@pisell/pisellos 2.3.73 → 2.3.75

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 (296) hide show
  1. package/dist/core/index.d.ts +7 -0
  2. package/dist/core/index.js +111 -71
  3. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  4. package/dist/model/strategy/adapter/walletPass/example.js +3 -26
  5. package/dist/model/strategy/strategy-example.js +5 -19
  6. package/dist/modules/Cart/index.js +0 -3
  7. package/dist/modules/Cart/utils/cartProduct.js +0 -1
  8. package/dist/modules/Date/index.js +1 -5
  9. package/dist/modules/Discount/index.js +2 -4
  10. package/dist/modules/OpenData/index.js +0 -2
  11. package/dist/modules/Order/index.d.ts +1 -1
  12. package/dist/modules/Order/index.js +36 -64
  13. package/dist/modules/Payment/index.js +97 -162
  14. package/dist/modules/Quotation/index.d.ts +6 -0
  15. package/dist/modules/Quotation/index.js +75 -19
  16. package/dist/modules/Rules/index.js +1 -4
  17. package/dist/modules/Schedule/index.js +0 -1
  18. package/dist/modules/Schedule/utils.js +0 -1
  19. package/dist/modules/Step/index.js +0 -1
  20. package/dist/plugins/request.d.ts +1 -0
  21. package/dist/plugins/request.js +1 -4
  22. package/dist/plugins/window.js +2 -6
  23. package/dist/server/index.d.ts +8 -2
  24. package/dist/server/index.js +303 -269
  25. package/dist/server/modules/floor-plan/index.d.ts +4 -0
  26. package/dist/server/modules/floor-plan/index.js +240 -98
  27. package/dist/server/modules/menu/index.js +75 -59
  28. package/dist/server/modules/order/index.d.ts +17 -7
  29. package/dist/server/modules/order/index.js +421 -211
  30. package/dist/server/modules/products/index.d.ts +8 -2
  31. package/dist/server/modules/products/index.js +191 -117
  32. package/dist/server/modules/quotation/index.js +29 -38
  33. package/dist/server/modules/resource/index.js +24 -17
  34. package/dist/server/modules/schedule/index.js +27 -35
  35. package/dist/server/utils/product.js +0 -1
  36. package/dist/solution/BaseSales/index.js +38 -41
  37. package/dist/solution/BookingByStep/index.d.ts +1 -1
  38. package/dist/solution/BookingByStep/index.js +7 -59
  39. package/dist/solution/BookingByStep/utils/capacity.js +1 -11
  40. package/dist/solution/BookingByStep/utils/resources.js +1 -3
  41. package/dist/solution/BookingByStep/utils/timeslots.js +2 -43
  42. package/dist/solution/BookingTicket/index.js +0 -2
  43. package/dist/solution/BookingTicket/utils/scan/cloudSearch.js +6 -7
  44. package/dist/solution/BookingTicket/utils/scan/handleScan.js +25 -31
  45. package/dist/solution/BookingTicket/utils/scan/index.js +6 -10
  46. package/dist/solution/BuyTickets/index.js +9 -12
  47. package/dist/solution/Checkout/index.js +177 -252
  48. package/dist/solution/Checkout/utils/index.js +4 -16
  49. package/dist/solution/RegisterAndLogin/index.js +30 -76
  50. package/dist/solution/ScanOrder/index.js +50 -60
  51. package/dist/solution/ShopDiscount/index.js +2 -7
  52. package/dist/solution/VenueBooking/index.js +45 -55
  53. package/dist/utils/task.js +15 -18
  54. package/dist/utils/watch.js +0 -1
  55. package/lib/apis/picoding.js +2 -0
  56. package/lib/core/index.d.ts +7 -0
  57. package/lib/core/index.js +149 -131
  58. package/lib/effects/index.js +46 -57
  59. package/lib/index.js +82 -49
  60. package/lib/model/index.js +14 -21
  61. package/lib/model/strategy/adapter/dataVariant/adapter.js +38 -50
  62. package/lib/model/strategy/adapter/dataVariant/evaluator.js +162 -236
  63. package/lib/model/strategy/adapter/dataVariant/examples.js +229 -237
  64. package/lib/model/strategy/adapter/dataVariant/index.js +39 -34
  65. package/lib/model/strategy/adapter/dataVariant/type.js +57 -28
  66. package/lib/model/strategy/adapter/index.js +100 -64
  67. package/lib/model/strategy/adapter/itemRule/adapter.js +156 -144
  68. package/lib/model/strategy/adapter/itemRule/evaluator.js +36 -48
  69. package/lib/model/strategy/adapter/itemRule/examples.js +295 -225
  70. package/lib/model/strategy/adapter/itemRule/index.js +83 -57
  71. package/lib/model/strategy/adapter/itemRule/type.js +97 -36
  72. package/lib/model/strategy/adapter/promotion/adapter.js +91 -69
  73. package/lib/model/strategy/adapter/promotion/evaluator.js +444 -310
  74. package/lib/model/strategy/adapter/promotion/examples.js +222 -234
  75. package/lib/model/strategy/adapter/promotion/index.js +1 -0
  76. package/lib/model/strategy/adapter/promotion/type.js +243 -36
  77. package/lib/model/strategy/adapter/type.js +4 -16
  78. package/lib/model/strategy/adapter/walletPass/evaluator.js +180 -150
  79. package/lib/model/strategy/adapter/walletPass/example.js +217 -190
  80. package/lib/model/strategy/adapter/walletPass/index.js +75 -51
  81. package/lib/model/strategy/adapter/walletPass/locales.js +36 -58
  82. package/lib/model/strategy/adapter/walletPass/type.js +4 -16
  83. package/lib/model/strategy/adapter/walletPass/utils.js +588 -378
  84. package/lib/model/strategy/engine.js +270 -168
  85. package/lib/model/strategy/index.js +49 -34
  86. package/lib/model/strategy/strategy-example.js +243 -239
  87. package/lib/model/strategy/type.js +100 -40
  88. package/lib/modules/Account/index.js +39 -53
  89. package/lib/modules/Account/types.js +20 -33
  90. package/lib/modules/AccountList/index.js +116 -154
  91. package/lib/modules/AccountList/types.js +30 -31
  92. package/lib/modules/AccountList/utils.js +18 -30
  93. package/lib/modules/BaseModule.js +23 -42
  94. package/lib/modules/BookingContext/index.js +158 -136
  95. package/lib/modules/BookingContext/types.js +46 -32
  96. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +138 -146
  97. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +78 -83
  98. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +170 -150
  99. package/lib/modules/BookingContext/utils/flexible.js +38 -55
  100. package/lib/modules/BookingContext/utils/formatResourceList.js +19 -34
  101. package/lib/modules/BookingContext/utils/index.js +124 -41
  102. package/lib/modules/BookingContext/utils/noResource.js +58 -70
  103. package/lib/modules/BookingContext/utils/orderLineDisplay.js +14 -41
  104. package/lib/modules/BookingContext/utils/productExtend.js +202 -155
  105. package/lib/modules/BookingContext/utils/resourceErrors.js +53 -53
  106. package/lib/modules/BookingContext/utils/resourceSelection.js +19 -41
  107. package/lib/modules/BookingContext/utils/resources.js +209 -167
  108. package/lib/modules/BookingContext/utils/serviceTimes.js +115 -116
  109. package/lib/modules/BookingContext/utils/timeSlices.js +76 -86
  110. package/lib/modules/Cart/index.js +170 -124
  111. package/lib/modules/Cart/types.js +46 -51
  112. package/lib/modules/Cart/utils/cartAccount.js +40 -39
  113. package/lib/modules/Cart/utils/cartDate.js +56 -61
  114. package/lib/modules/Cart/utils/cartDiscount.js +28 -33
  115. package/lib/modules/Cart/utils/cartNote.js +27 -32
  116. package/lib/modules/Cart/utils/cartProduct.js +321 -251
  117. package/lib/modules/Cart/utils/cartRelationForms.js +29 -35
  118. package/lib/modules/Cart/utils/cartResource.js +70 -78
  119. package/lib/modules/Cart/utils/changePrice.js +22 -50
  120. package/lib/modules/Cart/utils/index.js +106 -48
  121. package/lib/modules/Customer/constants.js +13 -34
  122. package/lib/modules/Customer/index.js +235 -172
  123. package/lib/modules/Customer/types.js +38 -35
  124. package/lib/modules/Date/index.js +116 -115
  125. package/lib/modules/Date/types.js +16 -28
  126. package/lib/modules/Date/utils.js +174 -123
  127. package/lib/modules/Discount/index.js +122 -127
  128. package/lib/modules/Discount/types.js +9 -31
  129. package/lib/modules/Guests/index.js +30 -56
  130. package/lib/modules/Guests/types.js +23 -33
  131. package/lib/modules/Holder/index.js +209 -189
  132. package/lib/modules/Holder/types.js +4 -16
  133. package/lib/modules/Holder/utils.js +20 -49
  134. package/lib/modules/OpenData/index.js +70 -76
  135. package/lib/modules/OpenData/types.js +4 -16
  136. package/lib/modules/OpenData/utils.js +44 -78
  137. package/lib/modules/Order/index.d.ts +1 -1
  138. package/lib/modules/Order/index.js +1713 -2118
  139. package/lib/modules/Order/payment-utils.js +77 -120
  140. package/lib/modules/Order/types.js +88 -35
  141. package/lib/modules/Order/utils/bundleDiscountHydration.js +41 -74
  142. package/lib/modules/Order/utils/discountProductLineIdentity.js +142 -100
  143. package/lib/modules/Order/utils/manualProductDiscount.js +124 -123
  144. package/lib/modules/Order/utils/orderCollectionIdentity.js +184 -244
  145. package/lib/modules/Order/utils.js +814 -647
  146. package/lib/modules/Payment/cash.js +20 -33
  147. package/lib/modules/Payment/cashRecommendationAlgorithm.js +145 -76
  148. package/lib/modules/Payment/eftpos.js +16 -30
  149. package/lib/modules/Payment/index.js +532 -399
  150. package/lib/modules/Payment/mx51.js +1 -0
  151. package/lib/modules/Payment/types.js +230 -108
  152. package/lib/modules/Payment/utils.js +52 -51
  153. package/lib/modules/Payment/walletpass.js +485 -660
  154. package/lib/modules/Product/index.js +51 -46
  155. package/lib/modules/Product/types.js +4 -16
  156. package/lib/modules/Product/utils.js +32 -33
  157. package/lib/modules/ProductList/index.js +113 -123
  158. package/lib/modules/ProductList/types.js +9 -31
  159. package/lib/modules/Quotation/index.d.ts +6 -0
  160. package/lib/modules/Quotation/index.js +110 -103
  161. package/lib/modules/Quotation/types.js +4 -16
  162. package/lib/modules/Resource/index.js +27 -59
  163. package/lib/modules/Resource/types.js +22 -32
  164. package/lib/modules/Resource/utils.js +30 -38
  165. package/lib/modules/ResourcePlanner/index.js +25 -23
  166. package/lib/modules/ResourcePlanner/localClock.js +54 -119
  167. package/lib/modules/ResourcePlanner/planner.js +589 -770
  168. package/lib/modules/ResourcePlanner/types.js +10 -29
  169. package/lib/modules/Rules/index.js +1218 -959
  170. package/lib/modules/Rules/types.js +17 -40
  171. package/lib/modules/SalesSummary/index.js +85 -90
  172. package/lib/modules/SalesSummary/types.js +4 -16
  173. package/lib/modules/SalesSummary/utils.js +355 -430
  174. package/lib/modules/ScanOrderLogger/index.js +59 -79
  175. package/lib/modules/ScanOrderLogger/providers/feishu.js +54 -78
  176. package/lib/modules/ScanOrderLogger/providers/grafana.js +13 -36
  177. package/lib/modules/ScanOrderLogger/types.js +4 -16
  178. package/lib/modules/Schedule/getDateIsInSchedule.js +334 -163
  179. package/lib/modules/Schedule/index.js +100 -114
  180. package/lib/modules/Schedule/type.js +4 -16
  181. package/lib/modules/Schedule/types.js +4 -16
  182. package/lib/modules/Schedule/utils.js +433 -291
  183. package/lib/modules/Step/index.js +40 -52
  184. package/lib/modules/Step/tyeps.js +4 -16
  185. package/lib/modules/Summary/index.js +66 -71
  186. package/lib/modules/Summary/types.js +4 -16
  187. package/lib/modules/Summary/utils.js +773 -418
  188. package/lib/modules/SurchargeList/index.js +46 -60
  189. package/lib/modules/SurchargeList/types.js +4 -16
  190. package/lib/modules/index.js +245 -63
  191. package/lib/plugins/app.js +4 -16
  192. package/lib/plugins/index.js +36 -25
  193. package/lib/plugins/request.d.ts +1 -0
  194. package/lib/plugins/request.js +137 -126
  195. package/lib/plugins/shopStore.js +4 -16
  196. package/lib/plugins/user.js +4 -16
  197. package/lib/plugins/window.js +171 -179
  198. package/lib/server/index.d.ts +8 -2
  199. package/lib/server/index.js +3083 -2663
  200. package/lib/server/modules/floor-plan/index.d.ts +4 -0
  201. package/lib/server/modules/floor-plan/index.js +159 -127
  202. package/lib/server/modules/floor-plan/types.js +15 -30
  203. package/lib/server/modules/index.js +106 -68
  204. package/lib/server/modules/menu/index.js +170 -124
  205. package/lib/server/modules/menu/types.js +18 -31
  206. package/lib/server/modules/order/index.d.ts +17 -7
  207. package/lib/server/modules/order/index.js +916 -977
  208. package/lib/server/modules/order/types.js +122 -33
  209. package/lib/server/modules/order/utils/filterBookings.js +219 -194
  210. package/lib/server/modules/order/utils/filterOrders.js +118 -92
  211. package/lib/server/modules/payment/index.js +59 -83
  212. package/lib/server/modules/payment/types.js +4 -16
  213. package/lib/server/modules/products/index.d.ts +8 -2
  214. package/lib/server/modules/products/index.js +656 -471
  215. package/lib/server/modules/products/types.js +44 -34
  216. package/lib/server/modules/quotation/index.js +137 -172
  217. package/lib/server/modules/quotation/types.js +21 -31
  218. package/lib/server/modules/resource/index.js +225 -186
  219. package/lib/server/modules/resource/types.js +42 -33
  220. package/lib/server/modules/schedule/index.js +135 -123
  221. package/lib/server/modules/schedule/types.js +14 -21
  222. package/lib/server/modules/schedule/utils.js +334 -163
  223. package/lib/server/types.js +4 -16
  224. package/lib/server/utils/index.js +25 -23
  225. package/lib/server/utils/product.js +196 -139
  226. package/lib/server/utils/schedule.js +34 -41
  227. package/lib/server/utils/small-ticket.js +479 -456
  228. package/lib/server/utils/time.js +40 -49
  229. package/lib/solution/BaseSales/index.js +1186 -1410
  230. package/lib/solution/BaseSales/types.js +42 -38
  231. package/lib/solution/BaseSales/utils/cartPromotion.js +642 -498
  232. package/lib/solution/BaseSales/utils/parseSalesResponse.js +85 -105
  233. package/lib/solution/BaseSales/utils/quotationPrice.js +56 -114
  234. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +108 -145
  235. package/lib/solution/BaseSales/utils.js +158 -143
  236. package/lib/solution/BookingByStep/index.d.ts +1 -1
  237. package/lib/solution/BookingByStep/index.js +1527 -1340
  238. package/lib/solution/BookingByStep/types.js +40 -99
  239. package/lib/solution/BookingByStep/utils/capacity.js +192 -160
  240. package/lib/solution/BookingByStep/utils/products.js +42 -52
  241. package/lib/solution/BookingByStep/utils/resources.js +527 -330
  242. package/lib/solution/BookingByStep/utils/stock.js +65 -44
  243. package/lib/solution/BookingByStep/utils/timeslots.js +129 -131
  244. package/lib/solution/BookingTicket/index.js +607 -522
  245. package/lib/solution/BookingTicket/types.js +99 -77
  246. package/lib/solution/BookingTicket/utils/addProductDecision.js +226 -189
  247. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +58 -89
  248. package/lib/solution/BookingTicket/utils/bookingStatus.js +107 -78
  249. package/lib/solution/BookingTicket/utils/cartView.js +114 -99
  250. package/lib/solution/BookingTicket/utils/exampleData.js +185 -0
  251. package/lib/solution/BookingTicket/utils/orderCustomer.js +18 -41
  252. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +219 -86
  253. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +168 -116
  254. package/lib/solution/BookingTicket/utils/scan/cloudSearch.js +79 -91
  255. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +54 -41
  256. package/lib/solution/BookingTicket/utils/scan/handleScan.js +84 -81
  257. package/lib/solution/BookingTicket/utils/scan/index.js +98 -104
  258. package/lib/solution/BookingTicket/utils/scan/scanCache.js +90 -43
  259. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +52 -64
  260. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +56 -58
  261. package/lib/solution/BookingTicket/utils/weighingProductSku.js +34 -48
  262. package/lib/solution/BuyTickets/index.js +67 -70
  263. package/lib/solution/BuyTickets/types.js +22 -38
  264. package/lib/solution/Checkout/index.js +1451 -1158
  265. package/lib/solution/Checkout/types.js +91 -61
  266. package/lib/solution/Checkout/utils/index.js +228 -156
  267. package/lib/solution/PlaceOrder/index.js +55 -0
  268. package/lib/solution/RegisterAndLogin/config.js +493 -460
  269. package/lib/solution/RegisterAndLogin/index.js +633 -630
  270. package/lib/solution/RegisterAndLogin/types.js +189 -76
  271. package/lib/solution/RegisterAndLogin/utils.js +183 -125
  272. package/lib/solution/Sales/index.js +328 -324
  273. package/lib/solution/Sales/types.js +27 -33
  274. package/lib/solution/ScanOrder/index.js +832 -864
  275. package/lib/solution/ScanOrder/types.js +33 -34
  276. package/lib/solution/ScanOrder/utils.js +409 -374
  277. package/lib/solution/ShopDiscount/index.js +226 -232
  278. package/lib/solution/ShopDiscount/types.js +15 -37
  279. package/lib/solution/ShopDiscount/utils.js +300 -172
  280. package/lib/solution/UnifiedBookingSales/index.js +1035 -1201
  281. package/lib/solution/UnifiedBookingSales/remoteOccupancyCache.js +99 -159
  282. package/lib/solution/UnifiedBookingSales/types.js +10 -32
  283. package/lib/solution/VenueBooking/index.js +811 -879
  284. package/lib/solution/VenueBooking/types.js +19 -39
  285. package/lib/solution/VenueBooking/utils/dateSummary.js +27 -56
  286. package/lib/solution/VenueBooking/utils/resource.js +31 -54
  287. package/lib/solution/VenueBooking/utils/slotMerge.js +94 -107
  288. package/lib/solution/VenueBooking/utils/timeSlot.js +132 -132
  289. package/lib/solution/VenueBooking/utils.js +130 -67
  290. package/lib/solution/index.js +124 -41
  291. package/lib/store/createStore.js +32 -29
  292. package/lib/types/index.js +4 -16
  293. package/lib/utils/payment-number.js +26 -46
  294. package/lib/utils/task.js +36 -36
  295. package/lib/utils/watch.js +81 -47
  296. package/package.json +2 -1
@@ -1,46 +1,24 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
18
2
 
19
- // src/modules/BookingContext/utils/resourceSelection.ts
20
- var resourceSelection_exports = {};
21
- __export(resourceSelection_exports, {
22
- hasActualResourceSelection: () => hasActualResourceSelection,
23
- productNeedsResourceExtend: () => productNeedsResourceExtend
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
24
5
  });
25
- module.exports = __toCommonJS(resourceSelection_exports);
6
+ exports.hasActualResourceSelection = hasActualResourceSelection;
7
+ exports.productNeedsResourceExtend = productNeedsResourceExtend;
8
+ /**
9
+ * 预约商品资源是否「需要补齐 / 已选中」——供 getProductExtend 门禁与 getIsAutoClose 共用。
10
+ */
11
+
12
+ /** 商品是否挂了生效的资源表单(product_resource.resources status=1)。 */
26
13
  function productNeedsResourceExtend(cacheItem) {
27
- var _a;
28
- const forms = (_a = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _a.resources;
29
- if (!Array.isArray(forms))
30
- return false;
31
- return forms.some((d) => Number(d == null ? void 0 : d.status) === 1);
14
+ const forms = cacheItem?.product_resource?.resources;
15
+ if (!Array.isArray(forms)) return false;
16
+ return forms.some(d => Number(d?.status) === 1);
32
17
  }
18
+
19
+ /** `_extend.resource` 是否至少有一类表单选中了具体资源。 */
33
20
  function hasActualResourceSelection(cacheItem) {
34
- var _a;
35
- const resource = (_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource;
36
- if (!resource || typeof resource !== "object")
37
- return false;
38
- return Object.values(resource).some(
39
- (rows) => Array.isArray(rows) && rows.length > 0
40
- );
41
- }
42
- // Annotate the CommonJS export names for ESM import in node:
43
- 0 && (module.exports = {
44
- hasActualResourceSelection,
45
- productNeedsResourceExtend
46
- });
21
+ const resource = cacheItem?._extend?.resource;
22
+ if (!resource || typeof resource !== 'object') return false;
23
+ return Object.values(resource).some(rows => Array.isArray(rows) && rows.length > 0);
24
+ }
@@ -1,117 +1,110 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ "use strict";
28
2
 
29
- // src/modules/BookingContext/utils/resources.ts
30
- var resources_exports = {};
31
- __export(resources_exports, {
32
- formatResource: () => formatResource,
33
- formatResources: () => formatResources,
34
- formatTimes: () => formatTimes,
35
- getResourceByIds: () => getResourceByIds,
36
- getResourceTimeIsUsable: () => getResourceTimeIsUsable,
37
- getSumCapacity: () => getSumCapacity,
38
- getUsableTime: () => getUsableTime,
39
- setDefaultCapacitys: () => setDefaultCapacitys,
40
- setDefaultResource: () => setDefaultResource
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
41
5
  });
42
- module.exports = __toCommonJS(resources_exports);
43
- var import_dayjs = __toESM(require("dayjs"));
44
- var import_lodash_es = require("lodash-es");
45
- var import_flexible = require("./flexible");
46
- var import_noResource = require("./noResource");
47
- var import_serviceTimes = require("./serviceTimes");
6
+ exports.formatResource = formatResource;
7
+ exports.formatResources = formatResources;
8
+ exports.formatTimes = formatTimes;
9
+ exports.getResourceByIds = getResourceByIds;
10
+ exports.getResourceTimeIsUsable = getResourceTimeIsUsable;
11
+ exports.getSumCapacity = getSumCapacity;
12
+ exports.getUsableTime = getUsableTime;
13
+ exports.setDefaultCapacitys = setDefaultCapacitys;
14
+ exports.setDefaultResource = setDefaultResource;
15
+ var _dayjs = _interopRequireDefault(require("dayjs"));
16
+ var _lodashEs = require("lodash-es");
17
+ var _flexible = require("./flexible");
18
+ var _noResource = require("./noResource");
19
+ var _serviceTimes = require("./serviceTimes");
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+ /**
22
+ * 资源运行态计算 helper(搬自 info2 `utilsByBooking.ts` + `service/addService/utils.tsx`)。
23
+ *
24
+ * 本文件输入输出全部为 plain object,不依赖 React / locales / @pisell/icon / mini-redux。
25
+ * 调用方传入:resource origin map(`/form/schedule` 返回) / cacheItem(含 `_extend.duration / _extend.start_date / _extend.start_time` 等)。
26
+ *
27
+ * 三个 info2 独有特性保留:
28
+ * 1. `resource_display_scope='all'`:取全部资源
29
+ * 2. `extraResources`:拖入未绑定资源时兼容渲染
30
+ * 3. `getNoResource2()`:占位"无资源"行
31
+ */
32
+
33
+ /**
34
+ * 从已选资源中取「最早结束」的 usableTime,供灵活时长计算上限。
35
+ * 与 info2 `service/addService/utils.tsx#getUsableTime` 等价。
36
+ */
48
37
  function getUsableTime(cacheItem) {
49
- var _a, _b, _c;
50
38
  try {
51
- const resourceByForm = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.resource) || {};
52
- const resourceMaps = ((_b = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _b.resourceMaps) || {};
39
+ const resourceByForm = cacheItem?._extend?.resource || {};
40
+ const resourceMaps = cacheItem?._data?.resourceMaps || {};
53
41
  let items = [];
54
42
  for (const formId of Object.keys(resourceByForm)) {
55
43
  const selected = resourceByForm[formId];
56
- const maps = (_c = resourceMaps[formId]) == null ? void 0 : _c.renderListMaps;
57
- if (!Array.isArray(selected) || !maps)
58
- continue;
59
- items = items.concat(
60
- selected.map((d) => maps[d.relation_id]).filter(Boolean)
61
- );
44
+ const maps = resourceMaps[formId]?.renderListMaps;
45
+ if (!Array.isArray(selected) || !maps) continue;
46
+ items = items.concat(selected.map(d => maps[d.relation_id]).filter(Boolean));
62
47
  }
63
- if (!items.length)
64
- return null;
48
+ if (!items.length) return null;
65
49
  return items.reduce((pre, event) => {
66
- var _a2, _b2, _c2, _d;
67
- const endAt = (0, import_dayjs.default)((_b2 = (_a2 = event._extend) == null ? void 0 : _a2.usableTime) == null ? void 0 : _b2.end_at);
68
- const preEnd = (0, import_dayjs.default)((_d = (_c2 = pre._extend) == null ? void 0 : _c2.usableTime) == null ? void 0 : _d.end_at);
50
+ const endAt = (0, _dayjs.default)(event._extend?.usableTime?.end_at);
51
+ const preEnd = (0, _dayjs.default)(pre._extend?.usableTime?.end_at);
69
52
  return endAt.isBefore(preEnd) ? event : pre;
70
53
  }, items[0]);
71
54
  } catch {
72
55
  return null;
73
56
  }
74
57
  }
58
+
59
+ /** Σ cacheItem._extend.capacity[].value × _extend.quantity。 */
75
60
  function getSumCapacity(cacheItem, isCalcQuantity = true) {
76
- var _a, _b;
77
- const list = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.capacity) || [];
61
+ const list = cacheItem?._extend?.capacity || [];
78
62
  let sum = 0;
79
63
  for (const item of list) {
80
- sum += Number((item == null ? void 0 : item.value) || 0);
64
+ sum += Number(item?.value || 0);
81
65
  }
82
- return sum * (isCalcQuantity ? ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) || 1 : 1);
66
+ return sum * (isCalcQuantity ? cacheItem?._extend?.quantity || 1 : 1);
83
67
  }
68
+
69
+ /** 当前 time 剩余容量 = totalCapacity - Σ event.pax。 */
84
70
  function getUseableEventCount(eventList, current) {
85
- return (eventList || []).reduce((pre, event) => pre - ((event == null ? void 0 : event.pax) || 0), current || 0);
71
+ return (eventList || []).reduce((pre, event) => pre - (event?.pax || 0), current || 0);
86
72
  }
73
+
74
+ /** 判断两个时间段是否有冲突。 */
87
75
  function isConflict(event, current) {
88
- const eventStart = (0, import_dayjs.default)(event.start_at);
89
- const eventEnd = (0, import_dayjs.default)(event.end_at);
90
- const currentStart = (0, import_dayjs.default)(current.start_at);
76
+ const eventStart = (0, _dayjs.default)(event.start_at);
77
+ const eventEnd = (0, _dayjs.default)(event.end_at);
78
+ const currentStart = (0, _dayjs.default)(current.start_at);
91
79
  const isBefore = currentStart.isBefore(eventEnd);
92
80
  let isAfter = true;
93
81
  if (current.end_at) {
94
- const currentEnd = (0, import_dayjs.default)(current.end_at);
82
+ const currentEnd = (0, _dayjs.default)(current.end_at);
95
83
  isAfter = currentEnd.isAfter(eventStart);
96
84
  }
97
85
  return isBefore && isAfter;
98
86
  }
87
+
88
+ /**
89
+ * 判断单个 time 是否可用,写回 `_extend` 标记位(isDateRange / isCountRange / isUsable / isMaxLimitRange)。
90
+ * 与 info2 `utilsByBooking.ts#getResourceTimeIsUsable` 等价。
91
+ */
99
92
  function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
100
- const startDate = (0, import_dayjs.default)(
101
- `${(0, import_dayjs.default)(cacheItem._extend.start_date).format("YYYY-MM-DD")} ${(0, import_serviceTimes.getServeStartTime)(cacheItem._extend.start_time)}`
102
- );
103
- const isFlexible = import_flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
93
+ const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem._extend.start_date).format('YYYY-MM-DD')} ${(0, _serviceTimes.getServeStartTime)(cacheItem._extend.start_time)}`);
94
+ const isFlexible = _flexible.flexibleObj.isFlexible(cacheItem._extend.duration);
104
95
  let isMaxLimitRange = false;
105
96
  let isDateRange = false;
106
97
  let isCountRange = false;
107
- const time = { ...item };
108
- const timeStartDate = (0, import_dayjs.default)(`${time.start_date} ${time.start_time}`).subtract(1, "second");
109
- const timeEndDate = (0, import_dayjs.default)(`${time.end_date} ${time.end_time}`).add(1, "second");
98
+ const time = {
99
+ ...item
100
+ };
101
+ const timeStartDate = (0, _dayjs.default)(`${time.start_date} ${time.start_time}`).subtract(1, 'second');
102
+ const timeEndDate = (0, _dayjs.default)(`${time.end_date} ${time.end_time}`).add(1, 'second');
110
103
  const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
111
104
  const currentCount = getSumCapacity(cacheItem);
112
105
  let eventList = time.event_list || [];
113
- if (cacheItem == null ? void 0 : cacheItem.booking_id) {
114
- eventList = eventList.filter((event) => event.id !== cacheItem.booking_id);
106
+ if (cacheItem?.booking_id) {
107
+ eventList = eventList.filter(event => event.id !== cacheItem.booking_id);
115
108
  }
116
109
  let endDate = null;
117
110
  let isCalcCount = true;
@@ -123,20 +116,25 @@ function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
123
116
  isCountRange = false;
124
117
  }
125
118
  } else {
126
- endDate = startDate.add(import_flexible.flexibleObj.getValue(cacheItem._extend.duration), "minute");
119
+ endDate = startDate.add(_flexible.flexibleObj.getValue(cacheItem._extend.duration), 'minute');
127
120
  const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
128
- if (isTimeRange)
129
- isDateRange = true;
121
+ if (isTimeRange) isDateRange = true;
130
122
  }
131
123
  if (isCalcCount) {
132
- const conflict = (eventList || []).filter(
133
- (d) => isConflict({ start_at: d.start_at, end_at: d.end_at }, { start_at: startDate, end_at: endDate })
134
- );
135
- if (resourceItem.resourceType === "single") {
124
+ const conflict = (eventList || []).filter(d => isConflict({
125
+ start_at: d.start_at,
126
+ end_at: d.end_at
127
+ }, {
128
+ start_at: startDate,
129
+ end_at: endDate
130
+ }));
131
+ if (resourceItem.resourceType === 'single') {
136
132
  isCountRange = conflict.length === 0;
137
133
  } else {
138
134
  const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
139
135
  isCountRange = currentCount <= conflictCount;
136
+ // totalCount 当前未直接参与判定,保留 reference 以与原版接近。
137
+ void totalCount;
140
138
  }
141
139
  }
142
140
  const isUsable = isDateRange && isCountRange;
@@ -148,22 +146,27 @@ function getResourceTimeIsUsable(item, cacheItem, resourceItem) {
148
146
  };
149
147
  return time;
150
148
  }
149
+
150
+ /**
151
+ * 在 resource.times 中找到最佳可用 time,并写回 `_extend.usableTime`。
152
+ * 与 info2 `utilsByBooking.ts#formatTimes` 等价。
153
+ */
151
154
  function formatTimes(resourceItem, cacheItem) {
152
155
  const usableTimes = [];
153
- const _resourceItem = { ...resourceItem };
156
+ const _resourceItem = {
157
+ ...resourceItem
158
+ };
154
159
  const sum = getSumCapacity(cacheItem);
155
160
  if (_resourceItem.capacity >= sum) {
156
- _resourceItem.times = (_resourceItem.times || []).map((time) => {
157
- var _a;
158
- const _time2 = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
159
- if ((_a = _time2 == null ? void 0 : _time2._extend) == null ? void 0 : _a.isDateRange)
160
- usableTimes.push(_time2);
161
- return _time2;
161
+ _resourceItem.times = (_resourceItem.times || []).map(time => {
162
+ const _time = getResourceTimeIsUsable(time, cacheItem, _resourceItem);
163
+ if (_time?._extend?.isDateRange) usableTimes.push(_time);
164
+ return _time;
162
165
  });
163
166
  }
164
167
  const _time = usableTimes.sort((a, b) => {
165
- const aEnd = (0, import_dayjs.default)(`${a.end_date} ${a.end_time}`).valueOf();
166
- const bEnd = (0, import_dayjs.default)(`${b.end_date} ${b.end_time}`).valueOf();
168
+ const aEnd = (0, _dayjs.default)(`${a.end_date} ${a.end_time}`).valueOf();
169
+ const bEnd = (0, _dayjs.default)(`${b.end_date} ${b.end_time}`).valueOf();
167
170
  return aEnd - bEnd;
168
171
  })[0];
169
172
  resourceItem._extend = {
@@ -172,53 +175,81 @@ function formatTimes(resourceItem, cacheItem) {
172
175
  };
173
176
  return resourceItem;
174
177
  }
178
+
179
+ /**
180
+ * 单个 resource 的整体可用性 + labelText 填充。
181
+ * 与 info2 `utilsByBooking.ts#formatResource` 等价;不再接收 formatLabel 回调(OS 不渲染 JSX)。
182
+ */
175
183
  function formatResource(resourceItem, cacheItem) {
176
- var _a, _b, _c;
177
- let _resourceItem = { ...resourceItem };
184
+ let _resourceItem = {
185
+ ...resourceItem
186
+ };
178
187
  _resourceItem = formatTimes(_resourceItem, cacheItem);
179
188
  _resourceItem.labelText = _resourceItem.main_field;
180
- const usable = (_c = (_b = (_a = _resourceItem._extend) == null ? void 0 : _a.usableTime) == null ? void 0 : _b._extend) == null ? void 0 : _c.isUsable;
189
+ const usable = _resourceItem._extend?.usableTime?._extend?.isUsable;
181
190
  _resourceItem.usable = usable;
182
191
  return _resourceItem;
183
192
  }
193
+
194
+ /**
195
+ * 把单个 resource origin 类型(如「技师」)的 renderList 中每个资源跑一遍 formatResource,
196
+ * 并维护 unbound 标记(拖入未绑定资源时 UI 用)。
197
+ * 与 info2 `service/addService/utils.tsx#formatResources` 等价(剥 JSX)。
198
+ */
184
199
  function formatResources(params) {
185
- const { cacheItem, resourcesOrigin } = params;
200
+ const {
201
+ cacheItem,
202
+ resourcesOrigin
203
+ } = params;
186
204
  try {
187
205
  const maps = {};
188
- const list = resourcesOrigin.map((item) => {
189
- const _item = (0, import_lodash_es.cloneDeep)(item);
206
+ const list = resourcesOrigin.map(item => {
207
+ const _item = (0, _lodashEs.cloneDeep)(item);
190
208
  const renderListMaps = {};
191
- _item.renderList = _item.renderList.map((d) => {
209
+ _item.renderList = _item.renderList.map(d => {
192
210
  const res = formatResource(d, cacheItem);
193
211
  const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
194
- if (unbound)
195
- res.unbound = true;
212
+ if (unbound) res.unbound = true;
196
213
  renderListMaps[res.id] = res;
197
214
  return res;
198
215
  }).sort((a, b) => b.usable ? 1 : -1);
199
- maps[_item.form_id] = { ..._item, renderListMaps };
216
+ maps[_item.form_id] = {
217
+ ..._item,
218
+ renderListMaps
219
+ };
200
220
  return _item;
201
221
  });
202
- return { list, maps };
222
+ return {
223
+ list,
224
+ maps
225
+ };
203
226
  } catch (err) {
204
- console.warn("[BookingContext] formatResources error", err);
205
- return { list: [], maps: {} };
227
+ console.warn('[BookingContext] formatResources error', err);
228
+ return {
229
+ list: [],
230
+ maps: {}
231
+ };
206
232
  }
207
233
  }
234
+
235
+ /** 取可用资源中"最大空闲时长"的那一个,作为自动分派候选。 */
208
236
  function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
209
- const { renderList, form_id } = resource;
210
- if (!isAutoAllocationOn(form_id))
211
- return [];
212
- const usableList = (renderList || []).filter((d) => d.usable && d.id !== 0);
237
+ const {
238
+ renderList,
239
+ form_id
240
+ } = resource;
241
+ if (!isAutoAllocationOn(form_id)) return [];
242
+ const usableList = (renderList || []).filter(d => d.usable && d.id !== 0);
213
243
  let defaultResource = [];
214
244
  let maxFreeTime = 0;
215
- usableList.forEach((d) => {
216
- const { times = [] } = d;
245
+ usableList.forEach(d => {
246
+ const {
247
+ times = []
248
+ } = d;
217
249
  const currentMaxFreeTime = times.reduce((pre, cur) => {
218
- var _a, _b, _c;
219
- const start = ((_c = (_b = cur.event_list) == null ? void 0 : _b[((_a = cur.event_list) == null ? void 0 : _a.length) - 1]) == null ? void 0 : _c.end_at) || cur.start_at;
250
+ const start = cur.event_list?.[cur.event_list?.length - 1]?.end_at || cur.start_at;
220
251
  const end = cur.end_at;
221
- const diff = (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(start), "minute");
252
+ const diff = (0, _dayjs.default)(end).diff((0, _dayjs.default)(start), 'minute');
222
253
  return diff > pre ? diff : pre;
223
254
  }, 0);
224
255
  if (currentMaxFreeTime > maxFreeTime) {
@@ -228,8 +259,19 @@ function getResourceMaxFreeTime(resource, isAutoAllocationOn) {
228
259
  });
229
260
  return defaultResource;
230
261
  }
262
+
263
+ /**
264
+ * 计算每类资源的默认值(写入 cacheItem._extend.resource)。
265
+ * 与 info2 `service/addService/utils.tsx#setDefaultResource` 等价;
266
+ * `resourceIdFromCalendar` 替代原版 sessionStorage `serviceParams.resource_id` 读取。
267
+ */
231
268
  function setDefaultResource(params) {
232
- const { cacheItem, resources, resourceIdFromCalendar, isAutoAllocationOn = () => true } = params;
269
+ const {
270
+ cacheItem,
271
+ resources,
272
+ resourceIdFromCalendar,
273
+ isAutoAllocationOn = () => true
274
+ } = params;
233
275
  const obj = {};
234
276
  const resourceId = Number(resourceIdFromCalendar) || 0;
235
277
  for (const item of resources) {
@@ -238,8 +280,8 @@ function setDefaultResource(params) {
238
280
  optional_resource = [],
239
281
  default_resource = []
240
282
  } = item;
241
- const renderList = item.renderList.filter((d) => {
242
- if ((select_type == null ? void 0 : select_type.type) === "single") {
283
+ const renderList = item.renderList.filter(d => {
284
+ if (select_type?.type === 'single') {
243
285
  if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
244
286
  return d.id === resourceId;
245
287
  }
@@ -253,46 +295,64 @@ function setDefaultResource(params) {
253
295
  } else {
254
296
  defaultOriginalResource = renderList;
255
297
  }
256
- obj[item.form_id] = defaultOriginalResource.map((d) => ({
298
+ obj[item.form_id] = defaultOriginalResource.map(d => ({
257
299
  children: d.children,
258
300
  relation_type: d.relation_type,
259
301
  form_id: item.form_id,
260
302
  relation_id: d.id,
261
- like_status: "common",
303
+ like_status: 'common',
262
304
  metadata: {
263
305
  form_name: item.title,
264
306
  resource_name: d.main_field
265
307
  }
266
308
  }));
309
+ // errors 字段由调用方在需要时通过 getResourceErrors 单独算,OS 这里不耦合。
267
310
  }
268
311
  return obj;
269
312
  }
313
+
314
+ /**
315
+ * 计算默认容量(与 info2 `setDefaultCapacitys` 等价)。
316
+ * package:按 _extend.other.bundle 拆 quantity;custom:按 capacity.custom[].min;其他:[{id:0,value:1}]。
317
+ */
270
318
  function setDefaultCapacitys(params) {
271
- var _a, _b;
272
- const { capacitys, cacheItem } = params;
273
- if ((capacitys == null ? void 0 : capacitys.type) === "package") {
274
- return (((_b = (_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.other) == null ? void 0 : _b.bundle) || []).map((d) => {
319
+ const {
320
+ capacitys,
321
+ cacheItem
322
+ } = params;
323
+ if (capacitys?.type === 'package') {
324
+ return (cacheItem?._extend?.other?.bundle || []).map(d => {
275
325
  const id = d._bundle_product_id;
276
- const item = ((capacitys == null ? void 0 : capacitys.package) || []).find((p) => p.product_id === id);
326
+ const item = (capacitys?.package || []).find(p => p.product_id === id);
277
327
  return {
278
328
  id,
279
329
  value: item ? d.quantity || 0 : 0,
280
- name: (item == null ? void 0 : item.name) || (d == null ? void 0 : d.title)
330
+ name: item?.name || d?.title
281
331
  };
282
332
  });
283
333
  }
284
- if ((capacitys == null ? void 0 : capacitys.type) === "custom") {
285
- return ((capacitys == null ? void 0 : capacitys.custom) || []).map((d) => ({
334
+ if (capacitys?.type === 'custom') {
335
+ return (capacitys?.custom || []).map(d => ({
286
336
  id: d.id,
287
337
  value: d.min,
288
338
  name: d.name
289
339
  }));
290
340
  }
291
- return [{ id: 0, value: 1, name: "" }];
341
+ return [{
342
+ id: 0,
343
+ value: 1,
344
+ name: ''
345
+ }];
292
346
  }
347
+
348
+ /**
349
+ * 通过商品 `product_resource.resources[]` 关联的 form/resource id,从 resourcesOriginMap 还原资源数据。
350
+ * 与 info2 `service/addService/utils.tsx#getResourceByIds` 等价(保留三特性)。
351
+ */
293
352
  function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
294
- var _a, _b;
295
- const _resources = [...((_a = cacheItem == null ? void 0 : cacheItem.product_resource) == null ? void 0 : _a.resources) || []].filter((d) => Number(d == null ? void 0 : d.status) === 1).map((item) => ({ ...item }));
353
+ const _resources = [...(cacheItem?.product_resource?.resources || [])].filter(d => Number(d?.status) === 1).map(item => ({
354
+ ...item
355
+ }));
296
356
  const {
297
357
  extraResources = [],
298
358
  resourcesOrigin = [],
@@ -300,29 +360,24 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
300
360
  } = extraParams || {};
301
361
  for (const item of _resources) {
302
362
  const form_id = item.id;
303
- const isAllResource = ((_b = resourceTab == null ? void 0 : resourceTab[item.code]) == null ? void 0 : _b.resource_display_scope) === "all";
363
+ const isAllResource = resourceTab?.[item.code]?.resource_display_scope === 'all';
304
364
  let extraResourceIds = [];
305
365
  if (isAllResource) {
306
- extraResourceIds = (resourcesOrigin || []).filter((d) => d.form_code === item.code).map((d) => d.id);
366
+ extraResourceIds = (resourcesOrigin || []).filter(d => d.form_code === item.code).map(d => d.id);
307
367
  } else {
308
- extraResourceIds = extraResources.filter(
309
- (_extraItem) => _extraItem.form_id === form_id && !!_extraItem.id && !item.optional_resource.includes(_extraItem.id) && !item.default_resource.includes(_extraItem.id)
310
- ).map((_extraItem) => _extraItem.id);
368
+ extraResourceIds = extraResources.filter(_extraItem => _extraItem.form_id === form_id && !!_extraItem.id && !item.optional_resource.includes(_extraItem.id) && !item.default_resource.includes(_extraItem.id)).map(_extraItem => _extraItem.id);
311
369
  }
312
370
  extraResourceIds = Array.from(new Set(extraResourceIds));
313
- item.optional_resource = (item.optional_resource || []).filter(
314
- (d) => item.default_resource.indexOf(d) === -1
315
- );
316
- const getChildrenMetadata = (id) => {
371
+ item.optional_resource = (item.optional_resource || []).filter(d => item.default_resource.indexOf(d) === -1);
372
+ const getChildrenMetadata = id => {
317
373
  const combiningResources = [];
318
374
  const origin = resourcesOriginMap[id];
319
- if ((origin == null ? void 0 : origin.combined_resource) && origin.combined_resource.status === 1) {
320
- (origin.combined_resource.resource_ids || []).forEach((cid) => {
321
- var _a2, _b2;
375
+ if (origin?.combined_resource && origin.combined_resource.status === 1) {
376
+ (origin.combined_resource.resource_ids || []).forEach(cid => {
322
377
  if (resourcesOriginMap[cid]) {
323
378
  combiningResources.push({
324
379
  ...resourcesOriginMap[cid],
325
- relation_id: ((_a2 = resourcesOriginMap[cid]) == null ? void 0 : _a2.relation_id) || ((_b2 = resourcesOriginMap[cid]) == null ? void 0 : _b2.id)
380
+ relation_id: resourcesOriginMap[cid]?.relation_id || resourcesOriginMap[cid]?.id
326
381
  });
327
382
  }
328
383
  });
@@ -330,23 +385,22 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
330
385
  return {
331
386
  children: combiningResources,
332
387
  metadata: {
333
- ...(origin == null ? void 0 : origin.metadata) || {},
334
- combined_resource: origin == null ? void 0 : origin.combined_resource
388
+ ...(origin?.metadata || {}),
389
+ combined_resource: origin?.combined_resource
335
390
  }
336
391
  };
337
392
  };
338
- const optional_resource = Array.from(
339
- /* @__PURE__ */ new Set([...item.optional_resource, ...extraResourceIds])
340
- ).map((d) => {
341
- if (!resourcesOriginMap[d])
342
- return null;
393
+ const optional_resource = Array.from(new Set([...item.optional_resource, ...extraResourceIds])).map(d => {
394
+ if (!resourcesOriginMap[d]) return null;
343
395
  return Object.assign({}, resourcesOriginMap[d], {
344
396
  form_id,
345
397
  resourceType: item.type,
346
398
  ...getChildrenMetadata(d)
347
399
  });
348
- }).filter((d) => d).concat((0, import_noResource.getNoResource2)({ form_id }));
349
- const default_resource = (item.default_resource || []).map((d) => {
400
+ }).filter(d => d).concat((0, _noResource.getNoResource2)({
401
+ form_id
402
+ }));
403
+ const default_resource = (item.default_resource || []).map(d => {
350
404
  const origin = resourcesOriginMap[d];
351
405
  if (origin) {
352
406
  origin.is_default = 1;
@@ -357,21 +411,9 @@ function getResourceByIds(resourcesOriginMap, cacheItem, extraParams) {
357
411
  });
358
412
  }
359
413
  return null;
360
- }).filter((d) => d);
414
+ }).filter(d => d);
361
415
  item.renderList = optional_resource.concat(default_resource);
362
416
  item.form_id = form_id;
363
417
  }
364
418
  return _resources;
365
- }
366
- // Annotate the CommonJS export names for ESM import in node:
367
- 0 && (module.exports = {
368
- formatResource,
369
- formatResources,
370
- formatTimes,
371
- getResourceByIds,
372
- getResourceTimeIsUsable,
373
- getSumCapacity,
374
- getUsableTime,
375
- setDefaultCapacitys,
376
- setDefaultResource
377
- });
419
+ }