import { screen } from "./screen.js";
import { assets_getter } from "./assets-getter.js";

export class view {
    #manager;

    /**
     * This function build new view instance. Basically, it require view
     * manager, and assets loader. Views are builded by screen manager, 
     * when view on screen had been changing.
     *  
     * @param {screen} manager - Screen manager
     */
    constructor(manager) {
        if (!(manager instanceof screen)) {
            throw new TypeError("Screen manager is in bad type.");
        }

        this.#manager = manager;
    }

    /**
     * @returns {screen} - This return screen manager
     */
    get manager() {
        return this.#manager;
    }

    /** 
     * Determinate that view is ready to interaction after show function. 
     * When return true, then after show() function manager would 
     * 
     * @returns {bool} - True 
     */

    /**
     * @returns {assets_getter} - This return assets loader
     */
    get loader() {
        return this.#manager.loader;
    }

    /**
     * This function is responsible for creating new view items.
     * 
     * @abstract
     * @returns {HTMLElement} - New view container
     */
    show() {
        throw new Error("This function must be override.");
    }

    /**
     * This function is responsibke for cleanup after view. It is empty by
     * default, but when it is required, it can be overwrite. It is called
     * before view destroy.
     */
    destroy() {

    }
}