147 lines
5.4 KiB
TypeScript
147 lines
5.4 KiB
TypeScript
/* Metro module 11879; source: utils/DragAndDropUtils.tsx; dependencies: [3, 22, 2] */
|
|
function _fun91135(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#91135, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12065:6, offset: 0x02053701, size: 197 bytes, params: 8, frame: 21
|
|
var object2;
|
|
const closure = calculatePositionDeltas;
|
|
const closure2 = function(a0, a1, a2) {
|
|
var property = a0[a1];
|
|
var items = [];
|
|
arraySpread(items, a0, 0, a1);
|
|
items.splice(a1, 1);
|
|
items.splice(a2, 0, property);
|
|
return items;
|
|
};
|
|
const closure3 = getPositionUpdates;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
let value = importDefault(3) /* metro dependency 3: Logger */;
|
|
value = new value('DragAndDropUtils');
|
|
object2 = {moveItemFromTo: closure2, calculatePositionDeltas: closure, getPositionUpdates: closure3};
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('utils/DragAndDropUtils.tsx');
|
|
exports.default = object2;
|
|
exports.calculatePositionDeltas = closure;
|
|
exports.moveItemFromTo = closure2;
|
|
exports.getPositionUpdates = closure3;
|
|
}
|
|
|
|
function calculatePositionDeltas({oldOrdering, newOrdering, idGetter, existingPositionGetter, ascending}) { // fn#91136, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12065:135, offset: 0x020537c6, size: 341 bytes, params: 2, frame: 27
|
|
var r0;
|
|
var r7;
|
|
var r15;
|
|
var r13;
|
|
var value;
|
|
var value5;
|
|
var value6;
|
|
var value7;
|
|
var value8;
|
|
var value9;
|
|
var push;
|
|
var reverse;
|
|
reducibleJoin2: while (true) {
|
|
if (ascending !== undefined) {
|
|
break reducibleJoin2;
|
|
}
|
|
value = true;
|
|
ascending = value;
|
|
break reducibleJoin2;
|
|
}
|
|
const length = newOrdering.length;
|
|
if (oldOrdering.length !== length) {
|
|
env0_2.warn('Arrays are not of the same length!', oldOrdering, newOrdering);
|
|
return [];
|
|
}
|
|
value = oldOrdering.map(idGetter);
|
|
value = value.sort();
|
|
value = value.join(':');
|
|
const value4 = newOrdering.map(idGetter).sort().join(':');
|
|
if (value !== value4) {
|
|
env0_2.warn('Object IDs in the old ordering and the new ordering are not the same.', value, value4);
|
|
return [];
|
|
}
|
|
const object2 = {};
|
|
value = 0;
|
|
if (value < length) {
|
|
r0 = value;
|
|
reducibleLoop5: while (true) {
|
|
value5 = idGetter(oldOrdering[r0]);
|
|
object2[value5] = existingPositionGetter(oldOrdering[r0]);
|
|
value6 = typeof r0 === 'bigint' ? r0 + 1n : +r0 + 1;
|
|
if (value6 < length) {
|
|
r0 = value6;
|
|
continue reducibleLoop5;
|
|
}
|
|
break reducibleLoop5;
|
|
}
|
|
}
|
|
const items2 = [];
|
|
if (value < length) {
|
|
r7 = value;
|
|
reducibleLoop7: while (true) {
|
|
value = idGetter(newOrdering[r7]);
|
|
reducibleJoin9: while (true) {
|
|
if (ascending) {
|
|
r15 = r7;
|
|
break reducibleJoin9;
|
|
}
|
|
value7 = length - 1 - r7;
|
|
r15 = value7;
|
|
break reducibleJoin9;
|
|
}
|
|
value8 = object2[value] === r15;
|
|
reducibleJoin11: while (true) {
|
|
if (value8) {
|
|
value9 = existingPositionGetter(newOrdering[r7]) === r15;
|
|
r13 = value9;
|
|
break reducibleJoin11;
|
|
}
|
|
r13 = value8;
|
|
break reducibleJoin11;
|
|
}
|
|
reducibleJoin13: while (true) {
|
|
if (r13) {
|
|
break reducibleJoin13;
|
|
}
|
|
push = items2.push;
|
|
Reflect.apply(push, items2, [{id: value, position: r15}]);
|
|
break reducibleJoin13;
|
|
}
|
|
value = typeof r7 === 'bigint' ? r7 + 1n : +r7 + 1;
|
|
if (value < length) {
|
|
r7 = value;
|
|
continue reducibleLoop7;
|
|
}
|
|
break reducibleLoop7;
|
|
}
|
|
}
|
|
reducibleJoin16: while (true) {
|
|
if (ascending) {
|
|
break reducibleJoin16;
|
|
}
|
|
reverse = items2.reverse;
|
|
Reflect.apply(reverse, items2, []);
|
|
break reducibleJoin16;
|
|
}
|
|
return items2;
|
|
}
|
|
|
|
function getPositionUpdates({objectArray, fromPosition, toPosition, idGetter, existingPositionGetter, ascending}) { // fn#91138, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:12065:762, offset: 0x02053958, size: 162 bytes, params: 2, frame: 21
|
|
var r7;
|
|
var value;
|
|
ascending = ascending === undefined || ascending;
|
|
const Array = global.Array;
|
|
if (Array.isArray(objectArray)) {
|
|
r7 = objectArray;
|
|
} else {
|
|
value = importDefault(22) /* metro dependency 22 */;
|
|
value = value.values(objectArray);
|
|
r7 = value;
|
|
}
|
|
const calculatePositionDeltasBinding = calculatePositionDeltas;
|
|
const object2 = {oldOrdering: r7};
|
|
object2.newOrdering = moveItemFromTo(r7, fromPosition, toPosition);
|
|
object2.idGetter = idGetter;
|
|
object2.existingPositionGetter = existingPositionGetter;
|
|
object2.ascending = ascending;
|
|
return calculatePositionDeltasBinding(object2);
|
|
}
|
|
|