cmat 0.0.111 → 0.0.113

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 (256) hide show
  1. package/fesm2022/cmat-components-adapter.mjs +531 -536
  2. package/fesm2022/cmat-components-adapter.mjs.map +1 -1
  3. package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
  4. package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
  5. package/fesm2022/cmat-components-card.mjs +150 -42
  6. package/fesm2022/cmat-components-card.mjs.map +1 -1
  7. package/fesm2022/cmat-components-carousel.mjs +1120 -629
  8. package/fesm2022/cmat-components-carousel.mjs.map +1 -1
  9. package/fesm2022/cmat-components-cascade.mjs +861 -441
  10. package/fesm2022/cmat-components-cascade.mjs.map +1 -1
  11. package/fesm2022/cmat-components-chip-input.mjs +580 -335
  12. package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
  13. package/fesm2022/cmat-components-code-editor.mjs +197 -105
  14. package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
  15. package/fesm2022/cmat-components-color-picker.mjs +1762 -825
  16. package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
  17. package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
  18. package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
  19. package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
  20. package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
  21. package/fesm2022/cmat-components-date-range.mjs +701 -456
  22. package/fesm2022/cmat-components-date-range.mjs.map +1 -1
  23. package/fesm2022/cmat-components-date-time-display.mjs +137 -30
  24. package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
  25. package/fesm2022/cmat-components-drawer.mjs +410 -258
  26. package/fesm2022/cmat-components-drawer.mjs.map +1 -1
  27. package/fesm2022/cmat-components-empty-state.mjs +201 -41
  28. package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
  29. package/fesm2022/cmat-components-file-preview.mjs +198 -35
  30. package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
  31. package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
  32. package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
  33. package/fesm2022/cmat-components-form-actions.mjs +102 -26
  34. package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
  35. package/fesm2022/cmat-components-fullscreen.mjs +167 -47
  36. package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
  37. package/fesm2022/cmat-components-highlight.mjs +203 -112
  38. package/fesm2022/cmat-components-highlight.mjs.map +1 -1
  39. package/fesm2022/cmat-components-image-viewer.mjs +489 -215
  40. package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
  41. package/fesm2022/cmat-components-inline-loading.mjs +117 -27
  42. package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
  43. package/fesm2022/cmat-components-json-editor.mjs +276 -230
  44. package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
  45. package/fesm2022/cmat-components-knob-input.mjs +615 -420
  46. package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
  47. package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
  48. package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
  49. package/fesm2022/cmat-components-masonry.mjs +120 -40
  50. package/fesm2022/cmat-components-masonry.mjs.map +1 -1
  51. package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
  52. package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
  53. package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
  54. package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
  55. package/fesm2022/cmat-components-navigation.mjs +3080 -1404
  56. package/fesm2022/cmat-components-navigation.mjs.map +1 -1
  57. package/fesm2022/cmat-components-opt-input.mjs +540 -466
  58. package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
  59. package/fesm2022/cmat-components-org-chart.mjs +528 -125
  60. package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
  61. package/fesm2022/cmat-components-page-header.mjs +141 -32
  62. package/fesm2022/cmat-components-page-header.mjs.map +1 -1
  63. package/fesm2022/cmat-components-pagination.mjs +866 -534
  64. package/fesm2022/cmat-components-pagination.mjs.map +1 -1
  65. package/fesm2022/cmat-components-password-strength.mjs +873 -434
  66. package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
  67. package/fesm2022/cmat-components-popover.mjs +1012 -731
  68. package/fesm2022/cmat-components-popover.mjs.map +1 -1
  69. package/fesm2022/cmat-components-progress-bar.mjs +98 -35
  70. package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
  71. package/fesm2022/cmat-components-qrcode.mjs +463 -287
  72. package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
  73. package/fesm2022/cmat-components-rating.mjs +377 -203
  74. package/fesm2022/cmat-components-rating.mjs.map +1 -1
  75. package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
  76. package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
  77. package/fesm2022/cmat-components-select-search.mjs +926 -496
  78. package/fesm2022/cmat-components-select-search.mjs.map +1 -1
  79. package/fesm2022/cmat-components-select-table.mjs +1280 -842
  80. package/fesm2022/cmat-components-select-table.mjs.map +1 -1
  81. package/fesm2022/cmat-components-select-tree.mjs +998 -690
  82. package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
  83. package/fesm2022/cmat-components-skeleton.mjs +143 -57
  84. package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
  85. package/fesm2022/cmat-components-speed-dial.mjs +457 -303
  86. package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
  87. package/fesm2022/cmat-components-status-tag.mjs +136 -44
  88. package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
  89. package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
  90. package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
  91. package/fesm2022/cmat-components-timeline.mjs +464 -168
  92. package/fesm2022/cmat-components-timeline.mjs.map +1 -1
  93. package/fesm2022/cmat-components-toast.mjs +346 -262
  94. package/fesm2022/cmat-components-toast.mjs.map +1 -1
  95. package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
  96. package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
  97. package/fesm2022/cmat-components-treetable.mjs +372 -112
  98. package/fesm2022/cmat-components-treetable.mjs.map +1 -1
  99. package/fesm2022/cmat-components-upload.mjs +904 -410
  100. package/fesm2022/cmat-components-upload.mjs.map +1 -1
  101. package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
  102. package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
  103. package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
  104. package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
  105. package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
  106. package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
  107. package/fesm2022/cmat-directives-autofocus.mjs +43 -25
  108. package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
  109. package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
  110. package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
  111. package/fesm2022/cmat-directives-debounce.mjs +162 -76
  112. package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
  113. package/fesm2022/cmat-directives-digit-only.mjs +457 -356
  114. package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
  115. package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
  116. package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
  117. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
  118. package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
  119. package/fesm2022/cmat-lib-mock-api.mjs +207 -195
  120. package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
  121. package/fesm2022/cmat-pipes-bytes.mjs +50 -30
  122. package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
  123. package/fesm2022/cmat-pipes-date-format.mjs +41 -25
  124. package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
  125. package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
  126. package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
  127. package/fesm2022/cmat-pipes-group-by.mjs +50 -38
  128. package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
  129. package/fesm2022/cmat-pipes-keys.mjs +44 -31
  130. package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
  131. package/fesm2022/cmat-pipes-secure.mjs +60 -49
  132. package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
  133. package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
  134. package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
  135. package/fesm2022/cmat-reports.mjs +2761 -0
  136. package/fesm2022/cmat-reports.mjs.map +1 -0
  137. package/fesm2022/cmat-services-alert.mjs +249 -277
  138. package/fesm2022/cmat-services-alert.mjs.map +1 -1
  139. package/fesm2022/cmat-services-config.mjs +110 -81
  140. package/fesm2022/cmat-services-config.mjs.map +1 -1
  141. package/fesm2022/cmat-services-confirmation.mjs +184 -73
  142. package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
  143. package/fesm2022/cmat-services-data.mjs +136 -125
  144. package/fesm2022/cmat-services-data.mjs.map +1 -1
  145. package/fesm2022/cmat-services-export-as.mjs +165 -183
  146. package/fesm2022/cmat-services-export-as.mjs.map +1 -1
  147. package/fesm2022/cmat-services-loading.mjs +116 -95
  148. package/fesm2022/cmat-services-loading.mjs.map +1 -1
  149. package/fesm2022/cmat-services-local-storage.mjs +75 -66
  150. package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
  151. package/fesm2022/cmat-services-media-watcher.mjs +69 -64
  152. package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
  153. package/fesm2022/cmat-services-platform.mjs +48 -45
  154. package/fesm2022/cmat-services-platform.mjs.map +1 -1
  155. package/fesm2022/cmat-services-print.mjs +984 -1109
  156. package/fesm2022/cmat-services-print.mjs.map +1 -1
  157. package/fesm2022/cmat-services-splash-screen.mjs +53 -38
  158. package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
  159. package/fesm2022/cmat-services-title.mjs +57 -47
  160. package/fesm2022/cmat-services-title.mjs.map +1 -1
  161. package/fesm2022/cmat-services-translation.mjs +79 -68
  162. package/fesm2022/cmat-services-translation.mjs.map +1 -1
  163. package/fesm2022/cmat-services-utils.mjs +424 -517
  164. package/fesm2022/cmat-services-utils.mjs.map +1 -1
  165. package/fesm2022/cmat-validators.mjs +23 -33
  166. package/fesm2022/cmat-validators.mjs.map +1 -1
  167. package/fesm2022/cmat-version.mjs +12 -16
  168. package/fesm2022/cmat-version.mjs.map +1 -1
  169. package/fesm2022/cmat.mjs +39805 -22511
  170. package/fesm2022/cmat.mjs.map +1 -1
  171. package/package.json +5 -1
  172. package/types/cmat-components-adapter.d.ts +145 -156
  173. package/types/cmat-components-breadcrumb.d.ts +108 -86
  174. package/types/cmat-components-card.d.ts +34 -18
  175. package/types/cmat-components-carousel.d.ts +251 -134
  176. package/types/cmat-components-cascade.d.ts +158 -117
  177. package/types/cmat-components-chip-input.d.ts +105 -71
  178. package/types/cmat-components-code-editor.d.ts +59 -34
  179. package/types/cmat-components-color-picker.d.ts +378 -236
  180. package/types/cmat-components-custom-formly.d.ts +776 -814
  181. package/types/cmat-components-data-picker.d.ts +502 -360
  182. package/types/cmat-components-date-range.d.ts +106 -77
  183. package/types/cmat-components-date-time-display.d.ts +36 -13
  184. package/types/cmat-components-drawer.d.ts +91 -61
  185. package/types/cmat-components-empty-state.d.ts +47 -17
  186. package/types/cmat-components-file-preview.d.ts +42 -14
  187. package/types/cmat-components-filter-toolbar.d.ts +57 -25
  188. package/types/cmat-components-form-actions.d.ts +18 -10
  189. package/types/cmat-components-fullscreen.d.ts +21 -13
  190. package/types/cmat-components-highlight.d.ts +33 -26
  191. package/types/cmat-components-image-viewer.d.ts +119 -58
  192. package/types/cmat-components-inline-loading.d.ts +24 -11
  193. package/types/cmat-components-json-editor.d.ts +39 -28
  194. package/types/cmat-components-knob-input.d.ts +172 -101
  195. package/types/cmat-components-loading-overlay.d.ts +8 -11
  196. package/types/cmat-components-masonry.d.ts +27 -14
  197. package/types/cmat-components-material-color-picker.d.ts +56 -42
  198. package/types/cmat-components-material-datetimepicker.d.ts +817 -454
  199. package/types/cmat-components-navigation.d.ts +295 -221
  200. package/types/cmat-components-opt-input.d.ts +111 -90
  201. package/types/cmat-components-org-chart.d.ts +53 -35
  202. package/types/cmat-components-page-header.d.ts +37 -14
  203. package/types/cmat-components-pagination.d.ts +144 -107
  204. package/types/cmat-components-password-strength.d.ts +197 -86
  205. package/types/cmat-components-popover.d.ts +264 -166
  206. package/types/cmat-components-progress-bar.d.ts +17 -14
  207. package/types/cmat-components-qrcode.d.ts +111 -42
  208. package/types/cmat-components-rating.d.ts +105 -59
  209. package/types/cmat-components-rich-text-editor.d.ts +39 -16
  210. package/types/cmat-components-select-search.d.ts +195 -99
  211. package/types/cmat-components-select-table.d.ts +241 -142
  212. package/types/cmat-components-select-tree.d.ts +185 -118
  213. package/types/cmat-components-skeleton.d.ts +55 -32
  214. package/types/cmat-components-speed-dial.d.ts +86 -61
  215. package/types/cmat-components-status-tag.d.ts +42 -24
  216. package/types/cmat-components-table-toolbar.d.ts +30 -12
  217. package/types/cmat-components-timeline.d.ts +83 -51
  218. package/types/cmat-components-toast.d.ts +84 -85
  219. package/types/cmat-components-transfer-picker.d.ts +228 -181
  220. package/types/cmat-components-treetable.d.ts +63 -39
  221. package/types/cmat-components-upload.d.ts +205 -106
  222. package/types/cmat-components-x6-angular-shape.d.ts +29 -37
  223. package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
  224. package/types/cmat-directives-arrow-cursor.d.ts +55 -35
  225. package/types/cmat-directives-autofocus.d.ts +8 -11
  226. package/types/cmat-directives-data-exporter.d.ts +71 -40
  227. package/types/cmat-directives-debounce.d.ts +31 -28
  228. package/types/cmat-directives-digit-only.d.ts +90 -53
  229. package/types/cmat-directives-equal-validator.d.ts +11 -14
  230. package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
  231. package/types/cmat-lib-mock-api.d.ts +46 -55
  232. package/types/cmat-pipes-bytes.d.ts +7 -10
  233. package/types/cmat-pipes-date-format.d.ts +7 -10
  234. package/types/cmat-pipes-find-by-key.d.ts +8 -12
  235. package/types/cmat-pipes-group-by.d.ts +11 -15
  236. package/types/cmat-pipes-keys.d.ts +10 -13
  237. package/types/cmat-pipes-secure.d.ts +14 -17
  238. package/types/cmat-pipes-uppercase.d.ts +7 -10
  239. package/types/cmat-reports.d.ts +1138 -0
  240. package/types/cmat-services-alert.d.ts +80 -87
  241. package/types/cmat-services-config.d.ts +37 -43
  242. package/types/cmat-services-confirmation.d.ts +31 -37
  243. package/types/cmat-services-data.d.ts +18 -21
  244. package/types/cmat-services-export-as.d.ts +28 -33
  245. package/types/cmat-services-loading.d.ts +27 -31
  246. package/types/cmat-services-local-storage.d.ts +17 -21
  247. package/types/cmat-services-media-watcher.d.ts +14 -18
  248. package/types/cmat-services-platform.d.ts +8 -11
  249. package/types/cmat-services-print.d.ts +97 -102
  250. package/types/cmat-services-splash-screen.d.ts +11 -14
  251. package/types/cmat-services-title.d.ts +9 -12
  252. package/types/cmat-services-translation.d.ts +19 -22
  253. package/types/cmat-services-utils.d.ts +76 -80
  254. package/types/cmat-validators.d.ts +5 -8
  255. package/types/cmat-version.d.ts +8 -10
  256. package/types/cmat.d.ts +7551 -5204
@@ -1,520 +1,427 @@
1
- import { HttpHeaders, HttpResponseBase, HttpResponse, HttpErrorResponse } from '@angular/common/http';
2
- import * as i0 from '@angular/core';
3
- import { InjectionToken, Injectable } from '@angular/core';
4
- import { CMAT_VERSION } from 'cmat/version';
5
- import AES from 'crypto-js/aes';
6
- import CryptoJSCore from 'crypto-js/core';
7
- import Base64 from 'crypto-js/enc-base64';
8
- import Hex from 'crypto-js/enc-hex';
9
- import UTF8 from 'crypto-js/enc-utf8';
10
- import Pkcs7 from 'crypto-js/pad-pkcs7';
11
- import dayjs from 'dayjs';
12
- import { isUndefined } from 'lodash-es';
13
- import { throwError } from 'rxjs';
14
-
15
- const CMAT_CRYPTO_CONFIG = new InjectionToken('CMAT_CRYPTO_CONFIG', {
16
- factory: () => ({
17
- key: '14789632236987411478963223698741',
18
- iv: '1478963223698741',
19
- specialParam: 'partymanageApi'
20
- })
21
- });
1
+ import { HttpErrorResponse, HttpHeaders, HttpResponse, HttpResponseBase } from "@angular/common/http";
2
+ import * as i0 from "@angular/core";
3
+ import { Injectable, InjectionToken } from "@angular/core";
4
+ import { CMAT_VERSION } from "cmat/version";
5
+ import AES from "crypto-js/aes";
6
+ import CryptoJSCore from "crypto-js/core";
7
+ import Base64 from "crypto-js/enc-base64";
8
+ import Hex from "crypto-js/enc-hex";
9
+ import UTF8 from "crypto-js/enc-utf8";
10
+ import Pkcs7 from "crypto-js/pad-pkcs7";
11
+ import dayjs from "dayjs";
12
+ import { isUndefined } from "lodash-es";
13
+ import { throwError } from "rxjs";
14
+ const CMAT_CRYPTO_CONFIG = new InjectionToken("CMAT_CRYPTO_CONFIG", { factory: () => ({
15
+ key: "14789632236987411478963223698741",
16
+ iv: "1478963223698741",
17
+ specialParam: "partymanageApi"
18
+ }) });
22
19
  function initializeCmatUtilsConfig(config) {
23
- CmatUtilsService.setCryptoConfig(config);
20
+ CmatUtilsService.setCryptoConfig(config);
24
21
  }
25
- class CmatUtilsService {
26
- static { this.captionAndMessageSeparator = ':'; }
27
- static { this.noNetworkMessageCaption = '无网络'; }
28
- static { this.noNetworkMessageDetail = '无法连接服务器'; }
29
- static { this.accessDeniedMessageCaption = '拒绝访问!'; }
30
- static { this.accessDeniedMessageDetail = ''; }
31
- static { this._key = null; }
32
- static { this._iv = null; }
33
- static { this._specialParam = null; }
34
- static get key() {
35
- return this._key;
36
- }
37
- static get iv() {
38
- return this._iv;
39
- }
40
- static get specialParam() {
41
- return this._specialParam;
42
- }
43
- get exactMatchOptions() {
44
- return {
45
- paths: 'exact',
46
- fragment: 'ignored',
47
- matrixParams: 'ignored',
48
- queryParams: 'exact'
49
- };
50
- }
51
- get subsetMatchOptions() {
52
- return {
53
- paths: 'subset',
54
- fragment: 'ignored',
55
- matrixParams: 'ignored',
56
- queryParams: 'subset'
57
- };
58
- }
59
- static setCryptoConfig(config) {
60
- this._key = UTF8.parse(config.key);
61
- this._iv = UTF8.parse(config.iv);
62
- this._specialParam = UTF8.parse(config.specialParam);
63
- }
64
- static getRequestHeaders() {
65
- return new HttpHeaders()
66
- .append('Content-Type', 'application/json')
67
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
68
- .append('App-Version', CMAT_VERSION);
69
- }
70
- static getRequestIdempotentHeaders() {
71
- return new HttpHeaders()
72
- .append('Content-Type', 'application/json')
73
- .append('X-Request-ID', CmatUtilsService.newGuid())
74
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
75
- .append('App-Version', CMAT_VERSION);
76
- }
77
- static getRequestBypassHeaders() {
78
- return new HttpHeaders()
79
- .append('Content-Type', 'application/json')
80
- .append('bypass', 'true')
81
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
82
- .append('App-Version', CMAT_VERSION);
83
- }
84
- static getRequestIdempotentBypassHeaders() {
85
- return new HttpHeaders()
86
- .append('Content-Type', 'application/json')
87
- .append('X-Request-ID', CmatUtilsService.newGuid())
88
- .append('bypass', 'true')
89
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
90
- .append('App-Version', CMAT_VERSION);
91
- }
92
- static getRequestCryptoHeaders(params) {
93
- return new HttpHeaders()
94
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
95
- .append('App-Version', this.getEncryptData(params).toString());
96
- }
97
- static getRequestCryptoBypassHeaders(params) {
98
- return new HttpHeaders()
99
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
100
- .append('bypass', 'true')
101
- .append('App-Version', this.getEncryptData(params).toString());
102
- }
103
- static getRequestCryptoIdempotentHeaders(params) {
104
- return new HttpHeaders()
105
- .append('X-Request-ID', CmatUtilsService.newGuid())
106
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
107
- .append('App-Version', this.getEncryptData(params).toString());
108
- }
109
- static getRequestCryptoIdempotentBypassHeaders(params) {
110
- return new HttpHeaders()
111
- .append('X-Request-ID', CmatUtilsService.newGuid())
112
- .append('Accept', `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`)
113
- .append('bypass', 'true')
114
- .append('App-Version', this.getEncryptData(params).toString());
115
- }
116
- static getEncryptData(data) {
117
- const src = UTF8.parse(UTF8.stringify(this.specialParam) + data);
118
- return AES.encrypt(src, this.key, {
119
- iv: this.iv,
120
- mode: CryptoJSCore.mode.CBC,
121
- padding: Pkcs7
122
- }).ciphertext.toString();
123
- }
124
- static getDecryptData(data) {
125
- const encryptedHexStr = Hex.parse(data);
126
- return AES.decrypt(Base64.stringify(encryptedHexStr), this.key, {
127
- iv: this.iv,
128
- mode: CryptoJSCore.mode.CBC,
129
- padding: Pkcs7
130
- }).toString(UTF8).toString();
131
- }
132
- static handleError(error) {
133
- if (error instanceof ErrorEvent) {
134
- console.error('Client side network error occurred:', error.message);
135
- }
136
- else if (typeof error === 'object' && error !== null && 'status' in error) {
137
- const httpError = error;
138
- console.error('Backend - ' +
139
- `status: ${String(httpError.status)}, ` +
140
- `message: ${String(httpError.error)}`);
141
- }
142
- else {
143
- console.error('Unknown error occurred:', String(error));
144
- }
145
- return throwError(() => error ?? 'server error');
146
- }
147
- static getHttpResponseMessage(data) {
148
- const responses = [];
149
- if (data instanceof HttpResponseBase) {
150
- if (this.checkNoNetwork(data)) {
151
- responses.push(`${this.noNetworkMessageCaption}${this.captionAndMessageSeparator} ${this.noNetworkMessageDetail}`);
152
- }
153
- else {
154
- const responseObject = this.getResponseBody(data);
155
- if (responseObject && typeof responseObject === 'object') {
156
- for (const key in responseObject) {
157
- if (Object.prototype.hasOwnProperty.call(responseObject, key)) {
158
- const value = responseObject[key];
159
- const stringValue = typeof value === 'object' && value !== null ? JSON.stringify(value) : String(value);
160
- if (key) {
161
- responses.push(`${key}${this.captionAndMessageSeparator} ${stringValue}`);
162
- }
163
- else if (value) {
164
- responses.push(stringValue);
165
- }
166
- }
167
- }
168
- }
169
- }
170
- const responseBody = this.getResponseBody(data);
171
- if (!responses.length && responseBody != null) {
172
- if (typeof responseBody === 'object') {
173
- responses.push(JSON.stringify(responseBody));
174
- }
175
- else {
176
- responses.push(String(responseBody));
177
- }
178
- }
179
- }
180
- if (!responses.length) {
181
- responses.push(typeof data === 'object' ? JSON.stringify(data) : String(data));
182
- }
183
- if (data instanceof HttpResponseBase && this.checkAccessDenied(data)) {
184
- responses.splice(0, 0, `${this.accessDeniedMessageCaption}${this.captionAndMessageSeparator} ${this.accessDeniedMessageDetail}`);
185
- }
186
- return responses;
187
- }
188
- static findHttpResponseMessage(messageToFind, data, seachInCaptionOnly = true, includeCaptionInResult = false) {
189
- const searchString = messageToFind.toLowerCase();
190
- const httpMessages = this.getHttpResponseMessage(data);
191
- for (const message of httpMessages) {
192
- const fullMessage = CmatUtilsService.splitInTwo(message, this.captionAndMessageSeparator);
193
- if (fullMessage.firstPart?.toLowerCase().includes(searchString)) {
194
- return includeCaptionInResult ? message : fullMessage.secondPart ?? fullMessage.firstPart;
195
- }
196
- }
197
- if (!seachInCaptionOnly) {
198
- for (const message of httpMessages) {
199
- if (message.toLowerCase().includes(searchString)) {
200
- if (includeCaptionInResult) {
201
- return message;
202
- }
203
- else {
204
- const fullMessage = CmatUtilsService.splitInTwo(message, this.captionAndMessageSeparator);
205
- return fullMessage.secondPart ?? fullMessage.firstPart;
206
- }
207
- }
208
- }
209
- }
210
- return null;
211
- }
212
- static getResponseBody(response) {
213
- if (response instanceof HttpResponse) {
214
- return response.body;
215
- }
216
- if (response instanceof HttpErrorResponse) {
217
- return response.error ?? response.message;
218
- }
219
- return null;
220
- }
221
- static checkNoNetwork(response) {
222
- if (response instanceof HttpResponseBase) {
223
- return response.status === 0;
224
- }
225
- return false;
226
- }
227
- static checkAccessDenied(response) {
228
- if (response instanceof HttpResponseBase) {
229
- return response.status === 403;
230
- }
231
- return false;
232
- }
233
- static checkNotFound(response) {
234
- if (response instanceof HttpResponseBase) {
235
- return response.status === 404;
236
- }
237
- return false;
238
- }
239
- static checkIsLocalHost(url, base) {
240
- if (url) {
241
- const location = new URL(url, base);
242
- return location.hostname === 'localhost' || location.hostname === '127.0.0.1';
243
- }
244
- return false;
245
- }
246
- static getQueryParamsFromString(paramString) {
247
- if (!paramString) {
248
- return null;
249
- }
250
- const params = {};
251
- for (const param of paramString.split('&')) {
252
- const keyValue = CmatUtilsService.splitInTwo(param, '=');
253
- params[keyValue.firstPart] = keyValue.secondPart;
254
- }
255
- return params;
256
- }
257
- static splitInTwo(text, separator) {
258
- const separatorIndex = separator && text.includes(separator) ? text.indexOf(separator) : -1;
259
- if (separatorIndex === -1) {
260
- return { firstPart: text, secondPart: null };
261
- }
262
- const part1 = text.substring(0, separatorIndex).trim();
263
- const part2 = text.substring(separatorIndex + 1).trim();
264
- return { firstPart: part1, secondPart: part2 };
265
- }
266
- static safeStringify(object) {
267
- let result;
268
- try {
269
- result = JSON.stringify(object);
270
- return result;
271
- }
272
- catch { /* empty */ }
273
- const simpleObject = {};
274
- for (const prop in object) {
275
- if (!Object.prototype.hasOwnProperty.call(object, prop)) {
276
- continue;
277
- }
278
- const value = object[prop];
279
- if (typeof value === 'object') {
280
- continue;
281
- }
282
- if (typeof value === 'function') {
283
- continue;
284
- }
285
- simpleObject[prop] = value;
286
- }
287
- result = '[***Sanitized Object***]: ' + JSON.stringify(simpleObject);
288
- return result;
289
- }
290
- static jsonTryParse(value) {
291
- try {
292
- return JSON.parse(value);
293
- }
294
- catch {
295
- if (isUndefined(value)) {
296
- return void 0;
297
- }
298
- return value;
299
- }
300
- }
301
- static capitalizeFirstLetter(text) {
302
- if (text) {
303
- return text.charAt(0).toUpperCase() + text.slice(1);
304
- }
305
- else {
306
- return text;
307
- }
308
- }
309
- static toTitleCase(text) {
310
- return text.replace(/\w\S*/g, (subString) => subString.charAt(0).toUpperCase() + subString.substring(1).toLowerCase());
311
- }
312
- static toLowerCase(items) {
313
- if (items instanceof Array) {
314
- const loweredRoles = items.map((item) => item.toLowerCase());
315
- return loweredRoles;
316
- }
317
- else if (typeof items === 'string') {
318
- return items.toLowerCase();
319
- }
320
- return void 0;
321
- }
322
- static uniqueId() {
323
- return this.randomNumber(1000000, 9000000).toString();
324
- }
325
- static randomNumber(min, max) {
326
- return Math.floor(Math.random() * (max - min + 1) + min);
327
- }
328
- static baseUrl() {
329
- let base;
330
- if (window.location.origin) {
331
- base = window.location.origin;
332
- }
333
- else {
334
- base = window.location.protocol + '//' + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
335
- }
336
- return base.replace(/\/$/, '');
337
- }
338
- static newGuid() {
339
- return crypto.randomUUID();
340
- }
341
- static testIsAbsoluteUrl(url) {
342
- const r = new RegExp('^(?:[a-z]+:)?//', 'i');
343
- return r.test(url);
344
- }
345
- static convertToAbsoluteUrl(url) {
346
- return CmatUtilsService.testIsAbsoluteUrl(url) ? url : '//' + url;
347
- }
348
- static urlBase64Decode(str) {
349
- let output = str.replace(/-/g, '+').replace(/_/g, '/');
350
- switch (output.length % 4) {
351
- case 0: {
352
- break;
353
- }
354
- case 2: {
355
- output += '==';
356
- break;
357
- }
358
- case 3: {
359
- output += '=';
360
- break;
361
- }
362
- }
363
- return this._base64DecodeUnicode(output);
364
- }
365
- static decodeToken(token) {
366
- const parts = token.split('.');
367
- if (parts.length !== 3) {
368
- throw new Error('JWT must have 3 parts');
369
- }
370
- const decoded = this.urlBase64Decode(parts[1]);
371
- if (!decoded) {
372
- throw new Error('Cannot decode the token');
373
- }
374
- return JSON.parse(decoded);
375
- }
376
- static getTokenExpirationDate(token) {
377
- const decoded = this.decodeToken(token);
378
- if (!Object.prototype.hasOwnProperty.call(decoded, 'exp')) {
379
- return null;
380
- }
381
- const date = new Date(0);
382
- date.setUTCSeconds(Number(decoded.exp));
383
- return date;
384
- }
385
- static isTokenExpired(token, offsetSeconds) {
386
- const date = this.getTokenExpirationDate(token);
387
- offsetSeconds = offsetSeconds ?? 0;
388
- if (date == null) {
389
- return false;
390
- }
391
- return !(date.valueOf() > (new Date().valueOf() + (offsetSeconds * 1000)));
392
- }
393
- static readAsDataURL(file) {
394
- return new Promise((resolve, reject) => {
395
- const reader = new FileReader();
396
- reader.onload = () => {
397
- resolve(reader.result);
398
- };
399
- reader.onerror = () => {
400
- reject(new Error('Failed to read file as Data URL'));
401
- };
402
- reader.readAsDataURL(file);
403
- });
404
- }
405
- static dataURIToBlob(dataURI) {
406
- const splitDataURI = dataURI.split(',');
407
- const byteString = splitDataURI[0].includes('base64') ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1]);
408
- const mimeString = splitDataURI[0].split(':')[1].split(';')[0];
409
- const ia = new Uint8Array(byteString.length);
410
- for (const [i, char] of [...byteString].entries()) {
411
- ia[i] = char.charCodeAt(0);
412
- }
413
- return new Blob([ia], { type: mimeString });
414
- }
415
- static getFileType(accept) {
416
- let fileType = 'file';
417
- switch (accept) {
418
- case 'image/jpeg':
419
- case 'image/jpg':
420
- fileType = 'jpg';
421
- break;
422
- case 'image/png':
423
- fileType = 'png';
424
- break;
425
- case 'text/csv':
426
- fileType = 'csv';
427
- break;
428
- case 'image/gif':
429
- fileType = 'gif';
430
- break;
431
- case 'application/msword':
432
- case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
433
- fileType = 'word';
434
- break;
435
- case 'application/vnd.ms-excel':
436
- case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
437
- fileType = 'excel';
438
- break;
439
- case 'application/pdf':
440
- fileType = 'pdf';
441
- break;
442
- case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
443
- case 'application/vnd.ms-powerpoint':
444
- fileType = 'ppt';
445
- break;
446
- case 'text/plain':
447
- fileType = 'text';
448
- break;
449
- case 'video/mpeg':
450
- case 'video/mp4':
451
- case 'audio/mp4':
452
- fileType = 'video';
453
- break;
454
- case 'application/zip':
455
- fileType = 'zip';
456
- break;
457
- }
458
- return fileType;
459
- }
460
- static isDateString(value) {
461
- if (!value || (typeof value !== 'string' && typeof value !== 'number')) {
462
- return false;
463
- }
464
- const stringValue = String(value);
465
- if (/^\d+$/.test(stringValue)) {
466
- return false;
467
- }
468
- const parsedDate = Date.parse(stringValue);
469
- if (isNaN(parsedDate)) {
470
- return false;
471
- }
472
- return dayjs(stringValue).isValid();
473
- }
474
- static transformObjectsForExport(jsonObjects, columns) {
475
- return jsonObjects.map((jsonObject) => {
476
- const result = {};
477
- columns.forEach((info) => {
478
- const parts = info.code.split('.');
479
- const lastPart = parts.pop();
480
- let currentValue = jsonObject;
481
- parts.forEach((part) => {
482
- if (typeof currentValue === 'object' && currentValue !== null && Object.prototype.hasOwnProperty.call(currentValue, part)) {
483
- currentValue = currentValue[part];
484
- }
485
- else {
486
- currentValue = undefined;
487
- }
488
- });
489
- result[info.code] = currentValue && typeof currentValue === 'object' && Object.prototype.hasOwnProperty.call(currentValue, lastPart) ? currentValue[lastPart] : '';
490
- });
491
- return result;
492
- });
493
- }
494
- static _base64DecodeUnicode(str) {
495
- return decodeURIComponent(Array.prototype.map.call(atob(str), (c) => '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)).join(''));
496
- }
497
- randomId(stringLength = 10) {
498
- const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
499
- let id = '';
500
- for (let i = 0; i < stringLength; i++) {
501
- id += chars.charAt(Math.floor(Math.random() * chars.length));
502
- }
503
- return id;
504
- }
505
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUtilsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
506
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUtilsService, providedIn: 'root' }); }
507
- }
508
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.2.0", ngImport: i0, type: CmatUtilsService, decorators: [{
509
- type: Injectable,
510
- args: [{
511
- providedIn: 'root'
512
- }]
513
- }] });
514
-
515
- /**
516
- * Generated bundle index. Do not edit.
517
- */
518
-
22
+ var CmatUtilsService = class CmatUtilsService {
23
+ static {
24
+ this.captionAndMessageSeparator = ":";
25
+ }
26
+ static {
27
+ this.noNetworkMessageCaption = "无网络";
28
+ }
29
+ static {
30
+ this.noNetworkMessageDetail = "无法连接服务器";
31
+ }
32
+ static {
33
+ this.accessDeniedMessageCaption = "拒绝访问!";
34
+ }
35
+ static {
36
+ this.accessDeniedMessageDetail = "";
37
+ }
38
+ static {
39
+ this._key = null;
40
+ }
41
+ static {
42
+ this._iv = null;
43
+ }
44
+ static {
45
+ this._specialParam = null;
46
+ }
47
+ static get key() {
48
+ return this._key;
49
+ }
50
+ static get iv() {
51
+ return this._iv;
52
+ }
53
+ static get specialParam() {
54
+ return this._specialParam;
55
+ }
56
+ get exactMatchOptions() {
57
+ return {
58
+ paths: "exact",
59
+ fragment: "ignored",
60
+ matrixParams: "ignored",
61
+ queryParams: "exact"
62
+ };
63
+ }
64
+ get subsetMatchOptions() {
65
+ return {
66
+ paths: "subset",
67
+ fragment: "ignored",
68
+ matrixParams: "ignored",
69
+ queryParams: "subset"
70
+ };
71
+ }
72
+ static setCryptoConfig(config) {
73
+ this._key = UTF8.parse(config.key);
74
+ this._iv = UTF8.parse(config.iv);
75
+ this._specialParam = UTF8.parse(config.specialParam);
76
+ }
77
+ static getRequestHeaders() {
78
+ return new HttpHeaders().append("Content-Type", "application/json").append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
79
+ }
80
+ static getRequestIdempotentHeaders() {
81
+ return new HttpHeaders().append("Content-Type", "application/json").append("X-Request-ID", CmatUtilsService.newGuid()).append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
82
+ }
83
+ static getRequestBypassHeaders() {
84
+ return new HttpHeaders().append("Content-Type", "application/json").append("bypass", "true").append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
85
+ }
86
+ static getRequestIdempotentBypassHeaders() {
87
+ return new HttpHeaders().append("Content-Type", "application/json").append("X-Request-ID", CmatUtilsService.newGuid()).append("bypass", "true").append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", CMAT_VERSION);
88
+ }
89
+ static getRequestCryptoHeaders(params) {
90
+ return new HttpHeaders().append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", this.getEncryptData(params).toString());
91
+ }
92
+ static getRequestCryptoBypassHeaders(params) {
93
+ return new HttpHeaders().append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("bypass", "true").append("App-Version", this.getEncryptData(params).toString());
94
+ }
95
+ static getRequestCryptoIdempotentHeaders(params) {
96
+ return new HttpHeaders().append("X-Request-ID", CmatUtilsService.newGuid()).append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("App-Version", this.getEncryptData(params).toString());
97
+ }
98
+ static getRequestCryptoIdempotentBypassHeaders(params) {
99
+ return new HttpHeaders().append("X-Request-ID", CmatUtilsService.newGuid()).append("Accept", `application/vnd.iman.v${CMAT_VERSION}+json, application/json, text/plain, */*`).append("bypass", "true").append("App-Version", this.getEncryptData(params).toString());
100
+ }
101
+ static getEncryptData(data) {
102
+ const src = UTF8.parse(UTF8.stringify(this.specialParam) + data);
103
+ return AES.encrypt(src, this.key, {
104
+ iv: this.iv,
105
+ mode: CryptoJSCore.mode.CBC,
106
+ padding: Pkcs7
107
+ }).ciphertext.toString();
108
+ }
109
+ static getDecryptData(data) {
110
+ const encryptedHexStr = Hex.parse(data);
111
+ return AES.decrypt(Base64.stringify(encryptedHexStr), this.key, {
112
+ iv: this.iv,
113
+ mode: CryptoJSCore.mode.CBC,
114
+ padding: Pkcs7
115
+ }).toString(UTF8).toString();
116
+ }
117
+ static handleError(error) {
118
+ if (error instanceof ErrorEvent) console.error("Client side network error occurred:", error.message);
119
+ else if (typeof error === "object" && error !== null && "status" in error) {
120
+ const httpError = error;
121
+ console.error(`Backend - status: ${String(httpError.status)}, message: ${String(httpError.error)}`);
122
+ } else console.error("Unknown error occurred:", String(error));
123
+ return throwError(() => error ?? "server error");
124
+ }
125
+ static getHttpResponseMessage(data) {
126
+ const responses = [];
127
+ if (data instanceof HttpResponseBase) {
128
+ if (this.checkNoNetwork(data)) responses.push(`${this.noNetworkMessageCaption}${this.captionAndMessageSeparator} ${this.noNetworkMessageDetail}`);
129
+ else {
130
+ const responseObject = this.getResponseBody(data);
131
+ if (responseObject && typeof responseObject === "object") {
132
+ for (const key in responseObject) if (Object.prototype.hasOwnProperty.call(responseObject, key)) {
133
+ const value = responseObject[key];
134
+ const stringValue = typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
135
+ if (key) responses.push(`${key}${this.captionAndMessageSeparator} ${stringValue}`);
136
+ else if (value) responses.push(stringValue);
137
+ }
138
+ }
139
+ }
140
+ const responseBody = this.getResponseBody(data);
141
+ if (!responses.length && responseBody != null) {
142
+ if (typeof responseBody === "object") responses.push(JSON.stringify(responseBody));
143
+ else responses.push(String(responseBody));
144
+ }
145
+ }
146
+ if (!responses.length) responses.push(typeof data === "object" ? JSON.stringify(data) : String(data));
147
+ if (data instanceof HttpResponseBase && this.checkAccessDenied(data)) responses.splice(0, 0, `${this.accessDeniedMessageCaption}${this.captionAndMessageSeparator} ${this.accessDeniedMessageDetail}`);
148
+ return responses;
149
+ }
150
+ static findHttpResponseMessage(messageToFind, data, seachInCaptionOnly = true, includeCaptionInResult = false) {
151
+ const searchString = messageToFind.toLowerCase();
152
+ const httpMessages = this.getHttpResponseMessage(data);
153
+ for (const message of httpMessages) {
154
+ const fullMessage = CmatUtilsService.splitInTwo(message, this.captionAndMessageSeparator);
155
+ if (fullMessage.firstPart?.toLowerCase().includes(searchString)) return includeCaptionInResult ? message : fullMessage.secondPart ?? fullMessage.firstPart;
156
+ }
157
+ if (!seachInCaptionOnly) {
158
+ for (const message of httpMessages) if (message.toLowerCase().includes(searchString)) {
159
+ if (includeCaptionInResult) return message;
160
+ else {
161
+ const fullMessage = CmatUtilsService.splitInTwo(message, this.captionAndMessageSeparator);
162
+ return fullMessage.secondPart ?? fullMessage.firstPart;
163
+ }
164
+ }
165
+ }
166
+ return null;
167
+ }
168
+ static getResponseBody(response) {
169
+ if (response instanceof HttpResponse) return response.body;
170
+ if (response instanceof HttpErrorResponse) return response.error ?? response.message;
171
+ return null;
172
+ }
173
+ static checkNoNetwork(response) {
174
+ if (response instanceof HttpResponseBase) return response.status === 0;
175
+ return false;
176
+ }
177
+ static checkAccessDenied(response) {
178
+ if (response instanceof HttpResponseBase) return response.status === 403;
179
+ return false;
180
+ }
181
+ static checkNotFound(response) {
182
+ if (response instanceof HttpResponseBase) return response.status === 404;
183
+ return false;
184
+ }
185
+ static checkIsLocalHost(url, base) {
186
+ if (url) {
187
+ const location = new URL(url, base);
188
+ return location.hostname === "localhost" || location.hostname === "127.0.0.1";
189
+ }
190
+ return false;
191
+ }
192
+ static getQueryParamsFromString(paramString) {
193
+ if (!paramString) return null;
194
+ const params = {};
195
+ for (const param of paramString.split("&")) {
196
+ const keyValue = CmatUtilsService.splitInTwo(param, "=");
197
+ params[keyValue.firstPart] = keyValue.secondPart;
198
+ }
199
+ return params;
200
+ }
201
+ static splitInTwo(text, separator) {
202
+ const separatorIndex = separator && text.includes(separator) ? text.indexOf(separator) : -1;
203
+ if (separatorIndex === -1) return {
204
+ firstPart: text,
205
+ secondPart: null
206
+ };
207
+ return {
208
+ firstPart: text.substring(0, separatorIndex).trim(),
209
+ secondPart: text.substring(separatorIndex + 1).trim()
210
+ };
211
+ }
212
+ static safeStringify(object) {
213
+ let result;
214
+ try {
215
+ result = JSON.stringify(object);
216
+ return result;
217
+ } catch {}
218
+ const simpleObject = {};
219
+ for (const prop in object) {
220
+ if (!Object.prototype.hasOwnProperty.call(object, prop)) continue;
221
+ const value = object[prop];
222
+ if (typeof value === "object") continue;
223
+ if (typeof value === "function") continue;
224
+ simpleObject[prop] = value;
225
+ }
226
+ result = "[***Sanitized Object***]: " + JSON.stringify(simpleObject);
227
+ return result;
228
+ }
229
+ static jsonTryParse(value) {
230
+ try {
231
+ return JSON.parse(value);
232
+ } catch {
233
+ if (isUndefined(value)) return;
234
+ return value;
235
+ }
236
+ }
237
+ static capitalizeFirstLetter(text) {
238
+ if (text) return text.charAt(0).toUpperCase() + text.slice(1);
239
+ else return text;
240
+ }
241
+ static toTitleCase(text) {
242
+ return text.replace(/\w\S*/g, (subString) => subString.charAt(0).toUpperCase() + subString.substring(1).toLowerCase());
243
+ }
244
+ static toLowerCase(items) {
245
+ if (items instanceof Array) return items.map((item) => item.toLowerCase());
246
+ else if (typeof items === "string") return items.toLowerCase();
247
+ }
248
+ static uniqueId() {
249
+ return this.randomNumber(1e6, 9e6).toString();
250
+ }
251
+ static randomNumber(min, max) {
252
+ return Math.floor(Math.random() * (max - min + 1) + min);
253
+ }
254
+ static baseUrl() {
255
+ let base;
256
+ if (window.location.origin) base = window.location.origin;
257
+ else base = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ":" + window.location.port : "");
258
+ return base.replace(/\/$/, "");
259
+ }
260
+ static newGuid() {
261
+ return crypto.randomUUID();
262
+ }
263
+ static testIsAbsoluteUrl(url) {
264
+ return (/* @__PURE__ */ new RegExp("^(?:[a-z]+:)?//", "i")).test(url);
265
+ }
266
+ static convertToAbsoluteUrl(url) {
267
+ return CmatUtilsService.testIsAbsoluteUrl(url) ? url : "//" + url;
268
+ }
269
+ static urlBase64Decode(str) {
270
+ let output = str.replace(/-/g, "+").replace(/_/g, "/");
271
+ switch (output.length % 4) {
272
+ case 0: break;
273
+ case 2:
274
+ output += "==";
275
+ break;
276
+ case 3: output += "=";
277
+ }
278
+ return this._base64DecodeUnicode(output);
279
+ }
280
+ static decodeToken(token) {
281
+ const parts = token.split(".");
282
+ if (parts.length !== 3) throw new Error("JWT must have 3 parts");
283
+ const decoded = this.urlBase64Decode(parts[1]);
284
+ if (!decoded) throw new Error("Cannot decode the token");
285
+ return JSON.parse(decoded);
286
+ }
287
+ static getTokenExpirationDate(token) {
288
+ const decoded = this.decodeToken(token);
289
+ if (!Object.prototype.hasOwnProperty.call(decoded, "exp")) return null;
290
+ const date = /* @__PURE__ */ new Date(0);
291
+ date.setUTCSeconds(Number(decoded.exp));
292
+ return date;
293
+ }
294
+ static isTokenExpired(token, offsetSeconds) {
295
+ const date = this.getTokenExpirationDate(token);
296
+ offsetSeconds = offsetSeconds ?? 0;
297
+ if (date == null) return false;
298
+ return !(date.valueOf() > (/* @__PURE__ */ new Date()).valueOf() + offsetSeconds * 1e3);
299
+ }
300
+ static readAsDataURL(file) {
301
+ return new Promise((resolve, reject) => {
302
+ const reader = new FileReader();
303
+ reader.onload = () => {
304
+ resolve(reader.result);
305
+ };
306
+ reader.onerror = () => {
307
+ reject(/* @__PURE__ */ new Error("Failed to read file as Data URL"));
308
+ };
309
+ reader.readAsDataURL(file);
310
+ });
311
+ }
312
+ static dataURIToBlob(dataURI) {
313
+ const splitDataURI = dataURI.split(",");
314
+ const byteString = splitDataURI[0].includes("base64") ? atob(splitDataURI[1]) : decodeURI(splitDataURI[1]);
315
+ const mimeString = splitDataURI[0].split(":")[1].split(";")[0];
316
+ const ia = new Uint8Array(byteString.length);
317
+ for (const [i, char] of [...byteString].entries()) ia[i] = char.charCodeAt(0);
318
+ return new Blob([ia], { type: mimeString });
319
+ }
320
+ static getFileType(accept) {
321
+ let fileType = "file";
322
+ switch (accept) {
323
+ case "image/jpeg":
324
+ case "image/jpg":
325
+ fileType = "jpg";
326
+ break;
327
+ case "image/png":
328
+ fileType = "png";
329
+ break;
330
+ case "text/csv":
331
+ fileType = "csv";
332
+ break;
333
+ case "image/gif":
334
+ fileType = "gif";
335
+ break;
336
+ case "application/msword":
337
+ case "application/vnd.openxmlformats-officedocument.wordprocessingml.document":
338
+ fileType = "word";
339
+ break;
340
+ case "application/vnd.ms-excel":
341
+ case "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
342
+ fileType = "excel";
343
+ break;
344
+ case "application/pdf":
345
+ fileType = "pdf";
346
+ break;
347
+ case "application/vnd.openxmlformats-officedocument.presentationml.presentation":
348
+ case "application/vnd.ms-powerpoint":
349
+ fileType = "ppt";
350
+ break;
351
+ case "text/plain":
352
+ fileType = "text";
353
+ break;
354
+ case "video/mpeg":
355
+ case "video/mp4":
356
+ case "audio/mp4":
357
+ fileType = "video";
358
+ break;
359
+ case "application/zip": fileType = "zip";
360
+ }
361
+ return fileType;
362
+ }
363
+ static isDateString(value) {
364
+ if (!value || typeof value !== "string" && typeof value !== "number") return false;
365
+ const stringValue = String(value);
366
+ if (/^\d+$/.test(stringValue)) return false;
367
+ if (isNaN(Date.parse(stringValue))) return false;
368
+ return dayjs(stringValue).isValid();
369
+ }
370
+ static transformObjectsForExport(jsonObjects, columns) {
371
+ return jsonObjects.map((jsonObject) => {
372
+ const result = {};
373
+ columns.forEach((info) => {
374
+ const parts = info.code.split(".");
375
+ const lastPart = parts.pop();
376
+ let currentValue = jsonObject;
377
+ parts.forEach((part) => {
378
+ if (typeof currentValue === "object" && currentValue !== null && Object.prototype.hasOwnProperty.call(currentValue, part)) currentValue = currentValue[part];
379
+ else currentValue = void 0;
380
+ });
381
+ result[info.code] = currentValue && typeof currentValue === "object" && Object.prototype.hasOwnProperty.call(currentValue, lastPart) ? currentValue[lastPart] : "";
382
+ });
383
+ return result;
384
+ });
385
+ }
386
+ static _base64DecodeUnicode(str) {
387
+ return decodeURIComponent(Array.prototype.map.call(atob(str), (c) => "%" + ("00" + c.charCodeAt(0).toString(16)).slice(-2)).join(""));
388
+ }
389
+ randomId(stringLength = 10) {
390
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
391
+ let id = "";
392
+ for (let i = 0; i < stringLength; i++) id += chars.charAt(Math.floor(Math.random() * 62));
393
+ return id;
394
+ }
395
+ static {
396
+ this.ɵfac = i0.ɵɵngDeclareFactory({
397
+ minVersion: "12.0.0",
398
+ version: "22.2.3",
399
+ ngImport: i0,
400
+ type: CmatUtilsService,
401
+ deps: [],
402
+ target: i0.ɵɵFactoryTarget.Injectable
403
+ });
404
+ }
405
+ static {
406
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
407
+ minVersion: "12.0.0",
408
+ version: "22.2.3",
409
+ ngImport: i0,
410
+ type: CmatUtilsService,
411
+ providedIn: "root"
412
+ });
413
+ }
414
+ };
415
+ i0.ɵɵngDeclareClassMetadata({
416
+ minVersion: "12.0.0",
417
+ version: "22.2.3",
418
+ ngImport: i0,
419
+ type: CmatUtilsService,
420
+ decorators: [{
421
+ type: Injectable,
422
+ args: [{ providedIn: "root" }]
423
+ }]
424
+ });
519
425
  export { CMAT_CRYPTO_CONFIG, CmatUtilsService, initializeCmatUtilsConfig };
520
- //# sourceMappingURL=cmat-services-utils.mjs.map
426
+
427
+ //# sourceMappingURL=cmat-services-utils.mjs.map