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

interface SearchFilterProps {
  query?: string;
  propertyType?: string;
  transactionType?: string;
  priceMin?: number;
  priceMax?: number;
  areaMin?: number;
  areaMax?: number;
  bedrooms?: number;
  district?: string;
  city?: string;
  sortBy?: 'price_asc' | 'price_desc' | 'date_desc' | 'relevance' | 'distance';
  page?: number;
  perPage?: number;
}

export class SearchFilter extends ValueObject<SearchFilterProps> {
  get query(): string | undefined {
    return this.props.query;
  }

  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 areaMin(): number | undefined {
    return this.props.areaMin;
  }

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

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

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

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

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

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

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

  static create(props: SearchFilterProps): SearchFilter {
    return new SearchFilter(props);
  }
}
