"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const tslib_es6 = require("../../../node_modules/tslib/tslib.es6.js");
const util = require("../../../../../../zrender@5.4.4/node_modules/zrender/lib/core/util.js");
const visualSolution = require("../../visual/visualSolution.js");
const Model = require("../../model/Model.js");
const Component = require("../../model/Component.js");
var DEFAULT_OUT_OF_BRUSH_COLOR = "#ddd";
var BrushModel = (
  /** @class */
  function(_super) {
    tslib_es6.__extends(BrushModel2, _super);
    function BrushModel2() {
      var _this = _super !== null && _super.apply(this, arguments) || this;
      _this.type = BrushModel2.type;
      _this.areas = [];
      _this.brushOption = {};
      return _this;
    }
    BrushModel2.prototype.optionUpdated = function(newOption, isInit) {
      var thisOption = this.option;
      !isInit && visualSolution.replaceVisualOption(thisOption, newOption, ["inBrush", "outOfBrush"]);
      var inBrush = thisOption.inBrush = thisOption.inBrush || {};
      thisOption.outOfBrush = thisOption.outOfBrush || {
        color: DEFAULT_OUT_OF_BRUSH_COLOR
      };
      if (!inBrush.hasOwnProperty("liftZ")) {
        inBrush.liftZ = 5;
      }
    };
    BrushModel2.prototype.setAreas = function(areas) {
      if (process.env.NODE_ENV !== "production") {
        util.assert(util.isArray(areas));
        util.each(areas, function(area) {
          util.assert(area.brushType, "Illegal areas");
        });
      }
      if (!areas) {
        return;
      }
      this.areas = util.map(areas, function(area) {
        return generateBrushOption(this.option, area);
      }, this);
    };
    BrushModel2.prototype.setBrushOption = function(brushOption) {
      this.brushOption = generateBrushOption(this.option, brushOption);
      this.brushType = this.brushOption.brushType;
    };
    BrushModel2.type = "brush";
    BrushModel2.dependencies = ["geo", "grid", "xAxis", "yAxis", "parallel", "series"];
    BrushModel2.defaultOption = {
      seriesIndex: "all",
      brushType: "rect",
      brushMode: "single",
      transformable: true,
      brushStyle: {
        borderWidth: 1,
        color: "rgba(210,219,238,0.3)",
        borderColor: "#D2DBEE"
      },
      throttleType: "fixRate",
      throttleDelay: 0,
      removeOnClick: true,
      z: 1e4
    };
    return BrushModel2;
  }(Component.default)
);
function generateBrushOption(option, brushOption) {
  return util.merge({
    brushType: option.brushType,
    brushMode: option.brushMode,
    transformable: option.transformable,
    brushStyle: new Model.default(option.brushStyle).getItemStyle(),
    removeOnClick: option.removeOnClick,
    z: option.z
  }, brushOption, true);
}
const BrushModel$1 = BrushModel;
exports.default = BrushModel$1;
