/**
 * @param {HTMLElement} contentInlay
 */
export function preparePage(contentInlay) {
  /** @type {HTMLButtonElement|undefined} */
  const btnVisibleToVollzugriff =
    contentInlay.querySelector('.privilege-set-visible-to-vollzugriff') ?? undefined;
  if (btnVisibleToVollzugriff) {
    btnVisibleToVollzugriff.addEventListener('click', () => {
      const privilegesAccessRadios =
        Array.from(contentInlay.querySelectorAll('input[type=radio].privilege-access[value="2"]'))
          .filter(radioInput => {
            return !!radioInput.offsetParent;
          });

      for (const radioInput of privilegesAccessRadios) {
        radioInput.checked = true;
      }
    }, {passive: true});
    btnVisibleToVollzugriff.disabled = false;
  }
}