@pisell/pisellos 2.3.77 → 2.3.78

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.
@@ -2034,34 +2034,65 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2034
2034
  }
2035
2035
  return getOpenData;
2036
2036
  }()
2037
+ /**
2038
+ * Load a resource policy without depending on the legacy appointmentBooking solution.
2039
+ */
2040
+ }, {
2041
+ key: "getProtocol",
2042
+ value: (function () {
2043
+ var _getProtocol = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(policyId) {
2044
+ var normalizedPolicyId;
2045
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2046
+ while (1) switch (_context13.prev = _context13.next) {
2047
+ case 0:
2048
+ normalizedPolicyId = String(policyId !== null && policyId !== void 0 ? policyId : '').trim();
2049
+ if (normalizedPolicyId) {
2050
+ _context13.next = 3;
2051
+ break;
2052
+ }
2053
+ throw new Error('[UnifiedBookingSales] getProtocol 需要 policyId');
2054
+ case 3:
2055
+ return _context13.abrupt("return", this.request.get("/shop-policy/".concat(encodeURIComponent(normalizedPolicyId))));
2056
+ case 4:
2057
+ case "end":
2058
+ return _context13.stop();
2059
+ }
2060
+ }, _callee13, this);
2061
+ }));
2062
+ function getProtocol(_x8) {
2063
+ return _getProtocol.apply(this, arguments);
2064
+ }
2065
+ return getProtocol;
2066
+ }()
2037
2067
  /**
2038
2068
  * Loads the product catalog used by both UI and Planner. Schedule data is requested with each
2039
2069
  * product because session products carry their fixed intervals there.
2040
2070
  */
2071
+ )
2041
2072
  }, {
2042
2073
  key: "loadProducts",
2043
2074
  value: (function () {
2044
- var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
2075
+ var _loadProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
2045
2076
  var params,
2046
2077
  options,
2047
2078
  schedule_date,
2048
2079
  schedule_datetime,
2049
2080
  result,
2050
- _args13 = arguments;
2051
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
2052
- while (1) switch (_context13.prev = _context13.next) {
2081
+ _args14 = arguments;
2082
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
2083
+ while (1) switch (_context14.prev = _context14.next) {
2053
2084
  case 0:
2054
- params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
2055
- options = _args13.length > 1 ? _args13[1] : undefined;
2085
+ params = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
2086
+ options = _args14.length > 1 ? _args14[1] : undefined;
2056
2087
  if (this.store.products) {
2057
- _context13.next = 4;
2088
+ _context14.next = 4;
2058
2089
  break;
2059
2090
  }
2060
2091
  throw new Error('[UnifiedBookingSales] products 模块未初始化');
2061
2092
  case 4:
2062
2093
  schedule_date = params.schedule_date || dayjs().format('YYYY-MM-DD');
2063
2094
  schedule_datetime = params.schedule_datetime || "".concat(schedule_date, " ").concat(dayjs().format('HH:mm:ss'));
2064
- _context13.next = 8;
2095
+ _context14.next = 8;
2065
2096
  return this.store.products.loadProducts(_objectSpread(_objectSpread({
2066
2097
  with_count: ['bundleGroup', 'optionGroup'],
2067
2098
  with_schedule: 1
@@ -2071,17 +2102,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2071
2102
  cacheId: this.cacheId
2072
2103
  }), options);
2073
2104
  case 8:
2074
- result = _context13.sent;
2105
+ result = _context14.sent;
2075
2106
  this.unifiedProductCatalog = Array.isArray(result) ? _toConsumableArray(result) : [];
2076
- _context13.next = 12;
2107
+ _context14.next = 12;
2077
2108
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), result);
2078
2109
  case 12:
2079
- return _context13.abrupt("return", result);
2110
+ return _context14.abrupt("return", result);
2080
2111
  case 13:
2081
2112
  case "end":
2082
- return _context13.stop();
2113
+ return _context14.stop();
2083
2114
  }
2084
- }, _callee13, this);
2115
+ }, _callee14, this);
2085
2116
  }));
2086
2117
  function loadProducts() {
2087
2118
  return _loadProducts.apply(this, arguments);
@@ -2091,24 +2122,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2091
2122
  }, {
2092
2123
  key: "loadScheduleAvailableDate",
2093
2124
  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) {
2125
+ var _loadScheduleAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
2126
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
2127
+ while (1) switch (_context15.prev = _context15.next) {
2097
2128
  case 0:
2098
2129
  if (this.store.schedule) {
2099
- _context14.next = 2;
2130
+ _context15.next = 2;
2100
2131
  break;
2101
2132
  }
2102
2133
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
2103
2134
  case 2:
2104
- return _context14.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
2135
+ return _context15.abrupt("return", this.store.schedule.loadScheduleAvailableDate(params));
2105
2136
  case 3:
2106
2137
  case "end":
2107
- return _context14.stop();
2138
+ return _context15.stop();
2108
2139
  }
2109
- }, _callee14, this);
2140
+ }, _callee15, this);
2110
2141
  }));
2111
- function loadScheduleAvailableDate(_x8) {
2142
+ function loadScheduleAvailableDate(_x9) {
2112
2143
  return _loadScheduleAvailableDate.apply(this, arguments);
2113
2144
  }
2114
2145
  return loadScheduleAvailableDate;
@@ -2122,15 +2153,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2122
2153
  }, {
2123
2154
  key: "loadProductsByScheduleDate",
2124
2155
  value: (function () {
2125
- var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee15(params) {
2156
+ var _loadProductsByScheduleDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16(params) {
2126
2157
  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
2158
  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) {
2159
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2160
+ while (1) switch (_context16.prev = _context16.next) {
2130
2161
  case 0:
2131
2162
  date = params.date, custom_page_id = params.custom_page_id, channel = params.channel, product_ids = params.product_ids, productLoadParams = _objectWithoutProperties(params, _excluded);
2132
2163
  if (this.store.schedule) {
2133
- _context15.next = 3;
2164
+ _context16.next = 3;
2134
2165
  break;
2135
2166
  }
2136
2167
  throw new Error('[UnifiedBookingSales] schedule 模块未初始化');
@@ -2141,10 +2172,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2141
2172
  });
2142
2173
  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
2174
  if (!(!hasCachedDate && !hasOtherProducts)) {
2144
- _context15.next = 9;
2175
+ _context16.next = 9;
2145
2176
  break;
2146
2177
  }
2147
- _context15.next = 9;
2178
+ _context16.next = 9;
2148
2179
  return this.loadScheduleAvailableDate({
2149
2180
  startDate: date,
2150
2181
  endDate: date,
@@ -2164,45 +2195,45 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2164
2195
  return !productIdFilter || productIdFilter.has(String(id));
2165
2196
  });
2166
2197
  if (availableProductIds.length) {
2167
- _context15.next = 17;
2198
+ _context16.next = 17;
2168
2199
  break;
2169
2200
  }
2170
2201
  this.unifiedProductCatalog = [];
2171
- _context15.next = 16;
2202
+ _context16.next = 16;
2172
2203
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), []);
2173
2204
  case 16:
2174
- return _context15.abrupt("return", []);
2205
+ return _context16.abrupt("return", []);
2175
2206
  case 17:
2176
- _context15.next = 19;
2207
+ _context16.next = 19;
2177
2208
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
2178
2209
  product_ids: availableProductIds,
2179
2210
  schedule_date: date
2180
2211
  }));
2181
2212
  case 19:
2182
- products = _context15.sent;
2213
+ products = _context16.sent;
2183
2214
  if (!(products.length || availableProductIds.length <= 1)) {
2184
- _context15.next = 22;
2215
+ _context16.next = 22;
2185
2216
  break;
2186
2217
  }
2187
- return _context15.abrupt("return", products);
2218
+ return _context16.abrupt("return", products);
2188
2219
  case 22:
2189
2220
  fallbackProducts = [];
2190
2221
  _iterator = _createForOfIteratorHelper(availableProductIds);
2191
- _context15.prev = 24;
2222
+ _context16.prev = 24;
2192
2223
  _iterator.s();
2193
2224
  case 26:
2194
2225
  if ((_step = _iterator.n()).done) {
2195
- _context15.next = 34;
2226
+ _context16.next = 34;
2196
2227
  break;
2197
2228
  }
2198
2229
  productId = _step.value;
2199
- _context15.next = 30;
2230
+ _context16.next = 30;
2200
2231
  return this.loadProducts(_objectSpread(_objectSpread({}, productLoadParams), {}, {
2201
2232
  product_ids: [productId],
2202
2233
  schedule_date: date
2203
2234
  }));
2204
2235
  case 30:
2205
- result = _context15.sent;
2236
+ result = _context16.sent;
2206
2237
  result.forEach(function (product) {
2207
2238
  var _id;
2208
2239
  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 +2245,32 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2214
2245
  }
2215
2246
  });
2216
2247
  case 32:
2217
- _context15.next = 26;
2248
+ _context16.next = 26;
2218
2249
  break;
2219
2250
  case 34:
2220
- _context15.next = 39;
2251
+ _context16.next = 39;
2221
2252
  break;
2222
2253
  case 36:
2223
- _context15.prev = 36;
2224
- _context15.t0 = _context15["catch"](24);
2225
- _iterator.e(_context15.t0);
2254
+ _context16.prev = 36;
2255
+ _context16.t0 = _context16["catch"](24);
2256
+ _iterator.e(_context16.t0);
2226
2257
  case 39:
2227
- _context15.prev = 39;
2258
+ _context16.prev = 39;
2228
2259
  _iterator.f();
2229
- return _context15.finish(39);
2260
+ return _context16.finish(39);
2230
2261
  case 42:
2231
2262
  this.unifiedProductCatalog = [].concat(fallbackProducts);
2232
- _context15.next = 45;
2263
+ _context16.next = 45;
2233
2264
  return this.core.effects.emit("".concat(this.name, ":onProductsLoaded"), fallbackProducts);
2234
2265
  case 45:
2235
- return _context15.abrupt("return", fallbackProducts);
2266
+ return _context16.abrupt("return", fallbackProducts);
2236
2267
  case 46:
2237
2268
  case "end":
2238
- return _context15.stop();
2269
+ return _context16.stop();
2239
2270
  }
2240
- }, _callee15, this, [[24, 36, 39, 42]]);
2271
+ }, _callee16, this, [[24, 36, 39, 42]]);
2241
2272
  }));
2242
- function loadProductsByScheduleDate(_x9) {
2273
+ function loadProductsByScheduleDate(_x10) {
2243
2274
  return _loadProductsByScheduleDate.apply(this, arguments);
2244
2275
  }
2245
2276
  return loadProductsByScheduleDate;
@@ -2292,7 +2323,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2292
2323
  }, {
2293
2324
  key: "applyPlannerDiscounts",
2294
2325
  value: (function () {
2295
- var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
2326
+ var _applyPlannerDiscounts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
2296
2327
  var _params$customerId;
2297
2328
  var params,
2298
2329
  tempOrder,
@@ -2309,24 +2340,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2309
2340
  discount,
2310
2341
  discountId,
2311
2342
  nextTempOrder,
2312
- _args16 = arguments;
2313
- return _regeneratorRuntime().wrap(function _callee16$(_context16) {
2314
- while (1) switch (_context16.prev = _context16.next) {
2343
+ _args17 = arguments;
2344
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2345
+ while (1) switch (_context17.prev = _context17.next) {
2315
2346
  case 0:
2316
- params = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {};
2347
+ params = _args17.length > 0 && _args17[0] !== undefined ? _args17[0] : {};
2317
2348
  tempOrder = this.getTempOrder();
2318
2349
  requestedCustomerId = (_params$customerId = params.customerId) !== null && _params$customerId !== void 0 ? _params$customerId : tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.customer_id;
2319
2350
  parsedCustomerId = Number(requestedCustomerId);
2320
2351
  customerId = Number.isFinite(parsedCustomerId) && parsedCustomerId > 1 ? parsedCustomerId : null;
2321
- _context16.next = 7;
2352
+ _context17.next = 7;
2322
2353
  return this.getSummary();
2323
2354
  case 7:
2324
- summaryBefore = _context16.sent;
2355
+ summaryBefore = _context17.sent;
2325
2356
  if (customerId) {
2326
- _context16.next = 10;
2357
+ _context17.next = 10;
2327
2358
  break;
2328
2359
  }
2329
- return _context16.abrupt("return", buildPlannerDiscountResult({
2360
+ return _context17.abrupt("return", buildPlannerDiscountResult({
2330
2361
  customerId: null,
2331
2362
  discountList: this.getDiscountList(),
2332
2363
  products: (tempOrder === null || tempOrder === void 0 ? void 0 : tempOrder.products) || [],
@@ -2335,7 +2366,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2335
2366
  status: 'no_customer'
2336
2367
  }));
2337
2368
  case 10:
2338
- _context16.next = 12;
2369
+ _context17.next = 12;
2339
2370
  return this.loadDiscountConfig({
2340
2371
  customerId: customerId,
2341
2372
  action: 'create'
@@ -2347,7 +2378,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2347
2378
  return String((_resolvePlannerDiscou = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou !== void 0 ? _resolvePlannerDiscou : '') === String(preferredDiscountId);
2348
2379
  });
2349
2380
  if (!preferredDiscount) {
2350
- _context16.next = 40;
2381
+ _context17.next = 40;
2351
2382
  break;
2352
2383
  }
2353
2384
  // A requested card is an explicit UI choice, not a best-effort preference. Clear prior
@@ -2359,98 +2390,98 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2359
2390
  return discount.isSelected === true && String((_resolvePlannerDiscou2 = resolvePlannerDiscountId(discount)) !== null && _resolvePlannerDiscou2 !== void 0 ? _resolvePlannerDiscou2 : '') !== String(preferredId);
2360
2391
  });
2361
2392
  _iterator2 = _createForOfIteratorHelper(selectedOtherDiscounts);
2362
- _context16.prev = 18;
2393
+ _context17.prev = 18;
2363
2394
  _iterator2.s();
2364
2395
  case 20:
2365
2396
  if ((_step2 = _iterator2.n()).done) {
2366
- _context16.next = 28;
2397
+ _context17.next = 28;
2367
2398
  break;
2368
2399
  }
2369
2400
  discount = _step2.value;
2370
2401
  discountId = Number(resolvePlannerDiscountId(discount));
2371
2402
  if (!Number.isFinite(discountId)) {
2372
- _context16.next = 26;
2403
+ _context17.next = 26;
2373
2404
  break;
2374
2405
  }
2375
- _context16.next = 26;
2406
+ _context17.next = 26;
2376
2407
  return this.setDiscountSelected({
2377
2408
  discountId: discountId,
2378
2409
  isSelected: false
2379
2410
  });
2380
2411
  case 26:
2381
- _context16.next = 20;
2412
+ _context17.next = 20;
2382
2413
  break;
2383
2414
  case 28:
2384
- _context16.next = 33;
2415
+ _context17.next = 33;
2385
2416
  break;
2386
2417
  case 30:
2387
- _context16.prev = 30;
2388
- _context16.t0 = _context16["catch"](18);
2389
- _iterator2.e(_context16.t0);
2418
+ _context17.prev = 30;
2419
+ _context17.t0 = _context17["catch"](18);
2420
+ _iterator2.e(_context17.t0);
2390
2421
  case 33:
2391
- _context16.prev = 33;
2422
+ _context17.prev = 33;
2392
2423
  _iterator2.f();
2393
- return _context16.finish(33);
2424
+ return _context17.finish(33);
2394
2425
  case 36:
2395
- _context16.next = 38;
2426
+ _context17.next = 38;
2396
2427
  return this.setDiscountSelected({
2397
2428
  discountId: Number(preferredId),
2398
2429
  isSelected: true
2399
2430
  });
2400
2431
  case 38:
2401
- _context16.next = 49;
2432
+ _context17.next = 49;
2402
2433
  break;
2403
2434
  case 40:
2404
2435
  if (!(preferredDiscountId === undefined || preferredDiscountId === null)) {
2405
- _context16.next = 46;
2436
+ _context17.next = 46;
2406
2437
  break;
2407
2438
  }
2408
2439
  if (!(params.applyBestDiscount !== false)) {
2409
- _context16.next = 44;
2440
+ _context17.next = 44;
2410
2441
  break;
2411
2442
  }
2412
- _context16.next = 44;
2443
+ _context17.next = 44;
2413
2444
  return this.bestDiscount();
2414
2445
  case 44:
2415
- _context16.next = 49;
2446
+ _context17.next = 49;
2416
2447
  break;
2417
2448
  case 46:
2418
2449
  if (!(params.applyBestDiscount !== false)) {
2419
- _context16.next = 49;
2450
+ _context17.next = 49;
2420
2451
  break;
2421
2452
  }
2422
- _context16.next = 49;
2453
+ _context17.next = 49;
2423
2454
  return this.bestDiscount();
2424
2455
  case 49:
2425
2456
  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;
2457
+ _context17.t1 = buildPlannerDiscountResult;
2458
+ _context17.t2 = customerId;
2459
+ _context17.t3 = this.getDiscountList();
2460
+ _context17.t4 = (nextTempOrder === null || nextTempOrder === void 0 ? void 0 : nextTempOrder.products) || [];
2461
+ _context17.t5 = summaryBefore;
2462
+ _context17.next = 57;
2432
2463
  return this.getSummary();
2433
2464
  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
2465
+ _context17.t6 = _context17.sent;
2466
+ _context17.t7 = params.applyBestDiscount === false && !preferredDiscount ? 'loaded' : 'applied';
2467
+ _context17.t8 = preferredDiscountId;
2468
+ _context17.t9 = preferredDiscountId === undefined || preferredDiscountId === null ? undefined : Boolean(preferredDiscount);
2469
+ _context17.t10 = {
2470
+ customerId: _context17.t2,
2471
+ discountList: _context17.t3,
2472
+ products: _context17.t4,
2473
+ summaryBefore: _context17.t5,
2474
+ summaryAfter: _context17.t6,
2475
+ status: _context17.t7,
2476
+ preferredDiscountId: _context17.t8,
2477
+ preferredDiscountFound: _context17.t9
2447
2478
  };
2448
- return _context16.abrupt("return", (0, _context16.t1)(_context16.t10));
2479
+ return _context17.abrupt("return", (0, _context17.t1)(_context17.t10));
2449
2480
  case 63:
2450
2481
  case "end":
2451
- return _context16.stop();
2482
+ return _context17.stop();
2452
2483
  }
2453
- }, _callee16, this, [[18, 30, 33, 36]]);
2484
+ }, _callee17, this, [[18, 30, 33, 36]]);
2454
2485
  }));
2455
2486
  function applyPlannerDiscounts() {
2456
2487
  return _applyPlannerDiscounts.apply(this, arguments);
@@ -2485,29 +2516,29 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2485
2516
  }, {
2486
2517
  key: "removeExistingStagedLines",
2487
2518
  value: (function () {
2488
- var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee17(ownershipKey) {
2519
+ var _removeExistingStagedLines = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(ownershipKey) {
2489
2520
  var _this$getTempOrder;
2490
2521
  var existingLines;
2491
- return _regeneratorRuntime().wrap(function _callee17$(_context17) {
2492
- while (1) switch (_context17.prev = _context17.next) {
2522
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
2523
+ while (1) switch (_context18.prev = _context18.next) {
2493
2524
  case 0:
2494
2525
  existingLines = (((_this$getTempOrder = this.getTempOrder()) === null || _this$getTempOrder === void 0 ? void 0 : _this$getTempOrder.products) || []).filter(function (product) {
2495
2526
  var _product$metadata4;
2496
2527
  return (product === null || product === void 0 || (_product$metadata4 = product.metadata) === null || _product$metadata4 === void 0 ? void 0 : _product$metadata4[ownershipKey]) === true;
2497
2528
  });
2498
2529
  if (!(existingLines.length > 0)) {
2499
- _context17.next = 4;
2530
+ _context18.next = 4;
2500
2531
  break;
2501
2532
  }
2502
- _context17.next = 4;
2533
+ _context18.next = 4;
2503
2534
  return this.removeProductsFromOrder(existingLines.map(buildAvailabilityLineIdentity));
2504
2535
  case 4:
2505
2536
  case "end":
2506
- return _context17.stop();
2537
+ return _context18.stop();
2507
2538
  }
2508
- }, _callee17, this);
2539
+ }, _callee18, this);
2509
2540
  }));
2510
- function removeExistingStagedLines(_x10) {
2541
+ function removeExistingStagedLines(_x11) {
2511
2542
  return _removeExistingStagedLines.apply(this, arguments);
2512
2543
  }
2513
2544
  return removeExistingStagedLines;
@@ -2515,25 +2546,25 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2515
2546
  }, {
2516
2547
  key: "stageProducts",
2517
2548
  value: function () {
2518
- var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee18(params, ownershipKey) {
2549
+ var _stageProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee19(params, ownershipKey) {
2519
2550
  var _params$rawProducts;
2520
2551
  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) {
2552
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
2553
+ while (1) switch (_context19.prev = _context19.next) {
2523
2554
  case 0:
2524
2555
  productIds = params.productIds || [];
2525
2556
  if (productIds.length) {
2526
- _context18.next = 3;
2557
+ _context19.next = 3;
2527
2558
  break;
2528
2559
  }
2529
- return _context18.abrupt("return", this.getTempOrder());
2560
+ return _context19.abrupt("return", this.getTempOrder());
2530
2561
  case 3:
2531
2562
  if (!((_params$rawProducts = params.rawProducts) !== null && _params$rawProducts !== void 0 && _params$rawProducts.length)) {
2532
- _context18.next = 7;
2563
+ _context19.next = 7;
2533
2564
  break;
2534
2565
  }
2535
2566
  this.unifiedProductCatalog = params.rawProducts;
2536
- _context18.next = 12;
2567
+ _context19.next = 12;
2537
2568
  break;
2538
2569
  case 7:
2539
2570
  existingIds = new Set((this.unifiedProductCatalog || []).map(function (product) {
@@ -2544,15 +2575,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2544
2575
  return !existingIds.has(String(id));
2545
2576
  });
2546
2577
  if (!(missingIds.length || params.productLoadParams)) {
2547
- _context18.next = 12;
2578
+ _context19.next = 12;
2548
2579
  break;
2549
2580
  }
2550
- _context18.next = 12;
2581
+ _context19.next = 12;
2551
2582
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
2552
2583
  product_ids: productIds.map(Number).filter(Number.isFinite)
2553
2584
  }));
2554
2585
  case 12:
2555
- _context18.next = 14;
2586
+ _context19.next = 14;
2556
2587
  return this.removeExistingStagedLines(ownershipKey);
2557
2588
  case 14:
2558
2589
  productIdSet = new Set(productIds.map(function (id) {
@@ -2565,30 +2596,30 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2565
2596
  _i = 0, _arr = selectedProducts;
2566
2597
  case 17:
2567
2598
  if (!(_i < _arr.length)) {
2568
- _context18.next = 26;
2599
+ _context19.next = 26;
2569
2600
  break;
2570
2601
  }
2571
2602
  sourceProduct = _arr[_i];
2572
2603
  productInput = this.buildUnifiedOrderProduct(sourceProduct, ownershipKey);
2573
2604
  if (!productInput) {
2574
- _context18.next = 23;
2605
+ _context19.next = 23;
2575
2606
  break;
2576
2607
  }
2577
- _context18.next = 23;
2608
+ _context19.next = 23;
2578
2609
  return this.addProductToOrder(productInput);
2579
2610
  case 23:
2580
2611
  _i++;
2581
- _context18.next = 17;
2612
+ _context19.next = 17;
2582
2613
  break;
2583
2614
  case 26:
2584
- return _context18.abrupt("return", this.getTempOrder());
2615
+ return _context19.abrupt("return", this.getTempOrder());
2585
2616
  case 27:
2586
2617
  case "end":
2587
- return _context18.stop();
2618
+ return _context19.stop();
2588
2619
  }
2589
- }, _callee18, this);
2620
+ }, _callee19, this);
2590
2621
  }));
2591
- function stageProducts(_x11, _x12) {
2622
+ function stageProducts(_x12, _x13) {
2592
2623
  return _stageProducts.apply(this, arguments);
2593
2624
  }
2594
2625
  return stageProducts;
@@ -2600,18 +2631,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2600
2631
  }, {
2601
2632
  key: "stageRetailProducts",
2602
2633
  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) {
2634
+ var _stageRetailProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2635
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2636
+ while (1) switch (_context20.prev = _context20.next) {
2606
2637
  case 0:
2607
- return _context19.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
2638
+ return _context20.abrupt("return", this.stageProducts(params, 'unified_booking_sales_retail'));
2608
2639
  case 1:
2609
2640
  case "end":
2610
- return _context19.stop();
2641
+ return _context20.stop();
2611
2642
  }
2612
- }, _callee19, this);
2643
+ }, _callee20, this);
2613
2644
  }));
2614
- function stageRetailProducts(_x13) {
2645
+ function stageRetailProducts(_x14) {
2615
2646
  return _stageRetailProducts.apply(this, arguments);
2616
2647
  }
2617
2648
  return stageRetailProducts;
@@ -2625,15 +2656,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2625
2656
  }, {
2626
2657
  key: "addRetailProduct",
2627
2658
  value: (function () {
2628
- var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee20(params) {
2659
+ var _addRetailProduct = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2629
2660
  var _params$quantity, _ref38, _params$productId, _params$product, _params$product2;
2630
2661
  var quantity, productId, sourceProduct, products, orderProduct;
2631
- return _regeneratorRuntime().wrap(function _callee20$(_context20) {
2632
- while (1) switch (_context20.prev = _context20.next) {
2662
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
2663
+ while (1) switch (_context21.prev = _context21.next) {
2633
2664
  case 0:
2634
2665
  quantity = Math.floor(Number((_params$quantity = params.quantity) !== null && _params$quantity !== void 0 ? _params$quantity : 1));
2635
2666
  if (!(!Number.isFinite(quantity) || quantity <= 0)) {
2636
- _context20.next = 3;
2667
+ _context21.next = 3;
2637
2668
  break;
2638
2669
  }
2639
2670
  throw new Error('[UnifiedBookingSales] retail 商品数量必须大于 0');
@@ -2647,22 +2678,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2647
2678
  });
2648
2679
  }
2649
2680
  if (!(!sourceProduct && productId !== undefined && productId !== null)) {
2650
- _context20.next = 11;
2681
+ _context21.next = 11;
2651
2682
  break;
2652
2683
  }
2653
- _context20.next = 9;
2684
+ _context21.next = 9;
2654
2685
  return this.loadProducts(_objectSpread(_objectSpread({}, params.productLoadParams || {}), {}, {
2655
2686
  product_ids: [Number(productId)].filter(Number.isFinite)
2656
2687
  }));
2657
2688
  case 9:
2658
- products = _context20.sent;
2689
+ products = _context21.sent;
2659
2690
  sourceProduct = products.find(function (product) {
2660
2691
  var _product$id4;
2661
2692
  return String((_product$id4 = product.id) !== null && _product$id4 !== void 0 ? _product$id4 : product.product_id) === String(productId);
2662
2693
  });
2663
2694
  case 11:
2664
2695
  if (sourceProduct) {
2665
- _context20.next = 13;
2696
+ _context21.next = 13;
2666
2697
  break;
2667
2698
  }
2668
2699
  throw new Error("[UnifiedBookingSales] \u672A\u627E\u5230\u96F6\u552E\u5546\u54C1 ".concat(String(productId !== null && productId !== void 0 ? productId : '')).trim());
@@ -2671,19 +2702,19 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2671
2702
  quantity: quantity
2672
2703
  }), 'unified_booking_sales_retail');
2673
2704
  if (orderProduct) {
2674
- _context20.next = 16;
2705
+ _context21.next = 16;
2675
2706
  break;
2676
2707
  }
2677
2708
  throw new Error('[UnifiedBookingSales] 无法生成零售商品订单行');
2678
2709
  case 16:
2679
- return _context20.abrupt("return", this.addProductToOrder(orderProduct));
2710
+ return _context21.abrupt("return", this.addProductToOrder(orderProduct));
2680
2711
  case 17:
2681
2712
  case "end":
2682
- return _context20.stop();
2713
+ return _context21.stop();
2683
2714
  }
2684
- }, _callee20, this);
2715
+ }, _callee21, this);
2685
2716
  }));
2686
- function addRetailProduct(_x14) {
2717
+ function addRetailProduct(_x15) {
2687
2718
  return _addRetailProduct.apply(this, arguments);
2688
2719
  }
2689
2720
  return addRetailProduct;
@@ -2848,46 +2879,46 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2848
2879
  }, {
2849
2880
  key: "loadAvailabilityProducts",
2850
2881
  value: function () {
2851
- var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee21(params) {
2882
+ var _loadAvailabilityProducts = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
2852
2883
  var _prepare$catalogScope,
2853
2884
  _prepare$catalogScope2,
2854
2885
  _this4 = this,
2855
2886
  _prepare$resourceIds;
2856
2887
  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) {
2888
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2889
+ while (1) switch (_context22.prev = _context22.next) {
2859
2890
  case 0:
2860
2891
  prepare = params.prepare, dateRange = params.dateRange;
2861
2892
  explicitProductIds = prepare.productIds || [];
2862
2893
  rawProducts = [];
2863
2894
  if (!Array.isArray(prepare.rawProducts)) {
2864
- _context21.next = 8;
2895
+ _context22.next = 8;
2865
2896
  break;
2866
2897
  }
2867
2898
  rawProducts = prepare.rawProducts;
2868
2899
  this.unifiedProductCatalog = _toConsumableArray(rawProducts);
2869
- _context21.next = 34;
2900
+ _context22.next = 34;
2870
2901
  break;
2871
2902
  case 8:
2872
2903
  if (!(explicitProductIds.length > 0)) {
2873
- _context21.next = 14;
2904
+ _context22.next = 14;
2874
2905
  break;
2875
2906
  }
2876
- _context21.next = 11;
2907
+ _context22.next = 11;
2877
2908
  return this.loadProducts({
2878
2909
  product_ids: explicitProductIds,
2879
2910
  schedule_date: dateRange.startDate
2880
2911
  });
2881
2912
  case 11:
2882
- rawProducts = _context21.sent;
2883
- _context21.next = 34;
2913
+ rawProducts = _context22.sent;
2914
+ _context22.next = 34;
2884
2915
  break;
2885
2916
  case 14:
2886
2917
  if (!(((_prepare$catalogScope = prepare.catalogScope) === null || _prepare$catalogScope === void 0 ? void 0 : _prepare$catalogScope.type) === 'schedule')) {
2887
- _context21.next = 30;
2918
+ _context22.next = 30;
2888
2919
  break;
2889
2920
  }
2890
- _context21.next = 17;
2921
+ _context22.next = 17;
2891
2922
  return this.loadScheduleAvailableDate({
2892
2923
  startDate: dateRange.startDate,
2893
2924
  endDate: dateRange.endDate,
@@ -2903,44 +2934,44 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2903
2934
  });
2904
2935
  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
2936
  if (!(productIds.length > 0)) {
2906
- _context21.next = 27;
2937
+ _context22.next = 27;
2907
2938
  break;
2908
2939
  }
2909
2940
  assertAvailabilityCatalogProductIds(productIds, 'prepare.catalogScope.scheduleProductIds');
2910
- _context21.next = 24;
2941
+ _context22.next = 24;
2911
2942
  return this.loadProducts({
2912
2943
  product_ids: productIds,
2913
2944
  schedule_date: dateRange.startDate
2914
2945
  });
2915
2946
  case 24:
2916
- rawProducts = _context21.sent;
2917
- _context21.next = 28;
2947
+ rawProducts = _context22.sent;
2948
+ _context22.next = 28;
2918
2949
  break;
2919
2950
  case 27:
2920
2951
  this.unifiedProductCatalog = [];
2921
2952
  case 28:
2922
- _context21.next = 34;
2953
+ _context22.next = 34;
2923
2954
  break;
2924
2955
  case 30:
2925
2956
  if (!(((_prepare$catalogScope2 = prepare.catalogScope) === null || _prepare$catalogScope2 === void 0 ? void 0 : _prepare$catalogScope2.type) === 'productList')) {
2926
- _context21.next = 34;
2957
+ _context22.next = 34;
2927
2958
  break;
2928
2959
  }
2929
- _context21.next = 33;
2960
+ _context22.next = 33;
2930
2961
  return this.loadProducts(_objectSpread(_objectSpread({}, prepare.catalogScope.params), {}, {
2931
2962
  schedule_date: prepare.catalogScope.params.schedule_date || dateRange.startDate
2932
2963
  }));
2933
2964
  case 33:
2934
- rawProducts = _context21.sent;
2965
+ rawProducts = _context22.sent;
2935
2966
  case 34:
2936
2967
  normalized = rawProducts.map(function (product) {
2937
2968
  return normalizeProductForAvailability(product, params.scheduleList, _this4.getAvailabilityRuntimeOffsetMinutes());
2938
2969
  });
2939
2970
  if (!(!explicitProductIds.length && (_prepare$resourceIds = prepare.resourceIds) !== null && _prepare$resourceIds !== void 0 && _prepare$resourceIds.length)) {
2940
- _context21.next = 37;
2971
+ _context22.next = 37;
2941
2972
  break;
2942
2973
  }
2943
- return _context21.abrupt("return", normalized.filter(function (product) {
2974
+ return _context22.abrupt("return", normalized.filter(function (product) {
2944
2975
  var _product$requirementG2;
2945
2976
  return (_product$requirementG2 = product.requirementGroups) === null || _product$requirementG2 === void 0 ? void 0 : _product$requirementG2.some(function (group) {
2946
2977
  var _group$resourceIds2;
@@ -2953,16 +2984,16 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2953
2984
  }));
2954
2985
  case 37:
2955
2986
  productIdSet = explicitProductIds.length ? new Set(explicitProductIds.map(String)) : null;
2956
- return _context21.abrupt("return", productIdSet ? normalized.filter(function (product) {
2987
+ return _context22.abrupt("return", productIdSet ? normalized.filter(function (product) {
2957
2988
  return productIdSet.has(String(product.id));
2958
2989
  }) : normalized);
2959
2990
  case 39:
2960
2991
  case "end":
2961
- return _context21.stop();
2992
+ return _context22.stop();
2962
2993
  }
2963
- }, _callee21, this);
2994
+ }, _callee22, this);
2964
2995
  }));
2965
- function loadAvailabilityProducts(_x15) {
2996
+ function loadAvailabilityProducts(_x16) {
2966
2997
  return _loadAvailabilityProducts.apply(this, arguments);
2967
2998
  }
2968
2999
  return loadAvailabilityProducts;
@@ -2975,12 +3006,12 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2975
3006
  }, {
2976
3007
  key: "fetchAvailabilityResourcesV2",
2977
3008
  value: (function () {
2978
- var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee22(params) {
3009
+ var _fetchAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
2979
3010
  var response, data;
2980
- return _regeneratorRuntime().wrap(function _callee22$(_context22) {
2981
- while (1) switch (_context22.prev = _context22.next) {
3011
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3012
+ while (1) switch (_context23.prev = _context23.next) {
2982
3013
  case 0:
2983
- _context22.next = 2;
3014
+ _context23.next = 2;
2984
3015
  return this.request.get('/schedule/resource/list/v2', {
2985
3016
  start_date: params.dateRange.startDate,
2986
3017
  end_date: params.dateRange.endDate,
@@ -2990,28 +3021,28 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
2990
3021
  useCache: false
2991
3022
  });
2992
3023
  case 2:
2993
- response = _context22.sent;
3024
+ response = _context23.sent;
2994
3025
  data = response === null || response === void 0 ? void 0 : response.data;
2995
3026
  if (!Array.isArray(data)) {
2996
- _context22.next = 6;
3027
+ _context23.next = 6;
2997
3028
  break;
2998
3029
  }
2999
- return _context22.abrupt("return", data);
3030
+ return _context23.abrupt("return", data);
3000
3031
  case 6:
3001
3032
  if (!Array.isArray(data === null || data === void 0 ? void 0 : data.list)) {
3002
- _context22.next = 8;
3033
+ _context23.next = 8;
3003
3034
  break;
3004
3035
  }
3005
- return _context22.abrupt("return", data.list);
3036
+ return _context23.abrupt("return", data.list);
3006
3037
  case 8:
3007
- return _context22.abrupt("return", []);
3038
+ return _context23.abrupt("return", []);
3008
3039
  case 9:
3009
3040
  case "end":
3010
- return _context22.stop();
3041
+ return _context23.stop();
3011
3042
  }
3012
- }, _callee22, this);
3043
+ }, _callee23, this);
3013
3044
  }));
3014
- function fetchAvailabilityResourcesV2(_x16) {
3045
+ function fetchAvailabilityResourcesV2(_x17) {
3015
3046
  return _fetchAvailabilityResourcesV.apply(this, arguments);
3016
3047
  }
3017
3048
  return fetchAvailabilityResourcesV2;
@@ -3019,17 +3050,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3019
3050
  }, {
3020
3051
  key: "fetchAndPublishAvailabilityResourcesV2",
3021
3052
  value: function () {
3022
- var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee23(params) {
3053
+ var _fetchAndPublishAvailabilityResourcesV = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
3023
3054
  var normalizedResourceIds, scopeKey, cacheParams, cachedRawResources;
3024
- return _regeneratorRuntime().wrap(function _callee23$(_context23) {
3025
- while (1) switch (_context23.prev = _context23.next) {
3055
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3056
+ while (1) switch (_context24.prev = _context24.next) {
3026
3057
  case 0:
3027
3058
  normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
3028
3059
  if (!(normalizedResourceIds.length === 0)) {
3029
- _context23.next = 3;
3060
+ _context24.next = 3;
3030
3061
  break;
3031
3062
  }
3032
- return _context23.abrupt("return", []);
3063
+ return _context24.abrupt("return", []);
3033
3064
  case 3:
3034
3065
  scopeKey = this.buildAvailabilityRemoteResourceScopeKey(params.timezone);
3035
3066
  cacheParams = {
@@ -3039,7 +3070,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3039
3070
  };
3040
3071
  cachedRawResources = this.availabilityRemoteOccupancyCache.read(cacheParams);
3041
3072
  if (!cachedRawResources) {
3042
- _context23.next = 9;
3073
+ _context24.next = 9;
3043
3074
  break;
3044
3075
  }
3045
3076
  if (params.useCacheOnHit) {
@@ -3051,23 +3082,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3051
3082
  console.warn('[UnifiedBookingSales] Remote occupancy background refresh failed', error);
3052
3083
  });
3053
3084
  }
3054
- return _context23.abrupt("return", cachedRawResources);
3085
+ return _context24.abrupt("return", cachedRawResources);
3055
3086
  case 9:
3056
- _context23.next = 11;
3087
+ _context24.next = 11;
3057
3088
  return this.refreshAvailabilityRemoteResourceQuery({
3058
3089
  timezone: params.timezone,
3059
3090
  dateRange: params.dateRange,
3060
3091
  resourceIds: normalizedResourceIds
3061
3092
  });
3062
3093
  case 11:
3063
- return _context23.abrupt("return", _context23.sent);
3094
+ return _context24.abrupt("return", _context24.sent);
3064
3095
  case 12:
3065
3096
  case "end":
3066
- return _context23.stop();
3097
+ return _context24.stop();
3067
3098
  }
3068
- }, _callee23, this);
3099
+ }, _callee24, this);
3069
3100
  }));
3070
- function fetchAndPublishAvailabilityResourcesV2(_x17) {
3101
+ function fetchAndPublishAvailabilityResourcesV2(_x18) {
3071
3102
  return _fetchAndPublishAvailabilityResourcesV.apply(this, arguments);
3072
3103
  }
3073
3104
  return fetchAndPublishAvailabilityResourcesV2;
@@ -3075,17 +3106,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3075
3106
  }, {
3076
3107
  key: "refreshAvailabilityRemoteResourceQuery",
3077
3108
  value: function () {
3078
- var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee24(params) {
3109
+ var _refreshAvailabilityRemoteResourceQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3079
3110
  var normalizedResourceIds, queryKey, epoch, existing, writeVersion, promise, rawResources, current;
3080
- return _regeneratorRuntime().wrap(function _callee24$(_context24) {
3081
- while (1) switch (_context24.prev = _context24.next) {
3111
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3112
+ while (1) switch (_context25.prev = _context25.next) {
3082
3113
  case 0:
3083
3114
  normalizedResourceIds = this.normalizeAvailabilityIdList(params.resourceIds) || [];
3084
3115
  if (!(normalizedResourceIds.length === 0)) {
3085
- _context24.next = 3;
3116
+ _context25.next = 3;
3086
3117
  break;
3087
3118
  }
3088
- return _context24.abrupt("return", []);
3119
+ return _context25.abrupt("return", []);
3089
3120
  case 3:
3090
3121
  queryKey = this.buildAvailabilityRemoteResourceQueryKey({
3091
3122
  timezone: params.timezone,
@@ -3095,13 +3126,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3095
3126
  epoch = this.availabilityRemoteResourceEpoch;
3096
3127
  existing = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3097
3128
  if (!((existing === null || existing === void 0 ? void 0 : existing.epoch) === epoch)) {
3098
- _context24.next = 10;
3129
+ _context25.next = 10;
3099
3130
  break;
3100
3131
  }
3101
- _context24.next = 9;
3132
+ _context25.next = 9;
3102
3133
  return existing.promise;
3103
3134
  case 9:
3104
- return _context24.abrupt("return", _context24.sent);
3135
+ return _context25.abrupt("return", _context25.sent);
3105
3136
  case 10:
3106
3137
  this.availabilityRemoteResourceQuerySequence += 1;
3107
3138
  writeVersion = this.availabilityRemoteResourceQuerySequence;
@@ -3113,11 +3144,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3113
3144
  epoch: epoch,
3114
3145
  promise: promise
3115
3146
  });
3116
- _context24.prev = 14;
3117
- _context24.next = 17;
3147
+ _context25.prev = 14;
3148
+ _context25.next = 17;
3118
3149
  return promise;
3119
3150
  case 17:
3120
- rawResources = _context24.sent;
3151
+ rawResources = _context25.sent;
3121
3152
  if (epoch === this.availabilityRemoteResourceEpoch) {
3122
3153
  this.availabilityRemoteOccupancyCache.publish({
3123
3154
  scopeKey: this.buildAvailabilityRemoteResourceScopeKey(params.timezone),
@@ -3128,21 +3159,21 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3128
3159
  version: writeVersion
3129
3160
  });
3130
3161
  }
3131
- return _context24.abrupt("return", rawResources);
3162
+ return _context25.abrupt("return", rawResources);
3132
3163
  case 20:
3133
- _context24.prev = 20;
3164
+ _context25.prev = 20;
3134
3165
  current = this.availabilityRemoteResourceQueryInFlight.get(queryKey);
3135
3166
  if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
3136
3167
  this.availabilityRemoteResourceQueryInFlight.delete(queryKey);
3137
3168
  }
3138
- return _context24.finish(20);
3169
+ return _context25.finish(20);
3139
3170
  case 24:
3140
3171
  case "end":
3141
- return _context24.stop();
3172
+ return _context25.stop();
3142
3173
  }
3143
- }, _callee24, this, [[14,, 20, 24]]);
3174
+ }, _callee25, this, [[14,, 20, 24]]);
3144
3175
  }));
3145
- function refreshAvailabilityRemoteResourceQuery(_x18) {
3176
+ function refreshAvailabilityRemoteResourceQuery(_x19) {
3146
3177
  return _refreshAvailabilityRemoteResourceQuery.apply(this, arguments);
3147
3178
  }
3148
3179
  return refreshAvailabilityRemoteResourceQuery;
@@ -3150,26 +3181,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3150
3181
  }, {
3151
3182
  key: "loadAvailabilityResources",
3152
3183
  value: function () {
3153
- var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee25(params) {
3184
+ var _loadAvailabilityResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
3154
3185
  var resourceIds, cachedRawResources, rawResources;
3155
- return _regeneratorRuntime().wrap(function _callee25$(_context25) {
3156
- while (1) switch (_context25.prev = _context25.next) {
3186
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3187
+ while (1) switch (_context26.prev = _context26.next) {
3157
3188
  case 0:
3158
3189
  resourceIds = collectAvailabilityResourceIds(params.products, params.resourceIds || []);
3159
3190
  if (!(resourceIds.length === 0)) {
3160
- _context25.next = 3;
3191
+ _context26.next = 3;
3161
3192
  break;
3162
3193
  }
3163
- return _context25.abrupt("return", {
3194
+ return _context26.abrupt("return", {
3164
3195
  resources: [],
3165
3196
  resourceOccupancies: []
3166
3197
  });
3167
3198
  case 3:
3168
3199
  if (!Array.isArray(params.rawResources)) {
3169
- _context25.next = 5;
3200
+ _context26.next = 5;
3170
3201
  break;
3171
3202
  }
3172
- return _context25.abrupt("return", buildAvailabilityResourcesFromV2({
3203
+ return _context26.abrupt("return", buildAvailabilityResourcesFromV2({
3173
3204
  rawResources: params.rawResources,
3174
3205
  scheduleList: params.scheduleList,
3175
3206
  dateRange: params.dateRange,
@@ -3177,7 +3208,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3177
3208
  }));
3178
3209
  case 5:
3179
3210
  if (!(params.fetchPolicy === 'cache_only')) {
3180
- _context25.next = 10;
3211
+ _context26.next = 10;
3181
3212
  break;
3182
3213
  }
3183
3214
  cachedRawResources = this.availabilityRemoteOccupancyCache.read({
@@ -3186,22 +3217,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3186
3217
  dateRange: params.dateRange
3187
3218
  });
3188
3219
  if (!cachedRawResources) {
3189
- _context25.next = 9;
3220
+ _context26.next = 9;
3190
3221
  break;
3191
3222
  }
3192
- return _context25.abrupt("return", buildAvailabilityResourcesFromV2({
3223
+ return _context26.abrupt("return", buildAvailabilityResourcesFromV2({
3193
3224
  rawResources: cachedRawResources,
3194
3225
  scheduleList: params.scheduleList,
3195
3226
  dateRange: params.dateRange,
3196
3227
  fixedOffsetMinutes: this.getAvailabilityRuntimeOffsetMinutes()
3197
3228
  }));
3198
3229
  case 9:
3199
- return _context25.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
3230
+ return _context26.abrupt("return", params.fallbackResources ? cloneDeep(params.fallbackResources) : {
3200
3231
  resources: [],
3201
3232
  resourceOccupancies: []
3202
3233
  });
3203
3234
  case 10:
3204
- _context25.next = 12;
3235
+ _context26.next = 12;
3205
3236
  return this.fetchAndPublishAvailabilityResourcesV2({
3206
3237
  timezone: params.timezone,
3207
3238
  dateRange: params.dateRange,
@@ -3209,8 +3240,8 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3209
3240
  useCacheOnHit: true
3210
3241
  });
3211
3242
  case 12:
3212
- rawResources = _context25.sent;
3213
- return _context25.abrupt("return", buildAvailabilityResourcesFromV2({
3243
+ rawResources = _context26.sent;
3244
+ return _context26.abrupt("return", buildAvailabilityResourcesFromV2({
3214
3245
  rawResources: rawResources,
3215
3246
  scheduleList: params.scheduleList,
3216
3247
  dateRange: params.dateRange,
@@ -3218,11 +3249,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3218
3249
  }));
3219
3250
  case 14:
3220
3251
  case "end":
3221
- return _context25.stop();
3252
+ return _context26.stop();
3222
3253
  }
3223
- }, _callee25, this);
3254
+ }, _callee26, this);
3224
3255
  }));
3225
- function loadAvailabilityResources(_x19) {
3256
+ function loadAvailabilityResources(_x20) {
3226
3257
  return _loadAvailabilityResources.apply(this, arguments);
3227
3258
  }
3228
3259
  return loadAvailabilityResources;
@@ -3453,7 +3484,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3453
3484
  }, {
3454
3485
  key: "buildAvailabilityProjectionSnapshot",
3455
3486
  value: function () {
3456
- var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee26(params) {
3487
+ var _buildAvailabilityProjectionSnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3457
3488
  var _this7 = this;
3458
3489
  var options,
3459
3490
  normalizedPrepareParams,
@@ -3475,11 +3506,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3475
3506
  durationCandidateAnchorAt,
3476
3507
  orderRevision,
3477
3508
  projection,
3478
- _args26 = arguments;
3479
- return _regeneratorRuntime().wrap(function _callee26$(_context26) {
3480
- while (1) switch (_context26.prev = _context26.next) {
3509
+ _args27 = arguments;
3510
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
3511
+ while (1) switch (_context27.prev = _context27.next) {
3481
3512
  case 0:
3482
- options = _args26.length > 1 && _args26[1] !== undefined ? _args26[1] : {};
3513
+ options = _args27.length > 1 && _args27[1] !== undefined ? _args27[1] : {};
3483
3514
  normalizedPrepareParams = this.normalizeAvailabilityPrepareDescriptor(params);
3484
3515
  timezoneLabel = String(normalizedPrepareParams.timezone);
3485
3516
  dateRange = normalizedPrepareParams.dateRange;
@@ -3493,15 +3524,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3493
3524
  scheduleList: scheduleList,
3494
3525
  businessHours: businessHours
3495
3526
  });
3496
- _context26.next = 11;
3527
+ _context27.next = 11;
3497
3528
  return this.loadAvailabilityProducts({
3498
3529
  prepare: normalizedPrepareParams,
3499
3530
  dateRange: dateRange,
3500
3531
  scheduleList: scheduleList
3501
3532
  });
3502
3533
  case 11:
3503
- products = _context26.sent;
3504
- _context26.next = 14;
3534
+ products = _context27.sent;
3535
+ _context27.next = 14;
3505
3536
  return this.loadAvailabilityResources({
3506
3537
  timezone: timezoneLabel,
3507
3538
  dateRange: dateRange,
@@ -3513,7 +3544,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3513
3544
  fallbackResources: options.fallbackResources
3514
3545
  });
3515
3546
  case 14:
3516
- loadedResources = _context26.sent;
3547
+ loadedResources = _context27.sent;
3517
3548
  tempOrder = this.getTempOrder();
3518
3549
  exclusions = this.resolveEditingOccupancyExclusions(tempOrder, normalizedPrepareParams.editingProductLineUids);
3519
3550
  injectedRawOccupancies = (normalizedPrepareParams.rawOccupancies || []).flatMap(function (occupancy) {
@@ -3559,18 +3590,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3559
3590
  prepareParams: normalizedPrepareParams,
3560
3591
  durationCandidateAnchorAt: durationCandidateAnchorAt
3561
3592
  });
3562
- return _context26.abrupt("return", {
3593
+ return _context27.abrupt("return", {
3563
3594
  projection: projection,
3564
3595
  prepareParams: normalizedPrepareParams,
3565
3596
  orderRevision: orderRevision
3566
3597
  });
3567
3598
  case 26:
3568
3599
  case "end":
3569
- return _context26.stop();
3600
+ return _context27.stop();
3570
3601
  }
3571
- }, _callee26, this);
3602
+ }, _callee27, this);
3572
3603
  }));
3573
- function buildAvailabilityProjectionSnapshot(_x20) {
3604
+ function buildAvailabilityProjectionSnapshot(_x21) {
3574
3605
  return _buildAvailabilityProjectionSnapshot.apply(this, arguments);
3575
3606
  }
3576
3607
  return buildAvailabilityProjectionSnapshot;
@@ -3578,10 +3609,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3578
3609
  }, {
3579
3610
  key: "getSharedPreparedAvailabilitySnapshot",
3580
3611
  value: function () {
3581
- var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee27(params) {
3612
+ var _getSharedPreparedAvailabilitySnapshot = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28(params) {
3582
3613
  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) {
3614
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3615
+ while (1) switch (_context28.prev = _context28.next) {
3585
3616
  case 0:
3586
3617
  lifecycleGeneration = this.availabilityLifecycleGeneration;
3587
3618
  normalizedParams = this.normalizeAvailabilityPrepareDescriptor(params);
@@ -3600,15 +3631,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3600
3631
  }
3601
3632
  })) : this.buildAvailabilityPrepareKey(normalizedParams);
3602
3633
  if (!hasRawInputs) {
3603
- _context27.next = 11;
3634
+ _context28.next = 11;
3604
3635
  break;
3605
3636
  }
3606
- _context27.next = 7;
3637
+ _context28.next = 7;
3607
3638
  return this.buildAvailabilityProjectionSnapshot(normalizedParams);
3608
3639
  case 7:
3609
- snapshot = _context27.sent;
3640
+ snapshot = _context28.sent;
3610
3641
  if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
3611
- _context27.next = 10;
3642
+ _context28.next = 10;
3612
3643
  break;
3613
3644
  }
3614
3645
  throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
@@ -3617,7 +3648,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3617
3648
  currentLifecycleGeneration: this.availabilityLifecycleGeneration
3618
3649
  });
3619
3650
  case 10:
3620
- return _context27.abrupt("return", {
3651
+ return _context28.abrupt("return", {
3621
3652
  prepareKey: prepareKey,
3622
3653
  snapshot: snapshot
3623
3654
  });
@@ -3631,13 +3662,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3631
3662
  promise: promise
3632
3663
  });
3633
3664
  }
3634
- _context27.prev = 14;
3635
- _context27.next = 17;
3665
+ _context28.prev = 14;
3666
+ _context28.next = 17;
3636
3667
  return promise;
3637
3668
  case 17:
3638
- _snapshot = _context27.sent;
3669
+ _snapshot = _context28.sent;
3639
3670
  if (!(lifecycleGeneration !== this.availabilityLifecycleGeneration)) {
3640
- _context27.next = 20;
3671
+ _context28.next = 20;
3641
3672
  break;
3642
3673
  }
3643
3674
  throw this.createAvailabilityFacadeError('AVAILABILITY_CONTEXT_NOT_FOUND', 'prepare 期间业务作用域或实例生命周期已变化,请重新 prepare', {
@@ -3646,24 +3677,24 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3646
3677
  currentLifecycleGeneration: this.availabilityLifecycleGeneration
3647
3678
  });
3648
3679
  case 20:
3649
- return _context27.abrupt("return", {
3680
+ return _context28.abrupt("return", {
3650
3681
  prepareKey: prepareKey,
3651
3682
  snapshot: _snapshot
3652
3683
  });
3653
3684
  case 21:
3654
- _context27.prev = 21;
3685
+ _context28.prev = 21;
3655
3686
  current = this.availabilityPrepareInFlight.get(prepareKey);
3656
3687
  if ((current === null || current === void 0 ? void 0 : current.promise) === promise) {
3657
3688
  this.availabilityPrepareInFlight.delete(prepareKey);
3658
3689
  }
3659
- return _context27.finish(21);
3690
+ return _context28.finish(21);
3660
3691
  case 25:
3661
3692
  case "end":
3662
- return _context27.stop();
3693
+ return _context28.stop();
3663
3694
  }
3664
- }, _callee27, this, [[14,, 21, 25]]);
3695
+ }, _callee28, this, [[14,, 21, 25]]);
3665
3696
  }));
3666
- function getSharedPreparedAvailabilitySnapshot(_x21) {
3697
+ function getSharedPreparedAvailabilitySnapshot(_x22) {
3667
3698
  return _getSharedPreparedAvailabilitySnapshot.apply(this, arguments);
3668
3699
  }
3669
3700
  return getSharedPreparedAvailabilitySnapshot;
@@ -3671,49 +3702,49 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3671
3702
  }, {
3672
3703
  key: "refreshAvailabilityContextProjection",
3673
3704
  value: function () {
3674
- var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(params) {
3705
+ var _refreshAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(params) {
3675
3706
  var _this8 = this;
3676
3707
  var existingInFlight, context, expectedVersion, expectedRefreshNonce, expectedLifecycleGeneration, refreshPromise, current;
3677
- return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3678
- while (1) switch (_context29.prev = _context29.next) {
3708
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3709
+ while (1) switch (_context30.prev = _context30.next) {
3679
3710
  case 0:
3680
3711
  existingInFlight = this.availabilityProjectionRefreshInFlight.get(params.contextId);
3681
3712
  if (!existingInFlight) {
3682
- _context29.next = 5;
3713
+ _context30.next = 5;
3683
3714
  break;
3684
3715
  }
3685
- _context29.next = 4;
3716
+ _context30.next = 4;
3686
3717
  return existingInFlight;
3687
3718
  case 4:
3688
- return _context29.abrupt("return", _context29.sent);
3719
+ return _context30.abrupt("return", _context30.sent);
3689
3720
  case 5:
3690
3721
  context = this.getAvailabilityContextEntry(params.contextId);
3691
3722
  expectedVersion = context.activeVersion;
3692
3723
  expectedRefreshNonce = context.refreshNonce;
3693
3724
  expectedLifecycleGeneration = this.availabilityLifecycleGeneration;
3694
- refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee28() {
3725
+ refreshPromise = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29() {
3695
3726
  var snapshot, currentContext, projectionEntry;
3696
- return _regeneratorRuntime().wrap(function _callee28$(_context28) {
3697
- while (1) switch (_context28.prev = _context28.next) {
3727
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
3728
+ while (1) switch (_context29.prev = _context29.next) {
3698
3729
  case 0:
3699
- _context28.next = 2;
3730
+ _context29.next = 2;
3700
3731
  return _this8.buildAvailabilityProjectionSnapshot(_this8.cloneAvailabilityPrepareParams(context.prepareParams), {
3701
3732
  durationCandidateAnchorAt: context.durationCandidateAnchorAt
3702
3733
  });
3703
3734
  case 2:
3704
- snapshot = _context28.sent;
3735
+ snapshot = _context29.sent;
3705
3736
  currentContext = _this8.availabilityContextRegistry.get(params.contextId);
3706
3737
  if (currentContext) {
3707
- _context28.next = 6;
3738
+ _context29.next = 6;
3708
3739
  break;
3709
3740
  }
3710
- return _context28.abrupt("return", null);
3741
+ return _context29.abrupt("return", null);
3711
3742
  case 6:
3712
3743
  if (!(expectedLifecycleGeneration !== _this8.availabilityLifecycleGeneration || currentContext.activeVersion !== expectedVersion || currentContext.refreshNonce !== expectedRefreshNonce || currentContext.lifecycleGeneration !== expectedLifecycleGeneration)) {
3713
- _context28.next = 8;
3744
+ _context29.next = 8;
3714
3745
  break;
3715
3746
  }
3716
- return _context28.abrupt("return", null);
3747
+ return _context29.abrupt("return", null);
3717
3748
  case 8:
3718
3749
  projectionEntry = _this8.storeAvailabilityProjectionEntry({
3719
3750
  contextId: currentContext.contextId,
@@ -3723,7 +3754,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3723
3754
  orderRevision: snapshot.orderRevision,
3724
3755
  incrementVersion: true
3725
3756
  });
3726
- _context28.next = 11;
3757
+ _context29.next = 11;
3727
3758
  return _this8.emitAvailabilityDiagnostic({
3728
3759
  action: 'refresh',
3729
3760
  contextId: currentContext.contextId,
@@ -3735,33 +3766,33 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3735
3766
  reason: params.reason
3736
3767
  });
3737
3768
  case 11:
3738
- return _context28.abrupt("return", projectionEntry);
3769
+ return _context29.abrupt("return", projectionEntry);
3739
3770
  case 12:
3740
3771
  case "end":
3741
- return _context28.stop();
3772
+ return _context29.stop();
3742
3773
  }
3743
- }, _callee28);
3774
+ }, _callee29);
3744
3775
  }))();
3745
3776
  this.availabilityProjectionRefreshInFlight.set(params.contextId, refreshPromise);
3746
- _context29.prev = 11;
3747
- _context29.next = 14;
3777
+ _context30.prev = 11;
3778
+ _context30.next = 14;
3748
3779
  return refreshPromise;
3749
3780
  case 14:
3750
- return _context29.abrupt("return", _context29.sent);
3781
+ return _context30.abrupt("return", _context30.sent);
3751
3782
  case 15:
3752
- _context29.prev = 15;
3783
+ _context30.prev = 15;
3753
3784
  current = this.availabilityProjectionRefreshInFlight.get(params.contextId);
3754
3785
  if (current === refreshPromise) {
3755
3786
  this.availabilityProjectionRefreshInFlight.delete(params.contextId);
3756
3787
  }
3757
- return _context29.finish(15);
3788
+ return _context30.finish(15);
3758
3789
  case 19:
3759
3790
  case "end":
3760
- return _context29.stop();
3791
+ return _context30.stop();
3761
3792
  }
3762
- }, _callee29, this, [[11,, 15, 19]]);
3793
+ }, _callee30, this, [[11,, 15, 19]]);
3763
3794
  }));
3764
- function refreshAvailabilityContextProjection(_x22) {
3795
+ function refreshAvailabilityContextProjection(_x23) {
3765
3796
  return _refreshAvailabilityContextProjection.apply(this, arguments);
3766
3797
  }
3767
3798
  return refreshAvailabilityContextProjection;
@@ -3769,53 +3800,53 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3769
3800
  }, {
3770
3801
  key: "ensureAvailabilityContextProjection",
3771
3802
  value: function () {
3772
- var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee30(contextId, reason) {
3803
+ var _ensureAvailabilityContextProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(contextId, reason) {
3773
3804
  var retries, context, currentOrderRevision, projectionEntry, refreshedProjectionEntry;
3774
- return _regeneratorRuntime().wrap(function _callee30$(_context30) {
3775
- while (1) switch (_context30.prev = _context30.next) {
3805
+ return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3806
+ while (1) switch (_context31.prev = _context31.next) {
3776
3807
  case 0:
3777
3808
  retries = 0;
3778
3809
  case 1:
3779
3810
  if (!(retries < 3)) {
3780
- _context30.next = 19;
3811
+ _context31.next = 19;
3781
3812
  break;
3782
3813
  }
3783
3814
  context = this.getAvailabilityContextEntry(contextId);
3784
3815
  currentOrderRevision = this.getCurrentOrderRevision();
3785
3816
  projectionEntry = this.getActiveAvailabilityProjectionEntry(context);
3786
3817
  if (!(projectionEntry && projectionEntry.orderRevision === currentOrderRevision)) {
3787
- _context30.next = 7;
3818
+ _context31.next = 7;
3788
3819
  break;
3789
3820
  }
3790
- return _context30.abrupt("return", {
3821
+ return _context31.abrupt("return", {
3791
3822
  context: context,
3792
3823
  projectionEntry: projectionEntry,
3793
3824
  refreshed: false
3794
3825
  });
3795
3826
  case 7:
3796
- _context30.next = 9;
3827
+ _context31.next = 9;
3797
3828
  return this.refreshAvailabilityContextProjection({
3798
3829
  contextId: contextId,
3799
3830
  reason: projectionEntry ? reason : "".concat(reason, ":projection_cache_miss"),
3800
3831
  previousOrderRevision: context.lastKnownOrderRevision
3801
3832
  });
3802
3833
  case 9:
3803
- refreshedProjectionEntry = _context30.sent;
3834
+ refreshedProjectionEntry = _context31.sent;
3804
3835
  if (refreshedProjectionEntry) {
3805
- _context30.next = 13;
3836
+ _context31.next = 13;
3806
3837
  break;
3807
3838
  }
3808
3839
  retries += 1;
3809
- return _context30.abrupt("continue", 1);
3840
+ return _context31.abrupt("continue", 1);
3810
3841
  case 13:
3811
3842
  if (!(refreshedProjectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
3812
- _context30.next = 16;
3843
+ _context31.next = 16;
3813
3844
  break;
3814
3845
  }
3815
3846
  retries += 1;
3816
- return _context30.abrupt("continue", 1);
3847
+ return _context31.abrupt("continue", 1);
3817
3848
  case 16:
3818
- return _context30.abrupt("return", {
3849
+ return _context31.abrupt("return", {
3819
3850
  context: this.getAvailabilityContextEntry(contextId),
3820
3851
  projectionEntry: refreshedProjectionEntry,
3821
3852
  refreshed: true
@@ -3827,11 +3858,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3827
3858
  });
3828
3859
  case 20:
3829
3860
  case "end":
3830
- return _context30.stop();
3861
+ return _context31.stop();
3831
3862
  }
3832
- }, _callee30, this);
3863
+ }, _callee31, this);
3833
3864
  }));
3834
- function ensureAvailabilityContextProjection(_x23, _x24) {
3865
+ function ensureAvailabilityContextProjection(_x24, _x25) {
3835
3866
  return _ensureAvailabilityContextProjection.apply(this, arguments);
3836
3867
  }
3837
3868
  return ensureAvailabilityContextProjection;
@@ -3839,18 +3870,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3839
3870
  }, {
3840
3871
  key: "tryAcquireAvailabilityCommitLock",
3841
3872
  value: function () {
3842
- var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee31(contextId) {
3873
+ var _tryAcquireAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(contextId) {
3843
3874
  var _currentContext$activ;
3844
3875
  var _waitingContext$activ, waitingContext, currentContext;
3845
- return _regeneratorRuntime().wrap(function _callee31$(_context31) {
3846
- while (1) switch (_context31.prev = _context31.next) {
3876
+ return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3877
+ while (1) switch (_context32.prev = _context32.next) {
3847
3878
  case 0:
3848
3879
  if (!this.availabilityCommitLocks.has(contextId)) {
3849
- _context31.next = 5;
3880
+ _context32.next = 5;
3850
3881
  break;
3851
3882
  }
3852
3883
  waitingContext = this.availabilityContextRegistry.get(contextId);
3853
- _context31.next = 4;
3884
+ _context32.next = 4;
3854
3885
  return this.emitAvailabilityDiagnostic({
3855
3886
  action: 'commit_lock_wait',
3856
3887
  contextId: contextId,
@@ -3867,7 +3898,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3867
3898
  case 5:
3868
3899
  this.availabilityCommitLocks.add(contextId);
3869
3900
  currentContext = this.availabilityContextRegistry.get(contextId);
3870
- _context31.next = 9;
3901
+ _context32.next = 9;
3871
3902
  return this.emitAvailabilityDiagnostic({
3872
3903
  action: 'commit_lock_acquired',
3873
3904
  contextId: contextId,
@@ -3879,11 +3910,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3879
3910
  });
3880
3911
  case 9:
3881
3912
  case "end":
3882
- return _context31.stop();
3913
+ return _context32.stop();
3883
3914
  }
3884
- }, _callee31, this);
3915
+ }, _callee32, this);
3885
3916
  }));
3886
- function tryAcquireAvailabilityCommitLock(_x25) {
3917
+ function tryAcquireAvailabilityCommitLock(_x26) {
3887
3918
  return _tryAcquireAvailabilityCommitLock.apply(this, arguments);
3888
3919
  }
3889
3920
  return tryAcquireAvailabilityCommitLock;
@@ -3891,15 +3922,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3891
3922
  }, {
3892
3923
  key: "releaseAvailabilityCommitLock",
3893
3924
  value: function () {
3894
- var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee32(contextId) {
3925
+ var _releaseAvailabilityCommitLock = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(contextId) {
3895
3926
  var _releasedContext$acti;
3896
3927
  var releasedContext;
3897
- return _regeneratorRuntime().wrap(function _callee32$(_context32) {
3898
- while (1) switch (_context32.prev = _context32.next) {
3928
+ return _regeneratorRuntime().wrap(function _callee33$(_context33) {
3929
+ while (1) switch (_context33.prev = _context33.next) {
3899
3930
  case 0:
3900
3931
  this.availabilityCommitLocks.delete(contextId);
3901
3932
  releasedContext = this.availabilityContextRegistry.get(contextId);
3902
- _context32.next = 4;
3933
+ _context33.next = 4;
3903
3934
  return this.emitAvailabilityDiagnostic({
3904
3935
  action: 'commit_lock_released',
3905
3936
  contextId: contextId,
@@ -3911,11 +3942,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3911
3942
  });
3912
3943
  case 4:
3913
3944
  case "end":
3914
- return _context32.stop();
3945
+ return _context33.stop();
3915
3946
  }
3916
- }, _callee32, this);
3947
+ }, _callee33, this);
3917
3948
  }));
3918
- function releaseAvailabilityCommitLock(_x26) {
3949
+ function releaseAvailabilityCommitLock(_x27) {
3919
3950
  return _releaseAvailabilityCommitLock.apply(this, arguments);
3920
3951
  }
3921
3952
  return releaseAvailabilityCommitLock;
@@ -3923,20 +3954,20 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3923
3954
  }, {
3924
3955
  key: "prepareAvailabilityProjection",
3925
3956
  value: (function () {
3926
- var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee33(params) {
3957
+ var _prepareAvailabilityProjection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(params) {
3927
3958
  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) {
3959
+ return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3960
+ while (1) switch (_context34.prev = _context34.next) {
3930
3961
  case 0:
3931
3962
  this.assertAvailabilityPrepareParams(params);
3932
- _context33.next = 3;
3963
+ _context34.next = 3;
3933
3964
  return this.resolveAvailabilityPrepareDefaults(params);
3934
3965
  case 3:
3935
- paramsWithDefaults = _context33.sent;
3936
- _context33.next = 6;
3966
+ paramsWithDefaults = _context34.sent;
3967
+ _context34.next = 6;
3937
3968
  return this.getSharedPreparedAvailabilitySnapshot(paramsWithDefaults);
3938
3969
  case 6:
3939
- _yield$this$getShared = _context33.sent;
3970
+ _yield$this$getShared = _context34.sent;
3940
3971
  prepareKey = _yield$this$getShared.prepareKey;
3941
3972
  snapshot = _yield$this$getShared.snapshot;
3942
3973
  contextId = this.createAvailabilityContextId();
@@ -3957,7 +3988,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3957
3988
  refreshed: false,
3958
3989
  reason: 'prepare'
3959
3990
  };
3960
- _context33.next = 16;
3991
+ _context34.next = 16;
3961
3992
  return this.emitAvailabilityDiagnostic({
3962
3993
  action: 'prepare',
3963
3994
  contextId: contextId,
@@ -3968,17 +3999,17 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3968
3999
  reason: 'prepare'
3969
4000
  });
3970
4001
  case 16:
3971
- _context33.next = 18;
4002
+ _context34.next = 18;
3972
4003
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilityProjectionPrepared), payload);
3973
4004
  case 18:
3974
- return _context33.abrupt("return", handle);
4005
+ return _context34.abrupt("return", handle);
3975
4006
  case 19:
3976
4007
  case "end":
3977
- return _context33.stop();
4008
+ return _context34.stop();
3978
4009
  }
3979
- }, _callee33, this);
4010
+ }, _callee34, this);
3980
4011
  }));
3981
- function prepareAvailabilityProjection(_x27) {
4012
+ function prepareAvailabilityProjection(_x28) {
3982
4013
  return _prepareAvailabilityProjection.apply(this, arguments);
3983
4014
  }
3984
4015
  return prepareAvailabilityProjection;
@@ -3986,26 +4017,26 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
3986
4017
  }, {
3987
4018
  key: "getProductTimeRanges",
3988
4019
  value: (function () {
3989
- var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee34(contextId) {
4020
+ var _getProductTimeRanges = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(contextId) {
3990
4021
  var _this9 = this;
3991
4022
  var request,
3992
4023
  _yield$this$ensureAva,
3993
4024
  context,
3994
4025
  projectionEntry,
3995
4026
  contextVersion,
3996
- _args34 = arguments;
3997
- return _regeneratorRuntime().wrap(function _callee34$(_context34) {
3998
- while (1) switch (_context34.prev = _context34.next) {
4027
+ _args35 = arguments;
4028
+ return _regeneratorRuntime().wrap(function _callee35$(_context35) {
4029
+ while (1) switch (_context35.prev = _context35.next) {
3999
4030
  case 0:
4000
- request = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : {};
4001
- _context34.next = 3;
4031
+ request = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : {};
4032
+ _context35.next = 3;
4002
4033
  return this.ensureAvailabilityContextProjection(contextId, 'get_product_time_ranges');
4003
4034
  case 3:
4004
- _yield$this$ensureAva = _context34.sent;
4035
+ _yield$this$ensureAva = _context35.sent;
4005
4036
  context = _yield$this$ensureAva.context;
4006
4037
  projectionEntry = _yield$this$ensureAva.projectionEntry;
4007
4038
  contextVersion = context.activeVersion;
4008
- return _context34.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, request).map(function (group) {
4039
+ return _context35.abrupt("return", getProjectionProductTimeRanges(projectionEntry.projection, request).map(function (group) {
4009
4040
  return _objectSpread(_objectSpread({}, group), {}, {
4010
4041
  ranges: group.ranges.map(function (candidate) {
4011
4042
  return _this9.decorateAvailabilityCandidate(context.contextId, contextVersion, candidate);
@@ -4014,11 +4045,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4014
4045
  }));
4015
4046
  case 8:
4016
4047
  case "end":
4017
- return _context34.stop();
4048
+ return _context35.stop();
4018
4049
  }
4019
- }, _callee34, this);
4050
+ }, _callee35, this);
4020
4051
  }));
4021
- function getProductTimeRanges(_x28) {
4052
+ function getProductTimeRanges(_x29) {
4022
4053
  return _getProductTimeRanges.apply(this, arguments);
4023
4054
  }
4024
4055
  return getProductTimeRanges;
@@ -4026,15 +4057,15 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4026
4057
  }, {
4027
4058
  key: "queryBookingAvailability",
4028
4059
  value: (function () {
4029
- var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee35(contextId, request) {
4060
+ var _queryBookingAvailability = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, request) {
4030
4061
  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) {
4062
+ return _regeneratorRuntime().wrap(function _callee36$(_context36) {
4063
+ while (1) switch (_context36.prev = _context36.next) {
4033
4064
  case 0:
4034
- _context35.next = 2;
4065
+ _context36.next = 2;
4035
4066
  return this.ensureAvailabilityContextProjection(contextId, 'query_booking_availability');
4036
4067
  case 2:
4037
- _yield$this$ensureAva2 = _context35.sent;
4068
+ _yield$this$ensureAva2 = _context36.sent;
4038
4069
  context = _yield$this$ensureAva2.context;
4039
4070
  projectionEntry = _yield$this$ensureAva2.projectionEntry;
4040
4071
  refreshed = _yield$this$ensureAva2.refreshed;
@@ -4066,18 +4097,18 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4066
4097
  });
4067
4098
  })
4068
4099
  }) : result;
4069
- return _context35.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
4100
+ return _context36.abrupt("return", _objectSpread(_objectSpread({}, contextualResult), {}, {
4070
4101
  contextId: context.contextId,
4071
4102
  contextVersion: contextVersion,
4072
4103
  refreshed: refreshed
4073
4104
  }));
4074
4105
  case 11:
4075
4106
  case "end":
4076
- return _context35.stop();
4107
+ return _context36.stop();
4077
4108
  }
4078
- }, _callee35, this);
4109
+ }, _callee36, this);
4079
4110
  }));
4080
- function queryBookingAvailability(_x29, _x30) {
4111
+ function queryBookingAvailability(_x30, _x31) {
4081
4112
  return _queryBookingAvailability.apply(this, arguments);
4082
4113
  }
4083
4114
  return queryBookingAvailability;
@@ -4147,27 +4178,27 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4147
4178
  }, {
4148
4179
  key: "commitAvailabilitySelection",
4149
4180
  value: (function () {
4150
- var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee36(contextId, params) {
4181
+ var _commitAvailabilitySelection = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee37(contextId, params) {
4151
4182
  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) {
4183
+ return _regeneratorRuntime().wrap(function _callee37$(_context37) {
4184
+ while (1) switch (_context37.prev = _context37.next) {
4154
4185
  case 0:
4155
4186
  normalizedContextId = String(contextId || '').trim();
4156
4187
  if (normalizedContextId) {
4157
- _context36.next = 3;
4188
+ _context37.next = 3;
4158
4189
  break;
4159
4190
  }
4160
4191
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'commitAvailabilitySelection 缺少 contextId', {
4161
4192
  candidate: params.candidate
4162
4193
  });
4163
4194
  case 3:
4164
- _context36.next = 5;
4195
+ _context37.next = 5;
4165
4196
  return this.tryAcquireAvailabilityCommitLock(normalizedContextId);
4166
4197
  case 5:
4167
- _context36.prev = 5;
4198
+ _context37.prev = 5;
4168
4199
  bookingCount = Number((_params$bookingCount = params.bookingCount) !== null && _params$bookingCount !== void 0 ? _params$bookingCount : 1);
4169
4200
  if (!(!Number.isInteger(bookingCount) || bookingCount <= 0)) {
4170
- _context36.next = 9;
4201
+ _context37.next = 9;
4171
4202
  break;
4172
4203
  }
4173
4204
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'bookingCount 必须是正整数', {
@@ -4175,7 +4206,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4175
4206
  });
4176
4207
  case 9:
4177
4208
  if (!(params.mode === 'edit' && bookingCount !== 1)) {
4178
- _context36.next = 11;
4209
+ _context37.next = 11;
4179
4210
  break;
4180
4211
  }
4181
4212
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', '编辑预约商品时 bookingCount 必须为 1', {
@@ -4184,7 +4215,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4184
4215
  case 11:
4185
4216
  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;
4186
4217
  if (!(orderProductQuantity !== undefined && orderProductQuantity !== null && Number(orderProductQuantity) !== bookingCount)) {
4187
- _context36.next = 14;
4218
+ _context37.next = 14;
4188
4219
  break;
4189
4220
  }
4190
4221
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'orderProduct 数量与 bookingCount 不一致', {
@@ -4194,22 +4225,22 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4194
4225
  case 14:
4195
4226
  partySize = Number(params.partySize);
4196
4227
  if (!(!Number.isInteger(partySize) || partySize <= 0)) {
4197
- _context36.next = 17;
4228
+ _context37.next = 17;
4198
4229
  break;
4199
4230
  }
4200
4231
  throw new AvailabilityError('INVALID_RESERVATION_QUANTITY', 'partySize 必须是正整数', {
4201
4232
  partySize: params.partySize
4202
4233
  });
4203
4234
  case 17:
4204
- _context36.next = 19;
4235
+ _context37.next = 19;
4205
4236
  return this.ensureAvailabilityContextProjection(normalizedContextId, 'commit_precheck');
4206
4237
  case 19:
4207
- _yield$this$ensureAva3 = _context36.sent;
4238
+ _yield$this$ensureAva3 = _context37.sent;
4208
4239
  context = _yield$this$ensureAva3.context;
4209
4240
  projectionEntry = _yield$this$ensureAva3.projectionEntry;
4210
4241
  refreshed = _yield$this$ensureAva3.refreshed;
4211
4242
  if (!refreshed) {
4212
- _context36.next = 25;
4243
+ _context37.next = 25;
4213
4244
  break;
4214
4245
  }
4215
4246
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -4220,11 +4251,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4220
4251
  case 25:
4221
4252
  boundEditingUids = context.prepareParams.editingProductLineUids || [];
4222
4253
  if (!(params.mode === 'edit')) {
4223
- _context36.next = 31;
4254
+ _context37.next = 31;
4224
4255
  break;
4225
4256
  }
4226
4257
  if (!(!params.productLineUid || !boundEditingUids.includes(String(params.productLineUid)))) {
4227
- _context36.next = 29;
4258
+ _context37.next = 29;
4228
4259
  break;
4229
4260
  }
4230
4261
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 与当前商品行不匹配,请重新 prepare 编辑上下文', {
@@ -4233,11 +4264,11 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4233
4264
  editingProductLineUids: boundEditingUids
4234
4265
  });
4235
4266
  case 29:
4236
- _context36.next = 33;
4267
+ _context37.next = 33;
4237
4268
  break;
4238
4269
  case 31:
4239
4270
  if (!(boundEditingUids.length > 0)) {
4240
- _context36.next = 33;
4271
+ _context37.next = 33;
4241
4272
  break;
4242
4273
  }
4243
4274
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'edit context 不能用于 add,请重新 prepare 新增上下文', {
@@ -4246,7 +4277,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4246
4277
  });
4247
4278
  case 33:
4248
4279
  if (!(projectionEntry.contextVersion !== context.activeVersion)) {
4249
- _context36.next = 35;
4280
+ _context37.next = 35;
4250
4281
  break;
4251
4282
  }
4252
4283
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', 'availability context 已刷新,请重新获取候选', {
@@ -4256,7 +4287,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4256
4287
  });
4257
4288
  case 35:
4258
4289
  if (!(projectionEntry.orderRevision !== this.getCurrentOrderRevision())) {
4259
- _context36.next = 37;
4290
+ _context37.next = 37;
4260
4291
  break;
4261
4292
  }
4262
4293
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '购物车已变化,请重新获取候选', {
@@ -4267,7 +4298,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4267
4298
  });
4268
4299
  case 37:
4269
4300
  if (!(projectionEntry.contextVersion !== params.candidate.availabilityContextVersion)) {
4270
- _context36.next = 39;
4301
+ _context37.next = 39;
4271
4302
  break;
4272
4303
  }
4273
4304
  throw this.createAvailabilityFacadeError('AVAILABILITY_SELECTION_STALE', '候选已过期,请重新获取最新时间段', {
@@ -4279,7 +4310,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4279
4310
  this.assertAvailabilityCandidateFreshness(context, params.candidate);
4280
4311
  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
4312
  if (sameAvailabilityId(orderProductId, params.candidate.productId)) {
4282
- _context36.next = 43;
4313
+ _context37.next = 43;
4283
4314
  break;
4284
4315
  }
4285
4316
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 与 candidate 商品不一致', {
@@ -4288,14 +4319,14 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4288
4319
  });
4289
4320
  case 43:
4290
4321
  if (!(params.mode === 'edit' && !params.productLineUid)) {
4291
- _context36.next = 45;
4322
+ _context37.next = 45;
4292
4323
  break;
4293
4324
  }
4294
4325
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', 'edit 模式必须提供 productLineUid');
4295
4326
  case 45:
4296
4327
  editingLine = params.mode === 'edit' ? this.findProductLineByUid(String(params.productLineUid)) : undefined;
4297
4328
  if (!(params.mode === 'edit' && !editingLine)) {
4298
- _context36.next = 48;
4329
+ _context37.next = 48;
4299
4330
  break;
4300
4331
  }
4301
4332
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '找不到要编辑的预约商品行', {
@@ -4303,7 +4334,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4303
4334
  });
4304
4335
  case 48:
4305
4336
  if (!(editingLine && !sameAvailabilityId((_editingLine$product_ = editingLine.product_id) !== null && _editingLine$product_ !== void 0 ? _editingLine$product_ : editingLine.id, params.candidate.productId))) {
4306
- _context36.next = 50;
4337
+ _context37.next = 50;
4307
4338
  break;
4308
4339
  }
4309
4340
  throw new AvailabilityError('INVALID_TARGET_FILTER', '编辑商品行与 candidate 商品不一致', {
@@ -4313,7 +4344,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4313
4344
  });
4314
4345
  case 50:
4315
4346
  if (Array.isArray(params.requirementSelections)) {
4316
- _context36.next = 52;
4347
+ _context37.next = 52;
4317
4348
  break;
4318
4349
  }
4319
4350
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'requirementSelections 必须是数组', {
@@ -4330,7 +4361,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4330
4361
  };
4331
4362
  prepareParams = baseProjection.meta.prepareParams;
4332
4363
  if (prepareParams) {
4333
- _context36.next = 57;
4364
+ _context37.next = 57;
4334
4365
  break;
4335
4366
  }
4336
4367
  throw new AvailabilityError('REVALIDATION_FAILED', 'projection 缺少 prepareParams,无法执行缓存重校验');
@@ -4342,7 +4373,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4342
4373
  })),
4343
4374
  includesInjectedRawOccupancies: true
4344
4375
  };
4345
- _context36.next = 60;
4376
+ _context37.next = 60;
4346
4377
  return this.buildAvailabilityProjectionSnapshot(_objectSpread(_objectSpread({}, this.cloneAvailabilityPrepareParams(prepareParams)), {}, {
4347
4378
  editingProductLineUids: params.mode === 'edit' && params.productLineUid ? [params.productLineUid] : []
4348
4379
  }), {
@@ -4351,13 +4382,13 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4351
4382
  durationCandidateAnchorAt: this.getAvailabilityDurationCandidateAnchorAt(baseProjection) || context.durationCandidateAnchorAt
4352
4383
  });
4353
4384
  case 60:
4354
- commitSnapshot = _context36.sent;
4385
+ commitSnapshot = _context37.sent;
4355
4386
  refreshedProjection = commitSnapshot.projection;
4356
4387
  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;
4388
+ _context37.next = 67;
4358
4389
  break;
4359
4390
  }
4360
- _context36.next = 65;
4391
+ _context37.next = 65;
4361
4392
  return this.refreshAvailabilityContextProjection({
4362
4393
  contextId: normalizedContextId,
4363
4394
  reason: 'commit_order_revision_changed',
@@ -4389,7 +4420,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4389
4420
  return candidate.startAt === params.candidate.startAt && candidate.endAt === params.candidate.endAt && candidate.bookingStartAt === params.candidate.bookingStartAt && candidate.bookingEndAt === params.candidate.bookingEndAt;
4390
4421
  });
4391
4422
  if (refreshedCandidateBase) {
4392
- _context36.next = 72;
4423
+ _context37.next = 72;
4393
4424
  break;
4394
4425
  }
4395
4426
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后候选时间已不在商品配置中', {
@@ -4405,7 +4436,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4405
4436
  bookingCount: bookingCount
4406
4437
  });
4407
4438
  if (validation.ok) {
4408
- _context36.next = 76;
4439
+ _context37.next = 76;
4409
4440
  break;
4410
4441
  }
4411
4442
  capacityConflict = validation.conflicts.find(function (conflict) {
@@ -4428,7 +4459,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4428
4459
  incrementVersion: true
4429
4460
  });
4430
4461
  revalidatedContext = this.getAvailabilityContextEntry(normalizedContextId);
4431
- _context36.next = 80;
4462
+ _context37.next = 80;
4432
4463
  return this.emitAvailabilityDiagnostic({
4433
4464
  action: 'refresh',
4434
4465
  contextId: normalizedContextId,
@@ -4452,7 +4483,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4452
4483
  return sameAvailabilityId(item.id, refreshedCandidate.productId);
4453
4484
  });
4454
4485
  if (product) {
4455
- _context36.next = 85;
4486
+ _context37.next = 85;
4456
4487
  break;
4457
4488
  }
4458
4489
  throw new AvailabilityError('REVALIDATION_FAILED', '缓存重校验后商品不在 projection 中', {
@@ -4462,7 +4493,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4462
4493
  existingBooking = editingLine ? this.findLinkedBooking(editingLine) : undefined;
4463
4494
  existingBookingUid = existingBooking ? getBookingUid(existingBooking) : '';
4464
4495
  if (!(params.mode === 'edit' && !existingBookingUid)) {
4465
- _context36.next = 89;
4496
+ _context37.next = 89;
4466
4497
  break;
4467
4498
  }
4468
4499
  throw new AvailabilityError('PRODUCT_LINE_NOT_FOUND', '编辑商品行缺少关联 booking', {
@@ -4484,7 +4515,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4484
4515
  quantity: bookingCount
4485
4516
  }), 'unified_booking_sales', product);
4486
4517
  if (transformed) {
4487
- _context36.next = 94;
4518
+ _context37.next = 94;
4488
4519
  break;
4489
4520
  }
4490
4521
  throw new AvailabilityError('INVALID_TARGET_FILTER', 'orderProduct 无法转换为订单行', {
@@ -4503,7 +4534,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4503
4534
  productLineUids = [];
4504
4535
  bookingUids = [];
4505
4536
  if (!(params.mode === 'edit' && editingLine && params.productLineUid)) {
4506
- _context36.next = 113;
4537
+ _context37.next = 113;
4507
4538
  break;
4508
4539
  }
4509
4540
  transformed.product_sku = (_transformed$product_ = transformed.product_sku) !== null && _transformed$product_ !== void 0 ? _transformed$product_ : editingLine.product_sku;
@@ -4513,7 +4544,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4513
4544
  unique_identification_number: params.productLineUid,
4514
4545
  booking_uid: existingBookingUid
4515
4546
  });
4516
- _context36.next = 107;
4547
+ _context37.next = 107;
4517
4548
  return this.updateOrderProduct({
4518
4549
  product_id: (_transformed$product_3 = transformed.product_id) !== null && _transformed$product_3 !== void 0 ? _transformed$product_3 : editingLine.product_id,
4519
4550
  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,
@@ -4526,7 +4557,7 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4526
4557
  bookingUid = existingBookingUid;
4527
4558
  productLineUids = [productLineUid];
4528
4559
  bookingUids = [bookingUid];
4529
- _context36.next = 125;
4560
+ _context37.next = 125;
4530
4561
  break;
4531
4562
  case 113:
4532
4563
  beforeProductLineUids = new Set((((_this$getTempOrder4 = this.getTempOrder()) === null || _this$getTempOrder4 === void 0 ? void 0 : _this$getTempOrder4.products) || []).map(function (line) {
@@ -4535,10 +4566,10 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4535
4566
  beforeBookingUids = new Set((((_this$getTempOrder5 = this.getTempOrder()) === null || _this$getTempOrder5 === void 0 ? void 0 : _this$getTempOrder5.bookings) || []).map(function (item) {
4536
4567
  return getBookingUid(item);
4537
4568
  }).filter(Boolean));
4538
- _context36.next = 117;
4569
+ _context37.next = 117;
4539
4570
  return this.addProductToOrder(transformed, booking);
4540
4571
  case 117:
4541
- products = _context36.sent;
4572
+ products = _context37.sent;
4542
4573
  addedLines = products.filter(function (line) {
4543
4574
  var _line$product_id, _line$metadata;
4544
4575
  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));
@@ -4575,23 +4606,23 @@ export var UnifiedBookingSalesImpl = /*#__PURE__*/function (_BookingTicket) {
4575
4606
  productLineUids: productLineUids,
4576
4607
  bookingUids: bookingUids
4577
4608
  };
4578
- _context36.next = 130;
4609
+ _context37.next = 130;
4579
4610
  return this.core.effects.emit("".concat(this.name, ":").concat(UnifiedBookingSalesHooks.onAvailabilitySelectionCommitted), result);
4580
4611
  case 130:
4581
- return _context36.abrupt("return", result);
4612
+ return _context37.abrupt("return", result);
4582
4613
  case 131:
4583
- _context36.prev = 131;
4584
- _context36.next = 134;
4614
+ _context37.prev = 131;
4615
+ _context37.next = 134;
4585
4616
  return this.releaseAvailabilityCommitLock(normalizedContextId);
4586
4617
  case 134:
4587
- return _context36.finish(131);
4618
+ return _context37.finish(131);
4588
4619
  case 135:
4589
4620
  case "end":
4590
- return _context36.stop();
4621
+ return _context37.stop();
4591
4622
  }
4592
- }, _callee36, this, [[5,, 131, 135]]);
4623
+ }, _callee37, this, [[5,, 131, 135]]);
4593
4624
  }));
4594
- function commitAvailabilitySelection(_x31, _x32) {
4625
+ function commitAvailabilitySelection(_x32, _x33) {
4595
4626
  return _commitAvailabilitySelection.apply(this, arguments);
4596
4627
  }
4597
4628
  return commitAvailabilitySelection;