<script lang="ts">
  import { invoke } from "@tauri-apps/api/core";
  import { onMount } from "svelte";
  import { PerfMonitor } from "@threlte/extras";

  import { Canvas } from "@threlte/core";
  import { GraphManager } from "$lib/graph-manager";
  import Graph from "$lib/components/graph/Graph.svelte";

  const graph = GraphManager.createEmptyGraph({ width: 12, height: 12 });
  graph.load();

  // onMount(async () => {
  //   try {
  //     const res = await invoke("greet", { name: "Dude" });
  //     console.log({ res });
  //   } catch (error) {
  //     console.log(error);
  //   }
  //
  //   try {
  //     const res2 = await invoke("run_nodes", {});
  //     console.log({ res2 });
  //   } catch (error) {
  //     console.log(error);
  //   }
  // });
</script>

<div>
  <Canvas shadows={false} renderMode="on-demand" autoRender={true}>
    <!-- <PerfMonitor /> -->
    <Graph {graph} />
  </Canvas>
</div>

<style>
  div {
    height: 100vh;
  }

  :global(html) {
    background: rgb(13, 19, 32);
    background: linear-gradient(
      180deg,
      rgba(13, 19, 32, 1) 0%,
      rgba(8, 12, 21, 1) 100%
    );
  }

  :global(body) {
    margin: 0;
    position: relative;
    width: 100vw;
    height: 100vh;
  }
</style>
