react-semaphor 0.1.525 → 0.1.526

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 (54) hide show
  1. package/dist/brand-studio/index.js +37 -37
  2. package/dist/briefings/index.js +3 -3
  3. package/dist/chunks/{calculated-field-identity-Dy_WpDdo.js → calculated-field-identity-D1ofR4KJ.js} +28 -28
  4. package/dist/chunks/{card-config-utils-CAyjC5Tp.js → card-config-utils-9sv4e-Vb.js} +15 -15
  5. package/dist/chunks/{switch-CWPcwAZ4.js → code-highlight-994tgM9v.js} +6309 -8642
  6. package/dist/chunks/dashboard-CsHvEtjN.js +15 -0
  7. package/dist/chunks/{dashboard-briefing-launcher-BilVIEyw.js → dashboard-briefing-launcher-DXz1GhFZ.js} +364 -370
  8. package/dist/chunks/{dashboard-controls-DyLPcvCK.js → dashboard-controls-Df8qOSrs.js} +163 -168
  9. package/dist/chunks/dashboard-json-Xldp0qww.js +65 -0
  10. package/dist/chunks/{edit-dashboard-visual-DtmKNNdE.js → edit-dashboard-visual-COHBqyic.js} +1108 -1107
  11. package/dist/chunks/editor-action-buttons-DahlP57T.js +2071 -0
  12. package/dist/chunks/{index-ON7Gpvcv.js → index-CbjuruKe.js} +40 -40
  13. package/dist/chunks/{matrix-control-sources-B1K7x0SL.js → matrix-control-sources-2VAzGlt8.js} +29 -29
  14. package/dist/chunks/pre-block-Cq1RqhZX.js +3987 -0
  15. package/dist/chunks/report-preferences-dialog-BcH-0lR-.js +1232 -0
  16. package/dist/chunks/search-CJz-QQ0Q.js +24 -0
  17. package/dist/chunks/{selection-reducer-CvCBQbl2.js → selection-reducer-NF5C07yM.js} +25 -46
  18. package/dist/chunks/{index-DYOaHuLS.js → semaphor-ready-indicator-BLRDuLr4.js} +142229 -147767
  19. package/dist/chunks/slider-BYIH4icg.js +877 -0
  20. package/dist/chunks/switch-XaAACBrJ.js +2234 -0
  21. package/dist/dashboard/index.js +1 -1
  22. package/dist/dashboard-authoring/index.js +4 -4
  23. package/dist/data-app-builder/index.js +67 -67
  24. package/dist/data-app-sdk/index.js +33 -32
  25. package/dist/index.js +435 -243
  26. package/dist/surfboard/index.js +4 -5
  27. package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
  28. package/dist/types/components/dashboard/sheet/layout-change-guard.d.ts +1 -1
  29. package/dist/types/components/dashboard/sheet/sheet-layout.d.ts +1 -1
  30. package/dist/types/components/editor/editor-main/text-card.d.ts +1 -1
  31. package/dist/types/components/editor/editor.d.ts +1 -1
  32. package/dist/types/components/providers/semaphor-context-provider.d.ts +1 -1
  33. package/dist/types/components/providers/theme-provider-context.d.ts +1 -1
  34. package/dist/types/components/providers/theme-provider.d.ts +1 -1
  35. package/dist/types/components/shared/unsaved-changes/use-pristine-snapshot-initializer.d.ts +1 -1
  36. package/dist/types/components/surfboard/dashboard-plus.d.ts +1 -1
  37. package/dist/types/components/visual/column-display-utils.d.ts +1 -1
  38. package/dist/types/components/visual/kpi-visual/kpi-utils.d.ts +1 -1
  39. package/dist/types/components/visual/settings/color-format.d.ts +1 -1
  40. package/dist/types/components/visual/visual-utils.d.ts +1 -1
  41. package/dist/types/lib/actions/data-point-click-action.d.ts +2 -1
  42. package/dist/types/lib/dashboard/normalize-dashboard-for-dirty-check.d.ts +1 -1
  43. package/dist/types/lib/hooks/explorer/use-schemas.d.ts +1 -1
  44. package/dist/types/lib/hooks/use-dashboard.d.ts +2 -2
  45. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +1 -2
  46. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  47. package/dist/types/lib/stores/table-actions.d.ts +2 -1
  48. package/dist/types/lib/types/token-types.d.ts +0 -12
  49. package/dist/types/lib/utils.d.ts +0 -2
  50. package/package.json +2 -1
  51. package/dist/chunks/dashboard-json-QEoU-mx4.js +0 -75
  52. package/dist/chunks/editor-action-buttons-B9VRW3Bh.js +0 -2019
  53. package/dist/chunks/report-preferences-dialog-BLaFmlE2.js +0 -723
  54. package/dist/types/lib/encrypt-utils.d.ts +0 -9
@@ -0,0 +1,1232 @@
1
+ import { jsxs as l, jsx as a, Fragment as $ } from "react/jsx-runtime";
2
+ import Pe, { useRef as M, useState as C, useCallback as _, useEffect as U, lazy as ie, Suspense as J, Activity as De, useMemo as q, useId as V } from "react";
3
+ import { aJ as Re, aK as _e, aL as Ae, aM as Ie, aN as Le, a as Fe, E as ze, F as Ue, B as Oe, S as je, U as Ve, D as We, C as Me, ax as Se, aO as $e, aP as ce, aQ as Z, aR as Be, e as He, f as Ke, g as Ge, h as Je, i as de, j as ue, aS as qe, aT as oe, aU as Ze, aV as Ye, aW as Xe, aX as Qe, aY as ea } from "./semaphor-ready-indicator-BLRDuLr4.js";
4
+ import { u as R, E as aa, c as z, Z as ta, $ as ra, P as la, a as na, B as L, b as sa, C as me, L as xe, _ as I, S as ae, d as te, e as re, f as le, g as F } from "./code-highlight-994tgM9v.js";
5
+ import { L as O, T as ia, a as oa, b as fe, d as he } from "./switch-XaAACBrJ.js";
6
+ import { X as ca } from "./x-CXDkqdur.js";
7
+ import "./validators-CsdOtZI6.js";
8
+ import "./matrix-operation-contract-D32U2CSw.js";
9
+ import { parseValueFormatPreferencesResponse as da, canonicalizeSupportedLocale as we, getSupportedCurrencyCodes as ua, canonicalizeSupportedCurrencyCode as ma } from "../value-format-preferences/index.js";
10
+ import { S as fa } from "./pre-block-Cq1RqhZX.js";
11
+ import { a as ha } from "./report-runtime-context-CxIoGyNM.js";
12
+ import { r as H, a as W } from "./raw-temporal-7bFbXd2a.js";
13
+ function va(e = []) {
14
+ const r = M(null), t = M(null), s = M(null), [n, i] = C(), o = _(() => {
15
+ var g, v, p;
16
+ const m = ((g = r.current) == null ? void 0 : g.clientWidth) ?? 0, h = ((v = s.current) == null ? void 0 : v.offsetWidth) ?? 0, y = ((p = t.current) == null ? void 0 : p.offsetWidth) ?? 0, f = m - h - y - 8, S = Math.max(f, 0);
17
+ i((k) => k === S ? k : S);
18
+ }, []);
19
+ return U(() => {
20
+ const m = r.current;
21
+ if (!m || typeof ResizeObserver > "u") return;
22
+ const h = new ResizeObserver(() => o());
23
+ return h.observe(m), o(), () => h.disconnect();
24
+ }, [o, ...e]), {
25
+ headerRef: r,
26
+ leftActionsRef: t,
27
+ rightActionsRef: s,
28
+ titleMaxWidth: n,
29
+ updateAvailableWidth: o
30
+ };
31
+ }
32
+ function pa({ filter: e }) {
33
+ var v;
34
+ const r = R(
35
+ (p) => p.isDashboardEditing
36
+ ), { preferences: t } = Re(), s = _e((v = t == null ? void 0 : t.cardDisplay) == null ? void 0 : v.mode), n = R((p) => p.filterValues), i = n == null ? void 0 : n.some(
37
+ (p) => p.filterId === e.id
38
+ ), { removeFilterValues: o, removeFilter: m, updateFilter: h } = aa(), {
39
+ headerRef: y,
40
+ leftActionsRef: N,
41
+ rightActionsRef: f,
42
+ titleMaxWidth: S,
43
+ updateAvailableWidth: g
44
+ } = va([
45
+ r,
46
+ i,
47
+ s
48
+ ]);
49
+ return U(() => {
50
+ g();
51
+ }, [e.title, g]), /* @__PURE__ */ l(
52
+ "div",
53
+ {
54
+ ref: y,
55
+ className: "group mb-1 flex h-5 items-center justify-between",
56
+ children: [
57
+ /* @__PURE__ */ l("div", { className: "flex grow items-center gap-2 min-w-0", children: [
58
+ /* @__PURE__ */ a(
59
+ "div",
60
+ {
61
+ className: "min-w-0 flex-1",
62
+ style: S !== void 0 ? { maxWidth: S } : void 0,
63
+ children: /* @__PURE__ */ a(O, { className: "my-1 block w-full text-sm", children: /* @__PURE__ */ a(
64
+ Ae,
65
+ {
66
+ value: e.title || e.column,
67
+ onSave: (p) => h({ ...e, title: p }),
68
+ isEditable: r,
69
+ placeholder: "Filter",
70
+ displayClassName: "text-sm truncate",
71
+ inputClassName: "text-sm"
72
+ }
73
+ ) })
74
+ }
75
+ ),
76
+ /* @__PURE__ */ l(
77
+ "div",
78
+ {
79
+ className: "flex shrink-0 items-center gap-1.5",
80
+ ref: N,
81
+ children: [
82
+ r && /* @__PURE__ */ a(Ie, { filter: e, isEditing: r }),
83
+ r && /* @__PURE__ */ a(
84
+ "button",
85
+ {
86
+ onClick: () => {
87
+ o(e.id), m(e.id);
88
+ },
89
+ className: "text-muted-foreground hover:text-foreground",
90
+ children: /* @__PURE__ */ a(ca, { className: "size-3.5" })
91
+ }
92
+ )
93
+ ]
94
+ }
95
+ )
96
+ ] }),
97
+ /* @__PURE__ */ a("div", { className: "hidden", ref: f })
98
+ ]
99
+ }
100
+ );
101
+ }
102
+ function ya() {
103
+ const e = R((s) => s.dashboard.filters), r = R((s) => s.theme), t = e == null ? void 0 : e.filter((s) => s.hide);
104
+ return t != null && t.length ? /* @__PURE__ */ a(
105
+ "div",
106
+ {
107
+ className: z("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5", {
108
+ "bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]": r === "light",
109
+ "bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]": r === "dark"
110
+ }),
111
+ children: t == null ? void 0 : t.map((s) => /* @__PURE__ */ l(
112
+ "div",
113
+ {
114
+ className: "flex min-w-[250px] max-w-fit flex-col gap-1 p-2",
115
+ children: [
116
+ /* @__PURE__ */ a(pa, { filter: s }),
117
+ /* @__PURE__ */ a(Le, { filter: s })
118
+ ]
119
+ },
120
+ s.id
121
+ ))
122
+ }
123
+ ) : null;
124
+ }
125
+ function ga() {
126
+ var i;
127
+ const e = R((o) => o.dashboard), r = R((o) => o.selectedSheetId), t = R(
128
+ (o) => o.isDashboardEditing
129
+ ), s = (i = e.sheets) == null ? void 0 : i.find(
130
+ (o) => o.id === r
131
+ ), n = ta(s);
132
+ return /* @__PURE__ */ a(
133
+ "div",
134
+ {
135
+ role: "dashboard-plus-main",
136
+ className: "flex min-h-0 grow basis-0 overflow-hidden",
137
+ children: /* @__PURE__ */ l("section", { className: "flex min-h-0 grow basis-0 flex-col overflow-hidden", children: [
138
+ t && !n && /* @__PURE__ */ a(ya, {}),
139
+ /* @__PURE__ */ a(Fe, {})
140
+ ] })
141
+ }
142
+ );
143
+ }
144
+ const ba = ie(() => import("./dashboard-controls-Df8qOSrs.js")), Sa = ie(
145
+ () => import("./edit-dashboard-visual-COHBqyic.js")
146
+ ), xa = ie(() => import("./dashboard-json-Xldp0qww.js"));
147
+ function Ga({
148
+ showControls: e = !1,
149
+ showFooter: r = !0,
150
+ ...t
151
+ }) {
152
+ const s = R((m) => m.isVisualEditing), n = R(
153
+ (m) => m.showDashboardJSON
154
+ ), { appearance: i, preferences: o } = t;
155
+ return /* @__PURE__ */ a(ze, { FallbackComponent: Ue, children: /* @__PURE__ */ a(fa, { dashboardProps: t, children: /* @__PURE__ */ l(Oe, { children: [
156
+ /* @__PURE__ */ a(je, { componentType: "surfboard", componentId: t.id }),
157
+ /* @__PURE__ */ l(Ve, { appearance: i, children: [
158
+ /* @__PURE__ */ a(
159
+ ra,
160
+ {
161
+ toastOptions: {
162
+ classNames: {
163
+ 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]",
164
+ content: "min-w-0 flex-1",
165
+ icon: "mt-0.5 shrink-0",
166
+ title: "max-w-full break-words pr-8",
167
+ description: "max-w-full break-words",
168
+ closeButton: "!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"
169
+ }
170
+ }
171
+ }
172
+ ),
173
+ /* @__PURE__ */ l(We, { preferences: o, children: [
174
+ n && /* @__PURE__ */ a(J, { fallback: null, children: /* @__PURE__ */ a(xa, {}) }),
175
+ /* @__PURE__ */ l("main", { className: "relative flex h-full w-full flex-col overflow-hidden", children: [
176
+ e && /* @__PURE__ */ a(J, { fallback: null, children: /* @__PURE__ */ a(ba, {}) }),
177
+ /* @__PURE__ */ a("div", { className: "flex grow overflow-hidden", children: /* @__PURE__ */ a("div", { className: "flex min-w-0 flex-1", children: /* @__PURE__ */ l(Me, { ...t, type: "dashboard", children: [
178
+ s && /* @__PURE__ */ a(J, { fallback: null, children: /* @__PURE__ */ a(Sa, {}) }),
179
+ /* @__PURE__ */ a(De, { mode: s ? "hidden" : "visible", children: /* @__PURE__ */ a(ga, {}) })
180
+ ] }) }) })
181
+ ] })
182
+ ] })
183
+ ] })
184
+ ] }) }) });
185
+ }
186
+ function wa(e = {}) {
187
+ const { authToken: r, tokenProps: t } = Se(), s = R(
188
+ (T) => T.actions.applyResolvedCalendarPreferences
189
+ ), n = e.enabled ?? !0, i = (r == null ? void 0 : r.accessToken) ?? null, o = (t == null ? void 0 : t.apiServiceUrl) ?? null, [m, h] = C(!1), [y, N] = C(!1), [f, S] = C(!1), [g, v] = C(null), [p, k] = C(null), x = M(i);
190
+ x.current = i, U(() => {
191
+ k(null), v(null), h(!1), N(!1), S(!1);
192
+ }, [i]);
193
+ const P = _(async (T) => {
194
+ const c = ha(await T.json());
195
+ if (!c.ok)
196
+ throw new Error("Calendar preferences response is invalid");
197
+ return c.value;
198
+ }, []), E = _(async () => {
199
+ if (!n || !i || !o) return;
200
+ const T = i;
201
+ h(!0), v(null);
202
+ try {
203
+ const c = await fetch(
204
+ `${o}/v1/user-preferences/calendar`,
205
+ {
206
+ method: "GET",
207
+ headers: { Authorization: `Bearer ${i}` }
208
+ }
209
+ );
210
+ if (!c.ok) {
211
+ const w = await c.json().catch(() => ({}));
212
+ throw new Error(w.error || "Failed to fetch preferences");
213
+ }
214
+ const u = await P(c);
215
+ x.current === T && k(u);
216
+ } catch (c) {
217
+ x.current === T && v(c instanceof Error ? c.message : "Unknown error");
218
+ } finally {
219
+ x.current === T && h(!1);
220
+ }
221
+ }, [i, o, n, P]);
222
+ U(() => {
223
+ n && E();
224
+ }, [n, E]);
225
+ const D = _(
226
+ async (T) => {
227
+ if (!i || !o)
228
+ return v("Not authenticated"), !1;
229
+ const c = i;
230
+ N(!0), v(null);
231
+ try {
232
+ const u = await fetch(
233
+ `${o}/v1/user-preferences/calendar`,
234
+ {
235
+ method: "PATCH",
236
+ headers: {
237
+ "Content-Type": "application/json",
238
+ Authorization: `Bearer ${i}`
239
+ },
240
+ body: JSON.stringify(T)
241
+ }
242
+ );
243
+ if (!u.ok) {
244
+ const d = await u.json().catch(() => ({}));
245
+ throw new Error(d.error || "Failed to update preferences");
246
+ }
247
+ const w = await P(u);
248
+ return x.current !== c ? !1 : (k(w), s(w.resolved, w.sources), !0);
249
+ } catch (u) {
250
+ return x.current === c && v(u instanceof Error ? u.message : "Unknown error"), !1;
251
+ } finally {
252
+ x.current === c && N(!1);
253
+ }
254
+ },
255
+ [
256
+ i,
257
+ o,
258
+ s,
259
+ P
260
+ ]
261
+ ), A = _(async () => {
262
+ if (!i || !o)
263
+ return v("Not authenticated"), !1;
264
+ const T = i;
265
+ S(!0), v(null);
266
+ try {
267
+ const c = await fetch(
268
+ `${o}/v1/user-preferences/calendar`,
269
+ {
270
+ method: "DELETE",
271
+ headers: { Authorization: `Bearer ${i}` }
272
+ }
273
+ );
274
+ if (!c.ok) {
275
+ const w = await c.json().catch(() => ({}));
276
+ throw new Error(w.error || "Failed to clear preferences");
277
+ }
278
+ const u = await P(c);
279
+ return x.current !== T ? !1 : (k(u), s(u.resolved, u.sources), !0);
280
+ } catch (c) {
281
+ return x.current === T && v(c instanceof Error ? c.message : "Unknown error"), !1;
282
+ } finally {
283
+ x.current === T && S(!1);
284
+ }
285
+ }, [
286
+ i,
287
+ o,
288
+ s,
289
+ P
290
+ ]);
291
+ return {
292
+ preferences: p,
293
+ isLoading: m,
294
+ isSaving: y,
295
+ isClearing: f,
296
+ error: g,
297
+ updatePreferences: D,
298
+ clearPreferences: A,
299
+ refetch: E
300
+ };
301
+ }
302
+ const K = [
303
+ { value: "America/New_York", label: "Eastern Time (US & Canada)" },
304
+ { value: "America/Chicago", label: "Central Time (US & Canada)" },
305
+ { value: "America/Denver", label: "Mountain Time (US & Canada)" },
306
+ { value: "America/Los_Angeles", label: "Pacific Time (US & Canada)" },
307
+ { value: "America/Phoenix", label: "Arizona" },
308
+ { value: "America/Anchorage", label: "Alaska" },
309
+ { value: "Pacific/Honolulu", label: "Hawaii" },
310
+ { value: "Europe/London", label: "London" },
311
+ { value: "Europe/Paris", label: "Paris, Berlin, Rome" },
312
+ { value: "Asia/Tokyo", label: "Tokyo" },
313
+ { value: "Asia/Shanghai", label: "Beijing, Shanghai" },
314
+ { value: "Asia/Kolkata", label: "Mumbai, New Delhi" },
315
+ { value: "Australia/Sydney", label: "Sydney" },
316
+ { value: "UTC", label: "UTC" }
317
+ ], Te = [
318
+ { value: 0, label: "Sunday" },
319
+ { value: 1, label: "Monday" },
320
+ { value: 6, label: "Saturday" }
321
+ ], ve = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground";
322
+ function Ta() {
323
+ try {
324
+ const e = Intl;
325
+ if (e.supportedValuesOf)
326
+ return e.supportedValuesOf("timeZone");
327
+ } catch {
328
+ }
329
+ return K.map((e) => e.value);
330
+ }
331
+ function Na(e) {
332
+ if (!e) return "default";
333
+ if (e.tz !== e.weekStart) return "inherited";
334
+ switch (e.tz) {
335
+ case "viewer_tenant":
336
+ return "tenant";
337
+ case "viewer_organization":
338
+ return "organization";
339
+ case "system_default":
340
+ return "system";
341
+ case "session_initial":
342
+ return "embedded";
343
+ default:
344
+ return "default";
345
+ }
346
+ }
347
+ function pe(e) {
348
+ const r = K.find((t) => t.value === e);
349
+ return r ? r.label : e;
350
+ }
351
+ function Ca(e) {
352
+ const r = Te.find((t) => t.value === e);
353
+ return r ? r.label : String(e);
354
+ }
355
+ function ka({
356
+ active: e,
357
+ onClose: r
358
+ }) {
359
+ const {
360
+ preferences: t,
361
+ isLoading: s,
362
+ isSaving: n,
363
+ isClearing: i,
364
+ updatePreferences: o,
365
+ clearPreferences: m
366
+ } = wa({ enabled: e }), h = $e(), y = (t == null ? void 0 : t.resolved.tz) || (h == null ? void 0 : h.tz) || "UTC", N = (t == null ? void 0 : t.resolved.weekStart) ?? (h == null ? void 0 : h.weekStart) ?? 1, [f, S] = C((t == null ? void 0 : t.stored) === null), [g, v] = C(!1), [p, k] = C(
367
+ y
368
+ ), [x, P] = C(
369
+ N
370
+ ), [E, D] = C(!1), A = q(() => Ta(), []), T = q(
371
+ () => A.filter(
372
+ (b) => !K.some((Ee) => Ee.value === b)
373
+ ),
374
+ [A]
375
+ ), c = q(() => pe(p), [p]), u = t != null && t.inherited ? pe(t.inherited.tz) : "UTC", w = t != null && t.inherited ? Ca(t.inherited.weekStart) : "Monday", d = Na(
376
+ t == null ? void 0 : t.inheritedSources
377
+ );
378
+ Pe.useEffect(() => {
379
+ if (!e) {
380
+ v(!1);
381
+ return;
382
+ }
383
+ g || (t && S(t.stored === null), k(y), P(N));
384
+ }, [
385
+ e,
386
+ g,
387
+ t,
388
+ y,
389
+ N
390
+ ]);
391
+ const B = async () => {
392
+ if (s) {
393
+ I.error("Preferences are still loading. Please try again.");
394
+ return;
395
+ }
396
+ f ? await m() ? (I.success("Now using default settings."), r()) : I.error("Failed to save preferences. Please try again.") : await o({
397
+ tz: p,
398
+ weekStart: x
399
+ }) ? (I.success("Preferences saved."), r()) : I.error("Failed to save preferences. Please try again.");
400
+ }, j = () => {
401
+ r();
402
+ }, G = n || i, ke = G || s;
403
+ return /* @__PURE__ */ l($, { children: [
404
+ /* @__PURE__ */ l("div", { className: "space-y-4 py-1", children: [
405
+ /* @__PURE__ */ l(
406
+ ce,
407
+ {
408
+ value: f ? "defaults" : "custom",
409
+ onValueChange: (b) => {
410
+ v(!0), S(b === "defaults");
411
+ },
412
+ className: "space-y-0.5",
413
+ children: [
414
+ /* @__PURE__ */ l(
415
+ "label",
416
+ {
417
+ htmlFor: "mode-defaults",
418
+ className: z(
419
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
420
+ f && "bg-muted/50"
421
+ ),
422
+ onClick: () => {
423
+ v(!0), S(!0);
424
+ },
425
+ children: [
426
+ /* @__PURE__ */ a(
427
+ Z,
428
+ {
429
+ value: "defaults",
430
+ id: "mode-defaults",
431
+ className: "mt-0.5"
432
+ }
433
+ ),
434
+ /* @__PURE__ */ l("div", { className: "flex-1 min-w-0", children: [
435
+ /* @__PURE__ */ l("p", { className: "text-[13px] font-medium text-foreground", children: [
436
+ "Use ",
437
+ d,
438
+ " defaults"
439
+ ] }),
440
+ /* @__PURE__ */ l("p", { className: "text-[12px] text-muted-foreground", children: [
441
+ u,
442
+ ", week starts ",
443
+ w
444
+ ] })
445
+ ] })
446
+ ]
447
+ }
448
+ ),
449
+ /* @__PURE__ */ l(
450
+ "label",
451
+ {
452
+ htmlFor: "mode-custom",
453
+ className: z(
454
+ "flex cursor-pointer items-start gap-2 rounded-control px-2 py-1.5 hover:bg-muted/50",
455
+ !f && "bg-muted/50"
456
+ ),
457
+ onClick: () => {
458
+ v(!0), S(!1);
459
+ },
460
+ children: [
461
+ /* @__PURE__ */ a(
462
+ Z,
463
+ {
464
+ value: "custom",
465
+ id: "mode-custom",
466
+ className: "mt-0.5"
467
+ }
468
+ ),
469
+ /* @__PURE__ */ a("p", { className: "flex-1 text-[13px] font-medium text-foreground", children: "Use custom settings" })
470
+ ]
471
+ }
472
+ )
473
+ ]
474
+ }
475
+ ),
476
+ /* @__PURE__ */ l(
477
+ "div",
478
+ {
479
+ className: z(
480
+ "space-y-4 border-t border-border/60 pt-4 transition-opacity",
481
+ f && "pointer-events-none opacity-50"
482
+ ),
483
+ children: [
484
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
485
+ /* @__PURE__ */ a(O, { className: ve, children: "Timezone" }),
486
+ /* @__PURE__ */ l(
487
+ la,
488
+ {
489
+ open: E,
490
+ onOpenChange: D,
491
+ modal: !0,
492
+ children: [
493
+ /* @__PURE__ */ a(na, { asChild: !0, children: /* @__PURE__ */ l(
494
+ L,
495
+ {
496
+ variant: "outline",
497
+ size: "xs",
498
+ role: "combobox",
499
+ "aria-expanded": E,
500
+ className: "w-full justify-between text-[12px] font-normal",
501
+ disabled: f,
502
+ children: [
503
+ /* @__PURE__ */ a("span", { className: "truncate", children: c }),
504
+ /* @__PURE__ */ a(Be, { className: "ml-2 h-3.5 w-3.5 shrink-0 opacity-50" })
505
+ ]
506
+ }
507
+ ) }),
508
+ /* @__PURE__ */ a(
509
+ sa,
510
+ {
511
+ className: "z-50 w-[--radix-popover-trigger-width] p-0",
512
+ align: "start",
513
+ children: /* @__PURE__ */ l(He, { className: "overflow-visible", children: [
514
+ /* @__PURE__ */ a(Ke, { placeholder: "Search timezones…" }),
515
+ /* @__PURE__ */ l(Ge, { children: [
516
+ /* @__PURE__ */ a(Je, { children: "No timezone found." }),
517
+ /* @__PURE__ */ a(de, { heading: "Common", children: K.map((b) => /* @__PURE__ */ l(
518
+ ue,
519
+ {
520
+ value: `${b.value} ${b.label}`,
521
+ onSelect: () => {
522
+ v(!0), k(b.value), D(!1);
523
+ },
524
+ children: [
525
+ /* @__PURE__ */ a(
526
+ me,
527
+ {
528
+ className: z(
529
+ "h-3.5 w-3.5",
530
+ p === b.value ? "opacity-100" : "opacity-0"
531
+ )
532
+ }
533
+ ),
534
+ /* @__PURE__ */ a("span", { className: "flex-1", children: b.label }),
535
+ /* @__PURE__ */ a("span", { className: "text-[11px] text-muted-foreground", children: b.value })
536
+ ]
537
+ },
538
+ b.value
539
+ )) }),
540
+ /* @__PURE__ */ a(qe, {}),
541
+ /* @__PURE__ */ a(de, { heading: "All timezones", children: T.map((b) => /* @__PURE__ */ l(
542
+ ue,
543
+ {
544
+ value: b,
545
+ onSelect: () => {
546
+ v(!0), k(b), D(!1);
547
+ },
548
+ children: [
549
+ /* @__PURE__ */ a(
550
+ me,
551
+ {
552
+ className: z(
553
+ "h-3.5 w-3.5",
554
+ p === b ? "opacity-100" : "opacity-0"
555
+ )
556
+ }
557
+ ),
558
+ b
559
+ ]
560
+ },
561
+ b
562
+ )) })
563
+ ] })
564
+ ] })
565
+ }
566
+ )
567
+ ]
568
+ }
569
+ )
570
+ ] }),
571
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
572
+ /* @__PURE__ */ a(O, { className: ve, children: "Week starts on" }),
573
+ /* @__PURE__ */ a(
574
+ ce,
575
+ {
576
+ value: String(x),
577
+ onValueChange: (b) => {
578
+ v(!0), P(Number(b));
579
+ },
580
+ className: "flex gap-4",
581
+ disabled: f,
582
+ children: Te.map((b) => /* @__PURE__ */ l(
583
+ "label",
584
+ {
585
+ htmlFor: `week-start-${b.value}`,
586
+ className: z(
587
+ "flex cursor-pointer items-center gap-2 text-[13px]",
588
+ f && "cursor-not-allowed"
589
+ ),
590
+ children: [
591
+ /* @__PURE__ */ a(
592
+ Z,
593
+ {
594
+ value: String(b.value),
595
+ id: `week-start-${b.value}`,
596
+ disabled: f
597
+ }
598
+ ),
599
+ b.label
600
+ ]
601
+ },
602
+ b.value
603
+ ))
604
+ }
605
+ )
606
+ ] })
607
+ ]
608
+ }
609
+ )
610
+ ] }),
611
+ /* @__PURE__ */ l(oe, { children: [
612
+ /* @__PURE__ */ a(
613
+ L,
614
+ {
615
+ variant: "outline",
616
+ size: "xs",
617
+ onClick: j,
618
+ disabled: G,
619
+ children: "Cancel"
620
+ }
621
+ ),
622
+ /* @__PURE__ */ a(L, { size: "xs", onClick: B, disabled: ke, children: G ? /* @__PURE__ */ l($, { children: [
623
+ /* @__PURE__ */ a(xe, { className: "h-3.5 w-3.5 animate-spin" }),
624
+ "Saving…"
625
+ ] }) : "Save" })
626
+ ] })
627
+ ] });
628
+ }
629
+ function Ea(e = {}) {
630
+ const { authToken: r, tokenProps: t } = Se(), s = R(
631
+ (c) => c.actions.applyResolvedValueFormatPreferences
632
+ ), n = e.enabled ?? !0, i = (r == null ? void 0 : r.accessToken) ?? null, o = (t == null ? void 0 : t.apiServiceUrl) ?? null, m = M(i);
633
+ m.current = i;
634
+ const [h, y] = C(null), [N, f] = C(!1), [S, g] = C(!1), [v, p] = C(!1), [k, x] = C(null);
635
+ U(() => {
636
+ y(null), x(null), f(!1), g(!1), p(!1);
637
+ }, [i]);
638
+ const P = _(async (c) => {
639
+ const u = da(await c.json());
640
+ if (!u.ok)
641
+ throw new Error("Value format preferences response is invalid");
642
+ return u.value;
643
+ }, []), E = _(
644
+ async (c, u) => {
645
+ if (!i || !o)
646
+ throw new Error("Not authenticated");
647
+ const w = await fetch(
648
+ `${o}/v1/user-preferences/value-format`,
649
+ {
650
+ method: c,
651
+ headers: {
652
+ Authorization: `Bearer ${i}`,
653
+ ...u ? { "Content-Type": "application/json" } : {}
654
+ },
655
+ body: u ? JSON.stringify(u) : void 0
656
+ }
657
+ );
658
+ if (!w.ok) {
659
+ const d = await w.json().catch(() => ({}));
660
+ throw new Error(d.error || "Failed to update preferences");
661
+ }
662
+ return P(w);
663
+ },
664
+ [i, o, P]
665
+ ), D = _(async () => {
666
+ if (!n || !i || !o) return;
667
+ const c = i;
668
+ f(!0), x(null);
669
+ try {
670
+ const u = await E("GET");
671
+ m.current === c && y(u);
672
+ } catch (u) {
673
+ m.current === c && x(u instanceof Error ? u.message : "Unknown error");
674
+ } finally {
675
+ m.current === c && f(!1);
676
+ }
677
+ }, [i, o, n, E]);
678
+ U(() => {
679
+ n && D();
680
+ }, [n, D]);
681
+ const A = _(
682
+ async (c) => {
683
+ const u = i;
684
+ g(!0), x(null);
685
+ try {
686
+ const w = await E("PATCH", c);
687
+ return m.current !== u ? !1 : (y(w), s(w.resolved, w.sources), !0);
688
+ } catch (w) {
689
+ return m.current === u && x(w instanceof Error ? w.message : "Unknown error"), !1;
690
+ } finally {
691
+ m.current === u && g(!1);
692
+ }
693
+ },
694
+ [i, s, E]
695
+ ), T = _(async () => {
696
+ const c = i;
697
+ p(!0), x(null);
698
+ try {
699
+ const u = await E("DELETE");
700
+ return m.current !== c ? !1 : (y(u), s(u.resolved, u.sources), !0);
701
+ } catch (u) {
702
+ return m.current === c && x(u instanceof Error ? u.message : "Unknown error"), !1;
703
+ } finally {
704
+ m.current === c && p(!1);
705
+ }
706
+ }, [i, s, E]);
707
+ return {
708
+ preferences: h,
709
+ isLoading: N,
710
+ isSaving: S,
711
+ isClearing: v,
712
+ error: k,
713
+ updatePreferences: A,
714
+ clearPreferences: T,
715
+ refetch: D
716
+ };
717
+ }
718
+ const ne = [
719
+ { value: "en-US", label: "English (United States)" },
720
+ { value: "en-GB", label: "English (United Kingdom)" },
721
+ { value: "de-DE", label: "German (Germany)" },
722
+ { value: "fr-FR", label: "French (France)" },
723
+ { value: "es-ES", label: "Spanish (Spain)" },
724
+ { value: "it-IT", label: "Italian (Italy)" },
725
+ { value: "nl-NL", label: "Dutch (Netherlands)" },
726
+ { value: "pt-BR", label: "Portuguese (Brazil)" },
727
+ { value: "ja-JP", label: "Japanese (Japan)" },
728
+ { value: "en-IN", label: "English (India)" },
729
+ { value: "en-NZ", label: "English (New Zealand)" },
730
+ { value: "mi-NZ", label: "Māori (New Zealand)" }
731
+ ], Ne = /* @__PURE__ */ new Set([
732
+ "USD",
733
+ "EUR",
734
+ "GBP",
735
+ "CAD",
736
+ "AUD",
737
+ "JPY",
738
+ "CHF",
739
+ "INR",
740
+ "BRL",
741
+ "KWD"
742
+ ]), Pa = ua(), Da = Pa.filter(
743
+ (e) => !Ne.has(e)
744
+ ), Ce = [
745
+ { value: "short", label: "Short" },
746
+ { value: "medium", label: "Medium" },
747
+ { value: "long", label: "Long" }
748
+ ], ye = "2026-07-31", Y = "2026-07-31T14:30:45";
749
+ function se(e) {
750
+ switch (e) {
751
+ case "viewer_user":
752
+ return "user";
753
+ case "viewer_tenant_user":
754
+ return "tenant user";
755
+ case "viewer_tenant":
756
+ return "tenant";
757
+ case "viewer_organization":
758
+ return "organization";
759
+ case "session_initial":
760
+ return "embedded session";
761
+ case "system_default":
762
+ return "system";
763
+ default:
764
+ return "another preference level";
765
+ }
766
+ }
767
+ function X(e) {
768
+ var r;
769
+ return ((r = Ce.find((t) => t.value === e)) == null ? void 0 : r.label) ?? e;
770
+ }
771
+ function Ra(e) {
772
+ const r = ne.find((t) => t.value === e);
773
+ return r ? `${r.label} — ${r.value}` : e;
774
+ }
775
+ function Q(e) {
776
+ return {
777
+ short: e("short"),
778
+ medium: e("medium"),
779
+ long: e("long")
780
+ };
781
+ }
782
+ function ee({
783
+ id: e,
784
+ label: r,
785
+ value: t,
786
+ inherited: s,
787
+ inheritedSource: n,
788
+ examples: i,
789
+ disabled: o,
790
+ onValueChange: m
791
+ }) {
792
+ const h = t === void 0 ? `Inherited · ${X(s)}` : X(t);
793
+ return /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
794
+ /* @__PURE__ */ a(O, { htmlFor: e, className: "text-[11px] text-muted-foreground", children: r }),
795
+ /* @__PURE__ */ l(
796
+ ae,
797
+ {
798
+ value: t ?? "inherit",
799
+ disabled: o,
800
+ onValueChange: m,
801
+ children: [
802
+ /* @__PURE__ */ a(te, { id: e, size: "xs", children: /* @__PURE__ */ a(re, { children: h }) }),
803
+ /* @__PURE__ */ l(le, { children: [
804
+ /* @__PURE__ */ a(F, { value: "inherit", className: "[&>span:last-child]:w-full", children: /* @__PURE__ */ l("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
805
+ /* @__PURE__ */ l("span", { children: [
806
+ "Inherited from ",
807
+ se(n),
808
+ " ·",
809
+ " ",
810
+ X(s)
811
+ ] }),
812
+ /* @__PURE__ */ a("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[s] })
813
+ ] }) }),
814
+ Ce.map((y) => /* @__PURE__ */ a(
815
+ F,
816
+ {
817
+ value: y.value,
818
+ className: "[&>span:last-child]:w-full",
819
+ children: /* @__PURE__ */ l("span", { className: "flex w-full min-w-0 items-center justify-between gap-4", children: [
820
+ /* @__PURE__ */ a("span", { children: y.label }),
821
+ /* @__PURE__ */ a("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: i[y.value] })
822
+ ] })
823
+ },
824
+ y.value
825
+ ))
826
+ ] })
827
+ ]
828
+ }
829
+ )
830
+ ] });
831
+ }
832
+ function _a({
833
+ value: e,
834
+ inherited: r,
835
+ inheritedSources: t,
836
+ onChange: s,
837
+ disabled: n
838
+ }) {
839
+ var T, c, u, w;
840
+ const i = V(), o = V(), m = V(), h = V(), y = V(), f = (e.locale === void 0 ? void 0 : we(e.locale)) ?? r.locale, S = e.defaultCurrency ?? r.defaultCurrency, g = {
841
+ locale: f,
842
+ dateStyle: e.dateStyle ?? r.dateStyle,
843
+ dateTime: {
844
+ dateStyle: ((T = e.dateTime) == null ? void 0 : T.dateStyle) ?? r.dateTime.dateStyle,
845
+ timeStyle: ((c = e.dateTime) == null ? void 0 : c.timeStyle) ?? r.dateTime.timeStyle
846
+ },
847
+ defaultCurrency: S
848
+ }, v = new Intl.NumberFormat(f, {
849
+ style: "currency",
850
+ currency: S
851
+ }).format(1e3), p = H({
852
+ preferences: g,
853
+ calendar: { tz: "UTC" }
854
+ }), k = W({
855
+ value: ye,
856
+ metadata: { kind: "raw_temporal", valueKind: "date" },
857
+ format: p
858
+ }).text, x = W({
859
+ value: Y,
860
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
861
+ format: p
862
+ }).text, P = Q(
863
+ (d) => W({
864
+ value: ye,
865
+ metadata: { kind: "raw_temporal", valueKind: "date" },
866
+ format: H({
867
+ preferences: { ...g, dateStyle: d },
868
+ calendar: { tz: "UTC" }
869
+ })
870
+ }).text
871
+ ), E = Q(
872
+ (d) => W({
873
+ value: Y,
874
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
875
+ format: H({
876
+ preferences: {
877
+ ...g,
878
+ dateTime: { ...g.dateTime, dateStyle: d }
879
+ },
880
+ calendar: { tz: "UTC" }
881
+ })
882
+ }).text
883
+ ), D = Q(
884
+ (d) => W({
885
+ value: Y,
886
+ metadata: { kind: "raw_temporal", valueKind: "wall_datetime" },
887
+ format: H({
888
+ preferences: {
889
+ ...g,
890
+ dateTime: { ...g.dateTime, timeStyle: d }
891
+ },
892
+ calendar: { tz: "UTC" }
893
+ })
894
+ }).text
895
+ ), A = (d, B) => {
896
+ const j = {
897
+ ...e.dateTime,
898
+ [d]: B === "inherit" ? void 0 : B
899
+ };
900
+ s({
901
+ ...e,
902
+ dateTime: j.dateStyle === void 0 && j.timeStyle === void 0 ? void 0 : j
903
+ });
904
+ };
905
+ return /* @__PURE__ */ l("div", { className: "space-y-4", children: [
906
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
907
+ /* @__PURE__ */ a(
908
+ O,
909
+ {
910
+ htmlFor: i,
911
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
912
+ children: "Locale"
913
+ }
914
+ ),
915
+ /* @__PURE__ */ l(
916
+ ae,
917
+ {
918
+ value: e.locale ?? "inherit",
919
+ disabled: n,
920
+ onValueChange: (d) => s({
921
+ ...e,
922
+ locale: d === "inherit" ? void 0 : d
923
+ }),
924
+ children: [
925
+ /* @__PURE__ */ a(te, { id: i, size: "xs", children: /* @__PURE__ */ a(re, { children: e.locale === void 0 ? `Inherited · ${r.locale}` : Ra(e.locale) }) }),
926
+ /* @__PURE__ */ l(le, { children: [
927
+ /* @__PURE__ */ l(F, { value: "inherit", children: [
928
+ "Inherited from ",
929
+ se(t.locale),
930
+ " ·",
931
+ " ",
932
+ r.locale
933
+ ] }),
934
+ e.locale && !ne.some(
935
+ (d) => d.value === e.locale
936
+ ) && /* @__PURE__ */ a(F, { value: e.locale, children: e.locale }),
937
+ ne.map((d) => /* @__PURE__ */ l(F, { value: d.value, children: [
938
+ d.label,
939
+ " — ",
940
+ d.value
941
+ ] }, d.value))
942
+ ] })
943
+ ]
944
+ }
945
+ )
946
+ ] }),
947
+ /* @__PURE__ */ l("fieldset", { className: "space-y-2", children: [
948
+ /* @__PURE__ */ a("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date values" }),
949
+ /* @__PURE__ */ a(
950
+ ee,
951
+ {
952
+ id: m,
953
+ label: "Format",
954
+ value: e.dateStyle,
955
+ inherited: r.dateStyle,
956
+ inheritedSource: t.dateStyle,
957
+ examples: P,
958
+ disabled: n,
959
+ onValueChange: (d) => s({
960
+ ...e,
961
+ dateStyle: d === "inherit" ? void 0 : d
962
+ })
963
+ }
964
+ )
965
+ ] }),
966
+ /* @__PURE__ */ l("fieldset", { className: "space-y-2", children: [
967
+ /* @__PURE__ */ a("legend", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Date & time values" }),
968
+ /* @__PURE__ */ a(
969
+ ee,
970
+ {
971
+ id: h,
972
+ label: "Date",
973
+ value: (u = e.dateTime) == null ? void 0 : u.dateStyle,
974
+ inherited: r.dateTime.dateStyle,
975
+ inheritedSource: t.dateTime.dateStyle,
976
+ examples: E,
977
+ disabled: n,
978
+ onValueChange: (d) => A("dateStyle", d)
979
+ }
980
+ ),
981
+ /* @__PURE__ */ a(
982
+ ee,
983
+ {
984
+ id: y,
985
+ label: "Time",
986
+ value: (w = e.dateTime) == null ? void 0 : w.timeStyle,
987
+ inherited: r.dateTime.timeStyle,
988
+ inheritedSource: t.dateTime.timeStyle,
989
+ examples: D,
990
+ disabled: n,
991
+ onValueChange: (d) => A("timeStyle", d)
992
+ }
993
+ )
994
+ ] }),
995
+ /* @__PURE__ */ l("div", { className: "space-y-1.5", children: [
996
+ /* @__PURE__ */ a(
997
+ O,
998
+ {
999
+ htmlFor: o,
1000
+ className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",
1001
+ children: "Default currency"
1002
+ }
1003
+ ),
1004
+ /* @__PURE__ */ l(
1005
+ ae,
1006
+ {
1007
+ value: e.defaultCurrency ?? "inherit",
1008
+ disabled: n,
1009
+ onValueChange: (d) => s({
1010
+ ...e,
1011
+ defaultCurrency: d === "inherit" ? void 0 : d
1012
+ }),
1013
+ children: [
1014
+ /* @__PURE__ */ a(te, { id: o, size: "xs", children: /* @__PURE__ */ a(re, { children: e.defaultCurrency === void 0 ? `Inherited · ${r.defaultCurrency}` : e.defaultCurrency }) }),
1015
+ /* @__PURE__ */ l(le, { children: [
1016
+ /* @__PURE__ */ l(F, { value: "inherit", children: [
1017
+ "Inherited from ",
1018
+ se(t.defaultCurrency),
1019
+ " ·",
1020
+ " ",
1021
+ r.defaultCurrency
1022
+ ] }),
1023
+ [...Ne].map((d) => /* @__PURE__ */ a(F, { value: d, children: d }, d)),
1024
+ Da.map((d) => /* @__PURE__ */ a(F, { value: d, children: d }, d))
1025
+ ] })
1026
+ ]
1027
+ }
1028
+ )
1029
+ ] }),
1030
+ /* @__PURE__ */ l("div", { className: "rounded-control border border-border/60 bg-muted/30 px-3 py-2", children: [
1031
+ /* @__PURE__ */ a("p", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Preview" }),
1032
+ /* @__PURE__ */ l("dl", { className: "mt-1.5 space-y-1 text-[12px]", children: [
1033
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between gap-4", children: [
1034
+ /* @__PURE__ */ a("dt", { className: "text-muted-foreground", children: "Date" }),
1035
+ /* @__PURE__ */ a("dd", { className: "text-right font-medium text-foreground", children: k })
1036
+ ] }),
1037
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between gap-4", children: [
1038
+ /* @__PURE__ */ a("dt", { className: "text-muted-foreground", children: "Date & time" }),
1039
+ /* @__PURE__ */ a("dd", { className: "text-right font-medium text-foreground", children: x })
1040
+ ] }),
1041
+ /* @__PURE__ */ l("div", { className: "flex items-baseline justify-between gap-4", children: [
1042
+ /* @__PURE__ */ a("dt", { className: "text-muted-foreground", children: "Currency" }),
1043
+ /* @__PURE__ */ a("dd", { className: "text-right font-medium text-foreground", children: v })
1044
+ ] })
1045
+ ] })
1046
+ ] }),
1047
+ /* @__PURE__ */ a("p", { className: "text-[11px] text-muted-foreground", children: "Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar." })
1048
+ ] });
1049
+ }
1050
+ const ge = [
1051
+ "locale",
1052
+ "dateStyle",
1053
+ "dateTime.dateStyle",
1054
+ "dateTime.timeStyle",
1055
+ "defaultCurrency"
1056
+ ];
1057
+ function be(e, r) {
1058
+ var t, s;
1059
+ switch (r) {
1060
+ case "locale":
1061
+ return e == null ? void 0 : e.locale;
1062
+ case "dateStyle":
1063
+ return e == null ? void 0 : e.dateStyle;
1064
+ case "dateTime.dateStyle":
1065
+ return (t = e == null ? void 0 : e.dateTime) == null ? void 0 : t.dateStyle;
1066
+ case "dateTime.timeStyle":
1067
+ return (s = e == null ? void 0 : e.dateTime) == null ? void 0 : s.timeStyle;
1068
+ case "defaultCurrency":
1069
+ return e == null ? void 0 : e.defaultCurrency;
1070
+ }
1071
+ }
1072
+ function Aa(e) {
1073
+ var s, n;
1074
+ const r = (s = e == null ? void 0 : e.dateTime) == null ? void 0 : s.dateStyle, t = (n = e == null ? void 0 : e.dateTime) == null ? void 0 : n.timeStyle;
1075
+ return {
1076
+ locale: e == null ? void 0 : e.locale,
1077
+ dateStyle: e == null ? void 0 : e.dateStyle,
1078
+ dateTime: r === void 0 && t === void 0 ? void 0 : { dateStyle: r, timeStyle: t },
1079
+ defaultCurrency: e == null ? void 0 : e.defaultCurrency
1080
+ };
1081
+ }
1082
+ function Ia({
1083
+ active: e,
1084
+ onClose: r
1085
+ }) {
1086
+ var m, h, y, N, f, S, g;
1087
+ const { preferences: t, isLoading: s, isSaving: n, updatePreferences: i } = Ea({ enabled: e });
1088
+ if (!e) return null;
1089
+ if (!t)
1090
+ return /* @__PURE__ */ l($, { children: [
1091
+ /* @__PURE__ */ a("div", { className: "py-2", children: /* @__PURE__ */ a("div", { className: "flex min-h-36 items-center justify-center text-[12px] text-muted-foreground", children: s ? "Loading preferences…" : "Preferences unavailable." }) }),
1092
+ /* @__PURE__ */ l(oe, { className: "justify-between sm:justify-between", children: [
1093
+ /* @__PURE__ */ a(L, { variant: "ghost", size: "xs", disabled: !0, children: "Reset display formats" }),
1094
+ /* @__PURE__ */ l("div", { className: "flex gap-2", children: [
1095
+ /* @__PURE__ */ a(L, { variant: "outline", size: "xs", onClick: r, children: "Cancel" }),
1096
+ /* @__PURE__ */ a(L, { size: "xs", disabled: !0, children: "Save" })
1097
+ ] })
1098
+ ] })
1099
+ ] });
1100
+ const o = [
1101
+ ((m = t.stored) == null ? void 0 : m.locale) ?? "",
1102
+ ((h = t.stored) == null ? void 0 : h.dateStyle) ?? "",
1103
+ ((N = (y = t.stored) == null ? void 0 : y.dateTime) == null ? void 0 : N.dateStyle) ?? "",
1104
+ ((S = (f = t.stored) == null ? void 0 : f.dateTime) == null ? void 0 : S.timeStyle) ?? "",
1105
+ ((g = t.stored) == null ? void 0 : g.defaultCurrency) ?? ""
1106
+ ].join(":");
1107
+ return /* @__PURE__ */ a(
1108
+ La,
1109
+ {
1110
+ preferences: t,
1111
+ isSaving: n,
1112
+ updatePreferences: i,
1113
+ onClose: r
1114
+ },
1115
+ o
1116
+ );
1117
+ }
1118
+ function La({
1119
+ preferences: e,
1120
+ isSaving: r,
1121
+ updatePreferences: t,
1122
+ onClose: s
1123
+ }) {
1124
+ var y, N;
1125
+ const [n, i] = C(
1126
+ () => Aa(e.stored)
1127
+ ), o = (n.locale === void 0 || we(n.locale) !== void 0) && (n.defaultCurrency === void 0 || ma(n.defaultCurrency) !== void 0) && (n.dateStyle === void 0 || ["short", "medium", "long"].includes(n.dateStyle)) && (((y = n.dateTime) == null ? void 0 : y.dateStyle) === void 0 || ["short", "medium", "long"].includes(n.dateTime.dateStyle)) && (((N = n.dateTime) == null ? void 0 : N.timeStyle) === void 0 || ["short", "medium", "long"].includes(n.dateTime.timeStyle)), m = async () => {
1128
+ const f = {
1129
+ ...n.locale !== void 0 ? { locale: n.locale } : {},
1130
+ ...n.dateStyle !== void 0 ? { dateStyle: n.dateStyle } : {},
1131
+ ...n.dateTime ? { dateTime: { ...n.dateTime } } : {},
1132
+ ...n.defaultCurrency !== void 0 ? { defaultCurrency: n.defaultCurrency } : {}
1133
+ }, S = ge.filter(
1134
+ (p) => be(n, p) === void 0 && be(e.stored, p) !== void 0
1135
+ ), g = {
1136
+ ...Object.keys(f).length > 0 ? { set: f } : {},
1137
+ ...S.length > 0 ? { clear: S } : {}
1138
+ };
1139
+ (Object.keys(g).length === 0 ? !0 : await t(g)) ? (I.success("Display format preferences saved."), s()) : I.error("Failed to save preferences. Please try again.");
1140
+ }, h = async () => {
1141
+ await t({
1142
+ clear: [...ge]
1143
+ }) ? (I.success("Display format preferences reset."), s()) : I.error(
1144
+ "Failed to reset display format preferences. Please try again."
1145
+ );
1146
+ };
1147
+ return /* @__PURE__ */ l($, { children: [
1148
+ /* @__PURE__ */ a("div", { className: "py-2", children: /* @__PURE__ */ a(
1149
+ _a,
1150
+ {
1151
+ value: n,
1152
+ inherited: e.inherited,
1153
+ inheritedSources: e.inheritedSources,
1154
+ onChange: i,
1155
+ disabled: r
1156
+ }
1157
+ ) }),
1158
+ /* @__PURE__ */ l(oe, { className: "justify-between sm:justify-between", children: [
1159
+ /* @__PURE__ */ a(
1160
+ L,
1161
+ {
1162
+ variant: "ghost",
1163
+ size: "xs",
1164
+ onClick: h,
1165
+ disabled: r || e.stored === null,
1166
+ children: "Reset display formats"
1167
+ }
1168
+ ),
1169
+ /* @__PURE__ */ l("div", { className: "flex gap-2", children: [
1170
+ /* @__PURE__ */ a(
1171
+ L,
1172
+ {
1173
+ variant: "outline",
1174
+ size: "xs",
1175
+ onClick: s,
1176
+ disabled: r,
1177
+ children: "Cancel"
1178
+ }
1179
+ ),
1180
+ /* @__PURE__ */ a(
1181
+ L,
1182
+ {
1183
+ size: "xs",
1184
+ onClick: m,
1185
+ disabled: r || !o,
1186
+ children: r ? /* @__PURE__ */ l($, { children: [
1187
+ /* @__PURE__ */ a(xe, { className: "h-3.5 w-3.5 animate-spin" }),
1188
+ "Saving…"
1189
+ ] }) : "Save"
1190
+ }
1191
+ )
1192
+ ] })
1193
+ ] })
1194
+ ] });
1195
+ }
1196
+ function Ja({
1197
+ open: e,
1198
+ onOpenChange: r
1199
+ }) {
1200
+ const [t, s] = C("display"), n = () => r(!1);
1201
+ return /* @__PURE__ */ a(Ze, { open: e, onOpenChange: r, children: /* @__PURE__ */ l(Ye, { className: "rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control", children: [
1202
+ /* @__PURE__ */ l(Xe, { children: [
1203
+ /* @__PURE__ */ a(Qe, { className: "text-[15px]", children: "Report preferences" }),
1204
+ /* @__PURE__ */ a(ea, { className: "text-[13px] leading-5", children: "Set how values and Calendar periods appear for you." })
1205
+ ] }),
1206
+ /* @__PURE__ */ l(ia, { value: t, onValueChange: s, children: [
1207
+ /* @__PURE__ */ l(oa, { variant: "underline", className: "w-full justify-start", children: [
1208
+ /* @__PURE__ */ a(fe, { value: "display", children: "Display formats" }),
1209
+ /* @__PURE__ */ a(fe, { value: "calendar", children: "Calendar" })
1210
+ ] }),
1211
+ /* @__PURE__ */ a(he, { value: "display", children: /* @__PURE__ */ a(
1212
+ Ia,
1213
+ {
1214
+ active: e && t === "display",
1215
+ onClose: n
1216
+ }
1217
+ ) }),
1218
+ /* @__PURE__ */ a(he, { value: "calendar", children: /* @__PURE__ */ a(
1219
+ ka,
1220
+ {
1221
+ active: e && t === "calendar",
1222
+ onClose: n
1223
+ }
1224
+ ) })
1225
+ ] })
1226
+ ] }) });
1227
+ }
1228
+ export {
1229
+ Ga as D,
1230
+ Ja as R,
1231
+ _a as a
1232
+ };