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



/**
 * Additional information: [1](https://docs.rs/icu/2.2.0/icu/locale/enum.ParseError.html)
 */
export class LocaleParseError {
    #value = undefined;

    static #values = new Map([
        ["Unknown", 0],
        ["Language", 1],
        ["Subtag", 2],
        ["Extension", 3]
    ]);

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

        if (value instanceof LocaleParseError) {
            return value;
        }

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

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

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

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

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

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

    static Unknown = LocaleParseError.#objectValues[0];
    static Language = LocaleParseError.#objectValues[1];
    static Subtag = LocaleParseError.#objectValues[2];
    static Extension = LocaleParseError.#objectValues[3];


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