import { g as G, h as D, p as h, l as y, i as H, j as e, k as J, m as Q, n as R, q as M, al as V, A as S, d as _, w as W, y as Y, z as b, v as T, X as Z, B as g, s as tt, u as et, t as st, a as at, c as ot, I as nt, a3 as rt, r as ct, f as I, x as B } from "./index-G5Vdjjso.js";
const ut = {
  Default: (t) => t,
  Thousands: (t) => `${Math.round(t / 1e3)}K`,
  Millions: (t) => `${Math.round(t / 1e6)}M`,
  Datetime: (t) => new Date(t).toLocaleString()
}, pt = (t) => {
  if (t === "Custom")
    return null;
  const [c, a] = t.split(" ");
  return `palette${a}`;
}, C = (t) => {
  const c = ["string", "boolean", "number", "function", "symbol"];
  if (t === null)
    return null;
  if (t !== void 0) {
    if (c.includes(typeof t))
      return t;
    if (Array.isArray(t))
      return t.map((a) => C(a));
    if (typeof t == "object" && t.constructor.name === "Object") {
      const a = {};
      return Object.entries(t).forEach(([p, f]) => {
        a[p] = C(f);
      }), a;
    }
    throw `Unsupported value: "${t}" of type: "${typeof t}"`;
  }
};
var it = I('<div class="component-placeholder svelte-mbw0de"><!> Add rows to your data source to start using your component</div>'), lt = I("<div></div> <!>", 1);
function ft(t, c) {
  G(c, !1);
  const a = () => B(z, "$component", f), p = () => B(q, "$builderStore", f), [f, U] = Y(), s = b(), i = b(), { styleable: v, builderStore: q } = D("sdk"), z = D("component");
  let x = h(c, "options", 8), A = h(c, "hasClickAction", 8, !1), E = h(c, "fullCursor", 8, !1), u = b(), m, w = null;
  const F = async (o) => {
    if (o?.xaxis?.type && o.xaxis.type !== w)
      await k(e(u));
    else {
      const n = o?.chart?.animations?.enabled ?? !0;
      await m?.updateOptions(o, !1, n);
    }
  }, k = async (o) => {
    if (o)
      try {
        await m?.destroy();
        const { default: n } = await import("./apexcharts.common-C95zIOBM.js").then((l) => l.a);
        m = new n(o, e(s)), w = e(s)?.xaxis?.type, await m.render();
      } catch (n) {
        if (n.message !== "Cannot read properties of undefined (reading 'parentNode')")
          throw n;
      }
  };
  y(() => H(x()), () => {
    g(s, C(x()));
  }), y(() => e(s), () => {
    g(i, e(s) == null || e(s)?.series?.length === 0);
  }), y(() => (e(u), e(i)), () => {
    k(e(u), e(i));
  }), y(() => e(s), () => {
    F(e(s));
  }), J(), Q();
  var $ = R(), K = M($);
  V(
    K,
    () => (e(s), S(() => e(s)?.customColor)),
    (o) => {
      var n = lt(), l = M(n);
      let j;
      T(l, (r, d) => v?.(r, d), () => a().styles), Z(l, (r) => g(u, r), () => e(u));
      var L = tt(l, 2);
      {
        var N = (r) => {
          var d = it(), O = ot(d);
          nt(O, {
            name: "warning",
            color: "var(--spectrum-global-color-static-red-600)"
          }), rt(), ct(d), T(d, (P, X) => v?.(P, X), () => ({
            ...a().styles,
            normal: {},
            custom: null,
            empty: !0
          })), _(r, d);
        };
        et(L, (r) => {
          p(), e(i), S(() => p().inBuilder && e(i)) && r(N);
        });
      }
      st((r) => j = at(l, 1, "svelte-mbw0de", null, j, r), [
        () => ({
          hide: e(i),
          hasClickAction: A(),
          hasClickActionFull: A() && E()
        })
      ]), _(o, n);
    }
  ), _(t, $), W(), U();
}
export {
  ft as A,
  ut as f,
  pt as p
};
