import { Point } from '@vertexvis/geometry';
import type { DecodedPng } from 'fast-png';
import { DepthBuffer } from './depthBuffer';
import { FrameImageLike } from './frame';
import { ImageAttributesLike } from './frame';
/**
 * A value that represents if a pixel does not contain a stencil value.
 */
export declare const STENCIL_BUFFER_EMPTY_VALUE = 0;
/**
 * A value that represents if a pixel contains a feature.
 */
export declare const STENCIL_BUFFER_FEATURE_VALUE = 255;
/**
 * The `StencilBufferManager` manages the stencil buffer state for the viewer.
 * Stencil buffers are represented as images and contain additional information
 * related to the rendered frame. Examples of information contained within a
 * stencil buffer include: cross section and feature edge positions.
 *
 * This class contains methods for fetching a stencil buffer for the currently
 * rendered frame, as well as helpers that components can use to get an
 * up-to-date stencil buffer after any interactions are performed.
 */
export declare class StencilBufferManager {
    private viewer;
    private pendingStencilBuffer?;
    private pendingInteractionFinished?;
    private pendingInteractionFinishedResolver?;
    /**
     * Constructs a new stencil buffer manager.
     *
     * **Note:** This class is only intended to be constructed by a viewer.
     *
     * @param viewer The viewer for this manager.
     */
    constructor(viewer: HTMLVertexViewerElement);
    /**
     * Fetches a stencil buffer for the last rendered frame. Returns `undefined`
     * if the last frame does not have stencil information.
     */
    fetch(): Promise<StencilBuffer | undefined>;
    /**
     * Returns a promise that resolves with the last generated stencil buffer, or
     * fetches a new stencil buffer if the frame has changed since the last
     * stencil buffer was fetched. Because the stencil buffer is cached by the
     * manager, this method can be called multiple times without performing a
     * network request.
     *
     * @see {@link StencilBufferManager.latestAfterInteraction} to wait for
     * requesting a stencil buffer after an interaction has finished.
     */
    latest(): Promise<StencilBuffer | undefined>;
    /**
     * Returns a promise that resolves with the latest stencil buffer, once any
     * interaction is being performed. If no interaction is being performed, then
     * the promise will resolve immediately with the latest stencil buffer.
     *
     * This method is useful for components to fetch the most up-to-date stencil
     * buffer. Because the stencil buffer is cached by the manager, components can
     * call this method multiple times without performing a network request.
     *
     * @see {@link StencilBufferManager.latest} - used internally by this method.
     */
    latestAfterInteraction(): Promise<StencilBuffer | undefined>;
    private handleInteractionStarted;
    private handleInteractionFinished;
    private invalidateStencilBuffer;
}
/**
 * Represents a stencil buffer that is managed by `StencilBufferManager`.
 *
 * @see {@link StencilBufferManager} for fetching a stencil buffer.
 */
export declare class StencilBuffer implements FrameImageLike {
    readonly imageAttr: ImageAttributesLike;
    readonly imageBytes: Uint8Array;
    readonly pixelBytes: Uint8Array;
    readonly imageChannels: number;
    readonly depthBuffer: DepthBuffer;
    /**
     * Constructor.
     *
     * @param imageAttr The attributes of the stencil image.
     * @param imageBytes The original bytes for the image of the stencil buffer.
     * @param pixelBytes The PNG pixel data of the stencil buffer.
     * @param imageChannels The number of color channels.
     * @param depthBuffer The depth buffer associated with this stencil buffer.
     */
    constructor(imageAttr: ImageAttributesLike, imageBytes: Uint8Array, pixelBytes: Uint8Array, imageChannels: number, depthBuffer: DepthBuffer);
    /**
     * Constructs a new stencil buffer from a decoded PNG.
     *
     * @param png The decoded PNG.
     * @param imageAttr The attributes of the stencil image.
     * * @param imageBytes The original bytes for the image of the stencil buffer.
     * @param depthBuffer The depth buffer associated with this stencil buffer.
     */
    static fromPng(png: Pick<DecodedPng, 'data' | 'channels'>, imageAttr: ImageAttributesLike, imageBytes: Uint8Array, depthBuffer: DepthBuffer): StencilBuffer;
    /**
     * Returns the color at the given frame position.
     *
     * @param pt A position within the frame.
     * @returns A color at the given position, or `undefined` if the color matches
     * the stencil buffer's empty color.
     * @see {@link Viewport.transformPointToFrame} to convert a viewport position
     * to frame position.
     */
    getValue(pt: Point.Point): number;
    /**
     * Performs a hit test of the given point. Returns `true` if the point hits a
     * pixel in the stencil.
     *
     * @param pt A point within the stencil's frame.
     * @returns `true` if the point hits a pixel in the stencil, `false`
     * otherwise.
     */
    hitTest(pt: Point.Point): boolean;
    /**
     * Returns the colored pixel nearest to the given `pt`. This method is useful
     * for performing snapping operations. An optional predicate can be provided
     * to filter the pixels that are evaluated.
     *
     * @param pt A position within the frame.
     * @param radius The radius around `pt` to evaluate.
     * @param predicate An optional predicate. If unspecified, any non-black
     * pixels are considered.
     * @returns A point within radius that matches the given predicate.
     * @see {@link Viewport.transformPointToFrame} to convert a viewport position
     * to frame position.
     */
    snapToNearestPixel(pt: Point.Point, radius: number, predicate?: (value: number) => boolean): Point.Point;
}
