/* @refresh reload */
import "./miwi/src/miwi";
import { Nav, setTheme, pushPage, mdColors } from "./miwi/src/miwi";
import { render } from "solid-js/web";
import "./assets/main.css";
import { MainMenu } from "./MainMenu";

(window as any).startTime = Date.now();

function setVhUnit() {
  let vh = window.innerHeight * 0.01;
  document.documentElement.style.setProperty("--vh", `${vh}px`);
}

window.addEventListener("resize", setVhUnit);
setVhUnit();

// Set the primary color for Miwi
setTheme({
  colors: {
    primary: "#4caf50",
    hint: mdColors.grey,
  },
  // debugInteractableArea: true,
});

const root = document.getElementById("root");

if (import.meta.env.DEV && !(root instanceof HTMLElement)) {
  throw new Error(
    "Root element not found. Did you forget to add it to your index.html? Or maybe the id attribute got misspelled?",
  );
}

render(() => {
  pushPage(MainMenu, {});
  return <Nav />;
}, root!);
