import { Directive, ElementRef, Input } from '@angular/core';
import { LayoutEditorMetadataExtractor } from '../../services';
import * as i0 from "@angular/core";
import * as i1 from "../../services";
//TODO: remove, do it more generic
/**
 * Copies designer styles that should be applied to element
 */
export class CopyDesignerStylesSADirective {
    //######################### public properties - inputs #########################
    /**
     * Designed component metadata
     */
    get metadata() {
        return this._metadata;
    }
    set metadata(value) {
        this._metadata = value;
        this._copyDesignerStyles();
    }
    //######################### constructor #########################
    constructor(_element, _metadataExtractor) {
        this._element = _element;
        this._metadataExtractor = _metadataExtractor;
    }
    //######################### protected methods #########################
    /**
     * Copies designer styles if necessary
     */
    async _copyDesignerStyles() {
        if (!this._metadata) {
            return;
        }
        const metadata = await this._metadataExtractor.extractMetadata(this._metadata);
        const applyDesignerStyles = metadata?.applyDesignerStyles;
        if (applyDesignerStyles) {
            applyDesignerStyles(this._metadata.options, this._element.nativeElement.style);
        }
    }
}
CopyDesignerStylesSADirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CopyDesignerStylesSADirective, deps: [{ token: i0.ElementRef }, { token: i1.LayoutEditorMetadataExtractor }], target: i0.ɵɵFactoryTarget.Directive });
CopyDesignerStylesSADirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.0.4", type: CopyDesignerStylesSADirective, isStandalone: true, selector: "[copyDesignerStyles]", inputs: { metadata: ["copyDesignerStyles", "metadata"] }, exportAs: ["copyDesignerStyles"], ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.4", ngImport: i0, type: CopyDesignerStylesSADirective, decorators: [{
            type: Directive,
            args: [{
                    selector: '[copyDesignerStyles]',
                    exportAs: 'copyDesignerStyles',
                    standalone: true
                }]
        }], ctorParameters: () => [{ type: i0.ElementRef }, { type: i1.LayoutEditorMetadataExtractor }], propDecorators: { metadata: [{
                type: Input,
                args: ['copyDesignerStyles']
            }] } });
//# sourceMappingURL=copyDesignerStyles.directive.js.map