"use strict";
require("../../../../echarts@5.4.3/node_modules/echarts/lib/echarts.js");
const api = require("../../../../echarts@5.4.3/node_modules/echarts/lib/export/api.js");
const Text = require("../../../../zrender@5.4.4/node_modules/zrender/lib/graphic/Text.js");
const helper = require("../../../../echarts@5.4.3/node_modules/echarts/lib/export/api/helper.js");
const states = require("../../../../echarts@5.4.3/node_modules/echarts/lib/util/states.js");
api.extendChartView({
  type: "wordCloud",
  render: function(seriesModel, ecModel, api2) {
    var group = this.group;
    group.removeAll();
    var data = seriesModel.getData();
    var gridSize = seriesModel.get("gridSize");
    seriesModel.layoutInstance.ondraw = function(text, size, dataIdx, drawn) {
      var itemModel = data.getItemModel(dataIdx);
      var textStyleModel = itemModel.getModel("textStyle");
      var textEl = new Text.default({
        style: helper.createTextStyle(textStyleModel),
        scaleX: 1 / drawn.info.mu,
        scaleY: 1 / drawn.info.mu,
        x: (drawn.gx + drawn.info.gw / 2) * gridSize,
        y: (drawn.gy + drawn.info.gh / 2) * gridSize,
        rotation: drawn.rot
      });
      textEl.setStyle({
        x: drawn.info.fillTextOffsetX,
        y: drawn.info.fillTextOffsetY + size * 0.5,
        text,
        verticalAlign: "middle",
        fill: data.getItemVisual(dataIdx, "style").fill,
        fontSize: size
      });
      group.add(textEl);
      data.setItemGraphicEl(dataIdx, textEl);
      textEl.ensureState("emphasis").style = helper.createTextStyle(
        itemModel.getModel(["emphasis", "textStyle"]),
        {
          state: "emphasis"
        }
      );
      textEl.ensureState("blur").style = helper.createTextStyle(
        itemModel.getModel(["blur", "textStyle"]),
        {
          state: "blur"
        }
      );
      states.enableHoverEmphasis(
        textEl,
        itemModel.get(["emphasis", "focus"]),
        itemModel.get(["emphasis", "blurScope"])
      );
      textEl.stateTransition = {
        duration: seriesModel.get("animation") ? seriesModel.get(["stateAnimation", "duration"]) : 0,
        easing: seriesModel.get(["stateAnimation", "easing"])
      };
      textEl.__highDownDispatcher = true;
    };
    this._model = seriesModel;
  },
  remove: function() {
    this.group.removeAll();
    this._model.layoutInstance.dispose();
  },
  dispose: function() {
    this._model.layoutInstance.dispose();
  }
});
