// Module ID: 12005 // Function ID: 12006 // Name: useIOSCompletionStates // Dependencies: [1982, 1909, 4091, 12006, 12000, 676, 4415, 12007, 2009, 12008, 589, 12003, 12119, 1236, 11, 2] // Exports: createGuildProgress, hideActionSheet, openActionSheet, useGuildProgressStep, useIsEligibleForGuildProgress // Module 12005 (useIOSCompletionStates) import DISCORD_EPOCHDefault from "DISCORD_EPOCH" /* 11 */; import getSystemLocale from "getSystemLocale" /* 1236 */; import asyncRequireImpl from "asyncRequireImpl" /* 2009 */; import ACTION_SHEET_HEIGHT_HALFDefault from "ACTION_SHEET_HEIGHT_HALF" /* 4415 */; import dispatcherDefault from "dispatcher" /* 12008 */; import closure_3 from "comparator" /* 1982 */; import closure_4 from "createGuildRecordFromRust" /* 1909 */; import closure_5 from "getUncachedChannelPermissions" /* 4091 */; import closure_6 from "completeStep" /* 12006 */; import { Steps } from "Steps" /* 12000 */; import ME from "ME" /* 676 */; require = arg1; function useIOSCompletionStates(guild) { const _require = guild; let obj = _require(589); const items = [closure_5]; const stateFromStores = obj.useStateFromStores(items, () => closure_1_5.can(closure_1_9.ADMINISTRATOR, closure_0)); const guildPersonalized = _require(12003).useGuildPersonalized(guild); const obj2 = _require(12003); const guildPopulated = _require(12003).useGuildPopulated(guild); const obj3 = _require(12003); const items1 = [closure_3]; const stateFromStores1 = _require(589).useStateFromStores(items1, () => closure_1_3.getDefaultChannel(guild.id)); const obj4 = _require(589); if (null != stateFromStores1) { const items2 = [stateFromStores1]; let items3 = items2; } else { items3 = []; } const channelsMessaged = _require(12003).useChannelsMessaged(items3); let tmpResult = tmp(589); const items4 = [closure_6]; let stateFromStores2 = channelsMessaged; if (!channelsMessaged) { stateFromStores2 = tmpResult.useStateFromStores(items4, () => { const progress = closure_1_6.getProgress(guild.id); let flag; if (progress != null) { flag = progress.has(closure_1_7.MESSAGE); } if (flag == null) { flag = false; } return flag; }); } tmpResult = tmp(589); const items5 = [closure_4]; const stateFromStores3 = tmpResult.useStateFromStores(items5, () => { guild = closure_1_4.getGuild(guild.id); let num; if (guild != null) { num = guild.premiumSubscriberCount; } if (num == null) { num = 0; } return num > 0; }); const obj5 = _require(12003); const tmp8 = closure_6; const items6 = [tmp8]; const stateFromStores4 = _require(589).useStateFromStores(items6, () => closure_1_6.getProgress(guild.id)); if (stateFromStores) { const ServerSetupBoostCtaExperiment = tmp(12119).ServerSetupBoostCtaExperiment; const enabled = ServerSetupBoostCtaExperiment.getConfig({ location: "GuildProgress" }).enabled; const items7 = [guildPopulated, guildPersonalized, stateFromStores2]; if (enabled) { items7.push(stateFromStores3); } let length = items7.filter((arg0) => arg0).length; let hasItem; if (stateFromStores4 != null) { hasItem = stateFromStores4.has(Steps.COMPLETED); } if (!hasItem) { hasItem = length === length2; } obj = { guildPopulated: null, guildPersonalized: null, guildMessaged: null, guildBoosted: null, showBoostStep: null, completed: null, dismissed: null, numFinished: null, totalSteps: null }; obj[0] = guildPopulated; obj[1] = guildPersonalized; obj[2] = stateFromStores2; obj[3] = stateFromStores3; obj[4] = enabled; obj[5] = hasItem; let hasItem1 = null == stateFromStores4; if (!hasItem1) { hasItem1 = stateFromStores4.has(Steps.DISMISSED); } obj[6] = hasItem1; if (hasItem) { length = length2; } obj[7] = length; obj[8] = items7.length; return obj; } else { return { guildPopulated: false, guildPersonalized: false, guildMessaged: false, guildChannelCreated: false, guildBoosted: false, showBoostStep: false, completed: true, dismissed: true, numFinished: 0, totalSteps: 0 }; } const tmpResult1 = _require(589); } ({ WELCOME_OLD_GUILD_AGE_THRESHOLD: closure_8, Permissions: c9 } = ME); const result = require("set").fileFinishedImporting("modules/guild_progress/native/GuildProgressUtils.tsx"); export const MIN_PROGRESS_PERCENT = 3; export const PROGRESS_BACKGROUND_COLOR = "rgba(78, 93, 148, 0.3)"; export const openActionSheet = function openActionSheet(guild) { let obj = ACTION_SHEET_HEIGHT_HALFDefault; obj = { guild }; obj.openLazy(asyncRequireImpl(12007, dependencyMap.paths), "guild-progress-" + guild.id, obj); }; export const hideActionSheet = function hideActionSheet(arg0) { ACTION_SHEET_HEIGHT_HALFDefault.hideActionSheet("guild-progress-" + arg0); }; export const createGuildProgress = function createGuildProgress(closure_0) { if (null != guild.getGuild(closure_0)) { const progress = dispatcherDefault.createProgress(closure_0); const obj = dispatcherDefault; } }; export { useIOSCompletionStates }; export const useGuildProgressStep = function useGuildProgressStep(guild) { const tmp = useIOSCompletionStates(guild); const totalSteps = tmp.totalSteps; let stringResult = null; ({ guildPersonalized, guildMessaged, guildBoosted, showBoostStep, completed } = tmp); if (!tmp.guildPopulated) { const intl = getSystemLocale.intl; stringResult = intl.string(getSystemLocale.t.q9n0Ta); } const items = [stringResult, , ]; let stringResult1 = null; if (!guildPersonalized) { const intl2 = getSystemLocale.intl; stringResult1 = intl2.string(getSystemLocale.t.DWB2YZ); } items[1] = stringResult1; let stringResult2 = null; if (!guildMessaged) { const intl3 = getSystemLocale.intl; stringResult2 = intl3.string(getSystemLocale.t.dNktpr); } items[2] = stringResult2; if (showBoostStep) { let stringResult3 = null; if (!guildBoosted) { const intl4 = getSystemLocale.intl; stringResult3 = intl4.string(getSystemLocale.t["6Qbqxw"]); } items.push(stringResult3); } const length = items.filter((arg0) => null == arg0).length; let found = items.find((arg0) => null != arg0); if (found == null) { const intl5 = getSystemLocale.intl; found = intl5.string(getSystemLocale.t["+Gyklt"]); } let obj = { percentComplete: Math.max(3, 100 * length / totalSteps), subtitle: null, completed: null }; if (length < totalSteps) { const intl7 = getSystemLocale.intl; obj = { currStep: null, total: null, step: null }; obj[0] = length + 1; obj[1] = totalSteps; obj[2] = found; let formatToPlainStringResult = intl7.formatToPlainString(getSystemLocale.t.zhHW5c, obj); } else { const intl6 = getSystemLocale.intl; formatToPlainStringResult = intl6.string(getSystemLocale.t["+Gyklt"]); } obj[1] = formatToPlainStringResult; obj[2] = completed; return obj; }; export const useIsEligibleForGuildProgress = function useIsEligibleForGuildProgress(guild) { const _require = guild; const items = [closure_5]; let stateFromStores = _require(589).useStateFromStores(items, () => closure_1_5.can(closure_1_9.ADMINISTRATOR, closure_0)); const obj = _require(589); const obj2 = DISCORD_EPOCHDefault; if (stateFromStores) { stateFromStores = extractTimestampResult >= Date.now() - closure_8; } return stateFromStores; };