import { FONT_FORMAT_MAP } from "../constants.js";
import { extractFontType } from "../utils.js";
function resolveLocalFont({ family, proxyURL }) {
  const fonts = [];
  for (const variant of family.variants) {
    const data = {
      weight: variant.weight,
      style: variant.style,
      src: variant.src.map(({ url: originalURL, tech }) => {
        return {
          originalURL,
          url: proxyURL({
            value: originalURL,
            data: {
              weight: variant.weight,
              style: variant.style
            }
          }),
          format: FONT_FORMAT_MAP[extractFontType(originalURL)],
          tech
        };
      })
    };
    if (variant.display) data.display = variant.display;
    if (variant.unicodeRange) data.unicodeRange = variant.unicodeRange;
    if (variant.stretch) data.stretch = variant.stretch;
    if (variant.featureSettings) data.featureSettings = variant.featureSettings;
    if (variant.variationSettings) data.variationSettings = variant.variationSettings;
    fonts.push(data);
  }
  return {
    fonts
  };
}
export {
  resolveLocalFont
};
