///
///
import type { QuerableProps } from "../queries/types.js";
import type { ChildTrait } from "./child.js";
/**
* @category Parent
*/
export declare function isParent(entity: unknown): entity is ParentTrait;
export type ChildAddedHandler = (child: ChildTrait) => void;
export type ChildRemovedHandler = (idx: number) => void;
/**
* @category Parent
*/
export declare const hasChildren: (entity: unknown) => boolean;
/**
* @ignore
*/
export declare const getKnownConstructor: (entity: ChildTrait) => AnyClass;
/**
* **Important trait**
*
* Entity will behave as container to hold all other entities with `ChildTrait`.
*
* Has many methods for adding, fetching, removing and manipulating order of children.
*
* Can behave as:
*
* - an array - all children are indexed next to each other
* - a map - there can be empty spaces between children
*
* @category Trait
*/
export declare class ParentTrait {
/**
* ChildTrait object -> its constructor's name
* Also good spot to count all children
* @category ParentTrait
*/
childrenPointers: Map;
/**
* Used by [ChildTrait.`isInteractive`](/api/server/classes/ChildTrait#isInteractive).
*
* If set to true, will prevent its direct children from getting interaction events.
*
* @category ParentTrait
*/
hijacksInteractionTarget: boolean;
/**
* @default Infinity
* @category ParentTrait
*/
maxChildren: number;
/**
* How children and their indexes behave when added into or removed from this parent.
* - array: there can be no empty spots, children will always move to fill in the gaps
* - map: no automatic movement is performed, adding to first empty spot,
* otherwise you need to ensure given spot isn't occupied
* @default "array"
* @category ParentTrait
*/
collectionBehaviour: "array" | "map";
childAdded: ChildAddedHandler;
childRemoved: ChildRemovedHandler;
removeChild(child: ChildTrait): boolean;
removeChildAt(idx: number): boolean;
/**
* Adds new item.
* @param entity
*/
addChild(entity: ChildTrait): void;
/**
* Adds new item.
* @param entity
* @param prepen squeeze into the first place, moving other children away.
*/
addChild(entity: ChildTrait, prepend: boolean): void;
/**
* Adds new item.
* @param entity
* @param atIndex squeeze into desired spot, moving other children away.
*/
addChild(entity: ChildTrait, atIndex: number): void;
/**
* Adds new item.
*/
addChild(entity: ChildTrait, arg1: boolean | number): void;
addChildren(entities: ChildTrait[]): void;
/**
* In array, moves child to target idx, rearranging everything between `from` and `to`.
* In map, swaps children at `from` and `to` (for now...)
* @param from index of child to move
* @param to desired target position
*/
moveChildTo(from: number, to: number): void;
/**
* Number of child elements
*/
countChildren(): number;
/**
* Gets all direct children in array form, "sorted" by idx
*/
getChildren(): T[];
/**
* Get one direct child of `parent` by its `idx`
*/
getChild(idx: number): T;
/**
* Get the element with highest 'idx' value
*/
getTop(): T;
/**
* Get the element with the lowest 'idx' value
*/
getBottom(): T;
/**
* For map behaviour, seeks out first available spot, starting from index 0.
* Arrays don't have gaps, so first "available" spot is always after last child.
* @returns index of first vacant spot, or -1 if no spot is available
*/
getFirstEmptySpot(): number;
/**
* unused?
*/
getLastEmptySpot(): number;
/**
* unused?
*/
getClosestEmptySpot(index: number): number;
/**
* Does index fit in range of this container.
* Doesn't check if index is occupied.
* Considering `maxChildren` and if index is negative or otherwise invalid.
* @param index
*/
indexFits(index: number): boolean;
/**
* Find one item matching props.
* @param props
*/
query(props: QuerableProps): T | undefined;
/**
* Looks for every matching entity here and deeper
*/
queryAll(props: QuerableProps): T[];
/**
* Takes care of manipulating indexes, and updating every internal things
* related to children spot movements
* @param where direction and range. (+1) - one up, (-2) - two in direction of array start
* @param start left-most child to manipulate
* @param end rightmost child, omit to have only one child moved
*/
protected move(where: number, start: number, end?: number): IndexUpdate[];
}