import { generateUUID } from '../../../../../utils/misc';
import { RTETextBlock } from '../../../dto/blocks/text-block';
import htmlElementToAnnotationGenerator from '../../../slimmers/controllers/helper/element-to-dto-strategy/annotation-handler/html-element-to-annotation-generator';
import { DivToLogicControlBlockStrategy } from './div-to-logic-control-block-strategy';
/**
 * Strategy to convert a div with class 'statementelement' into an function block.
 */
export class DivToFunctionContentStrategy extends DivToLogicControlBlockStrategy {
  constructor() {
    super(...arguments);
    this.blockClassName = 'statementelement';
  }
  /**
   * @inheritDoc
   */
  handle(elementsArray, options) {
    const element = elementsArray[0];
    const annotations = htmlElementToAnnotationGenerator.generate(RTETextBlock, element);
    const nodes = Array.from(elementsArray[0].childNodes);
    return RTETextBlock.from({
      id: generateUUID(),
      type: 'paragraph',
      annotations: Object.assign({ customClass: [this.blockClassName] }, annotations),
      nodes: this.generateChildNodes(nodes, undefined, options),
    });
  }
}
