import { DrawerService } from '@masterteam/components/dynamic-drawer';
import { DialogService } from '@masterteam/components/dialog';
import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { Directionality } from '@angular/cdk/bidi';

class ModalService {
    drawerService = inject(DrawerService);
    dialogService = inject(DialogService);
    dir = inject(Directionality, { optional: true });
    footerClass = 'mt-modal-footer';
    contentClass = 'mt-modal-content';
    modalConfig;
    openModal(component, modalType, config) {
        let ref;
        if (modalType === 'drawer') {
            config.position = this.handelStartEndPosition(config.position);
            console.log('Opening drawer with config:', config);
            ref = this.drawerService.open(component, config);
        }
        else {
            ref = this.dialogService.open(component, config);
        }
        return ref;
    }
    handelStartEndPosition(position) {
        if (position === 'start') {
            return this.dir?.value === 'rtl' ? 'right' : 'left';
        }
        else if (position === 'end') {
            return this.dir?.value === 'rtl' ? 'left' : 'right';
        }
        else {
            return position || 'right';
        }
    }
    static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: ModalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
    static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: ModalService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.3", ngImport: i0, type: ModalService, decorators: [{
            type: Injectable,
            args: [{ providedIn: 'root' }]
        }] });

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

export { ModalService };
//# sourceMappingURL=masterteam-components-modal.mjs.map
