import {ChatUser, DefaultMessage, MediaEntity} from '@modules/chats/interfaces';
import {Screens} from '@shared/constants';

export type CameraMediaSource = 'camera' | 'cameraGallery';

export type ChatsStackParamList = {
  [Screens.CHATS_HOME]: undefined;
  [Screens.CHAT_MESSAGES]: {
    /**
     * Conversation id
     */
    id: string;
    /**
     * Initial message to show in the input box on first render
     */
    initialMessage?: string;
  };
  [Screens.CHATS_NEW]: undefined;
  [Screens.CHATS_NEW_GROUP]: {
    isGroupCreation?: boolean;
  };
  [Screens.CHATS_NEW_GROUP_NAME]: {users: ChatUser[]};
  [Screens.CHATS_IMAGE_VIEWER]: {
    messageId: string;
    initialAssetId: number;
    senderId: number;
    channel: string;
  };
  [Screens.CHAT_MESSAGE_INFO]: {message: DefaultMessage};
  [Screens.NEW_CAMERA]: {
    /**
     * Called as soon as the user produces a media item — taken with the
     * camera, picked from the gallery, or tapped in the inline carousel.
     * Starts the upload pipeline immediately so compression and upload
     * run in parallel with the preview screen.
     *
     * Returns a promise that resolves to `{ok: true}` once the pipeline
     * has accepted the entity into the upload state, or `{ok: false}` if
     * the pipeline rejected it (size limit, attachment count, etc.). The
     * camera awaits this before letting the user confirm so we don't end
     * up committing a caption for an item that never made it in.
     */
    onMediaPicked: (
      item: MediaEntity,
      source: CameraMediaSource,
    ) => Promise<{ok: boolean}>;
    /**
     * Called when the user accepts the preview. The entity is already in
     * the upload pipeline — this just commits the caption + analytics.
     */
    onMediaConfirmed: (
      item: MediaEntity,
      caption: string,
      source: CameraMediaSource,
    ) => void;
    /**
     * Called when the user backs out of the preview. Removes the entity
     * from the upload state and signals the pipeline to drop any remaining
     * compression / upload work for it.
     */
    onMediaCanceled: (itemId: string) => void;
    conversationUserName: string;
    totalFilesBytes: number;
    hasMicrophonePermission: boolean;
  };
  [Screens.CHATS_CHAT_INFO]: {id: string};
};
