import { Component, Input } from '@angular/core';
import BaseSection from '../BaseSection';
import { SimpoElementsModule } from './../../elements/index';
import { CommonModule } from '@angular/common';
import { SimpoComponentModule } from '../../components/index';
import { TextEditorComponent } from '../../elements/text-editor/text-editor.component';
import { HoverDirective } from '../../directive/hover-element-directive';
import { AnimationDirective } from '../../directive/animation-directive';
import { BackgroundDirective } from '../../directive/background-directive';
import { SpacingHorizontalDirective } from '../../directive/spacing-horizontal.directive';
import { SpacingAroundDirective } from '../../directive/spacing-around.directive';
import { ImageEditorDirective } from '../../directive/image-editor.directive';
import { CornerDirective } from '../../directive/corner-directive';
import { ButtonDirectiveDirective } from '../../directive/button-directive.directive';
import { ButtonEditorDirective } from '../../directive/button-editor.directive';
import { PositionLayoutDirectiveDirective } from '../../directive/position-layout-directive.directive';
import { ContentFitDirective } from '../../directive/content-fit-directive';
import { ImageDirectiveDirective } from '../../directive/image-directive.directive';
import { ObjectPositionDirective } from '../../directive/image-position.directive';
import { FormsModule } from '@angular/forms';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { SimpoContainerAligment } from '../../directive/container-alignment.directive';
import { OverlayDirective } from '../../directive/overlay-directive';
import * as i0 from "@angular/core";
import * as i1 from "../../services/rest.service";
import * as i2 from "@angular/material/snack-bar";
import * as i3 from "@angular/common";
import * as i4 from "../../components/hover-elements/hover-elements.component";
import * as i5 from "../../components/delete-hover-element/delete-hover-element.component";
import * as i6 from "@angular/forms";
export class NewsLetterComponentComponent extends BaseSection {
    constructor(restservice, snackBar) {
        super();
        this.restservice = restservice;
        this.snackBar = snackBar;
        this.email = "";
        this.error = false;
    }
    ngOnInit() {
        this.styles = this.data?.styles;
        this.content = this.data?.content;
    }
    postNewsLetter() {
        const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-z]{2,4}$/;
        if (!emailRegex.test(this.email)) {
            this.snackBar.open("Please enter a valid email address.", "Close", {
                duration: 3000,
            });
            this.error = true;
            return;
        }
        else {
            this.error = false;
        }
        this.restservice.postNewsLetter(this.email).subscribe((res) => {
            this.snackBar.open("Thank you for subscribing to our newsletter!", "Close", {
                duration: 3000,
            });
        }, (error) => {
            this.snackBar.open("Failed to subscribe to newsletter. Please try again later.", "Close", {
                duration: 3000,
            });
        });
    }
    get stylesLayout() {
        return { ...this.styles?.layout };
    }
    getButtonId(index) {
        return this.data?.action?.buttons[index]?.id ?? "";
    }
    getButtonStyle(index) {
        return this.data?.action?.buttons[index]?.styles;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NewsLetterComponentComponent, deps: [{ token: i1.RestService }, { token: i2.MatSnackBar }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: NewsLetterComponentComponent, isStandalone: true, selector: "simpo-news-letter-component", inputs: { index: "index", edit: "edit", delete: "delete", data: "data" }, usesInheritance: true, ngImport: i0, template: "<div class=\"total-container\" simpoHover (hovering)=\"showEditTabs($event)\">\r\n    <div [spacingAround]=\"stylesLayout\" [id]=\"data?.id\">\r\n        <div [simpoBackground]=\"styles?.background\" [id]=\"data?.id\" class=\"total-container row justify-content-center\">\r\n            <div class=\"row field-container\" [simpoCorner]=\"styles?.corners\" [spacingHorizontal]=\"stylesLayout\"\r\n                [simpoLayout]=\"stylesLayout\" [simpoPositionLayoutDirective]=\"styles?.positionLayout\" [id]=\"data?.id\"\r\n                [simpoAnimation]=\"styles?.animation\" [simpoOverlay]=\"styles?.background\">\r\n                <div class=\"col-7 d-flex gap-2 align-items-center image-field-container\"\r\n                    [simpoPositionLayoutDirective]=\"styles?.positionLayout\" [id]=\"data?.id\" *ngIf=\"content?.image?.showImage\">\r\n                    <div class=\"image-container\">\r\n                        <img [src]=\"content?.image?.url\" [alt]=\"content?.image?.altText\" [simpoCorner]=\"styles?.corners\"\r\n                            [id]=\"data?.id\" [appImageEditor]=\"edit || false\" [imageData]=\"content?.image\"\r\n                            [simpoImageDirective]=\"styles?.image\" [id]=\"data?.id\"\r\n                            [simpoObjectPosition]=\"content?.image?.position\" [sectionId]=\"data?.id\"\r\n                            [class]=\"data?.id+(content?.image?.id || '') + ' w-100 h-100'\"\r\n                            [class.logo]=\"content?.display?.showIcon\">\r\n                    </div>\r\n                    <div class=\"text-container mb-3\" *ngIf=\"content?.display?.showIcon || !content?.image?.showImage\">\r\n                        <ng-container *ngFor=\"let item of content?.inputText; let i = index\">\r\n                            <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n                        </ng-container>\r\n                    </div>\r\n                </div>\r\n                <div\r\n                    class=\"col-5 d-flex flex-column align-items-center justify-content-center h-100 input-fields-container\" [simpoContainerAlignment]=\"stylesLayout\" [id]=\"data?.id\">\r\n                    <div class=\"text-container mb-3\" *ngIf=\"!content?.display?.showIcon\">\r\n                        <ng-container *ngFor=\"let item of content?.inputText; let i = index\">\r\n                            <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n                        </ng-container>\r\n                    </div>\r\n                    <div class=\"input-field w-75 mb-3\">\r\n                        <input type=\"email\" placeholder=\"Enter your email\" class=\"form-control py-2\" [(ngModel)]=\"email\"\r\n                            [class.error-border]=\"error\" [simpoCorner]=\"styles?.corners\">\r\n                    </div>\r\n                    <button class=\"submit w-75\" simpoButtonDirective [id]=\"data?.id+getButtonId(0)\"\r\n                        [buttonStyle]=\"getButtonStyle(0)\" [backgroundInfo]=\"styles?.background\" [sectionId]=\"data?.id\"\r\n                        [appButtonEditor]=\"edit ?? false\" [buttonId]=\"getButtonId(0)\"\r\n                        [color]=\"data?.styles?.background?.accentColor\" (click)=\"postNewsLetter()\">Submit</button>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div [ngClass]=\"{'hover_effect': edit}\" *ngIf=\"showEditors\">\r\n        <simpo-hover-elements [data]=\"data\" [index]=\"index\" [editOptions]=\"edit\"></simpo-hover-elements>\r\n    </div>\r\n    <div *ngIf=\"showDelete\" [ngClass]=\"{'hover_effect': delete}\">\r\n        <simpo-delete-hover-element [data]=\"data\" [index]=\"index\"></simpo-delete-hover-element>\r\n    </div>\r\n</div>", styles: [".hover_effect{position:unset;width:100%;top:0;left:0;height:100%}.total-container{position:relative}.submit{padding:5px 0}.logo{width:120px!important;height:120px!important;object-fit:unset!important}.error-border{border:2px solid #dc3545!important}@media (max-width:475px){.field-container{flex-direction:column}.total-container .total-container{justify-content:center}.image-field-container{width:100%}.image-container{margin-bottom:10px}.input-fields-container{height:auto!important;width:100%}}\n"], dependencies: [{ kind: "ngmodule", type: SimpoElementsModule }, { kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i3.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i3.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i3.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: SimpoComponentModule }, { kind: "component", type: i4.HoverElementsComponent, selector: "simpo-hover-elements", inputs: ["data", "index", "editOptions", "isMerged", "isEcommerce"], outputs: ["edit"] }, { kind: "component", type: i5.DeleteHoverElementComponent, selector: "simpo-delete-hover-element", inputs: ["index", "data"], outputs: ["edit"] }, { kind: "component", type: TextEditorComponent, selector: "simpo-text-editor", inputs: ["value", "editable", "isRTE", "sectionId", "label", "type", "inputTextIndex", "itemIndex"], outputs: ["valueChange"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i6.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i6.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i6.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: HoverDirective, selector: "[simpoHover]", outputs: ["hovering"] }, { kind: "directive", type: AnimationDirective, selector: "[simpoAnimation]", inputs: ["simpoAnimation"] }, { kind: "directive", type: BackgroundDirective, selector: "[simpoBackground]", inputs: ["simpoBackground", "scrollValue"] }, { kind: "directive", type: SpacingHorizontalDirective, selector: "[spacingHorizontal]", inputs: ["spacingHorizontal", "isHeader"] }, { kind: "directive", type: SpacingAroundDirective, selector: "[spacingAround]", inputs: ["spacingAround", "backgroundInfo"] }, { kind: "directive", type: ImageEditorDirective, selector: "[appImageEditor]", inputs: ["appImageEditor", "imageData", "sectionId", "showIcon", "iconData", "itemIndex"] }, { kind: "directive", type: CornerDirective, selector: "[simpoCorner]", inputs: ["simpoCorner"] }, { kind: "directive", type: ButtonDirectiveDirective, selector: "[simpoButtonDirective]", inputs: ["buttonStyle", "color", "scrollValue", "backgroundInfo"] }, { kind: "directive", type: ButtonEditorDirective, selector: "button[appButtonEditor]", inputs: ["appButtonEditor", "buttonData", "buttonStyle", "backgroundInfo", "sectionId", "buttonId", "itemIndex"] }, { kind: "directive", type: PositionLayoutDirectiveDirective, selector: "[simpoPositionLayoutDirective]", inputs: ["simpoPositionLayoutDirective"] }, { kind: "directive", type: ContentFitDirective, selector: "[simpoLayout]", inputs: ["simpoLayout"] }, { kind: "directive", type: ImageDirectiveDirective, selector: "[simpoImageDirective]", inputs: ["simpoImageDirective"] }, { kind: "directive", type: ObjectPositionDirective, selector: "[simpoObjectPosition]", inputs: ["simpoObjectPosition"] }, { kind: "ngmodule", type: MatSnackBarModule }, { kind: "directive", type: SimpoContainerAligment, selector: "[simpoContainerAlignment]", inputs: ["simpoContainerAlignment"] }, { kind: "directive", type: OverlayDirective, selector: "[simpoOverlay]", inputs: ["simpoOverlay"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: NewsLetterComponentComponent, decorators: [{
            type: Component,
            args: [{ selector: 'simpo-news-letter-component', standalone: true, imports: [
                        SimpoElementsModule,
                        CommonModule,
                        SimpoComponentModule,
                        TextEditorComponent,
                        FormsModule,
                        HoverDirective,
                        AnimationDirective,
                        BackgroundDirective,
                        SpacingHorizontalDirective,
                        SpacingAroundDirective,
                        ImageEditorDirective,
                        CornerDirective,
                        TextEditorComponent,
                        ButtonDirectiveDirective,
                        ButtonEditorDirective,
                        PositionLayoutDirectiveDirective,
                        ContentFitDirective,
                        ImageDirectiveDirective,
                        ObjectPositionDirective,
                        MatSnackBarModule,
                        SimpoContainerAligment,
                        OverlayDirective,
                    ], template: "<div class=\"total-container\" simpoHover (hovering)=\"showEditTabs($event)\">\r\n    <div [spacingAround]=\"stylesLayout\" [id]=\"data?.id\">\r\n        <div [simpoBackground]=\"styles?.background\" [id]=\"data?.id\" class=\"total-container row justify-content-center\">\r\n            <div class=\"row field-container\" [simpoCorner]=\"styles?.corners\" [spacingHorizontal]=\"stylesLayout\"\r\n                [simpoLayout]=\"stylesLayout\" [simpoPositionLayoutDirective]=\"styles?.positionLayout\" [id]=\"data?.id\"\r\n                [simpoAnimation]=\"styles?.animation\" [simpoOverlay]=\"styles?.background\">\r\n                <div class=\"col-7 d-flex gap-2 align-items-center image-field-container\"\r\n                    [simpoPositionLayoutDirective]=\"styles?.positionLayout\" [id]=\"data?.id\" *ngIf=\"content?.image?.showImage\">\r\n                    <div class=\"image-container\">\r\n                        <img [src]=\"content?.image?.url\" [alt]=\"content?.image?.altText\" [simpoCorner]=\"styles?.corners\"\r\n                            [id]=\"data?.id\" [appImageEditor]=\"edit || false\" [imageData]=\"content?.image\"\r\n                            [simpoImageDirective]=\"styles?.image\" [id]=\"data?.id\"\r\n                            [simpoObjectPosition]=\"content?.image?.position\" [sectionId]=\"data?.id\"\r\n                            [class]=\"data?.id+(content?.image?.id || '') + ' w-100 h-100'\"\r\n                            [class.logo]=\"content?.display?.showIcon\">\r\n                    </div>\r\n                    <div class=\"text-container mb-3\" *ngIf=\"content?.display?.showIcon || !content?.image?.showImage\">\r\n                        <ng-container *ngFor=\"let item of content?.inputText; let i = index\">\r\n                            <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n                        </ng-container>\r\n                    </div>\r\n                </div>\r\n                <div\r\n                    class=\"col-5 d-flex flex-column align-items-center justify-content-center h-100 input-fields-container\" [simpoContainerAlignment]=\"stylesLayout\" [id]=\"data?.id\">\r\n                    <div class=\"text-container mb-3\" *ngIf=\"!content?.display?.showIcon\">\r\n                        <ng-container *ngFor=\"let item of content?.inputText; let i = index\">\r\n                            <simpo-text-editor [(value)]=\"item.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"item.isRTE\"></simpo-text-editor>\r\n                        </ng-container>\r\n                    </div>\r\n                    <div class=\"input-field w-75 mb-3\">\r\n                        <input type=\"email\" placeholder=\"Enter your email\" class=\"form-control py-2\" [(ngModel)]=\"email\"\r\n                            [class.error-border]=\"error\" [simpoCorner]=\"styles?.corners\">\r\n                    </div>\r\n                    <button class=\"submit w-75\" simpoButtonDirective [id]=\"data?.id+getButtonId(0)\"\r\n                        [buttonStyle]=\"getButtonStyle(0)\" [backgroundInfo]=\"styles?.background\" [sectionId]=\"data?.id\"\r\n                        [appButtonEditor]=\"edit ?? false\" [buttonId]=\"getButtonId(0)\"\r\n                        [color]=\"data?.styles?.background?.accentColor\" (click)=\"postNewsLetter()\">Submit</button>\r\n                </div>\r\n            </div>\r\n        </div>\r\n    </div>\r\n    <div [ngClass]=\"{'hover_effect': edit}\" *ngIf=\"showEditors\">\r\n        <simpo-hover-elements [data]=\"data\" [index]=\"index\" [editOptions]=\"edit\"></simpo-hover-elements>\r\n    </div>\r\n    <div *ngIf=\"showDelete\" [ngClass]=\"{'hover_effect': delete}\">\r\n        <simpo-delete-hover-element [data]=\"data\" [index]=\"index\"></simpo-delete-hover-element>\r\n    </div>\r\n</div>", styles: [".hover_effect{position:unset;width:100%;top:0;left:0;height:100%}.total-container{position:relative}.submit{padding:5px 0}.logo{width:120px!important;height:120px!important;object-fit:unset!important}.error-border{border:2px solid #dc3545!important}@media (max-width:475px){.field-container{flex-direction:column}.total-container .total-container{justify-content:center}.image-field-container{width:100%}.image-container{margin-bottom:10px}.input-fields-container{height:auto!important;width:100%}}\n"] }]
        }], ctorParameters: () => [{ type: i1.RestService }, { type: i2.MatSnackBar }], propDecorators: { index: [{
                type: Input
            }], edit: [{
                type: Input
            }], delete: [{
                type: Input
            }], data: [{
                type: Input
            }] } });
//# sourceMappingURL=data:application/json;base64, 