import { defineComponent as v, createElementBlock as E, openBlock as _, createElementVNode as k, unref as x } from "vue";
import { cloneDeep as c } from "lodash";
import { useCommonChart as C } from "./hooks/useCommonChart.mjs";
import { SHJDatasourceV2 as D } from "../../../../../commons/plugins/datasource/index.mjs";
import { useChart as L } from "../../hooks/useChart.mjs";
import { SHJParseEvent as d } from "../../../../../commons/plugins/event/index.mjs";
const w = { class: "zerov-widget" }, b = ["id"], J = /* @__PURE__ */ v({
  __name: "index",
  props: {
    option: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: ["dataListener", "chart-click", "chart-dblclick", "chart-mousedown", "chart-mouseover", "chart-mouseout", "chart-contextmenu"],
  setup(u, { expose: m, emit: p }) {
    const e = u, s = p, {
      id: h,
      setOption: i,
      chart: l,
      renderChart: a,
      renderData: o
    } = L({
      basicOption: c(e.option),
      useEvents: c(e.useEvents),
      customRenderData: (t) => {
        t = c(t), D.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: (r) => {
            try {
              s("dataListener", r.data), d.parseEvents(e.useEvents, "dataListener", r.data);
              const n = t.series.find((f) => f._sourceId === r.id);
              n && (n.data = r.data[0].data), i(t);
            } catch {
              s("dataListener", null), d.parseEvents(e.useEvents, "dataListener", null), i(t);
            }
          }
        });
      },
      emits: s
    });
    return C(e, o, a), m({
      getEchartsInstance: () => l.value,
      refresh: () => {
        o(e.option), a(e.option);
      },
      refreshView: () => {
        a(e.option);
      },
      refreshData: () => {
        o(e.option);
      }
    }), (t, r) => (_(), E("div", w, [
      k("div", {
        id: x(h),
        class: "widget"
      }, null, 8, b)
    ]));
  }
});
export {
  J as default
};
