/*
 * Copyright (c), Huawei Technologies Co., Ltd. 2025-2025. All rights reserved.
 */

import GlyphAtlas from './GlyphAtlas';
import { EdgeProgram, NodeProgram, TextProgram, PolygonProgram } from './programs';

class ProgramManager {
    private gl: WebGL2RenderingContext;
    nodeProgram!: NodeProgram;
    edgeProgram!: EdgeProgram;
    textProgram!: TextProgram;
    clusterProgram!: PolygonProgram;
    fsgProgram!: PolygonProgram;
    highlightEdgeProgram!: EdgeProgram;
    highlightNodeProgram!: NodeProgram;
    constructor(gl: WebGL2RenderingContext) {
        this.gl = gl;
    }

    async initialize(): Promise<void> {
        this.nodeProgram = new NodeProgram(this.gl);
        this.nodeProgram.initialize();
        this.edgeProgram = new EdgeProgram(this.gl);
        this.edgeProgram.initialize();
        const atlas = await GlyphAtlas.create(this.gl);
        this.textProgram = new TextProgram(this.gl, atlas);
        this.textProgram.initialize();
        this.clusterProgram = new PolygonProgram(this.gl);
        this.clusterProgram.initialize();

        this.fsgProgram = new PolygonProgram(this.gl);
        this.fsgProgram.initialize();

        this.highlightNodeProgram = new NodeProgram(this.gl);
        this.highlightNodeProgram.initialize();
        this.highlightEdgeProgram = new EdgeProgram(this.gl);
        this.highlightEdgeProgram.initialize();
    }
}

export default ProgramManager;