import '../../../assert/js/assert.js';
import '../../../tandem/js/PhetioIDUtils.js';
import '../../../globals.js';
// Copyright 2022-2024, University of Colorado Boulder
/**
 * Rich enumeration for internal layout code
 *
 * NOTE: This is orientation-agnostic for a reason, so that it's natural with GridBox, and FlowBox can switch
 * orientation
 *
 * @author Jonathan Olson <jonathan.olson@colorado.edu>
 */
import Orientation from '../../../phet-core/js/Orientation.js';
import { scenery } from '../imports.js';
import EnumerationValue from '../../../phet-core/js/EnumerationValue.js';
import Enumeration from '../../../phet-core/js/Enumeration.js';
export const HorizontalLayoutAlignValues = ['left', 'right', 'center', 'origin'];
export const VerticalLayoutAlignValues = ['top', 'bottom', 'center', 'origin'];
export const RestrictedHorizontalLayoutAlignValues = ['left', 'right', 'center'];
export const RestrictedVerticalLayoutAlignValues = ['top', 'bottom', 'center'];
class LayoutAlign extends EnumerationValue {
    constructor(horizontal, vertical, padRatio = Number.POSITIVE_INFINITY) {
        super();
        this.horizontal = horizontal;
        this.vertical = vertical;
        this.padRatio = padRatio;
    }
    static getAllowedAligns(orientation) {
        return [...(orientation === Orientation.HORIZONTAL ? HorizontalLayoutAlignValues : VerticalLayoutAlignValues), null];
    }
    static getAllowedRestrictedAligns(orientation) {
        return [...(orientation === Orientation.HORIZONTAL ? RestrictedHorizontalLayoutAlignValues : RestrictedVerticalLayoutAlignValues), null];
    }
    // Converts a string union value into the internal Enumeration value
    static alignToInternal(orientation, key) {
        return orientation === Orientation.HORIZONTAL
            ? LayoutAlign.horizontalAlignToInternal(key)
            : LayoutAlign.verticalAlignToInternal(key);
    }
    static horizontalAlignToInternal(key) {
        if (key === null) {
            return null;
        }
        assert && assert(horizontalAlignMap[key]);
        return horizontalAlignMap[key];
    }
    static verticalAlignToInternal(key) {
        if (key === null) {
            return null;
        }
        assert && assert(verticalAlignMap[key]);
        return verticalAlignMap[key];
    }
    // Converts an internal Enumeration value into a string union value.
    static internalToAlign(orientation, align) {
        if (align === null) {
            return null;
        }
        else if (orientation === Orientation.HORIZONTAL) {
            return align.horizontal;
        }
        else {
            return align.vertical;
        }
    }
}
LayoutAlign.START = new LayoutAlign('left', 'top', 0);
LayoutAlign.END = new LayoutAlign('right', 'bottom', 1);
LayoutAlign.CENTER = new LayoutAlign('center', 'center', 0.5);
LayoutAlign.ORIGIN = new LayoutAlign('origin', 'origin');
LayoutAlign.enumeration = new Enumeration(LayoutAlign, {
    phetioDocumentation: 'Alignment for layout containers'
});
export default LayoutAlign;
const horizontalAlignMap = {
    left: LayoutAlign.START,
    right: LayoutAlign.END,
    center: LayoutAlign.CENTER,
    origin: LayoutAlign.ORIGIN
};
const verticalAlignMap = {
    top: LayoutAlign.START,
    bottom: LayoutAlign.END,
    center: LayoutAlign.CENTER,
    origin: LayoutAlign.ORIGIN
};
scenery.register('LayoutAlign', LayoutAlign);
//# sourceMappingURL=LayoutAlign.js.map