<script>
  import { _ } from "svelte-i18n";
  const license_promise = fetch("/licenses.json");
  let licenses = [];
  license_promise
    .then((response) => response.json())
    .then((json) => {
      licenses = json;
      console.log(json);
    });
</script>

<div class="pt-12 px-4 sm:px-6 lg:px-8 lg:pt-20 bg-gray-900 pb-12">
  <div class="text-center mb-8">
    <h1
      class="mt-9 font-display text-4xl leading-none font-semibold text-white sm:text-5xl lg:text-6xl">
      {$_('about')}
      🧾
    </h1>
    <p
      class="mt-2 max-w-xl mx-auto text-xl lg:max-w-3xl lg:text-2xl text-gray-300">
      Lauf für Kaya!
      <strong class="text-white font-medium">
        {$_('by')}
        <a href="https://odit.services" class="underline">ODIT.Services</a>
      </strong>
      <br />
      <span class="text-lg">{$_('lfk-is-os')}</span>
    </p>
  </div>
</div>

<div class="pt-0 pb-16 bg-gray-50 overflow-hidden lg:pt-12 lg:py-24">
  <div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
    <h2 class="text-4xl font-display font-semibold text-gray-900 md:text-5xl">
      {$_('credits')}
    </h2>
    <div
      class="max-w-3xl mx-auto text-xl leading-8 font-medium text-gray-900 mt-8">
      <p class="text-center">{$_('oss_credit_description')}</p>
    </div>
    <div class="w-screen leading-8 pl-5 mt-5">
      {#await license_promise}
        <p class="text-center w-full">Licenses are being loaded...</p>
      {:then}
        <table>
          <thead>
            <tr>
              <th>Name</th>
              <th>License</th>
              <th>Link</th>
              <th>Installed version</th>
              <th>Author</th>
            </tr>
          </thead>
          <tbody>
            {#each licenses as l}
              <tr>
                <td>{l.name}</td>
                <td>{l.license || '?'}</td>
                <td>{(l.repo?.url || l.repo).replace('git+', '')}</td>
                <td>{l.version || '?'}</td>
                <td>{l.author?.name || l.author || '?'}</td>
              </tr>
            {/each}
          </tbody>
        </table>
      {:catch error}
        <div
          class="text-white px-6 py-4 border-0 rounded relative mb-4 bg-red-500">
          <span class="inline-block align-middle mr-8">
            <b class="capitalize">{$_('general_promise_error')}</b>
            {error}
          </span>
        </div>
      {/await}
    </div>
    <h2 class="text-4xl font-display font-semibold text-gray-900 md:text-5xl">
      Fragen
    </h2>
    <div class="mt-6 border-t-2 border-gray-100 pt-10">
      <dl class="md:grid md:grid-cols-2 md:gap-8">
        <div>
          <div>
            <dt class="text-lg leading-6 font-medium text-gray-900">Q</dt>
            <dd class="mt-2">
              <p class="text-base text-gray-500">A</p>
            </dd>
          </div>
        </div>
        <div class="mt-12 sm:mt-0">
          <div id="team-pricing">
            <dt class="text-lg leading-6 font-medium text-gray-900">Q</dt>
            <dd class="mt-2">
              <p class="text-base text-gray-500">A</p>
            </dd>
          </div>
          <div class="mt-12">
            <dt class="text-lg leading-6 font-medium text-gray-900">Q</dt>
            <dd class="mt-2">
              <p class="text-base text-gray-500">A</p>
            </dd>
          </div>
        </div>
      </dl>
    </div>
  </div>
</div>
