import { __extends } from '../../../../../../tslib@2.3.0/node_modules/tslib/tslib.es6.mjs';
import ComponentView from '../../view/Component.mjs';
import { createHashMap, each } from '../../../../../../zrender@6.0.0/node_modules/zrender/lib/core/util.mjs';
import MarkerModel from './MarkerModel.mjs';
import { makeInner } from '../../util/model.mjs';
import { enterBlur, leaveBlur } from '../../util/states.mjs';
import { retrieveZInfo, traverseUpdateZ } from '../../util/graphic.mjs';

var inner = makeInner();
var MarkerView = /** @class */function (_super) {
  __extends(MarkerView, _super);
  function MarkerView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = MarkerView.type;
    return _this;
  }
  MarkerView.prototype.init = function () {
    this.markerGroupMap = createHashMap();
  };
  MarkerView.prototype.render = function (markerModel, ecModel, api) {
    var _this = this;
    var markerGroupMap = this.markerGroupMap;
    markerGroupMap.each(function (item) {
      inner(item).keep = false;
    });
    ecModel.eachSeries(function (seriesModel) {
      var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, _this.type);
      markerModel && _this.renderSeries(seriesModel, markerModel, ecModel, api);
    });
    markerGroupMap.each(function (item) {
      !inner(item).keep && _this.group.remove(item.group);
    });
    updateZ(ecModel, markerGroupMap, this.type);
  };
  MarkerView.prototype.markKeep = function (drawGroup) {
    inner(drawGroup).keep = true;
  };
  MarkerView.prototype.toggleBlurSeries = function (seriesModelList, isBlur) {
    var _this = this;
    each(seriesModelList, function (seriesModel) {
      var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, _this.type);
      if (markerModel) {
        var data = markerModel.getData();
        data.eachItemGraphicEl(function (el) {
          if (el) {
            isBlur ? enterBlur(el) : leaveBlur(el);
          }
        });
      }
    });
  };
  MarkerView.type = 'marker';
  return MarkerView;
}(ComponentView);
function updateZ(ecModel, markerGroupMap, type) {
  ecModel.eachSeries(function (seriesModel) {
    var markerModel = MarkerModel.getMarkerModelFromSeries(seriesModel, type);
    var markerDraw = markerGroupMap.get(seriesModel.id);
    if (markerModel && markerDraw && markerDraw.group) {
      var _a = retrieveZInfo(markerModel),
        z = _a.z,
        zlevel = _a.zlevel;
      traverseUpdateZ(markerDraw.group, z, zlevel);
    }
  });
}

export { MarkerView as default };
