import { CommonAnnotation, CommonAnnotationTypeEnum } from './common-annotation.abstract';
/**
 * Annotation to add custom class of element
 */
export class CustomClassAnnotation extends CommonAnnotation {
  constructor(customClass) {
    super();
    this.type = CommonAnnotationTypeEnum.CUSTOM_CLASS;
    this.customClass = customClass;
  }
  /**
   * Generate the map item for the annotation
   *
   * @param {string[]} customClass - custom class annotation
   * @returns {[CommonAnnotationTypeEnum.CUSTOM_CLASS, CustomClassAnnotation]} Map item for the annotation
   */
  static from(customClass) {
    return [CommonAnnotationTypeEnum.CUSTOM_CLASS, new CustomClassAnnotation(customClass)];
  }
  /**
   * Generate the JSON representation of the annotation
   *
   * @returns {Record<string, unknown>} JSON representation of the annotation
   */
  toJSON() {
    return {
      customClass: this.customClass,
    };
  }
  /**
   * Create a new custom class annotation
   *
   * @returns {CustomClassAnnotation} - Custom class annotation
   */
  clone() {
    return new CustomClassAnnotation(this.customClass);
  }
  /**
   * Generate the custom class of current element
   *
   * @returns {string} - Custom class
   */
  toString() {
    return `class="${this.customClass.join(' ')}"`;
  }
  /**
   * Generate the custom attribute for the annotation
   *
   * @returns {string[]} custom classes
   */
  renderClass() {
    return this.customClass;
  }
}
