import {
  renderMachineSessionControlView,
} from "./control-view-renderer.js";
import {
  createMachineSessionControlPageController,
} from "./control-page-controller.js";
import {
  createControlPageBrowserApiManifest,
  createControlPageBrowserApiMethods,
  createControlPageBrowserApiSchema,
  createIniPanelShellControlPageContract,
  isSupportedIniPanelControlPageApiManifest,
} from "./ui-shell.js";

const panelFrameNode = document.getElementById("panel-frame");
const statusNode = document.getElementById("control-page-status");
const viewNode = document.getElementById("control-page-view");

const controller = createMachineSessionControlPageController({
  panelFrame: panelFrameNode,
  statusNode,
  viewNode,
  renderControlView: renderMachineSessionControlView,
});

controller.mount();

window.linuxCncIniPanelControlPageApi = {
  isSupportedControlPageApiManifest: isSupportedIniPanelControlPageApiManifest,
  getControlPageApiSchema: createControlPageBrowserApiSchema,
  getControlPageApiManifest: createControlPageBrowserApiManifest,
  getControlPageApiMethods: createControlPageBrowserApiMethods,
  getControlView: controller.getControlView,
  getControlPageContract: createIniPanelShellControlPageContract,
  getPanelApi: controller.getPanelApi,
  loadControlPageSessionState: controller.loadSessionState,
  readControlPageStatus: controller.readStatus,
  refreshControlPage: controller.refresh,
  renderControlPage: controller.render,
};
