@alfadocs/ui-kit 1.65.0 → 1.67.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 (158) hide show
  1. package/dist/_chunks/ai-credits-exhausted-notice-DfAgfZDF.js +287 -0
  2. package/dist/_chunks/ai-credits-exhausted-notice.agent-DgTSTgez.js +43 -0
  3. package/dist/_chunks/ai-credits-notice-DQ-r3iQU.js +191 -0
  4. package/dist/_chunks/{ai-permission-notice-DpRmZ9Q3.js → ai-permission-notice-qsdm4Sx4.js} +2 -2
  5. package/dist/_chunks/{alert-DdDpOi-P.js → alert-DjsJMGRE.js} +3 -2
  6. package/dist/_chunks/{anamnesis-summary-rows-BIfw890v.js → anamnesis-summary-rows-BQ_EokKz.js} +2 -2
  7. package/dist/_chunks/{audio-recorder-DR-u1qbl.js → audio-recorder-B11RR-rC.js} +2 -2
  8. package/dist/_chunks/{auth-form-parts-Cmb41LSQ.js → auth-form-parts-DwUTH6YN.js} +2 -2
  9. package/dist/_chunks/{booking-DkjatiXc.js → booking-tTVxKPQY.js} +2 -2
  10. package/dist/_chunks/{calendar-workspace-Cp8yTZ1g.js → calendar-workspace-MRrzcxAy.js} +6 -6
  11. package/dist/_chunks/chart-CwmyCuWe.js +1340 -0
  12. package/dist/_chunks/{document-preview-B1dQm292.js → document-preview-VyQOjFVL.js} +2 -2
  13. package/dist/_chunks/{document-scanner-CVPVLK7z.js → document-scanner-CXH_GYh4.js} +2 -2
  14. package/dist/_chunks/{entity-summary-BQ9_KA8S.js → entity-summary-Bj-Wxq7Y.js} +2 -2
  15. package/dist/_chunks/{error-summary-DrUfuKu1.js → error-summary-PUE5Zxp9.js} +2 -2
  16. package/dist/_chunks/{forgot-password-form-CgZkEvZy.js → forgot-password-form-CPOfRE0C.js} +4 -4
  17. package/dist/_chunks/{freemium-paywall-DKJHRFpp.js → freemium-paywall-6DO7noHX.js} +2 -2
  18. package/dist/_chunks/heatmap-C1TeC7wT.js +3650 -0
  19. package/dist/_chunks/help-me-write-templates-Bw3Q58x-.js +687 -0
  20. package/dist/_chunks/hourglass-BEAzW1wE.js +26 -0
  21. package/dist/_chunks/{login-dev-card-PnADNcI9.js → login-dev-card-A-CL3mjt.js} +3 -3
  22. package/dist/_chunks/{marketplace-app-shell-C-2e4eCD.js → marketplace-app-shell-DtSX8sYb.js} +2 -2
  23. package/dist/_chunks/{notes-panel-uEGIL7mi.js → notes-panel-IdsmqRFC.js} +3 -3
  24. package/dist/_chunks/{patient-details-4P1vA9Ls.js → patient-details-C-EWQTms.js} +2 -2
  25. package/dist/_chunks/{patient-field-row-CBXhlfGD.js → patient-field-row-lY-Tb5Mo.js} +155 -176
  26. package/dist/_chunks/{patient-search-DOnDUVsl.js → patient-search-DpAKidZ5.js} +2 -2
  27. package/dist/_chunks/{patient-summary-card-CuDLo8MP.js → patient-summary-card-Bpto_VCD.js} +2 -2
  28. package/dist/_chunks/{payment-automation-upsell-C8MEu0t6.js → payment-automation-upsell-BQ307qEX.js} +2 -2
  29. package/dist/_chunks/{payment-form-C3dGY7v4.js → payment-form-XKtinW8r.js} +2 -2
  30. package/dist/_chunks/{pdf-viewer-DJ9VN7cu.js → pdf-viewer-BvoVMjH4.js} +2 -2
  31. package/dist/_chunks/{practice-results-8h2Utpt3.js → practice-results-BrUDDMXC.js} +2 -2
  32. package/dist/_chunks/{registration-form-BQyT_kBX.js → registration-form-BxwqUZzk.js} +3 -3
  33. package/dist/_chunks/{rich-text-editor-M2gT_E7f.js → rich-text-editor-aCIoptbg.js} +1653 -1743
  34. package/dist/_chunks/{sign-document-CY7xTXbm.js → sign-document-D1P1nUQA.js} +2 -2
  35. package/dist/_chunks/{signature-request-BMCHy2ZO.js → signature-request-3u6TvRt2.js} +2 -2
  36. package/dist/_chunks/{task-editor-CifOznfq.js → task-editor-Bb5MMcid.js} +2 -2
  37. package/dist/_chunks/{tasks-panel-8nLwBw6P.js → tasks-panel-BOb57Ysw.js} +2 -2
  38. package/dist/_chunks/{use-appointment-details-read-B-FEWbQM.js → use-appointment-details-read-CVSPoP5j.js} +4 -4
  39. package/dist/_chunks/voice-control-panel-BJIEbDq6.js +1148 -0
  40. package/dist/_chunks/{warning-stack-HYWAytZV.js → warning-stack-BdY-0bd3.js} +2 -2
  41. package/dist/_chunks/{workflow-map-C2B2qIr1.js → workflow-map-CYbRD9ek.js} +2 -2
  42. package/dist/agent-catalog.json +50 -3
  43. package/dist/agent-i18n/en.json +7 -4
  44. package/dist/components/_shared/use-apex-radial-centre.d.ts +7 -4
  45. package/dist/components/ai-credits-notice/ai-credits-exhausted-notice.agent.d.ts +4 -0
  46. package/dist/components/ai-credits-notice/ai-credits-exhausted-notice.d.ts +96 -0
  47. package/dist/components/ai-credits-notice/ai-credits-notice.d.ts +30 -4
  48. package/dist/components/ai-credits-notice/index.d.ts +3 -0
  49. package/dist/components/ai-credits-notice/index.js +10 -4
  50. package/dist/components/ai-permission-notice/index.js +1 -1
  51. package/dist/components/alert/index.js +1 -1
  52. package/dist/components/appointment-details-panel/index.js +1 -1
  53. package/dist/components/audio-recorder/index.js +1 -1
  54. package/dist/components/booking/index.js +1 -1
  55. package/dist/components/chart/index.js +1 -1
  56. package/dist/components/document-preview/index.js +1 -1
  57. package/dist/components/document-scanner/index.js +1 -1
  58. package/dist/components/entity-summary/index.js +1 -1
  59. package/dist/components/error-summary/index.js +1 -1
  60. package/dist/components/freemium-paywall/index.js +1 -1
  61. package/dist/components/heatmap/heatmap-context.d.ts +3 -0
  62. package/dist/components/heatmap/heatmap-disclosure.d.ts +67 -0
  63. package/dist/components/heatmap/heatmap-grid.d.ts +1 -1
  64. package/dist/components/heatmap/heatmap-legend.d.ts +5 -2
  65. package/dist/components/heatmap/heatmap-model.d.ts +107 -15
  66. package/dist/components/heatmap/heatmap-table-view.d.ts +3 -2
  67. package/dist/components/heatmap/heatmap.d.ts +33 -7
  68. package/dist/components/heatmap/index.d.ts +1 -1
  69. package/dist/components/heatmap/index.js +1 -1
  70. package/dist/components/notes-panel/index.js +1 -1
  71. package/dist/components/patient-details/index.js +1 -1
  72. package/dist/components/patient-search/index.js +1 -1
  73. package/dist/components/patient-summary-card/index.js +1 -1
  74. package/dist/components/payment-form/index.js +1 -1
  75. package/dist/components/pdf-viewer/index.js +1 -1
  76. package/dist/components/practice-results/index.js +1 -1
  77. package/dist/components/rich-text-editor/index.js +1 -1
  78. package/dist/components/sign-document/index.js +1 -1
  79. package/dist/components/task-editor/index.js +1 -1
  80. package/dist/components/tasks-panel/index.js +1 -1
  81. package/dist/components/voice-control-panel/index.d.ts +2 -1
  82. package/dist/components/voice-control-panel/index.js +1 -1
  83. package/dist/components/voice-control-panel/voice-control-panel.d.ts +43 -3
  84. package/dist/components/warning-stack/index.js +1 -1
  85. package/dist/components/workflow/index.js +1 -1
  86. package/dist/i18n/locales/ar.d.ts +29 -12
  87. package/dist/i18n/locales/ar.js +29 -12
  88. package/dist/i18n/locales/de.d.ts +29 -12
  89. package/dist/i18n/locales/de.js +29 -12
  90. package/dist/i18n/locales/el.d.ts +29 -12
  91. package/dist/i18n/locales/el.js +29 -12
  92. package/dist/i18n/locales/en.d.ts +29 -12
  93. package/dist/i18n/locales/en.js +29 -12
  94. package/dist/i18n/locales/es.d.ts +29 -12
  95. package/dist/i18n/locales/es.js +29 -12
  96. package/dist/i18n/locales/fr.d.ts +29 -12
  97. package/dist/i18n/locales/fr.js +29 -12
  98. package/dist/i18n/locales/hi.d.ts +29 -12
  99. package/dist/i18n/locales/hi.js +29 -12
  100. package/dist/i18n/locales/it.d.ts +29 -12
  101. package/dist/i18n/locales/it.js +29 -12
  102. package/dist/i18n/locales/ja.d.ts +29 -12
  103. package/dist/i18n/locales/ja.js +29 -12
  104. package/dist/i18n/locales/nl.d.ts +29 -12
  105. package/dist/i18n/locales/nl.js +29 -12
  106. package/dist/i18n/locales/pl.d.ts +29 -12
  107. package/dist/i18n/locales/pl.js +29 -12
  108. package/dist/i18n/locales/pt.d.ts +29 -12
  109. package/dist/i18n/locales/pt.js +29 -12
  110. package/dist/i18n/locales/ro.d.ts +29 -12
  111. package/dist/i18n/locales/ro.js +29 -12
  112. package/dist/i18n/locales/ru.d.ts +29 -12
  113. package/dist/i18n/locales/ru.js +29 -12
  114. package/dist/i18n/locales/sq.d.ts +29 -12
  115. package/dist/i18n/locales/sq.js +29 -12
  116. package/dist/i18n/locales/sv.d.ts +29 -12
  117. package/dist/i18n/locales/sv.js +29 -12
  118. package/dist/i18n/locales/tr.d.ts +29 -12
  119. package/dist/i18n/locales/tr.js +29 -12
  120. package/dist/i18n/locales/zh.d.ts +29 -12
  121. package/dist/i18n/locales/zh.js +29 -12
  122. package/dist/index.js +814 -809
  123. package/dist/locales/ar.json +29 -12
  124. package/dist/locales/de.json +29 -12
  125. package/dist/locales/el.json +29 -12
  126. package/dist/locales/en.json +29 -12
  127. package/dist/locales/es.json +29 -12
  128. package/dist/locales/fr.json +29 -12
  129. package/dist/locales/hi.json +29 -12
  130. package/dist/locales/it.json +29 -12
  131. package/dist/locales/ja.json +29 -12
  132. package/dist/locales/nl.json +29 -12
  133. package/dist/locales/pl.json +29 -12
  134. package/dist/locales/pt.json +29 -12
  135. package/dist/locales/ro.json +29 -12
  136. package/dist/locales/ru.json +29 -12
  137. package/dist/locales/sq.json +29 -12
  138. package/dist/locales/sv.json +29 -12
  139. package/dist/locales/tr.json +29 -12
  140. package/dist/locales/zh.json +29 -12
  141. package/dist/patterns/anamnesis/index.js +1 -1
  142. package/dist/patterns/calendar/index.js +1 -1
  143. package/dist/patterns/forgot-password-form/index.js +1 -1
  144. package/dist/patterns/help-me-write-templates/help-me-write-templates.d.ts +6 -23
  145. package/dist/patterns/help-me-write-templates/index.js +8 -7
  146. package/dist/patterns/login-form/index.js +1 -1
  147. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  148. package/dist/patterns/payment-automation-upsell/index.js +1 -1
  149. package/dist/patterns/registration-form/index.js +1 -1
  150. package/dist/patterns/signature-request/index.js +1 -1
  151. package/dist/tokens.css +1 -1
  152. package/package.json +1 -1
  153. package/dist/_chunks/ai-credits-notice-pK9BOmEz.js +0 -90
  154. package/dist/_chunks/ai-credits-notice.agent-C9L7orrP.js +0 -17
  155. package/dist/_chunks/chart-CIzXxNeM.js +0 -1322
  156. package/dist/_chunks/heatmap-BxRHM8Et.js +0 -2865
  157. package/dist/_chunks/help-me-write-templates-DFmqnsAa.js +0 -747
  158. package/dist/_chunks/voice-control-panel-C0BfY23Y.js +0 -1009
@@ -0,0 +1,3650 @@
1
+ import { jsx as H, jsxs as le, Fragment as Vn } from "react/jsx-runtime";
2
+ import { useContext as Gn, createContext as $n, useId as Pn, useRef as ie, useMemo as X, useState as we, useCallback as ae, useEffect as gt, memo as jn, forwardRef as Mn, lazy as Sn, Suspense as qn } from "react";
3
+ import { useTranslation as Ht } from "react-i18next";
4
+ import { u as Wn } from "./registry-DvAUVLHh.js";
5
+ import { f as An } from "./intl-locale-FWh-Y5_3.js";
6
+ import { B as Un } from "./button-D-MQxsA_.js";
7
+ import { E as Yn } from "./empty-state-pL1qum99.js";
8
+ import { L as Jn } from "./live-region-C41SO3cA.js";
9
+ import { S as qt } from "./skeleton-B1KTdJ4N.js";
10
+ import { T as Nn, a as Qn } from "./tooltip-uEBdD1-5.js";
11
+ import { p as Xn } from "./privacy-mask-Ch7743uk.js";
12
+ import { u as nt } from "./use-isomorphic-layout-effect-BGfaCOP1.js";
13
+ import { i as Zn } from "./is-development-CLUAnsU7.js";
14
+ import { c as ge } from "./index-D2ZczOXr.js";
15
+ import { C as eo } from "./chevron-down-DWE7GSq9.js";
16
+ import { E as to } from "./error-boundary-Dzgu3O6W.js";
17
+ import { c as _n } from "./createLucideIcon-DhHxpK9K.js";
18
+ /**
19
+ * @license lucide-react v1.22.0 - ISC
20
+ *
21
+ * This source code is licensed under the ISC license.
22
+ * See the LICENSE file in the root directory of this source tree.
23
+ */
24
+ const no = [
25
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", key: "afitv7" }],
26
+ ["path", { d: "M3 9h18", key: "1pudct" }],
27
+ ["path", { d: "M3 15h18", key: "5xshup" }],
28
+ ["path", { d: "M9 3v18", key: "fh3hqa" }],
29
+ ["path", { d: "M15 3v18", key: "14nvp0" }]
30
+ ], oo = _n("grid-3x3", no);
31
+ /**
32
+ * @license lucide-react v1.22.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */
37
+ const ao = [
38
+ [
39
+ "path",
40
+ {
41
+ d: "M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18",
42
+ key: "gugj83"
43
+ }
44
+ ]
45
+ ], ro = _n("table-2", ao), ft = {
46
+ type: "object",
47
+ properties: {
48
+ rowId: { type: "string", description: "Row id, from rowIds." },
49
+ columnId: {
50
+ type: ["string", "number"],
51
+ description: "Column id, from columnIds."
52
+ }
53
+ },
54
+ required: ["rowId", "columnId"]
55
+ }, so = {
56
+ id: "heatmap",
57
+ capabilities: [
58
+ "select_single",
59
+ "select_multiple",
60
+ "range_pick",
61
+ "expand",
62
+ "sort",
63
+ "view_change"
64
+ ],
65
+ state: {
66
+ selection: {
67
+ type: "Array<{ rowId, columnId }>",
68
+ descriptionKey: "ui.agent.heatmap.state.selection",
69
+ description: "Row and column ids of the selected cells.",
70
+ read: (e) => e.getSelection()
71
+ },
72
+ selectionMode: {
73
+ type: "'none' | 'single' | 'multiple' | 'range'",
74
+ descriptionKey: "ui.agent.heatmap.state.selectionMode",
75
+ description: "How cells can be selected in this heatmap.",
76
+ read: (e) => e.getSelectionMode()
77
+ },
78
+ view: {
79
+ type: "'heatmap' | 'table'",
80
+ descriptionKey: "ui.agent.heatmap.state.view",
81
+ description: "Whether the heatmap or its table view is showing.",
82
+ read: (e) => e.getView()
83
+ },
84
+ sortRows: {
85
+ type: "'none' | 'label' | 'total-asc' | 'total-desc'",
86
+ descriptionKey: "ui.agent.heatmap.state.sortRows",
87
+ description: "Current row order.",
88
+ read: (e) => e.getSortRows()
89
+ },
90
+ rowIds: {
91
+ type: "string[]",
92
+ descriptionKey: "ui.agent.heatmap.state.rowIds",
93
+ description: "Row ids in display order, every group expanded. Opaque, never a label.",
94
+ read: (e) => e.getRowIds()
95
+ },
96
+ columnIds: {
97
+ type: "Array<string | number>",
98
+ descriptionKey: "ui.agent.heatmap.state.columnIds",
99
+ description: "Column ids in order. Opaque, never a label.",
100
+ read: (e) => e.getColumnIds()
101
+ },
102
+ groupIds: {
103
+ type: "string[]",
104
+ descriptionKey: "ui.agent.heatmap.state.groupIds",
105
+ description: "Group ids in display order, empty unless rows are grouped. A group not listed in `groups` shows as group-1, group-2 and so on.",
106
+ read: (e) => e.getGroupIds()
107
+ },
108
+ collapsedGroups: {
109
+ type: "string[]",
110
+ descriptionKey: "ui.agent.heatmap.state.collapsedGroups",
111
+ description: "Ids (as in groupIds) of the row groups that are collapsed.",
112
+ read: (e) => e.getCollapsedGroups()
113
+ }
114
+ },
115
+ actions: {
116
+ select_cell: {
117
+ safety: "read",
118
+ argsType: "{ rowId: string, columnId: string | number }",
119
+ argsSchema: ft,
120
+ idempotent: !0,
121
+ descriptionKey: "ui.agent.heatmap.actions.selectCell",
122
+ description: "Make one cell the whole selection.",
123
+ errors: [
124
+ 'Selection is off (selection="none").',
125
+ "The row or column id does not exist."
126
+ ],
127
+ examples: [
128
+ {
129
+ args: { rowId: "chair-1", columnId: 10 },
130
+ note: "Select chair 1 at 10:00."
131
+ }
132
+ ],
133
+ invoke: (e, t) => {
134
+ e.selectCells([t]);
135
+ }
136
+ },
137
+ select_cells: {
138
+ safety: "read",
139
+ argsType: "{ cells: Array<{ rowId, columnId }> }",
140
+ argsSchema: {
141
+ type: "object",
142
+ properties: {
143
+ cells: {
144
+ type: "array",
145
+ items: ft,
146
+ description: "Cells to select; replaces the selection. Single mode keeps the first."
147
+ }
148
+ },
149
+ required: ["cells"]
150
+ },
151
+ idempotent: !0,
152
+ descriptionKey: "ui.agent.heatmap.actions.selectCells",
153
+ description: "Replace the selection with the given cells.",
154
+ errors: [
155
+ 'Selection is off (selection="none").',
156
+ "A row or column id does not exist; nothing is selected."
157
+ ],
158
+ invoke: (e, t) => {
159
+ e.selectCells(t.cells);
160
+ }
161
+ },
162
+ select_range: {
163
+ safety: "read",
164
+ argsType: "{ from: { rowId, columnId }, to: { rowId, columnId } }",
165
+ argsSchema: {
166
+ type: "object",
167
+ properties: {
168
+ from: { ...ft, description: "One corner, inclusive." },
169
+ to: { ...ft, description: "The opposite corner, inclusive." }
170
+ },
171
+ required: ["from", "to"]
172
+ },
173
+ idempotent: !0,
174
+ descriptionKey: "ui.agent.heatmap.actions.selectRange",
175
+ description: "Select the rectangle of cells between two corners, in the rows as shown.",
176
+ errors: [
177
+ 'Needs selection="range" or "multiple".',
178
+ "A corner names a row or column that does not exist."
179
+ ],
180
+ invoke: (e, t) => {
181
+ e.selectRange(t.from, t.to);
182
+ }
183
+ },
184
+ clear_selection: {
185
+ safety: "read",
186
+ idempotent: !0,
187
+ descriptionKey: "ui.agent.heatmap.actions.clearSelection",
188
+ description: "Deselect every cell.",
189
+ errors: ['Selection is off (selection="none").'],
190
+ invoke: (e) => {
191
+ e.clearSelection();
192
+ }
193
+ },
194
+ read_cell: {
195
+ safety: "read",
196
+ argsType: "{ rowId: string, columnId: string | number }",
197
+ argsSchema: ft,
198
+ returns: "{ value, count, status, step } | null",
199
+ returnsSchema: {
200
+ type: ["object", "null"],
201
+ properties: {
202
+ value: { type: ["number", "null"] },
203
+ count: { type: "number" },
204
+ status: { enum: ["value", "empty", "low-sample"] },
205
+ step: { type: ["number", "null"] }
206
+ }
207
+ },
208
+ idempotent: !0,
209
+ descriptionKey: "ui.agent.heatmap.actions.readCell",
210
+ description: "Read a cell's value, count, status and colour step (no labels).",
211
+ invoke: (e, t) => e.readCell(t)
212
+ },
213
+ toggle_table_view: {
214
+ safety: "read",
215
+ descriptionKey: "ui.agent.heatmap.actions.toggleTableView",
216
+ description: "Switch between the heatmap and its table view.",
217
+ returns: "'heatmap' | 'table'",
218
+ returnsSchema: { enum: ["heatmap", "table"] },
219
+ invoke: (e) => {
220
+ const t = e.getView() === "table" ? "heatmap" : "table";
221
+ return e.setView(t), t;
222
+ }
223
+ },
224
+ set_view: {
225
+ safety: "read",
226
+ argsType: "{ view: 'heatmap' | 'table' }",
227
+ argsSchema: {
228
+ type: "object",
229
+ properties: {
230
+ view: {
231
+ enum: ["heatmap", "table"],
232
+ description: "The coloured grid, or the same data as a table."
233
+ }
234
+ },
235
+ required: ["view"]
236
+ },
237
+ idempotent: !0,
238
+ descriptionKey: "ui.agent.heatmap.actions.setView",
239
+ description: "Show the heatmap or its table view.",
240
+ invoke: (e, t) => {
241
+ e.getView() !== t.view && e.setView(t.view);
242
+ }
243
+ },
244
+ sort_rows: {
245
+ safety: "read",
246
+ argsType: "{ sort: 'none' | 'label' | 'total-asc' | 'total-desc' }",
247
+ argsSchema: {
248
+ type: "object",
249
+ properties: {
250
+ sort: {
251
+ enum: ["none", "label", "total-asc", "total-desc"],
252
+ description: "Row order within each group: as given, by label, or by row total."
253
+ }
254
+ },
255
+ required: ["sort"]
256
+ },
257
+ idempotent: !0,
258
+ descriptionKey: "ui.agent.heatmap.actions.sortRows",
259
+ description: "Reorder the rows.",
260
+ invoke: (e, t) => {
261
+ e.setSortRows(t.sort);
262
+ }
263
+ },
264
+ expand_group: {
265
+ safety: "read",
266
+ argsType: "{ groupId: string }",
267
+ argsSchema: {
268
+ type: "object",
269
+ properties: {
270
+ groupId: { type: "string", description: "Group id, from groupIds." }
271
+ },
272
+ required: ["groupId"]
273
+ },
274
+ idempotent: !0,
275
+ descriptionKey: "ui.agent.heatmap.actions.expandGroup",
276
+ description: "Show a group's rows.",
277
+ errors: [
278
+ "Rows are not grouped (groupRows is off).",
279
+ "The group id does not exist (see groupIds)."
280
+ ],
281
+ invoke: (e, t) => {
282
+ e.setGroupCollapsed(t.groupId, !1);
283
+ }
284
+ },
285
+ collapse_group: {
286
+ safety: "read",
287
+ argsType: "{ groupId: string }",
288
+ argsSchema: {
289
+ type: "object",
290
+ properties: {
291
+ groupId: { type: "string", description: "Group id, from groupIds." }
292
+ },
293
+ required: ["groupId"]
294
+ },
295
+ idempotent: !0,
296
+ descriptionKey: "ui.agent.heatmap.actions.collapseGroup",
297
+ description: "Hide a group's rows, leaving its totals row.",
298
+ errors: [
299
+ "Rows are not grouped (groupRows is off).",
300
+ "The group id does not exist (see groupIds)."
301
+ ],
302
+ invoke: (e, t) => {
303
+ e.setGroupCollapsed(t.groupId, !0);
304
+ }
305
+ }
306
+ },
307
+ domHooks: {
308
+ root: {
309
+ attr: "data-component",
310
+ value: "heatmap",
311
+ description: "Marks the Heatmap root."
312
+ },
313
+ instanceId: {
314
+ attr: "data-component-id",
315
+ sourceProp: "id",
316
+ description: "Sourced from the id prop on Heatmap."
317
+ },
318
+ item: {
319
+ attr: "data-heatmap-cell-id",
320
+ description: 'On every data cell: "<rowId>:<columnId>", built from the opaque ids, never from labels. A group header row and its cells carry data-heatmap-group-id, the group id as in groupIds.'
321
+ }
322
+ }
323
+ }, _t = $n(null);
324
+ function Rn() {
325
+ return Gn(_t);
326
+ }
327
+ function En(e, t) {
328
+ const n = new Intl.NumberFormat(
329
+ e,
330
+ t === "rate" ? { style: "percent", maximumFractionDigits: 0 } : { maximumFractionDigits: 2 }
331
+ );
332
+ return (o) => n.format(o);
333
+ }
334
+ function Tn(e) {
335
+ const t = new Intl.NumberFormat(e, { maximumFractionDigits: 0 });
336
+ return (n) => t.format(n);
337
+ }
338
+ const io = "–";
339
+ function lo({
340
+ t: e,
341
+ privacyMode: t,
342
+ privacyScope: n = "rows",
343
+ valueType: o,
344
+ formatValue: s,
345
+ formatCount: a,
346
+ groups: i
347
+ }) {
348
+ const u = new Map(i == null ? void 0 : i.map((p) => [p.id, p.label])), d = Xn(), l = t, v = t && n === "all", m = t && n === "all", w = (p) => p.status === "empty" ? e("heatmap.noData") : p.status === "low-sample" ? p.withheld ? e("heatmap.totalWithheld") : e("heatmap.lowSample") : p.label !== void 0 && !t ? p.label : p.value === null ? e("heatmap.noData") : s(p.value), b = (p) => p.count === void 0 ? null : o === "rate" && p.status === "value" && p.value !== null ? e("heatmap.countOf", {
349
+ part: a(Math.round(p.value * p.count)),
350
+ total: a(p.count)
351
+ }) : e("heatmap.records", {
352
+ count: p.count,
353
+ formatted: a(p.count)
354
+ });
355
+ return {
356
+ masksRows: l,
357
+ masksColumns: v,
358
+ masksGroups: m,
359
+ rowLabel: (p) => l ? d : p.label,
360
+ columnLabel: (p) => v ? d : p.label,
361
+ // A group missing from `groups` has only its id to show, which may be a
362
+ // name, so privacy mode masks it whatever the scope.
363
+ groupLabel: (p) => m ? d : u.get(p) ?? (t ? d : p),
364
+ cellName: (p, A) => e("heatmap.cellName", { row: p, column: A }),
365
+ groupRowText: (p, A) => e("heatmap.groupRow", {
366
+ group: p,
367
+ method: e(A === "sum" ? "heatmap.totals.sum" : "heatmap.totals.mean")
368
+ }),
369
+ tableText: (p) => {
370
+ const A = p.status === "empty" ? null : b(p), O = w(p);
371
+ return A === null ? O : e("heatmap.valueWithCount", { value: O, count: A });
372
+ },
373
+ methodLabel: (p) => e(p === "sum" ? "heatmap.totals.sum" : "heatmap.totals.mean"),
374
+ valueText: w,
375
+ visibleText: (p) => p.status === "empty" ? io : p.status === "low-sample" ? "" : w(p),
376
+ countText: b,
377
+ sentence: (p, A, O) => {
378
+ const D = b(O), y = w(O);
379
+ return D === null || O.status === "empty" ? e("heatmap.cell", { row: p, column: A, value: y }) : e("heatmap.cellWithCount", {
380
+ row: p,
381
+ column: A,
382
+ value: y,
383
+ count: D
384
+ });
385
+ },
386
+ formatValue: s
387
+ };
388
+ }
389
+ const Te = 1e12, co = 5e6, uo = co;
390
+ let Tt = 0;
391
+ const tn = new Error("heatmap audit: work limit"), po = 32, Le = (e) => {
392
+ if (Tt += e, Tt > uo) throw tn;
393
+ };
394
+ function Wt(e, t) {
395
+ return {
396
+ n: e,
397
+ head: new Int32Array(e).fill(-1),
398
+ next: new Int32Array(t * 2),
399
+ to: new Int32Array(t * 2),
400
+ edges: 0
401
+ };
402
+ }
403
+ function ht(e, t, n) {
404
+ const o = e.edges;
405
+ return e.to[o] = n, e.next[o] = e.head[t], e.head[t] = o, e.to[o + 1] = t, e.next[o + 1] = e.head[n], e.head[n] = o + 1, e.edges += 2, o;
406
+ }
407
+ function nn(e, t, n, o, s, a, i, u, d) {
408
+ if (n === o) return s;
409
+ const l = a >= 0 ? a >> 1 : -1;
410
+ let v = 0, m = 0;
411
+ for (; v < s - i; ) {
412
+ u.fill(-2), u[n] = -1;
413
+ let w = 0, b = 0;
414
+ d[b++] = n;
415
+ let p = !1;
416
+ for (; w < b && !p; ) {
417
+ const O = d[w++];
418
+ for (let D = e.head[O]; D !== -1; D = e.next[D]) {
419
+ if (m += 1, t[D] <= i || D >> 1 === l) continue;
420
+ const y = e.to[D];
421
+ if (u[y] === -2) {
422
+ if (u[y] = D, y === o) {
423
+ p = !0;
424
+ break;
425
+ }
426
+ d[b++] = y;
427
+ }
428
+ }
429
+ }
430
+ if (Le(m), m = 0, !p) break;
431
+ let A = s - v;
432
+ for (let O = o; O !== n; O = e.to[u[O] ^ 1])
433
+ A = Math.min(A, t[u[O]]);
434
+ for (let O = o; O !== n; O = e.to[u[O] ^ 1])
435
+ t[u[O]] -= A, t[u[O] ^ 1] += A;
436
+ v += A;
437
+ }
438
+ return v;
439
+ }
440
+ function mo(e, t, n, o, s, a) {
441
+ const i = new Uint8Array(e.n), u = -1;
442
+ i[n] = 1;
443
+ let d = 0, l = 0;
444
+ a[l++] = n;
445
+ let v = 0;
446
+ for (; d < l; ) {
447
+ const m = a[d++];
448
+ for (let w = e.head[m]; w !== -1; w = e.next[w]) {
449
+ if (v += 1, t[w] <= s || w >> 1 === u) continue;
450
+ const b = e.to[w];
451
+ i[b] || (i[b] = 1, a[l++] = b);
452
+ }
453
+ }
454
+ return Le(v), i;
455
+ }
456
+ const fo = (e, t) => e.integral ? Math.max(1, Math.ceil(t / 2 - 1e-9)) : Math.max(t / 2, 1e-6);
457
+ function ho(e, t) {
458
+ const n = e.totals.length + e.cells.length + 1, o = new Float64Array(n), s = new Float64Array(n), a = e.mode === "free";
459
+ e.totals.forEach((u, d) => {
460
+ t[d] ? (o[d] = u.value, s[d] = u.value) : (o[d] = a ? -Te : 0, s[d] = Te);
461
+ });
462
+ const i = e.totals.length;
463
+ return e.cells.forEach((u, d) => {
464
+ o[i + d] = a ? -Te : Math.max(u.lo, -Te), s[i + d] = a ? Te : Math.min(u.hi, Te);
465
+ }), o[n - 1] = a ? -Te : 0, s[n - 1] = Te, { lo: o, hi: s };
466
+ }
467
+ function vt(e, t) {
468
+ const n = e.totals.length;
469
+ if (t < n) return [e.totals[t].from, e.totals[t].to];
470
+ if (t < n + e.cells.length) {
471
+ const o = e.cells[t - n];
472
+ return [o.from, o.to];
473
+ }
474
+ return [e.sink, e.source];
475
+ }
476
+ function go(e, t, n) {
477
+ const { lo: o, hi: s } = ho(e, t), a = o.length, i = e.nodeCount;
478
+ Le(a * 4);
479
+ const u = Wt(i + 2, a + i), d = new Float64Array((a + i) * 2), l = new Float64Array(i);
480
+ for (let g = 0; g < a; g += 1) {
481
+ const [R, L] = vt(e, g), V = ht(u, R, L);
482
+ d[V] = s[g] - o[g], l[L] += o[g], l[R] -= o[g];
483
+ }
484
+ const v = i, m = i + 1;
485
+ let w = 0;
486
+ for (let g = 0; g < i; g += 1)
487
+ l[g] > 0 ? (d[ht(u, v, g)] = l[g], w += l[g]) : l[g] < 0 && (d[ht(u, g, m)] = -l[g]);
488
+ const b = new Int32Array(i + 2), p = new Int32Array(i + 2);
489
+ if (nn(
490
+ u,
491
+ d,
492
+ v,
493
+ m,
494
+ 1 / 0,
495
+ -1,
496
+ n,
497
+ b,
498
+ p
499
+ ) < w - n * Math.max(1, a)) return null;
500
+ const O = new Float64Array(a);
501
+ for (let g = 0; g < a; g += 1)
502
+ O[g] = o[g] + (s[g] - o[g] - d[2 * g]);
503
+ const D = Wt(i, a), y = new Float64Array(a * 2);
504
+ for (let g = 0; g < a; g += 1) {
505
+ const [R, L] = vt(e, g), V = ht(D, R, L), J = g < e.totals.length && t[g];
506
+ y[V] = J ? 0 : Math.max(0, s[g] - O[g]), y[V + 1] = J ? 0 : Math.max(0, O[g] - o[g]);
507
+ }
508
+ const E = e.totals.length;
509
+ return {
510
+ graph: D,
511
+ cap: y,
512
+ flow: O,
513
+ closing: a - 1,
514
+ cellArc: (g) => E + g
515
+ };
516
+ }
517
+ function Ut(e, t, n, o, s, a, i, u) {
518
+ if (n === o) return !0;
519
+ u.fill(0);
520
+ const d = s >> 1;
521
+ u[n] = 1;
522
+ let l = 0, v = 0, m = 0;
523
+ for (i[v++] = n; l < v; ) {
524
+ const w = i[l++];
525
+ for (let b = e.head[w]; b !== -1; b = e.next[b]) {
526
+ if (m += 1, t[b] <= a || b >> 1 === d) continue;
527
+ const p = e.to[b];
528
+ if (!u[p]) {
529
+ if (p === o)
530
+ return Le(m), !0;
531
+ u[p] = 1, i[v++] = p;
532
+ }
533
+ }
534
+ }
535
+ return Le(m), !1;
536
+ }
537
+ function vo(e, t, n, o) {
538
+ const s = Array.from(
539
+ { length: n },
540
+ () => []
541
+ );
542
+ return e.totals.forEach((a, i) => {
543
+ t[i] && (s[a.from].push([a.to, a.records, i]), a.value > o && s[a.to].push([a.from, a.records, i]));
544
+ }), Le(e.totals.length), s;
545
+ }
546
+ function sn(e, t, n, o, s, a) {
547
+ const { graph: i, cap: u } = e, d = i.n, l = s >> 1, v = new Float64Array(d).fill(1 / 0), m = new Int32Array(d).fill(-1), w = new Int32Array(d).fill(-1), b = new Uint8Array(d);
548
+ v[n] = 0;
549
+ const p = [[0, n]], A = (y) => {
550
+ p.push(y);
551
+ let E = p.length - 1;
552
+ for (; E > 0; ) {
553
+ const g = E - 1 >> 1;
554
+ if (p[g][0] < y[0] || p[g][0] === y[0] && p[g][1] <= y[1])
555
+ break;
556
+ p[E] = p[g], E = g;
557
+ }
558
+ p[E] = y;
559
+ }, O = () => {
560
+ const y = p[0], E = p.pop();
561
+ if (p.length) {
562
+ let g = 0;
563
+ for (; ; ) {
564
+ const R = 2 * g + 1, L = R + 1;
565
+ let V = g;
566
+ const J = (Y, T) => p[Y][0] < T[0] || p[Y][0] === T[0] && p[Y][1] < T[1];
567
+ let F = E;
568
+ if (R < p.length && J(R, F) && (V = R, F = p[R]), L < p.length && J(L, F) && (V = L, F = p[L]), V === g) break;
569
+ p[g] = p[V], g = V;
570
+ }
571
+ p[g] = E;
572
+ }
573
+ return y;
574
+ };
575
+ for (; p.length; ) {
576
+ const [y, E] = O();
577
+ if (b[E]) continue;
578
+ b[E] = 1;
579
+ let g = 2 + t[E].length;
580
+ for (let R = i.head[E]; R !== -1; R = i.next[R]) g += 1;
581
+ if (Le(g), E === o) break;
582
+ for (let R = i.head[E]; R !== -1; R = i.next[R]) {
583
+ if (u[R] <= a || R >> 1 === l) continue;
584
+ const L = i.to[R];
585
+ y < v[L] && (v[L] = y, m[L] = -1, w[L] = E, A([y, L]));
586
+ }
587
+ for (const [R, L, V] of t[E])
588
+ y + L < v[R] && (v[R] = y + L, m[R] = V, w[R] = E, A([y + L, R]));
589
+ }
590
+ if (!Number.isFinite(v[o])) return [];
591
+ const D = [];
592
+ for (let y = o; y !== n; y = w[y])
593
+ m[y] >= 0 && D.push(m[y]);
594
+ return D.sort((y, E) => y - E);
595
+ }
596
+ function wo(e, t, n, o, s, a) {
597
+ const i = [], { graph: u, cap: d } = n, l = new Int32Array(u.n), v = new Int32Array(u.n), m = new Uint8Array(u.n), w = [], b = n.flow.length, p = new Uint8Array(b), A = e.mode === "rate" && e.integral, O = (g, R, L, V) => L <= o ? 0 : A && L <= 1 + o ? Ut(u, d, g, R, V, o, v, m) ? L : 0 : (Le(d.length >> 2), nn(u, d.slice(), g, R, L, V, o, l, v));
598
+ let D = null;
599
+ const y = () => (D = D ?? vo(e, t, u.n, o), D);
600
+ let E = 0;
601
+ for (const g of s) {
602
+ const R = e.cells[g], L = n.cellArc(g), [V, J] = vt(e, L), F = 2 * L;
603
+ let Y, T, N, K, z;
604
+ if (e.mode === "rate") {
605
+ const c = fo(e, R.records);
606
+ T = Math.min(d[F], c), K = O(J, V, T, F), N = Math.min(d[F + 1], c - K), z = O(V, J, N, F), Y = K + z >= c - o;
607
+ } else {
608
+ const c = n.flow[L];
609
+ N = d[F + 1], z = O(V, J, N, F);
610
+ const I = Math.max(c - 2 * z, z > o ? 0 : o * 4);
611
+ T = Math.min(d[F], I), K = I > 0 ? O(J, V, T, F) : 0, Y = I <= 0 || K >= I - o;
612
+ }
613
+ if (K + z <= o && (p[L] = 1), Y) continue;
614
+ if (i.push(g), a) {
615
+ w.push({ allOf: [] });
616
+ break;
617
+ }
618
+ if (E >= po) continue;
619
+ E += 1;
620
+ const $ = /* @__PURE__ */ new Set();
621
+ if (K < T - o)
622
+ for (const c of sn(n, y(), J, V, F, o))
623
+ $.add(c);
624
+ if (z < N - o)
625
+ for (const c of sn(n, y(), V, J, F, o))
626
+ $.add(c);
627
+ if ($.size === 0)
628
+ for (const c of e.cellTotals[g]) t[c] && $.add(c);
629
+ w.push({ allOf: [...$].sort((c, I) => c - I) });
630
+ }
631
+ return { disclosures: w, failed: i, pinned: p };
632
+ }
633
+ function bo(e, t, n, o, s) {
634
+ const { graph: a, cap: i } = n, u = new Int32Array(a.n), d = new Uint8Array(a.n), l = (v) => {
635
+ const [m, w] = vt(e, v), b = 2 * v;
636
+ i[b] > s && Ut(a, i, w, m, b, s, u, d) || i[b + 1] > s && Ut(a, i, m, w, b, s, u, d) || (o[v] = 1);
637
+ };
638
+ e.totals.forEach((v, m) => {
639
+ t[m] || l(m);
640
+ }), l(n.closing);
641
+ }
642
+ function ln(e, t, n, o) {
643
+ const s = e.nodeCount, a = new Int32Array(s);
644
+ for (let c = 0; c < s; c += 1) a[c] = c;
645
+ const i = (c) => {
646
+ let I = c;
647
+ for (; a[I] !== I; ) I = a[I];
648
+ for (; a[c] !== I; ) {
649
+ const P = a[c];
650
+ a[c] = I, c = P;
651
+ }
652
+ return I;
653
+ }, u = (c, I) => {
654
+ const P = i(c), C = i(I);
655
+ P !== C && (a[Math.max(P, C)] = Math.min(P, C));
656
+ };
657
+ e.totals.forEach((c, I) => {
658
+ !t[I] && !o[I] && u(c.from, c.to);
659
+ }), o[n.closing] || u(e.sink, e.source);
660
+ const d = /* @__PURE__ */ new Map();
661
+ e.cells.forEach((c, I) => {
662
+ if (o[n.cellArc(I)]) return;
663
+ const P = i(c.from), C = i(c.to);
664
+ if (P === C) return;
665
+ const Q = P * s + C, te = d.get(Q) ?? { from: P, to: C, weight: 0, cells: [] };
666
+ te.weight += c.records > 0 ? c.records : e.minCount, te.cells.push(I), d.set(Q, te);
667
+ });
668
+ const l = [...d.values()].sort(
669
+ (c, I) => c.from - I.from || c.to - I.to
670
+ );
671
+ if (l.length === 0) return [];
672
+ const v = [...new Set(l.flatMap((c) => [c.from, c.to]))].sort(
673
+ (c, I) => c - I
674
+ ), m = new Map(v.map((c, I) => [c, I])), w = v.length, b = Array.from({ length: w }, () => []);
675
+ l.forEach((c, I) => b[m.get(c.from)].push(I));
676
+ const p = new Int32Array(w).fill(-1);
677
+ {
678
+ const c = new Int32Array(w).fill(-1), I = new Int32Array(w), P = new Uint8Array(w), C = [];
679
+ let Q = 0, te = 0;
680
+ for (let x = 0; x < w; x += 1) {
681
+ if (c[x] !== -1) continue;
682
+ const _ = [[x, 0]];
683
+ for (c[x] = I[x] = Q++, C.push(x), P[x] = 1; _.length; ) {
684
+ const W = _[_.length - 1], [G, q] = W;
685
+ if (q < b[G].length) {
686
+ W[1] += 1;
687
+ const B = m.get(l[b[G][q]].to);
688
+ c[B] === -1 ? (c[B] = I[B] = Q++, C.push(B), P[B] = 1, _.push([B, 0])) : P[B] && (I[G] = Math.min(I[G], c[B]));
689
+ } else {
690
+ if (_.pop(), _.length) {
691
+ const B = _[_.length - 1][0];
692
+ I[B] = Math.min(I[B], I[G]);
693
+ }
694
+ if (I[G] === c[G]) {
695
+ let B;
696
+ do
697
+ B = C.pop(), P[B] = 0, p[B] = te;
698
+ while (B !== G);
699
+ te += 1;
700
+ }
701
+ }
702
+ }
703
+ }
704
+ }
705
+ const A = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map();
706
+ for (const c of l) {
707
+ const I = p[m.get(c.from)], P = p[m.get(c.to)];
708
+ if (I === P) continue;
709
+ const C = `${I}>${P}`, Q = A.get(C) ?? { a: I, b: P, weight: 0 };
710
+ Q.weight += c.weight, A.set(C, Q), O.set(C, [...O.get(C) ?? [], ...c.cells]);
711
+ }
712
+ if (A.size === 0) return [];
713
+ const D = [...A.entries()].sort(([c], [I]) => c < I ? -1 : 1), y = [...new Set(D.flatMap(([, c]) => [c.a, c.b]))].sort(
714
+ (c, I) => c - I
715
+ ), E = new Map(y.map((c, I) => [c, I])), g = y.length, R = new Int32Array(g);
716
+ for (let c = 0; c < g; c += 1) R[c] = c;
717
+ const L = (c) => {
718
+ for (; R[c] !== c; )
719
+ R[c] = R[R[c]], c = R[c];
720
+ return c;
721
+ };
722
+ for (const [, c] of D) {
723
+ const I = L(E.get(c.a)), P = L(E.get(c.b));
724
+ I !== P && (R[Math.max(I, P)] = Math.min(I, P));
725
+ }
726
+ const V = Wt(g, D.length), J = new Float64Array(D.length * 2);
727
+ for (const [, c] of D) {
728
+ const I = ht(
729
+ V,
730
+ E.get(c.a),
731
+ E.get(c.b)
732
+ );
733
+ J[I] = c.weight, J[I + 1] = Te;
734
+ }
735
+ const F = new Int32Array(g), Y = new Int32Array(g), T = /* @__PURE__ */ new Map(), N = (c) => {
736
+ const I = new Uint8Array(s), P = new Uint8Array(s), C = /* @__PURE__ */ new Map();
737
+ y.forEach((Q, te) => C.set(Q, c[te]));
738
+ for (let Q = 0; Q < s; Q += 1) {
739
+ const te = m.get(i(Q));
740
+ te !== void 0 && (P[Q] = 1, I[Q] = C.get(p[te]) ?? 0);
741
+ }
742
+ return { nodeSide: I, inGraph: P };
743
+ }, K = (c) => {
744
+ const I = [];
745
+ for (const [W, G] of D) {
746
+ const q = E.get(G.a), B = E.get(G.b);
747
+ c[q] === 1 && c[B] === 0 && I.push(...O.get(W) ?? []);
748
+ }
749
+ I.sort((W, G) => W - G);
750
+ const P = I.join(",");
751
+ if (T.has(P)) return;
752
+ const { nodeSide: C, inGraph: Q } = N(c), te = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set();
753
+ e.totals.forEach((W, G) => {
754
+ !t[G] || C[W.from] === C[W.to] || (Q[W.from] && Q[W.to] ? te.add(G) : x.add(G));
755
+ });
756
+ const _ = te.size > 0 ? te : x;
757
+ if (_.size === 0)
758
+ for (const W of I)
759
+ for (const G of e.cellTotals[W]) t[G] && _.add(G);
760
+ T.set(P, { anyOf: [..._].sort((W, G) => W - G) });
761
+ }, z = e.minCount, $ = /* @__PURE__ */ new Map();
762
+ for (let c = 0; c < g; c += 1) {
763
+ const I = L(c);
764
+ $.has(I) || $.set(I, c);
765
+ }
766
+ for (let c = 0; c < g; c += 1) {
767
+ const I = $.get(L(c));
768
+ if (I !== c)
769
+ for (const [P, C] of [
770
+ [I, c],
771
+ [c, I]
772
+ ]) {
773
+ Le(J.length >> 2);
774
+ const Q = J.slice();
775
+ if (nn(V, Q, P, C, z, -1, 1e-9, F, Y) < z - 1e-9) {
776
+ const x = mo(V, Q, P, -1, 1e-9, Y);
777
+ K(x);
778
+ }
779
+ }
780
+ }
781
+ return [...T.values()];
782
+ }
783
+ function yo(e, t) {
784
+ const n = e.nodeCount, o = e.totals.length + e.cells.length + 1, s = Array.from({ length: n }, () => []);
785
+ for (let l = 0; l < o; l += 1) {
786
+ if (l < e.totals.length && t[l]) continue;
787
+ const [v, m] = vt(e, l);
788
+ s[v].push([m, l]), s[m].push([v, l]);
789
+ }
790
+ const a = new Uint8Array(o), i = new Int32Array(n).fill(-1), u = new Int32Array(n);
791
+ let d = 0;
792
+ for (let l = 0; l < n; l += 1) {
793
+ if (i[l] !== -1) continue;
794
+ const v = [[l, -1, 0]];
795
+ for (i[l] = u[l] = d++; v.length; ) {
796
+ const m = v[v.length - 1], [w, b, p] = m;
797
+ if (p < s[w].length) {
798
+ m[2] += 1;
799
+ const [A, O] = s[w][p];
800
+ if (O === b) continue;
801
+ i[A] === -1 ? (i[A] = u[A] = d++, v.push([A, O, 0])) : u[w] = Math.min(u[w], i[A]);
802
+ } else if (v.pop(), v.length) {
803
+ const A = v[v.length - 1][0];
804
+ u[A] = Math.min(u[A], u[w]), u[w] > i[A] && (a[b] = 1);
805
+ }
806
+ }
807
+ }
808
+ return a;
809
+ }
810
+ function Ln(e, t, n, o, s = !1) {
811
+ if (e.mode === "free") {
812
+ const u = yo(e, t), d = [], l = [];
813
+ for (const m of o)
814
+ if (u[e.totals.length + m]) {
815
+ if (s) return { disclosures: [{ allOf: [] }], cells: [m] };
816
+ l.push(m), d.push({
817
+ anyOf: e.cellTotals[m].filter((w) => t[w])
818
+ });
819
+ }
820
+ if (d.length) return { disclosures: d, cells: l };
821
+ const v = {
822
+ closing: e.totals.length + e.cells.length,
823
+ cellArc: (m) => e.totals.length + m
824
+ };
825
+ return {
826
+ disclosures: ln(e, t, v, u),
827
+ cells: []
828
+ };
829
+ }
830
+ const a = go(e, t, n);
831
+ if (!a) return null;
832
+ const i = wo(e, t, a, n, o, s);
833
+ return i.disclosures.length ? { disclosures: i.disclosures, cells: i.failed } : (bo(e, t, a, i.pinned, n), {
834
+ disclosures: ln(e, t, a, i.pinned),
835
+ cells: []
836
+ });
837
+ }
838
+ function xo(e, t) {
839
+ const n = /* @__PURE__ */ new Set();
840
+ for (const s of t) for (const a of s.allOf ?? []) n.add(a);
841
+ let o = t.filter(
842
+ (s) => s.anyOf && s.anyOf.length > 0 && !s.anyOf.some((a) => n.has(a))
843
+ );
844
+ for (; o.length; ) {
845
+ const s = /* @__PURE__ */ new Map();
846
+ for (const i of o)
847
+ for (const u of i.anyOf ?? []) s.set(u, (s.get(u) ?? 0) + 1);
848
+ let a = -1;
849
+ for (const [i, u] of s) {
850
+ const d = s.get(a) ?? -1;
851
+ (a === -1 || u > d || u === d && (e.totals[i].records < e.totals[a].records || e.totals[i].records === e.totals[a].records && i < a)) && (a = i);
852
+ }
853
+ n.add(a), o = o.filter((i) => !(i.anyOf ?? []).includes(a));
854
+ }
855
+ return [...n].sort((s, a) => s - a);
856
+ }
857
+ function Io(e, t = 0) {
858
+ Tt = t;
859
+ try {
860
+ return Mo(e);
861
+ } catch (n) {
862
+ if (n !== tn) throw n;
863
+ const o = new Uint8Array(e.totals.length);
864
+ for (const s of e.cellTotals)
865
+ for (const a of s) o[a] = 1;
866
+ return e.totals.map((s, a) => s.shown && !o[a]);
867
+ }
868
+ }
869
+ function ko() {
870
+ return Tt;
871
+ }
872
+ function Mo(e) {
873
+ const t = e.totals.map((m) => m.shown);
874
+ if (e.cells.length === 0) return t;
875
+ let n = 1;
876
+ for (const m of e.totals)
877
+ m.shown && (n = Math.max(n, Math.abs(m.value)));
878
+ for (const m of e.cells)
879
+ Number.isFinite(m.hi) && (n = Math.max(n, Math.abs(m.hi)));
880
+ const o = 1e-9 * n, s = new Uint8Array(e.totals.length);
881
+ for (const m of e.cellTotals)
882
+ for (const w of m) s[w] = 1;
883
+ const a = () => t.map((m, w) => m && !s[w]), i = e.cells.map((m, w) => w);
884
+ let u = i;
885
+ const d = [], l = e.totals.length + 1;
886
+ for (let m = 0; ; m += 1) {
887
+ if (m > l) return a();
888
+ const w = Ln(e, t, o, u);
889
+ if (w === null) return a();
890
+ if (w.disclosures.length === 0) break;
891
+ const b = xo(e, w.disclosures);
892
+ if (b.length === 0) return a();
893
+ for (const p of b)
894
+ t[p] = !1, d.push(p);
895
+ u = w.cells;
896
+ }
897
+ const v = [...d].sort(
898
+ (m, w) => e.totals[w].records - e.totals[m].records || m - w
899
+ );
900
+ for (const m of v)
901
+ t[m] = !0, So(e, t, m, i, o) || (t[m] = !1);
902
+ return t;
903
+ }
904
+ function So(e, t, n, o, s) {
905
+ try {
906
+ const a = /* @__PURE__ */ new Set();
907
+ e.cellTotals.forEach((d, l) => {
908
+ d.includes(n) && a.add(l);
909
+ });
910
+ const i = [...a, ...o.filter((d) => !a.has(d))], u = Ln(e, t, s, i, !0);
911
+ return u !== null && u.disclosures.length === 0;
912
+ } catch (a) {
913
+ if (a !== tn) throw a;
914
+ return !1;
915
+ }
916
+ }
917
+ const Re = 10, on = Math.floor(Re / 2), ot = Re - 1, et = Re / 2, rt = (e, t, n) => Math.min(n, Math.max(t, e)), cn = /* @__PURE__ */ new Set();
918
+ function Yt(e) {
919
+ !Zn() || cn.has(e) || (cn.add(e), console.warn(`Heatmap: ${e}`));
920
+ }
921
+ function dn(e) {
922
+ return e[0] <= e[1] ? e : (Yt(
923
+ `scale domain [${e[0]}, ${e[1]}] is reversed; using [${e[1]}, ${e[0]}].`
924
+ ), [e[1], e[0]]);
925
+ }
926
+ function On(e) {
927
+ const t = e.filter(Number.isFinite).sort((n, o) => n - o);
928
+ return t.filter((n, o) => o === 0 || n !== t[o - 1]);
929
+ }
930
+ function Ao(e) {
931
+ let t = 1 / 0, n = -1 / 0;
932
+ for (const o of e)
933
+ Number.isFinite(o) && (o < t && (t = o), o > n && (n = o));
934
+ return t === 1 / 0 ? null : [t, n];
935
+ }
936
+ function No(e, t, n) {
937
+ if (!(n > t)) return on;
938
+ const o = rt((e - t) / (n - t), 0, 1);
939
+ return Math.min(ot, Math.floor(o * Re));
940
+ }
941
+ function _o(e, t, n, o) {
942
+ if (e < n) {
943
+ const i = n - t, u = i > 0 ? rt((n - e) / i, 0, 1) : 1;
944
+ return et - 1 - Math.min(et - 1, Math.floor(u * et));
945
+ }
946
+ const s = o - n, a = s > 0 ? rt((e - n) / s, 0, 1) : e > n ? 1 : 0;
947
+ return et + Math.min(et - 1, Math.floor(a * et));
948
+ }
949
+ function Ro(e, t) {
950
+ if (e.type !== "diverging" || e.midpoint === void 0) return !1;
951
+ const n = Math.max(
952
+ Math.abs(e.midpoint),
953
+ Math.abs(e.min ?? 0),
954
+ Math.abs(e.max ?? 0)
955
+ );
956
+ return Math.abs(t - e.midpoint) <= n * Number.EPSILON * 16;
957
+ }
958
+ function Eo(e, t) {
959
+ const n = e.length;
960
+ if (n === 0) return NaN;
961
+ if (n === 1) return e[0];
962
+ const o = rt(t, 0, 1) * (n - 1), s = Math.floor(o), a = Math.min(n - 1, s + 1);
963
+ return e[s] + (e[a] - e[s]) * (o - s);
964
+ }
965
+ function To(e, t) {
966
+ const n = Math.max(1, Math.round(t)), o = [];
967
+ for (let s = 1; s < n; s += 1)
968
+ o.push(Eo(e, s / n));
969
+ return o;
970
+ }
971
+ function Lo(e, t) {
972
+ if (e.length === 0) return [];
973
+ const n = e[0], o = (s) => {
974
+ let a = 0, i = e.length - 1;
975
+ for (; a < i; ) {
976
+ const u = a + i >>> 1;
977
+ e[u] < s ? a = u + 1 : i = u;
978
+ }
979
+ return e[a];
980
+ };
981
+ return On(
982
+ To(e, t).map(o)
983
+ ).filter((s) => s > n);
984
+ }
985
+ function un(e, t) {
986
+ let n = 0, o = t.length;
987
+ for (; n < o; ) {
988
+ const s = n + o >>> 1;
989
+ t[s] <= e ? n = s + 1 : o = s;
990
+ }
991
+ return n;
992
+ }
993
+ function Jt(e, t) {
994
+ return t <= 1 ? on : Math.round(
995
+ rt(e, 0, t - 1) * ot / (t - 1)
996
+ );
997
+ }
998
+ function Qt(e, t) {
999
+ const n = Ao(t);
1000
+ switch (e.type) {
1001
+ case "diverging": {
1002
+ const o = e.domain && e.domain !== "auto" ? dn(e.domain) : null, s = e.midpoint ?? (o && (o[0] > 0 || o[1] < 0) ? (o[0] + o[1]) / 2 : 0);
1003
+ let a, i;
1004
+ if (o)
1005
+ [a, i] = o;
1006
+ else {
1007
+ const u = n ? Math.max(
1008
+ Math.abs(n[0] - s),
1009
+ Math.abs(n[1] - s)
1010
+ ) : 0;
1011
+ a = s - u, i = s + u;
1012
+ }
1013
+ return {
1014
+ type: "diverging",
1015
+ min: a,
1016
+ max: i,
1017
+ midpoint: s,
1018
+ thresholds: [],
1019
+ stepOf: (u) => _o(u, a, s, i)
1020
+ };
1021
+ }
1022
+ case "quantile": {
1023
+ const o = t.filter(Number.isFinite).slice().sort((i, u) => i - u), s = rt(
1024
+ Math.round(e.buckets ?? Re),
1025
+ 2,
1026
+ Re
1027
+ ), a = Lo(o, s);
1028
+ return {
1029
+ type: "quantile",
1030
+ min: (n == null ? void 0 : n[0]) ?? null,
1031
+ max: (n == null ? void 0 : n[1]) ?? null,
1032
+ thresholds: a,
1033
+ stepOf: (i) => Jt(un(i, a), a.length + 1)
1034
+ };
1035
+ }
1036
+ case "threshold": {
1037
+ const o = e.thresholds.filter(Number.isFinite), s = On(o);
1038
+ s.length !== o.length && Yt("duplicate thresholds merged."), s.length > ot && Yt(
1039
+ `${s.length} thresholds given; ten steps take at most ${ot}, so the highest ${s.length - ot} are dropped.`
1040
+ );
1041
+ const a = s.slice(0, ot);
1042
+ return {
1043
+ type: "threshold",
1044
+ min: (n == null ? void 0 : n[0]) ?? null,
1045
+ max: (n == null ? void 0 : n[1]) ?? null,
1046
+ thresholds: a,
1047
+ stepOf: (i) => Jt(un(i, a), a.length + 1)
1048
+ };
1049
+ }
1050
+ case "sequential":
1051
+ default: {
1052
+ const o = e.domain && e.domain !== "auto" ? dn(e.domain) : null, s = o ? o[0] : (n == null ? void 0 : n[0]) ?? null, a = o ? o[1] : (n == null ? void 0 : n[1]) ?? null;
1053
+ return {
1054
+ type: "sequential",
1055
+ min: s,
1056
+ max: a,
1057
+ thresholds: [],
1058
+ stepOf: (i) => s === null || a === null ? on : No(i, s, a)
1059
+ };
1060
+ }
1061
+ }
1062
+ }
1063
+ function Oo(e) {
1064
+ let t = 0, n = !1, o = 0, s = !1;
1065
+ for (const a of e)
1066
+ a.value === null || !Number.isFinite(a.value) || (t += a.value, n = !0, a.count !== void 0 && (o += a.count, s = !0));
1067
+ return { value: n ? t : null, count: s ? o : void 0 };
1068
+ }
1069
+ function Co(e) {
1070
+ let t = 0, n = 0, o = 0, s = !1;
1071
+ for (const a of e) {
1072
+ if (a.value === null || !Number.isFinite(a.value)) continue;
1073
+ const i = a.count ?? 1;
1074
+ t += a.value * i, n += i, a.count !== void 0 && (o += a.count, s = !0);
1075
+ }
1076
+ return {
1077
+ value: n > 0 ? t / n : null,
1078
+ count: s ? o : void 0
1079
+ };
1080
+ }
1081
+ function Ho(e, t) {
1082
+ return t === "sum" ? Oo(e) : Co(e);
1083
+ }
1084
+ function Do(e, t) {
1085
+ const n = new Set(t == null ? void 0 : t.map((i) => i.id)), o = new Set(n), s = /* @__PURE__ */ new Map();
1086
+ let a = 0;
1087
+ for (const i of e) {
1088
+ const u = i.group;
1089
+ if (u === void 0 || s.has(u)) continue;
1090
+ if (n.has(u)) {
1091
+ s.set(u, u);
1092
+ continue;
1093
+ }
1094
+ let d;
1095
+ do
1096
+ a += 1, d = `group-${a}`;
1097
+ while (o.has(d));
1098
+ o.add(d), s.set(u, d);
1099
+ }
1100
+ return s;
1101
+ }
1102
+ function Cn(e, t) {
1103
+ return t !== void 0 && e !== void 0 && e < t;
1104
+ }
1105
+ function Hn(e, t) {
1106
+ if (e == null)
1107
+ return { value: null, status: "empty" };
1108
+ const n = typeof e == "number" ? { value: e } : e, o = n.value === null || !Number.isFinite(n.value) ? null : n.value, s = Cn(n.count, t) && (o !== null || (n.count ?? 0) > 0) ? "low-sample" : o === null ? "empty" : "value";
1109
+ return { value: o, count: n.count, label: n.label, status: s };
1110
+ }
1111
+ function Ko(e, t, n, o, s) {
1112
+ return e.map(
1113
+ (a, i) => t.map(
1114
+ (u, d) => {
1115
+ var l;
1116
+ return Hn(
1117
+ n ? n(a, u, i, d) : (l = o == null ? void 0 : o[i]) == null ? void 0 : l[d],
1118
+ s
1119
+ );
1120
+ }
1121
+ )
1122
+ );
1123
+ }
1124
+ function zo(e) {
1125
+ const t = [];
1126
+ for (const n of e)
1127
+ for (const o of n)
1128
+ o.status === "value" && o.value !== null && t.push(o.value);
1129
+ return t;
1130
+ }
1131
+ function Fo(e) {
1132
+ return e.some((t) => t.some((n) => n.status !== "empty"));
1133
+ }
1134
+ const Bo = {
1135
+ value: null,
1136
+ status: "low-sample",
1137
+ withheld: !0
1138
+ }, Vo = {
1139
+ rows: !0,
1140
+ columns: !0,
1141
+ grand: !0,
1142
+ groups: !0,
1143
+ groupColumns: !0
1144
+ };
1145
+ function Go(e, t, n) {
1146
+ const o = Ho(e, t);
1147
+ return {
1148
+ value: o.value,
1149
+ count: o.count,
1150
+ status: o.value === null ? "empty" : Cn(o.count, n) ? "low-sample" : "value"
1151
+ };
1152
+ }
1153
+ function $o(e, t, n, o) {
1154
+ const {
1155
+ rowMethod: s,
1156
+ columnMethod: a,
1157
+ groupColumnMethod: i,
1158
+ groups: u,
1159
+ minCount: d,
1160
+ getTotal: l,
1161
+ valueType: v = "number"
1162
+ } = o, m = o.shown ?? Vo, w = t.map((T, N) => N), b = n.map((T, N) => N), p = [], A = (T, N, K, z, $) => {
1163
+ const c = [];
1164
+ for (const x of K)
1165
+ for (const _ of z) c.push(e[x][_]);
1166
+ let I = 0, P = !1, C = !1;
1167
+ for (const x of c)
1168
+ x.status === "low-sample" && (P = !0, I += x.count ?? 0, x.value === null && (C = !0));
1169
+ const Q = T === void 0 ? Go(c, N, d) : Hn(T, d), te = Q.status === "low-sample" || T === void 0 && C || d !== void 0 && I > 0 && I < d;
1170
+ return p.push({
1171
+ method: N,
1172
+ rowIndexes: K,
1173
+ columnIndexes: z,
1174
+ own: Q,
1175
+ primary: te,
1176
+ visible: $,
1177
+ holdsHidden: P
1178
+ }), p.length - 1;
1179
+ }, O = t.map(
1180
+ (T, N) => A(
1181
+ l == null ? void 0 : l({
1182
+ kind: "row",
1183
+ method: s,
1184
+ row: T,
1185
+ rowId: T.id,
1186
+ rowIndex: N
1187
+ }),
1188
+ s,
1189
+ [N],
1190
+ b,
1191
+ m.rows
1192
+ )
1193
+ ), D = /* @__PURE__ */ new Map();
1194
+ t.forEach((T, N) => {
1195
+ if (T.group === void 0) return;
1196
+ const K = D.get(T.group) ?? [];
1197
+ K.push(N), D.set(T.group, K);
1198
+ });
1199
+ const y = new Map(u == null ? void 0 : u.map((T) => [T.id, T])), E = (T, N) => {
1200
+ const K = y.get(T);
1201
+ return {
1202
+ groupId: T,
1203
+ ...K === void 0 ? {} : { group: K },
1204
+ rows: N.map((z) => t[z]),
1205
+ rowIndexes: N
1206
+ };
1207
+ }, g = /* @__PURE__ */ new Map();
1208
+ for (const [T, N] of D) {
1209
+ const K = E(T, N);
1210
+ g.set(
1211
+ T,
1212
+ n.map(
1213
+ (z, $) => A(
1214
+ l == null ? void 0 : l({
1215
+ kind: "group-column",
1216
+ method: i,
1217
+ ...K,
1218
+ column: z,
1219
+ columnId: z.id,
1220
+ columnIndex: $
1221
+ }),
1222
+ i,
1223
+ N,
1224
+ [$],
1225
+ m.groupColumns
1226
+ )
1227
+ )
1228
+ );
1229
+ }
1230
+ const R = n.map(
1231
+ (T, N) => A(
1232
+ l == null ? void 0 : l({
1233
+ kind: "column",
1234
+ method: a,
1235
+ column: T,
1236
+ columnId: T.id,
1237
+ columnIndex: N
1238
+ }),
1239
+ a,
1240
+ w,
1241
+ [N],
1242
+ m.columns
1243
+ )
1244
+ ), L = /* @__PURE__ */ new Map();
1245
+ for (const [T, N] of D)
1246
+ L.set(
1247
+ T,
1248
+ A(
1249
+ l == null ? void 0 : l({
1250
+ kind: "group",
1251
+ method: s,
1252
+ ...E(T, N)
1253
+ }),
1254
+ s,
1255
+ N,
1256
+ b,
1257
+ m.groups
1258
+ )
1259
+ );
1260
+ const V = A(
1261
+ l == null ? void 0 : l({ kind: "grand", method: s }),
1262
+ s,
1263
+ w,
1264
+ b,
1265
+ m.grand
1266
+ ), J = p.map((T) => T.primary);
1267
+ Po({
1268
+ matrix: e,
1269
+ rows: t,
1270
+ drafts: p,
1271
+ rowDrafts: O,
1272
+ columnDrafts: R,
1273
+ groupDrafts: L,
1274
+ groupColumnDrafts: g,
1275
+ grandDraft: V,
1276
+ members: D,
1277
+ valueType: v,
1278
+ minCount: d
1279
+ }).forEach((T, N) => {
1280
+ T || (J[N] = !0);
1281
+ });
1282
+ const Y = (T) => J[T] ? Bo : p[T].own;
1283
+ return {
1284
+ rows: O.map(Y),
1285
+ columns: R.map(Y),
1286
+ grand: Y(V),
1287
+ groupColumns: new Map(
1288
+ [...g].map(([T, N]) => [
1289
+ T,
1290
+ N.map(Y)
1291
+ ])
1292
+ ),
1293
+ groups: new Map(
1294
+ [...L].map(([T, N]) => [T, Y(N)])
1295
+ )
1296
+ };
1297
+ }
1298
+ function Po(e) {
1299
+ const { matrix: t, rows: n, drafts: o, members: s, valueType: a, minCount: i } = e, u = o.map(() => !0);
1300
+ if (i === void 0) return u;
1301
+ const d = o.map(
1302
+ (x) => x.visible && !x.primary && x.own.value !== null
1303
+ ), l = new Set(
1304
+ o.filter((x, _) => d[_] && x.holdsHidden).map((x) => x.method)
1305
+ );
1306
+ if (l.size === 0) return u;
1307
+ const v = () => o.map((x, _) => !(d[_] && x.holdsHidden));
1308
+ if (l.size > 1) return v();
1309
+ const m = [...l][0];
1310
+ if (a === "rate" && m === "sum") return v();
1311
+ const w = (x) => m === "mean" ? x.count ?? 1 : 1, b = a === "rate";
1312
+ if (!b && m === "mean") return v();
1313
+ const p = (x) => x.status === "low-sample" && (m === "sum" || (x.count ?? 0) > 0), A = 0, O = 1, D = 2;
1314
+ let y = 3;
1315
+ const E = /* @__PURE__ */ new Map();
1316
+ for (const x of s.keys()) E.set(x, y++);
1317
+ const g = n.map(() => y++), R = /* @__PURE__ */ new Map(), L = e.columnDrafts.length;
1318
+ for (const x of s.keys())
1319
+ R.set(
1320
+ x,
1321
+ Array.from({ length: L }, () => y++)
1322
+ );
1323
+ const V = e.columnDrafts.map(() => y++), J = (x) => n[x].group, F = o.map(() => [0, 0]);
1324
+ e.rowDrafts.forEach((x, _) => {
1325
+ const W = J(_);
1326
+ F[x] = [
1327
+ W === void 0 ? D : E.get(W),
1328
+ g[_]
1329
+ ];
1330
+ });
1331
+ for (const [x, _] of e.groupDrafts)
1332
+ F[_] = [D, E.get(x)];
1333
+ for (const [x, _] of e.groupColumnDrafts)
1334
+ _.forEach((W, G) => {
1335
+ F[W] = [R.get(x)[G], V[G]];
1336
+ });
1337
+ e.columnDrafts.forEach((x, _) => {
1338
+ F[x] = [V[_], O];
1339
+ }), F[e.grandDraft] = [A, D];
1340
+ const Y = [], T = [];
1341
+ let N = !0, K = !0;
1342
+ if (t.forEach((x, _) => {
1343
+ x.forEach((W, G) => {
1344
+ if (W.value !== null && W.value < 0 && (K = !1), !p(W)) return;
1345
+ Number.isInteger(W.count ?? 0) || (N = !1);
1346
+ const q = J(_);
1347
+ Y.push({
1348
+ from: g[_],
1349
+ to: q === void 0 ? V[G] : R.get(q)[G],
1350
+ lo: 0,
1351
+ hi: a === "rate" ? W.count ?? 0 : 1 / 0,
1352
+ records: W.count ?? 0
1353
+ });
1354
+ const B = [
1355
+ e.rowDrafts[_],
1356
+ e.columnDrafts[G],
1357
+ e.grandDraft
1358
+ ];
1359
+ q !== void 0 && B.push(
1360
+ e.groupDrafts.get(q),
1361
+ e.groupColumnDrafts.get(q)[G]
1362
+ ), T.push(B.sort((re, ne) => re - ne));
1363
+ });
1364
+ }), Y.length === 0) return u;
1365
+ const z = (x) => Math.abs(x - Math.round(x)) <= 1e-9 * Math.max(1, Math.abs(x));
1366
+ let $ = !0, c = !1;
1367
+ const I = (x, _) => x.count === void 0 ? _ : Math.round(_), P = o.map((x, _) => {
1368
+ let W = 0, G = 0, q = 0, B = 0, re = 0;
1369
+ for (const Ne of x.rowIndexes)
1370
+ for (const be of x.columnIndexes) {
1371
+ const Z = t[Ne][be];
1372
+ if (Z.status !== "empty") {
1373
+ if (G += w(Z), W += Z.count ?? 1, p(Z)) re += 1;
1374
+ else if (Z.value !== null) {
1375
+ const pe = w(Z) * Z.value;
1376
+ z(pe) || ($ = !1), q += pe, B += I(Z, pe);
1377
+ }
1378
+ }
1379
+ }
1380
+ let ne = 0, Me = 0;
1381
+ if (d[_] && re > 0) {
1382
+ const Ne = x.own.value;
1383
+ ne = m === "mean" ? Ne * G : Ne, z(ne) || ($ = !1), m === "mean" && x.own.count !== void 0 && Math.abs(x.own.count - G) > 1e-9 * Math.max(1, G) && (c = !0), Me = x.own.count === void 0 ? ne : Math.round(ne);
1384
+ }
1385
+ return { records: W, exact: q, rounded: B, unknowns: re, whole: ne, wholeRounded: Me };
1386
+ });
1387
+ if (c) return v();
1388
+ o.forEach((x, _) => {
1389
+ d[_] && x.own.value < 0 && (K = !1);
1390
+ });
1391
+ const C = a === "rate" ? "rate" : K ? "scaled" : "free", Q = (x, _, W) => {
1392
+ const G = o.map((q, B) => {
1393
+ const re = P[B];
1394
+ let ne = 0;
1395
+ if (_[B] && re.unknowns > 0) {
1396
+ ne = x ? re.wholeRounded - re.rounded : re.whole - re.exact;
1397
+ const Me = 1e-9 * Math.max(1, Math.abs(re.whole), Math.abs(re.exact));
1398
+ ne < 0 && ne > -Me && (ne = 0);
1399
+ }
1400
+ return {
1401
+ from: F[B][0],
1402
+ to: F[B][1],
1403
+ value: ne,
1404
+ shown: _[B],
1405
+ records: re.records
1406
+ };
1407
+ });
1408
+ return Io(
1409
+ {
1410
+ nodeCount: y,
1411
+ sink: O,
1412
+ source: A,
1413
+ cells: Y,
1414
+ totals: G,
1415
+ cellTotals: T,
1416
+ mode: C,
1417
+ integral: b && N && (x || $),
1418
+ minCount: i
1419
+ },
1420
+ W
1421
+ );
1422
+ };
1423
+ let te;
1424
+ if (!b || $)
1425
+ te = Q(b, d, 0);
1426
+ else {
1427
+ const x = Q(!0, d, 0);
1428
+ te = Q(
1429
+ !1,
1430
+ d.map((_, W) => _ && x[W]),
1431
+ ko()
1432
+ );
1433
+ }
1434
+ return o.map((x, _) => !d[_] || te[_]);
1435
+ }
1436
+ const Vt = (e) => `d:${e}`, jo = (e) => `g:${e}`, At = "f";
1437
+ function qo(e, t, n, o, s) {
1438
+ const a = [...e];
1439
+ if (o === "label")
1440
+ return a.sort((i, u) => s.compare(t[i].label, t[u].label));
1441
+ if (o === "total-asc" || o === "total-desc") {
1442
+ const i = o === "total-asc" ? 1 : -1;
1443
+ return a.sort((u, d) => {
1444
+ var m, w;
1445
+ const l = (m = n[u]) == null ? void 0 : m.value, v = (w = n[d]) == null ? void 0 : w.value;
1446
+ return l == null ? v == null ? 0 : 1 : v == null ? -1 : (l - v) * i;
1447
+ });
1448
+ }
1449
+ return a;
1450
+ }
1451
+ function pn(e, t, n, o) {
1452
+ var d;
1453
+ if (!n)
1454
+ return t.map((l) => ({
1455
+ kind: "data",
1456
+ key: Vt(e[l].id),
1457
+ rowIndex: l,
1458
+ groupId: e[l].group
1459
+ }));
1460
+ const s = [], a = /* @__PURE__ */ new Map(), i = [];
1461
+ e.forEach((l) => {
1462
+ l.group !== void 0 && !a.has(l.group) && (a.set(l.group, []), s.push(l.group));
1463
+ });
1464
+ for (const l of t) {
1465
+ const v = e[l].group;
1466
+ v === void 0 ? i.push(l) : (d = a.get(v)) == null || d.push(l);
1467
+ }
1468
+ const u = [];
1469
+ for (const l of s) {
1470
+ const v = a.get(l) ?? [], m = o.has(l);
1471
+ if (u.push({
1472
+ kind: "group",
1473
+ key: jo(l),
1474
+ groupId: l,
1475
+ collapsed: m,
1476
+ rowIndexes: v
1477
+ }), !m)
1478
+ for (const w of v)
1479
+ u.push({
1480
+ kind: "data",
1481
+ key: Vt(e[w].id),
1482
+ rowIndex: w,
1483
+ groupId: l
1484
+ });
1485
+ }
1486
+ for (const l of i)
1487
+ u.push({ kind: "data", key: Vt(e[l].id), rowIndex: l });
1488
+ return u;
1489
+ }
1490
+ function Dn({
1491
+ cell: e,
1492
+ label: t,
1493
+ open: n,
1494
+ onOpenChange: o,
1495
+ side: s = "top",
1496
+ children: a
1497
+ }) {
1498
+ const i = Rn(), u = t ?? (i == null ? void 0 : i.tooltipText(e)) ?? "";
1499
+ return /* @__PURE__ */ H(
1500
+ Nn,
1501
+ {
1502
+ label: u,
1503
+ open: n,
1504
+ onOpenChange: o,
1505
+ side: s,
1506
+ delayDuration: 0,
1507
+ children: a
1508
+ }
1509
+ );
1510
+ }
1511
+ Dn.displayName = "HeatmapTooltip";
1512
+ function mn({
1513
+ label: e,
1514
+ onOpenChange: t
1515
+ }) {
1516
+ return /* @__PURE__ */ H(Nn, { label: e, open: !0, onOpenChange: t, delayDuration: 0, children: /* @__PURE__ */ H(
1517
+ "span",
1518
+ {
1519
+ "aria-hidden": "true",
1520
+ "data-component": "heatmap-tooltip",
1521
+ className: "ds:pointer-events-none ds:absolute ds:inset-0"
1522
+ }
1523
+ ) });
1524
+ }
1525
+ const Wo = 1e3, Uo = 3;
1526
+ function fn({ offset: e, viewport: t, lead: n, pitch: o, count: s }, a = Uo) {
1527
+ if (s <= 0) return [0, 0];
1528
+ if (!(o > 0)) return [0, s];
1529
+ const i = Math.abs(e) - n, u = Math.floor(i / o) - a, d = Math.ceil((i + t) / o) + a, l = Math.max(0, Math.min(s - 1, u)), v = Math.max(l + 1, Math.min(s, d));
1530
+ return [l, v];
1531
+ }
1532
+ function hn(e, t, n) {
1533
+ const [o, s] = e, a = [];
1534
+ for (let i = o; i < s; i += 1) a.push(i);
1535
+ return n === null || n < 0 || n >= t ? {
1536
+ indexes: a,
1537
+ lead: o,
1538
+ middle: 0,
1539
+ middleAfter: 0,
1540
+ tail: Math.max(0, t - s)
1541
+ } : n < o ? {
1542
+ indexes: [n, ...a],
1543
+ lead: n,
1544
+ middle: o - n - 1,
1545
+ middleAfter: 1,
1546
+ tail: Math.max(0, t - s)
1547
+ } : n >= s ? {
1548
+ indexes: [...a, n],
1549
+ lead: o,
1550
+ middle: n - s,
1551
+ middleAfter: a.length,
1552
+ tail: t - n - 1
1553
+ } : {
1554
+ indexes: a,
1555
+ lead: o,
1556
+ middle: 0,
1557
+ middleAfter: 0,
1558
+ tail: Math.max(0, t - s)
1559
+ };
1560
+ }
1561
+ function Nt(e) {
1562
+ return {
1563
+ indexes: Array.from({ length: e }, (t, n) => n),
1564
+ lead: 0,
1565
+ middle: 0,
1566
+ middleAfter: 0,
1567
+ tail: 0
1568
+ };
1569
+ }
1570
+ function gn(e, t) {
1571
+ if (e.indexes.every((o) => o < t)) return e;
1572
+ const n = e.indexes.filter((o) => o < t);
1573
+ return {
1574
+ indexes: n,
1575
+ lead: Math.min(e.lead, t),
1576
+ middle: 0,
1577
+ middleAfter: 0,
1578
+ tail: Math.max(0, t - (n.length + Math.min(e.lead, t)))
1579
+ };
1580
+ }
1581
+ function vn(e, t) {
1582
+ return e.lead !== t.lead || e.tail !== t.tail || e.middle !== t.middle || e.indexes.length !== t.indexes.length ? !1 : e.indexes.every((n, o) => n === t.indexes[o]);
1583
+ }
1584
+ const Xt = (e, t) => `${e}-${Math.min(9, Math.max(0, Math.round(t)))}`, Kn = {
1585
+ "primary-0": "ds:bg-[var(--heatmap-primary-0)] ds:text-[color:var(--heatmap-primary-0-foreground)]",
1586
+ "primary-1": "ds:bg-[var(--heatmap-primary-1)] ds:text-[color:var(--heatmap-primary-1-foreground)]",
1587
+ "primary-2": "ds:bg-[var(--heatmap-primary-2)] ds:text-[color:var(--heatmap-primary-2-foreground)]",
1588
+ "primary-3": "ds:bg-[var(--heatmap-primary-3)] ds:text-[color:var(--heatmap-primary-3-foreground)]",
1589
+ "primary-4": "ds:bg-[var(--heatmap-primary-4)] ds:text-[color:var(--heatmap-primary-4-foreground)]",
1590
+ "primary-5": "ds:bg-[var(--heatmap-primary-5)] ds:text-[color:var(--heatmap-primary-5-foreground)]",
1591
+ "primary-6": "ds:bg-[var(--heatmap-primary-6)] ds:text-[color:var(--heatmap-primary-6-foreground)]",
1592
+ "primary-7": "ds:bg-[var(--heatmap-primary-7)] ds:text-[color:var(--heatmap-primary-7-foreground)]",
1593
+ "primary-8": "ds:bg-[var(--heatmap-primary-8)] ds:text-[color:var(--heatmap-primary-8-foreground)]",
1594
+ "primary-9": "ds:bg-[var(--heatmap-primary-9)] ds:text-[color:var(--heatmap-primary-9-foreground)]",
1595
+ "success-0": "ds:bg-[var(--heatmap-success-0)] ds:text-[color:var(--heatmap-success-0-foreground)]",
1596
+ "success-1": "ds:bg-[var(--heatmap-success-1)] ds:text-[color:var(--heatmap-success-1-foreground)]",
1597
+ "success-2": "ds:bg-[var(--heatmap-success-2)] ds:text-[color:var(--heatmap-success-2-foreground)]",
1598
+ "success-3": "ds:bg-[var(--heatmap-success-3)] ds:text-[color:var(--heatmap-success-3-foreground)]",
1599
+ "success-4": "ds:bg-[var(--heatmap-success-4)] ds:text-[color:var(--heatmap-success-4-foreground)]",
1600
+ "success-5": "ds:bg-[var(--heatmap-success-5)] ds:text-[color:var(--heatmap-success-5-foreground)]",
1601
+ "success-6": "ds:bg-[var(--heatmap-success-6)] ds:text-[color:var(--heatmap-success-6-foreground)]",
1602
+ "success-7": "ds:bg-[var(--heatmap-success-7)] ds:text-[color:var(--heatmap-success-7-foreground)]",
1603
+ "success-8": "ds:bg-[var(--heatmap-success-8)] ds:text-[color:var(--heatmap-success-8-foreground)]",
1604
+ "success-9": "ds:bg-[var(--heatmap-success-9)] ds:text-[color:var(--heatmap-success-9-foreground)]",
1605
+ "destructive-0": "ds:bg-[var(--heatmap-destructive-0)] ds:text-[color:var(--heatmap-destructive-0-foreground)]",
1606
+ "destructive-1": "ds:bg-[var(--heatmap-destructive-1)] ds:text-[color:var(--heatmap-destructive-1-foreground)]",
1607
+ "destructive-2": "ds:bg-[var(--heatmap-destructive-2)] ds:text-[color:var(--heatmap-destructive-2-foreground)]",
1608
+ "destructive-3": "ds:bg-[var(--heatmap-destructive-3)] ds:text-[color:var(--heatmap-destructive-3-foreground)]",
1609
+ "destructive-4": "ds:bg-[var(--heatmap-destructive-4)] ds:text-[color:var(--heatmap-destructive-4-foreground)]",
1610
+ "destructive-5": "ds:bg-[var(--heatmap-destructive-5)] ds:text-[color:var(--heatmap-destructive-5-foreground)]",
1611
+ "destructive-6": "ds:bg-[var(--heatmap-destructive-6)] ds:text-[color:var(--heatmap-destructive-6-foreground)]",
1612
+ "destructive-7": "ds:bg-[var(--heatmap-destructive-7)] ds:text-[color:var(--heatmap-destructive-7-foreground)]",
1613
+ "destructive-8": "ds:bg-[var(--heatmap-destructive-8)] ds:text-[color:var(--heatmap-destructive-8-foreground)]",
1614
+ "destructive-9": "ds:bg-[var(--heatmap-destructive-9)] ds:text-[color:var(--heatmap-destructive-9-foreground)]",
1615
+ "diverging-0": "ds:bg-[var(--heatmap-diverging-0)] ds:text-[color:var(--heatmap-diverging-0-foreground)]",
1616
+ "diverging-1": "ds:bg-[var(--heatmap-diverging-1)] ds:text-[color:var(--heatmap-diverging-1-foreground)]",
1617
+ "diverging-2": "ds:bg-[var(--heatmap-diverging-2)] ds:text-[color:var(--heatmap-diverging-2-foreground)]",
1618
+ "diverging-3": "ds:bg-[var(--heatmap-diverging-3)] ds:text-[color:var(--heatmap-diverging-3-foreground)]",
1619
+ "diverging-4": "ds:bg-[var(--heatmap-diverging-4)] ds:text-[color:var(--heatmap-diverging-4-foreground)]",
1620
+ "diverging-5": "ds:bg-[var(--heatmap-diverging-5)] ds:text-[color:var(--heatmap-diverging-5-foreground)]",
1621
+ "diverging-6": "ds:bg-[var(--heatmap-diverging-6)] ds:text-[color:var(--heatmap-diverging-6-foreground)]",
1622
+ "diverging-7": "ds:bg-[var(--heatmap-diverging-7)] ds:text-[color:var(--heatmap-diverging-7-foreground)]",
1623
+ "diverging-8": "ds:bg-[var(--heatmap-diverging-8)] ds:text-[color:var(--heatmap-diverging-8-foreground)]",
1624
+ "diverging-9": "ds:bg-[var(--heatmap-diverging-9)] ds:text-[color:var(--heatmap-diverging-9-foreground)]",
1625
+ // A value exactly on a diverging scale's midpoint: neutral, so a cell
1626
+ // with no change never looks like one with a small change.
1627
+ midpoint: "ds:bg-[var(--heatmap-midpoint)] ds:text-[color:var(--heatmap-midpoint-foreground)]",
1628
+ empty: "ds:border ds:border-dashed ds:border-[color:var(--heatmap-empty-border)] ds:bg-[var(--heatmap-empty)] ds:text-[color:var(--heatmap-empty-foreground)]",
1629
+ "low-sample": "ds:border ds:border-[color:var(--heatmap-empty-border)] ds:bg-[var(--heatmap-low-sample-surface)] ds:bg-[image:var(--heatmap-low-sample)] ds:text-[color:var(--heatmap-empty-foreground)]",
1630
+ aggregate: "ds:bg-[var(--muted)] ds:text-[color:var(--foreground)] ds:font-semibold"
1631
+ }, wn = ge(
1632
+ "ds:flex ds:min-w-0 ds:max-w-full ds:flex-col ds:gap-[var(--spacing-sm)] ds:text-[color:var(--foreground)]"
1633
+ ), Yo = ge(
1634
+ "ds:flex ds:flex-wrap ds:items-center ds:justify-between ds:gap-[var(--spacing-sm)]"
1635
+ ), Jo = ge(
1636
+ [
1637
+ "ds:relative ds:max-w-full ds:overflow-auto ds:overscroll-contain",
1638
+ "ds:max-h-[var(--heatmap-max-block-size)]",
1639
+ "ds:bg-[var(--background)]",
1640
+ // Keep a cell scrolled into view clear of the sticky header, footer and
1641
+ // row-header column. The sizes are measured and set on this element.
1642
+ "ds:scroll-pt-[var(--heatmap-sticky-block-start)] ds:scroll-pb-[var(--heatmap-sticky-block-end)] ds:scroll-ps-[var(--heatmap-sticky-inline-start)]"
1643
+ ].join(" ")
1644
+ ), Qo = ge(
1645
+ // Focusable only to hold focus during a retry; not a control, so no ring.
1646
+ "ds:min-w-0 ds:max-w-full ds:outline-none",
1647
+ {
1648
+ variants: {
1649
+ capped: {
1650
+ true: "ds:flex ds:h-[var(--heatmap-max-block-size)] ds:flex-col",
1651
+ false: "ds:block ds:max-h-[var(--heatmap-max-block-size)]"
1652
+ }
1653
+ },
1654
+ defaultVariants: { capped: !1 }
1655
+ }
1656
+ ), Xo = ge(
1657
+ [
1658
+ "ds:grid ds:w-max ds:min-w-full",
1659
+ "ds:[grid-template-rows:auto] ds:auto-rows-[var(--heatmap-row-track)]",
1660
+ "ds:gap-[var(--heatmap-gap)]",
1661
+ "ds:outline-none"
1662
+ ].join(" "),
1663
+ {
1664
+ variants: {
1665
+ size: {
1666
+ sm: "ds:[--heatmap-cell-inline:var(--min-target-size)] ds:[--heatmap-cell-block:var(--min-target-size)]",
1667
+ md: "ds:[--heatmap-cell-inline:max(var(--min-target-size),var(--spacing-2xl))] ds:[--heatmap-cell-block:var(--min-target-size)]",
1668
+ lg: "ds:[--heatmap-cell-inline:max(var(--min-target-size),calc(var(--spacing-2xl)_+_var(--spacing-md)))] ds:[--heatmap-cell-block:max(var(--min-target-size),var(--spacing-2xl))]"
1669
+ },
1670
+ density: {
1671
+ default: "ds:[--heatmap-gap:var(--spacing-2xs)]",
1672
+ compact: "ds:[--heatmap-gap:var(--spacing-none)]"
1673
+ },
1674
+ virtualised: {
1675
+ true: "ds:[--heatmap-track:var(--heatmap-cell-inline)] ds:[--heatmap-row-track:var(--heatmap-cell-block)]",
1676
+ false: "ds:[--heatmap-track:minmax(var(--heatmap-cell-inline),1fr)] ds:[--heatmap-row-track:minmax(var(--heatmap-cell-block),auto)]"
1677
+ },
1678
+ totalsColumn: {
1679
+ true: "ds:grid-cols-[max-content_repeat(var(--heatmap-columns),var(--heatmap-track))_max-content]",
1680
+ false: "ds:grid-cols-[max-content_repeat(var(--heatmap-columns),var(--heatmap-track))]"
1681
+ }
1682
+ },
1683
+ defaultVariants: {
1684
+ size: "md",
1685
+ density: "default",
1686
+ virtualised: !1,
1687
+ totalsColumn: !1
1688
+ }
1689
+ }
1690
+ ), Lt = ge(
1691
+ "ds:col-span-full ds:grid ds:grid-cols-subgrid",
1692
+ {
1693
+ variants: {
1694
+ position: {
1695
+ // The header and footer rows stick to the scroll box's block edges,
1696
+ // above the row headers that stick to its inline start.
1697
+ // Each also covers the row gap on its inner side, so cells
1698
+ // scrolling underneath never show through the gap.
1699
+ header: "ds:sticky ds:top-0 ds:z-[calc(var(--z-sticky)+1)] ds:bg-[var(--background)] ds:after:pointer-events-none ds:after:absolute ds:after:inset-x-0 ds:after:top-[calc(100%_-_var(--spacing-2xs))] ds:after:h-[calc(var(--heatmap-gap)_+_var(--spacing-2xs))] ds:after:bg-[var(--background)] ds:after:content-['']",
1700
+ footer: "ds:sticky ds:bottom-0 ds:z-[calc(var(--z-sticky)+1)] ds:bg-[var(--background)] ds:after:pointer-events-none ds:after:absolute ds:after:inset-x-0 ds:after:bottom-[calc(100%_-_var(--spacing-2xs))] ds:after:h-[calc(var(--heatmap-gap)_+_var(--spacing-2xs))] ds:after:bg-[var(--background)] ds:after:content-['']",
1701
+ body: ""
1702
+ }
1703
+ },
1704
+ defaultVariants: { position: "body" }
1705
+ }
1706
+ ), at = ge("ds:pointer-events-none", {
1707
+ variants: {
1708
+ axis: {
1709
+ "row-lead": "ds:col-span-full ds:row-span-[var(--heatmap-row-lead)]",
1710
+ "row-middle": "ds:col-span-full ds:row-span-[var(--heatmap-row-middle)]",
1711
+ "row-tail": "ds:col-span-full ds:row-span-[var(--heatmap-row-tail)]",
1712
+ "col-lead": "ds:col-span-[var(--heatmap-col-lead)]",
1713
+ "col-middle": "ds:col-span-[var(--heatmap-col-middle)]",
1714
+ // Holds the skipped columns after the window, so the row-totals cell
1715
+ // lands in its own track at the end and never next to the window.
1716
+ "col-tail": "ds:col-span-[var(--heatmap-col-tail)]"
1717
+ }
1718
+ }
1719
+ }), zn = "ds:transition-colors ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none ds:data-[highlighted=true]:bg-[var(--muted)] ds:data-[highlighted=true]:text-[color:var(--foreground)]", Gt = ge(
1720
+ [
1721
+ "ds:flex ds:min-w-0 ds:items-end ds:justify-center ds:text-center",
1722
+ "ds:rounded-[var(--radius-sm)] ds:px-[var(--spacing-2xs)] ds:py-[var(--spacing-xs)]",
1723
+ "type-meta ds:text-[color:var(--muted-foreground)] ds:break-normal ds:[overflow-wrap:anywhere]",
1724
+ zn
1725
+ ].join(" "),
1726
+ {
1727
+ variants: {
1728
+ corner: {
1729
+ // The top-start corner sticks with the row headers below it.
1730
+ true: "ds:sticky ds:start-0 ds:z-[var(--z-sticky)] ds:items-end ds:justify-start ds:text-start ds:bg-[var(--background)] ds:pe-[var(--spacing-sm)]",
1731
+ false: ""
1732
+ }
1733
+ },
1734
+ defaultVariants: { corner: !1 }
1735
+ }
1736
+ ), Zt = ge(
1737
+ [
1738
+ "ds:sticky ds:start-0 ds:z-[var(--z-sticky)] ds:flex ds:min-w-0 ds:items-center",
1739
+ "ds:max-w-[calc(var(--spacing-2xl)*4)] ds:gap-[var(--spacing-xs)]",
1740
+ "ds:bg-[var(--background)] ds:ps-[var(--spacing-xs)] ds:pe-[var(--spacing-sm)]",
1741
+ // Cover the gaps at the inline end and below too, so cells scrolling
1742
+ // underneath never show through between row headers.
1743
+ "ds:after:pointer-events-none ds:after:absolute ds:after:top-0 ds:after:bottom-[calc(var(--heatmap-gap)*-1)] ds:after:start-full ds:after:w-[var(--heatmap-gap)] ds:after:bg-[var(--background)] ds:after:content-['']",
1744
+ // The strip below overlaps its neighbours slightly so a fractional row
1745
+ // position never leaves a hairline seam.
1746
+ "ds:before:pointer-events-none ds:before:absolute ds:before:inset-x-0 ds:before:top-[calc(100%_-_var(--spacing-2xs))] ds:before:h-[calc(var(--heatmap-gap)_+_var(--spacing-2xs)*2)] ds:before:bg-[var(--background)] ds:before:content-['']",
1747
+ "type-body-sm ds:text-start ds:break-normal ds:[overflow-wrap:anywhere]",
1748
+ zn
1749
+ ].join(" "),
1750
+ {
1751
+ variants: {
1752
+ kind: {
1753
+ data: "",
1754
+ group: "ds:font-semibold",
1755
+ total: "ds:font-semibold"
1756
+ },
1757
+ // A virtualised grid needs every row the same height: no wrapping.
1758
+ // The label truncates inside its own span (heatmapRowLabelVariants):
1759
+ // overflow on the header itself would clip its gap-covering strips.
1760
+ virtualised: {
1761
+ true: "ds:whitespace-nowrap",
1762
+ false: ""
1763
+ }
1764
+ },
1765
+ defaultVariants: { kind: "data", virtualised: !1 }
1766
+ }
1767
+ ), bn = ge("ds:min-w-0", {
1768
+ variants: {
1769
+ virtualised: {
1770
+ true: "ds:overflow-hidden ds:text-ellipsis",
1771
+ false: ""
1772
+ }
1773
+ },
1774
+ defaultVariants: { virtualised: !1 }
1775
+ }), Rt = ge(
1776
+ [
1777
+ "ds:relative ds:flex ds:min-w-0 ds:items-center ds:justify-center",
1778
+ "ds:min-h-[var(--heatmap-cell-block)] ds:overflow-hidden ds:px-[var(--spacing-2xs)]",
1779
+ "type-meta ds:tabular-nums ds:whitespace-nowrap ds:select-none",
1780
+ "ds:forced-colors:[forced-color-adjust:none]",
1781
+ "ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-ring",
1782
+ "ds:focus-visible:outline-offset-[calc(var(--focus-ring-width)*-1)]",
1783
+ "ds:focus-visible:shadow-[inset_0_0_0_calc(var(--focus-ring-width)*2)_var(--background)]",
1784
+ "ds:forced-colors:focus-visible:outline-[Highlight]",
1785
+ "ds:aria-selected:shadow-[inset_0_0_0_var(--spacing-2xs)_var(--background),inset_0_0_0_calc(var(--spacing-2xs)*2)_var(--foreground),inset_0_0_0_calc(var(--spacing-2xs)*3)_var(--background)]",
1786
+ "ds:aria-selected:focus-visible:shadow-[inset_0_0_0_calc(var(--focus-ring-width)_+_var(--spacing-2xs))_var(--background),inset_0_0_0_calc(var(--focus-ring-width)_+_var(--spacing-2xs)*2)_var(--foreground),inset_0_0_0_calc(var(--focus-ring-width)_+_var(--spacing-2xs)*3)_var(--background)]"
1787
+ ].join(" "),
1788
+ {
1789
+ variants: {
1790
+ tone: Kn,
1791
+ interactive: {
1792
+ true: "ds:cursor-pointer",
1793
+ false: "ds:cursor-default"
1794
+ }
1795
+ },
1796
+ defaultVariants: { tone: "empty", interactive: !1 }
1797
+ }
1798
+ ), Zo = ge(
1799
+ "ds:flex ds:min-w-0 ds:flex-wrap ds:items-center ds:gap-x-[var(--spacing-md)] ds:gap-y-[var(--spacing-xs)] type-meta ds:text-[color:var(--muted-foreground)]"
1800
+ ), ea = ge(
1801
+ "ds:flex ds:w-[calc(var(--spacing-xl)*6)] ds:min-w-0 ds:max-w-full ds:shrink ds:items-stretch",
1802
+ {
1803
+ variants: {
1804
+ variant: {
1805
+ stepped: "ds:gap-[var(--spacing-2xs)]",
1806
+ continuous: "ds:overflow-hidden ds:rounded-[var(--radius-sm)]"
1807
+ }
1808
+ },
1809
+ defaultVariants: { variant: "stepped" }
1810
+ }
1811
+ ), tt = ge(
1812
+ "ds:inline-block ds:forced-colors:[forced-color-adjust:none]",
1813
+ {
1814
+ variants: {
1815
+ tone: Kn,
1816
+ shape: {
1817
+ stepped: "ds:h-[var(--spacing-sm)] ds:min-w-0 ds:flex-1 ds:rounded-[var(--radius-sm)]",
1818
+ continuous: "ds:h-[var(--spacing-sm)] ds:min-w-0 ds:flex-1",
1819
+ key: "ds:size-[var(--spacing-md)] ds:shrink-0 ds:rounded-[var(--radius-sm)]",
1820
+ label: "ds:shrink-0 ds:rounded-[var(--radius-sm)] ds:px-[var(--spacing-xs)] ds:whitespace-nowrap"
1821
+ }
1822
+ },
1823
+ defaultVariants: { tone: "empty", shape: "key" }
1824
+ }
1825
+ ), Fn = "", Ot = (e, t) => `${e}${Fn}${String(t)}`, Et = (e) => {
1826
+ const t = e.indexOf(Fn);
1827
+ return [e.slice(0, t), e.slice(t + 1)];
1828
+ };
1829
+ function ta(e, t, n) {
1830
+ return e.status === "low-sample" ? "low-sample" : e.status === "empty" || e.value === null ? "empty" : Ro(t, e.value) ? "midpoint" : Xt(n, t.stepOf(e.value));
1831
+ }
1832
+ const na = { value: null, status: "empty" }, en = (e) => e.status === "value" ? "aggregate" : e.status;
1833
+ function Ct(e, t) {
1834
+ const n = [];
1835
+ return e.lead > 0 && n.push(
1836
+ /* @__PURE__ */ H(
1837
+ "div",
1838
+ {
1839
+ "aria-hidden": "true",
1840
+ className: at({ axis: "col-lead" })
1841
+ },
1842
+ "lead"
1843
+ )
1844
+ ), e.indexes.forEach((o, s) => {
1845
+ e.middle > 0 && s === e.middleAfter && n.push(
1846
+ /* @__PURE__ */ H(
1847
+ "div",
1848
+ {
1849
+ "aria-hidden": "true",
1850
+ className: at({ axis: "col-middle" })
1851
+ },
1852
+ "middle"
1853
+ )
1854
+ ), n.push(t(o));
1855
+ }), e.tail > 0 && n.push(
1856
+ /* @__PURE__ */ H(
1857
+ "div",
1858
+ {
1859
+ "aria-hidden": "true",
1860
+ className: at({ axis: "col-tail" })
1861
+ },
1862
+ "tail"
1863
+ )
1864
+ ), n;
1865
+ }
1866
+ const oa = jn(function({
1867
+ ctx: t,
1868
+ row: n,
1869
+ ariaRowIndex: o,
1870
+ highlighted: s,
1871
+ activeCol: a,
1872
+ tooltipCol: i,
1873
+ selectedCols: u
1874
+ }) {
1875
+ var O, D;
1876
+ const d = t.columns.length, l = X(
1877
+ () => new Set(u === "" ? [] : u.split(",").map(Number)),
1878
+ [u]
1879
+ );
1880
+ if (n.kind === "group") {
1881
+ const y = t.describer.groupLabel(n.groupId), E = t.groupIds.get(n.groupId), g = `${t.idBase}-label-${o}`, R = ((O = t.totals) == null ? void 0 : O.groupColumns.get(n.groupId)) ?? [], L = (D = t.totals) == null ? void 0 : D.groups.get(n.groupId), V = (F, Y, T, N) => {
1882
+ const K = F ?? na, z = T(K);
1883
+ return /* @__PURE__ */ le(
1884
+ "div",
1885
+ {
1886
+ role: "gridcell",
1887
+ "aria-colindex": Y + 2,
1888
+ "aria-expanded": !n.collapsed,
1889
+ "aria-label": z,
1890
+ tabIndex: a === Y ? 0 : -1,
1891
+ "data-heatmap-group-id": E,
1892
+ className: Rt({
1893
+ tone: en(K),
1894
+ interactive: !0
1895
+ }),
1896
+ children: [
1897
+ t.describer.visibleText(K),
1898
+ N && i === Y ? /* @__PURE__ */ H(
1899
+ mn,
1900
+ {
1901
+ label: z,
1902
+ onOpenChange: t.onTooltipOpenChange
1903
+ }
1904
+ ) : null
1905
+ ]
1906
+ },
1907
+ Y
1908
+ );
1909
+ }, J = t.describer.groupRowText(
1910
+ y,
1911
+ t.groupColumnMethod
1912
+ );
1913
+ return /* @__PURE__ */ le(
1914
+ "div",
1915
+ {
1916
+ role: "row",
1917
+ "aria-rowindex": o,
1918
+ "data-heatmap-body-row": "",
1919
+ "data-heatmap-group-id": E,
1920
+ className: Lt({ position: "body" }),
1921
+ children: [
1922
+ /* @__PURE__ */ le(
1923
+ "div",
1924
+ {
1925
+ role: "rowheader",
1926
+ "aria-colindex": 1,
1927
+ "aria-labelledby": g,
1928
+ "data-highlighted": s,
1929
+ className: Zt({
1930
+ kind: "group",
1931
+ virtualised: t.virtualised
1932
+ }),
1933
+ children: [
1934
+ /* @__PURE__ */ H(
1935
+ "button",
1936
+ {
1937
+ type: "button",
1938
+ tabIndex: -1,
1939
+ "aria-expanded": !n.collapsed,
1940
+ "aria-label": n.collapsed ? t.expandLabel(y) : t.collapseLabel(y),
1941
+ onMouseDown: (F) => F.preventDefault(),
1942
+ onClick: () => t.onToggleGroup(n.groupId),
1943
+ className: "ds:inline-flex ds:size-[var(--spacing-lg)] ds:shrink-0 ds:cursor-pointer ds:items-center ds:justify-center ds:rounded-[var(--radius-sm)] ds:bg-transparent ds:text-[color:inherit] ds:hover:bg-[var(--muted)] ds:focus-visible:outline-solid ds:focus-visible:outline-[length:var(--focus-ring-width)] ds:focus-visible:outline-ring ds:forced-colors:focus-visible:outline-[Highlight]",
1944
+ children: /* @__PURE__ */ H(
1945
+ eo,
1946
+ {
1947
+ "aria-hidden": "true",
1948
+ className: [
1949
+ "ds:size-4 ds:transition-transform ds:duration-[var(--animation-duration)] ds:motion-reduce:transition-none",
1950
+ n.collapsed ? "ds:-rotate-90 ds:rtl:rotate-90" : ""
1951
+ ].join(" ")
1952
+ }
1953
+ )
1954
+ }
1955
+ ),
1956
+ /* @__PURE__ */ H(
1957
+ "span",
1958
+ {
1959
+ id: g,
1960
+ className: bn({
1961
+ virtualised: t.virtualised
1962
+ }),
1963
+ children: y
1964
+ }
1965
+ )
1966
+ ]
1967
+ }
1968
+ ),
1969
+ Ct(
1970
+ t.colWindow,
1971
+ (F) => V(
1972
+ R[F],
1973
+ F,
1974
+ (Y) => t.describer.sentence(
1975
+ J,
1976
+ t.describer.columnLabel(t.columns[F]),
1977
+ Y
1978
+ ),
1979
+ !0
1980
+ )
1981
+ ),
1982
+ t.rowTotals ? V(
1983
+ L,
1984
+ d,
1985
+ (F) => t.describer.sentence(
1986
+ y,
1987
+ t.describer.methodLabel(t.rowTotals || "mean"),
1988
+ F
1989
+ ),
1990
+ !1
1991
+ ) : null
1992
+ ]
1993
+ }
1994
+ );
1995
+ }
1996
+ const v = n.rowIndex, m = t.rows[v], w = t.describer.rowLabel(m), b = t.matrix[v], p = (y) => {
1997
+ const E = b[y], g = t.columns[y], R = l.has(y);
1998
+ return /* @__PURE__ */ le(
1999
+ "div",
2000
+ {
2001
+ role: "gridcell",
2002
+ "aria-colindex": y + 2,
2003
+ "aria-label": t.describer.sentence(
2004
+ w,
2005
+ t.describer.columnLabel(g),
2006
+ E
2007
+ ),
2008
+ "aria-describedby": a === y ? t.describedBy : void 0,
2009
+ "aria-selected": t.selectable ? R : void 0,
2010
+ tabIndex: a === y ? 0 : -1,
2011
+ "data-heatmap-cell-id": `${m.id}:${String(g.id)}`,
2012
+ "data-status": E.status,
2013
+ className: Rt({
2014
+ tone: ta(E, t.scale, t.palette),
2015
+ interactive: t.interactive
2016
+ }),
2017
+ children: [
2018
+ t.showValues || E.status === "empty" ? t.describer.visibleText(E) : null,
2019
+ i === y ? /* @__PURE__ */ H(
2020
+ mn,
2021
+ {
2022
+ label: t.tooltipText(t.cellInfo(v, y)),
2023
+ onOpenChange: t.onTooltipOpenChange
2024
+ }
2025
+ ) : null
2026
+ ]
2027
+ },
2028
+ y
2029
+ );
2030
+ };
2031
+ let A = null;
2032
+ if (t.rowTotals && t.totals) {
2033
+ const y = t.totals.rows[v];
2034
+ A = /* @__PURE__ */ H(
2035
+ "div",
2036
+ {
2037
+ role: "gridcell",
2038
+ "aria-colindex": d + 2,
2039
+ "aria-label": t.describer.sentence(
2040
+ w,
2041
+ t.describer.methodLabel(t.rowTotals),
2042
+ y
2043
+ ),
2044
+ tabIndex: a === d ? 0 : -1,
2045
+ className: Rt({ tone: en(y) }),
2046
+ children: t.describer.visibleText(y)
2047
+ }
2048
+ );
2049
+ }
2050
+ return /* @__PURE__ */ le(
2051
+ "div",
2052
+ {
2053
+ role: "row",
2054
+ "aria-rowindex": o,
2055
+ "data-heatmap-body-row": "",
2056
+ "data-heatmap-row-id": m.id,
2057
+ className: Lt({ position: "body" }),
2058
+ children: [
2059
+ /* @__PURE__ */ H(
2060
+ "div",
2061
+ {
2062
+ role: "rowheader",
2063
+ "aria-colindex": 1,
2064
+ "data-highlighted": s,
2065
+ className: Zt({
2066
+ kind: "data",
2067
+ virtualised: t.virtualised
2068
+ }),
2069
+ children: /* @__PURE__ */ H(
2070
+ "span",
2071
+ {
2072
+ className: bn({ virtualised: t.virtualised }),
2073
+ children: w
2074
+ }
2075
+ )
2076
+ }
2077
+ ),
2078
+ Ct(t.colWindow, p),
2079
+ A
2080
+ ]
2081
+ }
2082
+ );
2083
+ }), $t = {
2084
+ headerBlock: 48,
2085
+ footerBlock: 0,
2086
+ rowPitch: 46,
2087
+ leadInline: 120,
2088
+ colPitch: 46,
2089
+ viewportBlock: 600,
2090
+ viewportInline: 900
2091
+ }, yn = (e) => Math.max(
2092
+ 1,
2093
+ Math.floor(
2094
+ (e.viewportBlock - e.headerBlock - e.footerBlock) / Math.max(1, e.rowPitch)
2095
+ )
2096
+ );
2097
+ function aa(e) {
2098
+ const {
2099
+ title: t,
2100
+ rowsLabel: n,
2101
+ rows: o,
2102
+ columns: s,
2103
+ matrix: a,
2104
+ body: i,
2105
+ scale: u,
2106
+ palette: d,
2107
+ describer: l,
2108
+ showValues: v,
2109
+ totals: m,
2110
+ rowTotals: w,
2111
+ columnTotals: b,
2112
+ groupColumnMethod: p,
2113
+ groupIds: A,
2114
+ selectionMode: O,
2115
+ selected: D,
2116
+ columnIndexOfKey: y,
2117
+ interactive: E,
2118
+ virtualised: g,
2119
+ size: R,
2120
+ density: L,
2121
+ cellInfo: V,
2122
+ tooltipText: J,
2123
+ describeFocused: F,
2124
+ onActivate: Y,
2125
+ onRange: T,
2126
+ onToggleGroup: N
2127
+ } = e, { t: K } = Ht("ui"), z = Pn(), $ = ie(null), c = ie(null), I = ie(null), P = ie(null), C = s.length, Q = C + (w ? 1 : 0), te = !!(b && m), x = X(
2128
+ () => [
2129
+ ...i.map((f) => f.key),
2130
+ ...te ? [At] : []
2131
+ ],
2132
+ [i, te]
2133
+ ), _ = X(() => {
2134
+ const f = /* @__PURE__ */ new Map();
2135
+ return x.forEach((r, h) => f.set(r, h)), f;
2136
+ }, [x]), [W, G] = we(() => ({
2137
+ rowKey: x[0] ?? At,
2138
+ col: 0
2139
+ })), q = (() => {
2140
+ const f = _.get(W.rowKey);
2141
+ if (f !== void 0) return f;
2142
+ const r = o.find((M) => `d:${M.id}` === W.rowKey);
2143
+ return ((r == null ? void 0 : r.group) === void 0 ? void 0 : _.get(`g:${r.group}`)) ?? 0;
2144
+ })(), B = Math.min(
2145
+ Math.max(0, W.col),
2146
+ Math.max(0, Q - 1)
2147
+ ), re = x[q], ne = ie(!1), [Me, Ne] = we(!1), be = ie(!1), Z = ie("pointer"), [pe, je] = we(null), qe = ie(null), [wt, Oe] = we(!1), We = ae((f) => {
2148
+ const r = qe.current;
2149
+ r === f || r && f && r.rowKey === f.rowKey && r.col === f.col || (qe.current = f, je(f), Oe(!1));
2150
+ }, []), me = pe ?? (Me && re ? { rowKey: re, col: B } : null), Ce = wt ? null : pe ?? (Me && Z.current === "keyboard" && re ? { rowKey: re, col: B } : null), [fe, Dt] = we($t), ve = ie(fe);
2151
+ ve.current = fe;
2152
+ const st = ae(() => {
2153
+ var ce, Ae;
2154
+ const f = $.current, r = c.current;
2155
+ if (!f || !r) return;
2156
+ const h = window.getComputedStyle(r), M = parseFloat(h.rowGap) || 0, S = parseFloat(h.columnGap) || 0, k = h.gridTemplateColumns.split(" ").map((Ze) => parseFloat(Ze)).filter((Ze) => Number.isFinite(Ze)), U = ((ce = I.current) == null ? void 0 : ce.getBoundingClientRect().height) ?? 0, j = r.querySelector(
2157
+ "[data-heatmap-body-row]"
2158
+ ), oe = (j == null ? void 0 : j.getBoundingClientRect().height) ?? 0, se = {
2159
+ headerBlock: U + M,
2160
+ footerBlock: ((Ae = P.current) == null ? void 0 : Ae.getBoundingClientRect().height) ?? 0,
2161
+ rowPitch: (oe || U || $t.rowPitch) + M,
2162
+ leadInline: (k[0] ?? 0) + S,
2163
+ colPitch: (k[1] ?? $t.colPitch) + S,
2164
+ viewportBlock: f.clientHeight,
2165
+ viewportInline: f.clientWidth
2166
+ }, ue = ve.current;
2167
+ Object.keys(se).some(
2168
+ (Ze) => Math.abs(se[Ze] - ue[Ze]) > 0.5
2169
+ ) && Dt(se);
2170
+ }, []);
2171
+ nt(() => {
2172
+ st();
2173
+ const f = $.current;
2174
+ if (!f || typeof ResizeObserver > "u") return;
2175
+ const r = new ResizeObserver(() => st());
2176
+ return r.observe(f), c.current && r.observe(c.current), () => r.disconnect();
2177
+ }, [st, i.length, C, R, L]);
2178
+ const it = re === At ? null : q, bt = B < C ? B : null, lt = ae(() => {
2179
+ if (!g)
2180
+ return { rows: Nt(i.length), cols: Nt(C) };
2181
+ const f = $.current, r = ve.current, h = fn({
2182
+ offset: (f == null ? void 0 : f.scrollTop) ?? 0,
2183
+ viewport: r.viewportBlock,
2184
+ lead: r.headerBlock,
2185
+ pitch: r.rowPitch,
2186
+ count: i.length
2187
+ }), M = fn({
2188
+ offset: (f == null ? void 0 : f.scrollLeft) ?? 0,
2189
+ viewport: r.viewportInline,
2190
+ lead: r.leadInline,
2191
+ pitch: r.colPitch,
2192
+ count: C
2193
+ });
2194
+ return {
2195
+ rows: hn(h, i.length, it),
2196
+ cols: hn(M, C, bt)
2197
+ };
2198
+ }, [g, i.length, C, it, bt]), [De, Kt] = we(lt), _e = X(() => Nt(i.length), [i.length]), yt = X(() => Nt(C), [C]), ye = X(
2199
+ () => g ? {
2200
+ rows: gn(De.rows, i.length),
2201
+ cols: gn(De.cols, C)
2202
+ } : { rows: _e, cols: yt },
2203
+ [g, De, i.length, C, _e, yt]
2204
+ ), Ue = ae(() => {
2205
+ const f = lt();
2206
+ Kt(
2207
+ (r) => vn(r.rows, f.rows) && vn(r.cols, f.cols) ? r : f
2208
+ );
2209
+ }, [lt]);
2210
+ nt(() => {
2211
+ Ue();
2212
+ }, [Ue, fe]);
2213
+ const Ke = ie(0), xt = ae(() => {
2214
+ !g || Ke.current || (Ke.current = window.requestAnimationFrame(() => {
2215
+ Ke.current = 0, Ue();
2216
+ }));
2217
+ }, [g, Ue]);
2218
+ gt(() => () => window.cancelAnimationFrame(Ke.current), []), nt(() => {
2219
+ re !== void 0 && re !== W.rowKey && G({ rowKey: re, col: B });
2220
+ }), nt(() => {
2221
+ if (!be.current || ne.current) return;
2222
+ const f = document.activeElement;
2223
+ f && f !== document.body && f.isConnected || (ne.current = !0);
2224
+ });
2225
+ const xe = ae(
2226
+ (f, r) => {
2227
+ var h;
2228
+ return ((h = c.current) == null ? void 0 : h.querySelector(
2229
+ `[role="row"][aria-rowindex="${f + 2}"] > [aria-colindex="${r + 2}"]`
2230
+ )) ?? null;
2231
+ },
2232
+ []
2233
+ );
2234
+ nt(() => {
2235
+ var r;
2236
+ if (!ne.current) return;
2237
+ const f = xe(q, B);
2238
+ f && (ne.current = !1, f.focus({ preventScroll: !0 }), (r = f.scrollIntoView) == null || r.call(f, { block: "nearest", inline: "nearest" }));
2239
+ });
2240
+ const Ye = () => c.current ? window.getComputedStyle(c.current).direction === "rtl" : !1, de = ie(null), ze = (f) => {
2241
+ const r = i[f];
2242
+ return r && r.kind === "data" ? r.rowIndex : null;
2243
+ }, Ie = ie(!1), Se = (f, r) => {
2244
+ const h = Math.max(0, Math.min(x.length - 1, f)), M = Math.max(0, Math.min(Q - 1, r));
2245
+ return ne.current = !0, Oe(!1), G({ rowKey: x[h], col: M }), { row: h, col: M };
2246
+ }, ct = (f, r, h) => {
2247
+ const M = i[f];
2248
+ if (M) {
2249
+ if (M.kind === "group") {
2250
+ N(M.groupId);
2251
+ return;
2252
+ }
2253
+ if (!(r >= C)) {
2254
+ if (O === "range" && h && de.current) {
2255
+ T(de.current, { rowIndex: M.rowIndex, col: r });
2256
+ return;
2257
+ }
2258
+ de.current = { rowIndex: M.rowIndex, col: r }, Y(M.rowIndex, r, !0);
2259
+ }
2260
+ }
2261
+ }, Fe = (f) => {
2262
+ if (f.target instanceof Element && f.target.closest("button"))
2263
+ return;
2264
+ Z.current = "keyboard";
2265
+ const r = x.length - 1, h = Q - 1, M = Ye() ? -1 : 1;
2266
+ let S = q, k = B;
2267
+ const U = f.ctrlKey || f.metaKey;
2268
+ switch (f.key) {
2269
+ case "ArrowRight":
2270
+ k += M;
2271
+ break;
2272
+ case "ArrowLeft":
2273
+ k -= M;
2274
+ break;
2275
+ case "ArrowDown":
2276
+ S += 1;
2277
+ break;
2278
+ case "ArrowUp":
2279
+ S -= 1;
2280
+ break;
2281
+ case "Home":
2282
+ k = 0, U && (S = 0);
2283
+ break;
2284
+ case "End":
2285
+ k = h, U && (S = r);
2286
+ break;
2287
+ case "PageDown": {
2288
+ const se = i.findIndex(
2289
+ (ce, Ae) => Ae > q && ce.kind === "group"
2290
+ );
2291
+ S = i.some((ce) => ce.kind === "group") ? se === -1 ? r : se : q + yn(ve.current);
2292
+ break;
2293
+ }
2294
+ case "PageUp": {
2295
+ let se = -1;
2296
+ for (let ce = Math.min(q, i.length) - 1; ce >= 0; ce -= 1)
2297
+ if (i[ce].kind === "group") {
2298
+ se = ce;
2299
+ break;
2300
+ }
2301
+ S = i.some((ce) => ce.kind === "group") ? se === -1 ? 0 : se : q - yn(ve.current);
2302
+ break;
2303
+ }
2304
+ case "Enter":
2305
+ case " ":
2306
+ f.preventDefault(), ct(q, B, f.shiftKey);
2307
+ return;
2308
+ case "Escape":
2309
+ Ce && (f.preventDefault(), Oe(!0));
2310
+ return;
2311
+ default:
2312
+ return;
2313
+ }
2314
+ f.preventDefault();
2315
+ const j = Se(S, k), oe = f.key.startsWith("Arrow");
2316
+ if (O === "range" && f.shiftKey && oe) {
2317
+ const se = ze(j.row), ue = de.current ?? (() => {
2318
+ const ce = ze(q);
2319
+ return ce === null || B >= C ? null : { rowIndex: ce, col: B };
2320
+ })();
2321
+ ue && se !== null && j.col < C && (de.current = ue, T(ue, { rowIndex: se, col: j.col }));
2322
+ }
2323
+ }, Je = (f) => {
2324
+ var k;
2325
+ if (!(f instanceof Element)) return null;
2326
+ const r = f.closest('[role="gridcell"]'), h = r == null ? void 0 : r.parentElement;
2327
+ if (!r || !h || !((k = c.current) != null && k.contains(r))) return null;
2328
+ const M = Number(h.getAttribute("aria-rowindex")) - 2, S = Number(r.getAttribute("aria-colindex")) - 2;
2329
+ return !Number.isInteger(M) || M < 0 || S < 0 ? null : { row: M, col: S };
2330
+ }, Be = ie(!1), Ve = ie("mouse"), It = (f) => {
2331
+ if (Z.current = "pointer", Ve.current = f.pointerType, O !== "range" || f.pointerType !== "mouse" || f.button !== 0)
2332
+ return;
2333
+ const r = Je(f.target);
2334
+ if (Ie.current = !1, !r) return;
2335
+ const h = ze(r.row);
2336
+ if (h === null || r.col >= C) return;
2337
+ if (f.shiftKey && de.current)
2338
+ T(de.current, { rowIndex: h, col: r.col });
2339
+ else {
2340
+ de.current = { rowIndex: h, col: r.col };
2341
+ const S = Ot(o[h].id, s[r.col].id);
2342
+ D.size === 1 && D.has(S) ? Ie.current = !0 : T(de.current, de.current);
2343
+ }
2344
+ Be.current = !0;
2345
+ const M = () => {
2346
+ Be.current = !1, window.removeEventListener("pointerup", M), window.removeEventListener("pointercancel", M);
2347
+ };
2348
+ window.addEventListener("pointerup", M), window.addEventListener("pointercancel", M);
2349
+ }, zt = (f) => {
2350
+ if (f.pointerType !== "mouse") return;
2351
+ const r = Je(f.target);
2352
+ if (We(
2353
+ r ? { rowKey: x[r.row], col: r.col } : null
2354
+ ), Be.current && r && de.current) {
2355
+ const h = ze(r.row);
2356
+ h !== null && r.col < C && ((h !== de.current.rowIndex || r.col !== de.current.col) && (Ie.current = !1), Ie.current || T(de.current, { rowIndex: h, col: r.col }));
2357
+ }
2358
+ }, he = ie(null), Ge = ae(() => {
2359
+ he.current && (document.removeEventListener("pointerover", he.current), he.current = null);
2360
+ }, []);
2361
+ gt(() => Ge, [Ge]);
2362
+ const kt = (f) => {
2363
+ Ge();
2364
+ const r = f.relatedTarget;
2365
+ if (r instanceof Element && r.closest('[data-component="tooltip"]')) {
2366
+ const h = (M) => {
2367
+ var k;
2368
+ const S = M.target;
2369
+ S instanceof Element && S.closest('[data-component="tooltip"]') || (Ge(), S instanceof Node && ((k = c.current) != null && k.contains(S)) || We(null));
2370
+ };
2371
+ he.current = h, document.addEventListener("pointerover", h);
2372
+ return;
2373
+ }
2374
+ We(null);
2375
+ }, He = (f) => {
2376
+ var M;
2377
+ const r = f.target instanceof Element ? f.target.closest("button") : null;
2378
+ if (r) {
2379
+ const S = Number((M = r.closest('[role="row"]')) == null ? void 0 : M.getAttribute("aria-rowindex")) - 2;
2380
+ Number.isInteger(S) && S >= 0 && Se(S, B);
2381
+ return;
2382
+ }
2383
+ const h = Je(f.target);
2384
+ if (h) {
2385
+ if (Se(h.row, h.col), ne.current = !1, O === "range" && Ve.current === "mouse") {
2386
+ const S = i[h.row];
2387
+ (S == null ? void 0 : S.kind) === "group" ? ct(h.row, h.col, !1) : (S == null ? void 0 : S.kind) === "data" && h.col < C && Y(S.rowIndex, h.col, Ie.current), Ie.current = !1;
2388
+ return;
2389
+ }
2390
+ ct(h.row, h.col, f.shiftKey);
2391
+ }
2392
+ }, $e = ie(!1);
2393
+ gt(() => {
2394
+ let f = 0;
2395
+ const r = () => {
2396
+ $e.current = !0, window.cancelAnimationFrame(f), f = window.requestAnimationFrame(() => {
2397
+ $e.current = !1;
2398
+ });
2399
+ };
2400
+ return window.addEventListener("scroll", r, { capture: !0 }), () => {
2401
+ window.removeEventListener("scroll", r, { capture: !0 }), window.cancelAnimationFrame(f);
2402
+ };
2403
+ }, []);
2404
+ const Pe = ae((f) => {
2405
+ f || $e.current && qe.current === null || Oe(!0);
2406
+ }, []), Qe = ae(
2407
+ (f) => K("heatmap.expandGroup", { group: f }),
2408
+ [K]
2409
+ ), Mt = ae(
2410
+ (f) => K("heatmap.collapseGroup", { group: f }),
2411
+ [K]
2412
+ ), dt = `${z}-description`, Xe = i[q], ut = F && (Xe == null ? void 0 : Xe.kind) === "data" && B < C ? J(V(Xe.rowIndex, B)) : null, ee = X(
2413
+ () => ({
2414
+ rows: o,
2415
+ columns: s,
2416
+ matrix: a,
2417
+ scale: u,
2418
+ palette: d,
2419
+ describer: l,
2420
+ showValues: v,
2421
+ totals: m,
2422
+ rowTotals: w,
2423
+ groupColumnMethod: p,
2424
+ groupIds: A,
2425
+ selectable: O !== "none",
2426
+ interactive: E,
2427
+ virtualised: g,
2428
+ colWindow: ye.cols,
2429
+ idBase: z,
2430
+ describedBy: F ? dt : void 0,
2431
+ cellInfo: V,
2432
+ tooltipText: J,
2433
+ onTooltipOpenChange: Pe,
2434
+ onToggleGroup: N,
2435
+ expandLabel: Qe,
2436
+ collapseLabel: Mt
2437
+ }),
2438
+ [
2439
+ o,
2440
+ s,
2441
+ a,
2442
+ u,
2443
+ d,
2444
+ l,
2445
+ v,
2446
+ m,
2447
+ w,
2448
+ p,
2449
+ A,
2450
+ O,
2451
+ E,
2452
+ g,
2453
+ ye.cols,
2454
+ z,
2455
+ F,
2456
+ dt,
2457
+ V,
2458
+ J,
2459
+ Pe,
2460
+ N,
2461
+ Qe,
2462
+ Mt
2463
+ ]
2464
+ ), Ft = X(() => {
2465
+ const f = /* @__PURE__ */ new Map();
2466
+ for (const h of D) {
2467
+ const [M, S] = Et(h), k = y(S);
2468
+ if (k === void 0) continue;
2469
+ const U = f.get(M) ?? [];
2470
+ U.push(k), f.set(M, U);
2471
+ }
2472
+ const r = /* @__PURE__ */ new Map();
2473
+ for (const [h, M] of f)
2474
+ r.set(h, M.sort((S, k) => S - k).join(","));
2475
+ return r;
2476
+ }, [D, y]), pt = (me == null ? void 0 : me.col) ?? -1, St = /* @__PURE__ */ le(
2477
+ "div",
2478
+ {
2479
+ ref: I,
2480
+ role: "row",
2481
+ "aria-rowindex": 1,
2482
+ className: Lt({ position: "header" }),
2483
+ children: [
2484
+ /* @__PURE__ */ H(
2485
+ "div",
2486
+ {
2487
+ role: "columnheader",
2488
+ "aria-colindex": 1,
2489
+ className: Gt({ corner: !0 }),
2490
+ children: n ?? /* @__PURE__ */ H("span", { className: "ds:sr-only", children: K("heatmap.rowsHeader") })
2491
+ }
2492
+ ),
2493
+ Ct(ye.cols, (f) => /* @__PURE__ */ H(
2494
+ "div",
2495
+ {
2496
+ role: "columnheader",
2497
+ "aria-colindex": f + 2,
2498
+ "data-highlighted": pt === f,
2499
+ className: Gt(),
2500
+ children: l.columnLabel(s[f])
2501
+ },
2502
+ f
2503
+ )),
2504
+ w ? /* @__PURE__ */ H(
2505
+ "div",
2506
+ {
2507
+ role: "columnheader",
2508
+ "aria-colindex": C + 2,
2509
+ "data-highlighted": pt === C,
2510
+ className: Gt(),
2511
+ children: l.methodLabel(w)
2512
+ }
2513
+ ) : null
2514
+ ]
2515
+ }
2516
+ );
2517
+ let mt = null;
2518
+ if (b && m) {
2519
+ const f = i.length, r = l.methodLabel(b), h = q === f, M = (S, k, U, j = r) => /* @__PURE__ */ H(
2520
+ "div",
2521
+ {
2522
+ role: "gridcell",
2523
+ "aria-colindex": k + 2,
2524
+ "aria-label": l.sentence(j, U, S),
2525
+ tabIndex: h && B === k ? 0 : -1,
2526
+ className: Rt({ tone: en(S) }),
2527
+ children: l.visibleText(S)
2528
+ },
2529
+ k
2530
+ );
2531
+ mt = /* @__PURE__ */ le(
2532
+ "div",
2533
+ {
2534
+ ref: P,
2535
+ role: "row",
2536
+ "aria-rowindex": f + 2,
2537
+ className: Lt({ position: "footer" }),
2538
+ children: [
2539
+ /* @__PURE__ */ H(
2540
+ "div",
2541
+ {
2542
+ role: "rowheader",
2543
+ "aria-colindex": 1,
2544
+ "data-highlighted": (me == null ? void 0 : me.rowKey) === At,
2545
+ className: Zt({ kind: "total", virtualised: g }),
2546
+ children: r
2547
+ }
2548
+ ),
2549
+ Ct(
2550
+ ye.cols,
2551
+ (S) => M(m.columns[S], S, l.columnLabel(s[S]))
2552
+ ),
2553
+ w ? M(
2554
+ m.grand,
2555
+ C,
2556
+ l.methodLabel(w),
2557
+ // The corner aggregates every cell by the row method, so it
2558
+ // is named for all cells, not for the footer's own method.
2559
+ K("heatmap.allCells")
2560
+ ) : null
2561
+ ]
2562
+ }
2563
+ );
2564
+ }
2565
+ const Ee = [], ke = ye.rows;
2566
+ ke.lead > 0 && Ee.push(
2567
+ /* @__PURE__ */ H(
2568
+ "div",
2569
+ {
2570
+ "aria-hidden": "true",
2571
+ className: at({ axis: "row-lead" })
2572
+ },
2573
+ "row-lead"
2574
+ )
2575
+ ), ke.indexes.forEach((f, r) => {
2576
+ ke.middle > 0 && r === ke.middleAfter && Ee.push(
2577
+ /* @__PURE__ */ H(
2578
+ "div",
2579
+ {
2580
+ "aria-hidden": "true",
2581
+ className: at({ axis: "row-middle" })
2582
+ },
2583
+ "row-middle"
2584
+ )
2585
+ );
2586
+ const h = i[f];
2587
+ if (!h) return;
2588
+ const M = f === q;
2589
+ Ee.push(
2590
+ /* @__PURE__ */ H(
2591
+ oa,
2592
+ {
2593
+ ctx: ee,
2594
+ row: h,
2595
+ ariaRowIndex: f + 2,
2596
+ highlighted: (me == null ? void 0 : me.rowKey) === h.key,
2597
+ activeCol: M ? B : -1,
2598
+ tooltipCol: (Ce == null ? void 0 : Ce.rowKey) === h.key ? Ce.col : -1,
2599
+ selectedCols: h.kind === "data" ? Ft.get(o[h.rowIndex].id) ?? "" : ""
2600
+ },
2601
+ h.key
2602
+ )
2603
+ );
2604
+ }), ke.tail > 0 && Ee.push(
2605
+ /* @__PURE__ */ H(
2606
+ "div",
2607
+ {
2608
+ "aria-hidden": "true",
2609
+ className: at({ axis: "row-tail" })
2610
+ },
2611
+ "row-tail"
2612
+ )
2613
+ );
2614
+ const Bt = {
2615
+ "--heatmap-columns": String(Math.max(1, C)),
2616
+ "--heatmap-row-lead": String(ke.lead),
2617
+ "--heatmap-row-middle": String(ke.middle),
2618
+ "--heatmap-row-tail": String(ke.tail),
2619
+ "--heatmap-col-lead": String(ye.cols.lead),
2620
+ "--heatmap-col-middle": String(ye.cols.middle),
2621
+ "--heatmap-col-tail": String(ye.cols.tail),
2622
+ "--heatmap-sticky-block-start": `${fe.headerBlock}px`,
2623
+ "--heatmap-sticky-block-end": `${fe.footerBlock}px`,
2624
+ "--heatmap-sticky-inline-start": `${fe.leadInline}px`
2625
+ };
2626
+ return /* @__PURE__ */ le(
2627
+ "div",
2628
+ {
2629
+ ref: $,
2630
+ onScroll: xt,
2631
+ style: Bt,
2632
+ "data-component": "heatmap-grid",
2633
+ className: Jo(),
2634
+ children: [
2635
+ /* @__PURE__ */ le(
2636
+ "div",
2637
+ {
2638
+ ref: c,
2639
+ role: "grid",
2640
+ tabIndex: -1,
2641
+ "aria-label": t,
2642
+ "aria-rowcount": x.length + 1,
2643
+ "aria-colcount": Q + 1,
2644
+ "aria-multiselectable": O === "multiple" || O === "range" ? !0 : void 0,
2645
+ "data-heatmap-grid": "",
2646
+ className: Xo({
2647
+ size: R,
2648
+ density: L,
2649
+ virtualised: g,
2650
+ totalsColumn: !!w
2651
+ }),
2652
+ onKeyDown: Fe,
2653
+ onPointerDown: It,
2654
+ onPointerMove: zt,
2655
+ onPointerLeave: kt,
2656
+ onClick: He,
2657
+ onFocus: (f) => {
2658
+ f.target.matches(":focus-visible") && (Z.current = "keyboard"), be.current = !0, Ne(!0);
2659
+ },
2660
+ onBlur: (f) => {
2661
+ f.currentTarget.contains(f.relatedTarget) || (be.current = !1, Ne(!1));
2662
+ },
2663
+ children: [
2664
+ St,
2665
+ Ee,
2666
+ mt
2667
+ ]
2668
+ }
2669
+ ),
2670
+ ut !== null ? /* @__PURE__ */ H("span", { id: dt, hidden: !0, children: ut }) : null
2671
+ ]
2672
+ }
2673
+ );
2674
+ }
2675
+ const Pt = Array.from({ length: Re }, (e, t) => t);
2676
+ function ra(e, t) {
2677
+ return {
2678
+ start: e.min === null ? "" : t(e.min),
2679
+ end: e.max === null ? "" : t(e.max),
2680
+ middle: e.type === "diverging" && e.midpoint !== void 0 ? t(e.midpoint) : void 0
2681
+ };
2682
+ }
2683
+ const an = Mn(
2684
+ ({
2685
+ variant: e = "stepped",
2686
+ palette: t,
2687
+ scale: n,
2688
+ values: o,
2689
+ valueFormatter: s,
2690
+ showEmpty: a,
2691
+ showLowSample: i,
2692
+ showWithheldTotal: u,
2693
+ minCount: d,
2694
+ className: l
2695
+ }, v) => {
2696
+ const { t: m, i18n: w } = Ht("ui"), b = Rn(), p = An(w.resolvedLanguage ?? w.language), A = X(
2697
+ () => n ? Qt(n, o ?? []) : (b == null ? void 0 : b.scale) ?? Qt({ type: "sequential" }, o ?? []),
2698
+ [n, o, b == null ? void 0 : b.scale]
2699
+ ), O = t ?? (b == null ? void 0 : b.palette) ?? (A.type === "diverging" ? "diverging" : "primary"), D = s ?? (b == null ? void 0 : b.describer.formatValue) ?? En(p, "number"), y = (A.type === "quantile" || A.type === "threshold") && A.thresholds.length > 0, E = A.thresholds.length + 1, g = y ? Array.from(
2700
+ { length: E },
2701
+ ($, c) => Jt(c, E)
2702
+ ) : [], R = A.thresholds.map(D), L = ra(A, D), V = y ? m("heatmap.legend.descriptionBands", {
2703
+ count: E,
2704
+ formatted: Tn(p)(E),
2705
+ edges: new Intl.ListFormat(p, {
2706
+ type: "conjunction"
2707
+ }).format(R)
2708
+ }) : L.middle !== void 0 ? m("heatmap.legend.descriptionDiverging", {
2709
+ min: L.start,
2710
+ max: L.end,
2711
+ midpoint: L.middle
2712
+ }) : m("heatmap.legend.description", {
2713
+ min: L.start,
2714
+ max: L.end
2715
+ }), J = (A.type === "quantile" || A.type === "threshold") && !y ? [A.min === null ? Re / 2 : A.stepOf(A.min)] : null, F = a ?? (b == null ? void 0 : b.hasEmpty) ?? !1, Y = i ?? (b == null ? void 0 : b.hasLowSample) ?? !1, T = u ?? (b == null ? void 0 : b.hasWithheldTotal) ?? !1, N = d ?? (b == null ? void 0 : b.minCount), K = e === "continuous" ? "continuous" : "stepped", z = ($) => /* @__PURE__ */ H("span", { className: ea({ variant: e }), children: $.map((c) => /* @__PURE__ */ H(
2716
+ "span",
2717
+ {
2718
+ className: tt({
2719
+ tone: Xt(O, c),
2720
+ shape: K
2721
+ })
2722
+ },
2723
+ c
2724
+ )) });
2725
+ return /* @__PURE__ */ le(
2726
+ "div",
2727
+ {
2728
+ ref: v,
2729
+ role: "group",
2730
+ "aria-label": m("heatmap.legend.label"),
2731
+ "data-component": "heatmap-legend",
2732
+ className: Zo({ className: l }),
2733
+ children: [
2734
+ /* @__PURE__ */ H("span", { className: "ds:sr-only", children: V }),
2735
+ y ? /* @__PURE__ */ H(
2736
+ "span",
2737
+ {
2738
+ "aria-hidden": "true",
2739
+ "data-legend": "bands",
2740
+ className: "ds:flex ds:min-w-0 ds:max-w-full ds:flex-wrap ds:items-center ds:gap-[var(--spacing-xs)] ds:tabular-nums",
2741
+ children: g.map(($, c) => /* @__PURE__ */ le(
2742
+ "span",
2743
+ {
2744
+ className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]",
2745
+ children: [
2746
+ /* @__PURE__ */ H(
2747
+ "span",
2748
+ {
2749
+ "data-step": $,
2750
+ className: tt({
2751
+ tone: Xt(O, $),
2752
+ shape: "key"
2753
+ })
2754
+ }
2755
+ ),
2756
+ c < R.length ? /* @__PURE__ */ H("span", { className: "ds:shrink-0", children: R[c] }) : null
2757
+ ]
2758
+ },
2759
+ $
2760
+ ))
2761
+ }
2762
+ ) : /* @__PURE__ */ le(
2763
+ "span",
2764
+ {
2765
+ "aria-hidden": "true",
2766
+ className: "ds:flex ds:min-w-0 ds:max-w-full ds:items-center ds:gap-[var(--spacing-xs)] ds:tabular-nums",
2767
+ children: [
2768
+ /* @__PURE__ */ H("span", { className: "ds:shrink-0", children: L.start }),
2769
+ L.middle !== void 0 ? /* @__PURE__ */ le(Vn, { children: [
2770
+ z(Pt.slice(0, Re / 2)),
2771
+ /* @__PURE__ */ H(
2772
+ "span",
2773
+ {
2774
+ "data-legend": "midpoint",
2775
+ className: tt({
2776
+ tone: "midpoint",
2777
+ shape: "label"
2778
+ }),
2779
+ children: L.middle
2780
+ }
2781
+ ),
2782
+ z(Pt.slice(Re / 2))
2783
+ ] }) : z(J ?? Pt),
2784
+ /* @__PURE__ */ H("span", { className: "ds:shrink-0", children: L.end })
2785
+ ]
2786
+ }
2787
+ ),
2788
+ F ? /* @__PURE__ */ le("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
2789
+ /* @__PURE__ */ H(
2790
+ "span",
2791
+ {
2792
+ "aria-hidden": "true",
2793
+ className: tt({ tone: "empty" })
2794
+ }
2795
+ ),
2796
+ m("heatmap.legend.noData")
2797
+ ] }) : null,
2798
+ Y ? /* @__PURE__ */ le("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
2799
+ /* @__PURE__ */ H(
2800
+ "span",
2801
+ {
2802
+ "aria-hidden": "true",
2803
+ className: tt({ tone: "low-sample" })
2804
+ }
2805
+ ),
2806
+ N === void 0 ? m("heatmap.legend.lowSample") : m("heatmap.legend.lowSampleUnder", {
2807
+ value: new Intl.NumberFormat(p).format(N)
2808
+ })
2809
+ ] }) : null,
2810
+ T ? /* @__PURE__ */ le("span", { className: "ds:inline-flex ds:items-center ds:gap-[var(--spacing-xs)]", children: [
2811
+ /* @__PURE__ */ H(
2812
+ "span",
2813
+ {
2814
+ "aria-hidden": "true",
2815
+ className: tt({ tone: "low-sample" })
2816
+ }
2817
+ ),
2818
+ m("heatmap.legend.totalWithheld")
2819
+ ] }) : null
2820
+ ]
2821
+ }
2822
+ );
2823
+ }
2824
+ );
2825
+ an.displayName = "HeatmapLegend";
2826
+ const rn = () => import("./data-table-COoCQ4n_.js").then((e) => e.h).then((e) => ({
2827
+ default: e.DataTable
2828
+ })), sa = Sn(rn);
2829
+ function xn() {
2830
+ rn().catch(() => {
2831
+ });
2832
+ }
2833
+ const In = { value: null, status: "empty" };
2834
+ function ia({
2835
+ title: e,
2836
+ rowsLabel: t,
2837
+ rows: n,
2838
+ columns: o,
2839
+ matrix: s,
2840
+ body: a,
2841
+ grouped: i,
2842
+ groupIds: u,
2843
+ describer: d,
2844
+ totals: l,
2845
+ rowTotals: v,
2846
+ columnTotals: m,
2847
+ groupColumnMethod: w,
2848
+ onLoadError: b
2849
+ }) {
2850
+ const { t: p } = Ht("ui"), A = X(
2851
+ () => [
2852
+ ...i ? [
2853
+ {
2854
+ colId: "group",
2855
+ field: "group",
2856
+ headerName: p("heatmap.table.group"),
2857
+ // A sort here would pull rows out of their groups.
2858
+ sortable: !1
2859
+ }
2860
+ ] : [],
2861
+ {
2862
+ colId: "row",
2863
+ field: "row",
2864
+ headerName: t ?? p("heatmap.rowsHeader"),
2865
+ sortable: !i
2866
+ },
2867
+ ...o.map(
2868
+ (N, K) => ({
2869
+ colId: `c${K}`,
2870
+ headerName: d.columnLabel(N),
2871
+ valueGetter: (z) => {
2872
+ var $;
2873
+ return (($ = z.data) == null ? void 0 : $.cells[K]) ?? "";
2874
+ },
2875
+ sortable: !1
2876
+ })
2877
+ ),
2878
+ ...v ? [
2879
+ {
2880
+ colId: "total",
2881
+ field: "total",
2882
+ headerName: d.methodLabel(v),
2883
+ sortable: !1
2884
+ }
2885
+ ] : []
2886
+ ],
2887
+ [i, t, o, d, v, p]
2888
+ ), O = X(
2889
+ () => a.map((N) => {
2890
+ if (N.kind === "group") {
2891
+ const $ = d.groupLabel(N.groupId), c = (l == null ? void 0 : l.groupColumns.get(N.groupId)) ?? [];
2892
+ return {
2893
+ id: `group:${u.get(N.groupId) ?? ""}`,
2894
+ group: $,
2895
+ row: d.groupRowText($, w),
2896
+ cells: o.map(
2897
+ (I, P) => d.tableText(c[P] ?? In)
2898
+ ),
2899
+ total: v && l ? d.tableText(
2900
+ l.groups.get(N.groupId) ?? In
2901
+ ) : void 0
2902
+ };
2903
+ }
2904
+ const K = N.rowIndex, z = n[K].group;
2905
+ return {
2906
+ id: `row:${n[K].id}`,
2907
+ group: i && z !== void 0 ? d.groupLabel(z) : void 0,
2908
+ row: d.rowLabel(n[K]),
2909
+ cells: s[K].map(($) => d.tableText($)),
2910
+ total: v && l ? d.tableText(l.rows[K]) : void 0
2911
+ };
2912
+ }),
2913
+ [
2914
+ a,
2915
+ n,
2916
+ o,
2917
+ s,
2918
+ i,
2919
+ u,
2920
+ d,
2921
+ v,
2922
+ l,
2923
+ w
2924
+ ]
2925
+ ), D = X(
2926
+ () => m && l ? [
2927
+ {
2928
+ id: "heatmap-column-totals",
2929
+ row: d.methodLabel(m),
2930
+ cells: l.columns.map((N) => d.tableText(N)),
2931
+ // The grand total, by the row method, as the grid's corner.
2932
+ total: v ? d.tableText(l.grand) : void 0
2933
+ }
2934
+ ] : void 0,
2935
+ [m, v, l, d]
2936
+ ), y = O.length + ((D == null ? void 0 : D.length) ?? 0), E = ie(y);
2937
+ E.current = y;
2938
+ const [g, R] = we(null), L = g === y, V = ie(null);
2939
+ nt(() => {
2940
+ const N = V.current;
2941
+ if (L || !N || typeof ResizeObserver > "u") return;
2942
+ const K = new ResizeObserver(() => {
2943
+ N.scrollHeight > N.clientHeight + 1 && R(E.current);
2944
+ }), z = () => {
2945
+ K.observe(N);
2946
+ for (const c of Array.from(N.children)) K.observe(c);
2947
+ };
2948
+ z();
2949
+ const $ = new MutationObserver(z);
2950
+ return $.observe(N, { childList: !0 }), () => {
2951
+ K.disconnect(), $.disconnect();
2952
+ };
2953
+ }, [L]);
2954
+ const J = X(
2955
+ () => ({
2956
+ getRowId: (N) => N.data.id,
2957
+ domLayout: L ? "normal" : "autoHeight"
2958
+ }),
2959
+ [L]
2960
+ ), [F, Y] = we(0), T = X(
2961
+ () => F === 0 ? sa : Sn(rn),
2962
+ [F]
2963
+ );
2964
+ return /* @__PURE__ */ H(
2965
+ "div",
2966
+ {
2967
+ ref: V,
2968
+ role: "group",
2969
+ "aria-label": e,
2970
+ tabIndex: -1,
2971
+ "data-component": "heatmap-table",
2972
+ "data-layout": L ? "capped" : "fit",
2973
+ className: Qo({ capped: L }),
2974
+ children: /* @__PURE__ */ H(
2975
+ to,
2976
+ {
2977
+ size: "sm",
2978
+ onError: () => b == null ? void 0 : b(),
2979
+ onRetry: () => {
2980
+ var N;
2981
+ Y((K) => K + 1), (N = V.current) == null || N.focus();
2982
+ },
2983
+ children: /* @__PURE__ */ H(
2984
+ qn,
2985
+ {
2986
+ fallback: /* @__PURE__ */ H("div", { role: "status", "aria-label": p("heatmap.loadingTable"), children: /* @__PURE__ */ H(
2987
+ qt,
2988
+ {
2989
+ variant: "rectangular",
2990
+ className: "ds:h-[calc(var(--min-target-size)*4)] ds:w-full"
2991
+ }
2992
+ ) }),
2993
+ children: /* @__PURE__ */ H(
2994
+ T,
2995
+ {
2996
+ columnDefs: A,
2997
+ rowData: O,
2998
+ pinnedBottomRowData: D,
2999
+ density: "compact",
3000
+ heightClass: L ? "ds:min-h-0 ds:flex-1" : "",
3001
+ gridOptions: J
3002
+ }
3003
+ )
3004
+ }
3005
+ )
3006
+ }
3007
+ )
3008
+ }
3009
+ );
3010
+ }
3011
+ const la = { type: "sequential", domain: "auto" }, jt = (e) => new Set((e ?? []).map((t) => Ot(t.rowId, t.columnId))), kn = { text: "", privacyMode: !1, repeat: 0 }, Bn = Mn(
3012
+ ({
3013
+ title: e,
3014
+ rows: t,
3015
+ columns: n,
3016
+ getCell: o,
3017
+ cells: s,
3018
+ groups: a,
3019
+ scale: i = la,
3020
+ palette: u,
3021
+ valueType: d = "number",
3022
+ minCount: l,
3023
+ getTotal: v,
3024
+ valueFormatter: m,
3025
+ showValues: w = !1,
3026
+ legend: b = "stepped",
3027
+ rowTotals: p = !1,
3028
+ columnTotals: A = !1,
3029
+ sortRows: O,
3030
+ defaultSortRows: D = "none",
3031
+ onSortRowsChange: y,
3032
+ groupRows: E = !1,
3033
+ defaultCollapsedGroups: g,
3034
+ selection: R = "none",
3035
+ selectedCells: L,
3036
+ defaultSelectedCells: V,
3037
+ onSelectionChange: J,
3038
+ onCellClick: F,
3039
+ renderTooltip: Y,
3040
+ density: T = "default",
3041
+ size: N = "md",
3042
+ loading: K = !1,
3043
+ privacyMode: z = !1,
3044
+ privacyScope: $ = "rows",
3045
+ rowsLabel: c,
3046
+ defaultView: I = "heatmap",
3047
+ onViewChange: P,
3048
+ id: C,
3049
+ className: Q,
3050
+ children: te
3051
+ }, x) => {
3052
+ const { t: _, i18n: W } = Ht("ui"), G = An(W.resolvedLanguage ?? W.language), q = X(
3053
+ () => Ko(t, n, o, s, l),
3054
+ [t, n, o, s, l]
3055
+ ), B = X(() => zo(q), [q]), re = JSON.stringify(i), ne = X(
3056
+ () => Qt(i, B),
3057
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- keyed by content
3058
+ [re, B]
3059
+ ), Me = u ?? (ne.type === "diverging" ? "diverging" : "primary"), Ne = X(
3060
+ () => m ?? En(G, d),
3061
+ [m, G, d]
3062
+ ), be = X(() => Tn(G), [G]), Z = X(
3063
+ () => lo({
3064
+ t: _,
3065
+ privacyMode: z,
3066
+ privacyScope: $,
3067
+ valueType: d,
3068
+ formatValue: Ne,
3069
+ formatCount: be,
3070
+ groups: a
3071
+ }),
3072
+ [
3073
+ _,
3074
+ z,
3075
+ $,
3076
+ d,
3077
+ Ne,
3078
+ be,
3079
+ a
3080
+ ]
3081
+ ), pe = X(
3082
+ () => Do(t, a),
3083
+ [t, a]
3084
+ ), je = A || p || "mean", qe = p || A || "mean", wt = A || p || "mean", [Oe, We] = we(kn), me = ie(0), Ce = ie(z);
3085
+ Ce.current = z;
3086
+ const fe = ae((r, h = !1) => {
3087
+ window.clearTimeout(me.current);
3088
+ const M = Ce.current, S = () => We((k) => ({
3089
+ text: r,
3090
+ privacyMode: M,
3091
+ repeat: k.text === r ? k.repeat + 1 : 0
3092
+ }));
3093
+ h ? me.current = window.setTimeout(S, 300) : S();
3094
+ }, []);
3095
+ gt(() => () => window.clearTimeout(me.current), []), gt(() => {
3096
+ window.clearTimeout(me.current), We((r) => r.text === "" ? r : kn);
3097
+ }, [z]);
3098
+ const Dt = Oe.privacyMode === z ? (
3099
+ // The same words twice leave the DOM unchanged and a screen reader
3100
+ // silent: a trailing no-break space on every other repeat changes
3101
+ // the text without changing what is read.
3102
+ `${Oe.text}${Oe.repeat % 2 === 1 ? " " : ""}`
3103
+ ) : "", [ve, st] = we(I), it = ae(
3104
+ (r) => {
3105
+ st(r), P == null || P(r), fe(
3106
+ _(r === "table" ? "heatmap.announce.tableView" : "heatmap.announce.heatmapView")
3107
+ );
3108
+ },
3109
+ [P, fe, _]
3110
+ ), [bt, lt] = we(D), De = O ?? bt, Kt = ae(
3111
+ (r) => {
3112
+ O === void 0 && lt(r), y == null || y(r);
3113
+ },
3114
+ [O, y]
3115
+ ), [_e, yt] = we(
3116
+ () => new Set(g ?? [])
3117
+ ), ye = ae(
3118
+ (r, h) => {
3119
+ if (_e.has(r) === h) return;
3120
+ yt((S) => {
3121
+ if (S.has(r) === h) return S;
3122
+ const k = new Set(S);
3123
+ return h ? k.add(r) : k.delete(r), k;
3124
+ });
3125
+ const M = Z.groupLabel(r);
3126
+ fe(
3127
+ h ? _("heatmap.announce.groupCollapsed", { group: M }) : _("heatmap.announce.groupExpanded", { group: M })
3128
+ );
3129
+ },
3130
+ [_e, fe, Z, _]
3131
+ ), Ue = ae(
3132
+ (r) => ye(r, !_e.has(r)),
3133
+ [_e, ye]
3134
+ ), Ke = X(
3135
+ () => new Intl.Collator(G, { numeric: !0, sensitivity: "base" }),
3136
+ [G]
3137
+ ), xt = De === "label" && Z.masksRows ? "none" : De, xe = X(
3138
+ () => $o(q, t, n, {
3139
+ rowMethod: qe,
3140
+ columnMethod: wt,
3141
+ groupColumnMethod: je,
3142
+ groups: a,
3143
+ minCount: l,
3144
+ getTotal: v,
3145
+ valueType: d
3146
+ }),
3147
+ [
3148
+ q,
3149
+ t,
3150
+ n,
3151
+ qe,
3152
+ wt,
3153
+ je,
3154
+ a,
3155
+ l,
3156
+ v,
3157
+ d
3158
+ ]
3159
+ ), Ye = X(
3160
+ () => qo(
3161
+ t.map((r, h) => h),
3162
+ t,
3163
+ xe.rows,
3164
+ xt,
3165
+ Ke
3166
+ ),
3167
+ [t, xe.rows, xt, Ke]
3168
+ ), de = X(
3169
+ () => pn(t, Ye, E, _e),
3170
+ [t, Ye, E, _e]
3171
+ ), ze = X(
3172
+ () => pn(t, Ye, E, /* @__PURE__ */ new Set()),
3173
+ [t, Ye, E]
3174
+ ), Ie = X(
3175
+ () => new Map(t.map((r, h) => [r.id, h])),
3176
+ [t]
3177
+ ), Se = X(
3178
+ () => new Map(n.map((r, h) => [String(r.id), h])),
3179
+ [n]
3180
+ ), ct = ae(
3181
+ (r) => Se.get(r),
3182
+ [Se]
3183
+ ), Fe = ae(
3184
+ (r, h) => {
3185
+ const M = t[r], S = n[h], k = q[r][h];
3186
+ return {
3187
+ rowId: M.id,
3188
+ columnId: S.id,
3189
+ row: M,
3190
+ column: S,
3191
+ rowIndex: r,
3192
+ columnIndex: h,
3193
+ value: k.value,
3194
+ count: k.count,
3195
+ label: k.label,
3196
+ status: k.status,
3197
+ step: k.status === "value" && k.value !== null ? ne.stepOf(k.value) : null
3198
+ };
3199
+ },
3200
+ [t, n, q, ne]
3201
+ ), Je = ae(
3202
+ (r) => {
3203
+ const h = r.row.group === void 0 ? void 0 : pe.get(r.row.group);
3204
+ return {
3205
+ rowId: r.rowId,
3206
+ columnId: r.columnId,
3207
+ row: {
3208
+ id: r.row.id,
3209
+ label: Z.rowLabel(r.row),
3210
+ ...h === void 0 ? {} : { group: h }
3211
+ },
3212
+ column: {
3213
+ id: r.column.id,
3214
+ label: Z.columnLabel(r.column)
3215
+ },
3216
+ rowIndex: r.rowIndex,
3217
+ columnIndex: r.columnIndex,
3218
+ value: r.value,
3219
+ count: r.count,
3220
+ status: r.status,
3221
+ step: r.step
3222
+ };
3223
+ },
3224
+ [Z, pe]
3225
+ ), Be = ae(
3226
+ (r) => Y ? Y(z ? Je(r) : r, {
3227
+ privacyMode: z
3228
+ }) : Z.sentence(
3229
+ Z.rowLabel(r.row),
3230
+ Z.columnLabel(r.column),
3231
+ q[r.rowIndex][r.columnIndex]
3232
+ ),
3233
+ [Y, z, Je, Z, q]
3234
+ ), Ve = L !== void 0, [It, zt] = we(
3235
+ () => jt(V)
3236
+ ), he = X(() => {
3237
+ const r = Ve ? jt(L) : It, h = /* @__PURE__ */ new Set();
3238
+ for (const M of r) {
3239
+ const [S, k] = Et(M);
3240
+ Ie.has(S) && Se.has(k) && h.add(M);
3241
+ }
3242
+ return h;
3243
+ }, [
3244
+ Ve,
3245
+ L,
3246
+ It,
3247
+ Ie,
3248
+ Se
3249
+ ]), Ge = ae(
3250
+ (r) => {
3251
+ const h = [];
3252
+ for (const M of r) {
3253
+ const [S, k] = Et(M), U = Ie.get(S), j = Se.get(k);
3254
+ U !== void 0 && j !== void 0 && h.push(Fe(U, j));
3255
+ }
3256
+ return h;
3257
+ },
3258
+ [Ie, Se, Fe]
3259
+ ), kt = ae(
3260
+ (r, h) => Z.cellName(
3261
+ Z.rowLabel(t[r]),
3262
+ Z.columnLabel(n[h])
3263
+ ),
3264
+ [Z, t, n]
3265
+ ), He = ae(
3266
+ (r, h, M = !1) => {
3267
+ Ve || zt(r), J == null || J(Ge(r)), fe(h, M);
3268
+ },
3269
+ [Ve, J, Ge, fe]
3270
+ ), $e = ae(
3271
+ (r) => r === 0 ? _("heatmap.announce.cleared") : _("heatmap.announce.count", {
3272
+ count: r,
3273
+ formatted: be(r)
3274
+ }),
3275
+ [_, be]
3276
+ ), Pe = X(
3277
+ () => de.flatMap((r) => r.kind === "data" ? [r.rowIndex] : []),
3278
+ [de]
3279
+ ), Qe = ae(
3280
+ (r, h) => {
3281
+ const M = Pe.indexOf(r.rowIndex), S = Pe.indexOf(h.rowIndex), k = /* @__PURE__ */ new Set();
3282
+ if (M === -1 || S === -1) return k;
3283
+ const [U, j] = M <= S ? [M, S] : [S, M], [oe, se] = r.col <= h.col ? [r.col, h.col] : [h.col, r.col];
3284
+ for (let ue = U; ue <= j; ue += 1) {
3285
+ const ce = t[Pe[ue]].id;
3286
+ for (let Ae = oe; Ae <= se; Ae += 1)
3287
+ k.add(Ot(ce, n[Ae].id));
3288
+ }
3289
+ return k;
3290
+ },
3291
+ [Pe, t, n]
3292
+ ), Mt = ae(
3293
+ (r, h, M) => {
3294
+ if (F == null || F(Fe(r, h)), !M || R === "none") return;
3295
+ const S = Ot(t[r].id, n[h].id), k = kt(r, h);
3296
+ if (R === "multiple") {
3297
+ const j = new Set(he), oe = !j.has(S);
3298
+ oe ? j.add(S) : j.delete(S), He(
3299
+ j,
3300
+ _(oe ? "heatmap.announce.added" : "heatmap.announce.removed", {
3301
+ cell: k,
3302
+ count: j.size,
3303
+ formatted: be(j.size)
3304
+ })
3305
+ );
3306
+ return;
3307
+ }
3308
+ const U = he.size === 1 && he.has(S);
3309
+ He(
3310
+ U ? /* @__PURE__ */ new Set() : /* @__PURE__ */ new Set([S]),
3311
+ U ? _("heatmap.announce.cleared") : _("heatmap.announce.selected", { cell: k })
3312
+ );
3313
+ },
3314
+ [
3315
+ F,
3316
+ Fe,
3317
+ R,
3318
+ t,
3319
+ n,
3320
+ kt,
3321
+ he,
3322
+ He,
3323
+ be,
3324
+ _
3325
+ ]
3326
+ ), dt = ae(
3327
+ (r, h) => {
3328
+ if (R !== "range" && R !== "multiple") return;
3329
+ const M = Qe(r, h);
3330
+ M.size === he.size && [...M].every((S) => he.has(S)) || He(M, $e(M.size), !0);
3331
+ },
3332
+ [R, Qe, he, He, $e]
3333
+ ), Xe = X(
3334
+ () => new Map([...pe].map(([r, h]) => [h, r])),
3335
+ [pe]
3336
+ ), ut = {
3337
+ selected: he,
3338
+ selection: R,
3339
+ view: ve,
3340
+ sortRows: De,
3341
+ collapsed: _e,
3342
+ groupRows: E,
3343
+ rows: t,
3344
+ columns: n,
3345
+ expandedBody: ze,
3346
+ groupIds: pe,
3347
+ groupByPublicId: Xe,
3348
+ rowIndexById: Ie,
3349
+ columnIndexById: Se,
3350
+ matrix: q,
3351
+ scale: ne,
3352
+ setView: it,
3353
+ setSortRows: Kt,
3354
+ setGroupCollapsed: ye,
3355
+ commitSelection: He,
3356
+ rectangle: Qe,
3357
+ countMessage: $e
3358
+ }, ee = ie(ut);
3359
+ ee.current = ut;
3360
+ const Ft = X(() => {
3361
+ const r = (k) => {
3362
+ const { columns: U, columnIndexById: j } = ee.current, oe = [];
3363
+ for (const se of k) {
3364
+ const [ue, ce] = Et(se), Ae = j.get(ce);
3365
+ Ae !== void 0 && oe.push({ rowId: ue, columnId: U[Ae].id });
3366
+ }
3367
+ return oe;
3368
+ }, h = (k) => {
3369
+ const { rowIndexById: U, columnIndexById: j } = ee.current, oe = U.get(k.rowId), se = j.get(String(k.columnId));
3370
+ return oe === void 0 || se === void 0 ? null : { rowIndex: oe, col: se };
3371
+ }, M = (k) => {
3372
+ const U = h(k);
3373
+ if (!U)
3374
+ throw new Error(
3375
+ `Heatmap: no cell at row "${k.rowId}", column "${String(k.columnId)}".`
3376
+ );
3377
+ return U;
3378
+ }, S = () => {
3379
+ if (ee.current.selection === "none")
3380
+ throw new Error('Heatmap: selection is off (selection="none").');
3381
+ };
3382
+ return {
3383
+ getSelection: () => r(ee.current.selected),
3384
+ getSelectionMode: () => ee.current.selection,
3385
+ selectCells: (k) => {
3386
+ S(), k.forEach(M);
3387
+ const { selection: U } = ee.current, j = U === "single" ? k.slice(0, 1) : k, oe = jt(j);
3388
+ ee.current.commitSelection(
3389
+ oe,
3390
+ ee.current.countMessage(oe.size)
3391
+ );
3392
+ },
3393
+ selectRange: (k, U) => {
3394
+ const { selection: j } = ee.current;
3395
+ if (j !== "range" && j !== "multiple")
3396
+ throw new Error(
3397
+ 'Heatmap: select_range needs selection="range" or "multiple".'
3398
+ );
3399
+ const oe = M(k), se = M(U), ue = ee.current.rectangle(oe, se);
3400
+ ee.current.commitSelection(
3401
+ ue,
3402
+ ee.current.countMessage(ue.size)
3403
+ );
3404
+ },
3405
+ clearSelection: () => {
3406
+ S(), ee.current.selected.size !== 0 && ee.current.commitSelection(
3407
+ /* @__PURE__ */ new Set(),
3408
+ ee.current.countMessage(0)
3409
+ );
3410
+ },
3411
+ readCell: (k) => {
3412
+ const U = h(k);
3413
+ if (!U) return null;
3414
+ const j = ee.current.matrix[U.rowIndex][U.col];
3415
+ return {
3416
+ value: j.value,
3417
+ count: j.count,
3418
+ status: j.status,
3419
+ step: j.status === "value" && j.value !== null ? ee.current.scale.stepOf(j.value) : null
3420
+ };
3421
+ },
3422
+ getView: () => ee.current.view,
3423
+ setView: (k) => ee.current.setView(k),
3424
+ getSortRows: () => ee.current.sortRows,
3425
+ setSortRows: (k) => ee.current.setSortRows(k),
3426
+ getRowIds: () => {
3427
+ const { expandedBody: k, rows: U } = ee.current;
3428
+ return k.flatMap(
3429
+ (j) => j.kind === "data" ? [U[j.rowIndex].id] : []
3430
+ );
3431
+ },
3432
+ getColumnIds: () => ee.current.columns.map((k) => k.id),
3433
+ getGroupIds: () => {
3434
+ const {
3435
+ groupRows: k,
3436
+ expandedBody: U,
3437
+ groupIds: j
3438
+ } = ee.current;
3439
+ return k ? U.flatMap(
3440
+ (oe) => oe.kind === "group" ? [j.get(oe.groupId) ?? ""] : []
3441
+ ) : [];
3442
+ },
3443
+ getCollapsedGroups: () => {
3444
+ const { collapsed: k, groupIds: U } = ee.current;
3445
+ return [...k].flatMap((j) => {
3446
+ const oe = U.get(j);
3447
+ return oe === void 0 ? [] : [oe];
3448
+ });
3449
+ },
3450
+ setGroupCollapsed: (k, U) => {
3451
+ const { groupRows: j, groupByPublicId: oe } = ee.current;
3452
+ if (!j)
3453
+ throw new Error(
3454
+ "Heatmap: rows are not grouped (groupRows is off)."
3455
+ );
3456
+ const se = oe.get(k);
3457
+ if (se === void 0)
3458
+ throw new Error(`Heatmap: no group "${k}".`);
3459
+ ee.current.setGroupCollapsed(se, U);
3460
+ }
3461
+ };
3462
+ }, []);
3463
+ Wn(so, Ft, C);
3464
+ const pt = X(
3465
+ () => q.some((r) => r.some((h) => h.status === "empty")),
3466
+ [q]
3467
+ ), St = X(() => {
3468
+ const r = (S) => S.status === "low-sample", h = E ? [...xe.groupColumns.values()].flat() : [], M = E ? [...xe.groups.values()] : [];
3469
+ return h.some(r) || p !== !1 && (xe.rows.some(r) || M.some(r)) || A !== !1 && (xe.columns.some(r) || p !== !1 && r(xe.grand));
3470
+ }, [xe, p, A, E]), mt = X(
3471
+ () => q.some((r) => r.some((h) => h.status === "low-sample")),
3472
+ [q]
3473
+ ), Ee = X(
3474
+ () => ({
3475
+ palette: Me,
3476
+ scale: ne,
3477
+ describer: Z,
3478
+ hasEmpty: pt,
3479
+ hasLowSample: mt,
3480
+ hasWithheldTotal: St,
3481
+ minCount: l,
3482
+ tooltipText: Be
3483
+ }),
3484
+ [
3485
+ Me,
3486
+ ne,
3487
+ Z,
3488
+ pt,
3489
+ mt,
3490
+ St,
3491
+ l,
3492
+ Be
3493
+ ]
3494
+ ), ke = wn({ className: Q });
3495
+ if (K)
3496
+ return /* @__PURE__ */ H(_t.Provider, { value: Ee, children: /* @__PURE__ */ le(
3497
+ "div",
3498
+ {
3499
+ ref: x,
3500
+ "data-component": "heatmap",
3501
+ "data-component-id": C,
3502
+ className: ke,
3503
+ children: [
3504
+ /* @__PURE__ */ le(
3505
+ "div",
3506
+ {
3507
+ role: "status",
3508
+ "aria-label": _("heatmap.loading"),
3509
+ "aria-busy": "true",
3510
+ className: wn(),
3511
+ children: [
3512
+ /* @__PURE__ */ H(
3513
+ qt,
3514
+ {
3515
+ variant: "rectangular",
3516
+ className: "ds:h-[var(--spacing-md)] ds:w-[calc(var(--spacing-xl)*6)] ds:max-w-full"
3517
+ }
3518
+ ),
3519
+ /* @__PURE__ */ H(
3520
+ qt,
3521
+ {
3522
+ variant: "rectangular",
3523
+ className: "ds:h-[calc(var(--min-target-size)*5)] ds:w-full"
3524
+ }
3525
+ )
3526
+ ]
3527
+ }
3528
+ ),
3529
+ te
3530
+ ]
3531
+ }
3532
+ ) });
3533
+ if (t.length === 0 || n.length === 0 || !Fo(q))
3534
+ return /* @__PURE__ */ H(_t.Provider, { value: Ee, children: /* @__PURE__ */ le(
3535
+ "div",
3536
+ {
3537
+ ref: x,
3538
+ "data-component": "heatmap",
3539
+ "data-component-id": C,
3540
+ className: ke,
3541
+ children: [
3542
+ /* @__PURE__ */ H(
3543
+ Yn,
3544
+ {
3545
+ variant: "no-results",
3546
+ size: "sm",
3547
+ title: _("heatmap.empty.title"),
3548
+ description: _("heatmap.empty.description")
3549
+ }
3550
+ ),
3551
+ te
3552
+ ]
3553
+ }
3554
+ ) });
3555
+ const Bt = t.length * n.length > Wo, f = R !== "none" || F !== void 0;
3556
+ return /* @__PURE__ */ H(_t.Provider, { value: Ee, children: /* @__PURE__ */ le(
3557
+ "div",
3558
+ {
3559
+ ref: x,
3560
+ "data-component": "heatmap",
3561
+ "data-component-id": C,
3562
+ className: ke,
3563
+ children: [
3564
+ /* @__PURE__ */ le("div", { className: Yo(), children: [
3565
+ b !== !1 ? /* @__PURE__ */ H(an, { variant: b }) : null,
3566
+ /* @__PURE__ */ H(
3567
+ Un,
3568
+ {
3569
+ intent: "outline",
3570
+ size: "sm",
3571
+ className: "ds:ms-auto",
3572
+ startIcon: ve === "table" ? /* @__PURE__ */ H(oo, { "aria-hidden": "true" }) : /* @__PURE__ */ H(ro, { "aria-hidden": "true" }),
3573
+ onPointerEnter: ve === "table" ? void 0 : xn,
3574
+ onFocus: ve === "table" ? void 0 : xn,
3575
+ onClick: () => it(ve === "table" ? "heatmap" : "table"),
3576
+ children: _(ve === "table" ? "heatmap.viewAsHeatmap" : "heatmap.viewAsTable")
3577
+ }
3578
+ )
3579
+ ] }),
3580
+ ve === "table" ? /* @__PURE__ */ H(
3581
+ ia,
3582
+ {
3583
+ onLoadError: () => fe(_("heatmap.announce.tableFailed")),
3584
+ title: e,
3585
+ rowsLabel: c,
3586
+ rows: t,
3587
+ columns: n,
3588
+ matrix: q,
3589
+ body: ze,
3590
+ grouped: E,
3591
+ groupIds: pe,
3592
+ describer: Z,
3593
+ totals: xe,
3594
+ rowTotals: p,
3595
+ columnTotals: A,
3596
+ groupColumnMethod: je
3597
+ },
3598
+ `${z}-${$}`
3599
+ ) : /* @__PURE__ */ H(Qn, { delayDuration: 0, children: /* @__PURE__ */ H(
3600
+ aa,
3601
+ {
3602
+ title: e,
3603
+ rowsLabel: c,
3604
+ rows: t,
3605
+ columns: n,
3606
+ matrix: q,
3607
+ body: de,
3608
+ scale: ne,
3609
+ palette: Me,
3610
+ describer: Z,
3611
+ showValues: w,
3612
+ totals: xe,
3613
+ rowTotals: p,
3614
+ columnTotals: A,
3615
+ groupColumnMethod: je,
3616
+ groupIds: pe,
3617
+ selectionMode: R,
3618
+ selected: he,
3619
+ columnIndexOfKey: ct,
3620
+ interactive: f,
3621
+ virtualised: Bt,
3622
+ size: N,
3623
+ density: T,
3624
+ cellInfo: Fe,
3625
+ tooltipText: Be,
3626
+ describeFocused: Y !== void 0,
3627
+ onActivate: Mt,
3628
+ onRange: dt,
3629
+ onToggleGroup: Ue
3630
+ }
3631
+ ) }),
3632
+ te,
3633
+ /* @__PURE__ */ H(Jn, { children: Dt }, String(z))
3634
+ ]
3635
+ }
3636
+ ) });
3637
+ }
3638
+ );
3639
+ Bn.displayName = "Heatmap";
3640
+ const Aa = Object.assign(Bn, {
3641
+ Legend: an,
3642
+ Tooltip: Dn
3643
+ });
3644
+ export {
3645
+ Aa as H,
3646
+ an as a,
3647
+ Dn as b,
3648
+ so as h
3649
+ };
3650
+ //# sourceMappingURL=heatmap-C1TeC7wT.js.map