react-semaphor 0.1.545 → 0.1.547

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 (159) hide show
  1. package/dist/analytics-protocol/index.js +408 -442
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +100 -76
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.js +6 -6
  6. package/dist/chunks/{add-to-dashboard-BuAqfA2Y.js → add-to-dashboard-BQRAAnc3.js} +55 -33
  7. package/dist/chunks/{analytics-base-schemas-BFAoRlkU.js → analytics-base-schemas-BKs3flFS.js} +2 -2
  8. package/dist/chunks/applied-constraints-DU-wndZ7.js +47 -0
  9. package/dist/chunks/{assistant-chat-D7sWTypJ.js → assistant-chat-CK84cPAB.js} +2826 -2595
  10. package/dist/chunks/{bookmark-state-CXw7lZ50.js → bookmark-state-Cu-a5ie_.js} +8 -15
  11. package/dist/chunks/comparison-window-caption-C2xF-eWw.js +1433 -0
  12. package/dist/chunks/{context-ClREvqCZ.js → context-BerEBuFR.js} +11 -6
  13. package/dist/chunks/custom-visual-inputs-ChL54gGm.js +295 -0
  14. package/dist/chunks/{dashboard-B1tMju0u.js → dashboard-DCk26-6i.js} +1 -1
  15. package/dist/chunks/{dashboard-briefing-launcher-CePgIu0Z.js → dashboard-briefing-launcher-CQ1eYsGy.js} +1291 -1277
  16. package/dist/chunks/dashboard-controls-BMeZjF7r.js +2307 -0
  17. package/dist/chunks/{dashboard-json-CoYRPqxx.js → dashboard-json-BZqCoanC.js} +5 -5
  18. package/dist/chunks/{document-dashboard-inputs-BesAHZvB.js → document-dashboard-inputs-tYd7ao0o.js} +877 -979
  19. package/dist/chunks/{edit-dashboard-visual-JPtNfJRb.js → edit-dashboard-visual-Bv3MHM_G.js} +2157 -2243
  20. package/dist/chunks/filter-reach-copy-CGWsL_ez.js +3480 -0
  21. package/dist/chunks/{filter-value-text-ff7osJr7.js → filter-value-text-Ddf55Ku1.js} +9 -9
  22. package/dist/chunks/global-date-filter-utils-BhAu8zIM.js +12137 -0
  23. package/dist/chunks/index-CtoK1Lgu.js +586 -0
  24. package/dist/chunks/{index-DRWiuqyd.js → index-DmrLP5Ro.js} +105 -104
  25. package/dist/chunks/list-filter-DsaTbM3J.js +15 -0
  26. package/dist/chunks/matrix-analytical-definition-B9vW-osb.js +717 -0
  27. package/dist/chunks/{matrix-card-DjwWcCo8.js → matrix-card-LiMEipvq.js} +3 -3
  28. package/dist/chunks/{matrix-formatter-DnCyRXJE.js → matrix-formatter-DWEeC0_c.js} +44 -44
  29. package/dist/chunks/{matrix-member-presentation-CQGdVks6.js → matrix-member-presentation-DqzG-UhQ.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-8OIO4gob.js → matrix-operation-contract-D6vYkZK4.js} +72 -72
  31. package/dist/chunks/{metric-comparison-DEwi9uc2.js → metric-comparison-zpGw4lD6.js} +2 -2
  32. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  33. package/dist/chunks/{pivot-header-presentation-DHcx1XGQ.js → pivot-header-presentation-CQnIDtUv.js} +1 -1
  34. package/dist/chunks/{pivot-result-identity-DJhXXcns.js → pivot-result-identity-C-Q1j1Wb.js} +1 -1
  35. package/dist/chunks/{pivot-result-lifecycle-DM4CyGKs.js → pivot-result-lifecycle-pwq3b7LC.js} +571 -380
  36. package/dist/chunks/{raw-temporal-contract-C51YG48G.js → raw-temporal-contract-WuXA8jBP.js} +1 -1
  37. package/dist/chunks/{raw-temporal-presentation-C3mUgnEx.js → raw-temporal-presentation-DypB7sMX.js} +8 -8
  38. package/dist/chunks/{report-preferences-dialog-DUtuUL_5.js → report-preferences-dialog-DoVyriYC.js} +154 -155
  39. package/dist/chunks/{report-runtime-context-Dq8XyODK.js → report-runtime-context-hWiTCzFV.js} +2 -2
  40. package/dist/chunks/resolve-dashboard-input-context-D0JDUa4h.js +5576 -0
  41. package/dist/chunks/{saved-dashboard-context-LrF_kW0l.js → saved-dashboard-context-BfAH5j4L.js} +34 -34
  42. package/dist/chunks/{selection-reducer-Dj_8xD69.js → selection-reducer-CJzkTZio.js} +15 -15
  43. package/dist/chunks/{semaphor-ready-indicator-BxF96Yhv.js → semaphor-ready-indicator-CRm17oIP.js} +51771 -52574
  44. package/dist/chunks/{shelf-drop-preview-context-CNaM_Gmh.js → shelf-drop-preview-context-vy6P9THz.js} +7 -7
  45. package/dist/chunks/{source-entity-resolution-BYn9giz3.js → source-entity-resolution-BIGRvtbG.js} +13 -13
  46. package/dist/chunks/{switch-uDtPgQlQ.js → switch-CEBOR4n7.js} +3 -3
  47. package/dist/chunks/{table-export-sheet-YzMioA7Y.js → table-export-sheet-4X9mAG3V.js} +1 -1
  48. package/dist/chunks/table-settings-WysCBj62.js +614 -0
  49. package/dist/chunks/{temporal-bucket-D7NBrrtL.js → temporal-bucket-CQOSbv9-.js} +26 -26
  50. package/dist/chunks/{token-types-DBbZVQsm.js → token-types-BMqRmT-C.js} +1 -1
  51. package/dist/chunks/{use-create-flow-overlay-state-CjB7ig1o.js → use-create-flow-overlay-state-Csx_Xjsh.js} +101 -101
  52. package/dist/chunks/{validators-DMHTpf7a.js → validators-C-aOQlTB.js} +713 -658
  53. package/dist/chunks/{relative-date-label-Bk2j94pA.js → zoned-wall-clock-MulfA26h.js} +64 -21
  54. package/dist/dashboard/index.js +2 -2
  55. package/dist/dashboard-authoring/index.js +1895 -1163
  56. package/dist/data-app-sdk/index.js +6 -6
  57. package/dist/data-app-sdk-adapters/index.js +3 -3
  58. package/dist/data-app-sdk-validation/index.js +14 -14
  59. package/dist/format-utils/index.js +133 -133
  60. package/dist/index.js +192 -186
  61. package/dist/layouts/index.js +5 -242
  62. package/dist/report-runtime-context/index.js +2 -2
  63. package/dist/shared/index.js +4 -5
  64. package/dist/style.css +1 -1
  65. package/dist/surfboard/index.js +2 -2
  66. package/dist/types/components/index.d.ts +2 -0
  67. package/dist/types/components/surfboard/arrange-layout-button.d.ts +8 -0
  68. package/dist/types/components/surfboard/filter/types.d.ts +7 -0
  69. package/dist/types/components/surfboard/screen-size-preview-button.d.ts +10 -0
  70. package/dist/types/components/visual/matrix-table/matrix-card-view.d.ts +3 -0
  71. package/dist/types/index.js +6 -6
  72. package/dist/types/lib/charts/table-chart-types.d.ts +4 -0
  73. package/dist/types/lib/charts/types.d.ts +2 -2
  74. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +346 -21
  75. package/dist/types/lib/dashboard-inputs/dashboard-filter-value-identity.d.ts +65 -0
  76. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +6 -0
  77. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +2 -0
  78. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +15 -0
  79. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +3 -3
  80. package/dist/types/lib/hooks/use-dashboard-card.d.ts +2 -0
  81. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +1 -1
  82. package/dist/types/lib/matrix-table/matrix-editor.d.ts +52 -0
  83. package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +9 -1
  84. package/dist/types/lib/matrix-table/matrix-runtime.d.ts +5 -1
  85. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +149 -10
  86. package/dist/types/lib/stores/dashboard-store.d.ts +137 -6
  87. package/dist/types/lib/types/common-types.d.ts +8 -0
  88. package/dist/types/lib/types/explorer-types.d.ts +10 -0
  89. package/dist/types/lib/types/semantic-types.d.ts +84 -0
  90. package/dist/types/lib/utils/build-saved-editor-card.d.ts +20 -0
  91. package/dist/types/lib/utils/card-type-change.d.ts +16 -0
  92. package/dist/types/lib/utils/field-availability-context.d.ts +25 -0
  93. package/dist/types/lib/utils/field-placement.d.ts +96 -0
  94. package/dist/types/lib/utils/field-state-calculator.d.ts +161 -0
  95. package/dist/types/lib/utils/qualified-entity-name.d.ts +2 -0
  96. package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +57 -1
  97. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +89 -0
  98. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  99. package/dist/types/shared/analytics-protocol/query-policies.d.ts +52 -0
  100. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +1 -1
  101. package/dist/types/shared/analytics-protocol/time-window.d.ts +40 -1
  102. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +4 -1
  103. package/dist/types/shared/assistant-protocol/answer-text.d.ts +20 -0
  104. package/dist/types/shared/assistant-protocol/context.d.ts +29 -29
  105. package/dist/types/shared/assistant-protocol/index.d.ts +1 -0
  106. package/dist/types/shared/assistant-protocol/limits.d.ts +6 -1
  107. package/dist/types/shared/assistant-protocol/parts.d.ts +43 -3
  108. package/dist/types/shared/assistant-protocol/request.d.ts +14 -2
  109. package/dist/types/shared/dashboard-authoring/calculated-field-identity.d.ts +3 -0
  110. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +487 -0
  111. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +34 -0
  112. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +7886 -0
  113. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +45 -0
  114. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +54 -0
  115. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +96 -0
  116. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +3 -3
  117. package/dist/types/shared/dashboard-authoring/column-catalog.d.ts +32 -0
  118. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -55
  119. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +24 -14
  120. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +9 -1
  121. package/dist/types/shared/dashboard-authoring/dashboard-filter-automatic-target.d.ts +4 -4
  122. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-contract.d.ts +3 -1
  123. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-types.d.ts +27 -1
  124. package/dist/types/shared/dashboard-authoring/dashboard-filter-value-compatibility.d.ts +12 -3
  125. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +26 -0
  126. package/dist/types/shared/dashboard-authoring/filter-applicability.d.ts +75 -0
  127. package/dist/types/shared/dashboard-authoring/filter-reach-copy.d.ts +18 -0
  128. package/dist/types/shared/dashboard-authoring/filter-reach-preview.d.ts +97 -0
  129. package/dist/types/shared/dashboard-authoring/index.d.ts +22 -2
  130. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +10 -37
  131. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +189 -0
  132. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +101 -0
  133. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +100 -0
  134. package/dist/types/shared/dashboard-authoring/semantic-auto-join-card.d.ts +22 -0
  135. package/dist/types/shared/dashboard-authoring/validators.d.ts +1 -2
  136. package/dist/types/shared/layouts/engine/grid.d.ts +25 -0
  137. package/dist/types/shared/layouts/engine/index.d.ts +4 -0
  138. package/dist/types/shared/layouts/engine/sheet-layout.d.ts +7 -0
  139. package/dist/types/shared/layouts/engine/types.d.ts +125 -0
  140. package/dist/types/shared/layouts/index.d.ts +1 -2
  141. package/package.json +2 -2
  142. package/dist/chunks/apply-dashboard-operations-CZEMsx8E.js +0 -2080
  143. package/dist/chunks/calendar-day-equality-dvoQp1xW.js +0 -410
  144. package/dist/chunks/comparison-window-caption-D4E6IHPD.js +0 -1624
  145. package/dist/chunks/custom-visual-inputs-DLCD9Y5V.js +0 -329
  146. package/dist/chunks/dashboard-controls-Cq05n3e0.js +0 -2315
  147. package/dist/chunks/dashboard-filter-value-compatibility-CwQ_iSNb.js +0 -108
  148. package/dist/chunks/matrix-analytical-definition-C7Gb0e12.js +0 -117
  149. package/dist/chunks/normalize-dashboard-for-dirty-check-Bk3VYv_q.js +0 -67
  150. package/dist/chunks/numeric-presentation-7X_IrD58.js +0 -5226
  151. package/dist/chunks/resolve-dashboard-input-context-DJ2tICwz.js +0 -9415
  152. package/dist/chunks/stable-serialize-CfqXeiBP.js +0 -6
  153. package/dist/chunks/table-settings-CLZocegs.js +0 -501
  154. package/dist/chunks/use-debounced-dirty-check-BwAbnX_5.js +0 -59
  155. package/dist/chunks/zoned-wall-clock-BkxV9jS2.js +0 -46
  156. package/dist/types/shared/dashboard-authoring/change-compiler.d.ts +0 -7
  157. package/dist/types/shared/dashboard-authoring/layout-compiler.d.ts +0 -2
  158. package/dist/types/shared/layouts/create-frame-layouts.d.ts +0 -27
  159. package/dist/types/shared/layouts/frame-layouts.d.ts +0 -23
@@ -0,0 +1,586 @@
1
+ const v = {
2
+ /** Widest first. */
3
+ breakpoints: ["lg", "md", "sm", "xs", "xxs"],
4
+ columns: { lg: 48, md: 36, sm: 24, xs: 12, xxs: 6 },
5
+ /** react-grid-layout's default breakpoint widths, now stated. */
6
+ minContainerWidthPx: { lg: 1200, md: 996, sm: 768, xs: 480, xxs: 0 },
7
+ editable: ["lg", "sm", "xs"],
8
+ customizable: ["sm", "xs"],
9
+ /** The preview canvas widths: Laptop, Tablet, Phone, Small phone (Desktop is at least `minContainerWidthPx.lg`; RL-D19). */
10
+ previewWidthPx: { md: 1024, sm: 820, xs: 390, xxs: 360 }
11
+ }, g = v.columns.lg;
12
+ function q(n) {
13
+ return n === "sm" || n === "xs";
14
+ }
15
+ function wt(n) {
16
+ return n === "lg" || q(n);
17
+ }
18
+ function bt(n) {
19
+ return n === "md" || wt(n);
20
+ }
21
+ const gt = [
22
+ "table",
23
+ "pivotTable",
24
+ "aggregateTable",
25
+ "matrixTable",
26
+ "detailTable"
27
+ ], Mt = new Set(gt);
28
+ function kt(n) {
29
+ return typeof n == "string" && Mt.has(n);
30
+ }
31
+ function vt(n) {
32
+ var t, i;
33
+ return ((t = n == null ? void 0 : n.cards) == null ? void 0 : t.find((e) => e.id === n.activeCardId)) ?? ((i = n == null ? void 0 : n.cards) == null ? void 0 : i[0]);
34
+ }
35
+ function K(n) {
36
+ var i;
37
+ const t = (i = vt(n)) == null ? void 0 : i.type;
38
+ return t === "kpi" ? "kpi" : t === "text" ? "text" : kt(t) ? "table" : "chart";
39
+ }
40
+ function J(n) {
41
+ return n === "kpi" || n === "text" ? "short" : "tall";
42
+ }
43
+ const L = {
44
+ kpi: { h: 15, minH: 12, minW: 6 },
45
+ chart: { h: 30, minH: 16, minW: 12 },
46
+ table: { h: 38, minH: 18, minW: 12 },
47
+ text: { h: 10, minH: 8, minW: 12 }
48
+ }, E = {
49
+ kpi: 48,
50
+ chart: 24,
51
+ table: 48,
52
+ text: 48
53
+ };
54
+ function Y(n) {
55
+ if (n <= 0) return [];
56
+ const t = Math.ceil(n / 4), i = Math.floor(n / t), e = n % t;
57
+ return Array.from({ length: t }, (o, r) => r < e ? i + 1 : i).flatMap(
58
+ (o) => Array.from({ length: o }, () => 48 / o)
59
+ );
60
+ }
61
+ const et = {
62
+ full: 48,
63
+ half: 24,
64
+ third: 16,
65
+ quarter: 12
66
+ }, Wt = ["full", "half", "third", "quarter"];
67
+ function _t(n) {
68
+ let t = "full", i = 1 / 0;
69
+ for (const e of Wt) {
70
+ const o = Math.abs(et[e] - n);
71
+ o < i && (t = e, i = o);
72
+ }
73
+ return t;
74
+ }
75
+ function N(n, t) {
76
+ return !(n.i === t.i || n.x + n.w <= t.x || n.x >= t.x + t.w || n.y + n.h <= t.y || n.y >= t.y + t.h);
77
+ }
78
+ function I(n) {
79
+ let t = 0;
80
+ for (const i of n) t = Math.max(t, i.y + i.h);
81
+ return t;
82
+ }
83
+ function Q(n, t) {
84
+ for (const i of n) if (N(i, t)) return i;
85
+ }
86
+ function Ht(n) {
87
+ return n.slice().sort((t, i) => t.y > i.y || t.y === i.y && t.x > i.x ? 1 : t.y === i.y && t.x === i.x ? 0 : -1);
88
+ }
89
+ function ot(n, t, i) {
90
+ t.y += 1;
91
+ const e = n.findIndex((o) => o.i === t.i);
92
+ for (let o = e + 1; o < n.length; o += 1) {
93
+ const r = n[o];
94
+ if (!r.static) {
95
+ if (r.y > t.y + t.h) break;
96
+ N(t, r) && ot(n, r, i + t.h);
97
+ }
98
+ }
99
+ t.y = i;
100
+ }
101
+ function zt(n, t, i) {
102
+ for (t.y = Math.min(I(n), t.y); t.y > 0 && !Q(n, t); ) t.y -= 1;
103
+ let e;
104
+ for (; e = Q(n, t); )
105
+ ot(i, t, e.y + e.h);
106
+ return t.y = Math.max(t.y, 0), t.x = Math.max(t.x, 0), t;
107
+ }
108
+ function M(n) {
109
+ const t = n.map((r) => ({ ...r })), i = t.filter((r) => r.static), e = Ht(t), o = /* @__PURE__ */ new Map();
110
+ for (const r of e) {
111
+ let s = { ...r };
112
+ s.static || (s = zt(i, s, e), i.push(s)), o.set(r, s);
113
+ }
114
+ return t.map((r) => o.get(r));
115
+ }
116
+ function It(n) {
117
+ return M(n).every((i, e) => i.y === n[e].y && i.x === n[e].x);
118
+ }
119
+ function Ot(n) {
120
+ for (let t = 0; t < n.length; t += 1)
121
+ for (let i = t + 1; i < n.length; i += 1)
122
+ if (N(n[t], n[i])) return !0;
123
+ return !1;
124
+ }
125
+ function B(n, t) {
126
+ const i = (e) => t.get(e.i) ?? Number.MAX_SAFE_INTEGER;
127
+ return n.slice().sort((e, o) => e.y - o.y || e.x - o.x || i(e) - i(o));
128
+ }
129
+ function R(n) {
130
+ const t = [];
131
+ let i = [], e = 0;
132
+ for (const o of n) {
133
+ const r = i[i.length - 1];
134
+ if (r && o.x >= r.x + r.w && e + o.w <= g) {
135
+ i.push(o), e += o.w;
136
+ continue;
137
+ }
138
+ i.length && t.push(i), i = [o], e = o.w;
139
+ }
140
+ return i.length && t.push(i), t;
141
+ }
142
+ function At(n) {
143
+ return new Map(n.map((t, i) => [t, i]));
144
+ }
145
+ function Et(n, t, i, e) {
146
+ const o = (c) => t.get(c) ?? "chart", r = B(n, i).map((c) => c.i), s = r.find((c) => o(c) === "text"), a = e ? r : [
147
+ ...s ? [s] : [],
148
+ ...r.filter((c) => o(c) === "kpi"),
149
+ ...r.filter((c) => o(c) === "chart"),
150
+ ...r.filter((c) => o(c) === "table"),
151
+ ...r.filter((c) => o(c) === "text" && c !== s)
152
+ ], f = (c) => {
153
+ const p = a[c];
154
+ if (!e) return a.filter((k) => o(k) === o(p));
155
+ let w = c;
156
+ for (; w > 0 && o(a[w - 1]) === o(p); ) w -= 1;
157
+ let h = c;
158
+ for (; h < a.length - 1 && o(a[h + 1]) === o(p); ) h += 1;
159
+ return a.slice(w, h + 1);
160
+ }, x = (c) => {
161
+ const p = a[c], w = o(p);
162
+ if (w === "table") return g;
163
+ if (w === "text") return p === s ? g : g / 2;
164
+ const h = f(c);
165
+ if (w === "kpi") return Y(h.length)[h.indexOf(p)];
166
+ const k = h.indexOf(p);
167
+ return h.length === 1 || h.length % 2 === 1 && k === 0 ? g : g / 2;
168
+ };
169
+ let l = 0, u = 0, d = 0;
170
+ const m = a.map((c, p) => {
171
+ const w = L[o(c)], h = Math.min(x(p), g);
172
+ l > 0 && l + h > g && (l = 0, u += d, d = 0);
173
+ const k = { i: c, x: l, y: u, w: h, h: w.h, minW: Math.min(w.minW, g), minH: w.minH };
174
+ return l += h, d = Math.max(d, w.h), k;
175
+ });
176
+ return { items: M(m), order: a };
177
+ }
178
+ function S(n) {
179
+ return Math.floor(n + 0.5);
180
+ }
181
+ function rt(n, t, i, e, o, r) {
182
+ const s = v.columns[t], a = { i: n.i, x: i, y: e, w: o, h: n.h }, f = r ?? n.minW;
183
+ return f !== void 0 && (a.minW = Math.max(1, Math.min(f, o, s))), n.minH !== void 0 && (a.minH = n.minH), n.maxW !== void 0 && (a.maxW = Math.max(o, Math.min(n.maxW, s))), n.maxH !== void 0 && (a.maxH = n.maxH), n.static !== void 0 && (a.static = n.static), n.isResizable !== void 0 && (a.isResizable = n.isResizable), n.isDraggable !== void 0 && (a.isDraggable = n.isDraggable), a;
184
+ }
185
+ function st(n) {
186
+ return M(
187
+ n.map((t) => {
188
+ let i = S(t.x * 0.75), o = S((t.x + t.w) * 0.75) - i;
189
+ o === 0 && (o = 1, i === 36 && (i = 35));
190
+ const r = t.minW === void 0 ? void 0 : Math.min(Math.max(1, S(t.minW * 0.75)), o);
191
+ return rt(t, "md", i, t.y, o, r);
192
+ })
193
+ );
194
+ }
195
+ function St(n, t) {
196
+ const i = new Map(st(n).map((r) => [r.i, r])), e = new Map(t.map((r) => [r.i, r])), o = v.columns.lg;
197
+ return n.map((r) => {
198
+ const s = e.get(r.i), a = i.get(r.i);
199
+ if (!s || !a) return r;
200
+ const f = { ...r };
201
+ if (s.x !== a.x || s.w !== a.w) {
202
+ const x = Math.min(o - 1, S(s.x * 1.3333333333333333)), l = Math.min(o, Math.max(x + 1, S((s.x + s.w) * (4 / 3))));
203
+ f.x = x, f.w = l - x;
204
+ }
205
+ return (s.y !== a.y || s.h !== a.h) && (f.y = s.y, f.h = s.h), f;
206
+ });
207
+ }
208
+ function j(n, t, i) {
209
+ const e = /* @__PURE__ */ new Map();
210
+ let o = 0;
211
+ for (const r of n) {
212
+ let s = 0;
213
+ for (const a of r)
214
+ e.set(a.source.i, rt(a.source, t, a.x, o, a.w)), s = Math.max(s, a.source.h);
215
+ o += s;
216
+ }
217
+ return M(i.map((r) => e.get(r.i)));
218
+ }
219
+ function tt(n, t, i) {
220
+ const e = [];
221
+ for (const o of n) {
222
+ let r;
223
+ const s = () => {
224
+ r && e.push([{ source: r, x: 0, w: t }]), r = void 0;
225
+ };
226
+ for (const a of o)
227
+ i(a) ? (s(), e.push([{ source: a, x: 0, w: t }])) : r ? (e.push([
228
+ { source: r, x: 0, w: t / 2 },
229
+ { source: a, x: t / 2, w: t / 2 }
230
+ ]), r = void 0) : r = a;
231
+ s();
232
+ }
233
+ return e;
234
+ }
235
+ function at(n, t, i, e) {
236
+ if (n === "md") return st(t);
237
+ const o = v.columns[n], r = R(B(t, e)), s = (a) => i.get(a.i) ?? "chart";
238
+ return n === "sm" ? j(tt(r, o, (a) => s(a) === "table" || s(a) === "text"), "sm", t) : n === "xs" ? j(tt(r, o, (a) => s(a) !== "kpi"), "xs", t) : j(
239
+ r.flatMap((a) => a.map((f) => [{ source: f, x: 0, w: o }])),
240
+ "xxs",
241
+ t
242
+ );
243
+ }
244
+ function H(n, t, i) {
245
+ const e = L[t];
246
+ return { i: n, x: 0, y: 0, w: i, h: e.h, minW: Math.min(e.minW, i), minH: e.minH };
247
+ }
248
+ function P(n, t) {
249
+ return n.slice().sort((i, e) => (t.get(i.i) ?? 0) - (t.get(e.i) ?? 0));
250
+ }
251
+ function G(n, t, i) {
252
+ return n.map((e) => e.y >= t ? { ...e, y: e.y + i } : e);
253
+ }
254
+ function Tt(n, t, i) {
255
+ const e = (f, x) => !t.some((l) => N({ ...n, i: "\0", x: f, y: x }, l)), o = n.x + n.w;
256
+ if (o + n.w <= i && e(o, n.y)) return { x: o, y: n.y };
257
+ const r = Math.max(i - n.w, 0), s = n.y + n.h, a = [s, ...t.map((f) => f.y + f.h).filter((f) => f > s).sort((f, x) => f - x)];
258
+ for (const f of a)
259
+ for (let x = 0; x <= r; x += 1) if (e(x, f)) return { x, y: f };
260
+ return { x: 0, y: s };
261
+ }
262
+ function ft(n, t) {
263
+ const i = Math.max(1, Math.min(n.w, t));
264
+ return {
265
+ ...n,
266
+ w: i,
267
+ x: Math.max(0, Math.min(n.x, t - i)),
268
+ ...n.minW !== void 0 ? { minW: Math.max(1, Math.min(n.minW, i)) } : {},
269
+ ...n.maxW !== void 0 ? { maxW: Math.max(i, Math.min(n.maxW, t)) } : {}
270
+ };
271
+ }
272
+ function ct(n, t, i, e) {
273
+ const o = n.find((f) => f.i === t), r = ft(o, e), { x: s, y: a } = Tt(r, n.filter((f) => f.i !== t), e);
274
+ return [...n, { ...r, i, x: s, y: a }];
275
+ }
276
+ function Bt(n, t, i, e, o) {
277
+ var u;
278
+ const r = e == null ? void 0 : e.position;
279
+ if (r && typeof r == "object" && "beside" in r)
280
+ return M(P(ct(n, r.beside, t, g), o.frameOrder));
281
+ const s = e != null && e.width ? et[e.width] : void 0;
282
+ let a = n.slice();
283
+ const f = (d) => M(P([...a, d], o.frameOrder));
284
+ if (r === "top") {
285
+ const d = H(t, i, s ?? E[i]);
286
+ return a = G(a, 0, d.h), f(d);
287
+ }
288
+ if (r === "end" || r === void 0 && s !== void 0)
289
+ return f({ ...H(t, i, s ?? E[i]), y: I(a) });
290
+ if (r && typeof r == "object" && "after" in r) {
291
+ const d = H(t, i, s ?? E[i]), c = R(B(a, o.frameOrder)).find((W) => W.some((b) => b.i === r.after)), p = c.find((W) => W.i === r.after), w = c[c.length - 1];
292
+ if (g - (w.x + w.w) >= d.w) {
293
+ const W = new Set(c.filter((b) => b.x > p.x).map((b) => b.i));
294
+ return a = a.map((b) => W.has(b.i) ? { ...b, x: b.x + d.w } : b), f({ ...d, x: p.x + p.w, y: p.y });
295
+ }
296
+ const k = Math.max(...c.map((W) => W.y + W.h));
297
+ return a = G(a, k, d.h), f({ ...d, x: 0, y: k });
298
+ }
299
+ const x = (d) => o.kinds.get(d.i) ?? "chart", l = R(B(a, o.frameOrder));
300
+ if (i === "kpi") {
301
+ const d = ((u = l[0]) == null ? void 0 : u.length) === 1 && x(l[0][0]) === "text" ? 1 : 0;
302
+ let m = d;
303
+ for (; m < l.length && l[m].every((y) => x(y) === "kpi"); ) m += 1;
304
+ if (m === d) {
305
+ const y = d === 1 ? l[0][0].y + l[0][0].h : 0, C = H(t, i, Y(1)[0]);
306
+ return a = G(a, y, C.h), f({ ...C, y });
307
+ }
308
+ const c = l.slice(d, m).flat(), p = new Set(c.map((y) => y.i)), w = Math.min(...c.map((y) => y.y)), h = Math.max(...c.map((y) => y.y + y.h)), k = [...c, H(t, i, 12)], W = Y(k.length);
309
+ let b = 0, F = w, O = 0;
310
+ const pt = k.map((y, C) => {
311
+ const $ = W[C];
312
+ b > 0 && b + $ > g && (b = 0, F += O, O = 0);
313
+ const yt = { ...y, x: b, y: F, w: $, ...y.minW !== void 0 ? { minW: Math.min(y.minW, $) } : {} };
314
+ return b += $, O = Math.max(O, y.h), yt;
315
+ }), Z = F + O, xt = a.filter((y) => !p.has(y.i)).map((y) => y.y >= w && Z > h ? { ...y, y: y.y + (Z - h) } : y);
316
+ return M(P([...xt, ...pt], o.frameOrder));
317
+ }
318
+ if (i === "chart") {
319
+ const d = l[l.length - 1], m = (d == null ? void 0 : d.length) === 1 ? d[0] : void 0;
320
+ return m && x(m) === "chart" && (m.x + m.w <= 24 || m.x >= 24) ? f({ ...H(t, i, 24), x: m.x + m.w <= 24 ? 24 : 0, y: m.y }) : f({ ...H(t, i, 24), y: I(a) });
321
+ }
322
+ return f({ ...H(t, i, g), y: I(a) });
323
+ }
324
+ function dt(n, t, i) {
325
+ const e = Math.max(1, Math.min(i, Math.round(t.w * i / g)));
326
+ return [...n, ft({ ...t, x: 0, y: I(n), w: e }, i)];
327
+ }
328
+ const V = ["md", "sm", "xs", "xxs"], ut = [];
329
+ function A(n) {
330
+ const t = n.map((i) => i.id);
331
+ return {
332
+ frames: n,
333
+ ids: t,
334
+ kinds: new Map(n.map((i) => [i.id, K(i)])),
335
+ frameOrder: At(t)
336
+ };
337
+ }
338
+ function _(n) {
339
+ return typeof n == "number" && Number.isFinite(n) ? Math.round(n) : void 0;
340
+ }
341
+ function T(n, t, i) {
342
+ const e = new Set(i.ids), o = /* @__PURE__ */ new Map();
343
+ if (!Array.isArray(n)) return o;
344
+ for (const r of n) {
345
+ if (!r || typeof r != "object") continue;
346
+ const s = r, a = s.i;
347
+ if (typeof a != "string" || !e.has(a) || o.has(a)) continue;
348
+ const f = i.kinds.get(a) ?? "chart", x = _(s.minH), l = Math.max(1, Math.min(_(s.w) ?? Math.min(E[f], t), t)), u = Math.max(_(s.h) ?? L[f].h, x ?? 1, 1), d = {
349
+ i: a,
350
+ x: Math.max(0, Math.min(_(s.x) ?? 0, t - l)),
351
+ y: Math.max(0, _(s.y) ?? Number.MAX_SAFE_INTEGER),
352
+ w: l,
353
+ h: u
354
+ }, m = _(s.minW);
355
+ m !== void 0 && (d.minW = Math.max(1, Math.min(m, l))), x !== void 0 && (d.minH = Math.max(1, Math.min(x, u)));
356
+ const c = _(s.maxW);
357
+ c !== void 0 && (d.maxW = Math.max(c, l));
358
+ const p = _(s.maxH);
359
+ p !== void 0 && (d.maxH = Math.max(p, u)), typeof s.static == "boolean" && (d.static = s.static), typeof s.isResizable == "boolean" && (d.isResizable = s.isResizable), typeof s.isDraggable == "boolean" && (d.isDraggable = s.isDraggable), o.set(a, d);
360
+ }
361
+ return o;
362
+ }
363
+ function Lt(n, t) {
364
+ return t.ids.every((i) => n.has(i));
365
+ }
366
+ function D(n, t) {
367
+ return t.ids.flatMap((i) => n.has(i) ? [n.get(i)] : []);
368
+ }
369
+ function X(n, t) {
370
+ const i = M(D(n, t)), e = new Map(i.map((r) => [r.i, r]));
371
+ let o = I(i);
372
+ for (const r of t.ids) {
373
+ if (e.has(r)) continue;
374
+ const s = t.kinds.get(r) ?? "chart", a = L[s], f = E[s];
375
+ e.set(r, { i: r, x: 0, y: o, w: f, h: a.h, minW: Math.min(a.minW, f), minH: a.minH }), o += a.h;
376
+ }
377
+ return M(t.ids.map((r) => e.get(r)));
378
+ }
379
+ function Ct(n, t) {
380
+ const i = g / t;
381
+ return n.map((e) => {
382
+ if (!e || typeof e != "object") return e;
383
+ const o = e, r = _(o.x), s = _(o.w);
384
+ if (r === void 0 || s === void 0) return o;
385
+ const a = Math.round(r * i), f = Math.round((r + s) * i);
386
+ return { ...o, x: a, w: Math.max(1, f - a) };
387
+ });
388
+ }
389
+ function $t(n) {
390
+ const t = n.layouts ?? {};
391
+ if (Array.isArray(t.lg)) return t.lg;
392
+ if (Array.isArray(n.layout)) return n.layout;
393
+ for (const i of V) {
394
+ const e = t[i];
395
+ if (Array.isArray(e)) return Ct(e, v.columns[i]);
396
+ }
397
+ return [];
398
+ }
399
+ function nt(n, t) {
400
+ var i;
401
+ return (i = n.layouts) == null ? void 0 : i[t];
402
+ }
403
+ function mt(n, t, i, e) {
404
+ let o = M(D(n, e));
405
+ for (const r of t)
406
+ n.has(r.i) || (o = dt(o, r, v.columns[i]));
407
+ return M(U(o, e));
408
+ }
409
+ function U(n, t) {
410
+ return n.slice().sort((i, e) => (t.frameOrder.get(i.i) ?? 0) - (t.frameOrder.get(e.i) ?? 0));
411
+ }
412
+ const Rt = ["i", "x", "y", "w", "h", "minW", "minH", "maxW", "maxH", "static", "isResizable", "isDraggable"];
413
+ function lt(n, t) {
414
+ return !Array.isArray(n) || n.length !== t.length ? !1 : t.every((i, e) => {
415
+ const o = n[e];
416
+ return !!o && Rt.every((r) => o[r] === i[r]);
417
+ });
418
+ }
419
+ function Dt(n, t) {
420
+ const i = new Map(t.map((e) => [e.i, e]));
421
+ return n.length === t.length && n.every((e) => {
422
+ const o = i.get(e.i);
423
+ return !!o && o.x === e.x && o.y === e.y && o.w === e.w && o.h === e.h;
424
+ });
425
+ }
426
+ function Nt(n, t) {
427
+ return v.breakpoints.every((i) => lt(n[i], t[i]));
428
+ }
429
+ function Ft(n) {
430
+ return v.customizable.filter((t) => n.includes(t));
431
+ }
432
+ function ht(n, t, i) {
433
+ const e = { lg: n };
434
+ for (const o of V)
435
+ e[o] = i[o] ?? at(o, n, t.kinds, t.frameOrder);
436
+ return e;
437
+ }
438
+ function jt(n, t) {
439
+ return R(B(n, t.frameOrder)).map((i) => ({
440
+ tiles: i.map((e) => ({ frameId: e.i, kind: t.kinds.get(e.i) ?? "chart", width: _t(e.w) }))
441
+ }));
442
+ }
443
+ function Pt(n) {
444
+ const t = A(n.frames ?? ut), i = X(T($t(n), g, t), t), e = Array.isArray(n.customizedBreakpoints), o = {}, r = [];
445
+ for (const f of V) {
446
+ const x = v.columns[f], l = T(nt(n, f), x, t), u = Lt(l, t) && t.ids.length > 0;
447
+ if (q(f)) {
448
+ if (e && n.customizedBreakpoints.includes(f)) {
449
+ o[f] = mt(l, i, f, t), r.push(f);
450
+ continue;
451
+ }
452
+ if (!e && u) {
453
+ const m = M(D(l, t));
454
+ Dt(m, at(f, i, t.kinds, t.frameOrder)) || (o[f] = m, r.push(f));
455
+ }
456
+ continue;
457
+ }
458
+ !e && u && (o[f] = M(D(l, t)));
459
+ }
460
+ const s = ht(i, t, o), a = v.breakpoints.some((f) => !lt(nt(n, f), s[f]));
461
+ return { layouts: s, customizedBreakpoints: r, rows: jt(i, t), repaired: a };
462
+ }
463
+ function z(n) {
464
+ return { ok: !1, failure: n };
465
+ }
466
+ function it(n, t, i) {
467
+ const e = L[i];
468
+ return n.map((o) => o.i === t ? { ...o, h: e.h, minH: e.minH, minW: Math.min(e.minW, o.w) } : o);
469
+ }
470
+ function Gt(n, t) {
471
+ const i = Pt(n), e = n.frames ?? ut;
472
+ let o = e, r = i.layouts.lg, s = i.customizedBreakpoints.slice();
473
+ const a = {};
474
+ for (const u of s) a[u] = i.layouts[u];
475
+ switch (t.kind) {
476
+ case "frame_added": {
477
+ const { frame: u, placement: d } = t;
478
+ if (e.some((h) => h.id === u.id))
479
+ return z({ code: "frame_already_on_sheet", frameId: u.id, message: `A frame with id ${u.id} is already on this sheet.` });
480
+ const m = d == null ? void 0 : d.position, c = typeof m == "object" ? "after" in m ? m.after : m.beside : void 0;
481
+ if (c !== void 0 && !e.some((h) => h.id === c))
482
+ return z({ code: "position_target_not_found", frameId: c, message: `No frame ${c} on this sheet to place the new frame next to.` });
483
+ if (m === "top") o = [u, ...e];
484
+ else if (c !== void 0) {
485
+ const h = e.findIndex((k) => k.id === c);
486
+ o = [...e.slice(0, h + 1), u, ...e.slice(h + 1)];
487
+ } else o = [...e, u];
488
+ const p = A(o);
489
+ r = Bt(r, u.id, p.kinds.get(u.id), d, p);
490
+ const w = r.find((h) => h.i === u.id);
491
+ for (const h of s) {
492
+ const k = v.columns[h], W = a[h], b = typeof m == "object" && "beside" in m ? ct(W, m.beside, u.id, k) : dt(W, w, k);
493
+ a[h] = M(U(b, p));
494
+ }
495
+ break;
496
+ }
497
+ case "frame_removed": {
498
+ if (!e.some((u) => u.id === t.frameId))
499
+ return z({ code: "frame_not_on_sheet", frameId: t.frameId, message: `No frame ${t.frameId} on this sheet.` });
500
+ o = e.filter((u) => u.id !== t.frameId), r = M(r.filter((u) => u.i !== t.frameId));
501
+ for (const u of s)
502
+ a[u] = M(a[u].filter((d) => d.i !== t.frameId));
503
+ break;
504
+ }
505
+ case "frame_updated": {
506
+ const u = e.findIndex((c) => c.id === t.frame.id);
507
+ if (u < 0)
508
+ return z({ code: "frame_not_on_sheet", frameId: t.frame.id, message: `No frame ${t.frame.id} on this sheet.` });
509
+ o = e.map((c, p) => p === u ? t.frame : c);
510
+ const d = K(e[u]), m = K(t.frame);
511
+ if (d === m)
512
+ return {
513
+ ok: !0,
514
+ frames: o,
515
+ layouts: i.layouts,
516
+ customizedBreakpoints: i.customizedBreakpoints,
517
+ changed: !0,
518
+ layoutsChanged: !1
519
+ };
520
+ if (t.resizeForNewKind && J(d) !== J(m)) {
521
+ r = M(it(r, t.frame.id, m));
522
+ for (const c of s)
523
+ a[c] = M(it(a[c], t.frame.id, m));
524
+ }
525
+ break;
526
+ }
527
+ case "grid_edited": {
528
+ if (!bt(t.breakpoint))
529
+ return z({ code: "breakpoint_not_editable", breakpoint: String(t.breakpoint), message: `The ${String(t.breakpoint)} layout is derived; edit Desktop, Tablet or Phone.` });
530
+ const u = A(e);
531
+ if (t.breakpoint === "md") {
532
+ const d = [...T(t.items, v.columns.md, u).values()];
533
+ r = X(new Map(St(r, d).map((m) => [m.i, m])), u);
534
+ } else if (t.breakpoint === "lg")
535
+ r = X(T(t.items, g, u), u);
536
+ else {
537
+ const d = t.breakpoint;
538
+ a[d] = mt(T(t.items, v.columns[d], u), r, d, u), s.includes(d) || (s = Ft([...s, d]));
539
+ }
540
+ break;
541
+ }
542
+ case "reset_to_automatic": {
543
+ if (!q(t.breakpoint))
544
+ return z({ code: "breakpoint_not_editable", breakpoint: String(t.breakpoint), message: "Only Tablet and Phone can go back to automatic." });
545
+ s = s.filter((u) => u !== t.breakpoint), delete a[t.breakpoint];
546
+ break;
547
+ }
548
+ case "arrange": {
549
+ const u = A(e), d = Et(r, u.kinds, u.frameOrder, t.keepOrder === !0), m = new Map(e.map((c) => [c.id, c]));
550
+ o = d.order.map((c) => m.get(c)), o.every((c, p) => c === e[p]) && (o = e), r = d.items, s = [];
551
+ for (const c of v.customizable) delete a[c];
552
+ break;
553
+ }
554
+ }
555
+ const f = A(o);
556
+ r = U(r, f);
557
+ const x = ht(r, f, a), l = !Nt(x, i.layouts) || s.join() !== i.customizedBreakpoints.join();
558
+ return { ok: !0, frames: o, layouts: x, customizedBreakpoints: s, changed: o !== e || l, layoutsChanged: l };
559
+ }
560
+ function Kt(n, t) {
561
+ const i = [...t].sort().join("\0");
562
+ for (const e of v.breakpoints) {
563
+ const o = n[e], r = v.columns[e];
564
+ if (!Array.isArray(o)) throw new Error(`Layout ${e} is missing.`);
565
+ if (o.map((s) => s.i).sort().join("\0") !== i) throw new Error(`Layout ${e} doesn't hold exactly the sheet's frames.`);
566
+ for (const s of o) {
567
+ if (![s.x, s.y, s.w, s.h].every(Number.isInteger)) throw new Error(`Layout ${e}: ${s.i} has a non-integer position or size.`);
568
+ if (s.x < 0 || s.y < 0 || s.w < 1 || s.w > r || s.x + s.w > r || s.h < 1)
569
+ throw new Error(`Layout ${e}: ${s.i} is out of bounds.`);
570
+ if (s.minW !== void 0 && (s.minW < 1 || s.minW > s.w)) throw new Error(`Layout ${e}: ${s.i} minW out of range.`);
571
+ if (s.minH !== void 0 && (s.minH < 1 || s.minH > s.h)) throw new Error(`Layout ${e}: ${s.i} minH out of range.`);
572
+ if (s.maxW !== void 0 && s.maxW < s.w) throw new Error(`Layout ${e}: ${s.i} maxW below w.`);
573
+ if (s.maxH !== void 0 && s.maxH < s.h) throw new Error(`Layout ${e}: ${s.i} maxH below h.`);
574
+ }
575
+ if (Ot(o)) throw new Error(`Layout ${e} has overlapping items.`);
576
+ if (!It(o)) throw new Error(`Layout ${e} isn't packed.`);
577
+ }
578
+ }
579
+ export {
580
+ v as D,
581
+ gt as T,
582
+ Gt as a,
583
+ Kt as b,
584
+ kt as i,
585
+ Pt as r
586
+ };