import { NodeAnnotation, NodeAnnotationTypeEnum } from './node-annotation.abstract';
import { CODE_FONT_FAMILY, CODE_WHITE_SPACE } from './text-format-default-styles';
/**
 * Annotation to make text code
 */
export class CodeAnnotation extends NodeAnnotation {
  constructor(code, useInternalStyle = true) {
    super();
    this.type = NodeAnnotationTypeEnum.CODE;
    this.code = code;
    this.useInternalStyle = useInternalStyle;
  }
  /**
   * Generate the map item for the annotation
   *
   * @param {boolean} code - Bold annotation
   * @param {boolean} useInternalStyle - Whether to use default style for the link
   * @returns {[NodeAnnotationTypeEnum.CODE, CodeAnnotation]} Map item for the annotation
   */
  static from(code, useInternalStyle) {
    return [NodeAnnotationTypeEnum.CODE, new CodeAnnotation(code, useInternalStyle)];
  }
  /**
   * Get the default standalone styles for an inline code annotation.
   *
   * @returns {AnnotationStyle} The default styles.
   */
  static getDefaultStyles() {
    return {
      fontFamily: CODE_FONT_FAMILY,
      whiteSpace: CODE_WHITE_SPACE,
    };
  }
  /**
   * Generate the JSON representation of the annotation
   *
   * @returns {Record<string, unknown>} JSON representation of the annotation
   */
  toJSON() {
    return {
      code: this.code,
    };
  }
  /**
   * @inheritDoc
   */
  clone() {
    return new CodeAnnotation(this.code, this.useInternalStyle);
  }
  /**
   * @inheritDoc
   */
  renderClass(options) {
    if (options === null || options === void 0 ? void 0 : options.standalone)
      return null;
    return this.code && this.useInternalStyle ? 'v-rte--code' : null;
  }
  /**
   * @inheritDoc
   */
  renderStyle(options) {
    if (!(options === null || options === void 0 ? void 0 : options.standalone))
      return null;
    return this.code && this.useInternalStyle ? CodeAnnotation.getDefaultStyles() : null;
  }
}
