/**
 * SubscriptionController — graph change subscription and watch logic.
 *
 * Extracted from subscribe.methods.js. Manages subscriber registration,
 * glob-filtered watches with optional polling, and deferred replay.
 *
 * @module domain/services/controllers/SubscriptionController
 */
import { type StateDiffResult } from '../state/StateDiff.ts';
import type { WarpState } from '../JoinReducer.ts';
/**
 * Callback shape for subscriber errors. Errors flow through the catch
 * binding and land here as `Error` — both WarpError (domain) and raw
 * Error instances propagated from infrastructure callbacks surface as
 * Error subtypes.
 */
export type SubscriberErrorHandler = (error: Error) => void;
/**
 * Change callback shape shared by `subscribe()` and `watch()`.
 */
export type SubscriberChangeHandler = (diff: StateDiffResult) => void;
interface SubscriptionHost {
    _cachedState: WarpState | null;
    _subscribers: Array<{
        onChange: SubscriberChangeHandler;
        onError?: SubscriberErrorHandler;
        pendingReplay?: boolean;
    }>;
    hasFrontierChanged(): Promise<boolean>;
}
type SchedulerFn = (callback: () => void, ms: number) => ReturnType<typeof setInterval>;
export default class SubscriptionController {
    _host: SubscriptionHost;
    private readonly _scheduler;
    constructor(host: SubscriptionHost, options?: {
        scheduler?: SchedulerFn;
    });
    /** Returns the scheduler, falling back to globalThis.setInterval at call time. */
    private _resolveScheduler;
    subscribe({ onChange, onError, replay }: {
        onChange: SubscriberChangeHandler;
        onError?: SubscriberErrorHandler;
        replay?: boolean;
    }): {
        unsubscribe: () => void;
    };
    watch(pattern: string | string[], { onChange, onError, poll }: {
        onChange: SubscriberChangeHandler;
        onError?: SubscriberErrorHandler;
        poll?: number;
    }): {
        unsubscribe: () => void;
    };
    _notifySubscribers(diff: StateDiffResult, currentState: WarpState): void;
}
export {};
