drizzle-cube
Version:
Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.
7,228 lines • 254 kB
JavaScript
import { jsx as o, jsxs as A, Fragment as Rt } from "react/jsx-runtime";
import de, { useContext as xt, createContext as It, useState as X, useMemo as Q, useCallback as Le, useRef as pe, useEffect as Fe, useSyncExternalStore as fn, useLayoutEffect as Vt } from "react";
import { ResponsiveContainer as qt, Tooltip as $r, ComposedChart as Dr, CartesianGrid as pt, XAxis as yt, YAxis as Ie, Legend as Oe, Bar as mn, Cell as Ot, Line as Ee, LineChart as hn, Area as xn, PieChart as pn, Pie as yn, ScatterChart as gn, Scatter as Zt, RadarChart as bn, PolarGrid as vn, PolarAngleAxis as wn, PolarRadiusAxis as Nn, Radar as An, RadialBarChart as kn, RadialBar as Sn, Treemap as Fn } from "recharts";
import { d as Nt, a as Tn, b as Qt, c as Jt, e as Mn, f as _n, g as $n, h as er, i as tr, j as Dn, k as Ht, l as Cn, m as zn, n as Ln, o as En, p as Rn, q as In, r as Vn, s as On, t as Hn, u as Yn, v as Pn, w as jn, x as Un, y as Bn, z as Wn, A as Gn, B as Kn, C as Xn, D as qn, E as Zn, F as Qn, G as Jn, H as ei, I as ti, J as ri, K as ni, L as ii, M as si, N as ai, O as oi, P as li, Q as ci, R as di, S as ui, T as fi, U as mi, V as hi, W as xi, X as pi, Y as yi, Z as gi, _ as bi, $ as vi, a0 as wi, a1 as Ni, a2 as Ai, a3 as ki, a4 as Si, a5 as Fi, a6 as Ti, a7 as Mi, a8 as _i, a9 as $i, aa as Di, ab as Ci, ac as st } from "./icons-B2XSxpVK.js";
class zi {
apiUrl;
headers;
credentials;
constructor(t, r = {}) {
this.apiUrl = r.apiUrl || "/cubejs-api/v1", this.headers = {
"Content-Type": "application/json",
...r.headers
}, this.credentials = r.credentials ?? "include", t && (this.headers.Authorization = t);
}
async load(t) {
const r = JSON.stringify(t), n = encodeURIComponent(r), i = `${this.apiUrl}/load?query=${n}`, s = await fetch(i, {
method: "GET",
headers: {
// Remove Content-Type for GET request
...Object.fromEntries(
Object.entries(this.headers).filter(([l]) => l !== "Content-Type")
)
},
credentials: this.credentials
});
if (!s.ok) {
let l = `Cube query failed: ${s.status}`;
try {
const d = await s.text();
try {
const c = JSON.parse(d);
c.error ? l = c.error : l += ` ${d}`;
} catch {
l += ` ${d}`;
}
} catch {
}
throw new Error(l);
}
const a = await s.json();
return new At(a);
}
async meta() {
const t = `${this.apiUrl}/meta`, r = await fetch(t, {
method: "GET",
headers: this.headers,
credentials: this.credentials
});
if (!r.ok)
throw new Error(`Failed to fetch meta: ${r.status}`);
return r.json();
}
async sql(t) {
const r = encodeURIComponent(JSON.stringify(t)), n = `${this.apiUrl}/sql?query=${r}`, i = await fetch(n, {
method: "GET",
headers: {
// Remove Content-Type for GET request
...Object.fromEntries(
Object.entries(this.headers).filter(([s]) => s !== "Content-Type")
)
},
credentials: this.credentials
});
if (!i.ok)
throw new Error(`SQL generation failed: ${i.status}`);
return i.json();
}
async dryRun(t) {
const r = `${this.apiUrl}/dry-run`, n = await fetch(r, {
method: "POST",
headers: this.headers,
credentials: this.credentials,
body: JSON.stringify({ query: t })
});
if (!n.ok) {
let i = `Dry run failed: ${n.status}`;
try {
const s = await n.text();
try {
const a = JSON.parse(s);
a.error ? i = a.error : i += ` ${s}`;
} catch {
i += ` ${s}`;
}
} catch {
}
throw new Error(i);
}
return n.json();
}
/**
* Execute multiple queries in a single batch request
* Used by BatchCoordinator to optimize network requests
*/
async batchLoad(t) {
const r = `${this.apiUrl}/batch`, n = await fetch(r, {
method: "POST",
headers: this.headers,
credentials: this.credentials,
body: JSON.stringify({ queries: t })
});
if (!n.ok) {
let s = `Batch query failed: ${n.status}`;
try {
const a = await n.text();
try {
const l = JSON.parse(a);
l.error ? s = l.error : s += ` ${a}`;
} catch {
s += ` ${a}`;
}
} catch {
}
throw new Error(s);
}
return (await n.json()).results.map((s) => !s.success && s.error ? {
...new At({ data: [], annotation: {} }),
error: s.error
} : new At(s));
}
}
class At {
loadResponse;
constructor(t) {
this.loadResponse = t;
}
rawData() {
return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].data || [] : this.loadResponse.data || [];
}
tablePivot() {
return this.rawData();
}
series() {
return this.rawData();
}
annotation() {
return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].annotation || {} : this.loadResponse.annotation || {};
}
}
function Li(e, t = {}) {
return new zi(e, t);
}
class Ei {
queue = [];
flushScheduled = !1;
batchExecutor;
delayMs;
constructor(t, r = 100) {
this.batchExecutor = t, this.delayMs = r;
}
/**
* Register a query to be batched. Returns a promise that resolves
* when the batch is executed and this specific query's result is available.
*/
register(t) {
return new Promise((r, n) => {
this.queue.push({ query: t, resolve: r, reject: n }), this.flushScheduled || this.scheduleFlush();
});
}
/**
* Schedule a flush after a short delay to collect multiple queries.
* The delay allows queries from lazy-loaded portlets that become visible
* during the same scroll action to be batched together.
*/
scheduleFlush() {
this.flushScheduled = !0, setTimeout(() => {
this.flush();
}, this.delayMs);
}
/**
* Execute all queued queries as a batch and resolve individual promises
*/
async flush() {
this.flushScheduled = !1;
const t = this.queue.slice();
if (this.queue = [], t.length !== 0)
try {
const r = t.map((i) => i.query), n = await this.batchExecutor(r);
t.forEach((i, s) => {
const a = n[s];
a && "error" in a && a.error ? i.reject(new Error(a.error)) : i.resolve(a);
});
} catch (r) {
t.forEach((n) => {
n.reject(r instanceof Error ? r : new Error(String(r)));
});
}
}
/**
* Get current queue size (useful for debugging)
*/
getQueueSize() {
return this.queue.length;
}
/**
* Clear the queue (useful for testing/cleanup)
*/
clear() {
this.queue = [], this.flushScheduled = !1;
}
}
const Cr = It(null);
function Ri({
apiOptions: e,
token: t,
options: r = {},
enableBatching: n = !0,
batchDelayMs: i = 100,
children: s
}) {
const [a, l] = X({ apiOptions: e, token: t }), d = Q(
() => Li(a.token, a.apiOptions),
[a.apiOptions, a.token]
), c = Q(() => n ? new Ei((h) => d.batchLoad(h), i) : null, [n, d, i]), u = Le((h, m) => {
l({ apiOptions: h, token: m });
}, []), f = Q(() => ({
cubeApi: d,
options: r,
updateApiConfig: u,
batchCoordinator: c,
enableBatching: n
}), [d, r, u, c, n]);
return /* @__PURE__ */ o(Cr.Provider, { value: f, children: s });
}
function zr() {
const e = xt(Cr);
if (!e)
throw new Error("useCubeApi must be used within CubeApiProvider");
return e;
}
const Ii = 900 * 1e3;
let _e = null;
function Vi(e) {
const t = {};
return e.cubes.forEach((r) => {
r.measures.forEach((n) => {
t[n.name] = n.title || n.shortTitle || n.name;
}), r.dimensions.forEach((n) => {
t[n.name] = n.title || n.shortTitle || n.name;
}), r.segments.forEach((n) => {
t[n.name] = n.title || n.shortTitle || n.name;
});
}), t;
}
function Oi() {
return _e ? Date.now() - _e.timestamp < Ii : !1;
}
function Hi(e) {
const [t, r] = X(null), [n, i] = X(!0), [s, a] = X(null), l = pe({}), [d] = X(() => ({})), c = Le(async () => {
if (Oi() && _e) {
r(_e.data), l.current = _e.labelMap, Object.keys(d).forEach((h) => delete d[h]), Object.assign(d, _e.labelMap), i(!1), a(null);
return;
}
try {
i(!0), a(null);
const h = await e.meta(), m = Vi(h);
_e = {
data: h,
labelMap: m,
timestamp: Date.now()
}, l.current = m, Object.keys(d).forEach((N) => delete d[N]), Object.assign(d, m), r(h);
} catch (h) {
const m = h instanceof Error ? h.message : "Failed to fetch metadata";
a(m), console.error("Failed to fetch cube metadata:", h);
} finally {
i(!1);
}
}, [e, d]);
Fe(() => {
c();
}, [c]);
const u = Le((h) => l.current[h] || h, []), f = Le(() => {
_e = null, c();
}, [c]);
return {
meta: t,
labelMap: d,
// Return stable reference
loading: n,
error: s,
refetch: f,
getFieldLabel: u
};
}
const Yt = It(null);
function Yi({ children: e }) {
const { cubeApi: t } = zr(), {
meta: r,
labelMap: n,
loading: i,
error: s,
getFieldLabel: a,
refetch: l
} = Hi(t), d = Q(() => ({
meta: r,
labelMap: n,
metaLoading: i,
metaError: s,
getFieldLabel: a,
refetchMeta: l
}), [r, n, i, s, a, l]);
return /* @__PURE__ */ o(Yt.Provider, { value: d, children: e });
}
function Pi() {
const e = xt(Yt);
if (!e)
throw new Error("useCubeMeta must be used within CubeMetaProvider");
return e;
}
const Lr = It(null);
function ji({
features: e = {
enableAI: !0,
aiEndpoint: "/api/ai/generate",
showSchemaDiagram: !1,
useAnalysisBuilder: !1
},
dashboardModes: t = ["rows", "grid"],
children: r
}) {
const [n, i] = X(e), s = Le((l) => {
i((d) => ({ ...d, ...l }));
}, []), a = Q(() => ({
features: n,
dashboardModes: t,
updateFeatures: s
}), [n, t, s]);
return /* @__PURE__ */ o(Lr.Provider, { value: a, children: r });
}
function Ui() {
const e = xt(Lr);
if (!e)
throw new Error("useCubeFeatures must be used within CubeFeaturesProvider");
return e;
}
function ql({
cubeApi: e,
// Intentionally unused - for backward compatibility
apiOptions: t,
token: r,
options: n,
features: i,
dashboardModes: s,
enableBatching: a,
batchDelayMs: l,
children: d
}) {
return /* @__PURE__ */ o(
Ri,
{
apiOptions: t || { apiUrl: "/cubejs-api/v1" },
token: r,
options: n,
enableBatching: a,
batchDelayMs: l,
children: /* @__PURE__ */ o(Yi, { children: /* @__PURE__ */ o(ji, { features: i, dashboardModes: s, children: d }) })
}
);
}
function Bi() {
const e = zr(), t = Pi(), r = Ui();
return Q(() => ({
...e,
...t,
features: r.features,
dashboardModes: r.dashboardModes
}), [e, t, r]);
}
const Er = {
// Action icons
close: { icon: Ci, category: "action" },
add: { icon: Di, category: "action" },
edit: { icon: $i, category: "action" },
delete: { icon: _i, category: "action" },
refresh: { icon: Nt, category: "action" },
copy: { icon: Mi, category: "action" },
duplicate: { icon: Ti, category: "action" },
settings: { icon: Fi, category: "action" },
filter: { icon: Si, category: "action" },
share: { icon: ki, category: "action" },
expand: { icon: er, category: "action" },
collapse: { icon: tr, category: "action" },
search: { icon: Ai, category: "action" },
menu: { icon: Ni, category: "action" },
run: { icon: wi, category: "action" },
check: { icon: vi, category: "action" },
link: { icon: bi, category: "action" },
eye: { icon: gi, category: "action" },
eyeOff: { icon: yi, category: "action" },
adjustments: { icon: pi, category: "action" },
desktop: { icon: xi, category: "action" },
table: { icon: hi, category: "action" },
sun: { icon: mi, category: "action" },
moon: { icon: fi, category: "action" },
ellipsisHorizontal: { icon: ui, category: "action" },
documentText: { icon: di, category: "action" },
bookOpen: { icon: ci, category: "action" },
codeBracket: { icon: li, category: "action" },
// Field type icons (solid for visual distinction)
measure: { icon: oi, category: "field" },
dimension: { icon: ai, category: "field" },
timeDimension: { icon: si, category: "field" },
segment: { icon: ii, category: "field" },
// Chart type icons (Tabler - keeping existing visuals)
chartBar: { icon: ni, category: "chart" },
chartLine: { icon: ri, category: "chart" },
chartArea: { icon: ti, category: "chart" },
chartPie: { icon: ei, category: "chart" },
chartScatter: { icon: Jn, category: "chart" },
chartBubble: { icon: Qn, category: "chart" },
chartRadar: { icon: Zn, category: "chart" },
chartRadialBar: { icon: qn, category: "chart" },
chartTreemap: { icon: Xn, category: "chart" },
chartTable: { icon: Kn, category: "chart" },
chartActivityGrid: { icon: Gn, category: "chart" },
chartKpiNumber: { icon: Wn, category: "chart" },
chartKpiDelta: { icon: Bn, category: "chart" },
chartKpiText: { icon: Un, category: "chart" },
chartMarkdown: { icon: jn, category: "chart" },
// Measure type icons (solid)
measureCount: { icon: Pn, category: "measure" },
measureCountDistinct: { icon: Yn, category: "measure" },
measureCountDistinctApprox: { icon: Hn, category: "measure" },
measureSum: { icon: On, category: "measure" },
measureAvg: { icon: Vn, category: "measure" },
measureMin: { icon: Qt, category: "measure" },
measureMax: { icon: Jt, category: "measure" },
measureRunningTotal: { icon: In, category: "measure" },
measureCalculated: { icon: Rn, category: "measure" },
measureNumber: { icon: En, category: "measure" },
// State icons
success: { icon: Ln, category: "state" },
warning: { icon: zn, category: "state" },
error: { icon: Cn, category: "state" },
info: { icon: Ht, category: "state" },
loading: { icon: Nt, category: "state" },
sparkles: { icon: Dn, category: "state" },
// Navigation icons
chevronUp: { icon: tr, category: "navigation" },
chevronDown: { icon: er, category: "navigation" },
chevronLeft: { icon: $n, category: "navigation" },
chevronRight: { icon: _n, category: "navigation" },
chevronUpDown: { icon: Mn, category: "navigation" },
arrowUp: { icon: Jt, category: "navigation" },
arrowDown: { icon: Qt, category: "navigation" },
arrowRight: { icon: Tn, category: "navigation" },
arrowPath: { icon: Nt, category: "navigation" }
};
let le = { ...Er };
const Ge = /* @__PURE__ */ new Map();
function Zl() {
return le;
}
function gt(e) {
const t = Ge.get(e);
if (t)
return t;
const r = le[e];
if (!r)
return console.warn(`Icon "${e}" not found in registry, using fallback`), ({ className: s, ...a }) => /* @__PURE__ */ o(st, { icon: le.info.icon, className: s, ...a });
const n = ({ className: i, ...s }) => /* @__PURE__ */ o(st, { icon: r.icon, className: i, ...s });
return Ge.set(e, n), n;
}
function Ql(e) {
return le[e]?.icon ?? le.info.icon;
}
function Jl(e, t) {
le[e] && (le[e] = {
...le[e],
icon: t
}, Ge.delete(e));
}
function ec(e) {
for (const [t, r] of Object.entries(e))
if (r && t in le) {
const n = t;
if ("body" in r)
le[n] = {
...le[n],
icon: r
};
else {
const i = r;
le[n] = {
...le[n],
...i,
icon: i.icon ?? le[n].icon
};
}
Ge.delete(n);
}
}
function tc() {
le = { ...Er }, Ge.clear();
}
function rc(e) {
const t = {};
for (const [r, n] of Object.entries(le))
n.category === e && (t[r] = gt(r));
return t;
}
function Wi(e) {
const r = {
count: "measureCount",
countDistinct: "measureCountDistinct",
countDistinctApprox: "measureCountDistinctApprox",
sum: "measureSum",
avg: "measureAvg",
min: "measureMin",
max: "measureMax",
runningTotal: "measureRunningTotal",
calculated: "measureCalculated",
number: "measureNumber"
}[e || ""] || "measureCount";
return gt(r);
}
function ue(e) {
const r = {
bar: "chartBar",
line: "chartLine",
area: "chartArea",
pie: "chartPie",
scatter: "chartScatter",
bubble: "chartBubble",
radar: "chartRadar",
radialBar: "chartRadialBar",
treemap: "chartTreemap",
table: "chartTable",
activityGrid: "chartActivityGrid",
kpiNumber: "chartKpiNumber",
kpiDelta: "chartKpiDelta",
kpiText: "chartKpiText",
markdown: "chartMarkdown"
}[e] || "chartBar";
return gt(r);
}
function nc(e) {
const r = {
measure: "measure",
dimension: "dimension",
timeDimension: "timeDimension",
time: "timeDimension",
segment: "segment"
}[e] || "dimension";
return gt(r);
}
const Gi = {
sm: "h-6 w-6",
md: "h-8 w-8",
lg: "h-12 w-12"
};
function rr({
size: e = "md",
className: t = ""
}) {
return /* @__PURE__ */ o(
"div",
{
className: `animate-spin rounded-full border-b-2 ${Gi[e]} ${t}`,
style: { borderBottomColor: "var(--dc-primary)" },
role: "status",
"aria-label": "Loading"
}
);
}
function Ki({ children: e, className: t = "" }) {
return /* @__PURE__ */ o("h3", { className: `text-sm font-semibold text-dc-primary uppercase tracking-wide ${t}`, children: e });
}
const Xi = {
icon: ue("bar"),
description: "Compare values across categories",
useCase: "Best for comparing discrete categories, showing rankings, or displaying changes over time",
dropZones: [
{
key: "xAxis",
label: "X-Axis (Categories)",
description: "Dimensions and time dimensions for grouping",
mandatory: !1,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop dimensions & time dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for bar heights",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures here",
enableDualAxis: !0
},
{
key: "series",
label: "Series (Split into Multiple Series)",
description: "Dimensions to create separate data series",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here to split data into series"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "stackType",
label: "Stacking",
type: "select",
defaultValue: "none",
options: [
{ value: "none", label: "None" },
{ value: "normal", label: "Stacked" },
{ value: "percent", label: "Stacked 100%" }
],
description: "How to stack multiple bar series"
},
{
key: "target",
label: "Target Values",
type: "string",
placeholder: "e.g., 100 or 50,75 for spread",
description: "Single value or comma-separated values to spread across X-axis"
},
{
key: "leftYAxisFormat",
label: "Left Y-Axis Format",
type: "axisFormat",
description: "Number formatting for left Y-axis"
},
{
key: "rightYAxisFormat",
label: "Right Y-Axis Format",
type: "axisFormat",
description: "Number formatting for right Y-axis"
}
]
}, ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
barChartConfig: Xi
}, Symbol.toStringTag, { value: "Module" })), qi = {
icon: ue("line"),
description: "Show trends and changes over time",
useCase: "Best for continuous data, trends, time series, and showing relationships between multiple series",
dropZones: [
{
key: "xAxis",
label: "X-Axis (Time/Categories)",
description: "Time dimensions or dimensions for X-axis",
mandatory: !0,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop time dimensions or dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for line values",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures here",
enableDualAxis: !0
},
{
key: "series",
label: "Series (Multiple Lines)",
description: "Dimensions to create separate lines",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here for multiple lines"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "connectNulls",
label: "Connect Nulls",
type: "boolean",
defaultValue: !1,
description: "Draw continuous line through missing data points"
},
{
key: "target",
label: "Target Values",
type: "string",
placeholder: "e.g., 100 or 50,75 for spread",
description: "Single value or comma-separated values to spread across X-axis"
},
{
key: "leftYAxisFormat",
label: "Left Y-Axis Format",
type: "axisFormat",
description: "Number formatting for left Y-axis"
},
{
key: "rightYAxisFormat",
label: "Right Y-Axis Format",
type: "axisFormat",
description: "Number formatting for right Y-axis"
}
]
}, sc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
lineChartConfig: qi
}, Symbol.toStringTag, { value: "Module" })), Zi = {
icon: ue("area"),
description: "Emphasize magnitude of change over time",
useCase: "Best for showing cumulative totals, volume changes, or stacked comparisons over time",
dropZones: [
{
key: "xAxis",
label: "X-Axis (Time/Categories)",
description: "Time dimensions or dimensions for X-axis",
mandatory: !0,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop time dimensions or dimensions here"
},
{
key: "yAxis",
label: "Y-Axis (Values)",
description: "Measures for area values",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures here",
enableDualAxis: !0
},
{
key: "series",
label: "Series (Stack Areas)",
description: "Dimensions to create stacked areas",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions here for stacked areas"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "stackType",
label: "Stacking",
type: "select",
defaultValue: "none",
options: [
{ value: "none", label: "None" },
{ value: "normal", label: "Stacked" },
{ value: "percent", label: "Stacked 100%" }
],
description: "How to stack multiple area series"
},
{
key: "connectNulls",
label: "Connect Nulls",
type: "boolean",
defaultValue: !1,
description: "Draw continuous line through missing data points"
},
{
key: "target",
label: "Target Values",
type: "string",
placeholder: "e.g., 100 or 50,75 for spread",
description: "Single value or comma-separated values to spread across X-axis"
},
{
key: "leftYAxisFormat",
label: "Left Y-Axis Format",
type: "axisFormat",
description: "Number formatting for left Y-axis"
},
{
key: "rightYAxisFormat",
label: "Right Y-Axis Format",
type: "axisFormat",
description: "Number formatting for right Y-axis"
}
]
}, ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
areaChartConfig: Zi
}, Symbol.toStringTag, { value: "Module" })), Qi = {
icon: ue("pie"),
description: "Show proportions of a whole",
useCase: "Best for showing percentage distribution or composition of a total (limit to 5-7 slices)",
dropZones: [
{
key: "xAxis",
label: "Categories",
description: "Dimension for pie slices",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension for categories"
},
{
key: "yAxis",
label: "Values",
description: "Measure for slice sizes",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for values"
}
],
displayOptions: ["showLegend", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "leftYAxisFormat",
label: "Value Format",
type: "axisFormat",
description: "Number formatting for values"
}
]
}, oc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
pieChartConfig: Qi
}, Symbol.toStringTag, { value: "Module" })), Ji = {
icon: ue("scatter"),
description: "Reveal correlations between variables",
useCase: "Best for identifying patterns, correlations, outliers, and relationships between two measures",
dropZones: [
{
key: "xAxis",
label: "X-Axis",
description: "Measure or dimension for X position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension", "timeDimension", "measure"],
emptyText: "Drop a field for X-axis"
},
{
key: "yAxis",
label: "Y-Axis",
description: "Measure for Y position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for Y-axis"
},
{
key: "series",
label: "Series (Color Groups)",
description: "Dimension to color points by category",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension to color points"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "xAxisFormat",
label: "X-Axis Format",
type: "axisFormat",
description: "Number formatting for X-axis"
},
{
key: "leftYAxisFormat",
label: "Y-Axis Format",
type: "axisFormat",
description: "Number formatting for Y-axis"
}
]
}, lc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
scatterChartConfig: Ji
}, Symbol.toStringTag, { value: "Module" })), es = {
icon: ue("bubble"),
description: "Compare three dimensions of data",
useCase: "Best for showing relationships between three variables (X, Y, and size), market analysis",
dropZones: [
{
key: "xAxis",
label: "X-Axis",
description: "Horizontal axis position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension", "timeDimension", "measure"],
emptyText: "Drop a field for X-axis position"
},
{
key: "yAxis",
label: "Y-Axis",
description: "Vertical axis position",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for Y-axis position"
},
{
key: "sizeField",
label: "Bubble Radius",
description: "Size of bubbles based on this measure",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for bubble size"
},
{
key: "series",
label: "Bubble Labels",
description: "Field to use for bubble labels and identification",
mandatory: !0,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension for bubble labels"
},
{
key: "colorField",
label: "Bubble Colour",
description: "Color bubbles by this field (optional)",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension", "measure"],
emptyText: "Drop a field for bubble color (optional)"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "minBubbleSize", "maxBubbleSize", "bubbleOpacity", "hideHeader"],
displayOptionsConfig: [
{
key: "xAxisFormat",
label: "X-Axis Format",
type: "axisFormat",
description: "Number formatting for X-axis"
},
{
key: "leftYAxisFormat",
label: "Y-Axis Format",
type: "axisFormat",
description: "Number formatting for Y-axis and values"
}
]
}, cc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
bubbleChartConfig: es
}, Symbol.toStringTag, { value: "Module" })), ts = {
icon: ue("radar"),
description: "Compare multiple metrics across categories",
useCase: "Best for multivariate comparisons, performance metrics, strengths/weaknesses analysis",
dropZones: [
{
key: "xAxis",
label: "Axes (Categories)",
description: "Dimensions for radar axes",
mandatory: !0,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for radar axes"
},
{
key: "yAxis",
label: "Values",
description: "Measures for radar values",
mandatory: !0,
acceptTypes: ["measure"],
emptyText: "Drop measures for values"
},
{
key: "series",
label: "Series (Multiple Shapes)",
description: "Dimensions to create multiple radar shapes",
mandatory: !1,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for multiple shapes"
}
],
displayOptions: ["showLegend", "showGrid", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "leftYAxisFormat",
label: "Value Format",
type: "axisFormat",
description: "Number formatting for values"
}
]
}, dc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
radarChartConfig: ts
}, Symbol.toStringTag, { value: "Module" })), rs = {
icon: ue("radialBar"),
description: "Circular progress and KPI visualization",
useCase: "Best for showing progress toward goals, KPIs, or comparing percentages in a compact form",
dropZones: [
{
key: "xAxis",
label: "Categories",
description: "Dimensions for radial segments",
mandatory: !0,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for categories"
},
{
key: "yAxis",
label: "Values",
description: "Measures for radial bar lengths",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for values"
}
],
displayOptions: ["showLegend", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "leftYAxisFormat",
label: "Value Format",
type: "axisFormat",
description: "Number formatting for values"
}
]
}, uc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
radialBarChartConfig: rs
}, Symbol.toStringTag, { value: "Module" })), ns = {
icon: ue("treemap"),
description: "Visualize hierarchical data with nested rectangles",
useCase: "Best for showing part-to-whole relationships in hierarchical data, disk usage, budget allocation",
dropZones: [
{
key: "xAxis",
label: "Categories",
description: "Dimensions for treemap rectangles",
mandatory: !0,
acceptTypes: ["dimension"],
emptyText: "Drop dimensions for categories"
},
{
key: "yAxis",
label: "Size",
description: "Measure for rectangle sizes",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for size"
},
{
key: "series",
label: "Color Groups",
description: "Dimension to color rectangles by category",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension"],
emptyText: "Drop a dimension for color grouping"
}
],
displayOptions: ["showLegend", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "leftYAxisFormat",
label: "Value Format",
type: "axisFormat",
description: "Number formatting for size values"
}
]
}, fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
treemapChartConfig: ns
}, Symbol.toStringTag, { value: "Module" })), is = {
icon: ue("table"),
description: "Display detailed tabular data",
useCase: "Best for precise values, detailed analysis, sortable/filterable data exploration",
dropZones: [
{
key: "xAxis",
label: "Columns",
description: "All fields to display as columns",
mandatory: !1,
acceptTypes: ["dimension", "timeDimension", "measure"],
emptyText: "Drop fields to display as columns (or leave empty for all)"
}
],
displayOptions: ["hideHeader"],
displayOptionsConfig: [
{
key: "leftYAxisFormat",
label: "Value Format",
type: "axisFormat",
description: "Number formatting for numeric values"
}
]
}, mc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
dataTableConfig: is
}, Symbol.toStringTag, { value: "Module" })), ss = {
icon: ue("activityGrid"),
description: "GitHub-style activity grid showing temporal patterns across different time scales",
useCase: "Best for visualizing activity patterns over time. Supports hour (3hr blocks × days), day (days × weeks), week (weeks × months), month (months × quarters), and quarter (quarters × years) granularities",
dropZones: [
{
key: "dateField",
label: "Time Dimension",
description: "Time field that determines grid structure (granularity affects layout)",
mandatory: !0,
maxItems: 1,
acceptTypes: ["timeDimension"],
emptyText: "Drop a time dimension (granularity affects grid structure)"
},
{
key: "valueField",
label: "Activity Measure",
description: "Measure used for activity intensity (color coding)",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure for activity intensity"
}
],
displayOptions: ["showLabels", "showTooltip", "hideHeader"],
displayOptionsConfig: [
{
key: "fitToWidth",
label: "Fit to Width",
type: "boolean",
defaultValue: !1,
description: "Automatically size blocks to fill portlet width and height while maintaining aspect ratio"
}
],
validate: (e) => {
const { dateField: t, valueField: r } = e;
return !t || Array.isArray(t) && t.length === 0 ? {
isValid: !1,
message: "Time dimension is required for activity grid"
} : !r || Array.isArray(r) && r.length === 0 ? {
isValid: !1,
message: "Activity measure is required for intensity mapping"
} : { isValid: !0 };
}
}, hc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
activityGridChartConfig: ss
}, Symbol.toStringTag, { value: "Module" })), as = {
icon: ue("kpiNumber"),
description: "Display key performance indicators as large numbers",
useCase: "Perfect for showing important metrics like revenue, user count, or other key business metrics in a prominent, easy-to-read format",
dropZones: [
{
key: "yAxis",
label: "Value",
description: "Measure to display as KPI number",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure here"
}
],
displayOptionsConfig: [
{
key: "target",
label: "Target Value",
type: "string",
placeholder: "e.g., 100",
description: "Target value to compare against (first value used if multiple provided)"
},
{
key: "prefix",
label: "Prefix",
type: "string",
placeholder: "e.g., $, €, #",
description: "Text to display before the number"
},
{
key: "suffix",
label: "Suffix",
type: "string",
placeholder: "e.g., %, units, items",
description: "Text to display after the number"
},
{
key: "decimals",
label: "Decimal Places",
type: "number",
defaultValue: 0,
min: 0,
max: 10,
step: 1,
description: "Number of decimal places to display"
},
{
key: "valueColorIndex",
label: "Value Color",
type: "paletteColor",
defaultValue: 0,
description: "Color from the dashboard palette for the KPI value text"
},
{
key: "useLastCompletePeriod",
label: "Use Last Complete Period",
type: "boolean",
defaultValue: !0,
description: "Exclude current incomplete period from aggregation (e.g., partial week/month)"
},
{
key: "skipLastPeriod",
label: "Skip Last Period",
type: "boolean",
defaultValue: !1,
description: "Always exclude the last period regardless of completeness"
}
],
displayOptions: ["hideHeader"]
}, xc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
kpiNumberConfig: as
}, Symbol.toStringTag, { value: "Module" })), os = {
icon: ue("kpiDelta"),
description: "Display change between latest and previous values with trend indicators",
useCase: "Perfect for showing performance changes over time, such as revenue growth, user acquisition changes, or other metrics where the trend and delta are more important than the absolute value",
dropZones: [
{
key: "yAxis",
label: "Value",
description: "Measure to track changes for",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure here"
},
{
key: "xAxis",
label: "Dimension (optional)",
description: "Dimension for ordering data (typically time)",
mandatory: !1,
maxItems: 1,
acceptTypes: ["dimension", "timeDimension"],
emptyText: "Drop a dimension for ordering"
}
],
displayOptionsConfig: [
{
key: "prefix",
label: "Prefix",
type: "string",
placeholder: "e.g., $, €, #",
description: "Text to display before the number"
},
{
key: "suffix",
label: "Suffix",
type: "string",
placeholder: "e.g., %, units, items",
description: "Text to display after the number"
},
{
key: "decimals",
label: "Decimal Places",
type: "number",
defaultValue: 1,
min: 0,
max: 10,
step: 1,
description: "Number of decimal places to display"
},
{
key: "positiveColorIndex",
label: "Positive Change Color",
type: "paletteColor",
defaultValue: 2,
// Typically green in most palettes
description: "Color for positive changes (increases)"
},
{
key: "negativeColorIndex",
label: "Negative Change Color",
type: "paletteColor",
defaultValue: 3,
// Typically red in most palettes
description: "Color for negative changes (decreases)"
},
{
key: "showHistogram",
label: "Show Variance Histogram",
type: "boolean",
defaultValue: !0,
description: "Display historical variance chart below the delta"
},
{
key: "useLastCompletePeriod",
label: "Use Last Complete Period",
type: "boolean",
defaultValue: !0,
description: "Exclude current incomplete period from delta calculation (e.g., partial week/month)"
},
{
key: "skipLastPeriod",
label: "Skip Last Period",
type: "boolean",
defaultValue: !1,
description: "Always exclude the last period regardless of completeness"
}
],
displayOptions: ["hideHeader"],
validate: (e) => !e.yAxis || Array.isArray(e.yAxis) && e.yAxis.length === 0 ? {
isValid: !1,
message: "A measure is required for KPI Delta charts"
} : { isValid: !0 }
}, pc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
kpiDeltaConfig: os
}, Symbol.toStringTag, { value: "Module" })), ls = {
icon: ue("kpiText"),
description: "Display key performance indicators as customizable text",
useCase: "Perfect for showing metrics with custom formatting, combining multiple values, or displaying contextual KPI information using templates",
dropZones: [
{
key: "yAxis",
label: "Value",
description: "Measure to display in the KPI text template",
mandatory: !0,
maxItems: 1,
acceptTypes: ["measure"],
emptyText: "Drop a measure here"
}
],
displayOptionsConfig: [
{
key: "template",
label: "Text Template",
type: "string",
placeholder: "e.g., Total Revenue: ${value}",
description: "Template for displaying the text. Use ${value} to insert the measure value."
},
{
key: "decimals",
label: "Decimal Places",
type: "number",
defaultValue: 0,
min: 0,
max: 10,
step: 1,
description: "Number of decimal places to display for numeric values"
},
{
key: "valueColorIndex",
label: "Value Color",
type: "paletteColor",
defaultValue: 0,
description: "Color from the dashboard palette for the KPI value text"
}
],
displayOptions: ["hideHeader"]
}, yc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
kpiTextConfig: ls
}, Symbol.toStringTag, { value: "Module" })), cs = {
icon: ue("markdown"),
description: "Display custom markdown content with formatting",
useCase: "Perfect for adding documentation, notes, instructions, or formatted text to dashboards",
skipQuery: !0,
// This chart doesn't require a valid query
dropZones: [],
// No drop zones needed for markdown content
displayOptionsConfig: [
{
key: "content",
label: "Markdown Content",
type: "string",
placeholder: `# Welcome
Add your **markdown** content here:
- Lists with bullets
- [Links](https://example.com)
- *Italic* and **bold** text`,
description: "Enter markdown text. Supports headers (#), bold (**text**), italic (*text*), links ([text](url)), and lists (- item)."
},
{
key: "accentColorIndex",
label: "Accent Color",
type: "paletteColor",
defaultValue: 0,
description: "Color from the dashboard palette for headers, bullets, and links"
},
{
key: "fontSize",
label: "Font Size",
type: "select",
defaultValue: "medium",
options: [
{ value: "small", label: "Small" },
{ value: "medium", label: "Medium" },
{ value: "large", label: "Large" }
],
description: "Overall text size for the markdown content"
},
{
key: "alignment",
label: "Text Alignment",
type: "select",
defaultValue: "left",
options: [
{ value: "left", label: "Left" },
{ value: "center", label: "Center" },
{ value: "right", label: "Right" }
],
description: "Horizontal alignment of the markdown content"
}
],
displayOptions: ["hideHeader"]
}, gc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
markdownConfig: cs
}, Symbol.toStringTag, { value: "Module" }));
function at(e) {
return e != null && !isNaN(Number(e));
}
function Ve(e) {
if (e == null) return null;
const t = typeof e == "string" ? parseFloat(e) : Number(e);
return isNaN(t) ? null : t;
}
function Rr(e) {
if (e == null) return "No data";
const t = typeof e == "number" ? e : parseFloat(e);
return isNaN(t) ? String(e) : Number.isInteger(t) ? t.toLocaleString() : parseFloat(t.toFixed(2)).toLocaleString();
}
function B(e, t, r) {
if (e == null)
return "No data";
const n = typeof e == "number" ? e : parseFloat(String(e));
if (isNaN(n))
return String(e);
if (!isFinite(n))
return n > 0 ? "∞" : "-∞";
const i = typeof navigator < "u" ? navigator.language : "en-US";
if (!t)
return Rr(e);
const { unit: s, abbreviate: a = !0, decimals: l, customPrefix: d, customSuffix: c } = t;
let u = n, f = "";
if (a) {
const m = Math.abs(n);
m >= 1e9 ? (u = n / 1e9, f = "B") : m >= 1e6 ? (u = n / 1e6, f = "M") : m >= 1e3 && (u = n / 1e3, f = "K");
}
const h = l !== void 0 ? l : Number.isInteger(u) ? 0 : 2;
switch (s) {
case "currency": {
const m = ds(i);
if (a && f) {
const N = new Intl.NumberFormat(i, {
style: "currency",
currency: m,
minimumFractionDigits: h,
maximumFractionDigits: h
}).format(u), w = new Intl.NumberFormat(i, {
style: "currency",
currency: m
}).formatToParts(u);
return w[w.length - 1]?.type === "currency" ? N.replace(/(\s*[^\d\s]+)$/, f + "$1") : N + f;
}
return new Intl.NumberFormat(i, {
style: "currency",
currency: m,
minimumFractionDigits: h,
maximumFractionDigits: h
}).format(u);
}
case "percent": {
const m = Math.abs(u) <= 1 && !a ? u * 100 : u;
return new Intl.NumberFormat(i, {
minimumFractionDigits: h,
maximumFractionDigits: h
}).format(m) + f + "%";
}
case "custom": {
const m = d || "", N = c || "", w = new Intl.NumberFormat(i, {
minimumFractionDigits: h,
maximumFractionDigits: h
}).format(u);
return m + w + f + N;
}
default:
return new Intl.NumberFormat(i, {
minimumFractionDigits: h,
maximumFractionDigits: h
}).format(u) + f;
}
}
function ds(e) {
const r = e.split("-")[1]?.toUpperCase();
return {
US: "USD",
CA: "CAD",
GB: "GBP",
UK: "GBP",
AU: "AUD",
NZ: "NZD",
EU: "EUR",
DE: "EUR",
FR: "EUR",
IT: "EUR",
ES: "EUR",
NL: "EUR",
BE: "EUR",
AT: "EUR",
IE: "EUR",
PT: "EUR",
FI: "EUR",
JP: "JPY",
CN: "CNY",
KR: "KRW",
IN: "INR",
BR: "BRL",
MX: "MXN",
CH: "CHF",
SE: "SEK",
NO: "NOK",
DK: "DKK",
PL: "PLN",
RU: "RUB",
ZA: "ZAR",
SG: "SGD",
HK: "HKD",
TW: "TWD",
TH: "THB",
MY: "MYR",
PH: "PHP",
ID: "IDR",
VN: "VND",
AE: "AED",
SA: "SAR",
IL: "ILS",
TR: "TRY"
}[r] || "USD";
}
function se(e, t) {
if (!e) return String(e || "Unknown");
const r = String(e);
if (r.match(/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}:\d{2}/)) {
let n = r;
r.includes(" ") && (n = r.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !n.endsWith("Z") && !n.includes("+") && (n = n + "Z");
const i = new Date(n);
if (isNaN(i.getTime()))
return r;
const s = i.getUTCFullYear(), a = String(i.getUTCMonth() + 1).padStart(2, "0"), l = String(i.getUTCDate()).padStart(2, "0"), d = i.getUTCHours(), c = i.getUTCMinutes();
if (t)
switch (t.toLowerCase()) {
case "year":
return `${s}`;
case "quarter": {
const h = Math.floor(i.getUTCMonth() / 3) + 1;
return `${s}-Q${h}`;
}
case "month":
return `${s}-${a}`;
case "week":
return `${s}-${a}-${l}`;
case "day":
return `${s}-${a}-${l}`;
case "hour":
return `${s}-${a}-${l} ${String(d).padStart(2, "0")}:00`;
case "minute":
return `${s}-${a}-${l} ${String(d).padStart(2, "0")}:${String(c).padStart(2, "0")}`;
}
const u = i.getUTCSeconds(), f = i.getUTCMilliseconds();
if (l === "01" && d === 0 && c === 0 && u === 0 && f === 0) {
if (a === "01" || a === "04" || a === "07" || a === "10") {
const h = Math.floor(i.getUTCMonth() / 3) + 1;
return `${s}-Q${h}`;
}
return `${s}-${a}`;
}
return d === 0 && c === 0 && u === 0 && f === 0 ? `${s}-${a}-${l}` : c === 0 && u === 0 && f === 0 ? `${s}-${a}-${l} ${String(d).padStart(2, "0")}:00` : `${s}-${a}-${l} ${String(d).padStart(2, "0")}:${String(c).padStart(2, "0")}`;
}
return r;
}
function be(e, t) {
try {
if (e?.timeDimensions) {
const n = e.timeDimensions.find((i) => t === i.dimension || t.startsWith(i.dimension.replace(".", "_")) || t === `${i.dimension}_${i.granularity}`);
if (n?.granularity)
return n.granularity;
}
const r = t.match(/_([a-z]+)$/);
if (r) {
const n = r[1];
if (["year", "quarter", "month", "week", "day", "hour", "minute", "second"].includes(n))
return n;
}
return;
} catch {
return;
}
}
function us(e, t, r, n, i = (s) => s) {
if (!e || e.length === 0) return [];
const s = be(n, t);
return e.map((a) => {
const l = {
name: se(a[t], s) || a[t] || "Unknown"
};
return r.forEach((d) => {
const c = i(d);
l[c] = Ve(a[d]);
}), l;
});
}
function Ze(e, t, r, n, i, s = (a) => a) {
if (!e || e.length === 0)
return { data: [], seriesKeys: [], hasDimensions: !1 };
const a = n || {}, l = [
...a.dimensions || [],
...a.timeDimensions?.map((m) => m.dimension) || []
], d = a.measures || [], c = r.filter((m) => d.includes(m)), u = (i || []).filter((m) => l.includes(m));
if (u.length > 0) {
const m = {};
e.forEach((k) => {
const x = be(n, t), v = se(k[t], x) || k[t] || "Unknown";
m[v] || (m[v] = { name: String(v) }), c.forEach((S) => {
const b = s(S), g = Ve(k[S]);
if (g !== null) {
const C = m[v][b];
m[v][b] = C == null ? g : C + g;
} else b in m[v] || (m[v][b] = null);
}), u.forEach((S) => {
const b = k[S];
if (b != null) {
const g = String(b), C = c[0] || d.find(
(_) => _.includes("totalCost") || _.includes("count") || _.includes("sum")
) || d[0];
if (C) {
const _ = Ve(k[C]);
if (_ !== null) {
const D = m[v][g];
m[v][g] = D == null ? _ : D + _;
} else g in m[v] || (m[v][g] = null);
}
}
});
});
const N = Object.values(m), w = Array.from(new Set(
e.flatMap(
(k) => u.map((x) => {
const v = k[x];
return v != null ? String(v) : null;
}).filter((x) => x !== null)
)
));
return {
data: N,
seriesKeys: w,
hasDimensions: !0
};
}
const f = us(e, t, r, n, s), h = r.map((m) => s(m));
return {
data: f,
seriesKeys: h,
hasDimensions: !1
};
}
function fs() {
const e = typeof navigator < "u" ? navigator.language : "en-US";
return new Intl.NumberFormat(e, {
style: "currency",
currency: ms(e),
currencyDisplay: "narrowSymbol"
}).format(0).replace(/[\d.,\s]/g, "").trim() || "$";
}
function ms(e) {
const r = e.split("-")[1]?.toUpperCase();
return {
US: "USD",
CA: "CAD",
GB: "GBP",
UK: "GBP",
AU: "AUD",
NZ: "NZD",
EU: "EUR",
DE: "EUR",
FR: "EUR",
IT: "EUR",
ES: "EUR",
NL: "EUR",
BE: "EUR",
AT: "EUR",
IE: "EUR",
PT: "EUR",
FI: "EUR",
JP: "JPY",
CN: "CNY",
KR: "KRW",
IN: "INR",
BR: "BRL",
MX: "MXN",
CH: "CHF",
SE: "SEK",
NO: "NOK",
DK: "DKK",
PL: "PLN",
RU: "RUB",
ZA: "ZAR",
SG: "SGD",
HK: "HKD",
TW: "TWD",
TH: "THB",
MY: "MYR",
PH: "PHP",
ID: "IDR",
VN: "VND",
AE: "AED",
SA: "SAR",
IL: "ILS",
TR: "TRY"
}[r] || "USD";
}
function bc({
value: e,
onChange: t,
axisLabel: r,
previewValue: n = 125e4
}) {
const i = e || {}, s = Q(() => fs(), []), a = Q(() => B(n, i), [n, i]), l = (c) => {
t({ ...i, ...c });
}, d = [
{ value: "currency", label: s },
{ value: "percent", label: "%" },
{ value: "number", label: "#" },
{ value: "custom", label: "Custom" }
];
return /* @__PURE__ */ A("div", { className: "space-y-3 pb-4", children: [
/* @__PURE__ */ o(Ki, { children: r }),
/* @__PURE__ */ A("div", { className: "space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Label" }),
/* @__PURE__ */ o(
"input",
{
type: "text",
value: i.label || "",
onChange: (c) => l({ label: c.target.value || void 0 }),
placeholder: "Auto-generated label",
className: "w-full px-2 py-1 text-sm border border-dc-border rounded-sm focus:ring-dc-accent focus:border-dc-accent bg-dc-surface text-dc-text"
}
)
] }),
/* @__PURE__ */ A("div", { className: "space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Unit" }),
/* @__PURE__ */ o("div", { className: "flex border border-dc-border rounded-sm overflow-hidden", children: d.map((c) => /* @__PURE__ */ o(
"button",
{
type: "button",
onClick: () => l({ unit: c.value }),
className: `flex-1 px-2 py-1.5 text-sm font-medium transition-colors ${i.unit === c.value ? "bg-dc-primary text-white" : "bg-dc-surface text-dc-text hover:bg-dc-border"}`,
children: c.label
},
c.value
)) })
] }),
i.unit === "custom" && /* @__PURE__ */ A("div", { className: "flex gap-2", children: [
/* @__PURE__ */ A("div", { className: "flex-1 space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Prefix" }),
/* @__PURE__ */ o(
"input",
{
type: "text",
value: i.customPrefix || "",
onChange: (c) => l({ customPrefix: c.target.value || void 0 }),
placeholder: "e.g., $",
className: "w-full px-2 py-1 text-sm border border-dc-border rounded-sm focus:ring-dc-accent focus:border-dc-accent bg-dc-surface text-dc-text"
}
)
] }),
/* @__PURE__ */ A("div", { className: "flex-1 space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Suffix" }),
/* @__PURE__ */ o(
"input",
{
type: "text",
value: i.customSuffix || "",
onChange: (c) => l({ customSuffix: c.target.value || void 0 }),
placeholder: "e.g., units",
className: "w-full px-2 py-1 text-sm border border-dc-border rounded-sm focus:ring-dc-accent focus:border-dc-accent bg-dc-surface text-dc-text"
}
)
] })
] }),
/* @__PURE__ */ A("div", { className: "space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Abbreviation" }),
/* @__PURE__ */ A("div", { className: "flex border border-dc-border rounded-sm overflow-hidden", children: [
/* @__PURE__ */ o(
"button",
{
type: "button",
onClick: () => l({ abbreviate: !0 }),
className: `flex-1 px-3 py-1.5 text-sm font-medium transition-colors ${i.abbreviate !== !1 ? "bg-dc-primary text-white" : "bg-dc-surface text-dc-text hover:bg-dc-border"}`,
children: "Yes"
}
),
/* @__PURE__ */ o(
"button",
{
type: "button",
onClick: () => l({ abbreviate: !1 }),
className: `flex-1 px-3 py-1.5 text-sm font-medium transition-colors ${i.abbreviate === !1 ? "bg-dc-primary text-white" : "bg-dc-surface text-dc-text hover:bg-dc-border"}`,
children: "No"
}
)
] })
] }),
/* @__PURE__ */ A("div", { className: "space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Decimals" }),
/* @__PURE__ */ A("div", { className: "flex gap-2", children: [
/* @__PURE__ */ o(
"button",
{
type: "button",
onClick: () => {
const c = i.decimals ?? 2;
c > 0 && l({ decimals: c - 1 });
},
disabled: (i.decimals ?? 2) <= 0,
className: "flex-1 px-3 py-2 text-sm border border-dc-border rounded-sm bg-dc-surface text-dc-text hover:bg-dc-border disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
children: "← .0"
}
),
/* @__PURE__ */ o(
"button",
{
type: "button",
onClick: () => {
const c = i.decimals ?? 2;
c < 4 && l({ decimals: c + 1 });
},
disabled: (i.decimals ?? 2) >= 4,
className: "flex-1 px-3 py-2 text-sm border border-dc-border rounded-sm bg-dc-surface text-dc-text hover:bg-dc-border disabled:opacity-40 disabled:cursor-not-allowed transition-colors",
children: ".00 →"
}
)
] })
] }),
/* @__PURE__ */ A("div", { className: "space-y-1", children: [
/* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Preview" }),
/* @__PURE__ */ o("div", { className: "text-sm font-mono text-dc-text", children: a })
] })
] });
}
function ve() {
const e = xt(Yt);
if (!e)
throw new Error("useCubeFieldLabel must be used within CubeProvider");
return Q(() => e.getFieldLabel, [e.getFieldLabel]);
}
function vc(e) {
return typeof window > "u" ? "" : getComputedStyle(document.documentElement).getPropertyValue(`--dc-${e}`).trim();
}
function hs(e, t) {
typeof window > "u" || document.documentElement.style.setProperty(`--dc-${e}`, t);
}
function wc(e) {
typeof window > "u" || Object.entries(e.colors).forEach(([t, r]) => {
if (r) {
const n = t.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
hs(n, r);
}
});
}
function Nc() {
if (typeof window > "u") return;
const e = document.documentElement.style;
Array.from(e).forEach((r) => {
r.startsWith("--dc-") && e.removeProperty(r);
});
}
function Pe() {
if (typeof window > "u") return "light";
const e = localStorage.getItem("theme");
if (e === "dark" || e === "neon" || e === "light")
return e;
const t = document.documentElement.getAttribute("data-theme");
return t === "dark" || t === "neon" ? t : document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") ? "dark" : document.documentElement.classList.contains("neon") || document.body.classList.contains("neon") ? "neon" : window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
function xs(e) {
typeof window > "u" || (document.documentElement.classList.remove("dark", "neon"), document.documentElement.setAttribute("data-theme", e), (e === "dark" || e === "neon") && document.documentElement.classList.add(e), localStorage.setItem("theme", e));
}
function Ac() {
const e = Pe();
return e === "dark" || e === "neon";
}
function Ir(e) {
if (typeof window > "u") return () => {
};
const t = new MutationObserver(() => {
e(Pe());
});
t.observe(document.documentElement, {
attributes: !0,
attributeFilter: ["class", "data-theme"]
});
const r = window.matchMedia("(prefers-color-scheme: dark)"), n = () => e(Pe());
return r.addEventListener("change", n), () => {
t.disconnect(), r.removeEventListener("change", n);
};
}
const kc = {
light: {
name: "light",
colors: {
surface: "#ffffff",
surfaceSecondary: "#f9fafb",
text: "#111827",
textSecondary: "#374151",
textMuted: "#6b7280",
border: "#e5e7eb",
primary: "#3b82f6",
primaryHover: "#2563eb"
}
},
dark: {
name: "dark",
colors: {
surface: "#1e293b",
surfaceSecondary: "#334155",
text: "#f1f5f9",
textSecondary: "#e2e8f0",
textMuted: "#cbd5e1",
border: "#475569",
primary: "#60a5fa",
primaryHover: "#3b82f6"
}
},
neon: {
name: "neon",
colors: {
surface: "#0a0118",
surfaceSecondary: "#1a0f2e",
surfaceTertiary: "#2a1f3e",
text: "#ffffff",
textSecondary: "#e0e0ff",
textMuted: "#b0b0d0",
border: "#ff00ff",
borderSecondary: "#00ffff",
primary: "#00ffff",
primaryHover: "#00cccc",
primaryContent: "#000000",
success: "#00ff00",
warning: "#ffff00",
error: "#ff0066",
info: "#00ffff",
danger: "#ff1493"
}
}
}, nt = {
listeners: /* @__PURE__ */ new Set(),
subscribe(e) {
return this.listeners.add(e), () => this.listeners.delete(e);
},
notify() {
this.listeners.forEach((e) => e());
}
};
Ir(() => {
nt.notify();
});
function ps() {
const e = fn(
nt.subscribe.bind(nt),
Pe,
// Client-side snapshot
Pe
// Server-side snapshot (SSR)
), t = Le((r) => {
xs(r), nt.notify();
}, []);
return { theme: e, setTheme: t };
}
const W = [
"#3b82f6",
// blue
"#10b981",
// green
"#f59e0b",
// yellow
"#ef4444",
// red
"#8b5cf6",
// purple
"#f97316",
// orange
"#06b6d4",
// cyan
"#84cc16"
// lime
], Ce = [
"#440154",
// dark purple
"#414487",
// purple-blue
"#2a788e",
// teal
"#22a884",
// green-teal
"#7ad151",
// green
"#fde725"
// yellow
], nr = "#10b981", ys = "#ef4444", je = {
top: 5,
right: 30,
left: 20,
bottom: 5
};
function gs(e, t) {
const r = new Date(e);
switch (t.toLowerCase()) {
case "day":
r.setHours(23, 59, 59, 999);
break;
case "week": {
const i = 6 - r.getDay();
r.setDate(r.getDate() + i), r.setHours(23, 59, 59, 999);
break;
}
case "month":
r.setMonth(r.getMonth() + 1, 0), r.setHours(23, 59, 59, 999);
break;
case "quarter": {
const n = r.getMonth(), i = Math.floor(n / 3) * 3 + 2;
r.setMonth(i + 1, 0), r.setHours(23, 59, 59, 999);
break;
}
case "year":
r.setMonth(11, 31), r.setHours(23, 59, 59, 999);
break;
default:
r.setHours(23, 59, 59, 999);
}
return r;
}
function bs(e, t, r) {
if (!e || !t || !r)
return !0;
const n = e[t];
if (!n)
return !0;
const i = new Date(n);
return isNaN(i.getTime()) ? !0 : gs(i, r) <= /* @__PURE__ */ new Date();
}
function vs(e, t) {
if (!e?.timeDimensions || e.timeDimensions.length === 0)
return null;
if (t) {
const n = e.timeDimensions.find(
(i) => i.dimension === t || i.dimension?.includes(t) || t?.includes(i.dimension)
);
if (n?.granularity)
return n.granularity;
}
return e.timeDimensions[0]?.granularity || null;
}
function Vr(e, t, r, n, i = !1) {
const s = {
filteredData: e,
excludedIncompletePeriod: !1,
skippedLastPeriod: !1,
granularity: null
};
if (e.length < 2)
return s;
const a = vs(r, t);
if (i)
return {
filteredData: e.slice(0, -1),
excludedIncompletePeriod: !1,
skippedLastPeriod: !0,
granularity: a
};
if (!n)
return { ...s, granularity: a };
if (!t)
return { ...s, granularity: a };
if (!r?.timeDimensions || r.timeDimensions.length === 0)
return { ...s, granularity: a };
if (!a)
return s;
const l = e[e.length - 1];
return bs(l, t, a) ? { ...s, granularity: a } : {
filteredData: e.slice(0, -1),
excludedIncompletePeriod: !0,
skippedLastPeriod: !1,
granularity: a
};
}
function ws(e) {
if (!e) return [];
const t = [];
return e.dimensions && t.push(...e.dimensions), e.timeDimensions && e.timeDimensions.forEach((r) => {
t.includes(r.dimension) || t.push(r.dimension);
}), e.measures && t.push(...e.measures), t;
}
function Ns(e, t) {
if (!e?.timeDimensions?.length) return null;
const r = e.timeDimensions.find((s) => s.granularity);
if (!r?.granularity || !e.measures?.length) return null;
let n, i;
if (t && t.length > 0) {
n = t.filter((a) => !(a === r.dimension || e.measures?.includes(a)));
const s = t.filter(
(a) => e.measures?.includes(a)
);
i = s.length > 0 ? s : e.measures;
} else
n = e.dimensions || [], i = e.measures;
return i.length === 0 ? null : {
timeDimension: r.dimension,
granularity: r.granularity,
dimensions: n,
measures: i
};
}
function As(e, t, r) {
const n = /* @__PURE__ */ new Set();
return e.forEach((i) => {
const s = i[t];
if (s != null) {
const a = se(s, r);
n.add(a);
}
}), Array.from(n).sort();
}
function ks(e, t, r) {
const n = [];
return e.measures.length > 1 && n.push({
key: "__measure__",
label: "Measure",
isTimeColumn: !1,
isMeasureColumn: !0
}), e.dimensions.forEach((i) => {
n.push({
key: i,
label: r(i),
isTimeColumn: !1
});
}), t.forEach((i) => {
n.push({
key: i,
label: i,
isTimeColumn: !0
});
}), n;
}
function Ss(e, t) {
const r = /* @__PURE__ */ new Map();
return e.forEach((n) => {
const i = t.dimensions.length > 0 ? t.dimensions.map((a) => String(n[a] ?? "")).join("|") : "__all__";
r.has(i) || r.set(i, /* @__PURE__ */ new Map());
const s = n[t.timeDimension];
if (s != null) {
const a = se(s, t.granularity);
r.get(i).set(a, n);
}
}), r;
}
function Fs(e, t, r, n) {
const i = Ss(e, t), s = Array.from(i.keys()), a = [], l = t.measures.length, d = s.length;
return t.measures.forEach((c) => {
s.forEach((u, f) => {
const h = i.get(u), m = l > 1 ? `${c}|${u}` : u, N = {}, w = u === "__all__" ? [] : u.split("|");
t.dimensions.forEach((v, S) => {
N[v] = w[S] ?? "";
}), l > 1 && (N.__measure__ = n(c)), r.forEach((v) => {
const S = h.get(v);
N[v] = S?.[c] ?? null;
});
const k = f === 0, x = k && l > 1 ? d : void 0;
a.push({
id: m,
measureField: c,
values: N,
isFirstInGroup: k,
dimensionRowSpan: x
});
});
}), a;
}
function Ts(e, t, r, n) {
if (!e || e.length === 0)
return { isPivoted: !0, columns: [], rows: [] };
const i = As(e, t.timeDimension, t.granularity), s = ks(t, i, r), a = Fs(e, t, i, r);
return { isPivoted: !0, columns: s, rows: a };
}
function Ms(e, t) {
if (t?.cubes)
for (const r of t.cubes) {
const n = r.measures.find((i) => i.name === e);
if (n)
return n.type;
}
}
function $e({ children: e, height: t = "100%" }) {
const r = pe(null), [n, i] = X(!1), [s, a] = X({ width: 0, height: 0 });
Vt(() => {
let l = !0, d = null;
const c = () => {
if (!l || !r.current) return;
const u = r.current.getBoundingClientRect(), f = Math.max(r.current.clientWidth, u.width), h = Math.max(r.current.clientHeight, u.height);
f > 0 && h > 0 && (a({ width: f, height: h }), i(!0));
};
return d = new ResizeObserver((u) => {
for (const f of u) {
const { width: h, height: m } = f.contentRect;
h > 0 && m > 0 && (a({ width: h, height: m }), n || i(!0));
}
}), r.current && (d.observe(r.current), c()), () => {
l = !1, d?.disconnect();
};
}, [n]);
try {
if (t === "100%")
return /* @__PURE__ */ o(
"div",
{
ref: r,
className: "w-full h-full flex-1 flex flex-col relative",
style: { minHeight: "250px", minWidth: "100px", overflow: "hidden" },
children: n && s.width > 0 && s.height > 0 ? /* @__PURE__ */ o(
qt,
{
width: s.width,
height: s.height - 16,
debounce: 100,
style: { marginTop: "16px" },
children: e
}
) : /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ o(rr, { size: "sm" }) })
}
);
const l = {
height: typeof t == "number" ? `${t}px` : t,
width: "100%",
minHeight: "200px",
minWidth: "100px"
};
return /* @__PURE__ */ o(
"div",
{
ref: r,
className: "w-full flex flex-col relative",
style: { ...l, overflow: "hidden" },
children: n && s.width > 0 && s.height > 0 ? /* @__PURE__ */ o(
qt,
{
width: s.width,
height: s.height - 16,
debounce: 100,
style: { marginTop: "16px" },
children: e
}
) : /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full h-full", children: /* @__PURE__ */ o(rr, { size: "sm" }) })
}
);
} catch (l) {
return /* @__PURE__ */ A(
"div",
{
className: "flex flex-col items-center justify-center w-full h-full p-4 text-center border border-dashed rounded-lg",
style: { height: t, borderColor: "var(--dc-border)", backgroundColor: "var(--dc-surface)" },
children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1 text-dc-text-muted", children: "Unable to display chart" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: l instanceof Error ? l.message : "Failed to create responsive container" })
]
}
);
}
}
const _s = (e, t) => e == null ? ["No data", t] : [Rr(e), t];
function He({ formatter: e, labelFormatter: t }) {
return /* @__PURE__ */ o(
$r,
{
formatter: e || _s,
labelFormatter: t,
contentStyle: {
backgroundColor: "white",
border: "1px solid #e5e7eb",
borderRadius: "0.5rem",
fontSize: "0.875rem",
color: "#1f2937",
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
padding: "8px 12px"
}
}
);
}
function bt(e) {
if (!e || typeof e != "string")
return [];
const t = e.trim();
if (!t)
return [];
try {
const r = t.split(",").map((n) => n.trim()).filter((n) => n !== "").map((n) => {
const i = parseFloat(n);
if (isNaN(i))
throw new Error(`Invalid numeric value: ${n}`);
return i;
});
return r.length > 0 ? r : [];
} catch (r) {
return console.warn("Failed to parse target values:", r), [];
}
}
function Pt(e, t) {
if (e.length === 0 || t <= 0)
return [];
if (e.length === 1)
return new Array(t).fill(e[0]);
const r = [], n = Math.floor(t / e.length), i = t % e.length;
let s = 0;
for (let a = 0; a < e.length; a++) {
const l = n + (a < i ? 1 : 0);
for (let d = 0; d < l; d++)
r[s++] = e[a];
}
return r;
}
function $s(e, t) {
return t === 0 ? e === 0 ? 0 : e > 0 ? 100 : -100 : (e - t) / t * 100;
}
function Ds(e, t = 1) {
return `${e >= 0 ? "+" : ""}${e.toFixed(t)}%`;
}
const Cs = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null), c = ve(), u = n?.stackType ?? (n?.stacked ? "normal" : "none"), f = u !== "none", h = u === "percent", m = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0
}, N = n?.leftYAxisFormat, w = n?.rightYAxisFormat;
let k, x = [], v = [], S = null;
r?.xAxis && r?.yAxis ? (k = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, x = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], v = r.series || []) : r?.x && r?.y ? (k = r.x, x = Array.isArray(r.y) ? r.y : [r.y]) : S = "Invalid or missing chart axis configuration", !S && (!k || !x || x.length === 0) && (S = "Missing required X-axis or Y-axis fields");
const { data: b, seriesKeys: g } = Q(() => S || !t || t.length === 0 || !k ? { data: [], seriesKeys: [] } : Ze(
t,
k,
x,
i,
v,
c
), [t, k, x, i, v, c, S]), C = Q(
() => r?.yAxisAssignment || {},
[r?.yAxisAssignment]
), _ = Q(() => {
const M = {};
return x.forEach((E) => {
const V = c(E);
M[V] = E;
}), M;
}, [x, c]), D = x.some((M) => C[M] === "right"), T = x.filter((M) => (C[M] || "left") === "left"), y = x.filter((M) => C[M] === "right"), { chartData: p, skippedCount: F } = Q(() => {
if (b.length === 0 || g.length === 0)
return { chartData: [], skippedCount: 0 };
const M = b.filter((V) => g.some((j) => at(V[j]))), E = b.length - M.length;
return { chartData: M, skippedCount: E };
}, [b, g]);
try {
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bar chart" })
] }) });
if (S)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: S })
] }) });
const M = f && !D, E = h && !D, V = E ? "expand" : void 0, j = g.length === 1 && p.some(($) => {
const U = $[g[0]];
return typeof U == "number" && U < 0;
}), q = m.showLegend, z = {
...je,
left: 40,
// Space for left Y-axis label
right: D ? 40 : 20
// Extra space for right Y-axis label if needed
}, Y = bt(n?.target || ""), J = Pt(Y, p.length);
let I = p;
return J.length > 0 && (I = p.map(($, U) => ({
...$,
__target: J[U] || null
}))), !p || p.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for bar chart after transformation" })
] }) }) : /* @__PURE__ */ A("div", { className: "relative w-full", style: { height: s }, children: [
/* @__PURE__ */ o($e, { height: F > 0 ? "calc(100% - 20px)" : "100%", children: /* @__PURE__ */ A(Dr, { data: I, margin: z, stackOffset: V, children: [
m.showGrid && /* @__PURE__ */ o(pt, { strokeDasharray: "3 3" }),
/* @__PURE__ */ o(
yt,
{
dataKey: "name",
tick: { fontSize: 12 },
angle: -45,
textAnchor: "end",
height: 60
}
),
/* @__PURE__ */ o(
Ie,
{
yAxisId: "left",
orientation: "left",
tick: { fontSize: 12 },
tickFormatter: E ? ($) => `${($ * 100).toFixed(0)}%` : N ? ($) => B($, N) : void 0,
domain: E ? [0, 1] : void 0,
label: E ? void 0 : T.length > 0 ? {
value: N?.label || c(T[0]),
angle: -90,
position: "left",
style: { textAnchor: "middle", fontSize: "12px" }
} : void 0
}
),
D && /* @__PURE__ */ o(
Ie,
{
yAxisId: "right",
orientation: "right",
tick: { fontSize: 12 },
tickFormatter: w ? ($) => B($, w) : void 0,
label: y.length > 0 ? {
value: w?.label || c(y[0]),
angle: 90,
position: "right",
style: { textAnchor: "middle", fontSize: "12px" }
} : void 0
}
),
m.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: ($, U) => {
if ($ == null)
return ["No data", U];
if (U === "Target")
return [B($, N), "Target Value"];
if (E && typeof $ == "number")
return [`${($ * 100).toFixed(1)}%`, U];
const O = _[U], ee = (O && C[O] === "right" ? "right" : "left") === "right" ? w : N;
return [B($, ee), U];
}
}
),
q && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
iconType: "rect",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: ($) => d(String($.dataKey || "")),
onMouseLeave: () => d(null)
}
),
g.map(($, U) => {
const O = _[$], G = O && C[O] === "right" ? "right" : "left";
return /* @__PURE__ */ o(
mn,
{
dataKey: $,
yAxisId: G,
stackId: M ? "stack" : void 0,
fill: j ? nr : a?.colors && a.colors[U % a.colors.length] || W[U % W.length],
fillOpacity: l ? l === $ ? 1 : 0.3 : 1,
children: j && p.map((ee, fe) => {
const me = ee[$], we = typeof me == "number" && me < 0 ? ys : nr;
return /* @__PURE__ */ o(
Ot,
{
fill: we,
fillOpacity: l ? l === $ ? 1 : 0.3 : 1
},
`cell-${fe}`
);
})
},
$
);
}),
J.length > 0 && /* @__PURE__ */ A(Rt, { children: [
/* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: "__target",
yAxisId: "left",
stroke: "#ffffff",
strokeWidth: 2,
dot: !1,
activeDot: !1,
connectNulls: !1
}
),
/* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: "__target",
yAxisId: "left",
name: "Target",
stroke: "#8B5CF6",
strokeWidth: 2,
strokeDasharray: "2 3",
dot: !1,
activeDot: !1,
connectNulls: !1
}
)
] })
] }) }),
F > 0 && /* @__PURE__ */ A("div", { className: "text-xs text-dc-text-muted text-center mt-1", children: [
F,
" data point",
F !== 1 ? "s" : "",
" with no values hidden"
] })
] });
} catch (M) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Bar Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: M instanceof Error ? M.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), Sc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Cs
}, Symbol.toStringTag, { value: "Module" })), zs = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null), c = ve();
try {
const u = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0,
connectNulls: n?.connectNulls ?? !1
}, f = n?.leftYAxisFormat, h = n?.rightYAxisFormat;
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in line chart" })
] }) });
let m, N, w = [];
if (r?.xAxis && r?.yAxis)
m = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, N = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], w = r.series || [];
else if (r?.x && r?.y)
m = r.x, N = Array.isArray(r.y) ? r.y : [r.y];
else
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!m || !N || N.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const { data: k, seriesKeys: x } = Ze(
t,
m,
N,
i,
w,
c
), v = Q(
() => r?.yAxisAssignment || {},
[r?.yAxisAssignment]
), S = Q(() => {
const F = {};
return N.forEach((M) => {
const E = c(M);
F[E] = M;
}), F;
}, [N, c]), b = N.some((F) => v[F] === "right"), g = N.filter((F) => (v[F] || "left") === "left"), C = N.filter((F) => v[F] === "right"), _ = u.showLegend, D = {
...je,
left: 40,
// Space for left Y-axis label
right: b ? 40 : 20
// Extra space for right Y-axis label if needed
}, T = bt(n?.target || ""), y = Pt(T, k.length);
let p = k;
return y.length > 0 && (p = k.map((F, M) => ({
...F,
__target: y[M] || null
}))), !k || k.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for line chart after transformation" })
] }) }) : /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ A(hn, { data: p, margin: D, children: [
u.showGrid && /* @__PURE__ */ o(pt, { strokeDasharray: "3 3" }),
/* @__PURE__ */ o(
yt,
{
dataKey: "name",
tick: { fontSize: 12 },
angle: -45,
textAnchor: "end",
height: 60
}
),
/* @__PURE__ */ o(
Ie,
{
yAxisId: "left",
orientation: "left",
tick: { fontSize: 12 },
tickFormatter: f ? (F) => B(F, f) : void 0,
label: g.length > 0 ? {
value: f?.label || c(g[0]),
angle: -90,
position: "left",
style: { textAnchor: "middle", fontSize: "12px" }
} : void 0
}
),
b && /* @__PURE__ */ o(
Ie,
{
yAxisId: "right",
orientation: "right",
tick: { fontSize: 12 },
tickFormatter: h ? (F) => B(F, h) : void 0,
label: C.length > 0 ? {
value: h?.label || c(C[0]),
angle: 90,
position: "right",
style: { textAnchor: "middle", fontSize: "12px" }
} : void 0
}
),
u.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: (F, M) => {
if (F == null)
return ["No data", M];
if (M === "Target")
return [B(F, f), "Target Value"];
const E = S[M], j = (E && v[E] === "right" ? "right" : "left") === "right" ? h : f;
return [B(F, j), M];
}
}
),
_ && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
iconType: "line",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (F) => d(String(F.dataKey || "")),
onMouseLeave: () => d(null)
}
),
x.map((F, M) => {
const E = S[F], V = E && v[E] === "right" ? "right" : "left";
return /* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: F,
yAxisId: V,
stroke: a?.colors && a.colors[M % a.colors.length] || W[M % W.length],
strokeWidth: 2,
dot: { r: 3 },
activeDot: { r: 5 },
strokeOpacity: l ? l === F ? 1 : 0.3 : 1,
connectNulls: u.connectNulls
},
F
);
}),
y.length > 0 && /* @__PURE__ */ A(Rt, { children: [
/* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: "__target",
yAxisId: "left",
stroke: "#ffffff",
strokeWidth: 2,
dot: !1,
activeDot: !1,
connectNulls: !1
}
),
/* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: "__target",
yAxisId: "left",
name: "Target",
stroke: "#8B5CF6",
strokeWidth: 2,
strokeDasharray: "2 3",
dot: !1,
activeDot: !1,
connectNulls: !1
}
)
] })
] }) });
} catch (u) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Line Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), Fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: zs
}, Symbol.toStringTag, { value: "Module" })), Ls = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null), c = ve();
try {
const u = n?.stackType ?? (n?.stacked ? "normal" : "none"), f = u !== "none", h = u === "percent", m = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0,
connectNulls: n?.connectNulls ?? !1
}, N = n?.leftYAxisFormat, w = n?.rightYAxisFormat;
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in area chart" })
] }) });
let k, x, v = [];
if (r?.xAxis && r?.yAxis)
k = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, x = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], v = r.series || [];
else if (r?.x && r?.y)
k = r.x, x = Array.isArray(r.y) ? r.y : [r.y];
else
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!k || !x || x.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const { data: S, seriesKeys: b } = Ze(
t,
k,
x,
i,
v,
c
), g = r?.yAxisAssignment || {}, C = {};
x.forEach((z) => {
const Y = c(z);
C[Y] = z;
});
const _ = x.some((z) => g[z] === "right"), D = x.filter((z) => (g[z] || "left") === "left"), T = x.filter((z) => g[z] === "right"), y = f && !_, p = h && !_, F = m.showLegend, M = {
...je,
left: 40,
// Space for left Y-axis label
right: _ ? 40 : 20
// Extra space for right Y-axis label if needed
}, E = bt(n?.target || ""), V = Pt(E, S.length);
let j = S;
return V.length > 0 && (j = S.map((z, Y) => ({
...z,
__target: V[Y] || null
}))), !S || S.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for area chart after transformation" })
] }) }) : /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ A(Dr, { data: j, margin: M, stackOffset: p ? "expand" : void 0, children: [
m.showGrid && /* @__PURE__ */ o(pt, { strokeDasharray: "3 3" }),
/* @__PURE__ */ o(yt, { dataKey: "name", tick: { fontSize: 12 }, angle: -45, textAnchor: "end", height: 60 }),
/* @__PURE__ */ o(
Ie,
{
yAxisId: "left",
orientation: "left",
tick: { fontSize: 12 },
tickFormatter: p ? (z) => `${(z * 100).toFixed(0)}%` : N ? (z) => B(z, N) : void 0,
domain: p ? [0, 1] : void 0,
label: p ? void 0 : D.length > 0 ? {
value: N?.label || c(D[0]),
angle: -90,
position: "left",
style: { textAnchor: "middle", fontSize: "12px" }
} : void 0
}
),
_ && /* @__PURE__ */ o(
Ie,
{
yAxisId: "right",
orientation: "right",
tick: { fontSize: 12 },
tickFormatter: w ? (z) => B(z, w) : void 0,
label: T.length > 0 ? {
value: w?.label || c(T[0]),
angle: 90,
position: "right",
style: { textAnchor: "middle", fontSize: "12px" }
} : void 0
}
),
m.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: (z, Y) => {
if (z == null)
return ["No data", Y];
if (Y === "Target")
return [B(z, N), "Target Value"];
if (p && typeof z == "number")
return [`${(z * 100).toFixed(1)}%`, Y];
const J = C[Y], $ = (J && g[J] === "right" ? "right" : "left") === "right" ? w : N;
return [B(z, $), Y];
}
}
),
F && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "rect",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (z) => d(String(z.dataKey || "")),
onMouseLeave: () => d(null)
}
),
b.map((z, Y) => {
const J = C[z], I = J && g[J] === "right" ? "right" : "left";
return /* @__PURE__ */ o(
xn,
{
type: "monotone",
dataKey: z,
yAxisId: I,
stackId: y ? "stack" : void 0,
stroke: a?.colors && a.colors[Y % a.colors.length] || W[Y % W.length],
fill: a?.colors && a.colors[Y % a.colors.length] || W[Y % W.length],
fillOpacity: l ? l === z ? 0.6 : 0.1 : 0.3,
strokeWidth: 2,
strokeOpacity: l ? l === z ? 1 : 0.3 : 1,
connectNulls: m.connectNulls
},
z
);
}),
V.length > 0 && /* @__PURE__ */ A(Rt, { children: [
/* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: "__target",
yAxisId: "left",
stroke: "#ffffff",
strokeWidth: 2,
dot: !1,
activeDot: !1,
connectNulls: !1
}
),
/* @__PURE__ */ o(
Ee,
{
type: "monotone",
dataKey: "__target",
yAxisId: "left",
name: "Target",
stroke: "#8B5CF6",
strokeWidth: 2,
strokeDasharray: "2 3",
dot: !1,
activeDot: !1,
connectNulls: !1
}
)
] })
] }) });
} catch (u) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Area Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), Tc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Ls
}, Symbol.toStringTag, { value: "Module" })), Es = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null), c = ve();
try {
const u = {
showLegend: n?.showLegend ?? !0,
showTooltip: n?.showTooltip ?? !0,
leftYAxisFormat: n?.leftYAxisFormat
};
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in pie chart" })
] }) });
let f, h, m, N = [];
if (r?.xAxis && r?.yAxis)
h = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, m = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], N = r.series || [];
else if (r?.x && r?.y)
h = r.x, m = Array.isArray(r.y) ? r.y : [r.y];
else
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "chartConfig.x/y or chartConfig.xAxis/yAxis required for pie chart" })
] }) });
if (!h || !m || m.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
if (N.length > 0) {
const { data: k } = Ze(
t,
h,
m,
i,
N,
c
);
if (f = [], k.length > 0) {
const x = k[0];
Object.keys(x).forEach((v) => {
v !== "name" && typeof x[v] == "number" && f.push({
name: String(v),
value: x[v]
});
});
}
} else {
const k = be(i, h);
f = t.map((x) => {
let v = se(x[h], k) || String(x[h]) || "Unknown";
return typeof x[h] == "boolean" ? v = x[h] ? "Active" : "Inactive" : (v === "true" || v === "false") && (v = v === "true" ? "Active" : "Inactive"), {
name: v,
value: typeof x[m[0]] == "string" ? parseFloat(x[m[0]]) : x[m[0]] || 0
};
});
}
const w = f.length;
return f = f.filter(
(k) => k.value != null && !isNaN(k.value) && k.value !== 0 && k.value > 0
), f.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: w > 0 ? `Filtered out ${w} data points (zero or invalid values)` : "No data points to display in pie chart" })
] }) }) : /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ A(pn, { children: [
/* @__PURE__ */ o(
yn,
{
data: f,
cx: "50%",
cy: "50%",
outerRadius: "70%",
dataKey: "value",
label: u.showLegend ? void 0 : ({ name: k, percent: x }) => `${k} ${((x || 0) * 100).toFixed(0)}%`,
children: f.map((k, x) => /* @__PURE__ */ o(
Ot,
{
fill: a?.colors && a.colors[x % a.colors.length] || W[x % W.length],
fillOpacity: l ? l === f[x].name ? 1 : 0.3 : 1
},
`cell-${x}`
))
}
),
u.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: u.leftYAxisFormat ? (k, x) => [B(k, u.leftYAxisFormat), x] : void 0
}
),
u.showLegend && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "circle",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (k) => d(String(k.value || "")),
onMouseLeave: () => d(null)
}
)
] }) });
} catch (u) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Pie Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), Mc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Es
}, Symbol.toStringTag, { value: "Module" })), Rs = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null), c = ve();
try {
const u = {
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0
}, f = n?.xAxisFormat, h = n?.leftYAxisFormat;
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in scatter chart" })
] }) });
let m, N, w = [];
if (r?.xAxis && r?.yAxis) {
m = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, N = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis;
const T = r.series;
w = T ? Array.isArray(T) ? T : [T] : [];
} else if (r?.x && r?.y)
m = r.x, N = Array.isArray(r.y) ? r.y[0] : r.y;
else
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Invalid or missing chart axis configuration" })
] }) });
if (!m || !N)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Missing required X-axis or Y-axis fields" })
] }) });
const x = (i?.timeDimensions || []).map((T) => T.dimension);
let v, S = {};
if (w.length > 0) {
const T = w[0];
t.forEach((p) => {
const F = String(p[T] || "Default");
S[F] || (S[F] = []);
const M = be(i, m), E = se(p[m], M) || p[m], V = Ve(p[N]), j = typeof E == "string" ? parseFloat(E) : E;
if (at(j) && V !== null) {
const q = {};
x.forEach((z) => {
if (p[z]) {
const Y = be(i, z);
q[z] = se(p[z], Y);
}
}), S[F].push({
x: j,
y: V,
name: F,
timeValues: q,
originalItem: p
});
}
}), v = Object.keys(S).flatMap((p) => S[p]);
} else {
const T = be(i, m);
v = t.map((y) => {
const p = se(y[m], T) || y[m], F = Ve(y[N]), M = typeof p == "string" ? parseFloat(p) : p, E = {};
return x.forEach((V) => {
if (y[V]) {
const j = be(i, V);
E[V] = se(y[V], j);
}
}), {
x: M,
y: F,
name: "Point",
timeValues: E,
originalItem: y,
isValid: at(M) && F !== null
};
}).filter((y) => y.isValid);
}
if (!v || v.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for scatter chart after transformation" })
] }) });
const b = Object.keys(S), C = b.length > 1 && b.length <= 20, _ = u.showLegend && C, D = {
...je,
left: 40
// Increased from 20 to 40 for Y-axis label space
};
return /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ A(gn, { margin: D, children: [
u.showGrid && /* @__PURE__ */ o(pt, { strokeDasharray: "3 3" }),
/* @__PURE__ */ o(
yt,
{
type: "number",
dataKey: "x",
name: f?.label || c(m),
tick: { fontSize: 12 },
tickFormatter: f ? (T) => B(T, f) : void 0
}
),
/* @__PURE__ */ o(
Ie,
{
type: "number",
dataKey: "y",
name: h?.label || c(N),
tick: { fontSize: 12 },
tickFormatter: h ? (T) => B(T, h) : void 0,
label: { value: h?.label || c(N), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
}
),
u.showTooltip && /* @__PURE__ */ o(
$r,
{
cursor: { strokeDasharray: "3 3" },
content: ({ active: T, payload: y }) => {
if (!T || !y || y.length === 0) return null;
const p = y[0]?.payload;
return p ? /* @__PURE__ */ A("div", { style: {
backgroundColor: "white",
border: "1px solid #e5e7eb",
borderRadius: "0.5rem",
fontSize: "0.875rem",
color: "#1f2937",
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",
padding: "8px 12px"
}, children: [
/* @__PURE__ */ o("div", { style: { fontWeight: 600, marginBottom: "4px" }, children: p.name }),
p.timeValues && Object.keys(p.timeValues).length > 0 && /* @__PURE__ */ o("div", { style: { marginBottom: "4px", color: "#6b7280" }, children: Object.entries(p.timeValues).map(([F, M]) => /* @__PURE__ */ A("div", { children: [
c(F),
": ",
M
] }, F)) }),
/* @__PURE__ */ A("div", { children: [
f?.label || c(m),
": ",
B(p.x, f)
] }),
/* @__PURE__ */ A("div", { children: [
h?.label || c(N),
": ",
B(p.y, h)
] })
] }) : null;
}
}
),
_ && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "circle",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (T) => d(String(T.dataKey || "")),
onMouseLeave: () => d(null)
}
),
C ? (
// Multiple series
b.map((T, y) => /* @__PURE__ */ o(
Zt,
{
name: T,
data: S[T],
fill: a?.colors && a.colors[y % a.colors.length] || W[y % W.length],
fillOpacity: l ? l === T ? 1 : 0.3 : 1
},
T
))
) : (
// Single series
/* @__PURE__ */ o(
Zt,
{
name: "Data",
data: v,
fill: a?.colors && a.colors[0] || W[0]
}
)
)
] }) });
} catch (u) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Scatter Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), _c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Rs
}, Symbol.toStringTag, { value: "Module" })), Is = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null);
try {
const c = {
showLegend: n?.showLegend ?? !0,
showTooltip: n?.showTooltip ?? !0,
showGrid: n?.showGrid ?? !0,
leftYAxisFormat: n?.leftYAxisFormat
};
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radar chart" })
] }) });
let u, f = [];
if (r?.xAxis && r?.yAxis) {
const h = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, m = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], N = r.series || [], { data: w, seriesKeys: k } = Ze(
t,
h,
m,
i,
N
);
u = w, f = k;
} else {
const h = t[0], m = Object.keys(h), N = m.find(
(k) => typeof h[k] == "string" || k.toLowerCase().includes("subject") || k.toLowerCase().includes("name") || k.toLowerCase().includes("category")
) || m[0], w = m.filter(
(k) => typeof h[k] == "number" && k !== N
);
if (w.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "No numeric fields found for radar chart values" })
] }) });
if (N) {
const k = be(i, N);
u = t.map((x) => {
const v = {
name: se(x[N], k) || String(x[N]) || "Unknown"
};
return w.forEach((S) => {
const b = S.split(".").pop() || S;
v[b] = typeof x[S] == "string" ? parseFloat(x[S]) : x[S] || 0;
}), v;
}), f = w.map((x) => x.split(".").pop() || x);
} else
u = t.map((k) => ({
name: String(k[m[0]] || "Unknown"),
value: typeof k[w[0]] == "string" ? parseFloat(k[w[0]]) : k[w[0]] || 0
})), f = ["value"];
}
return !u || u.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radar chart after transformation" })
] }) }) : /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ A(bn, { data: u, margin: { top: 20, right: 80, bottom: 20, left: 80 }, children: [
c.showGrid && /* @__PURE__ */ o(vn, {}),
/* @__PURE__ */ o(
wn,
{
dataKey: "name",
tick: { fontSize: 12 },
className: "text-dc-text-muted"
}
),
/* @__PURE__ */ o(
Nn,
{
tick: { fontSize: 10 },
className: "text-dc-text-muted",
tickFormatter: c.leftYAxisFormat ? (h) => B(h, c.leftYAxisFormat) : void 0
}
),
c.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: c.leftYAxisFormat ? (h, m) => [B(h, c.leftYAxisFormat), m] : void 0
}
),
c.showLegend && f.length > 1 && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "rect",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (h) => d(String(h.dataKey || "")),
onMouseLeave: () => d(null)
}
),
f.map((h, m) => /* @__PURE__ */ o(
An,
{
name: h,
dataKey: h,
stroke: a?.colors && a.colors[m % a.colors.length] || W[m % W.length],
fill: a?.colors && a.colors[m % a.colors.length] || W[m % W.length],
fillOpacity: l ? l === h ? 0.6 : 0.1 : 0.3,
strokeOpacity: l ? l === h ? 1 : 0.3 : 1,
strokeWidth: 2
},
h
))
] }) });
} catch (c) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Radar Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: c instanceof Error ? c.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), $c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Is
}, Symbol.toStringTag, { value: "Module" })), Vs = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null);
try {
const c = {
showLegend: n?.showLegend ?? !0,
showTooltip: n?.showTooltip ?? !0,
leftYAxisFormat: n?.leftYAxisFormat
};
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in radial bar chart" })
] }) });
let u;
if (r?.xAxis && r?.yAxis) {
const f = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, h = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis, m = be(i, f);
u = t.map((N, w) => ({
name: se(N[f], m) || String(N[f]) || "Unknown",
value: typeof N[h] == "string" ? parseFloat(N[h]) : N[h] || 0,
fill: a?.colors && a.colors[w % a.colors.length] || W[w % W.length]
}));
} else {
const f = t[0], h = Object.keys(f), m = h.find(
(w) => typeof f[w] == "string" || w.toLowerCase().includes("name") || w.toLowerCase().includes("label") || w.toLowerCase().includes("category")
) || h[0], N = h.find(
(w) => typeof f[w] == "number" && w !== m
) || h[1];
if (!N)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "No numeric field found for radial bar chart values" })
] }) });
u = t.map((w, k) => {
let x = w[m];
return typeof x == "boolean" ? x = x ? "Active" : "Inactive" : x === "true" || x === "false" ? x = x === "true" ? "Active" : "Inactive" : x = String(x), {
name: x,
value: typeof w[N] == "string" ? parseFloat(w[N]) : w[N] || 0,
fill: a?.colors && a.colors[k % a.colors.length] || W[k % W.length]
};
});
}
return u = u.filter((f) => f.value != null && f.value !== 0), u.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for radial bar chart after transformation" })
] }) }) : /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ A(
kn,
{
data: u,
innerRadius: "10%",
outerRadius: "80%",
margin: { top: 20, right: 30, bottom: 20, left: 30 },
children: [
c.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: c.leftYAxisFormat ? (f, h) => [B(f, c.leftYAxisFormat), h] : void 0
}
),
c.showLegend && /* @__PURE__ */ o(
Oe,
{
wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
iconType: "circle",
iconSize: 8,
layout: "horizontal",
align: "center",
verticalAlign: "bottom",
onMouseEnter: (f) => d(String(f.value || "")),
onMouseLeave: () => d(null)
}
),
/* @__PURE__ */ o(
Sn,
{
dataKey: "value",
cornerRadius: 4,
label: {
position: "insideStart",
fill: "#fff",
fontSize: 12,
formatter: c.leftYAxisFormat ? (f) => B(f, c.leftYAxisFormat) : void 0
},
children: u.map((f, h) => /* @__PURE__ */ o(
Ot,
{
fill: f.fill,
fillOpacity: l ? l === f.name ? 1 : 0.3 : 1
},
`cell-${h}`
))
}
)
]
}
) });
} catch (c) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Radial Bar Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: c instanceof Error ? c.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), Dc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Vs
}, Symbol.toStringTag, { value: "Module" }));
function it(e, t) {
return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Os(e, t) {
return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function Or(e) {
let t, r, n;
e.length !== 2 ? (t = it, r = (l, d) => it(e(l), d), n = (l, d) => e(l) - d) : (t = e === it || e === Os ? e : Hs, r = e, n = e);
function i(l, d, c = 0, u = l.length) {
if (c < u) {
if (t(d, d) !== 0) return u;
do {
const f = c + u >>> 1;
r(l[f], d) < 0 ? c = f + 1 : u = f;
} while (c < u);
}
return c;
}
function s(l, d, c = 0, u = l.length) {
if (c < u) {
if (t(d, d) !== 0) return u;
do {
const f = c + u >>> 1;
r(l[f], d) <= 0 ? c = f + 1 : u = f;
} while (c < u);
}
return c;
}
function a(l, d, c = 0, u = l.length) {
const f = i(l, d, c, u - 1);
return f > c && n(l[f - 1], d) > -n(l[f], d) ? f - 1 : f;
}
return { left: i, center: a, right: s };
}
function Hs() {
return 0;
}
function Ys(e) {
return e === null ? NaN : +e;
}
const Ps = Or(it), Hr = Ps.right;
Or(Ys).center;
function ir(e, t) {
let r, n;
if (t === void 0)
for (const i of e)
i != null && (r === void 0 ? i >= i && (r = n = i) : (r > i && (r = i), n < i && (n = i)));
else {
let i = -1;
for (let s of e)
(s = t(s, ++i, e)) != null && (r === void 0 ? s >= s && (r = n = s) : (r > s && (r = s), n < s && (n = s)));
}
return [r, n];
}
class sr extends Map {
constructor(t, r = Bs) {
if (super(), Object.defineProperties(this, { _intern: { value: /* @__PURE__ */ new Map() }, _key: { value: r } }), t != null) for (const [n, i] of t) this.set(n, i);
}
get(t) {
return super.get(ar(this, t));
}
has(t) {
return super.has(ar(this, t));
}
set(t, r) {
return super.set(js(this, t), r);
}
delete(t) {
return super.delete(Us(this, t));
}
}
function ar({ _intern: e, _key: t }, r) {
const n = t(r);
return e.has(n) ? e.get(n) : r;
}
function js({ _intern: e, _key: t }, r) {
const n = t(r);
return e.has(n) ? e.get(n) : (e.set(n, r), r);
}
function Us({ _intern: e, _key: t }, r) {
const n = t(r);
return e.has(n) && (r = e.get(n), e.delete(n)), r;
}
function Bs(e) {
return e !== null && typeof e == "object" ? e.valueOf() : e;
}
const Ws = Math.sqrt(50), Gs = Math.sqrt(10), Ks = Math.sqrt(2);
function ot(e, t, r) {
const n = (t - e) / Math.max(0, r), i = Math.floor(Math.log10(n)), s = n / Math.pow(10, i), a = s >= Ws ? 10 : s >= Gs ? 5 : s >= Ks ? 2 : 1;
let l, d, c;
return i < 0 ? (c = Math.pow(10, -i) / a, l = Math.round(e * c), d = Math.round(t * c), l / c < e && ++l, d / c > t && --d, c = -c) : (c = Math.pow(10, i) * a, l = Math.round(e / c), d = Math.round(t / c), l * c < e && ++l, d * c > t && --d), d < l && 0.5 <= r && r < 2 ? ot(e, t, r * 2) : [l, d, c];
}
function Xs(e, t, r) {
if (t = +t, e = +e, r = +r, !(r > 0)) return [];
if (e === t) return [e];
const n = t < e, [i, s, a] = n ? ot(t, e, r) : ot(e, t, r);
if (!(s >= i)) return [];
const l = s - i + 1, d = new Array(l);
if (n)
if (a < 0) for (let c = 0; c < l; ++c) d[c] = (s - c) / -a;
else for (let c = 0; c < l; ++c) d[c] = (s - c) * a;
else if (a < 0) for (let c = 0; c < l; ++c) d[c] = (i + c) / -a;
else for (let c = 0; c < l; ++c) d[c] = (i + c) * a;
return d;
}
function Mt(e, t, r) {
return t = +t, e = +e, r = +r, ot(e, t, r)[2];
}
function qs(e, t, r) {
t = +t, e = +e, r = +r;
const n = t < e, i = n ? Mt(t, e, r) : Mt(e, t, r);
return (n ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function _t(e, t) {
let r;
if (t === void 0)
for (const n of e)
n != null && (r < n || r === void 0 && n >= n) && (r = n);
else {
let n = -1;
for (let i of e)
(i = t(i, ++n, e)) != null && (r < i || r === void 0 && i >= i) && (r = i);
}
return r;
}
function or(e, t) {
let r;
if (t === void 0)
for (const n of e)
n != null && (r > n || r === void 0 && n >= n) && (r = n);
else {
let n = -1;
for (let i of e)
(i = t(i, ++n, e)) != null && (r > i || r === void 0 && i >= i) && (r = i);
}
return r;
}
function Zs(e) {
return e;
}
var kt = 1, St = 2, $t = 3, We = 4, lr = 1e-6;
function Qs(e) {
return "translate(" + e + ",0)";
}
function Js(e) {
return "translate(0," + e + ")";
}
function ea(e) {
return (t) => +e(t);
}
function ta(e, t) {
return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (r) => +e(r) + t;
}
function ra() {
return !this.__axis;
}
function Yr(e, t) {
var r = [], n = null, i = null, s = 6, a = 6, l = 3, d = typeof window < "u" && window.devicePixelRatio > 1 ? 0 : 0.5, c = e === kt || e === We ? -1 : 1, u = e === We || e === St ? "x" : "y", f = e === kt || e === $t ? Qs : Js;
function h(m) {
var N = n ?? (t.ticks ? t.ticks.apply(t, r) : t.domain()), w = i ?? (t.tickFormat ? t.tickFormat.apply(t, r) : Zs), k = Math.max(s, 0) + l, x = t.range(), v = +x[0] + d, S = +x[x.length - 1] + d, b = (t.bandwidth ? ta : ea)(t.copy(), d), g = m.selection ? m.selection() : m, C = g.selectAll(".domain").data([null]), _ = g.selectAll(".tick").data(N, t).order(), D = _.exit(), T = _.enter().append("g").attr("class", "tick"), y = _.select("line"), p = _.select("text");
C = C.merge(C.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), _ = _.merge(T), y = y.merge(T.append("line").attr("stroke", "currentColor").attr(u + "2", c * s)), p = p.merge(T.append("text").attr("fill", "currentColor").attr(u, c * k).attr("dy", e === kt ? "0em" : e === $t ? "0.71em" : "0.32em")), m !== g && (C = C.transition(m), _ = _.transition(m), y = y.transition(m), p = p.transition(m), D = D.transition(m).attr("opacity", lr).attr("transform", function(F) {
return isFinite(F = b(F)) ? f(F + d) : this.getAttribute("transform");
}), T.attr("opacity", lr).attr("transform", function(F) {
var M = this.parentNode.__axis;
return f((M && isFinite(M = M(F)) ? M : b(F)) + d);
})), D.remove(), C.attr("d", e === We || e === St ? a ? "M" + c * a + "," + v + "H" + d + "V" + S + "H" + c * a : "M" + d + "," + v + "V" + S : a ? "M" + v + "," + c * a + "V" + d + "H" + S + "V" + c * a : "M" + v + "," + d + "H" + S), _.attr("opacity", 1).attr("transform", function(F) {
return f(b(F) + d);
}), y.attr(u + "2", c * s), p.attr(u, c * k).text(w), g.filter(ra).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === St ? "start" : e === We ? "end" : "middle"), g.each(function() {
this.__axis = b;
});
}
return h.scale = function(m) {
return arguments.length ? (t = m, h) : t;
}, h.ticks = function() {
return r = Array.from(arguments), h;
}, h.tickArguments = function(m) {
return arguments.length ? (r = m == null ? [] : Array.from(m), h) : r.slice();
}, h.tickValues = function(m) {
return arguments.length ? (n = m == null ? null : Array.from(m), h) : n && n.slice();
}, h.tickFormat = function(m) {
return arguments.length ? (i = m, h) : i;
}, h.tickSize = function(m) {
return arguments.length ? (s = a = +m, h) : s;
}, h.tickSizeInner = function(m) {
return arguments.length ? (s = +m, h) : s;
}, h.tickSizeOuter = function(m) {
return arguments.length ? (a = +m, h) : a;
}, h.tickPadding = function(m) {
return arguments.length ? (l = +m, h) : l;
}, h.offset = function(m) {
return arguments.length ? (d = +m, h) : d;
}, h;
}
function cr(e) {
return Yr($t, e);
}
function dr(e) {
return Yr(We, e);
}
var Dt = "http://www.w3.org/1999/xhtml";
const ur = {
svg: "http://www.w3.org/2000/svg",
xhtml: Dt,
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
function Pr(e) {
var t = e += "", r = t.indexOf(":");
return r >= 0 && (t = e.slice(0, r)) !== "xmlns" && (e = e.slice(r + 1)), ur.hasOwnProperty(t) ? { space: ur[t], local: e } : e;
}
function na(e) {
return function() {
var t = this.ownerDocument, r = this.namespaceURI;
return r === Dt && t.documentElement.namespaceURI === Dt ? t.createElement(e) : t.createElementNS(r, e);
};
}
function ia(e) {
return function() {
return this.ownerDocument.createElementNS(e.space, e.local);
};
}
function jr(e) {
var t = Pr(e);
return (t.local ? ia : na)(t);
}
function sa() {
}
function Ur(e) {
return e == null ? sa : function() {
return this.querySelector(e);
};
}
function aa(e) {
typeof e != "function" && (e = Ur(e));
for (var t = this._groups, r = t.length, n = new Array(r), i = 0; i < r; ++i)
for (var s = t[i], a = s.length, l = n[i] = new Array(a), d, c, u = 0; u < a; ++u)
(d = s[u]) && (c = e.call(d, d.__data__, u, s)) && ("__data__" in d && (c.__data__ = d.__data__), l[u] = c);
return new ye(n, this._parents);
}
function oa(e) {
return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function la() {
return [];
}
function ca(e) {
return e == null ? la : function() {
return this.querySelectorAll(e);
};
}
function da(e) {
return function() {
return oa(e.apply(this, arguments));
};
}
function ua(e) {
typeof e == "function" ? e = da(e) : e = ca(e);
for (var t = this._groups, r = t.length, n = [], i = [], s = 0; s < r; ++s)
for (var a = t[s], l = a.length, d, c = 0; c < l; ++c)
(d = a[c]) && (n.push(e.call(d, d.__data__, c, a)), i.push(d));
return new ye(n, i);
}
function fa(e) {
return function() {
return this.matches(e);
};
}
function Br(e) {
return function(t) {
return t.matches(e);
};
}
var ma = Array.prototype.find;
function ha(e) {
return function() {
return ma.call(this.children, e);
};
}
function xa() {
return this.firstElementChild;
}
function pa(e) {
return this.select(e == null ? xa : ha(typeof e == "function" ? e : Br(e)));
}
var ya = Array.prototype.filter;
function ga() {
return Array.from(this.children);
}
function ba(e) {
return function() {
return ya.call(this.children, e);
};
}
function va(e) {
return this.selectAll(e == null ? ga : ba(typeof e == "function" ? e : Br(e)));
}
function wa(e) {
typeof e != "function" && (e = fa(e));
for (var t = this._groups, r = t.length, n = new Array(r), i = 0; i < r; ++i)
for (var s = t[i], a = s.length, l = n[i] = [], d, c = 0; c < a; ++c)
(d = s[c]) && e.call(d, d.__data__, c, s) && l.push(d);
return new ye(n, this._parents);
}
function Wr(e) {
return new Array(e.length);
}
function Na() {
return new ye(this._enter || this._groups.map(Wr), this._parents);
}
function lt(e, t) {
this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
lt.prototype = {
constructor: lt,
appendChild: function(e) {
return this._parent.insertBefore(e, this._next);
},
insertBefore: function(e, t) {
return this._parent.insertBefore(e, t);
},
querySelector: function(e) {
return this._parent.querySelector(e);
},
querySelectorAll: function(e) {
return this._parent.querySelectorAll(e);
}
};
function Aa(e) {
return function() {
return e;
};
}
function ka(e, t, r, n, i, s) {
for (var a = 0, l, d = t.length, c = s.length; a < c; ++a)
(l = t[a]) ? (l.__data__ = s[a], n[a] = l) : r[a] = new lt(e, s[a]);
for (; a < d; ++a)
(l = t[a]) && (i[a] = l);
}
function Sa(e, t, r, n, i, s, a) {
var l, d, c = /* @__PURE__ */ new Map(), u = t.length, f = s.length, h = new Array(u), m;
for (l = 0; l < u; ++l)
(d = t[l]) && (h[l] = m = a.call(d, d.__data__, l, t) + "", c.has(m) ? i[l] = d : c.set(m, d));
for (l = 0; l < f; ++l)
m = a.call(e, s[l], l, s) + "", (d = c.get(m)) ? (n[l] = d, d.__data__ = s[l], c.delete(m)) : r[l] = new lt(e, s[l]);
for (l = 0; l < u; ++l)
(d = t[l]) && c.get(h[l]) === d && (i[l] = d);
}
function Fa(e) {
return e.__data__;
}
function Ta(e, t) {
if (!arguments.length) return Array.from(this, Fa);
var r = t ? Sa : ka, n = this._parents, i = this._groups;
typeof e != "function" && (e = Aa(e));
for (var s = i.length, a = new Array(s), l = new Array(s), d = new Array(s), c = 0; c < s; ++c) {
var u = n[c], f = i[c], h = f.length, m = Ma(e.call(u, u && u.__data__, c, n)), N = m.length, w = l[c] = new Array(N), k = a[c] = new Array(N), x = d[c] = new Array(h);
r(u, f, w, k, x, m, t);
for (var v = 0, S = 0, b, g; v < N; ++v)
if (b = w[v]) {
for (v >= S && (S = v + 1); !(g = k[S]) && ++S < N; ) ;
b._next = g || null;
}
}
return a = new ye(a, n), a._enter = l, a._exit = d, a;
}
function Ma(e) {
return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function _a() {
return new ye(this._exit || this._groups.map(Wr), this._parents);
}
function $a(e, t, r) {
var n = this.enter(), i = this, s = this.exit();
return typeof e == "function" ? (n = e(n), n && (n = n.selection())) : n = n.append(e + ""), t != null && (i = t(i), i && (i = i.selection())), r == null ? s.remove() : r(s), n && i ? n.merge(i).order() : i;
}
function Da(e) {
for (var t = e.selection ? e.selection() : e, r = this._groups, n = t._groups, i = r.length, s = n.length, a = Math.min(i, s), l = new Array(i), d = 0; d < a; ++d)
for (var c = r[d], u = n[d], f = c.length, h = l[d] = new Array(f), m, N = 0; N < f; ++N)
(m = c[N] || u[N]) && (h[N] = m);
for (; d < i; ++d)
l[d] = r[d];
return new ye(l, this._parents);
}
function Ca() {
for (var e = this._groups, t = -1, r = e.length; ++t < r; )
for (var n = e[t], i = n.length - 1, s = n[i], a; --i >= 0; )
(a = n[i]) && (s && a.compareDocumentPosition(s) ^ 4 && s.parentNode.insertBefore(a, s), s = a);
return this;
}
function za(e) {
e || (e = La);
function t(f, h) {
return f && h ? e(f.__data__, h.__data__) : !f - !h;
}
for (var r = this._groups, n = r.length, i = new Array(n), s = 0; s < n; ++s) {
for (var a = r[s], l = a.length, d = i[s] = new Array(l), c, u = 0; u < l; ++u)
(c = a[u]) && (d[u] = c);
d.sort(t);
}
return new ye(i, this._parents).order();
}
function La(e, t) {
return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Ea() {
var e = arguments[0];
return arguments[0] = this, e.apply(null, arguments), this;
}
function Ra() {
return Array.from(this);
}
function Ia() {
for (var e = this._groups, t = 0, r = e.length; t < r; ++t)
for (var n = e[t], i = 0, s = n.length; i < s; ++i) {
var a = n[i];
if (a) return a;
}
return null;
}
function Va() {
let e = 0;
for (const t of this) ++e;
return e;
}
function Oa() {
return !this.node();
}
function Ha(e) {
for (var t = this._groups, r = 0, n = t.length; r < n; ++r)
for (var i = t[r], s = 0, a = i.length, l; s < a; ++s)
(l = i[s]) && e.call(l, l.__data__, s, i);
return this;
}
function Ya(e) {
return function() {
this.removeAttribute(e);
};
}
function Pa(e) {
return function() {
this.removeAttributeNS(e.space, e.local);
};
}
function ja(e, t) {
return function() {
this.setAttribute(e, t);
};
}
function Ua(e, t) {
return function() {
this.setAttributeNS(e.space, e.local, t);
};
}
function Ba(e, t) {
return function() {
var r = t.apply(this, arguments);
r == null ? this.removeAttribute(e) : this.setAttribute(e, r);
};
}
function Wa(e, t) {
return function() {
var r = t.apply(this, arguments);
r == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, r);
};
}
function Ga(e, t) {
var r = Pr(e);
if (arguments.length < 2) {
var n = this.node();
return r.local ? n.getAttributeNS(r.space, r.local) : n.getAttribute(r);
}
return this.each((t == null ? r.local ? Pa : Ya : typeof t == "function" ? r.local ? Wa : Ba : r.local ? Ua : ja)(r, t));
}
function Gr(e) {
return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function Ka(e) {
return function() {
this.style.removeProperty(e);
};
}
function Xa(e, t, r) {
return function() {
this.style.setProperty(e, t, r);
};
}
function qa(e, t, r) {
return function() {
var n = t.apply(this, arguments);
n == null ? this.style.removeProperty(e) : this.style.setProperty(e, n, r);
};
}
function Za(e, t, r) {
return arguments.length > 1 ? this.each((t == null ? Ka : typeof t == "function" ? qa : Xa)(e, t, r ?? "")) : Qa(this.node(), e);
}
function Qa(e, t) {
return e.style.getPropertyValue(t) || Gr(e).getComputedStyle(e, null).getPropertyValue(t);
}
function Ja(e) {
return function() {
delete this[e];
};
}
function eo(e, t) {
return function() {
this[e] = t;
};
}
function to(e, t) {
return function() {
var r = t.apply(this, arguments);
r == null ? delete this[e] : this[e] = r;
};
}
function ro(e, t) {
return arguments.length > 1 ? this.each((t == null ? Ja : typeof t == "function" ? to : eo)(e, t)) : this.node()[e];
}
function Kr(e) {
return e.trim().split(/^|\s+/);
}
function jt(e) {
return e.classList || new Xr(e);
}
function Xr(e) {
this._node = e, this._names = Kr(e.getAttribute("class") || "");
}
Xr.prototype = {
add: function(e) {
var t = this._names.indexOf(e);
t < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
},
remove: function(e) {
var t = this._names.indexOf(e);
t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
},
contains: function(e) {
return this._names.indexOf(e) >= 0;
}
};
function qr(e, t) {
for (var r = jt(e), n = -1, i = t.length; ++n < i; ) r.add(t[n]);
}
function Zr(e, t) {
for (var r = jt(e), n = -1, i = t.length; ++n < i; ) r.remove(t[n]);
}
function no(e) {
return function() {
qr(this, e);
};
}
function io(e) {
return function() {
Zr(this, e);
};
}
function so(e, t) {
return function() {
(t.apply(this, arguments) ? qr : Zr)(this, e);
};
}
function ao(e, t) {
var r = Kr(e + "");
if (arguments.length < 2) {
for (var n = jt(this.node()), i = -1, s = r.length; ++i < s; ) if (!n.contains(r[i])) return !1;
return !0;
}
return this.each((typeof t == "function" ? so : t ? no : io)(r, t));
}
function oo() {
this.textContent = "";
}
function lo(e) {
return function() {
this.textContent = e;
};
}
function co(e) {
return function() {
var t = e.apply(this, arguments);
this.textContent = t ?? "";
};
}
function uo(e) {
return arguments.length ? this.each(e == null ? oo : (typeof e == "function" ? co : lo)(e)) : this.node().textContent;
}
function fo() {
this.innerHTML = "";
}
function mo(e) {
return function() {
this.innerHTML = e;
};
}
function ho(e) {
return function() {
var t = e.apply(this, arguments);
this.innerHTML = t ?? "";
};
}
function xo(e) {
return arguments.length ? this.each(e == null ? fo : (typeof e == "function" ? ho : mo)(e)) : this.node().innerHTML;
}
function po() {
this.nextSibling && this.parentNode.appendChild(this);
}
function yo() {
return this.each(po);
}
function go() {
this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function bo() {
return this.each(go);
}
function vo(e) {
var t = typeof e == "function" ? e : jr(e);
return this.select(function() {
return this.appendChild(t.apply(this, arguments));
});
}
function wo() {
return null;
}
function No(e, t) {
var r = typeof e == "function" ? e : jr(e), n = t == null ? wo : typeof t == "function" ? t : Ur(t);
return this.select(function() {
return this.insertBefore(r.apply(this, arguments), n.apply(this, arguments) || null);
});
}
function Ao() {
var e = this.parentNode;
e && e.removeChild(this);
}
function ko() {
return this.each(Ao);
}
function So() {
var e = this.cloneNode(!1), t = this.parentNode;
return t ? t.insertBefore(e, this.nextSibling) : e;
}
function Fo() {
var e = this.cloneNode(!0), t = this.parentNode;
return t ? t.insertBefore(e, this.nextSibling) : e;
}
function To(e) {
return this.select(e ? Fo : So);
}
function Mo(e) {
return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function _o(e) {
return function(t) {
e.call(this, t, this.__data__);
};
}
function $o(e) {
return e.trim().split(/^|\s+/).map(function(t) {
var r = "", n = t.indexOf(".");
return n >= 0 && (r = t.slice(n + 1), t = t.slice(0, n)), { type: t, name: r };
});
}
function Do(e) {
return function() {
var t = this.__on;
if (t) {
for (var r = 0, n = -1, i = t.length, s; r < i; ++r)
s = t[r], (!e.type || s.type === e.type) && s.name === e.name ? this.removeEventListener(s.type, s.listener, s.options) : t[++n] = s;
++n ? t.length = n : delete this.__on;
}
};
}
function Co(e, t, r) {
return function() {
var n = this.__on, i, s = _o(t);
if (n) {
for (var a = 0, l = n.length; a < l; ++a)
if ((i = n[a]).type === e.type && i.name === e.name) {
this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = s, i.options = r), i.value = t;
return;
}
}
this.addEventListener(e.type, s, r), i = { type: e.type, name: e.name, value: t, listener: s, options: r }, n ? n.push(i) : this.__on = [i];
};
}
function zo(e, t, r) {
var n = $o(e + ""), i, s = n.length, a;
if (arguments.length < 2) {
var l = this.node().__on;
if (l) {
for (var d = 0, c = l.length, u; d < c; ++d)
for (i = 0, u = l[d]; i < s; ++i)
if ((a = n[i]).type === u.type && a.name === u.name)
return u.value;
}
return;
}
for (l = t ? Co : Do, i = 0; i < s; ++i) this.each(l(n[i], t, r));
return this;
}
function Qr(e, t, r) {
var n = Gr(e), i = n.CustomEvent;
typeof i == "function" ? i = new i(t, r) : (i = n.document.createEvent("Event"), r ? (i.initEvent(t, r.bubbles, r.cancelable), i.detail = r.detail) : i.initEvent(t, !1, !1)), e.dispatchEvent(i);
}
function Lo(e, t) {
return function() {
return Qr(this, e, t);
};
}
function Eo(e, t) {
return function() {
return Qr(this, e, t.apply(this, arguments));
};
}
function Ro(e, t) {
return this.each((typeof t == "function" ? Eo : Lo)(e, t));
}
function* Io() {
for (var e = this._groups, t = 0, r = e.length; t < r; ++t)
for (var n = e[t], i = 0, s = n.length, a; i < s; ++i)
(a = n[i]) && (yield a);
}
var Vo = [null];
function ye(e, t) {
this._groups = e, this._parents = t;
}
function Oo() {
return this;
}
ye.prototype = {
constructor: ye,
select: aa,
selectAll: ua,
selectChild: pa,
selectChildren: va,
filter: wa,
data: Ta,
enter: Na,
exit: _a,
join: $a,
merge: Da,
selection: Oo,
order: Ca,
sort: za,
call: Ea,
nodes: Ra,
node: Ia,
size: Va,
empty: Oa,
each: Ha,
attr: Ga,
style: Za,
property: ro,
classed: ao,
text: uo,
html: xo,
raise: yo,
lower: bo,
append: vo,
insert: No,
remove: ko,
clone: To,
datum: Mo,
on: zo,
dispatch: Ro,
[Symbol.iterator]: Io
};
function Ae(e) {
return typeof e == "string" ? new ye([[document.querySelector(e)]], [document.documentElement]) : new ye([[e]], Vo);
}
function Ut(e, t, r) {
e.prototype = t.prototype = r, r.constructor = e;
}
function Jr(e, t) {
var r = Object.create(e.prototype);
for (var n in t) r[n] = t[n];
return r;
}
function Qe() {
}
var Ke = 0.7, ct = 1 / Ke, Ye = "\\s*([+-]?\\d+)\\s*", Xe = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", Se = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Ho = /^#([0-9a-f]{3,8})$/, Yo = new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`), Po = new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`), jo = new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${Xe}\\)$`), Uo = new RegExp(`^rgba\\(${Se},${Se},${Se},${Xe}\\)$`), Bo = new RegExp(`^hsl\\(${Xe},${Se},${Se}\\)$`), Wo = new RegExp(`^hsla\\(${Xe},${Se},${Se},${Xe}\\)$`), fr = {
aliceblue: 15792383,
antiquewhite: 16444375,
aqua: 65535,
aquamarine: 8388564,
azure: 15794175,
beige: 16119260,
bisque: 16770244,
black: 0,
blanchedalmond: 16772045,
blue: 255,
blueviolet: 9055202,
brown: 10824234,
burlywood: 14596231,
cadetblue: 6266528,
chartreuse: 8388352,
chocolate: 13789470,
coral: 16744272,
cornflowerblue: 6591981,
cornsilk: 16775388,
crimson: 14423100,
cyan: 65535,
darkblue: 139,
darkcyan: 35723,
darkgoldenrod: 12092939,
darkgray: 11119017,
darkgreen: 25600,
darkgrey: 11119017,
darkkhaki: 12433259,
darkmagenta: 9109643,
darkolivegreen: 5597999,
darkorange: 16747520,
darkorchid: 10040012,
darkred: 9109504,
darksalmon: 15308410,
darkseagreen: 9419919,
darkslateblue: 4734347,
darkslategray: 3100495,
darkslategrey: 3100495,
darkturquoise: 52945,
darkviolet: 9699539,
deeppink: 16716947,
deepskyblue: 49151,
dimgray: 6908265,
dimgrey: 6908265,
dodgerblue: 2003199,
firebrick: 11674146,
floralwhite: 16775920,
forestgreen: 2263842,
fuchsia: 16711935,
gainsboro: 14474460,
ghostwhite: 16316671,
gold: 16766720,
goldenrod: 14329120,
gray: 8421504,
green: 32768,
greenyellow: 11403055,
grey: 8421504,
honeydew: 15794160,
hotpink: 16738740,
indianred: 13458524,
indigo: 4915330,
ivory: 16777200,
khaki: 15787660,
lavender: 15132410,
lavenderblush: 16773365,
lawngreen: 8190976,
lemonchiffon: 16775885,
lightblue: 11393254,
lightcoral: 15761536,
lightcyan: 14745599,
lightgoldenrodyellow: 16448210,
lightgray: 13882323,
lightgreen: 9498256,
lightgrey: 13882323,
lightpink: 16758465,
lightsalmon: 16752762,
lightseagreen: 2142890,
lightskyblue: 8900346,
lightslategray: 7833753,
lightslategrey: 7833753,
lightsteelblue: 11584734,
lightyellow: 16777184,
lime: 65280,
limegreen: 3329330,
linen: 16445670,
magenta: 16711935,
maroon: 8388608,
mediumaquamarine: 6737322,
mediumblue: 205,
mediumorchid: 12211667,
mediumpurple: 9662683,
mediumseagreen: 3978097,
mediumslateblue: 8087790,
mediumspringgreen: 64154,
mediumturquoise: 4772300,
mediumvioletred: 13047173,
midnightblue: 1644912,
mintcream: 16121850,
mistyrose: 16770273,
moccasin: 16770229,
navajowhite: 16768685,
navy: 128,
oldlace: 16643558,
olive: 8421376,
olivedrab: 7048739,
orange: 16753920,
orangered: 16729344,
orchid: 14315734,
palegoldenrod: 15657130,
palegreen: 10025880,
paleturquoise: 11529966,
palevioletred: 14381203,
papayawhip: 16773077,
peachpuff: 16767673,
peru: 13468991,
pink: 16761035,
plum: 14524637,
powderblue: 11591910,
purple: 8388736,
rebeccapurple: 6697881,
red: 16711680,
rosybrown: 12357519,
royalblue: 4286945,
saddlebrown: 9127187,
salmon: 16416882,
sandybrown: 16032864,
seagreen: 3050327,
seashell: 16774638,
sienna: 10506797,
silver: 12632256,
skyblue: 8900331,
slateblue: 6970061,
slategray: 7372944,
slategrey: 7372944,
snow: 16775930,
springgreen: 65407,
steelblue: 4620980,
tan: 13808780,
teal: 32896,
thistle: 14204888,
tomato: 16737095,
turquoise: 4251856,
violet: 15631086,
wheat: 16113331,
white: 16777215,
whitesmoke: 16119285,
yellow: 16776960,
yellowgreen: 10145074
};
Ut(Qe, qe, {
copy(e) {
return Object.assign(new this.constructor(), this, e);
},
displayable() {
return this.rgb().displayable();
},
hex: mr,
// Deprecated! Use color.formatHex.
formatHex: mr,
formatHex8: Go,
formatHsl: Ko,
formatRgb: hr,
toString: hr
});
function mr() {
return this.rgb().formatHex();
}
function Go() {
return this.rgb().formatHex8();
}
function Ko() {
return en(this).formatHsl();
}
function hr() {
return this.rgb().formatRgb();
}
function qe(e) {
var t, r;
return e = (e + "").trim().toLowerCase(), (t = Ho.exec(e)) ? (r = t[1].length, t = parseInt(t[1], 16), r === 6 ? xr(t) : r === 3 ? new he(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : r === 8 ? et(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : r === 4 ? et(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = Yo.exec(e)) ? new he(t[1], t[2], t[3], 1) : (t = Po.exec(e)) ? new he(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = jo.exec(e)) ? et(t[1], t[2], t[3], t[4]) : (t = Uo.exec(e)) ? et(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = Bo.exec(e)) ? gr(t[1], t[2] / 100, t[3] / 100, 1) : (t = Wo.exec(e)) ? gr(t[1], t[2] / 100, t[3] / 100, t[4]) : fr.hasOwnProperty(e) ? xr(fr[e]) : e === "transparent" ? new he(NaN, NaN, NaN, 0) : null;
}
function xr(e) {
return new he(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function et(e, t, r, n) {
return n <= 0 && (e = t = r = NaN), new he(e, t, r, n);
}
function Xo(e) {
return e instanceof Qe || (e = qe(e)), e ? (e = e.rgb(), new he(e.r, e.g, e.b, e.opacity)) : new he();
}
function Ct(e, t, r, n) {
return arguments.length === 1 ? Xo(e) : new he(e, t, r, n ?? 1);
}
function he(e, t, r, n) {
this.r = +e, this.g = +t, this.b = +r, this.opacity = +n;
}
Ut(he, Ct, Jr(Qe, {
brighter(e) {
return e = e == null ? ct : Math.pow(ct, e), new he(this.r * e, this.g * e, this.b * e, this.opacity);
},
darker(e) {
return e = e == null ? Ke : Math.pow(Ke, e), new he(this.r * e, this.g * e, this.b * e, this.opacity);
},
rgb() {
return this;
},
clamp() {
return new he(Re(this.r), Re(this.g), Re(this.b), dt(this.opacity));
},
displayable() {
return -0.5 <= this.r && this.r < 255.5 && -0.5 <= this.g && this.g < 255.5 && -0.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
},
hex: pr,
// Deprecated! Use color.formatHex.
formatHex: pr,
formatHex8: qo,
formatRgb: yr,
toString: yr
}));
function pr() {
return `#${ze(this.r)}${ze(this.g)}${ze(this.b)}`;
}
function qo() {
return `#${ze(this.r)}${ze(this.g)}${ze(this.b)}${ze((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function yr() {
const e = dt(this.opacity);
return `${e === 1 ? "rgb(" : "rgba("}${Re(this.r)}, ${Re(this.g)}, ${Re(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function dt(e) {
return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function Re(e) {
return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function ze(e) {
return e = Re(e), (e < 16 ? "0" : "") + e.toString(16);
}
function gr(e, t, r, n) {
return n <= 0 ? e = t = r = NaN : r <= 0 || r >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new ge(e, t, r, n);
}
function en(e) {
if (e instanceof ge) return new ge(e.h, e.s, e.l, e.opacity);
if (e instanceof Qe || (e = qe(e)), !e) return new ge();
if (e instanceof ge) return e;
e = e.rgb();
var t = e.r / 255, r = e.g / 255, n = e.b / 255, i = Math.min(t, r, n), s = Math.max(t, r, n), a = NaN, l = s - i, d = (s + i) / 2;
return l ? (t === s ? a = (r - n) / l + (r < n) * 6 : r === s ? a = (n - t) / l + 2 : a = (t - r) / l + 4, l /= d < 0.5 ? s + i : 2 - s - i, a *= 60) : l = d > 0 && d < 1 ? 0 : a, new ge(a, l, d, e.opacity);
}
function Zo(e, t, r, n) {
return arguments.length === 1 ? en(e) : new ge(e, t, r, n ?? 1);
}
function ge(e, t, r, n) {
this.h = +e, this.s = +t, this.l = +r, this.opacity = +n;
}
Ut(ge, Zo, Jr(Qe, {
brighter(e) {
return e = e == null ? ct : Math.pow(ct, e), new ge(this.h, this.s, this.l * e, this.opacity);
},
darker(e) {
return e = e == null ? Ke : Math.pow(Ke, e), new ge(this.h, this.s, this.l * e, this.opacity);
},
rgb() {
var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, r = this.l, n = r + (r < 0.5 ? r : 1 - r) * t, i = 2 * r - n;
return new he(
Ft(e >= 240 ? e - 240 : e + 120, i, n),
Ft(e, i, n),
Ft(e < 120 ? e + 240 : e - 120, i, n),
this.opacity
);
},
clamp() {
return new ge(br(this.h), tt(this.s), tt(this.l), dt(this.opacity));
},
displayable() {
return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
},
formatHsl() {
const e = dt(this.opacity);
return `${e === 1 ? "hsl(" : "hsla("}${br(this.h)}, ${tt(this.s) * 100}%, ${tt(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
}
}));
function br(e) {
return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function tt(e) {
return Math.max(0, Math.min(1, e || 0));
}
function Ft(e, t, r) {
return (e < 60 ? t + (r - t) * e / 60 : e < 180 ? r : e < 240 ? t + (r - t) * (240 - e) / 60 : t) * 255;
}
const Bt = (e) => () => e;
function Qo(e, t) {
return function(r) {
return e + r * t;
};
}
function Jo(e, t, r) {
return e = Math.pow(e, r), t = Math.pow(t, r) - e, r = 1 / r, function(n) {
return Math.pow(e + n * t, r);
};
}
function el(e) {
return (e = +e) == 1 ? tn : function(t, r) {
return r - t ? Jo(t, r, e) : Bt(isNaN(t) ? r : t);
};
}
function tn(e, t) {
var r = t - e;
return r ? Qo(e, r) : Bt(isNaN(e) ? t : e);
}
const vr = (function e(t) {
var r = el(t);
function n(i, s) {
var a = r((i = Ct(i)).r, (s = Ct(s)).r), l = r(i.g, s.g), d = r(i.b, s.b), c = tn(i.opacity, s.opacity);
return function(u) {
return i.r = a(u), i.g = l(u), i.b = d(u), i.opacity = c(u), i + "";
};
}
return n.gamma = e, n;
})(1);
function tl(e, t) {
t || (t = []);
var r = e ? Math.min(t.length, e.length) : 0, n = t.slice(), i;
return function(s) {
for (i = 0; i < r; ++i) n[i] = e[i] * (1 - s) + t[i] * s;
return n;
};
}
function rl(e) {
return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function nl(e, t) {
var r = t ? t.length : 0, n = e ? Math.min(r, e.length) : 0, i = new Array(n), s = new Array(r), a;
for (a = 0; a < n; ++a) i[a] = Wt(e[a], t[a]);
for (; a < r; ++a) s[a] = t[a];
return function(l) {
for (a = 0; a < n; ++a) s[a] = i[a](l);
return s;
};
}
function il(e, t) {
var r = /* @__PURE__ */ new Date();
return e = +e, t = +t, function(n) {
return r.setTime(e * (1 - n) + t * n), r;
};
}
function ut(e, t) {
return e = +e, t = +t, function(r) {
return e * (1 - r) + t * r;
};
}
function sl(e, t) {
var r = {}, n = {}, i;
(e === null || typeof e != "object") && (e = {}), (t === null || typeof t != "object") && (t = {});
for (i in t)
i in e ? r[i] = Wt(e[i], t[i]) : n[i] = t[i];
return function(s) {
for (i in r) n[i] = r[i](s);
return n;
};
}
var zt = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, Tt = new RegExp(zt.source, "g");
function al(e) {
return function() {
return e;
};
}
function ol(e) {
return function(t) {
return e(t) + "";
};
}
function ll(e, t) {
var r = zt.lastIndex = Tt.lastIndex = 0, n, i, s, a = -1, l = [], d = [];
for (e = e + "", t = t + ""; (n = zt.exec(e)) && (i = Tt.exec(t)); )
(s = i.index) > r && (s = t.slice(r, s), l[a] ? l[a] += s : l[++a] = s), (n = n[0]) === (i = i[0]) ? l[a] ? l[a] += i : l[++a] = i : (l[++a] = null, d.push({ i: a, x: ut(n, i) })), r = Tt.lastIndex;
return r < t.length && (s = t.slice(r), l[a] ? l[a] += s : l[++a] = s), l.length < 2 ? d[0] ? ol(d[0].x) : al(t) : (t = d.length, function(c) {
for (var u = 0, f; u < t; ++u) l[(f = d[u]).i] = f.x(c);
return l.join("");
});
}
function Wt(e, t) {
var r = typeof t, n;
return t == null || r === "boolean" ? Bt(t) : (r === "number" ? ut : r === "string" ? (n = qe(t)) ? (t = n, vr) : ll : t instanceof qe ? vr : t instanceof Date ? il : rl(t) ? tl : Array.isArray(t) ? nl : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? sl : ut)(e, t);
}
function cl(e, t) {
return e = +e, t = +t, function(r) {
return Math.round(e * (1 - r) + t * r);
};
}
function dl(e) {
return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function ft(e, t) {
if ((r = (e = t ? e.toExponential(t - 1) : e.toExponential()).indexOf("e")) < 0) return null;
var r, n = e.slice(0, r);
return [
n.length > 1 ? n[0] + n.slice(2) : n,
+e.slice(r + 1)
];
}
function Ue(e) {
return e = ft(Math.abs(e)), e ? e[1] : NaN;
}
function ul(e, t) {
return function(r, n) {
for (var i = r.length, s = [], a = 0, l = e[0], d = 0; i > 0 && l > 0 && (d + l + 1 > n && (l = Math.max(1, n - d)), s.push(r.substring(i -= l, i + l)), !((d += l + 1) > n)); )
l = e[a = (a + 1) % e.length];
return s.reverse().join(t);
};
}
function fl(e) {
return function(t) {
return t.replace(/[0-9]/g, function(r) {
return e[+r];
});
};
}
var ml = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function mt(e) {
if (!(t = ml.exec(e))) throw new Error("invalid format: " + e);
var t;
return new Gt({
fill: t[1],
align: t[2],
sign: t[3],
symbol: t[4],
zero: t[5],
width: t[6],
comma: t[7],
precision: t[8] && t[8].slice(1),
trim: t[9],
type: t[10]
});
}
mt.prototype = Gt.prototype;
function Gt(e) {
this.fill = e.fill === void 0 ? " " : e.fill + "", this.align = e.align === void 0 ? ">" : e.align + "", this.sign = e.sign === void 0 ? "-" : e.sign + "", this.symbol = e.symbol === void 0 ? "" : e.symbol + "", this.zero = !!e.zero, this.width = e.width === void 0 ? void 0 : +e.width, this.comma = !!e.comma, this.precision = e.precision === void 0 ? void 0 : +e.precision, this.trim = !!e.trim, this.type = e.type === void 0 ? "" : e.type + "";
}
Gt.prototype.toString = function() {
return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
};
function hl(e) {
e: for (var t = e.length, r = 1, n = -1, i; r < t; ++r)
switch (e[r]) {
case ".":
n = i = r;
break;
case "0":
n === 0 && (n = r), i = r;
break;
default:
if (!+e[r]) break e;
n > 0 && (n = 0);
break;
}
return n > 0 ? e.slice(0, n) + e.slice(i + 1) : e;
}
var rn;
function xl(e, t) {
var r = ft(e, t);
if (!r) return e + "";
var n = r[0], i = r[1], s = i - (rn = Math.max(-8, Math.min(8, Math.floor(i / 3))) * 3) + 1, a = n.length;
return s === a ? n : s > a ? n + new Array(s - a + 1).join("0") : s > 0 ? n.slice(0, s) + "." + n.slice(s) : "0." + new Array(1 - s).join("0") + ft(e, Math.max(0, t + s - 1))[0];
}
function wr(e, t) {
var r = ft(e, t);
if (!r) return e + "";
var n = r[0], i = r[1];
return i < 0 ? "0." + new Array(-i).join("0") + n : n.length > i + 1 ? n.slice(0, i + 1) + "." + n.slice(i + 1) : n + new Array(i - n.length + 2).join("0");
}
const Nr = {
"%": (e, t) => (e * 100).toFixed(t),
b: (e) => Math.round(e).toString(2),
c: (e) => e + "",
d: dl,
e: (e, t) => e.toExponential(t),
f: (e, t) => e.toFixed(t),
g: (e, t) => e.toPrecision(t),
o: (e) => Math.round(e).toString(8),
p: (e, t) => wr(e * 100, t),
r: wr,
s: xl,
X: (e) => Math.round(e).toString(16).toUpperCase(),
x: (e) => Math.round(e).toString(16)
};
function Ar(e) {
return e;
}
var kr = Array.prototype.map, Sr = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function pl(e) {
var t = e.grouping === void 0 || e.thousands === void 0 ? Ar : ul(kr.call(e.grouping, Number), e.thousands + ""), r = e.currency === void 0 ? "" : e.currency[0] + "", n = e.currency === void 0 ? "" : e.currency[1] + "", i = e.decimal === void 0 ? "." : e.decimal + "", s = e.numerals === void 0 ? Ar : fl(kr.call(e.numerals, String)), a = e.percent === void 0 ? "%" : e.percent + "", l = e.minus === void 0 ? "−" : e.minus + "", d = e.nan === void 0 ? "NaN" : e.nan + "";
function c(f) {
f = mt(f);
var h = f.fill, m = f.align, N = f.sign, w = f.symbol, k = f.zero, x = f.width, v = f.comma, S = f.precision, b = f.trim, g = f.type;
g === "n" ? (v = !0, g = "g") : Nr[g] || (S === void 0 && (S = 12), b = !0, g = "g"), (k || h === "0" && m === "=") && (k = !0, h = "0", m = "=");
var C = w === "$" ? r : w === "#" && /[boxX]/.test(g) ? "0" + g.toLowerCase() : "", _ = w === "$" ? n : /[%p]/.test(g) ? a : "", D = Nr[g], T = /[defgprs%]/.test(g);
S = S === void 0 ? 6 : /[gprs]/.test(g) ? Math.max(1, Math.min(21, S)) : Math.max(0, Math.min(20, S));
function y(p) {
var F = C, M = _, E, V, j;
if (g === "c")
M = D(p) + M, p = "";
else {
p = +p;
var q = p < 0 || 1 / p < 0;
if (p = isNaN(p) ? d : D(Math.abs(p), S), b && (p = hl(p)), q && +p == 0 && N !== "+" && (q = !1), F = (q ? N === "(" ? N : l : N === "-" || N === "(" ? "" : N) + F, M = (g === "s" ? Sr[8 + rn / 3] : "") + M + (q && N === "(" ? ")" : ""), T) {
for (E = -1, V = p.length; ++E < V; )
if (j = p.charCodeAt(E), 48 > j || j > 57) {
M = (j === 46 ? i + p.slice(E + 1) : p.slice(E)) + M, p = p.slice(0, E);
break;
}
}
}
v && !k && (p = t(p, 1 / 0));
var z = F.length + p.length + M.length, Y = z < x ? new Array(x - z + 1).join(h) : "";
switch (v && k && (p = t(Y + p, Y.length ? x - M.length : 1 / 0), Y = ""), m) {
case "<":
p = F + p + M + Y;
break;
case "=":
p = F + Y + p + M;
break;
case "^":
p = Y.slice(0, z = Y.length >> 1) + F + p + M + Y.slice(z);
break;
default:
p = Y + F + p + M;
break;
}
return s(p);
}
return y.toString = function() {
return f + "";
}, y;
}
function u(f, h) {
var m = c((f = mt(f), f.type = "f", f)), N = Math.max(-8, Math.min(8, Math.floor(Ue(h) / 3))) * 3, w = Math.pow(10, -N), k = Sr[8 + N / 3];
return function(x) {
return m(w * x) + k;
};
}
return {
format: c,
formatPrefix: u
};
}
var rt, nn, sn;
yl({
thousands: ",",
grouping: [3],
currency: ["$", ""]
});
function yl(e) {
return rt = pl(e), nn = rt.format, sn = rt.formatPrefix, rt;
}
function gl(e) {
return Math.max(0, -Ue(Math.abs(e)));
}
function bl(e, t) {
return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Ue(t) / 3))) * 3 - Ue(Math.abs(e)));
}
function vl(e, t) {
return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Ue(t) - Ue(e)) + 1;
}
function vt(e, t) {
switch (arguments.length) {
case 0:
break;
case 1:
this.range(e);
break;
default:
this.range(t).domain(e);
break;
}
return this;
}
const Fr = /* @__PURE__ */ Symbol("implicit");
function ht() {
var e = new sr(), t = [], r = [], n = Fr;
function i(s) {
let a = e.get(s);
if (a === void 0) {
if (n !== Fr) return n;
e.set(s, a = t.push(s) - 1);
}
return r[a % r.length];
}
return i.domain = function(s) {
if (!arguments.length) return t.slice();
t = [], e = new sr();
for (const a of s)
e.has(a) || e.set(a, t.push(a) - 1);
return i;
}, i.range = function(s) {
return arguments.length ? (r = Array.from(s), i) : r.slice();
}, i.unknown = function(s) {
return arguments.length ? (n = s, i) : n;
}, i.copy = function() {
return ht(t, r).unknown(n);
}, vt.apply(i, arguments), i;
}
function wl(e) {
return function() {
return e;
};
}
function Nl(e) {
return +e;
}
var Tr = [0, 1];
function ke(e) {
return e;
}
function Lt(e, t) {
return (t -= e = +e) ? function(r) {
return (r - e) / t;
} : wl(isNaN(t) ? NaN : 0.5);
}
function Al(e, t) {
var r;
return e > t && (r = e, e = t, t = r), function(n) {
return Math.max(e, Math.min(t, n));
};
}
function kl(e, t, r) {
var n = e[0], i = e[1], s = t[0], a = t[1];
return i < n ? (n = Lt(i, n), s = r(a, s)) : (n = Lt(n, i), s = r(s, a)), function(l) {
return s(n(l));
};
}
function Sl(e, t, r) {
var n = Math.min(e.length, t.length) - 1, i = new Array(n), s = new Array(n), a = -1;
for (e[n] < e[0] && (e = e.slice().reverse(), t = t.slice().reverse()); ++a < n; )
i[a] = Lt(e[a], e[a + 1]), s[a] = r(t[a], t[a + 1]);
return function(l) {
var d = Hr(e, l, 1, n) - 1;
return s[d](i[d](l));
};
}
function an(e, t) {
return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function on() {
var e = Tr, t = Tr, r = Wt, n, i, s, a = ke, l, d, c;
function u() {
var h = Math.min(e.length, t.length);
return a !== ke && (a = Al(e[0], e[h - 1])), l = h > 2 ? Sl : kl, d = c = null, f;
}
function f(h) {
return h == null || isNaN(h = +h) ? s : (d || (d = l(e.map(n), t, r)))(n(a(h)));
}
return f.invert = function(h) {
return a(i((c || (c = l(t, e.map(n), ut)))(h)));
}, f.domain = function(h) {
return arguments.length ? (e = Array.from(h, Nl), u()) : e.slice();
}, f.range = function(h) {
return arguments.length ? (t = Array.from(h), u()) : t.slice();
}, f.rangeRound = function(h) {
return t = Array.from(h), r = cl, u();
}, f.clamp = function(h) {
return arguments.length ? (a = h ? !0 : ke, u()) : a !== ke;
}, f.interpolate = function(h) {
return arguments.length ? (r = h, u()) : r;
}, f.unknown = function(h) {
return arguments.length ? (s = h, f) : s;
}, function(h, m) {
return n = h, i = m, u();
};
}
function Fl() {
return on()(ke, ke);
}
function Tl(e, t, r, n) {
var i = qs(e, t, r), s;
switch (n = mt(n ?? ",f"), n.type) {
case "s": {
var a = Math.max(Math.abs(e), Math.abs(t));
return n.precision == null && !isNaN(s = bl(i, a)) && (n.precision = s), sn(n, a);
}
case "":
case "e":
case "g":
case "p":
case "r": {
n.precision == null && !isNaN(s = vl(i, Math.max(Math.abs(e), Math.abs(t)))) && (n.precision = s - (n.type === "e"));
break;
}
case "f":
case "%": {
n.precision == null && !isNaN(s = gl(i)) && (n.precision = s - (n.type === "%") * 2);
break;
}
}
return nn(n);
}
function Kt(e) {
var t = e.domain;
return e.ticks = function(r) {
var n = t();
return Xs(n[0], n[n.length - 1], r ?? 10);
}, e.tickFormat = function(r, n) {
var i = t();
return Tl(i[0], i[i.length - 1], r ?? 10, n);
}, e.nice = function(r) {
r == null && (r = 10);
var n = t(), i = 0, s = n.length - 1, a = n[i], l = n[s], d, c, u = 10;
for (l < a && (c = a, a = l, l = c, c = i, i = s, s = c); u-- > 0; ) {
if (c = Mt(a, l, r), c === d)
return n[i] = a, n[s] = l, t(n);
if (c > 0)
a = Math.floor(a / c) * c, l = Math.ceil(l / c) * c;
else if (c < 0)
a = Math.ceil(a * c) / c, l = Math.floor(l * c) / c;
else
break;
d = c;
}
return e;
}, e;
}
function Et() {
var e = Fl();
return e.copy = function() {
return an(e, Et());
}, vt.apply(e, arguments), Kt(e);
}
function Mr(e) {
return function(t) {
return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
};
}
function Ml(e) {
return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function _l(e) {
return e < 0 ? -e * e : e * e;
}
function $l(e) {
var t = e(ke, ke), r = 1;
function n() {
return r === 1 ? e(ke, ke) : r === 0.5 ? e(Ml, _l) : e(Mr(r), Mr(1 / r));
}
return t.exponent = function(i) {
return arguments.length ? (r = +i, n()) : r;
}, Kt(t);
}
function ln() {
var e = $l(on());
return e.copy = function() {
return an(e, ln()).exponent(e.exponent());
}, vt.apply(e, arguments), e;
}
function Dl() {
return ln.apply(null, arguments).exponent(0.5);
}
function wt() {
var e = 0, t = 1, r = 1, n = [0.5], i = [0, 1], s;
function a(d) {
return d != null && d <= d ? i[Hr(n, d, 0, r)] : s;
}
function l() {
var d = -1;
for (n = new Array(r); ++d < r; ) n[d] = ((d + 1) * t - (d - r) * e) / (r + 1);
return a;
}
return a.domain = function(d) {
return arguments.length ? ([e, t] = d, e = +e, t = +t, l()) : [e, t];
}, a.range = function(d) {
return arguments.length ? (r = (i = Array.from(d)).length - 1, l()) : i.slice();
}, a.invertExtent = function(d) {
var c = i.indexOf(d);
return c < 0 ? [NaN, NaN] : c < 1 ? [e, n[0]] : c >= r ? [n[r - 1], t] : [n[c - 1], n[c]];
}, a.unknown = function(d) {
return arguments.length && (s = d), a;
}, a.thresholds = function() {
return n.slice();
}, a.copy = function() {
return wt().domain([e, t]).range(i).unknown(s);
}, vt.apply(Kt(a), arguments);
}
const Cl = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(null), c = ve();
try {
const u = {
showTooltip: n?.showTooltip ?? !0,
showLegend: n?.showLegend ?? !0,
leftYAxisFormat: n?.leftYAxisFormat
};
if (!t || t.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in treemap chart" })
] }) });
let f, h = !1, m;
if (r?.xAxis && r?.yAxis) {
const b = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, g = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis;
m = Array.isArray(r.series) ? r.series[0] : r.series;
const C = be(i, b);
if (m) {
const _ = t.map((D) => {
const T = D[m];
return typeof T == "string" ? parseFloat(T) : T;
}).filter((D) => !isNaN(D));
if (h = _.length === t.length && _.every((D) => typeof D == "number"), h) {
const D = Math.min(..._), T = Math.max(..._), y = wt().domain([D, T]).range(Ce);
f = t.map((p) => {
const F = typeof p[m] == "string" ? parseFloat(p[m]) : p[m], M = y(F);
return {
name: se(p[b], C) || String(p[b]) || "Unknown",
size: typeof p[g] == "string" ? parseFloat(p[g]) : p[g] || 0,
fill: M,
series: String(p[m])
};
});
} else {
const D = [...new Set(t.map((y) => String(y[m])))], T = ht().domain(D).range(a?.colors || W);
f = t.map((y) => ({
name: se(y[b], C) || String(y[b]) || "Unknown",
size: typeof y[g] == "string" ? parseFloat(y[g]) : y[g] || 0,
fill: T(String(y[m])),
series: String(y[m])
}));
}
} else
f = t.map((_, D) => ({
name: se(_[b], C) || String(_[b]) || "Unknown",
size: typeof _[g] == "string" ? parseFloat(_[g]) : _[g] || 0,
fill: a?.colors && a.colors[D % a.colors.length] || W[D % W.length]
}));
} else {
const b = t[0], g = Object.keys(b), C = g.find(
(D) => typeof b[D] == "string" || D.toLowerCase().includes("name") || D.toLowerCase().includes("label") || D.toLowerCase().includes("category")
) || g[0], _ = g.find((D) => D.toLowerCase().includes("size")) || g.find(
(D) => typeof b[D] == "number" && D !== C
) || g[1];
if (!_)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "No numeric field found for treemap chart size" })
] }) });
f = t.map((D, T) => {
let y = D[C];
return typeof y == "boolean" ? y = y ? "Active" : "Inactive" : y === "true" || y === "false" ? y = y === "true" ? "Active" : "Inactive" : y = String(y), {
name: y,
size: typeof D[_] == "string" ? parseFloat(D[_]) : D[_] || 0,
fill: a?.colors && a.colors[T % a.colors.length] || W[T % W.length]
};
});
}
if (f = f.filter((b) => b.size != null && b.size > 0), f.length === 0)
return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No valid data points for treemap chart after transformation" })
] }) });
const N = (b) => {
const { x: g, y: C, width: _, height: D, index: T, name: y, size: p } = b;
return _ < 20 || D < 20 ? null : /* @__PURE__ */ A("g", { children: [
/* @__PURE__ */ o(
"rect",
{
x: g,
y: C,
width: _,
height: D,
style: {
fill: f[T]?.fill || a?.colors && a.colors[T % a.colors.length] || W[T % W.length],
fillOpacity: l !== null ? l === T ? 1 : 0.6 : 0.8,
stroke: "#fff",
strokeWidth: 2,
cursor: "pointer"
},
onMouseEnter: () => d(T),
onMouseLeave: () => d(null)
}
),
/* @__PURE__ */ o(
"foreignObject",
{
x: g,
y: C,
width: _,
height: D,
style: { pointerEvents: "none", overflow: "visible" },
children: /* @__PURE__ */ A(
"div",
{
style: {
width: "100%",
height: "100%",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
padding: "4px",
boxSizing: "border-box",
color: "#ffffff",
textShadow: "0 1px 2px rgba(0,0,0,0.8)",
fontFamily: "system-ui, -apple-system, sans-serif",
overflow: "hidden"
},
children: [
_ > 40 && D > 30 && /* @__PURE__ */ o(
"div",
{
style: {
fontSize: `${Math.max(10, Math.min(_ / 8, D / 8, 16))}px`,
fontWeight: "600",
textAlign: "center",
lineHeight: "1.2",
marginBottom: _ > 60 && D > 45 ? "4px" : "0",
wordBreak: "break-word",
hyphens: "auto"
},
children: y
}
),
_ > 60 && D > 45 && /* @__PURE__ */ o(
"div",
{
style: {
fontSize: `${Math.max(8, Math.min(_ / 10, D / 10, 14))}px`,
textAlign: "center",
opacity: 0.9
},
children: u.leftYAxisFormat ? B(p, u.leftYAxisFormat) : typeof p == "number" ? p.toLocaleString() : p
}
)
]
}
)
}
)
] });
}, k = f.some((b) => "series" in b) ? [...new Set(f.map((b) => b.series).filter(Boolean))] : [];
let x = [];
if (u.showLegend && m)
if (h) {
const b = Math.min(...t.map((C) => {
const _ = C[m];
return typeof _ == "string" ? parseFloat(_) : _;
})), g = Math.max(...t.map((C) => {
const _ = C[m];
return typeof _ == "string" ? parseFloat(_) : _;
}));
x = Ce.map((C, _) => {
const D = _ / (Ce.length - 1), T = b + (g - b) * D;
return {
value: u.leftYAxisFormat ? B(T, u.leftYAxisFormat) : T.toFixed(2),
type: "rect",
color: C
};
});
} else k.length > 1 && (x = k.map((b, g) => ({
value: b,
type: "rect",
color: W[g % W.length]
})));
const v = u.showLegend && x.length > 0, S = v ? typeof s == "string" && s.includes("%") ? s : typeof s == "number" ? s + 60 : `calc(${s} + 60px)` : s;
return /* @__PURE__ */ A("div", { className: "w-full", style: { height: S }, children: [
/* @__PURE__ */ o($e, { height: v ? "calc(100% - 50px)" : "100%", children: /* @__PURE__ */ o(
Fn,
{
data: f,
dataKey: "size",
aspectRatio: 4 / 3,
stroke: "#fff",
content: /* @__PURE__ */ o(N, {}),
children: u.showTooltip && /* @__PURE__ */ o(
He,
{
formatter: u.leftYAxisFormat ? (b, g) => [B(b, u.leftYAxisFormat), g] : void 0
}
)
}
) }),
v && /* @__PURE__ */ o("div", { className: "flex justify-center items-center mt-4 pb-2", children: h ? (
// Gradient legend for numeric series
/* @__PURE__ */ A("div", { className: "flex flex-col items-center", children: [
/* @__PURE__ */ o("div", { className: "text-xs font-semibold text-dc-text-primary mb-2", children: m ? c(m) : "" }),
/* @__PURE__ */ A("div", { className: "flex items-center gap-2", children: [
/* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: u.leftYAxisFormat ? B(Math.min(...t.map((b) => {
const g = b[m];
return typeof g == "string" ? parseFloat(g) : g;
})), u.leftYAxisFormat) : Math.min(...t.map((b) => {
const g = b[m];
return typeof g == "string" ? parseFloat(g) : g;
})).toFixed(2) }),
/* @__PURE__ */ o(
"div",
{
className: "h-4 rounded-sm",
style: {
width: "200px",
background: `linear-gradient(to right, ${Ce.join(", ")})`
}
}
),
/* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: u.leftYAxisFormat ? B(Math.max(...t.map((b) => {
const g = b[m];
return typeof g == "string" ? parseFloat(g) : g;
})), u.leftYAxisFormat) : Math.max(...t.map((b) => {
const g = b[m];
return typeof g == "string" ? parseFloat(g) : g;
})).toFixed(2) })
] })
] })
) : (
// Discrete legend for categorical series
/* @__PURE__ */ o("div", { className: "flex flex-wrap justify-center gap-4", children: x.map((b, g) => /* @__PURE__ */ A("div", { className: "flex items-center gap-2", children: [
/* @__PURE__ */ o(
"div",
{
className: "w-3 h-3 rounded-xs",
style: { backgroundColor: b.color }
}
),
/* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: b.value })
] }, g)) })
) })
] });
} catch (u) {
return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "TreeMap Chart Error" }),
/* @__PURE__ */ o("div", { className: "text-xs mb-2", children: u instanceof Error ? u.message : "Unknown rendering error" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
] }) });
}
}), Cc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Cl
}, Symbol.toStringTag, { value: "Module" })), zl = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const l = pe(null), d = pe(null), [c, u] = X({ width: 0, height: 0 }), [f, h] = X(!1), { theme: m } = ps(), N = ve(), w = Q(() => ({
showLegend: n?.showLegend ?? !0,
showGrid: n?.showGrid ?? !0,
showTooltip: n?.showTooltip ?? !0,
minBubbleSize: n?.minBubbleSize ?? 5,
maxBubbleSize: n?.maxBubbleSize ?? 50,
bubbleOpacity: n?.bubbleOpacity ?? 0.7,
xAxisFormat: n?.xAxisFormat,
leftYAxisFormat: n?.leftYAxisFormat
}), [
n?.showLegend,
n?.showGrid,
n?.showTooltip,
n?.minBubbleSize,
n?.maxBubbleSize,
n?.bubbleOpacity,
n?.xAxisFormat,
n?.leftYAxisFormat
]);
return Vt(() => {
let x = 0;
const v = 10;
let S, b;
const g = () => {
if (d.current) {
const { width: _, height: D } = d.current.getBoundingClientRect();
if (_ > 0 && D > 0)
return u({ width: _, height: D }), h(!0), !0;
}
return !1;
};
if (!g() && x < v) {
const _ = () => {
!g() && x < v && (x++, b = setTimeout(() => {
S = requestAnimationFrame(_);
}, 50 * x));
};
S = requestAnimationFrame(_);
}
return () => {
S && cancelAnimationFrame(S), b && clearTimeout(b);
};
}, []), Fe(() => {
let x = null;
const v = () => {
if (d.current) {
const { width: S, height: b } = d.current.getBoundingClientRect();
S > 0 && b > 0 && (u({ width: S, height: b }), f || h(!0));
}
};
return d.current && (x = new ResizeObserver((S) => {
for (const b of S) {
const { width: g, height: C } = b.contentRect;
g > 0 && C > 0 && (u({ width: g, height: C }), f || h(!0));
}
}), x.observe(d.current), v()), window.addEventListener("resize", v), () => {
x && x.disconnect(), window.removeEventListener("resize", v);
};
}, [f]), Fe(() => {
if (!t || t.length === 0 || !l.current || !f || c.width === 0 || (Ae(l.current).selectAll("*").remove(), !r?.xAxis || !r?.yAxis || !r?.series))
return;
const x = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, v = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis, S = Array.isArray(r.series) ? r.series[0] : r.series, b = Array.isArray(r.sizeField) ? r.sizeField[0] : r.sizeField || v, g = Array.isArray(r.colorField) ? r.colorField[0] : r.colorField;
if (!x || !v || !S || !b)
return;
const C = be(i, x), _ = i?.timeDimensions?.some(
(L) => L.dimension === x
) || !1, D = t.map((L) => {
const R = L[x];
let K, re;
if (_ && R) {
const te = String(R);
let ce;
if (te.match(/^\d{4}-\d{2}-\d{2}[T ]/)) {
let Ne = te;
te.includes(" ") && (Ne = te.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !Ne.endsWith("Z") && !Ne.includes("+") && (Ne = Ne + "Z"), ce = new Date(Ne);
} else
ce = new Date(te);
K = isNaN(ce.getTime()) ? parseFloat(te) : ce.getTime(), re = se(R, C);
} else {
const te = se(R, C) || R;
K = typeof te == "string" ? parseFloat(te) : te, re = String(te);
}
const ne = Ve(L[v]), xe = Ve(L[b]), ae = L[S];
return {
x: K,
xLabel: re,
// Store formatted label for tooltip display
y: ne,
// Type assertion: filter below ensures this is never null
size: xe !== null ? Math.abs(xe) : 0,
// Ensure positive size
color: g ? L[g] : ae,
series: ae,
label: `${ae || "Unknown"}`,
isValid: at(K) && ne !== null && xe !== null && xe > 0
};
}).filter((L) => L.isValid && L.size > 0);
if (D.length === 0) return;
const T = {
...je,
left: je.left + 30,
// Add extra 30px left margin for Y-axis label
bottom: w.showLegend && g ? 100 : 40
// Add extra space for legend
}, y = c.width - T.left - T.right, p = c.height - T.top - T.bottom, F = Ae(l.current).attr("width", c.width).attr("height", c.height), M = F.append("g").attr("transform", `translate(${T.left},${T.top})`), E = Et().domain(ir(D, (L) => L.x)).range([0, y]).nice(), V = Et().domain(ir(D, (L) => L.y)).range([p, 0]).nice(), j = Dl().domain([0, _t(D, (L) => L.size)]).range([w.minBubbleSize, w.maxBubbleSize]);
let q, z = !1, Y = [];
if (g && D.length > 0) {
const L = D.map((R) => {
const K = R.color;
return typeof K == "string" ? parseFloat(K) : K;
}).filter((R) => !isNaN(R));
if (z = L.length === D.length && L.every((R) => typeof R == "number"), z) {
const R = Math.min(...L), K = Math.max(...L);
q = wt().domain([R, K]).range(a?.gradient || Ce);
} else
Y = [...new Set(D.map((R) => String(R.color)))], q = ht().domain(Y).range(a?.colors || W);
} else
q = ht().domain(["default"]).range([W[0]]);
const J = (L, R) => getComputedStyle(document.documentElement).getPropertyValue(L).trim() || R, I = m !== "light", $ = I ? J("--dc-text-muted", "#cbd5e1") : J("--dc-text-secondary", "#374151"), U = I ? J("--dc-border", "#475569") : "#9ca3af";
if (w.showGrid) {
const L = M.append("g").attr("class", "grid").attr("transform", `translate(0,${p})`).call(
cr(E).tickSize(-p).tickFormat(() => "")
);
L.selectAll("line").style("stroke", U).style("stroke-dasharray", "3,3").style("opacity", 0.3), L.select(".domain").style("stroke", "none");
const R = M.append("g").attr("class", "grid").call(
dr(V).tickSize(-y).tickFormat(() => "")
);
R.selectAll("line").style("stroke", U).style("stroke-dasharray", "3,3").style("opacity", 0.3), R.select(".domain").style("stroke", "none");
}
const O = cr(E);
_ ? O.tickFormat((L) => {
const R = new Date(L);
if (isNaN(R.getTime())) return String(L);
switch (C?.toLowerCase()) {
case "year":
return String(R.getUTCFullYear());
case "quarter": {
const K = Math.floor(R.getUTCMonth() / 3) + 1;
return `${R.getUTCFullYear()}-Q${K}`;
}
case "month":
return `${R.getUTCFullYear()}-${String(R.getUTCMonth() + 1).padStart(2, "0")}`;
case "week":
case "day":
return `${R.getUTCFullYear()}-${String(R.getUTCMonth() + 1).padStart(2, "0")}-${String(R.getUTCDate()).padStart(2, "0")}`;
case "hour":
return `${String(R.getUTCMonth() + 1).padStart(2, "0")}-${String(R.getUTCDate()).padStart(2, "0")} ${String(R.getUTCHours()).padStart(2, "0")}:00`;
default:
return `${R.getUTCFullYear()}-${String(R.getUTCMonth() + 1).padStart(2, "0")}`;
}
}) : w.xAxisFormat && O.tickFormat((L) => B(L, w.xAxisFormat));
const G = M.append("g").attr("transform", `translate(0,${p})`).call(O);
G.selectAll("text").style("fill", $), G.selectAll("line, path").style("stroke", U), G.append("text").attr("x", y / 2).attr("y", 35).attr("fill", $).style("text-anchor", "middle").style("font-size", "12px").text(w.xAxisFormat?.label || N(x));
const ee = dr(V);
w.leftYAxisFormat && ee.tickFormat((L) => B(L, w.leftYAxisFormat));
const fe = M.append("g").call(ee);
fe.selectAll("text").style("fill", $), fe.selectAll("line, path").style("stroke", U), fe.append("text").attr("transform", "rotate(-90)").attr("y", -35).attr("x", -p / 2).attr("fill", $).style("text-anchor", "middle").style("font-size", "12px").text(w.leftYAxisFormat?.label || N(v));
const me = Ae("body").append("div").attr("class", "bubble-chart-tooltip").style("position", "absolute").style("padding", "8px").style("background", "rgba(0, 0, 0, 0.8)").style("color", "white").style("border-radius", "4px").style("font-size", "12px").style("pointer-events", "none").style("opacity", 0).style("z-index", 1e3), we = M.selectAll(".bubble").data(D).enter().append("circle").attr("class", "bubble").attr("cx", (L) => E(L.x)).attr("cy", (L) => V(L.y)).attr("r", (L) => j(L.size)).style("fill", (L) => g && L.color !== void 0 ? q(z ? L.color : String(L.color)) : W[0]).style("opacity", w.bubbleOpacity).style("stroke", "#fff").style("stroke-width", 1).style("cursor", "pointer");
if (w.showTooltip && we.on("mouseover", function(L, R) {
Ae(this).transition().duration(200).style("opacity", 1).attr("r", j(R.size) * 1.1);
const K = [
`<strong>${R.series || "Unknown"}</strong>`,
`${N(x)}: ${R.xLabel || (w.xAxisFormat ? B(R.x, w.xAxisFormat) : R.x)}`,
`${N(v)}: ${w.leftYAxisFormat ? B(R.y, w.leftYAxisFormat) : R.y}`,
`${N(b)}: ${w.leftYAxisFormat ? B(R.size, w.leftYAxisFormat) : R.size}`,
g && R.color ? `${N(g)}: ${R.color}` : ""
].filter(Boolean).join("<br>");
me.html(K).style("left", L.pageX + 10 + "px").style("top", L.pageY - 10 + "px").transition().duration(200).style("opacity", 1);
}).on("mousemove", function(L) {
me.style("left", L.pageX + 10 + "px").style("top", L.pageY - 10 + "px");
}).on("mouseout", function(L, R) {
Ae(this).transition().duration(200).style("opacity", w.bubbleOpacity).attr("r", j(R.size)), me.transition().duration(200).style("opacity", 0);
}), w.showLegend && g)
if (z) {
const K = Math.min(...D.map((ce) => ce.color)), re = Math.max(...D.map((ce) => ce.color)), ne = M.append("g").attr("class", "color-legend").attr("transform", `translate(${y / 2 - 200 / 2}, ${p + 60})`), ae = F.append("defs").append("linearGradient").attr("id", "color-scale-gradient").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%"), te = a?.gradient || Ce;
te.forEach((ce, Ne) => {
ae.append("stop").attr("offset", `${Ne / (te.length - 1) * 100}%`).attr("stop-color", ce);
}), ne.append("rect").attr("width", 200).attr("height", 20).style("fill", "url(#color-scale-gradient)").style("stroke", "#ccc").style("stroke-width", 1), ne.append("text").attr("x", 0).attr("y", 35).attr("text-anchor", "start").style("font-size", "11px").style("fill", $).text(w.leftYAxisFormat ? B(K, w.leftYAxisFormat) : K.toFixed(2)), ne.append("text").attr("x", 200).attr("y", 35).attr("text-anchor", "end").style("font-size", "11px").style("fill", $).text(w.leftYAxisFormat ? B(re, w.leftYAxisFormat) : re.toFixed(2)), ne.append("text").attr("x", 200 / 2).attr("y", -5).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", $).text(N(g));
} else {
const L = Y;
if (L.length > 0) {
const K = M.append("g").attr("class", "legend").attr("transform", `translate(${y / 2 - L.length * 80 / 2}, ${p + 60})`).selectAll(".legend-item").data(L).enter().append("g").attr("class", "legend-item").attr("transform", (re, ne) => `translate(${ne * 80}, 0)`).style("cursor", "pointer");
K.append("circle").attr("cx", 5).attr("cy", 5).attr("r", 5).style("fill", (re) => q(re)).style("opacity", w.bubbleOpacity), K.append("text").attr("x", 15).attr("y", 5).attr("dy", ".35em").style("font-size", "11px").style("fill", $).text((re) => String(re)), K.on("mouseover", function(re, ne) {
we.transition().duration(200).style("opacity", (xe) => g && String(xe.color) === ne ? 1 : 0.2);
}).on("mouseout", function() {
we.transition().duration(200).style("opacity", w.bubbleOpacity);
});
}
}
return () => {
me.remove();
};
}, [t, r, w, i, c, f, a, m, N]), !t || t.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in bubble chart" })
] }) }) : r?.xAxis && r?.yAxis && r?.series ? /* @__PURE__ */ o("div", { className: "w-full flex-1 flex flex-col relative", style: { height: s, minHeight: "250px", overflow: "hidden" }, children: /* @__PURE__ */ A("div", { ref: d, className: "w-full h-full relative", children: [
/* @__PURE__ */ o("svg", { ref: l, className: "w-full h-full" }),
!f && /* @__PURE__ */ o("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ o("div", { className: "text-dc-text-muted text-sm", children: "Measuring chart dimensions..." }) })
] }) }) : /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Required" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Bubble chart requires xAxis, yAxis, series, and sizeField dimensions" }),
/* @__PURE__ */ o("div", { className: "text-xs mt-1", children: "Optional: colorField for bubble coloring" })
] }) });
}), zc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: zl
}, Symbol.toStringTag, { value: "Module" })), Ll = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = 300
}) {
const { getFieldLabel: a, meta: l } = Bi(), d = Q(
() => Ns(i, r?.xAxis),
[i, r?.xAxis]
), c = n?.pivotTimeDimension !== !1, u = Q(() => !d || !c ? null : Ts(t, d, a), [t, d, c, a, l]);
return !t || t.length === 0 ? /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full",
style: { height: s },
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data to display in table" })
] })
}
) : u?.isPivoted && u.columns.length > 0 ? /* @__PURE__ */ o(
El,
{
pivotedData: u,
height: s,
meta: l,
leftYAxisFormat: n?.leftYAxisFormat
}
) : /* @__PURE__ */ o(
Il,
{
data: t,
chartConfig: r,
queryObject: i,
height: s,
getFieldLabel: a,
leftYAxisFormat: n?.leftYAxisFormat
}
);
});
function El({
pivotedData: e,
height: t,
meta: r,
leftYAxisFormat: n
}) {
const { columns: i, rows: s } = e;
return i.length === 0 || s.length === 0 ? /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full",
style: { height: t },
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data to display in table" })
] })
}
) : /* @__PURE__ */ o("div", { className: "w-full overflow-auto", style: { height: t }, children: /* @__PURE__ */ A("table", { className: "min-w-full divide-y border-dc-border", children: [
/* @__PURE__ */ o("thead", { className: "bg-dc-surface-secondary sticky top-0", children: /* @__PURE__ */ o("tr", { children: i.map((a) => /* @__PURE__ */ o(
"th",
{
className: `px-3 py-2 text-xs font-medium text-dc-text-muted uppercase tracking-wider whitespace-nowrap ${a.isTimeColumn ? "text-right" : "text-left"}`,
children: a.label
},
a.key
)) }) }),
/* @__PURE__ */ o("tbody", { className: "bg-dc-surface divide-y border-dc-border", children: s.map((a) => /* @__PURE__ */ o(
Rl,
{
row: a,
columns: i,
meta: r,
leftYAxisFormat: n
},
a.id
)) })
] }) });
}
function Rl({
row: e,
columns: t,
meta: r,
leftYAxisFormat: n
}) {
const i = Ms(e.measureField, r), s = Wi(i);
return /* @__PURE__ */ o("tr", { className: "hover:bg-dc-surface-secondary", children: t.map((a) => {
const l = e.values[a.key];
return a.isMeasureColumn ? e.isFirstInGroup === !1 ? null : /* @__PURE__ */ o(
"td",
{
className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text align-top",
rowSpan: e.dimensionRowSpan,
children: /* @__PURE__ */ A("div", { className: "flex items-center", children: [
/* @__PURE__ */ o(s, { className: "w-3.5 h-3.5 mr-1.5 text-dc-text-muted shrink-0" }),
/* @__PURE__ */ o("span", { children: l })
] })
},
a.key
) : a.isTimeColumn ? /* @__PURE__ */ o(
"td",
{
className: "px-3 py-2 whitespace-nowrap text-sm text-right text-dc-text",
children: _r(l, n)
},
a.key
) : /* @__PURE__ */ o(
"td",
{
className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
children: _r(l)
},
a.key
);
}) });
}
function _r(e, t) {
return e == null ? "-" : typeof e == "number" ? t ? B(e, t) : Number.isInteger(e) ? e.toLocaleString() : parseFloat(e.toFixed(2)).toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
}
function Il({
data: e,
chartConfig: t,
queryObject: r,
height: n,
getFieldLabel: i,
leftYAxisFormat: s
}) {
const a = Object.keys(e[0] || {}), l = Q(() => {
if (t?.xAxis && t.xAxis.length > 0)
return t.xAxis.filter((c) => a.includes(c));
const d = ws(r);
if (d.length > 0) {
const c = d.filter((f) => a.includes(f)), u = a.filter((f) => !c.includes(f));
return [...c, ...u];
}
return a;
}, [t?.xAxis, r, a]);
return l.length === 0 ? /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full",
style: { height: n },
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No columns available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Data structure is invalid" })
] })
}
) : /* @__PURE__ */ o("div", { className: "w-full overflow-auto", style: { height: n }, children: /* @__PURE__ */ A("table", { className: "min-w-full divide-y border-dc-border", children: [
/* @__PURE__ */ o("thead", { className: "bg-dc-surface-secondary sticky top-0", children: /* @__PURE__ */ o("tr", { children: l.map((d) => /* @__PURE__ */ o(
"th",
{
className: "px-3 py-2 text-left text-xs font-medium text-dc-text-muted uppercase tracking-wider",
children: i(d)
},
d
)) }) }),
/* @__PURE__ */ o("tbody", { className: "bg-dc-surface divide-y border-dc-border", children: e.map((d, c) => /* @__PURE__ */ o("tr", { className: "hover:bg-dc-surface-secondary", children: l.map((u) => /* @__PURE__ */ o(
"td",
{
className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
children: Vl(d[u], s)
},
u
)) }, c)) })
] }) });
}
function Vl(e, t) {
return e == null ? "" : typeof e == "number" ? t ? B(e, t) : e.toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
}
const Lc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Ll
}, Symbol.toStringTag, { value: "Module" })), Ol = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const l = pe(null), d = pe(null), [c, u] = X({ width: 0, height: 0 }), [f, h] = X(!1), [m, N] = X("light"), w = ve();
Fe(() => (N(Pe()), Ir((y) => {
N(y);
})), []);
const k = {
showTooltip: n?.showTooltip ?? !0,
showLabels: n?.showLabels ?? !0,
fitToWidth: n?.fitToWidth ?? !1
};
Vt(() => {
let T = 0;
const y = 10;
let p, F;
const M = () => {
if (d.current) {
const { width: V, height: j } = d.current.getBoundingClientRect();
if (V > 0 && j > 0)
return u({ width: V, height: j }), h(!0), !0;
}
return !1;
};
if (!M() && T < y) {
const V = () => {
!M() && T < y && (T++, F = setTimeout(() => {
p = requestAnimationFrame(V);
}, 50 * T));
};
p = requestAnimationFrame(V);
}
return () => {
p && cancelAnimationFrame(p), F && clearTimeout(F);
};
}, []), Fe(() => {
let T = null;
const y = () => {
if (d.current) {
const { width: p, height: F } = d.current.getBoundingClientRect();
p > 0 && F > 0 && (u({ width: p, height: F }), f || h(!0));
}
};
return d.current && (T = new ResizeObserver(() => y()), T.observe(d.current), y()), window.addEventListener("resize", y), () => {
T && T.disconnect(), window.removeEventListener("resize", y);
};
}, [f]);
const x = (T) => Math.floor(T.getMonth() / 3) + 1, v = (T) => T.getMonth() % 3 + 1, S = (T) => {
const y = T.getDate();
return Math.floor((y - 1) / 7) + 1;
}, b = (T) => {
switch (T?.toLowerCase()) {
case "year":
return null;
case "quarter":
return {
extractX: (y) => y.getFullYear(),
extractY: (y) => x(y) - 1,
// 0-3 for indexing
xLabels: [],
// Will be determined from data
yLabels: ["Q1", "Q2", "Q3", "Q4"],
xFormat: (y) => `'${y.toString().slice(-2)}`,
// '24 instead of 2024
yFormat: (y) => ["Q1", "Q2", "Q3", "Q4"][y] || "",
cellWidth: 16,
cellHeight: 16
};
case "month":
return {
extractX: (y) => {
const p = y.getFullYear(), F = x(y);
return p * 10 + F;
},
extractY: (y) => v(y) - 1,
// 0-2 for indexing
xLabels: [],
// Will be determined from data
yLabels: ["Month 1", "Month 2", "Month 3"],
xFormat: (y) => `Q${y % 10}`,
yFormat: (y) => ["Month 1", "Month 2", "Month 3"][y] || "",
cellWidth: 16,
cellHeight: 16,
hasHierarchicalLabels: !0,
// Flag to indicate we need special handling
getYearFromX: (y) => Math.floor(y / 10)
// Helper to get year for grouping
};
case "week":
return {
extractX: (y) => {
const p = y.getFullYear(), F = y.getMonth() + 1;
return p * 100 + F;
},
extractY: (y) => S(y) - 1,
// 0-5 for indexing
xLabels: [],
// Will be determined from data
yLabels: ["Week 1", "Week 2", "Week 3", "Week 4", "Week 5"],
xFormat: (y) => {
const p = y % 100;
return ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"][p - 1] || "";
},
yFormat: (y) => ["Week 1", "Week 2", "Week 3", "Week 4", "Week 5"][y] || "",
cellWidth: 16,
cellHeight: 16,
hasHierarchicalLabels: !0,
// Add hierarchical labels like month view
getYearFromX: (y) => Math.floor(y / 100)
// Helper to get year for grouping
};
case "day":
return {
extractX: (y) => {
const { year: p, week: F } = g(y);
return p * 100 + F;
},
extractY: (y) => y.getDay(),
// 0-6 (Sun-Sat)
xLabels: [],
// Will be determined from data
yLabels: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
xFormat: (y) => `${y % 100}`,
yFormat: (y) => ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][y] || "",
cellWidth: 16,
cellHeight: 16,
hasHierarchicalLabels: !0,
// Add hierarchical labels
getYearFromX: (y) => Math.floor(y / 100)
// Helper to get year for grouping
};
case "hour":
return {
extractX: (y) => {
const p = y.getFullYear(), F = y.getMonth() + 1, M = y.getDate();
return p * 1e4 + F * 100 + M;
},
extractY: (y) => Math.floor(y.getHours() / 3),
// 0-7 for 8 three-hour blocks
xLabels: [],
// Will be determined from data
yLabels: ["00-03", "03-06", "06-09", "09-12", "12-15", "15-18", "18-21", "21-00"],
xFormat: (y) => `${y % 100}`,
yFormat: (y) => ["00-03", "03-06", "06-09", "09-12", "12-15", "15-18", "18-21", "21-00"][y] || "",
cellWidth: 16,
cellHeight: 16,
hasHierarchicalLabels: !0,
// Show year/month grouping above
getYearFromX: (y) => Math.floor(y / 100)
// Extract YYYYMM for month grouping
};
default:
return null;
}
}, g = (T) => {
const y = new Date(Date.UTC(T.getFullYear(), T.getMonth(), T.getDate())), p = y.getUTCDay() || 7;
y.setUTCDate(y.getUTCDate() + 4 - p);
const F = y.getUTCFullYear(), M = new Date(Date.UTC(F, 0, 1)), E = Math.ceil(((y.getTime() - M.getTime()) / 864e5 + 1) / 7);
return { year: F, week: E };
};
if (Fe(() => {
if (!t || t.length === 0 || !l.current || !f || c.width === 0 || (Ae(l.current).selectAll("*").remove(), !r?.dateField || !r?.valueField))
return;
const T = Array.isArray(r.dateField) ? r.dateField[0] : r.dateField, y = Array.isArray(r.valueField) ? r.valueField[0] : r.valueField;
if (!T || !y)
return;
const F = (() => {
if (!i?.timeDimensions || i.timeDimensions.length === 0)
return "day";
const H = i.timeDimensions.find(
(Z) => Z.dimension === T || Z.dimension.includes(T)
);
if (H && H.granularity)
return H.granularity;
const P = i.timeDimensions[0];
return P && P.granularity ? P.granularity : "day";
})(), M = b(F);
if (!M)
return;
const E = t.map((H) => {
const P = H[T], Z = typeof H[y] == "string" ? parseFloat(H[y]) : H[y] || 0;
let ie;
if (typeof P == "string") {
let oe = P;
P.includes(" ") && (oe = P.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !oe.endsWith("Z") && !oe.includes("+") && (oe = oe + "Z"), ie = new Date(oe);
} else
ie = new Date(P);
if (isNaN(ie.getTime()))
return null;
const Te = M.extractX(ie), Me = M.extractY(ie);
return {
x: Te,
y: Me,
value: Z,
date: ie,
label: se(P, F)
};
}).filter((H) => H !== null);
if (E.length === 0) return;
const V = _t(E, (H) => H.y) || 0, j = or(E, (H) => H.y) || 0, z = (() => {
const H = [...new Set(E.map((P) => P.x))].sort();
return H;
})(), Y = z.length * M.cellWidth + (z.length - 1) * 4, J = (V - j + 1) * M.cellHeight + (V - j) * 4, I = {
left: 60,
// Space for Y-axis labels
bottom: 10,
// Reduced since labels are at top
top: M.hasHierarchicalLabels ? 40 : 25,
// Extra space for hierarchical labels
right: 10
}, $ = c.width - I.left - I.right, U = c.height - I.top - I.bottom;
let O, G;
if (k.fitToWidth) {
const H = $ / Y, P = U / J, Z = Math.min(H, P);
O = M.cellWidth * Z, G = M.cellHeight * Z;
} else {
const P = { width: 16, height: 16 }, Z = 24, ie = $ / Y, Te = U / J, Me = Math.min(ie, Te);
O = Math.max(P.width, Math.min(Z, M.cellWidth * Me)), G = Math.max(P.height, Math.min(Z, M.cellHeight * Me)), F === "week" && O < P.width && (O = P.width);
}
const ee = z.length * O + (z.length - 1) * 4, me = ee > $ ? ee + I.left + I.right : c.width, L = Ae(l.current).attr("width", me).attr("height", c.height).append("g").attr("transform", `translate(${I.left},${I.top})`), R = E.map((H) => H.value), K = or(R) || 0, re = _t(R) || 1, ne = wt().domain([K, re]).range(a?.gradient || Ce), xe = /* @__PURE__ */ new Map();
E.forEach((H) => {
const P = `${H.x}-${H.y}`;
xe.set(P, H);
});
const ae = (H, P) => getComputedStyle(document.documentElement).getPropertyValue(H).trim() || P, te = m !== "light", ce = te ? ae("--dc-text-muted", "#cbd5e1") : ae("--dc-text-secondary", "#374151"), Ne = ae("--dc-border", "#e5e7eb"), dn = te ? ae("--dc-bg-secondary", "#1e293b") : ae("--dc-bg-secondary", "#f3f4f6"), Xt = te ? ae("--dc-border", "#334155") : ae("--dc-bg", "#ffffff"), Je = Ae("body").append("div").attr("class", "activity-grid-tooltip").style("position", "absolute").style("padding", "8px").style("background", "rgba(0, 0, 0, 0.8)").style("color", "white").style("border-radius", "4px").style("font-size", "12px").style("pointer-events", "none").style("opacity", 0).style("z-index", 1e3), Be = /* @__PURE__ */ new Map();
z.forEach((H, P) => {
Be.set(H, P);
});
for (const H of z)
for (let P = j; P <= V; P++) {
const Z = `${H}-${P}`, ie = xe.get(Z), Te = Be.get(H) || 0, Me = L.append("rect").attr("x", Te * (O + 4)).attr("y", (P - j) * (G + 4)).attr("width", O).attr("height", G).attr("rx", 2).attr("ry", 2).style("fill", ie ? ne(ie.value) : dn).style("stroke", Xt).style("stroke-width", 1);
k.showTooltip && Me.style("cursor", "pointer").on("mouseover", function(oe) {
if (Ae(this).style("stroke", "#000").style("stroke-width", 2), ie) {
const De = [
`<strong>${ie.label}</strong>`,
`${w(y)}: ${ie.value}`
].join("<br>");
Je.html(De).style("left", oe.pageX + 10 + "px").style("top", oe.pageY - 10 + "px").transition().duration(200).style("opacity", 1);
}
}).on("mousemove", function(oe) {
Je.style("left", oe.pageX + 10 + "px").style("top", oe.pageY - 10 + "px");
}).on("mouseout", function() {
Ae(this).style("stroke", Xt).style("stroke-width", 1), Je.transition().duration(200).style("opacity", 0);
});
}
if (k.showLabels) {
if (M.hasHierarchicalLabels && M.getYearFromX) {
const H = /* @__PURE__ */ new Map();
for (const P of z) {
const Z = M.getYearFromX(P);
H.has(Z) || H.set(Z, []), H.get(Z).push(P);
}
for (const P of z) {
const Z = Be.get(P) || 0;
L.append("text").attr("x", Z * (O + 4) + O / 2).attr("y", -8).attr("text-anchor", "middle").style("font-size", "10px").style("fill", ce).text(M.xFormat(P));
}
for (const [P, Z] of H)
if (Z.length > 0) {
const ie = Math.min(...Z.map((De) => Be.get(De) || 0)), Te = Math.max(...Z.map((De) => Be.get(De) || 0)), Me = (ie + Te) / 2;
let oe = "";
if (P > 9999) {
const De = Math.floor(P / 100), un = P % 100;
oe = `${["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][un - 1]} '${De.toString().slice(-2)}`;
} else
oe = `'${P.toString().slice(-2)}`;
L.append("text").attr("x", Me * (O + 4) + O / 2).attr("y", -25).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", ce).text(oe), Z.length > 1 && L.append("line").attr("x1", ie * (O + 4)).attr("x2", Te * (O + 4) + O).attr("y1", -20).attr("y2", -20).style("stroke", Ne).style("stroke-width", 1).style("opacity", 0.3);
}
} else {
const H = Math.max(1, Math.floor(z.length / 10));
for (let P = 0; P < z.length; P += H) {
const Z = z[P];
L.append("text").attr("x", P * (O + 4) + O / 2).attr("y", -8).attr("text-anchor", "middle").style("font-size", "10px").style("fill", ce).text(M.xFormat(Z));
}
}
for (let H = j; H <= V; H++)
L.append("text").attr("x", -8).attr("y", (H - j) * (G + 4) + G / 2).attr("text-anchor", "end").attr("dy", ".35em").style("font-size", "10px").style("fill", ce).text(M.yFormat(H));
}
return () => {
Je.remove();
};
}, [t, r, n, i, c, f, k.showTooltip, k.showLabels, a, m]), !t || t.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full",
style: { height: s },
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display in activity grid" })
] })
}
);
if (!(r?.dateField && r?.valueField))
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full",
style: { height: s },
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Required" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Activity grid requires a time dimension and a measure" })
] })
}
);
const _ = Array.isArray(r.dateField) ? r.dateField[0] : r.dateField;
return (i?.timeDimensions?.find(
(T) => T.dimension === _ || T.dimension.includes(_)
)?.granularity || "day")?.toLowerCase() === "year" ? /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full",
style: { height: s },
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Granularity Too High" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Activity grids work best with hour, day, week, month, or quarter granularity" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary mt-1", children: "Please choose a lower granularity for your time dimension" })
] })
}
) : /* @__PURE__ */ o("div", { className: "w-full flex flex-col relative", style: { height: s, minHeight: "250px", overflow: "hidden", width: "100%" }, children: /* @__PURE__ */ A("div", { ref: d, className: "w-full h-full relative overflow-x-auto", style: { width: "100%" }, children: [
/* @__PURE__ */ o("svg", { ref: l, className: "h-full" }),
!f && /* @__PURE__ */ o("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ o("div", { className: "text-dc-text-muted text-sm", children: "Measuring chart dimensions..." }) })
] }) });
}), Ec = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Ol
}, Symbol.toStringTag, { value: "Module" }));
function cn({
values: e,
min: t,
max: r,
color: n = "#1f2937",
bucketCount: i = 12,
height: s = 32,
formatValue: a = (u) => u.toString(),
width: l,
showAverageIndicator: d = !0,
targetValue: c
}) {
const u = new Array(i).fill(0), f = r - t;
e.forEach((k) => {
if (f === 0)
u[Math.floor(i / 2)]++;
else {
let x = Math.floor((k - t) / f * (i - 1));
x = Math.max(0, Math.min(i - 1, x)), u[x]++;
}
});
const h = Math.max(...u), m = e.reduce((k, x) => k + x, 0) / e.length, N = f === 0 ? 50 : (m - t) / f * 100, w = c !== void 0 && f > 0 ? (c - t) / f * 100 : null;
return /* @__PURE__ */ A("div", { className: "flex flex-col items-center", children: [
/* @__PURE__ */ A(
"div",
{
className: "relative flex items-end justify-center space-x-0.5",
style: {
height: `${s}px`,
width: l ? `${l}px` : "200px",
minWidth: "200px"
},
children: [
u.map((k, x) => {
const v = h > 0 ? k / h : 0, S = 0.1, b = k > 0 ? Math.max(S, v) : S;
return /* @__PURE__ */ o(
"div",
{
className: "flex-1 rounded-t-sm transition-all duration-300 ease-out",
style: {
height: `${b * s}px`,
backgroundColor: n,
opacity: k > 0 ? 0.7 + v * 0.3 : 0.2
// higher opacity for buckets with data
},
title: `${k} values in this range`
},
x
);
}),
d && /* @__PURE__ */ o(
"div",
{
className: "absolute top-0 bottom-0 pointer-events-none",
style: {
left: `${N}%`,
transform: "translateX(-50%)",
width: "2px",
backgroundColor: "#ef4444",
opacity: 0.8,
zIndex: 10
},
title: `Average: ${a(m)}`,
children: /* @__PURE__ */ o(
"div",
{
className: "absolute -top-1",
style: {
left: "50%",
transform: "translateX(-50%)",
width: "0",
height: "0",
borderLeft: "4px solid transparent",
borderRight: "4px solid transparent",
borderTop: "6px solid #ef4444"
}
}
)
}
),
w !== null && c !== void 0 && /* @__PURE__ */ o(
"div",
{
className: "absolute top-0 bottom-0 pointer-events-none",
style: {
left: `${Math.max(0, Math.min(100, w))}%`,
transform: "translateX(-50%)",
width: "2px",
backgroundColor: "#10b981",
opacity: 0.8,
zIndex: 11
},
title: `Target: ${a(c)}`,
children: /* @__PURE__ */ o(
"div",
{
className: "absolute -top-1",
style: {
left: "50%",
transform: "translateX(-50%)",
width: "0",
height: "0",
borderLeft: "4px solid transparent",
borderRight: "4px solid transparent",
borderTop: "6px solid #10b981"
}
}
)
}
)
]
}
),
/* @__PURE__ */ A(
"div",
{
className: "flex justify-between mt-2 text-xs text-dc-text-muted",
style: {
width: l ? `${l}px` : "200px",
minWidth: "200px"
},
children: [
/* @__PURE__ */ o("span", { children: a(t) }),
/* @__PURE__ */ o("span", { children: a(r) })
]
}
),
/* @__PURE__ */ A("div", { className: "text-center mt-1 text-xs text-dc-text-muted", children: [
"Average of ",
e.length,
" values"
] })
] });
}
const Hl = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(32), [c, u] = X(250), f = pe(null), h = pe(null), m = ve();
if (Fe(() => {
const I = () => {
if (f.current) {
const G = f.current.getBoundingClientRect(), ee = G.width, fe = G.height;
if (ee > 0 && fe > 0) {
const me = ee / 5, we = fe / 4, L = Math.min(me, we), R = Math.max(24, Math.min(L, 120));
d(R), setTimeout(() => {
if (h.current) {
const re = h.current.getBoundingClientRect().width, ne = Math.max(re, Math.min(ee * 0.6, 300));
u(ne);
}
}, 10);
}
}
}, $ = setTimeout(I, 50), U = new ResizeObserver(() => {
setTimeout(I, 10);
});
return f.current && U.observe(f.current), () => {
clearTimeout($), U.disconnect();
};
}, [t, r]), !t || t.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0
},
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
] })
}
);
let N = [];
if (r?.yAxis && (typeof r.yAxis == "string" ? N = [r.yAxis] : Array.isArray(r.yAxis) && (N = r.yAxis)), N.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0,
backgroundColor: "var(--dc-danger-bg)",
color: "var(--dc-danger)",
borderColor: "var(--dc-danger-border)"
},
children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "No measure fields configured" })
] })
}
);
const w = N[0], k = i?.timeDimensions?.[0]?.dimension || void 0, x = Q(() => {
let I = [...t];
return k && (I = I.sort(($, U) => {
const O = $[k], G = U[k];
return O < G ? -1 : O > G ? 1 : 0;
})), I;
}, [t, k]), { useLastCompletePeriod: v = !0, skipLastPeriod: S = !1 } = n, {
filteredData: b,
excludedIncompletePeriod: g,
skippedLastPeriod: C,
granularity: _
} = Q(() => Vr(x, k, i, v, S), [x, k, i, v, S]), D = b, T = Q(() => D.map(($) => {
if ($[w] !== void 0)
return $[w];
const U = Object.keys($).filter(
(O) => typeof $[O] == "number" && !isNaN($[O])
);
if (U.length > 0)
return $[U[0]];
}).filter(($) => $ != null && !isNaN(Number($))).map(($) => Number($)), [D, w]);
if (T.length === 0)
return /* @__PURE__ */ A(
"div",
{
ref: f,
className: "flex flex-col items-center justify-center w-full h-full p-4",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0
},
children: [
/* @__PURE__ */ o(
"div",
{
className: "text-dc-text-secondary font-bold text-center mb-3",
style: {
fontSize: "14px",
lineHeight: "1.2"
},
children: m(w)
}
),
/* @__PURE__ */ o(
"div",
{
className: "font-bold leading-none text-dc-text-muted",
style: {
fontSize: `${l}px`
},
children: "—"
}
),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted mt-2", children: "No data" })
]
}
);
const { avg: y, min: p, max: F } = Q(() => {
const $ = T.reduce((G, ee) => G + ee, 0) / T.length, U = Math.min(...T), O = Math.max(...T);
return { avg: $, min: U, max: O };
}, [T]), M = Le((I) => {
if (n.formatValue)
return n.formatValue(I);
if (I == null)
return "—";
const $ = n.decimals ?? 0, U = n.prefix ?? "";
let O;
return Math.abs(I) >= 1e9 ? O = (I / 1e9).toFixed($) + "B" : Math.abs(I) >= 1e6 ? O = (I / 1e6).toFixed($) + "M" : Math.abs(I) >= 1e3 ? O = (I / 1e3).toFixed($) + "K" : O = I.toFixed($), U + O;
}, [n.formatValue, n.decimals, n.prefix]), E = T.length === 1 ? T[0] : y, V = T.length > 1, j = Q(() => {
if (n.valueColorIndex !== void 0 && a?.colors) {
const I = n.valueColorIndex;
if (I >= 0 && I < a.colors.length)
return a.colors[I];
}
return a?.colors?.[0] || "#1f2937";
}, [n.valueColorIndex, a?.colors]), q = Q(() => bt(n?.target || ""), [n?.target]), z = q.length > 0 ? q[0] : null, Y = z !== null ? $s(E, z) : null, J = Q(() => {
if (Y === null) return "#6B7280";
if (Y >= 0) {
const I = n.positiveColorIndex ?? 1;
return a?.colors?.[I] || "#10B981";
} else {
const I = n.negativeColorIndex ?? 7;
return a?.colors?.[I] || "#EF4444";
}
}, [Y, n.positiveColorIndex, n.negativeColorIndex, a?.colors]);
return /* @__PURE__ */ A(
"div",
{
ref: f,
className: "flex flex-col items-center justify-center w-full h-full p-4",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0
},
children: [
/* @__PURE__ */ A(
"div",
{
className: "text-dc-text-secondary font-bold text-center mb-3 flex items-center justify-center gap-1",
style: {
fontSize: "14px",
lineHeight: "1.2"
},
children: [
/* @__PURE__ */ o("span", { children: (() => {
const I = m(w);
return I && I.length > 1 ? I : w;
})() }),
(g || C) && /* @__PURE__ */ o(
"span",
{
title: C ? `Excludes last ${_ || "period"}` : `Excludes current incomplete ${_}`,
className: "cursor-help",
children: /* @__PURE__ */ o(st, { icon: Ht, className: "w-4 h-4 text-dc-text-muted opacity-70" })
}
)
]
}
),
/* @__PURE__ */ A("div", { className: "flex items-center justify-center gap-4 mb-3", children: [
/* @__PURE__ */ o(
"div",
{
ref: h,
className: "font-bold leading-none",
style: {
fontSize: `${l}px`,
color: j
},
children: M(E)
}
),
z !== null && Y !== null && /* @__PURE__ */ A("div", { className: "flex flex-col items-start", children: [
/* @__PURE__ */ o(
"div",
{
className: "font-semibold",
style: {
fontSize: `${Math.max(12, l * 0.3)}px`,
color: J,
lineHeight: "1.2"
},
children: Ds(Y, 1)
}
),
/* @__PURE__ */ A(
"div",
{
className: "text-dc-text-muted text-xs",
style: {
opacity: 0.7,
fontSize: `${Math.max(10, l * 0.2)}px`
},
children: [
"vs ",
M(z)
]
}
)
] })
] }),
n.suffix && !n.formatValue && /* @__PURE__ */ o(
"div",
{
className: "text-dc-text-muted text-center",
style: {
fontSize: "14px",
lineHeight: "1.2",
opacity: 0.8
},
children: n.suffix
}
),
V && /* @__PURE__ */ o("div", { className: "mt-4", children: /* @__PURE__ */ o(
cn,
{
values: T,
min: p,
max: F,
color: j,
formatValue: M,
height: 24,
width: c,
targetValue: z || void 0
}
) })
]
}
);
}), Rc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Hl
}, Symbol.toStringTag, { value: "Module" }));
function Yl({
values: e,
lastValue: t,
positiveColor: r,
negativeColor: n,
formatValue: i,
width: s,
height: a
}) {
const l = Math.max(10, Math.floor(s / 10)), d = e.length > l ? e.slice(-l) : e, c = d.map((v) => v - t), u = Math.min(...c, 0), f = Math.max(...c, 0);
if (Math.max(Math.abs(u), Math.abs(f)) === 0 || c.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center bg-dc-bg-secondary rounded-sm border border-dc-border",
style: { width: `${s}px`, height: `${a}px` },
children: /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: "No variance data" })
}
);
const m = 2, N = s - (d.length - 1) * m, w = Math.max(4, N / d.length), k = f - u, x = k > 0 ? f / k * 100 : 50;
return /* @__PURE__ */ A("div", { className: "flex items-center space-x-2", children: [
/* @__PURE__ */ A(
"div",
{
className: "relative",
style: {
width: `${s}px`,
height: `${a}px`
},
children: [
/* @__PURE__ */ o(
"div",
{
className: "absolute left-0 right-0",
style: {
height: "1px",
top: `${x}%`,
backgroundColor: "var(--dc-border)",
zIndex: 1
}
}
),
c.map((v, S) => {
const b = Math.abs(v) / k, g = Math.max(2, b * (a - 4)), C = v >= 0, _ = S === d.length - 1, D = C ? r : n, T = S * (w + m);
return /* @__PURE__ */ o(
"div",
{
className: "absolute rounded-xs",
style: {
left: `${T}px`,
width: `${w}px`,
height: `${g}px`,
backgroundColor: D,
opacity: _ ? 1 : 0.6,
// Position bar relative to zero line
...C ? { bottom: `${100 - x}%` } : { top: `${x}%` },
zIndex: 2
},
title: `${i(d[S])}: ${v >= 0 ? "+" : ""}${i(v)} vs current`
},
S
);
})
]
}
),
/* @__PURE__ */ A(
"div",
{
className: "flex flex-col justify-between text-xs text-dc-text-muted",
style: { height: `${a}px` },
children: [
/* @__PURE__ */ A("span", { children: [
"+",
i(f)
] }),
/* @__PURE__ */ A("span", { children: [
(u < 0, ""),
i(u)
] })
]
}
)
] });
}
const Pl = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
queryObject: i,
height: s = "100%",
colorPalette: a
}) {
const [l, d] = X(32), [c, u] = X(250), f = pe(null), h = pe(null), m = ve();
if (Fe(() => {
const $ = () => {
if (f.current) {
const ee = f.current.getBoundingClientRect(), fe = ee.width, me = ee.height;
if (fe > 0 && me > 0) {
const we = fe / 4, L = me / 4, R = Math.min(we, L), K = Math.max(28, Math.min(R, 140));
d(K), setTimeout(() => {
if (h.current) {
const ne = h.current.getBoundingClientRect().width, xe = fe - 100, ae = Math.max(
ne,
Math.min(xe, fe * 0.7)
);
u(Math.max(100, ae));
}
}, 10);
}
}
}, U = setTimeout($, 50), O = new ResizeObserver(() => {
setTimeout($, 10);
});
return f.current && O.observe(f.current), () => {
clearTimeout(U), O.disconnect();
};
}, [t, r]), !t || t.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0
},
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
] })
}
);
let N = [], w = [];
if (r?.yAxis && (N = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis]), r?.xAxis && (w = Array.isArray(r.xAxis) ? r.xAxis : [r.xAxis]), N.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0,
backgroundColor: "var(--dc-danger-bg)",
color: "var(--dc-danger)",
borderColor: "var(--dc-danger-border)"
},
children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "No measure field configured" })
] })
}
);
const k = N[0], x = w[0];
let v = [...t];
x && (v = v.sort(($, U) => {
const O = $[x], G = U[x];
return O < G ? -1 : O > G ? 1 : 0;
}));
const { useLastCompletePeriod: S = !0, skipLastPeriod: b = !1 } = n, {
filteredData: g,
excludedIncompletePeriod: C,
skippedLastPeriod: _,
granularity: D
} = Vr(
v,
x,
i,
S,
b
), y = g.map(($) => $[k]).filter(($) => $ != null && !isNaN(Number($))).map(($) => Number($));
if (y.length < 2)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0,
backgroundColor: "var(--dc-warning-bg)",
color: "var(--dc-warning)",
borderColor: "var(--dc-warning-border)"
},
children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Insufficient Data" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "Delta calculation requires at least 2 data points" }),
/* @__PURE__ */ A("div", { className: "text-xs", children: [
"Current data points: ",
y.length
] })
] })
}
);
const p = y[y.length - 1], F = y[y.length - 2], M = p - F, E = F !== 0 ? M / Math.abs(F) * 100 : 0, V = M >= 0, j = ($) => {
if (n.formatValue)
return n.formatValue($);
if ($ == null)
return "—";
const U = n.decimals ?? 0, O = n.prefix ?? "";
let G;
return Math.abs($) >= 1e9 ? G = ($ / 1e9).toFixed(U) + "B" : Math.abs($) >= 1e6 ? G = ($ / 1e6).toFixed(U) + "M" : Math.abs($) >= 1e3 ? G = ($ / 1e3).toFixed(U) + "K" : G = $.toFixed(U), O + G;
}, q = () => {
if (n.positiveColorIndex !== void 0 && a?.colors) {
const $ = n.positiveColorIndex;
if ($ >= 0 && $ < a.colors.length)
return a.colors[$];
}
return "#10b981";
}, z = () => {
if (n.negativeColorIndex !== void 0 && a?.colors) {
const $ = n.negativeColorIndex;
if ($ >= 0 && $ < a.colors.length)
return a.colors[$];
}
return "#ef4444";
}, Y = q(), J = z(), I = V ? Y : J;
return /* @__PURE__ */ A(
"div",
{
ref: f,
className: "flex flex-col items-center justify-center w-full h-full p-4",
style: {
height: s === "100%" ? "100%" : s,
minHeight: s === "100%" ? "200px" : void 0
},
children: [
/* @__PURE__ */ A(
"div",
{
className: "text-dc-text-secondary font-bold text-center mb-2 flex items-center justify-center gap-1",
style: {
fontSize: "14px",
lineHeight: "1.2"
},
children: [
/* @__PURE__ */ o("span", { children: (() => {
const $ = m(k);
return $ && $.length > 1 ? $ : k;
})() }),
(C || _) && /* @__PURE__ */ o(
"span",
{
title: _ ? `Excludes last ${D || "period"}` : `Excludes current incomplete ${D}`,
className: "cursor-help",
children: /* @__PURE__ */ o(
st,
{
icon: Ht,
className: "w-4 h-4 text-dc-text-muted opacity-70"
}
)
}
)
]
}
),
/* @__PURE__ */ A("div", { className: "flex items-center justify-center space-x-4 mb-2", children: [
/* @__PURE__ */ o(
"div",
{
ref: h,
className: "font-bold leading-none",
style: {
fontSize: `${l}px`,
color: "var(--dc-text)"
// Keep main value neutral
},
children: j(p)
}
),
/* @__PURE__ */ A("div", { className: "flex items-center space-x-1", children: [
/* @__PURE__ */ o(
"div",
{
className: "font-bold",
style: {
color: I,
fontSize: `${l * 0.35}px`
},
children: V ? "▲" : "▼"
}
),
/* @__PURE__ */ A("div", { className: "text-left", children: [
/* @__PURE__ */ A(
"div",
{
className: "font-bold leading-tight",
style: {
fontSize: `${l * 0.35}px`,
color: I
},
children: [
V ? "+" : "",
j(M)
]
}
),
/* @__PURE__ */ A(
"div",
{
className: "font-semibold leading-tight",
style: {
fontSize: `${l * 0.28}px`,
color: I,
opacity: 0.8
},
children: [
V ? "+" : "",
E.toFixed(1),
"%"
]
}
)
] })
] })
] }),
n.suffix && !n.formatValue && /* @__PURE__ */ o(
"div",
{
className: "text-dc-text-muted text-center mb-3",
style: {
fontSize: "14px",
lineHeight: "1.2",
opacity: 0.8
},
children: n.suffix
}
),
n.showHistogram !== !1 && y.length > 2 && /* @__PURE__ */ o("div", { className: "mt-2 w-full flex justify-center overflow-hidden", children: /* @__PURE__ */ o(
Yl,
{
values: y,
lastValue: p,
positiveColor: Y,
negativeColor: J,
formatValue: j,
width: c,
height: 64
}
) })
]
}
);
}), Ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Pl
}, Symbol.toStringTag, { value: "Module" })), jl = de.memo(function({
data: t,
chartConfig: r,
displayConfig: n = {},
height: i = "100%",
colorPalette: s
}) {
const [a, l] = X(28), [d, c] = X(0), u = pe(null), f = pe(null), h = ve();
if (Fe(() => {
const p = () => {
if (u.current) {
const V = u.current.getBoundingClientRect(), j = V.width, q = V.height;
if (j > 0 && q > 0) {
const z = j / 8, Y = q / 5, J = Math.min(z, Y), I = Math.max(18, Math.min(J, 80));
l(I);
}
}
if (f.current) {
const E = f.current.getBoundingClientRect();
c(E.width);
}
}, F = setTimeout(p, 100), M = new ResizeObserver(() => {
clearTimeout(F), setTimeout(p, 50);
});
return u.current && M.observe(u.current), () => {
clearTimeout(F), M.disconnect();
};
}, [t, r]), !t || t.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: i === "100%" ? "100%" : i,
minHeight: i === "100%" ? "200px" : void 0
},
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No data available" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "No data points to display" })
] })
}
);
let m = [];
if (r?.yAxis && (typeof r.yAxis == "string" ? m = [r.yAxis] : Array.isArray(r.yAxis) && (m = r.yAxis)), m.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: i === "100%" ? "100%" : i,
minHeight: i === "100%" ? "200px" : void 0,
backgroundColor: "var(--dc-danger-bg)",
color: "var(--dc-danger)",
borderColor: "var(--dc-danger-border)"
},
children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "Configuration Error" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "No measure fields configured" })
] })
}
);
const N = m[0], w = t.map((p) => {
if (p[N] !== void 0)
return p[N];
const F = Object.keys(p);
if (F.length > 0)
return p[F[0]];
}).filter((p) => p != null);
if (w.length === 0)
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: i === "100%" ? "100%" : i,
minHeight: i === "100%" ? "200px" : void 0,
backgroundColor: "var(--dc-warning-bg)",
color: "var(--dc-warning)",
borderColor: "var(--dc-warning-border)"
},
children: /* @__PURE__ */ A("div", { className: "text-center", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No valid data" }),
/* @__PURE__ */ o("div", { className: "text-xs", children: "All values are null or invalid" })
] })
}
);
const k = w.map((p) => Number(p)).filter((p) => !isNaN(p));
let x, v = null, S = null, b = !1;
k.length > 0 ? w.length === 1 ? x = w[0] : (x = k.reduce((M, E) => M + E, 0) / k.length, v = Math.min(...k), S = Math.max(...k), b = !0) : x = w.length === 1 ? w[0] : w.join(", ");
const g = (p) => {
if (n.formatValue)
return n.formatValue(p);
if (p == null)
return "—";
const F = n.decimals ?? 2;
return Math.abs(p) >= 1e9 ? (p / 1e9).toFixed(F) + "B" : Math.abs(p) >= 1e6 ? (p / 1e6).toFixed(F) + "M" : Math.abs(p) >= 1e3 ? (p / 1e3).toFixed(F) + "K" : p.toFixed(F);
}, C = (p, F) => {
try {
const M = {
value: typeof F == "number" ? g(F) : String(F),
rawValue: F,
field: N,
fieldLabel: h(N),
min: v !== null ? g(v) : "",
max: S !== null ? g(S) : "",
count: w.length
};
return p.replace(/\$\{(\w+)\}/g, (E, V) => V in M ? String(M[V]) : E);
} catch {
return String(F);
}
}, _ = n.template || "${fieldLabel}: ${value}", D = C(_, x), y = (() => {
if (n.valueColorIndex !== void 0 && s?.colors) {
const p = n.valueColorIndex;
if (p >= 0 && p < s.colors.length)
return s.colors[p];
}
return s?.colors?.[0] || "#1f2937";
})();
return /* @__PURE__ */ A(
"div",
{
ref: u,
className: "flex flex-col items-center justify-center w-full h-full p-4",
style: {
height: i === "100%" ? "100%" : i,
minHeight: i === "100%" ? "200px" : void 0
},
children: [
/* @__PURE__ */ o(
"div",
{
ref: f,
className: "font-bold leading-tight text-center",
style: {
fontSize: `${a}px`,
color: y
},
children: D
}
),
b && v !== null && S !== null && /* @__PURE__ */ o("div", { className: "mt-4", children: /* @__PURE__ */ o(
cn,
{
values: w,
min: v,
max: S,
color: y,
formatValue: g,
height: 24,
width: d || 200
}
) })
]
}
);
}), Vc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: jl
}, Symbol.toStringTag, { value: "Module" })), Ul = de.memo(function({
displayConfig: t = {},
height: r = "100%",
colorPalette: n
}) {
const i = t.content || "", s = t.accentColorIndex ?? 0, a = t.fontSize || "medium", l = t.alignment || "left", c = n?.colors && s < n.colors.length ? n.colors[s] : "#8884d8", u = {
small: "text-sm",
medium: "text-lg",
large: "text-xl"
}, f = {
left: "text-left",
center: "text-center",
right: "text-right"
}, h = (x) => {
const v = x.split(`
`), S = [];
let b = null;
for (let g = 0; g < v.length; g++) {
const C = v[g].trim();
if (!C) {
b && (S.push(b), b = null), S.push({ type: "break" });
continue;
}
const _ = C.match(/^(#{1,3})\s+(.*)$/);
if (_) {
b && (S.push(b), b = null), S.push({
type: "header",
level: _[1].length,
content: _[2]
});
continue;
}
const D = C.match(/^[-*+]\s+(.*)$/);
if (D) {
(!b || b.ordered) && (b && S.push(b), b = { type: "list", ordered: !1, children: [] }), b.children.push({
type: "listItem",
children: m(D[1]),
parentOrdered: !1
});
continue;
}
const T = C.match(/^\d+\.\s+(.*)$/);
if (T) {
(!b || !b.ordered) && (b && S.push(b), b = { type: "list", ordered: !0, children: [] }), b.children.push({
type: "listItem",
children: m(T[1]),
parentOrdered: !0
});
continue;
}
b && (S.push(b), b = null), S.push({
type: "paragraph",
children: m(C)
});
}
return b && S.push(b), S;
}, m = (x) => {
const v = [];
let S = x;
for (; S; ) {
const b = S.match(/^(.*?)\[([^\]]+)\]\(([^)]+)\)(.*)$/);
if (b) {
const [, g, C, _, D] = b;
g && v.push(...N(g)), v.push({
type: "link",
content: C,
url: _
}), S = D;
continue;
}
v.push(...N(S));
break;
}
return v;
}, N = (x) => {
const v = [];
let S = x;
for (; S; ) {
const b = S.match(/^(.*?)\*\*([^*]+)\*\*(.*)$/);
if (b) {
const [, C, _, D] = b;
C && v.push({ type: "text", content: C }), v.push({ type: "bold", content: _ }), S = D;
continue;
}
const g = S.match(/^(.*?)\*([^*]+)\*(.*)$/);
if (g) {
const [, C, _, D] = g;
C && v.push({ type: "text", content: C }), v.push({ type: "italic", content: _ }), S = D;
continue;
}
v.push({ type: "text", content: S });
break;
}
return v;
}, w = (x, v, S) => {
switch (x.type) {
case "text":
return /* @__PURE__ */ o("span", { className: "text-dc-text", children: x.content }, v);
case "bold":
return /* @__PURE__ */ o("strong", { className: "font-bold text-dc-text", children: x.content }, v);
case "italic":
return /* @__PURE__ */ o("em", { className: "italic text-dc-text", children: x.content }, v);
case "link":
return /* @__PURE__ */ o(
"a",
{
href: x.url,
target: "_blank",
rel: "nofollow noopener noreferrer",
className: "hover:underline transition-colors",
style: { color: c },
children: x.content
},
v
);
case "header": {
const b = (C, _) => {
const D = "font-bold", T = {
1: "mb-4",
2: "mb-3",
3: "mb-2"
};
let y = "";
return _ === "small" ? y = { 1: "text-lg", 2: "text-base", 3: "text-sm" }[C] || "text-sm" : _ === "large" ? y = { 1: "text-5xl", 2: "text-4xl", 3: "text-3xl" }[C] || "text-3xl" : y = { 1: "text-3xl", 2: "text-2xl", 3: "text-xl" }[C] || "text-xl", `${D} ${y} ${T[C]}`;
}, g = `h${x.level}`;
return /* @__PURE__ */ o(
g,
{
className: b(x.level, a),
style: { color: c },
children: x.content
},
v
);
}
case "paragraph":
return /* @__PURE__ */ o("p", { className: "mb-3 leading-relaxed", children: x.children?.map((b, g) => w(b, g)) }, v);
case "list": {
const b = x.ordered ? "ol" : "ul";
let g = "mb-3";
return l === "center" ? g += " list-none flex flex-col items-center" : l === "right" ? g += " list-none ml-auto max-w-max" : g += " list-none ml-6", /* @__PURE__ */ o(b, { className: g, children: x.children?.map((C, _) => w(C, _, x.ordered ? _ + 1 : void 0)) }, v);
}
case "listItem":
if (x.children) {
if (x.parentOrdered && S !== void 0) {
const b = u[a];
return l === "center" ? /* @__PURE__ */ A("li", { className: "mb-1 flex items-center justify-center", children: [
/* @__PURE__ */ A(
"span",
{
className: `inline-block mr-2 shrink-0 ${b} font-medium`,
style: { color: c },
children: [
S,
"."
]
}
),
/* @__PURE__ */ o("span", { className: "text-center", children: x.children.map((g, C) => w(g, C)) })
] }, v) : l === "right" ? /* @__PURE__ */ A("li", { className: "mb-1 flex items-start justify-end", children: [
/* @__PURE__ */ o("span", { className: "text-right", children: x.children.map((g, C) => w(g, C)) }),
/* @__PURE__ */ A(
"span",
{
className: `inline-block ml-2 shrink-0 ${b} font-medium`,
style: { color: c },
children: [
S,
"."
]
}
)
] }, v) : /* @__PURE__ */ A("li", { className: "mb-1 flex items-start", children: [
/* @__PURE__ */ A(
"span",
{
className: `inline-block mr-3 shrink-0 ${b} font-medium`,
style: { color: c },
children: [
S,
"."
]
}
),
/* @__PURE__ */ o("span", { className: "flex-1", children: x.children.map((g, C) => w(g, C)) })
] }, v);
}
return l === "center" ? /* @__PURE__ */ A("li", { className: "mb-1 flex items-center justify-center", children: [
/* @__PURE__ */ o(
"span",
{
className: "inline-block w-2 h-2 rounded-full mr-2 shrink-0",
style: { backgroundColor: c }
}
),
/* @__PURE__ */ o("span", { className: "text-center", children: x.children.map((b, g) => w(b, g)) })
] }, v) : l === "right" ? /* @__PURE__ */ A("li", { className: "mb-1 flex items-start justify-end", children: [
/* @__PURE__ */ o("span", { className: "text-right", children: x.children.map((b, g) => w(b, g)) }),
/* @__PURE__ */ o(
"span",
{
className: "inline-block w-2 h-2 rounded-full ml-2 mt-2 shrink-0",
style: { backgroundColor: c }
}
)
] }, v) : /* @__PURE__ */ A("li", { className: "mb-1 flex items-start", children: [
/* @__PURE__ */ o(
"span",
{
className: "inline-block w-2 h-2 rounded-full mr-3 mt-2 shrink-0",
style: { backgroundColor: c }
}
),
/* @__PURE__ */ o("span", { className: "flex-1", children: x.children.map((b, g) => w(b, g)) })
] }, v);
}
return null;
case "break":
return /* @__PURE__ */ o("br", {}, v);
default:
return null;
}
};
if (!i.trim())
return /* @__PURE__ */ o(
"div",
{
className: "flex items-center justify-center w-full h-full",
style: {
height: r === "100%" ? "100%" : r,
minHeight: r === "100%" ? "200px" : void 0
},
children: /* @__PURE__ */ A("div", { className: "text-center text-dc-text-muted", children: [
/* @__PURE__ */ o("div", { className: "text-sm font-semibold mb-1", children: "No content" }),
/* @__PURE__ */ o("div", { className: "text-xs text-dc-text-secondary", children: "Add markdown content in the chart configuration" })
] })
}
);
const k = h(i);
return /* @__PURE__ */ o(
"div",
{
className: `p-4 w-full h-full overflow-auto ${u[a]} ${f[l]}`,
style: {
height: r === "100%" ? "100%" : r,
minHeight: r === "100%" ? "200px" : void 0
},
children: k.map((x, v) => w(x, v))
}
);
}), Oc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Ul
}, Symbol.toStringTag, { value: "Module" }));
export {
es as $,
Ls as A,
Cs as B,
ql as C,
Er as D,
Vs as E,
Cl as F,
Ll as G,
W as H,
nr as I,
je as J,
Hi as K,
rr as L,
Ki as M,
ys as N,
cs as O,
Es as P,
ls as Q,
Is as R,
Rs as S,
kc as T,
os as U,
as as V,
ss as W,
is as X,
ns as Y,
rs as Z,
ts as _,
zr as a,
Ji as a0,
Qi as a1,
Zi as a2,
qi as a3,
Xi as a4,
bc as a5,
ic as a6,
sc as a7,
ac as a8,
oc as a9,
lc as aa,
cc as ab,
dc as ac,
uc as ad,
fc as ae,
mc as af,
hc as ag,
xc as ah,
pc as ai,
yc as aj,
gc as ak,
Sc as al,
Fc as am,
Tc as an,
Mc as ao,
_c as ap,
$c as aq,
Dc as ar,
Cc as as,
zc as at,
Lc as au,
Ec as av,
Rc as aw,
Ic as ax,
Vc as ay,
Oc as az,
Pi as b,
Ui as c,
ve as d,
Li as e,
ps as f,
vc as g,
wc as h,
Pe as i,
xs as j,
Ac as k,
gt as l,
Ql as m,
Jl as n,
ec as o,
tc as p,
Zl as q,
Nc as r,
hs as s,
rc as t,
Bi as u,
Wi as v,
Ir as w,
ue as x,
nc as y,
zs as z
};
//# sourceMappingURL=charts-B8YMw1mi.js.map