
/*
* 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 { __extends } from "tslib";
import * as graphic from '../../util/graphic.js';
import { createClipPath } from '../helper/createClipPathFromCoordSys.js';
import ChartView from '../../view/Chart.js';
import { each } from 'tvrender/lib/core/util.js';
import PolyLinesPath from './PolyLinesPath.js';
import { getECData } from '../../util/innerStore.js';
import { toggleHoverEmphasis } from '../../util/states.js';
function getLineDashByLineStyle(lineStyle) {
  if (lineStyle === 'style_dashed') {
    return [8, 8];
  } else if (lineStyle === 'style_dotted') {
    return [4, 4];
  }
  return 'solid';
}
var MinePolyLinesView = /** @class */function (_super) {
  __extends(MinePolyLinesView, _super);
  function MinePolyLinesView() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = MinePolyLinesView.type;
    return _this;
  }
  MinePolyLinesView.prototype.init = function () {};
  MinePolyLinesView.prototype.render = function (seriesModel, ecModel, api) {
    var data = seriesModel.getData();
    this._renderLines(data, seriesModel, api);
    var clipPath = seriesModel.get('clip', true) && createClipPath(seriesModel.coordinateSystem, false, seriesModel);
    if (clipPath) {
      this.group.setClipPath(clipPath);
    } else {
      this.group.removeClipPath();
    }
    toggleHoverEmphasis(this.group, null, null, false);
    var groupId = seriesModel.get('groupId');
    getECData(this.group).groupId = groupId;
  };
  MinePolyLinesView.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);
  };
  MinePolyLinesView.prototype._renderLines = function (data, seriesModel, api) {
    if (!this._linesGroup) {
      this._linesGroup = new graphic.Group();
      this.group.add(this._linesGroup);
    } else {
      this._linesGroup.removeAll();
    }
    var emphasisState = seriesModel.get('emphasis').emphasisState;
    var linesGroup = this._linesGroup;
    var z2 = seriesModel.get('z2');
    var linesPointLayouts = data.getLayout('linesPointLayouts');
    each(linesPointLayouts, function (item) {
      var key = item.key,
        points = item.points;
      var _a = key.split(':'),
        color = _a[0],
        width = _a[1],
        lineStyle = _a[2],
        fill = _a[3],
        closed = _a[4],
        curved = _a[5];
      var isCurved = curved === 'true';
      var isClosed = closed === 'true';
      var el = new PolyLinesPath({
        shape: {
          points: points,
          closed: isClosed,
          curved: isCurved,
          lineStyle: lineStyle
        },
        style: {
          fill: fill,
          stroke: color,
          lineWidth: +width,
          lineDash: getLineDashByLineStyle(lineStyle)
        },
        z2: z2
      });
      el.states.emphasis = emphasisState;
      linesGroup.add(el);
    });
  };
  MinePolyLinesView.prototype.remove = function (ecModel, api) {
    this._linesGroup && this._linesGroup.removeAll();
    this._linesGroup = null;
  };
  MinePolyLinesView.prototype.dispose = function (ecModel, api) {
    this.remove(ecModel, api);
    // this._lineGroup.removeAll();
  };

  MinePolyLinesView.type = 'minePolyLines';
  return MinePolyLinesView;
}(ChartView);
export default MinePolyLinesView;