# generated by datamodel-codegen:
#   filename:  ConvertRequest-schema.json
#   timestamp: 2025-11-24T20:11:47+00:00

# Procedure:
# 1. Generate from schema:
#  datamodel-codegen \
# --input ../cimg-api/src/main/resources/schema/ConvertRequest-schema.json
# --input-file-type jsonschema
# --output src/orgjax/pyjit/model/convert.py
# --output-model-type dataclasses.dataclass
#
# 2. Remove classes such as StorageKey and Protocol, instead import them from dao.py
# 3. Change the main request to inherit from AbstractRequest
# 4. Make sure that the defaults from ../templates.py are the same.

from __future__ import annotations

from dataclasses import dataclass
from enum import Enum
from typing import List, Optional

from ..dao import StorageKey, AbstractRequest
from . import Info


class Option(Enum):
    debug = "debug"
    stich = "stich"
    separate = "separate"
    merge = "merge"
    expand = "expand"
    bigtiff = "bigtiff"
    nobigtiff = "nobigtiff"
    cache = "cache"
    nogroup = "nogroup"
    nolookup = "nolookup"
    autoscale = "autoscale"
    version = "version"
    noupgrade = "noupgrade"
    padded = "padded"
    nosas = "nosas"
    novalid = "novalid"
    validate = "validate"
    precompressed = "precompressed"
    overwrite = "overwrite"
    showinf = "showinf"


class Compression(Enum):
    Uncompressed = "Uncompressed"
    JPEG = "JPEG"
    JPEG2000 = "JPEG2000"
    Lossy = "Lossy"
    LZW = "LZW"
    zlib = "zlib"


@dataclass
class Point:
    x: float
    y: float


@dataclass
class Dimension:
    width: float
    height: float


@dataclass
class ConvertRequest(AbstractRequest):

    info: Optional[str] = Info.CONVERT

    useGeoJson: Optional[bool] = False
    info: Optional[Info] = None
    options: Optional[List[Option]] = None
    cmd: Optional[str] = None
    inFile: Optional[str] = None
    uploadDir: Optional[StorageKey] = None
    outFile: Optional[str] = None
    compression: Optional[Compression] = None
    series: Optional[int] = None
    cacheDir: Optional[str] = None
    map: Optional[str] = None
    range: Optional[List[int]] = None
    crop: Optional[Rectangle] = None
    manualRegions: Optional[List[Polygon]] = None
    channel: Optional[int] = None
    z: Optional[int] = None
    timepoint: Optional[int] = None
    option: Optional[List[str]] = None
    tilex: Optional[int] = None
    tiley: Optional[int] = None
    pyramidScale: Optional[int] = None
    swap: Optional[str] = None
    fill: Optional[int] = None
    pyramidResolutions: Optional[int] = None


@dataclass
class Rectangle:
    x: float
    y: float
    width: float
    height: float
    empty: bool
    minX: float
    minY: float
    maxX: float
    maxY: float
    centerX: float
    centerY: float
    bounds2D: Optional[Rectangle2D] = None
    location: Optional[Point] = None
    size: Optional[Dimension] = None


@dataclass
class Rectangle2D:
    minX: float
    minY: float
    maxX: float
    maxY: float
    centerX: float
    centerY: float
    x: float
    y: float
    width: float
    height: float
    empty: bool
    bounds2D: Optional[Rectangle2D] = None
    bounds: Optional[Rectangle] = None


@dataclass
class Polygon:
    npoints: int
    xpoints: Optional[List[int]] = None
    ypoints: Optional[List[int]] = None
    bounds: Optional[Rectangle] = None
    boundingBox: Optional[Rectangle] = None
    bounds2D: Optional[Rectangle2D] = None
