/**
 * UPLC (Untyped Plutus Lambda Calculus) Module
 *
 * Effect Schema-based types and transformations for UPLC programs.
 * Implements the Flat serialization format used by Plutus Core.
 *
 * @since 2.0.0
 * @module
 */
import { Equal, FastCheck, Hash, Inspectable, Schema } from "effect";
import * as CBOR from "./CBOR.js";
import * as Data from "./Data.js";
declare const UPLCError_base: new <A extends Record<string, any> = {}>(args: import("effect/Types").Equals<A, {}> extends true ? void : { readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }) => import("effect/Cause").YieldableError & {
    readonly _tag: "UPLCError";
} & Readonly<A>;
/**
 * Error class for UPLC related operations.
 *
 * @since 2.0.0
 * @category errors
 */
export declare class UPLCError extends UPLCError_base<{
    message?: string;
    cause?: unknown;
}> {
}
/**
 * Semantic version for UPLC programs.
 *
 * @since 2.0.0
 * @category model
 */
export type SemVer = `${number}.${number}.${number}`;
/**
 * Parse version components from SemVer string.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const parseSemVer: (v: SemVer) => {
    major: number;
    minor: number;
    patch: number;
};
/**
 * Create a SemVer string.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const makeSemVer: (major: number, minor: number, patch: number) => SemVer;
/**
 * All builtin functions supported in Plutus V3.
 * Order is significant - index is used in flat encoding.
 *
 * @since 2.0.0
 * @category constants
 */
export declare const BuiltinFunctions: readonly ["addInteger", "subtractInteger", "multiplyInteger", "divideInteger", "quotientInteger", "remainderInteger", "modInteger", "equalsInteger", "lessThanInteger", "lessThanEqualsInteger", "appendByteString", "consByteString", "sliceByteString", "lengthOfByteString", "indexByteString", "equalsByteString", "lessThanByteString", "lessThanEqualsByteString", "sha2_256", "sha3_256", "blake2b_256", "verifyEd25519Signature", "appendString", "equalsString", "encodeUtf8", "decodeUtf8", "ifThenElse", "chooseUnit", "trace", "fstPair", "sndPair", "chooseList", "mkCons", "headList", "tailList", "nullList", "chooseData", "constrData", "mapData", "listData", "iData", "bData", "unConstrData", "unMapData", "unListData", "unIData", "unBData", "equalsData", "mkPairData", "mkNilData", "mkNilPairData", "serialiseData", "verifyEcdsaSecp256k1Signature", "verifySchnorrSecp256k1Signature", "bls12_381_G1_add", "bls12_381_G1_neg", "bls12_381_G1_scalarMul", "bls12_381_G1_equal", "bls12_381_G1_hashToGroup", "bls12_381_G1_compress", "bls12_381_G1_uncompress", "bls12_381_G2_add", "bls12_381_G2_neg", "bls12_381_G2_scalarMul", "bls12_381_G2_equal", "bls12_381_G2_hashToGroup", "bls12_381_G2_compress", "bls12_381_G2_uncompress", "bls12_381_millerLoop", "bls12_381_mulMlResult", "bls12_381_finalVerify", "keccak_256", "blake2b_224", "integerToByteString", "byteStringToInteger", "andByteString", "orByteString", "xorByteString", "complementByteString", "readBit", "writeBits", "replicateByte", "shiftByteString", "rotateByteString", "countSetBits", "findFirstSetBit", "ripemd_160"];
export type BuiltinFunction = (typeof BuiltinFunctions)[number];
/**
 * Primitive UPLC data types.
 *
 * @since 2.0.0
 * @category model
 */
export type PrimitiveDataType = "Integer" | "ByteString" | "String" | "Unit" | "Bool" | "Data";
/**
 * UPLC data type (recursive for pair/list).
 *
 * @since 2.0.0
 * @category model
 */
export type DataType = PrimitiveDataType | {
    readonly pair: readonly [DataType, DataType];
} | {
    readonly list: DataType;
};
/**
 * Type tags for flat encoding.
 *
 * @since 2.0.0
 * @category constants
 */
export declare const DataTypeTags: {
    readonly Integer: 0;
    readonly ByteString: 1;
    readonly String: 2;
    readonly Unit: 3;
    readonly Bool: 4;
    readonly Data: 8;
};
/**
 * Value types for UPLC constants.
 *
 * @since 2.0.0
 * @category model
 */
export type ConstantValue = bigint | Uint8Array | string | boolean | null | {
    readonly items: ReadonlyArray<ConstantValue>;
} | {
    readonly index: bigint;
    readonly fields: ReadonlyArray<ConstantValue>;
} | ReadonlyMap<ConstantValue, ConstantValue>;
/**
 * Term tags for flat encoding.
 *
 * @since 2.0.0
 * @category constants
 */
export declare const TermTags: {
    readonly Var: 0;
    readonly Delay: 1;
    readonly Lambda: 2;
    readonly Apply: 3;
    readonly Constant: 4;
    readonly Force: 5;
    readonly Error: 6;
    readonly Builtin: 7;
    readonly Constr: 8;
    readonly Case: 9;
};
/**
 * UPLC Term - recursive union type.
 * Uses de Bruijn indices (bigint) for variable names.
 *
 * @since 2.0.0
 * @category model
 */
export type Term = {
    readonly type: "Var";
    readonly name: bigint;
} | {
    readonly type: "Lambda";
    readonly name: bigint;
    readonly body: Term;
} | {
    readonly type: "Apply";
    readonly function: Term;
    readonly argument: Term;
} | {
    readonly type: "Constant";
    readonly valueType: DataType;
    readonly value: ConstantValue;
} | {
    readonly type: "Builtin";
    readonly function: BuiltinFunction;
} | {
    readonly type: "Delay";
    readonly term: Term;
} | {
    readonly type: "Force";
    readonly term: Term;
} | {
    readonly type: "Constr";
    readonly tag: bigint;
    readonly terms: ReadonlyArray<Term>;
} | {
    readonly type: "Case";
    readonly term: Term;
    readonly cases: ReadonlyArray<Term>;
} | {
    readonly type: "Error";
};
/**
 * Encoded Term type (for Schema transformation).
 *
 * @since 2.0.0
 * @category model
 */
export type TermEncoded = {
    readonly type: "Var";
    readonly name: string;
} | {
    readonly type: "Lambda";
    readonly name: string;
    readonly body: TermEncoded;
} | {
    readonly type: "Apply";
    readonly function: TermEncoded;
    readonly argument: TermEncoded;
} | {
    readonly type: "Constant";
    readonly valueType: DataType;
    readonly value: ConstantValue;
} | {
    readonly type: "Builtin";
    readonly function: BuiltinFunction;
} | {
    readonly type: "Delay";
    readonly term: TermEncoded;
} | {
    readonly type: "Force";
    readonly term: TermEncoded;
} | {
    readonly type: "Constr";
    readonly tag: string;
    readonly terms: ReadonlyArray<TermEncoded>;
} | {
    readonly type: "Case";
    readonly term: TermEncoded;
    readonly cases: ReadonlyArray<TermEncoded>;
} | {
    readonly type: "Error";
};
declare const Program_base: Schema.Class<Program, {
    version: Schema.refine<string, typeof Schema.String>;
    body: Schema.suspend<Term, TermEncoded, never>;
}, Schema.Struct.Encoded<{
    version: Schema.refine<string, typeof Schema.String>;
    body: Schema.suspend<Term, TermEncoded, never>;
}>, never, {
    readonly body: Term;
} & {
    readonly version: string;
}, {}, {}>;
/**
 * UPLC Program - contains version and body term.
 *
 * @since 2.0.0
 * @category model
 */
export declare class Program extends Program_base {
    /**
     * Get the version as parsed components.
     */
    get versionParsed(): {
        major: number;
        minor: number;
        patch: number;
    };
    toJSON(): {
        _tag: "UPLC.Program";
        version: string;
        body: unknown;
    };
    toString(): string;
    [Inspectable.NodeInspectSymbol](): unknown;
    [Equal.symbol](that: unknown): boolean;
    [Hash.symbol](): number;
}
/**
 * Schema for UPLC Term (recursive union).
 *
 * @since 2.0.0
 * @category schemas
 */
export declare const TermSchema: Schema.Schema<Term, TermEncoded>;
/**
 * Transform from flat-encoded bytes to Program.
 *
 * @since 2.0.0
 * @category schemas
 */
export declare const FromFlatBytes: Schema.transform<typeof Schema.Uint8ArrayFromSelf, Schema.SchemaClass<Program, Program, never>>;
/**
 * Transform from flat-encoded hex string to Program.
 *
 * @since 2.0.0
 * @category schemas
 */
export declare const FromFlatHex: Schema.transform<Schema.Schema<Uint8Array<ArrayBufferLike>, string, never>, Schema.SchemaClass<Program, Program, never>>;
/**
 * Decode a UPLC program from flat-encoded bytes.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const fromFlatBytes: (i: Uint8Array<ArrayBufferLike>, overrideOptions?: import("effect/SchemaAST").ParseOptions) => Program;
/**
 * Decode a UPLC program from flat-encoded hex string.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const fromFlatHex: (i: string, overrideOptions?: import("effect/SchemaAST").ParseOptions) => Program;
/**
 * Encode a UPLC program to flat-encoded bytes.
 *
 * @since 2.0.0
 * @category encoding
 */
export declare const toFlatBytes: (a: Program, overrideOptions?: import("effect/SchemaAST").ParseOptions) => Uint8Array<ArrayBufferLike>;
/**
 * Encode a UPLC program to flat-encoded hex string.
 *
 * @since 2.0.0
 * @category encoding
 */
export declare const toFlatHex: (a: Program, overrideOptions?: import("effect/SchemaAST").ParseOptions) => string;
/**
 * Decode a UPLC program from double CBOR-encoded hex string.
 * This is the format used by compiled Plutus scripts.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const fromDoubleCborEncodedHex: (hex: string) => Program;
/**
 * Create a variable term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const varTerm: (name: bigint) => Term;
/**
 * Create a lambda term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const lambdaTerm: (name: bigint, body: Term) => Term;
/**
 * Create an application term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const applyTerm: (fn: Term, argument: Term) => Term;
/**
 * Create a constant term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const constantTerm: (valueType: DataType, value: ConstantValue) => Term;
/**
 * Create a builtin term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const builtinTerm: (fn: BuiltinFunction) => Term;
/**
 * Create a delay term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const delayTerm: (term: Term) => Term;
/**
 * Create a force term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const forceTerm: (term: Term) => Term;
/**
 * Create a constructor term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const constrTerm: (tag: bigint, terms: ReadonlyArray<Term>) => Term;
/**
 * Create a case term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const caseTerm: (term: Term, cases: ReadonlyArray<Term>) => Term;
/**
 * Create an error term.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const errorTerm: Term;
/**
 * FastCheck arbitrary for generating simple UPLC programs.
 *
 * @since 2.0.0
 * @category arbitrary
 */
export declare const simpleTermArbitrary: FastCheck.Arbitrary<Term>;
/**
 * FastCheck arbitrary for generating UPLC programs.
 *
 * @since 2.0.0
 * @category arbitrary
 */
export declare const arbitrary: FastCheck.Arbitrary<Program>;
/**
 * Apply single CBOR encoding to a hex string if not already encoded.
 * Wraps the bytes in a CBOR bytestring.
 *
 * @since 2.0.0
 * @category cbor
 */
export declare const applySingleCborEncoding: (script: string) => string;
/**
 * Apply double CBOR encoding to a hex string if not already encoded.
 * Wraps the bytes in two layers of CBOR bytestring.
 *
 * @since 2.0.0
 * @category cbor
 */
export declare const applyDoubleCborEncoding: (script: string) => string;
/**
 * Get the CBOR encoding level of a script.
 *
 * @since 2.0.0
 * @category cbor
 */
export declare const getCborEncodingLevel: (script: string) => "double" | "single" | "none";
/**
 * Decode a double CBOR-encoded script hex to flat bytes.
 *
 * @since 2.0.0
 * @category internal
 */
export declare const decodeDoubleCborHexToFlat: (hex: string) => Uint8Array;
/**
 * Decode a CBOR-encoded script to UPLC Program.
 * Handles both single and double CBOR encoding automatically.
 *
 * @since 2.0.0
 * @category parsing
 */
export declare const fromCborHexToProgram: (hex: string) => Program;
/**
 * Create a UPLC Constant term from PlutusData.
 * The data is CBOR-encoded and stored as a constant of type Data.
 *
 * Uses Aiken-compatible encoding (indefinite-length arrays/maps) by default,
 * which matches the on-chain format. An optional `options` parameter allows
 * customizing the CBOR encoding for testing or compatibility purposes.
 *
 * @since 2.0.0
 * @category constructors
 */
export declare const dataConstant: (data: Data.Data, options?: CBOR.CodecOptions) => Term;
/**
 * Applies a list of parameters (PlutusData values) to a Plutus script.
 *
 * The function takes a CBOR-encoded script and applies each parameter by wrapping
 * the script body in a series of Application nodes, where each parameter is
 * converted to a UPLC Constant of type Data.
 *
 * Uses Aiken-compatible encoding (indefinite-length arrays/maps) by default.
 * Pass custom CBOR options for compatibility with other encoding formats.
 *
 * @since 2.0.0
 * @category script
 */
export declare const applyParamsToScript: (plutusScript: string, params: ReadonlyArray<Data.Data>, options?: CBOR.CodecOptions) => string;
/**
 * Applies a list of parameters (PlutusData values) to a Plutus script,
 * with an optional schema for type-safe parameter conversion.
 *
 * @since 2.0.0
 * @category script
 */
export declare const applyParamsToScriptWithSchema: <T>(plutusScript: string, params: ReadonlyArray<T>, toData: (value: T) => Data.Data) => string;
export {};
//# sourceMappingURL=UPLC.d.ts.map