/* Metro module 4645; source: stores/DraftStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 1226, 1379, 4646, 661, 22, 21, 1360, 566, 694, 2] */ function _fun39972(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#39972, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:6, offset: 0x010f17d2, size: 674 bytes, params: 8, frame: 28 var object2; const env0_0 = require; const _arrayLikeToArray_39978 = function(a0, a1) { var r0; var r1; var r2; var value3; var length; var value5; var value = undefined; var value2 = value == null; reducibleJoin2: while (true) { if (value2) { r0 = value2; break reducibleJoin2; } value3 = value > a0.length; r0 = value3; break reducibleJoin2; } reducibleJoin4: while (true) { if (r0) { length = a0.length; r1 = length; break reducibleJoin4; } r1 = value; break reducibleJoin4; } value = (0, global.Array)(r1); var value4 = 0; if (value4 < r1) { r2 = value4; reducibleLoop5: while (true) { value[r2] = a0[r2]; value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; if (value5 < r1) { r2 = value5; continue reducibleLoop5; } break reducibleLoop5; } } return value; }; const closure = DRAFT_SAVE; const pruneNonexistentChannels = function() { var r2; var value3; var propertyName; var propertyName2; var value2 = AuthenticationStore.getId(); if (value2 != null) { if (!(GuildAvailabilityStore.totalUnavailableGuilds > 0)) { value3 = getUserDrafts(value2); for (propertyName in value3) { if (ChannelStore.getChannel(propertyName) != null) { r2 = propertyName2; continue; } delete value3[propertyName]; r2 = propertyName2; } } } }; const closure2 = function(a0) { var id = a0.channel.id; var value2 = AuthenticationStore.getId(); if (value2 != null) { delete getUserDrafts(value2)[id]; } return false; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(6) /* metro dependency 6 */; const env0_4 = importDefault(7) /* metro dependency 7 */; const env0_5 = importDefault(15) /* metro dependency 15 */; const env0_6 = importDefault(17) /* metro dependency 17 */; const env0_7 = importDefault(18) /* metro dependency 18 */; const env0_8 = importDefault(57) /* metro dependency 57 */; const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */; const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */; const guildAvailabilityStore = importDefault(4646) /* metro dependency 4646: GuildAvailabilityStore */; const MAX_MESSAGE_LENGTH_PREMIUM = (require(661) /* metro dependency 661: Constants */).MAX_MESSAGE_LENGTH_PREMIUM; const env0_12 = MAX_MESSAGE_LENGTH_PREMIUM + 500; object2 = {ChannelMessage: 0}; object2[0] = 'ChannelMessage'; object2.ThreadSettings = 1; object2[1] = 'ThreadSettings'; object2.FirstThreadMessage = 2; object2[2] = 'FirstThreadMessage'; object2.ApplicationLauncherCommand = 3; object2[3] = 'ApplicationLauncherCommand'; object2.Poll = 4; object2[4] = 'Poll'; object2.SlashCommand = 5; object2[5] = 'SlashCommand'; object2.ForwardContextMessage = 6; object2[6] = 'ForwardContextMessage'; object2.InteractionModal = 7; object2[7] = 'InteractionModal'; const env0_14 = {}; const PersistedStore = (importDefault(566) /* metro dependency 566: flux */).PersistedStore; let value = _fun39984(PersistedStore); value.displayName = 'DraftStore'; value.persistKey = 'DraftStore'; value.migrations = [_fun39996, _fun39997]; value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {CONNECTION_OPEN: CONNECTION_OPEN_39998, LOGOUT: LOGOUT_39999, MULTI_ACCOUNT_REMOVE_ACCOUNT: MULTI_ACCOUNT_REMOVE_ACCOUNT_40000, GUILD_DELETE: function() { pruneNonexistentChannels(); return false; }, CHANNEL_DELETE: closure2, THREAD_DELETE: closure2, THREAD_CREATE: THREAD_CREATE_40002, DRAFT_SAVE: closure, DRAFT_CHANGE: closure, DRAFT_CLEAR: function({channelId, draftType}) { return deleteDraft(channelId, draftType); }, THREAD_SETTINGS_DRAFT_CHANGE: THREAD_SETTINGS_DRAFT_CHANGE}); (require(2) /* metro dependency 2 */).fileFinishedImporting('stores/DraftStore.tsx'); exports.default = value; exports.DraftType = object2; } function _isNativeReflectConstruct_39973() { // fn#39973, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:190, offset: 0x010f1a74, size: 94 bytes, params: 1, frame: 18 var Boolean; var prototype; var valueOf; var call; var Reflect; var construct; var closure; var value; var error; try { Boolean = global.Boolean; prototype = Boolean.prototype; valueOf = prototype.valueOf; call = valueOf.call; Reflect = global.Reflect; construct = Reflect.construct; Boolean = global.Boolean; closure = function() { }; value = Reflect.apply(construct, Reflect, [Boolean, [], closure]); value = Reflect.apply(call, valueOf, [value]); var result = !value; } catch (error) { } return (_isNativeReflectConstruct_39973_isNativeReflectConstruct = function() { return !!result; })(); } function _createForOfIteratorHelperLoose_39976(a0, a1) { // fn#39976, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:383, offset: 0x010f1ad2, size: 370 bytes, params: 3, frame: 20 var r6; var r9; var r5; var value3; var regexp; const env0_0 = a0; const Symbol = global.Symbol; let value = typeof Symbol !== 'undefined'; let r1 = value && a0[global.Symbol.iterator]; r1 = !r1 ? a0['@@iterator'] : r1; if (r1) { value = r1.call(a0); return value.next.bind(value); } const Array = global.Array; if (Array.isArray(a0)) { if (r1) { } return _fun39977; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_39978(a0, value); r5 = value; } else { value3 = ({}).toString.call(a0).slice(8, -1); r6 = value3 === 'Object' && a0.constructor; r9 = r6 ? a0.constructor.name : value3; if (r9 === 'Map') { r6 = global.Array.from(a0); } else if (r9 === 'Set') { r6 = global.Array.from(a0); } else if (r9 === 'Arguments') { value = _arrayLikeToArray_39978(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_39978(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun39977; } const TypeError = global.TypeError; throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); } function getUserDrafts(a0) { // fn#39979, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:1710, offset: 0x010f1c44, size: 35 bytes, params: 2, frame: 4 var r0; var binding; var object2; const property = env0_14[a0]; if (property != null) { r0 = property; } else { binding = env0_14; object2 = {}; binding[a0] = object2; r0 = object2; } return r0; } function DRAFT_CHANGE({type, channelId, draft, draftType}) { // fn#39980, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:1777, offset: 0x010f1c67, size: 239 bytes, params: 2, frame: 19 var r2; var r4; var userDrafts; var property; var object2; draft = draft === ChannelStore.getChannel(channelId)?.template ? '' : draft; const id = AuthenticationStore.getId(); if (id == null) { deleteDraft(channelId, draftType); } else if (draft == null) { deleteDraft(channelId, draftType); } else if (draft !== '') { userDrafts = getUserDrafts(id); property = userDrafts[channelId]; if (property != null) { r2 = property; } else { object2 = {}; userDrafts[channelId] = object2; r2 = object2; } r4 = draft.length > env0_12 ? draft.substr(0, env0_12) : draft; property = r2[draftType]; draft = property?.draft; if (r4 !== draft) { object2 = {}; object2.timestamp = global.Date.now(); object2.draft = r4; r2[draftType] = object2; } } else { deleteDraft(channelId, draftType); } return type === 'DRAFT_SAVE'; } function deleteDraft(a0, a1) { // fn#39981, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:2193, offset: 0x010f1d56, size: 110 bytes, params: 3, frame: 15 let value = a2; const r5 = value !== undefined ? value : AuthenticationStore.getId(); if (r5 == null) { return false; } const userDrafts = getUserDrafts(r5); const property = userDrafts[a0]; if (property == null) { return false; } delete property[a1]; value = importDefault(22) /* metro dependency 22 */; if (value.isEmpty(property)) { delete userDrafts[a0]; } } function _fun39984(a0) { // fn#39984, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:2630, offset: 0x010f1e60, size: 185 bytes, params: 2, frame: 16 const closure = DraftStore; env0_7(closure, a0); return env0_4(closure, [{key: 'initialize', value: value_39986}, {key: 'getState', value: value_39987}, {key: 'getThreadDraftWithParentMessageId', value: value_39988}, {key: 'getRecentlyEditedDrafts', value: value_39990}, {key: 'getDraft', value: value_39994}, {key: 'getThreadSettings', value: value_39995}]); } function _fun39996(a0) { // fn#39996, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:4353, offset: 0x010f22d6, size: 83 bytes, params: 2, frame: 12 var r5; var propertyName; var propertyName2; var ChannelMessage; if (a0 == null) { return {}; } for (propertyName in a0) { if (!('timestamp' in a0[propertyName])) { r5 = propertyName2; continue; } ChannelMessage = env0_13.ChannelMessage; a0[propertyName] = {[ChannelMessage]: a0[propertyName]}; r5 = propertyName2; } return a0; } function _fun39997(a0) { // fn#39997, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:4455, offset: 0x010f2329, size: 77 bytes, params: 2, frame: 17 var propertyName; const id = AuthenticationStore.getId(); if (a0 == null) { return {}; } if (id == null) { return {}; } const object3 = {}; const object4 = {}; object3[id] = object4; for (propertyName in a0) { object4[propertyName] = a0[propertyName]; } return object3; } function CONNECTION_OPEN_39998() { // fn#39998, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:4597, offset: 0x010f2376, size: 52 bytes, params: 1, frame: 11 const id = AuthenticationStore.getId(); if (!(id in env0_14)) { env0_14[id] = {}; } pruneNonexistentChannels(); return false; } function LOGOUT_39999(a0) { // fn#39999, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:4708, offset: 0x010f23aa, size: 25 bytes, params: 2, frame: 2 if (!a0.isSwitchingAccount) { env0_14 = {}; } } function MULTI_ACCOUNT_REMOVE_ACCOUNT_40000(a0) { // fn#40000, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:4792, offset: 0x010f23c3, size: 39 bytes, params: 2, frame: 4 const userId = a0.userId; if (userId in env0_14) { delete env0_14[a0.userId]; } } function THREAD_CREATE_40002({channel}) { // fn#40002, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:5027, offset: 0x010f23fb, size: 333 bytes, params: 2, frame: 20 var ChannelMessage; var object; const id2 = AuthenticationStore.getId(); if (id2 == null) { return false; } if (channel.ownerId === id2) { return false; } const userDrafts = getUserDrafts(id2); let parent_id = channel.parent_id; let property = userDrafts[parent_id]; if (property == null) { return false; } let ThreadSettings = env0_13.ThreadSettings; property = property[ThreadSettings]; if (property == null) { return false; } const parentMessageId = property.parentMessageId; const defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */; const castChannelIdAsMessageId = defaultImport.castChannelIdAsMessageId; let id = channel.id; if (parentMessageId !== Reflect.apply(castChannelIdAsMessageId, defaultImport, [id])) { return false; } if (userDrafts[channel.parent_id] == null) { return false; } let FirstThreadMessage = env0_13.FirstThreadMessage; property = property[FirstThreadMessage]; const draft = property?.draft; const value5 = ''; const r8 = draft ?? value5; if (value5 !== r8) { id = channel.id; ChannelMessage = env0_13.ChannelMessage; object = {}; object.timestamp = global.Date.now(); object.draft = r8; userDrafts[id] = {[ChannelMessage]: object}; } const deleteDraftBinding = deleteDraft; parent_id = channel.parent_id; const binding = env0_13; ThreadSettings = binding.ThreadSettings; deleteDraftBinding(parent_id, ThreadSettings); parent_id = channel.parent_id; FirstThreadMessage = binding.FirstThreadMessage; deleteDraftBinding(parent_id, FirstThreadMessage); } function THREAD_SETTINGS_DRAFT_CHANGE({channelId, draft}) { // fn#40004, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:5742, offset: 0x010f2567, size: 143 bytes, params: 2, frame: 17 var r2; var userDrafts; var property; var object2; var binding; var ThreadSettings; var Date; const id = AuthenticationStore.getId(); if (id != null) { userDrafts = getUserDrafts(id); property = userDrafts[channelId]; if (property != null) { r2 = property; } else { object2 = {}; userDrafts[channelId] = object2; r2 = object2; } binding = env0_13; ThreadSettings = binding.ThreadSettings; object2 = {}; Date = global.Date; object2.timestamp = Date.now(); copyDataProperties(object2, r2[binding.ThreadSettings], Date); copyDataProperties(object2, draft, Date); object2['parentChannelId'] = channelId; r2[ThreadSettings] = object2; } } function value_39986(a0) { // fn#39986, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:2910, offset: 0x010f1f19, size: 337 bytes, params: 2, frame: 31 var r6; var r14; var r2; var value4; var value5; var property; var property2; var defaultImport2; var value6; var value7; var value8; var value9; var property3; var property4; var ChannelMessage; var property5; var draft; var value10; var trim; var value11; var deleteDraftBinding; var value12; var value13; const r0 = a0 ?? ({}); value = environment.__proto__; env1_14 = r0; let _createForOfIteratorHelperLoose_39976Binding = _createForOfIteratorHelperLoose_39976; const defaultImport = importDefault(21) /* metro dependency 21: SnowflakeUtils */; let entries = defaultImport.entries; const value2 = _createForOfIteratorHelperLoose_39976Binding(Reflect.apply(entries, defaultImport, [env1_14])); const value3 = value2(); let done = value3.done; if (!done) { r6 = value3; while (true) { value4 = r6.value; value5 = env1_8(value4, 2); property = value5[0]; property2 = value5[1]; _createForOfIteratorHelperLoose_39976Binding = _createForOfIteratorHelperLoose_39976; defaultImport2 = defaultImport; entries = defaultImport2.entries; value6 = _createForOfIteratorHelperLoose_39976Binding(Reflect.apply(entries, defaultImport2, [property2])); value7 = value6(); done = value7.done; if (!done) { r14 = value7; while (true) { value8 = r14.value; value9 = env1_8(value8, 2); property3 = value9[0]; property4 = value9[1]; ChannelMessage = env1_13.ChannelMessage; property5 = property4[ChannelMessage]; if (property5 != null) { draft = property5.draft; value10 = draft !== ''; if (!value10) { r2 = value10; continue; } draft = property5.draft; trim = draft.trim; value11 = Reflect.apply(trim, draft, []) !== ''; r2 = value11; if (r2) { break; } deleteDraftBinding = deleteDraft; ChannelMessage = env1_13.ChannelMessage; deleteDraftBinding(property3, ChannelMessage, property); break; } value12 = value6(); done = value12.done; if (done) { break; } r14 = value12; continue; } } value13 = value2(); done = value13.done; if (done) { break; } r6 = value13; continue; } } this.waitFor(AuthenticationStore, ChannelStore, GuildAvailabilityStore); } function value_39988(a0) { // fn#39988, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:3411, offset: 0x010f206a, size: 120 bytes, params: 2, frame: 16 var environment; var r0; var getUserDraftsBinding; var value3; var userDraftsBinding; const env0_1 = a0; let value = environment.__proto__; const id = AuthenticationStore.getId(); if (id != null) { getUserDraftsBinding = getUserDrafts; value3 = undefined; userDraftsBinding = getUserDraftsBinding(id); value = importDefault(21) /* metro dependency 21: SnowflakeUtils */; value = value.keys(userDraftsBinding); value = value.find(_fun39989); if (value != null) { value = this.getThreadSettings(value); r0 = value; } else { r0 = value3; } return r0; } } function value_39990(a0) { // fn#39990, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:3671, offset: 0x010f2112, size: 178 bytes, params: 2, frame: 15 var environment; const env0_0 = a0; let value = environment.__proto__; const id = AuthenticationStore.getId(); if (id == null) { return []; } const value5 = (importDefault(22) /* metro dependency 22 */)(getUserDrafts(id)).mapValues(_fun39991); value = value5.pickBy((require(1360) /* metro dependency 1360: GlobalUtils */).isNotNullish); value = value.toPairs(); value = value.map(function(a0) { var r1; var r2; var r32; var item3; var value3; var timestamp; var draft; var error; var iterator = a0[Symbol.iterator](); var iterator2 = iterator.next; var value = undefined; var item2 = Reflect.apply(iterator2, iterator, []); var item = item2.value; item2 = item2.done ? undefined : iterator; var value2 = item2 === value; var r3 = value2 ? value : item; if (value2) { r1 = item2; r2 = value2; r32 = value; } else { item3 = Reflect.apply(iterator2, item2, []); item = item3.value; item3 = item3.done ? undefined : item2; value3 = item3 === value; if (value3) { r1 = item3; r2 = value3; r32 = value; } else { r1 = item3; r2 = value3; r32 = item; } } try { timestamp = r32.timestamp; draft = r32.draft; } catch (error) { if (!r2) { try { r1.return(); } catch { } } throw error; } if (!r2) { r1.return(); } return {channelId: r3, timestamp: timestamp, draft: draft}; }); value = value.sortBy(function(a0) { return -a0.timestamp; }); return value.value(); } function value_39994(a0, a1) { // fn#39994, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:3972, offset: 0x010f2246, size: 76 bytes, params: 3, frame: 12 const value = environment.__proto__; const id = AuthenticationStore.getId(); if (id != null) { var property = getUserDrafts(id)[a0]; if (property == null) { return ''; } property = property[a1]; if (property != null) { return property.draft; } } return ''; } function value_39995(a0) { // fn#39995, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:4139, offset: 0x010f2292, size: 68 bytes, params: 2, frame: 13 const id = AuthenticationStore.getId(); const value3 = null; if (value3 == id) { return value3; } const property = getUserDrafts(id)[a0]; return value3 == property ? value3 : property[env1_13.ThreadSettings]; } function _fun39989(a0) { // fn#39989, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:3499, offset: 0x010f20e2, size: 48 bytes, params: 2, frame: 12 return env0_0.getThreadSettings(a0)?.parentMessageId === env0_1; } function _fun39991(a0) { // fn#39991, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4823:3772, offset: 0x00c3fa42, size: 27 bytes, params: 2, frame: 3 return a0?.[env0_0]; }