import { Effect } from "effect";
import * as BlockfrostEffect from "./internal/BlockfrostEffect.js";
/**
 * Blockfrost provider for Cardano blockchain data access.
 * Supports both mainnet and testnet networks with project-based authentication.
 * Implements rate limiting to respect Blockfrost API limits.
 *
 * @since 2.0.0
 * @category constructors
 */
export class BlockfrostProvider {
  effect;
  baseUrl;
  projectId;
  constructor(baseUrl, projectId) {
    this.baseUrl = baseUrl;
    this.projectId = projectId;
    this.effect = {
      getProtocolParameters: () => BlockfrostEffect.getProtocolParameters(baseUrl, projectId),
      getUtxos: BlockfrostEffect.getUtxos(baseUrl, projectId),
      getUtxosWithUnit: BlockfrostEffect.getUtxosWithUnit(baseUrl, projectId),
      getUtxoByUnit: BlockfrostEffect.getUtxoByUnit(baseUrl, projectId),
      getUtxosByOutRef: BlockfrostEffect.getUtxosByOutRef(baseUrl, projectId),
      getDelegation: BlockfrostEffect.getDelegation(baseUrl, projectId),
      getDatum: BlockfrostEffect.getDatum(baseUrl, projectId),
      awaitTx: BlockfrostEffect.awaitTx(baseUrl, projectId),
      submitTx: BlockfrostEffect.submitTx(baseUrl, projectId),
      evaluateTx: BlockfrostEffect.evaluateTx(baseUrl, projectId)
    };
  }
  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 Blockfrost provider for Cardano mainnet.
 *
 * @since 2.0.0
 * @category constructors
 */
export const mainnet = projectId => new BlockfrostProvider("https://cardano-mainnet.blockfrost.io/api/v0", projectId);
/**
 * Pre-configured Blockfrost provider for Cardano preprod testnet.
 *
 * @since 2.0.0
 * @category constructors
 */
export const preprod = projectId => new BlockfrostProvider("https://cardano-preprod.blockfrost.io/api/v0", projectId);
/**
 * Pre-configured Blockfrost provider for Cardano preview testnet.
 *
 * @since 2.0.0
 * @category constructors
 */
export const preview = projectId => new BlockfrostProvider("https://cardano-preview.blockfrost.io/api/v0", projectId);
/**
 * Create a custom Blockfrost provider with custom base URL.
 *
 * @since 2.0.0
 * @category constructors
 */
export const custom = (baseUrl, projectId) => new BlockfrostProvider(baseUrl, projectId);
//# sourceMappingURL=Blockfrost.js.map