"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.FontLoader = FontLoader;
var _react = _interopRequireWildcard(require("react"));
var _applyFontFacesWeb = require("./apply-font-faces.web.js");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
// Reach for the web variant explicitly. The default `./apply-font-faces`
// is a no-op stub on native — native loads its fonts via
// `useFonts(FONT_ASSETS)` in `FontLoader.native.tsx` and has no use for
// CSS `@font-face` injection. This file (`FontLoader.tsx`) is only picked
// up by web bundlers — Metro selects `FontLoader.native.tsx` on iOS/Android
// — so it is safe to take a direct dependency on the web implementation
// here.

/**
 * Web font loader. Applies the Bloom `@font-face` rules and CSS variables
 * to `:root` on first render, before the first paint, using the same
 * `useRef`-during-render pattern as `BloomThemeProvider`'s color application.
 *
 * No `useEffect`: the side effect runs synchronously inside the render phase,
 * gated by a ref so it only executes once. Subsequent renders short-circuit.
 *
 * Native consumers resolve `FontLoader.native.tsx` via the React Native /
 * Metro bundler's platform extension resolution — they never load this file.
 */
function FontLoader({
  enabled,
  children
}) {
  const applied = (0, _react.useRef)(false);
  if (enabled && !applied.current) {
    applied.current = true;
    (0, _applyFontFacesWeb.applyFontFaces)();
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
    children: children
  });
}
//# sourceMappingURL=FontLoader.js.map