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