import { Effect, Layer, Logger, LogLevel } from "effect";
import * as EffectRuntime from "../../../EffectRuntime.js";
import * as AddSigner from "../operations/AddSigner.js";
import * as Attach from "../operations/Attach.js";
import * as AttachMetadata from "../operations/AttachMetadata.js";
import * as Collect from "../operations/Collect.js";
import * as Governance from "../operations/Governance.js";
import * as Mint from "../operations/Mint.js";
import * as Pay from "../operations/Pay.js";
import * as Pool from "../operations/Pool.js";
import * as Propose from "../operations/Propose.js";
import * as ReadFrom from "../operations/ReadFrom.js";
import * as SendAll from "../operations/SendAll.js";
import * as Stake from "../operations/Stake.js";
import * as Validity from "../operations/Validity.js";
import * as Vote from "../operations/Vote.js";
import * as BuilderBuild from "./build.js";
const debugLayer = /*#__PURE__*/Layer.merge(Logger.pretty, /*#__PURE__*/Logger.minimumLogLevel(LogLevel.Debug));
const withDebugLogging = (effect, debug) => debug ? effect.pipe(Effect.provide(debugLayer)) : effect;
export const makeTxBuilder = config => {
  const programs = [];
  const txBuilder = {
    payToAddress: params => {
      programs.push(Pay.createPayToAddressProgram(params));
      return txBuilder;
    },
    collectFrom: params => {
      programs.push(Collect.createCollectFromProgram(params));
      return txBuilder;
    },
    sendAll: params => {
      programs.push(SendAll.createSendAllProgram(params));
      return txBuilder;
    },
    mintAssets: params => {
      programs.push(Mint.createMintAssetsProgram(params));
      return txBuilder;
    },
    readFrom: params => {
      programs.push(ReadFrom.createReadFromProgram(params));
      return txBuilder;
    },
    attachScript: params => {
      programs.push(Attach.attachScriptToState(params.script));
      return txBuilder;
    },
    registerStake: params => {
      programs.push(Stake.createRegisterStakeProgram(params));
      return txBuilder;
    },
    deregisterStake: params => {
      programs.push(Stake.createDeregisterStakeProgram(params));
      return txBuilder;
    },
    delegateTo: params => {
      programs.push(Stake.createDelegateToProgram(params));
      return txBuilder;
    },
    delegateToPool: params => {
      programs.push(Stake.createDelegateToPoolProgram(params));
      return txBuilder;
    },
    delegateToDRep: params => {
      programs.push(Stake.createDelegateToDRepProgram(params));
      return txBuilder;
    },
    delegateToPoolAndDRep: params => {
      programs.push(Stake.createDelegateToPoolAndDRepProgram(params));
      return txBuilder;
    },
    withdraw: params => {
      programs.push(Stake.createWithdrawProgram(params));
      return txBuilder;
    },
    registerAndDelegateTo: params => {
      programs.push(Stake.createRegisterAndDelegateToProgram(params));
      return txBuilder;
    },
    registerDRep: params => {
      programs.push(Governance.createRegisterDRepProgram(params));
      return txBuilder;
    },
    updateDRep: params => {
      programs.push(Governance.createUpdateDRepProgram(params));
      return txBuilder;
    },
    deregisterDRep: params => {
      programs.push(Governance.createDeregisterDRepProgram(params));
      return txBuilder;
    },
    authCommitteeHot: params => {
      programs.push(Governance.createAuthCommitteeHotProgram(params));
      return txBuilder;
    },
    resignCommitteeCold: params => {
      programs.push(Governance.createResignCommitteeColdProgram(params));
      return txBuilder;
    },
    registerPool: params => {
      programs.push(Pool.createRegisterPoolProgram(params));
      return txBuilder;
    },
    retirePool: params => {
      programs.push(Pool.createRetirePoolProgram(params));
      return txBuilder;
    },
    setValidity: params => {
      programs.push(Validity.createSetValidityProgram(params));
      return txBuilder;
    },
    vote: params => {
      programs.push(Vote.createVoteProgram(params));
      return txBuilder;
    },
    propose: params => {
      programs.push(Propose.createProposeProgram(params));
      return txBuilder;
    },
    addSigner: params => {
      programs.push(AddSigner.createAddSignerProgram(params));
      return txBuilder;
    },
    attachMetadata: params => {
      programs.push(AttachMetadata.createAttachMetadataProgram(params));
      return txBuilder;
    },
    compose: other => {
      const otherPrograms = other.getPrograms();
      if (otherPrograms.length > 0) {
        programs.push(...otherPrograms);
      }
      return txBuilder;
    },
    getPrograms: () => [...programs],
    buildEffect: options => BuilderBuild.makeBuild(config, programs, options),
    build: options => EffectRuntime.runEffectPromise(withDebugLogging(BuilderBuild.makeBuild(config, programs, options), options?.debug)),
    buildEither: options => EffectRuntime.runEffectPromise(withDebugLogging(BuilderBuild.makeBuild(config, programs, options).pipe(Effect.either), options?.debug))
  };
  return txBuilder;
};
//# sourceMappingURL=factory.js.map