import '../../../../assert/js/assert.js';
import '../../../../globals.js';
/**
 * Abstract supertype for layout constraints. Provides a lot of assistance to layout handling, including adding/removing
 * listeners, and reentrancy detection/loop prevention.
 *
 * We'll also handle reentrancy somewhat specially. If code tries to enter a layout reentrantly (while a layout is
 * already executing), we'll instead IGNORE this second one (and set a flag). Once our first layout is done, we'll
 * attempt to run the layout again. In case the subtype needs to lock multiple times (if a layout is FORCED), we have
 * an integer count of how many "layout" calls we're in (_layoutLockCount). Once this reaches zero, we're effectively
 * unlocked and not inside any layout calls.
 *
 * NOTE: This can still trigger infinite loops nominally (if every layout call triggers another layout call), but we
 * have a practical assertion limit that will stop this and flag it as an error.
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import TEmitter from '../../../../axon/js/TEmitter.js';
import { HeightSizableNode, LayoutProxy, Node, SizableNode, WidthSizableNode } from '../../imports.js';
export default abstract class LayoutConstraint {
    readonly ancestorNode: Node;
    private _layoutLockCount;
    private _layoutAttemptDuringLock;
    private _enabled;
    protected readonly _updateLayoutListener: () => void;
    private readonly _listenedNodes;
    readonly finishedLayoutEmitter: TEmitter;
    /**
     * (scenery-internal)
     */
    protected constructor(ancestorNode: Node);
    /**
     * Adds listeners to a Node, so that our layout updates will happen if this Node's Properties
     * (bounds/visibility/minimum size) change. Will be cleared on disposal of this type.
     * (scenery-internal)
     *
     * @param node
     * @param addLock - If true, we'll mark the node as having this layout constraint as responsible for its layout.
     * It will be an assertion failure if another layout container tries to lock the same node (so that we don't run into
     * infinite loops where multiple constraints try to move a node back-and-forth).
     * See Node's _activeParentLayoutConstraint for more information.
     */
    addNode(node: Node, addLock?: boolean): void;
    /**
     * (scenery-internal)
     */
    removeNode(node: Node): void;
    /**
     * NOTE: DO NOT call from places other than super.layout() in overridden layout() OR from the existing call in
     *       updateLayout(). Doing so would break the lock mechanism.
     * NOTE: Cannot be marked as abstract due to how mixins work
     */
    protected layout(): void;
    /**
     * (scenery-internal)
     */
    get isLocked(): boolean;
    /**
     * Locks the layout, so that automatic layout will NOT be triggered synchronously until unlock() is called and
     * the lock count returns to 0. This is set up so that if we trigger multiple reentrancy, we will only attempt to
     * re-layout once ALL of the layouts are finished.
     * (scenery-internal)
     */
    lock(): void;
    /**
     * Unlocks the layout. Generally (but not always), updateLayout() or updateLayoutAutomatically() should be called
     * after this, as locks are generally used for this purpose.
     * (scenery-internal)
     */
    unlock(): void;
    /**
     * Here for manual validation (say, in the devtools) - While some layouts are going on, this may not be correct, so it
     * could not be added to post-layout validation.
     * (scenery-internal)
     */
    validateLocalPreferredWidth(layoutContainer: WidthSizableNode): void;
    /**
     * Here for manual validation (say, in the devtools) - While some layouts are going on, this may not be correct, so it
     * could not be added to post-layout validation.
     * (scenery-internal)
     */
    validateLocalPreferredHeight(layoutContainer: HeightSizableNode): void;
    /**
     * Here for manual validation (say, in the devtools) - While some layouts are going on, this may not be correct, so it
     * could not be added to post-layout validation.
     * (scenery-internal)
     */
    validateLocalPreferredSize(layoutContainer: SizableNode): void;
    /**
     * Updates the layout of this constraint. Called automatically during initialization, when children change (if
     * resize is true), or when client wants to call this public method for any reason.
     */
    updateLayout(): void;
    /**
     * Called when we attempt to automatically layout components. (scenery-internal)
     */
    updateLayoutAutomatically(): void;
    /**
     * Creates a LayoutProxy for a unique trail from our ancestorNode to this Node (or null if that's not possible)
     * (scenery-internal)
     */
    createLayoutProxy(node: Node): LayoutProxy | null;
    get enabled(): boolean;
    set enabled(value: boolean);
    /**
     * Releases references
     */
    dispose(): void;
}
//# sourceMappingURL=LayoutConstraint.d.ts.map