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



/**
 * See the [Rust documentation for `WordType`](https://docs.rs/icu/2.2.0/icu/segmenter/options/enum.WordType.html) for more information.
 */
export class SegmenterWordType {
    #value = undefined;

    static #values = new Map([
        ["None", 0],
        ["Number", 1],
        ["Letter", 2]
    ]);

    static getAllEntries() {
        return SegmenterWordType.#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 SegmenterWordType.#objectValues[arguments[1]];
        }

        if (value instanceof SegmenterWordType) {
            return value;
        }

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

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

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

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

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

    /** @internal */
    get ffiValue(){
        return this.#value;
    }
    static #objectValues = [
        new SegmenterWordType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 0),
        new SegmenterWordType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 1),
        new SegmenterWordType(diplomatRuntime.internalConstructor, diplomatRuntime.internalConstructor, 2),
    ];

    static None = SegmenterWordType.#objectValues[0];
    static Number = SegmenterWordType.#objectValues[1];
    static Letter = SegmenterWordType.#objectValues[2];


    /**
     * See the [Rust documentation for `is_word_like`](https://docs.rs/icu/2.2.0/icu/segmenter/options/enum.WordType.html#method.is_word_like) for more information.
     */
    get isWordLike() {

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

        try {
            return result;
        }

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

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