import { Component, Input } from '@angular/core';
import { SearchType } from '../toolbar-event.service';
import { select } from '@ngrx/store';
import * as fromRedactSelectors from '../../store/selectors/redaction.selectors';
import * as i0 from "@angular/core";
import * as i1 from "../toolbar-event.service";
import * as i2 from "../toolbar-button-visibility.service";
import * as i3 from "@ngrx/store";
import * as i4 from "@angular/common";
import * as i5 from "../../shared/directives/tooltip-dismiss.directive";
import * as i6 from "rpx-xui-translation";
export class RedactionToolbarComponent {
    constructor(toolbarEventService, toolbarButtons, store) {
        this.toolbarEventService = toolbarEventService;
        this.toolbarButtons = toolbarButtons;
        this.store = store;
        this.preview = false;
        this.hasRedactions = false;
        this.subscriptions = [];
    }
    ngOnInit() {
        this.subscriptions.push(this.store.pipe(select(fromRedactSelectors.getRedactionArray)).subscribe(redactions => {
            this.hasRedactions = !!redactions.redactions.length;
        }));
        this.subscriptions.push(this.toolbarEventService.redactAllInProgressSubject.subscribe(inprogress => {
            this.redactionAllInProgress = inprogress;
        }));
    }
    onRedactAllSearch() {
        this.toolbarEventService.openRedactionSearch.next({ modeType: SearchType.Redact, isOpen: true });
    }
    toggleTextRedactionMode() {
        this.toolbarEventService.highlightModeSubject.next(true);
    }
    toggleDrawMode() {
        this.toolbarEventService.drawModeSubject.next(true);
    }
    togglePreview() {
        this.preview = !this.preview;
        this.toolbarEventService.toggleRedactionPreview(this.preview);
    }
    unmarkAll() {
        this.toolbarEventService.unmarkAll();
    }
    redact() {
        this.toolbarEventService.applyRedactionToDocument();
    }
    toggleRedactBar() {
        this.toolbarEventService.toggleRedactionMode();
    }
    redactPage() {
        this.toolbarEventService.drawModeSubject.next(true);
        this.toolbarEventService.redactPage();
    }
    ngOnDestroy() {
        for (const subscription of this.subscriptions) {
            subscription.unsubscribe();
        }
    }
    /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RedactionToolbarComponent, deps: [{ token: i1.ToolbarEventService }, { token: i2.ToolbarButtonVisibilityService }, { token: i3.Store }], target: i0.ɵɵFactoryTarget.Component }); }
    /** @nocollapse */ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: RedactionToolbarComponent, selector: "mv-redaction-toolbar", inputs: { showRedactSearch: "showRedactSearch" }, ngImport: i0, template: "<div class=\"redaction\">\n  <label class=\"govuk-label redaction-title\" data-l10n-id=\"redaction_options\">{{\n    \"Redaction options\" | rpxTranslate\n  }}</label>\n  <button\n    id=\"toggleDrawButton\"\n    class=\"mv-button redaction-button--draw mv-tooltip\"\n    [attr.data-tooltip]=\"'Draw a box' | rpxTranslate\"\n    data-l10n-id=\"toggleDrawButton\"\n    (click)=\"toggleDrawMode()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"toggleDrawButton_label\">{{\n      \"Draw a box\" | rpxTranslate\n    }}</span>\n  </button>\n  <button\n    id=\"redactPageButton\"\n    class=\"mv-button redaction-button--redact-page mv-tooltip\"\n    [attr.data-tooltip]=\"'Redact page' | rpxTranslate\"\n    data-l10n-id=\"redactPageButton\"\n    (click)=\"redactPage()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"redactPageButton_label\">{{\n      \"Redact page\" | rpxTranslate\n    }}</span>\n  </button>\n  <button\n    *ngIf=\"showRedactSearch\"\n    id=\"mvRedactFromSearchBtn\"\n    class=\"mv-button redaction-button--search mv-tooltip\"\n    [attr.data-tooltip]=\"'From search' | rpxTranslate\"\n    data-l10n-id=\"fromSearchButton\"\n    (click)=\"onRedactAllSearch()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span style=\"width: 5rem\" data-l10n-id=\"fromSearchButton_label\">{{\n      \"From search\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    *ngIf=\"toolbarButtons.showHighlightButton\"\n    id=\"toggleHighlightButton\"\n    class=\"mv-button redaction-button--redact mv-tooltip\"\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Redact text' | rpxTranslate\"\n    data-l10n-id=\"toggleTextRedactionButton\"\n    (click)=\"toggleTextRedactionMode()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"toggleTextRedactionButton_label\">{{\n      \"Redact text\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    [disabled]=\"!hasRedactions || redactionAllInProgress\"\n    id=\"mvClearBtn\"\n    #mvClearBtn\n    class=\"mv-button redaction-button--clear mv-tooltip\"\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Clear all' | rpxTranslate\"\n    data-l10n-id=\"toggleClearAllButton\"\n    (click)=\"unmarkAll()\"\n  >\n    <span data-l10n-id=\"Clear all\">{{ \"Clear all\" | rpxTranslate }}</span>\n  </button>\n\n  <button\n    [disabled]=\"!hasRedactions || redactionAllInProgress\"\n    id=\"mvPreviewBtn\"\n    class=\"mv-button mv-tooltip\"\n    [class.redaction-button--preview]=\"!preview\"\n    [class.redaction-button--hide-preview]=\"preview\"\n    redaction-button--preview\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Preview' | rpxTranslate\"\n    data-l10n-id=\"togglePreviewButton\"\n    (click)=\"togglePreview()\"\n  >\n    <span *ngIf=\"!preview\" data-l10n-id=\"redaction-preview_label\">{{\n      \"Preview\" | rpxTranslate\n    }}</span>\n    <span *ngIf=\"preview\" data-l10n-id=\"redaction-hide-preview_label\">{{\n      \"Hide preview\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    [disabled]=\"!hasRedactions || redactionAllInProgress\"\n    id=\"mvRedactBtn\"\n    class=\"mv-button redaction-button--download mv-tooltip\"\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Save document' | rpxTranslate\"\n    data-l10n-id=\"mvRedactBtn\"\n    (click)=\"redact()\"\n  >\n    <span data-l10n-id=\"Save Document\">{{\n      \"Save document\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    id=\"mvCloseBtn\"\n    #mvCloseBtn\n    class=\"mv-button redaction-button--close mv-tooltip\"\n    [attr.data-tooltip]=\"'Close Redaction' | rpxTranslate\"\n    data-l10n-id=\"mvRedactBtn\"\n    (click)=\"toggleRedactBar()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"Close Redaction\">{{\n      \"Close Redaction\" | rpxTranslate\n    }}</span>\n  </button>\n</div>\n", dependencies: [{ kind: "directive", type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i5.TooltipDismissDirective, selector: ".mv-tooltip, [mvTooltipDismiss]" }, { kind: "pipe", type: i6.RpxTranslatePipe, name: "rpxTranslate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: RedactionToolbarComponent, decorators: [{
            type: Component,
            args: [{ selector: 'mv-redaction-toolbar', template: "<div class=\"redaction\">\n  <label class=\"govuk-label redaction-title\" data-l10n-id=\"redaction_options\">{{\n    \"Redaction options\" | rpxTranslate\n  }}</label>\n  <button\n    id=\"toggleDrawButton\"\n    class=\"mv-button redaction-button--draw mv-tooltip\"\n    [attr.data-tooltip]=\"'Draw a box' | rpxTranslate\"\n    data-l10n-id=\"toggleDrawButton\"\n    (click)=\"toggleDrawMode()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"toggleDrawButton_label\">{{\n      \"Draw a box\" | rpxTranslate\n    }}</span>\n  </button>\n  <button\n    id=\"redactPageButton\"\n    class=\"mv-button redaction-button--redact-page mv-tooltip\"\n    [attr.data-tooltip]=\"'Redact page' | rpxTranslate\"\n    data-l10n-id=\"redactPageButton\"\n    (click)=\"redactPage()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"redactPageButton_label\">{{\n      \"Redact page\" | rpxTranslate\n    }}</span>\n  </button>\n  <button\n    *ngIf=\"showRedactSearch\"\n    id=\"mvRedactFromSearchBtn\"\n    class=\"mv-button redaction-button--search mv-tooltip\"\n    [attr.data-tooltip]=\"'From search' | rpxTranslate\"\n    data-l10n-id=\"fromSearchButton\"\n    (click)=\"onRedactAllSearch()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span style=\"width: 5rem\" data-l10n-id=\"fromSearchButton_label\">{{\n      \"From search\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    *ngIf=\"toolbarButtons.showHighlightButton\"\n    id=\"toggleHighlightButton\"\n    class=\"mv-button redaction-button--redact mv-tooltip\"\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Redact text' | rpxTranslate\"\n    data-l10n-id=\"toggleTextRedactionButton\"\n    (click)=\"toggleTextRedactionMode()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"toggleTextRedactionButton_label\">{{\n      \"Redact text\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    [disabled]=\"!hasRedactions || redactionAllInProgress\"\n    id=\"mvClearBtn\"\n    #mvClearBtn\n    class=\"mv-button redaction-button--clear mv-tooltip\"\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Clear all' | rpxTranslate\"\n    data-l10n-id=\"toggleClearAllButton\"\n    (click)=\"unmarkAll()\"\n  >\n    <span data-l10n-id=\"Clear all\">{{ \"Clear all\" | rpxTranslate }}</span>\n  </button>\n\n  <button\n    [disabled]=\"!hasRedactions || redactionAllInProgress\"\n    id=\"mvPreviewBtn\"\n    class=\"mv-button mv-tooltip\"\n    [class.redaction-button--preview]=\"!preview\"\n    [class.redaction-button--hide-preview]=\"preview\"\n    redaction-button--preview\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Preview' | rpxTranslate\"\n    data-l10n-id=\"togglePreviewButton\"\n    (click)=\"togglePreview()\"\n  >\n    <span *ngIf=\"!preview\" data-l10n-id=\"redaction-preview_label\">{{\n      \"Preview\" | rpxTranslate\n    }}</span>\n    <span *ngIf=\"preview\" data-l10n-id=\"redaction-hide-preview_label\">{{\n      \"Hide preview\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    [disabled]=\"!hasRedactions || redactionAllInProgress\"\n    id=\"mvRedactBtn\"\n    class=\"mv-button redaction-button--download mv-tooltip\"\n    aria-pressed=\"false\"\n    [attr.data-tooltip]=\"'Save document' | rpxTranslate\"\n    data-l10n-id=\"mvRedactBtn\"\n    (click)=\"redact()\"\n  >\n    <span data-l10n-id=\"Save Document\">{{\n      \"Save document\" | rpxTranslate\n    }}</span>\n  </button>\n\n  <button\n    id=\"mvCloseBtn\"\n    #mvCloseBtn\n    class=\"mv-button redaction-button--close mv-tooltip\"\n    [attr.data-tooltip]=\"'Close Redaction' | rpxTranslate\"\n    data-l10n-id=\"mvRedactBtn\"\n    (click)=\"toggleRedactBar()\"\n    [disabled]=\"redactionAllInProgress\"\n  >\n    <span data-l10n-id=\"Close Redaction\">{{\n      \"Close Redaction\" | rpxTranslate\n    }}</span>\n  </button>\n</div>\n" }]
        }], ctorParameters: () => [{ type: i1.ToolbarEventService }, { type: i2.ToolbarButtonVisibilityService }, { type: i3.Store }], propDecorators: { showRedactSearch: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 