/**
 * Backblaze B2 provider config (S3-compatible API).
 * Reads ZEN_STORAGE_* environment variables.
 *
 * Endpoint format: s3.<region>.backblazeb2.com (e.g. s3.us-west-004.backblazeb2.com)
 */

export function getConfig() {
  const host            = process.env.ZEN_STORAGE_ENDPOINT;
  const region          = process.env.ZEN_STORAGE_REGION;
  const accessKeyId     = process.env.ZEN_STORAGE_ACCESS_KEY;
  const secretAccessKey = process.env.ZEN_STORAGE_SECRET_KEY;
  const bucket          = process.env.ZEN_STORAGE_BUCKET;

  if (!host || !accessKeyId || !secretAccessKey) {
    throw new Error(
      'Backblaze B2 credentials are not configured. Please set ZEN_STORAGE_ENDPOINT, ZEN_STORAGE_ACCESS_KEY, and ZEN_STORAGE_SECRET_KEY.'
    );
  }
  if (!bucket) {
    throw new Error('ZEN_STORAGE_BUCKET environment variable is not set.');
  }
  if (!region) {
    throw new Error('ZEN_STORAGE_REGION environment variable is not set.');
  }

  return { accessKeyId, secretAccessKey, bucket, host, region };
}
