import { PropertyType } from '@prisma/client';

export const DUPLICATE_DETECTOR = Symbol('DUPLICATE_DETECTOR');

/** A candidate that may be a duplicate of a newly created listing */
export interface DuplicateCandidate {
  listingId: string;
  propertyId: string;
  title: string;
  address: string;
  district: string;
  distanceMeters: number;
  titleSimilarity: number;
  propertyType: PropertyType;
}

export interface DuplicateCheckParams {
  /** Exclude this property from results (the one being created) */
  excludePropertyId: string;
  latitude: number;
  longitude: number;
  title: string;
  propertyType: PropertyType;
  /** Max distance in meters to search for duplicates (default: 100) */
  radiusMeters?: number;
  /** Min title similarity ratio 0-1 to flag (default: 0.7) */
  minTitleSimilarity?: number;
}

export interface IDuplicateDetector {
  /** Find existing listings that may be duplicates of the given property */
  findDuplicates(params: DuplicateCheckParams): Promise<DuplicateCandidate[]>;
}
