import { RTETextBlock } from './blocks/text-block';
import { RTEImageBlock } from './blocks/image-block';
import { RTEListBlock } from './blocks/list-block';
import { RTEListItemBlock } from './blocks/list-item-block';
import { RTEHtmlBlock } from './blocks/html-block';
import { RTECodeBlock } from './blocks/code-block';
import { RTETextNode } from './nodes/text-node';
import { RTEImageNode } from './nodes/image-node';
import RTEDTOClassManager from '../../../helpers/rte-manager/dto-class-manager';
import RTEDTOActionStrategyManager from '../../../helpers/rte-manager/dto-action-strategy-manager';
import ElementToDTOClassStrategyManager from '../../../helpers/rte-manager/element-dto-class-strategy-manager';
import { HtmlBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/html-block-strategy';
import { UlToRTEListBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/ul-to-rte-list-block-strategy';
import { OlToRTEListBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/ol-to-rte-list-block-strategy';
import { ULNotLiChildToRTEListItemBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/ul-not-li-child-to-rte-list-item-block';
import { LiToRTEListItemBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/li-to-rte-list-item-block-strategy';
import { VegaCodeBlockToRTECodeBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/vega-code-block-to-rte-code-block-strategy';
import { JiraCodeToRTECodeBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/jira-code-to-rte-code-block-strategy';
import { InlineBlockToRTETextBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/inline-block-to-rte-text-block-strategy';
import { ImgToRTEImageBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/img-to-rte-image-block-strategy';
import { VegaImageToRTEImageBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/vega-image-to-rte-image-block-strategy';
import { SpanImageToRTEImageBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/span-img-to-rte-image-block-strategy';
import { ContinueInlineToRTETextBlockStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/continue-inline-to-rte-text-block-strategy';
import { PlainTextToTextNodeStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/plain-text-to-text-node-strategy';
import { InlineElementToTextNodeStrategy } from '../slimmers/controllers/helper/element-to-dto-strategy/inline-element-to-text-node-strategy';
import { RTEFilterStylesStrategyRegistry } from './filter-styles-strategies/filter-styles-strategy-registry';
import { ImageFilterStylesStrategy } from './filter-styles-strategies/image-node/image-filter-styles-strategy';
import { ListBlockFilterStylesStrategy } from './filter-styles-strategies/list-block/list-block-filter-styles-strategy';
import { ListItemBlockFilterStylesStrategy } from './filter-styles-strategies/list-block/list-item-block-filter-styles-strategy';
import { AlignmentFilterStylesStrategy } from './filter-styles-strategies/text-block/alignment-filter-styles-strategy';
import { CodeFilterStylesStrategy } from './filter-styles-strategies/text-node/code-filter-styles-strategy';
import { LinkFilterStylesStrategy } from './filter-styles-strategies/text-node/link-filter-styles-strategy';
import { TextFormatFilterStylesStrategy } from './filter-styles-strategies/text-node/text-format-filter-styles-strategy';
import { ParagraphFilterStylesStrategy } from './filter-styles-strategies/text-block/paragraph-filter-styles-strategy';
import { HeadingFilterStylesStrategy } from './filter-styles-strategies/text-block/heading-filter-styles-strategy';
import { TitleFilterStylesStrategy } from './filter-styles-strategies/text-block/title-filter-styles-strategy';
import { TitleHeadingNodeFilterStylesStrategy } from './filter-styles-strategies/text-node/title-heading-node-filter-styles-strategy';
import { CodeBlockFilterStylesStrategy } from './filter-styles-strategies/code-block/code-block-filter-styles-strategy';
import { RTECodeBlockNode } from './nodes/code-block-node';
import { CodeBlockNodeFilterStylesStrategy } from './filter-styles-strategies/code-block/code-node-filter-styles-strategy';
import { ListHeadingItemBlockFilterStylesStrategy } from './filter-styles-strategies/list-block/list-heading-item-block-filter-styles-strategy';
import { ListTitleItemBlockFilterStylesStrategy } from './filter-styles-strategies/list-block/list-title-item-block-filter-styles-strategy';
/**
 * Register and setup the default DTO classes and their basic action strategies.
 */
// Register the default block DTOs
RTEDTOClassManager.registerRTEDTOClass('paragraph', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('title', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('subtitle', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-1', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-2', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-3', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-4', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-5', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-6', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('heading-6', RTETextBlock);
RTEDTOClassManager.registerRTEDTOClass('list-item', RTEListItemBlock);
RTEDTOClassManager.registerRTEDTOClass('bullet-list', RTEListBlock);
RTEDTOClassManager.registerRTEDTOClass('number-list', RTEListBlock);
RTEDTOClassManager.registerRTEDTOClass('image', RTEImageBlock);
RTEDTOClassManager.registerRTEDTOClass('code-block', RTECodeBlock);
RTEDTOClassManager.registerRTEDTOClass('html-block', RTEHtmlBlock);
// Register the default node DTOs
RTEDTOClassManager.registerRTEDTOClass('text', RTETextNode);
RTEDTOClassManager.registerRTEDTOClass('image', RTEImageNode);
// Register basic strategies for default block DTOs
RTEDTOActionStrategyManager.registerBlockBasicStrategies(RTETextBlock.name);
RTEDTOActionStrategyManager.registerBlockBasicStrategies(RTEListBlock.name);
RTEDTOActionStrategyManager.registerBlockBasicStrategies(RTEListItemBlock.name);
RTEDTOActionStrategyManager.registerBlockBasicStrategies(RTEImageBlock.name);
RTEDTOActionStrategyManager.registerBlockBasicStrategies(RTEHtmlBlock.name);
// Register element to DTO strategies for default node DTOs, The order of registration matters, the later registered strategy has higher priority.
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new ContinueInlineToRTETextBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new SpanImageToRTEImageBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new VegaImageToRTEImageBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new ImgToRTEImageBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new InlineBlockToRTETextBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new LiToRTEListItemBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new ULNotLiChildToRTEListItemBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new OlToRTEListBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new UlToRTEListBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new HtmlBlockStrategy());
//!important: Code block strategies must be registered after HtmlBlockStrategy because registerElementToBlockStrategy uses unshift, giving later registrations higher priority.
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new JiraCodeToRTECodeBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToBlockStrategy(new VegaCodeBlockToRTECodeBlockStrategy());
ElementToDTOClassStrategyManager.registerElementToNodeStrategy(new InlineElementToTextNodeStrategy());
ElementToDTOClassStrategyManager.registerElementToNodeStrategy(new PlainTextToTextNodeStrategy());
// Register filter styles strategies (remove redundant default styles during HTML → DTO conversion)
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new AlignmentFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTEListBlock.name, new AlignmentFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new AlignmentFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTETextNode.name, new TextFormatFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new ParagraphFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new HeadingFilterStylesStrategy(1));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new HeadingFilterStylesStrategy(2));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new HeadingFilterStylesStrategy(3));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new HeadingFilterStylesStrategy(4));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new HeadingFilterStylesStrategy(5));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new HeadingFilterStylesStrategy(6));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new TitleFilterStylesStrategy('title'));
RTEFilterStylesStrategyRegistry.register(RTETextBlock.name, new TitleFilterStylesStrategy('subtitle'));
RTEFilterStylesStrategyRegistry.register(RTETextNode.name, new TitleHeadingNodeFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTETextNode.name, new CodeFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTETextNode.name, new LinkFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTEImageNode.name, new ImageFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTECodeBlock.name, new CodeBlockFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTECodeBlockNode.name, new CodeBlockNodeFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTEListBlock.name, new ListBlockFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListItemBlockFilterStylesStrategy());
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(1));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(2));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(3));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(4));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(5));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListHeadingItemBlockFilterStylesStrategy(6));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListTitleItemBlockFilterStylesStrategy('title'));
RTEFilterStylesStrategyRegistry.register(RTEListItemBlock.name, new ListTitleItemBlockFilterStylesStrategy('subtitle'));
