/**
 * @license
 * Copyright 2022-2026 Matter.js Authors
 * SPDX-License-Identifier: Apache-2.0
 */
import { ElementTag } from "#common/ElementTag.js";
import type { Model } from "./Model.js";
import type { ModelTreePosition } from "./ModelTreePosition.js";
/**
 * Children of a model.  This is a {@link Model} array with some specialization for model-specific operations.
 *
 * @template T the type of model that owns the children
 */
export interface Children<T extends Model = Model> extends Array<T> {
    /**
     * Add children.
     *
     * Operates like a standard array push but we adjust the type to allow insertion of elements as well as models.
     */
    push(...children: Model.TaggedDefinition<T>[]): number;
    /**
     * Array splice.
     *
     * Allows splicing in elements or models.
     */
    splice(index: number, deleteCount?: number, ...toAdd: Model.TaggedDefinition<T>[]): T[];
    /**
     * Access a model of specific type by ID or name.  This is an optimized operation that uses internal index lookup.
     */
    get<C extends Model>(type: Model.Type<C>, idOrName: number | string): C | undefined;
    /**
     * Access all models of a specific type, optionally filtered to a specific ID or number.  Even if filtered there
     * may be multiple return values if there are different variants of the element defined.
     */
    all<C extends Model>(type: Model.Type<C>, idOrName?: number | string): C[];
    /**
     * Access a model using a {@link Children.Selector}.  This is an optimized primitive used by various tree traversal
     * algorithms.
     */
    select(selector: Children.Selector, allowedTags?: Children.TagSelector, except?: Set<Model>): Model.ChildOf<T> | undefined;
    /**
     * Like {@link select} but retrieves all models for which selection applies.
     */
    selectAll(selector: Children.Selector, allowedTags?: Children.TagSelector, except?: Set<Model>): Model.ChildOf<T>[];
}
export interface InternalChildren<T extends Model = Model> extends Children<T> {
    /**
     * Models invoke this when their ID changes so we can update internal bookkeeping.
     */
    updateId(child: Model, oldId: number | undefined): void;
    /**
     * Models invoke this when their name changes so we can update internal bookkeeping.
     */
    updateName(child: Model, oldName: string): void;
    /**
     * Freeze the set of children.
     */
    freeze(): void;
    /**
     * Callback to notify of name changes.
     */
    onNameChanged?: (name: string, model?: Model) => void;
    /**
     * Ensure roots of children are synced with parent.
     */
    rerootAll(isOwned: boolean): void;
}
/**
 * Invoked by {@link Model} to instantiate a new child array.
 */
export declare function Children<T extends Model = Model>(initial: Children.InputIterable<T>, position: ModelTreePosition): InternalChildren<T>;
export declare namespace Children {
    /**
     * A model selector designates models for retrieval.  It may be a model name, number, or a predicate function.
     */
    type Selector = string | number | ((child: Model) => boolean);
    /**
     * A tag selector filters models based on type.  It may be a tag name, a list of tag names, or "*" or undefined to
     * disable type filtering.
     */
    type TagSelector = undefined | ElementTag | "*" | ElementTag[];
    /**
     * An iterable of input definitions.
     */
    type InputIterable<T extends Model> = Iterable<Model.TaggedDefinition<T>>;
}
export declare namespace Children {
    var installModelConstructor: (constructor: typeof Model) => typeof Model;
}
//# sourceMappingURL=Children.d.ts.map