react-semaphor 0.0.625 → 0.0.626
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{dashboard-plus-6SE6le74.js → dashboard-plus-DRy8xZTM.js} +1 -1
- package/dist/chunks/{dashboard-plus-BDC1AN44.js → dashboard-plus-ST0SJPKL.js} +1 -1
- package/dist/chunks/{index-C-47Q92V.js → index-BROU-OfV.js} +89 -93
- package/dist/chunks/{index-C7M8FtkG.js → index-BgTQ-g-l.js} +2 -2
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +3 -3
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as a, jsx as e, Fragment as te } from "react/jsx-runtime";
|
|
2
|
-
import { L as re, M as zr, u as se, N as ua, O as ma, P as _, Q as ha, R as Je, T as hs, I as wt, V as tt, W as yt, X as Pr, Y as Fe, Z as vt, _ as Nt, $ as bt, a0 as Ft, a1 as B, a2 as Ee, a3 as Qt, a4 as ve, a5 as Lr, a6 as xa, a7 as Ti, a8 as ir, a9 as ps, aa as G, ab as fs, ac as Mi, ad as _r, ae as Vr, af as ca, ag as Me, j as or, ah as Ai, ai as ct, aj as dt, ak as cr, al as St, am as kt, an as Dt, ao as Te, ap as de, aq as gt, ar as wn, as as ya, at as Br, au as Ii, av as Ei, aw as Oi, ax as at, ay as gs, az as Ri, aA as Sn, aB as _t, aC as Kt, aD as Ct, aE as rt, aF as jr, aG as Ve, aH as Ur, aI as kn, aJ as Da, aK as Re, aL as De, aM as nt, aN as Ta, aO as Tt, aP as Ma, aQ as Fi, aR as aa, aS as He, aT as Be, aU as je, aV as Ka, aW as Ge, aX as st, aY as Mt, aZ as Ja, a_ as Ha, a$ as zi, b0 as pa, b1 as xs, b2 as ys, b3 as vs, b4 as Ns, b5 as Dn, b6 as Pi, b7 as Ze, b8 as Li, b9 as Aa, ba as Qa, bb as Yr, bc as bs, bd as Tn, be as Cs, bf as _i, bg as $r, bh as he, bi as pe, bj as fe, bk as ge, bl as X, bm as ws, bn as Vi, bo as Bi, bp as Vt, bq as Za, br as qr, K as ie, bs as ji, bt as xt, J as A, bu as Ui, bv as Gr, bw as Wr, bx as Kr, by as Jr, bz as Hr, bA as Qr, bB as Zr, bC as Xr, bD as el, bE as Yi, bF as Ia, bG as Ut, bH as Ss, bI as $i, bJ as ks, bK as Mn, bL as qi, bM as Gi, bN as Wi, i as Ki, bO as tl, bP as _a, bQ as At, bR as Xa, bS as en, bT as tn, bU as an, bV as sa, bW as Ea, bX as fa, bY as va, bZ as Na, b_ as zt, b$ as nn, A as It, c0 as al, r as nl, q as sl, l as pt, c1 as Le, c2 as Ji, c3 as Zt, c4 as Jt, c5 as rl, c6 as Hi, k as ll, c7 as Va, c8 as Yt, c9 as Qi, n as Ht, m as Et, o as Ot, ca as Zn, cb as Ds, cc as An, cd as In, ce as Xt, x as dr, cf as _e, cg as En, ch as gn, ci as Ba, cj as Xn, ck as il, cl as ol, cm as Ts, cn as Zi, co as Xi, cp as cl, cq as eo, cr as On, cs as to, ct as ba, cu as ao, cv as no, cw as es, cx as $t, cy as $e, cz as qt, cA as so, cB as ro, cC as dl, cD as lo, cE as Ms, cF as io, cG as As, cH as Is, cI as oo, cJ as ul, cK as ml, cL as co, cM as uo, cN as ja, cO as mo, cP as Es, cQ as ho, cR as po, cS as ur, cT as fo, E as sn, b as Os, cU as Rs, cV as go, cW as xo, cX as yo, cY as vo, cZ as No, c_ as hl, c$ as Fs, d0 as pl, d1 as fl, d2 as gl, d3 as xl, d4 as yl, d5 as zs, d6 as Ps, d7 as vl, d8 as Nl, d9 as bl, da as Ls, db as Rn, dc as Fn, dd as bo, de as Co, df as wo, dg as So, dh as ko, di as Do, dj as To, dk as Xe, dl as et, dm as be, dn as Ce, dp as we, dq as Gt, dr as Mo, ds as Ao, dt as Io, du as Eo, dv as Oo, y as Ro, dw as mr, dx as Cl, dy as Fo, dz as zo, dA as Qe, dB as un, dC as hr, dD as Po, dE as pr, dF as fr, dG as Lo, dH as _o, dI as Vo, dJ as Bo, dK as _s, dL as Vs, dM as Bs, dN as Oa, dO as js, dP as ea, dQ as jo, dR as zn, dS as wl, dT as Bn, dU as Uo, dV as Yo, dW as gr, dX as $o, dY as qo, dZ as Go, d_ as Wo, d$ as Ko, w as xr, e0 as yr, e1 as Jo, e2 as Ho, e3 as ts, e4 as Qo, e5 as Zo, e6 as Xo, e7 as ec, e8 as tc, e9 as ac, ea as nc, eb as sc, ec as rc, ed as lc, ee as ic, ef as oc, eg as cc, eh as dc, ei as uc, ej as mc, ek as hc, el as Us, em as jn, en as pc, eo as fc, ep as as, eq as gc, er as xn, es as yn, et as Ra, eu as xc, ev as vr, ew as ns, ex as Sl, ey as Ys, ez as kl, eA as Un, eB as $s, eC as yc, eD as qs, eE as vc, eF as Nc, eG as Ua, eH as bc, eI as ss, eJ as Cc, eK as wc, eL as Sc, eM as rs, eN as ls, eO as vn, eP as kc, eQ as Ca, eR as Ya, eS as Dc, eT as Tc, eU as Mc, eV as Ac, eW as Ic, eX as Ec, eY as Oc, F as Dl, eZ as Rc, p as Fc, e_ as zc, B as Pc, e$ as Lc, f0 as _c, S as Vc, f1 as Bc, U as jc, f2 as Uc, C as Yc } from "./index-
|
|
2
|
+
import { L as re, M as zr, u as se, N as ua, O as ma, P as _, Q as ha, R as Je, T as hs, I as wt, V as tt, W as yt, X as Pr, Y as Fe, Z as vt, _ as Nt, $ as bt, a0 as Ft, a1 as B, a2 as Ee, a3 as Qt, a4 as ve, a5 as Lr, a6 as xa, a7 as Ti, a8 as ir, a9 as ps, aa as G, ab as fs, ac as Mi, ad as _r, ae as Vr, af as ca, ag as Me, j as or, ah as Ai, ai as ct, aj as dt, ak as cr, al as St, am as kt, an as Dt, ao as Te, ap as de, aq as gt, ar as wn, as as ya, at as Br, au as Ii, av as Ei, aw as Oi, ax as at, ay as gs, az as Ri, aA as Sn, aB as _t, aC as Kt, aD as Ct, aE as rt, aF as jr, aG as Ve, aH as Ur, aI as kn, aJ as Da, aK as Re, aL as De, aM as nt, aN as Ta, aO as Tt, aP as Ma, aQ as Fi, aR as aa, aS as He, aT as Be, aU as je, aV as Ka, aW as Ge, aX as st, aY as Mt, aZ as Ja, a_ as Ha, a$ as zi, b0 as pa, b1 as xs, b2 as ys, b3 as vs, b4 as Ns, b5 as Dn, b6 as Pi, b7 as Ze, b8 as Li, b9 as Aa, ba as Qa, bb as Yr, bc as bs, bd as Tn, be as Cs, bf as _i, bg as $r, bh as he, bi as pe, bj as fe, bk as ge, bl as X, bm as ws, bn as Vi, bo as Bi, bp as Vt, bq as Za, br as qr, K as ie, bs as ji, bt as xt, J as A, bu as Ui, bv as Gr, bw as Wr, bx as Kr, by as Jr, bz as Hr, bA as Qr, bB as Zr, bC as Xr, bD as el, bE as Yi, bF as Ia, bG as Ut, bH as Ss, bI as $i, bJ as ks, bK as Mn, bL as qi, bM as Gi, bN as Wi, i as Ki, bO as tl, bP as _a, bQ as At, bR as Xa, bS as en, bT as tn, bU as an, bV as sa, bW as Ea, bX as fa, bY as va, bZ as Na, b_ as zt, b$ as nn, A as It, c0 as al, r as nl, q as sl, l as pt, c1 as Le, c2 as Ji, c3 as Zt, c4 as Jt, c5 as rl, c6 as Hi, k as ll, c7 as Va, c8 as Yt, c9 as Qi, n as Ht, m as Et, o as Ot, ca as Zn, cb as Ds, cc as An, cd as In, ce as Xt, x as dr, cf as _e, cg as En, ch as gn, ci as Ba, cj as Xn, ck as il, cl as ol, cm as Ts, cn as Zi, co as Xi, cp as cl, cq as eo, cr as On, cs as to, ct as ba, cu as ao, cv as no, cw as es, cx as $t, cy as $e, cz as qt, cA as so, cB as ro, cC as dl, cD as lo, cE as Ms, cF as io, cG as As, cH as Is, cI as oo, cJ as ul, cK as ml, cL as co, cM as uo, cN as ja, cO as mo, cP as Es, cQ as ho, cR as po, cS as ur, cT as fo, E as sn, b as Os, cU as Rs, cV as go, cW as xo, cX as yo, cY as vo, cZ as No, c_ as hl, c$ as Fs, d0 as pl, d1 as fl, d2 as gl, d3 as xl, d4 as yl, d5 as zs, d6 as Ps, d7 as vl, d8 as Nl, d9 as bl, da as Ls, db as Rn, dc as Fn, dd as bo, de as Co, df as wo, dg as So, dh as ko, di as Do, dj as To, dk as Xe, dl as et, dm as be, dn as Ce, dp as we, dq as Gt, dr as Mo, ds as Ao, dt as Io, du as Eo, dv as Oo, y as Ro, dw as mr, dx as Cl, dy as Fo, dz as zo, dA as Qe, dB as un, dC as hr, dD as Po, dE as pr, dF as fr, dG as Lo, dH as _o, dI as Vo, dJ as Bo, dK as _s, dL as Vs, dM as Bs, dN as Oa, dO as js, dP as ea, dQ as jo, dR as zn, dS as wl, dT as Bn, dU as Uo, dV as Yo, dW as gr, dX as $o, dY as qo, dZ as Go, d_ as Wo, d$ as Ko, w as xr, e0 as yr, e1 as Jo, e2 as Ho, e3 as ts, e4 as Qo, e5 as Zo, e6 as Xo, e7 as ec, e8 as tc, e9 as ac, ea as nc, eb as sc, ec as rc, ed as lc, ee as ic, ef as oc, eg as cc, eh as dc, ei as uc, ej as mc, ek as hc, el as Us, em as jn, en as pc, eo as fc, ep as as, eq as gc, er as xn, es as yn, et as Ra, eu as xc, ev as vr, ew as ns, ex as Sl, ey as Ys, ez as kl, eA as Un, eB as $s, eC as yc, eD as qs, eE as vc, eF as Nc, eG as Ua, eH as bc, eI as ss, eJ as Cc, eK as wc, eL as Sc, eM as rs, eN as ls, eO as vn, eP as kc, eQ as Ca, eR as Ya, eS as Dc, eT as Tc, eU as Mc, eV as Ac, eW as Ic, eX as Ec, eY as Oc, F as Dl, eZ as Rc, p as Fc, e_ as zc, B as Pc, e$ as Lc, f0 as _c, S as Vc, f1 as Bc, U as jc, f2 as Uc, C as Yc } from "./index-BROU-OfV.js";
|
|
3
3
|
import * as na from "react";
|
|
4
4
|
import it, { useState as V, useEffect as Ae, useRef as Pt, useMemo as qe, useCallback as Se, Suspense as Tl, useContext as $c } from "react";
|
|
5
5
|
import "react-dom";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),s=require("./index-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),s=require("./index-BgTQ-g-l.js"),I=require("react");require("react-dom");function ea(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const ke=ea(I);/**
|
|
2
2
|
* @license lucide-react v0.453.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
@@ -58989,125 +58989,123 @@ function yMe(e) {
|
|
|
58989
58989
|
dashboardId: n,
|
|
58990
58990
|
visualId: r,
|
|
58991
58991
|
frameId: o,
|
|
58992
|
-
pageSettings: i
|
|
58993
|
-
|
|
58994
|
-
|
|
58995
|
-
|
|
58996
|
-
|
|
58997
|
-
|
|
58998
|
-
|
|
58992
|
+
pageSettings: i,
|
|
58993
|
+
enabled: a = !0
|
|
58994
|
+
} = e, [s, l] = re(!1), [c, u] = re(null), [d, f] = re(null), h = oe((A) => A.authToken), m = oe((A) => {
|
|
58995
|
+
var P;
|
|
58996
|
+
return (P = A.dashboard) == null ? void 0 : P.id;
|
|
58997
|
+
}), g = oe((A) => {
|
|
58998
|
+
var P;
|
|
58999
|
+
return (P = A.dashboard) == null ? void 0 : P.title;
|
|
58999
59000
|
});
|
|
59000
|
-
oe((
|
|
59001
|
-
const
|
|
59002
|
-
data:
|
|
59003
|
-
isLoading:
|
|
59004
|
-
isError:
|
|
59005
|
-
refetch:
|
|
59001
|
+
oe((A) => A.theme);
|
|
59002
|
+
const b = oe((A) => A.filterValues), y = n || m, { currentUser: v } = Ag(), w = "https://semaphor.cloud/api/v1/schedules", {
|
|
59003
|
+
data: S = [],
|
|
59004
|
+
isLoading: _,
|
|
59005
|
+
isError: E,
|
|
59006
|
+
refetch: N
|
|
59006
59007
|
} = Wn({
|
|
59007
|
-
queryKey: ["schedules",
|
|
59008
|
-
queryFn: async () =>
|
|
59009
|
-
|
|
59010
|
-
|
|
59011
|
-
|
|
59012
|
-
|
|
59013
|
-
|
|
59014
|
-
|
|
59015
|
-
|
|
59016
|
-
|
|
59017
|
-
}), N = be(
|
|
59018
|
-
async (M) => {
|
|
59019
|
-
s(!0), c(null);
|
|
59008
|
+
queryKey: ["schedules", y, r],
|
|
59009
|
+
queryFn: async () => await yr(
|
|
59010
|
+
w,
|
|
59011
|
+
(h == null ? void 0 : h.accessToken) || "",
|
|
59012
|
+
{}
|
|
59013
|
+
),
|
|
59014
|
+
enabled: !!(h != null && h.accessToken) && a
|
|
59015
|
+
}), D = be(
|
|
59016
|
+
async (A) => {
|
|
59017
|
+
l(!0), u(null);
|
|
59020
59018
|
try {
|
|
59021
|
-
const
|
|
59022
|
-
|
|
59023
|
-
|
|
59024
|
-
|
|
59025
|
-
), { authToken:
|
|
59019
|
+
const P = Tke(
|
|
59020
|
+
A.time,
|
|
59021
|
+
A.frequency,
|
|
59022
|
+
A.weekdays
|
|
59023
|
+
), { authToken: I, ...O } = t === "DASHBOARD" ? gM() : {}, R = AE(b || []), F = {
|
|
59026
59024
|
reportType: t,
|
|
59027
|
-
recipients:
|
|
59028
|
-
subject:
|
|
59029
|
-
frequency:
|
|
59030
|
-
time:
|
|
59031
|
-
timezone:
|
|
59032
|
-
dashboardId:
|
|
59025
|
+
recipients: A.recipients,
|
|
59026
|
+
subject: A.subject || g || "Scheduled Report",
|
|
59027
|
+
frequency: A.frequency,
|
|
59028
|
+
time: A.time,
|
|
59029
|
+
timezone: A.timezone,
|
|
59030
|
+
dashboardId: y,
|
|
59033
59031
|
// Enhanced fields
|
|
59034
|
-
weekdays:
|
|
59035
|
-
skipDates:
|
|
59036
|
-
startDate:
|
|
59037
|
-
endDate:
|
|
59032
|
+
weekdays: A.weekdays,
|
|
59033
|
+
skipDates: A.skipDates,
|
|
59034
|
+
startDate: A.startDate,
|
|
59035
|
+
endDate: A.endDate,
|
|
59038
59036
|
// Report generation preferences
|
|
59039
|
-
reportParams:
|
|
59037
|
+
reportParams: A.reportParams
|
|
59040
59038
|
};
|
|
59041
|
-
t === "DASHBOARD" ? (
|
|
59042
|
-
...
|
|
59043
|
-
filterLine:
|
|
59044
|
-
}) : t === "VISUAL" && (
|
|
59039
|
+
t === "DASHBOARD" ? (F.reportParams || (F.reportParams = {}), F.dashboardParams = {
|
|
59040
|
+
...O,
|
|
59041
|
+
filterLine: R
|
|
59042
|
+
}) : t === "VISUAL" && (F.visualId = r, F.frameId = o, F.pageSettings = {
|
|
59045
59043
|
...i,
|
|
59046
|
-
filterLine:
|
|
59044
|
+
filterLine: R
|
|
59047
59045
|
});
|
|
59048
|
-
const
|
|
59049
|
-
|
|
59050
|
-
(
|
|
59051
|
-
|
|
59046
|
+
const B = await Pg(
|
|
59047
|
+
w,
|
|
59048
|
+
(h == null ? void 0 : h.accessToken) || "",
|
|
59049
|
+
F
|
|
59052
59050
|
);
|
|
59053
59051
|
return ht.success("Schedule created successfully!", {
|
|
59054
|
-
description: `Reports will be sent ${
|
|
59055
|
-
}), await
|
|
59056
|
-
} catch (
|
|
59057
|
-
console.error("Failed to create schedule:",
|
|
59058
|
-
const
|
|
59059
|
-
throw
|
|
59060
|
-
description:
|
|
59061
|
-
}),
|
|
59052
|
+
description: `Reports will be sent ${A.frequency} at ${A.time}`
|
|
59053
|
+
}), await N(), l(!1), B;
|
|
59054
|
+
} catch (P) {
|
|
59055
|
+
console.error("Failed to create schedule:", P);
|
|
59056
|
+
const I = P instanceof Error ? P.message : "Failed to create schedule";
|
|
59057
|
+
throw u(I), l(!1), ht.error("Failed to create schedule", {
|
|
59058
|
+
description: I
|
|
59059
|
+
}), P;
|
|
59062
59060
|
}
|
|
59063
59061
|
},
|
|
59064
59062
|
[
|
|
59065
59063
|
t,
|
|
59066
|
-
|
|
59064
|
+
y,
|
|
59067
59065
|
r,
|
|
59068
59066
|
o,
|
|
59069
59067
|
i,
|
|
59070
|
-
|
|
59071
|
-
|
|
59072
|
-
|
|
59073
|
-
m,
|
|
59068
|
+
h,
|
|
59069
|
+
v,
|
|
59070
|
+
w,
|
|
59074
59071
|
g,
|
|
59075
|
-
|
|
59072
|
+
b,
|
|
59073
|
+
N
|
|
59076
59074
|
]
|
|
59077
|
-
),
|
|
59078
|
-
async (
|
|
59079
|
-
|
|
59075
|
+
), M = be(
|
|
59076
|
+
async (A) => {
|
|
59077
|
+
f(A);
|
|
59080
59078
|
try {
|
|
59081
|
-
if (!(await fetch(`${
|
|
59079
|
+
if (!(await fetch(`${w}/${A}`, {
|
|
59082
59080
|
method: "DELETE",
|
|
59083
59081
|
headers: {
|
|
59084
|
-
Authorization: `Bearer ${(
|
|
59082
|
+
Authorization: `Bearer ${(h == null ? void 0 : h.accessToken) || ""}`,
|
|
59085
59083
|
"Content-Type": "application/json"
|
|
59086
59084
|
}
|
|
59087
59085
|
})).ok)
|
|
59088
59086
|
throw new Error("Failed to delete schedule");
|
|
59089
|
-
ht.success("Schedule deleted successfully"), await
|
|
59090
|
-
} catch (
|
|
59091
|
-
throw console.error("Failed to delete schedule:",
|
|
59092
|
-
description:
|
|
59093
|
-
}),
|
|
59087
|
+
ht.success("Schedule deleted successfully"), await N(), f(null);
|
|
59088
|
+
} catch (P) {
|
|
59089
|
+
throw console.error("Failed to delete schedule:", P), f(null), ht.error("Failed to delete schedule", {
|
|
59090
|
+
description: P instanceof Error ? P.message : "Please try again"
|
|
59091
|
+
}), P;
|
|
59094
59092
|
}
|
|
59095
59093
|
},
|
|
59096
|
-
[
|
|
59094
|
+
[h, N]
|
|
59097
59095
|
);
|
|
59098
59096
|
return {
|
|
59099
59097
|
// Data
|
|
59100
|
-
schedules:
|
|
59101
|
-
isLoading:
|
|
59102
|
-
isError:
|
|
59098
|
+
schedules: S,
|
|
59099
|
+
isLoading: _,
|
|
59100
|
+
isError: E,
|
|
59103
59101
|
// Actions
|
|
59104
|
-
createSchedule:
|
|
59105
|
-
deleteSchedule:
|
|
59106
|
-
refetch:
|
|
59102
|
+
createSchedule: D,
|
|
59103
|
+
deleteSchedule: M,
|
|
59104
|
+
refetch: N,
|
|
59107
59105
|
// Status
|
|
59108
|
-
isSubmitting:
|
|
59109
|
-
submitError:
|
|
59110
|
-
deletingId:
|
|
59106
|
+
isSubmitting: s,
|
|
59107
|
+
submitError: c,
|
|
59108
|
+
deletingId: d
|
|
59111
59109
|
};
|
|
59112
59110
|
}
|
|
59113
59111
|
function vMe(e, t, n, r) {
|
|
@@ -59258,12 +59256,9 @@ function GH({
|
|
|
59258
59256
|
reportTitle: s.reportTitle,
|
|
59259
59257
|
isPdfRender: !0,
|
|
59260
59258
|
filterLine: s.filterLine
|
|
59261
|
-
}
|
|
59262
|
-
|
|
59263
|
-
|
|
59264
|
-
e && (r != null && r.id) && M();
|
|
59265
|
-
}, [e, r == null ? void 0 : r.id, M]);
|
|
59266
|
-
const A = ye(
|
|
59259
|
+
},
|
|
59260
|
+
enabled: e && !!(r != null && r.id)
|
|
59261
|
+
}), A = ye(
|
|
59267
59262
|
() => ({
|
|
59268
59263
|
id: "dummy",
|
|
59269
59264
|
type: "table",
|
|
@@ -59823,11 +59818,12 @@ function GH({
|
|
|
59823
59818
|
{
|
|
59824
59819
|
style: {
|
|
59825
59820
|
// PDF renders at 1240px viewport then scales to fit actual page width
|
|
59826
|
-
// Calculate scale based on actual page dimensions
|
|
59821
|
+
// Calculate scale based on actual page dimensions and orientation
|
|
59827
59822
|
transform: `scale(${H.width / 1240 * (U ? 0.9 : 1)})`,
|
|
59828
59823
|
transformOrigin: "top left",
|
|
59829
59824
|
width: "1240px",
|
|
59830
|
-
padding: "32px",
|
|
59825
|
+
padding: U ? "16px" : "32px",
|
|
59826
|
+
// Smaller padding for tables
|
|
59831
59827
|
minHeight: `${H.height / (H.width / 1240 * (U ? 0.9 : 1))}px`
|
|
59832
59828
|
},
|
|
59833
59829
|
children: se()
|
|
@@ -781,13 +781,13 @@ You can add a description to the \`${ff}\` by passing a \`${PW}\` component as a
|
|
|
781
781
|
|
|
782
782
|
Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${ff}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
|
|
783
783
|
|
|
784
|
-
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return C.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},gRe=kW,bRe=NW,FW=MW,$W=RW,LW=AW,zW=OW,BW=DW,VW=TW;const oj=gRe,yRe=bRe,HW=C.forwardRef(({className:e,...t},n)=>d.jsx(FW,{className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));HW.displayName=FW.displayName;const Kw=C.forwardRef(({className:e,...t},n)=>d.jsx(yRe,{children:d.jsxs(Xi,{children:[d.jsx(HW,{}),d.jsx($W,{ref:n,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]})}));Kw.displayName=$W.displayName;const Xw=({className:e,...t})=>d.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});Xw.displayName="AlertDialogHeader";const Qw=({className:e,...t})=>d.jsx("div",{className:Z("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Qw.displayName="AlertDialogFooter";const Jw=C.forwardRef(({className:e,...t},n)=>d.jsx(BW,{ref:n,className:Z("text-lg font-semibold",e),...t}));Jw.displayName=BW.displayName;const e1=C.forwardRef(({className:e,...t},n)=>d.jsx(VW,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));e1.displayName=VW.displayName;const t1=C.forwardRef(({className:e,...t},n)=>d.jsx(LW,{ref:n,className:Z(km(),e),...t}));t1.displayName=LW.displayName;const n1=C.forwardRef(({className:e,...t},n)=>d.jsx(zW,{ref:n,className:Z(km({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));n1.displayName=zW.displayName;function WW({schedules:e,onDelete:t,isDeleting:n,isLoading:r=!1,onRefresh:o}){const[i,s]=E.useState(null),a=c=>{s(c)},l=()=>{i&&(t(i),s(null))};return r?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.length===0?d.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[d.jsx(Ur,{className:"mx-auto mb-3 h-12 w-12 opacity-50"}),d.jsx("p",{className:"text-sm",children:"No active schedules"}),d.jsx("p",{className:"mt-1 text-xs",children:"Create a schedule to start receiving reports"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx("h4",{className:"text-sm font-medium",children:"Active Schedules"}),d.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.length," active schedule",e.length!==1?"s":""]})]}),o&&d.jsx(le,{variant:"ghost",size:"sm",onClick:o,className:"h-8",children:d.jsx(ene,{className:"h-3 w-3"})})]}),d.jsx(Zi,{}),d.jsx(Ta,{className:"max-h-[400px]",children:d.jsx("div",{className:"space-y-3",children:e.map(c=>d.jsx(xRe,{schedule:c,onDelete:()=>a(c.id),isDeleting:n===c.id},c.id))})})]}),d.jsx(oj,{open:!!i,onOpenChange:()=>s(null),children:d.jsxs(Kw,{children:[d.jsxs(Xw,{children:[d.jsx(Jw,{children:"Delete Schedule?"}),d.jsx(e1,{children:"This will permanently delete this schedule. You will no longer receive these reports."})]}),d.jsxs(Qw,{children:[d.jsx(n1,{children:"Cancel"}),d.jsx(t1,{onClick:l,children:"Delete Schedule"})]})]})})]})}function xRe({schedule:e,onDelete:t,isDeleting:n}){var l,c;const r=e.recipients?e.recipients.split(/[,;]/).filter(Boolean):[],o=r.length,i=e.endDate&&new Date(e.endDate)<new Date,s=new Date(e.nextRun),a=s<new Date&&!i;return d.jsx("div",{className:Z("rounded-lg border bg-card p-4 transition-colors",i&&"opacity-60"),children:d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsxs("div",{className:"flex-1 space-y-3",children:[d.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[d.jsxs(ur,{variant:e.reportType==="VISUAL"?"secondary":"default",className:"mt-0.5",children:[e.reportType==="VISUAL"?d.jsx(Ui,{className:"mr-1 h-3 w-3"}):d.jsx(Xte,{className:"mr-1 h-3 w-3"}),e.reportType==="VISUAL"?"Report":"Dashboard"]}),(e.dashboardName||e.reportName)&&d.jsx(ur,{variant:"outline",className:"mt-0.5 text-xs",children:e.dashboardName||e.reportName}),((l=e.reportParams)==null?void 0:l.sheetSelection)==="all"&&d.jsxs(ur,{variant:"outline",className:"mt-0.5 text-xs",children:[d.jsx(E3,{className:"mr-1 h-3 w-3"}),"All Sheets"]})]}),d.jsx("div",{className:"flex-1",children:d.jsx("p",{className:"text-sm font-medium",children:e.subject||"Untitled"})}),d.jsxs("div",{className:"grid gap-2 text-xs",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(xu,{className:"h-3 w-3"}),d.jsxs("span",{children:[Nv(e.frequency),e.frequency==="weekly"&&e.weekdays&&d.jsxs(d.Fragment,{children:[" on ",$Me(e.weekdays)]})," at ",z_(e.time)||e.time||"Time not set",e.timezone&&e.timezone!=="UTC"&&d.jsxs(d.Fragment,{children:[" ","(",(c=e.timezone.split("/").pop())==null?void 0:c.replace(/_/g," "),")"]})]})]}),d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(aN,{className:"h-3 w-3"}),d.jsx("span",{children:o===1?r[0]:`${o} recipients`})]}),(e.startDate||e.endDate)&&d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(Ur,{className:"h-3 w-3"}),d.jsx("span",{children:zMe(e.startDate?String(e.startDate):void 0,e.endDate?String(e.endDate):void 0)})]}),e.skipDates&&e.skipDates.length>0&&d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(Tf,{className:"h-3 w-3"}),d.jsxs("span",{children:["Skipping: ",LMe(e.skipDates)]})]}),d.jsxs("div",{className:Z("flex items-center gap-1.5 font-medium",i?"text-muted-foreground line-through":a?"text-orange-500":"text-foreground"),children:[d.jsx(xu,{className:"h-3 w-3"}),d.jsx("span",{children:i?"Schedule expired":d.jsxs(d.Fragment,{children:["Next: ",Cr(s,"MMM d, yyyy")," at"," ",Cr(s,"h:mm a"),a&&" (processing)"]})})]})]})]}),d.jsx("div",{className:"flex items-center",children:n?d.jsx(Rs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):d.jsx(le,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive",children:d.jsx(Bu,{className:"h-4 w-4"})})})]})})}function UW(e){const{reportType:t,dashboardId:n,visualId:r,frameId:o,pageSettings:i}=e,[
|
|
784
|
+
For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return C.useEffect(()=>{var r;document.getElementById((r=e.current)==null?void 0:r.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},gRe=kW,bRe=NW,FW=MW,$W=RW,LW=AW,zW=OW,BW=DW,VW=TW;const oj=gRe,yRe=bRe,HW=C.forwardRef(({className:e,...t},n)=>d.jsx(FW,{className:Z("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t,ref:n}));HW.displayName=FW.displayName;const Kw=C.forwardRef(({className:e,...t},n)=>d.jsx(yRe,{children:d.jsxs(Xi,{children:[d.jsx(HW,{}),d.jsx($W,{ref:n,className:Z("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...t})]})}));Kw.displayName=$W.displayName;const Xw=({className:e,...t})=>d.jsx("div",{className:Z("flex flex-col space-y-2 text-center sm:text-left",e),...t});Xw.displayName="AlertDialogHeader";const Qw=({className:e,...t})=>d.jsx("div",{className:Z("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t});Qw.displayName="AlertDialogFooter";const Jw=C.forwardRef(({className:e,...t},n)=>d.jsx(BW,{ref:n,className:Z("text-lg font-semibold",e),...t}));Jw.displayName=BW.displayName;const e1=C.forwardRef(({className:e,...t},n)=>d.jsx(VW,{ref:n,className:Z("text-sm text-muted-foreground",e),...t}));e1.displayName=VW.displayName;const t1=C.forwardRef(({className:e,...t},n)=>d.jsx(LW,{ref:n,className:Z(km(),e),...t}));t1.displayName=LW.displayName;const n1=C.forwardRef(({className:e,...t},n)=>d.jsx(zW,{ref:n,className:Z(km({variant:"outline"}),"mt-2 sm:mt-0",e),...t}));n1.displayName=zW.displayName;function WW({schedules:e,onDelete:t,isDeleting:n,isLoading:r=!1,onRefresh:o}){const[i,s]=E.useState(null),a=c=>{s(c)},l=()=>{i&&(t(i),s(null))};return r?d.jsx("div",{className:"flex items-center justify-center py-8",children:d.jsx(Rs,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):e.length===0?d.jsxs("div",{className:"py-8 text-center text-muted-foreground",children:[d.jsx(Ur,{className:"mx-auto mb-3 h-12 w-12 opacity-50"}),d.jsx("p",{className:"text-sm",children:"No active schedules"}),d.jsx("p",{className:"mt-1 text-xs",children:"Create a schedule to start receiving reports"})]}):d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-4",children:[d.jsxs("div",{className:"flex items-center justify-between",children:[d.jsxs("div",{children:[d.jsx("h4",{className:"text-sm font-medium",children:"Active Schedules"}),d.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.length," active schedule",e.length!==1?"s":""]})]}),o&&d.jsx(le,{variant:"ghost",size:"sm",onClick:o,className:"h-8",children:d.jsx(ene,{className:"h-3 w-3"})})]}),d.jsx(Zi,{}),d.jsx(Ta,{className:"max-h-[400px]",children:d.jsx("div",{className:"space-y-3",children:e.map(c=>d.jsx(xRe,{schedule:c,onDelete:()=>a(c.id),isDeleting:n===c.id},c.id))})})]}),d.jsx(oj,{open:!!i,onOpenChange:()=>s(null),children:d.jsxs(Kw,{children:[d.jsxs(Xw,{children:[d.jsx(Jw,{children:"Delete Schedule?"}),d.jsx(e1,{children:"This will permanently delete this schedule. You will no longer receive these reports."})]}),d.jsxs(Qw,{children:[d.jsx(n1,{children:"Cancel"}),d.jsx(t1,{onClick:l,children:"Delete Schedule"})]})]})})]})}function xRe({schedule:e,onDelete:t,isDeleting:n}){var l,c;const r=e.recipients?e.recipients.split(/[,;]/).filter(Boolean):[],o=r.length,i=e.endDate&&new Date(e.endDate)<new Date,s=new Date(e.nextRun),a=s<new Date&&!i;return d.jsx("div",{className:Z("rounded-lg border bg-card p-4 transition-colors",i&&"opacity-60"),children:d.jsxs("div",{className:"flex items-start justify-between gap-3",children:[d.jsxs("div",{className:"flex-1 space-y-3",children:[d.jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[d.jsxs(ur,{variant:e.reportType==="VISUAL"?"secondary":"default",className:"mt-0.5",children:[e.reportType==="VISUAL"?d.jsx(Ui,{className:"mr-1 h-3 w-3"}):d.jsx(Xte,{className:"mr-1 h-3 w-3"}),e.reportType==="VISUAL"?"Report":"Dashboard"]}),(e.dashboardName||e.reportName)&&d.jsx(ur,{variant:"outline",className:"mt-0.5 text-xs",children:e.dashboardName||e.reportName}),((l=e.reportParams)==null?void 0:l.sheetSelection)==="all"&&d.jsxs(ur,{variant:"outline",className:"mt-0.5 text-xs",children:[d.jsx(E3,{className:"mr-1 h-3 w-3"}),"All Sheets"]})]}),d.jsx("div",{className:"flex-1",children:d.jsx("p",{className:"text-sm font-medium",children:e.subject||"Untitled"})}),d.jsxs("div",{className:"grid gap-2 text-xs",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(xu,{className:"h-3 w-3"}),d.jsxs("span",{children:[Nv(e.frequency),e.frequency==="weekly"&&e.weekdays&&d.jsxs(d.Fragment,{children:[" on ",$Me(e.weekdays)]})," at ",z_(e.time)||e.time||"Time not set",e.timezone&&e.timezone!=="UTC"&&d.jsxs(d.Fragment,{children:[" ","(",(c=e.timezone.split("/").pop())==null?void 0:c.replace(/_/g," "),")"]})]})]}),d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(aN,{className:"h-3 w-3"}),d.jsx("span",{children:o===1?r[0]:`${o} recipients`})]}),(e.startDate||e.endDate)&&d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(Ur,{className:"h-3 w-3"}),d.jsx("span",{children:zMe(e.startDate?String(e.startDate):void 0,e.endDate?String(e.endDate):void 0)})]}),e.skipDates&&e.skipDates.length>0&&d.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground",children:[d.jsx(Tf,{className:"h-3 w-3"}),d.jsxs("span",{children:["Skipping: ",LMe(e.skipDates)]})]}),d.jsxs("div",{className:Z("flex items-center gap-1.5 font-medium",i?"text-muted-foreground line-through":a?"text-orange-500":"text-foreground"),children:[d.jsx(xu,{className:"h-3 w-3"}),d.jsx("span",{children:i?"Schedule expired":d.jsxs(d.Fragment,{children:["Next: ",Cr(s,"MMM d, yyyy")," at"," ",Cr(s,"h:mm a"),a&&" (processing)"]})})]})]})]}),d.jsx("div",{className:"flex items-center",children:n?d.jsx(Rs,{className:"h-4 w-4 animate-spin text-muted-foreground"}):d.jsx(le,{variant:"ghost",size:"sm",onClick:t,className:"h-8 w-8 p-0 hover:bg-destructive/10 hover:text-destructive",children:d.jsx(Bu,{className:"h-4 w-4"})})})]})})}function UW(e){const{reportType:t,dashboardId:n,visualId:r,frameId:o,pageSettings:i,enabled:s=!0}=e,[a,l]=E.useState(!1),[c,u]=E.useState(null),[f,h]=E.useState(null),p=ne(T=>T.authToken),m=ne(T=>{var D;return(D=T.dashboard)==null?void 0:D.id}),g=ne(T=>{var D;return(D=T.dashboard)==null?void 0:D.title});ne(T=>T.theme);const b=ne(T=>T.filterValues),y=n||m,{currentUser:x}=fh(),w="https://semaphor.cloud/api/v1/schedules",{data:S=[],isLoading:k,isError:_,refetch:N}=jn({queryKey:["schedules",y,r],queryFn:async()=>await or(w,(p==null?void 0:p.accessToken)||"",{}),enabled:!!(p!=null&&p.accessToken)&&s}),R=E.useCallback(async T=>{l(!0),u(null);try{const D=OMe(T.time,T.frequency,T.weekdays),{authToken:A,...I}=t==="DASHBOARD"?$M():{},j=HE(b||[]),F={reportType:t,recipients:T.recipients,subject:T.subject||g||"Scheduled Report",frequency:T.frequency,time:T.time,timezone:T.timezone,dashboardId:y,weekdays:T.weekdays,skipDates:T.skipDates,startDate:T.startDate,endDate:T.endDate,reportParams:T.reportParams};t==="DASHBOARD"?(F.reportParams||(F.reportParams={}),F.dashboardParams={...I,filterLine:j}):t==="VISUAL"&&(F.visualId=r,F.frameId=o,F.pageSettings={...i,filterLine:j});const z=await uh(w,(p==null?void 0:p.accessToken)||"",F);return it.success("Schedule created successfully!",{description:`Reports will be sent ${T.frequency} at ${T.time}`}),await N(),l(!1),z}catch(D){console.error("Failed to create schedule:",D);const A=D instanceof Error?D.message:"Failed to create schedule";throw u(A),l(!1),it.error("Failed to create schedule",{description:A}),D}},[t,y,r,o,i,p,x,w,g,b,N]),M=E.useCallback(async T=>{h(T);try{if(!(await fetch(`${w}/${T}`,{method:"DELETE",headers:{Authorization:`Bearer ${(p==null?void 0:p.accessToken)||""}`,"Content-Type":"application/json"}})).ok)throw new Error("Failed to delete schedule");it.success("Schedule deleted successfully"),await N(),h(null)}catch(D){throw console.error("Failed to delete schedule:",D),h(null),it.error("Failed to delete schedule",{description:D instanceof Error?D.message:"Please try again"}),D}},[p,N]);return{schedules:S,isLoading:k,isError:_,createSchedule:R,deleteSchedule:M,refetch:N,isSubmitting:a,submitError:c,deletingId:f}}function vRe(e,t,n,r){if(!e||e.length===0){console.warn("No data to export");return}const o=(r==null?void 0:r.delimiter)||",",i=Object.keys(e[0]);let s=i;if(n!=null&&n.columnVisibility&&(s=i.filter(l=>{var c;return((c=n.columnVisibility)==null?void 0:c[l])!==!1})),n!=null&&n.columnSizing){const l=Object.keys(n.columnSizing),c=l.filter(f=>s.includes(f)),u=s.filter(f=>!l.includes(f));s=[...c,...u]}let a="";{const l=s.map(c=>Nl(c,o));a+=l.join(o)+`
|
|
785
785
|
`}e.forEach(l=>{const c=s.map(u=>{var h;const f=l[u];if(f==null)return"";if(r!=null&&r.useFormattedValues&&((h=n==null?void 0:n.columnSettingsMap)!=null&&h[u])){const p=n.columnSettingsMap[u];if(p.type==="number"&&typeof f=="number"){const m=new Intl.NumberFormat(p.numberFormat.locale||"en-US",{style:p.numberFormat.style,currency:p.numberFormat.currency,minimumFractionDigits:p.numberFormat.minimumFractionDigits,maximumFractionDigits:p.numberFormat.maximumFractionDigits});return Nl(m.format(f),o)}if(p.type==="date"&&(f instanceof Date||typeof f=="string")){const m=f instanceof Date?f:new Date(f);if(!isNaN(m.getTime()))return Nl(m.toLocaleDateString(),o)}}return Nl(String(f),o)});a+=c.join(o)+`
|
|
786
786
|
`}),ij(a,t)}function Nl(e,t){return e.includes(t)||e.includes('"')||e.includes(`
|
|
787
787
|
`)||e.includes("\r")?`"${e.replace(/"/g,'""')}"`:e}function ij(e,t){const n=t.endsWith(".csv")?t:`${t}.csv`,r="\uFEFF",o=new Blob([r+e],{type:"text/csv;charset=utf-8;"}),i=URL.createObjectURL(o),s=document.createElement("a");s.href=i,s.download=n,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(i)}function wRe(e,t,n,r,o){if(!e||e.length===0){console.warn("No data to export");return}const i=(o==null?void 0:o.delimiter)||",",s=[];s.length===0&&s.push(...Object.keys(e[0]));let a="";{const l=s.map(c=>Nl(c,i));a+=l.join(i)+`
|
|
788
788
|
`}e.forEach(l=>{const c=s.map(u=>{const f=l[u];return(l.isSubtotal||l.isGrandTotal)&&s.indexOf(u)===0?Nl(l.isGrandTotal?"Grand Total":`${f} Total`,i):f==null?"":Nl(String(f),i)});a+=c.join(i)+`
|
|
789
789
|
`}),ij(a,t)}function SRe(e,t,n,r,o){if(!e||e.length===0){console.warn("No data to export");return}const i=(o==null?void 0:o.delimiter)||",";let s="";e.forEach(a=>{const l=Object.values(a).map(c=>c==null?"":Nl(String(c),i));s+=l.join(i)+`
|
|
790
|
-
`}),ij(s,t)}const CRe={letter:{width:816,height:1056},a4:{width:794,height:1123},legal:{width:816,height:1344},tabloid:{width:1056,height:1632},a3:{width:1123,height:1587}};function qW({isOpen:e,onClose:t,frame:n,card:r,data:o}){const{currentUser:i}=fh(),s=ne(oe=>oe.filterValues),[a,l]=E.useState({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1}),[c,u]=E.useState({recipients:(i==null?void 0:i.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),[f,h]=E.useState("download"),[p,m]=E.useState("pdf"),[g,b]=E.useState(!1),[y,x]=E.useState(!1),{schedules:v,isLoading:w,createSchedule:S,deleteSchedule:k,isSubmitting:_,submitError:N,deletingId:R,refetch:M}=UW({reportType:"VISUAL",visualId:r==null?void 0:r.id,frameId:n.id,pageSettings:{pageSize:a.pageSize,orientation:a.orientation,reportTitle:a.reportTitle,isPdfRender:!0,filterLine:a.filterLine}});E.useEffect(()=>{e&&(r!=null&&r.id)&&M()},[e,r==null?void 0:r.id,M]);const T=E.useMemo(()=>({id:"dummy",type:"table",title:"",frameId:"",config:{},queryConfig:{}}),[]),{data:D,isLoading:A,isFetching:I,pagination:j}=Yw(r||T),F=r?D:null,z=r?A:!1,V=r?I:!1,$=E.useMemo(()=>{const oe=o||F;return oe?oe.records&&oe.records.length>100?{...oe,records:oe.records.slice(0,100)}:oe:null},[o,F]),O=sb(r,$);E.useEffect(()=>{if(e&&!y){const oe=ne.getState().filterValues,me=HE(oe||[]);l({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1,filterLine:me}),u({recipients:(i==null?void 0:i.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),x(!0),h("download")}!e&&y&&x(!1)},[e,y,r==null?void 0:r.title,i==null?void 0:i.email]);const W=E.useRef(null),[B,P]=E.useState({width:0,height:0}),H=E.useMemo(()=>{const oe=CRe[a.pageSize];let me=oe.width,Ne=oe.height;return a.orientation==="landscape"&&([me,Ne]=[Ne,me]),{width:me,height:Ne}},[a.pageSize,a.orientation]),U=E.useMemo(()=>(r==null?void 0:r.type)&&["table","aggregateTable","pivotTable"].includes(r.type),[r==null?void 0:r.type]),X=E.useMemo(()=>{if(B.width===0||B.height===0)return .5;const oe=40,me=B.width-oe,Ne=B.height-oe,ye=me/H.width,ke=Ne/H.height;return Math.min(ye,ke,.9)},[B,H]);E.useEffect(()=>{const oe=()=>{if(W.current){const ye=W.current.getBoundingClientRect();P({width:ye.width,height:ye.height})}},me=setTimeout(oe,50);window.addEventListener("resize",oe);const Ne=new ResizeObserver(oe);return W.current&&Ne.observe(W.current),()=>{clearTimeout(me),window.removeEventListener("resize",oe),Ne.disconnect()}},[e]);const G=async()=>{var oe;if(!r||!$){it.error("No data to export");return}b(!0);try{if(p==="csv"){const me=a.reportTitle||r.title||"Report",Ne=(oe=r.preferences)==null?void 0:oe.tablePrefs;r.type==="aggregateTable"?wRe($.records||[],me,void 0,void 0,{includeHeaders:!0,includeSubtotals:!0,includeGrandTotal:!0}):r.type==="pivotTable"?SRe($.records||[],me,void 0,void 0,{includeHeaders:!0}):vRe($.records||[],me,Ne,{includeHeaders:!0}),it.success("CSV downloaded successfully"),t()}else await N9(r.id,n.id,a.reportTitle||r.title||"Report",r.type,a.password||void 0,a.pageSize,a.orientation,HE(s||[])),it.success("PDF downloaded successfully"),t()}catch(me){it.error(`Failed to generate ${p.toUpperCase()}`,{description:me instanceof Error?me.message:"Please try again"})}finally{b(!1)}},L=async()=>{if(!r||!$){it.error("No data to send");return}if(!c.recipients){it.error("Please enter recipient email addresses");return}const oe=c.recipients.split(/[,;]/).map(ke=>ke.trim()).filter(ke=>ke),me=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ne=oe.filter(ke=>!me.test(ke));if(Ne.length>0){it.error(`Invalid email addresses: ${Ne.join(", ")}`);return}b(!0);const ye=it.loading("Sending email...");try{await new Promise(lt=>setTimeout(lt,2e3)),it.dismiss(ye);const ke=oe.length,Le=ke===1?oe[0]:`${ke} recipients`;it.success(`✅ Email has been sent to ${Le}`,{duration:4e3})}catch(ke){it.error("Failed to send email",{description:ke instanceof Error?ke.message:"Please try again or contact support.",richColors:!0,duration:5e3}),console.error("Email send error:",ke)}},q=async oe=>{var me;if(!r){it.error("No visual selected");return}b(!0);try{const Ne={format:p};if(p==="pdf"&&(Ne.pdfOptions={pageSize:a.pageSize,orientation:a.orientation,includeFilters:!0,includeTimestamp:!0}),p==="csv"&&(Ne.csvOptions={delimiter:",",includeHeaders:!0,useFormattedValues:!0}),r.type==="table"||r.type==="aggregateTable"||r.type==="pivotTable"){const ye=(me=r.preferences)==null?void 0:me.tablePrefs;ye&&(Ne.tablePreferences=ye)}await S({...oe,reportParams:Ne}),t()}catch(Ne){console.error("Schedule creation error:",Ne)}finally{b(!1)}},Q=async oe=>{try{await k(oe)}catch(me){console.error("Failed to delete schedule:",me)}},ee=async()=>{switch(f){case"download":await G();break;case"email":await L();break}},K=E.useMemo(()=>({mode:"table-print"}),[]),ae=E.useMemo(()=>({displayPreferences:{...K,mode:"table-print"},shouldShowElement:()=>!1}),[K]),ie=()=>!r||!$?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No data to preview"}):z||V?d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx(Ol,{size:"md",color:"muted","aria-label":"Loading preview"})}):d.jsx(eM.Provider,{value:ae,children:d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("h1",{className:"text-xl font-bold",children:a.reportTitle}),a.filterLine&&d.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Filters: ",a.filterLine]})]}),d.jsx("div",{className:"flex-1",children:r.type==="table"?d.jsx(Hf,{card:r,data:$.records||[],paginationMetadata:j||void 0,onPaginationChange:()=>{},isLoading:!1}):r.type==="aggregateTable"?d.jsx(Iw,{card:r,data:$.records||[],groupByColumns:$.groupByColumns,pivotSchema:$.pivotSchema,paginationMetadata:j||void 0,onPaginationChange:()=>{},onAggregationChange:()=>{},isLoading:!1}):r.type==="pivotTable"&&O?d.jsx(ab,{card:r,data:O.data,options:{...O.options,pagination:{enabled:!1,pageSize:100}},onAggregationChange:()=>{},onAggregationLabelChange:()=>{}}):r.type==="pivotTable"&&!O?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No pivot table data to preview"}):d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Preview not available for this card type"})})]})});return d.jsx(Xl,{open:e,onOpenChange:t,children:d.jsxs(La,{className:"flex h-[90vh] w-[90vw] max-w-[1400px] flex-col gap-0 p-0",children:[d.jsxs(za,{className:"shrink-0 border-b px-6 py-4",children:[d.jsxs(Ba,{children:["PDF Preview - ",a.reportTitle]}),d.jsx(Va,{children:"Preview how your table will appear in the PDF and adjust settings before exporting"})]}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("div",{className:"flex w-[450px] shrink-0 flex-col border-r bg-muted/10",children:[d.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"report-title",children:"Report Title"}),d.jsx(yr,{id:"report-title",value:a.reportTitle,onChange:oe=>l({...a,reportTitle:oe.target.value}),placeholder:"Enter report title"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{children:"Action"}),d.jsxs(Li,{value:f,onValueChange:oe=>{h(oe),oe==="schedule"&&p==="csv"&&m("pdf")},className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"download",id:"download"}),d.jsx(ue,{htmlFor:"download",className:"flex cursor-pointer items-center",children:"Download"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"schedule",id:"schedule"}),d.jsx(ue,{htmlFor:"schedule",className:"flex cursor-pointer items-center",children:"Schedule"})]})]})]}),f==="download"&&((r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable"||(r==null?void 0:r.type)==="pivotTable")&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{children:"Export Format"}),d.jsxs(Li,{value:p,onValueChange:oe=>m(oe),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"pdf",id:"format-pdf"}),d.jsx(ue,{htmlFor:"format-pdf",className:"flex cursor-pointer items-center",children:"PDF"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"csv",id:"format-csv"}),d.jsx(ue,{htmlFor:"format-csv",className:"flex cursor-pointer items-center",children:"CSV"})]})]}),p==="csv"&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"CSV export preserves your column visibility and ordering"})]}),p==="pdf"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"page-size",children:"Page Size"}),d.jsxs(hn,{value:a.pageSize,onValueChange:oe=>l({...a,pageSize:oe}),children:[d.jsx(an,{id:"page-size",children:d.jsx(vn,{})}),d.jsxs(ln,{children:[d.jsx(Me,{value:"letter",children:'Letter (8.5" x 11")'}),d.jsx(Me,{value:"a4",children:"A4 (210mm x 297mm)"}),d.jsx(Me,{value:"legal",children:'Legal (8.5" x 14")'}),d.jsx(Me,{value:"tabloid",children:'Tabloid (11" x 17")'}),d.jsx(Me,{value:"a3",children:"A3 (297mm x 420mm)"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{children:"Orientation"}),d.jsxs(Li,{value:a.orientation,onValueChange:oe=>l({...a,orientation:oe}),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"portrait",id:"portrait"}),d.jsxs(ue,{htmlFor:"portrait",className:"flex cursor-pointer items-center",children:[d.jsx(Ui,{className:"mr-2 h-4 w-4"}),"Portrait"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"landscape",id:"landscape"}),d.jsxs(ue,{htmlFor:"landscape",className:"flex cursor-pointer items-center",children:[d.jsx(Ui,{className:"mr-2 h-4 w-4 rotate-90"}),"Landscape"]})]})]})]})]}),f==="download"&&p==="pdf"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"password",children:"Password Protection (Optional)"}),d.jsxs("div",{className:"relative",children:[d.jsx(yr,{id:"password",type:a.showPassword?"text":"password",value:a.password,onChange:oe=>l({...a,password:oe.target.value}),placeholder:"Enter password",className:"pr-10"}),d.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>l({...a,showPassword:!a.showPassword}),children:a.showPassword?d.jsx(Dv,{className:"h-4 w-4 text-muted-foreground"}):d.jsx(dh,{className:"h-4 w-4 text-muted-foreground"})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"If set, the PDF will require this password to open"})]}),f==="email"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"recipients",children:"Recipients"}),d.jsx(yr,{id:"recipients",type:"text",value:c.recipients,onChange:oe=>u({...c,recipients:oe.target.value}),placeholder:i!=null&&i.email?"Add more emails separated by commas":"email@example.com, email2@example.com"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Separate multiple emails with commas"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"subject",children:"Subject"}),d.jsx(yr,{id:"subject",value:c.subject,onChange:oe=>u({...c,subject:oe.target.value})})]})]}),f==="schedule"&&d.jsxs(d.Fragment,{children:[d.jsx(oW,{reportType:"VISUAL",defaultValues:{subject:`Visual Report: ${(r==null?void 0:r.title)||"Report"}`,recipients:(i==null?void 0:i.email)||""},onSubmit:q,isSubmitting:_,submitError:N}),v&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(Zi,{className:"my-4"}),d.jsx(WW,{schedules:v,onDelete:Q,isDeleting:R,isLoading:w,onRefresh:M})]})]})]}),d.jsx(Ql,{className:"border-t p-4",children:f!=="schedule"&&d.jsx(le,{onClick:ee,disabled:g,className:"w-full",children:g?d.jsxs(d.Fragment,{children:[d.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):f==="download"?d.jsxs(d.Fragment,{children:[d.jsx(jv,{className:"mr-2 h-4 w-4"}),"Download ",p==="csv"?"CSV":"PDF"]}):d.jsxs(d.Fragment,{children:[d.jsx(aN,{className:"mr-2 h-4 w-4"}),"Send Email"]})})})]}),d.jsx("div",{ref:W,className:"flex flex-1 items-center justify-center bg-muted/5 p-4",children:d.jsx("div",{className:"relative overflow-hidden rounded-lg bg-white shadow-lg transition-all duration-200",style:{width:`${H.width*X}px`,height:`${H.height*X}px`},children:d.jsx(Ta,{className:"h-full w-full overflow-auto",children:d.jsx("div",{style:{transform:`scale(${H.width/1240*(U?.9:1)})`,transformOrigin:"top left",width:"1240px",padding:"32px",minHeight:`${H.height/(H.width/1240*(U?.9:1))}px`},children:ie()})})})})]})]})})}function ERe(e,t,n,r,o,i){if(!e||e.length===0)return"";const s=[],a=[];if(n.forEach(l=>{a.push(l.label||l.name)}),r.forEach(l=>{l.isMetricColumn&&a.push(l.displayLabel||l.metricLabel||l.metricName||"")}),s.push(a.map(NC).join(",")),e.forEach(l=>{const c=[];if(l.isSubtotal&&!l.isGrandTotal){const u=l.subtotalLevel,f=n.findIndex(h=>h.alias===u);n.forEach((h,p)=>{var g,b,y,x;const m=h.alias||h.name;if(p===f){const v=l.aggregate||"SUM",w=(y=(b=(g=o==null?void 0:o.config)==null?void 0:g.rowAggregates)==null?void 0:b.find(S=>S.groupLevel===l.subtotalLevel&&S.function===v))==null?void 0:y.label;if(w)c.push(w);else{const k=(((x=l.subtotalContext)==null?void 0:x.groupByValues)||{})[m],_=v==="SUM"?"Total":v.charAt(0).toUpperCase()+v.slice(1).toLowerCase();k&&k!=="__TOTAL__"?c.push(`Subtotal (${k})`):c.push(`Subtotal ${_}`)}}else if(p<f){const v=l[m];c.push(v&&v!=="__TOTAL__"?String(v):"")}else c.push("")}),r.forEach(h=>{if(h.isMetricColumn){const p=l[h.alias],m=i==null?void 0:i[h.alias];c.push(kC(p,m))}})}else n.forEach(u=>{const f=u.alias||u.name,h=l[f];c.push(h?String(h):"")}),r.forEach(u=>{if(u.isMetricColumn){const f=l[u.alias],h=i==null?void 0:i[u.alias];c.push(kC(f,h))}});s.push(c.map(NC).join(","))}),t){const l=[];n.forEach((c,u)=>{var f,h;if(u===0){const p=(h=(f=o==null?void 0:o.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(m=>m.groupLevel==="ALL");if(p!=null&&p.label)l.push(p.label);else{const m=t.aggregate||"SUM",g=m==="SUM"?"Total":m.charAt(0).toUpperCase()+m.slice(1).toLowerCase();l.push(`Grand ${g}`)}}else l.push("")}),r.forEach(c=>{if(c.isMetricColumn){const u=t[c.alias],f=i==null?void 0:i[c.alias];l.push(kC(u,f))}}),s.push(l.map(NC).join(","))}return s.join(`
|
|
790
|
+
`}),ij(s,t)}const CRe={letter:{width:816,height:1056},a4:{width:794,height:1123},legal:{width:816,height:1344},tabloid:{width:1056,height:1632},a3:{width:1123,height:1587}};function qW({isOpen:e,onClose:t,frame:n,card:r,data:o}){const{currentUser:i}=fh(),s=ne(oe=>oe.filterValues),[a,l]=E.useState({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1}),[c,u]=E.useState({recipients:(i==null?void 0:i.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),[f,h]=E.useState("download"),[p,m]=E.useState("pdf"),[g,b]=E.useState(!1),[y,x]=E.useState(!1),{schedules:v,isLoading:w,createSchedule:S,deleteSchedule:k,isSubmitting:_,submitError:N,deletingId:R,refetch:M}=UW({reportType:"VISUAL",visualId:r==null?void 0:r.id,frameId:n.id,pageSettings:{pageSize:a.pageSize,orientation:a.orientation,reportTitle:a.reportTitle,isPdfRender:!0,filterLine:a.filterLine},enabled:e&&!!(r!=null&&r.id)}),T=E.useMemo(()=>({id:"dummy",type:"table",title:"",frameId:"",config:{},queryConfig:{}}),[]),{data:D,isLoading:A,isFetching:I,pagination:j}=Yw(r||T),F=r?D:null,z=r?A:!1,V=r?I:!1,$=E.useMemo(()=>{const oe=o||F;return oe?oe.records&&oe.records.length>100?{...oe,records:oe.records.slice(0,100)}:oe:null},[o,F]),O=sb(r,$);E.useEffect(()=>{if(e&&!y){const oe=ne.getState().filterValues,me=HE(oe||[]);l({reportTitle:(r==null?void 0:r.title)||"Report",pageSize:"letter",orientation:"portrait",password:"",showPassword:!1,filterLine:me}),u({recipients:(i==null?void 0:i.email)||"",subject:`Report: ${(r==null?void 0:r.title)||"Visual"}`,message:"Please find the attached report."}),x(!0),h("download")}!e&&y&&x(!1)},[e,y,r==null?void 0:r.title,i==null?void 0:i.email]);const W=E.useRef(null),[B,P]=E.useState({width:0,height:0}),H=E.useMemo(()=>{const oe=CRe[a.pageSize];let me=oe.width,Ne=oe.height;return a.orientation==="landscape"&&([me,Ne]=[Ne,me]),{width:me,height:Ne}},[a.pageSize,a.orientation]),U=E.useMemo(()=>(r==null?void 0:r.type)&&["table","aggregateTable","pivotTable"].includes(r.type),[r==null?void 0:r.type]),X=E.useMemo(()=>{if(B.width===0||B.height===0)return .5;const oe=40,me=B.width-oe,Ne=B.height-oe,ye=me/H.width,ke=Ne/H.height;return Math.min(ye,ke,.9)},[B,H]);E.useEffect(()=>{const oe=()=>{if(W.current){const ye=W.current.getBoundingClientRect();P({width:ye.width,height:ye.height})}},me=setTimeout(oe,50);window.addEventListener("resize",oe);const Ne=new ResizeObserver(oe);return W.current&&Ne.observe(W.current),()=>{clearTimeout(me),window.removeEventListener("resize",oe),Ne.disconnect()}},[e]);const G=async()=>{var oe;if(!r||!$){it.error("No data to export");return}b(!0);try{if(p==="csv"){const me=a.reportTitle||r.title||"Report",Ne=(oe=r.preferences)==null?void 0:oe.tablePrefs;r.type==="aggregateTable"?wRe($.records||[],me,void 0,void 0,{includeHeaders:!0,includeSubtotals:!0,includeGrandTotal:!0}):r.type==="pivotTable"?SRe($.records||[],me,void 0,void 0,{includeHeaders:!0}):vRe($.records||[],me,Ne,{includeHeaders:!0}),it.success("CSV downloaded successfully"),t()}else await N9(r.id,n.id,a.reportTitle||r.title||"Report",r.type,a.password||void 0,a.pageSize,a.orientation,HE(s||[])),it.success("PDF downloaded successfully"),t()}catch(me){it.error(`Failed to generate ${p.toUpperCase()}`,{description:me instanceof Error?me.message:"Please try again"})}finally{b(!1)}},L=async()=>{if(!r||!$){it.error("No data to send");return}if(!c.recipients){it.error("Please enter recipient email addresses");return}const oe=c.recipients.split(/[,;]/).map(ke=>ke.trim()).filter(ke=>ke),me=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,Ne=oe.filter(ke=>!me.test(ke));if(Ne.length>0){it.error(`Invalid email addresses: ${Ne.join(", ")}`);return}b(!0);const ye=it.loading("Sending email...");try{await new Promise(lt=>setTimeout(lt,2e3)),it.dismiss(ye);const ke=oe.length,Le=ke===1?oe[0]:`${ke} recipients`;it.success(`✅ Email has been sent to ${Le}`,{duration:4e3})}catch(ke){it.error("Failed to send email",{description:ke instanceof Error?ke.message:"Please try again or contact support.",richColors:!0,duration:5e3}),console.error("Email send error:",ke)}},q=async oe=>{var me;if(!r){it.error("No visual selected");return}b(!0);try{const Ne={format:p};if(p==="pdf"&&(Ne.pdfOptions={pageSize:a.pageSize,orientation:a.orientation,includeFilters:!0,includeTimestamp:!0}),p==="csv"&&(Ne.csvOptions={delimiter:",",includeHeaders:!0,useFormattedValues:!0}),r.type==="table"||r.type==="aggregateTable"||r.type==="pivotTable"){const ye=(me=r.preferences)==null?void 0:me.tablePrefs;ye&&(Ne.tablePreferences=ye)}await S({...oe,reportParams:Ne}),t()}catch(Ne){console.error("Schedule creation error:",Ne)}finally{b(!1)}},Q=async oe=>{try{await k(oe)}catch(me){console.error("Failed to delete schedule:",me)}},ee=async()=>{switch(f){case"download":await G();break;case"email":await L();break}},K=E.useMemo(()=>({mode:"table-print"}),[]),ae=E.useMemo(()=>({displayPreferences:{...K,mode:"table-print"},shouldShowElement:()=>!1}),[K]),ie=()=>!r||!$?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No data to preview"}):z||V?d.jsx("div",{className:"flex h-full items-center justify-center",children:d.jsx(Ol,{size:"md",color:"muted","aria-label":"Loading preview"})}):d.jsx(eM.Provider,{value:ae,children:d.jsxs("div",{className:"flex h-full flex-col",children:[d.jsxs("div",{className:"mb-4",children:[d.jsx("h1",{className:"text-xl font-bold",children:a.reportTitle}),a.filterLine&&d.jsxs("p",{className:"mt-1 text-sm text-muted-foreground",children:["Filters: ",a.filterLine]})]}),d.jsx("div",{className:"flex-1",children:r.type==="table"?d.jsx(Hf,{card:r,data:$.records||[],paginationMetadata:j||void 0,onPaginationChange:()=>{},isLoading:!1}):r.type==="aggregateTable"?d.jsx(Iw,{card:r,data:$.records||[],groupByColumns:$.groupByColumns,pivotSchema:$.pivotSchema,paginationMetadata:j||void 0,onPaginationChange:()=>{},onAggregationChange:()=>{},isLoading:!1}):r.type==="pivotTable"&&O?d.jsx(ab,{card:r,data:O.data,options:{...O.options,pagination:{enabled:!1,pageSize:100}},onAggregationChange:()=>{},onAggregationLabelChange:()=>{}}):r.type==="pivotTable"&&!O?d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"No pivot table data to preview"}):d.jsx("div",{className:"flex h-full items-center justify-center text-muted-foreground",children:"Preview not available for this card type"})})]})});return d.jsx(Xl,{open:e,onOpenChange:t,children:d.jsxs(La,{className:"flex h-[90vh] w-[90vw] max-w-[1400px] flex-col gap-0 p-0",children:[d.jsxs(za,{className:"shrink-0 border-b px-6 py-4",children:[d.jsxs(Ba,{children:["PDF Preview - ",a.reportTitle]}),d.jsx(Va,{children:"Preview how your table will appear in the PDF and adjust settings before exporting"})]}),d.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[d.jsxs("div",{className:"flex w-[450px] shrink-0 flex-col border-r bg-muted/10",children:[d.jsxs("div",{className:"flex-1 space-y-6 overflow-y-auto p-6",children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"report-title",children:"Report Title"}),d.jsx(yr,{id:"report-title",value:a.reportTitle,onChange:oe=>l({...a,reportTitle:oe.target.value}),placeholder:"Enter report title"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{children:"Action"}),d.jsxs(Li,{value:f,onValueChange:oe=>{h(oe),oe==="schedule"&&p==="csv"&&m("pdf")},className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"download",id:"download"}),d.jsx(ue,{htmlFor:"download",className:"flex cursor-pointer items-center",children:"Download"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"schedule",id:"schedule"}),d.jsx(ue,{htmlFor:"schedule",className:"flex cursor-pointer items-center",children:"Schedule"})]})]})]}),f==="download"&&((r==null?void 0:r.type)==="table"||(r==null?void 0:r.type)==="aggregateTable"||(r==null?void 0:r.type)==="pivotTable")&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{children:"Export Format"}),d.jsxs(Li,{value:p,onValueChange:oe=>m(oe),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"pdf",id:"format-pdf"}),d.jsx(ue,{htmlFor:"format-pdf",className:"flex cursor-pointer items-center",children:"PDF"})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"csv",id:"format-csv"}),d.jsx(ue,{htmlFor:"format-csv",className:"flex cursor-pointer items-center",children:"CSV"})]})]}),p==="csv"&&d.jsx("p",{className:"text-xs text-muted-foreground",children:"CSV export preserves your column visibility and ordering"})]}),p==="pdf"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"page-size",children:"Page Size"}),d.jsxs(hn,{value:a.pageSize,onValueChange:oe=>l({...a,pageSize:oe}),children:[d.jsx(an,{id:"page-size",children:d.jsx(vn,{})}),d.jsxs(ln,{children:[d.jsx(Me,{value:"letter",children:'Letter (8.5" x 11")'}),d.jsx(Me,{value:"a4",children:"A4 (210mm x 297mm)"}),d.jsx(Me,{value:"legal",children:'Legal (8.5" x 14")'}),d.jsx(Me,{value:"tabloid",children:'Tabloid (11" x 17")'}),d.jsx(Me,{value:"a3",children:"A3 (297mm x 420mm)"})]})]})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{children:"Orientation"}),d.jsxs(Li,{value:a.orientation,onValueChange:oe=>l({...a,orientation:oe}),className:"flex gap-4",children:[d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"portrait",id:"portrait"}),d.jsxs(ue,{htmlFor:"portrait",className:"flex cursor-pointer items-center",children:[d.jsx(Ui,{className:"mr-2 h-4 w-4"}),"Portrait"]})]}),d.jsxs("div",{className:"flex items-center space-x-2",children:[d.jsx(nr,{value:"landscape",id:"landscape"}),d.jsxs(ue,{htmlFor:"landscape",className:"flex cursor-pointer items-center",children:[d.jsx(Ui,{className:"mr-2 h-4 w-4 rotate-90"}),"Landscape"]})]})]})]})]}),f==="download"&&p==="pdf"&&d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"password",children:"Password Protection (Optional)"}),d.jsxs("div",{className:"relative",children:[d.jsx(yr,{id:"password",type:a.showPassword?"text":"password",value:a.password,onChange:oe=>l({...a,password:oe.target.value}),placeholder:"Enter password",className:"pr-10"}),d.jsx(le,{type:"button",variant:"ghost",size:"sm",className:"absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",onClick:()=>l({...a,showPassword:!a.showPassword}),children:a.showPassword?d.jsx(Dv,{className:"h-4 w-4 text-muted-foreground"}):d.jsx(dh,{className:"h-4 w-4 text-muted-foreground"})})]}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"If set, the PDF will require this password to open"})]}),f==="email"&&d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"recipients",children:"Recipients"}),d.jsx(yr,{id:"recipients",type:"text",value:c.recipients,onChange:oe=>u({...c,recipients:oe.target.value}),placeholder:i!=null&&i.email?"Add more emails separated by commas":"email@example.com, email2@example.com"}),d.jsx("p",{className:"text-xs text-muted-foreground",children:"Separate multiple emails with commas"})]}),d.jsxs("div",{className:"space-y-2",children:[d.jsx(ue,{htmlFor:"subject",children:"Subject"}),d.jsx(yr,{id:"subject",value:c.subject,onChange:oe=>u({...c,subject:oe.target.value})})]})]}),f==="schedule"&&d.jsxs(d.Fragment,{children:[d.jsx(oW,{reportType:"VISUAL",defaultValues:{subject:`Visual Report: ${(r==null?void 0:r.title)||"Report"}`,recipients:(i==null?void 0:i.email)||""},onSubmit:q,isSubmitting:_,submitError:N}),v&&v.length>0&&d.jsxs(d.Fragment,{children:[d.jsx(Zi,{className:"my-4"}),d.jsx(WW,{schedules:v,onDelete:Q,isDeleting:R,isLoading:w,onRefresh:M})]})]})]}),d.jsx(Ql,{className:"border-t p-4",children:f!=="schedule"&&d.jsx(le,{onClick:ee,disabled:g,className:"w-full",children:g?d.jsxs(d.Fragment,{children:[d.jsx(Rs,{className:"mr-2 h-4 w-4 animate-spin"}),"Processing..."]}):f==="download"?d.jsxs(d.Fragment,{children:[d.jsx(jv,{className:"mr-2 h-4 w-4"}),"Download ",p==="csv"?"CSV":"PDF"]}):d.jsxs(d.Fragment,{children:[d.jsx(aN,{className:"mr-2 h-4 w-4"}),"Send Email"]})})})]}),d.jsx("div",{ref:W,className:"flex flex-1 items-center justify-center bg-muted/5 p-4",children:d.jsx("div",{className:"relative overflow-hidden rounded-lg bg-white shadow-lg transition-all duration-200",style:{width:`${H.width*X}px`,height:`${H.height*X}px`},children:d.jsx(Ta,{className:"h-full w-full overflow-auto",children:d.jsx("div",{style:{transform:`scale(${H.width/1240*(U?.9:1)})`,transformOrigin:"top left",width:"1240px",padding:U?"16px":"32px",minHeight:`${H.height/(H.width/1240*(U?.9:1))}px`},children:ie()})})})})]})]})})}function ERe(e,t,n,r,o,i){if(!e||e.length===0)return"";const s=[],a=[];if(n.forEach(l=>{a.push(l.label||l.name)}),r.forEach(l=>{l.isMetricColumn&&a.push(l.displayLabel||l.metricLabel||l.metricName||"")}),s.push(a.map(NC).join(",")),e.forEach(l=>{const c=[];if(l.isSubtotal&&!l.isGrandTotal){const u=l.subtotalLevel,f=n.findIndex(h=>h.alias===u);n.forEach((h,p)=>{var g,b,y,x;const m=h.alias||h.name;if(p===f){const v=l.aggregate||"SUM",w=(y=(b=(g=o==null?void 0:o.config)==null?void 0:g.rowAggregates)==null?void 0:b.find(S=>S.groupLevel===l.subtotalLevel&&S.function===v))==null?void 0:y.label;if(w)c.push(w);else{const k=(((x=l.subtotalContext)==null?void 0:x.groupByValues)||{})[m],_=v==="SUM"?"Total":v.charAt(0).toUpperCase()+v.slice(1).toLowerCase();k&&k!=="__TOTAL__"?c.push(`Subtotal (${k})`):c.push(`Subtotal ${_}`)}}else if(p<f){const v=l[m];c.push(v&&v!=="__TOTAL__"?String(v):"")}else c.push("")}),r.forEach(h=>{if(h.isMetricColumn){const p=l[h.alias],m=i==null?void 0:i[h.alias];c.push(kC(p,m))}})}else n.forEach(u=>{const f=u.alias||u.name,h=l[f];c.push(h?String(h):"")}),r.forEach(u=>{if(u.isMetricColumn){const f=l[u.alias],h=i==null?void 0:i[u.alias];c.push(kC(f,h))}});s.push(c.map(NC).join(","))}),t){const l=[];n.forEach((c,u)=>{var f,h;if(u===0){const p=(h=(f=o==null?void 0:o.config)==null?void 0:f.rowAggregates)==null?void 0:h.find(m=>m.groupLevel==="ALL");if(p!=null&&p.label)l.push(p.label);else{const m=t.aggregate||"SUM",g=m==="SUM"?"Total":m.charAt(0).toUpperCase()+m.slice(1).toLowerCase();l.push(`Grand ${g}`)}}else l.push("")}),r.forEach(c=>{if(c.isMetricColumn){const u=t[c.alias],f=i==null?void 0:i[c.alias];l.push(kC(u,f))}}),s.push(l.map(NC).join(","))}return s.join(`
|
|
791
791
|
`)}function kC(e,t){if(e==null)return"";if((t==null?void 0:t.type)==="number"&&typeof e=="number"){const{numberFormat:n}=t;return n.style==="percent"?new Intl.NumberFormat(n.locale||"en-US",{style:"percent",minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e/100):n.style==="currency"?new Intl.NumberFormat(n.locale||"en-US",{style:"currency",currency:n.currency||"USD",minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e):new Intl.NumberFormat(n.locale||"en-US",{minimumFractionDigits:n.minimumFractionDigits??0,maximumFractionDigits:n.maximumFractionDigits??2}).format(e)}return typeof e=="number"?e.toLocaleString():String(e)}function NC(e){return/[",\n\r]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function YO(e,t){const n=new Blob([e],{type:"text/csv;charset=utf-8;"}),r=window.URL.createObjectURL(n),o=document.createElement("a");o.setAttribute("href",r),o.setAttribute("download",t),o.style.display="none",document.body.appendChild(o),o.click(),document.body.removeChild(o),window.URL.revokeObjectURL(r)}const _Re=e=>{const t=window.getSelection();if(!t||t.rangeCount===0)return 0;const n=t.getRangeAt(0),r=n.cloneRange();return r.selectNodeContents(e),r.setEnd(n.endContainer,n.endOffset),r.toString().length},kRe=(e,t)=>{var s,a;const n=window.getSelection(),r=document.createRange();let o=0;const i=l=>{var c;if(l.nodeType===Node.TEXT_NODE){const u=((c=l.textContent)==null?void 0:c.length)||0;if(o+u>=t)return r.setStart(l,t-o),r.setEnd(l,t-o),!0;o+=u}else for(let u=0;u<l.childNodes.length;u++)if(i(l.childNodes[u]))return!0;return!1};if(!i(e)&&e.childNodes.length>0){const l=e.childNodes[e.childNodes.length-1];l.nodeType===Node.TEXT_NODE&&(r.setStart(l,((s=l.textContent)==null?void 0:s.length)||0),r.setEnd(l,((a=l.textContent)==null?void 0:a.length)||0))}n==null||n.removeAllRanges(),n==null||n.addRange(r)};function ZO({value:e,onSave:t,placeholder:n="Click to add content...",className:r,disabled:o=!1,isDynamicText:i=!1}){const s=E.useRef(null),[a,l]=E.useState(!1),[c,u]=E.useState(!1),f=E.useRef(),h=E.useRef(e),[p,m]=E.useState(e),g=E.useRef(!1),y=ne(N=>N.isDashboardEditing)&&!o&&!i;E.useEffect(()=>{!g.current&&s.current&&(s.current.innerHTML=e||"",g.current=!0)},[e]),E.useEffect(()=>{!a&&e!==p&&(m(e),s.current&&g.current&&(s.current.innerHTML=e||""),h.current=e)},[e,a,p]);const x=E.useCallback(()=>{if(!s.current||!y)return;u(!0);const N=s.current.innerHTML;m(N),f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{var M;const R=((M=s.current)==null?void 0:M.innerHTML)||"";if(R!==h.current){const T=s.current?_Re(s.current):0;t(R),h.current=R,m(R),u(!1),setTimeout(()=>{s.current&&a&&(s.current.focus(),kRe(s.current,T))},0)}},500)},[y,t,a]),v=E.useCallback(N=>{N.preventDefault();const R=N.clipboardData.getData("text/plain"),M=N.clipboardData.getData("text/html");let T="";if(M&&!R){const j=document.createElement("div");j.innerHTML=M,j.querySelectorAll("script, style").forEach(F=>F.remove()),j.querySelectorAll("p, div, br").forEach(F=>{if(F.tagName==="BR")F.replaceWith(`
|
|
792
792
|
`);else{const z=F.textContent||"";z&&F.replaceWith(z+`
|
|
793
793
|
`)}}),T=j.innerHTML.replace(/\n\n+/g,`
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/index-BgTQ-g-l.js"),r=require("../types/index.cjs");exports.Dashboard=e.Dashboard;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./chunks/index-BgTQ-g-l.js"),C=require("./types/index.cjs"),i=require("./chunks/dashboard-plus-ST0SJPKL.js"),t=require("react/jsx-runtime"),h=require("react");require("react-dom");function T(a){const{displayPreferences:n,...d}=a,u={...d,id:a.dashboardId};return t.jsx(e.ErrorBoundary,{FallbackComponent:e.Fallback,children:t.jsx(e.SemaphorContextProvider,{dashboardProps:u,children:t.jsx(e.UXProvider,{children:t.jsx(e.DisplayPreferencesProvider,{displayPreferences:n,children:t.jsx(e.Container,{type:"visual",...u,children:t.jsx(S,{cardId:a.cardId})})})})})})}function S({cardId:a}){const n=e.useDashboardStore(o=>{var s;return(s=o.dashboard)==null?void 0:s.sheets}),{card:d,frame:u}=h.useMemo(()=>{const o=n==null?void 0:n.flatMap(r=>r.frames),s=o==null?void 0:o.flatMap(r=>r==null?void 0:r.cards),c=s==null?void 0:s.find(r=>(r==null?void 0:r.id)===a),M=o==null?void 0:o.find(r=>{var l;return(l=r==null?void 0:r.cards)==null?void 0:l.find(Y=>(Y==null?void 0:Y.id)===a)});return{card:c,frame:M}},[n,a]);return!d||!u?t.jsx(e.FallbackVisual,{error:new Error("Card not found"),resetErrorBoundary:()=>{},customerFacingMessage:`Card not found with ID: ${a}`}):t.jsx("main",{className:"flex h-full grow flex-col",children:t.jsx(e.ErrorBoundary,{FallbackComponent:({error:o,resetErrorBoundary:s})=>t.jsx(e.FallbackVisual,{error:o,resetErrorBoundary:s,customerFacingMessage:"Error creating visual. Please try again."}),children:t.jsx(e.DashboardCard,{card:d,frame:u})})})}const b=["MM-DD-YYYY","YYYY-MM-DD","MM/DD/YYYY","DD/MM/YYYY","MMMM DD, YYYY","MMM DD, YYYY","DD MMM YYYY","Week of MMM DD, YYYY","Week of MMMM DD, YYYY","YYYY-WW","MMM YYYY","MMMM YYYY","YYYY-MM","MM/YYYY","YYYY MMM","Q1 YYYY","YYYY Q1","1st Quarter YYYY","YYYY-Q1","Quarter 1, YYYY","YYYY","YY","custom"];var D=(a=>(a.SUBTOTAL="__SUBTOTAL__",a.TOTAL="__TOTAL__",a.ALL="__ALL__",a))(D||{});exports.Dashboard=e.Dashboard;exports.DashboardWC=e.DashboardWC;exports.SemaphorContextProvider=e.SemaphorContextProvider;exports.SemaphorDataProvider=e.SemaphorQueryClient;exports.SemaphorQueryClient=e.SemaphorQueryClient;exports.createSqlGenConfig=e.createSqlGenConfig;exports.downloadPdf=e.downloadPdf;exports.fmt=e.fmt;exports.getColumnDataType=e.getColumnDataType;exports.getFilterValueType=e.getFilterValueType;exports.getFormattedTableNameForQuery=e.getFormattedTableNameForQuery;exports.getQualifiedTableName=e.getQualifiedTableName;exports.getSql=e.getSql;exports.invalidateToken=e.invalidateToken;exports.isBooleanDataType=e.isBooleanDataType;exports.isColumnInSqlGen=e.isColumnInSqlGen;exports.isDateDataType=e.isDateDataType;exports.isNumberDataType=e.isNumberDataType;exports.isTextDataType=e.isTextDataType;exports.resolveDataType=e.resolveDataType;exports.resolveDatamodelName=e.resolveDatamodelName;exports.useCard=e.useCard;exports.useCurrentActiveCard=e.useCurrentActiveCard;exports.useCurrentCardConfig=e.useCurrentCardConfig;exports.useCurrentSheetActiveCards=e.useCurrentSheetActiveCards;exports.useDashboardActions=e.useDashboardActions;exports.useDashboardStore=e.useDashboardStore;exports.useDataColumns=e.useDataColumns;exports.useDateFilterHook=e.useDateFilterHook;exports.useEditorActions=e.useEditorActions;exports.useEditorAside=e.useEditorAside;exports.useEditorStore=e.useEditorStore;exports.useTextFilterHook=e.useTextFilterHook;exports.EMPTY_SELECTION=C.EMPTY_SELECTION;exports.ResourceManagementPanel=i.ResourceManagementPanel;exports.ScheduleDashboard=i.ScheduleDashboard;exports.SelectComponent=i.SelectComponent;exports.Surfboard=i.DashboardPlus;exports.cleanCard=i.cleanCard;exports.getDashbaordStateWithoutData=i.getDashbaordStateWithoutData;exports.DATE_FORMAT_VALUES=b;exports.PivotMarkerEnum=D;exports.Visual=T;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as l, F as c, S as f, U as h, a as p, C as m, u as C, b as u, c as T } from "./chunks/index-
|
|
2
|
-
import { D as L, h as k, f as Q, f as w, r as B, j as N, l as O, t as W, s as U, x as V, y as q, q as I, i as G, p as H, v as R, o as j, n as z, m as J, z as K, w as X, g as $, B as Z, H as aa, G as ea, I as sa, k as ra, d as oa, K as ta, A as Ya, J as na, e as ia } from "./chunks/index-
|
|
1
|
+
import { E as l, F as c, S as f, U as h, a as p, C as m, u as C, b as u, c as T } from "./chunks/index-BROU-OfV.js";
|
|
2
|
+
import { D as L, h as k, f as Q, f as w, r as B, j as N, l as O, t as W, s as U, x as V, y as q, q as I, i as G, p as H, v as R, o as j, n as z, m as J, z as K, w as X, g as $, B as Z, H as aa, G as ea, I as sa, k as ra, d as oa, K as ta, A as Ya, J as na, e as ia } from "./chunks/index-BROU-OfV.js";
|
|
3
3
|
import { EMPTY_SELECTION as ua } from "./types/index.js";
|
|
4
|
-
import { R as Ma, S as Da, a as ca, D as fa, c as ha, g as pa } from "./chunks/dashboard-plus-
|
|
4
|
+
import { R as Ma, S as Da, a as ca, D as fa, c as ha, g as pa } from "./chunks/dashboard-plus-DRy8xZTM.js";
|
|
5
5
|
import { jsx as s } from "react/jsx-runtime";
|
|
6
6
|
import { useMemo as b } from "react";
|
|
7
7
|
import "react-dom";
|
package/dist/surfboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/dashboard-plus-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../chunks/dashboard-plus-ST0SJPKL.js"),r=require("../types/index.cjs");exports.Surfboard=e.DashboardPlus;exports.EMPTY_SELECTION=r.EMPTY_SELECTION;
|
package/dist/surfboard/index.js
CHANGED