Files
discord-decomp/sources/modules/guilds_bar/native/GuildsBarDragPreview.tsx
T
2026-07-28 01:06:53 +03:00

392 lines
23 KiB
TypeScript

/* Metro module 14457; source: modules/guilds_bar/native/GuildsBarDragPreview.tsx; dependencies: [31, 4896, 14384, 33, 4501, 4017, 4577, 8141, 4508, 14394, 14415, 3769, 2] */
import ReanimatedNativeView from '../../core/native/ReanimatedNativeView.tsx'; /* Metro dependency 8141 */
import GuildsBarDnDStore from './GuildsBarDnDStore.tsx'; /* Metro dependency 14384 */
import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as JsxRuntimeModule from '../../../by-id/module-00033-JsxRuntime.js'; /* Metro dependency 33 */
import * as Module03769Module from '../../../by-id/module-03769.js'; /* Metro dependency 3769 */
import * as ReanimatedRexportModule from '../../reanimated/ReanimatedRexport.tsx'; /* Metro dependency 4017 */
import * as CreateStylesModule from '../../../design/components/Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
import * as TransitionGroupModule from '../../../design/components/TransitionGroup/TransitionGroup.tsx'; /* Metro dependency 4508 */
import * as SpringModule from '../../../design/animation/reanimated/spring/spring.tsx'; /* Metro dependency 4577 */
import * as SortedGuildStoreModule from '../../../stores/SortedGuildStore.tsx'; /* Metro dependency 4896 */
function _fun109403(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#109403, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:6, offset: 0x023499c1, size: 406 bytes, params: 8, frame: 21
const env0_0 = require;
const getItemPreviewKey = function({id}) {
return '' + id;
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactModule;
const env0_7 = (CreateStylesModule).createStyles({dragPreview: {'position': 'absolute',
'left': 0}, animatedPreviewStyle: {position: 'absolute'}});
const env0_8 = {'mass': 0.5, 'damping': 80, 'stiffness': 320};
object = {code: 'function GuildsBarDragPreviewTsx1(){const{scrollPosition,dragRegion,listInsets}=this.__closure;return Math.max(scrollPosition.get()<dragRegion.get().min?dragRegion.get().min-scrollPosition.get():0,listInsets.get().start);}'};
object = {code: 'function GuildsBarDragPreviewTsx2(){const{scrollPosition,windowSize,listInsets,dragRegion,draggedHeight}=this.__closure;return Math.min(scrollPosition.get()+(windowSize-listInsets.get().end)>dragRegion.get().max?dragRegion.get().max-draggedHeight-scrollPosition.get():windowSize-listInsets.get().end-draggedHeight,windowSize-listInsets.get().end-draggedHeight);}'};
object = {code: "function GuildsBarDragPreviewTsx3(){const{dropPosition,scrollPosition,gestureState,draggedHeight,minY,maxY,windowSize,withSpring,DRAG_SPRING_PHYSICS,runOnJS,dropComplete}=this.__closure;let translateY=function(){if(dropPosition!=null){return dropPosition-scrollPosition.get();}return gestureState.get().absoluteY-draggedHeight/2;}();if(gestureState.get().mode!=null&&dropPosition==null){translateY=Math.min(Math.max(translateY,minY.get()),maxY.get());}else{translateY=Math.max(-draggedHeight,Math.min(translateY,windowSize));}return{top:withSpring(translateY,DRAG_SPRING_PHYSICS,'animate-always',function(finished){if(finished&&dropPosition!=null){runOnJS(dropComplete)();}})};}"};
object = {code: 'function GuildsBarDragPreviewTsx4(finished){const{dropPosition,runOnJS,dropComplete}=this.__closure;if(finished&&dropPosition!=null){runOnJS(dropComplete)();}}'};
object = {code: "function GuildsBarDragPreviewTsx5(){const{isFolder,visible,withSpring,DRAG_SPRING_PHYSICS,transitionState,TransitionStates,runOnJS,cleanUp}=this.__closure;const targetScale=function(){if(isFolder){return visible.get()===1?1:0.3;}return visible.get()===1?1:0.33;}();const{translateX:translateX,translateY:translateY}=function(){if(isFolder){return{translateX:0,translateY:0};}if(visible.get()===1){return{translateX:0,translateY:0};}return{translateX:10,translateY:-10};}();return{zIndex:isFolder?0:1,transform:[{translateY:withSpring(translateY,DRAG_SPRING_PHYSICS,'animate-always')},{translateX:withSpring(translateX,DRAG_SPRING_PHYSICS,'animate-always')},{scale:withSpring(targetScale,DRAG_SPRING_PHYSICS,'animate-always',function(finished){if(finished&&transitionState===TransitionStates.YEETED&&isFolder){runOnJS(cleanUp)();}})}],opacity:withSpring(isFolder?visible.get():1,DRAG_SPRING_PHYSICS,'animate-always')};}"};
object = {code: 'function GuildsBarDragPreviewTsx6(finished){const{transitionState,TransitionStates,isFolder,runOnJS,cleanUp}=this.__closure;if(finished&&transitionState===TransitionStates.YEETED&&isFolder){runOnJS(cleanUp)();}}'};
value = value.memo(GuildsBarDragPreview);
(FileImportTrackerModule).fileFinishedImporting('modules/guilds_bar/native/GuildsBarDragPreview.tsx');
exports.default = value;
function PreviewItem({dragRegion, draggedHeight, draggedNode, dropComplete, gestureState, listInsets, overNode, overState, scrollPosition, windowSize, dropPosition}) { // fn#109404, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:1771, offset: 0x02349b57, size: 627 bytes, params: 2, frame: 33
const gestureState2 = gestureState;
const windowSize2 = windowSize;
const dropPosition2 = dropPosition;
const styles = useStyles();
let useDerivedValue = ReanimatedRexportModule.useDerivedValue;
let closure = function() {
var Math = global.Math;
return Math.max(scrollPosition.get() < dragRegion.get().min ? dragRegion.get().min - scrollPosition.get() : 0,
listInsets.get().start);
};
closure.__closure = {scrollPosition: scrollPosition, dragRegion: dragRegion, listInsets: listInsets};
closure.__workletHash = 17436881889698;
closure.__initData = dropPosition2;
const value2 = Reflect.apply(useDerivedValue, ReanimatedRexportModule, [closure]);
const env0_10 = value2;
useDerivedValue = ReanimatedRexportModule.useDerivedValue;
closure = PreviewItemY;
closure.__closure = {scrollPosition: scrollPosition, windowSize: windowSize, listInsets: listInsets,
dragRegion: dragRegion, draggedHeight: draggedHeight};
closure.__workletHash = 4371355784;
closure.__initData = env0_10;
const value3 = Reflect.apply(useDerivedValue, ReanimatedRexportModule, [closure]);
const env0_11 = value3;
const useAnimatedStyle = ReanimatedRexportModule.useAnimatedStyle;
closure = PreviewItemH;
object = {dropPosition: dropPosition, scrollPosition: scrollPosition, gestureState: gestureState,
draggedHeight: draggedHeight, minY: value2, maxY: value3, windowSize: windowSize};
object.withSpring = (require(4577) /* metro dependency 4577: spring */).withSpring;
object.DRAG_SPRING_PHYSICS = windowSize2;
object.runOnJS = ReanimatedRexportModule.runOnJS;
object.dropComplete = dropComplete;
closure.__closure = object;
closure.__workletHash = 5676492640532;
closure.__initData = env0_11;
const value4 = Reflect.apply(useAnimatedStyle, ReanimatedRexportModule, [closure]);
const value5 = gestureState2.useMemo(_fun109409, [overState, overNode]);
const items2 = [styles.dragPreview, value4];
const TransitionGroup = (TransitionGroupModule).TransitionGroup;
return (
<ReanimatedNativeView style={items2} nativeID="guilds-bar-drag-preview">
<TransitionGroup
renderItem={renderAnimatedItemPreview}
items={[value5 ?? draggedNode]}
getItemKey={getItemPreviewKey}
/>
</ReanimatedNativeView>
);
function PreviewItemY() { // fn#109406, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:2200, owner: PreviewItem.y, offset: 0x02349e3f, size: 202 bytes, params: 1, frame: 16
var r1;
var value6;
const Math = global.Math;
const min = Math.min;
let scrollPositionBinding = scrollPosition;
let get = scrollPositionBinding.get;
const value2 = Reflect.apply(get, scrollPositionBinding, []);
let windowSizeBinding = windowSize;
let listInsetsBinding = listInsets;
get = listInsetsBinding.get;
const value3 = value2 + (windowSizeBinding - Reflect.apply(get, listInsetsBinding, []).end);
get = dragRegion.get;
if (value3 > Reflect.apply(get, dragRegionBinding, []).max) {
dragRegionBinding = dragRegion;
get = dragRegionBinding.get;
value6 = Reflect.apply(get, dragRegionBinding, []).max - draggedHeight;
scrollPositionBinding = scrollPosition;
get = scrollPositionBinding.get;
r1 = value6 - Reflect.apply(get, scrollPositionBinding, []);
} else {
windowSizeBinding = windowSize;
listInsetsBinding = listInsets;
r1 = windowSizeBinding - listInsetsBinding.get().end - draggedHeight;
}
windowSizeBinding = windowSize;
listInsetsBinding = listInsets;
get = listInsetsBinding.get;
return Reflect.apply(min, Math, [r1, windowSizeBinding - Reflect.apply(get, listInsetsBinding,
[]).end - draggedHeight]);
}
function PreviewItemH() { // fn#109407, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:2466, owner: PreviewItem.H, offset: 0x02349f09, size: 354 bytes, params: 1, frame: 24
var r6;
var Math;
var max;
var value4;
var Math2;
var min;
var Math3;
var binding;
var value6;
const r5 = dropPosition != null ? dropPosition - scrollPosition.get() : gestureState.get().absoluteY - draggedHeight / 2;
const gestureStateBinding = gestureState;
let get = gestureStateBinding.get;
if (Reflect.apply(get, gestureStateBinding, []).mode == null) {
Math = global.Math;
max = Math.max;
value4 = -draggedHeight;
Math2 = global.Math;
r6 = Reflect.apply(max, Math, [value4, Math2.min(r5, windowSize)]);
} else if (dropPosition == null) {
Math = global.Math;
min = Math.min;
Math3 = global.Math;
max = Math3.max;
binding = env0_10;
get = binding.get;
value6 = Reflect.apply(max, Math3, [r5, Reflect.apply(get, binding, [])]);
binding = env0_11;
get = binding.get;
r6 = Reflect.apply(min, Math, [value6, Reflect.apply(get, binding, [])]);
} else {
Math = global.Math;
max = Math.max;
value4 = -draggedHeight;
Math2 = global.Math;
r6 = Reflect.apply(max, Math, [value4, Math2.min(r5, windowSize)]);
}
const withSpring = SpringModule.withSpring;
binding = env1_8;
const HT_1094082 = HT_109408;
const object2 = {};
object2.dropPosition = dropPosition;
object2.runOnJS = (require(4017) /* metro dependency 4017: ReanimatedRexport */).runOnJS;
object2.dropComplete = dropComplete;
HT_1094082.__closure = object2;
HT_1094082.__workletHash = 12640145939434;
HT_1094082.__initData = env1_12;
return {top: Reflect.apply(withSpring, SpringModule, [r6, binding, 'animate-always', HT_1094082])};
function HT_109408(a0) { // fn#109408, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:2675, owner: PreviewItem.H.t, offset: 0x0234a06b, size: 72 bytes, params: 2, frame: 12
var r0;
var runOnJS;
var value2;
let value = a0;
if (value) {
value = environment.__proto__;
value = dropPosition != null;
r0 = value;
} else {
r0 = value;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(4017) /* metro dependency 4017: ReanimatedRexport */;
runOnJS = value.runOnJS;
value2 = environment.__proto__;
Reflect.apply(runOnJS, value, [dropComplete])();
}
}
}
function _fun109409() { // fn#109409, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:3096, offset: 0x0234a0b3, size: 114 bytes, params: 1, frame: 4
var value2;
if (overState !== 'convert-after') {
if (overState !== 'convert-before') {
return undefined;
}
}
if (overNode != null) {
value2 = environment.__proto__;
return {type: GuildsNodeType.FOLDER, id: -1, parentId: undefined, name: undefined, color: undefined,
expanded: false, children: [overNode]};
}
}
}
function renderAnimatedItemPreview(a0, a1, a2, a3) { // fn#109411, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:3509, offset: 0x0234a145, size: 51 bytes, params: 5, frame: 15
return (
<AnimatedItemPreview
node={a1}
transitionState={a2}
cleanUp={a3}
key={a0}
/>
);
}
function AnimatedItemPreview({node, transitionState, cleanUp}) { // fn#109412, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:4779, offset: 0x0234a178, size: 533 bytes, params: 2, frame: 26
var r4;
var value;
const styles = useStyles();
const useSharedValue = ReanimatedRexportModule.useSharedValue;
const TransitionStates = (TransitionGroupModule).TransitionStates;
const ENTERED = TransitionStates.ENTERED;
const value4 = Reflect.apply(useSharedValue, ReanimatedRexportModule, [transitionState !== ENTERED ? 1 : 0]);
let type = node.type;
let FOLDER = GuildsNodeType.FOLDER;
const value5 = type === FOLDER;
const env0_3 = value5;
const useAnimatedStyle = ReanimatedRexportModule.useAnimatedStyle;
const AnimatedItemPreviewP2 = AnimatedItemPreviewP;
const object = {isFolder: value5, visible: value4};
object.withSpring = (require(4577) /* metro dependency 4577: spring */).withSpring;
object.DRAG_SPRING_PHYSICS = env0_8;
object.transitionState = transitionState;
object.TransitionStates = TransitionStates;
object.runOnJS = ReanimatedRexportModule.runOnJS;
object.cleanUp = cleanUp;
AnimatedItemPreviewP2.__closure = object;
AnimatedItemPreviewP2.__workletHash = 13465198693221;
AnimatedItemPreviewP2.__initData = env0_13;
const value6 = Reflect.apply(useAnimatedStyle, ReanimatedRexportModule, [AnimatedItemPreviewP2]);
env0_3.useEffect(_fun109415);
const items2 = [styles.animatedPreviewStyle, value6];
type = node.type;
FOLDER = GuildsNodeType.FOLDER;
if (type === FOLDER) {
value = importDefault(14394) /* metro dependency 14394: GuildsBarGuildFolder */;
value = ((Component) => <Component id={node.id} expanded={node.expanded} color={node.color} name={node.name} childNodes={node.children} isDragPreview />)(value);
r4 = value;
} else {
value = importDefault(14415) /* metro dependency 14415: GuildsBarGuild */;
value = ((Component) => <Component guildId={node.id} isDragPreview />)(value);
r4 = value;
}
return (
<ReanimatedNativeView style={items2}>
{r4}
</ReanimatedNativeView>
);
function AnimatedItemPreviewP() { // fn#109413, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:4976, owner: AnimatedItemPreview.p, offset: 0x0234a38d, size: 462 bytes, params: 1, frame: 29
let binding = env0_3;
const value2 = env0_2.get();
const value3 = 1;
const r15 = binding ? value3 !== value2 ? 0.3 : value3 : value3 !== value2 ? 0.33 : value3;
const {translateX, translateY} = env0_3 || value3 === env0_2.get() ? {'translateX': 0,
'translateY': 0} : {'translateX': 10, 'translateY': -10};
const object = {};
object.zIndex = env0_3 ? 0 : value3;
let withSpring = SpringModule.withSpring;
const items2 = [{translateY: Reflect.apply(withSpring, SpringModule, [translateY, env1_8, 'animate-always'])}];
const object3 = {};
object3.translateX = SpringModule.withSpring(translateX, env1_8, 'animate-always');
items2[1] = object3;
withSpring = SpringModule.withSpring;
binding = env1_8;
const pT2 = pT;
const object5 = {};
object5.transitionState = transitionState;
const TransitionStates = (TransitionGroupModule).TransitionStates;
object5.TransitionStates = TransitionStates;
object5.isFolder = env0_3;
object5.runOnJS = (require(4017) /* metro dependency 4017: ReanimatedRexport */).runOnJS;
object5.cleanUp = cleanUp;
pT2.__closure = object5;
pT2.__workletHash = 9409925192880;
pT2.__initData = env1_14;
items2[2] = {scale: Reflect.apply(withSpring, SpringModule, [r15, binding, 'animate-always', pT2])};
object.transform = items2;
object.opacity = SpringModule.withSpring(env0_3 ? env0_2.get() : value3, env1_8, 'animate-always');
return object;
function pT(a0) { // fn#109414, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:5327, owner: AnimatedItemPreview.p.t, offset: 0x0234a55b, size: 117 bytes, params: 2, frame: 13
var r0;
var transitionStateBinding;
var runOnJS;
var value2;
let value = a0;
if (value) {
value = environment.__proto__;
transitionStateBinding = transitionState;
value = environment.__proto__.__proto__;
value = transitionStateBinding === (require(4508) /* metro dependency 4508: TransitionGroup */).TransitionStates.YEETED;
r0 = value;
} else {
r0 = value;
}
if (r0) {
value = environment.__proto__;
r0 = env1_3;
}
if (r0) {
value = environment.__proto__.__proto__;
value = require(4017) /* metro dependency 4017: ReanimatedRexport */;
runOnJS = value.runOnJS;
value2 = environment.__proto__;
Reflect.apply(runOnJS, value, [cleanUp])();
}
}
}
function _fun109415() { // fn#109415, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:5884, offset: 0x0234a5d0, size: 69 bytes, params: 1, frame: 14
const binding = env0_2;
const set = binding.set;
const transitionStateBinding = transitionState;
const value = environment.__proto__;
const TransitionStates = (TransitionGroupModule).TransitionStates;
const YEETED = TransitionStates.YEETED;
Reflect.apply(set, binding, [transitionStateBinding !== YEETED ? 1 : 0]);
}
}
function GuildsBarDragPreview() { // fn#109416, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:6176, offset: 0x0234a615, size: 87 bytes, params: 1, frame: 15
const value2 = GuildsBarDnDStore(_fun109417, (Module03769Module).shallow);
const value3 = null;
return (
value3 != value2
? (
<PreviewItem {...value2} />
)
: value3
);
}
}
function _fun109417({dragSpecs, overSpecs, gestureState, scrollPosition, dragRegion, windowSize, dropComplete, listInsets, dropSpecs}) { // fn#109417, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:14654:6217, offset: 0x0234a66c, size: 286 bytes, params: 2, frame: 20
var node;
var state;
var object;
var value;
var value2;
var overState;
if (dropSpecs != null) {
overState = dropSpecs.overState;
object = {};
object.draggedNode = dropSpecs.dragNode;
object.draggedHeight = dropSpecs.itemSize;
object.overState = overState;
object.overNode = overState.startsWith('convert') ? dropSpecs.overNode : undefined;
object.dropPosition = dropSpecs.dropPosition;
object.gestureState = gestureState;
object.scrollPosition = scrollPosition;
object.dragRegion = dragRegion;
object.windowSize = windowSize;
object.dropComplete = dropComplete;
object.listInsets = listInsets;
return object;
}
if (dragSpecs != null) {
if (overSpecs != null) {
state = overSpecs.state;
object = {};
node = dragSpecs.node;
object.draggedNode = node;
object.draggedHeight = dragSpecs.itemSize;
object.overState = state;
value = state.startsWith('convert');
value2 = undefined;
node = value ? overSpecs.node : value2;
object.overNode = node;
object.dropPosition = value2;
object.gestureState = gestureState;
object.scrollPosition = scrollPosition;
object.dragRegion = dragRegion;
object.windowSize = windowSize;
object.dropComplete = dropComplete;
object.listInsets = listInsets;
return object;
}
}
return null;
}
global.__d(_fun109403, 14457, [31, 4896, 14384, 33, 4501, 4017, 4577, 8141, 4508, 14394, 14415, 3769,
2]) /* metro module 14457, dependencies: [31, 4896, 14384, 33, 4501, 4017, 4577, 8141, 4508, 14394, 14415, 3769, 2] */;