// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import { forEach } from 'lodash';

export function classWithModifiers(className: string, modifiers?: string[] | Record<string, boolean>) {
  let ret = className;

  if (modifiers != null) {
    if (Array.isArray(modifiers)) {
      modifiers.forEach((modifier) => {
        if (modifier != null) {
          ret += ` ${className}--${modifier}`;
        }
      });
    } else {
      forEach(modifiers, (isActive, modifier) => {
        if (isActive) {
          ret += ` ${className}--${modifier}`;
        }
      });
    }
  }

  return ret;
}

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0.
// See the LICENCE file in the repository root for full licence text.

import { forEach } from 'lodash';

type Modifiers = (string | null | undefined)[] | Record<string, boolean | null | undefined>;

export function classWithModifiers(className: string, modifiers?: Modifiers) {
  let ret = className;

  if (modifiers != null) {
    if (Array.isArray(modifiers)) {
      modifiers.forEach((modifier) => {
        if (modifier != null) {
          ret += ` ${className}--${modifier}`;
        }
      });
    } else {
      forEach(modifiers, (isActive, modifier) => {
        if (isActive) {
          ret += ` ${className}--${modifier}`;
        }
      });
    }
  }

  return ret;
}

Revert "Apparently null is a-ok for array/record of things"
Revert "Apparently null is a-ok for array/record of things"

This reverts commit d182845e558bef14edf1978498c5c964f6187060.

It's a bug. Fixed somewhere between 3.7.2 and 3.9.5
