// generated by diplomat-tool
import wasm from "./diplomat-wasm.mjs";
import * as diplomatRuntime from "./diplomat-runtime.mjs";



/**
 * See the [Rust documentation for `BidiClass`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html) for more information.
 */
export class BidiClass {
    #value = undefined;

    static #values = new Map([
        ["LeftToRight", 0],
        ["RightToLeft", 1],
        ["EuropeanNumber", 2],
        ["EuropeanSeparator", 3],
        ["EuropeanTerminator", 4],
        ["ArabicNumber", 5],
        ["CommonSeparator", 6],
        ["ParagraphSeparator", 7],
        ["SegmentSeparator", 8],
        ["WhiteSpace", 9],
        ["OtherNeutral", 10],
        ["LeftToRightEmbedding", 11],
        ["LeftToRightOverride", 12],
        ["ArabicLetter", 13],
        ["RightToLeftEmbedding", 14],
        ["RightToLeftOverride", 15],
        ["PopDirectionalFormat", 16],
        ["NonspacingMark", 17],
        ["BoundaryNeutral", 18],
        ["FirstStrongIsolate", 19],
        ["LeftToRightIsolate", 20],
        ["RightToLeftIsolate", 21],
        ["PopDirectionalIsolate", 22]
    ]);

    static getAllEntries() {
        return BidiClass.#values.entries();
    }

    #internalConstructor(value) {
        if (arguments.length > 1 && arguments[0] === diplomatRuntime.internalConstructor) {
            // We pass in two internalConstructor arguments to create *new*
            // instances of this type, otherwise the enums are treated as singletons.
            if (arguments[1] === diplomatRuntime.internalConstructor ) {
                this.#value = arguments[2];
                return this;
            }
            return BidiClass.#objectValues[arguments[1]];
        }

        if (value instanceof BidiClass) {
            return value;
        }

        let intVal = BidiClass.#values.get(value);

        // Nullish check, checks for null or undefined
        if (intVal != null) {
            return BidiClass.#objectValues[intVal];
        }

        throw TypeError(value + " is not a BidiClass and does not correspond to any of its enumerator values.");
    }

    /** @internal */
    static fromValue(value) {
        return new BidiClass(value);
    }

    get value(){
        return [...BidiClass.#values.keys()][this.#value];
    }

    /** @internal */
    get ffiValue(){
        return this.#value;
    }
    static #objectValues = [
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 3),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 4),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 5),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 6),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 7),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 8),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 9),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 10),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 11),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 12),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 13),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 14),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 15),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 16),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 17),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 18),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 19),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 20),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 21),
        new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 22),
    ];

    /**
     * See the [Rust documentation for `LeftToRight`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.LeftToRight) for more information.
     */
    static LeftToRight = BidiClass.#objectValues[0];
    /**
     * See the [Rust documentation for `RightToLeft`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.RightToLeft) for more information.
     */
    static RightToLeft = BidiClass.#objectValues[1];
    /**
     * See the [Rust documentation for `EuropeanNumber`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.EuropeanNumber) for more information.
     */
    static EuropeanNumber = BidiClass.#objectValues[2];
    /**
     * See the [Rust documentation for `EuropeanSeparator`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.EuropeanSeparator) for more information.
     */
    static EuropeanSeparator = BidiClass.#objectValues[3];
    /**
     * See the [Rust documentation for `EuropeanTerminator`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.EuropeanTerminator) for more information.
     */
    static EuropeanTerminator = BidiClass.#objectValues[4];
    /**
     * See the [Rust documentation for `ArabicNumber`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.ArabicNumber) for more information.
     */
    static ArabicNumber = BidiClass.#objectValues[5];
    /**
     * See the [Rust documentation for `CommonSeparator`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.CommonSeparator) for more information.
     */
    static CommonSeparator = BidiClass.#objectValues[6];
    /**
     * See the [Rust documentation for `ParagraphSeparator`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.ParagraphSeparator) for more information.
     */
    static ParagraphSeparator = BidiClass.#objectValues[7];
    /**
     * See the [Rust documentation for `SegmentSeparator`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.SegmentSeparator) for more information.
     */
    static SegmentSeparator = BidiClass.#objectValues[8];
    /**
     * See the [Rust documentation for `WhiteSpace`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.WhiteSpace) for more information.
     */
    static WhiteSpace = BidiClass.#objectValues[9];
    /**
     * See the [Rust documentation for `OtherNeutral`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.OtherNeutral) for more information.
     */
    static OtherNeutral = BidiClass.#objectValues[10];
    /**
     * See the [Rust documentation for `LeftToRightEmbedding`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.LeftToRightEmbedding) for more information.
     */
    static LeftToRightEmbedding = BidiClass.#objectValues[11];
    /**
     * See the [Rust documentation for `LeftToRightOverride`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.LeftToRightOverride) for more information.
     */
    static LeftToRightOverride = BidiClass.#objectValues[12];
    /**
     * See the [Rust documentation for `ArabicLetter`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.ArabicLetter) for more information.
     */
    static ArabicLetter = BidiClass.#objectValues[13];
    /**
     * See the [Rust documentation for `RightToLeftEmbedding`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.RightToLeftEmbedding) for more information.
     */
    static RightToLeftEmbedding = BidiClass.#objectValues[14];
    /**
     * See the [Rust documentation for `RightToLeftOverride`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.RightToLeftOverride) for more information.
     */
    static RightToLeftOverride = BidiClass.#objectValues[15];
    /**
     * See the [Rust documentation for `PopDirectionalFormat`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.PopDirectionalFormat) for more information.
     */
    static PopDirectionalFormat = BidiClass.#objectValues[16];
    /**
     * See the [Rust documentation for `NonspacingMark`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.NonspacingMark) for more information.
     */
    static NonspacingMark = BidiClass.#objectValues[17];
    /**
     * See the [Rust documentation for `BoundaryNeutral`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.BoundaryNeutral) for more information.
     */
    static BoundaryNeutral = BidiClass.#objectValues[18];
    /**
     * See the [Rust documentation for `FirstStrongIsolate`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.FirstStrongIsolate) for more information.
     */
    static FirstStrongIsolate = BidiClass.#objectValues[19];
    /**
     * See the [Rust documentation for `LeftToRightIsolate`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.LeftToRightIsolate) for more information.
     */
    static LeftToRightIsolate = BidiClass.#objectValues[20];
    /**
     * See the [Rust documentation for `RightToLeftIsolate`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.RightToLeftIsolate) for more information.
     */
    static RightToLeftIsolate = BidiClass.#objectValues[21];
    /**
     * See the [Rust documentation for `PopDirectionalIsolate`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#associatedconstant.PopDirectionalIsolate) for more information.
     */
    static PopDirectionalIsolate = BidiClass.#objectValues[22];


    /**
     * See the [Rust documentation for `for_char`](https://docs.rs/icu/2.2.0/icu/properties/props/trait.EnumeratedProperty.html#tymethod.for_char) for more information.
     */
    static forChar(ch) {

        const result = wasm.icu4x_BidiClass_for_char_mv1(ch);

        try {
            return new BidiClass(diplomatRuntime.internalConstructor, result);
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * Get the "long" name of this property value (returns empty if property value is unknown)
     *
     * See the [Rust documentation for `get`](https://docs.rs/icu/2.2.0/icu/properties/struct.PropertyNamesLongBorrowed.html#method.get) for more information.
     */
    longName() {
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);


        const result = wasm.icu4x_BidiClass_long_name_mv1(diplomatReceive.buffer, this.ffiValue);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer,  "string8", []).getValue();
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            diplomatReceive.free();
        }
    }

    /**
     * Get the "short" name of this property value (returns empty if property value is unknown)
     *
     * See the [Rust documentation for `get`](https://docs.rs/icu/2.2.0/icu/properties/struct.PropertyNamesShortBorrowed.html#method.get) for more information.
     */
    shortName() {
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 9, 4, true);


        const result = wasm.icu4x_BidiClass_short_name_mv1(diplomatReceive.buffer, this.ffiValue);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new diplomatRuntime.DiplomatSliceStr(wasm, diplomatReceive.buffer,  "string8", []).getValue();
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            diplomatReceive.free();
        }
    }

    /**
     * Convert to an integer value usable with ICU4C and `CodePointMapData`
     *
     * See the [Rust documentation for `to_icu4c_value`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#method.to_icu4c_value) for more information.
     */
    toIntegerValue() {

        const result = wasm.icu4x_BidiClass_to_integer_value_mv1(this.ffiValue);

        try {
            return result;
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
        }
    }

    /**
     * Convert from an integer value from ICU4C or `CodePointMapData`
     *
     * See the [Rust documentation for `from_icu4c_value`](https://docs.rs/icu/2.2.0/icu/properties/props/struct.BidiClass.html#method.from_icu4c_value) for more information.
     */
    static fromIntegerValue(other) {
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);


        const result = wasm.icu4x_BidiClass_from_integer_value_mv1(diplomatReceive.buffer, other);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            diplomatReceive.free();
        }
    }

    static tryFromStr(s) {
        let functionCleanupArena = new diplomatRuntime.CleanupArena();

        const sSlice = functionCleanupArena.alloc(diplomatRuntime.DiplomatBuf.sliceWrapper(wasm, diplomatRuntime.DiplomatBuf.str8(wasm, s)));
        const diplomatReceive = new diplomatRuntime.DiplomatReceiveBuf(wasm, 5, 4, true);


        const result = wasm.icu4x_BidiClass_try_from_str_mv1(diplomatReceive.buffer, sSlice.ptr);

        try {
            if (!diplomatReceive.resultFlag) {
                return null;
            }
            return new BidiClass(diplomatRuntime.internalConstructor, diplomatRuntime.enumDiscriminant(wasm, diplomatReceive.buffer));
        }

        finally {
            diplomatRuntime.FUNCTION_PARAM_ALLOC.clean();
            functionCleanupArena.free();

            diplomatReceive.free();
        }
    }

    constructor(value) {
        return this.#internalConstructor(...arguments)
    }
}