Files
discord-decomp/sources/by-id/module-00306.js
T
2026-07-28 01:06:53 +03:00

217 lines
11 KiB
JavaScript

/* Metro module 306; source: unknown; dependencies: [6, 7, 44, 304] */
import ClassCallCheck from './module-00006-ClassCallCheck.js'; /* Metro dependency 6 */
import CreateClass from './module-00007-CreateClass.js'; /* Metro dependency 7 */
function _fun4712(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#4712, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:6, offset: 0x00ccb234, size: 108 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
exports.default = _fun4713();
function _fun4713() { // fn#4713, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:118, offset: 0x00ccb2a0, size: 377 bytes, params: 1, frame: 15
return CreateClass(ListMetricsAggregator, [{key: 'notifyCellLayout', value: value_4715}, {key: 'notifyCellUnmounted',
value: function(a0) {
var value = this._cellMetrics.get(a0);
if (value) {
value.isMounted = false;
}
}}, {key: 'notifyListContentLayout', value: function({orientation, layout}) {
this._invalidateIfOrientationChanged(orientation);
this._contentLength = this._selectLength(layout);
}}, {key: 'getAverageCellLength', value: function() {
return this._averageCellLength;
}}, {key: 'getHighestMeasuredCellIndex', value: function() {
return this._highestMeasuredCellIndex;
}}, {key: 'getCellMetricsApprox', value: value_4720}, {key: 'getCellMetrics', value: value_4721},
{key: 'getCellOffsetApprox', value: function(a0, a1) {
var property = global.Number;
var value = property.isInteger(a0);
property = this.getCellMetricsApprox;
if (value) {
return Reflect.apply(property, this, [a0, a1]).offset;
}
var Math = global.Math;
value = Reflect.apply(property, this, [Math.floor(a0), a1]);
return value.offset + (a0 - global.Math.floor(a0)) * value.length;
}}, {key: 'getContentLength', value: function() {
return this._contentLength ?? 0;
}}, {key: 'hasContentLength', value: function() {
return this._contentLength != null;
}}, {key: 'flowRelativeOffset', value: value_4725}, {key: 'cartesianOffset', value: value_4726},
{key: '_invalidateIfOrientationChanged', value: function(a0) {
if (a0.rtl !== this._orientation.rtl) {
this._cellMetrics.clear();
}
if (a0.horizontal !== this._orientation.horizontal) {
this._averageCellLength = 0;
this._highestMeasuredCellIndex = 0;
this._measuredCellsLength = 0;
this._measuredCellsCount = 0;
}
this._orientation = a0;
}}, {key: '_selectLength', value: function({width, height}) {
return this._orientation.horizontal ? width : height;
}}, {key: '_selectOffset', value: function({x, y}) {
return this._orientation.horizontal ? x : y;
}}]);
function ListMetricsAggregator() { // fn#4714, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:139, offset: 0x00ccb419, size: 103 bytes, params: 1, frame: 14
const value = environment.__proto__;
env1_3(this, ListMetricsAggregator);
this._averageCellLength = 0;
const Map = global.Map;
this._cellMetrics = new Map();
this._highestMeasuredCellIndex = 0;
this._measuredCellsLength = 0;
this._measuredCellsCount = 0;
this._orientation = {'horizontal': false, 'rtl': false};
}
function value_4720(a0, a1) { // fn#4720, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:1608, offset: 0x00ccb613, size: 230 bytes, params: 3, frame: 19
var r3;
var cellMetrics;
let value = this.getCellMetrics(a0, a1);
if (value) {
if (value.index === a0) {
return value;
}
}
value = this.getHighestMeasuredCellIndex();
const value2 = undefined;
if (value < a0) {
cellMetrics = this.getCellMetrics(value, a1);
r3 = cellMetrics ? cellMetrics.offset + cellMetrics.length + this._averageCellLength * (a0 - value - 1) : value2;
} else {
r3 = value2;
}
r3 = r3 ?? this._averageCellLength * a0;
const data = a1.data;
const getItemCount = a1.getItemCount;
value = environment.__proto__;
(importDefault(44) /* metro dependency 44 */)(a0 >= 0 && a0 < getItemCount(data),
'Tried to get frame for out of range index ' + a0);
return {length: this._averageCellLength, offset: r3, index: a0, isMounted: false};
}
function value_4721(a0, {data, getItem, getItemCount, getItemLayout, keyExtractor}) { // fn#4721, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:2078, offset: 0x00ccb6f9, size: 217 bytes, params: 3, frame: 20
let value = environment.__proto__;
(importDefault(44) /* metro dependency 44 */)(a0 >= 0 && a0 < getItemCount(data),
'Tried to get metrics for out of range cell index ' + a0);
keyExtractor = keyExtractor ?? (require(304) /* metro dependency 304 */).keyExtractor;
value = this._cellMetrics.get(keyExtractor(getItem(data, a0), a0));
if (value) {
if (value.index === a0) {
return value;
}
if (getItemLayout) {
value = getItemLayout(data, a0);
return {index: a0, length: value.length, offset: value.offset, isMounted: true};
}
} else if (getItemLayout) {
value = getItemLayout(data, a0);
return {index: a0, length: value.length, offset: value.offset, isMounted: true};
}
return null;
}
function value_4725(a0, a1) { // fn#4725, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:2920, offset: 0x00ccb870, size: 131 bytes, params: 3, frame: 16
var r1;
let value = a1;
const _orientation = this._orientation;
if (_orientation.horizontal) {
if (_orientation.rtl) {
r1 = value ?? this._contentLength;
value = environment.__proto__;
value = importDefault(44) /* metro dependency 44 */;
value(r1 != null, 'ListMetricsAggregator must be notified of list content layout before resolving offsets');
value = this._selectOffset(a0);
return r1 - (value + this._selectLength(a0));
}
}
return this._selectOffset(a0);
}
function value_4726(a0) { // fn#4726, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:3266, offset: 0x00ccb8f3, size: 97 bytes, params: 2, frame: 16
var r0;
var value2;
var defaultImport;
var _contentLength;
let value = a0;
const _orientation = this._orientation;
if (_orientation.horizontal) {
if (_orientation.rtl) {
value2 = environment.__proto__;
defaultImport = importDefault(44) /* metro dependency 44 */;
_contentLength = this._contentLength;
defaultImport(_contentLength != null,
'ListMetricsAggregator must be notified of list content layout before resolving offsets');
_contentLength = this._contentLength;
value = _contentLength - value;
r0 = value;
} else {
r0 = value;
}
} else {
r0 = value;
}
return r0;
}
}
}
function value_4715({cellIndex, cellKey, orientation, layout}) { // fn#4715, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:347:416, offset: 0x00ccb480, size: 294 bytes, params: 2, frame: 17
var Math;
this._invalidateIfOrientationChanged(orientation);
const object = {index: cellIndex};
object.length = this._selectLength(layout);
object.isMounted = true;
object.offset = this.flowRelativeOffset(layout);
let value = this._cellMetrics.get(cellKey);
if (value) {
if (object.offset !== value.offset) {
if (value) {
value = object.length - value.length;
this._measuredCellsLength = this._measuredCellsLength + value;
} else {
this._measuredCellsLength = this._measuredCellsLength + object.length;
this._measuredCellsCount = this._measuredCellsCount + 1;
}
this._averageCellLength = this._measuredCellsLength / this._measuredCellsCount;
this._cellMetrics.set(cellKey, object);
Math = global.Math;
this._highestMeasuredCellIndex = Math.max(this._highestMeasuredCellIndex, cellIndex);
return true;
}
if (object.length === value.length) {
value.isMounted = true;
return false;
}
if (value) {
value = object.length - value.length;
this._measuredCellsLength = this._measuredCellsLength + value;
} else {
this._measuredCellsLength = this._measuredCellsLength + object.length;
this._measuredCellsCount = this._measuredCellsCount + 1;
}
this._averageCellLength = this._measuredCellsLength / this._measuredCellsCount;
this._cellMetrics.set(cellKey, object);
Math = global.Math;
this._highestMeasuredCellIndex = Math.max(this._highestMeasuredCellIndex, cellIndex);
} else {
if (value) {
value = object.length - value.length;
this._measuredCellsLength = this._measuredCellsLength + value;
} else {
this._measuredCellsLength = this._measuredCellsLength + object.length;
this._measuredCellsCount = this._measuredCellsCount + 1;
}
this._averageCellLength = this._measuredCellsLength / this._measuredCellsCount;
this._cellMetrics.set(cellKey, object);
Math = global.Math;
this._highestMeasuredCellIndex = Math.max(this._highestMeasuredCellIndex, cellIndex);
}
return true;
}
global.__d(_fun4712, 306, [6, 7, 44, 304]) /* metro module 306, dependencies: [6, 7, 44, 304] */;