import { BlockAnnotation, BlockAnnotationTypeEnum } from './block-annotation.abstract';
import { TEXT_STYLE_DEFAULTS } from './text-style-default-styles';
/**
 * Text style annotation
 */
export class TextStyleAnnotation extends BlockAnnotation {
  constructor(textStyle) {
    super();
    this.type = BlockAnnotationTypeEnum.TEXT_STYLE;
    this.textStyle = textStyle;
  }
  /**
   * Generate the map item for the annotations
   *
   * @param {VegaRTETextStyleType} textStyle - the text style type
   * @returns {[BlockAnnotationTypeEnum.TEXT_STYLE, TextStyleAnnotation]} Map item for the annotation
   */
  static from(textStyle) {
    return [BlockAnnotationTypeEnum.TEXT_STYLE, new TextStyleAnnotation(textStyle)];
  }
  /**
   * Get the default styles for a given text style type.
   *
   * @param {VegaRTETextStyleType} textStyle - The text style type.
   * @returns {Nullable<AnnotationStyle>} The default styles for the given text style type.
   */
  static getDefaultStyles(textStyle) {
    if (!textStyle)
      return null;
    return TEXT_STYLE_DEFAULTS[textStyle];
  }
  /**
   * Generate the JSON representation of the annotation
   *
   * @returns {Nullable<Record<string, unknown>>} JSON representation of the annotation
   */
  toJSON() {
    return { textStyle: this.textStyle };
  }
  /**
   * @inheritDoc
   */
  clone() {
    return new TextStyleAnnotation(this.textStyle);
  }
  /**
   * @inheritDoc
   */
  renderClass(options) {
    if (options === null || options === void 0 ? void 0 : options.standalone)
      return null;
    return this.textStyle ? `v-rte--text-style-${this.textStyle}` : null;
  }
  /**
   * @inheritDoc
   */
  renderStyle(options) {
    if (!(options === null || options === void 0 ? void 0 : options.standalone))
      return null;
    return this.textStyle ? TextStyleAnnotation.getDefaultStyles(this.textStyle) : null;
  }
}
