@fctc/edu-logic-lib 1.0.2 → 1.0.4

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 (69) hide show
  1. package/dist/{store.d.ts → index.d.mts} +574 -3
  2. package/dist/{store.d.mts → index.d.ts} +574 -3
  3. package/dist/index.js +4709 -0
  4. package/dist/index.mjs +4596 -0
  5. package/package.json +1 -1
  6. package/dist/base-model-type-DvO53Lwi.d.mts +0 -7
  7. package/dist/base-model-type-DvO53Lwi.d.ts +0 -7
  8. package/dist/chunk-6BLY7NZ6.mjs +0 -124
  9. package/dist/chunk-6QXB3XX7.mjs +0 -258
  10. package/dist/chunk-ELARQVCE.mjs +0 -2364
  11. package/dist/chunk-FVGPSTJ7.js +0 -124
  12. package/dist/chunk-GGOFXFSX.js +0 -2364
  13. package/dist/chunk-IXDDYGKE.js +0 -61
  14. package/dist/chunk-MJLXGYQ4.mjs +0 -102
  15. package/dist/chunk-MLJQPO4Q.mjs +0 -61
  16. package/dist/chunk-QLUONJPQ.mjs +0 -604
  17. package/dist/chunk-RZBHZYXG.js +0 -604
  18. package/dist/chunk-S7B3VKMJ.mjs +0 -95
  19. package/dist/chunk-S7YF2I23.js +0 -95
  20. package/dist/chunk-U4CC2BBB.js +0 -1074
  21. package/dist/chunk-UY6GNZNB.js +0 -258
  22. package/dist/chunk-W4W2L2NA.js +0 -102
  23. package/dist/chunk-WYXAE5LI.mjs +0 -1074
  24. package/dist/config.d.mts +0 -15
  25. package/dist/config.d.ts +0 -15
  26. package/dist/config.js +0 -7
  27. package/dist/config.mjs +0 -7
  28. package/dist/constants.d.mts +0 -120
  29. package/dist/constants.d.ts +0 -120
  30. package/dist/constants.js +0 -30
  31. package/dist/constants.mjs +0 -30
  32. package/dist/context-type-D5XefoL-.d.mts +0 -8
  33. package/dist/context-type-D5XefoL-.d.ts +0 -8
  34. package/dist/environment.d.mts +0 -37
  35. package/dist/environment.d.ts +0 -37
  36. package/dist/environment.js +0 -15
  37. package/dist/environment.mjs +0 -15
  38. package/dist/hooks.d.mts +0 -216
  39. package/dist/hooks.d.ts +0 -216
  40. package/dist/hooks.js +0 -776
  41. package/dist/hooks.mjs +0 -776
  42. package/dist/index-C_nK1Mii.d.mts +0 -19
  43. package/dist/index-C_nK1Mii.d.ts +0 -19
  44. package/dist/models.d.mts +0 -35
  45. package/dist/models.d.ts +0 -35
  46. package/dist/models.js +0 -43
  47. package/dist/models.mjs +0 -43
  48. package/dist/provider.d.mts +0 -16
  49. package/dist/provider.d.ts +0 -16
  50. package/dist/provider.js +0 -86
  51. package/dist/provider.mjs +0 -86
  52. package/dist/services.d.mts +0 -160
  53. package/dist/services.d.ts +0 -160
  54. package/dist/services.js +0 -26
  55. package/dist/services.mjs +0 -26
  56. package/dist/store.js +0 -128
  57. package/dist/store.mjs +0 -128
  58. package/dist/types.d.mts +0 -12
  59. package/dist/types.d.ts +0 -12
  60. package/dist/types.js +0 -1
  61. package/dist/types.mjs +0 -0
  62. package/dist/use-get-selection-DFh6sc49.d.mts +0 -26
  63. package/dist/use-get-selection-DFh6sc49.d.ts +0 -26
  64. package/dist/utils.d.mts +0 -52
  65. package/dist/utils.d.ts +0 -52
  66. package/dist/utils.js +0 -34
  67. package/dist/utils.mjs +0 -34
  68. package/dist/view-type-BTzRpkT7.d.mts +0 -106
  69. package/dist/view-type-BTzRpkT7.d.ts +0 -106
package/dist/index.mjs ADDED
@@ -0,0 +1,4596 @@
1
+ import { useDispatch, useSelector, Provider } from 'react-redux';
2
+ import { createSlice, configureStore } from '@reduxjs/toolkit';
3
+ import axios from 'axios';
4
+ import { useMutation, QueryClient, QueryClientProvider, useQueryClient } from '@tanstack/react-query';
5
+ import { useState, useEffect } from 'react';
6
+ import { jsx, Fragment } from 'react/jsx-runtime';
7
+
8
+ // src/constants/api/key-constant.ts
9
+ var KeyConstants = /* @__PURE__ */ ((KeyConstants2) => {
10
+ KeyConstants2["PROFILE"] = "userinfo";
11
+ KeyConstants2["CURRENT_COMPANY"] = "current_company";
12
+ KeyConstants2["LIST_COMPANY"] = "list_company";
13
+ KeyConstants2["COMPANY_INFO"] = "company_info";
14
+ KeyConstants2["MENU"] = "menus";
15
+ KeyConstants2["GET_VIEW_BY_ACTION"] = "get_view_by_action";
16
+ KeyConstants2["ACTION_DETAIL"] = "action_detail";
17
+ KeyConstants2["GET_DATA_SELECTION"] = "get_data_select";
18
+ KeyConstants2["WEB_SAVE"] = "web_save";
19
+ KeyConstants2["WEB_READ"] = "web_read";
20
+ KeyConstants2["GET_PROVIDER"] = "get_provider";
21
+ return KeyConstants2;
22
+ })(KeyConstants || {});
23
+
24
+ // src/constants/api/method-constant.ts
25
+ var MethodConstants = /* @__PURE__ */ ((MethodConstants2) => {
26
+ MethodConstants2["WEB_SEARCH_READ"] = "web_search_read";
27
+ MethodConstants2["WEB_READ_GROUP"] = "web_read_group";
28
+ MethodConstants2["WEB_READ"] = "web_read";
29
+ MethodConstants2["WEB_SAVE"] = "web_save";
30
+ MethodConstants2["UNLINK"] = "unlink";
31
+ MethodConstants2["ONCHANGE"] = "onchange";
32
+ MethodConstants2["GET_ONCHANGE_FIELDS"] = "get_fields_onchange";
33
+ MethodConstants2["GET_FIELD_VIEW"] = "get_fields_view_v2";
34
+ return MethodConstants2;
35
+ })(MethodConstants || {});
36
+
37
+ // src/constants/api/uri-constant.ts
38
+ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
39
+ UriConstants2["AUTH_TOKEN_PATH"] = "/authentication/oauth2/token";
40
+ UriConstants2["GENTOKEN_SOCIAL"] = "/token/generate";
41
+ UriConstants2["CALL_PATH"] = "/call";
42
+ UriConstants2["COMPANY_PATH"] = "/company";
43
+ UriConstants2["PROFILE_PATH"] = "/userinfo";
44
+ UriConstants2["RESET_PASSWORD_PATH"] = "/reset_password";
45
+ UriConstants2["CHANGE_PASSWORD_PATH"] = "/change_password";
46
+ UriConstants2["UPDATE_PASSWORD_PATH"] = "/change_password_parent";
47
+ UriConstants2["LOAD_ACTION"] = `/load_action`;
48
+ UriConstants2["REPORT_PATH"] = `/report`;
49
+ UriConstants2["RUN_ACTION_PATH"] = `/run_action`;
50
+ UriConstants2["UPLOAD_FILE_PATH"] = `/upload/file`;
51
+ UriConstants2["GET_MESSAGE"] = `/chatter/thread/messages`;
52
+ UriConstants2["SENT_MESSAGE"] = `/chatter/message/post`;
53
+ UriConstants2["UPLOAD_IMAGE"] = `/mail/attachment/upload`;
54
+ UriConstants2["DELETE_MESSAGE"] = `/chatter/message/update_content`;
55
+ UriConstants2["IMAGE_PATH"] = `/web/image`;
56
+ UriConstants2["LOAD_MESSAGE"] = `/load_message_failures`;
57
+ UriConstants2["TOKEN"] = `/check_token`;
58
+ UriConstants2["CREATE_UPDATE_PATH"] = `/create_update`;
59
+ UriConstants2["TWOFA_METHOD_PATH"] = `/id/api/v2/call`;
60
+ UriConstants2["SIGNIN_SSO"] = `/signin-sso/oauth`;
61
+ return UriConstants2;
62
+ })(UriConstants || {});
63
+
64
+ // src/constants/field/field-type-constant.ts
65
+ var FieldTypeConstants = /* @__PURE__ */ ((FieldTypeConstants2) => {
66
+ FieldTypeConstants2["CHAR"] = "char";
67
+ FieldTypeConstants2["TEXT"] = "text";
68
+ FieldTypeConstants2["INTEGER"] = "integer";
69
+ FieldTypeConstants2["FLOAT"] = "float";
70
+ FieldTypeConstants2["BOOLEAN"] = "boolean";
71
+ FieldTypeConstants2["DATE"] = "date";
72
+ FieldTypeConstants2["DATETIME"] = "datetime";
73
+ FieldTypeConstants2["BINARY"] = "binary";
74
+ FieldTypeConstants2["SELECTION"] = "selection";
75
+ FieldTypeConstants2["HTML"] = "html";
76
+ FieldTypeConstants2["MANY2ONE"] = "many2one";
77
+ FieldTypeConstants2["ONE2MANY"] = "one2many";
78
+ FieldTypeConstants2["MANY2MANY"] = "many2many";
79
+ FieldTypeConstants2["MONETARY"] = "monetary";
80
+ FieldTypeConstants2["REFERENCE"] = "reference";
81
+ FieldTypeConstants2["FUNCTION"] = "function";
82
+ FieldTypeConstants2["PROPERTY"] = "property";
83
+ return FieldTypeConstants2;
84
+ })(FieldTypeConstants || {});
85
+
86
+ // src/constants/method/method-type-constant.ts
87
+ var MethodType = /* @__PURE__ */ ((MethodType2) => {
88
+ MethodType2[MethodType2["CREATE"] = 0] = "CREATE";
89
+ MethodType2[MethodType2["UPDATE"] = 1] = "UPDATE";
90
+ MethodType2[MethodType2["DELETE"] = 2] = "DELETE";
91
+ MethodType2[MethodType2["UNLINK"] = 3] = "UNLINK";
92
+ MethodType2[MethodType2["NO_CHANGE"] = 4] = "NO_CHANGE";
93
+ return MethodType2;
94
+ })(MethodType || {});
95
+
96
+ // src/constants/model/model-constant.ts
97
+ var ModelConstants = /* @__PURE__ */ ((ModelConstants2) => {
98
+ ModelConstants2["MENU"] = "ir.ui.menu";
99
+ ModelConstants2["USER"] = "res.users";
100
+ ModelConstants2["COMPANY"] = "res.company";
101
+ ModelConstants2["WINDOW_ACTION"] = "ir.actions.act_window";
102
+ ModelConstants2["BASE_IMPORT"] = "base_import.import";
103
+ ModelConstants2["GET_IMPORT"] = "get_import_templates";
104
+ return ModelConstants2;
105
+ })(ModelConstants || {});
106
+
107
+ // src/constants/type/index.ts
108
+ var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
109
+ ComponentType2["TREE"] = "tree";
110
+ ComponentType2["GROUP"] = "group";
111
+ ComponentType2["LIST"] = "list";
112
+ ComponentType2["FORM"] = "form";
113
+ ComponentType2["FIELD"] = "field";
114
+ ComponentType2["DIV"] = "div";
115
+ ComponentType2["SPAN"] = "span";
116
+ return ComponentType2;
117
+ })(ComponentType || {});
118
+ var SearchType = {
119
+ FILTER: "filter_by",
120
+ SEARCH: "search_by",
121
+ GROUP: "group_by"
122
+ };
123
+
124
+ // src/constants/widget/widget-avatar-constant.ts
125
+ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
126
+ WIDGETAVATAR2["many2one_avatar_user"] = "many2one_avatar_user";
127
+ WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
128
+ return WIDGETAVATAR2;
129
+ })(WIDGETAVATAR || {});
130
+
131
+ // src/constants/widget/widget-color-constant.ts
132
+ var WIDGETCOLOR = /* @__PURE__ */ ((WIDGETCOLOR2) => {
133
+ WIDGETCOLOR2["many2many_tags"] = "many2many_tags";
134
+ WIDGETCOLOR2["helpdesk_sla_many2many_tags"] = "helpdesk_sla_many2many_tags";
135
+ return WIDGETCOLOR2;
136
+ })(WIDGETCOLOR || {});
137
+
138
+ // src/constants/widget/widget-status-constant.ts
139
+ var WIDGETSTATUS = /* @__PURE__ */ ((WIDGETSTATUS2) => {
140
+ WIDGETSTATUS2["sla_status_ids"] = "sla_status_ids";
141
+ return WIDGETSTATUS2;
142
+ })(WIDGETSTATUS || {});
143
+ var WIDGETNOSTRING = /* @__PURE__ */ ((WIDGETNOSTRING2) => {
144
+ WIDGETNOSTRING2["sla_status_ids"] = "sla_status_ids";
145
+ return WIDGETNOSTRING2;
146
+ })(WIDGETNOSTRING || {});
147
+ var initialState = {
148
+ baseUrl: "",
149
+ requests: null,
150
+ companies: [],
151
+ user: {},
152
+ envFile: null,
153
+ defaultCompany: {
154
+ id: null,
155
+ logo: "",
156
+ secondary_color: "",
157
+ primary_color: ""
158
+ },
159
+ context: {
160
+ uid: null,
161
+ allowed_company_ids: [],
162
+ lang: "vi_VN",
163
+ tz: "Asia/Saigon"
164
+ }
165
+ };
166
+ var envSlice = createSlice({
167
+ name: "env",
168
+ initialState,
169
+ reducers: {
170
+ setEnv: (state, action) => {
171
+ Object.assign(state, action.payload);
172
+ },
173
+ setUid: (state, action) => {
174
+ state.context.uid = action.payload;
175
+ },
176
+ setAllowCompanies: (state, action) => {
177
+ state.context.allowed_company_ids = action.payload;
178
+ },
179
+ setCompanies: (state, action) => {
180
+ state.companies = action.payload;
181
+ },
182
+ setDefaultCompany: (state, action) => {
183
+ state.defaultCompany = action.payload;
184
+ },
185
+ setLang: (state, action) => {
186
+ state.context.lang = action.payload;
187
+ },
188
+ setUser: (state, action) => {
189
+ state.user = action.payload;
190
+ },
191
+ setEnvFile: (state, action) => {
192
+ state.envFile = action.payload;
193
+ }
194
+ }
195
+ });
196
+ var {
197
+ setEnv,
198
+ setUid,
199
+ setLang,
200
+ setAllowCompanies,
201
+ setCompanies,
202
+ setDefaultCompany,
203
+ setUser,
204
+ setEnvFile
205
+ } = envSlice.actions;
206
+ var selectEnv = (state) => state.env;
207
+ var env_slice_default = envSlice.reducer;
208
+ var initialState2 = {
209
+ dataParse: null,
210
+ idFile: null,
211
+ isFileLoaded: false,
212
+ loadingImport: false,
213
+ selectedFile: null,
214
+ errorData: null
215
+ };
216
+ var excelSlice = createSlice({
217
+ name: "excel",
218
+ initialState: initialState2,
219
+ reducers: {
220
+ setDataParse: (state, action) => {
221
+ state.dataParse = action.payload;
222
+ },
223
+ setIdFile: (state, action) => {
224
+ state.idFile = action.payload;
225
+ },
226
+ setIsFileLoaded: (state, action) => {
227
+ state.isFileLoaded = action.payload;
228
+ },
229
+ setLoadingImport: (state, action) => {
230
+ state.loadingImport = action.payload;
231
+ },
232
+ setSelectedFile: (state, action) => {
233
+ state.selectedFile = action.payload;
234
+ },
235
+ setErrorData: (state, action) => {
236
+ state.errorData = action.payload;
237
+ }
238
+ }
239
+ });
240
+ var {
241
+ setDataParse,
242
+ setIdFile,
243
+ setIsFileLoaded,
244
+ setLoadingImport,
245
+ setSelectedFile,
246
+ setErrorData
247
+ } = excelSlice.actions;
248
+ var selectExcel = (state) => state.excel;
249
+ var excel_slice_default = excelSlice.reducer;
250
+ var initialState3 = {
251
+ viewDataStore: {},
252
+ isShowingModalDetail: false,
253
+ isShowModalTranslate: false,
254
+ formSubmitComponent: {},
255
+ fieldTranslation: null,
256
+ listSubject: {},
257
+ dataUser: {}
258
+ };
259
+ var formSlice = createSlice({
260
+ name: "form",
261
+ initialState: initialState3,
262
+ reducers: {
263
+ setViewDataStore: (state, action) => {
264
+ state.viewDataStore = action.payload;
265
+ },
266
+ setIsShowingModalDetail: (state, action) => {
267
+ state.isShowingModalDetail = action.payload;
268
+ },
269
+ setIsShowModalTranslate: (state, action) => {
270
+ state.isShowModalTranslate = action.payload;
271
+ },
272
+ setFormSubmitComponent: (state, action) => {
273
+ state.formSubmitComponent[action.payload.key] = action.payload.component;
274
+ },
275
+ setFieldTranslate: (state, action) => {
276
+ state.fieldTranslation = action.payload;
277
+ },
278
+ setListSubject: (state, action) => {
279
+ state.listSubject = action.payload;
280
+ },
281
+ setDataUser: (state, action) => {
282
+ state.dataUser = action.payload;
283
+ }
284
+ }
285
+ });
286
+ var {
287
+ setViewDataStore,
288
+ setIsShowingModalDetail,
289
+ setIsShowModalTranslate,
290
+ setFormSubmitComponent,
291
+ setFieldTranslate,
292
+ setListSubject,
293
+ setDataUser
294
+ } = formSlice.actions;
295
+ var selectForm = (state) => state.form;
296
+ var form_slice_default = formSlice.reducer;
297
+ var initialState4 = {
298
+ pageLimit: 10,
299
+ fields: {},
300
+ order: "",
301
+ selectedRowKeys: [],
302
+ indexRowTableModal: -2,
303
+ footerGroupTable: {},
304
+ page: 0,
305
+ domainTable: []
306
+ };
307
+ var listSlice = createSlice({
308
+ name: "list",
309
+ initialState: initialState4,
310
+ reducers: {
311
+ setPageLimit: (state, action) => {
312
+ state.pageLimit = action.payload;
313
+ },
314
+ setFields: (state, action) => {
315
+ state.fields = action.payload;
316
+ },
317
+ setOrder: (state, action) => {
318
+ state.order = action.payload;
319
+ },
320
+ setSelectedRowKeys: (state, action) => {
321
+ state.selectedRowKeys = action.payload;
322
+ },
323
+ setIndexRowTableModal: (state, action) => {
324
+ state.indexRowTableModal = action.payload;
325
+ },
326
+ setPage: (state, action) => {
327
+ state.page = action.payload;
328
+ },
329
+ setDomainTable: (state, action) => {
330
+ state.domainTable = action.payload;
331
+ }
332
+ }
333
+ });
334
+ var {
335
+ setPageLimit,
336
+ setFields,
337
+ setOrder,
338
+ setSelectedRowKeys,
339
+ setIndexRowTableModal,
340
+ setPage,
341
+ setDomainTable
342
+ } = listSlice.actions;
343
+ var selectList = (state) => state.list;
344
+ var list_slice_default = listSlice.reducer;
345
+ var initialState5 = {
346
+ menuList: []
347
+ };
348
+ var navbarSlice = createSlice({
349
+ name: "navbar",
350
+ initialState: initialState5,
351
+ reducers: {
352
+ setMenuList: (state, action) => {
353
+ state.menuList = action.payload;
354
+ }
355
+ }
356
+ });
357
+ var { setMenuList } = navbarSlice.actions;
358
+ var selectNavbar = (state) => state.navbar;
359
+ var navbar_slice_default = navbarSlice.reducer;
360
+ var initialState6 = {
361
+ profile: {}
362
+ };
363
+ var profileSlice = createSlice({
364
+ name: "profile",
365
+ initialState: initialState6,
366
+ reducers: {
367
+ setProfile: (state, action) => {
368
+ state.profile = action.payload;
369
+ }
370
+ }
371
+ });
372
+ var { setProfile } = profileSlice.actions;
373
+ var selectProfile = (state) => state.profile;
374
+ var profile_slice_default = profileSlice.reducer;
375
+ var initialState7 = {
376
+ groupByDomain: null,
377
+ tableHead: [],
378
+ searchString: "",
379
+ hoveredIndexSearchList: null,
380
+ selectedTags: [],
381
+ firstDomain: null,
382
+ searchMap: {},
383
+ typeFieldsSearch: "",
384
+ modelSearch: "",
385
+ filterBy: [],
386
+ groupBy: []
387
+ };
388
+ var searchSlice = createSlice({
389
+ name: "search",
390
+ initialState: initialState7,
391
+ reducers: {
392
+ setGroupByDomain: (state, action) => {
393
+ state.groupByDomain = action.payload;
394
+ },
395
+ setTableHead: (state, action) => {
396
+ state.tableHead = action.payload;
397
+ },
398
+ setSearchString: (state, action) => {
399
+ state.searchString = action.payload;
400
+ },
401
+ setHoveredIndexSearchList: (state, action) => {
402
+ state.hoveredIndexSearchList = action.payload;
403
+ },
404
+ setSelectedTags: (state, action) => {
405
+ state.selectedTags = action.payload;
406
+ },
407
+ setFirstDomain: (state, action) => {
408
+ state.firstDomain = action.payload;
409
+ },
410
+ setTypeFieldsSearch: (state, action) => {
411
+ state.typeFieldsSearch = action.payload;
412
+ },
413
+ setModelSearch: (state, action) => {
414
+ state.modelSearch = action.payload;
415
+ },
416
+ setFilterBy: (state, action) => {
417
+ state.filterBy = action.payload;
418
+ },
419
+ setGroupBy: (state, action) => {
420
+ state.groupBy = action.payload;
421
+ },
422
+ setSearchMap: (state, action) => {
423
+ state.searchMap = action.payload;
424
+ },
425
+ updateSearchMap: (state, action) => {
426
+ if (!state.searchMap[action.payload.key]) {
427
+ state.searchMap[action.payload.key] = [];
428
+ }
429
+ state.searchMap[action.payload.key].push(action.payload.value);
430
+ },
431
+ removeKeyFromSearchMap: (state, action) => {
432
+ const { key, item } = action.payload;
433
+ const values = state.searchMap[key];
434
+ if (!values) return;
435
+ if (item) {
436
+ const filtered = values.filter((value) => value.name !== item.name);
437
+ if (filtered.length > 0) {
438
+ state.searchMap[key] = filtered;
439
+ } else {
440
+ delete state.searchMap[key];
441
+ }
442
+ } else {
443
+ delete state.searchMap[key];
444
+ }
445
+ },
446
+ clearSearchMap: (state) => {
447
+ state.searchMap = {};
448
+ }
449
+ }
450
+ });
451
+ var {
452
+ setGroupByDomain,
453
+ setSelectedTags,
454
+ setSearchString,
455
+ setHoveredIndexSearchList,
456
+ setFirstDomain,
457
+ setTableHead,
458
+ setFilterBy,
459
+ setTypeFieldsSearch,
460
+ setModelSearch,
461
+ setSearchMap,
462
+ updateSearchMap,
463
+ removeKeyFromSearchMap,
464
+ setGroupBy,
465
+ clearSearchMap
466
+ } = searchSlice.actions;
467
+ var selectSearch = (state) => state.search;
468
+ var selectSearchMap = (state) => state.search.searchMap;
469
+ var search_slice_default = searchSlice.reducer;
470
+
471
+ // node_modules/redux/dist/redux.mjs
472
+ function formatProdErrorMessage(code) {
473
+ return `Minified Redux error #${code}; visit https://redux.js.org/Errors?code=${code} for the full message or use the non-minified dev environment for full errors. `;
474
+ }
475
+ var randomString = () => Math.random().toString(36).substring(7).split("").join(".");
476
+ var ActionTypes = {
477
+ INIT: `@@redux/INIT${/* @__PURE__ */ randomString()}`,
478
+ REPLACE: `@@redux/REPLACE${/* @__PURE__ */ randomString()}`,
479
+ PROBE_UNKNOWN_ACTION: () => `@@redux/PROBE_UNKNOWN_ACTION${randomString()}`
480
+ };
481
+ var actionTypes_default = ActionTypes;
482
+ function isPlainObject(obj) {
483
+ if (typeof obj !== "object" || obj === null)
484
+ return false;
485
+ let proto = obj;
486
+ while (Object.getPrototypeOf(proto) !== null) {
487
+ proto = Object.getPrototypeOf(proto);
488
+ }
489
+ return Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null;
490
+ }
491
+ function miniKindOf(val) {
492
+ if (val === void 0)
493
+ return "undefined";
494
+ if (val === null)
495
+ return "null";
496
+ const type = typeof val;
497
+ switch (type) {
498
+ case "boolean":
499
+ case "string":
500
+ case "number":
501
+ case "symbol":
502
+ case "function": {
503
+ return type;
504
+ }
505
+ }
506
+ if (Array.isArray(val))
507
+ return "array";
508
+ if (isDate(val))
509
+ return "date";
510
+ if (isError(val))
511
+ return "error";
512
+ const constructorName = ctorName(val);
513
+ switch (constructorName) {
514
+ case "Symbol":
515
+ case "Promise":
516
+ case "WeakMap":
517
+ case "WeakSet":
518
+ case "Map":
519
+ case "Set":
520
+ return constructorName;
521
+ }
522
+ return Object.prototype.toString.call(val).slice(8, -1).toLowerCase().replace(/\s/g, "");
523
+ }
524
+ function ctorName(val) {
525
+ return typeof val.constructor === "function" ? val.constructor.name : null;
526
+ }
527
+ function isError(val) {
528
+ return val instanceof Error || typeof val.message === "string" && val.constructor && typeof val.constructor.stackTraceLimit === "number";
529
+ }
530
+ function isDate(val) {
531
+ if (val instanceof Date)
532
+ return true;
533
+ return typeof val.toDateString === "function" && typeof val.getDate === "function" && typeof val.setDate === "function";
534
+ }
535
+ function kindOf(val) {
536
+ let typeOfVal = typeof val;
537
+ if (process.env.NODE_ENV !== "production") {
538
+ typeOfVal = miniKindOf(val);
539
+ }
540
+ return typeOfVal;
541
+ }
542
+ function warning(message) {
543
+ if (typeof console !== "undefined" && typeof console.error === "function") {
544
+ console.error(message);
545
+ }
546
+ try {
547
+ throw new Error(message);
548
+ } catch (e) {
549
+ }
550
+ }
551
+ function getUnexpectedStateShapeWarningMessage(inputState, reducers, action, unexpectedKeyCache) {
552
+ const reducerKeys = Object.keys(reducers);
553
+ const argumentName = action && action.type === actionTypes_default.INIT ? "preloadedState argument passed to createStore" : "previous state received by the reducer";
554
+ if (reducerKeys.length === 0) {
555
+ return "Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";
556
+ }
557
+ if (!isPlainObject(inputState)) {
558
+ return `The ${argumentName} has unexpected type of "${kindOf(inputState)}". Expected argument to be an object with the following keys: "${reducerKeys.join('", "')}"`;
559
+ }
560
+ const unexpectedKeys = Object.keys(inputState).filter((key) => !reducers.hasOwnProperty(key) && !unexpectedKeyCache[key]);
561
+ unexpectedKeys.forEach((key) => {
562
+ unexpectedKeyCache[key] = true;
563
+ });
564
+ if (action && action.type === actionTypes_default.REPLACE)
565
+ return;
566
+ if (unexpectedKeys.length > 0) {
567
+ return `Unexpected ${unexpectedKeys.length > 1 ? "keys" : "key"} "${unexpectedKeys.join('", "')}" found in ${argumentName}. Expected to find one of the known reducer keys instead: "${reducerKeys.join('", "')}". Unexpected keys will be ignored.`;
568
+ }
569
+ }
570
+ function assertReducerShape(reducers) {
571
+ Object.keys(reducers).forEach((key) => {
572
+ const reducer = reducers[key];
573
+ const initialState8 = reducer(void 0, {
574
+ type: actionTypes_default.INIT
575
+ });
576
+ if (typeof initialState8 === "undefined") {
577
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(12) : `The slice reducer for key "${key}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);
578
+ }
579
+ if (typeof reducer(void 0, {
580
+ type: actionTypes_default.PROBE_UNKNOWN_ACTION()
581
+ }) === "undefined") {
582
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(13) : `The slice reducer for key "${key}" returned undefined when probed with a random type. Don't try to handle '${actionTypes_default.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`);
583
+ }
584
+ });
585
+ }
586
+ function combineReducers(reducers) {
587
+ const reducerKeys = Object.keys(reducers);
588
+ const finalReducers = {};
589
+ for (let i = 0; i < reducerKeys.length; i++) {
590
+ const key = reducerKeys[i];
591
+ if (process.env.NODE_ENV !== "production") {
592
+ if (typeof reducers[key] === "undefined") {
593
+ warning(`No reducer provided for key "${key}"`);
594
+ }
595
+ }
596
+ if (typeof reducers[key] === "function") {
597
+ finalReducers[key] = reducers[key];
598
+ }
599
+ }
600
+ const finalReducerKeys = Object.keys(finalReducers);
601
+ let unexpectedKeyCache;
602
+ if (process.env.NODE_ENV !== "production") {
603
+ unexpectedKeyCache = {};
604
+ }
605
+ let shapeAssertionError;
606
+ try {
607
+ assertReducerShape(finalReducers);
608
+ } catch (e) {
609
+ shapeAssertionError = e;
610
+ }
611
+ return function combination(state = {}, action) {
612
+ if (shapeAssertionError) {
613
+ throw shapeAssertionError;
614
+ }
615
+ if (process.env.NODE_ENV !== "production") {
616
+ const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
617
+ if (warningMessage) {
618
+ warning(warningMessage);
619
+ }
620
+ }
621
+ let hasChanged = false;
622
+ const nextState = {};
623
+ for (let i = 0; i < finalReducerKeys.length; i++) {
624
+ const key = finalReducerKeys[i];
625
+ const reducer = finalReducers[key];
626
+ const previousStateForKey = state[key];
627
+ const nextStateForKey = reducer(previousStateForKey, action);
628
+ if (typeof nextStateForKey === "undefined") {
629
+ const actionType = action && action.type;
630
+ throw new Error(process.env.NODE_ENV === "production" ? formatProdErrorMessage(14) : `When called with an action of type ${actionType ? `"${String(actionType)}"` : "(unknown type)"}, the slice reducer for key "${key}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`);
631
+ }
632
+ nextState[key] = nextStateForKey;
633
+ hasChanged = hasChanged || nextStateForKey !== previousStateForKey;
634
+ }
635
+ hasChanged = hasChanged || finalReducerKeys.length !== Object.keys(state).length;
636
+ return hasChanged ? nextState : state;
637
+ };
638
+ }
639
+
640
+ // src/store/store.ts
641
+ var rootReducer = combineReducers({
642
+ env: env_slice_default,
643
+ navbar: navbar_slice_default,
644
+ list: list_slice_default,
645
+ search: search_slice_default,
646
+ form: form_slice_default,
647
+ excel: excel_slice_default,
648
+ profile: profile_slice_default
649
+ });
650
+ var envStore = configureStore({
651
+ reducer: rootReducer,
652
+ middleware: (getDefaultMiddleware) => getDefaultMiddleware({
653
+ serializableCheck: false
654
+ })
655
+ });
656
+
657
+ // src/store/index.ts
658
+ var useAppDispatch = useDispatch;
659
+ var useAppSelector = useSelector;
660
+ var MAINT_KEY = "MAINTENANCE_ACTIVE";
661
+ var MAINT_AT = "MAINTENANCE_AT";
662
+ var MAINT_LAST_PATH = "MAINTENANCE_LAST_PATH";
663
+ var hasRedirectedToMaintenance = false;
664
+ function setMaintenanceFlags() {
665
+ if (typeof window === "undefined") return;
666
+ const { pathname, search } = window.location;
667
+ const lastPath = pathname + (search || "");
668
+ if (pathname !== "/maintenance" && !window.localStorage.getItem(MAINT_LAST_PATH)) {
669
+ window.localStorage.setItem(MAINT_LAST_PATH, lastPath);
670
+ }
671
+ window.localStorage.setItem(MAINT_KEY, "true");
672
+ window.localStorage.setItem(MAINT_AT, String(Date.now()));
673
+ }
674
+ async function clearMaintenanceAndExit(getToken, opts) {
675
+ if (typeof window === "undefined") return;
676
+ const forceLogin = opts?.forceLogin === true;
677
+ const clearTokenOnForce = opts?.clearTokenOnForce !== false;
678
+ window.localStorage.removeItem(MAINT_KEY);
679
+ window.localStorage.removeItem(MAINT_AT);
680
+ const lastPath = window.localStorage.getItem(MAINT_LAST_PATH);
681
+ window.localStorage.removeItem(MAINT_LAST_PATH);
682
+ try {
683
+ if (forceLogin) {
684
+ if (clearTokenOnForce) {
685
+ try {
686
+ await opts?.clearToken?.();
687
+ } catch {
688
+ }
689
+ }
690
+ window.location.replace("/login");
691
+ return;
692
+ }
693
+ const token = await getToken();
694
+ if (token) {
695
+ const target = lastPath && lastPath !== "/maintenance" ? lastPath : "/";
696
+ window.location.replace(target);
697
+ } else {
698
+ window.location.replace("/login");
699
+ }
700
+ } catch {
701
+ window.location.replace("/login");
702
+ }
703
+ }
704
+ var axiosClient = {
705
+ init(config) {
706
+ const localStorage2 = config.localStorageUtils;
707
+ const sessionStorage = config.sessionStorageUtils;
708
+ const db = config.db;
709
+ let isRefreshing = false;
710
+ let failedQueue = [];
711
+ const processQueue = (error, token = null) => {
712
+ failedQueue?.forEach((prom) => {
713
+ if (error) {
714
+ prom.reject(error);
715
+ } else {
716
+ prom.resolve(token);
717
+ }
718
+ });
719
+ failedQueue = [];
720
+ };
721
+ const instance = axios.create({
722
+ adapter: axios.defaults.adapter,
723
+ baseURL: config.baseUrl,
724
+ timeout: 5e4,
725
+ paramsSerializer: (params) => new URLSearchParams(params).toString()
726
+ });
727
+ if (typeof window !== "undefined") {
728
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
729
+ const onMaintenancePage = window.location.pathname === "/maintenance";
730
+ if (isMaint && !onMaintenancePage) {
731
+ hasRedirectedToMaintenance = true;
732
+ window.location.replace("/maintenance");
733
+ }
734
+ if (isMaint && onMaintenancePage) {
735
+ const healthUrl = config.healthUrl || `${(config.baseUrl || "").replace(/\/+$/, "")}/health`;
736
+ (async () => {
737
+ try {
738
+ await axios.get(healthUrl, { timeout: 8e3 });
739
+ await clearMaintenanceAndExit(() => localStorage2.getAccessToken(), {
740
+ forceLogin: true,
741
+ clearTokenOnForce: true,
742
+ clearToken: () => localStorage2.clearToken()
743
+ });
744
+ } catch {
745
+ }
746
+ })();
747
+ }
748
+ }
749
+ instance.interceptors.request.use(
750
+ async (configReq) => {
751
+ const token = await localStorage2.getAccessToken();
752
+ if (token) {
753
+ configReq.headers["Authorization"] = "Bearer " + token;
754
+ }
755
+ return configReq;
756
+ },
757
+ (error) => Promise.reject(error)
758
+ );
759
+ instance.interceptors.response.use(
760
+ (response) => {
761
+ if (typeof window !== "undefined") {
762
+ const isMaint = window.localStorage.getItem(MAINT_KEY) === "true";
763
+ const onMaintenancePage = window.location.pathname === "/maintenance";
764
+ if (isMaint && onMaintenancePage) {
765
+ (async () => {
766
+ await clearMaintenanceAndExit(
767
+ () => localStorage2.getAccessToken(),
768
+ {
769
+ forceLogin: true,
770
+ clearTokenOnForce: true,
771
+ clearToken: () => localStorage2.clearToken()
772
+ }
773
+ );
774
+ })();
775
+ } else if (isMaint) {
776
+ window.localStorage.removeItem(MAINT_KEY);
777
+ window.localStorage.removeItem(MAINT_AT);
778
+ window.localStorage.removeItem(MAINT_LAST_PATH);
779
+ }
780
+ }
781
+ return handleResponse(response);
782
+ },
783
+ async (error) => {
784
+ const status = error?.response?.status;
785
+ if (status === 503) {
786
+ if (typeof window !== "undefined") {
787
+ setMaintenanceFlags();
788
+ if (!hasRedirectedToMaintenance && window.location.pathname !== "/maintenance") {
789
+ hasRedirectedToMaintenance = true;
790
+ window.location.replace("/maintenance");
791
+ }
792
+ }
793
+ return Promise.reject({
794
+ code: 503,
795
+ message: "SERVICE_UNAVAILABLE",
796
+ original: error?.response?.data
797
+ });
798
+ }
799
+ const handleError = async (err) => {
800
+ if (!err.response) {
801
+ return err;
802
+ }
803
+ const { data } = err.response;
804
+ if (data && data.code === 400 && ["invalid_grant"].includes(data.data?.error)) {
805
+ await clearAuthToken();
806
+ }
807
+ return data;
808
+ };
809
+ const originalRequest = error.config;
810
+ if ((error.response?.status === 403 || error.response?.status === 401 || error.response?.status === 404) && ["TOKEN_EXPIRED", "AUTHEN_FAIL", 401].includes(
811
+ error.response.data.code
812
+ )) {
813
+ if (isRefreshing) {
814
+ return new Promise(function(resolve, reject) {
815
+ failedQueue.push({ resolve, reject });
816
+ }).then((token) => {
817
+ originalRequest.headers["Authorization"] = "Bearer " + token;
818
+ return instance.request(originalRequest);
819
+ }).catch(async (err) => {
820
+ if ((err.response?.status === 400 || err.response?.status === 401) && ["invalid_grant"].includes(err.response.data.error)) {
821
+ await clearAuthToken();
822
+ }
823
+ });
824
+ }
825
+ const browserSession = await sessionStorage.getBrowserSession();
826
+ const refreshToken = await localStorage2.getRefreshToken();
827
+ const accessTokenExp = await localStorage2.getAccessToken();
828
+ isRefreshing = true;
829
+ if (!refreshToken && (!browserSession || browserSession == "unActive")) {
830
+ await clearAuthToken();
831
+ } else {
832
+ const payload = Object.fromEntries(
833
+ Object.entries({
834
+ refresh_token: refreshToken,
835
+ grant_type: "refresh_token",
836
+ client_id: config.config.clientId,
837
+ client_secret: config.config.clientSecret
838
+ }).filter(([_, value]) => !!value)
839
+ );
840
+ return new Promise(function(resolve) {
841
+ axios.post(
842
+ `${config.baseUrl}${"/authentication/oauth2/token" /* AUTH_TOKEN_PATH */}`,
843
+ payload,
844
+ {
845
+ headers: {
846
+ "Content-Type": "multipart/form-data",
847
+ Authorization: `Bearer ${accessTokenExp}`
848
+ }
849
+ }
850
+ ).then(async (res) => {
851
+ const data = res.data;
852
+ await localStorage2.setToken(data.access_token);
853
+ await localStorage2.setRefreshToken(data.refresh_token);
854
+ axios.defaults.headers.common["Authorization"] = "Bearer " + data.access_token;
855
+ originalRequest.headers["Authorization"] = "Bearer " + data.access_token;
856
+ processQueue(null, data.access_token);
857
+ resolve(instance.request(originalRequest));
858
+ }).catch(async (err) => {
859
+ if (err && (err?.error_code === "AUTHEN_FAIL" || err?.error_code === "TOKEN_EXPIRED" || err?.error_code === "TOKEN_INCORRECT" || err?.code === "ERR_BAD_REQUEST")) {
860
+ await clearAuthToken();
861
+ }
862
+ if (err && err.response) {
863
+ const { error_code } = err.response?.data || {};
864
+ if (error_code === "AUTHEN_FAIL") {
865
+ await clearAuthToken();
866
+ }
867
+ }
868
+ processQueue(err, null);
869
+ }).finally(() => {
870
+ isRefreshing = false;
871
+ });
872
+ });
873
+ }
874
+ }
875
+ return Promise.reject(await handleError(error));
876
+ }
877
+ );
878
+ const handleResponse = (res) => {
879
+ if (res && res.data) {
880
+ return res.data;
881
+ }
882
+ return res;
883
+ };
884
+ const clearAuthToken = async () => {
885
+ await localStorage2.clearToken();
886
+ if (typeof window !== "undefined") {
887
+ window.location.href = `/login`;
888
+ }
889
+ };
890
+ function formatUrl(url, db2) {
891
+ return url + (db2 ? "?db=" + db2 : "");
892
+ }
893
+ const responseBody = (response) => response;
894
+ const requests = {
895
+ get: (url, headers) => instance.get(formatUrl(url, db), headers).then(responseBody),
896
+ post: (url, body, headers) => instance.post(formatUrl(url, db), body, { headers }).then(responseBody),
897
+ post_excel: (url, body, headers) => instance.post(formatUrl(url, db), body, {
898
+ responseType: "arraybuffer",
899
+ headers: {
900
+ "Content-Type": typeof window !== "undefined" ? "application/json" : "application/javascript",
901
+ Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
902
+ }
903
+ }).then(responseBody),
904
+ put: (url, body, headers) => instance.put(formatUrl(url, db), body, headers).then(responseBody),
905
+ patch: (url, body) => instance.patch(formatUrl(url, db), body).then(responseBody),
906
+ delete: (url, body) => instance.delete(formatUrl(url, db), body).then(responseBody)
907
+ };
908
+ return requests;
909
+ }
910
+ };
911
+
912
+ // src/environment/EnvStore.ts
913
+ var EnvStore = class {
914
+ envStore;
915
+ baseUrl;
916
+ requests;
917
+ context;
918
+ defaultCompany;
919
+ config;
920
+ companies;
921
+ user;
922
+ db;
923
+ localStorageUtils;
924
+ sessionStorageUtils;
925
+ constructor(envStore2, localStorageUtils, sessionStorageUtils) {
926
+ this.envStore = envStore2;
927
+ this.localStorageUtils = localStorageUtils;
928
+ this.sessionStorageUtils = sessionStorageUtils;
929
+ this.setup();
930
+ }
931
+ setup() {
932
+ const env2 = this.envStore.getState().env;
933
+ this.baseUrl = env2?.baseUrl;
934
+ this.requests = env2?.requests;
935
+ this.context = env2?.context;
936
+ this.defaultCompany = env2?.defaultCompany;
937
+ this.config = env2?.config;
938
+ this.companies = env2?.companies || [];
939
+ this.user = env2?.user;
940
+ this.db = env2?.db;
941
+ }
942
+ setupEnv(envConfig) {
943
+ const dispatch = this.envStore.dispatch;
944
+ const env2 = {
945
+ ...envConfig,
946
+ localStorageUtils: this.localStorageUtils,
947
+ sessionStorageUtils: this.sessionStorageUtils
948
+ };
949
+ const requests = axiosClient.init(env2);
950
+ dispatch(setEnv({ ...env2, requests }));
951
+ this.setup();
952
+ }
953
+ setUid(uid) {
954
+ const dispatch = this.envStore.dispatch;
955
+ dispatch(setUid(uid));
956
+ this.setup();
957
+ }
958
+ setLang(lang) {
959
+ const dispatch = this.envStore.dispatch;
960
+ dispatch(setLang(lang));
961
+ this.setup();
962
+ }
963
+ setAllowCompanies(allowCompanies) {
964
+ const dispatch = this.envStore.dispatch;
965
+ dispatch(setAllowCompanies(allowCompanies));
966
+ this.setup();
967
+ }
968
+ setCompanies(companies) {
969
+ const dispatch = this.envStore.dispatch;
970
+ dispatch(setCompanies(companies));
971
+ this.setup();
972
+ }
973
+ setDefaultCompany(company) {
974
+ const dispatch = this.envStore.dispatch;
975
+ dispatch(setDefaultCompany(company));
976
+ this.setup();
977
+ }
978
+ setUserInfo(userInfo) {
979
+ const dispatch = this.envStore.dispatch;
980
+ dispatch(setUser(userInfo));
981
+ this.setup();
982
+ }
983
+ };
984
+ var env = null;
985
+ function initEnv({}) {
986
+ env = new EnvStore(envStore);
987
+ return env;
988
+ }
989
+ function getEnv() {
990
+ if (!env) env = new EnvStore(envStore);
991
+ return env;
992
+ }
993
+
994
+ // src/utils/domain/py_tokenizer.ts
995
+ var TokenizerError = class extends Error {
996
+ };
997
+ var directMap = {
998
+ "\\": "\\",
999
+ '"': '"',
1000
+ "'": "'",
1001
+ a: "\x07",
1002
+ b: "\b",
1003
+ f: "\f",
1004
+ n: "\n",
1005
+ r: "\r",
1006
+ t: " ",
1007
+ v: "\v"
1008
+ };
1009
+ function decodeStringLiteral(str, unicode) {
1010
+ const out = [];
1011
+ let code;
1012
+ for (let i = 0; i < str.length; ++i) {
1013
+ if (str[i] !== "\\") {
1014
+ out.push(str[i]);
1015
+ continue;
1016
+ }
1017
+ const escape = str[i + 1];
1018
+ if (escape in directMap) {
1019
+ out.push(directMap[escape]);
1020
+ ++i;
1021
+ continue;
1022
+ }
1023
+ switch (escape) {
1024
+ case "\n":
1025
+ ++i;
1026
+ continue;
1027
+ case "N":
1028
+ if (!unicode) {
1029
+ break;
1030
+ }
1031
+ throw new TokenizerError("SyntaxError: \\N{} escape not implemented");
1032
+ case "u":
1033
+ if (!unicode) {
1034
+ break;
1035
+ }
1036
+ const uni = str.slice(i + 2, i + 6);
1037
+ if (!/[0-9a-f]{4}/i.test(uni)) {
1038
+ throw new TokenizerError(
1039
+ [
1040
+ "SyntaxError: (unicode error) 'unicodeescape' codec",
1041
+ " can't decode bytes in position ",
1042
+ i,
1043
+ "-",
1044
+ i + 4,
1045
+ ": truncated \\uXXXX escape"
1046
+ ].join("")
1047
+ );
1048
+ }
1049
+ code = parseInt(uni, 16);
1050
+ out.push(String.fromCharCode(code));
1051
+ i += 5;
1052
+ continue;
1053
+ case "U":
1054
+ if (!unicode) {
1055
+ break;
1056
+ }
1057
+ throw new TokenizerError("SyntaxError: \\U escape not implemented");
1058
+ case "x":
1059
+ const hex = str.slice(i + 2, i + 4);
1060
+ if (!/[0-9a-f]{2}/i.test(hex)) {
1061
+ if (!unicode) {
1062
+ throw new TokenizerError("ValueError: invalid \\x escape");
1063
+ }
1064
+ throw new TokenizerError(
1065
+ [
1066
+ "SyntaxError: (unicode error) 'unicodeescape'",
1067
+ " codec can't decode bytes in position ",
1068
+ i,
1069
+ "-",
1070
+ i + 2,
1071
+ ": truncated \\xXX escape"
1072
+ ].join("")
1073
+ );
1074
+ }
1075
+ code = parseInt(hex, 16);
1076
+ out.push(String.fromCharCode(code));
1077
+ i += 3;
1078
+ continue;
1079
+ default:
1080
+ if (!/[0-8]/.test(escape)) {
1081
+ break;
1082
+ }
1083
+ const r = /[0-8]{1,3}/g;
1084
+ r.lastIndex = i + 1;
1085
+ const m = r.exec(str);
1086
+ if (!m) break;
1087
+ const oct = m[0];
1088
+ code = parseInt(oct, 8);
1089
+ out.push(String.fromCharCode(code));
1090
+ i += oct.length;
1091
+ continue;
1092
+ }
1093
+ out.push("\\");
1094
+ }
1095
+ return out.join("");
1096
+ }
1097
+ var constants = /* @__PURE__ */ new Set(["None", "False", "True"]);
1098
+ var comparators = [
1099
+ "in",
1100
+ "not",
1101
+ "not in",
1102
+ "is",
1103
+ "is not",
1104
+ "<",
1105
+ "<=",
1106
+ ">",
1107
+ ">=",
1108
+ "<>",
1109
+ "!=",
1110
+ "=="
1111
+ ];
1112
+ var binaryOperators = [
1113
+ "or",
1114
+ "and",
1115
+ "|",
1116
+ "^",
1117
+ "&",
1118
+ "<<",
1119
+ ">>",
1120
+ "+",
1121
+ "-",
1122
+ "*",
1123
+ "/",
1124
+ "//",
1125
+ "%",
1126
+ "~",
1127
+ "**",
1128
+ "."
1129
+ ];
1130
+ var unaryOperators = ["-"];
1131
+ var symbols = /* @__PURE__ */ new Set([
1132
+ ...["(", ")", "[", "]", "{", "}", ":", ","],
1133
+ ...["if", "else", "lambda", "="],
1134
+ ...comparators,
1135
+ ...binaryOperators,
1136
+ ...unaryOperators
1137
+ ]);
1138
+ function group(...args) {
1139
+ return "(" + args.join("|") + ")";
1140
+ }
1141
+ var Name = "[a-zA-Z_]\\w*";
1142
+ var Whitespace = "[ \\f\\t]*";
1143
+ var DecNumber = "\\d+(L|l)?";
1144
+ var IntNumber = DecNumber;
1145
+ var Exponent = "[eE][+-]?\\d+";
1146
+ var PointFloat = group(`\\d+\\.\\d*(${Exponent})?`, `\\.\\d+(${Exponent})?`);
1147
+ var FloatNumber = group(PointFloat, `\\d+${Exponent}`);
1148
+ var Number2 = group(FloatNumber, IntNumber);
1149
+ var Operator = group(
1150
+ "\\*\\*=?",
1151
+ ">>=?",
1152
+ "<<=?",
1153
+ "<>",
1154
+ "!=",
1155
+ "//=?",
1156
+ "[+\\-*/%&|^=<>]=?",
1157
+ "~"
1158
+ );
1159
+ var Bracket = "[\\[\\]\\(\\)\\{\\}]";
1160
+ var Special = "[:;.,`@]";
1161
+ var Funny = group(Operator, Bracket, Special);
1162
+ var ContStr = group(
1163
+ "([uU])?'([^\\n'\\\\]*(?:\\\\.[^\\n'\\\\]*)*)'",
1164
+ '([uU])?"([^\\n"\\\\]*(?:\\\\.[^\\n"\\\\]*)*)"'
1165
+ );
1166
+ var PseudoToken = Whitespace + group(Number2, Funny, ContStr, Name);
1167
+ var NumberPattern = new RegExp("^" + Number2 + "$");
1168
+ var StringPattern = new RegExp("^" + ContStr + "$");
1169
+ var NamePattern = new RegExp("^" + Name + "$");
1170
+ var strip = new RegExp("^" + Whitespace);
1171
+ function tokenize(str) {
1172
+ const tokens = [];
1173
+ const max = str.length;
1174
+ let start = 0;
1175
+ let end = 0;
1176
+ const pseudoprog = new RegExp(PseudoToken, "g");
1177
+ while (pseudoprog.lastIndex < max) {
1178
+ const pseudomatch = pseudoprog.exec(str);
1179
+ if (!pseudomatch) {
1180
+ if (/^\s+$/.test(str.slice(end))) {
1181
+ break;
1182
+ }
1183
+ throw new TokenizerError(
1184
+ "Failed to tokenize <<" + str + ">> at index " + (end || 0) + "; parsed so far: " + tokens
1185
+ );
1186
+ }
1187
+ if (pseudomatch.index > end) {
1188
+ if (str.slice(end, pseudomatch.index).trim()) {
1189
+ throw new TokenizerError("Invalid expression");
1190
+ }
1191
+ }
1192
+ start = pseudomatch.index;
1193
+ end = pseudoprog.lastIndex;
1194
+ let token = str.slice(start, end).replace(strip, "");
1195
+ if (NumberPattern.test(token)) {
1196
+ tokens.push({
1197
+ type: 0,
1198
+ value: parseFloat(token)
1199
+ });
1200
+ } else if (StringPattern.test(token)) {
1201
+ const m = StringPattern.exec(token);
1202
+ if (!m) throw new TokenizerError("Invalid string match");
1203
+ tokens.push({
1204
+ type: 1,
1205
+ value: decodeStringLiteral(
1206
+ m[3] !== void 0 ? m[3] : m[5],
1207
+ !!(m[2] || m[4])
1208
+ )
1209
+ });
1210
+ } else if (symbols.has(token)) {
1211
+ if (token === "in" && tokens.length > 0 && tokens[tokens.length - 1].value === "not") {
1212
+ token = "not in";
1213
+ tokens.pop();
1214
+ } else if (token === "not" && tokens.length > 0 && tokens[tokens.length - 1].value === "is") {
1215
+ token = "is not";
1216
+ tokens.pop();
1217
+ }
1218
+ tokens.push({
1219
+ type: 2,
1220
+ value: token
1221
+ });
1222
+ } else if (constants.has(token)) {
1223
+ tokens.push({
1224
+ type: 4,
1225
+ value: token
1226
+ });
1227
+ } else if (NamePattern.test(token)) {
1228
+ tokens.push({
1229
+ type: 3,
1230
+ value: token
1231
+ });
1232
+ } else {
1233
+ throw new TokenizerError("Invalid expression");
1234
+ }
1235
+ }
1236
+ return tokens;
1237
+ }
1238
+
1239
+ // src/utils/domain/py_parser.ts
1240
+ var ParserError = class extends Error {
1241
+ };
1242
+ var chainedOperators = new Set(comparators);
1243
+ var infixOperators = /* @__PURE__ */ new Set([...binaryOperators, ...comparators]);
1244
+ function bp(symbol) {
1245
+ switch (symbol) {
1246
+ case "=":
1247
+ return 10;
1248
+ case "if":
1249
+ return 20;
1250
+ case "in":
1251
+ case "not in":
1252
+ case "is":
1253
+ case "is not":
1254
+ case "<":
1255
+ case "<=":
1256
+ case ">":
1257
+ case ">=":
1258
+ case "<>":
1259
+ case "==":
1260
+ case "!=":
1261
+ return 60;
1262
+ case "or":
1263
+ return 30;
1264
+ case "and":
1265
+ return 40;
1266
+ case "not":
1267
+ return 50;
1268
+ case "|":
1269
+ return 70;
1270
+ case "^":
1271
+ return 80;
1272
+ case "&":
1273
+ return 90;
1274
+ case "<<":
1275
+ case ">>":
1276
+ return 100;
1277
+ case "+":
1278
+ case "-":
1279
+ return 110;
1280
+ case "*":
1281
+ case "/":
1282
+ case "//":
1283
+ case "%":
1284
+ return 120;
1285
+ case "**":
1286
+ return 140;
1287
+ case ".":
1288
+ case "(":
1289
+ case "[":
1290
+ return 150;
1291
+ default:
1292
+ return 0;
1293
+ }
1294
+ }
1295
+ function bindingPower(token) {
1296
+ return token.type === 2 ? bp(token.value) : 0;
1297
+ }
1298
+ function isSymbol(token, value) {
1299
+ return token.type === 2 && token.value === value;
1300
+ }
1301
+ function parsePrefix(current, tokens) {
1302
+ switch (current.type) {
1303
+ case 0:
1304
+ return { type: 0, value: current.value };
1305
+ case 1:
1306
+ return { type: 1, value: current.value };
1307
+ case 4:
1308
+ if (current.value === "None") {
1309
+ return {
1310
+ type: 3
1311
+ /* None */
1312
+ };
1313
+ } else {
1314
+ return { type: 2, value: current.value === "True" };
1315
+ }
1316
+ case 3:
1317
+ return { type: 5, value: current.value };
1318
+ case 2:
1319
+ switch (current.value) {
1320
+ case "-":
1321
+ case "+":
1322
+ case "~":
1323
+ return {
1324
+ type: 6,
1325
+ op: current.value,
1326
+ right: _parse(tokens, 130)
1327
+ };
1328
+ case "not":
1329
+ return {
1330
+ type: 6,
1331
+ op: current.value,
1332
+ right: _parse(tokens, 50)
1333
+ };
1334
+ case "(":
1335
+ const content = [];
1336
+ let isTuple = false;
1337
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
1338
+ content.push(_parse(tokens, 0));
1339
+ if (tokens[0]) {
1340
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
1341
+ isTuple = true;
1342
+ tokens.shift();
1343
+ } else if (!isSymbol(tokens[0], ")")) {
1344
+ throw new ParserError("parsing error");
1345
+ }
1346
+ } else {
1347
+ throw new ParserError("parsing error");
1348
+ }
1349
+ }
1350
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
1351
+ throw new ParserError("parsing error");
1352
+ }
1353
+ tokens.shift();
1354
+ isTuple = isTuple || content.length === 0;
1355
+ return isTuple ? { type: 10, value: content } : content[0];
1356
+ case "[":
1357
+ const value = [];
1358
+ while (tokens[0] && !isSymbol(tokens[0], "]")) {
1359
+ value.push(_parse(tokens, 0));
1360
+ if (tokens[0]) {
1361
+ if (isSymbol(tokens[0], ",")) {
1362
+ tokens.shift();
1363
+ } else if (!isSymbol(tokens[0], "]")) {
1364
+ throw new ParserError("parsing error");
1365
+ }
1366
+ }
1367
+ }
1368
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
1369
+ throw new ParserError("parsing error");
1370
+ }
1371
+ tokens.shift();
1372
+ return { type: 4, value };
1373
+ case "{":
1374
+ const dict = {};
1375
+ while (tokens[0] && !isSymbol(tokens[0], "}")) {
1376
+ const key = _parse(tokens, 0);
1377
+ if (key.type !== 1 && key.type !== 0 || !tokens[0] || !isSymbol(tokens[0], ":")) {
1378
+ throw new ParserError("parsing error");
1379
+ }
1380
+ tokens.shift();
1381
+ const val = _parse(tokens, 0);
1382
+ dict[key.value] = val;
1383
+ if (isSymbol(tokens[0], ",")) {
1384
+ tokens.shift();
1385
+ }
1386
+ }
1387
+ if (!tokens.shift()) {
1388
+ throw new ParserError("parsing error");
1389
+ }
1390
+ return { type: 11, value: dict };
1391
+ default:
1392
+ throw new ParserError("Token cannot be parsed");
1393
+ }
1394
+ default:
1395
+ throw new ParserError("Token cannot be parsed");
1396
+ }
1397
+ }
1398
+ function parseInfix(left, current, tokens) {
1399
+ switch (current.type) {
1400
+ case 2:
1401
+ if (infixOperators.has(current.value)) {
1402
+ let right = _parse(tokens, bindingPower(current));
1403
+ if (current.value === "and" || current.value === "or") {
1404
+ return {
1405
+ type: 14,
1406
+ op: current.value,
1407
+ left,
1408
+ right
1409
+ };
1410
+ } else if (current.value === ".") {
1411
+ if (right.type === 5) {
1412
+ return {
1413
+ type: 15,
1414
+ obj: left,
1415
+ key: right.value
1416
+ };
1417
+ } else {
1418
+ throw new ParserError("invalid obj lookup");
1419
+ }
1420
+ }
1421
+ let op = {
1422
+ type: 7,
1423
+ op: current.value,
1424
+ left,
1425
+ right
1426
+ };
1427
+ while (chainedOperators.has(current.value) && tokens[0] && tokens[0].type === 2 && chainedOperators.has(tokens[0].value)) {
1428
+ const nextToken = tokens.shift();
1429
+ op = {
1430
+ type: 14,
1431
+ op: "and",
1432
+ left: op,
1433
+ right: {
1434
+ type: 7,
1435
+ op: nextToken.value,
1436
+ left: right,
1437
+ right: _parse(tokens, bindingPower(nextToken))
1438
+ }
1439
+ };
1440
+ right = op.right;
1441
+ }
1442
+ return op;
1443
+ }
1444
+ switch (current.value) {
1445
+ case "(":
1446
+ const args = [];
1447
+ const kwargs = {};
1448
+ while (tokens[0] && !isSymbol(tokens[0], ")")) {
1449
+ const arg = _parse(tokens, 0);
1450
+ if (arg.type === 9) {
1451
+ kwargs[arg.name.value] = arg.value;
1452
+ } else {
1453
+ args.push(arg);
1454
+ }
1455
+ if (tokens[0] && isSymbol(tokens[0], ",")) {
1456
+ tokens.shift();
1457
+ }
1458
+ }
1459
+ if (!tokens[0] || !isSymbol(tokens[0], ")")) {
1460
+ throw new ParserError("parsing error");
1461
+ }
1462
+ tokens.shift();
1463
+ return { type: 8, fn: left, args, kwargs };
1464
+ case "=":
1465
+ if (left.type === 5) {
1466
+ return {
1467
+ type: 9,
1468
+ name: left,
1469
+ value: _parse(tokens, 10)
1470
+ };
1471
+ }
1472
+ break;
1473
+ case "[":
1474
+ const key = _parse(tokens);
1475
+ if (!tokens[0] || !isSymbol(tokens[0], "]")) {
1476
+ throw new ParserError("parsing error");
1477
+ }
1478
+ tokens.shift();
1479
+ return {
1480
+ type: 12,
1481
+ target: left,
1482
+ key
1483
+ };
1484
+ case "if":
1485
+ const condition = _parse(tokens);
1486
+ if (!tokens[0] || !isSymbol(tokens[0], "else")) {
1487
+ throw new ParserError("parsing error");
1488
+ }
1489
+ tokens.shift();
1490
+ const ifFalse = _parse(tokens);
1491
+ return {
1492
+ type: 13,
1493
+ condition,
1494
+ ifTrue: left,
1495
+ ifFalse
1496
+ };
1497
+ }
1498
+ }
1499
+ throw new ParserError("Token cannot be parsed");
1500
+ }
1501
+ function _parse(tokens, bp2 = 0) {
1502
+ const token = tokens.shift();
1503
+ if (!token) {
1504
+ throw new ParserError("Unexpected end of input");
1505
+ }
1506
+ let expr = parsePrefix(token, tokens);
1507
+ while (tokens[0] && bindingPower(tokens[0]) > bp2) {
1508
+ expr = parseInfix(expr, tokens.shift(), tokens);
1509
+ }
1510
+ return expr;
1511
+ }
1512
+ function parse(tokens) {
1513
+ if (tokens.length) {
1514
+ return _parse(tokens, 0);
1515
+ }
1516
+ throw new ParserError("Missing token");
1517
+ }
1518
+ function parseArgs(args, spec) {
1519
+ const last = args[args.length - 1];
1520
+ const unnamedArgs = typeof last === "object" ? args.slice(0, -1) : args;
1521
+ const kwargs = typeof last === "object" ? last : {};
1522
+ for (const [index, val] of unnamedArgs.entries()) {
1523
+ kwargs[spec[index]] = val;
1524
+ }
1525
+ return kwargs;
1526
+ }
1527
+
1528
+ // src/utils/domain/py_date.ts
1529
+ var AssertionError = class extends Error {
1530
+ };
1531
+ var ValueError = class extends Error {
1532
+ };
1533
+ var NotSupportedError = class extends Error {
1534
+ };
1535
+ function fmt2(n) {
1536
+ return String(n).padStart(2, "0");
1537
+ }
1538
+ function fmt4(n) {
1539
+ return String(n).padStart(4, "0");
1540
+ }
1541
+ function divmod(a, b, fn) {
1542
+ let mod = a % b;
1543
+ if (mod > 0 && b < 0 || mod < 0 && b > 0) {
1544
+ mod += b;
1545
+ }
1546
+ return fn(Math.floor(a / b), mod);
1547
+ }
1548
+ function assert(bool, message = "AssertionError") {
1549
+ if (!bool) {
1550
+ throw new AssertionError(message);
1551
+ }
1552
+ }
1553
+ var DAYS_IN_MONTH = [
1554
+ null,
1555
+ 31,
1556
+ 28,
1557
+ 31,
1558
+ 30,
1559
+ 31,
1560
+ 30,
1561
+ 31,
1562
+ 31,
1563
+ 30,
1564
+ 31,
1565
+ 30,
1566
+ 31
1567
+ ];
1568
+ var DAYS_BEFORE_MONTH = [null];
1569
+ for (let dbm = 0, i = 1; i < DAYS_IN_MONTH.length; ++i) {
1570
+ DAYS_BEFORE_MONTH.push(dbm);
1571
+ dbm += DAYS_IN_MONTH[i];
1572
+ }
1573
+ function daysInMonth(year, month) {
1574
+ if (month === 2 && isLeap(year)) {
1575
+ return 29;
1576
+ }
1577
+ return DAYS_IN_MONTH[month];
1578
+ }
1579
+ function isLeap(year) {
1580
+ return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
1581
+ }
1582
+ function daysBeforeYear(year) {
1583
+ const y = year - 1;
1584
+ return y * 365 + Math.floor(y / 4) - Math.floor(y / 100) + Math.floor(y / 400);
1585
+ }
1586
+ function daysBeforeMonth(year, month) {
1587
+ const postLeapFeb = month > 2 && isLeap(year);
1588
+ return DAYS_BEFORE_MONTH[month] + (postLeapFeb ? 1 : 0);
1589
+ }
1590
+ function ymd2ord(year, month, day) {
1591
+ const dim = daysInMonth(year, month);
1592
+ if (!(1 <= day && day <= dim)) {
1593
+ throw new ValueError(`day must be in 1..${dim}`);
1594
+ }
1595
+ return daysBeforeYear(year) + daysBeforeMonth(year, month) + day;
1596
+ }
1597
+ var DI400Y = daysBeforeYear(401);
1598
+ var DI100Y = daysBeforeYear(101);
1599
+ var DI4Y = daysBeforeYear(5);
1600
+ function ord2ymd(n) {
1601
+ --n;
1602
+ let n400 = 0, n100 = 0, n4 = 0, n1 = 0, n0 = 0;
1603
+ divmod(n, DI400Y, (_n400, n2) => {
1604
+ n400 = _n400;
1605
+ divmod(n2, DI100Y, (_n100, n3) => {
1606
+ n100 = _n100;
1607
+ divmod(n3, DI4Y, (_n4, n5) => {
1608
+ n4 = _n4;
1609
+ divmod(n5, 365, (_n1, n6) => {
1610
+ n1 = _n1;
1611
+ n0 = n6;
1612
+ });
1613
+ });
1614
+ });
1615
+ });
1616
+ n = n0;
1617
+ const year = n400 * 400 + 1 + n100 * 100 + n4 * 4 + n1;
1618
+ if (n1 === 4 || n100 === 100) {
1619
+ assert(n0 === 0);
1620
+ return {
1621
+ year: year - 1,
1622
+ month: 12,
1623
+ day: 31
1624
+ };
1625
+ }
1626
+ const leapyear = n1 === 3 && (n4 !== 24 || n100 === 3);
1627
+ assert(leapyear === isLeap(year));
1628
+ let month = n + 50 >> 5;
1629
+ let preceding = DAYS_BEFORE_MONTH[month] + (month > 2 && leapyear ? 1 : 0);
1630
+ if (preceding > n) {
1631
+ --month;
1632
+ preceding -= DAYS_IN_MONTH[month] + (month === 2 && leapyear ? 1 : 0);
1633
+ }
1634
+ n -= preceding;
1635
+ return {
1636
+ year,
1637
+ month,
1638
+ day: n + 1
1639
+ };
1640
+ }
1641
+ function tmxxx(year, month, day, hour, minute, second, microsecond) {
1642
+ hour = hour || 0;
1643
+ minute = minute || 0;
1644
+ second = second || 0;
1645
+ microsecond = microsecond || 0;
1646
+ if (microsecond < 0 || microsecond > 999999) {
1647
+ divmod(microsecond, 1e6, (carry, ms) => {
1648
+ microsecond = ms;
1649
+ second += carry;
1650
+ });
1651
+ }
1652
+ if (second < 0 || second > 59) {
1653
+ divmod(second, 60, (carry, s) => {
1654
+ second = s;
1655
+ minute += carry;
1656
+ });
1657
+ }
1658
+ if (minute < 0 || minute > 59) {
1659
+ divmod(minute, 60, (carry, m) => {
1660
+ minute = m;
1661
+ hour += carry;
1662
+ });
1663
+ }
1664
+ if (hour < 0 || hour > 23) {
1665
+ divmod(hour, 24, (carry, h) => {
1666
+ hour = h;
1667
+ day += carry;
1668
+ });
1669
+ }
1670
+ if (month < 1 || month > 12) {
1671
+ divmod(month - 1, 12, (carry, m) => {
1672
+ month = m + 1;
1673
+ year += carry;
1674
+ });
1675
+ }
1676
+ const dim = daysInMonth(year, month);
1677
+ if (day < 1 || day > dim) {
1678
+ if (day === 0) {
1679
+ --month;
1680
+ if (month > 0) {
1681
+ day = daysInMonth(year, month);
1682
+ } else {
1683
+ --year;
1684
+ month = 12;
1685
+ day = 31;
1686
+ }
1687
+ } else if (day === dim + 1) {
1688
+ ++month;
1689
+ day = 1;
1690
+ if (month > 12) {
1691
+ month = 1;
1692
+ ++year;
1693
+ }
1694
+ } else {
1695
+ const r = ord2ymd(ymd2ord(year, month, 1) + (day - 1));
1696
+ year = r.year;
1697
+ month = r.month;
1698
+ day = r.day;
1699
+ }
1700
+ }
1701
+ return {
1702
+ year,
1703
+ month,
1704
+ day,
1705
+ hour,
1706
+ minute,
1707
+ second,
1708
+ microsecond
1709
+ };
1710
+ }
1711
+ var PyDate = class _PyDate {
1712
+ constructor(year, month, day) {
1713
+ this.year = year;
1714
+ this.month = month;
1715
+ this.day = day;
1716
+ }
1717
+ static today() {
1718
+ return this.convertDate(/* @__PURE__ */ new Date());
1719
+ }
1720
+ static convertDate(date) {
1721
+ const year = date.getFullYear();
1722
+ const month = date.getMonth() + 1;
1723
+ const day = date.getDate();
1724
+ return new _PyDate(year, month, day);
1725
+ }
1726
+ static create(...args) {
1727
+ const { year, month, day } = parseArgs(args, ["year", "month", "day"]);
1728
+ return new _PyDate(year, month, day);
1729
+ }
1730
+ add(timedelta) {
1731
+ const s = tmxxx(this.year, this.month, this.day + timedelta.days, 0, 0, 0);
1732
+ return new _PyDate(s.year, s.month, s.day);
1733
+ }
1734
+ isEqual(other) {
1735
+ if (!(other instanceof _PyDate)) {
1736
+ return false;
1737
+ }
1738
+ return this.year === other.year && this.month === other.month && this.day === other.day;
1739
+ }
1740
+ strftime(format) {
1741
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1742
+ switch (c) {
1743
+ case "Y":
1744
+ return fmt4(this.year);
1745
+ case "m":
1746
+ return fmt2(this.month);
1747
+ case "d":
1748
+ return fmt2(this.day);
1749
+ default:
1750
+ throw new ValueError(`No known conversion for ${m}`);
1751
+ }
1752
+ });
1753
+ }
1754
+ substract(other) {
1755
+ if (other instanceof PyTimeDelta) {
1756
+ return this.add(other.negate());
1757
+ }
1758
+ if (other instanceof _PyDate) {
1759
+ return PyTimeDelta.create(this.toordinal() - other.toordinal());
1760
+ }
1761
+ throw new NotSupportedError();
1762
+ }
1763
+ toJSON() {
1764
+ return this.strftime("%Y-%m-%d");
1765
+ }
1766
+ toordinal() {
1767
+ return ymd2ord(this.year, this.month, this.day);
1768
+ }
1769
+ };
1770
+ var PyDateTime = class _PyDateTime {
1771
+ constructor(year, month, day, hour, minute, second, microsecond) {
1772
+ this.year = year;
1773
+ this.month = month;
1774
+ this.day = day;
1775
+ this.hour = hour;
1776
+ this.minute = minute;
1777
+ this.second = second;
1778
+ this.microsecond = microsecond;
1779
+ }
1780
+ static now() {
1781
+ return this.convertDate(/* @__PURE__ */ new Date());
1782
+ }
1783
+ static convertDate(date) {
1784
+ const year = date.getFullYear();
1785
+ const month = date.getMonth() + 1;
1786
+ const day = date.getDate();
1787
+ const hour = date.getHours();
1788
+ const minute = date.getMinutes();
1789
+ const second = date.getSeconds();
1790
+ return new _PyDateTime(year, month, day, hour, minute, second, 0);
1791
+ }
1792
+ static create(...args) {
1793
+ const namedArgs = parseArgs(args, [
1794
+ "year",
1795
+ "month",
1796
+ "day",
1797
+ "hour",
1798
+ "minute",
1799
+ "second",
1800
+ "microsecond"
1801
+ ]);
1802
+ const year = namedArgs.year;
1803
+ const month = namedArgs.month;
1804
+ const day = namedArgs.day;
1805
+ const hour = namedArgs.hour || 0;
1806
+ const minute = namedArgs.minute || 0;
1807
+ const second = namedArgs.second || 0;
1808
+ const ms = namedArgs.microsecond / 1e3 || 0;
1809
+ return new _PyDateTime(year, month, day, hour, minute, second, ms);
1810
+ }
1811
+ static combine(...args) {
1812
+ const { date, time } = parseArgs(args, ["date", "time"]);
1813
+ return _PyDateTime.create(
1814
+ date.year,
1815
+ date.month,
1816
+ date.day,
1817
+ time.hour,
1818
+ time.minute,
1819
+ time.second
1820
+ );
1821
+ }
1822
+ add(timedelta) {
1823
+ const s = tmxxx(
1824
+ this.year,
1825
+ this.month,
1826
+ this.day + timedelta.days,
1827
+ this.hour,
1828
+ this.minute,
1829
+ this.second + timedelta.seconds,
1830
+ this.microsecond + timedelta.microseconds
1831
+ );
1832
+ return new _PyDateTime(
1833
+ s.year,
1834
+ s.month,
1835
+ s.day,
1836
+ s.hour,
1837
+ s.minute,
1838
+ s.second,
1839
+ s.microsecond
1840
+ );
1841
+ }
1842
+ isEqual(other) {
1843
+ if (!(other instanceof _PyDateTime)) {
1844
+ return false;
1845
+ }
1846
+ return this.year === other.year && this.month === other.month && this.day === other.day && this.hour === other.hour && this.minute === other.minute && this.second === other.second && this.microsecond === other.microsecond;
1847
+ }
1848
+ strftime(format) {
1849
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1850
+ switch (c) {
1851
+ case "Y":
1852
+ return fmt4(this.year);
1853
+ case "m":
1854
+ return fmt2(this.month);
1855
+ case "d":
1856
+ return fmt2(this.day);
1857
+ case "H":
1858
+ return fmt2(this.hour);
1859
+ case "M":
1860
+ return fmt2(this.minute);
1861
+ case "S":
1862
+ return fmt2(this.second);
1863
+ default:
1864
+ throw new ValueError(`No known conversion for ${m}`);
1865
+ }
1866
+ });
1867
+ }
1868
+ substract(timedelta) {
1869
+ return this.add(timedelta.negate());
1870
+ }
1871
+ toJSON() {
1872
+ return this.strftime("%Y-%m-%d %H:%M:%S");
1873
+ }
1874
+ to_utc() {
1875
+ const d = new Date(
1876
+ this.year,
1877
+ this.month - 1,
1878
+ this.day,
1879
+ this.hour,
1880
+ this.minute,
1881
+ this.second
1882
+ );
1883
+ const timedelta = PyTimeDelta.create({ minutes: d.getTimezoneOffset() });
1884
+ return this.add(timedelta);
1885
+ }
1886
+ };
1887
+ var PyTime = class _PyTime extends PyDate {
1888
+ constructor(hour, minute, second) {
1889
+ const now = /* @__PURE__ */ new Date();
1890
+ const year = now.getFullYear();
1891
+ const month = now.getMonth() + 1;
1892
+ const day = now.getDate();
1893
+ super(year, month, day);
1894
+ this.hour = hour;
1895
+ this.minute = minute;
1896
+ this.second = second;
1897
+ this.hour = hour;
1898
+ this.minute = minute;
1899
+ this.second = second;
1900
+ }
1901
+ static create(...args) {
1902
+ const namedArgs = parseArgs(args, ["hour", "minute", "second"]);
1903
+ const hour = namedArgs.hour || 0;
1904
+ const minute = namedArgs.minute || 0;
1905
+ const second = namedArgs.second || 0;
1906
+ return new _PyTime(hour, minute, second);
1907
+ }
1908
+ strftime(format) {
1909
+ return format.replace(/%([A-Za-z])/g, (m, c) => {
1910
+ switch (c) {
1911
+ case "Y":
1912
+ return fmt4(this.year);
1913
+ case "m":
1914
+ return fmt2(this.month);
1915
+ case "d":
1916
+ return fmt2(this.day);
1917
+ case "H":
1918
+ return fmt2(this.hour);
1919
+ case "M":
1920
+ return fmt2(this.minute);
1921
+ case "S":
1922
+ return fmt2(this.second);
1923
+ default:
1924
+ throw new ValueError(`No known conversion for ${m}`);
1925
+ }
1926
+ });
1927
+ }
1928
+ toJSON() {
1929
+ return this.strftime("%H:%M:%S");
1930
+ }
1931
+ };
1932
+ var DAYS_IN_YEAR = [
1933
+ 31,
1934
+ 59,
1935
+ 90,
1936
+ 120,
1937
+ 151,
1938
+ 181,
1939
+ 212,
1940
+ 243,
1941
+ 273,
1942
+ 304,
1943
+ 334,
1944
+ 366
1945
+ ];
1946
+ var TIME_PERIODS = ["hour", "minute", "second"];
1947
+ var PERIODS = ["year", "month", "day", ...TIME_PERIODS];
1948
+ var RELATIVE_KEYS = "years months weeks days hours minutes seconds microseconds leapdays".split(
1949
+ " "
1950
+ );
1951
+ var ABSOLUTE_KEYS = "year month day hour minute second microsecond weekday nlyearday yearday".split(
1952
+ " "
1953
+ );
1954
+ var argsSpec = ["dt1", "dt2"];
1955
+ var PyRelativeDelta = class _PyRelativeDelta {
1956
+ static create(...args) {
1957
+ const params = parseArgs(args, argsSpec);
1958
+ if ("dt1" in params) {
1959
+ throw new Error("relativedelta(dt1, dt2) is not supported for now");
1960
+ }
1961
+ for (const period of PERIODS) {
1962
+ if (period in params) {
1963
+ const val = params[period];
1964
+ assert(val >= 0, `${period} ${val} is out of range`);
1965
+ }
1966
+ }
1967
+ for (const key of RELATIVE_KEYS) {
1968
+ params[key] = params[key] || 0;
1969
+ }
1970
+ for (const key of ABSOLUTE_KEYS) {
1971
+ params[key] = key in params ? params[key] : null;
1972
+ }
1973
+ params.days += 7 * params.weeks;
1974
+ let yearDay = 0;
1975
+ if (params.nlyearday) {
1976
+ yearDay = params.nlyearday;
1977
+ } else if (params.yearday) {
1978
+ yearDay = params.yearday;
1979
+ if (yearDay > 59) {
1980
+ params.leapDays = -1;
1981
+ }
1982
+ }
1983
+ if (yearDay) {
1984
+ for (let monthIndex = 0; monthIndex < DAYS_IN_YEAR.length; monthIndex++) {
1985
+ if (yearDay <= DAYS_IN_YEAR[monthIndex]) {
1986
+ params.month = monthIndex + 1;
1987
+ if (monthIndex === 0) {
1988
+ params.day = yearDay;
1989
+ } else {
1990
+ params.day = yearDay - DAYS_IN_YEAR[monthIndex - 1];
1991
+ }
1992
+ break;
1993
+ }
1994
+ }
1995
+ }
1996
+ return new _PyRelativeDelta(params);
1997
+ }
1998
+ static add(date, delta) {
1999
+ if (!(date instanceof PyDate || date instanceof PyDateTime)) {
2000
+ throw new NotSupportedError();
2001
+ }
2002
+ const s = tmxxx(
2003
+ (delta.year || date.year) + delta.years,
2004
+ (delta.month || date.month) + delta.months,
2005
+ delta.day || date.day,
2006
+ delta.hour || (date instanceof PyDateTime ? date.hour : 0),
2007
+ delta.minute || (date instanceof PyDateTime ? date.minute : 0),
2008
+ delta.second || (date instanceof PyDateTime ? date.second : 0),
2009
+ delta.microseconds || (date instanceof PyDateTime ? date.microsecond : 0)
2010
+ );
2011
+ const newDateTime = new PyDateTime(
2012
+ s.year,
2013
+ s.month,
2014
+ s.day,
2015
+ s.hour,
2016
+ s.minute,
2017
+ s.second,
2018
+ s.microsecond
2019
+ );
2020
+ let leapDays = 0;
2021
+ if (delta.leapDays && newDateTime.month > 2 && isLeap(newDateTime.year)) {
2022
+ leapDays = delta.leapDays;
2023
+ }
2024
+ const temp = newDateTime.add(
2025
+ PyTimeDelta.create({
2026
+ days: delta.days + leapDays,
2027
+ hours: delta.hours,
2028
+ minutes: delta.minutes,
2029
+ seconds: delta.seconds,
2030
+ microseconds: delta.microseconds
2031
+ })
2032
+ );
2033
+ const hasTime = Boolean(
2034
+ temp.hour || temp.minute || temp.second || temp.microsecond
2035
+ );
2036
+ const returnDate = !hasTime && date instanceof PyDate ? new PyDate(temp.year, temp.month, temp.day) : temp;
2037
+ if (delta.weekday !== null) {
2038
+ const wantedDow = delta.weekday + 1;
2039
+ const _date = new Date(
2040
+ returnDate.year,
2041
+ returnDate.month - 1,
2042
+ returnDate.day
2043
+ );
2044
+ const days = (7 - _date.getDay() + wantedDow) % 7;
2045
+ return returnDate.add(new PyTimeDelta(days, 0, 0));
2046
+ }
2047
+ return returnDate;
2048
+ }
2049
+ static substract(date, delta) {
2050
+ return _PyRelativeDelta.add(date, delta.negate());
2051
+ }
2052
+ constructor(params = {}, sign = 1) {
2053
+ this.years = sign * params.years;
2054
+ this.months = sign * params.months;
2055
+ this.days = sign * params.days;
2056
+ this.hours = sign * params.hours;
2057
+ this.minutes = sign * params.minutes;
2058
+ this.seconds = sign * params.seconds;
2059
+ this.microseconds = sign * params.microseconds;
2060
+ this.leapDays = params.leapDays;
2061
+ this.year = params.year;
2062
+ this.month = params.month;
2063
+ this.day = params.day;
2064
+ this.hour = params.hour;
2065
+ this.minute = params.minute;
2066
+ this.second = params.second;
2067
+ this.microsecond = params.microsecond;
2068
+ this.weekday = params.weekday;
2069
+ }
2070
+ years;
2071
+ months;
2072
+ days;
2073
+ hours;
2074
+ minutes;
2075
+ seconds;
2076
+ microseconds;
2077
+ leapDays;
2078
+ year;
2079
+ month;
2080
+ day;
2081
+ hour;
2082
+ minute;
2083
+ second;
2084
+ microsecond;
2085
+ weekday;
2086
+ negate() {
2087
+ return new _PyRelativeDelta(this, -1);
2088
+ }
2089
+ isEqual() {
2090
+ throw new NotSupportedError();
2091
+ }
2092
+ };
2093
+ var TIME_DELTA_KEYS = "weeks days hours minutes seconds milliseconds microseconds".split(" ");
2094
+ function modf(x) {
2095
+ const mod = x % 1;
2096
+ return [mod < 0 ? mod + 1 : mod, Math.floor(x)];
2097
+ }
2098
+ var PyTimeDelta = class _PyTimeDelta {
2099
+ constructor(days, seconds, microseconds) {
2100
+ this.days = days;
2101
+ this.seconds = seconds;
2102
+ this.microseconds = microseconds;
2103
+ }
2104
+ static create(...args) {
2105
+ const namedArgs = parseArgs(args, ["days", "seconds", "microseconds"]);
2106
+ for (const key of TIME_DELTA_KEYS) {
2107
+ namedArgs[key] = namedArgs[key] || 0;
2108
+ }
2109
+ let d = 0;
2110
+ let s = 0;
2111
+ let us = 0;
2112
+ const days = namedArgs.days + namedArgs.weeks * 7;
2113
+ let seconds = namedArgs.seconds + 60 * namedArgs.minutes + 3600 * namedArgs.hours;
2114
+ let microseconds = namedArgs.microseconds + 1e3 * namedArgs.milliseconds;
2115
+ const [dFrac, dInt] = modf(days);
2116
+ d = dInt;
2117
+ let daysecondsfrac = 0;
2118
+ if (dFrac) {
2119
+ const [dsFrac, dsInt] = modf(dFrac * 24 * 3600);
2120
+ s = dsInt;
2121
+ daysecondsfrac = dsFrac;
2122
+ }
2123
+ const [sFrac, sInt] = modf(seconds);
2124
+ seconds = sInt;
2125
+ const secondsfrac = sFrac + daysecondsfrac;
2126
+ divmod(seconds, 24 * 3600, (days2, seconds2) => {
2127
+ d += days2;
2128
+ s += seconds2;
2129
+ });
2130
+ microseconds += secondsfrac * 1e6;
2131
+ divmod(microseconds, 1e6, (seconds2, microseconds2) => {
2132
+ divmod(seconds2, 24 * 3600, (days2, seconds3) => {
2133
+ d += days2;
2134
+ s += seconds3;
2135
+ us += Math.round(microseconds2);
2136
+ });
2137
+ });
2138
+ return new _PyTimeDelta(d, s, us);
2139
+ }
2140
+ add(other) {
2141
+ return _PyTimeDelta.create({
2142
+ days: this.days + other.days,
2143
+ seconds: this.seconds + other.seconds,
2144
+ microseconds: this.microseconds + other.microseconds
2145
+ });
2146
+ }
2147
+ divide(n) {
2148
+ const us = (this.days * 24 * 3600 + this.seconds) * 1e6 + this.microseconds;
2149
+ return _PyTimeDelta.create({ microseconds: Math.floor(us / n) });
2150
+ }
2151
+ isEqual(other) {
2152
+ if (!(other instanceof _PyTimeDelta)) {
2153
+ return false;
2154
+ }
2155
+ return this.days === other.days && this.seconds === other.seconds && this.microseconds === other.microseconds;
2156
+ }
2157
+ isTrue() {
2158
+ return this.days !== 0 || this.seconds !== 0 || this.microseconds !== 0;
2159
+ }
2160
+ multiply(n) {
2161
+ return _PyTimeDelta.create({
2162
+ days: n * this.days,
2163
+ seconds: n * this.seconds,
2164
+ microseconds: n * this.microseconds
2165
+ });
2166
+ }
2167
+ negate() {
2168
+ return _PyTimeDelta.create({
2169
+ days: -this.days,
2170
+ seconds: -this.seconds,
2171
+ microseconds: -this.microseconds
2172
+ });
2173
+ }
2174
+ substract(other) {
2175
+ return _PyTimeDelta.create({
2176
+ days: this.days - other.days,
2177
+ seconds: this.seconds - other.seconds,
2178
+ microseconds: this.microseconds - other.microseconds
2179
+ });
2180
+ }
2181
+ total_seconds() {
2182
+ return this.days * 86400 + this.seconds + this.microseconds / 1e6;
2183
+ }
2184
+ };
2185
+
2186
+ // src/utils/domain/py_builtin.ts
2187
+ var EvaluationError = class extends Error {
2188
+ constructor(message) {
2189
+ super(message);
2190
+ this.name = "EvaluationError";
2191
+ }
2192
+ };
2193
+ function execOnIterable(iterable, func) {
2194
+ if (iterable === null) {
2195
+ throw new EvaluationError("value not iterable");
2196
+ }
2197
+ if (typeof iterable === "object" && !Array.isArray(iterable) && !(iterable instanceof Set)) {
2198
+ iterable = Object.keys(iterable);
2199
+ }
2200
+ if (typeof iterable?.[Symbol.iterator] !== "function") {
2201
+ throw new EvaluationError("value not iterable");
2202
+ }
2203
+ return func(iterable);
2204
+ }
2205
+ var BUILTINS = {
2206
+ /**
2207
+ * @param {any} value
2208
+ * @returns {boolean}
2209
+ */
2210
+ bool(value) {
2211
+ switch (typeof value) {
2212
+ case "number":
2213
+ return value !== 0;
2214
+ case "string":
2215
+ return value !== "";
2216
+ case "boolean":
2217
+ return value;
2218
+ case "object":
2219
+ if (value === null || value === void 0) {
2220
+ return false;
2221
+ }
2222
+ if ("isTrue" in value && typeof value.isTrue === "function") {
2223
+ return value.isTrue();
2224
+ }
2225
+ if (value instanceof Array) {
2226
+ return !!value.length;
2227
+ }
2228
+ if (value instanceof Set) {
2229
+ return !!value.size;
2230
+ }
2231
+ return Object.keys(value).length !== 0;
2232
+ default:
2233
+ return true;
2234
+ }
2235
+ },
2236
+ set(iterable) {
2237
+ if (arguments.length > 2) {
2238
+ throw new EvaluationError(
2239
+ `set expected at most 1 argument, got (${arguments.length - 1})`
2240
+ );
2241
+ }
2242
+ return execOnIterable(
2243
+ iterable,
2244
+ (iterable2) => new Set(iterable2)
2245
+ );
2246
+ },
2247
+ time: {
2248
+ strftime(format) {
2249
+ return PyDateTime.now().strftime(format);
2250
+ }
2251
+ },
2252
+ context_today() {
2253
+ return PyDate.today();
2254
+ },
2255
+ get current_date() {
2256
+ return this.today;
2257
+ },
2258
+ get today() {
2259
+ return PyDate.today().strftime("%Y-%m-%d");
2260
+ },
2261
+ get now() {
2262
+ return PyDateTime.now().strftime("%Y-%m-%d %H:%M:%S");
2263
+ },
2264
+ datetime: {
2265
+ time: PyTime,
2266
+ timedelta: PyTimeDelta,
2267
+ datetime: PyDateTime,
2268
+ date: PyDate
2269
+ },
2270
+ relativedelta: PyRelativeDelta,
2271
+ true: true,
2272
+ false: false
2273
+ };
2274
+
2275
+ // src/utils/domain/py_utils.ts
2276
+ function toPyValue(value) {
2277
+ switch (typeof value) {
2278
+ case "string":
2279
+ return { type: 1, value };
2280
+ case "number":
2281
+ return { type: 0, value };
2282
+ case "boolean":
2283
+ return { type: 2, value };
2284
+ case "object":
2285
+ if (Array.isArray(value)) {
2286
+ return { type: 4, value: value.map(toPyValue) };
2287
+ } else if (value === null) {
2288
+ return {
2289
+ type: 3
2290
+ /* None */
2291
+ };
2292
+ } else if (value instanceof Date) {
2293
+ return {
2294
+ type: 1,
2295
+ value: String(PyDateTime.convertDate(value))
2296
+ };
2297
+ } else if (value instanceof PyDate || value instanceof PyDateTime) {
2298
+ return { type: 1, value };
2299
+ } else {
2300
+ const content = {};
2301
+ for (const key in value) {
2302
+ content[key] = toPyValue(value[key]);
2303
+ }
2304
+ return { type: 11, value: content };
2305
+ }
2306
+ default:
2307
+ throw new Error("Invalid type");
2308
+ }
2309
+ }
2310
+ function formatAST(ast, lbp = 0) {
2311
+ switch (ast.type) {
2312
+ case 3:
2313
+ return "None";
2314
+ case 1:
2315
+ return JSON.stringify(ast.value);
2316
+ case 0:
2317
+ return String(ast.value);
2318
+ case 2:
2319
+ return ast.value ? "True" : "False";
2320
+ case 4:
2321
+ return `[${ast.value.map(formatAST).join(", ")}]`;
2322
+ case 6:
2323
+ if (ast.op === "not") {
2324
+ return `not ${formatAST(ast.right, 50)}`;
2325
+ }
2326
+ return `${ast.op}${formatAST(ast.right, 130)}`;
2327
+ case 7:
2328
+ const abp = bp(ast.op);
2329
+ const binaryStr = `${formatAST(ast.left, abp)} ${ast.op} ${formatAST(ast.right, abp)}`;
2330
+ return abp < lbp ? `(${binaryStr})` : binaryStr;
2331
+ case 11:
2332
+ const pairs = [];
2333
+ for (const k in ast.value) {
2334
+ pairs.push(`"${k}": ${formatAST(ast.value[k])}`);
2335
+ }
2336
+ return `{${pairs.join(", ")}}`;
2337
+ case 10:
2338
+ return `(${ast.value.map(formatAST).join(", ")})`;
2339
+ case 5:
2340
+ return ast.value;
2341
+ case 12:
2342
+ return `${formatAST(ast.target)}[${formatAST(ast.key)}]`;
2343
+ case 13:
2344
+ const { ifTrue, condition, ifFalse } = ast;
2345
+ return `${formatAST(ifTrue)} if ${formatAST(condition)} else ${formatAST(ifFalse)}`;
2346
+ case 14:
2347
+ const boolAbp = bp(ast.op);
2348
+ const boolStr = `${formatAST(ast.left, boolAbp)} ${ast.op} ${formatAST(ast.right, boolAbp)}`;
2349
+ return boolAbp < lbp ? `(${boolStr})` : boolStr;
2350
+ case 15:
2351
+ return `${formatAST(ast.obj, 150)}.${ast.key}`;
2352
+ case 8:
2353
+ const args = ast.args.map(formatAST);
2354
+ const kwargs = [];
2355
+ for (const kwarg in ast.kwargs) {
2356
+ kwargs.push(`${kwarg} = ${formatAST(ast.kwargs[kwarg])}`);
2357
+ }
2358
+ const argStr = args.concat(kwargs).join(", ");
2359
+ return `${formatAST(ast.fn)}(${argStr})`;
2360
+ default:
2361
+ throw new Error("invalid expression: " + JSON.stringify(ast));
2362
+ }
2363
+ }
2364
+ var PY_DICT = /* @__PURE__ */ Object.create(null);
2365
+ function toPyDict(obj) {
2366
+ return new Proxy(obj, {
2367
+ getPrototypeOf() {
2368
+ return PY_DICT;
2369
+ }
2370
+ });
2371
+ }
2372
+
2373
+ // src/utils/domain/py_interpreter.ts
2374
+ var isTrue = BUILTINS.bool;
2375
+ function applyUnaryOp(ast, context) {
2376
+ const value = evaluate(ast.right, context);
2377
+ switch (ast.op) {
2378
+ case "-":
2379
+ if (value instanceof Object && "negate" in value) {
2380
+ return value.negate();
2381
+ }
2382
+ return -value;
2383
+ case "+":
2384
+ return value;
2385
+ case "not":
2386
+ return !isTrue(value);
2387
+ default:
2388
+ throw new EvaluationError(`Unknown unary operator: ${ast.op}`);
2389
+ }
2390
+ }
2391
+ function pytypeIndex(val) {
2392
+ switch (typeof val) {
2393
+ case "object":
2394
+ return val === null ? 1 : Array.isArray(val) ? 5 : 3;
2395
+ case "number":
2396
+ return 2;
2397
+ case "string":
2398
+ return 4;
2399
+ default:
2400
+ throw new EvaluationError(`Unknown type: ${typeof val}`);
2401
+ }
2402
+ }
2403
+ function isLess(left, right) {
2404
+ if (typeof left === "number" && typeof right === "number") {
2405
+ return left < right;
2406
+ }
2407
+ if (typeof left === "boolean") {
2408
+ left = left ? 1 : 0;
2409
+ }
2410
+ if (typeof right === "boolean") {
2411
+ right = right ? 1 : 0;
2412
+ }
2413
+ const leftIndex = pytypeIndex(left);
2414
+ const rightIndex = pytypeIndex(right);
2415
+ if (leftIndex === rightIndex) {
2416
+ return left < right;
2417
+ }
2418
+ return leftIndex < rightIndex;
2419
+ }
2420
+ function isEqual(left, right) {
2421
+ if (typeof left !== typeof right) {
2422
+ if (typeof left === "boolean" && typeof right === "number") {
2423
+ return right === (left ? 1 : 0);
2424
+ }
2425
+ if (typeof left === "number" && typeof right === "boolean") {
2426
+ return left === (right ? 1 : 0);
2427
+ }
2428
+ return false;
2429
+ }
2430
+ if (left instanceof Object && "isEqual" in left) {
2431
+ return left.isEqual(right);
2432
+ }
2433
+ return left === right;
2434
+ }
2435
+ function isIn(left, right) {
2436
+ if (Array.isArray(right)) {
2437
+ return right.includes(left);
2438
+ }
2439
+ if (typeof right === "string" && typeof left === "string") {
2440
+ return right.includes(left);
2441
+ }
2442
+ if (typeof right === "object") {
2443
+ return left in right;
2444
+ }
2445
+ return false;
2446
+ }
2447
+ function applyBinaryOp(ast, context) {
2448
+ const left = evaluate(ast.left, context);
2449
+ const right = evaluate(ast.right, context);
2450
+ switch (ast.op) {
2451
+ case "+": {
2452
+ const relativeDeltaOnLeft = left instanceof PyRelativeDelta;
2453
+ const relativeDeltaOnRight = right instanceof PyRelativeDelta;
2454
+ if (relativeDeltaOnLeft || relativeDeltaOnRight) {
2455
+ const date = relativeDeltaOnLeft ? right : left;
2456
+ const delta = relativeDeltaOnLeft ? left : right;
2457
+ return PyRelativeDelta.add(date, delta);
2458
+ }
2459
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
2460
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2461
+ if (timeDeltaOnLeft && timeDeltaOnRight) {
2462
+ return left.add(right);
2463
+ }
2464
+ if (timeDeltaOnLeft) {
2465
+ if (right instanceof PyDate || right instanceof PyDateTime) {
2466
+ return right.add(left);
2467
+ } else {
2468
+ throw new NotSupportedError();
2469
+ }
2470
+ }
2471
+ if (timeDeltaOnRight) {
2472
+ if (left instanceof PyDate || left instanceof PyDateTime) {
2473
+ return left.add(right);
2474
+ } else {
2475
+ throw new NotSupportedError();
2476
+ }
2477
+ }
2478
+ if (left instanceof Array && right instanceof Array) {
2479
+ return [...left, ...right];
2480
+ }
2481
+ return left + right;
2482
+ }
2483
+ case "-": {
2484
+ const isRightDelta = right instanceof PyRelativeDelta;
2485
+ if (isRightDelta) {
2486
+ return PyRelativeDelta.substract(left, right);
2487
+ }
2488
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2489
+ if (timeDeltaOnRight) {
2490
+ if (left instanceof PyTimeDelta) {
2491
+ return left.substract(right);
2492
+ } else if (left instanceof PyDate || left instanceof PyDateTime) {
2493
+ return left.substract(right);
2494
+ } else {
2495
+ throw new NotSupportedError();
2496
+ }
2497
+ }
2498
+ if (left instanceof PyDate) {
2499
+ return left.substract(right);
2500
+ }
2501
+ return left - right;
2502
+ }
2503
+ case "*": {
2504
+ const timeDeltaOnLeft = left instanceof PyTimeDelta;
2505
+ const timeDeltaOnRight = right instanceof PyTimeDelta;
2506
+ if (timeDeltaOnLeft || timeDeltaOnRight) {
2507
+ const number = timeDeltaOnLeft ? right : left;
2508
+ const delta = timeDeltaOnLeft ? left : right;
2509
+ return delta.multiply(number);
2510
+ }
2511
+ return left * right;
2512
+ }
2513
+ case "/":
2514
+ return left / right;
2515
+ case "%":
2516
+ return left % right;
2517
+ case "//":
2518
+ if (left instanceof PyTimeDelta) {
2519
+ return left.divide(right);
2520
+ }
2521
+ return Math.floor(left / right);
2522
+ case "**":
2523
+ return left ** right;
2524
+ case "==":
2525
+ return isEqual(left, right);
2526
+ case "<>":
2527
+ case "!=":
2528
+ return !isEqual(left, right);
2529
+ case "<":
2530
+ return isLess(left, right);
2531
+ case ">":
2532
+ return isLess(right, left);
2533
+ case ">=":
2534
+ return isEqual(left, right) || isLess(right, left);
2535
+ case "<=":
2536
+ return isEqual(left, right) || isLess(left, right);
2537
+ case "in":
2538
+ return isIn(left, right);
2539
+ case "not in":
2540
+ return !isIn(left, right);
2541
+ default:
2542
+ throw new EvaluationError(`Unknown binary operator: ${ast.op}`);
2543
+ }
2544
+ }
2545
+ var DICT = {
2546
+ get(...args) {
2547
+ const { key, defValue } = parseArgs(args, ["key", "defValue"]);
2548
+ const self = this;
2549
+ if (key in self) {
2550
+ return self[key];
2551
+ } else if (defValue !== void 0) {
2552
+ return defValue;
2553
+ }
2554
+ return null;
2555
+ }
2556
+ };
2557
+ var STRING = {
2558
+ lower() {
2559
+ return this.toLowerCase();
2560
+ },
2561
+ upper() {
2562
+ return this.toUpperCase();
2563
+ }
2564
+ };
2565
+ function applyFunc(key, func, set, ...args) {
2566
+ if (args.length === 1) {
2567
+ return new Set(set);
2568
+ }
2569
+ if (args.length > 2) {
2570
+ throw new EvaluationError(
2571
+ `${key}: py_js supports at most 1 argument, got (${args.length - 1})`
2572
+ );
2573
+ }
2574
+ return execOnIterable(args[0], func);
2575
+ }
2576
+ var SET = {
2577
+ intersection(...args) {
2578
+ return applyFunc(
2579
+ "intersection",
2580
+ (iterable) => {
2581
+ const intersection = /* @__PURE__ */ new Set();
2582
+ for (const i of iterable) {
2583
+ if (this.has(i)) {
2584
+ intersection.add(i);
2585
+ }
2586
+ }
2587
+ return intersection;
2588
+ },
2589
+ this,
2590
+ ...args
2591
+ );
2592
+ },
2593
+ difference(...args) {
2594
+ return applyFunc(
2595
+ "difference",
2596
+ (iterable) => {
2597
+ iterable = new Set(iterable);
2598
+ const difference = /* @__PURE__ */ new Set();
2599
+ for (const e of this) {
2600
+ if (!iterable.has(e)) {
2601
+ difference.add(e);
2602
+ }
2603
+ }
2604
+ return difference;
2605
+ },
2606
+ this,
2607
+ ...args
2608
+ );
2609
+ },
2610
+ union(...args) {
2611
+ return applyFunc(
2612
+ "union",
2613
+ (iterable) => {
2614
+ return /* @__PURE__ */ new Set([...this, ...iterable]);
2615
+ },
2616
+ this,
2617
+ ...args
2618
+ );
2619
+ }
2620
+ };
2621
+ function methods(_class) {
2622
+ return Object.getOwnPropertyNames(_class.prototype).map(
2623
+ (prop) => _class.prototype[prop]
2624
+ );
2625
+ }
2626
+ var allowedFns = /* @__PURE__ */ new Set([
2627
+ BUILTINS.time.strftime,
2628
+ BUILTINS.set,
2629
+ BUILTINS.bool,
2630
+ BUILTINS.context_today,
2631
+ BUILTINS.datetime.datetime.now,
2632
+ BUILTINS.datetime.datetime.combine,
2633
+ BUILTINS.datetime.date.today,
2634
+ ...methods(BUILTINS.relativedelta),
2635
+ ...Object.values(BUILTINS.datetime).flatMap((obj) => methods(obj)),
2636
+ ...Object.values(SET),
2637
+ ...Object.values(DICT),
2638
+ ...Object.values(STRING)
2639
+ ]);
2640
+ var unboundFn = /* @__PURE__ */ Symbol("unbound function");
2641
+ function evaluate(ast, context = {}) {
2642
+ const dicts = /* @__PURE__ */ new Set();
2643
+ let pyContext;
2644
+ const evalContext = Object.create(context);
2645
+ if (!evalContext?.context) {
2646
+ Object.defineProperty(evalContext, "context", {
2647
+ get() {
2648
+ if (!pyContext) {
2649
+ pyContext = toPyDict(context);
2650
+ }
2651
+ return pyContext;
2652
+ }
2653
+ });
2654
+ }
2655
+ function _innerEvaluate(ast2) {
2656
+ switch (ast2?.type) {
2657
+ case 0:
2658
+ // Number
2659
+ case 1:
2660
+ return ast2.value;
2661
+ case 5:
2662
+ if (ast2.value in evalContext) {
2663
+ if (typeof evalContext[ast2.value] === "object" && evalContext[ast2.value]?.id && ast2?.value !== "parent") {
2664
+ return evalContext[ast2.value]?.id;
2665
+ }
2666
+ return evalContext[ast2.value] ?? false;
2667
+ } else if (ast2.value in BUILTINS) {
2668
+ return BUILTINS[ast2.value];
2669
+ } else {
2670
+ return false;
2671
+ }
2672
+ case 3:
2673
+ return null;
2674
+ case 2:
2675
+ return ast2.value;
2676
+ case 6:
2677
+ return applyUnaryOp(ast2, evalContext);
2678
+ case 7:
2679
+ return applyBinaryOp(ast2, evalContext);
2680
+ case 14:
2681
+ const left = _evaluate(ast2.left);
2682
+ if (ast2.op === "and") {
2683
+ return isTrue(left) ? _evaluate(ast2.right) : left;
2684
+ } else {
2685
+ return isTrue(left) ? left : _evaluate(ast2.right);
2686
+ }
2687
+ case 4:
2688
+ // List
2689
+ case 10:
2690
+ return ast2.value.map(_evaluate);
2691
+ case 11:
2692
+ const dict = {};
2693
+ for (const key2 in ast2.value) {
2694
+ dict[key2] = _evaluate(ast2.value[key2]);
2695
+ }
2696
+ dicts.add(dict);
2697
+ return dict;
2698
+ case 8:
2699
+ const fnValue = _evaluate(ast2.fn);
2700
+ const args = ast2.args.map(_evaluate);
2701
+ const kwargs = {};
2702
+ for (const kwarg in ast2.kwargs) {
2703
+ kwargs[kwarg] = _evaluate(ast2?.kwargs[kwarg]);
2704
+ }
2705
+ if (fnValue === PyDate || fnValue === PyDateTime || fnValue === PyTime || fnValue === PyRelativeDelta || fnValue === PyTimeDelta) {
2706
+ return fnValue.create(...args, kwargs);
2707
+ }
2708
+ return fnValue(...args, kwargs);
2709
+ case 12:
2710
+ const dictVal = _evaluate(ast2.target);
2711
+ const key = _evaluate(ast2.key);
2712
+ return dictVal[key];
2713
+ case 13:
2714
+ if (isTrue(_evaluate(ast2.condition))) {
2715
+ return _evaluate(ast2.ifTrue);
2716
+ } else {
2717
+ return _evaluate(ast2.ifFalse);
2718
+ }
2719
+ case 15:
2720
+ let leftVal = _evaluate(ast2.obj);
2721
+ let result;
2722
+ if (dicts.has(leftVal) || Object.isPrototypeOf.call(PY_DICT, leftVal)) {
2723
+ result = DICT[ast2.key];
2724
+ } else if (typeof leftVal === "string") {
2725
+ result = STRING[ast2.key];
2726
+ } else if (leftVal instanceof Set) {
2727
+ result = SET[ast2.key];
2728
+ } else if (ast2.key === "get" && typeof leftVal === "object") {
2729
+ result = DICT[ast2.key];
2730
+ leftVal = toPyDict(leftVal);
2731
+ } else if (typeof leftVal === "number") {
2732
+ result = leftVal;
2733
+ } else if (Array.isArray(leftVal[ast2.key])) {
2734
+ result = leftVal[ast2.key]?.map(
2735
+ (value) => value?.id ?? value
2736
+ );
2737
+ } else {
2738
+ result = leftVal[ast2.key]?.id ?? leftVal[ast2.key] ?? false;
2739
+ }
2740
+ if (typeof result === "function") {
2741
+ const bound = result.bind(leftVal);
2742
+ bound[unboundFn] = result;
2743
+ return bound;
2744
+ }
2745
+ return result;
2746
+ default:
2747
+ throw new EvaluationError(`AST of type ${ast2.type} cannot be evaluated`);
2748
+ }
2749
+ }
2750
+ function _evaluate(ast2) {
2751
+ const val = _innerEvaluate(ast2);
2752
+ if (typeof val === "function" && !allowedFns.has(val) && !allowedFns.has(val[unboundFn])) {
2753
+ throw new Error("Invalid Function Call");
2754
+ }
2755
+ return val;
2756
+ }
2757
+ return _evaluate(ast);
2758
+ }
2759
+
2760
+ // src/utils/domain/py.ts
2761
+ function parseExpr(expr) {
2762
+ const tokens = tokenize(expr);
2763
+ return parse(tokens);
2764
+ }
2765
+ function evaluateExpr(expr, context = {}) {
2766
+ let ast;
2767
+ try {
2768
+ ast = parseExpr(expr);
2769
+ } catch (error) {
2770
+ throw new EvalError(
2771
+ `Can not parse python expression: (${expr})
2772
+ Error: ${error.message}`
2773
+ );
2774
+ }
2775
+ try {
2776
+ return evaluate(ast, context);
2777
+ } catch (error) {
2778
+ throw new EvalError(
2779
+ `Can not evaluate python expression: (${expr})
2780
+ Error: ${error.message}`
2781
+ );
2782
+ }
2783
+ }
2784
+ function evaluateBooleanExpr(expr, context = {}) {
2785
+ if (!expr || expr === "False" || expr === "0") {
2786
+ return false;
2787
+ }
2788
+ if (expr === "True" || expr === "1") {
2789
+ return true;
2790
+ }
2791
+ return evaluateExpr(`bool(${expr})`, context);
2792
+ }
2793
+
2794
+ // src/utils/domain/context.ts
2795
+ function evalPartialContext(_context, evaluationContext = {}) {
2796
+ const ast = parseExpr(_context);
2797
+ const context = {};
2798
+ for (const key in ast.value) {
2799
+ const value = ast.value[key];
2800
+ try {
2801
+ context[key] = evaluate(value, evaluationContext);
2802
+ } catch {
2803
+ }
2804
+ }
2805
+ return context;
2806
+ }
2807
+
2808
+ // src/utils/domain/objects.ts
2809
+ function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
2810
+ if (!obj1 || !obj2 || typeof obj1 !== "object" || typeof obj2 !== "object") {
2811
+ return obj1 === obj2;
2812
+ }
2813
+ const obj1Keys = Object.keys(obj1);
2814
+ return obj1Keys.length === Object.keys(obj2).length && obj1Keys.every((key) => comparisonFn(obj1[key], obj2[key]));
2815
+ }
2816
+
2817
+ // src/utils/domain/arrays.ts
2818
+ var shallowEqual2 = shallowEqual;
2819
+
2820
+ // src/utils/domain/strings.ts
2821
+ function escapeRegExp(str) {
2822
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2823
+ }
2824
+
2825
+ // src/utils/domain/domain.ts
2826
+ var InvalidDomainError = class extends Error {
2827
+ };
2828
+ var Domain = class _Domain {
2829
+ ast = { type: -1, value: null };
2830
+ static TRUE;
2831
+ static FALSE;
2832
+ static combine(domains, operator) {
2833
+ if (domains.length === 0) {
2834
+ return new _Domain([]);
2835
+ }
2836
+ const domain1 = domains[0] instanceof _Domain ? domains[0] : new _Domain(domains[0]);
2837
+ if (domains.length === 1) {
2838
+ return domain1;
2839
+ }
2840
+ const domain2 = _Domain.combine(domains.slice(1), operator);
2841
+ const result = new _Domain([]);
2842
+ const astValues1 = domain1.ast.value;
2843
+ const astValues2 = domain2.ast.value;
2844
+ const op = operator === "AND" ? "&" : "|";
2845
+ const combinedAST = {
2846
+ type: 4,
2847
+ value: astValues1.concat(astValues2)
2848
+ };
2849
+ result.ast = normalizeDomainAST(combinedAST, op);
2850
+ return result;
2851
+ }
2852
+ static and(domains) {
2853
+ return _Domain.combine(domains, "AND");
2854
+ }
2855
+ static or(domains) {
2856
+ return _Domain.combine(domains, "OR");
2857
+ }
2858
+ static not(domain) {
2859
+ const result = new _Domain(domain);
2860
+ result.ast.value.unshift({ type: 1, value: "!" });
2861
+ return result;
2862
+ }
2863
+ static removeDomainLeaves(domain, keysToRemove) {
2864
+ function processLeaf(elements, idx, operatorCtx, newDomain2) {
2865
+ const leaf = elements[idx];
2866
+ if (leaf.type === 10) {
2867
+ if (keysToRemove.includes(leaf.value[0].value)) {
2868
+ if (operatorCtx === "&") {
2869
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2870
+ } else if (operatorCtx === "|") {
2871
+ newDomain2.ast.value.push(..._Domain.FALSE.ast.value);
2872
+ }
2873
+ } else {
2874
+ newDomain2.ast.value.push(leaf);
2875
+ }
2876
+ return 1;
2877
+ } else if (leaf.type === 1) {
2878
+ if (leaf.value === "|" && elements[idx + 1].type === 10 && elements[idx + 2].type === 10 && keysToRemove.includes(elements[idx + 1].value[0].value) && keysToRemove.includes(elements[idx + 2].value[0].value)) {
2879
+ newDomain2.ast.value.push(..._Domain.TRUE.ast.value);
2880
+ return 3;
2881
+ }
2882
+ newDomain2.ast.value.push(leaf);
2883
+ if (leaf.value === "!") {
2884
+ return 1 + processLeaf(elements, idx + 1, "&", newDomain2);
2885
+ }
2886
+ const firstLeafSkip = processLeaf(
2887
+ elements,
2888
+ idx + 1,
2889
+ leaf.value,
2890
+ newDomain2
2891
+ );
2892
+ const secondLeafSkip = processLeaf(
2893
+ elements,
2894
+ idx + 1 + firstLeafSkip,
2895
+ leaf.value,
2896
+ newDomain2
2897
+ );
2898
+ return 1 + firstLeafSkip + secondLeafSkip;
2899
+ }
2900
+ return 0;
2901
+ }
2902
+ const d = new _Domain(domain);
2903
+ if (d.ast.value.length === 0) {
2904
+ return d;
2905
+ }
2906
+ const newDomain = new _Domain([]);
2907
+ processLeaf(d.ast.value, 0, "&", newDomain);
2908
+ return newDomain;
2909
+ }
2910
+ constructor(descr = []) {
2911
+ if (descr instanceof _Domain) {
2912
+ return new _Domain(descr.toString());
2913
+ } else {
2914
+ let rawAST;
2915
+ try {
2916
+ rawAST = typeof descr === "string" ? parseExpr(descr) : toAST(descr);
2917
+ } catch (error) {
2918
+ throw new InvalidDomainError(
2919
+ `Invalid domain representation: ${descr}`,
2920
+ {
2921
+ cause: error
2922
+ }
2923
+ );
2924
+ }
2925
+ this.ast = normalizeDomainAST(rawAST);
2926
+ }
2927
+ }
2928
+ contains(record) {
2929
+ const expr = evaluate(this.ast, record);
2930
+ return matchDomain(record, expr);
2931
+ }
2932
+ toString() {
2933
+ return formatAST(this.ast);
2934
+ }
2935
+ toList(context) {
2936
+ return evaluate(this.ast, context);
2937
+ }
2938
+ toJson() {
2939
+ try {
2940
+ const evaluatedAsList = this.toList({});
2941
+ const evaluatedDomain = new _Domain(evaluatedAsList);
2942
+ if (evaluatedDomain.toString() === this.toString()) {
2943
+ return evaluatedAsList;
2944
+ }
2945
+ return this.toString();
2946
+ } catch {
2947
+ return this.toString();
2948
+ }
2949
+ }
2950
+ };
2951
+ var TRUE_LEAF = [1, "=", 1];
2952
+ var FALSE_LEAF = [0, "=", 1];
2953
+ var TRUE_DOMAIN = new Domain([TRUE_LEAF]);
2954
+ var FALSE_DOMAIN = new Domain([FALSE_LEAF]);
2955
+ Domain.TRUE = TRUE_DOMAIN;
2956
+ Domain.FALSE = FALSE_DOMAIN;
2957
+ function toAST(domain) {
2958
+ const elems = domain.map((elem) => {
2959
+ switch (elem) {
2960
+ case "!":
2961
+ case "&":
2962
+ case "|":
2963
+ return { type: 1, value: elem };
2964
+ default:
2965
+ return {
2966
+ type: 10,
2967
+ value: elem.map(toPyValue)
2968
+ };
2969
+ }
2970
+ });
2971
+ return { type: 4, value: elems };
2972
+ }
2973
+ function normalizeDomainAST(domain, op = "&") {
2974
+ if (domain.type !== 4) {
2975
+ if (domain.type === 10) {
2976
+ const value = domain.value;
2977
+ if (value.findIndex((e) => e.type === 10) === -1 || !value.every((e) => e.type === 10 || e.type === 1)) {
2978
+ throw new InvalidDomainError("Invalid domain AST");
2979
+ }
2980
+ } else {
2981
+ throw new InvalidDomainError("Invalid domain AST");
2982
+ }
2983
+ }
2984
+ if (domain.value.length === 0) {
2985
+ return domain;
2986
+ }
2987
+ let expected = 1;
2988
+ for (const child of domain.value) {
2989
+ switch (child.type) {
2990
+ case 1:
2991
+ if (child.value === "&" || child.value === "|") {
2992
+ expected++;
2993
+ } else if (child.value !== "!") {
2994
+ throw new InvalidDomainError("Invalid domain AST");
2995
+ }
2996
+ break;
2997
+ case 4:
2998
+ /* list */
2999
+ case 10:
3000
+ if (child.value.length === 3) {
3001
+ expected--;
3002
+ break;
3003
+ }
3004
+ throw new InvalidDomainError("Invalid domain AST");
3005
+ default:
3006
+ throw new InvalidDomainError("Invalid domain AST");
3007
+ }
3008
+ }
3009
+ const values = domain.value.slice();
3010
+ while (expected < 0) {
3011
+ expected++;
3012
+ values.unshift({ type: 1, value: op });
3013
+ }
3014
+ if (expected > 0) {
3015
+ throw new InvalidDomainError(
3016
+ `invalid domain ${formatAST(domain)} (missing ${expected} segment(s))`
3017
+ );
3018
+ }
3019
+ return { type: 4, value: values };
3020
+ }
3021
+ function matchCondition(record, condition) {
3022
+ if (typeof condition === "boolean") {
3023
+ return condition;
3024
+ }
3025
+ const [field, operator, value] = condition;
3026
+ if (typeof field === "string") {
3027
+ const names = field.split(".");
3028
+ if (names.length >= 2) {
3029
+ return matchCondition(record[names[0]], [
3030
+ names.slice(1).join("."),
3031
+ operator,
3032
+ value
3033
+ ]);
3034
+ }
3035
+ }
3036
+ let likeRegexp, ilikeRegexp;
3037
+ if (["like", "not like", "ilike", "not ilike"].includes(operator)) {
3038
+ likeRegexp = new RegExp(
3039
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
3040
+ "g"
3041
+ );
3042
+ ilikeRegexp = new RegExp(
3043
+ `(.*)${escapeRegExp(value).replaceAll("%", "(.*)")}(.*)`,
3044
+ "gi"
3045
+ );
3046
+ }
3047
+ const fieldValue = typeof field === "number" ? field : record[field];
3048
+ switch (operator) {
3049
+ case "=?":
3050
+ if ([false, null].includes(value)) {
3051
+ return true;
3052
+ }
3053
+ // eslint-disable-next-line no-fallthrough
3054
+ case "=":
3055
+ case "==":
3056
+ if (Array.isArray(fieldValue) && Array.isArray(value)) {
3057
+ return shallowEqual2(fieldValue, value);
3058
+ }
3059
+ return fieldValue === value;
3060
+ case "!=":
3061
+ case "<>":
3062
+ return !matchCondition(record, [field, "==", value]);
3063
+ case "<":
3064
+ return fieldValue < value;
3065
+ case "<=":
3066
+ return fieldValue <= value;
3067
+ case ">":
3068
+ return fieldValue > value;
3069
+ case ">=":
3070
+ return fieldValue >= value;
3071
+ case "in": {
3072
+ const val = Array.isArray(value) ? value : [value];
3073
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
3074
+ return fieldVal.some((fv) => val.includes(fv));
3075
+ }
3076
+ case "not in": {
3077
+ const val = Array.isArray(value) ? value : [value];
3078
+ const fieldVal = Array.isArray(fieldValue) ? fieldValue : [fieldValue];
3079
+ return !fieldVal.some((fv) => val.includes(fv));
3080
+ }
3081
+ case "like":
3082
+ if (fieldValue === false) {
3083
+ return false;
3084
+ }
3085
+ return Boolean(fieldValue.match(likeRegexp));
3086
+ case "not like":
3087
+ if (fieldValue === false) {
3088
+ return false;
3089
+ }
3090
+ return Boolean(!fieldValue.match(likeRegexp));
3091
+ case "=like":
3092
+ if (fieldValue === false) {
3093
+ return false;
3094
+ }
3095
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*")).test(
3096
+ fieldValue
3097
+ );
3098
+ case "ilike":
3099
+ if (fieldValue === false) {
3100
+ return false;
3101
+ }
3102
+ return Boolean(fieldValue.match(ilikeRegexp));
3103
+ case "not ilike":
3104
+ if (fieldValue === false) {
3105
+ return false;
3106
+ }
3107
+ return Boolean(!fieldValue.match(ilikeRegexp));
3108
+ case "=ilike":
3109
+ if (fieldValue === false) {
3110
+ return false;
3111
+ }
3112
+ return new RegExp(escapeRegExp(value).replace(/%/g, ".*"), "i").test(
3113
+ fieldValue
3114
+ );
3115
+ }
3116
+ throw new InvalidDomainError("could not match domain");
3117
+ }
3118
+ function makeOperators(record) {
3119
+ const match = matchCondition.bind(null, record);
3120
+ return {
3121
+ "!": (x) => !match(x),
3122
+ "&": (a, b) => match(a) && match(b),
3123
+ "|": (a, b) => match(a) || match(b)
3124
+ };
3125
+ }
3126
+ function matchDomain(record, domain) {
3127
+ if (domain.length === 0) {
3128
+ return true;
3129
+ }
3130
+ const operators = makeOperators(record);
3131
+ const reversedDomain = Array.from(domain).reverse();
3132
+ const condStack = [];
3133
+ for (const item of reversedDomain) {
3134
+ const operator = typeof item === "string" && operators[item];
3135
+ if (operator) {
3136
+ const operands = condStack.splice(-operator.length);
3137
+ condStack.push(operator(...operands));
3138
+ } else {
3139
+ condStack.push(item);
3140
+ }
3141
+ }
3142
+ return matchCondition(record, condStack.pop());
3143
+ }
3144
+ var checkDomain = (context, domain) => {
3145
+ try {
3146
+ if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
3147
+ return false;
3148
+ } else if (domain === "1" || domain === "True" || domain === true) {
3149
+ return true;
3150
+ }
3151
+ try {
3152
+ if (context && domain) {
3153
+ const d = new Domain(domain);
3154
+ return d.contains(context);
3155
+ }
3156
+ } catch (error) {
3157
+ if (context && domain) {
3158
+ const domainEval = evaluateBooleanExpr(domain, context);
3159
+ return domainEval;
3160
+ }
3161
+ return false;
3162
+ }
3163
+ return false;
3164
+ } catch (e) {
3165
+ return false;
3166
+ }
3167
+ };
3168
+ var matchDomains = (context, domains) => {
3169
+ if (Array.isArray(domains)) {
3170
+ if (domains?.length > 0) {
3171
+ return domains && domains.some((domain) => checkDomain(context, domain));
3172
+ }
3173
+ } else return checkDomain(context, domains);
3174
+ return false;
3175
+ };
3176
+
3177
+ // src/utils/function.ts
3178
+ var evalJSONContext = (_context, context = {}) => {
3179
+ try {
3180
+ return evalPartialContext(_context, context);
3181
+ } catch (err) {
3182
+ return null;
3183
+ }
3184
+ };
3185
+ var evalJSONDomain = (domain, context) => {
3186
+ try {
3187
+ if (context) {
3188
+ Object.keys(context)?.forEach((key) => {
3189
+ if (Array.isArray(context[key])) {
3190
+ const isTypeObject = context[key]?.every(
3191
+ (item) => typeof item === "object" && item !== null && item?.id !== void 0
3192
+ );
3193
+ if (isTypeObject) {
3194
+ context[key] = context[key]?.map((item) => item?.id);
3195
+ }
3196
+ }
3197
+ });
3198
+ }
3199
+ const value = evaluateExpr(domain, context);
3200
+ return value;
3201
+ } catch (err) {
3202
+ try {
3203
+ const domainObject = new Domain(domain).toList(context);
3204
+ return domainObject;
3205
+ } catch (err2) {
3206
+ return [];
3207
+ }
3208
+ }
3209
+ };
3210
+ var formatSortingString = (input) => {
3211
+ if (!input) return null;
3212
+ return input.split(",").map((field) => {
3213
+ const [key, order] = field.trim().split(/\s+/);
3214
+ const sortOrder = order?.toUpperCase() === "DESC" ? "DESC" : "ASC";
3215
+ return `${key} ${sortOrder}`;
3216
+ }).join(", ");
3217
+ };
3218
+ var domainHelper = {
3219
+ checkDomain,
3220
+ matchDomains,
3221
+ Domain
3222
+ };
3223
+ var toQueryString = (params) => {
3224
+ return Object.keys(params).map(
3225
+ (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
3226
+ ).join("&");
3227
+ };
3228
+ var stringToColor = (name, id) => {
3229
+ const combined = name + id / 2;
3230
+ let hash = 0;
3231
+ for (let i = 0; i < combined.length; i++) {
3232
+ hash = combined.charCodeAt(i) + ((hash << 5) - hash);
3233
+ }
3234
+ const r = hash >> 16 & 255;
3235
+ const g = hash >> 8 & 255;
3236
+ const b = hash & 255;
3237
+ const adjustedR = 120 + r % 61;
3238
+ const adjustedG = 120 + g % 61;
3239
+ const adjustedB = 120 + b % 61;
3240
+ return `#${adjustedR.toString(16).padStart(2, "0")}${adjustedG.toString(16).padStart(2, "0")}${adjustedB.toString(16).padStart(2, "0")}`;
3241
+ };
3242
+ var getFieldsOnChange = (fields) => {
3243
+ const result = [];
3244
+ function traverse(items) {
3245
+ for (const item of items) {
3246
+ if (item) {
3247
+ if (item?.type_co === "field" && matchDomains(fields, item?.on_change)) {
3248
+ result.push(item.name);
3249
+ }
3250
+ if (item?.fields && Array.isArray(item?.fields)) {
3251
+ traverse(item?.fields);
3252
+ }
3253
+ }
3254
+ }
3255
+ }
3256
+ traverse(fields);
3257
+ return result;
3258
+ };
3259
+ var formatUrlPath = ({
3260
+ viewType,
3261
+ aid,
3262
+ model,
3263
+ id,
3264
+ actionPath
3265
+ }) => {
3266
+ let _url = `/${viewType}/${actionPath}?aid=${aid}&model=${model}`;
3267
+ if (id) {
3268
+ _url += `&id=${id}`;
3269
+ }
3270
+ return _url;
3271
+ };
3272
+ var removeUndefinedFields = (obj) => {
3273
+ const newObj = {};
3274
+ for (const key in obj) {
3275
+ if (obj[key] !== void 0) {
3276
+ newObj[key] = obj[key];
3277
+ }
3278
+ }
3279
+ return newObj;
3280
+ };
3281
+ var useTabModel = (viewData, onchangeData) => {
3282
+ const tabsData = viewData?.views?.form?.tabs?.filter((val) => {
3283
+ if (!val) return null;
3284
+ const hide = checkDomain(onchangeData, val.invisible);
3285
+ if (!hide) {
3286
+ return val;
3287
+ }
3288
+ return false;
3289
+ }) || [];
3290
+ return tabsData;
3291
+ };
3292
+ var isBase64File = (str) => {
3293
+ try {
3294
+ const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
3295
+ if (dataUriPattern.test(str)) {
3296
+ return true;
3297
+ }
3298
+ const base64Pattern = (
3299
+ // eslint-disable-next-line no-useless-escape
3300
+ /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{2}==)?$/
3301
+ );
3302
+ return base64Pattern.test(str);
3303
+ } catch (e) {
3304
+ return false;
3305
+ }
3306
+ };
3307
+ var isBase64Image = (str) => {
3308
+ const base64Regex = /^data:image\/(png|jpeg|jpg|gif|webp);base64,/;
3309
+ if (!base64Regex.test(str)) {
3310
+ return false;
3311
+ }
3312
+ try {
3313
+ const base64Data = str.split(",")[1];
3314
+ return !!base64Data && atob(base64Data).length > 0;
3315
+ } catch (error) {
3316
+ return false;
3317
+ }
3318
+ };
3319
+ var checkIsImageLink = (url) => {
3320
+ const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
3321
+ return imageExtensions.test(url) || isBase64Image(url);
3322
+ };
3323
+ var formatFileSize = (size) => {
3324
+ if (size < 1024) return `${size} B`;
3325
+ const i = Math.floor(Math.log(size) / Math.log(1024));
3326
+ const sizes = ["B", "KB", "MB", "GB", "TB"];
3327
+ return `${(size / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
3328
+ };
3329
+ var getSubdomain = (url = window.location.href) => {
3330
+ const parts = url?.split(".");
3331
+ if (parts.length > 2) {
3332
+ return parts[0].replace("https://", "").replace("http://", "");
3333
+ }
3334
+ return null;
3335
+ };
3336
+
3337
+ // src/services/action-service/index.ts
3338
+ var ActionService = {
3339
+ async loadAction({
3340
+ idAction,
3341
+ context
3342
+ }) {
3343
+ const env2 = getEnv();
3344
+ const jsonData = {
3345
+ action_id: idAction,
3346
+ with_context: {
3347
+ ...context
3348
+ }
3349
+ };
3350
+ return env2.requests.post(`${"/load_action" /* LOAD_ACTION */}`, jsonData, {
3351
+ headers: {
3352
+ "Content-Type": "application/json"
3353
+ }
3354
+ });
3355
+ },
3356
+ async callButton({
3357
+ model,
3358
+ ids = [],
3359
+ context,
3360
+ method
3361
+ }) {
3362
+ try {
3363
+ const env2 = getEnv();
3364
+ const jsonData = {
3365
+ model,
3366
+ method,
3367
+ ids,
3368
+ with_context: context
3369
+ };
3370
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3371
+ headers: {
3372
+ "Content-Type": "application/json"
3373
+ }
3374
+ });
3375
+ } catch (error) {
3376
+ console.error("Error when calling button action:", error);
3377
+ throw error;
3378
+ }
3379
+ },
3380
+ async removeRows({
3381
+ model,
3382
+ ids,
3383
+ context
3384
+ }) {
3385
+ const env2 = getEnv();
3386
+ const jsonData = {
3387
+ model,
3388
+ method: "unlink",
3389
+ ids,
3390
+ with_context: context
3391
+ };
3392
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3393
+ headers: {
3394
+ "Content-Type": "application/json"
3395
+ }
3396
+ });
3397
+ },
3398
+ async duplicateRecord({
3399
+ model,
3400
+ id,
3401
+ context
3402
+ }) {
3403
+ const env2 = getEnv();
3404
+ const jsonData = {
3405
+ model,
3406
+ method: "copy",
3407
+ ids: id,
3408
+ with_context: context
3409
+ };
3410
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3411
+ headers: {
3412
+ "Content-Type": "application/json"
3413
+ }
3414
+ });
3415
+ },
3416
+ async print({ id, report, db }) {
3417
+ const env2 = getEnv();
3418
+ const jsonData = {
3419
+ report,
3420
+ id,
3421
+ type: "pdf",
3422
+ file_response: true,
3423
+ db
3424
+ };
3425
+ const queryString = toQueryString(jsonData);
3426
+ const urlWithParams = `${"/report" /* REPORT_PATH */}?${queryString}`;
3427
+ return env2.requests.get(urlWithParams, {
3428
+ headers: {
3429
+ "Content-Type": "application/json"
3430
+ },
3431
+ responseType: "arraybuffer"
3432
+ });
3433
+ },
3434
+ async runAction({
3435
+ idAction,
3436
+ context
3437
+ }) {
3438
+ const env2 = getEnv();
3439
+ const jsonData = {
3440
+ action_id: idAction,
3441
+ with_context: {
3442
+ ...context
3443
+ }
3444
+ };
3445
+ return env2.requests.post(`${"/run_action" /* RUN_ACTION_PATH */}`, jsonData, {
3446
+ headers: {
3447
+ "Content-Type": "application/json"
3448
+ }
3449
+ });
3450
+ }
3451
+ };
3452
+ var action_service_default = ActionService;
3453
+
3454
+ // src/services/auth-service/index.ts
3455
+ var AuthService = {
3456
+ async login(body) {
3457
+ const env2 = getEnv();
3458
+ const payload = Object.fromEntries(
3459
+ Object.entries({
3460
+ username: body.email,
3461
+ password: body.password,
3462
+ grant_type: env2?.config?.grantType || "",
3463
+ client_id: env2?.config?.clientId || "",
3464
+ client_secret: env2?.config?.clientSecret || ""
3465
+ }).filter(([_, value]) => !!value)
3466
+ );
3467
+ const encodedData = new URLSearchParams(payload).toString();
3468
+ return env2?.requests?.post(body.path, encodedData, {
3469
+ headers: {
3470
+ "Content-Type": "application/x-www-form-urlencoded"
3471
+ }
3472
+ });
3473
+ },
3474
+ async forgotPassword(email) {
3475
+ const env2 = getEnv();
3476
+ const bodyData = {
3477
+ login: email,
3478
+ url: `${window.location.origin}/reset-password`
3479
+ };
3480
+ return env2?.requests?.post("/reset_password" /* RESET_PASSWORD_PATH */, bodyData, {
3481
+ headers: {
3482
+ "Content-Type": "application/json"
3483
+ }
3484
+ });
3485
+ },
3486
+ async resetPassword(data, token) {
3487
+ const env2 = getEnv();
3488
+ const bodyData = {
3489
+ token,
3490
+ password: data.password,
3491
+ new_password: data.confirmPassword
3492
+ };
3493
+ return env2?.requests?.post("/change_password" /* CHANGE_PASSWORD_PATH */, bodyData, {
3494
+ headers: {
3495
+ "Content-Type": "application/json"
3496
+ }
3497
+ });
3498
+ },
3499
+ async updatePassword(data, token) {
3500
+ const env2 = getEnv();
3501
+ const bodyData = {
3502
+ token,
3503
+ old_password: data.oldPassword,
3504
+ new_password: data.newPassword
3505
+ };
3506
+ return env2?.requests?.post("/change_password_parent" /* UPDATE_PASSWORD_PATH */, bodyData, {
3507
+ headers: {
3508
+ "Content-Type": "application/json"
3509
+ }
3510
+ });
3511
+ },
3512
+ async isValidToken(token) {
3513
+ const env2 = getEnv();
3514
+ const bodyData = {
3515
+ token
3516
+ };
3517
+ return env2?.requests?.post("/check_token" /* TOKEN */, bodyData, {
3518
+ headers: {
3519
+ "Content-Type": "application/json"
3520
+ }
3521
+ });
3522
+ },
3523
+ async loginSocial({
3524
+ state,
3525
+ access_token
3526
+ }) {
3527
+ const env2 = getEnv();
3528
+ return env2?.requests?.post(
3529
+ "/token/generate" /* GENTOKEN_SOCIAL */,
3530
+ { state, access_token },
3531
+ {
3532
+ headers: {
3533
+ "Content-Type": "application/json"
3534
+ }
3535
+ }
3536
+ );
3537
+ },
3538
+ async getProviders(db) {
3539
+ const env2 = getEnv();
3540
+ return env2?.requests?.get("/oauth/providers", { params: { db } });
3541
+ }
3542
+ };
3543
+ var auth_service_default = AuthService;
3544
+
3545
+ // src/services/company-service/index.ts
3546
+ var CompanyService = {
3547
+ async getCurrentCompany() {
3548
+ const env2 = getEnv();
3549
+ return await env2.requests.get("/company" /* COMPANY_PATH */, {
3550
+ headers: {
3551
+ "Content-Type": "application/json"
3552
+ }
3553
+ });
3554
+ },
3555
+ async getInfoCompany(id) {
3556
+ const env2 = getEnv();
3557
+ const jsonData = {
3558
+ ids: [id],
3559
+ model: "res.company" /* COMPANY */,
3560
+ method: "web_read" /* WEB_READ */,
3561
+ kwargs: {
3562
+ specification: {
3563
+ primary_color: {},
3564
+ secondary_color: {},
3565
+ logo: {},
3566
+ display_name: {},
3567
+ secondary_logo: {}
3568
+ }
3569
+ }
3570
+ };
3571
+ return await env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3572
+ headers: {
3573
+ "Content-Type": "application/json"
3574
+ }
3575
+ });
3576
+ }
3577
+ };
3578
+ var company_service_default = CompanyService;
3579
+
3580
+ // src/services/excel-service/index.ts
3581
+ var ExcelService = {
3582
+ async uploadFile({ formData }) {
3583
+ const env2 = getEnv();
3584
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3585
+ headers: {
3586
+ "Content-Type": "multipart/form-data"
3587
+ }
3588
+ });
3589
+ },
3590
+ async uploadIdFile({ formData }) {
3591
+ const env2 = getEnv();
3592
+ return env2.requests.post(`${"/upload/file" /* UPLOAD_FILE_PATH */}`, formData, {
3593
+ headers: {
3594
+ "Content-Type": "multipart/form-data"
3595
+ }
3596
+ });
3597
+ },
3598
+ async parsePreview({
3599
+ id,
3600
+ selectedSheet,
3601
+ isHeader,
3602
+ context
3603
+ }) {
3604
+ const env2 = getEnv();
3605
+ const jsonData = {
3606
+ model: "base_import.import" /* BASE_IMPORT */,
3607
+ method: "parse_preview",
3608
+ ids: [id],
3609
+ kwargs: {
3610
+ options: {
3611
+ import_skip_records: [],
3612
+ import_set_empty_fields: [],
3613
+ fallback_values: {},
3614
+ name_create_enabled_fields: {},
3615
+ encoding: "",
3616
+ separator: "",
3617
+ quoting: '"',
3618
+ date_format: "",
3619
+ datetime_format: "",
3620
+ float_thousand_separator: ",",
3621
+ float_decimal_separator: ".",
3622
+ advanced: true,
3623
+ has_headers: isHeader,
3624
+ keep_matches: false,
3625
+ limit: 2e3,
3626
+ sheets: [],
3627
+ sheet: selectedSheet,
3628
+ skip: 0,
3629
+ tracking_disable: true
3630
+ }
3631
+ },
3632
+ with_context: context
3633
+ };
3634
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3635
+ headers: {
3636
+ "Content-Type": "multipart/form-data"
3637
+ }
3638
+ });
3639
+ },
3640
+ async executeImport({
3641
+ columns,
3642
+ fields,
3643
+ idFile,
3644
+ options,
3645
+ dryrun,
3646
+ context
3647
+ }) {
3648
+ const env2 = getEnv();
3649
+ const jsonData = {
3650
+ model: "base_import.import" /* BASE_IMPORT */,
3651
+ method: "execute_import",
3652
+ ids: [idFile],
3653
+ kwargs: {
3654
+ fields,
3655
+ columns,
3656
+ options,
3657
+ dryrun
3658
+ },
3659
+ with_context: context
3660
+ };
3661
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3662
+ headers: {
3663
+ "Content-Type": "multipart/form-data"
3664
+ }
3665
+ });
3666
+ },
3667
+ async getFileExcel({ model, context }) {
3668
+ const env2 = getEnv();
3669
+ const jsonData = {
3670
+ model,
3671
+ method: "get_import_templates" /* GET_IMPORT */,
3672
+ args: [],
3673
+ with_context: context
3674
+ };
3675
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData);
3676
+ },
3677
+ async getFieldExport({
3678
+ ids,
3679
+ model,
3680
+ isShow,
3681
+ parentField,
3682
+ fieldType,
3683
+ parentName,
3684
+ prefix,
3685
+ name,
3686
+ context,
3687
+ importCompat
3688
+ }) {
3689
+ const env2 = getEnv();
3690
+ const jsonData = {
3691
+ model,
3692
+ import_compat: importCompat,
3693
+ domain: [["id", "in", ids]],
3694
+ with_context: context
3695
+ };
3696
+ if (isShow) {
3697
+ jsonData.parent_field = parentField;
3698
+ jsonData.parent_field_type = fieldType;
3699
+ jsonData.parent_name = parentName;
3700
+ jsonData.name = name;
3701
+ jsonData.prefix = prefix;
3702
+ jsonData.exclude = [null];
3703
+ }
3704
+ return env2.requests.post("/export/get_fields", jsonData);
3705
+ },
3706
+ async exportExcel({
3707
+ model,
3708
+ domain,
3709
+ ids,
3710
+ fields,
3711
+ type,
3712
+ importCompat,
3713
+ context,
3714
+ groupby
3715
+ }) {
3716
+ const env2 = getEnv();
3717
+ const jsonData = {
3718
+ model,
3719
+ domain,
3720
+ ids,
3721
+ import_compat: importCompat,
3722
+ fields,
3723
+ with_context: context,
3724
+ groupby: groupby ?? []
3725
+ };
3726
+ return env2.requests.post_excel(`/export/${type}`, jsonData);
3727
+ }
3728
+ };
3729
+ var excel_service_default = ExcelService;
3730
+
3731
+ // src/services/form-service/index.ts
3732
+ var FormService = {
3733
+ async getComment({ data }) {
3734
+ try {
3735
+ const env2 = getEnv();
3736
+ const jsonData = {
3737
+ thread_id: data.thread_id,
3738
+ thread_model: data.thread_model,
3739
+ limit: 100,
3740
+ with_context: {
3741
+ lang: data.lang
3742
+ }
3743
+ };
3744
+ return env2.requests.post("/chatter/thread/messages" /* GET_MESSAGE */, jsonData, {
3745
+ headers: {
3746
+ "Content-Type": "application/json"
3747
+ }
3748
+ });
3749
+ } catch (error) {
3750
+ console.error("Error when sending message:", error);
3751
+ throw error;
3752
+ }
3753
+ },
3754
+ async sentComment({ data }) {
3755
+ try {
3756
+ const env2 = getEnv();
3757
+ const jsonData = {
3758
+ context: {
3759
+ tz: "Asia/Saigon",
3760
+ uid: 2,
3761
+ allowed_company_ids: [1],
3762
+ mail_post_autofollow: false,
3763
+ temporary_id: 142183.01
3764
+ },
3765
+ post_data: {
3766
+ body: data.message,
3767
+ message_type: "comment",
3768
+ attachment_ids: data.attachment_ids,
3769
+ attachment_tokens: [],
3770
+ subtype_xmlid: data.subtype
3771
+ },
3772
+ thread_id: Number(data.thread_id),
3773
+ thread_model: data.thread_model
3774
+ };
3775
+ return env2.requests.post("/chatter/message/post" /* SENT_MESSAGE */, jsonData, {
3776
+ headers: {
3777
+ "Content-Type": "application/json"
3778
+ }
3779
+ });
3780
+ } catch (error) {
3781
+ console.error("Error when sent message:", error);
3782
+ throw error;
3783
+ }
3784
+ },
3785
+ async deleteComment({ data }) {
3786
+ try {
3787
+ const env2 = getEnv();
3788
+ const jsonData = {
3789
+ attachment_ids: [],
3790
+ attachment_tokens: [],
3791
+ body: "",
3792
+ message_id: data.message_id
3793
+ };
3794
+ return env2.requests.post("/chatter/message/update_content" /* DELETE_MESSAGE */, jsonData, {
3795
+ headers: {
3796
+ "Content-Type": "application/json"
3797
+ }
3798
+ });
3799
+ } catch (error) {
3800
+ console.error("Error when sent message:", error);
3801
+ throw error;
3802
+ }
3803
+ },
3804
+ async getImage({ data }) {
3805
+ try {
3806
+ const env2 = getEnv();
3807
+ return env2.requests.get(
3808
+ `${"/web/image" /* IMAGE_PATH */}?filename=${data.filename}&unique=${data.checksum}&width=1920&height=300`,
3809
+ {
3810
+ headers: {
3811
+ "Content-Type": "application/json"
3812
+ }
3813
+ }
3814
+ );
3815
+ } catch (error) {
3816
+ console.error("Error when sent message:", error);
3817
+ throw error;
3818
+ }
3819
+ },
3820
+ async uploadImage({ data }) {
3821
+ try {
3822
+ const env2 = getEnv();
3823
+ return env2.requests.post("/mail/attachment/upload" /* UPLOAD_IMAGE */, data, {
3824
+ headers: {
3825
+ "Content-Type": "multipart/form-data"
3826
+ }
3827
+ });
3828
+ } catch (error) {
3829
+ console.error("Error when sent message:", error);
3830
+ throw error;
3831
+ }
3832
+ },
3833
+ async getFormView({ data }) {
3834
+ try {
3835
+ const env2 = getEnv();
3836
+ const jsonData = {
3837
+ model: data.model,
3838
+ method: "get_formview_action",
3839
+ ids: data.id ? [data.id] : [],
3840
+ with_context: data.context
3841
+ };
3842
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3843
+ headers: {
3844
+ "Content-Type": "application/json"
3845
+ }
3846
+ });
3847
+ } catch (error) {
3848
+ console.error("Error when fetching form view:", error);
3849
+ throw error;
3850
+ }
3851
+ },
3852
+ async changeStatus({ data }) {
3853
+ const env2 = getEnv();
3854
+ const vals = {
3855
+ [data.name]: data.stage_id
3856
+ };
3857
+ const jsonData = {
3858
+ model: data.model,
3859
+ method: "web_save",
3860
+ with_context: {
3861
+ lang: data.lang,
3862
+ allowed_company_ids: [1],
3863
+ uid: 2,
3864
+ search_default_my_ticket: true,
3865
+ search_default_is_open: true
3866
+ },
3867
+ ids: [data.id],
3868
+ kwargs: {
3869
+ vals,
3870
+ specification: {}
3871
+ }
3872
+ };
3873
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
3874
+ headers: {
3875
+ "Content-Type": "application/json"
3876
+ }
3877
+ });
3878
+ }
3879
+ };
3880
+ var form_service_default = FormService;
3881
+
3882
+ // src/services/model-service/index.ts
3883
+ var OBJECT_POSITION = 2;
3884
+ var ModelService = {
3885
+ async getAll({ data }) {
3886
+ const env2 = getEnv();
3887
+ const jsonReadGroup = data.type == "calendar" ? { fields: data?.fields } : data.fields && data.fields.length > 0 && data.groupby && data.groupby.length > 0 && data.groupby[0] ? {
3888
+ fields: data.fields,
3889
+ groupby: data.groupby
3890
+ } : {
3891
+ count_limit: 10001,
3892
+ order: data.sort,
3893
+ specification: data.specification
3894
+ };
3895
+ const jsonData = {
3896
+ model: String(data.model),
3897
+ method: data.type == "calendar" ? "search_read" : jsonReadGroup.fields && jsonReadGroup.groupby ? "web_read_group" : "web_search_read",
3898
+ ids: data.ids,
3899
+ with_context: data.context,
3900
+ kwargs: {
3901
+ domain: data.domain,
3902
+ limit: data.limit,
3903
+ offset: data.offset,
3904
+ ...jsonReadGroup
3905
+ }
3906
+ };
3907
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
3908
+ headers: {
3909
+ "Content-Type": "application/json"
3910
+ }
3911
+ });
3912
+ },
3913
+ async getList({
3914
+ model,
3915
+ ids = [],
3916
+ specification = {},
3917
+ domain = [],
3918
+ offset,
3919
+ order,
3920
+ context = {},
3921
+ limit = 10
3922
+ }) {
3923
+ const env2 = getEnv();
3924
+ const jsonData = {
3925
+ model,
3926
+ method: "web_search_read" /* WEB_SEARCH_READ */,
3927
+ ids,
3928
+ with_context: context,
3929
+ kwargs: {
3930
+ specification,
3931
+ domain,
3932
+ limit,
3933
+ offset,
3934
+ order
3935
+ }
3936
+ };
3937
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3938
+ headers: {
3939
+ "Content-Type": "application/json"
3940
+ }
3941
+ });
3942
+ },
3943
+ async getDetail({
3944
+ ids = [],
3945
+ model,
3946
+ specification,
3947
+ context
3948
+ }) {
3949
+ const env2 = getEnv();
3950
+ const jsonData = {
3951
+ model,
3952
+ method: "web_read" /* WEB_READ */,
3953
+ ids,
3954
+ with_context: context,
3955
+ kwargs: {
3956
+ specification
3957
+ }
3958
+ };
3959
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3960
+ headers: {
3961
+ "Content-Type": "application/json"
3962
+ }
3963
+ });
3964
+ },
3965
+ async save({
3966
+ model,
3967
+ ids = [],
3968
+ data = {},
3969
+ specification = {},
3970
+ context = {}
3971
+ }) {
3972
+ const env2 = getEnv();
3973
+ const jsonData = {
3974
+ model,
3975
+ method: "web_save" /* WEB_SAVE */,
3976
+ with_context: context,
3977
+ ids,
3978
+ kwargs: {
3979
+ vals: data,
3980
+ specification
3981
+ }
3982
+ };
3983
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3984
+ headers: {
3985
+ "Content-Type": "application/json"
3986
+ }
3987
+ });
3988
+ },
3989
+ async delete({ ids = [], model }) {
3990
+ const env2 = getEnv();
3991
+ const jsonData = {
3992
+ model,
3993
+ method: "unlink" /* UNLINK */,
3994
+ ids
3995
+ };
3996
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
3997
+ headers: {
3998
+ "Content-Type": "application/json"
3999
+ }
4000
+ });
4001
+ },
4002
+ async onChange({
4003
+ ids = [],
4004
+ model,
4005
+ object,
4006
+ specification,
4007
+ context,
4008
+ fieldChange
4009
+ }) {
4010
+ const env2 = getEnv();
4011
+ const jsonData = {
4012
+ model,
4013
+ method: "onchange" /* ONCHANGE */,
4014
+ ids,
4015
+ with_context: context,
4016
+ args: [
4017
+ object ? object : {},
4018
+ fieldChange ? fieldChange : [],
4019
+ specification
4020
+ ]
4021
+ };
4022
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4023
+ headers: {
4024
+ "Content-Type": "application/json"
4025
+ }
4026
+ });
4027
+ },
4028
+ async getListFieldsOnchange({ model }) {
4029
+ const env2 = getEnv();
4030
+ const jsonData = {
4031
+ model,
4032
+ method: "get_fields_onchange" /* GET_ONCHANGE_FIELDS */
4033
+ };
4034
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4035
+ headers: {
4036
+ "Content-Type": "application/json"
4037
+ }
4038
+ });
4039
+ },
4040
+ parseORMOdoo(data) {
4041
+ for (const key in data) {
4042
+ if (key === "display_name") {
4043
+ delete data[key];
4044
+ }
4045
+ if (!data[key] && data[key] !== 0) {
4046
+ data[key] = false;
4047
+ } else if (data[key] === "Draft") {
4048
+ data[key] = "/";
4049
+ }
4050
+ }
4051
+ return { ...data };
4052
+ },
4053
+ toDataJS(data, viewData, model) {
4054
+ for (const key in data) {
4055
+ if (data[key] === false) {
4056
+ if (viewData && model) {
4057
+ if (viewData?.models?.[model]?.[key]?.type !== "boolean" /* BOOLEAN */) {
4058
+ data[key] = null;
4059
+ }
4060
+ } else {
4061
+ data[key] = null;
4062
+ }
4063
+ } else if (data[key] === "/") {
4064
+ data[key] = "Draft";
4065
+ } else if (data[key] !== false) {
4066
+ if (model !== void 0) {
4067
+ if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */ || viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
4068
+ data[key] = (data[key] ??= [])?.map((item, index) => {
4069
+ const relation = viewData?.models?.[model]?.[key]?.relation;
4070
+ if (relation !== void 0) {
4071
+ if (viewData?.models?.[relation]) {
4072
+ if (item?.length >= 3) {
4073
+ if (item[0] === 2 /* DELETE */) {
4074
+ delete data[key][index];
4075
+ return;
4076
+ }
4077
+ return ModelService.toDataJS(
4078
+ { ...item[OBJECT_POSITION], id: `virtual_${index}` },
4079
+ viewData,
4080
+ relation
4081
+ );
4082
+ } else {
4083
+ return ModelService.toDataJS(item, viewData, relation);
4084
+ }
4085
+ } else {
4086
+ if (item?.length >= 3) {
4087
+ if (!item[OBJECT_POSITION] || item[0] === 2 /* DELETE */) {
4088
+ delete data[key][index];
4089
+ return;
4090
+ }
4091
+ return item[OBJECT_POSITION];
4092
+ } else {
4093
+ return item;
4094
+ }
4095
+ }
4096
+ }
4097
+ });
4098
+ }
4099
+ }
4100
+ }
4101
+ }
4102
+ return { ...data };
4103
+ }
4104
+ };
4105
+ var model_service_default = ModelService;
4106
+
4107
+ // src/services/user-service/index.ts
4108
+ var UserService = {
4109
+ async getProfile() {
4110
+ const env2 = getEnv();
4111
+ return env2.requests.get("/userinfo" /* PROFILE_PATH */, {
4112
+ headers: {
4113
+ "Content-Type": "application/x-www-form-urlencoded"
4114
+ }
4115
+ });
4116
+ },
4117
+ async getUser({ context, id }) {
4118
+ const env2 = getEnv();
4119
+ const jsonData = {
4120
+ model: "res.users",
4121
+ method: "web_read",
4122
+ ids: [id],
4123
+ with_context: context,
4124
+ kwargs: {
4125
+ specification: {
4126
+ display_name: {},
4127
+ image_1920: {},
4128
+ name: {},
4129
+ login: {},
4130
+ email: {},
4131
+ password: {},
4132
+ visible_group_id: {
4133
+ fields: {
4134
+ id: {},
4135
+ display_name: {}
4136
+ }
4137
+ },
4138
+ company_id: {
4139
+ fields: {
4140
+ id: {},
4141
+ display_name: {}
4142
+ }
4143
+ }
4144
+ }
4145
+ }
4146
+ };
4147
+ return env2.requests.post("/call" /* CALL_PATH */, jsonData, {
4148
+ headers: {
4149
+ "Content-Type": "application/json"
4150
+ }
4151
+ });
4152
+ },
4153
+ switchUserLocale: async ({ id, values }) => {
4154
+ const env2 = getEnv();
4155
+ const jsonData = {
4156
+ model: "res.users",
4157
+ domain: [["id", "=", id]],
4158
+ values
4159
+ };
4160
+ return env2?.requests.post(UriConstants?.CREATE_UPDATE_PATH, jsonData, {
4161
+ headers: {
4162
+ "Content-Type": "application/json"
4163
+ }
4164
+ });
4165
+ }
4166
+ };
4167
+ var user_service_default = UserService;
4168
+
4169
+ // src/services/view-service/index.ts
4170
+ var ViewService = {
4171
+ async getView({
4172
+ model,
4173
+ views,
4174
+ context = {},
4175
+ options = {},
4176
+ aid
4177
+ }) {
4178
+ const env2 = getEnv();
4179
+ const defaultOptions = {
4180
+ load_filters: true,
4181
+ toolbar: true,
4182
+ action_id: aid
4183
+ };
4184
+ const jsonDataView = {
4185
+ model,
4186
+ method: "get_fields_view_v2" /* GET_FIELD_VIEW */,
4187
+ kwargs: {
4188
+ views,
4189
+ options: { ...options, ...defaultOptions }
4190
+ },
4191
+ with_context: context
4192
+ };
4193
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonDataView, {
4194
+ headers: {
4195
+ "Content-Type": "application/json"
4196
+ }
4197
+ });
4198
+ },
4199
+ async getMenu(context) {
4200
+ const env2 = getEnv();
4201
+ const jsonData = {
4202
+ model: "ir.ui.menu" /* MENU */,
4203
+ method: "web_search_read" /* WEB_SEARCH_READ */,
4204
+ ids: [],
4205
+ with_context: context,
4206
+ kwargs: {
4207
+ specification: {
4208
+ active: {},
4209
+ name: {},
4210
+ is_display: {},
4211
+ sequence: {},
4212
+ complete_name: {},
4213
+ action: {
4214
+ fields: {
4215
+ display_name: {},
4216
+ type: {},
4217
+ binding_view_types: {}
4218
+ // res_model: {},
4219
+ }
4220
+ },
4221
+ url_icon: {},
4222
+ web_icon: {},
4223
+ web_icon_data: {},
4224
+ groups_id: {
4225
+ fields: {
4226
+ full_name: {}
4227
+ },
4228
+ limit: 40,
4229
+ order: ""
4230
+ },
4231
+ display_name: {},
4232
+ child_id: {
4233
+ fields: {
4234
+ active: {},
4235
+ name: {},
4236
+ is_display: {},
4237
+ sequence: {},
4238
+ complete_name: {},
4239
+ action: {
4240
+ fields: {
4241
+ display_name: {},
4242
+ type: {},
4243
+ binding_view_types: {}
4244
+ // res_model: {},
4245
+ }
4246
+ },
4247
+ url_icon: {},
4248
+ web_icon: {},
4249
+ web_icon_data: {},
4250
+ groups_id: {
4251
+ fields: {
4252
+ full_name: {}
4253
+ },
4254
+ limit: 40,
4255
+ order: ""
4256
+ },
4257
+ display_name: {},
4258
+ child_id: {
4259
+ fields: {
4260
+ active: {},
4261
+ name: {},
4262
+ is_display: {},
4263
+ sequence: {},
4264
+ complete_name: {},
4265
+ action: {
4266
+ fields: {
4267
+ display_name: {},
4268
+ type: {},
4269
+ binding_view_types: {}
4270
+ // res_model: {},
4271
+ }
4272
+ },
4273
+ url_icon: {},
4274
+ web_icon: {},
4275
+ web_icon_data: {},
4276
+ groups_id: {
4277
+ fields: {
4278
+ full_name: {}
4279
+ },
4280
+ limit: 40,
4281
+ order: ""
4282
+ },
4283
+ display_name: {},
4284
+ child_id: {
4285
+ fields: {
4286
+ active: {},
4287
+ name: {},
4288
+ is_display: {},
4289
+ sequence: {},
4290
+ complete_name: {},
4291
+ action: {
4292
+ fields: {
4293
+ display_name: {},
4294
+ type: {},
4295
+ binding_view_types: {}
4296
+ // res_model: {},
4297
+ }
4298
+ },
4299
+ url_icon: {},
4300
+ web_icon: {},
4301
+ web_icon_data: {},
4302
+ groups_id: {
4303
+ fields: {
4304
+ full_name: {}
4305
+ },
4306
+ limit: 40,
4307
+ order: ""
4308
+ },
4309
+ display_name: {},
4310
+ child_id: {
4311
+ fields: {},
4312
+ limit: 40,
4313
+ order: ""
4314
+ }
4315
+ },
4316
+ limit: 40,
4317
+ order: ""
4318
+ }
4319
+ },
4320
+ limit: 40,
4321
+ order: ""
4322
+ }
4323
+ },
4324
+ limit: 40,
4325
+ order: ""
4326
+ }
4327
+ },
4328
+ domain: [
4329
+ "&",
4330
+ ["is_display", "=", true],
4331
+ "&",
4332
+ ["active", "=", true],
4333
+ ["parent_id", "=", false]
4334
+ ]
4335
+ }
4336
+ };
4337
+ return env2?.requests?.post("/call" /* CALL_PATH */, jsonData, {
4338
+ headers: {
4339
+ "Content-Type": "application/json"
4340
+ }
4341
+ });
4342
+ },
4343
+ async getSelectionItem({ data }) {
4344
+ const env2 = getEnv();
4345
+ const jsonData = {
4346
+ model: data.model,
4347
+ ids: [],
4348
+ method: "get_data_select",
4349
+ with_context: data.context,
4350
+ kwargs: {
4351
+ count_limit: 10001,
4352
+ domain: data.domain ? data.domain : [],
4353
+ offset: 0,
4354
+ order: "",
4355
+ specification: data?.specification ?? {
4356
+ id: {},
4357
+ name: {},
4358
+ display_name: {}
4359
+ }
4360
+ }
4361
+ };
4362
+ return env2?.requests.post("/call" /* CALL_PATH */, jsonData, {
4363
+ headers: {
4364
+ "Content-Type": "application/json"
4365
+ }
4366
+ });
4367
+ },
4368
+ async loadMessages() {
4369
+ const env2 = getEnv();
4370
+ return env2.requests.post(
4371
+ "/load_message_failures" /* LOAD_MESSAGE */,
4372
+ {},
4373
+ {
4374
+ headers: {
4375
+ "Content-Type": "application/json"
4376
+ }
4377
+ }
4378
+ );
4379
+ },
4380
+ async getVersion() {
4381
+ const env2 = getEnv();
4382
+ return env2?.requests.get("", {
4383
+ headers: {
4384
+ "Content-Type": "application/json"
4385
+ }
4386
+ });
4387
+ }
4388
+ };
4389
+ var view_service_default = ViewService;
4390
+
4391
+ // src/hooks/auth/use-forgot-password.ts
4392
+ var useForgotPassword = () => {
4393
+ return useMutation({
4394
+ mutationFn: (email) => {
4395
+ return auth_service_default.forgotPassword(email);
4396
+ }
4397
+ });
4398
+ };
4399
+ var use_forgot_password_default = useForgotPassword;
4400
+
4401
+ // src/models/base-model/index.ts
4402
+ var BaseModel = class {
4403
+ name;
4404
+ view;
4405
+ actContext;
4406
+ fields;
4407
+ constructor(init) {
4408
+ this.name = init.name;
4409
+ this.view = init.view;
4410
+ this.actContext = init.actContext;
4411
+ this.fields = init.fields;
4412
+ }
4413
+ getSpecificationByFields({
4414
+ fields = [],
4415
+ specification = {},
4416
+ modelsData,
4417
+ model,
4418
+ modelRoot
4419
+ }) {
4420
+ if (Array.isArray(fields)) {
4421
+ let spec = { ...specification };
4422
+ fields.forEach((field) => {
4423
+ if (!field?.type_co || field?.name && field?.type_co === "field" /* FIELD */) {
4424
+ if (modelsData?.[model]?.[field?.name]) {
4425
+ if (modelsData?.[model]?.[field?.name]?.type === "one2many" /* ONE2MANY */ || modelsData?.[model]?.[field?.name]?.type === "many2many" /* MANY2MANY */) {
4426
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
4427
+ const modelRelation = modelsData?.[relation];
4428
+ if (modelRelation) {
4429
+ spec[field?.name] = {
4430
+ fields: {}
4431
+ };
4432
+ if (modelRoot && modelRoot === relation) {
4433
+ spec[field?.name].fields = { id: {} };
4434
+ } else {
4435
+ spec[field?.name].fields = this.getSpecificationByFields({
4436
+ fields: Object.values(modelRelation),
4437
+ specification: {},
4438
+ modelsData,
4439
+ model: relation,
4440
+ modelRoot: model
4441
+ });
4442
+ }
4443
+ } else {
4444
+ spec[field?.name] = {
4445
+ fields: {
4446
+ id: {},
4447
+ display_name: {}
4448
+ }
4449
+ };
4450
+ }
4451
+ } else if (modelsData?.[model]?.[field?.name]?.type === "many2one" /* MANY2ONE */) {
4452
+ spec[field?.name] = {
4453
+ fields: {
4454
+ id: {},
4455
+ display_name: {},
4456
+ ...WIDGETAVATAR[field?.widget] ? { image_256: {} } : {},
4457
+ ...field?.name === "currency_id" && fields?.find((item) => item?.widget === "monetary") ? { symbol: {} } : {},
4458
+ ...field?.widget === "many2many_binary" ? { mimetype: {} } : {}
4459
+ }
4460
+ };
4461
+ } else {
4462
+ spec[field?.name] = {};
4463
+ }
4464
+ }
4465
+ } else if (field?.type_co === "group" /* GROUP */ || field?.type_co === "div" /* DIV */ || field?.type_co === "span" /* SPAN */) {
4466
+ const specGroup = this.getSpecificationByFields({
4467
+ fields: field?.fields,
4468
+ specification: spec,
4469
+ modelsData,
4470
+ model
4471
+ });
4472
+ spec = { ...spec, ...specGroup };
4473
+ } else if (field?.type_co === "tree" /* TREE */ || field?.type_co === "list" /* LIST */) {
4474
+ const relation = modelsData?.[model]?.[field?.name]?.relation;
4475
+ const specTreee = this.getSpecificationByFields({
4476
+ fields: field?.fields,
4477
+ specification: {},
4478
+ modelsData,
4479
+ model: relation,
4480
+ modelRoot: model
4481
+ });
4482
+ spec = {
4483
+ ...spec,
4484
+ [field?.name]: {
4485
+ fields: { ...spec?.[field?.name]?.fields, ...specTreee }
4486
+ }
4487
+ };
4488
+ }
4489
+ });
4490
+ return spec;
4491
+ } else {
4492
+ console.warn("fields is not array");
4493
+ }
4494
+ }
4495
+ getTreeProps() {
4496
+ const props = this.view?.views?.list || {};
4497
+ return props;
4498
+ }
4499
+ getTreeFields() {
4500
+ const fields = this.view?.views?.list?.fields || [];
4501
+ return fields;
4502
+ }
4503
+ getSpecification() {
4504
+ const specInit = {};
4505
+ const modelData = this.view?.models || {};
4506
+ const specification = this.getSpecificationByFields({
4507
+ fields: this.fields,
4508
+ specification: specInit,
4509
+ modelsData: modelData,
4510
+ model: this.name,
4511
+ modelRoot: ""
4512
+ });
4513
+ return specification;
4514
+ }
4515
+ };
4516
+ var base_model_default = BaseModel;
4517
+ var ReactQueryProvider = ({ children }) => {
4518
+ const [queryClient] = useState(
4519
+ () => new QueryClient({
4520
+ defaultOptions: {
4521
+ queries: {
4522
+ refetchOnWindowFocus: false,
4523
+ refetchOnMount: false,
4524
+ refetchOnReconnect: false,
4525
+ retry: false
4526
+ }
4527
+ }
4528
+ })
4529
+ );
4530
+ return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children });
4531
+ };
4532
+ var ReduxProvider = ({ children }) => {
4533
+ return /* @__PURE__ */ jsx(Provider, { store: envStore, children });
4534
+ };
4535
+ var MainProvider = ({ children }) => {
4536
+ return /* @__PURE__ */ jsx(ReduxProvider, { children: /* @__PURE__ */ jsx(ReactQueryProvider, { children }) });
4537
+ };
4538
+ var VersionGate = ({ children }) => {
4539
+ const queryClient = useQueryClient();
4540
+ const [ready, setReady] = useState(false);
4541
+ useEffect(() => {
4542
+ const clearVersion = () => {
4543
+ queryClient.clear();
4544
+ localStorage.removeItem("__api_version__");
4545
+ };
4546
+ const validateVersion = async () => {
4547
+ const serverVersion = await view_service_default.getVersion();
4548
+ const cached = localStorage.getItem("__api_version__");
4549
+ if (cached !== serverVersion?.api_version) {
4550
+ clearVersion();
4551
+ localStorage.setItem("__api_version__", serverVersion?.api_version);
4552
+ } else {
4553
+ console.log("Api version:", serverVersion?.api_version);
4554
+ }
4555
+ setReady(true);
4556
+ };
4557
+ validateVersion();
4558
+ if (typeof window !== "undefined") {
4559
+ const onKey = (e) => {
4560
+ const key = e.key.toLowerCase();
4561
+ const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
4562
+ if (isHardRefresh) clearVersion();
4563
+ };
4564
+ window.addEventListener("keydown", onKey);
4565
+ return () => window.removeEventListener("keydown", onKey);
4566
+ }
4567
+ }, [queryClient]);
4568
+ return ready ? /* @__PURE__ */ jsx(Fragment, { children }) : null;
4569
+ };
4570
+
4571
+ // src/models/company-model/index.ts
4572
+ var CompanyModel = class extends base_model_default {
4573
+ constructor(init) {
4574
+ super(init);
4575
+ }
4576
+ async getCurrentCompany() {
4577
+ return await company_service_default.getCurrentCompany();
4578
+ }
4579
+ async getUserCompany(id) {
4580
+ return await company_service_default.getInfoCompany(id);
4581
+ }
4582
+ };
4583
+ var company_model_default = CompanyModel;
4584
+
4585
+ // src/models/user-model/index.ts
4586
+ var UserModel = class extends base_model_default {
4587
+ constructor(init) {
4588
+ super(init);
4589
+ }
4590
+ async getProfile() {
4591
+ return await user_service_default.getProfile();
4592
+ }
4593
+ };
4594
+ var user_model_default = UserModel;
4595
+
4596
+ export { action_service_default as ActionService, auth_service_default as AuthService, base_model_default as BaseModel, company_model_default as CompanyModel, company_service_default as CompanyService, ComponentType, EnvStore, excel_service_default as ExcelService, FieldTypeConstants, form_service_default as FormService, KeyConstants, MainProvider, MethodConstants, MethodType, ModelConstants, model_service_default as ModelService, ReactQueryProvider, SearchType, UriConstants, user_model_default as UserModel, user_service_default as UserService, VersionGate, view_service_default as ViewService, WIDGETAVATAR, WIDGETCOLOR, WIDGETNOSTRING, WIDGETSTATUS, axiosClient, checkIsImageLink, clearSearchMap, domainHelper, env, envSlice, envStore, evalJSONContext, evalJSONDomain, excelSlice, formSlice, formatFileSize, formatSortingString, formatUrlPath, getEnv, getFieldsOnChange, getSubdomain, initEnv, isBase64File, isBase64Image, listSlice, navbarSlice, profileSlice, removeKeyFromSearchMap, removeUndefinedFields, searchSlice, selectEnv, selectExcel, selectForm, selectList, selectNavbar, selectProfile, selectSearch, selectSearchMap, setAllowCompanies, setCompanies, setDataParse, setDataUser, setDefaultCompany, setDomainTable, setEnv, setEnvFile, setErrorData, setFieldTranslate, setFields, setFilterBy, setFirstDomain, setFormSubmitComponent, setGroupBy, setGroupByDomain, setHoveredIndexSearchList, setIdFile, setIndexRowTableModal, setIsFileLoaded, setIsShowModalTranslate, setIsShowingModalDetail, setLang, setListSubject, setLoadingImport, setMenuList, setModelSearch, setOrder, setPage, setPageLimit, setProfile, setSearchMap, setSearchString, setSelectedFile, setSelectedRowKeys, setSelectedTags, setTableHead, setTypeFieldsSearch, setUid, setUser, setViewDataStore, stringToColor, toQueryString, updateSearchMap, useAppDispatch, useAppSelector, use_forgot_password_default as useForgotPassword, useTabModel };