/** This class retrieves a specific error container element nested within a sibling container of a given input element. */
export class SiblingContainerNestedErrorContainerRetrievalStrategy {
  /**
   * The function searches for an element with the class 'vega-error' in the next sibling of the
   * inputContainer and returns it if found.
   *
   * @param {HTMLElement} inputContainer - The `inputContainer` parameter is an HTMLElement that
   * represents the container element containing some input element.
   * @returns { Nullable<HTMLElement>} An HTMLElement with the class 'vega-error' that is a sibling of the inputContainer, if
   * it exists. Otherwise, null is returned.
   */
  run(inputContainer) {
    const siblingContainer = inputContainer.nextElementSibling;
    if (siblingContainer && siblingContainer.querySelector('.vega-error')) {
      return siblingContainer.querySelector('.vega-error');
    }
    return null;
  }
}
