Files
2026-07-28 01:06:53 +03:00

277 lines
13 KiB
TypeScript

/* Metro module 7118; source: modules/go_live/utils/StreamPermissionUtils.tsx; dependencies: [4295, 1383, 1935, 1867, 3784, 4297, 661, 4808, 1244, 4800, 5072, 566, 2] */
import GuildStore from '../../../stores/GuildStore.tsx'; /* Metro dependency 1867 */
import PermissionStore from '../../../stores/PermissionStore.tsx'; /* Metro dependency 3784 */
import GameConsoleStore from '../../game_console/GameConsoleStore.tsx'; /* Metro dependency 4295 */
import VoiceStateStore from '../../../stores/VoiceStateStore.tsx'; /* Metro dependency 4297 */
import CanJoinVoiceChannel from '../../channel/canJoinVoiceChannel.tsx'; /* Metro dependency 4808 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as FluxModule from '../../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
import * as ConstantsModule from '../../../Constants.tsx'; /* Metro dependency 661 */
import * as IndexNativeModule from '../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as ChannelRecordModule from '../../../records/ChannelRecord.tsx'; /* Metro dependency 1383 */
import * as GuildChannelStoreModule from '../../../stores/GuildChannelStore.tsx'; /* Metro dependency 1935 */
function _fun56927(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#56927, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:6, offset: 0x013d5f45, size: 387 bytes, params: 8, frame: 23
let env0_0 = require;
const _arrayLikeToArray_56930 = 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 canStreamInChannel2 = canStreamInChannel;
const canWatchStream2 = canWatchStream;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {REMOTE_MODE: 0};
object[0] = 'REMOTE_MODE';
object.CHANNEL_FULL = 1;
object[1] = 'CHANNEL_FULL';
object.NO_PERMISSION = 2;
object[2] = 'NO_PERMISSION';
object.AGE_RESTRICTED = 3;
object[3] = 'AGE_RESTRICTED';
(FileImportTrackerModule).fileFinishedImporting('modules/go_live/utils/StreamPermissionUtils.tsx');
exports.canStreamInChannel = canStreamInChannel2;
exports.getStreamCTAString = getStreamCTAString;
exports.getStreamCTAAriaLabel = getStreamCTAAriaLabel;
exports.StreamUnavailableReasons = object;
exports.canWatchStream = canWatchStream2;
exports.useCanWatchStream = function(a0) {
var env0_0 = a0;
return require(dependencyMap[11]).useStateFromStoresArray([VoiceStateStore, GuildStore, PermissionStore,
GameConsoleStore], _fun56936);
};
exports.getStreamEligibleChannels = function(a0, a1, a2) {
var r2;
var channel;
var value4;
var items = [];
var value2 = _createForOfIteratorHelperLoose_56928(a0[GUILD_VOCAL_CHANNELS_KEY]);
var value3 = value2();
if (!value3.done) {
r2 = value3;
while (true) {
channel = r2.value.channel;
if (canStreamInChannel(channel, a1, a2)) {
items.push(channel);
}
value4 = value2();
if (value4.done) {
break;
}
r2 = value4;
continue;
}
}
return items;
};
function _createForOfIteratorHelperLoose_56928(a0, a1) { // fn#56928, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:228, offset: 0x013d60c8, 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 _fun56929;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_56930(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_56930(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_56930(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun56929;
}
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 _fun56929() { // fn#56929, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:799, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function canStreamInChannel(a0, a1, a2) { // fn#56931, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:1138, offset: 0x013d623a, size: 223 bytes, params: 4, frame: 19
let value = a3;
const value2 = undefined;
let r1 = !(value !== value2) || value;
if (a0.isPrivate()) {
return true;
}
const getGuild = a1.getGuild;
const getGuildId = a0.getGuildId;
value = Reflect.apply(getGuild, a1, [Reflect.apply(getGuildId, a0, [])]);
const maxStageVideoChannelUsers = value == null ? value2 : value.maxStageVideoChannelUsers;
const value3 = 0;
let r0 = a0.isGuildStageVoice() && (maxStageVideoChannelUsers ?? value3) <= value3;
if (r0) {
r0 = !r0;
} else {
r1 = r1 && !(importDefault(4808) /* metro dependency 4808: canJoinVoiceChannel */)(a0, a2);
r1 = !r1 && (a2.can(Permissions.STREAM,
a0) ? value != null && value.afkChannelId !== a0.id : !!a2.can(Permissions.STREAM, a0));
r0 = r1;
}
return r0;
}
function canWatchStream(a0, a1, a2, a3, a4) { // fn#56932, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:1595, offset: 0x013d6319, size: 356 bytes, params: 6, frame: 21
var r5;
var moduleValue3;
if (a0 == null) {
return [false, env0_10.NO_PERMISSION];
}
const value = a1.isInChannel(a0.id);
const r4 = a0 instanceof ChannelRecordBase && (require(4800) /* metro dependency 4800: ChannelUtils */).isChannelFull(a0,
a1, a2);
const value4 = undefined;
const value5 = (CanJoinVoiceChannel)(a0, a3);
const getAwaitingRemoteSessionInfo = a4.getAwaitingRemoteSessionInfo;
const r6 = Reflect.apply(getAwaitingRemoteSessionInfo, a4, []) != null || a4.getRemoteSessionId() != null;
const shouldAgeVerifyForAgeGate2 = (require(5072) /* metro dependency 5072: AgeGateUtils */).shouldAgeVerifyForAgeGate();
if (shouldAgeVerifyForAgeGate2) {
moduleValue3 = require(5072) /* metro dependency 5072: AgeGateUtils */;
r5 = moduleValue3.shouldShowAgeGateForChannelId(a0.id);
} else {
r5 = shouldAgeVerifyForAgeGate2;
}
return [!r6 && !r5 && (value || value5 && !r4),
r6 ? env0_10.REMOTE_MODE : r5 ? env0_10.AGE_RESTRICTED : value5 || value ? r4 && !value ? env0_10.CHANNEL_FULL : value4 : env0_10.NO_PERMISSION];
}
function getStreamCTAString(a0) { // fn#56933, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:2185, offset: 0x013d647d, size: 366 bytes, params: 2, frame: 15
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
const REMOTE_MODE = env0_10.REMOTE_MODE;
if (REMOTE_MODE === a0) {
return intl.string(t['1i3tSY']);
}
const CHANNEL_FULL = env0_10.CHANNEL_FULL;
if (CHANNEL_FULL === a0) {
return intl.string(t.elyVbv);
}
const NO_PERMISSION = env0_10.NO_PERMISSION;
if (NO_PERMISSION === a0) {
return intl.string(t.pgUTZC);
}
const AGE_RESTRICTED = env0_10.AGE_RESTRICTED;
if (AGE_RESTRICTED === a0) {
return intl.string(t.b5FqhF);
}
return intl.string(t['7Xq/nV']);
}
function getStreamCTAAriaLabel(a0) { // fn#56934, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:2584, offset: 0x013d65eb, size: 739 bytes, params: 2, frame: 18
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
const REMOTE_MODE = env0_10.REMOTE_MODE;
if (REMOTE_MODE === a0) {
return '' + intl.string(t['7Xq/nV']) + ': ' + intl.string(t['1i3tSY']);
}
const CHANNEL_FULL = env0_10.CHANNEL_FULL;
if (CHANNEL_FULL === a0) {
return '' + intl.string(t['7Xq/nV']) + ': ' + intl.string(t.elyVbv);
}
const NO_PERMISSION = env0_10.NO_PERMISSION;
if (NO_PERMISSION === a0) {
return '' + intl.string(t['7Xq/nV']) + ': ' + intl.string(t.pgUTZC);
}
const AGE_RESTRICTED = env0_10.AGE_RESTRICTED;
if (AGE_RESTRICTED === a0) {
return '' + intl.string(t['7Xq/nV']) + ': ' + intl.string(t.b5FqhF);
}
return '' + intl.string(t['7Xq/nV']) + ': ' + intl.string(t['9C444m']);
}
function useCanWatchStream(a0) { // fn#56935, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:3300, offset: 0x013d68ce, size: 89 bytes, params: 2, frame: 15
const env0_0 = a0;
return (FluxModule).useStateFromStoresArray([VoiceStateStore, GuildStore,
PermissionStore, GameConsoleStore], _fun56936);
function _fun56936() { // fn#56936, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7296:3382, offset: 0x013d6927, size: 38 bytes, params: 1, frame: 19
return canWatchStream(env0_0, VoiceStateStore, GuildStore, PermissionStore, GameConsoleStore);
}
}
}
global.__d(_fun56927, 7118, [4295, 1383, 1935, 1867, 3784, 4297, 661, 4808, 1244, 4800, 5072, 566,
2]) /* metro module 7118, dependencies: [4295, 1383, 1935, 1867, 3784, 4297, 661, 4808, 1244, 4800, 5072, 566, 2] */;