private @NotNull JComponent createConsentElement(Consent consent, boolean addCheckBox) {
    //TODO: refactor DocumentationComponent to use external link marker here, there and everywhere
    final JPanel pane;
    final boolean dataSharingDisabledExternally = ConsentOptions.getInstance().isUsageStatsConsent(consent)
                                                  && StatisticsUploadAssistant.isCollectionForceDisabled();
    final boolean dataSharingEnabledByFreeLicense = ConsentOptions.getInstance().isUsageStatsConsent(consent)
                                                  && isAllowedByFreeLicense();
    if (addCheckBox) {
      String checkBoxText = StringUtil.capitalize(StringUtil.toLowerCase(consent.getName()));
      if (ConsentOptions.getInstance().isEAP()) {
        if (ConsentOptions.condUsageStatsConsent().test(consent)) {
          checkBoxText = IdeBundle.message("gdpr.checkbox.when.using.eap.versions", checkBoxText);
        }
      }
      final JCheckBox cb = new JBCheckBox(checkBoxText, consent.isAccepted());
      ConsentStateSupplier stateSupplier;
      if (dataSharingDisabledExternally || dataSharingEnabledByFreeLicense) {
        stateSupplier = new ConsentStateSupplier(consent, () -> consent.isAccepted());
        cb.setEnabled(false);
        cb.setSelected(!dataSharingDisabledExternally);
      }
      else {
        stateSupplier = new ConsentStateSupplier(consent, () -> cb.isSelected());
      }
      //noinspection HardCodedStringLiteral
      pane = UI.PanelFactory.panel(cb).withComment(getParagraphTag()
                                                   +StringUtil.replace(consent.getText(), "\n", "</p>"+getParagraphTag())+"</p>").createPanel();
      cb.setOpaque(false);
      consentMapping.add(stateSupplier);
    } else {
      pane = new JPanel(new BorderLayout());
      final JEditorPane viewer = SwingHelper.createHtmlViewer(true, null, JBColor.WHITE, JBColor.BLACK);
      viewer.setOpaque(false);
      viewer.setFocusable(false);
      UIUtil.doNotScrollToCaret(viewer);
      viewer.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        protected void hyperlinkActivated(@NotNull HyperlinkEvent e) {
          final URL url = e.getURL();
          if (url != null) {
            BrowserUtil.browse(url);
          }
        }
      });
      viewer.setText("<html><body>" + replaceParagraphs(consent.getText()) + "</body></html>");
      StyleSheet styleSheet = ((HTMLDocument)viewer.getDocument()).getStyleSheet();
      //styleSheet.addRule("body {font-family: \"Segoe UI\", Tahoma, sans-serif;}");
      styleSheet.addRule("body {margin-top:0;padding-top:0;}");
      //styleSheet.addRule("body {font-size:" + JBUI.scaleFontSize(13) + "pt;}");
      styleSheet.addRule("h2, em {margin-top:" + JBUIScale.scaleFontSize((float)20) + "pt;}");
      styleSheet.addRule("h1, h2, h3, p, h4, em {margin-bottom:0;padding-bottom:0;}");
      styleSheet.addRule("p, h1 {margin-top:0;padding-top:" + JBUIScale.scaleFontSize((float)6) + "pt;}");
      styleSheet.addRule("li {margin-bottom:" + JBUIScale.scaleFontSize((float)6) + "pt;}");
      styleSheet.addRule("h2 {margin-top:0;padding-top:" + JBUIScale.scaleFontSize((float)13) + "pt;}");
      styleSheet.addRule("a, a:link {color:#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.ENABLED) + ";}");
      styleSheet.addRule("a:hover {color:#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.HOVERED) + ";}");
      styleSheet.addRule("a:active {color:#" + ColorUtil.toHex(JBUI.CurrentTheme.Link.Foreground.PRESSED) + ";}");
      viewer.setCaretPosition(0);
      pane.add(viewer, BorderLayout.CENTER);
      consentMapping.add(new ConsentStateSupplier(consent, () -> true));
    }
    pane.setOpaque(false);

    if (dataSharingDisabledExternally) return wrapPanelWithWarning(pane, Objects.requireNonNullElse(StatisticsUploadAssistant.getConsentWarning(),
                                                                                                    IdeBundle.message("gdpr.usage.statistics.disabled.externally.warning")));
    if (dataSharingEnabledByFreeLicense) return wrapPanelWithWarning(pane, IdeBundle.message("gdpr.usage.statistics.enabled.for.free.license.warning"));
    return pane;
  }
private @NotNull JComponent createConsentElement(Consent consent, boolean addCheckBox)