Geometry nodes sampling indices from selection

Hello I have curves, capturing the endpoint sel. 01, then split in corner points and creating instances on points at endpoint sel 10 “or” captured 01. Then I want to trim the curve corner split parts by 1/2 instance X size.

I can easily sample the 1/2 X for the trim curve start, the problem comes when combination of the “10 “or” captured 01” comes to play for the trim curve end for the last instance. I hope the images are selfexplaining. (workaround is to distribute the instances on the curve before split and sample X on this, but I am curious for this solution).

Not sure I am on the right way, but my intention now is to separate the “10 “or” captured 01” points, get their indices and sample the X on this. But how to get the indices for the sampling from this selection?

thanks!
trim.blend (1.4 MB)



here is the “workaround” solution mentioned above, still wondering how this is possible with endpoint selections.
trim1.blend (2.0 MB)