import { CsatMessage, Message, QuickReplyMessage } from '@rasahq/chat-widget-sdk'; /** * sessionStorage key used to remember which CSAT prompt the user has already * answered. The value is a stable content hash of the prompt - not just a * boolean - so that a server-side replay of the same message after a refresh * is correctly recognised as already-answered, instead of being treated as a * fresh ask that re-opens the thumbs popup. */ export declare const CSAT_ANSWERED_HASH_STORAGE_KEY = "rasa-csat-answered-hash"; export type CsatLikeMessage = CsatMessage | QuickReplyMessage; export interface CsatPayloads { satisfied?: string; unsatisfied?: string; } /** * Inspects a buttons message and returns the CSAT option payloads when it is * a satisfaction request. Returns null when the message is a normal * quick-reply (i.e. its button text/payloads do not match the `satisfied` / * `unsatisfied` vocabulary). * * Pure function so we can unit-test the heuristic in isolation. */ export declare function detectCsatButtons(message: QuickReplyMessage): CsatPayloads | null; /** * Produces a stable content hash for a CSAT prompt that is robust to the * non-stable fields that vary between a fresh push and a server replay * (timestamps, sender, etc.). Two CSAT prompts with the same question and * the same option vocabulary will hash identically. */ export declare function getCsatMessageHash(message: CsatLikeMessage): string; interface StorageLike { getItem(key: string): string | null; setItem(key: string, value: string): void; removeItem(key: string): void; } /** * Returns true iff the provided CSAT prompt has already been answered in the * current browser tab (sessionStorage). The hash comparison means a server * replay of the same prompt after a page refresh is treated as * "already answered", which fixes the bug where the popup briefly re-appeared * after rating + refresh. */ export declare function isCsatAnsweredFor(message: CsatLikeMessage, storage?: StorageLike | null): boolean; export declare function markCsatAnswered(message: CsatLikeMessage, storage?: StorageLike | null): void; export declare function clearCsatAnswered(storage?: StorageLike | null): void; /** * Returns the index of the last non-divider message, or -1 when the history * only contains dividers (or is empty). Session dividers are transparent for * "is the popup still pending?" purposes because every page refresh appends * a new (often empty) session entry, which would otherwise push real bot * turns out of the "last message" slot from the second refresh onwards. */ export declare function findLastContentIndex(history: Message[]): number; export {};