var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { MapToComponentField as MapToSlimmerField } from 'vega-slimmer/core';
import { HorizontalAlignmentAnnotationAction } from '../../../../dto/actions/horizontal-alignment-annotation-action';
import { BlockAnnotationTypeEnum } from '../../../../dto/annotations/block-annotation.abstract';
import { VegaInternalIconManager } from '../../../../../../helpers/icon/internal-icon-manager';
import AlignLeft from '../../../../assets/align-left';
import { VisualModeToolbarButtonSlimmer } from '../visual-mode-toolbar-button-slimmer.abstract';
export class LeftAlignToolbarButtonSlimmer extends VisualModeToolbarButtonSlimmer {
  constructor() {
    super({
      icon: 'align-left',
      tooltip: {
        text: 'Left Align',
      },
    });
  }
  isSelected() {
    const selectedBlocks = this.selectionController.getSelectedBlocks();
    return (selectedBlocks.length > 0 &&
      selectedBlocks.every((block) => {
        var _a;
        return ((_a = block.getAnnotationByType(BlockAnnotationTypeEnum.ALIGNMENT)) === null || _a === void 0 ? void 0 : _a.textAlign) === 'left';
      }));
  }
  onClick() {
    this.selectionController
      .getSelectedBlocks()
      .forEach((item) => item.apply(new HorizontalAlignmentAnnotationAction('left')));
    void this.popoverRef.hide();
  }
}
(() => {
  VegaInternalIconManager.register({
    'align-left': AlignLeft,
  });
})();
__decorate([
  MapToSlimmerField()
], LeftAlignToolbarButtonSlimmer.prototype, "selectionController", void 0);
__decorate([
  MapToSlimmerField()
], LeftAlignToolbarButtonSlimmer.prototype, "popoverRef", void 0);
