import { ValueObject } from '@modules/shared';

interface GeoFilterProps {
  lat: number;
  lng: number;
  radiusKm: number;
  propertyType?: string;
  transactionType?: string;
  priceMin?: number;
  priceMax?: number;
  sortBy?: 'distance' | 'price_asc' | 'price_desc' | 'date_desc';
  page?: number;
  perPage?: number;
}

export class GeoFilter extends ValueObject<GeoFilterProps> {
  get lat(): number {
    return this.props.lat;
  }

  get lng(): number {
    return this.props.lng;
  }

  get radiusKm(): number {
    return Math.min(this.props.radiusKm, 100);
  }

  get propertyType(): string | undefined {
    return this.props.propertyType;
  }

  get transactionType(): string | undefined {
    return this.props.transactionType;
  }

  get priceMin(): number | undefined {
    return this.props.priceMin;
  }

  get priceMax(): number | undefined {
    return this.props.priceMax;
  }

  get sortBy(): string {
    return this.props.sortBy ?? 'distance';
  }

  get page(): number {
    return this.props.page ?? 1;
  }

  get perPage(): number {
    return Math.min(this.props.perPage ?? 20, 100);
  }

  static create(props: GeoFilterProps): GeoFilter {
    return new GeoFilter(props);
  }
}
