/* Metro module 1938; source: stores/GuildRoleStore.tsx; dependencies: [6, 7, 15, 17, 18, 1419, 1868, 1422, 1939, 483, 1940, 1942, 1870, 2] */ function _fun21515(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#21515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:6, offset: 0x00ef296c, size: 517 bytes, params: 8, frame: 19 var object2; const _arrayLikeToArray_21518 = 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 checkGuildRolesExist = function(a0, a1, a2) { var Error; var value = a2.partitionLength(a1); if (value === 0) { Error = global.Error; value = 'Guild data was missing from store for guild ' + a1 + ': missing roles. (phase: ' + a0 + ')'; value = new Error(value); throw value; } }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_2 = importDefault(6) /* metro dependency 6 */; const env0_3 = importDefault(7) /* metro dependency 7 */; const env0_4 = importDefault(15) /* metro dependency 15 */; const env0_5 = importDefault(17) /* metro dependency 17 */; const env0_6 = importDefault(18) /* metro dependency 18 */; const env0_7 = (require(1419) /* metro dependency 1419: PlainRecord */).constructInPlace; const LibdiscoreStore = (require(1868) /* metro dependency 1868: LibdiscoreStore */).LibdiscoreStore; const env0_8 = (require(1422) /* metro dependency 1422: GuildRecord */).getGuildEveryoneRoleId; const env0_9 = (require(1939) /* metro dependency 1939: GuildRoleRecord */).GuildRoleRecordTypeTag; let value = _fun21525(LibdiscoreStore); value.displayName = 'GuildRoleStore'; object2 = {BACKGROUND_SYNC: BACKGROUND_SYNC_21537, OVERLAY_INITIALIZE: function(a0, a1) { var r2; var property; var partitionKey; var moduleValue; var value4; a1.clear(); var value2 = _createForOfIteratorHelperLoose_21516(a0.serializedGuildRoles); var value3 = value2(); if (!value3.done) { for (r2 = value3; true; r2 = value4) { property = r2.value; partitionKey = property.partitionKey; property = property.values; moduleValue = importAll(dependencyMap[11]); a1.setPartition(partitionKey, moduleValue.fromSerializedPartition(partitionKey, property)); value4 = value2(); if (value4.done) { break; } } } }, LOGOUT: function(a0, a1) { a1.clear(); }, RESET_SOCKET: function(a0, a1) { a1.clear(); }, CONNECTION_OPEN: CONNECTION_OPEN_21541, CACHE_LOADED: CACHE_LOADED_21543, CACHE_LOADED_LAZY: CACHE_LOADED_LAZY_21544, GUILD_CREATE: function({guild}, a1) { var id = guild.id; guild = guild.roles; syncRoles(id, guild, a1); checkGuildRolesExist('guild_create', id, a1); }, GUILD_UPDATE: GUILD_UPDATE_21546, GUILD_DELETE: function({guild}, a1) { if (!guild.unavailable) { a1.removePartition(guild.id); } }, GUILD_ROLE_CREATE: GUILD_ROLE_CREATE_21548, GUILD_ROLE_UPDATE: GUILD_ROLE_UPDATE, GUILD_ROLE_DELETE: function({guildId, roleId}, a1) { a1.removeRecord(guildId, roleId); }}; const LibdiscoreBatchStoreRefactorExperiment = (require(1870) /* metro dependency 1870: libdiscoreExperiments */).LibdiscoreBatchStoreRefactorExperiment; value = new value(object2, LibdiscoreBatchStoreRefactorExperiment.getCachedBridgedStoreMode()); (require(2) /* metro dependency 2 */).fileFinishedImporting('stores/GuildRoleStore.tsx'); exports.default = value; } function _createForOfIteratorHelperLoose_21516(a0, a1) { // fn#21516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:274, offset: 0x00ef2b71, 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 _fun21517; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_21518(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_21518(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_21518(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun21517; } 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 _isNativeReflectConstruct_21519() { // fn#21519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:1184, offset: 0x00ef2ce3, 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_21519_isNativeReflectConstruct = function() { return !!result; })(); } function createGuildRoleRecordFromRust(a0) { // fn#21522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:1377, offset: 0x00ef2d41, size: 82 bytes, params: 2, frame: 16 var value; const constructInPlaceBinding = constructInPlace; const object2 = {}; copyDataProperties(object2, a0, undefined); value = Reflect.apply((importAll(483) /* metro dependency 483: BigFlagUtils */).deserialize, value, [a0.permissions]); object2['permissions'] = value; return constructInPlaceBinding(GuildRoleRecordTypeTag, object2); } function syncRoles(a0, a1, a2) { // fn#21523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:2786, offset: 0x00ef2d93, size: 130 bytes, params: 4, frame: 17 var setPartition; let value = a1.op === 'update'; if (!(value && a1.writes.length === 0 && a1.deletes.length === 0)) { setPartition = a2.setPartition; value = importAll(1942) /* metro dependency 1942: GuildRoleRecordUtils */; Reflect.apply(setPartition, a2, [a0, value.fromSyncOperation(a0, a1, a2.getPartition(a0))]); } } function _fun21525(a0) { // fn#21525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:1500, offset: 0x00ef2e75, size: 235 bytes, params: 2, frame: 16 const closure = GuildRoleStore; env0_6(closure, a0); return env0_3(closure, [{key: 'stateWrapper', value: function() { return this.database; }}, {key: 'serializeAllGuildRoles', value: function() { return this.database.mapPartitions(importAll(dependencyMap[11]).toSerializedPartition); }}, {key: 'getUnsafeMutableRoles', value: function(a0) { return this.database.getPartition(a0); }}, {key: 'getManyRoles', value: function(a0, a1) { return this.database.getManyRecords(a0, a1); }}, {key: 'getRole', value: function(a0, a1) { return this.database.getRecord(a0, a1); }}, {key: 'getNumRoles', value: function(a0) { return this.database.partitionLength(a0); }}, {key: 'getEveryoneRole', value: value_21535}, {key: 'partitionVersion', value: function(a0) { return this.database.partitionVersion(a0); }}]); } function BACKGROUND_SYNC_21537({guilds}, a1) { // fn#21537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:3164, offset: 0x00ef3192, size: 252 bytes, params: 3, frame: 30 var r2; var r1; var value4; var getNullablePartition; var id; var value5; var value6; var data_mode; var value7; var setPartition; var moduleValue; var fromServerArray; var id2; var roles; var value8; var moduleValue2; var filterRoleDeletes; var id3; var partial_updates; var deleted_role_ids; var value9; var value10; const value2 = _createForOfIteratorHelperLoose_21516(guilds); const value3 = value2(); let done = value3.done; if (!done) { r2 = value3; while (true) { value4 = r2.value; getNullablePartition = a1.getNullablePartition; id = value4.id; value5 = Reflect.apply(getNullablePartition, a1, [id]); value6 = value5 != null; if (value6) { value7 = value4.data_mode !== 'unavailable'; r1 = value7; } else { r1 = value6; } if (!r1) { continue; } setPartition = a1.setPartition; id = value4.id; data_mode = value4.data_mode; if (data_mode === 'partial') { moduleValue2 = importAll(1940) /* metro dependency 1940: GuildRoleUtils */; filterRoleDeletes = moduleValue2.filterRoleDeletes; id3 = value4.id; partial_updates = value4.partial_updates; roles = partial_updates.roles; partial_updates = value4.partial_updates; deleted_role_ids = partial_updates.deleted_role_ids; value9 = Reflect.apply(filterRoleDeletes, moduleValue2, [id3, value5, roles, deleted_role_ids]); r1 = value9; } else { moduleValue = importAll(1942) /* metro dependency 1942: GuildRoleRecordUtils */; fromServerArray = moduleValue.fromServerArray; id2 = value4.id; roles = value4.roles; value8 = Reflect.apply(fromServerArray, moduleValue, [id2, roles]); r1 = value8; } Reflect.apply(setPartition, a1, [id, r1]); value10 = value2(); done = value10.done; if (done) { break; } r2 = value10; continue; } } } function CONNECTION_OPEN_21541({guilds, unavailableGuilds}, a1) { // fn#21541, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:3805, offset: 0x00ef330d, size: 276 bytes, params: 3, frame: 19 var r3; var r2; var value6; var value7; var value10; var has; var value11; var value13; var id; var syncRolesBinding; var roles; var value14; const Set = global.Set; let set = new Set(guilds.map(function(a0) { return a0.id; })); const value4 = _createForOfIteratorHelperLoose_21516(unavailableGuilds); const value5 = value4(); let done = value5.done; if (!done) { for (r3 = value5; true; r3 = value7) { value6 = r3.value; set.add(value6); value7 = value4(); done = value7.done; if (done) { break; } } } _createForOfIteratorHelperLoose_21516Binding = _createForOfIteratorHelperLoose_21516; const getPartitionKeys = a1.getPartitionKeys; const value8 = _createForOfIteratorHelperLoose_21516Binding(Reflect.apply(getPartitionKeys, a1, [])); const value9 = value8(); done = value9.done; if (!done) { r3 = value9; while (true) { value10 = r3.value; has = set.has; if (!Reflect.apply(has, set, [value10])) { a1.removePartition(value10); } value11 = value8(); done = value11.done; if (done) { break; } r3 = value11; continue; } } set = _createForOfIteratorHelperLoose_21516(guilds); const value12 = set(); done = value12.done; if (!done) { for (r2 = value12; true; r2 = value14) { value13 = r2.value; id = value13.id; syncRolesBinding = syncRoles; roles = value13.roles; syncRolesBinding(id, roles, a1); checkGuildRolesExist('connection_open', id, a1); value14 = set(); done = value14.done; if (done) { break; } } } } function CACHE_LOADED_21543({guilds}, a1) { // fn#21543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:4249, offset: 0x00ef3421, size: 142 bytes, params: 3, frame: 22 var r2; var value4; var id; var roles; var setPartition; var moduleValue; var fromSerializedPartition; var value5; a1.clear(); const value2 = _createForOfIteratorHelperLoose_21516(guilds); const value3 = value2(); let done = value3.done; if (!done) { for (r2 = value3; true; r2 = value5) { value4 = r2.value; id = value4.id; roles = value4.roles; setPartition = a1.setPartition; moduleValue = importAll(1942) /* metro dependency 1942: GuildRoleRecordUtils */; fromSerializedPartition = moduleValue.fromSerializedPartition; Reflect.apply(setPartition, a1, [id, Reflect.apply(fromSerializedPartition, moduleValue, [id, roles])]); checkGuildRolesExist('cache_loaded', id, a1); value5 = value2(); done = value5.done; if (done) { break; } } } } function CACHE_LOADED_LAZY_21544(a0, a1) { // fn#21544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:4488, offset: 0x00ef34af, size: 164 bytes, params: 3, frame: 22 var r1; var clear; var value; var _createForOfIteratorHelperLoose_21516Binding; var value2; var value3; var done; var value4; var id; var roles; var setPartition; var moduleValue; var fromSerializedPartition; var value5; let guilds = a0.guilds; reducibleJoin3: while (true) { if (guilds.length === 0) { break reducibleJoin3; } clear = a1.clear; Reflect.apply(clear, a1, []); value = environment; _createForOfIteratorHelperLoose_21516Binding = _createForOfIteratorHelperLoose_21516; guilds = a0.guilds; value2 = _createForOfIteratorHelperLoose_21516Binding(guilds); value3 = value2(); done = value3.done; if (done) { break reducibleJoin3; } r1 = value3; reducibleLoop2: while (true) { value4 = r1.value; id = value4.id; roles = value4.roles; setPartition = a1.setPartition; moduleValue = importAll(1942) /* metro dependency 1942: GuildRoleRecordUtils */; fromSerializedPartition = moduleValue.fromSerializedPartition; Reflect.apply(setPartition, a1, [id, Reflect.apply(fromSerializedPartition, moduleValue, [id, roles])]); checkGuildRolesExist('cache_loaded_lazy', id, a1); value5 = value2(); done = value5.done; if (done) { break reducibleJoin3; } r1 = value5; continue reducibleLoop2; } } } function GUILD_UPDATE_21546({guild}, a1) { // fn#21546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:4851, offset: 0x00ef358c, size: 73 bytes, params: 3, frame: 16 const id = guild.id; const roles = guild.roles; const setPartition = a1.setPartition; const guildRoleRecordUtilsModule = importAll(1942) /* metro dependency 1942: GuildRoleRecordUtils */; Reflect.apply(setPartition, a1, [id, guildRoleRecordUtilsModule.fromServerArray(id, roles)]); } function GUILD_ROLE_CREATE_21548(a0, a1) { // fn#21548, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:5021, offset: 0x00ef35fd, size: 85 bytes, params: 3, frame: 19 const setRecord = a1.setRecord; const guildId = a0.guildId; const id = a0.role.id; const value = importAll(1942) /* metro dependency 1942: GuildRoleRecordUtils */; Reflect.apply(setRecord, a1, [guildId, id, value.fromServer(a0.guildId, a0.role)]); } function GuildRoleStore(a0) { // fn#21526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:1512, offset: 0x00ef2f60, size: 212 bytes, params: 2, frame: 21 var r0; var Reflect; let value = copyRestArgs(0, undefined); let binding = env1_2; binding(this, GuildRoleStore); const items2 = []; arraySpread(items2, value, 0, items2); value = env1_5(GuildRoleStore); binding = env1_4; if (_isNativeReflectConstruct_21519()) { Reflect = global.Reflect; value = Reflect.construct(value, items2, env1_5(this).constructor); r0 = value; } else { value = value.apply(this, items2); r0 = value; } value = binding(this, r0); value.database = value.addKKVDatabase('guild_roles', createGuildRoleRecordFromRust); value.getSortedRoles = value.database.memoizedPartition(_fun21527); value.getRolesSnapshot = value.database.memoizedPartition(function(a0, a1) { var r1; var object = {}; copyDataProperties(object, a1, r1); return object; }); return value; } function value_21535(a0) { // fn#21535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:2559, offset: 0x00ef3122, size: 87 bytes, params: 2, frame: 13 let value = environment.__proto__; value = getGuildEveryoneRoleId(a0); value = this.database.getRecord(a0.id, value); if (value == null) { throw new global.Error('Guild does not have an @everyone role'); } return value; } function _fun21527(a0, a1) { // fn#21527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:2065:1860, offset: 0x00ef3034, size: 59 bytes, params: 3, frame: 13 let value = environment.__proto__.__proto__; value = importAll(1940) /* metro dependency 1940: GuildRoleUtils */; const sortGuildRoleRecords = value.sortGuildRoleRecords; const Object = global.Object; return Reflect.apply(sortGuildRoleRecords, value, [Object.values(a1)]); }