package p.studio.workspaces.assets.tiled;

import java.util.List;
import java.util.Objects;

public record TiledTilesetDocument(
        String version,
        String tiledVersion,
        String name,
        int tileWidth,
        int tileHeight,
        int tileCount,
        int columns,
        List<TiledProperty> properties,
        List<TiledTilesetTile> tiles) {

    public TiledTilesetDocument {
        version = Objects.requireNonNullElse(version, "1.10");
        tiledVersion = Objects.requireNonNullElse(tiledVersion, "1.12.1");
        name = Objects.requireNonNull(name, "name").trim();
        properties = List.copyOf(Objects.requireNonNull(properties, "properties"));
        tiles = List.copyOf(Objects.requireNonNull(tiles, "tiles"));
        if (name.isBlank()) {
            throw new IllegalArgumentException("name must not be blank");
        }
    }
}
