2026-07-23 10:11:24 +00:00
// Module ID: 4670
2026-07-24 07:16:23 +00:00
// Function ID: 40550
2026-07-20 16:05:17 +00:00
// Name: _createForOfIteratorHelperLoose
2026-07-23 10:11:24 +00:00
// Dependencies: [1838, 1849, 653, 1851, 22, 4671, 4057, 3776, 4025, 1212, 2]
2026-07-20 16:05:17 +00:00
// Exports: anyFileTooLarge, classifyFile, fileUploadLimitRoadblockDescription, sizeString, transformNativeFile, uploadSumTooLarge
2026-07-23 10:11:24 +00:00
// Module 4670 (_createForOfIteratorHelperLoose)
import _createForOfIteratorHelperLoose from "_createForOfIteratorHelperLoose" ;
import _isNativeReflectConstruct from "_isNativeReflectConstruct" ;
import ME from "ME" ;
import GuildFeatures from "GuildFeatures" ;
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 makeFile ( arg0 , arg1 , type ) {
const items = [ arg0 ] ;
const file = new File ( items , arg1 , { type } ) ;
return file ;
}
function classifyFileName ( name , type ) {
2026-07-23 10:11:24 +00:00
let str = name ;
2026-07-20 16:05:17 +00:00
const importDefault = type ;
let formatted ;
if ( null != name ) {
formatted = name . toLowerCase ( ) ;
}
2026-07-23 10:11:24 +00:00
str = "" ;
2026-07-20 16:05:17 +00:00
if ( null != formatted ) {
str = formatted ;
}
2026-07-23 10:11:24 +00:00
const found = importDefault ( 22 ) . find ( items , ( reType ) = > {
2026-07-20 16:05:17 +00:00
if ( null != reType . reType ) {
2026-07-23 10:11:24 +00:00
if ( null != closure_1 ) {
2026-07-20 16:05:17 +00:00
reType = reType . reType ;
2026-07-23 10:11:24 +00:00
let isMatch = reType . test ( closure_1 ) ;
2026-07-20 16:05:17 +00:00
}
return isMatch ;
}
isMatch = null != reType . reName ;
if ( isMatch ) {
isMatch = "" !== str ;
}
if ( isMatch ) {
const reName = reType . reName ;
isMatch = reName . test ( str ) ;
}
} ) ;
let str2 = "unknown" ;
if ( null != found ) {
str2 = found . klass ;
}
return str2 ;
}
function maxFileSize ( guildId ) {
const currentUser = authStore . getCurrentUser ( ) ;
2026-07-23 10:11:24 +00:00
const userMaxFileSize = importDefault ( 3776 ) . getUserMaxFileSize ( currentUser ) ;
2026-07-20 16:05:17 +00:00
if ( null == guildId ) {
return userMaxFileSize ;
} else {
2026-07-23 10:11:24 +00:00
guild = guild . getGuild ( guildId ) ;
2026-07-20 16:05:17 +00:00
if ( null != guild ) {
2026-07-23 10:11:24 +00:00
let tmp5 = ( function getGuildMaxFileSize ( guild ) {
let closure_0 = guild ;
const FileUploadPowerupHoldoutExperiment = outer1_0 ( outer1_2 [ 6 ] ) . FileUploadPowerupHoldoutExperiment ;
2026-07-20 16:05:17 +00:00
const enabled = FileUploadPowerupHoldoutExperiment . getConfig ( { location : "getGuildMaxFileSize" } ) . enabled ;
2026-07-23 10:11:24 +00:00
return outer1_9 . reduce ( ( arg0 , arg1 ) = > {
2026-07-20 16:05:17 +00:00
let tmp ;
let tmp2 ;
[ tmp , tmp2 ] = arg1 ;
if ( ! enabled ) {
2026-07-23 10:11:24 +00:00
const features = guild . features ;
2026-07-20 16:05:17 +00:00
let tmp6 = arg0 ;
if ( features . has ( tmp ) ) {
tmp6 = arg0 ;
if ( tmp2 > arg0 ) {
tmp6 = tmp2 ;
}
}
let tmp4 = tmp6 ;
} else {
tmp4 = arg0 ;
}
return tmp4 ;
2026-07-23 10:11:24 +00:00
} , outer1_6 ) ;
} ) ( guild ) ;
2026-07-20 16:05:17 +00:00
} else {
tmp5 = MAX_ATTACHMENT_SIZE ;
}
const _Math = Math ;
return Math . max ( tmp5 , userMaxFileSize ) ;
}
2026-07-23 10:11:24 +00:00
const obj = importDefault ( 3776 ) ;
2026-07-20 16:05:17 +00:00
}
function getUploadFileSizeSum ( arg0 ) {
let done ;
const tmp = _createForOfIteratorHelperLoose ( arg0 ) ;
const iter = tmp ( ) ;
let iter2 = iter ;
let num = 0 ;
let num2 = 0 ;
if ( ! iter . done ) {
do {
num = num + iter2 . value . size ;
let iter3 = tmp ( ) ;
iter2 = iter3 ;
num2 = num ;
done = iter3 . done ;
} while ( ! done ) ;
}
return num2 ;
}
function getMaxRequestSize() {
const currentUser = authStore . getCurrentUser ( ) ;
if ( null != currentUser ) {
currentUser . isStaff ( ) ;
}
return 524288000 ;
}
2026-07-23 10:11:24 +00:00
let GuildFeatures = ME . GuildFeatures ;
const MAX_ATTACHMENT_SIZE = ME . MAX_ATTACHMENT_SIZE ;
let closure_7 = GuildFeatures . MAX_PREMIUM_TIER_2_ATTACHMENT_SIZE ;
2026-07-20 16:05:17 +00:00
let obj = { reType : /^image\/vnd.adobe.photoshop/ , klass : "photoshop" } ;
2026-07-23 10:11:24 +00:00
let items = [ obj , , , , , , , , , , , , , ] ;
2026-07-20 16:05:17 +00:00
obj = { reType : /^image\/svg\+xml/ , klass : "webcode" } ;
items [ 1 ] = obj ;
obj = { reType : /^image\// , klass : "image" } ;
items [ 2 ] = obj ;
items [ 3 ] = { reType : /^video\// , klass : "video" } ;
items [ 4 ] = { reName : /\.pdf$/ , klass : "acrobat" } ;
items [ 5 ] = { reName : /\.ae/ , klass : "ae" } ;
items [ 6 ] = { reName : /\.sketch$/ , klass : "sketch" } ;
items [ 7 ] = { reName : /\.ai$/ , klass : "ai" } ;
items [ 8 ] = { reName : /\.(?:rar|zip|7z|tar|tar\.gz)$/ , klass : "archive" } ;
items [ 9 ] = { reName : /\.(?:c\+\+|cpp|cc|c|h|hpp|mm|m|json|js|ts|rb|rake|py|asm|fs|pyc|dtd|cgi|bat|rss|java|graphml|idb|lua|o|gml|prl|sls|conf|cmake|make|sln|vbe|cxx|wbf|vbs|r|wml|php|bash|applescript|fcgi|yaml|ex|exs|sh|ml|actionscript)$/ , klass : "code" } ;
items [ 10 ] = { reName : /\.(?:txt|rtf|doc|docx|md|pages|ppt|pptx|pptm|key|log)$/ , klass : "document" } ;
items [ 11 ] = { reName : /\.(?:xls|xlsx|numbers|csv)$/ , klass : "spreadsheet" } ;
items [ 12 ] = { reName : /\.(?:html|xhtml|htm|xml|xsd|css|styl)$/ , klass : "webcode" } ;
items [ 13 ] = { reName : /\.(?:mp3|ogg|opus|wav|aiff|flac)$/ , klass : "audio" } ;
2026-07-23 10:11:24 +00:00
const items1 = [ GuildFeatures . MAX_FILE_SIZE_250_MB , GuildFeatures . MAX_GUILD_FILE_SIZE_250_MB ] ;
2026-07-20 16:05:17 +00:00
const items2 = [ items1 , , ] ;
2026-07-23 10:11:24 +00:00
const items3 = [ GuildFeatures . MAX_FILE_SIZE_100_MB , GuildFeatures . MAX_GUILD_FILE_SIZE_100_MB ] ;
2026-07-20 16:05:17 +00:00
items2 [ 1 ] = items3 ;
2026-07-23 10:11:24 +00:00
const items4 = [ GuildFeatures . MAX_FILE_SIZE_50_MB , GuildFeatures . MAX_GUILD_FILE_SIZE_50_MB ] ;
2026-07-20 16:05:17 +00:00
items2 [ 2 ] = items4 ;
2026-07-23 10:11:24 +00:00
const result = require ( "ME" ) . fileFinishedImporting ( "utils/FileUtils.tsx" ) ;
2026-07-20 16:05:17 +00:00
export const transformNativeFile = function transformNativeFile ( data ) {
let tmp = data ;
if ( ! ( data instanceof File ) ) {
let str = "text/plain" ;
if ( null != arg1 ) {
str = arg1 ;
}
tmp = makeFile ( data . data . buffer , data . filename , str ) ;
const tmp2 = makeFile ;
}
return tmp ;
} ;
export { makeFile } ;
export const classifyFile = function classifyFile ( file ) {
return classifyFileName ( file . name , file . type ) ;
} ;
export { classifyFileName } ;
2026-07-23 10:11:24 +00:00
export const sizeString = function sizeString ( c2 ) {
return importDefault ( 4671 ) . filesize ( c2 ) ;
2026-07-20 16:05:17 +00:00
} ;
export { maxFileSize } ;
export const anyFileTooLarge = function anyFileTooLarge ( arg0 , guildId ) {
let closure_0 = maxFileSize ( guildId ) ;
return Array . from ( arg0 ) . some ( ( size ) = > size . size > closure_0 ) ;
} ;
export { getUploadFileSizeSum } ;
export const uploadSumTooLarge = function uploadSumTooLarge ( arg0 ) {
getMaxRequestSize ( ) ;
return getUploadFileSizeSum ( arg0 ) > 524288000 ;
} ;
export { getMaxRequestSize } ;
export const fileUploadLimitRoadblockDescription = function fileUploadLimitRoadblockDescription ( maxSize ) {
let guildId ;
let onClick ;
maxSize = maxSize . maxSize ;
( { guildId , onClick } = maxSize ) ;
if ( null == maxSize ) {
maxSize = maxFileSize ( guildId ) ;
}
2026-07-23 10:11:24 +00:00
maxSize = require ( 4025 ) /* formatSize */ . formatSize ( maxSize / 1024 , { useKibibytes : true } ) ;
const obj = require ( 4025 ) /* formatSize */ ;
const premiumMaxSize = require ( 4025 ) /* formatSize */ . formatSize ( closure_7 / 1024 , { useKibibytes : true } ) ;
const intl = require ( 1212 ) /* getSystemLocale */ . intl ;
return intl . format ( require ( 1212 ) /* getSystemLocale */ . t . tRuxk9 , { maxSize , premiumMaxSize , onClick } ) ;
2026-07-20 16:05:17 +00:00
} ;