import * as i0 from '@angular/core';
import { inject, Injectable } from '@angular/core';
import { GetTenantRegistrationTimelineQuery } from './acorex-connectivity-mock-get-tenant-registration-timeline.query-CfDjhtaC.mjs';

//#endregion
class GetTenantRegistrationChartDataQuery {
    constructor() {
        this.tenantRegistrationTimelineQuery = inject(GetTenantRegistrationTimelineQuery);
    }
    async fetch(input) {
        // Get all tenant registration timeline data (no pagination for charts)
        const timelineResult = await this.tenantRegistrationTimelineQuery.fetch({
            skip: 0,
            take: 10000,
            filters: input.filters,
            logic: input.logic,
        });
        // Group by month
        const monthGroups = new Map();
        for (const item of timelineResult.items) {
            const monthKey = `${item.year}-${String(item.monthNumber).padStart(2, '0')}`;
            if (!monthGroups.has(monthKey)) {
                monthGroups.set(monthKey, {
                    month: item.month,
                    year: item.year,
                    quarter: item.quarter,
                    tenantCount: 0,
                });
            }
            const group = monthGroups.get(monthKey);
            group.tenantCount++;
        }
        // Convert to array and sort by date
        const results = Array.from(monthGroups.values()).sort((a, b) => {
            if (a.year !== b.year)
                return a.year - b.year;
            const monthA = new Date(`${a.month} 1, ${a.year}`).getMonth();
            const monthB = new Date(`${b.month} 1, ${b.year}`).getMonth();
            return monthA - monthB;
        });
        return {
            items: results,
        };
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: GetTenantRegistrationChartDataQuery, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
    static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: GetTenantRegistrationChartDataQuery, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.19", ngImport: i0, type: GetTenantRegistrationChartDataQuery, decorators: [{
            type: Injectable,
            args: [{
                    providedIn: 'root',
                }]
        }] });

export { GetTenantRegistrationChartDataQuery };
//# sourceMappingURL=acorex-connectivity-mock-get-tenant-registration-chart-data.query-CACCBXn-.mjs.map
