import '../../../assert/js/assert.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 Enumeration from '../../../phet-core/js/Enumeration.js';
import EnumerationValue from '../../../phet-core/js/EnumerationValue.js';
import Orientation from '../../../phet-core/js/Orientation.js';
import { scenery } from '../imports.js';
export const HorizontalLayoutJustificationValues = ['left', 'right', 'center', 'spaceBetween', 'spaceAround', 'spaceEvenly'];
export const VerticalLayoutJustificationValues = ['top', 'bottom', 'center', 'spaceBetween', 'spaceAround', 'spaceEvenly'];
class LayoutJustification extends EnumerationValue {
    constructor(spacingFunctionFactory, horizontal, vertical) {
        super();
        this.spacingFunctionFactory = spacingFunctionFactory;
        this.horizontal = horizontal;
        this.vertical = vertical;
    }
    static getAllowedJustificationValues(orientation) {
        return orientation === Orientation.HORIZONTAL ? HorizontalLayoutJustificationValues : VerticalLayoutJustificationValues;
    }
    // Converts a string union value into the internal Enumeration value
    static justifyToInternal(orientation, key) {
        if (orientation === Orientation.HORIZONTAL) {
            assert && assert(horizontalJustificationMap[key]);
            return horizontalJustificationMap[key];
        }
        else {
            assert && assert(verticalJustificationMap[key]);
            return verticalJustificationMap[key];
        }
    }
    // Converts an internal Enumeration value into a string union value.
    static internalToJustify(orientation, justify) {
        if (orientation === Orientation.HORIZONTAL) {
            return justify.horizontal;
        }
        else {
            return justify.vertical;
        }
    }
}
LayoutJustification.START = new LayoutJustification(() => () => 0, 'left', 'top');
LayoutJustification.END = new LayoutJustification(spaceRemaining => index => index === 0 ? spaceRemaining : 0, 'right', 'bottom');
LayoutJustification.CENTER = new LayoutJustification(spaceRemaining => index => index === 0 ? spaceRemaining / 2 : 0, 'center', 'center');
LayoutJustification.SPACE_BETWEEN = new LayoutJustification((spaceRemaining, lineLength) => index => index !== 0 ? (spaceRemaining / (lineLength - 1)) : 0, 'spaceBetween', 'spaceBetween');
LayoutJustification.SPACE_AROUND = new LayoutJustification((spaceRemaining, lineLength) => index => (index !== 0 ? 2 : 1) * spaceRemaining / (2 * lineLength), 'spaceAround', 'spaceAround');
LayoutJustification.SPACE_EVENLY = new LayoutJustification((spaceRemaining, lineLength) => index => spaceRemaining / (lineLength + 1), 'spaceEvenly', 'spaceEvenly');
LayoutJustification.enumeration = new Enumeration(LayoutJustification, {
    phetioDocumentation: 'Justify for layout containers'
});
export default LayoutJustification;
const horizontalJustificationMap = {
    left: LayoutJustification.START,
    right: LayoutJustification.END,
    center: LayoutJustification.CENTER,
    spaceBetween: LayoutJustification.SPACE_BETWEEN,
    spaceAround: LayoutJustification.SPACE_AROUND,
    spaceEvenly: LayoutJustification.SPACE_EVENLY
};
const verticalJustificationMap = {
    top: LayoutJustification.START,
    bottom: LayoutJustification.END,
    center: LayoutJustification.CENTER,
    spaceBetween: LayoutJustification.SPACE_BETWEEN,
    spaceAround: LayoutJustification.SPACE_AROUND,
    spaceEvenly: LayoutJustification.SPACE_EVENLY
};
scenery.register('LayoutJustification', LayoutJustification);
//# sourceMappingURL=LayoutJustification.js.map