import { defineComponent as i, watch as n, createElementBlock as f, openBlock as v, createElementVNode as _, unref as b } from "vue";
import { cloneDeep as r, isEqual as E } from "lodash";
import O from "./default-option.json.mjs";
import { SHJDatasourceV2 as w } from "../../commons/core/datasource/index.mjs";
import { useChart as g } from "../../commons/core/useChart.mjs";
const k = { class: "zerov-widget" }, D = ["id"], x = i({ name: "zv-chart-other-candlestick-demo" }), B = /* @__PURE__ */ i({
  ...x,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: [
    "chart-click",
    "chart-dblclick",
    "chart-mousedown",
    "chart-mouseover",
    "chart-mouseout",
    "chart-contextmenu"
  ],
  setup(u, { expose: d, emit: p }) {
    const e = u, l = p, {
      id: m,
      setOption: a,
      chart: h,
      renderChart: o,
      renderData: c
    } = g({
      basicOption: r(e.basicOption),
      useEvents: r(e.useEvents),
      customRenderData: (t) => {
        t = r(t), w.parse({
          tId: e.uuid,
          sources: e.sources,
          callback: ({ data: s }) => {
            try {
              window.SHJParseEvent(e.useEvents, "dataListener", s), a(O);
            } catch {
              window.SHJParseEvent(e.useEvents, "dataListener", null), a(t);
            }
          }
        });
      },
      emit: l
    });
    return n(() => e.sources, () => {
      e.sources && e.sources.length > 0 && c(e.basicOption);
    }, {
      deep: !0
    }), n(() => r(e.basicOption), (t, s) => {
      E(t, s) || o(t);
    }, {
      deep: !0
    }), d({
      getEchartsInstance: () => h.value,
      refresh: () => {
        e.sources && e.sources.length > 0 && o(e.basicOption), c(e.basicOption);
      },
      refreshView: () => {
        e.sources && e.sources.length > 0 && o(e.basicOption);
      },
      refreshData: () => {
        c(e.basicOption);
      }
    }), (t, s) => (v(), f("div", k, [
      _("div", {
        id: b(m),
        class: "widget"
      }, null, 8, D)
    ]));
  }
});
export {
  B as default
};
