// Metro module 11511 (f11512). import Logger from "../modules/debug/Logger"; import Module12 from "../_bundle/Module12"; let c7845_2; const calculatePositionDeltas = function calculatePositionDeltas({ oldOrdering, newOrdering, idGetter, existingPositionGetter, ascending = true }) { const length = newOrdering.length; if (oldOrdering.length !== length) { c7845_2.warn("Arrays are not of the same length!", oldOrdering, newOrdering); return []; } const r15 = oldOrdering.map(idGetter).sort().join(":"); const r32 = newOrdering.map(idGetter).sort().join(":"); if (r15 !== r32) { c7845_2.warn("Object IDs in the old ordering and the new ordering are not the same.", r15, r32); return []; } const r33 = {}; const r5 = 0 < length; let r0 = 0; if (r5) { do { r33[idGetter(oldOrdering[r0])] = existingPositionGetter(oldOrdering[r0]); r0 = r0 + 1; } while (r0 < length); } const r37 = []; const r38 = 0 < length; let r39 = 0; if (r38) { do { const id = idGetter(newOrdering[r39]); const r41 = r39; const position = ascending ? r41 : length - 1 - r41; if (!(r33[id] === position && existingPositionGetter(newOrdering[r41]) === position)) { r37.push({ id, position }); } r39 = r41 + 1; } while (r39 < length); } if (!ascending) { r37.reverse(); } return r37; }; export function moveItemFromTo(a0, a1, a2) { const r5 = a0[a1]; const r2 = [...a0]; r2.splice(a1, 1); r2.splice(a2, 0, r5); return r2; } export function getPositionUpdates({ objectArray, fromPosition, toPosition, idGetter, existingPositionGetter, ascending = true }) { const oldOrdering = Array.isArray(objectArray) ? objectArray : Module12.values(objectArray); const r27 = oldOrdering[fromPosition]; const newOrdering = [...oldOrdering]; newOrdering.splice(fromPosition, 1); newOrdering.splice(toPosition, 0, r27); return calculatePositionDeltas({ oldOrdering, newOrdering, idGetter, existingPositionGetter, ascending }); } c7845_2 = new Logger("DragAndDropUtils"); const r23 = { moveItemFromTo, calculatePositionDeltas, getPositionUpdates }; export default r23; export { calculatePositionDeltas };