import React, {createContext, useContext, ReactNode} from 'react';

export type FontConfig = {
  regular: string;
  medium: string;
  bold: string;
  SemiCondensedExtraBold?: string; // optional if project uses it
  regularItalic: string;
};

const FontContext = createContext<FontConfig | undefined>(undefined);

export const FontProvider = ({
  fonts,
  children,
}: {
  fonts: FontConfig;
  children: ReactNode;
}) => {
  return <FontContext.Provider value={fonts}>{children}</FontContext.Provider>;
};

export const useFontConfig = () => {
  const context = useContext(FontContext);
  if (!context) {
    throw new Error('useFontConfig must be used inside FontProvider');
  }
  return context;
};
