type FontType = 'notoSans' | 'raleway' | 'varelaRound' | 'noto-sans-sc' | 'noto-sans-georgian' | 'noto-sans-arabic' ; export type UiDirectionType = 'rtl' | 'ltr' ; type LanguageType = { rtl : boolean ; additionalFont ? : FontType ; } ; type SupportedLanguagesType = Record < string , LanguageType > ; type FallbacksType = Record < string , string [ ] > ; class Config { sourceLanguage = 'de' ; supportedLanguages : SupportedLanguagesType = { de : { rtl : false } , ar : { rtl : true , additionalFont : 'noto-sans-arabic' } , en : { rtl : false } , pes : { rtl : true , additionalFont : 'noto-sans-arabic' } , fr : { rtl : false } , ro : { rtl : false } , tr : { rtl : false } , pl : { rtl : false } , ti : { rtl : false } , ckb : { rtl : true , additionalFont : 'noto-sans-arabic' } , ru : { rtl : false } , so : { rtl : false } , hr : { rtl : false } , es : { rtl : false } , 'sr-Latn' : { rtl : false } , 'sr-Cyrl' : { rtl : false } , ps : { rtl : true } , kmr : { rtl : false } , am : { rtl : false } , bg : { rtl : false } , el : { rtl : false } , it : { rtl : false } , 'zh-CN' : { rtl : false , additionalFont : 'noto-sans-sc' } , mk : { rtl : false } , sq : { rtl : false } , ka : { rtl : false , additionalFont : 'noto-sans-georgian' } , prs : { rtl : true , additionalFont : 'noto-sans-arabic' } , hu : { rtl : false } , ur : { rtl : true , additionalFont : 'noto-sans-arabic' } } ; fallbacks : FallbacksType = { ku : [ 'kmr' ] , fa : [ 'pes' ] , 'fa-AF' : [ 'prs' ] , fa_pr : [ 'pes' ] , 'de-si' : [ 'de' ] , sr : [ 'sr-Cyrl' ] , 'zh-hans' : [ 'zh-CN' ] } ; defaultFallback = 'de' ; constructor ( ) { this . checkConsistency ( ) ; } getSupportedLanguageTags ( ) { return Object . keys ( this . supportedLanguages ) ; } /**
     * Returns the passed languageTag if it is supported or that of a supported fallback or undefined if not supported
     */ getLanguageTagIfSupported ( languageTag ) { return Object . keys ( this . supportedLanguages ) . find ( key => key === languageTag || this . fallbacks [ languageTag ] ?. includes ( key ) ) ; } getSupportedLanguage ( languageTag ) { const fallbacks = this . fallbacks [ languageTag ] ; if ( fallbacks ) { const found = fallbacks . find ( fallback => ! ! this . supportedLanguages [ fallback ] ) ; if ( found ) { return this . supportedLanguages [ found ] ; } } return this . supportedLanguages [ languageTag ] ; } isSupportedLanguage ( languageTag ) { return ! ! this . getSupportedLanguage ( languageTag ) ; } /**
     * Checks whether the languageTag has an RTL script. This decision is made by the project "Integreat".
     * Writing direction is not an attribute of "language", but of "scripts". That means that there are languages which
     * can have RTL and LTR scripts.
     *
     * <b>Typical Usage</b>
     *
     * If you do not know whether to display UI elements RTL/LTR you can use this method. Browsers for example, do not
     * disclose the system script direction. On Android and iOS system libraries are used instead of this method
     * ( https )
     * ( https ).
     * This onlyworks for  {@link #supportedLanguages} and not for arbitrary ones. This is because we simply do now know
     * it and cannot know it.
     *
     *  see http param languageTag returns { * } hasRTLScript ( languageTag ) { const language = this . getSupportedLanguage ( languageTag ) ; if ( ! language ) { throw new Error ( `Unable to determine whether ${ languageTag } uses a RTL script. 
                        Only supported languages have a defined direction.` ) ; } return language . rtl ; } getScriptDirection ( languageTag ) { return this . hasRTLScript ( languageTag ) ? 'rtl' : 'ltr' ; } getAdditionalFont ( languageTag ) { return this . getSupportedLanguage ( languageTag ) ?. additionalFont ; } getFallbackLanguageTags ( ) { return Object . keys ( this . fallbacks ) ; } getFallbackTargetLanguageTags ( ) { const languageTags = [ ] ; const fallbacks = Object . values ( this . fallbacks ) ; fallbacks . forEach ( ( languagesInFallbacks ) => { languagesInFallbacks . forEach ( ( languageTag ) => { languageTags . push ( languageTag ) ; } ) ; } ) ; return languageTags ; } checkConsistency ( ) { const supportedLanguageTags = this . getSupportedLanguageTags ( ) ; this . getFallbackTargetLanguageTags ( ) . forEach ( ( languageTag ) => { if ( ! supportedLanguageTags . includes ( languageTag ) ) { throw Error ( `The code ${ languageTag } was mentioned in the fallbacks but is not included in 'targetLanguage'` ) ; } } ) ; } } export default new Config ( ) ;