/**
 * Type definitions for Bicorder Cluster Classifier
 */

export interface ModelData {
  version: string;
  generated: string;
  dimensions: string[];
  key_dimensions: string[];
  cluster_names: {
    '1': string;
    '2': string;
  };
  cluster_descriptions: {
    '1': string;
    '2': string;
  };
  scaler: {
    mean: number[];
    scale: number[];
  };
  lda: {
    coefficients: number[];
    intercept: number;
  };
  cluster_centroids_scaled: {
    '1': number[];
    '2': number[];
  };
  cluster_means_original: {
    '1': number[];
    '2': number[];
  };
  thresholds: {
    confidence_low: number;
    completeness_low: number;
    boundary_distance_low: number;
  };
  metadata: {
    total_protocols: number;
    cluster_1_count: number;
    cluster_2_count: number;
  };
}

export interface Ratings {
  [dimensionName: string]: number | null | undefined;
}

export interface PredictionResult {
  cluster: 1 | 2;
  clusterName: string;
  confidence: number;
  completeness: number;
  recommendedForm: 'short' | 'long';
}

export interface DetailedPredictionResult extends PredictionResult {
  ldaScore: number;
  distanceToBoundary: number;
  dimensionsProvided: number;
  dimensionsTotal: number;
  keyDimensionsProvided: number;
  keyDimensionsTotal: number;
  distancesToCentroids: {
    '1': number;
    '2': number;
  };
  rawConfidence: number;
}

export interface ShortFormAssessment {
  ready: boolean;
  keyDimensionsProvided: number;
  keyDimensionsTotal: number;
  coverage: number;
  missingKeyDimensions: string[];
}

export interface PredictOptions {
  detailed?: boolean;
}

export class BicorderClassifier {
  constructor(model: ModelData);

  predict(ratings: Ratings, options?: { detailed: false }): PredictionResult;
  predict(ratings: Ratings, options: { detailed: true }): DetailedPredictionResult;
  predict(ratings: Ratings, options?: PredictOptions): PredictionResult | DetailedPredictionResult;

  explainClassification(ratings: Ratings): string;

  getKeyDimensions(): string[];

  assessShortFormReadiness(ratings: Ratings): ShortFormAssessment;
}

export function loadClassifier(url?: string): Promise<BicorderClassifier>;
