<script lang="ts" setup>
import { computed } from 'vue'
import ServiceTabLayout from '@/Components/Panel/ServiceTabLayout.vue'
import WebConsole from '@/Components/Panel/WebConsole.vue'
import type { Service } from '@/types'

interface Props {
  service: Service
  consoleUrl: string | null
}

const props = defineProps<Props>()

const tabs = computed(() => [
  { label: 'Dashboard', icon: 'tabler-dashboard', to: `/services/${props.service.id}/game-panel` },
  { label: 'Console', icon: 'tabler-terminal-2', to: `/services/${props.service.id}/game-panel/console` },
  { label: 'Files', icon: 'tabler-folder', to: `/services/${props.service.id}/game-panel/files` },
  { label: 'Databases', icon: 'tabler-database', to: `/services/${props.service.id}/game-panel/databases` },
  { label: 'Backups', icon: 'tabler-archive', to: `/services/${props.service.id}/game-panel/backups` },
  { label: 'Schedules', icon: 'tabler-clock', to: `/services/${props.service.id}/game-panel/schedules` },
  { label: 'Startup', icon: 'tabler-rocket', to: `/services/${props.service.id}/game-panel/startup` },
  { label: 'Settings', icon: 'tabler-settings', to: `/services/${props.service.id}/game-panel/settings` },
  { label: 'Sub-Users', icon: 'tabler-users', to: `/services/${props.service.id}/game-panel/sub-users` },
])
</script>

<template>
  <ServiceTabLayout
    :service="service"
    :tabs="tabs"
    :current-tab="`/services/${service.id}/game-panel/console`"
  >
    <VCard elevation="0">
      <VCardTitle class="d-flex align-center gap-2">
        <VIcon icon="tabler-terminal-2" color="primary" />
        Server Console
      </VCardTitle>
      <VCardText>
        <VAlert v-if="!consoleUrl" type="info" variant="tonal" class="mb-4">
          <VAlertTitle>Console Not Available</VAlertTitle>
          The console requires Pterodactyl API configuration. Ensure the panel is connected and the server is running.
        </VAlert>
        <WebConsole v-if="consoleUrl" :url="consoleUrl" type="websocket" />
      </VCardText>
    </VCard>
  </ServiceTabLayout>
</template>
