@fctc/edu-logic-lib 1.0.2 → 1.0.3

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