import * as i0 from '@angular/core';
import { Component, inject, Injectable } from '@angular/core';
import { DialogComponent, DialogService } from '@seniorsistemas/angular-components/dialog';
import * as i1 from '@seniorsistemas/angular-components/template';
import { TemplateModule } from '@seniorsistemas/angular-components/template';
import * as i2 from '@seniorsistemas/angular-components/button';
import { ButtonModule } from '@seniorsistemas/angular-components/button';
import { take } from 'rxjs';

class PopupConfirmDialogComponent {
    confirmDialog;
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PopupConfirmDialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
    static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.14", type: PopupConfirmDialogComponent, isStandalone: true, selector: "ng-component", ngImport: i0, template: "@if (confirmDialog) {\n    <s-dialog [header]=\"confirmDialog.header\">\n        <div class=\"grid grid-cols-12\">\n            <div class=\"col-span-12\">\n                {{ confirmDialog.message }}\n            </div>\n        </div>\n        <ng-template\n            sTemplate=\"footer\"\n            let-activeDialog=\"activeDialog\"\n        >\n            <div class=\"grid grid-cols-12\">\n                <div class=\"col-span-12 flex flex-wrap justify-end gap-3\">\n                    @if (confirmDialog.rejectLabel) {\n                        <s-button\n                            [label]=\"confirmDialog.rejectLabel\"\n                            (clicked)=\"activeDialog.close(false)\"\n                            label=\"A\u00E7\u00E3o secund\u00E1ria\"\n                            priority=\"link\"\n                        />\n                    }\n                    <s-button\n                        [label]=\"confirmDialog.acceptLabel\"\n                        (clicked)=\"activeDialog.close(true)\"\n                        priority=\"primary\"\n                    />\n                </div>\n            </div>\n        </ng-template>\n    </s-dialog>\n}\n", dependencies: [{ kind: "component", type: DialogComponent, selector: "s-dialog", inputs: ["header", "visible", "size", "contentClassName", "escapeOnEsc", "destroyClickOutside"], outputs: ["visibleChange"] }, { kind: "ngmodule", type: TemplateModule }, { kind: "directive", type: i1.TemplateDirective, selector: "[sTemplate]", inputs: ["sTemplate"] }, { kind: "ngmodule", type: ButtonModule }, { kind: "component", type: i2.ButtonComponent, selector: "s-button", inputs: ["id", "label", "tooltip", "tooltipPosition", "iconClass", "rightIconClass", "caret", "styleClass", "baseZIndex", "disabled", "auxiliary", "type", "priority", "menuOptions", "size", "slide", "animation", "badge", "iconColor"], outputs: ["clicked"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: PopupConfirmDialogComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [DialogComponent, TemplateModule, ButtonModule], template: "@if (confirmDialog) {\n    <s-dialog [header]=\"confirmDialog.header\">\n        <div class=\"grid grid-cols-12\">\n            <div class=\"col-span-12\">\n                {{ confirmDialog.message }}\n            </div>\n        </div>\n        <ng-template\n            sTemplate=\"footer\"\n            let-activeDialog=\"activeDialog\"\n        >\n            <div class=\"grid grid-cols-12\">\n                <div class=\"col-span-12 flex flex-wrap justify-end gap-3\">\n                    @if (confirmDialog.rejectLabel) {\n                        <s-button\n                            [label]=\"confirmDialog.rejectLabel\"\n                            (clicked)=\"activeDialog.close(false)\"\n                            label=\"A\u00E7\u00E3o secund\u00E1ria\"\n                            priority=\"link\"\n                        />\n                    }\n                    <s-button\n                        [label]=\"confirmDialog.acceptLabel\"\n                        (clicked)=\"activeDialog.close(true)\"\n                        priority=\"primary\"\n                    />\n                </div>\n            </div>\n        </ng-template>\n    </s-dialog>\n}\n" }]
        }] });

class ConfirmDialogService {
    dialogService = inject(DialogService);
    confirm(confirmDialog) {
        const dialogRef = this.dialogService.open(PopupConfirmDialogComponent);
        dialogRef.componentInstance.confirmDialog = confirmDialog;
        dialogRef.closed.pipe(take(1)).subscribe((response) => {
            if (response) {
                confirmDialog.accept();
            }
            else if (!response && confirmDialog.reject) {
                confirmDialog.reject();
            }
        });
        dialogRef.dismissed.pipe(take(1)).subscribe(() => {
            if (confirmDialog.reject) {
                confirmDialog.reject();
            }
        });
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
    static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmDialogService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.14", ngImport: i0, type: ConfirmDialogService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

/**
 * Generated bundle index. Do not edit.
 */

export { ConfirmDialogService };
//# sourceMappingURL=seniorsistemas-angular-components-confirm-dialog.mjs.map
