import { BlockAnnotation, BlockAnnotationTypeEnum } from './block-annotation.abstract';
/**
 * Annotation for block indentation
 */
export class IndentAnnotation extends BlockAnnotation {
  constructor(indent) {
    super();
    this.type = BlockAnnotationTypeEnum.INDENT;
    this.indent = Math.max(0, indent);
  }
  /**
   * Generate the map item for the annotation
   *
   * @param {number} indent - Text alignment
   * @returns {[BlockAnnotationTypeEnum.INDENT, IndentAnnotation]} Map item for the annotation
   */
  static from(indent) {
    return [BlockAnnotationTypeEnum.INDENT, new IndentAnnotation(indent)];
  }
  /**
   * Generate the JSON item of the annotation
   *
   * @returns {Nullable<Record<string, unknown>>} JSON representation of the annotation
   */
  toJSON() {
    return this.indent > 0 ? { indent: this.indent } : null;
  }
  /**
   * @inheritDoc
   */
  clone() {
    return new IndentAnnotation(this.indent);
  }
  /**
   * @inheritDoc
   */
  renderClass() {
    return null;
  }
  /**
   * Generate the style for the annotation
   *
   * @returns {Nullable<AnnotationStyle>} - Annotation style
   */
  renderStyle() {
    return this.indent > 0 ? { marginLeft: `${this.indent * 16}px` } : null;
  }
}
