/* eslint-disable import/order */
import React from 'react';

<% icons.forEach((icon) => { -%>
import { <%= icon.Icon %> } from './<%= icon.Icon %>';
<% }); %>

import type { IconPropsReact } from './types';

export const IconComponentsMap = {
<% icons.forEach((icon) => { -%>
  <%= icon.name %>: <%= icon.Icon %>,
<% }); %>
};

export type IconName = keyof typeof IconComponentsMap;
type Props = IconPropsReact & { name: IconName };

export const EpilotIcon = (props: Props) => {
  const { name, ...restProps } = props;

  const iconComponent = IconComponentsMap[name];

  if (!iconComponent) return null;

  return React.createElement(iconComponent, restProps);
};

export default EpilotIcon;
