"""Constants for the ``razin init`` command."""

from __future__ import annotations

import re
from re import Pattern

from razin.constants.profiles import DEFAULT_PROFILE, ProfileName

INIT_CONFIG_TEMP_PREFIX: str = ".tmp-init-"
INIT_CONFIG_TEMP_SUFFIX: str = ".yaml"

INIT_PROFILE_CHOICES: tuple[str, ...] = ("strict", "balanced", "audit")
INIT_DEFAULT_PROFILE: ProfileName = DEFAULT_PROFILE

INIT_GENERATED_HEADER: str = "# Generated by razin init"
INIT_FROM_SCAN_REVIEW_HEADER: str = "# Review and uncomment entries you trust."
INIT_ADVANCED_SECTION_COMMENTS: tuple[str, ...] = (
    "# Optional advanced sections",
    "# tool_prefixes:",
    "#   - MCP_",
    "# detectors:",
    "#   enabled: []",
    "#   disabled: []",
    "# typosquat:",
    "#   baseline: []",
)

INIT_NET_DOC_DOMAIN_RULE_ID: str = "NET_DOC_DOMAIN"
INIT_MCP_ENDPOINT_RULE_ID: str = "MCP_ENDPOINT"
INIT_FROM_SCAN_RULE_CONFIG_KEYS: dict[str, str] = {
    INIT_NET_DOC_DOMAIN_RULE_ID: "allowlist_domains",
    INIT_MCP_ENDPOINT_RULE_ID: "mcp_allowlist_domains",
}
INIT_FROM_SCAN_RULE_IDS: tuple[str, ...] = (
    INIT_NET_DOC_DOMAIN_RULE_ID,
    INIT_MCP_ENDPOINT_RULE_ID,
)

INIT_HINT_MIN_FINDINGS: int = 3
INIT_HINT_DOMINANCE_THRESHOLD: float = 0.5

INIT_DESCRIPTION_QUOTED_VALUE_PATTERN: Pattern[str] = re.compile(r"'([^']+)'")
INIT_DOMAIN_TOKEN_PATTERN: Pattern[str] = re.compile(
    r"\b(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}\b",
    re.IGNORECASE,
)
