@cleartrip/ct-platform-login-module 1.1.0-beta.2 → 1.1.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,565 +1,2 @@
1
- 'use strict';
2
-
3
- var tslib = require('tslib');
4
- var jsxRuntime = require('react/jsx-runtime');
5
- var react = require('react');
6
- var ctDesignToast = require('@cleartrip/ct-design-toast');
7
- var ctDesignSpacer = require('@cleartrip/ct-design-spacer');
8
- var ctPlatformDrawer = require('@cleartrip/ct-platform-drawer');
9
- var ctDesignTheme = require('@cleartrip/ct-design-theme');
10
- var ctPlatformConstants = require('@cleartrip/ct-platform-constants');
11
- var ctPlatformUtils = require('@cleartrip/ct-platform-utils');
12
- var ctDesignField = require('@cleartrip/ct-design-field');
13
- var ctDesignSpinner = require('@cleartrip/ct-design-spinner');
14
- var ctDesignTypography = require('@cleartrip/ct-design-typography');
15
- var ctDesignAlertCallout = require('@cleartrip/ct-design-alert-callout');
16
- var ctDesignIcons = require('@cleartrip/ct-design-icons');
17
- var classNames = require('classnames');
18
- var ctDesignButton = require('@cleartrip/ct-design-button');
19
- var ctDesignDivider = require('@cleartrip/ct-design-divider');
20
- var ctPlatformAssets = require('@cleartrip/ct-platform-assets');
21
- var react$1 = require('swiper/react');
22
-
23
- function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
24
-
25
- var classNames__default = /*#__PURE__*/_interopDefault(classNames);
26
-
27
- function styleInject(css, ref) {
28
- if (ref === void 0) ref = {};
29
- var insertAt = ref.insertAt;
30
- if (!css || typeof document === 'undefined') {
31
- return;
32
- }
33
- var head = document.head || document.getElementsByTagName('head')[0];
34
- var style = document.createElement('style');
35
- style.type = 'text/css';
36
- if (insertAt === 'top') {
37
- if (head.firstChild) {
38
- head.insertBefore(style, head.firstChild);
39
- } else {
40
- head.appendChild(style);
41
- }
42
- } else {
43
- head.appendChild(style);
44
- }
45
- if (style.styleSheet) {
46
- style.styleSheet.cssText = css;
47
- } else {
48
- style.appendChild(document.createTextNode(css));
49
- }
50
- }
51
-
52
- var css_248z$1 = ".index-module_mobileinput_footertext__jPQ-g a{color:#0f6bff;text-decoration:none}.index-module_mobileinput-seperator__7Ewok{position:relative}.index-module_mobileinput_seperatortext__-KDOp{background:#fff;left:0;margin:0 auto;position:absolute;right:0;text-align:center;top:-10px;width:40px}.index-module_slider_carousel_wrapper__0SuGB{border-top-left-radius:16px;border-top-right-radius:16px;width:100dvw}.index-module_login_form__tpSDz{background-color:#fff;padding-left:16px;padding-right:16px}.index-module_nonUtilsSelector_toast__lvWmB{bottom:12px!important;margin-bottom:12px;margin:0 auto!important;padding:12px 16px!important;width:calc(100% - 48px)!important;z-index:2000}.index-module_login_otp_error__o3y2L{padding-top:4px}.index-module_login_otp_input__L-3P8{font-size:24px!important;font-style:normal;font-weight:600!important;height:56px!important;line-height:28px;padding:auto;text-align:center;width:56px!important}.index-module_footer_text__nkeJv{color:grey!important;font-size:12px!important}.index-module_swiper-custom-pagination__Ma1gV{--swiper-theme-color:#fff;--swiper-pagination-color:#fff;--swiper-pagination-bullet-inactive-color:#999;--swiper-pagination-bullet-inactive-opacity:1}.index-module_otp_box_wrapper__sM2Ba{margin-right:8px}.index-module_otp_container__1CE4N{display:flex;flex-direction:column;margin-top:24px}.index-module_swiper__r5-8U{height:100%;width:100%}.index-module_swiper__r5-8U .index-module_swiper-slide__Zchn0{height:auto}.index-module_swiper-slide__Zchn0 img{display:block;height:100%;object-fit:fill;width:100%}";
53
- var styles = {"mobileinput_footertext":"index-module_mobileinput_footertext__jPQ-g","mobileinput-seperator":"index-module_mobileinput-seperator__7Ewok","mobileinput_seperatortext":"index-module_mobileinput_seperatortext__-KDOp","slider_carousel_wrapper":"index-module_slider_carousel_wrapper__0SuGB","login_form":"index-module_login_form__tpSDz","nonUtilsSelector_toast":"index-module_nonUtilsSelector_toast__lvWmB","login_otp_error":"index-module_login_otp_error__o3y2L","login_otp_input":"index-module_login_otp_input__L-3P8","footer_text":"index-module_footer_text__nkeJv","swiper-custom-pagination":"index-module_swiper-custom-pagination__Ma1gV","otp_box_wrapper":"index-module_otp_box_wrapper__sM2Ba","otp_container":"index-module_otp_container__1CE4N","swiper":"index-module_swiper__r5-8U","swiper-slide":"index-module_swiper-slide__Zchn0"};
54
- styleInject(css_248z$1);
55
-
56
- var AutoDetectState;
57
- (function (AutoDetectState) {
58
- AutoDetectState[AutoDetectState["DETECTING"] = 0] = "DETECTING";
59
- AutoDetectState[AutoDetectState["FAILED"] = 1] = "FAILED";
60
- AutoDetectState[AutoDetectState["DETECTED"] = 2] = "DETECTED";
61
- })(AutoDetectState || (AutoDetectState = {}));
62
- var OtpInput = function (_a) {
63
- var mobileNumber = _a.mobileNumber, errorCallout = _a.errorCallout, ravenPayload = _a.ravenPayload, otpInputHeight = _a.otpInputHeight, skipProfileFlow = _a.skipProfileFlow, otpResendDisabled = _a.otpResendDisabled, getOTP = _a.getOTP, setCtaDisabled = _a.setCtaDisabled, setErrorCallout = _a.setErrorCallout, setMobileNumber = _a.setMobileNumber, setShowMobilePage = _a.setShowMobilePage, handleLoginSuccess = _a.handleLoginSuccess, handleLoginFailure = _a.handleLoginFailure;
64
- var inputRefs = react.useRef(Array(4).fill(null));
65
- var _b = react.useState(AutoDetectState.DETECTING), autoDetecting = _b[0], setAutoDetecting = _b[1];
66
- var _c = react.useState(ctPlatformConstants.LOGIN_CONSTANTS.OTP_COUNTDOWN), countdown = _c[0], setCountdown = _c[1];
67
- var _d = react.useState(''), otp = _d[0], setOtp = _d[1];
68
- var _f = react.useState(true), countdownEnabled = _f[0], setCountdownEnabled = _f[1];
69
- var _g = react.useState(false), verifiedOtp = _g[0], setVerifiedOtp = _g[1];
70
- var _h = react.useState(''), otpErrorMessage = _h[0], setOtpErrorMessage = _h[1];
71
- var _j = react.useState(true), enableAutoDetect = _j[0], setEnableAutoDetect = _j[1];
72
- var lastOtpRequest = react.useRef();
73
- var lastOtpRequestTimeStamp = react.useRef();
74
- var loginMethod = 'CT';
75
- react.useEffect(function () {
76
- autoDetect();
77
- var eventProps = ctPlatformUtils.getRavenEventProps();
78
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_otp_screen_opened', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
79
- }, []);
80
- react.useEffect(function () {
81
- if (ctPlatformUtils.isIOSApp()) {
82
- setEnableAutoDetect(false);
83
- }
84
- }, []);
85
- react.useEffect(function () {
86
- autoDetect();
87
- }, []);
88
- react.useEffect(function () {
89
- if (countdown === 0) {
90
- setCountdownEnabled(false);
91
- }
92
- }, [countdown]);
93
- react.useEffect(function () {
94
- var interval;
95
- if (countdownEnabled && countdown > 0) {
96
- interval = setInterval(function () {
97
- setCountdown(function (prevCountdown) { return prevCountdown - 1; });
98
- }, 1000);
99
- }
100
- return function () {
101
- clearInterval(interval);
102
- };
103
- }, [countdownEnabled, countdown]);
104
- var autoDetect = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
105
- var otp_1, _e_1;
106
- return tslib.__generator(this, function (_a) {
107
- switch (_a.label) {
108
- case 0:
109
- _a.trys.push([0, 2, , 3]);
110
- return [4, ctPlatformUtils.autoReadOtp()];
111
- case 1:
112
- otp_1 = _a.sent();
113
- setOtp(otp_1);
114
- setAutoDetecting(AutoDetectState.DETECTED);
115
- if ((otp_1 === null || otp_1 === void 0 ? void 0 : otp_1.length) === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH &&
116
- handleOtpComplete) {
117
- handleOtpComplete(otp_1, true);
118
- }
119
- return [3, 3];
120
- case 2:
121
- _e_1 = _a.sent();
122
- if (_e_1 === 'NOT_SUPPORTED') {
123
- setEnableAutoDetect(false);
124
- }
125
- return [3, 3];
126
- case 3: return [2];
127
- }
128
- });
129
- }); }, [enableAutoDetect]);
130
- var handleOtpValidationError = react.useCallback(function (e) {
131
- var eventProps = ctPlatformUtils.getRavenEventProps();
132
- ctPlatformUtils.ravenSDKTrigger('u_login_error', tslib.__assign({ action_name: 'otp_incorrect', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
133
- var message = e === null || e === void 0 ? void 0 : e.message;
134
- if (message !== 'OTP_VALIDATE_LIMIT_EXCEEDED') {
135
- setOtp('');
136
- }
137
- inputRefs.current[0].focus();
138
- inputRefs.current[0].click();
139
- var messageValue = ctPlatformConstants.LOGIN_CONSTANTS[message];
140
- var toastMessage = typeof messageValue === 'string'
141
- ? messageValue
142
- : ctPlatformConstants.LOGIN_CONSTANTS.INVALID_OTP;
143
- setOtpErrorMessage(toastMessage);
144
- }, [inputRefs]);
145
- var handleOtpComplete = react.useCallback(function (otp, autodetected) { return tslib.__awaiter(void 0, void 0, void 0, function () {
146
- var eventProps, response, status_1, action, e_1;
147
- return tslib.__generator(this, function (_a) {
148
- switch (_a.label) {
149
- case 0:
150
- _a.trys.push([0, 2, , 3]);
151
- eventProps = ctPlatformUtils.getRavenEventProps();
152
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'otp_entered', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: !autodetected ? 'manual_entry' : 'autodetected', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
153
- if (otp === lastOtpRequest.current &&
154
- lastOtpRequestTimeStamp.current &&
155
- lastOtpRequestTimeStamp.current - Date.now() <= 100) {
156
- return [2];
157
- }
158
- lastOtpRequest.current = otp;
159
- lastOtpRequestTimeStamp.current = Date.now();
160
- return [4, ctPlatformUtils.validateOtp(mobileNumber, otp)];
161
- case 1:
162
- response = _a.sent();
163
- status_1 = response.status, action = response.action;
164
- if (Number(status_1) === 200 && !ctPlatformUtils.isEmpty(action)) {
165
- setVerifiedOtp(true);
166
- setOtpErrorMessage('');
167
- ctPlatformUtils.updateNativeOnLogin();
168
- if (action === 'SIGNUP') {
169
- if (!skipProfileFlow) {
170
- window.location.href =
171
- ctPlatformConstants.NAVIGATION_ROUTES.PERSONAL_DETAILS +
172
- '?onboardingFlow=true';
173
- }
174
- handleLoginSuccess(loginMethod, true);
175
- }
176
- else {
177
- handleLoginSuccess(loginMethod);
178
- }
179
- }
180
- else {
181
- handleLoginFailure(loginMethod);
182
- }
183
- return [3, 3];
184
- case 2:
185
- e_1 = _a.sent();
186
- handleLoginFailure(loginMethod);
187
- handleOtpValidationError(e_1);
188
- return [3, 3];
189
- case 3: return [2];
190
- }
191
- });
192
- }); }, [
193
- lastOtpRequest,
194
- lastOtpRequestTimeStamp,
195
- setVerifiedOtp,
196
- setAutoDetecting,
197
- setOtpErrorMessage,
198
- handleOtpValidationError,
199
- ]);
200
- var handleOnPaste = function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
201
- var clipboardData, pastedArr, pastedString;
202
- var _a, _b;
203
- return tslib.__generator(this, function (_c) {
204
- switch (_c.label) {
205
- case 0: return [4, navigator.clipboard.readText()];
206
- case 1:
207
- clipboardData = _c.sent();
208
- if (clipboardData && ctPlatformUtils.isNumeric(clipboardData)) {
209
- pastedArr = clipboardData
210
- .slice(0, ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH)
211
- .split('');
212
- (_a = inputRefs.current[ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH - 1]) === null || _a === void 0 ? void 0 : _a.focus();
213
- (_b = inputRefs.current[ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH - 1]) === null || _b === void 0 ? void 0 : _b.click();
214
- pastedString = pastedArr.join('');
215
- setOtp(pastedString);
216
- if (pastedString.length === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH) {
217
- handleOtpComplete(pastedString, false);
218
- }
219
- }
220
- return [2];
221
- }
222
- });
223
- }); };
224
- var handleInput = react.useCallback(function (event, index) {
225
- var _a, _b;
226
- setErrorCallout('');
227
- var value = event.target.value;
228
- if (value !== '' && index < inputRefs.current.length - 1) {
229
- (_a = inputRefs.current[index + 1]) === null || _a === void 0 ? void 0 : _a.focus();
230
- (_b = inputRefs.current[index + 1]) === null || _b === void 0 ? void 0 : _b.click();
231
- }
232
- var inputValues = inputRefs.current.map(function (ref) {
233
- if (ctPlatformUtils.isHTMLInputElement(ref)) {
234
- return ref.value;
235
- }
236
- return '';
237
- });
238
- var otpValue = inputValues.join('').slice(0, 4);
239
- setOtp(otpValue);
240
- if (otpValue.length === ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH) {
241
- handleOtpComplete(otpValue, false);
242
- }
243
- }, [setOtp, handleOtpComplete]);
244
- var handleKeyDown = react.useCallback(function (e, index) {
245
- var _a, _b, _c;
246
- if (e.key === 'Backspace' &&
247
- index > 0 &&
248
- ((_a = inputRefs.current[index]) === null || _a === void 0 ? void 0 : _a.value) === '') {
249
- e.preventDefault();
250
- (_b = inputRefs.current[index - 1]) === null || _b === void 0 ? void 0 : _b.focus();
251
- (_c = inputRefs.current[index - 1]) === null || _c === void 0 ? void 0 : _c.click();
252
- }
253
- }, [inputRefs]);
254
- var onResendOtpClick = react.useCallback(function () {
255
- setCountdown(ctPlatformConstants.LOGIN_CONSTANTS.OTP_COUNTDOWN);
256
- setCountdownEnabled(true);
257
- getOTP(mobileNumber);
258
- var eventProps = ctPlatformUtils.getRavenEventProps();
259
- ctPlatformUtils.ravenSDKTrigger('u_login_error', tslib.__assign({ action_name: 'resend_otp_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
260
- }, [setCountdown, setCountdownEnabled]);
261
- var onEditCLick = react.useCallback(function () {
262
- setCtaDisabled(true);
263
- setShowMobilePage(true);
264
- setMobileNumber('');
265
- }, [setShowMobilePage]);
266
- return (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-column bg-neutral-100', style: { height: otpInputHeight } }, { children: [errorCallout && (jsxRuntime.jsx(ctDesignAlertCallout.AlertCallout, { variant: 'error', textNode: errorCallout, prefixIconNode: jsxRuntime.jsx(ctDesignIcons.InfoIcon, { fill: 'red' }), style: {
267
- color: '#ffff',
268
- backgroundColor: '#db201e',
269
- }, className: 'fs-12' })), jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-bottom' }, { children: [jsxRuntime.jsxs(ctDesignTypography.Typography, tslib.__assign({ variant: 'HM1', color: 'heading' }, { children: [ctPlatformConstants.LOGIN_CONSTANTS.OTP_TEXT, " ", jsxRuntime.jsx("br", {}), mobileNumber] })), jsxRuntime.jsx("div", tslib.__assign({ className: 'pl-2', onClick: onEditCLick }, { children: jsxRuntime.jsx(ctDesignIcons.Edit, {}) }))] })), jsxRuntime.jsxs("div", tslib.__assign({ className: styles.otp_container }, { children: [jsxRuntime.jsx("div", tslib.__assign({ className: 'flex' }, { children: tslib.__spreadArray([], Array(ctPlatformConstants.LOGIN_CONSTANTS.OTP_LENGTH), true).map(function (_, i) { return (jsxRuntime.jsx("div", tslib.__assign({ className: styles.otp_box_wrapper }, { children: jsxRuntime.jsx(ctDesignField.FieldV2, { prompt: {
270
- hasError: !!otpErrorMessage,
271
- }, type: 'number', placeholder: '', value: otp[i], max: 1, inputMode: 'numeric', className: styles.login_otp_input, variant: 'md', ref: function (ref) {
272
- if (ref) {
273
- inputRefs.current[i] = ref;
274
- }
275
- }, onKeyDown: function (e) { return handleKeyDown(e, i); }, onChange: function (e) { return handleInput(e, i); }, onPaste: handleOnPaste, autoFocus: i === 0 }) }), i)); }) })), !!otpErrorMessage && (jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'warning', className: styles.login_otp_error }, { children: otpErrorMessage })))] })), jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'pt-2' }), autoDetecting === AutoDetectState.DETECTING &&
276
- !verifiedOtp &&
277
- enableAutoDetect &&
278
- countdown >
279
- ctPlatformConstants.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN && (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle' }, { children: [jsxRuntime.jsx(ctDesignSpinner.Spinner, { width: '20px', height: '20px', borderColor: '#11a670', className: 'bg-neutral-900 bc-black' }), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'B3', className: 'fs-12 fw-500 ml-1 c-neutral-700' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.AUTO_DETECTING_TEXT }))] }))), autoDetecting === AutoDetectState.DETECTING &&
280
- countdown <= ctPlatformConstants.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN &&
281
- enableAutoDetect &&
282
- !verifiedOtp && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex' }, { children: [jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'B3', className: 'fs-12 fw-500 c-neutral-700 ' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.OTP_RESEND_TEXT })), jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'ml-1' }), otpResendDisabled ? (jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ className: 'color-neutral-200 fw-500', variant: 'B3' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.RESEND_CTA }))) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [countdown === 0 && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ isClickable: true, variant: 'B3', onClick: onResendOtpClick, color: 'link', className: '\n fs-12 fw-500 c-pointer' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.RESEND_CTA })) })), countdown > 0 && (jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ color: 'disabled', variant: 'B3' }, { children: ' Resend (' + countdown + 's)' })))] }))] })) })), !otpErrorMessage && verifiedOtp && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle' }, { children: [jsxRuntime.jsx(ctDesignIcons.CheckCircle, {}), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'success', className: 'fs-12' }, { children: autoDetecting === AutoDetectState.DETECTED
283
- ? ctPlatformConstants.LOGIN_CONSTANTS.AUTO_DETECTED_TEXT
284
- : ctPlatformConstants.LOGIN_CONSTANTS.VERIFIED_MESSAGE }))] })) })), jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'mt-24' })] })));
285
- };
286
-
287
- var css_248z = ".index-module_loader__63LeU{align-items:center;background-color:hsla(0,0%,100%,.95);bottom:0;display:flex;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:0}.index-module_loader__63LeU.index-module_With-full-opacity__ZSY-U{background-color:#fff}.index-module_loader__content__Q6kJl{max-width:280px;text-align:center}.index-module_loader__spinner__6B3AR{animation:index-module_loader-rotate__efcf3 .8s linear infinite;border:2px solid rgba(51,102,204,.3);border-radius:50%;border-top-color:#36c;display:inline-block;height:30px;margin-bottom:10px;position:relative;width:30px}.index-module_loader__heading__7YZ3N{color:#000;font-size:18px;font-weight:600;margin-bottom:5px}.index-module_loader__text__1QcLi{color:rgba(0,0,0,.8);font-size:16px;line-height:1.5}";
288
- var Styles = {"loader":"index-module_loader__63LeU","With-full-opacity":"index-module_With-full-opacity__ZSY-U","loader__content":"index-module_loader__content__Q6kJl","loader__spinner":"index-module_loader__spinner__6B3AR","loader-rotate":"index-module_loader-rotate__efcf3","loader__heading":"index-module_loader__heading__7YZ3N","loader__text":"index-module_loader__text__1QcLi"};
289
- styleInject(css_248z);
290
-
291
- var Loader = function (_a) {
292
- var title = _a.title, message = _a.message, className = _a.className;
293
- return (jsxRuntime.jsx("div", tslib.__assign({ className: "".concat(Styles['utilswrapper'], " utilswrapper") }, { children: jsxRuntime.jsx("div", tslib.__assign({ className: classNames__default.default(Styles['loader'], className) }, { children: jsxRuntime.jsxs("div", tslib.__assign({ className: Styles['loader__content'] }, { children: [jsxRuntime.jsx("div", { className: Styles['loader__spinner'] }), jsxRuntime.jsx("h5", tslib.__assign({ className: Styles['loader__heading'] }, { children: title })), jsxRuntime.jsx("p", tslib.__assign({ className: Styles['loader__text'] }, { children: message }))] })) })) })));
294
- };
295
-
296
- var MobileInput = function (_a) {
297
- var sendingOtp = _a.sendingOtp, ctaDisabled = _a.ctaDisabled, getOTP = _a.getOTP, setErrorCallout = _a.setErrorCallout, errorCallout = _a.errorCallout, mobileNumber = _a.mobileNumber, setMobileInputHeight = _a.setMobileInputHeight, setMobileNumber = _a.setMobileNumber, fallbackUri = _a.fallbackUri, skipProfileFlow = _a.skipProfileFlow, currentPageUri = _a.currentPageUri, ravenPayload = _a.ravenPayload;
298
- var fkSSOEnabled = react.useState(ctPlatformUtils.isFKSSOEnabled)[0];
299
- var _b = react.useState(false), fkButtonLoading = _b[0], setFkButtonLoading = _b[1];
300
- var inputRef = react.useRef(null);
301
- var mobileViewRef = react.useRef(null);
302
- react.useEffect(function () {
303
- if (mobileViewRef.current) {
304
- var height = mobileViewRef.current.clientHeight;
305
- setMobileInputHeight(height);
306
- }
307
- }, [mobileViewRef.current]);
308
- react.useEffect(function () {
309
- var timeout;
310
- if (inputRef.current) {
311
- timeout = setTimeout(function () {
312
- var _a;
313
- (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus();
314
- }, 100);
315
- }
316
- return function () {
317
- clearTimeout(timeout);
318
- };
319
- }, []);
320
- react.useEffect(function () {
321
- if (ctPlatformUtils.isAndroidApp()) {
322
- autoDetectMobileNumber();
323
- }
324
- }, []);
325
- var handleFKSSOClick = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
326
- var eventProps, redirectUrl;
327
- return tslib.__generator(this, function (_a) {
328
- switch (_a.label) {
329
- case 0:
330
- _a.trys.push([0, 2, , 3]);
331
- eventProps = ctPlatformUtils.getRavenEventProps();
332
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_with_flipkart_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'fk_sso', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
333
- setFkButtonLoading(true);
334
- return [4, ctPlatformUtils.handleFKSSO(fallbackUri, skipProfileFlow
335
- ? currentPageUri
336
- : ctPlatformConstants.NAVIGATION_ROUTES.PERSONAL_DETAILS +
337
- '?onboardingFlow=true', currentPageUri)];
338
- case 1:
339
- redirectUrl = _a.sent();
340
- window.location.href = redirectUrl;
341
- return [3, 3];
342
- case 2:
343
- _a.sent();
344
- setFkButtonLoading(false);
345
- return [3, 3];
346
- case 3: return [2];
347
- }
348
- });
349
- }); }, []);
350
- var handleInputChange = react.useCallback(function (event, autoDetected) {
351
- if (autoDetected === void 0) { autoDetected = false; }
352
- setErrorCallout('');
353
- var value = event.target.value || '';
354
- value = value.replace(ctPlatformUtils.MULTI_SPACE, ' ').trimStart();
355
- setMobileNumber(value);
356
- var validMobileNo = ctPlatformUtils.isValidMobileNumber(event.target.value);
357
- if (validMobileNo) {
358
- getOTP(value);
359
- var eventProps = ctPlatformUtils.getRavenEventProps();
360
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'get_otp_clicked', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'auto_click', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
361
- if (!autoDetected) {
362
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'phone_number_entered', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'manual_entry', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
363
- }
364
- else {
365
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'phone_number_autodetected', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', entry_type: 'autodetected', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
366
- }
367
- }
368
- }, [setMobileNumber]);
369
- var autoDetectMobileNumber = react.useCallback(function () { return tslib.__awaiter(void 0, void 0, void 0, function () {
370
- var autoDetectedNumber, simulatedEvent;
371
- return tslib.__generator(this, function (_a) {
372
- switch (_a.label) {
373
- case 0: return [4, ctPlatformUtils.showMobileNumberHint()];
374
- case 1:
375
- autoDetectedNumber = _a.sent();
376
- simulatedEvent = {
377
- target: {
378
- value: autoDetectedNumber,
379
- },
380
- };
381
- if (autoDetectedNumber) {
382
- handleInputChange(simulatedEvent, true);
383
- }
384
- return [2];
385
- }
386
- });
387
- }); }, [handleInputChange]);
388
- var handlePrivacyPolicyClick = react.useCallback(function () {
389
- var eventProps = ctPlatformUtils.getRavenEventProps();
390
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'policy_click', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
391
- window.location.href = ctPlatformConstants.NAVIGATION_ROUTES.PRIVACY_POLICY;
392
- }, []);
393
- var handleTermsOfUseClick = react.useCallback(function () {
394
- var eventProps = ctPlatformUtils.getRavenEventProps();
395
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'tnc_click', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
396
- window.location.href = ctPlatformConstants.NAVIGATION_ROUTES.TERMS;
397
- }, []);
398
- return (jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-column', ref: mobileViewRef }, { children: [errorCallout && (jsxRuntime.jsx(ctDesignAlertCallout.AlertCallout, { variant: 'error', textNode: errorCallout, prefixIconNode: jsxRuntime.jsx(ctDesignIcons.InfoIcon, { fill: 'red' }), style: {
399
- color: '#ffff',
400
- backgroundColor: '#db201e',
401
- }, className: 'fs-12' })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'HM1', color: 'heading', className: 'mb-4 fs-24' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.LOGIN_TO_CT })), jsxRuntime.jsx(ctDesignField.PhoneField, { onChange: handleInputChange, value: mobileNumber, placeholder: '', inputMode: 'numeric', ref: inputRef, min: 0, max: 10, autoFocus: true, countryCode: ctPlatformConstants.LOGIN_CONSTANTS.COUNTRY_CODE }), jsxRuntime.jsx(ctDesignButton.Button, tslib.__assign({ color: 'primary', size: 'medium', minWidth: '160px', disabled: ctaDisabled, loading: sendingOtp, className: 'my-6', onClick: function () { return getOTP(mobileNumber); } }, { children: ctPlatformConstants.LOGIN_CONSTANTS.GET_OTP })), fkSSOEnabled && (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", tslib.__assign({ className: 'my-6 p-relative' }, { children: [jsxRuntime.jsx(ctDesignDivider.Divider, {}), jsxRuntime.jsx("span", tslib.__assign({ className: "".concat(styles.mobileinput_seperatortext) }, { children: "or" }))] })), jsxRuntime.jsx(ctDesignButton.Button, tslib.__assign({ variant: 'outline', size: 'medium', className: 'my-6', loading: fkButtonLoading, onClick: handleFKSSOClick, showLeftIcon: !fkButtonLoading, LeftIcon: jsxRuntime.jsx("img", { src: ctPlatformAssets.FlipkartLogo }) }, { children: ctPlatformConstants.LOGIN_CONSTANTS.FK_LOGIN_CTA }))] })), jsxRuntime.jsxs("div", tslib.__assign({ className: 'pt-8 pb-6' }, { children: [jsxRuntime.jsx(ctDesignDivider.Divider, {}), jsxRuntime.jsxs("div", tslib.__assign({ className: 'flex flex-middle \n flex-center flex-wrap pt-2' }, { children: [jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', className: styles.footer_text }, { children: ctPlatformConstants.LOGIN_CONSTANTS.FOOTER_TEXT })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'link', className: 'pl-1 fs-12', isClickable: true, onClick: handlePrivacyPolicyClick }, { children: ctPlatformConstants.LOGIN_CONSTANTS.PRIVACY_CTA })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ className: 'px-1 fs-12 c-neutral-700', variant: 'P1' }, { children: '& ' })), jsxRuntime.jsx(ctDesignTypography.Typography, tslib.__assign({ variant: 'P1', color: 'link', isClickable: true, onClick: handleTermsOfUseClick, className: 'fs-12' }, { children: ctPlatformConstants.LOGIN_CONSTANTS.TNC_CTA }))] }))] }))] })));
402
- };
403
-
404
- const imagePlaceHolderURI =
405
- // eslint-disable-next-line max-len
406
- 'data:image/png;base64,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';
407
- const ImageUrls = [{
408
- src: 'https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel1.png',
409
- placeholder: imagePlaceHolderURI
410
- }, {
411
- src: 'https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel2.png',
412
- placeholder: imagePlaceHolderURI
413
- }, {
414
- src: 'https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel3.png',
415
- placeholder: imagePlaceHolderURI
416
- }];
417
-
418
- var ImageWithPlaceholder = function (_a) {
419
- var src = _a.src, placeholderSrc = _a.placeholderSrc, onLoad = _a.onLoad, props = tslib.__rest(_a, ["src", "placeholderSrc", "onLoad"]);
420
- var _b = react.useState(placeholderSrc || src), imgSrc = _b[0], setImgSrc = _b[1];
421
- var onLoadRef = react.useRef(onLoad);
422
- react.useEffect(function () {
423
- onLoadRef.current = onLoad;
424
- }, [onLoad]);
425
- react.useEffect(function () {
426
- var img = new Image();
427
- img.onload = function () {
428
- setImgSrc(src);
429
- if (onLoadRef.current) {
430
- onLoadRef.current();
431
- }
432
- };
433
- img.src = src;
434
- }, [src]);
435
- return jsxRuntime.jsx("img", tslib.__assign({ src: imgSrc }, props));
436
- };
437
-
438
- var CarouselWrapper = function () {
439
- return (jsxRuntime.jsx("div", tslib.__assign({ className: " o-hidden p-relative ".concat(styles.slider_carousel_wrapper) }, { children: jsxRuntime.jsx(react$1.Swiper, tslib.__assign({ autoplay: true, slidesPerView: 1, navigation: false, loop: true, pagination: { clickable: true }, className: "".concat(styles['swiper'], " ").concat(styles['swiper-custom-pagination']), lazy: {
440
- loadPrevNextAmount: 1,
441
- } }, { children: ImageUrls.map(function (item, index) {
442
- return (jsxRuntime.jsx(react$1.SwiperSlide, tslib.__assign({ className: styles['swiper-slide'] }, { children: jsxRuntime.jsx(jsxRuntime.Fragment, { children: index < 1 ? (jsxRuntime.jsx(ImageWithPlaceholder, { src: item.src, placeholderSrc: item.placeholder, alt: "Slide ".concat(index + 1), rel: 'preload', fetchPriority: 'high' })) : (jsxRuntime.jsx(ImageWithPlaceholder, { src: item.src, placeholderSrc: item.placeholder, alt: "Slide ".concat(index + 1), loading: 'lazy', className: 'lazy' })) }) }), index));
443
- }) })) })));
444
- };
445
-
446
- var LoginModule = function (_a) {
447
- var fallbackUri = _a.fallbackUri, isDrawerOpen = _a.isDrawerOpen, skipProfileFlow = _a.skipProfileFlow, _b = _a.showCarousel, showCarousel = _b === void 0 ? true : _b, _c = _a.ravenPayload, ravenPayload = _c === void 0 ? {} : _c, handleLoginClose = _a.handleLoginClose, onAuthSuccess = _a.onAuthSuccess, onAuthFailure = _a.onAuthFailure;
448
- var _d = react.useState(true), showMobilePage = _d[0], setShowMobilePage = _d[1];
449
- var _e = react.useState(true), ctaDisabled = _e[0], setCtaDisabled = _e[1];
450
- var _f = react.useState(false), sendingOtp = _f[0], setSendingOtp = _f[1];
451
- var _g = react.useState(isDrawerOpen), showLoginForm = _g[0], setShowLoginForm = _g[1];
452
- var _h = react.useState(''), mobileNumber = _h[0], setMobileNumber = _h[1];
453
- var _j = react.useState(0), mobileInputHeight = _j[0], setMobileInputHeight = _j[1];
454
- var _k = react.useState(false), otpResendDisabled = _k[0], setOtpResendDisabled = _k[1];
455
- var _l = react.useState(''), errorCallout = _l[0], setErrorCallout = _l[1];
456
- var _m = react.useState(false), showSuccess = _m[0], setShowSuccess = _m[1];
457
- var _o = react.useState(false), showSigninLoader = _o[0], setShowSigninLoader = _o[1];
458
- var currentPageUri = react.useState(function () { return ctPlatformUtils.getCurrentPathName(); })[0];
459
- var showSigninLoaderScreen = function () {
460
- setShowSigninLoader(true);
461
- };
462
- react.useEffect(function () {
463
- if (window) {
464
- window['showSigninLoaderScreen'] = showSigninLoaderScreen;
465
- }
466
- var queryValue = ctPlatformUtils.getQueryParam('fkSSOstatus');
467
- var loginMethod = 'FK';
468
- if (queryValue === 'signin') {
469
- if (ctPlatformUtils.isAndroidApp()) {
470
- ctPlatformUtils.updateNativeAndroidOnSignIn();
471
- }
472
- handleLoginSuccess(loginMethod);
473
- }
474
- if (queryValue === 'signup') {
475
- if (ctPlatformUtils.isAndroidApp()) {
476
- ctPlatformUtils.updateNativeAndroidOnSignIn();
477
- }
478
- handleLoginSuccess(loginMethod, true);
479
- }
480
- if (queryValue === 'failure') {
481
- handleLoginFailure(loginMethod);
482
- }
483
- }, []);
484
- var getOTP = react.useCallback(function (mobileNumber) { return tslib.__awaiter(void 0, void 0, void 0, function () {
485
- var res, status_1, err_1, message, errorMessage;
486
- return tslib.__generator(this, function (_a) {
487
- switch (_a.label) {
488
- case 0:
489
- _a.trys.push([0, 2, , 3]);
490
- setCtaDisabled(false);
491
- setSendingOtp(true);
492
- ctPlatformUtils.triggerOTPListener();
493
- return [4, ctPlatformUtils.sendLoginOtp(mobileNumber)];
494
- case 1:
495
- res = _a.sent();
496
- status_1 = (res || {}).status;
497
- if (status_1 === 'SUCCESS') {
498
- setShowMobilePage(false);
499
- setSendingOtp(false);
500
- }
501
- return [3, 3];
502
- case 2:
503
- err_1 = _a.sent();
504
- console.error(err_1);
505
- message = (err_1 || {}).message;
506
- setSendingOtp(false);
507
- errorMessage = message && ctPlatformConstants.LOGIN_CONSTANTS[message];
508
- if (errorMessage) {
509
- setErrorCallout(String(errorMessage));
510
- }
511
- else {
512
- setErrorCallout(String(ctPlatformConstants.LOGIN_CONSTANTS.GENERIC_ERROR_MESSAGE));
513
- }
514
- if (message === 'OTP_SEND_LIMIT_EXCEEDED') {
515
- setOtpResendDisabled(true);
516
- }
517
- return [3, 3];
518
- case 3: return [2];
519
- }
520
- });
521
- }); }, [showMobilePage, setShowMobilePage]);
522
- var handleLoginSuccess = react.useCallback(function (loginMethod, action) {
523
- var eventProps = ctPlatformUtils.getRavenEventProps();
524
- ctPlatformUtils.ravenSDKTrigger('u_login_success', tslib.__assign({ action_name: 'login_successful', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', login_new: action ? 'sign_up' : 'sign_in', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
525
- onAuthSuccess(loginMethod, action);
526
- if (action && !skipProfileFlow) ;
527
- else {
528
- handleDrawerClose();
529
- setShowSuccess(true);
530
- }
531
- }, []);
532
- var handleLoginFailure = react.useCallback(function (loginMethod) {
533
- onAuthFailure(loginMethod);
534
- }, []);
535
- var handleDrawerClose = function (evt) {
536
- evt === null || evt === void 0 ? void 0 : evt.stopPropagation();
537
- setShowLoginForm(false);
538
- setMobileNumber('');
539
- setCtaDisabled(true);
540
- var eventProps = ctPlatformUtils.getRavenEventProps();
541
- ctPlatformUtils.ravenSDKTrigger('u_login_click', tslib.__assign({ action_name: 'login_prompt_dismissed', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
542
- if (handleLoginClose && typeof handleLoginClose === 'function') {
543
- handleLoginClose();
544
- }
545
- };
546
- react.useEffect(function () {
547
- if (isDrawerOpen) {
548
- setShowMobilePage(true);
549
- setShowLoginForm(true);
550
- var eventProps = ctPlatformUtils.getRavenEventProps();
551
- ctPlatformUtils.ravenSDKTrigger('u_login_popup', tslib.__assign({ action_name: 'login_prompt_opened', login_form: eventProps === null || eventProps === void 0 ? void 0 : eventProps.loginForm, login_type: 'native', vertical: eventProps === null || eventProps === void 0 ? void 0 : eventProps.vertical, page_name: eventProps === null || eventProps === void 0 ? void 0 : eventProps.pageName }, ravenPayload));
552
- }
553
- else {
554
- setShowLoginForm(false);
555
- }
556
- }, [isDrawerOpen]);
557
- return (jsxRuntime.jsx(ctDesignTheme.ThemeProvider, { children: jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ctPlatformDrawer.Drawer, tslib.__assign({ direction: 'bottom', isOpen: showLoginForm, showClose: true, overlay: true, handleClose: handleDrawerClose, onClose: function () { } }, { children: jsxRuntime.jsx("div", tslib.__assign({ className: "".concat(styles['utilswrapper'], " utilswrapper") }, { children: jsxRuntime.jsxs("div", tslib.__assign({ style: {
558
- maxHeight: 'calc(100dvh - 60px)',
559
- overflowY: 'auto',
560
- borderRadius: '16px 16px 0 0',
561
- } }, { children: [showCarousel && jsxRuntime.jsx(CarouselWrapper, {}), jsxRuntime.jsxs("div", tslib.__assign({ className: styles['login_form'] }, { children: [jsxRuntime.jsx("div", { children: jsxRuntime.jsx(ctDesignSpacer.Spacer, { className: 'pt-6' }) }), showMobilePage ? (jsxRuntime.jsx(MobileInput, { device: 'PWA', ctaDisabled: ctaDisabled, sendingOtp: sendingOtp, getOTP: getOTP, mobileNumber: mobileNumber, setMobileNumber: setMobileNumber, setMobileInputHeight: setMobileInputHeight, fallbackUri: fallbackUri, skipProfileFlow: skipProfileFlow, currentPageUri: currentPageUri, setErrorCallout: setErrorCallout, errorCallout: errorCallout, ravenPayload: ravenPayload })) : (jsxRuntime.jsx(OtpInput, { mobileNumber: mobileNumber, getOTP: getOTP, setCtaDisabled: setCtaDisabled, setShowMobilePage: setShowMobilePage, handleLoginSuccess: handleLoginSuccess, handleLoginFailure: handleLoginFailure, otpInputHeight: mobileInputHeight, setMobileNumber: setMobileNumber, setErrorCallout: setErrorCallout, errorCallout: errorCallout, otpResendDisabled: otpResendDisabled, ravenPayload: ravenPayload, skipProfileFlow: skipProfileFlow }))] }))] })) })) })), showSuccess && (jsxRuntime.jsx(ctDesignToast.Toast, { text: 'Logged in successfully!', show: showSuccess, className: "".concat(styles.nonUtilsSelector_toast), closeTimeout: 2000 })), showSigninLoader && (jsxRuntime.jsx(Loader, { title: 'Please wait', message: 'Signing in...', className: 'z-2 bg-white' }))] }) }));
562
- };
563
-
564
- exports.LoginModule = LoginModule;
1
+ "use strict";var e=require("tslib"),i=require("react/jsx-runtime"),n=require("react"),r=require("@cleartrip/ct-design-toast"),t=require("@cleartrip/ct-design-spacer"),a=require("@cleartrip/ct-platform-drawer"),o=require("@cleartrip/ct-design-theme"),l=require("@cleartrip/ct-platform-constants"),s=require("@cleartrip/ct-platform-utils"),c=require("@cleartrip/ct-design-field"),_=require("@cleartrip/ct-design-spinner"),u=require("@cleartrip/ct-design-typography"),d=require("@cleartrip/ct-design-alert-callout"),g=require("@cleartrip/ct-design-icons"),p=require("classnames"),m=require("@cleartrip/ct-design-button"),f=require("@cleartrip/ct-design-divider"),v=require("@cleartrip/ct-platform-assets"),N=require("swiper/react");function A(e){return e&&e.__esModule?e:{default:e}}var x=A(p);function h(e,i){void 0===i&&(i={});var n=i.insertAt;if(e&&"undefined"!=typeof document){var r=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css","top"===n&&r.firstChild?r.insertBefore(t,r.firstChild):r.appendChild(t),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}}var T,E={mobileinput_footertext:"index-module_mobileinput_footertext__jPQ-g","mobileinput-seperator":"index-module_mobileinput-seperator__7Ewok",mobileinput_seperatortext:"index-module_mobileinput_seperatortext__-KDOp",slider_carousel_wrapper:"index-module_slider_carousel_wrapper__0SuGB",login_form:"index-module_login_form__tpSDz",nonUtilsSelector_toast:"index-module_nonUtilsSelector_toast__lvWmB",login_otp_error:"index-module_login_otp_error__o3y2L",login_otp_input:"index-module_login_otp_input__L-3P8",footer_text:"index-module_footer_text__nkeJv","swiper-custom-pagination":"index-module_swiper-custom-pagination__Ma1gV",otp_box_wrapper:"index-module_otp_box_wrapper__sM2Ba",otp_container:"index-module_otp_container__1CE4N",swiper:"index-module_swiper__r5-8U","swiper-slide":"index-module_swiper-slide__Zchn0"};h(".index-module_mobileinput_footertext__jPQ-g a{color:#0f6bff;text-decoration:none}.index-module_mobileinput-seperator__7Ewok{position:relative}.index-module_mobileinput_seperatortext__-KDOp{background:#fff;left:0;margin:0 auto;position:absolute;right:0;text-align:center;top:-10px;width:40px}.index-module_slider_carousel_wrapper__0SuGB{border-top-left-radius:16px;border-top-right-radius:16px;width:100dvw}.index-module_login_form__tpSDz{background-color:#fff;padding-left:16px;padding-right:16px}.index-module_nonUtilsSelector_toast__lvWmB{bottom:12px!important;margin-bottom:12px;margin:0 auto!important;padding:12px 16px!important;width:calc(100% - 48px)!important;z-index:2000}.index-module_login_otp_error__o3y2L{padding-top:4px}.index-module_login_otp_input__L-3P8{font-size:24px!important;font-style:normal;font-weight:600!important;height:56px!important;line-height:28px;padding:auto;text-align:center;width:56px!important}.index-module_footer_text__nkeJv{color:grey!important;font-size:12px!important}.index-module_swiper-custom-pagination__Ma1gV{--swiper-theme-color:#fff;--swiper-pagination-color:#fff;--swiper-pagination-bullet-inactive-color:#999;--swiper-pagination-bullet-inactive-opacity:1}.index-module_otp_box_wrapper__sM2Ba{margin-right:8px}.index-module_otp_container__1CE4N{display:flex;flex-direction:column;margin-top:24px}.index-module_swiper__r5-8U{height:100%;width:100%}.index-module_swiper__r5-8U .index-module_swiper-slide__Zchn0{height:auto}.index-module_swiper-slide__Zchn0 img{display:block;height:100%;object-fit:fill;width:100%}"),function(e){e[e.DETECTING=0]="DETECTING",e[e.FAILED=1]="FAILED",e[e.DETECTED=2]="DETECTED"}(T||(T={}));var C=function(r){var a=r.mobileNumber,o=r.errorCallout,p=r.ravenPayload,m=r.otpInputHeight,f=r.skipProfileFlow,v=r.otpResendDisabled,N=r.getOTP,A=r.setCtaDisabled,x=r.setErrorCallout,h=r.setMobileNumber,C=r.setShowMobilePage,S=r.handleLoginSuccess,b=r.handleLoginFailure,O=n.useRef(Array(4).fill(null)),I=n.useState(T.DETECTING),y=I[0],w=I[1],D=n.useState(l.LOGIN_CONSTANTS.OTP_COUNTDOWN),P=D[0],j=D[1],G=n.useState(""),k=G[0],L=G[1],B=n.useState(!0),Q=B[0],R=B[1],F=n.useState(!1),U=F[0],q=F[1],z=n.useState(""),X=z[0],K=z[1],M=n.useState(!0),J=M[0],W=M[1],Z=n.useRef(),V=n.useRef(),H="CT";n.useEffect((function(){Y();var i=s.getRavenEventProps();s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"login_otp_screen_opened",login_form:null==i?void 0:i.loginForm,login_type:"native",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},p))}),[]),n.useEffect((function(){s.isIOSApp()&&W(!1)}),[]),n.useEffect((function(){Y()}),[]),n.useEffect((function(){0===P&&R(!1)}),[P]),n.useEffect((function(){var e;return Q&&P>0&&(e=setInterval((function(){j((function(e){return e-1}))}),1e3)),function(){clearInterval(e)}}),[Q,P]);var Y=n.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var i;return e.__generator(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,s.autoReadOtp()];case 1:return i=e.sent(),L(i),w(T.DETECTED),(null==i?void 0:i.length)===l.LOGIN_CONSTANTS.OTP_LENGTH&&ee&&ee(i,!0),[3,3];case 2:return"NOT_SUPPORTED"===e.sent()&&W(!1),[3,3];case 3:return[2]}}))}))}),[J]),$=n.useCallback((function(i){var n=s.getRavenEventProps();s.ravenSDKTrigger("u_login_error",e.__assign({action_name:"otp_incorrect",login_form:null==n?void 0:n.loginForm,login_type:"native",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},p));var r=null==i?void 0:i.message;"OTP_VALIDATE_LIMIT_EXCEEDED"!==r&&L(""),O.current[0].focus(),O.current[0].click();var t=l.LOGIN_CONSTANTS[r],a="string"==typeof t?t:l.LOGIN_CONSTANTS.INVALID_OTP;K(a)}),[O]),ee=n.useCallback((function(i,n){return e.__awaiter(void 0,void 0,void 0,(function(){var r,t,o,c,_;return e.__generator(this,(function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),r=s.getRavenEventProps(),s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"otp_entered",login_form:null==r?void 0:r.loginForm,login_type:"native",entry_type:n?"autodetected":"manual_entry",vertical:null==r?void 0:r.vertical,page_name:null==r?void 0:r.pageName},p)),i===Z.current&&V.current&&V.current-Date.now()<=100?[2]:(Z.current=i,V.current=Date.now(),[4,s.validateOtp(a,i)]);case 1:return t=u.sent(),o=t.status,c=t.action,200!==Number(o)||s.isEmpty(c)?b(H):(q(!0),K(""),s.updateNativeOnLogin(),"SIGNUP"===c?(f||(window.location.href=l.NAVIGATION_ROUTES.PERSONAL_DETAILS+"?onboardingFlow=true"),S(H,!0)):S(H)),[3,3];case 2:return _=u.sent(),b(H),$(_),[3,3];case 3:return[2]}}))}))}),[Z,V,q,w,K,$]),ie=function(){return e.__awaiter(void 0,void 0,void 0,(function(){var i,n,r,t,a;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,navigator.clipboard.readText()];case 1:return(i=e.sent())&&s.isNumeric(i)&&(n=i.slice(0,l.LOGIN_CONSTANTS.OTP_LENGTH).split(""),null===(t=O.current[l.LOGIN_CONSTANTS.OTP_LENGTH-1])||void 0===t||t.focus(),null===(a=O.current[l.LOGIN_CONSTANTS.OTP_LENGTH-1])||void 0===a||a.click(),r=n.join(""),L(r),r.length===l.LOGIN_CONSTANTS.OTP_LENGTH&&ee(r,!1)),[2]}}))}))},ne=n.useCallback((function(e,i){var n,r;x(""),""!==e.target.value&&i<O.current.length-1&&(null===(n=O.current[i+1])||void 0===n||n.focus(),null===(r=O.current[i+1])||void 0===r||r.click());var t=O.current.map((function(e){return s.isHTMLInputElement(e)?e.value:""})).join("").slice(0,4);L(t),t.length===l.LOGIN_CONSTANTS.OTP_LENGTH&&ee(t,!1)}),[L,ee]),re=n.useCallback((function(e,i){var n,r,t;"Backspace"===e.key&&i>0&&""===(null===(n=O.current[i])||void 0===n?void 0:n.value)&&(e.preventDefault(),null===(r=O.current[i-1])||void 0===r||r.focus(),null===(t=O.current[i-1])||void 0===t||t.click())}),[O]),te=n.useCallback((function(){j(l.LOGIN_CONSTANTS.OTP_COUNTDOWN),R(!0),N(a);var i=s.getRavenEventProps();s.ravenSDKTrigger("u_login_error",e.__assign({action_name:"resend_otp_clicked",login_form:null==i?void 0:i.loginForm,login_type:"native",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},p))}),[j,R]),ae=n.useCallback((function(){A(!0),C(!0),h("")}),[C]);return i.jsxs("div",e.__assign({className:"flex flex-column bg-neutral-100",style:{height:m}},{children:[o&&i.jsx(d.AlertCallout,{variant:"error",textNode:o,prefixIconNode:i.jsx(g.InfoIcon,{fill:"red"}),style:{color:"#ffff",backgroundColor:"#db201e"},className:"fs-12"}),i.jsxs("div",e.__assign({className:"flex flex-bottom"},{children:[i.jsxs(u.Typography,e.__assign({variant:"HM1",color:"heading"},{children:[l.LOGIN_CONSTANTS.OTP_TEXT," ",i.jsx("br",{}),a]})),i.jsx("div",e.__assign({className:"pl-2",onClick:ae},{children:i.jsx(g.Edit,{})}))]})),i.jsxs("div",e.__assign({className:E.otp_container},{children:[i.jsx("div",e.__assign({className:"flex"},{children:e.__spreadArray([],Array(l.LOGIN_CONSTANTS.OTP_LENGTH),!0).map((function(n,r){return i.jsx("div",e.__assign({className:E.otp_box_wrapper},{children:i.jsx(c.FieldV2,{prompt:{hasError:!!X},type:"number",placeholder:"",value:k[r],max:1,inputMode:"numeric",className:E.login_otp_input,variant:"md",ref:function(e){e&&(O.current[r]=e)},onKeyDown:function(e){return re(e,r)},onChange:function(e){return ne(e,r)},onPaste:ie,autoFocus:0===r})}),r)}))})),!!X&&i.jsx(u.Typography,e.__assign({variant:"P1",color:"warning",className:E.login_otp_error},{children:X}))]})),i.jsx(t.Spacer,{className:"pt-2"}),y===T.DETECTING&&!U&&J&&P>l.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN&&i.jsxs("div",e.__assign({className:"flex flex-middle"},{children:[i.jsx(_.Spinner,{width:"20px",height:"20px",borderColor:"#11a670",className:"bg-neutral-900 bc-black"}),i.jsx(u.Typography,e.__assign({variant:"B3",className:"fs-12 fw-500 ml-1 c-neutral-700"},{children:l.LOGIN_CONSTANTS.AUTO_DETECTING_TEXT}))]})),y===T.DETECTING&&P<=l.LOGIN_CONSTANTS.RESEND_OTP_COUNTDOWN&&J&&!U&&i.jsx(i.Fragment,{children:i.jsxs("div",e.__assign({className:"flex"},{children:[i.jsx(u.Typography,e.__assign({variant:"B3",className:"fs-12 fw-500 c-neutral-700 "},{children:l.LOGIN_CONSTANTS.OTP_RESEND_TEXT})),i.jsx(t.Spacer,{className:"ml-1"}),v?i.jsx(u.Typography,e.__assign({className:"color-neutral-200 fw-500",variant:"B3"},{children:l.LOGIN_CONSTANTS.RESEND_CTA})):i.jsxs(i.Fragment,{children:[0===P&&i.jsx(i.Fragment,{children:i.jsx(u.Typography,e.__assign({isClickable:!0,variant:"B3",onClick:te,color:"link",className:"\n fs-12 fw-500 c-pointer"},{children:l.LOGIN_CONSTANTS.RESEND_CTA}))}),P>0&&i.jsx(u.Typography,e.__assign({color:"disabled",variant:"B3"},{children:" Resend ("+P+"s)"}))]})]}))}),!X&&U&&i.jsx(i.Fragment,{children:i.jsxs("div",e.__assign({className:"flex flex-middle"},{children:[i.jsx(g.CheckCircle,{}),i.jsx(u.Typography,e.__assign({variant:"P1",color:"success",className:"fs-12"},{children:y===T.DETECTED?l.LOGIN_CONSTANTS.AUTO_DETECTED_TEXT:l.LOGIN_CONSTANTS.VERIFIED_MESSAGE}))]}))}),i.jsx(t.Spacer,{className:"mt-24"})]}))},S={loader:"index-module_loader__63LeU","With-full-opacity":"index-module_With-full-opacity__ZSY-U",loader__content:"index-module_loader__content__Q6kJl",loader__spinner:"index-module_loader__spinner__6B3AR","loader-rotate":"index-module_loader-rotate__efcf3",loader__heading:"index-module_loader__heading__7YZ3N",loader__text:"index-module_loader__text__1QcLi"};h(".index-module_loader__63LeU{align-items:center;background-color:hsla(0,0%,100%,.95);bottom:0;display:flex;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:0}.index-module_loader__63LeU.index-module_With-full-opacity__ZSY-U{background-color:#fff}.index-module_loader__content__Q6kJl{max-width:280px;text-align:center}.index-module_loader__spinner__6B3AR{animation:index-module_loader-rotate__efcf3 .8s linear infinite;border:2px solid rgba(51,102,204,.3);border-radius:50%;border-top-color:#36c;display:inline-block;height:30px;margin-bottom:10px;position:relative;width:30px}.index-module_loader__heading__7YZ3N{color:#000;font-size:18px;font-weight:600;margin-bottom:5px}.index-module_loader__text__1QcLi{color:rgba(0,0,0,.8);font-size:16px;line-height:1.5}");var b=function(n){var r=n.title,t=n.message,a=n.className;return i.jsx("div",e.__assign({className:"".concat(S.utilswrapper," utilswrapper")},{children:i.jsx("div",e.__assign({className:x.default(S.loader,a)},{children:i.jsxs("div",e.__assign({className:S.loader__content},{children:[i.jsx("div",{className:S.loader__spinner}),i.jsx("h5",e.__assign({className:S.loader__heading},{children:r})),i.jsx("p",e.__assign({className:S.loader__text},{children:t}))]}))}))}))},O=function(r){var t=r.sendingOtp,a=r.ctaDisabled,o=r.getOTP,_=r.setErrorCallout,p=r.errorCallout,N=r.mobileNumber,A=r.setMobileInputHeight,x=r.setMobileNumber,h=r.fallbackUri,T=r.skipProfileFlow,C=r.currentPageUri,S=r.ravenPayload,b=n.useState(s.isFKSSOEnabled)[0],O=n.useState(!1),I=O[0],y=O[1],w=n.useRef(null),D=n.useRef(null);n.useEffect((function(){if(D.current){var e=D.current.clientHeight;A(e)}}),[D.current]),n.useEffect((function(){var e;return w.current&&(e=setTimeout((function(){var e;null===(e=w.current)||void 0===e||e.focus()}),100)),function(){clearTimeout(e)}}),[]),n.useEffect((function(){s.isAndroidApp()&&G()}),[]);var P=n.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var i,n;return e.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),i=s.getRavenEventProps(),s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"login_with_flipkart_clicked",login_form:null==i?void 0:i.loginForm,login_type:"fk_sso",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},S)),y(!0),[4,s.handleFKSSO(h,T?C:l.NAVIGATION_ROUTES.PERSONAL_DETAILS+"?onboardingFlow=true",C)];case 1:return n=r.sent(),window.location.href=n,[3,3];case 2:return r.sent(),y(!1),[3,3];case 3:return[2]}}))}))}),[]),j=n.useCallback((function(i,n){void 0===n&&(n=!1),_("");var r=i.target.value||"";if(r=r.replace(s.MULTI_SPACE," ").trimStart(),x(r),s.isValidMobileNumber(i.target.value)){o(r);var t=s.getRavenEventProps();s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"get_otp_clicked",login_form:null==t?void 0:t.loginForm,login_type:"native",entry_type:"auto_click",vertical:null==t?void 0:t.vertical,page_name:null==t?void 0:t.pageName},S)),n?s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"phone_number_autodetected",login_form:null==t?void 0:t.loginForm,login_type:"native",entry_type:"autodetected",vertical:null==t?void 0:t.vertical,page_name:null==t?void 0:t.pageName},S)):s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"phone_number_entered",login_form:null==t?void 0:t.loginForm,login_type:"native",entry_type:"manual_entry",vertical:null==t?void 0:t.vertical,page_name:null==t?void 0:t.pageName},S))}}),[x]),G=n.useCallback((function(){return e.__awaiter(void 0,void 0,void 0,(function(){var i,n;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,s.showMobileNumberHint()];case 1:return i=e.sent(),n={target:{value:i}},i&&j(n,!0),[2]}}))}))}),[j]),k=n.useCallback((function(){var i=s.getRavenEventProps();s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"policy_click",login_form:null==i?void 0:i.loginForm,login_type:"native",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},S)),window.location.href=l.NAVIGATION_ROUTES.PRIVACY_POLICY}),[]),L=n.useCallback((function(){var i=s.getRavenEventProps();s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"tnc_click",login_form:null==i?void 0:i.loginForm,login_type:"native",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},S)),window.location.href=l.NAVIGATION_ROUTES.TERMS}),[]);return i.jsxs("div",e.__assign({className:"flex flex-column",ref:D},{children:[p&&i.jsx(d.AlertCallout,{variant:"error",textNode:p,prefixIconNode:i.jsx(g.InfoIcon,{fill:"red"}),style:{color:"#ffff",backgroundColor:"#db201e"},className:"fs-12"}),i.jsx(u.Typography,e.__assign({variant:"HM1",color:"heading",className:"mb-4 fs-24"},{children:l.LOGIN_CONSTANTS.LOGIN_TO_CT})),i.jsx(c.PhoneField,{onChange:j,value:N,placeholder:"",inputMode:"numeric",ref:w,min:0,max:10,autoFocus:!0,countryCode:l.LOGIN_CONSTANTS.COUNTRY_CODE}),i.jsx(m.Button,e.__assign({color:"primary",size:"medium",minWidth:"160px",disabled:a,loading:t,className:"my-6",onClick:function(){return o(N)}},{children:l.LOGIN_CONSTANTS.GET_OTP})),b&&i.jsxs(i.Fragment,{children:[i.jsxs("div",e.__assign({className:"my-6 p-relative"},{children:[i.jsx(f.Divider,{}),i.jsx("span",e.__assign({className:"".concat(E.mobileinput_seperatortext)},{children:"or"}))]})),i.jsx(m.Button,e.__assign({variant:"outline",size:"medium",className:"my-6",loading:I,onClick:P,showLeftIcon:!I,LeftIcon:i.jsx("img",{src:v.FlipkartLogo})},{children:l.LOGIN_CONSTANTS.FK_LOGIN_CTA}))]}),i.jsxs("div",e.__assign({className:"pt-8 pb-6"},{children:[i.jsx(f.Divider,{}),i.jsxs("div",e.__assign({className:"flex flex-middle \n flex-center flex-wrap pt-2"},{children:[i.jsx(u.Typography,e.__assign({variant:"P1",className:E.footer_text},{children:l.LOGIN_CONSTANTS.FOOTER_TEXT})),i.jsx(u.Typography,e.__assign({variant:"P1",color:"link",className:"pl-1 fs-12",isClickable:!0,onClick:k},{children:l.LOGIN_CONSTANTS.PRIVACY_CTA})),i.jsx(u.Typography,e.__assign({className:"px-1 fs-12 c-neutral-700",variant:"P1"},{children:"& "})),i.jsx(u.Typography,e.__assign({variant:"P1",color:"link",isClickable:!0,onClick:L,className:"fs-12"},{children:l.LOGIN_CONSTANTS.TNC_CTA}))]}))]}))]}))};const I="data:image/png;base64,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",y=[{src:"https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel1.png",placeholder:I},{src:"https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel2.png",placeholder:I},{src:"https://fastui.cltpstatic.com/image/upload/offermgmt/images/carousel3.png",placeholder:I}];var w=function(r){var t=r.src,a=r.placeholderSrc,o=r.onLoad,l=e.__rest(r,["src","placeholderSrc","onLoad"]),s=n.useState(a||t),c=s[0],_=s[1],u=n.useRef(o);return n.useEffect((function(){u.current=o}),[o]),n.useEffect((function(){var e=new Image;e.onload=function(){_(t),u.current&&u.current()},e.src=t}),[t]),i.jsx("img",e.__assign({src:c},l))},D=function(){return i.jsx("div",e.__assign({className:" o-hidden p-relative ".concat(E.slider_carousel_wrapper)},{children:i.jsx(N.Swiper,e.__assign({autoplay:!0,slidesPerView:1,navigation:!1,loop:!0,pagination:{clickable:!0},className:"".concat(E.swiper," ").concat(E["swiper-custom-pagination"]),lazy:{loadPrevNextAmount:1}},{children:y.map((function(n,r){return i.jsx(N.SwiperSlide,e.__assign({className:E["swiper-slide"]},{children:i.jsx(i.Fragment,{children:r<1?i.jsx(w,{src:n.src,placeholderSrc:n.placeholder,alt:"Slide ".concat(r+1),rel:"preload",fetchPriority:"high"}):i.jsx(w,{src:n.src,placeholderSrc:n.placeholder,alt:"Slide ".concat(r+1),loading:"lazy",className:"lazy"})})}),r)}))}))}))};exports.LoginModule=function(c){var _=c.fallbackUri,u=c.isDrawerOpen,d=c.skipProfileFlow,g=c.showCarousel,p=void 0===g||g,m=c.ravenPayload,f=void 0===m?{}:m,v=c.handleLoginClose,N=c.onAuthSuccess,A=c.onAuthFailure,x=n.useState(!0),h=x[0],T=x[1],S=n.useState(!0),I=S[0],y=S[1],w=n.useState(!1),P=w[0],j=w[1],G=n.useState(u),k=G[0],L=G[1],B=n.useState(""),Q=B[0],R=B[1],F=n.useState(0),U=F[0],q=F[1],z=n.useState(!1),X=z[0],K=z[1],M=n.useState(""),J=M[0],W=M[1],Z=n.useState(!1),V=Z[0],H=Z[1],Y=n.useState(!1),$=Y[0],ee=Y[1],ie=n.useState((function(){return s.getCurrentPathName()}))[0],ne=function(){ee(!0)};n.useEffect((function(){window&&(window.showSigninLoaderScreen=ne);var e=s.getQueryParam("fkSSOstatus"),i="FK";"signin"===e&&(s.isAndroidApp()&&s.updateNativeAndroidOnSignIn(),te(i)),"signup"===e&&(s.isAndroidApp()&&s.updateNativeAndroidOnSignIn(),te(i,!0)),"failure"===e&&ae(i)}),[]);var re=n.useCallback((function(i){return e.__awaiter(void 0,void 0,void 0,(function(){var n,r,t,a;return e.__generator(this,(function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),y(!1),j(!0),s.triggerOTPListener(),[4,s.sendLoginOtp(i)];case 1:return n=e.sent(),"SUCCESS"===(n||{}).status&&(T(!1),j(!1)),[3,3];case 2:return r=e.sent(),console.error(r),t=(r||{}).message,j(!1),a=t&&l.LOGIN_CONSTANTS[t],W(String(a||l.LOGIN_CONSTANTS.GENERIC_ERROR_MESSAGE)),"OTP_SEND_LIMIT_EXCEEDED"===t&&K(!0),[3,3];case 3:return[2]}}))}))}),[h,T]),te=n.useCallback((function(i,n){var r=s.getRavenEventProps();s.ravenSDKTrigger("u_login_success",e.__assign({action_name:"login_successful",login_form:null==r?void 0:r.loginForm,login_type:"native",login_new:n?"sign_up":"sign_in",vertical:null==r?void 0:r.vertical,page_name:null==r?void 0:r.pageName},f)),N(i,n),n&&!d||(oe(),H(!0))}),[]),ae=n.useCallback((function(e){A(e)}),[]),oe=function(i){null==i||i.stopPropagation(),L(!1),R(""),y(!0);var n=s.getRavenEventProps();s.ravenSDKTrigger("u_login_click",e.__assign({action_name:"login_prompt_dismissed",login_form:null==n?void 0:n.loginForm,login_type:"native",vertical:null==n?void 0:n.vertical,page_name:null==n?void 0:n.pageName},f)),v&&"function"==typeof v&&v()};return n.useEffect((function(){if(u){T(!0),L(!0);var i=s.getRavenEventProps();s.ravenSDKTrigger("u_login_popup",e.__assign({action_name:"login_prompt_opened",login_form:null==i?void 0:i.loginForm,login_type:"native",vertical:null==i?void 0:i.vertical,page_name:null==i?void 0:i.pageName},f))}else L(!1)}),[u]),i.jsx(o.ThemeProvider,{children:i.jsxs(i.Fragment,{children:[i.jsx(a.Drawer,e.__assign({direction:"bottom",isOpen:k,showClose:!0,overlay:!0,handleClose:oe,onClose:function(){}},{children:i.jsx("div",e.__assign({className:"".concat(E.utilswrapper," utilswrapper")},{children:i.jsxs("div",e.__assign({style:{maxHeight:"calc(100dvh - 60px)",overflowY:"auto",borderRadius:"16px 16px 0 0"}},{children:[p&&i.jsx(D,{}),i.jsxs("div",e.__assign({className:E.login_form},{children:[i.jsx("div",{children:i.jsx(t.Spacer,{className:"pt-6"})}),h?i.jsx(O,{device:"PWA",ctaDisabled:I,sendingOtp:P,getOTP:re,mobileNumber:Q,setMobileNumber:R,setMobileInputHeight:q,fallbackUri:_,skipProfileFlow:d,currentPageUri:ie,setErrorCallout:W,errorCallout:J,ravenPayload:f}):i.jsx(C,{mobileNumber:Q,getOTP:re,setCtaDisabled:y,setShowMobilePage:T,handleLoginSuccess:te,handleLoginFailure:ae,otpInputHeight:U,setMobileNumber:R,setErrorCallout:W,errorCallout:J,otpResendDisabled:X,ravenPayload:f,skipProfileFlow:d})]}))]}))}))})),V&&i.jsx(r.Toast,{text:"Logged in successfully!",show:V,className:"".concat(E.nonUtilsSelector_toast),closeTimeout:2e3}),$&&i.jsx(b,{title:"Please wait",message:"Signing in...",className:"z-2 bg-white"})]})})};
565
2
  //# sourceMappingURL=ct-platform-login-module.cjs.js.map