Files
discord-decomp/sources/modules/auth/native/components/RegisterIdentity.tsx
T
2026-07-28 01:06:53 +03:00

342 lines
19 KiB
TypeScript

/* Metro module 14313; source: modules/auth/native/components/RegisterIdentity.tsx; dependencies: [5, 57, 31, 27, 14304, 14305, 33, 4501, 4584, 8973, 1484, 14314, 676, 14302, 14319, 14320, 14303, 4594, 8993, 9001, 14321, 4578, 1244, 8970, 5467, 14323, 14324, 8853, 9221, 2] */
import Module00005 from '../../../../by-id/module-00005.js'; /* Metro dependency 5 */
import Module00057 from '../../../../by-id/module-00057.js'; /* Metro dependency 57 */
import UseMountEffect from '../../../../hooks/useMountEffect.tsx'; /* Metro dependency 4594 */
import UseWideAuthView from '../useWideAuthView.tsx'; /* Metro dependency 8973 */
import AuthFormView from './AuthFormView.tsx'; /* Metro dependency 9001 */
import UseInitialRegistrationStep from '../useInitialRegistrationStep.tsx'; /* Metro dependency 14319 */
import UseAuthFlowBackHandler from './utils/useAuthFlowBackHandler.tsx'; /* Metro dependency 14320 */
import * as FileImportTrackerModule from '../../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as ConstantsIOSModule from '../../../../ConstantsIOS.tsx'; /* Metro dependency 676 */
import * as IndexNativeModule from '../../../../intl/index.native.tsx'; /* Metro dependency 1244 */
import * as UseNavigationNativeModule from '../../../../design/components/Navigator/native/useNavigation.native.tsx'; /* Metro dependency 1484 */
import * as ButtonNativeModule from '../../../../design/components/Button/native/Button.native.tsx'; /* Metro dependency 4578 */
import * as UseFontScaleModule from '../../../screen/native/useFontScale.tsx'; /* Metro dependency 4584 */
import * as SegmentedControlStateNativeModule from '../../../../design/components/SegmentedControl/native/SegmentedControlState.native.tsx'; /* Metro dependency 8853 */
import * as PhoneOrEmailUtilsModule from '../../../phone/PhoneOrEmailUtils.tsx'; /* Metro dependency 8993 */
import * as SegmentedControlNativeModule from '../../../../design/components/SegmentedControl/native/SegmentedControl.native.tsx'; /* Metro dependency 9221 */
import * as AuthModule from './Auth.tsx'; /* Metro dependency 14302 */
import * as RegistrationStepsUtilsModule from '../RegistrationStepsUtils.tsx'; /* Metro dependency 14303 */
import * as UseIdentityRegistrationStepModule from './utils/useIdentityRegistrationStep.tsx'; /* Metro dependency 14314 */
import * as RegisterPhoneOrEmailInputModule from './RegisterPhoneOrEmailInput.tsx'; /* Metro dependency 14321 */
import * as GetDeviceCountryModule from './utils/getDeviceCountry.tsx'; /* Metro dependency 14323 */
function _fun108322(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#108322, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:6, offset: 0x0231c912, size: 342 bytes, params: 8, frame: 19
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactNativeModule;
const env0_6 = value.View;
const env0_7 = value.ScrollView;
value = require(14304) /* metro dependency 14304: RegistrationUIStore */;
const env0_8 = value.clearRegistrationErrorMessage;
const env0_9 = value.setRegistrationErrors;
const env0_10 = value.updateRegistrationOptions;
const env0_11 = value.useRegistrationUIStore;
value = require(14305) /* metro dependency 14305: RegistrationConstants */;
const env0_12 = value.RegisterTransitionSteps;
const env0_13 = value.RegistrationTransitionActionTypes;
value = require(33) /* metro dependency 33 */;
const env0_14 = value.jsx;
const env0_15 = value.jsxs;
const env0_16 = (require(4501) /* metro dependency 4501: createStyles */).createStyles(function(a0) {
return {container: {'marginTop': 24, 'flex': 1}, page: {flex: 1}, button: {'width': '100%', 'marginTop': 24},
errors: {marginTop: 4}, segmentedControl: {minHeight: a0, marginBottom: 24},
scrollContent: {paddingBottom: 128}};
});
(FileImportTrackerModule).fileFinishedImporting('modules/auth/native/components/RegisterIdentity.tsx');
exports.RegisterIdentity = RegisterIdentity;
function RegisterIdentityBase({inputMode, setInputMode, headerText, controlComponent, subheader}) { // fn#108323, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:606, offset: 0x0231ca68, size: 1015 bytes, params: 2, frame: 35
var r0;
const closure = function() {
return RegisterIdentityBase_handleSubmit.apply(this, arguments);
};
const Math = global.Math;
const min = Math.min;
var value;
const styles = useStyles(45 * Reflect.apply(min, Math, [2,
(UseFontScaleModule).useFontScale()]));
const value4 = (UseWideAuthView)();
const env0_2 = (UseNavigationNativeModule).useNavigation();
const value5 = useRegistrationUIStore(function(a0) {
return a0.errors;
});
const useIdentityRegistrationStep = UseIdentityRegistrationStepModule.useIdentityRegistrationStep;
const AuthStates = (ConstantsIOSModule).AuthStates;
let REGISTER_IDENTITY = AuthStates.REGISTER_IDENTITY;
const value6 = Reflect.apply(useIdentityRegistrationStep, UseIdentityRegistrationStepModule, [REGISTER_IDENTITY,
inputMode]);
const loginEmail = value6.loginEmail;
const loginEmail2 = loginEmail;
const setLoginEmail = value6.setLoginEmail;
const loginPhone = value6.loginPhone;
const updateLoginPhone = value6.updateLoginPhone;
const identityErrorMessage = value6.identityErrorMessage;
const identityErrorMessage2 = identityErrorMessage;
const env0_6 = value6.registerAndVerifyPhone;
const preventSubmitIdentity = value6.preventSubmitIdentity;
const identityError = value6.identityError;
const env0_7 = value6.validateEmail;
let binding = identityErrorMessage2;
const [property, env0_8] = loginEmail2(binding.useState(false), 2);
binding = identityErrorMessage2;
const useContext = binding.useContext;
const TrackRegistrationContext = (AuthModule).TrackRegistrationContext;
const env0_9 = Reflect.apply(useContext, binding, [TrackRegistrationContext]);
const value9 = identityErrorMessage2.useMemo(_fun108330, [value5.message, identityErrorMessage]);
const defaultImport = UseInitialRegistrationStep;
REGISTER_IDENTITY = AuthStates.REGISTER_IDENTITY;
defaultImport(REGISTER_IDENTITY);
const defaultImport2 = UseAuthFlowBackHandler;
const getPreviousRegistrationTransitionStep = RegistrationStepsUtilsModule.getPreviousRegistrationTransitionStep;
REGISTER_IDENTITY = AuthStates.REGISTER_IDENTITY;
defaultImport2(Reflect.apply(getPreviousRegistrationTransitionStep, RegistrationStepsUtilsModule,
[REGISTER_IDENTITY]));
(UseMountEffect)(_fun108331);
const items2 = [controlComponent];
const RegisterPhoneOrEmailInput = (RegisterPhoneOrEmailInputModule).RegisterPhoneOrEmailInput;
items2[1] = (
<RegisterPhoneOrEmailInput
loginPhone={loginPhone}
loginEmail={loginEmail}
setLoginPhone={updateLoginPhone}
setLoginEmail={setLoginEmail}
inputMode={inputMode}
onSubmit={closure}
inputError={identityError}
autoFocus
/>
);
const Button = (ButtonNativeModule).Button;
const intl = (IndexNativeModule).intl;
const string = intl.string;
const PDTjLN = (IndexNativeModule).t.PDTjLN;
items2[2] = (
<View style={styles.button}>
<Button
loading={property}
size="lg"
text={Reflect.apply(string, intl, [PDTjLN])}
onPress={closure}
disabled={preventSubmitIdentity}
/>
</View>
);
items2[3] = (
value9 != null
? (
value9 === ''
? null
: ((Component) => <Component style={styles.errors}>{value9}</Component>)(importDefault(8970) /* metro dependency 8970: FreeFormErrorLabel */)
)
: null
);
const authFormView = (
<AuthFormView headerText={headerText} subHeader={subheader}>
<ScrollView
style={styles.container}
contentContainerStyle={styles.scrollContent}
keyboardShouldPersistTaps="handled"
>
{items2}
</ScrollView>
</AuthFormView>
);
if (value4) {
r0 = authFormView;
} else {
value = importDefault(5467) /* metro dependency 5467: KeyboardAwareView */;
value = ((Component) => <Component style={styles.page}>{authFormView}</Component>)(value);
r0 = value;
}
return r0;
function RegisterIdentityBase_handleSubmit() { // fn#108325, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:1292, owner: RegisterIdentityBase._handleSubmit, offset: 0x0231ce5f, size: 53 bytes, params: 1, frame: 13
var environment;
const value = environment.__proto__;
return env1_3(_fun108327).apply(this, arguments);
function* _fun108327() { // fn#108327, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:1341, offset: 0x0231ce9f, size: 380 bytes, params: 1, frame: 20
var environment;
var clearRegistrationErrorMessageBinding;
var closure;
var value4;
var error;
var value5;
var binding2;
if (true) {
value = environment.__proto__.__proto__.__proto__;
var binding = env3_9;
binding({});
var setRegistrationErrorsBinding = setRegistrationErrors;
var ACCOUNT_IDENTITY = env3_12.ACCOUNT_IDENTITY;
var SUBMITTED = env3_13.SUBMITTED;
setRegistrationErrorsBinding({step: ACCOUNT_IDENTITY, actionType: SUBMITTED});
var PhoneOrEmailSelectorForceMode = env3_0(env3_2[18]).PhoneOrEmailSelectorForceMode;
var EMAIL = PhoneOrEmailSelectorForceMode.EMAIL;
if (require === EMAIL) {
binding = env3_10;
binding({email: env2_4, phoneToken: undefined});
value5 = ScrollView();
if (value5 != null) {
env3_9({email: value5});
setRegistrationErrors({step: env3_12.ACCOUNT_IDENTITY, actionType: env3_13.INPUT_ERROR,
details: ['email']});
} else {
binding = env3_0;
binding2 = env3_2;
value = binding(binding2[16]);
value.handleNextOrSubmitRegistration(binding(binding2[12]).AuthStates.REGISTER_IDENTITY, dependencyMap,
setRegistrationErrors);
}
} else {
try {
clearRegistrationErrorMessageBinding = clearRegistrationErrorMessage;
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
try {
clearRegistrationErrorMessageBinding(true);
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
try {
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
try {
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
try {
closure = _fun108328;
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
try {
value = View(closure);
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
yield value;
try {
value = undefined;
value4 = false;
} catch (error) {
clearRegistrationErrorMessage(false);
throw error;
}
if (value4) {
clearRegistrationErrorMessage(false);
return value;
}
clearRegistrationErrorMessage(false);
}
}
function _fun108328() { // fn#108328, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:1719, offset: 0x0231d01b, size: 51 bytes, params: 1, frame: 12
const PhoneOrEmailSelectorForceMode = env4_0(env4_2[18]).PhoneOrEmailSelectorForceMode;
const EMAIL = PhoneOrEmailSelectorForceMode.EMAIL;
importDefault(EMAIL);
}
}
}
function _fun108330() { // fn#108330, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:1185, offset: 0x0231d059, size: 30 bytes, params: 1, frame: 3
return identityErrorMessage ?? Module00005.message;
}
function _fun108331() { // fn#108331, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:1970, offset: 0x0231d077, size: 51 bytes, params: 1, frame: 12
const binding = env0_9;
const ACCOUNT_IDENTITY = RegisterTransitionSteps.ACCOUNT_IDENTITY;
const VIEWED = RegistrationTransitionActionTypes.VIEWED;
binding({step: ACCOUNT_IDENTITY, actionType: VIEWED});
}
}
function RegisterIdentity() { // fn#108333, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:2715, offset: 0x0231d114, size: 534 bytes, params: 1, frame: 22
const Math = global.Math;
const styles = useStyles(45 * Math.min(2, (UseFontScaleModule).useFontScale()));
const deviceCountry = (GetDeviceCountryModule).getDeviceCountry();
const r1 = deviceCountry != null && (require(14324) /* metro dependency 14324: emailFirstCountries */).EMAIL_FIRST_COUNTRIES.has(deviceCountry);
let binding = ReactModule;
const value7 = binding.useMemo(_fun108334, [r1]);
binding = ReactModule;
const useState = binding.useState;
const value9 = Module00057(Reflect.apply(useState, binding, [value7[0].mode]), 2);
const property = value9[0];
const value10 = ReactModule.useCallback(_fun108335, [value9[1], value7]);
const useSegmentedControlState = SegmentedControlStateNativeModule.useSegmentedControlState;
object = {'pageWidth': 0, 'defaultIndex': 0};
object.onSetActiveIndex = value10;
object.items = value7.map(function({descriptor}) {
var object = {};
object.id = require(dependencyMap[22]).intl.string(descriptor);
object.label = require(dependencyMap[22]).intl.string(descriptor);
object.page = null;
return object;
});
const value11 = Reflect.apply(useSegmentedControlState, SegmentedControlStateNativeModule, [object]);
object = {inputMode: property, setInputMode: ReactModule.useCallback(_fun108337, [value11, value7])};
const SegmentedControl = (SegmentedControlNativeModule).SegmentedControl;
object.controlComponent = (
<View style={styles.segmentedControl}>
<SegmentedControl state={value11} keyboardShouldPersistTaps="handled" />
</View>
);
const intl = (IndexNativeModule).intl;
const string = intl.string;
const WEdDgv = (IndexNativeModule).t.WEdDgv;
object.headerText = Reflect.apply(string, intl, [WEdDgv]);
return <RegisterIdentityBase {...object} />;
function _fun108334() { // fn#108334, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:2886, offset: 0x0231d32a, size: 255 bytes, params: 1, frame: 18
var items2;
const PhoneOrEmailSelectorForceMode = (PhoneOrEmailUtilsModule).PhoneOrEmailSelectorForceMode;
const binding = env0_0;
const object = {};
const t = (IndexNativeModule).t;
if (binding) {
object.descriptor = t['w/qqKK'];
object.mode = PhoneOrEmailSelectorForceMode.EMAIL;
items2 = [object, {descriptor: t.dEYpSt, mode: PhoneOrEmailSelectorForceMode.PHONE}];
} else {
object.descriptor = t.dEYpSt;
object.mode = PhoneOrEmailSelectorForceMode.PHONE;
items2 = [object, {descriptor: t['w/qqKK'], mode: PhoneOrEmailSelectorForceMode.EMAIL}];
}
return items2;
}
function _fun108335(a0) { // fn#108335, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:3296, offset: 0x0231d429, size: 43 bytes, params: 2, frame: 12
clearRegistrationErrorMessage();
env0_2(env0_1[a0].mode);
}
function _fun108337(a0) { // fn#108337, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:3532, offset: 0x0231d4b0, size: 66 bytes, params: 2, frame: 13
const env0_0 = a0;
const index = env0_1.findIndex(_fun108338);
if (index !== -1) {
Module00005.setActiveIndex(index, false);
}
function _fun108338({mode}) { // fn#108338, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14510:3555, offset: 0x0231d4f2, size: 21 bytes, params: 2, frame: 2
return mode === env0_0;
}
}
}
}
global.__d(_fun108322, 14313, [5, 57, 31, 27, 14304, 14305, 33, 4501, 4584, 8973, 1484, 14314, 676, 14302, 14319,
14320, 14303, 4594, 8993, 9001, 14321, 4578, 1244, 8970, 5467, 14323, 14324, 8853, 9221,
2]) /* metro module 14313, dependencies: [5, 57, 31, 27, 14304, 14305, 33, 4501, 4584, 8973, 1484, 14314, 676, 14302, 14319, 14320, 14303, 4594, 8993, 9001, 14321, 4578, 1244, 8970, 5467, 14323, 14324, 8853, 9221, 2] */;