
/*
* 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";
/* global Uint32Array, Float64Array, Float32Array */
import SeriesModel from '../../model/Series.js';
import createSeriesData from '../helper/createSeriesData.js';
import * as zrUtil from 'tvrender/lib/core/util.js';
var BoxesSeriesModel = /** @class */function (_super) {
  __extends(BoxesSeriesModel, _super);
  function BoxesSeriesModel() {
    var _this = _super !== null && _super.apply(this, arguments) || this;
    _this.type = BoxesSeriesModel.type;
    _this.xFilterMode = 'weakFilter';
    _this.ignoreStyleOnData = true;
    return _this;
  }
  // dataIndexById: Record<string, number> = {};
  BoxesSeriesModel.prototype.getInitialData = function (option) {
    if (process.env.NODE_ENV !== 'production') {
      var coordSys = option.coordinateSystem;
      if (coordSys !== 'polar' && coordSys !== 'cartesian2d') {
        throw new Error('Boxes not support coordinateSystem besides cartesian and polar');
      }
    }
    // this.computedDataIndexById(option);
    return createSeriesData(null, this, {
      useEncodeDefaulter: true
    });
  };
  BoxesSeriesModel.prototype.getZLevelKey = function () {
    // Each progressive series has individual key.
    return this.getData().count() > this.getProgressiveThreshold() ? this.id : '';
  };
  // computedDataIndexById(option: BoxesSeriesOption) {
  //     const dataIndexById: Record<string, number> = {};
  //     zrUtil.each(option.data, function (item: BoxesDataItemOption, index) {
  //         dataIndexById[item.id] = index;
  //     });
  //     this.dataIndexById = dataIndexById;
  // }
  BoxesSeriesModel.prototype.getResetData = function (data) {
    // const dataIndexById = this.dataIndexById;
    // const that = this;
    var mergeIdById = {};
    var mergeData = zrUtil.filter(data, function (item) {
      mergeIdById[item.id] = 1;
      return !item.isDelete;
    });
    var newData = zrUtil.filter(this.option.data, function (item) {
      if (mergeIdById[item.id]) {
        return false;
      }
      return true;
    });
    this.option.data = newData.concat(mergeData).slice(-this.option.limit);
    // this.computedDataIndexById(this.option);
    return this.option.data;
  };
  BoxesSeriesModel.type = 'series.boxes';
  BoxesSeriesModel.dependencies = ['grid', 'polar'];
  BoxesSeriesModel.defaultOption = {
    coordinateSystem: 'cartesian2d',
    // zlevel: 0,
    z: 2,
    z2: 0,
    legendHoverLink: true,
    // Cartesian coordinate system
    xAxisIndex: 0,
    yAxisIndex: 0,
    dimensions: ['extend', 'left', 'right', 'top', 'bottom'],
    encode: {
      x: ['extend', 'left', 'right'],
      y: ['top', 'bottom']
    },
    baseDim: 'top',
    emphasis: {
      emphasisState: {
        // hoverLayer: true,
        zlevel: 1
      }
    },
    large: true,
    // Available when large is true
    largeThreshold: 600,
    clip: true,
    limit: 50
  };
  return BoxesSeriesModel;
}(SeriesModel);
export default BoxesSeriesModel;