import { Effect } from "effect";
import * as MaestroEffect from "./internal/MaestroEffect.js";
/**
 * Maestro provider for Cardano blockchain data access.
 * Supports mainnet and testnet networks with API key authentication.
 * Features cursor-based pagination and optional turbo submit for faster transaction processing.
 * Implements rate limiting to respect Maestro API limits.
 *
 * @since 2.0.0
 * @category constructors
 */
export class MaestroProvider {
  baseUrl;
  apiKey;
  turboSubmit;
  effect;
  constructor(baseUrl, apiKey, turboSubmit = false) {
    this.baseUrl = baseUrl;
    this.apiKey = apiKey;
    this.turboSubmit = turboSubmit;
    this.effect = {
      getProtocolParameters: () => MaestroEffect.getProtocolParameters(this.baseUrl, this.apiKey),
      getUtxos: MaestroEffect.getUtxos(this.baseUrl, this.apiKey),
      getUtxosWithUnit: MaestroEffect.getUtxosWithUnit(this.baseUrl, this.apiKey),
      getUtxosByOutRef: MaestroEffect.getUtxosByOutRef(this.baseUrl, this.apiKey),
      getDelegation: MaestroEffect.getDelegation(this.baseUrl, this.apiKey),
      submitTx: MaestroEffect.submitTx(this.baseUrl, this.apiKey, this.turboSubmit),
      evaluateTx: MaestroEffect.evaluateTx(this.baseUrl, this.apiKey),
      getUtxoByUnit: MaestroEffect.getUtxoByUnit(this.baseUrl, this.apiKey),
      getDatum: MaestroEffect.getDatum(this.baseUrl, this.apiKey),
      awaitTx: MaestroEffect.awaitTx(this.baseUrl, this.apiKey)
    };
  }
  getProtocolParameters = () => Effect.runPromise(this.effect.getProtocolParameters());
  getUtxos = addressOrCredential => Effect.runPromise(this.effect.getUtxos(addressOrCredential));
  getUtxosWithUnit = (addressOrCredential, unit) => Effect.runPromise(this.effect.getUtxosWithUnit(addressOrCredential, unit));
  getUtxoByUnit = unit => Effect.runPromise(this.effect.getUtxoByUnit(unit));
  getUtxosByOutRef = outRefs => Effect.runPromise(this.effect.getUtxosByOutRef(outRefs));
  getDelegation = rewardAddress => Effect.runPromise(this.effect.getDelegation(rewardAddress));
  getDatum = datumHash => Effect.runPromise(this.effect.getDatum(datumHash));
  awaitTx = (txHash, checkInterval, timeout) => Effect.runPromise(this.effect.awaitTx(txHash, checkInterval, timeout));
  submitTx = cbor => Effect.runPromise(this.effect.submitTx(cbor));
  evaluateTx = (tx, additionalUTxOs) => Effect.runPromise(this.effect.evaluateTx(tx, additionalUTxOs));
}
/**
 * Pre-configured Maestro provider for Cardano mainnet.
 *
 * @since 2.0.0
 * @category constructors
 */
export const mainnet = (apiKey, turboSubmit = false) => new MaestroProvider("https://api.maestro.org/v1", apiKey, turboSubmit);
/**
 * Pre-configured Maestro provider for Cardano preprod testnet.
 *
 * @since 2.0.0
 * @category constructors
 */
export const preprod = (apiKey, turboSubmit = false) => new MaestroProvider("https://preprod.api.maestro.org/v1", apiKey, turboSubmit);
/**
 * Pre-configured Maestro provider for Cardano preview testnet.
 *
 * @since 2.0.0
 * @category constructors
 */
export const preview = (apiKey, turboSubmit = false) => new MaestroProvider("https://preview.api.maestro.org/v1", apiKey, turboSubmit);
//# sourceMappingURL=Maestro.js.map