@fctc/interface-logic 1.4.5 → 1.4.7

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.
@@ -1,34 +1,5 @@
1
- // src/configs/axios-client.ts
2
- import axios from "axios";
3
-
4
- // src/constants/api/key-constant.ts
5
- var KeyConstants = /* @__PURE__ */ ((KeyConstants2) => {
6
- KeyConstants2["PROFILE"] = "userinfo";
7
- KeyConstants2["CURRENT_COMPANY"] = "current_company";
8
- KeyConstants2["LIST_COMPANY"] = "list_company";
9
- KeyConstants2["COMPANY_INFO"] = "company_info";
10
- KeyConstants2["MENU"] = "menus";
11
- KeyConstants2["GET_VIEW_BY_ACTION"] = "get_view_by_action";
12
- KeyConstants2["ACTION_DETAIL"] = "action_detail";
13
- KeyConstants2["GET_DATA_SELECTION"] = "get_data_select";
14
- KeyConstants2["WEB_SAVE"] = "web_save";
15
- KeyConstants2["WEB_READ"] = "web_read";
16
- KeyConstants2["GET_PROVIDER"] = "get_provider";
17
- return KeyConstants2;
18
- })(KeyConstants || {});
19
-
20
- // src/constants/api/method-constant.ts
21
- var MethodConstants = /* @__PURE__ */ ((MethodConstants2) => {
22
- MethodConstants2["WEB_SEARCH_READ"] = "web_search_read";
23
- MethodConstants2["WEB_READ_GROUP"] = "web_read_group";
24
- MethodConstants2["WEB_READ"] = "web_read";
25
- MethodConstants2["WEB_SAVE"] = "web_save";
26
- MethodConstants2["UNLINK"] = "unlink";
27
- MethodConstants2["ONCHANGE"] = "onchange";
28
- MethodConstants2["GET_ONCHANGE_FIELDS"] = "get_fields_onchange";
29
- MethodConstants2["GET_FIELD_VIEW"] = "get_fields_view_v2";
30
- return MethodConstants2;
31
- })(MethodConstants || {});
1
+ // src/hooks/auth/use-forgot-password.ts
2
+ import { useMutation } from "@tanstack/react-query";
32
3
 
33
4
  // src/constants/api/uri-constant.ts
34
5
  var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
@@ -60,380 +31,11 @@ var UriConstants = /* @__PURE__ */ ((UriConstants2) => {
60
31
  return UriConstants2;
61
32
  })(UriConstants || {});
62
33
 
63
- // src/utils/error-handler.ts
64
- var WesapError = class extends Error {
65
- code;
66
- constructor(message, code) {
67
- super(message);
68
- this.code = code;
69
- }
70
- };
71
- function handleError(error, env2) {
72
- if (error instanceof WesapError) {
73
- env2.services.notification.error(error.message);
74
- } else {
75
- env2.services.notification.error("An unexpected error occurred");
76
- }
77
- }
34
+ // src/configs/axios-client.ts
35
+ import axios from "axios";
78
36
 
79
37
  // src/utils/format.ts
80
38
  import moment from "moment";
81
- var formatCurrency = (amount, currency = "USD") => {
82
- const formatter = new Intl.NumberFormat("vi-VN", {
83
- style: "currency",
84
- currency,
85
- minimumFractionDigits: 0
86
- });
87
- return formatter.format(amount).replaceAll(".", ",");
88
- };
89
- var formatDate = (date, locale = "en-US") => {
90
- return new Intl.DateTimeFormat(locale).format(new Date(date));
91
- };
92
- var validateAndParseDate = (input, isDateTime = false) => {
93
- if (!input || typeof input !== "string") return null;
94
- const cleanInput = input.replace(/[^0-9-\/:\s]/g, "");
95
- const dateFormat = "YYYY-MM-DD";
96
- const dateTimeFormat = "YYYY-MM-DD HH:mm:ss";
97
- const currentDay = moment().format("DD");
98
- const currentMonth = moment().format("MM");
99
- const currentYear = moment().format("YYYY");
100
- const defaultTime = "00:00:00";
101
- const maxYear = parseInt(currentYear) + 10;
102
- const isValidDate = (day, month, year) => {
103
- const date = moment(`${day}-${month}-${year}`, "DD-MM-YYYY", true);
104
- return date.isValid();
105
- };
106
- const isValidTime = (hour, minute = "00", second = "00") => {
107
- const h = parseInt(hour, 10);
108
- const m = parseInt(minute, 10);
109
- const s = parseInt(second, 10);
110
- return h >= 0 && h <= 23 && m >= 0 && m <= 59 && s >= 0 && s <= 59;
111
- };
112
- const formatOutput = (day, month, year, time = defaultTime) => {
113
- let result = moment(
114
- `${day}-${month}-${year} ${time}`,
115
- "DD-MM-YYYY HH:mm:ss"
116
- );
117
- if (!result.isValid()) return null;
118
- if (isDateTime) {
119
- result = result.subtract(7, "hours");
120
- return result.format(dateTimeFormat);
121
- }
122
- return result.format(dateFormat);
123
- };
124
- if (isDateTime && input.match(
125
- /^\d{1,2}[\/-]\d{1,2}[\/-]\d{2,4}\s+\d{1,2}(:\d{1,2}(:\d{1,2})?)?$/
126
- )) {
127
- const [datePart, timePart] = input.split(/\s+/);
128
- const dateParts = datePart.split(/[\/-]/);
129
- const timeParts = timePart.split(":");
130
- const day = dateParts[0].padStart(2, "0");
131
- const month = dateParts[1].padStart(2, "0");
132
- const year = dateParts[2].length <= 2 ? `20${dateParts[2].padStart(2, "0")}` : dateParts[2].padStart(4, "0");
133
- const hour = timeParts[0].padStart(2, "0");
134
- const minute = timeParts[1] ? timeParts[1].padStart(2, "0") : "00";
135
- const second = timeParts[2] ? timeParts[2].padStart(2, "0") : "00";
136
- if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
137
- let result = moment(
138
- `${day}-${month}-${year} ${hour}:${minute}:${second}`,
139
- "DD-MM-YYYY HH:mm:ss"
140
- );
141
- if (!result.isValid()) return null;
142
- result = result.subtract(7, "hours");
143
- return result.format(dateTimeFormat);
144
- }
145
- return null;
146
- }
147
- if (cleanInput.match(/^\d{4}-\d{2}-\d{2}$/)) {
148
- const [year, month, day] = cleanInput.split("-");
149
- if (isValidDate(day, month, year)) {
150
- return formatOutput(day, month, year);
151
- }
152
- return null;
153
- }
154
- if (cleanInput.match(/^\d{1,2}\/\d{1,2}\/\d{2,4}$/)) {
155
- const [day, month, year] = cleanInput.split("/");
156
- const paddedDay = day.padStart(2, "0");
157
- const paddedMonth = month.padStart(2, "0");
158
- const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
159
- if (isValidDate(paddedDay, paddedMonth, fullYear)) {
160
- return formatOutput(paddedDay, paddedMonth, fullYear);
161
- }
162
- return null;
163
- }
164
- if (cleanInput.match(/^\d{1,2}-\d{1,2}-\d{2,4}$/)) {
165
- const [day, month, year] = cleanInput.split("-");
166
- const paddedDay = day.padStart(2, "0");
167
- const paddedMonth = month.padStart(2, "0");
168
- const fullYear = year.length <= 2 ? `20${year.padStart(2, "0")}` : year.padStart(4, "0");
169
- if (isValidDate(paddedDay, paddedMonth, fullYear)) {
170
- return formatOutput(paddedDay, paddedMonth, fullYear);
171
- }
172
- return null;
173
- }
174
- if (cleanInput.match(/^\d{1,2}[\/-]\d{1,2}$/)) {
175
- const [day, month] = cleanInput.split(/[\/-]/);
176
- const paddedDay = day.padStart(2, "0");
177
- const paddedMonth = month.padStart(2, "0");
178
- if (isValidDate(paddedDay, paddedMonth, currentYear)) {
179
- return formatOutput(paddedDay, paddedMonth, currentYear);
180
- }
181
- return null;
182
- }
183
- if (cleanInput.match(/^\d{4}$/)) {
184
- const num = parseInt(cleanInput, 10);
185
- if (num >= 2e3 && num <= maxYear) {
186
- if (isValidDate(currentDay, currentMonth, num.toString())) {
187
- return formatOutput(currentDay, currentMonth, num.toString());
188
- }
189
- return null;
190
- }
191
- const day = cleanInput.slice(0, 2);
192
- const month = cleanInput.slice(2, 4);
193
- if (isValidDate(day, month, currentYear)) {
194
- return formatOutput(day, month, currentYear);
195
- }
196
- return null;
197
- }
198
- if (cleanInput.startsWith("-") && /^\-\d+$/.test(cleanInput)) {
199
- const daysToSubtract = Math.abs(parseInt(cleanInput, 10));
200
- let result = moment().subtract(daysToSubtract, "days");
201
- if (isDateTime) {
202
- result = result.subtract(7, "hours");
203
- }
204
- if (result.isValid()) {
205
- return isDateTime ? result.format(dateTimeFormat) : result.format(dateFormat);
206
- }
207
- return null;
208
- }
209
- if (input.match(/^\d{1,2}[^0-9-\/]+\d{1,2}[^0-9-\/]+\d{2,4}.*$/)) {
210
- const parts = input.split(/[^0-9-\/]+/).filter(Boolean);
211
- const day = parts[0].padStart(2, "0");
212
- const month = parts[1].padStart(2, "0");
213
- let year = parts[2];
214
- year = year.length === 2 ? `20${year}` : year.padStart(4, "0");
215
- if (isValidDate(day, month, year)) {
216
- return formatOutput(day, month, year);
217
- }
218
- return null;
219
- }
220
- if (isDateTime) {
221
- if (cleanInput.length === 9) {
222
- const day = cleanInput.slice(0, 2);
223
- const month = cleanInput.slice(2, 4);
224
- const year = cleanInput.slice(4, 8);
225
- const hour = cleanInput.slice(8, 9).padStart(2, "0");
226
- if (isValidDate(day, month, year) && isValidTime(hour)) {
227
- let result = moment(
228
- `${day}-${month}-${year} ${hour}:00:00`,
229
- "DD-MM-YYYY HH:mm:ss"
230
- );
231
- if (!result.isValid()) return null;
232
- result = result.subtract(7, "hours");
233
- return result.format(dateTimeFormat);
234
- }
235
- return null;
236
- }
237
- if (cleanInput.length === 10) {
238
- const day = cleanInput.slice(0, 2);
239
- const month = cleanInput.slice(2, 4);
240
- const year = cleanInput.slice(4, 8);
241
- const hour = cleanInput.slice(8, 10);
242
- if (isValidDate(day, month, year) && isValidTime(hour)) {
243
- let result = moment(
244
- `${day}-${month}-${year} ${hour}:00:00`,
245
- "DD-MM-YYYY HH:mm:ss"
246
- );
247
- if (!result.isValid()) return null;
248
- result = result.subtract(7, "hours");
249
- return result.format(dateTimeFormat);
250
- }
251
- return null;
252
- }
253
- if (cleanInput.length === 11) {
254
- const day = cleanInput.slice(0, 2);
255
- const month = cleanInput.slice(2, 4);
256
- const year = cleanInput.slice(4, 8);
257
- const hour = cleanInput.slice(8, 10);
258
- const minute = cleanInput.slice(10, 11).padStart(2, "0");
259
- if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
260
- let result = moment(
261
- `${day}-${month}-${year} ${hour}:${minute}:00`,
262
- "DD-MM-YYYY HH:mm:ss"
263
- );
264
- if (!result.isValid()) return null;
265
- result = result.subtract(7, "hours");
266
- return result.format(dateTimeFormat);
267
- }
268
- return null;
269
- }
270
- if (cleanInput.length === 12) {
271
- const day = cleanInput.slice(0, 2);
272
- const month = cleanInput.slice(2, 4);
273
- const year = cleanInput.slice(4, 8);
274
- const hour = cleanInput.slice(8, 10);
275
- const minute = cleanInput.slice(10, 12);
276
- if (isValidDate(day, month, year) && isValidTime(hour, minute)) {
277
- let result = moment(
278
- `${day}-${month}-${year} ${hour}:${minute}:00`,
279
- "DD-MM-YYYY HH:mm:ss"
280
- );
281
- if (!result.isValid()) return null;
282
- result = result.subtract(7, "hours");
283
- return result.format(dateTimeFormat);
284
- }
285
- return null;
286
- }
287
- if (cleanInput.length === 13) {
288
- const day = cleanInput.slice(0, 2);
289
- const month = cleanInput.slice(2, 4);
290
- const year = cleanInput.slice(4, 8);
291
- const hour = cleanInput.slice(8, 10);
292
- const minute = cleanInput.slice(10, 12);
293
- const second = cleanInput.slice(12, 13).padStart(2, "0");
294
- if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
295
- let result = moment(
296
- `${day}-${month}-${year} ${hour}:${minute}:${second}`,
297
- "DD-MM-YYYY HH:mm:ss"
298
- );
299
- if (!result.isValid()) return null;
300
- result = result.subtract(7, "hours");
301
- return result.format(dateTimeFormat);
302
- }
303
- return null;
304
- }
305
- if (cleanInput.length === 14) {
306
- const day = cleanInput.slice(0, 2);
307
- const month = cleanInput.slice(2, 4);
308
- const year = cleanInput.slice(4, 8);
309
- const hour = cleanInput.slice(8, 10);
310
- const minute = cleanInput.slice(10, 12);
311
- const second = cleanInput.slice(12, 14);
312
- if (isValidDate(day, month, year) && isValidTime(hour, minute, second)) {
313
- let result = moment(
314
- `${day}-${month}-${year} ${hour}:${minute}:${second}`,
315
- "DD-MM-YYYY HH:mm:ss"
316
- );
317
- if (!result.isValid()) return null;
318
- result = result.subtract(7, "hours");
319
- return result.format(dateTimeFormat);
320
- }
321
- return null;
322
- }
323
- }
324
- const len = cleanInput.length;
325
- if (len === 1 || len === 2) {
326
- const paddedDay = cleanInput.padStart(2, "0");
327
- if (isValidDate(paddedDay, currentMonth, currentYear)) {
328
- return formatOutput(paddedDay, currentMonth, currentYear);
329
- }
330
- return null;
331
- }
332
- if (len === 3) {
333
- const day = cleanInput.slice(0, 2);
334
- const month = cleanInput.slice(2, 3).padStart(2, "0");
335
- if (isValidDate(day, month, currentYear)) {
336
- return formatOutput(day, month, currentYear);
337
- }
338
- return null;
339
- }
340
- if (len === 6) {
341
- const day = cleanInput.slice(0, 2);
342
- const month = cleanInput.slice(2, 4);
343
- let year = cleanInput.slice(4, 6);
344
- year = `20${year}`;
345
- if (parseInt(month) > 12) {
346
- if (isValidDate(day, currentMonth, currentYear)) {
347
- return formatOutput(day, currentMonth, currentYear);
348
- }
349
- return null;
350
- }
351
- if (isValidDate(day, month, year)) {
352
- return formatOutput(day, month, year);
353
- }
354
- return null;
355
- }
356
- if (len === 7) {
357
- return null;
358
- }
359
- if (len === 8) {
360
- const day = cleanInput.slice(0, 2);
361
- const month = cleanInput.slice(2, 4);
362
- const year = cleanInput.slice(4, 8);
363
- if (isValidDate(day, month, year)) {
364
- return formatOutput(day, month, year);
365
- }
366
- return null;
367
- }
368
- if (len > 8 && !isDateTime) {
369
- return null;
370
- }
371
- return null;
372
- };
373
-
374
- // src/constants/field/field-type-constant.ts
375
- var FieldTypeConstants = /* @__PURE__ */ ((FieldTypeConstants2) => {
376
- FieldTypeConstants2["CHAR"] = "char";
377
- FieldTypeConstants2["TEXT"] = "text";
378
- FieldTypeConstants2["INTEGER"] = "integer";
379
- FieldTypeConstants2["FLOAT"] = "float";
380
- FieldTypeConstants2["BOOLEAN"] = "boolean";
381
- FieldTypeConstants2["DATE"] = "date";
382
- FieldTypeConstants2["DATETIME"] = "datetime";
383
- FieldTypeConstants2["BINARY"] = "binary";
384
- FieldTypeConstants2["SELECTION"] = "selection";
385
- FieldTypeConstants2["HTML"] = "html";
386
- FieldTypeConstants2["MANY2ONE"] = "many2one";
387
- FieldTypeConstants2["ONE2MANY"] = "one2many";
388
- FieldTypeConstants2["MANY2MANY"] = "many2many";
389
- FieldTypeConstants2["MONETARY"] = "monetary";
390
- FieldTypeConstants2["REFERENCE"] = "reference";
391
- FieldTypeConstants2["FUNCTION"] = "function";
392
- FieldTypeConstants2["PROPERTY"] = "property";
393
- return FieldTypeConstants2;
394
- })(FieldTypeConstants || {});
395
-
396
- // src/constants/method/method-type-constant.ts
397
- var MethodType = /* @__PURE__ */ ((MethodType2) => {
398
- MethodType2[MethodType2["CREATE"] = 0] = "CREATE";
399
- MethodType2[MethodType2["UPDATE"] = 1] = "UPDATE";
400
- MethodType2[MethodType2["DELETE"] = 2] = "DELETE";
401
- MethodType2[MethodType2["UNLINK"] = 3] = "UNLINK";
402
- MethodType2[MethodType2["NO_CHANGE"] = 4] = "NO_CHANGE";
403
- return MethodType2;
404
- })(MethodType || {});
405
-
406
- // src/constants/model/model-constant.ts
407
- var ModelConstants = /* @__PURE__ */ ((ModelConstants2) => {
408
- ModelConstants2["MENU"] = "ir.ui.menu";
409
- ModelConstants2["USER"] = "res.users";
410
- ModelConstants2["COMPANY"] = "res.company";
411
- ModelConstants2["WINDOW_ACTION"] = "ir.actions.act_window";
412
- ModelConstants2["BASE_IMPORT"] = "base_import.import";
413
- ModelConstants2["GET_IMPORT"] = "get_import_templates";
414
- return ModelConstants2;
415
- })(ModelConstants || {});
416
-
417
- // src/constants/type/index.ts
418
- var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
419
- ComponentType2["GROUP"] = "group";
420
- ComponentType2["FIELD"] = "field";
421
- ComponentType2["TREE"] = "tree";
422
- ComponentType2["DIV"] = "div";
423
- ComponentType2["LIST"] = "list";
424
- ComponentType2["FORM"] = "form";
425
- ComponentType2["SETTINGS"] = "setting";
426
- ComponentType2["SPAN"] = "span";
427
- ComponentType2["KANBAN"] = "kanban";
428
- ComponentType2["CALENDAR"] = "calendar";
429
- ComponentType2["TYPE"] = "view-type";
430
- return ComponentType2;
431
- })(ComponentType || {});
432
- var SearchType = {
433
- FILTER: "filter_by",
434
- SEARCH: "search_by",
435
- GROUP: "group_by"
436
- };
437
39
 
438
40
  // src/constants/widget/widget-avatar-constant.ts
439
41
  var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
@@ -441,28 +43,6 @@ var WIDGETAVATAR = /* @__PURE__ */ ((WIDGETAVATAR2) => {
441
43
  WIDGETAVATAR2["many2many_avatar_user"] = "many2many_avatar_user";
442
44
  return WIDGETAVATAR2;
443
45
  })(WIDGETAVATAR || {});
444
- var WIDGETCURRENCY = /* @__PURE__ */ ((WIDGETCURRENCY2) => {
445
- WIDGETCURRENCY2["many2one_avatar_user"] = "many2one_avatar_user";
446
- WIDGETCURRENCY2["many2many_avatar_user"] = "many2many_avatar_user";
447
- return WIDGETCURRENCY2;
448
- })(WIDGETCURRENCY || {});
449
-
450
- // src/constants/widget/widget-color-constant.ts
451
- var WIDGETCOLOR = /* @__PURE__ */ ((WIDGETCOLOR2) => {
452
- WIDGETCOLOR2["many2many_tags"] = "many2many_tags";
453
- WIDGETCOLOR2["helpdesk_sla_many2many_tags"] = "helpdesk_sla_many2many_tags";
454
- return WIDGETCOLOR2;
455
- })(WIDGETCOLOR || {});
456
-
457
- // src/constants/widget/widget-status-constant.ts
458
- var WIDGETSTATUS = /* @__PURE__ */ ((WIDGETSTATUS2) => {
459
- WIDGETSTATUS2["sla_status_ids"] = "sla_status_ids";
460
- return WIDGETSTATUS2;
461
- })(WIDGETSTATUS || {});
462
- var WIDGETNOSTRING = /* @__PURE__ */ ((WIDGETNOSTRING2) => {
463
- WIDGETNOSTRING2["sla_status_ids"] = "sla_status_ids";
464
- return WIDGETNOSTRING2;
465
- })(WIDGETNOSTRING || {});
466
46
 
467
47
  // src/utils/domain/py_tokenizer.ts
468
48
  var TokenizerError = class extends Error {
@@ -2231,48 +1811,6 @@ function parseExpr(expr) {
2231
1811
  const tokens = tokenize(expr);
2232
1812
  return parse(tokens);
2233
1813
  }
2234
- function evaluateExpr(expr, context = {}) {
2235
- let ast;
2236
- try {
2237
- ast = parseExpr(expr);
2238
- } catch (error) {
2239
- throw new EvalError(
2240
- `Can not parse python expression: (${expr})
2241
- Error: ${error.message}`
2242
- );
2243
- }
2244
- try {
2245
- return evaluate(ast, context);
2246
- } catch (error) {
2247
- throw new EvalError(
2248
- `Can not evaluate python expression: (${expr})
2249
- Error: ${error.message}`
2250
- );
2251
- }
2252
- }
2253
- function evaluateBooleanExpr(expr, context = {}) {
2254
- if (!expr || expr === "False" || expr === "0") {
2255
- return false;
2256
- }
2257
- if (expr === "True" || expr === "1") {
2258
- return true;
2259
- }
2260
- return evaluateExpr(`bool(${expr})`, context);
2261
- }
2262
-
2263
- // src/utils/domain/context.ts
2264
- function evalPartialContext(_context, evaluationContext = {}) {
2265
- const ast = parseExpr(_context);
2266
- const context = {};
2267
- for (const key in ast.value) {
2268
- const value = ast.value[key];
2269
- try {
2270
- context[key] = evaluate(value, evaluationContext);
2271
- } catch {
2272
- }
2273
- }
2274
- return context;
2275
- }
2276
1814
 
2277
1815
  // src/utils/domain/objects.ts
2278
1816
  function shallowEqual(obj1, obj2, comparisonFn = (a, b) => a === b) {
@@ -2611,280 +2149,14 @@ function matchDomain(record, domain) {
2611
2149
  }
2612
2150
  return matchCondition(record, condStack.pop());
2613
2151
  }
2614
- var checkDomain = (context, domain) => {
2615
- try {
2616
- if (domain === void 0 || domain === "0" || domain === "False" || domain === false) {
2617
- return false;
2618
- } else if (domain === "1" || domain === "True" || domain === true) {
2619
- return true;
2620
- }
2621
- try {
2622
- if (context && domain) {
2623
- const d = new Domain(domain);
2624
- return d.contains(context);
2625
- }
2626
- } catch (error) {
2627
- if (context && domain) {
2628
- const domainEval = evaluateBooleanExpr(domain, context);
2629
- return domainEval;
2630
- }
2631
- return false;
2632
- }
2633
- return false;
2634
- } catch (e) {
2635
- return false;
2636
- }
2637
- };
2638
- var matchDomains = (context, domains) => {
2639
- if (Array.isArray(domains)) {
2640
- if (domains?.length > 0) {
2641
- return domains && domains.some((domain) => checkDomain(context, domain));
2642
- }
2643
- } else return checkDomain(context, domains);
2644
- return false;
2645
- };
2646
2152
 
2647
2153
  // src/utils/function.ts
2648
2154
  import { useEffect, useState } from "react";
2649
- var evalJSONContext = (_context, context = {}) => {
2650
- try {
2651
- return evalPartialContext(_context, context);
2652
- } catch (err) {
2653
- return null;
2654
- }
2655
- };
2656
- var evalJSONDomain = (domain, context) => {
2657
- try {
2658
- if (context) {
2659
- Object.keys(context)?.forEach((key) => {
2660
- if (Array.isArray(context[key])) {
2661
- const isTypeObject = context[key]?.every(
2662
- (item) => typeof item === "object" && item !== null && item?.id !== void 0
2663
- );
2664
- if (isTypeObject) {
2665
- context[key] = context[key]?.map((item) => item?.id);
2666
- }
2667
- }
2668
- });
2669
- }
2670
- const value = evaluateExpr(domain, context);
2671
- return value;
2672
- } catch (err) {
2673
- try {
2674
- const domainObject = new Domain(domain).toList(context);
2675
- return domainObject;
2676
- } catch (err2) {
2677
- return [];
2678
- }
2679
- }
2680
- };
2681
- var formatSortingString = (input) => {
2682
- if (!input) return null;
2683
- return input.split(",").map((field) => {
2684
- const [key, order] = field.trim().split(/\s+/);
2685
- const sortOrder = order?.toUpperCase() === "DESC" ? "DESC" : "ASC";
2686
- return `${key} ${sortOrder}`;
2687
- }).join(", ");
2688
- };
2689
- var domainHelper = {
2690
- checkDomain,
2691
- matchDomains,
2692
- Domain
2693
- };
2694
2155
  var toQueryString = (params) => {
2695
2156
  return Object.keys(params).map(
2696
2157
  (key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key].toString())
2697
2158
  ).join("&");
2698
2159
  };
2699
- var convertFloatToTime = (floatValue) => {
2700
- const hours = Math.floor(floatValue);
2701
- const minutes = Math.round((floatValue - hours) * 60);
2702
- const formattedHours = String(hours).padStart(2, "0");
2703
- const formattedMinutes = String(minutes).padStart(2, "0");
2704
- return `${formattedHours}:${formattedMinutes}`;
2705
- };
2706
- var convertTimeToFloat = (timeString) => {
2707
- const [hours, minutes] = timeString.split(":").map(Number);
2708
- return hours + minutes / 60;
2709
- };
2710
- var stringToColor = (name, id) => {
2711
- const combined = name + id / 2;
2712
- let hash = 0;
2713
- for (let i = 0; i < combined.length; i++) {
2714
- hash = combined.charCodeAt(i) + ((hash << 5) - hash);
2715
- }
2716
- const r = hash >> 16 & 255;
2717
- const g = hash >> 8 & 255;
2718
- const b = hash & 255;
2719
- const adjustedR = 120 + r % 61;
2720
- const adjustedG = 120 + g % 61;
2721
- const adjustedB = 120 + b % 61;
2722
- return `#${adjustedR.toString(16).padStart(2, "0")}${adjustedG.toString(16).padStart(2, "0")}${adjustedB.toString(16).padStart(2, "0")}`;
2723
- };
2724
- var getFieldsOnChange = (fields) => {
2725
- const result = [];
2726
- function traverse(items) {
2727
- for (const item of items) {
2728
- if (item) {
2729
- if (item?.type_co === "field" && matchDomains(fields, item?.on_change)) {
2730
- result.push(item.name);
2731
- }
2732
- if (item?.fields && Array.isArray(item?.fields)) {
2733
- traverse(item?.fields);
2734
- }
2735
- }
2736
- }
2737
- }
2738
- traverse(fields);
2739
- return result;
2740
- };
2741
- var filterFieldDirty = ({
2742
- id,
2743
- viewData,
2744
- formValues,
2745
- dirtyFields,
2746
- model,
2747
- defaultData
2748
- }) => {
2749
- const data = id ? { ...dirtyFields } : { ...formValues };
2750
- for (const key in data) {
2751
- if (viewData?.models?.[model]?.[key]?.type === "one2many" /* ONE2MANY */) {
2752
- const lineData = [];
2753
- (formValues[key] ?? []).forEach((itemData, index) => {
2754
- if (typeof itemData?.id === "string" && itemData?.id.includes("virtual")) {
2755
- delete itemData?.id;
2756
- }
2757
- if (!itemData?.id) {
2758
- lineData.push([
2759
- 0 /* CREATE */,
2760
- `virtual_${index}`,
2761
- filterFieldDirty({
2762
- id: itemData?.id,
2763
- viewData,
2764
- formValues: itemData,
2765
- dirtyFields: {},
2766
- model: viewData?.models?.[model]?.[key]?.relation,
2767
- defaultData
2768
- })
2769
- ]);
2770
- } else if (dirtyFields[key]?.length) {
2771
- dirtyFields[key].forEach((itemDirty, indexDirty) => {
2772
- if (Object.values(itemDirty).includes(true) && indexDirty === index) {
2773
- lineData.push([
2774
- 1 /* UPDATE */,
2775
- itemData?.id,
2776
- filterFieldDirty({
2777
- id: itemData?.id,
2778
- viewData,
2779
- formValues: itemData,
2780
- dirtyFields: itemDirty,
2781
- model: viewData?.models?.[model]?.[key]?.relation,
2782
- defaultData: {}
2783
- })
2784
- ]);
2785
- }
2786
- });
2787
- }
2788
- });
2789
- (defaultData[key] ?? []).forEach((item) => {
2790
- if (!(formValues[key] ?? []).find(
2791
- (itemData) => itemData?.id === item?.id
2792
- )) {
2793
- lineData.push([2 /* DELETE */, item?.id, item]);
2794
- }
2795
- });
2796
- data[key] = lineData;
2797
- } else if (viewData?.models?.[model]?.[key]?.type === "many2many" /* MANY2MANY */) {
2798
- const lineData = [];
2799
- (formValues[key] || []).forEach((itemData) => {
2800
- if (itemData?.id) {
2801
- lineData.push([4 /* NO_CHANGE */, itemData?.id]);
2802
- }
2803
- });
2804
- (defaultData[key] ?? []).forEach((item) => {
2805
- if (!(formValues[key] ?? []).find(
2806
- (itemData) => itemData?.id === item?.id
2807
- )) {
2808
- lineData.push([3 /* UNLINK */, item?.id]);
2809
- }
2810
- });
2811
- data[key] = lineData;
2812
- } else {
2813
- if (id && (typeof dirtyFields?.[key] === "object" && !dirtyFields?.[key]?.id || typeof dirtyFields[key] !== "object" && !dirtyFields[key])) {
2814
- delete data[key];
2815
- } else {
2816
- if (!data[key]) {
2817
- delete data[key];
2818
- } else {
2819
- data[key] = formValues?.[key]?.display_name ? formValues?.[key]?.id : formValues?.[key];
2820
- }
2821
- }
2822
- }
2823
- }
2824
- return data;
2825
- };
2826
- var mergeObjects = (object1, object2) => {
2827
- if (!object1 || !object2) return void 0;
2828
- const mergedObject = { ...object2 };
2829
- Object.keys(object1).forEach((key) => {
2830
- if (Array.isArray(object1[key]) && Array.isArray(object2[key])) {
2831
- mergedObject[key] = object2[key].map((item, index) => {
2832
- if (object1[key][index]) {
2833
- return {
2834
- ...item,
2835
- ...object1[key][index]
2836
- };
2837
- }
2838
- return item;
2839
- });
2840
- } else if (typeof object1[key] === "object" && typeof object2[key] === "object" && object1[key] !== null && object2[key] !== null) {
2841
- mergedObject[key] = mergeObjects(object1[key], object2[key]);
2842
- } else {
2843
- mergedObject[key] = object1[key] !== void 0 ? object1[key] : object2[key];
2844
- }
2845
- });
2846
- if (object2) {
2847
- Object.keys(object2).forEach((key) => {
2848
- if (!mergedObject.hasOwnProperty(key)) {
2849
- mergedObject[key] = object2[key];
2850
- }
2851
- });
2852
- }
2853
- return mergedObject;
2854
- };
2855
- var formatUrlPath = ({
2856
- viewType,
2857
- aid,
2858
- model,
2859
- id,
2860
- actionPath
2861
- }) => {
2862
- let _url = `/${viewType}/${actionPath}?aid=${aid}&model=${model}`;
2863
- if (id) {
2864
- _url += `&id=${id}`;
2865
- }
2866
- return _url;
2867
- };
2868
- var removeUndefinedFields = (obj) => {
2869
- const newObj = {};
2870
- for (const key in obj) {
2871
- if (obj[key] !== void 0) {
2872
- newObj[key] = obj[key];
2873
- }
2874
- }
2875
- return newObj;
2876
- };
2877
- var useTabModel = (viewData, onchangeData) => {
2878
- const tabsData = viewData?.views?.form?.tabs?.filter((val) => {
2879
- if (!val) return null;
2880
- const hide = checkDomain(onchangeData, val.invisible);
2881
- if (!hide) {
2882
- return val;
2883
- }
2884
- return false;
2885
- }) || [];
2886
- return tabsData;
2887
- };
2888
2160
  var isBase64File = (str) => {
2889
2161
  try {
2890
2162
  const dataUriPattern = /^data:([a-zA-Z]+\/[a-zA-Z0-9-.+]+)?;base64,/;
@@ -2900,69 +2172,6 @@ var isBase64File = (str) => {
2900
2172
  return false;
2901
2173
  }
2902
2174
  };
2903
- var isBase64Image = (str) => {
2904
- const base64Regex = /^data:image\/(png|jpeg|jpg|gif|webp);base64,/;
2905
- if (!base64Regex.test(str)) {
2906
- return false;
2907
- }
2908
- try {
2909
- const base64Data = str.split(",")[1];
2910
- return !!base64Data && atob(base64Data).length > 0;
2911
- } catch (error) {
2912
- return false;
2913
- }
2914
- };
2915
- var checkIsImageLink = (url) => {
2916
- const imageExtensions = /\.(jpg|jpeg|png|gif|bmp|webp|svg|tiff|ico)$/i;
2917
- return imageExtensions.test(url) || isBase64Image(url);
2918
- };
2919
- var formatFileSize = (size) => {
2920
- if (size < 1024) return `${size} B`;
2921
- const i = Math.floor(Math.log(size) / Math.log(1024));
2922
- const sizes = ["B", "KB", "MB", "GB", "TB"];
2923
- return `${(size / Math.pow(1024, i)).toFixed(2)} ${sizes[i]}`;
2924
- };
2925
- var getSubdomain = (url = window.location.href) => {
2926
- const parts = url?.split(".");
2927
- if (parts.length > 2) {
2928
- return parts[0].replace("https://", "").replace("http://", "");
2929
- }
2930
- return null;
2931
- };
2932
- var resequence = (arr, start, end) => {
2933
- if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
2934
- return [];
2935
- }
2936
- const [element] = arr.splice(start, 1);
2937
- arr.splice(end, 0, element);
2938
- return arr.slice(Math.min(start, end), Math.max(start, end) + 1);
2939
- };
2940
- var getOffSet = (arr, start, end) => {
2941
- if (start < 0 || start >= arr.length || end < 0 || end >= arr.length) {
2942
- return 0;
2943
- }
2944
- if (start > end) {
2945
- return end;
2946
- }
2947
- return arr.slice(0, start).length;
2948
- };
2949
- var copyTextToClipboard = async (text) => {
2950
- if ("clipboard" in navigator) {
2951
- return await navigator.clipboard.writeText(text);
2952
- } else {
2953
- const textArea = document.createElement("textarea");
2954
- textArea.value = text;
2955
- textArea.style.position = "fixed";
2956
- document.body.appendChild(textArea);
2957
- textArea.focus();
2958
- textArea.select();
2959
- try {
2960
- document.execCommand("copy");
2961
- } finally {
2962
- document.body.removeChild(textArea);
2963
- }
2964
- }
2965
- };
2966
2175
  var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2967
2176
  if (!originalRequest.data) return originalRequest.data;
2968
2177
  if (typeof originalRequest.data === "string") {
@@ -2982,41 +2191,6 @@ var updateTokenParamInOriginalRequest = (originalRequest, newAccessToken) => {
2982
2191
  }
2983
2192
  return originalRequest.data;
2984
2193
  };
2985
- var isObjectEmpty = (obj) => {
2986
- return Object.keys(obj).length === 0;
2987
- };
2988
- var useField = (props) => {
2989
- const [invisible, setInvisible] = useState(true);
2990
- const [required, setRequired] = useState(false);
2991
- const [readonly, setReadOnly] = useState(false);
2992
- const {
2993
- invisible: inv,
2994
- required: req,
2995
- readonly: rea,
2996
- onchangeData,
2997
- rootField,
2998
- index,
2999
- name
3000
- } = props;
3001
- const nameField = rootField ? `${rootField?.name}.${index}.${name}` : null;
3002
- useEffect(() => {
3003
- if (onchangeData && Object.keys(onchangeData).length > 0) {
3004
- setRequired(
3005
- typeof req === "object" ? matchDomains(onchangeData, req) : checkDomain(onchangeData, req)
3006
- );
3007
- setInvisible(matchDomains(onchangeData, inv));
3008
- setReadOnly(
3009
- typeof req === "object" ? matchDomains(onchangeData, rea) : checkDomain(onchangeData, rea)
3010
- );
3011
- }
3012
- }, [onchangeData]);
3013
- return {
3014
- invisible,
3015
- required,
3016
- readonly,
3017
- nameField
3018
- };
3019
- };
3020
2194
 
3021
2195
  // src/utils/storage/local-storage.ts
3022
2196
  var localStorageUtils = () => {
@@ -3317,7 +2491,6 @@ var {
3317
2491
  setConfig,
3318
2492
  setEnvFile
3319
2493
  } = envSlice.actions;
3320
- var selectEnv = (state) => state.env;
3321
2494
  var env_slice_default = envSlice.reducer;
3322
2495
 
3323
2496
  // src/store/reducers/excel-slice/index.ts
@@ -3846,10 +3019,6 @@ var envStore = configureStore({
3846
3019
  })
3847
3020
  });
3848
3021
 
3849
- // src/store/index.ts
3850
- var useAppDispatch = useDispatch;
3851
- var useAppSelector = useSelector;
3852
-
3853
3022
  // src/environment/EnvStore.ts
3854
3023
  var EnvStore = class {
3855
3024
  envStore;
@@ -3931,9 +3100,6 @@ function getEnv() {
3931
3100
  return env;
3932
3101
  }
3933
3102
 
3934
- // src/hooks/auth/use-forgot-password.ts
3935
- import { useMutation } from "@tanstack/react-query";
3936
-
3937
3103
  // src/services/action-service/index.ts
3938
3104
  var ActionService = {
3939
3105
  // Load Action
@@ -6677,112 +5843,7 @@ var useVerifyTotp = () => {
6677
5843
  });
6678
5844
  };
6679
5845
  var use_verify_totp_default = useVerifyTotp;
6680
-
6681
- // src/provider/react-query-provider.tsx
6682
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
6683
- import { jsx } from "react/jsx-runtime";
6684
-
6685
- // src/provider/redux-provider.tsx
6686
- import { Provider } from "react-redux";
6687
- import { jsx as jsx2 } from "react/jsx-runtime";
6688
-
6689
- // src/provider/main-provider.tsx
6690
- import { jsx as jsx3 } from "react/jsx-runtime";
6691
-
6692
- // src/provider/version-gate-provider.tsx
6693
- import { useEffect as useEffect2, useState as useState2 } from "react";
6694
- import { useQueryClient } from "@tanstack/react-query";
6695
- import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
6696
- var VersionGate = ({ children }) => {
6697
- const queryClient = useQueryClient();
6698
- const [ready, setReady] = useState2(false);
6699
- useEffect2(() => {
6700
- const clearVersion = () => {
6701
- queryClient.clear();
6702
- localStorage.removeItem("__api_version__");
6703
- };
6704
- const validateVersion = async () => {
6705
- const serverVersion = await view_service_default.getVersion();
6706
- const cached = localStorage.getItem("__api_version__");
6707
- if (cached !== serverVersion?.api_version) {
6708
- clearVersion();
6709
- localStorage.setItem("__api_version__", serverVersion?.api_version);
6710
- } else {
6711
- console.log("Api version:", serverVersion?.api_version);
6712
- }
6713
- setReady(true);
6714
- };
6715
- validateVersion();
6716
- if (typeof window !== "undefined") {
6717
- const onKey = (e) => {
6718
- const key = e.key.toLowerCase();
6719
- const isHardRefresh = (key === "f5" || key === "r") && e.ctrlKey && (key !== "r" || e.shiftKey) || key === "r" && e.metaKey && e.shiftKey || key === "r" && e.metaKey && e.altKey;
6720
- if (isHardRefresh) clearVersion();
6721
- };
6722
- window.addEventListener("keydown", onKey);
6723
- return () => window.removeEventListener("keydown", onKey);
6724
- }
6725
- }, [queryClient]);
6726
- return ready ? /* @__PURE__ */ jsx4(Fragment, { children }) : null;
6727
- };
6728
5846
  export {
6729
- action_service_default as ActionService,
6730
- auth_service_default as AuthService,
6731
- company_service_default as CompanyService,
6732
- ComponentType,
6733
- EnvStore,
6734
- excel_service_default as ExcelService,
6735
- FieldTypeConstants,
6736
- form_service_default as FormService,
6737
- kanban_service_default as KanbanService,
6738
- KeyConstants,
6739
- MethodConstants,
6740
- MethodType,
6741
- ModelConstants,
6742
- model_service_default as ModelService,
6743
- SearchType,
6744
- UriConstants,
6745
- user_service_default as UserService,
6746
- VersionGate,
6747
- view_service_default as ViewService,
6748
- WIDGETAVATAR,
6749
- WIDGETCOLOR,
6750
- WIDGETCURRENCY,
6751
- WIDGETNOSTRING,
6752
- WIDGETSTATUS,
6753
- WesapError,
6754
- axiosClient,
6755
- checkIsImageLink,
6756
- convertFloatToTime,
6757
- convertTimeToFloat,
6758
- copyTextToClipboard,
6759
- domainHelper,
6760
- evalJSONContext,
6761
- evalJSONDomain,
6762
- filterFieldDirty,
6763
- formatCurrency,
6764
- formatDate,
6765
- formatFileSize,
6766
- formatSortingString,
6767
- formatUrlPath,
6768
- getEnv,
6769
- getFieldsOnChange,
6770
- getOffSet,
6771
- getSubdomain,
6772
- handleError,
6773
- isBase64File,
6774
- isBase64Image,
6775
- isObjectEmpty,
6776
- mergeObjects,
6777
- removeUndefinedFields,
6778
- resequence,
6779
- selectEnv,
6780
- setEnvFile,
6781
- stringToColor,
6782
- toQueryString,
6783
- updateTokenParamInOriginalRequest,
6784
- useAppDispatch,
6785
- useAppSelector,
6786
5847
  use_button_default as useButton,
6787
5848
  use_change_status_default as useChangeStatus,
6788
5849
  use_delete_default as useDelete,
@@ -6790,7 +5851,6 @@ export {
6790
5851
  use_duplicate_record_default as useDuplicateRecord,
6791
5852
  uss_execute_import_default as useExecuteImport,
6792
5853
  use_export_excel_default as useExportExcel,
6793
- useField,
6794
5854
  use_forgot_password_default as useForgotPassword,
6795
5855
  use_forgotpassword_sso_default as useForgotPasswordSSO,
6796
5856
  uset_get_2FA_method_default as useGet2FAMethods,
@@ -6846,12 +5906,10 @@ export {
6846
5906
  use_settings_web_read_2fa_default as useSettingsWebRead2fa,
6847
5907
  use_signin_sso_default as useSignInSSO,
6848
5908
  use_switch_locale_default as useSwitchLocale,
6849
- useTabModel,
6850
5909
  use_update_password_default as useUpdatePassword,
6851
5910
  use_upload_file_default as useUploadFile,
6852
5911
  use_upload_id_file_default as useUploadIdFile,
6853
5912
  use_upload_image_default as useUploadImage,
6854
5913
  use_verify_2FA_default as useVerify2FA,
6855
- use_verify_totp_default as useVerifyTotp,
6856
- validateAndParseDate
5914
+ use_verify_totp_default as useVerifyTotp
6857
5915
  };