// @generated by flare-im-core-sdk-xtask
// Source: bindings/contract/events.json

/// Stable C event code -> contract id -> Tauri `im://*` name.
pub const EVENT_ROUTE_TABLE: &[(i32, &str, &str)] = &[
    (1001, "connection.connected", "im://connected"),
    (1002, "connection.disconnected", "im://disconnected"),
    (1003, "connection.reconnecting", "im://reconnecting"),
    (1004, "connection.state_changed", "im://state"),
    (
        1005,
        "connection.sync_state_changed",
        "im://sync_state_changed",
    ),
    (1006, "connection.server_error", "im://server_error"),
    (1007, "connection.kicked_off", "im://kicked_off"),
    (1008, "connection.token_expired", "im://token_expired"),
    (2001, "message.received", "im://message"),
    (2002, "message.received_batch", "im://message_batch"),
    (2003, "message.send_ack", "im://send_ack"),
    (2004, "message.send_failed", "im://send_failed"),
    (2005, "message.recalled", "im://message_recalled"),
    (2006, "message.typing", "im://typing"),
    (2007, "message.capability", "im://message_capability"),
    (2008, "message.edited", "im://message_edited"),
    (
        2009,
        "message.reaction_changed",
        "im://message_reaction_changed",
    ),
    (2010, "message.deleted", "im://message_deleted"),
    (2011, "message.read_receipt", "im://message_read_receipt"),
    (
        2021,
        "message.typing_aggregate",
        "im://message_typing_aggregate",
    ),
    (
        2012,
        "message.retention_scheduled",
        "im://message_retention_scheduled",
    ),
    (
        2013,
        "message.retention_expired",
        "im://message_retention_expired",
    ),
    (
        2014,
        "message.retention_purged",
        "im://message_retention_purged",
    ),
    (2015, "message.pinned", "im://message_pinned"),
    (2016, "message.unpinned", "im://message_unpinned"),
    (2017, "message.marked", "im://message_marked"),
    (2018, "message.unmarked", "im://message_unmarked"),
    (2019, "message.presence_changed", "im://presence_changed"),
    (2020, "message.custom", "im://message_custom_event"),
    (3001, "conversation.synced", "im://conversations_synced"),
    (3002, "conversation.created", "im://conversation_created"),
    (3003, "conversation.updated", "im://conversation_updated"),
    (
        3004,
        "conversation.unread_count_changed",
        "im://unread_count_changed",
    ),
    (3005, "conversation.deleted", "im://conversation_deleted"),
    (3501, "notification.received", "im://notification"),
    (4001, "sync.started", "im://sync_started"),
    (4002, "sync.finished", "im://sync_finished"),
    (4003, "sync.failed", "im://sync_failed"),
    (4004, "sync.progress", "im://sync_progress"),
    (4005, "sync.task_completed", "im://sync_completed"),
    (4006, "sync.state_changed", "im://sync_notify_state_changed"),
    (4007, "sync.resync_needed", "im://resync_needed"),
    (4008, "sync.readiness", "im://sync_readiness"),
    (6001, "view.updated", "im://view_updated"),
    (5001, "extension.event", "im://extension"),
];

pub fn contract_event_id_for_code(code: i32) -> Option<&'static str> {
    EVENT_ROUTE_TABLE
        .iter()
        .find(|(c, _, _)| *c == code)
        .map(|(_, id, _)| *id)
}

pub fn tauri_event_name_for_code(code: i32) -> Option<&'static str> {
    EVENT_ROUTE_TABLE
        .iter()
        .find(|(c, _, _)| *c == code)
        .map(|(_, _, name)| *name)
}
