'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var Cache = require('../../../../assets/cache/Cache.js');
var HTMLTextSystem = require('../HTMLTextSystem.js');
var loadFontCSS = require('./loadFontCSS.js');

async function getFontCss(fontFamilies, style) {
  const fontPromises = fontFamilies.filter((fontFamily) => Cache.Cache.has(fontFamily)).map((fontFamily, i) => {
    if (!HTMLTextSystem.FontStylePromiseCache.has(fontFamily)) {
      const { url } = Cache.Cache.get(fontFamily);
      if (i === 0) {
        HTMLTextSystem.FontStylePromiseCache.set(fontFamily, loadFontCSS.loadFontCSS(style, url));
      } else {
        HTMLTextSystem.FontStylePromiseCache.set(fontFamily, loadFontCSS.loadFontCSS({
          ...HTMLTextSystem.HTMLTextSystem.defaultFontOptions,
          fontFamily
        }, url));
      }
    }
    return HTMLTextSystem.FontStylePromiseCache.get(fontFamily);
  });
  return (await Promise.all(fontPromises)).join("\n");
}

exports.getFontCss = getFontCss;
//# sourceMappingURL=getFontCss.js.map
