react-semaphor 0.1.548 → 0.1.549

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