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, VegaSlimmer } from 'vega-slimmer/core';
/**
 * Handles the color related properties for the table properties component.`
 */
export class TableColorController extends VegaSlimmer {
  /**
   * Returns an array of light color values from the color schema.
   *
   * @returns {string[]} An array of light color strings.
   */
  getColors() {
    let result = [];
    if (this.colors) {
      result = this.colors.map((colorSchema) => this.isInDarkMode ? colorSchema.dark : colorSchema.light);
    }
    return result;
  }
  /**
   * Returns the color key corresponding to the provided color value.
   *
   * @param {string} color - The color value to find the key for.
   * @returns {string} The key of the color schema that matches the provided color value.
   */
  getColorKey(color) {
    let result = '';
    if (this.colors) {
      const colorSchema = this.colors.find((item) => this.isInDarkMode ? item.dark === color : item.light === color);
      result = colorSchema ? colorSchema.key : '';
    }
    return result;
  }
  /**
   * Returns the color value corresponding to the provided color key.
   *
   * @param {string} colorKey - The color key to find the value for.
   * @returns {string} The value of the color schema that matches the provided color key.
   */
  getColorByKey(colorKey) {
    let result = '';
    if (this.colors) {
      const colorSchema = this.colors.find((item) => item.key === colorKey);
      result = colorSchema ? (this.isInDarkMode ? colorSchema.dark : colorSchema.light) : '';
    }
    return result;
  }
}
__decorate([
  MapToComponentField()
], TableColorController.prototype, "colors", void 0);
__decorate([
  MapToComponentField({ writable: true })
], TableColorController.prototype, "isInDarkMode", void 0);
