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 { KeyboardManagerSlimmer } from '../../../../helpers/slimmers/keyboard-manager-slimmer';
import { MapToComponentField } from 'vega-slimmer/core';
/** The date picker key board controller slimmer */
export class VegaDatePickerKeyboardController extends KeyboardManagerSlimmer {
  /*
   * The below method is e2e-test covered in
   * @see{module:vega-date-picker-open-by-keyboard}
   */
  /* istanbul ignore next */
  /** The function sets up the functionality of key board control */
  constructor() {
    super((target) => [
      {
        keyCode: 'Enter',
        // eslint-disable-next-line jsdoc/require-jsdoc
        activeElementInScope: /* istanbul ignore next */ () => [
          target.vegaDatePickerSingleInputRenderer.getSingleDateInputRef(),
          target.vegaDatePickerRangeInputRenderer.getStartDateInputRef(),
          target.vegaDatePickerRangeInputRenderer.getEndDateInputRef(),
          target.vegaDatePickerCalendarRenderer.getCalendarContentBoxRef(),
        ],
        eventName: 'keydown',
        // eslint-disable-next-line jsdoc/require-jsdoc
        callback: /* istanbul ignore next */ (e) => {
          var _a;
          const activeElement = (((_a = e.target.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) ||
            e.target);
          return activeElement === null || activeElement === void 0 ? void 0 : activeElement.click();
        },
      },
    ]);
  }
}
__decorate([
  MapToComponentField()
], VegaDatePickerKeyboardController.prototype, "vegaDatePickerCalendarRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaDatePickerKeyboardController.prototype, "vegaDatePickerSingleInputRenderer", void 0);
__decorate([
  MapToComponentField()
], VegaDatePickerKeyboardController.prototype, "vegaDatePickerRangeInputRenderer", void 0);
