(function () { 'use strict'; var D = window.URUTAU_I18N; function get(k) { try { return localStorage.getItem(k); } catch (e) { return null; } } function set(k, v) { try { localStorage.setItem(k, v); } catch (e) { /* ignore */ } } var lang = get('urutau.lang') || ((navigator.language || 'en').toLowerCase().indexOf('pt') === 0 ? 'pt-BR' : 'en'); if (!D[lang]) lang = 'en'; var theme = get('urutau.theme'); if (theme === 'light' || theme === 'dark') document.documentElement.setAttribute('data-theme', theme); function t(k) { return D[lang][k] || D.en[k] || k; } function apply() { document.documentElement.lang = lang; document.querySelectorAll('[data-i18n]').forEach(function (n) { n.textContent = t(n.getAttribute('data-i18n')); }); document.querySelectorAll('[data-i18n-ph]').forEach(function (n) { n.setAttribute('placeholder', t(n.getAttribute('data-i18n-ph'))); }); document.querySelectorAll('[data-i18n-aria]').forEach(function (n) { n.setAttribute('aria-label', t(n.getAttribute('data-i18n-aria'))); }); document.querySelectorAll('[data-i18n-title]').forEach(function (n) { n.setAttribute('title', t(n.getAttribute('data-i18n-title'))); }); document.getElementById('lang').textContent = lang === 'en' ? 'PT' : 'EN'; var e = new URLSearchParams(location.search).get('e'); try { var nav = performance.getEntriesByType('navigation')[0]; if (nav && nav.responseStatus === 429) e = 'rate'; } catch (x) { /* ignore */ } document.getElementById('msg').textContent = e === 'bad' ? t('login.err.bad') : e === 'rate' ? t('login.err.rate') : ''; } document.getElementById('lang').addEventListener('click', function () { lang = lang === 'en' ? 'pt-BR' : 'en'; set('urutau.lang', lang); apply(); }); document.getElementById('theme').addEventListener('click', function () { var cur = document.documentElement.getAttribute('data-theme') || (matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark'); var next = cur === 'dark' ? 'light' : 'dark'; document.documentElement.setAttribute('data-theme', next); set('urutau.theme', next); }); apply(); })();