//
//  TSAIListPhoto.swift
//  KittensTravelNotes
//
//  Created by 100Years on 2025/7/5.
//

import ObjectMapper
class TSAIListPhotoGeneratorModel {
    var upLoadImage:UIImage
    var generatorStyle:TSGeneratorStyle
    var expandEdge:UIEdgeInsets
    var expandViewSizes:(CGSize,CGSize)?
    var additionalPrompt:String//追加的提示词
    
    //上传多张图片
    var upLoadImages:[UIImage]?
    
    init(upLoadImage: UIImage,
         generatorStyle: TSGeneratorStyle,
         expandEdge:UIEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0),
         expandViewSizes:(CGSize,CGSize)? = nil,
         additionalPrompt:String = "",
         upLoadImages:[UIImage]? = nil
    ) {
        self.upLoadImage = upLoadImage
        self.generatorStyle = generatorStyle
        self.expandEdge = expandEdge
        self.expandViewSizes = expandViewSizes
        self.additionalPrompt = additionalPrompt
        self.upLoadImages = upLoadImages
    }
    
    var prompt:String = ""
    var inputText:String = ""
    var upLoadImageUrl:String?
    var upLoadImageUrls:[String] = []
    var model:String = ""   //决定生图的模型
}

let kie = "kie"                 //走kie--chatgpt
let volcengine = "volcengine"   //走火山引擎
let flux = "flux"               //走kie--flux

class TSGenerateModel: TSBaseModel {
    var imageName:String = ""
    var imageText:String = ""
    var prompt:String = ""
    var isVip:Bool = false
    var specialStyle:Int = 0 //0 普通类型,1 热门类型,2 新类型,3 max,
    var input:Bool = false   //是否输入框
    var model:String = ""       //走新的通道,根据内容确定
    var unionType:Int = 0 //聚合类型,相同的为一类
    var inputText:String = ""
    override func mapping(map: ObjectMapper.Map) {
        imageName               <- map["imageName"]
        imageText               <- map["imageText"]
        prompt                  <- map["prompt"]
        isVip                   <- map["isVip"]
        specialStyle            <- map["specialStyle"]
        input                   <- map["input"]
        model                   <- map["model"]
        unionType               <- map["unionType"]
        input                   <- map["input"]
    }
    

    static func create(prompt:String,model:String = kie) -> TSGenerateModel{
        let mdoel = TSGenerateModel()
        mdoel.prompt = prompt
        mdoel.model = model
        return mdoel
    }
    
    
    
//    init(imageName: String,
//         imageText: String,
//         prompt: String,
//         isVip: Bool,
//         specialStyle: Int,
//         input: Bool,
//         model: String,
//         unionType: Int) {
//        self.imageName = imageName
//        self.imageText = imageText
//        self.prompt = prompt
//        self.isVip = isVip
//        self.specialStyle = specialStyle
//        self.input = input
//        self.model = model
//        self.unionType = unionType
//    }
//    
//    required convenience public init?(json: [String : Any]) {
//        fatalError("init(json:) has not been implemented")
//    }
//    
//    required convenience public init?(map: ObjectMapper.Map) {
//        fatalError("init(map:) has not been implemented")
//    }
    
}

enum TSGeneratorStyle:String {
    case ptp = "ptp"
    
    var imageMaxKb:Int{
        switch self {
        case .ptp:
            return 5*1024
        default:
            return 10*1024
        }
    }
    
    var imageMaxBitSize:Int{
        switch self {
        case .ptp:
            return kUploadImageMaxBit10Size
        default:
            return kUploadImageMaxBit10Size
        }
    }
    
    var userDefaultsKey:String{
        return self.rawValue
    }
    
    var config:TSPlogUploadHintVC.Config{
        switch self {
        case .ptp:
            return .ptpConfig
        default:
            return .ptpConfig
        }
    }
}
