import { PropertyType } from '@prisma/client';
import { MarketIndexEntity } from '../entities/market-index.entity';

export const MARKET_INDEX_REPOSITORY = Symbol('MARKET_INDEX_REPOSITORY');

export interface MarketReportResult {
  district: string;
  city: string;
  propertyType: PropertyType;
  period: string;
  medianPrice: string;
  avgPriceM2: number;
  totalListings: number;
  daysOnMarket: number;
  inventoryLevel: number;
  absorptionRate: number | null;
  yoyChange: number | null;
}

export interface HeatmapDataPoint {
  district: string;
  city: string;
  avgPriceM2: number;
  totalListings: number;
  medianPrice: string;
}

export interface PriceTrendPoint {
  period: string;
  medianPrice: string;
  avgPriceM2: number;
  totalListings: number;
}

export interface DistrictStatsResult {
  district: string;
  city: string;
  propertyType: PropertyType;
  medianPrice: string;
  avgPriceM2: number;
  totalListings: number;
  daysOnMarket: number;
  inventoryLevel: number;
  absorptionRate: number | null;
  yoyChange: number | null;
}

export interface IMarketIndexRepository {
  findById(id: string): Promise<MarketIndexEntity | null>;
  findByKey(district: string, city: string, propertyType: PropertyType, period: string): Promise<MarketIndexEntity | null>;
  save(entity: MarketIndexEntity): Promise<void>;
  update(entity: MarketIndexEntity): Promise<void>;
  getMarketReport(city: string, period: string, propertyType?: PropertyType): Promise<MarketReportResult[]>;
  getHeatmap(city: string, period: string): Promise<HeatmapDataPoint[]>;
  getPriceTrend(district: string, city: string, propertyType: PropertyType, periods: string[]): Promise<PriceTrendPoint[]>;
  getDistrictStats(city: string, period: string): Promise<DistrictStatsResult[]>;
}
