@alfadocs/ui-kit-debug 1.130.2 → 1.132.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/_chunks/{address-autocomplete-D2uNpxcE.js → address-autocomplete-yDLqg43e.js} +2 -2
  2. package/dist/_chunks/{address-autocomplete-D2uNpxcE.js.map → address-autocomplete-yDLqg43e.js.map} +1 -1
  3. package/dist/_chunks/{address-fields-BU65pA-V.js → address-fields-DvSWdeR0.js} +2 -2
  4. package/dist/_chunks/{address-fields-BU65pA-V.js.map → address-fields-DvSWdeR0.js.map} +1 -1
  5. package/dist/_chunks/bill-line-table-DHKb_O7c.js +2000 -0
  6. package/dist/_chunks/bill-line-table-DHKb_O7c.js.map +1 -0
  7. package/dist/_chunks/{data-grid-C9xlUMLt.js → data-grid-B2oaI7Lt.js} +2345 -2328
  8. package/dist/_chunks/data-grid-B2oaI7Lt.js.map +1 -0
  9. package/dist/_chunks/{default-tabs-BryvhiHv.js → default-tabs-DbebYO04.js} +3 -3
  10. package/dist/_chunks/{default-tabs-BryvhiHv.js.map → default-tabs-DbebYO04.js.map} +1 -1
  11. package/dist/_chunks/{invoice-upload-list-868v1oDe.js → invoice-upload-list-B5aMffTy.js} +21 -21
  12. package/dist/_chunks/{invoice-upload-list-868v1oDe.js.map → invoice-upload-list-B5aMffTy.js.map} +1 -1
  13. package/dist/_chunks/map-view-Cm69dCnY.js +1794 -0
  14. package/dist/_chunks/map-view-Cm69dCnY.js.map +1 -0
  15. package/dist/_chunks/{maps-core-gate-DKx96CC_.js → maps-core-gate-CP8SEHH1.js} +97 -93
  16. package/dist/_chunks/{maps-core-gate-DKx96CC_.js.map → maps-core-gate-CP8SEHH1.js.map} +1 -1
  17. package/dist/_chunks/{practice-results-M5A9-X9y.js → practice-results-DaxGw9_f.js} +762 -748
  18. package/dist/_chunks/practice-results-DaxGw9_f.js.map +1 -0
  19. package/dist/_chunks/{reserved.agent-BBuWWtYb.js → reserved.agent-W8mR179D.js} +2 -2
  20. package/dist/_chunks/{reserved.agent-BBuWWtYb.js.map → reserved.agent-W8mR179D.js.map} +1 -1
  21. package/dist/_chunks/{toolbar-BK6S9PhI.js → toolbar-CfdoJzMV.js} +2 -2
  22. package/dist/_chunks/{toolbar-BK6S9PhI.js.map → toolbar-CfdoJzMV.js.map} +1 -1
  23. package/dist/_chunks/{warehouse-load-summary-DkAKXcw0.js → warehouse-load-summary-CMMYzTDv.js} +75 -66
  24. package/dist/_chunks/warehouse-load-summary-CMMYzTDv.js.map +1 -0
  25. package/dist/agent-catalog.json +34 -11
  26. package/dist/agent-i18n/en.json +6 -4
  27. package/dist/browser-support.js +1 -1
  28. package/dist/components/_shared/decimal.d.ts +2 -0
  29. package/dist/components/_shared/decimal.d.ts.map +1 -1
  30. package/dist/components/address-autocomplete/index.js +1 -1
  31. package/dist/components/address-fields/index.js +1 -1
  32. package/dist/components/bill-line-table/bill-line-table.agent.d.ts.map +1 -1
  33. package/dist/components/bill-line-table/bill-line-table.columns.d.ts +4 -0
  34. package/dist/components/bill-line-table/bill-line-table.columns.d.ts.map +1 -1
  35. package/dist/components/bill-line-table/bill-line-table.d.ts.map +1 -1
  36. package/dist/components/bill-line-table/bill-line-table.header.d.ts +6 -0
  37. package/dist/components/bill-line-table/bill-line-table.header.d.ts.map +1 -1
  38. package/dist/components/bill-line-table/bill-line-table.invoice-cell.d.ts +6 -0
  39. package/dist/components/bill-line-table/bill-line-table.invoice-cell.d.ts.map +1 -0
  40. package/dist/components/bill-line-table/bill-line-table.model.d.ts +23 -10
  41. package/dist/components/bill-line-table/bill-line-table.model.d.ts.map +1 -1
  42. package/dist/components/bill-line-table/bill-line-table.scope.d.ts +56 -0
  43. package/dist/components/bill-line-table/bill-line-table.scope.d.ts.map +1 -0
  44. package/dist/components/bill-line-table/bill-line-table.types.d.ts +90 -10
  45. package/dist/components/bill-line-table/bill-line-table.types.d.ts.map +1 -1
  46. package/dist/components/bill-line-table/bill-line-table.variants.d.ts +2 -0
  47. package/dist/components/bill-line-table/bill-line-table.variants.d.ts.map +1 -1
  48. package/dist/components/bill-line-table/index.d.ts +3 -2
  49. package/dist/components/bill-line-table/index.d.ts.map +1 -1
  50. package/dist/components/bill-line-table/index.js +20 -18
  51. package/dist/components/bill-table/index.js +1 -1
  52. package/dist/components/booking/index.js +1 -1
  53. package/dist/components/data-grid/body.d.ts.map +1 -1
  54. package/dist/components/data-grid/data-grid.d.ts.map +1 -1
  55. package/dist/components/data-grid/data-grid.variants.d.ts.map +1 -1
  56. package/dist/components/data-grid/index.js +2 -2
  57. package/dist/components/data-grid/types.d.ts +6 -0
  58. package/dist/components/data-grid/types.d.ts.map +1 -1
  59. package/dist/components/data-grid/use-data-grid-engine.d.ts.map +1 -1
  60. package/dist/components/invoice-upload-list/index.js +1 -1
  61. package/dist/components/invoice-upload-list/invoice-upload-list.d.ts.map +1 -1
  62. package/dist/components/map-view/index.d.ts +1 -1
  63. package/dist/components/map-view/index.d.ts.map +1 -1
  64. package/dist/components/map-view/index.js +1 -1
  65. package/dist/components/map-view/map-view.agent.d.ts.map +1 -1
  66. package/dist/components/map-view/map-view.d.ts +42 -1
  67. package/dist/components/map-view/map-view.d.ts.map +1 -1
  68. package/dist/components/practice-results/index.js +1 -1
  69. package/dist/components/practice-results/practice-results.d.ts +12 -1
  70. package/dist/components/practice-results/practice-results.d.ts.map +1 -1
  71. package/dist/components/warehouse-load-summary/index.js +1 -1
  72. package/dist/components/warehouse-load-summary/warehouse-load-summary.d.ts.map +1 -1
  73. package/dist/core.css +1 -1
  74. package/dist/decimal/index.js +32 -28
  75. package/dist/decimal/index.js.map +1 -1
  76. package/dist/host-compat.css +7 -1
  77. package/dist/i18n/locales/ar.d.ts +2 -0
  78. package/dist/i18n/locales/ar.d.ts.map +1 -1
  79. package/dist/i18n/locales/ar.js +3 -1
  80. package/dist/i18n/locales/ar.js.map +1 -1
  81. package/dist/i18n/locales/de.d.ts +2 -0
  82. package/dist/i18n/locales/de.d.ts.map +1 -1
  83. package/dist/i18n/locales/de.js +3 -1
  84. package/dist/i18n/locales/de.js.map +1 -1
  85. package/dist/i18n/locales/el.d.ts +2 -0
  86. package/dist/i18n/locales/el.d.ts.map +1 -1
  87. package/dist/i18n/locales/el.js +3 -1
  88. package/dist/i18n/locales/el.js.map +1 -1
  89. package/dist/i18n/locales/en.d.ts +2 -0
  90. package/dist/i18n/locales/en.d.ts.map +1 -1
  91. package/dist/i18n/locales/en.js +3 -1
  92. package/dist/i18n/locales/en.js.map +1 -1
  93. package/dist/i18n/locales/es.d.ts +2 -0
  94. package/dist/i18n/locales/es.d.ts.map +1 -1
  95. package/dist/i18n/locales/es.js +3 -1
  96. package/dist/i18n/locales/es.js.map +1 -1
  97. package/dist/i18n/locales/fr.d.ts +2 -0
  98. package/dist/i18n/locales/fr.d.ts.map +1 -1
  99. package/dist/i18n/locales/fr.js +3 -1
  100. package/dist/i18n/locales/fr.js.map +1 -1
  101. package/dist/i18n/locales/hi.d.ts +2 -0
  102. package/dist/i18n/locales/hi.d.ts.map +1 -1
  103. package/dist/i18n/locales/hi.js +3 -1
  104. package/dist/i18n/locales/hi.js.map +1 -1
  105. package/dist/i18n/locales/it.d.ts +2 -0
  106. package/dist/i18n/locales/it.d.ts.map +1 -1
  107. package/dist/i18n/locales/it.js +3 -1
  108. package/dist/i18n/locales/it.js.map +1 -1
  109. package/dist/i18n/locales/ja.d.ts +2 -0
  110. package/dist/i18n/locales/ja.d.ts.map +1 -1
  111. package/dist/i18n/locales/ja.js +3 -1
  112. package/dist/i18n/locales/ja.js.map +1 -1
  113. package/dist/i18n/locales/nl.d.ts +2 -0
  114. package/dist/i18n/locales/nl.d.ts.map +1 -1
  115. package/dist/i18n/locales/nl.js +3 -1
  116. package/dist/i18n/locales/nl.js.map +1 -1
  117. package/dist/i18n/locales/pl.d.ts +2 -0
  118. package/dist/i18n/locales/pl.d.ts.map +1 -1
  119. package/dist/i18n/locales/pl.js +3 -1
  120. package/dist/i18n/locales/pl.js.map +1 -1
  121. package/dist/i18n/locales/pt.d.ts +2 -0
  122. package/dist/i18n/locales/pt.d.ts.map +1 -1
  123. package/dist/i18n/locales/pt.js +3 -1
  124. package/dist/i18n/locales/pt.js.map +1 -1
  125. package/dist/i18n/locales/ro.d.ts +2 -0
  126. package/dist/i18n/locales/ro.d.ts.map +1 -1
  127. package/dist/i18n/locales/ro.js +3 -1
  128. package/dist/i18n/locales/ro.js.map +1 -1
  129. package/dist/i18n/locales/ru.d.ts +2 -0
  130. package/dist/i18n/locales/ru.d.ts.map +1 -1
  131. package/dist/i18n/locales/ru.js +3 -1
  132. package/dist/i18n/locales/ru.js.map +1 -1
  133. package/dist/i18n/locales/sq.d.ts +2 -0
  134. package/dist/i18n/locales/sq.d.ts.map +1 -1
  135. package/dist/i18n/locales/sq.js +3 -1
  136. package/dist/i18n/locales/sq.js.map +1 -1
  137. package/dist/i18n/locales/sv.d.ts +2 -0
  138. package/dist/i18n/locales/sv.d.ts.map +1 -1
  139. package/dist/i18n/locales/sv.js +3 -1
  140. package/dist/i18n/locales/sv.js.map +1 -1
  141. package/dist/i18n/locales/tr.d.ts +2 -0
  142. package/dist/i18n/locales/tr.d.ts.map +1 -1
  143. package/dist/i18n/locales/tr.js +3 -1
  144. package/dist/i18n/locales/tr.js.map +1 -1
  145. package/dist/i18n/locales/zh.d.ts +2 -0
  146. package/dist/i18n/locales/zh.d.ts.map +1 -1
  147. package/dist/i18n/locales/zh.js +3 -1
  148. package/dist/i18n/locales/zh.js.map +1 -1
  149. package/dist/index.js +1062 -1060
  150. package/dist/locales/ar.json +3 -1
  151. package/dist/locales/de.json +3 -1
  152. package/dist/locales/el.json +3 -1
  153. package/dist/locales/en.json +3 -1
  154. package/dist/locales/es.json +3 -1
  155. package/dist/locales/fr.json +3 -1
  156. package/dist/locales/hi.json +3 -1
  157. package/dist/locales/it.json +3 -1
  158. package/dist/locales/ja.json +3 -1
  159. package/dist/locales/nl.json +3 -1
  160. package/dist/locales/pl.json +3 -1
  161. package/dist/locales/pt.json +3 -1
  162. package/dist/locales/ro.json +3 -1
  163. package/dist/locales/ru.json +3 -1
  164. package/dist/locales/sq.json +3 -1
  165. package/dist/locales/sv.json +3 -1
  166. package/dist/locales/tr.json +3 -1
  167. package/dist/locales/zh.json +3 -1
  168. package/dist/tokens.css +1 -1
  169. package/package.json +1 -1
  170. package/dist/_chunks/bill-line-table-CzYzg-Qh.js +0 -1757
  171. package/dist/_chunks/bill-line-table-CzYzg-Qh.js.map +0 -1
  172. package/dist/_chunks/data-grid-C9xlUMLt.js.map +0 -1
  173. package/dist/_chunks/map-view-DkL58SRp.js +0 -1613
  174. package/dist/_chunks/map-view-DkL58SRp.js.map +0 -1
  175. package/dist/_chunks/practice-results-M5A9-X9y.js.map +0 -1
  176. package/dist/_chunks/warehouse-load-summary-DkAKXcw0.js.map +0 -1
@@ -0,0 +1,2000 @@
1
+ import { jsxs as w, jsx as l, Fragment as ot } from "react/jsx-runtime";
2
+ import { createContext as Jt, useContext as we, useRef as A, useLayoutEffect as Kn, useMemo as E, forwardRef as Pn, useEffect as Ae, useState as qe, useCallback as B, useImperativeHandle as $n, useId as Fn } from "react";
3
+ import { useTranslation as Pe } from "react-i18next";
4
+ import { u as zn } from "./registry-DvAUVLHh.js";
5
+ import { e as Yn } from "./data-grid-B2oaI7Lt.js";
6
+ import { a as K } from "./format-number-DdzqwMs1.js";
7
+ import { i as Vt } from "./is-development-CLUAnsU7.js";
8
+ import { B as st } from "./badge-BUk4RjTS.js";
9
+ import { f as Qn } from "./intl-locale-FWh-Y5_3.js";
10
+ import { p as Wn } from "./privacy-mask-text-B8YfzB7L.js";
11
+ import { V as $e } from "./visually-hidden-BHxEUGyT.js";
12
+ import { c as x } from "./index-D2ZczOXr.js";
13
+ import { a as jn } from "./compact-editor-fields-cP6yh7xv.js";
14
+ import { E as Hn } from "./eye-off-C_4xkbRP.js";
15
+ import { C as Gn } from "./combobox-BBCVQS-S.js";
16
+ import { M as Xn } from "./money-OE6_oDPH.js";
17
+ import { divideDecimal as Zn, formatDecimal as ae, multiplyDecimal as Jn, sumDecimals as Ue, parseDecimal as fe, FATTURAPA_VALUE as pe, compareDecimal as Ne, decimalToNumber as Fe, negateDecimal as en, rescaleDecimal as tn, numberToDecimal as ei, shiftDecimal as ti } from "../decimal/index.js";
18
+ import { W as be, a as ni } from "./maps-MpMxTBov.js";
19
+ import { C as ii } from "./check-DrFSN__t.js";
20
+ import { P as ri } from "./plus-DzMQ_c6b.js";
21
+ import { A as ai } from "./arrow-right-KsIrLdt0.js";
22
+ import { C as li } from "./circle-alert-rGDZ73Wh.js";
23
+ import { T as oi } from "./triangle-alert-CBnO6nq_.js";
24
+ function Bt(e, t) {
25
+ throw new Error(`${e}: ${t}`);
26
+ }
27
+ const si = "^[0-9]{1,8}([.][0-9]{1,8})?$", Ie = { type: "string", minLength: 1 }, Ve = "{ id, invoiceId, sourceLineId, lineNumber, matchState, selected, selectable, readOnly, quantityLocked, itemKind, itemId, quantity, removesStock, warningCodes, invalid }", ci = {
28
+ id: "bill-line-table",
29
+ // select_multiple: ticks. set_value: a line's quantity and its item
30
+ // (whole-value assignment to a NumberInput and a Combobox, 26 section 4).
31
+ // scroll: focus_line. No `confirm`: loading is the host's.
32
+ capabilities: ["select_multiple", "set_value", "scroll"],
33
+ state: {
34
+ lines: {
35
+ type: `Array<${Ve}>`,
36
+ descriptionKey: "ui.agent.billLineTable.state.lines",
37
+ description: "Every invoice line in invoice order, with what Confirm will do with it. matchState is one of matched, newItem, itemToUpdate (a matched line whose price, VAT or discount will change; counted inside matchedCount), skip or alreadyLoaded. Quantities are exact decimal text as shown, unsigned; there are no descriptions or names. With several invoices (the invoices prop) id is the row key built from invoiceId and the line id, invoiceId names the invoice and sourceLineId is the host's own line id; every lineId argument below is a row key.",
38
+ read: (e) => e.getLines()
39
+ },
40
+ selection: {
41
+ type: "string[]",
42
+ descriptionKey: "ui.agent.billLineTable.state.selection",
43
+ description: "Ids (row keys with several invoices) of the ticked lines: the lines Confirm will load.",
44
+ read: (e) => e.getSelection()
45
+ },
46
+ summary: {
47
+ type: "{ lineCount, invoiceCount, selectedInvoiceCount, selectedCount, matchedCount, newItemCount, itemUpdateCount, skippedCount, alreadyLoadedCount, warningLineCount, invoiceLoaded, invalidCount, net, vat, gross, canConfirm, dirty }",
48
+ descriptionKey: "ui.agent.billLineTable.state.summary",
49
+ description: 'Counts and totals of the ticked lines. net, vat and gross are exact decimal text with 2 places ("14.58"). canConfirm is false while no line is ticked, a ticked line cannot load, or every invoice is already loaded (invoiceLoaded). With several invoices the counts cover the invoices still open, and a credit note counts against net, vat and gross.',
50
+ read: (e) => e.getSummary()
51
+ },
52
+ invalidLineIds: {
53
+ type: "string[]",
54
+ descriptionKey: "ui.agent.billLineTable.state.invalidLineIds",
55
+ description: "Ticked lines that cannot load as they are: an empty or zero quantity, an item no longer in the warehouse, or an error from the server.",
56
+ read: (e) => e.getInvalidLineIds()
57
+ }
58
+ },
59
+ actions: {
60
+ select_lines: {
61
+ safety: "write",
62
+ idempotent: !0,
63
+ argsType: "{ ids: string[]; mode?: 'replace' | 'add' | 'remove' }",
64
+ argsSchema: {
65
+ type: "object",
66
+ properties: {
67
+ ids: { type: "array", items: Ie, uniqueItems: !0 },
68
+ mode: { type: "string", enum: ["replace", "add", "remove"] }
69
+ },
70
+ required: ["ids"],
71
+ additionalProperties: !1
72
+ },
73
+ returns: "string[]",
74
+ errors: ["UNKNOWN_LINE", "LINE_READ_ONLY", "TABLE_READ_ONLY"],
75
+ examples: [{ args: { ids: ["ln-3", "ln-4"], mode: "add" } }],
76
+ descriptionKey: "ui.agent.billLineTable.actions.selectLines",
77
+ description: "Tick or untick lines. Lines of an invoice that is already loaded cannot be ticked. Returns the ticked ids.",
78
+ invoke: (e, t) => {
79
+ for (const a of t.ids)
80
+ e.getLine(a) || Bt("UNKNOWN_LINE", `no line "${a}".`);
81
+ const n = e.getSelection(), r = t.mode ?? "replace", i = r === "replace" ? t.ids : r === "add" ? [...n, ...t.ids] : n.filter((a) => !t.ids.includes(a));
82
+ return e.setSelection(i), e.getSelection();
83
+ }
84
+ },
85
+ select_all_lines: {
86
+ safety: "write",
87
+ idempotent: !0,
88
+ returns: "string[]",
89
+ errors: ["TABLE_READ_ONLY"],
90
+ descriptionKey: "ui.agent.billLineTable.actions.selectAllLines",
91
+ description: "Tick every line that can load. Returns the ticked ids.",
92
+ invoke: (e) => (e.selectAll(), e.getSelection())
93
+ },
94
+ clear_selection: {
95
+ safety: "write",
96
+ idempotent: !0,
97
+ returns: "string[]",
98
+ errors: ["TABLE_READ_ONLY"],
99
+ descriptionKey: "ui.agent.billLineTable.actions.clearSelection",
100
+ description: "Untick every line.",
101
+ invoke: (e) => (e.clearSelection(), e.getSelection())
102
+ },
103
+ set_quantity: {
104
+ safety: "write",
105
+ idempotent: !0,
106
+ argsType: "{ lineId: string; quantity: string }",
107
+ argsSchema: {
108
+ type: "object",
109
+ properties: {
110
+ lineId: Ie,
111
+ quantity: { type: "string", pattern: si }
112
+ },
113
+ required: ["lineId", "quantity"],
114
+ additionalProperties: !1
115
+ },
116
+ returns: Ve,
117
+ errors: [
118
+ "UNKNOWN_LINE",
119
+ "INVALID_QUANTITY",
120
+ "TABLE_READ_ONLY",
121
+ "LINE_READ_ONLY"
122
+ ],
123
+ examples: [
124
+ { args: { lineId: "ln-2", quantity: "2.5" } },
125
+ {
126
+ args: { lineId: "ln-7", quantity: "3" },
127
+ note: "On a credit note this removes 3 from stock."
128
+ }
129
+ ],
130
+ descriptionKey: "ui.agent.billLineTable.actions.setQuantity",
131
+ description: "Set the quantity of a line as shown in the table: a decimal above 0 and at most 10000000, with a dot and up to 8 places, never signed. On a credit note it is the quantity to remove. The line amount stays as invoiced. Does not tick the line.",
132
+ invoke: (e, t) => (e.setQuantity(t.lineId, t.quantity), e.getLine(t.lineId))
133
+ },
134
+ set_item: {
135
+ safety: "write",
136
+ idempotent: !0,
137
+ argsType: "{ lineId: string; itemId: string }",
138
+ argsSchema: {
139
+ type: "object",
140
+ properties: {
141
+ lineId: Ie,
142
+ itemId: { type: "string", minLength: 1 }
143
+ },
144
+ required: ["lineId", "itemId"],
145
+ additionalProperties: !1
146
+ },
147
+ returns: Ve,
148
+ errors: [
149
+ "UNKNOWN_LINE",
150
+ "UNKNOWN_ITEM",
151
+ "TABLE_READ_ONLY",
152
+ "LINE_READ_ONLY"
153
+ ],
154
+ descriptionKey: "ui.agent.billLineTable.actions.setItem",
155
+ description: "Load a line into an existing warehouse item, by item id. Does not tick the line.",
156
+ invoke: (e, t) => (e.setItem(t.lineId, { kind: "existing", itemId: t.itemId }), e.getLine(t.lineId))
157
+ },
158
+ create_new_item: {
159
+ safety: "write",
160
+ idempotent: !0,
161
+ argsType: "{ lineId: string; name?: string }",
162
+ argsSchema: {
163
+ type: "object",
164
+ properties: {
165
+ lineId: Ie,
166
+ // DoctorInventoryItem.name is a string of 255.
167
+ name: { type: "string", minLength: 1, maxLength: 255 }
168
+ },
169
+ required: ["lineId"],
170
+ additionalProperties: !1
171
+ },
172
+ returns: Ve,
173
+ errors: [
174
+ "UNKNOWN_LINE",
175
+ "INVALID_ARGS",
176
+ "TABLE_READ_ONLY",
177
+ "LINE_READ_ONLY"
178
+ ],
179
+ descriptionKey: "ui.agent.billLineTable.actions.createNewItem",
180
+ description: "Mark a line to create a new warehouse item when the invoice is loaded. Without a name, the item takes the line description. Nothing is created until Confirm. Does not tick the line.",
181
+ invoke: (e, t) => {
182
+ var r;
183
+ const n = (r = t.name) == null ? void 0 : r.trim();
184
+ return t.name !== void 0 && !n && Bt("INVALID_ARGS", "name is empty."), e.setItem(t.lineId, { kind: "new", name: n ?? "" }), e.getLine(t.lineId);
185
+ }
186
+ },
187
+ focus_line: {
188
+ safety: "read",
189
+ idempotent: !0,
190
+ argsType: "{ lineId: string; field?: 'select' | 'quantity' | 'item' }",
191
+ argsSchema: {
192
+ type: "object",
193
+ properties: {
194
+ lineId: Ie,
195
+ field: { type: "string", enum: ["select", "quantity", "item"] }
196
+ },
197
+ required: ["lineId"],
198
+ additionalProperties: !1
199
+ },
200
+ errors: ["UNKNOWN_LINE"],
201
+ descriptionKey: "ui.agent.billLineTable.actions.focusLine",
202
+ description: "Scroll a line into view and move focus to its checkbox, quantity or item field.",
203
+ invoke: (e, t) => {
204
+ e.focusLine(t.lineId, t.field);
205
+ }
206
+ }
207
+ },
208
+ domHooks: {
209
+ root: {
210
+ attr: "data-component",
211
+ value: "bill-line-table",
212
+ description: "Marks the element as a kit BillLineTable."
213
+ },
214
+ instanceId: {
215
+ attr: "data-component-id",
216
+ sourceProp: "gridId",
217
+ description: "The agent instance id."
218
+ },
219
+ item: {
220
+ attr: "data-row-id",
221
+ sourceProp: "lines[].id",
222
+ description: "BillLine.id on each body row (written by DataGrid), or the row key with several invoices. The only line datum in the DOM."
223
+ }
224
+ }
225
+ }, ui = x("ds:flex ds:min-w-0 ds:flex-col", {
226
+ variants: {
227
+ height: {
228
+ auto: "",
229
+ fill: "ds:min-h-0 ds:flex-1"
230
+ }
231
+ },
232
+ defaultVariants: { height: "fill" }
233
+ }), di = x([
234
+ "ds:w-full ds:min-w-0",
235
+ jn
236
+ ]), ze = x("ds:flex ds:flex-col", {
237
+ variants: {
238
+ align: {
239
+ start: "ds:items-start",
240
+ end: "ds:items-end"
241
+ }
242
+ },
243
+ defaultVariants: { align: "start" }
244
+ }), he = x(
245
+ "type-body-sm ds:text-[color:var(--muted-foreground)]"
246
+ ), ct = x(
247
+ "ds:m-0 ds:flex ds:list-none ds:flex-col ds:gap-[var(--spacing-2xs)] ds:p-0",
248
+ {
249
+ variants: {
250
+ align: {
251
+ start: "ds:items-start",
252
+ end: "ds:items-end"
253
+ }
254
+ },
255
+ defaultVariants: { align: "start" }
256
+ }
257
+ ), Ye = x("ds:tabular-nums"), mi = x(
258
+ "ds:flex ds:items-start ds:gap-[var(--spacing-xs)]"
259
+ ), Rt = x(
260
+ "ds:mt-[var(--spacing-2xs)] ds:size-4 ds:shrink-0",
261
+ {
262
+ variants: {
263
+ severity: {
264
+ warning: "ds:text-[color:var(--warning-foreground)]",
265
+ error: "ds:text-[color:var(--error-foreground)]"
266
+ }
267
+ },
268
+ defaultVariants: { severity: "warning" }
269
+ }
270
+ ), fi = x("ds:text-[color:var(--foreground)]"), pi = x(
271
+ "ds:m-0 ds:grid ds:grid-cols-1 ds:justify-items-end ds:text-end"
272
+ ), Dt = x(
273
+ "type-meta ds:text-[color:var(--muted-foreground)]"
274
+ ), Mt = x(
275
+ "ds:m-0 ds:[&:not(:last-child)]:mb-[var(--spacing-2xs)]"
276
+ ), hi = x(
277
+ "ds:flex ds:flex-wrap ds:items-baseline ds:justify-end ds:gap-x-[var(--spacing-xs)]"
278
+ ), vi = x(
279
+ "ds:inline ds:size-3 ds:align-middle ds:rtl:-scale-x-100"
280
+ ), gi = x("ds:tabular-nums type-body-sm"), yi = x(
281
+ "ds:m-0 ds:flex ds:shrink-0 ds:flex-wrap ds:gap-x-[var(--spacing-lg)] ds:gap-y-[var(--spacing-sm)] ds:pb-[var(--spacing-md)]"
282
+ ), Be = x(
283
+ "type-meta ds:text-[color:var(--muted-foreground)]"
284
+ ), Re = x(
285
+ "ds:m-0 ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:text-[color:var(--foreground)]"
286
+ ), Li = x(
287
+ "ds:flex ds:items-center ds:gap-[var(--spacing-xs)] ds:[font-weight:var(--font-weight-semibold)] ds:text-[color:var(--foreground)]"
288
+ ), Ut = /* @__PURE__ */ new Map(), bi = /^(\d{4})-(\d{2})-(\d{2})$/;
289
+ function nn(e, t) {
290
+ const n = bi.exec(e);
291
+ if (!n) return e;
292
+ const r = new Date(
293
+ Date.UTC(Number(n[1]), Number(n[2]) - 1, Number(n[3]))
294
+ );
295
+ if (Number.isNaN(r.getTime())) return e;
296
+ const i = Qn(t);
297
+ let a = Ut.get(i);
298
+ return a || (a = new Intl.DateTimeFormat(i, {
299
+ dateStyle: "medium",
300
+ timeZone: "UTC"
301
+ }), Ut.set(i, a)), a.format(r);
302
+ }
303
+ function rn({
304
+ invoice: e,
305
+ privacyMode: t
306
+ }) {
307
+ const { t: n } = Pe("ui");
308
+ return t && e.supplier.kind === "person" ? /* @__PURE__ */ w(ot, { children: [
309
+ /* @__PURE__ */ l(Hn, { "aria-hidden": "true", className: "ds:size-4 ds:shrink-0" }),
310
+ /* @__PURE__ */ l($e, { children: n("billLineTable.header.supplierHidden", "Name hidden") }),
311
+ /* @__PURE__ */ l("span", { "aria-hidden": "true", children: Wn() })
312
+ ] }) : /* @__PURE__ */ l("span", { dir: "auto", children: e.supplier.name });
313
+ }
314
+ function Ii({
315
+ invoice: e,
316
+ privacyMode: t
317
+ }) {
318
+ const { t: n, i18n: r } = Pe("ui");
319
+ return /* @__PURE__ */ w(
320
+ "dl",
321
+ {
322
+ className: yi(),
323
+ "data-component": "bill-line-invoice-header",
324
+ "data-part": "invoice-header",
325
+ children: [
326
+ /* @__PURE__ */ w("div", { children: [
327
+ /* @__PURE__ */ l("dt", { className: Be(), children: n("billLineTable.header.supplier", "Supplier") }),
328
+ /* @__PURE__ */ l("dd", { className: Re(), children: /* @__PURE__ */ l(rn, { invoice: e, privacyMode: t }) })
329
+ ] }),
330
+ /* @__PURE__ */ w("div", { children: [
331
+ /* @__PURE__ */ l("dt", { className: Be(), children: n("billLineTable.header.number", "Invoice number") }),
332
+ /* @__PURE__ */ l("dd", { className: Re(), children: /* @__PURE__ */ l("span", { dir: "auto", children: e.number }) })
333
+ ] }),
334
+ /* @__PURE__ */ w("div", { children: [
335
+ /* @__PURE__ */ l("dt", { className: Be(), children: n("billLineTable.header.date", "Date") }),
336
+ /* @__PURE__ */ l("dd", { className: Re(), children: nn(e.date, r.language) })
337
+ ] }),
338
+ /* @__PURE__ */ w("div", { children: [
339
+ /* @__PURE__ */ l("dt", { className: Be(), children: n("billLineTable.header.source", "Source") }),
340
+ /* @__PURE__ */ l("dd", { className: Re(), children: /* @__PURE__ */ l(st, { size: "sm", variant: "neutral", children: e.source === "sdi" ? n("billLineTable.header.sourceSdi", "SDI") : n("billLineTable.header.sourceUpload", "Upload") }) })
341
+ ] })
342
+ ]
343
+ }
344
+ );
345
+ }
346
+ function an(e, t) {
347
+ return e === void 0 ? t : `${e.length}:${e}:${t}`;
348
+ }
349
+ const Kt = /* @__PURE__ */ new WeakMap();
350
+ function Ti(e, t) {
351
+ if (t === e.id) return e;
352
+ const n = Kt.get(e);
353
+ if (n && n.id === t) return n;
354
+ const r = { ...e, id: t };
355
+ return Kt.set(e, r), r;
356
+ }
357
+ function wi(e, t) {
358
+ if (t === void 0) return { lines: e, sources: /* @__PURE__ */ new Map() };
359
+ const n = /* @__PURE__ */ new Map();
360
+ return { lines: e.map((i) => {
361
+ const a = an(i.invoiceId, i.id);
362
+ return n.has(a) || n.set(a, { invoiceId: i.invoiceId, lineId: i.id }), Ti(i, a);
363
+ }), sources: n };
364
+ }
365
+ const Ni = /* @__PURE__ */ new Map(), Pt = /* @__PURE__ */ new Set();
366
+ function ln(e, t, n, r = Ni) {
367
+ var O;
368
+ const i = t !== void 0, a = new Map(
369
+ (t ?? []).map((h) => [h.id, h])
370
+ ), c = (h) => i ? h.invoiceId : void 0, v = (h) => {
371
+ const p = c(h);
372
+ return p === void 0 ? null : a.get(p) ?? null;
373
+ }, d = (h) => {
374
+ var p;
375
+ return ((p = v(h)) == null ? void 0 : p.documentKind) ?? n;
376
+ }, m = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set();
377
+ let N = null;
378
+ for (const h of e) {
379
+ const p = c(h);
380
+ m.add(p), h.alreadyLoaded && I.add(p), i && (N === null || N.group !== p) && g.add(h.id), N = { group: p };
381
+ }
382
+ const _ = (O = e[0]) == null ? void 0 : O.id, b = new Set(g);
383
+ return _ !== void 0 && b.delete(_), {
384
+ multi: i,
385
+ allLoaded: m.size > 0 && [...m].every((h) => I.has(h)),
386
+ invoiceCount: m.size,
387
+ isLoaded: (h) => I.has(c(h)),
388
+ kindOf: d,
389
+ invoiceOf: v,
390
+ groupOf: c,
391
+ signOf: (h) => i && d(h) === "creditNote" ? -1 : 1,
392
+ invoiceStarts: i ? g : Pt,
393
+ groupStarts: i ? b : Pt,
394
+ sourceOf: (h) => r.get(h) ?? { invoiceId: void 0, lineId: h }
395
+ };
396
+ }
397
+ function ve(e, t = "invoice") {
398
+ return ln(e, void 0, t);
399
+ }
400
+ function ki(e, t) {
401
+ const n = [], r = new Set(t.map((_) => _.id)), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set();
402
+ let c, v = !1;
403
+ const d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set();
404
+ for (const _ of e) {
405
+ const b = _.invoiceId;
406
+ b === void 0 ? m.add(_.id) : r.has(b) || d.add(b);
407
+ const O = an(b, _.id);
408
+ i.has(O) && I.add(O), i.add(O), /\s/.test(O) && N.add(b ?? _.id), v && b !== c && a.add(c), a.has(b) && g.add(b ?? "(none)"), c = b, v = !0;
409
+ }
410
+ return d.size > 0 && n.push(
411
+ `lines refer to invoices that are not in "invoices": ${[...d].join(", ")}.`
412
+ ), m.size > 0 && n.push(
413
+ `lines have no invoiceId, so getLoadPayloadByInvoice leaves them out: ${[...m].join(", ")}.`
414
+ ), I.size > 0 && n.push(
415
+ `two lines have the same invoiceId and id: ${[...I].join(", ")}.`
416
+ ), g.size > 0 && n.push(
417
+ `the lines of an invoice are not next to each other: ${[...g].join(", ")}. The table never reorders them.`
418
+ ), N.size > 0 && n.push(
419
+ `an invoice id or a line id holds white space, which the row names need to be free of: ${[...N].join(", ")}.`
420
+ ), n;
421
+ }
422
+ const de = 8, Ke = 8, Si = 2, ke = 1e7, $t = 255, me = "bill-line-table:new-item", on = "quantityTooLarge", Te = { units: 0, scale: 0 }, sn = { units: ke, scale: 0 }, xi = {
423
+ ...pe.quantity,
424
+ allowNegative: !0
425
+ };
426
+ function Qe(e) {
427
+ let { units: t, scale: n } = e;
428
+ for (; n > 0 && t % 10 === 0; )
429
+ t /= 10, n -= 1;
430
+ return { units: t || 0, scale: n };
431
+ }
432
+ function at(e) {
433
+ return { units: Math.abs(e.units), scale: e.scale };
434
+ }
435
+ function P(e) {
436
+ const t = {
437
+ empty: !0,
438
+ wellFormed: !1,
439
+ positive: !1,
440
+ value: null,
441
+ editorNumber: null
442
+ };
443
+ if (e === null || e.trim() === "") return t;
444
+ const n = fe(e, xi);
445
+ if (n.ok) {
446
+ const r = Fe(n.value);
447
+ return {
448
+ empty: !1,
449
+ wellFormed: !0,
450
+ positive: n.value.units > 0,
451
+ value: n.value,
452
+ editorNumber: r !== null && Math.abs(r) <= ke ? r : null
453
+ };
454
+ }
455
+ return n.error === "unsafe" ? {
456
+ empty: !1,
457
+ wellFormed: !0,
458
+ positive: !e.trim().startsWith("-"),
459
+ value: null,
460
+ editorNumber: null
461
+ } : { ...t, empty: !1 };
462
+ }
463
+ function ut(e) {
464
+ const t = P(e);
465
+ return !t.wellFormed || t.editorNumber !== null;
466
+ }
467
+ function _i(e) {
468
+ const t = ei(e, de);
469
+ return t ? ae(Qe(t)) : null;
470
+ }
471
+ function Z(e) {
472
+ const t = fe(e, pe.lineTotal);
473
+ return t.ok ? t.value : null;
474
+ }
475
+ function cn(e) {
476
+ if (e === null) return null;
477
+ const t = fe(e, pe.rate);
478
+ return t.ok ? t.value : null;
479
+ }
480
+ function Ci(e, t) {
481
+ const n = Z(e), r = P(t).value;
482
+ if (!n || !r || r.units === 0) return null;
483
+ const i = Zn(n, r, Ke);
484
+ return i ? ae(Qe(i)) : null;
485
+ }
486
+ function Ei(e, t) {
487
+ const n = Z(e), r = Z(t);
488
+ return !n || !r ? e.trim() === t.trim() : Ne(at(n), at(r)) === 0;
489
+ }
490
+ function J(e) {
491
+ const t = e.trim(), n = Array.from(t);
492
+ return n.length > $t ? n.slice(0, $t).join("").trim() : t;
493
+ }
494
+ function lt(e, t) {
495
+ if (e.kind === "existing")
496
+ return { kind: "existing", itemId: e.itemId };
497
+ const n = J(e.name);
498
+ return {
499
+ kind: "new",
500
+ name: n === "" ? J(t.description) : n
501
+ };
502
+ }
503
+ function Oi(e) {
504
+ const t = P(e);
505
+ return t.wellFormed ? t.value === null ? !0 : Ne(at(t.value), sn) > 0 : !1;
506
+ }
507
+ function un(e, t) {
508
+ return Oi(t.quantity) && !fn(t.quantity, e.quantity);
509
+ }
510
+ function dn(e) {
511
+ return e.item.kind === "new" && J(e.item.name) === "";
512
+ }
513
+ function Ai(e, t) {
514
+ if (t.item.kind !== "new") return !1;
515
+ const n = J(t.item.name);
516
+ return n !== "" && n === J(e.description);
517
+ }
518
+ function Rr(e) {
519
+ return e.some((t) => t.alreadyLoaded);
520
+ }
521
+ function X(e) {
522
+ return {
523
+ quantity: e.quantity,
524
+ item: e.proposal === "existing" && e.proposedItemId !== null ? { kind: "existing", itemId: e.proposedItemId } : { kind: "new", name: J(e.description) }
525
+ };
526
+ }
527
+ function Dr(e) {
528
+ const t = {};
529
+ for (const n of e) t[n.id] = X(n);
530
+ return t;
531
+ }
532
+ function it(e, t = ve(e)) {
533
+ return e.filter((n) => !t.isLoaded(n) && n.proposal !== "skip").map((n) => n.id);
534
+ }
535
+ function Ft(e, t) {
536
+ const n = {};
537
+ for (const r of e)
538
+ n[r.id] = t[r.id] ?? X(r);
539
+ return n;
540
+ }
541
+ function G(e, t, n = ve(e)) {
542
+ if (t.length === 0) return [];
543
+ const r = new Set(t);
544
+ return e.filter((i) => r.has(i.id) && !n.isLoaded(i)).map((i) => i.id);
545
+ }
546
+ function mn(e, t) {
547
+ return e.kind === "existing" ? t.kind === "existing" && e.itemId === t.itemId : t.kind === "new" && J(e.name) === J(t.name);
548
+ }
549
+ function fn(e, t) {
550
+ if (e === t) return !0;
551
+ if (e === null || t === null) return !1;
552
+ const n = P(e).value, r = P(t).value;
553
+ return n && r ? Ne(n, r) === 0 : e.trim() === t.trim();
554
+ }
555
+ function pn(e, t) {
556
+ return fn(e.quantity, t.quantity) && mn(e.item, t.item);
557
+ }
558
+ function qi(e, t, n) {
559
+ return e.alreadyLoaded ? "alreadyLoaded" : n ? t.item.kind !== "existing" ? "newItem" : dt(e, t) ? "itemToUpdate" : "matched" : "skip";
560
+ }
561
+ function Me(e) {
562
+ if (!e || e.from === e.to) return !1;
563
+ if (e.from === null || e.to === null) return !0;
564
+ const t = fe(e.from, pe.lineTotal), n = fe(e.to, pe.lineTotal);
565
+ return t.ok && n.ok ? Ne(t.value, n.value) !== 0 : !0;
566
+ }
567
+ function Vi(e) {
568
+ const t = e.itemUpdate;
569
+ return t ? Me(t.unitPrice) || Me(t.vatRate) || Me(t.discountPercent) : !1;
570
+ }
571
+ function dt(e, t) {
572
+ return t.item.kind === "existing" && e.proposal === "existing" && t.item.itemId === e.proposedItemId && Vi(e);
573
+ }
574
+ function mt(e, t, n = !0) {
575
+ const r = P(t.quantity);
576
+ return !r.wellFormed || !r.positive || un(e, t) || !Z(e.lineTotal) || t.item.kind === "existing" && !n || dn(t) ? !0 : e.warnings.some((i) => i.severity === "error");
577
+ }
578
+ const ft = () => !0;
579
+ function hn(e, t) {
580
+ return e.item.kind !== "existing" || t(e.item.itemId);
581
+ }
582
+ function zt(e) {
583
+ const t = Ue(e);
584
+ if (t) return t;
585
+ const n = [];
586
+ for (const r of e) {
587
+ const i = tn(r, 2);
588
+ i && n.push(i);
589
+ }
590
+ return Ue(n) ?? Te;
591
+ }
592
+ function De(e) {
593
+ return tn(e, 2) ?? Te;
594
+ }
595
+ const rt = (e) => ae(e, 2);
596
+ function Bi(e, t) {
597
+ return t === -1 ? en(e) : e;
598
+ }
599
+ function Yt(e, t, n, r, i = ft, a = ve(e)) {
600
+ const c = new Set(G(e, n, a)), v = /* @__PURE__ */ new Set();
601
+ let d = 0, m = 0, I = 0, g = 0, N = 0, _ = 0, b = 0, O = 0;
602
+ const h = [], p = /* @__PURE__ */ new Map();
603
+ for (const y of e) {
604
+ const j = t[y.id] ?? X(y);
605
+ if ((y.warnings.length > 0 || !ut(y.quantity)) && (b += 1), y.alreadyLoaded) {
606
+ _ += 1;
607
+ continue;
608
+ }
609
+ if (!c.has(y.id)) {
610
+ N += 1;
611
+ continue;
612
+ }
613
+ d += 1, v.add(a.groupOf(y)), j.item.kind === "existing" ? (m += 1, dt(y, j) && (g += 1)) : I += 1, mt(y, j, hn(j, i)) && (O += 1);
614
+ const oe = Z(y.lineTotal);
615
+ if (!oe) continue;
616
+ const k = Bi(oe, a.signOf(y));
617
+ h.push(k);
618
+ const ge = cn(y.vatPercent);
619
+ if (ge) {
620
+ const te = `${a.groupOf(y) ?? ""}|${ae(Qe(ge))}`, se = p.get(te);
621
+ se ? se.amounts.push(k) : p.set(te, { rate: ge, amounts: [k] });
622
+ }
623
+ }
624
+ const Y = De(zt(h)), Q = [];
625
+ for (const y of p.values()) {
626
+ const j = {
627
+ units: y.rate.units,
628
+ scale: y.rate.scale + 2
629
+ }, oe = De(zt(y.amounts));
630
+ Q.push(Jn(oe, j, 2) ?? Te);
631
+ }
632
+ const V = Ue(Q) ?? Te, le = Ue([Y, V]) ?? Te, W = G(
633
+ e,
634
+ r.selection,
635
+ a
636
+ ), xe = W.length !== c.size || W.some((y) => !c.has(y)) || e.some(
637
+ (y) => !pn(
638
+ t[y.id] ?? X(y),
639
+ r.values[y.id] ?? X(y)
640
+ )
641
+ );
642
+ return {
643
+ lineCount: e.length,
644
+ invoiceCount: a.invoiceCount,
645
+ selectedInvoiceCount: v.size,
646
+ selectedCount: d,
647
+ matchedCount: m,
648
+ newItemCount: I,
649
+ itemUpdateCount: g,
650
+ skippedCount: N,
651
+ alreadyLoadedCount: _,
652
+ warningLineCount: b,
653
+ invoiceLoaded: a.allLoaded,
654
+ invalidCount: O,
655
+ net: rt(Y),
656
+ vat: rt(De(V)),
657
+ gross: rt(De(le)),
658
+ canConfirm: d > 0 && O === 0,
659
+ dirty: xe
660
+ };
661
+ }
662
+ function Ri(e) {
663
+ const t = P(e).value;
664
+ return t ? ae(t) : e.trim();
665
+ }
666
+ function vn(e, t, n, r, i) {
667
+ const a = new Set(G(e, n, i)), c = [], v = [];
668
+ for (const d of e) {
669
+ if (!a.has(d.id)) continue;
670
+ const m = t[d.id] ?? X(d);
671
+ if (m.quantity === null || mt(d, m, hn(m, r))) {
672
+ v.push(d.id);
673
+ continue;
674
+ }
675
+ const I = Ri(m.quantity), g = {
676
+ lineId: d.id,
677
+ quantity: i.kindOf(d) === "creditNote" ? `-${I}` : I,
678
+ item: lt(m.item, d)
679
+ };
680
+ dt(d, m) && (g.updateItem = !0), c.push({ line: d, entry: g });
681
+ }
682
+ return { entries: c, invalidLineIds: v };
683
+ }
684
+ function Di(e, t, n, r, i = ft, a = ve(e, r)) {
685
+ if (a.allLoaded) return { ok: !1, invalidLineIds: [] };
686
+ const { entries: c, invalidLineIds: v } = vn(
687
+ e,
688
+ t,
689
+ n,
690
+ i,
691
+ a
692
+ );
693
+ return v.length > 0 ? { ok: !1, invalidLineIds: v } : { ok: !0, lines: c.map(({ entry: d }) => d) };
694
+ }
695
+ function Mi(e, t, n, r, i = ft, a = ve(e, r)) {
696
+ if (a.allLoaded) return { ok: !1, invalidLineIds: [] };
697
+ const { entries: c, invalidLineIds: v } = vn(
698
+ e,
699
+ t,
700
+ n,
701
+ i,
702
+ a
703
+ );
704
+ if (v.length > 0) return { ok: !1, invalidLineIds: v };
705
+ const d = /* @__PURE__ */ new Map();
706
+ for (const { line: m, entry: I } of c) {
707
+ const g = a.groupOf(m);
708
+ if (a.multi && g === void 0) continue;
709
+ let N = d.get(g);
710
+ N || (N = {
711
+ invoiceId: g ?? null,
712
+ documentKind: a.kindOf(m),
713
+ lines: []
714
+ }, d.set(g, N)), N.lines.push({ ...I, lineId: a.sourceOf(I.lineId).lineId });
715
+ }
716
+ return { ok: !0, invoices: [...d.values()] };
717
+ }
718
+ function gn(e, t, n) {
719
+ const r = n.ticked.has(e.id), i = t.item.kind === "existing" ? n.findItem(t.item.itemId) ?? null : null, a = t.item.kind !== "existing" || i !== null, c = n.scope;
720
+ return {
721
+ line: e,
722
+ invoice: (c == null ? void 0 : c.invoiceOf(e)) ?? null,
723
+ documentKind: (c == null ? void 0 : c.kindOf(e)) ?? "invoice",
724
+ invoiceStart: (c == null ? void 0 : c.invoiceStarts.has(e.id)) ?? !1,
725
+ groupStart: (c == null ? void 0 : c.groupStarts.has(e.id)) ?? !1,
726
+ value: t,
727
+ selected: r,
728
+ matchState: qi(e, t, r),
729
+ invalid: r && mt(e, t, a),
730
+ readOnly: c ? c.isLoaded(e) : n.invoiceLoaded,
731
+ quantityLocked: !ut(e.quantity),
732
+ item: i,
733
+ itemKnown: a
734
+ };
735
+ }
736
+ function Ui(e, t) {
737
+ return e === t ? !0 : e === null || t === null ? !1 : e.id === t.id && e.name === t.name && e.code === t.code;
738
+ }
739
+ function Ki(e, t) {
740
+ return e === t ? !0 : e === null || t === null ? !1 : e.id === t.id && e.documentKind === t.documentKind && e.header.number === t.header.number && e.header.date === t.header.date && e.header.source === t.header.source && e.header.supplier.name === t.header.supplier.name && e.header.supplier.kind === t.header.supplier.kind;
741
+ }
742
+ function Pi(e, t) {
743
+ return e.line === t.line && e.value.quantity === t.value.quantity && mn(e.value.item, t.value.item) && e.selected === t.selected && e.matchState === t.matchState && e.invalid === t.invalid && e.readOnly === t.readOnly && e.quantityLocked === t.quantityLocked && e.itemKnown === t.itemKnown && e.documentKind === t.documentKind && e.invoiceStart === t.invoiceStart && e.groupStart === t.groupStart && Ki(e.invoice, t.invoice) && Ui(e.item, t.item);
744
+ }
745
+ function Qt(e) {
746
+ const t = e.scope ?? ve(e.lines), n = {
747
+ invoiceLoaded: t.allLoaded,
748
+ ticked: new Set(
749
+ G(e.lines, e.selection, t)
750
+ ),
751
+ findItem: e.findItem,
752
+ scope: t
753
+ };
754
+ return e.lines.map((r) => {
755
+ var c;
756
+ const i = gn(
757
+ r,
758
+ e.values[r.id] ?? X(r),
759
+ n
760
+ ), a = (c = e.previous) == null ? void 0 : c.get(r.id);
761
+ return a && Pi(a, i) ? a : i;
762
+ });
763
+ }
764
+ function $i(e, t) {
765
+ var a, c;
766
+ const n = e.line.warnings.map((v) => v.code);
767
+ e.quantityLocked && n.push(on);
768
+ const r = e.readOnly || e.line.alreadyLoaded, i = (a = t.scope) == null ? void 0 : a.sourceOf(e.line.id);
769
+ return {
770
+ id: e.line.id,
771
+ invoiceId: (c = t.scope) != null && c.multi ? e.line.invoiceId ?? null : null,
772
+ sourceLineId: (i == null ? void 0 : i.lineId) ?? e.line.id,
773
+ lineNumber: e.line.lineNumber,
774
+ matchState: e.matchState,
775
+ selected: e.selected,
776
+ selectable: !r && !t.tableReadOnly,
777
+ readOnly: r || t.tableReadOnly,
778
+ quantityLocked: e.quantityLocked,
779
+ itemKind: e.value.item.kind,
780
+ itemId: e.value.item.kind === "existing" ? e.value.item.itemId : null,
781
+ quantity: e.value.quantity,
782
+ removesStock: (t.scope ? e.documentKind : t.documentKind) === "creditNote",
783
+ warningCodes: n,
784
+ invalid: e.invalid
785
+ };
786
+ }
787
+ function Fi(e) {
788
+ const t = fe(e, pe.quantity);
789
+ return !t.ok || t.value.units <= 0 || Ne(t.value, sn) > 0 ? null : ae(Qe(t.value));
790
+ }
791
+ function zi({
792
+ row: e,
793
+ privacyMode: t
794
+ }) {
795
+ const { t: n, i18n: r } = Pe("ui"), i = e.invoice;
796
+ if (!i) return null;
797
+ const { header: a } = i;
798
+ return /* @__PURE__ */ w("span", { "data-component": "bill-line-invoice-cell", className: ze(), children: [
799
+ e.invoiceStart ? /* @__PURE__ */ l("span", { className: Li(), children: /* @__PURE__ */ l(rn, { invoice: a, privacyMode: t }) }) : null,
800
+ /* @__PURE__ */ l("span", { dir: "auto", className: he(), children: a.number }),
801
+ e.invoiceStart ? /* @__PURE__ */ l("span", { className: he(), children: nn(a.date, r.language) }) : null,
802
+ e.documentKind === "creditNote" ? /* @__PURE__ */ l(st, { size: "sm", variant: "neutral", children: n("invoiceUploadList.documentKind.creditNote", "Credit note") }) : null
803
+ ] });
804
+ }
805
+ const Yi = {
806
+ itemOptions: [],
807
+ itemOptionIds: /* @__PURE__ */ new Set(),
808
+ serverSearch: !1,
809
+ itemsLoading: !1,
810
+ searchingLineId: null
811
+ }, yn = Jt(Yi), Se = Jt(
812
+ null
813
+ ), Qi = {
814
+ matched: { variant: be.matched, check: !1 },
815
+ newItem: { variant: be.newItem, check: !1 },
816
+ itemToUpdate: {
817
+ variant: be.itemToUpdate,
818
+ check: !1
819
+ },
820
+ skip: { variant: be.skip, check: !1 },
821
+ alreadyLoaded: {
822
+ variant: be.alreadyLoaded,
823
+ check: !0
824
+ }
825
+ };
826
+ function Wt(e, t) {
827
+ const n = ni[e];
828
+ return t(n.key, n.en);
829
+ }
830
+ function We(e, t) {
831
+ const n = cn(e), r = n ? Fe(n) : null;
832
+ return r === null ? e.trim() : K(ti(r, -2), t, {
833
+ style: "percent",
834
+ minimumFractionDigits: 0,
835
+ maximumFractionDigits: Si
836
+ });
837
+ }
838
+ function ee({
839
+ value: e,
840
+ currency: t,
841
+ fractionDigits: n = Ke,
842
+ tone: r = "default"
843
+ }) {
844
+ const i = Z(e);
845
+ return i ? /* @__PURE__ */ l(
846
+ Xn,
847
+ {
848
+ size: "sm",
849
+ tone: r,
850
+ value: i.units,
851
+ scale: i.scale,
852
+ currency: t,
853
+ minimumFractionDigits: Math.min(2, n),
854
+ maximumFractionDigits: n
855
+ }
856
+ ) : /* @__PURE__ */ l("span", { dir: "ltr", className: Ye(), children: e.trim() });
857
+ }
858
+ function Ln(e, t) {
859
+ const n = t.replace(
860
+ /\s/g,
861
+ (r) => `_${r.charCodeAt(0).toString(16)}_`
862
+ );
863
+ return `${e.statusIdPrefix}-${n}`;
864
+ }
865
+ function jt(e, t) {
866
+ if (!t.multi || e.documentKind !== "creditNote")
867
+ return e.line.lineTotal;
868
+ const n = Z(e.line.lineTotal);
869
+ return n && n.units !== 0 ? ae(en(n)) : e.line.lineTotal;
870
+ }
871
+ function Wi(e, t) {
872
+ const n = e.value.quantity;
873
+ if (n === null) return null;
874
+ const r = P(n), i = r.value ? Fe(r.value) : null;
875
+ return /* @__PURE__ */ w("span", { className: Ye(), children: [
876
+ i === null ? (
877
+ // More digits than a double holds: every digit, as sent.
878
+ /* @__PURE__ */ l("span", { dir: "ltr", children: n.trim() })
879
+ ) : K(i, t, {
880
+ maximumFractionDigits: de
881
+ }),
882
+ e.line.unitOfMeasure ? /* @__PURE__ */ w(ot, { children: [
883
+ " ",
884
+ /* @__PURE__ */ l("span", { dir: "auto", children: e.line.unitOfMeasure })
885
+ ] }) : null
886
+ ] });
887
+ }
888
+ function ji(e, t) {
889
+ const { t: n } = t;
890
+ if (!e.selected) return;
891
+ const r = P(e.value.quantity);
892
+ if (r.empty)
893
+ return n("billLineTable.quantity.errorRequired", "Enter a quantity");
894
+ if (!r.wellFormed || !r.positive)
895
+ return n(
896
+ "billLineTable.quantity.errorNotPositive",
897
+ "Enter a quantity above 0"
898
+ );
899
+ if (un(e.line, e.value))
900
+ return n("billLineTable.quantity.errorTooLarge", {
901
+ max: K(ke, t.language),
902
+ defaultValue: "Enter a quantity of {{max}} or less"
903
+ });
904
+ const i = e.line.warnings.find(
905
+ (a) => a.severity === "error"
906
+ );
907
+ return i == null ? void 0 : i.message;
908
+ }
909
+ function Hi(e, t) {
910
+ if (!e.itemKnown)
911
+ return t(
912
+ "billLineTable.item.errorUnknown",
913
+ "This item is no longer in the warehouse. Choose another."
914
+ );
915
+ if (e.selected && dn(e.value))
916
+ return t(
917
+ "billLineTable.item.errorNameRequired",
918
+ "Enter a name for the new item"
919
+ );
920
+ }
921
+ function Gi(e, t) {
922
+ const n = Ci(e.line.lineTotal, e.value.quantity), r = n !== null && !Ei(n, e.line.unitPrice) ? n : null;
923
+ return /* @__PURE__ */ w("span", { className: ze({ align: "end" }), children: [
924
+ /* @__PURE__ */ l(ee, { value: e.line.unitPrice, currency: t.currency }),
925
+ r !== null ? /* @__PURE__ */ w("span", { className: he(), children: [
926
+ t.t("billLineTable.unitPrice.netLabel", "Net per unit"),
927
+ " ",
928
+ /* @__PURE__ */ l(
929
+ ee,
930
+ {
931
+ value: r,
932
+ currency: t.currency,
933
+ tone: "muted"
934
+ }
935
+ )
936
+ ] }) : null
937
+ ] });
938
+ }
939
+ function Xi(e, t) {
940
+ return e.line.adjustments.length === 0 ? null : /* @__PURE__ */ l("ul", { className: ct({ align: "end" }), children: e.line.adjustments.map((n, r) => (
941
+ // Index key: the blocks have no identity and never reorder.
942
+ /* @__PURE__ */ w("li", { className: hi(), children: [
943
+ /* @__PURE__ */ l("span", { className: he(), children: n.type === "discount" ? t.t("billLineTable.adjustment.discount", "Discount") : t.t("billLineTable.adjustment.surcharge", "Surcharge") }),
944
+ /* @__PURE__ */ w("span", { className: Ye(), children: [
945
+ /* @__PURE__ */ l("span", { "aria-hidden": "true", children: n.type === "discount" ? "−" : "+" }),
946
+ n.percent !== null ? We(n.percent, t.language) : n.amount !== null ? /* @__PURE__ */ l(
947
+ ee,
948
+ {
949
+ value: n.amount,
950
+ currency: t.currency
951
+ }
952
+ ) : null
953
+ ] })
954
+ ] }, r)
955
+ )) });
956
+ }
957
+ function Ht(e, t, n) {
958
+ if (t === null)
959
+ return n.t("billLineTable.update.none", "none");
960
+ if (e !== "price") return We(t, n.language);
961
+ const r = Z(t);
962
+ return r ? K(r.units / 10 ** r.scale, n.language, {
963
+ style: "currency",
964
+ currency: n.currency,
965
+ minimumFractionDigits: Math.min(2, Ke),
966
+ maximumFractionDigits: Ke
967
+ }) : t.trim();
968
+ }
969
+ function Gt(e, t, n) {
970
+ return t === null ? n.t("billLineTable.update.none", "none") : e === "price" ? /* @__PURE__ */ l(ee, { value: t, currency: n.currency }) : We(t, n.language);
971
+ }
972
+ function Zi(e, t) {
973
+ if (e.matchState !== "itemToUpdate" || !e.line.itemUpdate) return null;
974
+ const n = e.line.itemUpdate, r = [
975
+ {
976
+ key: "price",
977
+ label: t.t("billLineTable.update.price", "Price"),
978
+ change: n.unitPrice
979
+ },
980
+ {
981
+ key: "vat",
982
+ label: t.t("billLineTable.update.vat", "VAT"),
983
+ change: n.vatRate
984
+ },
985
+ {
986
+ key: "discount",
987
+ label: t.t("billLineTable.update.discount", "Discount"),
988
+ change: n.discountPercent
989
+ }
990
+ ].filter((i) => Me(i.change));
991
+ return r.length === 0 ? null : /* @__PURE__ */ l(
992
+ "ul",
993
+ {
994
+ className: ct({ align: "start" }),
995
+ "aria-label": t.t("billLineTable.update.label", "Changes to the item"),
996
+ children: r.map(
997
+ ({ key: i, label: a, change: c }) => c ? /* @__PURE__ */ w("li", { className: gi(), children: [
998
+ /* @__PURE__ */ w("span", { "aria-hidden": "true", children: [
999
+ a,
1000
+ " ",
1001
+ Gt(i, c.from, t),
1002
+ " ",
1003
+ /* @__PURE__ */ l(ai, { className: vi() }),
1004
+ " ",
1005
+ Gt(i, c.to, t)
1006
+ ] }),
1007
+ /* @__PURE__ */ l($e, { children: t.t("billLineTable.update.change", {
1008
+ label: a,
1009
+ from: Ht(i, c.from, t),
1010
+ to: Ht(i, c.to, t),
1011
+ defaultValue: "{{label}}: from {{from}} to {{to}}"
1012
+ }) })
1013
+ ] }, i) : null
1014
+ )
1015
+ }
1016
+ );
1017
+ }
1018
+ function Ji(e, t) {
1019
+ if (e.line.vatPercent === null)
1020
+ return /* @__PURE__ */ w(ot, { children: [
1021
+ /* @__PURE__ */ l("span", { "aria-hidden": "true", children: "–" }),
1022
+ /* @__PURE__ */ l($e, { children: t.t("billLineTable.vat.none", "No VAT rate") })
1023
+ ] });
1024
+ const n = We(e.line.vatPercent, t.language);
1025
+ return e.line.vatNature ? t.t("billLineTable.vat.withNature", {
1026
+ rate: n,
1027
+ nature: e.line.vatNature,
1028
+ defaultValue: "{{rate}} ({{nature}})"
1029
+ }) : n;
1030
+ }
1031
+ function pt(e, t) {
1032
+ return t.privacyMode ? t.t("billLineTable.item.newOptionMasked", "New item") : t.t("billLineTable.item.newOption", {
1033
+ name: e,
1034
+ defaultValue: "New item: {{name}}"
1035
+ });
1036
+ }
1037
+ function er(e, t) {
1038
+ const n = [pt("", { ...t, privacyMode: !1 }).trim()];
1039
+ t.privacyMode && n.push(t.t("billLineTable.item.newOptionMasked", "New item"));
1040
+ for (const r of n)
1041
+ if (r !== "" && e.startsWith(r))
1042
+ return e.slice(r.length).trim();
1043
+ return e.trim();
1044
+ }
1045
+ function Xt(e, t) {
1046
+ var r;
1047
+ const n = e.value.item;
1048
+ return n.kind === "new" ? pt(n.name, t) : ((r = e.item) == null ? void 0 : r.name) ?? "";
1049
+ }
1050
+ function bn(e) {
1051
+ return {
1052
+ value: e.id,
1053
+ label: e.name,
1054
+ description: e.code ?? void 0,
1055
+ // Item names are text a practice wrote.
1056
+ dir: "auto"
1057
+ };
1058
+ }
1059
+ const tr = () => 1;
1060
+ function nr(e, t) {
1061
+ const n = [...e.line.warnings];
1062
+ return e.quantityLocked && n.push({
1063
+ code: on,
1064
+ message: t.t(
1065
+ "billLineTable.quantity.tooLarge",
1066
+ "This quantity is too large to edit here. It loads as on the invoice."
1067
+ ),
1068
+ severity: "warning"
1069
+ }), t.privacyMode && e.selected && Ai(e.line, e.value) && n.push({
1070
+ code: "newItemNameHidden",
1071
+ message: t.t(
1072
+ "billLineTable.item.checkNameHidden",
1073
+ "The new item takes the line description as its name. Turn off privacy mode to check it before you load."
1074
+ ),
1075
+ severity: "warning"
1076
+ }), n.length === 0 ? null : /* @__PURE__ */ l("ul", { className: ct(), children: n.map((r, i) => (
1077
+ // Index key: warnings have no identity of their own.
1078
+ /* @__PURE__ */ w("li", { className: mi(), children: [
1079
+ r.severity === "error" ? /* @__PURE__ */ l(
1080
+ li,
1081
+ {
1082
+ "aria-hidden": "true",
1083
+ className: Rt({ severity: "error" })
1084
+ }
1085
+ ) : /* @__PURE__ */ l(
1086
+ oi,
1087
+ {
1088
+ "aria-hidden": "true",
1089
+ className: Rt({ severity: "warning" })
1090
+ }
1091
+ ),
1092
+ /* @__PURE__ */ w("span", { className: fi(), children: [
1093
+ /* @__PURE__ */ l($e, { children: r.severity === "error" ? t.t("billLineTable.warnings.error", "Error:") : t.t("billLineTable.warnings.warning", "Warning:") }),
1094
+ /* @__PURE__ */ l("span", { dir: "auto", children: r.message })
1095
+ ] })
1096
+ ] }, i)
1097
+ )) });
1098
+ }
1099
+ function ir({
1100
+ row: e,
1101
+ context: t,
1102
+ deps: n
1103
+ }) {
1104
+ const r = we(yn), { t: i, setItem: a, queryItems: c } = n, { line: v, value: d, item: m } = e, I = d.item.kind === "new" ? d.item.name : null, g = A(null), N = A(n.privacyMode), _ = A(0), b = A(!1);
1105
+ if (N.current !== n.privacyMode) {
1106
+ N.current = n.privacyMode;
1107
+ const p = g.current;
1108
+ p !== null && p.contains(p.ownerDocument.activeElement) && (_.current += 1, b.current = !0);
1109
+ }
1110
+ Kn(() => {
1111
+ if (!b.current) return;
1112
+ b.current = !1;
1113
+ const p = () => {
1114
+ var Y, Q;
1115
+ return (Q = (Y = g.current) == null ? void 0 : Y.querySelector('input[role="combobox"]')) == null ? void 0 : Q.focus();
1116
+ };
1117
+ p(), queueMicrotask(p);
1118
+ }, [n.privacyMode]);
1119
+ const O = E(() => I !== null ? [
1120
+ {
1121
+ value: me,
1122
+ label: pt(I, n),
1123
+ description: i(
1124
+ "billLineTable.item.newOptionDescription",
1125
+ "Created when you load the invoice"
1126
+ )
1127
+ },
1128
+ ...r.itemOptions
1129
+ ] : m && !r.itemOptionIds.has(m.id) ? [bn(m), ...r.itemOptions] : r.itemOptions, [I, m, r.itemOptions, r.itemOptionIds, n, i]), h = E(
1130
+ () => ({
1131
+ label: i("billLineTable.item.createNew", "Create new item"),
1132
+ icon: /* @__PURE__ */ l(ri, {}),
1133
+ // Marks the line only; nothing is created before Confirm (D5). The
1134
+ // typed text names the item; with none, the description does.
1135
+ onSelect: (p) => a(v.id, {
1136
+ kind: "new",
1137
+ name: er(p, n)
1138
+ })
1139
+ }),
1140
+ [i, a, v.id, n]
1141
+ );
1142
+ return /* @__PURE__ */ l("div", { ref: g, className: di(), children: /* @__PURE__ */ l(
1143
+ Gn,
1144
+ {
1145
+ "aria-labelledby": t.labelledBy,
1146
+ "aria-invalid": t.invalid || void 0,
1147
+ "aria-describedby": [t.errorId, Ln(n, v.id)].filter(Boolean).join(" ") || void 0,
1148
+ options: O,
1149
+ value: d.item.kind === "existing" ? d.item.itemId : me,
1150
+ onValueChange: (p) => {
1151
+ p === "" || p === me || a(v.id, { kind: "existing", itemId: p });
1152
+ },
1153
+ placeholder: i("billLineTable.item.placeholder", "Choose an item"),
1154
+ openOnFocus: !1,
1155
+ popoverSize: "md",
1156
+ wrapOptionLabels: !0,
1157
+ action: h,
1158
+ onQueryChange: r.serverSearch ? (p) => c(v.id, p) : void 0,
1159
+ filter: r.serverSearch ? tr : void 0,
1160
+ loading: r.serverSearch ? r.searchingLineId === v.id && r.itemsLoading : void 0
1161
+ },
1162
+ _.current
1163
+ ) });
1164
+ }
1165
+ function rr({ deps: e }) {
1166
+ const t = we(Se);
1167
+ if (!t) return null;
1168
+ const n = t.lineCount - t.alreadyLoadedCount;
1169
+ return /* @__PURE__ */ w("span", { className: ze(), children: [
1170
+ /* @__PURE__ */ l("span", { children: e.t("billLineTable.footer.ticked", {
1171
+ count: n,
1172
+ selected: K(t.selectedCount, e.language),
1173
+ total: K(n, e.language),
1174
+ defaultValue: "{{selected}} of {{total}} lines ticked",
1175
+ defaultValue_one: "{{selected}} of {{total}} line ticked",
1176
+ defaultValue_other: "{{selected}} of {{total}} lines ticked"
1177
+ }) }),
1178
+ t.itemUpdateCount > 0 ? /* @__PURE__ */ l("span", { className: he(), children: e.t("billLineTable.footer.itemsToUpdate", {
1179
+ count: t.itemUpdateCount,
1180
+ countText: K(t.itemUpdateCount, e.language),
1181
+ defaultValue: "{{countText}} items to update",
1182
+ defaultValue_one: "{{countText}} item to update",
1183
+ defaultValue_other: "{{countText}} items to update"
1184
+ }) }) : null,
1185
+ t.newItemCount > 0 ? /* @__PURE__ */ l("span", { className: he(), children: e.t("billLineTable.footer.newItems", {
1186
+ count: t.newItemCount,
1187
+ countText: K(t.newItemCount, e.language),
1188
+ defaultValue: "{{countText}} new items",
1189
+ defaultValue_one: "{{countText}} new item",
1190
+ defaultValue_other: "{{countText}} new items"
1191
+ }) }) : null
1192
+ ] });
1193
+ }
1194
+ function ar({ currency: e }) {
1195
+ const t = we(Se);
1196
+ return t ? /* @__PURE__ */ l(ee, { value: t.vat, currency: e, fractionDigits: 2 }) : null;
1197
+ }
1198
+ function lr({ deps: e }) {
1199
+ const t = we(Se);
1200
+ return t ? /* @__PURE__ */ w("dl", { className: pi(), children: [
1201
+ /* @__PURE__ */ l("dt", { className: Dt(), children: e.t("billLineTable.footer.net", "Net") }),
1202
+ /* @__PURE__ */ l("dd", { className: Mt(), children: /* @__PURE__ */ l(
1203
+ ee,
1204
+ {
1205
+ value: t.net,
1206
+ currency: e.currency,
1207
+ fractionDigits: 2
1208
+ }
1209
+ ) }),
1210
+ /* @__PURE__ */ l("dt", { className: Dt(), children: e.t("billLineTable.footer.gross", "Total with VAT") }),
1211
+ /* @__PURE__ */ l("dd", { className: Mt(), children: /* @__PURE__ */ l(
1212
+ ee,
1213
+ {
1214
+ value: t.gross,
1215
+ currency: e.currency,
1216
+ fractionDigits: 2
1217
+ }
1218
+ ) })
1219
+ ] }) : null;
1220
+ }
1221
+ function or({ deps: e }) {
1222
+ const t = we(Se);
1223
+ return !t || t.warningLineCount === 0 ? null : /* @__PURE__ */ l("span", { children: e.t("billLineTable.footer.warningLines", {
1224
+ count: t.warningLineCount,
1225
+ countText: K(t.warningLineCount, e.language),
1226
+ defaultValue: "{{countText}} lines with warnings",
1227
+ defaultValue_one: "{{countText}} line with warnings",
1228
+ defaultValue_other: "{{countText}} lines with warnings"
1229
+ }) });
1230
+ }
1231
+ function sr(e) {
1232
+ const { t } = e, n = {
1233
+ kind: "number",
1234
+ mode: "decimal",
1235
+ // The float lives only inside NumberInput: every change goes back to
1236
+ // exact text at once, within BILL_LINE_MAX_QUANTITY. Unsigned in the
1237
+ // field and in the value: the document carries the sign (D6).
1238
+ // A typed value above the limit stays in the field with its error
1239
+ // (`quantityError`); an invoiced one is locked by `isEditable`.
1240
+ getValue: (i) => {
1241
+ const a = P(i.value.quantity).value;
1242
+ return a ? Fe(a) : null;
1243
+ },
1244
+ onChange: (i, a) => e.setQuantity(
1245
+ i.line.id,
1246
+ a === null ? null : _i(a)
1247
+ ),
1248
+ // A quantity the editor cannot hold exactly stays text, never clamped.
1249
+ isEditable: (i) => !i.readOnly && !i.quantityLocked,
1250
+ min: 0,
1251
+ max: ke,
1252
+ step: 1,
1253
+ maximumFractionDigits: de,
1254
+ // DG-1: FatturaPA UnitaMisura per line, as the supplier wrote it.
1255
+ unit: (i) => i.line.unitOfMeasure ?? void 0,
1256
+ error: (i) => ji(i, e),
1257
+ // WCAG 3.3.2: the field says how many decimals it takes, since a digit
1258
+ // past the limit is refused as it is typed. Kit copy and a constant
1259
+ // only, so it shows in privacy mode too (`hostTextPrivacySafe`).
1260
+ description: (i) => {
1261
+ const a = t(
1262
+ "billLineTable.quantity.precision",
1263
+ "Up to {{formatted}} decimal places",
1264
+ {
1265
+ count: de,
1266
+ formatted: K(
1267
+ de,
1268
+ e.language
1269
+ )
1270
+ }
1271
+ );
1272
+ return e.multi && i.documentKind === "creditNote" && e.documentKind !== "creditNote" ? `${t("billLineTable.column.quantityCreditNote", "Quantity to remove")}. ${a}` : a;
1273
+ }
1274
+ }, r = {
1275
+ id: "invoice",
1276
+ header: t("invoiceUploadList.column.invoiceNumber", "Invoice number"),
1277
+ wrap: !0,
1278
+ sort: !1,
1279
+ // Supplier names can be people: masked under privacy mode as in the
1280
+ // header block, inside the cell.
1281
+ cell: (i) => /* @__PURE__ */ l(zi, { row: i, privacyMode: e.privacyMode }),
1282
+ exportValue: (i) => {
1283
+ var a;
1284
+ return ((a = i.invoice) == null ? void 0 : a.header.number) ?? null;
1285
+ },
1286
+ size: 176,
1287
+ hideable: !1,
1288
+ reorderable: !1
1289
+ };
1290
+ return [
1291
+ {
1292
+ id: "description",
1293
+ header: t("billLineTable.column.description", "Description"),
1294
+ rowHeader: !0,
1295
+ pin: "start",
1296
+ wrap: !0,
1297
+ // Lab invoices can name a patient here (D9).
1298
+ privacy: "mask",
1299
+ cell: (i) => /* @__PURE__ */ l("span", { dir: "auto", children: i.line.description }),
1300
+ value: (i) => i.line.description,
1301
+ // No sorting in any mode (D10); privacy mode would turn it off anyway.
1302
+ sort: !1,
1303
+ size: 200,
1304
+ minSize: 192,
1305
+ hideable: !1,
1306
+ reorderable: !1,
1307
+ // The totals row's header cell.
1308
+ footer: () => /* @__PURE__ */ l(rr, { deps: e })
1309
+ },
1310
+ ...e.multi ? [r] : [],
1311
+ {
1312
+ id: "quantity",
1313
+ header: e.documentKind === "creditNote" ? t("billLineTable.column.quantityCreditNote", "Quantity to remove") : t("billLineTable.column.quantity", "Quantity"),
1314
+ align: "end",
1315
+ // Read-only lines (a loaded invoice, the table while loading, or a
1316
+ // locked quantity): the unsigned value as text, plus the unit.
1317
+ cell: (i) => Wi(i, e.language),
1318
+ exportValue: (i) => i.value.quantity,
1319
+ edit: n,
1320
+ size: 128,
1321
+ hideable: !1,
1322
+ reorderable: !1
1323
+ },
1324
+ {
1325
+ id: "item",
1326
+ header: t("billLineTable.column.item", "Warehouse item"),
1327
+ cell: (i) => /* @__PURE__ */ l("span", { dir: "auto", children: Xt(i, e) }),
1328
+ exportValue: (i) => Xt(i, e) || null,
1329
+ edit: {
1330
+ kind: "custom",
1331
+ render: (i, a) => /* @__PURE__ */ l(ir, { row: i, context: a, deps: e }),
1332
+ error: (i) => Hi(i, t)
1333
+ },
1334
+ size: 240,
1335
+ minSize: 192,
1336
+ hideable: !1,
1337
+ reorderable: !1
1338
+ },
1339
+ {
1340
+ id: "match",
1341
+ header: t("billLineTable.column.match", "Status"),
1342
+ cell: (i) => {
1343
+ const a = Qi[i.matchState];
1344
+ return /* @__PURE__ */ w("span", { id: Ln(e, i.line.id), className: ze(), children: [
1345
+ /* @__PURE__ */ l(
1346
+ st,
1347
+ {
1348
+ size: "sm",
1349
+ variant: a.variant,
1350
+ leading: a.check ? /* @__PURE__ */ l(ii, {}) : void 0,
1351
+ children: Wt(i.matchState, t)
1352
+ }
1353
+ ),
1354
+ Zi(i, e)
1355
+ ] });
1356
+ },
1357
+ exportValue: (i) => Wt(i.matchState, t),
1358
+ wrap: !0,
1359
+ size: 176,
1360
+ hideable: !1,
1361
+ reorderable: !1
1362
+ },
1363
+ {
1364
+ id: "warnings",
1365
+ header: t("billLineTable.column.warnings", "Warnings"),
1366
+ wrap: !0,
1367
+ // Not masked: a warning must not quote the description
1368
+ // (BillLineWarning.message), so errors stay readable (D9).
1369
+ cell: (i) => nr(i, e),
1370
+ exportValue: (i) => i.line.warnings.map((a) => a.message).join("; ") || null,
1371
+ size: 168,
1372
+ hideable: !1,
1373
+ reorderable: !1,
1374
+ footer: () => /* @__PURE__ */ l(or, { deps: e })
1375
+ },
1376
+ {
1377
+ id: "lineTotal",
1378
+ header: t("billLineTable.column.lineTotal", "Amount"),
1379
+ align: "end",
1380
+ cell: (i) => /* @__PURE__ */ l(
1381
+ ee,
1382
+ {
1383
+ value: jt(i, e),
1384
+ currency: e.currency
1385
+ }
1386
+ ),
1387
+ exportValue: (i) => jt(i, e),
1388
+ size: 128,
1389
+ hideable: !1,
1390
+ reorderable: !1,
1391
+ // From the summary (exact decimals, ticked lines), not from the
1392
+ // footer context's rows.
1393
+ footer: () => /* @__PURE__ */ l(lr, { deps: e })
1394
+ },
1395
+ {
1396
+ id: "unitPrice",
1397
+ header: t("billLineTable.column.unitPrice", "Unit price"),
1398
+ align: "end",
1399
+ cell: (i) => Gi(i, e),
1400
+ exportValue: (i) => i.line.unitPrice,
1401
+ // 112 px of text: "EENHEIDSPRIJS" (nl) is the longest word.
1402
+ size: 144,
1403
+ hideable: !1,
1404
+ reorderable: !1
1405
+ },
1406
+ {
1407
+ id: "vat",
1408
+ header: t("billLineTable.column.vat", "VAT"),
1409
+ align: "end",
1410
+ cell: (i) => Ji(i, e),
1411
+ exportValue: (i) => i.line.vatPercent,
1412
+ size: 88,
1413
+ hideable: !1,
1414
+ reorderable: !1,
1415
+ // VAT of the ticked lines, under the VAT header.
1416
+ footer: () => /* @__PURE__ */ l(ar, { currency: e.currency })
1417
+ },
1418
+ {
1419
+ id: "adjustment",
1420
+ header: t("billLineTable.column.adjustment", "Discount or surcharge"),
1421
+ align: "end",
1422
+ cell: (i) => Xi(i, e),
1423
+ exportValue: (i) => i.line.adjustments.map(
1424
+ (a) => `${a.type === "discount" ? "-" : "+"}${a.percent !== null ? `${a.percent}%` : a.amount ?? ""}`
1425
+ ).join(", ") || null,
1426
+ // 112 px of text: "MAGGIORAZIONE" (it) is the longest word.
1427
+ size: 144,
1428
+ hideable: !1,
1429
+ reorderable: !1
1430
+ },
1431
+ {
1432
+ id: "supplierCode",
1433
+ header: t("billLineTable.column.supplierCode", "Supplier code"),
1434
+ cell: (i) => i.line.supplierCode === null ? null : /* @__PURE__ */ l("span", { dir: "ltr", className: Ye(), children: i.line.supplierCode }),
1435
+ exportValue: (i) => i.line.supplierCode,
1436
+ // 136 px of text: "LEVERANCIERSCODE" (nl) is the longest word.
1437
+ size: 168,
1438
+ hideable: !1,
1439
+ reorderable: !1
1440
+ }
1441
+ ];
1442
+ }
1443
+ function cr(e) {
1444
+ return e.map(bn);
1445
+ }
1446
+ const Zt = {};
1447
+ function re(e, t) {
1448
+ return new Error(`${e}: ${t}`);
1449
+ }
1450
+ function ur(e, t) {
1451
+ return e.length === t.length && e.every((n, r) => n === t[r]);
1452
+ }
1453
+ function dr(e) {
1454
+ return JSON.stringify(e);
1455
+ }
1456
+ const mr = Pn(function({
1457
+ lines: t,
1458
+ items: n,
1459
+ selectedItems: r,
1460
+ documentKind: i = "invoice",
1461
+ currency: a = "EUR",
1462
+ gridId: c,
1463
+ caption: v,
1464
+ invoice: d,
1465
+ invoices: m,
1466
+ values: I,
1467
+ defaultValues: g,
1468
+ onValuesChange: N,
1469
+ selection: _,
1470
+ defaultSelection: b,
1471
+ onSelectionChange: O,
1472
+ onSummaryChange: h,
1473
+ onItemQueryChange: p,
1474
+ itemsLoading: Y = !1,
1475
+ status: Q = "ready",
1476
+ error: V,
1477
+ readOnly: le = !1,
1478
+ privacyMode: W = !1,
1479
+ height: xe = "fill",
1480
+ className: y,
1481
+ ...j
1482
+ }, oe) {
1483
+ const { t: k, i18n: ge } = Pe("ui"), te = ge.language, se = A(null), _e = le !== !1, ht = m !== void 0, je = E(
1484
+ () => wi(t, ht ? [] : void 0),
1485
+ [t, ht]
1486
+ ), S = je.lines, R = E(
1487
+ () => ln(S, m, i, je.sources),
1488
+ [S, m, i, je]
1489
+ ), He = R.multi;
1490
+ Ae(() => {
1491
+ if (Vt() && m !== void 0) {
1492
+ d !== void 0 && console.warn(
1493
+ '[BillLineTable] "invoice" is ignored when "invoices" is set: each invoice shows in the Invoice column.'
1494
+ );
1495
+ for (const o of ki(t, m))
1496
+ console.warn(`[BillLineTable] ${o}`);
1497
+ }
1498
+ }, [t, m, d]);
1499
+ const In = A(/* @__PURE__ */ new Map()), ce = E(() => {
1500
+ const o = In.current;
1501
+ for (const f of r ?? []) o.set(f.id, f);
1502
+ for (const f of n) o.set(f.id, f);
1503
+ return new Map(o);
1504
+ }, [n, r]);
1505
+ Ae(() => {
1506
+ Vt() && n.some((o) => o.id === me) && console.warn(
1507
+ `[BillLineTable] an item id equals "${me}", the value of the new-item option, so that item cannot be chosen.`
1508
+ );
1509
+ }, [n]);
1510
+ const vt = E(() => cr(n), [n]), gt = E(
1511
+ () => new Set(n.map((o) => o.id)),
1512
+ [n]
1513
+ ), [yt, Tn] = qe(null), Lt = p !== void 0, wn = E(
1514
+ () => ({
1515
+ itemOptions: vt,
1516
+ itemOptionIds: gt,
1517
+ serverSearch: Lt,
1518
+ itemsLoading: Y,
1519
+ searchingLineId: yt
1520
+ }),
1521
+ [vt, gt, Lt, Y, yt]
1522
+ ), bt = I !== void 0, [Nn, kn] = qe(
1523
+ () => g ?? Zt
1524
+ ), D = I ?? Nn, Ge = _ !== void 0, [Xe, It] = qe(
1525
+ () => b ?? it(S, R)
1526
+ ), [Tt, Sn] = qe(S);
1527
+ if (Tt !== S && (Sn(S), !Ge && b === void 0)) {
1528
+ const o = new Set(Tt.map((L) => L.id)), f = it(S, R).filter(
1529
+ (L) => !o.has(L) && !Xe.includes(L)
1530
+ );
1531
+ f.length > 0 && It([...Xe, ...f]);
1532
+ }
1533
+ const M = _ ?? Xe, $ = A(D);
1534
+ $.current = D;
1535
+ const F = A(M);
1536
+ F.current = M;
1537
+ const wt = A(null), Nt = A(null), Ce = E(
1538
+ () => ({
1539
+ values: g ?? Zt,
1540
+ selection: b ?? it(S, R)
1541
+ }),
1542
+ [g, b, S, R]
1543
+ ), kt = A(/* @__PURE__ */ new Map()), Ze = E(() => {
1544
+ const o = Qt({
1545
+ lines: S,
1546
+ values: D,
1547
+ selection: M,
1548
+ findItem: (f) => ce.get(f),
1549
+ previous: kt.current,
1550
+ scope: R
1551
+ });
1552
+ return kt.current = new Map(o.map((f) => [f.line.id, f])), o;
1553
+ }, [S, D, M, ce, R]), xn = E(
1554
+ () => Ze.filter((o) => o.selected).map((o) => o.line.id),
1555
+ [Ze]
1556
+ ), St = B(
1557
+ (o) => ce.has(o),
1558
+ [ce]
1559
+ ), ye = E(
1560
+ () => Yt(
1561
+ S,
1562
+ D,
1563
+ M,
1564
+ Ce,
1565
+ St,
1566
+ R
1567
+ ),
1568
+ [S, D, M, Ce, St, R]
1569
+ ), xt = E(
1570
+ () => new Map(S.map((o) => [o.id, o])),
1571
+ [S]
1572
+ ), T = A({
1573
+ lines: S,
1574
+ lineById: xt,
1575
+ itemIndex: ce,
1576
+ defaults: Ce,
1577
+ documentKind: i,
1578
+ scope: R,
1579
+ tableReadOnly: _e,
1580
+ valuesControlled: bt,
1581
+ selectionControlled: Ge
1582
+ });
1583
+ T.current = {
1584
+ lines: S,
1585
+ lineById: xt,
1586
+ itemIndex: ce,
1587
+ defaults: Ce,
1588
+ documentKind: i,
1589
+ scope: R,
1590
+ tableReadOnly: _e,
1591
+ valuesControlled: bt,
1592
+ selectionControlled: Ge
1593
+ };
1594
+ const Le = A({
1595
+ onValuesChange: N,
1596
+ onSelectionChange: O,
1597
+ onSummaryChange: h,
1598
+ onItemQueryChange: p
1599
+ });
1600
+ Le.current = {
1601
+ onValuesChange: N,
1602
+ onSelectionChange: O,
1603
+ onSummaryChange: h,
1604
+ onItemQueryChange: p
1605
+ };
1606
+ const Je = A(/* @__PURE__ */ new Set()), H = B((o) => {
1607
+ for (const f of [...Je.current]) f(o);
1608
+ }, []), ne = B(
1609
+ (o, f, L, C) => {
1610
+ var ie, Oe;
1611
+ const U = T.current;
1612
+ if (!U.lineById.has(o)) return;
1613
+ const z = Ft(U.lines, $.current), s = z[o], u = { ...s, ...L };
1614
+ if (pn(s, u)) return;
1615
+ const q = {
1616
+ ...z,
1617
+ [o]: u
1618
+ };
1619
+ $.current = q, wt.current = q, U.valuesControlled || kn(q), (Oe = (ie = Le.current).onValuesChange) == null || Oe.call(ie, q, { lineId: o, field: f, source: C }), H({ event: "values", source: C });
1620
+ },
1621
+ [H]
1622
+ ), ue = B(
1623
+ (o, f) => {
1624
+ var z, s;
1625
+ const L = T.current, C = G(L.lines, o, L.scope), U = G(
1626
+ L.lines,
1627
+ F.current,
1628
+ L.scope
1629
+ );
1630
+ ur(C, U) || (F.current = C, Nt.current = C, L.selectionControlled || It(C), (s = (z = Le.current).onSelectionChange) == null || s.call(z, C), H({ event: "selection", source: f }));
1631
+ },
1632
+ [H]
1633
+ ), _t = B(
1634
+ (o, f) => ne(o, "quantity", { quantity: f }, "user"),
1635
+ [ne]
1636
+ ), Ct = B(
1637
+ (o, f) => {
1638
+ const L = T.current.lineById.get(o);
1639
+ L && ne(
1640
+ o,
1641
+ "item",
1642
+ { item: lt(f, L) },
1643
+ "user"
1644
+ );
1645
+ },
1646
+ [ne]
1647
+ ), Et = B((o, f) => {
1648
+ var L, C;
1649
+ Tn(o), (C = (L = Le.current).onItemQueryChange) == null || C.call(L, o, f);
1650
+ }, []), _n = B(
1651
+ (o) => ue(o, "user"),
1652
+ [ue]
1653
+ ), Ot = A(null);
1654
+ Ae(() => {
1655
+ var f, L;
1656
+ const o = dr(ye);
1657
+ o !== Ot.current && (Ot.current = o, (L = (f = Le.current).onSummaryChange) == null || L.call(f, ye));
1658
+ }, [ye]);
1659
+ const Ee = `${Q}:${_e ? "readOnly" : "editable"}`, At = A({
1660
+ lines: S,
1661
+ values: D,
1662
+ selection: M,
1663
+ status: Ee
1664
+ });
1665
+ Ae(() => {
1666
+ const o = At.current;
1667
+ (o.lines !== S || o.values !== D && D !== wt.current) && H({ event: "values", source: "host" }), o.selection !== M && M !== Nt.current && H({ event: "selection", source: "host" }), o.status !== Ee && H({ event: "status", source: "host" }), At.current = {
1668
+ lines: S,
1669
+ values: D,
1670
+ selection: M,
1671
+ status: Ee
1672
+ };
1673
+ }, [S, D, M, Ee, H]);
1674
+ const et = E(() => {
1675
+ const o = () => {
1676
+ const s = T.current;
1677
+ return Qt({
1678
+ lines: s.lines,
1679
+ values: $.current,
1680
+ selection: F.current,
1681
+ findItem: (u) => s.itemIndex.get(u),
1682
+ scope: s.scope
1683
+ });
1684
+ }, f = (s) => $i(s, {
1685
+ tableReadOnly: T.current.tableReadOnly,
1686
+ documentKind: T.current.documentKind,
1687
+ scope: T.current.scope
1688
+ }), L = (s) => T.current.itemIndex.has(s), C = (s) => {
1689
+ const u = T.current.lineById.get(s);
1690
+ if (!u) throw re("UNKNOWN_LINE", `no line "${s}".`);
1691
+ return u;
1692
+ }, U = () => {
1693
+ if (T.current.tableReadOnly)
1694
+ throw re(
1695
+ "TABLE_READ_ONLY",
1696
+ "the table is read-only while the load request runs."
1697
+ );
1698
+ }, z = (s) => {
1699
+ const u = T.current.lineById.get(s);
1700
+ if (u && T.current.scope.isLoaded(u))
1701
+ throw re(
1702
+ "LINE_READ_ONLY",
1703
+ `line "${s}" belongs to an invoice that is already loaded.`
1704
+ );
1705
+ };
1706
+ return {
1707
+ getLineIds: () => T.current.lines.map((s) => s.id),
1708
+ getLine: (s) => {
1709
+ const u = T.current, q = u.lineById.get(s);
1710
+ if (!q) return null;
1711
+ const ie = gn(
1712
+ q,
1713
+ $.current[s] ?? X(q),
1714
+ {
1715
+ invoiceLoaded: u.scope.allLoaded,
1716
+ ticked: new Set(
1717
+ G(
1718
+ u.lines,
1719
+ F.current,
1720
+ u.scope
1721
+ )
1722
+ ),
1723
+ findItem: (Oe) => u.itemIndex.get(Oe),
1724
+ scope: u.scope
1725
+ }
1726
+ );
1727
+ return f(ie);
1728
+ },
1729
+ getLines: () => o().map(f),
1730
+ getSelection: () => G(
1731
+ T.current.lines,
1732
+ F.current,
1733
+ T.current.scope
1734
+ ),
1735
+ getValues: () => Ft(T.current.lines, $.current),
1736
+ getSummary: () => {
1737
+ const s = T.current;
1738
+ return Yt(
1739
+ s.lines,
1740
+ $.current,
1741
+ F.current,
1742
+ s.defaults,
1743
+ L,
1744
+ s.scope
1745
+ );
1746
+ },
1747
+ getInvalidLineIds: () => o().filter((s) => s.invalid).map((s) => s.line.id),
1748
+ getLoadPayload: () => {
1749
+ const s = T.current;
1750
+ return Di(
1751
+ s.lines,
1752
+ $.current,
1753
+ F.current,
1754
+ s.documentKind,
1755
+ L,
1756
+ s.scope
1757
+ );
1758
+ },
1759
+ getLoadPayloadByInvoice: () => {
1760
+ const s = T.current;
1761
+ return Mi(
1762
+ s.lines,
1763
+ $.current,
1764
+ F.current,
1765
+ s.documentKind,
1766
+ L,
1767
+ s.scope
1768
+ );
1769
+ },
1770
+ setSelection: (s) => {
1771
+ for (const u of s) C(u);
1772
+ U();
1773
+ for (const u of s) {
1774
+ if (C(u).alreadyLoaded)
1775
+ throw re(
1776
+ "LINE_READ_ONLY",
1777
+ `line "${u}" is already loaded.`
1778
+ );
1779
+ z(u);
1780
+ }
1781
+ ue(s, "api");
1782
+ },
1783
+ selectAll: () => {
1784
+ U(), ue(
1785
+ T.current.lines.map((s) => s.id),
1786
+ "api"
1787
+ );
1788
+ },
1789
+ clearSelection: () => {
1790
+ U(), ue([], "api");
1791
+ },
1792
+ setQuantity: (s, u) => {
1793
+ const q = C(s), ie = Fi(u);
1794
+ if (ie === null)
1795
+ throw re(
1796
+ "INVALID_QUANTITY",
1797
+ `"${u}" is not a quantity above 0 and at most ${ke}, with at most ${de} decimal places.`
1798
+ );
1799
+ if (U(), z(s), !ut(q.quantity))
1800
+ throw re(
1801
+ "LINE_READ_ONLY",
1802
+ `line "${s}" has a quantity too large to edit; it loads as invoiced.`
1803
+ );
1804
+ ne(s, "quantity", { quantity: ie }, "api");
1805
+ },
1806
+ setItem: (s, u) => {
1807
+ const q = C(s);
1808
+ if (u.kind === "existing" && (u.itemId === me || !L(u.itemId)))
1809
+ throw re("UNKNOWN_ITEM", `no item "${u.itemId}".`);
1810
+ U(), z(s), ne(
1811
+ s,
1812
+ "item",
1813
+ { item: lt(u, q) },
1814
+ "api"
1815
+ );
1816
+ },
1817
+ focusLine: (s, u = "select") => {
1818
+ var q;
1819
+ C(s), (q = se.current) == null || q.focusRow(
1820
+ s,
1821
+ u === "select" ? void 0 : u
1822
+ );
1823
+ },
1824
+ scrollToLine: (s) => {
1825
+ var u;
1826
+ C(s), (u = se.current) == null || u.scrollToRow(s);
1827
+ },
1828
+ subscribe: (s) => (Je.current.add(s), () => {
1829
+ Je.current.delete(s);
1830
+ })
1831
+ };
1832
+ }, [ue, ne]);
1833
+ $n(oe, () => et, [et]), zn(ci, et, c);
1834
+ const qt = `${Fn()}-status`, tt = m !== void 0 ? m.length > 0 && m.every(
1835
+ (o) => (o.documentKind ?? i) === "creditNote"
1836
+ ) ? "creditNote" : "invoice" : i, Cn = E(
1837
+ () => sr({
1838
+ t: k,
1839
+ language: te,
1840
+ documentKind: tt,
1841
+ multi: He,
1842
+ currency: a,
1843
+ privacyMode: W,
1844
+ setQuantity: _t,
1845
+ setItem: Ct,
1846
+ queryItems: Et,
1847
+ statusIdPrefix: qt
1848
+ }),
1849
+ [
1850
+ k,
1851
+ te,
1852
+ tt,
1853
+ He,
1854
+ a,
1855
+ W,
1856
+ _t,
1857
+ Ct,
1858
+ Et,
1859
+ qt
1860
+ ]
1861
+ ), En = B((o) => o.line.id, []), On = B((o) => o.readOnly, []), An = B(
1862
+ (o) => {
1863
+ const f = k("billLineTable.rowLabel", {
1864
+ number: K(o.line.lineNumber, te),
1865
+ defaultValue: "Line {{number}}"
1866
+ });
1867
+ return o.invoice ? `${f}, ${o.invoice.header.number}` : f;
1868
+ },
1869
+ [k, te]
1870
+ ), qn = B(
1871
+ (o) => o.groupStart,
1872
+ []
1873
+ ), Vn = B(
1874
+ (o) => o.line.alreadyLoaded ? {
1875
+ state: "none",
1876
+ reason: k(
1877
+ "billLineTable.selection.alreadyLoadedReason",
1878
+ "Already loaded into the warehouse"
1879
+ )
1880
+ } : o.readOnly ? {
1881
+ state: "none",
1882
+ reason: k(
1883
+ "billLineTable.selection.invoiceLoadedReason",
1884
+ "This invoice was already loaded. Lines left out then cannot be loaded later."
1885
+ )
1886
+ } : "selectable",
1887
+ [k]
1888
+ ), Bn = ye.invoiceLoaded, nt = _e ? typeof le == "object" && le.reason !== "" && !W ? le.reason : k(
1889
+ "billLineTable.selection.readOnlyReason",
1890
+ "Loading into the warehouse"
1891
+ ) : Bn ? k(
1892
+ "billLineTable.selection.invoiceLoadedReason",
1893
+ "This invoice was already loaded. Lines left out then cannot be loaded later."
1894
+ ) : null, Rn = E(
1895
+ () => nt === null ? !1 : { reason: nt },
1896
+ [nt]
1897
+ ), Dn = E(
1898
+ () => ({
1899
+ title: (V == null ? void 0 : V.title) ?? k("billLineTable.error.title", "The invoice lines could not be read"),
1900
+ description: (V == null ? void 0 : V.description) ?? k(
1901
+ "billLineTable.error.description",
1902
+ "Try again. If it keeps failing, open the invoice to check it."
1903
+ ),
1904
+ onRetry: V == null ? void 0 : V.onRetry
1905
+ }),
1906
+ [V, k]
1907
+ ), Mn = E(
1908
+ () => ({
1909
+ title: k(
1910
+ "billLineTable.empty.title",
1911
+ "This invoice has no lines to load"
1912
+ ),
1913
+ description: k(
1914
+ "billLineTable.empty.description",
1915
+ "Open the invoice to check what the supplier sent."
1916
+ )
1917
+ }),
1918
+ [k]
1919
+ ), Un = v ?? (tt === "creditNote" ? k("billLineTable.captionCreditNote", "Credit note lines") : k("billLineTable.caption", "Invoice lines"));
1920
+ return /* @__PURE__ */ w(
1921
+ "div",
1922
+ {
1923
+ ...j,
1924
+ "data-component": "bill-line-table",
1925
+ "data-component-id": c,
1926
+ className: ui({ height: xe, className: y }),
1927
+ children: [
1928
+ d && !He ? /* @__PURE__ */ l(
1929
+ Ii,
1930
+ {
1931
+ invoice: d,
1932
+ privacyMode: W
1933
+ }
1934
+ ) : null,
1935
+ /* @__PURE__ */ l(yn.Provider, { value: wn, children: /* @__PURE__ */ l(Se.Provider, { value: ye, children: /* @__PURE__ */ l(
1936
+ Yn,
1937
+ {
1938
+ ref: se,
1939
+ caption: Un,
1940
+ columns: Cn,
1941
+ rows: Ze,
1942
+ getRowId: En,
1943
+ registerAgent: !1,
1944
+ persistColumnState: !1,
1945
+ dataMode: "client",
1946
+ selectionMode: "multiple",
1947
+ rowSelection: xn,
1948
+ onRowSelectionChange: _n,
1949
+ getRowSelectability: Vn,
1950
+ selectAllScope: "all",
1951
+ rangeSelection: !0,
1952
+ isRowReadOnly: On,
1953
+ getRowGroupStart: qn,
1954
+ readOnly: Rn,
1955
+ getRowLabel: An,
1956
+ rowLabelPrivacySafe: !0,
1957
+ hostTextPrivacySafe: !0,
1958
+ multiSort: !1,
1959
+ columnResizing: !1,
1960
+ responsiveColumns: !1,
1961
+ status: Q,
1962
+ error: Dn,
1963
+ empty: Mn,
1964
+ density: "default",
1965
+ height: xe,
1966
+ virtualization: "auto",
1967
+ privacyMode: W
1968
+ }
1969
+ ) }) })
1970
+ ]
1971
+ }
1972
+ );
1973
+ });
1974
+ mr.displayName = "BillLineTable";
1975
+ export {
1976
+ $t as B,
1977
+ ke as a,
1978
+ me as b,
1979
+ Si as c,
1980
+ Ke as d,
1981
+ de as e,
1982
+ on as f,
1983
+ mr as g,
1984
+ an as h,
1985
+ ci as i,
1986
+ Di as j,
1987
+ Mi as k,
1988
+ qi as l,
1989
+ it as m,
1990
+ X as n,
1991
+ Dr as o,
1992
+ Vi as p,
1993
+ Rr as q,
1994
+ mt as r,
1995
+ dt as s,
1996
+ ut as t,
1997
+ Ci as u,
1998
+ Yt as v
1999
+ };
2000
+ //# sourceMappingURL=bill-line-table-DHKb_O7c.js.map