react-semaphor 0.1.556 → 0.1.557

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 (75) hide show
  1. package/DATA_APP_SDK.md +6 -29
  2. package/dist/analytics-protocol/index.js +19 -20
  3. package/dist/assistant-context/index.js +1 -1
  4. package/dist/brand-studio/index.js +28 -29
  5. package/dist/briefings/index.js +55 -56
  6. package/dist/chunks/{assistant-chat-C7Acww1T.js → assistant-chat-WMTpYirZ.js} +78 -80
  7. package/dist/chunks/{bookmark-state-7iZErWnR.js → bookmark-state-PjQpxbG7.js} +3 -3
  8. package/dist/chunks/{braces-o9UiRQes.js → braces-BOErQVyi.js} +1 -1
  9. package/dist/chunks/{comparison-window-caption-BseG5aOZ.js → comparison-window-caption-Dc7BaCMz.js} +186 -189
  10. package/dist/chunks/{custom-visual-inputs-ChuKjx27.js → custom-visual-inputs-CxYI-gFa.js} +1 -1
  11. package/dist/chunks/{dashboard-BU6rE5kV.js → dashboard-4D8Vy4pL.js} +1 -1
  12. package/dist/chunks/{dashboard-briefing-launcher-qrYd2zkN.js → dashboard-briefing-launcher-C4EmOfxs.js} +147 -149
  13. package/dist/chunks/{dashboard-controls-BsapXI2H.js → dashboard-controls-DBWykmvL.js} +170 -172
  14. package/dist/chunks/{dashboard-json-CJqPqYnI.js → dashboard-json-DiX-p0F7.js} +20 -21
  15. package/dist/chunks/{document-dashboard-inputs-BNSprf5_.js → document-dashboard-inputs-DP5hquBR.js} +30 -30
  16. package/dist/chunks/{edit-dashboard-visual-CjAdV-WG.js → edit-dashboard-visual-n1jLV_7V.js} +4773 -4802
  17. package/dist/chunks/{filter-reach-copy-BTrqtFkh.js → filter-reach-copy-BB9iakLA.js} +147 -148
  18. package/dist/chunks/{filter-value-text-CJTJDCym.js → filter-value-text-CUBpotVN.js} +3 -3
  19. package/dist/chunks/{global-date-filter-utils-CTVf3dG3.js → global-date-filter-utils-Cc5tqkoW.js} +585 -591
  20. package/dist/chunks/{index-B_vIRa-q.js → index-CgjhzkKM.js} +69 -70
  21. package/dist/chunks/{layout-grid-Bgzth8vd.js → layout-grid-CcNklCwL.js} +1 -1
  22. package/dist/chunks/{list-filter-DsaTbM3J.js → list-filter-Ds_4UTpD.js} +1 -1
  23. package/dist/chunks/{matrix-analytical-definition-Cg0ioFGQ.js → matrix-analytical-definition-4GTUDheD.js} +3 -3
  24. package/dist/chunks/{matrix-card-yYibXSw1.js → matrix-card-fS_4O7zA.js} +2 -2
  25. package/dist/chunks/{matrix-member-presentation-DEEauKXC.js → matrix-member-presentation-Dj7HaAHC.js} +1 -1
  26. package/dist/chunks/{matrix-operation-contract-C1G6AJNh.js → matrix-operation-contract-CpgLZ7E5.js} +21 -21
  27. package/dist/chunks/{metric-comparison-BfcmwxM1.js → metric-comparison-C8LY7GG5.js} +1 -1
  28. package/dist/chunks/{palette-D10o_yYX.js → palette-DMkIhagj.js} +1 -1
  29. package/dist/chunks/{matrix-formatter-C2kjsCDf.js → pivot-result-contract-expectations-DMk-mKhG.js} +444 -395
  30. package/dist/chunks/{pivot-result-identity-CWi5WrrY.js → pivot-result-identity-CrQ54Xbj.js} +1 -1
  31. package/dist/chunks/{raw-temporal-presentation-DWzLIHc3.js → raw-temporal-presentation-DdEpgPRB.js} +24 -25
  32. package/dist/chunks/report-preferences-dialog-CFg5VFLk.js +2109 -0
  33. package/dist/chunks/{report-runtime-context-BgM-iNWB.js → report-runtime-context-CohdtiMg.js} +1 -1
  34. package/dist/chunks/{resolve-dashboard-input-context-Df8V5QHW.js → resolve-dashboard-input-context-Djl3kCFL.js} +224 -226
  35. package/dist/chunks/{save-CfJpQQ68.js → save-D1EpMcwT.js} +1 -1
  36. package/dist/chunks/{saved-dashboard-context-VvXI6r03.js → saved-dashboard-context-umlQFevH.js} +8 -8
  37. package/dist/chunks/selection-reducer-_d6aKJnj.js +46 -0
  38. package/dist/chunks/{semaphor-ready-indicator-fejZmdq9.js → semaphor-ready-indicator-4cOp6sla.js} +40458 -43400
  39. package/dist/chunks/{shelf-drop-preview-context-BuTCXe-S.js → shelf-drop-preview-context-DAtRuvR7.js} +6 -6
  40. package/dist/chunks/{source-entity-resolution-B46EZIzX.js → source-entity-resolution-DXW1HpKf.js} +1 -1
  41. package/dist/chunks/{switch-Bq92UGId.js → switch-9CJt5EF_.js} +1430 -1341
  42. package/dist/chunks/{table-export-sheet-noKl8-en.js → table-export-sheet-CTCTA_bd.js} +1 -1
  43. package/dist/chunks/{table-settings-PpINOzw8.js → table-settings-DF1gdVQR.js} +2 -2
  44. package/dist/chunks/temporal-input-presentation-DoSniQj1.js +2939 -0
  45. package/dist/chunks/{token-types--0bgRCaO.js → token-types-DFyLflLY.js} +1 -1
  46. package/dist/chunks/{upload-BFX7apKV.js → upload-LSNKpt0w.js} +1 -1
  47. package/dist/chunks/{use-create-flow-overlay-state-Cz-ve64t.js → use-create-flow-overlay-state-esyMT9vU.js} +124 -126
  48. package/dist/chunks/{validators-CZo_H4E6.js → validators-hmfNNQz8.js} +5 -5
  49. package/dist/chunks/zoned-wall-clock-E35Frf9v.js +191 -0
  50. package/dist/dashboard/index.js +2 -2
  51. package/dist/dashboard-authoring/index.js +130 -131
  52. package/dist/data-app-sdk/index.js +788 -4153
  53. package/dist/data-app-sdk-adapters/index.js +2 -2
  54. package/dist/data-app-sdk-validation/index.js +5 -5
  55. package/dist/format-utils/index.js +230 -233
  56. package/dist/index.js +216 -217
  57. package/dist/report-runtime-context/index.js +1 -1
  58. package/dist/style.css +1 -1
  59. package/dist/surfboard/index.js +2 -2
  60. package/dist/types/data-app-sdk/contracts.d.ts +0 -146
  61. package/dist/types/data-app-sdk/index.d.ts +0 -2
  62. package/dist/types/index.js +6 -6
  63. package/dist/types/shared/dashboard-authoring/filter-model/filter-definitions.d.ts +1 -7
  64. package/package.json +1 -3
  65. package/src/data-app-sdk/README.md +7 -31
  66. package/dist/chunks/pivot-result-contract-expectations-fKBHFPfz.js +0 -56
  67. package/dist/chunks/raw-temporal-contract-CjHaUIsE.js +0 -64
  68. package/dist/chunks/report-preferences-dialog-D_wrbIQt.js +0 -2261
  69. package/dist/chunks/selection-reducer-By4CSmEF.js +0 -111
  70. package/dist/chunks/temporal-bucket-DzyadxVY.js +0 -2071
  71. package/dist/chunks/temporal-input-presentation-CJWS4d0L.js +0 -879
  72. package/dist/chunks/x-4f5U2XwU.js +0 -100
  73. package/dist/chunks/zoned-wall-clock-MulfA26h.js +0 -129
  74. package/dist/types/data-app-sdk/devtools/index.d.ts +0 -49
  75. package/dist/types/data-app-sdk/devtools.d.ts +0 -1
@@ -0,0 +1,2109 @@
1
+ import { jsx as o, Fragment as te, jsxs as h } from "react/jsx-runtime";
2
+ import * as p from "react";
3
+ import jt, { useMemo as ee, useState as L, useEffect as J, createContext as $t, useRef as j, useCallback as K, useContext as qe, lazy as Ee, Suspense as Se, useLayoutEffect as Ce, Activity as Vt, useId as de } from "react";
4
+ import { b as Wt, b6 as He, bi as Kt, bj as qt, u as M, bk as gt, x as Ht, bl as Gt, bm as Jt, bn as Xt, bo as Yt, bp as ge, bq as yt, br as tt, bs as Zt, Z as ye, Y as Qt, bt as ea, bu as ta, _ as at, $ as aa, bv as ra, E as na, F as sa, S as la, B as oa, a as ia, U as da, bw as ca, D as ua, A as fa, C as ma, bx as ha, by as pa, bz as va, bA as ba, bB as ga, bC as ya, bD as rt, bE as ke, bF as wa, bG as Ge, bH as G, bI as Sa, bJ as xa, bK as Ca, bL as Ia, bM as Ea } from "./semaphor-ready-indicator-4cOp6sla.js";
5
+ import { j as Na } from "./index-CuHybtft.js";
6
+ import { I as Ta } from "./table-settings-DF1gdVQR.js";
7
+ import { r as ka, a as wt } from "./availability-Bp5Gfu1I.js";
8
+ import { s as Aa } from "./global-date-filter-utils-Cc5tqkoW.js";
9
+ import { B as q, Q as Ra, U as Da, V as _a, W as Pa, Y as Oa, Z as La, _ as oe, D as Q, $ as he, m as pe, P as za, a as Fa, b as Ma, d as nt, L as St, s as ze, t as Fe, u as Me, v as Ue, w as Y, T as Ua, e as Ba, f as st, h as lt } from "./switch-9CJt5EF_.js";
10
+ import "./validators-hmfNNQz8.js";
11
+ import "./matrix-operation-contract-CpgLZ7E5.js";
12
+ import "./analytics-base-schemas-BUFUoO6G.js";
13
+ import "zod";
14
+ import { parseValueFormatPreferencesResponse as ja, canonicalizeSupportedLocale as xt, getSupportedCurrencyCodes as $a, canonicalizeSupportedCurrencyCode as Va } from "../value-format-preferences/index.js";
15
+ import { c as B } from "./_commonjsHelpers-DimLPMtv.js";
16
+ import { a as Wa } from "./filter-reach-copy-BB9iakLA.js";
17
+ import { a as Ka } from "./report-runtime-context-CohdtiMg.js";
18
+ import { r as we, a9 as ce } from "./temporal-input-presentation-DoSniQj1.js";
19
+ function qa() {
20
+ return /* @__PURE__ */ o(
21
+ "div",
22
+ {
23
+ role: "dashboard-plus-main",
24
+ className: "flex min-h-0 grow basis-0 overflow-hidden",
25
+ children: /* @__PURE__ */ o("section", { className: "flex min-h-0 grow basis-0 flex-col overflow-hidden", children: /* @__PURE__ */ o(Wt, {}) })
26
+ }
27
+ );
28
+ }
29
+ const Ha = /* @__PURE__ */ new Set(["iat", "exp", "nbf", "jti"]);
30
+ function Ga(e) {
31
+ return Aa(
32
+ Object.fromEntries(
33
+ Object.entries(e ?? {}).filter(([a]) => !Ha.has(a))
34
+ )
35
+ );
36
+ }
37
+ function Ja(e) {
38
+ var t;
39
+ const a = e == null ? void 0 : e.config;
40
+ return ka({
41
+ features: ((t = a == null ? void 0 : a.projectFeatures) == null ? void 0 : t.features) ?? {},
42
+ config: { enabled: wt(a).enabled },
43
+ identity: {
44
+ orgUserId: e == null ? void 0 : e.orgUserId,
45
+ tenantId: e == null ? void 0 : e.tenantId,
46
+ endUserId: e == null ? void 0 : e.endUserId
47
+ },
48
+ modelConfigured: !0
49
+ });
50
+ }
51
+ let ot = 0;
52
+ function it(e, a) {
53
+ ot += 1;
54
+ const { name: t, layout: n } = wt(a == null ? void 0 : a.config);
55
+ return { ...qt(n), id: ot, callerKey: e, assistantName: t };
56
+ }
57
+ function Xa({
58
+ children: e,
59
+ authToken: a
60
+ }) {
61
+ const t = He(), n = ee(
62
+ () => a === void 0 ? t.tokenProps : Za(a),
63
+ [a, t.tokenProps]
64
+ ), r = ee(() => Ga(n), [n]), l = ee(
65
+ () => Ja(n).available,
66
+ [n]
67
+ ), [s, i] = L(() => it(r, n));
68
+ s.callerKey !== r && i(it(r, n)), Qa(s);
69
+ const m = ee(() => ({ instance: s, available: l }), [s, l]);
70
+ return /* @__PURE__ */ o(Kt.Provider, { value: m, children: e });
71
+ }
72
+ function Ya({ children: e }) {
73
+ return gt() ? /* @__PURE__ */ o(te, { children: e }) : /* @__PURE__ */ o(Xa, { children: e });
74
+ }
75
+ function Za(e) {
76
+ if (!(e != null && e.accessToken)) return {};
77
+ try {
78
+ return Na(e.accessToken);
79
+ } catch {
80
+ return {};
81
+ }
82
+ }
83
+ function Qa(e) {
84
+ J(() => {
85
+ const a = (n, r) => {
86
+ const l = e.store.getState().focus;
87
+ l && !er(l, n, r) && e.clearFocus();
88
+ }, t = M.getState();
89
+ return a(t.selectedSheetId, t.dashboard), M.subscribe((n, r) => {
90
+ (n.selectedSheetId !== r.selectedSheetId || n.dashboard !== r.dashboard) && a(n.selectedSheetId, n.dashboard), n.isVisualEditing && !r.isVisualEditing && e.leaveBeside();
91
+ });
92
+ }, [e]);
93
+ }
94
+ function er(e, a, t) {
95
+ if ((a ?? null) !== e.sheetId) return !1;
96
+ const n = t ? Ta(t, e.cardId) : void 0;
97
+ return !!n && n.sheet.id === e.sheetId;
98
+ }
99
+ const tr = 640, ar = 960;
100
+ function rr(e) {
101
+ return e >= ar ? "lg" : e >= tr ? "md" : "sm";
102
+ }
103
+ function nr(e, a) {
104
+ return e === "always" ? !0 : e === "menu" ? !1 : e === "md" ? a !== "sm" : a === "lg";
105
+ }
106
+ const sr = {
107
+ width: "lg",
108
+ hasOverflowMenu: !1,
109
+ overflowItems: [],
110
+ register: () => () => {
111
+ },
112
+ openOverflowId: null,
113
+ setOpenOverflowId: () => {
114
+ },
115
+ anchorSlot: null,
116
+ setAnchorSlot: () => {
117
+ }
118
+ }, Je = $t(sr);
119
+ function kn() {
120
+ const [e, a] = L("lg"), t = j(null);
121
+ return { measure: K((r) => {
122
+ var s;
123
+ if ((s = t.current) == null || s.disconnect(), t.current = null, !r || typeof ResizeObserver > "u") return;
124
+ const l = (i) => a(rr(i));
125
+ l(r.getBoundingClientRect().width), t.current = new ResizeObserver(([i]) => {
126
+ i && l(i.contentRect.width);
127
+ }), t.current.observe(r);
128
+ }, []), width: e };
129
+ }
130
+ function lr() {
131
+ return qe(Je).width;
132
+ }
133
+ function An() {
134
+ return qe(Je).overflowItems;
135
+ }
136
+ function Rn(e, a, t) {
137
+ const n = qe(Je), r = n.hasOverflowMenu && !nr(a, n.width), { register: l, setOpenOverflowId: s } = n, i = t == null ? void 0 : t.label, m = t == null ? void 0 : t.hint, u = t == null ? void 0 : t.checked, y = (t == null ? void 0 : t.order) ?? 0, c = j(t == null ? void 0 : t.icon);
138
+ c.current = t == null ? void 0 : t.icon;
139
+ const v = j(t == null ? void 0 : t.onSelect);
140
+ v.current = t == null ? void 0 : t.onSelect;
141
+ const f = j(t == null ? void 0 : t.onOpen);
142
+ return f.current = t == null ? void 0 : t.onOpen, J(() => {
143
+ if (!(!r || i === void 0))
144
+ return l({
145
+ id: e,
146
+ label: i,
147
+ icon: c.current,
148
+ hint: m,
149
+ checked: u,
150
+ order: y,
151
+ onSelect: () => {
152
+ if (v.current) return v.current();
153
+ window.setTimeout(() => {
154
+ var w;
155
+ s(e), (w = f.current) == null || w.call(f);
156
+ }, 0);
157
+ }
158
+ });
159
+ }, [u, r, m, e, i, y, l, s]), {
160
+ collapsed: r,
161
+ popoverOpen: n.openOverflowId === e,
162
+ setPopoverOpen: (w) => s(w ? e : null),
163
+ anchorSlot: n.anchorSlot
164
+ };
165
+ }
166
+ const or = Ee(() => import("./assistant-chat-WMTpYirZ.js"));
167
+ function Dn() {
168
+ const e = Ht(), a = lr();
169
+ if (!e.available) return null;
170
+ const t = a !== "lg";
171
+ return /* @__PURE__ */ h(
172
+ q,
173
+ {
174
+ variant: e.isOpen ? "secondary" : "outline",
175
+ size: "xs",
176
+ "aria-pressed": e.isOpen,
177
+ "aria-label": e.assistantName,
178
+ title: t ? e.assistantName : void 0,
179
+ onClick: e.toggle,
180
+ className: t ? "w-7 px-0" : void 0,
181
+ children: [
182
+ /* @__PURE__ */ o(Gt, { className: "h-3.5 w-3.5" }),
183
+ !t && e.assistantName
184
+ ]
185
+ }
186
+ );
187
+ }
188
+ const ir = {
189
+ // Docked widths are the viewer's (the resize handle), applied as a style.
190
+ "docked-right": "relative shrink-0 border-l border-border",
191
+ "docked-left": "relative order-first shrink-0 border-r border-border",
192
+ centered: "absolute left-1/2 top-1/2 z-30 h-[min(80%,760px)] w-[min(640px,calc(100%-2rem))] -translate-x-1/2 -translate-y-1/2 rounded-card border border-border shadow-lg",
193
+ "full-page": "absolute inset-0 z-30"
194
+ }, dr = "absolute left-0 top-0 z-30 max-h-[var(--assistant-beside-max-h)] max-w-[var(--assistant-beside-max-w)] rounded-card border border-border shadow-lg", cr = 640, me = 8;
195
+ function ur({ surface: e = "dashboard" } = {}) {
196
+ const a = gt(), { isOpen: t, mounted: n, storedLayout: r, width: l, beside: s, besideSize: i, focusCardId: m, askCount: u } = Jt(
197
+ (a == null ? void 0 : a.instance.store) ?? Yt,
198
+ Xt((S) => {
199
+ var C;
200
+ return {
201
+ isOpen: S.isOpen,
202
+ mounted: S.mounted,
203
+ storedLayout: S.layout,
204
+ width: S.width,
205
+ beside: S.beside,
206
+ besideSize: S.besideSize,
207
+ focusCardId: (C = S.focus) == null ? void 0 : C.cardId,
208
+ askCount: S.askCount
209
+ };
210
+ })
211
+ ), y = e === "none", c = M(
212
+ (S) => s && t && m && !y ? fr(S.dashboard, S.selectedSheetId, m) : void 0
213
+ ), v = mr(c, u);
214
+ if (!(a != null && a.available) || !n && !y) return null;
215
+ const f = y ? "full-page" : v.shown ? "beside-card" : r, w = y || t, b = f === "docked-right" || f === "docked-left";
216
+ return /* @__PURE__ */ h(
217
+ "aside",
218
+ {
219
+ ref: v.setFloating,
220
+ "aria-label": a.instance.assistantName,
221
+ "data-testid": "assistant-panel",
222
+ "data-layout": f,
223
+ "data-beside-frame": f === "beside-card" ? c : void 0,
224
+ "data-beside-side": f === "beside-card" ? v.side : void 0,
225
+ className: B(
226
+ "flex-col bg-background",
227
+ f === "beside-card" ? dr : ir[f],
228
+ w ? "flex" : "hidden"
229
+ ),
230
+ style: f === "beside-card" ? { ...v.style, width: i.width, height: i.height } : (
231
+ // The saved width, never more than the share of the dashboard's area the
232
+ // handle allows, however the area is sized now or later (P4-10).
233
+ b ? { width: l, maxWidth: `${Ct * 100}%` } : void 0
234
+ ),
235
+ onKeyDown: f === "beside-card" ? (S) => {
236
+ if (S.key !== "Escape" || S.defaultPrevented || !(S.target instanceof Node) || !S.currentTarget.contains(S.target)) return;
237
+ S.preventDefault();
238
+ const C = v.cardActions();
239
+ a.instance.close(), C == null || C.focus();
240
+ } : void 0,
241
+ children: [
242
+ b ? /* @__PURE__ */ o(vr, { instance: a.instance, side: f === "docked-left" ? "right" : "left", width: l }) : null,
243
+ f === "beside-card" ? /* @__PURE__ */ o(pr, { instance: a.instance, size: i, side: v.handleSide }) : null,
244
+ /* @__PURE__ */ o(Se, { fallback: null, children: /* @__PURE__ */ o(or, { instance: a.instance, surface: e, placement: f }, a.instance.id) })
245
+ ]
246
+ }
247
+ );
248
+ }
249
+ function fr(e, a, t) {
250
+ var r, l, s;
251
+ const n = (r = e.sheets) == null ? void 0 : r.find((i) => i.id === a);
252
+ return (s = (l = n == null ? void 0 : n.frames) == null ? void 0 : l.find((i) => {
253
+ var m;
254
+ return (m = i.cards) == null ? void 0 : m.some((u) => u.id === t);
255
+ })) == null ? void 0 : s.id;
256
+ }
257
+ function mr(e, a) {
258
+ var w;
259
+ const [t, n] = L(void 0), [r, l] = L(void 0), s = j(a);
260
+ Ce(() => {
261
+ s.current = a;
262
+ });
263
+ const i = r === a ? null : t, { refs: m, elements: u, floatingStyles: y, middlewareData: c, isPositioned: v } = Ra({
264
+ strategy: "absolute",
265
+ placement: i ?? "right-start",
266
+ middleware: [
267
+ Da(me),
268
+ _a({ padding: me }),
269
+ Pa({
270
+ padding: me,
271
+ apply: ({ availableWidth: b, availableHeight: S, elements: C }) => {
272
+ C.floating.style.setProperty("--assistant-beside-max-w", `${Math.max(0, b)}px`), C.floating.style.setProperty("--assistant-beside-max-h", `${Math.max(0, S)}px`);
273
+ }
274
+ }),
275
+ Oa()
276
+ ],
277
+ whileElementsMounted: (b, S, C) => La(b, S, () => {
278
+ const _ = hr(b, S);
279
+ n(_), _ === null && l(s.current), C();
280
+ })
281
+ }), f = u.floating;
282
+ return Ce(() => {
283
+ m.setReference(e ? dt(f == null ? void 0 : f.parentElement, e) : null);
284
+ }, [e, f, m]), {
285
+ shown: e !== void 0 && i !== null && u.reference !== null,
286
+ setFloating: m.setFloating,
287
+ style: {
288
+ ...y,
289
+ // Not before it is placed (its side is chosen first): never a flash at
290
+ // the row's corner. With the card wholly out of view, it goes with the card.
291
+ ...!v || (w = c.hide) != null && w.referenceHidden ? { visibility: "hidden" } : {}
292
+ },
293
+ /** The side the conversation took; the size handle sits on the corner away from the card. */
294
+ side: i ?? void 0,
295
+ handleSide: i === "left-start" ? "left" : "right",
296
+ /** The card's ··· menu, where Ask lives and focus returns on Escape. */
297
+ cardActions: () => {
298
+ var b;
299
+ return e ? (b = dt(f == null ? void 0 : f.parentElement, e)) == null ? void 0 : b.querySelector("[data-card-actions]") : null;
300
+ }
301
+ };
302
+ }
303
+ function dt(e, a) {
304
+ return e ? Array.from(e.querySelectorAll("[data-frame-id]")).find((t) => t.dataset.frameId === a) ?? null : null;
305
+ }
306
+ function hr(e, a) {
307
+ const t = a.parentElement;
308
+ if (!t || !e.isConnected) return null;
309
+ const n = t.getBoundingClientRect();
310
+ if (n.width < cr) return null;
311
+ const r = e.getBoundingClientRect(), { min: l } = yt, s = (i, m) => i >= l.width + 2 * me && m >= l.height + 2 * me;
312
+ return s(n.right - r.right, n.height) ? "right-start" : s(r.left - n.left, n.height) ? "left-start" : s(n.width, n.bottom - r.bottom) ? "bottom-start" : null;
313
+ }
314
+ function pr({
315
+ instance: e,
316
+ size: a,
317
+ side: t
318
+ }) {
319
+ const n = j(void 0), r = t === "left" ? -1 : 1, l = (s) => {
320
+ const i = n.current;
321
+ return {
322
+ width: i.start.width + r * (s.clientX - i.x),
323
+ height: i.start.height + (s.clientY - i.y)
324
+ };
325
+ };
326
+ return /* @__PURE__ */ o(
327
+ "div",
328
+ {
329
+ role: "separator",
330
+ "aria-label": "Resize assistant",
331
+ tabIndex: 0,
332
+ title: "Drag to resize. Double-click to reset.",
333
+ onPointerDown: (s) => {
334
+ var i, m;
335
+ s.preventDefault(), (m = (i = s.currentTarget).setPointerCapture) == null || m.call(i, s.pointerId), n.current = { x: s.clientX, y: s.clientY, start: a };
336
+ },
337
+ onPointerMove: (s) => {
338
+ n.current && e.setBesideSize(l(s));
339
+ },
340
+ onPointerUp: (s) => {
341
+ n.current && (e.setBesideSize(l(s), { save: !0 }), n.current = void 0);
342
+ },
343
+ onPointerCancel: () => {
344
+ n.current = void 0;
345
+ },
346
+ onKeyDown: (s) => {
347
+ const i = {
348
+ ArrowLeft: { width: -r * le, height: 0 },
349
+ ArrowRight: { width: r * le, height: 0 },
350
+ ArrowUp: { width: 0, height: -le },
351
+ ArrowDown: { width: 0, height: le }
352
+ }[s.key];
353
+ i && (s.preventDefault(), e.setBesideSize({ width: a.width + i.width, height: a.height + i.height }, { save: !0 }));
354
+ },
355
+ onDoubleClick: () => e.setBesideSize(yt.default, { save: !0 }),
356
+ className: B(
357
+ "absolute bottom-0 z-10 h-3 w-3 touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
358
+ t === "left" ? "left-0 cursor-nesw-resize rounded-bl-card" : "right-0 cursor-nwse-resize rounded-br-card"
359
+ )
360
+ }
361
+ );
362
+ }
363
+ const le = 16, Ct = 0.6;
364
+ function vr({ instance: e, side: a, width: t }) {
365
+ const n = j(void 0), r = (c) => {
366
+ var f, w;
367
+ const v = (w = (f = c.closest("aside")) == null ? void 0 : f.parentElement) == null ? void 0 : w.clientWidth;
368
+ return v ? v * Ct : ge.max;
369
+ }, l = (c) => {
370
+ var v;
371
+ return ((v = c.closest("aside")) == null ? void 0 : v.getBoundingClientRect().width) || t;
372
+ }, s = (c) => {
373
+ const v = n.current;
374
+ if (!v) return t;
375
+ const f = c - v.startX;
376
+ return tt(v.startWidth + (a === "left" ? -f : f), v.maxForArea);
377
+ }, i = (c) => {
378
+ var v, f;
379
+ c.preventDefault(), (f = (v = c.currentTarget).setPointerCapture) == null || f.call(v, c.pointerId), n.current = { startX: c.clientX, startWidth: l(c.currentTarget), maxForArea: r(c.currentTarget) };
380
+ }, m = (c) => {
381
+ n.current && e.setWidth(s(c.clientX));
382
+ }, u = (c) => {
383
+ n.current && (e.setWidth(s(c.clientX), { save: !0 }), n.current = void 0);
384
+ }, y = (c) => {
385
+ if (c.key !== "ArrowLeft" && c.key !== "ArrowRight") return;
386
+ c.preventDefault();
387
+ const v = c.key === "ArrowLeft" == (a === "left");
388
+ e.setWidth(tt(l(c.currentTarget) + (v ? le : -le), r(c.currentTarget)), { save: !0 });
389
+ };
390
+ return /* @__PURE__ */ o(
391
+ "div",
392
+ {
393
+ role: "separator",
394
+ "aria-orientation": "vertical",
395
+ "aria-label": "Resize assistant",
396
+ "aria-valuenow": t,
397
+ "aria-valuemin": ge.min,
398
+ "aria-valuemax": ge.max,
399
+ tabIndex: 0,
400
+ title: "Drag to resize. Double-click to reset.",
401
+ onPointerDown: i,
402
+ onPointerMove: m,
403
+ onPointerUp: u,
404
+ onPointerCancel: u,
405
+ onKeyDown: y,
406
+ onDoubleClick: () => e.setWidth(ge.default, { save: !0 }),
407
+ className: B(
408
+ "absolute inset-y-0 z-10 w-1.5 cursor-col-resize touch-none outline-none hover:bg-primary/30 focus-visible:bg-primary/40",
409
+ a === "left" ? "-left-[3px]" : "-right-[3px]"
410
+ )
411
+ }
412
+ );
413
+ }
414
+ function br(e) {
415
+ const a = Zt();
416
+ return K(
417
+ async (t, n) => {
418
+ const r = M.getState();
419
+ if (r.isVisualEditing)
420
+ return { ok: !1, reason: "not_editable", message: ye.not_editable };
421
+ if (!e()) return { ok: !1, reason: "not_editable", message: ye.no_save };
422
+ if (r.dashboard !== t.basedOn)
423
+ return { ok: !1, reason: "dashboard_changed", message: ye.dashboard_changed };
424
+ const l = Wa(t.basedOn, t.operations, t.context);
425
+ if (!l.ok) return { ok: !1, reason: "refused", message: l.failedAt.message };
426
+ const s = { domainsById: {} };
427
+ for (const i of gr(t.basedOn, l.dashboard)) {
428
+ const m = await a(i, { reuseLoaded: !0 }).catch((u) => {
429
+ console.warn("Applying the change without refreshed semantic metadata:", u);
430
+ });
431
+ Qt(s, m);
432
+ }
433
+ return n != null && n.stillWanted && !n.stillWanted() ? { ok: !1, reason: "dropped" } : e() ? M.getState().actions.applyProposal({ ...t, semanticExecutionPayload: s }) : { ok: !1, reason: "not_editable", message: ye.no_save };
434
+ },
435
+ [e, a]
436
+ );
437
+ }
438
+ function gr(e, a) {
439
+ const t = new Set((e.sheets ?? []).flatMap((n) => n.frames ?? []));
440
+ return (a.sheets ?? []).flatMap((n) => (n.frames ?? []).filter((r) => !t.has(r)));
441
+ }
442
+ function yr(e) {
443
+ const { canEditDashboard: a, isInspectionMode: t } = ea(), n = ta(), r = M(at), l = e && n && a === !0 && !t, s = j(l);
444
+ Ce(() => {
445
+ s.current = l;
446
+ });
447
+ const i = K(
448
+ () => s.current && at(M.getState()),
449
+ []
450
+ );
451
+ return { canChange: l && r, canChangeNow: i };
452
+ }
453
+ const It = {
454
+ dashboard_changed: "Not applied: the dashboard on screen changed after this change was prepared.",
455
+ not_editable: "Not applied: the dashboard can't be changed on screen right now (the editor is open, or Save isn't shown).",
456
+ expired: "Not applied: it arrived after the time it had to land.",
457
+ refused: "Not applied: the change no longer fits the dashboard."
458
+ }, ue = {
459
+ changed: "Changed by your assistant",
460
+ undo: "Undo",
461
+ changedSince: "Changed since. Cancel discards every unsaved change.",
462
+ closeEditorToUndo: "Close the editor to undo."
463
+ };
464
+ function wr({
465
+ port: e,
466
+ onLifecycleEvent: a
467
+ }) {
468
+ const { canChange: t, canChangeNow: n } = yr(!0), r = M((f) => {
469
+ var w;
470
+ return (w = f.dashboard) == null ? void 0 : w.id;
471
+ }), l = br(n), [s, i] = L(null), m = j(/* @__PURE__ */ new Map()), u = j(/* @__PURE__ */ new Map()), y = j(Promise.resolve()), c = j({ apply: l, onLifecycleEvent: a });
472
+ Ce(() => {
473
+ c.current = { apply: l, onLifecycleEvent: a };
474
+ }), J(() => {
475
+ e.setScreenState({ eligible: t, ...r ? { dashboardId: r } : {} });
476
+ }, [e, t, r]), J(
477
+ () => M.subscribe((f, w) => {
478
+ if (f.editSessionEpoch !== w.editSessionEpoch) {
479
+ m.current.clear(), i(null);
480
+ return;
481
+ }
482
+ if (f.dashboard !== w.dashboard)
483
+ for (const [b, S] of m.current)
484
+ S !== f.dashboard && m.current.delete(b);
485
+ }),
486
+ []
487
+ ), J(() => {
488
+ const f = (b) => {
489
+ const S = M.getState().dashboard;
490
+ if (!S || S.id !== b.dashboardId) return;
491
+ const C = Cr();
492
+ m.current.set(C, S), e.answerCopyRequest({
493
+ kind: "uploaded",
494
+ screenId: e.screenId,
495
+ requestId: b.requestId,
496
+ revisionId: C,
497
+ dashboard: S
498
+ });
499
+ }, w = async (b, S) => {
500
+ var g, E, R;
501
+ const C = u.current.get(b.deliveryId);
502
+ if (C) {
503
+ e.reportOutcome({ screenId: e.screenId, deliveryId: b.deliveryId, outcome: C });
504
+ return;
505
+ }
506
+ const _ = m.current.get(b.revisionId), z = () => !_ || m.current.get(b.revisionId) !== _ ? "dashboard_changed" : performance.now() < S + b.applyWithinMs ? null : "expired", F = z();
507
+ let P;
508
+ if (F || !_)
509
+ P = xe(F ?? "dashboard_changed");
510
+ else {
511
+ let I = "expired";
512
+ const H = await c.current.apply(
513
+ { proposalId: b.proposalId, operations: b.operations, context: b.context, basedOn: _ },
514
+ {
515
+ stillWanted: () => {
516
+ const V = z();
517
+ return V && (I = V), V === null;
518
+ }
519
+ }
520
+ );
521
+ P = xr(H, I);
522
+ }
523
+ if (u.current.set(b.deliveryId, P), e.reportOutcome({ screenId: e.screenId, deliveryId: b.deliveryId, outcome: P }), P.status !== "applied") return;
524
+ const N = ((g = M.getState().dashboard) == null ? void 0 : g.id) ?? "";
525
+ i({ deliveryId: b.deliveryId, proposalId: b.proposalId, summary: b.summary, dashboardId: N, words: null }), (R = (E = c.current).onLifecycleEvent) == null || R.call(E, {
526
+ type: "dashboard:change-applied",
527
+ dashboardId: N,
528
+ payload: { deliveryId: b.deliveryId, summary: b.summary }
529
+ });
530
+ };
531
+ return e.subscribe((b) => {
532
+ if (b.type === "copy_request") {
533
+ f(b);
534
+ return;
535
+ }
536
+ const S = performance.now();
537
+ y.current = y.current.then(
538
+ () => w(b, S).catch((C) => console.error("[live-screen] a delivery failed", C))
539
+ );
540
+ });
541
+ }, [e]);
542
+ const v = K(() => {
543
+ var w, b;
544
+ if (!s) return;
545
+ const f = M.getState().actions.undoProposal(s.proposalId);
546
+ f.ok ? ((b = (w = c.current).onLifecycleEvent) == null || b.call(w, {
547
+ type: "dashboard:change-undone",
548
+ dashboardId: s.dashboardId,
549
+ payload: { deliveryId: s.deliveryId, summary: s.summary }
550
+ }), i(null)) : f.reason === "changed_since" ? i({ ...s, words: "changed_since" }) : f.reason === "not_editable" ? i({ ...s, words: "not_editable" }) : i(null);
551
+ }, [s]);
552
+ return s ? /* @__PURE__ */ o(Sr, { note: s, onUndo: v }) : null;
553
+ }
554
+ function Sr({ note: e, onUndo: a }) {
555
+ const t = M((s) => aa(s, e.proposalId)), n = M((s) => s.isVisualEditing);
556
+ if (t === "none" && e.words === null) return null;
557
+ const r = e.words === "changed_since" || t === "changed_since", l = r ? "changed_since" : e.words === "not_editable" ? "not_editable" : t;
558
+ return /* @__PURE__ */ h(
559
+ "div",
560
+ {
561
+ className: "flex min-h-8 items-center gap-2 border-b border-border bg-muted/40 px-3 py-1 text-xs text-muted-foreground",
562
+ "data-testid": "live-change-note",
563
+ "data-note-state": l,
564
+ role: "status",
565
+ children: [
566
+ /* @__PURE__ */ h("span", { className: "truncate", title: e.summary.join(" "), children: [
567
+ ue.changed,
568
+ r ? `. ${ue.changedSince}` : e.words === "not_editable" ? `. ${ue.closeEditorToUndo}` : ""
569
+ ] }),
570
+ !r && t === "undoable" ? /* @__PURE__ */ h(te, { children: [
571
+ /* @__PURE__ */ o("span", { "aria-hidden": "true", children: "·" }),
572
+ /* @__PURE__ */ h(
573
+ q,
574
+ {
575
+ variant: "outline",
576
+ size: "xs",
577
+ className: "h-6 gap-1 px-2 text-[11.5px]",
578
+ disabled: n,
579
+ title: n ? ue.closeEditorToUndo : void 0,
580
+ onClick: a,
581
+ children: [
582
+ /* @__PURE__ */ o(ra, { className: "h-3 w-3" }),
583
+ ue.undo
584
+ ]
585
+ }
586
+ )
587
+ ] }) : null
588
+ ]
589
+ }
590
+ );
591
+ }
592
+ function xr(e, a) {
593
+ if (e.ok) return { status: "applied" };
594
+ switch (e.reason) {
595
+ case "dashboard_changed":
596
+ case "not_editable":
597
+ return xe(e.reason);
598
+ case "refused":
599
+ return { status: "not_applied", reason: "refused", message: (e.message || It.refused).slice(0, 500) };
600
+ case "dropped":
601
+ return xe(a);
602
+ case "previous_not_applied":
603
+ return xe("refused");
604
+ }
605
+ }
606
+ function xe(e) {
607
+ return { status: "not_applied", reason: e, message: It[e] };
608
+ }
609
+ function Cr() {
610
+ return globalThis.crypto.randomUUID();
611
+ }
612
+ const Ir = Ee(() => import("./dashboard-controls-DBWykmvL.js")), Er = Ee(
613
+ () => import("./edit-dashboard-visual-n1jLV_7V.js")
614
+ ), Nr = Ee(() => import("./dashboard-json-DiX-p0F7.js"));
615
+ function _n({
616
+ showControls: e = !1,
617
+ showFooter: a = !0,
618
+ liveScreen: t,
619
+ ...n
620
+ }) {
621
+ const r = M((m) => m.isVisualEditing), l = M(
622
+ (m) => m.showDashboardJSON
623
+ ), { appearance: s, preferences: i } = n;
624
+ return /* @__PURE__ */ o(na, { FallbackComponent: sa, children: /* @__PURE__ */ o(la, { dashboardProps: n, children: /* @__PURE__ */ h(oa, { children: [
625
+ /* @__PURE__ */ o(ia, { componentType: "surfboard", componentId: n.id }),
626
+ /* @__PURE__ */ h(da, { appearance: s, children: [
627
+ /* @__PURE__ */ o(
628
+ ca,
629
+ {
630
+ toastOptions: {
631
+ classNames: {
632
+ toast: "max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",
633
+ content: "min-w-0 flex-1",
634
+ icon: "mt-0.5 shrink-0",
635
+ title: "max-w-full break-words pr-8",
636
+ description: "max-w-full break-words",
637
+ closeButton: "!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"
638
+ }
639
+ }
640
+ }
641
+ ),
642
+ /* @__PURE__ */ h(ua, { preferences: i, children: [
643
+ l && /* @__PURE__ */ o(Se, { fallback: null, children: /* @__PURE__ */ o(Nr, {}) }),
644
+ /* @__PURE__ */ o(fa, { children: /* @__PURE__ */ o(Ya, { children: /* @__PURE__ */ h("main", { className: "relative flex h-full w-full flex-col overflow-hidden", children: [
645
+ e && /* @__PURE__ */ o(Se, { fallback: null, children: /* @__PURE__ */ o(Ir, {}) }),
646
+ t && /* @__PURE__ */ o(wr, { port: t, onLifecycleEvent: n.onDashboardLifecycleEvent }),
647
+ /* @__PURE__ */ h("div", { className: "relative flex grow overflow-hidden", children: [
648
+ /* @__PURE__ */ o("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ h(ma, { ...n, type: "dashboard", children: [
649
+ r && /* @__PURE__ */ o(Se, { fallback: null, children: /* @__PURE__ */ o(Er, {}) }),
650
+ /* @__PURE__ */ o(Vt, { mode: r ? "hidden" : "visible", children: /* @__PURE__ */ o(qa, {}) })
651
+ ] }) }),
652
+ /* @__PURE__ */ o(ur, {})
653
+ ] })
654
+ ] }) }) })
655
+ ] })
656
+ ] })
657
+ ] }) }) });
658
+ }
659
+ var ct = 1, Tr = 0.9, kr = 0.8, Ar = 0.17, Ae = 0.1, Re = 0.999, Rr = 0.9999, Dr = 0.99, _r = /[\\\/_+.#"@\[\(\{&]/, Pr = /[\\\/_+.#"@\[\(\{&]/g, Or = /[\s-]/, Et = /[\s-]/g;
660
+ function Be(e, a, t, n, r, l, s) {
661
+ if (l === a.length) return r === e.length ? ct : Dr;
662
+ var i = `${r},${l}`;
663
+ if (s[i] !== void 0) return s[i];
664
+ for (var m = n.charAt(l), u = t.indexOf(m, r), y = 0, c, v, f, w; u >= 0; ) c = Be(e, a, t, n, u + 1, l + 1, s), c > y && (u === r ? c *= ct : _r.test(e.charAt(u - 1)) ? (c *= kr, f = e.slice(r, u - 1).match(Pr), f && r > 0 && (c *= Math.pow(Re, f.length))) : Or.test(e.charAt(u - 1)) ? (c *= Tr, w = e.slice(r, u - 1).match(Et), w && r > 0 && (c *= Math.pow(Re, w.length))) : (c *= Ar, r > 0 && (c *= Math.pow(Re, u - r))), e.charAt(u) !== a.charAt(l) && (c *= Rr)), (c < Ae && t.charAt(u - 1) === n.charAt(l + 1) || n.charAt(l + 1) === n.charAt(l) && t.charAt(u - 1) !== n.charAt(l)) && (v = Be(e, a, t, n, u + 1, l + 2, s), v * Ae > c && (c = v * Ae)), c > y && (y = c), u = t.indexOf(m, u + 1);
665
+ return s[i] = y, y;
666
+ }
667
+ function ut(e) {
668
+ return e.toLowerCase().replace(Et, " ");
669
+ }
670
+ function Lr(e, a, t) {
671
+ return e = t && t.length > 0 ? `${e + " " + t.join(" ")}` : e, Be(e, a, ut(e), ut(a), 0, 0, {});
672
+ }
673
+ var fe = '[cmdk-group=""]', De = '[cmdk-group-items=""]', zr = '[cmdk-group-heading=""]', Nt = '[cmdk-item=""]', ft = `${Nt}:not([aria-disabled="true"])`, je = "cmdk-item-select", ne = "data-value", Fr = (e, a, t) => Lr(e, a, t), Tt = p.createContext(void 0), ve = () => p.useContext(Tt), kt = p.createContext(void 0), Xe = () => p.useContext(kt), At = p.createContext(void 0), Rt = p.forwardRef((e, a) => {
674
+ let t = se(() => {
675
+ var d, T;
676
+ return { search: "", value: (T = (d = e.value) != null ? d : e.defaultValue) != null ? T : "", selectedItemId: void 0, filtered: { count: 0, items: /* @__PURE__ */ new Map(), groups: /* @__PURE__ */ new Set() } };
677
+ }), n = se(() => /* @__PURE__ */ new Set()), r = se(() => /* @__PURE__ */ new Map()), l = se(() => /* @__PURE__ */ new Map()), s = se(() => /* @__PURE__ */ new Set()), i = Dt(e), { label: m, children: u, value: y, onValueChange: c, filter: v, shouldFilter: f, loop: w, disablePointerSelection: b = !1, vimBindings: S = !0, ...C } = e, _ = oe(), z = oe(), F = oe(), P = p.useRef(null), N = Gr();
678
+ ae(() => {
679
+ if (y !== void 0) {
680
+ let d = y.trim();
681
+ t.current.value = d, g.emit();
682
+ }
683
+ }, [y]), ae(() => {
684
+ N(6, re);
685
+ }, []);
686
+ let g = p.useMemo(() => ({ subscribe: (d) => (s.current.add(d), () => s.current.delete(d)), snapshot: () => t.current, setState: (d, T, A) => {
687
+ var x, D, O, W;
688
+ if (!Object.is(t.current[d], T)) {
689
+ if (t.current[d] = T, d === "search") V(), I(), N(1, H);
690
+ else if (d === "value") {
691
+ if (document.activeElement.hasAttribute("cmdk-input") || document.activeElement.hasAttribute("cmdk-root")) {
692
+ let U = document.getElementById(F);
693
+ U ? U.focus() : (x = document.getElementById(_)) == null || x.focus();
694
+ }
695
+ if (N(7, () => {
696
+ var U;
697
+ t.current.selectedItemId = (U = X()) == null ? void 0 : U.id, g.emit();
698
+ }), A || N(5, re), ((D = i.current) == null ? void 0 : D.value) !== void 0) {
699
+ let U = T ?? "";
700
+ (W = (O = i.current).onValueChange) == null || W.call(O, U);
701
+ return;
702
+ }
703
+ }
704
+ g.emit();
705
+ }
706
+ }, emit: () => {
707
+ s.current.forEach((d) => d());
708
+ } }), []), E = p.useMemo(() => ({ value: (d, T, A) => {
709
+ var x;
710
+ T !== ((x = l.current.get(d)) == null ? void 0 : x.value) && (l.current.set(d, { value: T, keywords: A }), t.current.filtered.items.set(d, R(T, A)), N(2, () => {
711
+ I(), g.emit();
712
+ }));
713
+ }, item: (d, T) => (n.current.add(d), T && (r.current.has(T) ? r.current.get(T).add(d) : r.current.set(T, /* @__PURE__ */ new Set([d]))), N(3, () => {
714
+ V(), I(), t.current.value || H(), g.emit();
715
+ }), () => {
716
+ l.current.delete(d), n.current.delete(d), t.current.filtered.items.delete(d);
717
+ let A = X();
718
+ N(4, () => {
719
+ V(), (A == null ? void 0 : A.getAttribute("id")) === d && H(), g.emit();
720
+ });
721
+ }), group: (d) => (r.current.has(d) || r.current.set(d, /* @__PURE__ */ new Set()), () => {
722
+ l.current.delete(d), r.current.delete(d);
723
+ }), filter: () => i.current.shouldFilter, label: m || e["aria-label"], getDisablePointerSelection: () => i.current.disablePointerSelection, listId: _, inputId: F, labelId: z, listInnerRef: P }), []);
724
+ function R(d, T) {
725
+ var A, x;
726
+ let D = (x = (A = i.current) == null ? void 0 : A.filter) != null ? x : Fr;
727
+ return d ? D(d, t.current.search, T) : 0;
728
+ }
729
+ function I() {
730
+ if (!t.current.search || i.current.shouldFilter === !1) return;
731
+ let d = t.current.filtered.items, T = [];
732
+ t.current.filtered.groups.forEach((x) => {
733
+ let D = r.current.get(x), O = 0;
734
+ D.forEach((W) => {
735
+ let U = d.get(W);
736
+ O = Math.max(U, O);
737
+ }), T.push([x, O]);
738
+ });
739
+ let A = P.current;
740
+ k().sort((x, D) => {
741
+ var O, W;
742
+ let U = x.getAttribute("id"), be = D.getAttribute("id");
743
+ return ((O = d.get(be)) != null ? O : 0) - ((W = d.get(U)) != null ? W : 0);
744
+ }).forEach((x) => {
745
+ let D = x.closest(De);
746
+ D ? D.appendChild(x.parentElement === D ? x : x.closest(`${De} > *`)) : A.appendChild(x.parentElement === A ? x : x.closest(`${De} > *`));
747
+ }), T.sort((x, D) => D[1] - x[1]).forEach((x) => {
748
+ var D;
749
+ let O = (D = P.current) == null ? void 0 : D.querySelector(`${fe}[${ne}="${encodeURIComponent(x[0])}"]`);
750
+ O == null || O.parentElement.appendChild(O);
751
+ });
752
+ }
753
+ function H() {
754
+ let d = k().find((A) => A.getAttribute("aria-disabled") !== "true"), T = d == null ? void 0 : d.getAttribute(ne);
755
+ g.setState("value", T || void 0);
756
+ }
757
+ function V() {
758
+ var d, T, A, x;
759
+ if (!t.current.search || i.current.shouldFilter === !1) {
760
+ t.current.filtered.count = n.current.size;
761
+ return;
762
+ }
763
+ t.current.filtered.groups = /* @__PURE__ */ new Set();
764
+ let D = 0;
765
+ for (let O of n.current) {
766
+ let W = (T = (d = l.current.get(O)) == null ? void 0 : d.value) != null ? T : "", U = (x = (A = l.current.get(O)) == null ? void 0 : A.keywords) != null ? x : [], be = R(W, U);
767
+ t.current.filtered.items.set(O, be), be > 0 && D++;
768
+ }
769
+ for (let [O, W] of r.current) for (let U of W) if (t.current.filtered.items.get(U) > 0) {
770
+ t.current.filtered.groups.add(O);
771
+ break;
772
+ }
773
+ t.current.filtered.count = D;
774
+ }
775
+ function re() {
776
+ var d, T, A;
777
+ let x = X();
778
+ x && (((d = x.parentElement) == null ? void 0 : d.firstChild) === x && ((A = (T = x.closest(fe)) == null ? void 0 : T.querySelector(zr)) == null || A.scrollIntoView({ block: "nearest" })), x.scrollIntoView({ block: "nearest" }));
779
+ }
780
+ function X() {
781
+ var d;
782
+ return (d = P.current) == null ? void 0 : d.querySelector(`${Nt}[aria-selected="true"]`);
783
+ }
784
+ function k() {
785
+ var d;
786
+ return Array.from(((d = P.current) == null ? void 0 : d.querySelectorAll(ft)) || []);
787
+ }
788
+ function ie(d) {
789
+ let T = k()[d];
790
+ T && g.setState("value", T.getAttribute(ne));
791
+ }
792
+ function Te(d) {
793
+ var T;
794
+ let A = X(), x = k(), D = x.findIndex((W) => W === A), O = x[D + d];
795
+ (T = i.current) != null && T.loop && (O = D + d < 0 ? x[x.length - 1] : D + d === x.length ? x[0] : x[D + d]), O && g.setState("value", O.getAttribute(ne));
796
+ }
797
+ function Ye(d) {
798
+ let T = X(), A = T == null ? void 0 : T.closest(fe), x;
799
+ for (; A && !x; ) A = d > 0 ? qr(A, fe) : Hr(A, fe), x = A == null ? void 0 : A.querySelector(ft);
800
+ x ? g.setState("value", x.getAttribute(ne)) : Te(d);
801
+ }
802
+ let Ze = () => ie(k().length - 1), Qe = (d) => {
803
+ d.preventDefault(), d.metaKey ? Ze() : d.altKey ? Ye(1) : Te(1);
804
+ }, et = (d) => {
805
+ d.preventDefault(), d.metaKey ? ie(0) : d.altKey ? Ye(-1) : Te(-1);
806
+ };
807
+ return p.createElement(Q.div, { ref: a, tabIndex: -1, ...C, "cmdk-root": "", onKeyDown: (d) => {
808
+ var T;
809
+ (T = C.onKeyDown) == null || T.call(C, d);
810
+ let A = d.nativeEvent.isComposing || d.keyCode === 229;
811
+ if (!(d.defaultPrevented || A)) switch (d.key) {
812
+ case "n":
813
+ case "j": {
814
+ S && d.ctrlKey && Qe(d);
815
+ break;
816
+ }
817
+ case "ArrowDown": {
818
+ Qe(d);
819
+ break;
820
+ }
821
+ case "p":
822
+ case "k": {
823
+ S && d.ctrlKey && et(d);
824
+ break;
825
+ }
826
+ case "ArrowUp": {
827
+ et(d);
828
+ break;
829
+ }
830
+ case "Home": {
831
+ d.preventDefault(), ie(0);
832
+ break;
833
+ }
834
+ case "End": {
835
+ d.preventDefault(), Ze();
836
+ break;
837
+ }
838
+ case "Enter": {
839
+ d.preventDefault();
840
+ let x = X();
841
+ if (x) {
842
+ let D = new Event(je);
843
+ x.dispatchEvent(D);
844
+ }
845
+ }
846
+ }
847
+ } }, p.createElement("label", { "cmdk-label": "", htmlFor: E.inputId, id: E.labelId, style: Xr }, m), Ne(e, (d) => p.createElement(kt.Provider, { value: g }, p.createElement(Tt.Provider, { value: E }, d))));
848
+ }), Mr = p.forwardRef((e, a) => {
849
+ var t, n;
850
+ let r = oe(), l = p.useRef(null), s = p.useContext(At), i = ve(), m = Dt(e), u = (n = (t = m.current) == null ? void 0 : t.forceMount) != null ? n : s == null ? void 0 : s.forceMount;
851
+ ae(() => {
852
+ if (!u) return i.item(r, s == null ? void 0 : s.id);
853
+ }, [u]);
854
+ let y = _t(r, l, [e.value, e.children, l], e.keywords), c = Xe(), v = Z((N) => N.value && N.value === y.current), f = Z((N) => u || i.filter() === !1 ? !0 : N.search ? N.filtered.items.get(r) > 0 : !0);
855
+ p.useEffect(() => {
856
+ let N = l.current;
857
+ if (!(!N || e.disabled)) return N.addEventListener(je, w), () => N.removeEventListener(je, w);
858
+ }, [f, e.onSelect, e.disabled]);
859
+ function w() {
860
+ var N, g;
861
+ b(), (g = (N = m.current).onSelect) == null || g.call(N, y.current);
862
+ }
863
+ function b() {
864
+ c.setState("value", y.current, !0);
865
+ }
866
+ if (!f) return null;
867
+ let { disabled: S, value: C, onSelect: _, forceMount: z, keywords: F, ...P } = e;
868
+ return p.createElement(Q.div, { ref: he(l, a), ...P, id: r, "cmdk-item": "", role: "option", "aria-disabled": !!S, "aria-selected": !!v, "data-disabled": !!S, "data-selected": !!v, onPointerMove: S || i.getDisablePointerSelection() ? void 0 : b, onClick: S ? void 0 : w }, e.children);
869
+ }), Ur = p.forwardRef((e, a) => {
870
+ let { heading: t, children: n, forceMount: r, ...l } = e, s = oe(), i = p.useRef(null), m = p.useRef(null), u = oe(), y = ve(), c = Z((f) => r || y.filter() === !1 ? !0 : f.search ? f.filtered.groups.has(s) : !0);
871
+ ae(() => y.group(s), []), _t(s, i, [e.value, e.heading, m]);
872
+ let v = p.useMemo(() => ({ id: s, forceMount: r }), [r]);
873
+ return p.createElement(Q.div, { ref: he(i, a), ...l, "cmdk-group": "", role: "presentation", hidden: c ? void 0 : !0 }, t && p.createElement("div", { ref: m, "cmdk-group-heading": "", "aria-hidden": !0, id: u }, t), Ne(e, (f) => p.createElement("div", { "cmdk-group-items": "", role: "group", "aria-labelledby": t ? u : void 0 }, p.createElement(At.Provider, { value: v }, f))));
874
+ }), Br = p.forwardRef((e, a) => {
875
+ let { alwaysRender: t, ...n } = e, r = p.useRef(null), l = Z((s) => !s.search);
876
+ return !t && !l ? null : p.createElement(Q.div, { ref: he(r, a), ...n, "cmdk-separator": "", role: "separator" });
877
+ }), jr = p.forwardRef((e, a) => {
878
+ let { onValueChange: t, ...n } = e, r = e.value != null, l = Xe(), s = Z((u) => u.search), i = Z((u) => u.selectedItemId), m = ve();
879
+ return p.useEffect(() => {
880
+ e.value != null && l.setState("search", e.value);
881
+ }, [e.value]), p.createElement(Q.input, { ref: a, ...n, "cmdk-input": "", autoComplete: "off", autoCorrect: "off", spellCheck: !1, "aria-autocomplete": "list", role: "combobox", "aria-expanded": !0, "aria-controls": m.listId, "aria-labelledby": m.labelId, "aria-activedescendant": i, id: m.inputId, type: "text", value: r ? e.value : s, onChange: (u) => {
882
+ r || l.setState("search", u.target.value), t == null || t(u.target.value);
883
+ } });
884
+ }), $r = p.forwardRef((e, a) => {
885
+ let { children: t, label: n = "Suggestions", ...r } = e, l = p.useRef(null), s = p.useRef(null), i = Z((u) => u.selectedItemId), m = ve();
886
+ return p.useEffect(() => {
887
+ if (s.current && l.current) {
888
+ let u = s.current, y = l.current, c, v = new ResizeObserver(() => {
889
+ c = requestAnimationFrame(() => {
890
+ let f = u.offsetHeight;
891
+ y.style.setProperty("--cmdk-list-height", f.toFixed(1) + "px");
892
+ });
893
+ });
894
+ return v.observe(u), () => {
895
+ cancelAnimationFrame(c), v.unobserve(u);
896
+ };
897
+ }
898
+ }, []), p.createElement(Q.div, { ref: he(l, a), ...r, "cmdk-list": "", role: "listbox", tabIndex: -1, "aria-activedescendant": i, "aria-label": n, id: m.listId }, Ne(e, (u) => p.createElement("div", { ref: he(s, m.listInnerRef), "cmdk-list-sizer": "" }, u)));
899
+ }), Vr = p.forwardRef((e, a) => {
900
+ let { open: t, onOpenChange: n, overlayClassName: r, contentClassName: l, container: s, ...i } = e;
901
+ return p.createElement(ha, { open: t, onOpenChange: n }, p.createElement(pa, { container: s }, p.createElement(va, { "cmdk-overlay": "", className: r }), p.createElement(ba, { "aria-label": e.label, "cmdk-dialog": "", className: l }, p.createElement(Rt, { ref: a, ...i }))));
902
+ }), Wr = p.forwardRef((e, a) => Z((t) => t.filtered.count === 0) ? p.createElement(Q.div, { ref: a, ...e, "cmdk-empty": "", role: "presentation" }) : null), Kr = p.forwardRef((e, a) => {
903
+ let { progress: t, children: n, label: r = "Loading...", ...l } = e;
904
+ return p.createElement(Q.div, { ref: a, ...l, "cmdk-loading": "", role: "progressbar", "aria-valuenow": t, "aria-valuemin": 0, "aria-valuemax": 100, "aria-label": r }, Ne(e, (s) => p.createElement("div", { "aria-hidden": !0 }, s)));
905
+ }), $ = Object.assign(Rt, { List: $r, Item: Mr, Input: jr, Group: Ur, Separator: Br, Dialog: Vr, Empty: Wr, Loading: Kr });
906
+ function qr(e, a) {
907
+ let t = e.nextElementSibling;
908
+ for (; t; ) {
909
+ if (t.matches(a)) return t;
910
+ t = t.nextElementSibling;
911
+ }
912
+ }
913
+ function Hr(e, a) {
914
+ let t = e.previousElementSibling;
915
+ for (; t; ) {
916
+ if (t.matches(a)) return t;
917
+ t = t.previousElementSibling;
918
+ }
919
+ }
920
+ function Dt(e) {
921
+ let a = p.useRef(e);
922
+ return ae(() => {
923
+ a.current = e;
924
+ }), a;
925
+ }
926
+ var ae = typeof window > "u" ? p.useEffect : p.useLayoutEffect;
927
+ function se(e) {
928
+ let a = p.useRef();
929
+ return a.current === void 0 && (a.current = e()), a;
930
+ }
931
+ function Z(e) {
932
+ let a = Xe(), t = () => e(a.snapshot());
933
+ return p.useSyncExternalStore(a.subscribe, t, t);
934
+ }
935
+ function _t(e, a, t, n = []) {
936
+ let r = p.useRef(), l = ve();
937
+ return ae(() => {
938
+ var s;
939
+ let i = (() => {
940
+ var u;
941
+ for (let y of t) {
942
+ if (typeof y == "string") return y.trim();
943
+ if (typeof y == "object" && "current" in y) return y.current ? (u = y.current.textContent) == null ? void 0 : u.trim() : r.current;
944
+ }
945
+ })(), m = n.map((u) => u.trim());
946
+ l.value(e, i, m), (s = a.current) == null || s.setAttribute(ne, i), r.current = i;
947
+ }), r;
948
+ }
949
+ var Gr = () => {
950
+ let [e, a] = p.useState(), t = se(() => /* @__PURE__ */ new Map());
951
+ return ae(() => {
952
+ t.current.forEach((n) => n()), t.current = /* @__PURE__ */ new Map();
953
+ }, [e]), (n, r) => {
954
+ t.current.set(n, r), a({});
955
+ };
956
+ };
957
+ function Jr(e) {
958
+ let a = e.type;
959
+ return typeof a == "function" ? a(e.props) : "render" in a ? a.render(e.props) : e;
960
+ }
961
+ function Ne({ asChild: e, children: a }, t) {
962
+ return e && p.isValidElement(a) ? p.cloneElement(Jr(a), { ref: a.ref }, t(a.props.children)) : t(a);
963
+ }
964
+ var Xr = { position: "absolute", width: "1px", height: "1px", padding: "0", margin: "-1px", overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0" };
965
+ const Pt = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ o(
966
+ $,
967
+ {
968
+ ref: t,
969
+ className: B(
970
+ "flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground",
971
+ e
972
+ ),
973
+ ...a
974
+ }
975
+ ));
976
+ Pt.displayName = $.displayName;
977
+ const Ot = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ h("div", { className: "flex items-center border-b px-3", "cmdk-input-wrapper": "", children: [
978
+ /* @__PURE__ */ o(ga, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
979
+ /* @__PURE__ */ o(
980
+ $.Input,
981
+ {
982
+ ref: t,
983
+ className: B(
984
+ "flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))] disabled:cursor-not-allowed disabled:opacity-50",
985
+ e
986
+ ),
987
+ ...a
988
+ }
989
+ )
990
+ ] }));
991
+ Ot.displayName = $.Input.displayName;
992
+ const Lt = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ o(
993
+ $.List,
994
+ {
995
+ ref: t,
996
+ className: B("max-h-[300px] overflow-y-auto overflow-x-hidden", e),
997
+ ...a
998
+ }
999
+ ));
1000
+ Lt.displayName = $.List.displayName;
1001
+ const zt = p.forwardRef((e, a) => /* @__PURE__ */ o(
1002
+ $.Empty,
1003
+ {
1004
+ ref: a,
1005
+ className: "py-6 text-center text-sm",
1006
+ ...e
1007
+ }
1008
+ ));
1009
+ zt.displayName = $.Empty.displayName;
1010
+ const $e = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ o(
1011
+ $.Group,
1012
+ {
1013
+ ref: t,
1014
+ className: B(
1015
+ "overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground",
1016
+ e
1017
+ ),
1018
+ ...a
1019
+ }
1020
+ ));
1021
+ $e.displayName = $.Group.displayName;
1022
+ const Ft = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ o(
1023
+ $.Separator,
1024
+ {
1025
+ ref: t,
1026
+ className: B("-mx-1 h-px bg-border", e),
1027
+ ...a
1028
+ }
1029
+ ));
1030
+ Ft.displayName = $.Separator.displayName;
1031
+ const Ve = p.forwardRef(({ className: e, ...a }, t) => /* @__PURE__ */ o(
1032
+ $.Item,
1033
+ {
1034
+ ref: t,
1035
+ className: B(
1036
+ "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50",
1037
+ e
1038
+ ),
1039
+ ...a
1040
+ }
1041
+ ));
1042
+ Ve.displayName = $.Item.displayName;
1043
+ function Yr(e = {}) {
1044
+ const { authToken: a, tokenProps: t } = He(), n = M(
1045
+ (N) => N.actions.applyResolvedCalendarPreferences
1046
+ ), r = e.enabled ?? !0, l = (a == null ? void 0 : a.accessToken) ?? null, s = (t == null ? void 0 : t.apiServiceUrl) ?? null, [i, m] = L(!1), [u, y] = L(!1), [c, v] = L(!1), [f, w] = L(null), [b, S] = L(null), C = j(l);
1047
+ C.current = l, J(() => {
1048
+ S(null), w(null), m(!1), y(!1), v(!1);
1049
+ }, [l]);
1050
+ const _ = K(async (N) => {
1051
+ const g = Ka(await N.json());
1052
+ if (!g.ok)
1053
+ throw new Error("Calendar preferences response is invalid");
1054
+ return g.value;
1055
+ }, []), z = K(async () => {
1056
+ if (!r || !l || !s) return;
1057
+ const N = l;
1058
+ m(!0), w(null);
1059
+ try {
1060
+ const g = await fetch(
1061
+ `${s}/v1/user-preferences/calendar`,
1062
+ {
1063
+ method: "GET",
1064
+ headers: { Authorization: `Bearer ${l}` }
1065
+ }
1066
+ );
1067
+ if (!g.ok) {
1068
+ const R = await g.json().catch(() => ({}));
1069
+ throw new Error(R.error || "Failed to fetch preferences");
1070
+ }
1071
+ const E = await _(g);
1072
+ C.current === N && S(E);
1073
+ } catch (g) {
1074
+ C.current === N && w(g instanceof Error ? g.message : "Unknown error");
1075
+ } finally {
1076
+ C.current === N && m(!1);
1077
+ }
1078
+ }, [l, s, r, _]);
1079
+ J(() => {
1080
+ r && z();
1081
+ }, [r, z]);
1082
+ const F = K(
1083
+ async (N) => {
1084
+ if (!l || !s)
1085
+ return w("Not authenticated"), !1;
1086
+ const g = l;
1087
+ y(!0), w(null);
1088
+ try {
1089
+ const E = await fetch(
1090
+ `${s}/v1/user-preferences/calendar`,
1091
+ {
1092
+ method: "PATCH",
1093
+ headers: {
1094
+ "Content-Type": "application/json",
1095
+ Authorization: `Bearer ${l}`
1096
+ },
1097
+ body: JSON.stringify(N)
1098
+ }
1099
+ );
1100
+ if (!E.ok) {
1101
+ const I = await E.json().catch(() => ({}));
1102
+ throw new Error(I.error || "Failed to update preferences");
1103
+ }
1104
+ const R = await _(E);
1105
+ return C.current !== g ? !1 : (S(R), n(R.resolved, R.sources), !0);
1106
+ } catch (E) {
1107
+ return C.current === g && w(E instanceof Error ? E.message : "Unknown error"), !1;
1108
+ } finally {
1109
+ C.current === g && y(!1);
1110
+ }
1111
+ },
1112
+ [
1113
+ l,
1114
+ s,
1115
+ n,
1116
+ _
1117
+ ]
1118
+ ), P = K(async () => {
1119
+ if (!l || !s)
1120
+ return w("Not authenticated"), !1;
1121
+ const N = l;
1122
+ v(!0), w(null);
1123
+ try {
1124
+ const g = await fetch(
1125
+ `${s}/v1/user-preferences/calendar`,
1126
+ {
1127
+ method: "DELETE",
1128
+ headers: { Authorization: `Bearer ${l}` }
1129
+ }
1130
+ );
1131
+ if (!g.ok) {
1132
+ const R = await g.json().catch(() => ({}));
1133
+ throw new Error(R.error || "Failed to clear preferences");
1134
+ }
1135
+ const E = await _(g);
1136
+ return C.current !== N ? !1 : (S(E), n(E.resolved, E.sources), !0);
1137
+ } catch (g) {
1138
+ return C.current === N && w(g instanceof Error ? g.message : "Unknown error"), !1;
1139
+ } finally {
1140
+ C.current === N && v(!1);
1141
+ }
1142
+ }, [
1143
+ l,
1144
+ s,
1145
+ n,
1146
+ _
1147
+ ]);
1148
+ return {
1149
+ preferences: b,
1150
+ isLoading: i,
1151
+ isSaving: u,
1152
+ isClearing: c,
1153
+ error: f,
1154
+ updatePreferences: F,
1155
+ clearPreferences: P,
1156
+ refetch: z
1157
+ };
1158
+ }
1159
+ const Ie = [
1160
+ { value: "America/New_York", label: "Eastern Time (US & Canada)" },
1161
+ { value: "America/Chicago", label: "Central Time (US & Canada)" },
1162
+ { value: "America/Denver", label: "Mountain Time (US & Canada)" },
1163
+ { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
1164
+ { value: "America/Phoenix", label: "Arizona" },
1165
+ { value: "America/Anchorage", label: "Alaska" },
1166
+ { value: "Pacific/Honolulu", label: "Hawaii" },
1167
+ { value: "Europe/London", label: "London" },
1168
+ { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
1169
+ { value: "Asia/Tokyo", label: "Tokyo" },
1170
+ { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
1171
+ { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
1172
+ { value: "Australia/Sydney", label: "Sydney" },
1173
+ { value: "UTC", label: "UTC" }
1174
+ ], Mt = [
1175
+ { value: 0, label: "Sunday" },
1176
+ { value: 1, label: "Monday" },
1177
+ { value: 6, label: "Saturday" }
1178
+ ], mt = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
1179
+ function Zr() {
1180
+ try {
1181
+ const e = Intl;
1182
+ if (e.supportedValuesOf)
1183
+ return e.supportedValuesOf("timeZone");
1184
+ } catch {
1185
+ }
1186
+ return Ie.map((e) => e.value);
1187
+ }
1188
+ function Qr(e) {
1189
+ if (!e) return "default";
1190
+ if (e.tz !== e.weekStart) return "inherited";
1191
+ switch (e.tz) {
1192
+ case "viewer_tenant":
1193
+ return "tenant";
1194
+ case "viewer_organization":
1195
+ return "organization";
1196
+ case "system_default":
1197
+ return "system";
1198
+ case "session_initial":
1199
+ return "embedded";
1200
+ default:
1201
+ return "default";
1202
+ }
1203
+ }
1204
+ function ht(e) {
1205
+ const a = Ie.find((t) => t.value === e);
1206
+ return a ? a.label : e;
1207
+ }
1208
+ function en(e) {
1209
+ const a = Mt.find((t) => t.value === e);
1210
+ return a ? a.label : String(e);
1211
+ }
1212
+ function tn({
1213
+ active: e,
1214
+ onClose: a
1215
+ }) {
1216
+ const {
1217
+ preferences: t,
1218
+ isLoading: n,
1219
+ isSaving: r,
1220
+ isClearing: l,
1221
+ updatePreferences: s,
1222
+ clearPreferences: i
1223
+ } = Yr({ enabled: e }), m = ya(), u = (t == null ? void 0 : t.resolved.tz) || (m == null ? void 0 : m.tz) || "UTC", y = (t == null ? void 0 : t.resolved.weekStart) ?? (m == null ? void 0 : m.weekStart) ?? 1, [c, v] = L((t == null ? void 0 : t.stored) === null), [f, w] = L(!1), [b, S] = L(
1224
+ u
1225
+ ), [C, _] = L(
1226
+ y
1227
+ ), [z, F] = L(!1), P = ee(() => Zr(), []), N = ee(
1228
+ () => P.filter(
1229
+ (k) => !Ie.some((ie) => ie.value === k)
1230
+ ),
1231
+ [P]
1232
+ ), g = ee(() => ht(b), [b]), E = t != null && t.inherited ? ht(t.inherited.tz) : "UTC", R = t != null && t.inherited ? en(t.inherited.weekStart) : "Monday", I = Qr(
1233
+ t == null ? void 0 : t.inheritedSources
1234
+ );
1235
+ jt.useEffect(() => {
1236
+ if (!e) {
1237
+ w(!1);
1238
+ return;
1239
+ }
1240
+ f || (t && v(t.stored === null), S(u), _(y));
1241
+ }, [
1242
+ e,
1243
+ f,
1244
+ t,
1245
+ u,
1246
+ y
1247
+ ]);
1248
+ const H = async () => {
1249
+ if (n) {
1250
+ G.error("Preferences are still loading. Please try again.");
1251
+ return;
1252
+ }
1253
+ c ? await i() ? (G.success("Now using default settings."), a()) : G.error("Failed to save preferences. Please try again.") : await s({
1254
+ tz: b,
1255
+ weekStart: C
1256
+ }) ? (G.success("Preferences saved."), a()) : G.error("Failed to save preferences. Please try again.");
1257
+ }, V = () => {
1258
+ a();
1259
+ }, re = r || l, X = re || n;
1260
+ return /* @__PURE__ */ h(te, { children: [
1261
+ /* @__PURE__ */ h("div", { className: "space-y-4 py-1", children: [
1262
+ /* @__PURE__ */ h(
1263
+ rt,
1264
+ {
1265
+ value: c ? "defaults" : "custom",
1266
+ onValueChange: (k) => {
1267
+ w(!0), v(k === "defaults");
1268
+ },
1269
+ className: "space-y-0.5",
1270
+ children: [
1271
+ /* @__PURE__ */ h(
1272
+ "label",
1273
+ {
1274
+ htmlFor: "mode-defaults",
1275
+ className: B(
1276
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
1277
+ c && "bg-muted/50"
1278
+ ),
1279
+ onClick: () => {
1280
+ w(!0), v(!0);
1281
+ },
1282
+ children: [
1283
+ /* @__PURE__ */ o(
1284
+ ke,
1285
+ {
1286
+ value: "defaults",
1287
+ id: "mode-defaults",
1288
+ className: "mt-0.5"
1289
+ }
1290
+ ),
1291
+ /* @__PURE__ */ h("div", { className: "flex-1 min-w-0", children: [
1292
+ /* @__PURE__ */ h("p", { className: "text-[13px] font-medium text-foreground", children: [
1293
+ "Use ",
1294
+ I,
1295
+ " defaults"
1296
+ ] }),
1297
+ /* @__PURE__ */ h("p", { className: "text-[12px] text-muted-foreground", children: [
1298
+ E,
1299
+ ", week starts ",
1300
+ R
1301
+ ] })
1302
+ ] })
1303
+ ]
1304
+ }
1305
+ ),
1306
+ /* @__PURE__ */ h(
1307
+ "label",
1308
+ {
1309
+ htmlFor: "mode-custom",
1310
+ className: B(
1311
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
1312
+ !c && "bg-muted/50"
1313
+ ),
1314
+ onClick: () => {
1315
+ w(!0), v(!1);
1316
+ },
1317
+ children: [
1318
+ /* @__PURE__ */ o(
1319
+ ke,
1320
+ {
1321
+ value: "custom",
1322
+ id: "mode-custom",
1323
+ className: "mt-0.5"
1324
+ }
1325
+ ),
1326
+ /* @__PURE__ */ o("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
1327
+ ]
1328
+ }
1329
+ )
1330
+ ]
1331
+ }
1332
+ ),
1333
+ /* @__PURE__ */ h(
1334
+ "div",
1335
+ {
1336
+ className: B(
1337
+ "space-y-4 border-t border-border/60 pt-4 transition-opacity",
1338
+ c && "pointer-events-none opacity-50"
1339
+ ),
1340
+ children: [
1341
+ /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1342
+ /* @__PURE__ */ o(pe, { className: mt, children: "Timezone" }),
1343
+ /* @__PURE__ */ h(
1344
+ za,
1345
+ {
1346
+ open: z,
1347
+ onOpenChange: F,
1348
+ modal: !0,
1349
+ children: [
1350
+ /* @__PURE__ */ o(Fa, { asChild: !0, children: /* @__PURE__ */ h(
1351
+ q,
1352
+ {
1353
+ variant: "outline",
1354
+ size: "xs",
1355
+ role: "combobox",
1356
+ "aria-expanded": z,
1357
+ className: "w-full justify-between text-[12px] font-normal",
1358
+ disabled: c,
1359
+ children: [
1360
+ /* @__PURE__ */ o("span", { className: "truncate", children: g }),
1361
+ /* @__PURE__ */ o(wa, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
1362
+ ]
1363
+ }
1364
+ ) }),
1365
+ /* @__PURE__ */ o(
1366
+ Ma,
1367
+ {
1368
+ className: "z-50 w-[--radix-popover-trigger-width] p-0",
1369
+ align: "start",
1370
+ children: /* @__PURE__ */ h(Pt, { className: "overflow-visible", children: [
1371
+ /* @__PURE__ */ o(Ot, { placeholder: "Search timezones…" }),
1372
+ /* @__PURE__ */ h(Lt, { children: [
1373
+ /* @__PURE__ */ o(zt, { children: "No timezone found." }),
1374
+ /* @__PURE__ */ o($e, { heading: "Common", children: Ie.map((k) => /* @__PURE__ */ h(
1375
+ Ve,
1376
+ {
1377
+ value: `${k.value} ${k.label}`,
1378
+ onSelect: () => {
1379
+ w(!0), S(k.value), F(!1);
1380
+ },
1381
+ children: [
1382
+ /* @__PURE__ */ o(
1383
+ nt,
1384
+ {
1385
+ className: B(
1386
+ "h-3.5 w-3.5",
1387
+ b === k.value ? "opacity-100" : "opacity-0"
1388
+ )
1389
+ }
1390
+ ),
1391
+ /* @__PURE__ */ o("span", { className: "flex-1", children: k.label }),
1392
+ /* @__PURE__ */ o("span", { className: "text-[11px] text-muted-foreground", children: k.value })
1393
+ ]
1394
+ },
1395
+ k.value
1396
+ )) }),
1397
+ /* @__PURE__ */ o(Ft, {}),
1398
+ /* @__PURE__ */ o($e, { heading: "All timezones", children: N.map((k) => /* @__PURE__ */ h(
1399
+ Ve,
1400
+ {
1401
+ value: k,
1402
+ onSelect: () => {
1403
+ w(!0), S(k), F(!1);
1404
+ },
1405
+ children: [
1406
+ /* @__PURE__ */ o(
1407
+ nt,
1408
+ {
1409
+ className: B(
1410
+ "h-3.5 w-3.5",
1411
+ b === k ? "opacity-100" : "opacity-0"
1412
+ )
1413
+ }
1414
+ ),
1415
+ k
1416
+ ]
1417
+ },
1418
+ k
1419
+ )) })
1420
+ ] })
1421
+ ] })
1422
+ }
1423
+ )
1424
+ ]
1425
+ }
1426
+ )
1427
+ ] }),
1428
+ /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1429
+ /* @__PURE__ */ o(pe, { className: mt, children: "Week starts on" }),
1430
+ /* @__PURE__ */ o(
1431
+ rt,
1432
+ {
1433
+ value: String(C),
1434
+ onValueChange: (k) => {
1435
+ w(!0), _(Number(k));
1436
+ },
1437
+ className: "flex gap-4",
1438
+ disabled: c,
1439
+ children: Mt.map((k) => /* @__PURE__ */ h(
1440
+ "label",
1441
+ {
1442
+ htmlFor: `week-start-${k.value}`,
1443
+ className: B(
1444
+ "flex cursor-pointer items-center gap-2 text-[13px]",
1445
+ c && "cursor-not-allowed"
1446
+ ),
1447
+ children: [
1448
+ /* @__PURE__ */ o(
1449
+ ke,
1450
+ {
1451
+ value: String(k.value),
1452
+ id: `week-start-${k.value}`,
1453
+ disabled: c
1454
+ }
1455
+ ),
1456
+ k.label
1457
+ ]
1458
+ },
1459
+ k.value
1460
+ ))
1461
+ }
1462
+ )
1463
+ ] })
1464
+ ]
1465
+ }
1466
+ )
1467
+ ] }),
1468
+ /* @__PURE__ */ h(Ge, { children: [
1469
+ /* @__PURE__ */ o(
1470
+ q,
1471
+ {
1472
+ variant: "outline",
1473
+ size: "xs",
1474
+ onClick: V,
1475
+ disabled: re,
1476
+ children: "Cancel"
1477
+ }
1478
+ ),
1479
+ /* @__PURE__ */ o(q, { size: "xs", onClick: H, disabled: X, children: re ? /* @__PURE__ */ h(te, { children: [
1480
+ /* @__PURE__ */ o(St, { className: "h-3.5 w-3.5 animate-spin" }),
1481
+ "Saving…"
1482
+ ] }) : "Save" })
1483
+ ] })
1484
+ ] });
1485
+ }
1486
+ function an(e = {}) {
1487
+ const { authToken: a, tokenProps: t } = He(), n = M(
1488
+ (g) => g.actions.applyResolvedValueFormatPreferences
1489
+ ), r = e.enabled ?? !0, l = (a == null ? void 0 : a.accessToken) ?? null, s = (t == null ? void 0 : t.apiServiceUrl) ?? null, i = j(l);
1490
+ i.current = l;
1491
+ const [m, u] = L(null), [y, c] = L(!1), [v, f] = L(!1), [w, b] = L(!1), [S, C] = L(null);
1492
+ J(() => {
1493
+ u(null), C(null), c(!1), f(!1), b(!1);
1494
+ }, [l]);
1495
+ const _ = K(async (g) => {
1496
+ const E = ja(await g.json());
1497
+ if (!E.ok)
1498
+ throw new Error("Value format preferences response is invalid");
1499
+ return E.value;
1500
+ }, []), z = K(
1501
+ async (g, E) => {
1502
+ if (!l || !s)
1503
+ throw new Error("Not authenticated");
1504
+ const R = await fetch(
1505
+ `${s}/v1/user-preferences/value-format`,
1506
+ {
1507
+ method: g,
1508
+ headers: {
1509
+ Authorization: `Bearer ${l}`,
1510
+ ...E ? { "Content-Type": "application/json" } : {}
1511
+ },
1512
+ body: E ? JSON.stringify(E) : void 0
1513
+ }
1514
+ );
1515
+ if (!R.ok) {
1516
+ const I = await R.json().catch(() => ({}));
1517
+ throw new Error(I.error || "Failed to update preferences");
1518
+ }
1519
+ return _(R);
1520
+ },
1521
+ [l, s, _]
1522
+ ), F = K(async () => {
1523
+ if (!r || !l || !s) return;
1524
+ const g = l;
1525
+ c(!0), C(null);
1526
+ try {
1527
+ const E = await z("GET");
1528
+ i.current === g && u(E);
1529
+ } catch (E) {
1530
+ i.current === g && C(E instanceof Error ? E.message : "Unknown error");
1531
+ } finally {
1532
+ i.current === g && c(!1);
1533
+ }
1534
+ }, [l, s, r, z]);
1535
+ J(() => {
1536
+ r && F();
1537
+ }, [r, F]);
1538
+ const P = K(
1539
+ async (g) => {
1540
+ const E = l;
1541
+ f(!0), C(null);
1542
+ try {
1543
+ const R = await z("PATCH", g);
1544
+ return i.current !== E ? !1 : (u(R), n(R.resolved, R.sources), !0);
1545
+ } catch (R) {
1546
+ return i.current === E && C(R instanceof Error ? R.message : "Unknown error"), !1;
1547
+ } finally {
1548
+ i.current === E && f(!1);
1549
+ }
1550
+ },
1551
+ [l, n, z]
1552
+ ), N = K(async () => {
1553
+ const g = l;
1554
+ b(!0), C(null);
1555
+ try {
1556
+ const E = await z("DELETE");
1557
+ return i.current !== g ? !1 : (u(E), n(E.resolved, E.sources), !0);
1558
+ } catch (E) {
1559
+ return i.current === g && C(E instanceof Error ? E.message : "Unknown error"), !1;
1560
+ } finally {
1561
+ i.current === g && b(!1);
1562
+ }
1563
+ }, [l, n, z]);
1564
+ return {
1565
+ preferences: m,
1566
+ isLoading: y,
1567
+ isSaving: v,
1568
+ isClearing: w,
1569
+ error: S,
1570
+ updatePreferences: P,
1571
+ clearPreferences: N,
1572
+ refetch: F
1573
+ };
1574
+ }
1575
+ const We = [
1576
+ { value: "en-US", label: "English (United States)" },
1577
+ { value: "en-GB", label: "English (United Kingdom)" },
1578
+ { value: "de-DE", label: "German (Germany)" },
1579
+ { value: "fr-FR", label: "French (France)" },
1580
+ { value: "es-ES", label: "Spanish (Spain)" },
1581
+ { value: "it-IT", label: "Italian (Italy)" },
1582
+ { value: "nl-NL", label: "Dutch (Netherlands)" },
1583
+ { value: "pt-BR", label: "Portuguese (Brazil)" },
1584
+ { value: "ja-JP", label: "Japanese (Japan)" },
1585
+ { value: "en-IN", label: "English (India)" },
1586
+ { value: "en-NZ", label: "English (New Zealand)" },
1587
+ { value: "mi-NZ", label: "Māori (New Zealand)" }
1588
+ ], Ut = /* @__PURE__ */ new Set([
1589
+ "USD",
1590
+ "EUR",
1591
+ "GBP",
1592
+ "CAD",
1593
+ "AUD",
1594
+ "JPY",
1595
+ "CHF",
1596
+ "INR",
1597
+ "BRL",
1598
+ "KWD"
1599
+ ]), rn = $a(), nn = rn.filter(
1600
+ (e) => !Ut.has(e)
1601
+ ), Bt = [
1602
+ { value: "short", label: "Short" },
1603
+ { value: "medium", label: "Medium" },
1604
+ { value: "long", label: "Long" }
1605
+ ], pt = "2026-07-31", _e = "2026-07-31T14:30:45";
1606
+ function Ke(e) {
1607
+ switch (e) {
1608
+ case "viewer_user":
1609
+ return "user";
1610
+ case "viewer_tenant_user":
1611
+ return "tenant user";
1612
+ case "viewer_tenant":
1613
+ return "tenant";
1614
+ case "viewer_organization":
1615
+ return "organization";
1616
+ case "session_initial":
1617
+ return "embedded session";
1618
+ case "system_default":
1619
+ return "system";
1620
+ default:
1621
+ return "another preference level";
1622
+ }
1623
+ }
1624
+ function Pe(e) {
1625
+ var a;
1626
+ return ((a = Bt.find((t) => t.value === e)) == null ? void 0 : a.label) ?? e;
1627
+ }
1628
+ function sn(e) {
1629
+ const a = We.find((t) => t.value === e);
1630
+ return a ? `${a.label} — ${a.value}` : e;
1631
+ }
1632
+ function Oe(e) {
1633
+ return {
1634
+ short: e("short"),
1635
+ medium: e("medium"),
1636
+ long: e("long")
1637
+ };
1638
+ }
1639
+ function Le({
1640
+ id: e,
1641
+ label: a,
1642
+ value: t,
1643
+ inherited: n,
1644
+ inheritedSource: r,
1645
+ examples: l,
1646
+ disabled: s,
1647
+ onValueChange: i
1648
+ }) {
1649
+ const m = t === void 0 ? `Inherited · ${Pe(n)}` : Pe(t);
1650
+ return /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1651
+ /* @__PURE__ */ o(pe, { htmlFor: e, className: "text-[11px] text-muted-foreground", children: a }),
1652
+ /* @__PURE__ */ h(
1653
+ ze,
1654
+ {
1655
+ value: t ?? "inherit",
1656
+ disabled: s,
1657
+ onValueChange: i,
1658
+ children: [
1659
+ /* @__PURE__ */ o(Fe, { id: e, size: "xs", children: /* @__PURE__ */ o(Me, { children: m }) }),
1660
+ /* @__PURE__ */ h(Ue, { children: [
1661
+ /* @__PURE__ */ o(Y, { value: "inherit", className: "[&>span:last-child]:w-full", children: /* @__PURE__ */ h("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1662
+ /* @__PURE__ */ h("span", { children: [
1663
+ "Inherited from ",
1664
+ Ke(r),
1665
+ " ·",
1666
+ " ",
1667
+ Pe(n)
1668
+ ] }),
1669
+ /* @__PURE__ */ o("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: l[n] })
1670
+ ] }) }),
1671
+ Bt.map((u) => /* @__PURE__ */ o(
1672
+ Y,
1673
+ {
1674
+ value: u.value,
1675
+ className: "[&>span:last-child]:w-full",
1676
+ children: /* @__PURE__ */ h("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
1677
+ /* @__PURE__ */ o("span", { children: u.label }),
1678
+ /* @__PURE__ */ o("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: l[u.value] })
1679
+ ] })
1680
+ },
1681
+ u.value
1682
+ ))
1683
+ ] })
1684
+ ]
1685
+ }
1686
+ )
1687
+ ] });
1688
+ }
1689
+ function ln({
1690
+ value: e,
1691
+ inherited: a,
1692
+ inheritedSources: t,
1693
+ onChange: n,
1694
+ disabled: r
1695
+ }) {
1696
+ var N, g, E, R;
1697
+ const l = de(), s = de(), i = de(), m = de(), u = de(), c = (e.locale === void 0 ? void 0 : xt(e.locale)) ?? a.locale, v = e.defaultCurrency ?? a.defaultCurrency, f = {
1698
+ locale: c,
1699
+ dateStyle: e.dateStyle ?? a.dateStyle,
1700
+ dateTime: {
1701
+ dateStyle: ((N = e.dateTime) == null ? void 0 : N.dateStyle) ?? a.dateTime.dateStyle,
1702
+ timeStyle: ((g = e.dateTime) == null ? void 0 : g.timeStyle) ?? a.dateTime.timeStyle
1703
+ },
1704
+ defaultCurrency: v
1705
+ }, w = new Intl.NumberFormat(c, {
1706
+ style: "currency",
1707
+ currency: v
1708
+ }).format(1e3), b = we({
1709
+ preferences: f,
1710
+ calendar: { tz: "UTC" }
1711
+ }), S = ce({
1712
+ value: pt,
1713
+ metadata: { kind: "raw_temporal", valueKind: "date" },
1714
+ format: b
1715
+ }).text, C = ce({
1716
+ value: _e,
1717
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1718
+ format: b
1719
+ }).text, _ = Oe(
1720
+ (I) => ce({
1721
+ value: pt,
1722
+ metadata: { kind: "raw_temporal", valueKind: "date" },
1723
+ format: we({
1724
+ preferences: { ...f, dateStyle: I },
1725
+ calendar: { tz: "UTC" }
1726
+ })
1727
+ }).text
1728
+ ), z = Oe(
1729
+ (I) => ce({
1730
+ value: _e,
1731
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1732
+ format: we({
1733
+ preferences: {
1734
+ ...f,
1735
+ dateTime: { ...f.dateTime, dateStyle: I }
1736
+ },
1737
+ calendar: { tz: "UTC" }
1738
+ })
1739
+ }).text
1740
+ ), F = Oe(
1741
+ (I) => ce({
1742
+ value: _e,
1743
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
1744
+ format: we({
1745
+ preferences: {
1746
+ ...f,
1747
+ dateTime: { ...f.dateTime, timeStyle: I }
1748
+ },
1749
+ calendar: { tz: "UTC" }
1750
+ })
1751
+ }).text
1752
+ ), P = (I, H) => {
1753
+ const V = {
1754
+ ...e.dateTime,
1755
+ [I]: H === "inherit" ? void 0 : H
1756
+ };
1757
+ n({
1758
+ ...e,
1759
+ dateTime: V.dateStyle === void 0 && V.timeStyle === void 0 ? void 0 : V
1760
+ });
1761
+ };
1762
+ return /* @__PURE__ */ h("div", { className: "space-y-4", children: [
1763
+ /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1764
+ /* @__PURE__ */ o(
1765
+ pe,
1766
+ {
1767
+ htmlFor: l,
1768
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1769
+ children: "Locale"
1770
+ }
1771
+ ),
1772
+ /* @__PURE__ */ h(
1773
+ ze,
1774
+ {
1775
+ value: e.locale ?? "inherit",
1776
+ disabled: r,
1777
+ onValueChange: (I) => n({
1778
+ ...e,
1779
+ locale: I === "inherit" ? void 0 : I
1780
+ }),
1781
+ children: [
1782
+ /* @__PURE__ */ o(Fe, { id: l, size: "xs", children: /* @__PURE__ */ o(Me, { children: e.locale === void 0 ? `Inherited · ${a.locale}` : sn(e.locale) }) }),
1783
+ /* @__PURE__ */ h(Ue, { children: [
1784
+ /* @__PURE__ */ h(Y, { value: "inherit", children: [
1785
+ "Inherited from ",
1786
+ Ke(t.locale),
1787
+ " ·",
1788
+ " ",
1789
+ a.locale
1790
+ ] }),
1791
+ e.locale && !We.some(
1792
+ (I) => I.value === e.locale
1793
+ ) && /* @__PURE__ */ o(Y, { value: e.locale, children: e.locale }),
1794
+ We.map((I) => /* @__PURE__ */ h(Y, { value: I.value, children: [
1795
+ I.label,
1796
+ " — ",
1797
+ I.value
1798
+ ] }, I.value))
1799
+ ] })
1800
+ ]
1801
+ }
1802
+ )
1803
+ ] }),
1804
+ /* @__PURE__ */ h("fieldset", { className: "space-y-2", children: [
1805
+ /* @__PURE__ */ o("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date values" }),
1806
+ /* @__PURE__ */ o(
1807
+ Le,
1808
+ {
1809
+ id: i,
1810
+ label: "Format",
1811
+ value: e.dateStyle,
1812
+ inherited: a.dateStyle,
1813
+ inheritedSource: t.dateStyle,
1814
+ examples: _,
1815
+ disabled: r,
1816
+ onValueChange: (I) => n({
1817
+ ...e,
1818
+ dateStyle: I === "inherit" ? void 0 : I
1819
+ })
1820
+ }
1821
+ )
1822
+ ] }),
1823
+ /* @__PURE__ */ h("fieldset", { className: "space-y-2", children: [
1824
+ /* @__PURE__ */ o("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date & time values" }),
1825
+ /* @__PURE__ */ o(
1826
+ Le,
1827
+ {
1828
+ id: m,
1829
+ label: "Date",
1830
+ value: (E = e.dateTime) == null ? void 0 : E.dateStyle,
1831
+ inherited: a.dateTime.dateStyle,
1832
+ inheritedSource: t.dateTime.dateStyle,
1833
+ examples: z,
1834
+ disabled: r,
1835
+ onValueChange: (I) => P("dateStyle", I)
1836
+ }
1837
+ ),
1838
+ /* @__PURE__ */ o(
1839
+ Le,
1840
+ {
1841
+ id: u,
1842
+ label: "Time",
1843
+ value: (R = e.dateTime) == null ? void 0 : R.timeStyle,
1844
+ inherited: a.dateTime.timeStyle,
1845
+ inheritedSource: t.dateTime.timeStyle,
1846
+ examples: F,
1847
+ disabled: r,
1848
+ onValueChange: (I) => P("timeStyle", I)
1849
+ }
1850
+ )
1851
+ ] }),
1852
+ /* @__PURE__ */ h("div", { className: "space-y-1.5", children: [
1853
+ /* @__PURE__ */ o(
1854
+ pe,
1855
+ {
1856
+ htmlFor: s,
1857
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1858
+ children: "Default currency"
1859
+ }
1860
+ ),
1861
+ /* @__PURE__ */ h(
1862
+ ze,
1863
+ {
1864
+ value: e.defaultCurrency ?? "inherit",
1865
+ disabled: r,
1866
+ onValueChange: (I) => n({
1867
+ ...e,
1868
+ defaultCurrency: I === "inherit" ? void 0 : I
1869
+ }),
1870
+ children: [
1871
+ /* @__PURE__ */ o(Fe, { id: s, size: "xs", children: /* @__PURE__ */ o(Me, { children: e.defaultCurrency === void 0 ? `Inherited · ${a.defaultCurrency}` : e.defaultCurrency }) }),
1872
+ /* @__PURE__ */ h(Ue, { children: [
1873
+ /* @__PURE__ */ h(Y, { value: "inherit", children: [
1874
+ "Inherited from ",
1875
+ Ke(t.defaultCurrency),
1876
+ " ·",
1877
+ " ",
1878
+ a.defaultCurrency
1879
+ ] }),
1880
+ [...Ut].map((I) => /* @__PURE__ */ o(Y, { value: I, children: I }, I)),
1881
+ nn.map((I) => /* @__PURE__ */ o(Y, { value: I, children: I }, I))
1882
+ ] })
1883
+ ]
1884
+ }
1885
+ )
1886
+ ] }),
1887
+ /* @__PURE__ */ h("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2", children: [
1888
+ /* @__PURE__ */ o("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Preview" }),
1889
+ /* @__PURE__ */ h("dl", { className: "mt-1.5 space-y-1 text-[12px]", children: [
1890
+ /* @__PURE__ */ h("div", { className: "flex items-baseline justify-between gap-4", children: [
1891
+ /* @__PURE__ */ o("dt", { className: "text-muted-foreground", children: "Date" }),
1892
+ /* @__PURE__ */ o("dd", { className: "text-right font-medium text-foreground", children: S })
1893
+ ] }),
1894
+ /* @__PURE__ */ h("div", { className: "flex items-baseline justify-between gap-4", children: [
1895
+ /* @__PURE__ */ o("dt", { className: "text-muted-foreground", children: "Date & time" }),
1896
+ /* @__PURE__ */ o("dd", { className: "text-right font-medium text-foreground", children: C })
1897
+ ] }),
1898
+ /* @__PURE__ */ h("div", { className: "flex items-baseline justify-between gap-4", children: [
1899
+ /* @__PURE__ */ o("dt", { className: "text-muted-foreground", children: "Currency" }),
1900
+ /* @__PURE__ */ o("dd", { className: "text-right font-medium text-foreground", children: w })
1901
+ ] })
1902
+ ] })
1903
+ ] }),
1904
+ /* @__PURE__ */ o("p", { className: "text-[11px] text-muted-foreground", children: "Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar." })
1905
+ ] });
1906
+ }
1907
+ const vt = [
1908
+ "locale",
1909
+ "dateStyle",
1910
+ "dateTime.dateStyle",
1911
+ "dateTime.timeStyle",
1912
+ "defaultCurrency"
1913
+ ];
1914
+ function bt(e, a) {
1915
+ var t, n;
1916
+ switch (a) {
1917
+ case "locale":
1918
+ return e == null ? void 0 : e.locale;
1919
+ case "dateStyle":
1920
+ return e == null ? void 0 : e.dateStyle;
1921
+ case "dateTime.dateStyle":
1922
+ return (t = e == null ? void 0 : e.dateTime) == null ? void 0 : t.dateStyle;
1923
+ case "dateTime.timeStyle":
1924
+ return (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.timeStyle;
1925
+ case "defaultCurrency":
1926
+ return e == null ? void 0 : e.defaultCurrency;
1927
+ }
1928
+ }
1929
+ function on(e) {
1930
+ var n, r;
1931
+ const a = (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.dateStyle, t = (r = e == null ? void 0 : e.dateTime) == null ? void 0 : r.timeStyle;
1932
+ return {
1933
+ locale: e == null ? void 0 : e.locale,
1934
+ dateStyle: e == null ? void 0 : e.dateStyle,
1935
+ dateTime: a === void 0 && t === void 0 ? void 0 : { dateStyle: a, timeStyle: t },
1936
+ defaultCurrency: e == null ? void 0 : e.defaultCurrency
1937
+ };
1938
+ }
1939
+ function dn({
1940
+ active: e,
1941
+ onClose: a
1942
+ }) {
1943
+ var i, m, u, y, c, v, f;
1944
+ const { preferences: t, isLoading: n, isSaving: r, updatePreferences: l } = an({ enabled: e });
1945
+ if (!e) return null;
1946
+ if (!t)
1947
+ return /* @__PURE__ */ h(te, { children: [
1948
+ /* @__PURE__ */ o("div", { className: "py-2", children: /* @__PURE__ */ o("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: n ? "Loading preferences…" : "Preferences unavailable." }) }),
1949
+ /* @__PURE__ */ h(Ge, { className: "justify-between sm:justify-between", children: [
1950
+ /* @__PURE__ */ o(q, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
1951
+ /* @__PURE__ */ h("div", { className: "flex gap-2", children: [
1952
+ /* @__PURE__ */ o(q, { variant: "outline", size: "xs", onClick: a, children: "Cancel" }),
1953
+ /* @__PURE__ */ o(q, { size: "xs", disabled: !0, children: "Save" })
1954
+ ] })
1955
+ ] })
1956
+ ] });
1957
+ const s = [
1958
+ ((i = t.stored) == null ? void 0 : i.locale) ?? "",
1959
+ ((m = t.stored) == null ? void 0 : m.dateStyle) ?? "",
1960
+ ((y = (u = t.stored) == null ? void 0 : u.dateTime) == null ? void 0 : y.dateStyle) ?? "",
1961
+ ((v = (c = t.stored) == null ? void 0 : c.dateTime) == null ? void 0 : v.timeStyle) ?? "",
1962
+ ((f = t.stored) == null ? void 0 : f.defaultCurrency) ?? ""
1963
+ ].join(":");
1964
+ return /* @__PURE__ */ o(
1965
+ cn,
1966
+ {
1967
+ preferences: t,
1968
+ isSaving: r,
1969
+ updatePreferences: l,
1970
+ onClose: a
1971
+ },
1972
+ s
1973
+ );
1974
+ }
1975
+ function cn({
1976
+ preferences: e,
1977
+ isSaving: a,
1978
+ updatePreferences: t,
1979
+ onClose: n
1980
+ }) {
1981
+ var u, y;
1982
+ const [r, l] = L(
1983
+ () => on(e.stored)
1984
+ ), s = (r.locale === void 0 || xt(r.locale) !== void 0) && (r.defaultCurrency === void 0 || Va(r.defaultCurrency) !== void 0) && (r.dateStyle === void 0 || ["short", "medium", "long"].includes(r.dateStyle)) && (((u = r.dateTime) == null ? void 0 : u.dateStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.dateStyle)) && (((y = r.dateTime) == null ? void 0 : y.timeStyle) === void 0 || ["short", "medium", "long"].includes(r.dateTime.timeStyle)), i = async () => {
1985
+ const c = {
1986
+ ...r.locale !== void 0 ? { locale: r.locale } : {},
1987
+ ...r.dateStyle !== void 0 ? { dateStyle: r.dateStyle } : {},
1988
+ ...r.dateTime ? { dateTime: { ...r.dateTime } } : {},
1989
+ ...r.defaultCurrency !== void 0 ? { defaultCurrency: r.defaultCurrency } : {}
1990
+ }, v = vt.filter(
1991
+ (b) => bt(r, b) === void 0 && bt(e.stored, b) !== void 0
1992
+ ), f = {
1993
+ ...Object.keys(c).length > 0 ? { set: c } : {},
1994
+ ...v.length > 0 ? { clear: v } : {}
1995
+ };
1996
+ (Object.keys(f).length === 0 ? !0 : await t(f)) ? (G.success("Display format preferences saved."), n()) : G.error("Failed to save preferences. Please try again.");
1997
+ }, m = async () => {
1998
+ await t({
1999
+ clear: [...vt]
2000
+ }) ? (G.success("Display format preferences reset."), n()) : G.error(
2001
+ "Failed to reset display format preferences. Please try again."
2002
+ );
2003
+ };
2004
+ return /* @__PURE__ */ h(te, { children: [
2005
+ /* @__PURE__ */ o("div", { className: "py-2", children: /* @__PURE__ */ o(
2006
+ ln,
2007
+ {
2008
+ value: r,
2009
+ inherited: e.inherited,
2010
+ inheritedSources: e.inheritedSources,
2011
+ onChange: l,
2012
+ disabled: a
2013
+ }
2014
+ ) }),
2015
+ /* @__PURE__ */ h(Ge, { className: "justify-between sm:justify-between", children: [
2016
+ /* @__PURE__ */ o(
2017
+ q,
2018
+ {
2019
+ variant: "ghost",
2020
+ size: "xs",
2021
+ onClick: m,
2022
+ disabled: a || e.stored === null,
2023
+ children: "Reset display formats"
2024
+ }
2025
+ ),
2026
+ /* @__PURE__ */ h("div", { className: "flex gap-2", children: [
2027
+ /* @__PURE__ */ o(
2028
+ q,
2029
+ {
2030
+ variant: "outline",
2031
+ size: "xs",
2032
+ onClick: n,
2033
+ disabled: a,
2034
+ children: "Cancel"
2035
+ }
2036
+ ),
2037
+ /* @__PURE__ */ o(
2038
+ q,
2039
+ {
2040
+ size: "xs",
2041
+ onClick: i,
2042
+ disabled: a || !s,
2043
+ children: a ? /* @__PURE__ */ h(te, { children: [
2044
+ /* @__PURE__ */ o(St, { className: "h-3.5 w-3.5 animate-spin" }),
2045
+ "Saving…"
2046
+ ] }) : "Save"
2047
+ }
2048
+ )
2049
+ ] })
2050
+ ] })
2051
+ ] });
2052
+ }
2053
+ function Pn({
2054
+ open: e,
2055
+ onOpenChange: a
2056
+ }) {
2057
+ const [t, n] = L("display"), r = () => a(!1);
2058
+ return /* @__PURE__ */ o(Sa, { open: e, onOpenChange: a, children: /* @__PURE__ */ h(xa, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
2059
+ /* @__PURE__ */ h(Ca, { children: [
2060
+ /* @__PURE__ */ o(Ia, { className: "text-[15px]", children: "Report preferences" }),
2061
+ /* @__PURE__ */ o(Ea, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
2062
+ ] }),
2063
+ /* @__PURE__ */ h(Ua, { value: t, onValueChange: n, children: [
2064
+ /* @__PURE__ */ h(Ba, { variant: "underline", className: "w-full justify-start", children: [
2065
+ /* @__PURE__ */ o(st, { value: "display", children: "Display formats" }),
2066
+ /* @__PURE__ */ o(st, { value: "calendar", children: "Calendar" })
2067
+ ] }),
2068
+ /* @__PURE__ */ o(lt, { value: "display", children: /* @__PURE__ */ o(
2069
+ dn,
2070
+ {
2071
+ active: e && t === "display",
2072
+ onClose: r
2073
+ }
2074
+ ) }),
2075
+ /* @__PURE__ */ o(lt, { value: "calendar", children: /* @__PURE__ */ o(
2076
+ tn,
2077
+ {
2078
+ active: e && t === "calendar",
2079
+ onClose: r
2080
+ }
2081
+ ) })
2082
+ ] })
2083
+ ] }) });
2084
+ }
2085
+ export {
2086
+ Xa as A,
2087
+ Pt as C,
2088
+ _n as D,
2089
+ Pn as R,
2090
+ ar as T,
2091
+ ln as a,
2092
+ Ot as b,
2093
+ Lt as c,
2094
+ zt as d,
2095
+ $e as e,
2096
+ Ve as f,
2097
+ ur as g,
2098
+ Dn as h,
2099
+ tr as i,
2100
+ nr as j,
2101
+ Rn as k,
2102
+ An as l,
2103
+ lr as m,
2104
+ Je as n,
2105
+ yr as o,
2106
+ br as p,
2107
+ rr as t,
2108
+ kn as u
2109
+ };