import { AXPSystemStatuses, AXPStatusProvider, systemStatusToDefinition, AXPSystemStatusType, AXP_STATUS_PROVIDERS, AXP_MENU_PROVIDER } from '@acorex/platform/common';
import { AXPTaskBadgeProvider, AXPResourceAppointmentBoardProvider, AXP_TASK_BADGE_PROVIDERS, AXP_RESOURCE_APPOINTMENT_PROVIDER } from '@acorex/platform/layout/components';
import { AXPEntityService, AXP_ENTITY_CONFIG_TOKEN, AXP_ENTITY_DEFINITION_LOADER } from '@acorex/platform/layout/entity';
import { AXPCommandEventsService, AXPCommandExecutor, AXPRuntimeModule, provideCommandSetups } from '@acorex/platform/runtime';
import * as i0 from '@angular/core';
import { inject, DestroyRef, signal, Injectable, input, computed, ViewEncapsulation, ChangeDetectionStrategy, Component, Injector, NgModule } from '@angular/core';
import { AXPLayoutBuilderService } from '@acorex/platform/layout/builder';
import * as i4 from '@acorex/core/translation';
import { AXTranslationService, AXTranslationModule } from '@acorex/core/translation';
import * as i1 from '@acorex/components/button';
import { AXButtonModule } from '@acorex/components/button';
import * as i2 from '@acorex/components/decorators';
import { AXDecoratorModule } from '@acorex/components/decorators';
import * as i3 from '@angular/common';
import { CommonModule } from '@angular/common';
import { AXPCommonMenuKeys, AXP_RESOURCE_APPOINTMENT_PAGE_CONFIG } from '@acorex/modules/common';
import { AXP_IDENTIFIER_RULES } from '@acorex/modules/identifier-management';
import { AXPSessionService, AXPAuthGuard, AXP_PERMISSION_DEFINITION_PROVIDER } from '@acorex/platform/auth';
import { AXP_MODULE_MANIFEST_PROVIDER, AXP_FEATURE_DEFINITION_PROVIDER } from '@acorex/platform/core';
import { ROUTES } from '@angular/router';
import { firstValueFrom } from 'rxjs';

const config = {
    i18n: 'human-capital-management',
    module: 'HumanCapitalManagement',
};
const RootConfig = {
    config,
    module: {
        route: 'human-capital-management',
        name: config.module,
        title: '@human-capital-management:module.title',
        icon: 'fa-light fa-users',
    },
    entities: {
        employee: {
            name: 'Employee',
            source: `${config.module}.Employee`,
            title: '@human-capital-management:employees.entities.employee.title',
            titlePlural: '@human-capital-management:employees.entities.employee.plural',
            icon: 'fa-light fa-address-card',
        },
        employmentType: {
            name: 'EmploymentType',
            source: `${config.module}.EmploymentType`,
            title: '@human-capital-management:employment-types.entities.employment-type.title',
            titlePlural: '@human-capital-management:employment-types.entities.employment-type.plural',
            icon: 'fa-light fa-file-signature',
        },
        positionAssignment: {
            name: 'PositionAssignment',
            source: `${config.module}.PositionAssignment`,
            title: '@human-capital-management:position-assignments.entities.position-assignment.title',
            titlePlural: '@human-capital-management:position-assignments.entities.position-assignment.plural',
            icon: 'fa-light fa-user-tie-hair',
        },
        leaveType: {
            name: 'LeaveType',
            source: `${config.module}.LeaveType`,
            title: '@human-capital-management:leave-types.entities.leave-type.title',
            titlePlural: '@human-capital-management:leave-types.entities.leave-type.plural',
            icon: 'fa-light fa-calendar-days',
        },
        leaveRequest: {
            name: 'LeaveRequest',
            source: `${config.module}.LeaveRequest`,
            title: '@human-capital-management:leave-requests.entities.leave-request.title',
            titlePlural: '@human-capital-management:leave-requests.entities.leave-request.plural',
            icon: 'fa-light fa-plane-departure',
        },
    },
    pages: {
        appointmentBoard: {
            path: 'Boards/ResourceAppointment',
            title: '@human-capital-management:leave-requests.menus.appointment-board.title',
            icon: 'fa-light fa-calendar-lines',
        },
    },
};

// Entity exports - services and modules removed, handled by middleware
// Exporting entity types for use in feature components

//#endregion
//#region ----   Task Badge Provider   ----
class AXMLeaveRequestBadgeProvider extends AXPTaskBadgeProvider {
    //#endregion
    constructor() {
        super();
        //#region ----   Services & Dependencies   ----
        this.entityService = inject(AXPEntityService);
        this.leaveRequestData = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.leaveRequest.name)
            .data();
        this.commandEvents = inject(AXPCommandEventsService);
        this.destroyRef = inject(DestroyRef);
        //#endregion
        //#region ----   Signals & Properties   ----
        this.key = 'leave-request-badge';
        this.count = signal(0, ...(ngDevMode ? [{ debugName: "count" }] : []));
        void this.refresh();
        const unsubscribe = this.commandEvents.listen((event) => this.handleCommandEvent(event));
        this.destroyRef.onDestroy(unsubscribe);
    }
    //#region ----   Badge Actions   ----
    /**
     * Forces badge count recalculation by querying the leave request entity service.
     */
    async refresh() {
        const baseFilters = [
            {
                field: 'statusId',
                operator: { type: 'equal' },
                value: AXPSystemStatuses.Pending.name,
            },
        ];
        const result = await this.leaveRequestData.query({
            skip: 0,
            take: 99,
            filter: {
                logic: 'and',
                filters: baseFilters,
            },
        });
        this.count.set(result.total);
    }
    /**
     * Handles command execution events and refreshes the badge when targeted leave request commands succeed.
     */
    async handleCommandEvent(event) {
        if (!event || event.stage !== 'after' || !event.success) {
            return;
        }
        await this.refresh();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestBadgeProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestBadgeProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestBadgeProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [] });

class AXMLeaveRequestResourceAppointmentProvider extends AXPResourceAppointmentBoardProvider {
    constructor() {
        super(...arguments);
        this.entityService = inject(AXPEntityService);
    }
    get name() {
        return 'leave-request';
    }
    get title() {
        return '@human-capital-management:leave-requests.entities.leave-request.plural';
    }
    get icon() {
        return RootConfig.entities.leaveRequest.icon;
    }
    async getList(filter) {
        const leaveRequestDataAccessor = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.leaveRequest.name)
            .data();
        const employeeDataAccessor = this.entityService
            .withEntity(RootConfig.module.name, RootConfig.entities.employee.name)
            .data();
        const fieldFilters = [];
        if (filter?.range?.from) {
            fieldFilters.push({
                field: 'startDate',
                operator: { type: 'gte' },
                value: filter.range.from,
            });
        }
        if (filter?.range?.end) {
            fieldFilters.push({
                field: 'endDate',
                operator: { type: 'lte' },
                value: filter.range.end,
            });
        }
        const employee = await employeeDataAccessor.query();
        const { items } = await leaveRequestDataAccessor.query({
            skip: 0,
            take: 1000,
            ...(fieldFilters.length
                ? {
                    filter: {
                        logic: 'and',
                        filters: fieldFilters,
                    },
                }
                : {}),
        });
        const result = employee.items.map((employee) => ({
            id: employee.id,
            title: employee.person?.displayName ?? '',
            description: 'description', //TODO fill later
            icon: 'icon',
            appointments: items
                .filter((item) => item.employeeId === employee.id)
                .map((item) => ({
                id: item.id,
                title: item.leaveType?.title ?? '',
                startDate: item.startDate,
                endDate: item.endDate,
                resourceId: item.employeeId,
                description: item.reason,
                allDay: false,
            })),
        }));
        return result;
        // const resourcesMap = new Map<string | number, AXPResourceAppointmentResource>();
        // for (const leave of items) {
        //   const resourceId: string | number = leave.employeeId ?? 'unassigned';
        //   let resource = resourcesMap.get(resourceId);
        //   if (!resource) {
        //     resource = {
        //       id: resourceId,
        //       title: leave.employee?.person?.displayName ?? '@general:terms.people.employee',
        //       appointments: [],
        //     };
        //     resourcesMap.set(resourceId, resource);
        //   }
        //   const task: AXPResourceAppointmentItem = {
        //     id: leave.id,
        //     title: leave.leaveType?.title ?? '@human-capital-management:leave-requests.entities.leave-request.title',
        //     description: leave.reason,
        //     startDate: leave.startDate,
        //     endDate: leave.endDate,
        //     allDay: false,
        //     resourceId,
        //   };
        //   resource.appointments.push(task);
        // }
        // return Array.from(resourcesMap.values());
    }
    async getStatuses() {
        const pending = AXPSystemStatuses.Pending;
        const approved = AXPSystemStatuses.Approved;
        const rejected = AXPSystemStatuses.Rejected;
        const cancelled = AXPSystemStatuses.Cancelled;
        const statuses = [
            { key: pending.name, index: 0, title: pending.title, color: pending.color },
            { key: approved.name, index: 1, title: approved.title, color: approved.color },
            { key: rejected.name, index: 2, title: rejected.title, color: rejected.color },
            { key: cancelled.name, index: 3, title: cancelled.title, color: cancelled.color },
        ];
        return statuses;
    }
    async getActions(
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    context) {
        // Actions can be wired to existing approve/reject/cancel commands later.
        // For now, return an empty list so the board works without a context menu.
        return [];
    }
    async executeCommand(
    // eslint-disable-next-line @typescript-eslint/no-unused-vars
    command) {
        // No-op for now – commands are handled by existing leave request commands elsewhere.
        return { success: true };
    }
}

class AXPLeaveRequestDialogService {
    constructor() {
        this.layoutBuilder = inject(AXPLayoutBuilderService);
        this.translationService = inject(AXTranslationService);
    }
    async showRejectionDialog() {
        const result = await this.layoutBuilder
            .create()
            .dialog(dialog => {
            dialog
                .setTitle('@general:actions.reject.title')
                .setMessage('@human-capital-management:leave-requests.components.rejection-dialog.message')
                .setContext({ reason: '', note: '' })
                .content(flex => {
                flex
                    .setDirection('column')
                    .formField('@human-capital-management:leave-requests.components.rejection-dialog.fields.reason-label', field => {
                    field.path('reason');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-requests.components.rejection-dialog.fields.reason-placeholder',
                        maxLength: 500
                    });
                })
                    .formField('@human-capital-management:leave-requests.components.rejection-dialog.fields.note-label', field => {
                    field.path('note');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-requests.components.rejection-dialog.fields.note-placeholder',
                        maxLength: 1000
                    });
                });
            })
                .setActions(actions => {
                actions.cancel('@general:actions.cancel.title').submit('@general:actions.reject.title');
            })
                .onAction(async (dialogRef) => {
                const context = dialogRef.context();
                const action = dialogRef.action();
                if (!context || action === 'cancel') {
                    return { reason: undefined, note: undefined, cancelled: true };
                }
                return {
                    reason: context['reason'],
                    note: context['note'],
                    cancelled: false
                };
            });
        })
            .show();
        return result;
    }
    async showCancellationDialog() {
        const result = await this.layoutBuilder
            .create()
            .dialog(dialog => {
            dialog
                .setTitle('@general:actions.cancel.title')
                .setMessage('@human-capital-management:leave-requests.components.cancellation-dialog.message')
                .setContext({ reason: '', note: '' })
                .content(flex => {
                flex
                    .setDirection('column')
                    .formField('@human-capital-management:leave-requests.components.cancellation-dialog.fields.reason-label', field => {
                    field.path('reason');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-requests.components.cancellation-dialog.fields.reason-placeholder',
                        maxLength: 500
                    });
                })
                    .formField('@human-capital-management:leave-requests.components.cancellation-dialog.fields.note-label', field => {
                    field.path('note');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-requests.components.cancellation-dialog.fields.note-placeholder',
                        maxLength: 1000
                    });
                });
            })
                .setActions(actions => {
                actions.cancel('@general:actions.close.title').submit('@general:actions.cancel.title');
            })
                .onAction(async (dialogRef) => {
                const context = dialogRef.context();
                const action = dialogRef.action();
                if (!context || action === 'cancel') {
                    return { reason: undefined, note: undefined, cancelled: true };
                }
                return {
                    reason: context['reason'],
                    note: context['note'],
                    cancelled: false
                };
            });
        })
            .show();
        return result;
    }
    async showApprovalDialog() {
        const result = await this.layoutBuilder
            .create()
            .dialog(dialog => {
            dialog
                .setTitle('@general:actions.approve.title')
                .setMessage('@human-capital-management:leave-requests.components.approval-dialog.message')
                .setContext({ note: '' })
                .content(flex => {
                flex
                    .setDirection('column')
                    .formField('@human-capital-management:leave-requests.components.approval-dialog.fields.note-label', field => {
                    field.path('note');
                    field.largeTextBox({
                        placeholder: '@human-capital-management:leave-requests.components.approval-dialog.fields.note-placeholder',
                        maxLength: 1000
                    });
                });
            })
                .setActions(actions => {
                actions.cancel('@general:actions.cancel.title').submit('@general:actions.approve.title');
            })
                .onAction(async (dialogRef) => {
                const context = dialogRef.context();
                const action = dialogRef.action();
                if (!context || action === 'cancel') {
                    return { note: undefined, cancelled: true };
                }
                return {
                    note: context['note'],
                    cancelled: false
                };
            });
        })
            .show();
        return result;
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXPLeaveRequestDialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXPLeaveRequestDialogService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXPLeaveRequestDialogService, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root'
                }]
        }] });

class AXMLeaveRequestTaskPopoverComponent {
    constructor() {
        this.task = input.required(...(ngDevMode ? [{ debugName: "task" }] : []));
        this.commandExecutor = inject(AXPCommandExecutor);
        this.dialogService = inject(AXPLeaveRequestDialogService);
        this.taskData = computed(() => {
            const task = this.task();
            return (task.data ||
                task.payload);
        }, ...(ngDevMode ? [{ debugName: "taskData" }] : []));
        this.employeeName = computed(() => {
            const data = this.taskData();
            return data?.employee?.person?.displayName || this.task().reporter?.fullName || 'Unknown';
        }, ...(ngDevMode ? [{ debugName: "employeeName" }] : []));
        this.managerName = computed(() => {
            const data = this.taskData();
            return data?.employee?.manager?.person?.displayName || this.task().assignee?.fullName || '';
        }, ...(ngDevMode ? [{ debugName: "managerName" }] : []));
        this.leaveType = computed(() => {
            const data = this.taskData();
            // Extract leave type from task title or data
            const title = this.task().title || '';
            const parts = title.split(' - ');
            return parts.length > 1 ? parts[1] : data?.leaveType?.title || 'N/A';
        }, ...(ngDevMode ? [{ debugName: "leaveType" }] : []));
        this.canApprove = computed(() => {
            const statusId = this.task().status?.id;
            return statusId === AXPSystemStatuses.Pending.name || statusId === AXPSystemStatuses.Rejected.name;
        }, ...(ngDevMode ? [{ debugName: "canApprove" }] : []));
        this.canReject = computed(() => {
            const statusId = this.task().status?.id;
            return statusId === AXPSystemStatuses.Pending.name || statusId === AXPSystemStatuses.Approved.name;
        }, ...(ngDevMode ? [{ debugName: "canReject" }] : []));
        this.canCancel = computed(() => {
            const statusId = this.task().status?.id;
            return statusId === AXPSystemStatuses.Pending.name || statusId === AXPSystemStatuses.Approved.name;
        }, ...(ngDevMode ? [{ debugName: "canCancel" }] : []));
    }
    formatDate(date) {
        return new Intl.DateTimeFormat('en-US', {
            year: 'numeric',
            month: 'short',
            day: 'numeric',
        }).format(new Date(date));
    }
    calculateDuration() {
        const start = new Date(this.task().startDate);
        const end = new Date(this.task().endDate);
        const diffTime = Math.abs(end.getTime() - start.getTime());
        const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
        return diffDays + 1; // Include both start and end days
    }
    async handleApprove() {
        const task = this.task();
        const leaveRequestId = task.id;
        try {
            const dialogResult = await this.dialogService.showApprovalDialog();
            if (dialogResult?.cancelled) {
                return;
            }
            const commandKey = 'HumanCapitalManagement.LeaveRequest:Approve';
            const result = await this.commandExecutor.execute(commandKey, {
                id: leaveRequestId,
                reason: dialogResult?.reason,
                note: dialogResult?.note,
            });
            if (result?.success) {
                // Optionally emit an event or refresh the task
                console.log('Leave request approved successfully');
            }
        }
        catch (error) {
            console.error('Failed to approve leave request:', error);
        }
    }
    async handleReject() {
        const task = this.task();
        const leaveRequestId = task.id;
        try {
            const dialogResult = await this.dialogService.showRejectionDialog();
            if (dialogResult?.cancelled) {
                return;
            }
            const commandKey = 'HumanCapitalManagement.LeaveRequest:Reject';
            const result = await this.commandExecutor.execute(commandKey, {
                id: leaveRequestId,
                reason: dialogResult?.reason,
                note: dialogResult?.note,
            });
            if (result?.success) {
                console.log('Leave request rejected successfully');
            }
        }
        catch (error) {
            console.error('Failed to reject leave request:', error);
        }
    }
    async handleCancel() {
        const task = this.task();
        const leaveRequestId = task.id;
        try {
            const dialogResult = await this.dialogService.showCancellationDialog();
            if (dialogResult?.cancelled) {
                return;
            }
            const commandKey = 'HumanCapitalManagement.LeaveRequest:Cancel';
            const result = await this.commandExecutor.execute(commandKey, {
                id: leaveRequestId,
                reason: dialogResult?.reason,
                note: dialogResult?.note,
            });
            if (result?.success) {
                console.log('Leave request cancelled successfully');
            }
        }
        catch (error) {
            console.error('Failed to cancel leave request:', error);
        }
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestTaskPopoverComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.19", type: AXMLeaveRequestTaskPopoverComponent, isStandalone: true, selector: "axm-leave-request-task-popover", inputs: { task: { classPropertyName: "task", publicName: "task", isSignal: true, isRequired: true, transformFunction: null } }, ngImport: i0, template: `
    <div class="leave-request-popover">
      <!-- Employee Info -->
      <div class="leave-request-popover__section">
        <div class="leave-request-popover__section-header">
          <i class="fa-light fa-user"></i>
          <span>Employee Information</span>
        </div>
        <div class="leave-request-popover__section-content">
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Employee:</span>
            <span class="leave-request-popover__value">{{ employeeName() }}</span>
          </div>
          @if (managerName(); as manager) {
            <div class="leave-request-popover__info-row">
              <span class="leave-request-popover__label">Manager:</span>
              <span class="leave-request-popover__value">{{ manager }}</span>
            </div>
          }
        </div>
      </div>

      <!-- Leave Details -->
      <div class="leave-request-popover__section">
        <div class="leave-request-popover__section-header">
          <i class="fa-light fa-calendar"></i>
          <span>Leave Details</span>
        </div>
        <div class="leave-request-popover__section-content">
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Leave Type:</span>
            <span class="leave-request-popover__value">{{ leaveType() }}</span>
          </div>
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Start Date:</span>
            <span class="leave-request-popover__value">{{ formatDate(task().startDate) }}</span>
          </div>
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">End Date:</span>
            <span class="leave-request-popover__value">{{ formatDate(task().endDate) }}</span>
          </div>
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Duration:</span>
            <span class="leave-request-popover__value">{{ calculateDuration() }} days</span>
          </div>
        </div>
      </div>

      <!-- Reason -->
      @if (task().description) {
        <div class="leave-request-popover__section">
          <div class="leave-request-popover__section-header">
            <i class="fa-light fa-note-sticky"></i>
            <span>Reason</span>
          </div>
          <div class="leave-request-popover__section-content">
            <p class="leave-request-popover__reason">{{ task().description }}</p>
          </div>
        </div>
      }

      <!-- Status -->
      <div class="leave-request-popover__section">
        <div class="leave-request-popover__section-header">
          <i class="fa-light fa-flag"></i>
          <span>Status</span>
        </div>
        <div class="leave-request-popover__section-content">
          <div class="leave-request-popover__status-badge" [attr.data-status]="task().status.id">
            {{ task().status.title }}
          </div>
        </div>
      </div>

      <!-- Actions -->
      <div class="leave-request-popover__actions">
        @if (canApprove()) {
          <ax-button
            [color]="'success'"
            [look]="'blank'"
            [text]="'@general:actions.approve.title' | translate | async"
            (onClick)="handleApprove()"
            class="leave-request-popover__action-btn"
          >
            <ax-prefix>
              <i class="fa-light fa-check"></i>
            </ax-prefix>
          </ax-button>
        }

        @if (canReject()) {
          <ax-button
            [color]="'danger'"
            [look]="'blank'"
            [text]="'@general:actions.reject.title' | translate | async"
            (onClick)="handleReject()"
            class="leave-request-popover__action-btn"
          >
            <ax-prefix>
              <i class="fa-light fa-xmark"></i>
            </ax-prefix>
          </ax-button>
        }

        @if (canCancel()) {
          <ax-button
            [color]="'secondary'"
            [look]="'blank'"
            [text]="'@general:actions.cancel.title' | translate | async"
            (onClick)="handleCancel()"
            class="leave-request-popover__action-btn"
          >
            <ax-prefix>
              <i class="fa-light fa-ban"></i>
            </ax-prefix>
          </ax-button>
        }
      </div>
    </div>
  `, isInline: true, styles: [".leave-request-popover{padding:12px;display:flex;flex-direction:column;gap:10px;min-width:280px;max-width:360px}.leave-request-popover__section{display:flex;flex-direction:column;gap:6px}.leave-request-popover__section-header{display:flex;align-items:center;gap:6px;font-weight:600;font-size:13px;color:var(--ax-sys-color-text-primary);padding-bottom:6px;border-bottom:1px solid var(--ax-sys-color-border)}.leave-request-popover__section-header i{font-size:13px;color:var(--ax-sys-color-text-neutral-600)}.leave-request-popover__section-content{display:flex;flex-direction:column;gap:6px}.leave-request-popover__info-row{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;font-size:12px;line-height:1.4}.leave-request-popover__label{color:var(--ax-sys-color-text-neutral-600);font-weight:500;flex-shrink:0}.leave-request-popover__value{color:var(--ax-sys-color-text-primary);text-align:right;word-break:break-word}.leave-request-popover__reason{margin:0;padding:8px;background:var(--ax-sys-color-lighter-surface);border-radius:4px;font-size:12px;line-height:1.4;color:var(--ax-sys-color-text-primary)}.leave-request-popover__status-badge{display:inline-block;padding:3px 10px;border-radius:10px;font-size:11px;font-weight:500;text-transform:capitalize}.leave-request-popover__status-badge[data-status=pending]{background:var(--ax-sys-color-warning-lightest);color:var(--ax-sys-color-warning)}.leave-request-popover__status-badge[data-status=approved]{background:var(--ax-sys-color-success-lightest);color:var(--ax-sys-color-success)}.leave-request-popover__status-badge[data-status=rejected]{background:var(--ax-sys-color-danger-lightest);color:var(--ax-sys-color-danger)}.leave-request-popover__status-badge[data-status=cancelled]{background:var(--ax-sys-color-neutral-lightest);color:var(--ax-sys-color-neutral)}.leave-request-popover__actions{display:flex;gap:6px;flex-wrap:wrap;padding-top:8px;border-top:1px solid var(--ax-sys-color-border)}.leave-request-popover__action-btn{flex:1;min-width:90px}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: AXButtonModule }, { kind: "component", type: i1.AXButtonComponent, selector: "ax-button", inputs: ["disabled", "size", "tabIndex", "color", "look", "text", "toggleable", "selected", "iconOnly", "type", "loadingText"], outputs: ["onBlur", "onFocus", "onClick", "selectedChange", "toggleableChange", "lookChange", "colorChange", "disabledChange", "loadingTextChange"] }, { kind: "ngmodule", type: AXDecoratorModule }, { kind: "component", type: i2.AXDecoratorGenericComponent, selector: "ax-footer, ax-header, ax-content, ax-divider, ax-form-hint, ax-prefix, ax-suffix, ax-text, ax-title, ax-subtitle, ax-placeholder, ax-overlay" }, { kind: "ngmodule", type: AXTranslationModule }, { kind: "pipe", type: i3.AsyncPipe, name: "async" }, { kind: "pipe", type: i4.AXTranslatorPipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestTaskPopoverComponent, decorators: [{
            type: Component,
            args: [{ selector: 'axm-leave-request-task-popover', template: `
    <div class="leave-request-popover">
      <!-- Employee Info -->
      <div class="leave-request-popover__section">
        <div class="leave-request-popover__section-header">
          <i class="fa-light fa-user"></i>
          <span>Employee Information</span>
        </div>
        <div class="leave-request-popover__section-content">
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Employee:</span>
            <span class="leave-request-popover__value">{{ employeeName() }}</span>
          </div>
          @if (managerName(); as manager) {
            <div class="leave-request-popover__info-row">
              <span class="leave-request-popover__label">Manager:</span>
              <span class="leave-request-popover__value">{{ manager }}</span>
            </div>
          }
        </div>
      </div>

      <!-- Leave Details -->
      <div class="leave-request-popover__section">
        <div class="leave-request-popover__section-header">
          <i class="fa-light fa-calendar"></i>
          <span>Leave Details</span>
        </div>
        <div class="leave-request-popover__section-content">
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Leave Type:</span>
            <span class="leave-request-popover__value">{{ leaveType() }}</span>
          </div>
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Start Date:</span>
            <span class="leave-request-popover__value">{{ formatDate(task().startDate) }}</span>
          </div>
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">End Date:</span>
            <span class="leave-request-popover__value">{{ formatDate(task().endDate) }}</span>
          </div>
          <div class="leave-request-popover__info-row">
            <span class="leave-request-popover__label">Duration:</span>
            <span class="leave-request-popover__value">{{ calculateDuration() }} days</span>
          </div>
        </div>
      </div>

      <!-- Reason -->
      @if (task().description) {
        <div class="leave-request-popover__section">
          <div class="leave-request-popover__section-header">
            <i class="fa-light fa-note-sticky"></i>
            <span>Reason</span>
          </div>
          <div class="leave-request-popover__section-content">
            <p class="leave-request-popover__reason">{{ task().description }}</p>
          </div>
        </div>
      }

      <!-- Status -->
      <div class="leave-request-popover__section">
        <div class="leave-request-popover__section-header">
          <i class="fa-light fa-flag"></i>
          <span>Status</span>
        </div>
        <div class="leave-request-popover__section-content">
          <div class="leave-request-popover__status-badge" [attr.data-status]="task().status.id">
            {{ task().status.title }}
          </div>
        </div>
      </div>

      <!-- Actions -->
      <div class="leave-request-popover__actions">
        @if (canApprove()) {
          <ax-button
            [color]="'success'"
            [look]="'blank'"
            [text]="'@general:actions.approve.title' | translate | async"
            (onClick)="handleApprove()"
            class="leave-request-popover__action-btn"
          >
            <ax-prefix>
              <i class="fa-light fa-check"></i>
            </ax-prefix>
          </ax-button>
        }

        @if (canReject()) {
          <ax-button
            [color]="'danger'"
            [look]="'blank'"
            [text]="'@general:actions.reject.title' | translate | async"
            (onClick)="handleReject()"
            class="leave-request-popover__action-btn"
          >
            <ax-prefix>
              <i class="fa-light fa-xmark"></i>
            </ax-prefix>
          </ax-button>
        }

        @if (canCancel()) {
          <ax-button
            [color]="'secondary'"
            [look]="'blank'"
            [text]="'@general:actions.cancel.title' | translate | async"
            (onClick)="handleCancel()"
            class="leave-request-popover__action-btn"
          >
            <ax-prefix>
              <i class="fa-light fa-ban"></i>
            </ax-prefix>
          </ax-button>
        }
      </div>
    </div>
  `, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, imports: [CommonModule, AXButtonModule, AXDecoratorModule, AXTranslationModule], styles: [".leave-request-popover{padding:12px;display:flex;flex-direction:column;gap:10px;min-width:280px;max-width:360px}.leave-request-popover__section{display:flex;flex-direction:column;gap:6px}.leave-request-popover__section-header{display:flex;align-items:center;gap:6px;font-weight:600;font-size:13px;color:var(--ax-sys-color-text-primary);padding-bottom:6px;border-bottom:1px solid var(--ax-sys-color-border)}.leave-request-popover__section-header i{font-size:13px;color:var(--ax-sys-color-text-neutral-600)}.leave-request-popover__section-content{display:flex;flex-direction:column;gap:6px}.leave-request-popover__info-row{display:flex;justify-content:space-between;align-items:flex-start;gap:10px;font-size:12px;line-height:1.4}.leave-request-popover__label{color:var(--ax-sys-color-text-neutral-600);font-weight:500;flex-shrink:0}.leave-request-popover__value{color:var(--ax-sys-color-text-primary);text-align:right;word-break:break-word}.leave-request-popover__reason{margin:0;padding:8px;background:var(--ax-sys-color-lighter-surface);border-radius:4px;font-size:12px;line-height:1.4;color:var(--ax-sys-color-text-primary)}.leave-request-popover__status-badge{display:inline-block;padding:3px 10px;border-radius:10px;font-size:11px;font-weight:500;text-transform:capitalize}.leave-request-popover__status-badge[data-status=pending]{background:var(--ax-sys-color-warning-lightest);color:var(--ax-sys-color-warning)}.leave-request-popover__status-badge[data-status=approved]{background:var(--ax-sys-color-success-lightest);color:var(--ax-sys-color-success)}.leave-request-popover__status-badge[data-status=rejected]{background:var(--ax-sys-color-danger-lightest);color:var(--ax-sys-color-danger)}.leave-request-popover__status-badge[data-status=cancelled]{background:var(--ax-sys-color-neutral-lightest);color:var(--ax-sys-color-neutral)}.leave-request-popover__actions{display:flex;gap:6px;flex-wrap:wrap;padding-top:8px;border-top:1px solid var(--ax-sys-color-border)}.leave-request-popover__action-btn{flex:1;min-width:90px}\n"] }]
        }], propDecorators: { task: [{ type: i0.Input, args: [{ isSignal: true, alias: "task", required: true }] }] } });

const AXPHumanCapitalManagementFeatureKeys = {
    EmployeeManagement: 'HumanCapitalManagement:Feature:Employee.Management',
    LeaveManagement: 'HumanCapitalManagement:Feature:Leave.Management',
};

//#region ----   Imports   ----
//#endregion
//#region ----   Feature Definition Provider   ----
/**
 * Human Capital Management Feature Definition Provider.
 * Provides feature definitions for the Human Capital Management module.
 */
class AXPHumanCapitalManagementFeatureDefinitionProvider {
    async provide(context) {
        context.addFeature(AXPHumanCapitalManagementFeatureKeys.EmployeeManagement, {
            title: '@human-capital-management:features.employee-management.title',
            description: '@human-capital-management:features.employee-management.description',
            defaultValue: true,
            type: 'boolean',
        });
        context.addFeature(AXPHumanCapitalManagementFeatureKeys.LeaveManagement, {
            title: '@human-capital-management:features.leave-management.title',
            description: '@human-capital-management:features.leave-management.description',
            defaultValue: true,
            type: 'boolean',
        });
    }
}
//#endregion

class AXMHumanCapitalModuleEntityProvider {
    constructor() {
        this.injector = inject(Injector);
    }
    preload() {
        const module = RootConfig.module.name;
        return Array.from(Object.values(RootConfig.entities)).map((entity) => ({
            module: module,
            entity: entity.name,
        }));
    }
    async get(moduleName, entityName) {
        if (moduleName == RootConfig.module.name) {
            switch (entityName) {
                case RootConfig.entities.employee.name:
                    return (await import('./acorex-modules-human-capital-management-employee.entity-Dcv5nfxA.mjs')).factory();
                case RootConfig.entities.employmentType.name:
                    return (await import('./acorex-modules-human-capital-management-employment-type.entity-fZrfUpr6.mjs')).factory();
                case RootConfig.entities.positionAssignment?.name:
                    return (await import('./acorex-modules-human-capital-management-position-assignment.entity-P-IN-w_1.mjs')).factory();
                case RootConfig.entities.leaveType.name:
                    return (await import('./acorex-modules-human-capital-management-leave-type.entity-YitcNesR.mjs')).factory();
                case RootConfig.entities.leaveRequest.name:
                    return (await import('./acorex-modules-human-capital-management-leave-request.entity-CS3Fr_k2.mjs')).factory();
            }
        }
        return null;
    }
    async list() {
        const m = RootConfig.module.name;
        return Promise.resolve(Object.values(RootConfig.entities).map((e) => ({ name: e.name, module: m })));
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalModuleEntityProvider, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalModuleEntityProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalModuleEntityProvider, decorators: [{
            type: Injectable
        }] });

//#region ----   Imports   ----
//#endregion
//#region ----   Leave Request Status Provider   ----
/**
 * Leave request status provider defining lifecycle states: Pending, Approved, Rejected, Cancelled.
 * Used by the status plugin to manage leave request status transitions and metadata.
 */
class AXMLeaveRequestStatusProvider extends AXPStatusProvider {
    constructor() {
        super(...arguments);
        this.key = 'human-capital-management.status.leave-request';
        this.statuses = [
            systemStatusToDefinition(AXPSystemStatusType.Pending, {
                title: '@human-capital-management:leave-requests.states.pending',
                generateView: true,
            }),
            systemStatusToDefinition(AXPSystemStatusType.Approved, {
                title: '@human-capital-management:leave-requests.states.approved',
                generateView: true,
            }),
            systemStatusToDefinition(AXPSystemStatusType.Rejected, {
                title: '@human-capital-management:leave-requests.states.rejected',
                generateView: true,
            }),
            systemStatusToDefinition(AXPSystemStatusType.Cancelled, {
                title: '@human-capital-management:leave-requests.states.cancelled',
                generateView: true,
            }),
        ];
        this.transitions = [
            {
                from: AXPSystemStatusType.Pending,
                to: AXPSystemStatusType.Approved,
                title: '@general:statuses.transitions.approve',
                requiresApproval: true
            },
            {
                from: AXPSystemStatusType.Pending,
                to: AXPSystemStatusType.Rejected,
                title: '@general:statuses.transitions.reject',
                requiresApproval: true
            },
            {
                from: AXPSystemStatusType.Pending,
                to: AXPSystemStatusType.Cancelled,
                title: '@general:statuses.transitions.cancel',
                requiresApproval: true
            },
            {
                from: AXPSystemStatusType.Approved,
                to: AXPSystemStatusType.Cancelled,
                title: '@general:statuses.transitions.cancel',
                requiresApproval: true
            },
        ];
        this.defaultStatus = AXPSystemStatusType.Pending;
    }
}
//#endregion

class AXMLeaveRequestFeatureModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestFeatureModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestFeatureModule, imports: [CommonModule, AXPRuntimeModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestFeatureModule, providers: [
            {
                provide: AXP_TASK_BADGE_PROVIDERS,
                useClass: AXMLeaveRequestBadgeProvider,
                multi: true,
            },
            {
                provide: AXP_STATUS_PROVIDERS,
                useClass: AXMLeaveRequestStatusProvider,
                multi: true,
            },
            provideCommandSetups([
                {
                    key: 'HumanCapitalManagement.LeaveRequest:Approve',
                    command: () => import('./acorex-modules-human-capital-management-approve-leave-request.command-C7cEuryl.mjs').then((c) => c.ApproveLeaveRequestCommand),
                },
                {
                    key: 'HumanCapitalManagement.LeaveRequest:Reject',
                    command: () => import('./acorex-modules-human-capital-management-reject-leave-request.command-Dg45oY0X.mjs').then((c) => c.RejectLeaveRequestCommand),
                },
                {
                    key: 'HumanCapitalManagement.LeaveRequest:Cancel',
                    command: () => import('./acorex-modules-human-capital-management-cancel-leave-request.command-iGNY2Pxh.mjs').then((c) => c.CancelLeaveRequestCommand),
                },
            ]),
        ], imports: [CommonModule, AXPRuntimeModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMLeaveRequestFeatureModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule, AXPRuntimeModule],
                    providers: [
                        {
                            provide: AXP_TASK_BADGE_PROVIDERS,
                            useClass: AXMLeaveRequestBadgeProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_STATUS_PROVIDERS,
                            useClass: AXMLeaveRequestStatusProvider,
                            multi: true,
                        },
                        provideCommandSetups([
                            {
                                key: 'HumanCapitalManagement.LeaveRequest:Approve',
                                command: () => import('./acorex-modules-human-capital-management-approve-leave-request.command-C7cEuryl.mjs').then((c) => c.ApproveLeaveRequestCommand),
                            },
                            {
                                key: 'HumanCapitalManagement.LeaveRequest:Reject',
                                command: () => import('./acorex-modules-human-capital-management-reject-leave-request.command-Dg45oY0X.mjs').then((c) => c.RejectLeaveRequestCommand),
                            },
                            {
                                key: 'HumanCapitalManagement.LeaveRequest:Cancel',
                                command: () => import('./acorex-modules-human-capital-management-cancel-leave-request.command-iGNY2Pxh.mjs').then((c) => c.CancelLeaveRequestCommand),
                            },
                        ]),
                    ],
                }]
        }] });

const AXM_EMPLOYEE_CODE_IDENTIFIER_RULE = {
    id: 'employee-code',
    title: 'Employee Code',
    entity: 'HumanCapitalManagement.Employee',
    pattern: 'EMP-{date:YYYYMM}-{seq:4}',
    enabled: true,
    priority: 1,
    scopeConfig: { byTenant: false, period: 'yearly', minValue: 100, blockSize: 0 },
};

//#region ----   Imports   ----
//#endregion
//#region ----   Manifest Definition   ----
/**
 * Human Capital Management Module Manifest.
 * Defines module metadata, features, and provider references.
 */
const HumanCapitalManagementManifest = {
    name: RootConfig.module.name,
    version: '1.0.0',
    title: RootConfig.module.title,
    icon: RootConfig.module.icon,
    i18n: RootConfig.config.i18n,
    // Module dependencies
    dependencies: [
        'OrganizationManagement',
        'PersonManagement',
        'LocationManagement',
        'DocumentManagement',
    ],
};
//#endregion

const AXPHumanCapitalManagementMenuKeys = {
    Root: 'HumanCapitalManagement:Menu',
    Employees: 'HumanCapitalManagement:Menu:Employees',
    EmploymentTypes: 'HumanCapitalManagement:Menu:EmploymentTypes',
    Divider1: 'HumanCapitalManagement:Menu:Divider1',
    PositionAssignments: 'HumanCapitalManagement:Menu:PositionAssignments',
    Divider2: 'HumanCapitalManagement:Menu:Divider2',
    LeaveTypes: 'HumanCapitalManagement:Menu:LeaveTypes',
    LeaveRequests: 'HumanCapitalManagement:Menu:LeaveRequests',
    LeaveRequestBoard: 'HumanCapitalManagement:Menu:LeaveRequestBoard',
};

const AXMPermissionsKeys = {
    HumanCapitalManagement: {
        Employee: {
            Management: 'HumanCapitalManagement:Permission:Employee.Management',
            View: 'HumanCapitalManagement:Permission:Employee.View',
            Edit: 'HumanCapitalManagement:Permission:Employee.Edit',
            Delete: 'HumanCapitalManagement:Permission:Employee.Delete',
            Create: 'HumanCapitalManagement:Permission:Employee.Create',
        },
        EmploymentType: {
            Management: 'HumanCapitalManagement:Permission:EmploymentType.Management',
            View: 'HumanCapitalManagement:Permission:EmploymentType.View',
            Edit: 'HumanCapitalManagement:Permission:EmploymentType.Edit',
            Delete: 'HumanCapitalManagement:Permission:EmploymentType.Delete',
            Create: 'HumanCapitalManagement:Permission:EmploymentType.Create',
        },
        PositionAssignment: {
            Management: 'HumanCapitalManagement:Permission:PositionAssignment.Management',
            View: 'HumanCapitalManagement:Permission:PositionAssignment.View',
            Edit: 'HumanCapitalManagement:Permission:PositionAssignment.Edit',
            Delete: 'HumanCapitalManagement:Permission:PositionAssignment.Delete',
            Create: 'HumanCapitalManagement:Permission:PositionAssignment.Create',
        },
        LeaveType: {
            Management: 'HumanCapitalManagement:Permission:LeaveType.Management',
            View: 'HumanCapitalManagement:Permission:LeaveType.View',
            Edit: 'HumanCapitalManagement:Permission:LeaveType.Edit',
            Delete: 'HumanCapitalManagement:Permission:LeaveType.Delete',
            Create: 'HumanCapitalManagement:Permission:LeaveType.Create',
        },
        LeaveRequest: {
            Management: 'HumanCapitalManagement:Permission:LeaveRequest.Management',
            View: 'HumanCapitalManagement:Permission:LeaveRequest.View',
            Edit: 'HumanCapitalManagement:Permission:LeaveRequest.Edit',
            Delete: 'HumanCapitalManagement:Permission:LeaveRequest.Delete',
            Create: 'HumanCapitalManagement:Permission:LeaveRequest.Create',
        },
    },
};

class AXMMenuProvider {
    constructor() {
        this.entityService = inject(AXPEntityService);
        this.sessionService = inject(AXPSessionService);
    }
    async provide(context) {
        const isAuthorized = await firstValueFrom(this.sessionService.isAuthorized$);
        if (!isAuthorized) {
            return;
        }
        const module = RootConfig.module;
        const organizationMenu = context.find(AXPCommonMenuKeys.Organization);
        if (!organizationMenu.exists) {
            context.addItems([
                {
                    name: AXPCommonMenuKeys.Organization,
                    priority: 9000,
                    text: '@organization-management:module.menus.root.title',
                    type: 'menu',
                    icon: 'fa-light fa-sitemap',
                    children: [],
                },
            ]);
        }
        // Root Organization: Employees, Position Assignments, Leave Requests (operational)
        context.find(AXPCommonMenuKeys.Organization).addItems([
            {
                name: AXPHumanCapitalManagementMenuKeys.Employees,
                text: '@human-capital-management:employees.menus.employees.title',
                path: this.entityService.createPath(module.name, RootConfig.entities.employee.name),
                priority: 60,
                icon: RootConfig.entities.employee.icon,
                policy: {
                    permissions: [AXMPermissionsKeys.HumanCapitalManagement.Employee.Management],
                    features: [AXPHumanCapitalManagementFeatureKeys.EmployeeManagement],
                },
            },
            {
                name: AXPHumanCapitalManagementMenuKeys.PositionAssignments,
                text: '@human-capital-management:position-assignments.menus.position-assignments.title',
                path: this.entityService.createPath(module.name, RootConfig.entities.positionAssignment.name),
                priority: 61,
                icon: RootConfig.entities.positionAssignment.icon,
                policy: {
                    permissions: [AXMPermissionsKeys.HumanCapitalManagement.Employee.Management],
                    features: [AXPHumanCapitalManagementFeatureKeys.EmployeeManagement],
                },
            },
            { name: AXPHumanCapitalManagementMenuKeys.Divider1, text: '', type: 'break', priority: 62 },
            {
                name: AXPHumanCapitalManagementMenuKeys.LeaveRequests,
                text: '@human-capital-management:leave-requests.menus.leave-requests.title',
                path: this.entityService.createPath(module.name, RootConfig.entities.leaveRequest.name),
                priority: 63,
                icon: RootConfig.entities.leaveRequest.icon,
                badgeKey: 'leave-request-badge',
                policy: {
                    permissions: [AXMPermissionsKeys.HumanCapitalManagement.LeaveRequest.Management],
                    features: [AXPHumanCapitalManagementFeatureKeys.LeaveManagement],
                },
            },
            {
                name: AXPHumanCapitalManagementMenuKeys.LeaveRequestBoard,
                text: RootConfig.pages.appointmentBoard.title,
                path: `${this.sessionService.application?.name}/${RootConfig.pages.appointmentBoard.path}/leave-request`,
                priority: 64,
                icon: RootConfig.pages.appointmentBoard.icon,
                policy: {
                    permissions: [AXMPermissionsKeys.HumanCapitalManagement.LeaveRequest.Management],
                    features: [AXPHumanCapitalManagementFeatureKeys.LeaveManagement],
                },
            },
        ]);
        // Configuration/Organization: Employment Types, Leave Types (reference)
        const orgConfigMenu = context.find(AXPCommonMenuKeys.OrganizationConfig);
        if (!orgConfigMenu.exists) {
            context.find(AXPCommonMenuKeys.Configuration).addItems([
                {
                    name: AXPCommonMenuKeys.OrganizationConfig,
                    priority: 8600,
                    text: '@organization-management:module.menus.configuration.title',
                    icon: module.icon,
                    type: 'menu',
                    children: [],
                },
            ]);
        }
        context.find(AXPCommonMenuKeys.OrganizationConfig).addItems([
            {
                name: AXPHumanCapitalManagementMenuKeys.EmploymentTypes,
                text: '@human-capital-management:employment-types.menus.employment-types.title',
                path: this.entityService.createPath(module.name, RootConfig.entities.employmentType.name),
                priority: 8,
                icon: RootConfig.entities.employmentType.icon,
                policy: {
                    permissions: [AXMPermissionsKeys.HumanCapitalManagement.Employee.Management],
                    features: [AXPHumanCapitalManagementFeatureKeys.EmployeeManagement],
                },
            },
            {
                name: AXPHumanCapitalManagementMenuKeys.LeaveTypes,
                text: '@human-capital-management:leave-types.menus.leave-types.title',
                path: this.entityService.createPath(module.name, RootConfig.entities.leaveType.name),
                priority: 9,
                icon: RootConfig.entities.leaveType.icon,
                policy: {
                    permissions: [AXMPermissionsKeys.HumanCapitalManagement.LeaveType.Management],
                    features: [AXPHumanCapitalManagementFeatureKeys.LeaveManagement],
                },
            },
        ]);
    }
}

class AXMPermissionDefinitionProvider {
    constructor(injector) {
        this.injector = injector;
        this.translateService = this.injector.get(AXTranslationService);
    }
    async define(context) {
        const keys = AXMPermissionsKeys.HumanCapitalManagement;
        const moduleTitle = await this.translateService.translateAsync('@human-capital-management:module.permissions.title');
        const moduleDescription = await this.translateService.translateAsync('@human-capital-management:module.permissions.description');
        context.addGroup(RootConfig.module.name, moduleTitle, moduleDescription)
            //
            .addPermission(keys.Employee.Management, await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.title'), await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.description'))
            .addChild(keys.Employee.View, await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.view.title'), await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.view.description'))
            .addChild(keys.Employee.Create, await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.create.title'), await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.create.description'))
            .addChild(keys.Employee.Edit, await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.edit.title'), await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.edit.description'))
            .addChild(keys.Employee.Delete, await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.delete.title'), await this.translateService.translateAsync('@human-capital-management:employees.permissions.employees.actions.delete.description'))
            .endPermission()
            //
            .addPermission(keys.EmploymentType.Management, await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.title'), await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.description'))
            .addChild(keys.EmploymentType.View, await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.view.title'), await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.view.description'))
            .addChild(keys.EmploymentType.Create, await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.create.title'), await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.create.description'))
            .addChild(keys.EmploymentType.Edit, await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.edit.title'), await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.edit.description'))
            .addChild(keys.EmploymentType.Delete, await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.delete.title'), await this.translateService.translateAsync('@human-capital-management:employment-types.permissions.employment-types.actions.delete.description'))
            .endPermission()
            //
            .addPermission(keys.PositionAssignment.Management, await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.title'), await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.description'))
            .addChild(keys.PositionAssignment.View, await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.view.title'), await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.view.description'))
            .addChild(keys.PositionAssignment.Create, await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.create.title'), await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.create.description'))
            .addChild(keys.PositionAssignment.Edit, await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.edit.title'), await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.edit.description'))
            .addChild(keys.PositionAssignment.Delete, await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.delete.title'), await this.translateService.translateAsync('@human-capital-management:position-assignments.permissions.position-assignments.actions.delete.description'))
            .endPermission()
            //
            .addPermission(keys.LeaveType.Management, await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.title'), await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.description'))
            .addChild(keys.LeaveType.View, await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.view.title'), await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.view.description'))
            .addChild(keys.LeaveType.Create, await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.create.title'), await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.create.description'))
            .addChild(keys.LeaveType.Edit, await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.edit.title'), await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.edit.description'))
            .addChild(keys.LeaveType.Delete, await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.delete.title'), await this.translateService.translateAsync('@human-capital-management:leave-types.permissions.leave-types.actions.delete.description'))
            .endPermission()
            //
            .addPermission(keys.LeaveRequest.Management, await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.title'), await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.description'))
            .addChild(keys.LeaveRequest.View, await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.view.title'), await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.view.description'))
            .addChild(keys.LeaveRequest.Create, await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.create.title'), await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.create.description'))
            .addChild(keys.LeaveRequest.Edit, await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.edit.title'), await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.edit.description'))
            .addChild(keys.LeaveRequest.Delete, await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.delete.title'), await this.translateService.translateAsync('@human-capital-management:leave-requests.permissions.leave-requests.actions.delete.description'))
            .endPermission()
            //
            .endGroup();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMPermissionDefinitionProvider, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMPermissionDefinitionProvider }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMPermissionDefinitionProvider, decorators: [{
            type: Injectable
        }], ctorParameters: () => [{ type: i0.Injector }] });

//#region ---- Appointment Board Route ----
function createAppointmentBoardRoute() {
    const config = inject(AXP_ENTITY_CONFIG_TOKEN);
    return {
        path: `:app/${RootConfig.pages.appointmentBoard.path}/:provider-name`,
        canActivate: [AXPAuthGuard],
        loadComponent: () => config.viewers.root(),
        children: [
            {
                path: '',
                loadComponent: () => import('@acorex/modules/common').then((c) => c.AXPResourceAppointmentPageComponent),
                providers: [
                    {
                        provide: AXP_RESOURCE_APPOINTMENT_PAGE_CONFIG,
                        useValue: {
                            pageTitle: RootConfig.pages.appointmentBoard.title,
                            pageDescription: '@human-capital-management:leave-requests.menus.appointment-board.description',
                            pageIcon: RootConfig.pages.appointmentBoard.icon,
                            breadcrumbs: [{ title: RootConfig.module.title }],
                            showResourceHeaders: true,
                            showUnassignedAppointments: true,
                        },
                    },
                ],
            },
        ],
    };
}
//#endregion
class AXMHumanCapitalManagementModule {
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalManagementModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
    static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalManagementModule, imports: [CommonModule, AXPRuntimeModule, AXMLeaveRequestFeatureModule] }); }
    static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalManagementModule, providers: [
            // Appointment Board route
            {
                provide: ROUTES,
                multi: true,
                useFactory: () => [createAppointmentBoardRoute()],
            },
            {
                provide: AXP_RESOURCE_APPOINTMENT_PROVIDER,
                useClass: AXMLeaveRequestResourceAppointmentProvider,
                multi: true,
            },
            // Module-specific providers (not part of manifest system)
            {
                provide: AXP_IDENTIFIER_RULES,
                multi: true,
                useValue: AXM_EMPLOYEE_CODE_IDENTIFIER_RULE,
            },
            // Module Manifest Provider
            {
                provide: AXP_MODULE_MANIFEST_PROVIDER,
                useValue: HumanCapitalManagementManifest,
                multi: true,
            },
            // Provider references (now using tokens)
            {
                provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                useClass: AXMPermissionDefinitionProvider,
                multi: true,
            },
            {
                provide: AXP_MENU_PROVIDER,
                useClass: AXMMenuProvider,
                multi: true,
            },
            {
                provide: AXP_ENTITY_DEFINITION_LOADER,
                useClass: AXMHumanCapitalModuleEntityProvider,
                multi: true,
            },
            {
                provide: AXP_FEATURE_DEFINITION_PROVIDER,
                useClass: AXPHumanCapitalManagementFeatureDefinitionProvider,
                multi: true,
            },
        ], imports: [CommonModule, AXPRuntimeModule, AXMLeaveRequestFeatureModule] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: AXMHumanCapitalManagementModule, decorators: [{
            type: NgModule,
            args: [{
                    imports: [CommonModule, AXPRuntimeModule, AXMLeaveRequestFeatureModule],
                    providers: [
                        // Appointment Board route
                        {
                            provide: ROUTES,
                            multi: true,
                            useFactory: () => [createAppointmentBoardRoute()],
                        },
                        {
                            provide: AXP_RESOURCE_APPOINTMENT_PROVIDER,
                            useClass: AXMLeaveRequestResourceAppointmentProvider,
                            multi: true,
                        },
                        // Module-specific providers (not part of manifest system)
                        {
                            provide: AXP_IDENTIFIER_RULES,
                            multi: true,
                            useValue: AXM_EMPLOYEE_CODE_IDENTIFIER_RULE,
                        },
                        // Module Manifest Provider
                        {
                            provide: AXP_MODULE_MANIFEST_PROVIDER,
                            useValue: HumanCapitalManagementManifest,
                            multi: true,
                        },
                        // Provider references (now using tokens)
                        {
                            provide: AXP_PERMISSION_DEFINITION_PROVIDER,
                            useClass: AXMPermissionDefinitionProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_MENU_PROVIDER,
                            useClass: AXMMenuProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_ENTITY_DEFINITION_LOADER,
                            useClass: AXMHumanCapitalModuleEntityProvider,
                            multi: true,
                        },
                        {
                            provide: AXP_FEATURE_DEFINITION_PROVIDER,
                            useClass: AXPHumanCapitalManagementFeatureDefinitionProvider,
                            multi: true,
                        },
                    ],
                }]
        }] });

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

export { AXMHumanCapitalManagementModule, AXMLeaveRequestBadgeProvider, AXMLeaveRequestResourceAppointmentProvider, AXMLeaveRequestTaskPopoverComponent, AXMPermissionsKeys, AXPHumanCapitalManagementFeatureDefinitionProvider, AXPHumanCapitalManagementFeatureKeys, AXPHumanCapitalManagementMenuKeys, AXPLeaveRequestDialogService, HumanCapitalManagementManifest, RootConfig };
//# sourceMappingURL=acorex-modules-human-capital-management.mjs.map
