{"ast":null,"code":"import { useTheme } from \"./useTheme\";\nexport function useResolvedFontFamily(props) {\n  var fontFamily = props.fontFamily,\n    fontStyle = props.fontStyle,\n    fontWeight = props.fontWeight;\n  var newFontFamily = fontFamily;\n  var newFontStyle = fontStyle;\n  var newFontWeight = fontWeight;\n  var _useTheme = useTheme(),\n    fontConfig = _useTheme.fontConfig,\n    fontWeights = _useTheme.fontWeights,\n    fonts = _useTheme.fonts;\n  if (fontWeight && fontStyle && fontFamily && fontFamily in fonts) {\n    var fontToken = fonts[fontFamily];\n    if (fontConfig && fontConfig[fontToken]) {\n      newFontWeight = undefined;\n      newFontStyle = undefined;\n      var fontWeightNumber = fontWeight in fontWeights ? fontWeights[fontWeight] : fontWeight;\n      var fontVariant = fontConfig[fontToken][fontWeightNumber];\n      if (typeof fontVariant === 'object') {\n        if (fontVariant[fontStyle]) newFontFamily = fontVariant[fontStyle];\n      } else {\n        newFontFamily = fontVariant;\n      }\n    } else {\n      newFontFamily = fonts[fontFamily];\n    }\n  }\n  return {\n    fontFamily: newFontFamily,\n    fontWeight: newFontWeight,\n    fontStyle: newFontStyle\n  };\n}","map":{"version":3,"sources":["useResolvedFontFamily.ts"],"names":["useTheme","useResolvedFontFamily","props","fontFamily","fontStyle","fontWeight","newFontFamily","newFontStyle","newFontWeight","fontConfig","fontWeights","fonts","fontToken","undefined","fontWeightNumber","fontVariant"],"mappings":"AAAA,SAASA,QAAT;AAWA,OAAO,SAASC,qBAAT,CAA+BC,KAA/B,EAIJ;EACD,IAAQC,UAAF,GAAwCD,KAA9C,CAAQC,UAAF;IAAcC,SAAd,GAAwCF,KAA9C,CAAoBE,SAAd;IAAyBC,UAAAA,GAAeH,KAA9C,CAA+BG,UAAAA;EAC/B,IAAIC,aAAa,GAAGH,UAApB;EACA,IAAII,YAAY,GAAGH,SAAnB;EACA,IAAII,aAAa,GAAGH,UAApB;EAEA,IAAA,SAAA,GAA2CL,QAAQ,CAAA,CAAnD;IAAQS,UAAF,GAAA,SAAA,CAAEA,UAAF;IAAcC,WAAd,GAAA,SAAA,CAAcA,WAAd;IAA2BC,KAAAA,GAAAA,SAAAA,CAAAA,KAAAA;EACjC,IAAIN,UAAU,IAAID,SAAdC,IAA2BF,UAA3BE,IAAyCF,UAAU,IAAIQ,KAA3D,EAAkE;IAEhE,IAAMC,SAAc,GAAGD,KAAK,CAACR,UAAD,CAA5B;IACA,IAAIM,UAAU,IAAIA,UAAU,CAACG,SAAD,CAA5B,EAAyC;MAKvCJ,aAAa,GAAGK,SALuB;MAOvCN,YAAY,GAAGM,SAAfN;MAEA,IAAIO,gBAAgB,GAClBT,UAAU,IAAIK,WAAdL,GAA4BK,WAAW,CAACL,UAAD,CAAvCA,GAAsDA,UADxD;MAEA,IAAIU,WAAW,GAAGN,UAAU,CAACG,SAAD,CAAVH,CAAsBK,gBAAtBL,CAAlB;MAEA,IAAI,OAAOM,WAAP,KAAuB,QAA3B,EAAqC;QACnC,IAAIA,WAAW,CAACX,SAAD,CAAf,EAA4BE,aAAa,GAAGS,WAAW,CAACX,SAAD,CAA3BE;MAC7B,CAFD,MAEO;QACLA,aAAa,GAAGS,WAAhBT;MACD;IACF,CAlBD,MAkBO;MACLA,aAAa,GAAGK,KAAK,CAACR,UAAD,CAArBG;IACD;EACF;EAED,OAAO;IACLH,UAAU,EAAEG,aADP;IAELD,UAAU,EAAEG,aAFP;IAGLJ,SAAS,EAAEG;EAHN,CAAP;AAKD","sourcesContent":["import { useTheme } from './useTheme';\nimport type { ITheme } from '../theme';\n/**\n *\n * @param props\n * @returns resolved fontFamily\n * @description Combination of fontWeight, fontStyle and font family is fully supported on web but on Android we need to pass the exact font family.\n * for e.g. If we load Roboto-Light-Italic.ttf using css, we can use fontFamily: Roboto, fontWeight: 300, fontStyle: italic on web, but same may not work on all the platforms. Other platform needs to set fontFamily: Roboto-Light-Italic in order to work.\n * So this function's purpose is to intake styles like fontFamily: Roboto, fontWeight: 300, fontStyle: Italic and return fontFamily: Roboto-Light-Italic depending upon the fontConfig token in typography theme.\n * This function depends upon fontConfig token in typography for mapping.\n */\nexport function useResolvedFontFamily(props: {\n  fontFamily?: keyof ITheme['fonts'];\n  fontStyle?: string;\n  fontWeight?: keyof ITheme['fontWeights'];\n}) {\n  const { fontFamily, fontStyle, fontWeight } = props;\n  let newFontFamily = fontFamily;\n  let newFontStyle = fontStyle;\n  let newFontWeight = fontWeight;\n\n  const { fontConfig, fontWeights, fonts } = useTheme();\n  if (fontWeight && fontStyle && fontFamily && fontFamily in fonts) {\n    // TODO: Fix typing remove any.\n    const fontToken: any = fonts[fontFamily];\n    if (fontConfig && fontConfig[fontToken]) {\n      // If a custom font family is resolved, set fontWeight and fontStyle to undefined.\n      // https://github.com/GeekyAnts/NativeBase/issues/3811\n      // On Android, If a fontFamily and fontWeight both are passed, it behaves in a weird way and applies system fonts with passed fontWeight. This happens only for some fontWeights e.g. '700' or 'bold'. So, if we find a custom fontFamily, we remove fontWeight and fontStyle\n      //@ts-ignore\n      newFontWeight = undefined;\n      //@ts-ignore\n      newFontStyle = undefined;\n\n      let fontWeightNumber =\n        fontWeight in fontWeights ? fontWeights[fontWeight] : fontWeight;\n      let fontVariant = fontConfig[fontToken][fontWeightNumber];\n\n      if (typeof fontVariant === 'object') {\n        if (fontVariant[fontStyle]) newFontFamily = fontVariant[fontStyle];\n      } else {\n        newFontFamily = fontVariant;\n      }\n    } else {\n      newFontFamily = fonts[fontFamily];\n    }\n  }\n\n  return {\n    fontFamily: newFontFamily,\n    fontWeight: newFontWeight,\n    fontStyle: newFontStyle,\n  };\n}\n"]},"metadata":{},"sourceType":"module"}