import { UmbraError } from './chunk-4TZVXB5G.js';
import { __name } from './chunk-7QVYU63E.js';

// src/arcium/errors.ts
var ComputationMonitorError = class extends UmbraError {
  static {
    __name(this, "ComputationMonitorError");
  }
  /** The monitoring stage where the failure occurred. */
  stage;
  /**
   * @param stage - The monitoring pipeline stage where the failure occurred.
   * @param message - A human-readable description of the error.
   * @param cause - The underlying error that caused this failure, if any.
   */
  constructor(stage, message, cause) {
    super(message, {
      code: `COMPUTATION_MONITOR_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "ComputationMonitorError";
    this.stage = stage;
  }
};
function isComputationMonitorError(error) {
  return error instanceof ComputationMonitorError;
}
__name(isComputationMonitorError, "isComputationMonitorError");

// src/solana/errors.ts
var InstructionError = class extends UmbraError {
  static {
    __name(this, "InstructionError");
  }
  /**
   * The name of the instruction that failed during construction or validation.
   *
   * @remarks
   * Matches the Anchor instruction name (camelCase), e.g. `"encryptedDeposit"`,
   * `"initUserAccount"`. May be `undefined` if the failing instruction could
   * not be identified at the throw site.
   */
  instructionName;
  /**
   * Creates a new `InstructionError`.
   *
   * @param message - Human-readable description of the instruction failure.
   * @param options - Optional structured metadata.
   * @param options.code - Error code string. Defaults to `"INSTRUCTION_ERROR"`.
   * @param options.instructionName - The name of the failing instruction.
   * @param options.context - Arbitrary key-value pairs for diagnostic context.
   * @param options.cause - The underlying error that caused this failure, if any.
   */
  constructor(message, options) {
    super(message, {
      code: options?.code ?? "INSTRUCTION_ERROR",
      ...options?.context !== void 0 && {
        context: options.context
      },
      ...options?.cause !== void 0 && {
        cause: options.cause
      }
    });
    this.name = "InstructionError";
    if (options?.instructionName !== void 0) {
      this.instructionName = options.instructionName;
    }
  }
};
var RpcError = class extends UmbraError {
  static {
    __name(this, "RpcError");
  }
  /**
   * The RPC endpoint URL that was called when the error occurred.
   *
   * @remarks
   * May be `undefined` if the endpoint was not known at the throw site (e.g.,
   * when the error originates deep within `@solana/kit` internals).
   */
  endpoint;
  /**
   * The HTTP status code returned by the RPC node, if applicable.
   *
   * @remarks
   * `undefined` for network-level failures (e.g., DNS resolution failure,
   * connection refused) where no HTTP response was received.
   */
  statusCode;
  /**
   * The JSON-RPC error code from the response body, if any.
   *
   * @remarks
   * Set when the RPC node returns a well-formed JSON-RPC error object with a
   * numeric `code` field. `undefined` for HTTP-level failures or when the node
   * returns a malformed response body.
   */
  rpcErrorCode;
  /**
   * Creates a new `RpcError`.
   *
   * @param message - Human-readable description of the RPC failure.
   * @param options - Optional structured metadata.
   * @param options.code - Error code string. Defaults to `"RPC_ERROR"`.
   * @param options.endpoint - The RPC endpoint URL that was called.
   * @param options.statusCode - HTTP status code from the response, if any.
   * @param options.rpcErrorCode - JSON-RPC error code from the response, if any.
   * @param options.context - Arbitrary key-value pairs for diagnostic context.
   * @param options.cause - The underlying error that caused this failure, if any.
   */
  constructor(message, options) {
    super(message, {
      code: options?.code ?? "RPC_ERROR",
      ...options?.context !== void 0 && {
        context: options.context
      },
      ...options?.cause !== void 0 && {
        cause: options.cause
      }
    });
    this.name = "RpcError";
    if (options?.endpoint !== void 0) {
      this.endpoint = options.endpoint;
    }
    if (options?.statusCode !== void 0) {
      this.statusCode = options.statusCode;
    }
    if (options?.rpcErrorCode !== void 0) {
      this.rpcErrorCode = options.rpcErrorCode;
    }
  }
};
var TransactionError = class extends UmbraError {
  static {
    __name(this, "TransactionError");
  }
  /**
   * The transaction signature, if available.
   *
   * @remarks
   * Base58-encoded signature string. Present when the transaction was submitted
   * to the network but failed during execution. Use this to look up the failed
   * transaction in a block explorer.
   */
  signature;
  /**
   * Simulation log output from the transaction preflight, if available.
   *
   * @remarks
   * Each entry in the array is one line of program log output (e.g.,
   * `"Program log: ..."` or `"Program <address> failed: ..."`). Anchor programs
   * emit error codes and names here when constraints are violated.
   */
  simulationLogs;
  /**
   * Creates a new `TransactionError`.
   *
   * @param message - Human-readable description of the transaction failure.
   * @param options - Optional structured metadata.
   * @param options.code - Error code string. Defaults to `"TRANSACTION_ERROR"`.
   * @param options.signature - Base58-encoded transaction signature, if available.
   * @param options.simulationLogs - Program log output from preflight simulation.
   * @param options.context - Arbitrary key-value pairs for diagnostic context.
   * @param options.cause - The underlying error that caused this failure, if any.
   */
  constructor(message, options) {
    super(message, {
      code: options?.code ?? "TRANSACTION_ERROR",
      ...options?.context !== void 0 && {
        context: options.context
      },
      ...options?.cause !== void 0 && {
        cause: options.cause
      }
    });
    this.name = "TransactionError";
    if (options?.signature !== void 0) {
      this.signature = options.signature;
    }
    if (options?.simulationLogs !== void 0) {
      this.simulationLogs = options.simulationLogs;
    }
  }
};
var TransactionSigningError = class extends TransactionError {
  static {
    __name(this, "TransactionSigningError");
  }
  /**
   * Whether the signing was explicitly rejected by the user.
   *
   * @remarks
   * `true` when the wallet UI presented a sign request and the user actively
   * clicked "Reject" or equivalent. `false` when the failure was due to a
   * technical issue (disconnected device, timeout, missing key).
   *
   * @defaultValue `false`
   */
  wasRejected;
  /**
   * The address of the signer that failed to produce a signature.
   *
   * @remarks
   * Base58-encoded public key string. May be `undefined` if the failing signer
   * could not be identified at the throw site.
   */
  signerAddress;
  /**
   * Creates a new `TransactionSigningError`.
   *
   * @param message - Human-readable description of the signing failure.
   * @param options - Optional structured metadata.
   * @param options.code - Error code string. Defaults to `"TRANSACTION_SIGNING_ERROR"`.
   * @param options.wasRejected - Whether the user deliberately rejected. Defaults to `false`.
   * @param options.signerAddress - Base58 address of the signer that failed.
   * @param options.signature - Transaction signature, if the transaction was partially signed.
   * @param options.context - Arbitrary key-value pairs for diagnostic context.
   * @param options.cause - The underlying error that caused this failure, if any.
   */
  constructor(message, options) {
    super(message, {
      code: options?.code ?? "TRANSACTION_SIGNING_ERROR",
      ...options?.signature !== void 0 && {
        signature: options.signature
      },
      ...options?.context !== void 0 && {
        context: options.context
      },
      ...options?.cause !== void 0 && {
        cause: options.cause
      }
    });
    this.name = "TransactionSigningError";
    this.wasRejected = options?.wasRejected ?? false;
    if (options?.signerAddress !== void 0) {
      this.signerAddress = options.signerAddress;
    }
  }
};
var MasterSeedSigningRejectedError = class extends TransactionSigningError {
  static {
    __name(this, "MasterSeedSigningRejectedError");
  }
  /**
   * Creates a new `MasterSeedSigningRejectedError`.
   *
   * @param message - Human-readable description. Defaults to a standard rejection
   *   message explaining that the user declined the required derivation signature.
   * @param options - Optional structured metadata.
   * @param options.signerAddress - Base58 address of the wallet that rejected.
   * @param options.context - Arbitrary key-value pairs for diagnostic context.
   * @param options.cause - The underlying error that caused this failure, if any.
   */
  constructor(message = "Master seed derivation was rejected. The user declined to sign the required message.", options) {
    super(message, {
      code: "MASTER_SEED_SIGNING_REJECTED",
      wasRejected: true,
      ...options?.signerAddress !== void 0 && {
        signerAddress: options.signerAddress
      },
      ...options?.context !== void 0 && {
        context: options.context
      },
      ...options?.cause !== void 0 && {
        cause: options.cause
      }
    });
    this.name = "MasterSeedSigningRejectedError";
  }
};
function isInstructionError(error) {
  return error instanceof InstructionError;
}
__name(isInstructionError, "isInstructionError");
function isRpcError(error) {
  return error instanceof RpcError;
}
__name(isRpcError, "isRpcError");
function isTransactionError(error) {
  return error instanceof TransactionError;
}
__name(isTransactionError, "isTransactionError");
function isTransactionSigningError(error) {
  return error instanceof TransactionSigningError;
}
__name(isTransactionSigningError, "isTransactionSigningError");

// src/umbra/errors.ts
var EncryptedDepositError = class extends UmbraError {
  static {
    __name(this, "EncryptedDepositError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `ENCRYPTED_DEPOSIT_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "EncryptedDepositError";
    this.stage = stage;
  }
};
function isEncryptedDepositError(error) {
  return error instanceof EncryptedDepositError;
}
__name(isEncryptedDepositError, "isEncryptedDepositError");
var EncryptedWithdrawalError = class extends UmbraError {
  static {
    __name(this, "EncryptedWithdrawalError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `ENCRYPTED_WITHDRAWAL_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "EncryptedWithdrawalError";
    this.stage = stage;
  }
};
function isEncryptedWithdrawalError(error) {
  return error instanceof EncryptedWithdrawalError;
}
__name(isEncryptedWithdrawalError, "isEncryptedWithdrawalError");
var RegistrationError = class extends UmbraError {
  static {
    __name(this, "RegistrationError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `REGISTRATION_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "RegistrationError";
    this.stage = stage;
  }
};
function isRegistrationError(error) {
  return error instanceof RegistrationError;
}
__name(isRegistrationError, "isRegistrationError");
var ConversionError = class extends UmbraError {
  static {
    __name(this, "ConversionError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `CONVERSION_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "ConversionError";
    this.stage = stage;
  }
};
function isConversionError(error) {
  return error instanceof ConversionError;
}
__name(isConversionError, "isConversionError");
var CreateUtxoError = class extends UmbraError {
  static {
    __name(this, "CreateUtxoError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `CREATE_UTXO_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "CreateUtxoError";
    this.stage = stage;
  }
};
function isCreateUtxoError(error) {
  return error instanceof CreateUtxoError;
}
__name(isCreateUtxoError, "isCreateUtxoError");
var FetchUtxosError = class extends UmbraError {
  static {
    __name(this, "FetchUtxosError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `FETCH_UTXOS_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "FetchUtxosError";
    this.stage = stage;
  }
};
function isFetchUtxosError(error) {
  return error instanceof FetchUtxosError;
}
__name(isFetchUtxosError, "isFetchUtxosError");
var ClaimUtxoError = class extends UmbraError {
  static {
    __name(this, "ClaimUtxoError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `CLAIM_UTXO_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "ClaimUtxoError";
    this.stage = stage;
  }
};
function isClaimUtxoError(error) {
  return error instanceof ClaimUtxoError;
}
__name(isClaimUtxoError, "isClaimUtxoError");
var QueryError = class extends UmbraError {
  static {
    __name(this, "QueryError");
  }
  stage;
  constructor(stage, message, cause) {
    super(message, {
      code: `QUERY_${stage.toUpperCase().replaceAll("-", "_")}`,
      cause
    });
    this.name = "QueryError";
    this.stage = stage;
  }
};
function isQueryError(error) {
  return error instanceof QueryError;
}
__name(isQueryError, "isQueryError");

export { ClaimUtxoError, ComputationMonitorError, ConversionError, CreateUtxoError, EncryptedDepositError, EncryptedWithdrawalError, FetchUtxosError, InstructionError, MasterSeedSigningRejectedError, QueryError, RegistrationError, RpcError, TransactionError, TransactionSigningError, isClaimUtxoError, isComputationMonitorError, isConversionError, isCreateUtxoError, isEncryptedDepositError, isEncryptedWithdrawalError, isFetchUtxosError, isInstructionError, isQueryError, isRegistrationError, isRpcError, isTransactionError, isTransactionSigningError };
//# sourceMappingURL=chunk-GP26R377.js.map
//# sourceMappingURL=chunk-GP26R377.js.map