Pinch Manipulator in Unity UI Toolkit

Hello. I have the following task: When a visual element is tapped once, it moves with the finger. When tapped twice, it either zooms in or out depending on whether the fingers are moving apart or together. The documentation (Unity - Manual: Manipulators) provides examples for both dragging and pinching, but all of them are separate and designed for single taps, not multiple. I have made numerous attempts, but none have been particularly successful so far.

Using the Input System while working with Unity UI allowed tracking the positions of multiple fingers simultaneously. However, here the pointerID is always 1 if only one finger is moving, and if two fingers are moving, two different OnPointerMove events are triggered, making it difficult to track the correct distance between the fingers.

Could you please help?