/* Metro module 3848; source: modules/links/native/handleURL.tsx; dependencies: [5, 27, 3849, 661, 3, 3850, 3852, 3853, 3854, 3855, 3856, 1244, 4078, 477, 4080, 1473, 4093, 4254, 2] */ function _fun31724(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#31724, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:6, offset: 0x01001fe6, size: 254 bytes, params: 8, frame: 19 const env0_0 = require; const _arrayLikeToArray_31727 = function(a0, a1) { var r0; var r1; var r2; var value3; var length; var value5; var value = undefined; var value2 = value == null; reducibleJoin2: while (true) { if (value2) { r0 = value2; break reducibleJoin2; } value3 = value > a0.length; r0 = value3; break reducibleJoin2; } reducibleJoin4: while (true) { if (r0) { length = a0.length; r1 = length; break reducibleJoin4; } r1 = value; break reducibleJoin4; } value = (0, global.Array)(r1); var value4 = 0; if (value4 < r1) { r2 = value4; reducibleLoop5: while (true) { value[r2] = a0[r2]; value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1; if (value5 < r1) { r2 = value5; continue reducibleLoop5; } break reducibleLoop5; } } return value; }; const sanitizeURLPart = function(a0) { var r0; var value = a0; if (value == null) { r0 = value; } else { value = value.replace(RegExp('[^\\x00-\\x7F]+', 'g'), _fun31729); r0 = value; } return r0; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(5) /* metro dependency 5 */; const env0_4 = (require(27) /* metro dependency 27 */).Linking; const actionSheetStore = importDefault(3849) /* metro dependency 3849: ActionSheetStore */; const env0_6 = (require(661) /* metro dependency 661: Constants */).WebBrowserType; let value = importDefault(3) /* metro dependency 3: Logger */; value = new value('handleURL'); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/links/native/handleURL.tsx'); exports.default = function(a0, a1) { return _handleURL.apply(this, arguments); }; } function _createForOfIteratorHelperLoose_31725(a0, a1) { // fn#31725, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:165, offset: 0x010020e4, size: 370 bytes, params: 3, frame: 20 var r6; var r9; var r5; var value3; var regexp; const env0_0 = a0; const Symbol = global.Symbol; let value = typeof Symbol !== 'undefined'; let r1 = value && a0[global.Symbol.iterator]; r1 = !r1 ? a0['@@iterator'] : r1; if (r1) { value = r1.call(a0); return value.next.bind(value); } const Array = global.Array; if (Array.isArray(a0)) { if (r1) { } return _fun31726; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_31727(a0, value); r5 = value; } else { value3 = ({}).toString.call(a0).slice(8, -1); r6 = value3 === 'Object' && a0.constructor; r9 = r6 ? a0.constructor.name : value3; if (r9 === 'Map') { r6 = global.Array.from(a0); } else if (r9 === 'Set') { r6 = global.Array.from(a0); } else if (r9 === 'Arguments') { value = _arrayLikeToArray_31727(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_31727(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun31726; } const TypeError = global.TypeError; throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'); } function sanitizeURLPart(a0) { // fn#31728, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:1107, offset: 0x01002256, size: 46 bytes, params: 2, frame: 14 const value = a0; return value == null ? value : value.replace(RegExp('[^\\x00-\\x7F]+', 'g'), function(a0) { return (0, global.encodeURIComponent)(a0); }); } function _handleURL() { // fn#31730, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:1207, offset: 0x01002284, size: 48 bytes, params: 1, frame: 14 return env0_3(_fun31732).apply(this, arguments); } async function _fun31732(a0, a1) { // fn#31732, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:1250, offset: 0x010022c6, size: 471 bytes, params: 3, frame: 22 var environment; var r1; var r7; var binding; var binding2; var property; var value9; var value10; var binding3; var pathname; var search; var hash; var binding4; var payload; var error; let value = a0; let value2 = a2; if (true) { var env0_0; var env0_1 = a1; r1 = value2 !== undefined ? value2 : {}; var allowExternal = r1.allowExternal; allowExternal = allowExternal === undefined || allowExternal; var forceExternalBrowser = r1.forceExternalBrowser; forceExternalBrowser = !(forceExternalBrowser === undefined) && forceExternalBrowser; await undefined; if (false) { return undefined; } var closure = openInBrowser; if (forceExternalBrowser) { closure(); } else { var regexp = RegExp('^[a-zA-Z0-9+-.]+:', ''); var test = regexp.test; if (Reflect.apply(test, regexp, [value])) { r7 = value; } else { value = 'https://' + value; r7 = value; } regexp = RegExp('^https?:', 'i'); test = regexp.test; if (Reflect.apply(test, regexp, [r7])) { try { value = environment.__proto__.__proto__; binding = env2_1; binding2 = env2_2; property = binding2[15]; value9 = binding(property); value10 = value9.parse(r7); binding3 = env2_10; pathname = value10.pathname; value = binding3(pathname); value10.pathname = value; search = value10.search; value = binding3(search); value10.search = value; hash = value10.hash; value = binding3(hash); value10.hash = value; property = binding2[15]; value = binding(property); value = value.format(value10); env0_0 = value; r7 = value; } catch (error) { return undefined; } value = environment.__proto__.__proto__; binding = env2_1; binding4 = env2_2; payload = binding(binding4[16])(r7).payload; value = binding(binding4[17]); if (value({payload: payload, safe: true})) { return undefined; } if (allowExternal) { await ((a0) => { var env0_0 = a0; var Promise = global.Promise; var value = Object.create(Promise.prototype, {constructor: {value: Promise}}); var value2 = new Promise(_fun31737); return value2 instanceof Object ? value2 : value; })(r7); value = undefined; if (false) { return value; } if (value) { return undefined; } await tryHandleCustomScheme(r7); value = undefined; if (false) { return value; } if (value) { return undefined; } await tryHandleWhitelistedURL(r7); value = undefined; if (false) { return value; } if (!value) { closure(); } return undefined; } return undefined; } value = environment.__proto__.__proto__; binding = env2_1; binding4 = env2_2; payload = binding(binding4[16])(r7).payload; value = binding(binding4[17]); if (value({payload: payload, safe: true})) { return undefined; } if (allowExternal) { await ((a0) => { var env0_0 = a0; var Promise = global.Promise; var value = Object.create(Promise.prototype, {constructor: {value: Promise}}); var value2 = new Promise(_fun31737); return value2 instanceof Object ? value2 : value; })(r7); value = undefined; if (false) { return value; } if (value) { return undefined; } await tryHandleCustomScheme(r7); value = undefined; if (false) { return value; } if (value) { return undefined; } await tryHandleWhitelistedURL(r7); value = undefined; if (false) { return value; } if (!value) { closure(); } return undefined; } } } } function openInBrowser() { // fn#31733, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:1333, offset: 0x0100249d, size: 631 bytes, params: 1, frame: 21 var environment; var r7; var r3; var r4; var binding2; var presentFailedToast; var intl; var SAFARI; var browserManagerSelectedBrowser; var isIOS2; var value9; var browserManagerOpenUrl; var value10; var binding3; var value11; let value = environment.__proto__.__proto__.__proto__; let binding = env3_1; if (binding(env3_2[9]).sanitizeUrl(env0_0) != null) { SAFARI = env3_6.SAFARI; binding = env0_0; if (binding.startsWith('https:')) { binding = env3_0; browserManagerSelectedBrowser = binding(env3_2[12]).getBrowserManagerSelectedBrowser(); r7 = require ?? browserManagerSelectedBrowser; if (forceExternalBrowser && r7 === env3_6.IN_APP) { if (browserManagerSelectedBrowser !== env3_6.IN_APP) { r3 = browserManagerSelectedBrowser; } else { binding = env3_0; isIOS2 = binding(env3_2[13]).isIOS(); binding = env3_6; r3 = isIOS2 ? binding.SAFARI : binding.CHROME; } r4 = r3; } else { r4 = r7; } } else { binding = env0_0; if (binding.startsWith('http:')) { binding = env3_0; browserManagerSelectedBrowser = binding(env3_2[12]).getBrowserManagerSelectedBrowser(); r7 = require ?? browserManagerSelectedBrowser; if (forceExternalBrowser && r7 === env3_6.IN_APP) { if (browserManagerSelectedBrowser !== env3_6.IN_APP) { r3 = browserManagerSelectedBrowser; } else { binding = env3_0; isIOS2 = binding(env3_2[13]).isIOS(); binding = env3_6; r3 = isIOS2 ? binding.SAFARI : binding.CHROME; } r4 = r3; } else { r4 = r7; } } else { r4 = SAFARI; } } if (env3_6.IN_APP === r4) { binding = env3_0; binding3 = env3_2; value11 = binding(binding3[12]); value11.browserManagerOpenUrl(env0_0, env3_6.IN_APP).catch(_fun31734); if (binding(binding3[13]).isIOS() && env3_5.isOpen()) { env3_1(env3_2[14]).hideAllActionSheets(); } } else if (env3_6.CHROME === r4) { binding = env3_0; value10 = binding(env3_2[12]); browserManagerOpenUrl = value10.browserManagerOpenUrl; binding = env0_0; Reflect.apply(browserManagerOpenUrl, value10, [binding, env3_6.CHROME]).catch(_fun31735); } else { env3_6.SAFARI; binding = env3_0; value9 = binding(env3_2[12]); browserManagerOpenUrl = value9.browserManagerOpenUrl; binding = env0_0; Reflect.apply(browserManagerOpenUrl, value9, [binding, env3_6.SAFARI]); } } else { binding = env3_0; binding2 = env3_2; value = binding(binding2[10]); presentFailedToast = value.presentFailedToast; intl = binding(binding2[11]).intl; Reflect.apply(presentFailedToast, value, [intl.string(binding(binding2[11]).t.XiqzAp)]); } } function tryHandleUniversalLink(a0) { // fn#31736, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:2453, offset: 0x0100278e, size: 44 bytes, params: 2, frame: 11 const env0_0 = a0; const Promise = global.Promise; const value = Object.create(Promise.prototype, {constructor: {value: Promise}}); const promise = new Promise(_fun31737); return promise instanceof Object ? promise : value; } function tryHandleCustomScheme(a0) { // fn#31740, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:2709, offset: 0x01002863, size: 305 bytes, params: 2, frame: 23 var r5; var r6; var r2; var r10; var r4; var promise; var regex; var protocol; var property; let value = a0; var env0_0; const binding = env3_8; const binding2 = env3_0; const value3 = undefined; const LINKING_SCHEMAS_VALUES = binding2(env3_2[6]).LINKING_SCHEMAS_VALUES; const value4 = binding(LINKING_SCHEMAS_VALUES); const value5 = value4(); let done = value5.done; const value6 = null; if (done) { r4 = value; } else { r5 = value5; r6 = value; while (true) { value = r5.value; regex = value.regex; protocol = value.protocol; value = regex.exec(r6); if (value6 == value) { r2 = value3; } else { property = value[1]; r2 = property; } if (value6 == r2) { r10 = r6; continue; } value = protocol + r2; env0_0 = value; r10 = value; value = value4(); done = value.done; if (done) { r4 = r10; break; } r5 = value; r6 = r10; continue; } } const r3 = r4.indexOf('://') === -1 ? value6 : r4.split('://')[0]; if (r3 === 'http') { promise = new global.Promise(_fun31741); } else if (r3 === 'https') { promise = new global.Promise(_fun31741); } else { env3_7.info('tryHandleCustomScheme', r4); promise = new global.Promise(_fun31742); } return promise; } function tryHandleWhitelistedURL(a0) { // fn#31745, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3301, offset: 0x01002a63, size: 163 bytes, params: 2, frame: 17 var environment; var r3; var value3; var regex; var protocol; var value4; var value5; var Promise; var promise; const env0_0 = a0; const closure = tryHandleWhitelistedURL_loop; let value = environment.__proto__.__proto__.__proto__; const binding = env3_8; const LINKING_WHITELIST_VALUES = env3_0(env3_2[8]).LINKING_WHITELIST_VALUES; const value2 = binding(LINKING_WHITELIST_VALUES)(); let done = value2.done; if (!done) { r3 = value2; reducibleLoop1: while (true) { value3 = r3.value; regex = value3.regex; var env0_1 = regex; protocol = value3.protocol; value4 = closure(protocol); if (value4 !== 0) { reducibleJoin3: while (true) { if (value4) { return value4.v; } break reducibleJoin3; } } value5 = value(); done = value5.done; if (done) { Promise = global.Promise; value = Object.create(Promise.prototype, {constructor: {value: Promise}}); promise = new Promise(_fun31750); return promise instanceof Object ? promise : value; } r3 = value5; continue reducibleLoop1; } } Promise = global.Promise; value = Object.create(Promise.prototype, {constructor: {value: Promise}}); promise = new Promise(_fun31750); return promise instanceof Object ? promise : value; } function _fun31734() { // fn#31734, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:1648, offset: 0x01002714, size: 122 bytes, params: 1, frame: 18 let value = environment.__proto__.__proto__.__proto__.__proto__; const binding = env4_0; const binding2 = env4_2; value = binding(binding2[10]); const presentFailedToast = value.presentFailedToast; const intl = binding(binding2[11]).intl; const string = intl.string; const HryVrx = binding(binding2[11]).t.HryVrx; Reflect.apply(presentFailedToast, value, ['' + Reflect.apply(string, intl, [HryVrx]) + ' ' + env1_0]); } function _fun31737(a0) { // fn#31737, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:2508, offset: 0x010027ba, size: 85 bytes, params: 2, frame: 13 var environment; const env0_0 = a0; let value = environment.__proto__.__proto__.__proto__.__proto__; value = env4_1(env4_2[5]); value = value.tryOpenUrlAsUniversalLink(env0_0); value = value.then(_fun31738); value.catch(_fun31739); } function _fun31741(a0) { // fn#31741, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3020, offset: 0x01002994, size: 38 bytes, params: 2, frame: 11 env4_7.info('URL is not a custom scheme.'); a0(false); } function _fun31742(a0) { // fn#31742, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3119, offset: 0x010029ba, size: 85 bytes, params: 2, frame: 13 var environment; const env0_0 = a0; let value = environment.__proto__.__proto__.__proto__.__proto__; value = env4_1(env4_2[5]); value = value.tryOpenScheme(env0_0); value = value.then(_fun31743); value.catch(_fun31744); } function tryHandleWhitelistedURL_loop(a0) { // fn#31746, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3355, owner: tryHandleWhitelistedURL._loop, offset: 0x01002b06, size: 83 bytes, params: 2, frame: 13 return regex.exec(a0) === null ? 0 : {v: new global.Promise(_fun31747)}; } function _fun31750(a0) { // fn#31750, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3823, offset: 0x01002c3c, size: 38 bytes, params: 2, frame: 11 env4_7.info('URL is not whitelisted.'); a0(false); } function _fun31738() { // fn#31738, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:2555, offset: 0x0100280f, size: 42 bytes, params: 1, frame: 11 env5_7.info('Universal link opened successfully.'); env0_0(true); } function _fun31739() { // fn#31739, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:2622, offset: 0x01002839, size: 42 bytes, params: 1, frame: 11 env5_7.info('URL is not a handled universal link.'); env0_0(false); } function _fun31743() { // fn#31743, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3154, offset: 0x01002a0f, size: 42 bytes, params: 1, frame: 11 env5_7.info('Custom scheme opened successfully.'); env0_0(true); } function _fun31744() { // fn#31744, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3220, offset: 0x01002a39, size: 42 bytes, params: 1, frame: 11 env5_7.info('Custom scheme failed to open.'); env0_0(false); } function _fun31747(a0) { // fn#31747, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3409, offset: 0x01002b59, size: 69 bytes, params: 2, frame: 12 var environment; const env0_0 = a0; let value = environment.__proto__.__proto__.__proto__.__proto__.__proto__; value = env5_4.canOpenURL(env0_0); value = value.then(_fun31748); value.catch(_fun31749); } function _fun31748(a0) { // fn#31748, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3435, offset: 0x01002b9e, size: 106 bytes, params: 2, frame: 12 var performURLNavigation; var value2; let value = environment.__proto__.__proto__.__proto__.__proto__.__proto__.__proto__; if (a0) { value = env6_1(env6_2[7]); performURLNavigation = value.performURLNavigation; value2 = environment.__proto__.__proto__; Reflect.apply(performURLNavigation, value, [env2_0]); env0_0(true); } else { env6_7.info('Whitelisted URL, but cannot be opened (app likely not installed).'); env0_0(false); } } function _fun31749(a0) { // fn#31749, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:3987:3575, offset: 0x01002c08, size: 52 bytes, params: 2, frame: 13 env6_7.info('Whitelisted URL encountered an error.', {error: a0}); env0_0(false); }