"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.H6 = exports.H5 = exports.H4 = exports.H3 = exports.H2 = exports.H1 = void 0;
exports.P = P;
exports.Text = exports.Span = void 0;
Object.defineProperty(exports, "fontFamilies", {
  enumerable: true,
  get: function () {
    return _tokens.fontFamilies;
  }
});
var _react = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _useTheme = require("../theme/use-theme.js");
var _tokens = require("../fonts/tokens.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); }
/**
 * Platform-aware font-family value. On web we resolve to the CSS custom
 * property set by `applyFontFaces` so consumer apps can re-skin Bloom by
 * overriding `--bloom-font-*` at any subtree. On native we use the literal
 * family name registered by `expo-font`'s `useFonts(FONT_ASSETS)`.
 */
function fontFamilyStyle(kind) {
  if (_reactNative.Platform.OS === 'web') {
    return {
      fontFamily: `var(--bloom-font-${kind})`
    };
  }
  if (kind === 'mono') return {
    fontFamily: 'Geist Mono'
  };
  // `display` and `sans` both resolve to BlomusModernus on native — Bloom's
  // default body font. The CSS stack in `tokens.ts` differs (display vs sans
  // have different fallback chains for web), but on RN the literal family
  // name is the only thing that matters; the .ttf is registered via
  // `useFonts(FONT_ASSETS)` in `FontLoader.native.tsx`.
  return {
    fontFamily: 'BlomusModernus'
  };
}
const SANS_FONT_FAMILY = fontFamilyStyle('sans');
const DISPLAY_FONT_FAMILY = fontFamilyStyle('display');

/**
 * Base text component with theme-aware default color and the Bloom sans
 * font family applied.
 */
const TextComponent = function Text({
  children,
  style,
  ...rest
}) {
  const {
    colors
  } = (0, _useTheme.useTheme)();
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
    ...rest,
    style: [{
      fontSize: 13,
      color: colors.text,
      ...SANS_FONT_FAMILY
    }, style],
    children: children
  });
};
const Text = exports.Span = exports.Text = /*#__PURE__*/(0, _react.memo)(TextComponent);
Text.displayName = 'Text';
const HEADING_STYLE = {
  ...DISPLAY_FONT_FAMILY,
  fontWeight: '700'
};
function createHeadingElement({
  level
}) {
  return function HeadingElement({
    style,
    ...rest
  }) {
    const extraProps = _reactNative.Platform.OS === 'web' ? {
      role: 'heading',
      'aria-level': level
    } : {};
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(Text, {
      ...extraProps,
      ...rest,
      style: [HEADING_STYLE, style]
    });
  };
}
const H1 = exports.H1 = createHeadingElement({
  level: 1
});
H1.displayName = 'H1';
const H2 = exports.H2 = createHeadingElement({
  level: 2
});
H2.displayName = 'H2';
const H3 = exports.H3 = createHeadingElement({
  level: 3
});
H3.displayName = 'H3';
const H4 = exports.H4 = createHeadingElement({
  level: 4
});
H4.displayName = 'H4';
const H5 = exports.H5 = createHeadingElement({
  level: 5
});
H5.displayName = 'H5';
const H6 = exports.H6 = createHeadingElement({
  level: 6
});
H6.displayName = 'H6';
function P({
  style,
  ...rest
}) {
  const extraProps = _reactNative.Platform.OS === 'web' ? {
    role: 'paragraph'
  } : {};
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Text, {
    ...extraProps,
    ...rest,
    style: [{
      fontSize: 15,
      lineHeight: 15 * 1.625
    }, style]
  });
}
P.displayName = 'P';
//# sourceMappingURL=index.js.map