349 lines
14 KiB
TypeScript
349 lines
14 KiB
TypeScript
// Metro module 10526 (f10527).
|
|
import { useChannelCallStore } from "./ChannelCallStore";
|
|
import { PIP_FOCUS_SCALE, PIP_GESTURE_ACTIVE_OFFSET } from "./components/Constants";
|
|
import * as _ReanimatedRexport from "../../reanimated/ReanimatedRexport";
|
|
import { useDerivedValue, useSharedValue, useAnimatedReaction, useAnimatedStyle } from "../../reanimated/ReanimatedRexport";
|
|
import * as _timing from "../../../design/animation/reanimated/timing/timing";
|
|
import * as _native from "../../../design/void/native";
|
|
import * as _cheapWorkletShallowEqual from "../../reanimated/native/cheapWorkletShallowEqual";
|
|
import { Gesture } from "../../../_bundle/Module5273";
|
|
import * as _spring from "../../../design/animation/reanimated/spring/spring";
|
|
let clamp;
|
|
const spring = {
|
|
mass: 1,
|
|
stiffness: 250,
|
|
overshootClamping: true,
|
|
restSpeedThreshold: 0.001,
|
|
restDisplacementThreshold: 0.001,
|
|
damping: 20
|
|
};
|
|
const __initData = {
|
|
code: "function useDraggablePipTsx1(){const{withTiming,pipFocus,PIP_FOCUS_SCALE,STANDARD_EASING}=this.__closure;return withTiming(pipFocus?PIP_FOCUS_SCALE:1,{easing:STANDARD_EASING,duration:250});}"
|
|
};
|
|
const __initData2 = {
|
|
code: "function useDraggablePipTsx2(){const{width}=this.__closure;return width;}"
|
|
};
|
|
const __initData3 = {
|
|
code: "function useDraggablePipTsx3(){const{height}=this.__closure;return height;}"
|
|
};
|
|
const __initData4 = {
|
|
code: "function useDraggablePipTsx4(){const{pipScale,width}=this.__closure;return pipScale.get()*width;}"
|
|
};
|
|
const __initData5 = {
|
|
code: "function useDraggablePipTsx5(){const{pipScale,height}=this.__closure;return pipScale.get()*height;}"
|
|
};
|
|
const __initData6 = {
|
|
code: "function useDraggablePipTsx6(){const{containerWidth}=this.__closure;return containerWidth;}"
|
|
};
|
|
const __initData7 = {
|
|
code: "function useDraggablePipTsx7(){const{containerHeight}=this.__closure;return containerHeight;}"
|
|
};
|
|
const __initData8 = {
|
|
code: "function useDraggablePipTsx8(){const{containerWidth,scaledWidthDv,xPosition}=this.__closure;return[containerWidth-scaledWidthDv.get(),xPosition.get()];}"
|
|
};
|
|
const __initData9 = {
|
|
code: "function useDraggablePipTsx9(result,previous){const{cheapWorkletArrayShallowEqual,clamp,xPosition,xDestination}=this.__closure;if(cheapWorkletArrayShallowEqual(result,previous!==null&&previous!==void 0?previous:undefined))return;const[containerWidthNew,xPositionNew]=result;const[containerWidthOld]=previous!==null&&previous!==void 0?previous:[0,0];if(previous!=null&&containerWidthNew!==containerWidthOld){const newX=clamp(xPositionNew*(containerWidthNew/containerWidthOld),0,containerWidthNew);xPosition.set(newX);xDestination.set(newX);}}"
|
|
};
|
|
const __initData10 = {
|
|
code: "function useDraggablePipTsx10(){const{containerHeight,scaledHeightDv,yPosition}=this.__closure;return[containerHeight-scaledHeightDv.get(),yPosition.get()];}"
|
|
};
|
|
const __initData11 = {
|
|
code: "function useDraggablePipTsx11(result,previous){const{cheapWorkletArrayShallowEqual,clamp,yPosition,yDestination}=this.__closure;if(cheapWorkletArrayShallowEqual(result,previous!==null&&previous!==void 0?previous:undefined))return;const[containerHeightNew,yPositionNew]=result;const[containerHeightOld]=previous!==null&&previous!==void 0?previous:[0,0];if(previous!=null&&containerHeightNew!==containerHeightOld){const newY=clamp(yPositionNew*(containerHeightNew/containerHeightOld),0,containerHeightNew);yPosition.set(newY);yDestination.set(newY);}}"
|
|
};
|
|
const __initData12 = {
|
|
code: "function useDraggablePipTsx12(event){const{xPosition,containerWidthDv,scaledWidthDv,clamp,yPosition,containerHeightDv,scaledHeightDv,snapToCorners,withSpring,spring,xDestination,yDestination}=this.__closure;const toss=0.0875;const xToss=xPosition.get()+toss*event.velocityX;const xMin=0;const xMax=containerWidthDv.get()-scaledWidthDv.get();const targetX=clamp(xToss,xMin,xMax);const yToss=yPosition.get()+toss*event.velocityY;const yMin=0;const yMax=containerHeightDv.get()-scaledHeightDv.get();const targetY=clamp(yToss,yMin,yMax);const top=targetY;const bottom=containerHeightDv.get()-scaledHeightDv.get()-targetY;const left=targetX;const right=containerWidthDv.get()-scaledWidthDv.get()-targetX;const minDistance=Math.min(top,bottom,left,right);let snapX=targetX;let snapY=targetY;switch(minDistance){case top:snapY=yMin;if(snapToCorners){snapX=left<right?xMin:xMax;}break;case bottom:snapY=yMax;if(snapToCorners){snapX=left<right?xMin:xMax;}break;case left:snapX=xMin;if(snapToCorners){snapY=top<bottom?yMin:yMax;}break;case right:snapX=xMax;if(snapToCorners){snapY=top<bottom?yMin:yMax;}break;}xPosition.set(withSpring(snapX,{...spring,velocity:event.velocityX}));xDestination.set(snapX);yPosition.set(withSpring(snapY,{...spring,velocity:event.velocityY}));yDestination.set(snapY);}"
|
|
};
|
|
const __initData13 = {
|
|
code: "function useDraggablePipTsx13(event){const{xPosition,xDestination,yPosition,yDestination,trackedVoiceControlsToggleMovedForGestureSv,onMoved,runOnJS}=this.__closure;xPosition.set(xDestination.get()+event.translationX);yPosition.set(yDestination.get()+event.translationY);if(!trackedVoiceControlsToggleMovedForGestureSv.get()){if(onMoved!=null){runOnJS(onMoved)();}trackedVoiceControlsToggleMovedForGestureSv.set(true);}}"
|
|
};
|
|
const __initData14 = {
|
|
code: "function useDraggablePipTsx14(){const{onPress,runOnJS}=this.__closure;if(onPress!=null){runOnJS(onPress)();}}"
|
|
};
|
|
const __initData15 = {
|
|
code: "function useDraggablePipTsx15(){const{xPosition,scaledWidthDv,widthDv,yPosition,scaledHeightDv,heightDv,pipScale}=this.__closure;return{transform:[{translateX:xPosition.get()+(scaledWidthDv.get()-widthDv.get())/2},{translateY:yPosition.get()+(scaledHeightDv.get()-heightDv.get())/2},{scale:pipScale.get()}]};}"
|
|
};
|
|
const clamp2 = function clamp(a0, a1, a2) {
|
|
return Math.min(Math.max(a0, a1), a2);
|
|
};
|
|
clamp2.__closure = {};
|
|
clamp2.__workletHash = 1988116204206;
|
|
clamp2.__initData = {
|
|
code: "function clamp_useDraggablePipTsx16(value,min,max){return Math.min(Math.max(value,min),max);}"
|
|
};
|
|
clamp = clamp2;
|
|
export function useDraggablePip({ width, height, containerWidth, containerHeight, onPress, onMoved, snapToCorners }) {
|
|
let derivedValue, derivedValue2, derivedValue3, derivedValue4, derivedValue5, derivedValue6, derivedValue7, sharedValue, sharedValue2, sharedValue3, sharedValue4, sharedValue5;
|
|
derivedValue = void 0;
|
|
derivedValue2 = void 0;
|
|
derivedValue3 = void 0;
|
|
derivedValue4 = void 0;
|
|
derivedValue5 = void 0;
|
|
derivedValue6 = void 0;
|
|
derivedValue7 = void 0;
|
|
sharedValue = void 0;
|
|
sharedValue2 = void 0;
|
|
sharedValue3 = void 0;
|
|
sharedValue4 = void 0;
|
|
sharedValue5 = void 0;
|
|
const channelCallStore = useChannelCallStore((a0) => a0.pipFocus);
|
|
const X = function X() {
|
|
return _timing.withTiming(channelCallStore ? PIP_FOCUS_SCALE : 1, {
|
|
easing: _native.STANDARD_EASING,
|
|
duration: 250
|
|
});
|
|
};
|
|
X.__closure = {
|
|
withTiming: _timing.withTiming,
|
|
pipFocus: channelCallStore,
|
|
PIP_FOCUS_SCALE,
|
|
STANDARD_EASING: _native.STANDARD_EASING
|
|
};
|
|
X.__workletHash = 7848271415351;
|
|
X.__initData = __initData;
|
|
derivedValue = useDerivedValue(X);
|
|
const Y = () => width;
|
|
Y.__closure = {
|
|
width
|
|
};
|
|
Y.__workletHash = 14810909441301;
|
|
Y.__initData = __initData2;
|
|
derivedValue2 = useDerivedValue(Y);
|
|
const N = () => height;
|
|
N.__closure = {
|
|
height
|
|
};
|
|
N.__workletHash = 15343935194036;
|
|
N.__initData = __initData3;
|
|
derivedValue3 = useDerivedValue(N);
|
|
const V = () => derivedValue.get() * width;
|
|
V.__closure = {
|
|
pipScale: derivedValue,
|
|
width
|
|
};
|
|
V.__workletHash = 3468337829868;
|
|
V.__initData = __initData4;
|
|
derivedValue4 = useDerivedValue(V);
|
|
const F = () => derivedValue.get() * height;
|
|
F.__closure = {
|
|
pipScale: derivedValue,
|
|
height
|
|
};
|
|
F.__workletHash = 7163944260205;
|
|
F.__initData = __initData5;
|
|
derivedValue5 = useDerivedValue(F);
|
|
const G = () => containerWidth;
|
|
G.__closure = {
|
|
containerWidth
|
|
};
|
|
G.__workletHash = 13449836478609;
|
|
G.__initData = __initData6;
|
|
derivedValue6 = useDerivedValue(G);
|
|
const I = () => containerHeight;
|
|
I.__closure = {
|
|
containerHeight
|
|
};
|
|
I.__workletHash = 4105281399152;
|
|
I.__initData = __initData7;
|
|
derivedValue7 = useDerivedValue(I);
|
|
sharedValue = useSharedValue(0);
|
|
sharedValue2 = useSharedValue(sharedValue.get());
|
|
sharedValue3 = useSharedValue(0);
|
|
sharedValue4 = useSharedValue(sharedValue3.get());
|
|
sharedValue5 = useSharedValue(false);
|
|
const J = function J() {
|
|
return [containerWidth - derivedValue4.get(), sharedValue2.get()];
|
|
};
|
|
J.__closure = {
|
|
containerWidth,
|
|
scaledWidthDv: derivedValue4,
|
|
xPosition: sharedValue2
|
|
};
|
|
J.__workletHash = 2741340788440;
|
|
J.__initData = __initData8;
|
|
const q = function q(a0, a1) {
|
|
if (!_cheapWorkletShallowEqual.cheapWorkletArrayShallowEqual(a0, a1 == null ? void 0 : a1)) {
|
|
const [r18, r19] = a0;
|
|
const [r23] = a1 == null ? [0, 0] : a1;
|
|
if (a1 != null && r18 !== r23) {
|
|
const r35 = Math.min(Math.max(r19 * (r18 / r23), 0), r18);
|
|
sharedValue2.set(r35);
|
|
sharedValue.set(r35);
|
|
}
|
|
}
|
|
};
|
|
q.__closure = {
|
|
cheapWorkletArrayShallowEqual: _cheapWorkletShallowEqual.cheapWorkletArrayShallowEqual,
|
|
clamp,
|
|
xPosition: sharedValue2,
|
|
xDestination: sharedValue
|
|
};
|
|
q.__workletHash = 15748808822770;
|
|
q.__initData = __initData9;
|
|
useAnimatedReaction(J, q);
|
|
const U = function U() {
|
|
return [containerHeight - derivedValue5.get(), sharedValue4.get()];
|
|
};
|
|
U.__closure = {
|
|
containerHeight,
|
|
scaledHeightDv: derivedValue5,
|
|
yPosition: sharedValue4
|
|
};
|
|
U.__workletHash = 11475249153313;
|
|
U.__initData = __initData10;
|
|
const R = function R(a0, a1) {
|
|
if (!_cheapWorkletShallowEqual.cheapWorkletArrayShallowEqual(a0, a1 == null ? void 0 : a1)) {
|
|
const [r18, r19] = a0;
|
|
const [r23] = a1 == null ? [0, 0] : a1;
|
|
if (a1 != null && r18 !== r23) {
|
|
const r35 = Math.min(Math.max(r19 * (r18 / r23), 0), r18);
|
|
sharedValue4.set(r35);
|
|
sharedValue3.set(r35);
|
|
}
|
|
}
|
|
};
|
|
R.__closure = {
|
|
cheapWorkletArrayShallowEqual: _cheapWorkletShallowEqual.cheapWorkletArrayShallowEqual,
|
|
clamp,
|
|
yPosition: sharedValue4,
|
|
yDestination: sharedValue3
|
|
};
|
|
R.__workletHash = 7685377389843;
|
|
R.__initData = __initData11;
|
|
useAnimatedReaction(U, R);
|
|
const r149 = Gesture.Pan().activeOffsetX([-PIP_GESTURE_ACTIVE_OFFSET, PIP_GESTURE_ACTIVE_OFFSET]).activeOffsetY([-PIP_GESTURE_ACTIVE_OFFSET, PIP_GESTURE_ACTIVE_OFFSET]);
|
|
const ae = function ae(a0) {
|
|
sharedValue2.set(sharedValue.get() + a0.translationX);
|
|
sharedValue4.set(sharedValue3.get() + a0.translationY);
|
|
if (!sharedValue5.get()) {
|
|
if (onMoved != null) {
|
|
_ReanimatedRexport.runOnJS(onMoved)();
|
|
}
|
|
sharedValue5.set(true);
|
|
}
|
|
};
|
|
ae.__closure = {
|
|
xPosition: sharedValue2,
|
|
xDestination: sharedValue,
|
|
yPosition: sharedValue4,
|
|
yDestination: sharedValue3,
|
|
trackedVoiceControlsToggleMovedForGestureSv: sharedValue5,
|
|
onMoved,
|
|
runOnJS: _ReanimatedRexport.runOnJS
|
|
};
|
|
ae.__workletHash = 14964390506971;
|
|
ae.__initData = __initData13;
|
|
const r158 = r149.onUpdate(ae);
|
|
const se = function se(a0) {
|
|
let r70, r71;
|
|
const r15 = sharedValue2.get() + 0.0875 * a0.velocityX;
|
|
const r6 = derivedValue6.get() - derivedValue4.get();
|
|
const r36 = Math.min(Math.max(r15, 0), r6);
|
|
const r20 = sharedValue4.get() + 0.0875 * a0.velocityY;
|
|
const r47 = derivedValue7.get() - derivedValue5.get();
|
|
const r53 = Math.min(Math.max(r20, 0), r47);
|
|
const r59 = derivedValue7.get() - derivedValue5.get() - r53;
|
|
const r65 = derivedValue6.get() - derivedValue4.get() - r36;
|
|
const r69 = Math.min(r53, r59, r36, r65);
|
|
if (r53 === r69) {
|
|
r70 = 0;
|
|
r71 = r36;
|
|
if (snapToCorners) {
|
|
r71 = r36 < r65 ? 0 : r6;
|
|
r70 = 0;
|
|
}
|
|
} else if (r59 === r69) {
|
|
r70 = r47;
|
|
r71 = r36;
|
|
if (snapToCorners) {
|
|
r71 = r36 < r65 ? 0 : r6;
|
|
r70 = r47;
|
|
}
|
|
} else if (r36 === r69) {
|
|
r70 = r53;
|
|
r71 = 0;
|
|
if (snapToCorners) {
|
|
r70 = r53 < r59 ? 0 : r47;
|
|
r71 = 0;
|
|
}
|
|
} else {
|
|
r70 = r53;
|
|
r71 = r36;
|
|
if (r65 === r69) {
|
|
r70 = r53;
|
|
r71 = r6;
|
|
if (snapToCorners) {
|
|
r70 = r53 < r59 ? 0 : r47;
|
|
r71 = r6;
|
|
}
|
|
}
|
|
}
|
|
sharedValue2.set(_spring.withSpring(r71, {
|
|
...spring,
|
|
velocity: a0.velocityX
|
|
}));
|
|
sharedValue.set(r71);
|
|
sharedValue4.set(_spring.withSpring(r70, {
|
|
...spring,
|
|
velocity: a0.velocityY
|
|
}));
|
|
sharedValue3.set(r70);
|
|
};
|
|
se.__closure = {
|
|
xPosition: sharedValue2,
|
|
containerWidthDv: derivedValue6,
|
|
scaledWidthDv: derivedValue4,
|
|
clamp,
|
|
yPosition: sharedValue4,
|
|
containerHeightDv: derivedValue7,
|
|
scaledHeightDv: derivedValue5,
|
|
snapToCorners,
|
|
withSpring: _spring.withSpring,
|
|
spring,
|
|
xDestination: sharedValue,
|
|
yDestination: sharedValue3
|
|
};
|
|
se.__workletHash = 690760681755;
|
|
se.__initData = __initData12;
|
|
const r168 = r158.onEnd(se);
|
|
const r173 = Gesture.Tap();
|
|
const re = function re() {
|
|
if (onPress != null) {
|
|
_ReanimatedRexport.runOnJS(onPress)();
|
|
}
|
|
};
|
|
re.__closure = {
|
|
onPress,
|
|
runOnJS: _ReanimatedRexport.runOnJS
|
|
};
|
|
re.__workletHash = 4692146362189;
|
|
re.__initData = __initData14;
|
|
const r188 = {
|
|
gesture: Gesture.Race(r168, r173.onStart(re)),
|
|
draggableGridItemStyles: null
|
|
};
|
|
const ce = function ce() {
|
|
return {
|
|
transform: [{
|
|
translateX: sharedValue2.get() + (derivedValue4.get() - derivedValue2.get()) / 2
|
|
}, {
|
|
translateY: sharedValue4.get() + (derivedValue5.get() - derivedValue3.get()) / 2
|
|
}, {
|
|
scale: derivedValue.get()
|
|
}]
|
|
};
|
|
};
|
|
ce.__closure = {
|
|
xPosition: sharedValue2,
|
|
scaledWidthDv: derivedValue4,
|
|
widthDv: derivedValue2,
|
|
yPosition: sharedValue4,
|
|
scaledHeightDv: derivedValue5,
|
|
heightDv: derivedValue3,
|
|
pipScale: derivedValue
|
|
};
|
|
ce.__workletHash = 12534173786665;
|
|
ce.__initData = __initData15;
|
|
r188.draggableGridItemStyles = useAnimatedStyle(ce);
|
|
return r188;
|
|
}
|