# Загрузка стилей компонента
document.head.insertAdjacentHTML('beforeend','<style type="text/tailwindcss"  page="LanguageSwitcher">'+stylFns['app/shared/LanguageSwitcher/index.styl']+'</style>')

module.exports =
    name: 'LanguageSwitcher'
    render: (new Function '_ctx', '_cache', renderFns['app/shared/LanguageSwitcher/index.pug'])()
    
    data: ->
        isOpen: false
        languages: [
            { code: 'ru', name: 'Русский', native: 'Русский' }
            { code: 'en', name: 'English', native: 'English' }
            { code: 'tj', name: 'Tajik', native: 'Тоҷикӣ' }
        ]
    
    computed:
        currentLanguage: ->
            return _.currentLanguage || 'ru'
        
        currentLanguageName: ->
            lang = @languages.find (l) -> l.code == @currentLanguage
            return lang?.native || 'Русский'
    
    methods:
        changeLanguage: (languageCode) ->
            _.changeLanguage(languageCode)
            @isOpen = false
        
        toggleDropdown: ->
            @isOpen = !@isOpen
