@declarion/react 0.57.0 → 0.59.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 (165) hide show
  1. package/README.md +0 -2
  2. package/dist-lib/AgentChatPanel.impl-DBH1Ff4G.js +1200 -0
  3. package/dist-lib/DetailAuditStrip-GNRA_eP5.js +289 -0
  4. package/dist-lib/{DraggableChildrenTable-BV5sb8Uo.js → DraggableChildrenTable-4RZC351U.js} +87 -86
  5. package/dist-lib/Grid-CQabaBLx.js +405 -0
  6. package/dist-lib/{LayoutRenderer-C9AH9cXf.js → LayoutRenderer-DGKWZKpW.js} +1000 -1114
  7. package/dist-lib/{ListCardsBody-DXcDg536.js → ListCardsBody-DfGmyNIu.js} +84 -84
  8. package/dist-lib/MarkdownRenderer-BDbzDv_y.js +87 -0
  9. package/dist-lib/{RefreshControl-CNtN8zSl.js → RefreshControl-Bhoib0ZA.js} +126 -155
  10. package/dist-lib/SmartDetailPage.impl-Ds2RGg6K.js +1565 -0
  11. package/dist-lib/SmartListPage.impl-BrZLE_Gb.js +3046 -0
  12. package/dist-lib/{SmartRecordListPage.impl-Bkl9aZJ8.js → SmartRecordListPage.impl-C1FJLr80.js} +281 -280
  13. package/dist-lib/SortHeaderMenu-Cijxk4cX.js +107 -0
  14. package/dist-lib/action-dispatch-DY0c8U81.js +1967 -0
  15. package/dist-lib/api/client.d.ts +5 -0
  16. package/dist-lib/api/data.d.ts +2 -4
  17. package/dist-lib/api/entities.d.ts +8 -15
  18. package/dist-lib/api/events.d.ts +3 -3
  19. package/dist-lib/cardProjection-Bkl2SSYz.js +499 -0
  20. package/dist-lib/components/actions/ResponsiveActionBar.d.ts +17 -16
  21. package/dist-lib/components/agents/AgentChatPanel.d.ts +3 -13
  22. package/dist-lib/components/agents/AgentChatPanel.impl.d.ts +14 -0
  23. package/dist-lib/components/agents/AgentPicker.d.ts +1 -2
  24. package/dist-lib/components/chrome/PageShell.d.ts +7 -0
  25. package/dist-lib/components/chrome/RecordHeader.d.ts +1 -2
  26. package/dist-lib/components/detail-layout/DetailAuditStrip.d.ts +1 -2
  27. package/dist-lib/components/detail-layout/DetailHighlights.d.ts +1 -2
  28. package/dist-lib/components/detail-layout/blockMeta.d.ts +2 -1
  29. package/dist-lib/components/fields/BoolField.d.ts +1 -1
  30. package/dist-lib/components/fields/EnumField.d.ts +1 -1
  31. package/dist-lib/components/fields/IntArrayField.d.ts +1 -1
  32. package/dist-lib/components/fields/MultilangArrayField.d.ts +2 -0
  33. package/dist-lib/components/fields/MultilangField.d.ts +1 -1
  34. package/dist-lib/components/fields/MultilangTextField.d.ts +1 -1
  35. package/dist-lib/components/fields/NumberField.d.ts +1 -1
  36. package/dist-lib/components/fields/PasswordField.d.ts +1 -1
  37. package/dist-lib/components/fields/RefCombobox.d.ts +1 -1
  38. package/dist-lib/components/fields/SecretField.d.ts +1 -1
  39. package/dist-lib/components/fields/StringArrayField.d.ts +1 -1
  40. package/dist-lib/components/fields/TimestampField.d.ts +1 -1
  41. package/dist-lib/components/fields/cells/registry.d.ts +2 -1
  42. package/dist-lib/components/fields/index.d.ts +2 -1
  43. package/dist-lib/components/fields/langMap.d.ts +2 -0
  44. package/dist-lib/components/fields/secretValue.d.ts +2 -0
  45. package/dist-lib/components/file-widgets/UnknownFileWidget.d.ts +3 -0
  46. package/dist-lib/components/file-widgets/UploadFailureText.d.ts +4 -0
  47. package/dist-lib/components/file-widgets/helpers.d.ts +1 -1
  48. package/dist-lib/components/file-widgets/host.d.ts +4 -3
  49. package/dist-lib/components/file-widgets/types.d.ts +1 -0
  50. package/dist-lib/components/file-widgets/upload.d.ts +18 -3
  51. package/dist-lib/components/filters/filter-op-label.d.ts +3 -0
  52. package/dist-lib/components/layout/ImpersonationBanner.d.ts +1 -1
  53. package/dist-lib/components/layout/ImpersonationFrame.d.ts +1 -1
  54. package/dist-lib/components/layout/Layout.d.ts +2 -1
  55. package/dist-lib/components/layout/Sidebar.d.ts +2 -1
  56. package/dist-lib/components/layout/TenantChip.d.ts +1 -1
  57. package/dist-lib/components/list/ViewSwitcher.d.ts +4 -2
  58. package/dist-lib/components/pages/DocumentsMenu.d.ts +1 -2
  59. package/dist-lib/components/pages/ExportMenu.d.ts +3 -5
  60. package/dist-lib/components/pages/RecordDocumentsPanel.d.ts +1 -2
  61. package/dist-lib/components/pages/auth/AuthShell.d.ts +4 -31
  62. package/dist-lib/components/pages/exportRequest.d.ts +4 -6
  63. package/dist-lib/components/pages/list/DeleteViewDialog.d.ts +8 -0
  64. package/dist-lib/components/pages/list/ListCardRow.d.ts +1 -2
  65. package/dist-lib/components/pages/list/ListCardsBody.d.ts +0 -1
  66. package/dist-lib/components/pages/list/ListFloatbar.d.ts +2 -2
  67. package/dist-lib/components/pages/list/ListHeader.d.ts +2 -2
  68. package/dist-lib/components/pages/list/ListNoRows.d.ts +4 -5
  69. package/dist-lib/components/pages/list/ListToolbar.d.ts +3 -2
  70. package/dist-lib/components/pages/list/ListUrlBanner.d.ts +10 -0
  71. package/dist-lib/components/pages/list/RowActionsCell.d.ts +2 -4
  72. package/dist-lib/components/pages/list/RowContextMenu.d.ts +1 -2
  73. package/dist-lib/components/pages/list/columns.d.ts +2 -1
  74. package/dist-lib/components/pages/list/filter-meta.d.ts +2 -1
  75. package/dist-lib/components/pages/list/useActiveView.d.ts +38 -0
  76. package/dist-lib/components/pages/list/useListColumnLayout.d.ts +6 -5
  77. package/dist-lib/components/pages/list/useListQuery.d.ts +4 -4
  78. package/dist-lib/components/pages/list/useListSort.d.ts +5 -4
  79. package/dist-lib/components/pages/list/useListViews.d.ts +18 -8
  80. package/dist-lib/components/pages/list/useRowMenu.d.ts +2 -3
  81. package/dist-lib/components/pages/profile/Profile.d.ts +3 -0
  82. package/dist-lib/components/params/ParamsBlock.d.ts +1 -13
  83. package/dist-lib/components/params/param-editors.d.ts +3 -11
  84. package/dist-lib/components/primitives/ClassifiedFieldLocked.d.ts +1 -2
  85. package/dist-lib/components/shared/DynamicIcon.d.ts +2 -2
  86. package/dist-lib/components/shared/LoadingSkeleton.d.ts +1 -0
  87. package/dist-lib/components/shared/LucideIcon.d.ts +1 -1
  88. package/dist-lib/components/shared/useOwnRefresh.d.ts +1 -1
  89. package/dist-lib/declarion-react.css +1 -1
  90. package/dist-lib/embed/theme.d.ts +1 -1
  91. package/dist-lib/embed/useEmbedNavigate.d.ts +1 -1
  92. package/dist-lib/failure-v-uGSpbX.js +158 -0
  93. package/dist-lib/{field-classification-D6xQYn-h.js → field-classification-C28XE-_P.js} +514 -307
  94. package/dist-lib/format-count-DA4wmmWR.js +1771 -0
  95. package/dist-lib/hooks/useEntityData.d.ts +1 -1
  96. package/dist-lib/hooks/useFilters.d.ts +7 -5
  97. package/dist-lib/hooks/useLanguage.d.ts +4 -0
  98. package/dist-lib/hooks/useParams.d.ts +4 -51
  99. package/dist-lib/hooks/useRegisterScreenTab.d.ts +1 -1
  100. package/dist-lib/hooks/useSSE.d.ts +3 -3
  101. package/dist-lib/hooks/useTabTitle.d.ts +2 -0
  102. package/dist-lib/hooks/useText.d.ts +3 -3
  103. package/dist-lib/hooks/useVersionWatcher.d.ts +1 -1
  104. package/dist-lib/hooks/useViews.d.ts +20 -0
  105. package/dist-lib/index.d.ts +8 -7
  106. package/dist-lib/index.js +2716 -5795
  107. package/dist-lib/lib/action-dispatch.d.ts +2 -1
  108. package/dist-lib/lib/actions.d.ts +30 -42
  109. package/dist-lib/lib/anchor.d.ts +3 -4
  110. package/dist-lib/lib/decimal-text.d.ts +1 -0
  111. package/dist-lib/lib/document-templates.d.ts +1 -2
  112. package/dist-lib/lib/download.d.ts +2 -1
  113. package/dist-lib/lib/evidence-verdict.d.ts +2 -1
  114. package/dist-lib/lib/failure.d.ts +2 -0
  115. package/dist-lib/lib/field-classification.d.ts +3 -3
  116. package/dist-lib/lib/filters.d.ts +18 -2
  117. package/dist-lib/lib/format-count.d.ts +8 -7
  118. package/dist-lib/lib/language.d.ts +19 -0
  119. package/dist-lib/lib/mass-edit.d.ts +2 -1
  120. package/dist-lib/lib/realtime-query-keys.d.ts +1 -1
  121. package/dist-lib/lib/realtime-reconcile.d.ts +3 -4
  122. package/dist-lib/lib/screen-back.d.ts +4 -6
  123. package/dist-lib/lib/sort.d.ts +9 -9
  124. package/dist-lib/lib/timestamp.d.ts +5 -7
  125. package/dist-lib/lib/ui-actions.d.ts +2 -1
  126. package/dist-lib/peekDraftStore-D-cTbiIr.js +199 -0
  127. package/dist-lib/registry-Cb3W-czW.js +1950 -0
  128. package/dist-lib/safe-url-oSJw5pzO.js +34 -0
  129. package/dist-lib/stores/icon-registry.d.ts +2 -2
  130. package/dist-lib/stores/list-layout.d.ts +3 -4
  131. package/dist-lib/stores/realtime.d.ts +1 -1
  132. package/dist-lib/stores/tabs.d.ts +3 -2
  133. package/dist-lib/testing.d.ts +6 -0
  134. package/dist-lib/testing.js +98 -76
  135. package/dist-lib/types/api.d.ts +7 -8
  136. package/dist-lib/types/fieldType.d.ts +1 -1
  137. package/dist-lib/types/files.d.ts +4 -4
  138. package/dist-lib/types/schema.d.ts +44 -50
  139. package/dist-lib/useAgentConversation-D97IqE-J.js +623 -0
  140. package/dist-lib/{useCurrentScreen-CzwzQpoW.js → useCurrentScreen-BL5NZFCw.js} +2777 -3768
  141. package/dist-lib/useListQuery-BG1GyKtJ.js +103 -0
  142. package/dist-lib/useProperties-4Lg3odrt.js +83 -0
  143. package/dist-lib/{useTabSearchMirror-C39U85cg.js → useTabSearchMirror-ZVLlINBX.js} +49 -51
  144. package/dist-lib/useText-BFDCTUSo.js +952 -0
  145. package/dist-lib/{value-Bo8C8WMU.js → value-By1-WJ8J.js} +74 -76
  146. package/dist-lib/vite/fingerprint-plugin.d.ts +2 -3
  147. package/package.json +9 -9
  148. package/dist-lib/Grid-DWgUPuZ3.js +0 -404
  149. package/dist-lib/MarkdownRenderer-CcSFc2N3.js +0 -85
  150. package/dist-lib/RecordIdBadge-CGxPR-8q.js +0 -24
  151. package/dist-lib/SmartDetailPage.impl-lskCd-WG.js +0 -1846
  152. package/dist-lib/SmartListPage.impl-CrGbdzyK.js +0 -2854
  153. package/dist-lib/SortHeaderMenu-SYSAaqQJ.js +0 -106
  154. package/dist-lib/action-dispatch-CR4ajBtT.js +0 -1985
  155. package/dist-lib/cardProjection-CW5RIMko.js +0 -699
  156. package/dist-lib/components/pages/home/HomeStub.d.ts +0 -6
  157. package/dist-lib/components/pages/jobs/Jobs.d.ts +0 -1
  158. package/dist-lib/components/pages/pipeline/Pipeline.d.ts +0 -1
  159. package/dist-lib/format-count-Dobmi-Ji.js +0 -1551
  160. package/dist-lib/hooks/useUserLocale.d.ts +0 -1
  161. package/dist-lib/lib/messages.d.ts +0 -12
  162. package/dist-lib/peekDraftStore-5wQ7lq_V.js +0 -194
  163. package/dist-lib/registry-CjgUaF7C.js +0 -1768
  164. package/dist-lib/useListQuery-D7Hr5WM1.js +0 -96
  165. package/dist-lib/useProperties-CqtCzFCr.js +0 -81
@@ -0,0 +1,1565 @@
1
+ import { s as e, t } from "./DynamicIcon-DW5krHuX.js";
2
+ import { An as n, At as r, Cn as i, In as a, Ln as o, Lt as s, Rn as c, W as l, X as u, _n as d, b as f, ct as p, et as ee, gn as m, hn as h, i as g, jn as _, kn as v, mn as y, nn as te, on as b, ot as x, rt as S, ut as ne, vn as re, xn as ie, y as C, yn as ae } from "./useCurrentScreen-BL5NZFCw.js";
3
+ import { r as oe, s as w, t as T } from "./RefreshControl-Bhoib0ZA.js";
4
+ import { $ as se, D as ce, f as le, p as ue, t as E, u as de } from "./useText-BFDCTUSo.js";
5
+ import { c as D, h as O, s as fe } from "./registry-Cb3W-czW.js";
6
+ import { n as pe, r as me, t as he } from "./DetailAuditStrip-GNRA_eP5.js";
7
+ import { a as ge, m as k, n as A, p as j, r as M, t as N, u as P } from "./failure-v-uGSpbX.js";
8
+ import { C as _e, L as ve, M as ye, N as be, O as xe, f as Se, g as Ce, h as we, k as Te, l as Ee, m as De, y as Oe } from "./field-classification-C28XE-_P.js";
9
+ import { c as ke, f as Ae, h as je, m as Me, o as Ne, p as Pe, r as Fe, t as Ie, u as Le } from "./action-dispatch-DY0c8U81.js";
10
+ import { n as Re, r as ze, t as Be } from "./dataTableStyles-vwD1mVOP.js";
11
+ import { a as Ve, i as He, o as Ue, r as We, s as Ge } from "./peekDraftStore-D-cTbiIr.js";
12
+ import { n as Ke, t as qe } from "./LayoutRenderer-DGKWZKpW.js";
13
+ import { t as Je } from "./cardProjection-Bkl2SSYz.js";
14
+ import { Fragment as Ye, useCallback as F, useEffect as I, useMemo as L, useRef as Xe, useState as R } from "react";
15
+ import { useLocation as Ze, useParams as Qe, useSearchParams as $e } from "react-router";
16
+ import { useQuery as z, useQueryClient as et } from "@tanstack/react-query";
17
+ import { Fragment as tt, jsx as B, jsxs as V } from "react/jsx-runtime";
18
+ //#region src/components/chrome/AssociationTabs.tsx
19
+ function nt({ entityCode: e, recordId: n, associations: r, schema: i }) {
20
+ let a = E(), o = L(() => Object.entries(r), [r]), [s, c] = R(0);
21
+ if (o.length === 0) return null;
22
+ let [l, u] = o[s];
23
+ return /* @__PURE__ */ B(O, {
24
+ title: /* @__PURE__ */ B("div", {
25
+ style: {
26
+ display: "flex",
27
+ alignItems: "center",
28
+ gap: 4,
29
+ borderBottom: "1px solid var(--divider)",
30
+ margin: "-10px -14px 0 -14px",
31
+ padding: "0 14px"
32
+ },
33
+ children: o.map(([e, n], r) => {
34
+ let i = r === s;
35
+ return /* @__PURE__ */ V("button", {
36
+ onClick: (e) => {
37
+ e.stopPropagation(), c(r);
38
+ },
39
+ style: {
40
+ display: "inline-flex",
41
+ alignItems: "center",
42
+ gap: 6,
43
+ padding: "10px 12px",
44
+ fontSize: 12.5,
45
+ background: "transparent",
46
+ border: 0,
47
+ borderBottom: `2px solid ${i ? "var(--accent)" : "transparent"}`,
48
+ marginBottom: -1,
49
+ color: i ? "var(--text)" : "var(--text-3)",
50
+ cursor: "pointer",
51
+ fontWeight: i ? 600 : 500
52
+ },
53
+ children: [n.display?.icon && /* @__PURE__ */ B(t, {
54
+ name: n.display.icon,
55
+ size: 13
56
+ }), a(n.display?.name) || e]
57
+ }, e);
58
+ })
59
+ }),
60
+ collapsible: !1,
61
+ padding: "0",
62
+ children: /* @__PURE__ */ B(H, {
63
+ entityCode: e,
64
+ recordId: n,
65
+ assocKey: l,
66
+ association: u,
67
+ schema: i
68
+ })
69
+ });
70
+ }
71
+ function H({ entityCode: t, recordId: n, assocKey: r, association: i, schema: a }) {
72
+ let o = E(), s = E("errors"), l = be(), f = `${t}.${r}`, { data: p, isLoading: ee } = z({
73
+ queryKey: [
74
+ "association",
75
+ f,
76
+ n
77
+ ],
78
+ queryFn: () => k(f, [n])
79
+ }), m = p?.target_entity ?? i.target, h = a.entities[m], g = L(() => p?.ids ?? [], [p?.ids]), _ = L(() => h?.fields.names().find((e) => h.fields.get(e)?.primary) ?? "id", [h]), v = L(() => g.slice(0, 50), [g]), { data: y, isLoading: te } = z({
80
+ queryKey: [
81
+ "association-records",
82
+ m,
83
+ v
84
+ ],
85
+ queryFn: () => j(m, {
86
+ per_page: 50,
87
+ filters: [{
88
+ field: _,
89
+ op: "in",
90
+ value: v
91
+ }]
92
+ }),
93
+ enabled: v.length > 0 && !!h
94
+ }), b = y?.data ?? [], x = y?.$refs, ne = L(() => h ? h.fields.names().filter((e) => {
95
+ let t = h.fields.get(e);
96
+ return t && !t.primary && !t.auto && t.display?.is_listable !== !1;
97
+ }).slice(0, 6) : [], [h]), re = () => {
98
+ let e = u(a, m);
99
+ if (!e) return;
100
+ let t = o(i.display?.name) || r, n = new URLSearchParams();
101
+ n.set("filters", JSON.stringify([{
102
+ field: _,
103
+ op: "in",
104
+ value: g
105
+ }])), l(e.route, {
106
+ title: t,
107
+ icon: i.display?.icon || e.icon,
108
+ search: n.toString()
109
+ });
110
+ }, ie = {
111
+ fontSize: 12.5,
112
+ color: "var(--text-3)",
113
+ padding: "14px 16px"
114
+ };
115
+ if (ee || te) return /* @__PURE__ */ B("div", {
116
+ style: ie,
117
+ children: o("shell.loading", "Loading…")
118
+ });
119
+ if (!h) return /* @__PURE__ */ B("div", {
120
+ style: ie,
121
+ children: s("record.related_entity_not_found", "The related record type is not declared in this deployment.")
122
+ });
123
+ if (g.length === 0) return /* @__PURE__ */ B("div", {
124
+ style: ie,
125
+ children: o("shell.association.empty", "No related records.")
126
+ });
127
+ let C = u(a, m);
128
+ return /* @__PURE__ */ V("div", {
129
+ style: { padding: "8px 0" },
130
+ children: [
131
+ /* @__PURE__ */ V("table", {
132
+ style: ze,
133
+ children: [/* @__PURE__ */ B("thead", { children: /* @__PURE__ */ B("tr", { children: ne.map((e) => /* @__PURE__ */ B("th", {
134
+ style: Re,
135
+ children: d(o, h.fields.get(e), e, a.entities)
136
+ }, e)) }) }), /* @__PURE__ */ B("tbody", { children: b.map((e, t) => /* @__PURE__ */ B("tr", { children: ne.map((t) => {
137
+ let n = h.fields.get(t);
138
+ return n ? /* @__PURE__ */ B("td", {
139
+ style: Be,
140
+ children: S({
141
+ field: n,
142
+ fieldName: t,
143
+ value: e[t],
144
+ mode: "display",
145
+ record: e,
146
+ refs: x,
147
+ t: o
148
+ })
149
+ }, t) : /* @__PURE__ */ B("td", {}, t);
150
+ }) }, t)) })]
151
+ }),
152
+ C && p && p.count > b.length && /* @__PURE__ */ B("div", {
153
+ style: {
154
+ padding: "10px 16px",
155
+ textAlign: "center"
156
+ },
157
+ children: /* @__PURE__ */ B(c, {
158
+ icon: /* @__PURE__ */ B(e.external, { size: 12 }),
159
+ onClick: re,
160
+ children: o("shell.association.view_all", "View all {count} records", { count: p.count })
161
+ })
162
+ }),
163
+ C && b.length > 0 && p && p.count <= b.length && /* @__PURE__ */ B("div", {
164
+ style: {
165
+ padding: "10px 16px",
166
+ textAlign: "center"
167
+ },
168
+ children: /* @__PURE__ */ B(c, {
169
+ kind: "ghost",
170
+ icon: /* @__PURE__ */ B(e.external, { size: 12 }),
171
+ onClick: re,
172
+ children: o("shell.association.open_list", "Open in list view")
173
+ })
174
+ })
175
+ ]
176
+ });
177
+ }
178
+ //#endregion
179
+ //#region src/components/pages/RecordDocumentsPanel.tsx
180
+ var rt = 4e3, U = "pdf";
181
+ function it(e) {
182
+ return e?.some((e) => e.status === "pending") ? rt : !1;
183
+ }
184
+ function at({ entityCode: t, objectId: n, canGenerateOne: r, canManageTemplates: i }) {
185
+ let a = E(), o = E("errors"), { data: s, isLoading: c, error: l } = z({
186
+ queryKey: [
187
+ C,
188
+ t,
189
+ n
190
+ ],
191
+ queryFn: async () => (await P("document.object_links", {
192
+ entity: t,
193
+ object_id: n
194
+ })).result?.documents ?? [],
195
+ enabled: !!(t && n) && (!!r || !!i),
196
+ refetchInterval: (e) => it(e.state.data)
197
+ }), u = (s?.length ?? 0) > 0;
198
+ return !r && !u ? null : /* @__PURE__ */ V(O, {
199
+ title: /* @__PURE__ */ B(W, {}),
200
+ collapsible: !1,
201
+ padding: "0",
202
+ children: [
203
+ c && /* @__PURE__ */ B(G, {
204
+ icon: /* @__PURE__ */ B(e.loader, { size: 14 }),
205
+ text: a("document.panel.loading", "Loading documents...")
206
+ }),
207
+ l && /* @__PURE__ */ B(G, {
208
+ icon: /* @__PURE__ */ B(e.warning, { size: 14 }),
209
+ text: N(o, l)
210
+ }),
211
+ !c && !l && (s?.length ?? 0) === 0 && /* @__PURE__ */ B(G, {
212
+ icon: /* @__PURE__ */ B(e.file, { size: 14 }),
213
+ text: a("document.panel.empty", "No generated documents")
214
+ }),
215
+ !c && !l && s && s.length > 0 && /* @__PURE__ */ B("div", {
216
+ style: {
217
+ display: "flex",
218
+ flexDirection: "column"
219
+ },
220
+ children: s.map((e) => /* @__PURE__ */ B(ot, {
221
+ entityCode: t,
222
+ objectId: n,
223
+ doc: e
224
+ }, e.generated_document_id))
225
+ })
226
+ ]
227
+ });
228
+ }
229
+ function W() {
230
+ let t = E();
231
+ return /* @__PURE__ */ V("div", {
232
+ style: {
233
+ display: "flex",
234
+ alignItems: "center",
235
+ gap: 6,
236
+ margin: "-10px -14px 0 -14px",
237
+ padding: "10px 14px",
238
+ fontSize: 12.5,
239
+ fontWeight: 600,
240
+ color: "var(--text)"
241
+ },
242
+ children: [/* @__PURE__ */ B(e.file, { size: 13 }), t("document.panel.title", "Documents")]
243
+ });
244
+ }
245
+ function ot({ entityCode: t, objectId: n, doc: r }) {
246
+ let i = E(), { data: a } = le(), o = i(a?.entities?.generated_document?.fields.get("status")?.values?.find((e) => e.code === r.status)?.name) || r.status, s = E("errors"), l = et(), [u, d] = R(!1), [f, p] = R(!1), [ee, m] = R(!1), [h, g] = R(!1), [_, v] = R(null), y = i(r.title) || r.filename || r.template_code, te = r.status === "ready" && r.download_url && !h;
247
+ async function b() {
248
+ d(!0), v(null);
249
+ try {
250
+ let e = (await P("document.download_format", {
251
+ generated_document_id: r.generated_document_id,
252
+ format: U
253
+ })).result;
254
+ e?.download_url && await A(s, e.download_url, e.filename);
255
+ } catch (e) {
256
+ M(e) ? (g(!0), v(s("document.artifact_unavailable", "This generated file is not available."))) : v(N(s, e));
257
+ } finally {
258
+ d(!1);
259
+ }
260
+ }
261
+ async function x() {
262
+ if (r.download_url) {
263
+ p(!0), v(null);
264
+ try {
265
+ await A(s, r.download_url, r.filename);
266
+ } catch (e) {
267
+ M(e) ? (g(!0), v(s("document.artifact_unavailable", "This generated file is not available."))) : v(N(s, e));
268
+ } finally {
269
+ p(!1);
270
+ }
271
+ }
272
+ }
273
+ async function S() {
274
+ m(!0), v(null);
275
+ try {
276
+ await P("document.generate", {
277
+ ...r.input ?? {},
278
+ template_code: r.template_code,
279
+ template_source: r.template_source,
280
+ output_format: r.output_format
281
+ }), await l.invalidateQueries({ queryKey: [
282
+ C,
283
+ t,
284
+ n
285
+ ] });
286
+ } catch (e) {
287
+ v(N(s, e));
288
+ } finally {
289
+ m(!1);
290
+ }
291
+ }
292
+ return /* @__PURE__ */ V("div", {
293
+ style: {
294
+ display: "grid",
295
+ gridTemplateColumns: "minmax(0, 1fr) auto",
296
+ gap: 12,
297
+ alignItems: "center",
298
+ padding: "11px 14px",
299
+ borderTop: "1px solid var(--divider)"
300
+ },
301
+ children: [/* @__PURE__ */ V("div", {
302
+ style: { minWidth: 0 },
303
+ children: [
304
+ /* @__PURE__ */ B("div", {
305
+ style: {
306
+ fontSize: 13,
307
+ fontWeight: 600,
308
+ color: "var(--text)",
309
+ overflow: "hidden",
310
+ textOverflow: "ellipsis",
311
+ whiteSpace: "nowrap"
312
+ },
313
+ children: y
314
+ }),
315
+ /* @__PURE__ */ V("div", {
316
+ style: {
317
+ marginTop: 3,
318
+ display: "flex",
319
+ gap: 8,
320
+ alignItems: "center",
321
+ color: "var(--text-3)",
322
+ fontSize: 11.5
323
+ },
324
+ children: [
325
+ /* @__PURE__ */ B("span", { children: r.output_format.toUpperCase() }),
326
+ /* @__PURE__ */ B("span", { children: h ? i("document.row.artifact_missing", "artifact unavailable") : o }),
327
+ /* @__PURE__ */ B("span", { children: r.ready_at || r.created_at })
328
+ ]
329
+ }),
330
+ r.status === "failed" && r.error_text && /* @__PURE__ */ B("div", {
331
+ style: {
332
+ marginTop: 5,
333
+ color: "var(--danger)",
334
+ fontSize: 12
335
+ },
336
+ children: r.error_text
337
+ }),
338
+ _ && /* @__PURE__ */ B("div", {
339
+ style: {
340
+ marginTop: 5,
341
+ color: "var(--danger)",
342
+ fontSize: 12
343
+ },
344
+ children: _
345
+ })
346
+ ]
347
+ }), te ? /* @__PURE__ */ V("div", {
348
+ style: {
349
+ display: "flex",
350
+ gap: 6
351
+ },
352
+ children: [/* @__PURE__ */ B(c, {
353
+ kind: "ghost",
354
+ size: "sm",
355
+ icon: B(u ? e.loader : e.file, { size: 12 }),
356
+ onClick: b,
357
+ disabled: u,
358
+ children: U.toUpperCase()
359
+ }), /* @__PURE__ */ B(c, {
360
+ kind: "default",
361
+ size: "sm",
362
+ icon: B(f ? e.loader : e.download, { size: 12 }),
363
+ onClick: x,
364
+ disabled: f,
365
+ children: i("document.result.download", "Download")
366
+ })]
367
+ }) : h ? /* @__PURE__ */ B(c, {
368
+ kind: "ghost",
369
+ size: "sm",
370
+ icon: B(ee ? e.loader : e.file, { size: 12 }),
371
+ onClick: S,
372
+ disabled: ee,
373
+ children: i("document.row.regenerate", "Regenerate")
374
+ }) : /* @__PURE__ */ B(c, {
375
+ kind: "ghost",
376
+ size: "sm",
377
+ disabled: !0,
378
+ children: r.status === "pending" ? i("document.row.pending", "Pending") : i("document.not_available", "Unavailable")
379
+ })]
380
+ });
381
+ }
382
+ function G({ icon: e, text: t }) {
383
+ return /* @__PURE__ */ V("div", {
384
+ style: {
385
+ display: "flex",
386
+ alignItems: "center",
387
+ gap: 8,
388
+ padding: "14px",
389
+ color: "var(--text-3)",
390
+ fontSize: 12.5
391
+ },
392
+ children: [e, t]
393
+ });
394
+ }
395
+ //#endregion
396
+ //#region src/components/detail-layout/ErrorSummary.tsx
397
+ function st({ errors: t, onJump: n }) {
398
+ let r = E();
399
+ return t.length === 0 ? null : /* @__PURE__ */ V("div", {
400
+ role: "alert",
401
+ style: {
402
+ display: "flex",
403
+ gap: 10,
404
+ padding: "10px 12px",
405
+ marginBottom: 12,
406
+ borderRadius: 8,
407
+ background: "var(--danger-soft)",
408
+ border: "1px solid var(--danger-border)",
409
+ color: "var(--text)"
410
+ },
411
+ children: [/* @__PURE__ */ B("span", {
412
+ style: {
413
+ color: "var(--danger)",
414
+ marginTop: 1,
415
+ display: "flex"
416
+ },
417
+ children: /* @__PURE__ */ B(e.warning, { size: 14 })
418
+ }), /* @__PURE__ */ V("div", {
419
+ style: {
420
+ flex: 1,
421
+ minWidth: 0
422
+ },
423
+ children: [/* @__PURE__ */ B("div", {
424
+ style: {
425
+ fontSize: 12.5,
426
+ fontWeight: 600,
427
+ marginBottom: 4
428
+ },
429
+ children: de(r, "record.errors.summary", t.length, {
430
+ one: "{count} field needs attention",
431
+ other: "{count} fields need attention"
432
+ })
433
+ }), /* @__PURE__ */ B("ul", {
434
+ style: {
435
+ margin: 0,
436
+ padding: 0,
437
+ listStyle: "none",
438
+ display: "flex",
439
+ flexDirection: "column",
440
+ gap: 2
441
+ },
442
+ children: t.map((e) => /* @__PURE__ */ B("li", { children: /* @__PURE__ */ V("button", {
443
+ type: "button",
444
+ onClick: n ? () => n(e.name) : void 0,
445
+ style: {
446
+ background: "transparent",
447
+ border: 0,
448
+ padding: 0,
449
+ cursor: n ? "pointer" : "default",
450
+ fontSize: 12,
451
+ textAlign: "left",
452
+ fontFamily: "inherit"
453
+ },
454
+ children: [
455
+ /* @__PURE__ */ B("span", {
456
+ style: {
457
+ color: "var(--danger)",
458
+ marginRight: 6
459
+ },
460
+ children: "•"
461
+ }),
462
+ /* @__PURE__ */ B("span", {
463
+ style: {
464
+ fontWeight: 500,
465
+ color: "var(--text-2)"
466
+ },
467
+ children: e.label
468
+ }),
469
+ /* @__PURE__ */ V("span", {
470
+ style: { color: "var(--text-3)" },
471
+ children: [" - ", e.message]
472
+ })
473
+ ]
474
+ }) }, e.name))
475
+ })]
476
+ })]
477
+ });
478
+ }
479
+ //#endregion
480
+ //#region src/components/chrome/HighlightsStrip.tsx
481
+ function K({ items: e }) {
482
+ return e.length === 0 ? null : /* @__PURE__ */ B("div", {
483
+ style: {
484
+ display: "flex",
485
+ alignItems: "center",
486
+ flexWrap: "wrap",
487
+ gap: "6px 0",
488
+ fontSize: 12
489
+ },
490
+ children: e.map((e, t) => /* @__PURE__ */ V(Ye, { children: [t > 0 && /* @__PURE__ */ B("span", { style: {
491
+ width: 1,
492
+ height: 12,
493
+ background: "var(--divider)",
494
+ marginInline: 12
495
+ } }), /* @__PURE__ */ V("span", {
496
+ style: {
497
+ display: "inline-flex",
498
+ alignItems: "center",
499
+ gap: 6,
500
+ lineHeight: 1.3
501
+ },
502
+ children: [/* @__PURE__ */ B("span", {
503
+ style: {
504
+ color: "var(--text-3)",
505
+ fontSize: 11.5
506
+ },
507
+ children: e.label
508
+ }), /* @__PURE__ */ B("span", {
509
+ style: { color: "var(--text)" },
510
+ children: e.value
511
+ })]
512
+ })] }, t))
513
+ });
514
+ }
515
+ //#endregion
516
+ //#region src/components/detail-layout/DetailHighlights.tsx
517
+ function ct({ screen: e, entity: t, entityCode: n, record: r, refs: i, objectStatuses: o, schema: s }) {
518
+ let c = E(), l = e.highlights;
519
+ if (!l || l.length === 0) return null;
520
+ let u = [];
521
+ for (let e of l) {
522
+ let l = t.status_groups?.[e];
523
+ if (l) {
524
+ let t = o?.find((t) => t.group_code === e), n = t ? l.statuses.find((e) => e.code === t.status_code) : void 0;
525
+ u.push({
526
+ label: c(l.name),
527
+ value: n ? /* @__PURE__ */ B(a, {
528
+ tone: n.color ?? "slate",
529
+ size: "xs",
530
+ children: c(n.name)
531
+ }) : /* @__PURE__ */ B("span", {
532
+ style: { color: "var(--text-4)" },
533
+ children: "—"
534
+ })
535
+ });
536
+ continue;
537
+ }
538
+ if (t.fields.get(e) || t.files?.get(e)) {
539
+ let a = Pe({
540
+ entity: t,
541
+ entityCode: n,
542
+ fieldName: e,
543
+ record: r,
544
+ mode: "display",
545
+ refs: i,
546
+ entities: s.entities,
547
+ screens: s.screens,
548
+ surface: "list",
549
+ t: c
550
+ });
551
+ u.push({
552
+ label: Me(c, t, e, s.entities),
553
+ value: a
554
+ });
555
+ continue;
556
+ }
557
+ }
558
+ return u.length === 0 ? null : /* @__PURE__ */ B(K, { items: u });
559
+ }
560
+ //#endregion
561
+ //#region src/components/detail-layout/EvidenceBlock.tsx
562
+ function lt(e, t) {
563
+ if (!e) return;
564
+ let n = new Date(e);
565
+ if (!Number.isNaN(n.getTime())) return n.toLocaleString(t);
566
+ }
567
+ function ut({ evidence: e }) {
568
+ let t = E(), n = e?.verdict ?? "unverified", r = lt(e?.verified_at, t.language), i = [];
569
+ return r && i.push(t("record.evidence.verified", "Verified {when}", { when: r })), e?.seq && i.push(t("record.evidence.chain", "chain #{seq}", { seq: e.seq })), e?.checkpoint_number && i.push(t("record.evidence.checkpoint", "checkpoint {number}", { number: e.checkpoint_number })), e?.generation && i.push(t("record.evidence.generation", "generation {number}", { number: e.generation })), /* @__PURE__ */ V("div", {
570
+ style: {
571
+ display: "flex",
572
+ flexDirection: "column",
573
+ gap: 6
574
+ },
575
+ children: [/* @__PURE__ */ V("div", {
576
+ style: {
577
+ display: "flex",
578
+ alignItems: "center",
579
+ gap: 10,
580
+ flexWrap: "wrap"
581
+ },
582
+ children: [
583
+ /* @__PURE__ */ B("span", {
584
+ style: {
585
+ fontSize: 12,
586
+ fontWeight: 600,
587
+ color: "var(--muted-foreground)"
588
+ },
589
+ children: t("record.evidence.title", "Evidence")
590
+ }),
591
+ /* @__PURE__ */ B(a, {
592
+ tone: Ve(n),
593
+ size: "sm",
594
+ dot: !0,
595
+ children: He(t, n)
596
+ }),
597
+ i.length > 0 && /* @__PURE__ */ B("span", {
598
+ style: {
599
+ fontSize: 12,
600
+ color: "var(--muted-foreground)"
601
+ },
602
+ children: i.join(" · ")
603
+ })
604
+ ]
605
+ }), e?.reason && /* @__PURE__ */ B("span", {
606
+ style: {
607
+ fontSize: 12,
608
+ color: "var(--destructive)"
609
+ },
610
+ children: e.reason
611
+ })]
612
+ });
613
+ }
614
+ //#endregion
615
+ //#region src/lib/children-validation.ts
616
+ function dt(e, t, n) {
617
+ let r = [];
618
+ for (let [i, a] of e.fields) {
619
+ if (!a.required || a.auto || n && a.primary || e.tenant_key && i === e.tenant_key || a.default !== void 0 && a.default !== null) continue;
620
+ let o = t[i];
621
+ (o == null || o === "") && r.push(i);
622
+ }
623
+ return r;
624
+ }
625
+ var ft = /^[^@\s]+@[^@\s]+\.[^@\s]+$/;
626
+ function pt(e, t) {
627
+ let n = [];
628
+ for (let [r, i] of e.fields) {
629
+ if (i.type !== "email") continue;
630
+ let e = t[r];
631
+ typeof e == "string" && e !== "" && !ft.test(e) && n.push(r);
632
+ }
633
+ return n;
634
+ }
635
+ function mt(e, t) {
636
+ let n = /* @__PURE__ */ new Set();
637
+ for (let r of Object.values(t.entities)) if (r.children) {
638
+ for (let t of r.children) if (t.entity === e && t.foreign_key) {
639
+ let e = Array.isArray(t.foreign_key) ? t.foreign_key : [t.foreign_key];
640
+ for (let t of e) n.add(t);
641
+ }
642
+ }
643
+ return n;
644
+ }
645
+ function ht(e, t) {
646
+ if (!e || !t) return {};
647
+ let n = {};
648
+ for (let [r, i] of Object.entries(e)) {
649
+ let e = t.entities[r];
650
+ if (!e) continue;
651
+ let a = mt(r, t), o = [];
652
+ for (let [t, n] of e.fields) e.tenant_key && t === e.tenant_key || n.required && !n.auto && !n.primary && !a.has(t) && o.push(t);
653
+ if (o.length !== 0) for (let e of i) {
654
+ if (e._deleted) continue;
655
+ let t = [];
656
+ for (let n of o) {
657
+ let r = e[n];
658
+ (r == null || r === "") && t.push(n);
659
+ }
660
+ t.length > 0 && (n[r] || (n[r] = {}), n[r][e._key] = t);
661
+ }
662
+ }
663
+ return n;
664
+ }
665
+ //#endregion
666
+ //#region src/components/pages/SmartDetailPage.impl.tsx
667
+ var gt = () => {};
668
+ function _t(e, t) {
669
+ return e.length === t.length && JSON.stringify(e) === JSON.stringify(t);
670
+ }
671
+ function vt(e, t) {
672
+ if (e) {
673
+ let n = m(e, t), r = i(n);
674
+ if (r.replace(/^\|+|\|+$/g, "")) return r;
675
+ }
676
+ return t.id == null ? crypto.randomUUID() : _(t.id);
677
+ }
678
+ function q({ screenCode: e }) {
679
+ return /* @__PURE__ */ B(x, { children: /* @__PURE__ */ B(yt, { screenCode: e }) });
680
+ }
681
+ function yt({ screenCode: t }) {
682
+ let a = E(), c = E("errors"), { id: l } = Qe(), u = r(), [ee, g] = $e(), { data: _ } = le(), te = ue((e) => e.user), x = p(), S = b(), C = _?.screens[t], w = C?.entity ? _?.entities[C.entity] : void 0, T = C?.entity, de = h(w, "create"), O = h(w, "update"), pe = h(w, "restore"), ge = (() => {
683
+ if (!w || !w.singleton || !w.prefilter) return;
684
+ let e = ae(w);
685
+ if (e.length !== 1) return;
686
+ let t = w.prefilter[e[0]];
687
+ if (t === "$caller.user_id") return te?.id;
688
+ if (t === "$caller.tenant_id") return te?.tenant?.id;
689
+ })(), k = ge !== void 0, A = k ? ge : l, j = !k && A === "new", M = L(() => {
690
+ if (!A || j) return;
691
+ if (!w) return A;
692
+ let e = ae(w);
693
+ if (e.length === 1) return { [e[0]]: A };
694
+ let t = ie(A, e.length);
695
+ if (!t) return;
696
+ let n = {};
697
+ for (let r = 0; r < e.length; r++) n[e[r]] = t[r] ?? "";
698
+ return n;
699
+ }, [
700
+ A,
701
+ j,
702
+ w
703
+ ]), N = L(() => {
704
+ if (M) return typeof M == "string" ? M : i(M);
705
+ }, [M]), P = D(T, M), { data: be, isLoading: ke, error: Me } = P, Ne = f(w?.realtime, T ?? ""), Pe = T ? Ne : !1;
706
+ Oe(fe(T, M), !j);
707
+ let Ie = Se(T ?? ""), Re = we(T ?? ""), ze = De(T ?? ""), Be = Object.keys(w?.status_groups ?? {}).length > 0, Ve = be?.data, He = Ve?.$statuses, Ge = Ve?.$properties, Ye = ee.get("edit") === "true", [z, et] = R(j || Ye), [H, rt] = R({}), [U, it] = R({}), [W, ot] = R({}), [G, K] = R(void 0), [lt, ft] = R(!1), [mt, q] = R(void 0), [yt, xt] = R(!1), St = j ? de : O, J = z && St, wt = ce();
708
+ s(J && !j, wt.enabled);
709
+ let [Tt, Et] = R(() => {
710
+ let e = parseInt(C?.sidebar_width || "380", 10);
711
+ return isNaN(e) ? 380 : e;
712
+ }), Dt = Xe(null), Ot = Xe(null), kt = F((e) => {
713
+ e.preventDefault();
714
+ let t = Dt.current;
715
+ if (!t) return;
716
+ let n = t.offsetWidth;
717
+ Ot.current = {
718
+ startX: e.clientX,
719
+ startW: n
720
+ };
721
+ let r = (e) => {
722
+ if (!Ot.current) return;
723
+ let n = Ot.current.startX - e.clientX, r = Math.max(280, Math.min(800, Ot.current.startW + n));
724
+ t.style.width = `${r}px`;
725
+ }, i = () => {
726
+ Ot.current && t && Et(parseInt(t.style.width, 10) || Ot.current.startW), Ot.current = null, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i);
727
+ };
728
+ document.addEventListener("mousemove", r), document.addEventListener("mouseup", i);
729
+ }, []), Y = be?.data, X = Fe(w, C, Y ?? {});
730
+ I(() => {
731
+ let e = parseInt(X?.sidebar_width || "380", 10);
732
+ Et(Number.isNaN(e) ? 380 : e);
733
+ }, [X?.sidebar_width]);
734
+ let Z = typeof Y?.$row_version == "string" ? Y.$row_version : void 0, At = Y?.$refs, jt = Xe(Z);
735
+ I(() => {
736
+ if (!Z) return;
737
+ let e = jt.current;
738
+ jt.current = Z, e && e !== Z && z && ft(!0);
739
+ }, [z, Z]);
740
+ let Mt = !!w?.soft_delete && Y != null && Y[w.soft_delete] != null, Nt = Ze(), Pt = Xe(null);
741
+ oe({ scrollElementRef: Pt });
742
+ let Ft = !j && Me instanceof se && Me.status === 404, It = j && !y(w), Lt = Xe(null);
743
+ I(() => {
744
+ if (!Ft) return;
745
+ let e = _e(Nt);
746
+ Lt.current !== e && (Lt.current = e, ye.getState().kill(e));
747
+ }, [Ft, Nt]);
748
+ let { openTab: Rt, updateTabTitle: zt, findTabByPathname: Bt } = ve();
749
+ I(() => {
750
+ if (!w || k || wt.enabled) return;
751
+ let e = Nt.pathname, t = a(X?.display?.name) || a(w.display.name), n = X?.display?.icon || w.display.icon;
752
+ Bt(e) || Rt({
753
+ pathname: e,
754
+ search: "",
755
+ title: j ? a("record.new_title", "New {name}", { name: t }) : t,
756
+ derivedTitle: !j,
757
+ icon: n,
758
+ closable: !0
759
+ });
760
+ }, [
761
+ Nt.pathname,
762
+ a,
763
+ X?.display?.icon,
764
+ w?.display.icon,
765
+ j,
766
+ k,
767
+ wt.enabled
768
+ ]), I(() => {
769
+ if (!Y || !w || k || wt.enabled) return;
770
+ let e = Bt(Nt.pathname);
771
+ if (e) {
772
+ let t = a(X?.display?.name) || a(w.display.name), n = re(a, Y, w), r = n && !String(n).startsWith("/") ? String(n) : t;
773
+ zt(e.id, r, r === t);
774
+ }
775
+ }, [
776
+ Y,
777
+ a,
778
+ w?.display.display_field,
779
+ Nt.pathname,
780
+ k,
781
+ wt.enabled
782
+ ]);
783
+ let Vt = L(() => {
784
+ if (!w || !St) return /* @__PURE__ */ new Set();
785
+ let e = /* @__PURE__ */ new Set();
786
+ for (let [t, n] of w.fields) !n.auto && !n.primary && e.add(t);
787
+ for (let [t] of w.files ?? []) e.add(t);
788
+ return e;
789
+ }, [w, St]);
790
+ I(() => {
791
+ if (Ye && Y && w && O) {
792
+ if (z || et(!0), Object.keys(H).length === 0) {
793
+ let e = A ? We(A) : null;
794
+ if (e) {
795
+ let t = xe({
796
+ entity: w,
797
+ formData: e,
798
+ record: void 0,
799
+ isNew: !0
800
+ });
801
+ Te(t).forEach((e) => {
802
+ x.registerDraft({
803
+ fileId: e,
804
+ discard: () => ne(e)
805
+ });
806
+ });
807
+ }
808
+ let t = {};
809
+ Vt.forEach((n) => {
810
+ let r = e ? e[n] : void 0;
811
+ if (r !== void 0) {
812
+ t[n] = r;
813
+ return;
814
+ }
815
+ let i = Ae(w, Y, n);
816
+ t[n] = Le(w, n) ? i ?? null : i ?? "";
817
+ }), rt(t);
818
+ }
819
+ if (w.children !== void 0 && w.children.length > 0 && G === void 0) {
820
+ let e = Y.$children;
821
+ if (e && Object.keys(e).length > 0) {
822
+ let t = {};
823
+ for (let [n, r] of Object.entries(e)) {
824
+ let e = _?.entities[n];
825
+ t[n] = r.map((t) => ({
826
+ ...t,
827
+ _key: vt(e, t)
828
+ }));
829
+ }
830
+ K(t), q(e);
831
+ } else K({}), q({});
832
+ }
833
+ g((e) => {
834
+ let t = new URLSearchParams(e);
835
+ return t.delete("edit"), t;
836
+ }, { replace: !0 });
837
+ }
838
+ }, [
839
+ Ye,
840
+ Y,
841
+ Vt,
842
+ O,
843
+ w,
844
+ G,
845
+ _
846
+ ]), I(() => {
847
+ j && de && w?.children && w.children.length !== 0 && G === void 0 && (K({}), q({}));
848
+ }, [
849
+ j,
850
+ de,
851
+ w?.children
852
+ ]);
853
+ let Ht = F(async () => {
854
+ if (await x.flushAllDrafts(), j) {
855
+ let e = X?.route?.replace("/:id", "") ?? "/";
856
+ u(e);
857
+ } else et(!1), rt({}), it({}), ot({}), K(void 0), q(void 0), xt(!1);
858
+ }, [
859
+ x,
860
+ j,
861
+ X,
862
+ u
863
+ ]), Ut = F((e, t) => {
864
+ rt((n) => ({
865
+ ...n,
866
+ [e]: t
867
+ }));
868
+ }, []), Q = L(() => {
869
+ if (!X?.route) return "/";
870
+ let e = X.route.split("/");
871
+ return e.pop(), e.join("/") || "/";
872
+ }, [X]), Wt = L(() => !_?.screens || !Q || Q === "/" ? !1 : Object.values(_.screens).some((e) => e.route === Q), [_, Q]), Gt = F(() => {
873
+ if (!Wt) {
874
+ u("/");
875
+ return;
876
+ }
877
+ let e = Bt(Q)?.search ?? "";
878
+ u(e ? `${Q}?${e}` : Q);
879
+ }, [
880
+ Wt,
881
+ Q,
882
+ Bt,
883
+ u
884
+ ]), Kt = Ce({ fallback: Gt }), qt = !k && (Kt.hasOriginBack || Kt.allowFallbackBack && !!Wt), Jt = L(() => {
885
+ if (!w) return {};
886
+ let e = {};
887
+ for (let t of dt(w, H, j)) Vt.has(t) && (e[t] = a("record.field.required", "Required"));
888
+ for (let t of pt(w, H)) Vt.has(t) && (e[t] = c("record.email_invalid", "This is not a valid email address."));
889
+ return e;
890
+ }, [
891
+ a,
892
+ c,
893
+ w,
894
+ H,
895
+ j,
896
+ Vt
897
+ ]), Yt = Object.keys(Jt).length > 0, Xt = F(() => {
898
+ if (!T || !w || j && !de || !j && !O || (xt(!0), Yt)) return;
899
+ let e = {}, t = xe({
900
+ entity: w,
901
+ formData: H,
902
+ record: Y,
903
+ isNew: j
904
+ }), n = Te(t);
905
+ if (j) for (let [t, n] of Object.entries(H)) {
906
+ if (w.files?.has(t)) continue;
907
+ let r = je(w, t, n);
908
+ r !== "" && r != null && (e[t] = r);
909
+ }
910
+ else {
911
+ for (let [t, n] of Object.entries(H)) {
912
+ if (w.files?.has(t)) continue;
913
+ let r = Y ? Ae(w, Y, t) : void 0, i = je(w, t, n), a = je(w, t, r);
914
+ (i === "" ? null : i) !== (a === "" || a === void 0 ? null : a) && (e[t] = i);
915
+ }
916
+ Z && (e.$row_version = Z);
917
+ }
918
+ if (Object.keys(t).length > 0 && (e.$files = t), Object.keys(U).length > 0 && (e.$statuses = Object.entries(U).map(([e, t]) => ({
919
+ status_group_code: e,
920
+ status_code: t
921
+ }))), Object.keys(W).length > 0 && (e.$properties = Object.entries(W).map(([e, t]) => ({
922
+ property_code: e,
923
+ value: t
924
+ }))), G) {
925
+ let t = {};
926
+ for (let [e, n] of Object.entries(G)) {
927
+ let r = n.filter((e) => !e._deleted).map((e) => {
928
+ let { _key: t, _deleted: n, _dirty: r, ...i } = e;
929
+ return i;
930
+ }), i = mt?.[e] ?? [];
931
+ (j || !_t(r, i)) && (t[e] = r);
932
+ }
933
+ Object.keys(t).length > 0 && (e.$children = t);
934
+ }
935
+ if (!j && Object.keys(e).length === 0) {
936
+ et(!1), it({}), ot({}), K(void 0), q(void 0), xt(!1);
937
+ return;
938
+ }
939
+ let r = () => {
940
+ et(!1), ft(!1), xt(!1), it({}), ot({}), K(void 0), q(void 0);
941
+ };
942
+ j ? Ie.mutate(e, { onSuccess: (e) => {
943
+ n.forEach((e) => x.markCommitted(e));
944
+ let t = e.data, a = w ? m(w, t) : {}, o = i(a);
945
+ u(o ? `${Q}/${encodeURIComponent(o)}` : Q, { replace: !0 }), r();
946
+ } }) : M && Re.mutate({
947
+ pkValues: M,
948
+ data: e
949
+ }, {
950
+ onSuccess: () => {
951
+ n.forEach((e) => x.markCommitted(e)), r();
952
+ },
953
+ onError: (e) => {
954
+ e instanceof se && e.code === "entity.stale_object" && ft(!0);
955
+ }
956
+ });
957
+ }, [
958
+ x,
959
+ j,
960
+ de,
961
+ O,
962
+ T,
963
+ H,
964
+ Yt,
965
+ U,
966
+ W,
967
+ G,
968
+ mt,
969
+ Ie,
970
+ Re,
971
+ w,
972
+ u,
973
+ Q,
974
+ Y,
975
+ Z,
976
+ M
977
+ ]), Zt = F((e, t) => {
978
+ K((n) => ({
979
+ ...n ?? {},
980
+ [e]: t
981
+ }));
982
+ }, []), Qt = F(() => {
983
+ M && !j && pe && ze.mutate(M);
984
+ }, [
985
+ M,
986
+ j,
987
+ pe,
988
+ ze
989
+ ]), $t = L(() => ht(G, _), [G, _]), en = Object.keys($t).length > 0;
990
+ if (!X || !w) return null;
991
+ if (!j && ke) return /* @__PURE__ */ B(Ee, {});
992
+ if (It) return /* @__PURE__ */ V("div", {
993
+ style: { padding: 24 },
994
+ children: [/* @__PURE__ */ V("div", {
995
+ style: {
996
+ display: "flex",
997
+ alignItems: "center",
998
+ gap: 8,
999
+ marginBottom: 8
1000
+ },
1001
+ children: [qt && /* @__PURE__ */ B(o, {
1002
+ icon: /* @__PURE__ */ B(e.back, { size: 14 }),
1003
+ onClick: Kt.goBack,
1004
+ title: a("record.back", "Back")
1005
+ }), /* @__PURE__ */ B("h1", {
1006
+ style: {
1007
+ margin: 0,
1008
+ fontSize: 18,
1009
+ fontWeight: 600,
1010
+ color: "var(--text)"
1011
+ },
1012
+ children: a("record.create_closed.title", "Not Available")
1013
+ })]
1014
+ }), /* @__PURE__ */ B("p", {
1015
+ style: { color: "var(--text-3)" },
1016
+ children: a("record.create_closed.body", "This record type is not created from a form.")
1017
+ })]
1018
+ });
1019
+ if (!j && !Y || Ft) return /* @__PURE__ */ V("div", {
1020
+ style: { padding: 24 },
1021
+ children: [/* @__PURE__ */ V("div", {
1022
+ style: {
1023
+ display: "flex",
1024
+ alignItems: "center",
1025
+ gap: 8,
1026
+ marginBottom: 8
1027
+ },
1028
+ children: [qt && /* @__PURE__ */ B(o, {
1029
+ icon: /* @__PURE__ */ B(e.back, { size: 14 }),
1030
+ onClick: Kt.goBack,
1031
+ title: a("record.back", "Back")
1032
+ }), /* @__PURE__ */ B("h1", {
1033
+ style: {
1034
+ margin: 0,
1035
+ fontSize: 18,
1036
+ fontWeight: 600,
1037
+ color: "var(--text)"
1038
+ },
1039
+ children: a("record.missing.title", "Not Found")
1040
+ })]
1041
+ }), /* @__PURE__ */ B("p", {
1042
+ style: { color: "var(--text-3)" },
1043
+ children: c("entity.not_found", "This record does not exist.")
1044
+ })]
1045
+ });
1046
+ let tn = w.display, nn = a(X.display?.name) || a(tn.name), rn = re(a, Y, w), an = j ? a("record.new_title", "New {name}", { name: nn }) : rn ? String(rn) : nn, on = Ie.isPending || Re.isPending, sn = X.responsive?.[S.category]?.layout, cn = sn?.tabs ?? (S.isPhone ? "sections" : void 0), ln = sn?.header_card === !0 ? Je({
1047
+ entity: w,
1048
+ screen: X
1049
+ }) : void 0, $ = {
1050
+ schema: _,
1051
+ entity: w,
1052
+ entityCode: T,
1053
+ recordId: N ?? A ?? "",
1054
+ record: J ? {
1055
+ ...Y ?? {},
1056
+ ...H
1057
+ } : Y ?? {},
1058
+ isNew: j,
1059
+ mode: J ? "edit" : "display",
1060
+ onFieldChange: J ? Ut : void 0,
1061
+ refs: At,
1062
+ objectProperties: (() => {
1063
+ let e = Ge ?? [];
1064
+ if (!J || Object.keys(W).length === 0) return e.length > 0 ? e : void 0;
1065
+ let t = e.map((e) => W[e.property_code] === void 0 ? e : {
1066
+ ...e,
1067
+ value: W[e.property_code]
1068
+ });
1069
+ for (let [n, r] of Object.entries(W)) e.some((e) => e.property_code === n) || t.push({
1070
+ property_code: n,
1071
+ name: {},
1072
+ type: "string",
1073
+ value: r
1074
+ });
1075
+ return t;
1076
+ })(),
1077
+ onSetProperty: j || !O ? void 0 : J ? (e, t) => ot((n) => ({
1078
+ ...n,
1079
+ [e]: t
1080
+ })) : void 0,
1081
+ isPropertyPending: !1,
1082
+ objectStatuses: (() => {
1083
+ let e = He ?? [];
1084
+ if (!J || Object.keys(U).length === 0) return e.length > 0 ? e : void 0;
1085
+ let t = e.map((e) => U[e.group_code] === void 0 ? e : {
1086
+ ...e,
1087
+ status_code: U[e.group_code]
1088
+ });
1089
+ for (let [r, i] of Object.entries(U)) e.some((e) => e.group_code === r) || t.push({
1090
+ group_code: r,
1091
+ status_code: i,
1092
+ status_name: {},
1093
+ set_at: n()
1094
+ });
1095
+ return t;
1096
+ })(),
1097
+ onSetStatus: j || !O ? void 0 : J ? (e, t) => it((n) => ({
1098
+ ...n,
1099
+ [e]: t
1100
+ })) : void 0,
1101
+ isStatusPending: !1,
1102
+ pendingChildren: J ? G : void 0,
1103
+ onChildrenChange: J ? Zt : void 0,
1104
+ childValidationErrors: J ? $t : void 0,
1105
+ fieldErrors: J && yt ? Jt : void 0,
1106
+ detailTabsPresentation: cn,
1107
+ relatedRecordsPresentation: sn?.related_records
1108
+ }, un = !!X.sidebar && X.sidebar.length > 0, dn = sn?.sidebar === "hidden", fn = un && !dn && !S.isDesktop, pn = un && !dn && S.isDesktop, mn = !j && Y ? /* @__PURE__ */ B(ct, {
1109
+ screen: X,
1110
+ entity: w,
1111
+ entityCode: T,
1112
+ record: Y,
1113
+ refs: At,
1114
+ objectStatuses: He,
1115
+ schema: _
1116
+ }) : void 0, hn = /* @__PURE__ */ B(Ct, {
1117
+ title: an,
1118
+ recordId: A,
1119
+ editing: J,
1120
+ isNew: j,
1121
+ isRecordDeleted: Mt,
1122
+ dirty: z,
1123
+ isSaving: on,
1124
+ hasChildErrors: en,
1125
+ hasFieldErrors: yt && Yt,
1126
+ canRestore: pe,
1127
+ entity: w,
1128
+ screen: X,
1129
+ globalActions: _?.actions,
1130
+ entityCode: T,
1131
+ record: Y,
1132
+ id: A,
1133
+ listRoute: Q,
1134
+ listRouteExists: !!Wt,
1135
+ highlights: mn,
1136
+ showBack: qt,
1137
+ onBack: Kt.goBack,
1138
+ onCancelEdit: Ht,
1139
+ onSave: Xt,
1140
+ onRestore: Qt,
1141
+ isRestoring: ze.isPending,
1142
+ refreshControl: {
1143
+ refetch: P.refetch,
1144
+ isLoading: P.isLoading,
1145
+ isLive: Pe
1146
+ },
1147
+ isRealtimeEntity: w?.realtime === !0,
1148
+ canManageTemplates: Ue(_)
1149
+ }), gn = Mt && /* @__PURE__ */ V("div", {
1150
+ style: {
1151
+ display: "flex",
1152
+ alignItems: "center",
1153
+ gap: 8,
1154
+ padding: "10px 14px",
1155
+ marginBottom: 12,
1156
+ borderRadius: 8,
1157
+ border: "1px solid var(--danger)",
1158
+ background: "var(--danger-soft)",
1159
+ color: "var(--danger)",
1160
+ fontSize: 12.5
1161
+ },
1162
+ children: [/* @__PURE__ */ B(e.warning, { size: 14 }), /* @__PURE__ */ B("span", { children: a("record.deleted_banner", "This record was deleted on {date}", { date: v(String(Y[w.soft_delete])) }) })]
1163
+ }), _n = lt && /* @__PURE__ */ V("div", {
1164
+ style: {
1165
+ display: "flex",
1166
+ alignItems: "center",
1167
+ gap: 8,
1168
+ padding: "10px 14px",
1169
+ marginBottom: 12,
1170
+ borderRadius: 8,
1171
+ border: "1px solid var(--warn)",
1172
+ background: "var(--warn-soft)",
1173
+ color: "var(--warn)",
1174
+ fontSize: 12.5
1175
+ },
1176
+ children: [/* @__PURE__ */ B(e.warning, { size: 14 }), /* @__PURE__ */ B("span", { children: a("record.changed_on_server", "This record changed on the server while you were viewing or editing it.") })]
1177
+ }), vn = J && yt && Yt && /* @__PURE__ */ B(st, {
1178
+ errors: Object.entries(Jt).map(([e, t]) => {
1179
+ let n = w.fields.get(e);
1180
+ return {
1181
+ name: e,
1182
+ label: n ? d(a, n, e, _?.entities) : e,
1183
+ message: t
1184
+ };
1185
+ }),
1186
+ onJump: (e) => {
1187
+ let t = document.getElementById(`${T}-${e}`);
1188
+ t && (t.scrollIntoView({
1189
+ block: "center",
1190
+ behavior: "smooth"
1191
+ }), t.focus?.());
1192
+ }
1193
+ }), yn = Be && !j && !(X.items && X.items.length > 0) && /* @__PURE__ */ B("div", {
1194
+ className: "mb-4",
1195
+ children: /* @__PURE__ */ B(Ke, {
1196
+ statusGroups: w.status_groups ?? {},
1197
+ objectStatuses: $.objectStatuses,
1198
+ onSetStatus: O && J ? (e, t) => it((n) => ({
1199
+ ...n,
1200
+ [e]: t
1201
+ })) : gt,
1202
+ isPending: !1,
1203
+ mode: J ? "edit" : "display"
1204
+ })
1205
+ }), bn = w.evidence_covered && !j && Y && /* @__PURE__ */ B("div", {
1206
+ className: "mb-4",
1207
+ children: /* @__PURE__ */ B(ut, { evidence: Y.$evidence })
1208
+ }), xn = /* @__PURE__ */ V(tt, { children: [
1209
+ ln && (Y || j) && /* @__PURE__ */ B(bt, {
1210
+ card: ln,
1211
+ entity: w,
1212
+ record: $.record,
1213
+ objectStatuses: $.objectStatuses,
1214
+ objectProperties: $.objectProperties
1215
+ }),
1216
+ X.items && X.items.length > 0 && (Y || j) && _ && /* @__PURE__ */ B(qe, {
1217
+ nodes: X.items,
1218
+ ctx: $
1219
+ }),
1220
+ !j && A && T && w.associations && Object.keys(w.associations).length > 0 && _ && /* @__PURE__ */ B(nt, {
1221
+ entityCode: T,
1222
+ recordId: N ?? A ?? "",
1223
+ associations: w.associations,
1224
+ schema: _
1225
+ }),
1226
+ !j && A && T && /* @__PURE__ */ B(at, {
1227
+ entityCode: T,
1228
+ objectId: N ?? A,
1229
+ canGenerateOne: !!w?.documents?.generate_one,
1230
+ canManageTemplates: Ue(_)
1231
+ }),
1232
+ !j && Y && _ && /* @__PURE__ */ B(he, {
1233
+ screen: X,
1234
+ entity: w,
1235
+ entityCode: T,
1236
+ record: Y,
1237
+ refs: At,
1238
+ schema: _
1239
+ })
1240
+ ] }), Sn = /* @__PURE__ */ V(tt, { children: [
1241
+ hn,
1242
+ _n,
1243
+ gn,
1244
+ vn,
1245
+ yn,
1246
+ bn
1247
+ ] });
1248
+ return pn ? /* @__PURE__ */ V("div", {
1249
+ style: {
1250
+ height: "100%",
1251
+ display: "flex",
1252
+ overflow: "hidden",
1253
+ background: "var(--background)"
1254
+ },
1255
+ children: [
1256
+ /* @__PURE__ */ B("div", {
1257
+ style: {
1258
+ flex: 1,
1259
+ minWidth: 0,
1260
+ height: "100%"
1261
+ },
1262
+ children: /* @__PURE__ */ B(me, {
1263
+ scrollRef: Pt,
1264
+ header: Sn,
1265
+ children: xn
1266
+ })
1267
+ }),
1268
+ /* @__PURE__ */ B("div", {
1269
+ className: "detail-resize-handle",
1270
+ onMouseDown: kt,
1271
+ title: a("record.layout.drag_to_resize", "Drag to resize"),
1272
+ children: /* @__PURE__ */ B("div", { style: {
1273
+ position: "absolute",
1274
+ top: 0,
1275
+ bottom: 0,
1276
+ left: "50%",
1277
+ transform: "translateX(-50%)",
1278
+ width: 1,
1279
+ background: "var(--border)"
1280
+ } })
1281
+ }),
1282
+ /* @__PURE__ */ B("div", {
1283
+ ref: Dt,
1284
+ style: {
1285
+ flexShrink: 0,
1286
+ height: "100%",
1287
+ width: `${Tt}px`
1288
+ },
1289
+ children: (Y || j) && _ && /* @__PURE__ */ B(qe, {
1290
+ nodes: X.sidebar,
1291
+ ctx: $
1292
+ })
1293
+ })
1294
+ ]
1295
+ }) : /* @__PURE__ */ V(me, {
1296
+ scrollRef: Pt,
1297
+ header: Sn,
1298
+ children: [xn, fn && (Y || j) && _ && /* @__PURE__ */ B("div", {
1299
+ "data-testid": "detail-sidebar-inline",
1300
+ style: {
1301
+ display: "flex",
1302
+ flexDirection: "column",
1303
+ gap: 16,
1304
+ minWidth: 0
1305
+ },
1306
+ children: /* @__PURE__ */ B(qe, {
1307
+ nodes: X.sidebar,
1308
+ ctx: $
1309
+ })
1310
+ })]
1311
+ });
1312
+ }
1313
+ function bt({ card: e, entity: t, record: n, objectStatuses: r, objectProperties: i }) {
1314
+ let a = E(), o = (e) => {
1315
+ let o = xt(a, t, e, n, r, i);
1316
+ return o != null && _(o) !== "";
1317
+ }, s = (e) => {
1318
+ let o = xt(a, t, e, n, r, i);
1319
+ return _(o) || /* @__PURE__ */ B("span", {
1320
+ style: { color: "var(--text-3)" },
1321
+ children: "-"
1322
+ });
1323
+ }, c = e.titleUsesDisplay ? re(a, n, t) : e.titleField ? xt(a, t, e.titleField, n, r, i) : void 0, l = _(c) || a(t.display?.name) || a("record.fallback_title", "Record"), u = e.badgeFields.filter((t) => !e.hideEmptyFields || o(t)), d = e.bodyFields.filter((t) => !e.hideEmptyFields || o(t)), f = e.metaFields.filter((t) => !e.hideEmptyFields || o(t));
1324
+ return /* @__PURE__ */ V("section", {
1325
+ "data-testid": "detail-header-card",
1326
+ style: {
1327
+ width: "100%",
1328
+ minWidth: 0,
1329
+ border: "1px solid var(--border)",
1330
+ borderRadius: 8,
1331
+ background: "var(--surface)",
1332
+ boxShadow: "var(--shadow-xs)",
1333
+ padding: 14,
1334
+ boxSizing: "border-box"
1335
+ },
1336
+ children: [
1337
+ /* @__PURE__ */ V("div", {
1338
+ style: { minWidth: 0 },
1339
+ children: [/* @__PURE__ */ B("div", {
1340
+ style: {
1341
+ fontSize: 15,
1342
+ lineHeight: 1.25,
1343
+ fontWeight: 700,
1344
+ color: "var(--text)",
1345
+ overflowWrap: "anywhere"
1346
+ },
1347
+ children: l
1348
+ }), e.subtitleField && /* @__PURE__ */ B("div", {
1349
+ style: {
1350
+ marginTop: 4,
1351
+ fontSize: 12.5,
1352
+ lineHeight: 1.35,
1353
+ color: "var(--text-3)",
1354
+ overflowWrap: "anywhere"
1355
+ },
1356
+ children: s(e.subtitleField)
1357
+ })]
1358
+ }),
1359
+ u.length > 0 && /* @__PURE__ */ B("div", {
1360
+ style: {
1361
+ display: "flex",
1362
+ flexWrap: "wrap",
1363
+ gap: 6,
1364
+ marginTop: 10
1365
+ },
1366
+ children: u.map((e) => /* @__PURE__ */ B("span", {
1367
+ style: {
1368
+ minWidth: 0,
1369
+ maxWidth: "100%",
1370
+ borderRadius: 999,
1371
+ background: "var(--surface-2)",
1372
+ color: "var(--text-2)",
1373
+ padding: "2px 8px",
1374
+ fontSize: 12,
1375
+ lineHeight: 1.4,
1376
+ overflowWrap: "anywhere"
1377
+ },
1378
+ children: s(e)
1379
+ }, e))
1380
+ }),
1381
+ d.length > 0 && /* @__PURE__ */ B("dl", {
1382
+ style: {
1383
+ display: "grid",
1384
+ gridTemplateColumns: "minmax(84px, max-content) minmax(0, 1fr)",
1385
+ gap: "6px 10px",
1386
+ margin: "12px 0 0",
1387
+ fontSize: 12.5,
1388
+ lineHeight: 1.35
1389
+ },
1390
+ children: d.map((e) => /* @__PURE__ */ V("div", {
1391
+ style: { display: "contents" },
1392
+ children: [/* @__PURE__ */ B("dt", {
1393
+ style: { color: "var(--text-3)" },
1394
+ children: St(a, t, e)
1395
+ }), /* @__PURE__ */ B("dd", {
1396
+ style: {
1397
+ margin: 0,
1398
+ color: "var(--text-2)",
1399
+ minWidth: 0,
1400
+ overflowWrap: "anywhere"
1401
+ },
1402
+ children: s(e)
1403
+ })]
1404
+ }, e))
1405
+ }),
1406
+ f.length > 0 && /* @__PURE__ */ B("div", {
1407
+ style: {
1408
+ display: "flex",
1409
+ flexWrap: "wrap",
1410
+ gap: 10,
1411
+ marginTop: 10,
1412
+ color: "var(--text-3)",
1413
+ fontSize: 11.5
1414
+ },
1415
+ children: f.map((e) => /* @__PURE__ */ V("span", {
1416
+ style: {
1417
+ minWidth: 0,
1418
+ overflowWrap: "anywhere"
1419
+ },
1420
+ children: [
1421
+ St(a, t, e),
1422
+ ": ",
1423
+ s(e)
1424
+ ]
1425
+ }, e))
1426
+ })
1427
+ ]
1428
+ });
1429
+ }
1430
+ function xt(e, t, n, r, i, a) {
1431
+ if (n.startsWith("$status.")) {
1432
+ let t = n.slice(8), r = i?.find((e) => e.group_code === t);
1433
+ return e(r?.status_name) || r?.status_code;
1434
+ }
1435
+ if (n.startsWith("$property.")) {
1436
+ let e = n.slice(10);
1437
+ return a?.find((t) => t.property_code === e)?.value;
1438
+ }
1439
+ return Ae(t, r, n);
1440
+ }
1441
+ function St(e, t, n) {
1442
+ if (n.startsWith("$status.")) return n.slice(8);
1443
+ if (n.startsWith("$property.")) return n.slice(10);
1444
+ let r = t.fields.get(n);
1445
+ return r ? d(e, r, n) : n;
1446
+ }
1447
+ function Ct({ title: n, recordId: i, editing: a, isNew: o, isRecordDeleted: s, dirty: u, isSaving: d, hasChildErrors: f, hasFieldErrors: p, canRestore: m, entity: h, screen: _, globalActions: v, entityCode: y, record: b, id: x, listRoute: S, listRouteExists: ne, highlights: re, showBack: ie, onBack: C, onCancelEdit: ae, onSave: oe, onRestore: se, isRestoring: ce, refreshControl: le, isRealtimeEntity: ue, canManageTemplates: de }) {
1448
+ let D = E(), O = E("errors"), { run: fe } = g(), me = w("detail"), he = be(), k = r(), A = ee(_?.action_layout, h?.action_layout, h?.actions, v, "detail_toolbar"), j = ee(_?.action_layout, h?.action_layout, h?.actions, v, "detail"), M = l(D, j, h?.actions, v, b ?? {}, [], Ne(h, b ?? {})), N = l(D, A, h?.actions, v, b ?? {}, [], Ne(h, b ?? {})), ve = L(() => {
1449
+ if (!h) return;
1450
+ let e = x ? [x] : [];
1451
+ return {
1452
+ entity: h,
1453
+ entityCode: y ?? "",
1454
+ screen: _,
1455
+ screenRoute: _?.route ?? "",
1456
+ selectedRows: b ? [b] : [],
1457
+ selectedIds: e,
1458
+ t: D,
1459
+ tabNavigate: (e, t) => he(e, {
1460
+ title: t?.title,
1461
+ icon: t?.icon,
1462
+ search: t?.search
1463
+ }),
1464
+ runActionApi: (e, t) => P(e, t)
1465
+ };
1466
+ }, [
1467
+ h,
1468
+ y,
1469
+ _,
1470
+ x,
1471
+ b,
1472
+ D,
1473
+ he
1474
+ ]), xe = (e, t) => {
1475
+ let n = Ie(O, e, t, { row: b ?? void 0 });
1476
+ if (n === null) return;
1477
+ let r = x ? [x] : [], i = e === "__delete" && ne ? S : null;
1478
+ return fe({
1479
+ action: t,
1480
+ title: D(t.display?.name) || e,
1481
+ row: b ?? void 0,
1482
+ execute: (e) => P(n, ge(e, r)),
1483
+ onSuccess: i ? () => {
1484
+ ye.getState().kill(_e(location)), k(i, { replace: !0 });
1485
+ } : void 0
1486
+ });
1487
+ }, Se = me.isVisible("show_actions") && !o && x && M.length > 0 ? /* @__PURE__ */ B(ke, {
1488
+ layout: M,
1489
+ row: b,
1490
+ onRun: xe,
1491
+ kind: "detail",
1492
+ entityActions: h?.actions,
1493
+ globalActions: v,
1494
+ reservedRightWidth: 0,
1495
+ widgetContext: ve
1496
+ }) : null, Ce = !o && x ? /* @__PURE__ */ B(T, {
1497
+ liveObject: le,
1498
+ realtime: ue
1499
+ }) : null, we = me.isVisible("show_actions") && !o && x && N.length > 0 ? /* @__PURE__ */ V("div", {
1500
+ style: {
1501
+ display: "flex",
1502
+ justifyContent: "flex-end",
1503
+ alignItems: "center",
1504
+ gap: 8,
1505
+ marginTop: 10
1506
+ },
1507
+ children: [Se ? null : Ce, /* @__PURE__ */ B(ke, {
1508
+ layout: N,
1509
+ row: b,
1510
+ onRun: xe,
1511
+ kind: "detail",
1512
+ entityActions: h?.actions,
1513
+ globalActions: v,
1514
+ reservedRightWidth: 0,
1515
+ widgetContext: ve,
1516
+ ariaLabel: Se ? D("record.toolbar_actions", "Detail toolbar actions") : D("record.page_actions", "Page actions")
1517
+ })]
1518
+ }) : null, Te = me.isVisible("show_actions") && !o && x && y ? /* @__PURE__ */ B(Ge, {
1519
+ entityCode: y,
1520
+ scope: "detail",
1521
+ objectIds: [x],
1522
+ capability: h?.documents,
1523
+ canManageTemplates: de
1524
+ }) : null, Ee = s ? m ? /* @__PURE__ */ B(c, {
1525
+ kind: "primary",
1526
+ icon: B(ce ? te : e.refresh, { size: 13 }),
1527
+ onClick: se,
1528
+ disabled: ce,
1529
+ children: ce ? D("record.restoring", "Restoring…") : D("record.restore", "Restore")
1530
+ }) : null : a ? /* @__PURE__ */ V(tt, { children: [/* @__PURE__ */ B(c, {
1531
+ icon: /* @__PURE__ */ B(e.x, { size: 13 }),
1532
+ onClick: ae,
1533
+ disabled: d,
1534
+ children: D("dialog.cancel", "Cancel")
1535
+ }), /* @__PURE__ */ B(c, {
1536
+ kind: "primary",
1537
+ icon: B(d ? te : e.save, { size: 13 }),
1538
+ onClick: oe,
1539
+ disabled: d || f || p,
1540
+ title: f ? D("record.save.fix_child_rows", "Fix errors in child rows") : p ? D("record.save.fix_fields", "Fix the highlighted fields") : void 0,
1541
+ children: d ? D("dialog.saving", "Saving…") : D("dialog.save", "Save")
1542
+ })] }) : !o && x ? Se ? /* @__PURE__ */ V("span", {
1543
+ style: { display: "contents" },
1544
+ children: [Te, Se]
1545
+ }) : Te : null;
1546
+ return /* @__PURE__ */ V(tt, { children: [/* @__PURE__ */ B(pe, {
1547
+ icon: h?.display.icon ? /* @__PURE__ */ B(t, {
1548
+ name: h.display.icon,
1549
+ size: 16
1550
+ }) : void 0,
1551
+ title: n,
1552
+ description: D(_?.display?.description) || D(h?.display?.description),
1553
+ recordId: i,
1554
+ highlights: re,
1555
+ identityControls: !s && !a && !o ? Ce : null,
1556
+ mode: o ? "create" : a ? "edit" : "display",
1557
+ dirty: u,
1558
+ showBack: ie,
1559
+ onBack: C,
1560
+ right: Ee,
1561
+ showTitle: me.isVisible("show_title")
1562
+ }), we] });
1563
+ }
1564
+ //#endregion
1565
+ export { q as SmartDetailPage };