import { ListQuery, ContentEntry, ContentInput, EntityRef, ContentVisibility } from '@platform-modules/content';
export { ContentEntry, ContentInput, ContentStatus, ContentVisibility, EntityRef, ListQuery } from '@platform-modules/content';
import * as react from 'react';
import { ConsentState, ConsentCategory } from '@platform-modules/content/privacy';
export { ConsentCategory, ConsentState } from '@platform-modules/content/privacy';

/**
 * Injected data seam for browser-side content authoring.
 * The consumer wires each method to its authenticated API route — identity is server-derived.
 */
interface ContentClient {
    list(query?: ListQuery): Promise<ContentEntry[]>;
    getBySlug(type: string, slug: string): Promise<ContentEntry | null>;
    put(input: ContentInput): Promise<ContentEntry>;
    publish(id: string): Promise<EntityRef>;
    schedule(id: string, at: string): Promise<EntityRef>;
    unpublish(id: string): Promise<EntityRef>;
    setVisibility(id: string, visibility: ContentVisibility): Promise<EntityRef>;
    trash(id: string): Promise<EntityRef>;
    restore(id: string): Promise<EntityRef>;
    remove(id: string): Promise<EntityRef>;
}

/** Typed boundary error when a workflow action requires a persisted entry id. */
declare class ContentEntryNotSavedError extends Error {
    readonly action: string;
    readonly name = "ContentEntryNotSavedError";
    constructor(action: string);
}
declare function isContentEntryNotSavedError(e: unknown): e is ContentEntryNotSavedError;

declare function useContentList(client: ContentClient, query?: ListQuery): {
    entries: ContentEntry[];
    loading: boolean;
    error: Error | null;
    reload: () => void;
};

declare function useContentEntry(client: ContentClient, ref: ContentEntry | null): {
    entry: ContentEntry | null;
    loading: boolean;
    error: Error | null;
    save: (input?: ContentInput) => Promise<ContentEntry | undefined>;
    publish: () => Promise<EntityRef | undefined>;
    schedule: (at: string) => Promise<EntityRef | undefined>;
    unpublish: () => Promise<EntityRef | undefined>;
    trash: () => Promise<EntityRef | undefined>;
    restore: () => Promise<EntityRef | undefined>;
    setVisibility: (visibility: ContentVisibility) => Promise<EntityRef | undefined>;
    remove: () => Promise<EntityRef | undefined>;
};
type UseContentEntryResult = ReturnType<typeof useContentEntry>;

type AutosaveState = 'idle' | 'saving' | 'saved' | 'error';
declare function useAutosave(save: (value: string) => Promise<unknown>, value: string, opts?: {
    delayMs?: number;
}): {
    state: AutosaveState;
};

interface ContentEditorFormProps {
    client: ContentClient;
    /** Edit an existing entry, or `null` for a new one. */
    entry: ContentEntry | null;
    onSaved?: (entry: ContentEntry) => void;
    className?: string;
}
declare function ContentEditorForm({ client, entry, onSaved, className }: ContentEditorFormProps): react.JSX.Element;

/**
 * Persistence seam for consent. Sync (localStorage/cookie are sync) — an async seam would force
 * loading-state complexity for an adapter that does not exist (YAGNI). Inject a custom impl for
 * cookie/server persistence; the default below uses localStorage.
 */
interface ConsentStorage {
    load(): string | null;
    save(value: string): void;
}
/**
 * Default localStorage-backed storage. LAZY: constructs with no `localStorage` access (safe to evaluate
 * as a default during SSR); touches `window.localStorage` only inside load()/save(), each guarded so a
 * SecurityError (storage disabled / private mode) degrades to null / no-op, never a throw.
 */
declare function createLocalStorageConsentStorage(key?: string): ConsentStorage;
interface UseConsentOptions {
    /** The CONFIGURED policy version. Stored consent whose version ≠ this is treated as absent (re-prompt). */
    version: string;
    /** Defaults to a localStorage-backed store. */
    storage?: ConsentStorage;
}
interface UseConsentResult {
    /** false during SSR + first client render; true after the mount effect (prevents hydration mismatch). */
    ready: boolean;
    /** version-matched stored consent, else null. */
    consent: ConsentState | null;
    save(categories: Record<ConsentCategory, boolean>): ConsentState;
    acceptAll(): ConsentState;
    rejectAll(): ConsentState;
}
declare function useConsent(options: UseConsentOptions): UseConsentResult;

interface ConsentBannerLabels {
    title?: string;
    description?: string;
    acceptAll?: string;
    rejectAll?: string;
    save?: string;
    policyLink?: string;
    categoryLabels?: Partial<Record<ConsentCategory, string>>;
}
interface ConsentBannerProps {
    version: string;
    storage?: ConsentStorage;
    /** NON-necessary categories shown. Default: analytics, marketing, preferences. */
    categories?: ConsentCategory[];
    policyHref?: string;
    labels?: ConsentBannerLabels;
    /** Controlled override for re-consent ("Manage cookies"). show = open ?? (ready && !consent). */
    open?: boolean;
    onChange?: (state: ConsentState) => void;
    className?: string;
}
declare function ConsentBanner({ version, storage, categories, policyHref, labels, open, onChange, className, }: ConsentBannerProps): react.JSX.Element | null;

export { type AutosaveState, ConsentBanner, type ConsentBannerLabels, type ConsentBannerProps, type ConsentStorage, type ContentClient, ContentEditorForm, type ContentEditorFormProps, ContentEntryNotSavedError, type UseConsentOptions, type UseConsentResult, type UseContentEntryResult, createLocalStorageConsentStorage, isContentEntryNotSavedError, useAutosave, useConsent, useContentEntry, useContentList };
