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

395 lines
22 KiB
TypeScript

/* Metro module 11737; source: modules/polls/useCreatePollFormData.tsx; dependencies: [5, 57, 31, 7217, 7149, 11738, 11197, 11739, 11740, 11741, 1244, 8436, 2] */
import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
import PollsActionCreators from './PollsActionCreators.tsx'; /* Metro dependency 11197 */
import UseRequest from '../../hooks/useRequest.tsx'; /* Metro dependency 11738 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as IndexNativeModule from '../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as PollsUtilsModule from './PollsUtils.tsx'; /* Metro dependency 7149 */
import * as PollsConstantsModule from './PollsConstants.tsx'; /* Metro dependency 7217 */
import * as PollUploadAttachmentActionCreatorsNativeModule from './PollUploadAttachmentActionCreators.native.tsx'; /* Metro dependency 11739 */
import * as PollTypesModule from './PollTypes.tsx'; /* Metro dependency 11741 */
function _fun89941(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#89941, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:6, offset: 0x02024f55, size: 210 bytes, params: 8, frame: 20
const env0_0 = require;
const createPollCreationImageForMedia = function(a0, a1) {
return {mediaAttachmentState: {status: a1, mediaURL: a0}, emoji: undefined, stickerId: undefined};
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/polls/useCreatePollFormData.tsx');
exports.default = useCreatePollCommonData;
function useCreatePollCommonData(a0, a1, a2, a3) { // fn#89943, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:435, offset: 0x0202504d, size: 1112 bytes, params: 5, frame: 45
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = a2;
const env0_3 = a3;
const id = a0.id;
const id2 = id;
let binding = env0_6;
let useState = binding.useState;
const value2 = Reflect.apply(useState, binding, [_fun89944]);
const value3 = undefined;
const value4 = property12(value2, 2);
const property = value4[0];
var property12 = property;
var env0_6 = value4[1];
const value6 = binding.useState((a3 == null ? value3 : a3.initialQuestion) ?? '');
binding = property12;
const value7 = binding(value6, 2);
const property2 = value7[0];
const property3 = value7[1];
const binding2 = env0_6;
useState = binding2.useState;
const value8 = binding(Reflect.apply(useState, binding2, [false]), 2);
const property4 = value8[0];
const property5 = value8[1];
const value9 = binding2.useState((a3 == null ? value3 : a3.initialDuration) ?? PollDurations.ONE_DAY);
binding = property12;
const value10 = binding(value9, 2);
const property6 = value10[0];
const property7 = value10[1];
const binding3 = env0_6;
useState = binding3.useState;
const value11 = binding(Reflect.apply(useState, binding3, [{}]), 2);
const property8 = value11[0];
const env0_11 = value11[1];
useState = binding3.useState;
const value12 = binding(Reflect.apply(useState, binding3, [false]), 2);
const property9 = value12[0];
const property10 = value12[1];
const value13 = property.filter(_fun89946);
const r18 = property2.length > 0 && value13.length >= MIN_NUMBER_OF_ANSWERS_PER_POLL && property.filter(_fun89947).length === 0;
const value19 = property12((UseRequest)((PollsActionCreators).createPoll),
2);
const property11 = value19[0];
const {error, loading} = value19[1];
const value20 = property.length < MAX_NUMBER_OF_ANSWERS_PER_POLL;
const value21 = property.length > MIN_NUMBER_OF_ANSWERS_PER_POLL;
binding = env0_6;
let useCallback = binding.useCallback;
const value22 = Reflect.apply(useCallback, binding, [_fun89948, []]);
const value23 = binding.useCallback(_fun89950, []);
const value24 = binding.useCallback(_fun89953, []);
const value25 = binding.useCallback(_fun89955, [property]);
const value27 = binding.useCallback(_fun89956(), [property, value24, value25]);
const value28 = binding.useCallback(_fun89960, [property, value24, value25]);
const value29 = binding.useCallback(_fun89961, [id, value24, value25]);
const value30 = binding.useCallback(_fun89962, []);
const value31 = binding.useCallback(_fun89964, [value20]);
const value32 = binding.useCallback(_fun89966, [property.length, value21, id, a2, value25]);
binding.useEffect(function() {
return _fun89969;
}, [id]);
const value33 = binding.useCallback(_fun89970, [property, property2]);
useCallback = binding.useCallback;
let value = id2(_fun89974);
value = Reflect.apply(useCallback, binding, [value, [property2, value13, property4, property6, property11, a0, a1]]);
useCallback = binding.useCallback;
return {answers: property, question: property2, setQuestion: property3, allowMultiSelect: property4,
setAllowMultiSelect: property5, duration: property6, setDuration: property7, canPost: r18,
canAddMoreAnswers: value20, canRemoveMoreAnswers: value21, handleQuestionChange: value22,
handleAnswerTextChange: value23, handleGifSelect: value27, handleEmojiSelect: value29,
handleCustomUpload: value28, handleAddAnswer: value31, handleRemoveAnswer: value32,
handleRemoveAnswerImage: value30, fieldErrors: property8, createPoll: value,
handleSubmitPoll: Reflect.apply(useCallback, binding, [_fun89975, [value, loading, value33]]),
submitting: loading, createPollError: error, shouldFocusOnInvalidField: property9,
setShouldFocusOnInvalidField: property10};
function _fun89944() { // fn#89944, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:506, offset: 0x020254a5, size: 133 bytes, params: 1, frame: 15
var environment;
var items2;
var value;
let r0 = importAll == null || importAll.initialAnswers == null ? undefined : importAll.initialAnswers.map(_fun89945);
if (r0 == null) {
value = environment.__proto__;
value = require(7149) /* metro dependency 7149: PollsUtils */;
value = value.generateEmptyPollAnswer();
items2 = [value];
value = require(7149) /* metro dependency 7149: PollsUtils */;
items2[1] = value.generateEmptyPollAnswer();
r0 = items2;
}
return r0;
function _fun89945(a0) { // fn#89945, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:585, offset: 0x0202552a, size: 56 bytes, params: 2, frame: 13
const object = {};
let value = environment.__proto__.__proto__;
value = require(7149) /* metro dependency 7149: PollsUtils */;
copyDataProperties(object, value.generateEmptyPollAnswer(), require);
copyDataProperties(object, a0, require);
return object;
}
}
function _fun89946(a0) { // fn#89946, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1044, offset: 0x02025562, size: 41 bytes, params: 2, frame: 11
const value = environment.__proto__;
return (PollsUtilsModule).isAnswerFilled(a0);
}
function _fun89947(a0) { // fn#89947, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1087, offset: 0x0202558b, size: 41 bytes, params: 2, frame: 11
const value = environment.__proto__;
return (PollsUtilsModule).isIncompleteAnswer(a0);
}
function _fun89948(a0) { // fn#89948, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1282, offset: 0x020255b4, size: 37 bytes, params: 2, frame: 12
env0_11(function(a0) {
var r1;
var object = {};
copyDataProperties(object, a0, r1);
delete object.question;
return object;
});
(0, PollsConstantsModule.MIN_NUMBER_OF_ANSWERS_PER_POLL)(a0);
}
function _fun89950({text, index, localCreationAnswerId}) { // fn#89950, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1365, offset: 0x020255ec, size: 72 bytes, params: 2, frame: 13
env0_11(function(a0) {
var r3;
var object = {};
copyDataProperties(object, a0, r3);
delete object['answer-' + localCreationAnswerId];
return object;
});
env0_6(function(a0) {
var r4;
var items = [];
arraySpread(items, a0, 0, r4);
var indexBinding = index;
var object = {};
copyDataProperties(object, items[indexBinding], 0);
object['text'] = text;
items[indexBinding] = object;
return items;
});
}
function _fun89953(a0, a1) { // fn#89953, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1544, offset: 0x0202569c, size: 39 bytes, params: 3, frame: 11
const env0_0 = a0;
const env0_1 = a1;
env0_6(_fun89954);
function _fun89954(a0) { // fn#89954, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1555, offset: 0x020256c3, size: 55 bytes, params: 2, frame: 15
const items2 = [];
arraySpread(items2, a0, 0, undefined);
const object = {};
copyDataProperties(object, items2[require], 0);
object['image'] = env0_0;
items2[require] = object;
return items2;
}
}
function _fun89955(a0, a1, a2) { // fn#89955, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1631, offset: 0x020256fa, size: 149 bytes, params: 4, frame: 19
var value4;
var moduleValue;
var removePollUploadAttachment;
var localCreationAnswerId;
var moduleValue2;
const property = Module00057[a1];
const image = property.image;
const value = undefined;
const mediaAttachmentState = image == null ? value : image.mediaAttachmentState;
if (mediaAttachmentState != null && mediaAttachmentState.mediaURL !== a2) {
value4 = environment.__proto__;
moduleValue = importAll(11739) /* metro dependency 11739: PollUploadAttachmentActionCreatorsNative */;
removePollUploadAttachment = moduleValue.removePollUploadAttachment;
localCreationAnswerId = property.localCreationAnswerId;
moduleValue2 = require(11740) /* metro dependency 11740: PollAttachmentUtils */;
Reflect.apply(removePollUploadAttachment, moduleValue, [a0, localCreationAnswerId,
moduleValue2.getFileNameFromGifUrl(property.localCreationAnswerId, mediaAttachmentState.mediaURL)]);
}
return value;
}
function _fun89956() { // fn#89956, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1881, offset: 0x0202578f, size: 36 bytes, params: 1, frame: 12
const env0_0 = env1_4(_fun89958);
return _fun89959;
function* _fun89958(a0, a1, a2) { // fn#89958, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:1901, offset: 0x020257be, size: 257 bytes, params: 4, frame: 24
if (true) {
value = environment.__proto__.__proto__;
var localCreationAnswerId = env2_5[a1].localCreationAnswerId;
env2_19(a0, a1);
var binding = env2_18;
var binding2 = env3_10;
var binding3 = env3_0;
var binding4 = env3_3;
var PollMediaUploadAttachmentStatus = binding3(binding4[9]).PollMediaUploadAttachmentStatus;
var PREPARING = PollMediaUploadAttachmentStatus.PREPARING;
binding(binding2(a2, PREPARING), a1);
var value4 = env3_2(binding4[7]);
yield value4.handlePollGifAttachmentAdd(a0, localCreationAnswerId, a2);
var value5 = undefined;
if (false) {
return value5;
}
if (value5 != null) {
env2_18(env3_10(a2, env3_0(env3_3[9]).PollMediaUploadAttachmentStatus.READY_TO_UPLOAD), a1);
} else {
env2_18(env3_10(a2, env3_0(env3_3[9]).PollMediaUploadAttachmentStatus.ERROR), a1);
}
}
}
function _fun89959() { // fn#89959, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2300, offset: 0x00c3945f, size: 30 bytes, params: 1, frame: 13
return env0_0.apply(this, arguments);
}
}
function _fun89960(a0, a1, a2) { // fn#89960, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2375, offset: 0x020258bf, size: 180 bytes, params: 4, frame: 24
const localCreationAnswerId = Module00057[a1].localCreationAnswerId;
const URL = global.URL;
const objectURL = URL.createObjectURL(a2);
env0_19(a0, a1);
let binding = env0_18;
const createPollCreationImageForMediaBinding = createPollCreationImageForMedia;
const PollMediaUploadAttachmentStatus = (PollTypesModule).PollMediaUploadAttachmentStatus;
const PREPARING = PollMediaUploadAttachmentStatus.PREPARING;
binding(createPollCreationImageForMediaBinding(objectURL, PREPARING), a1);
(PollUploadAttachmentActionCreatorsNativeModule).handlePollMediaAttachmentAdd(a0,
localCreationAnswerId, a2);
binding = env0_18;
const READY_TO_UPLOAD = PollMediaUploadAttachmentStatus.READY_TO_UPLOAD;
binding(createPollCreationImageForMediaBinding(objectURL, READY_TO_UPLOAD), a1);
}
function _fun89961(a0, a1) { // fn#89961, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2714, offset: 0x02025973, size: 54 bytes, params: 3, frame: 14
env0_19(id, a1);
env0_18({emoji: a0, stickerId: undefined, mediaAttachmentState: undefined}, a1);
}
function _fun89962(a0) { // fn#89962, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2822, offset: 0x020259a9, size: 32 bytes, params: 2, frame: 11
const env0_0 = a0;
env0_6(_fun89963);
function _fun89963(a0) { // fn#89963, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2829, offset: 0x020259c9, size: 53 bytes, params: 2, frame: 15
const items2 = [];
arraySpread(items2, a0, 0, undefined);
const binding = env0_0;
const object = {};
copyDataProperties(object, items2[binding], 0);
object['image'] = undefined;
items2[binding] = object;
return items2;
}
}
function _fun89964() { // fn#89964, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2910, offset: 0x020259fe, size: 34 bytes, params: 1, frame: 11
if (result) {
env0_6(function(a0) {
var r4;
var items = [];
var value = arraySpread(items, a0, 0, r4);
items[value] = require(dependencyMap[4]).generateEmptyPollAnswer();
value + 1;
return items;
});
}
}
function _fun89966(a0) { // fn#89966, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:2992, offset: 0x02025a61, size: 97 bytes, params: 2, frame: 16
var length;
var binding;
const env0_0 = a0;
if (result_2) {
length = Module00057.length;
binding = env0_19;
binding(id, a0);
binding = env0_6;
binding(_fun89967);
if (importDefault != null) {
importDefault({indexToRemove: a0, numberOfAnswers: length});
}
}
function _fun89967(a0) { // fn#89967, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3029, offset: 0x02025ac2, size: 40 bytes, params: 2, frame: 14
const items2 = [];
arraySpread(items2, a0, 0, undefined);
items2.splice(env0_0, 1);
return items2;
}
}
function _fun89968() { // fn#89968, offset: 0x02025aea, size: 11 bytes, params: 1, frame: 1
return _fun89969;
function _fun89969() { // fn#89969, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3162, offset: 0x02025af5, size: 45 bytes, params: 1, frame: 12
let value = environment.__proto__.__proto__;
value = importAll(11739) /* metro dependency 11739: PollUploadAttachmentActionCreatorsNative */;
value.removeAllPollUploadAttachments(id);
}
}
function _fun89970() { // fn#89970, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3238, offset: 0x02025b22, size: 314 bytes, params: 1, frame: 18
var environment;
var value2;
const intl = (IndexNativeModule).intl;
const t = (IndexNativeModule).t;
let env0_0 = true;
const object = {};
let binding = PollsConstantsModule.MAX_NUMBER_OF_ANSWERS_PER_POLL;
if (binding.trim().length === 0) {
env0_0 = false;
value2 = environment.__proto__;
object.question = intl.string(t.gPX3oI);
}
binding = Module00057;
if (binding.filter(_fun89971).length < MIN_NUMBER_OF_ANSWERS_PER_POLL) {
env0_0 = false;
object['answer-' + Module00057[0].localCreationAnswerId] = intl.string(t.fYvzEX);
}
Module00057.forEach(_fun89972);
env0_11(object);
env0_12(!env0_0);
return env0_0;
function _fun89971(a0) { // fn#89971, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3353, offset: 0x02025c5c, size: 41 bytes, params: 2, frame: 11
const value = environment.__proto__.__proto__;
return (PollsUtilsModule).isAnswerFilled(a0);
}
function _fun89972(a0) { // fn#89972, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3494, offset: 0x02025c85, size: 148 bytes, params: 2, frame: 16
var binding;
var value3;
var intl;
if (PollsUtilsModule.isIncompleteAnswer(a0)) {
binding = env0_1;
value3 = 'answer-' + a0.localCreationAnswerId;
intl = (require(1244) /* metro dependency 1244: indexNative */).intl;
binding[value3] = intl.string((require(1244) /* metro dependency 1244: indexNative */).t['8Qqkc+']);
}
}
}
function* _fun89974() { // fn#89974, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3663, offset: 0x02025d24, size: 137 bytes, params: 1, frame: 15
if (true) {
value = environment.__proto__;
var binding = env1_14;
var object = {};
object.channel = require;
object.question = MAX_NUMBER_OF_ANSWERS_PER_POLL;
object.answers = env1_13;
object.allowMultiSelect = PollDurations;
object.duration = createPollCreationImageForMedia;
var PollLayoutTypes = env2_0(env2_3[11]).PollLayoutTypes;
var DEFAULT = PollLayoutTypes.DEFAULT;
object.layout = DEFAULT;
object.onClose = importDefault;
yield binding(object);
}
}
function _fun89975() { // fn#89975, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11923:3835, offset: 0x02025dad, size: 40 bytes, params: 1, frame: 11
if (!loading && env0_20()) {
env0_21();
}
}
}
}
global.__d(_fun89941, 11737, [5, 57, 31, 7217, 7149, 11738, 11197, 11739, 11740, 11741, 1244, 8436,
2]) /* metro module 11737, dependencies: [5, 57, 31, 7217, 7149, 11738, 11197, 11739, 11740, 11741, 1244, 8436, 2] */;