<script lang="ts" setup>
import { enumPageComponentTemplates } from "@/definitions/enum";
import {
    Article_Card,
    Article_Detail_General,
    Article_Detail_Podcast,
    Article_Detail_Video,
    Article_Detail_Image
} from "./index";
const _props = defineProps<{
  settings: any;
  component?: any;
}>();

const definedDynamicComponent: Record<string, any> = {
  'TYPE:Detail-LAYOUT:default': Article_Detail_General,
  'TYPE:Detail-LAYOUT:image': Article_Detail_Image,
  'TYPE:Detail-LAYOUT:video': Article_Detail_Video,
  'TYPE:Detail-LAYOUT:podcast': Article_Detail_Podcast,
};

const getCurrentComponent = computed(() => `${_props.settings.layout}`);
const GET_PROPS = computed(() => {
  return () => {
    let props: any = {};
    if (_props.settings) {
      for (const [key, value] of Object.entries(_props.settings)) {
        props = {
          ...props,
          [key]: value,
        };
      }
      return props;
    }
  };
});
</script>

<template>
  <component :is="definedDynamicComponent[getCurrentComponent]" v-bind="GET_PROPS()" />
</template>
