import { AXDialogService } from '@acorex/components/dialog';
import { AXLoadingDialogService } from '@acorex/components/loading-dialog';
import { AXTranslationService } from '@acorex/core/translation';
import { AXPEntityDefinitionRegistryService, AXPEntityService } from '@acorex/platform/layout/entity';
import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { RootConfig } from './acorex-modules-security-management.mjs';

class AXPTerminateSessionCommand {
    constructor() {
        this.entityResolver = inject(AXPEntityDefinitionRegistryService);
        this.translationService = inject(AXTranslationService);
        this.dialogService = inject(AXDialogService);
        this.loadingDialog = inject(AXLoadingDialogService);
        this.entityService = inject(AXPEntityService);
        this.deviceSessionsDataAccessor = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.deviceSessions.name)
            .data();
    }
    async execute(input) {
        // const context = input.__context__;
        // const moduleEntity = context.getVariable('entity');
        // const [moduleName, entityName] = moduleEntity.split('.');
        // const data = context.data;
        // const meta = context.metaData;
        // const ids = Array.isArray(data) ? data.map((c) => c.id) : [data.id];
        // const entity = await this.entityResolver.resolve(moduleName, entityName);
        // if (entity.parentKey && data[entity.parentKey]) {
        //   context.setVariable('meta', { ...meta, refreshTargetId: data[entity.parentKey] });
        // }
        // context.setVariable('terminateSuccessful', false);
        // const dialog = this.loadingDialog.show({
        //   title: await this.translationService.translateAsync('workflow.terminating'),
        //   mode: 'determinate',
        //   status: 'Terminating...',
        //   progressValue: 0,
        //   text: `0/${ids.length}`,
        //   buttons: [
        //     {
        //       text: await this.translationService.translateAsync('cancel'),
        //       color: 'danger',
        //       onClick: () => {
        //         dialog.close();
        //       },
        //     },
        //   ],
        // });
        //   const terminateExec = this.dataService.;
        //   let faildCounter = 0;
        //   for (const element of ids) {
        //     const res = await terminateExec(element);
        //     if (!res) {
        //       faildCounter++;
        //       await this.dialogService.alert(
        //         await this.translationService.translateAsync('workflow.fail-delete-title'),
        //         await this.translationService.translateAsync('workflow.fail-delete-body', {
        //           params: { item: 1 },
        //         }),
        //         'danger',
        //       );
        //     }
        //   }
        //   context.setOutput('result', faildCounter == 0 ? true : false);
        //   setTimeout(() => {
        //     dialog.close();
        //     this.dispatch(AXPRefreshEvent({ entity: moduleEntity, meta: context.getVariable<any>('meta') }));
        //   }, 300);
        return {
            success: false,
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXPTerminateSessionCommand, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXPTerminateSessionCommand, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXPTerminateSessionCommand, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { AXPTerminateSessionCommand };
//# sourceMappingURL=acorex-modules-security-management-terminate-session.command-CJ7oe0xA.mjs.map
