import { ComponentType } from 'react';
import { c as ArtifactRecord, b as ArtifactLabelsOf, A as ArtifactCallbacksOf } from './types-GCkXbyFm.js';

/** Block-type discriminator constants. Mirrors the wire shape from io-server / shapes-agent. */
declare const blockTypes: {
    readonly TEXT: "TEXT";
    readonly ARTIFACT_REF: "ARTIFACT_REF";
};
/** Discriminator for content blocks. */
type BlockType = (typeof blockTypes)[keyof typeof blockTypes];
/** Plain-text content block — rendered as Markdown. */
interface TextBlockRecord {
    /** Block-type discriminator. */
    type: typeof blockTypes.TEXT;
    /** Type-specific data; kept as `payload` to match the wire shape 1:1. */
    payload: {
        /** The Markdown source for this text segment. */
        text: string;
    };
}
/**
 * Reference-to-an-artifact content block — dispatched to the per-type artifact component.
 *
 * The artifact-domain types (`ArtifactRecord`, `TableArtifactRecord`, etc.) live in
 * `@/components/artifacts/types` so the artifact layer can be consumed independently of the
 * block layer (e.g. by a future surface that renders an artifact outside chat). The block layer
 * imports them here to wrap an artifact in an `ARTIFACT_REF` block.
 *
 * `ArtifactRefBlockRecord` is a *distributed* union over `ArtifactRecord` branches — TS narrows
 * `labels` and `callbacks` to the slice matching `artifact.type` via `ArtifactLabelsOf<T>` /
 * `ArtifactCallbacksOf<T>`. Without this distribution, `Partial<ChartLabels | TableLabels>`
 * collapses to `Partial<ChartLabels> | Partial<TableLabels>` and TS accepts chart-only keys on
 * a TABLE block's payload (the discriminator becomes load-bearing only at runtime, not in the
 * type system).
 */
type ArtifactRefBlockRecord = ArtifactRecord extends infer TArtifact ? TArtifact extends ArtifactRecord ? {
    /** Block-type discriminator. */
    type: typeof blockTypes.ARTIFACT_REF;
    /** Type-specific data; kept as `payload` to match the wire shape 1:1. */
    payload: {
        /** The artifact's stable identifier, used for keying / future cross-message reuse. */
        artifactId: string;
        /** Inlined artifact metadata — clients fetch the underlying data via `artifact.protectedAsset.presignedUrl`. */
        artifact: TArtifact;
        /**
         * Optional consumer-supplied labels for the rendered artifact's action buttons + status
         * messages — a flat slice narrowed by `artifact.type`. NOT a wire field; the consumer
         * constructs this from their i18n layer when materialising the block-record from the
         * server payload, then passes the augmented block to `<Block>`. The dispatcher forwards
         * the slice directly to the matching renderer — no per-type key wrapping (the block
         * already carries the discriminator).
         *
         * TS catches cross-type assignments here: `block.payload.labels = { downloadCsv: 'X' }`
         * on a `TableArtifactRecord`-typed block is a type error because `downloadCsv` isn't a
         * `TableArtifactLabels` key.
         */
        labels?: Partial<ArtifactLabelsOf<TArtifact>>;
        /**
         * Optional side-effect callbacks for actions on the rendered artifact (e.g. `onDownload`).
         * Flat slice narrowed by `artifact.type` via `ArtifactCallbacksOf<T>`. NOT a wire field
         * — the consumer wires this once to bridge artifact actions to their analytics /
         * observability layer.
         */
        callbacks?: Partial<ArtifactCallbacksOf<TArtifact>>;
    };
} : never : never;
/** Discriminated union of all supported content blocks. Additive — new types extend this union. */
type BlockRecord = TextBlockRecord | ArtifactRefBlockRecord;
/** Props every concrete block component receives from the dispatcher. */
interface BlockComponentProps<TBlock extends BlockRecord = BlockRecord> {
    /** The block to render. */
    block: TBlock;
}
/** Per-block-type service — registry entry that pairs a discriminator with its concrete component. */
interface BlockService<TBlock extends BlockRecord = BlockRecord> {
    /** Discriminator value this service handles. */
    type: BlockType;
    /** React component that renders a block of this type. */
    Component: ComponentType<BlockComponentProps<TBlock>>;
    /**
     * Returns a plain-text or markdown string representation of this block suitable for clipboard
     * copy. Called by `copyMessageText` when the user clicks "copy message".
     *
     * - `TextBlockService`: returns `block.payload.text` verbatim (markdown preserved).
     * - `ArtifactRefBlockService`: delegates to `ArtifactServices[artifact.type].toClipboardText`.
     *   Falls back to `[Artifact: <title>]` when the artifact type has no registered component.
     *
     * Optional so external `BlockService` implementors don't break on upgrade — when omitted, the
     * aggregator treats the block as contributing the empty string (silently skipped). Implementations
     * must be pure, synchronous functions — no async, no hooks, no side effects.
     */
    toClipboardText?: (block: TBlock) => string;
}

export { type ArtifactRefBlockRecord as A, type BlockComponentProps as B, type TextBlockRecord as T, type BlockRecord as a, type BlockService as b, type BlockType as c, blockTypes as d };
