# SPDX-License-Identifier: AGPL-3.0-only
# Copyright (c) 2026 sol pbc

"""Owner-facing copy constants for the entities app."""

from __future__ import annotations

from typing import Any

ENT_DETACH_CONFIRM = "detach {name} from {facet}? stays in your journal and you can re-attach it anytime."
ENT_DETACH_DONE = "detached from {facet}. {name} is still in your journal."
ENT_DETACH_REATTACH_ACTION = "re-attach it →"
ENT_DETACH_FIND_ACTION = "find it in your journal →"
ENT_OBS_SOURCE_LINK_TITLE = "see this day"
ENT_OBS_HEADING = "moments"
ENT_GRID_TITLE = "moments over time"
ENT_GRID_LEDE = "{n} {observation_unit} across {d} {day_unit}"
ENT_GRID_UNIT_ONE = "moment"
ENT_GRID_UNIT_OTHER = "moments"
ENT_GRID_UNIT_NONE = "nothing yet"
ENT_GRID_DAY_ONE = "day"
ENT_GRID_DAY_OTHER = "days"
ENT_GRID_SHOW_ALL = "show all {n} {observation_unit}"
ENT_GRID_DEFAULT_DAY = "most recent day: {day}"
ENT_GRID_RANGE = "{from} – {to}"
ENT_GRID_CLEAR_RANGE = "clear range"
ENT_DETECTED_EMPTY = "nothing detected here yet. as sol experiences your day in this facet, people, places, and things show up here to add to your journal."
ENT_CARDS_EMPTY = "no entities in this facet yet. anything sol detects below, you can star to keep. or add one yourself."
ENT_OBS_EMPTY = "nothing with {name} yet."
ENT_OBS_LOAD_FAILED = "sol couldn't load these moments. try again →"
ENT_TRUST_HEADING = "identity trust"
ENT_TRUST_MERGE_LABEL = "merge into"
ENT_TRUST_MERGE_ACTION = "preview merge"
ENT_TRUST_MERGE_CONFIRM = (
    "merge {source} into {target}? you can undo this merge afterward."
)
ENT_TRUST_MERGE_CONFIRM_ACTION = "confirm merge"
ENT_TRUST_PREVIEW_SUMMARY = "preview: {aliases} aliases, {facets} facet links, {observations} moments, {segments} speaker labels."
ENT_TRUST_MERGE_DONE = "merged."
ENT_TRUST_UNDO_ACTION = "undo merge"
ENT_TRUST_UNDO_CONFIRM = "undo this merge and restore both identities?"
ENT_TRUST_SUGGESTIONS_HEADING = "open merge suggestions"
ENT_TRUST_SUGGESTIONS_EMPTY = "no open merge suggestions involve this entity."
ENT_TRUST_SUGGESTION_SUMMARY = "{source} → {target} · {facet}"
ENT_TRUST_HISTORY_HEADING = "version history"
ENT_TRUST_HISTORY_EMPTY = "no identity history is available yet."
ENT_TRUST_HISTORY_SUMMARY = "{kind} · {date} · {name}"
ENT_TRUST_HISTORY_CHANGE = "{before} → {after}"
ENT_TRUST_IDENTITY_SUMMARY = "{name} · {type} · aka: {akas}"
ENT_TRUST_IDENTITY_NONE = "no prior identity"
ENT_TRUST_RESTORE_ACTION = "restore this version"
ENT_TRUST_RESTORE_CONFIRM = "restore the identity from this version? the current identity will remain in history."
ENT_TRUST_LOAD_FAILED = "couldn't load identity trust details. try again."
ENT_TRUST_ACTION_FAILED = "that identity change couldn't be completed."
ENT_TRUST_REPAIR_REQUIRED = "{detail} {remediation}"
ENT_CONN_WITH_YOU_EYEBROW = "with you"
ENT_CONN_WITH_YOU_SUMMARY = "{n} moments together · latest {kind} ({day})"
ENT_CONN_WITH_YOU_SUMMARY_ONE = "1 moment together · latest {kind} ({day})"
ENT_CONN_WITH_YOU_TOGGLE = "the moments behind this ›"
ENT_CONN_WITH_YOU_FAILED = "couldn't check your own history with this entity just now."
ENT_CONN_SUMMARY = "{s} with direct evidence · {a} from shared events only"
ENT_CONN_EVENTS_ONLY = "events only"
ENT_CONN_ROW_META = "{n} moments · {day}"
ENT_CONN_ROW_META_ATTENDANCE = "{n} events together · {day}"
ENT_CONN_ROW_META_ONE = "1 moment · {day}"
ENT_CONN_ROW_META_ONE_ATTENDANCE = "1 event together · {day}"
ENT_CONN_EVIDENCE_CAPTION = "the moments behind this — evidence, not a conclusion"
ENT_CONN_EVIDENCE_MORE = "showing {k} of {n} — show more"
ENT_CONN_EVIDENCE_VIEW_ENTITY = "view entity →"
ENT_CONN_EVIDENCE_FAILED = "couldn't load these moments. try again."
ENT_CONN_UPCOMING = " (upcoming)"
ENT_CONN_EMPTY = (
    "no connections recorded yet — they appear as sol notices who and what this "
    "entity shows up with."
)
ENT_CONN_INDEX_UNAVAILABLE = "the connections index hasn't been built yet."
ENT_CONN_INDEX_ACTION = "check system health →"
ENT_CONN_AMBIGUOUS = "sol isn't sure which entity this is yet."
ENT_CONN_LOAD_FAILED = "couldn't load connections. try again."
ENT_CONN_KIND_WORDS = {
    "works-with": "works with",
    "works-at": "works at",
    "reports-to": "reports to",
    "family-of": "family",
    "knows": "knows",
    "uses": "uses",
    "created": "created",
    "decided-with": "decided together",
    "committed-to": "committed",
    "spoke-with": "spoke",
    "mentioned": "mentioned",
    "messaged-with": "messaged",
    "scheduled-with": "scheduled",
    "party-of": "party to",
    "other": "related",
    "attended-with": "events",
    "co-present": "around together",
}
ENT_CONN_KIND_CHIP_WORDS = {
    "committed-to": "commitments",
    "mentioned": "mentions",
}
ENT_CONN_SOURCE_WORDS = {
    "event-legacy": "older calendar events",
    "co-presence": "shared moments",
    "participation": "activity records",
    "commitment": "commitments",
    "closure": "commitments",
    "decision": "decisions",
    "relation": "what sol has learned",
    "observation": "what sol has learned",
    "speaker": "conversation",
    "mention": "conversation",
    "messaging": "messages",
    "calendar": "calendar events",
    "document": "documents",
}
ENT_CONN_SOURCE_WORD_FALLBACK = "what sol has learned"
ENT_CONN_LABEL_FALLBACKS = {
    "spoke-with": "a conversation",
    "co-present": "time in the same place",
    "mentioned": "came up in conversation",
}


def entities_copy_payload() -> dict[str, Any]:
    """Return copy constants for templates and browser code."""
    return {
        name: value
        for name, value in globals().items()
        if name.startswith("ENT_") and name.isupper()
    }


def entities_copy_values() -> list[str]:
    """Return all verbatim copy values, flattening list and dict constants."""
    values: list[str] = []
    for value in entities_copy_payload().values():
        if isinstance(value, str):
            values.append(value)
        elif isinstance(value, list):
            values.extend(item for item in value if isinstance(item, str))
        elif isinstance(value, dict):
            values.extend(item for item in value.values() if isinstance(item, str))
    return values
