@pisell/pisellos 2.2.243 → 2.2.244

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 (315) hide show
  1. package/dist/model/strategy/adapter/promotion/evaluator.js +2 -3
  2. package/dist/model/strategy/adapter/promotion/index.js +9 -0
  3. package/dist/model/strategy/adapter/walletPass/utils.js +4 -7
  4. package/dist/modules/Cart/utils/cartProduct.js +3 -24
  5. package/dist/modules/Cart/utils/changePrice.js +11 -11
  6. package/dist/modules/Customer/index.d.ts +0 -20
  7. package/dist/modules/Customer/index.js +83 -172
  8. package/dist/modules/Customer/types.d.ts +0 -2
  9. package/dist/modules/Discount/index.js +3 -4
  10. package/dist/modules/Discount/types.d.ts +0 -1
  11. package/dist/modules/OpenData/index.d.ts +0 -8
  12. package/dist/modules/OpenData/index.js +17 -37
  13. package/dist/modules/Order/index.d.ts +18 -268
  14. package/dist/modules/Order/index.js +757 -3306
  15. package/dist/modules/Order/types.d.ts +31 -279
  16. package/dist/modules/Order/types.js +0 -38
  17. package/dist/modules/Order/utils.d.ts +5 -147
  18. package/dist/modules/Order/utils.js +103 -746
  19. package/dist/modules/Payment/index.d.ts +13 -10
  20. package/dist/modules/Payment/index.js +837 -467
  21. package/dist/modules/Payment/types.d.ts +0 -2
  22. package/dist/modules/Payment/utils.js +1 -2
  23. package/dist/modules/Payment/walletpass.js +7 -14
  24. package/dist/modules/ProductList/index.d.ts +12 -16
  25. package/dist/modules/ProductList/index.js +59 -133
  26. package/dist/modules/ProductList/types.d.ts +0 -14
  27. package/dist/modules/Quotation/index.d.ts +1 -0
  28. package/dist/modules/Quotation/index.js +22 -25
  29. package/dist/modules/Rules/index.d.ts +0 -4
  30. package/dist/modules/Rules/index.js +69 -93
  31. package/dist/modules/Rules/types.d.ts +0 -1
  32. package/dist/modules/SalesSummary/index.d.ts +25 -8
  33. package/dist/modules/SalesSummary/index.js +35 -86
  34. package/dist/modules/SalesSummary/types.d.ts +1 -4
  35. package/dist/modules/SalesSummary/utils.d.ts +25 -2
  36. package/dist/modules/SalesSummary/utils.js +162 -794
  37. package/dist/modules/Schedule/index.d.ts +0 -7
  38. package/dist/modules/Schedule/index.js +2 -24
  39. package/dist/modules/Summary/index.js +3 -4
  40. package/dist/modules/index.d.ts +0 -2
  41. package/dist/modules/index.js +1 -3
  42. package/dist/plugins/request.d.ts +0 -1
  43. package/dist/server/index.d.ts +1 -204
  44. package/dist/server/index.js +928 -3658
  45. package/dist/server/modules/index.d.ts +0 -2
  46. package/dist/server/modules/index.js +0 -2
  47. package/dist/server/modules/order/index.d.ts +4 -120
  48. package/dist/server/modules/order/index.js +483 -1779
  49. package/dist/server/modules/order/types.d.ts +3 -32
  50. package/dist/server/modules/order/types.js +0 -8
  51. package/dist/server/modules/order/utils/filterBookings.js +3 -26
  52. package/dist/server/modules/order/utils/filterOrders.js +8 -23
  53. package/dist/server/modules/products/index.d.ts +7 -34
  54. package/dist/server/modules/products/index.js +317 -631
  55. package/dist/server/modules/resource/index.d.ts +0 -2
  56. package/dist/server/modules/resource/index.js +3 -29
  57. package/dist/server/modules/schedule/index.d.ts +4 -4
  58. package/dist/server/modules/schedule/index.js +88 -111
  59. package/dist/solution/BaseSales/index.d.ts +9 -131
  60. package/dist/solution/BaseSales/index.js +447 -1944
  61. package/dist/solution/BaseSales/types.d.ts +6 -76
  62. package/dist/solution/BaseSales/types.js +4 -5
  63. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  64. package/dist/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +24 -105
  65. package/dist/solution/BaseSales/utils.d.ts +1 -1
  66. package/dist/solution/BaseSales/utils.js +21 -62
  67. package/dist/solution/BookingByStep/index.d.ts +1 -1
  68. package/dist/solution/BookingTicket/index.d.ts +10 -270
  69. package/dist/solution/BookingTicket/index.js +237 -1772
  70. package/dist/solution/BookingTicket/types.d.ts +1 -118
  71. package/dist/solution/BookingTicket/types.js +2 -41
  72. package/dist/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  73. package/dist/solution/BookingTicket/utils/bookingStatus.js +0 -70
  74. package/dist/solution/BookingTicket/utils/cartView.d.ts +1 -9
  75. package/dist/solution/BookingTicket/utils/cartView.js +7 -94
  76. package/dist/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  77. package/dist/solution/BookingTicket/utils/scan/index.js +8 -20
  78. package/dist/solution/Checkout/appointmentDemo.json +1 -0
  79. package/dist/solution/Checkout/index.d.ts +0 -1
  80. package/dist/solution/Checkout/index.js +9 -10
  81. package/dist/solution/RegisterAndLogin/config.js +10 -2
  82. package/dist/solution/ScanOrder/index.d.ts +3 -9
  83. package/dist/solution/ScanOrder/index.js +134 -241
  84. package/dist/solution/ScanOrder/types.d.ts +5 -9
  85. package/dist/solution/ScanOrder/types.js +3 -2
  86. package/dist/solution/ScanOrder/utils.d.ts +1 -1
  87. package/dist/solution/ScanOrder/utils.js +22 -84
  88. package/dist/solution/VenueBooking/index.d.ts +2 -5
  89. package/dist/solution/VenueBooking/index.js +59 -110
  90. package/dist/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  91. package/dist/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  92. package/dist/solution/VenueBooking/utils/slotMerge.js +0 -10
  93. package/dist/types/index.d.ts +0 -10
  94. package/lib/model/strategy/adapter/promotion/evaluator.js +1 -2
  95. package/lib/model/strategy/adapter/promotion/index.js +0 -49
  96. package/lib/model/strategy/adapter/walletPass/utils.js +2 -3
  97. package/lib/modules/Cart/utils/cartProduct.js +3 -20
  98. package/lib/modules/Cart/utils/changePrice.js +20 -12
  99. package/lib/modules/Customer/index.d.ts +0 -20
  100. package/lib/modules/Customer/index.js +11 -64
  101. package/lib/modules/Customer/types.d.ts +0 -2
  102. package/lib/modules/Discount/index.js +1 -5
  103. package/lib/modules/Discount/types.d.ts +0 -1
  104. package/lib/modules/OpenData/index.d.ts +0 -8
  105. package/lib/modules/OpenData/index.js +5 -19
  106. package/lib/modules/Order/index.d.ts +18 -268
  107. package/lib/modules/Order/index.js +344 -2149
  108. package/lib/modules/Order/types.d.ts +31 -279
  109. package/lib/modules/Order/types.js +0 -1
  110. package/lib/modules/Order/utils.d.ts +5 -147
  111. package/lib/modules/Order/utils.js +46 -614
  112. package/lib/modules/Payment/index.d.ts +13 -10
  113. package/lib/modules/Payment/index.js +150 -18
  114. package/lib/modules/Payment/types.d.ts +0 -2
  115. package/lib/modules/Payment/utils.js +1 -2
  116. package/lib/modules/Payment/walletpass.js +3 -7
  117. package/lib/modules/ProductList/index.d.ts +12 -16
  118. package/lib/modules/ProductList/index.js +4 -41
  119. package/lib/modules/ProductList/types.d.ts +0 -14
  120. package/lib/modules/Quotation/index.d.ts +1 -0
  121. package/lib/modules/Quotation/index.js +16 -19
  122. package/lib/modules/Rules/index.d.ts +0 -4
  123. package/lib/modules/Rules/index.js +120 -136
  124. package/lib/modules/Rules/types.d.ts +0 -1
  125. package/lib/modules/SalesSummary/index.d.ts +25 -8
  126. package/lib/modules/SalesSummary/index.js +4 -30
  127. package/lib/modules/SalesSummary/types.d.ts +1 -4
  128. package/lib/modules/SalesSummary/utils.d.ts +25 -2
  129. package/lib/modules/SalesSummary/utils.js +91 -645
  130. package/lib/modules/Schedule/index.d.ts +0 -7
  131. package/lib/modules/Schedule/index.js +1 -17
  132. package/lib/modules/Summary/index.js +4 -5
  133. package/lib/modules/index.d.ts +0 -2
  134. package/lib/modules/index.js +1 -5
  135. package/lib/plugins/request.d.ts +0 -1
  136. package/lib/server/index.d.ts +1 -204
  137. package/lib/server/index.js +57 -1888
  138. package/lib/server/modules/index.d.ts +0 -2
  139. package/lib/server/modules/index.js +0 -3
  140. package/lib/server/modules/order/index.d.ts +4 -120
  141. package/lib/server/modules/order/index.js +142 -919
  142. package/lib/server/modules/order/types.d.ts +3 -32
  143. package/lib/server/modules/order/utils/filterBookings.js +5 -24
  144. package/lib/server/modules/order/utils/filterOrders.js +6 -15
  145. package/lib/server/modules/products/index.d.ts +7 -34
  146. package/lib/server/modules/products/index.js +54 -189
  147. package/lib/server/modules/resource/index.d.ts +0 -2
  148. package/lib/server/modules/resource/index.js +3 -27
  149. package/lib/server/modules/schedule/index.d.ts +4 -4
  150. package/lib/server/modules/schedule/index.js +40 -47
  151. package/lib/solution/BaseSales/index.d.ts +9 -131
  152. package/lib/solution/BaseSales/index.js +63 -1106
  153. package/lib/solution/BaseSales/types.d.ts +6 -76
  154. package/lib/solution/BaseSales/types.js +1 -3
  155. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.d.ts +0 -1
  156. package/lib/solution/BaseSales/utils/transformBaseProductToOrderProduct.js +18 -106
  157. package/lib/solution/BaseSales/utils.d.ts +1 -1
  158. package/lib/solution/BaseSales/utils.js +10 -54
  159. package/lib/solution/BookingByStep/index.d.ts +1 -1
  160. package/lib/solution/BookingTicket/index.d.ts +10 -270
  161. package/lib/solution/BookingTicket/index.js +29 -922
  162. package/lib/solution/BookingTicket/types.d.ts +1 -118
  163. package/lib/solution/BookingTicket/types.js +0 -11
  164. package/lib/solution/BookingTicket/utils/bookingStatus.d.ts +0 -40
  165. package/lib/solution/BookingTicket/utils/bookingStatus.js +2 -44
  166. package/lib/solution/BookingTicket/utils/cartView.d.ts +1 -9
  167. package/lib/solution/BookingTicket/utils/cartView.js +6 -61
  168. package/lib/solution/BookingTicket/utils/scan/index.d.ts +0 -5
  169. package/lib/solution/BookingTicket/utils/scan/index.js +3 -17
  170. package/lib/solution/Checkout/appointmentDemo.json +1 -0
  171. package/lib/solution/Checkout/index.d.ts +0 -1
  172. package/lib/solution/Checkout/index.js +2 -1
  173. package/lib/solution/RegisterAndLogin/config.js +10 -2
  174. package/lib/solution/ScanOrder/index.d.ts +3 -9
  175. package/lib/solution/ScanOrder/index.js +70 -153
  176. package/lib/solution/ScanOrder/types.d.ts +5 -9
  177. package/lib/solution/ScanOrder/utils.d.ts +1 -1
  178. package/lib/solution/ScanOrder/utils.js +17 -83
  179. package/lib/solution/VenueBooking/index.d.ts +2 -5
  180. package/lib/solution/VenueBooking/index.js +17 -54
  181. package/lib/solution/VenueBooking/sales-section-4-annotated.json +2 -0
  182. package/lib/solution/VenueBooking/utils/slotMerge.d.ts +0 -4
  183. package/lib/solution/VenueBooking/utils/slotMerge.js +0 -10
  184. package/lib/types/index.d.ts +0 -10
  185. package/package.json +1 -1
  186. package/dist/modules/BookingContext/index.d.ts +0 -48
  187. package/dist/modules/BookingContext/index.js +0 -566
  188. package/dist/modules/BookingContext/types.d.ts +0 -102
  189. package/dist/modules/BookingContext/types.js +0 -51
  190. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  191. package/dist/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -284
  192. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  193. package/dist/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -145
  194. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  195. package/dist/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -218
  196. package/dist/modules/BookingContext/utils/flexible.d.ts +0 -28
  197. package/dist/modules/BookingContext/utils/flexible.js +0 -56
  198. package/dist/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  199. package/dist/modules/BookingContext/utils/formatResourceList.js +0 -38
  200. package/dist/modules/BookingContext/utils/index.d.ts +0 -11
  201. package/dist/modules/BookingContext/utils/index.js +0 -11
  202. package/dist/modules/BookingContext/utils/noResource.d.ts +0 -13
  203. package/dist/modules/BookingContext/utils/noResource.js +0 -77
  204. package/dist/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  205. package/dist/modules/BookingContext/utils/orderLineDisplay.js +0 -36
  206. package/dist/modules/BookingContext/utils/productExtend.d.ts +0 -72
  207. package/dist/modules/BookingContext/utils/productExtend.js +0 -339
  208. package/dist/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  209. package/dist/modules/BookingContext/utils/resourceErrors.js +0 -74
  210. package/dist/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  211. package/dist/modules/BookingContext/utils/resourceSelection.js +0 -24
  212. package/dist/modules/BookingContext/utils/resources.d.ts +0 -80
  213. package/dist/modules/BookingContext/utils/resources.js +0 -486
  214. package/dist/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  215. package/dist/modules/BookingContext/utils/serviceTimes.js +0 -151
  216. package/dist/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  217. package/dist/modules/BookingContext/utils/timeSlices.js +0 -100
  218. package/dist/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  219. package/dist/modules/Order/utils/manualProductDiscount.js +0 -210
  220. package/dist/modules/SurchargeList/index.d.ts +0 -16
  221. package/dist/modules/SurchargeList/index.js +0 -162
  222. package/dist/modules/SurchargeList/types.d.ts +0 -11
  223. package/dist/modules/SurchargeList/types.js +0 -1
  224. package/dist/server/modules/payment/index.d.ts +0 -28
  225. package/dist/server/modules/payment/index.js +0 -305
  226. package/dist/server/modules/payment/types.d.ts +0 -9
  227. package/dist/server/modules/payment/types.js +0 -1
  228. package/dist/server/test.json +0 -713
  229. package/dist/server/utils/small-ticket.d.ts +0 -71
  230. package/dist/server/utils/small-ticket.js +0 -830
  231. package/dist/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  232. package/dist/solution/BaseSales/utils/cartPromotion.js +0 -1438
  233. package/dist/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  234. package/dist/solution/BaseSales/utils/quotationPrice.js +0 -237
  235. package/dist/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  236. package/dist/solution/BookingTicket/utils/addProductDecision.js +0 -346
  237. package/dist/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  238. package/dist/solution/BookingTicket/utils/addTimeAvailability.js +0 -95
  239. package/dist/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  240. package/dist/solution/BookingTicket/utils/exampleData.js +0 -183
  241. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  242. package/dist/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -438
  243. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  244. package/dist/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -399
  245. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  246. package/dist/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -56
  247. package/dist/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  248. package/dist/solution/BookingTicket/utils/scan/scanProductValues.js +0 -150
  249. package/dist/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  250. package/dist/solution/BookingTicket/utils/sessionCatalogStale.js +0 -78
  251. package/lib/modules/BookingContext/index.d.ts +0 -48
  252. package/lib/modules/BookingContext/index.js +0 -368
  253. package/lib/modules/BookingContext/types.d.ts +0 -102
  254. package/lib/modules/BookingContext/types.js +0 -34
  255. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.d.ts +0 -16
  256. package/lib/modules/BookingContext/utils/buildCacheItemFromOrderLine.js +0 -276
  257. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.d.ts +0 -8
  258. package/lib/modules/BookingContext/utils/buildNormalProductCacheItemFromOrderLine.js +0 -151
  259. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.d.ts +0 -76
  260. package/lib/modules/BookingContext/utils/cacheItemToBookingInput.js +0 -201
  261. package/lib/modules/BookingContext/utils/flexible.d.ts +0 -28
  262. package/lib/modules/BookingContext/utils/flexible.js +0 -80
  263. package/lib/modules/BookingContext/utils/formatResourceList.d.ts +0 -8
  264. package/lib/modules/BookingContext/utils/formatResourceList.js +0 -50
  265. package/lib/modules/BookingContext/utils/index.d.ts +0 -11
  266. package/lib/modules/BookingContext/utils/index.js +0 -43
  267. package/lib/modules/BookingContext/utils/noResource.d.ts +0 -13
  268. package/lib/modules/BookingContext/utils/noResource.js +0 -90
  269. package/lib/modules/BookingContext/utils/orderLineDisplay.d.ts +0 -1
  270. package/lib/modules/BookingContext/utils/orderLineDisplay.js +0 -56
  271. package/lib/modules/BookingContext/utils/productExtend.d.ts +0 -72
  272. package/lib/modules/BookingContext/utils/productExtend.js +0 -283
  273. package/lib/modules/BookingContext/utils/resourceErrors.d.ts +0 -41
  274. package/lib/modules/BookingContext/utils/resourceErrors.js +0 -80
  275. package/lib/modules/BookingContext/utils/resourceSelection.d.ts +0 -7
  276. package/lib/modules/BookingContext/utils/resourceSelection.js +0 -46
  277. package/lib/modules/BookingContext/utils/resources.d.ts +0 -80
  278. package/lib/modules/BookingContext/utils/resources.js +0 -377
  279. package/lib/modules/BookingContext/utils/serviceTimes.d.ts +0 -55
  280. package/lib/modules/BookingContext/utils/serviceTimes.js +0 -162
  281. package/lib/modules/BookingContext/utils/timeSlices.d.ts +0 -42
  282. package/lib/modules/BookingContext/utils/timeSlices.js +0 -124
  283. package/lib/modules/Order/utils/manualProductDiscount.d.ts +0 -106
  284. package/lib/modules/Order/utils/manualProductDiscount.js +0 -206
  285. package/lib/modules/SurchargeList/index.d.ts +0 -16
  286. package/lib/modules/SurchargeList/index.js +0 -89
  287. package/lib/modules/SurchargeList/types.d.ts +0 -11
  288. package/lib/modules/SurchargeList/types.js +0 -17
  289. package/lib/server/modules/payment/index.d.ts +0 -28
  290. package/lib/server/modules/payment/index.js +0 -192
  291. package/lib/server/modules/payment/types.d.ts +0 -9
  292. package/lib/server/modules/payment/types.js +0 -17
  293. package/lib/server/test.json +0 -713
  294. package/lib/server/utils/small-ticket.d.ts +0 -71
  295. package/lib/server/utils/small-ticket.js +0 -781
  296. package/lib/solution/BaseSales/utils/cartPromotion.d.ts +0 -287
  297. package/lib/solution/BaseSales/utils/cartPromotion.js +0 -992
  298. package/lib/solution/BaseSales/utils/quotationPrice.d.ts +0 -7
  299. package/lib/solution/BaseSales/utils/quotationPrice.js +0 -277
  300. package/lib/solution/BookingTicket/utils/addProductDecision.d.ts +0 -117
  301. package/lib/solution/BookingTicket/utils/addProductDecision.js +0 -318
  302. package/lib/solution/BookingTicket/utils/addTimeAvailability.d.ts +0 -35
  303. package/lib/solution/BookingTicket/utils/addTimeAvailability.js +0 -125
  304. package/lib/solution/BookingTicket/utils/exampleData.d.ts +0 -123
  305. package/lib/solution/BookingTicket/utils/exampleData.js +0 -0
  306. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.d.ts +0 -185
  307. package/lib/solution/BookingTicket/utils/resolveBestAddTimePlan.js +0 -254
  308. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.d.ts +0 -36
  309. package/lib/solution/BookingTicket/utils/scan/applyGlobalScan.js +0 -168
  310. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.d.ts +0 -32
  311. package/lib/solution/BookingTicket/utils/scan/formatGlobalScan.js +0 -51
  312. package/lib/solution/BookingTicket/utils/scan/scanProductValues.d.ts +0 -21
  313. package/lib/solution/BookingTicket/utils/scan/scanProductValues.js +0 -127
  314. package/lib/solution/BookingTicket/utils/sessionCatalogStale.d.ts +0 -23
  315. package/lib/solution/BookingTicket/utils/sessionCatalogStale.js +0 -85
@@ -1,377 +0,0 @@
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);
28
-
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
41
- });
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");
48
- function getUsableTime(cacheItem) {
49
- var _a, _b, _c;
50
- 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) || {};
53
- let items = [];
54
- for (const formId of Object.keys(resourceByForm)) {
55
- 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
- );
62
- }
63
- if (!items.length)
64
- return null;
65
- 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);
69
- return endAt.isBefore(preEnd) ? event : pre;
70
- }, items[0]);
71
- } catch {
72
- return null;
73
- }
74
- }
75
- function getSumCapacity(cacheItem, isCalcQuantity = true) {
76
- var _a, _b;
77
- const list = ((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.capacity) || [];
78
- let sum = 0;
79
- for (const item of list) {
80
- sum += Number((item == null ? void 0 : item.value) || 0);
81
- }
82
- return sum * (isCalcQuantity ? ((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.quantity) || 1 : 1);
83
- }
84
- function getUseableEventCount(eventList, current) {
85
- return (eventList || []).reduce((pre, event) => pre - ((event == null ? void 0 : event.pax) || 0), current || 0);
86
- }
87
- 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);
91
- const isBefore = currentStart.isBefore(eventEnd);
92
- let isAfter = true;
93
- if (current.end_at) {
94
- const currentEnd = (0, import_dayjs.default)(current.end_at);
95
- isAfter = currentEnd.isAfter(eventStart);
96
- }
97
- return isBefore && isAfter;
98
- }
99
- 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);
104
- let isMaxLimitRange = false;
105
- let isDateRange = false;
106
- 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");
110
- const totalCount = getUseableEventCount(time.event_list, resourceItem.capacity);
111
- const currentCount = getSumCapacity(cacheItem);
112
- let eventList = time.event_list || [];
113
- if (cacheItem == null ? void 0 : cacheItem.booking_id) {
114
- eventList = eventList.filter((event) => event.id !== cacheItem.booking_id);
115
- }
116
- let endDate = null;
117
- let isCalcCount = true;
118
- if (isFlexible) {
119
- isDateRange = startDate.isAfter(timeStartDate) && startDate.isBefore(timeEndDate);
120
- if (!isDateRange && eventList.length) {
121
- isCalcCount = false;
122
- isDateRange = true;
123
- isCountRange = false;
124
- }
125
- } else {
126
- endDate = startDate.add(import_flexible.flexibleObj.getValue(cacheItem._extend.duration), "minute");
127
- const isTimeRange = startDate.isAfter(timeStartDate) && endDate.isBefore(timeEndDate);
128
- if (isTimeRange)
129
- isDateRange = true;
130
- }
131
- 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") {
136
- isCountRange = conflict.length === 0;
137
- } else {
138
- const conflictCount = getUseableEventCount(conflict, resourceItem.capacity);
139
- isCountRange = currentCount <= conflictCount;
140
- }
141
- }
142
- const isUsable = isDateRange && isCountRange;
143
- time._extend = {
144
- isMaxLimitRange,
145
- isDateRange,
146
- isCountRange,
147
- isUsable
148
- };
149
- return time;
150
- }
151
- function formatTimes(resourceItem, cacheItem) {
152
- const usableTimes = [];
153
- const _resourceItem = { ...resourceItem };
154
- const sum = getSumCapacity(cacheItem);
155
- 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;
162
- });
163
- }
164
- 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();
167
- return aEnd - bEnd;
168
- })[0];
169
- resourceItem._extend = {
170
- ...resourceItem._extend,
171
- usableTime: _time
172
- };
173
- return resourceItem;
174
- }
175
- function formatResource(resourceItem, cacheItem) {
176
- var _a, _b, _c;
177
- let _resourceItem = { ...resourceItem };
178
- _resourceItem = formatTimes(_resourceItem, cacheItem);
179
- _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;
181
- _resourceItem.usable = usable;
182
- return _resourceItem;
183
- }
184
- function formatResources(params) {
185
- const { cacheItem, resourcesOrigin } = params;
186
- try {
187
- const maps = {};
188
- const list = resourcesOrigin.map((item) => {
189
- const _item = (0, import_lodash_es.cloneDeep)(item);
190
- const renderListMaps = {};
191
- _item.renderList = _item.renderList.map((d) => {
192
- const res = formatResource(d, cacheItem);
193
- const unbound = !item.optional_resource.includes(res.id) && !item.default_resource.includes(res.id) && res.id !== 0;
194
- if (unbound)
195
- res.unbound = true;
196
- renderListMaps[res.id] = res;
197
- return res;
198
- }).sort((a, b) => b.usable ? 1 : -1);
199
- maps[_item.form_id] = { ..._item, renderListMaps };
200
- return _item;
201
- });
202
- return { list, maps };
203
- } catch (err) {
204
- console.warn("[BookingContext] formatResources error", err);
205
- return { list: [], maps: {} };
206
- }
207
- }
208
- 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);
213
- let defaultResource = [];
214
- let maxFreeTime = 0;
215
- usableList.forEach((d) => {
216
- const { times = [] } = d;
217
- 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;
220
- const end = cur.end_at;
221
- const diff = (0, import_dayjs.default)(end).diff((0, import_dayjs.default)(start), "minute");
222
- return diff > pre ? diff : pre;
223
- }, 0);
224
- if (currentMaxFreeTime > maxFreeTime) {
225
- maxFreeTime = currentMaxFreeTime;
226
- defaultResource = [d];
227
- }
228
- });
229
- return defaultResource;
230
- }
231
- function setDefaultResource(params) {
232
- const { cacheItem, resources, resourceIdFromCalendar, isAutoAllocationOn = () => true } = params;
233
- const obj = {};
234
- const resourceId = Number(resourceIdFromCalendar) || 0;
235
- for (const item of resources) {
236
- const {
237
- select_type = {},
238
- optional_resource = [],
239
- default_resource = []
240
- } = item;
241
- const renderList = item.renderList.filter((d) => {
242
- if ((select_type == null ? void 0 : select_type.type) === "single") {
243
- if (resourceId && (optional_resource.includes(resourceId) || default_resource.includes(resourceId))) {
244
- return d.id === resourceId;
245
- }
246
- return d.is_default === 1;
247
- }
248
- return d.is_default === 1 || d.id === resourceId;
249
- });
250
- let defaultOriginalResource = [];
251
- if (renderList.length === 0) {
252
- defaultOriginalResource = getResourceMaxFreeTime(item, isAutoAllocationOn);
253
- } else {
254
- defaultOriginalResource = renderList;
255
- }
256
- obj[item.form_id] = defaultOriginalResource.map((d) => ({
257
- children: d.children,
258
- relation_type: d.relation_type,
259
- form_id: item.form_id,
260
- relation_id: d.id,
261
- like_status: "common",
262
- metadata: {
263
- form_name: item.title,
264
- resource_name: d.main_field
265
- }
266
- }));
267
- }
268
- return obj;
269
- }
270
- 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) => {
275
- const id = d._bundle_product_id;
276
- const item = ((capacitys == null ? void 0 : capacitys.package) || []).find((p) => p.product_id === id);
277
- return {
278
- id,
279
- value: item ? d.quantity || 0 : 0,
280
- name: (item == null ? void 0 : item.name) || (d == null ? void 0 : d.title)
281
- };
282
- });
283
- }
284
- if ((capacitys == null ? void 0 : capacitys.type) === "custom") {
285
- return ((capacitys == null ? void 0 : capacitys.custom) || []).map((d) => ({
286
- id: d.id,
287
- value: d.min,
288
- name: d.name
289
- }));
290
- }
291
- return [{ id: 0, value: 1, name: "" }];
292
- }
293
- 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 }));
296
- const {
297
- extraResources = [],
298
- resourcesOrigin = [],
299
- resourceTab = {}
300
- } = extraParams || {};
301
- for (const item of _resources) {
302
- const form_id = item.id;
303
- const isAllResource = ((_b = resourceTab == null ? void 0 : resourceTab[item.code]) == null ? void 0 : _b.resource_display_scope) === "all";
304
- let extraResourceIds = [];
305
- if (isAllResource) {
306
- extraResourceIds = (resourcesOrigin || []).filter((d) => d.form_code === item.code).map((d) => d.id);
307
- } 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);
311
- }
312
- 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) => {
317
- const combiningResources = [];
318
- 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;
322
- if (resourcesOriginMap[cid]) {
323
- combiningResources.push({
324
- ...resourcesOriginMap[cid],
325
- relation_id: ((_a2 = resourcesOriginMap[cid]) == null ? void 0 : _a2.relation_id) || ((_b2 = resourcesOriginMap[cid]) == null ? void 0 : _b2.id)
326
- });
327
- }
328
- });
329
- }
330
- return {
331
- children: combiningResources,
332
- metadata: {
333
- ...(origin == null ? void 0 : origin.metadata) || {},
334
- combined_resource: origin == null ? void 0 : origin.combined_resource
335
- }
336
- };
337
- };
338
- const optional_resource = Array.from(
339
- /* @__PURE__ */ new Set([...item.optional_resource, ...extraResourceIds])
340
- ).map((d) => {
341
- if (!resourcesOriginMap[d])
342
- return null;
343
- return Object.assign({}, resourcesOriginMap[d], {
344
- form_id,
345
- resourceType: item.type,
346
- ...getChildrenMetadata(d)
347
- });
348
- }).filter((d) => d).concat((0, import_noResource.getNoResource2)({ form_id }));
349
- const default_resource = (item.default_resource || []).map((d) => {
350
- const origin = resourcesOriginMap[d];
351
- if (origin) {
352
- origin.is_default = 1;
353
- return Object.assign({}, origin, {
354
- form_id,
355
- resourceType: item.type,
356
- ...getChildrenMetadata(d)
357
- });
358
- }
359
- return null;
360
- }).filter((d) => d);
361
- item.renderList = optional_resource.concat(default_resource);
362
- item.form_id = form_id;
363
- }
364
- 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
- });
@@ -1,55 +0,0 @@
1
- import { Dayjs } from 'dayjs';
2
- import { getDurationValue } from './flexible';
3
- /**
4
- * 判断商品是否为跨日预约(duration.type === 'days')。与 info2 isMultiDayProduct 等价。
5
- */
6
- export declare function isMultiDayProduct(product: any): boolean;
7
- /**
8
- * 判断 cacheItem 是否为 session 商品(extension_type ∈ session_product / session_ticket)。
9
- */
10
- export declare function isSessionProduct(cacheItem: any): boolean;
11
- /** 从 catalog `cartDetailValue` 或 `_extend.other` 取 session 快照。 */
12
- export declare function getSessionFromItem(item: any): Record<string, any> | null;
13
- /**
14
- * 将 cartDetailValue.session 写入 _extend 的起止时间(与 info2 getServiceStartTimeAndEndTime 的 session 分支一致)。
15
- * 日历日优先用 ctx.date,时分取自 session.start_at / end_at 或 session.start_time / end_time。
16
- */
17
- export declare function applySessionTimesToExtend(item: any, extend: Record<string, any>, ctx?: {
18
- date?: string | Dayjs | null;
19
- }): Record<string, any>;
20
- /**
21
- * 是否应写入 booking(与 Product.utils isNormalProduct 对齐,并覆盖 session_ticket / cartDetailValue.session)。
22
- */
23
- export declare function isBookingProduct(item: any): boolean;
24
- /**
25
- * 处理 'now' 时间占位:'now' → 当前 HH:mm;其他原样返回。
26
- * 与 info2 `getServeStartTime` 等价。
27
- */
28
- export declare function getServeStartTime(startTime: string | undefined | null): string;
29
- /**
30
- * 计算商品的开始结束时间(统一为 dayjs 实例)。
31
- * 与 info2 `getServiceTimes` 行为等价:
32
- * - 跨日商品:startDate = start_date + start_time,endDate = _extend.end_date 原样
33
- * - session 商品:从 _extend.other.session 取 start_at / end_at
34
- * - 普通商品:startDate + duration(含 flexible 处理)
35
- */
36
- export declare function getServiceTimes(service: any): {
37
- startDate: Dayjs;
38
- endDate: Dayjs;
39
- };
40
- /**
41
- * 跨日预约相关:把 _extend.start_date / end_date 都对齐到 dayjs startOf('day')。
42
- * 与 info2 `formatDayDate` 等价。
43
- */
44
- export declare function formatDayDate(_extend: any): {
45
- start_date: Dayjs;
46
- end_date: Dayjs;
47
- };
48
- /**
49
- * 计算跨日预约时长:
50
- * - type='days' → end - start 的天数
51
- * - type='minutes' → end - start 的分钟数
52
- * 与 info2 `getDays` 等价。
53
- */
54
- export declare function getDays(cacheItem: any, type: 'minutes' | 'days'): number;
55
- export { getDurationValue };
@@ -1,162 +0,0 @@
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);
28
-
29
- // src/modules/BookingContext/utils/serviceTimes.ts
30
- var serviceTimes_exports = {};
31
- __export(serviceTimes_exports, {
32
- applySessionTimesToExtend: () => applySessionTimesToExtend,
33
- formatDayDate: () => formatDayDate,
34
- getDays: () => getDays,
35
- getDurationValue: () => import_flexible.getDurationValue,
36
- getServeStartTime: () => getServeStartTime,
37
- getServiceTimes: () => getServiceTimes,
38
- getSessionFromItem: () => getSessionFromItem,
39
- isBookingProduct: () => isBookingProduct,
40
- isMultiDayProduct: () => isMultiDayProduct,
41
- isSessionProduct: () => isSessionProduct
42
- });
43
- module.exports = __toCommonJS(serviceTimes_exports);
44
- var import_dayjs = __toESM(require("dayjs"));
45
- var import_flexible = require("./flexible");
46
- function isMultiDayProduct(product) {
47
- var _a;
48
- return ((_a = product == null ? void 0 : product.duration) == null ? void 0 : _a.type) === "days";
49
- }
50
- function isSessionProduct(cacheItem) {
51
- return ["session_product", "session_ticket"].includes(cacheItem == null ? void 0 : cacheItem.extension_type);
52
- }
53
- function getSessionFromItem(item) {
54
- var _a, _b, _c;
55
- const session = ((_a = item == null ? void 0 : item.cartDetailValue) == null ? void 0 : _a.session) ?? ((_c = (_b = item == null ? void 0 : item._extend) == null ? void 0 : _b.other) == null ? void 0 : _c.session);
56
- return session && typeof session === "object" ? session : null;
57
- }
58
- function applySessionTimesToExtend(item, extend, ctx) {
59
- var _a;
60
- const session = ((_a = extend == null ? void 0 : extend.other) == null ? void 0 : _a.session) ?? getSessionFromItem(item);
61
- if (!session || !isSessionProduct(item)) {
62
- return extend;
63
- }
64
- const baseDate = (ctx == null ? void 0 : ctx.date) ? (0, import_dayjs.default)(ctx.date) : (0, import_dayjs.default)();
65
- const startAt = (0, import_dayjs.default)(
66
- `${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.start_at).format("HH:mm:ss")}`
67
- );
68
- const endAt = (0, import_dayjs.default)(
69
- `${baseDate.format("YYYY-MM-DD")} ${(0, import_dayjs.default)(session.end_at).format("HH:mm:ss")}`
70
- );
71
- const nextExtend = {
72
- ...extend,
73
- other: { ...extend.other || {}, session },
74
- start_date: startAt,
75
- startDate: startAt,
76
- start_time: session.start_time ?? (0, import_dayjs.default)(session.start_at).format("HH:mm"),
77
- end_date: endAt,
78
- endDate: endAt,
79
- end_time: session.end_time ?? (0, import_dayjs.default)(session.end_at).format("HH:mm")
80
- };
81
- return {
82
- ...nextExtend,
83
- duration: getDays({ _extend: nextExtend }, "minutes")
84
- };
85
- }
86
- function isBookingProduct(item) {
87
- var _a, _b;
88
- if (!item)
89
- return false;
90
- if (item.duration)
91
- return true;
92
- if ((_a = item == null ? void 0 : item.schedules) == null ? void 0 : _a.length)
93
- return true;
94
- if ((_b = item == null ? void 0 : item["schedule.ids"]) == null ? void 0 : _b.length)
95
- return true;
96
- if (isSessionProduct(item))
97
- return true;
98
- if (getSessionFromItem(item))
99
- return true;
100
- return false;
101
- }
102
- function getServeStartTime(startTime) {
103
- if (startTime === "now")
104
- return (0, import_dayjs.default)().format("HH:mm");
105
- return startTime || "";
106
- }
107
- function getServiceTimes(service) {
108
- var _a, _b, _c, _d, _e, _f, _g, _h;
109
- const startDate = (0, import_dayjs.default)(
110
- `${(0, import_dayjs.default)((_a = service == null ? void 0 : service._extend) == null ? void 0 : _a.start_date).format("YYYY-MM-DD")} ${getServeStartTime(
111
- (_b = service == null ? void 0 : service._extend) == null ? void 0 : _b.start_time
112
- )}`
113
- );
114
- if (isMultiDayProduct(service)) {
115
- const startTime = getServeStartTime((_c = service == null ? void 0 : service._extend) == null ? void 0 : _c.start_time);
116
- const endDateRaw = ((_d = service == null ? void 0 : service._extend) == null ? void 0 : _d.end_date) ?? ((_e = service == null ? void 0 : service._extend) == null ? void 0 : _e.endDate);
117
- const endBase = (0, import_dayjs.default)(endDateRaw);
118
- const endDate2 = endBase.isValid() ? (0, import_dayjs.default)(`${endBase.format("YYYY-MM-DD")} ${startTime}`) : endBase;
119
- return {
120
- startDate,
121
- endDate: endDate2
122
- };
123
- }
124
- const session = (_g = (_f = service == null ? void 0 : service._extend) == null ? void 0 : _f.other) == null ? void 0 : _g.session;
125
- if (isSessionProduct(service) && session) {
126
- return {
127
- startDate: (0, import_dayjs.default)(session.start_at),
128
- endDate: (0, import_dayjs.default)(session.end_at)
129
- };
130
- }
131
- const endDate = startDate.add(import_flexible.flexibleObj.getValue((_h = service == null ? void 0 : service._extend) == null ? void 0 : _h.duration), "minute");
132
- return { startDate, endDate };
133
- }
134
- function formatDayDate(_extend) {
135
- return {
136
- start_date: (0, import_dayjs.default)(_extend == null ? void 0 : _extend.start_date).startOf("day"),
137
- end_date: (0, import_dayjs.default)(_extend == null ? void 0 : _extend.end_date).startOf("day")
138
- };
139
- }
140
- function getDays(cacheItem, type) {
141
- var _a, _b;
142
- if (type === "days") {
143
- const { start_date, end_date } = formatDayDate(cacheItem._extend);
144
- return end_date.diff(start_date, "day");
145
- }
146
- const startDate = (0, import_dayjs.default)((_a = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _a.start_date);
147
- const endDate = (0, import_dayjs.default)((_b = cacheItem == null ? void 0 : cacheItem._extend) == null ? void 0 : _b.end_date);
148
- return endDate.diff(startDate, type);
149
- }
150
- // Annotate the CommonJS export names for ESM import in node:
151
- 0 && (module.exports = {
152
- applySessionTimesToExtend,
153
- formatDayDate,
154
- getDays,
155
- getDurationValue,
156
- getServeStartTime,
157
- getServiceTimes,
158
- getSessionFromItem,
159
- isBookingProduct,
160
- isMultiDayProduct,
161
- isSessionProduct
162
- });
@@ -1,42 +0,0 @@
1
- import dayjs from 'dayjs';
2
- import { getDurationValue } from './flexible';
3
- export interface TimeSlice {
4
- label: string;
5
- value: string;
6
- }
7
- export interface DurationSlice {
8
- label: string;
9
- value: number;
10
- }
11
- export interface TimeSlicesResult {
12
- timeSlices: TimeSlice[];
13
- durationSlicesBasedOnTime: DurationSlice[];
14
- }
15
- /**
16
- * 把一天切成等长时间槽,输出 timeSlices(开始时间标签)与 durationSlicesBasedOnTime(基于切片的时长选项)。
17
- *
18
- * 与 info2 `sliceDayIntoFiveMinutes` 行为等价;为了不依赖 `locales`,label 输出原始时间字符串('08:00 AM' / '90'),
19
- * UI 侧需要本地化展示时可基于 value 自行包装。
20
- *
21
- * @param config booking config `basic.service_time`,{ value: minutes }
22
- * @param isDay 是否跨日预约(true 时按 1~30 天切片)
23
- */
24
- export declare function sliceDayIntoFiveMinutes(config: {
25
- value?: number;
26
- } | undefined | null, isDay?: boolean): TimeSlicesResult;
27
- /**
28
- * 取「下一个 duration 选项」:优先用 defaultValue;否则在 array 中找匹配的;找不到取第一个。
29
- * 与 info2 `findNextDuration` 等价。
30
- */
31
- export declare function findNextDuration(current: {
32
- value?: number;
33
- } | undefined, array: DurationSlice[], defaultValue?: number): number | undefined;
34
- /** 取首选 time slice:若指定 date(HH:mm)则找第一个 >= date 的;否则第一个。 */
35
- export declare function findNextSlice(params: {
36
- timeSlices: TimeSlice[];
37
- index?: number;
38
- date?: string;
39
- }): string | undefined;
40
- /** 取 endDate;duration='flexible' 时取 endDate 与店铺营业时间的较小值,否则 startDate + duration 分钟。 */
41
- export declare function getEndDate(startDate: dayjs.Dayjs, duration: string | number, endDate: any, shopOpeningHours?: string): dayjs.Dayjs;
42
- export { getDurationValue };