@pisell/utils 3.0.6 → 3.0.7

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 (200) hide show
  1. package/es/arrayUtils.d.ts +23 -26
  2. package/es/arrayUtils.js +157 -97
  3. package/es/common/index.d.ts +5 -0
  4. package/es/common/index.js +5 -0
  5. package/es/common/stateHelper.d.ts +2 -6
  6. package/es/common/stateHelper.js +24 -22
  7. package/es/common/types.d.ts +10 -13
  8. package/es/common/types.js +1 -0
  9. package/es/componentStorage.d.ts +25 -27
  10. package/es/componentStorage.js +130 -94
  11. package/es/constants/index.js +9 -7
  12. package/es/date.js +53 -36
  13. package/es/document.js +67 -43
  14. package/es/escPosPrinter/EscPosPrinter.js +490 -353
  15. package/es/escPosPrinter/index.d.ts +9 -9
  16. package/es/escPosPrinter/index.js +52 -37
  17. package/es/firebase/config/index.js +54 -0
  18. package/es/firebase/index.js +232 -0
  19. package/es/format.d.ts +15 -12
  20. package/es/format.js +156 -89
  21. package/es/image.js +60 -48
  22. package/es/index.d.ts +24 -39
  23. package/es/index.js +35 -40
  24. package/es/jsBridge/index.d.ts +4 -8
  25. package/es/jsBridge/index.js +55 -56
  26. package/es/jsBridge/regDeviceApi.js +126 -87
  27. package/es/jsBridge/types.d.ts +115 -95
  28. package/es/jsBridge/types.js +1 -0
  29. package/es/locales.d.ts +8 -11
  30. package/es/locales.js +96 -77
  31. package/es/log.d.ts +6 -11
  32. package/es/log.js +59 -37
  33. package/es/miniRedux.d.ts +13 -20
  34. package/es/miniRedux.js +76 -42
  35. package/es/number-input/hooks/index.d.ts +4 -0
  36. package/es/number-input/hooks/index.js +5 -0
  37. package/es/number-input/hooks/useNumberInputState.d.ts +2 -6
  38. package/es/number-input/hooks/useNumberInputState.js +128 -71
  39. package/es/number-input/index.d.ts +14 -0
  40. package/es/number-input/index.js +21 -0
  41. package/es/number-input/types.d.ts +88 -88
  42. package/es/number-input/types.js +1 -0
  43. package/es/number-input/utils/formatter.d.ts +10 -13
  44. package/es/number-input/utils/formatter.js +77 -51
  45. package/es/number-input/utils/index.d.ts +7 -0
  46. package/es/number-input/utils/index.js +8 -0
  47. package/es/number-input/utils/validation.d.ts +2 -7
  48. package/es/number-input/utils/validation.js +66 -51
  49. package/es/otherUtils.d.ts +9 -12
  50. package/es/otherUtils.js +129 -71
  51. package/es/platform.d.ts +9 -12
  52. package/es/platform.js +85 -61
  53. package/es/select/hooks/index.d.ts +5 -0
  54. package/es/select/hooks/index.js +6 -0
  55. package/es/select/hooks/useDebouncedSearch.d.ts +1 -4
  56. package/es/select/hooks/useDebouncedSearch.js +53 -39
  57. package/es/select/hooks/useSelectState.d.ts +7 -7
  58. package/es/select/hooks/useSelectState.js +113 -56
  59. package/es/select/index.d.ts +8 -7
  60. package/es/select/index.js +13 -0
  61. package/es/select/types.d.ts +211 -211
  62. package/es/select/types.js +1 -0
  63. package/es/select/utils/filterOptions.d.ts +6 -7
  64. package/es/select/utils/filterOptions.js +31 -26
  65. package/es/select/utils/helpers.d.ts +9 -10
  66. package/es/select/utils/helpers.js +52 -42
  67. package/es/select/utils/index.d.ts +7 -4
  68. package/es/select/utils/index.js +8 -0
  69. package/es/select/utils/sortOptions.d.ts +5 -6
  70. package/es/select/utils/sortOptions.js +31 -19
  71. package/es/select/utils/tagAggregation.d.ts +6 -6
  72. package/es/select/utils/tagAggregation.js +47 -34
  73. package/es/text-input/hooks/index.d.ts +4 -0
  74. package/es/text-input/hooks/index.js +5 -0
  75. package/es/text-input/hooks/useTextInputState.d.ts +2 -6
  76. package/es/text-input/hooks/useTextInputState.js +126 -69
  77. package/es/text-input/index.d.ts +14 -0
  78. package/es/text-input/index.js +20 -0
  79. package/es/text-input/types.d.ts +48 -48
  80. package/es/text-input/types.js +1 -0
  81. package/es/text-input/utils/index.d.ts +5 -0
  82. package/es/text-input/utils/index.js +7 -0
  83. package/es/text-input/utils/validation.d.ts +2 -7
  84. package/es/text-input/utils/validation.js +70 -50
  85. package/es/typeUtils.js +84 -61
  86. package/es/walletValidity.d.ts +42 -44
  87. package/es/walletValidity.js +557 -396
  88. package/es/weighing.d.ts +45 -48
  89. package/es/weighing.js +106 -83
  90. package/lib/arrayUtils.d.ts +23 -26
  91. package/lib/arrayUtils.js +111 -101
  92. package/lib/common/index.d.ts +5 -0
  93. package/lib/common/index.js +29 -0
  94. package/lib/common/stateHelper.d.ts +2 -6
  95. package/lib/common/stateHelper.js +32 -21
  96. package/lib/common/types.d.ts +10 -13
  97. package/lib/common/types.js +17 -0
  98. package/lib/componentStorage.d.ts +25 -27
  99. package/lib/componentStorage.js +126 -96
  100. package/lib/constants/index.js +36 -7
  101. package/lib/date.js +65 -43
  102. package/lib/document.js +62 -46
  103. package/lib/escPosPrinter/EscPosPrinter.js +403 -327
  104. package/lib/escPosPrinter/index.d.ts +9 -9
  105. package/lib/escPosPrinter/index.js +84 -38
  106. package/lib/firebase/config/index.js +79 -0
  107. package/lib/firebase/index.js +180 -0
  108. package/lib/format.d.ts +15 -12
  109. package/lib/format.js +133 -91
  110. package/lib/image.js +74 -48
  111. package/lib/index.d.ts +24 -39
  112. package/lib/index.js +80 -137
  113. package/lib/jsBridge/index.d.ts +4 -8
  114. package/lib/jsBridge/index.js +76 -57
  115. package/lib/jsBridge/regDeviceApi.js +133 -86
  116. package/lib/jsBridge/types.d.ts +115 -95
  117. package/lib/jsBridge/types.js +17 -0
  118. package/lib/locales.d.ts +8 -11
  119. package/lib/locales.js +90 -79
  120. package/lib/log.d.ts +6 -11
  121. package/lib/log.js +61 -37
  122. package/lib/miniRedux.d.ts +13 -20
  123. package/lib/miniRedux.js +89 -43
  124. package/lib/number-input/hooks/index.d.ts +4 -0
  125. package/lib/number-input/hooks/index.js +29 -0
  126. package/lib/number-input/hooks/useNumberInputState.d.ts +2 -6
  127. package/lib/number-input/hooks/useNumberInputState.js +81 -71
  128. package/lib/number-input/index.d.ts +14 -0
  129. package/lib/number-input/index.js +41 -0
  130. package/lib/number-input/types.d.ts +88 -88
  131. package/lib/number-input/types.js +17 -0
  132. package/lib/number-input/utils/formatter.d.ts +10 -13
  133. package/lib/number-input/utils/formatter.js +49 -52
  134. package/lib/number-input/utils/index.d.ts +7 -0
  135. package/lib/number-input/utils/index.js +39 -0
  136. package/lib/number-input/utils/validation.d.ts +2 -7
  137. package/lib/number-input/utils/validation.js +52 -50
  138. package/lib/otherUtils.d.ts +9 -12
  139. package/lib/otherUtils.js +98 -86
  140. package/lib/platform.d.ts +9 -12
  141. package/lib/platform.js +123 -68
  142. package/lib/select/hooks/index.d.ts +5 -0
  143. package/lib/select/hooks/index.js +34 -0
  144. package/lib/select/hooks/useDebouncedSearch.d.ts +1 -4
  145. package/lib/select/hooks/useDebouncedSearch.js +41 -40
  146. package/lib/select/hooks/useSelectState.d.ts +7 -7
  147. package/lib/select/hooks/useSelectState.js +93 -58
  148. package/lib/select/index.d.ts +8 -7
  149. package/lib/select/index.js +53 -0
  150. package/lib/select/types.d.ts +211 -211
  151. package/lib/select/types.js +17 -0
  152. package/lib/select/utils/filterOptions.d.ts +6 -7
  153. package/lib/select/utils/filterOptions.js +37 -26
  154. package/lib/select/utils/helpers.d.ts +9 -10
  155. package/lib/select/utils/helpers.js +41 -45
  156. package/lib/select/utils/index.d.ts +7 -4
  157. package/lib/select/utils/index.js +48 -0
  158. package/lib/select/utils/sortOptions.d.ts +5 -6
  159. package/lib/select/utils/sortOptions.js +39 -18
  160. package/lib/select/utils/tagAggregation.d.ts +6 -6
  161. package/lib/select/utils/tagAggregation.js +41 -33
  162. package/lib/text-input/hooks/index.d.ts +4 -0
  163. package/lib/text-input/hooks/index.js +29 -0
  164. package/lib/text-input/hooks/useTextInputState.d.ts +2 -6
  165. package/lib/text-input/hooks/useTextInputState.js +79 -69
  166. package/lib/text-input/index.d.ts +14 -0
  167. package/lib/text-input/index.js +35 -0
  168. package/lib/text-input/types.d.ts +48 -48
  169. package/lib/text-input/types.js +17 -0
  170. package/lib/text-input/utils/index.d.ts +5 -0
  171. package/lib/text-input/utils/index.js +32 -0
  172. package/lib/text-input/utils/validation.d.ts +2 -7
  173. package/lib/text-input/utils/validation.js +58 -49
  174. package/lib/typeUtils.js +73 -68
  175. package/lib/walletValidity.d.ts +42 -44
  176. package/lib/walletValidity.js +393 -410
  177. package/lib/weighing.d.ts +45 -48
  178. package/lib/weighing.js +149 -104
  179. package/package.json +1 -1
  180. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  181. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  182. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  183. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  184. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  185. package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -11
  186. package/es/date.d.ts +0 -31
  187. package/es/document.d.ts +0 -16
  188. package/es/image.d.ts +0 -14
  189. package/es/typeUtils.d.ts +0 -45
  190. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +0 -27
  191. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +0 -12
  192. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +0 -25
  193. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +0 -14
  194. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +0 -9
  195. package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +0 -16
  196. package/lib/_virtual/_rolldown/runtime.js +0 -23
  197. package/lib/date.d.ts +0 -31
  198. package/lib/document.d.ts +0 -16
  199. package/lib/image.d.ts +0 -14
  200. package/lib/typeUtils.d.ts +0 -45
@@ -1,446 +1,429 @@
1
- const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
- const require_objectSpread2 = require("./_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
3
- let dayjs = require("dayjs");
4
- dayjs = require_runtime.__toESM(dayjs);
5
- //#region src/walletValidity.ts
6
- const CONSTANTS = {
7
- ALL_DAY_START: "00:00",
8
- ALL_DAY_END: "23:59",
9
- SECONDS_SUFFIX: ":59"
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/walletValidity.ts
30
+ var walletValidity_exports = {};
31
+ __export(walletValidity_exports, {
32
+ getScheduleSummary: () => getScheduleSummary,
33
+ getWalletValidityRange: () => getWalletValidityRange
34
+ });
35
+ module.exports = __toCommonJS(walletValidity_exports);
36
+ var import_dayjs = __toESM(require("dayjs"));
37
+ var CONSTANTS = {
38
+ ALL_DAY_START: "00:00",
39
+ ALL_DAY_END: "23:59",
40
+ SECONDS_SUFFIX: ":59"
10
41
  };
11
42
  function getValidityDate(value) {
12
- if (typeof value !== "string") return null;
13
- const match = value.match(/^(\d{4}-\d{2}-\d{2})(?:$|[ T])/);
14
- if (!match) return null;
15
- const date = (0, dayjs.default)(match[1]);
16
- return date.isValid() && date.format("YYYY-MM-DD") === match[1] ? match[1] : null;
43
+ if (typeof value !== "string") return null;
44
+ const match = value.match(/^(\d{4}-\d{2}-\d{2})(?:$|[ T])/);
45
+ if (!match) return null;
46
+ const date = (0, import_dayjs.default)(match[1]);
47
+ return date.isValid() && date.format("YYYY-MM-DD") === match[1] ? match[1] : null;
17
48
  }
18
- /** 仅计算展示日期的交集,不修改日程的重复起点或每日使用时段。 */
19
49
  function getWalletValidityRange(start, end, validity) {
20
- const scheduleStart = getValidityDate(start);
21
- const scheduleEnd = getValidityDate(end);
22
- const passStart = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.start_date);
23
- const passEnd = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.expire_date) || getValidityDate(validity === null || validity === void 0 ? void 0 : validity.expire_time);
24
- const startDate = passStart && (!scheduleStart || passStart > scheduleStart) ? passStart : scheduleStart;
25
- const endDate = passEnd && (!scheduleEnd || passEnd < scheduleEnd) ? passEnd : scheduleEnd;
26
- return {
27
- startDate,
28
- endDate,
29
- isEmpty: Boolean(startDate && endDate && startDate > endDate)
30
- };
50
+ const scheduleStart = getValidityDate(start);
51
+ const scheduleEnd = getValidityDate(end);
52
+ const passStart = getValidityDate(validity == null ? void 0 : validity.start_date);
53
+ const passEnd = getValidityDate(validity == null ? void 0 : validity.expire_date) || getValidityDate(validity == null ? void 0 : validity.expire_time);
54
+ const startDate = passStart && (!scheduleStart || passStart > scheduleStart) ? passStart : scheduleStart;
55
+ const endDate = passEnd && (!scheduleEnd || passEnd < scheduleEnd) ? passEnd : scheduleEnd;
56
+ return {
57
+ startDate,
58
+ endDate,
59
+ isEmpty: Boolean(startDate && endDate && startDate > endDate)
60
+ };
31
61
  }
32
- const textConfig = {
33
- "zh-HK": {
34
- weekdays: [
35
- "日",
36
- "一",
37
- "二",
38
- "三",
39
- "四",
40
- "五",
41
- "六"
42
- ],
43
- separator: "、",
44
- timeSeparator: "–",
45
- rangeSeparator: " 至 ",
46
- periodSeparator: ";",
47
- timeSlotSeparator: ",",
48
- every: "每",
49
- day: "天",
50
- week: "周",
51
- month: "月",
52
- year: "年",
53
- available: "可用",
54
- unlimited: "无限期",
55
- noAvailableDates: "無可用日期",
56
- multipleRules: "多規則,點詳情",
57
- multipleSlots: ",多時段",
58
- until: "至",
59
- daily: "每天",
60
- days: "天",
61
- weeks: "周",
62
- everyPrefix: "每",
63
- weekPrefix: "周",
64
- dateFormat: "YYYY-MM-DD",
65
- dateTimeFormat: "YYYY-MM-DD HH:mm",
66
- longTermValidFrom: "自",
67
- noExpiry: "起長期有效",
68
- on: ""
69
- },
70
- "zh-CN": {
71
- weekdays: [
72
- "日",
73
- "一",
74
- "二",
75
- "三",
76
- "四",
77
- "五",
78
- "六"
79
- ],
80
- separator: "、",
81
- timeSeparator: "–",
82
- rangeSeparator: " 至 ",
83
- periodSeparator: ";",
84
- timeSlotSeparator: ",",
85
- every: "每",
86
- day: "天",
87
- week: "周",
88
- month: "月",
89
- year: "年",
90
- available: "可用",
91
- unlimited: "无限期",
92
- noAvailableDates: "无可用日期",
93
- multipleRules: "多规则,点详情",
94
- multipleSlots: ",多时段",
95
- until: "至",
96
- daily: "每天",
97
- days: "天",
98
- weeks: "周",
99
- everyPrefix: "每",
100
- weekPrefix: "周",
101
- dateFormat: "YYYY-MM-DD",
102
- dateTimeFormat: "YYYY-MM-DD HH:mm",
103
- longTermValidFrom: "自",
104
- noExpiry: "起长期有效",
105
- on: ""
106
- },
107
- "en": {
108
- weekdays: [
109
- "Sun",
110
- "Mon",
111
- "Tue",
112
- "Wed",
113
- "Thu",
114
- "Fri",
115
- "Sat"
116
- ],
117
- separator: ", ",
118
- timeSeparator: "–",
119
- rangeSeparator: " - ",
120
- periodSeparator: "; ",
121
- timeSlotSeparator: ", ",
122
- every: "every ",
123
- day: "day",
124
- week: "week",
125
- month: "month",
126
- year: "year",
127
- available: "available",
128
- unlimited: "unlimited",
129
- noAvailableDates: "No available dates",
130
- multipleRules: "Multiple rules, see details",
131
- multipleSlots: ", multiple slots",
132
- until: "Until ",
133
- daily: "daily",
134
- days: "days",
135
- weeks: "weeks",
136
- everyPrefix: "every ",
137
- weekPrefix: "",
138
- dateFormat: "DD MMM YYYY",
139
- dateTimeFormat: "DD MMM YYYY h:mm A",
140
- longTermValidFrom: "from ",
141
- noExpiry: ", no expiry",
142
- on: "on "
143
- }
62
+ var textConfig = {
63
+ "zh-HK": {
64
+ weekdays: ["日", "一", "二", "三", "四", "五", "六"],
65
+ separator: "、",
66
+ timeSeparator: "–",
67
+ rangeSeparator: " 至 ",
68
+ periodSeparator: ";",
69
+ timeSlotSeparator: ",",
70
+ every: "每",
71
+ day: "天",
72
+ week: "周",
73
+ month: "月",
74
+ year: "年",
75
+ available: "可用",
76
+ unlimited: "无限期",
77
+ noAvailableDates: "無可用日期",
78
+ multipleRules: "多規則,點詳情",
79
+ multipleSlots: ",多時段",
80
+ until: "至",
81
+ daily: "每天",
82
+ days: "天",
83
+ weeks: "周",
84
+ everyPrefix: "每",
85
+ weekPrefix: "周",
86
+ dateFormat: "YYYY-MM-DD",
87
+ dateTimeFormat: "YYYY-MM-DD HH:mm",
88
+ longTermValidFrom: "自",
89
+ noExpiry: "起長期有效",
90
+ on: ""
91
+ },
92
+ "zh-CN": {
93
+ weekdays: ["日", "一", "二", "三", "四", "五", "六"],
94
+ separator: "、",
95
+ timeSeparator: "–",
96
+ rangeSeparator: " 至 ",
97
+ periodSeparator: ";",
98
+ timeSlotSeparator: ",",
99
+ every: "每",
100
+ day: "天",
101
+ week: "周",
102
+ month: "月",
103
+ year: "年",
104
+ available: "可用",
105
+ unlimited: "无限期",
106
+ noAvailableDates: "无可用日期",
107
+ multipleRules: "多规则,点详情",
108
+ multipleSlots: ",多时段",
109
+ until: "至",
110
+ daily: "每天",
111
+ days: "天",
112
+ weeks: "周",
113
+ everyPrefix: "每",
114
+ weekPrefix: "周",
115
+ dateFormat: "YYYY-MM-DD",
116
+ dateTimeFormat: "YYYY-MM-DD HH:mm",
117
+ longTermValidFrom: "自",
118
+ noExpiry: "起长期有效",
119
+ on: ""
120
+ },
121
+ "en": {
122
+ weekdays: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
123
+ separator: ", ",
124
+ timeSeparator: "–",
125
+ rangeSeparator: " - ",
126
+ periodSeparator: "; ",
127
+ timeSlotSeparator: ", ",
128
+ every: "every ",
129
+ day: "day",
130
+ week: "week",
131
+ month: "month",
132
+ year: "year",
133
+ available: "available",
134
+ unlimited: "unlimited",
135
+ noAvailableDates: "No available dates",
136
+ multipleRules: "Multiple rules, see details",
137
+ multipleSlots: ", multiple slots",
138
+ until: "Until ",
139
+ daily: "daily",
140
+ days: "days",
141
+ weeks: "weeks",
142
+ everyPrefix: "every ",
143
+ weekPrefix: "",
144
+ dateFormat: "DD MMM YYYY",
145
+ dateTimeFormat: "DD MMM YYYY h:mm A",
146
+ longTermValidFrom: "from ",
147
+ noExpiry: ", no expiry",
148
+ on: "on "
149
+ }
144
150
  };
145
- /**
146
- * 获取星期几的表示
147
- * @param dayNumbers 星期几的数字数组 (0-6, 0代表周日)
148
- * @param locale 语言设置
149
- * @param separator 分隔符,可选,默认使用locale配置的分隔符
150
- * @returns 格式化的星期几文案
151
- */
152
151
  function getWeekdayText(dayNumbers, locale, separator) {
153
- const config = textConfig[locale];
154
- return [...new Set(dayNumbers)].sort((a, b) => a - b).map((day) => config.weekdays[day]).join(separator || config.separator);
152
+ const config = textConfig[locale];
153
+ return [...new Set(dayNumbers)].sort((a, b) => a - b).map((day) => config.weekdays[day]).join(separator || config.separator);
155
154
  }
156
- /**
157
- * 获取指定语言的文案配置
158
- * @param locale 语言设置
159
- * @param key 配置项key
160
- * @returns 对应语言的文案
161
- */
162
155
  function getText(locale, key) {
163
- return textConfig[locale][key];
156
+ return textConfig[locale][key];
164
157
  }
165
- /**
166
- * 获取指定语言的配置对象(缓存优化)
167
- * @param locale 语言设置
168
- * @returns 对应语言的完整配置对象
169
- */
170
158
  function getConfig(locale) {
171
- return textConfig[locale];
159
+ return textConfig[locale];
172
160
  }
173
- /**
174
- * 获取每日频率文案
175
- * @param frequency 频率数字
176
- * @param locale 语言设置
177
- * @returns 格式化的每日频率文案
178
- */
179
161
  function getDailyFrequencyText(frequency, locale) {
180
- if (frequency === 1) return getText(locale, "daily");
181
- const config = textConfig[locale];
182
- if (locale === "en") return `${config.everyPrefix}${frequency} ${config.days}`;
183
- else return `${config.everyPrefix}${frequency}${config.days}`;
162
+ if (frequency === 1) {
163
+ return getText(locale, "daily");
164
+ }
165
+ const config = textConfig[locale];
166
+ if (locale === "en") {
167
+ return `${config.everyPrefix}${frequency} ${config.days}`;
168
+ } else {
169
+ return `${config.everyPrefix}${frequency}${config.days}`;
170
+ }
184
171
  }
185
- /**
186
- * 获取每周频率前缀文案
187
- * @param frequency 频率数字
188
- * @param locale 语言设置
189
- * @returns 格式化的每周频率前缀文案
190
- */
191
172
  function getWeeklyFrequencyPrefix(frequency, locale) {
192
- if (frequency === 1) return "";
193
- const config = textConfig[locale];
194
- if (locale === "en") return `${config.everyPrefix}${frequency} ${config.weeks}, `;
195
- else return `${config.everyPrefix}${frequency}${config.weeks} `;
173
+ if (frequency === 1) {
174
+ return "";
175
+ }
176
+ const config = textConfig[locale];
177
+ if (locale === "en") {
178
+ return `${config.everyPrefix}${frequency} ${config.weeks}, `;
179
+ } else {
180
+ return `${config.everyPrefix}${frequency}${config.weeks} `;
181
+ }
196
182
  }
197
- /**
198
- * 格式化日期时间函数
199
- * @param dateTime 日期时间字符串
200
- * @param isAll 是否为全天
201
- * @param locale 语言设置
202
- * @returns 格式化后的日期时间字符串
203
- */
204
183
  function formatDateTime(dateTime, isAll = false, locale = "zh-CN") {
205
- const date = (0, dayjs.default)(dateTime);
206
- const config = getConfig(locale);
207
- if (isAll) return date.format(config.dateFormat);
208
- return date.format(config.dateTimeFormat);
184
+ const date = (0, import_dayjs.default)(dateTime);
185
+ const config = getConfig(locale);
186
+ if (isAll) {
187
+ return date.format(config.dateFormat);
188
+ }
189
+ return date.format(config.dateTimeFormat);
209
190
  }
210
- /**
211
- * 判断是否为全天日程
212
- * @param startTime 开始时间 (HH:mm格式)
213
- * @param endTime 结束时间 (HH:mm格式)
214
- * @returns 是否为全天日程
215
- */
216
191
  function isAllDaySchedule(startTime, endTime) {
217
- return startTime === CONSTANTS.ALL_DAY_START && endTime === CONSTANTS.ALL_DAY_END;
192
+ return startTime === CONSTANTS.ALL_DAY_START && endTime === CONSTANTS.ALL_DAY_END;
218
193
  }
219
- /**
220
- * 生成日期范围文案
221
- * @param startDate 开始日期
222
- * @param endDate 结束日期
223
- * @param isStarted 是否已开始
224
- * @param locale 语言设置
225
- * @param isAllDay 是否为全天
226
- * @returns 格式化的日期范围文案
227
- */
228
194
  function formatDateRange(startDate, endDate, isStarted, locale, isAllDay = false, validity) {
229
- const config = getConfig(locale);
230
- const range = getWalletValidityRange(startDate, endDate, validity);
231
- if (range.isEmpty) return config.noAvailableDates;
232
- const effectiveStart = range.startDate === getValidityDate(startDate) ? startDate : `${range.startDate} 00:00:00`;
233
- const effectiveEnd = range.endDate === getValidityDate(endDate) ? endDate : `${range.endDate} 23:59:59`;
234
- if (!range.endDate) return config.unlimited;
235
- if ((range.startDate ? (0, dayjs.default)(effectiveStart).isBefore((0, dayjs.default)()) : isStarted) || !range.startDate) {
236
- const endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
237
- return `${config.until}${endDateStr}`;
238
- } else {
239
- const startDateStr = formatDateTime(effectiveStart, isAllDay, locale);
240
- const endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
241
- return `${startDateStr}${config.rangeSeparator}${endDateStr}`;
242
- }
195
+ const config = getConfig(locale);
196
+ const range = getWalletValidityRange(startDate, endDate, validity);
197
+ if (range.isEmpty) return config.noAvailableDates;
198
+ const effectiveStart = range.startDate === getValidityDate(startDate) ? startDate : `${range.startDate} 00:00:00`;
199
+ const effectiveEnd = range.endDate === getValidityDate(endDate) ? endDate : `${range.endDate} 23:59:59`;
200
+ if (!range.endDate) return config.unlimited;
201
+ const hasStarted = range.startDate ? (0, import_dayjs.default)(effectiveStart).isBefore((0, import_dayjs.default)()) : isStarted;
202
+ if (hasStarted || !range.startDate) {
203
+ const endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
204
+ return `${config.until}${endDateStr}`;
205
+ } else {
206
+ const startDateStr = formatDateTime(effectiveStart, isAllDay, locale);
207
+ const endDateStr = formatDateTime(effectiveEnd, isAllDay, locale);
208
+ return `${startDateStr}${config.rangeSeparator}${endDateStr}`;
209
+ }
243
210
  }
244
- /**
245
- * 获取schedule摘要信息
246
- * @param scheduleList 日程列表
247
- * @param locale 语言设置
248
- * @returns 摘要文本
249
- */
250
211
  function getScheduleSummary(scheduleList, locale = "zh-CN", validity) {
251
- try {
252
- locale = textConfig[locale] ? locale : "en";
253
- if (!scheduleList || !Array.isArray(scheduleList)) return "";
254
- if (scheduleList.length > 1) {
255
- const range = getWalletValidityRange(null, null, validity);
256
- if (!range.startDate && !range.endDate) return getText(locale, "multipleRules");
257
- const summaries = scheduleList.map((schedule) => getScheduleSummary([schedule], locale, validity)).filter((summary) => summary !== getText(locale, "noAvailableDates"));
258
- if (summaries.length === 0) return getText(locale, "noAvailableDates");
259
- if (summaries.length === 1 && summaries[0]) return summaries[0];
260
- return `${range.endDate ? `${formatDateRange(range.startDate || "", range.endDate, false, locale, true)}${getText(locale, "periodSeparator")}` : ""}${getText(locale, "multipleRules")}`;
261
- }
262
- if (scheduleList.length === 0) return "";
263
- const schedule = scheduleList[0];
264
- if (!schedule) return "";
265
- const now = (0, dayjs.default)();
266
- let startTime = null;
267
- if (schedule.start_time) startTime = (0, dayjs.default)(schedule.start_time);
268
- else if (schedule.designation && schedule.designation.length > 0) {
269
- const firstDesignation = schedule.designation[0];
270
- if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) startTime = (0, dayjs.default)(`${firstDesignation.start_date} ${firstDesignation.start_time}`);
271
- }
272
- const passStart = getValidityDate(validity === null || validity === void 0 ? void 0 : validity.start_date);
273
- if (passStart && (!startTime || (0, dayjs.default)(passStart).isAfter(startTime))) startTime = (0, dayjs.default)(passStart);
274
- const summary = generateSummaryText(schedule, startTime ? isTimeStarted(now, startTime) : false, locale, validity);
275
- if (summary === getText(locale, "noAvailableDates")) {
276
- var _schedule$repeat_rule;
277
- const included = (_schedule$repeat_rule = schedule.repeat_rule) === null || _schedule$repeat_rule === void 0 || (_schedule$repeat_rule = _schedule$repeat_rule.included_date) === null || _schedule$repeat_rule === void 0 ? void 0 : _schedule$repeat_rule.filter((item) => !getWalletValidityRange(item.start, item.end, validity).isEmpty);
278
- if (included === null || included === void 0 ? void 0 : included.length) return getScheduleSummary([require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, schedule), {}, {
279
- start_time: null,
280
- end_time: null,
281
- type: "designation",
282
- repeat_type: "none",
283
- repeat_rule: null,
284
- is_all: 1,
285
- designation: included.map((item) => ({
286
- start_date: item.start,
287
- end_date: item.end,
288
- start_time: "00:00",
289
- end_time: "23:59"
290
- }))
291
- })], locale, validity);
292
- }
293
- return summary;
294
- } catch (error) {
295
- console.warn("Error in getScheduleSummary:", error);
296
- return "";
297
- }
212
+ var _a, _b;
213
+ try {
214
+ locale = textConfig[locale] ? locale : "en";
215
+ if (!scheduleList || !Array.isArray(scheduleList)) {
216
+ return "";
217
+ }
218
+ if (scheduleList.length > 1) {
219
+ const range = getWalletValidityRange(null, null, validity);
220
+ if (!range.startDate && !range.endDate) return getText(locale, "multipleRules");
221
+ const summaries = scheduleList.map((schedule2) => getScheduleSummary([schedule2], locale, validity)).filter((summary2) => summary2 !== getText(locale, "noAvailableDates"));
222
+ if (summaries.length === 0) return getText(locale, "noAvailableDates");
223
+ if (summaries.length === 1 && summaries[0]) return summaries[0];
224
+ const prefix = range.endDate ? `${formatDateRange(range.startDate || "", range.endDate, false, locale, true)}${getText(locale, "periodSeparator")}` : "";
225
+ return `${prefix}${getText(locale, "multipleRules")}`;
226
+ }
227
+ if (scheduleList.length === 0) {
228
+ return "";
229
+ }
230
+ const schedule = scheduleList[0];
231
+ if (!schedule) {
232
+ return "";
233
+ }
234
+ const now = (0, import_dayjs.default)();
235
+ let startTime = null;
236
+ if (schedule.start_time) {
237
+ startTime = (0, import_dayjs.default)(schedule.start_time);
238
+ } else if (schedule.designation && schedule.designation.length > 0) {
239
+ const firstDesignation = schedule.designation[0];
240
+ if (firstDesignation && firstDesignation.start_date && firstDesignation.start_time) {
241
+ startTime = (0, import_dayjs.default)(`${firstDesignation.start_date} ${firstDesignation.start_time}`);
242
+ }
243
+ }
244
+ const passStart = getValidityDate(validity == null ? void 0 : validity.start_date);
245
+ if (passStart && (!startTime || (0, import_dayjs.default)(passStart).isAfter(startTime))) {
246
+ startTime = (0, import_dayjs.default)(passStart);
247
+ }
248
+ const isStarted = startTime ? isTimeStarted(now, startTime) : false;
249
+ const summary = generateSummaryText(schedule, isStarted, locale, validity);
250
+ if (summary === getText(locale, "noAvailableDates")) {
251
+ const included = (_b = (_a = schedule.repeat_rule) == null ? void 0 : _a.included_date) == null ? void 0 : _b.filter(
252
+ (item) => !getWalletValidityRange(item.start, item.end, validity).isEmpty
253
+ );
254
+ if (included == null ? void 0 : included.length) {
255
+ return getScheduleSummary([{
256
+ ...schedule,
257
+ start_time: null,
258
+ end_time: null,
259
+ type: "designation",
260
+ repeat_type: "none",
261
+ repeat_rule: null,
262
+ is_all: 1,
263
+ designation: included.map((item) => ({
264
+ start_date: item.start,
265
+ end_date: item.end,
266
+ start_time: "00:00",
267
+ end_time: "23:59"
268
+ }))
269
+ }], locale, validity);
270
+ }
271
+ }
272
+ return summary;
273
+ } catch (error) {
274
+ console.warn("Error in getScheduleSummary:", error);
275
+ return "";
276
+ }
298
277
  }
299
- /**
300
- * 判断开始时间是否在当前时间之后
301
- * @param now 当前时间
302
- * @param startTime 开始时间
303
- * @returns 是否已开始
304
- */
305
278
  function isTimeStarted(now, startTime) {
306
- return startTime.isBefore(now);
279
+ return startTime.isBefore(now);
307
280
  }
308
- /**
309
- * 生成摘要文本
310
- * @param schedule 日程对象
311
- * @param isStarted 是否已开始
312
- * @param locale 语言设置
313
- * @returns 生成的摘要文本
314
- */
315
281
  function generateSummaryText(schedule, isStarted, locale, validity) {
316
- if (schedule.type === "designation" && schedule.designation && schedule.designation.length > 1) {
317
- const passRange = getWalletValidityRange(null, null, validity);
318
- if (!passRange.startDate && !passRange.endDate) return getText(locale, "multipleRules");
319
- const designation = schedule.designation.filter((item) => !getWalletValidityRange(item.start_date, item.end_date, validity).isEmpty);
320
- if (!designation.length) return getText(locale, "noAvailableDates");
321
- if (designation.length === 1) return generateSingleScheduleSummary(require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, schedule), {}, { designation }), isStarted, locale, validity);
322
- const range = getWalletValidityRange(designation.map((item) => item.start_date).sort()[0], designation.map((item) => item.end_date).sort().pop(), validity);
323
- return `${range.endDate ? `${formatDateRange(range.startDate || "", range.endDate, isStarted, locale, true)}${getText(locale, "periodSeparator")}` : ""}${getText(locale, "multipleRules")}`;
324
- }
325
- if (schedule.type === "time-slots") {
326
- const range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
327
- if (range.isEmpty) return getText(locale, "noAvailableDates");
328
- return `${range.endDate ? formatDateTime(range.endDate, true, locale) : getText(locale, "unlimited")}${getText(locale, "multipleSlots")}`;
329
- }
330
- if (schedule.repeat_type !== "none" && schedule.repeat_rule) return generateRecurringSummary(schedule, isStarted, locale, validity);
331
- return generateSingleScheduleSummary(schedule, isStarted, locale, validity);
282
+ if (schedule.type === "designation" && schedule.designation && schedule.designation.length > 1) {
283
+ const passRange = getWalletValidityRange(null, null, validity);
284
+ if (!passRange.startDate && !passRange.endDate) return getText(locale, "multipleRules");
285
+ const designation = schedule.designation.filter(
286
+ (item) => !getWalletValidityRange(item.start_date, item.end_date, validity).isEmpty
287
+ );
288
+ if (!designation.length) return getText(locale, "noAvailableDates");
289
+ if (designation.length === 1) {
290
+ return generateSingleScheduleSummary({ ...schedule, designation }, isStarted, locale, validity);
291
+ }
292
+ const range = getWalletValidityRange(
293
+ designation.map((item) => item.start_date).sort()[0],
294
+ designation.map((item) => item.end_date).sort().pop(),
295
+ validity
296
+ );
297
+ const prefix = range.endDate ? `${formatDateRange(range.startDate || "", range.endDate, isStarted, locale, true)}${getText(locale, "periodSeparator")}` : "";
298
+ return `${prefix}${getText(locale, "multipleRules")}`;
299
+ }
300
+ if (schedule.type === "time-slots") {
301
+ const range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
302
+ if (range.isEmpty) return getText(locale, "noAvailableDates");
303
+ const endDateStr = range.endDate ? formatDateTime(range.endDate, true, locale) : getText(locale, "unlimited");
304
+ const suffix = getText(locale, "multipleSlots");
305
+ return `${endDateStr}${suffix}`;
306
+ }
307
+ if (schedule.repeat_type !== "none" && schedule.repeat_rule) {
308
+ return generateRecurringSummary(schedule, isStarted, locale, validity);
309
+ }
310
+ return generateSingleScheduleSummary(schedule, isStarted, locale, validity);
332
311
  }
333
- /**
334
- * 生成循环日程摘要
335
- * @param schedule 日程对象
336
- * @param isStarted 是否已开始
337
- * @param locale 语言设置
338
- * @returns 循环日程摘要文本
339
- */
340
312
  function generateRecurringSummary(schedule, isStarted, locale, validity) {
341
- const { repeat_type, repeat_rule } = schedule;
342
- if (!repeat_rule) return "";
343
- const { frequency, frequency_date, end } = repeat_rule;
344
- const range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
345
- if (range.isEmpty) return getText(locale, "noAvailableDates");
346
- if (end.type === "never" && !range.endDate) return generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeat_type, frequency, frequency_date, validity);
347
- const endDate = range.endDate;
348
- if (!endDate) return "";
349
- if (repeat_type === "daily") {
350
- const frequencyText = getDailyFrequencyText(frequency, locale);
351
- return `${formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity)}${getText(locale, "timeSlotSeparator")}${frequencyText}`;
352
- }
353
- if (repeat_type === "weekly") {
354
- const weekdaysText = getWeekdayText(frequency_date, locale, "/");
355
- const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
356
- const config = getConfig(locale);
357
- return `${formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity)}${config.timeSlotSeparator}${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
358
- }
359
- return "";
313
+ const { repeat_type, repeat_rule } = schedule;
314
+ if (!repeat_rule) return "";
315
+ const { frequency, frequency_date, end } = repeat_rule;
316
+ const range = getWalletValidityRange(schedule.start_time, getScheduleEndDate(schedule), validity);
317
+ if (range.isEmpty) return getText(locale, "noAvailableDates");
318
+ if (end.type === "never" && !range.endDate) {
319
+ return generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeat_type, frequency, frequency_date, validity);
320
+ }
321
+ const endDate = range.endDate;
322
+ if (!endDate) return "";
323
+ if (repeat_type === "daily") {
324
+ const frequencyText = getDailyFrequencyText(frequency, locale);
325
+ const dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
326
+ return `${dateRange}${getText(locale, "timeSlotSeparator")}${frequencyText}`;
327
+ }
328
+ if (repeat_type === "weekly") {
329
+ const weekdaysText = getWeekdayText(frequency_date, locale, "/");
330
+ const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
331
+ const config = getConfig(locale);
332
+ const dateRange = formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
333
+ return `${dateRange}${config.timeSlotSeparator}${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
334
+ }
335
+ return "";
360
336
  }
361
- /**
362
- * 生成永不结束的循环日程摘要
363
- * @param schedule 日程对象
364
- * @param isStarted 是否已开始
365
- * @param locale 语言设置
366
- * @param repeatType 循环类型
367
- * @param frequency 频率
368
- * @param frequencyDate 频率日期数组(用于周循环)
369
- * @returns 永不结束的循环日程摘要文本
370
- */
371
337
  function generateNeverEndingRecurringSummary(schedule, isStarted, locale, repeatType, frequency, frequencyDate, validity) {
372
- const config = getConfig(locale);
373
- if (repeatType === "daily") if (frequency === 1) {
374
- const range = getWalletValidityRange(schedule.start_time, null, validity);
375
- if (range.startDate) {
376
- const startDateStr = formatDateTime(range.startDate, true, locale);
377
- return `${config.longTermValidFrom}${startDateStr}${config.noExpiry}`;
378
- }
379
- return "";
380
- } else {
381
- const frequencyText = getDailyFrequencyText(frequency, locale);
382
- if (locale === "en") return `${frequencyText}`;
383
- else return `${frequencyText}${config.available}`;
384
- }
385
- if (repeatType === "weekly") {
386
- const weekdaysText = getWeekdayText(frequencyDate, locale, locale === "en" ? " & " : "/");
387
- if (frequency === 1) if (locale === "en") return `${config.on}${weekdaysText}`;
388
- else return `${config.everyPrefix}${config.weekPrefix}${weekdaysText}${config.available}`;
389
- else {
390
- const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
391
- if (locale === "en") return `${frequencyPrefix}${config.on}${weekdaysText}`;
392
- else return `${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
393
- }
394
- }
395
- return "";
338
+ const config = getConfig(locale);
339
+ if (repeatType === "daily") {
340
+ if (frequency === 1) {
341
+ const range = getWalletValidityRange(schedule.start_time, null, validity);
342
+ if (range.startDate) {
343
+ const startDateStr = formatDateTime(range.startDate, true, locale);
344
+ return `${config.longTermValidFrom}${startDateStr}${config.noExpiry}`;
345
+ }
346
+ return "";
347
+ } else {
348
+ const frequencyText = getDailyFrequencyText(frequency, locale);
349
+ if (locale === "en") {
350
+ return `${frequencyText}`;
351
+ } else {
352
+ return `${frequencyText}${config.available}`;
353
+ }
354
+ }
355
+ }
356
+ if (repeatType === "weekly") {
357
+ const weekdaysText = getWeekdayText(frequencyDate, locale, locale === "en" ? " & " : "/");
358
+ if (frequency === 1) {
359
+ if (locale === "en") {
360
+ return `${config.on}${weekdaysText}`;
361
+ } else {
362
+ return `${config.everyPrefix}${config.weekPrefix}${weekdaysText}${config.available}`;
363
+ }
364
+ } else {
365
+ const frequencyPrefix = getWeeklyFrequencyPrefix(frequency, locale);
366
+ if (locale === "en") {
367
+ return `${frequencyPrefix}${config.on}${weekdaysText}`;
368
+ } else {
369
+ return `${frequencyPrefix}${config.weekPrefix}${weekdaysText}`;
370
+ }
371
+ }
372
+ }
373
+ return "";
396
374
  }
397
- /**
398
- * 生成单个日程摘要
399
- * @param schedule 日程对象
400
- * @param isStarted 是否已开始
401
- * @param locale 语言设置
402
- * @returns 单个日程摘要文本
403
- */
404
375
  function generateSingleScheduleSummary(schedule, isStarted, locale, validity) {
405
- const isAllDay = schedule.is_all === 1;
406
- if (schedule.type === "designation" && schedule.designation && schedule.designation.length === 1) {
407
- const designation = schedule.designation[0];
408
- const startDate = designation.start_date;
409
- const endDate = designation.end_date;
410
- const startTime = designation.start_time;
411
- const endTime = designation.end_time;
412
- if (isAllDaySchedule(startTime, endTime) || isAllDay) return formatDateRange(startDate, endDate, isStarted, locale, true, validity);
413
- else return formatDateRange(`${startDate} ${startTime}${CONSTANTS.SECONDS_SUFFIX}`, `${endDate} ${endTime}${CONSTANTS.SECONDS_SUFFIX}`, isStarted, locale, false, validity);
414
- }
415
- if (isAllDay) {
416
- const endDate = getScheduleEndDate(schedule);
417
- if (!endDate) return "";
418
- return formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
419
- } else return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false, validity);
376
+ const isAllDay = schedule.is_all === 1;
377
+ if (schedule.type === "designation" && schedule.designation && schedule.designation.length === 1) {
378
+ const designation = schedule.designation[0];
379
+ const startDate = designation.start_date;
380
+ const endDate = designation.end_date;
381
+ const startTime = designation.start_time;
382
+ const endTime = designation.end_time;
383
+ const isDesignationAllDay = isAllDaySchedule(startTime, endTime);
384
+ if (isDesignationAllDay || isAllDay) {
385
+ return formatDateRange(startDate, endDate, isStarted, locale, true, validity);
386
+ } else {
387
+ const startDateTime = `${startDate} ${startTime}${CONSTANTS.SECONDS_SUFFIX}`;
388
+ const endDateTime = `${endDate} ${endTime}${CONSTANTS.SECONDS_SUFFIX}`;
389
+ return formatDateRange(startDateTime, endDateTime, isStarted, locale, false, validity);
390
+ }
391
+ }
392
+ if (isAllDay) {
393
+ const endDate = getScheduleEndDate(schedule);
394
+ if (!endDate) return "";
395
+ return formatDateRange(schedule.start_time, endDate, isStarted, locale, true, validity);
396
+ } else {
397
+ return formatDateRange(schedule.start_time, schedule.end_time, isStarted, locale, false, validity);
398
+ }
420
399
  }
421
- /**
422
- * 获取日程结束日期
423
- * @param schedule 日程对象
424
- * @returns 结束日期字符串,如果无法确定则返回null
425
- */
426
400
  function getScheduleEndDate(schedule) {
427
- try {
428
- if (schedule.repeat_rule) {
429
- if (schedule.repeat_rule.end.type === "never") return null;
430
- else if (schedule.repeat_rule.end.end_date) return `${schedule.repeat_rule.end.end_date} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
431
- }
432
- if (schedule.designation && schedule.designation.length > 0) {
433
- const lastDesignation = schedule.designation[schedule.designation.length - 1];
434
- return `${lastDesignation.end_date} ${lastDesignation.end_time}${CONSTANTS.SECONDS_SUFFIX}`;
435
- }
436
- if (schedule.end_time) return schedule.end_time;
437
- if (schedule.start_time) return schedule.start_time;
438
- return null;
439
- } catch (error) {
440
- console.warn("Error in getScheduleEndDate:", error);
441
- return null;
442
- }
401
+ try {
402
+ if (schedule.repeat_rule) {
403
+ if (schedule.repeat_rule.end.type === "never") {
404
+ return null;
405
+ } else if (schedule.repeat_rule.end.end_date) {
406
+ return `${schedule.repeat_rule.end.end_date} ${CONSTANTS.ALL_DAY_END}${CONSTANTS.SECONDS_SUFFIX}`;
407
+ }
408
+ }
409
+ if (schedule.designation && schedule.designation.length > 0) {
410
+ const lastDesignation = schedule.designation[schedule.designation.length - 1];
411
+ return `${lastDesignation.end_date} ${lastDesignation.end_time}${CONSTANTS.SECONDS_SUFFIX}`;
412
+ }
413
+ if (schedule.end_time) {
414
+ return schedule.end_time;
415
+ }
416
+ if (schedule.start_time) {
417
+ return schedule.start_time;
418
+ }
419
+ return null;
420
+ } catch (error) {
421
+ console.warn("Error in getScheduleEndDate:", error);
422
+ return null;
423
+ }
443
424
  }
444
- //#endregion
445
- exports.getScheduleSummary = getScheduleSummary;
446
- exports.getWalletValidityRange = getWalletValidityRange;
425
+ // Annotate the CommonJS export names for ESM import in node:
426
+ 0 && (module.exports = {
427
+ getScheduleSummary,
428
+ getWalletValidityRange
429
+ });