@tesouro/embedded-components-react 0.5.231 → 0.5.233

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 (78) hide show
  1. package/README.md +1 -0
  2. package/dist/index.css +4 -0
  3. package/dist/index.d.ts +105 -2
  4. package/dist/index.js +1 -1
  5. package/dist/lib/ReceivablesWidget.d.ts +105 -2
  6. package/dist/lib/ReceivablesWidget.js +1 -1
  7. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index.js +11 -10
  8. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index10.js +92 -55
  9. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index11.js +67 -142
  10. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index12.js +186 -17
  11. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index13.js +27 -0
  12. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index3.js +45 -74
  13. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index4.js +68 -53
  14. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index5.js +66 -32
  15. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index6.js +28 -34
  16. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index7.js +24 -166
  17. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index8.js +177 -1
  18. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/data-access/dist/index9.js +42 -95
  19. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index13.js +36 -33
  21. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index14.js +38 -0
  22. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index16.js +1 -1
  23. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index17.js +206 -147
  24. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index18.js +2 -2
  25. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index19.js +39 -58
  26. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index20.js +53 -227
  27. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index21.js +216 -287
  28. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index22.js +453 -43
  29. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js +103 -126
  30. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js +122 -146
  31. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index25.js +145 -41
  32. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index26.js +39 -115
  33. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index27.js +113 -90
  34. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index28.js +81 -98
  35. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index29.js +111 -27
  36. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index30.js +26 -633
  37. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index31.js +639 -39
  38. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index32.js +41 -40
  39. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index33.js +35 -74
  40. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index34.js +73 -130
  41. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index35.js +133 -329
  42. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index36.js +345 -0
  43. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index.js +13 -12
  44. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index10.js +15 -12
  45. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index19.js +35 -24
  46. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index21.js +8 -71
  47. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index22.js +70 -17
  48. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index23.js +31 -12
  49. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index24.js +18 -30
  50. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index25.js +12 -301
  51. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index26.js +33 -1
  52. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index27.js +14 -46
  53. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index28.js +23 -67
  54. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index29.js +76 -485
  55. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index30.js +395 -95
  56. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index31.js +2 -0
  57. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index32.js +48 -2
  58. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index33.js +72 -4
  59. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index34.js +496 -1
  60. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index35.js +97 -91
  61. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index37.js +2 -236
  62. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index38.js +3 -2
  63. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index39.js +1 -249
  64. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index40.js +89 -82
  65. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index41.js +23 -54
  66. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index42.js +223 -340
  67. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index43.js +3 -0
  68. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index44.js +249 -0
  69. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index45.js +93 -0
  70. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index46.js +59 -0
  71. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index47.js +353 -0
  72. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index9.js +18 -1
  73. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +41 -41
  74. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/clientRegistry.js +6 -3
  75. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +75 -43
  76. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  77. package/package.json +1 -1
  78. package/dist/libs/tesouro-embedded-components-react/invoicing-widget/ui/dist/index36.js +0 -28
@@ -1,131 +1,108 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { buildReceivableAuditHistory as e } from "../../../shared/util/dist/lib/auditHistory/buildReceivableAuditHistory.js";
6
+ import { hasAnyScope as t } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
7
+ import { Scope as n } from "../../../shared/data-access/dist/lib/scopes.js";
8
+ import "../../../shared/data-access/dist/index.js";
9
+ import { useWidgetConfig as ee } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
10
+ import { useOrganizationUserNames as r } from "../../../shared/feature/dist/lib/user/useOrganizationUserNames.js";
11
+ import "../../../shared/feature/dist/index.js";
12
+ import { RECEIVABLE_DETAILS_SECTION as i } from "../../ui/dist/index21.js";
13
+ import "../../ui/dist/index.js";
14
+ import { useAllReceivableHistoryQuery as a } from "../../data-access/dist/index3.js";
15
+ import { usePaymentAccountsQuery as o } from "../../data-access/dist/index4.js";
16
+ import { useReceivablePaymentRecordsQuery as s } from "../../data-access/dist/index9.js";
17
+ import { useReceivablePdfLinkQuery as c, useReceivableQuery as te, useReceivablesByIdQueries as l } from "../../data-access/dist/index11.js";
18
+ import { useOverdueRemindersQuery as u, usePaymentRemindersQuery as ne, useRecurrenceQuery as d } from "../../data-access/dist/index12.js";
19
+ import "../../data-access/dist/index.js";
20
+ import { buildReceivableAuditHistoryLabels as f } from "./index19.js";
21
+ import { getBankAccountPermissions as re } from "./index20.js";
22
+ import { buildReceivableDetailsView as p, buildUnsupportedDetailsView as m } from "./index22.js";
23
+ import { useMemo as h, useState as g } from "react";
1
24
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index23.js
2
- var e = {
3
- invoice: [
4
- "ReceivableFacadeCreateQuotePayload",
5
- "ReceivableCreateBasedOnPayload",
6
- "UpdateQuotePayload",
7
- "UpdateCreditNotePayload",
8
- "UpdateIssuedInvoicePayload"
9
- ],
10
- quote: [
11
- "ReceivableFacadeCreateInvoicePayload",
12
- "ReceivableCreateBasedOnPayload",
13
- "UpdateInvoicePayload",
14
- "UpdateCreditNotePayload",
15
- "UpdateIssuedInvoicePayload"
16
- ]
17
- }, t = {
18
- counterpart_id: "customerId",
19
- counterpart_billing_address_id: "customerId",
20
- counterpart_shipping_address_id: "customerId",
21
- bank_account_id: "bankAccountId",
22
- bank_account_type: "bankAccountId",
23
- payment_terms_id: "paymentTermsId",
24
- "payment_terms.term_final.end_date": "paymentTermsId",
25
- "payment_terms.term_final.number_of_days": "paymentTermsId",
26
- memo: "openingNote",
27
- footer: "closingNote",
28
- "discount.amount": "discount"
29
- }, n = {
30
- quantity: "quantity",
31
- "product.name": "name",
32
- "product.price.value": "price",
33
- "product.price.currency": "price",
34
- "product.measure_unit.name": "measureUnit"
35
- }, r = (e) => typeof e == "number" || /^\d+$/.test(e), i = (e) => /^[A-Z]/.test(e) || e.includes("[") || e.includes("-"), a = (e) => e.filter((e, t) => t !== 0 || e !== "body").filter((e) => r(e) || !i(String(e))).join("."), o = (e) => typeof e == "string" || typeof e == "number", s = (e, t) => e === t || RegExp(`(^|[^A-Za-z0-9_])${t}([^A-Za-z0-9_]|$)`).test(e), c = (e) => typeof e == "object" && !!e;
36
- function l(e) {
37
- if (typeof e == "string") return e.trim() ? {
38
- path: "",
39
- loc: [],
40
- msg: e,
41
- type: ""
42
- } : null;
43
- if (!c(e)) return null;
44
- let { loc: t, msg: n, type: r } = e;
45
- if (typeof n != "string" || !n.trim()) return null;
46
- let i = Array.isArray(t) ? t.filter(o) : [];
25
+ var _ = [i.attachments];
26
+ function v({ selectedReceivableId: v, enabled: y = !0, messages: b, statusLabels: x, auditHistoryLabels: S, onOpenReceivable: C }) {
27
+ let { initResponse: w } = ee(), T = h(() => re(w?.scopes), [w?.scopes]), E = te(v, { enabled: y }), D = E.data, O = D?.type === "invoice" ? D : void 0, k = c(v, { enabled: y && !!O }), ie = ne({ enabled: y && !!O?.payment_reminder_id }), ae = u({ enabled: y && !!O?.overdue_reminder_id }), A = o({
28
+ enabled: y && !!O,
29
+ canReadEmbedded: T.canReadEmbedded,
30
+ canReadExternal: T.canReadExternal
31
+ }), j = d(y ? O?.recurrence_id : void 0), M = j.data, N = s(O?.id, { enabled: y }), P = a(O?.id, { enabled: y && !!O }), F = h(() => O?.status === "recurring" ? (M?.iterations ?? []).flatMap((e) => e.issued_invoice_id ? [e.issued_invoice_id] : []) : [], [O?.status, M?.iterations]), I = l(F, { enabled: y }), L = h(() => new Map(I.filter((e) => !!e).map((e) => [e.id, e])), [I]), [R, z] = g(_), [B, V] = g(v);
32
+ B !== v && (V(v), z(_));
33
+ let H = R.includes(i.auditHistory), U = h(() => P.data?.data ?? [], [P.data]), W = U.some((e) => e.recorded_by === "user" && !!e.entity_user_id), G = t(w?.scopes, [n.UserReadOrg]), { userNames: K, isError: q } = r({ enabled: y && H && G && W }), J = h(() => ({
34
+ ...f(b, x),
35
+ ...S
36
+ }), [
37
+ b,
38
+ x,
39
+ S
40
+ ]), Y = h(() => {
41
+ let t = O ? e(U, K, J, {
42
+ documentType: "invoice",
43
+ currency: O.currency,
44
+ documentNumber: O.document_id,
45
+ dueDate: O.due_date
46
+ }) : [];
47
+ return {
48
+ rows: t,
49
+ countLabel: P.data && !P.isLoading && !P.isError ? String(t.length) : void 0,
50
+ isLoading: P.isLoading,
51
+ isError: P.isError,
52
+ showNamesError: G && q && W
53
+ };
54
+ }, [
55
+ O,
56
+ U,
57
+ K,
58
+ J,
59
+ P.data,
60
+ P.isLoading,
61
+ P.isError,
62
+ G,
63
+ q,
64
+ W
65
+ ]), X = ie.data?.data.find((e) => e.id === O?.payment_reminder_id), Z = ae.data?.data.find((e) => e.id === O?.overdue_reminder_id), Q = A.paymentAccounts.find((e) => e.id === O?.bank_account_id), $ = k.data?.file_url || void 0;
47
66
  return {
48
- path: a(i),
49
- loc: i,
50
- msg: n,
51
- type: typeof r == "string" ? r : ""
52
- };
53
- }
54
- function u(e, t = []) {
55
- if (!c(e) || !Array.isArray(e.detail)) return [];
56
- let n = [], r = /* @__PURE__ */ new Set();
57
- for (let i of e.detail) {
58
- let e = l(i);
59
- if (!e || e.loc.some((e) => typeof e == "string" && t.some((t) => s(e, t)))) continue;
60
- let a = `${e.path}:${e.msg}`;
61
- r.has(a) || (r.add(a), n.push(e));
62
- }
63
- return n;
64
- }
65
- var d = 3;
66
- function f(e, t) {
67
- let n = [...new Set(e.map(({ msg: e }) => e))];
68
- if (!n.length) return "";
69
- let r = n.slice(0, d).join("; "), i = n.length - d;
70
- return i > 0 ? t.apiErrorsSummary.replace("{message}", r).replace("{count}", String(i)) : r;
71
- }
72
- var p = 200;
73
- function m(e) {
74
- let t = e.trim();
75
- if (!(!t || t.length > p) && !t.includes("<")) return t;
76
- }
77
- function h(e, { irrelevantVariants: t, messages: n }) {
78
- if (e instanceof Error) return e.message;
79
- if (typeof e == "string") return m(e) ?? n.unknownError;
80
- if (!c(e)) return n.unknownError;
81
- if (c(e.error) && typeof e.error.message == "string") return e.error.message;
82
- if (Array.isArray(e.detail)) {
83
- let r = f(u(e, t), n);
84
- if (r) return r;
85
- }
86
- return n.unknownError;
87
- }
88
- function g(e) {
89
- return e.replace(/^(invoice|quote)\./, "");
90
- }
91
- var _ = /^line_items\.(?:(add|replace)\.)?(\d+)\.(?:data\.)?(.+)$/;
92
- function v(e, t, n) {
93
- return e === "add" ? n.added?.[t] : e === "replace" ? n.replaced?.[t] : n.created?.[t];
94
- }
95
- function y(e, r) {
96
- let i = {}, a;
97
- for (let { path: o, msg: s } of e) {
98
- if (!o) continue;
99
- let e = g(o);
100
- if (e === "line_items") {
101
- a = s;
102
- continue;
103
- }
104
- let c = t[e];
105
- if (c) {
106
- i[c] = s;
107
- continue;
108
- }
109
- let l = e.match(_);
110
- if (!l) continue;
111
- let [, u, d, f] = l;
112
- if (f === "tax_rate_value") {
113
- i.taxRate = s;
114
- continue;
115
- }
116
- let p = n[f], m = v(u, Number(d), r);
117
- p && m && (i.lineItems = {
118
- ...i.lineItems,
119
- [m]: {
120
- ...i.lineItems?.[m],
121
- [p]: s
122
- }
123
- });
124
- }
125
- return {
126
- errors: i,
127
- listError: a
67
+ receivable: D,
68
+ recurrence: M,
69
+ detailsView: h(() => p({
70
+ receivable: D,
71
+ pdfUrl: $,
72
+ paymentReminder: X,
73
+ overdueReminder: Z,
74
+ depositAccount: Q,
75
+ isAccountListIncomplete: A.isIncomplete,
76
+ recurrence: M,
77
+ paymentRecords: N.data?.data,
78
+ isLoadingPaymentRecords: N.isLoading,
79
+ iterationInvoices: L,
80
+ auditHistory: Y,
81
+ statusLabels: x,
82
+ messages: b,
83
+ onOpenReceivable: C
84
+ }), [
85
+ D,
86
+ $,
87
+ X,
88
+ Z,
89
+ Q,
90
+ A.isIncomplete,
91
+ M,
92
+ N.data,
93
+ N.isLoading,
94
+ L,
95
+ Y,
96
+ x,
97
+ b,
98
+ C
99
+ ]),
100
+ unsupportedView: h(() => m(D, b), [D, b]),
101
+ openSections: R,
102
+ setOpenSections: z,
103
+ isLoading: E.isLoading || k.isLoading || j.isLoading,
104
+ isError: E.isError
128
105
  };
129
106
  }
130
107
  //#endregion
131
- export { e as UNSUBMITTED_PAYLOAD_VARIANTS, y as apiValidationErrorsToFormErrors, h as getApiErrorMessage, u as parseApiValidationErrors, f as summarizeApiValidationErrors, g as toCreatePayloadPath };
108
+ export { v as useReceivableDetails };
@@ -1,155 +1,131 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { toFileArray as e, validateAttachmentFile as t } from "./index7.js";
6
- import { useDeleteReceivableAttachmentMutation as n, useUploadReceivableAttachmentMutation as r } from "../../data-access/dist/index4.js";
7
- import "../../data-access/dist/index.js";
8
- import { useCallback as i, useEffect as a, useRef as o, useState as s } from "react";
9
1
  //#region ../../libs/tesouro-embedded-components-react/invoicing-widget/feature/dist/index24.js
10
- function c({ attachments: c, setAttachments: l, receivableId: u }) {
11
- let { mutateAsync: d } = r(), { mutate: f } = n(), [p, m] = s([]), [h, g] = s(!1), _ = o(0), v = o(/* @__PURE__ */ new Set()), y = o(/* @__PURE__ */ new Set()), b = o(/* @__PURE__ */ new Set()), x = o(0), S = o(!1), C = o({
12
- deleteFile: f,
13
- receivableId: u
14
- });
15
- a(() => {
16
- C.current = {
17
- deleteFile: f,
18
- receivableId: u
19
- };
20
- }, [f, u]), a(() => {
21
- S.current = !1;
22
- let e = y.current;
23
- return () => {
24
- S.current = !0;
25
- let { deleteFile: t, receivableId: n } = C.current;
26
- for (let r of e) t({
27
- path: { file_id: r },
28
- receivableId: n
29
- });
30
- e.clear();
31
- };
32
- }, []);
33
- let w = i(async (e, t) => {
34
- let n = x.current, r = () => S.current || x.current !== n;
35
- try {
36
- let n = await d({
37
- file: t,
38
- receivableId: u
39
- });
40
- if (r() || v.current.delete(e)) {
41
- f({
42
- path: { file_id: n.id },
43
- receivableId: u
44
- });
45
- return;
46
- }
47
- y.current.add(n.id), m((t) => t.filter((t) => t.id !== e)), l((e) => [...e, {
48
- id: n.id,
49
- includeInEmail: !0,
50
- name: n.name,
51
- size: n.size
52
- }]);
53
- } catch {
54
- let t = v.current.delete(e);
55
- if (r() || t) return;
56
- m((t) => t.map((t) => t.id === e ? {
57
- ...t,
58
- status: "upload_failed"
59
- } : t));
60
- }
61
- }, [
62
- f,
63
- u,
64
- l,
65
- d
66
- ]), T = i((n) => {
67
- let r = e(n);
68
- if (r.length === 0) return;
69
- let i = p.filter((e) => e.status === "uploading").length, a = 10 - c.length - i, o = [], s = !1;
70
- for (let e of r) {
71
- _.current += 1;
72
- let n = `pending-attachment-${_.current}`, r = t(e);
73
- if (r) {
74
- o.push({
75
- id: n,
76
- name: e.name,
77
- status: r
78
- });
79
- continue;
80
- }
81
- if (a <= 0) {
82
- s = !0;
83
- continue;
84
- }
85
- --a, o.push({
86
- id: n,
87
- name: e.name,
88
- status: "uploading"
89
- }), w(n, e);
2
+ var e = {
3
+ invoice: [
4
+ "ReceivableFacadeCreateQuotePayload",
5
+ "ReceivableCreateBasedOnPayload",
6
+ "UpdateQuotePayload",
7
+ "UpdateCreditNotePayload",
8
+ "UpdateIssuedInvoicePayload"
9
+ ],
10
+ quote: [
11
+ "ReceivableFacadeCreateInvoicePayload",
12
+ "ReceivableCreateBasedOnPayload",
13
+ "UpdateInvoicePayload",
14
+ "UpdateCreditNotePayload",
15
+ "UpdateIssuedInvoicePayload"
16
+ ]
17
+ }, t = {
18
+ counterpart_id: "customerId",
19
+ counterpart_billing_address_id: "customerId",
20
+ counterpart_shipping_address_id: "customerId",
21
+ bank_account_id: "bankAccountId",
22
+ bank_account_type: "bankAccountId",
23
+ payment_terms_id: "paymentTermsId",
24
+ "payment_terms.term_final.end_date": "paymentTermsId",
25
+ "payment_terms.term_final.number_of_days": "paymentTermsId",
26
+ memo: "openingNote",
27
+ footer: "closingNote",
28
+ "discount.amount": "discount"
29
+ }, n = {
30
+ quantity: "quantity",
31
+ "product.name": "name",
32
+ "product.price.value": "price",
33
+ "product.price.currency": "price",
34
+ "product.measure_unit.name": "measureUnit"
35
+ }, r = (e) => typeof e == "number" || /^\d+$/.test(e), i = (e) => /^[A-Z]/.test(e) || e.includes("[") || e.includes("-"), a = (e) => e.filter((e, t) => t !== 0 || e !== "body").filter((e) => r(e) || !i(String(e))).join("."), o = (e) => typeof e == "string" || typeof e == "number", s = (e, t) => e === t || RegExp(`(^|[^A-Za-z0-9_])${t}([^A-Za-z0-9_]|$)`).test(e), c = (e) => typeof e == "object" && !!e;
36
+ function l(e) {
37
+ if (typeof e == "string") return e.trim() ? {
38
+ path: "",
39
+ loc: [],
40
+ msg: e,
41
+ type: ""
42
+ } : null;
43
+ if (!c(e)) return null;
44
+ let { loc: t, msg: n, type: r } = e;
45
+ if (typeof n != "string" || !n.trim()) return null;
46
+ let i = Array.isArray(t) ? t.filter(o) : [];
47
+ return {
48
+ path: a(i),
49
+ loc: i,
50
+ msg: n,
51
+ type: typeof r == "string" ? r : ""
52
+ };
53
+ }
54
+ function u(e, t = []) {
55
+ if (!c(e) || !Array.isArray(e.detail)) return [];
56
+ let n = [], r = /* @__PURE__ */ new Set();
57
+ for (let i of e.detail) {
58
+ let e = l(i);
59
+ if (!e || e.loc.some((e) => typeof e == "string" && t.some((t) => s(e, t)))) continue;
60
+ let a = `${e.path}:${e.msg}`;
61
+ r.has(a) || (r.add(a), n.push(e));
62
+ }
63
+ return n;
64
+ }
65
+ var d = 3;
66
+ function f(e, t) {
67
+ let n = [...new Set(e.map(({ msg: e }) => e))];
68
+ if (!n.length) return "";
69
+ let r = n.slice(0, d).join("; "), i = n.length - d;
70
+ return i > 0 ? t.apiErrorsSummary.replace("{message}", r).replace("{count}", String(i)) : r;
71
+ }
72
+ var p = 200;
73
+ function m(e) {
74
+ let t = e.trim();
75
+ if (!(!t || t.length > p) && !t.includes("<")) return t;
76
+ }
77
+ function h(e, { irrelevantVariants: t, messages: n }) {
78
+ if (e instanceof Error) return e.message;
79
+ if (typeof e == "string") return m(e) ?? n.unknownError;
80
+ if (!c(e)) return n.unknownError;
81
+ if (c(e.error) && typeof e.error.message == "string") return e.error.message;
82
+ if (Array.isArray(e.detail)) {
83
+ let r = f(u(e, t), n);
84
+ if (r) return r;
85
+ }
86
+ return n.unknownError;
87
+ }
88
+ function g(e) {
89
+ return e.replace(/^(invoice|quote)\./, "");
90
+ }
91
+ var _ = /^line_items\.(?:(add|replace)\.)?(\d+)\.(?:data\.)?(.+)$/;
92
+ function v(e, t, n) {
93
+ return e === "add" ? n.added?.[t] : e === "replace" ? n.replaced?.[t] : n.created?.[t];
94
+ }
95
+ function y(e, r) {
96
+ let i = {}, a;
97
+ for (let { path: o, msg: s } of e) {
98
+ if (!o) continue;
99
+ let e = g(o);
100
+ if (e === "line_items") {
101
+ a = s;
102
+ continue;
90
103
  }
91
- o.length > 0 && m((e) => [...e, ...o]), g(s);
92
- }, [
93
- c.length,
94
- p,
95
- w
96
- ]), E = i((e, t) => {
97
- l((n) => n.map((n) => n.id === e ? {
98
- ...n,
99
- includeInEmail: t
100
- } : n));
101
- }, [l]), D = i((e) => {
102
- g(!1);
103
- let t = p.find((t) => t.id === e);
104
- if (t) {
105
- t.status === "uploading" && v.current.add(e), m((t) => t.filter((t) => t.id !== e));
106
- return;
104
+ let c = t[e];
105
+ if (c) {
106
+ i[c] = s;
107
+ continue;
107
108
  }
108
- if (l((t) => t.filter((t) => t.id !== e)), !y.current.delete(e)) {
109
- b.current.add(e);
110
- return;
109
+ let l = e.match(_);
110
+ if (!l) continue;
111
+ let [, u, d, f] = l;
112
+ if (f === "tax_rate_value") {
113
+ i.taxRate = s;
114
+ continue;
111
115
  }
112
- f({
113
- path: { file_id: e },
114
- receivableId: u
115
- });
116
- }, [
117
- f,
118
- p,
119
- u,
120
- l
121
- ]), O = i(() => {
122
- x.current += 1, v.current.clear(), y.current.clear(), b.current.clear(), m([]), g(!1);
123
- }, []), k = i(() => {
124
- let e = new Set(y.current);
125
- for (let t of e) f({
126
- path: { file_id: t },
127
- receivableId: u
128
- });
129
- l((t) => t.filter(({ id: t }) => !e.has(t))), O();
130
- }, [
131
- f,
132
- u,
133
- O,
134
- l
135
- ]), A = i(() => {
136
- for (let e of b.current) f({
137
- path: { file_id: e },
138
- receivableId: u
116
+ let p = n[f], m = v(u, Number(d), r);
117
+ p && m && (i.lineItems = {
118
+ ...i.lineItems,
119
+ [m]: {
120
+ ...i.lineItems?.[m],
121
+ [p]: s
122
+ }
139
123
  });
140
- b.current.clear();
141
- }, [f, u]);
124
+ }
142
125
  return {
143
- pendingUploads: p,
144
- isUploading: p.some((e) => e.status === "uploading"),
145
- isCountLimitReached: h,
146
- selectFiles: T,
147
- setIncludeInEmail: E,
148
- remove: D,
149
- reset: O,
150
- discardUploads: k,
151
- commitRemovals: A
126
+ errors: i,
127
+ listError: a
152
128
  };
153
129
  }
154
130
  //#endregion
155
- export { c as useReceivableAttachmentUploads };
131
+ export { e as UNSUBMITTED_PAYLOAD_VARIANTS, y as apiValidationErrorsToFormErrors, h as getApiErrorMessage, u as parseApiValidationErrors, f as summarizeApiValidationErrors, g as toCreatePayloadPath };