package p.studio.workspaces.assets.messages.events;

import p.packer.messages.AssetReference;
import p.studio.controls.banks.StudioAssetCapacitySeverity;
import p.studio.lsp.events.StudioEvent;

import java.util.Objects;

public record StudioAssetBankCompositionCapacityChangedEvent(
        AssetReference assetReference,
        double progress,
        StudioAssetCapacitySeverity severity,
        boolean blocked,
        String labelText,
        String hintText) implements StudioEvent {

    public StudioAssetBankCompositionCapacityChangedEvent {
        Objects.requireNonNull(assetReference, "assetReference");
        severity = severity == null ? StudioAssetCapacitySeverity.GREEN : severity;
        if (progress < 0.0d || progress > 1.0d) {
            throw new IllegalArgumentException("progress must be in the 0..1 range");
        }
        labelText = Objects.requireNonNullElse(labelText, "");
        hintText = Objects.requireNonNullElse(hintText, "");
    }
}
