private static int calcHorizontalAlignment(JComponent jcomp) {
    int componentLeftInset;
    if (jcomp instanceof PopupAlignableComponent pac) {
      componentLeftInset = pac.getLeftGap();
    }
    else {
      componentLeftInset = jcomp.getInsets().left;
      if (jcomp instanceof AbstractButton button) {
        Insets margin = button.getMargin();
        if (margin != null) {
          componentLeftInset += margin.left;
        }
      }
    }
    int popupLeftInset = JBUI.CurrentTheme.Popup.Selection.LEFT_RIGHT_INSET.get() + JBUI.CurrentTheme.Popup.Selection.innerInsets().left;
    int res = componentLeftInset - popupLeftInset;
    return res;
  }
private static int calcHorizontalAlignment(JComponent jcomp)