import { isNonNullable } from '../../../../../../types/type-guard';
/**
 * Abstract class to define strategies for processing HTML elements
 */
export class ElementToDTOStrategy {
}
/**
 * Class to represent the output of a strategy applied to HTML elements
 */
export class ElementToDTOStrategyOutput {
  constructor(currentStrategy, currentElements) {
    this.childrenOutput = [];
    this.currentStrategy = currentStrategy;
    this.currentElements = currentElements;
  }
  /**
   * Set children output.
   *
   * @param {ElementToDTOStrategyOutput[]} childrenOutput - children outputs.
   */
  setChildrenOutput(childrenOutput) {
    this.childrenOutput = childrenOutput;
  }
  /**
   * Transform current output and children output to DTO
   *
   * @param {VegaRTETransformOptions} [options] - Options for transformation.
   * @returns {Nullable<RTEContentBlock>} - DTO.
   */
  toDto(options = { autoMatchFormat: true, skipCustomAnnotations: true }) {
    const currentBlock = this.currentStrategy.handle(this.currentElements, options);
    if (this.childrenOutput.length > 0 && currentBlock) {
      this.currentStrategy.appendChildBlocks(currentBlock, this.childrenOutput
        .map((childOutput) => childOutput.toDto(options))
        .filter(isNonNullable));
    }
    return currentBlock;
  }
}
