{"version":3,"file":"NameRegion.cjs","sources":["../../../../src/lib/Name/NameRegion.tsx"],"sourcesContent":["import {forwardRef, useMemo} from 'react';\nimport classNames from 'classnames';\n\nimport type {DataAttributes, LibraryProps} from '@/internal/LibraryAPI';\nimport {useBrowserLocale} from '@/internal/locale';\nimport type {Locale, CountryCodes} from '@/internal/locale';\n\nimport classes from './Name.module.css';\n\nexport type Props = DataAttributes &\n    LibraryProps & {\n        /**\n         * Provide a string with a BCP 47 language tag or an Intl.Locale instance,\n         * or an array of such locale identifiers. Defaults to user setting\n         * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DisplayNames/DisplayNames#locales\n         */\n        locale?: Locale;\n        /**\n         * Provide a two-letter ISO 3166 region code\n         * @see https://www.iso.org/iso-3166-country-codes.html\n         */\n        countryCode: keyof typeof CountryCodes;\n    };\n\nexport const NameRegion = forwardRef<HTMLDivElement, Props>(\n    ({className, locale: localeProp, countryCode, ...nativeProps}, ref) => {\n        const userLocale = useBrowserLocale();\n        const locale = localeProp ? localeProp : userLocale;\n        const formattedValue = useMemo(\n            () => new Intl.DisplayNames(locale, {type: 'region'}).of(countryCode),\n            [countryCode, locale]\n        );\n\n        return (\n            <span {...nativeProps} className={classNames(classes.name, className)} ref={ref}>\n                {formattedValue}\n            </span>\n        );\n    }\n);\n\nNameRegion.displayName = 'NameRegion';\n"],"names":["NameRegion","forwardRef","className","localeProp","countryCode","nativeProps","ref","userLocale","useBrowserLocale","locale","formattedValue","useMemo","jsx","classNames","classes"],"mappings":"wQAwBaA,EAAaC,EAAAA,WACtB,CAAC,CAAC,UAAAC,EAAW,OAAQC,EAAY,YAAAC,EAAa,GAAGC,CAAA,EAAcC,IAAQ,CACnE,MAAMC,EAAaC,EAAAA,iBAAA,EACbC,EAASN,GAA0BI,EACnCG,EAAiBC,EAAAA,QACnB,IAAM,IAAI,KAAK,aAAaF,EAAQ,CAAC,KAAM,QAAA,CAAS,EAAE,GAAGL,CAAW,EACpE,CAACA,EAAaK,CAAM,CAAA,EAGxB,OACIG,EAAAA,IAAC,OAAA,CAAM,GAAGP,EAAa,UAAWQ,EAAWC,UAAQ,KAAMZ,CAAS,EAAG,IAAAI,EAClE,SAAAI,CAAA,CACL,CAER,CACJ,EAEAV,EAAW,YAAc"}