"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.customAnimatedText = void 0;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _theming = require("../theming");
var _forwardRef = require("../utils/forwardRef");
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); }
/**
 * Animated text component which follows styles from the theme.
 *
 * @extends Text props https://reactnative.dev/docs/text#props
 */
const AnimatedText = (0, _forwardRef.forwardRef)(function AnimatedText({
  style,
  theme: themeOverrides,
  variant,
  ...rest
}, ref) {
  const theme = (0, _theming.useInternalTheme)(themeOverrides);
  const writingDirection = _reactNative.I18nManager.getConstants().isRTL ? 'rtl' : 'ltr';
  if (theme.isV3 && variant) {
    const font = theme.fonts[variant];
    if (typeof font !== 'object') {
      throw new Error(`Variant ${variant} was not provided properly. Valid variants are ${Object.keys(theme.fonts).join(', ')}.`);
    }
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.Text, {
      ref: ref,
      ...rest,
      style: [font, styles.text, {
        writingDirection,
        color: theme.colors.onSurface
      }, style]
    });
  } else {
    const font = !theme.isV3 ? theme.fonts.regular || theme.fonts.default : theme.fonts.bodyMedium;
    const textStyle = {
      ...font,
      color: theme.isV3 ? theme.colors.onSurface : theme.colors.text || theme.colors.onSurface
    };
    return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Animated.Text, {
      ref: ref,
      ...rest,
      style: [styles.text, textStyle, {
        writingDirection
      }, style]
    });
  }
});
const styles = _reactNative.StyleSheet.create({
  text: {
    textAlign: 'left'
  }
});
const customAnimatedText = () => AnimatedText;
exports.customAnimatedText = customAnimatedText;
var _default = exports.default = AnimatedText;
//# sourceMappingURL=AnimatedText.js.map