<template>
  <div class="page-container">
    <support-tabs model-value="contact-us" />
    <div class="page-header">
      <h1 class="page-title">{{ $t('navigation.contact-info') }}</h1>
      <app-breadcrumb class="breadcrumb" :items="breadcrumbItems" />
    </div>

    <div class="page-content">
      <el-skeleton
        :rows="10"
        :loading="pending"
        animated
        :throttle="{ leading: 500, trailing: 500 }"
      >
        <template #default>
          <!-- eslint-disable-next-line vue/no-v-html -->
          <div class="html-typography" v-html="contactInfo?.content || ''" />
          <!-- <div v-if="!hydrated" v-html="contactInfo?.content || ''" /> -->
          <!-- <div v-else> -->
          <!--   <html-renderer -->
          <!--     class="html-typography" -->
          <!--     :html="contactInfo?.content || ''" -->
          <!--   /> -->
          <!-- </div> -->
        </template>
      </el-skeleton>
    </div>
  </div>
</template>

<script setup lang="ts">
  const localePath = useLocalePath();
  const hydrated = ref(false);
  const breadcrumbItems = [
    { label: $t('navigation.home'), to: localePath('/') },
    { label: $t('navigation.support'), to: localePath('/support') },
    { label: $t('navigation.contact-info') },
  ];
  const { data, pending, error } = useContactInfo();

  const contactInfo = computed(() => data.value ?? null);

  watch(error, (value) => {
    if (value) {
      logger.error('数据获取失败: ', value);
    }
  });

  const pageTitle = $t('page-title.contact-us');
  usePageSeo({
    title: pageTitle,
  });

  onMounted(() => {
    hydrated.value = true;
  });
</script>

<style scoped>
  .page-container {
    max-width: 1200px;
    margin: 0 auto;
  }

  .page-header {
    display: flex;
    padding: 2rem 2rem 0rem;
  }

  .page-title {
    font-size: 2rem;
    font-weight: bold;
    color: var(--el-color-primary);
    margin-bottom: 1rem;
  }

  .breadcrumb {
    margin-left: auto;
  }

  .page-content {
    padding: 2rem;
    margin-bottom: 2rem;
  }

  :deep(.markdown-body ul) {
    list-style-type: none;
  }

  @media (max-width: 768px) {
    .breadcrumb {
      display: none;
    }
  }
</style>
