import { io } from 'socket.io-client';
import { MenuBar } from './menuBar';
import { TabController } from './tabController';
import { MorphFeature } from 'morphux';
import { DashboardCameraRunner } from './dashboard.camerarunner';
import { LogsHandler } from './logsHandler';
import { Calibration } from './calibration';
import { DashboardUnity } from './dashboard.unity';

const socket = io('/');
export class Main {
	socket = socket;

	MenuBar = new MenuBar(this);
	TabController = new TabController(this);

	Logs = new LogsHandler(this);
	Calibration = new Calibration(this);

	DashboardCameraRunner = new DashboardCameraRunner(this);
	DashboardUnityRunner = new DashboardUnity(this);

	constructor() {
		if (window.location.search.includes('debug')) {
			(window as any).SN = this;
			console.log('Debug mode enabled');
		}
	}
}

MorphFeature.Loader({ active: true, message: 'Connecting to server...' });
socket.on('connect', () => {
	console.log('Connected to server');
	MorphFeature.Loader({ active: false });
});

const _Main = new Main();
