import type { Codec } from './codec';
import type { DecodeMode, Decoder } from './decode';
import type { EncodeMode, Encoder } from './encode';
export type MetadataValue = bigint | boolean | null | number | string | undefined | {
    readonly [key: string]: MetadataValue;
} | readonly MetadataValue[];
export type KnownConstraint = {
    readonly kind: 'endsWith';
    readonly value: string;
} | {
    readonly kind: 'format';
    readonly value: 'email' | 'iso-datetime' | 'url' | 'uuid';
} | {
    readonly kind: 'integer';
} | {
    readonly kind: 'max';
    readonly value: bigint | number;
} | {
    readonly kind: 'maxLength';
    readonly value: number;
} | {
    readonly kind: 'min';
    readonly value: bigint | number;
} | {
    readonly kind: 'minLength';
    readonly value: number;
} | {
    readonly kind: 'multipleOf';
    readonly value: bigint | number;
} | {
    readonly flags: string;
    readonly kind: 'pattern';
    readonly source: string;
} | {
    readonly kind: 'startsWith';
    readonly value: string;
};
export type MetadataEffect = {
    readonly constraint: KnownConstraint;
    readonly kind: 'constraint';
} | {
    readonly async?: boolean;
    readonly helperName?: string | null;
    readonly helperText?: string | null;
    readonly kind: 'default';
    readonly opaque?: boolean;
    readonly value?: MetadataValue;
} | {
    readonly async: boolean;
    readonly effect: 'andThen' | 'factory' | 'preprocess' | 'refine' | 'transform' | 'via';
    readonly helperName?: string | null;
    readonly helperText?: string | null;
    readonly kind: 'opaque';
};
export type MetadataField = {
    readonly effects?: readonly MetadataEffect[];
    readonly localName: string;
    readonly node: string;
    readonly optional: boolean;
    readonly wireName: string;
};
type MetadataNodeBase = {
    readonly effects?: readonly MetadataEffect[];
};
export type MetadataNode = ({
    readonly kind: 'array';
    readonly element: string;
} & MetadataNodeBase) | ({
    readonly fields: readonly MetadataField[];
    readonly kind: 'object';
    readonly unknownKeys: 'passthrough' | 'strict' | 'strip';
} & MetadataNodeBase) | ({
    readonly kind: 'intersection';
    readonly members: readonly string[];
} & MetadataNodeBase) | ({
    readonly kind: 'literal';
    readonly value: boolean | null | number | string;
} & MetadataNodeBase) | ({
    readonly kind: 'null';
} & MetadataNodeBase) | ({
    readonly kind: 'opaque';
} & MetadataNodeBase) | ({
    readonly kind: 'option';
    readonly value: string;
} & MetadataNodeBase) | ({
    readonly kind: 'primitive';
    readonly primitive: 'bigint' | 'boolean' | 'number' | 'string';
} & MetadataNodeBase) | ({
    readonly key: 'string';
    readonly kind: 'record';
    readonly value: string;
} & MetadataNodeBase) | ({
    readonly kind: 'ref';
    readonly target: string;
} & MetadataNodeBase) | ({
    readonly err: string;
    readonly kind: 'result';
    readonly ok: string;
} & MetadataNodeBase) | ({
    readonly elements: readonly string[];
    readonly kind: 'tuple';
} & MetadataNodeBase) | ({
    readonly kind: 'undefined';
} & MetadataNodeBase) | ({
    readonly kind: 'union';
    readonly members: readonly string[];
} & MetadataNodeBase);
export type DirectionMetadata = {
    readonly mode: 'async' | 'sync';
    readonly nodes: Readonly<Record<string, MetadataNode>>;
    readonly root: string;
};
export type DeriveMetadata = {
    readonly decode?: DirectionMetadata;
    readonly encode?: DirectionMetadata;
    readonly name?: string | null;
};
type ModeValue = 'async' | 'sync';
type ModeProvider = ModeValue | (() => ModeValue);
export type __InternalFieldMetadata = {
    readonly effects?: readonly MetadataEffect[];
    readonly localName?: string;
    readonly wireName?: string;
};
type InternalMetadataField = {
    readonly effects?: readonly MetadataEffect[];
    readonly localName: string;
    readonly node: __InternalMetadataNode;
    readonly optional: boolean;
    readonly wireName: string;
};
type InternalNodeBase = {
    readonly effects?: readonly MetadataEffect[];
};
export type __InternalMetadataNode = ({
    readonly kind: 'array';
    readonly element: __InternalMetadataNode;
} & InternalNodeBase) | ({
    readonly fields: readonly InternalMetadataField[];
    readonly kind: 'object';
    readonly unknownKeys: 'passthrough' | 'strict' | 'strip';
} & InternalNodeBase) | ({
    readonly kind: 'intersection';
    readonly members: readonly __InternalMetadataNode[];
} & InternalNodeBase) | ({
    readonly kind: 'literal';
    readonly value: boolean | null | number | string;
} & InternalNodeBase) | ({
    readonly kind: 'null';
} & InternalNodeBase) | ({
    readonly kind: 'opaque';
} & InternalNodeBase) | ({
    readonly kind: 'option';
    readonly value: __InternalMetadataNode;
} & InternalNodeBase) | ({
    readonly kind: 'primitive';
    readonly primitive: 'bigint' | 'boolean' | 'number' | 'string';
} & InternalNodeBase) | ({
    readonly key: 'string';
    readonly kind: 'record';
    readonly value: __InternalMetadataNode;
} & InternalNodeBase) | ({
    readonly kind: 'ref';
    readonly target: () => __InternalMetadataNode;
} & InternalNodeBase) | ({
    readonly err: __InternalMetadataNode;
    readonly kind: 'result';
    readonly ok: __InternalMetadataNode;
} & InternalNodeBase) | ({
    readonly elements: readonly __InternalMetadataNode[];
    readonly kind: 'tuple';
} & InternalNodeBase) | ({
    readonly kind: 'undefined';
} & InternalNodeBase) | ({
    readonly kind: 'union';
    readonly members: readonly __InternalMetadataNode[];
} & InternalNodeBase);
export type __InternalDirectionMetadata = {
    readonly mode: ModeProvider;
    readonly root: __InternalMetadataNode;
};
// #[effects(add: [mut], unknown: [direct])]
export declare function metadataOf(value: Decoder<unknown, unknown, DecodeMode> | Encoder<unknown, unknown, unknown, EncodeMode> | Codec<unknown, unknown, unknown, unknown, DecodeMode, EncodeMode>): DeriveMetadata | null;
// #[effects(add: [mut], unknown: [direct])]
export declare function attachMetadata<T extends Decoder<unknown, unknown, DecodeMode> | Encoder<unknown, unknown, unknown, EncodeMode> | Codec<unknown, unknown, unknown, unknown, DecodeMode, EncodeMode>>(value: T, metadata: DeriveMetadata): T;
// #[effects(add: [mut])]
export declare function __attachDecodeMetadata<T extends object>(value: T, metadata: __InternalDirectionMetadata): T;
// #[effects(add: [mut])]
export declare function __attachEncodeMetadata<T extends object>(value: T, metadata: __InternalDirectionMetadata): T;
// #[effects(add: [mut])]
export declare function __attachName<T extends object>(value: T, name: string): T;
// #[effects(add: [])]
export declare function __decodeDirectionOf(value: unknown): __InternalDirectionMetadata | null;
// #[effects(add: [])]
export declare function __encodeDirectionOf(value: unknown): __InternalDirectionMetadata | null;
// #[effects(add: [], unknown: [direct])]
export declare function __decodeDirectionOrOpaque(value: unknown): __InternalDirectionMetadata;
// #[effects(add: [], unknown: [direct])]
export declare function __encodeDirectionOrOpaque(value: unknown): __InternalDirectionMetadata;
// #[effects(add: [mut])]
export declare function __setDecodeMode<T extends object>(value: T, mode: DecodeMode): T;
// #[effects(add: [mut])]
export declare function __setEncodeMode<T extends object>(value: T, mode: EncodeMode): T;
// #[effects(add: [], unknown: [direct])]
export declare function __decodeModeOf(value: unknown): DecodeMode | null;
// #[effects(add: [], unknown: [direct])]
export declare function __encodeModeOf(value: unknown): EncodeMode | null;
// #[effects(add: [mut])]
export declare function __setFieldMetadata<T extends object>(value: T, metadata: __InternalFieldMetadata): T;
// #[effects(add: [])]
export declare function __fieldMetadataOf(value: unknown): __InternalFieldMetadata | null;
// #[effects(add: [])]
export declare function __cloneNodeWithEffects(node: __InternalMetadataNode, effects: readonly MetadataEffect[]): __InternalMetadataNode;
// #[effects(add: [])]
export declare function __helperName(value: unknown): string | null;
// #[effects(add: [])]
export declare function __isAsyncCallable(value: unknown): boolean;
// #[effects(add: [], forward: [{ from: values.some }])]
export declare function __inferCallableMode(...values: readonly unknown[]): ModeValue;
// #[effects(add: [], unknown: [direct])]
export declare function __metadataValueOf(value: unknown): MetadataValue | null;
export {};
