package dev.photosync.core.config;

import lombok.Builder;

/** Look and memory budget of the timeline browser. */
@Builder(toBuilder = true)
public record BrowserSettings(int tileSize, int thumbnailCacheEntries, boolean showVideoBadge) {

    public static BrowserSettings defaults() {
        return BrowserSettings.builder()
                .tileSize(96)
                // Each cached tile is an uploaded GPU texture plus its decoded
                // bytes, so this is the single biggest memory knob in the mod.
                .thumbnailCacheEntries(256)
                .showVideoBadge(true)
                .build();
    }

    BrowserSettings normalized() {
        return toBuilder()
                .tileSize(Math.min(192, Math.max(48, tileSize)))
                .thumbnailCacheEntries(Math.min(2048, Math.max(32, thumbnailCacheEntries)))
                .build();
    }
}
