@pisell/pisellos 2.3.77 → 2.3.79

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.
@@ -1062,6 +1062,137 @@ function buildBookingFromAvailabilitySelection(params) {
1062
1062
  } : {})
1063
1063
  });
1064
1064
  }
1065
+ var POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES = new Set(['past', 'booking_cutoff', 'resource_full', 'resource_unavailable', 'resource_capacity_exceeded',
1066
+ // A required group whose selected resource is outside its window is surfaced
1067
+ // as missing_resource at group level. Structural validation below still
1068
+ // rejects a genuinely missing selection.
1069
+ 'missing_resource']);
1070
+ function matchesForcedSelectionGroup(selection, group) {
1071
+ var hasGroupId = typeof selection.requirementGroupId === 'string' && selection.requirementGroupId.trim().length > 0;
1072
+ var hasFormId = selection.formId !== undefined && selection.formId !== null;
1073
+ if (!hasGroupId && !hasFormId) return false;
1074
+ if (hasGroupId && selection.requirementGroupId !== group.id) return false;
1075
+ if (hasFormId && !sameAvailabilityId(selection.formId, group.formId)) return false;
1076
+ return true;
1077
+ }
1078
+
1079
+ /**
1080
+ * POS may intentionally overbook a configured time/resource. Rebuild the
1081
+ * assignments from the submitted, structurally valid resource identities so
1082
+ * a full/unavailable option is not silently dropped by normal availability
1083
+ * evaluation. This deliberately ignores capacity, occupancy and resource
1084
+ * windows, while retaining product/group/resource identity and selection
1085
+ * cardinality checks.
1086
+ */
1087
+ function buildPosForcedAvailabilityAssignments(params) {
1088
+ var product = params.product,
1089
+ resources = params.resources,
1090
+ candidate = params.candidate,
1091
+ requirementSelections = params.requirementSelections,
1092
+ partySize = params.partySize;
1093
+ var groups = product.requirementGroups || [];
1094
+ var conflicts = [];
1095
+ var assignments = [];
1096
+ var selectionsByGroup = new Map();
1097
+ var addConflict = function addConflict(code, message) {
1098
+ var details = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
1099
+ return conflicts.push(_objectSpread({
1100
+ code: code,
1101
+ message: message,
1102
+ productId: candidate.productId,
1103
+ candidateKey: candidate.key
1104
+ }, details));
1105
+ };
1106
+ requirementSelections.forEach(function (selection) {
1107
+ var _group$min, _group$max;
1108
+ var matchedGroups = groups.filter(function (group) {
1109
+ return matchesForcedSelectionGroup(selection, group);
1110
+ });
1111
+ if (matchedGroups.length !== 1) {
1112
+ addConflict('invalid_requirement_group', '选择的资源组不属于当前商品', {
1113
+ requirementGroupId: selection.requirementGroupId,
1114
+ formId: selection.formId
1115
+ });
1116
+ return;
1117
+ }
1118
+ var group = matchedGroups[0];
1119
+ if (selectionsByGroup.has(group.id)) {
1120
+ addConflict('invalid_selection_count', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u88AB\u91CD\u590D\u63D0\u4EA4"), {
1121
+ requirementGroupId: group.id,
1122
+ formId: group.formId
1123
+ });
1124
+ return;
1125
+ }
1126
+ selectionsByGroup.set(group.id, selection);
1127
+ if (!Array.isArray(selection.resourceIds)) {
1128
+ addConflict('invalid_selection_count', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u7684\u8D44\u6E90\u9009\u62E9\u5FC5\u987B\u662F\u6570\u7EC4"), {
1129
+ requirementGroupId: group.id,
1130
+ formId: group.formId
1131
+ });
1132
+ return;
1133
+ }
1134
+ var selectedResourceIds = Array.from(new Map(selection.resourceIds.map(function (resourceId) {
1135
+ return [String(resourceId), resourceId];
1136
+ })).values());
1137
+ var required = group.required !== false;
1138
+ var min = Math.max(required ? 1 : 0, Number((_group$min = group.min) !== null && _group$min !== void 0 ? _group$min : required ? 1 : 0) || 0);
1139
+ var max = Math.max(min, Number((_group$max = group.max) !== null && _group$max !== void 0 ? _group$max : Math.max(min, 1)) || Math.max(min, 1));
1140
+ if (selectedResourceIds.length < min) {
1141
+ addConflict('missing_resource', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u7F3A\u5C11\u5DF2\u9009\u8D44\u6E90"), {
1142
+ requirementGroupId: group.id,
1143
+ formId: group.formId
1144
+ });
1145
+ return;
1146
+ }
1147
+ if (selectedResourceIds.length > max) {
1148
+ addConflict('invalid_selection_count', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u5DF2\u9009\u8D44\u6E90\u6570\u91CF\u8D85\u51FA\u4E0A\u9650"), {
1149
+ requirementGroupId: group.id,
1150
+ formId: group.formId
1151
+ });
1152
+ return;
1153
+ }
1154
+ selectedResourceIds.forEach(function (resourceId) {
1155
+ var _group$resourceIds2, _group$formId, _candidate$primarySch5, _candidate$primarySch6;
1156
+ var resource = resources.find(function (item) {
1157
+ return sameAvailabilityId(item.id, resourceId);
1158
+ });
1159
+ var belongsToGroup = Boolean(resource && !(group.formId !== undefined && resource.formId !== undefined && !sameAvailabilityId(group.formId, resource.formId)) && !((_group$resourceIds2 = group.resourceIds) !== null && _group$resourceIds2 !== void 0 && _group$resourceIds2.length && !group.resourceIds.some(function (id) {
1160
+ return sameAvailabilityId(id, resourceId);
1161
+ })));
1162
+ if (!resource || !belongsToGroup) {
1163
+ addConflict('resource_unavailable', "\u8D44\u6E90 ".concat(String(resourceId), " \u4E0D\u5C5E\u4E8E\u5F53\u524D\u5546\u54C1\u8D44\u6E90\u7EC4"), {
1164
+ requirementGroupId: group.id,
1165
+ formId: group.formId,
1166
+ resourceId: resourceId
1167
+ });
1168
+ return;
1169
+ }
1170
+ assignments.push({
1171
+ productId: product.id,
1172
+ resourceId: resourceId,
1173
+ formId: (_group$formId = group.formId) !== null && _group$formId !== void 0 ? _group$formId : resource.formId,
1174
+ startAt: candidate.bookingStartAt || candidate.startAt,
1175
+ endAt: candidate.bookingEndAt || candidate.endAt,
1176
+ capacityRequired: Math.max(1, partySize),
1177
+ scheduleId: (_candidate$primarySch5 = candidate.primaryScheduleRef) === null || _candidate$primarySch5 === void 0 ? void 0 : _candidate$primarySch5.scheduleId,
1178
+ timeSlotId: (_candidate$primarySch6 = candidate.primaryScheduleRef) === null || _candidate$primarySch6 === void 0 ? void 0 : _candidate$primarySch6.timeSlotId
1179
+ });
1180
+ });
1181
+ });
1182
+ groups.filter(function (group) {
1183
+ return group.required !== false;
1184
+ }).forEach(function (group) {
1185
+ if (selectionsByGroup.has(group.id)) return;
1186
+ addConflict('missing_resource', "\u8D44\u6E90\u7EC4 ".concat(group.id, " \u7F3A\u5C11\u5DF2\u9009\u8D44\u6E90"), {
1187
+ requirementGroupId: group.id,
1188
+ formId: group.formId
1189
+ });
1190
+ });
1191
+ return {
1192
+ assignments: assignments,
1193
+ conflicts: conflicts
1194
+ };
1195
+ }
1065
1196
  export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
1066
1197
  _inherits(UnifiedBookingSalesImpl, _BookingTicket);
1067
1198
  var _super = _createSuper(UnifiedBookingSalesImpl);
@@ -2034,34 +2165,69 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2034
2165
  }
2035
2166
  return getOpenData;
2036
2167
  }()
2168
+ /**
2169
+ * Load a resource policy without depending on the legacy appointmentBooking solution.
2170
+ */
2171
+ }, {
2172
+ key: "getProtocol",
2173
+ value: (function () {
2174
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(policyId) {
2175
+ var normalizedPolicyId, policyUrl;
2176
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2177
+ while (1) switch (_context13.prev = _context13.next) {
2178
+ case 0:
2179
+ normalizedPolicyId = String(policyId !== null && policyId !== void 0 ? policyId : '').trim();
2180
+ if (normalizedPolicyId) {
2181
+ _context13.next = 3;
2182
+ break;
2183
+ }
2184
+ throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
2185
+ case 3:
2186
+ policyUrl = 'shop-policy';
2187
+ if (this.otherParams.platform === 'kiosk' || this.otherParams.platform === 'pos' || this.otherParams.platform === 'shop') {
2188
+ policyUrl = 'policy';
2189
+ }
2190
+ return _context13.abrupt("return", this.request.get("/".concat(policyUrl, "/").concat(encodeURIComponent(normalizedPolicyId))));
2191
+ case 6:
2192
+ case "end":
2193
+ return _context13.stop();
2194
+ }
2195
+ }, _callee13, this);
2196
+ }));
2197
+ function getProtocol(_x8) {
2198
+ return _getProtocol.apply(this, arguments);
2199
+ }
2200
+ return getProtocol;
2201
+ }()
2037
2202
  /**
2038
2203
  * Loads the product catalog used by both UI and Planner. Schedule data is requested with each
2039
2204
  * product because session products carry their fixed intervals there.
2040
2205
  */
2206
+ )
2041
2207
  }, {
2042
2208
  key: "loadProducts",
2043
2209
  value: (function () {
2044
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2210
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
2045
2211
  var params,
2046
2212
  options,
2047
2213
  schedule_date,
2048
2214
  schedule_datetime,
2049
2215
  result,
2050
- _args13 = arguments;
2051
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2052
- while (1) switch (_context13.prev = _context13.next) {
2216
+ _args14 = arguments;
2217
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
2218
+ while (1) switch (_context14.prev = _context14.next) {
2053
2219
  case 0:
2054
- params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
2055
- options = _args13.length > 1 ? _args13[1] : undefined;
2220
+ params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
2221
+ options = _args14.length > 1 ? _args14[1] : undefined;
2056
2222
  if (this.store.products) {
2057
- _context13.next = 4;
2223
+ _context14.next = 4;
2058
2224
  break;
2059
2225
  }
2060
2226
  throw new Error('[UnifiedBookingSales] products 模块未初始化');
2061
2227
  case 4:
2062
2228
  schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
2063
2229
  schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
2064
- _context13.next = 8;
2230
+ _context14.next = 8;
2065
2231
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
2066
2232
  with_count: ['bundleGroup', 'optionGroup'],
2067
2233
  with_schedule: 1
@@ -2071,17 +2237,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2071
2237
  cacheId: this.cacheId
2072
2238
  }), options);
2073
2239
  case 8:
2074
- result = _context13.sent;
2240
+ result = _context14.sent;
2075
2241
  this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
2076
- _context13.next = 12;
2242
+ _context14.next = 12;
2077
2243
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
2078
2244
  case 12:
2079
- return _context13.abrupt("return", result);
2245
+ return _context14.abrupt("return", result);
2080
2246
  case 13:
2081
2247
  case "end":
2082
- return _context13.stop();
2248
+ return _context14.stop();
2083
2249
  }
2084
- }, _callee13, this);
2250
+ }, _callee14, this);
2085
2251
  }));
2086
2252
  function loadProducts() {
2087
2253
  return _loadProducts.apply(this, arguments);
@@ -2091,24 +2257,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2091
2257
  }, {
2092
2258
  key: "loadScheduleAvailableDate",
2093
2259
  value: (function () {
2094
- var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14(params) {
2095
- return _regeneratorRuntime().wrap(function _callee14$(_context14) {
2096
- while (1) switch (_context14.prev = _context14.next) {
2260
+ var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
2261
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2262
+ while (1) switch (_context15.prev = _context15.next) {
2097
2263
  case 0:
2098
2264
  if (this.store.schedule) {
2099
- _context14.next = 2;
2265
+ _context15.next = 2;
2100
2266
  break;
2101
2267
  }
2102
2268
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
2103
2269
  case 2:
2104
- return _context14.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
2270
+ return _context15.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
2105
2271
  case 3:
2106
2272
  case "end":
2107
- return _context14.stop();
2273
+ return _context15.stop();
2108
2274
  }
2109
- }, _callee14, this);
2275
+ }, _callee15, this);
2110
2276
  }));
2111
- function loadScheduleAvailableDate(_x8) {
2277
+ function loadScheduleAvailableDate(_x9) {
2112
2278
  return _loadScheduleAvailableDate.apply(this, arguments);
2113
2279
  }
2114
2280
  return loadScheduleAvailableDate;
@@ -2122,15 +2288,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2122
2288
  }, {
2123
2289
  key: "loadProductsByScheduleDate",
2124
2290
  value: (function () {
2125
- var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
2291
+ var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
2126
2292
  var _this$store$schedule$, _this$store$schedule, _this$store$schedule$2, _this$store$schedule2, _this$store$schedule$3, _this$store$schedule3, _this$store$schedule$4, _this$store$schedule4;
2127
2293
  var date, custom_page_id, channel, product_ids, productLoadParams, cachedDates, hasCachedDate, hasOtherProducts, scheduleDate, productIdFilter, availableProductIds, products, fallbackProducts, _iterator, _step, productId, result;
2128
- return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2129
- while (1) switch (_context15.prev = _context15.next) {
2294
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2295
+ while (1) switch (_context16.prev = _context16.next) {
2130
2296
  case 0:
2131
2297
  date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
2132
2298
  if (this.store.schedule) {
2133
- _context15.next = 3;
2299
+ _context16.next = 3;
2134
2300
  break;
2135
2301
  }
2136
2302
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
@@ -2141,10 +2307,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2141
2307
  });
2142
2308
  hasOtherProducts = (((_this$store$schedule$2 = (_this$store$schedule2 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$2 === void 0 ? void 0 : _this$store$schedule$2.call(_this$store$schedule2)) || []).length > 0;
2143
2309
  if (!(!hasCachedDate && !hasOtherProducts)) {
2144
- _context15.next = 9;
2310
+ _context16.next = 9;
2145
2311
  break;
2146
2312
  }
2147
- _context15.next = 9;
2313
+ _context16.next = 9;
2148
2314
  return this.loadScheduleAvailableDate({
2149
2315
  startDate: date,
2150
2316
  endDate: date,
@@ -2164,45 +2330,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2164
2330
  return !productIdFilter || productIdFilter.has(String(id));
2165
2331
  });
2166
2332
  if (availableProductIds.length) {
2167
- _context15.next = 17;
2333
+ _context16.next = 17;
2168
2334
  break;
2169
2335
  }
2170
2336
  this.unifiedProductCatalog = [];
2171
- _context15.next = 16;
2337
+ _context16.next = 16;
2172
2338
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
2173
2339
  case 16:
2174
- return _context15.abrupt("return", []);
2340
+ return _context16.abrupt("return", []);
2175
2341
  case 17:
2176
- _context15.next = 19;
2342
+ _context16.next = 19;
2177
2343
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
2178
2344
  product_ids: availableProductIds,
2179
2345
  schedule_date: date
2180
2346
  }));
2181
2347
  case 19:
2182
- products = _context15.sent;
2348
+ products = _context16.sent;
2183
2349
  if (!(products.length || availableProductIds.length <= 1)) {
2184
- _context15.next = 22;
2350
+ _context16.next = 22;
2185
2351
  break;
2186
2352
  }
2187
- return _context15.abrupt("return", products);
2353
+ return _context16.abrupt("return", products);
2188
2354
  case 22:
2189
2355
  fallbackProducts = [];
2190
2356
  _iterator = _createForOfIteratorHelper(availableProductIds);
2191
- _context15.prev = 24;
2357
+ _context16.prev = 24;
2192
2358
  _iterator.s();
2193
2359
  case 26:
2194
2360
  if ((_step = _iterator.n()).done) {
2195
- _context15.next = 34;
2361
+ _context16.next = 34;
2196
2362
  break;
2197
2363
  }
2198
2364
  productId = _step.value;
2199
- _context15.next = 30;
2365
+ _context16.next = 30;
2200
2366
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
2201
2367
  product_ids: [productId],
2202
2368
  schedule_date: date
2203
2369
  }));
2204
2370
  case 30:
2205
- result = _context15.sent;
2371
+ result = _context16.sent;
2206
2372
  result.forEach(function (product) {
2207
2373
  var _id;
2208
2374
  var id = (_id = product === null || product === void 0 ? void 0 : product.id) !== null && _id !== void 0 ? _id : product === null || product === void 0 ? void 0 : product.product_id;
@@ -2214,32 +2380,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2214
2380
  }
2215
2381
  });
2216
2382
  case 32:
2217
- _context15.next = 26;
2383
+ _context16.next = 26;
2218
2384
  break;
2219
2385
  case 34:
2220
- _context15.next = 39;
2386
+ _context16.next = 39;
2221
2387
  break;
2222
2388
  case 36:
2223
- _context15.prev = 36;
2224
- _context15.t0 = _context15["catch"](24);
2225
- _iterator.e(_context15.t0);
2389
+ _context16.prev = 36;
2390
+ _context16.t0 = _context16["catch"](24);
2391
+ _iterator.e(_context16.t0);
2226
2392
  case 39:
2227
- _context15.prev = 39;
2393
+ _context16.prev = 39;
2228
2394
  _iterator.f();
2229
- return _context15.finish(39);
2395
+ return _context16.finish(39);
2230
2396
  case 42:
2231
2397
  this.unifiedProductCatalog = [].concat(fallbackProducts);
2232
- _context15.next = 45;
2398
+ _context16.next = 45;
2233
2399
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
2234
2400
  case 45:
2235
- return _context15.abrupt("return", fallbackProducts);
2401
+ return _context16.abrupt("return", fallbackProducts);
2236
2402
  case 46:
2237
2403
  case "end":
2238
- return _context15.stop();
2404
+ return _context16.stop();
2239
2405
  }
2240
- }, _callee15, this, [[24, 36, 39, 42]]);
2406
+ }, _callee16, this, [[24, 36, 39, 42]]);
2241
2407
  }));
2242
- function loadProductsByScheduleDate(_x9) {
2408
+ function loadProductsByScheduleDate(_x10) {
2243
2409
  return _loadProductsByScheduleDate.apply(this, arguments);
2244
2410
  }
2245
2411
  return loadProductsByScheduleDate;
@@ -2292,7 +2458,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2292
2458
  }, {
2293
2459
  key: "applyPlannerDiscounts",
2294
2460
  value: (function () {
2295
- var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
2461
+ var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2296
2462
  var _params$customerId;
2297
2463
  var params,
2298
2464
  tempOrder,
@@ -2309,24 +2475,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2309
2475
  discount,
2310
2476
  discountId,
2311
2477
  nextTempOrder,
2312
- _args16 = arguments;
2313
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2314
- while (1) switch (_context16.prev = _context16.next) {
2478
+ _args17 = arguments;
2479
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2480
+ while (1) switch (_context17.prev = _context17.next) {
2315
2481
  case 0:
2316
- params = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
2482
+ params = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
2317
2483
  tempOrder = this.getTempOrder();
2318
2484
  requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
2319
2485
  parsedCustomerId = Number(requestedCustomerId);
2320
2486
  customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
2321
- _context16.next = 7;
2487
+ _context17.next = 7;
2322
2488
  return this.getSummary();
2323
2489
  case 7:
2324
- summaryBefore = _context16.sent;
2490
+ summaryBefore = _context17.sent;
2325
2491
  if (customerId) {
2326
- _context16.next = 10;
2492
+ _context17.next = 10;
2327
2493
  break;
2328
2494
  }
2329
- return _context16.abrupt("return", buildPlannerDiscountResult({
2495
+ return _context17.abrupt("return", buildPlannerDiscountResult({
2330
2496
  customerId: null,
2331
2497
  discountList: this.getDiscountList(),
2332
2498
  products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
@@ -2335,7 +2501,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2335
2501
  status: 'no_customer'
2336
2502
  }));
2337
2503
  case 10:
2338
- _context16.next = 12;
2504
+ _context17.next = 12;
2339
2505
  return this.loadDiscountConfig({
2340
2506
  customerId: customerId,
2341
2507
  action: 'create'
@@ -2347,7 +2513,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2347
2513
  return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
2348
2514
  });
2349
2515
  if (!preferredDiscount) {
2350
- _context16.next = 40;
2516
+ _context17.next = 40;
2351
2517
  break;
2352
2518
  }
2353
2519
  // A requested card is an explicit UI choice, not a best-effort preference. Clear prior
@@ -2359,98 +2525,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2359
2525
  return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
2360
2526
  });
2361
2527
  _iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
2362
- _context16.prev = 18;
2528
+ _context17.prev = 18;
2363
2529
  _iterator2.s();
2364
2530
  case 20:
2365
2531
  if ((_step2 = _iterator2.n()).done) {
2366
- _context16.next = 28;
2532
+ _context17.next = 28;
2367
2533
  break;
2368
2534
  }
2369
2535
  discount = _step2.value;
2370
2536
  discountId = Number(resolvePlannerDiscountId(discount));
2371
2537
  if (!Number.isFinite(discountId)) {
2372
- _context16.next = 26;
2538
+ _context17.next = 26;
2373
2539
  break;
2374
2540
  }
2375
- _context16.next = 26;
2541
+ _context17.next = 26;
2376
2542
  return this.setDiscountSelected({
2377
2543
  discountId: discountId,
2378
2544
  isSelected: false
2379
2545
  });
2380
2546
  case 26:
2381
- _context16.next = 20;
2547
+ _context17.next = 20;
2382
2548
  break;
2383
2549
  case 28:
2384
- _context16.next = 33;
2550
+ _context17.next = 33;
2385
2551
  break;
2386
2552
  case 30:
2387
- _context16.prev = 30;
2388
- _context16.t0 = _context16["catch"](18);
2389
- _iterator2.e(_context16.t0);
2553
+ _context17.prev = 30;
2554
+ _context17.t0 = _context17["catch"](18);
2555
+ _iterator2.e(_context17.t0);
2390
2556
  case 33:
2391
- _context16.prev = 33;
2557
+ _context17.prev = 33;
2392
2558
  _iterator2.f();
2393
- return _context16.finish(33);
2559
+ return _context17.finish(33);
2394
2560
  case 36:
2395
- _context16.next = 38;
2561
+ _context17.next = 38;
2396
2562
  return this.setDiscountSelected({
2397
2563
  discountId: Number(preferredId),
2398
2564
  isSelected: true
2399
2565
  });
2400
2566
  case 38:
2401
- _context16.next = 49;
2567
+ _context17.next = 49;
2402
2568
  break;
2403
2569
  case 40:
2404
2570
  if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
2405
- _context16.next = 46;
2571
+ _context17.next = 46;
2406
2572
  break;
2407
2573
  }
2408
2574
  if (!(params.applyBestDiscount !== false)) {
2409
- _context16.next = 44;
2575
+ _context17.next = 44;
2410
2576
  break;
2411
2577
  }
2412
- _context16.next = 44;
2578
+ _context17.next = 44;
2413
2579
  return this.bestDiscount();
2414
2580
  case 44:
2415
- _context16.next = 49;
2581
+ _context17.next = 49;
2416
2582
  break;
2417
2583
  case 46:
2418
2584
  if (!(params.applyBestDiscount !== false)) {
2419
- _context16.next = 49;
2585
+ _context17.next = 49;
2420
2586
  break;
2421
2587
  }
2422
- _context16.next = 49;
2588
+ _context17.next = 49;
2423
2589
  return this.bestDiscount();
2424
2590
  case 49:
2425
2591
  nextTempOrder = this.getTempOrder();
2426
- _context16.t1 = buildPlannerDiscountResult;
2427
- _context16.t2 = customerId;
2428
- _context16.t3 = this.getDiscountList();
2429
- _context16.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
2430
- _context16.t5 = summaryBefore;
2431
- _context16.next = 57;
2592
+ _context17.t1 = buildPlannerDiscountResult;
2593
+ _context17.t2 = customerId;
2594
+ _context17.t3 = this.getDiscountList();
2595
+ _context17.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
2596
+ _context17.t5 = summaryBefore;
2597
+ _context17.next = 57;
2432
2598
  return this.getSummary();
2433
2599
  case 57:
2434
- _context16.t6 = _context16.sent;
2435
- _context16.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
2436
- _context16.t8 = preferredDiscountId;
2437
- _context16.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
2438
- _context16.t10 = {
2439
- customerId: _context16.t2,
2440
- discountList: _context16.t3,
2441
- products: _context16.t4,
2442
- summaryBefore: _context16.t5,
2443
- summaryAfter: _context16.t6,
2444
- status: _context16.t7,
2445
- preferredDiscountId: _context16.t8,
2446
- preferredDiscountFound: _context16.t9
2600
+ _context17.t6 = _context17.sent;
2601
+ _context17.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
2602
+ _context17.t8 = preferredDiscountId;
2603
+ _context17.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
2604
+ _context17.t10 = {
2605
+ customerId: _context17.t2,
2606
+ discountList: _context17.t3,
2607
+ products: _context17.t4,
2608
+ summaryBefore: _context17.t5,
2609
+ summaryAfter: _context17.t6,
2610
+ status: _context17.t7,
2611
+ preferredDiscountId: _context17.t8,
2612
+ preferredDiscountFound: _context17.t9
2447
2613
  };
2448
- return _context16.abrupt("return", (0, _context16.t1)(_context16.t10));
2614
+ return _context17.abrupt("return", (0, _context17.t1)(_context17.t10));
2449
2615
  case 63:
2450
2616
  case "end":
2451
- return _context16.stop();
2617
+ return _context17.stop();
2452
2618
  }
2453
- }, _callee16, this, [[18, 30, 33, 36]]);
2619
+ }, _callee17, this, [[18, 30, 33, 36]]);
2454
2620
  }));
2455
2621
  function applyPlannerDiscounts() {
2456
2622
  return _applyPlannerDiscounts.apply(this, arguments);
@@ -2460,23 +2626,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2460
2626
  }, {
2461
2627
  key: "buildUnifiedOrderProduct",
2462
2628
  value: function buildUnifiedOrderProduct(sourceProduct, ownershipKey, product) {
2463
- var _sourceProduct$id, _ref33, _sourceProduct$produc, _ref34, _ref35, _sourceProduct$quanti, _sourceProduct$price, _ref36, _ref37, _sourceProduct$sellin;
2629
+ var _ref33, _sourceProduct$_exten, _sourceProduct$_exten2, _sourceProduct$metada, _sourceProduct$id, _ref34, _sourceProduct$produc, _ref35, _ref36, _sourceProduct$quanti, _sourceProduct$price, _ref37, _ref38, _sourceProduct$sellin;
2464
2630
  var normalizedProductRaw = (product === null || product === void 0 ? void 0 : product.raw) || {};
2631
+ var quotationShelfId = (_ref33 = (_sourceProduct$_exten = (_sourceProduct$_exten2 = sourceProduct._extend) === null || _sourceProduct$_exten2 === void 0 ? void 0 : _sourceProduct$_exten2.quotation_shelf_id) !== null && _sourceProduct$_exten !== void 0 ? _sourceProduct$_exten : sourceProduct.quotation_shelf_id) !== null && _ref33 !== void 0 ? _ref33 : (_sourceProduct$metada = sourceProduct.metadata) === null || _sourceProduct$metada === void 0 ? void 0 : _sourceProduct$metada.quotation_shelf_id;
2465
2632
  var orderProduct = this.transformBaseProductToOrderProduct({
2466
2633
  payload: _objectSpread(_objectSpread({}, sourceProduct), {}, {
2467
2634
  id: (_sourceProduct$id = sourceProduct.id) !== null && _sourceProduct$id !== void 0 ? _sourceProduct$id : product === null || product === void 0 ? void 0 : product.id,
2468
- product_id: (_ref33 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref33 !== void 0 ? _ref33 : product === null || product === void 0 ? void 0 : product.id,
2469
- quantity: (_ref34 = (_ref35 = (_sourceProduct$quanti = sourceProduct.quantity) !== null && _sourceProduct$quanti !== void 0 ? _sourceProduct$quanti : sourceProduct.num) !== null && _ref35 !== void 0 ? _ref35 : product === null || product === void 0 ? void 0 : product.quantity) !== null && _ref34 !== void 0 ? _ref34 : 1,
2635
+ product_id: (_ref34 = (_sourceProduct$produc = sourceProduct.product_id) !== null && _sourceProduct$produc !== void 0 ? _sourceProduct$produc : sourceProduct.id) !== null && _ref34 !== void 0 ? _ref34 : product === null || product === void 0 ? void 0 : product.id,
2636
+ quantity: (_ref35 = (_ref36 = (_sourceProduct$quanti = sourceProduct.quantity) !== null && _sourceProduct$quanti !== void 0 ? _sourceProduct$quanti : sourceProduct.num) !== null && _ref36 !== void 0 ? _ref36 : product === null || product === void 0 ? void 0 : product.quantity) !== null && _ref35 !== void 0 ? _ref35 : 1,
2470
2637
  price: (_sourceProduct$price = sourceProduct.price) !== null && _sourceProduct$price !== void 0 ? _sourceProduct$price : normalizedProductRaw.price,
2471
- selling_price: (_ref36 = (_ref37 = (_sourceProduct$sellin = sourceProduct.selling_price) !== null && _sourceProduct$sellin !== void 0 ? _sourceProduct$sellin : sourceProduct.price) !== null && _ref37 !== void 0 ? _ref37 : normalizedProductRaw.selling_price) !== null && _ref36 !== void 0 ? _ref36 : normalizedProductRaw.price,
2638
+ selling_price: (_ref37 = (_ref38 = (_sourceProduct$sellin = sourceProduct.selling_price) !== null && _sourceProduct$sellin !== void 0 ? _sourceProduct$sellin : sourceProduct.price) !== null && _ref38 !== void 0 ? _ref38 : normalizedProductRaw.selling_price) !== null && _ref37 !== void 0 ? _ref37 : normalizedProductRaw.price,
2472
2639
  metadata: _objectSpread(_objectSpread({}, sourceProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true))
2473
2640
  }),
2474
2641
  sourceProduct: sourceProduct
2475
2642
  });
2476
2643
  if (orderProduct && _typeof(orderProduct) === 'object') {
2477
- // BaseSales may rebuild metadata from its price source. Stamp ownership after that transform
2478
- // so each UnifiedBookingSales entry point can replace only its own temporary lines.
2479
- orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true));
2644
+ // BaseSales may rebuild metadata from its price source. Stamp ownership and the selected
2645
+ // quotation shelf after that transform so neither booking adds nor edits lose quote identity.
2646
+ orderProduct.metadata = _objectSpread(_objectSpread({}, orderProduct.metadata || {}), {}, _defineProperty({}, ownershipKey, true), quotationShelfId !== undefined ? {
2647
+ quotation_shelf_id: quotationShelfId
2648
+ } : {});
2480
2649
  }
2481
2650
  return orderProduct;
2482
2651
  }
@@ -2485,29 +2654,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2485
2654
  }, {
2486
2655
  key: "removeExistingStagedLines",
2487
2656
  value: (function () {
2488
- var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(ownershipKey) {
2657
+ var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ownershipKey) {
2489
2658
  var _this$getTempOrder;
2490
2659
  var existingLines;
2491
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2492
- while (1) switch (_context17.prev = _context17.next) {
2660
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2661
+ while (1) switch (_context18.prev = _context18.next) {
2493
2662
  case 0:
2494
2663
  existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
2495
2664
  var _product$metadata4;
2496
2665
  return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
2497
2666
  });
2498
2667
  if (!(existingLines.length > 0)) {
2499
- _context17.next = 4;
2668
+ _context18.next = 4;
2500
2669
  break;
2501
2670
  }
2502
- _context17.next = 4;
2671
+ _context18.next = 4;
2503
2672
  return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
2504
2673
  case 4:
2505
2674
  case "end":
2506
- return _context17.stop();
2675
+ return _context18.stop();
2507
2676
  }
2508
- }, _callee17, this);
2677
+ }, _callee18, this);
2509
2678
  }));
2510
- function removeExistingStagedLines(_x10) {
2679
+ function removeExistingStagedLines(_x11) {
2511
2680
  return _removeExistingStagedLines.apply(this, arguments);
2512
2681
  }
2513
2682
  return removeExistingStagedLines;
@@ -2515,25 +2684,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2515
2684
  }, {
2516
2685
  key: "stageProducts",
2517
2686
  value: function () {
2518
- var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params, ownershipKey) {
2687
+ var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params, ownershipKey) {
2519
2688
  var _params$rawProducts;
2520
2689
  var productIds, existingIds, missingIds, productIdSet, selectedProducts, _i, _arr, sourceProduct, productInput;
2521
- return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2522
- while (1) switch (_context18.prev = _context18.next) {
2690
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2691
+ while (1) switch (_context19.prev = _context19.next) {
2523
2692
  case 0:
2524
2693
  productIds = params.productIds || [];
2525
2694
  if (productIds.length) {
2526
- _context18.next = 3;
2695
+ _context19.next = 3;
2527
2696
  break;
2528
2697
  }
2529
- return _context18.abrupt("return", this.getTempOrder());
2698
+ return _context19.abrupt("return", this.getTempOrder());
2530
2699
  case 3:
2531
2700
  if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
2532
- _context18.next = 7;
2701
+ _context19.next = 7;
2533
2702
  break;
2534
2703
  }
2535
2704
  this.unifiedProductCatalog = params.rawProducts;
2536
- _context18.next = 12;
2705
+ _context19.next = 12;
2537
2706
  break;
2538
2707
  case 7:
2539
2708
  existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
@@ -2544,15 +2713,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2544
2713
  return !existingIds.has(String(id));
2545
2714
  });
2546
2715
  if (!(missingIds.length || params.productLoadParams)) {
2547
- _context18.next = 12;
2716
+ _context19.next = 12;
2548
2717
  break;
2549
2718
  }
2550
- _context18.next = 12;
2719
+ _context19.next = 12;
2551
2720
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
2552
2721
  product_ids: productIds.map(Number).filter(Number.isFinite)
2553
2722
  }));
2554
2723
  case 12:
2555
- _context18.next = 14;
2724
+ _context19.next = 14;
2556
2725
  return this.removeExistingStagedLines(ownershipKey);
2557
2726
  case 14:
2558
2727
  productIdSet = new Set(productIds.map(function (id) {
@@ -2565,30 +2734,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2565
2734
  _i = 0, _arr = selectedProducts;
2566
2735
  case 17:
2567
2736
  if (!(_i < _arr.length)) {
2568
- _context18.next = 26;
2737
+ _context19.next = 26;
2569
2738
  break;
2570
2739
  }
2571
2740
  sourceProduct = _arr[_i];
2572
2741
  productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
2573
2742
  if (!productInput) {
2574
- _context18.next = 23;
2743
+ _context19.next = 23;
2575
2744
  break;
2576
2745
  }
2577
- _context18.next = 23;
2746
+ _context19.next = 23;
2578
2747
  return this.addProductToOrder(productInput);
2579
2748
  case 23:
2580
2749
  _i++;
2581
- _context18.next = 17;
2750
+ _context19.next = 17;
2582
2751
  break;
2583
2752
  case 26:
2584
- return _context18.abrupt("return", this.getTempOrder());
2753
+ return _context19.abrupt("return", this.getTempOrder());
2585
2754
  case 27:
2586
2755
  case "end":
2587
- return _context18.stop();
2756
+ return _context19.stop();
2588
2757
  }
2589
- }, _callee18, this);
2758
+ }, _callee19, this);
2590
2759
  }));
2591
- function stageProducts(_x11, _x12) {
2760
+ function stageProducts(_x12, _x13) {
2592
2761
  return _stageProducts.apply(this, arguments);
2593
2762
  }
2594
2763
  return stageProducts;
@@ -2600,18 +2769,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2600
2769
  }, {
2601
2770
  key: "stageRetailProducts",
2602
2771
  value: (function () {
2603
- var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params) {
2604
- return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2605
- while (1) switch (_context19.prev = _context19.next) {
2772
+ var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2773
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2774
+ while (1) switch (_context20.prev = _context20.next) {
2606
2775
  case 0:
2607
- return _context19.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
2776
+ return _context20.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
2608
2777
  case 1:
2609
2778
  case "end":
2610
- return _context19.stop();
2779
+ return _context20.stop();
2611
2780
  }
2612
- }, _callee19, this);
2781
+ }, _callee20, this);
2613
2782
  }));
2614
- function stageRetailProducts(_x13) {
2783
+ function stageRetailProducts(_x14) {
2615
2784
  return _stageRetailProducts.apply(this, arguments);
2616
2785
  }
2617
2786
  return stageRetailProducts;
@@ -2625,20 +2794,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2625
2794
  }, {
2626
2795
  key: "addRetailProduct",
2627
2796
  value: (function () {
2628
- var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2629
- var _params$quantity, _ref38, _params$productId, _params$product, _params$product2;
2797
+ var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2798
+ var _params$quantity, _ref39, _params$productId, _params$product, _params$product2;
2630
2799
  var quantity, productId, sourceProduct, products, orderProduct;
2631
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2632
- while (1) switch (_context20.prev = _context20.next) {
2800
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2801
+ while (1) switch (_context21.prev = _context21.next) {
2633
2802
  case 0:
2634
2803
  quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
2635
2804
  if (!(!Number.isFinite(quantity) || quantity <= 0)) {
2636
- _context20.next = 3;
2805
+ _context21.next = 3;
2637
2806
  break;
2638
2807
  }
2639
2808
  throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
2640
2809
  case 3:
2641
- productId = (_ref38 = (_params$productId = params.productId) !== null && _params$productId !== void 0 ? _params$productId : (_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.id) !== null && _ref38 !== void 0 ? _ref38 : (_params$product2 = params.product) === null || _params$product2 === void 0 ? void 0 : _params$product2.product_id;
2810
+ productId = (_ref39 = (_params$productId = params.productId) !== null && _params$productId !== void 0 ? _params$productId : (_params$product = params.product) === null || _params$product === void 0 ? void 0 : _params$product.id) !== null && _ref39 !== void 0 ? _ref39 : (_params$product2 = params.product) === null || _params$product2 === void 0 ? void 0 : _params$product2.product_id;
2642
2811
  sourceProduct = params.product;
2643
2812
  if (!sourceProduct && productId !== undefined && productId !== null) {
2644
2813
  sourceProduct = this.unifiedProductCatalog.find(function (product) {
@@ -2647,22 +2816,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2647
2816
  });
2648
2817
  }
2649
2818
  if (!(!sourceProduct && productId !== undefined && productId !== null)) {
2650
- _context20.next = 11;
2819
+ _context21.next = 11;
2651
2820
  break;
2652
2821
  }
2653
- _context20.next = 9;
2822
+ _context21.next = 9;
2654
2823
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
2655
2824
  product_ids: [Number(productId)].filter(Number.isFinite)
2656
2825
  }));
2657
2826
  case 9:
2658
- products = _context20.sent;
2827
+ products = _context21.sent;
2659
2828
  sourceProduct = products.find(function (product) {
2660
2829
  var _product$id4;
2661
2830
  return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
2662
2831
  });
2663
2832
  case 11:
2664
2833
  if (sourceProduct) {
2665
- _context20.next = 13;
2834
+ _context21.next = 13;
2666
2835
  break;
2667
2836
  }
2668
2837
  throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
@@ -2671,19 +2840,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2671
2840
  quantity: quantity
2672
2841
  }), 'unified_booking_sales_retail');
2673
2842
  if (orderProduct) {
2674
- _context20.next = 16;
2843
+ _context21.next = 16;
2675
2844
  break;
2676
2845
  }
2677
2846
  throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
2678
2847
  case 16:
2679
- return _context20.abrupt("return", this.addProductToOrder(orderProduct));
2848
+ return _context21.abrupt("return", this.addProductToOrder(orderProduct));
2680
2849
  case 17:
2681
2850
  case "end":
2682
- return _context20.stop();
2851
+ return _context21.stop();
2683
2852
  }
2684
- }, _callee20, this);
2853
+ }, _callee21, this);
2685
2854
  }));
2686
- function addRetailProduct(_x14) {
2855
+ function addRetailProduct(_x15) {
2687
2856
  return _addRetailProduct.apply(this, arguments);
2688
2857
  }
2689
2858
  return addRetailProduct;
@@ -2848,46 +3017,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2848
3017
  }, {
2849
3018
  key: "loadAvailabilityProducts",
2850
3019
  value: function () {
2851
- var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
3020
+ var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2852
3021
  var _prepare$catalogScope,
2853
3022
  _prepare$catalogScope2,
2854
3023
  _this4 = this,
2855
3024
  _prepare$resourceIds;
2856
3025
  var prepare, dateRange, explicitProductIds, rawProducts, _this$store$schedule$6, _this$store$schedule6, _this$store$schedule$7, _this$store$schedule7, dateSet, scheduleProductIds, productIds, normalized, productIdSet;
2857
- return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2858
- while (1) switch (_context21.prev = _context21.next) {
3026
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
3027
+ while (1) switch (_context22.prev = _context22.next) {
2859
3028
  case 0:
2860
3029
  prepare = params.prepare, dateRange = params.dateRange;
2861
3030
  explicitProductIds = prepare.productIds || [];
2862
3031
  rawProducts = [];
2863
3032
  if (!Array.isArray(prepare.rawProducts)) {
2864
- _context21.next = 8;
3033
+ _context22.next = 8;
2865
3034
  break;
2866
3035
  }
2867
3036
  rawProducts = prepare.rawProducts;
2868
3037
  this.unifiedProductCatalog = _toConsumableArray(rawProducts);
2869
- _context21.next = 34;
3038
+ _context22.next = 34;
2870
3039
  break;
2871
3040
  case 8:
2872
3041
  if (!(explicitProductIds.length > 0)) {
2873
- _context21.next = 14;
3042
+ _context22.next = 14;
2874
3043
  break;
2875
3044
  }
2876
- _context21.next = 11;
3045
+ _context22.next = 11;
2877
3046
  return this.loadProducts({
2878
3047
  product_ids: explicitProductIds,
2879
3048
  schedule_date: dateRange.startDate
2880
3049
  });
2881
3050
  case 11:
2882
- rawProducts = _context21.sent;
2883
- _context21.next = 34;
3051
+ rawProducts = _context22.sent;
3052
+ _context22.next = 34;
2884
3053
  break;
2885
3054
  case 14:
2886
3055
  if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
2887
- _context21.next = 30;
3056
+ _context22.next = 30;
2888
3057
  break;
2889
3058
  }
2890
- _context21.next = 17;
3059
+ _context22.next = 17;
2891
3060
  return this.loadScheduleAvailableDate({
2892
3061
  startDate: dateRange.startDate,
2893
3062
  endDate: dateRange.endDate,
@@ -2903,48 +3072,48 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2903
3072
  });
2904
3073
  productIds = uniqueAvailabilityIds([].concat(_toConsumableArray(scheduleProductIds), _toConsumableArray(((_this$store$schedule$7 = (_this$store$schedule7 = this.store.schedule).getOtherProductsIds) === null || _this$store$schedule$7 === void 0 ? void 0 : _this$store$schedule$7.call(_this$store$schedule7)) || [])));
2905
3074
  if (!(productIds.length > 0)) {
2906
- _context21.next = 27;
3075
+ _context22.next = 27;
2907
3076
  break;
2908
3077
  }
2909
3078
  assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
2910
- _context21.next = 24;
3079
+ _context22.next = 24;
2911
3080
  return this.loadProducts({
2912
3081
  product_ids: productIds,
2913
3082
  schedule_date: dateRange.startDate
2914
3083
  });
2915
3084
  case 24:
2916
- rawProducts = _context21.sent;
2917
- _context21.next = 28;
3085
+ rawProducts = _context22.sent;
3086
+ _context22.next = 28;
2918
3087
  break;
2919
3088
  case 27:
2920
3089
  this.unifiedProductCatalog = [];
2921
3090
  case 28:
2922
- _context21.next = 34;
3091
+ _context22.next = 34;
2923
3092
  break;
2924
3093
  case 30:
2925
3094
  if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
2926
- _context21.next = 34;
3095
+ _context22.next = 34;
2927
3096
  break;
2928
3097
  }
2929
- _context21.next = 33;
3098
+ _context22.next = 33;
2930
3099
  return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
2931
3100
  schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
2932
3101
  }));
2933
3102
  case 33:
2934
- rawProducts = _context21.sent;
3103
+ rawProducts = _context22.sent;
2935
3104
  case 34:
2936
3105
  normalized = rawProducts.map(function (product) {
2937
3106
  return normalizeProductForAvailability(product, params.scheduleList, _this4.getAvailabilityRuntimeOffsetMinutes());
2938
3107
  });
2939
3108
  if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
2940
- _context21.next = 37;
3109
+ _context22.next = 37;
2941
3110
  break;
2942
3111
  }
2943
- return _context21.abrupt("return", normalized.filter(function (product) {
3112
+ return _context22.abrupt("return", normalized.filter(function (product) {
2944
3113
  var _product$requirementG2;
2945
3114
  return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
2946
- var _group$resourceIds2;
2947
- return (_group$resourceIds2 = group.resourceIds) === null || _group$resourceIds2 === void 0 ? void 0 : _group$resourceIds2.some(function (resourceId) {
3115
+ var _group$resourceIds3;
3116
+ return (_group$resourceIds3 = group.resourceIds) === null || _group$resourceIds3 === void 0 ? void 0 : _group$resourceIds3.some(function (resourceId) {
2948
3117
  return prepare.resourceIds.some(function (id) {
2949
3118
  return sameAvailabilityId(id, resourceId);
2950
3119
  });
@@ -2953,16 +3122,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2953
3122
  }));
2954
3123
  case 37:
2955
3124
  productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
2956
- return _context21.abrupt("return", productIdSet ? normalized.filter(function (product) {
3125
+ return _context22.abrupt("return", productIdSet ? normalized.filter(function (product) {
2957
3126
  return productIdSet.has(String(product.id));
2958
3127
  }) : normalized);
2959
3128
  case 39:
2960
3129
  case "end":
2961
- return _context21.stop();
3130
+ return _context22.stop();
2962
3131
  }
2963
- }, _callee21, this);
3132
+ }, _callee22, this);
2964
3133
  }));
2965
- function loadAvailabilityProducts(_x15) {
3134
+ function loadAvailabilityProducts(_x16) {
2966
3135
  return _loadAvailabilityProducts.apply(this, arguments);
2967
3136
  }
2968
3137
  return loadAvailabilityProducts;
@@ -2975,12 +3144,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2975
3144
  }, {
2976
3145
  key: "fetchAvailabilityResourcesV2",
2977
3146
  value: (function () {
2978
- var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
3147
+ var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2979
3148
  var response, data;
2980
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2981
- while (1) switch (_context22.prev = _context22.next) {
3149
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3150
+ while (1) switch (_context23.prev = _context23.next) {
2982
3151
  case 0:
2983
- _context22.next = 2;
3152
+ _context23.next = 2;
2984
3153
  return this.request.get('/schedule/resource/list/v2', {
2985
3154
  start_date: params.dateRange.startDate,
2986
3155
  end_date: params.dateRange.endDate,
@@ -2990,28 +3159,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2990
3159
  useCache: false
2991
3160
  });
2992
3161
  case 2:
2993
- response = _context22.sent;
3162
+ response = _context23.sent;
2994
3163
  data = response === null || response === void 0 ? void 0 : response.data;
2995
3164
  if (!Array.isArray(data)) {
2996
- _context22.next = 6;
3165
+ _context23.next = 6;
2997
3166
  break;
2998
3167
  }
2999
- return _context22.abrupt("return", data);
3168
+ return _context23.abrupt("return", data);
3000
3169
  case 6:
3001
3170
  if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
3002
- _context22.next = 8;
3171
+ _context23.next = 8;
3003
3172
  break;
3004
3173
  }
3005
- return _context22.abrupt("return", data.list);
3174
+ return _context23.abrupt("return", data.list);
3006
3175
  case 8:
3007
- return _context22.abrupt("return", []);
3176
+ return _context23.abrupt("return", []);
3008
3177
  case 9:
3009
3178
  case "end":
3010
- return _context22.stop();
3179
+ return _context23.stop();
3011
3180
  }
3012
- }, _callee22, this);
3181
+ }, _callee23, this);
3013
3182
  }));
3014
- function fetchAvailabilityResourcesV2(_x16) {
3183
+ function fetchAvailabilityResourcesV2(_x17) {
3015
3184
  return _fetchAvailabilityResourcesV.apply(this, arguments);
3016
3185
  }
3017
3186
  return fetchAvailabilityResourcesV2;
@@ -3019,17 +3188,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3019
3188
  }, {
3020
3189
  key: "fetchAndPublishAvailabilityResourcesV2",
3021
3190
  value: function () {
3022
- var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
3191
+ var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
3023
3192
  var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
3024
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3025
- while (1) switch (_context23.prev = _context23.next) {
3193
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3194
+ while (1) switch (_context24.prev = _context24.next) {
3026
3195
  case 0:
3027
3196
  normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
3028
3197
  if (!(normalizedResourceIds.length === 0)) {
3029
- _context23.next = 3;
3198
+ _context24.next = 3;
3030
3199
  break;
3031
3200
  }
3032
- return _context23.abrupt("return", []);
3201
+ return _context24.abrupt("return", []);
3033
3202
  case 3:
3034
3203
  scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
3035
3204
  cacheParams = {
@@ -3039,7 +3208,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3039
3208
  };
3040
3209
  cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
3041
3210
  if (!cachedRawResources) {
3042
- _context23.next = 9;
3211
+ _context24.next = 9;
3043
3212
  break;
3044
3213
  }
3045
3214
  if (params.useCacheOnHit) {
@@ -3051,23 +3220,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3051
3220
  console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
3052
3221
  });
3053
3222
  }
3054
- return _context23.abrupt("return", cachedRawResources);
3223
+ return _context24.abrupt("return", cachedRawResources);
3055
3224
  case 9:
3056
- _context23.next = 11;
3225
+ _context24.next = 11;
3057
3226
  return this.refreshAvailabilityRemoteResourceQuery({
3058
3227
  timezone: params.timezone,
3059
3228
  dateRange: params.dateRange,
3060
3229
  resourceIds: normalizedResourceIds
3061
3230
  });
3062
3231
  case 11:
3063
- return _context23.abrupt("return", _context23.sent);
3232
+ return _context24.abrupt("return", _context24.sent);
3064
3233
  case 12:
3065
3234
  case "end":
3066
- return _context23.stop();
3235
+ return _context24.stop();
3067
3236
  }
3068
- }, _callee23, this);
3237
+ }, _callee24, this);
3069
3238
  }));
3070
- function fetchAndPublishAvailabilityResourcesV2(_x17) {
3239
+ function fetchAndPublishAvailabilityResourcesV2(_x18) {
3071
3240
  return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
3072
3241
  }
3073
3242
  return fetchAndPublishAvailabilityResourcesV2;
@@ -3075,17 +3244,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3075
3244
  }, {
3076
3245
  key: "refreshAvailabilityRemoteResourceQuery",
3077
3246
  value: function () {
3078
- var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
3247
+ var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3079
3248
  var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
3080
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3081
- while (1) switch (_context24.prev = _context24.next) {
3249
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3250
+ while (1) switch (_context25.prev = _context25.next) {
3082
3251
  case 0:
3083
3252
  normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
3084
3253
  if (!(normalizedResourceIds.length === 0)) {
3085
- _context24.next = 3;
3254
+ _context25.next = 3;
3086
3255
  break;
3087
3256
  }
3088
- return _context24.abrupt("return", []);
3257
+ return _context25.abrupt("return", []);
3089
3258
  case 3:
3090
3259
  queryKey = this.buildAvailabilityRemoteResourceQueryKey({
3091
3260
  timezone: params.timezone,
@@ -3095,13 +3264,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3095
3264
  epoch = this.availabilityRemoteResourceEpoch;
3096
3265
  existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3097
3266
  if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
3098
- _context24.next = 10;
3267
+ _context25.next = 10;
3099
3268
  break;
3100
3269
  }
3101
- _context24.next = 9;
3270
+ _context25.next = 9;
3102
3271
  return existing.promise;
3103
3272
  case 9:
3104
- return _context24.abrupt("return", _context24.sent);
3273
+ return _context25.abrupt("return", _context25.sent);
3105
3274
  case 10:
3106
3275
  this.availabilityRemoteResourceQuerySequence += 1;
3107
3276
  writeVersion = this.availabilityRemoteResourceQuerySequence;
@@ -3113,11 +3282,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3113
3282
  epoch: epoch,
3114
3283
  promise: promise
3115
3284
  });
3116
- _context24.prev = 14;
3117
- _context24.next = 17;
3285
+ _context25.prev = 14;
3286
+ _context25.next = 17;
3118
3287
  return promise;
3119
3288
  case 17:
3120
- rawResources = _context24.sent;
3289
+ rawResources = _context25.sent;
3121
3290
  if (epoch === this.availabilityRemoteResourceEpoch) {
3122
3291
  this.availabilityRemoteOccupancyCache.publish({
3123
3292
  scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
@@ -3128,21 +3297,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3128
3297
  version: writeVersion
3129
3298
  });
3130
3299
  }
3131
- return _context24.abrupt("return", rawResources);
3300
+ return _context25.abrupt("return", rawResources);
3132
3301
  case 20:
3133
- _context24.prev = 20;
3302
+ _context25.prev = 20;
3134
3303
  current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3135
3304
  if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
3136
3305
  this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
3137
3306
  }
3138
- return _context24.finish(20);
3307
+ return _context25.finish(20);
3139
3308
  case 24:
3140
3309
  case "end":
3141
- return _context24.stop();
3310
+ return _context25.stop();
3142
3311
  }
3143
- }, _callee24, this, [[14,, 20, 24]]);
3312
+ }, _callee25, this, [[14,, 20, 24]]);
3144
3313
  }));
3145
- function refreshAvailabilityRemoteResourceQuery(_x18) {
3314
+ function refreshAvailabilityRemoteResourceQuery(_x19) {
3146
3315
  return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
3147
3316
  }
3148
3317
  return refreshAvailabilityRemoteResourceQuery;
@@ -3150,26 +3319,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3150
3319
  }, {
3151
3320
  key: "loadAvailabilityResources",
3152
3321
  value: function () {
3153
- var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3322
+ var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
3154
3323
  var resourceIds, cachedRawResources, rawResources;
3155
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3156
- while (1) switch (_context25.prev = _context25.next) {
3324
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3325
+ while (1) switch (_context26.prev = _context26.next) {
3157
3326
  case 0:
3158
3327
  resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
3159
3328
  if (!(resourceIds.length === 0)) {
3160
- _context25.next = 3;
3329
+ _context26.next = 3;
3161
3330
  break;
3162
3331
  }
3163
- return _context25.abrupt("return", {
3332
+ return _context26.abrupt("return", {
3164
3333
  resources: [],
3165
3334
  resourceOccupancies: []
3166
3335
  });
3167
3336
  case 3:
3168
3337
  if (!Array.isArray(params.rawResources)) {
3169
- _context25.next = 5;
3338
+ _context26.next = 5;
3170
3339
  break;
3171
3340
  }
3172
- return _context25.abrupt("return", buildAvailabilityResourcesFromV2({
3341
+ return _context26.abrupt("return", buildAvailabilityResourcesFromV2({
3173
3342
  rawResources: params.rawResources,
3174
3343
  scheduleList: params.scheduleList,
3175
3344
  dateRange: params.dateRange,
@@ -3177,7 +3346,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3177
3346
  }));
3178
3347
  case 5:
3179
3348
  if (!(params.fetchPolicy === 'cache_only')) {
3180
- _context25.next = 10;
3349
+ _context26.next = 10;
3181
3350
  break;
3182
3351
  }
3183
3352
  cachedRawResources = this.availabilityRemoteOccupancyCache.read({
@@ -3186,22 +3355,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3186
3355
  dateRange: params.dateRange
3187
3356
  });
3188
3357
  if (!cachedRawResources) {
3189
- _context25.next = 9;
3358
+ _context26.next = 9;
3190
3359
  break;
3191
3360
  }
3192
- return _context25.abrupt("return", buildAvailabilityResourcesFromV2({
3361
+ return _context26.abrupt("return", buildAvailabilityResourcesFromV2({
3193
3362
  rawResources: cachedRawResources,
3194
3363
  scheduleList: params.scheduleList,
3195
3364
  dateRange: params.dateRange,
3196
3365
  fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
3197
3366
  }));
3198
3367
  case 9:
3199
- return _context25.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
3368
+ return _context26.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
3200
3369
  resources: [],
3201
3370
  resourceOccupancies: []
3202
3371
  });
3203
3372
  case 10:
3204
- _context25.next = 12;
3373
+ _context26.next = 12;
3205
3374
  return this.fetchAndPublishAvailabilityResourcesV2({
3206
3375
  timezone: params.timezone,
3207
3376
  dateRange: params.dateRange,
@@ -3209,8 +3378,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3209
3378
  useCacheOnHit: true
3210
3379
  });
3211
3380
  case 12:
3212
- rawResources = _context25.sent;
3213
- return _context25.abrupt("return", buildAvailabilityResourcesFromV2({
3381
+ rawResources = _context26.sent;
3382
+ return _context26.abrupt("return", buildAvailabilityResourcesFromV2({
3214
3383
  rawResources: rawResources,
3215
3384
  scheduleList: params.scheduleList,
3216
3385
  dateRange: params.dateRange,
@@ -3218,11 +3387,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3218
3387
  }));
3219
3388
  case 14:
3220
3389
  case "end":
3221
- return _context25.stop();
3390
+ return _context26.stop();
3222
3391
  }
3223
- }, _callee25, this);
3392
+ }, _callee26, this);
3224
3393
  }));
3225
- function loadAvailabilityResources(_x19) {
3394
+ function loadAvailabilityResources(_x20) {
3226
3395
  return _loadAvailabilityResources.apply(this, arguments);
3227
3396
  }
3228
3397
  return loadAvailabilityResources;
@@ -3242,7 +3411,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3242
3411
  var products = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) ? tempOrder.products : [];
3243
3412
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
3244
3413
  productLineUids.forEach(function (requestedUid) {
3245
- var _ref39, _product$booking_uid2, _product$metadata5;
3414
+ var _ref40, _product$booking_uid2, _product$metadata5;
3246
3415
  var product = products.find(function (line) {
3247
3416
  return getProductLineUid(line) === String(requestedUid);
3248
3417
  });
@@ -3252,7 +3421,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3252
3421
  });
3253
3422
  }
3254
3423
  var productUid = getProductLineUid(product);
3255
- var linkedBookingUid = String((_ref39 = (_product$booking_uid2 = product.booking_uid) !== null && _product$booking_uid2 !== void 0 ? _product$booking_uid2 : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid) !== null && _ref39 !== void 0 ? _ref39 : '');
3424
+ var linkedBookingUid = String((_ref40 = (_product$booking_uid2 = product.booking_uid) !== null && _product$booking_uid2 !== void 0 ? _product$booking_uid2 : (_product$metadata5 = product.metadata) === null || _product$metadata5 === void 0 ? void 0 : _product$metadata5.booking_uid) !== null && _ref40 !== void 0 ? _ref40 : '');
3256
3425
  var linkedBookings = bookings.filter(function (booking) {
3257
3426
  var _booking$product_uid;
3258
3427
  return linkedBookingUid && getBookingUid(booking) === linkedBookingUid || productUid && String((_booking$product_uid = booking.product_uid) !== null && _booking$product_uid !== void 0 ? _booking$product_uid : '') === productUid;
@@ -3298,16 +3467,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3298
3467
  var _this5 = this;
3299
3468
  var bookings = Array.isArray(tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.bookings) ? tempOrder.bookings : [];
3300
3469
  return bookings.flatMap(function (booking) {
3301
- var _ref40, _booking$product_uid2, _booking$metadata2;
3470
+ var _ref41, _booking$product_uid2, _booking$metadata2;
3302
3471
  var bookingUid = getBookingUid(booking);
3303
- var productUid = String((_ref40 = (_booking$product_uid2 = booking.product_uid) !== null && _booking$product_uid2 !== void 0 ? _booking$product_uid2 : (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid) !== null && _ref40 !== void 0 ? _ref40 : '');
3472
+ var productUid = String((_ref41 = (_booking$product_uid2 = booking.product_uid) !== null && _booking$product_uid2 !== void 0 ? _booking$product_uid2 : (_booking$metadata2 = booking.metadata) === null || _booking$metadata2 === void 0 ? void 0 : _booking$metadata2.product_uid) !== null && _ref41 !== void 0 ? _ref41 : '');
3304
3473
  var scheduleEventId = toNumberId(booking.schedule_event_id);
3305
3474
  var startAt = booking.start_at || "".concat(booking.start_date || '', " ").concat(booking.start_time || '').trim();
3306
3475
  var endAt = booking.end_at || "".concat(booking.end_date || booking.start_date || '', " ").concat(booking.end_time || '').trim();
3307
3476
  var resources = Array.isArray(booking.resources) ? booking.resources : [];
3308
3477
  return resources.flatMap(function (resource) {
3309
- var _ref41, _resource$resource_id, _ref42, _resource$capacity;
3310
- var resourceId = (_ref41 = (_resource$resource_id = resource.resource_id) !== null && _resource$resource_id !== void 0 ? _resource$resource_id : resource.relation_id) !== null && _ref41 !== void 0 ? _ref41 : resource.id;
3478
+ var _ref42, _resource$resource_id, _ref43, _resource$capacity;
3479
+ var resourceId = (_ref42 = (_resource$resource_id = resource.resource_id) !== null && _resource$resource_id !== void 0 ? _resource$resource_id : resource.relation_id) !== null && _ref42 !== void 0 ? _ref42 : resource.id;
3311
3480
  if (resourceId == null || !startAt || !endAt) return [];
3312
3481
  var range = normalizeAvailabilityLocalDateTimeRange({
3313
3482
  startAt: startAt,
@@ -3320,7 +3489,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3320
3489
  resourceId: resourceId,
3321
3490
  startAt: range.startAt,
3322
3491
  endAt: range.endAt,
3323
- pax: Math.max(1, Number((_ref42 = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : booking.capacity) !== null && _ref42 !== void 0 ? _ref42 : 1) || 1),
3492
+ pax: Math.max(1, Number((_ref43 = (_resource$capacity = resource.capacity) !== null && _resource$capacity !== void 0 ? _resource$capacity : booking.capacity) !== null && _ref43 !== void 0 ? _ref43 : 1) || 1),
3324
3493
  source: 'cart',
3325
3494
  scheduleEventId: scheduleEventId,
3326
3495
  bookingUid: bookingUid || undefined,
@@ -3453,7 +3622,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3453
3622
  }, {
3454
3623
  key: "buildAvailabilityProjectionSnapshot",
3455
3624
  value: function () {
3456
- var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
3625
+ var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3457
3626
  var _this7 = this;
3458
3627
  var options,
3459
3628
  normalizedPrepareParams,
@@ -3475,11 +3644,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3475
3644
  durationCandidateAnchorAt,
3476
3645
  orderRevision,
3477
3646
  projection,
3478
- _args26 = arguments;
3479
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3480
- while (1) switch (_context26.prev = _context26.next) {
3647
+ _args27 = arguments;
3648
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3649
+ while (1) switch (_context27.prev = _context27.next) {
3481
3650
  case 0:
3482
- options = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
3651
+ options = _args27.length > 1 && _args27[1] !== undefined ? _args27[1] : {};
3483
3652
  normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
3484
3653
  timezoneLabel = String(normalizedPrepareParams.timezone);
3485
3654
  dateRange = normalizedPrepareParams.dateRange;
@@ -3493,15 +3662,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3493
3662
  scheduleList: scheduleList,
3494
3663
  businessHours: businessHours
3495
3664
  });
3496
- _context26.next = 11;
3665
+ _context27.next = 11;
3497
3666
  return this.loadAvailabilityProducts({
3498
3667
  prepare: normalizedPrepareParams,
3499
3668
  dateRange: dateRange,
3500
3669
  scheduleList: scheduleList
3501
3670
  });
3502
3671
  case 11:
3503
- products = _context26.sent;
3504
- _context26.next = 14;
3672
+ products = _context27.sent;
3673
+ _context27.next = 14;
3505
3674
  return this.loadAvailabilityResources({
3506
3675
  timezone: timezoneLabel,
3507
3676
  dateRange: dateRange,
@@ -3513,7 +3682,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3513
3682
  fallbackResources: options.fallbackResources
3514
3683
  });
3515
3684
  case 14:
3516
- loadedResources = _context26.sent;
3685
+ loadedResources = _context27.sent;
3517
3686
  tempOrder = this.getTempOrder();
3518
3687
  exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
3519
3688
  injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
@@ -3559,18 +3728,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3559
3728
  prepareParams: normalizedPrepareParams,
3560
3729
  durationCandidateAnchorAt: durationCandidateAnchorAt
3561
3730
  });
3562
- return _context26.abrupt("return", {
3731
+ return _context27.abrupt("return", {
3563
3732
  projection: projection,
3564
3733
  prepareParams: normalizedPrepareParams,
3565
3734
  orderRevision: orderRevision
3566
3735
  });
3567
3736
  case 26:
3568
3737
  case "end":
3569
- return _context26.stop();
3738
+ return _context27.stop();
3570
3739
  }
3571
- }, _callee26, this);
3740
+ }, _callee27, this);
3572
3741
  }));
3573
- function buildAvailabilityProjectionSnapshot(_x20) {
3742
+ function buildAvailabilityProjectionSnapshot(_x21) {
3574
3743
  return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
3575
3744
  }
3576
3745
  return buildAvailabilityProjectionSnapshot;
@@ -3578,10 +3747,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3578
3747
  }, {
3579
3748
  key: "getSharedPreparedAvailabilitySnapshot",
3580
3749
  value: function () {
3581
- var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3750
+ var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3582
3751
  var lifecycleGeneration, normalizedParams, hasRawInputs, prepareKey, snapshot, existing, promise, _snapshot, current;
3583
- return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3584
- while (1) switch (_context27.prev = _context27.next) {
3752
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3753
+ while (1) switch (_context28.prev = _context28.next) {
3585
3754
  case 0:
3586
3755
  lifecycleGeneration = this.availabilityLifecycleGeneration;
3587
3756
  normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
@@ -3600,15 +3769,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3600
3769
  }
3601
3770
  })) : this.buildAvailabilityPrepareKey(normalizedParams);
3602
3771
  if (!hasRawInputs) {
3603
- _context27.next = 11;
3772
+ _context28.next = 11;
3604
3773
  break;
3605
3774
  }
3606
- _context27.next = 7;
3775
+ _context28.next = 7;
3607
3776
  return this.buildAvailabilityProjectionSnapshot(normalizedParams);
3608
3777
  case 7:
3609
- snapshot = _context27.sent;
3778
+ snapshot = _context28.sent;
3610
3779
  if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
3611
- _context27.next = 10;
3780
+ _context28.next = 10;
3612
3781
  break;
3613
3782
  }
3614
3783
  throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
@@ -3617,7 +3786,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3617
3786
  currentLifecycleGeneration: this.availabilityLifecycleGeneration
3618
3787
  });
3619
3788
  case 10:
3620
- return _context27.abrupt("return", {
3789
+ return _context28.abrupt("return", {
3621
3790
  prepareKey: prepareKey,
3622
3791
  snapshot: snapshot
3623
3792
  });
@@ -3631,13 +3800,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3631
3800
  promise: promise
3632
3801
  });
3633
3802
  }
3634
- _context27.prev = 14;
3635
- _context27.next = 17;
3803
+ _context28.prev = 14;
3804
+ _context28.next = 17;
3636
3805
  return promise;
3637
3806
  case 17:
3638
- _snapshot = _context27.sent;
3807
+ _snapshot = _context28.sent;
3639
3808
  if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
3640
- _context27.next = 20;
3809
+ _context28.next = 20;
3641
3810
  break;
3642
3811
  }
3643
3812
  throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
@@ -3646,24 +3815,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3646
3815
  currentLifecycleGeneration: this.availabilityLifecycleGeneration
3647
3816
  });
3648
3817
  case 20:
3649
- return _context27.abrupt("return", {
3818
+ return _context28.abrupt("return", {
3650
3819
  prepareKey: prepareKey,
3651
3820
  snapshot: _snapshot
3652
3821
  });
3653
3822
  case 21:
3654
- _context27.prev = 21;
3823
+ _context28.prev = 21;
3655
3824
  current = this.availabilityPrepareInFlight.get(prepareKey);
3656
3825
  if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
3657
3826
  this.availabilityPrepareInFlight.delete(prepareKey);
3658
3827
  }
3659
- return _context27.finish(21);
3828
+ return _context28.finish(21);
3660
3829
  case 25:
3661
3830
  case "end":
3662
- return _context27.stop();
3831
+ return _context28.stop();
3663
3832
  }
3664
- }, _callee27, this, [[14,, 21, 25]]);
3833
+ }, _callee28, this, [[14,, 21, 25]]);
3665
3834
  }));
3666
- function getSharedPreparedAvailabilitySnapshot(_x21) {
3835
+ function getSharedPreparedAvailabilitySnapshot(_x22) {
3667
3836
  return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
3668
3837
  }
3669
3838
  return getSharedPreparedAvailabilitySnapshot;
@@ -3671,49 +3840,49 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3671
3840
  }, {
3672
3841
  key: "refreshAvailabilityContextProjection",
3673
3842
  value: function () {
3674
- var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3843
+ var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3675
3844
  var _this8 = this;
3676
3845
  var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
3677
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3678
- while (1) switch (_context29.prev = _context29.next) {
3846
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3847
+ while (1) switch (_context30.prev = _context30.next) {
3679
3848
  case 0:
3680
3849
  existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
3681
3850
  if (!existingInFlight) {
3682
- _context29.next = 5;
3851
+ _context30.next = 5;
3683
3852
  break;
3684
3853
  }
3685
- _context29.next = 4;
3854
+ _context30.next = 4;
3686
3855
  return existingInFlight;
3687
3856
  case 4:
3688
- return _context29.abrupt("return", _context29.sent);
3857
+ return _context30.abrupt("return", _context30.sent);
3689
3858
  case 5:
3690
3859
  context = this.getAvailabilityContextEntry(params.contextId);
3691
3860
  expectedVersion = context.activeVersion;
3692
3861
  expectedRefreshNonce = context.refreshNonce;
3693
3862
  expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
3694
- refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3863
+ refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3695
3864
  var snapshot, currentContext, projectionEntry;
3696
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3697
- while (1) switch (_context28.prev = _context28.next) {
3865
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3866
+ while (1) switch (_context29.prev = _context29.next) {
3698
3867
  case 0:
3699
- _context28.next = 2;
3868
+ _context29.next = 2;
3700
3869
  return _this8.buildAvailabilityProjectionSnapshot(_this8.cloneAvailabilityPrepareParams(context.prepareParams), {
3701
3870
  durationCandidateAnchorAt: context.durationCandidateAnchorAt
3702
3871
  });
3703
3872
  case 2:
3704
- snapshot = _context28.sent;
3873
+ snapshot = _context29.sent;
3705
3874
  currentContext = _this8.availabilityContextRegistry.get(params.contextId);
3706
3875
  if (currentContext) {
3707
- _context28.next = 6;
3876
+ _context29.next = 6;
3708
3877
  break;
3709
3878
  }
3710
- return _context28.abrupt("return", null);
3879
+ return _context29.abrupt("return", null);
3711
3880
  case 6:
3712
3881
  if (!(expectedLifecycleGeneration !== _this8.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
3713
- _context28.next = 8;
3882
+ _context29.next = 8;
3714
3883
  break;
3715
3884
  }
3716
- return _context28.abrupt("return", null);
3885
+ return _context29.abrupt("return", null);
3717
3886
  case 8:
3718
3887
  projectionEntry = _this8.storeAvailabilityProjectionEntry({
3719
3888
  contextId: currentContext.contextId,
@@ -3723,7 +3892,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3723
3892
  orderRevision: snapshot.orderRevision,
3724
3893
  incrementVersion: true
3725
3894
  });
3726
- _context28.next = 11;
3895
+ _context29.next = 11;
3727
3896
  return _this8.emitAvailabilityDiagnostic({
3728
3897
  action: 'refresh',
3729
3898
  contextId: currentContext.contextId,
@@ -3735,33 +3904,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3735
3904
  reason: params.reason
3736
3905
  });
3737
3906
  case 11:
3738
- return _context28.abrupt("return", projectionEntry);
3907
+ return _context29.abrupt("return", projectionEntry);
3739
3908
  case 12:
3740
3909
  case "end":
3741
- return _context28.stop();
3910
+ return _context29.stop();
3742
3911
  }
3743
- }, _callee28);
3912
+ }, _callee29);
3744
3913
  }))();
3745
3914
  this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
3746
- _context29.prev = 11;
3747
- _context29.next = 14;
3915
+ _context30.prev = 11;
3916
+ _context30.next = 14;
3748
3917
  return refreshPromise;
3749
3918
  case 14:
3750
- return _context29.abrupt("return", _context29.sent);
3919
+ return _context30.abrupt("return", _context30.sent);
3751
3920
  case 15:
3752
- _context29.prev = 15;
3921
+ _context30.prev = 15;
3753
3922
  current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
3754
3923
  if (current === refreshPromise) {
3755
3924
  this.availabilityProjectionRefreshInFlight.delete(params.contextId);
3756
3925
  }
3757
- return _context29.finish(15);
3926
+ return _context30.finish(15);
3758
3927
  case 19:
3759
3928
  case "end":
3760
- return _context29.stop();
3929
+ return _context30.stop();
3761
3930
  }
3762
- }, _callee29, this, [[11,, 15, 19]]);
3931
+ }, _callee30, this, [[11,, 15, 19]]);
3763
3932
  }));
3764
- function refreshAvailabilityContextProjection(_x22) {
3933
+ function refreshAvailabilityContextProjection(_x23) {
3765
3934
  return _refreshAvailabilityContextProjection.apply(this, arguments);
3766
3935
  }
3767
3936
  return refreshAvailabilityContextProjection;
@@ -3769,53 +3938,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3769
3938
  }, {
3770
3939
  key: "ensureAvailabilityContextProjection",
3771
3940
  value: function () {
3772
- var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(contextId, reason) {
3941
+ var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(contextId, reason) {
3773
3942
  var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
3774
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3775
- while (1) switch (_context30.prev = _context30.next) {
3943
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3944
+ while (1) switch (_context31.prev = _context31.next) {
3776
3945
  case 0:
3777
3946
  retries = 0;
3778
3947
  case 1:
3779
3948
  if (!(retries < 3)) {
3780
- _context30.next = 19;
3949
+ _context31.next = 19;
3781
3950
  break;
3782
3951
  }
3783
3952
  context = this.getAvailabilityContextEntry(contextId);
3784
3953
  currentOrderRevision = this.getCurrentOrderRevision();
3785
3954
  projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
3786
3955
  if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
3787
- _context30.next = 7;
3956
+ _context31.next = 7;
3788
3957
  break;
3789
3958
  }
3790
- return _context30.abrupt("return", {
3959
+ return _context31.abrupt("return", {
3791
3960
  context: context,
3792
3961
  projectionEntry: projectionEntry,
3793
3962
  refreshed: false
3794
3963
  });
3795
3964
  case 7:
3796
- _context30.next = 9;
3965
+ _context31.next = 9;
3797
3966
  return this.refreshAvailabilityContextProjection({
3798
3967
  contextId: contextId,
3799
3968
  reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
3800
3969
  previousOrderRevision: context.lastKnownOrderRevision
3801
3970
  });
3802
3971
  case 9:
3803
- refreshedProjectionEntry = _context30.sent;
3972
+ refreshedProjectionEntry = _context31.sent;
3804
3973
  if (refreshedProjectionEntry) {
3805
- _context30.next = 13;
3974
+ _context31.next = 13;
3806
3975
  break;
3807
3976
  }
3808
3977
  retries += 1;
3809
- return _context30.abrupt("continue", 1);
3978
+ return _context31.abrupt("continue", 1);
3810
3979
  case 13:
3811
3980
  if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
3812
- _context30.next = 16;
3981
+ _context31.next = 16;
3813
3982
  break;
3814
3983
  }
3815
3984
  retries += 1;
3816
- return _context30.abrupt("continue", 1);
3985
+ return _context31.abrupt("continue", 1);
3817
3986
  case 16:
3818
- return _context30.abrupt("return", {
3987
+ return _context31.abrupt("return", {
3819
3988
  context: this.getAvailabilityContextEntry(contextId),
3820
3989
  projectionEntry: refreshedProjectionEntry,
3821
3990
  refreshed: true
@@ -3827,11 +3996,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3827
3996
  });
3828
3997
  case 20:
3829
3998
  case "end":
3830
- return _context30.stop();
3999
+ return _context31.stop();
3831
4000
  }
3832
- }, _callee30, this);
4001
+ }, _callee31, this);
3833
4002
  }));
3834
- function ensureAvailabilityContextProjection(_x23, _x24) {
4003
+ function ensureAvailabilityContextProjection(_x24, _x25) {
3835
4004
  return _ensureAvailabilityContextProjection.apply(this, arguments);
3836
4005
  }
3837
4006
  return ensureAvailabilityContextProjection;
@@ -3839,18 +4008,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3839
4008
  }, {
3840
4009
  key: "tryAcquireAvailabilityCommitLock",
3841
4010
  value: function () {
3842
- var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(contextId) {
4011
+ var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(contextId) {
3843
4012
  var _currentContext$activ;
3844
4013
  var _waitingContext$activ, waitingContext, currentContext;
3845
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3846
- while (1) switch (_context31.prev = _context31.next) {
4014
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
4015
+ while (1) switch (_context32.prev = _context32.next) {
3847
4016
  case 0:
3848
4017
  if (!this.availabilityCommitLocks.has(contextId)) {
3849
- _context31.next = 5;
4018
+ _context32.next = 5;
3850
4019
  break;
3851
4020
  }
3852
4021
  waitingContext = this.availabilityContextRegistry.get(contextId);
3853
- _context31.next = 4;
4022
+ _context32.next = 4;
3854
4023
  return this.emitAvailabilityDiagnostic({
3855
4024
  action: 'commit_lock_wait',
3856
4025
  contextId: contextId,
@@ -3867,7 +4036,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3867
4036
  case 5:
3868
4037
  this.availabilityCommitLocks.add(contextId);
3869
4038
  currentContext = this.availabilityContextRegistry.get(contextId);
3870
- _context31.next = 9;
4039
+ _context32.next = 9;
3871
4040
  return this.emitAvailabilityDiagnostic({
3872
4041
  action: 'commit_lock_acquired',
3873
4042
  contextId: contextId,
@@ -3879,11 +4048,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3879
4048
  });
3880
4049
  case 9:
3881
4050
  case "end":
3882
- return _context31.stop();
4051
+ return _context32.stop();
3883
4052
  }
3884
- }, _callee31, this);
4053
+ }, _callee32, this);
3885
4054
  }));
3886
- function tryAcquireAvailabilityCommitLock(_x25) {
4055
+ function tryAcquireAvailabilityCommitLock(_x26) {
3887
4056
  return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
3888
4057
  }
3889
4058
  return tryAcquireAvailabilityCommitLock;
@@ -3891,15 +4060,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3891
4060
  }, {
3892
4061
  key: "releaseAvailabilityCommitLock",
3893
4062
  value: function () {
3894
- var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(contextId) {
4063
+ var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(contextId) {
3895
4064
  var _releasedContext$acti;
3896
4065
  var releasedContext;
3897
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3898
- while (1) switch (_context32.prev = _context32.next) {
4066
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
4067
+ while (1) switch (_context33.prev = _context33.next) {
3899
4068
  case 0:
3900
4069
  this.availabilityCommitLocks.delete(contextId);
3901
4070
  releasedContext = this.availabilityContextRegistry.get(contextId);
3902
- _context32.next = 4;
4071
+ _context33.next = 4;
3903
4072
  return this.emitAvailabilityDiagnostic({
3904
4073
  action: 'commit_lock_released',
3905
4074
  contextId: contextId,
@@ -3911,11 +4080,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3911
4080
  });
3912
4081
  case 4:
3913
4082
  case "end":
3914
- return _context32.stop();
4083
+ return _context33.stop();
3915
4084
  }
3916
- }, _callee32, this);
4085
+ }, _callee33, this);
3917
4086
  }));
3918
- function releaseAvailabilityCommitLock(_x26) {
4087
+ function releaseAvailabilityCommitLock(_x27) {
3919
4088
  return _releaseAvailabilityCommitLock.apply(this, arguments);
3920
4089
  }
3921
4090
  return releaseAvailabilityCommitLock;
@@ -3923,20 +4092,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3923
4092
  }, {
3924
4093
  key: "prepareAvailabilityProjection",
3925
4094
  value: (function () {
3926
- var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
4095
+ var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3927
4096
  var paramsWithDefaults, _yield$this$getShared, prepareKey, snapshot, contextId, projectionEntry, context, handle, payload;
3928
- return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3929
- while (1) switch (_context33.prev = _context33.next) {
4097
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
4098
+ while (1) switch (_context34.prev = _context34.next) {
3930
4099
  case 0:
3931
4100
  this.assertAvailabilityPrepareParams(params);
3932
- _context33.next = 3;
4101
+ _context34.next = 3;
3933
4102
  return this.resolveAvailabilityPrepareDefaults(params);
3934
4103
  case 3:
3935
- paramsWithDefaults = _context33.sent;
3936
- _context33.next = 6;
4104
+ paramsWithDefaults = _context34.sent;
4105
+ _context34.next = 6;
3937
4106
  return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
3938
4107
  case 6:
3939
- _yield$this$getShared = _context33.sent;
4108
+ _yield$this$getShared = _context34.sent;
3940
4109
  prepareKey = _yield$this$getShared.prepareKey;
3941
4110
  snapshot = _yield$this$getShared.snapshot;
3942
4111
  contextId = this.createAvailabilityContextId();
@@ -3957,7 +4126,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3957
4126
  refreshed: false,
3958
4127
  reason: 'prepare'
3959
4128
  };
3960
- _context33.next = 16;
4129
+ _context34.next = 16;
3961
4130
  return this.emitAvailabilityDiagnostic({
3962
4131
  action: 'prepare',
3963
4132
  contextId: contextId,
@@ -3968,17 +4137,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3968
4137
  reason: 'prepare'
3969
4138
  });
3970
4139
  case 16:
3971
- _context33.next = 18;
4140
+ _context34.next = 18;
3972
4141
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
3973
4142
  case 18:
3974
- return _context33.abrupt("return", handle);
4143
+ return _context34.abrupt("return", handle);
3975
4144
  case 19:
3976
4145
  case "end":
3977
- return _context33.stop();
4146
+ return _context34.stop();
3978
4147
  }
3979
- }, _callee33, this);
4148
+ }, _callee34, this);
3980
4149
  }));
3981
- function prepareAvailabilityProjection(_x27) {
4150
+ function prepareAvailabilityProjection(_x28) {
3982
4151
  return _prepareAvailabilityProjection.apply(this, arguments);
3983
4152
  }
3984
4153
  return prepareAvailabilityProjection;
@@ -3986,26 +4155,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3986
4155
  }, {
3987
4156
  key: "getProductTimeRanges",
3988
4157
  value: (function () {
3989
- var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(contextId) {
4158
+ var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(contextId) {
3990
4159
  var _this9 = this;
3991
4160
  var request,
3992
4161
  _yield$this$ensureAva,
3993
4162
  context,
3994
4163
  projectionEntry,
3995
4164
  contextVersion,
3996
- _args34 = arguments;
3997
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3998
- while (1) switch (_context34.prev = _context34.next) {
4165
+ _args35 = arguments;
4166
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4167
+ while (1) switch (_context35.prev = _context35.next) {
3999
4168
  case 0:
4000
- request = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
4001
- _context34.next = 3;
4169
+ request = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : {};
4170
+ _context35.next = 3;
4002
4171
  return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
4003
4172
  case 3:
4004
- _yield$this$ensureAva = _context34.sent;
4173
+ _yield$this$ensureAva = _context35.sent;
4005
4174
  context = _yield$this$ensureAva.context;
4006
4175
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4007
4176
  contextVersion = context.activeVersion;
4008
- return _context34.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, request).map(function (group) {
4177
+ return _context35.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, request).map(function (group) {
4009
4178
  return _objectSpread(_objectSpread({}, group), {}, {
4010
4179
  ranges: group.ranges.map(function (candidate) {
4011
4180
  return _this9.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
@@ -4014,11 +4183,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4014
4183
  }));
4015
4184
  case 8:
4016
4185
  case "end":
4017
- return _context34.stop();
4186
+ return _context35.stop();
4018
4187
  }
4019
- }, _callee34, this);
4188
+ }, _callee35, this);
4020
4189
  }));
4021
- function getProductTimeRanges(_x28) {
4190
+ function getProductTimeRanges(_x29) {
4022
4191
  return _getProductTimeRanges.apply(this, arguments);
4023
4192
  }
4024
4193
  return getProductTimeRanges;
@@ -4026,15 +4195,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4026
4195
  }, {
4027
4196
  key: "queryBookingAvailability",
4028
4197
  value: (function () {
4029
- var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(contextId, request) {
4198
+ var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, request) {
4030
4199
  var _yield$this$ensureAva2, context, projectionEntry, refreshed, result, contextVersion, contextualResult;
4031
- return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4032
- while (1) switch (_context35.prev = _context35.next) {
4200
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4201
+ while (1) switch (_context36.prev = _context36.next) {
4033
4202
  case 0:
4034
- _context35.next = 2;
4203
+ _context36.next = 2;
4035
4204
  return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
4036
4205
  case 2:
4037
- _yield$this$ensureAva2 = _context35.sent;
4206
+ _yield$this$ensureAva2 = _context36.sent;
4038
4207
  context = _yield$this$ensureAva2.context;
4039
4208
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
4040
4209
  refreshed = _yield$this$ensureAva2.refreshed;
@@ -4066,18 +4235,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4066
4235
  });
4067
4236
  })
4068
4237
  }) : result;
4069
- return _context35.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
4238
+ return _context36.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
4070
4239
  contextId: context.contextId,
4071
4240
  contextVersion: contextVersion,
4072
4241
  refreshed: refreshed
4073
4242
  }));
4074
4243
  case 11:
4075
4244
  case "end":
4076
- return _context35.stop();
4245
+ return _context36.stop();
4077
4246
  }
4078
- }, _callee35, this);
4247
+ }, _callee36, this);
4079
4248
  }));
4080
- function queryBookingAvailability(_x29, _x30) {
4249
+ function queryBookingAvailability(_x30, _x31) {
4081
4250
  return _queryBookingAvailability.apply(this, arguments);
4082
4251
  }
4083
4252
  return queryBookingAvailability;
@@ -4134,9 +4303,9 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4134
4303
  }, {
4135
4304
  key: "findLinkedBooking",
4136
4305
  value: function findLinkedBooking(product) {
4137
- var _ref44, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
4306
+ var _ref45, _product$booking_uid3, _product$metadata6, _this$getTempOrder3;
4138
4307
  var productUid = getProductLineUid(product);
4139
- var bookingUid = String((_ref44 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid) !== null && _ref44 !== void 0 ? _ref44 : '');
4308
+ var bookingUid = String((_ref45 = (_product$booking_uid3 = product.booking_uid) !== null && _product$booking_uid3 !== void 0 ? _product$booking_uid3 : (_product$metadata6 = product.metadata) === null || _product$metadata6 === void 0 ? void 0 : _product$metadata6.booking_uid) !== null && _ref45 !== void 0 ? _ref45 : '');
4140
4309
  return (((_this$getTempOrder3 = this.getTempOrder()) === null || _this$getTempOrder3 === void 0 ? void 0 : _this$getTempOrder3.bookings) || []).find(function (booking) {
4141
4310
  var _booking$product_uid3;
4142
4311
  return bookingUid && getBookingUid(booking) === bookingUid || productUid && String((_booking$product_uid3 = booking.product_uid) !== null && _booking$product_uid3 !== void 0 ? _booking$product_uid3 : '') === productUid;
@@ -4147,27 +4316,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4147
4316
  }, {
4148
4317
  key: "commitAvailabilitySelection",
4149
4318
  value: (function () {
4150
- var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, params) {
4151
- var normalizedContextId, _params$bookingCount, _ref45, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _ref46, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref47, _ref48, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, refreshedRanges, refreshedCandidateBase, validation, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, product, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref49, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4152
- return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4153
- while (1) switch (_context36.prev = _context36.next) {
4319
+ var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId, params) {
4320
+ var normalizedContextId, _params$bookingCount, _ref46, _params$orderProduct$, _params$orderProduct, _params$orderProduct2, _params$orderProduct3, _params$orderProduct$2, _params$orderProduct4, _params$orderProduct5, _editingLine$product_, _baseProjection$meta$, _refreshedProjection$, _baseProjection$meta$2, _this$otherParams$pla, _this$otherParams17, _ref47, _params$orderProduct$3, _params$orderProduct6, _existingBooking$meta, _ref48, _ref49, _params$orderProduct$4, _params$orderProduct7, _params$orderProduct8, _existingBooking$meta2, _existingBooking$hold, bookingCount, orderProductQuantity, partySize, _yield$this$ensureAva3, context, projectionEntry, refreshed, boundEditingUids, orderProductId, editingLine, _editingLine$product_2, baseProjection, commitWriteGuard, prepareParams, fallbackResources, commitSnapshot, refreshedProjection, _baseProjection$meta$3, latestContext, refreshedRanges, refreshedCandidateBase, product, validation, allowPosAvailabilityOverride, forced, capacityConflict, revalidationEntry, revalidatedContext, refreshedCandidate, existingBooking, existingBookingUid, booking, transformed, productLineUid, bookingUid, productLineUids, bookingUids, _transformed$product_, _transformed$product_2, _transformed$product_3, _ref50, _transformed$product_4, _this$getTempOrder4, _this$getTempOrder5, _this$getTempOrder6, beforeProductLineUids, beforeBookingUids, products, addedLines, addedBookings, nextContext, result;
4321
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4322
+ while (1) switch (_context37.prev = _context37.next) {
4154
4323
  case 0:
4155
4324
  normalizedContextId = String(contextId || '').trim();
4156
4325
  if (normalizedContextId) {
4157
- _context36.next = 3;
4326
+ _context37.next = 3;
4158
4327
  break;
4159
4328
  }
4160
4329
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
4161
4330
  candidate: params.candidate
4162
4331
  });
4163
4332
  case 3:
4164
- _context36.next = 5;
4333
+ _context37.next = 5;
4165
4334
  return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
4166
4335
  case 5:
4167
- _context36.prev = 5;
4336
+ _context37.prev = 5;
4168
4337
  bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
4169
4338
  if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
4170
- _context36.next = 9;
4339
+ _context37.next = 9;
4171
4340
  break;
4172
4341
  }
4173
4342
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
@@ -4175,16 +4344,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4175
4344
  });
4176
4345
  case 9:
4177
4346
  if (!(params.mode === 'edit' && bookingCount !== 1)) {
4178
- _context36.next = 11;
4347
+ _context37.next = 11;
4179
4348
  break;
4180
4349
  }
4181
4350
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
4182
4351
  bookingCount: bookingCount
4183
4352
  });
4184
4353
  case 11:
4185
- orderProductQuantity = (_ref45 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref45 !== void 0 ? _ref45 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
4354
+ orderProductQuantity = (_ref46 = (_params$orderProduct$ = (_params$orderProduct = params.orderProduct) === null || _params$orderProduct === void 0 ? void 0 : _params$orderProduct.num) !== null && _params$orderProduct$ !== void 0 ? _params$orderProduct$ : (_params$orderProduct2 = params.orderProduct) === null || _params$orderProduct2 === void 0 ? void 0 : _params$orderProduct2.quantity) !== null && _ref46 !== void 0 ? _ref46 : (_params$orderProduct3 = params.orderProduct) === null || _params$orderProduct3 === void 0 || (_params$orderProduct3 = _params$orderProduct3._extend) === null || _params$orderProduct3 === void 0 ? void 0 : _params$orderProduct3.quantity;
4186
4355
  if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
4187
- _context36.next = 14;
4356
+ _context37.next = 14;
4188
4357
  break;
4189
4358
  }
4190
4359
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
@@ -4194,22 +4363,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4194
4363
  case 14:
4195
4364
  partySize = Number(params.partySize);
4196
4365
  if (!(!Number.isInteger(partySize) || partySize <= 0)) {
4197
- _context36.next = 17;
4366
+ _context37.next = 17;
4198
4367
  break;
4199
4368
  }
4200
4369
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
4201
4370
  partySize: params.partySize
4202
4371
  });
4203
4372
  case 17:
4204
- _context36.next = 19;
4373
+ _context37.next = 19;
4205
4374
  return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
4206
4375
  case 19:
4207
- _yield$this$ensureAva3 = _context36.sent;
4376
+ _yield$this$ensureAva3 = _context37.sent;
4208
4377
  context = _yield$this$ensureAva3.context;
4209
4378
  projectionEntry = _yield$this$ensureAva3.projectionEntry;
4210
4379
  refreshed = _yield$this$ensureAva3.refreshed;
4211
4380
  if (!refreshed) {
4212
- _context36.next = 25;
4381
+ _context37.next = 25;
4213
4382
  break;
4214
4383
  }
4215
4384
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -4220,11 +4389,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4220
4389
  case 25:
4221
4390
  boundEditingUids = context.prepareParams.editingProductLineUids || [];
4222
4391
  if (!(params.mode === 'edit')) {
4223
- _context36.next = 31;
4392
+ _context37.next = 31;
4224
4393
  break;
4225
4394
  }
4226
4395
  if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
4227
- _context36.next = 29;
4396
+ _context37.next = 29;
4228
4397
  break;
4229
4398
  }
4230
4399
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
@@ -4233,11 +4402,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4233
4402
  editingProductLineUids: boundEditingUids
4234
4403
  });
4235
4404
  case 29:
4236
- _context36.next = 33;
4405
+ _context37.next = 33;
4237
4406
  break;
4238
4407
  case 31:
4239
4408
  if (!(boundEditingUids.length > 0)) {
4240
- _context36.next = 33;
4409
+ _context37.next = 33;
4241
4410
  break;
4242
4411
  }
4243
4412
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
@@ -4246,7 +4415,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4246
4415
  });
4247
4416
  case 33:
4248
4417
  if (!(projectionEntry.contextVersion !== context.activeVersion)) {
4249
- _context36.next = 35;
4418
+ _context37.next = 35;
4250
4419
  break;
4251
4420
  }
4252
4421
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -4256,7 +4425,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4256
4425
  });
4257
4426
  case 35:
4258
4427
  if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
4259
- _context36.next = 37;
4428
+ _context37.next = 37;
4260
4429
  break;
4261
4430
  }
4262
4431
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
@@ -4267,7 +4436,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4267
4436
  });
4268
4437
  case 37:
4269
4438
  if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
4270
- _context36.next = 39;
4439
+ _context37.next = 39;
4271
4440
  break;
4272
4441
  }
4273
4442
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
@@ -4279,7 +4448,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4279
4448
  this.assertAvailabilityCandidateFreshness(context, params.candidate);
4280
4449
  orderProductId = (_params$orderProduct$2 = (_params$orderProduct4 = params.orderProduct) === null || _params$orderProduct4 === void 0 ? void 0 : _params$orderProduct4.product_id) !== null && _params$orderProduct$2 !== void 0 ? _params$orderProduct$2 : (_params$orderProduct5 = params.orderProduct) === null || _params$orderProduct5 === void 0 ? void 0 : _params$orderProduct5.id;
4281
4450
  if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
4282
- _context36.next = 43;
4451
+ _context37.next = 43;
4283
4452
  break;
4284
4453
  }
4285
4454
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
@@ -4288,14 +4457,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4288
4457
  });
4289
4458
  case 43:
4290
4459
  if (!(params.mode === 'edit' && !params.productLineUid)) {
4291
- _context36.next = 45;
4460
+ _context37.next = 45;
4292
4461
  break;
4293
4462
  }
4294
4463
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
4295
4464
  case 45:
4296
4465
  editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
4297
4466
  if (!(params.mode === 'edit' && !editingLine)) {
4298
- _context36.next = 48;
4467
+ _context37.next = 48;
4299
4468
  break;
4300
4469
  }
4301
4470
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
@@ -4303,7 +4472,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4303
4472
  });
4304
4473
  case 48:
4305
4474
  if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
4306
- _context36.next = 50;
4475
+ _context37.next = 50;
4307
4476
  break;
4308
4477
  }
4309
4478
  throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
@@ -4313,7 +4482,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4313
4482
  });
4314
4483
  case 50:
4315
4484
  if (Array.isArray(params.requirementSelections)) {
4316
- _context36.next = 52;
4485
+ _context37.next = 52;
4317
4486
  break;
4318
4487
  }
4319
4488
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
@@ -4330,7 +4499,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4330
4499
  };
4331
4500
  prepareParams = baseProjection.meta.prepareParams;
4332
4501
  if (prepareParams) {
4333
- _context36.next = 57;
4502
+ _context37.next = 57;
4334
4503
  break;
4335
4504
  }
4336
4505
  throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
@@ -4342,7 +4511,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4342
4511
  })),
4343
4512
  includesInjectedRawOccupancies: true
4344
4513
  };
4345
- _context36.next = 60;
4514
+ _context37.next = 60;
4346
4515
  return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
4347
4516
  editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
4348
4517
  }), {
@@ -4351,13 +4520,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4351
4520
  durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
4352
4521
  });
4353
4522
  case 60:
4354
- commitSnapshot = _context36.sent;
4523
+ commitSnapshot = _context37.sent;
4355
4524
  refreshedProjection = commitSnapshot.projection;
4356
4525
  if (!(String((_refreshedProjection$ = refreshedProjection.meta.orderRevision) !== null && _refreshedProjection$ !== void 0 ? _refreshedProjection$ : '') !== String((_baseProjection$meta$2 = baseProjection.meta.orderRevision) !== null && _baseProjection$meta$2 !== void 0 ? _baseProjection$meta$2 : ''))) {
4357
- _context36.next = 67;
4526
+ _context37.next = 67;
4358
4527
  break;
4359
4528
  }
4360
- _context36.next = 65;
4529
+ _context37.next = 65;
4361
4530
  return this.refreshAvailabilityContextProjection({
4362
4531
  contextId: normalizedContextId,
4363
4532
  reason: 'commit_order_revision_changed',
@@ -4389,7 +4558,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4389
4558
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
4390
4559
  });
4391
4560
  if (refreshedCandidateBase) {
4392
- _context36.next = 72;
4561
+ _context37.next = 72;
4393
4562
  break;
4394
4563
  }
4395
4564
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -4398,14 +4567,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4398
4567
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4399
4568
  });
4400
4569
  case 72:
4570
+ product = refreshedProjection.products.find(function (item) {
4571
+ return sameAvailabilityId(item.id, refreshedCandidateBase.productId);
4572
+ });
4573
+ if (product) {
4574
+ _context37.next = 75;
4575
+ break;
4576
+ }
4577
+ throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
4578
+ productId: refreshedCandidateBase.productId
4579
+ });
4580
+ case 75:
4401
4581
  validation = validateAvailabilitySelection(refreshedProjection, {
4402
4582
  candidate: refreshedCandidateBase,
4403
4583
  requirementSelections: params.requirementSelections,
4404
4584
  partySize: partySize,
4405
4585
  bookingCount: bookingCount
4406
4586
  });
4587
+ allowPosAvailabilityOverride = String((_this$otherParams$pla = (_this$otherParams17 = this.otherParams) === null || _this$otherParams17 === void 0 ? void 0 : _this$otherParams17.platform) !== null && _this$otherParams$pla !== void 0 ? _this$otherParams$pla : '').trim().toLowerCase() === 'pos';
4588
+ if (allowPosAvailabilityOverride && !validation.ok && validation.conflicts.every(function (conflict) {
4589
+ return POS_OVERRIDABLE_AVAILABILITY_CONFLICT_CODES.has(conflict.code);
4590
+ })) {
4591
+ forced = buildPosForcedAvailabilityAssignments({
4592
+ product: product,
4593
+ resources: refreshedProjection.resources,
4594
+ candidate: refreshedCandidateBase,
4595
+ requirementSelections: params.requirementSelections,
4596
+ partySize: partySize
4597
+ });
4598
+ validation = forced.conflicts.length > 0 ? _objectSpread(_objectSpread({}, validation), {}, {
4599
+ assignments: [],
4600
+ conflicts: forced.conflicts
4601
+ }) : _objectSpread(_objectSpread({}, validation), {}, {
4602
+ ok: true,
4603
+ status: validation.availability.status,
4604
+ assignments: forced.assignments,
4605
+ conflicts: []
4606
+ });
4607
+ }
4407
4608
  if (validation.ok) {
4408
- _context36.next = 76;
4609
+ _context37.next = 81;
4409
4610
  break;
4410
4611
  }
4411
4612
  capacityConflict = validation.conflicts.find(function (conflict) {
@@ -4415,7 +4616,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4415
4616
  validation: validation,
4416
4617
  refreshedSnapshotId: refreshedProjection.meta.snapshotId
4417
4618
  });
4418
- case 76:
4619
+ case 81:
4419
4620
  // Revalidation failure must leave the caller's candidate reusable. Only publish the
4420
4621
  // refreshed projection/version after candidate and resource validation has passed;
4421
4622
  // otherwise a second Confirm from the still-open modal would incorrectly become stale.
@@ -4428,7 +4629,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4428
4629
  incrementVersion: true
4429
4630
  });
4430
4631
  revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
4431
- _context36.next = 80;
4632
+ _context37.next = 85;
4432
4633
  return this.emitAvailabilityDiagnostic({
4433
4634
  action: 'refresh',
4434
4635
  contextId: normalizedContextId,
@@ -4439,7 +4640,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4439
4640
  previousOrderRevision: baseProjection.meta.orderRevision,
4440
4641
  reason: 'commit_cached_occupancy_revalidation'
4441
4642
  });
4442
- case 80:
4643
+ case 85:
4443
4644
  commitWriteGuard = {
4444
4645
  contextId: normalizedContextId,
4445
4646
  expectedVersion: revalidatedContext.activeVersion,
@@ -4448,27 +4649,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4448
4649
  expectedOrderRevision: revalidationEntry.orderRevision
4449
4650
  };
4450
4651
  refreshedCandidate = this.decorateAvailabilityCandidate(normalizedContextId, revalidatedContext.activeVersion, refreshedCandidateBase);
4451
- product = refreshedProjection.products.find(function (item) {
4452
- return sameAvailabilityId(item.id, refreshedCandidate.productId);
4453
- });
4454
- if (product) {
4455
- _context36.next = 85;
4456
- break;
4457
- }
4458
- throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
4459
- productId: refreshedCandidate.productId
4460
- });
4461
- case 85:
4462
4652
  existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
4463
4653
  existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
4464
4654
  if (!(params.mode === 'edit' && !existingBookingUid)) {
4465
- _context36.next = 89;
4655
+ _context37.next = 91;
4466
4656
  break;
4467
4657
  }
4468
4658
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
4469
4659
  productLineUid: params.productLineUid
4470
4660
  });
4471
- case 89:
4661
+ case 91:
4472
4662
  this.assertAvailabilityCommitWriteCAS(commitWriteGuard);
4473
4663
  booking = buildBookingFromAvailabilitySelection({
4474
4664
  assignments: validation.assignments,
@@ -4476,21 +4666,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4476
4666
  product: product,
4477
4667
  resources: refreshedProjection.resources,
4478
4668
  bookingUid: existingBookingUid || undefined,
4479
- holder: (_ref46 = (_params$orderProduct$3 = (_params$orderProduct6 = params.orderProduct) === null || _params$orderProduct6 === void 0 || (_params$orderProduct6 = _params$orderProduct6._extend) === null || _params$orderProduct6 === void 0 ? void 0 : _params$orderProduct6.holder) !== null && _params$orderProduct$3 !== void 0 ? _params$orderProduct$3 : existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _ref46 !== void 0 ? _ref46 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
4480
- holderIds: (_ref47 = (_ref48 = (_params$orderProduct$4 = (_params$orderProduct7 = params.orderProduct) === null || _params$orderProduct7 === void 0 || (_params$orderProduct7 = _params$orderProduct7._extend) === null || _params$orderProduct7 === void 0 ? void 0 : _params$orderProduct7.holder_id) !== null && _params$orderProduct$4 !== void 0 ? _params$orderProduct$4 : (_params$orderProduct8 = params.orderProduct) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8._extend) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8.holder) === null || _params$orderProduct8 === void 0 ? void 0 : _params$orderProduct8.form_record) !== null && _ref48 !== void 0 ? _ref48 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref47 !== void 0 ? _ref47 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
4669
+ holder: (_ref47 = (_params$orderProduct$3 = (_params$orderProduct6 = params.orderProduct) === null || _params$orderProduct6 === void 0 || (_params$orderProduct6 = _params$orderProduct6._extend) === null || _params$orderProduct6 === void 0 ? void 0 : _params$orderProduct6.holder) !== null && _params$orderProduct$3 !== void 0 ? _params$orderProduct$3 : existingBooking === null || existingBooking === void 0 ? void 0 : existingBooking.holder) !== null && _ref47 !== void 0 ? _ref47 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta = existingBooking.metadata) === null || _existingBooking$meta === void 0 ? void 0 : _existingBooking$meta.holder,
4670
+ holderIds: (_ref48 = (_ref49 = (_params$orderProduct$4 = (_params$orderProduct7 = params.orderProduct) === null || _params$orderProduct7 === void 0 || (_params$orderProduct7 = _params$orderProduct7._extend) === null || _params$orderProduct7 === void 0 ? void 0 : _params$orderProduct7.holder_id) !== null && _params$orderProduct$4 !== void 0 ? _params$orderProduct$4 : (_params$orderProduct8 = params.orderProduct) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8._extend) === null || _params$orderProduct8 === void 0 || (_params$orderProduct8 = _params$orderProduct8.holder) === null || _params$orderProduct8 === void 0 ? void 0 : _params$orderProduct8.form_record) !== null && _ref49 !== void 0 ? _ref49 : existingBooking === null || existingBooking === void 0 || (_existingBooking$meta2 = existingBooking.metadata) === null || _existingBooking$meta2 === void 0 ? void 0 : _existingBooking$meta2.holder_id) !== null && _ref48 !== void 0 ? _ref48 : existingBooking === null || existingBooking === void 0 || (_existingBooking$hold = existingBooking.holder) === null || _existingBooking$hold === void 0 ? void 0 : _existingBooking$hold.form_record
4481
4671
  });
4482
4672
  transformed = this.buildUnifiedOrderProduct(_objectSpread(_objectSpread({}, params.orderProduct), {}, {
4483
4673
  num: bookingCount,
4484
4674
  quantity: bookingCount
4485
4675
  }), 'unified_booking_sales', product);
4486
4676
  if (transformed) {
4487
- _context36.next = 94;
4677
+ _context37.next = 96;
4488
4678
  break;
4489
4679
  }
4490
4680
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
4491
4681
  orderProduct: params.orderProduct
4492
4682
  });
4493
- case 94:
4683
+ case 96:
4494
4684
  transformed.num = bookingCount;
4495
4685
  transformed.metadata = _objectSpread(_objectSpread({}, transformed.metadata || {}), {}, {
4496
4686
  unified_booking_sales: true,
@@ -4503,7 +4693,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4503
4693
  productLineUids = [];
4504
4694
  bookingUids = [];
4505
4695
  if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
4506
- _context36.next = 113;
4696
+ _context37.next = 115;
4507
4697
  break;
4508
4698
  }
4509
4699
  transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
@@ -4513,32 +4703,36 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4513
4703
  unique_identification_number: params.productLineUid,
4514
4704
  booking_uid: existingBookingUid
4515
4705
  });
4516
- _context36.next = 107;
4517
- return this.updateOrderProduct({
4706
+ _context37.next = 109;
4707
+ return this.updateOrderProduct(_objectSpread(_objectSpread({
4518
4708
  product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
4519
- product_variant_id: (_ref49 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref49 !== void 0 ? _ref49 : 0,
4709
+ product_variant_id: (_ref50 = (_transformed$product_4 = transformed.product_variant_id) !== null && _transformed$product_4 !== void 0 ? _transformed$product_4 : editingLine.product_variant_id) !== null && _ref50 !== void 0 ? _ref50 : 0,
4520
4710
  unique_identification_number: params.productLineUid,
4521
4711
  updates: transformed,
4522
4712
  booking: booking
4523
- });
4524
- case 107:
4713
+ }, params.allowBookingReprice !== undefined ? {
4714
+ allow_booking_reprice: params.allowBookingReprice
4715
+ } : {}), params.allowBookingDiscountReapply !== undefined ? {
4716
+ allow_booking_discount_reapply: params.allowBookingDiscountReapply
4717
+ } : {}));
4718
+ case 109:
4525
4719
  productLineUid = params.productLineUid;
4526
4720
  bookingUid = existingBookingUid;
4527
4721
  productLineUids = [productLineUid];
4528
4722
  bookingUids = [bookingUid];
4529
- _context36.next = 125;
4723
+ _context37.next = 127;
4530
4724
  break;
4531
- case 113:
4725
+ case 115:
4532
4726
  beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
4533
4727
  return getProductLineUid(line);
4534
4728
  }).filter(Boolean));
4535
4729
  beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
4536
4730
  return getBookingUid(item);
4537
4731
  }).filter(Boolean));
4538
- _context36.next = 117;
4732
+ _context37.next = 119;
4539
4733
  return this.addProductToOrder(transformed, booking);
4540
- case 117:
4541
- products = _context36.sent;
4734
+ case 119:
4735
+ products = _context37.sent;
4542
4736
  addedLines = products.filter(function (line) {
4543
4737
  var _line$product_id, _line$metadata;
4544
4738
  return sameAvailabilityId((_line$product_id = line.product_id) !== null && _line$product_id !== void 0 ? _line$product_id : line.id, refreshedCandidate.productId) && ((_line$metadata = line.metadata) === null || _line$metadata === void 0 ? void 0 : _line$metadata.availability_candidate_key) === refreshedCandidate.key && !beforeProductLineUids.has(getProductLineUid(line));
@@ -4555,13 +4749,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4555
4749
  }).filter(Boolean);
4556
4750
  if (bookingUids.length === 0) {
4557
4751
  bookingUids = addedLines.map(function (line) {
4558
- var _ref50, _line$booking_uid, _line$metadata2;
4559
- return String((_ref50 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) !== null && _ref50 !== void 0 ? _ref50 : '');
4752
+ var _ref51, _line$booking_uid, _line$metadata2;
4753
+ return String((_ref51 = (_line$booking_uid = line.booking_uid) !== null && _line$booking_uid !== void 0 ? _line$booking_uid : (_line$metadata2 = line.metadata) === null || _line$metadata2 === void 0 ? void 0 : _line$metadata2.booking_uid) !== null && _ref51 !== void 0 ? _ref51 : '');
4560
4754
  }).filter(Boolean);
4561
4755
  }
4562
4756
  productLineUid = productLineUids[productLineUids.length - 1] || '';
4563
4757
  bookingUid = bookingUids[bookingUids.length - 1] || '';
4564
- case 125:
4758
+ case 127:
4565
4759
  this.invalidateAvailabilityContextsAfterCommit();
4566
4760
  nextContext = this.getAvailabilityContextEntry(normalizedContextId);
4567
4761
  result = {
@@ -4575,23 +4769,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4575
4769
  productLineUids: productLineUids,
4576
4770
  bookingUids: bookingUids
4577
4771
  };
4578
- _context36.next = 130;
4772
+ _context37.next = 132;
4579
4773
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
4580
- case 130:
4581
- return _context36.abrupt("return", result);
4582
- case 131:
4583
- _context36.prev = 131;
4584
- _context36.next = 134;
4774
+ case 132:
4775
+ return _context37.abrupt("return", result);
4776
+ case 133:
4777
+ _context37.prev = 133;
4778
+ _context37.next = 136;
4585
4779
  return this.releaseAvailabilityCommitLock(normalizedContextId);
4586
- case 134:
4587
- return _context36.finish(131);
4588
- case 135:
4780
+ case 136:
4781
+ return _context37.finish(133);
4782
+ case 137:
4589
4783
  case "end":
4590
- return _context36.stop();
4784
+ return _context37.stop();
4591
4785
  }
4592
- }, _callee36, this, [[5,, 131, 135]]);
4786
+ }, _callee37, this, [[5,, 133, 137]]);
4593
4787
  }));
4594
- function commitAvailabilitySelection(_x31, _x32) {
4788
+ function commitAvailabilitySelection(_x32, _x33) {
4595
4789
  return _commitAvailabilitySelection.apply(this, arguments);
4596
4790
  }
4597
4791
  return commitAvailabilitySelection;