react-semaphor 0.1.281 → 0.1.283

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