{ "version": 3, "sources": ["src/app/_pipes/compact-number.pipe.ts"], "sourcesContent": ["import { Pipe, PipeTransform } from '@angular/core';\nimport {AccountService} from \"../_services/account.service\";\n\nconst specialCases = [4, 7, 10, 13];\n\n@Pipe({\n name: 'compactNumber',\n standalone: true\n})\nexport class CompactNumberPipe implements PipeTransform {\n\n constructor() {}\n\n transform(value: number): string {\n // Weblate allows some non-standard languages, like 'zh_Hans', which should be just 'zh'. So we handle that here\n const key = localStorage.getItem(AccountService.localeKey)?.replace('_', '-');\n if (key?.endsWith('Hans')) {\n return this.transformValue(key?.split('-')[0] || 'en', value);\n }\n return this.transformValue(key || 'en', value);\n }\n\n private transformValue(locale: string, value: number) {\n const formatter = new Intl.NumberFormat(locale, {\n //@ts-ignore\n notation: 'compact', // https://github.com/microsoft/TypeScript/issues/36533\n maximumSignificantDigits: 3\n });\n\n const formatterForDoublePrecision = new Intl.NumberFormat(locale, {\n //@ts-ignore\n notation: 'compact', // https://github.com/microsoft/TypeScript/issues/36533\n maximumSignificantDigits: 2\n });\n\n if (value < 1000) return value + '';\n if (specialCases.includes((value + '').length)) { // from 4, every 3 will have a case where we need to override\n return formatterForDoublePrecision.format(value);\n }\n\n return formatter.format(value);\n }\n\n\n\n}\n"], "mappings": "iFAGA,IAAMA,EAAe,CAAC,EAAG,EAAG,GAAI,EAAE,EAMrBC,GAAiB,IAAA,CAAxB,MAAOA,CAAiB,CAE5BC,aAAA,CAAe,CAEfC,UAAUC,EAAa,CAErB,IAAMC,EAAMC,aAAaC,QAAQC,EAAeC,SAAS,GAAGC,QAAQ,IAAK,GAAG,EAC5E,OAAIL,GAAKM,SAAS,MAAM,EACf,KAAKC,eAAeP,GAAKQ,MAAM,GAAG,EAAE,CAAC,GAAK,KAAMT,CAAK,EAEvD,KAAKQ,eAAeP,GAAO,KAAMD,CAAK,CAC/C,CAEQQ,eAAeE,EAAgBV,EAAa,CAClD,IAAMW,EAAY,IAAIC,KAAKC,aAAaH,EAAQ,CAE9CI,SAAU,UACVC,yBAA0B,EAC3B,EAEKC,EAA8B,IAAIJ,KAAKC,aAAaH,EAAQ,CAEhEI,SAAU,UACVC,yBAA0B,EAC3B,EAED,OAAIf,EAAQ,IAAaA,EAAQ,GAC7BJ,EAAaqB,UAAUjB,EAAQ,IAAIkB,MAAM,EACpCF,EAA4BG,OAAOnB,CAAK,EAG1CW,EAAUQ,OAAOnB,CAAK,CAC/B,iDAhCWH,EAAiB,CAAA,qDAAjBA,EAAiBuB,KAAA,GAAAC,WAAA,EAAA,CAAA,CAAA,SAAjBxB,CAAiB,GAAA", "names": ["specialCases", "CompactNumberPipe", "constructor", "transform", "value", "key", "localStorage", "getItem", "AccountService", "localeKey", "replace", "endsWith", "transformValue", "split", "locale", "formatter", "Intl", "NumberFormat", "notation", "maximumSignificantDigits", "formatterForDoublePrecision", "includes", "length", "format", "pure", "standalone"] }