react-semaphor 0.1.260 → 0.1.261
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.
- package/dist/chunks/dashboard-controls-0hbftZxY.js +42 -0
- package/dist/chunks/dashboard-controls-BYi_r2lH.js +1971 -0
- package/dist/chunks/dashboard-filter-controls-button-BPCw1GMh.js +1066 -0
- package/dist/chunks/dashboard-filter-controls-button-f4pDkDUL.js +11 -0
- package/dist/chunks/{dashboard-json-U7VmojaR.js → dashboard-json-2NJCXsDD.js} +1 -1
- package/dist/chunks/{dashboard-json-BUrApiYl.js → dashboard-json-Dpy-zKf2.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-DlVBUQmC.js → dashboard-summary-settings-dialog-B9zRCvc-.js} +1 -1
- package/dist/chunks/{dashboard-summary-settings-dialog-CaxmCNyy.js → dashboard-summary-settings-dialog-Be3JilRI.js} +1 -1
- package/dist/chunks/edit-dashboard-visual-Bon08erH.js +188 -0
- package/dist/chunks/{edit-dashboard-visual-N2r5ObJ_.js → edit-dashboard-visual-CqTlmuYL.js} +5970 -5492
- package/dist/chunks/index-BoJEr_9F.js +1114 -0
- package/dist/chunks/{index-BNdZjo5d.js → index-C2c-_lPE.js} +48333 -44824
- package/dist/chunks/{normalize-dashboard-for-dirty-check-Bn27S0PN.js → normalize-dashboard-for-dirty-check-5KpZN8xr.js} +20 -19
- package/dist/chunks/normalize-dashboard-for-dirty-check-BXRUMVb2.js +1 -0
- package/dist/chunks/{resource-management-panel-C_ZqsVMH.js → resource-management-panel-BtLPW2b4.js} +1 -1
- package/dist/chunks/{resource-management-panel-zF23gLOJ.js → resource-management-panel-Bva2_0OU.js} +70 -70
- package/dist/chunks/use-create-flow-overlay-state-9X7GyUzl.js +21 -0
- package/dist/chunks/use-create-flow-overlay-state-Vyd5mSnf.js +1445 -0
- package/dist/chunks/{use-visual-utils-BBTQGDdB.js → use-visual-utils-Jv4hWSLm.js} +1 -1
- package/dist/chunks/{use-visual-utils-K1k39w2U.js → use-visual-utils-OPk_1t4I.js} +1 -1
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +5 -4
- package/dist/index.cjs +1 -1
- package/dist/index.js +102 -99
- package/dist/shared/index.cjs +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +5 -4
- package/dist/types/dashboard.d.ts +105 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -3
- package/dist/types/main.d.ts +175 -1
- package/dist/types/shared.d.ts +89 -0
- package/dist/types/surfboard.d.ts +105 -0
- package/dist/types/types.d.ts +113 -0
- package/package.json +1 -1
- package/dist/chunks/dashboard-controls-CIdYp98a.js +0 -47
- package/dist/chunks/dashboard-controls-DOqBYrkB.js +0 -1847
- package/dist/chunks/edit-dashboard-visual-uA-0wLnR.js +0 -193
- package/dist/chunks/editor-action-buttons-B6lABkRB.js +0 -412
- package/dist/chunks/editor-action-buttons-Dh7Xndgk.js +0 -21
- package/dist/chunks/index-DOeggx0V.js +0 -1109
- package/dist/chunks/normalize-dashboard-for-dirty-check-B7NQDI1H.js +0 -1
- package/dist/chunks/notification-bell-BxyeaeRc.js +0 -839
- package/dist/chunks/notification-bell-tJRds5JJ.js +0 -6
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
function s(t) {
|
|
2
|
+
return JSON.stringify(t, (n, r) => !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((i, e) => (i[e] = r[e], i), {}));
|
|
3
|
+
}
|
|
4
|
+
const y = [
|
|
2
5
|
"i",
|
|
3
6
|
"x",
|
|
4
7
|
"y",
|
|
@@ -12,58 +15,56 @@ const s = [
|
|
|
12
15
|
"isResizable",
|
|
13
16
|
"isDraggable"
|
|
14
17
|
];
|
|
15
|
-
function
|
|
18
|
+
function f(t, n, r) {
|
|
16
19
|
t[n] = r;
|
|
17
20
|
}
|
|
18
|
-
function
|
|
21
|
+
function a(t) {
|
|
19
22
|
const n = {};
|
|
20
|
-
for (const r of
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
+
for (const r of y) {
|
|
24
|
+
const i = t[r];
|
|
25
|
+
i !== void 0 && ((r === "isResizable" || r === "isDraggable") && i === !0 || f(n, r, i));
|
|
23
26
|
}
|
|
24
27
|
return n;
|
|
25
28
|
}
|
|
26
29
|
function o(t) {
|
|
27
|
-
return t ? t.map(
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
+
return t ? t.map(a).sort((n, r) => {
|
|
31
|
+
const i = String(n.i ?? ""), e = String(r.i ?? "");
|
|
32
|
+
return i !== e ? i.localeCompare(e) : Number(n.y ?? 0) - Number(r.y ?? 0) || Number(n.x ?? 0) - Number(r.x ?? 0) || Number(n.h ?? 0) - Number(r.h ?? 0) || Number(n.w ?? 0) - Number(r.w ?? 0);
|
|
30
33
|
}) : [];
|
|
31
34
|
}
|
|
32
35
|
function u(t) {
|
|
33
36
|
if (!t) return;
|
|
34
37
|
const n = {};
|
|
35
38
|
for (const r of Object.keys(t).sort()) {
|
|
36
|
-
const
|
|
37
|
-
|
|
39
|
+
const i = t[r];
|
|
40
|
+
i && (n[r] = o(i));
|
|
38
41
|
}
|
|
39
42
|
return n;
|
|
40
43
|
}
|
|
41
|
-
function a(t) {
|
|
42
|
-
return JSON.stringify(t, (n, r) => !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((e, i) => (e[i] = r[i], e), {}));
|
|
43
|
-
}
|
|
44
44
|
function c(t) {
|
|
45
45
|
var n;
|
|
46
46
|
return t ? {
|
|
47
47
|
...t,
|
|
48
48
|
sheets: (n = t.sheets) == null ? void 0 : n.map((r) => {
|
|
49
49
|
if (!r) return r;
|
|
50
|
-
const
|
|
50
|
+
const i = {
|
|
51
51
|
...r
|
|
52
52
|
};
|
|
53
|
-
return r.layout && (
|
|
53
|
+
return r.layout && (i.layout = o(r.layout)), r.layouts && (i.layouts = u(r.layouts)), i;
|
|
54
54
|
})
|
|
55
55
|
} : null;
|
|
56
56
|
}
|
|
57
57
|
function m(t) {
|
|
58
58
|
return JSON.stringify(t ?? null, function(n, r) {
|
|
59
|
-
return n === "layout" && Array.isArray(r) ? o(r) : n === "layouts" && r && typeof r == "object" && !Array.isArray(r) ? u(r) : !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((
|
|
59
|
+
return n === "layout" && Array.isArray(r) ? o(r) : n === "layouts" && r && typeof r == "object" && !Array.isArray(r) ? u(r) : !r || typeof r != "object" || Array.isArray(r) ? r : Object.keys(r).sort().reduce((i, e) => (i[e] = r[e], i), {});
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
62
|
function b(t) {
|
|
63
|
-
return
|
|
63
|
+
return s(u(t) ?? null);
|
|
64
64
|
}
|
|
65
65
|
export {
|
|
66
|
-
|
|
66
|
+
s as a,
|
|
67
|
+
b,
|
|
67
68
|
c as n,
|
|
68
69
|
m as s
|
|
69
70
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function s(i){return JSON.stringify(i,(t,r)=>!r||typeof r!="object"||Array.isArray(r)?r:Object.keys(r).sort().reduce((e,n)=>(e[n]=r[n],e),{}))}const y=["i","x","y","w","h","minW","minH","maxW","maxH","static","isResizable","isDraggable"];function a(i,t,r){i[t]=r}function f(i){const t={};for(const r of y){const e=i[r];e!==void 0&&((r==="isResizable"||r==="isDraggable")&&e===!0||a(t,r,e))}return t}function o(i){return i?i.map(f).sort((t,r)=>{const e=String(t.i??""),n=String(r.i??"");return e!==n?e.localeCompare(n):Number(t.y??0)-Number(r.y??0)||Number(t.x??0)-Number(r.x??0)||Number(t.h??0)-Number(r.h??0)||Number(t.w??0)-Number(r.w??0)}):[]}function u(i){if(!i)return;const t={};for(const r of Object.keys(i).sort()){const e=i[r];e&&(t[r]=o(e))}return t}function c(i){var t;return i?{...i,sheets:(t=i.sheets)==null?void 0:t.map(r=>{if(!r)return r;const e={...r};return r.layout&&(e.layout=o(r.layout)),r.layouts&&(e.layouts=u(r.layouts)),e})}:null}function m(i){return JSON.stringify(i??null,function(t,r){return t==="layout"&&Array.isArray(r)?o(r):t==="layouts"&&r&&typeof r=="object"&&!Array.isArray(r)?u(r):!r||typeof r!="object"||Array.isArray(r)?r:Object.keys(r).sort().reduce((e,n)=>(e[n]=r[n],e),{})})}function b(i){return s(u(i)??null)}exports.normalizeDashboardForDirtyCheck=c;exports.serializeDashboardForDirtyCheck=m;exports.serializeLayoutsForDirtyCheck=b;exports.stableSerialize=s;
|
package/dist/chunks/{resource-management-panel-C_ZqsVMH.js → resource-management-panel-BtLPW2b4.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),t=require("./index-BoJEr_9F.js"),h=require("react"),re=require("./use-visual-utils-Jv4hWSLm.js");/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
package/dist/chunks/{resource-management-panel-zF23gLOJ.js → resource-management-panel-Bva2_0OU.js}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r, Fragment as le } from "react/jsx-runtime";
|
|
2
|
-
import { bL as Pe, u as re, U as je, K as ce,
|
|
2
|
+
import { bL as Pe, u as re, U as je, K as ce, cw as Fe, cx as Be, c as X, B as P, cp as ie, cy as ze, cz as He, cA as Ke, cB as _e, cC as Q, w as oe, cD as Ge, cE as We, cF as Ye, cG as ge, cc as ue, cH as $e, cI as Je, cJ as xe, cK as De, cL as we, cM as Qe, ak as Ne, ag as ve, cN as ye, cO as Ce, cP as Se, cQ as Ee, cR as Ve, cS as Le, cT as Ae, cU as Oe, cV as Te, cW as Xe, cX as he, cY as Ze, ae as te, b as qe, cZ as Re, c_ as ke, e as et, f as tt, g as rt, h as nt, i as ot, L as be, c$ as de, v as st, d0 as at, d1 as it, d2 as dt, bS as lt, bT as ct, bU as ut, bV as ht, d3 as mt, d4 as pt } from "./index-C2c-_lPE.js";
|
|
3
3
|
import ft, { useRef as gt, useEffect as ne, useState as x } from "react";
|
|
4
|
-
import { a as Ue } from "./use-visual-utils-
|
|
4
|
+
import { a as Ue } from "./use-visual-utils-OPk_1t4I.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license lucide-react v0.453.0 - ISC
|
|
7
7
|
*
|
|
@@ -62,7 +62,7 @@ function wt({
|
|
|
62
62
|
formatDate: v
|
|
63
63
|
}) {
|
|
64
64
|
var I, U, j, F;
|
|
65
|
-
const { selectVisual: m } = ce(), c = Fe(t.id), u = Dt(t.id), A = re((i) => i.isVisualEditing), { isConsoleMode: R } =
|
|
65
|
+
const { selectVisual: m } = ce(), c = Fe(t.id), u = Dt(t.id), A = re((i) => i.isVisualEditing), { isConsoleMode: R } = Be(), b = ft.useRef(null), [S, E] = x(!1), [V, O] = x(!1);
|
|
66
66
|
ne(() => {
|
|
67
67
|
p ? (E(!0), O(!0)) : V && (E(!1), O(!1));
|
|
68
68
|
}, [p, V]), ne(() => {
|
|
@@ -80,7 +80,7 @@ function wt({
|
|
|
80
80
|
"div",
|
|
81
81
|
{
|
|
82
82
|
ref: b,
|
|
83
|
-
className:
|
|
83
|
+
className: X(
|
|
84
84
|
"group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",
|
|
85
85
|
u ? "border-primary/30 bg-primary/10" : c && "border-border/60 bg-muted/50"
|
|
86
86
|
),
|
|
@@ -116,7 +116,7 @@ function wt({
|
|
|
116
116
|
/* @__PURE__ */ e(
|
|
117
117
|
"div",
|
|
118
118
|
{
|
|
119
|
-
className:
|
|
119
|
+
className: X(
|
|
120
120
|
"flex flex-shrink-0 items-center gap-1 transition-opacity",
|
|
121
121
|
c || u || S ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0 group-hover:pointer-events-auto group-hover:opacity-100 group-focus-within:pointer-events-auto group-focus-within:opacity-100"
|
|
122
122
|
),
|
|
@@ -140,7 +140,7 @@ function wt({
|
|
|
140
140
|
}
|
|
141
141
|
),
|
|
142
142
|
/* @__PURE__ */ r(
|
|
143
|
-
|
|
143
|
+
ze,
|
|
144
144
|
{
|
|
145
145
|
modal: !1,
|
|
146
146
|
open: S,
|
|
@@ -163,7 +163,7 @@ function wt({
|
|
|
163
163
|
className: "z-[51] w-44 rounded-xl border border-border/60 p-1 shadow-sm",
|
|
164
164
|
children: [
|
|
165
165
|
/* @__PURE__ */ r(
|
|
166
|
-
|
|
166
|
+
Q,
|
|
167
167
|
{
|
|
168
168
|
onClick: (i) => {
|
|
169
169
|
i.stopPropagation(), d(t);
|
|
@@ -176,7 +176,7 @@ function wt({
|
|
|
176
176
|
}
|
|
177
177
|
),
|
|
178
178
|
/* @__PURE__ */ r(
|
|
179
|
-
|
|
179
|
+
Q,
|
|
180
180
|
{
|
|
181
181
|
onClick: (i) => {
|
|
182
182
|
i.stopPropagation(), a == null || a(t);
|
|
@@ -188,46 +188,46 @@ function wt({
|
|
|
188
188
|
}
|
|
189
189
|
),
|
|
190
190
|
/* @__PURE__ */ r(
|
|
191
|
-
|
|
191
|
+
Q,
|
|
192
192
|
{
|
|
193
193
|
onClick: (i) => {
|
|
194
194
|
i.preventDefault(), i.stopPropagation(), s(t.id);
|
|
195
195
|
},
|
|
196
196
|
disabled: p,
|
|
197
197
|
children: [
|
|
198
|
-
p ? /* @__PURE__ */ e(oe, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(
|
|
198
|
+
p ? /* @__PURE__ */ e(oe, { className: "mr-2 h-3 w-3 animate-spin" }) : /* @__PURE__ */ e(Ge, { className: "mr-2 h-3 w-3" }),
|
|
199
199
|
p ? "Duplicating..." : "Duplicate"
|
|
200
200
|
]
|
|
201
201
|
}
|
|
202
202
|
),
|
|
203
203
|
t.ownership.isOwner && /* @__PURE__ */ r(le, { children: [
|
|
204
204
|
/* @__PURE__ */ r(
|
|
205
|
-
|
|
205
|
+
Q,
|
|
206
206
|
{
|
|
207
207
|
onClick: (i) => {
|
|
208
208
|
i.stopPropagation(), h == null || h(t);
|
|
209
209
|
},
|
|
210
210
|
children: [
|
|
211
|
-
/* @__PURE__ */ e(
|
|
211
|
+
/* @__PURE__ */ e(We, { className: "mr-2 h-3 w-3" }),
|
|
212
212
|
"Edit details"
|
|
213
213
|
]
|
|
214
214
|
}
|
|
215
215
|
),
|
|
216
216
|
/* @__PURE__ */ r(
|
|
217
|
-
|
|
217
|
+
Q,
|
|
218
218
|
{
|
|
219
219
|
onClick: (i) => {
|
|
220
220
|
i.stopPropagation(), w(t);
|
|
221
221
|
},
|
|
222
222
|
children: [
|
|
223
|
-
/* @__PURE__ */ e(
|
|
223
|
+
/* @__PURE__ */ e(Ye, { className: "mr-2 h-3 w-3" }),
|
|
224
224
|
"Share"
|
|
225
225
|
]
|
|
226
226
|
}
|
|
227
227
|
),
|
|
228
228
|
/* @__PURE__ */ e(ge, {}),
|
|
229
229
|
/* @__PURE__ */ r(
|
|
230
|
-
|
|
230
|
+
Q,
|
|
231
231
|
{
|
|
232
232
|
onClick: (i) => {
|
|
233
233
|
i.stopPropagation(), D(t);
|
|
@@ -244,11 +244,11 @@ function wt({
|
|
|
244
244
|
/* @__PURE__ */ e(ge, {}),
|
|
245
245
|
/* @__PURE__ */ r("div", { className: "space-y-1 px-2 py-2 text-xs text-muted-foreground", children: [
|
|
246
246
|
(((U = t.ownership.createdBy) == null ? void 0 : U.type) === "tenant" || ((j = t.ownership.createdBy) == null ? void 0 : j.type) === "organization" && R) && /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
|
|
247
|
-
/* @__PURE__ */ e(
|
|
247
|
+
/* @__PURE__ */ e($e, { className: "h-3 w-3" }),
|
|
248
248
|
/* @__PURE__ */ e("span", { children: ((F = t.ownership.createdBy) == null ? void 0 : F.name) || "Unknown" })
|
|
249
249
|
] }),
|
|
250
250
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
|
|
251
|
-
/* @__PURE__ */ e(
|
|
251
|
+
/* @__PURE__ */ e(Je, { className: "h-3 w-3" }),
|
|
252
252
|
/* @__PURE__ */ e("span", { children: v(t.lastModified) })
|
|
253
253
|
] })
|
|
254
254
|
] })
|
|
@@ -295,47 +295,47 @@ function Nt({ searchQuery: t }) {
|
|
|
295
295
|
s && O(s.id);
|
|
296
296
|
}, {
|
|
297
297
|
startUpdating: i,
|
|
298
|
-
stopUpdating:
|
|
299
|
-
isUpdating:
|
|
298
|
+
stopUpdating: W,
|
|
299
|
+
isUpdating: z
|
|
300
300
|
} = De(), L = (o, T, l) => {
|
|
301
301
|
var ee;
|
|
302
|
-
const
|
|
302
|
+
const B = Object.fromEntries(
|
|
303
303
|
Object.entries(T).filter(([, M]) => M !== void 0)
|
|
304
304
|
);
|
|
305
|
-
if (Object.keys(
|
|
305
|
+
if (Object.keys(B).length === 0) {
|
|
306
306
|
(ee = l == null ? void 0 : l.onSuccess) == null || ee.call(l);
|
|
307
307
|
return;
|
|
308
308
|
}
|
|
309
|
-
const N = Object.keys(
|
|
309
|
+
const N = Object.keys(B), K = N.length === 1 ? N[0] : void 0;
|
|
310
310
|
i(o, K), V(
|
|
311
311
|
{
|
|
312
312
|
resourceId: o,
|
|
313
|
-
data:
|
|
313
|
+
data: B
|
|
314
314
|
},
|
|
315
315
|
{
|
|
316
316
|
onSuccess: () => {
|
|
317
317
|
var M;
|
|
318
|
-
|
|
318
|
+
W(o, K), (M = l == null ? void 0 : l.onSuccess) == null || M.call(l);
|
|
319
319
|
},
|
|
320
320
|
onError: () => {
|
|
321
321
|
var M;
|
|
322
|
-
|
|
322
|
+
W(o, K), (M = l == null ? void 0 : l.onError) == null || M.call(l);
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
325
|
);
|
|
326
|
-
},
|
|
326
|
+
}, Y = (o) => {
|
|
327
327
|
m(o), y(o, {
|
|
328
328
|
onSettled: () => m(null)
|
|
329
329
|
});
|
|
330
330
|
}, H = (o) => {
|
|
331
331
|
A(o);
|
|
332
|
-
},
|
|
332
|
+
}, $ = (o) => {
|
|
333
333
|
R(o);
|
|
334
|
-
},
|
|
334
|
+
}, J = (o) => {
|
|
335
335
|
a(o), p(!0);
|
|
336
|
-
},
|
|
336
|
+
}, Z = (o) => {
|
|
337
337
|
u(o);
|
|
338
|
-
},
|
|
338
|
+
}, q = () => {
|
|
339
339
|
u(null);
|
|
340
340
|
}, k = ({
|
|
341
341
|
title: o,
|
|
@@ -364,19 +364,19 @@ function Nt({ searchQuery: t }) {
|
|
|
364
364
|
)
|
|
365
365
|
] }) }) : /* @__PURE__ */ r("div", { className: "flex h-full flex-1 flex-col", children: [
|
|
366
366
|
/* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5", children: I.length === 0 ? /* @__PURE__ */ r("div", { className: "rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center", children: [
|
|
367
|
-
/* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(
|
|
367
|
+
/* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(Qe, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
|
|
368
368
|
/* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: t ? "No visuals found" : "No visuals yet" }),
|
|
369
369
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t ? "Try adjusting your search" : 'Click "New" above to add your first visual' })
|
|
370
370
|
] }) : I.map((o) => /* @__PURE__ */ e(
|
|
371
371
|
wt,
|
|
372
372
|
{
|
|
373
373
|
visual: o,
|
|
374
|
-
onAddVisual:
|
|
374
|
+
onAddVisual: $,
|
|
375
375
|
onOpenVisual: H,
|
|
376
|
-
onEditDetails:
|
|
376
|
+
onEditDetails: Z,
|
|
377
377
|
onDeleteClick: j,
|
|
378
|
-
onDuplicateVisual:
|
|
379
|
-
onShareVisual:
|
|
378
|
+
onDuplicateVisual: Y,
|
|
379
|
+
onShareVisual: J,
|
|
380
380
|
isDeleting: C,
|
|
381
381
|
isDuplicating: v === o.id,
|
|
382
382
|
formatDate: U
|
|
@@ -400,9 +400,9 @@ function Nt({ searchQuery: t }) {
|
|
|
400
400
|
resourceLabel: "Visual",
|
|
401
401
|
initialTitle: c.title || "",
|
|
402
402
|
initialDescription: c.description || "",
|
|
403
|
-
onClose:
|
|
403
|
+
onClose: q,
|
|
404
404
|
onSave: k,
|
|
405
|
-
isSaving:
|
|
405
|
+
isSaving: z(c.id)
|
|
406
406
|
}
|
|
407
407
|
),
|
|
408
408
|
/* @__PURE__ */ e(
|
|
@@ -456,7 +456,7 @@ function vt({
|
|
|
456
456
|
onDashboardItemClick: v
|
|
457
457
|
}) {
|
|
458
458
|
var V, O;
|
|
459
|
-
const { selectDashboard: m } = ce(), c =
|
|
459
|
+
const { selectDashboard: m } = ce(), c = Xe(t.id), { userContext: u, isLoading: A } = he(), R = ((V = u == null ? void 0 : u.permissions) == null ? void 0 : V.canEdit) ?? !1, b = A || !R, S = () => {
|
|
460
460
|
m(t), d(t.id), v == null || v(t.id);
|
|
461
461
|
}, E = (y) => {
|
|
462
462
|
y.currentTarget === y.target && (y.key === "Enter" || y.key === " ") && (y.preventDefault(), S());
|
|
@@ -464,7 +464,7 @@ function vt({
|
|
|
464
464
|
return /* @__PURE__ */ r(
|
|
465
465
|
"div",
|
|
466
466
|
{
|
|
467
|
-
className:
|
|
467
|
+
className: X(
|
|
468
468
|
"group flex cursor-pointer items-start gap-2 rounded-xl border border-transparent px-2.5 py-2.5 transition-[background-color,border-color,box-shadow] hover:border-border/50 hover:bg-muted/35 focus-within:ring-2 focus-within:ring-inset focus-within:ring-ring/40",
|
|
469
469
|
c && "border-border/60 bg-muted/50"
|
|
470
470
|
),
|
|
@@ -500,12 +500,12 @@ function vt({
|
|
|
500
500
|
/* @__PURE__ */ e(
|
|
501
501
|
"div",
|
|
502
502
|
{
|
|
503
|
-
className:
|
|
503
|
+
className: X(
|
|
504
504
|
"flex-shrink-0 transition-opacity",
|
|
505
505
|
c ? "opacity-100" : "opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"
|
|
506
506
|
),
|
|
507
507
|
children: /* @__PURE__ */ e(
|
|
508
|
-
|
|
508
|
+
Ze,
|
|
509
509
|
{
|
|
510
510
|
dashboard: t,
|
|
511
511
|
isDeleting: f,
|
|
@@ -542,45 +542,45 @@ function Ct(t) {
|
|
|
542
542
|
(n) => n.actions.selectDashboard
|
|
543
543
|
), y = te(
|
|
544
544
|
(n) => n.actions.clearSelectedDashboard
|
|
545
|
-
), { tokenProps: C, id: I } =
|
|
545
|
+
), { tokenProps: C, id: I } = qe(), {
|
|
546
546
|
resources: U,
|
|
547
547
|
isLoading: j,
|
|
548
548
|
isError: F,
|
|
549
549
|
updateResource: i,
|
|
550
|
-
deleteResource:
|
|
551
|
-
duplicateResource:
|
|
550
|
+
deleteResource: W,
|
|
551
|
+
duplicateResource: z,
|
|
552
552
|
isDeleting: L
|
|
553
553
|
} = Re(() => {
|
|
554
554
|
m(!1);
|
|
555
555
|
const n = c == null ? void 0 : c.id;
|
|
556
556
|
u(null), (V == null ? void 0 : V.id) === n && (!(C != null && C.dashboard_id) && !I ? y() : E && E.id !== n && O(E));
|
|
557
|
-
}), { userContext:
|
|
557
|
+
}), { userContext: Y } = he(), H = ((me = Y == null ? void 0 : Y.permissions) == null ? void 0 : me.canCreateDashboard) ?? !1, $ = U.filter(
|
|
558
558
|
(n) => {
|
|
559
559
|
var _, g;
|
|
560
560
|
return ((_ = n == null ? void 0 : n.title) == null ? void 0 : _.toLowerCase().includes(f.toLowerCase())) || ((g = n == null ? void 0 : n.description) == null ? void 0 : g.toLowerCase().includes(f.toLowerCase()));
|
|
561
561
|
}
|
|
562
|
-
),
|
|
562
|
+
), J = (n) => new Date(n).toLocaleDateString("en-US", {
|
|
563
563
|
month: "short",
|
|
564
564
|
day: "numeric",
|
|
565
565
|
year: "numeric"
|
|
566
|
-
}),
|
|
566
|
+
}), Z = (n) => {
|
|
567
567
|
p == null || p(n);
|
|
568
|
-
},
|
|
568
|
+
}, q = (n) => {
|
|
569
569
|
u(n), m(!0);
|
|
570
570
|
}, k = () => {
|
|
571
|
-
c &&
|
|
571
|
+
c && W(c.id);
|
|
572
572
|
}, o = (n) => {
|
|
573
|
-
R(n),
|
|
573
|
+
R(n), z(n, {
|
|
574
574
|
onSettled: () => R(null)
|
|
575
575
|
});
|
|
576
576
|
}, {
|
|
577
577
|
startUpdating: T,
|
|
578
578
|
stopUpdating: l,
|
|
579
|
-
isUpdating:
|
|
579
|
+
isUpdating: B
|
|
580
580
|
} = De(), N = (n, _, g) => {
|
|
581
581
|
var fe;
|
|
582
582
|
const se = Object.fromEntries(
|
|
583
|
-
Object.entries(_).filter(([,
|
|
583
|
+
Object.entries(_).filter(([, G]) => G !== void 0)
|
|
584
584
|
);
|
|
585
585
|
if (Object.keys(se).length === 0) {
|
|
586
586
|
(fe = g == null ? void 0 : g.onSuccess) == null || fe.call(g);
|
|
@@ -594,12 +594,12 @@ function Ct(t) {
|
|
|
594
594
|
},
|
|
595
595
|
{
|
|
596
596
|
onSuccess: () => {
|
|
597
|
-
var
|
|
598
|
-
l(n, ae), (
|
|
597
|
+
var G;
|
|
598
|
+
l(n, ae), (G = g == null ? void 0 : g.onSuccess) == null || G.call(g);
|
|
599
599
|
},
|
|
600
600
|
onError: () => {
|
|
601
|
-
var
|
|
602
|
-
l(n, ae), (
|
|
601
|
+
var G;
|
|
602
|
+
l(n, ae), (G = g == null ? void 0 : g.onError) == null || G.call(g);
|
|
603
603
|
}
|
|
604
604
|
}
|
|
605
605
|
);
|
|
@@ -623,22 +623,22 @@ function Ct(t) {
|
|
|
623
623
|
});
|
|
624
624
|
};
|
|
625
625
|
return j ? /* @__PURE__ */ e(Ie, {}) : F ? /* @__PURE__ */ e(yt, { onRetry: () => window.location.reload() }) : /* @__PURE__ */ r("div", { className: "flex h-full flex-1 flex-col", children: [
|
|
626
|
-
/* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5", children:
|
|
626
|
+
/* @__PURE__ */ e("div", { className: "flex flex-1 basis-0 flex-col gap-1.5 overflow-y-auto px-0.5", children: $.length === 0 ? /* @__PURE__ */ r("div", { className: "rounded-xl border border-dashed border-border/60 bg-muted/20 px-4 py-8 text-center", children: [
|
|
627
627
|
/* @__PURE__ */ e("div", { className: "mb-3", children: /* @__PURE__ */ e(ke, { className: "mx-auto h-12 w-12 text-muted-foreground/50" }) }),
|
|
628
628
|
/* @__PURE__ */ e("h3", { className: "mb-1 font-medium text-foreground", children: f ? "No dashboards found" : "No dashboards yet" }),
|
|
629
629
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: f ? "Try adjusting your search" : H ? 'Click "New" above to add your first dashboard' : "No dashboards have been shared with you yet" })
|
|
630
|
-
] }) :
|
|
630
|
+
] }) : $.map((n) => /* @__PURE__ */ e(
|
|
631
631
|
vt,
|
|
632
632
|
{
|
|
633
633
|
dashboard: n,
|
|
634
634
|
isDeleting: L,
|
|
635
635
|
isDuplicating: A === n.id,
|
|
636
|
-
onLoadDashboard:
|
|
636
|
+
onLoadDashboard: Z,
|
|
637
637
|
onEditDetails: ee,
|
|
638
|
-
onDeleteClick:
|
|
638
|
+
onDeleteClick: q,
|
|
639
639
|
onDuplicateDashboard: o,
|
|
640
640
|
onShareDashboard: K,
|
|
641
|
-
formatDate:
|
|
641
|
+
formatDate: J,
|
|
642
642
|
onDashboardItemClick: a
|
|
643
643
|
},
|
|
644
644
|
n.id
|
|
@@ -698,7 +698,7 @@ function Ct(t) {
|
|
|
698
698
|
initialDescription: b.description || "",
|
|
699
699
|
onClose: M,
|
|
700
700
|
onSave: Me,
|
|
701
|
-
isSaving:
|
|
701
|
+
isSaving: B(b.id)
|
|
702
702
|
}
|
|
703
703
|
)
|
|
704
704
|
] });
|
|
@@ -785,7 +785,7 @@ function Ot({
|
|
|
785
785
|
onDashboardItemClick: d,
|
|
786
786
|
variant: a = "inline"
|
|
787
787
|
}) {
|
|
788
|
-
var l,
|
|
788
|
+
var l, B;
|
|
789
789
|
const h = re(
|
|
790
790
|
(N) => N.isDashboardEditing
|
|
791
791
|
), [D, s] = x(!1), [w, v] = x(""), [m, c] = x(!1), { currentUser: u, userContext: A } = he(), R = ((l = A == null ? void 0 : A.permissions) == null ? void 0 : l.canCreateDashboard) ?? !1, { onCreateSuccess: b } = at({
|
|
@@ -800,11 +800,11 @@ function Ot({
|
|
|
800
800
|
(N) => {
|
|
801
801
|
s(!1), N && (S(N), E(N));
|
|
802
802
|
}
|
|
803
|
-
), U = a === "overlay", j = h ? "New Visual" : "New", F = h ? "New Visual" : "New Dashboard", i = h ? "Search visuals..." : "Search dashboards...",
|
|
803
|
+
), U = a === "overlay", j = h ? "New Visual" : "New", F = h ? "New Visual" : "New Dashboard", i = h ? "Search visuals..." : "Search dashboards...", W = h ? "Collapse visuals panel" : "Collapse dashboard panel", z = ((u == null ? void 0 : u.name) ?? "").trim(), L = ((u == null ? void 0 : u.email) ?? "").trim(), H = z && z.toLowerCase() !== "undefined" ? z : L || "Current user", $ = ((B = H.charAt(0)) == null ? void 0 : B.toUpperCase()) || "?", J = L && L.toLowerCase() !== "undefined" ? L : "", Z = xt(f, {
|
|
804
804
|
enabled: t && U
|
|
805
|
-
}),
|
|
805
|
+
}), q = X(
|
|
806
806
|
"flex h-full flex-col border-r border-border/60 bg-background",
|
|
807
|
-
U ?
|
|
807
|
+
U ? X(
|
|
808
808
|
"absolute inset-y-0 left-0 z-[51] w-60 overflow-hidden shadow-lg transition-transform duration-300 ease-in-out",
|
|
809
809
|
t ? "translate-x-0" : "pointer-events-none -translate-x-full"
|
|
810
810
|
) : "w-full max-w-[17rem] min-w-[11rem] overflow-hidden",
|
|
@@ -819,7 +819,7 @@ function Ot({
|
|
|
819
819
|
}
|
|
820
820
|
});
|
|
821
821
|
};
|
|
822
|
-
return /* @__PURE__ */ e(le, { children: (!U || t) && /* @__PURE__ */ r("div", { ref:
|
|
822
|
+
return /* @__PURE__ */ e(le, { children: (!U || t) && /* @__PURE__ */ r("div", { ref: Z, className: q, children: [
|
|
823
823
|
/* @__PURE__ */ r("div", { className: "border-b border-border/60 bg-background", children: [
|
|
824
824
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between px-3 py-2", children: [
|
|
825
825
|
/* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e("h2", { className: "whitespace-nowrap text-sm font-semibold", children: h ? "Visuals" : "Dashboards" }) }),
|
|
@@ -856,7 +856,7 @@ function Ot({
|
|
|
856
856
|
variant: "outline",
|
|
857
857
|
className: "h-8 w-8 rounded-md border-border/60 bg-background p-0.5 text-muted-foreground hover:bg-muted/35 hover:text-foreground",
|
|
858
858
|
onClick: f,
|
|
859
|
-
"aria-label":
|
|
859
|
+
"aria-label": W,
|
|
860
860
|
children: /* @__PURE__ */ e(dt, { className: "h-3.5 w-3.5" })
|
|
861
861
|
}
|
|
862
862
|
)
|
|
@@ -884,10 +884,10 @@ function Ot({
|
|
|
884
884
|
) }),
|
|
885
885
|
u && /* @__PURE__ */ e(lt, { children: /* @__PURE__ */ e("div", { className: "border-t border-border/60 bg-muted/20 px-3 py-2.5", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
886
886
|
/* @__PURE__ */ r(ct, { children: [
|
|
887
|
-
/* @__PURE__ */ e(ut, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "flex h-7 w-7 cursor-default items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ e("span", { className: "text-xs font-medium text-primary", children:
|
|
887
|
+
/* @__PURE__ */ e(ut, { asChild: !0, children: /* @__PURE__ */ e("div", { className: "flex h-7 w-7 cursor-default items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ e("span", { className: "text-xs font-medium text-primary", children: $ }) }) }),
|
|
888
888
|
/* @__PURE__ */ e(ht, { side: "top", className: "max-w-xs", children: /* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
889
889
|
/* @__PURE__ */ e("div", { className: "font-medium", children: H }),
|
|
890
|
-
|
|
890
|
+
J && /* @__PURE__ */ e("div", { className: "text-xs text-muted-foreground", children: J }),
|
|
891
891
|
u.role && /* @__PURE__ */ r("div", { className: "text-xs text-muted-foreground", children: [
|
|
892
892
|
"Role: ",
|
|
893
893
|
mt(u.role.replace(/_/g, " "))
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";const e=require("./index-BoJEr_9F.js"),t=require("react/jsx-runtime"),R=require("./use-visual-utils-Jv4hWSLm.js"),C=require("react");/**
|
|
2
|
+
* @license lucide-react v0.453.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const pe=e.createLucideIcon("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
7
|
+
* @license lucide-react v0.453.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ne=e.createLucideIcon("Library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);/**
|
|
12
|
+
* @license lucide-react v0.453.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const de=e.createLucideIcon("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
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
|
+
*/const W=e.createLucideIcon("Save",[["path",{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",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);function J(){var n,v;const l=e.useEditorStore(b=>b.card),r=e.useEditorStore(b=>b.frame),d=C.useMemo(()=>e.findCustomVisualConfigCard(r,l),[r,l]),{manifest:i}=e.useCustomVisual(((n=d==null?void 0:d.customCardPreferences)==null?void 0:n.url)||""),m=C.useMemo(()=>{var b;return(b=i==null?void 0:i.visuals)==null?void 0:b.find(h=>{var y;return h.name===((y=d==null?void 0:d.customCardPreferences)==null?void 0:y.componentName)})},[i,(v=d==null?void 0:d.customCardPreferences)==null?void 0:v.componentName]),f=e.resolveMultiInputType(d,m),p=C.useMemo(()=>e.getCustomVisualInputCards({frame:r,configCard:d,isMultiInputVisual:f==="multiple"}),[r,d,f]),x=C.useMemo(()=>{const b=p.findIndex(h=>(h==null?void 0:h.id)===l.id);return b<0?-1:e.getSlotIndexForCard(l,b)},[p,l]);return C.useMemo(()=>!d||f!=="multiple"||x<0?l.type:e.getEffectiveCardTypeForSlot(l,x,m==null?void 0:m.slots)??l.type,[d,f,x,l,m==null?void 0:m.slots])}function xe({type:l,isLinked:r,className:d,showLabel:i=!1,showLocal:m=!1}){const f=e.useDashboardStore(E=>E.selectedFrameId),p=e.useManagementStore(E=>E.selectedVisual),x=e.useEditorStore(E=>E.frame);let n;if(l)n=l;else if(r!==void 0)n=r?"linked":"library";else if(!!!(x!=null&&x.visualId||p!=null&&p.id)&&f)n="local";else if(p&&!f)n="library";else if(x!=null&&x.visualId&&f)n="linked";else if(p!=null&&p.id&&f)n="library";else return null;if(n==="local"&&!m)return null;const v={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",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",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"},b={local:"Local to this dashboard: Changes made here only affect this dashboard copy.",linked:"Linked to library: Changes made here update the library visual and all linked instances.",library:"Library visual: Share and reuse this visual across multiple dashboards."},h={local:"border-slate-200 bg-slate-50 text-slate-900 dark:border-slate-700 dark:bg-slate-900 dark:text-slate-100",linked:"border-purple-200 bg-purple-50 text-purple-900 dark:border-purple-800 dark:bg-purple-950 dark:text-purple-100",library:"border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100"},y={local:"fill-slate-50 dark:fill-slate-900",linked:"fill-purple-50 dark:fill-purple-950",library:"fill-blue-50 dark:fill-blue-950"},j={local:t.jsx("span",{className:"h-2 w-2 rounded-full bg-current/70"}),linked:t.jsx(de,{className:"h-3.5 w-3.5"}),library:t.jsx(ne,{className:"h-3.5 w-3.5"})},L={local:"Local",linked:"Linked",library:"Library"};return t.jsx(e.TooltipProvider,{children:t.jsxs(e.Tooltip,{delayDuration:300,children:[t.jsx(e.TooltipTrigger,{asChild:!0,children:t.jsxs(e.Badge,{variant:"outline",className:e.cn("cursor-help select-none transition-all",v[n],d),children:[j[n],i&&t.jsx("span",{className:"ml-1 text-xs font-medium leading-none",children:L[n]})]})}),t.jsxs(e.TooltipContent,{side:"bottom",className:e.cn("max-w-xs",h[n]),children:[t.jsx(e.TooltipArrow,{className:y[n]}),t.jsx("p",{children:b[n]})]})]})})}function he(l,r){return{...l,sql:"",python:"",config:void 0,customCfg:"",preferences:{},interactionConfig:void 0,linkedInteractionTargetOverrides:void 0,customCardPreferences:r?l.customCardPreferences:void 0,type:r?l.type:"bar"}}function fe({className:l,variant:r="outline"}){var x;const{setCardSql:d}=e.useEditorActions();e.useEditorStore(n=>n.frame);const i=e.useEditorStore(n=>n.card);R.useRemoteChartStore(((x=i.customCardPreferences)==null?void 0:x.url)||""),e.useEditorStore(n=>n.selectedSchemaName),e.useEditorStore(n=>n.selectedDatamodelId),e.useEditorStore(n=>n.selectedDatabaseName),e.useEditorStore(n=>n.selectedTableName),e.useEditorStore(n=>n.selectedConnectionId),e.useEditorStore(n=>n.isShowingVisual),i.sql;const m=e.useEditorStore(n=>n.onSave),{getUpdatedFrame:f}=R.useVisualUtils();function p(){const n=f();m==null||m(n)}return t.jsxs(e.Button,{onClick:p,className:e.cn("h-8",l),size:"sm",variant:r,children:[t.jsx(e.Check,{className:"mr-2 size-4 font-bold"}),"Accept"]})}function be({className:l,variant:r="default"}){const d=e.useQueryClient(),[i,m]=C.useState(!1),f=e.useDashboardStore(y=>y.actions.setIsDashboardPanelOpen),{setIsVisualEditing:p}=e.useDashboardActions(),{getUpdatedFrame:x}=R.useVisualUtils(),n=e.useSelectedVisual(),v=e.useEditorStore(y=>y.frame),b=e.useUpdateVisualMutation(),h=()=>{const y=x(),j=(v==null?void 0:v.visualId)||(n==null?void 0:n.id);if(!j){e.ue.error("No visual to save");return}m(!0),b.mutate({visualId:j,data:{frameObject:y}},{onSuccess:()=>{m(!1),f(!0),e.ue.success("Visual updated successfully"),d.invalidateQueries({queryKey:["resource-by-id","visual",j],exact:!0})},onError:()=>{m(!1),e.ue.error("Failed to update visual")}})};return t.jsxs(e.Button,{onClick:h,className:e.cn("h-8",l),size:"sm",variant:r,children:[i&&t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving"]}),!i&&t.jsxs(t.Fragment,{children:[t.jsx(W,{className:"mr-2 size-4 font-bold"}),"Save to Library"]})]})}function ye({className:l}){const r=e.useQueryClient(),[d,i]=C.useState(!1),m=e.useSelectedVisual(),f=e.useEditorStore(y=>y.frame),p=e.useDashboardStore(y=>y.selectedSheetId),{updateFrame:x,setIsVisualEditing:n}=e.useDashboardActions(),{getUpdatedFrame:v}=R.useVisualUtils(),b=e.useUpdateVisualMutation(),h=async()=>{if(!p){e.ue.error("No sheet selected");return}const y=(f==null?void 0:f.visualId)||(m==null?void 0:m.id);if(!y){e.ue.error("No visual to update");return}i(!0);try{const j=v();await b.mutateAsync({visualId:y,data:{frameObject:j}});const L={...j,visualId:y};x(p,L),r.invalidateQueries({queryKey:["visuals"]}),r.invalidateQueries({queryKey:["visual",y]}),e.ue.success("Saved to library and applied locally"),setTimeout(()=>{n(!1)},300)}catch(j){console.error("Failed to save and apply:",j),e.ue.error("Failed to save and apply changes")}finally{i(!1)}};return t.jsx(e.Button,{onClick:h,className:e.cn("h-8",l),size:"sm",variant:"default",disabled:d,children:d?t.jsxs(t.Fragment,{children:[t.jsx(e.LoaderCircle,{className:"mr-2 size-4 animate-spin font-bold"})," Saving..."]}):t.jsxs(t.Fragment,{children:[t.jsx(W,{className:"mr-2 size-4 font-bold"}),"Save & Apply"]})})}function ge({className:l}){const{setTempQueryData:r,setSqlGen:d}=e.useEditorActions(),i=e.useQueryClient(),m=e.useEditorStore(h=>h.tempQueryData),f=e.useEditorStore(h=>h.onClose),p=e.useEditorStore(h=>h.card),x=J(),n=C.useMemo(()=>x!==p.type?{...p,type:x}:p,[p,x]),{queryKey:v}=e.useDashboardCardQuery(n);function b(){if(m){const{queryKey:h,queryData:y}=m;h&&y&&i.setQueryData(h,y)}d({}),f==null||f()}return t.jsxs(e.Button,{onClick:b,className:e.cn("h-8",l),size:"sm",variant:"outline",children:[t.jsx(e.X,{className:"mr-2 size-4"}),"Close"]})}function Ce({label:l="Clear",variant:r="secondary",className:d}={}){const{setTempQueryData:i}=e.useEditorActions(),m=e.useQueryClient(),f=e.useEditorStore(a=>a.tempQueryData),p=e.useEditorStore(a=>a.card),x=J(),n=C.useMemo(()=>x!==p.type?{...p,type:x}:p,[p,x]),{queryKey:v}=e.useDashboardCardQuery(n),{setCardSql:b,setSqlGen:h,setCardPython:y,setCardCustomCfg:j,setCardPreferences:L,clearQueryConfig:E,setCardConfig:K,setCardType:P,setFrame:z,setCard:M,setActiveTabCardId:H}=e.useEditorActions();function q(){var F,U,_,I;const a=m.getQueryData(v);f!=null&&f.queryData||i({queryKey:v,queryData:a}),m.setQueryData(v,null),m.removeQueries({queryKey:v,exact:!0}),b(""),h({}),E(),K(void 0),y(""),j(""),L({});const k=e.useEditorStore.getState().frame,O=e.useEditorStore.getState().card,T=e.findCustomVisualConfigCard(k,O),D=((F=T==null?void 0:T.customCardPreferences)==null?void 0:F.visualType)==="multiple"||!!((U=T==null?void 0:T.customCardPreferences)!=null&&U.dataInputCardIds)||(((_=T==null?void 0:T.customCardPreferences)==null?void 0:_.minInputs)||0)>1||(((I=T==null?void 0:T.customCardPreferences)==null?void 0:I.maxInputs)||0)>1,V=he(O,D);z({...k,cards:k.cards.map(B=>B.id===V.id?V:B)}),H(V.id),M(V),D||P("bar")}return t.jsxs(e.Button,{onClick:q,className:e.cn("h-8",d),size:"sm",variant:r,children:[t.jsx(e.X,{className:"mr-2 size-3.5"}),l]})}function oe(l){const{control:r,onChange:d}=l;return t.jsxs("div",{className:"space-y-1",children:[t.jsx(e.Label,{className:"text-xs",children:"Label"}),t.jsxs("div",{className:"relative",children:[t.jsx(e.Input,{className:"pr-40",value:r.label,placeholder:"Control label",onChange:i=>d(i.target.value)}),t.jsx(e.Badge,{variant:"outline",className:"pointer-events-none absolute right-3 top-1/2 -translate-y-1/2 text-xs",children:e.getFriendlyTypeOption(r.type).label})]})]})}function ve(l){const{currentStep:r,labels:d}=l;return t.jsx("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:t.jsx("div",{className:"flex flex-wrap items-center gap-2 sm:gap-3",children:d.map((i,m)=>{const f=m+1,p=f===r,x=f<r;return t.jsxs(C.Fragment,{children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:e.cn("flex h-7 w-7 items-center justify-center rounded-full border text-[11px] font-semibold",p?"border-primary bg-primary text-primary-foreground":x?"border-primary/25 bg-primary/10 text-primary":"border-border bg-muted/30 text-muted-foreground"),children:f}),t.jsx("span",{className:e.cn("text-xs font-medium",p?"text-foreground":"text-muted-foreground"),children:i})]}),m<d.length-1?t.jsx("span",{className:"h-px w-5 bg-border/80 sm:w-8","aria-hidden":"true"}):null]},i)})})})}function Y(l){const{secondary:r,tertiary:d,primary:i}=l;return t.jsxs("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:[r,d,i]})}function je(l){const{control:r,scope:d,detail:i}=l;return t.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-border/40 bg-muted/20 p-3",children:[t.jsx(e.CircleCheck,{className:"mt-0.5 h-4 w-4 text-emerald-600"}),t.jsxs("div",{className:"space-y-1",children:[t.jsx("div",{className:"text-sm font-medium",children:r.label}),t.jsxs("div",{className:"text-xs text-muted-foreground",children:[e.getFriendlyTypeOption(r.type).label," ·"," ",e.getControlOptionPreview(r)," ·"," ",e.getPlacementLabel(d,r.placement)]}),i?t.jsx("div",{className:"text-xs text-muted-foreground",children:i}):null]})]})}function G(l){const{title:r,children:d,className:i}=l;return t.jsxs("div",{className:e.cn("space-y-1 rounded-xl border border-border/40 bg-muted/20 p-3",i),children:[t.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:r}),d]})}function Se(l){const{createdReference:r,description:d}=l;return t.jsxs(G,{title:"SQL cards",className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md border border-border/30 bg-muted/40 px-3 py-2",children:[t.jsx("code",{className:"min-w-0 truncate text-xs",children:r}),t.jsx(e.CopyButton,{text:r,ariaLabel:"Copy SQL control reference"})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:d})]})}function le(l){const{control:r,defaultValue:d,availableFieldChoices:i,availableMetricChoices:m,onControlChange:f,onLabelChange:p,onDefaultValueChange:x,onBack:n,onNext:v,nextDisabled:b}=l;return t.jsxs("div",{className:"space-y-3",children:[t.jsx(oe,{control:r,onChange:p}),t.jsx(e.ControlDefinitionOptionsEditor,{control:r,availableFieldChoices:i,availableMetricChoices:m,onChange:f}),t.jsx(e.ControlDefaultValueEditor,{control:r,value:d,onChange:x,allowCardDefault:!0,hint:"This is the value viewers will see first."}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:n,children:"Back"}),primary:t.jsx(e.Button,{type:"button",onClick:v,disabled:b,children:"Next"})})]})}function re(l){const{control:r,scope:d,createdReference:i,explorerContent:m,sqlDescription:f,summaryDetail:p,onBack:x,onCancel:n,onDone:v}=l;return t.jsxs("div",{className:"space-y-4",children:[t.jsx(je,{control:r,scope:d,detail:p}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{className:"text-sm font-medium",children:"How cards use this control"}),m,t.jsx(Se,{createdReference:i,description:f})]}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:x,children:"Back"}),tertiary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:n,children:"Cancel"}),primary:t.jsx(e.Button,{type:"button",onClick:v,children:"Done"})})]})}function Ne(l){const r=e.createBlankControl(l.scope,l.existingControls,l.reservedIds),d=l.type===r.type?{...r,label:e.DEFAULT_LABEL_BY_TYPE[l.type]}:{...e.applyControlTypeChange({controls:[{...r,label:e.DEFAULT_LABEL_BY_TYPE[l.type]}],controlId:r.id,nextType:l.type}).controls[0],label:e.DEFAULT_LABEL_BY_TYPE[l.type]};return{step:2,control:d,defaultValue:e.getDefaultValueForType(d,void 0)}}function ke({scope:l,controls:r,reservedControlIds:d,defaultValues:i,onChange:m,emptyMessage:f,initialCreateFlow:p=!1,usageByControlId:x,availableFieldChoices:n,availableMetricChoices:v,structuralParticipants:b,structuralParticipantIdsByControlId:h,card:y,onCreateFlowActiveChange:j,onCreateFlowComplete:L}){const E=C.useMemo(()=>new Set(d||[]),[d]),K=e.getPlacementOptionsForScope(l),P=e.getDefaultPlacement(l),[z,M]=C.useState(null),[H,q]=C.useState(null),[a,k]=C.useState(()=>p?{step:1,control:e.createBlankControl(l,r,Array.from(E))}:null),O=C.useRef(p),T=C.useMemo(()=>e.getFriendlyControlTypeOptions({scope:l,card:y}),[y,l]),D=C.useCallback(s=>l==="dashboard"&&(s==="field_selector"||s==="metric_selector"),[l]),V=C.useMemo(()=>a?e.getEligibleParticipantsForStructuralControl(b||[],a.control.type):[],[a,b]),F=C.useMemo(()=>{if(!a)return{fields:n||[],metrics:v||[]};if(!D(a.control.type))return{fields:n||[],metrics:v||[]};const s=a.selectedCardIds||[],u=e.getCompatibleStructuralChoiceCatalog({controlType:a.control.type,participants:b||[],selectedCardIds:s});return{fields:a.control.type==="field_selector"?u.choices.map(c=>({option:c,target:u.fieldTargetMap[c.value]})):[],metrics:a.control.type==="metric_selector"?u.choices.map(c=>({option:c,target:u.metricTargetMap[c.value]})):[]}},[n,v,a,D,b]);C.useEffect(()=>{j==null||j(!!a)},[a,j]),C.useEffect(()=>{const s=p&&!O.current;O.current=p,s&&(k({step:1,control:e.createBlankControl(l,r,Array.from(E))}),q(null),M(null))},[r,p,E,l]);const U=s=>{if(!D(s.type))return{fields:n||[],metrics:v||[]};const u=(h==null?void 0:h[s.id])||[];if(u.length===0)return{fields:n||[],metrics:v||[]};const c=e.getCompatibleStructuralChoiceCatalog({controlType:s.type,participants:b||[],selectedCardIds:u});return{fields:s.type==="field_selector"?c.choices.map(g=>({option:g,target:c.fieldTargetMap[g.value]})):[],metrics:s.type==="metric_selector"?c.choices.map(g=>({option:g,target:c.metricTargetMap[g.value]})):[]}},_=s=>{if(!D(s.control.type))return{nextControl:s.control,cardBindingsById:void 0};const u=(h==null?void 0:h[s.control.id])||[],c=e.getCompatibleStructuralChoiceCatalog({controlType:s.control.type,participants:b||[],selectedCardIds:s.nextSelectedCardIds}),g=e.reconcileStructuralControlChoices({control:s.control,choices:c.choices}),S=Object.fromEntries(u.filter(o=>!s.nextSelectedCardIds.includes(o)).map(o=>[o,void 0]));return s.nextSelectedCardIds.length>0&&g.source.kind==="manual"&&g.source.options.length>0&&Object.assign(S,e.buildStructuralControlBindingsForParticipants({control:g,participants:b||[],selectedCardIds:s.nextSelectedCardIds})),{nextControl:g,cardBindingsById:S}},I=C.useCallback((s,u=i,c={type:"update"})=>{m(s,u,c)},[i,m]),B=(s,u)=>{const c=r.find(w=>w.id===s);let g=r.map(w=>w.id!==s?w:u(w));const S=g.find(w=>w.id===s);let o,N;if(S&&l==="dashboard"&&(S.type==="field_selector"||S.type==="metric_selector")){const w=(h==null?void 0:h[S.id])||[],A=_({control:S,nextSelectedCardIds:w});g=g.map(ae=>ae.id===s?A.nextControl:ae),o=A.cardBindingsById,N=[S.id]}else if(c&&l==="dashboard"&&(c.type==="field_selector"||c.type==="metric_selector")){const w=(h==null?void 0:h[c.id])||[];o=Object.fromEntries(w.map(A=>[A,void 0])),N=[c.id]}I(g,i,{type:"update",cardBindingsById:o,affectedBindingControlIds:N})},ie=(s,u)=>{const c=u.trim();if(c.length===0||c===s||E.has(c)||r.some(o=>o.id===c&&o.id!==s))return;const g=r.map(o=>o.id===s?{...o,id:c}:o);if(!i){I(g,void 0,{type:"rename",oldId:s,newId:c});return}const S={...i};Object.prototype.hasOwnProperty.call(S,s)&&(S[c]=S[s],delete S[s]),I(g,S,{type:"rename",oldId:s,newId:c})},ce=s=>{const u=r.filter(g=>g.id!==s);if(!i){I(u,void 0,{type:"remove",controlId:s});return}const c={...i};delete c[s],I(u,c,{type:"remove",controlId:s})},ue=C.useCallback(()=>{k({step:1,control:e.createBlankControl(l,r,Array.from(E))}),q(null),M(null)},[r,E,l]),Q=s=>{k(u=>u&&{...u,control:s(u.control)})},Z=s=>{k(u=>u&&{...u,defaultValue:s})},X=(()=>{if(!a)return!1;if(a.step===2&&D(a.control.type))return(a.selectedCardIds||[]).length>0;if(a.step!==2&&a.step!==3||!a.control.label.trim())return!1;const u=e.ensureManualSource(a.control);return u.source.kind==="manual"&&(e.needsManualOptions(u)&&u.source.options.length===0||u.source.options.some(g=>g.label.trim().length===0||g.value.trim().length===0))?!1:e.hasConcreteDefaultValue(e.getDefaultValueForType(u,a.defaultValue))})(),ee=()=>{var o;if(!a)return;const s=e.ensureManualSource(a.control),u=e.deriveUniqueControlId({label:s.label,fallbackId:s.id,existingControls:r,reservedIds:Array.from(E)}),c={...s,id:u},g=l==="dashboard"&&(c.type==="field_selector"||c.type==="metric_selector")&&((o=a.selectedCardIds)!=null&&o.length)?e.buildStructuralControlBindingsForParticipants({control:c,participants:b||[],selectedCardIds:a.selectedCardIds}):void 0,S=e.getDefaultValueForType(c,a.defaultValue);k({step:l==="dashboard"&&(c.type==="field_selector"||c.type==="metric_selector")?4:3,control:c,defaultValue:S,createdControlId:u,selectedCardIds:a.selectedCardIds,cardBindingsById:g})},$=C.useCallback(()=>{k(null)},[]),te=C.useCallback(()=>{if(!(a!=null&&a.createdControlId)){k(null);return}const s=a.control,u=a.createdControlId,c=e.getDefaultValueForType(s,a.defaultValue);i?I([...r,s],{...i,[u]:c},{type:"add",cardBindingsById:a.cardBindingsById}):I([...r,{...s,defaultValue:c}],void 0,{type:"add",cardBindingsById:a.cardBindingsById}),q(u),k(null),L==null||L()},[r,a,i,I,L]),me=a?D(a.control.type)?["Choose type","Select cards","Configure","Finish"]:["Choose type","Configure","Finish"]:[],se=a!=null&&a.createdControlId?`[[param.${a.createdControlId}]]`:a?`[[param.${e.slugifyControlValue(a.control.label)||a.control.id}]]`:"";return t.jsxs("div",{className:"space-y-4",children:[a?t.jsxs("div",{className:"space-y-4 pb-1",children:[t.jsx(ve,{currentStep:a.step,labels:me}),a.step===1&&t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("p",{className:"text-sm font-medium",children:"What kind of input should viewers see?"}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose the viewer experience first. You can fine-tune the details next."}),l==="card"&&(y==null?void 0:y.sql)==null?t.jsx("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]}),t.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:T.map(s=>t.jsxs("button",{type:"button",className:"rounded-xl border border-border/50 bg-muted/20 p-3 text-left transition-colors hover:border-border/70 hover:bg-muted/35",onClick:()=>k(Ne({scope:l,existingControls:r,reservedIds:Array.from(E),type:s.value})),children:[t.jsx("div",{className:"text-sm font-medium",children:s.label}),t.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:s.description})]},s.value))}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:$,children:"Back to controls"})})]}),a.step===2&&D(a.control.type)&&t.jsxs("div",{className:"space-y-3",children:[t.jsxs("div",{className:"space-y-3",children:[t.jsx(oe,{control:a.control,onChange:s=>Q(u=>({...u,label:s}))}),t.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which cards should respond to this shared control."})]}),V.length===0?t.jsx("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."}):t.jsx("div",{className:"space-y-2 rounded-xl bg-muted/20 p-3",children:V.map(s=>{const u=(a.selectedCardIds||[]).includes(s.cardId);return t.jsxs("label",{className:"flex items-start gap-2 text-sm",children:[t.jsx(e.Checkbox,{checked:u,onCheckedChange:c=>k(g=>g&&{...g,selectedCardIds:c===!0?[...g.selectedCardIds||[],s.cardId]:(g.selectedCardIds||[]).filter(S=>S!==s.cardId)})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"font-medium",children:s.title}),t.jsx("div",{className:"text-xs text-muted-foreground",children:a.control.type==="field_selector"?`${s.fieldChoices.length} compatible group-by fields`:`${s.metricChoices.length} compatible metrics`})]})]},s.cardId)})}),t.jsx(Y,{secondary:t.jsx(e.Button,{type:"button",variant:"outline",onClick:()=>k(s=>s&&{...s,step:1,selectedCardIds:[]}),children:"Back"}),primary:t.jsx(e.Button,{type:"button",onClick:()=>k(s=>s&&{...s,step:3}),disabled:!X,children:"Next"})})]}),a.step===2&&!D(a.control.type)&&t.jsx(le,{control:a.control,defaultValue:a.defaultValue,availableFieldChoices:F.fields,availableMetricChoices:F.metrics,onControlChange:s=>Q(()=>s),onLabelChange:s=>Q(u=>({...u,label:s})),onDefaultValueChange:Z,onBack:()=>k(s=>s&&{...s,step:1}),onNext:ee,nextDisabled:!X}),a.step===3&&D(a.control.type)&&t.jsx(le,{control:a.control,defaultValue:a.defaultValue,availableFieldChoices:F.fields,availableMetricChoices:F.metrics,onControlChange:s=>Q(()=>s),onLabelChange:s=>Q(u=>({...u,label:s})),onDefaultValueChange:Z,onBack:()=>k(s=>s&&{...s,step:2}),onNext:ee,nextDisabled:!X}),a.step===3&&!D(a.control.type)&&t.jsx(re,{control:a.control,scope:l,createdReference:se,explorerContent:t.jsx(G,{title:"Explorer cards",children:t.jsxs("p",{className:"text-sm",children:["Open the card and use"," ",t.jsx("span",{className:"font-medium",children:"Settings → Controls"})," ","to choose what this control changes."]})}),sqlDescription:"Reference this control directly in the SQL editor.",onBack:()=>k(s=>s&&{...s,step:2}),onCancel:$,onDone:te}),a.step===4&&D(a.control.type)&&t.jsx(re,{control:a.control,scope:l,createdReference:se,summaryDetail:t.jsxs(t.Fragment,{children:["Used by ",(a.selectedCardIds||[]).length," ","selected card",(a.selectedCardIds||[]).length===1?"":"s"]}),explorerContent:t.jsx(G,{title:"Explorer cards",children:t.jsx("p",{className:"text-sm",children:"Selected cards have been set up to respond to this control automatically."})}),sqlDescription:"SQL cards can still reference this control directly in the SQL editor.",onBack:()=>k(s=>s&&{...s,step:3}),onCancel:$,onDone:te})]}):null,!a&&r.length===0?t.jsx("div",{className:"rounded-md border border-dashed p-3 text-sm text-muted-foreground",children:f}):null,!a&&r.map(s=>{const u=U(s),c=x==null?void 0:x[s.id],g=i&&Object.prototype.hasOwnProperty.call(i,s.id)?i[s.id]:s.defaultValue,S=H===s.id;return t.jsxs("div",{className:"rounded-md border",children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3",children:[t.jsxs("button",{type:"button",className:"flex min-w-0 flex-1 items-start gap-2 text-left",onClick:()=>q(o=>o===s.id?null:s.id),children:[S?t.jsx(e.ChevronDown,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}):t.jsx(e.ChevronRight,{className:"mt-0.5 h-4 w-4 shrink-0 text-muted-foreground"}),t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium",children:s.label||"Untitled control"}),t.jsx(e.Badge,{variant:"outline",className:"text-[11px]",children:e.getFriendlyTypeOption(s.type).label}),t.jsx(e.Badge,{variant:"secondary",className:"text-[11px]",children:e.getPlacementLabel(l,s.placement)})]}),t.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:[e.getControlOptionPreview(s),c!=null&&c.status?` · ${c.status}`:""]})]})]}),t.jsx(e.Button,{type:"button",size:"icon",variant:"ghost",className:"h-8 w-8 shrink-0",onClick:()=>ce(s.id),"aria-label":`Remove ${s.label}`,children:t.jsx(e.Trash2,{className:"h-4 w-4"})})]}),S&&t.jsxs("div",{className:"space-y-4 border-t px-3 py-4",children:[c!=null&&c.helper?t.jsx("div",{className:"rounded-md bg-muted/30 px-3 py-2 text-xs text-muted-foreground",children:c.helper}):null,t.jsxs("div",{className:"grid gap-3 md:grid-cols-3",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Label"}),t.jsx(e.Input,{value:s.label,placeholder:"Control label",onChange:o=>B(s.id,N=>({...N,label:o.target.value}))})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Type"}),t.jsxs(e.Select,{value:s.type,onValueChange:o=>{const N=e.applyControlTypeChange({controls:r,controlId:s.id,nextType:o,defaultValues:i});I(N.controls,N.defaultValues)},children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.getFriendlyControlTypeOptions({scope:l,card:y,includeType:s.type}).map(o=>t.jsx(e.SelectItem,{value:o.value,children:o.label},o.value))})]})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Show in"}),t.jsxs(e.Select,{value:s.placement||P,onValueChange:o=>B(s.id,N=>({...N,placement:o})),children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:K.map(o=>t.jsx(e.SelectItem,{value:o.value,children:o.label},o.value))})]})]})]}),D(s.type)?t.jsx(e.StructuralParticipantSelector,{type:s.type,participants:e.getEligibleParticipantsForStructuralControl(b||[],s.type).map(o=>({cardId:o.cardId,title:o.title,choiceCount:s.type==="field_selector"?o.fieldChoices.length:o.metricChoices.length})),selectedCardIds:(h==null?void 0:h[s.id])||[],onChange:o=>{const N=_({control:s,nextSelectedCardIds:o}),w=r.map(A=>A.id===s.id?N.nextControl:A);I(w,i,{type:"update",cardBindingsById:N.cardBindingsById})}}):null,t.jsx(e.ControlDefinitionOptionsEditor,{control:s,availableFieldChoices:u.fields,availableMetricChoices:u.metrics,onChange:o=>B(s.id,()=>o)}),s.initialValueStrategy==="saved_default"&&t.jsx(e.ControlDefaultValueEditor,{control:s,value:g,allowNoDefault:!0,allowCardDefault:!0,onChange:o=>{if(i){const N={...i};o===void 0?delete N[s.id]:N[s.id]=o,I(r,N);return}B(s.id,N=>({...N,defaultValue:o}))}}),t.jsxs(e.Collapsible,{open:z===s.id,onOpenChange:o=>M(o?s.id:null),children:[t.jsx(e.CollapsibleTrigger,{asChild:!0,children:t.jsxs(e.Button,{type:"button",variant:"ghost",className:"h-auto px-0 text-xs text-muted-foreground hover:bg-transparent",children:[z===s.id?t.jsx(e.ChevronDown,{className:"mr-1 h-4 w-4"}):t.jsx(e.ChevronRight,{className:"mr-1 h-4 w-4"}),"Advanced"]})}),t.jsxs(e.CollapsibleContent,{className:"space-y-3 pt-2",children:[t.jsxs("div",{className:"grid gap-3 md:grid-cols-2",children:[t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Control ID"}),t.jsx(e.ControlIdInput,{controlId:s.id,onCommit:o=>ie(s.id,o)},s.id)]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(e.Label,{className:"text-xs",children:"Initial value"}),t.jsxs(e.Select,{value:s.initialValueStrategy,onValueChange:o=>B(s.id,N=>({...N,initialValueStrategy:o})),children:[t.jsx(e.SelectTrigger,{children:t.jsx(e.SelectValue,{})}),t.jsx(e.SelectContent,{children:e.INITIAL_VALUE_STRATEGY_OPTIONS.map(o=>t.jsx(e.SelectItem,{value:o.value,children:o.label},o.value))})]}),t.jsx("p",{className:"text-[11px] text-muted-foreground",children:e.getInitialValueStrategyHint(s.initialValueStrategy)})]})]}),t.jsx(e.ControlVisibilitySettings,{control:s,onChange:o=>B(s.id,()=>o)})]})]})]})]},s.id)}),!a&&t.jsxs(e.Button,{type:"button",variant:"outline",size:"sm",onClick:ue,children:[t.jsx(e.Plus,{className:"mr-2 h-4 w-4"}),"Add control"]})]})}function Ee(l){const{open:r,onOpenChange:d,initialCreateFlowActive:i=!1}=l,m=r!==void 0,[f,p]=C.useState(!1),[x,n]=C.useState(i),v=m?r:f,b=C.useCallback(j=>{!j&&x||(m||p(j),j||n(!1),d==null||d(j))},[m,x,d]),h=C.useCallback(()=>{m||p(!1),n(!1),d==null||d(!1)},[m,d]);C.useEffect(()=>{v||n(!1)},[v]);const y=C.useCallback(j=>{x&&j.preventDefault()},[x]);return{forceClose:h,handleOpenChange:b,isCreateFlowActive:x,preventPassiveDismissDuringCreate:y,resolvedOpen:v,setIsCreateFlowActive:n}}exports.CircleX=pe;exports.ControlDefinitionListEditor=ke;exports.EditorAcceptButton=fe;exports.EditorCancelButton=ge;exports.EditorClearButton=Ce;exports.Library=ne;exports.Link2=de;exports.Save=W;exports.VisualBadge=xe;exports.VisualSaveAndApplyButton=ye;exports.VisualSaveButton=be;exports.useCreateFlowOverlayState=Ee;exports.useEffectiveEditorCardType=J;
|