{"ast":null,"code":"import _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nvar _excluded = [\"children\"],\n  _excluded2 = [\"isTruncated\", \"noOfLines\", \"bold\", \"italic\", \"sub\", \"highlight\", \"underline\", \"strikeThrough\", \"fontFamily\", \"fontWeight\", \"fontStyle\", \"_hover\", \"fontSize\", \"numberOfLines\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nimport React, { memo, forwardRef, useRef } from 'react';\nimport { usePropsResolution } from \"../../../hooks/useThemeProps\";\nimport { useHover } from '@react-native-aria/interactions';\nimport { mergeRefs } from \"../../../utils/mergeRefs\";\nimport { makeStyledComponent } from \"../../../utils/makeStyledComponent\";\nimport { useResolvedFontFamily } from \"../../../hooks/useResolvedFontFamily\";\nimport NativeText from \"react-native-web/dist/exports/Text\";\nvar StyledText = makeStyledComponent(NativeText);\nvar TextAncestorContext = React.createContext(false);\nvar Text = function Text(_ref2, ref) {\n  var children = _ref2.children,\n    props = _objectWithoutProperties(_ref2, _excluded);\n  var hasTextAncestor = React.useContext(TextAncestorContext);\n  var _usePropsResolution = usePropsResolution('Text', props, {}, {\n      resolveResponsively: ['noOfLines', 'numberOfLines'],\n      notResolveThemeProps: hasTextAncestor ? true : false\n    }),\n    isTruncated = _usePropsResolution.isTruncated,\n    noOfLines = _usePropsResolution.noOfLines,\n    bold = _usePropsResolution.bold,\n    italic = _usePropsResolution.italic,\n    sub = _usePropsResolution.sub,\n    highlight = _usePropsResolution.highlight,\n    underline = _usePropsResolution.underline,\n    strikeThrough = _usePropsResolution.strikeThrough,\n    propFontFamily = _usePropsResolution.fontFamily,\n    propFontWeight = _usePropsResolution.fontWeight,\n    propFontStyle = _usePropsResolution.fontStyle,\n    _hover = _usePropsResolution._hover,\n    fontSize = _usePropsResolution.fontSize,\n    numberOfLines = _usePropsResolution.numberOfLines,\n    resolvedProps = _objectWithoutProperties(_usePropsResolution, _excluded2);\n  var _ref = useRef(null);\n  var _useHover = useHover({}, _hover ? _ref : null),\n    isHovered = _useHover.isHovered;\n  var fontFamily = propFontFamily;\n  var fontStyle = italic ? 'italic' : propFontStyle;\n  var fontWeight = bold ? 'bold' : propFontWeight;\n  var resolvedFontFamily = useResolvedFontFamily({\n    fontFamily: fontFamily,\n    fontWeight: fontWeight !== null && fontWeight !== void 0 ? fontWeight : hasTextAncestor ? undefined : 400,\n    fontStyle: fontStyle !== null && fontStyle !== void 0 ? fontStyle : hasTextAncestor ? undefined : 'normal'\n  });\n  if (resolvedFontFamily) {\n    fontFamily = resolvedFontFamily;\n  }\n  var propsToSpread = _objectSpread(_objectSpread(_objectSpread({}, resolvedProps), {}, {\n    numberOfLines: numberOfLines || noOfLines ? numberOfLines || noOfLines : isTruncated ? 1 : undefined\n  }, resolvedFontFamily), {}, {\n    bg: highlight ? 'warning.300' : resolvedProps.bg,\n    textDecorationLine: underline && strikeThrough ? 'underline line-through' : underline ? 'underline' : strikeThrough ? 'line-through' : resolvedProps.textDecorationLine,\n    fontSize: sub ? 10 : fontSize,\n    ref: mergeRefs([ref, _ref])\n  }, isHovered && _hover);\n  return hasTextAncestor ? React.createElement(StyledText, propsToSpread, children) : React.createElement(TextAncestorContext.Provider, {\n    value: true\n  }, React.createElement(StyledText, propsToSpread, children));\n};\nexport default memo(forwardRef(Text));","map":{"version":3,"sources":["index.tsx"],"names":["React","memo","forwardRef","useRef","usePropsResolution","useHover","mergeRefs","makeStyledComponent","useResolvedFontFamily","StyledText","NativeText","TextAncestorContext","createContext","Text","children","props","ref","hasTextAncestor","useContext","isTruncated","noOfLines","bold","italic","sub","highlight","underline","strikeThrough","fontFamily","propFontFamily","fontWeight","propFontWeight","fontStyle","propFontStyle","_hover","fontSize","numberOfLines","resolvedProps","resolveResponsively","notResolveThemeProps","_ref","isHovered","resolvedFontFamily","undefined","propsToSpread","bg","textDecorationLine"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,IAAhB,EAAsBC,UAAtB,EAAkCC,MAAlC,QAAgD,OAAhD;AACA,SAASC,kBAAT;AAEA,SAASC,QAAT,QAAyB,iCAAzB;AACA,SAASC,SAAT;AACA,SAASC,mBAAT;AACA,SAASC,qBAAT;AAAA,OAAA,UAAA;AAGA,IAAMC,UAAU,GAAGF,mBAAmB,CAACG,UAAD,CAAtC;AAIA,IAAMC,mBAAmB,GAAGX,KAAK,CAACY,aAANZ,CAAoB,KAApBA,CAA5B;AAEA,IAAMa,IAAI,GAAG,SAAPA,IAAI,CAAA,KAAA,EAAwCG,GAArC,EAAkD;EAAA,IAA/CF,QAAF,GAAA,KAAA,CAAEA,QAAF;IAAeC,KAAAA,GAAAA,wBAAAA,CAAAA,KAAAA,EAAAA,SAAAA;EAC3B,IAAME,eAAe,GAAGjB,KAAK,CAACkB,UAANlB,CAAiBW,mBAAjBX,CAAxB;EAEA,IAAA,mBAAA,GAgBII,kBAAkB,CACpB,MADoB,EAEpBW,KAFoB,EAGpB,CAAA,CAHoB,EAIpB;MACEsB,mBAAmB,EAAE,CAAC,WAAD,EAAc,eAAd,CADvB;MAIEC,oBAAoB,EAAErB,eAAe,GAAG,IAAH,GAAU;IAJjD,CAJoB,CAhBtB;IACEE,WADI,GAAA,mBAAA,CACJA,WADI;IAEJC,SAFI,GAAA,mBAAA,CAEJA,SAFI;IA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wB;IACtBd,UAAU,GAAGc,kBAAbd;EACD;EAED,IAAMgB,aAAa,GAAA,aAAA,CAAA,aAAA,CAAA,aAAA,KACdP,aADiB;IAEpBD,aAAa,EACXA,aAAa,IAAIf,SAAjBe,GACIA,aAAa,IAAIf,SADrBe,GAEIhB,WAAW,GACX,CADW,GAEXuB;EAPc,GAQjBD,kBARiB;IASpBG,EAAE,EAAEpB,SAAS,GAAG,aAAH,GAAmBY,aAAa,CAACQ,EAT1B;IAUpBC,kBAAkB,EAChBpB,SAAS,IAAIC,aAAbD,GACI,wBADJA,GAEIA,SAAS,GACT,WADS,GAETC,aAAa,GACb,cADa,GAEbU,aAAa,CAACS,kBAjBA;IAkBpBX,QAAQ,EAAEX,GAAG,GAAG,EAAH,GAAQW,QAlBD;IAmBpBlB,GAAG,EAAEV,SAAS,CAAC,CAACU,GAAD,EAAMuB,IAAN,CAAD;EAnBM,GAoBhBC,SAAS,IAAIP,MAAjB,CArE2D;EAyE7D,OAAOhB,eAAe,GACpB,KAAA,CAAA,aAAA,CAAC,UAAD,EAAgB0B,aAAhB,EAAgC7B,QAAhC,CADoB,GAGpB,KAAA,CAAA,aAAA,CAAC,mBAAD,CAAqB,QAArB,EAAA;IAA8B,KAAK,EAAE;EAArC,CAAA,EACE,KAAA,CAAA,aAAA,CAAC,UAAD,EAAgB6B,aAAhB,EAAgC7B,QAAhC,CADF,CAHF;AAOD,CAhFD;AAkFA,eAAeb,IAAI,CAACC,UAAU,CAACW,IAAD,CAAX,CAAnB","sourcesContent":["import React, { memo, forwardRef, useRef } from 'react';\nimport { usePropsResolution } from '../../../hooks/useThemeProps';\nimport type { ITextProps } from './types';\nimport { useHover } from '@react-native-aria/interactions';\nimport { mergeRefs } from '../../../utils/mergeRefs';\nimport { makeStyledComponent } from '../../../utils/makeStyledComponent';\nimport { useResolvedFontFamily } from '../../../hooks/useResolvedFontFamily';\nimport { Text as NativeText } from 'react-native';\n\nconst StyledText = makeStyledComponent(NativeText);\n// updateComponentThemeMap('Text');\n\n// To have a RN compatible behaviour, we'll inherit parent text styles as base style\nconst TextAncestorContext = React.createContext(false);\n\nconst Text = ({ children, ...props }: ITextProps, ref: any) => {\n  const hasTextAncestor = React.useContext(TextAncestorContext);\n\n  const {\n    isTruncated,\n    noOfLines,\n    bold,\n    italic,\n    sub,\n    highlight,\n    underline,\n    strikeThrough,\n    fontFamily: propFontFamily,\n    fontWeight: propFontWeight,\n    fontStyle: propFontStyle,\n    _hover,\n    fontSize,\n    numberOfLines,\n    ...resolvedProps\n  } = usePropsResolution(\n    'Text',\n    props,\n    {},\n    {\n      resolveResponsively: ['noOfLines', 'numberOfLines'],\n      // We override the component base theme if text has an ancestor.\n      // componentTheme: hasTextAncestor ? {} : undefined,\n      notResolveThemeProps: hasTextAncestor ? true : false,\n    }\n  );\n\n  const _ref = useRef(null);\n  // TODO: might have to add this condition\n  const { isHovered } = useHover({}, _hover ? _ref : null);\n\n  let fontFamily = propFontFamily;\n  const fontStyle = italic ? 'italic' : propFontStyle;\n  const fontWeight = bold ? 'bold' : propFontWeight;\n\n  const resolvedFontFamily = useResolvedFontFamily({\n    fontFamily,\n    fontWeight: fontWeight ?? (hasTextAncestor ? undefined : 400),\n    fontStyle: fontStyle ?? (hasTextAncestor ? undefined : 'normal'),\n  });\n\n  if (resolvedFontFamily) {\n    fontFamily = resolvedFontFamily;\n  }\n\n  const propsToSpread = {\n    ...resolvedProps,\n    numberOfLines:\n      numberOfLines || noOfLines\n        ? numberOfLines || noOfLines\n        : isTruncated\n        ? 1\n        : undefined,\n    ...resolvedFontFamily,\n    bg: highlight ? 'warning.300' : resolvedProps.bg,\n    textDecorationLine:\n      underline && strikeThrough\n        ? 'underline line-through'\n        : underline\n        ? 'underline'\n        : strikeThrough\n        ? 'line-through'\n        : resolvedProps.textDecorationLine,\n    fontSize: sub ? 10 : fontSize,\n    ref: mergeRefs([ref, _ref]),\n    ...(isHovered && _hover),\n  };\n\n  // console.log(INTERNAL_themeStyle, 'internal theme style');\n  return hasTextAncestor ? (\n    <StyledText {...propsToSpread}>{children}</StyledText>\n  ) : (\n    <TextAncestorContext.Provider value={true}>\n      <StyledText {...propsToSpread}>{children}</StyledText>\n    </TextAncestorContext.Provider>\n  );\n};\n\nexport default memo(forwardRef(Text));\nexport type { ITextProps };\n"]},"metadata":{},"sourceType":"module"}