import type {Gallery_Client_Performance, Json_Primitive, Json_Value} from "./gallery_types";

export function gallery_message(type: string, payload: Record<string, Json_Value> = {}): string {
    return JSON.stringify({category: "event", type, ...payload});
}
export function gallery_open_message(case_id: string, frame_mode: string): string {return gallery_message("gallery_open", {case: case_id, frame_mode});}
export function gallery_patch_message(target: string, patch: Record<string, Json_Value>): string {return gallery_message("gallery_patch", {target, patch});}
export function gallery_action_message(action: string, argument?: Json_Primitive): string {return gallery_message("gallery_action", argument === undefined ? {action} : {action, argument});}
export function gallery_metrics_payload(client_performance: Gallery_Client_Performance): Record<string, Json_Value> {return {client_metrics: client_performance as unknown as Record<string, Json_Value>};}
