cmat 0.0.111 → 0.0.112
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.
- package/fesm2022/cmat-components-adapter.mjs +531 -536
- package/fesm2022/cmat-components-adapter.mjs.map +1 -1
- package/fesm2022/cmat-components-breadcrumb.mjs +521 -356
- package/fesm2022/cmat-components-breadcrumb.mjs.map +1 -1
- package/fesm2022/cmat-components-card.mjs +150 -42
- package/fesm2022/cmat-components-card.mjs.map +1 -1
- package/fesm2022/cmat-components-carousel.mjs +1120 -629
- package/fesm2022/cmat-components-carousel.mjs.map +1 -1
- package/fesm2022/cmat-components-cascade.mjs +861 -441
- package/fesm2022/cmat-components-cascade.mjs.map +1 -1
- package/fesm2022/cmat-components-chip-input.mjs +580 -335
- package/fesm2022/cmat-components-chip-input.mjs.map +1 -1
- package/fesm2022/cmat-components-code-editor.mjs +197 -105
- package/fesm2022/cmat-components-code-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-color-picker.mjs +1762 -825
- package/fesm2022/cmat-components-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-custom-formly.mjs +5196 -2531
- package/fesm2022/cmat-components-custom-formly.mjs.map +1 -1
- package/fesm2022/cmat-components-data-picker.mjs +1901 -1073
- package/fesm2022/cmat-components-data-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-date-range.mjs +701 -456
- package/fesm2022/cmat-components-date-range.mjs.map +1 -1
- package/fesm2022/cmat-components-date-time-display.mjs +137 -30
- package/fesm2022/cmat-components-date-time-display.mjs.map +1 -1
- package/fesm2022/cmat-components-drawer.mjs +410 -258
- package/fesm2022/cmat-components-drawer.mjs.map +1 -1
- package/fesm2022/cmat-components-empty-state.mjs +201 -41
- package/fesm2022/cmat-components-empty-state.mjs.map +1 -1
- package/fesm2022/cmat-components-file-preview.mjs +198 -35
- package/fesm2022/cmat-components-file-preview.mjs.map +1 -1
- package/fesm2022/cmat-components-filter-toolbar.mjs +320 -72
- package/fesm2022/cmat-components-filter-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-form-actions.mjs +102 -26
- package/fesm2022/cmat-components-form-actions.mjs.map +1 -1
- package/fesm2022/cmat-components-fullscreen.mjs +167 -47
- package/fesm2022/cmat-components-fullscreen.mjs.map +1 -1
- package/fesm2022/cmat-components-highlight.mjs +203 -112
- package/fesm2022/cmat-components-highlight.mjs.map +1 -1
- package/fesm2022/cmat-components-image-viewer.mjs +489 -215
- package/fesm2022/cmat-components-image-viewer.mjs.map +1 -1
- package/fesm2022/cmat-components-inline-loading.mjs +117 -27
- package/fesm2022/cmat-components-inline-loading.mjs.map +1 -1
- package/fesm2022/cmat-components-json-editor.mjs +276 -230
- package/fesm2022/cmat-components-json-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-knob-input.mjs +615 -420
- package/fesm2022/cmat-components-knob-input.mjs.map +1 -1
- package/fesm2022/cmat-components-loading-overlay.mjs +53 -25
- package/fesm2022/cmat-components-loading-overlay.mjs.map +1 -1
- package/fesm2022/cmat-components-masonry.mjs +120 -40
- package/fesm2022/cmat-components-masonry.mjs.map +1 -1
- package/fesm2022/cmat-components-material-color-picker.mjs +332 -155
- package/fesm2022/cmat-components-material-color-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-material-datetimepicker.mjs +4283 -2504
- package/fesm2022/cmat-components-material-datetimepicker.mjs.map +1 -1
- package/fesm2022/cmat-components-navigation.mjs +3080 -1404
- package/fesm2022/cmat-components-navigation.mjs.map +1 -1
- package/fesm2022/cmat-components-opt-input.mjs +540 -466
- package/fesm2022/cmat-components-opt-input.mjs.map +1 -1
- package/fesm2022/cmat-components-org-chart.mjs +528 -125
- package/fesm2022/cmat-components-org-chart.mjs.map +1 -1
- package/fesm2022/cmat-components-page-header.mjs +141 -32
- package/fesm2022/cmat-components-page-header.mjs.map +1 -1
- package/fesm2022/cmat-components-pagination.mjs +866 -534
- package/fesm2022/cmat-components-pagination.mjs.map +1 -1
- package/fesm2022/cmat-components-password-strength.mjs +873 -434
- package/fesm2022/cmat-components-password-strength.mjs.map +1 -1
- package/fesm2022/cmat-components-popover.mjs +1012 -731
- package/fesm2022/cmat-components-popover.mjs.map +1 -1
- package/fesm2022/cmat-components-progress-bar.mjs +98 -35
- package/fesm2022/cmat-components-progress-bar.mjs.map +1 -1
- package/fesm2022/cmat-components-qrcode.mjs +463 -287
- package/fesm2022/cmat-components-qrcode.mjs.map +1 -1
- package/fesm2022/cmat-components-rating.mjs +377 -203
- package/fesm2022/cmat-components-rating.mjs.map +1 -1
- package/fesm2022/cmat-components-rich-text-editor.mjs +153 -39
- package/fesm2022/cmat-components-rich-text-editor.mjs.map +1 -1
- package/fesm2022/cmat-components-select-search.mjs +926 -496
- package/fesm2022/cmat-components-select-search.mjs.map +1 -1
- package/fesm2022/cmat-components-select-table.mjs +1280 -842
- package/fesm2022/cmat-components-select-table.mjs.map +1 -1
- package/fesm2022/cmat-components-select-tree.mjs +998 -690
- package/fesm2022/cmat-components-select-tree.mjs.map +1 -1
- package/fesm2022/cmat-components-skeleton.mjs +143 -57
- package/fesm2022/cmat-components-skeleton.mjs.map +1 -1
- package/fesm2022/cmat-components-speed-dial.mjs +457 -303
- package/fesm2022/cmat-components-speed-dial.mjs.map +1 -1
- package/fesm2022/cmat-components-status-tag.mjs +136 -44
- package/fesm2022/cmat-components-status-tag.mjs.map +1 -1
- package/fesm2022/cmat-components-table-toolbar.mjs +120 -28
- package/fesm2022/cmat-components-table-toolbar.mjs.map +1 -1
- package/fesm2022/cmat-components-timeline.mjs +464 -168
- package/fesm2022/cmat-components-timeline.mjs.map +1 -1
- package/fesm2022/cmat-components-toast.mjs +346 -262
- package/fesm2022/cmat-components-toast.mjs.map +1 -1
- package/fesm2022/cmat-components-transfer-picker.mjs +1427 -593
- package/fesm2022/cmat-components-transfer-picker.mjs.map +1 -1
- package/fesm2022/cmat-components-treetable.mjs +372 -112
- package/fesm2022/cmat-components-treetable.mjs.map +1 -1
- package/fesm2022/cmat-components-upload.mjs +904 -410
- package/fesm2022/cmat-components-upload.mjs.map +1 -1
- package/fesm2022/cmat-components-x6-angular-shape.mjs +153 -170
- package/fesm2022/cmat-components-x6-angular-shape.mjs.map +1 -1
- package/fesm2022/cmat-directives-animate-on-scroll.mjs +220 -138
- package/fesm2022/cmat-directives-animate-on-scroll.mjs.map +1 -1
- package/fesm2022/cmat-directives-arrow-cursor.mjs +246 -193
- package/fesm2022/cmat-directives-arrow-cursor.mjs.map +1 -1
- package/fesm2022/cmat-directives-autofocus.mjs +43 -25
- package/fesm2022/cmat-directives-autofocus.mjs.map +1 -1
- package/fesm2022/cmat-directives-data-exporter.mjs +537 -338
- package/fesm2022/cmat-directives-data-exporter.mjs.map +1 -1
- package/fesm2022/cmat-directives-debounce.mjs +162 -76
- package/fesm2022/cmat-directives-debounce.mjs.map +1 -1
- package/fesm2022/cmat-directives-digit-only.mjs +457 -356
- package/fesm2022/cmat-directives-digit-only.mjs.map +1 -1
- package/fesm2022/cmat-directives-equal-validator.mjs +70 -53
- package/fesm2022/cmat-directives-equal-validator.mjs.map +1 -1
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs +180 -132
- package/fesm2022/cmat-directives-seamless-auto-scroll.mjs.map +1 -1
- package/fesm2022/cmat-lib-mock-api.mjs +207 -195
- package/fesm2022/cmat-lib-mock-api.mjs.map +1 -1
- package/fesm2022/cmat-pipes-bytes.mjs +50 -30
- package/fesm2022/cmat-pipes-bytes.mjs.map +1 -1
- package/fesm2022/cmat-pipes-date-format.mjs +41 -25
- package/fesm2022/cmat-pipes-date-format.mjs.map +1 -1
- package/fesm2022/cmat-pipes-find-by-key.mjs +44 -26
- package/fesm2022/cmat-pipes-find-by-key.mjs.map +1 -1
- package/fesm2022/cmat-pipes-group-by.mjs +50 -38
- package/fesm2022/cmat-pipes-group-by.mjs.map +1 -1
- package/fesm2022/cmat-pipes-keys.mjs +44 -31
- package/fesm2022/cmat-pipes-keys.mjs.map +1 -1
- package/fesm2022/cmat-pipes-secure.mjs +60 -49
- package/fesm2022/cmat-pipes-secure.mjs.map +1 -1
- package/fesm2022/cmat-pipes-uppercase.mjs +39 -22
- package/fesm2022/cmat-pipes-uppercase.mjs.map +1 -1
- package/fesm2022/cmat-reports.mjs +2751 -0
- package/fesm2022/cmat-reports.mjs.map +1 -0
- package/fesm2022/cmat-services-alert.mjs +249 -277
- package/fesm2022/cmat-services-alert.mjs.map +1 -1
- package/fesm2022/cmat-services-config.mjs +110 -81
- package/fesm2022/cmat-services-config.mjs.map +1 -1
- package/fesm2022/cmat-services-confirmation.mjs +184 -73
- package/fesm2022/cmat-services-confirmation.mjs.map +1 -1
- package/fesm2022/cmat-services-data.mjs +136 -125
- package/fesm2022/cmat-services-data.mjs.map +1 -1
- package/fesm2022/cmat-services-export-as.mjs +165 -183
- package/fesm2022/cmat-services-export-as.mjs.map +1 -1
- package/fesm2022/cmat-services-loading.mjs +116 -95
- package/fesm2022/cmat-services-loading.mjs.map +1 -1
- package/fesm2022/cmat-services-local-storage.mjs +75 -66
- package/fesm2022/cmat-services-local-storage.mjs.map +1 -1
- package/fesm2022/cmat-services-media-watcher.mjs +69 -64
- package/fesm2022/cmat-services-media-watcher.mjs.map +1 -1
- package/fesm2022/cmat-services-platform.mjs +48 -45
- package/fesm2022/cmat-services-platform.mjs.map +1 -1
- package/fesm2022/cmat-services-print.mjs +984 -1109
- package/fesm2022/cmat-services-print.mjs.map +1 -1
- package/fesm2022/cmat-services-splash-screen.mjs +53 -38
- package/fesm2022/cmat-services-splash-screen.mjs.map +1 -1
- package/fesm2022/cmat-services-title.mjs +57 -47
- package/fesm2022/cmat-services-title.mjs.map +1 -1
- package/fesm2022/cmat-services-translation.mjs +79 -68
- package/fesm2022/cmat-services-translation.mjs.map +1 -1
- package/fesm2022/cmat-services-utils.mjs +424 -517
- package/fesm2022/cmat-services-utils.mjs.map +1 -1
- package/fesm2022/cmat-validators.mjs +23 -33
- package/fesm2022/cmat-validators.mjs.map +1 -1
- package/fesm2022/cmat-version.mjs +12 -16
- package/fesm2022/cmat-version.mjs.map +1 -1
- package/fesm2022/cmat.mjs +39805 -22511
- package/fesm2022/cmat.mjs.map +1 -1
- package/package.json +5 -1
- package/types/cmat-components-adapter.d.ts +145 -156
- package/types/cmat-components-breadcrumb.d.ts +108 -86
- package/types/cmat-components-card.d.ts +34 -18
- package/types/cmat-components-carousel.d.ts +251 -134
- package/types/cmat-components-cascade.d.ts +158 -117
- package/types/cmat-components-chip-input.d.ts +105 -71
- package/types/cmat-components-code-editor.d.ts +59 -34
- package/types/cmat-components-color-picker.d.ts +378 -236
- package/types/cmat-components-custom-formly.d.ts +776 -814
- package/types/cmat-components-data-picker.d.ts +502 -360
- package/types/cmat-components-date-range.d.ts +106 -77
- package/types/cmat-components-date-time-display.d.ts +36 -13
- package/types/cmat-components-drawer.d.ts +91 -61
- package/types/cmat-components-empty-state.d.ts +47 -17
- package/types/cmat-components-file-preview.d.ts +42 -14
- package/types/cmat-components-filter-toolbar.d.ts +57 -25
- package/types/cmat-components-form-actions.d.ts +18 -10
- package/types/cmat-components-fullscreen.d.ts +21 -13
- package/types/cmat-components-highlight.d.ts +33 -26
- package/types/cmat-components-image-viewer.d.ts +119 -58
- package/types/cmat-components-inline-loading.d.ts +24 -11
- package/types/cmat-components-json-editor.d.ts +39 -28
- package/types/cmat-components-knob-input.d.ts +172 -101
- package/types/cmat-components-loading-overlay.d.ts +8 -11
- package/types/cmat-components-masonry.d.ts +27 -14
- package/types/cmat-components-material-color-picker.d.ts +56 -42
- package/types/cmat-components-material-datetimepicker.d.ts +817 -454
- package/types/cmat-components-navigation.d.ts +295 -221
- package/types/cmat-components-opt-input.d.ts +111 -90
- package/types/cmat-components-org-chart.d.ts +53 -35
- package/types/cmat-components-page-header.d.ts +37 -14
- package/types/cmat-components-pagination.d.ts +144 -107
- package/types/cmat-components-password-strength.d.ts +197 -86
- package/types/cmat-components-popover.d.ts +264 -166
- package/types/cmat-components-progress-bar.d.ts +17 -14
- package/types/cmat-components-qrcode.d.ts +111 -42
- package/types/cmat-components-rating.d.ts +105 -59
- package/types/cmat-components-rich-text-editor.d.ts +39 -16
- package/types/cmat-components-select-search.d.ts +195 -99
- package/types/cmat-components-select-table.d.ts +241 -142
- package/types/cmat-components-select-tree.d.ts +185 -118
- package/types/cmat-components-skeleton.d.ts +55 -32
- package/types/cmat-components-speed-dial.d.ts +86 -61
- package/types/cmat-components-status-tag.d.ts +42 -24
- package/types/cmat-components-table-toolbar.d.ts +30 -12
- package/types/cmat-components-timeline.d.ts +83 -51
- package/types/cmat-components-toast.d.ts +84 -85
- package/types/cmat-components-transfer-picker.d.ts +228 -181
- package/types/cmat-components-treetable.d.ts +63 -39
- package/types/cmat-components-upload.d.ts +205 -106
- package/types/cmat-components-x6-angular-shape.d.ts +29 -37
- package/types/cmat-directives-animate-on-scroll.d.ts +48 -30
- package/types/cmat-directives-arrow-cursor.d.ts +55 -35
- package/types/cmat-directives-autofocus.d.ts +8 -11
- package/types/cmat-directives-data-exporter.d.ts +71 -40
- package/types/cmat-directives-debounce.d.ts +31 -28
- package/types/cmat-directives-digit-only.d.ts +90 -53
- package/types/cmat-directives-equal-validator.d.ts +11 -14
- package/types/cmat-directives-seamless-auto-scroll.d.ts +42 -29
- package/types/cmat-lib-mock-api.d.ts +46 -55
- package/types/cmat-pipes-bytes.d.ts +7 -10
- package/types/cmat-pipes-date-format.d.ts +7 -10
- package/types/cmat-pipes-find-by-key.d.ts +8 -12
- package/types/cmat-pipes-group-by.d.ts +11 -15
- package/types/cmat-pipes-keys.d.ts +10 -13
- package/types/cmat-pipes-secure.d.ts +14 -17
- package/types/cmat-pipes-uppercase.d.ts +7 -10
- package/types/cmat-reports.d.ts +1131 -0
- package/types/cmat-services-alert.d.ts +80 -87
- package/types/cmat-services-config.d.ts +37 -43
- package/types/cmat-services-confirmation.d.ts +31 -37
- package/types/cmat-services-data.d.ts +18 -21
- package/types/cmat-services-export-as.d.ts +28 -33
- package/types/cmat-services-loading.d.ts +27 -31
- package/types/cmat-services-local-storage.d.ts +17 -21
- package/types/cmat-services-media-watcher.d.ts +14 -18
- package/types/cmat-services-platform.d.ts +8 -11
- package/types/cmat-services-print.d.ts +97 -102
- package/types/cmat-services-splash-screen.d.ts +11 -14
- package/types/cmat-services-title.d.ts +9 -12
- package/types/cmat-services-translation.d.ts +19 -22
- package/types/cmat-services-utils.d.ts +76 -80
- package/types/cmat-validators.d.ts +5 -8
- package/types/cmat-version.d.ts +8 -10
- package/types/cmat.d.ts +7551 -5204
|
@@ -1,126 +1,137 @@
|
|
|
1
|
-
import { HttpClient, HttpParams } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { CmatUrlStateConfigService } from
|
|
5
|
-
import { CmatUtilsService } from
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
import { HttpClient, HttpParams } from "@angular/common/http";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { Injectable, effect, inject } from "@angular/core";
|
|
4
|
+
import { CmatUrlStateConfigService } from "cmat/services/config";
|
|
5
|
+
import { CmatUtilsService } from "cmat/services/utils";
|
|
6
|
+
import { catchError, map, retry } from "rxjs/operators";
|
|
7
|
+
var CmatDataService = class CmatDataService {
|
|
8
|
+
constructor() {
|
|
9
|
+
this._http = inject(HttpClient);
|
|
10
|
+
this._urlStateConfigService = inject(CmatUrlStateConfigService);
|
|
11
|
+
this._enableDataProtect = false;
|
|
12
|
+
effect(() => {
|
|
13
|
+
this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
get(url, params = {}, auth = true) {
|
|
17
|
+
const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders("");
|
|
18
|
+
const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
|
|
19
|
+
if (this._enableDataProtect) return this._http.get(url, {
|
|
20
|
+
...options,
|
|
21
|
+
headers
|
|
22
|
+
}).pipe(retry({
|
|
23
|
+
count: 3,
|
|
24
|
+
delay: 1e3
|
|
25
|
+
}), map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
|
|
26
|
+
else return this._http.get(url, {
|
|
27
|
+
...options,
|
|
28
|
+
headers
|
|
29
|
+
}).pipe(retry({
|
|
30
|
+
count: 3,
|
|
31
|
+
delay: 1e3
|
|
32
|
+
}), catchError((err) => CmatUtilsService.handleError(err)));
|
|
33
|
+
}
|
|
34
|
+
post(url, data, params = {}, auth = true, idempotent = false) {
|
|
35
|
+
const headers = auth ? idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders() : idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders("") : CmatUtilsService.getRequestCryptoBypassHeaders("");
|
|
36
|
+
const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
|
|
37
|
+
if (this._enableDataProtect) {
|
|
38
|
+
data = CmatUtilsService.getEncryptData(JSON.stringify(data));
|
|
39
|
+
return this._http.post(url, data, {
|
|
40
|
+
...options,
|
|
41
|
+
headers
|
|
42
|
+
}).pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
|
|
43
|
+
} else return this._http.post(url, data, {
|
|
44
|
+
...options,
|
|
45
|
+
headers
|
|
46
|
+
}).pipe(catchError((err) => CmatUtilsService.handleError(err)));
|
|
47
|
+
}
|
|
48
|
+
put(url, data, params = {}, auth = true) {
|
|
49
|
+
const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders("");
|
|
50
|
+
const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
|
|
51
|
+
if (this._enableDataProtect) {
|
|
52
|
+
data = CmatUtilsService.getEncryptData(JSON.stringify(data));
|
|
53
|
+
return this._http.put(url, data, {
|
|
54
|
+
...options,
|
|
55
|
+
headers
|
|
56
|
+
}).pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
|
|
57
|
+
} else return this._http.put(url, data, {
|
|
58
|
+
...options,
|
|
59
|
+
headers
|
|
60
|
+
}).pipe(catchError((err) => CmatUtilsService.handleError(err)));
|
|
61
|
+
}
|
|
62
|
+
delete(url, params = {}, auth = true) {
|
|
63
|
+
const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders("");
|
|
64
|
+
const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
|
|
65
|
+
return this._http.delete(url, {
|
|
66
|
+
...options,
|
|
67
|
+
headers
|
|
68
|
+
}).pipe(catchError((err) => CmatUtilsService.handleError(err)));
|
|
69
|
+
}
|
|
70
|
+
patch(url, data, params = {}, auth = true) {
|
|
71
|
+
const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders("");
|
|
72
|
+
const options = { params: this._buildHttpParams(params, this._enableDataProtect) };
|
|
73
|
+
if (this._enableDataProtect) {
|
|
74
|
+
data = CmatUtilsService.getEncryptData(JSON.stringify(data));
|
|
75
|
+
return this._http.patch(url, data, {
|
|
76
|
+
...options,
|
|
77
|
+
headers
|
|
78
|
+
}).pipe(map((res) => this._decryptResponse(res)), catchError((err) => CmatUtilsService.handleError(err)));
|
|
79
|
+
} else return this._http.patch(url, data, {
|
|
80
|
+
...options,
|
|
81
|
+
headers
|
|
82
|
+
}).pipe(catchError((err) => CmatUtilsService.handleError(err)));
|
|
83
|
+
}
|
|
84
|
+
_buildHttpParams(params, encrypted) {
|
|
85
|
+
if (Object.keys(params).length === 0) return new HttpParams();
|
|
86
|
+
if (encrypted) return new HttpParams().set("params", CmatUtilsService.getEncryptData(JSON.stringify(params)));
|
|
87
|
+
const normalizedParams = {};
|
|
88
|
+
Object.entries(params).forEach(([key, value]) => {
|
|
89
|
+
const normalizedValue = this._normalizeParamValue(value);
|
|
90
|
+
if (normalizedValue !== void 0) normalizedParams[key] = normalizedValue;
|
|
91
|
+
});
|
|
92
|
+
return new HttpParams({ fromObject: normalizedParams });
|
|
93
|
+
}
|
|
94
|
+
_decryptResponse(res) {
|
|
95
|
+
if (!res) return res;
|
|
96
|
+
return JSON.parse(CmatUtilsService.getDecryptData(res));
|
|
97
|
+
}
|
|
98
|
+
_normalizeParamValue(value) {
|
|
99
|
+
if (value === null || value === void 0) return;
|
|
100
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") return `${value}`;
|
|
101
|
+
if (value instanceof Date) return value.toISOString();
|
|
102
|
+
return JSON.stringify(value);
|
|
103
|
+
}
|
|
104
|
+
static {
|
|
105
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
106
|
+
minVersion: "12.0.0",
|
|
107
|
+
version: "22.2.3",
|
|
108
|
+
ngImport: i0,
|
|
109
|
+
type: CmatDataService,
|
|
110
|
+
deps: [],
|
|
111
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
static {
|
|
115
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
116
|
+
minVersion: "12.0.0",
|
|
117
|
+
version: "22.2.3",
|
|
118
|
+
ngImport: i0,
|
|
119
|
+
type: CmatDataService,
|
|
120
|
+
providedIn: "root"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
125
|
+
minVersion: "12.0.0",
|
|
126
|
+
version: "22.2.3",
|
|
127
|
+
ngImport: i0,
|
|
128
|
+
type: CmatDataService,
|
|
129
|
+
decorators: [{
|
|
130
|
+
type: Injectable,
|
|
131
|
+
args: [{ providedIn: "root" }]
|
|
132
|
+
}],
|
|
133
|
+
ctorParameters: () => []
|
|
134
|
+
});
|
|
125
135
|
export { CmatDataService };
|
|
126
|
-
|
|
136
|
+
|
|
137
|
+
//# sourceMappingURL=cmat-services-data.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cmat-services-data.mjs","sources":["../../../projects/cmat/services/data/data.service.ts","../../../projects/cmat/services/data/cmat-services-data.ts"],"sourcesContent":["import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';\r\nimport { Injectable, effect, inject } from '@angular/core';\r\nimport { CmatUrlStateConfigService } from 'cmat/services/config';\r\nimport { CmatUtilsService } from 'cmat/services/utils';\r\nimport { Observable } from 'rxjs';\r\nimport { catchError, map, retry } from 'rxjs/operators';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CmatDataService {\r\n private readonly _http = inject(HttpClient);\r\n private readonly _urlStateConfigService = inject(CmatUrlStateConfigService);\r\n\r\n private _enableDataProtect: boolean = false;\r\n\r\n constructor() {\r\n effect(() => {\r\n this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;\r\n });\r\n }\r\n\r\n get<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n return this._http.get<string>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.get<T>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n }\r\n\r\n post<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true, idempotent: boolean = false): Observable<T> {\r\n const headers = auth ? (idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders()) : (idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders('') : CmatUtilsService.getRequestCryptoBypassHeaders(''));\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.post<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.post<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n put<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.put<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.put<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n delete<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n return this._http.delete<T>(url, {\r\n ...options,\r\n headers: headers\r\n })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n patch<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.patch<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.patch<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n private _buildHttpParams(params: Record<string, unknown>, encrypted: boolean): HttpParams {\r\n if (Object.keys(params).length === 0) {\r\n return new HttpParams();\r\n }\r\n\r\n if (encrypted) {\r\n return new HttpParams().set('params', CmatUtilsService.getEncryptData(JSON.stringify(params)));\r\n }\r\n\r\n const normalizedParams: Record<string, string> = {};\r\n\r\n Object.entries(params).forEach(([key, value]) => {\r\n const normalizedValue = this._normalizeParamValue(value);\r\n\r\n if (normalizedValue !== undefined) {\r\n normalizedParams[key] = normalizedValue;\r\n }\r\n });\r\n\r\n return new HttpParams({ fromObject: normalizedParams });\r\n }\r\n\r\n private _decryptResponse<T>(res: string): T | string {\r\n if (!res) {\r\n return res;\r\n }\r\n\r\n return JSON.parse(CmatUtilsService.getDecryptData(res)) as T;\r\n }\r\n\r\n private _normalizeParamValue(value: unknown): string | undefined {\r\n if (value === null || value === undefined) {\r\n return undefined;\r\n }\r\n\r\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\r\n return `${value}`;\r\n }\r\n\r\n if (value instanceof Date) {\r\n return value.toISOString();\r\n }\r\n\r\n return JSON.stringify(value);\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAUa,eAAe,CAAA;AAMxB,IAAA,WAAA,GAAA;AALiB,QAAA,IAAA,CAAA,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC;AAC1B,QAAA,IAAA,CAAA,sBAAsB,GAAG,MAAM,CAAC,yBAAyB,CAAC;QAEnE,IAAA,CAAA,kBAAkB,GAAY,KAAK;QAGvC,MAAM,CAAC,MAAK;YACR,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,EAAE,CAAC,iBAAiB;AACpF,QAAA,CAAC,CAAC;IACN;AAEA,IAAA,GAAG,CAAI,GAAW,EAAE,SAAkC,EAAE,EAAE,OAAgB,IAAI,EAAA;AAC1E,QAAA,MAAM,OAAO,GAAG,IAAI,GAAG,gBAAgB,CAAC,iBAAiB,EAAE,GAAG,gBAAgB,CAAC,uBAAuB,CAAC,EAAE,CAAC;AAC1G,QAAA,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,kBAAkB,CAAC,EAAE;AAElF,QAAA,IAAI,IAAI,CAAC,kBAAkB,EAAE;AACzB,YAAA,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAS,GAAG,EAAE,EAAE,GAAG,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE;iBAC9D,IAAI,CACD,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAChC,GAAG,CAAC,CAAC,GAAW,KAAK,IAAI,CAAC,gBAAgB,CAAI,GAAG,CAAM,CAAC,EACxD,UAAU,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A,gBAAgB,CAAI,GAAW,EAAA;QACnC,IAAI,CAAC,GAAG,EAAE;AACN,YAAA,OAAO,GAAG;QACd;QAEA,OAAO,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,cAAc,CAAC,GAAG,CAAC,CAAM;IAChE;AAEQ,IAAA,oBAAoB,CAAC,KAAc,EAAA;QACvC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE;AACvC,YAAA,OAAO,SAAS;QACpB;AAEA,QAAA,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YACtF,OAAO,CAAA,EAAG,KAAK,CAAA,CAAE;QACrB;AAEA,QAAA,IAAI,KAAK,YAAY,IAAI,EAAE;AACvB,YAAA,OAAO,KAAK,CAAC,WAAW,EAAE;QAC9B;AAEA,QAAA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;IAChC;8GAtJS,eAAe,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAf,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,eAAe,cAFZ,MAAM,EAAA,CAAA,CAAA;;2FAET,eAAe,EAAA,UAAA,EAAA,CAAA;kBAH3B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,UAAU,EAAE;AACf,iBAAA;;;ACTD;;AAEG;;"}
|
|
1
|
+
{"version":3,"file":"cmat-services-data.mjs","names":[],"sources":["../../../projects/cmat/services/data/data.service.ts"],"sourcesContent":["import { HttpClient, HttpErrorResponse, HttpParams } from '@angular/common/http';\r\nimport { Injectable, effect, inject } from '@angular/core';\r\nimport { CmatUrlStateConfigService } from 'cmat/services/config';\r\nimport { CmatUtilsService } from 'cmat/services/utils';\r\nimport { Observable } from 'rxjs';\r\nimport { catchError, map, retry } from 'rxjs/operators';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class CmatDataService {\r\n private readonly _http = inject(HttpClient);\r\n private readonly _urlStateConfigService = inject(CmatUrlStateConfigService);\r\n\r\n private _enableDataProtect: boolean = false;\r\n\r\n constructor() {\r\n effect(() => {\r\n this._enableDataProtect = this._urlStateConfigService.config().enableDataProtect;\r\n });\r\n }\r\n\r\n get<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestHeaders() : CmatUtilsService.getRequestCryptoHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n return this._http.get<string>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.get<T>(url, { ...options, headers: headers })\r\n .pipe(\r\n retry({ count: 3, delay: 1000 }),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n }\r\n\r\n post<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true, idempotent: boolean = false): Observable<T> {\r\n const headers = auth ? (idempotent ? CmatUtilsService.getRequestIdempotentBypassHeaders() : CmatUtilsService.getRequestBypassHeaders()) : (idempotent ? CmatUtilsService.getRequestCryptoIdempotentBypassHeaders('') : CmatUtilsService.getRequestCryptoBypassHeaders(''));\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.post<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.post<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n put<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.put<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.put<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n delete<T>(url: string, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n return this._http.delete<T>(url, {\r\n ...options,\r\n headers: headers\r\n })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n\r\n patch<T>(url: string, data: unknown, params: Record<string, unknown> = {}, auth: boolean = true): Observable<T> {\r\n const headers = auth ? CmatUtilsService.getRequestBypassHeaders() : CmatUtilsService.getRequestCryptoBypassHeaders('');\r\n const options = { params: this._buildHttpParams(params, this._enableDataProtect) };\r\n\r\n if (this._enableDataProtect) {\r\n data = CmatUtilsService.getEncryptData(JSON.stringify(data));\r\n\r\n return this._http.patch<string>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n map((res: string) => this._decryptResponse<T>(res) as T),\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n } else {\r\n return this._http.patch<T>(url, data, { ...options, headers: headers })\r\n .pipe(\r\n catchError((err: unknown) => CmatUtilsService.handleError(err as ErrorEvent | HttpErrorResponse))\r\n );\r\n }\r\n }\r\n\r\n private _buildHttpParams(params: Record<string, unknown>, encrypted: boolean): HttpParams {\r\n if (Object.keys(params).length === 0) {\r\n return new HttpParams();\r\n }\r\n\r\n if (encrypted) {\r\n return new HttpParams().set('params', CmatUtilsService.getEncryptData(JSON.stringify(params)));\r\n }\r\n\r\n const normalizedParams: Record<string, string> = {};\r\n\r\n Object.entries(params).forEach(([key, value]) => {\r\n const normalizedValue = this._normalizeParamValue(value);\r\n\r\n if (normalizedValue !== undefined) {\r\n normalizedParams[key] = normalizedValue;\r\n }\r\n });\r\n\r\n return new HttpParams({ fromObject: normalizedParams });\r\n }\r\n\r\n private _decryptResponse<T>(res: string): T | string {\r\n if (!res) {\r\n return res;\r\n }\r\n\r\n return JSON.parse(CmatUtilsService.getDecryptData(res)) as T;\r\n }\r\n\r\n private _normalizeParamValue(value: unknown): string | undefined {\r\n if (value === null || value === undefined) {\r\n return undefined;\r\n }\r\n\r\n if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {\r\n return `${value}`;\r\n }\r\n\r\n if (value instanceof Date) {\r\n return value.toISOString();\r\n }\r\n\r\n return JSON.stringify(value);\r\n }\r\n}\r\n"],"mappings":";;;;;;AAUA,IAAa,kBAAb,MAAa,gBAAe;CAMxB,cAAA;EALiB,KAAA,QAAQ,OAAO,UAAU;EACzB,KAAA,yBAAyB,OAAO,yBAAyB;EAElE,KAAA,qBAA8B;EAGlC,aAAY;GAC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