package io.synor.compute;

/**
 * Configuration for SynorCompute client.
 */
public class SynorConfig {
    private final String apiKey;
    private final String baseUrl;
    private final ProcessorType defaultProcessor;
    private final Precision defaultPrecision;
    private final Priority defaultPriority;
    private final int timeoutMs;
    private final boolean debug;

    private SynorConfig(Builder builder) {
        this.apiKey = builder.apiKey;
        this.baseUrl = builder.baseUrl;
        this.defaultProcessor = builder.defaultProcessor;
        this.defaultPrecision = builder.defaultPrecision;
        this.defaultPriority = builder.defaultPriority;
        this.timeoutMs = builder.timeoutMs;
        this.debug = builder.debug;
    }

    public String getApiKey() {
        return apiKey;
    }

    public String getBaseUrl() {
        return baseUrl;
    }

    public ProcessorType getDefaultProcessor() {
        return defaultProcessor;
    }

    public Precision getDefaultPrecision() {
        return defaultPrecision;
    }

    public Priority getDefaultPriority() {
        return defaultPriority;
    }

    public int getTimeoutMs() {
        return timeoutMs;
    }

    public boolean isDebug() {
        return debug;
    }

    public static Builder builder(String apiKey) {
        return new Builder(apiKey);
    }

    public static class Builder {
        private final String apiKey;
        private String baseUrl = "https://api.synor.io/compute/v1";
        private ProcessorType defaultProcessor = ProcessorType.AUTO;
        private Precision defaultPrecision = Precision.FP32;
        private Priority defaultPriority = Priority.NORMAL;
        private int timeoutMs = 30000;
        private boolean debug = false;

        public Builder(String apiKey) {
            if (apiKey == null || apiKey.isEmpty()) {
                throw new IllegalArgumentException("API key is required");
            }
            this.apiKey = apiKey;
        }

        public Builder baseUrl(String baseUrl) {
            this.baseUrl = baseUrl;
            return this;
        }

        public Builder defaultProcessor(ProcessorType processor) {
            this.defaultProcessor = processor;
            return this;
        }

        public Builder defaultPrecision(Precision precision) {
            this.defaultPrecision = precision;
            return this;
        }

        public Builder defaultPriority(Priority priority) {
            this.defaultPriority = priority;
            return this;
        }

        public Builder timeoutMs(int timeoutMs) {
            this.timeoutMs = timeoutMs;
            return this;
        }

        public Builder debug(boolean debug) {
            this.debug = debug;
            return this;
        }

        public SynorConfig build() {
            return new SynorConfig(this);
        }
    }
}
