import { Icon, IconsData, IconValidationError } from './types';
import icons from './data/icons.json';

export { DevIcon } from './components/DevIcon';
export type { DevIconProps } from './components/DevIcon';

class DevIcons {
  private icons: IconsData = icons;

  getAllIcons(): IconsData {
    return this.icons;
  }

  getIcon(name: string): Icon | undefined {
    return this.icons[name];
  }

  hasIcon(name: string): boolean {
    return name in this.icons;
  }

  getIconKeys(): string[] {
    return Object.keys(this.icons);
  }

  addIcon(name: string, icon: Icon): void {
    if (!this.validateSvg(icon.icon)) {
      throw new IconValidationError('Invalid SVG provided');
    }
    this.icons[name] = icon;
  }

  private validateSvg(svg: string): boolean {
    // Basic SVG validation
    return svg.includes('<svg') && svg.includes('</svg>');
  }
}

const devIcons = new DevIcons();
export default devIcons; 