react-semaphor 0.1.293 → 0.1.294

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 (40) hide show
  1. package/dist/chunks/{braces-C7GP95Fp.js → braces-DR-GdaLC.js} +1 -1
  2. package/dist/chunks/{braces-BwW2HFlB.js → braces-DfDQiR3J.js} +1 -1
  3. package/dist/chunks/{dashboard-controls-jrkoCSY_.js → dashboard-controls-C3Z9bpYE.js} +504 -472
  4. package/dist/chunks/{dashboard-controls-DgUc38Tn.js → dashboard-controls-DGEVXgP5.js} +9 -9
  5. package/dist/chunks/dashboard-filter-controls-button-BIYT1ucX.js +11 -0
  6. package/dist/chunks/dashboard-filter-controls-button-DxgGUl00.js +1152 -0
  7. package/dist/chunks/{dashboard-json-COjT-zjQ.js → dashboard-json-BvTeHePu.js} +1 -1
  8. package/dist/chunks/{dashboard-json-C0NiRL-A.js → dashboard-json-DQW8TN0I.js} +1 -1
  9. package/dist/chunks/{dashboard-summary-settings-dialog-CXqaN_zj.js → dashboard-summary-settings-dialog-BsmKiGud.js} +1 -1
  10. package/dist/chunks/{dashboard-summary-settings-dialog-CGuFl7Xe.js → dashboard-summary-settings-dialog-q7fx3YAK.js} +1 -1
  11. package/dist/chunks/edit-dashboard-visual-ChKj-Lzr.js +183 -0
  12. package/dist/chunks/{edit-dashboard-visual-ppdXk86H.js → edit-dashboard-visual-RVl9nbDZ.js} +2175 -2160
  13. package/dist/chunks/index-BlspGR07.js +1435 -0
  14. package/dist/chunks/{index-9z-jMqN8.js → index-DerPpfv0.js} +32720 -31308
  15. package/dist/chunks/{resource-management-panel-CP8cegZP.js → resource-management-panel-DnZ1rw1A.js} +64 -64
  16. package/dist/chunks/{resource-management-panel-os6AuEKT.js → resource-management-panel-epydPwyM.js} +1 -1
  17. package/dist/chunks/use-create-flow-overlay-state-Bcg4EgoD.js +21 -0
  18. package/dist/chunks/{use-create-flow-overlay-state-wpuqRZX5.js → use-create-flow-overlay-state-C5vdfXhM.js} +430 -425
  19. package/dist/chunks/use-visual-utils-D9Kknvjl.js +337 -0
  20. package/dist/chunks/use-visual-utils-Dw_yw9zU.js +1 -0
  21. package/dist/dashboard/index.cjs +1 -1
  22. package/dist/dashboard/index.js +1 -1
  23. package/dist/index.cjs +1 -1
  24. package/dist/index.js +258 -253
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.cjs +1 -1
  27. package/dist/surfboard/index.js +2 -2
  28. package/dist/types/dashboard.d.ts +28 -0
  29. package/dist/types/main.d.ts +42 -4
  30. package/dist/types/shared.d.ts +3 -0
  31. package/dist/types/surfboard.d.ts +28 -0
  32. package/dist/types/types.d.ts +28 -0
  33. package/package.json +1 -1
  34. package/dist/chunks/dashboard-filter-controls-button-B19UWmsK.js +0 -11
  35. package/dist/chunks/dashboard-filter-controls-button-DGH4DxJ8.js +0 -1109
  36. package/dist/chunks/edit-dashboard-visual-CDOz4LWO.js +0 -183
  37. package/dist/chunks/index-K25f5Rqr.js +0 -1435
  38. package/dist/chunks/use-create-flow-overlay-state-CecnMS_v.js +0 -21
  39. package/dist/chunks/use-visual-utils-BTfG-ppd.js +0 -1
  40. package/dist/chunks/use-visual-utils-BhRKGJql.js +0 -334
@@ -0,0 +1,337 @@
1
+ import { H as G, d as Y, J as X, K as Z, M as ee, N as te, O as re, Q as se, u as b, T as ae, U as oe, y as v, V as ne, W as B, Y as ie } from "./index-DerPpfv0.js";
2
+ import { useState as H, useEffect as ce, useCallback as A } from "react";
3
+ function de(e) {
4
+ const [a, s] = H(null), [r, t] = H(null), o = G();
5
+ return ce(() => {
6
+ if (!e || e.trim() === "") {
7
+ s(null), t(null);
8
+ return;
9
+ }
10
+ if (!o)
11
+ return;
12
+ (async () => {
13
+ try {
14
+ if (!e.startsWith("http://") && !e.startsWith("https://"))
15
+ throw new Error(`Invalid URL format: ${e}`);
16
+ try {
17
+ new URL(e);
18
+ } catch {
19
+ throw new Error(`Invalid URL: ${e}`);
20
+ }
21
+ const i = `${e.endsWith("/") ? e : `${e}/`}index.js`;
22
+ try {
23
+ if (!(await fetch(i, { method: "HEAD" })).ok)
24
+ throw new Error(`Module not found at ${i}`);
25
+ } catch {
26
+ }
27
+ const f = await import(
28
+ /* @vite-ignore */
29
+ /* webpackIgnore: true */
30
+ i
31
+ );
32
+ if (typeof f.useChartStore != "function")
33
+ throw new Error("useChartStore is not a function");
34
+ s(() => f.useChartStore), t(null);
35
+ } catch (n) {
36
+ const i = n instanceof Error ? n.message : "Unknown error";
37
+ console.error("Failed to load remote chart store:", i), t(i), s(null);
38
+ }
39
+ })();
40
+ }, [e, o]), a;
41
+ }
42
+ function le(e, a) {
43
+ if (e.length === 0)
44
+ return "";
45
+ const s = e.find(
46
+ (r) => {
47
+ var t, o;
48
+ return ((t = r.customCardPreferences) == null ? void 0 : t.visualType) === "multiple" || !!((o = r.customCardPreferences) != null && o.dataInputCardIds);
49
+ }
50
+ );
51
+ if (s)
52
+ return s.id;
53
+ if (a) {
54
+ const r = e.find((t) => t.id === a);
55
+ if (r) {
56
+ const t = r.tabTitle;
57
+ if (t == "All__Header")
58
+ return e[0].id;
59
+ if (t && t.endsWith("__Header")) {
60
+ const l = t.split("__")[0], n = e.find(
61
+ (i) => i.tabTitle === l
62
+ );
63
+ return n ? n.id : e[0].id;
64
+ }
65
+ return a;
66
+ }
67
+ }
68
+ return e[0].id;
69
+ }
70
+ const M = /* @__PURE__ */ new Set();
71
+ function Se(e) {
72
+ return M.add(e), () => {
73
+ M.delete(e);
74
+ };
75
+ }
76
+ function ue() {
77
+ M.forEach((e) => {
78
+ e();
79
+ });
80
+ }
81
+ const fe = (e) => {
82
+ if (!e || !("detailTableBackup" in e))
83
+ return e;
84
+ const { detailTableBackup: a, ...s } = e;
85
+ return s;
86
+ };
87
+ async function Q(e, a, s, r) {
88
+ if (!a || !s)
89
+ throw new Error("Missing auth token or visual ID");
90
+ const t = ["resource-by-id", "visual", s], o = r.getQueryData(t);
91
+ if (o)
92
+ return console.log("Using cached visual data for:", s), { data: o, fromCache: !0 };
93
+ console.log("Fetching visual data from network for:", s);
94
+ const l = v.loading("Loading visual...", {
95
+ position: "top-center"
96
+ });
97
+ try {
98
+ const n = await fetch(
99
+ `${e}/management/v1/visuals/${s}`,
100
+ {
101
+ headers: {
102
+ Authorization: `Bearer ${a}`
103
+ }
104
+ }
105
+ );
106
+ if (!n.ok)
107
+ throw new Error("Failed to load visual");
108
+ const i = await n.json();
109
+ return r.setQueryData(t, i), v.dismiss(l), { data: i, fromCache: !1 };
110
+ } catch (n) {
111
+ throw v.dismiss(l), n;
112
+ }
113
+ }
114
+ function z(e) {
115
+ if (typeof e == "string")
116
+ return JSON.parse(e);
117
+ if (typeof e == "object")
118
+ return e;
119
+ throw new Error("Invalid frame object format");
120
+ }
121
+ function he(e, a) {
122
+ var o, l;
123
+ const s = (e == null ? void 0 : e.frameObject) ?? ((o = e == null ? void 0 : e.visual) == null ? void 0 : o.frameObject);
124
+ if (!s)
125
+ return !1;
126
+ const r = z(s);
127
+ if (!(r != null && r.cards) || r.cards.length === 0)
128
+ return !1;
129
+ const t = (l = r.cards) == null ? void 0 : l.find(
130
+ (n) => n.id === r.activeCardId
131
+ );
132
+ return t ? (ne({
133
+ ...a,
134
+ frame: r,
135
+ card: t,
136
+ visualId: (e == null ? void 0 : e.id) || r.visualId
137
+ }), !0) : !1;
138
+ }
139
+ function me() {
140
+ const e = B(
141
+ (r) => {
142
+ var t;
143
+ return ((t = r.card.customCardPreferences) == null ? void 0 : t.url) || "";
144
+ }
145
+ ), a = de(e);
146
+ return { getUpdatedFrame: A(() => {
147
+ var p;
148
+ ue();
149
+ const {
150
+ frame: r,
151
+ card: t,
152
+ isDevMode: o,
153
+ isShowingVisual: l,
154
+ selectedSchemaName: n,
155
+ selectedDatamodelId: i,
156
+ selectedDatabaseName: f,
157
+ selectedTableName: h,
158
+ selectedConnectionId: F
159
+ } = B.getState(), y = t.sql, C = (p = a == null ? void 0 : a.getState()) == null ? void 0 : p.settings, I = ie(t, {
160
+ isDevMode: o,
161
+ cardSql: y,
162
+ isShowingVisual: l,
163
+ selectedSchemaName: n,
164
+ selectedDatamodelId: i,
165
+ selectedDatabaseName: f,
166
+ selectedTableName: h,
167
+ selectedConnectionId: F,
168
+ remoteChartSettings: C,
169
+ stripConfig: fe
170
+ }), m = r.cards.map(
171
+ (g) => g.id === t.id ? I : g
172
+ );
173
+ return {
174
+ ...r,
175
+ cards: m,
176
+ activeCardId: le(m, r.activeCardId)
177
+ };
178
+ }, [a]) };
179
+ }
180
+ function Ee() {
181
+ const { authToken: e, tokenProps: a } = Y(), s = X(), r = Z(), t = ee(), { selectVisual: o } = te(), {
182
+ setFrame: l,
183
+ setCard: n,
184
+ setIsDevMode: i,
185
+ initializeModeDrafts: f,
186
+ setActiveTabCardId: h,
187
+ updateDataSource: F,
188
+ setQueryResultColumns: y,
189
+ setSelectedConnectionId: C,
190
+ setSelectedDatabaseName: I,
191
+ setSelectedSchemaName: m,
192
+ setSelectedTableName: p,
193
+ setSelectedDatamodelId: g,
194
+ setFilterValues: P,
195
+ setInlineFilterValuesMap: T,
196
+ setApplyFilters: D
197
+ } = re(), {
198
+ setIsDashboardEditing: U,
199
+ setIsVisualEditing: L,
200
+ setSelectedFrameId: N,
201
+ clearSelectedFrameId: W,
202
+ setIsDashboardPanelOpen: j
203
+ } = se(), S = b((c) => c.selectedSheetId), k = b((c) => c.selectedFrameId), $ = b((c) => c.dashboard), O = b((c) => c.filterValues), R = b(
204
+ (c) => c.inlineFilterValuesMap
205
+ ), E = ae((t == null ? void 0 : t.id) || "", {
206
+ enabled: !!(t != null && t.id) && !!(e != null && e.accessToken)
207
+ }), q = A(
208
+ async (c) => {
209
+ try {
210
+ o(c), W();
211
+ const { data: u, fromCache: V } = await Q(
212
+ a.apiServiceUrl,
213
+ (e == null ? void 0 : e.accessToken) || "",
214
+ c.id,
215
+ s
216
+ );
217
+ if (!he(u, {
218
+ setFrame: l,
219
+ setCard: n,
220
+ setIsDevMode: i,
221
+ initializeModeDrafts: f,
222
+ setActiveTabCardId: h,
223
+ updateDataSource: F,
224
+ setQueryResultColumns: y,
225
+ setSelectedConnectionId: C,
226
+ setSelectedDatabaseName: I,
227
+ setSelectedSchemaName: m,
228
+ setSelectedTableName: p,
229
+ setSelectedDatamodelId: g,
230
+ setFilterValues: P,
231
+ setInlineFilterValuesMap: T,
232
+ setApplyFilters: D,
233
+ setIsDashboardEditing: U,
234
+ setIsVisualEditing: L,
235
+ dashboard: $,
236
+ selectedSheetId: S,
237
+ selectedFrameId: k,
238
+ filterValues: O,
239
+ inlineFilterValuesMap: R
240
+ }))
241
+ throw new Error("Failed to setup editor with visual data");
242
+ return { success: !0, fromCache: V };
243
+ } catch (u) {
244
+ return console.error("Error editing visual:", u), { success: !1, error: "Failed to load visual for editing" };
245
+ }
246
+ },
247
+ [
248
+ e == null ? void 0 : e.accessToken,
249
+ a.apiServiceUrl,
250
+ s,
251
+ o,
252
+ l,
253
+ n,
254
+ U,
255
+ L,
256
+ i,
257
+ f,
258
+ h,
259
+ F,
260
+ y,
261
+ C,
262
+ I,
263
+ m,
264
+ p,
265
+ g,
266
+ P,
267
+ T,
268
+ D,
269
+ W,
270
+ $,
271
+ S,
272
+ k,
273
+ O,
274
+ R
275
+ ]
276
+ ), J = A(
277
+ async (c) => {
278
+ var V;
279
+ const u = (d) => (v.error(d), { success: !1, error: d });
280
+ try {
281
+ if (o(c), !S)
282
+ return u("No sheet selected. Please select a sheet first.");
283
+ const { data: d, fromCache: K } = await Q(
284
+ a.apiServiceUrl,
285
+ (e == null ? void 0 : e.accessToken) || "",
286
+ c.id,
287
+ s
288
+ ), _ = (d == null ? void 0 : d.frameObject) ?? ((V = d == null ? void 0 : d.visual) == null ? void 0 : V.frameObject);
289
+ if (!_)
290
+ return u("Visual has no frame data");
291
+ const w = z(_);
292
+ if (!(w != null && w.cards) || w.cards.length === 0)
293
+ return u("Visual frame is malformed");
294
+ const x = {
295
+ ...oe(w),
296
+ visualId: c.id
297
+ // Link this frame to the library visual
298
+ };
299
+ return await r(
300
+ S,
301
+ x,
302
+ "end"
303
+ ), U(!0), N(x.id), j(!1), { success: !0, fromCache: K };
304
+ } catch (d) {
305
+ return console.error("Error adding visual:", d), u(
306
+ d instanceof Error ? d.message : "Failed to add visual to dashboard"
307
+ );
308
+ }
309
+ },
310
+ [
311
+ e == null ? void 0 : e.accessToken,
312
+ a.apiServiceUrl,
313
+ s,
314
+ o,
315
+ S,
316
+ U,
317
+ N,
318
+ j,
319
+ r
320
+ ]
321
+ );
322
+ return {
323
+ visual: E.data,
324
+ isLoading: E.isLoading,
325
+ isError: E.isError,
326
+ error: E.error,
327
+ handleEditLibraryVisual: q,
328
+ handleAddLibraryVisual: J,
329
+ getUpdatedFrame: me().getUpdatedFrame,
330
+ refetch: E.refetch
331
+ };
332
+ }
333
+ export {
334
+ ue as f,
335
+ Se as r,
336
+ Ee as u
337
+ };
@@ -0,0 +1 @@
1
+ "use strict";const a=require("./index-BlspGR07.js"),p=require("react");function G(e){const[o,s]=p.useState(null),[r,t]=p.useState(null),n=a.useEnsureReactGlobals();return p.useEffect(()=>{if(!e||e.trim()===""){s(null),t(null);return}if(!n)return;(async()=>{try{if(!e.startsWith("http://")&&!e.startsWith("https://"))throw new Error(`Invalid URL format: ${e}`);try{new URL(e)}catch{throw new Error(`Invalid URL: ${e}`)}const c=`${e.endsWith("/")?e:`${e}/`}index.js`;try{if(!(await fetch(c,{method:"HEAD"})).ok)throw new Error(`Module not found at ${c}`)}catch{}const h=await import(c);if(typeof h.useChartStore!="function")throw new Error("useChartStore is not a function");s(()=>h.useChartStore),t(null)}catch(i){const c=i instanceof Error?i.message:"Unknown error";console.error("Failed to load remote chart store:",c),t(c),s(null)}})()},[e,n]),o}function J(e,o){if(e.length===0)return"";const s=e.find(r=>{var t,n;return((t=r.customCardPreferences)==null?void 0:t.visualType)==="multiple"||!!((n=r.customCardPreferences)!=null&&n.dataInputCardIds)});if(s)return s.id;if(o){const r=e.find(t=>t.id===o);if(r){const t=r.tabTitle;if(t=="All__Header")return e[0].id;if(t&&t.endsWith("__Header")){const u=t.split("__")[0],i=e.find(c=>c.tabTitle===u);return i?i.id:e[0].id}return o}}return e[0].id}const D=new Set;function K(e){return D.add(e),()=>{D.delete(e)}}function B(){D.forEach(e=>{e()})}const X=e=>{if(!e||!("detailTableBackup"in e))return e;const{detailTableBackup:o,...s}=e;return s};async function x(e,o,s,r){if(!o||!s)throw new Error("Missing auth token or visual ID");const t=["resource-by-id","visual",s],n=r.getQueryData(t);if(n)return console.log("Using cached visual data for:",s),{data:n,fromCache:!0};console.log("Fetching visual data from network for:",s);const u=a.ue.loading("Loading visual...",{position:"top-center"});try{const i=await fetch(`${e}/management/v1/visuals/${s}`,{headers:{Authorization:`Bearer ${o}`}});if(!i.ok)throw new Error("Failed to load visual");const c=await i.json();return r.setQueryData(t,c),a.ue.dismiss(u),{data:c,fromCache:!1}}catch(i){throw a.ue.dismiss(u),i}}function q(e){if(typeof e=="string")return JSON.parse(e);if(typeof e=="object")return e;throw new Error("Invalid frame object format")}function Y(e,o){var n,u;const s=(e==null?void 0:e.frameObject)??((n=e==null?void 0:e.visual)==null?void 0:n.frameObject);if(!s)return!1;const r=q(s);if(!(r!=null&&r.cards)||r.cards.length===0)return!1;const t=(u=r.cards)==null?void 0:u.find(i=>i.id===r.activeCardId);return t?(a.setupEditorWithCard({...o,frame:r,card:t,visualId:(e==null?void 0:e.id)||r.visualId}),!0):!1}function Z(){const e=a.useEditorStore(r=>{var t;return((t=r.card.customCardPreferences)==null?void 0:t.url)||""}),o=G(e);return{getUpdatedFrame:p.useCallback(()=>{var g;B();const{frame:r,card:t,isDevMode:n,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C}=a.useEditorStore.getState(),y=t.sql,I=(g=o==null?void 0:o.getState())==null?void 0:g.settings,U=a.buildSavedEditorCard(t,{isDevMode:n,cardSql:y,isShowingVisual:u,selectedSchemaName:i,selectedDatamodelId:c,selectedDatabaseName:h,selectedTableName:m,selectedConnectionId:C,remoteChartSettings:I,stripConfig:X}),S=r.cards.map(b=>b.id===t.id?U:b);return{...r,cards:S,activeCardId:J(S,r.activeCardId)}},[o])}}function ee(){const{authToken:e,tokenProps:o}=a.useSemaphorContext(),s=a.useQueryClient(),r=a.useAddFrameWithFreshSemanticExecutionPayload(),t=a.useSelectedVisual(),{selectVisual:n}=a.useManagementActions(),{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M}=a.useEditorActions(),{setIsDashboardEditing:V,setIsVisualEditing:k,setSelectedFrameId:L,clearSelectedFrameId:T,setIsDashboardPanelOpen:j}=a.useDashboardActions(),E=a.useDashboardStore(d=>d.selectedSheetId),N=a.useDashboardStore(d=>d.selectedFrameId),R=a.useDashboardStore(d=>d.dashboard),W=a.useDashboardStore(d=>d.filterValues),$=a.useDashboardStore(d=>d.inlineFilterValuesMap),w=a.useVisualById((t==null?void 0:t.id)||"",{enabled:!!(t!=null&&t.id)&&!!(e!=null&&e.accessToken)}),z=p.useCallback(async d=>{try{n(d),T();const{data:f,fromCache:v}=await x(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s);if(!Y(f,{setFrame:u,setCard:i,setIsDevMode:c,initializeModeDrafts:h,setActiveTabCardId:m,updateDataSource:C,setQueryResultColumns:y,setSelectedConnectionId:I,setSelectedDatabaseName:U,setSelectedSchemaName:S,setSelectedTableName:g,setSelectedDatamodelId:b,setFilterValues:A,setInlineFilterValuesMap:P,setApplyFilters:M,setIsDashboardEditing:V,setIsVisualEditing:k,dashboard:R,selectedSheetId:E,selectedFrameId:N,filterValues:W,inlineFilterValuesMap:$}))throw new Error("Failed to setup editor with visual data");return{success:!0,fromCache:v}}catch(f){return console.error("Error editing visual:",f),{success:!1,error:"Failed to load visual for editing"}}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,u,i,V,k,c,h,m,C,y,I,U,S,g,b,A,P,M,T,R,E,N,W,$]),H=p.useCallback(async d=>{var v;const f=l=>(a.ue.error(l),{success:!1,error:l});try{if(n(d),!E)return f("No sheet selected. Please select a sheet first.");const{data:l,fromCache:Q}=await x(o.apiServiceUrl,(e==null?void 0:e.accessToken)||"",d.id,s),O=(l==null?void 0:l.frameObject)??((v=l==null?void 0:l.visual)==null?void 0:v.frameObject);if(!O)return f("Visual has no frame data");const F=q(O);if(!(F!=null&&F.cards)||F.cards.length===0)return f("Visual frame is malformed");const _={...a.cloneLinkedFrameWithSourceMapping(F),visualId:d.id};return await r(E,_,"end"),V(!0),L(_.id),j(!1),{success:!0,fromCache:Q}}catch(l){return console.error("Error adding visual:",l),f(l instanceof Error?l.message:"Failed to add visual to dashboard")}},[e==null?void 0:e.accessToken,o.apiServiceUrl,s,n,E,V,L,j,r]);return{visual:w.data,isLoading:w.isLoading,isError:w.isError,error:w.error,handleEditLibraryVisual:z,handleAddLibraryVisual:H,getUpdatedFrame:Z().getUpdatedFrame,refetch:w.refetch}}exports.flushPendingEditorDrafts=B;exports.registerPendingEditorDraftFlusher=K;exports.useVisualUtils=ee;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-K25f5Rqr.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("../chunks/index-BlspGR07.js"),e=require("../types/index.cjs");exports.Dashboard=r.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
@@ -1,4 +1,4 @@
1
- import { D as E } from "../chunks/index-9z-jMqN8.js";
1
+ import { D as E } from "../chunks/index-DerPpfv0.js";
2
2
  import { CONTROL_CARD_DEFAULT_VALUE as L, EMPTY_SELECTION as T } from "../types/index.js";
3
3
  export {
4
4
  L as CONTROL_CARD_DEFAULT_VALUE,
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-K25f5Rqr.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-CXqaN_zj.js"),t=require("react/jsx-runtime"),x=require("react"),O=require("./chunks/resource-management-panel-os6AuEKT.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const A=require("./chunks/dashboard-filter-controls-button-B19UWmsK.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(x);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=x.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),u=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var m;return(m=i==null?void 0:i.cards)==null?void 0:m.find(f=>(f==null?void 0:f.id)===s)});return{card:u,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:u,className:a,icon:i,showNone:m=!1}){const f=R.useRef(null),[D,C]=R.useState(!1),[b,j]=R.useState("100%"),y=m?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var h;return l?"Loading...":c?"Error":n?(h=r==null?void 0:r.find(S=>S.id===n))==null?void 0:h.name:`Select ${s}`}function T(h,S){o(S),C(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:C,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:u,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(h=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:h.name,onSelect:S=>T(S,h.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===h.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:h.name,children:h.name})]})},h.id))})]})]})})]})}function H({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=x.useState(!1),l=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(u=>{var a;return(a=u.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function $(s,r){x.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function G(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function K({alertId:s,onBack:r}){var h,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:u}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,m]=x.useState([]),[f,D]=x.useState([]),[C,b]=x.useState(null),j=x.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=C&&N.some(B=>B.id===C)?C:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,C,o]),y=x.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??C;if(!p||!g||!s||!v){m([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();m(Array.isArray(N.attempts)?N.attempts:[])}else m([])}catch{m([])}},[s,n,C,o]),I=x.useCallback(async()=>{await u();const d=await j();await y(d)},[y,j,u]);x.useEffect(()=>{j().catch(()=>{})},[j]),x.useEffect(()=>{y().catch(()=>{})},[y]);const T=x.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:G(a)}),((h=a.alertState)==null?void 0:h.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===C?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function Y(){var c,u;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((u=r.data)==null?void 0:u.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",m=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(m==null?void 0:m.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=A.AdvancedModeToggle;exports.DashboardControlsSettings=A.DashboardControlsSettings;exports.DashboardFilterControlsButton=A.DashboardFilterControlsButton;exports.ExportNotificationItem=A.ExportNotificationItem;exports.ExportNotificationList=A.ExportNotificationList;exports.NotificationBell=A.NotificationBell;exports.UnsavedChangesAlert=A.UnsavedChangesAlert;exports.VisualEditingControls=A.VisualEditingControls;exports.useExportPolling=A.useExportPolling;exports.useExportRecovery=A.useExportRecovery;exports.usePristineSnapshotInitializer=A.usePristineSnapshotInitializer;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=K;exports.Combobox=W;exports.ScheduleDashboard=H;exports.TenantQuotaPage=Y;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=$;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BlspGR07.js"),_=require("./types/index.cjs"),M=require("./chunks/dashboard-summary-settings-dialog-BsmKiGud.js"),t=require("react/jsx-runtime"),u=require("react"),O=require("./chunks/resource-management-panel-epydPwyM.js"),U=require("./chunks/use-debounced-dirty-check-XHSwAefL.js");require("react-dom");const C=require("./chunks/dashboard-filter-controls-button-BIYT1ucX.js"),L=require("./chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js");function z(s){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const o=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(r,n,o.get?o:{enumerable:!0,get:()=>s[n]})}}return r.default=s,Object.freeze(r)}const R=z(u);function Q(s){const{authToken:r,tokenProps:n}=e.useSemaphorContext();return e.useMutation({mutationFn:async o=>e.backtestAlert(n.apiServiceUrl,r.accessToken,s,o)})}function q(s){const{displayPreferences:r,cardId:n,...o}=s,l={...o,id:s.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsxs(e.SemaphorContextProvider,{dashboardProps:l,children:[t.jsx(e.SemaphorReadyIndicator,{componentType:"visual",componentId:s.cardId}),t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:r,children:t.jsx(e.Container,{type:"visual",cardId:n,...l,children:t.jsx(V,{cardId:n})})})})]})})}function V({cardId:s}){const r=e.useDashboardStore(l=>{var c;return(c=l.dashboard)==null?void 0:c.sheets}),{card:n,frame:o}=u.useMemo(()=>{const l=r==null?void 0:r.flatMap(i=>i.frames),c=l==null?void 0:l.flatMap(i=>i==null?void 0:i.cards),m=c==null?void 0:c.find(i=>(i==null?void 0:i.id)===s),a=l==null?void 0:l.find(i=>{var h;return(h=i==null?void 0:i.cards)==null?void 0:h.find(f=>(f==null?void 0:f.id)===s)});return{card:m,frame:a}},[r,s]);return!n||!o?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${s}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:l,resetErrorBoundary:c})=>t.jsx(e.FallbackVisual,{error:l,resetErrorBoundary:c,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:n,frame:o})})})}function W(s,r,n,o){u.useEffect(()=>{s&&!n&&r&&o(e.cloneDeep(r))},[s,n,r,o])}function H({name:s,items:r,value:n,onChange:o,isLoading:l,isError:c,refetch:m,className:a,icon:i,showNone:h=!1}){const f=R.useRef(null),[D,A]=R.useState(!1),[b,j]=R.useState("100%"),y=h?[...r||[],{id:"none",name:"None"}]:r;R.useLayoutEffect(()=>{f.current&&j(f.current.offsetWidth)},[]);function I(){var x;return l?"Loading...":c?"Error":n?(x=r==null?void 0:r.find(S=>S.id===n))==null?void 0:x.name:`Select ${s}`}function T(x,S){o(S),A(!1)}return t.jsxs(e.Popover,{open:D,onOpenChange:A,children:[t.jsx(e.PopoverTrigger,{asChild:!0,children:t.jsxs(e.Button,{ref:f,variant:"outline",role:"combobox","aria-expanded":D,className:e.cn("flex h-9 w-full justify-between",a),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[i&&t.jsx("div",{className:"mr-2",children:i}),t.jsx("span",{className:"max-w-[150px] overflow-hidden truncate text-ellipsis whitespace-nowrap",children:I()})]}),t.jsx(e.ChevronDown,{className:"size-4 opacity-50"})]})}),t.jsx(e.PopoverContent,{className:"w-full p-0",style:{minWidth:b},children:t.jsxs(e.Command,{children:[t.jsxs("div",{className:"flex h-9 items-center justify-between border-b pr-1",children:[t.jsx(e.CommandInput,{className:"h-9",placeholder:"Search..."}),t.jsx(e.IconButton,{className:"h-7",onClick:m,children:t.jsx(e.RefreshCw,{className:e.cn("size-3.5 opacity-50",l&&"animate-spin")})})]}),t.jsxs(e.CommandList,{children:[t.jsxs(e.CommandEmpty,{children:["No ",s==null?void 0:s.toLowerCase()," found."]}),t.jsx(e.CommandGroup,{children:y==null?void 0:y.map(x=>t.jsx(e.CommandItem,{className:"overflow-x-auto",value:x.name,onSelect:S=>T(S,x.id),children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(e.Check,{className:e.cn("size-4",n===x.id?"opacity-100":"opacity-0")}),t.jsx("div",{title:x.name,children:x.name})]})},x.id))})]})]})})]})}function $({triggerButtonClassName:s,variant:r="ghost"}){const[n,o]=u.useState(!1),l=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.id}),c=e.useDashboardStore(m=>{var a;return(a=m.dashboard)==null?void 0:a.title});return l?t.jsxs(t.Fragment,{children:[t.jsx(e.IconButton,{tooltip:"Schedule Dashboard",className:e.cn("h-7 p-2",s),buttonProps:{variant:r},onClick:()=>o(!0),children:t.jsx(e.Clock,{className:"size-4"})}),t.jsx(e.EmailScheduleDialog,{open:n,onOpenChange:o,dashboardId:l,dashboardName:c})]}):null}function G(s,r){u.useEffect(()=>(s&&r&&(window.__SEMAPHOR_PRINT_STATE__={...r}),()=>{s&&window.__SEMAPHOR_PRINT_STATE__&&delete window.__SEMAPHOR_PRINT_STATE__}),[s,r])}function P(s){if(!s)return"--";const r=new Date(s);return Number.isNaN(r.getTime())?"--":r.toLocaleString()}function K(s){var r;return((r=s.alertState)==null?void 0:r.currentState)==="FIRING"?"Signal surfaced":s.status==="ACTIVE"?"Watching":s.status==="PAUSED"?"Paused":s.status}function Y({alertId:s,onBack:r}){var x,S,F,w;const{authToken:n,tokenProps:o}=e.useSemaphorContext(),{data:l,isLoading:c,refetch:m}=e.useAlertDetail(s),a=(l==null?void 0:l.alert)??null,[i,h]=u.useState([]),[f,D]=u.useState([]),[A,b]=u.useState(null),j=u.useCallback(async()=>{var g;const d=o==null?void 0:o.apiServiceUrl,p=n==null?void 0:n.accessToken;if(!d||!p||!s)return null;try{const v=await fetch(`${d}/v1/alerts/${s}/runs?limit=20`,{headers:{Authorization:`Bearer ${p}`}});if(v.ok){const E=await v.json(),N=Array.isArray(E.runs)?E.runs:[],k=A&&N.some(B=>B.id===A)?A:((g=N[0])==null?void 0:g.id)??null;return D(N),b(k),k}D([]),b(null)}catch{return D([]),b(null),null}return null},[s,n,A,o]),y=u.useCallback(async d=>{const p=o==null?void 0:o.apiServiceUrl,g=n==null?void 0:n.accessToken,v=d??A;if(!p||!g||!s||!v){h([]);return}try{const E=await fetch(`${p}/v1/alerts/${s}/runs/${v}/deliveries`,{headers:{Authorization:`Bearer ${g}`}});if(E.ok){const N=await E.json();h(Array.isArray(N.attempts)?N.attempts:[])}else h([])}catch{h([])}},[s,n,A,o]),I=u.useCallback(async()=>{await m();const d=await j();await y(d)},[y,j,m]);u.useEffect(()=>{j().catch(()=>{})},[j]),u.useEffect(()=>{y().catch(()=>{})},[y]);const T=u.useMemo(()=>{const d={};for(const p of i)d[p.channel]||(d[p.channel]=[]),d[p.channel].push(p);return d},[i]);return c?t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Loading signal detail..."}):a?t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[r&&t.jsx(e.Button,{variant:"outline",size:"sm",onClick:r,children:"Back"}),t.jsx("h2",{className:"text-lg font-semibold",children:a.name}),t.jsx(e.Badge,{variant:a.status==="ACTIVE"?"default":"secondary",children:K(a)}),((x=a.alertState)==null?void 0:x.currentState)&&t.jsx(e.Badge,{variant:a.alertState.currentState==="FIRING"?"destructive":"outline",children:a.alertState.currentState==="FIRING"?"Signal surfaced":"Stable"})]}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>void I(),children:"Refresh"})]}),a.description&&t.jsx("p",{className:"text-sm text-muted-foreground",children:a.description}),t.jsxs("div",{className:"rounded-md border bg-muted/30 p-4 text-sm",children:[t.jsx("p",{className:"font-medium",children:"What changed"}),t.jsx("p",{className:"mt-1 text-muted-foreground",children:"Review the latest signal activity, then investigate the underlying dashboard context if you need more detail."})]}),t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Signal Watch"}),t.jsxs("div",{className:"grid grid-cols-2 gap-2 text-sm",children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Watching for:"})," ",e.formatSignalCondition(a.jobConfig.operator,a.jobConfig.threshold)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Severity:"})," ",a.jobConfig.severity]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Evaluated:"})," ",P((S=a.alertState)==null?void 0:S.lastEvaluatedAt)]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-muted-foreground",children:"Last Surfaced:"})," ",P((F=a.alertState)==null?void 0:F.lastTriggeredAt)]})]})]}),((w=a.deliveryConfig)==null?void 0:w.channels)&&a.deliveryConfig.channels.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-2",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Where It Surfaces"}),t.jsx("div",{className:"flex flex-wrap gap-2",children:a.deliveryConfig.channels.map(d=>t.jsx(e.Badge,{variant:"outline",children:d},d))})]}),f.length>0&&t.jsxs("div",{className:"rounded-md border bg-background p-4 space-y-3",children:[t.jsx("h3",{className:"text-sm font-semibold",children:"Recent Delivery Activity"}),f.length>1&&t.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(d=>t.jsx(e.Button,{variant:d.id===A?"default":"outline",size:"sm",onClick:()=>b(d.id),children:P(d.scheduledFor)},d.id))}),Object.keys(T).length===0?t.jsx("p",{className:"text-sm text-muted-foreground",children:"No delivery attempts were recorded for this run."}):Object.entries(T).map(([d,p])=>t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"flex items-center gap-2",children:t.jsx(e.Badge,{variant:"secondary",className:"text-xs",children:d})}),t.jsx("div",{className:"overflow-hidden rounded border",children:t.jsxs("table",{className:"w-full text-xs",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Recipient"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Status"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Time"}),t.jsx("th",{className:"px-2 py-1 text-left font-medium",children:"Error"})]})}),t.jsx("tbody",{children:p.map(g=>t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-2 py-1",children:g.recipient}),t.jsx("td",{className:"px-2 py-1",children:t.jsx(e.Badge,{variant:g.status==="SENT"?"default":"destructive",className:"text-[10px]",children:g.status})}),t.jsx("td",{className:"px-2 py-1",children:P(g.createdAt)}),t.jsx("td",{className:"px-2 py-1 text-muted-foreground",children:g.error||"--"})]},g.id))})]})})]},d))]})]}):t.jsx("div",{className:"p-4 text-sm text-muted-foreground",children:"Signal not found."})}function X(){var c,m;const{quotasQuery:s,usageQuery:r}=e.useAlertQuotas(),n=((c=s.data)==null?void 0:c.quotas)||[],o=((m=r.data)==null?void 0:m.usage)||[],l=new Map(o.map(a=>[a.tenantId||"org",a]));return t.jsxs("div",{className:"space-y-4 p-4",children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsx("h2",{className:"text-xl font-semibold",children:"Alert Quotas"}),t.jsx(e.Button,{variant:"outline",size:"sm",onClick:()=>{s.refetch(),r.refetch()},children:"Refresh"})]}),s.isLoading||r.isLoading?t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading quota usage..."}):null,t.jsx("div",{className:"overflow-hidden rounded-lg border",children:t.jsxs("table",{className:"w-full text-sm",children:[t.jsx("thead",{className:"bg-muted/40",children:t.jsxs("tr",{children:[t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Tenant"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Active Alerts"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Active"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Min Cadence"}),t.jsx("th",{className:"px-3 py-2 text-left font-medium",children:"Max Context Sources"})]})}),t.jsx("tbody",{children:n.map(a=>{const i=a.tenantId||"org",h=l.get(i);return t.jsxs("tr",{className:"border-t",children:[t.jsx("td",{className:"px-3 py-2",children:i}),t.jsx("td",{className:"px-3 py-2",children:(h==null?void 0:h.activeAlerts)??0}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxActiveAlerts}),t.jsxs("td",{className:"px-3 py-2",children:[a.policy.minCadenceMinutes," min"]}),t.jsx("td",{className:"px-3 py-2",children:a.policy.maxContextSources})]},i)})})]})})]})}exports.AlertManagementPage=e.AlertManagementPage;exports.AlertWizardDialog=e.AlertWizardDialog;exports.AlertsApiError=e.AlertsApiError;exports.CALCULATED_FIELD_ENTITY_MARKER=e.CALCULATED_FIELD_ENTITY_MARKER;exports.CardAlertIndicator=e.CardAlertIndicator;exports.CardSummary=e.CardSummary;exports.DATE_FORMAT_VALUES=e.DATE_FORMAT_VALUES;exports.Dashboard=e.Dashboard;exports.DashboardExportDialog=e.DashboardExportDialog;exports.DashboardWC=e.DashboardWC;exports.EmailScheduleDialog=e.EmailScheduleDialog;exports.ExportError=e.ExportError;exports.PivotMarkerEnum=e.PivotMarkerEnum;exports.ResourceType=e.ResourceType;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.ShareDialog=e.ShareDialog;exports.SummaryCard=e.SummaryCard;exports.Surfboard=e.DashboardPlus;exports.backtestAlert=e.backtestAlert;exports.cancelExport=e.cancelExport;exports.cloneDeep=e.cloneDeep;exports.createAlert=e.createAlert;exports.createEmptyKpiConfig=e.createEmptyKpiConfig;exports.createExport=e.createExport;exports.createSqlGenConfig=e.createSqlGenConfig;exports.deleteAlert=e.deleteAlert;exports.downloadPdf=e.downloadPdf;exports.emitDashboardLoad=e.emitDashboardLoad;exports.emitDashboardUnload=e.emitDashboardUnload;exports.fmt=e.fmt;exports.formatFileSize=e.formatFileSize;exports.getAlert=e.getAlert;exports.getAlertContextSources=e.getAlertContextSources;exports.getAlertHistory=e.getAlertHistory;exports.getAlertQuotaUsage=e.getAlertQuotaUsage;exports.getAlertRunDeliveries=e.getAlertRunDeliveries;exports.getAlertRunSteps=e.getAlertRunSteps;exports.getAlertRuns=e.getAlertRuns;exports.getAlertState=e.getAlertState;exports.getColumnDataType=e.getColumnDataType;exports.getDownloadUrl=e.getDownloadUrl;exports.getExportStatus=e.getExportStatus;exports.getExports=e.getExports;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isCalculatedDimension=e.isCalculatedDimension;exports.isCalculatedField=e.isCalculatedField;exports.isCalculatedMetric=e.isCalculatedMetric;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isExportComplete=e.isExportComplete;exports.isExportInProgress=e.isExportInProgress;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.listAlertQuotas=e.listAlertQuotas;exports.listAlerts=e.listAlerts;exports.previewAlertDeliverable=e.previewAlertDeliverable;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.triggerAlertNow=e.triggerAlertNow;exports.updateAlert=e.updateAlert;exports.updateAlertContextSources=e.updateAlertContextSources;exports.updateAlertQuota=e.updateAlertQuota;exports.useActiveExports=e.useActiveExports;exports.useAddNewFrame=e.useAddNewFrame;exports.useAlertActions=e.useAlertActions;exports.useAlertDeliveries=e.useAlertDeliveries;exports.useAlertDetail=e.useAlertDetail;exports.useAlertDraft=e.useAlertDraft;exports.useAlertFilters=e.useAlertFilters;exports.useAlertHistory=e.useAlertHistory;exports.useAlertQuotas=e.useAlertQuotas;exports.useAlertRuns=e.useAlertRuns;exports.useAlertState=e.useAlertState;exports.useAlertStore=e.useAlertStore;exports.useAlertWizard=e.useAlertWizard;exports.useAlerts=e.useAlerts;exports.useAlertsBootstrap=e.useAlertsBootstrap;exports.useAlertsById=e.useAlertsById;exports.useAlertsForCard=e.useAlertsForCard;exports.useCard=e.useCard;exports.useCardAlertMap=e.useCardAlertMap;exports.useCardSummary=e.useCardSummary;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardById=e.useDashboardById;exports.useDashboardQuery=e.useDashboardQuery;exports.useDashboardStore=e.useDashboardStore;exports.useDashboardSummary=e.useDashboardSummary;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useExportActions=e.useExportActions;exports.useExportStore=e.useExportStore;exports.useInProgressExportsCount=e.useInProgressExportsCount;exports.useManagementStore=e.useManagementStore;exports.useResourceManagement=e.useResourceManagement;exports.useSelectedAlertId=e.useSelectedAlertId;exports.useTextFilterHook=e.useTextFilterHook;exports.CONTROL_CARD_DEFAULT_VALUE=_.CONTROL_CARD_DEFAULT_VALUE;exports.DEFAULT_CALENDAR_CONTEXT=_.DEFAULT_CALENDAR_CONTEXT;exports.DEFAULT_SEMANTIC_DOMAIN_ACCESS=_.DEFAULT_SEMANTIC_DOMAIN_ACCESS;exports.EMPTY_SELECTION=_.EMPTY_SELECTION;exports.CalendarPreferencesDialog=M.CalendarPreferencesDialog;exports.DashboardSummarySettingsDialog=M.DashboardSummarySettingsDialog;exports.ResourceManagementPanel=O.ResourceManagementPanel;exports.useDebouncedDirtyCheck=U.useDebouncedDirtyCheck;exports.AdvancedModeToggle=C.AdvancedModeToggle;exports.DashboardControlsSettings=C.DashboardControlsSettings;exports.DashboardFilterControlsButton=C.DashboardFilterControlsButton;exports.ExportNotificationItem=C.ExportNotificationItem;exports.ExportNotificationList=C.ExportNotificationList;exports.NotificationBell=C.NotificationBell;exports.UnsavedChangesAlert=C.UnsavedChangesAlert;exports.VisualEditingControls=C.VisualEditingControls;exports.useExportPolling=C.useExportPolling;exports.useExportRecovery=C.useExportRecovery;exports.normalizeDashboardForDirtyCheck=L.normalizeDashboardForDirtyCheck;exports.serializeDashboardForDirtyCheck=L.serializeDashboardForDirtyCheck;exports.AlertDetailPageEmbedded=Y;exports.Combobox=H;exports.ScheduleDashboard=$;exports.TenantQuotaPage=X;exports.Visual=q;exports.useAlertBacktest=Q;exports.useExposePrintState=G;exports.usePristineSnapshotInitializer=W;