@servicetitan/titan-chatbot-api 3.0.0

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 (160) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts +11 -0
  3. package/dist/api-client/__mocks__/chatbot-api-client.mock.d.ts.map +1 -0
  4. package/dist/api-client/__mocks__/chatbot-api-client.mock.js +47 -0
  5. package/dist/api-client/__mocks__/chatbot-api-client.mock.js.map +1 -0
  6. package/dist/api-client/base/chatbot-api-client.d.ts +27 -0
  7. package/dist/api-client/base/chatbot-api-client.d.ts.map +1 -0
  8. package/dist/api-client/base/chatbot-api-client.js +10 -0
  9. package/dist/api-client/base/chatbot-api-client.js.map +1 -0
  10. package/dist/api-client/help-center/__tests__/converter-from-models.test.d.ts +2 -0
  11. package/dist/api-client/help-center/__tests__/converter-from-models.test.d.ts.map +1 -0
  12. package/dist/api-client/help-center/__tests__/converter-from-models.test.js +34 -0
  13. package/dist/api-client/help-center/__tests__/converter-from-models.test.js.map +1 -0
  14. package/dist/api-client/help-center/__tests__/converter-to-models.test.d.ts +2 -0
  15. package/dist/api-client/help-center/__tests__/converter-to-models.test.d.ts.map +1 -0
  16. package/dist/api-client/help-center/__tests__/converter-to-models.test.js +82 -0
  17. package/dist/api-client/help-center/__tests__/converter-to-models.test.js.map +1 -0
  18. package/dist/api-client/help-center/chatbot-api-client.d.ts +31 -0
  19. package/dist/api-client/help-center/chatbot-api-client.d.ts.map +1 -0
  20. package/dist/api-client/help-center/chatbot-api-client.js +90 -0
  21. package/dist/api-client/help-center/chatbot-api-client.js.map +1 -0
  22. package/dist/api-client/help-center/converter-from-models.d.ts +13 -0
  23. package/dist/api-client/help-center/converter-from-models.d.ts.map +1 -0
  24. package/dist/api-client/help-center/converter-from-models.js +113 -0
  25. package/dist/api-client/help-center/converter-from-models.js.map +1 -0
  26. package/dist/api-client/help-center/converter-to-models.d.ts +13 -0
  27. package/dist/api-client/help-center/converter-to-models.d.ts.map +1 -0
  28. package/dist/api-client/help-center/converter-to-models.js +95 -0
  29. package/dist/api-client/help-center/converter-to-models.js.map +1 -0
  30. package/dist/api-client/help-center/index.d.ts +2 -0
  31. package/dist/api-client/help-center/index.d.ts.map +1 -0
  32. package/dist/api-client/help-center/index.js +2 -0
  33. package/dist/api-client/help-center/index.js.map +1 -0
  34. package/dist/api-client/help-center/native-client.d.ts +1260 -0
  35. package/dist/api-client/help-center/native-client.d.ts.map +1 -0
  36. package/dist/api-client/help-center/native-client.js +6169 -0
  37. package/dist/api-client/help-center/native-client.js.map +1 -0
  38. package/dist/api-client/index.d.ts +8 -0
  39. package/dist/api-client/index.d.ts.map +1 -0
  40. package/dist/api-client/index.js +8 -0
  41. package/dist/api-client/index.js.map +1 -0
  42. package/dist/api-client/models/__mocks__/models.mock.d.ts +13 -0
  43. package/dist/api-client/models/__mocks__/models.mock.d.ts.map +1 -0
  44. package/dist/api-client/models/__mocks__/models.mock.js +114 -0
  45. package/dist/api-client/models/__mocks__/models.mock.js.map +1 -0
  46. package/dist/api-client/models/index.d.ts +22 -0
  47. package/dist/api-client/models/index.d.ts.map +1 -0
  48. package/dist/api-client/models/index.js +15 -0
  49. package/dist/api-client/models/index.js.map +1 -0
  50. package/dist/api-client/titan-chat/chatbot-api-client.d.ts +34 -0
  51. package/dist/api-client/titan-chat/chatbot-api-client.d.ts.map +1 -0
  52. package/dist/api-client/titan-chat/chatbot-api-client.js +72 -0
  53. package/dist/api-client/titan-chat/chatbot-api-client.js.map +1 -0
  54. package/dist/api-client/titan-chat/index.d.ts +2 -0
  55. package/dist/api-client/titan-chat/index.d.ts.map +1 -0
  56. package/dist/api-client/titan-chat/index.js +2 -0
  57. package/dist/api-client/titan-chat/index.js.map +1 -0
  58. package/dist/api-client/titan-chat/native-client.d.ts +225 -0
  59. package/dist/api-client/titan-chat/native-client.d.ts.map +1 -0
  60. package/dist/api-client/titan-chat/native-client.js +931 -0
  61. package/dist/api-client/titan-chat/native-client.js.map +1 -0
  62. package/dist/api-client/utils/model-utils.d.ts +4 -0
  63. package/dist/api-client/utils/model-utils.d.ts.map +1 -0
  64. package/dist/api-client/utils/model-utils.js +58 -0
  65. package/dist/api-client/utils/model-utils.js.map +1 -0
  66. package/dist/index.d.ts +6 -0
  67. package/dist/index.d.ts.map +1 -0
  68. package/dist/index.js +7 -0
  69. package/dist/index.js.map +1 -0
  70. package/dist/models/chatbot-customizations.d.ts +15 -0
  71. package/dist/models/chatbot-customizations.d.ts.map +1 -0
  72. package/dist/models/chatbot-customizations.js +2 -0
  73. package/dist/models/chatbot-customizations.js.map +1 -0
  74. package/dist/models/index.d.ts +2 -0
  75. package/dist/models/index.d.ts.map +1 -0
  76. package/dist/models/index.js +2 -0
  77. package/dist/models/index.js.map +1 -0
  78. package/dist/stores/__tests__/chatbot-ui-backend.store.test.d.ts +2 -0
  79. package/dist/stores/__tests__/chatbot-ui-backend.store.test.d.ts.map +1 -0
  80. package/dist/stores/__tests__/chatbot-ui-backend.store.test.js +341 -0
  81. package/dist/stores/__tests__/chatbot-ui-backend.store.test.js.map +1 -0
  82. package/dist/stores/__tests__/chatbot-ui.store.test.d.ts +2 -0
  83. package/dist/stores/__tests__/chatbot-ui.store.test.d.ts.map +1 -0
  84. package/dist/stores/__tests__/chatbot-ui.store.test.js +166 -0
  85. package/dist/stores/__tests__/chatbot-ui.store.test.js.map +1 -0
  86. package/dist/stores/__tests__/filter.store.test.d.ts +2 -0
  87. package/dist/stores/__tests__/filter.store.test.d.ts.map +1 -0
  88. package/dist/stores/__tests__/filter.store.test.js +316 -0
  89. package/dist/stores/__tests__/filter.store.test.js.map +1 -0
  90. package/dist/stores/__tests__/initialize.store.test.d.ts +2 -0
  91. package/dist/stores/__tests__/initialize.store.test.d.ts.map +1 -0
  92. package/dist/stores/__tests__/initialize.store.test.js +54 -0
  93. package/dist/stores/__tests__/initialize.store.test.js.map +1 -0
  94. package/dist/stores/chatbot-ui-backend.store.d.ts +61 -0
  95. package/dist/stores/chatbot-ui-backend.store.d.ts.map +1 -0
  96. package/dist/stores/chatbot-ui-backend.store.js +396 -0
  97. package/dist/stores/chatbot-ui-backend.store.js.map +1 -0
  98. package/dist/stores/chatbot-ui.store.d.ts +25 -0
  99. package/dist/stores/chatbot-ui.store.d.ts.map +1 -0
  100. package/dist/stores/chatbot-ui.store.js +87 -0
  101. package/dist/stores/chatbot-ui.store.js.map +1 -0
  102. package/dist/stores/filter.store.d.ts +30 -0
  103. package/dist/stores/filter.store.d.ts.map +1 -0
  104. package/dist/stores/filter.store.js +334 -0
  105. package/dist/stores/filter.store.js.map +1 -0
  106. package/dist/stores/index.d.ts +4 -0
  107. package/dist/stores/index.d.ts.map +1 -0
  108. package/dist/stores/index.js +4 -0
  109. package/dist/stores/index.js.map +1 -0
  110. package/dist/stores/initialize.store.d.ts +17 -0
  111. package/dist/stores/initialize.store.d.ts.map +1 -0
  112. package/dist/stores/initialize.store.js +98 -0
  113. package/dist/stores/initialize.store.js.map +1 -0
  114. package/dist/utils/__tests__/axios-utils.test.d.ts +2 -0
  115. package/dist/utils/__tests__/axios-utils.test.d.ts.map +1 -0
  116. package/dist/utils/__tests__/axios-utils.test.js +33 -0
  117. package/dist/utils/__tests__/axios-utils.test.js.map +1 -0
  118. package/dist/utils/axios-utils.d.ts +5 -0
  119. package/dist/utils/axios-utils.d.ts.map +1 -0
  120. package/dist/utils/axios-utils.js +23 -0
  121. package/dist/utils/axios-utils.js.map +1 -0
  122. package/dist/utils/test-utils.d.ts +5 -0
  123. package/dist/utils/test-utils.d.ts.map +1 -0
  124. package/dist/utils/test-utils.js +17 -0
  125. package/dist/utils/test-utils.js.map +1 -0
  126. package/package.json +45 -0
  127. package/src/api-client/__mocks__/chatbot-api-client.mock.ts +11 -0
  128. package/src/api-client/base/chatbot-api-client.ts +33 -0
  129. package/src/api-client/help-center/__tests__/converter-from-models.test.ts +41 -0
  130. package/src/api-client/help-center/__tests__/converter-to-models.test.ts +89 -0
  131. package/src/api-client/help-center/chatbot-api-client.ts +107 -0
  132. package/src/api-client/help-center/converter-from-models.ts +132 -0
  133. package/src/api-client/help-center/converter-to-models.ts +124 -0
  134. package/src/api-client/help-center/index.ts +1 -0
  135. package/src/api-client/help-center/native-client.ts +5662 -0
  136. package/src/api-client/index.ts +12 -0
  137. package/src/api-client/models/__mocks__/models.mock.ts +141 -0
  138. package/src/api-client/models/index.ts +48 -0
  139. package/src/api-client/titan-chat/chatbot-api-client.ts +77 -0
  140. package/src/api-client/titan-chat/index.ts +1 -0
  141. package/src/api-client/titan-chat/native-client.ts +826 -0
  142. package/src/api-client/utils/model-utils.ts +68 -0
  143. package/src/cypress.d.ts +10 -0
  144. package/src/index.ts +6 -0
  145. package/src/models/chatbot-customizations.ts +16 -0
  146. package/src/models/index.ts +1 -0
  147. package/src/stores/__tests__/chatbot-ui-backend.store.test.ts +426 -0
  148. package/src/stores/__tests__/chatbot-ui.store.test.ts +196 -0
  149. package/src/stores/__tests__/filter.store.test.ts +363 -0
  150. package/src/stores/__tests__/initialize.store.test.ts +73 -0
  151. package/src/stores/chatbot-ui-backend.store.ts +401 -0
  152. package/src/stores/chatbot-ui.store.ts +82 -0
  153. package/src/stores/filter.store.ts +250 -0
  154. package/src/stores/index.ts +12 -0
  155. package/src/stores/initialize.store.ts +62 -0
  156. package/src/utils/__tests__/axios-utils.test.ts +40 -0
  157. package/src/utils/axios-utils.ts +25 -0
  158. package/src/utils/test-utils.ts +22 -0
  159. package/tsconfig.json +19 -0
  160. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1,334 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import cloneDeep from 'lodash/cloneDeep';
11
+ import { action, makeObservable, observable } from 'mobx';
12
+ import { nanoid } from 'nanoid';
13
+ import { Models, ModelsUtils } from '../api-client';
14
+ export class FilterStore {
15
+ constructor() {
16
+ Object.defineProperty(this, "selectedOptions", {
17
+ enumerable: true,
18
+ configurable: true,
19
+ writable: true,
20
+ value: {}
21
+ });
22
+ Object.defineProperty(this, "filters", {
23
+ enumerable: true,
24
+ configurable: true,
25
+ writable: true,
26
+ value: []
27
+ });
28
+ Object.defineProperty(this, "model", {
29
+ enumerable: true,
30
+ configurable: true,
31
+ writable: true,
32
+ value: void 0
33
+ });
34
+ Object.defineProperty(this, "originalFilters", {
35
+ enumerable: true,
36
+ configurable: true,
37
+ writable: true,
38
+ value: []
39
+ });
40
+ Object.defineProperty(this, "selectOption", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: (filterKey, optionKey) => {
45
+ const allFilterOptions = this.getExistingFilterOptions(filterKey);
46
+ const option = allFilterOptions.find(o => o.key === optionKey);
47
+ if (!option) {
48
+ throw new Error(`Option "${optionKey}" does not exist in the filter "${filterKey}".`);
49
+ }
50
+ if (!this.selectedOptions[filterKey]) {
51
+ this.selectedOptions[filterKey] = [];
52
+ }
53
+ this.selectedOptions[filterKey] = [...this.selectedOptions[filterKey], option.key];
54
+ this.addSubSequentFilters(filterKey);
55
+ }
56
+ });
57
+ Object.defineProperty(this, "selectAll", {
58
+ enumerable: true,
59
+ configurable: true,
60
+ writable: true,
61
+ value: (filterKey) => {
62
+ this.selectedOptions[filterKey] = this.getExistingFilterOptions(filterKey).map(o => o.key);
63
+ this.addSubSequentFilters(filterKey);
64
+ }
65
+ });
66
+ Object.defineProperty(this, "deselectOption", {
67
+ enumerable: true,
68
+ configurable: true,
69
+ writable: true,
70
+ value: (filterKey, optionKey) => {
71
+ this.selectedOptions[filterKey] = this.selectedOptions[filterKey].filter(o => o !== optionKey);
72
+ this.cleanUpFilterOptions(filterKey, optionKey);
73
+ this.removeSubSequentFilters(filterKey);
74
+ this.addSubSequentFilters(filterKey);
75
+ }
76
+ });
77
+ Object.defineProperty(this, "deselectAll", {
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true,
81
+ value: (filterKey) => {
82
+ for (const selectedKey of this.selectedOptions[filterKey]) {
83
+ this.deselectOption(filterKey, selectedKey);
84
+ }
85
+ }
86
+ });
87
+ Object.defineProperty(this, "getFilterLabel", {
88
+ enumerable: true,
89
+ configurable: true,
90
+ writable: true,
91
+ value: (key) => {
92
+ // transform camel case key to human-readable label
93
+ return key.replace(/([A-Z])/g, ' $1').replace(/^./, function (str) {
94
+ return str.toUpperCase();
95
+ });
96
+ }
97
+ });
98
+ Object.defineProperty(this, "removeSubSequentFilters", {
99
+ enumerable: true,
100
+ configurable: true,
101
+ writable: true,
102
+ value: (filterKey) => {
103
+ const filter = this.getExistingFilterByKey(filterKey);
104
+ const subFilters = this.getSubFilters(filter);
105
+ this.filters = this.filters.filter(x => !subFilters.some(f => f.key === x.key));
106
+ }
107
+ });
108
+ Object.defineProperty(this, "addSubSequentFilters", {
109
+ enumerable: true,
110
+ configurable: true,
111
+ writable: true,
112
+ value: (filterKey) => {
113
+ var _a, _b;
114
+ const filter = this.getExistingFilterByKey(filterKey);
115
+ if (!filter.subOptions) {
116
+ return;
117
+ }
118
+ // Get selected items for the filter
119
+ const filterSelectedKeys = (_a = this.selectedOptions[filterKey]) !== null && _a !== void 0 ? _a : [];
120
+ const filterSelectedOptions = filter.subOptions.filter(x => x.type === Models.OptionType.Selectable && filterSelectedKeys.includes(x.key));
121
+ // Find all sub-filters for the selected options
122
+ const allSubFilters = (_b = filterSelectedOptions.flatMap(selectedOption => {
123
+ var _a;
124
+ // For each selected option, collect its sub-filters
125
+ const subFilters = [];
126
+ for (const subFilter of (_a = selectedOption.subOptions) !== null && _a !== void 0 ? _a : []) {
127
+ const originalFilter = cloneDeep(this.getOriginalFilter(subFilter.uid));
128
+ originalFilter.parentKeys = [selectedOption.uid];
129
+ subFilters.push(originalFilter);
130
+ }
131
+ return subFilters;
132
+ })) !== null && _b !== void 0 ? _b : [];
133
+ // Merge sub-filters with the same key and their options (with parent keys merging)
134
+ const mergedSubFilters = allSubFilters.reduce((acc, subFilter) => {
135
+ var _a, _b;
136
+ if (!subFilter.subOptions) {
137
+ return acc;
138
+ }
139
+ const subfilterOptions = ((_a = subFilter.subOptions) !== null && _a !== void 0 ? _a : []);
140
+ const subfilterParentKeys = subFilter.parentKeys;
141
+ // Merge filters with the same key and their options if they already exist
142
+ subfilterOptions.forEach(subfilterOption => {
143
+ subfilterOption.parentKeys = this.mergeParentKeys(subfilterOption.parentKeys, subfilterParentKeys);
144
+ });
145
+ // Check if the filter already exists in the accumulator
146
+ const existingFilter = acc.find(x => x.key === subFilter.key);
147
+ if (!existingFilter) {
148
+ return [...acc, subFilter];
149
+ }
150
+ // Merge options for subfilters by key
151
+ existingFilter.subOptions = subfilterOptions.reduce((acc2, subfilterOption) => {
152
+ const existing = acc2.find(o => o.key === subfilterOption.key);
153
+ if (!existing) {
154
+ return [...acc2, subfilterOption];
155
+ }
156
+ existing.parentKeys = this.mergeParentKeys(existing.parentKeys, subfilterOption.parentKeys);
157
+ return acc2;
158
+ }, [...((_b = existingFilter.subOptions) !== null && _b !== void 0 ? _b : [])]);
159
+ return acc;
160
+ }, []);
161
+ // Update the filters with the merged sub-filters
162
+ for (const newFilter of mergedSubFilters) {
163
+ const existingFilterIdx = this.filters.findIndex(f => f.key === newFilter.key);
164
+ if (existingFilterIdx < 0) {
165
+ this.filters.push(newFilter);
166
+ }
167
+ else {
168
+ this.filters[existingFilterIdx] = newFilter;
169
+ }
170
+ this.addSubSequentFilters(newFilter.key);
171
+ }
172
+ }
173
+ });
174
+ Object.defineProperty(this, "mergeParentKeys", {
175
+ enumerable: true,
176
+ configurable: true,
177
+ writable: true,
178
+ value: (keys1, keys2) => {
179
+ if (!keys1 && !keys2) {
180
+ return [];
181
+ }
182
+ if (!keys1) {
183
+ return keys2 !== null && keys2 !== void 0 ? keys2 : [];
184
+ }
185
+ if (!keys2) {
186
+ return keys1;
187
+ }
188
+ const mergedKeys = new Set([...keys1, ...keys2]);
189
+ return Array.from(mergedKeys);
190
+ }
191
+ });
192
+ Object.defineProperty(this, "cleanUpFilterOptions", {
193
+ enumerable: true,
194
+ configurable: true,
195
+ writable: true,
196
+ value: (filterKey, parentKeyToRemove) => {
197
+ var _a, _b, _c;
198
+ const filter = this.getExistingFilterByKey(filterKey);
199
+ const filterSubOptionToRemove = (_a = filter.subOptions) === null || _a === void 0 ? void 0 : _a.find(x => x.key === parentKeyToRemove);
200
+ const filterSubOptionToRemoveUid = filterSubOptionToRemove === null || filterSubOptionToRemove === void 0 ? void 0 : filterSubOptionToRemove.uid;
201
+ const filterIdx = this.filters.findIndex(f => f.key === filterKey);
202
+ for (let i = filterIdx + 1; i < this.filters.length; i++) {
203
+ const subFilter = this.filters[i];
204
+ (_b = subFilter.subOptions) === null || _b === void 0 ? void 0 : _b.forEach((o) => {
205
+ var _a, _b, _c;
206
+ o.parentKeys = ((_a = o.parentKeys) !== null && _a !== void 0 ? _a : []).filter(p => p !== filterSubOptionToRemoveUid);
207
+ // Uncheck sub-filter options if they no longer have parent keys
208
+ if (!((_b = o.parentKeys) === null || _b === void 0 ? void 0 : _b.length)) {
209
+ this.selectedOptions[subFilter.key] = (_c = this.selectedOptions[subFilter.key]) === null || _c === void 0 ? void 0 : _c.filter(x => x !== o.key);
210
+ }
211
+ });
212
+ subFilter.subOptions = (_c = subFilter.subOptions) === null || _c === void 0 ? void 0 : _c.filter((o) => { var _a; return Boolean((_a = o.parentKeys) === null || _a === void 0 ? void 0 : _a.length); });
213
+ }
214
+ }
215
+ });
216
+ Object.defineProperty(this, "getSubFilters", {
217
+ enumerable: true,
218
+ configurable: true,
219
+ writable: true,
220
+ value: (filter) => {
221
+ var _a;
222
+ const result = [];
223
+ (_a = filter.subOptions) === null || _a === void 0 ? void 0 : _a.forEach(filterSelectable => {
224
+ var _a;
225
+ (_a = filterSelectable.subOptions) === null || _a === void 0 ? void 0 : _a.forEach(subFilter => {
226
+ result.push(subFilter, ...this.getSubFilters(subFilter));
227
+ });
228
+ });
229
+ return result;
230
+ }
231
+ });
232
+ Object.defineProperty(this, "getOriginalFilters", {
233
+ enumerable: true,
234
+ configurable: true,
235
+ writable: true,
236
+ value: () => {
237
+ return this.originalFilters.reduce((acc, next) => {
238
+ return [...acc, next, ...this.getSubFilters(next)];
239
+ }, []);
240
+ }
241
+ });
242
+ Object.defineProperty(this, "getOriginalFilter", {
243
+ enumerable: true,
244
+ configurable: true,
245
+ writable: true,
246
+ value: (uid) => {
247
+ const originalFilters = this.getOriginalFilters();
248
+ const filter = originalFilters.find(f => f.uid === uid);
249
+ if (!filter) {
250
+ throw new Error(`Filter with key "${uid}" does not exist.`);
251
+ }
252
+ return filter;
253
+ }
254
+ });
255
+ Object.defineProperty(this, "getExistingFilterOptions", {
256
+ enumerable: true,
257
+ configurable: true,
258
+ writable: true,
259
+ value: (filterKey) => {
260
+ var _a, _b;
261
+ const filter = this.getExistingFilterByKey(filterKey);
262
+ return (_b = (_a = filter.subOptions) === null || _a === void 0 ? void 0 : _a.filter(x => x.type === Models.OptionType.Selectable)) !== null && _b !== void 0 ? _b : [];
263
+ }
264
+ });
265
+ Object.defineProperty(this, "getExistingFilterByKey", {
266
+ enumerable: true,
267
+ configurable: true,
268
+ writable: true,
269
+ value: (filterKey) => {
270
+ const filter = this.filters.find(f => f.key === filterKey);
271
+ if (!filter) {
272
+ throw new Error(`Filter with key "${filterKey}" does not exist.`);
273
+ }
274
+ return filter;
275
+ }
276
+ });
277
+ makeObservable(this);
278
+ }
279
+ initFilters(model) {
280
+ var _a, _b;
281
+ const setUids = (o) => {
282
+ o === null || o === void 0 ? void 0 : o.forEach(x => {
283
+ x.uid = nanoid();
284
+ setUids(x.subOptions);
285
+ });
286
+ };
287
+ this.model = model;
288
+ this.originalFilters = cloneDeep((_b = (_a = model.options.subOptions) === null || _a === void 0 ? void 0 : _a.filter(x => x.type === Models.OptionType.Group)) !== null && _b !== void 0 ? _b : []);
289
+ setUids(this.originalFilters);
290
+ this.filters = this.originalFilters;
291
+ }
292
+ export() {
293
+ return ModelsUtils.createSelectionsModel(this.originalFilters, this.selectedOptions);
294
+ }
295
+ }
296
+ __decorate([
297
+ observable,
298
+ __metadata("design:type", Object)
299
+ ], FilterStore.prototype, "selectedOptions", void 0);
300
+ __decorate([
301
+ observable,
302
+ __metadata("design:type", Array)
303
+ ], FilterStore.prototype, "filters", void 0);
304
+ __decorate([
305
+ action,
306
+ __metadata("design:type", Function),
307
+ __metadata("design:paramtypes", [Object]),
308
+ __metadata("design:returntype", void 0)
309
+ ], FilterStore.prototype, "initFilters", null);
310
+ __decorate([
311
+ action,
312
+ __metadata("design:type", Object)
313
+ ], FilterStore.prototype, "selectOption", void 0);
314
+ __decorate([
315
+ action,
316
+ __metadata("design:type", Object)
317
+ ], FilterStore.prototype, "selectAll", void 0);
318
+ __decorate([
319
+ action,
320
+ __metadata("design:type", Object)
321
+ ], FilterStore.prototype, "deselectOption", void 0);
322
+ __decorate([
323
+ action,
324
+ __metadata("design:type", Object)
325
+ ], FilterStore.prototype, "deselectAll", void 0);
326
+ __decorate([
327
+ action,
328
+ __metadata("design:type", Object)
329
+ ], FilterStore.prototype, "removeSubSequentFilters", void 0);
330
+ __decorate([
331
+ action,
332
+ __metadata("design:type", Object)
333
+ ], FilterStore.prototype, "addSubSequentFilters", void 0);
334
+ //# sourceMappingURL=filter.store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.store.js","sourceRoot":"","sources":["../../src/stores/filter.store.ts"],"names":[],"mappings":";;;;;;;;;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AAC,eAAe,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC;IACxC,CAAC;IA8CD,MAAM;QACF,OAAO,WAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IACzF,CAAC;CAqKJ;AA9Oe;IAAX,UAAU;;oDAAgD;AAC/C;IAAX,UAAU;;4CAAyB;AAUpC;IADC,MAAM;;;;8CAeN;AAGD;IADC,MAAM;;iDAYL;AAGF;IADC,MAAM;;8CAIL;AAGF;IADC,MAAM;;mDAQL;AAGF;IADC,MAAM;;gDAKL;AAcM;IADP,MAAM;;4DAKL;AAGM;IADP,MAAM;;yDAiFL"}
@@ -0,0 +1,4 @@
1
+ export { CHATBOT_UI_BACKEND_STORE_TOKEN, IChatbotUiBackendStore, ChatbotUiBackendStore, } from './chatbot-ui-backend.store';
2
+ export { CHATBOT_UI_STORE_TOKEN, IChatbotUiStore, ChatbotUiStore, ChatbotUiEvent, } from './chatbot-ui.store';
3
+ export { InitializeStore, InitializeStoreStatus } from './initialize.store';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,8BAA8B,EAC9B,sBAAsB,EACtB,qBAAqB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,sBAAsB,EACtB,eAAe,EACf,cAAc,EACd,cAAc,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { CHATBOT_UI_BACKEND_STORE_TOKEN, ChatbotUiBackendStore, } from './chatbot-ui-backend.store';
2
+ export { CHATBOT_UI_STORE_TOKEN, ChatbotUiStore, ChatbotUiEvent, } from './chatbot-ui.store';
3
+ export { InitializeStore, InitializeStoreStatus } from './initialize.store';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stores/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,8BAA8B,EAE9B,qBAAqB,GACxB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,sBAAsB,EAEtB,cAAc,EACd,cAAc,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC"}
@@ -0,0 +1,17 @@
1
+ export declare enum InitializeStoreStatus {
2
+ None = "None",
3
+ Pending = "Pending",
4
+ Success = "Success",
5
+ Error = "Error"
6
+ }
7
+ export declare class InitializeStore {
8
+ initializeStatus: InitializeStoreStatus;
9
+ private initializePromiseInner?;
10
+ get isInitialized(): boolean;
11
+ constructor();
12
+ initialize(force?: boolean): Promise<void>;
13
+ protected initializeInternal(): Promise<void>;
14
+ private setInitializeStatus;
15
+ private resetInitialization;
16
+ }
17
+ //# sourceMappingURL=initialize.store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialize.store.d.ts","sourceRoot":"","sources":["../../src/stores/initialize.store.ts"],"names":[],"mappings":"AAGA,oBAAY,qBAAqB;IAC7B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;CAClB;AAED,qBACa,eAAe;IAExB,gBAAgB,wBAA8B;IAG9C,OAAO,CAAC,sBAAsB,CAAC,CAAgB;IAE/C,IACI,aAAa,YAEhB;;IAMK,UAAU,CAAC,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB9C,SAAS,CAAC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAK7C,OAAO,CAAC,mBAAmB;IAK3B,OAAO,CAAC,mBAAmB;CAI9B"}
@@ -0,0 +1,98 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __metadata = (this && this.__metadata) || function (k, v) {
8
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
+ };
10
+ import { injectable } from '@servicetitan/react-ioc';
11
+ import { action, computed, makeObservable, observable } from 'mobx';
12
+ export var InitializeStoreStatus;
13
+ (function (InitializeStoreStatus) {
14
+ InitializeStoreStatus["None"] = "None";
15
+ InitializeStoreStatus["Pending"] = "Pending";
16
+ InitializeStoreStatus["Success"] = "Success";
17
+ InitializeStoreStatus["Error"] = "Error";
18
+ })(InitializeStoreStatus || (InitializeStoreStatus = {}));
19
+ let InitializeStore = class InitializeStore {
20
+ get isInitialized() {
21
+ return this.initializeStatus === InitializeStoreStatus.Success;
22
+ }
23
+ constructor() {
24
+ Object.defineProperty(this, "initializeStatus", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: InitializeStoreStatus.None
29
+ });
30
+ Object.defineProperty(this, "initializePromiseInner", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ makeObservable(this);
37
+ }
38
+ async initialize(force = false) {
39
+ if (force) {
40
+ this.resetInitialization();
41
+ }
42
+ if (this.initializePromiseInner) {
43
+ return this.initializePromiseInner;
44
+ }
45
+ try {
46
+ this.setInitializeStatus(InitializeStoreStatus.Pending);
47
+ this.initializePromiseInner = this.initializeInternal();
48
+ await this.initializePromiseInner;
49
+ this.setInitializeStatus(InitializeStoreStatus.Success);
50
+ }
51
+ catch (e) {
52
+ this.setInitializeStatus(InitializeStoreStatus.Error);
53
+ throw e;
54
+ }
55
+ return this.initializePromiseInner;
56
+ }
57
+ initializeInternal() {
58
+ return Promise.resolve();
59
+ }
60
+ setInitializeStatus(initializeStatus) {
61
+ this.initializeStatus = initializeStatus;
62
+ }
63
+ resetInitialization() {
64
+ this.initializeStatus = InitializeStoreStatus.None;
65
+ this.initializePromiseInner = undefined;
66
+ }
67
+ };
68
+ __decorate([
69
+ observable,
70
+ __metadata("design:type", Object)
71
+ ], InitializeStore.prototype, "initializeStatus", void 0);
72
+ __decorate([
73
+ observable.ref,
74
+ __metadata("design:type", Promise)
75
+ ], InitializeStore.prototype, "initializePromiseInner", void 0);
76
+ __decorate([
77
+ computed,
78
+ __metadata("design:type", Object),
79
+ __metadata("design:paramtypes", [])
80
+ ], InitializeStore.prototype, "isInitialized", null);
81
+ __decorate([
82
+ action,
83
+ __metadata("design:type", Function),
84
+ __metadata("design:paramtypes", [String]),
85
+ __metadata("design:returntype", void 0)
86
+ ], InitializeStore.prototype, "setInitializeStatus", null);
87
+ __decorate([
88
+ action,
89
+ __metadata("design:type", Function),
90
+ __metadata("design:paramtypes", []),
91
+ __metadata("design:returntype", void 0)
92
+ ], InitializeStore.prototype, "resetInitialization", null);
93
+ InitializeStore = __decorate([
94
+ injectable(),
95
+ __metadata("design:paramtypes", [])
96
+ ], InitializeStore);
97
+ export { InitializeStore };
98
+ //# sourceMappingURL=initialize.store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"initialize.store.js","sourceRoot":"","sources":["../../src/stores/initialize.store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEpE,MAAM,CAAN,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC7B,sCAAa,CAAA;IACb,4CAAmB,CAAA;IACnB,4CAAmB,CAAA;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BAAsB,GAAG,SAAS,CAAC;IAC5C,CAAC;CACJ,CAAA;AAhDG;IADC,UAAU;;yDACmC;AAGtC;IADP,UAAU,CAAC,GAAG;;+DACgC;AAE/C;IAAC,QAAQ;;;oDAGR;AA+BO;IADP,MAAM;;;;0DAGN;AAGO;IADP,MAAM;;;;0DAIN;AAjDQ,eAAe;IAD3B,UAAU,EAAE;;GACA,eAAe,CAkD3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=axios-utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-utils.test.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/axios-utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,33 @@
1
+ import { expect } from '@jest/globals';
2
+ import { withTimeout } from '../axios-utils';
3
+ describe('axios-utils', () => {
4
+ beforeEach(() => {
5
+ jest.useFakeTimers();
6
+ jest.setSystemTime(new Date('2000-01-01T00:00:00.000Z'));
7
+ });
8
+ afterEach(() => {
9
+ jest.clearAllMocks();
10
+ jest.useRealTimers();
11
+ });
12
+ test('should withTimeout (timeout first)', async () => {
13
+ const abortController = new AbortController();
14
+ const spyAbort = jest.spyOn(abortController, 'abort');
15
+ const action = new Promise(resolve => setTimeout(() => resolve('done'), 100));
16
+ const timeoutMs = 50;
17
+ const p = expect(withTimeout(action, timeoutMs, abortController)).rejects.toThrow('The request is timed out');
18
+ await jest.advanceTimersByTimeAsync(50);
19
+ await p;
20
+ expect(spyAbort).toHaveBeenCalledWith('The request is timed out');
21
+ });
22
+ test('should withTimeout (resolves first)', async () => {
23
+ const abortController = new AbortController();
24
+ const spyAbort = jest.spyOn(abortController, 'abort');
25
+ const action = new Promise(resolve => setTimeout(() => resolve('done'), 100));
26
+ const timeoutMs = 150;
27
+ const p = expect(withTimeout(action, timeoutMs, abortController)).resolves.toEqual('done');
28
+ await jest.advanceTimersByTimeAsync(100);
29
+ await p;
30
+ expect(spyAbort).not.toHaveBeenCalled();
31
+ });
32
+ });
33
+ //# sourceMappingURL=axios-utils.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-utils.test.js","sourceRoot":"","sources":["../../../src/utils/__tests__/axios-utils.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IACzB,UAAU,CAAC,GAAG,EAAE;QACZ,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC,0BAA0B,CAAC,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,oCAAoC,EAAE,KAAK,IAAI,EAAE;QAClD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9E,MAAM,SAAS,GAAG,EAAE,CAAC;QAErB,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAC7E,0BAA0B,CAC7B,CAAC;QACF,MAAM,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,CAAC;QACR,MAAM,CAAC,QAAQ,CAAC,CAAC,oBAAoB,CAAC,0BAA0B,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,eAAe,GAAG,IAAI,eAAe,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC;QACtD,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;QAC9E,MAAM,SAAS,GAAG,GAAG,CAAC;QAEtB,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAC3F,MAAM,IAAI,CAAC,wBAAwB,CAAC,GAAG,CAAC,CAAC;QACzC,MAAM,CAAC,CAAC;QACR,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;IAC5C,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Aborts the action if it takes longer than the specified timeout.
3
+ */
4
+ export declare function withTimeout<T>(action: Promise<T>, timeoutMs: number, abortController: AbortController): Promise<T>;
5
+ //# sourceMappingURL=axios-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-utils.d.ts","sourceRoot":"","sources":["../../src/utils/axios-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAC/B,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,EAClB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,eAAe,GACjC,OAAO,CAAC,CAAC,CAAC,CAiBZ"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Aborts the action if it takes longer than the specified timeout.
3
+ */
4
+ export async function withTimeout(action, timeoutMs, abortController) {
5
+ let timeoutId = undefined;
6
+ const timeoutPromise = new Promise((_, reject) => {
7
+ timeoutId = setTimeout(() => {
8
+ abortController.abort('The request is timed out');
9
+ reject(new Error('The request is timed out'));
10
+ }, timeoutMs);
11
+ });
12
+ const promise = Promise.race([action, timeoutPromise]);
13
+ try {
14
+ return await promise;
15
+ }
16
+ finally {
17
+ if (timeoutId) {
18
+ clearTimeout(timeoutId);
19
+ timeoutId = undefined;
20
+ }
21
+ }
22
+ }
23
+ //# sourceMappingURL=axios-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"axios-utils.js","sourceRoot":"","sources":["../../src/utils/axios-utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC7B,MAAkB,EAClB,SAAiB,EACjB,eAAgC;IAEhC,IAAI,SAAS,GAA8C,SAAS,CAAC;IACrE,MAAM,cAAc,GAAG,IAAI,OAAO,CAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;QAChD,SAAS,GAAG,UAAU,CAAC,GAAG,EAAE;YACxB,eAAe,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;YAClD,MAAM,CAAC,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC,CAAC;QAClD,CAAC,EAAE,SAAS,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC;IACvD,IAAI,CAAC;QACD,OAAO,MAAM,OAAO,CAAC;IACzB,CAAC;YAAS,CAAC;QACP,IAAI,SAAS,EAAE,CAAC;YACZ,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,SAAS,GAAG,SAAS,CAAC;QAC1B,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { Container } from '@servicetitan/react-ioc';
2
+ type Newable<T> = new (...args: never[]) => T;
3
+ export declare const initTestContainer: (serviceIdentifier: Newable<unknown> | Newable<unknown>[], initDependenciesFn: (container: Container) => void) => () => Container;
4
+ export {};
5
+ //# sourceMappingURL=test-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.d.ts","sourceRoot":"","sources":["../../src/utils/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,KAAK,OAAO,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AAE9C,eAAO,MAAM,iBAAiB,GAC1B,mBAAmB,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,EAAE,EACxD,oBAAoB,CAAC,SAAS,EAAE,SAAS,KAAK,IAAI,oBAerD,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { Container } from '@servicetitan/react-ioc';
2
+ export const initTestContainer = (serviceIdentifier, initDependenciesFn) => {
3
+ const rootContainer = new Container();
4
+ if (Array.isArray(serviceIdentifier)) {
5
+ serviceIdentifier.forEach(identifier => rootContainer.bind(identifier).toSelf());
6
+ }
7
+ else {
8
+ rootContainer.bind(serviceIdentifier).toSelf();
9
+ }
10
+ return () => {
11
+ const container = new Container();
12
+ container.parent = rootContainer;
13
+ initDependenciesFn(container);
14
+ return container;
15
+ };
16
+ };
17
+ //# sourceMappingURL=test-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-utils.js","sourceRoot":"","sources":["../../src/utils/test-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAIpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC7B,iBAAwD,EACxD,kBAAkD,EACpD,EAAE;IACA,MAAM,aAAa,GAAG,IAAI,SAAS,EAAE,CAAC;IACtC,IAAI,KAAK,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;QACnC,iBAAiB,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACrF,CAAC;SAAM,CAAC;QACJ,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;IAED,OAAO,GAAG,EAAE;QACR,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE,CAAC;QAClC,SAAS,CAAC,MAAM,GAAG,aAAa,CAAC;QACjC,kBAAkB,CAAC,SAAS,CAAC,CAAC;QAC9B,OAAO,SAAS,CAAC;IACrB,CAAC,CAAC;AACN,CAAC,CAAC"}