UNPKG

drizzle-cube

Version:

Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.

7,428 lines 259 kB
import { jsx as o, jsxs as k, Fragment as Vt } from "react/jsx-runtime";
import de, { useContext as xt, createContext as Ot, useState as Q, useMemo as Z, useCallback as Le, useRef as ye, useEffect as Te, useSyncExternalStore as pn, useLayoutEffect as Pt } from "react";
import { ResponsiveContainer as Qt, Tooltip as Cr, ComposedChart as zr, CartesianGrid as yt, XAxis as gt, YAxis as Ie, Legend as Oe, Bar as xn, Cell as Ht, Line as Re, LineChart as yn, Area as gn, PieChart as bn, Pie as vn, ScatterChart as wn, Scatter as Jt, RadarChart as Nn, PolarGrid as An, PolarAngleAxis as Sn, PolarRadiusAxis as kn, Radar as Tn, RadialBarChart as Fn, RadialBar as Mn, Treemap as _n } from "recharts";
import { d as St, a as $n, b as er, c as tr, e as Dn, f as Cn, g as zn, h as rr, i as nr, j as Ln, k as Yt, l as Rn, m as En, n as In, o as Vn, p as On, q as Pn, r as Hn, s as Yn, t as jn, u as Un, v as Bn, w as Wn, x as Gn, y as Kn, z as Xn, A as qn, B as Zn, C as Qn, D as Jn, E as ei, F as ti, G as ri, H as ni, I as ii, J as si, K as ai, L as oi, M as li, N as ci, O as di, P as ui, Q as fi, R as mi, S as hi, T as pi, U as xi, V as yi, W as gi, X as bi, Y as vi, Z as wi, _ as Ni, $ as Ai, a0 as Si, a1 as ki, a2 as Ti, a3 as Fi, a4 as Mi, a5 as _i, a6 as $i, a7 as Di, a8 as Ci, a9 as zi, aa as Li, ab as Ri, ac as Ei, ad as at } from "./icons-DI4Xack3.js";
class Ii {
  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 kt(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 kt({ data: [], annotation: {} }),
      error: s.error
    } : new kt(s));
  }
}
class kt {
  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 || {};
  }
  /**
   * Get cache metadata if result was served from cache
   * Returns undefined if not a cache hit
   */
  cacheInfo() {
    return this.loadResponse.results && this.loadResponse.results[0] ? this.loadResponse.results[0].cache : this.loadResponse.cache;
  }
}
function Vi(e, t = {}) {
  return new Ii(e, t);
}
class Oi {
  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 Lr = Ot(null);
function Pi({
  apiOptions: e,
  token: t,
  options: r = {},
  enableBatching: n = !0,
  batchDelayMs: i = 100,
  children: s
}) {
  const [a, l] = Q({ apiOptions: e, token: t }), d = Z(
    () => Vi(a.token, a.apiOptions),
    [a.apiOptions, a.token]
  ), c = Z(() => n ? new Oi((h) => d.batchLoad(h), i) : null, [n, d, i]), f = Le((h, u) => {
    l({ apiOptions: h, token: u });
  }, []), m = Z(() => ({
    cubeApi: d,
    options: r,
    updateApiConfig: f,
    batchCoordinator: c,
    enableBatching: n
  }), [d, r, f, c, n]);
  return /* @__PURE__ */ o(Lr.Provider, { value: m, children: s });
}
function Rr() {
  const e = xt(Lr);
  if (!e)
    throw new Error("useCubeApi must be used within CubeApiProvider");
  return e;
}
const Hi = 900 * 1e3;
let _e = null;
function Yi(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 ji() {
  return _e ? Date.now() - _e.timestamp < Hi : !1;
}
function Ui(e) {
  const [t, r] = Q(null), [n, i] = Q(!0), [s, a] = Q(null), l = ye({}), [d] = Q(() => ({})), c = Le(async () => {
    if (ji() && _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(), u = Yi(h);
      _e = {
        data: h,
        labelMap: u,
        timestamp: Date.now()
      }, l.current = u, Object.keys(d).forEach((N) => delete d[N]), Object.assign(d, u), r(h);
    } catch (h) {
      const u = h instanceof Error ? h.message : "Failed to fetch metadata";
      a(u), console.error("Failed to fetch cube metadata:", h);
    } finally {
      i(!1);
    }
  }, [e, d]);
  Te(() => {
    c();
  }, [c]);
  const f = Le((h) => l.current[h] || h, []), m = Le(() => {
    _e = null, c();
  }, [c]);
  return {
    meta: t,
    labelMap: d,
    // Return stable reference
    loading: n,
    error: s,
    refetch: m,
    getFieldLabel: f
  };
}
const jt = Ot(null);
function Bi({ children: e }) {
  const { cubeApi: t } = Rr(), {
    meta: r,
    labelMap: n,
    loading: i,
    error: s,
    getFieldLabel: a,
    refetch: l
  } = Ui(t), d = Z(() => ({
    meta: r,
    labelMap: n,
    metaLoading: i,
    metaError: s,
    getFieldLabel: a,
    refetchMeta: l
  }), [r, n, i, s, a, l]);
  return /* @__PURE__ */ o(jt.Provider, { value: d, children: e });
}
function Wi() {
  const e = xt(jt);
  if (!e)
    throw new Error("useCubeMeta must be used within CubeMetaProvider");
  return e;
}
const Er = Ot(null), Gi = {
  enableAI: !0,
  aiEndpoint: "/api/ai/generate",
  showSchemaDiagram: !1,
  useAnalysisBuilder: !1,
  editToolbar: "both",
  floatingToolbarPosition: "right"
};
function Ki({
  features: e,
  dashboardModes: t = ["rows", "grid"],
  children: r
}) {
  const [n, i] = Q(() => ({
    ...Gi,
    ...e
  })), s = Le((l) => {
    i((d) => ({ ...d, ...l }));
  }, []), a = Z(() => ({
    features: n,
    dashboardModes: t,
    updateFeatures: s
  }), [n, t, s]);
  return /* @__PURE__ */ o(Er.Provider, { value: a, children: r });
}
function Xi() {
  const e = xt(Er);
  if (!e)
    throw new Error("useCubeFeatures must be used within CubeFeaturesProvider");
  return e;
}
function lc({
  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(
    Pi,
    {
      apiOptions: t || { apiUrl: "/cubejs-api/v1" },
      token: r,
      options: n,
      enableBatching: a,
      batchDelayMs: l,
      children: /* @__PURE__ */ o(Bi, { children: /* @__PURE__ */ o(Ki, { features: i, dashboardModes: s, children: d }) })
    }
  );
}
function qi() {
  const e = Rr(), t = Wi(), r = Xi();
  return Z(() => ({
    ...e,
    ...t,
    features: r.features,
    dashboardModes: r.dashboardModes
  }), [e, t, r]);
}
const Ir = {
  // Action icons
  close: { icon: Ei, category: "action" },
  add: { icon: Ri, category: "action" },
  edit: { icon: Li, category: "action" },
  delete: { icon: zi, category: "action" },
  refresh: { icon: St, category: "action" },
  copy: { icon: Ci, category: "action" },
  duplicate: { icon: Di, category: "action" },
  settings: { icon: $i, category: "action" },
  filter: { icon: _i, category: "action" },
  share: { icon: Mi, category: "action" },
  expand: { icon: rr, category: "action" },
  collapse: { icon: nr, category: "action" },
  search: { icon: Fi, category: "action" },
  menu: { icon: Ti, category: "action" },
  run: { icon: ki, category: "action" },
  check: { icon: Si, category: "action" },
  link: { icon: Ai, category: "action" },
  eye: { icon: Ni, category: "action" },
  eyeOff: { icon: wi, category: "action" },
  adjustments: { icon: vi, category: "action" },
  desktop: { icon: bi, category: "action" },
  table: { icon: gi, category: "action" },
  sun: { icon: yi, category: "action" },
  moon: { icon: xi, category: "action" },
  ellipsisHorizontal: { icon: pi, category: "action" },
  documentText: { icon: hi, category: "action" },
  bookOpen: { icon: mi, category: "action" },
  codeBracket: { icon: fi, category: "action" },
  swatch: { icon: ui, category: "action" },
  // Field type icons (solid for visual distinction)
  measure: { icon: di, category: "field" },
  dimension: { icon: ci, category: "field" },
  timeDimension: { icon: li, category: "field" },
  segment: { icon: oi, category: "field" },
  // Chart type icons (Tabler - keeping existing visuals)
  chartBar: { icon: ai, category: "chart" },
  chartLine: { icon: si, category: "chart" },
  chartArea: { icon: ii, category: "chart" },
  chartPie: { icon: ni, category: "chart" },
  chartScatter: { icon: ri, category: "chart" },
  chartBubble: { icon: ti, category: "chart" },
  chartRadar: { icon: ei, category: "chart" },
  chartRadialBar: { icon: Jn, category: "chart" },
  chartTreemap: { icon: Qn, category: "chart" },
  chartTable: { icon: Zn, category: "chart" },
  chartActivityGrid: { icon: qn, category: "chart" },
  chartKpiNumber: { icon: Xn, category: "chart" },
  chartKpiDelta: { icon: Kn, category: "chart" },
  chartKpiText: { icon: Gn, category: "chart" },
  chartMarkdown: { icon: Wn, category: "chart" },
  // Measure type icons (solid)
  measureCount: { icon: Bn, category: "measure" },
  measureCountDistinct: { icon: Un, category: "measure" },
  measureCountDistinctApprox: { icon: jn, category: "measure" },
  measureSum: { icon: Yn, category: "measure" },
  measureAvg: { icon: Hn, category: "measure" },
  measureMin: { icon: er, category: "measure" },
  measureMax: { icon: tr, category: "measure" },
  measureRunningTotal: { icon: Pn, category: "measure" },
  measureCalculated: { icon: On, category: "measure" },
  measureNumber: { icon: Vn, category: "measure" },
  // State icons
  success: { icon: In, category: "state" },
  warning: { icon: En, category: "state" },
  error: { icon: Rn, category: "state" },
  info: { icon: Yt, category: "state" },
  loading: { icon: St, category: "state" },
  sparkles: { icon: Ln, category: "state" },
  // Navigation icons
  chevronUp: { icon: nr, category: "navigation" },
  chevronDown: { icon: rr, category: "navigation" },
  chevronLeft: { icon: zn, category: "navigation" },
  chevronRight: { icon: Cn, category: "navigation" },
  chevronUpDown: { icon: Dn, category: "navigation" },
  arrowUp: { icon: tr, category: "navigation" },
  arrowDown: { icon: er, category: "navigation" },
  arrowRight: { icon: $n, category: "navigation" },
  arrowPath: { icon: St, category: "navigation" }
};
let le = { ...Ir };
const Ge = /* @__PURE__ */ new Map();
function cc() {
  return le;
}
function bt(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(at, { icon: le.info.icon, className: s, ...a });
  const n = ({ className: i, ...s }) => /* @__PURE__ */ o(at, { icon: r.icon, className: i, ...s });
  return Ge.set(e, n), n;
}
function dc(e) {
  return le[e]?.icon ?? le.info.icon;
}
function uc(e, t) {
  le[e] && (le[e] = {
    ...le[e],
    icon: t
  }, Ge.delete(e));
}
function fc(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 mc() {
  le = { ...Ir }, Ge.clear();
}
function hc(e) {
  const t = {};
  for (const [r, n] of Object.entries(le))
    n.category === e && (t[r] = bt(r));
  return t;
}
function Zi(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 bt(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 bt(r);
}
function pc(e) {
  const r = {
    measure: "measure",
    dimension: "dimension",
    timeDimension: "timeDimension",
    time: "timeDimension",
    segment: "segment"
  }[e] || "dimension";
  return bt(r);
}
const Qi = {
  sm: "h-6 w-6",
  md: "h-8 w-8",
  lg: "h-12 w-12"
};
function ir({
  size: e = "md",
  className: t = ""
}) {
  return /* @__PURE__ */ o(
    "div",
    {
      className: `animate-spin rounded-full border-b-2 ${Qi[e]} ${t}`,
      style: { borderBottomColor: "var(--dc-primary)" },
      role: "status",
      "aria-label": "Loading"
    }
  );
}
function Ji({ children: e, className: t = "" }) {
  return /* @__PURE__ */ o("h3", { className: `text-sm font-semibold text-dc-primary uppercase tracking-wide ${t}`, children: e });
}
const es = {
  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"
    }
  ]
}, xc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  barChartConfig: es
}, Symbol.toStringTag, { value: "Module" })), ts = {
  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: "priorPeriodStyle",
      label: "Prior Period Line Style",
      type: "select",
      defaultValue: "dashed",
      options: [
        { value: "dashed", label: "Dashed" },
        { value: "dotted", label: "Dotted" },
        { value: "solid", label: "Solid" }
      ],
      description: "Line style for prior period in comparison mode"
    },
    {
      key: "priorPeriodOpacity",
      label: "Prior Period Opacity",
      type: "number",
      defaultValue: 0.5,
      min: 0.1,
      max: 1,
      step: 0.1,
      description: "Opacity for prior period lines (0.1 to 1)"
    },
    {
      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"
    }
  ]
}, yc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  lineChartConfig: ts
}, Symbol.toStringTag, { value: "Module" })), rs = {
  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"
    }
  ]
}, gc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  areaChartConfig: rs
}, Symbol.toStringTag, { value: "Module" })), ns = {
  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"
    }
  ]
}, bc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  pieChartConfig: ns
}, Symbol.toStringTag, { value: "Module" })), is = {
  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"
    }
  ]
}, vc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  scatterChartConfig: is
}, Symbol.toStringTag, { value: "Module" })), ss = {
  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"
    }
  ]
}, wc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  bubbleChartConfig: ss
}, Symbol.toStringTag, { value: "Module" })), as = {
  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"
    }
  ]
}, Nc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  radarChartConfig: as
}, Symbol.toStringTag, { value: "Module" })), os = {
  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"
    }
  ]
}, Ac = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  radialBarChartConfig: os
}, Symbol.toStringTag, { value: "Module" })), ls = {
  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"
    }
  ]
}, Sc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  treemapChartConfig: ls
}, Symbol.toStringTag, { value: "Module" })), cs = {
  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"
    }
  ]
}, kc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  dataTableConfig: cs
}, Symbol.toStringTag, { value: "Module" })), ds = {
  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 };
  }
}, Tc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  activityGridChartConfig: ds
}, Symbol.toStringTag, { value: "Module" })), us = {
  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"]
}, Fc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  kpiNumberConfig: us
}, Symbol.toStringTag, { value: "Module" })), fs = {
  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 }
}, Mc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  kpiDeltaConfig: fs
}, Symbol.toStringTag, { value: "Module" })), ms = {
  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"]
}, _c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  kpiTextConfig: ms
}, Symbol.toStringTag, { value: "Module" })), hs = {
  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"]
}, $c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  markdownConfig: hs
}, Symbol.toStringTag, { value: "Module" }));
function ot(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 Vr(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 W(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 Vr(e);
  const { unit: s, abbreviate: a = !0, decimals: l, customPrefix: d, customSuffix: c } = t;
  let f = n, m = "";
  if (a) {
    const u = Math.abs(n);
    u >= 1e9 ? (f = n / 1e9, m = "B") : u >= 1e6 ? (f = n / 1e6, m = "M") : u >= 1e3 && (f = n / 1e3, m = "K");
  }
  const h = l !== void 0 ? l : Number.isInteger(f) ? 0 : 2;
  switch (s) {
    case "currency": {
      const u = ps(i);
      if (a && m) {
        const N = new Intl.NumberFormat(i, {
          style: "currency",
          currency: u,
          minimumFractionDigits: h,
          maximumFractionDigits: h
        }).format(f), w = new Intl.NumberFormat(i, {
          style: "currency",
          currency: u
        }).formatToParts(f);
        return w[w.length - 1]?.type === "currency" ? N.replace(/(\s*[^\d\s]+)$/, m + "$1") : N + m;
      }
      return new Intl.NumberFormat(i, {
        style: "currency",
        currency: u,
        minimumFractionDigits: h,
        maximumFractionDigits: h
      }).format(f);
    }
    case "percent": {
      const u = Math.abs(f) <= 1 && !a ? f * 100 : f;
      return new Intl.NumberFormat(i, {
        minimumFractionDigits: h,
        maximumFractionDigits: h
      }).format(u) + m + "%";
    }
    case "custom": {
      const u = d || "", N = c || "", w = new Intl.NumberFormat(i, {
        minimumFractionDigits: h,
        maximumFractionDigits: h
      }).format(f);
      return u + w + m + N;
    }
    default:
      return new Intl.NumberFormat(i, {
        minimumFractionDigits: h,
        maximumFractionDigits: h
      }).format(f) + m;
  }
}
function ps(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 ee(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 f = i.getUTCSeconds(), m = i.getUTCMilliseconds();
    if (l === "01" && d === 0 && c === 0 && f === 0 && m === 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 && f === 0 && m === 0 ? `${s}-${a}-${l}` : c === 0 && f === 0 && m === 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 pe(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 xs(e, t, r, n, i = (s) => s) {
  if (!e || e.length === 0) return [];
  const s = pe(n, t);
  return e.map((a) => {
    const l = {
      name: ee(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((u) => u.dimension) || []
  ], d = a.measures || [], c = r.filter((u) => d.includes(u)), f = (i || []).filter((u) => l.includes(u));
  if (f.length > 0) {
    const u = {};
    e.forEach((A) => {
      const p = pe(n, t), v = ee(A[t], p) || A[t] || "Unknown";
      u[v] || (u[v] = { name: String(v) }), c.forEach((S) => {
        const g = s(S), b = Ve(A[S]);
        if (b !== null) {
          const D = u[v][g];
          u[v][g] = D == null ? b : D + b;
        } else g in u[v] || (u[v][g] = null);
      }), f.forEach((S) => {
        const g = A[S];
        if (g != null) {
          const b = String(g), D = c[0] || d.find(
            (_) => _.includes("totalCost") || _.includes("count") || _.includes("sum")
          ) || d[0];
          if (D) {
            const _ = Ve(A[D]);
            if (_ !== null) {
              const $ = u[v][b];
              u[v][b] = $ == null ? _ : $ + _;
            } else b in u[v] || (u[v][b] = null);
          }
        }
      });
    });
    const N = Object.values(u), w = Array.from(new Set(
      e.flatMap(
        (A) => f.map((p) => {
          const v = A[p];
          return v != null ? String(v) : null;
        }).filter((p) => p !== null)
      )
    ));
    return {
      data: N,
      seriesKeys: w,
      hasDimensions: !0
    };
  }
  const m = xs(e, t, r, n, s), h = r.map((u) => s(u));
  return {
    data: m,
    seriesKeys: h,
    hasDimensions: !1
  };
}
function ys() {
  const e = typeof navigator < "u" ? navigator.language : "en-US";
  return new Intl.NumberFormat(e, {
    style: "currency",
    currency: gs(e),
    currencyDisplay: "narrowSymbol"
  }).format(0).replace(/[\d.,\s]/g, "").trim() || "$";
}
function gs(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 Dc({
  value: e,
  onChange: t,
  axisLabel: r,
  previewValue: n = 125e4
}) {
  const i = e || {}, s = Z(() => ys(), []), a = Z(() => W(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__ */ k("div", { className: "space-y-3 pb-4", children: [
    /* @__PURE__ */ o(Ji, { children: r }),
    /* @__PURE__ */ k("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__ */ k("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__ */ k("div", { className: "flex gap-2", children: [
      /* @__PURE__ */ k("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__ */ k("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__ */ k("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Abbreviation" }),
      /* @__PURE__ */ k("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__ */ k("div", { className: "space-y-1", children: [
      /* @__PURE__ */ o("label", { className: "text-xs text-dc-text-secondary", children: "Decimals" }),
      /* @__PURE__ */ k("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__ */ k("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(jt);
  if (!e)
    throw new Error("useCubeFieldLabel must be used within CubeProvider");
  return Z(() => e.getFieldLabel, [e.getFieldLabel]);
}
function Cc(e) {
  return typeof window > "u" ? "" : getComputedStyle(document.documentElement).getPropertyValue(`--dc-${e}`).trim();
}
function bs(e, t) {
  typeof window > "u" || document.documentElement.style.setProperty(`--dc-${e}`, t);
}
function zc(e) {
  typeof window > "u" || Object.entries(e.colors).forEach(([t, r]) => {
    if (r) {
      const n = t.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
      bs(n, r);
    }
  });
}
function Lc() {
  if (typeof window > "u") return;
  const e = document.documentElement.style;
  Array.from(e).forEach((r) => {
    r.startsWith("--dc-") && e.removeProperty(r);
  });
}
function Ye() {
  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 vs(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 Rc() {
  const e = Ye();
  return e === "dark" || e === "neon";
}
function Or(e) {
  if (typeof window > "u") return () => {
  };
  const t = new MutationObserver(() => {
    e(Ye());
  });
  t.observe(document.documentElement, {
    attributes: !0,
    attributeFilter: ["class", "data-theme"]
  });
  const r = window.matchMedia("(prefers-color-scheme: dark)"), n = () => e(Ye());
  return r.addEventListener("change", n), () => {
    t.disconnect(), r.removeEventListener("change", n);
  };
}
const Ec = {
  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());
  }
};
Or(() => {
  nt.notify();
});
function ws() {
  const e = pn(
    nt.subscribe.bind(nt),
    Ye,
    // Client-side snapshot
    Ye
    // Server-side snapshot (SSR)
  ), t = Le((r) => {
    vs(r), nt.notify();
  }, []);
  return { theme: e, setTheme: t };
}
const G = [
  "#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
], sr = "#10b981", Ns = "#ef4444", je = {
  top: 5,
  right: 30,
  left: 20,
  bottom: 5
};
function As(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 Ss(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 : As(i, r) <= /* @__PURE__ */ new Date();
}
function ks(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 Pr(e, t, r, n, i = !1) {
  const s = {
    filteredData: e,
    excludedIncompletePeriod: !1,
    skippedLastPeriod: !1,
    granularity: null
  };
  if (e.length < 2)
    return s;
  const a = ks(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 Ss(l, t, a) ? { ...s, granularity: a } : {
    filteredData: e.slice(0, -1),
    excludedIncompletePeriod: !0,
    skippedLastPeriod: !1,
    granularity: a
  };
}
function Ts(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 Fs(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 Ms(e, t, r) {
  const n = /* @__PURE__ */ new Set();
  return e.forEach((i) => {
    const s = i[t];
    if (s != null) {
      const a = ee(s, r);
      n.add(a);
    }
  }), Array.from(n).sort();
}
function _s(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 $s(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 = ee(s, t.granularity);
      r.get(i).set(a, n);
    }
  }), r;
}
function Ds(e, t, r, n) {
  const i = $s(e, t), s = Array.from(i.keys()), a = [], l = t.measures.length, d = s.length;
  return t.measures.forEach((c) => {
    s.forEach((f, m) => {
      const h = i.get(f), u = l > 1 ? `${c}|${f}` : f, N = {}, w = f === "__all__" ? [] : f.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 A = m === 0, p = A && l > 1 ? d : void 0;
      a.push({
        id: u,
        measureField: c,
        values: N,
        isFirstInGroup: A,
        dimensionRowSpan: p
      });
    });
  }), a;
}
function Cs(e, t, r, n) {
  if (!e || e.length === 0)
    return { isPivoted: !0, columns: [], rows: [] };
  const i = Ms(e, t.timeDimension, t.granularity), s = _s(t, i, r), a = Ds(e, t, i, r);
  return { isPivoted: !0, columns: s, rows: a };
}
function zs(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 vt(e) {
  return e.length > 0 && "__periodIndex" in e[0];
}
function Hr(e) {
  if (!vt(e)) return [];
  const t = /* @__PURE__ */ new Set();
  for (const r of e)
    r.__period && t.add(r.__period);
  return Array.from(t);
}
function Ls(e) {
  if (!vt(e)) return [];
  const t = /* @__PURE__ */ new Set();
  for (const r of e)
    typeof r.__periodIndex == "number" && t.add(r.__periodIndex);
  return Array.from(t).sort((r, n) => r - n);
}
function it(e, t) {
  return t === 0 ? "Current" : "Prior";
}
function Rs(e, t, r) {
  if (e.length === 0) return [];
  const n = ["__period", "__periodIndex", "__periodDayIndex"], i = e[0], s = [];
  for (const a of Object.keys(i))
    !t.includes(a) && a !== r && !n.includes(a) && s.push(a);
  return s;
}
function Es(e, t) {
  const r = /* @__PURE__ */ new Map();
  for (const n of t)
    r.set(n, /* @__PURE__ */ new Set());
  for (const n of e)
    for (const i of t)
      n[i] !== void 0 && n[i] !== null && r.get(i).add(n[i]);
  return r;
}
function Is(e, t, r, n) {
  if (!vt(e))
    return { data: e, seriesKeys: t, xAxisKey: r };
  const i = Hr(e), s = Ls(e), a = Rs(e, t, r), l = a.length > 0, d = l ? Es(e, a) : null, c = /* @__PURE__ */ new Map();
  for (const h of e) {
    const u = h.__periodDayIndex, N = h.__periodIndex;
    c.has(u) || c.set(u, {
      __periodDayIndex: u,
      // Store the date from the first period (index 0) for reference
      __displayDate: N === 0 ? h[r] : void 0
    });
    const w = c.get(u);
    !w.__displayDate && h[r] && (w.__displayDate = h[r]);
    let A = "";
    l && (A = a.map((S) => {
      const g = h[S];
      return n ? n(String(g)) : String(g);
    }).join(" / "));
    const p = it(i[N] || "", N);
    for (const v of t) {
      const S = n ? n(v) : v, g = A ? `${A} - ${S} (${p})` : `${S} (${p})`;
      w[g] = h[v];
    }
  }
  const f = Array.from(c.values()).sort((h, u) => h.__periodDayIndex - u.__periodDayIndex), m = [];
  if (l && d) {
    const h = Vs(
      a,
      d,
      n
    );
    for (const u of h)
      for (const N of t) {
        const w = n ? n(N) : N;
        for (let A = 0; A < s.length; A++) {
          const p = it(i[A] || "", A);
          m.push(`${u} - ${w} (${p})`);
        }
      }
  } else
    for (const h of t) {
      const u = n ? n(h) : h;
      for (let N = 0; N < s.length; N++) {
        const w = it(i[N] || "", N);
        m.push(`${u} (${w})`);
      }
    }
  return {
    data: f,
    seriesKeys: m,
    xAxisKey: "__periodDayIndex"
  };
}
function Vs(e, t, r) {
  if (e.length === 0) return [];
  if (e.length === 1) {
    const a = e[0];
    return Array.from(t.get(a) || []).map((d) => r ? r(String(d)) : String(d));
  }
  const n = [], i = e.map(
    (a) => Array.from(t.get(a) || [])
  );
  function s(a, l) {
    if (a === i.length) {
      const d = l.map(
        (c) => r ? r(String(c)) : String(c)
      );
      n.push(d.join(" / "));
      return;
    }
    for (const d of i[a])
      s(a + 1, [...l, d]);
  }
  return s(0, []), n;
}
function Os(e, t) {
  if (t.length < 2) return !1;
  for (let r = 1; r < t.length; r++) {
    const n = it(t[r], r);
    if (e.includes(`(${n})`))
      return !0;
  }
  return e.includes("(Prior");
}
function Ps(e = "dashed") {
  switch (e) {
    case "solid":
      return;
    case "dashed":
      return "5 5";
    case "dotted":
      return "2 2";
    default:
      return "5 5";
  }
}
function $e({ children: e, height: t = "100%" }) {
  const r = ye(null), [n, i] = Q(!1), [s, a] = Q({ width: 0, height: 0 });
  Pt(() => {
    let l = !0, d = null;
    const c = () => {
      if (!l || !r.current) return;
      const f = r.current.getBoundingClientRect(), m = Math.max(r.current.clientWidth, f.width), h = Math.max(r.current.clientHeight, f.height);
      m > 0 && h > 0 && (a({ width: m, height: h }), i(!0));
    };
    return d = new ResizeObserver((f) => {
      for (const m of f) {
        const { width: h, height: u } = m.contentRect;
        h > 0 && u > 0 && (a({ width: h, height: u }), 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(ir, { 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(ir, { size: "sm" }) })
      }
    );
  } catch (l) {
    return /* @__PURE__ */ k(
      "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 Hs = (e, t) => e == null ? ["No data", t] : [Vr(e), t];
function Pe({ formatter: e, labelFormatter: t }) {
  return /* @__PURE__ */ o(
    Cr,
    {
      formatter: e || Hs,
      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 wt(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 Ut(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 Ys(e, t) {
  return t === 0 ? e === 0 ? 0 : e > 0 ? 100 : -100 : (e - t) / t * 100;
}
function js(e, t = 1) {
  return `${e >= 0 ? "+" : ""}${e.toFixed(t)}%`;
}
const Us = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(null), c = ve(), f = n?.stackType ?? (n?.stacked ? "normal" : "none"), m = f !== "none", h = f === "percent", u = {
    showLegend: n?.showLegend ?? !0,
    showGrid: n?.showGrid ?? !0,
    showTooltip: n?.showTooltip ?? !0
  }, N = n?.leftYAxisFormat, w = n?.rightYAxisFormat;
  let A, p = [], v = [], S = null;
  r?.xAxis && r?.yAxis ? (A = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, p = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], v = r.series || []) : r?.x && r?.y ? (A = r.x, p = Array.isArray(r.y) ? r.y : [r.y]) : S = "Invalid or missing chart axis configuration", !S && (!A || !p || p.length === 0) && (S = "Missing required X-axis or Y-axis fields");
  const { data: g, seriesKeys: b } = Z(() => S || !t || t.length === 0 || !A ? { data: [], seriesKeys: [] } : Ze(
    t,
    A,
    p,
    i,
    v,
    c
  ), [t, A, p, i, v, c, S]), D = Z(
    () => r?.yAxisAssignment || {},
    [r?.yAxisAssignment]
  ), _ = Z(() => {
    const C = {};
    return p.forEach((V) => {
      const P = c(V);
      C[P] = V;
    }), C;
  }, [p, c]), $ = p.some((C) => D[C] === "right"), T = p.filter((C) => (D[C] || "left") === "left"), y = p.filter((C) => D[C] === "right"), { chartData: x, skippedCount: z } = Z(() => {
    if (g.length === 0 || b.length === 0)
      return { chartData: [], skippedCount: 0 };
    const C = g.filter((P) => b.some((Y) => ot(P[Y]))), V = g.length - C.length;
    return { chartData: C, skippedCount: V };
  }, [g, b]);
  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__ */ k("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__ */ k("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 C = m && !$, V = h && !$, P = V ? "expand" : void 0, Y = b.length === 1 && x.some((M) => {
      const U = M[b[0]];
      return typeof U == "number" && U < 0;
    }), X = u.showLegend, F = {
      ...je,
      left: 40,
      // Space for left Y-axis label
      right: $ ? 40 : 20
      // Extra space for right Y-axis label if needed
    }, E = wt(n?.target || ""), B = Ut(E, x.length);
    let R = x;
    return B.length > 0 && (R = x.map((M, U) => ({
      ...M,
      __target: B[U] || null
    }))), !x || x.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ k("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__ */ k("div", { className: "relative w-full", style: { height: s }, children: [
      /* @__PURE__ */ o($e, { height: z > 0 ? "calc(100% - 20px)" : "100%", children: /* @__PURE__ */ k(zr, { data: R, margin: F, stackOffset: P, children: [
        u.showGrid && /* @__PURE__ */ o(yt, { strokeDasharray: "3 3" }),
        /* @__PURE__ */ o(
          gt,
          {
            dataKey: "name",
            tick: { fontSize: 12 },
            angle: -45,
            textAnchor: "end",
            height: 60
          }
        ),
        /* @__PURE__ */ o(
          Ie,
          {
            yAxisId: "left",
            orientation: "left",
            tick: { fontSize: 12 },
            tickFormatter: V ? (M) => `${(M * 100).toFixed(0)}%` : N ? (M) => W(M, N) : void 0,
            domain: V ? [0, 1] : void 0,
            label: V ? void 0 : T.length > 0 ? {
              value: N?.label || c(T[0]),
              angle: -90,
              position: "left",
              style: { textAnchor: "middle", fontSize: "12px" }
            } : void 0
          }
        ),
        $ && /* @__PURE__ */ o(
          Ie,
          {
            yAxisId: "right",
            orientation: "right",
            tick: { fontSize: 12 },
            tickFormatter: w ? (M) => W(M, w) : void 0,
            label: y.length > 0 ? {
              value: w?.label || c(y[0]),
              angle: 90,
              position: "right",
              style: { textAnchor: "middle", fontSize: "12px" }
            } : void 0
          }
        ),
        u.showTooltip && /* @__PURE__ */ o(
          Pe,
          {
            formatter: (M, U) => {
              if (M == null)
                return ["No data", U];
              if (U === "Target")
                return [W(M, N), "Target Value"];
              if (V && typeof M == "number")
                return [`${(M * 100).toFixed(1)}%`, U];
              const O = _[U], te = (O && D[O] === "right" ? "right" : "left") === "right" ? w : N;
              return [W(M, te), U];
            }
          }
        ),
        X && /* @__PURE__ */ o(
          Oe,
          {
            wrapperStyle: { fontSize: "12px", paddingTop: "25px" },
            iconType: "rect",
            iconSize: 8,
            layout: "horizontal",
            align: "center",
            verticalAlign: "bottom",
            onMouseEnter: (M) => d(String(M.dataKey || "")),
            onMouseLeave: () => d(null)
          }
        ),
        b.map((M, U) => {
          const O = _[M], K = O && D[O] === "right" ? "right" : "left";
          return /* @__PURE__ */ o(
            xn,
            {
              dataKey: M,
              yAxisId: K,
              stackId: C ? "stack" : void 0,
              fill: Y ? sr : a?.colors && a.colors[U % a.colors.length] || G[U % G.length],
              fillOpacity: l ? l === M ? 1 : 0.3 : 1,
              children: Y && x.map((te, fe) => {
                const me = te[M], we = typeof me == "number" && me < 0 ? Ns : sr;
                return /* @__PURE__ */ o(
                  Ht,
                  {
                    fill: we,
                    fillOpacity: l ? l === M ? 1 : 0.3 : 1
                  },
                  `cell-${fe}`
                );
              })
            },
            M
          );
        }),
        B.length > 0 && /* @__PURE__ */ k(Vt, { children: [
          /* @__PURE__ */ o(
            Re,
            {
              type: "monotone",
              dataKey: "__target",
              yAxisId: "left",
              stroke: "#ffffff",
              strokeWidth: 2,
              dot: !1,
              activeDot: !1,
              connectNulls: !1
            }
          ),
          /* @__PURE__ */ o(
            Re,
            {
              type: "monotone",
              dataKey: "__target",
              yAxisId: "left",
              name: "Target",
              stroke: "#8B5CF6",
              strokeWidth: 2,
              strokeDasharray: "2 3",
              dot: !1,
              activeDot: !1,
              connectNulls: !1
            }
          )
        ] })
      ] }) }),
      z > 0 && /* @__PURE__ */ k("div", { className: "text-xs text-dc-text-muted text-center mt-1", children: [
        z,
        " data point",
        z !== 1 ? "s" : "",
        " with no values hidden"
      ] })
    ] });
  } 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__ */ k("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: C instanceof Error ? C.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), Ic = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Us
}, Symbol.toStringTag, { value: "Module" })), Bs = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(null), c = ve(), f = Z(() => r?.yAxis ? Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis] : r?.y ? Array.isArray(r.y) ? r.y : [r.y] : [], [r?.yAxis, r?.y]), m = Z(
    () => r?.yAxisAssignment || {},
    [r?.yAxisAssignment]
  ), h = Z(() => {
    const u = {};
    return f.forEach((N) => {
      const w = c(N);
      u[w] = N;
    }), u;
  }, [f, c]);
  try {
    const u = {
      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__ */ k("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 A, p = [];
    if (r?.xAxis && r?.yAxis)
      A = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, p = r.series || [];
    else if (r?.x && r?.y)
      A = r.x;
    else
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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 (!A || f.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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 v = vt(t), S = n?.priorPeriodStyle || "dashed", g = n?.priorPeriodOpacity ?? 0.5, b = v ? Hr(t) : [];
    let D, _, $ = "name";
    if (v) {
      const F = Is(t, f, A, c);
      D = F.data, _ = F.seriesKeys, $ = "__periodDayIndex";
    } else {
      const F = Ze(
        t,
        A,
        f,
        i,
        p,
        c
      );
      D = F.data, _ = F.seriesKeys;
    }
    const T = (F) => {
      if (h[F])
        return h[F];
      const B = F.replace(/\s*\((Current|Prior)\)$/, "").split(" - "), R = B[B.length - 1];
      return h[R];
    }, y = f.some((F) => m[F] === "right"), x = f.filter((F) => (m[F] || "left") === "left"), z = f.filter((F) => m[F] === "right"), C = u.showLegend, V = {
      ...je,
      left: 40,
      // Space for left Y-axis label
      right: y ? 40 : 20
      // Extra space for right Y-axis label if needed
    }, P = wt(n?.target || ""), Y = Ut(P, D.length);
    let X = D;
    return Y.length > 0 && (X = D.map((F, E) => ({
      ...F,
      __target: Y[E] || null
    }))), !D || D.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ k("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__ */ k(yn, { data: X, margin: V, children: [
      u.showGrid && /* @__PURE__ */ o(yt, { strokeDasharray: "3 3" }),
      /* @__PURE__ */ o(
        gt,
        {
          dataKey: $,
          tick: { fontSize: 12 },
          angle: -45,
          textAnchor: "end",
          height: 60,
          tickFormatter: v ? (F, E) => {
            const B = D[E];
            if (B?.__displayDate) {
              const R = pe(i, A);
              return ee(B.__displayDate, R);
            }
            return `Period ${F + 1}`;
          } : void 0
        }
      ),
      /* @__PURE__ */ o(
        Ie,
        {
          yAxisId: "left",
          orientation: "left",
          tick: { fontSize: 12 },
          tickFormatter: N ? (F) => W(F, N) : void 0,
          label: x.length > 0 ? {
            value: N?.label || c(x[0]),
            angle: -90,
            position: "left",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      y && /* @__PURE__ */ o(
        Ie,
        {
          yAxisId: "right",
          orientation: "right",
          tick: { fontSize: 12 },
          tickFormatter: w ? (F) => W(F, w) : void 0,
          label: z.length > 0 ? {
            value: w?.label || c(z[0]),
            angle: 90,
            position: "right",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      u.showTooltip && /* @__PURE__ */ o(
        Pe,
        {
          formatter: (F, E) => {
            if (F == null)
              return ["No data", E];
            if (E === "Target")
              return [W(F, N), "Target Value"];
            const B = T(E), M = (B && m[B] === "right" ? "right" : "left") === "right" ? w : N;
            return [W(F, M), E];
          },
          labelFormatter: v ? (F, E) => {
            if (E && E.length > 0) {
              const B = E[0]?.payload;
              if (B?.__displayDate) {
                const R = pe(i, A);
                return ee(B.__displayDate, R);
              }
            }
            return `Period ${Number(F) + 1}`;
          } : void 0
        }
      ),
      C && /* @__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)
        }
      ),
      _.map((F, E) => {
        const B = T(F), R = B && m[B] === "right" ? "right" : "left", M = v && Os(F, b), U = M ? Ps(S) : void 0, O = M ? g : 1;
        return /* @__PURE__ */ o(
          Re,
          {
            type: "monotone",
            dataKey: F,
            yAxisId: R,
            stroke: a?.colors && a.colors[E % a.colors.length] || G[E % G.length],
            strokeWidth: M ? 1.5 : 2,
            strokeDasharray: U,
            dot: M ? !1 : { r: 3 },
            activeDot: M ? !1 : { r: 5 },
            strokeOpacity: l ? l === F ? 1 : 0.3 : O,
            connectNulls: u.connectNulls
          },
          F
        );
      }),
      Y.length > 0 && /* @__PURE__ */ k(Vt, { children: [
        /* @__PURE__ */ o(
          Re,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            stroke: "#ffffff",
            strokeWidth: 2,
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        ),
        /* @__PURE__ */ o(
          Re,
          {
            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__ */ k("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" })
    ] }) });
  }
}), Vc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Bs
}, Symbol.toStringTag, { value: "Module" })), Ws = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(null), c = ve();
  try {
    const f = n?.stackType ?? (n?.stacked ? "normal" : "none"), m = f !== "none", h = f === "percent", u = {
      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__ */ k("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 A, p, v = [];
    if (r?.xAxis && r?.yAxis)
      A = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, p = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], v = r.series || [];
    else if (r?.x && r?.y)
      A = r.x, p = 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__ */ k("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 (!A || !p || p.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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: g } = Ze(
      t,
      A,
      p,
      i,
      v,
      c
    ), b = r?.yAxisAssignment || {}, D = {};
    p.forEach((F) => {
      const E = c(F);
      D[E] = F;
    });
    const _ = p.some((F) => b[F] === "right"), $ = p.filter((F) => (b[F] || "left") === "left"), T = p.filter((F) => b[F] === "right"), y = m && !_, x = h && !_, z = u.showLegend, C = {
      ...je,
      left: 40,
      // Space for left Y-axis label
      right: _ ? 40 : 20
      // Extra space for right Y-axis label if needed
    }, V = wt(n?.target || ""), P = Ut(V, S.length);
    let Y = S;
    return P.length > 0 && (Y = S.map((F, E) => ({
      ...F,
      __target: P[E] || 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__ */ k("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__ */ k(zr, { data: Y, margin: C, stackOffset: x ? "expand" : void 0, children: [
      u.showGrid && /* @__PURE__ */ o(yt, { strokeDasharray: "3 3" }),
      /* @__PURE__ */ o(gt, { dataKey: "name", tick: { fontSize: 12 }, angle: -45, textAnchor: "end", height: 60 }),
      /* @__PURE__ */ o(
        Ie,
        {
          yAxisId: "left",
          orientation: "left",
          tick: { fontSize: 12 },
          tickFormatter: x ? (F) => `${(F * 100).toFixed(0)}%` : N ? (F) => W(F, N) : void 0,
          domain: x ? [0, 1] : void 0,
          label: x ? void 0 : $.length > 0 ? {
            value: N?.label || c($[0]),
            angle: -90,
            position: "left",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      _ && /* @__PURE__ */ o(
        Ie,
        {
          yAxisId: "right",
          orientation: "right",
          tick: { fontSize: 12 },
          tickFormatter: w ? (F) => W(F, w) : void 0,
          label: T.length > 0 ? {
            value: w?.label || c(T[0]),
            angle: 90,
            position: "right",
            style: { textAnchor: "middle", fontSize: "12px" }
          } : void 0
        }
      ),
      u.showTooltip && /* @__PURE__ */ o(
        Pe,
        {
          formatter: (F, E) => {
            if (F == null)
              return ["No data", E];
            if (E === "Target")
              return [W(F, N), "Target Value"];
            if (x && typeof F == "number")
              return [`${(F * 100).toFixed(1)}%`, E];
            const B = D[E], M = (B && b[B] === "right" ? "right" : "left") === "right" ? w : N;
            return [W(F, M), E];
          }
        }
      ),
      z && /* @__PURE__ */ o(
        Oe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
          iconType: "rect",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (F) => d(String(F.dataKey || "")),
          onMouseLeave: () => d(null)
        }
      ),
      g.map((F, E) => {
        const B = D[F], R = B && b[B] === "right" ? "right" : "left";
        return /* @__PURE__ */ o(
          gn,
          {
            type: "monotone",
            dataKey: F,
            yAxisId: R,
            stackId: y ? "stack" : void 0,
            stroke: a?.colors && a.colors[E % a.colors.length] || G[E % G.length],
            fill: a?.colors && a.colors[E % a.colors.length] || G[E % G.length],
            fillOpacity: l ? l === F ? 0.6 : 0.1 : 0.3,
            strokeWidth: 2,
            strokeOpacity: l ? l === F ? 1 : 0.3 : 1,
            connectNulls: u.connectNulls
          },
          F
        );
      }),
      P.length > 0 && /* @__PURE__ */ k(Vt, { children: [
        /* @__PURE__ */ o(
          Re,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            stroke: "#ffffff",
            strokeWidth: 2,
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        ),
        /* @__PURE__ */ o(
          Re,
          {
            type: "monotone",
            dataKey: "__target",
            yAxisId: "left",
            name: "Target",
            stroke: "#8B5CF6",
            strokeWidth: 2,
            strokeDasharray: "2 3",
            dot: !1,
            activeDot: !1,
            connectNulls: !1
          }
        )
      ] })
    ] }) });
  } catch (f) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ k("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: f instanceof Error ? f.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), Oc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Ws
}, Symbol.toStringTag, { value: "Module" })), Gs = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(null), c = ve();
  try {
    const f = {
      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__ */ k("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 m, h, u, N = [];
    if (r?.xAxis && r?.yAxis)
      h = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, u = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], N = r.series || [];
    else if (r?.x && r?.y)
      h = r.x, u = 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__ */ k("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 || !u || u.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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: A } = Ze(
        t,
        h,
        u,
        i,
        N,
        c
      );
      if (m = [], A.length > 0) {
        const p = A[0];
        Object.keys(p).forEach((v) => {
          v !== "name" && typeof p[v] == "number" && m.push({
            name: String(v),
            value: p[v]
          });
        });
      }
    } else {
      const A = pe(i, h);
      m = t.map((p) => {
        let v = ee(p[h], A) || String(p[h]) || "Unknown";
        return typeof p[h] == "boolean" ? v = p[h] ? "Active" : "Inactive" : (v === "true" || v === "false") && (v = v === "true" ? "Active" : "Inactive"), {
          name: v,
          value: typeof p[u[0]] == "string" ? parseFloat(p[u[0]]) : p[u[0]] || 0
        };
      });
    }
    const w = m.length;
    return m = m.filter(
      (A) => A.value != null && !isNaN(A.value) && A.value !== 0 && A.value > 0
    ), m.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ k("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__ */ k(bn, { children: [
      /* @__PURE__ */ o(
        vn,
        {
          data: m,
          cx: "50%",
          cy: "50%",
          outerRadius: "70%",
          dataKey: "value",
          label: f.showLegend ? void 0 : ({ name: A, percent: p }) => `${A} ${((p || 0) * 100).toFixed(0)}%`,
          children: m.map((A, p) => /* @__PURE__ */ o(
            Ht,
            {
              fill: a?.colors && a.colors[p % a.colors.length] || G[p % G.length],
              fillOpacity: l ? l === m[p].name ? 1 : 0.3 : 1
            },
            `cell-${p}`
          ))
        }
      ),
      f.showTooltip && /* @__PURE__ */ o(
        Pe,
        {
          formatter: f.leftYAxisFormat ? (A, p) => [W(A, f.leftYAxisFormat), p] : void 0
        }
      ),
      f.showLegend && /* @__PURE__ */ o(
        Oe,
        {
          wrapperStyle: { fontSize: "12px", paddingTop: "10px" },
          iconType: "circle",
          iconSize: 8,
          layout: "horizontal",
          align: "center",
          verticalAlign: "bottom",
          onMouseEnter: (A) => d(String(A.value || "")),
          onMouseLeave: () => d(null)
        }
      )
    ] }) });
  } catch (f) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ k("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: f instanceof Error ? f.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), Pc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Gs
}, Symbol.toStringTag, { value: "Module" })), Ks = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(null), c = ve();
  try {
    const f = {
      showLegend: n?.showLegend ?? !0,
      showGrid: n?.showGrid ?? !0,
      showTooltip: n?.showTooltip ?? !0
    }, m = 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__ */ k("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 u, N, w = [];
    if (r?.xAxis && r?.yAxis) {
      u = 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)
      u = 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__ */ k("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 (!u || !N)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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 p = (i?.timeDimensions || []).map((T) => T.dimension);
    let v, S = {};
    if (w.length > 0) {
      const T = w[0];
      t.forEach((x) => {
        const z = String(x[T] || "Default");
        S[z] || (S[z] = []);
        const C = pe(i, u), V = ee(x[u], C) || x[u], P = Ve(x[N]), Y = typeof V == "string" ? parseFloat(V) : V;
        if (ot(Y) && P !== null) {
          const X = {};
          p.forEach((F) => {
            if (x[F]) {
              const E = pe(i, F);
              X[F] = ee(x[F], E);
            }
          }), S[z].push({
            x: Y,
            y: P,
            name: z,
            timeValues: X,
            originalItem: x
          });
        }
      }), v = Object.keys(S).flatMap((x) => S[x]);
    } else {
      const T = pe(i, u);
      v = t.map((y) => {
        const x = ee(y[u], T) || y[u], z = Ve(y[N]), C = typeof x == "string" ? parseFloat(x) : x, V = {};
        return p.forEach((P) => {
          if (y[P]) {
            const Y = pe(i, P);
            V[P] = ee(y[P], Y);
          }
        }), {
          x: C,
          y: z,
          name: "Point",
          timeValues: V,
          originalItem: y,
          isValid: ot(C) && z !== 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__ */ k("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 g = Object.keys(S), D = g.length > 1 && g.length <= 20, _ = f.showLegend && D, $ = {
      ...je,
      left: 40
      // Increased from 20 to 40 for Y-axis label space
    };
    return /* @__PURE__ */ o($e, { height: s, children: /* @__PURE__ */ k(wn, { margin: $, children: [
      f.showGrid && /* @__PURE__ */ o(yt, { strokeDasharray: "3 3" }),
      /* @__PURE__ */ o(
        gt,
        {
          type: "number",
          dataKey: "x",
          name: m?.label || c(u),
          tick: { fontSize: 12 },
          tickFormatter: m ? (T) => W(T, m) : void 0
        }
      ),
      /* @__PURE__ */ o(
        Ie,
        {
          type: "number",
          dataKey: "y",
          name: h?.label || c(N),
          tick: { fontSize: 12 },
          tickFormatter: h ? (T) => W(T, h) : void 0,
          label: { value: h?.label || c(N), angle: -90, position: "left", style: { textAnchor: "middle", fontSize: "12px" } }
        }
      ),
      f.showTooltip && /* @__PURE__ */ o(
        Cr,
        {
          cursor: { strokeDasharray: "3 3" },
          content: ({ active: T, payload: y }) => {
            if (!T || !y || y.length === 0) return null;
            const x = y[0]?.payload;
            return x ? /* @__PURE__ */ k("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: x.name }),
              x.timeValues && Object.keys(x.timeValues).length > 0 && /* @__PURE__ */ o("div", { style: { marginBottom: "4px", color: "#6b7280" }, children: Object.entries(x.timeValues).map(([z, C]) => /* @__PURE__ */ k("div", { children: [
                c(z),
                ": ",
                C
              ] }, z)) }),
              /* @__PURE__ */ k("div", { children: [
                m?.label || c(u),
                ": ",
                W(x.x, m)
              ] }),
              /* @__PURE__ */ k("div", { children: [
                h?.label || c(N),
                ": ",
                W(x.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)
        }
      ),
      D ? (
        // Multiple series
        g.map((T, y) => /* @__PURE__ */ o(
          Jt,
          {
            name: T,
            data: S[T],
            fill: a?.colors && a.colors[y % a.colors.length] || G[y % G.length],
            fillOpacity: l ? l === T ? 1 : 0.3 : 1
          },
          T
        ))
      ) : (
        // Single series
        /* @__PURE__ */ o(
          Jt,
          {
            name: "Data",
            data: v,
            fill: a?.colors && a.colors[0] || G[0]
          }
        )
      )
    ] }) });
  } catch (f) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ k("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: f instanceof Error ? f.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), Hc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Ks
}, Symbol.toStringTag, { value: "Module" })), Xs = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(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__ */ k("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 f, m = [];
    if (r?.xAxis && r?.yAxis) {
      const h = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, u = Array.isArray(r.yAxis) ? r.yAxis : [r.yAxis], N = r.series || [], { data: w, seriesKeys: A } = Ze(
        t,
        h,
        u,
        i,
        N
      );
      f = w, m = A;
    } else {
      const h = t[0], u = Object.keys(h), N = u.find(
        (A) => typeof h[A] == "string" || A.toLowerCase().includes("subject") || A.toLowerCase().includes("name") || A.toLowerCase().includes("category")
      ) || u[0], w = u.filter(
        (A) => typeof h[A] == "number" && A !== 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__ */ k("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 A = pe(i, N);
        f = t.map((p) => {
          const v = {
            name: ee(p[N], A) || String(p[N]) || "Unknown"
          };
          return w.forEach((S) => {
            const g = S.split(".").pop() || S;
            v[g] = typeof p[S] == "string" ? parseFloat(p[S]) : p[S] || 0;
          }), v;
        }), m = w.map((p) => p.split(".").pop() || p);
      } else
        f = t.map((A) => ({
          name: String(A[u[0]] || "Unknown"),
          value: typeof A[w[0]] == "string" ? parseFloat(A[w[0]]) : A[w[0]] || 0
        })), m = ["value"];
    }
    return !f || f.length === 0 ? /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ k("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__ */ k(Nn, { data: f, margin: { top: 20, right: 80, bottom: 20, left: 80 }, children: [
      c.showGrid && /* @__PURE__ */ o(An, {}),
      /* @__PURE__ */ o(
        Sn,
        {
          dataKey: "name",
          tick: { fontSize: 12 },
          className: "text-dc-text-muted"
        }
      ),
      /* @__PURE__ */ o(
        kn,
        {
          tick: { fontSize: 10 },
          className: "text-dc-text-muted",
          tickFormatter: c.leftYAxisFormat ? (h) => W(h, c.leftYAxisFormat) : void 0
        }
      ),
      c.showTooltip && /* @__PURE__ */ o(
        Pe,
        {
          formatter: c.leftYAxisFormat ? (h, u) => [W(h, c.leftYAxisFormat), u] : void 0
        }
      ),
      c.showLegend && m.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)
        }
      ),
      m.map((h, u) => /* @__PURE__ */ o(
        Tn,
        {
          name: h,
          dataKey: h,
          stroke: a?.colors && a.colors[u % a.colors.length] || G[u % G.length],
          fill: a?.colors && a.colors[u % a.colors.length] || G[u % G.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__ */ k("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" })
    ] }) });
  }
}), Yc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Xs
}, Symbol.toStringTag, { value: "Module" })), qs = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(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__ */ k("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 f;
    if (r?.xAxis && r?.yAxis) {
      const m = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, h = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis, u = pe(i, m);
      f = t.map((N, w) => ({
        name: ee(N[m], u) || String(N[m]) || "Unknown",
        value: typeof N[h] == "string" ? parseFloat(N[h]) : N[h] || 0,
        fill: a?.colors && a.colors[w % a.colors.length] || G[w % G.length]
      }));
    } else {
      const m = t[0], h = Object.keys(m), u = h.find(
        (w) => typeof m[w] == "string" || w.toLowerCase().includes("name") || w.toLowerCase().includes("label") || w.toLowerCase().includes("category")
      ) || h[0], N = h.find(
        (w) => typeof m[w] == "number" && w !== u
      ) || h[1];
      if (!N)
        return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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" })
        ] }) });
      f = t.map((w, A) => {
        let p = w[u];
        return typeof p == "boolean" ? p = p ? "Active" : "Inactive" : p === "true" || p === "false" ? p = p === "true" ? "Active" : "Inactive" : p = String(p), {
          name: p,
          value: typeof w[N] == "string" ? parseFloat(w[N]) : w[N] || 0,
          fill: a?.colors && a.colors[A % a.colors.length] || G[A % G.length]
        };
      });
    }
    return f = f.filter((m) => m.value != null && m.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__ */ k("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__ */ k(
      Fn,
      {
        data: f,
        innerRadius: "10%",
        outerRadius: "80%",
        margin: { top: 20, right: 30, bottom: 20, left: 30 },
        children: [
          c.showTooltip && /* @__PURE__ */ o(
            Pe,
            {
              formatter: c.leftYAxisFormat ? (m, h) => [W(m, 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: (m) => d(String(m.value || "")),
              onMouseLeave: () => d(null)
            }
          ),
          /* @__PURE__ */ o(
            Mn,
            {
              dataKey: "value",
              cornerRadius: 4,
              label: {
                position: "insideStart",
                fill: "#fff",
                fontSize: 12,
                formatter: c.leftYAxisFormat ? (m) => W(m, c.leftYAxisFormat) : void 0
              },
              children: f.map((m, h) => /* @__PURE__ */ o(
                Ht,
                {
                  fill: m.fill,
                  fillOpacity: l ? l === m.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__ */ k("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" })
    ] }) });
  }
}), jc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: qs
}, Symbol.toStringTag, { value: "Module" }));
function st(e, t) {
  return e == null || t == null ? NaN : e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Zs(e, t) {
  return e == null || t == null ? NaN : t < e ? -1 : t > e ? 1 : t >= e ? 0 : NaN;
}
function Yr(e) {
  let t, r, n;
  e.length !== 2 ? (t = st, r = (l, d) => st(e(l), d), n = (l, d) => e(l) - d) : (t = e === st || e === Zs ? e : Qs, r = e, n = e);
  function i(l, d, c = 0, f = l.length) {
    if (c < f) {
      if (t(d, d) !== 0) return f;
      do {
        const m = c + f >>> 1;
        r(l[m], d) < 0 ? c = m + 1 : f = m;
      } while (c < f);
    }
    return c;
  }
  function s(l, d, c = 0, f = l.length) {
    if (c < f) {
      if (t(d, d) !== 0) return f;
      do {
        const m = c + f >>> 1;
        r(l[m], d) <= 0 ? c = m + 1 : f = m;
      } while (c < f);
    }
    return c;
  }
  function a(l, d, c = 0, f = l.length) {
    const m = i(l, d, c, f - 1);
    return m > c && n(l[m - 1], d) > -n(l[m], d) ? m - 1 : m;
  }
  return { left: i, center: a, right: s };
}
function Qs() {
  return 0;
}
function Js(e) {
  return e === null ? NaN : +e;
}
const ea = Yr(st), jr = ea.right;
Yr(Js).center;
function ar(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 or extends Map {
  constructor(t, r = na) {
    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(lr(this, t));
  }
  has(t) {
    return super.has(lr(this, t));
  }
  set(t, r) {
    return super.set(ta(this, t), r);
  }
  delete(t) {
    return super.delete(ra(this, t));
  }
}
function lr({ _intern: e, _key: t }, r) {
  const n = t(r);
  return e.has(n) ? e.get(n) : r;
}
function ta({ _intern: e, _key: t }, r) {
  const n = t(r);
  return e.has(n) ? e.get(n) : (e.set(n, r), r);
}
function ra({ _intern: e, _key: t }, r) {
  const n = t(r);
  return e.has(n) && (r = e.get(n), e.delete(n)), r;
}
function na(e) {
  return e !== null && typeof e == "object" ? e.valueOf() : e;
}
const ia = Math.sqrt(50), sa = Math.sqrt(10), aa = Math.sqrt(2);
function lt(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 >= ia ? 10 : s >= sa ? 5 : s >= aa ? 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 ? lt(e, t, r * 2) : [l, d, c];
}
function oa(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 ? lt(t, e, r) : lt(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 $t(e, t, r) {
  return t = +t, e = +e, r = +r, lt(e, t, r)[2];
}
function la(e, t, r) {
  t = +t, e = +e, r = +r;
  const n = t < e, i = n ? $t(t, e, r) : $t(e, t, r);
  return (n ? -1 : 1) * (i < 0 ? 1 / -i : i);
}
function Dt(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 cr(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 ca(e) {
  return e;
}
var Tt = 1, Ft = 2, Ct = 3, We = 4, dr = 1e-6;
function da(e) {
  return "translate(" + e + ",0)";
}
function ua(e) {
  return "translate(0," + e + ")";
}
function fa(e) {
  return (t) => +e(t);
}
function ma(e, t) {
  return t = Math.max(0, e.bandwidth() - t * 2) / 2, e.round() && (t = Math.round(t)), (r) => +e(r) + t;
}
function ha() {
  return !this.__axis;
}
function Ur(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 === Tt || e === We ? -1 : 1, f = e === We || e === Ft ? "x" : "y", m = e === Tt || e === Ct ? da : ua;
  function h(u) {
    var N = n ?? (t.ticks ? t.ticks.apply(t, r) : t.domain()), w = i ?? (t.tickFormat ? t.tickFormat.apply(t, r) : ca), A = Math.max(s, 0) + l, p = t.range(), v = +p[0] + d, S = +p[p.length - 1] + d, g = (t.bandwidth ? ma : fa)(t.copy(), d), b = u.selection ? u.selection() : u, D = b.selectAll(".domain").data([null]), _ = b.selectAll(".tick").data(N, t).order(), $ = _.exit(), T = _.enter().append("g").attr("class", "tick"), y = _.select("line"), x = _.select("text");
    D = D.merge(D.enter().insert("path", ".tick").attr("class", "domain").attr("stroke", "currentColor")), _ = _.merge(T), y = y.merge(T.append("line").attr("stroke", "currentColor").attr(f + "2", c * s)), x = x.merge(T.append("text").attr("fill", "currentColor").attr(f, c * A).attr("dy", e === Tt ? "0em" : e === Ct ? "0.71em" : "0.32em")), u !== b && (D = D.transition(u), _ = _.transition(u), y = y.transition(u), x = x.transition(u), $ = $.transition(u).attr("opacity", dr).attr("transform", function(z) {
      return isFinite(z = g(z)) ? m(z + d) : this.getAttribute("transform");
    }), T.attr("opacity", dr).attr("transform", function(z) {
      var C = this.parentNode.__axis;
      return m((C && isFinite(C = C(z)) ? C : g(z)) + d);
    })), $.remove(), D.attr("d", e === We || e === Ft ? 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(z) {
      return m(g(z) + d);
    }), y.attr(f + "2", c * s), x.attr(f, c * A).text(w), b.filter(ha).attr("fill", "none").attr("font-size", 10).attr("font-family", "sans-serif").attr("text-anchor", e === Ft ? "start" : e === We ? "end" : "middle"), b.each(function() {
      this.__axis = g;
    });
  }
  return h.scale = function(u) {
    return arguments.length ? (t = u, h) : t;
  }, h.ticks = function() {
    return r = Array.from(arguments), h;
  }, h.tickArguments = function(u) {
    return arguments.length ? (r = u == null ? [] : Array.from(u), h) : r.slice();
  }, h.tickValues = function(u) {
    return arguments.length ? (n = u == null ? null : Array.from(u), h) : n && n.slice();
  }, h.tickFormat = function(u) {
    return arguments.length ? (i = u, h) : i;
  }, h.tickSize = function(u) {
    return arguments.length ? (s = a = +u, h) : s;
  }, h.tickSizeInner = function(u) {
    return arguments.length ? (s = +u, h) : s;
  }, h.tickSizeOuter = function(u) {
    return arguments.length ? (a = +u, h) : a;
  }, h.tickPadding = function(u) {
    return arguments.length ? (l = +u, h) : l;
  }, h.offset = function(u) {
    return arguments.length ? (d = +u, h) : d;
  }, h;
}
function ur(e) {
  return Ur(Ct, e);
}
function fr(e) {
  return Ur(We, e);
}
var zt = "http://www.w3.org/1999/xhtml";
const mr = {
  svg: "http://www.w3.org/2000/svg",
  xhtml: zt,
  xlink: "http://www.w3.org/1999/xlink",
  xml: "http://www.w3.org/XML/1998/namespace",
  xmlns: "http://www.w3.org/2000/xmlns/"
};
function Br(e) {
  var t = e += "", r = t.indexOf(":");
  return r >= 0 && (t = e.slice(0, r)) !== "xmlns" && (e = e.slice(r + 1)), mr.hasOwnProperty(t) ? { space: mr[t], local: e } : e;
}
function pa(e) {
  return function() {
    var t = this.ownerDocument, r = this.namespaceURI;
    return r === zt && t.documentElement.namespaceURI === zt ? t.createElement(e) : t.createElementNS(r, e);
  };
}
function xa(e) {
  return function() {
    return this.ownerDocument.createElementNS(e.space, e.local);
  };
}
function Wr(e) {
  var t = Br(e);
  return (t.local ? xa : pa)(t);
}
function ya() {
}
function Gr(e) {
  return e == null ? ya : function() {
    return this.querySelector(e);
  };
}
function ga(e) {
  typeof e != "function" && (e = Gr(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, f = 0; f < a; ++f)
      (d = s[f]) && (c = e.call(d, d.__data__, f, s)) && ("__data__" in d && (c.__data__ = d.__data__), l[f] = c);
  return new ge(n, this._parents);
}
function ba(e) {
  return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
function va() {
  return [];
}
function wa(e) {
  return e == null ? va : function() {
    return this.querySelectorAll(e);
  };
}
function Na(e) {
  return function() {
    return ba(e.apply(this, arguments));
  };
}
function Aa(e) {
  typeof e == "function" ? e = Na(e) : e = wa(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 ge(n, i);
}
function Sa(e) {
  return function() {
    return this.matches(e);
  };
}
function Kr(e) {
  return function(t) {
    return t.matches(e);
  };
}
var ka = Array.prototype.find;
function Ta(e) {
  return function() {
    return ka.call(this.children, e);
  };
}
function Fa() {
  return this.firstElementChild;
}
function Ma(e) {
  return this.select(e == null ? Fa : Ta(typeof e == "function" ? e : Kr(e)));
}
var _a = Array.prototype.filter;
function $a() {
  return Array.from(this.children);
}
function Da(e) {
  return function() {
    return _a.call(this.children, e);
  };
}
function Ca(e) {
  return this.selectAll(e == null ? $a : Da(typeof e == "function" ? e : Kr(e)));
}
function za(e) {
  typeof e != "function" && (e = Sa(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 ge(n, this._parents);
}
function Xr(e) {
  return new Array(e.length);
}
function La() {
  return new ge(this._enter || this._groups.map(Xr), this._parents);
}
function ct(e, t) {
  this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
ct.prototype = {
  constructor: ct,
  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 Ra(e) {
  return function() {
    return e;
  };
}
function Ea(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 ct(e, s[a]);
  for (; a < d; ++a)
    (l = t[a]) && (i[a] = l);
}
function Ia(e, t, r, n, i, s, a) {
  var l, d, c = /* @__PURE__ */ new Map(), f = t.length, m = s.length, h = new Array(f), u;
  for (l = 0; l < f; ++l)
    (d = t[l]) && (h[l] = u = a.call(d, d.__data__, l, t) + "", c.has(u) ? i[l] = d : c.set(u, d));
  for (l = 0; l < m; ++l)
    u = a.call(e, s[l], l, s) + "", (d = c.get(u)) ? (n[l] = d, d.__data__ = s[l], c.delete(u)) : r[l] = new ct(e, s[l]);
  for (l = 0; l < f; ++l)
    (d = t[l]) && c.get(h[l]) === d && (i[l] = d);
}
function Va(e) {
  return e.__data__;
}
function Oa(e, t) {
  if (!arguments.length) return Array.from(this, Va);
  var r = t ? Ia : Ea, n = this._parents, i = this._groups;
  typeof e != "function" && (e = Ra(e));
  for (var s = i.length, a = new Array(s), l = new Array(s), d = new Array(s), c = 0; c < s; ++c) {
    var f = n[c], m = i[c], h = m.length, u = Pa(e.call(f, f && f.__data__, c, n)), N = u.length, w = l[c] = new Array(N), A = a[c] = new Array(N), p = d[c] = new Array(h);
    r(f, m, w, A, p, u, t);
    for (var v = 0, S = 0, g, b; v < N; ++v)
      if (g = w[v]) {
        for (v >= S && (S = v + 1); !(b = A[S]) && ++S < N; ) ;
        g._next = b || null;
      }
  }
  return a = new ge(a, n), a._enter = l, a._exit = d, a;
}
function Pa(e) {
  return typeof e == "object" && "length" in e ? e : Array.from(e);
}
function Ha() {
  return new ge(this._exit || this._groups.map(Xr), this._parents);
}
function Ya(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 ja(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], f = n[d], m = c.length, h = l[d] = new Array(m), u, N = 0; N < m; ++N)
      (u = c[N] || f[N]) && (h[N] = u);
  for (; d < i; ++d)
    l[d] = r[d];
  return new ge(l, this._parents);
}
function Ua() {
  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 Ba(e) {
  e || (e = Wa);
  function t(m, h) {
    return m && h ? e(m.__data__, h.__data__) : !m - !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, f = 0; f < l; ++f)
      (c = a[f]) && (d[f] = c);
    d.sort(t);
  }
  return new ge(i, this._parents).order();
}
function Wa(e, t) {
  return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
function Ga() {
  var e = arguments[0];
  return arguments[0] = this, e.apply(null, arguments), this;
}
function Ka() {
  return Array.from(this);
}
function Xa() {
  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 qa() {
  let e = 0;
  for (const t of this) ++e;
  return e;
}
function Za() {
  return !this.node();
}
function Qa(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 Ja(e) {
  return function() {
    this.removeAttribute(e);
  };
}
function eo(e) {
  return function() {
    this.removeAttributeNS(e.space, e.local);
  };
}
function to(e, t) {
  return function() {
    this.setAttribute(e, t);
  };
}
function ro(e, t) {
  return function() {
    this.setAttributeNS(e.space, e.local, t);
  };
}
function no(e, t) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? this.removeAttribute(e) : this.setAttribute(e, r);
  };
}
function io(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 so(e, t) {
  var r = Br(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 ? eo : Ja : typeof t == "function" ? r.local ? io : no : r.local ? ro : to)(r, t));
}
function qr(e) {
  return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
function ao(e) {
  return function() {
    this.style.removeProperty(e);
  };
}
function oo(e, t, r) {
  return function() {
    this.style.setProperty(e, t, r);
  };
}
function lo(e, t, r) {
  return function() {
    var n = t.apply(this, arguments);
    n == null ? this.style.removeProperty(e) : this.style.setProperty(e, n, r);
  };
}
function co(e, t, r) {
  return arguments.length > 1 ? this.each((t == null ? ao : typeof t == "function" ? lo : oo)(e, t, r ?? "")) : uo(this.node(), e);
}
function uo(e, t) {
  return e.style.getPropertyValue(t) || qr(e).getComputedStyle(e, null).getPropertyValue(t);
}
function fo(e) {
  return function() {
    delete this[e];
  };
}
function mo(e, t) {
  return function() {
    this[e] = t;
  };
}
function ho(e, t) {
  return function() {
    var r = t.apply(this, arguments);
    r == null ? delete this[e] : this[e] = r;
  };
}
function po(e, t) {
  return arguments.length > 1 ? this.each((t == null ? fo : typeof t == "function" ? ho : mo)(e, t)) : this.node()[e];
}
function Zr(e) {
  return e.trim().split(/^|\s+/);
}
function Bt(e) {
  return e.classList || new Qr(e);
}
function Qr(e) {
  this._node = e, this._names = Zr(e.getAttribute("class") || "");
}
Qr.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 Jr(e, t) {
  for (var r = Bt(e), n = -1, i = t.length; ++n < i; ) r.add(t[n]);
}
function en(e, t) {
  for (var r = Bt(e), n = -1, i = t.length; ++n < i; ) r.remove(t[n]);
}
function xo(e) {
  return function() {
    Jr(this, e);
  };
}
function yo(e) {
  return function() {
    en(this, e);
  };
}
function go(e, t) {
  return function() {
    (t.apply(this, arguments) ? Jr : en)(this, e);
  };
}
function bo(e, t) {
  var r = Zr(e + "");
  if (arguments.length < 2) {
    for (var n = Bt(this.node()), i = -1, s = r.length; ++i < s; ) if (!n.contains(r[i])) return !1;
    return !0;
  }
  return this.each((typeof t == "function" ? go : t ? xo : yo)(r, t));
}
function vo() {
  this.textContent = "";
}
function wo(e) {
  return function() {
    this.textContent = e;
  };
}
function No(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.textContent = t ?? "";
  };
}
function Ao(e) {
  return arguments.length ? this.each(e == null ? vo : (typeof e == "function" ? No : wo)(e)) : this.node().textContent;
}
function So() {
  this.innerHTML = "";
}
function ko(e) {
  return function() {
    this.innerHTML = e;
  };
}
function To(e) {
  return function() {
    var t = e.apply(this, arguments);
    this.innerHTML = t ?? "";
  };
}
function Fo(e) {
  return arguments.length ? this.each(e == null ? So : (typeof e == "function" ? To : ko)(e)) : this.node().innerHTML;
}
function Mo() {
  this.nextSibling && this.parentNode.appendChild(this);
}
function _o() {
  return this.each(Mo);
}
function $o() {
  this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function Do() {
  return this.each($o);
}
function Co(e) {
  var t = typeof e == "function" ? e : Wr(e);
  return this.select(function() {
    return this.appendChild(t.apply(this, arguments));
  });
}
function zo() {
  return null;
}
function Lo(e, t) {
  var r = typeof e == "function" ? e : Wr(e), n = t == null ? zo : typeof t == "function" ? t : Gr(t);
  return this.select(function() {
    return this.insertBefore(r.apply(this, arguments), n.apply(this, arguments) || null);
  });
}
function Ro() {
  var e = this.parentNode;
  e && e.removeChild(this);
}
function Eo() {
  return this.each(Ro);
}
function Io() {
  var e = this.cloneNode(!1), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function Vo() {
  var e = this.cloneNode(!0), t = this.parentNode;
  return t ? t.insertBefore(e, this.nextSibling) : e;
}
function Oo(e) {
  return this.select(e ? Vo : Io);
}
function Po(e) {
  return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
function Ho(e) {
  return function(t) {
    e.call(this, t, this.__data__);
  };
}
function Yo(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 jo(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 Uo(e, t, r) {
  return function() {
    var n = this.__on, i, s = Ho(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 Bo(e, t, r) {
  var n = Yo(e + ""), i, s = n.length, a;
  if (arguments.length < 2) {
    var l = this.node().__on;
    if (l) {
      for (var d = 0, c = l.length, f; d < c; ++d)
        for (i = 0, f = l[d]; i < s; ++i)
          if ((a = n[i]).type === f.type && a.name === f.name)
            return f.value;
    }
    return;
  }
  for (l = t ? Uo : jo, i = 0; i < s; ++i) this.each(l(n[i], t, r));
  return this;
}
function tn(e, t, r) {
  var n = qr(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 Wo(e, t) {
  return function() {
    return tn(this, e, t);
  };
}
function Go(e, t) {
  return function() {
    return tn(this, e, t.apply(this, arguments));
  };
}
function Ko(e, t) {
  return this.each((typeof t == "function" ? Go : Wo)(e, t));
}
function* Xo() {
  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 qo = [null];
function ge(e, t) {
  this._groups = e, this._parents = t;
}
function Zo() {
  return this;
}
ge.prototype = {
  constructor: ge,
  select: ga,
  selectAll: Aa,
  selectChild: Ma,
  selectChildren: Ca,
  filter: za,
  data: Oa,
  enter: La,
  exit: Ha,
  join: Ya,
  merge: ja,
  selection: Zo,
  order: Ua,
  sort: Ba,
  call: Ga,
  nodes: Ka,
  node: Xa,
  size: qa,
  empty: Za,
  each: Qa,
  attr: so,
  style: co,
  property: po,
  classed: bo,
  text: Ao,
  html: Fo,
  raise: _o,
  lower: Do,
  append: Co,
  insert: Lo,
  remove: Eo,
  clone: Oo,
  datum: Po,
  on: Bo,
  dispatch: Ko,
  [Symbol.iterator]: Xo
};
function Ae(e) {
  return typeof e == "string" ? new ge([[document.querySelector(e)]], [document.documentElement]) : new ge([[e]], qo);
}
function Wt(e, t, r) {
  e.prototype = t.prototype = r, r.constructor = e;
}
function rn(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, dt = 1 / Ke, He = "\\s*([+-]?\\d+)\\s*", Xe = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", ke = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", Qo = /^#([0-9a-f]{3,8})$/, Jo = new RegExp(`^rgb\\(${He},${He},${He}\\)$`), el = new RegExp(`^rgb\\(${ke},${ke},${ke}\\)$`), tl = new RegExp(`^rgba\\(${He},${He},${He},${Xe}\\)$`), rl = new RegExp(`^rgba\\(${ke},${ke},${ke},${Xe}\\)$`), nl = new RegExp(`^hsl\\(${Xe},${ke},${ke}\\)$`), il = new RegExp(`^hsla\\(${Xe},${ke},${ke},${Xe}\\)$`), hr = {
  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
};
Wt(Qe, qe, {
  copy(e) {
    return Object.assign(new this.constructor(), this, e);
  },
  displayable() {
    return this.rgb().displayable();
  },
  hex: pr,
  // Deprecated! Use color.formatHex.
  formatHex: pr,
  formatHex8: sl,
  formatHsl: al,
  formatRgb: xr,
  toString: xr
});
function pr() {
  return this.rgb().formatHex();
}
function sl() {
  return this.rgb().formatHex8();
}
function al() {
  return nn(this).formatHsl();
}
function xr() {
  return this.rgb().formatRgb();
}
function qe(e) {
  var t, r;
  return e = (e + "").trim().toLowerCase(), (t = Qo.exec(e)) ? (r = t[1].length, t = parseInt(t[1], 16), r === 6 ? yr(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 = Jo.exec(e)) ? new he(t[1], t[2], t[3], 1) : (t = el.exec(e)) ? new he(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = tl.exec(e)) ? et(t[1], t[2], t[3], t[4]) : (t = rl.exec(e)) ? et(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = nl.exec(e)) ? vr(t[1], t[2] / 100, t[3] / 100, 1) : (t = il.exec(e)) ? vr(t[1], t[2] / 100, t[3] / 100, t[4]) : hr.hasOwnProperty(e) ? yr(hr[e]) : e === "transparent" ? new he(NaN, NaN, NaN, 0) : null;
}
function yr(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 ol(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 Lt(e, t, r, n) {
  return arguments.length === 1 ? ol(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;
}
Wt(he, Lt, rn(Qe, {
  brighter(e) {
    return e = e == null ? dt : Math.pow(dt, 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(Ee(this.r), Ee(this.g), Ee(this.b), ut(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: gr,
  // Deprecated! Use color.formatHex.
  formatHex: gr,
  formatHex8: ll,
  formatRgb: br,
  toString: br
}));
function gr() {
  return `#${ze(this.r)}${ze(this.g)}${ze(this.b)}`;
}
function ll() {
  return `#${ze(this.r)}${ze(this.g)}${ze(this.b)}${ze((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function br() {
  const e = ut(this.opacity);
  return `${e === 1 ? "rgb(" : "rgba("}${Ee(this.r)}, ${Ee(this.g)}, ${Ee(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function ut(e) {
  return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function Ee(e) {
  return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function ze(e) {
  return e = Ee(e), (e < 16 ? "0" : "") + e.toString(16);
}
function vr(e, t, r, n) {
  return n <= 0 ? e = t = r = NaN : r <= 0 || r >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new be(e, t, r, n);
}
function nn(e) {
  if (e instanceof be) return new be(e.h, e.s, e.l, e.opacity);
  if (e instanceof Qe || (e = qe(e)), !e) return new be();
  if (e instanceof be) 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 be(a, l, d, e.opacity);
}
function cl(e, t, r, n) {
  return arguments.length === 1 ? nn(e) : new be(e, t, r, n ?? 1);
}
function be(e, t, r, n) {
  this.h = +e, this.s = +t, this.l = +r, this.opacity = +n;
}
Wt(be, cl, rn(Qe, {
  brighter(e) {
    return e = e == null ? dt : Math.pow(dt, e), new be(this.h, this.s, this.l * e, this.opacity);
  },
  darker(e) {
    return e = e == null ? Ke : Math.pow(Ke, e), new be(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(
      Mt(e >= 240 ? e - 240 : e + 120, i, n),
      Mt(e, i, n),
      Mt(e < 120 ? e + 240 : e - 120, i, n),
      this.opacity
    );
  },
  clamp() {
    return new be(wr(this.h), tt(this.s), tt(this.l), ut(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 = ut(this.opacity);
    return `${e === 1 ? "hsl(" : "hsla("}${wr(this.h)}, ${tt(this.s) * 100}%, ${tt(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
  }
}));
function wr(e) {
  return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function tt(e) {
  return Math.max(0, Math.min(1, e || 0));
}
function Mt(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 Gt = (e) => () => e;
function dl(e, t) {
  return function(r) {
    return e + r * t;
  };
}
function ul(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 fl(e) {
  return (e = +e) == 1 ? sn : function(t, r) {
    return r - t ? ul(t, r, e) : Gt(isNaN(t) ? r : t);
  };
}
function sn(e, t) {
  var r = t - e;
  return r ? dl(e, r) : Gt(isNaN(e) ? t : e);
}
const Nr = (function e(t) {
  var r = fl(t);
  function n(i, s) {
    var a = r((i = Lt(i)).r, (s = Lt(s)).r), l = r(i.g, s.g), d = r(i.b, s.b), c = sn(i.opacity, s.opacity);
    return function(f) {
      return i.r = a(f), i.g = l(f), i.b = d(f), i.opacity = c(f), i + "";
    };
  }
  return n.gamma = e, n;
})(1);
function ml(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 hl(e) {
  return ArrayBuffer.isView(e) && !(e instanceof DataView);
}
function pl(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] = Kt(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 xl(e, t) {
  var r = /* @__PURE__ */ new Date();
  return e = +e, t = +t, function(n) {
    return r.setTime(e * (1 - n) + t * n), r;
  };
}
function ft(e, t) {
  return e = +e, t = +t, function(r) {
    return e * (1 - r) + t * r;
  };
}
function yl(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] = Kt(e[i], t[i]) : n[i] = t[i];
  return function(s) {
    for (i in r) n[i] = r[i](s);
    return n;
  };
}
var Rt = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, _t = new RegExp(Rt.source, "g");
function gl(e) {
  return function() {
    return e;
  };
}
function bl(e) {
  return function(t) {
    return e(t) + "";
  };
}
function vl(e, t) {
  var r = Rt.lastIndex = _t.lastIndex = 0, n, i, s, a = -1, l = [], d = [];
  for (e = e + "", t = t + ""; (n = Rt.exec(e)) && (i = _t.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: ft(n, i) })), r = _t.lastIndex;
  return r < t.length && (s = t.slice(r), l[a] ? l[a] += s : l[++a] = s), l.length < 2 ? d[0] ? bl(d[0].x) : gl(t) : (t = d.length, function(c) {
    for (var f = 0, m; f < t; ++f) l[(m = d[f]).i] = m.x(c);
    return l.join("");
  });
}
function Kt(e, t) {
  var r = typeof t, n;
  return t == null || r === "boolean" ? Gt(t) : (r === "number" ? ft : r === "string" ? (n = qe(t)) ? (t = n, Nr) : vl : t instanceof qe ? Nr : t instanceof Date ? xl : hl(t) ? ml : Array.isArray(t) ? pl : typeof t.valueOf != "function" && typeof t.toString != "function" || isNaN(t) ? yl : ft)(e, t);
}
function wl(e, t) {
  return e = +e, t = +t, function(r) {
    return Math.round(e * (1 - r) + t * r);
  };
}
function Nl(e) {
  return Math.abs(e = Math.round(e)) >= 1e21 ? e.toLocaleString("en").replace(/,/g, "") : e.toString(10);
}
function mt(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 = mt(Math.abs(e)), e ? e[1] : NaN;
}
function Al(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 Sl(e) {
  return function(t) {
    return t.replace(/[0-9]/g, function(r) {
      return e[+r];
    });
  };
}
var kl = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
function ht(e) {
  if (!(t = kl.exec(e))) throw new Error("invalid format: " + e);
  var t;
  return new Xt({
    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]
  });
}
ht.prototype = Xt.prototype;
function Xt(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 + "";
}
Xt.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 Tl(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 an;
function Fl(e, t) {
  var r = mt(e, t);
  if (!r) return e + "";
  var n = r[0], i = r[1], s = i - (an = 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") + mt(e, Math.max(0, t + s - 1))[0];
}
function Ar(e, t) {
  var r = mt(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 Sr = {
  "%": (e, t) => (e * 100).toFixed(t),
  b: (e) => Math.round(e).toString(2),
  c: (e) => e + "",
  d: Nl,
  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) => Ar(e * 100, t),
  r: Ar,
  s: Fl,
  X: (e) => Math.round(e).toString(16).toUpperCase(),
  x: (e) => Math.round(e).toString(16)
};
function kr(e) {
  return e;
}
var Tr = Array.prototype.map, Fr = ["y", "z", "a", "f", "p", "n", "µ", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
function Ml(e) {
  var t = e.grouping === void 0 || e.thousands === void 0 ? kr : Al(Tr.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 ? kr : Sl(Tr.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(m) {
    m = ht(m);
    var h = m.fill, u = m.align, N = m.sign, w = m.symbol, A = m.zero, p = m.width, v = m.comma, S = m.precision, g = m.trim, b = m.type;
    b === "n" ? (v = !0, b = "g") : Sr[b] || (S === void 0 && (S = 12), g = !0, b = "g"), (A || h === "0" && u === "=") && (A = !0, h = "0", u = "=");
    var D = w === "$" ? r : w === "#" && /[boxX]/.test(b) ? "0" + b.toLowerCase() : "", _ = w === "$" ? n : /[%p]/.test(b) ? a : "", $ = Sr[b], T = /[defgprs%]/.test(b);
    S = S === void 0 ? 6 : /[gprs]/.test(b) ? Math.max(1, Math.min(21, S)) : Math.max(0, Math.min(20, S));
    function y(x) {
      var z = D, C = _, V, P, Y;
      if (b === "c")
        C = $(x) + C, x = "";
      else {
        x = +x;
        var X = x < 0 || 1 / x < 0;
        if (x = isNaN(x) ? d : $(Math.abs(x), S), g && (x = Tl(x)), X && +x == 0 && N !== "+" && (X = !1), z = (X ? N === "(" ? N : l : N === "-" || N === "(" ? "" : N) + z, C = (b === "s" ? Fr[8 + an / 3] : "") + C + (X && N === "(" ? ")" : ""), T) {
          for (V = -1, P = x.length; ++V < P; )
            if (Y = x.charCodeAt(V), 48 > Y || Y > 57) {
              C = (Y === 46 ? i + x.slice(V + 1) : x.slice(V)) + C, x = x.slice(0, V);
              break;
            }
        }
      }
      v && !A && (x = t(x, 1 / 0));
      var F = z.length + x.length + C.length, E = F < p ? new Array(p - F + 1).join(h) : "";
      switch (v && A && (x = t(E + x, E.length ? p - C.length : 1 / 0), E = ""), u) {
        case "<":
          x = z + x + C + E;
          break;
        case "=":
          x = z + E + x + C;
          break;
        case "^":
          x = E.slice(0, F = E.length >> 1) + z + x + C + E.slice(F);
          break;
        default:
          x = E + z + x + C;
          break;
      }
      return s(x);
    }
    return y.toString = function() {
      return m + "";
    }, y;
  }
  function f(m, h) {
    var u = c((m = ht(m), m.type = "f", m)), N = Math.max(-8, Math.min(8, Math.floor(Ue(h) / 3))) * 3, w = Math.pow(10, -N), A = Fr[8 + N / 3];
    return function(p) {
      return u(w * p) + A;
    };
  }
  return {
    format: c,
    formatPrefix: f
  };
}
var rt, on, ln;
_l({
  thousands: ",",
  grouping: [3],
  currency: ["$", ""]
});
function _l(e) {
  return rt = Ml(e), on = rt.format, ln = rt.formatPrefix, rt;
}
function $l(e) {
  return Math.max(0, -Ue(Math.abs(e)));
}
function Dl(e, t) {
  return Math.max(0, Math.max(-8, Math.min(8, Math.floor(Ue(t) / 3))) * 3 - Ue(Math.abs(e)));
}
function Cl(e, t) {
  return e = Math.abs(e), t = Math.abs(t) - e, Math.max(0, Ue(t) - Ue(e)) + 1;
}
function Nt(e, t) {
  switch (arguments.length) {
    case 0:
      break;
    case 1:
      this.range(e);
      break;
    default:
      this.range(t).domain(e);
      break;
  }
  return this;
}
const Mr = /* @__PURE__ */ Symbol("implicit");
function pt() {
  var e = new or(), t = [], r = [], n = Mr;
  function i(s) {
    let a = e.get(s);
    if (a === void 0) {
      if (n !== Mr) 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 or();
    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 pt(t, r).unknown(n);
  }, Nt.apply(i, arguments), i;
}
function zl(e) {
  return function() {
    return e;
  };
}
function Ll(e) {
  return +e;
}
var _r = [0, 1];
function Se(e) {
  return e;
}
function Et(e, t) {
  return (t -= e = +e) ? function(r) {
    return (r - e) / t;
  } : zl(isNaN(t) ? NaN : 0.5);
}
function Rl(e, t) {
  var r;
  return e > t && (r = e, e = t, t = r), function(n) {
    return Math.max(e, Math.min(t, n));
  };
}
function El(e, t, r) {
  var n = e[0], i = e[1], s = t[0], a = t[1];
  return i < n ? (n = Et(i, n), s = r(a, s)) : (n = Et(n, i), s = r(s, a)), function(l) {
    return s(n(l));
  };
}
function Il(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] = Et(e[a], e[a + 1]), s[a] = r(t[a], t[a + 1]);
  return function(l) {
    var d = jr(e, l, 1, n) - 1;
    return s[d](i[d](l));
  };
}
function cn(e, t) {
  return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown());
}
function dn() {
  var e = _r, t = _r, r = Kt, n, i, s, a = Se, l, d, c;
  function f() {
    var h = Math.min(e.length, t.length);
    return a !== Se && (a = Rl(e[0], e[h - 1])), l = h > 2 ? Il : El, d = c = null, m;
  }
  function m(h) {
    return h == null || isNaN(h = +h) ? s : (d || (d = l(e.map(n), t, r)))(n(a(h)));
  }
  return m.invert = function(h) {
    return a(i((c || (c = l(t, e.map(n), ft)))(h)));
  }, m.domain = function(h) {
    return arguments.length ? (e = Array.from(h, Ll), f()) : e.slice();
  }, m.range = function(h) {
    return arguments.length ? (t = Array.from(h), f()) : t.slice();
  }, m.rangeRound = function(h) {
    return t = Array.from(h), r = wl, f();
  }, m.clamp = function(h) {
    return arguments.length ? (a = h ? !0 : Se, f()) : a !== Se;
  }, m.interpolate = function(h) {
    return arguments.length ? (r = h, f()) : r;
  }, m.unknown = function(h) {
    return arguments.length ? (s = h, m) : s;
  }, function(h, u) {
    return n = h, i = u, f();
  };
}
function Vl() {
  return dn()(Se, Se);
}
function Ol(e, t, r, n) {
  var i = la(e, t, r), s;
  switch (n = ht(n ?? ",f"), n.type) {
    case "s": {
      var a = Math.max(Math.abs(e), Math.abs(t));
      return n.precision == null && !isNaN(s = Dl(i, a)) && (n.precision = s), ln(n, a);
    }
    case "":
    case "e":
    case "g":
    case "p":
    case "r": {
      n.precision == null && !isNaN(s = Cl(i, Math.max(Math.abs(e), Math.abs(t)))) && (n.precision = s - (n.type === "e"));
      break;
    }
    case "f":
    case "%": {
      n.precision == null && !isNaN(s = $l(i)) && (n.precision = s - (n.type === "%") * 2);
      break;
    }
  }
  return on(n);
}
function qt(e) {
  var t = e.domain;
  return e.ticks = function(r) {
    var n = t();
    return oa(n[0], n[n.length - 1], r ?? 10);
  }, e.tickFormat = function(r, n) {
    var i = t();
    return Ol(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, f = 10;
    for (l < a && (c = a, a = l, l = c, c = i, i = s, s = c); f-- > 0; ) {
      if (c = $t(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 It() {
  var e = Vl();
  return e.copy = function() {
    return cn(e, It());
  }, Nt.apply(e, arguments), qt(e);
}
function $r(e) {
  return function(t) {
    return t < 0 ? -Math.pow(-t, e) : Math.pow(t, e);
  };
}
function Pl(e) {
  return e < 0 ? -Math.sqrt(-e) : Math.sqrt(e);
}
function Hl(e) {
  return e < 0 ? -e * e : e * e;
}
function Yl(e) {
  var t = e(Se, Se), r = 1;
  function n() {
    return r === 1 ? e(Se, Se) : r === 0.5 ? e(Pl, Hl) : e($r(r), $r(1 / r));
  }
  return t.exponent = function(i) {
    return arguments.length ? (r = +i, n()) : r;
  }, qt(t);
}
function un() {
  var e = Yl(dn());
  return e.copy = function() {
    return cn(e, un()).exponent(e.exponent());
  }, Nt.apply(e, arguments), e;
}
function jl() {
  return un.apply(null, arguments).exponent(0.5);
}
function At() {
  var e = 0, t = 1, r = 1, n = [0.5], i = [0, 1], s;
  function a(d) {
    return d != null && d <= d ? i[jr(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 At().domain([e, t]).range(i).unknown(s);
  }, Nt.apply(qt(a), arguments);
}
const Ul = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(null), c = ve();
  try {
    const f = {
      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__ */ k("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 m, h = !1, u;
    if (r?.xAxis && r?.yAxis) {
      const g = Array.isArray(r.xAxis) ? r.xAxis[0] : r.xAxis, b = Array.isArray(r.yAxis) ? r.yAxis[0] : r.yAxis;
      u = Array.isArray(r.series) ? r.series[0] : r.series;
      const D = pe(i, g);
      if (u) {
        const _ = t.map(($) => {
          const T = $[u];
          return typeof T == "string" ? parseFloat(T) : T;
        }).filter(($) => !isNaN($));
        if (h = _.length === t.length && _.every(($) => typeof $ == "number"), h) {
          const $ = Math.min(..._), T = Math.max(..._), y = At().domain([$, T]).range(Ce);
          m = t.map((x) => {
            const z = typeof x[u] == "string" ? parseFloat(x[u]) : x[u], C = y(z);
            return {
              name: ee(x[g], D) || String(x[g]) || "Unknown",
              size: typeof x[b] == "string" ? parseFloat(x[b]) : x[b] || 0,
              fill: C,
              series: String(x[u])
            };
          });
        } else {
          const $ = [...new Set(t.map((y) => String(y[u])))], T = pt().domain($).range(a?.colors || G);
          m = t.map((y) => ({
            name: ee(y[g], D) || String(y[g]) || "Unknown",
            size: typeof y[b] == "string" ? parseFloat(y[b]) : y[b] || 0,
            fill: T(String(y[u])),
            series: String(y[u])
          }));
        }
      } else
        m = t.map((_, $) => ({
          name: ee(_[g], D) || String(_[g]) || "Unknown",
          size: typeof _[b] == "string" ? parseFloat(_[b]) : _[b] || 0,
          fill: a?.colors && a.colors[$ % a.colors.length] || G[$ % G.length]
        }));
    } else {
      const g = t[0], b = Object.keys(g), D = b.find(
        ($) => typeof g[$] == "string" || $.toLowerCase().includes("name") || $.toLowerCase().includes("label") || $.toLowerCase().includes("category")
      ) || b[0], _ = b.find(($) => $.toLowerCase().includes("size")) || b.find(
        ($) => typeof g[$] == "number" && $ !== D
      ) || b[1];
      if (!_)
        return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-warning", style: { height: s }, children: /* @__PURE__ */ k("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" })
        ] }) });
      m = t.map(($, T) => {
        let y = $[D];
        return typeof y == "boolean" ? y = y ? "Active" : "Inactive" : y === "true" || y === "false" ? y = y === "true" ? "Active" : "Inactive" : y = String(y), {
          name: y,
          size: typeof $[_] == "string" ? parseFloat($[_]) : $[_] || 0,
          fill: a?.colors && a.colors[T % a.colors.length] || G[T % G.length]
        };
      });
    }
    if (m = m.filter((g) => g.size != null && g.size > 0), m.length === 0)
      return /* @__PURE__ */ o("div", { className: "flex items-center justify-center w-full text-dc-text-muted", style: { height: s }, children: /* @__PURE__ */ k("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 = (g) => {
      const { x: b, y: D, width: _, height: $, index: T, name: y, size: x } = g;
      return _ < 20 || $ < 20 ? null : /* @__PURE__ */ k("g", { children: [
        /* @__PURE__ */ o(
          "rect",
          {
            x: b,
            y: D,
            width: _,
            height: $,
            style: {
              fill: m[T]?.fill || a?.colors && a.colors[T % a.colors.length] || G[T % G.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: b,
            y: D,
            width: _,
            height: $,
            style: { pointerEvents: "none", overflow: "visible" },
            children: /* @__PURE__ */ k(
              "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 && $ > 30 && /* @__PURE__ */ o(
                    "div",
                    {
                      style: {
                        fontSize: `${Math.max(10, Math.min(_ / 8, $ / 8, 16))}px`,
                        fontWeight: "600",
                        textAlign: "center",
                        lineHeight: "1.2",
                        marginBottom: _ > 60 && $ > 45 ? "4px" : "0",
                        wordBreak: "break-word",
                        hyphens: "auto"
                      },
                      children: y
                    }
                  ),
                  _ > 60 && $ > 45 && /* @__PURE__ */ o(
                    "div",
                    {
                      style: {
                        fontSize: `${Math.max(8, Math.min(_ / 10, $ / 10, 14))}px`,
                        textAlign: "center",
                        opacity: 0.9
                      },
                      children: f.leftYAxisFormat ? W(x, f.leftYAxisFormat) : typeof x == "number" ? x.toLocaleString() : x
                    }
                  )
                ]
              }
            )
          }
        )
      ] });
    }, A = m.some((g) => "series" in g) ? [...new Set(m.map((g) => g.series).filter(Boolean))] : [];
    let p = [];
    if (f.showLegend && u)
      if (h) {
        const g = Math.min(...t.map((D) => {
          const _ = D[u];
          return typeof _ == "string" ? parseFloat(_) : _;
        })), b = Math.max(...t.map((D) => {
          const _ = D[u];
          return typeof _ == "string" ? parseFloat(_) : _;
        }));
        p = Ce.map((D, _) => {
          const $ = _ / (Ce.length - 1), T = g + (b - g) * $;
          return {
            value: f.leftYAxisFormat ? W(T, f.leftYAxisFormat) : T.toFixed(2),
            type: "rect",
            color: D
          };
        });
      } else A.length > 1 && (p = A.map((g, b) => ({
        value: g,
        type: "rect",
        color: G[b % G.length]
      })));
    const v = f.showLegend && p.length > 0, S = v ? typeof s == "string" && s.includes("%") ? s : typeof s == "number" ? s + 60 : `calc(${s} + 60px)` : s;
    return /* @__PURE__ */ k("div", { className: "w-full", style: { height: S }, children: [
      /* @__PURE__ */ o($e, { height: v ? "calc(100% - 50px)" : "100%", children: /* @__PURE__ */ o(
        _n,
        {
          data: m,
          dataKey: "size",
          aspectRatio: 4 / 3,
          stroke: "#fff",
          content: /* @__PURE__ */ o(N, {}),
          children: f.showTooltip && /* @__PURE__ */ o(
            Pe,
            {
              formatter: f.leftYAxisFormat ? (g, b) => [W(g, f.leftYAxisFormat), b] : void 0
            }
          )
        }
      ) }),
      v && /* @__PURE__ */ o("div", { className: "flex justify-center items-center mt-4 pb-2", children: h ? (
        // Gradient legend for numeric series
        /* @__PURE__ */ k("div", { className: "flex flex-col items-center", children: [
          /* @__PURE__ */ o("div", { className: "text-xs font-semibold text-dc-text-primary mb-2", children: u ? c(u) : "" }),
          /* @__PURE__ */ k("div", { className: "flex items-center gap-2", children: [
            /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: f.leftYAxisFormat ? W(Math.min(...t.map((g) => {
              const b = g[u];
              return typeof b == "string" ? parseFloat(b) : b;
            })), f.leftYAxisFormat) : Math.min(...t.map((g) => {
              const b = g[u];
              return typeof b == "string" ? parseFloat(b) : b;
            })).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: f.leftYAxisFormat ? W(Math.max(...t.map((g) => {
              const b = g[u];
              return typeof b == "string" ? parseFloat(b) : b;
            })), f.leftYAxisFormat) : Math.max(...t.map((g) => {
              const b = g[u];
              return typeof b == "string" ? parseFloat(b) : b;
            })).toFixed(2) })
          ] })
        ] })
      ) : (
        // Discrete legend for categorical series
        /* @__PURE__ */ o("div", { className: "flex flex-wrap justify-center gap-4", children: p.map((g, b) => /* @__PURE__ */ k("div", { className: "flex items-center gap-2", children: [
          /* @__PURE__ */ o(
            "div",
            {
              className: "w-3 h-3 rounded-xs",
              style: { backgroundColor: g.color }
            }
          ),
          /* @__PURE__ */ o("span", { className: "text-xs text-dc-text-muted", children: g.value })
        ] }, b)) })
      ) })
    ] });
  } catch (f) {
    return /* @__PURE__ */ o("div", { className: "flex flex-col items-center justify-center w-full text-dc-error p-4", style: { height: s }, children: /* @__PURE__ */ k("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: f instanceof Error ? f.message : "Unknown rendering error" }),
      /* @__PURE__ */ o("div", { className: "text-xs text-dc-text-muted", children: "Check the data and configuration" })
    ] }) });
  }
}), Uc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Ul
}, Symbol.toStringTag, { value: "Module" })), Bl = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const l = ye(null), d = ye(null), [c, f] = Q({ width: 0, height: 0 }), [m, h] = Q(!1), { theme: u } = ws(), N = ve(), w = Z(() => ({
    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 Pt(() => {
    let p = 0;
    const v = 10;
    let S, g;
    const b = () => {
      if (d.current) {
        const { width: _, height: $ } = d.current.getBoundingClientRect();
        if (_ > 0 && $ > 0)
          return f({ width: _, height: $ }), h(!0), !0;
      }
      return !1;
    };
    if (!b() && p < v) {
      const _ = () => {
        !b() && p < v && (p++, g = setTimeout(() => {
          S = requestAnimationFrame(_);
        }, 50 * p));
      };
      S = requestAnimationFrame(_);
    }
    return () => {
      S && cancelAnimationFrame(S), g && clearTimeout(g);
    };
  }, []), Te(() => {
    let p = null;
    const v = () => {
      if (d.current) {
        const { width: S, height: g } = d.current.getBoundingClientRect();
        S > 0 && g > 0 && (f({ width: S, height: g }), m || h(!0));
      }
    };
    return d.current && (p = new ResizeObserver((S) => {
      for (const g of S) {
        const { width: b, height: D } = g.contentRect;
        b > 0 && D > 0 && (f({ width: b, height: D }), m || h(!0));
      }
    }), p.observe(d.current), v()), window.addEventListener("resize", v), () => {
      p && p.disconnect(), window.removeEventListener("resize", v);
    };
  }, [m]), Te(() => {
    if (!t || t.length === 0 || !l.current || !m || c.width === 0 || (Ae(l.current).selectAll("*").remove(), !r?.xAxis || !r?.yAxis || !r?.series))
      return;
    const p = 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, g = Array.isArray(r.sizeField) ? r.sizeField[0] : r.sizeField || v, b = Array.isArray(r.colorField) ? r.colorField[0] : r.colorField;
    if (!p || !v || !S || !g)
      return;
    const D = pe(i, p), _ = i?.timeDimensions?.some(
      (L) => L.dimension === p
    ) || !1, $ = t.map((L) => {
      const I = L[p];
      let q, ne;
      if (_ && I) {
        const re = String(I);
        let ce;
        if (re.match(/^\d{4}-\d{2}-\d{2}[T ]/)) {
          let Ne = re;
          re.includes(" ") && (Ne = re.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(re);
        q = isNaN(ce.getTime()) ? parseFloat(re) : ce.getTime(), ne = ee(I, D);
      } else {
        const re = ee(I, D) || I;
        q = typeof re == "string" ? parseFloat(re) : re, ne = String(re);
      }
      const ie = Ve(L[v]), xe = Ve(L[g]), ae = L[S];
      return {
        x: q,
        xLabel: ne,
        // Store formatted label for tooltip display
        y: ie,
        // Type assertion: filter below ensures this is never null
        size: xe !== null ? Math.abs(xe) : 0,
        // Ensure positive size
        color: b ? L[b] : ae,
        series: ae,
        label: `${ae || "Unknown"}`,
        isValid: ot(q) && ie !== null && xe !== null && xe > 0
      };
    }).filter((L) => L.isValid && L.size > 0);
    if ($.length === 0) return;
    const T = {
      ...je,
      left: je.left + 30,
      // Add extra 30px left margin for Y-axis label
      bottom: w.showLegend && b ? 100 : 40
      // Add extra space for legend
    }, y = c.width - T.left - T.right, x = c.height - T.top - T.bottom, z = Ae(l.current).attr("width", c.width).attr("height", c.height), C = z.append("g").attr("transform", `translate(${T.left},${T.top})`), V = It().domain(ar($, (L) => L.x)).range([0, y]).nice(), P = It().domain(ar($, (L) => L.y)).range([x, 0]).nice(), Y = jl().domain([0, Dt($, (L) => L.size)]).range([w.minBubbleSize, w.maxBubbleSize]);
    let X, F = !1, E = [];
    if (b && $.length > 0) {
      const L = $.map((I) => {
        const q = I.color;
        return typeof q == "string" ? parseFloat(q) : q;
      }).filter((I) => !isNaN(I));
      if (F = L.length === $.length && L.every((I) => typeof I == "number"), F) {
        const I = Math.min(...L), q = Math.max(...L);
        X = At().domain([I, q]).range(a?.gradient || Ce);
      } else
        E = [...new Set($.map((I) => String(I.color)))], X = pt().domain(E).range(a?.colors || G);
    } else
      X = pt().domain(["default"]).range([G[0]]);
    const B = (L, I) => getComputedStyle(document.documentElement).getPropertyValue(L).trim() || I, R = u !== "light", M = R ? B("--dc-text-muted", "#cbd5e1") : B("--dc-text-secondary", "#374151"), U = R ? B("--dc-border", "#475569") : "#9ca3af";
    if (w.showGrid) {
      const L = C.append("g").attr("class", "grid").attr("transform", `translate(0,${x})`).call(
        ur(V).tickSize(-x).tickFormat(() => "")
      );
      L.selectAll("line").style("stroke", U).style("stroke-dasharray", "3,3").style("opacity", 0.3), L.select(".domain").style("stroke", "none");
      const I = C.append("g").attr("class", "grid").call(
        fr(P).tickSize(-y).tickFormat(() => "")
      );
      I.selectAll("line").style("stroke", U).style("stroke-dasharray", "3,3").style("opacity", 0.3), I.select(".domain").style("stroke", "none");
    }
    const O = ur(V);
    _ ? O.tickFormat((L) => {
      const I = new Date(L);
      if (isNaN(I.getTime())) return String(L);
      switch (D?.toLowerCase()) {
        case "year":
          return String(I.getUTCFullYear());
        case "quarter": {
          const q = Math.floor(I.getUTCMonth() / 3) + 1;
          return `${I.getUTCFullYear()}-Q${q}`;
        }
        case "month":
          return `${I.getUTCFullYear()}-${String(I.getUTCMonth() + 1).padStart(2, "0")}`;
        case "week":
        case "day":
          return `${I.getUTCFullYear()}-${String(I.getUTCMonth() + 1).padStart(2, "0")}-${String(I.getUTCDate()).padStart(2, "0")}`;
        case "hour":
          return `${String(I.getUTCMonth() + 1).padStart(2, "0")}-${String(I.getUTCDate()).padStart(2, "0")} ${String(I.getUTCHours()).padStart(2, "0")}:00`;
        default:
          return `${I.getUTCFullYear()}-${String(I.getUTCMonth() + 1).padStart(2, "0")}`;
      }
    }) : w.xAxisFormat && O.tickFormat((L) => W(L, w.xAxisFormat));
    const K = C.append("g").attr("transform", `translate(0,${x})`).call(O);
    K.selectAll("text").style("fill", M), K.selectAll("line, path").style("stroke", U), K.append("text").attr("x", y / 2).attr("y", 35).attr("fill", M).style("text-anchor", "middle").style("font-size", "12px").text(w.xAxisFormat?.label || N(p));
    const te = fr(P);
    w.leftYAxisFormat && te.tickFormat((L) => W(L, w.leftYAxisFormat));
    const fe = C.append("g").call(te);
    fe.selectAll("text").style("fill", M), fe.selectAll("line, path").style("stroke", U), fe.append("text").attr("transform", "rotate(-90)").attr("y", -35).attr("x", -x / 2).attr("fill", M).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 = C.selectAll(".bubble").data($).enter().append("circle").attr("class", "bubble").attr("cx", (L) => V(L.x)).attr("cy", (L) => P(L.y)).attr("r", (L) => Y(L.size)).style("fill", (L) => b && L.color !== void 0 ? X(F ? L.color : String(L.color)) : G[0]).style("opacity", w.bubbleOpacity).style("stroke", "#fff").style("stroke-width", 1).style("cursor", "pointer");
    if (w.showTooltip && we.on("mouseover", function(L, I) {
      Ae(this).transition().duration(200).style("opacity", 1).attr("r", Y(I.size) * 1.1);
      const q = [
        `<strong>${I.series || "Unknown"}</strong>`,
        `${N(p)}: ${I.xLabel || (w.xAxisFormat ? W(I.x, w.xAxisFormat) : I.x)}`,
        `${N(v)}: ${w.leftYAxisFormat ? W(I.y, w.leftYAxisFormat) : I.y}`,
        `${N(g)}: ${w.leftYAxisFormat ? W(I.size, w.leftYAxisFormat) : I.size}`,
        b && I.color ? `${N(b)}: ${I.color}` : ""
      ].filter(Boolean).join("<br>");
      me.html(q).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, I) {
      Ae(this).transition().duration(200).style("opacity", w.bubbleOpacity).attr("r", Y(I.size)), me.transition().duration(200).style("opacity", 0);
    }), w.showLegend && b)
      if (F) {
        const q = Math.min(...$.map((ce) => ce.color)), ne = Math.max(...$.map((ce) => ce.color)), ie = C.append("g").attr("class", "color-legend").attr("transform", `translate(${y / 2 - 200 / 2}, ${x + 60})`), ae = z.append("defs").append("linearGradient").attr("id", "color-scale-gradient").attr("x1", "0%").attr("y1", "0%").attr("x2", "100%").attr("y2", "0%"), re = a?.gradient || Ce;
        re.forEach((ce, Ne) => {
          ae.append("stop").attr("offset", `${Ne / (re.length - 1) * 100}%`).attr("stop-color", ce);
        }), ie.append("rect").attr("width", 200).attr("height", 20).style("fill", "url(#color-scale-gradient)").style("stroke", "#ccc").style("stroke-width", 1), ie.append("text").attr("x", 0).attr("y", 35).attr("text-anchor", "start").style("font-size", "11px").style("fill", M).text(w.leftYAxisFormat ? W(q, w.leftYAxisFormat) : q.toFixed(2)), ie.append("text").attr("x", 200).attr("y", 35).attr("text-anchor", "end").style("font-size", "11px").style("fill", M).text(w.leftYAxisFormat ? W(ne, w.leftYAxisFormat) : ne.toFixed(2)), ie.append("text").attr("x", 200 / 2).attr("y", -5).attr("text-anchor", "middle").style("font-size", "12px").style("font-weight", "bold").style("fill", M).text(N(b));
      } else {
        const L = E;
        if (L.length > 0) {
          const q = C.append("g").attr("class", "legend").attr("transform", `translate(${y / 2 - L.length * 80 / 2}, ${x + 60})`).selectAll(".legend-item").data(L).enter().append("g").attr("class", "legend-item").attr("transform", (ne, ie) => `translate(${ie * 80}, 0)`).style("cursor", "pointer");
          q.append("circle").attr("cx", 5).attr("cy", 5).attr("r", 5).style("fill", (ne) => X(ne)).style("opacity", w.bubbleOpacity), q.append("text").attr("x", 15).attr("y", 5).attr("dy", ".35em").style("font-size", "11px").style("fill", M).text((ne) => String(ne)), q.on("mouseover", function(ne, ie) {
            we.transition().duration(200).style("opacity", (xe) => b && String(xe.color) === ie ? 1 : 0.2);
          }).on("mouseout", function() {
            we.transition().duration(200).style("opacity", w.bubbleOpacity);
          });
        }
      }
    return () => {
      me.remove();
    };
  }, [t, r, w, i, c, m, a, u, 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__ */ k("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__ */ k("div", { ref: d, className: "w-full h-full relative", children: [
    /* @__PURE__ */ o("svg", { ref: l, className: "w-full h-full" }),
    !m && /* @__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__ */ k("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" })
  ] }) });
}), Bc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Bl
}, Symbol.toStringTag, { value: "Module" })), Wl = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = 300
}) {
  const { getFieldLabel: a, meta: l } = qi(), d = Z(
    () => Fs(i, r?.xAxis),
    [i, r?.xAxis]
  ), c = n?.pivotTimeDimension !== !1, f = Z(() => !d || !c ? null : Cs(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__ */ k("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" })
      ] })
    }
  ) : f?.isPivoted && f.columns.length > 0 ? /* @__PURE__ */ o(
    Gl,
    {
      pivotedData: f,
      height: s,
      meta: l,
      leftYAxisFormat: n?.leftYAxisFormat
    }
  ) : /* @__PURE__ */ o(
    Xl,
    {
      data: t,
      chartConfig: r,
      queryObject: i,
      height: s,
      getFieldLabel: a,
      leftYAxisFormat: n?.leftYAxisFormat
    }
  );
});
function Gl({
  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__ */ k("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__ */ k("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(
      Kl,
      {
        row: a,
        columns: i,
        meta: r,
        leftYAxisFormat: n
      },
      a.id
    )) })
  ] }) });
}
function Kl({
  row: e,
  columns: t,
  meta: r,
  leftYAxisFormat: n
}) {
  const i = zs(e.measureField, r), s = Zi(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__ */ k("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: Dr(l, n)
      },
      a.key
    ) : /* @__PURE__ */ o(
      "td",
      {
        className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
        children: Dr(l)
      },
      a.key
    );
  }) });
}
function Dr(e, t) {
  return e == null ? "-" : typeof e == "number" ? t ? W(e, t) : Number.isInteger(e) ? e.toLocaleString() : parseFloat(e.toFixed(2)).toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
}
function Xl({
  data: e,
  chartConfig: t,
  queryObject: r,
  height: n,
  getFieldLabel: i,
  leftYAxisFormat: s
}) {
  const a = Object.keys(e[0] || {}), l = Z(() => {
    if (t?.xAxis && t.xAxis.length > 0)
      return t.xAxis.filter((c) => a.includes(c));
    const d = Ts(r);
    if (d.length > 0) {
      const c = d.filter((m) => a.includes(m)), f = a.filter((m) => !c.includes(m));
      return [...c, ...f];
    }
    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__ */ k("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__ */ k("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((f) => /* @__PURE__ */ o(
      "td",
      {
        className: "px-3 py-2 whitespace-nowrap text-sm text-dc-text",
        children: ql(d[f], s)
      },
      f
    )) }, c)) })
  ] }) });
}
function ql(e, t) {
  return e == null ? "" : typeof e == "number" ? t ? W(e, t) : e.toLocaleString() : typeof e == "boolean" ? e ? "Yes" : "No" : String(e);
}
const Wc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Wl
}, Symbol.toStringTag, { value: "Module" })), Zl = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const l = ye(null), d = ye(null), [c, f] = Q({ width: 0, height: 0 }), [m, h] = Q(!1), [u, N] = Q("light"), w = ve();
  Te(() => (N(Ye()), Or((y) => {
    N(y);
  })), []);
  const A = {
    showTooltip: n?.showTooltip ?? !0,
    showLabels: n?.showLabels ?? !0,
    fitToWidth: n?.fitToWidth ?? !1
  };
  Pt(() => {
    let T = 0;
    const y = 10;
    let x, z;
    const C = () => {
      if (d.current) {
        const { width: P, height: Y } = d.current.getBoundingClientRect();
        if (P > 0 && Y > 0)
          return f({ width: P, height: Y }), h(!0), !0;
      }
      return !1;
    };
    if (!C() && T < y) {
      const P = () => {
        !C() && T < y && (T++, z = setTimeout(() => {
          x = requestAnimationFrame(P);
        }, 50 * T));
      };
      x = requestAnimationFrame(P);
    }
    return () => {
      x && cancelAnimationFrame(x), z && clearTimeout(z);
    };
  }, []), Te(() => {
    let T = null;
    const y = () => {
      if (d.current) {
        const { width: x, height: z } = d.current.getBoundingClientRect();
        x > 0 && z > 0 && (f({ width: x, height: z }), m || 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);
    };
  }, [m]);
  const p = (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;
  }, g = (T) => {
    switch (T?.toLowerCase()) {
      case "year":
        return null;
      case "quarter":
        return {
          extractX: (y) => y.getFullYear(),
          extractY: (y) => p(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 x = y.getFullYear(), z = p(y);
            return x * 10 + z;
          },
          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 x = y.getFullYear(), z = y.getMonth() + 1;
            return x * 100 + z;
          },
          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 x = y % 100;
            return ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"][x - 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: x, week: z } = b(y);
            return x * 100 + z;
          },
          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 x = y.getFullYear(), z = y.getMonth() + 1, C = y.getDate();
            return x * 1e4 + z * 100 + C;
          },
          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;
    }
  }, b = (T) => {
    const y = new Date(Date.UTC(T.getFullYear(), T.getMonth(), T.getDate())), x = y.getUTCDay() || 7;
    y.setUTCDate(y.getUTCDate() + 4 - x);
    const z = y.getUTCFullYear(), C = new Date(Date.UTC(z, 0, 1)), V = Math.ceil(((y.getTime() - C.getTime()) / 864e5 + 1) / 7);
    return { year: z, week: V };
  };
  if (Te(() => {
    if (!t || t.length === 0 || !l.current || !m || 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 z = (() => {
      if (!i?.timeDimensions || i.timeDimensions.length === 0)
        return "day";
      const H = i.timeDimensions.find(
        (J) => J.dimension === T || J.dimension.includes(T)
      );
      if (H && H.granularity)
        return H.granularity;
      const j = i.timeDimensions[0];
      return j && j.granularity ? j.granularity : "day";
    })(), C = g(z);
    if (!C)
      return;
    const V = t.map((H) => {
      const j = H[T], J = typeof H[y] == "string" ? parseFloat(H[y]) : H[y] || 0;
      let se;
      if (typeof j == "string") {
        let oe = j;
        j.includes(" ") && (oe = j.replace(" ", "T").replace("+00", "Z").replace(/\+\d{2}:\d{2}$/, "Z")), !oe.endsWith("Z") && !oe.includes("+") && (oe = oe + "Z"), se = new Date(oe);
      } else
        se = new Date(j);
      if (isNaN(se.getTime()))
        return null;
      const Fe = C.extractX(se), Me = C.extractY(se);
      return {
        x: Fe,
        y: Me,
        value: J,
        date: se,
        label: ee(j, z)
      };
    }).filter((H) => H !== null);
    if (V.length === 0) return;
    const P = Dt(V, (H) => H.y) || 0, Y = cr(V, (H) => H.y) || 0, F = (() => {
      const H = [...new Set(V.map((j) => j.x))].sort();
      return H;
    })(), E = F.length * C.cellWidth + (F.length - 1) * 4, B = (P - Y + 1) * C.cellHeight + (P - Y) * 4, R = {
      left: 60,
      // Space for Y-axis labels
      bottom: 10,
      // Reduced since labels are at top
      top: C.hasHierarchicalLabels ? 40 : 25,
      // Extra space for hierarchical labels
      right: 10
    }, M = c.width - R.left - R.right, U = c.height - R.top - R.bottom;
    let O, K;
    if (A.fitToWidth) {
      const H = M / E, j = U / B, J = Math.min(H, j);
      O = C.cellWidth * J, K = C.cellHeight * J;
    } else {
      const j = { width: 16, height: 16 }, J = 24, se = M / E, Fe = U / B, Me = Math.min(se, Fe);
      O = Math.max(j.width, Math.min(J, C.cellWidth * Me)), K = Math.max(j.height, Math.min(J, C.cellHeight * Me)), z === "week" && O < j.width && (O = j.width);
    }
    const te = F.length * O + (F.length - 1) * 4, me = te > M ? te + R.left + R.right : c.width, L = Ae(l.current).attr("width", me).attr("height", c.height).append("g").attr("transform", `translate(${R.left},${R.top})`), I = V.map((H) => H.value), q = cr(I) || 0, ne = Dt(I) || 1, ie = At().domain([q, ne]).range(a?.gradient || Ce), xe = /* @__PURE__ */ new Map();
    V.forEach((H) => {
      const j = `${H.x}-${H.y}`;
      xe.set(j, H);
    });
    const ae = (H, j) => getComputedStyle(document.documentElement).getPropertyValue(H).trim() || j, re = u !== "light", ce = re ? ae("--dc-text-muted", "#cbd5e1") : ae("--dc-text-secondary", "#374151"), Ne = ae("--dc-border", "#e5e7eb"), mn = re ? ae("--dc-bg-secondary", "#1e293b") : ae("--dc-bg-secondary", "#f3f4f6"), Zt = re ? 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();
    F.forEach((H, j) => {
      Be.set(H, j);
    });
    for (const H of F)
      for (let j = Y; j <= P; j++) {
        const J = `${H}-${j}`, se = xe.get(J), Fe = Be.get(H) || 0, Me = L.append("rect").attr("x", Fe * (O + 4)).attr("y", (j - Y) * (K + 4)).attr("width", O).attr("height", K).attr("rx", 2).attr("ry", 2).style("fill", se ? ie(se.value) : mn).style("stroke", Zt).style("stroke-width", 1);
        A.showTooltip && Me.style("cursor", "pointer").on("mouseover", function(oe) {
          if (Ae(this).style("stroke", "#000").style("stroke-width", 2), se) {
            const De = [
              `<strong>${se.label}</strong>`,
              `${w(y)}: ${se.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", Zt).style("stroke-width", 1), Je.transition().duration(200).style("opacity", 0);
        });
      }
    if (A.showLabels) {
      if (C.hasHierarchicalLabels && C.getYearFromX) {
        const H = /* @__PURE__ */ new Map();
        for (const j of F) {
          const J = C.getYearFromX(j);
          H.has(J) || H.set(J, []), H.get(J).push(j);
        }
        for (const j of F) {
          const J = Be.get(j) || 0;
          L.append("text").attr("x", J * (O + 4) + O / 2).attr("y", -8).attr("text-anchor", "middle").style("font-size", "10px").style("fill", ce).text(C.xFormat(j));
        }
        for (const [j, J] of H)
          if (J.length > 0) {
            const se = Math.min(...J.map((De) => Be.get(De) || 0)), Fe = Math.max(...J.map((De) => Be.get(De) || 0)), Me = (se + Fe) / 2;
            let oe = "";
            if (j > 9999) {
              const De = Math.floor(j / 100), hn = j % 100;
              oe = `${["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][hn - 1]} '${De.toString().slice(-2)}`;
            } else
              oe = `'${j.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), J.length > 1 && L.append("line").attr("x1", se * (O + 4)).attr("x2", Fe * (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(F.length / 10));
        for (let j = 0; j < F.length; j += H) {
          const J = F[j];
          L.append("text").attr("x", j * (O + 4) + O / 2).attr("y", -8).attr("text-anchor", "middle").style("font-size", "10px").style("fill", ce).text(C.xFormat(J));
        }
      }
      for (let H = Y; H <= P; H++)
        L.append("text").attr("x", -8).attr("y", (H - Y) * (K + 4) + K / 2).attr("text-anchor", "end").attr("dy", ".35em").style("font-size", "10px").style("fill", ce).text(C.yFormat(H));
    }
    return () => {
      Je.remove();
    };
  }, [t, r, n, i, c, m, A.showTooltip, A.showLabels, a, u]), !t || t.length === 0)
    return /* @__PURE__ */ o(
      "div",
      {
        className: "flex items-center justify-center w-full",
        style: { height: s },
        children: /* @__PURE__ */ k("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__ */ k("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__ */ k("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__ */ k("div", { ref: d, className: "w-full h-full relative overflow-x-auto", style: { width: "100%" }, children: [
    /* @__PURE__ */ o("svg", { ref: l, className: "h-full" }),
    !m && /* @__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..." }) })
  ] }) });
}), Gc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Zl
}, Symbol.toStringTag, { value: "Module" }));
function fn({
  values: e,
  min: t,
  max: r,
  color: n = "#1f2937",
  bucketCount: i = 12,
  height: s = 32,
  formatValue: a = (f) => f.toString(),
  width: l,
  showAverageIndicator: d = !0,
  targetValue: c
}) {
  const f = new Array(i).fill(0), m = r - t;
  e.forEach((A) => {
    if (m === 0)
      f[Math.floor(i / 2)]++;
    else {
      let p = Math.floor((A - t) / m * (i - 1));
      p = Math.max(0, Math.min(i - 1, p)), f[p]++;
    }
  });
  const h = Math.max(...f), u = e.reduce((A, p) => A + p, 0) / e.length, N = m === 0 ? 50 : (u - t) / m * 100, w = c !== void 0 && m > 0 ? (c - t) / m * 100 : null;
  return /* @__PURE__ */ k("div", { className: "flex flex-col items-center", children: [
    /* @__PURE__ */ k(
      "div",
      {
        className: "relative flex items-end justify-center space-x-0.5",
        style: {
          height: `${s}px`,
          width: l ? `${l}px` : "200px",
          minWidth: "200px"
        },
        children: [
          f.map((A, p) => {
            const v = h > 0 ? A / h : 0, S = 0.1, g = A > 0 ? Math.max(S, v) : S;
            return /* @__PURE__ */ o(
              "div",
              {
                className: "flex-1 rounded-t-sm transition-all duration-300 ease-out",
                style: {
                  height: `${g * s}px`,
                  backgroundColor: n,
                  opacity: A > 0 ? 0.7 + v * 0.3 : 0.2
                  // higher opacity for buckets with data
                },
                title: `${A} values in this range`
              },
              p
            );
          }),
          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(u)}`,
              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__ */ k(
      "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__ */ k("div", { className: "text-center mt-1 text-xs text-dc-text-muted", children: [
      "Average of ",
      e.length,
      " values"
    ] })
  ] });
}
const Ql = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(32), [c, f] = Q(250), m = ye(null), h = ye(null), u = ve();
  if (Te(() => {
    const R = () => {
      if (m.current) {
        const K = m.current.getBoundingClientRect(), te = K.width, fe = K.height;
        if (te > 0 && fe > 0) {
          const me = te / 5, we = fe / 4, L = Math.min(me, we), I = Math.max(24, Math.min(L, 120));
          d(I), setTimeout(() => {
            if (h.current) {
              const ne = h.current.getBoundingClientRect().width, ie = Math.max(ne, Math.min(te * 0.6, 300));
              f(ie);
            }
          }, 10);
        }
      }
    }, M = setTimeout(R, 50), U = new ResizeObserver(() => {
      setTimeout(R, 10);
    });
    return m.current && U.observe(m.current), () => {
      clearTimeout(M), 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__ */ k("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__ */ k("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], A = i?.timeDimensions?.[0]?.dimension || void 0, p = Z(() => {
    let R = [...t];
    return A && (R = R.sort((M, U) => {
      const O = M[A], K = U[A];
      return O < K ? -1 : O > K ? 1 : 0;
    })), R;
  }, [t, A]), { useLastCompletePeriod: v = !0, skipLastPeriod: S = !1 } = n, {
    filteredData: g,
    excludedIncompletePeriod: b,
    skippedLastPeriod: D,
    granularity: _
  } = Z(() => Pr(p, A, i, v, S), [p, A, i, v, S]), $ = g, T = Z(() => $.map((M) => {
    if (M[w] !== void 0)
      return M[w];
    const U = Object.keys(M).filter(
      (O) => typeof M[O] == "number" && !isNaN(M[O])
    );
    if (U.length > 0)
      return M[U[0]];
  }).filter((M) => M != null && !isNaN(Number(M))).map((M) => Number(M)), [$, w]);
  if (T.length === 0)
    return /* @__PURE__ */ k(
      "div",
      {
        ref: m,
        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: u(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: x, max: z } = Z(() => {
    const M = T.reduce((K, te) => K + te, 0) / T.length, U = Math.min(...T), O = Math.max(...T);
    return { avg: M, min: U, max: O };
  }, [T]), C = Le((R) => {
    if (n.formatValue)
      return n.formatValue(R);
    if (R == null)
      return "—";
    const M = n.decimals ?? 0, U = n.prefix ?? "";
    let O;
    return Math.abs(R) >= 1e9 ? O = (R / 1e9).toFixed(M) + "B" : Math.abs(R) >= 1e6 ? O = (R / 1e6).toFixed(M) + "M" : Math.abs(R) >= 1e3 ? O = (R / 1e3).toFixed(M) + "K" : O = R.toFixed(M), U + O;
  }, [n.formatValue, n.decimals, n.prefix]), V = T.length === 1 ? T[0] : y, P = T.length > 1, Y = Z(() => {
    if (n.valueColorIndex !== void 0 && a?.colors) {
      const R = n.valueColorIndex;
      if (R >= 0 && R < a.colors.length)
        return a.colors[R];
    }
    return a?.colors?.[0] || "#1f2937";
  }, [n.valueColorIndex, a?.colors]), X = Z(() => wt(n?.target || ""), [n?.target]), F = X.length > 0 ? X[0] : null, E = F !== null ? Ys(V, F) : null, B = Z(() => {
    if (E === null) return "#6B7280";
    if (E >= 0) {
      const R = n.positiveColorIndex ?? 1;
      return a?.colors?.[R] || "#10B981";
    } else {
      const R = n.negativeColorIndex ?? 7;
      return a?.colors?.[R] || "#EF4444";
    }
  }, [E, n.positiveColorIndex, n.negativeColorIndex, a?.colors]);
  return /* @__PURE__ */ k(
    "div",
    {
      ref: m,
      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__ */ k(
          "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 R = u(w);
                return R && R.length > 1 ? R : w;
              })() }),
              (b || D) && /* @__PURE__ */ o(
                "span",
                {
                  title: D ? `Excludes last ${_ || "period"}` : `Excludes current incomplete ${_}`,
                  className: "cursor-help",
                  children: /* @__PURE__ */ o(at, { icon: Yt, className: "w-4 h-4 text-dc-text-muted opacity-70" })
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ k("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: Y
              },
              children: C(V)
            }
          ),
          F !== null && E !== null && /* @__PURE__ */ k("div", { className: "flex flex-col items-start", children: [
            /* @__PURE__ */ o(
              "div",
              {
                className: "font-semibold",
                style: {
                  fontSize: `${Math.max(12, l * 0.3)}px`,
                  color: B,
                  lineHeight: "1.2"
                },
                children: js(E, 1)
              }
            ),
            /* @__PURE__ */ k(
              "div",
              {
                className: "text-dc-text-muted text-xs",
                style: {
                  opacity: 0.7,
                  fontSize: `${Math.max(10, l * 0.2)}px`
                },
                children: [
                  "vs ",
                  C(F)
                ]
              }
            )
          ] })
        ] }),
        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
          }
        ),
        P && /* @__PURE__ */ o("div", { className: "mt-4", children: /* @__PURE__ */ o(
          fn,
          {
            values: T,
            min: x,
            max: z,
            color: Y,
            formatValue: C,
            height: 24,
            width: c,
            targetValue: F || void 0
          }
        ) })
      ]
    }
  );
}), Kc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: Ql
}, Symbol.toStringTag, { value: "Module" }));
function Jl({
  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), f = Math.min(...c, 0), m = Math.max(...c, 0);
  if (Math.max(Math.abs(f), Math.abs(m)) === 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 u = 2, N = s - (d.length - 1) * u, w = Math.max(4, N / d.length), A = m - f, p = A > 0 ? m / A * 100 : 50;
  return /* @__PURE__ */ k("div", { className: "flex items-center space-x-2", children: [
    /* @__PURE__ */ k(
      "div",
      {
        className: "relative",
        style: {
          width: `${s}px`,
          height: `${a}px`
        },
        children: [
          /* @__PURE__ */ o(
            "div",
            {
              className: "absolute left-0 right-0",
              style: {
                height: "1px",
                top: `${p}%`,
                backgroundColor: "var(--dc-border)",
                zIndex: 1
              }
            }
          ),
          c.map((v, S) => {
            const g = Math.abs(v) / A, b = Math.max(2, g * (a - 4)), D = v >= 0, _ = S === d.length - 1, $ = D ? r : n, T = S * (w + u);
            return /* @__PURE__ */ o(
              "div",
              {
                className: "absolute rounded-xs",
                style: {
                  left: `${T}px`,
                  width: `${w}px`,
                  height: `${b}px`,
                  backgroundColor: $,
                  opacity: _ ? 1 : 0.6,
                  // Position bar relative to zero line
                  ...D ? { bottom: `${100 - p}%` } : { top: `${p}%` },
                  zIndex: 2
                },
                title: `${i(d[S])}: ${v >= 0 ? "+" : ""}${i(v)} vs current`
              },
              S
            );
          })
        ]
      }
    ),
    /* @__PURE__ */ k(
      "div",
      {
        className: "flex flex-col justify-between text-xs text-dc-text-muted",
        style: { height: `${a}px` },
        children: [
          /* @__PURE__ */ k("span", { children: [
            "+",
            i(m)
          ] }),
          /* @__PURE__ */ k("span", { children: [
            (f < 0, ""),
            i(f)
          ] })
        ]
      }
    )
  ] });
}
const ec = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  queryObject: i,
  height: s = "100%",
  colorPalette: a
}) {
  const [l, d] = Q(32), [c, f] = Q(250), m = ye(null), h = ye(null), u = ve();
  if (Te(() => {
    const M = () => {
      if (m.current) {
        const te = m.current.getBoundingClientRect(), fe = te.width, me = te.height;
        if (fe > 0 && me > 0) {
          const we = fe / 4, L = me / 4, I = Math.min(we, L), q = Math.max(28, Math.min(I, 140));
          d(q), setTimeout(() => {
            if (h.current) {
              const ie = h.current.getBoundingClientRect().width, xe = fe - 100, ae = Math.max(
                ie,
                Math.min(xe, fe * 0.7)
              );
              f(Math.max(100, ae));
            }
          }, 10);
        }
      }
    }, U = setTimeout(M, 50), O = new ResizeObserver(() => {
      setTimeout(M, 10);
    });
    return m.current && O.observe(m.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__ */ k("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__ */ k("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 A = N[0], p = w[0];
  let v = [...t];
  p && (v = v.sort((M, U) => {
    const O = M[p], K = U[p];
    return O < K ? -1 : O > K ? 1 : 0;
  }));
  const { useLastCompletePeriod: S = !0, skipLastPeriod: g = !1 } = n, {
    filteredData: b,
    excludedIncompletePeriod: D,
    skippedLastPeriod: _,
    granularity: $
  } = Pr(
    v,
    p,
    i,
    S,
    g
  ), y = b.map((M) => M[A]).filter((M) => M != null && !isNaN(Number(M))).map((M) => Number(M));
  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__ */ k("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__ */ k("div", { className: "text-xs", children: [
            "Current data points: ",
            y.length
          ] })
        ] })
      }
    );
  const x = y[y.length - 1], z = y[y.length - 2], C = x - z, V = z !== 0 ? C / Math.abs(z) * 100 : 0, P = C >= 0, Y = (M) => {
    if (n.formatValue)
      return n.formatValue(M);
    if (M == null)
      return "—";
    const U = n.decimals ?? 0, O = n.prefix ?? "";
    let K;
    return Math.abs(M) >= 1e9 ? K = (M / 1e9).toFixed(U) + "B" : Math.abs(M) >= 1e6 ? K = (M / 1e6).toFixed(U) + "M" : Math.abs(M) >= 1e3 ? K = (M / 1e3).toFixed(U) + "K" : K = M.toFixed(U), O + K;
  }, X = () => {
    if (n.positiveColorIndex !== void 0 && a?.colors) {
      const M = n.positiveColorIndex;
      if (M >= 0 && M < a.colors.length)
        return a.colors[M];
    }
    return "#10b981";
  }, F = () => {
    if (n.negativeColorIndex !== void 0 && a?.colors) {
      const M = n.negativeColorIndex;
      if (M >= 0 && M < a.colors.length)
        return a.colors[M];
    }
    return "#ef4444";
  }, E = X(), B = F(), R = P ? E : B;
  return /* @__PURE__ */ k(
    "div",
    {
      ref: m,
      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__ */ k(
          "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 = u(A);
                return M && M.length > 1 ? M : A;
              })() }),
              (D || _) && /* @__PURE__ */ o(
                "span",
                {
                  title: _ ? `Excludes last ${$ || "period"}` : `Excludes current incomplete ${$}`,
                  className: "cursor-help",
                  children: /* @__PURE__ */ o(
                    at,
                    {
                      icon: Yt,
                      className: "w-4 h-4 text-dc-text-muted opacity-70"
                    }
                  )
                }
              )
            ]
          }
        ),
        /* @__PURE__ */ k("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: Y(x)
            }
          ),
          /* @__PURE__ */ k("div", { className: "flex items-center space-x-1", children: [
            /* @__PURE__ */ o(
              "div",
              {
                className: "font-bold",
                style: {
                  color: R,
                  fontSize: `${l * 0.35}px`
                },
                children: P ? "▲" : "▼"
              }
            ),
            /* @__PURE__ */ k("div", { className: "text-left", children: [
              /* @__PURE__ */ k(
                "div",
                {
                  className: "font-bold leading-tight",
                  style: {
                    fontSize: `${l * 0.35}px`,
                    color: R
                  },
                  children: [
                    P ? "+" : "",
                    Y(C)
                  ]
                }
              ),
              /* @__PURE__ */ k(
                "div",
                {
                  className: "font-semibold leading-tight",
                  style: {
                    fontSize: `${l * 0.28}px`,
                    color: R,
                    opacity: 0.8
                  },
                  children: [
                    P ? "+" : "",
                    V.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(
          Jl,
          {
            values: y,
            lastValue: x,
            positiveColor: E,
            negativeColor: B,
            formatValue: Y,
            width: c,
            height: 64
          }
        ) })
      ]
    }
  );
}), Xc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: ec
}, Symbol.toStringTag, { value: "Module" })), tc = de.memo(function({
  data: t,
  chartConfig: r,
  displayConfig: n = {},
  height: i = "100%",
  colorPalette: s
}) {
  const [a, l] = Q(28), [d, c] = Q(0), f = ye(null), m = ye(null), h = ve();
  if (Te(() => {
    const x = () => {
      if (f.current) {
        const P = f.current.getBoundingClientRect(), Y = P.width, X = P.height;
        if (Y > 0 && X > 0) {
          const F = Y / 8, E = X / 5, B = Math.min(F, E), R = Math.max(18, Math.min(B, 80));
          l(R);
        }
      }
      if (m.current) {
        const V = m.current.getBoundingClientRect();
        c(V.width);
      }
    }, z = setTimeout(x, 100), C = new ResizeObserver(() => {
      clearTimeout(z), setTimeout(x, 50);
    });
    return f.current && C.observe(f.current), () => {
      clearTimeout(z), C.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__ */ k("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 u = [];
  if (r?.yAxis && (typeof r.yAxis == "string" ? u = [r.yAxis] : Array.isArray(r.yAxis) && (u = r.yAxis)), u.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__ */ k("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 = u[0], w = t.map((x) => {
    if (x[N] !== void 0)
      return x[N];
    const z = Object.keys(x);
    if (z.length > 0)
      return x[z[0]];
  }).filter((x) => x != 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__ */ k("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 A = w.map((x) => Number(x)).filter((x) => !isNaN(x));
  let p, v = null, S = null, g = !1;
  A.length > 0 ? w.length === 1 ? p = w[0] : (p = A.reduce((C, V) => C + V, 0) / A.length, v = Math.min(...A), S = Math.max(...A), g = !0) : p = w.length === 1 ? w[0] : w.join(", ");
  const b = (x) => {
    if (n.formatValue)
      return n.formatValue(x);
    if (x == null)
      return "—";
    const z = n.decimals ?? 2;
    return Math.abs(x) >= 1e9 ? (x / 1e9).toFixed(z) + "B" : Math.abs(x) >= 1e6 ? (x / 1e6).toFixed(z) + "M" : Math.abs(x) >= 1e3 ? (x / 1e3).toFixed(z) + "K" : x.toFixed(z);
  }, D = (x, z) => {
    try {
      const C = {
        value: typeof z == "number" ? b(z) : String(z),
        rawValue: z,
        field: N,
        fieldLabel: h(N),
        min: v !== null ? b(v) : "",
        max: S !== null ? b(S) : "",
        count: w.length
      };
      return x.replace(/\$\{(\w+)\}/g, (V, P) => P in C ? String(C[P]) : V);
    } catch {
      return String(z);
    }
  }, _ = n.template || "${fieldLabel}: ${value}", $ = D(_, p), y = (() => {
    if (n.valueColorIndex !== void 0 && s?.colors) {
      const x = n.valueColorIndex;
      if (x >= 0 && x < s.colors.length)
        return s.colors[x];
    }
    return s?.colors?.[0] || "#1f2937";
  })();
  return /* @__PURE__ */ k(
    "div",
    {
      ref: f,
      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: m,
            className: "font-bold leading-tight text-center",
            style: {
              fontSize: `${a}px`,
              color: y
            },
            children: $
          }
        ),
        g && v !== null && S !== null && /* @__PURE__ */ o("div", { className: "mt-4", children: /* @__PURE__ */ o(
          fn,
          {
            values: w,
            min: v,
            max: S,
            color: y,
            formatValue: b,
            height: 24,
            width: d || 200
          }
        ) })
      ]
    }
  );
}), qc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: tc
}, Symbol.toStringTag, { value: "Module" })), rc = 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", f = {
    small: "text-sm",
    medium: "text-lg",
    large: "text-xl"
  }, m = {
    left: "text-left",
    center: "text-center",
    right: "text-right"
  }, h = (p) => {
    const v = p.split(`
`), S = [];
    let g = null;
    for (let b = 0; b < v.length; b++) {
      const D = v[b].trim();
      if (!D) {
        g && (S.push(g), g = null), S.push({ type: "break" });
        continue;
      }
      const _ = D.match(/^(#{1,3})\s+(.*)$/);
      if (_) {
        g && (S.push(g), g = null), S.push({
          type: "header",
          level: _[1].length,
          content: _[2]
        });
        continue;
      }
      const $ = D.match(/^[-*+]\s+(.*)$/);
      if ($) {
        (!g || g.ordered) && (g && S.push(g), g = { type: "list", ordered: !1, children: [] }), g.children.push({
          type: "listItem",
          children: u($[1]),
          parentOrdered: !1
        });
        continue;
      }
      const T = D.match(/^\d+\.\s+(.*)$/);
      if (T) {
        (!g || !g.ordered) && (g && S.push(g), g = { type: "list", ordered: !0, children: [] }), g.children.push({
          type: "listItem",
          children: u(T[1]),
          parentOrdered: !0
        });
        continue;
      }
      g && (S.push(g), g = null), S.push({
        type: "paragraph",
        children: u(D)
      });
    }
    return g && S.push(g), S;
  }, u = (p) => {
    const v = [];
    let S = p;
    for (; S; ) {
      const g = S.match(/^(.*?)\[([^\]]+)\]\(([^)]+)\)(.*)$/);
      if (g) {
        const [, b, D, _, $] = g;
        b && v.push(...N(b)), v.push({
          type: "link",
          content: D,
          url: _
        }), S = $;
        continue;
      }
      v.push(...N(S));
      break;
    }
    return v;
  }, N = (p) => {
    const v = [];
    let S = p;
    for (; S; ) {
      const g = S.match(/^(.*?)\*\*([^*]+)\*\*(.*)$/);
      if (g) {
        const [, D, _, $] = g;
        D && v.push({ type: "text", content: D }), v.push({ type: "bold", content: _ }), S = $;
        continue;
      }
      const b = S.match(/^(.*?)\*([^*]+)\*(.*)$/);
      if (b) {
        const [, D, _, $] = b;
        D && v.push({ type: "text", content: D }), v.push({ type: "italic", content: _ }), S = $;
        continue;
      }
      v.push({ type: "text", content: S });
      break;
    }
    return v;
  }, w = (p, v, S) => {
    switch (p.type) {
      case "text":
        return /* @__PURE__ */ o("span", { className: "text-dc-text", children: p.content }, v);
      case "bold":
        return /* @__PURE__ */ o("strong", { className: "font-bold text-dc-text", children: p.content }, v);
      case "italic":
        return /* @__PURE__ */ o("em", { className: "italic text-dc-text", children: p.content }, v);
      case "link":
        return /* @__PURE__ */ o(
          "a",
          {
            href: p.url,
            target: "_blank",
            rel: "nofollow noopener noreferrer",
            className: "hover:underline transition-colors",
            style: { color: c },
            children: p.content
          },
          v
        );
      case "header": {
        const g = (D, _) => {
          const $ = "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" }[D] || "text-sm" : _ === "large" ? y = { 1: "text-5xl", 2: "text-4xl", 3: "text-3xl" }[D] || "text-3xl" : y = { 1: "text-3xl", 2: "text-2xl", 3: "text-xl" }[D] || "text-xl", `${$} ${y} ${T[D]}`;
        }, b = `h${p.level}`;
        return /* @__PURE__ */ o(
          b,
          {
            className: g(p.level, a),
            style: { color: c },
            children: p.content
          },
          v
        );
      }
      case "paragraph":
        return /* @__PURE__ */ o("p", { className: "mb-3 leading-relaxed", children: p.children?.map((g, b) => w(g, b)) }, v);
      case "list": {
        const g = p.ordered ? "ol" : "ul";
        let b = "mb-3";
        return l === "center" ? b += " list-none flex flex-col items-center" : l === "right" ? b += " list-none ml-auto max-w-max" : b += " list-none ml-6", /* @__PURE__ */ o(g, { className: b, children: p.children?.map((D, _) => w(D, _, p.ordered ? _ + 1 : void 0)) }, v);
      }
      case "listItem":
        if (p.children) {
          if (p.parentOrdered && S !== void 0) {
            const g = f[a];
            return l === "center" ? /* @__PURE__ */ k("li", { className: "mb-1 flex items-center justify-center", children: [
              /* @__PURE__ */ k(
                "span",
                {
                  className: `inline-block mr-2 shrink-0 ${g} font-medium`,
                  style: { color: c },
                  children: [
                    S,
                    "."
                  ]
                }
              ),
              /* @__PURE__ */ o("span", { className: "text-center", children: p.children.map((b, D) => w(b, D)) })
            ] }, v) : l === "right" ? /* @__PURE__ */ k("li", { className: "mb-1 flex items-start justify-end", children: [
              /* @__PURE__ */ o("span", { className: "text-right", children: p.children.map((b, D) => w(b, D)) }),
              /* @__PURE__ */ k(
                "span",
                {
                  className: `inline-block ml-2 shrink-0 ${g} font-medium`,
                  style: { color: c },
                  children: [
                    S,
                    "."
                  ]
                }
              )
            ] }, v) : /* @__PURE__ */ k("li", { className: "mb-1 flex items-start", children: [
              /* @__PURE__ */ k(
                "span",
                {
                  className: `inline-block mr-3 shrink-0 ${g} font-medium`,
                  style: { color: c },
                  children: [
                    S,
                    "."
                  ]
                }
              ),
              /* @__PURE__ */ o("span", { className: "flex-1", children: p.children.map((b, D) => w(b, D)) })
            ] }, v);
          }
          return l === "center" ? /* @__PURE__ */ k("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: p.children.map((g, b) => w(g, b)) })
          ] }, v) : l === "right" ? /* @__PURE__ */ k("li", { className: "mb-1 flex items-start justify-end", children: [
            /* @__PURE__ */ o("span", { className: "text-right", children: p.children.map((g, b) => w(g, b)) }),
            /* @__PURE__ */ o(
              "span",
              {
                className: "inline-block w-2 h-2 rounded-full ml-2 mt-2 shrink-0",
                style: { backgroundColor: c }
              }
            )
          ] }, v) : /* @__PURE__ */ k("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: p.children.map((g, b) => w(g, b)) })
          ] }, 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__ */ k("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 A = h(i);
  return /* @__PURE__ */ o(
    "div",
    {
      className: `p-4 w-full h-full overflow-auto ${f[a]} ${m[l]}`,
      style: {
        height: r === "100%" ? "100%" : r,
        minHeight: r === "100%" ? "200px" : void 0
      },
      children: A.map((p, v) => w(p, v))
    }
  );
}), Zc = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  default: rc
}, Symbol.toStringTag, { value: "Module" }));
export {
  ss as $,
  Ws as A,
  Us as B,
  lc as C,
  Ir as D,
  qs as E,
  Ul as F,
  Wl as G,
  G as H,
  sr as I,
  je as J,
  Ui as K,
  ir as L,
  Ji as M,
  Ns as N,
  hs as O,
  Gs as P,
  ms as Q,
  Xs as R,
  Ks as S,
  Ec as T,
  fs as U,
  us as V,
  ds as W,
  cs as X,
  ls as Y,
  os as Z,
  as as _,
  Rr as a,
  is as a0,
  ns as a1,
  rs as a2,
  ts as a3,
  es as a4,
  Dc as a5,
  xc as a6,
  yc as a7,
  gc as a8,
  bc as a9,
  vc as aa,
  wc as ab,
  Nc as ac,
  Ac as ad,
  Sc as ae,
  kc as af,
  Tc as ag,
  Fc as ah,
  Mc as ai,
  _c as aj,
  $c as ak,
  Ic as al,
  Vc as am,
  Oc as an,
  Pc as ao,
  Hc as ap,
  Yc as aq,
  jc as ar,
  Uc as as,
  Bc as at,
  Wc as au,
  Gc as av,
  Kc as aw,
  Xc as ax,
  qc as ay,
  Zc as az,
  Wi as b,
  Xi as c,
  ve as d,
  Vi as e,
  ws as f,
  Cc as g,
  zc as h,
  Ye as i,
  vs as j,
  Rc as k,
  bt as l,
  dc as m,
  uc as n,
  fc as o,
  mc as p,
  cc as q,
  Lc as r,
  bs as s,
  hc as t,
  qi as u,
  Zi as v,
  Or as w,
  ue as x,
  pc as y,
  Bs as z
};
//# sourceMappingURL=charts-BvLb1eub.js.map