import React from "react";
import { TouchableOpacity, Image, NativeModules, Platform } from "react-native";
import { ImageBubbleStyle } from "./ImageBubbleStyle";
const { FileManager, ImageManager } = NativeModules;
export const CometChatImageBubble = (props) => {
    const { thumbnailUrl, imageUrl, onPress, placeHolderImage, style } = props;
    const _style = new ImageBubbleStyle(style || {});
    const { backgroundColor, border, borderRadius, height, width } = _style;
    const getFileName = (url) => {
        return (url.substring(url.lastIndexOf("/") + 1));
    };
    const openImage = () => {
        let url;
        if (typeof imageUrl == "object") {
            url = imageUrl.uri;
        }
        if (onPress) {
            onPress(imageUrl);
        }
        Platform.OS == 'ios' ?
            FileManager.openFile(url, `${getFileName(url)}_${new Date().getTime()}.png`, (s) => { }) :
            ImageManager.openImage(url, s => { });
    };
    return (<TouchableOpacity onPress={openImage} activeOpacity={1}>

            <Image resizeMode={Platform.OS == "android" ? "cover" : "contain"} loadingIndicatorSource={placeHolderImage} source={thumbnailUrl ?? imageUrl} style={{
            height, width,
            backgroundColor,
            borderRadius,
            ...border
        }}/>
        </TouchableOpacity>);
};
//# sourceMappingURL=CometChatImageBubble.js.map