@pisell/pisellos 3.0.77 → 3.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/modules/Cart/types.d.ts +2 -0
  2. package/dist/modules/Cart/utils/cartProduct.js +21 -1
  3. package/dist/modules/Cart/utils/changePrice.js +6 -0
  4. package/dist/modules/Date/index.d.ts +1 -1
  5. package/dist/modules/Date/index.js +16 -8
  6. package/dist/modules/Date/types.d.ts +3 -1
  7. package/dist/modules/Discount/index.d.ts +1 -0
  8. package/dist/modules/Discount/index.js +2 -1
  9. package/dist/modules/ProductList/index.js +8 -9
  10. package/dist/modules/Rules/index.d.ts +3 -1
  11. package/dist/modules/Rules/index.js +110 -27
  12. package/dist/modules/Rules/types.d.ts +6 -0
  13. package/dist/modules/Rules/types.js +8 -0
  14. package/dist/modules/Schedule/index.d.ts +9 -0
  15. package/dist/modules/Schedule/index.js +76 -0
  16. package/dist/modules/Summary/index.d.ts +3 -0
  17. package/dist/modules/Summary/index.js +134 -15
  18. package/dist/modules/Summary/types.d.ts +7 -0
  19. package/dist/modules/Summary/utils.d.ts +104 -1
  20. package/dist/modules/Summary/utils.js +1131 -13
  21. package/dist/solution/BookingByStep/index.d.ts +14 -0
  22. package/dist/solution/BookingByStep/index.js +688 -210
  23. package/dist/solution/BookingByStep/utils/capacity.js +1 -1
  24. package/dist/solution/BookingByStep/utils/resources.js +4 -0
  25. package/dist/solution/ShopDiscount/index.d.ts +2 -0
  26. package/dist/solution/ShopDiscount/index.js +11 -6
  27. package/lib/modules/Cart/types.d.ts +2 -0
  28. package/lib/modules/Cart/utils/cartProduct.js +16 -1
  29. package/lib/modules/Cart/utils/changePrice.js +5 -0
  30. package/lib/modules/Date/index.d.ts +1 -1
  31. package/lib/modules/Date/index.js +7 -1
  32. package/lib/modules/Date/types.d.ts +3 -1
  33. package/lib/modules/Discount/index.d.ts +1 -0
  34. package/lib/modules/Discount/index.js +2 -1
  35. package/lib/modules/ProductList/index.js +0 -7
  36. package/lib/modules/Rules/index.d.ts +3 -1
  37. package/lib/modules/Rules/index.js +43 -5
  38. package/lib/modules/Rules/types.d.ts +6 -0
  39. package/lib/modules/Rules/types.js +11 -2
  40. package/lib/modules/Schedule/index.d.ts +9 -0
  41. package/lib/modules/Schedule/index.js +60 -0
  42. package/lib/modules/Summary/index.d.ts +3 -0
  43. package/lib/modules/Summary/index.js +61 -2
  44. package/lib/modules/Summary/types.d.ts +7 -0
  45. package/lib/modules/Summary/utils.d.ts +104 -1
  46. package/lib/modules/Summary/utils.js +673 -8
  47. package/lib/solution/BookingByStep/index.d.ts +14 -0
  48. package/lib/solution/BookingByStep/index.js +465 -89
  49. package/lib/solution/BookingByStep/utils/capacity.js +1 -1
  50. package/lib/solution/BookingByStep/utils/resources.js +4 -1
  51. package/lib/solution/ShopDiscount/index.d.ts +2 -0
  52. package/lib/solution/ShopDiscount/index.js +11 -5
  53. package/package.json +1 -1
@@ -862,7 +862,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
862
862
  resources.push(...dateResources || []);
863
863
  } else {
864
864
  const dateList = this.store.date.getDateList();
865
- dateList.forEach((n) => {
865
+ dateList == null ? void 0 : dateList.forEach((n) => {
866
866
  if (n.resource)
867
867
  resources.push(...n.resource);
868
868
  });
@@ -1393,7 +1393,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1393
1393
  }
1394
1394
  // 从购物车中获取已经分配好第一步资源的所有时间片
1395
1395
  getTimeSlotByAllResources(resources_code) {
1396
- var _a, _b, _c, _d, _e, _f, _g, _h;
1396
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
1397
1397
  let dateRange = this.store.date.getDateRange();
1398
1398
  const resources = [];
1399
1399
  const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
@@ -1403,7 +1403,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1403
1403
  let maxCutOffTime = void 0;
1404
1404
  let maxCutOffTimeValue = (0, import_dayjs.default)();
1405
1405
  cartItems.forEach((item) => {
1406
- var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i;
1406
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
1407
1407
  (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1408
1408
  if (n.code === resources_code) {
1409
1409
  resources.push(...n.renderList || []);
@@ -1416,7 +1416,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1416
1416
  resourcesTypeId = (_g2 = (_f2 = (_e2 = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e2.resources) == null ? void 0 : _f2.find(
1417
1417
  (n) => n.code === resources_code
1418
1418
  )) == null ? void 0 : _g2.id;
1419
- if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1419
+ if (((_h2 = item._productOrigin) == null ? void 0 : _h2.cut_off_time) && ((_i2 = item._productOrigin) == null ? void 0 : _i2.cut_off_time.type) === "advance") {
1420
1420
  const currentCutOffTime = (0, import_dayjs.default)().add(
1421
1421
  item._productOrigin.cut_off_time.unit,
1422
1422
  item._productOrigin.cut_off_time.unit_type
@@ -1434,6 +1434,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1434
1434
  }
1435
1435
  });
1436
1436
  }
1437
+ if (((_c = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _c.date) && resources.length) {
1438
+ const currentDate = (_d = dateRange == null ? void 0 : dateRange[0]) == null ? void 0 : _d.date;
1439
+ const theDateResources = this.store.date.getResourcesListByDate(currentDate);
1440
+ resources.forEach((item) => {
1441
+ var _a2;
1442
+ const noCurrentDateTimes = item.times.some((n) => {
1443
+ return (0, import_dayjs.default)(n.start_at).isSame((0, import_dayjs.default)(currentDate), "day");
1444
+ });
1445
+ if (!noCurrentDateTimes) {
1446
+ item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
1447
+ }
1448
+ });
1449
+ }
1450
+ if (resources.length === 0) {
1451
+ resources.push(...this.store.date.getResourcesListByDate(dateRange[0].date) || []);
1452
+ }
1437
1453
  const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
1438
1454
  let duration = 0;
1439
1455
  const accountList = this.store.accountList.getAccounts();
@@ -1461,7 +1477,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1461
1477
  } else {
1462
1478
  checkDuration(cartItems);
1463
1479
  }
1464
- if (!((_c = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _c.start_date) && !((_d = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _d.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1480
+ if (!((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.start_date) && !((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1465
1481
  return [];
1466
1482
  }
1467
1483
  if ((cartItems == null ? void 0 : cartItems[0].start_date) && !dateRange) {
@@ -1473,7 +1489,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1473
1489
  weekNum: 0
1474
1490
  },
1475
1491
  {
1476
- date: ((_e = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _e.end_date) || ((_f = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _f.start_date) || "",
1492
+ date: ((_g = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _g.end_date) || ((_h = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _h.start_date) || "",
1477
1493
  status: "available",
1478
1494
  week: "",
1479
1495
  weekNum: 0
@@ -1487,26 +1503,38 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1487
1503
  return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1488
1504
  }
1489
1505
  );
1490
- let operating_day_boundary = (_h = (_g = this.shopStore.get("core")) == null ? void 0 : _g.core) == null ? void 0 : _h.operating_day_boundary;
1506
+ let operating_day_boundary = (_j = (_i = this.shopStore.get("core")) == null ? void 0 : _i.core) == null ? void 0 : _j.operating_day_boundary;
1491
1507
  let maxBlockThreshold = 0;
1492
1508
  if (hasFlexibleDuration) {
1493
1509
  maxBlockThreshold = cartItems.reduce((max, item) => {
1494
1510
  var _a2, _b2, _c2, _d2, _e2, _f2;
1495
1511
  if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
1496
- return Math.max(max, ((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0);
1512
+ return Math.max(
1513
+ max,
1514
+ ((_f2 = (_e2 = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e2.flexible_config) == null ? void 0 : _f2.block_threshold) || 0
1515
+ );
1497
1516
  }
1498
1517
  return 0;
1499
1518
  }, 0);
1500
1519
  }
1501
1520
  const calculateCapacityFromCartItems = (items) => {
1502
- return items.reduce((total, item) => {
1503
- return total + ((0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 0);
1504
- }, 0);
1521
+ var _a2;
1522
+ const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
1523
+ const sameResourceLength = items.filter((item) => {
1524
+ var _a3;
1525
+ return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1526
+ }).length;
1527
+ if (sameResourceLength === items.length) {
1528
+ return 1;
1529
+ }
1530
+ return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
1505
1531
  };
1506
1532
  let maxCapacity = 1;
1507
1533
  if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1508
1534
  accountList.forEach((account) => {
1509
- const accountCartItems = this.store.cart.getCartByAccount(account.getId());
1535
+ const accountCartItems = this.store.cart.getCartByAccount(
1536
+ account.getId()
1537
+ );
1510
1538
  const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
1511
1539
  if (currentCapacity > maxCapacity) {
1512
1540
  maxCapacity = currentCapacity;
@@ -1530,6 +1558,172 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1530
1558
  });
1531
1559
  return timeSlots;
1532
1560
  }
1561
+ // 从购物车中获取已经分配好第一步资源的所有时间片,批量版本,用于给日期提供能否高亮的判断
1562
+ async getTimeSlotByAllResourcesForDate({ resources_code, startDate, endDate }) {
1563
+ var _a, _b, _c, _d;
1564
+ if ((0, import_dayjs.default)(endDate).diff((0, import_dayjs.default)(startDate), "day") < 30) {
1565
+ endDate = (0, import_dayjs.default)(startDate).add(30, "day").format("YYYY-MM-DD");
1566
+ }
1567
+ await this.getAvailableDate({
1568
+ startDate,
1569
+ endDate,
1570
+ useCache: true
1571
+ });
1572
+ const resources = [];
1573
+ const cartItems = this.store.cart.getItems().filter((n) => !(0, import_utils5.isNormalProduct)(n._productOrigin));
1574
+ const resourceIds = [];
1575
+ let resourcesTypeId = void 0;
1576
+ let isSingleResource = false;
1577
+ let maxCutOffTime = void 0;
1578
+ let maxCutOffTimeValue = (0, import_dayjs.default)();
1579
+ cartItems.forEach((item) => {
1580
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i;
1581
+ (_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.forEach((n) => {
1582
+ if (n.code === resources_code) {
1583
+ resources.push(...n.renderList || []);
1584
+ isSingleResource = n.type === "single";
1585
+ }
1586
+ });
1587
+ if (item.resource_id && !resourceIds.includes(item.resource_id)) {
1588
+ resourceIds.push(item.resource_id);
1589
+ }
1590
+ resourcesTypeId = (_g = (_f = (_e = (_d2 = item == null ? void 0 : item._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find(
1591
+ (n) => n.code === resources_code
1592
+ )) == null ? void 0 : _g.id;
1593
+ if (((_h = item._productOrigin) == null ? void 0 : _h.cut_off_time) && ((_i = item._productOrigin) == null ? void 0 : _i.cut_off_time.type) === "advance") {
1594
+ const currentCutOffTime = (0, import_dayjs.default)().add(
1595
+ item._productOrigin.cut_off_time.unit,
1596
+ item._productOrigin.cut_off_time.unit_type
1597
+ );
1598
+ if (currentCutOffTime.isAfter(maxCutOffTimeValue, "minute")) {
1599
+ maxCutOffTimeValue = currentCutOffTime;
1600
+ maxCutOffTime = item._productOrigin.cut_off_time;
1601
+ }
1602
+ }
1603
+ });
1604
+ if (!resources.length)
1605
+ return [];
1606
+ let duration = 0;
1607
+ const accountList = this.store.accountList.getAccounts();
1608
+ const checkDuration = (cartItems2) => {
1609
+ let accountDuration = 0;
1610
+ cartItems2.forEach((item) => {
1611
+ var _a2, _b2, _c2, _d2, _e, _f;
1612
+ if (isSingleResource) {
1613
+ accountDuration += ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.value) || 10;
1614
+ } else {
1615
+ if (accountDuration < (((_d2 = (_c2 = item._productOrigin) == null ? void 0 : _c2.duration) == null ? void 0 : _d2.value) || 10)) {
1616
+ accountDuration = ((_f = (_e = item._productOrigin) == null ? void 0 : _e.duration) == null ? void 0 : _f.value) || 10;
1617
+ }
1618
+ }
1619
+ });
1620
+ if (accountDuration > duration) {
1621
+ duration = accountDuration;
1622
+ }
1623
+ };
1624
+ if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1625
+ accountList.forEach((account) => {
1626
+ const cartItems2 = this.store.cart.getCartByAccount(account.getId());
1627
+ checkDuration(cartItems2);
1628
+ });
1629
+ } else {
1630
+ checkDuration(cartItems);
1631
+ }
1632
+ if (!((_a = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _a.start_date) && !((_b = cartItems == null ? void 0 : cartItems[0]) == null ? void 0 : _b.resource_id) || !(cartItems == null ? void 0 : cartItems[0].duration)) {
1633
+ return [];
1634
+ }
1635
+ const resourcesUseableMap = {};
1636
+ const hasFlexibleDuration = cartItems.some(
1637
+ (item) => {
1638
+ var _a2, _b2;
1639
+ return ((_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.type) === "flexible";
1640
+ }
1641
+ );
1642
+ let operating_day_boundary = (_d = (_c = this.shopStore.get("core")) == null ? void 0 : _c.core) == null ? void 0 : _d.operating_day_boundary;
1643
+ let maxBlockThreshold = 0;
1644
+ if (hasFlexibleDuration) {
1645
+ maxBlockThreshold = cartItems.reduce((max, item) => {
1646
+ var _a2, _b2, _c2, _d2, _e, _f;
1647
+ if ((_c2 = (_b2 = (_a2 = item._productOrigin) == null ? void 0 : _a2.duration) == null ? void 0 : _b2.flexible_config) == null ? void 0 : _c2.is_enable_minimum_duration) {
1648
+ return Math.max(max, ((_f = (_e = (_d2 = item._productOrigin) == null ? void 0 : _d2.duration) == null ? void 0 : _e.flexible_config) == null ? void 0 : _f.block_threshold) || 0);
1649
+ }
1650
+ return 0;
1651
+ }, 0);
1652
+ }
1653
+ const calculateCapacityFromCartItems = (items) => {
1654
+ var _a2;
1655
+ const firstResource = (_a2 = items[0]._resourceOrigin) == null ? void 0 : _a2[0].id;
1656
+ const sameResourceLength = items.filter((item) => {
1657
+ var _a3;
1658
+ return ((_a3 = item._resourceOrigin) == null ? void 0 : _a3[0].id) === firstResource;
1659
+ }).length;
1660
+ if (sameResourceLength !== items.length) {
1661
+ return 1;
1662
+ }
1663
+ return Math.max(...items.map((item) => (0, import_capacity.getCapacityInfoByCartItem)(item).currentCapacity || 1));
1664
+ };
1665
+ let maxCapacity = 1;
1666
+ if (cartItems == null ? void 0 : cartItems[0].holder_id) {
1667
+ accountList.forEach((account) => {
1668
+ const accountCartItems = this.store.cart.getCartByAccount(account.getId());
1669
+ const currentCapacity = calculateCapacityFromCartItems(accountCartItems);
1670
+ if (currentCapacity > maxCapacity) {
1671
+ maxCapacity = currentCapacity;
1672
+ }
1673
+ });
1674
+ } else {
1675
+ maxCapacity = calculateCapacityFromCartItems(cartItems);
1676
+ }
1677
+ const arr = [];
1678
+ const today = (0, import_dayjs.default)().startOf("day");
1679
+ for (let i = (0, import_dayjs.default)(startDate); i.isBefore((0, import_dayjs.default)(endDate)); i = i.add(1, "day")) {
1680
+ const currentDate = i.format("YYYY-MM-DD");
1681
+ const theDateResources = this.store.date.getResourcesListByDate(currentDate);
1682
+ resources.forEach((item) => {
1683
+ var _a2;
1684
+ item.times = ((_a2 = theDateResources == null ? void 0 : theDateResources.find((n) => n.id === item.id)) == null ? void 0 : _a2.times) || [];
1685
+ });
1686
+ const resourcesMap = (0, import_utils2.getResourcesMap)(resources);
1687
+ if (i.isBefore(today)) {
1688
+ arr.push({
1689
+ date: currentDate,
1690
+ status: "unavailable",
1691
+ week: i.format("ddd"),
1692
+ weekNum: i.day()
1693
+ });
1694
+ continue;
1695
+ }
1696
+ const timeSlots = (0, import_resources.getTimeSlicesByResources)({
1697
+ resourceIds,
1698
+ resourcesMap,
1699
+ duration,
1700
+ currentDate,
1701
+ split: 10,
1702
+ resourcesUseableMap,
1703
+ capacity: maxCapacity,
1704
+ cut_off_time: maxCutOffTime,
1705
+ hasFlexibleDuration,
1706
+ operating_day_boundary,
1707
+ maxBlockThreshold
1708
+ });
1709
+ if (timeSlots.length > 0) {
1710
+ arr.push({
1711
+ date: currentDate,
1712
+ status: "available",
1713
+ week: i.format("ddd"),
1714
+ weekNum: i.day()
1715
+ });
1716
+ } else {
1717
+ arr.push({
1718
+ date: currentDate,
1719
+ status: "unavailable",
1720
+ week: i.format("ddd"),
1721
+ weekNum: i.day()
1722
+ });
1723
+ }
1724
+ }
1725
+ return arr;
1726
+ }
1533
1727
  // 提交时间切片,绑定到对应购物车的商品上,更新购物车---只有 duration 商品
1534
1728
  submitTimeSlot(timeSlots) {
1535
1729
  var _a, _b;
@@ -1558,6 +1752,28 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1558
1752
  newResources.forEach((resource) => {
1559
1753
  var _a3, _b2, _c, _d, _e, _f, _g, _h, _i, _j, _k;
1560
1754
  if (((_b2 = (_a3 = item._productOrigin) == null ? void 0 : _a3.duration) == null ? void 0 : _b2.type) === "flexible") {
1755
+ let getEarliestBlockedStartTime = function({
1756
+ currentStartTime: currentStartTime2,
1757
+ times
1758
+ }) {
1759
+ const currentStart = (0, import_dayjs.default)(currentStartTime2);
1760
+ let earliestBlockStart;
1761
+ for (const time of times || []) {
1762
+ for (const event of time.event_list || []) {
1763
+ const eventStart = (0, import_dayjs.default)(event.start_at);
1764
+ const eventEnd = (0, import_dayjs.default)(event.end_at);
1765
+ if (eventStart.isBefore(currentStart) && eventEnd.isAfter(currentStart)) {
1766
+ return currentStart.format("YYYY-MM-DD HH:mm");
1767
+ }
1768
+ if (eventStart.isAfter(currentStart)) {
1769
+ if (!earliestBlockStart || eventStart.isBefore(earliestBlockStart)) {
1770
+ earliestBlockStart = eventStart;
1771
+ }
1772
+ }
1773
+ }
1774
+ }
1775
+ return earliestBlockStart == null ? void 0 : earliestBlockStart.format("YYYY-MM-DD HH:mm");
1776
+ };
1561
1777
  item.duration = {
1562
1778
  type: "minutes",
1563
1779
  value: 10
@@ -1572,13 +1788,22 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1572
1788
  },
1573
1789
  targetResourceTimes[0]
1574
1790
  );
1791
+ const earliestBlockedStartTime = getEarliestBlockedStartTime({
1792
+ currentStartTime,
1793
+ times: targetResourceTimes
1794
+ });
1575
1795
  const resourceDate = (0, import_dayjs.default)(resourcesEndTime.end_at).format(
1576
1796
  "YYYY-MM-DD"
1577
1797
  );
1578
1798
  const operatingBoundaryDateTime = `${resourceDate} ${operating_day_boundary.type === "start_time" ? "23:59" : operating_day_boundary.time}`;
1579
- const endTime = (0, import_dayjs.default)(resourcesEndTime.end_at).isBefore(
1580
- (0, import_dayjs.default)(operatingBoundaryDateTime)
1581
- ) ? resourcesEndTime.end_at : operatingBoundaryDateTime;
1799
+ const endTimeCandidates = [
1800
+ resourcesEndTime.end_at,
1801
+ operatingBoundaryDateTime,
1802
+ ...earliestBlockedStartTime ? [earliestBlockedStartTime] : []
1803
+ ];
1804
+ const endTime = endTimeCandidates.reduce((earliest, value) => {
1805
+ return (0, import_dayjs.default)(value).isBefore((0, import_dayjs.default)(earliest)) ? value : earliest;
1806
+ }, endTimeCandidates[0]);
1582
1807
  let formattedEndTime;
1583
1808
  if (typeof endTime === "string" && endTime.includes(":") && !endTime.includes(" ") && !endTime.includes("T")) {
1584
1809
  const currentDate = timeSlots.start_at.format("YYYY-MM-DD");
@@ -1673,7 +1898,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1673
1898
  resources,
1674
1899
  product
1675
1900
  }) {
1676
- var _a, _b, _c, _d, _e;
1901
+ var _a, _b, _c, _d;
1677
1902
  const targetProduct = this.store.currentProduct;
1678
1903
  const targetProductData = product || targetProduct;
1679
1904
  let targetSchedules = [];
@@ -1716,24 +1941,48 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1716
1941
  return -1;
1717
1942
  return 0;
1718
1943
  });
1719
- const firstEnabledResourceId = (_e = (_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.find(
1944
+ const enabledResourceTypeConfigs = ((_d = (_c = targetProductData == null ? void 0 : targetProductData.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
1720
1945
  (n) => n.status === 1
1721
- )) == null ? void 0 : _e.id;
1946
+ )) || [];
1947
+ const resourceTypeConfigById = new Map(
1948
+ enabledResourceTypeConfigs.map((n) => [n.id, n])
1949
+ );
1722
1950
  const formatScheduleTimeSlots = scheduleTimeSlots.map((item) => {
1723
1951
  const resourcesUseableMap = {};
1724
- let count = 0;
1725
- let bookingLeft = 0;
1726
- let summaryCount = 0;
1952
+ const statsByResourceType = {};
1953
+ enabledResourceTypeConfigs.forEach((cfg) => {
1954
+ statsByResourceType[cfg.id] = {
1955
+ count: 0,
1956
+ left: 0,
1957
+ summaryCount: 0,
1958
+ summaryConfigCount: 0
1959
+ };
1960
+ });
1727
1961
  allProductResources == null ? void 0 : allProductResources.forEach((m) => {
1728
- let currentResourcesCount = 0;
1729
- let currentResourcesSummaryCount = 0;
1730
- const currentResourcesTimeSlotCanUsedArr = [];
1962
+ const currentResourceTypeConfig = resourceTypeConfigById.get(m.form_id);
1963
+ if (!currentResourceTypeConfig)
1964
+ return;
1965
+ let currentResourceMaxRemainingCapacity = 0;
1966
+ let isAllTimeSlicesUsable = true;
1731
1967
  const mTimes = m.times.filter((n) => {
1732
- return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
1968
+ return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute") || m.onlyComputed && (0, import_dayjs.default)(n.start_at).isBefore((0, import_dayjs.default)(item.end), "minute") && (0, import_dayjs.default)(n.end_at).isAfter((0, import_dayjs.default)(item.start), "minute");
1733
1969
  });
1734
1970
  if (mTimes.length === 0) {
1735
1971
  return;
1736
1972
  }
1973
+ if (!m.onlyComputed) {
1974
+ const currentStats2 = statsByResourceType[m.form_id] || {
1975
+ count: 0,
1976
+ left: 0,
1977
+ summaryCount: 0,
1978
+ summaryConfigCount: 0
1979
+ };
1980
+ if (currentResourceTypeConfig.type === "multiple")
1981
+ currentStats2.summaryConfigCount += m.capacity;
1982
+ else
1983
+ currentStats2.summaryConfigCount += 1;
1984
+ statsByResourceType[m.form_id] = currentStats2;
1985
+ }
1737
1986
  mTimes.forEach((childTiem) => {
1738
1987
  const res = (0, import_resources.getIsUsableByTimeItem)({
1739
1988
  timeSlice: {
@@ -1751,47 +2000,67 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1751
2000
  if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res.reason !== "capacityOnly") {
1752
2001
  resourcesUseableMap[m.id] = res.usable;
1753
2002
  }
1754
- if (res.usable && res.remainingCapacity >= count && !m.onlyComputed) {
1755
- currentResourcesCount = res.remainingCapacity;
2003
+ if (!res.usable)
2004
+ isAllTimeSlicesUsable = false;
2005
+ if (res.usable && !m.onlyComputed) {
2006
+ if (res.remainingCapacity > currentResourceMaxRemainingCapacity)
2007
+ currentResourceMaxRemainingCapacity = res.remainingCapacity;
1756
2008
  }
1757
- if (res.usable && !m.onlyComputed && res.remainingCapacity >= currentResourcesSummaryCount) {
1758
- currentResourcesSummaryCount = res.remainingCapacity;
1759
- }
1760
- currentResourcesTimeSlotCanUsedArr.push(res.usable);
1761
2009
  });
1762
- if (!currentResourcesTimeSlotCanUsedArr.some(
1763
- (n) => n === false
1764
- ) && // 只统计第一种资源的容量和 left
1765
- m.form_id === firstEnabledResourceId) {
1766
- if (currentResourcesCount >= count) {
1767
- count = currentResourcesCount;
1768
- }
1769
- if (!m.onlyComputed) {
1770
- bookingLeft += 1;
1771
- summaryCount += currentResourcesSummaryCount;
1772
- }
2010
+ if (!isAllTimeSlicesUsable)
2011
+ return;
2012
+ if (m.onlyComputed)
2013
+ return;
2014
+ const currentStats = statsByResourceType[m.form_id] || {
2015
+ count: 0,
2016
+ left: 0,
2017
+ summaryCount: 0,
2018
+ summaryConfigCount: 0
2019
+ };
2020
+ currentStats.left += 1;
2021
+ if (currentResourceTypeConfig.type === "multiple") {
2022
+ currentStats.summaryCount += currentResourceMaxRemainingCapacity;
2023
+ if (currentResourceMaxRemainingCapacity > currentStats.count)
2024
+ currentStats.count = currentResourceMaxRemainingCapacity;
2025
+ } else {
2026
+ currentStats.summaryCount += 1;
2027
+ if (currentStats.count < 1)
2028
+ currentStats.count = 1;
1773
2029
  }
2030
+ statsByResourceType[m.form_id] = currentStats;
1774
2031
  });
1775
2032
  const cartItems2 = this.store.cart.getItems();
1776
2033
  productResources.forEach((n) => {
2034
+ const currentResourceTypeConfig = resourceTypeConfigById.get(n.id);
2035
+ if (!currentResourceTypeConfig)
2036
+ return;
2037
+ const currentStats = statsByResourceType[n.id] || {
2038
+ count: 0,
2039
+ left: 0,
2040
+ summaryCount: 0
2041
+ };
1777
2042
  if (n.type === "single") {
1778
2043
  const currentResourcesSet = /* @__PURE__ */ new Set([...n.optional_resource, ...n.default_resource]);
1779
2044
  const sameCartItems = cartItems2.filter((m) => {
1780
2045
  var _a2, _b2, _c2;
1781
2046
  return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) === ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
1782
2047
  });
1783
- if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > bookingLeft) {
1784
- bookingLeft = 0;
1785
- count = 0;
1786
- summaryCount = 0;
2048
+ if (sameCartItems.length > 0 && sameCartItems.length >= currentResourcesSet.size || sameCartItems.length > currentStats.left) {
2049
+ currentStats.left = 0;
2050
+ currentStats.count = 0;
2051
+ currentStats.summaryCount = 0;
1787
2052
  }
1788
- const otherCartItems = cartItems2.filter((m) => {
1789
- var _a2, _b2, _c2;
1790
- return ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
1791
- });
2053
+ let otherCartItems = cartItems2.filter(
2054
+ (m) => {
2055
+ var _a2, _b2, _c2, _d2, _e, _f;
2056
+ const isTimeMatch = ((_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.id) == null ? void 0 : _b2.toString()) !== ((_c2 = targetProductData == null ? void 0 : targetProductData.id) == null ? void 0 : _c2.toString()) && `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end;
2057
+ const isResourceMatch = (_f = (_e = (_d2 = m._productOrigin) == null ? void 0 : _d2.product_resource) == null ? void 0 : _e.resources) == null ? void 0 : _f.find((m2) => m2.type === n.type && m2.status === 1);
2058
+ return isTimeMatch && isResourceMatch;
2059
+ }
2060
+ );
1792
2061
  otherCartItems.forEach((m) => {
1793
2062
  var _a2, _b2, _c2;
1794
- const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type);
2063
+ const sameTypeResources = (_c2 = (_b2 = (_a2 = m._productOrigin) == null ? void 0 : _a2.product_resource) == null ? void 0 : _b2.resources) == null ? void 0 : _c2.find((m2) => m2.type === n.type && m2.status === 1);
1795
2064
  const sameTypeResourcesSet = /* @__PURE__ */ new Set([...(sameTypeResources == null ? void 0 : sameTypeResources.optional_resource) || [], ...(sameTypeResources == null ? void 0 : sameTypeResources.default_resource) || []]);
1796
2065
  sameTypeResourcesSet.forEach((resource) => currentResourcesSet.add(resource));
1797
2066
  });
@@ -1807,9 +2076,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1807
2076
  }
1808
2077
  });
1809
2078
  if (currentResourcesSet.size > 0 && otherCartItems.length + sameCartItems.length >= currentResourcesSet.size) {
1810
- bookingLeft = 0;
1811
- count = 0;
1812
- summaryCount = 0;
2079
+ currentStats.left = 0;
2080
+ currentStats.count = 0;
2081
+ currentStats.summaryCount = 0;
1813
2082
  }
1814
2083
  } else {
1815
2084
  const sameCartItems = cartItems2.filter((m) => {
@@ -1819,9 +2088,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1819
2088
  const sameCartNeedCapacity = sameCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
1820
2089
  const currentProductResourcesCapacity = n.renderList.reduce((acc, curr) => !curr.onlyComputed ? acc + curr.capacity || 0 : acc, 0);
1821
2090
  if (sameCartNeedCapacity >= currentProductResourcesCapacity) {
1822
- bookingLeft = 0;
1823
- count = 0;
1824
- summaryCount = 0;
2091
+ currentStats.left = 0;
2092
+ currentStats.count = 0;
2093
+ currentStats.summaryCount = 0;
1825
2094
  }
1826
2095
  const otherSameTimesCartItems = cartItems2.filter((m) => `${m.start_date} ${m.start_time}` === item.start && `${m.start_date} ${m.end_time}` === item.end);
1827
2096
  const otherCartNeedCapacity = otherSameTimesCartItems.reduce((acc, curr) => acc + (0, import_capacity.getCapacityInfoByCartItem)(curr).currentCapacity, 0);
@@ -1864,22 +2133,68 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1864
2133
  return acc;
1865
2134
  }, 0);
1866
2135
  if (otherCartNeedCapacity + usedCapacity >= currentTypeResourcesCapacity) {
1867
- bookingLeft = 0;
1868
- count = 0;
1869
- summaryCount = 0;
2136
+ currentStats.left = 0;
2137
+ currentStats.count = 0;
2138
+ currentStats.summaryCount = 0;
1870
2139
  }
1871
2140
  }
2141
+ statsByResourceType[n.id] = currentStats;
1872
2142
  });
1873
2143
  const startDayJs = (0, import_dayjs.default)(item.start);
1874
2144
  const endDayJs = (0, import_dayjs.default)(item.end);
2145
+ let bottleneckResourceTypeId;
2146
+ let bottleneckValue = Infinity;
2147
+ enabledResourceTypeConfigs.forEach((cfg) => {
2148
+ const stats = statsByResourceType[cfg.id] || {
2149
+ count: 0,
2150
+ left: 0,
2151
+ summaryCount: 0,
2152
+ summaryConfigCount: 0
2153
+ };
2154
+ const value = cfg.type === "multiple" ? stats.summaryCount : stats.left;
2155
+ if (value < bottleneckValue) {
2156
+ bottleneckValue = value;
2157
+ bottleneckResourceTypeId = cfg.id;
2158
+ }
2159
+ });
2160
+ const bottleneckStats = bottleneckResourceTypeId !== void 0 ? statsByResourceType[bottleneckResourceTypeId] || {
2161
+ count: 0,
2162
+ left: 0,
2163
+ summaryCount: 0,
2164
+ summaryConfigCount: 0
2165
+ } : { count: 0, left: 0, summaryCount: 0, summaryConfigCount: 0 };
2166
+ const bottleneckConfig = bottleneckResourceTypeId !== void 0 ? resourceTypeConfigById.get(bottleneckResourceTypeId) : void 0;
2167
+ let status = "sold_out";
2168
+ if (bottleneckStats.left === 0)
2169
+ status = "sold_out";
2170
+ else if (!bottleneckConfig || bottleneckStats.summaryConfigCount === 0)
2171
+ status = "sold_out";
2172
+ else if (bottleneckConfig.type === "multiple") {
2173
+ const usageRatio = bottleneckStats.summaryCount / bottleneckStats.summaryConfigCount;
2174
+ if (usageRatio > 0.5)
2175
+ status = "lots_of_space";
2176
+ else if (bottleneckStats.summaryCount > 0)
2177
+ status = "filling_up_fast";
2178
+ else
2179
+ status = "sold_out";
2180
+ } else {
2181
+ const usageRatio = bottleneckStats.left / bottleneckStats.summaryConfigCount;
2182
+ if (usageRatio > 0.5)
2183
+ status = "lots_of_space";
2184
+ else if (bottleneckStats.count > 0)
2185
+ status = "filling_up_fast";
2186
+ else
2187
+ status = "sold_out";
2188
+ }
1875
2189
  return {
1876
2190
  start_time: startDayJs.format("HH:mm"),
1877
2191
  end_time: endDayJs.format("HH:mm"),
1878
2192
  start_at: startDayJs,
1879
2193
  end_at: endDayJs,
1880
- count,
1881
- left: bookingLeft,
1882
- summaryCount
2194
+ count: bottleneckStats.count,
2195
+ left: bottleneckStats.left,
2196
+ summaryCount: bottleneckStats.summaryCount,
2197
+ status
1883
2198
  };
1884
2199
  });
1885
2200
  return formatScheduleTimeSlots;
@@ -1965,6 +2280,9 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
1965
2280
  if (!itemsByResourceType[resourceCode]) {
1966
2281
  itemsByResourceType[resourceCode] = [];
1967
2282
  }
2283
+ if (itemsByResourceType[resourceCode].find((item) => item.holder_id === cartItem.holder_id)) {
2284
+ return;
2285
+ }
1968
2286
  if (!itemsByResourceType[resourceCode].find((item) => item._id === cartItem._id)) {
1969
2287
  itemsByResourceType[resourceCode].push(cartItem);
1970
2288
  }
@@ -2634,7 +2952,7 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2634
2952
  const openResources = ((_d = (_c = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _c.resources) == null ? void 0 : _d.filter(
2635
2953
  (m) => m.status === 1
2636
2954
  )) || [];
2637
- const allProductResources = (0, import_resources.sortCombinedResources)(res.data);
2955
+ const allProductResources = (0, import_lodash_es.cloneDeep)((0, import_resources.sortCombinedResources)(res.data) || []);
2638
2956
  allProductResources.forEach((m) => {
2639
2957
  var _a2, _b2;
2640
2958
  const resource = (_b2 = (_a2 = tempProducts == null ? void 0 : tempProducts.product_resource) == null ? void 0 : _a2.resources) == null ? void 0 : _b2.find(
@@ -2650,6 +2968,8 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2650
2968
  while ((0, import_dayjs.default)(currentDate).isBefore((0, import_dayjs.default)(endDate), "day") || (0, import_dayjs.default)(currentDate).isSame((0, import_dayjs.default)(endDate), "day")) {
2651
2969
  const currentDateStr = currentDate.format("YYYY-MM-DD");
2652
2970
  let status = "available";
2971
+ let summaryCount = 0;
2972
+ let availableCount = 0;
2653
2973
  const { latestStartDate, earliestEndDate } = (0, import_resources.checkSessionProductLeadTime)(tempProducts);
2654
2974
  if (latestStartDate || earliestEndDate) {
2655
2975
  if (latestStartDate && (0, import_dayjs.default)(currentDate).isBefore(latestStartDate, "day")) {
@@ -2674,43 +2994,84 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2674
2994
  currentDateStr
2675
2995
  );
2676
2996
  const scheduleTimeSlots = (0, import_utils3.getAllSortedDateRanges)(minTimeMaxTime);
2677
- const timesSlotCanUse = scheduleTimeSlots.some((item) => {
2997
+ let timesSlotCanUse = false;
2998
+ scheduleTimeSlots.forEach((item) => {
2678
2999
  const resourcesUseableMap = {};
2679
- return openResources.every((resource) => {
3000
+ let isAllResourceTypesUseable = true;
3001
+ openResources.forEach((resource) => {
3002
+ var _a2;
2680
3003
  const currentResourcesList = allProductResources.filter(
2681
3004
  (n) => n.form_id === resource.resource_type_id
2682
3005
  );
2683
- return currentResourcesList == null ? void 0 : currentResourcesList.some((m) => {
3006
+ (_a2 = resource.renderList) == null ? void 0 : _a2.forEach((item2) => {
3007
+ if (item2.onlyComputed) {
3008
+ const targetIndex = currentResourcesList.findIndex((n) => n.id === item2.id);
3009
+ if (targetIndex && targetIndex !== -1) {
3010
+ currentResourcesList[targetIndex].onlyComputed = true;
3011
+ }
3012
+ }
3013
+ });
3014
+ currentResourcesList.forEach((item2) => {
3015
+ var _a3, _b2;
3016
+ if (!((_a3 = resource.optional_resource) == null ? void 0 : _a3.includes(item2.id)) && !((_b2 = resource.default_resource) == null ? void 0 : _b2.includes(item2.id))) {
3017
+ item2.onlyComputed = true;
3018
+ }
3019
+ });
3020
+ currentResourcesList.sort((a, b) => {
3021
+ return a.onlyComputed ? -1 : 1;
3022
+ });
3023
+ let isAnyResourceUseableInType = false;
3024
+ currentResourcesList == null ? void 0 : currentResourcesList.forEach((m) => {
2684
3025
  const mTimes = m.times.filter((n) => {
2685
3026
  return !(0, import_dayjs.default)(n.start_at).isAfter((0, import_dayjs.default)(item.start), "minute") && !(0, import_dayjs.default)(n.end_at).isBefore((0, import_dayjs.default)(item.end), "minute");
2686
3027
  });
2687
- if (mTimes.length === 0) {
3028
+ if (mTimes.length === 0)
2688
3029
  return;
3030
+ if (!m.onlyComputed) {
3031
+ if (resource.type === "multiple") {
3032
+ summaryCount += m.capacity;
3033
+ } else {
3034
+ summaryCount += 1;
3035
+ }
2689
3036
  }
2690
- const targetCanUseTimes = mTimes.some(
2691
- (childTiem) => {
2692
- const res2 = (0, import_resources.getIsUsableByTimeItem)({
2693
- timeSlice: {
2694
- start_time: item.start,
2695
- end_time: item.end,
2696
- start_at: (0, import_dayjs.default)(item.start),
2697
- end_at: (0, import_dayjs.default)(item.end)
2698
- },
2699
- time: childTiem,
2700
- resource: m,
2701
- currentCount: 1,
2702
- resourcesUseableMap,
2703
- cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
2704
- });
2705
- if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
2706
- resourcesUseableMap[m.id] = res2.usable;
3037
+ let isAnyTimeSliceUseable = false;
3038
+ mTimes.forEach((childTiem) => {
3039
+ if (isAnyTimeSliceUseable)
3040
+ return;
3041
+ const res2 = (0, import_resources.getIsUsableByTimeItem)({
3042
+ timeSlice: {
3043
+ start_time: item.start,
3044
+ end_time: item.end,
3045
+ start_at: (0, import_dayjs.default)(item.start),
3046
+ end_at: (0, import_dayjs.default)(item.end)
3047
+ },
3048
+ time: childTiem,
3049
+ resource: m,
3050
+ currentCount: 1,
3051
+ resourcesUseableMap,
3052
+ cut_off_time: tempProducts == null ? void 0 : tempProducts.cut_off_time
3053
+ });
3054
+ if ((resourcesUseableMap == null ? void 0 : resourcesUseableMap[m.id]) !== false && res2.reason !== "capacityOnly") {
3055
+ resourcesUseableMap[m.id] = res2.usable;
3056
+ }
3057
+ if (res2.usable && !m.onlyComputed) {
3058
+ isAnyTimeSliceUseable = true;
3059
+ if (resource.type === "multiple") {
3060
+ availableCount += res2.remainingCapacity;
3061
+ } else {
3062
+ availableCount += 1;
2707
3063
  }
2708
- return res2.usable && !m.onlyComputed;
2709
3064
  }
2710
- );
2711
- return targetCanUseTimes;
3065
+ ;
3066
+ });
3067
+ if (isAnyTimeSliceUseable)
3068
+ isAnyResourceUseableInType = true;
2712
3069
  });
3070
+ if (!isAnyResourceUseableInType)
3071
+ isAllResourceTypesUseable = false;
2713
3072
  });
3073
+ if (isAllResourceTypesUseable)
3074
+ timesSlotCanUse = true;
2714
3075
  });
2715
3076
  if (!timesSlotCanUse) {
2716
3077
  status = "unavailable";
@@ -2719,11 +3080,26 @@ var BookingByStepImpl = class extends import_BaseModule.BaseModule {
2719
3080
  firstAvailableDate = currentDateStr;
2720
3081
  }
2721
3082
  }
3083
+ let dateStatus;
3084
+ if (status === "unavailable") {
3085
+ if (availableCount === 0 && summaryCount > 0)
3086
+ dateStatus = "sold_out";
3087
+ else
3088
+ dateStatus = "unavailable";
3089
+ } else {
3090
+ const usageRatio = availableCount / summaryCount;
3091
+ if (usageRatio > 0.5)
3092
+ dateStatus = "lots_of_space";
3093
+ else
3094
+ dateStatus = "filling_up_fast";
3095
+ }
2722
3096
  dates.push({
2723
3097
  date: (0, import_dayjs.default)(currentDate).format("YYYY-MM-DD"),
2724
3098
  week: (0, import_dayjs.default)(currentDate).format("ddd"),
2725
3099
  weekNum: (0, import_dayjs.default)(currentDate).day(),
2726
- status
3100
+ summaryCount,
3101
+ availableCount,
3102
+ status: dateStatus
2727
3103
  });
2728
3104
  if (firstAvailableDate && (0, import_dayjs.default)(currentDate).diff((0, import_dayjs.default)(startDate), "day") > 31) {
2729
3105
  break;