Spreading objects of varied sizes on XY so that the distance between them is equal?

Hello,
I have a collection with several objects in it of different sizes (the number of objects is not known in advance)

I’m looking for a way using Geometry Nodes to take this group and scatter it in XY so that they are fairly close to each other but not touching.

In the meantime, what I did was creating a grid whose size should be sufficient for the number of instances, give an initial distance to get a large enough surface on which all the instances will be spread without touching each other.
(Suppose I have 21 instances, then I create a 5x5 grid and scatter points on it with a minimum distance of the same initial distance and then delete unnecessary points to get exactly 21 points and then scatter all the instances on it in their order)

Problems I encountered:

  1. A way to save each instance its size in order to later calculate its relative position with it.
  2. A way to find the distance between each instance and the instances next to it.
  3. Reducing the distance between the instances to a minimum that would allow proximity between them but not contact.