/* Metro module 6727; source: lib/spellcheck/Spellchecker.tsx; dependencies: [5, 57, 6, 7, 1949, 3, 3767, 6728, 6729, 6730, 22, 1864, 1360, 2] */ import Logger from '../../modules/debug/Logger.tsx'; /* Metro dependency 3 */ import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */ import ClassCallCheck from '../../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */ import CreateClass from '../../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */ import Module00022 from '../../by-id/module-00022.js'; /* Metro dependency 22 */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import LocaleStore from '../../modules/user_settings/LocaleStore.tsx'; /* Metro dependency 1949 */ import LanguageDetector from './LanguageDetector.tsx'; /* Metro dependency 6730 */ import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ function _fun52835(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#52835, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:6, offset: 0x013380be, size: 339 bytes, params: 8, frame: 20 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const value = undefined; const value4 = new (Logger)('Spellchecker'); const env0_9 = (importDefault(3767) /* metro dependency 3767: DiscordNative */) == null ? value : (importDefault(3767) /* metro dependency 3767: DiscordNative */).spellCheck; const value7 = _fun52842(); const env0_11 = (Module00022).debounce(_fun52859, 250); (FileImportTrackerModule).fileFinishedImporting('lib/spellcheck/Spellchecker.tsx'); exports.Spellchecker = value7; exports.install = function() { return _install.apply(this, arguments); }; return value; function normalizeLocale_52836(a0) { // fn#52836, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:221, offset: 0x01338211, size: 255 bytes, params: 2, frame: 19 let value = a0; const r3 = (importDefault(6728) /* metro dependency 6728: fallbackLocales */)[value] ?? value; value = Reflect.apply((require(6729) /* metro dependency 6729 */).parse, value, [r3.replace(RegExp('[_-]', 'g'), '-')]); if (value == null) { env0_8.error('' + r3 + ' is not a valid locale.'); } else { var langtag = value.langtag; var language = langtag.language; if (language == null) { env0_8.error('' + r3 + ' is not a valid locale.'); return undefined; } langtag = value.langtag; var region = langtag.region; if (region != null) { langtag = value.langtag; language = langtag.language; region = langtag.region; language = language.language; value = language.toLowerCase(); return '' + value + '-' + region.toUpperCase(); } env0_8.error('' + r3 + ' is not a valid locale.'); } } function _install() { // fn#52837, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:2371, offset: 0x01338310, size: 48 bytes, params: 1, frame: 14 return Module00005(_fun52839).apply(this, arguments); function* _fun52839() { // fn#52839, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:2410, offset: 0x01338349, size: 149 bytes, params: 1, frame: 16 var environment; if (false) { return undefined; } value = environment.__proto__.__proto__; const binding = env2_9; const getAvailableDictionaries = binding.getAvailableDictionaries; yield Reflect.apply(getAvailableDictionaries, binding, []); const value3 = undefined; if (false) { return value3; } const value5 = (value3 ?? []).map(env2_12); const env2_103 = new env2_10(value5.filter(env2_0(env2_2[12]).isNotNullish)); ((a0) => { var env0_0 = a0; if (global.document.body != null) { global.document.body.addEventListener('beforeinput', _fun52841, true); } })(env2_103); return env2_103; function attachToInput(a0) { // fn#52840, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:2551, offset: 0x013383de, size: 69 bytes, params: 2, frame: 15 const env0_0 = a0; if (global.document.body != null) { global.document.body.addEventListener('beforeinput', _fun52841, true); } function _fun52841({target}) { // fn#52841, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:2644, offset: 0x01338423, size: 33 bytes, params: 2, frame: 13 return env4_11(env0_0, target); } } } } function _fun52842() { // fn#52842, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:528, offset: 0x01338444, size: 277 bytes, params: 1, frame: 15 return CreateClass(Spellchecker, [{key: 'enabled', get: function() { return this._enabled; }, set: function(a0) { this._enabled = a0; }}, {key: 'setLearnedWords', value: function(a0) { spellCheck.setLearnedWords(a0); }}, {key: 'setLocale', value: value_52849}, {key: 'setAppLocale', value: function(a0) { this.regionPreference = a0.split('-')[1]; }}, {key: 'detectLanguage', value: function(a0) { if (this.enabled) { this.languageDetector.process(a0); } }}, {key: 'getAvailableLanguages', value: function(a0) { a0.forEach(_fun52854); return {}; }}, {key: 'isMisspelled', value: function(a0) { return this.misspelledWord !== '' && a0 === this.misspelledWord; }}, {key: 'getCorrectionsForMisspelling', value: function(a0, a1) { return this.isMisspelled(a0, a1) ? this.corrections : []; }}, {key: 'getCachedMisspelling', value: function() { return {misspelledWord: this.misspelledWord, corrections: this.corrections}; }}, {key: 'replaceMisspelling', value: function(a0) { spellCheck.replaceMisspelling(a0); }}]); function Spellchecker(a0) { // fn#52843, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:549, offset: 0x01338559, size: 226 bytes, params: 2, frame: 17 const env0_1 = a0; env1_5(this, Spellchecker); this._enabled = true; this.misspelledWord = ''; this.corrections = []; const value4 = env1_4(LocaleStore.locale.split('-'), 2); const property = value4[0]; this.regionPreference = value4[1]; const env0_3 = this.getAvailableLanguages(a0); const defaultImport = LanguageDetector; const value5 = Object.create(defaultImport.prototype, {constructor: {value: defaultImport}}); const defaultImport2 = new defaultImport(property, _fun52844); this.languageDetector = defaultImport2 instanceof Object ? defaultImport2 : value5; spellCheck.on('spellcheck-result', _fun52845); function _fun52844(a0) { // fn#52844, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:802, offset: 0x0133863b, size: 156 bytes, params: 2, frame: 17 var r4; const value2 = '' + a0 + '-' + env0_0.regionPreference; if (env0_1.indexOf(value2) !== -1) { env0_0.setLocale(value2); } else { r4 = env0_3[a0] ?? (importDefault(6728) /* metro dependency 6728: fallbackLocales */)[env0_2]; if (r4 != null) { env0_0.setLocale(r4); } } } function _fun52845(a0, a1) { // fn#52845, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:981, offset: 0x013386d7, size: 57 bytes, params: 3, frame: 7 const value = a0; const value2 = a1; env0_0.misspelledWord = value ?? ''; env0_0.corrections = value2 ?? []; } } function value_52849(a0) { // fn#52849, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:1231, offset: 0x01338739, size: 52 bytes, params: 2, frame: 12 var environment; const env0_0 = a0; let value = environment.__proto__; value = spellCheck.setLocale(a0); if (value != null) { value.then(_fun52850); } function _fun52850(a0) { // fn#52850, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:1283, offset: 0x0133876d, size: 72 bytes, params: 2, frame: 14 const value = environment.__proto__.__proto__; const binding = env2_8; binding.info('Switching to ' + env0_0, a0 ? '(available)' : '(unavailable)'); } } function value_52853(a0) { // fn#52853, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:1554, offset: 0x013387fd, size: 28 bytes, params: 2, frame: 12 a0.forEach(_fun52854); return {}; function _fun52854(a0) { // fn#52854, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:1593, offset: 0x01338819, size: 67 bytes, params: 2, frame: 15 const value = a0; const property = env2_4(value.split('-'), 1)[0]; const binding = env0_0; binding[property] = binding[property] ?? value; } } } function _fun52859(a0, a1) { // fn#52859, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:6905:2080, offset: 0x013388db, size: 195 bytes, params: 3, frame: 20 var r1; var value3; var moduleValue; var moduleValue2; var moduleValue3; const value = null; if (value == a1) { r1 = value; } else { value3 = undefined; moduleValue = require(1864) /* metro dependency 1864: DOMUtils */; if (moduleValue.isElement(a1, global.HTMLInputElement)) { r1 = a1.value; } else { moduleValue2 = require(1864) /* metro dependency 1864: DOMUtils */; if (moduleValue2.isElement(a1, global.HTMLTextAreaElement)) { r1 = a1.value; } else { moduleValue3 = require(1864) /* metro dependency 1864: DOMUtils */; r1 = moduleValue3.isElement(a1) && a1.hasAttribute('contenteditable') ? a1.textContent : value3; } } } if (value != r1) { a0.detectLanguage(r1); } } } global.__d(_fun52835, 6727, [5, 57, 6, 7, 1949, 3, 3767, 6728, 6729, 6730, 22, 1864, 1360, 2]) /* metro module 6727, dependencies: [5, 57, 6, 7, 1949, 3, 3767, 6728, 6729, 6730, 22, 1864, 1360, 2] */;