import type { NormalizedQueryV1, NormalizedQueryV2, NormalizedQueryV2_0_1, NormalizedQueryV2_0_2 } from "../src/types/normalizer";

export function normalizedFixture(): NormalizedQueryV1 {
  return {
    schema_version: "normalized_query_v1",
    user_question_raw: "По каким поставщикам не бьются взаиморасчеты?",
    normalized_question: "Показать поставщиков с расхождениями по взаиморасчетам.",
    intent_class: "cross_entity",
    business_problem_type: "reconciliation",
    domain_entities: ["контрагент", "документ", "проводка"],
    accounts_mentioned: ["60"],
    documents_mentioned: ["поступление", "списание"],
    registers_mentioned: ["взаиморасчеты"],
    period_scope: {
      type: "inferred",
      value: "2020-06",
      confidence: "medium"
    },
    requires: {
      needs_cross_entity_join: true,
      needs_causal_chain: true,
      needs_exact_object_trace: false,
      needs_ranking: false,
      needs_anomaly_summary: false,
      needs_runtime_truth: false,
      needs_period_cut: true,
      needs_evidence: true
    },
    expected_output_shape: "reconciliation_report",
    route_hint: "hybrid_store_plus_live",
    ambiguities: [],
    confidence: {
      overall: "medium",
      intent_class: "high",
      route_hint: "medium"
    }
  };
}

export function normalizedFixtureV2(): NormalizedQueryV2 {
  return {
    schema_version: "normalized_query_v2",
    user_message_raw: "Проверь по поставщикам хвосты и отдельно скажи, что не относится к данным компании.",
    message_in_scope: true,
    scope_confidence: "medium",
    contains_multiple_tasks: true,
    fragments: [
      {
        fragment_id: "F1",
        raw_fragment_text: "Проверь по поставщикам хвосты",
        normalized_fragment_text: "Проверить хвосты по поставщикам",
        domain_relevance: "in_scope",
        business_scope: "company_specific_accounting",
        entity_hints: ["поставщик", "взаиморасчеты"],
        account_hints: ["60"],
        document_hints: ["документ"],
        register_hints: ["остатки"],
        time_scope: {
          type: "missing",
          value: null,
          confidence: "low"
        },
        flags: {
          has_multi_entity_scope: true,
          asks_for_chain_explanation: true,
          asks_for_ranking_or_top: false,
          asks_for_period_summary: false,
          asks_for_rule_check: false,
          asks_for_anomaly_scan: true,
          asks_for_exact_object_trace: false,
          asks_for_evidence: true,
          mentions_period_close_context: false
        },
        candidate_labels: ["cross_entity", "anomaly_probe"],
        confidence: "medium"
      }
    ],
    discarded_fragments: [
      {
        raw_fragment_text: "короче",
        reason: "noise_or_too_short"
      }
    ],
    global_notes: {
      needs_clarification: true,
      clarification_reason: "Не указан период."
    }
  };
}

export function normalizedFixtureV2_0_1(): NormalizedQueryV2_0_1 {
  return {
    schema_version: "normalized_query_v2_0_1",
    user_message_raw: "Проверь, что висит по 97 и где есть подозрительные хвосты.",
    message_in_scope: true,
    scope_confidence: "high",
    contains_multiple_tasks: false,
    fragments: [
      {
        fragment_id: "F1",
        raw_fragment_text: "Проверь, что висит по 97 и где есть подозрительные хвосты",
        normalized_fragment_text: "Проверить зависшие записи по 97 и подозрительные хвосты",
        domain_relevance: "in_scope",
        business_scope: "company_specific_accounting",
        entity_hints: ["рбп"],
        account_hints: ["97"],
        document_hints: [],
        register_hints: ["остатки"],
        time_scope: {
          type: "missing",
          value: null,
          confidence: "low"
        },
        flags: {
          has_multi_entity_scope: false,
          asks_for_chain_explanation: false,
          asks_for_ranking_or_top: false,
          asks_for_period_summary: false,
          asks_for_rule_check: true,
          asks_for_anomaly_scan: true,
          asks_for_exact_object_trace: false,
          asks_for_evidence: false,
          mentions_period_close_context: false
        },
        candidate_labels: ["rule_based_account_control", "anomaly_probe"],
        confidence: "high",
        execution_readiness: "executable_with_soft_assumptions",
        clarification_reason: null,
        soft_assumption_used: ["problem_scan_mode_enabled"]
      }
    ],
    discarded_fragments: [],
    global_notes: {
      needs_clarification: false,
      clarification_reason: null
    }
  };
}

export function normalizedFixtureV2_0_2(): NormalizedQueryV2_0_2 {
  return {
    schema_version: "normalized_query_v2_0_2",
    user_message_raw: "Проверь зависшие истории по 97 и подсвети рискованные участки.",
    message_in_scope: true,
    scope_confidence: "high",
    contains_multiple_tasks: false,
    fragments: [
      {
        fragment_id: "F1",
        raw_fragment_text: "Проверь зависшие истории по 97 и подсвети рискованные участки",
        normalized_fragment_text: "Проверить зависшие истории по 97 и рискованные участки",
        domain_relevance: "in_scope",
        business_scope: "company_specific_accounting",
        entity_hints: ["рбп"],
        account_hints: ["97"],
        document_hints: [],
        register_hints: ["остатки"],
        time_scope: {
          type: "missing",
          value: null,
          confidence: "low"
        },
        flags: {
          has_multi_entity_scope: false,
          asks_for_chain_explanation: false,
          asks_for_ranking_or_top: false,
          asks_for_period_summary: false,
          asks_for_rule_check: true,
          asks_for_anomaly_scan: true,
          asks_for_exact_object_trace: false,
          asks_for_evidence: false,
          mentions_period_close_context: false
        },
        candidate_labels: ["rule_based_account_control", "anomaly_probe"],
        confidence: "high",
        execution_readiness: "executable_with_soft_assumptions",
        clarification_reason: null,
        soft_assumption_used: ["problem_scan_mode_enabled"],
        route_status: "routed",
        no_route_reason: null
      }
    ],
    discarded_fragments: [],
    global_notes: {
      needs_clarification: false,
      clarification_reason: null
    }
  };
}
