import { Component, Input, ViewChild } from '@angular/core';
import { CommonModule } from '@angular/common';
import { SimpoElementsModule } from '../../elements/index';
import { SimpoComponentModule } from '../../components/index';
import { AnimationDirective } from '../../directive/animation-directive';
import { BackgroundDirective } from '../../directive/background-directive';
import { ContentFitDirective } from '../../directive/content-fit-directive';
import { BannerContentFitDirective } from '../../directive/banner-content-fit-directive';
import { BorderDirective } from '../../directive/border-directive';
import { ButtonDirectiveDirective } from '../../directive/button-directive.directive';
import { ColumnDirectiveDirective } from '../../directive/column-directive.directive';
import { ContainerFitDirective } from '../../directive/container-fir.directive';
import { simpoConetenAlignmentDirective } from '../../directive/content-alignment-directive';
import { CornerDirective } from '../../directive/corner-directive';
import { SimpoFooterLayoutDirective } from '../../directive/footer-layout-directive';
import { HoverDirective } from '../../directive/hover-element-directive';
import { ImageDirectiveDirective } from '../../directive/image-directive.directive';
import { OverlayDirective } from '../../directive/overlay-directive';
import { PositionLayoutDirectiveDirective } from '../../directive/position-layout-directive.directive';
import { TextBackgroundDirectiveDirective } from '../../directive/text-background-directive.directive';
import { ObjectPositionDirective } from '../../directive/image-position.directive';
import BaseSection from '../BaseSection';
import { ContentTitleDirective } from '../../directive/content-title-spacing.directive';
import { TextEditorComponent } from '../../elements/text-editor/text-editor.component';
import { ImageEditorDirective } from '../../directive/image-editor.directive';
import { SpacingHorizontalDirective } from '../../directive/spacing-horizontal.directive';
import { SimpoWrapComntainer } from '../../directive/wrap-containers.directive';
import { MatIcon } from '@angular/material/icon';
import * as i0 from "@angular/core";
import * as i1 from "../../services/events.service";
import * as i2 from "../../elements/svg-divider/svg-divider.component";
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";
export class ImageGridSectionComponent extends BaseSection {
    constructor(_eventService) {
        super();
        this._eventService = _eventService;
        this._mainContainer = null;
        this.isOverflowing = false;
        this.atStart = true;
        this.atEnd = false;
    }
    ngOnInit() {
        this.content = this.data?.content;
        this.style = this.data?.styles;
        this.deleteSelected = this.delete;
    }
    get stylesLayout() {
        return { ...this.style?.layout };
    }
    get headingSpace() {
        return this.style?.layout?.headingSpacing;
    }
    editSection() {
        if (window.innerWidth <= 475)
            return;
        this._eventService.toggleEditorEvent.emit(false);
        setTimeout(() => {
            this._eventService.editSection.emit({ data: this.data });
        }, 100);
    }
    getLength() {
        return this.content?.listItem?.data?.length || 0;
    }
    getJustifyContent() {
        const el = this.imagegrid?.nativeElement;
        if (!el)
            return '';
        const isOverflowing = el.scrollWidth > el.clientWidth;
        if (isOverflowing) {
            return 'flex-start';
        }
        return this.style?.layout?.align || '';
    }
    get scrollStep() { return Math.round((this.imagegrid?.nativeElement?.clientWidth || 300) * 0.8); }
    scrollRight() {
        const el = this.imagegrid?.nativeElement;
        if (!el)
            return;
        el.scrollBy({ left: this.scrollStep, behavior: 'smooth' });
        setTimeout(() => this.updateEdges(), 300);
    }
    ngAfterViewInit() {
        // initial check
        setTimeout(() => this.checkOverflow(), 50);
        if (this.imagegrid?.nativeElement) {
            this.ro = new ResizeObserver(() => this.checkOverflow());
            this.ro.observe(this.imagegrid.nativeElement);
        }
    }
    ngOnDestroy() { this.ro?.disconnect(); }
    updateEdges() {
        const el = this.imagegrid?.nativeElement;
        if (!el)
            return;
        this.atStart = el.scrollLeft <= 5;
        this.atEnd = el.scrollLeft + el.clientWidth >= el.scrollWidth - 5;
    }
    checkOverflow() {
        const el = this.imagegrid?.nativeElement;
        if (!el)
            return;
        this.isOverflowing = el.scrollWidth > el.clientWidth + 1;
        this.updateEdges();
    }
    onScroll() { this.updateEdges(); }
    scrollLeft() {
        const el = this.imagegrid?.nativeElement;
        if (!el)
            return;
        el.scrollBy({ left: -this.scrollStep, behavior: 'smooth' });
        setTimeout(() => this.updateEdges(), 300);
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ImageGridSectionComponent, deps: [{ token: i1.EventsService }], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: ImageGridSectionComponent, isStandalone: true, selector: "simpo-image-grid-section", inputs: { data: "data", index: "index", edit: "edit", customClass: "customClass", delete: "delete", nextComponentColor: "nextComponentColor" }, viewQueries: [{ propertyName: "imagegrid", first: true, predicate: ["imagegrid"], descendants: true }, { propertyName: "_mainContainer", first: true, predicate: ["mainContainer"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<section [id]=\"data?.id\" [simpoBackground]=\"style?.background\" simpoHover (hovering)=\"showEditTabs($event)\"\r\n  class=\"total-container\" [attr.style]=\"customClass\">\r\n  <div #mainContainer [id]=\"data?.id\" [simpoOverlay]=\"style?.background\" [spacingHorizontal]=\"stylesLayout\">\r\n    <div class=\"container-fluid\" [id]=\"data?.id\" [simpoBorder]=\"style?.border\" [simpoLayout]=\"style?.layout\">\r\n      <div class=\"row\" [id]=\"data?.id\" [simpoAnimation]=\"style?.animation\"\r\n        [ngStyle]=\"style?.fullWidth ? {'padding': '0px'} : {}\">\r\n        <div *ngFor=\"let text of data?.content?.inputText; let i = index\">\r\n          <div class=\"heading-large content-side\" [simpoContentTitleSpace]=\"headingSpace\">\r\n            <ng-container *ngIf=\"edit ||  (text.value && text.value.length > 0)\">\r\n              <simpo-text-editor [(value)]=\"text.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"text.isRTE\"></simpo-text-editor>\r\n            </ng-container>\r\n          </div>\r\n        </div>\r\n\r\n        <ng-container *ngIf=\"style?.gridStyle == 'Style1'\">\r\n          <button class=\"scroll-btn left p-0 d-flex align-items-center justify-content-center\"\r\n            *ngIf=\"style?.direction === 'ROW' && isOverflowing\" (click)=\"scrollLeft()\"\r\n            [disabled]=\"atStart\"><mat-icon>keyboard_arrow_left</mat-icon>\r\n          </button>\r\n          <div class=\"main-image-section d-flex position-relative\" [class.row]=\"style?.direction == 'ROW' \"\r\n            [class.wrap-scroll]=\"style?.direction == 'ROW'\" [class.flex-wrap]=\"style?.direction == 'COLUMN'\"\r\n            [class.mobile-two-columns]=\"style?.direction == 'COLUMN' && style?.mobileColumn == 2\" [id]=\"data?.id\"\r\n            #imagegrid [style.justifyContent]=\"getJustifyContent()\" (scroll)=\"onScroll()\">\r\n            <div class=\"image-section p-md-3 p-2\" *ngFor=\"let img of content?.listItem?.data; let i = index\"\r\n              [simpoColumnDirective]=\"style?.size\" [id]=\"data?.id\"\r\n              [attr.style]=\"style?.removeGaps ? 'padding: 0px !important; margin: 0px !important;' : {}\">\r\n              <img loading=\"lazy\" [simpoImageDirective]=\"style?.image\" [simpoCorner]=\"style?.corners\" [id]=\"data?.id\"\r\n                [class]=\"data?.id+img.image.id\" [simpoObjectPosition]=\"img.image.position\" [src]=\"img.image.url\"\r\n                [alt]=\"img.image.altText\" loading=\"lazy\" [appImageEditor]=\"edit || false\" [imageData]=\"img?.image\"\r\n                [sectionId]=\"data?.id\" [itemIndex]=\"i\" class=\"w-100\" />\r\n            </div>\r\n          </div>\r\n          <button class=\"scroll-btn right p-0 d-flex align-items-center justify-content-center\"\r\n            *ngIf=\"style?.direction === 'ROW' && isOverflowing\" (click)=\"scrollRight()\"\r\n            [disabled]=\"atEnd\"><mat-icon>keyboard_arrow_right</mat-icon>\r\n          </button>\r\n\r\n        </ng-container>\r\n        <ng-container *ngIf=\"style?.gridStyle == 'Style2'\">\r\n          <div class=\"grid h-100\" [class.remove-gap]=\"style?.removeGaps\" [class.p-0]=\"style?.fullWidth\">\r\n            <ng-container *ngFor=\"let img of content?.listItem?.data; let i = index\">\r\n              <img loading=\"lazy\" [simpoImageDirective]=\"style?.image\" [simpoCorner]=\"style?.corners\" [id]=\"data?.id\"\r\n                [class]=\"data?.id+img.image.id\" [simpoObjectPosition]=\"img.image.position\" [src]=\"img.image.url\"\r\n                [alt]=\"img.image.altText\" loading=\"lazy\" [appImageEditor]=\"edit || false\" [imageData]=\"img?.image\"\r\n                [sectionId]=\"data?.id\" [itemIndex]=\"i\" class=\"w-100\" />\r\n            </ng-container>\r\n          </div>\r\n\r\n\r\n        </ng-container>\r\n      </div>\r\n    </div>\r\n  </div>\r\n  <ng-container *ngIf=\"style?.devider?.display\">\r\n    <simpo-svg-divider [dividerType]=\"style?.devider?.deviderType\"\r\n      [color]=\"nextComponentColor?.color\"></simpo-svg-divider>\r\n  </ng-container>\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</section>", styles: [".total-container{height:auto;position:relative}.main-image-section{margin-bottom:1.5rem}.mb-1{margin-bottom:1.5rem!important}.hover_effect{position:unset;width:100%;top:0;left:0;height:100%}.wrap-scroll{overflow:scroll;flex-wrap:nowrap}@media screen and (min-width : 1200px){.grid{display:grid;grid-template-columns:1fr 1fr;grid-auto-rows:auto;grid-gap:5px}.grid img:first-child:last-child{grid-column:1 / span 2}.grid img:first-child:nth-last-child(2),.grid img:nth-child(2):last-child{grid-column:span 1;height:100%}.grid img:nth-child(3n+1):not(:last-child){grid-column:1;grid-row:span 2;height:100%}.grid img:nth-child(3n+2){grid-column:2}.grid img:nth-child(3n+3){grid-column:2;align-self:end}.grid img:nth-child(3n+4){grid-column:1 / span 2}}.remove-gap{grid-gap:0!important}@media screen and (min-width: 760px){.cards{padding-bottom:24px}}.main-image-container{width:100%}@media screen and (max-width: 760px){.scroll-btn{display:none!important}.mobile-two-columns{display:grid!important;grid-template-columns:1fr 1fr;grid-auto-rows:auto;grid-gap:5px;padding:0!important}}.right-column-container{display:flex;flex-direction:column;height:100%;padding:0}.image-half-height{height:50%!important;flex:1}.image-half-height:first-child{margin-bottom:2px}.scroll-btn{position:absolute;top:50%;z-index:10;font-size:18px;width:36px!important;height:36px!important;border-radius:50%;border:none}.scroll-btn.left{left:8px}.scroll-btn.right{right:8px}\n"], dependencies: [{ kind: "ngmodule", type: SimpoElementsModule }, { kind: "component", type: i2.SvgDividerComponent, selector: "simpo-svg-divider", inputs: ["dividerType", "color"] }, { 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: "directive", type: i3.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: ColumnDirectiveDirective, selector: "[simpoColumnDirective]", inputs: ["simpoColumnDirective"] }, { kind: "directive", type: ImageDirectiveDirective, selector: "[simpoImageDirective]", inputs: ["simpoImageDirective"] }, { kind: "directive", type: ContentFitDirective, selector: "[simpoLayout]", inputs: ["simpoLayout"] }, { 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: "directive", type: 
                //directive
                AnimationDirective, selector: "[simpoAnimation]", inputs: ["simpoAnimation"] }, { kind: "directive", type: BackgroundDirective, selector: "[simpoBackground]", inputs: ["simpoBackground", "scrollValue"] }, { kind: "directive", type: BorderDirective, selector: "[simpoBorder]", inputs: ["simpoBorder"] }, { kind: "directive", type: CornerDirective, selector: "[simpoCorner]", inputs: ["simpoCorner"] }, { kind: "directive", type: HoverDirective, selector: "[simpoHover]", outputs: ["hovering"] }, { kind: "directive", type: OverlayDirective, selector: "[simpoOverlay]", inputs: ["simpoOverlay"] }, { kind: "directive", type: ObjectPositionDirective, selector: "[simpoObjectPosition]", inputs: ["simpoObjectPosition"] }, { kind: "directive", type: ContentTitleDirective, selector: "[simpoContentTitleSpace]", inputs: ["simpoContentTitleSpace"] }, { kind: "directive", type: ImageEditorDirective, selector: "[appImageEditor]", inputs: ["appImageEditor", "imageData", "sectionId", "showIcon", "iconData", "itemIndex"] }, { kind: "directive", type: SpacingHorizontalDirective, selector: "[spacingHorizontal]", inputs: ["spacingHorizontal", "isHeader"] }, { kind: "component", type: MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: ImageGridSectionComponent, decorators: [{
            type: Component,
            args: [{ selector: 'simpo-image-grid-section', standalone: true, imports: [
                        SimpoElementsModule,
                        CommonModule,
                        ColumnDirectiveDirective,
                        ImageDirectiveDirective,
                        ContentFitDirective,
                        SimpoComponentModule,
                        TextEditorComponent,
                        //directive
                        AnimationDirective,
                        BackgroundDirective,
                        BannerContentFitDirective,
                        BorderDirective,
                        ButtonDirectiveDirective,
                        ColumnDirectiveDirective,
                        ContainerFitDirective,
                        simpoConetenAlignmentDirective,
                        ContentFitDirective,
                        CornerDirective,
                        SimpoFooterLayoutDirective,
                        HoverDirective,
                        ImageDirectiveDirective,
                        OverlayDirective,
                        PositionLayoutDirectiveDirective,
                        TextBackgroundDirectiveDirective,
                        ObjectPositionDirective,
                        ContentTitleDirective,
                        ImageEditorDirective,
                        SpacingHorizontalDirective,
                        SimpoWrapComntainer,
                        MatIcon
                    ], template: "<section [id]=\"data?.id\" [simpoBackground]=\"style?.background\" simpoHover (hovering)=\"showEditTabs($event)\"\r\n  class=\"total-container\" [attr.style]=\"customClass\">\r\n  <div #mainContainer [id]=\"data?.id\" [simpoOverlay]=\"style?.background\" [spacingHorizontal]=\"stylesLayout\">\r\n    <div class=\"container-fluid\" [id]=\"data?.id\" [simpoBorder]=\"style?.border\" [simpoLayout]=\"style?.layout\">\r\n      <div class=\"row\" [id]=\"data?.id\" [simpoAnimation]=\"style?.animation\"\r\n        [ngStyle]=\"style?.fullWidth ? {'padding': '0px'} : {}\">\r\n        <div *ngFor=\"let text of data?.content?.inputText; let i = index\">\r\n          <div class=\"heading-large content-side\" [simpoContentTitleSpace]=\"headingSpace\">\r\n            <ng-container *ngIf=\"edit ||  (text.value && text.value.length > 0)\">\r\n              <simpo-text-editor [(value)]=\"text.value\" [editable]=\"edit || false\" [sectionId]=\"data?.id\" [inputTextIndex]=\"i\" [isRTE]=\"text.isRTE\"></simpo-text-editor>\r\n            </ng-container>\r\n          </div>\r\n        </div>\r\n\r\n        <ng-container *ngIf=\"style?.gridStyle == 'Style1'\">\r\n          <button class=\"scroll-btn left p-0 d-flex align-items-center justify-content-center\"\r\n            *ngIf=\"style?.direction === 'ROW' && isOverflowing\" (click)=\"scrollLeft()\"\r\n            [disabled]=\"atStart\"><mat-icon>keyboard_arrow_left</mat-icon>\r\n          </button>\r\n          <div class=\"main-image-section d-flex position-relative\" [class.row]=\"style?.direction == 'ROW' \"\r\n            [class.wrap-scroll]=\"style?.direction == 'ROW'\" [class.flex-wrap]=\"style?.direction == 'COLUMN'\"\r\n            [class.mobile-two-columns]=\"style?.direction == 'COLUMN' && style?.mobileColumn == 2\" [id]=\"data?.id\"\r\n            #imagegrid [style.justifyContent]=\"getJustifyContent()\" (scroll)=\"onScroll()\">\r\n            <div class=\"image-section p-md-3 p-2\" *ngFor=\"let img of content?.listItem?.data; let i = index\"\r\n              [simpoColumnDirective]=\"style?.size\" [id]=\"data?.id\"\r\n              [attr.style]=\"style?.removeGaps ? 'padding: 0px !important; margin: 0px !important;' : {}\">\r\n              <img loading=\"lazy\" [simpoImageDirective]=\"style?.image\" [simpoCorner]=\"style?.corners\" [id]=\"data?.id\"\r\n                [class]=\"data?.id+img.image.id\" [simpoObjectPosition]=\"img.image.position\" [src]=\"img.image.url\"\r\n                [alt]=\"img.image.altText\" loading=\"lazy\" [appImageEditor]=\"edit || false\" [imageData]=\"img?.image\"\r\n                [sectionId]=\"data?.id\" [itemIndex]=\"i\" class=\"w-100\" />\r\n            </div>\r\n          </div>\r\n          <button class=\"scroll-btn right p-0 d-flex align-items-center justify-content-center\"\r\n            *ngIf=\"style?.direction === 'ROW' && isOverflowing\" (click)=\"scrollRight()\"\r\n            [disabled]=\"atEnd\"><mat-icon>keyboard_arrow_right</mat-icon>\r\n          </button>\r\n\r\n        </ng-container>\r\n        <ng-container *ngIf=\"style?.gridStyle == 'Style2'\">\r\n          <div class=\"grid h-100\" [class.remove-gap]=\"style?.removeGaps\" [class.p-0]=\"style?.fullWidth\">\r\n            <ng-container *ngFor=\"let img of content?.listItem?.data; let i = index\">\r\n              <img loading=\"lazy\" [simpoImageDirective]=\"style?.image\" [simpoCorner]=\"style?.corners\" [id]=\"data?.id\"\r\n                [class]=\"data?.id+img.image.id\" [simpoObjectPosition]=\"img.image.position\" [src]=\"img.image.url\"\r\n                [alt]=\"img.image.altText\" loading=\"lazy\" [appImageEditor]=\"edit || false\" [imageData]=\"img?.image\"\r\n                [sectionId]=\"data?.id\" [itemIndex]=\"i\" class=\"w-100\" />\r\n            </ng-container>\r\n          </div>\r\n\r\n\r\n        </ng-container>\r\n      </div>\r\n    </div>\r\n  </div>\r\n  <ng-container *ngIf=\"style?.devider?.display\">\r\n    <simpo-svg-divider [dividerType]=\"style?.devider?.deviderType\"\r\n      [color]=\"nextComponentColor?.color\"></simpo-svg-divider>\r\n  </ng-container>\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</section>", styles: [".total-container{height:auto;position:relative}.main-image-section{margin-bottom:1.5rem}.mb-1{margin-bottom:1.5rem!important}.hover_effect{position:unset;width:100%;top:0;left:0;height:100%}.wrap-scroll{overflow:scroll;flex-wrap:nowrap}@media screen and (min-width : 1200px){.grid{display:grid;grid-template-columns:1fr 1fr;grid-auto-rows:auto;grid-gap:5px}.grid img:first-child:last-child{grid-column:1 / span 2}.grid img:first-child:nth-last-child(2),.grid img:nth-child(2):last-child{grid-column:span 1;height:100%}.grid img:nth-child(3n+1):not(:last-child){grid-column:1;grid-row:span 2;height:100%}.grid img:nth-child(3n+2){grid-column:2}.grid img:nth-child(3n+3){grid-column:2;align-self:end}.grid img:nth-child(3n+4){grid-column:1 / span 2}}.remove-gap{grid-gap:0!important}@media screen and (min-width: 760px){.cards{padding-bottom:24px}}.main-image-container{width:100%}@media screen and (max-width: 760px){.scroll-btn{display:none!important}.mobile-two-columns{display:grid!important;grid-template-columns:1fr 1fr;grid-auto-rows:auto;grid-gap:5px;padding:0!important}}.right-column-container{display:flex;flex-direction:column;height:100%;padding:0}.image-half-height{height:50%!important;flex:1}.image-half-height:first-child{margin-bottom:2px}.scroll-btn{position:absolute;top:50%;z-index:10;font-size:18px;width:36px!important;height:36px!important;border-radius:50%;border:none}.scroll-btn.left{left:8px}.scroll-btn.right{right:8px}\n"] }]
        }], ctorParameters: () => [{ type: i1.EventsService }], propDecorators: { imagegrid: [{
                type: ViewChild,
                args: ['imagegrid', { static: false }]
            }], data: [{
                type: Input
            }], index: [{
                type: Input
            }], edit: [{
                type: Input
            }], customClass: [{
                type: Input
            }], delete: [{
                type: Input
            }], nextComponentColor: [{
                type: Input
            }], _mainContainer: [{
                type: ViewChild,
                args: ['mainContainer']
            }] } });
//# sourceMappingURL=data:application/json;base64, 