var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
/**
 * The class is responsible for managing the visibility and behavior of the tooltip content box.
 */
export class VegaVirtualScrollModeController extends VegaSlimmer {
  constructor() {
    super(...arguments);
    this.mode = 'normal';
  }
  /**
   * The componentWillLoad function is used to initialize mode.
   */
  componentWillLoad() {
    this.setMode();
  }
  /**
   * While watchVirtualizationThreshold changed, we should reset the mode.
   */
  watchVirtualizationThreshold() {
    this.setMode();
  }
  /**
   * While source changed, we should reset the mode.
   */
  watchSourceChange() {
    this.setMode();
  }
  /**
   * Get current mode
   *
   * @returns {VirtualScrollMode} - mode
   */
  getMode() {
    return this.mode;
  }
  /**
   * Set the mode of the pager to virtual or normal depending on the length of
   */
  setMode() {
    const originalMode = this.mode;
    this.mode =
      this.source.length > this.virtualizationThreshold && this.virtualizationThreshold > 0
        ? 'virtual'
        : 'normal';
    if (originalMode === 'normal' && this.mode === 'virtual') {
      this.positionController.changeModeFromNormalToVirtual();
    }
  }
}
__decorate([
  MapToComponentField()
], VegaVirtualScrollModeController.prototype, "source", void 0);
__decorate([
  MapToComponentField()
], VegaVirtualScrollModeController.prototype, "virtualizationThreshold", void 0);
__decorate([
  MapToComponentField()
], VegaVirtualScrollModeController.prototype, "positionController", void 0);
__decorate([
  MapToComponentMethod('componentWillLoad')
], VegaVirtualScrollModeController.prototype, "componentWillLoad", null);
__decorate([
  MapToComponentMethod('watchVirtualizationThreshold')
], VegaVirtualScrollModeController.prototype, "watchVirtualizationThreshold", null);
__decorate([
  MapToComponentMethod('watchSourceChange')
], VegaVirtualScrollModeController.prototype, "watchSourceChange", null);
