<script lang="ts">
  async function downloadAPK() {
    try {
      const response = await fetch("https://garage.gilmour109.de/calchat-releases/calchat.apk");
      const blob = await response.blob();
      const objectUrl = URL.createObjectURL(blob);

      const a = document.createElement("a");
      a.style.display = "none";
      a.href = objectUrl;
      a.download = "calchat.apk";

      document.body.appendChild(a);
      a.click();

      document.body.removeChild(a);
      URL.revokeObjectURL(objectUrl);
    } catch (error) {
      console.error(`coudn't download calchat apk: ${error}`);
    }
  }
</script>

<h1 class="text-4xl font-bold">This is where CalChat builds can be downloaded from.</h1>
<h3 class="text-xl font-bold">Currently only available for Android arm64</h3>
<button on:click={downloadAPK}>Download APK here!</button>
