@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,222 +1,269 @@
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/productExtend.ts
30
- var productExtend_exports = {};
31
- __export(productExtend_exports, {
32
- derivePresetStartTimeFromDate: () => derivePresetStartTimeFromDate,
33
- getIsAutoClose: () => getIsAutoClose,
34
- getProductExtend: () => getProductExtend,
35
- getServiceStartTimeAndEndTime: () => getServiceStartTimeAndEndTime,
36
- getSumCapacity: () => import_resources.getSumCapacity,
37
- getTimeObj: () => getTimeObj
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.derivePresetStartTimeFromDate = derivePresetStartTimeFromDate;
7
+ exports.getIsAutoClose = getIsAutoClose;
8
+ exports.getProductExtend = getProductExtend;
9
+ exports.getServiceStartTimeAndEndTime = getServiceStartTimeAndEndTime;
10
+ Object.defineProperty(exports, "getSumCapacity", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _resources.getSumCapacity;
14
+ }
38
15
  });
39
- module.exports = __toCommonJS(productExtend_exports);
40
- var import_dayjs = __toESM(require("dayjs"));
41
- var import_resources = require("./resources");
42
- var import_resourceSelection = require("./resourceSelection");
43
- var import_serviceTimes = require("./serviceTimes");
44
- var import_timeSlices = require("./timeSlices");
45
- var import_flexible = require("./flexible");
16
+ exports.getTimeObj = getTimeObj;
17
+ var _dayjs = _interopRequireDefault(require("dayjs"));
18
+ var _resources = require("./resources");
19
+ var _resourceSelection = require("./resourceSelection");
20
+ var _serviceTimes = require("./serviceTimes");
21
+ var _timeSlices = require("./timeSlices");
22
+ var _flexible = require("./flexible");
23
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
+ /**
25
+ * 上下文(与 info2 state.bookingConfig / state.service / state.date 一一对应)。
26
+ *
27
+ * 设计原则:所有助手函数都通过 context 显式拿数据,**不读 mini-redux**,
28
+ * 让 OS 这层完全可在 Node 单测下运行(dayjs 在 Node 也是纯函数)。
29
+ */
30
+
31
+ /** 从 BookingContext.date 提取 HH:mm(仅当日期带有效时分时)。 */
46
32
  function derivePresetStartTimeFromDate(date) {
47
- if (date == null)
48
- return void 0;
49
- const d = (0, import_dayjs.default)(date);
50
- if (!d.isValid())
51
- return void 0;
52
- const hhmm = d.format("HH:mm");
53
- if (hhmm === "00:00")
54
- return void 0;
33
+ if (date == null) return undefined;
34
+ const d = (0, _dayjs.default)(date);
35
+ if (!d.isValid()) return undefined;
36
+ const hhmm = d.format('HH:mm');
37
+ if (hhmm === '00:00') return undefined;
55
38
  return hhmm;
56
39
  }
40
+
41
+ /**
42
+ * 取预约时间偏好(sequential / parallel);默认 sequential。
43
+ */
57
44
  function getAppointmentTimingPreference(ctx) {
58
- var _a, _b, _c;
59
- return ((_c = (_b = (_a = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.information_tab) == null ? void 0 : _c.appointment_timing_preference) || "sequential";
45
+ return ctx?.bookingConfig?.config?.information_tab?.appointment_timing_preference || 'sequential';
60
46
  }
47
+
48
+ /**
49
+ * 灵活时长选项(cacheItem.duration.type === 'flexible' 时)。
50
+ */
61
51
  function getFlexibleOption(params) {
62
- var _a, _b, _c, _d, _e;
63
- const { cacheItem, useStartTime } = params;
64
- const duration = (0, import_flexible.getDurationValue)(cacheItem == null ? void 0 : cacheItem.duration);
65
- if (duration !== "flexible")
66
- return null;
67
- const startDate = (0, import_dayjs.default)(
68
- `${(0, import_dayjs.default)((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.start_date).format("YYYY-MM-DD")} ${useStartTime || ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.start_time) || "00:00"}`
69
- );
70
- const usable = (0, import_resources.getUsableTime)(cacheItem);
71
- const usableEndAt = ((_d = (_c = usable == null ? void 0 : usable._extend) == null ? void 0 : _c.usableTime) == null ? void 0 : _d.end_at) ? (0, import_dayjs.default)(usable._extend.usableTime.end_at) : null;
72
- const endDate = (0, import_timeSlices.getEndDate)(
73
- startDate,
74
- "flexible",
75
- usableEndAt,
76
- (_e = params.ctx) == null ? void 0 : _e.shopOpeningHours
77
- );
78
- const timeValue = endDate.diff(startDate, "minute");
79
- return { label: String(timeValue), value: import_flexible.flexibleObj.create(timeValue) };
52
+ const {
53
+ cacheItem,
54
+ useStartTime
55
+ } = params;
56
+ const duration = (0, _flexible.getDurationValue)(cacheItem?.duration);
57
+ if (duration !== 'flexible') return null;
58
+ const startDate = (0, _dayjs.default)(`${(0, _dayjs.default)(cacheItem?._extend?.start_date).format('YYYY-MM-DD')} ${useStartTime || cacheItem?._extend?.start_time || '00:00'}`);
59
+ const usable = (0, _resources.getUsableTime)(cacheItem);
60
+ const usableEndAt = usable?._extend?.usableTime?.end_at ? (0, _dayjs.default)(usable._extend.usableTime.end_at) : null;
61
+ const endDate = (0, _timeSlices.getEndDate)(startDate, 'flexible', usableEndAt, params.ctx?.shopOpeningHours);
62
+ const timeValue = endDate.diff(startDate, 'minute');
63
+ return {
64
+ label: String(timeValue),
65
+ value: _flexible.flexibleObj.create(timeValue)
66
+ };
80
67
  }
68
+
69
+ /**
70
+ * 时间切片对象(含灵活时长选项)。与 info2 `getTimeObj` 等价。
71
+ */
81
72
  function getTimeObj(params) {
82
- var _a, _b, _c;
83
- const { cacheItem, useStartTime, useDuration, ctx } = params;
84
- const isMultiDay = (0, import_serviceTimes.isMultiDayProduct)(cacheItem);
85
- const flexibleOption = getFlexibleOption({ cacheItem, useStartTime, ctx });
73
+ const {
74
+ cacheItem,
75
+ useStartTime,
76
+ useDuration,
77
+ ctx
78
+ } = params;
79
+ const isMultiDay = (0, _serviceTimes.isMultiDayProduct)(cacheItem);
80
+ const flexibleOption = getFlexibleOption({
81
+ cacheItem,
82
+ useStartTime,
83
+ ctx
84
+ });
86
85
  const {
87
86
  timeSlices,
88
87
  durationSlicesBasedOnTime
89
- } = (0, import_timeSlices.sliceDayIntoFiveMinutes)(
90
- (_c = (_b = (_a = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _a.config) == null ? void 0 : _b.basic) == null ? void 0 : _c.service_time,
91
- isMultiDay
92
- );
88
+ } = (0, _timeSlices.sliceDayIntoFiveMinutes)(ctx?.bookingConfig?.config?.basic?.service_time, isMultiDay);
93
89
  if (flexibleOption) {
94
90
  durationSlicesBasedOnTime.unshift(flexibleOption);
95
91
  }
96
- if (useDuration && !durationSlicesBasedOnTime.some((d) => d.value === useDuration)) {
92
+ if (useDuration && !durationSlicesBasedOnTime.some(d => d.value === useDuration)) {
97
93
  durationSlicesBasedOnTime.unshift({
98
94
  label: String(useDuration),
99
95
  value: useDuration
100
96
  });
101
97
  }
102
- return { timeSlices, durationSlicesBasedOnTime };
98
+ return {
99
+ timeSlices,
100
+ durationSlicesBasedOnTime
101
+ };
103
102
  }
103
+
104
+ /**
105
+ * 计算商品行 _extend(包含 start_time / endDate / duration / start_date / end_date / sub_type 等)。
106
+ * 与 info2 `utilsByBooking.ts#getServiceStartTimeAndEndTime` 等价;显著差异:
107
+ * - 不读 `state.service.value` / `mini-redux`,由 ctx.previousService 显式注入。
108
+ * - 不读 `sessionStorage.serviceParams`,由 ctx.presetStartTime / ctx.resourceIdFromCalendar 注入。
109
+ * - cacheItem.isCustomItem → 直接返回 `{ duration: null }`。
110
+ */
104
111
  function getServiceStartTimeAndEndTime(params) {
105
- var _a, _b, _c, _d, _e;
106
- const { cacheItem, timeObj, ctx } = params;
107
- if (cacheItem == null ? void 0 : cacheItem.isCustomItem) {
108
- return { duration: null };
112
+ const {
113
+ cacheItem,
114
+ timeObj,
115
+ ctx
116
+ } = params;
117
+ if (cacheItem?.isCustomItem) {
118
+ return {
119
+ duration: null
120
+ };
109
121
  }
110
122
  const appointmentTimingPreference = getAppointmentTimingPreference(ctx);
111
123
  const lastServer = ctx.previousService || null;
112
124
  const resolveDuration = () => {
113
- var _a2;
114
- if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem))
115
- return (0, import_serviceTimes.getDays)(cacheItem, "days");
116
- return (0, import_timeSlices.findNextDuration)(cacheItem.duration, timeObj.durationSlicesBasedOnTime, (_a2 = cacheItem == null ? void 0 : cacheItem.duration) == null ? void 0 : _a2.value);
125
+ if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) return (0, _serviceTimes.getDays)(cacheItem, 'days');
126
+ return (0, _timeSlices.findNextDuration)(cacheItem.duration, timeObj.durationSlicesBasedOnTime, cacheItem?.duration?.value);
127
+ };
128
+ let _extend = {
129
+ duration: resolveDuration()
117
130
  };
118
- let _extend = { duration: resolveDuration() };
119
131
  if (lastServer) {
120
- const lastStart = (_a = lastServer._extend) == null ? void 0 : _a.startDate;
121
- const lastEnd = (_b = lastServer._extend) == null ? void 0 : _b.endDate;
122
- if (appointmentTimingPreference === "parallel") {
123
- _extend.start_time = (0, import_dayjs.default)(lastStart).format("HH:mm");
124
- } else if ((0, import_dayjs.default)(lastEnd).isAfter((0, import_dayjs.default)(lastStart), "day")) {
125
- _extend.start_time = (_c = timeObj.timeSlices[timeObj.timeSlices.length - 1]) == null ? void 0 : _c.value;
132
+ const lastStart = lastServer._extend?.startDate;
133
+ const lastEnd = lastServer._extend?.endDate;
134
+ if (appointmentTimingPreference === 'parallel') {
135
+ _extend.start_time = (0, _dayjs.default)(lastStart).format('HH:mm');
136
+ } else if ((0, _dayjs.default)(lastEnd).isAfter((0, _dayjs.default)(lastStart), 'day')) {
137
+ _extend.start_time = timeObj.timeSlices[timeObj.timeSlices.length - 1]?.value;
126
138
  } else {
127
- _extend.start_time = lastEnd ? (0, import_dayjs.default)(lastEnd).format("HH:mm") : (0, import_dayjs.default)().format("HH:mm");
139
+ _extend.start_time = lastEnd ? (0, _dayjs.default)(lastEnd).format('HH:mm') : (0, _dayjs.default)().format('HH:mm');
128
140
  }
129
141
  } else {
130
142
  const presetStartTime = ctx.presetStartTime;
131
- if (presetStartTime && presetStartTime !== "00:00") {
143
+ // info2 getServiceStartTimeAndEndTime 一致:日历/顶部日期带 HH:mm 时原样使用,
144
+ // 不做 findNextSlice 栅格对齐(否则 01:47 会被抬到 01:50)。
145
+ if (presetStartTime && presetStartTime !== '00:00') {
132
146
  _extend.start_time = presetStartTime;
133
147
  } else if (cacheItem.currentDefaultTime) {
134
148
  _extend.start_time = cacheItem.currentDefaultTime;
135
149
  } else {
136
- _extend.start_time = (0, import_dayjs.default)().format("HH:mm");
150
+ _extend.start_time = (0, _dayjs.default)().format('HH:mm');
137
151
  }
138
152
  }
139
- _extend = { ..._extend, ...cacheItem._extend };
140
- const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)({ ...cacheItem, _extend });
153
+ _extend = {
154
+ ..._extend,
155
+ ...cacheItem._extend
156
+ };
157
+ const {
158
+ startDate,
159
+ endDate
160
+ } = (0, _serviceTimes.getServiceTimes)({
161
+ ...cacheItem,
162
+ _extend
163
+ });
141
164
  _extend.startDate = startDate;
142
165
  _extend.endDate = endDate;
143
- if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem)) {
144
- _extend.start_time = _extend.start_time || startDate.format("HH:mm");
145
- _extend.end_time = _extend.end_time || endDate.format("HH:mm");
166
+ if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) {
167
+ _extend.start_time = _extend.start_time || startDate.format('HH:mm');
168
+ _extend.end_time = _extend.end_time || endDate.format('HH:mm');
146
169
  _extend.start_date = _extend.start_date ?? startDate;
147
170
  _extend.end_date = _extend.end_date ?? endDate;
148
171
  }
149
- const session = (_e = (_d = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _d.other) == null ? void 0 : _e.session;
150
- if ((0, import_serviceTimes.isSessionProduct)(cacheItem) && session) {
151
- const baseDate = ctx.date ? (0, import_dayjs.default)(ctx.date) : (0, import_dayjs.default)();
152
- const startAt = (0, import_dayjs.default)(`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.start_at).format("HH:mm:ss")}`);
153
- const endAt = (0, import_dayjs.default)(`${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.end_at).format("HH:mm:ss")}`);
172
+ const session = cacheItem?._extend?.other?.session;
173
+ if ((0, _serviceTimes.isSessionProduct)(cacheItem) && session) {
174
+ const baseDate = ctx.date ? (0, _dayjs.default)(ctx.date) : (0, _dayjs.default)();
175
+ const startAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.start_at).format('HH:mm:ss')}`);
176
+ const endAt = (0, _dayjs.default)(`${baseDate.format('YYYY-MM-DD')} ${(0, _dayjs.default)(session.end_at).format('HH:mm:ss')}`);
154
177
  _extend.start_date = startAt;
155
178
  _extend.startDate = startAt;
156
179
  _extend.start_time = session.start_time;
157
180
  _extend.end_date = endAt;
158
181
  _extend.endDate = endAt;
159
182
  _extend.end_time = session.end_time;
160
- _extend.duration = (0, import_serviceTimes.getDays)({ _extend }, "minutes");
183
+ _extend.duration = (0, _serviceTimes.getDays)({
184
+ _extend
185
+ }, 'minutes');
161
186
  }
162
187
  return _extend;
163
188
  }
189
+
190
+ /**
191
+ * 综合:把 cacheItem 拼装出完整的 _extend / _data(资源 / 容量 / timeObj),并标记 autoClose。
192
+ * 与 info2 `service/addService/utils.tsx#getProductExtend` 等价;剥 React `console.time` / JSX。
193
+ *
194
+ * 入参 ctx 必须至少给:bookingConfig / resourcesOriginMap / resourcesOrigin / date。
195
+ */
164
196
  function getProductExtend(params) {
165
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
166
- const { cacheItem, ctx, isDisabledTime } = params;
167
- const isNew = cacheItem.new || !((_a = cacheItem._extend) == null ? void 0 : _a.endDate);
168
- const _cacheItem = { ...cacheItem };
197
+ const {
198
+ cacheItem,
199
+ ctx,
200
+ isDisabledTime
201
+ } = params;
202
+ const isNew = cacheItem.new || !cacheItem._extend?.endDate;
203
+ const _cacheItem = {
204
+ ...cacheItem
205
+ };
169
206
  const resourcesOriginMap = ctx.resourcesOriginMap || {};
170
207
  _cacheItem._data = {};
171
- if ((0, import_serviceTimes.isMultiDayProduct)(cacheItem)) {
208
+ if ((0, _serviceTimes.isMultiDayProduct)(cacheItem)) {
172
209
  _cacheItem._extend = _cacheItem._extend || {};
173
- _cacheItem._extend.holder_id = ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.holder_id) || [];
174
- _cacheItem._extend.sub_type = "days";
210
+ _cacheItem._extend.holder_id = cacheItem?._extend?.holder_id || [];
211
+ _cacheItem._extend.sub_type = 'days';
175
212
  }
176
213
  if (isNew) {
177
- _cacheItem._data.timeObj = getTimeObj({ cacheItem, ctx });
214
+ _cacheItem._data.timeObj = getTimeObj({
215
+ cacheItem,
216
+ ctx
217
+ });
178
218
  _cacheItem._extend = getServiceStartTimeAndEndTime({
179
219
  cacheItem,
180
220
  timeObj: _cacheItem._data.timeObj,
181
221
  ctx
182
222
  });
183
223
  _cacheItem._data.capacitys = cacheItem.capacity;
184
- _cacheItem._data.resourcesOrigin = (0, import_resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
185
- resourceTab: (_d = (_c = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _c.config) == null ? void 0 : _d.resource_tab,
224
+ _cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
225
+ resourceTab: ctx?.bookingConfig?.config?.resource_tab,
186
226
  resourcesOrigin: ctx.resourcesOrigin || []
187
227
  });
188
- _cacheItem._extend.capacity = (0, import_resources.setDefaultCapacitys)({
228
+ _cacheItem._extend.capacity = (0, _resources.setDefaultCapacitys)({
189
229
  capacitys: _cacheItem._data.capacitys,
190
230
  cacheItem: _cacheItem
191
231
  });
192
- const { list, maps } = (0, import_resources.formatResources)({
232
+ const {
233
+ list,
234
+ maps
235
+ } = (0, _resources.formatResources)({
193
236
  cacheItem: _cacheItem,
194
237
  resourcesOrigin: _cacheItem._data.resourcesOrigin
195
238
  });
196
239
  _cacheItem._data.resources = list;
197
240
  _cacheItem._data.resourceMaps = maps;
198
- _cacheItem._extend.resource = (0, import_resources.setDefaultResource)({
241
+ _cacheItem._extend.resource = (0, _resources.setDefaultResource)({
199
242
  cacheItem: _cacheItem,
200
243
  resources: _cacheItem._data.resources,
201
244
  resourceIdFromCalendar: ctx.resourceIdFromCalendar,
202
245
  isAutoAllocationOn: ctx.isAutoAllocationOn
203
246
  });
204
- if ((0, import_flexible.isProductFlexibleDuration)(_cacheItem == null ? void 0 : _cacheItem.duration)) {
247
+
248
+ // 灵活时长二次计算(资源默认选中后,按 usableTime 重算 flexible 分钟数)
249
+ if ((0, _flexible.isProductFlexibleDuration)(_cacheItem?.duration)) {
205
250
  _cacheItem._data.timeObj = getTimeObj({
206
251
  cacheItem: _cacheItem,
207
252
  useStartTime: _cacheItem._extend.start_time,
208
253
  ctx
209
254
  });
210
- _cacheItem._extend.duration = (_g = (_f = (_e = _cacheItem._data.timeObj) == null ? void 0 : _e.durationSlicesBasedOnTime) == null ? void 0 : _f[0]) == null ? void 0 : _g.value;
211
- const { endDate } = (0, import_serviceTimes.getServiceTimes)(_cacheItem);
255
+ _cacheItem._extend.duration = _cacheItem._data.timeObj?.durationSlicesBasedOnTime?.[0]?.value;
256
+ const {
257
+ endDate
258
+ } = (0, _serviceTimes.getServiceTimes)(_cacheItem);
212
259
  _cacheItem._extend.endDate = endDate;
213
260
  }
214
261
  _cacheItem.autoClose = getIsAutoClose(_cacheItem, ctx.isAutoAllocationOn || (() => true));
215
- if (_cacheItem._extend.bundle_edit !== void 0) {
262
+ if (_cacheItem._extend.bundle_edit !== undefined) {
216
263
  _cacheItem._extend.bundle_edit = 1;
217
264
  }
218
265
  if (!isDisabledTime) {
219
- _cacheItem._time = (/* @__PURE__ */ new Date()).getTime();
266
+ _cacheItem._time = new Date().getTime();
220
267
  }
221
268
  } else {
222
269
  if (!_cacheItem._data.capacitys) {
@@ -224,19 +271,25 @@ function getProductExtend(params) {
224
271
  }
225
272
  if (!_cacheItem._data.resourcesOrigin) {
226
273
  const extraResources = [];
227
- if (Array.isArray((_h = _cacheItem._extend) == null ? void 0 : _h.event_resources)) {
228
- _cacheItem._extend.event_resources.forEach((er) => {
229
- extraResources.push({ form_id: er.form_id, id: er.relation_id });
274
+ if (Array.isArray(_cacheItem._extend?.event_resources)) {
275
+ _cacheItem._extend.event_resources.forEach(er => {
276
+ extraResources.push({
277
+ form_id: er.form_id,
278
+ id: er.relation_id
279
+ });
230
280
  });
231
281
  }
232
- _cacheItem._data.resourcesOrigin = (0, import_resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
282
+ _cacheItem._data.resourcesOrigin = (0, _resources.getResourceByIds)(resourcesOriginMap, cacheItem, {
233
283
  extraResources,
234
- resourceTab: (_j = (_i = ctx == null ? void 0 : ctx.bookingConfig) == null ? void 0 : _i.config) == null ? void 0 : _j.resource_tab,
284
+ resourceTab: ctx?.bookingConfig?.config?.resource_tab,
235
285
  resourcesOrigin: ctx.resourcesOrigin || []
236
286
  });
237
287
  }
238
288
  if (!_cacheItem._data.resources) {
239
- const { list, maps } = (0, import_resources.formatResources)({
289
+ const {
290
+ list,
291
+ maps
292
+ } = (0, _resources.formatResources)({
240
293
  cacheItem: _cacheItem,
241
294
  resourcesOrigin: _cacheItem._data.resourcesOrigin
242
295
  });
@@ -245,40 +298,34 @@ function getProductExtend(params) {
245
298
  }
246
299
  _cacheItem._data.timeObj = getTimeObj({
247
300
  cacheItem: _cacheItem,
248
- useStartTime: (_k = _cacheItem._extend) == null ? void 0 : _k.start_time,
301
+ useStartTime: _cacheItem._extend?.start_time,
249
302
  ctx
250
303
  });
251
304
  }
252
305
  return _cacheItem;
253
306
  }
307
+
308
+ /**
309
+ * 是否可自动关闭弹窗(不需要用户进 EditService 抽屉)。
310
+ * 与 info2 `service/addService/utils.tsx#getIsAutoClose` 等价;
311
+ * `getAutoAllocationStorage` 抽象为入参 `isAutoAllocationOn(formId)`。
312
+ */
254
313
  function getIsAutoClose(cacheItem, isAutoAllocationOn) {
255
- var _a, _b, _c, _d, _e;
256
- if ((0, import_resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, import_resourceSelection.hasActualResourceSelection)(cacheItem)) {
314
+ if ((0, _resourceSelection.productNeedsResourceExtend)(cacheItem) && !(0, _resourceSelection.hasActualResourceSelection)(cacheItem)) {
257
315
  return false;
258
316
  }
259
- if (((_b = (_a = cacheItem._data) == null ? void 0 : _a.capacitys) == null ? void 0 : _b.type) !== "custom") {
260
- const resources = ((_c = cacheItem == null ? void 0 : cacheItem._data) == null ? void 0 : _c.resources) || [];
317
+ if (cacheItem._data?.capacitys?.type !== 'custom') {
318
+ const resources = cacheItem?._data?.resources || [];
261
319
  if (resources.length === 1) {
262
320
  const first = resources[0];
263
- if (((_d = first.select_type) == null ? void 0 : _d.type) === "single" && (first.default_resource || []).length > 0) {
321
+ if (first.select_type?.type === 'single' && (first.default_resource || []).length > 0) {
264
322
  return true;
265
323
  }
266
324
  }
267
325
  }
268
- const entries = Object.entries(((_e = cacheItem._extend) == null ? void 0 : _e.resource) || {});
326
+ const entries = Object.entries(cacheItem._extend?.resource || {});
269
327
  if (entries.length === 0) {
270
- return !(0, import_resourceSelection.productNeedsResourceExtend)(cacheItem);
328
+ return !(0, _resourceSelection.productNeedsResourceExtend)(cacheItem);
271
329
  }
272
- return entries.every(
273
- ([key, value]) => isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0
274
- );
275
- }
276
- // Annotate the CommonJS export names for ESM import in node:
277
- 0 && (module.exports = {
278
- derivePresetStartTimeFromDate,
279
- getIsAutoClose,
280
- getProductExtend,
281
- getServiceStartTimeAndEndTime,
282
- getSumCapacity,
283
- getTimeObj
284
- });
330
+ return entries.every(([key, value]) => isAutoAllocationOn(key) && Array.isArray(value) && value.length > 0);
331
+ }
@@ -1,55 +1,56 @@
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/resourceErrors.ts
30
- var resourceErrors_exports = {};
31
- __export(resourceErrors_exports, {
32
- getResourceErrors: () => getResourceErrors
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
33
5
  });
34
- module.exports = __toCommonJS(resourceErrors_exports);
35
- var import_dayjs = __toESM(require("dayjs"));
36
- var import_serviceTimes = require("./serviceTimes");
6
+ exports.getResourceErrors = getResourceErrors;
7
+ var _dayjs = _interopRequireDefault(require("dayjs"));
8
+ var _serviceTimes = require("./serviceTimes");
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ /**
11
+ * 结构化的「资源不可用」原因(替代 info2 `getErrorList` 输出的 i18n 文案 + type 字段)。
12
+ *
13
+ * 与 info2 type 字段映射:
14
+ * - `no_product` ↔ type='products'
15
+ * - `time_out_of_range` ↔ type='time'
16
+ * - `count_out_of_range` ↔ type='limit'
17
+ * - `resource_unbound` ↔ type='unbound'
18
+ *
19
+ * OS 这边不耦合 i18n 文案,UI 拿到 reason + params 后自行渲染(参考 docs/SDK 中给出的 i18n key 对照表)。
20
+ */
21
+
22
+ /**
23
+ * 替代 info2 `utilsByBooking.ts#getErrorList`,输出结构化错误。
24
+ *
25
+ * 行为对齐:
26
+ * 1. cacheItem 没有 id → `no_product`(与 info2 `!cacheItem?.id` 分支等价)。
27
+ * 2. 资源 null / 无 _extend → 返回 []。
28
+ * 3. resource.usable=false 时:
29
+ * - 没有 _extend.usableTime → `time_out_of_range`
30
+ * - 有 usableTime 但 `_extend.isCountRange=false` → `count_out_of_range`
31
+ * 4. resource.unbound=true → 追加 `resource_unbound`。
32
+ * 5. 不再耦合 `_data.resourceMaps[form_id].type === 'single'` 判断(与 info2 实际未使用此变量一致)。
33
+ */
37
34
  function getResourceErrors(resource, cacheItem) {
38
- var _a, _b, _c, _d;
39
- if (!(cacheItem == null ? void 0 : cacheItem.id)) {
40
- return [{ reason: "no_product", params: {} }];
35
+ if (!cacheItem?.id) {
36
+ return [{
37
+ reason: 'no_product',
38
+ params: {}
39
+ }];
41
40
  }
42
- if (!resource)
43
- return [];
41
+ if (!resource) return [];
44
42
  const list = [];
45
43
  if (!resource.usable) {
46
- const { startDate, endDate } = (0, import_serviceTimes.getServiceTimes)(cacheItem);
47
- const startText = startDate.format("hh:mm A");
48
- const endText = endDate.format("hh:mm A");
49
- const isCrossDay = (0, import_dayjs.default)(endDate).isAfter(startDate, "day");
50
- if (!((_a = resource._extend) == null ? void 0 : _a.usableTime)) {
44
+ const {
45
+ startDate,
46
+ endDate
47
+ } = (0, _serviceTimes.getServiceTimes)(cacheItem);
48
+ const startText = startDate.format('hh:mm A');
49
+ const endText = endDate.format('hh:mm A');
50
+ const isCrossDay = (0, _dayjs.default)(endDate).isAfter(startDate, 'day');
51
+ if (!resource._extend?.usableTime) {
51
52
  list.push({
52
- reason: "time_out_of_range",
53
+ reason: 'time_out_of_range',
53
54
  params: {
54
55
  labelText: resource.labelText,
55
56
  startText,
@@ -57,9 +58,9 @@ function getResourceErrors(resource, cacheItem) {
57
58
  isCrossDay
58
59
  }
59
60
  });
60
- } else if (!((_d = (_c = (_b = resource._extend) == null ? void 0 : _b.usableTime) == null ? void 0 : _c._extend) == null ? void 0 : _d.isCountRange)) {
61
+ } else if (!resource._extend?.usableTime?._extend?.isCountRange) {
61
62
  list.push({
62
- reason: "count_out_of_range",
63
+ reason: 'count_out_of_range',
63
64
  params: {
64
65
  labelText: resource.labelText,
65
66
  startText,
@@ -70,11 +71,10 @@ function getResourceErrors(resource, cacheItem) {
70
71
  }
71
72
  }
72
73
  if (resource.unbound) {
73
- list.push({ reason: "resource_unbound", params: {} });
74
+ list.push({
75
+ reason: 'resource_unbound',
76
+ params: {}
77
+ });
74
78
  }
75
79
  return list;
76
- }
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- getResourceErrors
80
- });
80
+ }