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,1606 +1,11 @@
1
- import { jsxs as d, jsx as r, Fragment as ue } from "react/jsx-runtime";
2
- import g, { useState as pe } from "react";
3
- import { c as de, P as be, N as B, S as M, a as Ye, b as We, d as Ce, e as ye, f as Ne, B as S, g as qe, h as Se, C as Ke, R as we, L as fe, X as Xe, i as me, j as Ze, T as Qe, k as er, l as V, m as rr, n as G, o as or, p as ar, q as nr, r as tr, s as E, t as Q, u as ee, v as re, I as Fe, w as oe, x as ae, y as Pe, z as Oe, A as Te, D as Be, E as Re } from "../chunks/style-sheet-parts-CDCG-8Ej.js";
4
- import { v as dr, A as ne, d as cr, p as sr } from "../chunks/schema-C9NPiIru.js";
5
- import { S as j, C as lr, a as ge, c as te } from "../chunks/pickers-DkqmtnTL.js";
6
- import "../chunks/validators-Baf3VIf5.js";
7
- import "../chunks/matrix-operation-contract-DPBj69D8.js";
8
- import "../chunks/analytics-base-schemas-DsUh5Q3C.js";
9
- import "../value-format-preferences/index.js";
10
- import { e as ir } from "../chunks/brand-BoUV0iHF.js";
11
- import { b as ur, D as pr } from "../chunks/edit-9df1zOWe.js";
12
- import { n as Ee } from "../chunks/index-BVKzKl5d.js";
13
- import { b as br } from "../chunks/resolver-DG_tfEpt.js";
14
- import { P as H } from "../chunks/palette-Be62Tkoa.js";
15
- import { U as fr } from "../chunks/upload-H15d7uHK.js";
16
- import { S as mr } from "../chunks/save-C5A0JnEV.js";
17
- import { L as gr } from "../chunks/layout-grid-9LndRoLa.js";
18
- /**
1
+ var gr=Object.defineProperty;var fr=(e,n,o)=>n in e?gr(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o;var De=(e,n,o)=>fr(e,typeof n!="symbol"?n+"":n,o);import{jsxs as i,jsx as r,Fragment as T}from"react/jsx-runtime";import k from"react";import{c as Ie,U as mr,V as R,W as We,Y as je,Z as Ye,_ as Je,$ as vr,a0 as yr,a1 as Ue,P as xr,b as kr,e as Sr,a2 as Cr,a3 as Se,a4 as wr,a5 as Nr,a6 as Tr,a7 as Fr,a8 as Er,a9 as Or,aa as He,ab as Pr,B,ac as Ve,ad as Ar,X as Ge,C as Rr,ae as Dr,af as Br,ag as Be,ah as zr,ai as _r,aj as $r,ak as Lr,al as Mr,am as Ir,g as Wr}from"../chunks/appearance-provider-CfoAVQuG.js";import{k as N,a6 as ze,a7 as jr}from"../chunks/resolve-dashboard-input-context-BDY7KwRe.js";import"../chunks/validators-Dg2kyF4_.js";import"../chunks/matrix-operation-contract-CWvcEsQ0.js";import"../chunks/analytics-base-schemas-DMFrDqn_.js";import"../value-format-preferences/index.js";import{A as ce,v as Yr,p as be,S as Jr,d as ie}from"../chunks/schema-O1Y3WTGF.js";import{e as Ur}from"../chunks/brand-C9APUFaP.js";import{n as Xe}from"../chunks/index-bkP6SnYu.js";import{b as Ke}from"../chunks/resolver-CjsW8Rz0.js";import{c as Hr,u as Vr}from"../chunks/appearance-runtime-provider-Bx8H-moR.js";import{e as Ce,D as _e}from"../chunks/filter-reach-preview-C5M5_hf_.js";import{P as Gr}from"../chunks/palette-NvEIuXHN.js";import{L as Xr}from"../chunks/layout-grid-CFzqJ7GC.js";/**
19
2
  * @license lucide-react v0.453.0 - ISC
20
3
  *
21
4
  * This source code is licensed under the ISC license.
22
5
  * See the LICENSE file in the root directory of this source tree.
23
- */
24
- const hr = de("Ban", [
25
- ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
26
- ["path", { d: "m4.9 4.9 14.2 14.2", key: "1m5liu" }]
27
- ]);
28
- /**
6
+ */const Kr=Ie("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
29
7
  * @license lucide-react v0.453.0 - ISC
30
8
  *
31
9
  * This source code is licensed under the ISC license.
32
10
  * See the LICENSE file in the root directory of this source tree.
33
- */
34
- const xr = de("Clipboard", [
35
- ["rect", { width: "8", height: "4", x: "8", y: "2", rx: "1", ry: "1", key: "tgr4d6" }],
36
- [
37
- "path",
38
- {
39
- d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",
40
- key: "116196"
41
- }
42
- ]
43
- ]);
44
- /**
45
- * @license lucide-react v0.453.0 - ISC
46
- *
47
- * This source code is licensed under the ISC license.
48
- * See the LICENSE file in the root directory of this source tree.
49
- */
50
- const vr = de("Pipette", [
51
- ["path", { d: "m2 22 1-1h3l9-9", key: "1sre89" }],
52
- ["path", { d: "M3 21v-3l9-9", key: "hpe2y6" }],
53
- [
54
- "path",
55
- {
56
- d: "m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",
57
- key: "196du1"
58
- }
59
- ]
60
- ]), kr = [
61
- { value: "none", label: "None" },
62
- { value: "compact", label: "Compact" },
63
- { value: "default", label: "Default" },
64
- { value: "roomy", label: "Roomy" }
65
- ], he = [
66
- { value: "outlined", label: "Outlined", note: "A border on a muted canvas" },
67
- { value: "raised", label: "Raised", note: "A shadow and no border on a muted canvas" },
68
- { value: "open", label: "Open", note: "No border or shadow on a plain canvas" }
69
- ], Cr = [
70
- { value: "square", label: "Square" },
71
- { value: "subtle", label: "Subtle" },
72
- { value: "rounded", label: "Rounded" },
73
- { value: "round", label: "Round" }
74
- ];
75
- function yr({
76
- spec: e,
77
- mode: a,
78
- onEdit: n
79
- }) {
80
- var F;
81
- const c = ur({ organizationAppearance: e }, a), s = c.authored, [f, h] = pe(null), [x, v] = pe(!1), b = (l) => h(n(l)), i = (l) => pr[l], p = s.canvas === "muted" ? "muted" : s.canvas === "background" ? "background" : "color", y = (l) => ({ [a]: l });
82
- return /* @__PURE__ */ d("div", { className: "-mx-4", children: [
83
- /* @__PURE__ */ r(
84
- be,
85
- {
86
- label: "Spacing",
87
- options: kr.map((l) => ({
88
- ...l,
89
- title: `${j[l.value]} px between cards and around them`,
90
- preview: { ...s, spacing: j[l.value], canvasPadding: j[l.value] }
91
- })),
92
- lit: c.pickers.spacing,
93
- note: "Card sizes never change with spacing.",
94
- changed: c.source.spacing === "organization" || c.source.canvasPadding === "organization",
95
- resetTitle: `Back to the default: ${j.default} px`,
96
- onPick: (l) => b({ spacing: l }),
97
- onReset: () => b({ reset: ["spacing", "canvasPadding"] }),
98
- children: /* @__PURE__ */ d("div", { className: "mt-2 flex items-center gap-1.5", children: [
99
- /* @__PURE__ */ r("span", { className: "text-[11px] text-muted-foreground", children: "Gap" }),
100
- /* @__PURE__ */ r(B, { value: s.spacing, ...i("spacing"), onChange: (l) => b({ spacing: l }) }),
101
- /* @__PURE__ */ r("span", { className: "ml-2 text-[11px] text-muted-foreground", children: "Canvas padding" }),
102
- /* @__PURE__ */ r(B, { value: s.canvasPadding, ...i("canvasPadding"), onChange: (l) => b({ canvasPadding: l }) })
103
- ] })
104
- }
105
- ),
106
- /* @__PURE__ */ r(
107
- be,
108
- {
109
- label: "Cards",
110
- options: he.map((l) => ({ value: l.value, label: l.label, title: l.note, preview: { ...s, ...lr[l.value] } })),
111
- lit: c.pickers.cards,
112
- note: ((F = he.find((l) => l.value === c.pickers.cards)) == null ? void 0 : F.note) ?? "Your own mix of border, shadow and canvas",
113
- changed: ["cardBorder", "cardShadow", "canvas"].some((l) => c.source[l] === "organization"),
114
- resetTitle: "Back to the default cards",
115
- onPick: (l) => b({ cards: l }),
116
- onReset: () => b({ reset: ["cards"] })
117
- }
118
- ),
119
- /* @__PURE__ */ d("div", { className: "grid gap-2 px-4 pb-3", children: [
120
- /* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-2", children: [
121
- /* @__PURE__ */ d("span", { className: "w-24 text-[12px] text-muted-foreground", children: [
122
- "Canvas (",
123
- a,
124
- ")"
125
- ] }),
126
- /* @__PURE__ */ r(
127
- M,
128
- {
129
- label: "Canvas background",
130
- value: p,
131
- onChange: (l) => b({ canvas: y(l === "color" ? a === "dark" ? "#111318" : "#f4f6f8" : l) }),
132
- options: [
133
- { value: "muted", label: "Muted" },
134
- { value: "background", label: "Plain" },
135
- { value: "color", label: "Custom" }
136
- ]
137
- }
138
- ),
139
- p === "color" ? /* @__PURE__ */ r(Ye, { color: We(s.canvas), label: "Canvas color", onChange: (l) => b({ canvas: y(l) }) }) : null
140
- ] }),
141
- /* @__PURE__ */ d("div", { className: "flex flex-wrap items-center gap-2", children: [
142
- /* @__PURE__ */ r("span", { className: "w-24 text-[12px] text-muted-foreground", children: "Corners" }),
143
- /* @__PURE__ */ r(
144
- M,
145
- {
146
- label: "Corners",
147
- value: c.pickers.corners,
148
- onChange: (l) => b({ corners: l }),
149
- options: Cr.map((l) => ({
150
- ...l,
151
- title: `Cards ${ge[l.value].cardCorners} px, controls ${ge[l.value].controlCorners} px`
152
- }))
153
- }
154
- ),
155
- /* @__PURE__ */ r("button", { type: "button", className: "text-[11px] text-foreground underline-offset-2 hover:underline", onClick: () => v(!x), children: x || !c.pickers.corners ? "Hide" : "Set separately" })
156
- ] }),
157
- x || !c.pickers.corners ? /* @__PURE__ */ d("div", { className: "flex items-center gap-1.5 pl-[104px]", children: [
158
- /* @__PURE__ */ r("span", { className: "text-[11px] text-muted-foreground", children: "Cards" }),
159
- /* @__PURE__ */ r(B, { value: s.cardCorners, ...i("cardCorners"), onChange: (l) => b({ corners: { cards: l } }) }),
160
- /* @__PURE__ */ r("span", { className: "ml-1 text-[11px] text-muted-foreground", children: "Controls" }),
161
- /* @__PURE__ */ r(B, { value: s.controlCorners, ...i("controlCorners"), onChange: (l) => b({ corners: { controls: l } }) })
162
- ] }) : null,
163
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
164
- /* @__PURE__ */ r("span", { className: "w-24 text-[12px] text-muted-foreground", children: "Card border" }),
165
- /* @__PURE__ */ r(Ce, { checked: s.cardBorder === "on", onCheckedChange: (l) => b({ border: l ? "on" : "off" }), "aria-label": "Card border" }),
166
- /* @__PURE__ */ r("span", { className: "ml-4 w-20 text-[12px] text-muted-foreground", children: "Shadow" }),
167
- /* @__PURE__ */ r(
168
- M,
169
- {
170
- label: "Card shadow",
171
- value: s.cardShadow === "custom" ? null : s.cardShadow,
172
- onChange: (l) => b({ shadow: l }),
173
- options: [
174
- { value: "none", label: "None" },
175
- { value: "subtle", label: "Subtle" },
176
- { value: "raised", label: "Raised" }
177
- ]
178
- }
179
- )
180
- ] }),
181
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
182
- /* @__PURE__ */ r("span", { className: "w-24 text-[12px] text-muted-foreground", children: "Bar corners" }),
183
- /* @__PURE__ */ r(B, { value: s.barCorners, ...i("barCorners"), onChange: (l) => b({ barCorners: l }) })
184
- ] }),
185
- f ? /* @__PURE__ */ d("p", { role: "alert", className: "text-[12px] text-destructive", children: [
186
- f.message,
187
- " ",
188
- f.fix
189
- ] }) : null
190
- ] })
191
- ] });
192
- }
193
- const Ae = [
194
- {
195
- id: "semaphor",
196
- name: "Semaphor",
197
- description: "Dense neutral system defaults for embedded analytics.",
198
- primary: "#18181b",
199
- accent: "#f4f4f5",
200
- light: {
201
- background: "#ffffff",
202
- foreground: "#18181b",
203
- muted: "#fafafa",
204
- mutedForeground: "#71717a",
205
- border: "#e4e4e7",
206
- primary: "#18181b",
207
- primaryForeground: "#ffffff",
208
- accent: "#f4f4f5",
209
- accentForeground: "#18181b",
210
- selection: "#2563eb",
211
- card: "#ffffff",
212
- cardForeground: "#18181b",
213
- chartPalette: [
214
- "#3b82f6",
215
- "#10b981",
216
- "#f59e0b",
217
- "#ef4444",
218
- "#8b5cf6",
219
- "#06b6d4"
220
- ]
221
- },
222
- dark: {
223
- background: "#09090b",
224
- foreground: "#fafafa",
225
- muted: "#18181b",
226
- mutedForeground: "#a1a1aa",
227
- border: "#27272a",
228
- primary: "#fafafa",
229
- primaryForeground: "#09090b",
230
- accent: "#27272a",
231
- accentForeground: "#fafafa",
232
- selection: "#5090f7",
233
- card: "#09090b",
234
- cardForeground: "#fafafa",
235
- chartPalette: [
236
- "#60a5fa",
237
- "#34d399",
238
- "#fbbf24",
239
- "#f87171",
240
- "#a78bfa",
241
- "#22d3ee"
242
- ]
243
- }
244
- },
245
- {
246
- id: "atlas-blue",
247
- name: "Atlas Blue",
248
- description: "Crisp enterprise blue with restrained neutral surfaces.",
249
- primary: "#2563eb",
250
- accent: "#dbeafe",
251
- light: {
252
- background: "#f8fafc",
253
- foreground: "#0f172a",
254
- muted: "#f1f5f9",
255
- mutedForeground: "#64748b",
256
- border: "#cbd5e1",
257
- primary: "#2563eb",
258
- primaryForeground: "#ffffff",
259
- accent: "#dbeafe",
260
- accentForeground: "#1e3a8a",
261
- selection: "#2563eb",
262
- card: "#ffffff",
263
- cardForeground: "#0f172a",
264
- chartPalette: [
265
- "#2563eb",
266
- "#0f766e",
267
- "#ca8a04",
268
- "#dc2626",
269
- "#7c3aed",
270
- "#0891b2"
271
- ]
272
- },
273
- dark: {
274
- background: "#020617",
275
- foreground: "#e2e8f0",
276
- muted: "#0f172a",
277
- mutedForeground: "#94a3b8",
278
- border: "#1e293b",
279
- primary: "#60a5fa",
280
- primaryForeground: "#020617",
281
- accent: "#1e3a8a",
282
- accentForeground: "#dbeafe",
283
- selection: "#60a5fa",
284
- card: "#0f172a",
285
- cardForeground: "#e2e8f0",
286
- chartPalette: [
287
- "#60a5fa",
288
- "#2dd4bf",
289
- "#facc15",
290
- "#f87171",
291
- "#a78bfa",
292
- "#22d3ee"
293
- ]
294
- }
295
- },
296
- {
297
- id: "field-green",
298
- name: "Field Green",
299
- description: "Operational green accents with quiet, readable canvases.",
300
- primary: "#047857",
301
- accent: "#d1fae5",
302
- light: {
303
- background: "#fbfdfb",
304
- foreground: "#10231d",
305
- muted: "#f1f5f3",
306
- mutedForeground: "#64746d",
307
- border: "#d7ded9",
308
- primary: "#047857",
309
- primaryForeground: "#ffffff",
310
- accent: "#d1fae5",
311
- accentForeground: "#064e3b",
312
- selection: "#047857",
313
- card: "#ffffff",
314
- cardForeground: "#10231d",
315
- chartPalette: [
316
- "#047857",
317
- "#2563eb",
318
- "#d97706",
319
- "#dc2626",
320
- "#7c3aed",
321
- "#0891b2"
322
- ]
323
- },
324
- dark: {
325
- background: "#071511",
326
- foreground: "#e7f4ef",
327
- muted: "#10231d",
328
- mutedForeground: "#92aaa1",
329
- border: "#244139",
330
- primary: "#34d399",
331
- primaryForeground: "#071511",
332
- accent: "#064e3b",
333
- accentForeground: "#d1fae5",
334
- selection: "#34d399",
335
- card: "#0b1d17",
336
- cardForeground: "#e7f4ef",
337
- chartPalette: [
338
- "#34d399",
339
- "#60a5fa",
340
- "#fbbf24",
341
- "#f87171",
342
- "#a78bfa",
343
- "#22d3ee"
344
- ]
345
- }
346
- }
347
- ];
348
- function R(e) {
349
- const a = br({
350
- organizationAppearance: e ? Ee(e).spec : void 0
351
- });
352
- return Nr(
353
- ze(J(a))
354
- );
355
- }
356
- function Nr(e) {
357
- var a;
358
- for (const n of Object.values(e.schemes)) {
359
- const c = (a = n.components.table) == null ? void 0 : a.row;
360
- c != null && c.selectedBackground && c.selectedBackground === c.hoverBackground && delete c.selectedBackground;
361
- }
362
- return e;
363
- }
364
- function $(e) {
365
- const a = J({
366
- version: ne,
367
- mode: e.mode,
368
- schemes: e.schemes
369
- }), n = dr(a);
370
- if (!n.success) {
371
- const c = n.issues[0];
372
- throw new Error(
373
- `Invalid Brand Studio appearance at ${c.path}: ${c.message}`
374
- );
375
- }
376
- return n.value;
377
- }
378
- function xe(e) {
379
- var n, c;
380
- const a = $(e);
381
- for (const s of ["light", "dark"]) {
382
- const f = (n = a.schemes) == null ? void 0 : n[s];
383
- if (!(f != null && f.components)) continue;
384
- const h = ze(
385
- J({ version: ne, mode: e.mode, schemes: { light: { tokens: f.tokens, components: {} }, dark: { tokens: f.tokens, components: {} } } })
386
- ).schemes[s].components;
387
- for (const x of Sr) {
388
- const v = f.components[x];
389
- if (v)
390
- for (const b of wr[x])
391
- v[b] !== void 0 && v[b] === ((c = h[x]) == null ? void 0 : c[b]) && delete v[b];
392
- }
393
- }
394
- return Ee(a).spec ?? { version: ne, mode: e.mode };
395
- }
396
- const Sr = ["dashboard", "card"], wr = {
397
- dashboard: ["foreground", "borderColor"],
398
- card: ["background", "foreground", "borderColor"]
399
- };
400
- function Fr(e, a) {
401
- const n = Ae.find((s) => s.id === a);
402
- if (!n)
403
- return e;
404
- const c = J(e);
405
- return ve(c.schemes.light, n.light), ve(c.schemes.dark, n.dark), c;
406
- }
407
- function ve(e, a) {
408
- e.tokens.color.background = a.background, e.tokens.color.foreground = a.foreground, e.tokens.color.muted = a.muted, e.tokens.color.mutedForeground = a.mutedForeground, e.tokens.color.border = a.border, e.tokens.color.input = a.border, e.tokens.color.primary = a.primary, e.tokens.color.primaryForeground = a.primaryForeground, e.tokens.color.accent = a.accent, e.tokens.color.accentForeground = a.accentForeground, e.tokens.color.selection = a.selection, e.tokens.color.card = a.card, e.tokens.color.cardForeground = a.cardForeground, e.components.dashboard.background = a.background, e.components.dashboard.foreground = a.foreground, e.components.dashboard.borderColor = a.border, e.components.card.background = a.card, e.components.card.foreground = a.cardForeground, e.components.card.borderColor = a.border, e.components.interactive.toolbarBackground = a.background, e.components.interactive.background = a.card, e.components.interactive.foreground = a.foreground, e.components.interactive.borderColor = a.border, e.components.chart.palette = [...a.chartPalette], e.components.chart.background = a.card, e.components.chart.foreground = a.foreground, e.components.chart.gridColor = a.border, e.components.chart.axisColor = a.mutedForeground, e.components.table.container.background = a.card, e.components.table.container.borderColor = a.border, e.components.table.header.background = a.muted, e.components.table.header.foreground = a.mutedForeground, e.components.table.header.dividerColor = a.border, e.components.table.row.dividerColor = a.border, e.components.table.row.zebraBackground = a.muted, e.components.table.pagination.background = a.card, e.components.table.pagination.foreground = a.foreground, e.components.table.pagination.borderColor = a.border;
409
- }
410
- function Y(e, a, n) {
411
- switch (e.tokens.color[a] = n, a) {
412
- case "background":
413
- e.components.dashboard.background = n, e.components.interactive.toolbarBackground = n;
414
- break;
415
- case "foreground":
416
- e.components.dashboard.foreground = n, e.components.interactive.foreground = n, e.components.pagination.foreground = n, e.components.chart.foreground = n, e.components.table.pagination.foreground = n, e.components.table.subtotal.foreground = n, e.components.table.grandTotal.foreground = n;
417
- break;
418
- case "card":
419
- e.components.card.background = n, e.components.interactive.background = n, e.components.pagination.background = n, e.components.chart.background = n, e.components.table.container.background = n, e.components.table.pagination.background = n;
420
- break;
421
- case "cardForeground":
422
- e.components.card.foreground = n;
423
- break;
424
- case "muted":
425
- e.components.table.header.background = n, e.components.table.row.zebraBackground = n, e.components.table.subtotal.background = n, e.components.table.grandTotal.background = n;
426
- break;
427
- case "mutedForeground":
428
- e.components.table.header.foreground = n, e.components.chart.axisColor = n;
429
- break;
430
- case "border":
431
- e.tokens.color.input = n, e.components.dashboard.borderColor = n, e.components.card.borderColor = n, e.components.interactive.borderColor = n, e.components.pagination.borderColor = n, e.components.chart.gridColor = n, e.components.table.container.borderColor = n, e.components.table.header.dividerColor = n, e.components.table.row.dividerColor = n, e.components.table.grandTotal.borderColor = n, e.components.table.pagination.borderColor = n;
432
- break;
433
- case "accent":
434
- e.components.table.row.hoverBackground = n;
435
- break;
436
- }
437
- }
438
- function Pr(e, a, n) {
439
- switch (e.tokens.radius[a] = n, a) {
440
- case "table":
441
- e.components.table.container.borderRadius = n;
442
- break;
443
- }
444
- }
445
- function ze(e) {
446
- for (const a of ["light", "dark"]) {
447
- const n = e.schemes[a], c = n.tokens, s = c.color, f = {
448
- fontFamily: "",
449
- headingFontFamily: "",
450
- monoFontFamily: "",
451
- baseFontSize: 14,
452
- density: "comfortable"
453
- };
454
- c.typography = { ...f, ...c.typography };
455
- const h = {
456
- control: 5,
457
- card: 5,
458
- table: 5,
459
- badge: 999
460
- };
461
- c.radius = { ...h, ...c.radius };
462
- const x = {
463
- dashboardPadding: 16,
464
- gridGap: 12,
465
- cardPadding: 16,
466
- controlGap: 8,
467
- tableCellX: 12,
468
- tableCellY: 8
469
- };
470
- c.spacing = { ...x, ...c.spacing };
471
- const v = {
472
- card: "none",
473
- popover: "0 12px 32px rgba(15, 23, 42, 0.14)",
474
- focusRing: "0 0 0 2px rgba(37, 99, 235, 0.35)"
475
- };
476
- c.shadow = { ...v, ...c.shadow };
477
- const b = {
478
- dashboard: {
479
- background: s.background,
480
- foreground: s.foreground,
481
- borderColor: s.border
482
- },
483
- card: {
484
- background: s.card,
485
- foreground: s.cardForeground,
486
- borderColor: s.border
487
- },
488
- interactive: {
489
- toolbarBackground: s.background,
490
- background: s.card,
491
- foreground: s.foreground,
492
- borderColor: s.border
493
- },
494
- chart: {
495
- palette: [],
496
- background: s.card,
497
- foreground: s.foreground,
498
- gridColor: s.border,
499
- axisColor: s.mutedForeground,
500
- barRadius: 0
501
- },
502
- table: ke(s, c),
503
- pagination: {
504
- background: s.card,
505
- foreground: s.foreground,
506
- borderColor: s.border
507
- }
508
- };
509
- n.components = Object.fromEntries(
510
- Object.entries({ ...b, ...n.components }).map(([p, y]) => [
511
- p,
512
- { ...b[p], ...y }
513
- ])
514
- );
515
- const i = {
516
- palette: [],
517
- background: s.card,
518
- foreground: s.foreground,
519
- gridColor: s.border,
520
- axisColor: s.mutedForeground,
521
- barRadius: 2
522
- };
523
- n.components.chart = { ...i, ...n.components.chart }, n.components.table = {
524
- ...ke(s, c),
525
- ...n.components.table
526
- };
527
- }
528
- return e;
529
- }
530
- function ke(e, a) {
531
- return {
532
- density: a.typography.density,
533
- container: {
534
- background: e.card,
535
- borderColor: e.border,
536
- borderRadius: a.radius.table,
537
- shadow: a.shadow.card
538
- },
539
- header: {
540
- background: e.muted,
541
- foreground: e.mutedForeground,
542
- dividerColor: e.border,
543
- fontWeight: 600,
544
- uppercase: !0,
545
- sticky: !0
546
- },
547
- row: {
548
- height: 32,
549
- dividerColor: e.border,
550
- zebra: !1,
551
- zebraBackground: e.muted,
552
- hoverBackground: e.accent
553
- },
554
- cell: {
555
- paddingX: a.spacing.tableCellX,
556
- paddingY: a.spacing.tableCellY,
557
- verticalAlign: "middle",
558
- wrap: "nowrap"
559
- },
560
- subtotal: {
561
- background: e.muted,
562
- foreground: e.foreground,
563
- fontWeight: 600
564
- },
565
- grandTotal: {
566
- background: e.muted,
567
- foreground: e.foreground,
568
- fontWeight: 700,
569
- borderColor: e.border
570
- },
571
- pagination: {
572
- background: e.card,
573
- foreground: e.foreground,
574
- borderColor: e.border
575
- }
576
- };
577
- }
578
- function J(e) {
579
- return JSON.parse(JSON.stringify(e));
580
- }
581
- const Or = [
582
- ["background", "Canvas"],
583
- ["foreground", "Text"],
584
- ["card", "Card"],
585
- ["cardForeground", "Card text"],
586
- ["primary", "Primary"],
587
- ["primaryForeground", "Primary text"],
588
- ["accent", "Accent"],
589
- ["accentForeground", "Accent text"],
590
- ["muted", "Muted"],
591
- ["mutedForeground", "Muted text"],
592
- ["border", "Border"],
593
- ["positive", "Positive"],
594
- ["negative", "Negative"],
595
- ["warning", "Warning"],
596
- ["info", "Info"]
597
- ], W = cr, Tr = [
598
- "#ffffff",
599
- "#f8fafc",
600
- "#f4f4f5",
601
- "#e4e4e7",
602
- "#18181b",
603
- "#09090b",
604
- "#2563eb",
605
- "#0f766e",
606
- "#047857",
607
- "#d97706",
608
- "#dc2626",
609
- "#7c3aed"
610
- ];
611
- function Zr({
612
- appearance: e,
613
- previewTitle: a,
614
- isLoading: n = !1,
615
- isSaving: c = !1,
616
- error: s = null,
617
- className: f,
618
- onDraftChange: h,
619
- onSave: x,
620
- onClearConfig: v,
621
- onCancel: b
622
- }) {
623
- const [i, p] = g.useState(null), [y, F] = g.useState("light"), [l, A] = g.useState(!1), [De, O] = g.useState(
624
- "idle"
625
- ), [ce, Ie] = g.useState(!1), [z, U] = g.useState(""), [D, C] = g.useState(null), se = g.useRef(null), I = g.useRef(h), T = g.useRef(!1);
626
- g.useEffect(() => {
627
- I.current = h;
628
- }, [h]), g.useEffect(() => {
629
- if (e === void 0) {
630
- T.current = !0, p(null);
631
- return;
632
- }
633
- const o = R(e);
634
- T.current = !0, p(o), F("light"), C(null);
635
- }, [e]), g.useEffect(() => {
636
- var o;
637
- if (i) {
638
- if (T.current) {
639
- T.current = !1;
640
- return;
641
- }
642
- try {
643
- const t = $(i);
644
- (o = I.current) == null || o.call(I, t), C(null);
645
- } catch (t) {
646
- C(
647
- t instanceof Error ? t.message : "Appearance is invalid"
648
- );
649
- }
650
- }
651
- }, [i]);
652
- const u = i == null ? void 0 : i.schemes[y], L = c || l, _e = g.useMemo(
653
- () => u ? Er(u.tokens.radius.control) : void 0,
654
- [u]
655
- ), je = (o) => {
656
- p((t) => {
657
- if (!t) return t;
658
- const k = Ar(t);
659
- return o(k), k;
660
- });
661
- }, m = (o) => {
662
- je((t) => {
663
- o(t.schemes[y]);
664
- });
665
- }, _ = g.useMemo(() => {
666
- if (!i) return null;
667
- try {
668
- return xe(i);
669
- } catch {
670
- return null;
671
- }
672
- }, [i]), $e = (o) => {
673
- if (!_) return null;
674
- const t = ir({ spec: _, edit: o, mode: y });
675
- return t.ok ? (p(R(t.spec)), null) : t.refusal;
676
- }, Je = async () => {
677
- if (!i || !x) return;
678
- let o;
679
- try {
680
- o = xe(i);
681
- } catch (t) {
682
- C(
683
- t instanceof Error ? t.message : "Appearance is invalid"
684
- );
685
- return;
686
- }
687
- A(!0);
688
- try {
689
- await x(o);
690
- } finally {
691
- A(!1);
692
- }
693
- }, Ue = () => {
694
- const o = R(null);
695
- O("idle"), p(o);
696
- }, Le = async () => {
697
- if (v) {
698
- A(!0), C(null), O("idle");
699
- try {
700
- await v(), T.current = !0, p(R(null)), F("light");
701
- } catch (o) {
702
- C(
703
- o instanceof Error ? o.message : "Unable to clear organization appearance"
704
- );
705
- } finally {
706
- A(!1);
707
- }
708
- }
709
- }, le = g.useCallback(() => i ? JSON.stringify($(i), null, 2) : "", [i]), Me = (o) => {
710
- if (Ie(o), o)
711
- try {
712
- U(le()), C(null);
713
- } catch (t) {
714
- C(
715
- t instanceof Error ? t.message : "Appearance is invalid"
716
- );
717
- }
718
- }, Ve = async () => {
719
- if (i)
720
- try {
721
- const o = ce && z ? z : le();
722
- await navigator.clipboard.writeText(o), C(null), O("copied");
723
- } catch (o) {
724
- C(
725
- o instanceof Error ? o.message : "Unable to copy brand spec"
726
- );
727
- }
728
- }, ie = (o) => {
729
- const t = JSON.parse(o), k = R(t), w = $(k);
730
- O("idle"), F("light"), p(k), U(JSON.stringify(w, null, 2));
731
- }, Ge = () => {
732
- try {
733
- ie(z);
734
- } catch (o) {
735
- C(
736
- o instanceof Error ? o.message : "Brand spec must be valid JSON"
737
- );
738
- }
739
- }, He = async (o) => {
740
- var k;
741
- const t = (k = o.target.files) == null ? void 0 : k[0];
742
- if (o.target.value = "", !!t)
743
- try {
744
- ie(await zr(t));
745
- } catch (w) {
746
- C(
747
- w instanceof Error ? w.message : "Uploaded file must be a valid brand spec"
748
- );
749
- }
750
- };
751
- return /* @__PURE__ */ d(
752
- "div",
753
- {
754
- className: te(
755
- "flex min-h-0 flex-1 flex-col bg-background text-foreground",
756
- f
757
- ),
758
- style: _e,
759
- children: [
760
- /* @__PURE__ */ d("header", { className: "flex h-11 shrink-0 items-start gap-3 border-b border-border/60 px-4 pt-2", children: [
761
- /* @__PURE__ */ r("div", { className: "mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-control border border-border/70", children: /* @__PURE__ */ r(H, { className: "h-3.5 w-3.5" }) }),
762
- /* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
763
- /* @__PURE__ */ r("h2", { className: "truncate text-[13px] font-semibold leading-tight", children: "Brand Studio" }),
764
- /* @__PURE__ */ d("p", { className: "truncate text-[11px] leading-tight text-muted-foreground", children: [
765
- "Previewing ",
766
- a || "current dashboard"
767
- ] })
768
- ] }),
769
- /* @__PURE__ */ d(
770
- ye,
771
- {
772
- open: ce,
773
- onOpenChange: Me,
774
- children: [
775
- /* @__PURE__ */ r(Ne, { asChild: !0, children: /* @__PURE__ */ d(S, { type: "button", size: "xs", variant: "ghost", disabled: !i, children: [
776
- /* @__PURE__ */ r(qe, { className: "h-3.5 w-3.5" }),
777
- "Brand Spec"
778
- ] }) }),
779
- /* @__PURE__ */ d(
780
- Se,
781
- {
782
- align: "end",
783
- sideOffset: 6,
784
- className: "z-[60] w-[min(520px,calc(100vw-24px))] rounded-control p-2",
785
- children: [
786
- /* @__PURE__ */ d("div", { className: "mb-2 flex items-center justify-between gap-2", children: [
787
- /* @__PURE__ */ d("div", { className: "min-w-0", children: [
788
- /* @__PURE__ */ r("div", { className: "text-[12px] font-medium", children: "Brand spec" }),
789
- /* @__PURE__ */ r("div", { className: "text-[11px] text-muted-foreground", children: "Edit, apply, copy, or upload your brand spec." })
790
- ] }),
791
- /* @__PURE__ */ d("div", { className: "flex shrink-0 items-center gap-1", children: [
792
- /* @__PURE__ */ d(
793
- S,
794
- {
795
- type: "button",
796
- size: "xs",
797
- variant: "ghost",
798
- onClick: Ve,
799
- children: [
800
- /* @__PURE__ */ r(xr, { className: "h-3.5 w-3.5" }),
801
- De === "copied" ? "Copied" : "Copy"
802
- ]
803
- }
804
- ),
805
- /* @__PURE__ */ d(
806
- S,
807
- {
808
- type: "button",
809
- size: "xs",
810
- variant: "ghost",
811
- onClick: () => {
812
- var o;
813
- return (o = se.current) == null ? void 0 : o.click();
814
- },
815
- children: [
816
- /* @__PURE__ */ r(fr, { className: "h-3.5 w-3.5" }),
817
- "Upload"
818
- ]
819
- }
820
- ),
821
- /* @__PURE__ */ r(S, { type: "button", size: "xs", onClick: Ge, children: "Apply" })
822
- ] })
823
- ] }),
824
- /* @__PURE__ */ r("div", { className: "h-[320px] overflow-hidden rounded-control border border-input", children: /* @__PURE__ */ r(
825
- Ke,
826
- {
827
- ariaLabel: "Brand spec",
828
- value: z,
829
- onValueChange: (o) => {
830
- U(o), O("idle");
831
- },
832
- language: "json",
833
- embedded: !0,
834
- hideLineNumbers: !0,
835
- dense: !0
836
- }
837
- ) })
838
- ]
839
- }
840
- )
841
- ]
842
- }
843
- ),
844
- /* @__PURE__ */ r(
845
- "input",
846
- {
847
- ref: se,
848
- "aria-label": "Upload brand spec",
849
- type: "file",
850
- accept: "application/json,.json",
851
- className: "sr-only",
852
- onChange: He
853
- }
854
- ),
855
- /* @__PURE__ */ d(
856
- S,
857
- {
858
- type: "button",
859
- size: "xs",
860
- variant: "ghost",
861
- onClick: Ue,
862
- disabled: !i,
863
- children: [
864
- /* @__PURE__ */ r(we, { className: "h-3.5 w-3.5" }),
865
- "Reset"
866
- ]
867
- }
868
- ),
869
- v && /* @__PURE__ */ d(
870
- S,
871
- {
872
- type: "button",
873
- size: "xs",
874
- variant: "ghost",
875
- onClick: Le,
876
- disabled: L,
877
- children: [
878
- /* @__PURE__ */ r(hr, { className: "h-3.5 w-3.5" }),
879
- "No config"
880
- ]
881
- }
882
- ),
883
- /* @__PURE__ */ d(
884
- S,
885
- {
886
- type: "button",
887
- size: "xs",
888
- onClick: Je,
889
- disabled: !i || L || !!D || !x,
890
- children: [
891
- L ? /* @__PURE__ */ r(fe, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ r(mr, { className: "h-3.5 w-3.5" }),
892
- "Save"
893
- ]
894
- }
895
- ),
896
- b && /* @__PURE__ */ r(
897
- "button",
898
- {
899
- type: "button",
900
- "aria-label": "Close Brand Studio",
901
- className: "flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",
902
- onClick: b,
903
- children: /* @__PURE__ */ r(Xe, { className: "h-3.5 w-3.5" })
904
- }
905
- )
906
- ] }),
907
- /* @__PURE__ */ d("div", { className: "flex shrink-0 items-center justify-between border-b border-border/60 px-4 py-2", children: [
908
- /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-[12px] text-muted-foreground", children: D ? /* @__PURE__ */ d(ue, { children: [
909
- /* @__PURE__ */ r(me, { className: "h-3.5 w-3.5 text-destructive" }),
910
- "Preview keeps the last valid draft"
911
- ] }) : /* @__PURE__ */ d(ue, { children: [
912
- /* @__PURE__ */ r(Ze, { className: "h-3.5 w-3.5 text-emerald-500" }),
913
- "Draft is applied to the live dashboard preview"
914
- ] }) }),
915
- /* @__PURE__ */ r("div", { className: "inline-flex h-7 items-center overflow-hidden rounded-control border border-border/70", children: ["light", "dark"].map((o) => /* @__PURE__ */ r(
916
- "button",
917
- {
918
- type: "button",
919
- className: te(
920
- "h-full px-2.5 text-[12px] capitalize transition-colors",
921
- y === o ? "bg-muted text-foreground" : "text-muted-foreground hover:text-foreground"
922
- ),
923
- onClick: () => F(o),
924
- children: o
925
- },
926
- o
927
- )) })
928
- ] }),
929
- D && /* @__PURE__ */ r("div", { className: "border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-[12px] text-destructive", children: D }),
930
- n ? /* @__PURE__ */ r("div", { className: "flex flex-1 items-center justify-center", children: /* @__PURE__ */ r(fe, { className: "h-4 w-4 animate-spin text-muted-foreground" }) }) : s ? /* @__PURE__ */ r("div", { className: "p-4 text-[13px] text-muted-foreground", children: s }) : i && u ? /* @__PURE__ */ d(Qe, { defaultValue: "style", className: "flex min-h-0 flex-1 flex-col", children: [
931
- /* @__PURE__ */ r("div", { className: "shrink-0 px-4 pt-3", children: /* @__PURE__ */ d(er, { variant: "underline", className: "w-full gap-5", children: [
932
- /* @__PURE__ */ r(V, { value: "style", children: "Style" }),
933
- /* @__PURE__ */ r(V, { value: "surfaces", children: "Surfaces" }),
934
- /* @__PURE__ */ r(V, { value: "data", children: "Data" })
935
- ] }) }),
936
- /* @__PURE__ */ d(rr, { className: "min-h-0 flex-1", children: [
937
- /* @__PURE__ */ d(G, { value: "style", className: "m-0 p-4", children: [
938
- /* @__PURE__ */ r(
939
- P,
940
- {
941
- icon: H,
942
- title: "Presets",
943
- description: "Start from a full light and dark appearance.",
944
- children: /* @__PURE__ */ r("div", { className: "grid grid-cols-1 gap-2", children: Ae.map((o) => /* @__PURE__ */ d(
945
- "button",
946
- {
947
- type: "button",
948
- className: "flex items-center gap-3 rounded-control border border-border/70 px-3 py-2 text-left hover:bg-muted/60",
949
- onClick: () => {
950
- const t = Fr(i, o.id);
951
- p(t);
952
- },
953
- children: [
954
- /* @__PURE__ */ d("div", { className: "flex h-7 w-10 overflow-hidden rounded-control border border-border/70", children: [
955
- /* @__PURE__ */ r(
956
- "span",
957
- {
958
- className: "h-full flex-1",
959
- style: { backgroundColor: o.primary }
960
- }
961
- ),
962
- /* @__PURE__ */ r(
963
- "span",
964
- {
965
- className: "h-full flex-1",
966
- style: { backgroundColor: o.accent }
967
- }
968
- )
969
- ] }),
970
- /* @__PURE__ */ d("span", { className: "min-w-0 flex-1", children: [
971
- /* @__PURE__ */ r("span", { className: "block text-[13px] font-medium", children: o.name }),
972
- /* @__PURE__ */ r("span", { className: "block truncate text-[12px] text-muted-foreground", children: o.description })
973
- ] })
974
- ]
975
- },
976
- o.id
977
- )) })
978
- }
979
- ),
980
- /* @__PURE__ */ r(
981
- P,
982
- {
983
- icon: H,
984
- title: "Color",
985
- description: `Editing the ${y} scheme.`,
986
- children: /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-2", children: Or.map(([o, t]) => /* @__PURE__ */ r(
987
- N,
988
- {
989
- label: t,
990
- value: u.tokens.color[o],
991
- onChange: (k) => m((w) => {
992
- Y(w, o, k);
993
- })
994
- },
995
- o
996
- )) })
997
- }
998
- ),
999
- /* @__PURE__ */ d(
1000
- P,
1001
- {
1002
- icon: or,
1003
- title: "Typography",
1004
- description: "Fonts and density used by dashboard and workflow chrome.",
1005
- children: [
1006
- /* @__PURE__ */ r(
1007
- Br,
1008
- {
1009
- value: u.tokens.typography.fontFamily,
1010
- onChange: (o) => m((t) => {
1011
- t.tokens.typography.fontFamily = o, t.tokens.typography.headingFontFamily = o;
1012
- })
1013
- }
1014
- ),
1015
- /* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-2", children: [
1016
- /* @__PURE__ */ r(
1017
- K,
1018
- {
1019
- label: "Base size",
1020
- value: u.tokens.typography.baseFontSize,
1021
- min: 11,
1022
- max: 18,
1023
- onChange: (o) => m((t) => {
1024
- t.tokens.typography.baseFontSize = o;
1025
- })
1026
- }
1027
- ),
1028
- /* @__PURE__ */ r(
1029
- X,
1030
- {
1031
- label: "Density",
1032
- value: u.tokens.typography.density,
1033
- options: [
1034
- ["compact", "Compact"],
1035
- ["comfortable", "Comfortable"],
1036
- ["spacious", "Spacious"]
1037
- ],
1038
- onChange: (o) => m((t) => {
1039
- t.tokens.typography.density = o, t.components.table.density = t.tokens.typography.density;
1040
- })
1041
- }
1042
- )
1043
- ] })
1044
- ]
1045
- }
1046
- )
1047
- ] }),
1048
- /* @__PURE__ */ d(G, { value: "surfaces", className: "m-0 p-4", children: [
1049
- /* @__PURE__ */ d(
1050
- P,
1051
- {
1052
- icon: gr,
1053
- title: "Layout",
1054
- description: "Canvas, grid, and card rhythm for embedded dashboards.",
1055
- children: [
1056
- _ ? /* @__PURE__ */ r(yr, { spec: _, mode: y, onEdit: $e }) : null,
1057
- /* @__PURE__ */ d("div", { className: "grid grid-cols-3 gap-2", children: [
1058
- /* @__PURE__ */ r(
1059
- K,
1060
- {
1061
- label: "Card pad",
1062
- tooltip: "Inner padding inside card/widget frames around titles, controls, and visual content.",
1063
- value: u.tokens.spacing.cardPadding,
1064
- min: 0,
1065
- max: 32,
1066
- onChange: (o) => m((t) => {
1067
- t.tokens.spacing.cardPadding = o;
1068
- })
1069
- }
1070
- ),
1071
- /* @__PURE__ */ r(
1072
- K,
1073
- {
1074
- label: "Table radius",
1075
- tooltip: "Corner radius for table containers, table chrome, and table pagination surfaces.",
1076
- value: u.tokens.radius.table,
1077
- min: 0,
1078
- max: 12,
1079
- onChange: (o) => m((t) => {
1080
- Pr(t, "table", o);
1081
- })
1082
- }
1083
- )
1084
- ] })
1085
- ]
1086
- }
1087
- ),
1088
- /* @__PURE__ */ r(
1089
- P,
1090
- {
1091
- icon: me,
1092
- title: "Filters and Controls",
1093
- description: "Dashboard filter/control toolbar, chip states, menus, and settings panels.",
1094
- children: /* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-2", children: [
1095
- /* @__PURE__ */ r(
1096
- N,
1097
- {
1098
- label: "Toolbar background",
1099
- tooltip: "Background color for the dashboard filter/control toolbar strip. This is separate from chip state colors.",
1100
- value: u.components.interactive.toolbarBackground || u.tokens.color.background,
1101
- onChange: (o) => m((t) => {
1102
- t.components.interactive.toolbarBackground = o;
1103
- })
1104
- }
1105
- ),
1106
- /* @__PURE__ */ r(
1107
- N,
1108
- {
1109
- label: "Default state",
1110
- tooltip: "Unselected filter/control chips plus the base surface for their menus, dialogs, and pagination fallback.",
1111
- value: u.components.interactive.background || u.tokens.color.card,
1112
- onChange: (o) => m((t) => {
1113
- t.components.interactive.background = o, t.components.pagination.background = o;
1114
- })
1115
- }
1116
- ),
1117
- /* @__PURE__ */ r(
1118
- N,
1119
- {
1120
- label: "Border",
1121
- tooltip: "Border color for filter/control chips, runtime inputs, settings panels, and related popover chrome.",
1122
- value: u.components.interactive.borderColor || u.tokens.color.border,
1123
- onChange: (o) => m((t) => {
1124
- t.components.interactive.borderColor = o, t.components.pagination.borderColor = o;
1125
- })
1126
- }
1127
- ),
1128
- /* @__PURE__ */ r(
1129
- N,
1130
- {
1131
- label: "Selected state",
1132
- tooltip: "Selected filter/control chips and hover feedback. This keeps a lighter default state and a stronger selected state.",
1133
- value: u.tokens.color.accent,
1134
- onChange: (o) => m((t) => {
1135
- Y(t, "accent", o);
1136
- })
1137
- }
1138
- )
1139
- ] })
1140
- }
1141
- )
1142
- ] }),
1143
- /* @__PURE__ */ d(G, { value: "data", className: "m-0 p-4", children: [
1144
- /* @__PURE__ */ d(
1145
- P,
1146
- {
1147
- icon: ar,
1148
- title: "Charts",
1149
- description: "Palette and semantic chart text/grid colors.",
1150
- children: [
1151
- /* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-2", children: u.components.chart.palette.map((o, t) => /* @__PURE__ */ d("div", { className: "flex items-end gap-1", children: [
1152
- /* @__PURE__ */ r("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ r(
1153
- N,
1154
- {
1155
- label: `Series ${t + 1}`,
1156
- value: o || "#000000",
1157
- onChange: (k) => m((w) => {
1158
- w.components.chart.palette[t] = k;
1159
- })
1160
- }
1161
- ) }),
1162
- u.components.chart.palette.length > 1 ? /* @__PURE__ */ r(
1163
- S,
1164
- {
1165
- size: "xs",
1166
- variant: "ghost",
1167
- "aria-label": `Remove series ${t + 1} color`,
1168
- className: "h-7 w-7 p-0 text-muted-foreground hover:text-foreground",
1169
- onClick: () => m((k) => {
1170
- k.components.chart.palette.splice(t, 1);
1171
- }),
1172
- children: "×"
1173
- }
1174
- ) : null
1175
- ] }, t)) }),
1176
- u.components.chart.palette.length < 12 ? /* @__PURE__ */ r(
1177
- S,
1178
- {
1179
- size: "xs",
1180
- variant: "outline",
1181
- className: "w-fit",
1182
- onClick: () => m((o) => {
1183
- o.components.chart.palette.push("#64748b");
1184
- }),
1185
- children: "Add a color"
1186
- }
1187
- ) : null,
1188
- /* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-2", children: [
1189
- /* @__PURE__ */ r(
1190
- N,
1191
- {
1192
- label: "Grid",
1193
- value: u.components.chart.gridColor,
1194
- onChange: (o) => m((t) => {
1195
- t.components.chart.gridColor = o;
1196
- })
1197
- }
1198
- ),
1199
- /* @__PURE__ */ r(
1200
- N,
1201
- {
1202
- label: "Axis",
1203
- value: u.components.chart.axisColor,
1204
- onChange: (o) => m((t) => {
1205
- t.components.chart.axisColor = o;
1206
- })
1207
- }
1208
- )
1209
- ] })
1210
- ]
1211
- }
1212
- ),
1213
- /* @__PURE__ */ d(
1214
- P,
1215
- {
1216
- icon: nr,
1217
- title: "Tables",
1218
- description: "All tables share this appearance.",
1219
- children: [
1220
- /* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-2", children: [
1221
- /* @__PURE__ */ r(
1222
- X,
1223
- {
1224
- label: "Density",
1225
- value: u.components.table.density,
1226
- options: [
1227
- ["compact", "Compact"],
1228
- ["comfortable", "Comfortable"],
1229
- ["spacious", "Spacious"]
1230
- ],
1231
- onChange: (o) => m((t) => {
1232
- t.components.table.density = o;
1233
- })
1234
- }
1235
- ),
1236
- /* @__PURE__ */ r(
1237
- X,
1238
- {
1239
- label: "Cell wrap",
1240
- value: u.components.table.cell.wrap,
1241
- options: [
1242
- ["nowrap", "No wrap"],
1243
- ["wrap", "Wrap"]
1244
- ],
1245
- onChange: (o) => m((t) => {
1246
- t.components.table.cell.wrap = o;
1247
- })
1248
- }
1249
- )
1250
- ] }),
1251
- /* @__PURE__ */ d("div", { className: "grid grid-cols-2 gap-2", children: [
1252
- /* @__PURE__ */ r(
1253
- N,
1254
- {
1255
- label: "Header",
1256
- value: u.components.table.header.background,
1257
- onChange: (o) => m((t) => {
1258
- t.components.table.header.background = o;
1259
- })
1260
- }
1261
- ),
1262
- /* @__PURE__ */ r(
1263
- N,
1264
- {
1265
- label: "Divider",
1266
- value: u.components.table.row.dividerColor,
1267
- onChange: (o) => m((t) => {
1268
- t.components.table.row.dividerColor = o, t.components.table.header.dividerColor = o;
1269
- })
1270
- }
1271
- ),
1272
- /* @__PURE__ */ r(
1273
- N,
1274
- {
1275
- label: "Selection",
1276
- value: u.tokens.color.selection,
1277
- onChange: (o) => m((t) => {
1278
- Y(t, "selection", o);
1279
- })
1280
- }
1281
- )
1282
- ] }),
1283
- /* @__PURE__ */ r(
1284
- Z,
1285
- {
1286
- label: "Zebra rows",
1287
- checked: u.components.table.row.zebra,
1288
- onCheckedChange: (o) => m((t) => {
1289
- t.components.table.row.zebra = o;
1290
- })
1291
- }
1292
- ),
1293
- /* @__PURE__ */ r(
1294
- Z,
1295
- {
1296
- label: "Sticky headers",
1297
- checked: u.components.table.header.sticky,
1298
- onCheckedChange: (o) => m((t) => {
1299
- t.components.table.header.sticky = o;
1300
- })
1301
- }
1302
- ),
1303
- /* @__PURE__ */ r(
1304
- Z,
1305
- {
1306
- label: "Uppercase headers",
1307
- checked: u.components.table.header.uppercase,
1308
- onCheckedChange: (o) => m((t) => {
1309
- t.components.table.header.uppercase = o;
1310
- })
1311
- }
1312
- )
1313
- ]
1314
- }
1315
- )
1316
- ] })
1317
- ] })
1318
- ] }) : null
1319
- ]
1320
- }
1321
- );
1322
- }
1323
- function P({
1324
- icon: e,
1325
- title: a,
1326
- description: n,
1327
- children: c
1328
- }) {
1329
- return /* @__PURE__ */ d("section", { className: "mb-6 last:mb-0", children: [
1330
- /* @__PURE__ */ d("div", { className: "mb-3 flex items-start gap-2", children: [
1331
- /* @__PURE__ */ r("div", { className: "mt-0.5 flex h-5 w-5 items-center justify-center rounded-control border border-border/70", children: /* @__PURE__ */ r(e, { className: "h-3 w-3 text-muted-foreground" }) }),
1332
- /* @__PURE__ */ d("div", { className: "min-w-0", children: [
1333
- /* @__PURE__ */ r("h3", { className: "text-[13px] font-semibold", children: a }),
1334
- /* @__PURE__ */ r("p", { className: "mt-0.5 text-[12px] leading-4 text-muted-foreground", children: n })
1335
- ] })
1336
- ] }),
1337
- /* @__PURE__ */ r("div", { className: "space-y-2", children: c }),
1338
- /* @__PURE__ */ r(tr, { className: "mt-5 bg-border/60" })
1339
- ] });
1340
- }
1341
- function Br({
1342
- value: e,
1343
- onChange: a
1344
- }) {
1345
- var c;
1346
- const n = (c = W.find((s) => s.value === e)) == null ? void 0 : c.id;
1347
- return /* @__PURE__ */ d("div", { children: [
1348
- /* @__PURE__ */ r(E, { className: "mb-1 block text-[11px] font-normal text-muted-foreground", children: "Font family" }),
1349
- /* @__PURE__ */ d("div", { className: "grid grid-cols-[minmax(0,1fr)_150px] gap-2", children: [
1350
- /* @__PURE__ */ d(
1351
- Pe,
1352
- {
1353
- value: n,
1354
- onValueChange: (s) => {
1355
- const f = W.find(
1356
- (h) => h.id === s
1357
- );
1358
- f && a(f.value);
1359
- },
1360
- children: [
1361
- /* @__PURE__ */ r(Oe, { size: "xs", "aria-label": "Font family preset", children: /* @__PURE__ */ r(Te, { placeholder: "Select font" }) }),
1362
- /* @__PURE__ */ r(Be, { children: W.map((s) => /* @__PURE__ */ r(Re, { value: s.id, children: s.label }, s.id)) })
1363
- ]
1364
- }
1365
- ),
1366
- /* @__PURE__ */ r(
1367
- "div",
1368
- {
1369
- className: "flex h-7 items-center rounded-control border border-border/60 bg-muted/30 px-2 text-[12px]",
1370
- style: { fontFamily: e },
1371
- children: "Aa 123"
1372
- }
1373
- )
1374
- ] })
1375
- ] });
1376
- }
1377
- function N({
1378
- label: e,
1379
- tooltip: a,
1380
- value: n,
1381
- onChange: c
1382
- }) {
1383
- const [s, f] = g.useState(!1), [h, x] = g.useState(n), v = Rr(n), b = n !== h, i = (p) => {
1384
- f(p), p && x(n);
1385
- };
1386
- return /* @__PURE__ */ d("div", { className: "block", children: [
1387
- /* @__PURE__ */ d("div", { className: "mb-1 flex items-center gap-1", children: [
1388
- /* @__PURE__ */ r(E, { className: "text-[11px] font-normal text-muted-foreground", children: e }),
1389
- a ? /* @__PURE__ */ r(Q, { children: /* @__PURE__ */ d(ee, { children: [
1390
- /* @__PURE__ */ r(re, { asChild: !0, children: /* @__PURE__ */ r(
1391
- "button",
1392
- {
1393
- type: "button",
1394
- "aria-label": `${e} details`,
1395
- className: "inline-flex h-3.5 w-3.5 items-center justify-center rounded-control text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",
1396
- children: /* @__PURE__ */ r(Fe, { className: "h-3 w-3" })
1397
- }
1398
- ) }),
1399
- /* @__PURE__ */ r(oe, { side: "top", className: "max-w-64", children: a })
1400
- ] }) }) : null
1401
- ] }),
1402
- /* @__PURE__ */ d("div", { className: "flex h-7 items-center overflow-hidden rounded-control border border-input bg-background", children: [
1403
- /* @__PURE__ */ d(ye, { open: s, onOpenChange: i, children: [
1404
- /* @__PURE__ */ r(Ne, { asChild: !0, children: /* @__PURE__ */ r(
1405
- "button",
1406
- {
1407
- type: "button",
1408
- "aria-label": `Open ${e} color picker`,
1409
- className: "ml-1 flex h-5 w-5 shrink-0 items-center justify-center rounded-control border border-border/70",
1410
- style: { backgroundColor: n },
1411
- children: /* @__PURE__ */ r("span", { className: "sr-only", children: e })
1412
- }
1413
- ) }),
1414
- /* @__PURE__ */ d(
1415
- Se,
1416
- {
1417
- align: "start",
1418
- sideOffset: 6,
1419
- className: "z-[60] w-64 rounded-control p-2",
1420
- children: [
1421
- /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
1422
- /* @__PURE__ */ d(
1423
- "label",
1424
- {
1425
- className: "relative flex h-16 w-16 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-control border border-border/70",
1426
- style: { backgroundColor: n },
1427
- children: [
1428
- /* @__PURE__ */ r(
1429
- "input",
1430
- {
1431
- "aria-label": `${e} native color picker`,
1432
- type: "color",
1433
- value: v,
1434
- onChange: (p) => c(p.target.value),
1435
- className: "absolute inset-0 h-full w-full cursor-pointer opacity-0"
1436
- }
1437
- ),
1438
- /* @__PURE__ */ r("span", { className: "rounded-control bg-black/45 p-1 text-white shadow-sm", children: /* @__PURE__ */ r(vr, { className: "h-3.5 w-3.5" }) })
1439
- ]
1440
- }
1441
- ),
1442
- /* @__PURE__ */ d("div", { className: "min-w-0 flex-1", children: [
1443
- /* @__PURE__ */ d("div", { className: "mb-1 flex items-center justify-between gap-2", children: [
1444
- /* @__PURE__ */ r(E, { className: "block text-[11px] font-normal text-muted-foreground", children: "Color value" }),
1445
- /* @__PURE__ */ r(Q, { children: /* @__PURE__ */ d(ee, { children: [
1446
- /* @__PURE__ */ r(re, { asChild: !0, children: /* @__PURE__ */ r(
1447
- "button",
1448
- {
1449
- type: "button",
1450
- "aria-label": `Reset ${e} color to previous value`,
1451
- disabled: !b,
1452
- className: "inline-flex h-5 w-5 items-center justify-center rounded-control text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-35",
1453
- onClick: () => c(h),
1454
- children: /* @__PURE__ */ r(we, { className: "h-3 w-3" })
1455
- }
1456
- ) }),
1457
- /* @__PURE__ */ r(oe, { side: "top", children: "Reset to previous value" })
1458
- ] }) })
1459
- ] }),
1460
- /* @__PURE__ */ r(
1461
- ae,
1462
- {
1463
- size: "xs",
1464
- "aria-label": `${e} popover color value`,
1465
- value: n,
1466
- onChange: (p) => c(p.target.value),
1467
- className: "font-mono"
1468
- }
1469
- )
1470
- ] })
1471
- ] }),
1472
- /* @__PURE__ */ r("div", { className: "mt-2 grid grid-cols-6 gap-1", children: Tr.map((p) => /* @__PURE__ */ r(
1473
- "button",
1474
- {
1475
- type: "button",
1476
- "aria-label": `Set ${e} to ${p}`,
1477
- className: te(
1478
- "h-6 rounded-control border border-border/70 shadow-sm",
1479
- n.toLowerCase() === p && "ring-2 ring-ring"
1480
- ),
1481
- style: { backgroundColor: p },
1482
- onClick: () => c(p)
1483
- },
1484
- p
1485
- )) })
1486
- ]
1487
- }
1488
- )
1489
- ] }),
1490
- /* @__PURE__ */ r(
1491
- ae,
1492
- {
1493
- size: "xs",
1494
- "aria-label": `${e} color value`,
1495
- value: n,
1496
- onChange: (p) => c(p.target.value),
1497
- className: "h-full border-0 px-2 font-mono shadow-none focus-visible:border-0"
1498
- }
1499
- )
1500
- ] })
1501
- ] });
1502
- }
1503
- function Rr(e) {
1504
- const a = sr(e);
1505
- return a ? `#${q(a.r)}${q(a.g)}${q(a.b)}` : "#000000";
1506
- }
1507
- function q(e) {
1508
- return Math.round(e).toString(16).padStart(2, "0");
1509
- }
1510
- function K({
1511
- label: e,
1512
- tooltip: a,
1513
- value: n,
1514
- min: c,
1515
- max: s,
1516
- onChange: f
1517
- }) {
1518
- const h = g.useId();
1519
- return /* @__PURE__ */ d("div", { className: "block", children: [
1520
- /* @__PURE__ */ d("div", { className: "mb-1 flex items-center gap-1", children: [
1521
- /* @__PURE__ */ r(
1522
- E,
1523
- {
1524
- htmlFor: h,
1525
- className: "text-[11px] font-normal text-muted-foreground",
1526
- children: e
1527
- }
1528
- ),
1529
- a ? /* @__PURE__ */ r(Q, { children: /* @__PURE__ */ d(ee, { children: [
1530
- /* @__PURE__ */ r(re, { asChild: !0, children: /* @__PURE__ */ r(
1531
- "button",
1532
- {
1533
- type: "button",
1534
- "aria-label": `${e} details`,
1535
- className: "inline-flex h-3.5 w-3.5 items-center justify-center rounded-control text-muted-foreground/70 transition-colors hover:bg-muted hover:text-foreground",
1536
- children: /* @__PURE__ */ r(Fe, { className: "h-3 w-3" })
1537
- }
1538
- ) }),
1539
- /* @__PURE__ */ r(oe, { side: "top", className: "max-w-56", children: a })
1540
- ] }) }) : null
1541
- ] }),
1542
- /* @__PURE__ */ r(
1543
- ae,
1544
- {
1545
- id: h,
1546
- size: "xs",
1547
- type: "number",
1548
- min: c,
1549
- max: s,
1550
- value: n,
1551
- onChange: (x) => {
1552
- const v = Number(x.target.value);
1553
- Number.isNaN(v) || f(v);
1554
- }
1555
- }
1556
- )
1557
- ] });
1558
- }
1559
- function X({
1560
- label: e,
1561
- value: a,
1562
- options: n,
1563
- onChange: c
1564
- }) {
1565
- return /* @__PURE__ */ d("div", { children: [
1566
- /* @__PURE__ */ r(E, { className: "mb-1 block text-[11px] font-normal text-muted-foreground", children: e }),
1567
- /* @__PURE__ */ d(Pe, { value: a, onValueChange: c, children: [
1568
- /* @__PURE__ */ r(Oe, { size: "xs", children: /* @__PURE__ */ r(Te, {}) }),
1569
- /* @__PURE__ */ r(Be, { children: n.map(([s, f]) => /* @__PURE__ */ r(Re, { value: s, children: f }, s)) })
1570
- ] })
1571
- ] });
1572
- }
1573
- function Z({
1574
- label: e,
1575
- checked: a,
1576
- onCheckedChange: n
1577
- }) {
1578
- return /* @__PURE__ */ d("div", { className: "flex h-8 items-center justify-between rounded-control border border-border/60 px-2", children: [
1579
- /* @__PURE__ */ r("span", { className: "text-[12px]", children: e }),
1580
- /* @__PURE__ */ r(Ce, { size: "xs", checked: a, onCheckedChange: n })
1581
- ] });
1582
- }
1583
- function Er(e) {
1584
- const a = `${Number((e / 16).toFixed(4))}rem`;
1585
- return {
1586
- "--semaphor-radius": a,
1587
- "--semaphor-control-radius": a
1588
- };
1589
- }
1590
- function Ar(e) {
1591
- return JSON.parse(JSON.stringify(e));
1592
- }
1593
- function zr(e) {
1594
- return typeof e.text == "function" ? e.text() : new Promise((a, n) => {
1595
- const c = new FileReader();
1596
- c.onload = () => a(String(c.result ?? "")), c.onerror = () => n(c.error ?? new Error("Unable to read file")), c.readAsText(e);
1597
- });
1598
- }
1599
- export {
1600
- Ae as BRAND_STUDIO_PRESETS,
1601
- Zr as BrandStudioEditor,
1602
- Fr as applyBrandStudioPreset,
1603
- xe as brandStudioSaveSpec,
1604
- $ as buildAppearanceSpecFromDraft,
1605
- R as createBrandStudioDraft
1606
- };
11
+ */const qr=Ie("Pipette",[["path",{d:"m2 22 1-1h3l9-9",key:"1sre89"}],["path",{d:"M3 21v-3l9-9",key:"hpe2y6"}],["path",{d:"m15 6 3.4-3.4a2.1 2.1 0 1 1 3 3L18 9l.4.4a2.1 2.1 0 1 1-3 3l-3.8-3.8a2.1 2.1 0 1 1 3-3l.4.4Z",key:"196du1"}]]),V={modern:{label:"Modern",values:{borders:"horizontal",cell:{paddingX:16,paddingY:8,fontSize:13},header:{paddingY:8,fontSize:10,fontWeight:500,uppercase:!0,wrap:!1,filled:!1}}},report:{label:"Report",values:{borders:"horizontal",cell:{paddingX:10,paddingY:5,fontSize:12},header:{paddingY:6,fontSize:12,fontWeight:600,uppercase:!1,wrap:!0,filled:!0}}},compact:{label:"Compact",values:{borders:"horizontal",cell:{paddingX:6,paddingY:3,fontSize:12},header:{paddingY:4,fontSize:11,fontWeight:600,uppercase:!1,wrap:!1,filled:!1}}}},qe=Object.keys(V);function $e(e,n){const{borders:o,cell:a,header:t}=V[e].values,{filled:l,...s}=t;return{borders:o,cell:{...a},header:{...s,background:l?n.accent??"#f4f4f5":"transparent",foreground:l?n.foreground:void 0}};}const ge=[{id:"semaphor",name:"Semaphor",description:"Dense neutral system defaults for embedded analytics.",primary:"#18181b",accent:"#f4f4f5",light:{background:"#ffffff",foreground:"#18181b",muted:"#fafafa",mutedForeground:"#71717a",border:"#e4e4e7",primary:"#18181b",primaryForeground:"#ffffff",accent:"#f4f4f5",accentForeground:"#18181b",selection:"#2563eb",card:"#ffffff",cardForeground:"#18181b",chartPalette:["#3b82f6","#10b981","#f59e0b","#ef4444","#8b5cf6","#06b6d4"]},dark:{background:"#09090b",foreground:"#fafafa",muted:"#18181b",mutedForeground:"#a1a1aa",border:"#27272a",primary:"#fafafa",primaryForeground:"#09090b",accent:"#27272a",accentForeground:"#fafafa",selection:"#5090f7",card:"#09090b",cardForeground:"#fafafa",chartPalette:["#60a5fa","#34d399","#fbbf24","#f87171","#a78bfa","#22d3ee"]}},{id:"atlas-blue",name:"Atlas Blue",description:"Crisp enterprise blue with restrained neutral surfaces.",primary:"#2563eb",accent:"#dbeafe",light:{background:"#f8fafc",foreground:"#0f172a",muted:"#f1f5f9",mutedForeground:"#64748b",border:"#cbd5e1",primary:"#2563eb",primaryForeground:"#ffffff",accent:"#dbeafe",accentForeground:"#1e3a8a",selection:"#2563eb",card:"#ffffff",cardForeground:"#0f172a",chartPalette:["#2563eb","#0f766e","#ca8a04","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#020617",foreground:"#e2e8f0",muted:"#0f172a",mutedForeground:"#94a3b8",border:"#1e293b",primary:"#60a5fa",primaryForeground:"#020617",accent:"#1e3a8a",accentForeground:"#dbeafe",selection:"#60a5fa",card:"#0f172a",cardForeground:"#e2e8f0",chartPalette:["#60a5fa","#2dd4bf","#facc15","#f87171","#a78bfa","#22d3ee"]}},{id:"field-green",name:"Field Green",description:"Operational green accents with quiet, readable canvases.",primary:"#047857",accent:"#d1fae5",light:{background:"#fbfdfb",foreground:"#10231d",muted:"#f1f5f3",mutedForeground:"#64746d",border:"#d7ded9",primary:"#047857",primaryForeground:"#ffffff",accent:"#d1fae5",accentForeground:"#064e3b",selection:"#047857",card:"#ffffff",cardForeground:"#10231d",chartPalette:["#047857","#2563eb","#d97706","#dc2626","#7c3aed","#0891b2"]},dark:{background:"#071511",foreground:"#e7f4ef",muted:"#10231d",mutedForeground:"#92aaa1",border:"#244139",primary:"#34d399",primaryForeground:"#071511",accent:"#064e3b",accentForeground:"#d1fae5",selection:"#34d399",card:"#0b1d17",cardForeground:"#e7f4ef",chartPalette:["#34d399","#60a5fa","#fbbf24","#f87171","#a78bfa","#22d3ee"]}}];function j(e){const n=Ke({organizationAppearance:e?Xe(e).spec:void 0});return Qr(Ze(re(n)));}function Qr(e){var n;for(const o of Object.values(e.schemes)){const a=(n=o.components.table)==null?void 0:n.row;a!=null&&a.selectedBackground&&a.selectedBackground===a.hoverBackground&&delete a.selectedBackground;}return e;}function fe(e){const n=re({version:ce,mode:e.mode,schemes:e.schemes}),o=Yr(n);if(!o.success)throw new Qe(o.issues[0]);return o.value;}class Qe extends Error{constructor(o){super(`Invalid Brand Studio appearance at ${o.path}: ${o.message}`);De(this,"issue");this.name="BrandStudioDraftError",this.issue=o;}}function Zr(e){return Ke({organizationAppearance:ee(e)});}function ee(e){var o,a;const n=fe(e);for(const t of["light","dark"]){const l=(o=n.schemes)==null?void 0:o[t];if(!(l!=null&&l.components))continue;const s=Ze(re({version:ce,mode:e.mode,schemes:{light:{tokens:l.tokens,components:{}},dark:{tokens:l.tokens,components:{}}}})).schemes[t].components;for(const m of en){const u=l.components[m];if(u)for(const d of rn[m])u[d]!==void 0&&u[d]===((a=s[m])==null?void 0:a[d])&&delete u[d];}}return Xe(n).spec??{version:ce,mode:e.mode};}const en=["dashboard","card"],rn={dashboard:["foreground","borderColor"],card:["background","foreground","borderColor"]};function nn(e,n){const o=ge.find(t=>t.id===n);if(!o)return e;const a=re(e);return Le(a.schemes.light,o.light),Le(a.schemes.dark,o.dark),a;}function Le(e,n){e.tokens.color.background=n.background,e.tokens.color.foreground=n.foreground,e.tokens.color.muted=n.muted,e.tokens.color.mutedForeground=n.mutedForeground,e.tokens.color.border=n.border,e.tokens.color.input=n.border,e.tokens.color.primary=n.primary,e.tokens.color.primaryForeground=n.primaryForeground,e.tokens.color.accent=n.accent,e.tokens.color.accentForeground=n.accentForeground,e.tokens.color.selection=n.selection,e.tokens.color.card=n.card,e.tokens.color.cardForeground=n.cardForeground,e.components.dashboard.background=n.background,e.components.dashboard.foreground=n.foreground,e.components.dashboard.borderColor=n.border,e.components.card.background=n.card,e.components.card.foreground=n.cardForeground,e.components.card.borderColor=n.border,e.components.interactive.toolbarBackground=n.background,e.components.interactive.background=n.card,e.components.interactive.foreground=n.foreground,e.components.interactive.borderColor=n.border,e.components.chart.palette=[...n.chartPalette],e.components.chart.background=n.card,e.components.chart.foreground=n.foreground,e.components.chart.gridColor=n.border,e.components.chart.axisColor=n.mutedForeground;}function ue(e,n,o){switch(e.tokens.color[n]=o,n){case"background":e.components.dashboard.background=o,e.components.interactive.toolbarBackground=o;break;case"foreground":e.components.dashboard.foreground=o,e.components.interactive.foreground=o,e.components.pagination.foreground=o,e.components.chart.foreground=o;break;case"card":e.components.card.background=o,e.components.interactive.background=o,e.components.pagination.background=o,e.components.chart.background=o;break;case"cardForeground":e.components.card.foreground=o;break;case"mutedForeground":e.components.chart.axisColor=o;break;case"border":e.tokens.color.input=o,e.components.dashboard.borderColor=o,e.components.card.borderColor=o,e.components.interactive.borderColor=o,e.components.pagination.borderColor=o,e.components.chart.gridColor=o;break;}}function on(e,n,o){e.tokens.radius[n]=o;}function Ze(e){for(const n of["light","dark"]){const o=e.schemes[n],a=o.tokens,t=a.color,l={fontFamily:"",headingFontFamily:"",monoFontFamily:"",baseFontSize:14,density:"comfortable"};a.typography={...l,...a.typography};const s={control:5,card:5,table:5,badge:999};a.radius={...s,...a.radius};const m={dashboardPadding:16,gridGap:12,cardPadding:16,controlGap:8,tableCellX:16,tableCellY:8};a.spacing={...m,...a.spacing};const u={card:"none",popover:"0 12px 32px rgba(15, 23, 42, 0.14)",focusRing:"0 0 0 2px rgba(37, 99, 235, 0.35)"};a.shadow={...u,...a.shadow};const d={dashboard:{background:t.background,foreground:t.foreground,borderColor:t.border},card:{background:t.card,foreground:t.cardForeground,borderColor:t.border},interactive:{toolbarBackground:t.background,background:t.card,foreground:t.foreground,borderColor:t.border},chart:{palette:[],background:t.card,foreground:t.foreground,gridColor:t.border,axisColor:t.mutedForeground,barRadius:0},table:{},documentTable:{},pagination:{background:t.card,foreground:t.foreground,borderColor:t.border}};o.components=Object.fromEntries(Object.entries({...d,...o.components}).map(([f,b])=>[f,{...d[f],...b}]));const c={palette:[],background:t.card,foreground:t.foreground,gridColor:t.border,axisColor:t.mutedForeground,barRadius:2};o.components.chart={...c,...o.components.chart};}return e;}function re(e){return JSON.parse(JSON.stringify(e));}function we(e,n){if(e===void 0||n===void 0)return e===n;if(e.trim().toLowerCase()===n.trim().toLowerCase())return!0;const o=be(e),a=be(n);return!o||!a?!1:Math.round(o.r)===Math.round(a.r)&&Math.round(o.g)===Math.round(a.g)&&Math.round(o.b)===Math.round(a.b);}function an(e,n){var o,a;return(a=(o=Jr.schemes[e].tokens)==null?void 0:o.color)==null?void 0:a[n];}function tn(e,n){let o;try{o=ee(e);}catch{return;}let a;try{a=ee(j(n??null));}catch{a={version:ce};}const t=me(o),l=me(a),s=/* @__PURE__ */new Map();for(const d of/* @__PURE__ */new Set([...t.keys(),...l.keys()]))t.get(d)!==l.get(d)&&s.set(d,t.get(d));const m={light:/* @__PURE__ */new Map(),dark:/* @__PURE__ */new Map()};for(const[d,c]of s){const f=/^schemes\.(light|dark)\.tokens\.color\./.exec(d),b=f?m[f[1]]:void 0;b&&c!==void 0&&!b.has(c)&&b.set(c,d);}const u=/* @__PURE__ */new Set();for(const[d,c]of s){const f=/^schemes\.(light|dark)\.(tokens\.color|components)\./.exec(d),b=f&&c!==void 0?m[f[1]].get(c):void 0;if(b!==void 0&&b!==d)continue;const g=/^schemes\.(light|dark)\.(.*)$/.exec(d);if(g){const y=`schemes.${g[1]==="light"?"dark":"light"}.${g[2]}`;if(s.has(y)&&s.get(y)===c){u.add(`schemes.*.${g[2]}`);continue;}}u.add(d);}return u.size;}function me(e,n="",o=/* @__PURE__ */new Map()){if(e&&typeof e=="object"&&!Array.isArray(e))for(const[a,t]of Object.entries(e))me(t,n?`${n}.${a}`:a,o);else n&&o.set(n,JSON.stringify(e));return o;}const ln=[["container","background"],["container","borderColor"],["row","zebraBackground"],["row","hoverBackground"],["subtotal","background"],["subtotal","foreground"],["grandTotal","borderColor"],["pagination","background"],["pagination","foreground"],["pagination","borderColor"]];function Ne(e){var o;const n=[];for(const a of["light","dark"]){const t=new Set(Object.values(e.schemes[a].tokens.color).map(s=>String(s).toLowerCase())),l=e.schemes[a].components.table;for(const[s,m]of ln){const u=(o=l[s])==null?void 0:o[m];typeof u=="string"&&t.has(u.toLowerCase())&&n.push({scheme:a,part:s,key:m});}}return n;}function sn(e){const n=re(e);for(const{scheme:o,part:a,key:t}of Ne(e)){const l=n.schemes[o].components.table,s={...l[a]};delete s[t],Object.keys(s).length?l[a]=s:delete l[a];}return n;}const er={background:"Page",card:"Cards",muted:"Tinted surface",border:"Lines",foreground:"Text",mutedForeground:"Secondary text",primary:"Primary",accent:"Accent",selection:"Selection",link:"Links",positive:"Positive",negative:"Negative",warning:"Warning",info:"Info",primaryForeground:"Text on primary",accentForeground:"Text on accent",cardForeground:"Text on cards",input:"Input borders",destructive:"Destructive",destructiveForeground:"Text on destructive"},dn={dashboard:"Dashboards",card:"Dashboards",interactive:"Filters and controls",pagination:"Filters and controls",chart:"Charts",table:"Tables",matrixTable:"Tables",documentTable:"Tables"};function de(e){return e instanceof Qe?cn(e.issue):e instanceof Error?e.message:"This brand can't be saved yet.";}function cn(e){const n=e.path.replace(/^\$\./,"").split("."),o=n[0]==="schemes"&&(n[1]==="light"||n[1]==="dark")?n[1]:null,a=o?` (${o==="light"?"Light":"Dark"})`:"",t=e.code==="invalid_color";if(o&&n[2]==="tokens"&&n[3]==="color"&&n[4]){const s=er[n[4]]??n[4];return t?`${s}${a} isn't a color yet. Enter one like #1A73E8.`:`${s}${a} can't be saved as it is.`;}const l=o&&n[2]==="components"?dn[n[3]??""]:void 0;return l?t?`A color in ${l}${a} isn't a color yet. Enter one like #1A73E8.`:`A value in ${l}${a} is out of range. Set it again to save.`:t?`A color${a} isn't a color yet. Enter one like #1A73E8.`:"A setting can't be saved as it is. Check Advanced.";}const rr={dashboards:"table",documents:"documentTable"};function Te(e,n,o){const a=Hr({spec:Zr(e),mode:o==="documents"?"light":n});return mr(a,{surface:o==="documents"?"document":"dashboard",kind:"table"});}function un(e,n,o){return e.schemes[o==="documents"?"light":n].components[rr[o]]??{};}function hn(e){var n;return((n=e.schemes.light.components.documentTable)==null?void 0:n.sameAsDashboards)===!0;}function G(e,n,o,a){const t=nr(e),l=rr[n],s=a&&n==="dashboards"?[a]:["light","dark"];for(const m of s){const u=t.schemes[m].components;u[l]=mn(u[l]??{},o);}return t;}function pn(e,n,o,a){if(n==="documents"){const l=e.schemes.light.tokens.color.accent;return G(e,n,{header:{background:a?l:"transparent"}},o);}let t=e;for(const l of[o,o==="light"?"dark":"light"]){const s=e.schemes[l].tokens.color.accent;t=G(t,n,{header:{background:a?s:"transparent"}},l);}return t;}function bn(e,n){const o=nr(e);for(const a of["light","dark"]){const t={...o.schemes[a].components.documentTable};t.sameAsDashboards=n,o.schemes[a].components.documentTable=t;}return o;}function gn(e,n,o){var t,l,s,m;if(n==="documents"){const u=e.schemes.light.tokens.color,d=$e(o,u),c=V[o].values.header.filled?d.header:{...d.header,background:"transparent",foreground:u.mutedForeground};return G(e,n,{...d,header:c});}let a=e;for(const u of["light","dark"]){const d=$e(o,e.schemes[u].tokens.color),c=e.schemes[u].tokens.spacing,f={...d.cell,paddingX:((t=d.cell)==null?void 0:t.paddingX)===c.tableCellX||(l=d.cell)==null?void 0:l.paddingX,paddingY:((s=d.cell)==null?void 0:s.paddingY)===c.tableCellY||(m=d.cell)==null?void 0:m.paddingY};a=G(a,n,{...d,cell:f},u);}return a;}function fn(e,n){return qe.find(o=>{const{borders:a,cell:t,header:l}=V[o].values;return e.rows.borders===a&&e.cell.paddingX===t.paddingX&&e.cell.paddingY===t.paddingY&&e.cell.fontSize===t.fontSize&&e.header.paddingY===l.paddingY&&e.header.fontSize===l.fontSize&&e.header.fontWeight===l.fontWeight&&e.header.uppercase===l.uppercase&&e.header.wrap===l.wrap&&(l.filled?e.header.background!=="transparent":e.header.background==="transparent"&&(e.header.foreground.startsWith("hsl(var(")||we(e.header.foreground,n)));})??null;}function mn(e,n){const o={...e};for(const[a,t]of Object.entries(n)){if(t===void 0)continue;const l=o[a];if(t&&typeof t=="object"){const s={...(l&&typeof l=="object"?l:{})};for(const[m,u]of Object.entries(t))u===void 0?delete s[m]:s[m]=u;o[a]=s;}else o[a]=t;}return o;}function nr(e){return JSON.parse(JSON.stringify(e));}function vn({draft:e,appearance:n,scheme:o,view:a,onSchemeChange:t,onViewChange:l}){const s=k.useMemo(()=>({...(n??{version:1}),mode:a==="document"?"light":o}),[n,o,a]);return/* @__PURE__ */i("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-muted/30",children:[/* @__PURE__ */i("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-border/60 px-4 py-2",children:[/* @__PURE__ */r(R,{label:"Preview",value:a,onChange:l,options:[{value:"dashboard",label:"Dashboard"},{value:"table",label:"Table"},{value:"document",label:"Document"}]}),/* @__PURE__ */r(R,{label:"Scheme",value:o,onChange:t,options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"}]})]}),/* @__PURE__ */r("div",{className:"min-h-0 flex-1 overflow-auto p-5",children:/* @__PURE__ */r(We,{organizationAppearance:s,children:a==="document"?/* @__PURE__ */r(wn,{draft:e}):/* @__PURE__ */r(Cn,{view:a})})})]});}const yn=[{region:"North",status:"Succeeded",orders:1284,revenue:98765.43},{region:"South",status:"Failed",orders:342,revenue:12034.5},{region:"East",status:"Running",orders:905,revenue:45210.2},{region:"West",status:"Succeeded",orders:1110,revenue:76402.1}],xn={region:"Total",orders:3641,revenue:232412.23},kn={id:"brand-studio-preview-table",type:"table",title:"Runs by region",config:{},preferences:{tablePrefs:{tableStyle:{totals:{enabled:!0}}}}},Sn={status:{type:"badge",badge:{style:"pill",tones:{Succeeded:"green",Failed:"red"}}}};function ve(){return/* @__PURE__ */r(Ue,{card:kn,data:yn,totalsByColumnId:xn,columnSettings:Sn,suppressSortControls:!0});}function Cn({view:e}){const{compiledAppearance:n}=Vr(),o=vr(),a=yr("interactive"),t=n.chartTheme.palette,l=n.chartTheme.barRadius,s=e==="table"?"Runs by region":"Revenue overview",m=[["Last 90 days",!0],["All regions",!1]];return/* @__PURE__ */i("div",{className:"mx-auto max-w-[820px] overflow-hidden rounded-[8px] border border-border/60 shadow-sm",style:{...o.dashboardContainerStyle,fontFamily:"var(--semaphor-font-family)"},children:[/* @__PURE__ */i("div",{className:"flex items-center gap-2 border-b border-border px-3 py-2",style:a.containerStyle,children:[/* @__PURE__ */r("span",{className:"text-[13px] font-semibold",children:s}),/* @__PURE__ */r("span",{className:"ml-auto flex gap-1.5",children:m.map(([u,d])=>/* @__PURE__ */r("span",{className:N("inline-flex h-7 items-center rounded-control border border-border px-2 text-[12px]",d?a.hasAppearance?"bg-accent/80":"bg-muted/80":"bg-muted/40"),style:a.chipStyle,children:u},u))})]}),/* @__PURE__ */r("div",{style:{...o.dashboardCanvasStyle,padding:o.canvasPadding},children:e==="table"?/* @__PURE__ */r(Q,{frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:/* @__PURE__ */r(ve,{})}):/* @__PURE__ */i("div",{className:"grid grid-cols-3",style:{gap:o.spacing},children:[[["Revenue","$1.24M","+8.2%",!0],["Orders","12,480","+3.1%",!0],["Refunds","2.4%","+0.4 pts",!1]].map(([u,d,c,f])=>/* @__PURE__ */i(Q,{frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"text-[11px] text-muted-foreground",children:u}),/* @__PURE__ */r("p",{className:"mt-1 text-[22px] font-semibold tracking-tight",children:d}),/* @__PURE__ */i("p",{className:"text-[11px]",style:{color:`hsl(var(${f?"--semaphor-positive":"--semaphor-negative"}))`},children:[c," vs last period"]})]},String(u))),/* @__PURE__ */i(Q,{className:"col-span-2",frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"mb-3 text-[13px] font-semibold",children:"Revenue by month"}),/* @__PURE__ */r("div",{className:"flex h-[110px] items-end gap-2 border-b border-border",children:[48,62,55,70,66,82,78,90].map((u,d)=>/* @__PURE__ */r("span",{className:"flex-1",style:{height:`${u}%`,background:t[0],borderRadius:`${l}px ${l}px 0 0`}},d))})]}),/* @__PURE__ */i(Q,{frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"mb-2 text-[13px] font-semibold",children:"By channel"}),["Direct","Partners","Online"].map((u,d)=>/* @__PURE__ */i("div",{className:"flex items-center gap-2 py-1 text-[12px]",children:[/* @__PURE__ */r("span",{className:"h-2 w-2 rounded-full",style:{background:t[(d+1)%t.length]}}),u,/* @__PURE__ */i("span",{className:"ml-auto tabular-nums text-muted-foreground",children:[[46,31,23][d],"%"]})]},u))]}),/* @__PURE__ */i(Q,{className:"col-span-3",frame:o.cardFrameStyle,gutter:o.cardGutterStyle,children:[/* @__PURE__ */r("p",{className:"mb-2 text-[13px] font-semibold",children:"Recent runs"}),/* @__PURE__ */r(ve,{})]})]})})]});}function Q({frame:e,gutter:n,className:o,children:a}){return/* @__PURE__ */r("div",{className:N("relative min-w-0 overflow-clip rounded-card border bg-card text-card-foreground shadow-sm",o),style:e,children:/* @__PURE__ */r("div",{className:"py-3",style:n,children:a})});}function wn({draft:e}){const n=Te(e,"light","documents");return/* @__PURE__ */i("div",{className:"mx-auto w-[600px] rounded-[2px] bg-white p-10 text-zinc-900 shadow-[0_1px_3px_rgba(0,0,0,.12),0_8px_24px_rgba(0,0,0,.08)]",children:[/* @__PURE__ */r("p",{className:"text-[11px] text-zinc-500",children:"Weekly operations report · Page 1 of 4"}),/* @__PURE__ */r("h3",{className:"mt-3 text-[18px] font-semibold tracking-tight",children:"Runs by region"}),/* @__PURE__ */r("p",{className:"mt-1 text-[12px] text-zinc-500",children:"Week of Nov 10"}),/* @__PURE__ */r("div",{className:`mt-4 ${Ye(n)}`,style:je({style:n,isSliced:!0}),children:/* @__PURE__ */r(Je,{value:"document",children:/* @__PURE__ */r(ve,{})})})]});}const Nn=["#ffffff","#f8fafc","#f4f4f5","#e4e4e7","#18181b","#09090b","#2563eb","#0f766e","#047857","#d97706","#dc2626","#7c3aed"];function or(e){const n=be(e);return n?`#${pe(n.r)}${pe(n.g)}${pe(n.b)}`:"#000000";}function pe(e){return Math.round(e).toString(16).padStart(2,"0");}function _({title:e,children:n}){return/* @__PURE__ */i("div",{className:"px-5 pb-2 pt-5",children:[/* @__PURE__ */r("h2",{className:"text-[14px] font-semibold tracking-tight",children:e}),n?/* @__PURE__ */r("p",{className:"mt-0.5 text-[12px] leading-[1.45] text-muted-foreground",children:n}):null]});}function C({label:e,aside:n,children:o}){return/* @__PURE__ */i("div",{className:"px-5 py-3",children:[/* @__PURE__ */i("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[/* @__PURE__ */r("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e}),n]}),/* @__PURE__ */r("div",{className:"divide-y divide-border/50",children:o})]});}function v({label:e,hint:n,error:o,children:a}){return/* @__PURE__ */i("div",{className:"py-2",children:[/* @__PURE__ */i("div",{className:"flex min-h-7 items-center justify-between gap-3",children:[/* @__PURE__ */i("div",{className:"min-w-0",children:[/* @__PURE__ */r("p",{className:"truncate text-[13px]",children:e}),n?/* @__PURE__ */r("p",{className:"truncate text-[11px] text-muted-foreground",children:n}):null]}),/* @__PURE__ */r("div",{className:"flex shrink-0 items-center gap-1.5",children:a})]}),o?/* @__PURE__ */r("p",{role:"alert",className:"mt-1 text-[11px] text-destructive",children:o}):null]});}function w({label:e,value:n,min:o,max:a,unit:t="px",onChange:l}){const s=c=>l(Math.min(a,Math.max(o,Math.round(c)))),[m,u]=k.useState(null),d=()=>{if(m===null)return;const c=Number(m);m.trim()!==""&&Number.isFinite(c)&&s(c),u(null);};return/* @__PURE__ */i("span",{className:"inline-flex h-7 items-center rounded-control border border-border",children:[/* @__PURE__ */r("button",{type:"button","aria-label":`Less ${e}`,disabled:n<=o,onClick:()=>s(n-1),className:"grid h-full w-6 place-items-center text-muted-foreground hover:text-foreground disabled:opacity-35",children:/* @__PURE__ */r(Or,{className:"h-3 w-3"})}),/* @__PURE__ */i("span",{className:"flex w-12 items-baseline justify-center gap-0.5",children:[/* @__PURE__ */r("input",{"aria-label":e,inputMode:"numeric",value:m??String(n),onChange:c=>u(c.target.value),onBlur:d,onKeyDown:c=>{c.key==="Enter"&&d(),c.key==="Escape"&&u(null);},className:"w-6 bg-transparent text-right text-[12px] tabular-nums outline-none"}),/* @__PURE__ */r("span",{className:"text-[11px] text-muted-foreground",children:t})]}),/* @__PURE__ */r("button",{type:"button","aria-label":`More ${e}`,disabled:n>=a,onClick:()=>s(n+1),className:"grid h-full w-6 place-items-center text-muted-foreground hover:text-foreground disabled:opacity-35",children:/* @__PURE__ */r(He,{className:"h-3 w-3"})})]});}function E({label:e,hint:n,value:o,onChange:a,onReset:t}){return/* @__PURE__ */i(v,{label:e,hint:n,children:[/* @__PURE__ */r("span",{className:"w-[66px] truncate text-right font-mono text-[11px] uppercase text-muted-foreground",children:or(o)}),/* @__PURE__ */r(ne,{label:e,value:o,onChange:a}),t?/* @__PURE__ */r("button",{type:"button","aria-label":`Reset ${e}`,onClick:t,className:"rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:/* @__PURE__ */r(Se,{className:"h-3 w-3"})}):/* @__PURE__ */r("span",{className:"w-5"})]});}function ne({label:e,value:n,onChange:o}){const[a,t]=k.useState(!1),[l,s]=k.useState(n),[m,u]=k.useState(null);return/* @__PURE__ */i(xr,{open:a,onOpenChange:d=>{d&&s(n),u(null),t(d);},children:[/* @__PURE__ */r(kr,{asChild:!0,children:/* @__PURE__ */r("button",{type:"button","aria-label":`Open ${e} color picker`,className:"h-6 w-6 rounded-[4px] border border-black/10 dark:border-white/15",style:{backgroundColor:n}})}),/* @__PURE__ */i(Sr,{align:"end",sideOffset:6,className:"z-[60] w-64 rounded-control p-2",children:[/* @__PURE__ */i("div",{className:"flex items-center gap-2",children:[/* @__PURE__ */i("label",{className:"relative flex h-14 w-14 shrink-0 cursor-pointer items-center justify-center overflow-hidden rounded-control border border-border/70",style:{backgroundColor:n},children:[/* @__PURE__ */r("input",{"aria-label":`${e} native color picker`,type:"color",value:or(n),onChange:d=>{u(null),o(d.target.value);},className:"absolute inset-0 h-full w-full cursor-pointer opacity-0"}),/* @__PURE__ */r("span",{className:"rounded-control bg-black/45 p-1 text-white shadow-sm",children:/* @__PURE__ */r(qr,{className:"h-3.5 w-3.5"})})]}),/* @__PURE__ */r(Cr,{size:"xs","aria-label":`${e} color value`,value:m??n,onChange:d=>{u(d.target.value),o(d.target.value);},onBlur:()=>u(null),className:"font-mono"}),n!==l?/* @__PURE__ */r("button",{type:"button","aria-label":`Reset ${e} color to previous value`,title:"Back to the color it had",onClick:()=>{u(null),o(l);},className:"shrink-0 rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",children:/* @__PURE__ */r(Se,{className:"h-3.5 w-3.5"})}):null]}),/* @__PURE__ */r("div",{className:"mt-2 grid grid-cols-6 gap-1",children:Nn.map(d=>/* @__PURE__ */r("button",{type:"button","aria-label":`Set ${e} to ${d}`,className:N("h-6 rounded-control border border-border/70",n.toLowerCase()===d&&"ring-2 ring-ring"),style:{backgroundColor:d},onClick:()=>{u(null),o(d);}},d))})]})]});}function z({label:e,value:n,options:o,width:a=140,onChange:t}){return/* @__PURE__ */i(wr,{value:n,onValueChange:t,children:[/* @__PURE__ */r(Nr,{size:"xs","aria-label":e,style:{width:a},children:/* @__PURE__ */r(Tr,{})}),/* @__PURE__ */r(Fr,{children:o.map(([l,s])=>/* @__PURE__ */r(Er,{value:l,children:s},l))})]});}function W({label:e,checked:n,onCheckedChange:o}){return/* @__PURE__ */r(Pr,{size:"xs","aria-label":e,checked:n,onCheckedChange:o});}const Tn={semaphor:"Neutral"},Fn={"open-sans":"Open Sans"},ye=ie.map(e=>[e.id,Fn[e.id]??e.label]),xe=e=>{var n;return((n=ie.find(o=>o.value===e))==null?void 0:n.id)??ie[0].id;},ke=e=>{var n;return(n=ie.find(o=>o.id===e))==null?void 0:n.value;};function En({context:e}){var f;const{draft:n,scheme:o,setDraft:a,updateScheme:t,updateBoth:l,dashboardStyleSpec:s,editDashboardFields:m}=e,u=n.schemes[o].tokens.color,d=s?Ce({organizationAppearance:s},o):null,c=(f=ge.find(b=>we(b.light.primary,n.schemes.light.tokens.color.primary)))==null?void 0:f.id;return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Brand",children:"Four choices set the look. Every other section fine-tunes it."}),/* @__PURE__ */r(C,{label:"Start from",children:/* @__PURE__ */r("div",{className:"grid grid-cols-3 gap-2 py-2",children:ge.map(b=>/* @__PURE__ */i("button",{type:"button","aria-pressed":c===b.id,onClick:()=>a(nn(n,b.id)),className:N("rounded-[6px] border p-2 text-left",c===b.id?"border-foreground ring-1 ring-foreground":"border-border hover:border-foreground/40"),children:[/* @__PURE__ */i("span",{className:"flex gap-1",children:[/* @__PURE__ */r("span",{className:"h-4 w-4 rounded-[3px]",style:{background:b.light.primary}}),/* @__PURE__ */r("span",{className:"h-4 w-4 rounded-[3px] border border-border/60",style:{background:b.light.accent}}),/* @__PURE__ */r("span",{className:"h-4 w-4 rounded-[3px]",style:{background:b.dark.background}})]}),/* @__PURE__ */r("span",{className:"mt-1.5 block truncate text-[12px] font-medium",children:Tn[b.id]??b.name})]},b.id))})}),/* @__PURE__ */i(C,{label:"Your brand",children:[/* @__PURE__ */r(v,{label:"Primary color",hint:"Buttons, selection and links",children:/* @__PURE__ */r(ne,{label:"Primary color",value:u.primary,onChange:b=>t(g=>ue(g,"primary",b))})}),/* @__PURE__ */r(v,{label:"Font",children:/* @__PURE__ */r(z,{label:"Font",value:xe(n.schemes.light.tokens.typography.fontFamily),options:ye,onChange:b=>l(g=>{const y=ke(b);y&&(g.tokens.typography.fontFamily=y,g.tokens.typography.headingFontFamily=y);})})}),d?/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(v,{label:"Corners",children:/* @__PURE__ */r(R,{label:"Corners",value:d.pickers.corners,onChange:b=>m({corners:b}),options:["square","subtle","rounded"].map(b=>({value:b,label:b[0].toUpperCase()+b.slice(1),title:`Cards ${ze[b].cardCorners} px, controls ${ze[b].controlCorners} px`}))})}),/* @__PURE__ */r(v,{label:"Spacing",children:/* @__PURE__ */r(R,{label:"Spacing",value:d.pickers.spacing,onChange:b=>m({spacing:b}),options:["compact","default","roomy"].map(b=>({value:b,label:b[0].toUpperCase()+b.slice(1),title:`${jr[b]} px between cards`}))})})]}):null]})]});}const On=[{label:"Surfaces",rows:[["background"],["card"],["muted"],["border"]]},{label:"Text",rows:[["foreground"],["mutedForeground"]]},{label:"Brand",rows:[["primary"],["accent","Hover and highlights"],["selection","What a viewer filtered by"],["link"]]},{label:"Status",rows:[["positive"],["negative"],["warning"],["info"]]}],Pn=["primaryForeground","accentForeground","cardForeground","input","destructive","destructiveForeground"];function An({context:e}){const{draft:n,scheme:o,setDraft:a,updateScheme:t}=e,[l,s]=k.useState(!1),m=n.schemes[o].tokens.color,u=Ne(n),d=([c,f])=>{const b=er[c],g=an(o,c),y=g!==void 0&&!we(m[c],g);return/* @__PURE__ */r(E,{label:b,hint:f??(y?"Your color":"Default"),value:m[c]??g??"#000000",onChange:D=>t(S=>ue(S,c,D)),onReset:y&&g?()=>t(D=>ue(D,c,g)):void 0},c);};return/* @__PURE__ */i(T,{children:[/* @__PURE__ */i(_,{title:"Colors",children:[o==="light"?"Light":"Dark"," colors. Switch to ",o==="light"?"Dark":"Light"," to edit the other set; every other setting applies to both."]}),u.length?/* @__PURE__ */i("div",{className:"mx-5 mb-1 rounded-[6px] border border-amber-500/40 bg-amber-500/10 p-3",children:[/* @__PURE__ */i("p",{className:"text-[12px] font-medium",children:[u.length," table color",u.length===1?" was":"s were"," copied from your colors"]}),/* @__PURE__ */r("p",{className:"mt-0.5 text-[12px] leading-[1.45] text-muted-foreground",children:"An earlier version of this editor saved them, so they don't change when you change your colors."}),/* @__PURE__ */r(B,{size:"xs",className:"mt-2",onClick:()=>a(sn(n)),children:"Follow my colors"})]}):null,On.map(c=>/* @__PURE__ */r(C,{label:c.label,children:c.rows.map(d)},c.label)),/* @__PURE__ */i("button",{type:"button",onClick:()=>s(!l),className:"flex w-full items-center gap-1 px-5 py-2 text-[12px] text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */r(Ve,{className:N("h-3 w-3 transition-transform",l&&"rotate-90")}),"Text on colors, inputs and destructive"]}),l?/* @__PURE__ */r(C,{label:"More colors",children:Pn.map(c=>d([c]))}):null]});}function Rn({context:e}){const{draft:n,updateBoth:o}=e,a=n.schemes.light.tokens.typography;return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Typography",children:"Your app loads the font; a missing one falls back to the system font."}),/* @__PURE__ */i(C,{label:"Fonts",children:[/* @__PURE__ */r(v,{label:"Text",children:/* @__PURE__ */r(z,{label:"Text font",value:xe(a.fontFamily),options:ye,onChange:t=>o(l=>{const s=ke(t);s&&(l.tokens.typography.fontFamily=s);})})}),/* @__PURE__ */r(v,{label:"Headings",children:/* @__PURE__ */r(z,{label:"Heading font",value:xe(a.headingFontFamily),options:ye,onChange:t=>o(l=>{const s=ke(t);s&&(l.tokens.typography.headingFontFamily=s);})})})]}),/* @__PURE__ */i(C,{label:"Size",children:[/* @__PURE__ */r(v,{label:"Base size",hint:"Charts and controls scale from it",children:/* @__PURE__ */r(w,{label:"Base size",value:a.baseFontSize,min:11,max:18,onChange:t=>o(l=>l.tokens.typography.baseFontSize=t)})}),/* @__PURE__ */r(v,{label:"Density",hint:"Space in menus and panels",children:/* @__PURE__ */r(z,{label:"Density",value:a.density,width:130,options:[["compact","Compact"],["comfortable","Comfortable"],["spacious","Spacious"]],onChange:t=>o(l=>l.tokens.typography.density=t)})})]})]});}const Z=e=>({min:_e[e].min,max:_e[e].max});function Dn({context:e}){const{draft:n,scheme:o,updateBoth:a,dashboardStyleSpec:t,editDashboardFields:l}=e,[s,m]=k.useState(null);if(!t)return null;const u=Ce({organizationAppearance:t},o),d=u.authored,c=g=>m(l(g)),f=d.canvas==="muted"?"muted":d.canvas==="background"?"background":"color",b=g=>({[o]:g});return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Dashboards",children:"How cards sit on the canvas. A dashboard can set its own in its Style panel."}),/* @__PURE__ */i(C,{label:"Layout",children:[/* @__PURE__ */r(v,{label:"Space between cards",children:/* @__PURE__ */r(w,{label:"Space between cards",value:d.spacing,...Z("spacing"),onChange:g=>c({spacing:g})})}),/* @__PURE__ */r(v,{label:"Canvas edge",children:/* @__PURE__ */r(w,{label:"Canvas edge",value:d.canvasPadding,...Z("canvasPadding"),onChange:g=>c({canvasPadding:g})})}),/* @__PURE__ */i(v,{label:`Canvas (${o})`,children:[/* @__PURE__ */r(R,{label:"Canvas",value:f,onChange:g=>c({canvas:b(g==="color"?o==="dark"?"#111318":"#f4f6f8":g)}),options:[{value:"muted",label:"Tinted"},{value:"background",label:"Plain"},{value:"color",label:"Custom"}]}),f==="color"?/* @__PURE__ */r(ne,{label:"Canvas color",value:Ar(d.canvas),onChange:g=>c({canvas:b(g)})}):null]})]}),/* @__PURE__ */i(C,{label:"Cards",children:[/* @__PURE__ */r(v,{label:"Style",children:/* @__PURE__ */r(R,{label:"Card style",value:u.pickers.cards,onChange:g=>c({cards:g}),options:[{value:"outlined",label:"Outlined",title:"A border on a tinted canvas"},{value:"raised",label:"Raised",title:"A shadow, no border"},{value:"open",label:"Open",title:"No border or shadow on a plain canvas"}]})}),/* @__PURE__ */r(v,{label:"Card corners",children:/* @__PURE__ */r(w,{label:"Card corners",value:d.cardCorners,...Z("cardCorners"),onChange:g=>c({corners:{cards:g}})})}),/* @__PURE__ */r(v,{label:"Control corners",children:/* @__PURE__ */r(w,{label:"Control corners",value:d.controlCorners,...Z("controlCorners"),onChange:g=>c({corners:{controls:g}})})}),/* @__PURE__ */r(v,{label:"Padding inside",children:/* @__PURE__ */r(w,{label:"Padding inside cards",value:n.schemes.light.tokens.spacing.cardPadding,min:0,max:32,onChange:g=>a(y=>y.tokens.spacing.cardPadding=g)})}),/* @__PURE__ */r(v,{label:"Table corners",children:/* @__PURE__ */r(w,{label:"Table corners",value:n.schemes.light.tokens.radius.table,min:0,max:12,onChange:g=>a(y=>on(y,"table",g))})})]}),s?/* @__PURE__ */i("p",{role:"alert",className:"px-5 text-[12px] text-destructive",children:[s.message," ",s.fix]}):null]});}function Bn({context:e}){const{draft:n,scheme:o,updateScheme:a,dashboardStyleSpec:t,editDashboardFields:l}=e,s=n.schemes[o].components.chart,m=t?Ce({organizationAppearance:t},o):null;return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Charts",children:"Series take colors in order."}),/* @__PURE__ */r(C,{label:`Series colors (${o})`,children:/* @__PURE__ */i("div",{className:"flex flex-wrap items-center gap-1.5 py-2",children:[s.palette.map((u,d)=>/* @__PURE__ */i("span",{className:"group/series relative",children:[/* @__PURE__ */r(ne,{label:`Series ${d+1}`,value:u||"#000000",onChange:c=>a(f=>f.components.chart.palette[d]=c)}),s.palette.length>1?/* @__PURE__ */r("button",{type:"button","aria-label":`Remove series ${d+1} color`,onClick:()=>a(c=>c.components.chart.palette.splice(d,1)),className:"absolute -right-1.5 -top-1.5 hidden h-3.5 w-3.5 place-items-center rounded-full bg-foreground text-background group-hover/series:grid group-focus-within/series:grid",children:/* @__PURE__ */r(Ge,{className:"h-2.5 w-2.5"})}):null]},d)),s.palette.length<12?/* @__PURE__ */r("button",{type:"button","aria-label":"Add a color",onClick:()=>a(u=>u.components.chart.palette.push("#64748b")),className:"grid h-6 w-6 place-items-center rounded-[4px] border border-dashed border-border text-muted-foreground hover:text-foreground",children:/* @__PURE__ */r(He,{className:"h-3 w-3"})}):null]})}),/* @__PURE__ */i(C,{label:"Bars and lines",children:[m?/* @__PURE__ */r(v,{label:"Bar corners",children:/* @__PURE__ */r(w,{label:"Bar corners",value:m.authored.barCorners,...Z("barCorners"),onChange:u=>l({barCorners:u})})}):null,/* @__PURE__ */r(E,{label:"Grid lines",value:s.gridColor,onChange:u=>a(d=>d.components.chart.gridColor=u)}),/* @__PURE__ */r(E,{label:"Axis labels",value:s.axisColor,onChange:u=>a(d=>d.components.chart.axisColor=u)})]})]});}function zn({context:e}){const{draft:n,scheme:o,updateScheme:a}=e,t=n.schemes[o];return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Filters and controls",children:"The bar above the cards, its chips, menus and panels."}),/* @__PURE__ */r(C,{label:"Toolbar",children:/* @__PURE__ */r(E,{label:"Background",value:t.components.interactive.toolbarBackground||t.tokens.color.background,onChange:l=>a(s=>s.components.interactive.toolbarBackground=l)})}),/* @__PURE__ */i(C,{label:"Chips",children:[/* @__PURE__ */r(E,{label:"Resting",hint:"Menus and panels too",value:t.components.interactive.background||t.tokens.color.card,onChange:l=>a(s=>{s.components.interactive.background=l,s.components.pagination.background=l;})}),/* @__PURE__ */r(E,{label:"Borders",value:t.components.interactive.borderColor||t.tokens.color.border,onChange:l=>a(s=>{s.components.interactive.borderColor=l,s.components.pagination.borderColor=l;})}),/* @__PURE__ */r(E,{label:"Selected",hint:"The Accent color",value:t.tokens.color.accent,onChange:l=>a(s=>ue(s,"accent",l))})]})]});}function _n({json:e,onJsonChange:n,onApplyJson:o,onCopyJson:a,copied:t,onUpload:l,onReset:s,onRemove:m,removing:u}){return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Advanced",children:"Your brand as JSON, for version control or another organization."}),/* @__PURE__ */i(C,{label:"Brand spec",children:[/* @__PURE__ */r("div",{className:"my-2 h-[260px] overflow-hidden rounded-control border border-input",children:/* @__PURE__ */r(Rr,{ariaLabel:"Brand spec",value:e,onValueChange:n,language:"json",embedded:!0,hideLineNumbers:!0,dense:!0})}),/* @__PURE__ */i("div",{className:"flex flex-wrap gap-2 py-2",children:[/* @__PURE__ */r(B,{type:"button",size:"xs",onClick:o,children:"Apply"}),/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",onClick:a,children:[/* @__PURE__ */r(Kr,{className:"h-3.5 w-3.5"}),t?"Copied":"Copy"]}),/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",onClick:l,children:[/* @__PURE__ */r(Dr,{className:"h-3.5 w-3.5"}),"Upload a spec"]})]})]}),/* @__PURE__ */i(C,{label:"Start over",children:[/* @__PURE__ */r(v,{label:"Reset to the default look",hint:"Your saved brand stays until you save",children:/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",onClick:s,children:[/* @__PURE__ */r(Se,{className:"h-3.5 w-3.5"}),"Reset"]})}),m?/* @__PURE__ */r(v,{label:"Remove the brand",hint:"Dashboards use the default look",children:/* @__PURE__ */i(B,{type:"button",size:"xs",variant:"outline",className:"text-destructive",onClick:m,disabled:u,children:[/* @__PURE__ */r(Br,{className:"h-3.5 w-3.5"}),"Remove"]})}):null]})]});}const $n=[["horizontal","Rows"],["full","Grid"],["inner","Inner grid"],["vertical","Columns"],["outer","Frame only"],["none","None"]],Me=[["400","Regular"],["500","Medium"],["600","Semibold"],["700","Bold"]],Ln=[["solid","Solid"],["dashed","Dashed"],["dotted","Dotted"],["double","Double"],["none","None"]];function Mn({draft:e,shown:n=e,scheme:o,onDraftChange:a,onTargetChange:t,showPreview:l=!1}){var $,ae,L,Y,J,te;const[s,m]=k.useState("dashboards"),u=h=>{m(h),t==null||t(h);},[d,c]=k.useState(!1),f=Te(n,o,s),b=un(e,o,s),g=e.schemes[s==="documents"?"light":o].tokens.color,y=s==="documents"&&hn(e),D=fn(f,g.mutedForeground),S=h=>a(G(e,s,h)),O=h=>a(G(e,s,h,o)),oe=f.header.background!=="transparent";return/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(_,{title:"Tables",children:"Every table and Matrix shares this style; a card keeps only Wrap text and its totals row."}),/* @__PURE__ */r("div",{className:"px-5",children:/* @__PURE__ */r(R,{label:"Table style target",fill:!0,value:s,onChange:u,options:[{value:"dashboards",label:"Dashboards"},{value:"documents",label:"Documents"}]})}),s==="documents"?/* @__PURE__ */r(C,{label:"Documents",children:/* @__PURE__ */r(v,{label:"Same as dashboards",hint:"Off: reports print in their own style",children:/* @__PURE__ */r(W,{label:"Same as dashboards",checked:y,onCheckedChange:h=>a(bn(e,h))})})}):null,y?null:/* @__PURE__ */i(T,{children:[/* @__PURE__ */r(C,{label:"Start from",children:/* @__PURE__ */r("div",{className:"grid grid-cols-3 gap-2 py-2",children:qe.map(h=>{const X=V[h].values;return/* @__PURE__ */i("button",{type:"button","aria-pressed":D===h,onClick:()=>a(gn(e,s,h)),className:N("rounded-[6px] border p-2 text-left",D===h?"border-foreground ring-1 ring-foreground":"border-border hover:border-foreground/40"),children:[/* @__PURE__ */i("span",{"aria-hidden":!0,className:"block overflow-hidden rounded-[3px] border border-border/60 bg-background",children:[/* @__PURE__ */r("span",{className:N("block h-2",X.header.filled&&"bg-muted")}),[0,1,2].map(U=>/* @__PURE__ */r("span",{className:"block border-t border-border/50",style:{height:2+X.cell.paddingY}},U))]}),/* @__PURE__ */r("span",{className:"mt-1.5 block text-[12px] font-medium",children:V[h].label})]},h);})})}),/* @__PURE__ */i(C,{label:"Rows",children:[/* @__PURE__ */r(v,{label:"Row padding",children:/* @__PURE__ */r(w,{label:"Row padding",value:f.cell.paddingY,min:0,max:16,onChange:h=>S({cell:{paddingY:h}})})}),/* @__PURE__ */r(v,{label:"Column padding",children:/* @__PURE__ */r(w,{label:"Column padding",value:f.cell.paddingX,min:0,max:24,onChange:h=>S({cell:{paddingX:h}})})}),/* @__PURE__ */r(v,{label:"Text size",children:/* @__PURE__ */r(w,{label:"Text size",value:f.cell.fontSize,min:9,max:18,onChange:h=>S({cell:{fontSize:h}})})}),/* @__PURE__ */r(v,{label:"Values in tall rows",children:/* @__PURE__ */r(R,{label:"Values in tall rows",value:f.cell.verticalAlign,onChange:h=>S({cell:{verticalAlign:h}}),options:[{value:"top",label:"Top"},{value:"middle",label:"Middle"},{value:"bottom",label:"Bottom"}]})}),/* @__PURE__ */r(v,{label:"Lines",children:/* @__PURE__ */r(z,{label:"Lines",value:f.rows.borders,options:$n,width:120,onChange:h=>S({borders:h})})}),/* @__PURE__ */r(v,{label:"Striped rows",children:/* @__PURE__ */r(W,{label:"Striped rows",checked:f.rows.zebra,onCheckedChange:h=>S({row:{zebra:h}})})})]}),/* @__PURE__ */i(C,{label:"Header",children:[/* @__PURE__ */r(v,{label:"Text size",children:/* @__PURE__ */r(w,{label:"Header text size",value:f.header.fontSize,min:9,max:18,onChange:h=>S({header:{fontSize:h}})})}),/* @__PURE__ */r(v,{label:"Padding",children:/* @__PURE__ */r(w,{label:"Header padding",value:f.header.paddingY,min:0,max:16,onChange:h=>S({header:{paddingY:h}})})}),/* @__PURE__ */r(v,{label:"Weight",children:/* @__PURE__ */r(z,{label:"Header weight",value:String(f.header.fontWeight),options:Me,width:110,onChange:h=>S({header:{fontWeight:Number(h)}})})}),/* @__PURE__ */r(v,{label:"Capitals",children:/* @__PURE__ */r(W,{label:"Header capitals",checked:f.header.uppercase,onCheckedChange:h=>S({header:{uppercase:h}})})}),/* @__PURE__ */i(v,{label:"Band",children:[oe?/* @__PURE__ */r(ne,{label:"Band",value:(($=b.header)==null?void 0:$.background)??g.accent,onChange:h=>O({header:{background:h}})}):null,/* @__PURE__ */r(W,{label:"Header band",checked:oe,onCheckedChange:h=>a(pn(e,s,o,h))})]}),/* @__PURE__ */r(E,{label:"Header text",value:((ae=b.header)==null?void 0:ae.foreground)??g.mutedForeground,onChange:h=>O({header:{foreground:h}})})]}),/* @__PURE__ */i("button",{type:"button",onClick:()=>c(!d),className:"flex w-full items-center gap-1 px-5 py-2 text-[12px] text-muted-foreground hover:text-foreground",children:[/* @__PURE__ */r(Ve,{className:N("h-3 w-3 transition-transform",d&&"rotate-90")}),"Totals row, wrapping and lines"]}),d?/* @__PURE__ */i(T,{children:[/* @__PURE__ */i(C,{label:"Totals row",children:[/* @__PURE__ */r(E,{label:"Background",value:((L=b.grandTotal)==null?void 0:L.background)??g.card,onChange:h=>O({grandTotal:{background:h}})}),/* @__PURE__ */r(E,{label:"Text",value:((Y=b.grandTotal)==null?void 0:Y.foreground)??g.foreground,onChange:h=>O({grandTotal:{foreground:h}})}),/* @__PURE__ */r(v,{label:"Weight",children:/* @__PURE__ */r(z,{label:"Totals weight",value:String(f.totals.fontWeight),options:Me,width:110,onChange:h=>S({grandTotal:{fontWeight:Number(h)}})})}),/* @__PURE__ */r(v,{label:"Rule above",children:/* @__PURE__ */r(z,{label:"Totals rule",value:((J=b.grandTotal)==null?void 0:J.borderTop)??"solid",options:Ln,width:110,onChange:h=>S({grandTotal:{borderTop:h}})})})]}),/* @__PURE__ */i(C,{label:"More",children:[/* @__PURE__ */r(v,{label:"Wrap long text",hint:"A card can turn it on for itself",children:/* @__PURE__ */r(W,{label:"Cell wrap",checked:f.cell.wrap,onCheckedChange:h=>S({cell:{wrap:h?"wrap":"nowrap"}})})}),/* @__PURE__ */r(v,{label:"Wrap header",hint:"Tables; Matrix keeps one line",children:/* @__PURE__ */r(W,{label:"Wrap header",checked:f.header.wrap,onCheckedChange:h=>S({header:{wrap:h}})})}),s==="dashboards"?/* @__PURE__ */r(v,{label:"Sticky header",children:/* @__PURE__ */r(W,{label:"Sticky header",checked:f.header.sticky,onCheckedChange:h=>S({header:{sticky:h}})})}):null,s==="dashboards"?/* @__PURE__ */r(E,{label:"Divider",value:((te=b.row)==null?void 0:te.dividerColor)??g.border,onChange:h=>O({row:{dividerColor:h},header:{dividerColor:h}})}):null]})]}):null]}),l?/* @__PURE__ */r("div",{className:"px-5 pb-5",children:/* @__PURE__ */r(Yn,{draft:n,scheme:o,target:s})}):null]});}const In=[{region:"North",status:"Succeeded",orders:1284,revenue:98765.43,note:"Quarter closed early"},{region:"South",status:"Failed",orders:342,revenue:12034.5,note:"Retry scheduled after the warehouse sync finished late"},{region:"East",status:"Running",orders:905,revenue:45210.2,note:""}],Wn={id:"brand-studio-table-preview",type:"table",title:"Preview",config:{},preferences:{tablePrefs:{tableStyle:{totals:{enabled:!0}}}}},jn={region:"Total",orders:2531,revenue:155010.13};function Yn({draft:e,scheme:n,target:o}){const a=k.useMemo(()=>({...e,mode:o==="documents"?"light":n}),[e,n,o]),t=/* @__PURE__ */r(Ue,{card:Wn,data:In,totalsByColumnId:jn,suppressSortControls:!0}),l=o==="documents"?Te(e,"light","documents"):void 0;return/* @__PURE__ */r("div",{"aria-label":"Table preview",className:"overflow-hidden rounded-control border border-border/60",children:/* @__PURE__ */r(We,{organizationAppearance:a,children:l?/* @__PURE__ */r("div",{className:"bg-white p-3",children:/* @__PURE__ */r("div",{className:Ye(l),style:je({style:l,isSliced:!0}),children:/* @__PURE__ */r(Je,{value:"document",children:t})})}):t})});}const Jn=[{id:"brand",label:"Brand",icon:zr},{id:"colors",label:"Colors",icon:Gr},{id:"type",label:"Typography",icon:_r},{id:"dashboards",label:"Dashboards",icon:Xr},{id:"charts",label:"Charts",icon:$r},{id:"tables",label:"Tables",icon:Lr},{id:"filters",label:"Filters and controls",icon:Mr},{id:"advanced",label:"Advanced",icon:Ir}],Un={tables:"table"};function ho({appearance:e,layout:n="panel",isLoading:o=!1,isSaving:a=!1,error:t=null,className:l,onDraftChange:s,onSave:m,onClearConfig:u,onCancel:d}){const[c,f]=k.useState(null),[b,g]=k.useState("light"),[y,D]=k.useState("brand"),[S,O]=k.useState("dashboard"),[oe,$]=k.useState(!1),[ae,L]=k.useState("idle"),[Y,J]=k.useState(""),[te,h]=k.useState(null),X=k.useRef(null),U=k.useRef(s),K=k.useRef(!1);k.useEffect(()=>{U.current=s;},[s]),k.useEffect(()=>{if(e===void 0){K.current=!0,f(null);return;}K.current=!0,f(j(e)),g("light"),h(null);},[e]);const P=k.useMemo(()=>{if(!c)return{spec:null,error:null};try{return{spec:ee(c),error:null};}catch(p){return{spec:null,error:de(p)};}},[c]),[A,ar]=k.useState(null);c&&P.spec&&c!==(A==null?void 0:A.draft)&&ar({draft:c,spec:P.spec});const Fe=P.spec?c:(A==null?void 0:A.draft)??c,Ee=P.spec??(A==null?void 0:A.spec)??null;k.useEffect(()=>{var p;if(c){if(K.current){K.current=!1;return;}P.spec&&((p=U.current)==null||p.call(U,P.spec)),h(null);}},[c,P]);const le=a||oe,H=k.useMemo(()=>c?tn(c,e):0,[c,e]),Oe=p=>{f(x=>{if(!x)return x;const I=Hn(x);return p(I),I;});},he=Ee,tr=p=>{if(!he)return null;const x=Ur({spec:he,edit:p,mode:b});return x.ok?(f(j(x.spec)),null):x.refusal;},lr=async()=>{if(!c||!m)return;let p;try{p=ee(c);}catch(x){h(de(x));return;}$(!0);try{await m(p);}finally{$(!1);}},se=p=>{L("idle");try{J(JSON.stringify(fe(p),null,2));}catch{}},sr=()=>{const p=j(e??null);f(p),se(p),h(null);},dr=()=>{const p=j(null);f(p),se(p);},cr=async()=>{if(u){$(!0),h(null);try{await u(),K.current=!0;const p=j(null);f(p),se(p),g("light");}catch(p){h(p instanceof Error?p.message:"Unable to remove the brand");}finally{$(!1);}}},Pe=p=>{const x=j(JSON.parse(p));L("idle"),g("light"),f(x),J(JSON.stringify(fe(x),null,2));},ir=()=>{try{Pe(Y);}catch(p){h(p instanceof SyntaxError?"The brand spec isn't valid JSON.":de(p));}},ur=async()=>{try{await navigator.clipboard.writeText(Y),L("copied");}catch(p){h(p instanceof Error?p.message:"Unable to copy brand spec");}},hr=async p=>{var I;const x=(I=p.target.files)==null?void 0:I[0];if(p.target.value="",!!x)try{Pe(await Vn(x));}catch(Re){h(Re instanceof SyntaxError?"The uploaded file isn't valid JSON.":de(Re));}},pr=p=>{p==="advanced"&&y!=="advanced"&&c&&se(c),D(p);const x=Un[p];x&&S==="dashboard"&&O(x);},M=c?{draft:c,scheme:b,setDraft:p=>f(p),updateScheme:p=>Oe(x=>p(x.schemes[b])),updateBoth:p=>Oe(x=>{p(x.schemes.light),p(x.schemes.dark);}),dashboardStyleSpec:he,editDashboardFields:tr}:null,F=n==="page",Ae=c?Ne(c).length>0:!1,q=te??P.error,br=q?/* @__PURE__ */r("span",{className:"truncate text-[12px] text-destructive",title:q,children:"Fix the brand to save"}):le?/* @__PURE__ */i("span",{className:"inline-flex items-center gap-1 text-[12px] text-muted-foreground",children:[/* @__PURE__ */r(Be,{className:"h-3.5 w-3.5 animate-spin"})," Saving"]}):H?/* @__PURE__ */r("span",{className:"text-[12px] text-muted-foreground",children:"Unsaved changes"}):/* @__PURE__ */i("span",{className:"inline-flex items-center gap-1 text-[12px] text-muted-foreground",children:[/* @__PURE__ */r(Wr,{className:"h-3.5 w-3.5 text-emerald-600"})," Up to date"]});return/* @__PURE__ */i("div",{className:N("flex min-h-0 flex-1 flex-col bg-background text-foreground",l),children:[/* @__PURE__ */i("header",{className:"flex h-11 shrink-0 items-center gap-3 border-b border-border/60 px-4",children:[/* @__PURE__ */r("h2",{className:"text-[13px] font-semibold",children:"Brand Studio"}),/* @__PURE__ */i("div",{className:"ml-auto flex min-w-0 items-center gap-2",children:[br,F?null:/* @__PURE__ */r(R,{label:"Scheme",value:b,onChange:g,options:[{value:"light",label:"Light"},{value:"dark",label:"Dark"}]}),/* @__PURE__ */r(B,{type:"button",size:"xs",variant:"ghost",onClick:sr,disabled:!c||!H&&!P.error||le,children:"Discard"}),/* @__PURE__ */r(B,{type:"button",size:"xs",onClick:lr,disabled:!c||le||!!q||!m||!H,children:H?`Save ${H} change${H===1?"":"s"}`:"Save"}),d?/* @__PURE__ */r("button",{type:"button","aria-label":"Close Brand Studio",className:"flex h-7 w-7 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:d,children:/* @__PURE__ */r(Ge,{className:"h-3.5 w-3.5"})}):null]})]}),q?/* @__PURE__ */r("div",{className:"shrink-0 border-b border-destructive/20 bg-destructive/5 px-4 py-2 text-[12px] text-destructive",children:q}):null,/* @__PURE__ */r("input",{ref:X,"aria-label":"Upload brand spec",type:"file",accept:"application/json,.json",className:"sr-only",onChange:hr}),o?/* @__PURE__ */r("div",{className:"flex flex-1 items-center justify-center",children:/* @__PURE__ */r(Be,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):t?/* @__PURE__ */r("div",{className:"p-4 text-[13px] text-muted-foreground",children:t}):c&&M?/* @__PURE__ */i("div",{className:"flex min-h-0 flex-1",children:[/* @__PURE__ */r("nav",{"aria-label":"Brand Studio sections",className:N("shrink-0 overflow-y-auto border-r border-border/60 p-2",F?"w-[188px]":"w-[52px]"),children:Jn.map(({id:p,label:x,icon:I})=>/* @__PURE__ */i("button",{type:"button","aria-current":y===p?"page":void 0,title:F?void 0:x,"aria-label":F?void 0:p==="colors"&&Ae?`${x}, needs attention`:x,onClick:()=>pr(p),className:N("relative flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px]",y===p?"bg-muted font-medium text-foreground":"text-muted-foreground hover:bg-muted/50 hover:text-foreground",!F&&"justify-center"),children:[/* @__PURE__ */r(I,{className:"h-3.5 w-3.5 shrink-0"}),F?/* @__PURE__ */r("span",{className:"truncate",children:x}):null,p==="colors"&&Ae?/* @__PURE__ */i(T,{children:[/* @__PURE__ */r("span",{"aria-hidden":!0,className:N("h-1.5 w-1.5 rounded-full bg-amber-500",F?"ml-auto":"absolute right-1.5 top-1.5")}),F?/* @__PURE__ */r("span",{className:"sr-only",children:", needs attention"}):null]}):null]},p))}),/* @__PURE__ */i("div",{className:N("min-w-0 overflow-y-auto pb-6",F?"w-[360px] shrink-0 border-r border-border/60":"flex-1"),children:[y==="brand"?/* @__PURE__ */r(En,{context:M}):null,y==="colors"?/* @__PURE__ */r(An,{context:M}):null,y==="type"?/* @__PURE__ */r(Rn,{context:M}):null,y==="dashboards"?/* @__PURE__ */r(Dn,{context:M}):null,y==="charts"?/* @__PURE__ */r(Bn,{context:M}):null,y==="tables"?/* @__PURE__ */r(Mn,{draft:c,shown:Fe??c,scheme:b,onDraftChange:f,onTargetChange:p=>O(p==="documents"?"document":"table"),showPreview:!F}):null,y==="filters"?/* @__PURE__ */r(zn,{context:M}):null,y==="advanced"?/* @__PURE__ */r(_n,{json:Y,onJsonChange:p=>{J(p),L("idle");},onApplyJson:ir,onCopyJson:ur,copied:ae==="copied",onUpload:()=>{var p;return(p=X.current)==null?void 0:p.click();},onReset:dr,onRemove:u?cr:void 0,removing:le}):null]}),F?/* @__PURE__ */r(vn,{draft:Fe??c,appearance:Ee,scheme:b,view:S,onSchemeChange:g,onViewChange:O}):null]}):null]});}function Hn(e){return JSON.parse(JSON.stringify(e));}function Vn(e){return typeof e.text=="function"?e.text():new Promise((n,o)=>{const a=new FileReader();a.onload=()=>n(String(a.result??"")),a.onerror=()=>o(a.error??new Error("Unable to read file")),a.readAsText(e);});}export{ge as BRAND_STUDIO_PRESETS,ho as BrandStudioEditor,nn as applyBrandStudioPreset,ee as brandStudioSaveSpec,fe as buildAppearanceSpecFromDraft,j as createBrandStudioDraft};