import * as assert from "@esfx/internal-assert" ; import { HierarchyIterable , HierarchyProvider , Hierarchical } from '@esfx/iter-hierarchy' ; export class Page < T > implements Iterable < T > { /**
     * The page offset from the start of the source iterable.
     */ readonly page : number ; /**
     * The element offset from the start of the source iterable.
     */ readonly offset : number ; /**
     * The values associated with this page.
     */ readonly values : Iterable < T > ; constructor ( page , offset , values ) { assert . mustBePositiveInteger ( page , "page" ) ; assert . mustBePositiveInteger ( offset , "offset" ) ; assert . mustBeIterableObject ( values , "values" ) ; this . page = page ; this . offset = offset ; this . values = values ; } static from < TNode , T extends TNode > ( page , offset , values , provider ) ; static from < TNode , T extends TNode > ( page , offset , values ) ; static from < T > ( page , offset , values ) ; static from < T > ( page , offset , values , provider ? ) { assert . mustBePositiveInteger ( page , "page" ) ; assert . mustBePositiveInteger ( offset , "offset" ) ; assert . mustBeIterableObject ( values , "values" ) ; assert . mustBeTypeOrUndefined ( HierarchyProvider . hasInstance , provider , "provider" ) ; if ( provider ) values = HierarchyIterable . create ( values , provider ) ; return HierarchyIterable . hasInstance ( values ) ? new HierarchyPage ( page , offset , values ) : new Page ( page , offset , values ) ; } [ Symbol . iterator ] ( ) { return this . values [ Symbol . iterator ] ( ) ; } } export class HierarchyPage < TNode , T extends TNode > extends Page < T > implements HierarchyIterable < TNode , T > { private _provider : HierarchyProvider < TNode > ; declare readonly values : HierarchyIterable < TNode , T > ; constructor ( page , offset , values , provider ) ; constructor ( page , offset , values ) ; constructor ( page , offset , values , provider ? ) { assert . mustBePositiveInteger ( page , "page" ) ; assert . mustBePositiveInteger ( offset , "offset" ) ; assert . mustBeIterableObject ( values , "values" ) ; if ( provider ) values = HierarchyIterable . create ( values , provider ) ; assert . mustBeType ( HierarchyIterable . hasInstance , values , "values" ) ; super ( page , offset , values ) ; this . _provider = values [ Hierarchical . hierarchy ] ( ) ; } [ Hierarchical . hierarchy ] ( ) { return this . _provider ; } }