// Override descriptions for lexicon properties
// Format: "lexiconId" or "lexiconId#defName" -> { propertyName: description }

export const DESCRIPTION_OVERRIDES: Record<string, Record<string, string>> = {
    'site.standard.publication': {
        url: 'Base publication url (ex: `https://standard.site`). The canonical document URL is formed by combining this value with the document `path`.',
        icon: 'Square image to identify the publication. Should be at least 256x256.',
        name: 'Name of the publication.',
        description: 'Brief description of the publication.',
        basicTheme: 'Simplified publication theme for tools and apps to utilize when displaying content.',
        labels: 'Self-label values for this publication. Effectively content warnings.',
        preferences: 'Object containing platform specific preferences (with a few shared properties).',
    },
    'site.standard.theme.basic': {
        background: 'Color used for content background.',
        foreground: 'Color used for content text.',
        accent: 'Color used for links and button backgrounds.',
        accentForeground: 'Color used for button text.',
    },
    'site.standard.publication#preferences': {
        showInDiscover: 'Boolean which decides whether the publication should appear in discovery feeds.',
    },
    'site.standard.document': {
        site: 'Points to a publication record (`at://`) or a publication url (`https://`) for loose documents. Avoid trailing slashes.',
        path: 'Combine with `site` or publication `url` to construct a canonical URL to the document. Prepend with a leading slash.',
        title: 'Title of the document.',
        description: 'A brief description or excerpt from the document.',
        coverImage: 'Image to used for thumbnail or cover image. Less than 1MB is size.',
        content: 'Open union used to define the record\'s content. Each entry must specify a `$type` and may be extended with other lexicons to support additional content formats.',
        textContent: 'Plaintext representation of the documents contents. Should not contain markdown or other formatting.',
        bskyPostRef: 'Strong reference to a Bluesky post. Useful to keep track of comments off-platform.',
        tags: 'Array of strings used to tag or categorize the document. Avoid prepending tags with hashtags.',
        links: 'Open union describing relationships between this document and external resources.',
        labels: 'Self-label values for this document. Effectively content warnings.',
        contributors: 'List of additional contributors to this document.',
        publishedAt: 'Timestamp of the documents publish time.',
        updatedAt: 'Timestamp of the documents last edit.',
    },
    'site.standard.document#contributor': {
        did: 'DID of the contributor.',
        role: 'Role of the contributor (ex: `editor`, `translator`).',
        displayName: 'Optional display name override for the contributor.',
    },
    'site.standard.graph.subscription': {
        publication: 'AT-URI reference to the publication record being subscribed to.',
        createdAt: 'Timestamp marking when the subscription was created.',
    },
    'site.standard.graph.recommend': {
        document: 'AT-URI reference to the document record being recommended.',
        createdAt: 'Timestamp marking when the recommend was created.',
    },
}

// Helper to get override for a specific property
export function getDescriptionOverride(
    lexiconId: string,
    defName: string | null,
    propertyName: string
): string | undefined {
    const key = defName && defName !== 'main' ? `${lexiconId}#${defName}` : lexiconId
    return DESCRIPTION_OVERRIDES[key]?.[propertyName]
}

// Override property display order
// Format: "lexiconId" or "lexiconId#defName" -> [propertyNames in desired order]
// Properties not listed will appear after in their original order

export const PROPERTY_ORDER: Record<string, string[]> = {
    'site.standard.publication': [
        'url',
        'icon',
        'name',
        'description',
        'basicTheme',
        'labels',
        'preferences',
    ],
    'site.standard.document': [
        'site',
        'path',
        'title',
        'description',
        'coverImage',
        'content',
        'textContent',
        'bskyPostRef',
        'tags',
        'links',
        'labels',
        'contributors',
        'publishedAt',
        'updatedAt',
    ],
    'site.standard.document#contributor': [
        'did',
        'role',
        'displayName',
    ],
    'site.standard.graph.subscription': [
        'publication',
        'createdAt',
    ],
    'site.standard.graph.recommend': [
        'document',
        'createdAt',
    ],
    'site.standard.theme.basic': [
        'background',
        'foreground',
        'accent',
        'accentForeground',
    ],
}

// Helper to get property order for a lexicon/def
export function getPropertyOrder(
    lexiconId: string,
    defName: string | null
): string[] | undefined {
    const key = defName && defName !== 'main' ? `${lexiconId}#${defName}` : lexiconId
    return PROPERTY_ORDER[key]
}
