import * as assert from "@esfx/internal-assert" ; import { Hierarchical , HierarchyProvider , HierarchyIterable } from '@esfx/iter-hierarchy' ; /**
 * Represents a group of values associated with the same key.
 */ export class Grouping < K , V > implements Iterable < V > { /**
     * The key associated with this group.
     */ readonly key : K ; /**
     * The values in the group.
     */ readonly values : Iterable < V > ; constructor ( key , values ) { assert . mustBeIterableObject ( values , "values" ) ; this . key = key ; this . values = values ; } static from < K , VNode , V extends VNode > ( key , values , provider ) ; static from < K , VNode , V extends VNode > ( key , values ) ; static from < K , V > ( key , values ) ; static from < K , V > ( key , values , provider ? ) { assert . mustBeIterableObject ( values , "values" ) ; assert . mustBeTypeOrUndefined ( HierarchyProvider . hasInstance , provider , "provider" ) ; if ( provider ) values = HierarchyIterable . create ( values , provider ) ; return HierarchyIterable . hasInstance ( values ) ? new HierarchyGrouping ( key , values ) : new Grouping ( key , values ) ; } [ Symbol . iterator ] ( ) { return this . values [ Symbol . iterator ] ( ) ; } } export class HierarchyGrouping < K , VNode , V extends VNode > extends Grouping < K , V > implements HierarchyIterable < VNode , V > { private _provider : HierarchyProvider < VNode > ; declare readonly values : HierarchyIterable < VNode , V > ; constructor ( key , values , provider ) ; constructor ( key , values ) ; constructor ( key , values , provider ? ) { assert . mustBeIterableObject ( values , "values" ) ; if ( provider ) values = HierarchyIterable . create ( values , provider ) ; assert . mustBeType ( HierarchyIterable . hasInstance , values , "values" ) ; super ( key , values ) ; this . _provider = values [ Hierarchical . hierarchy ] ( ) ; } [ Hierarchical . hierarchy ] ( ) { return this . _provider ; } }