/**
 * slackRefreshBinding — the §10.5 (TOPIC-PROFILE-SPEC) Slack arm of
 * SessionRefresh: binding-resolution surface + conversation-key scheme.
 *
 * SessionRefresh was Telegram-only by construction (its binding lookup
 * returned `not_telegram_bound` for everything else). The kill-time half of
 * Slack continuity already exists in server bootstrap (`beforeSessionKill` →
 * `slackAdapter.saveChannelResume(routingKey, uuid, sessionName)`), so the
 * narrow gap is (a) resolving WHICH Slack conversation a session is bound to
 * and (b) a Slack-capable respawner callback. This module defines the
 * structural interfaces + key helpers; SessionRefresh consumes them.
 *
 * Conversation-key scheme (spec §10.5): the platform-agnostic key space is
 *   bare numeric            → Telegram topic id (back-compat)
 *   slack:<channel>[:<thread>] → Slack conversation
 * SlackAdapter's own routing key is `<channelId>` or `<channelId>:<thread_ts>`
 * — the slack:* conversation key is exactly that routing key behind the
 * `slack:` prefix.
 */
export const SLACK_CONVERSATION_KEY_PREFIX = 'slack:';
/** `<channelId>[:<thread_ts>]` routing key → `slack:<channel>[:<thread>]` (§10.5). */
export function slackConversationKey(routingKey) {
    return `${SLACK_CONVERSATION_KEY_PREFIX}${routingKey}`;
}
/** `slack:<channel>[:<thread>]` → routing key, or null when not a Slack key. */
export function parseSlackConversationKey(key) {
    if (!key.startsWith(SLACK_CONVERSATION_KEY_PREFIX))
        return null;
    const routingKey = key.slice(SLACK_CONVERSATION_KEY_PREFIX.length);
    return routingKey.length > 0 ? routingKey : null;
}
/**
 * Stable negative synthetic topic id for a Slack routing key.
 *
 * IDENTICAL hash to `server.ts:slackChannelToSyntheticId` and the inline copy
 * in `routes.ts` (build-event heartbeat) — sum-shift char hash, negated so it
 * can never collide with a (positive) Telegram topic id. RefreshResult keeps
 * a numeric `topicId` for back-compat consumers (e.g. the restart-all log
 * line reads result.topicId); Slack results carry this synthetic id so those
 * consumers stay type- and meaning-compatible with the rest of the system's
 * Slack↔numeric bridging (PresenceProxy, resume heartbeat).
 *
 * NOTE for the integrating session: this is now the THIRD copy of the hash —
 * consolidating server.ts + routes.ts onto this export is a wiring follow-up
 * (both files are owned by other builders in this round).
 */
export function slackRoutingKeySyntheticId(routingKey) {
    let hash = 0;
    for (let i = 0; i < routingKey.length; i++) {
        hash = ((hash << 5) - hash + routingKey.charCodeAt(i)) | 0;
    }
    return -(Math.abs(hash) + 1); // always negative, never 0
}
//# sourceMappingURL=slackRefreshBinding.js.map