
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/


/**
 * AUTO-GENERATED FILE. DO NOT MODIFY.
 */

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License.  You may obtain a copy of the License at
*
*   http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied.  See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { __assign, __extends } from "tslib";
import * as graphic from '../../util/graphic.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import ChartView from '../../view/Chart.js';
import { LongColor, ShortColor, ArrowSize, TriangleSize, CloseColor } from './constants.js';
import { createSymbol } from '../../util/symbol.js';
import { each } from 'tvrender/lib/core/util.js';
import SymbolPath from './SymbolPath.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
var StrategyView = /** @class */function (_super) {
  __extends(StrategyView, _super);
  function StrategyView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = StrategyView.type;
    return _this;
  }
  StrategyView.prototype.init = function () {};
  StrategyView.prototype.render = function (seriesModel, ecModel, api) {
    var data = seriesModel.getData();
    this._renderSymbol(data, seriesModel);
    var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
    if (clipPath) {
      this.group.setClipPath(clipPath);
    } else {
      this.group.removeClipPath();
    }
  };
  StrategyView.prototype._getClipShape = function (seriesModel) {
    if (!seriesModel.get('clip', true)) {
      return;
    }
    var coordSys = seriesModel.coordinateSystem;
    // PENDING make `0.1` configurable, for example, `clipTolerance`?
    return coordSys && coordSys.getArea && coordSys.getArea(.1);
  };
  StrategyView.prototype._renderSymbol = function (data, seriesModel) {
    if (!this._symbolGroup) {
      this._symbolGroup = new graphic.Group();
      this.group.add(this._symbolGroup);
    } else {
      this._symbolGroup.removeAll();
    }
    var symbolGroup = this._symbolGroup;
    var z2 = seriesModel.get('z2');
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var groupId = seriesModel.get('groupId');
    var upTriangle = data.getLayout('upTriangle');
    if (upTriangle && upTriangle.length) {
      var upTriangleEl = new SymbolPath({
        shape: {
          points: upTriangle,
          size: TriangleSize
        },
        style: {
          fill: LongColor
        },
        z2: z2
      });
      upTriangleEl.symbolProxy = createSymbol('triangleRight', 0, 0, 0, 0);
      upTriangleEl.states.emphasis = emphasisState;
      symbolGroup.add(upTriangleEl);
    }
    var closeUpTriangle = data.getLayout('closeUpTriangle');
    if (closeUpTriangle && closeUpTriangle.length) {
      var closeUpTriangleEl = new SymbolPath({
        shape: {
          points: closeUpTriangle,
          size: TriangleSize
        },
        style: {
          fill: CloseColor
        },
        z2: z2
      });
      closeUpTriangleEl.symbolProxy = createSymbol('triangleRight', 0, 0, 0, 0);
      closeUpTriangleEl.states.emphasis = emphasisState;
      symbolGroup.add(closeUpTriangleEl);
    }
    var upArrow = data.getLayout('upArrow');
    if (upArrow && upArrow.length) {
      var arrowUpEl = new SymbolPath({
        shape: {
          points: upArrow,
          size: ArrowSize
        },
        style: {
          fill: LongColor
        },
        z2: z2
      });
      arrowUpEl.symbolProxy = createSymbol('arrowUp', 0, 0, 0, 0);
      arrowUpEl.symbolProxy.shape = __assign(__assign({}, arrowUpEl.symbolProxy.shape), {
        triangleWidth: 4,
        triangleHeight: 6
      });
      arrowUpEl.states.emphasis = emphasisState;
      symbolGroup.add(arrowUpEl);
    }
    var closeUpArrow = data.getLayout('closeUpArrow');
    if (closeUpArrow && closeUpArrow.length) {
      var closeUpArrowEl = new SymbolPath({
        shape: {
          points: closeUpArrow,
          size: ArrowSize
        },
        style: {
          fill: CloseColor
        },
        z2: z2
      });
      closeUpArrowEl.symbolProxy = createSymbol('arrowUpClose', 0, 0, 0, 0);
      closeUpArrowEl.symbolProxy.shape = __assign(__assign({}, closeUpArrowEl.symbolProxy.shape), {
        triangleWidth: 4,
        triangleHeight: 6
      });
      closeUpArrowEl.states.emphasis = emphasisState;
      symbolGroup.add(closeUpArrowEl);
    }
    var downTriangle = data.getLayout('downTriangle');
    if (downTriangle && downTriangle.length) {
      var downTriangleEl = new SymbolPath({
        shape: {
          points: downTriangle,
          size: TriangleSize
        },
        style: {
          fill: ShortColor
        },
        z2: z2
      });
      downTriangleEl.symbolProxy = createSymbol('triangleLeft', 0, 0, 0, 0);
      downTriangleEl.states.emphasis = emphasisState;
      symbolGroup.add(downTriangleEl);
    }
    var closeDownTriangle = data.getLayout('closeDownTriangle');
    if (closeDownTriangle && closeDownTriangle.length) {
      var closeDownTriangleEl = new SymbolPath({
        shape: {
          points: closeDownTriangle,
          size: TriangleSize
        },
        style: {
          fill: CloseColor
        },
        z2: z2
      });
      closeDownTriangleEl.symbolProxy = createSymbol('triangleLeft', 0, 0, 0, 0);
      closeDownTriangleEl.states.emphasis = emphasisState;
      symbolGroup.add(closeDownTriangleEl);
    }
    var downArrow = data.getLayout('downArrow');
    if (downArrow && downArrow.length) {
      var arrowDownEl = new SymbolPath({
        shape: {
          points: downArrow,
          size: ArrowSize
        },
        style: {
          fill: ShortColor
        },
        z2: z2
      });
      arrowDownEl.symbolProxy = createSymbol('arrowDown', 0, 0, 0, 0);
      arrowDownEl.symbolProxy.shape = __assign(__assign({}, arrowDownEl.symbolProxy.shape), {
        triangleWidth: 4,
        triangleHeight: 6
      });
      arrowDownEl.states.emphasis = emphasisState;
      symbolGroup.add(arrowDownEl);
    }
    var closeDownArrow = data.getLayout('closeDownArrow');
    if (closeDownArrow && closeDownArrow.length) {
      var closeDownArrowEl = new SymbolPath({
        shape: {
          points: closeDownArrow,
          size: ArrowSize
        },
        style: {
          fill: CloseColor
        },
        z2: z2
      });
      closeDownArrowEl.symbolProxy = createSymbol('arrowDownClose', 0, 0, 0, 0);
      closeDownArrowEl.symbolProxy.shape = __assign(__assign({}, closeDownArrowEl.symbolProxy.shape), {
        triangleWidth: 4,
        triangleHeight: 6
      });
      closeDownArrowEl.states.emphasis = emphasisState;
      symbolGroup.add(closeDownArrowEl);
    }
    var texts = data.getLayout('texts');
    if (texts && texts.length) {
      var textColor_1 = seriesModel.get('textColor');
      var textBorder_1 = seriesModel.get('textBorder');
      var textBorderWidth_1 = seriesModel.get('textBorderWidth');
      each(texts, function (item) {
        var text = item.text,
          point = item.point;
        var el = new graphic.Text({
          style: {
            text: text,
            align: 'center',
            fill: textColor_1 !== null && textColor_1 !== void 0 ? textColor_1 : '#fff',
            fontSize: 12,
            stroke: textBorder_1,
            lineWidth: textBorderWidth_1,
            x: point[0],
            y: point[1]
          }
        });
        el.states.emphasis = emphasisState;
        symbolGroup.add(el);
      });
    }
    toggleHoverEmphasis(this.group, null, null, false);
    getECData(this.group).groupId = groupId;
  };
  StrategyView.prototype.remove = function (ecModel, api) {
    this._symbolGroup && this._symbolGroup.removeAll();
    this._symbolGroup = null;
  };
  StrategyView.prototype.dispose = function (ecModel, api) {
    this.remove(ecModel, api);
    // this._lineGroup.removeAll();
  };

  StrategyView.type = 'strategy';
  return StrategyView;
}(ChartView);
export default StrategyView;