2026-07-24 07:16:23 +00:00
// Module ID: 7002
// Function ID: 55994
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-24 07:16:23 +00:00
// Dependencies: [1348, 7003, 4349, 3758, 3767, 7070, 653, 491, 566, 5604, 664, 1833, 4360, 1212, 7005, 22, 4319, 2]
2026-07-20 16:05:17 +00:00
// Exports: createPollServerDataFromCreateRequest, filterOutUUID, formatPollResultNotificationCenterText, generateEmptyPollAnswer, getPollAnswerVotesTooltipText, getPollReplyPreview, getPollResultsReplyPreview, getPollResultsReplyPreviewMobile, getTotalVotes, hasNonVoteReactions, isIncompleteAnswer, isPollCreationEmpty, useCanPostPollsInChannel
2026-07-24 07:16:23 +00:00
// Module 7002 (_createForOfIteratorHelperLoose)
2026-07-23 10:11:24 +00:00
import _isNativeReflectConstruct from "_isNativeReflectConstruct" ;
import closure_4 from "_isNativeReflectConstruct" ;
import closure_5 from "_isNativeReflectConstruct" ;
import closure_6 from "_isNativeReflectConstruct" ;
import closure_7 from "_isNativeReflectConstruct" ;
import POLL_ATTACHMENT_FOLDER from "POLL_ATTACHMENT_FOLDER" ;
import ME from "ME" ;
let closure_10 ;
let closure_11 ;
let closure_8 ;
let closure_9 ;
const require = arg1 ;
function _createForOfIteratorHelperLoose ( iterable ) {
let closure_0 = iterable ;
iterable = "undefined" !== typeof Symbol ;
if ( iterable ) {
2026-07-20 16:05:17 +00:00
const _Symbol = Symbol ;
2026-07-23 10:11:24 +00:00
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( ! iterable ) {
iterable = iterable [ Symbol . iterator ] ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
if ( iterable ) {
const iter = iterable . call ( iterable ) ;
2026-07-20 16:05:17 +00:00
const next = iter . next ;
return next . bind ( iter ) ;
} else {
const _Array = Array ;
2026-07-23 10:11:24 +00:00
let tmp = iterable ;
if ( ! Array . isArray ( iterable ) ) {
2026-07-20 16:05:17 +00:00
let tmp2 ;
2026-07-23 10:11:24 +00:00
if ( iterable ) {
if ( "string" === typeof iterable ) {
tmp2 = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
const toString = { } . toString ;
2026-07-23 10:11:24 +00:00
const substr = toString . call ( iterable ) . slice ( 8 , - 1 ) ;
2026-07-20 16:05:17 +00:00
let name = substr ;
if ( tmp3 ) {
2026-07-23 10:11:24 +00:00
name = iterable . constructor . name ;
2026-07-20 16:05:17 +00:00
}
if ( "Map" !== name ) {
if ( "Set" !== name ) {
if ( "Arguments" === name ) {
2026-07-23 10:11:24 +00:00
let arr = _arrayLikeToArray ( iterable , undefined ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
let obj = /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/ ;
2026-07-20 16:05:17 +00:00
}
}
tmp2 = arr ;
}
const _Array2 = Array ;
2026-07-23 10:11:24 +00:00
arr = Array . from ( iterable ) ;
const callResult = toString . call ( iterable ) ;
tmp3 = "Object" === substr && iterable . constructor ;
2026-07-20 16:05:17 +00:00
}
}
tmp = tmp2 ;
if ( ! tmp2 ) {
const _TypeError = TypeError ;
const typeError = new TypeError ( "Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method." ) ;
throw typeError ;
}
}
if ( tmp ) {
2026-07-23 10:11:24 +00:00
closure_0 = tmp ;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
let c1 = 0 ;
2026-07-20 16:05:17 +00:00
return ( ) = > {
2026-07-23 10:11:24 +00:00
if ( closure_1 >= length . length ) {
2026-07-20 16:05:17 +00:00
let obj = { done : true } ;
} else {
obj = { done : false } ;
closure_1 = tmp3 + 1 ;
2026-07-23 10:11:24 +00:00
obj . value = length [ + closure_1 ] ;
2026-07-20 16:05:17 +00:00
}
return obj ;
} ;
}
}
function _arrayLikeToArray ( arg0 , arg1 ) {
let length ;
if ( tmp ) {
length = arg0 . length ;
}
const ArrayResult = Array ( length ) ;
for ( let num = 0 ; num < length ; num = num + 1 ) {
ArrayResult [ num ] = arg0 [ num ] ;
}
return ArrayResult ;
}
function generateLocalCreationAnswerId() {
2026-07-23 10:11:24 +00:00
return require ( 491 ) /* v1 */ . v4 ( ) ;
2026-07-20 16:05:17 +00:00
}
function isAnswerFilled ( text ) {
let trimmed ;
if ( null != text . text ) {
trimmed = str . trim ( ) ;
}
let tmp2 = null != trimmed ;
if ( tmp2 ) {
tmp2 = trimmed . length > 0 ;
}
return tmp2 ;
}
function createPollExpiryTimestamp ( duration ) {
const timestamp = Date . now ( ) ;
2026-07-23 10:11:24 +00:00
return new Date ( timestamp + duration * importDefault ( 664 ) . Millis . HOUR ) . toISOString ( ) ;
2026-07-20 16:05:17 +00:00
}
function getPollResultsPollName ( merged , closure_8 ) {
const first = merged . embeds [ 0 ] ;
let rawValue ;
if ( null != first ) {
const fields = first . fields ;
if ( null != fields ) {
const found = fields . find ( ( rawName ) = > "poll_question_text" === rawName . rawName ) ;
if ( null != found ) {
rawValue = found . rawValue ;
}
}
}
let str = "" ;
if ( null != rawValue ) {
str = rawValue ;
}
let truncateTextResult = str ;
if ( null != closure_8 ) {
2026-07-23 10:11:24 +00:00
truncateTextResult = require ( 1833 ) /* cssValueToNumber */ . truncateText ( str , closure_8 ) ;
const obj = require ( 1833 ) /* cssValueToNumber */ ;
2026-07-20 16:05:17 +00:00
}
return truncateTextResult ;
}
function getSampleOfVoterUsernamesForAnswer ( message , id ) {
const channelId = message . getChannelId ( ) ;
2026-07-23 10:11:24 +00:00
const obj = { id , name : "" , animated : false } ;
2026-07-24 07:16:23 +00:00
reactions = reactions . getReactions ( channelId , message . id , obj , closure_9 , channel ( 7005 ) . ReactionTypes . VOTE ) ;
2026-07-23 10:11:24 +00:00
channel = channel . getChannel ( channelId ) ;
2026-07-20 16:05:17 +00:00
let guildId = null ;
if ( null != channel ) {
guildId = null ;
if ( ! channel . isPrivate ( ) ) {
guildId = channel . getGuildId ( ) ;
}
}
let items ;
if ( null != reactions ) {
items = reactions . values ( ) ;
}
if ( null == items ) {
items = [ ] ;
}
2026-07-23 10:11:24 +00:00
const tmp3 = guildId ( 22 ) ;
const tmp3Result = guildId ( 22 ) ( Array . from ( items ) ) ;
const rejectResult = guildId ( 22 ) ( Array . from ( items ) ) . reject ( ( id ) = > outer1_7 . isBlockedOrIgnored ( id . id ) ) ;
const takeResult = guildId ( 22 ) ( Array . from ( items ) ) . reject ( ( id ) = > outer1_7 . isBlockedOrIgnored ( id . id ) ) . take ( closure_9 ) ;
return guildId ( 22 ) ( Array . from ( items ) ) . reject ( ( id ) = > outer1_7 . isBlockedOrIgnored ( id . id ) ) . take ( closure_9 ) . map ( ( arg0 ) = > {
2026-07-20 16:05:17 +00:00
let id ;
if ( null != channel ) {
id = channel . id ;
}
2026-07-23 10:11:24 +00:00
return guildId ( outer1_2 [ 16 ] ) . getName ( guildId , id , arg0 ) ;
2026-07-20 16:05:17 +00:00
} ) . value ( ) ;
}
function formatVoterTooltipText ( arr , arg1 ) {
let num = 0 ;
const bound = Math . max ( 0 , arg1 - arr . length ) ;
let num2 = 1 ;
if ( 1 === arr . length ) {
if ( bound > num ) {
2026-07-23 10:11:24 +00:00
const intl6 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
let obj = { } ;
num = arr [ num ] ;
obj . a = num ;
obj . n = bound ;
2026-07-23 10:11:24 +00:00
let formatToPlainStringResult = intl6 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t [ "SV/iZn" ] , obj ) ;
2026-07-20 16:05:17 +00:00
} else {
formatToPlainStringResult = arr [ num ] ;
}
} else {
let num6 = 2 ;
if ( 2 === arr . length ) {
if ( bound > num ) {
2026-07-23 10:11:24 +00:00
const intl5 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
obj = { a : arr [ num ] } ;
num2 = arr [ num2 ] ;
obj . b = num2 ;
obj . n = bound ;
2026-07-23 10:11:24 +00:00
let formatToPlainStringResult1 = intl5 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t . YBnZK0 , obj ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const intl4 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
const obj1 = { a : arr [ num ] , b : arr [ num2 ] } ;
2026-07-23 10:11:24 +00:00
formatToPlainStringResult1 = intl4 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t [ "O5+f5c" ] , obj1 ) ;
2026-07-20 16:05:17 +00:00
}
} else if ( 3 === arr . length ) {
if ( bound > num ) {
2026-07-23 10:11:24 +00:00
const intl3 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
const obj2 = { a : arr [ num ] , b : arr [ num2 ] } ;
num6 = arr [ num6 ] ;
obj2 . c = num6 ;
obj2 . n = bound ;
2026-07-23 10:11:24 +00:00
let formatToPlainStringResult2 = intl3 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t [ "ThXp+N" ] , obj2 ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const intl2 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
const obj3 = { a : arr [ num ] , b : arr [ num2 ] , c : arr [ num6 ] } ;
2026-07-23 10:11:24 +00:00
formatToPlainStringResult2 = intl2 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t [ "0UzBM3" ] , obj3 ) ;
2026-07-20 16:05:17 +00:00
}
} else {
2026-07-23 10:11:24 +00:00
const intl = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
obj = { n : bound } ;
2026-07-23 10:11:24 +00:00
return intl . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t . yVX6kE , obj ) ;
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-23 10:11:24 +00:00
( { POLL_RESULT_MESSAGE_POLL_TITLE_MAX_VISIBLE_CHARS : closure_8 , VOTES_TOOLTIP_MAX_USERS : closure_9 } = POLL_ATTACHMENT_FOLDER ) ;
( { ChannelTypesSets : closure_10 , Permissions : closure_11 } = ME ) ;
const result = require ( "_isNativeReflectConstruct" ) . fileFinishedImporting ( "modules/polls/PollsUtils.tsx" ) ;
2026-07-20 16:05:17 +00:00
export const generateEmptyPollAnswer = function generateEmptyPollAnswer() {
return { text : undefined , image : undefined , localCreationAnswerId : generateLocalCreationAnswerId ( ) } ;
} ;
export { generateLocalCreationAnswerId } ;
export const filterOutUUID = function filterOutUUID ( str ) {
return str . replace ( /\b[a-f\d]{8}-(?:[a-f\d]{4}-){3}[a-f\d]{12}-\b/i , "" ) ;
} ;
export const hasNonVoteReactions = function hasNonVoteReactions ( reactions ) {
const tmp = _createForOfIteratorHelperLoose ( reactions . reactions ) ;
let iter = tmp ( ) ;
if ( ! iter . done ) {
while ( null != iter . value . me_vote ) {
let iter2 = tmp ( ) ;
iter = iter2 ;
}
return true ;
}
return false ;
} ;
export const useCanPostPollsInChannel = function useCanPostPollsInChannel ( channel ) {
2026-07-23 10:11:24 +00:00
const _require = channel ;
2026-07-20 16:05:17 +00:00
const items = [ closure_6 ] ;
2026-07-23 10:11:24 +00:00
return _require ( 566 ) . useStateFromStores ( items , ( ) = > {
let tmp = null != _private ;
2026-07-20 16:05:17 +00:00
if ( tmp ) {
2026-07-23 10:11:24 +00:00
tmp = _private . id !== _private ( outer1_2 [ 9 ] ) . FAKE_PLACEHOLDER_PRIVATE_CHANNEL_ID ;
2026-07-20 16:05:17 +00:00
}
if ( tmp ) {
2026-07-23 10:11:24 +00:00
const POLLS = outer1_10 . POLLS ;
const tmp7 = ! POLLS . has ( _private . type ) ;
2026-07-20 16:05:17 +00:00
let tmp8 = ! tmp7 ;
if ( ! tmp7 ) {
2026-07-23 10:11:24 +00:00
const tmp10 = ! _private . isPrivate ( ) ;
2026-07-20 16:05:17 +00:00
let tmp11 = ! tmp10 ;
if ( tmp10 ) {
2026-07-23 10:11:24 +00:00
let canResult = outer1_6 . can ( outer1_11 . SEND_MESSAGES , _private ) ;
2026-07-20 16:05:17 +00:00
if ( canResult ) {
2026-07-23 10:11:24 +00:00
canResult = outer1_6 . can ( outer1_11 . SEND_POLLS , _private ) ;
2026-07-20 16:05:17 +00:00
}
tmp11 = canResult ;
}
tmp8 = tmp11 ;
}
tmp = tmp8 ;
}
return tmp ;
} ) ;
} ;
export const isPollCreationEmpty = function isPollCreationEmpty ( closure_4 , answers ) {
let tmp = 0 === closure_4 . length ;
if ( tmp ) {
2026-07-23 10:11:24 +00:00
tmp = null == answers . find ( ( arg0 ) = > outer1_15 ( arg0 ) ) ;
2026-07-20 16:05:17 +00:00
}
return tmp ;
} ;
export { isAnswerFilled } ;
export const isIncompleteAnswer = function isIncompleteAnswer ( text ) {
if ( null != text . text ) {
const trimmed = str . trim ( ) ;
}
let tmp = null != text . image ;
if ( tmp ) {
let tmp2 = null == trimmed ;
if ( ! tmp2 ) {
tmp2 = 0 === trimmed . length ;
}
tmp = tmp2 ;
}
return tmp ;
} ;
export { createPollExpiryTimestamp } ;
export const createPollServerDataFromCreateRequest = function createPollServerDataFromCreateRequest ( poll ) {
if ( null != poll ) {
let mapped ;
if ( null != poll ) {
const answers = poll . answers ;
if ( null != answers ) {
mapped = answers . map ( ( poll_media ) = > {
let name ;
poll_media = poll_media . poll_media ;
let emoji ;
if ( null != poll_media ) {
emoji = poll_media . emoji ;
}
let obj = { } ;
const merged = Object . assign ( poll_media . poll_media ) ;
let tmp3 ;
if ( null != emoji ) {
obj = { } ;
( { id : obj2.id , name } = emoji ) ;
let str = "" ;
if ( null != name ) {
str = name ;
}
obj . name = str ;
tmp3 = obj ;
}
obj [ "emoji" ] = tmp3 ;
obj = { } ;
const merged1 = Object . assign ( poll_media ) ;
obj [ "answer_id" ] = arg1 + 1 ;
obj [ "poll_media" ] = obj ;
return obj ;
} ) ;
}
}
let duration ;
if ( null != poll ) {
duration = poll . duration ;
}
let str = "0" ;
if ( null != duration ) {
str = createPollExpiryTimestamp ( poll . duration ) ;
}
2026-07-23 10:11:24 +00:00
let obj = { } ;
let merged = Object . assign ( poll ) ;
2026-07-20 16:05:17 +00:00
obj [ "expiry" ] = str ;
obj [ "answers" ] = mapped ;
return obj ;
}
} ;
export const getPollReplyPreview = function getPollReplyPreview ( message ) {
const poll = message . poll ;
let text ;
if ( null != poll ) {
const question = poll . question ;
if ( null != question ) {
text = question . text ;
}
}
let str = "" ;
if ( null != text ) {
str = text ;
}
return str ;
} ;
export const getPollResultsReplyPreview = function getPollResultsReplyPreview ( message ) {
2026-07-23 10:11:24 +00:00
let obj = require ( 4360 ) /* useNullableMessageAuthor */ ;
2026-07-20 16:05:17 +00:00
const messageAuthor = obj . getMessageAuthor ( message ) ;
2026-07-23 10:11:24 +00:00
const intl = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
obj = { username : messageAuthor.nick , title : getPollResultsPollName ( message , closure_8 ) } ;
2026-07-23 10:11:24 +00:00
return intl . format ( require ( 1212 ) /* getSystemLocale */ . t . Vn97Ka , obj ) ;
2026-07-20 16:05:17 +00:00
} ;
export const getPollResultsReplyPreviewMobile = function getPollResultsReplyPreviewMobile ( merged ) {
if ( "author" in merged ) {
2026-07-23 10:11:24 +00:00
let obj = require ( 4360 ) /* useNullableMessageAuthor */ ;
2026-07-20 16:05:17 +00:00
const messageAuthor = obj . getMessageAuthor ( merged ) ;
2026-07-23 10:11:24 +00:00
const intl = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
obj = { username : messageAuthor.nick , title : getPollResultsPollName ( merged , closure_8 ) } ;
2026-07-23 10:11:24 +00:00
return intl . formatToParts ( require ( 1212 ) /* getSystemLocale */ . t . Vn97Ka , obj ) ;
2026-07-20 16:05:17 +00:00
} else {
return null ;
}
} ;
export const getTotalVotes = function getTotalVotes ( reactions ) {
return reactions . reduce ( ( arg0 , count_details ) = > {
count_details = count_details . count_details ;
let vote ;
if ( null != count_details ) {
vote = count_details . vote ;
}
let num = 0 ;
if ( null != vote ) {
num = vote ;
}
return arg0 + num ;
} , 0 ) ;
} ;
export { getSampleOfVoterUsernamesForAnswer } ;
export { formatVoterTooltipText } ;
export const getPollAnswerVotesTooltipText = function getPollAnswerVotesTooltipText ( arg0 , arg1 , id ) {
2026-07-23 10:11:24 +00:00
message = message . getMessage ( arg1 , arg0 ) ;
2026-07-20 16:05:17 +00:00
if ( null == message ) {
return "" ;
} else {
2026-07-23 10:11:24 +00:00
const obj = { id , name : "" , animated : false } ;
2026-07-20 16:05:17 +00:00
let str = "" ;
const reaction = message . getReaction ( obj ) ;
let vote ;
if ( null != reaction ) {
const count_details = reaction . count_details ;
if ( null != count_details ) {
vote = count_details . vote ;
}
}
let num2 = 0 ;
if ( null != vote ) {
num2 = vote ;
}
const arr = getSampleOfVoterUsernamesForAnswer ( message , id ) ;
if ( 0 !== arr . length ) {
str = formatVoterTooltipText ( arr , num2 ) ;
}
return str ;
}
} ;
export const formatPollResultNotificationCenterText = function formatPollResultNotificationCenterText ( totalVotes ) {
let questionText ;
let victorAnswerId ;
let victorAnswerText ;
( { questionText , totalVotes } = totalVotes ) ;
let num = 0 ;
( { victorAnswerText , victorAnswerId } = totalVotes ) ;
if ( totalVotes . totalVotes > 0 ) {
const _Math = Math ;
num = Math . round ( tmp / totalVotes * 100 ) ;
}
if ( 0 === totalVotes ) {
2026-07-23 10:11:24 +00:00
const intl3 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
let obj = { questionText } ;
2026-07-23 10:11:24 +00:00
let formatToPlainStringResult = intl3 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t [ "8anM0l" ] , obj ) ;
2026-07-20 16:05:17 +00:00
} else if ( null != victorAnswerId ) {
2026-07-23 10:11:24 +00:00
const intl2 = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
obj = { questionText , victorAnswerText } ;
const _HermesInternal2 = HermesInternal ;
obj . percentage = "" + num + "%" ;
2026-07-23 10:11:24 +00:00
formatToPlainStringResult = intl2 . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t [ "8yEgvE" ] , obj ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
const intl = require ( 1212 ) /* getSystemLocale */ . intl ;
2026-07-20 16:05:17 +00:00
obj = { questionText } ;
const _HermesInternal = HermesInternal ;
obj . percentage = "" + num + "%" ;
2026-07-23 10:11:24 +00:00
formatToPlainStringResult = intl . formatToPlainString ( require ( 1212 ) /* getSystemLocale */ . t . XVk6Zv , obj ) ;
2026-07-20 16:05:17 +00:00
}
return formatToPlainStringResult ;
} ;