import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { AXPSessionService } from '@acorex/platform/auth';
import { AXPEntityStorageService } from '@acorex/platform/layout/entity';

const LEAVE_REQUEST_ENTITY = 'HumanCapitalManagement.LeaveRequest';
/**
 * Assign To Manager Activity (Backend - Mock)
 *
 * Assigns a workflow task to a manager. Outputs managerId and employee into workflow variables
 * so later steps can use {{vars.employee.displayName}} etc.
 *
 * Execution Mode: backend
 * Activity Type: workflow-activity:assign-to-manager
 */
class AssignToManggerActivity {
    constructor() {
        this.sessionService = inject(AXPSessionService);
        this.entityStorage = inject(AXPEntityStorageService);
    }
    async execute(input) {
        const leaveRequestId = input?.leaveRequestId ?? input?.properties?.leaveRequestId;
        const managerId = this.sessionService.user?.id ?? null;
        let employee = { displayName: '' };
        if (leaveRequestId) {
            try {
                const record = await this.entityStorage.getOne(LEAVE_REQUEST_ENTITY, leaveRequestId);
                if (record) {
                    employee = {
                        displayName: record.employeeName ??
                            record.employee?.person?.displayName ??
                            record.employee?.displayName ??
                            '',
                        ...(record.employee ?? {}),
                    };
                }
            }
            catch {
                // keep default employee
            }
        }
        console.log('[AssignToManggerActivity] leaveRequestId:', leaveRequestId, 'managerId:', managerId, 'employee:', employee);
        return {
            success: true,
            data: {
                outcomes: { done: true },
                output: {
                    managerId,
                    employee,
                    leaveRequestId,
                },
            },
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssignToManggerActivity, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssignToManggerActivity, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AssignToManggerActivity, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { AssignToManggerActivity };
//# sourceMappingURL=acorex-connectivity-mock-assign-to-manager.command-CzzTHBVX.mjs.map
