import { Component, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef } from '@angular/core';
import { FirstUppercaseLocalizeSAPipe } from '@anglr/common';
import { RelationsNodeBase, RelationNodeOutputSAComponent, RelationsNodeHeaderSAComponent } from '@anglr/dynamic/relations-editor';
import { TitledDialogService } from '@anglr/common/material';
import { isPresent } from '@jscrpt/common';
import { lastValueFrom } from '@jscrpt/common/rxjs';
import { RichTextBlockEditorDialogSAComponent } from '../../richTextBlock/misc/components';
import * as i0 from "@angular/core";
import * as i1 from "@anglr/common/material";
/**
 * Relations node component for rich text source
 */
export class RichTextSourceNodeSAComponent extends RelationsNodeBase {
    //######################### constructor #########################
    constructor(changeDetector, element, dialog) {
        super(changeDetector, element);
        this.dialog = dialog;
    }
    //######################### protected methods - template bindings #########################
    /**
     * Shows code editor
     */
    async showCodeEditor() {
        const result = await lastValueFrom(this.dialog.open(RichTextBlockEditorDialogSAComponent, {
            title: 'Rich text editor',
            width: '75vw',
            height: '75vh',
            data: this.metadata?.relationsOptions?.content ?? ''
        }).afterClosed());
        if (isPresent(result)) {
            if (this.metadata?.relationsOptions) {
                this.metadata.relationsOptions.content = result;
                this.history.getNewState();
            }
        }
    }
}
RichTextSourceNodeSAComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: RichTextSourceNodeSAComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i1.TitledDialogService }], target: i0.ɵɵFactoryTarget.Component });
RichTextSourceNodeSAComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.0.4", type: RichTextSourceNodeSAComponent, isStandalone: true, selector: "rich-text-source-node", usesInheritance: true, ngImport: i0, template: "<relations-node-header [parent]=\"this\" [destroySubject]=\"destroySubject\" [name]=\"'rich text source'|firstUppercaseLocalize\"></relations-node-header>\n\n<div class=\"node-content\">\n    <div class=\"inputs-outputs\">\n        <div class=\"inputs\">\n        </div>\n    \n        <div class=\"outputs\">\n            <div class=\"output\">\n                <div>{{'html string'|firstUppercaseLocalize}}</div>\n                <relation-node-output [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"htmlString\" [parent]=\"this\"></relation-node-output>\n            </div>\n        </div>\n    </div>\n\n    <button type=\"button\" class=\"dynamic-btn dynamic-btn-primary\" (click)=\"showCodeEditor()\">\n        <span>{{'content'|firstUppercaseLocalize}}</span>\n    </button>\n</div>", dependencies: [{ kind: "component", type: RelationsNodeHeaderSAComponent, selector: "relations-node-header", inputs: ["parent", "destroySubject", "name"] }, { kind: "component", type: RelationNodeOutputSAComponent, selector: "relation-node-output" }, { kind: "pipe", type: FirstUppercaseLocalizeSAPipe, name: "firstUppercaseLocalize" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: RichTextSourceNodeSAComponent, decorators: [{
            type: Component,
            args: [{ selector: 'rich-text-source-node', standalone: true, imports: [
                        RelationsNodeHeaderSAComponent,
                        RelationNodeOutputSAComponent,
                        FirstUppercaseLocalizeSAPipe,
                    ], changeDetection: ChangeDetectionStrategy.OnPush, template: "<relations-node-header [parent]=\"this\" [destroySubject]=\"destroySubject\" [name]=\"'rich text source'|firstUppercaseLocalize\"></relations-node-header>\n\n<div class=\"node-content\">\n    <div class=\"inputs-outputs\">\n        <div class=\"inputs\">\n        </div>\n    \n        <div class=\"outputs\">\n            <div class=\"output\">\n                <div>{{'html string'|firstUppercaseLocalize}}</div>\n                <relation-node-output [parentCoordiantes]=\"nodePosition\" [zoomLevel]=\"zoomLevel\" name=\"htmlString\" [parent]=\"this\"></relation-node-output>\n            </div>\n        </div>\n    </div>\n\n    <button type=\"button\" class=\"dynamic-btn dynamic-btn-primary\" (click)=\"showCodeEditor()\">\n        <span>{{'content'|firstUppercaseLocalize}}</span>\n    </button>\n</div>" }]
        }], ctorParameters: () => [{ type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i1.TitledDialogService }] });
//# sourceMappingURL=richTextSourceNode.component.js.map