"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 BrushController = require("../helper/BrushController.js");
const visualEncoding = require("./visualEncoding.js");
const Component = require("../../view/Component.js");
var BrushView = (
  /** @class */
  function(_super) {
    tslib_es6.__extends(BrushView2, _super);
    function BrushView2() {
      var _this = _super !== null && _super.apply(this, arguments) || this;
      _this.type = BrushView2.type;
      return _this;
    }
    BrushView2.prototype.init = function(ecModel, api) {
      this.ecModel = ecModel;
      this.api = api;
      this.model;
      (this._brushController = new BrushController.default(api.getZr())).on("brush", util.bind(this._onBrush, this)).mount();
    };
    BrushView2.prototype.render = function(brushModel, ecModel, api, payload) {
      this.model = brushModel;
      this._updateController(brushModel, ecModel, api, payload);
    };
    BrushView2.prototype.updateTransform = function(brushModel, ecModel, api, payload) {
      visualEncoding.layoutCovers(ecModel);
      this._updateController(brushModel, ecModel, api, payload);
    };
    BrushView2.prototype.updateVisual = function(brushModel, ecModel, api, payload) {
      this.updateTransform(brushModel, ecModel, api, payload);
    };
    BrushView2.prototype.updateView = function(brushModel, ecModel, api, payload) {
      this._updateController(brushModel, ecModel, api, payload);
    };
    BrushView2.prototype._updateController = function(brushModel, ecModel, api, payload) {
      (!payload || payload.$from !== brushModel.id) && this._brushController.setPanels(brushModel.brushTargetManager.makePanelOpts(api)).enableBrush(brushModel.brushOption).updateCovers(brushModel.areas.slice());
    };
    BrushView2.prototype.dispose = function() {
      this._brushController.dispose();
    };
    BrushView2.prototype._onBrush = function(eventParam) {
      var modelId = this.model.id;
      var areas = this.model.brushTargetManager.setOutputRanges(eventParam.areas, this.ecModel);
      (!eventParam.isEnd || eventParam.removeOnClick) && this.api.dispatchAction({
        type: "brush",
        brushId: modelId,
        areas: util.clone(areas),
        $from: modelId
      });
      eventParam.isEnd && this.api.dispatchAction({
        type: "brushEnd",
        brushId: modelId,
        areas: util.clone(areas),
        $from: modelId
      });
    };
    BrushView2.type = "brush";
    return BrushView2;
  }(Component.default)
);
const BrushView$1 = BrushView;
exports.default = BrushView$1;
