<template>
  <component
    :is="iconComponent"
    :class="['svg-icon', { inherit: props.inheritColor }]"
    :fill="fill"
  ></component>
</template>

<script setup lang="ts">
  import { snakeToHump } from '@/utils/utils';
  import { computed } from 'vue';
  import IconAdd from '../../assets/svgs/icon-add.svg?component';
  import IconAi from '../../assets/svgs/icon-ai.svg?component';
  import IconApply from '../../assets/svgs/icon-apply.svg?component';
  import IconArrowRight from '../../assets/svgs/icon-arrow-right.svg?component';
  import IconArrow from '../../assets/svgs/icon-arrow.svg?component';
  import IconAssign from '../../assets/svgs/icon-assign.svg?component';
  import IconBase from '../../assets/svgs/icon-base.svg?component';
  import IconDataCheck from '../../assets/svgs/icon-data-check.svg?component';
  import IconDelete from '../../assets/svgs/icon-delete.svg?component';
  import IconError from '../../assets/svgs/icon-error.svg?component';
  import IconExamManage from '../../assets/svgs/icon-exam-manage.svg?component';
  import IconFile from '../../assets/svgs/icon-file.svg?component';
  import IconHome from '../../assets/svgs/icon-home.svg?component';
  import IconImport from '../../assets/svgs/icon-import.svg?component';
  import IconSystemInitS from '../../assets/svgs/icon-system-init-s.svg?component';
  import IconIssuePaper from '../../assets/svgs/icon-issue-paper.svg?component';
  import IconJump from '../../assets/svgs/icon-jump.svg?component';
  import IconLog from '../../assets/svgs/icon-log.svg?component';
  import IconLogo from '../../assets/svgs/icon-logo.svg?component';
  import IconLogout from '../../assets/svgs/icon-logout.svg?component';
  import IconMarkManageS from '../../assets/svgs/icon-mark-manage-s.svg?component';
  import IconMarkManage from '../../assets/svgs/icon-mark-manage.svg?component';
  import IconMenu from '../../assets/svgs/icon-menu.svg?component';
  import IconNotice from '../../assets/svgs/icon-notice.svg?component';
  import IconOrg from '../../assets/svgs/icon-org.svg?component';
  import IconPrint from '../../assets/svgs/icon-print.svg?component';
  import IconRejectManage from '../../assets/svgs/icon-reject-manage.svg?component';
  import IconReviewS from '../../assets/svgs/icon-review-s.svg?component';
  import IconScanProgress from '../../assets/svgs/icon-scan-progress.svg?component';
  import IconScoreExportS from '../../assets/svgs/icon-score-export-s.svg?component';
  import IconScoreQuery from '../../assets/svgs/icon-score-query.svg?component';
  import IconScoreReview from '../../assets/svgs/icon-score-review.svg?component';
  import IconScoreViewS from '../../assets/svgs/icon-score-view-s.svg?component';
  import IconScore from '../../assets/svgs/icon-score.svg?component';
  import IconSetting from '../../assets/svgs/icon-setting.svg?component';
  import IconStudentManage from '../../assets/svgs/icon-student-manage.svg?component';
  import IconSubjectAnalysis from '../../assets/svgs/icon-subject-analysis.svg?component';
  import IconSubjectManage from '../../assets/svgs/icon-subject-manage.svg?component';
  import IconSuccess from '../../assets/svgs/icon-success.svg?component';
  import IconSystem from '../../assets/svgs/icon-system.svg?component';
  import IconUserManage from '../../assets/svgs/icon-user-manage.svg?component';
  import IconUser from '../../assets/svgs/icon-user.svg?component';
  import IconView from '../../assets/svgs/icon-view.svg?component';
  import IconWarningS from '../../assets/svgs/icon-warning-s.svg?component';

  defineOptions({
    name: 'SvgIcon',
  });

  const props = withDefaults(
    defineProps<{
      name: string;
      fill?: string;
      inheritColor?: boolean;
    }>(),
    {
      fill: 'currentColor',
      inheritColor: true,
    }
  );

  const icons = {
    IconAdd,
    IconAi,
    IconApply,
    IconArrowRight,
    IconArrow,
    IconAssign,
    IconBase,
    IconDataCheck,
    IconDelete,
    IconError,
    IconExamManage,
    IconFile,
    IconHome,
    IconImport,
    IconSystemInitS,
    IconIssuePaper,
    IconJump,
    IconLog,
    IconLogo,
    IconLogout,
    IconMarkManageS,
    IconMarkManage,
    IconMenu,
    IconNotice,
    IconOrg,
    IconPrint,
    IconRejectManage,
    IconReviewS,
    IconScanProgress,
    IconScoreExportS,
    IconScoreQuery,
    IconScoreReview,
    IconScoreViewS,
    IconScore,
    IconSetting,
    IconStudentManage,
    IconSubjectAnalysis,
    IconSubjectManage,
    IconSuccess,
    IconSystem,
    IconUserManage,
    IconUser,
    IconView,
    IconWarningS,
  };

  const iconName = snakeToHump(props.name) as keyof typeof icons;

  const iconComponent = computed(() => icons[iconName]);
</script>
