#ifndef SERVICES_ASSISTANT_IMAGE_HANDLER_INTERFACE_H
#define SERVICES_ASSISTANT_IMAGE_HANDLER_INTERFACE_H

#include <string>

#include "assistant/intentdialoguemanager/dialoguemessage.h"

class ImageHandlerInterface {
public:
    virtual ~ImageHandlerInterface() = default;

    // TODO 这个接口返回值用处不大的话理应删除
    virtual DialogueData::CallSuccessIdentifier textToImage(const std::string &prompt) = 0;  // 文生图

    // 抠图
    virtual DialogueData::CallSuccessIdentifier imageMatting(const std::string &imagePath) = 0;

    // 二值化
    virtual DialogueData::CallSuccessIdentifier imageBinarization(const std::string &imagePath) = 0;

    void setTextToImageCallback(const DialogueCallback::TextToImageCallback &callback) {
        textToImageCallback_ = callback;
    }

    void setImageMattingCallback(const DialogueCallback::ImageMattingCallback &callback) {
        imageMattingCallback_ = callback;
    }

    void setImageBinarizationCallback(const DialogueCallback::ImageBinarizationCallback &callback) {
        imageBinarizationCallback_ = callback;
    }

    virtual std::string getFeedbackUrl(const std::string &imageModelName) = 0;

    virtual void stopImageMatting() = 0;
    virtual void stopImageBinarization() = 0;

protected:
    void callTextToImageCallback(const DialogueCallback::TextToImageResult &message) {
        if (textToImageCallback_ != nullptr) {
            textToImageCallback_(message);
        }
    }

    void callImageMattingCallback(const DialogueCallback::ImageMattingResult &result) {
        if (imageMattingCallback_ != nullptr) {
            imageMattingCallback_(result);
        }
    }

    void callImageBinarizationCallback(const DialogueCallback::ImageBinarizationResult &result) {
        if (imageBinarizationCallback_ != nullptr) {
            imageBinarizationCallback_(result);
        }
    }

protected:
    DialogueCallback::TextToImageCallback textToImageCallback_{nullptr};
    DialogueCallback::ImageMattingCallback imageMattingCallback_{nullptr};
    DialogueCallback::ImageBinarizationCallback imageBinarizationCallback_{nullptr};
};

#endif  // SERVICES_ASSISTANT_IMAGE_HANDLER_INTERFACE_H
