import { defineComponent as a, ref as m, watch as p, nextTick as f, onBeforeUnmount as l, createElementBlock as c, openBlock as u } from "vue";
import * as n from "echarts/core";
import { TitleComponent as d, TooltipComponent as s, LegendComponent as h } from "echarts/components";
import { PieChart as C } from "echarts/charts";
import { LabelLayout as _ } from "echarts/features";
import { CanvasRenderer as y } from "echarts/renderers";
import { defaultOption as k } from "./model/options.js";
const B = {
  name: "CiEchartPie"
}, O = /* @__PURE__ */ a({
  ...B,
  props: {
    option: { default: () => k },
    immediate: { type: Boolean, default: !1 }
  },
  setup(r) {
    n.use([
      d,
      s,
      h,
      C,
      y,
      _
    ]);
    const o = m(null);
    let e = null;
    const t = r;
    function i() {
      e ? e.clear() : e = n.init(o.value), e.setOption(t.option);
    }
    return p(
      () => t.option,
      () => {
        f(() => {
          typeof window > "u" || i();
        });
      },
      { deep: !0, immediate: t.immediate }
    ), l(() => {
      e && e.dispose();
    }), (v, w) => (u(), c("div", {
      id: "CiEchartPie",
      ref_key: "chartRef",
      ref: o
    }, null, 512));
  }
});
export {
  O as default
};
