import { z } from 'zod';
import { type DesignBlockId, type DesignPageId, type BlockContentVersionId, type BlockOrderIndex, type NonEmptyReadonlyArray, type PageBlockSnapshot, type PageContentVersionId, type PublishedPageBlockSnapshot, type PublishedPageDesignVersionDataV1 } from './types';
import { type PageDesignIntent, type PageDesignIntentParseIssue } from './pageDesignIntent';
export type Result<TValue, TError> = Readonly<{
    kind: 'success';
    value: TValue;
}> | Readonly<{
    kind: 'failure';
    error: TError;
}>;
export type PageDesignAuthority = Readonly<{
    kind: 'canonical-theme-v2';
    pageVersionId: PageContentVersionId;
    state: PageDesignIntent;
}> | Readonly<{
    kind: 'absent';
}> | Readonly<{
    kind: 'invalid';
    issues: NonEmptyReadonlyArray<PageDesignIntentParseIssue>;
}>;
type PageDesignAuthorityBlocker = Readonly<{
    kind: 'blocked-missing-authority';
}> | Readonly<{
    kind: 'invalid-design-state';
    issues: NonEmptyReadonlyArray<PageDesignIntentParseIssue>;
}>;
export type PageDesignPublishBlocker = PageDesignAuthorityBlocker | Readonly<{
    kind: 'missing-published-block-content';
    snapshots: NonEmptyReadonlyArray<Exclude<PageBlockSnapshot, PublishedPageBlockSnapshot>>;
}>;
export type PageDesignPublishPlan = Readonly<{
    kind: 'publish-page-design';
    pageId: DesignPageId;
    pageVersionId: PageContentVersionId;
    state: PageDesignIntent;
    /** Persisted as content_versions.data for the page-owned published design row. */
    versionData: PublishedPageDesignVersionDataV1;
}>;
export type PageDesignRuntimePairingIssue = Readonly<{
    kind: 'missing-current-block';
    persisted: PublishedPageBlockSnapshot;
}> | Readonly<{
    kind: 'unexpected-current-block';
    current: PageBlockSnapshot;
}> | Readonly<{
    kind: 'current-missing-published-content';
    current: Exclude<PageBlockSnapshot, PublishedPageBlockSnapshot>;
}> | Readonly<{
    kind: 'published-content-mismatch';
    blockId: DesignBlockId;
    persistedContentVersionId: BlockContentVersionId;
    currentContentVersionId: BlockContentVersionId;
}> | Readonly<{
    kind: 'order-index-mismatch';
    blockId: DesignBlockId;
    persistedOrderIndex: BlockOrderIndex;
    currentOrderIndex: BlockOrderIndex;
}> | Readonly<{
    /**
     * Pairing is keyed by blockId. A kind change keeps block identity but marks
     * the published design snapshot stale until a new page design version is saved.
     */
    kind: 'block-kind-changed';
    blockId: DesignBlockId;
    persistedBlockKind: string;
    currentBlockKind: string;
}>;
export type PageDesignRuntimePairingPlan = Readonly<{
    kind: 'paired';
    versionData: PublishedPageDesignVersionDataV1;
    currentBlockSequence: readonly PublishedPageBlockSnapshot[];
}> | Readonly<{
    kind: 'stale';
    versionData: PublishedPageDesignVersionDataV1;
    currentBlockSequence: readonly PageBlockSnapshot[];
    issues: NonEmptyReadonlyArray<PageDesignRuntimePairingIssue>;
}>;
export type PageDesignSaveRevision = Readonly<{
    kind: 'absent';
}> | Readonly<{
    kind: 'draft' | 'published';
    contentVersionId: PageContentVersionId;
    updatedAt: string;
}>;
export type PageDesignSaveBlocker = Readonly<{
    kind: 'stale-page-design-revision';
    expected: PageDesignSaveRevision;
    actual: PageDesignSaveRevision;
}> | Readonly<{
    kind: 'invalid-design-state';
    issue: PageDesignIntentParseIssue;
}> | Readonly<{
    kind: 'missing-design-state';
}>;
export type PageDesignSavePlan = Readonly<{
    kind: 'save-page-design-draft';
    state: PageDesignIntent;
}>;
export declare const publishedPageBlockSnapshotSchema: z.ZodObject<{
    kind: z.ZodLiteral<"published-block-content">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
    contentVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>;
    identifier: z.ZodNullable<z.ZodString>;
    blockKind: z.ZodString;
    orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
}, z.core.$strict>;
export declare const draftPageBlockSnapshotSchema: z.ZodObject<{
    kind: z.ZodLiteral<"draft-block-content">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
    contentVersionId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>>;
    identifier: z.ZodNullable<z.ZodString>;
    blockKind: z.ZodString;
    orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
}, z.core.$strict>;
export declare const missingPageBlockSnapshotSchema: z.ZodObject<{
    kind: z.ZodLiteral<"missing-block-content">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
    identifier: z.ZodNullable<z.ZodString>;
    blockKind: z.ZodString;
    orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    reason: z.ZodEnum<{
        "new-block": "new-block";
        "deleted-content-version": "deleted-content-version";
        "unpublished-block": "unpublished-block";
    }>;
}, z.core.$strict>;
export declare const pageBlockSnapshotSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
    kind: z.ZodLiteral<"published-block-content">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
    contentVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>;
    identifier: z.ZodNullable<z.ZodString>;
    blockKind: z.ZodString;
    orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
}, z.core.$strict>, z.ZodObject<{
    kind: z.ZodLiteral<"draft-block-content">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
    contentVersionId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>>;
    identifier: z.ZodNullable<z.ZodString>;
    blockKind: z.ZodString;
    orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
}, z.core.$strict>, z.ZodObject<{
    kind: z.ZodLiteral<"missing-block-content">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
    identifier: z.ZodNullable<z.ZodString>;
    blockKind: z.ZodString;
    orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    reason: z.ZodEnum<{
        "new-block": "new-block";
        "deleted-content-version": "deleted-content-version";
        "unpublished-block": "unpublished-block";
    }>;
}, z.core.$strict>], "kind">;
type PageBlockSequenceOrderItem = Readonly<Pick<PageBlockSnapshot, 'blockId' | 'orderIndex'>>;
export declare function validatePageDesignBlockSequence(snapshots: readonly PageBlockSequenceOrderItem[]): void;
export declare const publishedPageDesignVersionDataV1Schema: z.ZodObject<{
    schemaVersion: z.ZodLiteral<1>;
    stage: z.ZodLiteral<"published">;
    pageId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignPageId, string>>;
    blockSequence: z.ZodArray<z.ZodObject<{
        kind: z.ZodLiteral<"published-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        contentVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    }, z.core.$strict>>;
}, z.core.$strict>;
export declare const draftPageDesignVersionDataV1Schema: z.ZodObject<{
    schemaVersion: z.ZodLiteral<1>;
    stage: z.ZodLiteral<"draft">;
    pageId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignPageId, string>>;
    blockSequence: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
        kind: z.ZodLiteral<"published-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        contentVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    }, z.core.$strict>, z.ZodObject<{
        kind: z.ZodLiteral<"draft-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        contentVersionId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    }, z.core.$strict>, z.ZodObject<{
        kind: z.ZodLiteral<"missing-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
        reason: z.ZodEnum<{
            "new-block": "new-block";
            "deleted-content-version": "deleted-content-version";
            "unpublished-block": "unpublished-block";
        }>;
    }, z.core.$strict>], "kind">>;
}, z.core.$strict>;
export declare const pageDesignVersionDataV1Schema: z.ZodDiscriminatedUnion<[z.ZodObject<{
    schemaVersion: z.ZodLiteral<1>;
    stage: z.ZodLiteral<"published">;
    pageId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignPageId, string>>;
    blockSequence: z.ZodArray<z.ZodObject<{
        kind: z.ZodLiteral<"published-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        contentVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    }, z.core.$strict>>;
}, z.core.$strict>, z.ZodObject<{
    schemaVersion: z.ZodLiteral<1>;
    stage: z.ZodLiteral<"draft">;
    pageId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignPageId, string>>;
    blockSequence: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
        kind: z.ZodLiteral<"published-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        contentVersionId: z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    }, z.core.$strict>, z.ZodObject<{
        kind: z.ZodLiteral<"draft-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        contentVersionId: z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<BlockContentVersionId, string>>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
    }, z.core.$strict>, z.ZodObject<{
        kind: z.ZodLiteral<"missing-block-content">;
        blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
        identifier: z.ZodNullable<z.ZodString>;
        blockKind: z.ZodString;
        orderIndex: z.ZodPipe<z.ZodNumber, z.ZodTransform<BlockOrderIndex, number>>;
        reason: z.ZodEnum<{
            "new-block": "new-block";
            "deleted-content-version": "deleted-content-version";
            "unpublished-block": "unpublished-block";
        }>;
    }, z.core.$strict>], "kind">>;
}, z.core.$strict>], "stage">;
export declare const contentVersionOwnerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
    kind: z.ZodLiteral<"block">;
    blockId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignBlockId, string>>;
}, z.core.$strict>, z.ZodObject<{
    kind: z.ZodLiteral<"entry">;
    entryId: z.ZodPipe<z.ZodString, z.ZodTransform<import("@riverbankcms/blocks").DesignEntryId, string>>;
}, z.core.$strict>, z.ZodObject<{
    kind: z.ZodLiteral<"page">;
    pageId: z.ZodPipe<z.ZodString, z.ZodTransform<DesignPageId, string>>;
}, z.core.$strict>], "kind">;
export declare function parsePageDesignAuthority(input: Readonly<{
    pageVersionId: PageContentVersionId;
    designState: unknown;
}>): PageDesignAuthority;
export declare function buildPageDesignPublishPlan(input: Readonly<{
    pageId: DesignPageId;
    authority: PageDesignAuthority;
    blockSequence: readonly PageBlockSnapshot[];
}>): Result<PageDesignPublishPlan, PageDesignPublishBlocker>;
export declare function buildPageDesignRuntimePairingPlan(input: Readonly<{
    versionData: PublishedPageDesignVersionDataV1;
    currentBlockSequence: readonly PageBlockSnapshot[];
}>): PageDesignRuntimePairingPlan;
export declare function buildPageDesignSavePlan(input: Readonly<{
    expectedRevision: PageDesignSaveRevision;
    currentRevision: PageDesignSaveRevision;
    designState: unknown;
}>): Result<PageDesignSavePlan, PageDesignSaveBlocker>;
export {};
