react-semaphor 0.1.563 → 0.1.565
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/DATA_APP_SDK.md +3 -3
- package/README.md +2 -2
- package/dist/analytics-protocol/index.js +8 -8
- package/dist/assistant-context/index.js +3 -2
- package/dist/brand-studio/index.js +28 -29
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{assistant-chat-iIp02_77.js → assistant-chat-DNfb5fbF.js} +294 -294
- package/dist/chunks/{bookmark-impact-D4Kl4amw.js → bookmark-impact-CHr7b1J2.js} +2 -2
- package/dist/chunks/bookmark-state-ByODVqee.js +1613 -0
- package/dist/chunks/card-filter-builder-CcEcfaYz.js +4100 -0
- package/dist/chunks/{switch-BW4yXSYs.js → code-editor-DJNOsgJH.js} +463 -442
- package/dist/chunks/{comparison-window-caption-D1EUXzaR.js → comparison-window-caption-CMLb3mut.js} +451 -419
- package/dist/chunks/{dashboard-CmqeP3QZ.js → dashboard-CtIfxycc.js} +1 -1
- package/dist/chunks/dashboard-briefing-launcher-D3mc6peE.js +4910 -0
- package/dist/chunks/{dashboard-controls-B253nJS-.js → dashboard-controls-BFv0zdws.js} +684 -674
- package/dist/chunks/{dashboard-json-osQuinUZ.js → dashboard-json-CXn_3OYb.js} +4 -4
- package/dist/chunks/{dates-DFY7Gfss.js → dates-DcRxw17S.js} +13 -13
- package/dist/chunks/{edit-dashboard-visual-CMar-NhA.js → edit-dashboard-visual-Y6HatqBd.js} +7704 -10337
- package/dist/chunks/filter-reach-copy-DbggA5B7.js +4673 -0
- package/dist/chunks/{filter-value-text-CPwFkrMz.js → filter-value-text-7zhmth1S.js} +2 -2
- package/dist/chunks/{index-CNGkfUp4.js → index-DDa_rklN.js} +69 -64
- package/dist/chunks/index-RNaTnE3m.js +585 -0
- package/dist/chunks/{layout-grid-BM65viQh.js → layout-grid-0hIlqEtk.js} +1 -1
- package/dist/chunks/{list-filter-BoeLBfL3.js → list-filter-DkgoCeBm.js} +1 -1
- package/dist/chunks/{matrix-analytical-definition-hEucouWM.js → matrix-analytical-definition-C9xB_T84.js} +18 -18
- package/dist/chunks/{matrix-card-CCh9JjP1.js → matrix-card-BSUeSXpD.js} +2 -2
- package/dist/chunks/{matrix-member-presentation-DsAUbuoL.js → matrix-member-presentation-DZNgQpUq.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-DsLdFdSa.js → matrix-operation-contract-Eb6elidS.js} +1 -1
- package/dist/chunks/{metric-comparison-Bnso1cm1.js → metric-comparison-ChXUFaZu.js} +1 -1
- package/dist/chunks/{palette-p1XSJFgB.js → palette-4vf2BEEg.js} +1 -1
- package/dist/chunks/{pivot-result-contract-expectations-B53jqszr.js → pivot-result-contract-expectations-Ddh1rNz5.js} +4 -4
- package/dist/chunks/{pivot-result-identity-Dq5jm-EC.js → pivot-result-identity-BlbLrqaC.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-l54wJyYE.js → report-preferences-dialog-Db-b04B4.js} +122 -131
- package/dist/chunks/{report-runtime-context-BITkNSDa.js → report-runtime-context-DnA_PiKo.js} +1 -1
- package/dist/chunks/resolve-dashboard-input-context-C18J-YZC.js +21394 -0
- package/dist/chunks/{save-CHV1B1fL.js → save-D6pHmSSP.js} +1 -1
- package/dist/chunks/saved-dashboard-context-DhC_EVus.js +629 -0
- package/dist/chunks/{selection-reducer-Bz5aywT4.js → selection-reducer-OaJ-N5uN.js} +1 -1
- package/dist/chunks/{semaphor-ready-indicator-C3EQEiD9.js → semaphor-ready-indicator-T6TsiBMT.js} +80879 -80744
- package/dist/chunks/{shelf-drop-preview-context-BODiBlqT.js → shelf-drop-preview-context-CNWL_b0S.js} +407 -407
- package/dist/chunks/{source-entity-resolution-DdDVXFB8.js → source-entity-resolution-DF6GulDn.js} +1 -1
- package/dist/chunks/stored-dashboard-IdmtrNkA.js +5026 -0
- package/dist/chunks/{table-export-sheet-bSXxGn-v.js → table-export-sheet--DUKWk6o.js} +1 -1
- package/dist/chunks/{temporal-input-presentation-sk9gqLi6.js → temporal-input-presentation--2r9BLr0.js} +392 -377
- package/dist/chunks/{token-types-BUK06hU2.js → token-types-C8JymO8s.js} +1 -1
- package/dist/chunks/{upload-BnmuyPqW.js → upload-Cf3wXZT8.js} +1 -1
- package/dist/chunks/{validators-BIM0FE31.js → validators-wtjw0aw6.js} +7 -7
- package/dist/chunks/variable-draft-3xseULxR.js +241 -0
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +2226 -1704
- package/dist/data-app-sdk/index.js +4 -4
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +5 -5
- package/dist/format-utils/index.js +174 -167
- package/dist/index.js +190 -188
- package/dist/layouts/index.js +1 -1
- package/dist/pdf-export-policy/index.js +80 -28
- package/dist/pdf-table-layout/index.js +65 -65
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
- package/dist/types/components/activity/activity-bell.d.ts +5 -1
- package/dist/types/components/activity/activity-types.d.ts +12 -4
- package/dist/types/components/dashboard-variables/data-variables-menu.d.ts +8 -0
- package/dist/types/components/dashboard-variables/variable-editor-host.d.ts +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/index.js +5 -5
- package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +62 -0
- package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +33 -2
- package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +7 -2
- package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +4 -2
- package/dist/types/lib/dashboard-variables/data-text.d.ts +33 -0
- package/dist/types/lib/dashboard-variables/types.d.ts +207 -0
- package/dist/types/lib/document/document-edits.d.ts +16 -1
- package/dist/types/lib/document/document-panel-target.d.ts +1 -1
- package/dist/types/lib/document/document-section-query-options.d.ts +29 -0
- package/dist/types/lib/document/document-table-data-policy.d.ts +0 -1
- package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +92 -0
- package/dist/types/lib/query-context/build-card-query-context.d.ts +6 -0
- package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +1 -0
- package/dist/types/lib/query-context/use-semantic-execution-payload-for-cards.d.ts +24 -0
- package/dist/types/lib/stores/dashboard-store.d.ts +36 -0
- package/dist/types/lib/text-variables/temporal-input-text.d.ts +28 -0
- package/dist/types/lib/text-variables/text-variable-types.d.ts +72 -0
- package/dist/types/lib/types/common-types.d.ts +155 -51
- package/dist/types/lib/utils/card-definition.d.ts +2 -2
- package/dist/types/shared/assistant-context/index.d.ts +1 -1
- package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +51 -1
- package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +7 -1
- package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +7 -1
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +1088 -431
- package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +18 -1
- package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +8 -1
- package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +40 -40
- package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -16
- package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/dashboard-filter-targets.d.ts +29 -0
- package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +7 -4
- package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +159 -0
- package/dist/types/shared/dashboard-authoring/dashboard-variable-changes.d.ts +61 -0
- package/dist/types/shared/dashboard-authoring/document-section-cards.d.ts +7 -0
- package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +10 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +6 -0
- package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +1 -1
- package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +50 -3
- package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +48 -1
- package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -2
- package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +87 -13
- package/dist/types/shared/dashboard-authoring/text-card-words/chip-colors.d.ts +23 -0
- package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +90 -8
- package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +31 -3
- package/dist/types/shared/dashboard-authoring/text-card-words/variable-words.d.ts +8 -0
- package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +125 -0
- package/dist/types/shared/dashboard-authoring/variable-editability.d.ts +24 -0
- package/dist/types/shared/dashboard-authoring/variable-references.d.ts +39 -0
- package/dist/types/shared/format-utils/document-print.d.ts +4 -2
- package/dist/types/shared/format-utils/index.d.ts +1 -0
- package/dist/types/shared/format-utils/pdf-capacity-lines.d.ts +17 -0
- package/dist/types/shared/format-utils/pdf-delivery.d.ts +8 -1
- package/dist/types/shared/format-utils/pdf-export-policy.d.ts +74 -6
- package/dist/types/shared/format-utils/presentation-execution.d.ts +9 -0
- package/package.json +2 -2
- package/src/data-app-sdk/README.md +3 -3
- package/dist/chunks/bookmark-state-CWeoGbrx.js +0 -743
- package/dist/chunks/braces-DzgoQC64.js +0 -23
- package/dist/chunks/dashboard-briefing-launcher-TYlSW77S.js +0 -3828
- package/dist/chunks/filter-reach-copy-CvV7W5dd.js +0 -3965
- package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +0 -16722
- package/dist/chunks/index-CJW5BdWT.js +0 -583
- package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +0 -8214
- package/dist/chunks/saved-dashboard-context-DFYBrE6O.js +0 -564
- package/dist/chunks/use-create-flow-overlay-state-BXY8-Cyz.js +0 -1436
|
@@ -0,0 +1,4910 @@
|
|
|
1
|
+
import { jsx as t, jsxs as s, Fragment as U } from "react/jsx-runtime";
|
|
2
|
+
import la, { useState as A, useEffect as Ie, useCallback as ie, useMemo as Y, useLayoutEffect as Ut, useRef as et, useContext as da } from "react";
|
|
3
|
+
import { da as it, bu as Le, bv as Ve, bx as Pe, db as Ba, aU as $e, aR as ot, dc as _a, dd as lt, de as Ct, a7 as dt, a4 as ve, u as w, df as Oa, dg as Ma, bt as M, dh as za, a6 as oe, aP as Ra, bZ as Ua, di as $a, dj as ja, bn as ca, bN as be, ch as ua, bM as tt, o as qa, k as Wa, dk as Qa, ck as wt, cl as St, cm as kt, cn as Dt, co as At, cp as Ft, cq as It, cr as ha, cu as Et, dl as Ka, dm as Ha, c9 as pt, c6 as je, c7 as qe, dn as ma, c8 as We, bV as re, ci as Ga, cd as at, dp as Ya, bS as Xa, bw as Tt, by as ct, dq as pa, bs as Ja, dr as fa, be as ut, ds as Za, bf as en, i as tn, dt as an, b9 as nn, w as rn, t as sn, du as on, dv as ln, dw as ga, dx as dn, dy as cn, dz as Ce, dA as un, R as ba, dB as hn, dC as mn, aM as pn, dD as fn, dE as ge, dF as gn, W as Lt, dG as bn, dH as ft, dI as xn, dJ as $t, dK as vn, dL as yn, dM as Nn, dN as xa, cK as Cn, dO as wn, dP as Sn, dQ as Vt, cv as va, dR as kn, dS as jt, dT as Dn, dU as An, dV as Fn, dW as In, aT as En, bo as Tn, bY as ya, dX as Ln, dY as Vn, dZ as Xe, d_ as Pn, d$ as Bn, e0 as _n, A as On, aB as Mn, aC as zn, ah as Rn, ag as Un, af as $n, ae as jn, ab as qn, a9 as Wn, e1 as Qn, e2 as Kn, e3 as Hn, e4 as Gn, e5 as Yn, az as Xn } from "./semaphor-ready-indicator-T6TsiBMT.js";
|
|
4
|
+
import { c as we, B as L, X as Qe, n as Re, s as xe, L as de, l as Pt, e as Bt, k as Jn, z as _t, P as Ee, a5 as Na, d as Te, a as nt, S as Ca, b as Nt, t as Se, u as ke, v as De, w as Ae, x as fe, a6 as Zn } from "./code-editor-DJNOsgJH.js";
|
|
5
|
+
import { L as Ue } from "./layout-grid-0hIlqEtk.js";
|
|
6
|
+
import "./index-CuHybtft.js";
|
|
7
|
+
import { o as er } from "./validators-wtjw0aw6.js";
|
|
8
|
+
import "./matrix-operation-contract-Eb6elidS.js";
|
|
9
|
+
import "./analytics-base-schemas-BaIQrEzX.js";
|
|
10
|
+
import "zod";
|
|
11
|
+
import "../value-format-preferences/index.js";
|
|
12
|
+
import { c as J } from "./_commonjsHelpers-DimLPMtv.js";
|
|
13
|
+
import { s as Je } from "./normalize-dashboard-for-dirty-check-XKgH3GFX.js";
|
|
14
|
+
import { bv as qt, b6 as Wt, eb as Qt, gy as tr, gz as rt, g1 as Kt, gA as ar, o as Ke, gB as nr, p as rr, f_ as sr, gC as ir, gD as or, cg as lr, gE as dr, l as cr, eW as ur, gF as hr, gG as mr, a as Ot, aJ as pr, a2 as fr, gH as gr, gI as br, c5 as xr, gJ as vr, gK as Ht, gL as yr } from "./resolve-dashboard-input-context-C18J-YZC.js";
|
|
15
|
+
import { createPortal as Nr } from "react-dom";
|
|
16
|
+
import { aK as Gt, ar as Cr } from "./temporal-input-presentation--2r9BLr0.js";
|
|
17
|
+
import { az as wr, am as Sr, A as kr, a7 as st, Q as Dr } from "./bookmark-state-ByODVqee.js";
|
|
18
|
+
import "./index-RNaTnE3m.js";
|
|
19
|
+
import "./context-R31TSL5V.js";
|
|
20
|
+
import { S as wa } from "./save-D6pHmSSP.js";
|
|
21
|
+
import { V as Ar, L as Fr, a as Ir, u as Sa, C as ka, F as Er, b as Tr, A as Lr, c as Vr } from "./card-filter-builder-CcEcfaYz.js";
|
|
22
|
+
import { m as Pr, k as Da, n as Aa } from "./report-preferences-dialog-Db-b04B4.js";
|
|
23
|
+
import { v as Br, G as _r, o as Or } from "./filter-reach-copy-DbggA5B7.js";
|
|
24
|
+
import { a as Yt, d as Xt, c as Mr, i as zr, b as Rr, e as Ur, v as Jt, f as Zt, g as $r } from "./variable-draft-3xseULxR.js";
|
|
25
|
+
import { g as pe, d as jr, a as qr } from "./index-DDa_rklN.js";
|
|
26
|
+
/**
|
|
27
|
+
* @license lucide-react v0.453.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/
|
|
32
|
+
const Wr = we("ArrowUpRight", [
|
|
33
|
+
["path", { d: "M7 7h10v10", key: "1tivn9" }],
|
|
34
|
+
["path", { d: "M7 17 17 7", key: "1vkiza" }]
|
|
35
|
+
]);
|
|
36
|
+
/**
|
|
37
|
+
* @license lucide-react v0.453.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/
|
|
42
|
+
const ea = we("Bell", [
|
|
43
|
+
["path", { d: "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9", key: "1qo2s2" }],
|
|
44
|
+
["path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0", key: "qgo35s" }]
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* @license lucide-react v0.453.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/
|
|
52
|
+
const Qr = we("CalendarRange", [
|
|
53
|
+
["rect", { width: "18", height: "18", x: "3", y: "4", rx: "2", key: "1hopcy" }],
|
|
54
|
+
["path", { d: "M16 2v4", key: "4m81vk" }],
|
|
55
|
+
["path", { d: "M3 10h18", key: "8toen8" }],
|
|
56
|
+
["path", { d: "M8 2v4", key: "1cmpym" }],
|
|
57
|
+
["path", { d: "M17 14h-6", key: "bkmgh3" }],
|
|
58
|
+
["path", { d: "M13 18H7", key: "bb0bb7" }],
|
|
59
|
+
["path", { d: "M7 14h.01", key: "1qa3f1" }],
|
|
60
|
+
["path", { d: "M17 18h.01", key: "1bdyru" }]
|
|
61
|
+
]);
|
|
62
|
+
/**
|
|
63
|
+
* @license lucide-react v0.453.0 - ISC
|
|
64
|
+
*
|
|
65
|
+
* This source code is licensed under the ISC license.
|
|
66
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
+
*/
|
|
68
|
+
const Kr = we("CodeXml", [
|
|
69
|
+
["path", { d: "m18 16 4-4-4-4", key: "1inbqp" }],
|
|
70
|
+
["path", { d: "m6 8-4 4 4 4", key: "15zrgr" }],
|
|
71
|
+
["path", { d: "m14.5 4-5 16", key: "e7oirm" }]
|
|
72
|
+
]);
|
|
73
|
+
/**
|
|
74
|
+
* @license lucide-react v0.453.0 - ISC
|
|
75
|
+
*
|
|
76
|
+
* This source code is licensed under the ISC license.
|
|
77
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
78
|
+
*/
|
|
79
|
+
const ta = we("MonitorSmartphone", [
|
|
80
|
+
["path", { d: "M18 8V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h8", key: "10dyio" }],
|
|
81
|
+
["path", { d: "M10 19v-3.96 3.15", key: "1irgej" }],
|
|
82
|
+
["path", { d: "M7 19h5", key: "qswx4l" }],
|
|
83
|
+
["rect", { width: "6", height: "10", x: "16", y: "12", rx: "2", key: "1egngj" }]
|
|
84
|
+
]);
|
|
85
|
+
/**
|
|
86
|
+
* @license lucide-react v0.453.0 - ISC
|
|
87
|
+
*
|
|
88
|
+
* This source code is licensed under the ISC license.
|
|
89
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
90
|
+
*/
|
|
91
|
+
const Hr = we("MousePointer2", [
|
|
92
|
+
[
|
|
93
|
+
"path",
|
|
94
|
+
{
|
|
95
|
+
d: "M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",
|
|
96
|
+
key: "edeuup"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
]);
|
|
100
|
+
/**
|
|
101
|
+
* @license lucide-react v0.453.0 - ISC
|
|
102
|
+
*
|
|
103
|
+
* This source code is licensed under the ISC license.
|
|
104
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
+
*/
|
|
106
|
+
const Gr = we("Newspaper", [
|
|
107
|
+
[
|
|
108
|
+
"path",
|
|
109
|
+
{
|
|
110
|
+
d: "M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",
|
|
111
|
+
key: "7pis2x"
|
|
112
|
+
}
|
|
113
|
+
],
|
|
114
|
+
["path", { d: "M18 14h-8", key: "sponae" }],
|
|
115
|
+
["path", { d: "M15 18h-5", key: "95g1m2" }],
|
|
116
|
+
["path", { d: "M10 6h8v4h-8V6Z", key: "smlsk5" }]
|
|
117
|
+
]);
|
|
118
|
+
/**
|
|
119
|
+
* @license lucide-react v0.453.0 - ISC
|
|
120
|
+
*
|
|
121
|
+
* This source code is licensed under the ISC license.
|
|
122
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
123
|
+
*/
|
|
124
|
+
const Yr = we("Terminal", [
|
|
125
|
+
["polyline", { points: "4 17 10 11 4 5", key: "akl6gq" }],
|
|
126
|
+
["line", { x1: "12", x2: "20", y1: "19", y2: "19", key: "q2wloq" }]
|
|
127
|
+
]);
|
|
128
|
+
function Xr() {
|
|
129
|
+
return /* @__PURE__ */ t("div", { className: "space-y-1.5 py-1", children: [...Array(5)].map((e, a) => /* @__PURE__ */ s(
|
|
130
|
+
"div",
|
|
131
|
+
{
|
|
132
|
+
className: "flex animate-pulse items-start gap-3 rounded-xl border border-transparent px-2.5 py-2.5",
|
|
133
|
+
children: [
|
|
134
|
+
/* @__PURE__ */ t("div", { className: "mt-0.5 h-4 w-4 flex-shrink-0 rounded bg-muted/60" }),
|
|
135
|
+
/* @__PURE__ */ s("div", { className: "flex-1 space-y-1.5", children: [
|
|
136
|
+
/* @__PURE__ */ t("div", { className: "h-4 w-3/5 rounded bg-muted/60" }),
|
|
137
|
+
/* @__PURE__ */ t("div", { className: "h-3 w-4/5 rounded bg-muted/40" })
|
|
138
|
+
] })
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
a
|
|
142
|
+
)) });
|
|
143
|
+
}
|
|
144
|
+
function Jr({
|
|
145
|
+
open: e,
|
|
146
|
+
onOpenChange: a,
|
|
147
|
+
onSubmit: r,
|
|
148
|
+
isCreating: n
|
|
149
|
+
}) {
|
|
150
|
+
const i = it("interactive"), [o, l] = A(""), [u, c] = A("");
|
|
151
|
+
Ie(() => {
|
|
152
|
+
e || (l(""), c(""));
|
|
153
|
+
}, [e]);
|
|
154
|
+
const d = () => {
|
|
155
|
+
o.trim() && r({ title: o, description: u });
|
|
156
|
+
}, h = (p) => {
|
|
157
|
+
a(p);
|
|
158
|
+
};
|
|
159
|
+
return /* @__PURE__ */ t(Le, { open: e, onOpenChange: h, children: /* @__PURE__ */ s(
|
|
160
|
+
Ve,
|
|
161
|
+
{
|
|
162
|
+
showCloseButton: !1,
|
|
163
|
+
className: "flex max-w-lg grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",
|
|
164
|
+
style: i.dialogStyle,
|
|
165
|
+
children: [
|
|
166
|
+
/* @__PURE__ */ s("div", { className: "flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
|
|
167
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
168
|
+
/* @__PURE__ */ t(Ue, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
169
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-baseline gap-2", children: [
|
|
170
|
+
/* @__PURE__ */ t(Pe, { className: "truncate text-[13px] font-medium leading-none tracking-normal", children: "New library visual" }),
|
|
171
|
+
/* @__PURE__ */ t("span", { className: "shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground", children: "Visual" })
|
|
172
|
+
] })
|
|
173
|
+
] }),
|
|
174
|
+
/* @__PURE__ */ t(
|
|
175
|
+
L,
|
|
176
|
+
{
|
|
177
|
+
size: "xs",
|
|
178
|
+
variant: "ghost",
|
|
179
|
+
className: "w-7 px-0 text-muted-foreground hover:text-foreground",
|
|
180
|
+
onClick: () => h(!1),
|
|
181
|
+
"aria-label": "Close",
|
|
182
|
+
disabled: n,
|
|
183
|
+
children: /* @__PURE__ */ t(Qe, { className: "h-3.5 w-3.5" })
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
] }),
|
|
187
|
+
/* @__PURE__ */ s("div", { className: "space-y-3 px-4 py-3", children: [
|
|
188
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: "Create a saved visual that can be reused across dashboards." }),
|
|
189
|
+
/* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
190
|
+
/* @__PURE__ */ t(Re, { htmlFor: "visual-title", className: "text-[12px]", children: "Name" }),
|
|
191
|
+
/* @__PURE__ */ t(
|
|
192
|
+
xe,
|
|
193
|
+
{
|
|
194
|
+
id: "visual-title",
|
|
195
|
+
size: "sm",
|
|
196
|
+
placeholder: "Untitled visual",
|
|
197
|
+
value: o,
|
|
198
|
+
onChange: (p) => l(p.target.value),
|
|
199
|
+
disabled: n,
|
|
200
|
+
onKeyDown: (p) => {
|
|
201
|
+
p.key === "Enter" && !p.shiftKey && (p.preventDefault(), d());
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] }),
|
|
206
|
+
/* @__PURE__ */ s("div", { className: "space-y-1.5", children: [
|
|
207
|
+
/* @__PURE__ */ t(Re, { htmlFor: "visual-description", className: "text-[12px]", children: "Description" }),
|
|
208
|
+
/* @__PURE__ */ t(
|
|
209
|
+
xe,
|
|
210
|
+
{
|
|
211
|
+
id: "visual-description",
|
|
212
|
+
size: "sm",
|
|
213
|
+
placeholder: "Optional",
|
|
214
|
+
value: u,
|
|
215
|
+
onChange: (p) => c(p.target.value),
|
|
216
|
+
disabled: n
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
] })
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ s("div", { className: "flex shrink-0 justify-end gap-2 border-t border-border/60 px-4 py-2.5", children: [
|
|
222
|
+
/* @__PURE__ */ t(
|
|
223
|
+
L,
|
|
224
|
+
{
|
|
225
|
+
size: "xs",
|
|
226
|
+
variant: "outline",
|
|
227
|
+
onClick: () => h(!1),
|
|
228
|
+
disabled: n,
|
|
229
|
+
children: "Cancel"
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ t(
|
|
233
|
+
L,
|
|
234
|
+
{
|
|
235
|
+
size: "xs",
|
|
236
|
+
onClick: d,
|
|
237
|
+
disabled: !o.trim() || n,
|
|
238
|
+
children: n ? /* @__PURE__ */ s(U, { children: [
|
|
239
|
+
/* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
240
|
+
"Creating..."
|
|
241
|
+
] }) : "Create library visual"
|
|
242
|
+
}
|
|
243
|
+
)
|
|
244
|
+
] })
|
|
245
|
+
]
|
|
246
|
+
}
|
|
247
|
+
) });
|
|
248
|
+
}
|
|
249
|
+
function Zr(e) {
|
|
250
|
+
const [a, r] = A(null), [n, i] = A(null), o = Ba();
|
|
251
|
+
return Ie(() => {
|
|
252
|
+
if (!e || e.trim() === "") {
|
|
253
|
+
r(null), i(null);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
if (!o)
|
|
257
|
+
return;
|
|
258
|
+
(async () => {
|
|
259
|
+
try {
|
|
260
|
+
if (!e.startsWith("http://") && !e.startsWith("https://"))
|
|
261
|
+
throw new Error(`Invalid URL format: ${e}`);
|
|
262
|
+
try {
|
|
263
|
+
new URL(e);
|
|
264
|
+
} catch {
|
|
265
|
+
throw new Error(`Invalid URL: ${e}`);
|
|
266
|
+
}
|
|
267
|
+
const c = `${e.endsWith("/") ? e : `${e}/`}index.js`;
|
|
268
|
+
try {
|
|
269
|
+
if (!(await fetch(c, { method: "HEAD" })).ok)
|
|
270
|
+
throw new Error(`Module not found at ${c}`);
|
|
271
|
+
} catch {
|
|
272
|
+
}
|
|
273
|
+
const d = await import(
|
|
274
|
+
/* @vite-ignore */
|
|
275
|
+
/* webpackIgnore: true */
|
|
276
|
+
c
|
|
277
|
+
);
|
|
278
|
+
if (typeof d.useChartStore != "function")
|
|
279
|
+
throw new Error("useChartStore is not a function");
|
|
280
|
+
r(() => d.useChartStore), i(null);
|
|
281
|
+
} catch (u) {
|
|
282
|
+
const c = u instanceof Error ? u.message : "Unknown error";
|
|
283
|
+
console.error("Failed to load remote chart store:", c), i(c), r(null);
|
|
284
|
+
}
|
|
285
|
+
})();
|
|
286
|
+
}, [e, o]), a;
|
|
287
|
+
}
|
|
288
|
+
function es(e, a) {
|
|
289
|
+
if (e.length === 0)
|
|
290
|
+
return "";
|
|
291
|
+
const r = e.find(
|
|
292
|
+
(n) => {
|
|
293
|
+
var i, o;
|
|
294
|
+
return ((i = n.customCardPreferences) == null ? void 0 : i.visualType) === "multiple" || !!((o = n.customCardPreferences) != null && o.dataInputCardIds);
|
|
295
|
+
}
|
|
296
|
+
);
|
|
297
|
+
if (r)
|
|
298
|
+
return r.id;
|
|
299
|
+
if (a) {
|
|
300
|
+
const n = e.find((i) => i.id === a);
|
|
301
|
+
if (n) {
|
|
302
|
+
const i = n.tabTitle;
|
|
303
|
+
if (i == "All__Header")
|
|
304
|
+
return e[0].id;
|
|
305
|
+
if (i && i.endsWith("__Header")) {
|
|
306
|
+
const l = i.split("__")[0], u = e.find(
|
|
307
|
+
(c) => c.tabTitle === l
|
|
308
|
+
);
|
|
309
|
+
return u ? u.id : e[0].id;
|
|
310
|
+
}
|
|
311
|
+
return a;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return e[0].id;
|
|
315
|
+
}
|
|
316
|
+
async function aa(e, a, r, n, i = "Opening library visual...") {
|
|
317
|
+
if (!a || !r)
|
|
318
|
+
throw new Error("Missing auth token or visual ID");
|
|
319
|
+
const o = ["resource-by-id", "visual", r], l = n.getQueryData(o);
|
|
320
|
+
if (l)
|
|
321
|
+
return console.log("Using cached visual data for:", r), { data: l, fromCache: !0 };
|
|
322
|
+
console.log("Fetching visual data from network for:", r);
|
|
323
|
+
const u = M.loading(i, {
|
|
324
|
+
position: "top-center"
|
|
325
|
+
});
|
|
326
|
+
try {
|
|
327
|
+
const c = await fetch(
|
|
328
|
+
`${e}/management/v1/visuals/${r}`,
|
|
329
|
+
{
|
|
330
|
+
headers: {
|
|
331
|
+
Authorization: `Bearer ${a}`
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
if (!c.ok)
|
|
336
|
+
throw new Error("Failed to load visual");
|
|
337
|
+
const d = await c.json();
|
|
338
|
+
return n.setQueryData(o, d), M.dismiss(u), { data: d, fromCache: !1 };
|
|
339
|
+
} catch (c) {
|
|
340
|
+
throw M.dismiss(u), c;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
function Fa(e) {
|
|
344
|
+
if (typeof e == "string")
|
|
345
|
+
return JSON.parse(e);
|
|
346
|
+
if (typeof e == "object")
|
|
347
|
+
return e;
|
|
348
|
+
throw new Error("Invalid frame object format");
|
|
349
|
+
}
|
|
350
|
+
function ts(e, a) {
|
|
351
|
+
var o, l;
|
|
352
|
+
const r = (e == null ? void 0 : e.frameObject) ?? ((o = e == null ? void 0 : e.visual) == null ? void 0 : o.frameObject);
|
|
353
|
+
if (!r)
|
|
354
|
+
return !1;
|
|
355
|
+
const n = Fa(r);
|
|
356
|
+
if (!(n != null && n.cards) || n.cards.length === 0)
|
|
357
|
+
return !1;
|
|
358
|
+
const i = (l = n.cards) == null ? void 0 : l.find(
|
|
359
|
+
(u) => u.id === n.activeCardId
|
|
360
|
+
);
|
|
361
|
+
return i ? (za({
|
|
362
|
+
...a,
|
|
363
|
+
frame: n,
|
|
364
|
+
card: i,
|
|
365
|
+
visualId: (e == null ? void 0 : e.id) || n.visualId
|
|
366
|
+
}), !0) : !1;
|
|
367
|
+
}
|
|
368
|
+
function as() {
|
|
369
|
+
const e = oe(
|
|
370
|
+
(n) => {
|
|
371
|
+
var i;
|
|
372
|
+
return ((i = n.card.customCardPreferences) == null ? void 0 : i.url) || "";
|
|
373
|
+
}
|
|
374
|
+
), a = Zr(e);
|
|
375
|
+
return { getUpdatedFrame: ie(() => {
|
|
376
|
+
var N;
|
|
377
|
+
Ra();
|
|
378
|
+
const {
|
|
379
|
+
frame: n,
|
|
380
|
+
card: i,
|
|
381
|
+
isDevMode: o,
|
|
382
|
+
selectedSchemaName: l,
|
|
383
|
+
selectedDatabaseName: u,
|
|
384
|
+
selectedTableName: c,
|
|
385
|
+
selectedConnectionId: d
|
|
386
|
+
} = oe.getState(), h = i.sql, p = (N = a == null ? void 0 : a.getState()) == null ? void 0 : N.settings, m = qt(i, {
|
|
387
|
+
isDevMode: o,
|
|
388
|
+
cardSql: h,
|
|
389
|
+
selectedSchemaName: l,
|
|
390
|
+
selectedDatabaseName: u,
|
|
391
|
+
selectedTableName: c,
|
|
392
|
+
selectedConnectionId: d,
|
|
393
|
+
remoteChartSettings: p,
|
|
394
|
+
stripConfig: Wt
|
|
395
|
+
}), f = n.cards.map((k) => {
|
|
396
|
+
if (k.id === i.id) return Qt({ before: i, after: m });
|
|
397
|
+
const V = tr(k) ? qt(k, { isDevMode: !0, cardSql: k.sql, stripConfig: Wt }) : k;
|
|
398
|
+
return Qt({ before: k, after: V });
|
|
399
|
+
}), g = f.flatMap((k) => k.dropped);
|
|
400
|
+
g.length && M.info("Some conditional formatting rules were removed", {
|
|
401
|
+
description: `Their column isn't in the saved visual: ${g.map((k) => k.name || "an unnamed rule").join(", ")}.`
|
|
402
|
+
});
|
|
403
|
+
const y = f.map((k) => k.card);
|
|
404
|
+
return {
|
|
405
|
+
...n,
|
|
406
|
+
cards: y,
|
|
407
|
+
activeCardId: es(y, n.activeCardId)
|
|
408
|
+
};
|
|
409
|
+
}, [a]) };
|
|
410
|
+
}
|
|
411
|
+
function Be() {
|
|
412
|
+
const { authToken: e, tokenProps: a } = $e(), r = ot(), n = _a(), i = lt(), { selectVisual: o } = Ct(), {
|
|
413
|
+
setFrame: l,
|
|
414
|
+
loadCard: u,
|
|
415
|
+
setIsDevMode: c,
|
|
416
|
+
initializeModeDrafts: d,
|
|
417
|
+
setActiveTabCardId: h,
|
|
418
|
+
updateDataSource: p,
|
|
419
|
+
setQueryResultColumns: m,
|
|
420
|
+
setSelectedConnectionId: f,
|
|
421
|
+
setSelectedDatabaseName: g,
|
|
422
|
+
setSelectedSchemaName: y,
|
|
423
|
+
setSelectedTableName: N,
|
|
424
|
+
setSelectedDatamodelId: k,
|
|
425
|
+
setInlineFilterValuesMap: V,
|
|
426
|
+
setApplyFilters: P,
|
|
427
|
+
clearEditorContext: D
|
|
428
|
+
} = dt(), {
|
|
429
|
+
setIsDashboardEditing: O,
|
|
430
|
+
setIsVisualEditing: b,
|
|
431
|
+
clearSelectedFrameId: S
|
|
432
|
+
} = ve(), v = w((_) => _.selectedSheetId), T = w((_) => _.selectedFrameId), I = w((_) => _.dashboard), H = w(
|
|
433
|
+
(_) => _.inlineFilterValuesMap
|
|
434
|
+
), B = Oa((i == null ? void 0 : i.id) || "", {
|
|
435
|
+
enabled: !!(i != null && i.id) && !!(e != null && e.accessToken)
|
|
436
|
+
}), Q = ie(
|
|
437
|
+
async (_) => {
|
|
438
|
+
try {
|
|
439
|
+
o(_), S(), D();
|
|
440
|
+
const { data: te, fromCache: Z } = await aa(
|
|
441
|
+
a.apiServiceUrl,
|
|
442
|
+
(e == null ? void 0 : e.accessToken) || "",
|
|
443
|
+
_.id,
|
|
444
|
+
r,
|
|
445
|
+
"Opening library visual..."
|
|
446
|
+
);
|
|
447
|
+
if (!ts(te, {
|
|
448
|
+
setFrame: l,
|
|
449
|
+
loadCard: u,
|
|
450
|
+
setIsDevMode: c,
|
|
451
|
+
initializeModeDrafts: d,
|
|
452
|
+
setActiveTabCardId: h,
|
|
453
|
+
updateDataSource: p,
|
|
454
|
+
setQueryResultColumns: m,
|
|
455
|
+
setSelectedConnectionId: f,
|
|
456
|
+
setSelectedDatabaseName: g,
|
|
457
|
+
setSelectedSchemaName: y,
|
|
458
|
+
setSelectedTableName: N,
|
|
459
|
+
setSelectedDatamodelId: k,
|
|
460
|
+
setInlineFilterValuesMap: V,
|
|
461
|
+
setApplyFilters: P,
|
|
462
|
+
setIsDashboardEditing: O,
|
|
463
|
+
setIsVisualEditing: b,
|
|
464
|
+
dashboard: I,
|
|
465
|
+
selectedSheetId: v,
|
|
466
|
+
selectedFrameId: T,
|
|
467
|
+
inlineFilterValuesMap: H
|
|
468
|
+
}))
|
|
469
|
+
throw new Error("Failed to setup editor with visual data");
|
|
470
|
+
return { success: !0, fromCache: Z };
|
|
471
|
+
} catch (te) {
|
|
472
|
+
return console.error("Error editing visual:", te), { success: !1, error: "Failed to load visual for editing" };
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
[
|
|
476
|
+
e == null ? void 0 : e.accessToken,
|
|
477
|
+
a.apiServiceUrl,
|
|
478
|
+
r,
|
|
479
|
+
o,
|
|
480
|
+
l,
|
|
481
|
+
u,
|
|
482
|
+
O,
|
|
483
|
+
b,
|
|
484
|
+
c,
|
|
485
|
+
d,
|
|
486
|
+
h,
|
|
487
|
+
p,
|
|
488
|
+
m,
|
|
489
|
+
f,
|
|
490
|
+
g,
|
|
491
|
+
y,
|
|
492
|
+
N,
|
|
493
|
+
k,
|
|
494
|
+
V,
|
|
495
|
+
P,
|
|
496
|
+
D,
|
|
497
|
+
S,
|
|
498
|
+
I,
|
|
499
|
+
v,
|
|
500
|
+
T,
|
|
501
|
+
H
|
|
502
|
+
]
|
|
503
|
+
), X = ie(
|
|
504
|
+
async (_) => {
|
|
505
|
+
var Z;
|
|
506
|
+
const te = (G) => (M.error(G), { success: !1, error: G });
|
|
507
|
+
try {
|
|
508
|
+
if (o(_), !v)
|
|
509
|
+
return te("No sheet selected. Please select a sheet first.");
|
|
510
|
+
const { data: G, fromCache: E } = await aa(
|
|
511
|
+
a.apiServiceUrl,
|
|
512
|
+
(e == null ? void 0 : e.accessToken) || "",
|
|
513
|
+
_.id,
|
|
514
|
+
r,
|
|
515
|
+
"Adding visual to dashboard..."
|
|
516
|
+
), ae = (G == null ? void 0 : G.frameObject) ?? ((Z = G == null ? void 0 : G.visual) == null ? void 0 : Z.frameObject);
|
|
517
|
+
if (!ae)
|
|
518
|
+
return te("Visual has no frame data");
|
|
519
|
+
const j = Fa(ae);
|
|
520
|
+
if (!(j != null && j.cards) || j.cards.length === 0)
|
|
521
|
+
return te("Visual frame is malformed");
|
|
522
|
+
const z = {
|
|
523
|
+
...Ma(j),
|
|
524
|
+
visualId: _.id
|
|
525
|
+
// Link this frame to the library visual
|
|
526
|
+
};
|
|
527
|
+
return await n(v, z), O(!0), { success: !0, fromCache: E };
|
|
528
|
+
} catch (G) {
|
|
529
|
+
return console.error("Error adding visual:", G), te(
|
|
530
|
+
G instanceof Error ? G.message : "Failed to add visual to dashboard"
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
[
|
|
535
|
+
e == null ? void 0 : e.accessToken,
|
|
536
|
+
a.apiServiceUrl,
|
|
537
|
+
r,
|
|
538
|
+
o,
|
|
539
|
+
v,
|
|
540
|
+
O,
|
|
541
|
+
n
|
|
542
|
+
]
|
|
543
|
+
);
|
|
544
|
+
return {
|
|
545
|
+
visual: B.data,
|
|
546
|
+
isLoading: B.isLoading,
|
|
547
|
+
isError: B.isError,
|
|
548
|
+
error: B.error,
|
|
549
|
+
handleEditLibraryVisual: Q,
|
|
550
|
+
handleAddLibraryVisual: X,
|
|
551
|
+
getUpdatedFrame: as().getUpdatedFrame,
|
|
552
|
+
refetch: B.refetch
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function Ia(e) {
|
|
556
|
+
return e ? new Date(e).toLocaleDateString("en-US", {
|
|
557
|
+
month: "short",
|
|
558
|
+
day: "numeric",
|
|
559
|
+
year: "numeric"
|
|
560
|
+
}) : "Unknown";
|
|
561
|
+
}
|
|
562
|
+
function Ea(e, a) {
|
|
563
|
+
var n;
|
|
564
|
+
const r = (n = e.ownership.createdBy) == null ? void 0 : n.type;
|
|
565
|
+
return r === "tenant" || r === "organization" && a;
|
|
566
|
+
}
|
|
567
|
+
function Mt(e, a) {
|
|
568
|
+
var r, n;
|
|
569
|
+
return Ea(e, a) ? ((r = e.ownership.createdBy) == null ? void 0 : r.name) || ((n = e.createdByTenantUserRel) == null ? void 0 : n.name) || e.lastModifiedBy || "Unknown" : "Organization";
|
|
570
|
+
}
|
|
571
|
+
function ns(e, a) {
|
|
572
|
+
return Mt(e, a).split(/\s+/).filter(Boolean).slice(0, 2).map((n) => n.charAt(0).toUpperCase()).join("") || "?";
|
|
573
|
+
}
|
|
574
|
+
function rs(e) {
|
|
575
|
+
const a = (e || "").toLowerCase();
|
|
576
|
+
return a.includes("table") ? Pt : a.includes("pie") || a.includes("donut") ? Ka : a.includes("line") ? Ha : a.includes("bar") ? Jn : Ue;
|
|
577
|
+
}
|
|
578
|
+
function ss({ visual: e }) {
|
|
579
|
+
const a = e.ownership.status === "public" ? "Public" : e.ownership.status === "shared" || e.ownership.sharedCount > 0 ? "Shared" : "Private";
|
|
580
|
+
return /* @__PURE__ */ t("span", { className: "inline-flex items-center rounded-[4px] border border-border/60 px-1.5 py-px text-[11px] text-muted-foreground", children: a });
|
|
581
|
+
}
|
|
582
|
+
function Wi({
|
|
583
|
+
open: e,
|
|
584
|
+
onOpenChange: a
|
|
585
|
+
}) {
|
|
586
|
+
const r = it("interactive"), [n, i] = A(""), [o, l] = A(/* @__PURE__ */ new Set()), [u, c] = A(!1), [d, h] = A(
|
|
587
|
+
null
|
|
588
|
+
), [p, m] = A(
|
|
589
|
+
null
|
|
590
|
+
), [f, g] = A(!1), [y, N] = A(null), [k, V] = A(null), P = () => {
|
|
591
|
+
l(/* @__PURE__ */ new Set()), h(null), m(null), g(!1), N(null);
|
|
592
|
+
}, D = () => {
|
|
593
|
+
a(!1), P();
|
|
594
|
+
}, { selectVisual: O } = Ct(), { handleAddLibraryVisual: b, handleEditLibraryVisual: S } = Be(), { isConsoleMode: v } = Ua(), {
|
|
595
|
+
resources: T,
|
|
596
|
+
isLoading: I,
|
|
597
|
+
isError: H,
|
|
598
|
+
createResource: B,
|
|
599
|
+
updateResource: Q,
|
|
600
|
+
deleteResourceAsync: X,
|
|
601
|
+
duplicateResource: _,
|
|
602
|
+
isCreating: te,
|
|
603
|
+
isDeleting: Z
|
|
604
|
+
} = $a(
|
|
605
|
+
void 0,
|
|
606
|
+
(C) => {
|
|
607
|
+
c(!1), C && (O(C), S(C), D());
|
|
608
|
+
}
|
|
609
|
+
), {
|
|
610
|
+
startUpdating: G,
|
|
611
|
+
stopUpdating: E,
|
|
612
|
+
isUpdating: ae
|
|
613
|
+
} = ja(), j = T, z = Y(() => {
|
|
614
|
+
const C = n.trim().toLowerCase();
|
|
615
|
+
return C ? j.filter(
|
|
616
|
+
(q) => {
|
|
617
|
+
var ee, me, Ne;
|
|
618
|
+
return ((ee = q.title) == null ? void 0 : ee.toLowerCase().includes(C)) || ((me = q.description) == null ? void 0 : me.toLowerCase().includes(C)) || ((Ne = q.kind) == null ? void 0 : Ne.toLowerCase().includes(C));
|
|
619
|
+
}
|
|
620
|
+
) : j;
|
|
621
|
+
}, [n, j]), ne = Y(
|
|
622
|
+
() => j.filter(
|
|
623
|
+
(C) => o.has(C.id)
|
|
624
|
+
),
|
|
625
|
+
[o, j]
|
|
626
|
+
), ue = ne.filter(
|
|
627
|
+
(C) => C.permissions.canDelete
|
|
628
|
+
), he = ne.filter(
|
|
629
|
+
(C) => C.permissions.canShare
|
|
630
|
+
), ye = z.length > 0 && z.every(
|
|
631
|
+
(C) => o.has(C.id)
|
|
632
|
+
), x = z.some(
|
|
633
|
+
(C) => o.has(C.id)
|
|
634
|
+
), R = (C) => {
|
|
635
|
+
const q = new Set(o);
|
|
636
|
+
C(q), l(q);
|
|
637
|
+
}, $ = (C) => {
|
|
638
|
+
R((q) => {
|
|
639
|
+
q.has(C) ? q.delete(C) : q.add(C);
|
|
640
|
+
});
|
|
641
|
+
}, K = () => {
|
|
642
|
+
l((C) => {
|
|
643
|
+
const q = new Set(C);
|
|
644
|
+
return ye ? z.forEach(
|
|
645
|
+
(ee) => q.delete(ee.id)
|
|
646
|
+
) : z.forEach(
|
|
647
|
+
(ee) => q.add(ee.id)
|
|
648
|
+
), q;
|
|
649
|
+
});
|
|
650
|
+
}, le = async (C) => {
|
|
651
|
+
(await b(C)).success && D();
|
|
652
|
+
}, _e = async () => {
|
|
653
|
+
const C = ne;
|
|
654
|
+
if (C.length === 0) return;
|
|
655
|
+
let q = !1;
|
|
656
|
+
for (const ee of C)
|
|
657
|
+
if (!(await b(ee)).success) {
|
|
658
|
+
q = !0;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
q || D();
|
|
662
|
+
}, ht = (C) => {
|
|
663
|
+
S(C), D();
|
|
664
|
+
}, Fe = (C) => {
|
|
665
|
+
V(C), _(C, {
|
|
666
|
+
onSettled: () => V(null)
|
|
667
|
+
});
|
|
668
|
+
}, He = () => {
|
|
669
|
+
if (ue.length === 0) {
|
|
670
|
+
M.error("Select a visual you can delete");
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
|
+
N(null), g(!0);
|
|
674
|
+
}, mt = async () => {
|
|
675
|
+
const C = y ? [y] : ue;
|
|
676
|
+
try {
|
|
677
|
+
for (const q of C)
|
|
678
|
+
await X(q.id);
|
|
679
|
+
l((q) => {
|
|
680
|
+
const ee = new Set(q);
|
|
681
|
+
return C.forEach(
|
|
682
|
+
(me) => ee.delete(me.id)
|
|
683
|
+
), ee;
|
|
684
|
+
}), g(!1), N(null);
|
|
685
|
+
} catch {
|
|
686
|
+
}
|
|
687
|
+
}, Oe = () => {
|
|
688
|
+
if (ne.length !== 1) {
|
|
689
|
+
M.error("Select one visual to share");
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
const [C] = ne;
|
|
693
|
+
if (!C.permissions.canShare) {
|
|
694
|
+
M.error("You do not have permission to share this visual");
|
|
695
|
+
return;
|
|
696
|
+
}
|
|
697
|
+
h(C);
|
|
698
|
+
}, Me = ({
|
|
699
|
+
title: C,
|
|
700
|
+
description: q
|
|
701
|
+
}) => {
|
|
702
|
+
if (!p) return;
|
|
703
|
+
const ee = {};
|
|
704
|
+
if (C !== p.title && (ee.title = C), (p.description || "") !== q && (ee.description = q), Object.keys(ee).length === 0) {
|
|
705
|
+
m(null);
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
const me = Object.keys(ee), Ne = me.length === 1 ? me[0] : void 0;
|
|
709
|
+
G(p.id, Ne), Q(
|
|
710
|
+
{
|
|
711
|
+
resourceId: p.id,
|
|
712
|
+
data: ee
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
onSuccess: () => {
|
|
716
|
+
E(p.id, Ne), m(null);
|
|
717
|
+
},
|
|
718
|
+
onError: () => {
|
|
719
|
+
E(p.id, Ne);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
);
|
|
723
|
+
}, ce = (C) => {
|
|
724
|
+
a(C), C || P();
|
|
725
|
+
}, ze = y ? 1 : ue.length;
|
|
726
|
+
return /* @__PURE__ */ s(U, { children: [
|
|
727
|
+
/* @__PURE__ */ t(Le, { open: e, onOpenChange: ce, children: /* @__PURE__ */ s(
|
|
728
|
+
Ve,
|
|
729
|
+
{
|
|
730
|
+
showCloseButton: !1,
|
|
731
|
+
className: "flex max-h-[80vh] w-[min(72rem,calc(100vw-2rem))] max-w-none grid-cols-none flex-col gap-0 overflow-hidden rounded-card border-border/60 p-0 shadow-lg sm:rounded-card",
|
|
732
|
+
style: r.dialogStyle,
|
|
733
|
+
children: [
|
|
734
|
+
/* @__PURE__ */ s("div", { className: "flex h-10 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
|
|
735
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
736
|
+
/* @__PURE__ */ t(Pt, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
737
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-baseline gap-2", children: [
|
|
738
|
+
/* @__PURE__ */ t(Pe, { className: "truncate text-[13px] font-medium leading-none tracking-normal", children: "Visuals library" }),
|
|
739
|
+
/* @__PURE__ */ t("span", { className: "shrink-0 text-[10px] font-medium uppercase leading-none tracking-[0.08em] text-muted-foreground", children: "Add to dashboard" })
|
|
740
|
+
] })
|
|
741
|
+
] }),
|
|
742
|
+
/* @__PURE__ */ t(
|
|
743
|
+
L,
|
|
744
|
+
{
|
|
745
|
+
size: "xs",
|
|
746
|
+
variant: "ghost",
|
|
747
|
+
className: "w-7 px-0 text-muted-foreground hover:text-foreground",
|
|
748
|
+
onClick: () => ce(!1),
|
|
749
|
+
"aria-label": "Close visuals library",
|
|
750
|
+
children: "×"
|
|
751
|
+
}
|
|
752
|
+
)
|
|
753
|
+
] }),
|
|
754
|
+
/* @__PURE__ */ s("div", { className: "flex shrink-0 items-center gap-2 border-b border-border/60 px-3 py-2", children: [
|
|
755
|
+
/* @__PURE__ */ s("div", { className: "relative min-w-[12rem] flex-1 md:max-w-md", children: [
|
|
756
|
+
/* @__PURE__ */ t(ca, { className: "pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground" }),
|
|
757
|
+
/* @__PURE__ */ t(
|
|
758
|
+
"input",
|
|
759
|
+
{
|
|
760
|
+
autoFocus: !0,
|
|
761
|
+
value: n,
|
|
762
|
+
onChange: (C) => i(C.target.value),
|
|
763
|
+
placeholder: "Search visuals...",
|
|
764
|
+
className: "h-7 w-full rounded-control border border-input bg-background pl-7 pr-2 text-[12px] text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none",
|
|
765
|
+
"aria-label": "Search visuals"
|
|
766
|
+
}
|
|
767
|
+
)
|
|
768
|
+
] }),
|
|
769
|
+
/* @__PURE__ */ s(
|
|
770
|
+
L,
|
|
771
|
+
{
|
|
772
|
+
size: "xs",
|
|
773
|
+
variant: "outline",
|
|
774
|
+
className: "ml-auto",
|
|
775
|
+
onClick: () => c(!0),
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ t(be, { className: "h-3.5 w-3.5" }),
|
|
778
|
+
"New library visual"
|
|
779
|
+
]
|
|
780
|
+
}
|
|
781
|
+
)
|
|
782
|
+
] }),
|
|
783
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 flex-1 overflow-auto", children: I ? /* @__PURE__ */ t("div", { className: "p-3", children: /* @__PURE__ */ t(Xr, {}) }) : H ? /* @__PURE__ */ t("div", { className: "flex flex-col items-center gap-2 px-4 py-12 text-center", children: /* @__PURE__ */ t("p", { className: "text-[13px] text-destructive", children: "Failed to load visuals" }) }) : z.length === 0 ? /* @__PURE__ */ s("div", { className: "flex flex-col items-center gap-2 px-4 py-12 text-center", children: [
|
|
784
|
+
/* @__PURE__ */ t(Ue, { className: "h-5 w-5 text-muted-foreground/60" }),
|
|
785
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium", children: n ? "No visuals found" : "No visuals yet" }),
|
|
786
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: n ? "Try a different search." : "Create a saved visual to add it here." })
|
|
787
|
+
] }) : /* @__PURE__ */ t(
|
|
788
|
+
is,
|
|
789
|
+
{
|
|
790
|
+
visuals: z,
|
|
791
|
+
selectedIds: o,
|
|
792
|
+
allFilteredSelected: ye,
|
|
793
|
+
someFilteredSelected: x,
|
|
794
|
+
onSelectAll: K,
|
|
795
|
+
onToggleSelection: $,
|
|
796
|
+
onAddVisual: le,
|
|
797
|
+
onOpenVisual: ht,
|
|
798
|
+
onEditDetails: m,
|
|
799
|
+
onShareVisual: h,
|
|
800
|
+
onDeleteVisual: (C) => {
|
|
801
|
+
N(C), g(!0);
|
|
802
|
+
},
|
|
803
|
+
onDuplicateVisual: Fe,
|
|
804
|
+
duplicatingId: k,
|
|
805
|
+
isDeleting: Z,
|
|
806
|
+
isConsoleMode: v
|
|
807
|
+
}
|
|
808
|
+
) }),
|
|
809
|
+
/* @__PURE__ */ s("div", { className: "flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-3 py-2", children: [
|
|
810
|
+
/* @__PURE__ */ t("div", { className: "flex min-w-0 items-center gap-1.5", children: o.size > 0 && /* @__PURE__ */ s(U, { children: [
|
|
811
|
+
/* @__PURE__ */ s("span", { className: "text-[12px] text-muted-foreground", children: [
|
|
812
|
+
/* @__PURE__ */ t("span", { className: "font-medium tabular-nums text-foreground", children: o.size }),
|
|
813
|
+
" ",
|
|
814
|
+
"selected"
|
|
815
|
+
] }),
|
|
816
|
+
/* @__PURE__ */ t(
|
|
817
|
+
L,
|
|
818
|
+
{
|
|
819
|
+
size: "xs",
|
|
820
|
+
variant: "ghost",
|
|
821
|
+
onClick: () => l(/* @__PURE__ */ new Set()),
|
|
822
|
+
children: "Clear"
|
|
823
|
+
}
|
|
824
|
+
),
|
|
825
|
+
/* @__PURE__ */ s(
|
|
826
|
+
L,
|
|
827
|
+
{
|
|
828
|
+
size: "xs",
|
|
829
|
+
variant: "outline",
|
|
830
|
+
onClick: Oe,
|
|
831
|
+
disabled: ne.length !== 1 || he.length !== 1,
|
|
832
|
+
children: [
|
|
833
|
+
/* @__PURE__ */ t(ua, { className: "h-3.5 w-3.5" }),
|
|
834
|
+
"Share"
|
|
835
|
+
]
|
|
836
|
+
}
|
|
837
|
+
),
|
|
838
|
+
/* @__PURE__ */ s(
|
|
839
|
+
L,
|
|
840
|
+
{
|
|
841
|
+
size: "xs",
|
|
842
|
+
variant: "outline",
|
|
843
|
+
className: "text-destructive hover:text-destructive",
|
|
844
|
+
onClick: He,
|
|
845
|
+
disabled: ue.length === 0,
|
|
846
|
+
children: [
|
|
847
|
+
/* @__PURE__ */ t(tt, { className: "h-3.5 w-3.5" }),
|
|
848
|
+
"Delete ",
|
|
849
|
+
ue.length || o.size
|
|
850
|
+
]
|
|
851
|
+
}
|
|
852
|
+
)
|
|
853
|
+
] }) }),
|
|
854
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
855
|
+
/* @__PURE__ */ t(
|
|
856
|
+
L,
|
|
857
|
+
{
|
|
858
|
+
size: "xs",
|
|
859
|
+
variant: "outline",
|
|
860
|
+
onClick: () => ce(!1),
|
|
861
|
+
children: "Close"
|
|
862
|
+
}
|
|
863
|
+
),
|
|
864
|
+
/* @__PURE__ */ s(
|
|
865
|
+
L,
|
|
866
|
+
{
|
|
867
|
+
size: "xs",
|
|
868
|
+
onClick: _e,
|
|
869
|
+
disabled: o.size === 0,
|
|
870
|
+
children: [
|
|
871
|
+
/* @__PURE__ */ t(Bt, { className: "h-3.5 w-3.5" }),
|
|
872
|
+
o.size === 0 ? "Add to dashboard" : `Add ${o.size} visual${o.size === 1 ? "" : "s"}`
|
|
873
|
+
]
|
|
874
|
+
}
|
|
875
|
+
)
|
|
876
|
+
] })
|
|
877
|
+
] })
|
|
878
|
+
]
|
|
879
|
+
}
|
|
880
|
+
) }),
|
|
881
|
+
/* @__PURE__ */ t(
|
|
882
|
+
Jr,
|
|
883
|
+
{
|
|
884
|
+
open: u,
|
|
885
|
+
onOpenChange: c,
|
|
886
|
+
onSubmit: B,
|
|
887
|
+
isCreating: te
|
|
888
|
+
}
|
|
889
|
+
),
|
|
890
|
+
d && /* @__PURE__ */ t(
|
|
891
|
+
qa,
|
|
892
|
+
{
|
|
893
|
+
resource: d,
|
|
894
|
+
resourceType: Wa.VISUAL,
|
|
895
|
+
onClose: () => h(null)
|
|
896
|
+
}
|
|
897
|
+
),
|
|
898
|
+
p && /* @__PURE__ */ t(
|
|
899
|
+
Qa,
|
|
900
|
+
{
|
|
901
|
+
open: !!p,
|
|
902
|
+
resourceLabel: "Visual",
|
|
903
|
+
initialTitle: p.title || "",
|
|
904
|
+
initialDescription: p.description || "",
|
|
905
|
+
onClose: () => m(null),
|
|
906
|
+
onSave: Me,
|
|
907
|
+
isSaving: ae(p.id)
|
|
908
|
+
}
|
|
909
|
+
),
|
|
910
|
+
/* @__PURE__ */ t(
|
|
911
|
+
wt,
|
|
912
|
+
{
|
|
913
|
+
open: f,
|
|
914
|
+
onOpenChange: (C) => {
|
|
915
|
+
!C && Z || (g(C), C || N(null));
|
|
916
|
+
},
|
|
917
|
+
children: /* @__PURE__ */ s(St, { children: [
|
|
918
|
+
/* @__PURE__ */ s(kt, { children: [
|
|
919
|
+
/* @__PURE__ */ s(Dt, { children: [
|
|
920
|
+
"Delete ",
|
|
921
|
+
ze,
|
|
922
|
+
" visual",
|
|
923
|
+
ze === 1 ? "" : "s",
|
|
924
|
+
"?"
|
|
925
|
+
] }),
|
|
926
|
+
/* @__PURE__ */ t(At, { children: "This cannot be undone. Visuals already added to dashboards may need to be removed from those dashboards separately." })
|
|
927
|
+
] }),
|
|
928
|
+
/* @__PURE__ */ s(Ft, { children: [
|
|
929
|
+
/* @__PURE__ */ t(It, { disabled: Z, children: "Cancel" }),
|
|
930
|
+
/* @__PURE__ */ s(
|
|
931
|
+
ha,
|
|
932
|
+
{
|
|
933
|
+
onClick: (C) => {
|
|
934
|
+
C.preventDefault(), mt();
|
|
935
|
+
},
|
|
936
|
+
disabled: Z || ze === 0,
|
|
937
|
+
children: [
|
|
938
|
+
Z ? /* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(tt, { className: "h-3.5 w-3.5" }),
|
|
939
|
+
Z ? "Deleting..." : "Delete"
|
|
940
|
+
]
|
|
941
|
+
}
|
|
942
|
+
)
|
|
943
|
+
] })
|
|
944
|
+
] })
|
|
945
|
+
}
|
|
946
|
+
)
|
|
947
|
+
] });
|
|
948
|
+
}
|
|
949
|
+
function is({
|
|
950
|
+
visuals: e,
|
|
951
|
+
selectedIds: a,
|
|
952
|
+
allFilteredSelected: r,
|
|
953
|
+
someFilteredSelected: n,
|
|
954
|
+
onSelectAll: i,
|
|
955
|
+
onToggleSelection: o,
|
|
956
|
+
onAddVisual: l,
|
|
957
|
+
onOpenVisual: u,
|
|
958
|
+
onEditDetails: c,
|
|
959
|
+
onShareVisual: d,
|
|
960
|
+
onDeleteVisual: h,
|
|
961
|
+
onDuplicateVisual: p,
|
|
962
|
+
duplicatingId: m,
|
|
963
|
+
isDeleting: f,
|
|
964
|
+
isConsoleMode: g
|
|
965
|
+
}) {
|
|
966
|
+
return /* @__PURE__ */ s("div", { className: "min-w-[48rem]", children: [
|
|
967
|
+
/* @__PURE__ */ s("div", { className: "grid h-9 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/60 px-3 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: [
|
|
968
|
+
/* @__PURE__ */ t(
|
|
969
|
+
Et,
|
|
970
|
+
{
|
|
971
|
+
checked: r ? !0 : n ? "indeterminate" : !1,
|
|
972
|
+
onCheckedChange: i,
|
|
973
|
+
"aria-label": "Select all visuals"
|
|
974
|
+
}
|
|
975
|
+
),
|
|
976
|
+
/* @__PURE__ */ t("span", { children: "Name" }),
|
|
977
|
+
/* @__PURE__ */ t("span", { children: "Created by" }),
|
|
978
|
+
/* @__PURE__ */ t("span", { children: "Updated" }),
|
|
979
|
+
/* @__PURE__ */ t("span", { children: "Visibility" }),
|
|
980
|
+
/* @__PURE__ */ t("span", { className: "text-right", children: "Shared" }),
|
|
981
|
+
/* @__PURE__ */ t("span", { className: "text-right", children: "Actions" })
|
|
982
|
+
] }),
|
|
983
|
+
e.map((y) => /* @__PURE__ */ t(
|
|
984
|
+
os,
|
|
985
|
+
{
|
|
986
|
+
visual: y,
|
|
987
|
+
selected: a.has(y.id),
|
|
988
|
+
onToggleSelection: o,
|
|
989
|
+
onAddVisual: l,
|
|
990
|
+
onOpenVisual: u,
|
|
991
|
+
onEditDetails: c,
|
|
992
|
+
onShareVisual: d,
|
|
993
|
+
onDeleteVisual: h,
|
|
994
|
+
onDuplicateVisual: p,
|
|
995
|
+
duplicatingId: m,
|
|
996
|
+
isDeleting: f,
|
|
997
|
+
isConsoleMode: g
|
|
998
|
+
},
|
|
999
|
+
y.id
|
|
1000
|
+
))
|
|
1001
|
+
] });
|
|
1002
|
+
}
|
|
1003
|
+
function os({
|
|
1004
|
+
visual: e,
|
|
1005
|
+
selected: a,
|
|
1006
|
+
onToggleSelection: r,
|
|
1007
|
+
onAddVisual: n,
|
|
1008
|
+
onOpenVisual: i,
|
|
1009
|
+
onEditDetails: o,
|
|
1010
|
+
onShareVisual: l,
|
|
1011
|
+
onDeleteVisual: u,
|
|
1012
|
+
onDuplicateVisual: c,
|
|
1013
|
+
duplicatingId: d,
|
|
1014
|
+
isDeleting: h,
|
|
1015
|
+
isConsoleMode: p
|
|
1016
|
+
}) {
|
|
1017
|
+
var g;
|
|
1018
|
+
const m = rs(e.kind), f = () => {
|
|
1019
|
+
n(e);
|
|
1020
|
+
};
|
|
1021
|
+
return /* @__PURE__ */ s(
|
|
1022
|
+
"div",
|
|
1023
|
+
{
|
|
1024
|
+
className: J(
|
|
1025
|
+
"group grid min-h-12 grid-cols-[2.5rem_minmax(14rem,1.8fr)_minmax(10rem,1fr)_8rem_7rem_5rem_5.5rem] items-center border-b border-border/50 px-3 text-[13px] hover:bg-muted/50",
|
|
1026
|
+
a && "bg-muted/70"
|
|
1027
|
+
),
|
|
1028
|
+
children: [
|
|
1029
|
+
/* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
|
|
1030
|
+
Et,
|
|
1031
|
+
{
|
|
1032
|
+
checked: a,
|
|
1033
|
+
onCheckedChange: () => r(e.id),
|
|
1034
|
+
"aria-label": `Select ${e.title || "visual"}`
|
|
1035
|
+
}
|
|
1036
|
+
) }),
|
|
1037
|
+
/* @__PURE__ */ s(
|
|
1038
|
+
"button",
|
|
1039
|
+
{
|
|
1040
|
+
type: "button",
|
|
1041
|
+
className: "flex min-w-0 items-center gap-2 rounded-[4px] text-left outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
1042
|
+
onClick: f,
|
|
1043
|
+
"aria-label": `Add ${e.title || "visual"} to dashboard`,
|
|
1044
|
+
children: [
|
|
1045
|
+
/* @__PURE__ */ t(m, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
1046
|
+
/* @__PURE__ */ s("div", { className: "min-w-0", children: [
|
|
1047
|
+
/* @__PURE__ */ t(
|
|
1048
|
+
"div",
|
|
1049
|
+
{
|
|
1050
|
+
className: "truncate font-medium text-foreground",
|
|
1051
|
+
title: e.title || "Untitled Visual",
|
|
1052
|
+
children: e.title || "Untitled Visual"
|
|
1053
|
+
}
|
|
1054
|
+
),
|
|
1055
|
+
((g = e.description) == null ? void 0 : g.trim()) && /* @__PURE__ */ t(
|
|
1056
|
+
"div",
|
|
1057
|
+
{
|
|
1058
|
+
className: "truncate text-[11px] text-muted-foreground",
|
|
1059
|
+
title: e.description,
|
|
1060
|
+
children: e.description
|
|
1061
|
+
}
|
|
1062
|
+
)
|
|
1063
|
+
] })
|
|
1064
|
+
]
|
|
1065
|
+
}
|
|
1066
|
+
),
|
|
1067
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
1068
|
+
/* @__PURE__ */ t("div", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-muted text-[9px] font-medium text-muted-foreground", children: ns(e, p) }),
|
|
1069
|
+
/* @__PURE__ */ t("span", { className: "truncate text-muted-foreground", children: Mt(e, p) })
|
|
1070
|
+
] }),
|
|
1071
|
+
/* @__PURE__ */ t("span", { className: "text-muted-foreground", children: Ia(e.updatedAt) }),
|
|
1072
|
+
/* @__PURE__ */ t(ss, { visual: e }),
|
|
1073
|
+
/* @__PURE__ */ t("span", { className: "text-right tabular-nums text-muted-foreground", children: e.ownership.sharedCount > 0 ? e.ownership.sharedCount : "—" }),
|
|
1074
|
+
/* @__PURE__ */ t(
|
|
1075
|
+
ls,
|
|
1076
|
+
{
|
|
1077
|
+
visual: e,
|
|
1078
|
+
onOpenVisual: i,
|
|
1079
|
+
onEditDetails: o,
|
|
1080
|
+
onShareVisual: l,
|
|
1081
|
+
onDeleteVisual: u,
|
|
1082
|
+
onDuplicateVisual: c,
|
|
1083
|
+
duplicatingId: d,
|
|
1084
|
+
isDeleting: h,
|
|
1085
|
+
isConsoleMode: p
|
|
1086
|
+
}
|
|
1087
|
+
)
|
|
1088
|
+
]
|
|
1089
|
+
}
|
|
1090
|
+
);
|
|
1091
|
+
}
|
|
1092
|
+
function ls({
|
|
1093
|
+
visual: e,
|
|
1094
|
+
onOpenVisual: a,
|
|
1095
|
+
onEditDetails: r,
|
|
1096
|
+
onShareVisual: n,
|
|
1097
|
+
onDeleteVisual: i,
|
|
1098
|
+
onDuplicateVisual: o,
|
|
1099
|
+
duplicatingId: l,
|
|
1100
|
+
isDeleting: u,
|
|
1101
|
+
isConsoleMode: c
|
|
1102
|
+
}) {
|
|
1103
|
+
return /* @__PURE__ */ s(
|
|
1104
|
+
"div",
|
|
1105
|
+
{
|
|
1106
|
+
className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100",
|
|
1107
|
+
onClick: (d) => d.stopPropagation(),
|
|
1108
|
+
children: [
|
|
1109
|
+
/* @__PURE__ */ t(
|
|
1110
|
+
L,
|
|
1111
|
+
{
|
|
1112
|
+
size: "xs",
|
|
1113
|
+
variant: "ghost",
|
|
1114
|
+
className: "w-7 px-0",
|
|
1115
|
+
onClick: () => a(e),
|
|
1116
|
+
"aria-label": "Edit visual",
|
|
1117
|
+
children: /* @__PURE__ */ t(pt, { className: "h-3.5 w-3.5" })
|
|
1118
|
+
}
|
|
1119
|
+
),
|
|
1120
|
+
/* @__PURE__ */ s(je, { modal: !1, children: [
|
|
1121
|
+
/* @__PURE__ */ t(qe, { asChild: !0, children: /* @__PURE__ */ t(
|
|
1122
|
+
L,
|
|
1123
|
+
{
|
|
1124
|
+
size: "xs",
|
|
1125
|
+
variant: "ghost",
|
|
1126
|
+
className: "w-7 px-0",
|
|
1127
|
+
"aria-label": "More actions",
|
|
1128
|
+
children: /* @__PURE__ */ t(ma, { className: "h-3.5 w-3.5" })
|
|
1129
|
+
}
|
|
1130
|
+
) }),
|
|
1131
|
+
/* @__PURE__ */ s(
|
|
1132
|
+
We,
|
|
1133
|
+
{
|
|
1134
|
+
align: "end",
|
|
1135
|
+
className: "z-[60] w-44 rounded-[6px] border-border/60 p-1 shadow-sm",
|
|
1136
|
+
children: [
|
|
1137
|
+
/* @__PURE__ */ s(re, { onClick: () => a(e), children: [
|
|
1138
|
+
/* @__PURE__ */ t(pt, { className: "h-3.5 w-3.5" }),
|
|
1139
|
+
"Edit visual"
|
|
1140
|
+
] }),
|
|
1141
|
+
/* @__PURE__ */ s(
|
|
1142
|
+
re,
|
|
1143
|
+
{
|
|
1144
|
+
onClick: () => o(e.id),
|
|
1145
|
+
disabled: l === e.id,
|
|
1146
|
+
children: [
|
|
1147
|
+
l === e.id ? /* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ t(Ga, { className: "h-3.5 w-3.5" }),
|
|
1148
|
+
l === e.id ? "Duplicating..." : "Duplicate"
|
|
1149
|
+
]
|
|
1150
|
+
}
|
|
1151
|
+
),
|
|
1152
|
+
e.permissions.canEdit && /* @__PURE__ */ s(re, { onClick: () => r(e), children: [
|
|
1153
|
+
/* @__PURE__ */ t(pt, { className: "h-3.5 w-3.5" }),
|
|
1154
|
+
"Edit details"
|
|
1155
|
+
] }),
|
|
1156
|
+
e.permissions.canShare && /* @__PURE__ */ s(re, { onClick: () => n(e), children: [
|
|
1157
|
+
/* @__PURE__ */ t(ua, { className: "h-3.5 w-3.5" }),
|
|
1158
|
+
"Share"
|
|
1159
|
+
] }),
|
|
1160
|
+
e.permissions.canDelete && /* @__PURE__ */ s(U, { children: [
|
|
1161
|
+
/* @__PURE__ */ t(at, {}),
|
|
1162
|
+
/* @__PURE__ */ s(
|
|
1163
|
+
re,
|
|
1164
|
+
{
|
|
1165
|
+
className: "text-destructive focus:bg-destructive/10 focus:text-destructive",
|
|
1166
|
+
onClick: () => i(e),
|
|
1167
|
+
disabled: u,
|
|
1168
|
+
children: [
|
|
1169
|
+
/* @__PURE__ */ t(tt, { className: "h-3.5 w-3.5" }),
|
|
1170
|
+
u ? "Deleting..." : "Delete"
|
|
1171
|
+
]
|
|
1172
|
+
}
|
|
1173
|
+
)
|
|
1174
|
+
] }),
|
|
1175
|
+
/* @__PURE__ */ t(at, {}),
|
|
1176
|
+
/* @__PURE__ */ s("div", { className: "space-y-1 px-2 py-1.5 text-[11px] text-muted-foreground", children: [
|
|
1177
|
+
Ea(e, c) && /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
|
|
1178
|
+
/* @__PURE__ */ t(Ya, { className: "h-3 w-3" }),
|
|
1179
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: Mt(e, c) })
|
|
1180
|
+
] }),
|
|
1181
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
|
|
1182
|
+
/* @__PURE__ */ t(Xa, { className: "h-3 w-3" }),
|
|
1183
|
+
/* @__PURE__ */ t("span", { children: Ia(e.updatedAt) })
|
|
1184
|
+
] })
|
|
1185
|
+
] })
|
|
1186
|
+
]
|
|
1187
|
+
}
|
|
1188
|
+
)
|
|
1189
|
+
] })
|
|
1190
|
+
]
|
|
1191
|
+
}
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
function Qi(e, a, r = !1) {
|
|
1195
|
+
const n = w((d) => d.dashboard), i = w(
|
|
1196
|
+
(d) => d.isDashboardEditing
|
|
1197
|
+
), o = w(
|
|
1198
|
+
(d) => d.onDashboardLifecycleEvent
|
|
1199
|
+
), l = ie(() => {
|
|
1200
|
+
const d = w.getState().dashboard;
|
|
1201
|
+
return a || !e || !d || d.id !== e.id ? !1 : Je(d) !== Je(e);
|
|
1202
|
+
}, [e, a]);
|
|
1203
|
+
Ut(() => (w.setState({ checkUnsavedDashboardChanges: l }), () => {
|
|
1204
|
+
w.getState().checkUnsavedDashboardChanges === l && w.setState({ checkUnsavedDashboardChanges: null });
|
|
1205
|
+
}), [l]);
|
|
1206
|
+
const u = Y(() => !r || a || !n || i && (!e || n.id !== e.id) ? null : {
|
|
1207
|
+
dashboardId: n.id,
|
|
1208
|
+
dirty: i && e ? Je(n) !== Je(e) : !1
|
|
1209
|
+
}, [
|
|
1210
|
+
i,
|
|
1211
|
+
a,
|
|
1212
|
+
r,
|
|
1213
|
+
e,
|
|
1214
|
+
n
|
|
1215
|
+
]), c = et(null);
|
|
1216
|
+
return Ut(() => {
|
|
1217
|
+
if (!o || !u) {
|
|
1218
|
+
c.current = null;
|
|
1219
|
+
return;
|
|
1220
|
+
}
|
|
1221
|
+
const d = c.current;
|
|
1222
|
+
(d == null ? void 0 : d.callback) === o && d.dashboardId === u.dashboardId && d.dirty === u.dirty || (c.current = {
|
|
1223
|
+
callback: o,
|
|
1224
|
+
dashboardId: u.dashboardId,
|
|
1225
|
+
dirty: u.dirty
|
|
1226
|
+
}, o({
|
|
1227
|
+
type: "dashboard:dirty-state",
|
|
1228
|
+
dashboardId: u.dashboardId,
|
|
1229
|
+
payload: { dirty: u.dirty }
|
|
1230
|
+
}));
|
|
1231
|
+
}, [u, o]), l;
|
|
1232
|
+
}
|
|
1233
|
+
function ds({
|
|
1234
|
+
open: e,
|
|
1235
|
+
onOpenChange: a,
|
|
1236
|
+
isLibraryVisual: r,
|
|
1237
|
+
currentVisualName: n,
|
|
1238
|
+
isSaving: i = !1,
|
|
1239
|
+
destinationMode: o = "both",
|
|
1240
|
+
onConfirm: l
|
|
1241
|
+
}) {
|
|
1242
|
+
const [u, c] = A(
|
|
1243
|
+
r && n ? `Copy of ${n}` : n || ""
|
|
1244
|
+
), [d, h] = A("");
|
|
1245
|
+
la.useEffect(() => {
|
|
1246
|
+
e && (c(
|
|
1247
|
+
r && n ? `Copy of ${n}` : n || ""
|
|
1248
|
+
), h(""));
|
|
1249
|
+
}, [e, r, n]);
|
|
1250
|
+
const p = !!u.trim(), m = o === "local" ? {
|
|
1251
|
+
saveToLibrary: !1,
|
|
1252
|
+
saveToCurrentDashboard: !0,
|
|
1253
|
+
badgeType: "local",
|
|
1254
|
+
description: "Creates a local copy on the current dashboard.",
|
|
1255
|
+
actionLabel: "Add to Dashboard (Local)"
|
|
1256
|
+
} : o === "library" ? {
|
|
1257
|
+
saveToLibrary: !0,
|
|
1258
|
+
saveToCurrentDashboard: !1,
|
|
1259
|
+
badgeType: "library",
|
|
1260
|
+
description: "Creates a reusable visual in Visual Library.",
|
|
1261
|
+
actionLabel: "Save as Library Visual"
|
|
1262
|
+
} : {
|
|
1263
|
+
saveToLibrary: !0,
|
|
1264
|
+
saveToCurrentDashboard: !0,
|
|
1265
|
+
badgeType: "linked",
|
|
1266
|
+
description: "Creates a new library visual and adds a linked copy to this dashboard.",
|
|
1267
|
+
actionLabel: "Save Copy as Linked Visual"
|
|
1268
|
+
}, f = () => {
|
|
1269
|
+
!p || i || l({
|
|
1270
|
+
name: u.trim(),
|
|
1271
|
+
description: d.trim() || void 0,
|
|
1272
|
+
saveToLibrary: m.saveToLibrary,
|
|
1273
|
+
saveToCurrentDashboard: m.saveToCurrentDashboard
|
|
1274
|
+
});
|
|
1275
|
+
};
|
|
1276
|
+
return /* @__PURE__ */ t(Le, { open: e, onOpenChange: a, children: /* @__PURE__ */ s(Ve, { className: "sm:max-w-[500px]", children: [
|
|
1277
|
+
/* @__PURE__ */ s(Tt, { children: [
|
|
1278
|
+
/* @__PURE__ */ s(Pe, { className: "flex items-center gap-2", children: [
|
|
1279
|
+
/* @__PURE__ */ t("span", { children: "Save Visual As" }),
|
|
1280
|
+
m.badgeType !== "local" && /* @__PURE__ */ t(
|
|
1281
|
+
Ar,
|
|
1282
|
+
{
|
|
1283
|
+
type: m.badgeType,
|
|
1284
|
+
showLabel: !0,
|
|
1285
|
+
className: "px-2 py-0.5"
|
|
1286
|
+
}
|
|
1287
|
+
)
|
|
1288
|
+
] }),
|
|
1289
|
+
/* @__PURE__ */ t(ct, { children: m.description })
|
|
1290
|
+
] }),
|
|
1291
|
+
/* @__PURE__ */ s("div", { className: "grid gap-4 py-4", children: [
|
|
1292
|
+
/* @__PURE__ */ s("div", { className: "grid gap-2", children: [
|
|
1293
|
+
/* @__PURE__ */ t(Re, { htmlFor: "name", children: "Name" }),
|
|
1294
|
+
/* @__PURE__ */ t(
|
|
1295
|
+
xe,
|
|
1296
|
+
{
|
|
1297
|
+
id: "name",
|
|
1298
|
+
value: u,
|
|
1299
|
+
onChange: (g) => c(g.target.value),
|
|
1300
|
+
placeholder: "Enter visual name",
|
|
1301
|
+
disabled: i
|
|
1302
|
+
}
|
|
1303
|
+
)
|
|
1304
|
+
] }),
|
|
1305
|
+
/* @__PURE__ */ s("div", { className: "grid gap-2", children: [
|
|
1306
|
+
/* @__PURE__ */ t(Re, { htmlFor: "description", children: "Description (optional)" }),
|
|
1307
|
+
/* @__PURE__ */ t(
|
|
1308
|
+
pa,
|
|
1309
|
+
{
|
|
1310
|
+
id: "description",
|
|
1311
|
+
value: d,
|
|
1312
|
+
onChange: (g) => h(g.target.value),
|
|
1313
|
+
placeholder: "Enter visual description",
|
|
1314
|
+
rows: 3,
|
|
1315
|
+
disabled: i
|
|
1316
|
+
}
|
|
1317
|
+
)
|
|
1318
|
+
] })
|
|
1319
|
+
] }),
|
|
1320
|
+
/* @__PURE__ */ s(Ja, { children: [
|
|
1321
|
+
/* @__PURE__ */ t(
|
|
1322
|
+
L,
|
|
1323
|
+
{
|
|
1324
|
+
variant: "outline",
|
|
1325
|
+
onClick: () => a(!1),
|
|
1326
|
+
disabled: i,
|
|
1327
|
+
children: "Cancel"
|
|
1328
|
+
}
|
|
1329
|
+
),
|
|
1330
|
+
/* @__PURE__ */ s(L, { onClick: f, disabled: !p || i, children: [
|
|
1331
|
+
i && /* @__PURE__ */ t(de, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1332
|
+
m.actionLabel
|
|
1333
|
+
] })
|
|
1334
|
+
] })
|
|
1335
|
+
] }) });
|
|
1336
|
+
}
|
|
1337
|
+
function zt(e) {
|
|
1338
|
+
var a;
|
|
1339
|
+
for (const r of e.cards)
|
|
1340
|
+
if (r.type === "matrixTable" && !er.safeParse((a = r.config) == null ? void 0 : a.matrix).success)
|
|
1341
|
+
return M.error("Matrix requires at least one row field, one metric, and valid settings."), !1;
|
|
1342
|
+
return !0;
|
|
1343
|
+
}
|
|
1344
|
+
function gt({
|
|
1345
|
+
className: e,
|
|
1346
|
+
variant: a = "outline"
|
|
1347
|
+
}) {
|
|
1348
|
+
const r = oe((o) => o.onSave), { getUpdatedFrame: n } = Be();
|
|
1349
|
+
function i() {
|
|
1350
|
+
const o = n();
|
|
1351
|
+
zt(o) && (r == null || r(o));
|
|
1352
|
+
}
|
|
1353
|
+
return /* @__PURE__ */ s(
|
|
1354
|
+
L,
|
|
1355
|
+
{
|
|
1356
|
+
onClick: i,
|
|
1357
|
+
className: e,
|
|
1358
|
+
size: "xs",
|
|
1359
|
+
variant: a,
|
|
1360
|
+
children: [
|
|
1361
|
+
/* @__PURE__ */ t(Bt, { className: "h-3.5 w-3.5" }),
|
|
1362
|
+
"Done"
|
|
1363
|
+
]
|
|
1364
|
+
}
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
function cs({
|
|
1368
|
+
className: e,
|
|
1369
|
+
variant: a = "default"
|
|
1370
|
+
}) {
|
|
1371
|
+
const r = ot(), [n, i] = A(!1), { setIsVisualEditing: o } = ve(), { getUpdatedFrame: l } = Be(), u = lt(), c = oe((p) => p.frame), d = fa();
|
|
1372
|
+
return /* @__PURE__ */ t(
|
|
1373
|
+
L,
|
|
1374
|
+
{
|
|
1375
|
+
onClick: () => {
|
|
1376
|
+
const p = l();
|
|
1377
|
+
if (!zt(p))
|
|
1378
|
+
return;
|
|
1379
|
+
const m = (c == null ? void 0 : c.visualId) || (u == null ? void 0 : u.id);
|
|
1380
|
+
if (!m) {
|
|
1381
|
+
M.error("No visual to save");
|
|
1382
|
+
return;
|
|
1383
|
+
}
|
|
1384
|
+
i(!0), d.mutate(
|
|
1385
|
+
{
|
|
1386
|
+
visualId: m,
|
|
1387
|
+
data: {
|
|
1388
|
+
frameObject: p
|
|
1389
|
+
}
|
|
1390
|
+
},
|
|
1391
|
+
{
|
|
1392
|
+
onSuccess: () => {
|
|
1393
|
+
i(!1), M.success("Visual updated successfully"), r.invalidateQueries({
|
|
1394
|
+
queryKey: ["resource-by-id", "visual", m],
|
|
1395
|
+
exact: !0
|
|
1396
|
+
});
|
|
1397
|
+
},
|
|
1398
|
+
onError: () => {
|
|
1399
|
+
i(!1), M.error("Failed to update visual");
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
);
|
|
1403
|
+
},
|
|
1404
|
+
className: e,
|
|
1405
|
+
size: "xs",
|
|
1406
|
+
variant: a,
|
|
1407
|
+
children: n ? /* @__PURE__ */ s(U, { children: [
|
|
1408
|
+
/* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1409
|
+
"Saving"
|
|
1410
|
+
] }) : /* @__PURE__ */ s(U, { children: [
|
|
1411
|
+
/* @__PURE__ */ t(wa, { className: "h-3.5 w-3.5" }),
|
|
1412
|
+
"Save to Library"
|
|
1413
|
+
] })
|
|
1414
|
+
}
|
|
1415
|
+
);
|
|
1416
|
+
}
|
|
1417
|
+
function us({
|
|
1418
|
+
className: e
|
|
1419
|
+
}) {
|
|
1420
|
+
const a = ot(), [r, n] = A(!1), i = lt(), o = oe((g) => g.frame), l = w((g) => g.selectedSheetId), u = w((g) => g.dashboard), { updateFrame: c, setIsVisualEditing: d } = ve(), { getUpdatedFrame: h } = Be(), p = fa(), m = ut();
|
|
1421
|
+
return /* @__PURE__ */ t(
|
|
1422
|
+
L,
|
|
1423
|
+
{
|
|
1424
|
+
onClick: async () => {
|
|
1425
|
+
if (!l) {
|
|
1426
|
+
M.error("No sheet selected");
|
|
1427
|
+
return;
|
|
1428
|
+
}
|
|
1429
|
+
const g = (o == null ? void 0 : o.visualId) || (i == null ? void 0 : i.id);
|
|
1430
|
+
if (!g) {
|
|
1431
|
+
M.error("No visual to update");
|
|
1432
|
+
return;
|
|
1433
|
+
}
|
|
1434
|
+
n(!0);
|
|
1435
|
+
try {
|
|
1436
|
+
const y = h();
|
|
1437
|
+
if (!zt(y)) {
|
|
1438
|
+
n(!1);
|
|
1439
|
+
return;
|
|
1440
|
+
}
|
|
1441
|
+
const N = {
|
|
1442
|
+
...y,
|
|
1443
|
+
visualId: g
|
|
1444
|
+
// Keep the link to library visual
|
|
1445
|
+
}, k = rt(u, N.id), V = await m(N, {
|
|
1446
|
+
previousFrame: k
|
|
1447
|
+
});
|
|
1448
|
+
await p.mutateAsync({
|
|
1449
|
+
visualId: g,
|
|
1450
|
+
data: {
|
|
1451
|
+
frameObject: y
|
|
1452
|
+
}
|
|
1453
|
+
}), c(l, N, {
|
|
1454
|
+
semanticExecutionPayload: V
|
|
1455
|
+
}), a.invalidateQueries({ queryKey: ["visuals"] }), a.invalidateQueries({ queryKey: ["visual", g] }), M.success("Saved to library and applied locally"), setTimeout(() => {
|
|
1456
|
+
d(!1);
|
|
1457
|
+
}, 300);
|
|
1458
|
+
} catch (y) {
|
|
1459
|
+
console.error("Failed to save and apply:", y), M.error(
|
|
1460
|
+
y instanceof Error ? y.message : "Failed to save and apply changes"
|
|
1461
|
+
);
|
|
1462
|
+
} finally {
|
|
1463
|
+
n(!1);
|
|
1464
|
+
}
|
|
1465
|
+
},
|
|
1466
|
+
className: e,
|
|
1467
|
+
size: "xs",
|
|
1468
|
+
variant: "default",
|
|
1469
|
+
disabled: r,
|
|
1470
|
+
children: r ? /* @__PURE__ */ s(U, { children: [
|
|
1471
|
+
/* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1472
|
+
"Saving..."
|
|
1473
|
+
] }) : /* @__PURE__ */ s(U, { children: [
|
|
1474
|
+
/* @__PURE__ */ t(wa, { className: "h-3.5 w-3.5" }),
|
|
1475
|
+
"Save & Apply"
|
|
1476
|
+
] })
|
|
1477
|
+
}
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
function bt({ className: e }) {
|
|
1481
|
+
const { setTempQueryData: a, setSqlGen: r } = dt(), n = ot(), i = oe((u) => u.tempQueryData), o = oe((u) => u.onClose);
|
|
1482
|
+
function l() {
|
|
1483
|
+
if (i) {
|
|
1484
|
+
const { queryKey: u, queryData: c } = i;
|
|
1485
|
+
u && c && n.setQueryData(u, c);
|
|
1486
|
+
}
|
|
1487
|
+
r({}), o == null || o();
|
|
1488
|
+
}
|
|
1489
|
+
return /* @__PURE__ */ s(
|
|
1490
|
+
L,
|
|
1491
|
+
{
|
|
1492
|
+
onClick: l,
|
|
1493
|
+
className: e,
|
|
1494
|
+
size: "xs",
|
|
1495
|
+
variant: "outline",
|
|
1496
|
+
children: [
|
|
1497
|
+
/* @__PURE__ */ t(Qe, { className: "h-3.5 w-3.5" }),
|
|
1498
|
+
"Close"
|
|
1499
|
+
]
|
|
1500
|
+
}
|
|
1501
|
+
);
|
|
1502
|
+
}
|
|
1503
|
+
function hs() {
|
|
1504
|
+
const [e, a] = A(!1), [r, n] = A(!1), [i, o] = A(null), [l, u] = A(null), c = oe((b) => b.frame), d = oe((b) => b.card), h = lt(), p = w((b) => b.selectedSheetId), m = w((b) => b.dashboard), { getUpdatedFrame: f } = Be(), { selectVisual: g } = Ct(), { addFrame: y, setIsVisualEditing: N } = ve(), k = ut(), V = !!(c != null && c.visualId), P = (() => {
|
|
1505
|
+
var b, S;
|
|
1506
|
+
return ((b = c == null ? void 0 : c.cards) == null ? void 0 : b.length) === 1 && ((S = c.cards[0]) != null && S.title) ? c.cards[0].title : h != null && h.title ? h.title : (d == null ? void 0 : d.title) || "Untitled Visual";
|
|
1507
|
+
})(), D = Za((b) => {
|
|
1508
|
+
b != null && b.id && (g(b), r && i && l && p && (async () => {
|
|
1509
|
+
try {
|
|
1510
|
+
const S = {
|
|
1511
|
+
...i,
|
|
1512
|
+
id: Kt(),
|
|
1513
|
+
visualId: b.id
|
|
1514
|
+
// Link to the newly created library visual
|
|
1515
|
+
};
|
|
1516
|
+
y(p, S, {
|
|
1517
|
+
semanticExecutionPayload: l
|
|
1518
|
+
}), n(!1), o(null), u(null), N(!1);
|
|
1519
|
+
} catch (S) {
|
|
1520
|
+
console.error(
|
|
1521
|
+
"Failed to promote semantic metadata for saved visual:",
|
|
1522
|
+
S
|
|
1523
|
+
), M.error(
|
|
1524
|
+
S instanceof Error ? S.message : "Failed to prepare semantic metadata for the saved visual"
|
|
1525
|
+
);
|
|
1526
|
+
}
|
|
1527
|
+
})(), a(!1));
|
|
1528
|
+
});
|
|
1529
|
+
return {
|
|
1530
|
+
saveAsDialogOpen: e,
|
|
1531
|
+
setSaveAsDialogOpen: a,
|
|
1532
|
+
handleSaveAs: async (b) => {
|
|
1533
|
+
if (!p) {
|
|
1534
|
+
M.error("No sheet selected");
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
const S = f(), T = S.cards.length === 1 ? {
|
|
1538
|
+
...S,
|
|
1539
|
+
cards: S.cards.map((I) => ({
|
|
1540
|
+
...I,
|
|
1541
|
+
title: b.name
|
|
1542
|
+
// Use visual name as card title
|
|
1543
|
+
}))
|
|
1544
|
+
} : S;
|
|
1545
|
+
if (b.saveToLibrary) {
|
|
1546
|
+
let I = null;
|
|
1547
|
+
if (b.saveToCurrentDashboard)
|
|
1548
|
+
try {
|
|
1549
|
+
I = await k(T, {
|
|
1550
|
+
previousFrame: rt(m, T.id)
|
|
1551
|
+
});
|
|
1552
|
+
} catch (B) {
|
|
1553
|
+
console.error(
|
|
1554
|
+
"Failed to prepare semantic metadata before saving visual:",
|
|
1555
|
+
B
|
|
1556
|
+
), M.error(
|
|
1557
|
+
B instanceof Error ? B.message : "Failed to prepare semantic metadata for the saved visual"
|
|
1558
|
+
);
|
|
1559
|
+
return;
|
|
1560
|
+
}
|
|
1561
|
+
n(b.saveToCurrentDashboard), o(T), u(I);
|
|
1562
|
+
const H = {
|
|
1563
|
+
title: b.name,
|
|
1564
|
+
description: b.description,
|
|
1565
|
+
frameObject: T,
|
|
1566
|
+
// Card title synced for single-card frames
|
|
1567
|
+
isPrivate: !1
|
|
1568
|
+
};
|
|
1569
|
+
D.mutate(H);
|
|
1570
|
+
} else if (b.saveToCurrentDashboard) {
|
|
1571
|
+
const I = {
|
|
1572
|
+
...T,
|
|
1573
|
+
// Card title already synced
|
|
1574
|
+
id: Kt(),
|
|
1575
|
+
visualId: void 0
|
|
1576
|
+
// Explicitly no visualId for local visuals
|
|
1577
|
+
};
|
|
1578
|
+
try {
|
|
1579
|
+
const H = await k(T, {
|
|
1580
|
+
previousFrame: rt(m, T.id)
|
|
1581
|
+
});
|
|
1582
|
+
y(p, I, {
|
|
1583
|
+
semanticExecutionPayload: H
|
|
1584
|
+
}), M.success("Visual saved to dashboard"), a(!1), N(!1);
|
|
1585
|
+
} catch (H) {
|
|
1586
|
+
console.error("Failed to save visual to dashboard:", H), M.error(
|
|
1587
|
+
H instanceof Error ? H.message : "Failed to prepare semantic metadata for the visual"
|
|
1588
|
+
);
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
},
|
|
1592
|
+
isLibraryVisual: V,
|
|
1593
|
+
currentVisualName: P,
|
|
1594
|
+
isSaving: D.isPending
|
|
1595
|
+
};
|
|
1596
|
+
}
|
|
1597
|
+
function Ki(e = {}) {
|
|
1598
|
+
const { isInspectionMode: a } = en(), r = oe((B) => B.frame), n = oe((B) => B.editorContext), i = tn((B) => B.selectedVisual), o = w((B) => B.selectedFrameId), l = w((B) => B.selectedSheetId), u = w((B) => B.dashboard), { setIsVisualEditing: c, updateFrame: d } = ve(), [h, p] = A(!1), [m, f] = A("both"), g = ut(), y = (n == null ? void 0 : n.type) === "documentSection", N = !!(r != null && r.visualId || i != null && i.id), k = !!(r != null && r.visualId && o), V = N && !k, {
|
|
1599
|
+
saveAsDialogOpen: P,
|
|
1600
|
+
setSaveAsDialogOpen: D,
|
|
1601
|
+
handleSaveAs: O,
|
|
1602
|
+
isLibraryVisual: b,
|
|
1603
|
+
currentVisualName: S,
|
|
1604
|
+
isSaving: v
|
|
1605
|
+
} = hs(), { getUpdatedFrame: T } = Be();
|
|
1606
|
+
if (a)
|
|
1607
|
+
return /* @__PURE__ */ s(U, { children: [
|
|
1608
|
+
/* @__PURE__ */ t(
|
|
1609
|
+
gt,
|
|
1610
|
+
{
|
|
1611
|
+
className: "rounded-control",
|
|
1612
|
+
variant: "default"
|
|
1613
|
+
}
|
|
1614
|
+
),
|
|
1615
|
+
/* @__PURE__ */ t(bt, {})
|
|
1616
|
+
] });
|
|
1617
|
+
if (y)
|
|
1618
|
+
return /* @__PURE__ */ s(U, { children: [
|
|
1619
|
+
/* @__PURE__ */ t(gt, { className: "rounded-control", variant: "default" }),
|
|
1620
|
+
/* @__PURE__ */ t(bt, {})
|
|
1621
|
+
] });
|
|
1622
|
+
const I = async () => {
|
|
1623
|
+
if (!l) {
|
|
1624
|
+
M.error("No sheet selected");
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
1627
|
+
if (h) return;
|
|
1628
|
+
p(!0);
|
|
1629
|
+
const Q = {
|
|
1630
|
+
...T(),
|
|
1631
|
+
visualId: void 0
|
|
1632
|
+
}, X = rt(u, Q.id);
|
|
1633
|
+
try {
|
|
1634
|
+
const _ = await g(Q, {
|
|
1635
|
+
previousFrame: X
|
|
1636
|
+
});
|
|
1637
|
+
d(l, Q, {
|
|
1638
|
+
semanticExecutionPayload: _
|
|
1639
|
+
});
|
|
1640
|
+
} catch (_) {
|
|
1641
|
+
console.error("Failed to apply local semantic metadata:", _), p(!1), M.error(
|
|
1642
|
+
_ instanceof Error ? _.message : "Failed to prepare semantic metadata for this visual"
|
|
1643
|
+
);
|
|
1644
|
+
return;
|
|
1645
|
+
}
|
|
1646
|
+
setTimeout(() => {
|
|
1647
|
+
p(!1), M.success("Changes applied. Visual is now local to this dashboard"), c(!1);
|
|
1648
|
+
}, 300);
|
|
1649
|
+
}, H = (B) => {
|
|
1650
|
+
f(B), D(!0);
|
|
1651
|
+
};
|
|
1652
|
+
return /* @__PURE__ */ s(U, { children: [
|
|
1653
|
+
/* @__PURE__ */ s("div", { className: "inline-flex items-center overflow-hidden rounded-control", children: [
|
|
1654
|
+
!N && /* @__PURE__ */ t(gt, { className: "!rounded-none", variant: "default" }),
|
|
1655
|
+
N && V && /* @__PURE__ */ t(cs, { className: "!rounded-none", variant: "default" }),
|
|
1656
|
+
N && k && /* @__PURE__ */ t(us, { className: "!rounded-none" }),
|
|
1657
|
+
/* @__PURE__ */ s(je, { modal: !1, children: [
|
|
1658
|
+
/* @__PURE__ */ t(qe, { asChild: !0, children: /* @__PURE__ */ t(
|
|
1659
|
+
L,
|
|
1660
|
+
{
|
|
1661
|
+
variant: "default",
|
|
1662
|
+
size: "xs",
|
|
1663
|
+
className: "w-7 !rounded-none border-l border-primary-foreground/20 px-0",
|
|
1664
|
+
"aria-label": "Open visual save options",
|
|
1665
|
+
disabled: v || h,
|
|
1666
|
+
children: /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" })
|
|
1667
|
+
}
|
|
1668
|
+
) }),
|
|
1669
|
+
/* @__PURE__ */ s(
|
|
1670
|
+
We,
|
|
1671
|
+
{
|
|
1672
|
+
align: "end",
|
|
1673
|
+
className: "min-w-[220px] rounded-control border border-border/60 p-1 shadow-sm",
|
|
1674
|
+
children: [
|
|
1675
|
+
k && /* @__PURE__ */ s(U, { children: [
|
|
1676
|
+
/* @__PURE__ */ s(
|
|
1677
|
+
re,
|
|
1678
|
+
{
|
|
1679
|
+
onClick: I,
|
|
1680
|
+
disabled: h,
|
|
1681
|
+
children: [
|
|
1682
|
+
/* @__PURE__ */ t(Bt, { className: "h-3.5 w-3.5" }),
|
|
1683
|
+
h ? "Applying..." : "Apply Locally"
|
|
1684
|
+
]
|
|
1685
|
+
}
|
|
1686
|
+
),
|
|
1687
|
+
/* @__PURE__ */ t(at, {})
|
|
1688
|
+
] }),
|
|
1689
|
+
/* @__PURE__ */ s(
|
|
1690
|
+
re,
|
|
1691
|
+
{
|
|
1692
|
+
onClick: () => H("local"),
|
|
1693
|
+
disabled: v,
|
|
1694
|
+
children: [
|
|
1695
|
+
/* @__PURE__ */ t(be, { className: "h-3.5 w-3.5" }),
|
|
1696
|
+
"Add to Dashboard (Local)"
|
|
1697
|
+
]
|
|
1698
|
+
}
|
|
1699
|
+
),
|
|
1700
|
+
/* @__PURE__ */ s(
|
|
1701
|
+
re,
|
|
1702
|
+
{
|
|
1703
|
+
onClick: () => H("library"),
|
|
1704
|
+
disabled: v,
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ t(Fr, { className: "h-3.5 w-3.5" }),
|
|
1707
|
+
"Save as Library Visual"
|
|
1708
|
+
]
|
|
1709
|
+
}
|
|
1710
|
+
),
|
|
1711
|
+
/* @__PURE__ */ s(
|
|
1712
|
+
re,
|
|
1713
|
+
{
|
|
1714
|
+
onClick: () => H("both"),
|
|
1715
|
+
disabled: v,
|
|
1716
|
+
children: [
|
|
1717
|
+
/* @__PURE__ */ t(Ir, { className: "h-3.5 w-3.5" }),
|
|
1718
|
+
"Save Copy as Linked Visual"
|
|
1719
|
+
]
|
|
1720
|
+
}
|
|
1721
|
+
)
|
|
1722
|
+
]
|
|
1723
|
+
}
|
|
1724
|
+
)
|
|
1725
|
+
] })
|
|
1726
|
+
] }),
|
|
1727
|
+
/* @__PURE__ */ t(bt, {}),
|
|
1728
|
+
/* @__PURE__ */ t(
|
|
1729
|
+
ds,
|
|
1730
|
+
{
|
|
1731
|
+
open: P,
|
|
1732
|
+
onOpenChange: (B) => {
|
|
1733
|
+
v || D(B);
|
|
1734
|
+
},
|
|
1735
|
+
isLibraryVisual: b,
|
|
1736
|
+
currentVisualName: S,
|
|
1737
|
+
isSaving: v,
|
|
1738
|
+
destinationMode: m,
|
|
1739
|
+
onConfirm: O
|
|
1740
|
+
}
|
|
1741
|
+
)
|
|
1742
|
+
] });
|
|
1743
|
+
}
|
|
1744
|
+
function Hi({ className: e }) {
|
|
1745
|
+
const a = oe((h) => h.isDevMode), r = oe((h) => h.card.type), n = w((h) => h.isVisualEditing), { setIsDevMode: i } = dt(), { config: o } = da(an).tokenProps, l = (o == null ? void 0 : o.showAdvancedMode) !== !1;
|
|
1746
|
+
if (!n || !l || !ar(r))
|
|
1747
|
+
return null;
|
|
1748
|
+
const u = a ? Hr : Kr, c = a ? "Visual editor" : "SQL editor", d = a ? "Switch to visual editor" : "Switch to SQL editor";
|
|
1749
|
+
return /* @__PURE__ */ s(
|
|
1750
|
+
"button",
|
|
1751
|
+
{
|
|
1752
|
+
type: "button",
|
|
1753
|
+
"aria-label": d,
|
|
1754
|
+
title: d,
|
|
1755
|
+
onClick: () => i(!a),
|
|
1756
|
+
className: J(
|
|
1757
|
+
"inline-flex h-7 items-center gap-1.5 rounded-control border border-input bg-background px-2 text-[12px] font-medium text-foreground transition-colors hover:bg-muted/40 focus-visible:border-ring focus-visible:outline-none",
|
|
1758
|
+
e
|
|
1759
|
+
),
|
|
1760
|
+
children: [
|
|
1761
|
+
/* @__PURE__ */ t(u, { className: "h-3 w-3 text-muted-foreground" }),
|
|
1762
|
+
c
|
|
1763
|
+
]
|
|
1764
|
+
}
|
|
1765
|
+
);
|
|
1766
|
+
}
|
|
1767
|
+
function Gi() {
|
|
1768
|
+
const e = Pr() === "sm", a = w((c) => c.isDashboardEditing), r = w((c) => c.isVisualEditing), n = w((c) => {
|
|
1769
|
+
var h;
|
|
1770
|
+
const d = ((h = c.dashboard) == null ? void 0 : h.sheets) ?? [];
|
|
1771
|
+
return d.find((p) => p.id === c.selectedSheetId) ?? d[0];
|
|
1772
|
+
}), i = w((c) => c.actions.arrangeSheet), o = w((c) => c.actions.undoArrange);
|
|
1773
|
+
if (!a || r || !n || Ke(n)) return null;
|
|
1774
|
+
const l = !(n.frames ?? []).length, u = (c) => {
|
|
1775
|
+
const d = i(n.id, { keepOrder: c });
|
|
1776
|
+
if (!d.ok) {
|
|
1777
|
+
M.error(d.reason === "not_a_grid" ? "This sheet has no grid to arrange." : "The dashboard can't be arranged right now.");
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
M("Arranged", {
|
|
1781
|
+
// Long enough to reach Undo after looking at the result; the default 4 seconds isn't.
|
|
1782
|
+
duration: 1e4,
|
|
1783
|
+
description: c ? "Sizes and gaps fixed on every screen size, in your order." : "KPIs on top, charts in pairs, tables full width, on every screen size.",
|
|
1784
|
+
action: {
|
|
1785
|
+
label: "Undo",
|
|
1786
|
+
onClick: () => {
|
|
1787
|
+
const h = o();
|
|
1788
|
+
!h.ok && h.reason === "changed_since" && M.info("The dashboard changed after Arrange, so it can't be undone from here.");
|
|
1789
|
+
}
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
};
|
|
1793
|
+
return /* @__PURE__ */ s("div", { className: "inline-flex h-7 items-stretch overflow-hidden rounded-control border border-input bg-background", children: [
|
|
1794
|
+
/* @__PURE__ */ s(
|
|
1795
|
+
L,
|
|
1796
|
+
{
|
|
1797
|
+
variant: "ghost",
|
|
1798
|
+
size: "xs",
|
|
1799
|
+
disabled: l,
|
|
1800
|
+
title: l ? "This sheet has no cards to arrange" : "Lay out the cards by kind on every screen size",
|
|
1801
|
+
onClick: () => u(!1),
|
|
1802
|
+
"aria-label": e ? "Arrange" : void 0,
|
|
1803
|
+
className: `h-full rounded-none border-0 shadow-none hover:bg-accent${e ? " w-7 px-0" : ""}`,
|
|
1804
|
+
children: [
|
|
1805
|
+
/* @__PURE__ */ t(Ue, { className: "h-3.5 w-3.5" }),
|
|
1806
|
+
!e && "Arrange"
|
|
1807
|
+
]
|
|
1808
|
+
}
|
|
1809
|
+
),
|
|
1810
|
+
/* @__PURE__ */ s(je, { modal: !1, children: [
|
|
1811
|
+
/* @__PURE__ */ t(qe, { asChild: !0, children: /* @__PURE__ */ t(
|
|
1812
|
+
L,
|
|
1813
|
+
{
|
|
1814
|
+
variant: "ghost",
|
|
1815
|
+
size: "xs",
|
|
1816
|
+
disabled: l,
|
|
1817
|
+
className: "h-full w-7 rounded-none border-0 border-l border-border/60 px-0 shadow-none hover:bg-accent",
|
|
1818
|
+
"aria-label": "Open arrange options",
|
|
1819
|
+
children: /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" })
|
|
1820
|
+
}
|
|
1821
|
+
) }),
|
|
1822
|
+
/* @__PURE__ */ t(We, { align: "end", className: "z-[60] w-48 rounded-[6px] border-border/60 p-1 shadow-sm", children: /* @__PURE__ */ s(re, { onClick: () => u(!0), children: [
|
|
1823
|
+
/* @__PURE__ */ t(Ue, { className: "h-3.5 w-3.5" }),
|
|
1824
|
+
"Keep my order"
|
|
1825
|
+
] }) })
|
|
1826
|
+
] })
|
|
1827
|
+
] });
|
|
1828
|
+
}
|
|
1829
|
+
function Yi() {
|
|
1830
|
+
const e = w((i) => i.screenSizesOpen), a = w((i) => {
|
|
1831
|
+
var u, c;
|
|
1832
|
+
const o = ((u = i.dashboard) == null ? void 0 : u.sheets) ?? [], l = o.find((d) => d.id === i.selectedSheetId) ?? o[0];
|
|
1833
|
+
return !!l && !Ke(l) && !!((c = l.frames) != null && c.length);
|
|
1834
|
+
}), r = w((i) => i.actions.setScreenSizesOpen), n = Da(
|
|
1835
|
+
"screen-sizes",
|
|
1836
|
+
"lg",
|
|
1837
|
+
a ? {
|
|
1838
|
+
label: "Screen sizes",
|
|
1839
|
+
icon: /* @__PURE__ */ t(ta, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
|
|
1840
|
+
checked: e,
|
|
1841
|
+
order: 40,
|
|
1842
|
+
onSelect: () => r(!e)
|
|
1843
|
+
} : void 0
|
|
1844
|
+
);
|
|
1845
|
+
return !a || n.collapsed ? null : /* @__PURE__ */ t(
|
|
1846
|
+
L,
|
|
1847
|
+
{
|
|
1848
|
+
type: "button",
|
|
1849
|
+
size: "xs",
|
|
1850
|
+
variant: e ? "secondary" : "ghost",
|
|
1851
|
+
"aria-pressed": e,
|
|
1852
|
+
"aria-label": "Screen sizes",
|
|
1853
|
+
title: "Screen sizes",
|
|
1854
|
+
onClick: () => r(!e),
|
|
1855
|
+
className: "w-7 px-0",
|
|
1856
|
+
children: /* @__PURE__ */ t(ta, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
|
|
1857
|
+
}
|
|
1858
|
+
);
|
|
1859
|
+
}
|
|
1860
|
+
function Xi({ dashboardId: e }) {
|
|
1861
|
+
const { openDashboardId: a, access: r, printMode: n, serverIsFavorite: i, fetchedAt: o } = w(
|
|
1862
|
+
nn((c) => {
|
|
1863
|
+
var d;
|
|
1864
|
+
return {
|
|
1865
|
+
openDashboardId: (d = c.dashboard) == null ? void 0 : d.id,
|
|
1866
|
+
access: c.viewer.access,
|
|
1867
|
+
printMode: c.viewer.printMode,
|
|
1868
|
+
serverIsFavorite: c.viewer.isFavorite,
|
|
1869
|
+
fetchedAt: c.viewer.fetchedAt
|
|
1870
|
+
};
|
|
1871
|
+
})
|
|
1872
|
+
), l = rn(), u = l.isFavorite(e, i, o);
|
|
1873
|
+
return a !== e || n || r === "session-only" ? null : /* @__PURE__ */ t(
|
|
1874
|
+
sn,
|
|
1875
|
+
{
|
|
1876
|
+
variant: "toolbar",
|
|
1877
|
+
isFavorite: u,
|
|
1878
|
+
readOnly: r === "read-only",
|
|
1879
|
+
pending: l.isPending(e),
|
|
1880
|
+
onToggle: () => void l.setFavorite({ dashboardId: e, isFavorite: !u })
|
|
1881
|
+
}
|
|
1882
|
+
);
|
|
1883
|
+
}
|
|
1884
|
+
function Ji({
|
|
1885
|
+
width: e,
|
|
1886
|
+
hasOverflowMenu: a = !0,
|
|
1887
|
+
children: r
|
|
1888
|
+
}) {
|
|
1889
|
+
const [n, i] = A(
|
|
1890
|
+
() => /* @__PURE__ */ new Map()
|
|
1891
|
+
), [o, l] = A(null), [u, c] = A(null), d = ie((p) => (i((m) => new Map(m).set(p.id, p)), () => i((m) => {
|
|
1892
|
+
if (m.get(p.id) !== p) return m;
|
|
1893
|
+
const f = new Map(m);
|
|
1894
|
+
return f.delete(p.id), f;
|
|
1895
|
+
})), []), h = Y(
|
|
1896
|
+
() => ({
|
|
1897
|
+
width: e,
|
|
1898
|
+
hasOverflowMenu: a,
|
|
1899
|
+
overflowItems: [...n.values()].sort((p, m) => p.order - m.order),
|
|
1900
|
+
register: d,
|
|
1901
|
+
openOverflowId: o,
|
|
1902
|
+
setOpenOverflowId: l,
|
|
1903
|
+
anchorSlot: u,
|
|
1904
|
+
setAnchorSlot: c
|
|
1905
|
+
}),
|
|
1906
|
+
[u, a, n, o, d, e]
|
|
1907
|
+
);
|
|
1908
|
+
return /* @__PURE__ */ t(Aa.Provider, { value: h, children: r });
|
|
1909
|
+
}
|
|
1910
|
+
function Zi() {
|
|
1911
|
+
const { setAnchorSlot: e } = da(Aa);
|
|
1912
|
+
return /* @__PURE__ */ t("span", { ref: e, "aria-hidden": !0, className: "relative -mr-1.5 block h-7 w-0" });
|
|
1913
|
+
}
|
|
1914
|
+
function eo(e) {
|
|
1915
|
+
var c;
|
|
1916
|
+
const { authToken: a, tokenProps: r } = $e(), { data: n } = on(), { mutate: i, isPending: o } = ln(), l = !!e && ((c = n == null ? void 0 : n.preference) == null ? void 0 : c.defaultDashboardId) === e, u = !n || o;
|
|
1917
|
+
return {
|
|
1918
|
+
available: !!e && !!(a != null && a.accessToken) && !!(r != null && r.apiServiceUrl),
|
|
1919
|
+
isDefault: l,
|
|
1920
|
+
disabled: u,
|
|
1921
|
+
toggle: () => {
|
|
1922
|
+
!e || u || i({ dashboardId: l ? null : e });
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
}
|
|
1926
|
+
function to({
|
|
1927
|
+
open: e,
|
|
1928
|
+
onOpenChange: a,
|
|
1929
|
+
onSave: r,
|
|
1930
|
+
onDiscard: n,
|
|
1931
|
+
isSaving: i,
|
|
1932
|
+
title: o = "Unsaved changes",
|
|
1933
|
+
description: l = "You have unsaved changes to this dashboard. What would you like to do?",
|
|
1934
|
+
cancelLabel: u = "Cancel",
|
|
1935
|
+
discardLabel: c = "Discard changes",
|
|
1936
|
+
saveLabel: d = "Save"
|
|
1937
|
+
}) {
|
|
1938
|
+
return /* @__PURE__ */ t(wt, { open: e, onOpenChange: (p) => {
|
|
1939
|
+
!p && i || a(p);
|
|
1940
|
+
}, children: /* @__PURE__ */ s(St, { children: [
|
|
1941
|
+
/* @__PURE__ */ s(kt, { children: [
|
|
1942
|
+
/* @__PURE__ */ t(Dt, { children: o }),
|
|
1943
|
+
/* @__PURE__ */ t(At, { children: l })
|
|
1944
|
+
] }),
|
|
1945
|
+
/* @__PURE__ */ s(Ft, { children: [
|
|
1946
|
+
/* @__PURE__ */ t(
|
|
1947
|
+
L,
|
|
1948
|
+
{
|
|
1949
|
+
type: "button",
|
|
1950
|
+
size: "xs",
|
|
1951
|
+
onClick: n,
|
|
1952
|
+
disabled: i,
|
|
1953
|
+
variant: "outline",
|
|
1954
|
+
className: "mr-auto text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10 focus-visible:text-destructive",
|
|
1955
|
+
children: c
|
|
1956
|
+
}
|
|
1957
|
+
),
|
|
1958
|
+
/* @__PURE__ */ t(It, { disabled: i, children: u }),
|
|
1959
|
+
/* @__PURE__ */ t(L, { type: "button", size: "xs", onClick: r, disabled: i, children: i ? /* @__PURE__ */ s(U, { children: [
|
|
1960
|
+
/* @__PURE__ */ t(de, { className: "mr-2 h-3.5 w-3.5 animate-spin" }),
|
|
1961
|
+
"Saving..."
|
|
1962
|
+
] }) : d })
|
|
1963
|
+
] })
|
|
1964
|
+
] }) });
|
|
1965
|
+
}
|
|
1966
|
+
async function ao(e) {
|
|
1967
|
+
var o, l;
|
|
1968
|
+
const a = (l = (o = w.getState()) == null ? void 0 : o.authToken) == null ? void 0 : l.accessToken;
|
|
1969
|
+
if (!a)
|
|
1970
|
+
return;
|
|
1971
|
+
const r = `${e}/v1/invalidate-token`, n = await fetch(r, {
|
|
1972
|
+
method: "POST",
|
|
1973
|
+
headers: {
|
|
1974
|
+
Authorization: `Bearer ${a}`
|
|
1975
|
+
}
|
|
1976
|
+
});
|
|
1977
|
+
if (!n.ok)
|
|
1978
|
+
throw new Error("Failed to invalidate token");
|
|
1979
|
+
const i = await n.json();
|
|
1980
|
+
return console.log("invalidateToken", i), i;
|
|
1981
|
+
}
|
|
1982
|
+
function ms(e) {
|
|
1983
|
+
var r;
|
|
1984
|
+
const a = e.item;
|
|
1985
|
+
return a.kind === "export" ? {
|
|
1986
|
+
title: a.title,
|
|
1987
|
+
status: a.status,
|
|
1988
|
+
startedAt: a.startedAt,
|
|
1989
|
+
finishedAt: a.finishedAt,
|
|
1990
|
+
running: fn(a.stage),
|
|
1991
|
+
finishedDetail: [
|
|
1992
|
+
a.totalRows !== null ? `${a.totalRows.toLocaleString("en-US")} rows` : null,
|
|
1993
|
+
a.fileSize ? pn(a.fileSize) : null
|
|
1994
|
+
].filter((n) => !!n),
|
|
1995
|
+
failure: ((r = a.failure) == null ? void 0 : r.kind) === "export" ? a.failure.message : a.status === "failed" ? Ce.failedFallback : null,
|
|
1996
|
+
note: null
|
|
1997
|
+
} : {
|
|
1998
|
+
title: a.title,
|
|
1999
|
+
status: a.status,
|
|
2000
|
+
startedAt: a.startedAt,
|
|
2001
|
+
finishedAt: a.finishedAt,
|
|
2002
|
+
running: { text: a.stageLabel ?? Ce.inProgress },
|
|
2003
|
+
finishedDetail: [],
|
|
2004
|
+
failure: null,
|
|
2005
|
+
note: a.omittedAttachmentCount > 0 ? ge.attachmentsLeftOut(a.omittedAttachmentCount) : null
|
|
2006
|
+
};
|
|
2007
|
+
}
|
|
2008
|
+
function na({ row: e, now: a, api: r }) {
|
|
2009
|
+
const [n, i] = A("idle"), o = cn(e, r), l = async () => {
|
|
2010
|
+
if (!o) return;
|
|
2011
|
+
i("working");
|
|
2012
|
+
const u = await gn(r, e, o);
|
|
2013
|
+
i(u === "done" ? "idle" : u);
|
|
2014
|
+
};
|
|
2015
|
+
return /* @__PURE__ */ t(
|
|
2016
|
+
Ta,
|
|
2017
|
+
{
|
|
2018
|
+
shown: ms(e),
|
|
2019
|
+
now: a,
|
|
2020
|
+
longRunningHint: e.item.kind === "export",
|
|
2021
|
+
action: o ? { label: ga[o], run: () => void l() } : null,
|
|
2022
|
+
working: n === "working",
|
|
2023
|
+
problem: n === "denied" || n === "blocked" ? n : null
|
|
2024
|
+
}
|
|
2025
|
+
);
|
|
2026
|
+
}
|
|
2027
|
+
function ps({ work: e, now: a }) {
|
|
2028
|
+
const r = e.stage === "preparing" ? e.cancel : null;
|
|
2029
|
+
return /* @__PURE__ */ t(
|
|
2030
|
+
Ta,
|
|
2031
|
+
{
|
|
2032
|
+
shown: {
|
|
2033
|
+
title: e.title,
|
|
2034
|
+
status: "running",
|
|
2035
|
+
startedAt: e.startedAt,
|
|
2036
|
+
finishedAt: null,
|
|
2037
|
+
running: dn(e),
|
|
2038
|
+
finishedDetail: [],
|
|
2039
|
+
failure: null,
|
|
2040
|
+
note: null
|
|
2041
|
+
},
|
|
2042
|
+
now: a,
|
|
2043
|
+
longRunningHint: !1,
|
|
2044
|
+
action: r ? { label: ga.cancel, run: r } : null,
|
|
2045
|
+
working: !1,
|
|
2046
|
+
problem: null
|
|
2047
|
+
}
|
|
2048
|
+
);
|
|
2049
|
+
}
|
|
2050
|
+
function Ta({
|
|
2051
|
+
shown: e,
|
|
2052
|
+
now: a,
|
|
2053
|
+
longRunningHint: r,
|
|
2054
|
+
action: n,
|
|
2055
|
+
working: i,
|
|
2056
|
+
problem: o
|
|
2057
|
+
}) {
|
|
2058
|
+
const l = e.status === "ready" ? "bg-emerald-500" : e.status === "failed" ? "bg-destructive" : e.status === "cancelled" ? "bg-muted-foreground/40" : "animate-pulse bg-muted-foreground/60", u = e.status === "ready" ? Ce.ready : e.status === "failed" ? Ce.failed : e.status === "cancelled" ? Ce.cancelled : Ce.inProgress, c = Date.parse(e.startedAt), d = Gt(Date.parse(e.finishedAt ?? e.startedAt), a, { addSuffix: !0 }), h = e.status === "running" && r && a - c >= un, p = /* @__PURE__ */ t("span", { className: "text-muted-foreground/50", children: "·" });
|
|
2059
|
+
return /* @__PURE__ */ s("div", { className: "group flex items-start gap-2.5 px-3 py-2 transition-colors hover:bg-muted/40 focus-within:bg-muted/40", children: [
|
|
2060
|
+
/* @__PURE__ */ t("span", { className: "flex h-5 shrink-0 items-center", "aria-hidden": "true", children: /* @__PURE__ */ t("span", { className: `h-1.5 w-1.5 rounded-full ${l}` }) }),
|
|
2061
|
+
/* @__PURE__ */ t("span", { className: "sr-only", children: u }),
|
|
2062
|
+
/* @__PURE__ */ s("div", { className: "min-w-0 flex-1", children: [
|
|
2063
|
+
/* @__PURE__ */ s("div", { className: "flex h-5 items-center gap-2", children: [
|
|
2064
|
+
/* @__PURE__ */ t("span", { className: "min-w-0 flex-1 truncate text-[13px] font-medium leading-5", children: e.title }),
|
|
2065
|
+
n && i && /* @__PURE__ */ t("span", { role: "status", className: "inline-flex shrink-0 items-center gap-1.5 text-[12px] text-muted-foreground", children: /* @__PURE__ */ t(ba, { className: "h-3 w-3 animate-spin", strokeWidth: 1.75 }) }),
|
|
2066
|
+
n && !i && /* @__PURE__ */ t(
|
|
2067
|
+
"button",
|
|
2068
|
+
{
|
|
2069
|
+
type: "button",
|
|
2070
|
+
onClick: n.run,
|
|
2071
|
+
className: "shrink-0 text-[12px] font-medium text-foreground/80 underline-offset-2 hover:text-foreground hover:underline focus-visible:underline focus-visible:outline-none",
|
|
2072
|
+
children: n.label
|
|
2073
|
+
}
|
|
2074
|
+
)
|
|
2075
|
+
] }),
|
|
2076
|
+
e.status === "running" && e.running && /* @__PURE__ */ s("div", { className: "text-[12px] leading-4 text-muted-foreground", children: [
|
|
2077
|
+
/* @__PURE__ */ t("span", { className: "tabular-nums", children: e.running.text }),
|
|
2078
|
+
e.running.detail && /* @__PURE__ */ s(U, { children: [
|
|
2079
|
+
" ",
|
|
2080
|
+
p,
|
|
2081
|
+
" ",
|
|
2082
|
+
/* @__PURE__ */ t("span", { className: "tabular-nums", children: e.running.detail })
|
|
2083
|
+
] }),
|
|
2084
|
+
" ",
|
|
2085
|
+
p,
|
|
2086
|
+
" ",
|
|
2087
|
+
/* @__PURE__ */ t("span", { children: Ce.started(Gt(c, a)) }),
|
|
2088
|
+
e.running.percent !== void 0 && /* @__PURE__ */ t(hn, { value: e.running.percent, className: "mt-1.5 h-1" }),
|
|
2089
|
+
h && /* @__PURE__ */ t("div", { className: "mt-1", children: Ce.longRunning })
|
|
2090
|
+
] }),
|
|
2091
|
+
e.status !== "running" && /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5 text-[12px] leading-4 text-muted-foreground", children: [
|
|
2092
|
+
e.status === "ready" && e.finishedDetail.length > 0 ? (
|
|
2093
|
+
// Disclosed on hover or focus only; the time is what a reader scans.
|
|
2094
|
+
/* @__PURE__ */ s("span", { className: "hidden group-hover:contents group-focus-within:contents", children: [
|
|
2095
|
+
e.finishedDetail.map((m, f) => /* @__PURE__ */ s(la.Fragment, { children: [
|
|
2096
|
+
f > 0 && p,
|
|
2097
|
+
/* @__PURE__ */ t("span", { children: m })
|
|
2098
|
+
] }, f)),
|
|
2099
|
+
p
|
|
2100
|
+
] })
|
|
2101
|
+
) : e.status !== "ready" ? /* @__PURE__ */ s(U, { children: [
|
|
2102
|
+
/* @__PURE__ */ t("span", { children: u }),
|
|
2103
|
+
p
|
|
2104
|
+
] }) : null,
|
|
2105
|
+
/* @__PURE__ */ t("span", { children: d })
|
|
2106
|
+
] }),
|
|
2107
|
+
e.note && /* @__PURE__ */ t("div", { className: "text-[12px] leading-4 text-muted-foreground", children: e.note }),
|
|
2108
|
+
e.status === "failed" && e.failure && /* @__PURE__ */ t("div", { className: "mt-1 whitespace-pre-wrap break-words text-[12px] leading-4 text-destructive", children: e.failure }),
|
|
2109
|
+
o && /* @__PURE__ */ t(mn, { problem: o, className: "mt-1" })
|
|
2110
|
+
] })
|
|
2111
|
+
] });
|
|
2112
|
+
}
|
|
2113
|
+
function no({ variant: e }) {
|
|
2114
|
+
const { snapshot: a, markSeen: r } = Lt(), n = a.runningCount > 0 ? a.runningCount > 9 ? "9+" : String(a.runningCount) : a.hasUnseenFinished ? "" : null, i = Da("activity", "md", {
|
|
2115
|
+
label: ge.title,
|
|
2116
|
+
icon: /* @__PURE__ */ t(ea, { className: "h-3.5 w-3.5" }),
|
|
2117
|
+
hint: n || (n === "" ? "New" : void 0),
|
|
2118
|
+
order: 30,
|
|
2119
|
+
onOpen: r
|
|
2120
|
+
});
|
|
2121
|
+
return i.collapsed ? /* @__PURE__ */ s(
|
|
2122
|
+
Ee,
|
|
2123
|
+
{
|
|
2124
|
+
open: i.popoverOpen,
|
|
2125
|
+
onOpenChange: (o) => {
|
|
2126
|
+
i.setPopoverOpen(o), o && r();
|
|
2127
|
+
},
|
|
2128
|
+
children: [
|
|
2129
|
+
i.anchorSlot && Nr(
|
|
2130
|
+
/* @__PURE__ */ t(Na, { asChild: !0, children: /* @__PURE__ */ t("span", { className: "absolute right-0 top-0 h-7 w-px" }) }),
|
|
2131
|
+
i.anchorSlot
|
|
2132
|
+
),
|
|
2133
|
+
/* @__PURE__ */ t(
|
|
2134
|
+
Te,
|
|
2135
|
+
{
|
|
2136
|
+
className: "w-80 p-0",
|
|
2137
|
+
align: "end",
|
|
2138
|
+
sideOffset: 8,
|
|
2139
|
+
onFocusOutside: (o) => o.preventDefault(),
|
|
2140
|
+
children: /* @__PURE__ */ t(ra, {})
|
|
2141
|
+
}
|
|
2142
|
+
)
|
|
2143
|
+
]
|
|
2144
|
+
}
|
|
2145
|
+
) : /* @__PURE__ */ s(Ee, { onOpenChange: (o) => {
|
|
2146
|
+
o && r();
|
|
2147
|
+
}, children: [
|
|
2148
|
+
/* @__PURE__ */ t(nt, { asChild: !0, children: /* @__PURE__ */ s(
|
|
2149
|
+
L,
|
|
2150
|
+
{
|
|
2151
|
+
variant: e ?? "ghost",
|
|
2152
|
+
size: "xs",
|
|
2153
|
+
className: "relative w-7 px-0",
|
|
2154
|
+
"aria-label": ge.title,
|
|
2155
|
+
title: ge.title,
|
|
2156
|
+
children: [
|
|
2157
|
+
/* @__PURE__ */ t(ea, { className: "h-3.5 w-3.5" }),
|
|
2158
|
+
n !== null && /* @__PURE__ */ t(
|
|
2159
|
+
"span",
|
|
2160
|
+
{
|
|
2161
|
+
className: `absolute flex items-center justify-center rounded-full bg-primary text-primary-foreground ${n ? "-right-0.5 -top-0.5 h-3.5 min-w-3.5 px-0.5 text-[9px] font-semibold" : "right-1 top-1 h-1.5 w-1.5"}`,
|
|
2162
|
+
children: n
|
|
2163
|
+
}
|
|
2164
|
+
)
|
|
2165
|
+
]
|
|
2166
|
+
}
|
|
2167
|
+
) }),
|
|
2168
|
+
/* @__PURE__ */ t(Te, { className: "w-80 p-0", align: "end", sideOffset: 8, children: /* @__PURE__ */ t(ra, {}) })
|
|
2169
|
+
] });
|
|
2170
|
+
}
|
|
2171
|
+
function ra() {
|
|
2172
|
+
const e = Lt(), a = bn(), { rows: r, browserRows: n, activeTruncated: i } = e.snapshot, o = r.some((d) => ft(d.item.status)), l = [
|
|
2173
|
+
...r.filter((d) => !ft(d.item.status)).map((d) => ({ startedAt: d.item.startedAt, row: d })),
|
|
2174
|
+
...n.map((d) => ({ startedAt: d.startedAt, work: d }))
|
|
2175
|
+
].sort((d, h) => h.startedAt.localeCompare(d.startedAt)), u = r.filter((d) => ft(d.item.status)), c = r.length + n.length;
|
|
2176
|
+
return c === 0 ? /* @__PURE__ */ s("div", { className: "flex flex-col items-center gap-1.5 px-6 py-8 text-center", children: [
|
|
2177
|
+
/* @__PURE__ */ t("span", { className: "flex h-8 w-8 items-center justify-center rounded-[6px] border border-border text-muted-foreground", children: /* @__PURE__ */ t(xn, { className: "h-3.5 w-3.5", strokeWidth: 1.75 }) }),
|
|
2178
|
+
/* @__PURE__ */ t("p", { className: "text-[13px] font-medium", children: ge.title }),
|
|
2179
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] text-muted-foreground", children: ge.empty })
|
|
2180
|
+
] }) : /* @__PURE__ */ s("div", { className: "flex flex-col", children: [
|
|
2181
|
+
/* @__PURE__ */ s("div", { className: "flex h-8 items-center gap-2 border-b border-border px-3", children: [
|
|
2182
|
+
/* @__PURE__ */ t("span", { className: "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: ge.title }),
|
|
2183
|
+
/* @__PURE__ */ t("span", { className: "text-[10px] tabular-nums text-muted-foreground/70", children: c }),
|
|
2184
|
+
/* @__PURE__ */ s("div", { className: "ml-auto flex items-center gap-0.5", children: [
|
|
2185
|
+
o && /* @__PURE__ */ t(
|
|
2186
|
+
L,
|
|
2187
|
+
{
|
|
2188
|
+
variant: "ghost",
|
|
2189
|
+
size: "xs",
|
|
2190
|
+
className: "h-6 px-1.5 text-[12px] text-muted-foreground hover:text-foreground",
|
|
2191
|
+
onClick: e.clearFinished,
|
|
2192
|
+
children: ge.clear
|
|
2193
|
+
}
|
|
2194
|
+
),
|
|
2195
|
+
/* @__PURE__ */ t(
|
|
2196
|
+
L,
|
|
2197
|
+
{
|
|
2198
|
+
variant: "ghost",
|
|
2199
|
+
size: "xs",
|
|
2200
|
+
className: "h-6 w-6 px-0 text-muted-foreground hover:text-foreground",
|
|
2201
|
+
onClick: e.refresh,
|
|
2202
|
+
title: "Refresh status",
|
|
2203
|
+
"aria-label": "Refresh status",
|
|
2204
|
+
children: /* @__PURE__ */ t(ba, { strokeWidth: 1.75, className: "h-3.5 w-3.5" })
|
|
2205
|
+
}
|
|
2206
|
+
)
|
|
2207
|
+
] })
|
|
2208
|
+
] }),
|
|
2209
|
+
i && /* @__PURE__ */ t("p", { className: "border-b border-border px-3 py-2 text-[12px] leading-4 text-muted-foreground", children: ge.truncated }),
|
|
2210
|
+
/* @__PURE__ */ t("div", { className: "max-h-[320px] overflow-y-auto", children: /* @__PURE__ */ s("div", { className: "divide-y divide-border/70", children: [
|
|
2211
|
+
l.map((d) => "work" in d ? /* @__PURE__ */ t(ps, { work: d.work, now: a }, d.work.id) : /* @__PURE__ */ t(na, { row: d.row, now: a, api: e }, $t(d.row))),
|
|
2212
|
+
u.map((d) => /* @__PURE__ */ t(na, { row: d, now: a, api: e }, $t(d)))
|
|
2213
|
+
] }) })
|
|
2214
|
+
] });
|
|
2215
|
+
}
|
|
2216
|
+
function fs(e) {
|
|
2217
|
+
if (e)
|
|
2218
|
+
return {
|
|
2219
|
+
renamed: e.type === "rename" ? { oldId: e.oldId, newId: e.newId } : void 0,
|
|
2220
|
+
removedControlId: e.type === "remove" ? e.controlId : void 0,
|
|
2221
|
+
cardBindingsById: e.type === "add" || e.type === "update" ? e.cardBindingsById : void 0,
|
|
2222
|
+
affectedBindingControlIds: e.type === "add" || e.type === "update" ? e.affectedBindingControlIds : void 0
|
|
2223
|
+
};
|
|
2224
|
+
}
|
|
2225
|
+
function gs({
|
|
2226
|
+
open: e,
|
|
2227
|
+
onOpenChange: a,
|
|
2228
|
+
trigger: r,
|
|
2229
|
+
showTrigger: n = !0,
|
|
2230
|
+
initialMode: i = "manage"
|
|
2231
|
+
}) {
|
|
2232
|
+
const o = i === "create", {
|
|
2233
|
+
forceClose: l,
|
|
2234
|
+
handleOpenChange: u,
|
|
2235
|
+
isCreateFlowActive: c,
|
|
2236
|
+
preventPassiveDismissDuringCreate: d,
|
|
2237
|
+
resolvedOpen: h,
|
|
2238
|
+
setIsCreateFlowActive: p
|
|
2239
|
+
} = Sa({
|
|
2240
|
+
open: e,
|
|
2241
|
+
onOpenChange: a,
|
|
2242
|
+
initialCreateFlowActive: i === "create",
|
|
2243
|
+
// Dialog mode renders a built-in X close button — allow explicit
|
|
2244
|
+
// closes through `handleOpenChange`. Popover mode has no X; its
|
|
2245
|
+
// only close-via-trigger path is a re-click that would silently
|
|
2246
|
+
// wipe the in-progress create flow, so block everything during
|
|
2247
|
+
// create and make consumers use `forceClose()` from a dedicated
|
|
2248
|
+
// button.
|
|
2249
|
+
dismissMode: n ? "passive" : "explicit-only"
|
|
2250
|
+
}), m = w((v) => v.dashboard), { setDashboardControlsModel: f } = ve(), { participants: g } = vn(wr(m)), y = Array.from(
|
|
2251
|
+
new Map(
|
|
2252
|
+
g.flatMap(
|
|
2253
|
+
(v) => v.fieldChoices.map((T) => {
|
|
2254
|
+
var I;
|
|
2255
|
+
return [
|
|
2256
|
+
T.value,
|
|
2257
|
+
{
|
|
2258
|
+
option: T,
|
|
2259
|
+
target: (I = v.fieldTargetMap) == null ? void 0 : I[T.value]
|
|
2260
|
+
}
|
|
2261
|
+
];
|
|
2262
|
+
})
|
|
2263
|
+
)
|
|
2264
|
+
).values()
|
|
2265
|
+
), N = Array.from(
|
|
2266
|
+
new Map(
|
|
2267
|
+
g.flatMap(
|
|
2268
|
+
(v) => v.metricChoices.map((T) => {
|
|
2269
|
+
var I;
|
|
2270
|
+
return [
|
|
2271
|
+
T.value,
|
|
2272
|
+
{
|
|
2273
|
+
option: T,
|
|
2274
|
+
target: (I = v.metricTargetMap) == null ? void 0 : I[T.value]
|
|
2275
|
+
}
|
|
2276
|
+
];
|
|
2277
|
+
})
|
|
2278
|
+
)
|
|
2279
|
+
).values()
|
|
2280
|
+
), k = nr({
|
|
2281
|
+
...m || {},
|
|
2282
|
+
controls: []
|
|
2283
|
+
}), V = yn(m), P = (v, T, I) => {
|
|
2284
|
+
f(
|
|
2285
|
+
v,
|
|
2286
|
+
T,
|
|
2287
|
+
fs(I)
|
|
2288
|
+
);
|
|
2289
|
+
}, D = ie(() => {
|
|
2290
|
+
if (o) {
|
|
2291
|
+
l();
|
|
2292
|
+
return;
|
|
2293
|
+
}
|
|
2294
|
+
p(!1);
|
|
2295
|
+
}, [o, l, p]), O = /* @__PURE__ */ t(
|
|
2296
|
+
ka,
|
|
2297
|
+
{
|
|
2298
|
+
scope: "dashboard",
|
|
2299
|
+
controls: m.controls || [],
|
|
2300
|
+
reservedControlIds: k,
|
|
2301
|
+
defaultValues: m.defaultControlValues || {},
|
|
2302
|
+
usageByControlId: Nn(m),
|
|
2303
|
+
availableFieldChoices: y,
|
|
2304
|
+
availableMetricChoices: N,
|
|
2305
|
+
structuralParticipants: g,
|
|
2306
|
+
structuralParticipantIdsByControlId: V,
|
|
2307
|
+
initialCreateFlow: i === "create",
|
|
2308
|
+
onCreateFlowActiveChange: p,
|
|
2309
|
+
onCreateFlowComplete: D,
|
|
2310
|
+
onChange: P,
|
|
2311
|
+
emptyMessage: "No dashboard controls yet."
|
|
2312
|
+
}
|
|
2313
|
+
), b = c ? "Add dashboard control" : "Dashboard Controls", S = /* @__PURE__ */ s(U, { children: [
|
|
2314
|
+
/* @__PURE__ */ s("div", { className: "space-y-1", children: [
|
|
2315
|
+
/* @__PURE__ */ t("h4", { className: "text-sm font-medium", children: "Dashboard Controls" }),
|
|
2316
|
+
/* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground", children: "Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control." })
|
|
2317
|
+
] }),
|
|
2318
|
+
O
|
|
2319
|
+
] });
|
|
2320
|
+
return n ? /* @__PURE__ */ s(Ee, { open: h, onOpenChange: u, children: [
|
|
2321
|
+
/* @__PURE__ */ t(nt, { asChild: !0, children: r || /* @__PURE__ */ s(L, { variant: "outline", className: "h-7 px-2", size: "sm", children: [
|
|
2322
|
+
/* @__PURE__ */ t(Ca, { className: "mr-2 h-4 w-4" }),
|
|
2323
|
+
"Controls"
|
|
2324
|
+
] }) }),
|
|
2325
|
+
/* @__PURE__ */ t(
|
|
2326
|
+
Te,
|
|
2327
|
+
{
|
|
2328
|
+
className: "w-[620px] max-w-[95vw] space-y-4",
|
|
2329
|
+
align: "end",
|
|
2330
|
+
onEscapeKeyDown: d,
|
|
2331
|
+
onPointerDownOutside: d,
|
|
2332
|
+
children: S
|
|
2333
|
+
}
|
|
2334
|
+
)
|
|
2335
|
+
] }) : /* @__PURE__ */ t(Le, { open: h, onOpenChange: u, children: /* @__PURE__ */ s(
|
|
2336
|
+
Ve,
|
|
2337
|
+
{
|
|
2338
|
+
className: "flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",
|
|
2339
|
+
onEscapeKeyDown: d,
|
|
2340
|
+
onPointerDownOutside: d,
|
|
2341
|
+
children: [
|
|
2342
|
+
/* @__PURE__ */ s(
|
|
2343
|
+
Tt,
|
|
2344
|
+
{
|
|
2345
|
+
className: c ? "space-y-0" : void 0,
|
|
2346
|
+
children: [
|
|
2347
|
+
/* @__PURE__ */ t(Pe, { className: "text-[15px]", children: b }),
|
|
2348
|
+
/* @__PURE__ */ t(
|
|
2349
|
+
ct,
|
|
2350
|
+
{
|
|
2351
|
+
className: c ? "sr-only" : "text-[13px]",
|
|
2352
|
+
children: c ? "Configure and add a shared dashboard control." : "Add shared controls viewers can use across the dashboard. Each card can decide how to respond to the same control."
|
|
2353
|
+
}
|
|
2354
|
+
)
|
|
2355
|
+
]
|
|
2356
|
+
}
|
|
2357
|
+
),
|
|
2358
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 overflow-y-auto pr-1", children: O })
|
|
2359
|
+
]
|
|
2360
|
+
}
|
|
2361
|
+
) });
|
|
2362
|
+
}
|
|
2363
|
+
const bs = [
|
|
2364
|
+
"enum",
|
|
2365
|
+
"multi_enum",
|
|
2366
|
+
"text",
|
|
2367
|
+
"number",
|
|
2368
|
+
"boolean",
|
|
2369
|
+
"date"
|
|
2370
|
+
];
|
|
2371
|
+
function xs({
|
|
2372
|
+
open: e,
|
|
2373
|
+
onOpenChange: a,
|
|
2374
|
+
initialMode: r = "manage"
|
|
2375
|
+
}) {
|
|
2376
|
+
var S;
|
|
2377
|
+
const n = r === "create", {
|
|
2378
|
+
forceClose: i,
|
|
2379
|
+
handleOpenChange: o,
|
|
2380
|
+
isCreateFlowActive: l,
|
|
2381
|
+
preventPassiveDismissDuringCreate: u,
|
|
2382
|
+
resolvedOpen: c,
|
|
2383
|
+
setIsCreateFlowActive: d
|
|
2384
|
+
} = Sa({
|
|
2385
|
+
open: e,
|
|
2386
|
+
onOpenChange: a,
|
|
2387
|
+
initialCreateFlowActive: r === "create",
|
|
2388
|
+
dismissMode: "explicit-only"
|
|
2389
|
+
}), h = w((v) => v.dashboard), p = w((v) => v.selectedSheetId), { setDashboardInputs: m } = ve(), f = (S = h.sheets) == null ? void 0 : S.find(
|
|
2390
|
+
(v) => v.id === p
|
|
2391
|
+
), g = (f == null ? void 0 : f.kind) === "document" && !!f.document, y = Y(
|
|
2392
|
+
() => g && (f != null && f.document) ? rr(h, f.id) : [],
|
|
2393
|
+
[h, g, f == null ? void 0 : f.document, f == null ? void 0 : f.id]
|
|
2394
|
+
), N = Y(
|
|
2395
|
+
() => y.filter(
|
|
2396
|
+
(v) => v.kind === "control"
|
|
2397
|
+
),
|
|
2398
|
+
[y]
|
|
2399
|
+
), k = Y(
|
|
2400
|
+
() => N.map((v) => v.control),
|
|
2401
|
+
[N]
|
|
2402
|
+
), V = Y(
|
|
2403
|
+
() => ys(k),
|
|
2404
|
+
[k]
|
|
2405
|
+
), P = Y(
|
|
2406
|
+
() => [
|
|
2407
|
+
...vs(h),
|
|
2408
|
+
...(h.variables ?? []).map((v) => v.name)
|
|
2409
|
+
],
|
|
2410
|
+
[h]
|
|
2411
|
+
), D = ie(() => {
|
|
2412
|
+
if (n) {
|
|
2413
|
+
i();
|
|
2414
|
+
return;
|
|
2415
|
+
}
|
|
2416
|
+
d(!1);
|
|
2417
|
+
}, [n, i, d]), O = ie(
|
|
2418
|
+
(v, T, I) => {
|
|
2419
|
+
!g || !(f != null && f.document) || m(
|
|
2420
|
+
Cs({
|
|
2421
|
+
dashboard: h,
|
|
2422
|
+
documentSheetId: f.id,
|
|
2423
|
+
currentDocumentInputs: y,
|
|
2424
|
+
nextControls: v,
|
|
2425
|
+
nextDefaultValues: T,
|
|
2426
|
+
change: I
|
|
2427
|
+
})
|
|
2428
|
+
);
|
|
2429
|
+
},
|
|
2430
|
+
[
|
|
2431
|
+
h,
|
|
2432
|
+
y,
|
|
2433
|
+
g,
|
|
2434
|
+
f,
|
|
2435
|
+
m
|
|
2436
|
+
]
|
|
2437
|
+
);
|
|
2438
|
+
return !g || !(f != null && f.document) ? null : /* @__PURE__ */ t(Le, { open: c, onOpenChange: o, children: /* @__PURE__ */ s(
|
|
2439
|
+
Ve,
|
|
2440
|
+
{
|
|
2441
|
+
className: "flex max-h-[88vh] flex-col overflow-hidden sm:max-w-[600px]",
|
|
2442
|
+
onEscapeKeyDown: u,
|
|
2443
|
+
onPointerDownOutside: u,
|
|
2444
|
+
children: [
|
|
2445
|
+
/* @__PURE__ */ s(Tt, { className: l ? "space-y-0" : void 0, children: [
|
|
2446
|
+
/* @__PURE__ */ t(Pe, { className: "text-[15px]", children: l ? "Add document control" : "Document Controls" }),
|
|
2447
|
+
/* @__PURE__ */ t(
|
|
2448
|
+
ct,
|
|
2449
|
+
{
|
|
2450
|
+
className: l ? "sr-only" : "text-[13px]",
|
|
2451
|
+
children: l ? "Configure and add a document-local control input." : "Add document-local control inputs. They are stored on this document sheet and are not dashboard controls."
|
|
2452
|
+
}
|
|
2453
|
+
)
|
|
2454
|
+
] }),
|
|
2455
|
+
/* @__PURE__ */ t("div", { className: "min-h-0 overflow-y-auto pr-1", children: /* @__PURE__ */ t(
|
|
2456
|
+
ka,
|
|
2457
|
+
{
|
|
2458
|
+
scope: "dashboard",
|
|
2459
|
+
controls: k,
|
|
2460
|
+
reservedControlIds: P,
|
|
2461
|
+
defaultValues: V,
|
|
2462
|
+
usageByControlId: {},
|
|
2463
|
+
availableFieldChoices: [],
|
|
2464
|
+
availableMetricChoices: [],
|
|
2465
|
+
structuralParticipants: [],
|
|
2466
|
+
structuralParticipantIdsByControlId: {},
|
|
2467
|
+
allowedControlTypes: bs,
|
|
2468
|
+
initialCreateFlow: r === "create",
|
|
2469
|
+
onCreateFlowActiveChange: d,
|
|
2470
|
+
onCreateFlowComplete: D,
|
|
2471
|
+
onChange: O,
|
|
2472
|
+
emptyMessage: "No document controls yet."
|
|
2473
|
+
}
|
|
2474
|
+
) })
|
|
2475
|
+
]
|
|
2476
|
+
}
|
|
2477
|
+
) });
|
|
2478
|
+
}
|
|
2479
|
+
function vs(e) {
|
|
2480
|
+
return (e.controls || []).map((a) => a.id);
|
|
2481
|
+
}
|
|
2482
|
+
function ys(e) {
|
|
2483
|
+
const a = {};
|
|
2484
|
+
for (const r of e)
|
|
2485
|
+
r.defaultValue !== void 0 && (a[r.id] = r.defaultValue);
|
|
2486
|
+
return a;
|
|
2487
|
+
}
|
|
2488
|
+
function Ns(e, a) {
|
|
2489
|
+
return a ? Object.prototype.hasOwnProperty.call(a, e.id) ? {
|
|
2490
|
+
...e,
|
|
2491
|
+
defaultValue: a[e.id]
|
|
2492
|
+
} : e.defaultValue === void 0 ? e : { ...e, defaultValue: void 0 } : e.defaultValue === void 0 ? e : { ...e, defaultValue: void 0 };
|
|
2493
|
+
}
|
|
2494
|
+
function Cs({
|
|
2495
|
+
dashboard: e,
|
|
2496
|
+
documentSheetId: a,
|
|
2497
|
+
currentDocumentInputs: r,
|
|
2498
|
+
nextControls: n,
|
|
2499
|
+
nextDefaultValues: i,
|
|
2500
|
+
change: o
|
|
2501
|
+
}) {
|
|
2502
|
+
const l = new Map(
|
|
2503
|
+
n.map((f) => [
|
|
2504
|
+
f.id,
|
|
2505
|
+
Ns(f, i)
|
|
2506
|
+
])
|
|
2507
|
+
), u = (o == null ? void 0 : o.type) === "rename" ? { oldId: o.oldId, newId: o.newId } : null, c = /* @__PURE__ */ new Set(), d = [];
|
|
2508
|
+
for (const f of r) {
|
|
2509
|
+
if (f.kind !== "control") {
|
|
2510
|
+
d.push(f);
|
|
2511
|
+
continue;
|
|
2512
|
+
}
|
|
2513
|
+
const g = l.get(f.control.id) || ((u == null ? void 0 : u.oldId) === f.control.id ? l.get(u.newId) : void 0);
|
|
2514
|
+
if (!g)
|
|
2515
|
+
continue;
|
|
2516
|
+
c.add(g.id);
|
|
2517
|
+
const y = sr(
|
|
2518
|
+
e,
|
|
2519
|
+
{ name: g.id },
|
|
2520
|
+
{ exclude: { source: "input", inputId: f.id }, alsoTaken: d }
|
|
2521
|
+
), N = g.id === y ? g : { ...g, id: y };
|
|
2522
|
+
d.push({
|
|
2523
|
+
...f,
|
|
2524
|
+
label: N.label,
|
|
2525
|
+
variableName: y,
|
|
2526
|
+
requiredAtExecution: N.requiredAtExecution,
|
|
2527
|
+
control: N
|
|
2528
|
+
});
|
|
2529
|
+
}
|
|
2530
|
+
for (const f of l.values())
|
|
2531
|
+
c.has(f.id) || d.push(
|
|
2532
|
+
ir({
|
|
2533
|
+
control: f,
|
|
2534
|
+
dashboard: e,
|
|
2535
|
+
alsoTaken: d,
|
|
2536
|
+
sheetId: a
|
|
2537
|
+
})
|
|
2538
|
+
);
|
|
2539
|
+
const h = new Set(
|
|
2540
|
+
r.map((f) => f.id)
|
|
2541
|
+
);
|
|
2542
|
+
return [...(Array.isArray(e.inputs) ? e.inputs : []).filter(
|
|
2543
|
+
(f) => !h.has(f.id)
|
|
2544
|
+
), ...d];
|
|
2545
|
+
}
|
|
2546
|
+
function ws({
|
|
2547
|
+
showFilters: e,
|
|
2548
|
+
onShowFiltersChange: a,
|
|
2549
|
+
pickerContent: r,
|
|
2550
|
+
settingsContent: n,
|
|
2551
|
+
size: i = "default",
|
|
2552
|
+
className: o,
|
|
2553
|
+
primaryButtonClassName: l,
|
|
2554
|
+
secondaryButtonClassName: u,
|
|
2555
|
+
pickerContentClassName: c,
|
|
2556
|
+
settingsContentClassName: d
|
|
2557
|
+
}) {
|
|
2558
|
+
const h = i === "toolbar", [p, m] = A(!1), f = it("interactive");
|
|
2559
|
+
return /* @__PURE__ */ s(
|
|
2560
|
+
"div",
|
|
2561
|
+
{
|
|
2562
|
+
className: J(
|
|
2563
|
+
// Height lives on the shell so the outer border is part of the
|
|
2564
|
+
// h-7 box (matches regular `size="xs"` buttons). Inner triggers
|
|
2565
|
+
// stretch to fill via `h-full`.
|
|
2566
|
+
"relative inline-flex items-stretch overflow-hidden rounded-control border border-input bg-background",
|
|
2567
|
+
h ? "h-8" : "h-7",
|
|
2568
|
+
o
|
|
2569
|
+
),
|
|
2570
|
+
children: [
|
|
2571
|
+
/* @__PURE__ */ s(Ee, { open: e, onOpenChange: a, children: [
|
|
2572
|
+
/* @__PURE__ */ t(nt, { asChild: !0, children: /* @__PURE__ */ s(
|
|
2573
|
+
L,
|
|
2574
|
+
{
|
|
2575
|
+
variant: "ghost",
|
|
2576
|
+
size: "xs",
|
|
2577
|
+
className: J(
|
|
2578
|
+
"h-full rounded-none border-0 bg-transparent pl-2.5 pr-2 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",
|
|
2579
|
+
l
|
|
2580
|
+
),
|
|
2581
|
+
children: [
|
|
2582
|
+
e ? /* @__PURE__ */ t(Er, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(xa, { className: "h-3.5 w-3.5" }),
|
|
2583
|
+
"Filter"
|
|
2584
|
+
]
|
|
2585
|
+
}
|
|
2586
|
+
) }),
|
|
2587
|
+
/* @__PURE__ */ t(
|
|
2588
|
+
Te,
|
|
2589
|
+
{
|
|
2590
|
+
align: "end",
|
|
2591
|
+
sideOffset: 6,
|
|
2592
|
+
className: J(
|
|
2593
|
+
"w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",
|
|
2594
|
+
c
|
|
2595
|
+
),
|
|
2596
|
+
style: f.contentStyle,
|
|
2597
|
+
children: r
|
|
2598
|
+
}
|
|
2599
|
+
)
|
|
2600
|
+
] }),
|
|
2601
|
+
/* @__PURE__ */ s(Ee, { open: p, onOpenChange: m, children: [
|
|
2602
|
+
/* @__PURE__ */ t(nt, { asChild: !0, children: /* @__PURE__ */ t(
|
|
2603
|
+
L,
|
|
2604
|
+
{
|
|
2605
|
+
variant: "ghost",
|
|
2606
|
+
size: "xs",
|
|
2607
|
+
className: J(
|
|
2608
|
+
"h-full w-7 rounded-none border-0 border-l border-border/60 bg-transparent px-0 shadow-none hover:bg-accent/50 data-[state=open]:bg-accent/60",
|
|
2609
|
+
u
|
|
2610
|
+
),
|
|
2611
|
+
"aria-label": "Filter and control actions",
|
|
2612
|
+
children: /* @__PURE__ */ t(_t, { className: "h-3.5 w-3.5" })
|
|
2613
|
+
}
|
|
2614
|
+
) }),
|
|
2615
|
+
/* @__PURE__ */ t(
|
|
2616
|
+
Te,
|
|
2617
|
+
{
|
|
2618
|
+
align: "end",
|
|
2619
|
+
sideOffset: 6,
|
|
2620
|
+
className: J(
|
|
2621
|
+
"w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",
|
|
2622
|
+
d
|
|
2623
|
+
),
|
|
2624
|
+
style: f.contentStyle,
|
|
2625
|
+
children: n(() => m(!1))
|
|
2626
|
+
}
|
|
2627
|
+
)
|
|
2628
|
+
] })
|
|
2629
|
+
]
|
|
2630
|
+
}
|
|
2631
|
+
);
|
|
2632
|
+
}
|
|
2633
|
+
function Ss() {
|
|
2634
|
+
Tr();
|
|
2635
|
+
const e = w((c) => c.selectedSheetId), a = w((c) => c.selectedFrameId), r = w((c) => c.dashboard), n = w((c) => c.actions.getSelectedFrame), { setSelectedFrameId: i } = ve(), { setCard: o } = dt(), l = oe((c) => c.card.dataSource);
|
|
2636
|
+
return Ie(() => {
|
|
2637
|
+
var d, h;
|
|
2638
|
+
let c = n();
|
|
2639
|
+
if (!c) {
|
|
2640
|
+
const p = (d = r == null ? void 0 : r.sheets) == null ? void 0 : d.find((f) => f.id === e), m = (h = p == null ? void 0 : p.frames) == null ? void 0 : h[0];
|
|
2641
|
+
m && (i(m.id), c = m);
|
|
2642
|
+
}
|
|
2643
|
+
if (c) {
|
|
2644
|
+
const p = c.cards.find((m) => m.id === c.activeCardId);
|
|
2645
|
+
p && o(p);
|
|
2646
|
+
}
|
|
2647
|
+
}, [n, e, a, r, i, o]), {
|
|
2648
|
+
hasEntities: !!(l != null && l.selectedEntities && l.selectedEntities.length > 0)
|
|
2649
|
+
};
|
|
2650
|
+
}
|
|
2651
|
+
function ks() {
|
|
2652
|
+
const e = w((c) => c.dashboard), a = w(
|
|
2653
|
+
(c) => c.semanticExecutionPayload
|
|
2654
|
+
), r = w(
|
|
2655
|
+
(c) => c.actions.addFilterInput
|
|
2656
|
+
), { hasEntities: n } = Ss(), { isLoading: i } = Cn(), o = Y(
|
|
2657
|
+
() => or(e, a),
|
|
2658
|
+
[e, a]
|
|
2659
|
+
), u = !lr(e) && o.hasEligibleCards && !i;
|
|
2660
|
+
return /* @__PURE__ */ s("div", { className: "flex h-[520px] w-[400px] flex-col", children: [
|
|
2661
|
+
u && /* @__PURE__ */ t("div", { className: "border-b border-border/60 p-2", children: /* @__PURE__ */ s(
|
|
2662
|
+
"button",
|
|
2663
|
+
{
|
|
2664
|
+
type: "button",
|
|
2665
|
+
onClick: () => r(dr(), {
|
|
2666
|
+
kind: "allSheets",
|
|
2667
|
+
sheetKinds: ["dashboard"]
|
|
2668
|
+
}),
|
|
2669
|
+
title: `Applies to ${o.eligibleCardCount} of ${o.totalCardCount} date-aware cards`,
|
|
2670
|
+
className: "flex w-full items-start gap-2 rounded-control px-2 py-1.5 text-left outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-border",
|
|
2671
|
+
children: [
|
|
2672
|
+
/* @__PURE__ */ t(Qr, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
|
|
2673
|
+
/* @__PURE__ */ s("span", { className: "flex min-w-0 flex-col", children: [
|
|
2674
|
+
/* @__PURE__ */ t("span", { className: "text-[12px] font-medium text-foreground", children: "Add global date filter" }),
|
|
2675
|
+
/* @__PURE__ */ t("span", { className: "text-[11px] leading-[1.4] text-muted-foreground", children: "One date range across all date-aware cards." })
|
|
2676
|
+
] })
|
|
2677
|
+
]
|
|
2678
|
+
}
|
|
2679
|
+
) }),
|
|
2680
|
+
!n && /* @__PURE__ */ s("div", { className: "flex flex-1 flex-col items-center justify-center px-6 py-8 text-center", children: [
|
|
2681
|
+
/* @__PURE__ */ t(wn, { className: "mb-3 h-10 w-10 text-muted-foreground/50" }),
|
|
2682
|
+
/* @__PURE__ */ t("h3", { className: "mb-1 text-[13px] font-medium text-foreground", children: "No fields configured" }),
|
|
2683
|
+
/* @__PURE__ */ t("p", { className: "text-[11px] text-muted-foreground", children: "Configure a data source for this card to enable filtering." })
|
|
2684
|
+
] }),
|
|
2685
|
+
n && /* @__PURE__ */ t("div", { className: "flex flex-1 overflow-hidden", children: /* @__PURE__ */ t(Sn, { context: "filter" }) })
|
|
2686
|
+
] });
|
|
2687
|
+
}
|
|
2688
|
+
function Ds({
|
|
2689
|
+
onAddFilter: e,
|
|
2690
|
+
onAddControl: a,
|
|
2691
|
+
onManageControls: r,
|
|
2692
|
+
onDismiss: n
|
|
2693
|
+
}) {
|
|
2694
|
+
const i = w(
|
|
2695
|
+
(u) => u.dashboard.filterLayout
|
|
2696
|
+
), { setFilterLayout: o } = ve(), l = (i == null ? void 0 : i.toolbarWrap) ?? !1;
|
|
2697
|
+
return /* @__PURE__ */ s("div", { className: "w-[300px]", children: [
|
|
2698
|
+
/* @__PURE__ */ s("div", { className: "p-1", children: [
|
|
2699
|
+
/* @__PURE__ */ t(
|
|
2700
|
+
xt,
|
|
2701
|
+
{
|
|
2702
|
+
icon: xa,
|
|
2703
|
+
label: "Add filter",
|
|
2704
|
+
onClick: () => {
|
|
2705
|
+
e(), n();
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
),
|
|
2709
|
+
/* @__PURE__ */ t(
|
|
2710
|
+
xt,
|
|
2711
|
+
{
|
|
2712
|
+
icon: Ca,
|
|
2713
|
+
label: "Add control",
|
|
2714
|
+
onClick: () => {
|
|
2715
|
+
a(), n();
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
),
|
|
2719
|
+
/* @__PURE__ */ t(
|
|
2720
|
+
xt,
|
|
2721
|
+
{
|
|
2722
|
+
icon: Vt,
|
|
2723
|
+
label: "Manage controls",
|
|
2724
|
+
onClick: () => {
|
|
2725
|
+
r(), n();
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
)
|
|
2729
|
+
] }),
|
|
2730
|
+
/* @__PURE__ */ t("div", { className: "border-t border-border/60" }),
|
|
2731
|
+
/* @__PURE__ */ s("div", { className: "space-y-1 p-2", children: [
|
|
2732
|
+
/* @__PURE__ */ t("p", { className: "px-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", children: "Display" }),
|
|
2733
|
+
/* @__PURE__ */ t(
|
|
2734
|
+
As,
|
|
2735
|
+
{
|
|
2736
|
+
id: "filter-display-wrap",
|
|
2737
|
+
label: "Wrap to multiple lines",
|
|
2738
|
+
checked: l,
|
|
2739
|
+
onCheckedChange: (u) => o({ toolbarWrap: u === !0 })
|
|
2740
|
+
}
|
|
2741
|
+
)
|
|
2742
|
+
] })
|
|
2743
|
+
] });
|
|
2744
|
+
}
|
|
2745
|
+
function xt({
|
|
2746
|
+
icon: e,
|
|
2747
|
+
label: a,
|
|
2748
|
+
onClick: r
|
|
2749
|
+
}) {
|
|
2750
|
+
return /* @__PURE__ */ s(
|
|
2751
|
+
"button",
|
|
2752
|
+
{
|
|
2753
|
+
type: "button",
|
|
2754
|
+
onClick: r,
|
|
2755
|
+
className: "flex w-full items-center gap-2 rounded-control px-2 py-1.5 text-left text-[13px] text-foreground outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40",
|
|
2756
|
+
children: [
|
|
2757
|
+
/* @__PURE__ */ t(e, { className: "h-3.5 w-3.5 text-muted-foreground" }),
|
|
2758
|
+
a
|
|
2759
|
+
]
|
|
2760
|
+
}
|
|
2761
|
+
);
|
|
2762
|
+
}
|
|
2763
|
+
function As({
|
|
2764
|
+
id: e,
|
|
2765
|
+
label: a,
|
|
2766
|
+
checked: r,
|
|
2767
|
+
onCheckedChange: n
|
|
2768
|
+
}) {
|
|
2769
|
+
return /* @__PURE__ */ s("div", { className: "flex items-center gap-2 rounded-control px-1 py-1 transition-colors hover:bg-muted/40 focus-within:bg-muted/40", children: [
|
|
2770
|
+
/* @__PURE__ */ t(Et, { id: e, checked: r, onCheckedChange: n }),
|
|
2771
|
+
/* @__PURE__ */ t(
|
|
2772
|
+
Re,
|
|
2773
|
+
{
|
|
2774
|
+
htmlFor: e,
|
|
2775
|
+
className: "cursor-pointer text-[12px] font-normal leading-[1.3]",
|
|
2776
|
+
children: a
|
|
2777
|
+
}
|
|
2778
|
+
)
|
|
2779
|
+
] });
|
|
2780
|
+
}
|
|
2781
|
+
function ro({
|
|
2782
|
+
size: e,
|
|
2783
|
+
className: a,
|
|
2784
|
+
primaryButtonClassName: r,
|
|
2785
|
+
secondaryButtonClassName: n,
|
|
2786
|
+
pickerContentClassName: i,
|
|
2787
|
+
settingsContentClassName: o
|
|
2788
|
+
}) {
|
|
2789
|
+
var O;
|
|
2790
|
+
const [l, u] = A(null), c = w((b) => b.dashboard), d = w((b) => b.selectedSheetId), h = w((b) => b.showFilters), p = w((b) => b.actions), { setDocumentPanelTarget: m, setShowFilters: f } = p, g = (O = c.sheets) == null ? void 0 : O.find(
|
|
2791
|
+
(b) => b.id === d
|
|
2792
|
+
), y = Ke(g), N = ie((b) => {
|
|
2793
|
+
window.setTimeout(() => {
|
|
2794
|
+
u(b);
|
|
2795
|
+
}, 0);
|
|
2796
|
+
}, []), k = ie(
|
|
2797
|
+
(b) => {
|
|
2798
|
+
if (y && d) {
|
|
2799
|
+
b && m(d, {
|
|
2800
|
+
kind: "document",
|
|
2801
|
+
group: "inputs"
|
|
2802
|
+
});
|
|
2803
|
+
return;
|
|
2804
|
+
}
|
|
2805
|
+
f(b);
|
|
2806
|
+
},
|
|
2807
|
+
[
|
|
2808
|
+
y,
|
|
2809
|
+
d,
|
|
2810
|
+
m,
|
|
2811
|
+
f
|
|
2812
|
+
]
|
|
2813
|
+
), V = ie(() => {
|
|
2814
|
+
k(!0);
|
|
2815
|
+
}, [k]), P = ie(() => {
|
|
2816
|
+
N("create");
|
|
2817
|
+
}, [N]), D = ie(() => {
|
|
2818
|
+
N("manage");
|
|
2819
|
+
}, [N]);
|
|
2820
|
+
return /* @__PURE__ */ s(U, { children: [
|
|
2821
|
+
/* @__PURE__ */ t(
|
|
2822
|
+
ws,
|
|
2823
|
+
{
|
|
2824
|
+
showFilters: y ? !1 : h,
|
|
2825
|
+
onShowFiltersChange: k,
|
|
2826
|
+
pickerContent: /* @__PURE__ */ t(ks, {}),
|
|
2827
|
+
settingsContent: (b) => /* @__PURE__ */ t(
|
|
2828
|
+
Ds,
|
|
2829
|
+
{
|
|
2830
|
+
onAddFilter: V,
|
|
2831
|
+
onAddControl: P,
|
|
2832
|
+
onManageControls: D,
|
|
2833
|
+
onDismiss: b
|
|
2834
|
+
}
|
|
2835
|
+
),
|
|
2836
|
+
size: e,
|
|
2837
|
+
className: a,
|
|
2838
|
+
primaryButtonClassName: r,
|
|
2839
|
+
secondaryButtonClassName: n,
|
|
2840
|
+
pickerContentClassName: i,
|
|
2841
|
+
settingsContentClassName: o
|
|
2842
|
+
}
|
|
2843
|
+
),
|
|
2844
|
+
l ? y ? /* @__PURE__ */ t(
|
|
2845
|
+
xs,
|
|
2846
|
+
{
|
|
2847
|
+
open: !0,
|
|
2848
|
+
onOpenChange: (b) => {
|
|
2849
|
+
b || u(null);
|
|
2850
|
+
},
|
|
2851
|
+
initialMode: l
|
|
2852
|
+
}
|
|
2853
|
+
) : /* @__PURE__ */ t(
|
|
2854
|
+
gs,
|
|
2855
|
+
{
|
|
2856
|
+
open: !0,
|
|
2857
|
+
onOpenChange: (b) => {
|
|
2858
|
+
b || u(null);
|
|
2859
|
+
},
|
|
2860
|
+
showTrigger: !1,
|
|
2861
|
+
initialMode: l
|
|
2862
|
+
}
|
|
2863
|
+
) : null
|
|
2864
|
+
] });
|
|
2865
|
+
}
|
|
2866
|
+
function Fs(e, a) {
|
|
2867
|
+
return (e.variables ?? []).map((r) => {
|
|
2868
|
+
const n = Sr(e, r.id);
|
|
2869
|
+
return {
|
|
2870
|
+
variable: r,
|
|
2871
|
+
question: Br(r),
|
|
2872
|
+
places: n,
|
|
2873
|
+
usedHere: !!a && n.some((i) => i.sheetId === a)
|
|
2874
|
+
};
|
|
2875
|
+
});
|
|
2876
|
+
}
|
|
2877
|
+
function Is(e, a) {
|
|
2878
|
+
const r = a ? e.places.filter((i) => i.sheetId === a).length : 0, n = e.places.length - r;
|
|
2879
|
+
return e.places.length ? r && n ? `Used here · ${n} elsewhere` : r ? "Used here" : `Used in ${n} ${n === 1 ? "place" : "places"}` : "Not used yet";
|
|
2880
|
+
}
|
|
2881
|
+
function Es({
|
|
2882
|
+
dashboard: e,
|
|
2883
|
+
sheetId: a,
|
|
2884
|
+
sheetTitle: r,
|
|
2885
|
+
onOpen: n,
|
|
2886
|
+
onNew: i
|
|
2887
|
+
}) {
|
|
2888
|
+
const [o, l] = A(""), u = Y(() => Fs(e, a), [e, a]), c = o.trim().toLowerCase(), d = u.filter(
|
|
2889
|
+
(m) => !c || m.variable.name.toLowerCase().includes(c) || (m.variable.label ?? "").toLowerCase().includes(c) || m.question.toLowerCase().includes(c)
|
|
2890
|
+
), h = d.filter((m) => m.usedHere), p = d.filter((m) => !m.usedHere);
|
|
2891
|
+
return /* @__PURE__ */ s("div", { className: "w-[380px] max-w-[calc(100vw-24px)] overflow-hidden", "data-testid": "variables-list", children: [
|
|
2892
|
+
/* @__PURE__ */ s("div", { className: "flex h-11 items-center justify-between gap-2 border-b border-border/60 px-3", children: [
|
|
2893
|
+
/* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
|
|
2894
|
+
/* @__PURE__ */ t(Nt, { className: "h-3.5 w-3.5 text-muted-foreground", "aria-hidden": !0 }),
|
|
2895
|
+
/* @__PURE__ */ t("span", { className: "text-[13px] font-medium", children: "Data variables" }),
|
|
2896
|
+
u.length ? /* @__PURE__ */ t("span", { className: "rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium tabular-nums text-muted-foreground", children: u.length }) : null
|
|
2897
|
+
] }),
|
|
2898
|
+
u.length ? /* @__PURE__ */ s(L, { size: "xs", className: "gap-1", onClick: i, children: [
|
|
2899
|
+
/* @__PURE__ */ t(be, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
|
|
2900
|
+
" New variable"
|
|
2901
|
+
] }) : null
|
|
2902
|
+
] }),
|
|
2903
|
+
u.length ? /* @__PURE__ */ s(U, { children: [
|
|
2904
|
+
/* @__PURE__ */ t("div", { className: "px-3 py-2", children: /* @__PURE__ */ s("div", { className: "flex h-7 items-center gap-1.5 rounded-control border border-border px-2 text-[12px] text-muted-foreground", children: [
|
|
2905
|
+
/* @__PURE__ */ t(ca, { className: "h-3.5 w-3.5 shrink-0", "aria-hidden": !0 }),
|
|
2906
|
+
/* @__PURE__ */ t(
|
|
2907
|
+
"input",
|
|
2908
|
+
{
|
|
2909
|
+
value: o,
|
|
2910
|
+
onChange: (m) => l(m.target.value),
|
|
2911
|
+
placeholder: "Search variables",
|
|
2912
|
+
"aria-label": "Search variables",
|
|
2913
|
+
className: "w-full bg-transparent text-foreground outline-none placeholder:text-muted-foreground"
|
|
2914
|
+
}
|
|
2915
|
+
)
|
|
2916
|
+
] }) }),
|
|
2917
|
+
/* @__PURE__ */ s("div", { className: "max-h-[360px] overflow-y-auto", children: [
|
|
2918
|
+
h.length ? /* @__PURE__ */ t(sa, { children: r ? `On ${r}` : "On this tab" }) : null,
|
|
2919
|
+
h.map((m) => /* @__PURE__ */ t(ia, { row: m, sheetId: a, onOpen: n }, m.variable.id)),
|
|
2920
|
+
p.length ? /* @__PURE__ */ t(sa, { children: h.length ? "Elsewhere on this dashboard" : "On this dashboard" }) : null,
|
|
2921
|
+
p.map((m) => /* @__PURE__ */ t(ia, { row: m, sheetId: a, onOpen: n, muted: !!h.length }, m.variable.id)),
|
|
2922
|
+
d.length ? null : /* @__PURE__ */ t("p", { className: "px-4 py-6 text-center text-[12px] text-muted-foreground", children: "No variable matches." })
|
|
2923
|
+
] })
|
|
2924
|
+
] }) : /* @__PURE__ */ s("div", { className: "px-6 py-8 text-center", children: [
|
|
2925
|
+
/* @__PURE__ */ t("span", { className: "mx-auto flex h-8 w-8 items-center justify-center rounded-full bg-muted", children: /* @__PURE__ */ t(Nt, { className: "h-4 w-4 text-muted-foreground", "aria-hidden": !0 }) }),
|
|
2926
|
+
/* @__PURE__ */ t("p", { className: "mt-3 text-[13px] font-medium", children: "No variables yet" }),
|
|
2927
|
+
/* @__PURE__ */ t("p", { className: "mx-auto mt-1 max-w-[280px] text-[12px] leading-[1.5] text-muted-foreground", children: "A variable shows a value from your data in any text: a name or address in a header, the latest date in a footer." }),
|
|
2928
|
+
/* @__PURE__ */ s(L, { size: "xs", className: "mt-4 gap-1", onClick: i, children: [
|
|
2929
|
+
/* @__PURE__ */ t(be, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
|
|
2930
|
+
" New variable"
|
|
2931
|
+
] })
|
|
2932
|
+
] })
|
|
2933
|
+
] });
|
|
2934
|
+
}
|
|
2935
|
+
function sa({ children: e }) {
|
|
2936
|
+
return /* @__PURE__ */ t("p", { className: "border-y border-border/60 bg-muted/40 px-4 py-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground first:border-t-0", children: e });
|
|
2937
|
+
}
|
|
2938
|
+
function ia({
|
|
2939
|
+
row: e,
|
|
2940
|
+
sheetId: a,
|
|
2941
|
+
onOpen: r,
|
|
2942
|
+
muted: n
|
|
2943
|
+
}) {
|
|
2944
|
+
return /* @__PURE__ */ s(
|
|
2945
|
+
"button",
|
|
2946
|
+
{
|
|
2947
|
+
type: "button",
|
|
2948
|
+
onClick: () => r(e.variable.id),
|
|
2949
|
+
className: "grid w-full grid-cols-[minmax(0,1fr)_132px] items-center gap-3 border-t border-border/60 px-4 py-2 text-left first:border-t-0 hover:bg-muted/50",
|
|
2950
|
+
children: [
|
|
2951
|
+
/* @__PURE__ */ s("span", { className: "min-w-0", children: [
|
|
2952
|
+
/* @__PURE__ */ t("span", { className: J("block truncate text-[12px] font-medium text-foreground", !e.variable.label && "font-mono"), children: e.variable.label || e.variable.name }),
|
|
2953
|
+
/* @__PURE__ */ t("span", { className: "mt-0.5 block truncate text-[11px] text-muted-foreground", children: e.question })
|
|
2954
|
+
] }),
|
|
2955
|
+
/* @__PURE__ */ t("span", { className: J("truncate text-right text-[11px]", n ? "text-muted-foreground/70" : "text-muted-foreground"), children: Is(e, a) })
|
|
2956
|
+
]
|
|
2957
|
+
}
|
|
2958
|
+
);
|
|
2959
|
+
}
|
|
2960
|
+
function so() {
|
|
2961
|
+
const e = w((r) => {
|
|
2962
|
+
var n;
|
|
2963
|
+
return ((n = r.dashboard.variables) == null ? void 0 : n.length) ?? 0;
|
|
2964
|
+
}), a = w((r) => r.actions.setVariablesListOpen);
|
|
2965
|
+
return { label: "Data variables", count: e, open: () => a(!0) };
|
|
2966
|
+
}
|
|
2967
|
+
function io() {
|
|
2968
|
+
var c;
|
|
2969
|
+
const e = w((d) => d.variablesListOpen), a = w((d) => d.actions.setVariablesListOpen), r = w((d) => d.dashboard), n = w((d) => d.selectedSheetId), i = w((d) => d.actions.openVariableEditor), o = it("interactive"), l = (c = r.sheets) == null ? void 0 : c.find((d) => d.id === n), u = (d) => {
|
|
2970
|
+
a(!1), i(d);
|
|
2971
|
+
};
|
|
2972
|
+
return /* @__PURE__ */ s(Ee, { open: e, onOpenChange: a, children: [
|
|
2973
|
+
/* @__PURE__ */ t(Na, { asChild: !0, children: /* @__PURE__ */ t("span", { "aria-hidden": !0, className: "pointer-events-none inline-block h-7 w-0 self-center" }) }),
|
|
2974
|
+
/* @__PURE__ */ t(
|
|
2975
|
+
Te,
|
|
2976
|
+
{
|
|
2977
|
+
align: "end",
|
|
2978
|
+
sideOffset: 6,
|
|
2979
|
+
collisionPadding: 12,
|
|
2980
|
+
onFocusOutside: (d) => d.preventDefault(),
|
|
2981
|
+
className: "z-50 w-auto rounded-card border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",
|
|
2982
|
+
style: o.contentStyle,
|
|
2983
|
+
children: /* @__PURE__ */ t(
|
|
2984
|
+
Es,
|
|
2985
|
+
{
|
|
2986
|
+
dashboard: r,
|
|
2987
|
+
sheetId: n ?? void 0,
|
|
2988
|
+
sheetTitle: l == null ? void 0 : l.title,
|
|
2989
|
+
onOpen: (d) => u({ kind: "edit", variableId: d }),
|
|
2990
|
+
onNew: () => u({ kind: "new" })
|
|
2991
|
+
}
|
|
2992
|
+
)
|
|
2993
|
+
}
|
|
2994
|
+
)
|
|
2995
|
+
] });
|
|
2996
|
+
}
|
|
2997
|
+
function Ts(e, a) {
|
|
2998
|
+
const r = cr(e);
|
|
2999
|
+
return new Set(
|
|
3000
|
+
(e.sheets ?? []).map((i) => {
|
|
3001
|
+
const o = { sheetId: i.id, cardId: a, sheetKind: Ke(i) ? "document" : "dashboard" };
|
|
3002
|
+
return r.filter((l) => kr(l, o)).map((l) => l.runtimeScope === "shared" ? l.id : `${l.id}@${i.id}`).join(`
|
|
3003
|
+
`);
|
|
3004
|
+
})
|
|
3005
|
+
).size > 1;
|
|
3006
|
+
}
|
|
3007
|
+
const Ls = [];
|
|
3008
|
+
function vt(e) {
|
|
3009
|
+
return Object.fromEntries(
|
|
3010
|
+
Object.entries(e).filter(([, a]) => a != null)
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
3013
|
+
function Vs(e) {
|
|
3014
|
+
const a = e == null ? void 0 : e.type;
|
|
3015
|
+
return a === "dataset" || a === "model" || hr.includes(a);
|
|
3016
|
+
}
|
|
3017
|
+
function Ps(e, a) {
|
|
3018
|
+
return _r(
|
|
3019
|
+
e.map((r, n) => {
|
|
3020
|
+
var i, o;
|
|
3021
|
+
return {
|
|
3022
|
+
target: r,
|
|
3023
|
+
columns: (i = a[n]) == null ? void 0 : i.columns,
|
|
3024
|
+
calculatedFields: (o = a[n]) == null ? void 0 : o.calculatedFields
|
|
3025
|
+
};
|
|
3026
|
+
})
|
|
3027
|
+
).columns;
|
|
3028
|
+
}
|
|
3029
|
+
function Bs(e) {
|
|
3030
|
+
const { tokenProps: a } = $e(), r = w((m) => m.authToken), { connections: n } = va(), i = e == null ? void 0 : e.connectionId, o = n.find((m) => m.id === i), l = Y(
|
|
3031
|
+
() => ((e == null ? void 0 : e.selectedEntities) ?? []).filter(Vs),
|
|
3032
|
+
[e == null ? void 0 : e.selectedEntities]
|
|
3033
|
+
), u = (m) => {
|
|
3034
|
+
var g;
|
|
3035
|
+
if (!(r != null && r.accessToken)) return !1;
|
|
3036
|
+
if (m.type === "dataset") {
|
|
3037
|
+
const y = m;
|
|
3038
|
+
return !!(y.domainId && y.name);
|
|
3039
|
+
}
|
|
3040
|
+
if (m.type === "model") return !!(i && m.id);
|
|
3041
|
+
const f = ((g = o == null ? void 0 : o.capabilities) == null ? void 0 : g.path) || [];
|
|
3042
|
+
return !(!i || !m.name || f.includes("database") && !m.database || f.includes("schema") && !m.schema);
|
|
3043
|
+
}, c = ie(
|
|
3044
|
+
(m) => {
|
|
3045
|
+
var g, y;
|
|
3046
|
+
const f = Ps(
|
|
3047
|
+
l,
|
|
3048
|
+
m.map((N) => N.data)
|
|
3049
|
+
);
|
|
3050
|
+
return {
|
|
3051
|
+
fields: f.length ? f : Ls,
|
|
3052
|
+
isLoading: m.some((N) => N.isLoading),
|
|
3053
|
+
error: (y = (g = m.find((N) => N.error)) == null ? void 0 : g.error) == null ? void 0 : y.message
|
|
3054
|
+
};
|
|
3055
|
+
},
|
|
3056
|
+
[l]
|
|
3057
|
+
), { fields: d, isLoading: h, error: p } = kn({
|
|
3058
|
+
queries: l.map((m) => ({
|
|
3059
|
+
queryKey: ["columns", i, m, (e == null ? void 0 : e.semanticDomainId) ?? null],
|
|
3060
|
+
queryFn: () => ur(
|
|
3061
|
+
`${a.apiServiceUrl}/v1/columns`,
|
|
3062
|
+
(r == null ? void 0 : r.accessToken) || "",
|
|
3063
|
+
m.type === "model" ? vt({
|
|
3064
|
+
connection_id: i,
|
|
3065
|
+
datamodel_id: m.id,
|
|
3066
|
+
database_name: "",
|
|
3067
|
+
schema_name: "",
|
|
3068
|
+
table_name: ""
|
|
3069
|
+
}) : m.type === "dataset" ? vt({
|
|
3070
|
+
connection_id: m.connectionId ?? i,
|
|
3071
|
+
domain_id: m.domainId,
|
|
3072
|
+
dataset_name: m.name,
|
|
3073
|
+
database_name: m.database,
|
|
3074
|
+
schema_name: m.schema,
|
|
3075
|
+
table_name: m.table
|
|
3076
|
+
}) : vt({
|
|
3077
|
+
connection_id: i,
|
|
3078
|
+
datamodel_id: "",
|
|
3079
|
+
database_name: m.database,
|
|
3080
|
+
schema_name: m.schema,
|
|
3081
|
+
table_name: m.name
|
|
3082
|
+
})
|
|
3083
|
+
),
|
|
3084
|
+
enabled: u(m),
|
|
3085
|
+
staleTime: 6e4
|
|
3086
|
+
})),
|
|
3087
|
+
combine: c
|
|
3088
|
+
});
|
|
3089
|
+
return { fields: d, isLoading: h, error: p };
|
|
3090
|
+
}
|
|
3091
|
+
function _s(e) {
|
|
3092
|
+
var r;
|
|
3093
|
+
const a = ((r = e.comparison) == null ? void 0 : r.mode) === "explicit" ? e.comparison.spec : void 0;
|
|
3094
|
+
return a && a.kind !== "target" ? { mode: "period", spec: a } : { mode: "off" };
|
|
3095
|
+
}
|
|
3096
|
+
function Os(e) {
|
|
3097
|
+
return e.mode === "period" ? pr(e.spec) : void 0;
|
|
3098
|
+
}
|
|
3099
|
+
const Rt = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", Ms = {
|
|
3100
|
+
connectionId: "",
|
|
3101
|
+
connectionType: "",
|
|
3102
|
+
mode: "semanticDomain",
|
|
3103
|
+
selectedEntities: []
|
|
3104
|
+
};
|
|
3105
|
+
function se({
|
|
3106
|
+
label: e,
|
|
3107
|
+
hint: a,
|
|
3108
|
+
aside: r,
|
|
3109
|
+
children: n,
|
|
3110
|
+
className: i
|
|
3111
|
+
}) {
|
|
3112
|
+
return /* @__PURE__ */ s("div", { className: i, children: [
|
|
3113
|
+
/* @__PURE__ */ s("div", { className: "mb-1 flex min-h-5 items-center justify-between gap-2", children: [
|
|
3114
|
+
/* @__PURE__ */ t("p", { className: Rt, children: e }),
|
|
3115
|
+
r
|
|
3116
|
+
] }),
|
|
3117
|
+
n,
|
|
3118
|
+
a ? /* @__PURE__ */ t("p", { className: "mt-1 text-[11px] leading-4 text-muted-foreground", children: a }) : null
|
|
3119
|
+
] });
|
|
3120
|
+
}
|
|
3121
|
+
function yt({
|
|
3122
|
+
muted: e,
|
|
3123
|
+
onClick: a,
|
|
3124
|
+
children: r,
|
|
3125
|
+
ariaLabel: n
|
|
3126
|
+
}) {
|
|
3127
|
+
return /* @__PURE__ */ t(
|
|
3128
|
+
"button",
|
|
3129
|
+
{
|
|
3130
|
+
type: "button",
|
|
3131
|
+
onClick: a,
|
|
3132
|
+
"aria-label": n,
|
|
3133
|
+
className: J(
|
|
3134
|
+
"flex h-7 w-full items-center gap-1.5 rounded-control border border-input bg-background px-2 text-left text-[12px] hover:bg-muted/50",
|
|
3135
|
+
e ? "text-muted-foreground" : "text-foreground"
|
|
3136
|
+
),
|
|
3137
|
+
children: r
|
|
3138
|
+
}
|
|
3139
|
+
);
|
|
3140
|
+
}
|
|
3141
|
+
function zs(e) {
|
|
3142
|
+
var r;
|
|
3143
|
+
const a = (r = e == null ? void 0 : e.selectedEntities) == null ? void 0 : r[0];
|
|
3144
|
+
if (a)
|
|
3145
|
+
return a.label || a.name;
|
|
3146
|
+
}
|
|
3147
|
+
function Rs(e) {
|
|
3148
|
+
const a = Ot(e);
|
|
3149
|
+
return a === "date" ? "date" : a === "string" ? "text" : a === "number" ? "number" : a === "boolean" ? "yes/no" : a;
|
|
3150
|
+
}
|
|
3151
|
+
const oa = "__new_calculated_field__";
|
|
3152
|
+
function Us({
|
|
3153
|
+
draft: e,
|
|
3154
|
+
onChange: a,
|
|
3155
|
+
handle: r,
|
|
3156
|
+
onCalculatedFieldOpenChange: n
|
|
3157
|
+
}) {
|
|
3158
|
+
var _, te, Z, G, E, ae, j, z, ne, ue, he, ye;
|
|
3159
|
+
const { tokenProps: i } = $e(), o = ((_ = i.config) == null ? void 0 : _.showAdvancedMode) !== !1, l = ((te = i.config) == null ? void 0 : te.showDirectSource) !== !1, { connections: u } = va(), [c, d] = A(!1), [h, p] = A(!1), [m, f] = A(!1), g = (x) => {
|
|
3160
|
+
p(x), n == null || n(x);
|
|
3161
|
+
}, { fields: y, isLoading: N, error: k } = Bs(e.mode === "data" ? e.dataSource : void 0), V = [...e.calculatedFields ?? [], ...y], P = (x) => x && (V.find((R) => R.id === x.id) ?? V.find((R) => $s(R, x))), D = [
|
|
3162
|
+
...V,
|
|
3163
|
+
...[e.field, e.sortField].filter(
|
|
3164
|
+
(x) => !!x && !P(x) && !V.some((R) => R.id === x.id)
|
|
3165
|
+
)
|
|
3166
|
+
], O = ((Z = P(e.field)) == null ? void 0 : Z.id) ?? ((G = e.field) == null ? void 0 : G.id) ?? "", b = ((E = P(e.sortField ?? e.field)) == null ? void 0 : E.id) ?? ((ae = e.sortField ?? e.field) == null ? void 0 : ae.id) ?? "", S = (x) => a({ ...e, ...x }), v = zs(e.dataSource), T = ((j = e.dataSource) == null ? void 0 : j.mode) === "database" ? Pt : jt, I = "mt-1 inline-flex items-center gap-1 text-[11px] font-medium text-muted-foreground underline-offset-2 hover:text-foreground hover:underline", H = {
|
|
3167
|
+
connectionId: ((z = e.dataSource) == null ? void 0 : z.connectionId) || e.connectionId,
|
|
3168
|
+
dataSource: e.dataSource,
|
|
3169
|
+
config: e.conditions ? { filters: e.conditions } : {},
|
|
3170
|
+
cardType: "text"
|
|
3171
|
+
}, B = Yt(e.field), Q = (ne = B.find((x) => x.value === e.get)) == null ? void 0 : ne.hint, X = (x) => {
|
|
3172
|
+
if (x === oa) {
|
|
3173
|
+
g(!0);
|
|
3174
|
+
return;
|
|
3175
|
+
}
|
|
3176
|
+
const R = D.find((K) => K.id === x);
|
|
3177
|
+
if (!R) return;
|
|
3178
|
+
const $ = Yt(R).some((K) => K.value === e.get) && e.field !== void 0;
|
|
3179
|
+
S({ field: R, get: $ ? e.get : Xt(R) });
|
|
3180
|
+
};
|
|
3181
|
+
return h ? /* @__PURE__ */ t(
|
|
3182
|
+
Dn,
|
|
3183
|
+
{
|
|
3184
|
+
inline: !0,
|
|
3185
|
+
open: !0,
|
|
3186
|
+
onOpenChange: g,
|
|
3187
|
+
availableFields: D,
|
|
3188
|
+
cardId: e.id,
|
|
3189
|
+
source: H,
|
|
3190
|
+
onSave: (x) => {
|
|
3191
|
+
const R = { ...x, fieldScope: x.fieldScope ?? "card" };
|
|
3192
|
+
S({
|
|
3193
|
+
calculatedFields: [...(e.calculatedFields ?? []).filter(($) => $.id !== R.id), R],
|
|
3194
|
+
field: R,
|
|
3195
|
+
get: Xt(R)
|
|
3196
|
+
}), g(!1);
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
) : /* @__PURE__ */ s(U, { children: [
|
|
3200
|
+
/* @__PURE__ */ t(
|
|
3201
|
+
se,
|
|
3202
|
+
{
|
|
3203
|
+
label: "Name",
|
|
3204
|
+
aside: /* @__PURE__ */ t(qs, { value: e.name, placeholder: r, editing: m, onEditing: f, onChange: (x) => S({ name: x }) }),
|
|
3205
|
+
hint: m ? "The key: what you type after {{, and what links and agents use. Letters, digits and underscores." : void 0,
|
|
3206
|
+
children: /* @__PURE__ */ t(
|
|
3207
|
+
xe,
|
|
3208
|
+
{
|
|
3209
|
+
size: "xs",
|
|
3210
|
+
value: e.label ?? "",
|
|
3211
|
+
onChange: (x) => S({ label: x.target.value }),
|
|
3212
|
+
placeholder: ((ue = e.field) == null ? void 0 : ue.label) || "Latest order date",
|
|
3213
|
+
"aria-label": "Variable name"
|
|
3214
|
+
}
|
|
3215
|
+
)
|
|
3216
|
+
}
|
|
3217
|
+
),
|
|
3218
|
+
e.mode === "sql" ? /* @__PURE__ */ s(U, { children: [
|
|
3219
|
+
/* @__PURE__ */ s(se, { label: "Connection", children: [
|
|
3220
|
+
/* @__PURE__ */ s(
|
|
3221
|
+
Se,
|
|
3222
|
+
{
|
|
3223
|
+
value: e.connectionId ?? "",
|
|
3224
|
+
onValueChange: (x) => S({ connectionId: x }),
|
|
3225
|
+
children: [
|
|
3226
|
+
/* @__PURE__ */ t(ke, { size: "xs", "aria-label": "Connection", children: /* @__PURE__ */ t(De, { placeholder: "Choose a connection" }) }),
|
|
3227
|
+
/* @__PURE__ */ t(Ae, { children: u.map((x) => /* @__PURE__ */ t(fe, { value: x.id, children: x.name }, x.id)) })
|
|
3228
|
+
]
|
|
3229
|
+
}
|
|
3230
|
+
),
|
|
3231
|
+
/* @__PURE__ */ s("button", { type: "button", onClick: () => S({ mode: "data" }), className: I, children: [
|
|
3232
|
+
/* @__PURE__ */ t(jt, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
3233
|
+
" Use a dataset or table instead"
|
|
3234
|
+
] })
|
|
3235
|
+
] }),
|
|
3236
|
+
/* @__PURE__ */ t(
|
|
3237
|
+
se,
|
|
3238
|
+
{
|
|
3239
|
+
label: "SQL",
|
|
3240
|
+
hint: /* @__PURE__ */ t(U, { children: "One row. Each column is a part; the first shows by default. Filters reach it where the SQL names them, as a SQL card's do." }),
|
|
3241
|
+
children: /* @__PURE__ */ t(
|
|
3242
|
+
pa,
|
|
3243
|
+
{
|
|
3244
|
+
size: "xs",
|
|
3245
|
+
value: e.sql,
|
|
3246
|
+
onChange: (x) => S({ sql: x.target.value }),
|
|
3247
|
+
placeholder: "select max(order_date) as latest_order_date from orders",
|
|
3248
|
+
className: "min-h-[96px] font-mono",
|
|
3249
|
+
"aria-label": "SQL"
|
|
3250
|
+
}
|
|
3251
|
+
)
|
|
3252
|
+
}
|
|
3253
|
+
),
|
|
3254
|
+
/* @__PURE__ */ t(se, { label: "Get", children: /* @__PURE__ */ s(
|
|
3255
|
+
Se,
|
|
3256
|
+
{
|
|
3257
|
+
value: e.get === "first" ? "first" : "only",
|
|
3258
|
+
onValueChange: (x) => S({ get: x }),
|
|
3259
|
+
children: [
|
|
3260
|
+
/* @__PURE__ */ t(ke, { size: "xs", "aria-label": "Get", children: /* @__PURE__ */ t(De, {}) }),
|
|
3261
|
+
/* @__PURE__ */ s(Ae, { children: [
|
|
3262
|
+
/* @__PURE__ */ t(fe, { value: "only", children: "The only row" }),
|
|
3263
|
+
/* @__PURE__ */ t(fe, { value: "first", children: "The first row" })
|
|
3264
|
+
] })
|
|
3265
|
+
]
|
|
3266
|
+
}
|
|
3267
|
+
) })
|
|
3268
|
+
] }) : /* @__PURE__ */ s(U, { children: [
|
|
3269
|
+
/* @__PURE__ */ s(se, { label: "Source", children: [
|
|
3270
|
+
/* @__PURE__ */ t(yt, { muted: !v, onClick: () => d(!0), ariaLabel: "Source", children: v ? /* @__PURE__ */ s(U, { children: [
|
|
3271
|
+
/* @__PURE__ */ t(T, { className: "h-3.5 w-3.5 text-muted-foreground", "aria-hidden": !0 }),
|
|
3272
|
+
" ",
|
|
3273
|
+
v
|
|
3274
|
+
] }) : l ? "Choose a dataset or table" : "Choose a dataset" }),
|
|
3275
|
+
o ? /* @__PURE__ */ s("button", { type: "button", onClick: () => {
|
|
3276
|
+
var x;
|
|
3277
|
+
return S({ mode: "sql", connectionId: ((x = e.dataSource) == null ? void 0 : x.connectionId) || e.connectionId });
|
|
3278
|
+
}, className: I, children: [
|
|
3279
|
+
/* @__PURE__ */ t(Yr, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
3280
|
+
" Write SQL instead"
|
|
3281
|
+
] }) : null
|
|
3282
|
+
] }),
|
|
3283
|
+
/* @__PURE__ */ t(
|
|
3284
|
+
Lr,
|
|
3285
|
+
{
|
|
3286
|
+
open: c,
|
|
3287
|
+
onOpenChange: d,
|
|
3288
|
+
dataSource: e.dataSource ?? Ms,
|
|
3289
|
+
incomingSelectedEntities: ((he = e.dataSource) == null ? void 0 : he.selectedEntities) ?? [],
|
|
3290
|
+
onDataSourceChange: (x) => {
|
|
3291
|
+
var $;
|
|
3292
|
+
const R = JSON.stringify(x.selectedEntities) === JSON.stringify(($ = e.dataSource) == null ? void 0 : $.selectedEntities);
|
|
3293
|
+
S(
|
|
3294
|
+
R ? { dataSource: x } : { dataSource: x, field: void 0, sortField: void 0, conditions: null, calculatedFields: void 0 }
|
|
3295
|
+
);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
),
|
|
3299
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
3300
|
+
/* @__PURE__ */ t(se, { label: "Field", children: v ? /* @__PURE__ */ s(Se, { value: O, onValueChange: X, disabled: N && !D.length, children: [
|
|
3301
|
+
/* @__PURE__ */ t(ke, { size: "xs", "aria-label": "Field", children: /* @__PURE__ */ t(De, { placeholder: N ? "Loading fields…" : k ? "Fields unavailable" : "Choose a field" }) }),
|
|
3302
|
+
/* @__PURE__ */ s(Ae, { children: [
|
|
3303
|
+
D.map((x) => /* @__PURE__ */ t(fe, { value: x.id, children: /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
|
|
3304
|
+
/* @__PURE__ */ t("span", { children: x.label || x.name }),
|
|
3305
|
+
/* @__PURE__ */ t("span", { className: "text-muted-foreground", children: Rs(x.dataType) })
|
|
3306
|
+
] }) }, x.id)),
|
|
3307
|
+
/* @__PURE__ */ t(Zn, {}),
|
|
3308
|
+
/* @__PURE__ */ t(fe, { value: oa, children: /* @__PURE__ */ s("span", { className: "flex items-center gap-1.5", children: [
|
|
3309
|
+
/* @__PURE__ */ t(be, { className: "h-3 w-3", "aria-hidden": !0 }),
|
|
3310
|
+
" New calculated field…"
|
|
3311
|
+
] }) })
|
|
3312
|
+
] })
|
|
3313
|
+
] }) : /* @__PURE__ */ t(yt, { muted: !0, children: "Choose a source first" }) }),
|
|
3314
|
+
/* @__PURE__ */ t(se, { label: "Get", children: /* @__PURE__ */ s(
|
|
3315
|
+
Se,
|
|
3316
|
+
{
|
|
3317
|
+
value: e.get,
|
|
3318
|
+
onValueChange: (x) => S({ get: x }),
|
|
3319
|
+
disabled: !e.field,
|
|
3320
|
+
children: [
|
|
3321
|
+
/* @__PURE__ */ t(ke, { size: "xs", "aria-label": "Get", children: /* @__PURE__ */ t(De, {}) }),
|
|
3322
|
+
/* @__PURE__ */ t(Ae, { children: B.map((x) => /* @__PURE__ */ t(fe, { value: x.value, children: x.label }, x.value)) })
|
|
3323
|
+
]
|
|
3324
|
+
}
|
|
3325
|
+
) }),
|
|
3326
|
+
e.field && Q ? /* @__PURE__ */ t("p", { className: "col-span-2 -mt-1.5 text-[11px] leading-4 text-muted-foreground", children: Q }) : null,
|
|
3327
|
+
k ? /* @__PURE__ */ t("p", { className: "col-span-2 -mt-1.5 text-[11px] leading-4 text-destructive", children: k }) : null,
|
|
3328
|
+
Mr(e) ? /* @__PURE__ */ t(
|
|
3329
|
+
se,
|
|
3330
|
+
{
|
|
3331
|
+
label: "Compare with",
|
|
3332
|
+
className: "col-span-2",
|
|
3333
|
+
children: /* @__PURE__ */ t(
|
|
3334
|
+
An,
|
|
3335
|
+
{
|
|
3336
|
+
controlLabel: "Variable",
|
|
3337
|
+
selection: _s(e),
|
|
3338
|
+
onChange: (x) => S({ comparison: Os(x) })
|
|
3339
|
+
}
|
|
3340
|
+
)
|
|
3341
|
+
}
|
|
3342
|
+
) : null,
|
|
3343
|
+
e.field && !zr(e.get) && e.get !== "only" ? /* @__PURE__ */ s("div", { className: J("col-span-2 grid gap-3", e.get === "list" ? "grid-cols-3" : "grid-cols-2"), children: [
|
|
3344
|
+
/* @__PURE__ */ t(se, { label: "Order by", children: /* @__PURE__ */ s(
|
|
3345
|
+
Se,
|
|
3346
|
+
{
|
|
3347
|
+
value: `${b}|${e.sortDirection}`,
|
|
3348
|
+
onValueChange: (x) => {
|
|
3349
|
+
const R = x.lastIndexOf("|"), $ = x.slice(0, R), K = x.slice(R + 1);
|
|
3350
|
+
S({ sortField: D.find((le) => le.id === $), sortDirection: K });
|
|
3351
|
+
},
|
|
3352
|
+
children: [
|
|
3353
|
+
/* @__PURE__ */ t(ke, { size: "xs", "aria-label": "Order by", children: /* @__PURE__ */ t(De, {}) }),
|
|
3354
|
+
/* @__PURE__ */ t(Ae, { children: D.flatMap(
|
|
3355
|
+
(x) => ["asc", "desc"].map((R) => /* @__PURE__ */ s(fe, { value: `${x.id}|${R}`, children: [
|
|
3356
|
+
x.label || x.name,
|
|
3357
|
+
", ",
|
|
3358
|
+
js(x, R)
|
|
3359
|
+
] }, `${x.id}|${R}`))
|
|
3360
|
+
) })
|
|
3361
|
+
]
|
|
3362
|
+
}
|
|
3363
|
+
) }),
|
|
3364
|
+
e.get === "list" ? /* @__PURE__ */ s(U, { children: [
|
|
3365
|
+
/* @__PURE__ */ t(se, { label: "Show up to", children: /* @__PURE__ */ t(
|
|
3366
|
+
xe,
|
|
3367
|
+
{
|
|
3368
|
+
size: "xs",
|
|
3369
|
+
type: "number",
|
|
3370
|
+
min: 1,
|
|
3371
|
+
max: st,
|
|
3372
|
+
value: e.listLimit ?? "",
|
|
3373
|
+
placeholder: "10",
|
|
3374
|
+
onChange: (x) => {
|
|
3375
|
+
const R = Number.parseInt(x.target.value, 10);
|
|
3376
|
+
S({ listLimit: Number.isFinite(R) && R > 0 ? Math.min(R, st) : void 0 });
|
|
3377
|
+
},
|
|
3378
|
+
"aria-label": "Show up to"
|
|
3379
|
+
}
|
|
3380
|
+
) }),
|
|
3381
|
+
/* @__PURE__ */ t(se, { label: "Separator", children: /* @__PURE__ */ t(
|
|
3382
|
+
xe,
|
|
3383
|
+
{
|
|
3384
|
+
size: "xs",
|
|
3385
|
+
value: e.listSeparator ?? ", ",
|
|
3386
|
+
maxLength: mr,
|
|
3387
|
+
onChange: (x) => S({ listSeparator: x.target.value }),
|
|
3388
|
+
className: "font-mono",
|
|
3389
|
+
"aria-label": "Separator"
|
|
3390
|
+
}
|
|
3391
|
+
) })
|
|
3392
|
+
] }) : null
|
|
3393
|
+
] }) : null
|
|
3394
|
+
] }),
|
|
3395
|
+
/* @__PURE__ */ t(se, { label: "Filters", children: v ? (
|
|
3396
|
+
// In place, not a dialog over the dialog: each edit is the draft's, and
|
|
3397
|
+
// Cancel or Done here keeps or drops it. A new source starts a new list.
|
|
3398
|
+
/* @__PURE__ */ t(
|
|
3399
|
+
Vr,
|
|
3400
|
+
{
|
|
3401
|
+
filters: e.conditions ?? null,
|
|
3402
|
+
availableFields: D,
|
|
3403
|
+
source: H,
|
|
3404
|
+
onChange: (x) => S({ conditions: x })
|
|
3405
|
+
},
|
|
3406
|
+
JSON.stringify(((ye = e.dataSource) == null ? void 0 : ye.selectedEntities) ?? null)
|
|
3407
|
+
)
|
|
3408
|
+
) : /* @__PURE__ */ t(yt, { muted: !0, children: "Choose a source first" }) })
|
|
3409
|
+
] })
|
|
3410
|
+
] });
|
|
3411
|
+
}
|
|
3412
|
+
function $s(e, a) {
|
|
3413
|
+
return e.name === a.name && (e.qualifiedEntityName ?? e.entityName ?? "") === (a.qualifiedEntityName ?? a.entityName ?? "");
|
|
3414
|
+
}
|
|
3415
|
+
function js(e, a) {
|
|
3416
|
+
const r = Ot(e.dataType);
|
|
3417
|
+
return r === "date" ? a === "asc" ? "earliest first" : "latest first" : r === "number" ? a === "asc" ? "lowest first" : "highest first" : a === "asc" ? "A to Z" : "Z to A";
|
|
3418
|
+
}
|
|
3419
|
+
function qs({
|
|
3420
|
+
value: e,
|
|
3421
|
+
placeholder: a,
|
|
3422
|
+
editing: r,
|
|
3423
|
+
onEditing: n,
|
|
3424
|
+
onChange: i
|
|
3425
|
+
}) {
|
|
3426
|
+
return r ? /* @__PURE__ */ t(
|
|
3427
|
+
xe,
|
|
3428
|
+
{
|
|
3429
|
+
size: "xs",
|
|
3430
|
+
autoFocus: !0,
|
|
3431
|
+
value: e,
|
|
3432
|
+
placeholder: a,
|
|
3433
|
+
onChange: (o) => i(o.target.value),
|
|
3434
|
+
onBlur: () => n(!1),
|
|
3435
|
+
onKeyDown: (o) => {
|
|
3436
|
+
(o.key === "Enter" || o.key === "Escape") && (o.preventDefault(), o.stopPropagation(), n(!1));
|
|
3437
|
+
},
|
|
3438
|
+
className: "h-6 w-44 font-mono text-[11px]",
|
|
3439
|
+
"aria-label": "Key"
|
|
3440
|
+
}
|
|
3441
|
+
) : /* @__PURE__ */ s(
|
|
3442
|
+
"button",
|
|
3443
|
+
{
|
|
3444
|
+
type: "button",
|
|
3445
|
+
onClick: () => n(!0),
|
|
3446
|
+
"aria-label": "Edit key",
|
|
3447
|
+
title: "The key: what you type after {{, and what links and agents use",
|
|
3448
|
+
className: "inline-flex h-5 items-center gap-1 rounded-[4px] px-1 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
|
|
3449
|
+
children: [
|
|
3450
|
+
`{{${e.trim() || a}}}`,
|
|
3451
|
+
/* @__PURE__ */ t(Vt, { className: "h-3 w-3", "aria-hidden": !0 })
|
|
3452
|
+
]
|
|
3453
|
+
}
|
|
3454
|
+
);
|
|
3455
|
+
}
|
|
3456
|
+
const Ws = [
|
|
3457
|
+
{ id: "data", label: "Data" },
|
|
3458
|
+
{ id: "filters", label: "Dashboard filters" },
|
|
3459
|
+
{ id: "display", label: "Display" }
|
|
3460
|
+
];
|
|
3461
|
+
function Qs(e) {
|
|
3462
|
+
const { name: a, label: r, presentation: n, emptyText: i, ...o } = e;
|
|
3463
|
+
return JSON.stringify(o);
|
|
3464
|
+
}
|
|
3465
|
+
function Ks({
|
|
3466
|
+
variable: e,
|
|
3467
|
+
onClose: a,
|
|
3468
|
+
onHoldEscape: r
|
|
3469
|
+
}) {
|
|
3470
|
+
var Z, G;
|
|
3471
|
+
const n = w((E) => E.dashboard), i = w((E) => E.selectedSheetId), o = w((E) => E.actions.saveVariableChange), [l, u] = A(
|
|
3472
|
+
() => e ? Rr(e) : Ur()
|
|
3473
|
+
), [c, d] = A("data"), [h, p] = A(!1), m = (E) => {
|
|
3474
|
+
p(E), r == null || r(E);
|
|
3475
|
+
}, [f, g] = A([]), [y, N] = A(null), k = !e, V = Qs(l), P = Y(
|
|
3476
|
+
() => Jt({ ...JSON.parse(V), name: "" }, n),
|
|
3477
|
+
[V, n]
|
|
3478
|
+
), { name: D, label: O, presentation: b, emptyText: S } = l, v = Y(
|
|
3479
|
+
() => ({
|
|
3480
|
+
...P,
|
|
3481
|
+
name: Zt(n, { id: P.id, name: D, field: l.field, mode: l.mode, label: O }),
|
|
3482
|
+
...O != null && O.trim() ? { label: O.trim() } : {},
|
|
3483
|
+
...b ? { presentation: b } : {},
|
|
3484
|
+
...S != null && S.trim() ? { emptyText: S } : {}
|
|
3485
|
+
}),
|
|
3486
|
+
// The field and mode are inside the query key already.
|
|
3487
|
+
[P, n, D, O, b, S, l.field, l.mode]
|
|
3488
|
+
), T = Y(
|
|
3489
|
+
() => ({
|
|
3490
|
+
...n,
|
|
3491
|
+
variables: [...(n.variables ?? []).filter((E) => E.id !== v.id), v]
|
|
3492
|
+
}),
|
|
3493
|
+
[n, v]
|
|
3494
|
+
), I = $r(l), H = ut(), B = w((E) => E.actions.mergeSemanticExecutionPayload), [Q, X] = A(!1), _ = async () => {
|
|
3495
|
+
const E = Jt(l, n);
|
|
3496
|
+
X(!0);
|
|
3497
|
+
let ae;
|
|
3498
|
+
try {
|
|
3499
|
+
const z = xr(n, e ? { kind: "update", id: e.id, patch: E } : { kind: "add", variable: E });
|
|
3500
|
+
if (!z.ok) {
|
|
3501
|
+
X(!1), g(z.issues);
|
|
3502
|
+
return;
|
|
3503
|
+
}
|
|
3504
|
+
const [ne] = z.queryFrames;
|
|
3505
|
+
ae = ne ? await H(ne, e ? { previousFrame: vr(n, e) } : void 0) : { domainsById: {} };
|
|
3506
|
+
} catch (z) {
|
|
3507
|
+
X(!1), g([
|
|
3508
|
+
{
|
|
3509
|
+
code: "queryMissing",
|
|
3510
|
+
message: z instanceof Error && z.message ? z.message : "The data source's details could not be loaded.",
|
|
3511
|
+
fix: "Try again, or choose the source again."
|
|
3512
|
+
}
|
|
3513
|
+
]);
|
|
3514
|
+
return;
|
|
3515
|
+
}
|
|
3516
|
+
const j = o(
|
|
3517
|
+
k ? { kind: "add", variable: E } : { kind: "update", id: E.id, patch: Hs(E) }
|
|
3518
|
+
);
|
|
3519
|
+
if (X(!1), !j.ok) {
|
|
3520
|
+
g(j.issues);
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
B(ae), a();
|
|
3524
|
+
}, te = (E) => {
|
|
3525
|
+
if (!e) return;
|
|
3526
|
+
const ae = o({ kind: "remove", id: e.id, confirmed: E });
|
|
3527
|
+
if (!ae.ok) {
|
|
3528
|
+
const j = ae.issues.find((z) => z.code === "inUse");
|
|
3529
|
+
if (j && !E) {
|
|
3530
|
+
N(j);
|
|
3531
|
+
return;
|
|
3532
|
+
}
|
|
3533
|
+
g(ae.issues);
|
|
3534
|
+
return;
|
|
3535
|
+
}
|
|
3536
|
+
a();
|
|
3537
|
+
};
|
|
3538
|
+
return /* @__PURE__ */ s(
|
|
3539
|
+
"div",
|
|
3540
|
+
{
|
|
3541
|
+
className: "flex h-[600px] max-h-[85vh] w-[600px] max-w-[calc(100vw-24px)] flex-col overflow-hidden",
|
|
3542
|
+
"data-testid": "variable-editor",
|
|
3543
|
+
children: [
|
|
3544
|
+
/* @__PURE__ */ s("div", { className: "flex min-h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5", children: [
|
|
3545
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-start gap-2", children: [
|
|
3546
|
+
/* @__PURE__ */ t(Nt, { className: "mt-1 h-3.5 w-3.5 shrink-0 text-muted-foreground", "aria-hidden": !0 }),
|
|
3547
|
+
/* @__PURE__ */ s("div", { className: "min-w-0", children: [
|
|
3548
|
+
/* @__PURE__ */ s("p", { className: "flex items-center gap-2", children: [
|
|
3549
|
+
/* @__PURE__ */ t("span", { className: "truncate text-[13px] font-medium text-foreground", children: k ? "New variable" : e.label || e.name }),
|
|
3550
|
+
/* @__PURE__ */ t("span", { className: Rt, children: "Variable from data" })
|
|
3551
|
+
] }),
|
|
3552
|
+
/* @__PURE__ */ t("p", { className: "mt-0.5 truncate text-[10px] leading-3 text-muted-foreground/70", children: "Available on every tab and Document of this dashboard" })
|
|
3553
|
+
] })
|
|
3554
|
+
] }),
|
|
3555
|
+
/* @__PURE__ */ t(
|
|
3556
|
+
"button",
|
|
3557
|
+
{
|
|
3558
|
+
type: "button",
|
|
3559
|
+
onClick: a,
|
|
3560
|
+
"aria-label": "Close",
|
|
3561
|
+
className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
3562
|
+
children: /* @__PURE__ */ t(Qe, { className: "h-3.5 w-3.5", "aria-hidden": !0 })
|
|
3563
|
+
}
|
|
3564
|
+
)
|
|
3565
|
+
] }),
|
|
3566
|
+
h ? null : /* @__PURE__ */ t("nav", { role: "tablist", "aria-label": "Variable settings sections", className: "flex h-9 shrink-0 items-stretch gap-4 border-b border-border/60 px-4", children: Ws.map((E) => /* @__PURE__ */ s(
|
|
3567
|
+
"button",
|
|
3568
|
+
{
|
|
3569
|
+
role: "tab",
|
|
3570
|
+
"aria-selected": c === E.id,
|
|
3571
|
+
onClick: () => d(E.id),
|
|
3572
|
+
className: J(
|
|
3573
|
+
"relative -mb-px inline-flex items-center text-[13px] transition-colors focus-visible:outline-none",
|
|
3574
|
+
c === E.id ? "font-medium text-foreground" : "text-muted-foreground hover:text-foreground"
|
|
3575
|
+
),
|
|
3576
|
+
children: [
|
|
3577
|
+
E.label,
|
|
3578
|
+
c === E.id ? /* @__PURE__ */ t("span", { className: "absolute inset-x-0 -bottom-px h-[2px] bg-foreground" }) : null
|
|
3579
|
+
]
|
|
3580
|
+
},
|
|
3581
|
+
E.id
|
|
3582
|
+
)) }),
|
|
3583
|
+
/* @__PURE__ */ s("div", { className: J("min-h-0 flex-1 overflow-y-auto", c === "filters" || h ? "" : "space-y-4 px-4 py-4"), children: [
|
|
3584
|
+
c === "data" ? /* @__PURE__ */ t(
|
|
3585
|
+
Us,
|
|
3586
|
+
{
|
|
3587
|
+
draft: l,
|
|
3588
|
+
onChange: u,
|
|
3589
|
+
handle: Zt(n, l),
|
|
3590
|
+
onCalculatedFieldOpenChange: m
|
|
3591
|
+
}
|
|
3592
|
+
) : null,
|
|
3593
|
+
c === "filters" ? /* @__PURE__ */ t(Gs, { draft: l, draftDashboard: T }) : null,
|
|
3594
|
+
c === "display" ? /* @__PURE__ */ t(Js, { draft: l, onChange: u }) : null
|
|
3595
|
+
] }),
|
|
3596
|
+
h ? null : /* @__PURE__ */ s(U, { children: [
|
|
3597
|
+
/* @__PURE__ */ t(
|
|
3598
|
+
Zs,
|
|
3599
|
+
{
|
|
3600
|
+
draft: l,
|
|
3601
|
+
draftVariable: v,
|
|
3602
|
+
draftDashboard: T,
|
|
3603
|
+
blocker: I,
|
|
3604
|
+
selectedSheetId: i ?? void 0
|
|
3605
|
+
}
|
|
3606
|
+
),
|
|
3607
|
+
f.length ? /* @__PURE__ */ t("div", { className: "shrink-0 border-t border-border/60 bg-destructive/5 px-4 py-2 text-[11px] leading-4 text-destructive", role: "alert", children: f.map((E) => /* @__PURE__ */ s("p", { children: [
|
|
3608
|
+
E.message,
|
|
3609
|
+
" ",
|
|
3610
|
+
E.fix
|
|
3611
|
+
] }, `${E.code}:${E.path ?? ""}`)) }) : null,
|
|
3612
|
+
y ? /* @__PURE__ */ s("div", { className: "shrink-0 border-t border-border/60 bg-amber-500/10 px-4 py-2 text-[11px] leading-4 text-amber-800 dark:text-amber-300", role: "alertdialog", children: [
|
|
3613
|
+
/* @__PURE__ */ s("p", { children: [
|
|
3614
|
+
y.message,
|
|
3615
|
+
" Used in ",
|
|
3616
|
+
((Z = y.places) == null ? void 0 : Z.length) ?? 0,
|
|
3617
|
+
" ",
|
|
3618
|
+
((G = y.places) == null ? void 0 : G.length) === 1 ? "place" : "places",
|
|
3619
|
+
". Its chips then read as missing."
|
|
3620
|
+
] }),
|
|
3621
|
+
/* @__PURE__ */ s("div", { className: "mt-1.5 flex gap-1.5", children: [
|
|
3622
|
+
/* @__PURE__ */ t(L, { variant: "outline", size: "xs", className: "h-6 px-2 text-[11px]", onClick: () => N(null), children: "Keep it" }),
|
|
3623
|
+
/* @__PURE__ */ t(L, { size: "xs", className: "h-6 px-2 text-[11px]", onClick: () => te(!0), children: "Remove anyway" })
|
|
3624
|
+
] })
|
|
3625
|
+
] }) : null,
|
|
3626
|
+
/* @__PURE__ */ s("div", { className: "flex shrink-0 items-center justify-between gap-2 border-t border-border/60 px-4 py-2.5", children: [
|
|
3627
|
+
k ? /* @__PURE__ */ t("span", {}) : /* @__PURE__ */ t(
|
|
3628
|
+
L,
|
|
3629
|
+
{
|
|
3630
|
+
variant: "outline",
|
|
3631
|
+
size: "xs",
|
|
3632
|
+
className: "text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive",
|
|
3633
|
+
onClick: () => te(!1),
|
|
3634
|
+
children: "Delete"
|
|
3635
|
+
}
|
|
3636
|
+
),
|
|
3637
|
+
/* @__PURE__ */ s("span", { className: "flex items-center gap-1.5", children: [
|
|
3638
|
+
/* @__PURE__ */ t(L, { variant: "outline", size: "xs", onClick: a, children: "Cancel" }),
|
|
3639
|
+
/* @__PURE__ */ t(L, { size: "xs", disabled: !!I || Q, title: I, onClick: () => void _(), children: k ? "Create" : "Done" })
|
|
3640
|
+
] })
|
|
3641
|
+
] })
|
|
3642
|
+
] })
|
|
3643
|
+
]
|
|
3644
|
+
}
|
|
3645
|
+
);
|
|
3646
|
+
}
|
|
3647
|
+
function Hs(e) {
|
|
3648
|
+
const { id: a, ...r } = e;
|
|
3649
|
+
return {
|
|
3650
|
+
...r,
|
|
3651
|
+
// Fields the draft cleared come back as `undefined`, so an update drops them.
|
|
3652
|
+
label: r.label,
|
|
3653
|
+
presentation: r.presentation,
|
|
3654
|
+
emptyText: r.emptyText
|
|
3655
|
+
};
|
|
3656
|
+
}
|
|
3657
|
+
function Gs({ draft: e, draftDashboard: a }) {
|
|
3658
|
+
const r = Y(() => fr(a), [a]), n = r.inputs.filter(
|
|
3659
|
+
(o) => r.reachedVariables({ inputId: o.input.id }).some((l) => l.variableId === e.id)
|
|
3660
|
+
), i = e.mode === "sql" && Or(e.sql);
|
|
3661
|
+
return n.length ? /* @__PURE__ */ s("div", { className: "divide-y divide-border/60", children: [
|
|
3662
|
+
/* @__PURE__ */ t("p", { className: "px-4 py-2 text-[11px] leading-4 text-muted-foreground", children: "How each filter applies here. Change a mapping on the filter's Cards tab, under Variables." }),
|
|
3663
|
+
n.map((o) => {
|
|
3664
|
+
var c;
|
|
3665
|
+
const l = (c = o.input.application) == null ? void 0 : c.cards.find((d) => d.cardId === e.id), u = i ? "Subscribes in SQL" : e.mode === "sql" ? "Not named in the SQL" : (l == null ? void 0 : l.kind) === "excluded" ? "Don't apply" : (l == null ? void 0 : l.kind) === "bound" ? `${l.target.kind === "field" ? "Field" : "Path"} · ${l.target.field.name}` : "Auto";
|
|
3666
|
+
return /* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3 px-4 py-2 text-[12px]", children: [
|
|
3667
|
+
/* @__PURE__ */ s("span", { className: "min-w-0", children: [
|
|
3668
|
+
/* @__PURE__ */ t("span", { className: "block truncate font-medium text-foreground", children: o.input.label || o.input.filter.title }),
|
|
3669
|
+
/* @__PURE__ */ t("span", { className: "block truncate text-[11px] text-muted-foreground", children: Ys(o.input.scope) })
|
|
3670
|
+
] }),
|
|
3671
|
+
/* @__PURE__ */ t("span", { className: J("shrink-0 text-[11px]", u === "Don't apply" || u === "Not named in the SQL" ? "text-muted-foreground" : "text-foreground"), children: u })
|
|
3672
|
+
] }, o.input.id);
|
|
3673
|
+
})
|
|
3674
|
+
] }) : /* @__PURE__ */ t("p", { className: "px-4 py-6 text-center text-[12px] text-muted-foreground", children: "No filter reaches this variable. A filter on the tabs or Documents where it is used reaches it; a variable used nowhere yet follows every tab's filters." });
|
|
3675
|
+
}
|
|
3676
|
+
function Ys(e) {
|
|
3677
|
+
switch (e.kind) {
|
|
3678
|
+
case "allSheets":
|
|
3679
|
+
return "On every tab";
|
|
3680
|
+
case "sheets":
|
|
3681
|
+
return "On chosen tabs";
|
|
3682
|
+
case "cards":
|
|
3683
|
+
return "On chosen cards and variables";
|
|
3684
|
+
default:
|
|
3685
|
+
return e.kind;
|
|
3686
|
+
}
|
|
3687
|
+
}
|
|
3688
|
+
const Xs = [
|
|
3689
|
+
{ value: "auto", label: "Automatic" },
|
|
3690
|
+
{ value: "short", label: "Short" },
|
|
3691
|
+
{ value: "medium", label: "Medium" },
|
|
3692
|
+
{ value: "long", label: "Long" },
|
|
3693
|
+
{ value: "pattern", label: "Custom pattern…" }
|
|
3694
|
+
];
|
|
3695
|
+
function Js({ draft: e, onChange: a }) {
|
|
3696
|
+
var u, c;
|
|
3697
|
+
const r = e.mode === "sql" ? "unknown" : Ot((u = e.field) == null ? void 0 : u.dataType), n = (c = e.presentation) == null ? void 0 : c.temporal, i = n ? n.mode === "style" ? n.dateStyle : n.mode === "pattern" ? "pattern" : "auto" : "auto", o = (n == null ? void 0 : n.mode) === "pattern" ? Cr(n.pattern) : null, l = (d) => a({ ...e, presentation: d && Object.keys(d).length ? d : void 0 });
|
|
3698
|
+
return /* @__PURE__ */ s(U, { children: [
|
|
3699
|
+
r === "date" || r === "unknown" ? /* @__PURE__ */ s(se, { label: "Dates read as", hint: "A chip can change this for itself.", children: [
|
|
3700
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
|
|
3701
|
+
/* @__PURE__ */ s(
|
|
3702
|
+
Se,
|
|
3703
|
+
{
|
|
3704
|
+
value: i,
|
|
3705
|
+
onValueChange: (d) => l({
|
|
3706
|
+
...e.presentation,
|
|
3707
|
+
temporal: d === "auto" ? void 0 : d === "pattern" ? { mode: "pattern", dialect: "semaphor_tokens", pattern: (n == null ? void 0 : n.mode) === "pattern" ? n.pattern : "MMM D, YYYY" } : { mode: "style", dateStyle: d }
|
|
3708
|
+
}),
|
|
3709
|
+
children: [
|
|
3710
|
+
/* @__PURE__ */ t(ke, { size: "xs", className: "w-44", "aria-label": "Date style", children: /* @__PURE__ */ t(De, {}) }),
|
|
3711
|
+
/* @__PURE__ */ t(Ae, { children: Xs.map((d) => /* @__PURE__ */ t(fe, { value: d.value, children: d.label }, d.value)) })
|
|
3712
|
+
]
|
|
3713
|
+
}
|
|
3714
|
+
),
|
|
3715
|
+
(n == null ? void 0 : n.mode) === "pattern" ? /* @__PURE__ */ t(
|
|
3716
|
+
xe,
|
|
3717
|
+
{
|
|
3718
|
+
size: "xs",
|
|
3719
|
+
value: n.pattern,
|
|
3720
|
+
onChange: (d) => l({ ...e.presentation, temporal: { mode: "pattern", dialect: "semaphor_tokens", pattern: d.target.value } }),
|
|
3721
|
+
className: "w-40 font-mono",
|
|
3722
|
+
"aria-label": "Date pattern"
|
|
3723
|
+
}
|
|
3724
|
+
) : null
|
|
3725
|
+
] }),
|
|
3726
|
+
o ? /* @__PURE__ */ t("p", { className: "mt-1 text-[11px] text-destructive", children: o }) : null
|
|
3727
|
+
] }) : null,
|
|
3728
|
+
r === "number" || r === "unknown" ? /* @__PURE__ */ t(se, { label: "Numbers read as", hint: "A chip can change any of these for itself.", children: /* @__PURE__ */ t(Fn, { value: e.presentation, onChange: l }) }) : null,
|
|
3729
|
+
/* @__PURE__ */ t(
|
|
3730
|
+
se,
|
|
3731
|
+
{
|
|
3732
|
+
label: "When there’s no value",
|
|
3733
|
+
hint: "Readers see this when nothing matches or more than one does. Leave it empty to show nothing.",
|
|
3734
|
+
children: /* @__PURE__ */ t(
|
|
3735
|
+
xe,
|
|
3736
|
+
{
|
|
3737
|
+
size: "xs",
|
|
3738
|
+
value: e.emptyText ?? "",
|
|
3739
|
+
maxLength: gr,
|
|
3740
|
+
onChange: (d) => a({ ...e, emptyText: d.target.value || void 0 }),
|
|
3741
|
+
placeholder: "Show nothing",
|
|
3742
|
+
className: "w-72",
|
|
3743
|
+
"aria-label": "Empty text"
|
|
3744
|
+
}
|
|
3745
|
+
)
|
|
3746
|
+
}
|
|
3747
|
+
)
|
|
3748
|
+
] });
|
|
3749
|
+
}
|
|
3750
|
+
function Zs({
|
|
3751
|
+
draft: e,
|
|
3752
|
+
draftVariable: a,
|
|
3753
|
+
draftDashboard: r,
|
|
3754
|
+
blocker: n,
|
|
3755
|
+
selectedSheetId: i
|
|
3756
|
+
}) {
|
|
3757
|
+
var S;
|
|
3758
|
+
const o = r.sheets ?? [], l = Y(() => Ts(r, a.id), [r, a.id]), [u, c] = A(void 0), d = (l ? u : void 0) ?? i ?? ((S = o[0]) == null ? void 0 : S.id), h = o.find((v) => v.id === d), p = w((v) => d ? v.documentSectionRuntimeBySheetId[d] : void 0), m = !!(h && Ke(h)), f = Y(
|
|
3759
|
+
() => d ? m ? p ? { kind: "document", sheetId: d, runtime: p } : void 0 : { kind: "sheet", sheetId: d } : void 0,
|
|
3760
|
+
[m, p, d]
|
|
3761
|
+
), g = Y(() => n || !f ? [] : [a], [n, a, f]), N = In({
|
|
3762
|
+
dashboard: r,
|
|
3763
|
+
place: f ?? { kind: "sheet", sheetId: d ?? "" },
|
|
3764
|
+
purpose: "preview",
|
|
3765
|
+
variables: g
|
|
3766
|
+
}).byId.get(a.id), k = En(), V = Tn(), P = Y(
|
|
3767
|
+
() => br({ preferences: k, calendar: V }),
|
|
3768
|
+
[V, k]
|
|
3769
|
+
);
|
|
3770
|
+
let D, O = "", b = null;
|
|
3771
|
+
if (n)
|
|
3772
|
+
D = /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: e.mode === "sql" ? "Write the SQL to see a value." : "Choose a source and a field to see a value." });
|
|
3773
|
+
else if (!f)
|
|
3774
|
+
D = /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: "Open this Document to preview here." });
|
|
3775
|
+
else if (!N || N.status === "loading")
|
|
3776
|
+
D = /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: "Loading…" });
|
|
3777
|
+
else {
|
|
3778
|
+
const v = ei(a, N, P);
|
|
3779
|
+
if (D = v.body, O = v.meta, v.unavailable) {
|
|
3780
|
+
const T = (h == null ? void 0 : h.title) || "this tab";
|
|
3781
|
+
b = /* @__PURE__ */ s("p", { className: "mt-1.5 flex gap-1.5 text-[11px] leading-4 text-amber-700 dark:text-amber-400", children: [
|
|
3782
|
+
/* @__PURE__ */ t(ya, { className: "mt-px h-3 w-3 shrink-0", "aria-hidden": !0 }),
|
|
3783
|
+
/* @__PURE__ */ s("span", { children: [
|
|
3784
|
+
"No change on ",
|
|
3785
|
+
T,
|
|
3786
|
+
". ",
|
|
3787
|
+
Ln(v.unavailable, "variable")
|
|
3788
|
+
] })
|
|
3789
|
+
] });
|
|
3790
|
+
}
|
|
3791
|
+
}
|
|
3792
|
+
return /* @__PURE__ */ s("div", { className: "shrink-0 border-t border-border/60 bg-muted/30 px-4 py-2.5", "data-testid": "variable-preview", children: [
|
|
3793
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
|
|
3794
|
+
/* @__PURE__ */ t("span", { className: Rt, children: l ? "Preview on" : "Preview" }),
|
|
3795
|
+
l ? /* @__PURE__ */ s(Se, { value: d ?? "", onValueChange: c, disabled: !!n, children: [
|
|
3796
|
+
/* @__PURE__ */ t(ke, { size: "xs", className: "h-6 w-auto gap-1.5 px-2 text-[12px]", "aria-label": "Preview place", children: /* @__PURE__ */ t(De, {}) }),
|
|
3797
|
+
/* @__PURE__ */ t(Ae, { children: o.map((v) => /* @__PURE__ */ t(fe, { value: v.id, children: v.title || v.id }, v.id)) })
|
|
3798
|
+
] }) : null,
|
|
3799
|
+
/* @__PURE__ */ t("div", { className: "min-w-0 flex-1 truncate text-right text-[13px]", children: D })
|
|
3800
|
+
] }),
|
|
3801
|
+
O ? /* @__PURE__ */ t("p", { className: "mt-1 text-[11px] leading-4 text-muted-foreground", children: O }) : null,
|
|
3802
|
+
b
|
|
3803
|
+
] });
|
|
3804
|
+
}
|
|
3805
|
+
function ei(e, a, r) {
|
|
3806
|
+
const n = (h) => /* @__PURE__ */ t("span", { className: "font-medium text-foreground", children: h }), i = (h) => /* @__PURE__ */ s("span", { className: "inline-flex items-center gap-1.5 text-[12px] text-amber-700 dark:text-amber-400", children: [
|
|
3807
|
+
/* @__PURE__ */ t(ya, { className: "h-3.5 w-3.5", "aria-hidden": !0 }),
|
|
3808
|
+
" ",
|
|
3809
|
+
h
|
|
3810
|
+
] }), o = (h) => h === void 0 ? "" : h === "beyondCap" ? `more than ${st} match` : `${h} ${h === 1 ? "match" : "matches"}`, l = "filterReach" in a ? a.filterReach : [], u = l.filter((h) => h.status === "applied").length, c = l.length - u, d = l.length ? ` · ${u} ${u === 1 ? "filter" : "filters"} applied${c ? `, ${c} skipped` : ""}` : "";
|
|
3811
|
+
switch (a.status) {
|
|
3812
|
+
case "answered": {
|
|
3813
|
+
const h = Dr(e, Object.keys(a.parts))[0], p = h ? a.parts[h] : void 0, m = p && Ht(p, e.presentation, r) || "(empty)", f = `${o(a.matched)}${d}`.replace(/^ · /, ""), g = yr(e, a, r);
|
|
3814
|
+
return g && typeof g == "object" && "unavailable" in g ? { body: n(m), meta: f, unavailable: g.unavailable } : g === "noPrevious" ? { body: n(m), meta: `${f} · Nothing in the period before to compare with.`.replace(/^ · /, "") } : g ? {
|
|
3815
|
+
body: /* @__PURE__ */ s(U, { children: [
|
|
3816
|
+
n(g.value),
|
|
3817
|
+
/* @__PURE__ */ s("span", { className: "text-muted-foreground", children: [
|
|
3818
|
+
" · was ",
|
|
3819
|
+
g.previous,
|
|
3820
|
+
" · "
|
|
3821
|
+
] }),
|
|
3822
|
+
n(g.change)
|
|
3823
|
+
] }),
|
|
3824
|
+
meta: f
|
|
3825
|
+
} : { body: n(m), meta: f };
|
|
3826
|
+
}
|
|
3827
|
+
case "listed": {
|
|
3828
|
+
const h = a.items.map((m) => Ht(m, e.presentation, r)), p = a.more === "beyondCap" ? " and more" : a.more ? ` and ${a.more} more` : "";
|
|
3829
|
+
return { body: n(`${h.join(e.get.kind === "list" ? e.get.separator ?? ", " : ", ")}${p}`), meta: `${o(a.matched)}${d}` };
|
|
3830
|
+
}
|
|
3831
|
+
case "none":
|
|
3832
|
+
return a.why === "moreThanOne" ? {
|
|
3833
|
+
body: i(`More than one matches${a.matched !== void 0 ? ` (${a.matched === "beyondCap" ? `${st}+` : a.matched})` : ""}. Readers see nothing.`),
|
|
3834
|
+
meta: "Keep a selection on a filter, add a condition, or choose First or List."
|
|
3835
|
+
} : { body: /* @__PURE__ */ t("span", { className: "text-muted-foreground", children: "No rows match." }), meta: d.slice(3) };
|
|
3836
|
+
case "held":
|
|
3837
|
+
return { body: /* @__PURE__ */ s("span", { className: "text-muted-foreground", children: [
|
|
3838
|
+
"Waiting for ",
|
|
3839
|
+
a.missingRequired.join(", "),
|
|
3840
|
+
"."
|
|
3841
|
+
] }), meta: "A required filter has no value here." };
|
|
3842
|
+
case "broken":
|
|
3843
|
+
return { body: i("The query no longer compiles against its mapping."), meta: "" };
|
|
3844
|
+
case "failed":
|
|
3845
|
+
return { body: i("The query failed."), meta: a.message };
|
|
3846
|
+
default:
|
|
3847
|
+
return { body: null, meta: "" };
|
|
3848
|
+
}
|
|
3849
|
+
}
|
|
3850
|
+
function oo() {
|
|
3851
|
+
const e = w((l) => l.variableEditor), a = w((l) => l.dashboard.variables), r = w((l) => l.actions.closeVariableEditor), n = et(!1), i = (e == null ? void 0 : e.kind) === "edit" ? a == null ? void 0 : a.find((l) => l.id === e.variableId) : void 0;
|
|
3852
|
+
return !(e && (e.kind === "new" || i)) ? null : /* @__PURE__ */ s(Le, { modal: !1, open: !0, onOpenChange: (l) => !l && r(), children: [
|
|
3853
|
+
/* @__PURE__ */ t("div", { className: "pointer-events-none fixed inset-0 z-40 bg-zinc-950/40 backdrop-blur-sm" }),
|
|
3854
|
+
/* @__PURE__ */ s(
|
|
3855
|
+
Ve,
|
|
3856
|
+
{
|
|
3857
|
+
className: "w-auto max-w-none gap-0 overflow-hidden p-0 [&>button:last-child]:hidden",
|
|
3858
|
+
onInteractOutside: (l) => l.preventDefault(),
|
|
3859
|
+
onEscapeKeyDown: (l) => {
|
|
3860
|
+
n.current ? l.preventDefault() : r();
|
|
3861
|
+
},
|
|
3862
|
+
children: [
|
|
3863
|
+
/* @__PURE__ */ t(Pe, { className: "sr-only", children: "Variable from data" }),
|
|
3864
|
+
/* @__PURE__ */ t(ct, { className: "sr-only", children: "Define a value from your data to show in text." }),
|
|
3865
|
+
/* @__PURE__ */ t(
|
|
3866
|
+
Ks,
|
|
3867
|
+
{
|
|
3868
|
+
variable: i,
|
|
3869
|
+
onClose: r,
|
|
3870
|
+
onHoldEscape: (l) => {
|
|
3871
|
+
n.current = l;
|
|
3872
|
+
}
|
|
3873
|
+
},
|
|
3874
|
+
(e == null ? void 0 : e.kind) === "edit" ? e.variableId : "new"
|
|
3875
|
+
)
|
|
3876
|
+
]
|
|
3877
|
+
}
|
|
3878
|
+
)
|
|
3879
|
+
] });
|
|
3880
|
+
}
|
|
3881
|
+
function ti({
|
|
3882
|
+
disabled: e,
|
|
3883
|
+
briefingCount: a,
|
|
3884
|
+
className: r,
|
|
3885
|
+
onClick: n
|
|
3886
|
+
}) {
|
|
3887
|
+
const i = typeof a == "number" && a > 0;
|
|
3888
|
+
return /* @__PURE__ */ s(
|
|
3889
|
+
L,
|
|
3890
|
+
{
|
|
3891
|
+
type: "button",
|
|
3892
|
+
size: "xs",
|
|
3893
|
+
variant: "outline",
|
|
3894
|
+
disabled: e,
|
|
3895
|
+
className: J("gap-1.5", r),
|
|
3896
|
+
onClick: n,
|
|
3897
|
+
"aria-label": "Reports & briefings",
|
|
3898
|
+
children: [
|
|
3899
|
+
/* @__PURE__ */ t(Gr, { className: "h-3.5 w-3.5" }),
|
|
3900
|
+
"Reports & briefings",
|
|
3901
|
+
i ? /* @__PURE__ */ t("span", { className: "ml-0.5 rounded-control bg-muted px-1 text-[10px] tabular-nums text-foreground/70", children: a }) : null
|
|
3902
|
+
]
|
|
3903
|
+
}
|
|
3904
|
+
);
|
|
3905
|
+
}
|
|
3906
|
+
const ai = "text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground", La = "inline-flex h-7 items-center gap-1.5 rounded-control px-2 text-[12px] text-muted-foreground hover:bg-muted hover:text-foreground disabled:opacity-50", Ze = "inline-flex h-7 items-center gap-1.5 rounded-control bg-primary px-3 text-[12px] font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50";
|
|
3907
|
+
function ni(e) {
|
|
3908
|
+
return e === "dashboard" ? "This dashboard" : "Project";
|
|
3909
|
+
}
|
|
3910
|
+
function ri(e) {
|
|
3911
|
+
if (!e) return "Never";
|
|
3912
|
+
const a = new Date(e);
|
|
3913
|
+
if (Number.isNaN(a.getTime())) return "Unknown";
|
|
3914
|
+
const r = Date.now() - a.getTime(), n = Math.round(r / 6e4);
|
|
3915
|
+
if (n < 1) return "now";
|
|
3916
|
+
if (n < 60) return `${n}m ago`;
|
|
3917
|
+
const i = Math.round(n / 60);
|
|
3918
|
+
if (i < 24) return `${i}h ago`;
|
|
3919
|
+
const o = Math.round(i / 24);
|
|
3920
|
+
if (o < 7) return `${o}d ago`;
|
|
3921
|
+
const l = Math.round(o / 7);
|
|
3922
|
+
return l < 5 ? `${l}w ago` : `${Math.round(o / 30)}mo ago`;
|
|
3923
|
+
}
|
|
3924
|
+
function si(e) {
|
|
3925
|
+
return e.scheduleExpr ? jr(
|
|
3926
|
+
e.scheduleExpr,
|
|
3927
|
+
e.timezone || "UTC"
|
|
3928
|
+
) ?? "Invalid schedule" : "On demand";
|
|
3929
|
+
}
|
|
3930
|
+
function ii(e) {
|
|
3931
|
+
if (e.lastRunStatus) {
|
|
3932
|
+
const a = e.lastRunStatus.toString().toUpperCase();
|
|
3933
|
+
return a === "SUCCESS" ? "Last run completed." : a === "FAILED" ? "Last run failed." : `Last run ${e.lastRunStatus.toString().toLowerCase()}`;
|
|
3934
|
+
}
|
|
3935
|
+
return null;
|
|
3936
|
+
}
|
|
3937
|
+
function Va(e) {
|
|
3938
|
+
return e.hasActiveRun ? "Running" : e.lastRunStatus ? `Last run ${e.lastRunStatus.toString().toLowerCase()}` : "Idle";
|
|
3939
|
+
}
|
|
3940
|
+
function oi(e) {
|
|
3941
|
+
return e.source.type === "dashboard" ? "This dashboard" : "Project";
|
|
3942
|
+
}
|
|
3943
|
+
function li({
|
|
3944
|
+
activeView: e,
|
|
3945
|
+
onChange: a
|
|
3946
|
+
}) {
|
|
3947
|
+
return /* @__PURE__ */ t(
|
|
3948
|
+
"div",
|
|
3949
|
+
{
|
|
3950
|
+
className: "flex shrink-0 items-center gap-1 rounded-control bg-muted p-0.5",
|
|
3951
|
+
role: "tablist",
|
|
3952
|
+
"aria-label": "Briefing source view",
|
|
3953
|
+
children: ["dashboard", "project"].map((r) => {
|
|
3954
|
+
const n = e === r;
|
|
3955
|
+
return /* @__PURE__ */ t(
|
|
3956
|
+
"button",
|
|
3957
|
+
{
|
|
3958
|
+
type: "button",
|
|
3959
|
+
role: "tab",
|
|
3960
|
+
"aria-selected": n,
|
|
3961
|
+
onClick: () => a(r),
|
|
3962
|
+
className: J(
|
|
3963
|
+
"h-6 rounded-[3px] px-2 text-[11px] transition-colors",
|
|
3964
|
+
n ? "bg-background font-medium text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
|
|
3965
|
+
),
|
|
3966
|
+
children: ni(r)
|
|
3967
|
+
},
|
|
3968
|
+
r
|
|
3969
|
+
);
|
|
3970
|
+
})
|
|
3971
|
+
}
|
|
3972
|
+
);
|
|
3973
|
+
}
|
|
3974
|
+
function di({
|
|
3975
|
+
briefings: e,
|
|
3976
|
+
dashboardLabel: a,
|
|
3977
|
+
sourceView: r,
|
|
3978
|
+
error: n,
|
|
3979
|
+
loading: i,
|
|
3980
|
+
onSourceViewChange: o,
|
|
3981
|
+
onClose: l,
|
|
3982
|
+
onEdit: u,
|
|
3983
|
+
onNew: c,
|
|
3984
|
+
canCreate: d,
|
|
3985
|
+
canCreateScheduledReport: h,
|
|
3986
|
+
analyticalBriefingsEnabled: p,
|
|
3987
|
+
onRunNow: m,
|
|
3988
|
+
onTogglePause: f,
|
|
3989
|
+
onDelete: g,
|
|
3990
|
+
selectingId: y,
|
|
3991
|
+
busyId: N,
|
|
3992
|
+
manageBriefingsHref: k,
|
|
3993
|
+
contentKind: V,
|
|
3994
|
+
hideHeader: P = !1
|
|
3995
|
+
}) {
|
|
3996
|
+
const D = e.length, O = e.filter((I) => I.status === "ACTIVE").length, b = V === "reports" ? D === 1 ? "report" : "reports" : V === "briefings" ? D === 1 ? "briefing" : "briefings" : D === 1 ? "item" : "items", S = e.find((I) => I.hasActiveRun) ?? null, v = V ?? "reports & briefings", T = r === "dashboard" ? a : `Project ${v}`;
|
|
3997
|
+
return /* @__PURE__ */ s(
|
|
3998
|
+
"section",
|
|
3999
|
+
{
|
|
4000
|
+
"aria-label": `Dashboard ${v.replace("&", "and")}`,
|
|
4001
|
+
className: "flex h-full min-h-0 flex-col bg-background text-foreground",
|
|
4002
|
+
children: [
|
|
4003
|
+
P ? null : /* @__PURE__ */ s("header", { className: "flex items-start justify-between gap-3 border-b border-border px-4 py-3", children: [
|
|
4004
|
+
/* @__PURE__ */ s("div", { className: "min-w-0", children: [
|
|
4005
|
+
/* @__PURE__ */ t("div", { className: ai, children: v }),
|
|
4006
|
+
/* @__PURE__ */ t("h2", { className: "mt-0.5 truncate text-[14px] font-semibold leading-5", children: T })
|
|
4007
|
+
] }),
|
|
4008
|
+
/* @__PURE__ */ t(
|
|
4009
|
+
"button",
|
|
4010
|
+
{
|
|
4011
|
+
type: "button",
|
|
4012
|
+
onClick: l,
|
|
4013
|
+
className: "rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
4014
|
+
"aria-label": `Close ${v.replace("&", "and")} panel`,
|
|
4015
|
+
children: /* @__PURE__ */ t(Qe, { className: "h-3.5 w-3.5" })
|
|
4016
|
+
}
|
|
4017
|
+
)
|
|
4018
|
+
] }),
|
|
4019
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-3 border-b border-border px-4 py-2", children: [
|
|
4020
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-3", children: [
|
|
4021
|
+
/* @__PURE__ */ t(
|
|
4022
|
+
li,
|
|
4023
|
+
{
|
|
4024
|
+
activeView: r,
|
|
4025
|
+
onChange: o
|
|
4026
|
+
}
|
|
4027
|
+
),
|
|
4028
|
+
/* @__PURE__ */ t("div", { className: "flex min-w-0 items-center gap-1.5 text-[11px] text-muted-foreground", children: i && D === 0 ? /* @__PURE__ */ s("span", { children: [
|
|
4029
|
+
"Loading ",
|
|
4030
|
+
v,
|
|
4031
|
+
"…"
|
|
4032
|
+
] }) : D === 0 ? /* @__PURE__ */ s("span", { children: [
|
|
4033
|
+
"No ",
|
|
4034
|
+
v,
|
|
4035
|
+
" yet"
|
|
4036
|
+
] }) : /* @__PURE__ */ s(U, { children: [
|
|
4037
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-foreground/80", children: [
|
|
4038
|
+
D,
|
|
4039
|
+
" ",
|
|
4040
|
+
b
|
|
4041
|
+
] }),
|
|
4042
|
+
/* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
|
|
4043
|
+
/* @__PURE__ */ s("span", { children: [
|
|
4044
|
+
O,
|
|
4045
|
+
" active"
|
|
4046
|
+
] })
|
|
4047
|
+
] }) })
|
|
4048
|
+
] }),
|
|
4049
|
+
/* @__PURE__ */ s("div", { className: "flex items-center gap-1.5", children: [
|
|
4050
|
+
i ? (
|
|
4051
|
+
// Auto-refresh on open; surface a quiet spinner near the count
|
|
4052
|
+
// when a manual reload is in flight, but don't show a separate
|
|
4053
|
+
// refresh button — close+reopen handles the rare "stale list"
|
|
4054
|
+
// case without crowding the toolbar.
|
|
4055
|
+
/* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground" })
|
|
4056
|
+
) : null,
|
|
4057
|
+
D > 0 && d ? p && h ? /* @__PURE__ */ s(je, { children: [
|
|
4058
|
+
/* @__PURE__ */ t(qe, { asChild: !0, children: /* @__PURE__ */ s("button", { className: Ze, children: [
|
|
4059
|
+
/* @__PURE__ */ t(be, { className: "h-3 w-3" }),
|
|
4060
|
+
" New"
|
|
4061
|
+
] }) }),
|
|
4062
|
+
/* @__PURE__ */ s(We, { align: "end", children: [
|
|
4063
|
+
/* @__PURE__ */ t(re, { onClick: () => c("scheduled_report"), children: "Schedule a report" }),
|
|
4064
|
+
/* @__PURE__ */ t(
|
|
4065
|
+
re,
|
|
4066
|
+
{
|
|
4067
|
+
onClick: () => c("analytical_briefing"),
|
|
4068
|
+
children: "Create analytical briefing"
|
|
4069
|
+
}
|
|
4070
|
+
)
|
|
4071
|
+
] })
|
|
4072
|
+
] }) : h ? /* @__PURE__ */ s(
|
|
4073
|
+
"button",
|
|
4074
|
+
{
|
|
4075
|
+
onClick: () => c("scheduled_report"),
|
|
4076
|
+
className: Ze,
|
|
4077
|
+
children: [
|
|
4078
|
+
/* @__PURE__ */ t(be, { className: "h-3 w-3" }),
|
|
4079
|
+
" Schedule report"
|
|
4080
|
+
]
|
|
4081
|
+
}
|
|
4082
|
+
) : p ? /* @__PURE__ */ s(
|
|
4083
|
+
"button",
|
|
4084
|
+
{
|
|
4085
|
+
onClick: () => c("analytical_briefing"),
|
|
4086
|
+
className: Ze,
|
|
4087
|
+
children: [
|
|
4088
|
+
/* @__PURE__ */ t(be, { className: "h-3 w-3" }),
|
|
4089
|
+
" New briefing"
|
|
4090
|
+
]
|
|
4091
|
+
}
|
|
4092
|
+
) : null : null
|
|
4093
|
+
] })
|
|
4094
|
+
] }),
|
|
4095
|
+
S ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2 border-b border-border bg-muted/60 px-4 py-2 text-[12px]", children: [
|
|
4096
|
+
/* @__PURE__ */ t(de, { className: "h-3 w-3 shrink-0 animate-spin text-muted-foreground" }),
|
|
4097
|
+
/* @__PURE__ */ t("span", { className: "font-medium text-foreground", children: S.name }),
|
|
4098
|
+
/* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
|
|
4099
|
+
/* @__PURE__ */ t("span", { className: "truncate text-muted-foreground", children: Va(S) })
|
|
4100
|
+
] }) : null,
|
|
4101
|
+
/* @__PURE__ */ s("div", { className: "flex-1 overflow-y-auto", children: [
|
|
4102
|
+
n ? /* @__PURE__ */ t("div", { className: "m-4 rounded-card border border-destructive/30 bg-destructive/10 px-3 py-2 text-[12px] text-destructive", children: n }) : null,
|
|
4103
|
+
!i && e.length === 0 && !n ? /* @__PURE__ */ t(
|
|
4104
|
+
ci,
|
|
4105
|
+
{
|
|
4106
|
+
onNew: c,
|
|
4107
|
+
canCreate: d,
|
|
4108
|
+
canCreateScheduledReport: h,
|
|
4109
|
+
analyticalBriefingsEnabled: p,
|
|
4110
|
+
contentKind: V
|
|
4111
|
+
}
|
|
4112
|
+
) : null,
|
|
4113
|
+
e.map((I) => /* @__PURE__ */ t(
|
|
4114
|
+
hi,
|
|
4115
|
+
{
|
|
4116
|
+
briefing: I,
|
|
4117
|
+
isOpening: y === I.id,
|
|
4118
|
+
isBusy: N === I.id,
|
|
4119
|
+
onOpen: () => u(I.id),
|
|
4120
|
+
onRunNow: () => m(I),
|
|
4121
|
+
onTogglePause: () => f(I),
|
|
4122
|
+
onDelete: () => g(I)
|
|
4123
|
+
},
|
|
4124
|
+
I.id
|
|
4125
|
+
))
|
|
4126
|
+
] }),
|
|
4127
|
+
k ? /* @__PURE__ */ t("div", { className: "border-t border-border px-4 py-2.5", children: /* @__PURE__ */ s(
|
|
4128
|
+
"a",
|
|
4129
|
+
{
|
|
4130
|
+
href: k,
|
|
4131
|
+
className: J(La, "h-6 px-1 text-[11px]"),
|
|
4132
|
+
children: [
|
|
4133
|
+
"Manage all reports & briefings",
|
|
4134
|
+
/* @__PURE__ */ t(Wr, { className: "h-3 w-3" })
|
|
4135
|
+
]
|
|
4136
|
+
}
|
|
4137
|
+
) }) : null
|
|
4138
|
+
]
|
|
4139
|
+
}
|
|
4140
|
+
);
|
|
4141
|
+
}
|
|
4142
|
+
function ci({
|
|
4143
|
+
onNew: e,
|
|
4144
|
+
canCreate: a,
|
|
4145
|
+
canCreateScheduledReport: r,
|
|
4146
|
+
analyticalBriefingsEnabled: n,
|
|
4147
|
+
contentKind: i
|
|
4148
|
+
}) {
|
|
4149
|
+
const o = i === "reports" ? {
|
|
4150
|
+
title: "No reports yet",
|
|
4151
|
+
description: "Schedule an emailed dashboard or visual report to see it here."
|
|
4152
|
+
} : i === "briefings" ? {
|
|
4153
|
+
title: "No briefings yet",
|
|
4154
|
+
description: "Create an analytical briefing to monitor this dashboard and brief your team."
|
|
4155
|
+
} : null;
|
|
4156
|
+
return /* @__PURE__ */ s("div", { className: "flex h-full flex-col items-center justify-center px-8 py-12 text-center", children: [
|
|
4157
|
+
/* @__PURE__ */ t(ui, { className: "mb-5 h-[88px] w-[112px] text-border" }),
|
|
4158
|
+
/* @__PURE__ */ t("div", { className: "text-[13px] font-medium text-foreground", children: (o == null ? void 0 : o.title) ?? "Have an analyst brief your team" }),
|
|
4159
|
+
/* @__PURE__ */ t("p", { className: "mt-1.5 max-w-[320px] text-[12px] leading-5 text-muted-foreground", children: (o == null ? void 0 : o.description) ?? "Describe what to watch. An analyst digs into this dashboard and the data behind it, then briefs your team on the cadence you choose." }),
|
|
4160
|
+
a ? /* @__PURE__ */ s("div", { className: "mt-4 flex flex-wrap justify-center gap-2", children: [
|
|
4161
|
+
r ? /* @__PURE__ */ s(
|
|
4162
|
+
"button",
|
|
4163
|
+
{
|
|
4164
|
+
onClick: () => e("scheduled_report"),
|
|
4165
|
+
className: Ze,
|
|
4166
|
+
children: [
|
|
4167
|
+
/* @__PURE__ */ t(be, { className: "h-3 w-3" }),
|
|
4168
|
+
" Schedule a report"
|
|
4169
|
+
]
|
|
4170
|
+
}
|
|
4171
|
+
) : null,
|
|
4172
|
+
n ? /* @__PURE__ */ t(
|
|
4173
|
+
"button",
|
|
4174
|
+
{
|
|
4175
|
+
onClick: () => e("analytical_briefing"),
|
|
4176
|
+
className: La,
|
|
4177
|
+
children: "Create analytical briefing"
|
|
4178
|
+
}
|
|
4179
|
+
) : null
|
|
4180
|
+
] }) : null
|
|
4181
|
+
] });
|
|
4182
|
+
}
|
|
4183
|
+
function ui({ className: e }) {
|
|
4184
|
+
return /* @__PURE__ */ s(
|
|
4185
|
+
"svg",
|
|
4186
|
+
{
|
|
4187
|
+
viewBox: "0 0 112 88",
|
|
4188
|
+
fill: "none",
|
|
4189
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
4190
|
+
role: "presentation",
|
|
4191
|
+
"aria-hidden": "true",
|
|
4192
|
+
className: e,
|
|
4193
|
+
children: [
|
|
4194
|
+
/* @__PURE__ */ t(
|
|
4195
|
+
"rect",
|
|
4196
|
+
{
|
|
4197
|
+
x: "22",
|
|
4198
|
+
y: "6",
|
|
4199
|
+
width: "60",
|
|
4200
|
+
height: "72",
|
|
4201
|
+
rx: "3",
|
|
4202
|
+
stroke: "currentColor",
|
|
4203
|
+
strokeWidth: "1.25"
|
|
4204
|
+
}
|
|
4205
|
+
),
|
|
4206
|
+
/* @__PURE__ */ t(
|
|
4207
|
+
"line",
|
|
4208
|
+
{
|
|
4209
|
+
x1: "30",
|
|
4210
|
+
y1: "16",
|
|
4211
|
+
x2: "64",
|
|
4212
|
+
y2: "16",
|
|
4213
|
+
stroke: "currentColor",
|
|
4214
|
+
strokeWidth: "1.5",
|
|
4215
|
+
strokeLinecap: "round"
|
|
4216
|
+
}
|
|
4217
|
+
),
|
|
4218
|
+
/* @__PURE__ */ t(
|
|
4219
|
+
"line",
|
|
4220
|
+
{
|
|
4221
|
+
x1: "30",
|
|
4222
|
+
y1: "21",
|
|
4223
|
+
x2: "52",
|
|
4224
|
+
y2: "21",
|
|
4225
|
+
stroke: "currentColor",
|
|
4226
|
+
strokeWidth: "1",
|
|
4227
|
+
strokeLinecap: "round",
|
|
4228
|
+
opacity: "0.5"
|
|
4229
|
+
}
|
|
4230
|
+
),
|
|
4231
|
+
/* @__PURE__ */ t("circle", { cx: "31", cy: "32", r: "1", fill: "currentColor", opacity: "0.6" }),
|
|
4232
|
+
/* @__PURE__ */ t(
|
|
4233
|
+
"line",
|
|
4234
|
+
{
|
|
4235
|
+
x1: "35",
|
|
4236
|
+
y1: "32",
|
|
4237
|
+
x2: "72",
|
|
4238
|
+
y2: "32",
|
|
4239
|
+
stroke: "currentColor",
|
|
4240
|
+
strokeWidth: "1",
|
|
4241
|
+
opacity: "0.4",
|
|
4242
|
+
strokeLinecap: "round"
|
|
4243
|
+
}
|
|
4244
|
+
),
|
|
4245
|
+
/* @__PURE__ */ t("circle", { cx: "31", cy: "38", r: "1", fill: "currentColor", opacity: "0.6" }),
|
|
4246
|
+
/* @__PURE__ */ t(
|
|
4247
|
+
"line",
|
|
4248
|
+
{
|
|
4249
|
+
x1: "35",
|
|
4250
|
+
y1: "38",
|
|
4251
|
+
x2: "68",
|
|
4252
|
+
y2: "38",
|
|
4253
|
+
stroke: "currentColor",
|
|
4254
|
+
strokeWidth: "1",
|
|
4255
|
+
opacity: "0.4",
|
|
4256
|
+
strokeLinecap: "round"
|
|
4257
|
+
}
|
|
4258
|
+
),
|
|
4259
|
+
/* @__PURE__ */ t("circle", { cx: "31", cy: "44", r: "1", fill: "currentColor", opacity: "0.6" }),
|
|
4260
|
+
/* @__PURE__ */ t(
|
|
4261
|
+
"line",
|
|
4262
|
+
{
|
|
4263
|
+
x1: "35",
|
|
4264
|
+
y1: "44",
|
|
4265
|
+
x2: "74",
|
|
4266
|
+
y2: "44",
|
|
4267
|
+
stroke: "currentColor",
|
|
4268
|
+
strokeWidth: "1",
|
|
4269
|
+
opacity: "0.4",
|
|
4270
|
+
strokeLinecap: "round"
|
|
4271
|
+
}
|
|
4272
|
+
),
|
|
4273
|
+
/* @__PURE__ */ t(
|
|
4274
|
+
"rect",
|
|
4275
|
+
{
|
|
4276
|
+
x: "30",
|
|
4277
|
+
y: "64",
|
|
4278
|
+
width: "5",
|
|
4279
|
+
height: "8",
|
|
4280
|
+
rx: "0.5",
|
|
4281
|
+
fill: "currentColor",
|
|
4282
|
+
opacity: "0.55"
|
|
4283
|
+
}
|
|
4284
|
+
),
|
|
4285
|
+
/* @__PURE__ */ t(
|
|
4286
|
+
"rect",
|
|
4287
|
+
{
|
|
4288
|
+
x: "38",
|
|
4289
|
+
y: "60",
|
|
4290
|
+
width: "5",
|
|
4291
|
+
height: "12",
|
|
4292
|
+
rx: "0.5",
|
|
4293
|
+
fill: "currentColor",
|
|
4294
|
+
opacity: "0.7"
|
|
4295
|
+
}
|
|
4296
|
+
),
|
|
4297
|
+
/* @__PURE__ */ t(
|
|
4298
|
+
"rect",
|
|
4299
|
+
{
|
|
4300
|
+
x: "46",
|
|
4301
|
+
y: "56",
|
|
4302
|
+
width: "5",
|
|
4303
|
+
height: "16",
|
|
4304
|
+
rx: "0.5",
|
|
4305
|
+
fill: "currentColor",
|
|
4306
|
+
opacity: "0.85"
|
|
4307
|
+
}
|
|
4308
|
+
),
|
|
4309
|
+
/* @__PURE__ */ t(
|
|
4310
|
+
"rect",
|
|
4311
|
+
{
|
|
4312
|
+
x: "54",
|
|
4313
|
+
y: "62",
|
|
4314
|
+
width: "5",
|
|
4315
|
+
height: "10",
|
|
4316
|
+
rx: "0.5",
|
|
4317
|
+
fill: "currentColor",
|
|
4318
|
+
opacity: "0.6"
|
|
4319
|
+
}
|
|
4320
|
+
),
|
|
4321
|
+
/* @__PURE__ */ t(
|
|
4322
|
+
"rect",
|
|
4323
|
+
{
|
|
4324
|
+
x: "62",
|
|
4325
|
+
y: "58",
|
|
4326
|
+
width: "5",
|
|
4327
|
+
height: "14",
|
|
4328
|
+
rx: "0.5",
|
|
4329
|
+
fill: "currentColor",
|
|
4330
|
+
opacity: "0.75"
|
|
4331
|
+
}
|
|
4332
|
+
),
|
|
4333
|
+
/* @__PURE__ */ t(
|
|
4334
|
+
"circle",
|
|
4335
|
+
{
|
|
4336
|
+
cx: "86",
|
|
4337
|
+
cy: "62",
|
|
4338
|
+
r: "10",
|
|
4339
|
+
fill: "var(--background, white)",
|
|
4340
|
+
stroke: "currentColor",
|
|
4341
|
+
strokeWidth: "1.25"
|
|
4342
|
+
}
|
|
4343
|
+
),
|
|
4344
|
+
/* @__PURE__ */ t(
|
|
4345
|
+
"line",
|
|
4346
|
+
{
|
|
4347
|
+
x1: "93.5",
|
|
4348
|
+
y1: "69.5",
|
|
4349
|
+
x2: "100",
|
|
4350
|
+
y2: "76",
|
|
4351
|
+
stroke: "currentColor",
|
|
4352
|
+
strokeWidth: "1.5",
|
|
4353
|
+
strokeLinecap: "round"
|
|
4354
|
+
}
|
|
4355
|
+
)
|
|
4356
|
+
]
|
|
4357
|
+
}
|
|
4358
|
+
);
|
|
4359
|
+
}
|
|
4360
|
+
function hi({
|
|
4361
|
+
briefing: e,
|
|
4362
|
+
isOpening: a,
|
|
4363
|
+
isBusy: r,
|
|
4364
|
+
onOpen: n,
|
|
4365
|
+
onRunNow: i,
|
|
4366
|
+
onTogglePause: o,
|
|
4367
|
+
onDelete: l
|
|
4368
|
+
}) {
|
|
4369
|
+
const u = e.status === "PAUSED", c = e.hasActiveRun, d = ii(e), h = ri(e.lastRunAt), p = e.lastRunStatus, m = pe(e), f = p === "SUCCESS" ? Xe.success.dot : p === "FAILED" ? Xe.danger.dot : p ? Xe.warning.dot : Xe.neutral.dot;
|
|
4370
|
+
return /* @__PURE__ */ s(
|
|
4371
|
+
"div",
|
|
4372
|
+
{
|
|
4373
|
+
className: J(
|
|
4374
|
+
"group relative border-b border-border/60 px-4 py-3 transition-colors hover:bg-muted/60",
|
|
4375
|
+
u && "opacity-70"
|
|
4376
|
+
),
|
|
4377
|
+
children: [
|
|
4378
|
+
/* @__PURE__ */ s(
|
|
4379
|
+
"div",
|
|
4380
|
+
{
|
|
4381
|
+
role: "button",
|
|
4382
|
+
tabIndex: 0,
|
|
4383
|
+
onClick: n,
|
|
4384
|
+
onKeyDown: (g) => {
|
|
4385
|
+
(g.key === "Enter" || g.key === " ") && (g.preventDefault(), n());
|
|
4386
|
+
},
|
|
4387
|
+
className: "cursor-pointer pr-8",
|
|
4388
|
+
children: [
|
|
4389
|
+
/* @__PURE__ */ s("div", { className: "flex min-w-0 items-center gap-2", children: [
|
|
4390
|
+
/* @__PURE__ */ t("span", { className: "truncate text-[13px] font-medium text-foreground", children: e.name }),
|
|
4391
|
+
u ? /* @__PURE__ */ t("span", { className: "shrink-0 text-[11px] text-muted-foreground", children: "· Paused" }) : null
|
|
4392
|
+
] }),
|
|
4393
|
+
/* @__PURE__ */ s("div", { className: "mt-1 flex flex-wrap items-center gap-x-1.5 text-[11px] text-muted-foreground", children: [
|
|
4394
|
+
/* @__PURE__ */ t("span", { children: m.typeLabel }),
|
|
4395
|
+
/* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
|
|
4396
|
+
/* @__PURE__ */ t("span", { children: oi(e) }),
|
|
4397
|
+
/* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
|
|
4398
|
+
/* @__PURE__ */ t(Vn, { className: "h-3 w-3" }),
|
|
4399
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: si(e) }),
|
|
4400
|
+
e.lastRunAt ? /* @__PURE__ */ s(U, { children: [
|
|
4401
|
+
/* @__PURE__ */ t("span", { className: "text-border", children: "·" }),
|
|
4402
|
+
/* @__PURE__ */ s("span", { children: [
|
|
4403
|
+
"Last run ",
|
|
4404
|
+
h
|
|
4405
|
+
] })
|
|
4406
|
+
] }) : null
|
|
4407
|
+
] }),
|
|
4408
|
+
d || c ? /* @__PURE__ */ s("div", { className: "mt-1.5 flex items-center gap-1.5 text-[12px] leading-[1.5] text-foreground/80", children: [
|
|
4409
|
+
c ? /* @__PURE__ */ t(de, { className: "h-3 w-3 shrink-0 animate-spin text-muted-foreground/70" }) : /* @__PURE__ */ t(
|
|
4410
|
+
"span",
|
|
4411
|
+
{
|
|
4412
|
+
className: J(
|
|
4413
|
+
"inline-block h-1.5 w-1.5 shrink-0 rounded-full",
|
|
4414
|
+
f
|
|
4415
|
+
)
|
|
4416
|
+
}
|
|
4417
|
+
),
|
|
4418
|
+
/* @__PURE__ */ t("span", { className: "truncate", children: c ? Va(e) : d })
|
|
4419
|
+
] }) : null
|
|
4420
|
+
]
|
|
4421
|
+
}
|
|
4422
|
+
),
|
|
4423
|
+
/* @__PURE__ */ t("div", { className: "absolute right-3 top-3", children: r ? /* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground/70" }) : a ? /* @__PURE__ */ t(de, { className: "h-3.5 w-3.5 animate-spin text-muted-foreground/70" }) : /* @__PURE__ */ s(je, { children: [
|
|
4424
|
+
/* @__PURE__ */ t(qe, { asChild: !0, children: /* @__PURE__ */ t(
|
|
4425
|
+
"button",
|
|
4426
|
+
{
|
|
4427
|
+
type: "button",
|
|
4428
|
+
onClick: (g) => g.stopPropagation(),
|
|
4429
|
+
className: "inline-flex h-6 w-6 items-center justify-center rounded-control text-muted-foreground/70 opacity-60 hover:bg-muted hover:text-foreground/80 focus-visible:opacity-100 group-hover:opacity-100",
|
|
4430
|
+
"aria-label": `${m.noun === "report" ? "Report" : "Briefing"} actions`,
|
|
4431
|
+
children: /* @__PURE__ */ t(ma, { className: "h-3.5 w-3.5" })
|
|
4432
|
+
}
|
|
4433
|
+
) }),
|
|
4434
|
+
/* @__PURE__ */ s(We, { align: "end", className: "w-44", children: [
|
|
4435
|
+
/* @__PURE__ */ s(re, { onClick: n, children: [
|
|
4436
|
+
/* @__PURE__ */ t(Vt, { className: "h-3.5 w-3.5" }),
|
|
4437
|
+
"Edit ",
|
|
4438
|
+
m.noun
|
|
4439
|
+
] }),
|
|
4440
|
+
/* @__PURE__ */ s(
|
|
4441
|
+
re,
|
|
4442
|
+
{
|
|
4443
|
+
onClick: (g) => {
|
|
4444
|
+
g.preventDefault(), i();
|
|
4445
|
+
},
|
|
4446
|
+
children: [
|
|
4447
|
+
/* @__PURE__ */ t(Pn, { className: "h-3.5 w-3.5" }),
|
|
4448
|
+
"Run now"
|
|
4449
|
+
]
|
|
4450
|
+
}
|
|
4451
|
+
),
|
|
4452
|
+
e.scheduleExpr ? /* @__PURE__ */ t(
|
|
4453
|
+
re,
|
|
4454
|
+
{
|
|
4455
|
+
onClick: (g) => {
|
|
4456
|
+
g.preventDefault(), o();
|
|
4457
|
+
},
|
|
4458
|
+
children: u ? /* @__PURE__ */ s(U, { children: [
|
|
4459
|
+
/* @__PURE__ */ t(Bn, { className: "h-3.5 w-3.5" }),
|
|
4460
|
+
"Resume"
|
|
4461
|
+
] }) : /* @__PURE__ */ s(U, { children: [
|
|
4462
|
+
/* @__PURE__ */ t(_n, { className: "h-3.5 w-3.5" }),
|
|
4463
|
+
"Pause"
|
|
4464
|
+
] })
|
|
4465
|
+
}
|
|
4466
|
+
) : null,
|
|
4467
|
+
/* @__PURE__ */ t(at, {}),
|
|
4468
|
+
/* @__PURE__ */ s(
|
|
4469
|
+
re,
|
|
4470
|
+
{
|
|
4471
|
+
onClick: (g) => {
|
|
4472
|
+
g.preventDefault(), l();
|
|
4473
|
+
},
|
|
4474
|
+
className: "text-destructive focus:bg-destructive/10 focus:text-destructive",
|
|
4475
|
+
children: [
|
|
4476
|
+
/* @__PURE__ */ t(tt, { className: "h-3.5 w-3.5" }),
|
|
4477
|
+
"Delete ",
|
|
4478
|
+
m.noun
|
|
4479
|
+
]
|
|
4480
|
+
}
|
|
4481
|
+
)
|
|
4482
|
+
] })
|
|
4483
|
+
] }) })
|
|
4484
|
+
]
|
|
4485
|
+
}
|
|
4486
|
+
);
|
|
4487
|
+
}
|
|
4488
|
+
function mi(e) {
|
|
4489
|
+
return (e == null ? void 0 : e.trim()) || "This dashboard";
|
|
4490
|
+
}
|
|
4491
|
+
function pi(e) {
|
|
4492
|
+
return e === "This dashboard" ? "Watch this dashboard" : `Watch ${e}`;
|
|
4493
|
+
}
|
|
4494
|
+
function fi(e, a, r) {
|
|
4495
|
+
return a !== "dashboard" ? e : e.filter(
|
|
4496
|
+
(n) => n.source.type === "dashboard" && n.source.dashboardId === r
|
|
4497
|
+
);
|
|
4498
|
+
}
|
|
4499
|
+
async function gi(e) {
|
|
4500
|
+
const r = [];
|
|
4501
|
+
let n = 1, i = 0, o = Number.POSITIVE_INFINITY;
|
|
4502
|
+
for (; i < o; ) {
|
|
4503
|
+
const l = await e.apiClient.listBriefings(
|
|
4504
|
+
e.apiServiceUrl,
|
|
4505
|
+
e.token,
|
|
4506
|
+
{ scope: "organization", page: n, pageSize: 100 }
|
|
4507
|
+
);
|
|
4508
|
+
if (r.push(...l.briefings), i += l.briefings.length, o = l.total, l.briefings.length === 0 || i >= o) break;
|
|
4509
|
+
n += 1;
|
|
4510
|
+
}
|
|
4511
|
+
return r;
|
|
4512
|
+
}
|
|
4513
|
+
const bi = {
|
|
4514
|
+
listBriefings: Wn,
|
|
4515
|
+
getBriefing: qn,
|
|
4516
|
+
pauseBriefing: jn,
|
|
4517
|
+
resumeBriefing: $n,
|
|
4518
|
+
deleteBriefing: Un,
|
|
4519
|
+
runBriefingNow: Rn
|
|
4520
|
+
};
|
|
4521
|
+
function lo(e) {
|
|
4522
|
+
return /* @__PURE__ */ t(On, { authToken: e.token ? { accessToken: e.token } : void 0, children: /* @__PURE__ */ t(Mn, { children: /* @__PURE__ */ t(xi, { ...e }) }) });
|
|
4523
|
+
}
|
|
4524
|
+
function xi({
|
|
4525
|
+
dashboardId: e,
|
|
4526
|
+
dashboardTitle: a,
|
|
4527
|
+
apiServiceUrl: r,
|
|
4528
|
+
token: n,
|
|
4529
|
+
disabled: i,
|
|
4530
|
+
className: o,
|
|
4531
|
+
manageBriefingsHref: l,
|
|
4532
|
+
open: u,
|
|
4533
|
+
onOpenChange: c,
|
|
4534
|
+
hideTrigger: d = !1,
|
|
4535
|
+
workflowIntent: h,
|
|
4536
|
+
openRun: p,
|
|
4537
|
+
client: m
|
|
4538
|
+
}) {
|
|
4539
|
+
const { authToken: f, tokenProps: g } = $e(), y = zn(), N = !h || y.canCreate && (h === "scheduled_report" || y.analyticalBriefingsEnabled), [k, V] = A(!1), P = u ?? k, D = (F) => {
|
|
4540
|
+
u === void 0 && V(F), c == null || c(F);
|
|
4541
|
+
}, [O, b] = A(
|
|
4542
|
+
h ? "author" : "list"
|
|
4543
|
+
), [S, v] = A(
|
|
4544
|
+
h ?? "analytical_briefing"
|
|
4545
|
+
), [T, I] = A("dashboard"), [H, B] = A(
|
|
4546
|
+
[]
|
|
4547
|
+
), [Q, X] = A(null), _ = h && !N && !Q ? "list" : O, [te, Z] = A(!1), [G, E] = A(null), [ae, j] = A(null), [z, ne] = A(
|
|
4548
|
+
null
|
|
4549
|
+
), [ue, he] = A(null), ye = et(null), x = et(P);
|
|
4550
|
+
Ie(() => {
|
|
4551
|
+
const F = P && !x.current;
|
|
4552
|
+
x.current = P, !(!F || !h) && (X(null), I("dashboard"), v(h), b("author"), he(null));
|
|
4553
|
+
}, [P, h]);
|
|
4554
|
+
const R = Lt(), $ = r ?? (g == null ? void 0 : g.apiServiceUrl), K = n ?? (f == null ? void 0 : f.accessToken), le = Y(() => ({ ...bi, ...m }), [m]), [_e, ht] = A(null);
|
|
4555
|
+
Ie(() => {
|
|
4556
|
+
if (!p || !$ || !K) return;
|
|
4557
|
+
let F = !0;
|
|
4558
|
+
return le.getBriefing($, K, p.briefingId).then(({ briefing: W }) => {
|
|
4559
|
+
F && (X(W), ht(p), b("author"));
|
|
4560
|
+
}, (W) => {
|
|
4561
|
+
F && M.error(W instanceof Error ? W.message : "Could not open the run.");
|
|
4562
|
+
}), () => {
|
|
4563
|
+
F = !1;
|
|
4564
|
+
};
|
|
4565
|
+
}, [p, $, K, le]);
|
|
4566
|
+
const Fe = mi(a), He = Y(() => {
|
|
4567
|
+
const F = fi(
|
|
4568
|
+
H,
|
|
4569
|
+
T,
|
|
4570
|
+
e
|
|
4571
|
+
);
|
|
4572
|
+
if (!h)
|
|
4573
|
+
return F;
|
|
4574
|
+
const W = h === "scheduled_report" ? "report" : "briefing";
|
|
4575
|
+
return F.filter(
|
|
4576
|
+
(Ge) => pe(Ge).noun === W
|
|
4577
|
+
);
|
|
4578
|
+
}, [e, H, T, h]), mt = Y(() => T === "dashboard" ? {
|
|
4579
|
+
source: { type: "dashboard", dashboardId: e },
|
|
4580
|
+
label: Fe,
|
|
4581
|
+
detail: pi(Fe)
|
|
4582
|
+
} : {
|
|
4583
|
+
source: { type: "project" },
|
|
4584
|
+
label: "This project",
|
|
4585
|
+
detail: "Use any data in this project."
|
|
4586
|
+
}, [e, Fe, T]), Oe = !!($ && K), Me = qr({
|
|
4587
|
+
canCreate: y.canCreate,
|
|
4588
|
+
analyticalBriefingsEnabled: y.analyticalBriefingsEnabled,
|
|
4589
|
+
scheduledReportAvailable: T === "dashboard"
|
|
4590
|
+
}), ce = ie(async () => {
|
|
4591
|
+
if (!(!$ || !K)) {
|
|
4592
|
+
Z(!0), he(null);
|
|
4593
|
+
try {
|
|
4594
|
+
B(
|
|
4595
|
+
await gi({
|
|
4596
|
+
apiClient: le,
|
|
4597
|
+
apiServiceUrl: $,
|
|
4598
|
+
token: K
|
|
4599
|
+
})
|
|
4600
|
+
);
|
|
4601
|
+
} catch (F) {
|
|
4602
|
+
he(
|
|
4603
|
+
F instanceof Error ? F.message : "Could not load briefings."
|
|
4604
|
+
);
|
|
4605
|
+
} finally {
|
|
4606
|
+
Z(!1);
|
|
4607
|
+
}
|
|
4608
|
+
}
|
|
4609
|
+
}, [le, $, K]);
|
|
4610
|
+
Ie(() => {
|
|
4611
|
+
!P || _ !== "list" || !Oe || ce();
|
|
4612
|
+
}, [Oe, _, ce, P]);
|
|
4613
|
+
const ze = () => {
|
|
4614
|
+
X(null), I("dashboard"), b("list"), D(!0);
|
|
4615
|
+
}, C = (F) => {
|
|
4616
|
+
X(null), v(F), b("author");
|
|
4617
|
+
}, q = async (F) => {
|
|
4618
|
+
if (!(!$ || !K)) {
|
|
4619
|
+
E(F), he(null);
|
|
4620
|
+
try {
|
|
4621
|
+
const W = await le.getBriefing(
|
|
4622
|
+
$,
|
|
4623
|
+
K,
|
|
4624
|
+
F
|
|
4625
|
+
);
|
|
4626
|
+
X(W.briefing), b("author");
|
|
4627
|
+
} catch (W) {
|
|
4628
|
+
he(
|
|
4629
|
+
W instanceof Error ? W.message : "Could not open briefing."
|
|
4630
|
+
);
|
|
4631
|
+
} finally {
|
|
4632
|
+
E(null);
|
|
4633
|
+
}
|
|
4634
|
+
}
|
|
4635
|
+
}, ee = async (F) => {
|
|
4636
|
+
if (!(!$ || !K)) {
|
|
4637
|
+
j(F.id);
|
|
4638
|
+
try {
|
|
4639
|
+
const W = await le.runBriefingNow(
|
|
4640
|
+
$,
|
|
4641
|
+
K,
|
|
4642
|
+
F.id,
|
|
4643
|
+
{ requestId: vi() }
|
|
4644
|
+
);
|
|
4645
|
+
R.track({ kind: "briefing", id: W.run.id, title: F.name, briefingId: F.id }), ce();
|
|
4646
|
+
} catch (W) {
|
|
4647
|
+
M.error(
|
|
4648
|
+
W instanceof Error ? W.message : "Could not start the run."
|
|
4649
|
+
);
|
|
4650
|
+
} finally {
|
|
4651
|
+
j(null);
|
|
4652
|
+
}
|
|
4653
|
+
}
|
|
4654
|
+
}, me = async (F) => {
|
|
4655
|
+
if (!$ || !K) return;
|
|
4656
|
+
const { noun: W } = pe(F), Ge = W === "report" ? "Report" : "Briefing";
|
|
4657
|
+
j(F.id);
|
|
4658
|
+
try {
|
|
4659
|
+
const Ye = F.status === "PAUSED" ? await le.resumeBriefing(
|
|
4660
|
+
$,
|
|
4661
|
+
K,
|
|
4662
|
+
F.id
|
|
4663
|
+
) : await le.pauseBriefing(
|
|
4664
|
+
$,
|
|
4665
|
+
K,
|
|
4666
|
+
F.id
|
|
4667
|
+
);
|
|
4668
|
+
M.success(
|
|
4669
|
+
Ye.briefing.status === "PAUSED" ? `${Ge} paused` : `${Ge} resumed`
|
|
4670
|
+
), ce();
|
|
4671
|
+
} catch (Ye) {
|
|
4672
|
+
M.error(
|
|
4673
|
+
Ye instanceof Error ? Ye.message : `Could not update the ${W} status.`
|
|
4674
|
+
);
|
|
4675
|
+
} finally {
|
|
4676
|
+
j(null);
|
|
4677
|
+
}
|
|
4678
|
+
}, Ne = async () => {
|
|
4679
|
+
if (!z || !$ || !K) return;
|
|
4680
|
+
const F = z;
|
|
4681
|
+
j(F.id);
|
|
4682
|
+
try {
|
|
4683
|
+
await le.deleteBriefing(
|
|
4684
|
+
$,
|
|
4685
|
+
K,
|
|
4686
|
+
F.id
|
|
4687
|
+
);
|
|
4688
|
+
const { noun: W } = pe(F);
|
|
4689
|
+
M.success(`${W === "report" ? "Report" : "Briefing"} deleted`), ne(null), ce();
|
|
4690
|
+
} catch (W) {
|
|
4691
|
+
M.error(
|
|
4692
|
+
W instanceof Error ? W.message : "Could not delete the briefing."
|
|
4693
|
+
);
|
|
4694
|
+
} finally {
|
|
4695
|
+
j(null);
|
|
4696
|
+
}
|
|
4697
|
+
}, Pa = He.length;
|
|
4698
|
+
return y.surfaceVisible ? /* @__PURE__ */ s(Qn, { open: P, onOpenChange: D, children: [
|
|
4699
|
+
d ? null : /* @__PURE__ */ t(
|
|
4700
|
+
ti,
|
|
4701
|
+
{
|
|
4702
|
+
disabled: i || !Oe,
|
|
4703
|
+
briefingCount: Pa,
|
|
4704
|
+
className: o,
|
|
4705
|
+
onClick: ze
|
|
4706
|
+
}
|
|
4707
|
+
),
|
|
4708
|
+
/* @__PURE__ */ s(
|
|
4709
|
+
Kn,
|
|
4710
|
+
{
|
|
4711
|
+
ref: ye,
|
|
4712
|
+
side: "right",
|
|
4713
|
+
hideClose: !0,
|
|
4714
|
+
className: "flex h-full w-full flex-col overflow-hidden p-0 outline-none sm:max-w-[560px]",
|
|
4715
|
+
onOpenAutoFocus: (F) => {
|
|
4716
|
+
var W;
|
|
4717
|
+
F.preventDefault(), (W = ye.current) == null || W.focus({ preventScroll: !0 });
|
|
4718
|
+
},
|
|
4719
|
+
children: [
|
|
4720
|
+
/* @__PURE__ */ s(Hn, { className: "sr-only", children: [
|
|
4721
|
+
/* @__PURE__ */ t(Gn, { children: "Reports & briefings" }),
|
|
4722
|
+
/* @__PURE__ */ t(Yn, { children: "Manage reports and briefings for this dashboard." })
|
|
4723
|
+
] }),
|
|
4724
|
+
h ? /* @__PURE__ */ s("div", { className: "flex shrink-0 items-start justify-between gap-3 border-b border-border pl-4 pr-3 pt-2", children: [
|
|
4725
|
+
/* @__PURE__ */ s(
|
|
4726
|
+
"div",
|
|
4727
|
+
{
|
|
4728
|
+
className: "flex items-center gap-5",
|
|
4729
|
+
role: "tablist",
|
|
4730
|
+
"aria-label": h === "scheduled_report" ? "Email report workflow" : "Analytical briefing workflow",
|
|
4731
|
+
children: [
|
|
4732
|
+
/* @__PURE__ */ t(
|
|
4733
|
+
"button",
|
|
4734
|
+
{
|
|
4735
|
+
type: "button",
|
|
4736
|
+
role: "tab",
|
|
4737
|
+
"aria-selected": _ === "author",
|
|
4738
|
+
disabled: !N,
|
|
4739
|
+
className: J(
|
|
4740
|
+
"-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",
|
|
4741
|
+
_ === "author" ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground",
|
|
4742
|
+
!N && "cursor-not-allowed opacity-50"
|
|
4743
|
+
),
|
|
4744
|
+
onClick: () => {
|
|
4745
|
+
N && (X(null), v(h), I("dashboard"), b("author"));
|
|
4746
|
+
},
|
|
4747
|
+
children: Q ? `Edit ${pe(Q).noun}` : h === "scheduled_report" ? "Schedule report" : "Create briefing"
|
|
4748
|
+
}
|
|
4749
|
+
),
|
|
4750
|
+
/* @__PURE__ */ t(
|
|
4751
|
+
"button",
|
|
4752
|
+
{
|
|
4753
|
+
type: "button",
|
|
4754
|
+
role: "tab",
|
|
4755
|
+
"aria-selected": _ === "list",
|
|
4756
|
+
className: J(
|
|
4757
|
+
"-mb-px border-b-2 px-0.5 pb-2 text-[12px] transition-colors",
|
|
4758
|
+
_ === "list" ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"
|
|
4759
|
+
),
|
|
4760
|
+
onClick: () => b("list"),
|
|
4761
|
+
children: h === "scheduled_report" ? "Manage reports" : "Manage briefings"
|
|
4762
|
+
}
|
|
4763
|
+
)
|
|
4764
|
+
]
|
|
4765
|
+
}
|
|
4766
|
+
),
|
|
4767
|
+
/* @__PURE__ */ t(
|
|
4768
|
+
"button",
|
|
4769
|
+
{
|
|
4770
|
+
type: "button",
|
|
4771
|
+
onClick: () => D(!1),
|
|
4772
|
+
className: "rounded-control p-1 text-muted-foreground hover:bg-muted hover:text-foreground",
|
|
4773
|
+
"aria-label": h === "scheduled_report" ? "Close email report workflow" : "Close analytical briefing workflow",
|
|
4774
|
+
children: /* @__PURE__ */ t(Qe, { className: "h-3.5 w-3.5" })
|
|
4775
|
+
}
|
|
4776
|
+
)
|
|
4777
|
+
] }) : null,
|
|
4778
|
+
_ === "list" ? /* @__PURE__ */ t(
|
|
4779
|
+
di,
|
|
4780
|
+
{
|
|
4781
|
+
briefings: He,
|
|
4782
|
+
dashboardLabel: Fe,
|
|
4783
|
+
sourceView: T,
|
|
4784
|
+
error: ue,
|
|
4785
|
+
loading: te,
|
|
4786
|
+
onSourceViewChange: I,
|
|
4787
|
+
onClose: () => D(!1),
|
|
4788
|
+
onEdit: (F) => {
|
|
4789
|
+
q(F);
|
|
4790
|
+
},
|
|
4791
|
+
onNew: C,
|
|
4792
|
+
canCreate: !h && Me.length > 0,
|
|
4793
|
+
canCreateScheduledReport: Me.includes(
|
|
4794
|
+
"scheduled_report"
|
|
4795
|
+
),
|
|
4796
|
+
analyticalBriefingsEnabled: Me.includes(
|
|
4797
|
+
"analytical_briefing"
|
|
4798
|
+
),
|
|
4799
|
+
onRunNow: (F) => {
|
|
4800
|
+
ee(F);
|
|
4801
|
+
},
|
|
4802
|
+
onTogglePause: (F) => {
|
|
4803
|
+
me(F);
|
|
4804
|
+
},
|
|
4805
|
+
onDelete: (F) => ne(F),
|
|
4806
|
+
selectingId: G,
|
|
4807
|
+
busyId: ae,
|
|
4808
|
+
manageBriefingsHref: l,
|
|
4809
|
+
contentKind: h === "scheduled_report" ? "reports" : h === "analytical_briefing" ? "briefings" : void 0,
|
|
4810
|
+
hideHeader: !!h
|
|
4811
|
+
}
|
|
4812
|
+
) : /* @__PURE__ */ t(
|
|
4813
|
+
Xn,
|
|
4814
|
+
{
|
|
4815
|
+
apiServiceUrl: $,
|
|
4816
|
+
token: K,
|
|
4817
|
+
briefing: Q,
|
|
4818
|
+
initialRunId: _e && (Q == null ? void 0 : Q.id) === _e.briefingId ? _e.runId : void 0,
|
|
4819
|
+
intent: S,
|
|
4820
|
+
sourceContext: Q ? void 0 : mt,
|
|
4821
|
+
title: Q ? `Edit ${pe(Q).noun}` : S === "scheduled_report" ? "Schedule report" : "Create analytical briefing",
|
|
4822
|
+
hideHeader: !!h,
|
|
4823
|
+
className: "h-full min-h-0 max-w-none border-0 shadow-none",
|
|
4824
|
+
onBack: h ? void 0 : () => b("list"),
|
|
4825
|
+
onCancel: () => D(!1),
|
|
4826
|
+
onDeleted: () => {
|
|
4827
|
+
const F = Q ? pe(Q).noun : "briefing";
|
|
4828
|
+
M.success(`${F === "report" ? "Report" : "Briefing"} deleted`), X(null), b("list"), ce();
|
|
4829
|
+
},
|
|
4830
|
+
onRunStarted: () => {
|
|
4831
|
+
},
|
|
4832
|
+
onSaved: (F) => {
|
|
4833
|
+
X(F), ce();
|
|
4834
|
+
},
|
|
4835
|
+
onMinimizeRun: () => {
|
|
4836
|
+
D(!1);
|
|
4837
|
+
}
|
|
4838
|
+
}
|
|
4839
|
+
)
|
|
4840
|
+
]
|
|
4841
|
+
}
|
|
4842
|
+
),
|
|
4843
|
+
/* @__PURE__ */ t(
|
|
4844
|
+
wt,
|
|
4845
|
+
{
|
|
4846
|
+
open: !!z,
|
|
4847
|
+
onOpenChange: (F) => {
|
|
4848
|
+
F || ne(null);
|
|
4849
|
+
},
|
|
4850
|
+
children: /* @__PURE__ */ s(St, { children: [
|
|
4851
|
+
/* @__PURE__ */ s(kt, { children: [
|
|
4852
|
+
/* @__PURE__ */ s(Dt, { children: [
|
|
4853
|
+
"Delete",
|
|
4854
|
+
" ",
|
|
4855
|
+
z ? pe(z).noun : "briefing",
|
|
4856
|
+
"?"
|
|
4857
|
+
] }),
|
|
4858
|
+
/* @__PURE__ */ s(At, { children: [
|
|
4859
|
+
"This permanently deletes ",
|
|
4860
|
+
/* @__PURE__ */ t("strong", { children: z == null ? void 0 : z.name }),
|
|
4861
|
+
". Recipients will stop receiving it."
|
|
4862
|
+
] })
|
|
4863
|
+
] }),
|
|
4864
|
+
/* @__PURE__ */ s(Ft, { children: [
|
|
4865
|
+
/* @__PURE__ */ t(It, { children: "Cancel" }),
|
|
4866
|
+
/* @__PURE__ */ s(
|
|
4867
|
+
ha,
|
|
4868
|
+
{
|
|
4869
|
+
className: "bg-destructive/90 hover:bg-destructive",
|
|
4870
|
+
onClick: Ne,
|
|
4871
|
+
children: [
|
|
4872
|
+
"Delete",
|
|
4873
|
+
" ",
|
|
4874
|
+
z ? pe(z).noun : "briefing"
|
|
4875
|
+
]
|
|
4876
|
+
}
|
|
4877
|
+
)
|
|
4878
|
+
] })
|
|
4879
|
+
] })
|
|
4880
|
+
}
|
|
4881
|
+
)
|
|
4882
|
+
] }) : null;
|
|
4883
|
+
}
|
|
4884
|
+
function vi() {
|
|
4885
|
+
return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `briefing-run-now-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
4886
|
+
}
|
|
4887
|
+
export {
|
|
4888
|
+
Hi as A,
|
|
4889
|
+
Xi as D,
|
|
4890
|
+
Yi as S,
|
|
4891
|
+
Zi as T,
|
|
4892
|
+
to as U,
|
|
4893
|
+
Wi as V,
|
|
4894
|
+
ti as W,
|
|
4895
|
+
Ki as a,
|
|
4896
|
+
Gi as b,
|
|
4897
|
+
Ji as c,
|
|
4898
|
+
eo as d,
|
|
4899
|
+
no as e,
|
|
4900
|
+
gs as f,
|
|
4901
|
+
xs as g,
|
|
4902
|
+
ws as h,
|
|
4903
|
+
ao as i,
|
|
4904
|
+
ro as j,
|
|
4905
|
+
io as k,
|
|
4906
|
+
so as l,
|
|
4907
|
+
oo as m,
|
|
4908
|
+
lo as n,
|
|
4909
|
+
Qi as u
|
|
4910
|
+
};
|