
/*
* 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 { __spreadArray } from "tslib";
/* global Float32Array */
import createRenderPlanner from '../helper/createRenderPlanner.js';
import { error } from '../../util/log.js';
import { map } from 'tvrender/lib/core/util.js';
function optimizePoint(point1, point2, lineWidth) {
  var notOptimize = lineWidth % 2 === 0;
  if (notOptimize) {
    return;
  }
  if (point1[0] === point2[0]) {
    point2[0] = point1[0] = Math.floor(point1[0]) + 0.5;
  }
  if (point1[1] === point2[1]) {
    point2[1] = point1[1] = Math.floor(point1[1]) + 0.5;
  }
}
var MineLinesLayout = {
  seriesType: 'mineLines',
  plan: createRenderPlanner(),
  reset: function (seriesModel) {
    var coordSys = seriesModel.coordinateSystem;
    if (!coordSys) {
      if (process.env.NODE_ENV !== 'production') {
        error('The lines series must have a coordinate system.');
      }
      return;
    }
    var data = seriesModel.getData();
    var cDimIdx = 0;
    var vDimIdx = 1;
    var coordDims = ['x', 'y'];
    var cDimsI = map(data.mapDimensionsAll(coordDims[cDimIdx]), data.getDimensionIndex, data);
    var vDimsI = map(data.mapDimensionsAll(coordDims[vDimIdx]), data.getDimensionIndex, data);
    var x1DimI = cDimsI[1];
    var x2DimI = cDimsI[2];
    var y1DimI = vDimsI[0];
    var y2DimI = vDimsI[1];
    if (cDimsI.length < 2 || vDimsI.length < 2) {
      return;
    }
    return {
      progress: function (params, mineLinesData) {
        var store = mineLinesData.getStore();
        var linesPointById = {};
        for (var i = params.start; i < params.end; i++) {
          var x1Val = store.get(x1DimI, i);
          var x2Val = store.get(x2DimI, i);
          var y1Val = store.get(y1DimI, i);
          var y2Val = store.get(y2DimI, i);
          var startPoint = coordSys.dataToPoint([x1Val, y1Val]);
          var endPoint = coordSys.dataToPoint([x2Val, y2Val]);
          var itemModel = data.getItemModel(i);
          var _a = itemModel.get('itemStyle'),
            width = _a.width,
            color = _a.color,
            lineStyle = _a.lineStyle,
            extend = _a.extend;
          if (!color) {
            continue;
          }
          var key = color + ":" + width + ":" + lineStyle + ":" + extend;
          var points = linesPointById[key] || [];
          optimizePoint(startPoint, endPoint, width);
          points.push.apply(points, __spreadArray(__spreadArray([], startPoint, false), endPoint, false));
          linesPointById[key] = points;
        }
        data.setLayout({
          linesPointById: linesPointById
        });
      }
    };
  }
};
export default MineLinesLayout;