import {RenderersController as RenderersController2} from "./poly/RenderersController";
import {PolyLibsController as PolyLibsController2} from "./poly/PolyLibsController";
import {
  NodesRegister as NodesRegister2,
  OperationsRegister
} from "./poly/registers/nodes/NodesRegister";
import {ExpressionRegister as ExpressionRegister2} from "./poly/registers/expressions/ExpressionRegister";
import {DynamicModulesRegister as DynamicModulesRegister2} from "./poly/registers/modules/DynamicModulesRegister";
import {AssemblersRegister} from "./poly/registers/assemblers/AssemblersRegistry";
import {PluginsRegister as PluginsRegister2} from "./poly/registers/plugins/PluginsRegister";
import {CamerasRegister as CamerasRegister2} from "./poly/registers/cameras/CamerasRegister";
export class PolyEngine {
  constructor() {
    this.renderersController = new RenderersController2();
    this.nodesRegister = new NodesRegister2(this);
    this.operationsRegister = new OperationsRegister(this);
    this.expressionsRegister = new ExpressionRegister2();
    this.modulesRegister = new DynamicModulesRegister2();
    this.assemblersRegister = new AssemblersRegister();
    this.pluginsRegister = new PluginsRegister2(this);
    this.camerasRegister = new CamerasRegister2(this);
    this.scenesByUuid = {};
    this._player_mode = true;
    this._logger = null;
  }
  static _instance_() {
    if (window.__POLYGONJS_POLY_INSTANCE__) {
      return window.__POLYGONJS_POLY_INSTANCE__;
    } else {
      const instance = new PolyEngine();
      window.__POLYGONJS_POLY_INSTANCE__ = instance;
      return window.__POLYGONJS_POLY_INSTANCE__;
    }
  }
  setPlayerMode(mode) {
    this._player_mode = mode;
  }
  playerMode() {
    return this._player_mode;
  }
  registerNode(node, tab_menu_category, options) {
    this.nodesRegister.register(node, tab_menu_category, options);
  }
  registerOperation(operation) {
    this.operationsRegister.register(operation);
  }
  registerCamera(node) {
    this.camerasRegister.register(node);
  }
  registerPlugin(plugin) {
    this.pluginsRegister.register(plugin);
  }
  registeredNodes(parent_context, type) {
    return this.nodesRegister.registeredNodes(parent_context, type);
  }
  registeredOperation(parent_context, operation_type) {
    return this.operationsRegister.registeredOperation(parent_context, operation_type);
  }
  registeredCameraTypes() {
    return this.camerasRegister.registeredTypes();
  }
  inWorkerThread() {
    return false;
  }
  desktopController() {
  }
  get libs() {
    return this._libs_controller = this._libs_controller || new PolyLibsController2();
  }
  setEnv(env) {
    this._env = env;
  }
  env() {
    return this._env;
  }
  setLogger(logger) {
    this._logger = logger;
  }
  get logger() {
    return this._logger;
  }
  log(message, ...optionalParams) {
    this.logger?.log(...[message, ...optionalParams]);
  }
  warn(message, ...optionalParams) {
    this.logger?.warn(...[message, ...optionalParams]);
  }
  error(message, ...optionalParams) {
    this.logger?.error(...[message, ...optionalParams]);
  }
}
export const Poly = PolyEngine._instance_();
