@pisell/pisellos 3.0.15 → 3.0.18

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.
@@ -430,7 +430,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
430
430
  break;
431
431
  }
432
432
  _context7.next = 3;
433
- return this.store.accountList.addHolderAccounts([account], extra.customerId);
433
+ return this.store.accountList.addHolderAccounts({
434
+ holders: [account],
435
+ customerId: extra.customerId,
436
+ type: 'unshift'
437
+ });
434
438
  case 3:
435
439
  accountModules = _context7.sent;
436
440
  return _context7.abrupt("return", accountModules[0].getAccount());
@@ -463,7 +467,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
463
467
  _context8.next = 3;
464
468
  break;
465
469
  }
466
- this.store.accountList.addHolderAccounts(accounts, extra.customerId);
470
+ this.store.accountList.addHolderAccounts({
471
+ holders: accounts,
472
+ customerId: extra.customerId,
473
+ type: 'unshift'
474
+ });
467
475
  return _context8.abrupt("return");
468
476
  case 3:
469
477
  res = [];
@@ -641,7 +649,10 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
641
649
  key: "getAvailableDate",
642
650
  value: function () {
643
651
  var _getAvailableDate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
644
- var _this3 = this;
652
+ var _this3 = this,
653
+ _dateRange$,
654
+ _dateRange$2,
655
+ _dateRange$3;
645
656
  var params,
646
657
  products,
647
658
  startDate,
@@ -684,8 +695,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
684
695
  })];
685
696
  }
686
697
  dateRange = this.store.date.getDateRange();
687
- tempStartDate = startDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[0].date);
688
- tempEndDate = endDate || (dateRange === null || dateRange === void 0 ? void 0 : dateRange[1].date);
698
+ tempStartDate = startDate || (dateRange === null || dateRange === void 0 || (_dateRange$ = dateRange[0]) === null || _dateRange$ === void 0 ? void 0 : _dateRange$.date);
699
+ tempEndDate = endDate || (dateRange === null || dateRange === void 0 || (_dateRange$2 = dateRange[1]) === null || _dateRange$2 === void 0 ? void 0 : _dateRange$2.date) || (dateRange === null || dateRange === void 0 || (_dateRange$3 = dateRange[0]) === null || _dateRange$3 === void 0 ? void 0 : _dateRange$3.date);
689
700
  if (tempProducts.length) {
690
701
  _context13.next = 11;
691
702
  break;
@@ -1026,6 +1037,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1026
1037
  if (!targetCartItem) {
1027
1038
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(params._id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
1028
1039
  }
1040
+ var currentResourcesCapacityMap = {};
1029
1041
  if (params.resources) {
1030
1042
  var _targetCartItem$_prod;
1031
1043
  var formatCapacity = formatDefaultCapacitys({
@@ -1037,39 +1049,90 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1037
1049
  });
1038
1050
  params.resources = params.resources.map(function (n) {
1039
1051
  n.capacity = currentCapacity || 1;
1052
+ currentResourcesCapacityMap[n.id] = currentCapacity;
1040
1053
  checkSubResourcesCapacity(n);
1041
1054
  return n;
1042
1055
  });
1043
1056
  }
1044
1057
  this.store.cart.updateItem(params);
1045
- // 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,则要把选择了相同资源的 product._origin.resources 给去除
1058
+ var allOriginResources = [];
1059
+ var dateRange = this.store.date.getDateRange();
1060
+ if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1061
+ dateRange.forEach(function (n) {
1062
+ if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
1063
+ });
1064
+ }
1065
+ // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1066
+ if (!allOriginResources.length) {
1067
+ var dateList = this.store.date.getDateList();
1068
+ dateList.forEach(function (n) {
1069
+ if (n.resource) allOriginResources.push.apply(allOriginResources, _toConsumableArray(n.resource));
1070
+ });
1071
+ }
1072
+ // 更新购物车后,需要判定购物车里是否存在多个账号选择了相同资源的情况,如果是,且资源是单个预约,则要把选择了相同资源的 product._origin.resources 给去除
1046
1073
  var cartItems = this.store.cart.getItems();
1047
1074
  cartItems.forEach(function (item) {
1048
- if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
1075
+ if (item._id !== targetCartItem._id) {
1049
1076
  var _item$_origin$resourc;
1050
1077
  var resources = (_item$_origin$resourc = item._origin.resources) === null || _item$_origin$resourc === void 0 ? void 0 : _item$_origin$resourc.filter(function (m) {
1051
1078
  // 检查当前资源是否与目标资源的任何资源匹配
1052
1079
  return !targetCartItem._origin.resources.some(function (targetRes) {
1053
- var _targetRes$metadata$c, _m$metadata$combined_;
1054
- // 检查主资源ID是否匹配
1055
- if (targetRes.id === m.id) return true;
1056
- // 检查组合资源的情况
1057
- if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
1058
- // 如果现在选择的是组合资源,需要判断
1059
- // 1、当前其他购物车里是否选了当前组合资源的子资源
1060
- // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
1061
-
1062
- targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
1063
- return m.metadata.combined_resource.resource_ids.includes(n);
1064
- }))) return true;
1065
- if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
1080
+ // 如果新更新进来的资源不是单个预约,其实就不需要检测了资源重叠了,但是需要检测资源 capacity 是否足够
1081
+ if (targetRes.resourceType !== 'single') {
1082
+ var _item$_productOrigin2;
1083
+ var _formatCapacity = formatDefaultCapacitys({
1084
+ capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1085
+ product_bundle: item._origin.product.product_bundle
1086
+ });
1087
+ var _currentCapacity = getSumCapacity({
1088
+ capacity: _formatCapacity
1089
+ });
1090
+ var originResource = allOriginResources.find(function (n) {
1091
+ return n.id === targetRes.id;
1092
+ });
1093
+ if (currentResourcesCapacityMap[targetRes.id] + _currentCapacity > (originResource === null || originResource === void 0 ? void 0 : originResource.capacity)) {
1094
+ return true;
1095
+ }
1096
+ currentResourcesCapacityMap[targetRes.id] += _currentCapacity;
1097
+ return false;
1098
+ }
1099
+ if (item.holder_id !== (targetCartItem === null || targetCartItem === void 0 ? void 0 : targetCartItem.holder_id)) {
1100
+ var _targetRes$metadata$c, _m$metadata$combined_;
1101
+ // 检查主资源ID是否匹配
1102
+ if (targetRes.id === m.id) return true;
1103
+ // 检查组合资源的情况
1104
+ if (((_targetRes$metadata$c = targetRes.metadata.combined_resource) === null || _targetRes$metadata$c === void 0 ? void 0 : _targetRes$metadata$c.status) === 1 && (
1105
+ // 如果现在选择的是组合资源,需要判断
1106
+ // 1、当前其他购物车里是否选了当前组合资源的子资源
1107
+ // 2、如果其他购物车里的商品也是组合资源,出了组合资源本身的 id 需要判断,还需要判断子资源的 id 是否有交集
1108
+ targetRes.metadata.combined_resource.resource_ids.includes(m.id) || targetRes.metadata.combined_resource.resource_ids.some(function (n) {
1109
+ return m.metadata.combined_resource.resource_ids.includes(n);
1110
+ }))) return true;
1111
+ if (((_m$metadata$combined_ = m.metadata.combined_resource) === null || _m$metadata$combined_ === void 0 ? void 0 : _m$metadata$combined_.status) === 1 && m.metadata.combined_resource.resource_ids.includes(targetRes.id)) return true;
1112
+ }
1066
1113
  return false;
1067
1114
  });
1068
1115
  });
1069
- _this5.store.cart.updateItem({
1070
- _id: item._id,
1071
- resources: resources
1072
- });
1116
+ // session 类商品应该只调用清空 resource 的方法
1117
+ if (item.start_time) {
1118
+ var start_time = item.start_time;
1119
+ var end_time = item.end_time;
1120
+ var start_date = item.start_date;
1121
+ var end_date = item.end_date;
1122
+ _this5.store.cart.updateItem({
1123
+ _id: item._id,
1124
+ resources: resources,
1125
+ date: {
1126
+ startTime: dayjs("".concat(start_date, " ").concat(start_time)).format('YYYY-MM-DD HH:mm'),
1127
+ endTime: dayjs("".concat(end_date, " ").concat(end_time)).format('YYYY-MM-DD HH:mm')
1128
+ }
1129
+ });
1130
+ } else {
1131
+ _this5.store.cart.updateItem({
1132
+ _id: item._id,
1133
+ resources: resources
1134
+ });
1135
+ }
1073
1136
  }
1074
1137
  });
1075
1138
  }
@@ -1178,15 +1241,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1178
1241
  var resourcesMap = getResourcesMap(cloneDeep(resources));
1179
1242
  var cartItems = this.store.cart.getItems();
1180
1243
  var arr = [];
1181
- var capacityMap = {};
1182
1244
  cartItems.forEach(function (cartItem) {
1183
1245
  var _cartItem$_productOri, _cartItem$_productOri2;
1184
1246
  var selectedResources = [];
1185
- if (cartItem.holder_id) {
1186
- selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
1187
- } else {
1188
- selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1189
- }
1190
1247
  var formatCapacity = formatDefaultCapacitys({
1191
1248
  capacity: (_cartItem$_productOri = cartItem._productOrigin) === null || _cartItem$_productOri === void 0 ? void 0 : _cartItem$_productOri.capacity,
1192
1249
  product_bundle: cartItem._origin.product.product_bundle
@@ -1195,6 +1252,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1195
1252
  var currentCapacity = getSumCapacity({
1196
1253
  capacity: formatCapacity
1197
1254
  });
1255
+ if (cartItem.holder_id) {
1256
+ selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
1257
+ } else {
1258
+ selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1259
+ }
1198
1260
  var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri2 = cartItem._productOrigin) === null || _cartItem$_productOri2 === void 0 || (_cartItem$_productOri2 = _cartItem$_productOri2.product_resource) === null || _cartItem$_productOri2 === void 0 ? void 0 : _cartItem$_productOri2.resources) || [], selectedResources, currentCapacity);
1199
1261
  // 如果购物车里已经有了时间片,则需要按照时间片过滤
1200
1262
  if (cartItem._origin.start_time) {
@@ -1212,7 +1274,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1212
1274
  return 0;
1213
1275
  });
1214
1276
  n.renderList = n.renderList.filter(function (m) {
1215
- var recordCount = capacityMap[m.id] || 0;
1216
1277
  // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
1217
1278
  // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
1218
1279
  // 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
@@ -1233,7 +1294,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1233
1294
  },
1234
1295
  time: item,
1235
1296
  resource: m,
1236
- currentCount: recordCount + (currentCapacity || 0),
1297
+ currentCount: currentCapacity || 0,
1237
1298
  resourcesUseableMap: resourcesUseableMap
1238
1299
  });
1239
1300
  // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
@@ -1282,6 +1343,132 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1282
1343
  return arr;
1283
1344
  }
1284
1345
 
1346
+ // 在日期那边点击下一步的时候,检查这一天购物车里的商品是不是都有资源可以用
1347
+ }, {
1348
+ key: "checkResourceListForDate",
1349
+ value: function checkResourceListForDate() {
1350
+ var dateRange = this.store.date.getDateRange();
1351
+ var resources = [];
1352
+ if (dateRange !== null && dateRange !== void 0 && dateRange.length) {
1353
+ dateRange.forEach(function (n) {
1354
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1355
+ });
1356
+ }
1357
+ // 如果此时 resources 为空,视作购物车里已经有了 dateRange 数据,此时 dateList 里明确就是那一天的数据
1358
+ if (!resources.length) {
1359
+ var dateList = this.store.date.getDateList();
1360
+ dateList.forEach(function (n) {
1361
+ if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1362
+ });
1363
+ }
1364
+ var resourcesMap = getResourcesMap(cloneDeep(resources));
1365
+ var cartItems = this.store.cart.getItems();
1366
+ var arr = [];
1367
+ cartItems.forEach(function (cartItem) {
1368
+ var _cartItem$_productOri4, _cartItem$_productOri5;
1369
+ var selectedResources = [];
1370
+ var formatCapacity = formatDefaultCapacitys({
1371
+ capacity: (_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.capacity,
1372
+ product_bundle: cartItem._origin.product.product_bundle
1373
+ });
1374
+ cartItem._origin.metadata.capacity = formatCapacity;
1375
+ var currentCapacity = getSumCapacity({
1376
+ capacity: formatCapacity
1377
+ });
1378
+ if (cartItem.holder_id) {
1379
+ selectedResources = getOthersSelectedResources(cartItems, cartItem.holder_id, resourcesMap);
1380
+ } else {
1381
+ selectedResources = getOthersCartSelectedResources(cartItems, cartItem._id, resourcesMap);
1382
+ }
1383
+ var productResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri5 = cartItem._productOrigin) === null || _cartItem$_productOri5 === void 0 || (_cartItem$_productOri5 = _cartItem$_productOri5.product_resource) === null || _cartItem$_productOri5 === void 0 ? void 0 : _cartItem$_productOri5.resources) || [], selectedResources, currentCapacity);
1384
+ // 如果购物车里已经有了时间片,则需要按照时间片过滤
1385
+ if (cartItem._origin.start_time) {
1386
+ var startTime = dayjs("".concat(cartItem._origin.start_date, " ").concat(cartItem._origin.start_time));
1387
+ var endTime = dayjs("".concat(cartItem._origin.end_date, " ").concat(cartItem._origin.end_time));
1388
+ var resourcesUseableMap = {};
1389
+ productResources.forEach(function (n) {
1390
+ // 资源排下序,把单个资源靠前,组合资源排在后面
1391
+ n.renderList = n.renderList.sort(function (a, b) {
1392
+ var _a$metadata2, _b$metadata2;
1393
+ var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
1394
+ var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
1395
+ if (aIsCombined && !bIsCombined) return 1;
1396
+ if (!aIsCombined && bIsCombined) return -1;
1397
+ return 0;
1398
+ });
1399
+ n.renderList = n.renderList.filter(function (m) {
1400
+ // m.times 需要做个过滤,假设 timeSlice.start_at 是 09:30 timeSlice.end_at 是 11:30
1401
+ // time 是 time.start_at = 2025-05-26 10:30, time.end_at = 2025-05-26 12:30
1402
+ // 需要判断 time 的开始结束时间 是否包含timeSlice的开始结束时间
1403
+ var mTimes = m.times.filter(function (n) {
1404
+ return !dayjs(n.start_at).isAfter(dayjs(startTime)) && !dayjs(n.end_at).isBefore(dayjs(endTime));
1405
+ });
1406
+ // 如果在这个区间的时间一个都没有,可以直接认为这个资源不可用
1407
+ if (mTimes.length === 0) {
1408
+ return false;
1409
+ }
1410
+ var canUseArr = mTimes.map(function (item) {
1411
+ var res = getIsUsableByTimeItem({
1412
+ timeSlice: {
1413
+ start_time: startTime.format('HH:mm'),
1414
+ end_time: endTime.format('HH:mm'),
1415
+ start_at: startTime,
1416
+ end_at: endTime
1417
+ },
1418
+ time: item,
1419
+ resource: m,
1420
+ currentCount: currentCapacity || 0,
1421
+ resourcesUseableMap: resourcesUseableMap
1422
+ });
1423
+ // 如果仅仅是因为子资源容量不够,不应该标记子资源是被占用的情况
1424
+ if ((resourcesUseableMap === null || resourcesUseableMap === void 0 ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== 'capacityOnly') {
1425
+ resourcesUseableMap[m.id] = res.usable;
1426
+ }
1427
+ return res.usable;
1428
+ });
1429
+ if (m.onlyComputed) return false;
1430
+ // 在已经选定时间的情况下,只要canUseTime 里有一个 false,那就代表不可用
1431
+ return !canUseArr.some(function (n) {
1432
+ return n === false;
1433
+ });
1434
+ });
1435
+ });
1436
+ } else {
1437
+ productResources.forEach(function (item) {
1438
+ // 如果资源的 capacity 已经小于了当前需要的 capacity ,则需要把资源给过滤掉
1439
+ // 同时,在这一步尝试去拉一下时间片,基于商品的时长,看每个资源是否还有空余时间能对这个商品做服务,如果没有则过滤
1440
+ item.renderList = item.renderList.filter(function (n) {
1441
+ var _cartItem$_productOri6;
1442
+ var recordCount = n.capacity || 0;
1443
+ if (n.onlyComputed) return false;
1444
+ // 查一下这个资源基于商品的可用时间片
1445
+ var timeSlots = getTimeSlicesByResource({
1446
+ resource: n,
1447
+ duration: ((_cartItem$_productOri6 = cartItem._productOrigin) === null || _cartItem$_productOri6 === void 0 || (_cartItem$_productOri6 = _cartItem$_productOri6.duration) === null || _cartItem$_productOri6 === void 0 ? void 0 : _cartItem$_productOri6.value) || 0,
1448
+ split: 10,
1449
+ currentDate: dateRange[0].date
1450
+ });
1451
+ return recordCount >= currentCapacity && timeSlots.length > 0;
1452
+ });
1453
+ });
1454
+ }
1455
+ arr.push({
1456
+ id: cartItem.id,
1457
+ // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
1458
+ _id: cartItem._id,
1459
+ // 这里返回的是购物车 id ,后面提交的时候要用的,用这个 id 绑定资源和时间
1460
+ productResources: productResources
1461
+ });
1462
+ });
1463
+ // 检查 productResources里是不是每一项资源的 renderList 里都有数据
1464
+ var hasResource = arr.every(function (n) {
1465
+ return n.productResources.every(function (m) {
1466
+ return m.renderList.length > 0;
1467
+ });
1468
+ });
1469
+ return hasResource;
1470
+ }
1471
+
1285
1472
  // 给单个购物车里的商品获取资源列表
1286
1473
  }, {
1287
1474
  key: "getResourcesListByCartItem",
@@ -1293,9 +1480,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1293
1480
  dateRange.forEach(function (n) {
1294
1481
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1295
1482
  });
1296
- // 这里为什么要 cloneDeep:因为 getOthersSelectedResources 和 getOthersCartSelectedResources 会修改 resourcesMap 的 capacity
1297
1483
  // 用于确保后续分配的容量不会超出
1298
- var resourcesMap = getResourcesMap(cloneDeep(resources));
1484
+ var resourcesMap = getResourcesMap(resources);
1299
1485
  var targetCartItem = cartItems.find(function (n) {
1300
1486
  return n._id === id;
1301
1487
  });
@@ -1303,11 +1489,6 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1303
1489
  throw new Error("\u6CA1\u6709\u627E\u5230".concat(id, "\u8D2D\u7269\u8F66\u5546\u54C1"));
1304
1490
  }
1305
1491
  var selectedResources = [];
1306
- if (targetCartItem.holder_id) {
1307
- selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
1308
- } else {
1309
- selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
1310
- }
1311
1492
  var formatCapacity = formatDefaultCapacitys({
1312
1493
  capacity: (_targetCartItem$_prod2 = targetCartItem._productOrigin) === null || _targetCartItem$_prod2 === void 0 ? void 0 : _targetCartItem$_prod2.capacity,
1313
1494
  product_bundle: targetCartItem._origin.product.product_bundle
@@ -1315,6 +1496,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1315
1496
  var currentCapacity = getSumCapacity({
1316
1497
  capacity: formatCapacity
1317
1498
  });
1499
+ if (targetCartItem.holder_id) {
1500
+ selectedResources = getOthersSelectedResources(cartItems, targetCartItem.holder_id, resourcesMap);
1501
+ } else {
1502
+ selectedResources = getOthersCartSelectedResources(cartItems, targetCartItem._id, resourcesMap);
1503
+ }
1318
1504
  var productResources = getResourcesByProduct(resourcesMap, ((_targetCartItem$_prod3 = targetCartItem._productOrigin) === null || _targetCartItem$_prod3 === void 0 || (_targetCartItem$_prod3 = _targetCartItem$_prod3.product_resource) === null || _targetCartItem$_prod3 === void 0 ? void 0 : _targetCartItem$_prod3.resources) || [], selectedResources, currentCapacity);
1319
1505
  productResources.forEach(function (item) {
1320
1506
  item.renderList = item.renderList.filter(function (n) {
@@ -1360,7 +1546,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1360
1546
  }, {
1361
1547
  key: "autoSelectAccountResources",
1362
1548
  value: function autoSelectAccountResources(_ref8) {
1363
- var _cartItem$_productOri4, _allProductResources$;
1549
+ var _cartItem$_productOri7, _allProductResources$;
1364
1550
  var cartItem = _ref8.cartItem,
1365
1551
  holder_id = _ref8.holder_id,
1366
1552
  resources_code = _ref8.resources_code,
@@ -1409,21 +1595,22 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1409
1595
  var resourcesMap = getResourcesMap(cloneDeep(AllResources));
1410
1596
  var allCartItems = cloneDeep(this.store.cart.getItems());
1411
1597
  var selectedResources = getOthersSelectedResources(allCartItems, holder_id, resourcesMap);
1412
- var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri4 = cartItem._productOrigin) === null || _cartItem$_productOri4 === void 0 || (_cartItem$_productOri4 = _cartItem$_productOri4.product_resource) === null || _cartItem$_productOri4 === void 0 ? void 0 : _cartItem$_productOri4.resources) || [], selectedResources, 1);
1598
+ var allProductResources = getResourcesByProduct(resourcesMap, ((_cartItem$_productOri7 = cartItem._productOrigin) === null || _cartItem$_productOri7 === void 0 || (_cartItem$_productOri7 = _cartItem$_productOri7.product_resource) === null || _cartItem$_productOri7 === void 0 ? void 0 : _cartItem$_productOri7.resources) || [], selectedResources, 1);
1413
1599
  var resources = ((_allProductResources$ = allProductResources.find(function (n) {
1414
1600
  return n.code === resources_code;
1415
1601
  })) === null || _allProductResources$ === void 0 ? void 0 : _allProductResources$.renderList) || [];
1416
1602
  // 资源排下序,把单个资源靠前,组合资源排在后面
1417
1603
  resources.sort(function (a, b) {
1418
- var _a$metadata2, _b$metadata2;
1419
- var aIsCombined = ((_a$metadata2 = a.metadata) === null || _a$metadata2 === void 0 || (_a$metadata2 = _a$metadata2.combined_resource) === null || _a$metadata2 === void 0 ? void 0 : _a$metadata2.status) === 1;
1420
- var bIsCombined = ((_b$metadata2 = b.metadata) === null || _b$metadata2 === void 0 || (_b$metadata2 = _b$metadata2.combined_resource) === null || _b$metadata2 === void 0 ? void 0 : _b$metadata2.status) === 1;
1604
+ var _a$metadata3, _b$metadata3;
1605
+ var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
1606
+ var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
1421
1607
  if (aIsCombined && !bIsCombined) return 1;
1422
1608
  if (!aIsCombined && bIsCombined) return -1;
1423
1609
  return 0;
1424
1610
  });
1425
1611
  var resourcesUseableMap = _toConsumableArray(selectedResources).reduce(function (acc, n) {
1426
- acc[n] = false;
1612
+ var _resourcesMap$n;
1613
+ acc[n] = ((_resourcesMap$n = resourcesMap[n]) === null || _resourcesMap$n === void 0 ? void 0 : _resourcesMap$n.resourceType) === 'single' ? false : true;
1427
1614
  return acc;
1428
1615
  }, {});
1429
1616
 
@@ -1519,16 +1706,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1519
1706
  }, {
1520
1707
  key: "autoSelectAllProductResources",
1521
1708
  value: function autoSelectAllProductResources(resources_code, timeSlots) {
1522
- var _dateRange$,
1709
+ var _dateRange$4,
1523
1710
  _this8 = this;
1524
1711
  var dateRange = this.store.date.getDateRange();
1525
1712
  var resources = [];
1526
- if (dateRange !== null && dateRange !== void 0 && (_dateRange$ = dateRange[0]) !== null && _dateRange$ !== void 0 && _dateRange$.date) {
1713
+ if (dateRange !== null && dateRange !== void 0 && (_dateRange$4 = dateRange[0]) !== null && _dateRange$4 !== void 0 && _dateRange$4.date) {
1527
1714
  dateRange.forEach(function (n) {
1528
1715
  if (n.resource) resources.push.apply(resources, _toConsumableArray(n.resource));
1529
1716
  });
1530
1717
  }
1531
- var resourcesMap = getResourcesMap(cloneDeep(resources));
1718
+ // const resourcesMap = getResourcesMap(cloneDeep(resources));
1532
1719
  // 一个账号一个账号处理
1533
1720
  var errorList = [];
1534
1721
  var selectResourcesMap = {};
@@ -1540,9 +1727,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1540
1727
  // 第一个商品分配完以后,第二个商品分配的start_time应该是第一个商品的 end_time ,然后 end_time 应该是 start_time+duration
1541
1728
 
1542
1729
  cartItems.forEach(function (item, index) {
1543
- var _item$_productOrigin2;
1730
+ var _item$_productOrigin3;
1544
1731
  var formatCapacity = formatDefaultCapacitys({
1545
- capacity: (_item$_productOrigin2 = item._productOrigin) === null || _item$_productOrigin2 === void 0 ? void 0 : _item$_productOrigin2.capacity,
1732
+ capacity: (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.capacity,
1546
1733
  product_bundle: item._origin.product.product_bundle
1547
1734
  });
1548
1735
  var currentCapacity = getSumCapacity({
@@ -1558,10 +1745,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1558
1745
  };
1559
1746
  }
1560
1747
  if (recordTimeSlots) {
1561
- if (index !== 0 && recordTimeSlots) {
1562
- var _item$_productOrigin$, _item$_productOrigin3, _ref9, _item$_productOrigin4, _item$_productOrigin$2, _item$_productOrigin5, _ref10, _item$_productOrigin6;
1563
- var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin3 = item._productOrigin) === null || _item$_productOrigin3 === void 0 || (_item$_productOrigin3 = _item$_productOrigin3.duration) === null || _item$_productOrigin3 === void 0 ? void 0 : _item$_productOrigin3.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.duration) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
1564
- var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
1748
+ var _item$_productOrigin4;
1749
+ // 同一账号下,如果当前商品不是第一个,则需要根据上一个商品的 end_time duration 计算出当前商品的 start_time end_time
1750
+ // 前提:当前资源是单个预约才需要这么做
1751
+ var currentResourceConfig = (_item$_productOrigin4 = item._productOrigin) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.product_resource) === null || _item$_productOrigin4 === void 0 || (_item$_productOrigin4 = _item$_productOrigin4.resources) === null || _item$_productOrigin4 === void 0 ? void 0 : _item$_productOrigin4.find(function (n) {
1752
+ return n.code === resources_code;
1753
+ });
1754
+ if (index !== 0 && recordTimeSlots && (currentResourceConfig === null || currentResourceConfig === void 0 ? void 0 : currentResourceConfig.type) === 'single') {
1755
+ var _item$_productOrigin$, _item$_productOrigin5, _ref9, _item$_productOrigin6, _item$_productOrigin$2, _item$_productOrigin7, _ref10, _item$_productOrigin8;
1756
+ var start_at = dayjs(recordTimeSlots.end_time).add((_item$_productOrigin$ = (_item$_productOrigin5 = item._productOrigin) === null || _item$_productOrigin5 === void 0 || (_item$_productOrigin5 = _item$_productOrigin5.duration) === null || _item$_productOrigin5 === void 0 ? void 0 : _item$_productOrigin5.value) !== null && _item$_productOrigin$ !== void 0 ? _item$_productOrigin$ : 0, (_ref9 = (_item$_productOrigin6 = item._productOrigin) === null || _item$_productOrigin6 === void 0 || (_item$_productOrigin6 = _item$_productOrigin6.duration) === null || _item$_productOrigin6 === void 0 ? void 0 : _item$_productOrigin6.type) !== null && _ref9 !== void 0 ? _ref9 : 'minutes');
1757
+ var end_at = start_at.add((_item$_productOrigin$2 = (_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.duration) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.value) !== null && _item$_productOrigin$2 !== void 0 ? _item$_productOrigin$2 : 0, (_ref10 = (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.duration) === null || _item$_productOrigin8 === void 0 ? void 0 : _item$_productOrigin8.type) !== null && _ref10 !== void 0 ? _ref10 : 'minutes');
1565
1758
  recordTimeSlots = {
1566
1759
  start_time: start_at.format('HH:mm'),
1567
1760
  end_time: end_at.format('HH:mm'),
@@ -1603,12 +1796,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1603
1796
  errorList.push(item._id);
1604
1797
  }
1605
1798
  } else {
1606
- var _item$_productOrigin7, _productResources$fin;
1799
+ var _item$_productOrigin9, _productResources$fin;
1607
1800
  // 这里必须每次循环重新读,避免前一次循环操作了购物车,导致数据变更
1608
1801
  var allCartItems = cloneDeep(_this8.store.cart.getItems());
1609
1802
  // 如果没有传递 timeSlots,代表是第一种资源,则直接拿商品的 duration,到资源列表里找一个公共可用的
1610
1803
  var selectedResources = [];
1611
- var _resources = cloneDeep(((_item$_productOrigin7 = item._productOrigin) === null || _item$_productOrigin7 === void 0 || (_item$_productOrigin7 = _item$_productOrigin7.product_resource) === null || _item$_productOrigin7 === void 0 ? void 0 : _item$_productOrigin7.resources) || []);
1804
+ var _resources = cloneDeep(((_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.resources) || []);
1612
1805
  var currentResourcesRenderList = [];
1613
1806
  _resources.forEach(function (n) {
1614
1807
  var _n$renderList;
@@ -1616,7 +1809,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1616
1809
  // 过滤掉 capacity 小于 currentCapacity 的资源
1617
1810
  n.renderList = n.renderList.filter(function (m) {
1618
1811
  var _item$duration;
1619
- var recordCount = m.capacity || 0;
1812
+ // 同时 还需要减去 selectResourcesMap 里已经选中的资源的数量
1813
+ var recordCount = (m.capacity || 0) - (selectResourcesMap[m.id] || 0);
1620
1814
  var timeSlots = getTimeSlicesByResource({
1621
1815
  resource: m,
1622
1816
  duration: (item === null || item === void 0 || (_item$duration = item.duration) === null || _item$duration === void 0 ? void 0 : _item$duration.value) || 0,
@@ -1628,16 +1822,16 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1628
1822
  currentResourcesRenderList.push.apply(currentResourcesRenderList, _toConsumableArray(n.renderList || []));
1629
1823
  }
1630
1824
  });
1631
- var _resourcesMap2 = getResourcesMap(currentResourcesRenderList);
1825
+ var resourcesMap = getResourcesMap(currentResourcesRenderList);
1632
1826
  if (item.holder_id) {
1633
- selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, _resourcesMap2);
1827
+ selectedResources = getOthersSelectedResources(allCartItems, item.holder_id, resourcesMap);
1634
1828
  } else {
1635
- selectedResources = getOthersCartSelectedResources(allCartItems, item._id, _resourcesMap2);
1829
+ selectedResources = getOthersCartSelectedResources(allCartItems, item._id, resourcesMap);
1636
1830
  }
1637
- var productResources = getResourcesByProduct(_resourcesMap2, cloneDeep(_resources), selectedResources, currentCapacity);
1831
+ var productResources = getResourcesByProduct(resourcesMap, cloneDeep(_resources), selectedResources, currentCapacity);
1638
1832
  productResources.forEach(function (item) {
1639
1833
  item.renderList = item.renderList.filter(function (n) {
1640
- var recordCount = n.capacity || 0;
1834
+ var recordCount = (n.capacity || 0) - (selectResourcesMap[n.id] || 0);
1641
1835
  if (n.onlyComputed) return false;
1642
1836
  return recordCount >= currentCapacity;
1643
1837
  });
@@ -1658,6 +1852,11 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1658
1852
  targetResource.capacity = currentCapacity;
1659
1853
  // 在这里处理 children 的数据
1660
1854
  checkSubResourcesCapacity(targetResource);
1855
+ if (!selectResourcesMap[targetResource.id]) {
1856
+ selectResourcesMap[targetResource.id] = currentCapacity;
1857
+ } else {
1858
+ selectResourcesMap[targetResource.id] += currentCapacity;
1859
+ }
1661
1860
  _this8.store.cart.updateItem({
1662
1861
  _id: item._id,
1663
1862
  resources: [].concat(_toConsumableArray((item._origin.resources || []).filter(function (existingRes) {
@@ -1702,8 +1901,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1702
1901
  var resourceIds = [];
1703
1902
  var resourcesTypeId = undefined;
1704
1903
  cartItems.forEach(function (item) {
1705
- var _item$_productOrigin8, _item$_productOrigin9;
1706
- (_item$_productOrigin8 = item._productOrigin) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.product_resource) === null || _item$_productOrigin8 === void 0 || (_item$_productOrigin8 = _item$_productOrigin8.resources) === null || _item$_productOrigin8 === void 0 || _item$_productOrigin8.forEach(function (n) {
1904
+ var _item$_productOrigin10, _item$_productOrigin11;
1905
+ (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.product_resource) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.resources) === null || _item$_productOrigin10 === void 0 || _item$_productOrigin10.forEach(function (n) {
1707
1906
  if (n.code === resources_code) {
1708
1907
  resources.push.apply(resources, _toConsumableArray(n.renderList || []));
1709
1908
  }
@@ -1714,9 +1913,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1714
1913
  if (item.resource_id) {
1715
1914
  resourceIds.push(item.resource_id);
1716
1915
  }
1717
- resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin9 = item._productOrigin) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.product_resource) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.resources) === null || _item$_productOrigin9 === void 0 || (_item$_productOrigin9 = _item$_productOrigin9.find(function (n) {
1916
+ resourcesTypeId = item === null || item === void 0 || (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.product_resource) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.resources) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.find(function (n) {
1718
1917
  return n.code === resources_code;
1719
- })) === null || _item$_productOrigin9 === void 0 ? void 0 : _item$_productOrigin9.id;
1918
+ })) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.id;
1720
1919
  });
1721
1920
  // 保险起见,在这里如果 dateRange 里也有 resources 的话,也 push 进去
1722
1921
  if ((_dateRange = dateRange) !== null && _dateRange !== void 0 && (_dateRange = _dateRange[0]) !== null && _dateRange !== void 0 && (_dateRange = _dateRange.resource) !== null && _dateRange !== void 0 && _dateRange.length) {
@@ -1736,8 +1935,8 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1736
1935
  var checkDuration = function checkDuration(cartItems) {
1737
1936
  var accountDuration = 0;
1738
1937
  cartItems.forEach(function (item) {
1739
- var _item$_productOrigin$3, _item$_productOrigin10;
1740
- accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin10 = item._productOrigin) === null || _item$_productOrigin10 === void 0 || (_item$_productOrigin10 = _item$_productOrigin10.duration) === null || _item$_productOrigin10 === void 0 ? void 0 : _item$_productOrigin10.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1938
+ var _item$_productOrigin$3, _item$_productOrigin12;
1939
+ accountDuration += (_item$_productOrigin$3 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.value) !== null && _item$_productOrigin$3 !== void 0 ? _item$_productOrigin$3 : 0;
1741
1940
  });
1742
1941
  if (accountDuration > duration) {
1743
1942
  duration = accountDuration;
@@ -1804,11 +2003,12 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1804
2003
  Object.values(itemsByAccount).forEach(function (accountItems) {
1805
2004
  var currentStartTime = timeSlots.start_at.format('YYYY-MM-DD HH:mm');
1806
2005
  accountItems.forEach(function (item, index) {
2006
+ var _newResources$;
1807
2007
  var newResources = cloneDeep(item._origin.resources);
1808
2008
  newResources.forEach(function (resource) {
1809
- var _item$_productOrigin$4, _item$_productOrigin11, _ref11, _item$_productOrigin12;
2009
+ var _item$_productOrigin$4, _item$_productOrigin13, _ref11, _item$_productOrigin14;
1810
2010
  resource.startTime = currentStartTime;
1811
- resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin11 = item._productOrigin) === null || _item$_productOrigin11 === void 0 || (_item$_productOrigin11 = _item$_productOrigin11.duration) === null || _item$_productOrigin11 === void 0 ? void 0 : _item$_productOrigin11.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin12 = item._productOrigin) === null || _item$_productOrigin12 === void 0 || (_item$_productOrigin12 = _item$_productOrigin12.duration) === null || _item$_productOrigin12 === void 0 ? void 0 : _item$_productOrigin12.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
2011
+ resource.endTime = dayjs(currentStartTime).add((_item$_productOrigin$4 = (_item$_productOrigin13 = item._productOrigin) === null || _item$_productOrigin13 === void 0 || (_item$_productOrigin13 = _item$_productOrigin13.duration) === null || _item$_productOrigin13 === void 0 ? void 0 : _item$_productOrigin13.value) !== null && _item$_productOrigin$4 !== void 0 ? _item$_productOrigin$4 : 0, (_ref11 = (_item$_productOrigin14 = item._productOrigin) === null || _item$_productOrigin14 === void 0 || (_item$_productOrigin14 = _item$_productOrigin14.duration) === null || _item$_productOrigin14 === void 0 ? void 0 : _item$_productOrigin14.type) !== null && _ref11 !== void 0 ? _ref11 : 'minutes').format('YYYY-MM-DD HH:mm');
1812
2012
  delete resource.times;
1813
2013
  });
1814
2014
  _this10.store.cart.updateItem({
@@ -1817,7 +2017,7 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1817
2017
  });
1818
2018
 
1819
2019
  // 更新下一个商品的开始时间为当前商品的结束时间
1820
- if (index < accountItems.length - 1) {
2020
+ if (index < accountItems.length - 1 && (newResources === null || newResources === void 0 || (_newResources$ = newResources[0]) === null || _newResources$ === void 0 ? void 0 : _newResources$.resourceType) === 'single') {
1821
2021
  currentStartTime = newResources[0].endTime;
1822
2022
  }
1823
2023
  });
@@ -1925,9 +2125,9 @@ export var BookingByStepImpl = /*#__PURE__*/function (_BaseModule) {
1925
2125
  });
1926
2126
  // 资源排下序,把单个资源靠前,组合资源排在后面
1927
2127
  allProductResources.sort(function (a, b) {
1928
- var _a$metadata3, _b$metadata3;
1929
- var aIsCombined = ((_a$metadata3 = a.metadata) === null || _a$metadata3 === void 0 || (_a$metadata3 = _a$metadata3.combined_resource) === null || _a$metadata3 === void 0 ? void 0 : _a$metadata3.status) === 1;
1930
- var bIsCombined = ((_b$metadata3 = b.metadata) === null || _b$metadata3 === void 0 || (_b$metadata3 = _b$metadata3.combined_resource) === null || _b$metadata3 === void 0 ? void 0 : _b$metadata3.status) === 1;
2128
+ var _a$metadata4, _b$metadata4;
2129
+ var aIsCombined = ((_a$metadata4 = a.metadata) === null || _a$metadata4 === void 0 || (_a$metadata4 = _a$metadata4.combined_resource) === null || _a$metadata4 === void 0 ? void 0 : _a$metadata4.status) === 1;
2130
+ var bIsCombined = ((_b$metadata4 = b.metadata) === null || _b$metadata4 === void 0 || (_b$metadata4 = _b$metadata4.combined_resource) === null || _b$metadata4 === void 0 ? void 0 : _b$metadata4.status) === 1;
1931
2131
  if (aIsCombined && !bIsCombined) return 1;
1932
2132
  if (!aIsCombined && bIsCombined) return -1;
1933
2133
  return 0;