import { Injectable } from '@nestjs/common';
import type { FeatureExtractor } from './feature.interface';
import { EntitlementStatusFeatureExtractor } from './entitlement-status.feature';
import { RfmFeatureExtractor } from './rfm.feature';
import { AgeBracketFeatureExtractor } from './age-bracket.feature';
import { GenderFeatureExtractor } from './gender.feature';
import { AcquisitionChannelFeatureExtractor } from './acquisition-channel.feature';
import { FamilyStructureFeatureExtractor } from './family-structure.feature';
import { ReferralChampionFeatureExtractor } from './referral-champion.feature';
import { LifecycleStageFeatureExtractor } from './lifecycle-stage.feature';
import { TreatmentHistoryFeatureExtractor } from './treatment-history.feature';
import { TimePreferenceFeatureExtractor } from './time-preference.feature';
import { DiscountAnchorFeatureExtractor } from './discount-anchor.feature';
import { SpecialAttentionFeatureExtractor } from './special-attention.feature';
import { TreatmentSensitivityFeatureExtractor } from './treatment-sensitivity.feature';
import { ContraindicationFeatureExtractor } from './contraindication.feature';
import { PotentialTreatmentFeatureExtractor } from './potential-treatment.feature';
import { UrgencyLevelFeatureExtractor } from './urgency-level.feature';

/**
 * FeatureRegistry — 收集所有 PersonaFeature 提取器。
 *
 * W7 重构:统计层 rfm(RFM 8 分群)统一了旧 value(=M)+ recall_risk(=R+缺口)+
 *   treatment_chain_status(降级为详情页 episode 视图,不进画像)→ 三个旧 extractor 已摘除。
 * W7 末:do_not_contact_status 摘除 — 免打扰并入 special_attention(CDP D.2.3);
 *   合规闸召回读 patient_profiles 原始列(不依赖本特征);已故/投诉信号后续补(投诉数据缺)。
 * 单个 extractor 抛错不影响其余 — PersonaService 整体记 partial。
 */
/**
 * 全部 extractor 的 DI provider 清单 —— PersonaModule 与测试共用这一份。
 * (原先 module.providers 与本文件构造参数各写一遍,加特征时容易只改一边。)
 * extractor 都是无依赖纯函数类,所以测试里 `providers: [FeatureRegistry, ...此清单]` 即可跑起来。
 */
export const FEATURE_EXTRACTOR_PROVIDERS = [
  RfmFeatureExtractor,
  AgeBracketFeatureExtractor,
  GenderFeatureExtractor,
  AcquisitionChannelFeatureExtractor,
  FamilyStructureFeatureExtractor,
  ReferralChampionFeatureExtractor,
  LifecycleStageFeatureExtractor,
  TreatmentHistoryFeatureExtractor,
  TimePreferenceFeatureExtractor,
  DiscountAnchorFeatureExtractor,
  SpecialAttentionFeatureExtractor,
  TreatmentSensitivityFeatureExtractor,
  ContraindicationFeatureExtractor,
  PotentialTreatmentFeatureExtractor,
  UrgencyLevelFeatureExtractor,
  EntitlementStatusFeatureExtractor,
];

@Injectable()
export class FeatureRegistry {
  readonly extractors: FeatureExtractor[];

  constructor(
    rfm: RfmFeatureExtractor,
    age: AgeBracketFeatureExtractor,
    gender: GenderFeatureExtractor,
    acquisition: AcquisitionChannelFeatureExtractor,
    family: FamilyStructureFeatureExtractor,
    referral: ReferralChampionFeatureExtractor,
    lifecycle: LifecycleStageFeatureExtractor,
    treatmentHistory: TreatmentHistoryFeatureExtractor,
    timePref: TimePreferenceFeatureExtractor,
    discountAnchor: DiscountAnchorFeatureExtractor,
    specialAttention: SpecialAttentionFeatureExtractor,
    treatmentSensitivity: TreatmentSensitivityFeatureExtractor,
    contraindication: ContraindicationFeatureExtractor,
    potentialTreatment: PotentialTreatmentFeatureExtractor,
    urgencyLevel: UrgencyLevelFeatureExtractor,
    entitlement: EntitlementStatusFeatureExtractor,
  ) {
    this.extractors = [rfm, age, gender, acquisition, family, referral, lifecycle, treatmentHistory, timePref, discountAnchor, specialAttention, treatmentSensitivity, contraindication, potentialTreatment, urgencyLevel, entitlement];
  }
}
