react-semaphor 0.1.281 → 0.1.282

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 (33) hide show
  1. package/dist/chunks/{dashboard-controls-D3R8Z79V.js → dashboard-controls-B_F5f_BF.js} +4 -4
  2. package/dist/chunks/{dashboard-controls-CLd_NTpW.js → dashboard-controls-XX9__V-e.js} +1 -1
  3. package/dist/chunks/{dashboard-filter-controls-button-zj4HH2IS.js → dashboard-filter-controls-button-DVLBLHga.js} +60 -60
  4. package/dist/chunks/{dashboard-filter-controls-button-DLjcoN1G.js → dashboard-filter-controls-button-DZpvfXwU.js} +1 -1
  5. package/dist/chunks/{dashboard-json-CPyonfsi.js → dashboard-json-CexNQg-E.js} +1 -1
  6. package/dist/chunks/{dashboard-json-BcdeYcFr.js → dashboard-json-Dd9Q2bZm.js} +1 -1
  7. package/dist/chunks/{dashboard-summary-settings-dialog-Cpb9FCXf.js → dashboard-summary-settings-dialog-BjdrHb1l.js} +1 -1
  8. package/dist/chunks/{dashboard-summary-settings-dialog-BYQfaQGZ.js → dashboard-summary-settings-dialog-zdacBYZZ.js} +1 -1
  9. package/dist/chunks/{edit-dashboard-visual-NyBBQhsY.js → edit-dashboard-visual-Bi9pQx6G.js} +1 -1
  10. package/dist/chunks/{edit-dashboard-visual-CsTmOttj.js → edit-dashboard-visual-DQts3aun.js} +2 -2
  11. package/dist/chunks/{index-DvAOngur.js → index-BY0YEY92.js} +223 -223
  12. package/dist/chunks/{index-CsX3UmQg.js → index-Bgn4zTsp.js} +25445 -24528
  13. package/dist/chunks/{resource-management-panel-BxJ99bHx.js → resource-management-panel--xIMLPdz.js} +2 -2
  14. package/dist/chunks/{resource-management-panel-lglhpWpc.js → resource-management-panel-w7afzaPB.js} +1 -1
  15. package/dist/chunks/use-create-flow-overlay-state-AsQy4tbh.js +21 -0
  16. package/dist/chunks/use-create-flow-overlay-state-COsIHnQp.js +1523 -0
  17. package/dist/chunks/{use-visual-utils-C7wVd3rs.js → use-visual-utils-BCWNcaWk.js} +1 -1
  18. package/dist/chunks/{use-visual-utils-C54WwvId.js → use-visual-utils-CI-7TNJI.js} +1 -1
  19. package/dist/dashboard/index.cjs +1 -1
  20. package/dist/dashboard/index.js +1 -1
  21. package/dist/index.cjs +1 -1
  22. package/dist/index.js +5 -5
  23. package/dist/style.css +1 -1
  24. package/dist/surfboard/index.cjs +1 -1
  25. package/dist/surfboard/index.js +2 -2
  26. package/dist/types/dashboard.d.ts +9 -1
  27. package/dist/types/main.d.ts +9 -1
  28. package/dist/types/shared.d.ts +9 -1
  29. package/dist/types/surfboard.d.ts +9 -1
  30. package/dist/types/types.d.ts +9 -1
  31. package/package.json +1 -1
  32. package/dist/chunks/use-create-flow-overlay-state-BjV5Q6Lb.js +0 -1443
  33. package/dist/chunks/use-create-flow-overlay-state-BrmQZdh2.js +0 -21
@@ -0,0 +1,1523 @@
1
+ import { bM as ne, U as F, bN as Ye, bO as pt, bP as ft, bQ as ht, bR as bt, bS as yt, u as Ve, af as vt, bT as gt, bU as Ct, bV as xt, ac as se, c as _, bW as kt, bX as Nt, B as T, s as St, H as ie, N as Xe, J as Ge, bY as Pe, w as We, M as Se, bZ as Je, X as Ze, x as O, b_ as Dt, b$ as wt, c0 as ae, c1 as Oe, c2 as ze, c3 as he, c4 as be, c5 as Vt, c6 as Be, c7 as It, c8 as Tt, c9 as le, ca as qt, cb as Qe, cc as Ft, a6 as Ue, cd as je, ce as Ie, cf as et, cg as tt, ch as Et, L as H, I as at, y as ye, z as ve, A as ge, E as Ce, F as xe, ci as lt, cj as Lt, ck as At, cl as st, cm as rt, cn as _t, co as Mt, cp as Ot, cq as zt, cr as Bt, cs as Qt, ct as Ut, cu as jt, cv as ke, cw as Re, cx as Rt, cy as $e, cz as $t, cA as Kt, cB as Ht } from "./index-Bgn4zTsp.js";
2
+ import { jsx as t, jsxs as c, Fragment as Z } from "react/jsx-runtime";
3
+ import { useMemo as L, useState as j, useRef as Ne, useCallback as M, useEffect as De, Fragment as Yt } from "react";
4
+ import { u as Te } from "./use-visual-utils-BCWNcaWk.js";
5
+ /**
6
+ * @license lucide-react v0.453.0 - ISC
7
+ *
8
+ * This source code is licensed under the ISC license.
9
+ * See the LICENSE file in the root directory of this source tree.
10
+ */
11
+ const ra = ne("CircleX", [
12
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
13
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
14
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
15
+ ]);
16
+ /**
17
+ * @license lucide-react v0.453.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */
22
+ const Xt = ne("Library", [
23
+ ["path", { d: "m16 6 4 14", key: "ji33uf" }],
24
+ ["path", { d: "M12 6v14", key: "1n7gus" }],
25
+ ["path", { d: "M8 8v12", key: "1gg7y9" }],
26
+ ["path", { d: "M4 4v16", key: "6qkkli" }]
27
+ ]);
28
+ /**
29
+ * @license lucide-react v0.453.0 - ISC
30
+ *
31
+ * This source code is licensed under the ISC license.
32
+ * See the LICENSE file in the root directory of this source tree.
33
+ */
34
+ const Gt = ne("Link2", [
35
+ ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
36
+ ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
37
+ ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
38
+ ]);
39
+ /**
40
+ * @license lucide-react v0.453.0 - ISC
41
+ *
42
+ * This source code is licensed under the ISC license.
43
+ * See the LICENSE file in the root directory of this source tree.
44
+ */
45
+ const nt = ne("Save", [
46
+ [
47
+ "path",
48
+ {
49
+ d: "M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",
50
+ key: "1c8476"
51
+ }
52
+ ],
53
+ ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
54
+ ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
55
+ ]);
56
+ function it() {
57
+ var h, C;
58
+ const s = F((g) => g.card), l = F((g) => g.frame), n = L(
59
+ () => Ye(l, s),
60
+ [l, s]
61
+ ), { manifest: o } = pt(
62
+ ((h = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : h.url) || ""
63
+ ), m = L(
64
+ () => {
65
+ var g;
66
+ return (g = o == null ? void 0 : o.visuals) == null ? void 0 : g.find(
67
+ (b) => {
68
+ var v;
69
+ return b.name === ((v = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : v.componentName);
70
+ }
71
+ );
72
+ },
73
+ [o, (C = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : C.componentName]
74
+ ), p = ft(n, m), f = L(
75
+ () => ht({
76
+ frame: l,
77
+ configCard: n,
78
+ isMultiInputVisual: p === "multiple"
79
+ }),
80
+ [l, n, p]
81
+ ), y = L(() => {
82
+ const g = f.findIndex(
83
+ (b) => (b == null ? void 0 : b.id) === s.id
84
+ );
85
+ return g < 0 ? -1 : bt(s, g);
86
+ }, [f, s]);
87
+ return L(() => !n || p !== "multiple" || y < 0 ? s.type : yt(
88
+ s,
89
+ y,
90
+ m == null ? void 0 : m.slots
91
+ ) ?? s.type, [n, p, y, s, m == null ? void 0 : m.slots]);
92
+ }
93
+ function na({
94
+ type: s,
95
+ isLinked: l,
96
+ className: n,
97
+ showLabel: o = !1,
98
+ showLocal: m = !1
99
+ }) {
100
+ const p = Ve((w) => w.selectedFrameId), f = vt((w) => w.selectedVisual), y = F((w) => w.frame);
101
+ let h;
102
+ if (s)
103
+ h = s;
104
+ else if (l !== void 0)
105
+ h = l ? "linked" : "library";
106
+ else if (!!!(y != null && y.visualId || f != null && f.id) && p)
107
+ h = "local";
108
+ else if (f && !p)
109
+ h = "library";
110
+ else if (y != null && y.visualId && p)
111
+ h = "linked";
112
+ else if (f != null && f.id && p)
113
+ h = "library";
114
+ else
115
+ return null;
116
+ if (h === "local" && !m)
117
+ return null;
118
+ const C = {
119
+ local: "border-slate-200/70 bg-slate-50/80 text-slate-700 shadow-sm hover:bg-slate-100/80 dark:border-slate-700 dark:bg-slate-900/70 dark:text-slate-200 dark:hover:bg-slate-800/80",
120
+ linked: "border-purple-200/70 bg-gradient-to-r from-purple-50/50 to-purple-100/30 text-purple-900 shadow-sm hover:from-purple-100/60 hover:to-purple-100/50 hover:shadow-md dark:border-purple-800/50 dark:from-purple-950/40 dark:to-purple-900/30 dark:text-purple-100 dark:hover:from-purple-950/60 dark:hover:to-purple-900/50",
121
+ library: "border-blue-200/70 bg-gradient-to-r from-blue-50/50 to-blue-100/30 text-blue-900 shadow-sm hover:from-blue-100/60 hover:to-blue-100/50 hover:shadow-md dark:border-blue-800/50 dark:from-blue-950/40 dark:to-blue-900/30 dark:text-blue-100 dark:hover:from-blue-950/60 dark:hover:to-blue-900/50"
122
+ }, g = {
123
+ local: "Local to this dashboard: Changes made here only affect this dashboard copy.",
124
+ linked: "Linked to library: Changes made here update the library visual and all linked instances.",
125
+ library: "Library visual: Share and reuse this visual across multiple dashboards."
126
+ }, b = {
127
+ local: "border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",
128
+ linked: "border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",
129
+ library: "border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"
130
+ }, v = {
131
+ local: "fill-slate-50 dark:fill-slate-900",
132
+ linked: "fill-purple-50 dark:fill-purple-950",
133
+ library: "fill-blue-50 dark:fill-blue-950"
134
+ }, k = {
135
+ local: /* @__PURE__ */ t("span", { className: "h-2 w-2 rounded-full bg-current/70" }),
136
+ linked: /* @__PURE__ */ t(Gt, { className: "h-3.5 w-3.5" }),
137
+ library: /* @__PURE__ */ t(Xt, { className: "h-3.5 w-3.5" })
138
+ }, A = {
139
+ local: "Local",
140
+ linked: "Linked",
141
+ library: "Library"
142
+ };
143
+ return /* @__PURE__ */ t(gt, { children: /* @__PURE__ */ c(Ct, { delayDuration: 300, children: [
144
+ /* @__PURE__ */ t(xt, { asChild: !0, children: /* @__PURE__ */ c(
145
+ se,
146
+ {
147
+ variant: "outline",
148
+ className: _(
149
+ "cursor-help select-none transition-all",
150
+ C[h],
151
+ n
152
+ ),
153
+ children: [
154
+ k[h],
155
+ o && /* @__PURE__ */ t("span", { className: "ml-1 text-xs font-medium leading-none", children: A[h] })
156
+ ]
157
+ }
158
+ ) }),
159
+ /* @__PURE__ */ c(
160
+ kt,
161
+ {
162
+ side: "bottom",
163
+ className: _("max-w-xs", b[h]),
164
+ children: [
165
+ /* @__PURE__ */ t(Nt, { className: v[h] }),
166
+ /* @__PURE__ */ t("p", { children: g[h] })
167
+ ]
168
+ }
169
+ )
170
+ ] }) });
171
+ }
172
+ function Pt(s, l) {
173
+ return {
174
+ ...s,
175
+ sql: "",
176
+ python: "",
177
+ config: void 0,
178
+ customCfg: "",
179
+ preferences: {},
180
+ interactionConfig: void 0,
181
+ linkedInteractionTargetOverrides: void 0,
182
+ dynamicCardPreferences: void 0,
183
+ customCardPreferences: l ? s.customCardPreferences : void 0,
184
+ visualizationMode: "builtin",
185
+ type: l ? s.type : "bar"
186
+ };
187
+ }
188
+ function qe(s) {
189
+ const l = Dt(s);
190
+ return l ? (O.error(l), !1) : !0;
191
+ }
192
+ function ia({
193
+ className: s,
194
+ variant: l = "outline"
195
+ }) {
196
+ const n = F((p) => p.onSave), { getUpdatedFrame: o } = Te();
197
+ function m() {
198
+ const p = o();
199
+ qe(p) && (n == null || n(p));
200
+ }
201
+ return /* @__PURE__ */ c(
202
+ T,
203
+ {
204
+ onClick: m,
205
+ className: _("h-8", s),
206
+ size: "sm",
207
+ variant: l,
208
+ children: [
209
+ /* @__PURE__ */ t(St, { className: "mr-2 size-4 font-bold" }),
210
+ "Accept"
211
+ ]
212
+ }
213
+ );
214
+ }
215
+ function da({
216
+ className: s,
217
+ variant: l = "default"
218
+ }) {
219
+ const n = ie(), [o, m] = j(!1), p = Ve(
220
+ (v) => v.actions.setIsDashboardPanelOpen
221
+ ), { setIsVisualEditing: f } = Xe(), { getUpdatedFrame: y } = Te(), h = Ge(), C = F((v) => v.frame), g = Pe();
222
+ return /* @__PURE__ */ c(
223
+ T,
224
+ {
225
+ onClick: () => {
226
+ const v = y();
227
+ if (!qe(v))
228
+ return;
229
+ const k = (C == null ? void 0 : C.visualId) || (h == null ? void 0 : h.id);
230
+ if (!k) {
231
+ O.error("No visual to save");
232
+ return;
233
+ }
234
+ m(!0), g.mutate(
235
+ {
236
+ visualId: k,
237
+ data: {
238
+ frameObject: v
239
+ }
240
+ },
241
+ {
242
+ onSuccess: () => {
243
+ m(!1), p(!0), O.success("Visual updated successfully"), n.invalidateQueries({
244
+ queryKey: ["resource-by-id", "visual", k],
245
+ exact: !0
246
+ });
247
+ },
248
+ onError: () => {
249
+ m(!1), O.error("Failed to update visual");
250
+ }
251
+ }
252
+ );
253
+ },
254
+ className: _("h-8", s),
255
+ size: "sm",
256
+ variant: l,
257
+ children: [
258
+ o && /* @__PURE__ */ c(Z, { children: [
259
+ /* @__PURE__ */ t(We, { className: "mr-2 size-4 animate-spin font-bold" }),
260
+ " Saving"
261
+ ] }),
262
+ !o && /* @__PURE__ */ c(Z, { children: [
263
+ /* @__PURE__ */ t(nt, { className: "mr-2 size-4 font-bold" }),
264
+ "Save to Library"
265
+ ] })
266
+ ]
267
+ }
268
+ );
269
+ }
270
+ function oa({
271
+ className: s
272
+ }) {
273
+ const l = ie(), [n, o] = j(!1), m = Ge(), p = F((v) => v.frame), f = Ve((v) => v.selectedSheetId), { updateFrame: y, setIsVisualEditing: h } = Xe(), { getUpdatedFrame: C } = Te(), g = Pe();
274
+ return /* @__PURE__ */ t(
275
+ T,
276
+ {
277
+ onClick: async () => {
278
+ if (!f) {
279
+ O.error("No sheet selected");
280
+ return;
281
+ }
282
+ const v = (p == null ? void 0 : p.visualId) || (m == null ? void 0 : m.id);
283
+ if (!v) {
284
+ O.error("No visual to update");
285
+ return;
286
+ }
287
+ o(!0);
288
+ try {
289
+ const k = C();
290
+ if (!qe(k)) {
291
+ o(!1);
292
+ return;
293
+ }
294
+ await g.mutateAsync({
295
+ visualId: v,
296
+ data: {
297
+ frameObject: k
298
+ }
299
+ });
300
+ const A = {
301
+ ...k,
302
+ visualId: v
303
+ // Keep the link to library visual
304
+ };
305
+ y(f, A), l.invalidateQueries({ queryKey: ["visuals"] }), l.invalidateQueries({ queryKey: ["visual", v] }), O.success("Saved to library and applied locally"), setTimeout(() => {
306
+ h(!1);
307
+ }, 300);
308
+ } catch (k) {
309
+ console.error("Failed to save and apply:", k), O.error("Failed to save and apply changes");
310
+ } finally {
311
+ o(!1);
312
+ }
313
+ },
314
+ className: _("h-8", s),
315
+ size: "sm",
316
+ variant: "default",
317
+ disabled: n,
318
+ children: n ? /* @__PURE__ */ c(Z, { children: [
319
+ /* @__PURE__ */ t(We, { className: "mr-2 size-4 animate-spin font-bold" }),
320
+ " Saving..."
321
+ ] }) : /* @__PURE__ */ c(Z, { children: [
322
+ /* @__PURE__ */ t(nt, { className: "mr-2 size-4 font-bold" }),
323
+ "Save & Apply"
324
+ ] })
325
+ }
326
+ );
327
+ }
328
+ function ca({ className: s }) {
329
+ const { setTempQueryData: l, setSqlGen: n } = Se(), o = ie(), m = F((b) => b.tempQueryData), p = F((b) => b.onClose), f = F((b) => b.card), y = it(), h = L(() => y !== f.type ? { ...f, type: y } : f, [f, y]), { queryKey: C } = Je(h);
330
+ function g() {
331
+ if (m) {
332
+ const { queryKey: b, queryData: v } = m;
333
+ b && v && o.setQueryData(b, v);
334
+ }
335
+ n({}), p == null || p();
336
+ }
337
+ return /* @__PURE__ */ c(
338
+ T,
339
+ {
340
+ onClick: g,
341
+ className: _("h-8", s),
342
+ size: "sm",
343
+ variant: "outline",
344
+ children: [
345
+ /* @__PURE__ */ t(Ze, { className: "mr-2 size-4" }),
346
+ "Close"
347
+ ]
348
+ }
349
+ );
350
+ }
351
+ function ua({
352
+ label: s = "Clear",
353
+ variant: l = "secondary",
354
+ className: n
355
+ } = {}) {
356
+ const { setTempQueryData: o } = Se(), m = ie(), p = F((a) => a.tempQueryData), f = F((a) => a.card), y = it(), h = L(() => y !== f.type ? { ...f, type: y } : f, [f, y]), { queryKey: C } = Je(h), {
357
+ setCardSql: g,
358
+ setSqlGen: b,
359
+ setCardPython: v,
360
+ setCardCustomCfg: k,
361
+ setCardPreferences: A,
362
+ clearQueryConfig: w,
363
+ setCardConfig: de,
364
+ setCardType: oe,
365
+ setFrame: ee,
366
+ setCard: Y,
367
+ setActiveTabCardId: ce
368
+ } = Se();
369
+ function R() {
370
+ var q, G, B, te;
371
+ const a = m.getQueryData(C);
372
+ p != null && p.queryData || o({
373
+ queryKey: C,
374
+ queryData: a
375
+ }), m.setQueryData(C, null), m.removeQueries({ queryKey: C, exact: !0 }), g(""), b({}), w(), de(void 0), v(""), k(""), A({});
376
+ const N = F.getState().frame, z = F.getState().card, S = Ye(N, z), X = ((q = S == null ? void 0 : S.customCardPreferences) == null ? void 0 : q.visualType) === "multiple" || !!((G = S == null ? void 0 : S.customCardPreferences) != null && G.dataInputCardIds) || (((B = S == null ? void 0 : S.customCardPreferences) == null ? void 0 : B.minInputs) || 0) > 1 || (((te = S == null ? void 0 : S.customCardPreferences) == null ? void 0 : te.maxInputs) || 0) > 1, $ = Pt(z, X);
377
+ ee({
378
+ ...N,
379
+ cards: N.cards.map(
380
+ (P) => P.id === $.id ? $ : P
381
+ )
382
+ }), ce($.id), Y($), X || oe("bar");
383
+ }
384
+ return /* @__PURE__ */ c(
385
+ T,
386
+ {
387
+ onClick: R,
388
+ className: _("h-8", n),
389
+ size: "sm",
390
+ variant: l,
391
+ children: [
392
+ /* @__PURE__ */ t(Ze, { className: "mr-2 size-3.5" }),
393
+ s
394
+ ]
395
+ }
396
+ );
397
+ }
398
+ function dt(s) {
399
+ const { control: l, onChange: n } = s;
400
+ return /* @__PURE__ */ c("div", { className: "space-y-1", children: [
401
+ /* @__PURE__ */ t(H, { className: "text-xs", children: "Label" }),
402
+ /* @__PURE__ */ c("div", { className: "relative", children: [
403
+ /* @__PURE__ */ t(
404
+ at,
405
+ {
406
+ className: "pr-40",
407
+ value: l.label,
408
+ placeholder: "Control label",
409
+ onChange: (o) => n(o.target.value)
410
+ }
411
+ ),
412
+ /* @__PURE__ */ t(
413
+ se,
414
+ {
415
+ variant: "outline",
416
+ className: "pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs",
417
+ children: Ie(l.type).label
418
+ }
419
+ )
420
+ ] })
421
+ ] });
422
+ }
423
+ function Wt(s) {
424
+ const { currentStep: l, labels: n } = s;
425
+ return /* @__PURE__ */ t("div", { className: "sticky top-0 z-10 -mx-1 border-b bg-background/95 px-1 pb-2 pt-1 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: /* @__PURE__ */ t("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3", children: n.map((o, m) => {
426
+ const p = m + 1, f = p === l, y = p < l;
427
+ return /* @__PURE__ */ c(Yt, { children: [
428
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-2", children: [
429
+ /* @__PURE__ */ t(
430
+ "span",
431
+ {
432
+ className: _(
433
+ "flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",
434
+ f ? "border-primary bg-primary text-primary-foreground" : y ? "border-primary/25 bg-primary/10 text-primary" : "border-border bg-muted/30 text-muted-foreground"
435
+ ),
436
+ children: p
437
+ }
438
+ ),
439
+ /* @__PURE__ */ t(
440
+ "span",
441
+ {
442
+ className: _(
443
+ "text-xs font-medium",
444
+ f ? "text-foreground" : "text-muted-foreground"
445
+ ),
446
+ children: o
447
+ }
448
+ )
449
+ ] }),
450
+ m < n.length - 1 ? /* @__PURE__ */ t(
451
+ "span",
452
+ {
453
+ className: "h-px w-5 bg-border/80 sm:w-8",
454
+ "aria-hidden": "true"
455
+ }
456
+ ) : null
457
+ ] }, o);
458
+ }) }) });
459
+ }
460
+ function re(s) {
461
+ const { secondary: l, tertiary: n, primary: o } = s;
462
+ return /* @__PURE__ */ c("div", { className: "sticky bottom-0 z-10 -mx-1 flex justify-end gap-2 border-t bg-background/95 px-1 pb-1 pt-3 backdrop-blur supports-[backdrop-filter]:bg-background/85", children: [
463
+ l,
464
+ n,
465
+ o
466
+ ] });
467
+ }
468
+ function Jt(s) {
469
+ const { control: l, scope: n, detail: o } = s;
470
+ return /* @__PURE__ */ c("div", { className: "flex items-start gap-3 rounded-xl border border-border/40 bg-muted/20 p-3", children: [
471
+ /* @__PURE__ */ t(Kt, { className: "mt-0.5 h-4 w-4 text-emerald-600" }),
472
+ /* @__PURE__ */ c("div", { className: "space-y-1", children: [
473
+ /* @__PURE__ */ t("div", { className: "text-sm font-medium", children: l.label }),
474
+ /* @__PURE__ */ c("div", { className: "text-xs text-muted-foreground", children: [
475
+ Ie(l.type).label,
476
+ " ·",
477
+ " ",
478
+ tt(l),
479
+ " ·",
480
+ " ",
481
+ et(n, l.placement)
482
+ ] }),
483
+ o ? /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: o }) : null
484
+ ] })
485
+ ] });
486
+ }
487
+ function we(s) {
488
+ const { title: l, children: n, className: o } = s;
489
+ return /* @__PURE__ */ c(
490
+ "div",
491
+ {
492
+ className: _(
493
+ "space-y-1 rounded-xl border border-border/40 bg-muted/20 p-3",
494
+ o
495
+ ),
496
+ children: [
497
+ /* @__PURE__ */ t("div", { className: "text-xs font-medium uppercase tracking-wide text-muted-foreground", children: l }),
498
+ n
499
+ ]
500
+ }
501
+ );
502
+ }
503
+ function Zt(s) {
504
+ const { createdReference: l, description: n } = s;
505
+ return /* @__PURE__ */ c(we, { title: "SQL cards", className: "space-y-2", children: [
506
+ /* @__PURE__ */ c("div", { className: "flex items-center justify-between gap-2 rounded-md border border-border/30 bg-muted/40 px-3 py-2", children: [
507
+ /* @__PURE__ */ t("code", { className: "min-w-0 truncate text-xs", children: l }),
508
+ /* @__PURE__ */ t(
509
+ Ht,
510
+ {
511
+ text: l,
512
+ ariaLabel: "Copy SQL control reference"
513
+ }
514
+ )
515
+ ] }),
516
+ /* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: n })
517
+ ] });
518
+ }
519
+ function Ke(s) {
520
+ const {
521
+ control: l,
522
+ defaultValue: n,
523
+ availableFieldChoices: o,
524
+ availableMetricChoices: m,
525
+ previewControlDefinitions: p,
526
+ previewControlValues: f,
527
+ onControlChange: y,
528
+ onLabelChange: h,
529
+ onDefaultValueChange: C,
530
+ onBack: g,
531
+ onNext: b,
532
+ nextDisabled: v
533
+ } = s;
534
+ return /* @__PURE__ */ c("div", { className: "space-y-3", children: [
535
+ /* @__PURE__ */ t(dt, { control: l, onChange: h }),
536
+ /* @__PURE__ */ t(
537
+ st,
538
+ {
539
+ control: l,
540
+ availableFieldChoices: o,
541
+ availableMetricChoices: m,
542
+ previewControlDefinitions: p,
543
+ previewControlValues: f,
544
+ controlLifecycle: "create",
545
+ onChange: y
546
+ }
547
+ ),
548
+ /* @__PURE__ */ t(
549
+ rt,
550
+ {
551
+ control: l,
552
+ value: n,
553
+ onChange: C,
554
+ allowCardDefault: !0,
555
+ hint: "This is the value viewers will see first.",
556
+ previewControlDefinitions: p,
557
+ previewControlValues: f
558
+ }
559
+ ),
560
+ /* @__PURE__ */ t(
561
+ re,
562
+ {
563
+ secondary: /* @__PURE__ */ t(T, { type: "button", variant: "outline", onClick: g, children: "Back" }),
564
+ primary: /* @__PURE__ */ t(T, { type: "button", onClick: b, disabled: v, children: "Next" })
565
+ }
566
+ )
567
+ ] });
568
+ }
569
+ function He(s) {
570
+ const {
571
+ control: l,
572
+ scope: n,
573
+ createdReference: o,
574
+ explorerContent: m,
575
+ sqlDescription: p,
576
+ summaryDetail: f,
577
+ onBack: y,
578
+ onCancel: h,
579
+ onDone: C
580
+ } = s;
581
+ return /* @__PURE__ */ c("div", { className: "space-y-4", children: [
582
+ /* @__PURE__ */ t(
583
+ Jt,
584
+ {
585
+ control: l,
586
+ scope: n,
587
+ detail: f
588
+ }
589
+ ),
590
+ /* @__PURE__ */ c("div", { className: "space-y-2", children: [
591
+ /* @__PURE__ */ t("p", { className: "text-sm font-medium", children: "How cards use this control" }),
592
+ m,
593
+ /* @__PURE__ */ t(
594
+ Zt,
595
+ {
596
+ createdReference: o,
597
+ description: p
598
+ }
599
+ )
600
+ ] }),
601
+ /* @__PURE__ */ t(
602
+ re,
603
+ {
604
+ secondary: /* @__PURE__ */ t(T, { type: "button", variant: "outline", onClick: y, children: "Back" }),
605
+ tertiary: /* @__PURE__ */ t(T, { type: "button", variant: "outline", onClick: h, children: "Cancel" }),
606
+ primary: /* @__PURE__ */ t(T, { type: "button", onClick: C, children: "Done" })
607
+ }
608
+ )
609
+ ] });
610
+ }
611
+ function ea(s) {
612
+ const l = ae(
613
+ s.scope,
614
+ s.existingControls,
615
+ s.reservedIds
616
+ ), n = s.type === l.type ? {
617
+ ...l,
618
+ label: ke[s.type]
619
+ } : {
620
+ ...lt({
621
+ controls: [
622
+ {
623
+ ...l,
624
+ label: ke[s.type]
625
+ }
626
+ ],
627
+ controlId: l.id,
628
+ nextType: s.type
629
+ }).controls[0],
630
+ label: ke[s.type]
631
+ };
632
+ return {
633
+ step: 2,
634
+ control: n,
635
+ defaultValue: le(n, void 0)
636
+ };
637
+ }
638
+ function ma({
639
+ scope: s,
640
+ controls: l,
641
+ reservedControlIds: n,
642
+ defaultValues: o,
643
+ onChange: m,
644
+ emptyMessage: p,
645
+ initialCreateFlow: f = !1,
646
+ usageByControlId: y,
647
+ availableFieldChoices: h,
648
+ availableMetricChoices: C,
649
+ structuralParticipants: g,
650
+ structuralParticipantIdsByControlId: b,
651
+ card: v,
652
+ onCreateFlowActiveChange: k,
653
+ onCreateFlowComplete: A
654
+ }) {
655
+ const w = L(
656
+ () => new Set(n || []),
657
+ [n]
658
+ ), de = Lt(s), oe = wt(s), [ee, Y] = j(
659
+ null
660
+ ), [ce, R] = j(
661
+ null
662
+ ), [a, N] = j(
663
+ () => f ? {
664
+ step: 1,
665
+ control: ae(s, l, Array.from(w))
666
+ } : null
667
+ ), z = Ne({}), S = Ne(void 0), X = Ne(f), $ = L(
668
+ () => Oe({ scope: s, card: v }),
669
+ [v, s]
670
+ ), q = M(
671
+ (e) => s === "dashboard" && (e === "field_selector" || e === "metric_selector"),
672
+ [s]
673
+ ), G = L(
674
+ () => a ? ze(
675
+ g || [],
676
+ a.control.type
677
+ ) : [],
678
+ [a, g]
679
+ ), B = L(() => {
680
+ if (!a)
681
+ return {
682
+ fields: h || [],
683
+ metrics: C || []
684
+ };
685
+ if (!q(a.control.type))
686
+ return {
687
+ fields: h || [],
688
+ metrics: C || []
689
+ };
690
+ const e = a.selectedCardIds || [], i = he({
691
+ controlType: a.control.type,
692
+ participants: g || [],
693
+ selectedCardIds: e
694
+ });
695
+ return {
696
+ fields: a.control.type === "field_selector" ? i.choices.map((r) => ({
697
+ option: r,
698
+ target: i.fieldTargetMap[r.value]
699
+ })) : [],
700
+ metrics: a.control.type === "metric_selector" ? i.choices.map((r) => ({
701
+ option: r,
702
+ target: i.metricTargetMap[r.value]
703
+ })) : []
704
+ };
705
+ }, [
706
+ h,
707
+ C,
708
+ a,
709
+ q,
710
+ g
711
+ ]);
712
+ De(() => {
713
+ k == null || k(!!a);
714
+ }, [a, k]), De(() => {
715
+ const e = f && !X.current;
716
+ X.current = f, e && (N({
717
+ step: 1,
718
+ control: ae(s, l, Array.from(w))
719
+ }), R(null), Y(null));
720
+ }, [l, f, w, s]);
721
+ const te = (e) => {
722
+ if (!q(e.type))
723
+ return {
724
+ fields: h || [],
725
+ metrics: C || []
726
+ };
727
+ const i = (b == null ? void 0 : b[e.id]) || [];
728
+ if (i.length === 0)
729
+ return {
730
+ fields: h || [],
731
+ metrics: C || []
732
+ };
733
+ const r = he({
734
+ controlType: e.type,
735
+ participants: g || [],
736
+ selectedCardIds: i
737
+ });
738
+ return {
739
+ fields: e.type === "field_selector" ? r.choices.map((u) => ({
740
+ option: u,
741
+ target: r.fieldTargetMap[u.value]
742
+ })) : [],
743
+ metrics: e.type === "metric_selector" ? r.choices.map((u) => ({
744
+ option: u,
745
+ target: r.metricTargetMap[u.value]
746
+ })) : []
747
+ };
748
+ }, P = (e) => {
749
+ if (!q(e.control.type))
750
+ return {
751
+ nextControl: e.control,
752
+ cardBindingsById: void 0
753
+ };
754
+ const i = (b == null ? void 0 : b[e.control.id]) || [], r = he({
755
+ controlType: e.control.type,
756
+ participants: g || [],
757
+ selectedCardIds: e.nextSelectedCardIds
758
+ }), u = $t({
759
+ control: e.control,
760
+ choices: r.choices
761
+ }), x = Object.fromEntries(
762
+ i.filter((d) => !e.nextSelectedCardIds.includes(d)).map((d) => [d, void 0])
763
+ );
764
+ return e.nextSelectedCardIds.length > 0 && u.source.kind === "manual" && u.source.options.length > 0 && Object.assign(
765
+ x,
766
+ $e({
767
+ control: u,
768
+ participants: g || [],
769
+ selectedCardIds: e.nextSelectedCardIds
770
+ })
771
+ ), {
772
+ nextControl: u,
773
+ cardBindingsById: x
774
+ };
775
+ }, E = M((e, i = o, r = { type: "update" }) => {
776
+ const u = e.map((x) => (be({
777
+ control: x,
778
+ defaultValues: i
779
+ }), Vt(
780
+ x
781
+ )));
782
+ m(u, i, r);
783
+ }, [o, m]), W = (e, i) => {
784
+ const r = l.find(
785
+ (V) => V.id === e
786
+ );
787
+ let u = l.map((V) => V.id !== e ? V : i(V));
788
+ const x = u.find(
789
+ (V) => V.id === e
790
+ );
791
+ let d, D;
792
+ if (x && s === "dashboard" && (x.type === "field_selector" || x.type === "metric_selector")) {
793
+ const V = (b == null ? void 0 : b[x.id]) || [], K = P({
794
+ control: x,
795
+ nextSelectedCardIds: V
796
+ });
797
+ u = u.map(
798
+ (U) => U.id === e ? K.nextControl : U
799
+ ), d = K.cardBindingsById, D = [x.id];
800
+ } else if (r && s === "dashboard" && (r.type === "field_selector" || r.type === "metric_selector")) {
801
+ const V = (b == null ? void 0 : b[r.id]) || [];
802
+ d = Object.fromEntries(
803
+ V.map((K) => [K, void 0])
804
+ ), D = [r.id];
805
+ }
806
+ const I = u.find(
807
+ (V) => V.id === e
808
+ );
809
+ let Q = o;
810
+ if (r && I) {
811
+ const V = be({
812
+ control: r,
813
+ defaultValues: o
814
+ });
815
+ r.source.kind === "manual" && I.source.kind === "sql_query" && (z.current[e] = V);
816
+ const K = V === void 0 && r.source.kind === "sql_query" && I.source.kind === "manual" ? z.current[e] : V, U = Re({
817
+ previousControl: r,
818
+ nextControl: I,
819
+ currentDefaultValue: K
820
+ });
821
+ I.source.kind === "manual" && (z.current[e] = U), o && (Q = { ...o }, U === void 0 ? delete Q[e] : Q[e] = U), u = u.map(
822
+ (Me) => Me.id === e ? { ...I, defaultValue: U } : Me
823
+ );
824
+ }
825
+ E(u, Q, {
826
+ type: "update",
827
+ cardBindingsById: d,
828
+ affectedBindingControlIds: D
829
+ });
830
+ }, ot = (e, i) => {
831
+ const r = i.trim();
832
+ if (r.length === 0 || r === e || w.has(r) || l.some(
833
+ (d) => d.id === r && d.id !== e
834
+ ))
835
+ return;
836
+ const u = l.map(
837
+ (d) => d.id === e ? { ...d, id: r } : d
838
+ );
839
+ if (!o) {
840
+ E(u, void 0, {
841
+ type: "rename",
842
+ oldId: e,
843
+ newId: r
844
+ });
845
+ return;
846
+ }
847
+ const x = { ...o };
848
+ Object.prototype.hasOwnProperty.call(x, e) && (x[r] = x[e], delete x[e]), E(u, x, {
849
+ type: "rename",
850
+ oldId: e,
851
+ newId: r
852
+ });
853
+ }, ct = (e) => {
854
+ const i = l.filter((u) => u.id !== e);
855
+ if (!o) {
856
+ E(i, void 0, { type: "remove", controlId: e });
857
+ return;
858
+ }
859
+ const r = { ...o };
860
+ delete r[e], E(i, r, { type: "remove", controlId: e });
861
+ }, ut = M(() => {
862
+ S.current = void 0, N({
863
+ step: 1,
864
+ control: ae(s, l, Array.from(w))
865
+ }), R(null), Y(null);
866
+ }, [l, w, s]), J = (e) => {
867
+ N(
868
+ (i) => i && (() => {
869
+ const r = e(i.control);
870
+ i.control.source.kind === "manual" && r.source.kind === "sql_query" && (S.current = i.defaultValue);
871
+ const u = i.defaultValue === void 0 && i.control.source.kind === "sql_query" && r.source.kind === "manual" ? S.current : i.defaultValue, x = Re({
872
+ previousControl: i.control,
873
+ nextControl: r,
874
+ currentDefaultValue: u
875
+ });
876
+ return r.source.kind === "manual" && (S.current = x), {
877
+ ...i,
878
+ control: r,
879
+ defaultValue: x
880
+ };
881
+ })()
882
+ );
883
+ }, Fe = (e) => {
884
+ N(
885
+ (i) => i && (i.control.source.kind === "manual" && (S.current = e), {
886
+ ...i,
887
+ defaultValue: e
888
+ })
889
+ );
890
+ }, ue = (() => {
891
+ if (!a)
892
+ return !1;
893
+ if (a.step === 2 && q(a.control.type))
894
+ return (a.selectedCardIds || []).length > 0;
895
+ if (a.step !== 2 && a.step !== 3 || !a.control.label.trim())
896
+ return !1;
897
+ const i = a.control.source.kind === "sql_query" ? a.control : Be(a.control);
898
+ if (i.source.kind === "manual" && (It(i) && i.source.options.length === 0 || i.source.options.some(
899
+ (u) => u.label.trim().length === 0 || u.value.trim().length === 0
900
+ )))
901
+ return !1;
902
+ if (i.source.kind === "sql_query") {
903
+ const { connectionId: r, sql: u, valueColumn: x } = i.source;
904
+ return r.trim().length > 0 && u.trim().length > 0 && x.trim().length > 0;
905
+ }
906
+ return Tt(
907
+ le(i, a.defaultValue)
908
+ );
909
+ })(), Ee = () => {
910
+ var d;
911
+ if (!a)
912
+ return;
913
+ const e = Be(a.control), i = Rt({
914
+ label: e.label,
915
+ fallbackId: e.id,
916
+ existingControls: l,
917
+ reservedIds: Array.from(w)
918
+ }), r = {
919
+ ...e,
920
+ id: i
921
+ }, u = s === "dashboard" && (r.type === "field_selector" || r.type === "metric_selector") && ((d = a.selectedCardIds) != null && d.length) ? $e({
922
+ control: r,
923
+ participants: g || [],
924
+ selectedCardIds: a.selectedCardIds
925
+ }) : void 0, x = le(
926
+ r,
927
+ a.defaultValue
928
+ );
929
+ N({
930
+ step: s === "dashboard" && (r.type === "field_selector" || r.type === "metric_selector") ? 4 : 3,
931
+ control: r,
932
+ defaultValue: x,
933
+ createdControlId: i,
934
+ selectedCardIds: a.selectedCardIds,
935
+ cardBindingsById: u
936
+ });
937
+ }, me = M(() => {
938
+ N(null);
939
+ }, []), Le = M(() => {
940
+ if (!(a != null && a.createdControlId)) {
941
+ N(null);
942
+ return;
943
+ }
944
+ const e = a.control, i = a.createdControlId, r = le(
945
+ e,
946
+ a.defaultValue
947
+ );
948
+ if (o) {
949
+ const u = { ...o };
950
+ r === void 0 ? delete u[i] : u[i] = r, E(
951
+ [
952
+ ...l,
953
+ {
954
+ ...e,
955
+ defaultValue: r
956
+ }
957
+ ],
958
+ u,
959
+ {
960
+ type: "add",
961
+ cardBindingsById: a.cardBindingsById
962
+ }
963
+ );
964
+ } else
965
+ E(
966
+ [
967
+ ...l,
968
+ {
969
+ ...e,
970
+ defaultValue: r
971
+ }
972
+ ],
973
+ void 0,
974
+ {
975
+ type: "add",
976
+ cardBindingsById: a.cardBindingsById
977
+ }
978
+ );
979
+ R(i), N(null), A == null || A();
980
+ }, [l, a, o, E, A]), mt = a ? q(a.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Ae = a != null && a.createdControlId ? `[[param.${a.createdControlId}]]` : a ? `[[param.${qt(a.control.label) || a.control.id}]]` : "", pe = Qe({
981
+ controls: l,
982
+ defaultValues: o
983
+ }), fe = a ? [...l, a.control] : l, _e = a ? Qe({
984
+ controls: fe,
985
+ defaultValues: o,
986
+ overrides: [
987
+ {
988
+ controlId: a.control.id,
989
+ value: a.defaultValue
990
+ }
991
+ ]
992
+ }) : pe;
993
+ return /* @__PURE__ */ c("div", { className: "space-y-4", children: [
994
+ a ? /* @__PURE__ */ c("div", { className: "space-y-4 pb-1", children: [
995
+ /* @__PURE__ */ t(
996
+ Wt,
997
+ {
998
+ currentStep: a.step,
999
+ labels: mt
1000
+ }
1001
+ ),
1002
+ a.step === 1 && /* @__PURE__ */ c("div", { className: "space-y-4", children: [
1003
+ /* @__PURE__ */ c("div", { children: [
1004
+ /* @__PURE__ */ t("p", { className: "text-sm font-medium", children: "What kind of input should viewers see?" }),
1005
+ /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Choose the viewer experience first. You can fine-tune the details next." }),
1006
+ s === "card" && (v == null ? void 0 : v.sql) == null ? /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: "Explorer cards support displayed metric, group by field, aggregation, and time grain controls here." }) : null
1007
+ ] }),
1008
+ /* @__PURE__ */ t("div", { className: "grid gap-3 sm:grid-cols-2", children: $.map((e) => /* @__PURE__ */ c(
1009
+ "button",
1010
+ {
1011
+ type: "button",
1012
+ className: "rounded-xl border border-border/50 bg-muted/20 p-3 text-left transition-colors hover:border-border/70 hover:bg-muted/35",
1013
+ onClick: () => N(
1014
+ ea({
1015
+ scope: s,
1016
+ existingControls: l,
1017
+ reservedIds: Array.from(w),
1018
+ type: e.value
1019
+ })
1020
+ ),
1021
+ children: [
1022
+ /* @__PURE__ */ t("div", { className: "text-sm font-medium", children: e.label }),
1023
+ /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-muted-foreground", children: e.description })
1024
+ ]
1025
+ },
1026
+ e.value
1027
+ )) }),
1028
+ /* @__PURE__ */ t(
1029
+ re,
1030
+ {
1031
+ secondary: /* @__PURE__ */ t(
1032
+ T,
1033
+ {
1034
+ type: "button",
1035
+ variant: "outline",
1036
+ onClick: me,
1037
+ children: "Back to controls"
1038
+ }
1039
+ )
1040
+ }
1041
+ )
1042
+ ] }),
1043
+ a.step === 2 && q(a.control.type) && /* @__PURE__ */ c("div", { className: "space-y-3", children: [
1044
+ /* @__PURE__ */ c("div", { className: "space-y-3", children: [
1045
+ /* @__PURE__ */ t(
1046
+ dt,
1047
+ {
1048
+ control: a.control,
1049
+ onChange: (e) => J((i) => ({
1050
+ ...i,
1051
+ label: e
1052
+ }))
1053
+ }
1054
+ ),
1055
+ /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Choose which cards should respond to this shared control." })
1056
+ ] }),
1057
+ G.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-xl bg-muted/20 p-3 text-xs text-muted-foreground", children: "No eligible cards are available yet. Add compatible metrics or group-by fields to cards first." }) : /* @__PURE__ */ t("div", { className: "space-y-2 rounded-xl bg-muted/20 p-3", children: G.map((e) => {
1058
+ const i = (a.selectedCardIds || []).includes(e.cardId);
1059
+ return /* @__PURE__ */ c(
1060
+ "label",
1061
+ {
1062
+ className: "flex items-start gap-2 text-sm",
1063
+ children: [
1064
+ /* @__PURE__ */ t(
1065
+ Ft,
1066
+ {
1067
+ checked: i,
1068
+ onCheckedChange: (r) => N(
1069
+ (u) => u && {
1070
+ ...u,
1071
+ selectedCardIds: r === !0 ? [
1072
+ ...u.selectedCardIds || [],
1073
+ e.cardId
1074
+ ] : (u.selectedCardIds || []).filter(
1075
+ (x) => x !== e.cardId
1076
+ )
1077
+ }
1078
+ )
1079
+ }
1080
+ ),
1081
+ /* @__PURE__ */ c("div", { className: "min-w-0", children: [
1082
+ /* @__PURE__ */ t("div", { className: "font-medium", children: e.title }),
1083
+ /* @__PURE__ */ t("div", { className: "text-xs text-muted-foreground", children: a.control.type === "field_selector" ? `${e.fieldChoices.length} compatible group-by fields` : `${e.metricChoices.length} compatible metrics` })
1084
+ ] })
1085
+ ]
1086
+ },
1087
+ e.cardId
1088
+ );
1089
+ }) }),
1090
+ /* @__PURE__ */ t(
1091
+ re,
1092
+ {
1093
+ secondary: /* @__PURE__ */ t(
1094
+ T,
1095
+ {
1096
+ type: "button",
1097
+ variant: "outline",
1098
+ onClick: () => N(
1099
+ (e) => e && {
1100
+ ...e,
1101
+ step: 1,
1102
+ selectedCardIds: []
1103
+ }
1104
+ ),
1105
+ children: "Back"
1106
+ }
1107
+ ),
1108
+ primary: /* @__PURE__ */ t(
1109
+ T,
1110
+ {
1111
+ type: "button",
1112
+ onClick: () => N(
1113
+ (e) => e && {
1114
+ ...e,
1115
+ step: 3
1116
+ }
1117
+ ),
1118
+ disabled: !ue,
1119
+ children: "Next"
1120
+ }
1121
+ )
1122
+ }
1123
+ )
1124
+ ] }),
1125
+ a.step === 2 && !q(a.control.type) && /* @__PURE__ */ t(
1126
+ Ke,
1127
+ {
1128
+ control: a.control,
1129
+ defaultValue: a.defaultValue,
1130
+ availableFieldChoices: B.fields,
1131
+ availableMetricChoices: B.metrics,
1132
+ previewControlDefinitions: fe,
1133
+ previewControlValues: _e,
1134
+ onControlChange: (e) => J(() => e),
1135
+ onLabelChange: (e) => J((i) => ({
1136
+ ...i,
1137
+ label: e
1138
+ })),
1139
+ onDefaultValueChange: Fe,
1140
+ onBack: () => N(
1141
+ (e) => e && {
1142
+ ...e,
1143
+ step: 1
1144
+ }
1145
+ ),
1146
+ onNext: Ee,
1147
+ nextDisabled: !ue
1148
+ }
1149
+ ),
1150
+ a.step === 3 && q(a.control.type) && /* @__PURE__ */ t(
1151
+ Ke,
1152
+ {
1153
+ control: a.control,
1154
+ defaultValue: a.defaultValue,
1155
+ availableFieldChoices: B.fields,
1156
+ availableMetricChoices: B.metrics,
1157
+ previewControlDefinitions: fe,
1158
+ previewControlValues: _e,
1159
+ onControlChange: (e) => J(() => e),
1160
+ onLabelChange: (e) => J((i) => ({
1161
+ ...i,
1162
+ label: e
1163
+ })),
1164
+ onDefaultValueChange: Fe,
1165
+ onBack: () => N(
1166
+ (e) => e && {
1167
+ ...e,
1168
+ step: 2
1169
+ }
1170
+ ),
1171
+ onNext: Ee,
1172
+ nextDisabled: !ue
1173
+ }
1174
+ ),
1175
+ a.step === 3 && !q(a.control.type) && /* @__PURE__ */ t(
1176
+ He,
1177
+ {
1178
+ control: a.control,
1179
+ scope: s,
1180
+ createdReference: Ae,
1181
+ explorerContent: /* @__PURE__ */ t(we, { title: "Explorer cards", children: /* @__PURE__ */ c("p", { className: "text-sm", children: [
1182
+ "Open the card and use",
1183
+ " ",
1184
+ /* @__PURE__ */ t("span", { className: "font-medium", children: "Settings → Controls" }),
1185
+ " ",
1186
+ "to choose what this control changes."
1187
+ ] }) }),
1188
+ sqlDescription: "Reference this control directly in the SQL editor.",
1189
+ onBack: () => N(
1190
+ (e) => e && {
1191
+ ...e,
1192
+ step: 2
1193
+ }
1194
+ ),
1195
+ onCancel: me,
1196
+ onDone: Le
1197
+ }
1198
+ ),
1199
+ a.step === 4 && q(a.control.type) && /* @__PURE__ */ t(
1200
+ He,
1201
+ {
1202
+ control: a.control,
1203
+ scope: s,
1204
+ createdReference: Ae,
1205
+ summaryDetail: /* @__PURE__ */ c(Z, { children: [
1206
+ "Used by ",
1207
+ (a.selectedCardIds || []).length,
1208
+ " ",
1209
+ "selected card",
1210
+ (a.selectedCardIds || []).length === 1 ? "" : "s"
1211
+ ] }),
1212
+ explorerContent: /* @__PURE__ */ t(we, { title: "Explorer cards", children: /* @__PURE__ */ t("p", { className: "text-sm", children: "Selected cards have been set up to respond to this control automatically." }) }),
1213
+ sqlDescription: "SQL cards can still reference this control directly in the SQL editor.",
1214
+ onBack: () => N(
1215
+ (e) => e && {
1216
+ ...e,
1217
+ step: 3
1218
+ }
1219
+ ),
1220
+ onCancel: me,
1221
+ onDone: Le
1222
+ }
1223
+ )
1224
+ ] }) : null,
1225
+ !a && l.length === 0 ? /* @__PURE__ */ t("div", { className: "rounded-md border border-dashed p-3 text-sm text-muted-foreground", children: p }) : null,
1226
+ !a && l.map((e) => {
1227
+ const i = te(e), r = y == null ? void 0 : y[e.id], u = be({
1228
+ control: e,
1229
+ defaultValues: o
1230
+ }), x = ce === e.id;
1231
+ return /* @__PURE__ */ c("div", { className: "rounded-md border", children: [
1232
+ /* @__PURE__ */ c("div", { className: "flex items-center gap-2 px-3 py-3", children: [
1233
+ /* @__PURE__ */ c(
1234
+ "button",
1235
+ {
1236
+ type: "button",
1237
+ className: "flex min-w-0 flex-1 items-start gap-2 text-left",
1238
+ onClick: () => R(
1239
+ (d) => d === e.id ? null : e.id
1240
+ ),
1241
+ children: [
1242
+ x ? /* @__PURE__ */ t(Ue, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ t(je, { className: "mt-0.5 h-4 w-4 shrink-0 text-muted-foreground" }),
1243
+ /* @__PURE__ */ c("div", { className: "min-w-0", children: [
1244
+ /* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-2", children: [
1245
+ /* @__PURE__ */ t("span", { className: "truncate text-sm font-medium", children: e.label || "Untitled control" }),
1246
+ /* @__PURE__ */ t(se, { variant: "outline", className: "text-[11px]", children: Ie(e.type).label }),
1247
+ /* @__PURE__ */ t(se, { variant: "secondary", className: "text-[11px]", children: et(s, e.placement) })
1248
+ ] }),
1249
+ /* @__PURE__ */ c("div", { className: "mt-1 text-xs text-muted-foreground", children: [
1250
+ tt(e),
1251
+ r != null && r.status ? ` · ${r.status}` : ""
1252
+ ] })
1253
+ ] })
1254
+ ]
1255
+ }
1256
+ ),
1257
+ /* @__PURE__ */ t(
1258
+ T,
1259
+ {
1260
+ type: "button",
1261
+ size: "icon",
1262
+ variant: "ghost",
1263
+ className: "h-8 w-8 shrink-0",
1264
+ onClick: () => ct(e.id),
1265
+ "aria-label": `Remove ${e.label}`,
1266
+ children: /* @__PURE__ */ t(Et, { className: "h-4 w-4" })
1267
+ }
1268
+ )
1269
+ ] }),
1270
+ x && /* @__PURE__ */ c("div", { className: "space-y-4 border-t px-3 py-4", children: [
1271
+ r != null && r.helper ? /* @__PURE__ */ t("div", { className: "rounded-md bg-muted/30 px-3 py-2 text-xs text-muted-foreground", children: r.helper }) : null,
1272
+ /* @__PURE__ */ c("div", { className: "grid gap-3 md:grid-cols-3", children: [
1273
+ /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
1274
+ /* @__PURE__ */ t(H, { className: "text-xs", children: "Label" }),
1275
+ /* @__PURE__ */ t(
1276
+ at,
1277
+ {
1278
+ value: e.label,
1279
+ placeholder: "Control label",
1280
+ onChange: (d) => W(e.id, (D) => ({
1281
+ ...D,
1282
+ label: d.target.value
1283
+ }))
1284
+ }
1285
+ )
1286
+ ] }),
1287
+ /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
1288
+ /* @__PURE__ */ t(H, { className: "text-xs", children: "Type" }),
1289
+ /* @__PURE__ */ c(
1290
+ ye,
1291
+ {
1292
+ value: e.type,
1293
+ onValueChange: (d) => {
1294
+ const D = lt({
1295
+ controls: l,
1296
+ controlId: e.id,
1297
+ nextType: d,
1298
+ defaultValues: o
1299
+ });
1300
+ E(D.controls, D.defaultValues);
1301
+ },
1302
+ children: [
1303
+ /* @__PURE__ */ t(ve, { children: /* @__PURE__ */ t(ge, {}) }),
1304
+ /* @__PURE__ */ t(Ce, { children: Oe({
1305
+ scope: s,
1306
+ card: v,
1307
+ includeType: e.type
1308
+ }).map((d) => /* @__PURE__ */ t(xe, { value: d.value, children: d.label }, d.value)) })
1309
+ ]
1310
+ }
1311
+ )
1312
+ ] }),
1313
+ /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
1314
+ /* @__PURE__ */ t(H, { className: "text-xs", children: "Show in" }),
1315
+ /* @__PURE__ */ c(
1316
+ ye,
1317
+ {
1318
+ value: e.placement || oe,
1319
+ onValueChange: (d) => W(e.id, (D) => ({
1320
+ ...D,
1321
+ placement: d
1322
+ })),
1323
+ children: [
1324
+ /* @__PURE__ */ t(ve, { children: /* @__PURE__ */ t(ge, {}) }),
1325
+ /* @__PURE__ */ t(Ce, { children: de.map((d) => /* @__PURE__ */ t(xe, { value: d.value, children: d.label }, d.value)) })
1326
+ ]
1327
+ }
1328
+ )
1329
+ ] })
1330
+ ] }),
1331
+ q(e.type) ? /* @__PURE__ */ t(
1332
+ At,
1333
+ {
1334
+ type: e.type,
1335
+ participants: ze(
1336
+ g || [],
1337
+ e.type
1338
+ ).map((d) => ({
1339
+ cardId: d.cardId,
1340
+ title: d.title,
1341
+ choiceCount: e.type === "field_selector" ? d.fieldChoices.length : d.metricChoices.length
1342
+ })),
1343
+ selectedCardIds: (b == null ? void 0 : b[e.id]) || [],
1344
+ onChange: (d) => {
1345
+ const D = P({
1346
+ control: e,
1347
+ nextSelectedCardIds: d
1348
+ }), I = l.map(
1349
+ (Q) => Q.id === e.id ? D.nextControl : Q
1350
+ );
1351
+ E(I, o, {
1352
+ type: "update",
1353
+ cardBindingsById: D.cardBindingsById
1354
+ });
1355
+ }
1356
+ }
1357
+ ) : null,
1358
+ /* @__PURE__ */ t(
1359
+ st,
1360
+ {
1361
+ control: e,
1362
+ availableFieldChoices: i.fields,
1363
+ availableMetricChoices: i.metrics,
1364
+ previewControlDefinitions: l,
1365
+ previewControlValues: pe,
1366
+ controlLifecycle: "edit",
1367
+ onChange: (d) => W(e.id, () => d)
1368
+ }
1369
+ ),
1370
+ e.initialValueStrategy === "saved_default" && /* @__PURE__ */ t(
1371
+ rt,
1372
+ {
1373
+ control: e,
1374
+ value: u,
1375
+ allowNoDefault: !0,
1376
+ allowCardDefault: !0,
1377
+ previewControlDefinitions: l,
1378
+ previewControlValues: pe,
1379
+ onChange: (d) => {
1380
+ const D = l.map(
1381
+ (I) => I.id === e.id ? { ...I, defaultValue: d } : I
1382
+ );
1383
+ if (e.source.kind === "manual" && (z.current[e.id] = d), o) {
1384
+ const I = { ...o };
1385
+ d === void 0 ? delete I[e.id] : I[e.id] = d, E(D, I);
1386
+ return;
1387
+ }
1388
+ E(D, void 0);
1389
+ }
1390
+ }
1391
+ ),
1392
+ /* @__PURE__ */ c(
1393
+ _t,
1394
+ {
1395
+ open: ee === e.id,
1396
+ onOpenChange: (d) => Y(d ? e.id : null),
1397
+ children: [
1398
+ /* @__PURE__ */ t(Mt, { asChild: !0, children: /* @__PURE__ */ c(
1399
+ T,
1400
+ {
1401
+ type: "button",
1402
+ variant: "ghost",
1403
+ className: "h-auto px-0 text-xs text-muted-foreground hover:bg-transparent",
1404
+ children: [
1405
+ ee === e.id ? /* @__PURE__ */ t(Ue, { className: "mr-1 h-4 w-4" }) : /* @__PURE__ */ t(je, { className: "mr-1 h-4 w-4" }),
1406
+ "Advanced"
1407
+ ]
1408
+ }
1409
+ ) }),
1410
+ /* @__PURE__ */ c(Ot, { className: "space-y-3 pt-2", children: [
1411
+ /* @__PURE__ */ c("div", { className: "grid gap-3 md:grid-cols-2", children: [
1412
+ /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
1413
+ /* @__PURE__ */ t(H, { className: "text-xs", children: "Control ID" }),
1414
+ /* @__PURE__ */ t(
1415
+ zt,
1416
+ {
1417
+ controlId: e.id,
1418
+ onCommit: (d) => ot(e.id, d)
1419
+ },
1420
+ e.id
1421
+ )
1422
+ ] }),
1423
+ /* @__PURE__ */ c("div", { className: "space-y-1.5", children: [
1424
+ /* @__PURE__ */ t(H, { className: "text-xs", children: "Initial value" }),
1425
+ /* @__PURE__ */ c(
1426
+ ye,
1427
+ {
1428
+ value: e.initialValueStrategy,
1429
+ onValueChange: (d) => W(e.id, (D) => ({
1430
+ ...D,
1431
+ initialValueStrategy: d
1432
+ })),
1433
+ children: [
1434
+ /* @__PURE__ */ t(ve, { children: /* @__PURE__ */ t(ge, {}) }),
1435
+ /* @__PURE__ */ t(Ce, { children: Bt.map((d) => /* @__PURE__ */ t(
1436
+ xe,
1437
+ {
1438
+ value: d.value,
1439
+ children: d.label
1440
+ },
1441
+ d.value
1442
+ )) })
1443
+ ]
1444
+ }
1445
+ ),
1446
+ /* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: Qt(
1447
+ e.initialValueStrategy
1448
+ ) })
1449
+ ] })
1450
+ ] }),
1451
+ /* @__PURE__ */ t(
1452
+ Ut,
1453
+ {
1454
+ control: e,
1455
+ onChange: (d) => W(e.id, () => d)
1456
+ }
1457
+ )
1458
+ ] })
1459
+ ]
1460
+ }
1461
+ )
1462
+ ] })
1463
+ ] }, e.id);
1464
+ }),
1465
+ !a && /* @__PURE__ */ c(
1466
+ T,
1467
+ {
1468
+ type: "button",
1469
+ variant: "outline",
1470
+ size: "sm",
1471
+ onClick: ut,
1472
+ children: [
1473
+ /* @__PURE__ */ t(jt, { className: "mr-2 h-4 w-4" }),
1474
+ "Add control"
1475
+ ]
1476
+ }
1477
+ )
1478
+ ] });
1479
+ }
1480
+ function pa(s) {
1481
+ const { open: l, onOpenChange: n, initialCreateFlowActive: o = !1 } = s, m = l !== void 0, [p, f] = j(!1), [y, h] = j(
1482
+ o
1483
+ ), C = m ? l : p, g = M(
1484
+ (k) => {
1485
+ !k && y || (m || f(k), k || h(!1), n == null || n(k));
1486
+ },
1487
+ [m, y, n]
1488
+ ), b = M(() => {
1489
+ m || f(!1), h(!1), n == null || n(!1);
1490
+ }, [m, n]);
1491
+ De(() => {
1492
+ C || h(!1);
1493
+ }, [C]);
1494
+ const v = M(
1495
+ (k) => {
1496
+ y && k.preventDefault();
1497
+ },
1498
+ [y]
1499
+ );
1500
+ return {
1501
+ forceClose: b,
1502
+ handleOpenChange: g,
1503
+ isCreateFlowActive: y,
1504
+ preventPassiveDismissDuringCreate: v,
1505
+ resolvedOpen: C,
1506
+ setIsCreateFlowActive: h
1507
+ };
1508
+ }
1509
+ export {
1510
+ ra as C,
1511
+ ia as E,
1512
+ Xt as L,
1513
+ nt as S,
1514
+ na as V,
1515
+ da as a,
1516
+ oa as b,
1517
+ Gt as c,
1518
+ ca as d,
1519
+ ma as e,
1520
+ ua as f,
1521
+ it as g,
1522
+ pa as u
1523
+ };