react-semaphor 0.1.603 → 0.1.605

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 (208) hide show
  1. package/dist/activity/index.js +1 -73
  2. package/dist/analytics-protocol/index.js +1 -1491
  3. package/dist/appearance/index.js +1 -12
  4. package/dist/appearance-runtime/index.js +1 -5
  5. package/dist/assistant-context/index.js +1 -11
  6. package/dist/assistant-protocol/index.js +1 -152
  7. package/dist/brand-studio/index.js +3 -1598
  8. package/dist/briefings/index.js +1 -70
  9. package/dist/chunks/add-to-dashboard-CEmZUf9o.js +12 -0
  10. package/dist/chunks/analytics-base-schemas-DMFrDqn_.js +1 -0
  11. package/dist/chunks/appearance-provider-CfoAVQuG.js +608 -0
  12. package/dist/chunks/appearance-runtime-provider-Bx8H-moR.js +1 -0
  13. package/dist/chunks/applied-constraints-CinevlKD.js +1 -0
  14. package/dist/chunks/assistant-chat-DgUaCE9k.js +51 -0
  15. package/dist/chunks/attachment-filter-line-C_zHMhGh.js +1 -0
  16. package/dist/chunks/attribution-BEFSsbNn.js +1 -0
  17. package/dist/chunks/availability-3AIOf6Z-.js +1 -0
  18. package/dist/chunks/bookmark-impact-BAtemeyK.js +1 -0
  19. package/dist/chunks/bookmark-state-DScd31KT.js +1 -0
  20. package/dist/chunks/brand-C9APUFaP.js +1 -0
  21. package/dist/chunks/card-filter-builder-ClWrXB7P.js +11 -0
  22. package/dist/chunks/column-bands-DwxbZ6UI.js +1 -0
  23. package/dist/chunks/comparison-window-caption-tguyN24S.js +1 -0
  24. package/dist/chunks/context-CntvtZwC.js +2 -0
  25. package/dist/chunks/conversation-JMK2kyTK.js +1 -0
  26. package/dist/chunks/dashboard-ChIcbVTx.js +1 -0
  27. package/dist/chunks/dashboard-briefing-launcher-CwMlhkxV.js +42 -0
  28. package/dist/chunks/dashboard-controls-UCSAFCGA.js +42 -0
  29. package/dist/chunks/dashboard-json-B120hYDa.js +1 -0
  30. package/dist/chunks/dashboard-temporal-snapshot-BFJKbp_6.js +1 -0
  31. package/dist/chunks/edit-dashboard-visual-DvHp03h_.js +73 -0
  32. package/dist/chunks/export-file-format-B-wQNHIn.js +4 -0
  33. package/dist/chunks/filter-line-WwUV5JzN.js +1 -0
  34. package/dist/chunks/filter-reach-preview-C5M5_hf_.js +1 -0
  35. package/dist/chunks/filter-value-text-DqTHe_vu.js +1 -0
  36. package/dist/chunks/index-DViPGDFj.js +1 -0
  37. package/dist/chunks/index-bkP6SnYu.js +1 -0
  38. package/dist/chunks/kpi-trend-rule-B87LNzcz.js +1 -0
  39. package/dist/chunks/layout-grid-CFzqJ7GC.js +6 -0
  40. package/dist/chunks/matrix-analytical-definition-5T-2euHZ.js +1 -0
  41. package/dist/chunks/matrix-member-presentation-vVAv-aqg.js +1 -0
  42. package/dist/chunks/matrix-operation-contract-CWvcEsQ0.js +1 -0
  43. package/dist/chunks/normalize-dashboard-for-dirty-check-ILKfqgL3.js +1 -0
  44. package/dist/chunks/numeric-range-options-C8tr-Bls.js +1 -0
  45. package/dist/chunks/palette-NvEIuXHN.js +6 -0
  46. package/dist/chunks/pivot-result-contract-expectations-BNWhS8mv.js +1 -0
  47. package/dist/chunks/pivot-result-identity-B0eWVMXg.js +1 -0
  48. package/dist/chunks/raw-temporal-value-BHQ-ldpW.js +1 -0
  49. package/dist/chunks/rendered-file-BbvwaU6z.js +1 -0
  50. package/dist/chunks/report-preferences-dialog-Bseb2Rlg.js +1 -0
  51. package/dist/chunks/report-runtime-context-Cd1b5pku.js +1 -0
  52. package/dist/chunks/resolve-dashboard-input-context-BDY7KwRe.js +8 -0
  53. package/dist/chunks/resolver-CjsW8Rz0.js +1 -0
  54. package/dist/chunks/saved-dashboard-context-C3lWc4Dx.js +1 -0
  55. package/dist/chunks/schema-O1Y3WTGF.js +4 -0
  56. package/dist/chunks/selection-filter-compiler-kYsRugss.js +1 -0
  57. package/dist/chunks/semaphor-ready-indicator-BQarSo6S.js +612 -0
  58. package/dist/chunks/set-6mOnfQeH.js +1 -0
  59. package/dist/chunks/slider-BPnHdMGq.js +4 -0
  60. package/dist/chunks/stored-dashboard-DfrxDLhR.js +1 -0
  61. package/dist/chunks/table-export-sheet-xaczzWZF.js +2 -0
  62. package/dist/chunks/token-types-1vzMWjI-.js +1 -0
  63. package/dist/chunks/validators-Dg2kyF4_.js +1 -0
  64. package/dist/chunks/variable-draft-B4_xqr4Y.js +1 -0
  65. package/dist/chunks/visual-choice-DgEFfkE-.js +1 -0
  66. package/dist/dashboard/index.js +1 -7
  67. package/dist/dashboard-authoring/index.js +1 -4614
  68. package/dist/format-utils/index.js +1 -425
  69. package/dist/index.js +1 -554
  70. package/dist/layouts/index.js +1 -7
  71. package/dist/live-channel/index.js +1 -124
  72. package/dist/pdf-export-policy/index.js +1 -92
  73. package/dist/pdf-table-layout/index.js +1 -993
  74. package/dist/report-runtime-context/index.js +1 -9
  75. package/dist/shared/index.js +1 -6
  76. package/dist/style.css +1 -1
  77. package/dist/surfboard/index.js +1 -9
  78. package/dist/types/brand-studio/brand-studio-draft.d.ts +45 -13
  79. package/dist/types/brand-studio/brand-studio-editor.d.ts +13 -2
  80. package/dist/types/components/index.d.ts +1 -0
  81. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +17 -6
  82. package/dist/types/components/visual/data-table/types/data-table.d.ts +52 -42
  83. package/dist/types/index.js +1 -88
  84. package/dist/types/lib/appearance/aliases.d.ts +3 -0
  85. package/dist/types/lib/appearance/index.d.ts +1 -0
  86. package/dist/types/lib/appearance/table-density.d.ts +18 -0
  87. package/dist/types/lib/appearance/types.d.ts +39 -1
  88. package/dist/types/lib/dashboard-viewer/column-header-actions.d.ts +100 -0
  89. package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +0 -27
  90. package/dist/types/lib/dashboard-viewer/table-view.d.ts +26 -2
  91. package/dist/types/lib/dashboard-viewer/use-table-view.d.ts +2 -0
  92. package/dist/types/lib/filter-values/build-card-filter-definition.d.ts +32 -0
  93. package/dist/types/lib/hooks/use-add-new-frame.d.ts +7 -0
  94. package/dist/types/lib/hooks/use-dashboard-card.d.ts +4 -0
  95. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +8 -0
  96. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +9 -0
  97. package/dist/types/lib/stores/dashboard-store.d.ts +14 -2
  98. package/dist/types/lib/stores/explorer-actions.d.ts +7 -10
  99. package/dist/types/lib/types/common-types.d.ts +1 -2
  100. package/dist/types/lib/types/semantic-types.d.ts +6 -10
  101. package/dist/types/lib/utils/card-config-utils.d.ts +13 -0
  102. package/dist/types/lib/utils/field-placement.d.ts +17 -0
  103. package/dist/types/lib/utils/field-state-calculator.d.ts +7 -19
  104. package/dist/types/shared/analytics-protocol/analytics-refusal.d.ts +21 -1
  105. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +7 -4
  106. package/dist/types/shared/dashboard-authoring/calculations/definition.d.ts +13 -0
  107. package/dist/types/shared/dashboard-authoring/card-data-source/card-base.d.ts +125 -0
  108. package/dist/types/shared/dashboard-authoring/card-data-source/card-field-folders.d.ts +55 -0
  109. package/dist/types/shared/dashboard-authoring/card-data-source/card-joins.d.ts +114 -0
  110. package/dist/types/shared/dashboard-authoring/card-data-source/card-prune.d.ts +12 -0
  111. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-catalog.d.ts +60 -0
  112. package/dist/types/shared/dashboard-authoring/card-data-source/filter-field-folders.d.ts +180 -0
  113. package/dist/types/shared/dashboard-authoring/card-data-source/index.d.ts +7 -0
  114. package/dist/types/shared/dashboard-authoring/card-data-source/join-reach.d.ts +42 -0
  115. package/dist/types/shared/dashboard-authoring/card-field-places.d.ts +28 -0
  116. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +2 -8
  117. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  118. package/dist/types/shared/dashboard-authoring/card-settings/column-display-values.d.ts +5 -0
  119. package/dist/types/shared/dashboard-authoring/card-settings/column-display.d.ts +52 -0
  120. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +1 -0
  121. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +9 -0
  122. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +4 -0
  123. package/dist/types/shared/dashboard-authoring/card-settings/table-viewer-switches.d.ts +15 -0
  124. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +5 -0
  125. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  126. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +132 -3
  127. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +3 -1
  128. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  129. package/dist/types/shared/dashboard-authoring/conditional-formatting/store.d.ts +10 -1
  130. package/dist/types/shared/dashboard-authoring/field-aggregations.d.ts +9 -2
  131. package/dist/types/shared/dashboard-authoring/field-folders/field-folders.d.ts +116 -0
  132. package/dist/types/shared/dashboard-authoring/field-folders/index.d.ts +1 -0
  133. package/dist/types/shared/dashboard-authoring/filter-reach-decision.d.ts +11 -0
  134. package/dist/types/shared/dashboard-authoring/index.d.ts +7 -1
  135. package/dist/types/shared/dashboard-authoring/operations/card-operations.d.ts +2 -0
  136. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +7 -2
  137. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +6 -2
  138. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -0
  139. package/dist/types/shared/dashboard-authoring/see-records/result.d.ts +7 -22
  140. package/dist/types/shared/dashboard-authoring/sheet-kinds.d.ts +36 -0
  141. package/dist/types/shared/dashboard-authoring/table-sheet-shape.d.ts +140 -0
  142. package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +15 -0
  143. package/dist/types/shared/dashboard-viewer/table-settings.d.ts +8 -2
  144. package/dist/types/shared/format-utils/types/format-types.d.ts +1 -1
  145. package/dist/usage-events/index.js +1 -285
  146. package/dist/value-format-preferences/index.js +1 -635
  147. package/package.json +5 -2
  148. package/dist/chunks/add-to-dashboard-CFF-wFU-.js +0 -291
  149. package/dist/chunks/analytics-base-schemas-DsUh5Q3C.js +0 -680
  150. package/dist/chunks/appearance-context-BwBp25ZG.js +0 -162
  151. package/dist/chunks/appearance-runtime-provider-BRHYELkC.js +0 -80
  152. package/dist/chunks/applied-constraints-DU-wndZ7.js +0 -47
  153. package/dist/chunks/assistant-chat-B6hNQI1t.js +0 -6115
  154. package/dist/chunks/attribution-BvoKvhcj.js +0 -32
  155. package/dist/chunks/availability-Bp5Gfu1I.js +0 -44
  156. package/dist/chunks/bookmark-impact-Ba2PLcGp.js +0 -76
  157. package/dist/chunks/bookmark-state-n7AaNzR_.js +0 -1667
  158. package/dist/chunks/brand-BoUV0iHF.js +0 -54
  159. package/dist/chunks/card-filter-builder-Y22HizVx.js +0 -4069
  160. package/dist/chunks/column-bands-RdM-kjDe.js +0 -47
  161. package/dist/chunks/comparison-window-caption-Ck2TIbnR.js +0 -741
  162. package/dist/chunks/context-UCQ7sere.js +0 -369
  163. package/dist/chunks/conversation-sQiWYUOb.js +0 -16
  164. package/dist/chunks/dashboard-BghI99oY.js +0 -14
  165. package/dist/chunks/dashboard-briefing-launcher-DtBAnGiH.js +0 -4875
  166. package/dist/chunks/dashboard-controls-CtFXlyjV.js +0 -2290
  167. package/dist/chunks/dashboard-json-DfGBUtCd.js +0 -66
  168. package/dist/chunks/dates-BnrXF4bb.js +0 -185
  169. package/dist/chunks/edit-9df1zOWe.js +0 -226
  170. package/dist/chunks/edit-dashboard-visual-oxt3x1wb.js +0 -18397
  171. package/dist/chunks/export-file-format-C-tJsxsf.js +0 -111
  172. package/dist/chunks/filter-line-Cy5YYqRL.js +0 -703
  173. package/dist/chunks/filter-reach-copy-CE_ZX147.js +0 -5111
  174. package/dist/chunks/filter-value-text-fWvSDwkl.js +0 -153
  175. package/dist/chunks/index-BVKzKl5d.js +0 -90
  176. package/dist/chunks/index-CV_Kzou0.js +0 -595
  177. package/dist/chunks/index-D5rxbtS4.js +0 -2795
  178. package/dist/chunks/layout-grid-9LndRoLa.js +0 -16
  179. package/dist/chunks/matrix-analytical-definition-CCp48UCw.js +0 -1233
  180. package/dist/chunks/matrix-member-presentation-zNehruXR.js +0 -391
  181. package/dist/chunks/matrix-operation-contract-DPBj69D8.js +0 -1413
  182. package/dist/chunks/metric-comparison-B0FR-Q8I.js +0 -600
  183. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +0 -119
  184. package/dist/chunks/paintbrush-58FQYY-y.js +0 -27
  185. package/dist/chunks/palette-Be62Tkoa.js +0 -23
  186. package/dist/chunks/pickers-DkqmtnTL.js +0 -2403
  187. package/dist/chunks/pivot-result-contract-expectations-BYqAmG9n.js +0 -5092
  188. package/dist/chunks/pivot-result-identity-CAP4--iq.js +0 -77
  189. package/dist/chunks/raw-temporal-value-Dg_MTFF7.js +0 -3778
  190. package/dist/chunks/rendered-file-D8xEuVVx.js +0 -108
  191. package/dist/chunks/report-preferences-dialog-uJp9GBTM.js +0 -1651
  192. package/dist/chunks/report-runtime-context-c77_KF9v.js +0 -388
  193. package/dist/chunks/resolve-dashboard-input-context-Rtl1ffmE.js +0 -25324
  194. package/dist/chunks/resolver-DG_tfEpt.js +0 -156
  195. package/dist/chunks/save-C5A0JnEV.js +0 -21
  196. package/dist/chunks/saved-dashboard-context-tcyTU8jm.js +0 -618
  197. package/dist/chunks/schema-C9NPiIru.js +0 -2568
  198. package/dist/chunks/selection-filter-compiler-DNijjI5y.js +0 -150
  199. package/dist/chunks/semaphor-ready-indicator-FBvunj6S.js +0 -145603
  200. package/dist/chunks/shelf-drop-preview-context-QKStrcK9.js +0 -2466
  201. package/dist/chunks/stored-dashboard-CHozcAY9.js +0 -4075
  202. package/dist/chunks/style-sheet-parts-CDCG-8Ej.js +0 -8681
  203. package/dist/chunks/table-export-sheet-ZFIvs6Sj.js +0 -949
  204. package/dist/chunks/token-types-XbM6QByy.js +0 -8
  205. package/dist/chunks/upload-H15d7uHK.js +0 -15
  206. package/dist/chunks/validators-Baf3VIf5.js +0 -3686
  207. package/dist/chunks/variable-draft-C2y8Jp6Z.js +0 -242
  208. package/dist/chunks/visual-choice-DDfHfHvY.js +0 -172
@@ -1,993 +1 @@
1
- import { PDF_NUMBER_COLUMN_TOO_WIDE as me } from "../pdf-export-policy/index.js";
2
- import { p as he, c as fe } from "../chunks/column-bands-RdM-kjDe.js";
3
- const pe = {
4
- letter: "Letter",
5
- legal: "Legal",
6
- tabloid: "Tabloid",
7
- ledger: "Ledger",
8
- a0: "A0",
9
- a1: "A1",
10
- a2: "A2",
11
- a3: "A3",
12
- a4: "A4",
13
- a5: "A5",
14
- a6: "A6"
15
- };
16
- function J(e) {
17
- if (!e) return "Letter";
18
- const t = pe[e.toLowerCase()];
19
- return t || (console.warn(`Unknown page size "${e}", defaulting to Letter`), "Letter");
20
- }
21
- const ge = 96, xe = 25.4, R = Object.freeze({
22
- marginsMm: Object.freeze({
23
- top: 8,
24
- right: 10,
25
- bottom: 12,
26
- left: 10
27
- }),
28
- printBodyPaddingMm: 0
29
- });
30
- function _(e) {
31
- return e === 0 ? "0" : `${e}mm`;
32
- }
33
- function st() {
34
- const { top: e, right: t, bottom: n, left: i } = R.marginsMm;
35
- return {
36
- top: _(e),
37
- right: _(t),
38
- bottom: _(n),
39
- left: _(i)
40
- };
41
- }
42
- function ot() {
43
- return _(R.printBodyPaddingMm);
44
- }
45
- function be() {
46
- const { left: e, right: t } = R.marginsMm;
47
- return (e + t + R.printBodyPaddingMm * 2) / xe * ge;
48
- }
49
- const re = Object.freeze({
50
- boolean: Object.freeze({ min: 52, max: 80 }),
51
- numeric: Object.freeze({ min: 56, max: 184 }),
52
- datetime: Object.freeze({ min: 82, max: 184 }),
53
- id: Object.freeze({ min: 72, max: 224 }),
54
- text: Object.freeze({ min: 76, max: 280 })
55
- }), H = Object.freeze({
56
- averageGlyphPx: 7.4,
57
- // 11pt tabular numerals, including semibold subtotal rows. Proportional
58
- // text metrics (especially the narrow '1') underestimate printed totals.
59
- tabularNumericGlyphPx: 9,
60
- horizontalPaddingPx: 18,
61
- measuredWidthHeadroom: 1.2,
62
- representativePercentile: 0.9
63
- });
64
- function D(e) {
65
- return e == null ? "" : String(e).replace(/\s+/g, " ").trim();
66
- }
67
- function ye(e, t = !1) {
68
- return Array.from(D(e)).reduce((n, i) => t && i >= "0" && i <= "9" ? n + 1 : /[ilI1.,'|]/.test(i) ? n + 0.5 : /[MW@%&#]/.test(i) ? n + 1.25 : /\s/.test(i) ? n + 0.55 : n + 1, 0);
69
- }
70
- function U(e, t = !1) {
71
- return ye(e, t) * (t ? H.tabularNumericGlyphPx : H.averageGlyphPx) + H.horizontalPaddingPx;
72
- }
73
- function Pe(e) {
74
- const t = D(e);
75
- if (!t) return 0;
76
- const i = t.split(/\s+/).filter(Boolean).reduce(
77
- (a, u) => Math.max(a, U(u)),
78
- 0
79
- ), s = U(t) * 0.72;
80
- return Math.max(i, s);
81
- }
82
- function we(e, t) {
83
- if (e.length === 0) return 0;
84
- const n = [...e].sort((s, a) => s - a), i = Math.max(0, Math.ceil(t * n.length) - 1);
85
- return n[Math.min(i, n.length - 1)];
86
- }
87
- function Ne(e, t) {
88
- const n = t.map(D).filter(Boolean).map((i) => U(i, e === "numeric"));
89
- return n.length === 0 ? 0 : e === "numeric" || e === "boolean" ? Math.max(...n) : we(n, H.representativePercentile);
90
- }
91
- function F(e) {
92
- return re[e] || re.text;
93
- }
94
- function Ce({
95
- type: e = "text",
96
- label: t = "",
97
- sampleValues: n = [],
98
- grandTotalValue: i = "",
99
- measuredWidthPx: s = null,
100
- declaredNumeric: a = !1
101
- } = {}) {
102
- const u = F(e), r = [...n, i], l = Ne(e, r), o = Math.max(
103
- u.min,
104
- Pe(t),
105
- l
106
- ), c = Number(s), d = r.some((h) => D(h)), y = Number.isFinite(c) && c > 0 ? d ? Math.min(c, o * H.measuredWidthHeadroom) : c : 0, g = Math.max(o, y), m = Math.min(u.max, Math.max(u.min, g));
107
- return a ? Math.max(l, m) : m;
108
- }
109
- function W(e) {
110
- return e == null ? "" : String(e);
111
- }
112
- function X(e = {}) {
113
- return {
114
- text: W(e.text),
115
- colspan: 1,
116
- rowspan: 1,
117
- className: e.className || "",
118
- columnId: e.columnId || null,
119
- isHeader: !!e.isHeader,
120
- ...typeof e.isNumeric == "boolean" ? { isNumeric: e.isNumeric } : {},
121
- ...typeof e.pdfIsNumeric == "boolean" ? { pdfIsNumeric: e.pdfIsNumeric } : {},
122
- measuredWidthPx: Number(e.measuredWidthPx) || null
123
- };
124
- }
125
- function Ie(e = []) {
126
- return Array.isArray(e) ? e.map((t) => Array.isArray(t) ? t : Array.isArray(t == null ? void 0 : t.cells) ? t.cells : []) : [];
127
- }
128
- function Ae(e, t) {
129
- const n = String(e || "").split(/\s+/).map((i) => i.trim()).filter(Boolean);
130
- return n.includes(t) || n.push(t), n.join(" ");
131
- }
132
- function Se(e) {
133
- return String(e || "").split(/\s+/).map((t) => t.trim()).filter(
134
- (t) => t && t !== "numeric" && t !== "text-right" && t !== "text-end"
135
- ).join(" ");
136
- }
137
- function We(e = []) {
138
- return new Map(
139
- e.map((t, n) => [t == null ? void 0 : t.columnId, n]).filter(([t]) => t)
140
- );
141
- }
142
- function K(e = {}, t = null) {
143
- if (typeof e.pdfIsNumeric == "boolean")
144
- return e.pdfIsNumeric;
145
- if (typeof (t == null ? void 0 : t.isNumeric) == "boolean")
146
- return t.isNumeric;
147
- if (typeof e.isNumeric == "boolean")
148
- return e.isNumeric;
149
- }
150
- function B(e = {}, t = null) {
151
- const n = !!(t != null && t.isNumeric), i = Se(e.className);
152
- return {
153
- ...e,
154
- className: n ? Ae(i, "numeric") : i,
155
- isNumeric: n
156
- };
157
- }
158
- function ie(e = null, t = null) {
159
- return B(
160
- {
161
- text: "",
162
- colspan: 1,
163
- rowspan: 1,
164
- className: (t == null ? void 0 : t.className) || "",
165
- columnId: (e == null ? void 0 : e.columnId) || null,
166
- isHeader: !!(t != null && t.isHeader)
167
- },
168
- e
169
- );
170
- }
171
- function ve(e = [], t = []) {
172
- const n = Array.from(
173
- { length: t.length },
174
- () => null
175
- ), i = We(t);
176
- return e.map((s = {}) => {
177
- const a = n.map((o) => !!(o != null && o.remaining)), u = [];
178
- let r = 0;
179
- const l = (o) => {
180
- for (; r < o && r < t.length; )
181
- u.push(
182
- ie(t[r], n[r])
183
- ), r += 1;
184
- };
185
- return (s.cells || []).forEach((o = {}) => {
186
- for (; r < t.length && a[r]; )
187
- u.push(
188
- ie(t[r], n[r])
189
- ), r += 1;
190
- const c = o.columnId ? i.get(o.columnId) : void 0, d = Math.max(r, c ?? r);
191
- l(d);
192
- const y = Math.max(1, Number(o.colspan || 1)), g = Math.max(1, Number(o.rowspan || 1)), m = {
193
- ...o,
194
- colspan: y,
195
- rowspan: 1
196
- };
197
- if (u.push(
198
- y > 1 || !t[d] ? B(m, { isNumeric: !1 }) : B(
199
- m,
200
- t[d]
201
- )
202
- ), g > 1)
203
- for (let h = 0; h < y; h += 1) {
204
- const f = d + h;
205
- f < n.length && (n[f] = {
206
- remaining: g - 1,
207
- className: o.className || "",
208
- isHeader: !!o.isHeader
209
- });
210
- }
211
- r = d + y;
212
- }), l(t.length), n.forEach((o, c) => {
213
- !a[c] || !(o != null && o.remaining) || (o.remaining -= 1, o.remaining <= 0 && (n[c] = null));
214
- }), {
215
- ...s,
216
- cells: u
217
- };
218
- });
219
- }
220
- function Le(e = []) {
221
- const t = Ie(e);
222
- if (t.length === 0)
223
- return {
224
- headerRows: [],
225
- rowSources: [],
226
- matrix: [],
227
- placements: [],
228
- leafCells: []
229
- };
230
- const n = t.length, i = e.map(
231
- (o) => Array.isArray(o) ? {} : o || {}
232
- ), s = Array.from(
233
- { length: n },
234
- () => []
235
- ), a = [];
236
- t.forEach((o, c) => {
237
- let d = 0;
238
- o.forEach((y = {}, g) => {
239
- for (; s[c][d] !== void 0; )
240
- d += 1;
241
- const m = Math.max(1, Number(y.colspan || 1)), h = Math.max(1, Number(y.rowspan || 1)), f = {
242
- id: `${c}:${g}`,
243
- rowIndex: c,
244
- startCol: d,
245
- endCol: d + m - 1,
246
- colspan: m,
247
- rowspan: h,
248
- cell: X(y),
249
- hasChildHeaders: !1
250
- };
251
- a.push(f);
252
- for (let S = 0; S < h; S += 1) {
253
- const N = c + S;
254
- if (N >= n) break;
255
- for (let b = 0; b < m; b += 1) {
256
- const P = d + b;
257
- s[N][P] === void 0 && (s[N][P] = f);
258
- }
259
- }
260
- d += m;
261
- });
262
- }), a.forEach((o) => {
263
- o.hasChildHeaders = a.some(
264
- (c) => c.rowIndex > o.rowIndex && c.startCol <= o.endCol && c.endCol >= o.startCol
265
- );
266
- });
267
- const u = n - 1, r = s.reduce((o, c) => Math.max(o, c.length), 0), l = Array.from({ length: r }, (o, c) => {
268
- let d = null;
269
- for (let f = u; f >= 0; f -= 1)
270
- if (s[f][c]) {
271
- d = s[f][c];
272
- break;
273
- }
274
- if (!d) return X();
275
- const y = c - d.startCol, g = d.colspan === 1 || !d.hasChildHeaders, m = d.cell, h = g && Number.isFinite(m.measuredWidthPx) && m.measuredWidthPx > 0 ? m.measuredWidthPx / d.colspan : null;
276
- return {
277
- text: m.text,
278
- colspan: 1,
279
- rowspan: 1,
280
- className: m.className,
281
- columnId: g && y === 0 ? m.columnId : null,
282
- isHeader: m.isHeader,
283
- ...g && typeof m.isNumeric == "boolean" ? { isNumeric: m.isNumeric } : {},
284
- ...g && typeof m.pdfIsNumeric == "boolean" ? { pdfIsNumeric: m.pdfIsNumeric } : {},
285
- measuredWidthPx: h
286
- };
287
- });
288
- return { headerRows: t, rowSources: i, matrix: s, placements: a, leafCells: l };
289
- }
290
- function $() {
291
- return {
292
- text: "",
293
- colspan: 1,
294
- rowspan: 1,
295
- className: "",
296
- columnId: null,
297
- isHeader: !1,
298
- measuredWidthPx: null
299
- };
300
- }
301
- function G(e = {}, t = {}) {
302
- return {
303
- text: W(e.text),
304
- colspan: 1,
305
- rowspan: 1,
306
- className: e.className || "",
307
- columnId: e.columnId || null,
308
- isHeader: !!e.isHeader,
309
- ...typeof e.isNumeric == "boolean" ? { isNumeric: e.isNumeric } : {},
310
- ...typeof e.pdfIsNumeric == "boolean" ? { pdfIsNumeric: e.pdfIsNumeric } : {},
311
- measuredWidthPx: Number(e.measuredWidthPx) || null,
312
- ...t
313
- };
314
- }
315
- function se(e = []) {
316
- return e.reduce(
317
- (t, n) => t + Math.max(1, Number((n == null ? void 0 : n.colspan) || 1)),
318
- 0
319
- );
320
- }
321
- function Be(e = [], t = 0) {
322
- const n = Array.from({ length: t }, () => 0);
323
- return e.map((i = {}) => {
324
- const s = Array.from(
325
- { length: t },
326
- () => null
327
- );
328
- let a = 0;
329
- const u = () => {
330
- for (; a < t && n[a] > 0; )
331
- s[a] = $(), n[a] -= 1, a += 1;
332
- };
333
- for (u(), (i.cells || []).forEach((r = {}) => {
334
- if (u(), a >= t) return;
335
- const l = Math.max(1, Number(r.colspan || 1)), o = Math.max(1, Number(r.rowspan || 1));
336
- for (let c = 0; c < l; c += 1) {
337
- const d = a + c;
338
- if (d >= t) break;
339
- s[d] = c === 0 ? G(r) : G(r, {
340
- text: "",
341
- columnId: null,
342
- measuredWidthPx: null
343
- }), o > 1 && (n[d] = Math.max(
344
- n[d],
345
- o - 1
346
- ));
347
- }
348
- a += l;
349
- }); a < t; )
350
- n[a] > 0 && (n[a] -= 1), s[a] = s[a] || $(), a += 1;
351
- return s.map((r) => r || $());
352
- });
353
- }
354
- function Me(e = null, t = 0) {
355
- if (!e) return null;
356
- const n = [];
357
- for ((e.cells || []).forEach((i = {}) => {
358
- const s = Math.max(1, Number(i.colspan || 1));
359
- n.push(G(i));
360
- for (let a = 1; a < s; a += 1)
361
- n.push(
362
- G(i, {
363
- text: "",
364
- columnId: null,
365
- measuredWidthPx: null
366
- })
367
- );
368
- }); n.length < t; ) n.push($());
369
- return n.slice(0, t);
370
- }
371
- function Te(e) {
372
- const t = W(e).trim().toLowerCase();
373
- return t ? ["-", "—", "–", "n/a", "na", "null", "none"].includes(t) : !0;
374
- }
375
- function ze(e) {
376
- const t = W(e).trim().toLowerCase();
377
- return ["true", "false", "yes", "no", "y", "n", "on", "off"].includes(
378
- t
379
- );
380
- }
381
- function Ee(e) {
382
- const t = W(e).trim();
383
- return t ? /^\d{4}-\d{2}-\d{2}/.test(t) || /^\d{1,2}\/\d{1,2}\/\d{2,4}/.test(t) || /^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}/.test(t) : !1;
384
- }
385
- function _e(e) {
386
- const t = W(e).trim();
387
- return !!(t && !t.includes(" ") && /^[a-z0-9_.:-]{8,}$/i.test(t));
388
- }
389
- function He(e) {
390
- if (typeof e == "number") return !0;
391
- const t = W(e).trim().replace(/^\((.*)\)$/, "-$1").replace(/[$,%\s]/g, "").replace(/,/g, "");
392
- return !!(t && /^-?\d+(\.\d+)?$/.test(t));
393
- }
394
- function ke(e) {
395
- const t = W(e).trim().replace(/^\((.*)\)$/, "-$1").replace(/[$%\s]/g, "");
396
- return !!(t && /^-?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?$/.test(t));
397
- }
398
- function je(e) {
399
- const t = W(e).trim();
400
- if (!t.includes(",")) return !1;
401
- const n = t.split(",").map((i) => i.trim()).filter(Boolean);
402
- return n.length < 2 || !n.every((i) => /^[a-z0-9_.:/-]+$/i.test(i)) ? !1 : /,\s+/.test(t) ? !0 : ke(t) ? !1 : n.some((i) => !/^\d+$/.test(i));
403
- }
404
- function Oe(e, t, n) {
405
- return Array.isArray(e) && (e.find(
406
- (s) => (s == null ? void 0 : s.columnId) && s.columnId === t
407
- ) || e[n]) || null;
408
- }
409
- function $e(e, t, n) {
410
- const i = K(e, t);
411
- if (typeof i == "boolean")
412
- return i ? "numeric" : "text";
413
- const s = n.filter((a) => !Te(a));
414
- return s.length === 0 || s.some((a) => je(a)) ? "text" : s.filter(He).length / s.length >= 0.8 ? "numeric" : s.filter(ze).length / s.length >= 0.8 ? "boolean" : s.filter(Ee).length / s.length >= 0.7 ? "datetime" : s.filter(_e).length / s.length >= 0.7 ? "id" : "text";
415
- }
416
- function oe(e) {
417
- return W(e == null ? void 0 : e.text).trim().length > 0;
418
- }
419
- function Re(e = []) {
420
- return [
421
- {
422
- cells: e.map(
423
- (t) => B(
424
- {
425
- text: t.label,
426
- colspan: 1,
427
- rowspan: 1,
428
- className: "",
429
- columnId: t.columnId,
430
- isHeader: !0
431
- },
432
- t
433
- )
434
- )
435
- }
436
- ];
437
- }
438
- function Fe(e, t, n) {
439
- if (!e.headerRows.length || !t.length) return null;
440
- const i = new Map(
441
- t.map((r, l) => [r, l])
442
- ), s = new Map(
443
- n.map((r) => [r.sourceIndex, r])
444
- );
445
- if (!t.every(
446
- (r) => e.matrix.every((l) => !!l[r])
447
- )) return null;
448
- const u = e.rowSources.map((r, l) => ({
449
- ...r,
450
- cells: [],
451
- __rowIndex: l
452
- }));
453
- for (const r of e.placements) {
454
- const l = t.filter(
455
- (h) => h >= r.startCol && h <= r.endCol
456
- ).map((h) => i.get(h));
457
- if (l.length === 0) continue;
458
- for (let h = 1; h < l.length; h += 1)
459
- if (l[h] !== l[h - 1] + 1) return null;
460
- const o = t.filter(
461
- (h) => h >= r.startCol && h <= r.endCol
462
- ).map((h) => s.get(h)).filter((h) => !!h), c = r.colspan === 1 && !r.hasChildHeaders && o.length === 1, y = r.colspan > 1 && !r.hasChildHeaders && o.length > 0 && o.every(
463
- (h) => h.isNumeric === o[0].isNumeric
464
- ), g = r.cell, m = {
465
- text: g.text,
466
- colspan: l.length,
467
- rowspan: r.rowspan,
468
- className: g.className,
469
- columnId: c ? g.columnId : null,
470
- isHeader: !0,
471
- measuredWidthPx: null,
472
- __sortIndex: l[0]
473
- };
474
- u[r.rowIndex].cells.push(
475
- c || y ? B(m, o[0]) : B(m, { isNumeric: !1 })
476
- );
477
- }
478
- return u.map(({ __rowIndex: r, ...l }) => ({
479
- ...l,
480
- cells: l.cells.sort((o, c) => o.__sortIndex - c.__sortIndex).map(({ __sortIndex: o, ...c }) => c)
481
- }));
482
- }
483
- function ae(e = {}) {
484
- return {
485
- text: W(e.text),
486
- colspan: 1,
487
- rowspan: 1,
488
- className: e.className || "",
489
- columnId: e.columnId || null,
490
- isHeader: !!e.isHeader,
491
- ...typeof e.isNumeric == "boolean" ? { isNumeric: e.isNumeric } : {}
492
- };
493
- }
494
- function ce(e = {}) {
495
- return String(e.tableType || "").toLowerCase() === "pivot" || e.pivotLevels !== void 0 || e.rowLevels !== void 0;
496
- }
497
- function Ge(e) {
498
- const t = Number(e);
499
- return Number.isFinite(t) ? Math.max(0, Math.trunc(t)) : 0;
500
- }
501
- function De(e, t, n, i) {
502
- if (!ce(e)) return 0;
503
- const s = Ge(e.rowLevels);
504
- if (s > 0) return Math.min(s, i.length);
505
- const a = t.find(
506
- (l) => String((l == null ? void 0 : l.type) || "data").toLowerCase() === "data" && Array.isArray(l == null ? void 0 : l.cells)
507
- );
508
- if (a) {
509
- const l = a.cells, o = l.some(
510
- (d) => !!(d != null && d.isHeader)
511
- );
512
- let c = 0;
513
- for (const d of l) {
514
- if (!(d != null && d.isHeader)) break;
515
- c += Math.max(1, Number(d.colspan || 1));
516
- }
517
- if (c > 0 || o)
518
- return Math.min(c, i.length);
519
- }
520
- const u = n.placements.filter((l) => l.rowIndex === 0).sort((l, o) => l.startCol - o.startCol);
521
- let r = 0;
522
- for (const l of u) {
523
- if (l.startCol !== r) break;
524
- const o = /^rowLevel\d+$/i.test(
525
- String(l.cell.columnId || "")
526
- ), d = n.headerRows.length > 1 && l.rowspan >= n.headerRows.length && i.slice(l.startCol, l.endCol + 1).every((y) => !(y != null && y.isNumeric));
527
- if (!o && !d) break;
528
- r += l.colspan;
529
- }
530
- if (r === 0 && u.length > 0) {
531
- const l = u[0];
532
- if (l.colspan > 1 && l.rowspan < Math.max(1, n.headerRows.length) && n.leafCells.slice(l.startCol, l.endCol + 1).every((c) => K(c) !== !0))
533
- return Math.min(l.colspan, i.length);
534
- }
535
- return Math.min(r, i.length);
536
- }
537
- function Ve(e = {}, t = {}) {
538
- const n = Array.isArray(e.headers) ? e.headers : [], i = Array.isArray(e.rows) ? e.rows : [], s = e.metadata || {}, a = Le(n), u = Math.max(
539
- a.leafCells.length,
540
- Number(s.totalColumns || 0),
541
- ...i.map((p) => se((p == null ? void 0 : p.cells) || [])),
542
- e.grandTotal ? se(e.grandTotal.cells || []) : 0
543
- ), r = Be(i, u), l = r.filter(
544
- (p, x) => {
545
- var C;
546
- return x < 50 || ((C = i[x]) == null ? void 0 : C.type) === "subtotal";
547
- }
548
- ), o = Me(
549
- e.grandTotal,
550
- u
551
- ), c = Array.isArray(s.columns) ? s.columns : [], d = Array.from(
552
- { length: u },
553
- (p, x) => {
554
- var te, ne;
555
- const C = a.leafCells[x] || X(), A = (te = r.find((E) => {
556
- var M;
557
- return (M = E[x]) == null ? void 0 : M.columnId;
558
- })) == null ? void 0 : te[x], I = Oe(
559
- c,
560
- C.columnId || (A == null ? void 0 : A.columnId),
561
- x
562
- ), V = C.columnId || (I == null ? void 0 : I.columnId) || (A == null ? void 0 : A.columnId) || `col_${x + 1}`, k = W(C.text) || W(I == null ? void 0 : I.label) || `Column ${x + 1}`, j = l.map(
563
- (E) => {
564
- var M;
565
- return ((M = E[x]) == null ? void 0 : M.text) ?? "";
566
- }
567
- ), v = ((ne = o == null ? void 0 : o[x]) == null ? void 0 : ne.text) ?? "", T = $e(C, I, [
568
- ...j,
569
- v
570
- ]), z = K(C, I) === !0, O = F(T).min, de = Number.isFinite(I == null ? void 0 : I.measuredWidthPx) ? Number(I == null ? void 0 : I.measuredWidthPx) : Number.isFinite(C.measuredWidthPx) ? Number(C.measuredWidthPx) : null, ee = Ce({
571
- type: T,
572
- label: k,
573
- sampleValues: z ? r.map((E) => {
574
- var M;
575
- return ((M = E[x]) == null ? void 0 : M.text) ?? "";
576
- }) : j,
577
- grandTotalValue: v,
578
- measuredWidthPx: de,
579
- declaredNumeric: z
580
- });
581
- return {
582
- index: x,
583
- sourceIndex: x,
584
- columnId: V,
585
- label: k,
586
- type: T,
587
- minWidthPx: T === "numeric" ? ee : O,
588
- widthPx: ee,
589
- isNumeric: T === "numeric",
590
- declaredNumeric: z
591
- };
592
- }
593
- ), y = ce(s), g = De(
594
- s,
595
- i,
596
- a,
597
- d
598
- ), h = t.suppressEmptyColumns !== !1 && String(s.tableType || "").toLowerCase() === "data" && (r.length > 0 || o) ? d.filter((p) => {
599
- const x = p.sourceIndex;
600
- return r.some((C) => oe(C[x])) || oe(o == null ? void 0 : o[x]);
601
- }).map((p) => p.sourceIndex) : d.map((p) => p.sourceIndex);
602
- h.length === 0 && d.length > 0 && h.push(d[0].sourceIndex);
603
- const f = new Set(h), S = d.filter((p) => !f.has(p.sourceIndex)).map((p) => ({ columnId: p.columnId, label: p.label })), N = h.map((p, x) => ({
604
- ...d[p],
605
- index: x
606
- })), b = N.map((p) => p.index), P = S.length === 0;
607
- return {
608
- columns: N,
609
- hiddenEmptyColumns: S,
610
- isPivotTable: y,
611
- pivotAnchorCount: g,
612
- project: (p = b, { preserveHeaderHierarchy: x = !0, preserveBodySpans: C = !1 } = {}) => {
613
- const A = p.map((v) => N[v]).filter(Boolean), I = A.map((v) => v.sourceIndex), V = x ? Fe(a, I, A) : null, k = C && P && A.length === N.length ? ve(i, d) : i.map((v, T) => ({
614
- ...v,
615
- cells: A.map(
616
- (z) => {
617
- var O;
618
- return B(
619
- ae((O = r[T]) == null ? void 0 : O[z.sourceIndex]),
620
- z
621
- );
622
- }
623
- )
624
- })), j = o ? {
625
- ...e.grandTotal || {},
626
- cells: A.map(
627
- (v) => B(
628
- ae(o[v.sourceIndex]),
629
- v
630
- )
631
- )
632
- } : null;
633
- return {
634
- headers: V || Re(A),
635
- rows: k,
636
- grandTotal: j,
637
- columns: A
638
- };
639
- }
640
- };
641
- }
642
- function Y() {
643
- const e = new Error(
644
- "Numeric values cannot fit this PDF layout without clipping. Use horizontal pagination, narrow the export or use CSV."
645
- );
646
- return e.code = me, e.deliveryBlocking = !0, e;
647
- }
648
- const w = 96, le = {
649
- Letter: { width: 8.5 * w, height: 11 * w },
650
- Legal: { width: 8.5 * w, height: 14 * w },
651
- Tabloid: { width: 11 * w, height: 17 * w },
652
- Ledger: { width: 17 * w, height: 11 * w },
653
- A0: { width: 841 / 25.4 * w, height: 1189 / 25.4 * w },
654
- A1: { width: 594 / 25.4 * w, height: 841 / 25.4 * w },
655
- A2: { width: 420 / 25.4 * w, height: 594 / 25.4 * w },
656
- A3: { width: 297 / 25.4 * w, height: 420 / 25.4 * w },
657
- A4: { width: 210 / 25.4 * w, height: 297 / 25.4 * w },
658
- A5: { width: 148 / 25.4 * w, height: 210 / 25.4 * w },
659
- A6: { width: 105 / 25.4 * w, height: 148 / 25.4 * w }
660
- }, q = ["Letter", "Legal", "A3", "Tabloid"], qe = /* @__PURE__ */ new Set([
661
- "auto",
662
- "fit",
663
- "horizontal_paginate"
664
- ]);
665
- function Q(e) {
666
- return String(e || "portrait").toLowerCase() === "landscape" ? "landscape" : "portrait";
667
- }
668
- function Ue(e, t) {
669
- const n = J(e || "Letter"), i = le[n] || le.Letter, s = Q(t);
670
- return s === "landscape" ? {
671
- pageSize: n,
672
- orientation: s,
673
- width: i.height,
674
- height: i.width
675
- } : {
676
- pageSize: n,
677
- orientation: s,
678
- width: i.width,
679
- height: i.height
680
- };
681
- }
682
- function Xe(e, t) {
683
- const n = Ue(e, t);
684
- return Math.max(200, n.width - be() - 8);
685
- }
686
- function Ye(e, t) {
687
- const n = J(e || "Letter"), i = Q(t), s = [], a = (r, l) => {
688
- s.find(
689
- (c) => c.pageSize === r && c.orientation === l
690
- ) || s.push({
691
- pageSize: r,
692
- orientation: l,
693
- printableWidthPx: Xe(r, l)
694
- });
695
- };
696
- a(n, i), a(
697
- n,
698
- i === "portrait" ? "landscape" : "portrait"
699
- );
700
- const u = Math.max(0, q.indexOf(n));
701
- for (let r = u; r < q.length; r += 1)
702
- a(q[r], "landscape");
703
- return s;
704
- }
705
- function ue(e = []) {
706
- return !Array.isArray(e) || e.length === 0 ? null : e.reduce((t, n) => t ? n.printableWidthPx > t.printableWidthPx ? n : t : n, null);
707
- }
708
- function Z(e, t = "widthPx") {
709
- return e.reduce(
710
- (n, i) => n + (Number(i == null ? void 0 : i[t]) || 0),
711
- 0
712
- );
713
- }
714
- function Ze(e, t) {
715
- const n = Z(e);
716
- if (n <= t)
717
- return e.map((u) => u.widthPx);
718
- const i = Z(e, "minWidthPx");
719
- if (i >= t)
720
- return e.map((u) => u.minWidthPx);
721
- const s = n - t, a = n - i;
722
- return e.map((u) => {
723
- const r = Math.max(0, u.widthPx - u.minWidthPx), l = s * (r / a);
724
- return Math.max(u.minWidthPx, u.widthPx - l);
725
- });
726
- }
727
- function Je(e, t) {
728
- const n = t * 0.35, i = [];
729
- let s = 0;
730
- for (const a of e) {
731
- if (i.length >= 2) break;
732
- a.isNumeric || s + a.widthPx > n && i.length > 0 || (i.push(a.index), s += a.widthPx);
733
- }
734
- return i.length === 0 && e.length > 0 && i.push(e[0].index), i;
735
- }
736
- function Ke(e, t, n = 0) {
737
- if (e.some(
738
- (f) => f.declaredNumeric && f.widthPx > t
739
- ))
740
- throw Y();
741
- const i = F("text").min, s = n > 0, a = s ? e.slice(0, n).map((f) => f.index) : [];
742
- let u = s ? [...a] : Je(e, t);
743
- const r = (f) => f.reduce((S, N) => {
744
- var b;
745
- return S + (((b = e[N]) == null ? void 0 : b.widthPx) || 0);
746
- }, 0), l = () => e.map((f) => f.index).filter((f) => !(u.includes(f) || s && a.includes(f)));
747
- let o = l();
748
- if (o.length > 0) {
749
- let f = r(u);
750
- if (s)
751
- for (; u.length > 1 && t - f < i; )
752
- u = u.slice(0, -1), f = r(u);
753
- for (; !s && u.length > 0 && t - f < i; )
754
- u = u.slice(0, -1), f = r(u);
755
- o = l();
756
- }
757
- const c = r(u), d = Math.max(40, t - c), y = {}, g = [];
758
- let m = [], h = 0;
759
- return o.forEach((f) => {
760
- var b, P;
761
- const S = ((b = e[f]) == null ? void 0 : b.widthPx) || F("text").min;
762
- if ((P = e[f]) != null && P.declaredNumeric && S > d)
763
- throw Y();
764
- const N = Math.min(S, d);
765
- if (y[f] = N, m.length > 0 && h + N > d) {
766
- g.push(m), m = [f], h = N;
767
- return;
768
- }
769
- m.push(f), h += N;
770
- }), m.length > 0 && g.push(m), g.length === 0 && g.push([]), {
771
- anchorIndices: u,
772
- bands: g,
773
- dynamicWidthByIndex: y
774
- };
775
- }
776
- function Qe(e, t, n) {
777
- const { columnGroups: i, groupLabels: s, groupLevelLabel: a } = e.metadata ?? {};
778
- if (!Array.isArray(i) || !Array.isArray(s) || typeof a != "string")
779
- return null;
780
- const u = (o) => {
781
- const c = i[o.sourceIndex];
782
- return typeof c == "number" ? c : null;
783
- }, r = he({
784
- columns: t.map((o) => ({
785
- widthPx: o.widthPx,
786
- group: u(o)
787
- })),
788
- printableWidthPx: n,
789
- maxBands: Number.POSITIVE_INFINITY
790
- });
791
- if (r.kind === "too_wide") return null;
792
- const l = t.filter((o) => u(o) === null).map((o) => o.index);
793
- return r.kind === "fits" ? {
794
- anchorIndices: l,
795
- bands: [{ columns: t.map((o) => o.index), caption: null }]
796
- } : {
797
- anchorIndices: l,
798
- bands: r.bands.map((o) => ({
799
- columns: o.columns,
800
- caption: fe({
801
- groupLevelLabel: a,
802
- groupLabels: s.map(String),
803
- firstGroup: o.firstGroup,
804
- lastGroup: o.lastGroup
805
- })
806
- }))
807
- };
808
- }
809
- function et(e = [], t = 0) {
810
- const n = [...new Set(e)].filter((u) => Number.isInteger(u) && u >= 0).sort((u, r) => u - r);
811
- if (n.length === 0) {
812
- const u = Math.max(1, Number(t) || 1);
813
- return `Columns 1-${u} of ${u}`;
814
- }
815
- const i = [];
816
- let s = n[0], a = n[0];
817
- for (let u = 1; u < n.length; u += 1) {
818
- const r = n[u];
819
- if (r === a + 1) {
820
- a = r;
821
- continue;
822
- }
823
- i.push(
824
- s === a ? `${s + 1}` : `${s + 1}-${a + 1}`
825
- ), s = r, a = r;
826
- }
827
- return i.push(
828
- s === a ? `${s + 1}` : `${s + 1}-${a + 1}`
829
- ), `Columns ${i.join(", ")} of ${Math.max(1, Number(t) || 1)}`;
830
- }
831
- function tt(e, t, n = {}) {
832
- return t.map((i) => {
833
- const s = e[i], a = Number(n[i]), u = Number.isFinite(a) && a > 0 ? a : s.widthPx;
834
- return {
835
- columnId: s.columnId,
836
- label: s.label,
837
- widthPx: u,
838
- isNumeric: s.isNumeric
839
- };
840
- });
841
- }
842
- function at(e, t = {}) {
843
- const n = J(t.pageSize || "Letter"), i = Q(
844
- t.orientation || "portrait"
845
- ), s = String(t.wideTableStrategy || "auto"), a = qe.has(s) ? s : "auto", u = Ve(e, t), { columns: r, hiddenEmptyColumns: l, isPivotTable: o, pivotAnchorCount: c } = u, d = Z(r, "minWidthPx"), y = Ye(
846
- n,
847
- i
848
- );
849
- let g = y.find(
850
- (b) => d <= b.printableWidthPx
851
- );
852
- if (a === "fit" && !g && (g = ue(y), r.some(
853
- (b) => b.declaredNumeric && b.widthPx > g.printableWidthPx
854
- )))
855
- throw Y();
856
- if (g && a !== "horizontal_paginate") {
857
- const b = Ze(r, g.printableWidthPx), P = r.map((x) => x.index), L = l.length > 0, p = u.project(P, {
858
- preserveHeaderHierarchy: !L,
859
- preserveBodySpans: !L
860
- });
861
- return {
862
- sections: [
863
- {
864
- headers: p.headers,
865
- rows: p.rows,
866
- grandTotal: p.grandTotal,
867
- bandLabel: null,
868
- columns: r.map((x, C) => ({
869
- columnId: x.columnId,
870
- label: x.label,
871
- widthPx: b[C],
872
- isNumeric: x.isNumeric
873
- }))
874
- }
875
- ],
876
- layoutApplied: {
877
- requestedPageSize: n,
878
- requestedOrientation: i,
879
- effectivePageSize: g.pageSize,
880
- effectiveOrientation: g.orientation,
881
- usedBanding: !1,
882
- bandCount: 1,
883
- totalColumns: r.length,
884
- anchorColumns: [],
885
- autoAdjustedLayout: g.pageSize !== n || g.orientation !== i,
886
- strategyApplied: "fit",
887
- hiddenEmptyColumnCount: l.length,
888
- hiddenEmptyColumns: l.map((x) => x.label)
889
- }
890
- };
891
- }
892
- const m = g || ue(y), h = Qe(
893
- e,
894
- r,
895
- m.printableWidthPx
896
- );
897
- if (h) {
898
- const b = h.bands.map((P) => {
899
- const L = u.project(P.columns, {
900
- preserveHeaderHierarchy: o,
901
- preserveBodySpans: !1
902
- });
903
- return {
904
- headers: L.headers,
905
- rows: L.rows,
906
- grandTotal: L.grandTotal,
907
- bandLabel: P.caption,
908
- columns: P.columns.map((p) => ({
909
- columnId: r[p].columnId,
910
- label: r[p].label,
911
- widthPx: r[p].widthPx,
912
- isNumeric: r[p].isNumeric
913
- }))
914
- };
915
- });
916
- return {
917
- sections: b,
918
- layoutApplied: {
919
- requestedPageSize: n,
920
- requestedOrientation: i,
921
- effectivePageSize: m.pageSize,
922
- effectiveOrientation: m.orientation,
923
- usedBanding: b.length > 1,
924
- bandCount: b.length,
925
- totalColumns: r.length,
926
- anchorColumns: h.anchorIndices.map(
927
- (P) => r[P].label
928
- ),
929
- autoAdjustedLayout: m.pageSize !== n || m.orientation !== i,
930
- strategyApplied: "horizontal_paginate",
931
- hiddenEmptyColumnCount: l.length,
932
- hiddenEmptyColumns: l.map((P) => P.label)
933
- }
934
- };
935
- }
936
- const f = Ke(
937
- r,
938
- m.printableWidthPx,
939
- c
940
- ), S = f.anchorIndices.map((b) => {
941
- var P;
942
- return (P = r[b]) == null ? void 0 : P.label;
943
- }).filter(Boolean), N = f.bands.map((b) => {
944
- const P = [...f.anchorIndices, ...b], L = tt(
945
- r,
946
- P,
947
- f.dynamicWidthByIndex
948
- ), p = u.project(P, {
949
- preserveHeaderHierarchy: o,
950
- preserveBodySpans: !1
951
- }), x = et(
952
- P,
953
- r.length
954
- );
955
- return {
956
- headers: p.headers,
957
- rows: p.rows,
958
- grandTotal: p.grandTotal,
959
- bandLabel: x,
960
- columns: L
961
- };
962
- });
963
- return {
964
- sections: N,
965
- layoutApplied: {
966
- requestedPageSize: n,
967
- requestedOrientation: i,
968
- effectivePageSize: m.pageSize,
969
- effectiveOrientation: m.orientation,
970
- usedBanding: !0,
971
- bandCount: N.length,
972
- totalColumns: r.length,
973
- anchorColumns: S,
974
- autoAdjustedLayout: m.pageSize !== n || m.orientation !== i,
975
- strategyApplied: "horizontal_paginate",
976
- hiddenEmptyColumnCount: l.length,
977
- hiddenEmptyColumns: l.map((b) => b.label)
978
- }
979
- };
980
- }
981
- export {
982
- R as TABLE_PAGE_GEOMETRY,
983
- Ve as buildPdfTableModel,
984
- at as buildWideTableLayout,
985
- fe as columnBandCaption,
986
- Ce as estimateColumnWidthPx,
987
- F as getColumnWidthBounds,
988
- be as getTableHorizontalInsetPx,
989
- st as getTablePdfMargins,
990
- ot as getTablePrintBodyPaddingCss,
991
- J as normalizePageSize,
992
- he as planColumnBands
993
- };
1
+ import{PDF_NUMBER_COLUMN_TOO_WIDE as me}from"../pdf-export-policy/index.js";import{p as he,c as fe}from"../chunks/column-bands-DwxbZ6UI.js";const pe={letter:"Letter",legal:"Legal",tabloid:"Tabloid",ledger:"Ledger",a0:"A0",a1:"A1",a2:"A2",a3:"A3",a4:"A4",a5:"A5",a6:"A6"};function J(e){if(!e)return"Letter";const t=pe[e.toLowerCase()];return t||(console.warn(`Unknown page size "${e}", defaulting to Letter`),"Letter");}const ge=96,xe=25.4,R=Object.freeze({marginsMm:Object.freeze({top:8,right:10,bottom:12,left:10}),printBodyPaddingMm:0});function _(e){return e===0?"0":`${e}mm`;}function st(){const{top:e,right:t,bottom:n,left:i}=R.marginsMm;return{top:_(e),right:_(t),bottom:_(n),left:_(i)};}function ot(){return _(R.printBodyPaddingMm);}function be(){const{left:e,right:t}=R.marginsMm;return(e+t+R.printBodyPaddingMm*2)/xe*ge;}const re=Object.freeze({boolean:Object.freeze({min:52,max:80}),numeric:Object.freeze({min:56,max:184}),datetime:Object.freeze({min:82,max:184}),id:Object.freeze({min:72,max:224}),text:Object.freeze({min:76,max:280})}),H=Object.freeze({averageGlyphPx:7.4,tabularNumericGlyphPx:9,horizontalPaddingPx:18,measuredWidthHeadroom:1.2,representativePercentile:0.9});function D(e){return e==null?"":String(e).replace(/\s+/g," ").trim();}function ye(e,t=!1){return Array.from(D(e)).reduce((n,i)=>t&&i>="0"&&i<="9"?n+1:/[ilI1.,'|]/.test(i)?n+0.5:/[MW@%&#]/.test(i)?n+1.25:/\s/.test(i)?n+0.55:n+1,0);}function U(e,t=!1){return ye(e,t)*(t?H.tabularNumericGlyphPx:H.averageGlyphPx)+H.horizontalPaddingPx;}function Pe(e){const t=D(e);if(!t)return 0;const i=t.split(/\s+/).filter(Boolean).reduce((a,u)=>Math.max(a,U(u)),0),s=U(t)*0.72;return Math.max(i,s);}function we(e,t){if(e.length===0)return 0;const n=[...e].sort((s,a)=>s-a),i=Math.max(0,Math.ceil(t*n.length)-1);return n[Math.min(i,n.length-1)];}function Ne(e,t){const n=t.map(D).filter(Boolean).map(i=>U(i,e==="numeric"));return n.length===0?0:e==="numeric"||e==="boolean"?Math.max(...n):we(n,H.representativePercentile);}function F(e){return re[e]||re.text;}function Ce({type:e="text",label:t="",sampleValues:n=[],grandTotalValue:i="",measuredWidthPx:s=null,declaredNumeric:a=!1}={}){const u=F(e),r=[...n,i],l=Ne(e,r),o=Math.max(u.min,Pe(t),l),c=Number(s),d=r.some(h=>D(h)),y=Number.isFinite(c)&&c>0?d?Math.min(c,o*H.measuredWidthHeadroom):c:0,g=Math.max(o,y),m=Math.min(u.max,Math.max(u.min,g));return a?Math.max(l,m):m;}function W(e){return e==null?"":String(e);}function X(e={}){return{text:W(e.text),colspan:1,rowspan:1,className:e.className||"",columnId:e.columnId||null,isHeader:!!e.isHeader,...(typeof e.isNumeric=="boolean"?{isNumeric:e.isNumeric}:{}),...(typeof e.pdfIsNumeric=="boolean"?{pdfIsNumeric:e.pdfIsNumeric}:{}),measuredWidthPx:Number(e.measuredWidthPx)||null};}function Ie(e=[]){return Array.isArray(e)?e.map(t=>Array.isArray(t)?t:Array.isArray(t==null?void 0:t.cells)?t.cells:[]):[];}function Ae(e,t){const n=String(e||"").split(/\s+/).map(i=>i.trim()).filter(Boolean);return n.includes(t)||n.push(t),n.join(" ");}function Se(e){return String(e||"").split(/\s+/).map(t=>t.trim()).filter(t=>t&&t!=="numeric"&&t!=="text-right"&&t!=="text-end").join(" ");}function We(e=[]){return new Map(e.map((t,n)=>[t==null?void 0:t.columnId,n]).filter(([t])=>t));}function K(e={},t=null){if(typeof e.pdfIsNumeric=="boolean")return e.pdfIsNumeric;if(typeof(t==null?void 0:t.isNumeric)=="boolean")return t.isNumeric;if(typeof e.isNumeric=="boolean")return e.isNumeric;}function B(e={},t=null){const n=!!(t!=null&&t.isNumeric),i=Se(e.className);return{...e,className:n?Ae(i,"numeric"):i,isNumeric:n};}function ie(e=null,t=null){return B({text:"",colspan:1,rowspan:1,className:(t==null?void 0:t.className)||"",columnId:(e==null?void 0:e.columnId)||null,isHeader:!!(t!=null&&t.isHeader)},e);}function ve(e=[],t=[]){const n=Array.from({length:t.length},()=>null),i=We(t);return e.map((s={})=>{const a=n.map(o=>!!(o!=null&&o.remaining)),u=[];let r=0;const l=o=>{for(;r<o&&r<t.length;)u.push(ie(t[r],n[r])),r+=1;};return(s.cells||[]).forEach((o={})=>{for(;r<t.length&&a[r];)u.push(ie(t[r],n[r])),r+=1;const c=o.columnId?i.get(o.columnId):void 0,d=Math.max(r,c??r);l(d);const y=Math.max(1,Number(o.colspan||1)),g=Math.max(1,Number(o.rowspan||1)),m={...o,colspan:y,rowspan:1};if(u.push(y>1||!t[d]?B(m,{isNumeric:!1}):B(m,t[d])),g>1)for(let h=0;h<y;h+=1){const f=d+h;f<n.length&&(n[f]={remaining:g-1,className:o.className||"",isHeader:!!o.isHeader});}r=d+y;}),l(t.length),n.forEach((o,c)=>{!a[c]||!(o!=null&&o.remaining)||(o.remaining-=1,o.remaining<=0&&(n[c]=null));}),{...s,cells:u};});}function Le(e=[]){const t=Ie(e);if(t.length===0)return{headerRows:[],rowSources:[],matrix:[],placements:[],leafCells:[]};const n=t.length,i=e.map(o=>Array.isArray(o)?{}:o||{}),s=Array.from({length:n},()=>[]),a=[];t.forEach((o,c)=>{let d=0;o.forEach((y={},g)=>{for(;s[c][d]!==void 0;)d+=1;const m=Math.max(1,Number(y.colspan||1)),h=Math.max(1,Number(y.rowspan||1)),f={id:`${c}:${g}`,rowIndex:c,startCol:d,endCol:d+m-1,colspan:m,rowspan:h,cell:X(y),hasChildHeaders:!1};a.push(f);for(let S=0;S<h;S+=1){const N=c+S;if(N>=n)break;for(let b=0;b<m;b+=1){const P=d+b;s[N][P]===void 0&&(s[N][P]=f);}}d+=m;});}),a.forEach(o=>{o.hasChildHeaders=a.some(c=>c.rowIndex>o.rowIndex&&c.startCol<=o.endCol&&c.endCol>=o.startCol);});const u=n-1,r=s.reduce((o,c)=>Math.max(o,c.length),0),l=Array.from({length:r},(o,c)=>{let d=null;for(let f=u;f>=0;f-=1)if(s[f][c]){d=s[f][c];break;}if(!d)return X();const y=c-d.startCol,g=d.colspan===1||!d.hasChildHeaders,m=d.cell,h=g&&Number.isFinite(m.measuredWidthPx)&&m.measuredWidthPx>0?m.measuredWidthPx/d.colspan:null;return{text:m.text,colspan:1,rowspan:1,className:m.className,columnId:g&&y===0?m.columnId:null,isHeader:m.isHeader,...(g&&typeof m.isNumeric=="boolean"?{isNumeric:m.isNumeric}:{}),...(g&&typeof m.pdfIsNumeric=="boolean"?{pdfIsNumeric:m.pdfIsNumeric}:{}),measuredWidthPx:h};});return{headerRows:t,rowSources:i,matrix:s,placements:a,leafCells:l};}function $(){return{text:"",colspan:1,rowspan:1,className:"",columnId:null,isHeader:!1,measuredWidthPx:null};}function G(e={},t={}){return{text:W(e.text),colspan:1,rowspan:1,className:e.className||"",columnId:e.columnId||null,isHeader:!!e.isHeader,...(typeof e.isNumeric=="boolean"?{isNumeric:e.isNumeric}:{}),...(typeof e.pdfIsNumeric=="boolean"?{pdfIsNumeric:e.pdfIsNumeric}:{}),measuredWidthPx:Number(e.measuredWidthPx)||null,...t};}function se(e=[]){return e.reduce((t,n)=>t+Math.max(1,Number((n==null?void 0:n.colspan)||1)),0);}function Be(e=[],t=0){const n=Array.from({length:t},()=>0);return e.map((i={})=>{const s=Array.from({length:t},()=>null);let a=0;const u=()=>{for(;a<t&&n[a]>0;)s[a]=$(),n[a]-=1,a+=1;};for(u(),(i.cells||[]).forEach((r={})=>{if(u(),a>=t)return;const l=Math.max(1,Number(r.colspan||1)),o=Math.max(1,Number(r.rowspan||1));for(let c=0;c<l;c+=1){const d=a+c;if(d>=t)break;s[d]=c===0?G(r):G(r,{text:"",columnId:null,measuredWidthPx:null}),o>1&&(n[d]=Math.max(n[d],o-1));}a+=l;});a<t;)n[a]>0&&(n[a]-=1),s[a]=s[a]||$(),a+=1;return s.map(r=>r||$());});}function Me(e=null,t=0){if(!e)return null;const n=[];for((e.cells||[]).forEach((i={})=>{const s=Math.max(1,Number(i.colspan||1));n.push(G(i));for(let a=1;a<s;a+=1)n.push(G(i,{text:"",columnId:null,measuredWidthPx:null}));});n.length<t;)n.push($());return n.slice(0,t);}function Te(e){const t=W(e).trim().toLowerCase();return t?["-","—","–","n/a","na","null","none"].includes(t):!0;}function ze(e){const t=W(e).trim().toLowerCase();return["true","false","yes","no","y","n","on","off"].includes(t);}function Ee(e){const t=W(e).trim();return t?/^\d{4}-\d{2}-\d{2}/.test(t)||/^\d{1,2}\/\d{1,2}\/\d{2,4}/.test(t)||/^\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}/.test(t):!1;}function _e(e){const t=W(e).trim();return!!(t&&!t.includes(" ")&&/^[a-z0-9_.:-]{8,}$/i.test(t));}function He(e){if(typeof e=="number")return!0;const t=W(e).trim().replace(/^\((.*)\)$/,"-$1").replace(/[$,%\s]/g,"").replace(/,/g,"");return!!(t&&/^-?\d+(\.\d+)?$/.test(t));}function ke(e){const t=W(e).trim().replace(/^\((.*)\)$/,"-$1").replace(/[$%\s]/g,"");return!!(t&&/^-?(?:\d{1,3}(?:,\d{3})+|\d+)(?:\.\d+)?$/.test(t));}function je(e){const t=W(e).trim();if(!t.includes(","))return!1;const n=t.split(",").map(i=>i.trim()).filter(Boolean);return n.length<2||!n.every(i=>/^[a-z0-9_.:/-]+$/i.test(i))?!1:/,\s+/.test(t)?!0:ke(t)?!1:n.some(i=>!/^\d+$/.test(i));}function Oe(e,t,n){return Array.isArray(e)&&(e.find(s=>(s==null?void 0:s.columnId)&&s.columnId===t)||e[n])||null;}function $e(e,t,n){const i=K(e,t);if(typeof i=="boolean")return i?"numeric":"text";const s=n.filter(a=>!Te(a));return s.length===0||s.some(a=>je(a))?"text":s.filter(He).length/s.length>=0.8?"numeric":s.filter(ze).length/s.length>=0.8?"boolean":s.filter(Ee).length/s.length>=0.7?"datetime":s.filter(_e).length/s.length>=0.7?"id":"text";}function oe(e){return W(e==null?void 0:e.text).trim().length>0;}function Re(e=[]){return[{cells:e.map(t=>B({text:t.label,colspan:1,rowspan:1,className:"",columnId:t.columnId,isHeader:!0},t))}];}function Fe(e,t,n){if(!e.headerRows.length||!t.length)return null;const i=new Map(t.map((r,l)=>[r,l])),s=new Map(n.map(r=>[r.sourceIndex,r]));if(!t.every(r=>e.matrix.every(l=>!!l[r])))return null;const u=e.rowSources.map((r,l)=>({...r,cells:[],__rowIndex:l}));for(const r of e.placements){const l=t.filter(h=>h>=r.startCol&&h<=r.endCol).map(h=>i.get(h));if(l.length===0)continue;for(let h=1;h<l.length;h+=1)if(l[h]!==l[h-1]+1)return null;const o=t.filter(h=>h>=r.startCol&&h<=r.endCol).map(h=>s.get(h)).filter(h=>!!h),c=r.colspan===1&&!r.hasChildHeaders&&o.length===1,y=r.colspan>1&&!r.hasChildHeaders&&o.length>0&&o.every(h=>h.isNumeric===o[0].isNumeric),g=r.cell,m={text:g.text,colspan:l.length,rowspan:r.rowspan,className:g.className,columnId:c?g.columnId:null,isHeader:!0,measuredWidthPx:null,__sortIndex:l[0]};u[r.rowIndex].cells.push(c||y?B(m,o[0]):B(m,{isNumeric:!1}));}return u.map(({__rowIndex:r,...l})=>({...l,cells:l.cells.sort((o,c)=>o.__sortIndex-c.__sortIndex).map(({__sortIndex:o,...c})=>c)}));}function ae(e={}){return{text:W(e.text),colspan:1,rowspan:1,className:e.className||"",columnId:e.columnId||null,isHeader:!!e.isHeader,...(typeof e.isNumeric=="boolean"?{isNumeric:e.isNumeric}:{})};}function ce(e={}){return String(e.tableType||"").toLowerCase()==="pivot"||e.pivotLevels!==void 0||e.rowLevels!==void 0;}function Ge(e){const t=Number(e);return Number.isFinite(t)?Math.max(0,Math.trunc(t)):0;}function De(e,t,n,i){if(!ce(e))return 0;const s=Ge(e.rowLevels);if(s>0)return Math.min(s,i.length);const a=t.find(l=>String((l==null?void 0:l.type)||"data").toLowerCase()==="data"&&Array.isArray(l==null?void 0:l.cells));if(a){const l=a.cells,o=l.some(d=>!!(d!=null&&d.isHeader));let c=0;for(const d of l){if(!(d!=null&&d.isHeader))break;c+=Math.max(1,Number(d.colspan||1));}if(c>0||o)return Math.min(c,i.length);}const u=n.placements.filter(l=>l.rowIndex===0).sort((l,o)=>l.startCol-o.startCol);let r=0;for(const l of u){if(l.startCol!==r)break;const o=/^rowLevel\d+$/i.test(String(l.cell.columnId||"")),d=n.headerRows.length>1&&l.rowspan>=n.headerRows.length&&i.slice(l.startCol,l.endCol+1).every(y=>!(y!=null&&y.isNumeric));if(!o&&!d)break;r+=l.colspan;}if(r===0&&u.length>0){const l=u[0];if(l.colspan>1&&l.rowspan<Math.max(1,n.headerRows.length)&&n.leafCells.slice(l.startCol,l.endCol+1).every(c=>K(c)!==!0))return Math.min(l.colspan,i.length);}return Math.min(r,i.length);}function Ve(e={},t={}){const n=Array.isArray(e.headers)?e.headers:[],i=Array.isArray(e.rows)?e.rows:[],s=e.metadata||{},a=Le(n),u=Math.max(a.leafCells.length,Number(s.totalColumns||0),...i.map(p=>se((p==null?void 0:p.cells)||[])),e.grandTotal?se(e.grandTotal.cells||[]):0),r=Be(i,u),l=r.filter((p,x)=>{var C;return x<50||((C=i[x])==null?void 0:C.type)==="subtotal";}),o=Me(e.grandTotal,u),c=Array.isArray(s.columns)?s.columns:[],d=Array.from({length:u},(p,x)=>{var te,ne;const C=a.leafCells[x]||X(),A=(te=r.find(E=>{var M;return(M=E[x])==null?void 0:M.columnId;}))==null?void 0:te[x],I=Oe(c,C.columnId||(A==null?void 0:A.columnId),x),V=C.columnId||(I==null?void 0:I.columnId)||(A==null?void 0:A.columnId)||`col_${x+1}`,k=W(C.text)||W(I==null?void 0:I.label)||`Column ${x+1}`,j=l.map(E=>{var M;return((M=E[x])==null?void 0:M.text)??"";}),v=((ne=o==null?void 0:o[x])==null?void 0:ne.text)??"",T=$e(C,I,[...j,v]),z=K(C,I)===!0,O=F(T).min,de=Number.isFinite(I==null?void 0:I.measuredWidthPx)?Number(I==null?void 0:I.measuredWidthPx):Number.isFinite(C.measuredWidthPx)?Number(C.measuredWidthPx):null,ee=Ce({type:T,label:k,sampleValues:z?r.map(E=>{var M;return((M=E[x])==null?void 0:M.text)??"";}):j,grandTotalValue:v,measuredWidthPx:de,declaredNumeric:z});return{index:x,sourceIndex:x,columnId:V,label:k,type:T,minWidthPx:T==="numeric"?ee:O,widthPx:ee,isNumeric:T==="numeric",declaredNumeric:z};}),y=ce(s),g=De(s,i,a,d),h=t.suppressEmptyColumns!==!1&&String(s.tableType||"").toLowerCase()==="data"&&(r.length>0||o)?d.filter(p=>{const x=p.sourceIndex;return r.some(C=>oe(C[x]))||oe(o==null?void 0:o[x]);}).map(p=>p.sourceIndex):d.map(p=>p.sourceIndex);h.length===0&&d.length>0&&h.push(d[0].sourceIndex);const f=new Set(h),S=d.filter(p=>!f.has(p.sourceIndex)).map(p=>({columnId:p.columnId,label:p.label})),N=h.map((p,x)=>({...d[p],index:x})),b=N.map(p=>p.index),P=S.length===0;return{columns:N,hiddenEmptyColumns:S,isPivotTable:y,pivotAnchorCount:g,project:(p=b,{preserveHeaderHierarchy:x=!0,preserveBodySpans:C=!1}={})=>{const A=p.map(v=>N[v]).filter(Boolean),I=A.map(v=>v.sourceIndex),V=x?Fe(a,I,A):null,k=C&&P&&A.length===N.length?ve(i,d):i.map((v,T)=>({...v,cells:A.map(z=>{var O;return B(ae((O=r[T])==null?void 0:O[z.sourceIndex]),z);})})),j=o?{...(e.grandTotal||{}),cells:A.map(v=>B(ae(o[v.sourceIndex]),v))}:null;return{headers:V||Re(A),rows:k,grandTotal:j,columns:A};}};}function Y(){const e=new Error("Numeric values cannot fit this PDF layout without clipping. Use horizontal pagination, narrow the export or use CSV.");return e.code=me,e.deliveryBlocking=!0,e;}const w=96,le={Letter:{width:8.5*w,height:11*w},Legal:{width:8.5*w,height:14*w},Tabloid:{width:11*w,height:17*w},Ledger:{width:17*w,height:11*w},A0:{width:841/25.4*w,height:1189/25.4*w},A1:{width:594/25.4*w,height:841/25.4*w},A2:{width:420/25.4*w,height:594/25.4*w},A3:{width:297/25.4*w,height:420/25.4*w},A4:{width:210/25.4*w,height:297/25.4*w},A5:{width:148/25.4*w,height:210/25.4*w},A6:{width:105/25.4*w,height:148/25.4*w}},q=["Letter","Legal","A3","Tabloid"],qe=/* @__PURE__ */new Set(["auto","fit","horizontal_paginate"]);function Q(e){return String(e||"portrait").toLowerCase()==="landscape"?"landscape":"portrait";}function Ue(e,t){const n=J(e||"Letter"),i=le[n]||le.Letter,s=Q(t);return s==="landscape"?{pageSize:n,orientation:s,width:i.height,height:i.width}:{pageSize:n,orientation:s,width:i.width,height:i.height};}function Xe(e,t){const n=Ue(e,t);return Math.max(200,n.width-be()-8);}function Ye(e,t){const n=J(e||"Letter"),i=Q(t),s=[],a=(r,l)=>{s.find(c=>c.pageSize===r&&c.orientation===l)||s.push({pageSize:r,orientation:l,printableWidthPx:Xe(r,l)});};a(n,i),a(n,i==="portrait"?"landscape":"portrait");const u=Math.max(0,q.indexOf(n));for(let r=u;r<q.length;r+=1)a(q[r],"landscape");return s;}function ue(e=[]){return!Array.isArray(e)||e.length===0?null:e.reduce((t,n)=>t?n.printableWidthPx>t.printableWidthPx?n:t:n,null);}function Z(e,t="widthPx"){return e.reduce((n,i)=>n+(Number(i==null?void 0:i[t])||0),0);}function Ze(e,t){const n=Z(e);if(n<=t)return e.map(u=>u.widthPx);const i=Z(e,"minWidthPx");if(i>=t)return e.map(u=>u.minWidthPx);const s=n-t,a=n-i;return e.map(u=>{const r=Math.max(0,u.widthPx-u.minWidthPx),l=s*(r/a);return Math.max(u.minWidthPx,u.widthPx-l);});}function Je(e,t){const n=t*0.35,i=[];let s=0;for(const a of e){if(i.length>=2)break;a.isNumeric||s+a.widthPx>n&&i.length>0||(i.push(a.index),s+=a.widthPx);}return i.length===0&&e.length>0&&i.push(e[0].index),i;}function Ke(e,t,n=0){if(e.some(f=>f.declaredNumeric&&f.widthPx>t))throw Y();const i=F("text").min,s=n>0,a=s?e.slice(0,n).map(f=>f.index):[];let u=s?[...a]:Je(e,t);const r=f=>f.reduce((S,N)=>{var b;return S+(((b=e[N])==null?void 0:b.widthPx)||0);},0),l=()=>e.map(f=>f.index).filter(f=>!(u.includes(f)||s&&a.includes(f)));let o=l();if(o.length>0){let f=r(u);if(s)for(;u.length>1&&t-f<i;)u=u.slice(0,-1),f=r(u);for(;!s&&u.length>0&&t-f<i;)u=u.slice(0,-1),f=r(u);o=l();}const c=r(u),d=Math.max(40,t-c),y={},g=[];let m=[],h=0;return o.forEach(f=>{var b,P;const S=((b=e[f])==null?void 0:b.widthPx)||F("text").min;if((P=e[f])!=null&&P.declaredNumeric&&S>d)throw Y();const N=Math.min(S,d);if(y[f]=N,m.length>0&&h+N>d){g.push(m),m=[f],h=N;return;}m.push(f),h+=N;}),m.length>0&&g.push(m),g.length===0&&g.push([]),{anchorIndices:u,bands:g,dynamicWidthByIndex:y};}function Qe(e,t,n){const{columnGroups:i,groupLabels:s,groupLevelLabel:a}=e.metadata??{};if(!Array.isArray(i)||!Array.isArray(s)||typeof a!="string")return null;const u=o=>{const c=i[o.sourceIndex];return typeof c=="number"?c:null;},r=he({columns:t.map(o=>({widthPx:o.widthPx,group:u(o)})),printableWidthPx:n,maxBands:Number.POSITIVE_INFINITY});if(r.kind==="too_wide")return null;const l=t.filter(o=>u(o)===null).map(o=>o.index);return r.kind==="fits"?{anchorIndices:l,bands:[{columns:t.map(o=>o.index),caption:null}]}:{anchorIndices:l,bands:r.bands.map(o=>({columns:o.columns,caption:fe({groupLevelLabel:a,groupLabels:s.map(String),firstGroup:o.firstGroup,lastGroup:o.lastGroup})}))};}function et(e=[],t=0){const n=[...new Set(e)].filter(u=>Number.isInteger(u)&&u>=0).sort((u,r)=>u-r);if(n.length===0){const u=Math.max(1,Number(t)||1);return`Columns 1-${u} of ${u}`;}const i=[];let s=n[0],a=n[0];for(let u=1;u<n.length;u+=1){const r=n[u];if(r===a+1){a=r;continue;}i.push(s===a?`${s+1}`:`${s+1}-${a+1}`),s=r,a=r;}return i.push(s===a?`${s+1}`:`${s+1}-${a+1}`),`Columns ${i.join(", ")} of ${Math.max(1,Number(t)||1)}`;}function tt(e,t,n={}){return t.map(i=>{const s=e[i],a=Number(n[i]),u=Number.isFinite(a)&&a>0?a:s.widthPx;return{columnId:s.columnId,label:s.label,widthPx:u,isNumeric:s.isNumeric};});}function at(e,t={}){const n=J(t.pageSize||"Letter"),i=Q(t.orientation||"portrait"),s=String(t.wideTableStrategy||"auto"),a=qe.has(s)?s:"auto",u=Ve(e,t),{columns:r,hiddenEmptyColumns:l,isPivotTable:o,pivotAnchorCount:c}=u,d=Z(r,"minWidthPx"),y=Ye(n,i);let g=y.find(b=>d<=b.printableWidthPx);if(a==="fit"&&!g&&(g=ue(y),r.some(b=>b.declaredNumeric&&b.widthPx>g.printableWidthPx)))throw Y();if(g&&a!=="horizontal_paginate"){const b=Ze(r,g.printableWidthPx),P=r.map(x=>x.index),L=l.length>0,p=u.project(P,{preserveHeaderHierarchy:!L,preserveBodySpans:!L});return{sections:[{headers:p.headers,rows:p.rows,grandTotal:p.grandTotal,bandLabel:null,columns:r.map((x,C)=>({columnId:x.columnId,label:x.label,widthPx:b[C],isNumeric:x.isNumeric}))}],layoutApplied:{requestedPageSize:n,requestedOrientation:i,effectivePageSize:g.pageSize,effectiveOrientation:g.orientation,usedBanding:!1,bandCount:1,totalColumns:r.length,anchorColumns:[],autoAdjustedLayout:g.pageSize!==n||g.orientation!==i,strategyApplied:"fit",hiddenEmptyColumnCount:l.length,hiddenEmptyColumns:l.map(x=>x.label)}};}const m=g||ue(y),h=Qe(e,r,m.printableWidthPx);if(h){const b=h.bands.map(P=>{const L=u.project(P.columns,{preserveHeaderHierarchy:o,preserveBodySpans:!1});return{headers:L.headers,rows:L.rows,grandTotal:L.grandTotal,bandLabel:P.caption,columns:P.columns.map(p=>({columnId:r[p].columnId,label:r[p].label,widthPx:r[p].widthPx,isNumeric:r[p].isNumeric}))};});return{sections:b,layoutApplied:{requestedPageSize:n,requestedOrientation:i,effectivePageSize:m.pageSize,effectiveOrientation:m.orientation,usedBanding:b.length>1,bandCount:b.length,totalColumns:r.length,anchorColumns:h.anchorIndices.map(P=>r[P].label),autoAdjustedLayout:m.pageSize!==n||m.orientation!==i,strategyApplied:"horizontal_paginate",hiddenEmptyColumnCount:l.length,hiddenEmptyColumns:l.map(P=>P.label)}};}const f=Ke(r,m.printableWidthPx,c),S=f.anchorIndices.map(b=>{var P;return(P=r[b])==null?void 0:P.label;}).filter(Boolean),N=f.bands.map(b=>{const P=[...f.anchorIndices,...b],L=tt(r,P,f.dynamicWidthByIndex),p=u.project(P,{preserveHeaderHierarchy:o,preserveBodySpans:!1}),x=et(P,r.length);return{headers:p.headers,rows:p.rows,grandTotal:p.grandTotal,bandLabel:x,columns:L};});return{sections:N,layoutApplied:{requestedPageSize:n,requestedOrientation:i,effectivePageSize:m.pageSize,effectiveOrientation:m.orientation,usedBanding:!0,bandCount:N.length,totalColumns:r.length,anchorColumns:S,autoAdjustedLayout:m.pageSize!==n||m.orientation!==i,strategyApplied:"horizontal_paginate",hiddenEmptyColumnCount:l.length,hiddenEmptyColumns:l.map(b=>b.label)}};}export{R as TABLE_PAGE_GEOMETRY,Ve as buildPdfTableModel,at as buildWideTableLayout,fe as columnBandCaption,Ce as estimateColumnWidthPx,F as getColumnWidthBounds,be as getTableHorizontalInsetPx,st as getTablePdfMargins,ot as getTablePrintBodyPaddingCss,J as normalizePageSize,he as planColumnBands};