import { MatrixEvent, Room } from "matrix-js-sdk";
import { AttachmentBatch } from "./attachment";
import { Proof, MediaMetadata, MediaInterventionFlags } from "./proof";

export type KeanuEventExtension = {
    isMxThread?: boolean;
    isChannelMessage?: boolean;
    isPinned?: boolean;
    parentThread?: MatrixEvent & KeanuEventExtension;
    replyEvent?: MatrixEvent & KeanuEventExtension;
    uploadBatch?: AttachmentBatch;
}

export type KeanuEvent = MatrixEvent & KeanuEventExtension;

export type EventAttachmentUrlType = "src" | "thumbnail";
export type EventAttachmentUrlData = {data: string, type: EventAttachmentUrlType};

export type EventAttachment = {
    event: KeanuEvent;
    name: string;
    src?: string;
    srcSize: number;
    srcProgress: number;
    srcPromise?: Promise<EventAttachmentUrlData>;
    thumbnail?: string;
    thumbnailProgress: number;
    thumbnailPromise?: Promise<EventAttachmentUrlData>;
    autoDownloadable: boolean;
    proof?: Proof;
    mediaInterventionFlags?: MediaInterventionFlags;
    mediaMetadata?: MediaMetadata;
    loadSrc: () => Promise<EventAttachmentUrlData>;
    loadThumbnail: () => Promise<EventAttachmentUrlData>;
    loadBlob: () => Promise<{data: Blob}>;
    release: (src: boolean, thumbnail: boolean) => void;
};


export type KeanuRoom = Room & {
    displayType: "im.keanu.room_type_default" | "im.keanu.room_type_voice" | "im.keanu.room_type_file" | "im.keanu.room_type_channel" | undefined;
}