/* @ts-self-types="./lastid_sdk.d.ts" */

/**
 * Age proof credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * // Verify user is at least 21
 * const policy = new AgeProofPolicy()
 *     .atLeast(21)
 *     .withCallback("https://yourapp.com/callback");
 *
 * // Verify user is between 18 and 65
 * const policy2 = new AgeProofPolicy()
 *     .between(18, 65)
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class AgeProofPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(AgeProofPolicy.prototype);
        obj.__wbg_ptr = ptr;
        AgeProofPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        AgeProofPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_ageproofpolicy_free(ptr, 0);
    }
    /**
     * Require user to be at least the specified age (>=).
     * @param {number} age
     * @returns {AgeProofPolicy}
     */
    atLeast(age) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.ageproofpolicy_atLeast(ptr, age);
        return AgeProofPolicy.__wrap(ret);
    }
    /**
     * Require user to be at most the specified age (<=).
     * @param {number} age
     * @returns {AgeProofPolicy}
     */
    atMost(age) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.ageproofpolicy_atMost(ptr, age);
        return AgeProofPolicy.__wrap(ret);
    }
    /**
     * Require user to be within the specified age range (inclusive).
     * @param {number} min_age
     * @param {number} max_age
     * @returns {AgeProofPolicy}
     */
    between(min_age, max_age) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.ageproofpolicy_between(ptr, min_age, max_age);
        return AgeProofPolicy.__wrap(ret);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.ageproofpolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * Require user to be exactly the specified age.
     * @param {number} age
     * @returns {AgeProofPolicy}
     */
    exactly(age) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.ageproofpolicy_exactly(ptr, age);
        return AgeProofPolicy.__wrap(ret);
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.ageproofpolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.ageproofpolicy_new();
        this.__wbg_ptr = ret >>> 0;
        AgeProofPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * Require user to be over the specified age (>).
     * @param {number} age
     * @returns {AgeProofPolicy}
     */
    over(age) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.ageproofpolicy_over(ptr, age);
        return AgeProofPolicy.__wrap(ret);
    }
    /**
     * Require user to be under the specified age (<).
     * @param {number} age
     * @returns {AgeProofPolicy}
     */
    under(age) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.ageproofpolicy_under(ptr, age);
        return AgeProofPolicy.__wrap(ret);
    }
    /**
     * @param {string} url
     * @returns {AgeProofPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.ageproofpolicy_withCallback(ptr, ptr0, len0);
        return AgeProofPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) AgeProofPolicy.prototype[Symbol.dispose] = AgeProofPolicy.prototype.free;
exports.AgeProofPolicy = AgeProofPolicy;

/**
 * Base credential policy builder for WASM.
 *
 * Creates a policy for requesting the basic user DID credential.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new BaseCredentialPolicy()
 *     .withState("csrf-token")
 *     .withNonce("binding-nonce")
 *     .withCallback("https://yourapp.com/callback");
 *
 * const response = await client.requestCredential(policy);
 * ```
 */
class BaseCredentialPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(BaseCredentialPolicy.prototype);
        obj.__wbg_ptr = ptr;
        BaseCredentialPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        BaseCredentialPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_basecredentialpolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.basecredentialpolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.basecredentialpolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.basecredentialpolicy_new();
        this.__wbg_ptr = ret >>> 0;
        BaseCredentialPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {string} url
     * @returns {BaseCredentialPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.basecredentialpolicy_withCallback(ptr, ptr0, len0);
        return BaseCredentialPolicy.__wrap(ret);
    }
    /**
     * @param {string} nonce
     * @returns {BaseCredentialPolicy}
     */
    withNonce(nonce) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(nonce, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.basecredentialpolicy_withNonce(ptr, ptr0, len0);
        return BaseCredentialPolicy.__wrap(ret);
    }
    /**
     * @param {string} state
     * @returns {BaseCredentialPolicy}
     */
    withState(state) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(state, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.basecredentialpolicy_withState(ptr, ptr0, len0);
        return BaseCredentialPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) BaseCredentialPolicy.prototype[Symbol.dispose] = BaseCredentialPolicy.prototype.free;
exports.BaseCredentialPolicy = BaseCredentialPolicy;

/**
 * Employment credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new EmploymentPolicy()
 *     .withEmployerDomain("acme.com")
 *     .withStatus("Current")
 *     .withFields(["company", "title"])
 *     .withOptionalFields(["department", "start_date"])
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class EmploymentPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(EmploymentPolicy.prototype);
        obj.__wbg_ptr = ptr;
        EmploymentPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        EmploymentPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_employmentpolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.employmentpolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.employmentpolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.employmentpolicy_new();
        this.__wbg_ptr = ret >>> 0;
        EmploymentPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {string} url
     * @returns {EmploymentPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withCallback(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
    /**
     * Constrain to a specific employer domain (e.g., "example.com").
     * @param {string} domain
     * @returns {EmploymentPolicy}
     */
    withEmployerDomain(domain) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withEmployerDomain(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
    /**
     * @param {string} field
     * @returns {EmploymentPolicy}
     */
    withField(field) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withField(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
    /**
     * Add required fields that must be disclosed.
     * Valid fields: company, title, department, start_date, end_date,
     * is_current, responsibilities
     * @param {string[]} fields
     * @returns {EmploymentPolicy}
     */
    withFields(fields) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withFields(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
    /**
     * @param {string} field
     * @returns {EmploymentPolicy}
     */
    withOptionalField(field) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withOptionalField(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
    /**
     * Add optional fields that the user can choose to disclose.
     * Valid fields: company, title, department, start_date, end_date,
     * is_current, responsibilities
     * @param {string[]} fields
     * @returns {EmploymentPolicy}
     */
    withOptionalFields(fields) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withOptionalFields(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
    /**
     * Set the required employment status: Current, Former, or Any.
     * @param {string} status
     * @returns {EmploymentPolicy}
     */
    withStatus(status) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(status, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.employmentpolicy_withStatus(ptr, ptr0, len0);
        return EmploymentPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) EmploymentPolicy.prototype[Symbol.dispose] = EmploymentPolicy.prototype.free;
exports.EmploymentPolicy = EmploymentPolicy;

/**
 * Error codes for programmatic error handling in JavaScript.
 *
 * These codes allow TypeScript developers to handle errors programmatically
 * without parsing error message strings.
 * @enum {1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 99}
 */
const ErrorCode = Object.freeze({
    /**
     * Configuration error (invalid endpoint, missing client_id, etc.)
     */
    ConfigError: 1, "1": "ConfigError",
    /**
     * Network error (connection failed, timeout, DNS resolution)
     */
    NetworkError: 2, "2": "NetworkError",
    /**
     * Authentication error (invalid credentials, token expired)
     */
    AuthError: 3, "3": "AuthError",
    /**
     * Policy validation error (missing required fields, invalid constraints)
     */
    PolicyError: 4, "4": "PolicyError",
    /**
     * Credential verification error (signature invalid, expired, revoked)
     */
    VerificationError: 5, "5": "VerificationError",
    /**
     * Trust registry error (issuer not found, suspended, unauthorized)
     */
    TrustError: 6, "6": "TrustError",
    /**
     * Request not found (404 from IDP)
     */
    NotFoundError: 7, "7": "NotFoundError",
    /**
     * Request expired (credential request timed out)
     */
    ExpiredError: 8, "8": "ExpiredError",
    /**
     * Request denied by user
     */
    DeniedError: 9, "9": "DeniedError",
    /**
     * Rate limited by IDP
     */
    RateLimitError: 10, "10": "RateLimitError",
    /**
     * Internal SDK error (unexpected state)
     */
    InternalError: 99, "99": "InternalError",
});
exports.ErrorCode = ErrorCode;

/**
 * Structured error for JavaScript with code, message, and optional details.
 *
 * This provides a better developer experience than plain string errors,
 * allowing programmatic error handling in TypeScript.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * try {
 *     const response = await client.requestCredential(policy);
 * } catch (error) {
 *     if (error.code === 'NETWORK_ERROR') {
 *         // Retry with backoff
 *     } else if (error.code === 'POLICY_ERROR') {
 *         // Show validation errors to user
 *         console.error(error.details);
 *     }
 * }
 * ```
 */
class LastIDError {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(LastIDError.prototype);
        obj.__wbg_ptr = ptr;
        LastIDErrorFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        LastIDErrorFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_lastiderror_free(ptr, 0);
    }
    /**
     * Get the error code string (e.g., "NETWORK_ERROR").
     * @returns {string}
     */
    get code() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.lastiderror_code(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * Get additional error details (if available).
     * @returns {string | undefined}
     */
    get details() {
        const ret = wasm.lastiderror_details(this.__wbg_ptr);
        let v1;
        if (ret[0] !== 0) {
            v1 = getStringFromWasm0(ret[0], ret[1]).slice();
            wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
        }
        return v1;
    }
    /**
     * Check if this error is retryable.
     * @returns {boolean}
     */
    get isRetryable() {
        const ret = wasm.lastiderror_isRetryable(this.__wbg_ptr);
        return ret !== 0;
    }
    /**
     * Get the human-readable error message.
     * @returns {string}
     */
    get message() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.lastiderror_message(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * Create a new error.
     * @param {ErrorCode} code
     * @param {string} message
     */
    constructor(code, message) {
        const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.lastiderror_new(code, ptr0, len0);
        this.__wbg_ptr = ret >>> 0;
        LastIDErrorFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * Get the numeric error code for switch statements.
     * @returns {number}
     */
    get numericCode() {
        const ret = wasm.lastiderror_numericCode(this.__wbg_ptr);
        return ret >>> 0;
    }
    /**
     * Get a suggested retry delay in milliseconds (if retryable).
     * @returns {number | undefined}
     */
    get suggestedRetryMs() {
        const ret = wasm.lastiderror_suggestedRetryMs(this.__wbg_ptr);
        return ret === 0x100000001 ? undefined : ret;
    }
    /**
     * Create an error with additional details.
     * @param {ErrorCode} code
     * @param {string} message
     * @param {string} details
     * @returns {LastIDError}
     */
    static with_details(code, message, details) {
        const ptr0 = passStringToWasm0(message, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(details, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len1 = WASM_VECTOR_LEN;
        const ret = wasm.lastiderror_with_details(code, ptr0, len0, ptr1, len1);
        return LastIDError.__wrap(ret);
    }
}
if (Symbol.dispose) LastIDError.prototype[Symbol.dispose] = LastIDError.prototype.free;
exports.LastIDError = LastIDError;

/**
 * Persona credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new PersonaPolicy()
 *     .withFields(["display_name", "email"])
 *     .withOptionalFields(["phone", "company"])
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class PersonaPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(PersonaPolicy.prototype);
        obj.__wbg_ptr = ptr;
        PersonaPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        PersonaPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_personapolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.personapolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.personapolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.personapolicy_new();
        this.__wbg_ptr = ret >>> 0;
        PersonaPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {string} url
     * @returns {PersonaPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.basecredentialpolicy_withNonce(ptr, ptr0, len0);
        return PersonaPolicy.__wrap(ret);
    }
    /**
     * @param {string} field
     * @returns {PersonaPolicy}
     */
    withField(field) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.personapolicy_withField(ptr, ptr0, len0);
        return PersonaPolicy.__wrap(ret);
    }
    /**
     * Add required fields that must be disclosed.
     * Valid fields: display_name, email, phone, company, job_title,
     * avatar_url, website, location, visibility
     * @param {string[]} fields
     * @returns {PersonaPolicy}
     */
    withFields(fields) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.personapolicy_withFields(ptr, ptr0, len0);
        return PersonaPolicy.__wrap(ret);
    }
    /**
     * @param {string} field
     * @returns {PersonaPolicy}
     */
    withOptionalField(field) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.personapolicy_withOptionalField(ptr, ptr0, len0);
        return PersonaPolicy.__wrap(ret);
    }
    /**
     * Add optional fields that the user can choose to disclose.
     * Valid fields: display_name, email, phone, company, job_title,
     * avatar_url, website, location, visibility
     * @param {string[]} fields
     * @returns {PersonaPolicy}
     */
    withOptionalFields(fields) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.personapolicy_withOptionalFields(ptr, ptr0, len0);
        return PersonaPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) PersonaPolicy.prototype[Symbol.dispose] = PersonaPolicy.prototype.free;
exports.PersonaPolicy = PersonaPolicy;

/**
 * Trust credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new TrustPolicy()
 *     .withMinimumLevel("Verified")
 *     .withTrustedIssuer("did:lastid:trusted-org")
 *     .requireMutualTrust()
 *     .withMaxAgeDays(30)
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class TrustPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(TrustPolicy.prototype);
        obj.__wbg_ptr = ptr;
        TrustPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        TrustPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_trustpolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.trustpolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.trustpolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.trustpolicy_new();
        this.__wbg_ptr = ret >>> 0;
        TrustPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * Require mutual trust (both parties have established trust).
     * @returns {TrustPolicy}
     */
    requireMutualTrust() {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.trustpolicy_requireMutualTrust(ptr);
        return TrustPolicy.__wrap(ret);
    }
    /**
     * @param {string} url
     * @returns {TrustPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.trustpolicy_withCallback(ptr, ptr0, len0);
        return TrustPolicy.__wrap(ret);
    }
    /**
     * Set maximum age of the trust credential in days.
     * @param {number} days
     * @returns {TrustPolicy}
     */
    withMaxAgeDays(days) {
        const ptr = this.__destroy_into_raw();
        const ret = wasm.trustpolicy_withMaxAgeDays(ptr, days);
        return TrustPolicy.__wrap(ret);
    }
    /**
     * Set the minimum required trust level: None, Basic, Verified, High, or
     * Ultimate.
     * @param {string} level
     * @returns {TrustPolicy}
     */
    withMinimumLevel(level) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.trustpolicy_withMinimumLevel(ptr, ptr0, len0);
        return TrustPolicy.__wrap(ret);
    }
    /**
     * Add a trusted issuer DID that must have established trust.
     * @param {string} issuer_did
     * @returns {TrustPolicy}
     */
    withTrustedIssuer(issuer_did) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(issuer_did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.trustpolicy_withTrustedIssuer(ptr, ptr0, len0);
        return TrustPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) TrustPolicy.prototype[Symbol.dispose] = TrustPolicy.prototype.free;
exports.TrustPolicy = TrustPolicy;

/**
 * Verified email credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new VerifiedEmailPolicy()
 *     .withDomainConstraint("company.com")
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class VerifiedEmailPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(VerifiedEmailPolicy.prototype);
        obj.__wbg_ptr = ptr;
        VerifiedEmailPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        VerifiedEmailPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_verifiedemailpolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.verifiedemailpolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.verifiedemailpolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.verifiedemailpolicy_new();
        this.__wbg_ptr = ret >>> 0;
        VerifiedEmailPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {string} url
     * @returns {VerifiedEmailPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedemailpolicy_withCallback(ptr, ptr0, len0);
        return VerifiedEmailPolicy.__wrap(ret);
    }
    /**
     * Add a domain constraint (e.g., "example.com" requires @example.com
     * emails).
     * @param {string} domain
     * @returns {VerifiedEmailPolicy}
     */
    withDomainConstraint(domain) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(domain, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedemailpolicy_withDomainConstraint(ptr, ptr0, len0);
        return VerifiedEmailPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) VerifiedEmailPolicy.prototype[Symbol.dispose] = VerifiedEmailPolicy.prototype.free;
exports.VerifiedEmailPolicy = VerifiedEmailPolicy;

/**
 * Verified persona (KYC) credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new VerifiedPersonaPolicy()
 *     .withVerificationLevel("Enhanced")
 *     .withFields(["legal_name", "date_of_birth"])
 *     .withOptionalFields(["nationality", "residential_address"])
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class VerifiedPersonaPolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(VerifiedPersonaPolicy.prototype);
        obj.__wbg_ptr = ptr;
        VerifiedPersonaPolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        VerifiedPersonaPolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_verifiedpersonapolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.verifiedpersonapolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.verifiedpersonapolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.verifiedpersonapolicy_new();
        this.__wbg_ptr = ret >>> 0;
        VerifiedPersonaPolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {string} url
     * @returns {VerifiedPersonaPolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedpersonapolicy_withCallback(ptr, ptr0, len0);
        return VerifiedPersonaPolicy.__wrap(ret);
    }
    /**
     * @param {string} field
     * @returns {VerifiedPersonaPolicy}
     */
    withField(field) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedpersonapolicy_withField(ptr, ptr0, len0);
        return VerifiedPersonaPolicy.__wrap(ret);
    }
    /**
     * Add required fields that must be disclosed.
     * Valid fields: legal_name, first_name, last_name, date_of_birth, age,
     * nationality, residential_address, structured_address, government_id_type,
     * document_number, liveness_score, face_match_score
     * @param {string[]} fields
     * @returns {VerifiedPersonaPolicy}
     */
    withFields(fields) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedpersonapolicy_withFields(ptr, ptr0, len0);
        return VerifiedPersonaPolicy.__wrap(ret);
    }
    /**
     * @param {string} field
     * @returns {VerifiedPersonaPolicy}
     */
    withOptionalField(field) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(field, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedpersonapolicy_withOptionalField(ptr, ptr0, len0);
        return VerifiedPersonaPolicy.__wrap(ret);
    }
    /**
     * Add optional fields that the user can choose to disclose.
     * Valid fields: legal_name, first_name, last_name, date_of_birth, age,
     * nationality, residential_address, structured_address, government_id_type,
     * document_number, liveness_score, face_match_score
     * @param {string[]} fields
     * @returns {VerifiedPersonaPolicy}
     */
    withOptionalFields(fields) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passArrayJsValueToWasm0(fields, wasm.__wbindgen_malloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedpersonapolicy_withOptionalFields(ptr, ptr0, len0);
        return VerifiedPersonaPolicy.__wrap(ret);
    }
    /**
     * Set the required verification level: Basic, Standard, or Enhanced.
     * @param {string} level
     * @returns {VerifiedPersonaPolicy}
     */
    withVerificationLevel(level) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedpersonapolicy_withVerificationLevel(ptr, ptr0, len0);
        return VerifiedPersonaPolicy.__wrap(ret);
    }
}
if (Symbol.dispose) VerifiedPersonaPolicy.prototype[Symbol.dispose] = VerifiedPersonaPolicy.prototype.free;
exports.VerifiedPersonaPolicy = VerifiedPersonaPolicy;

/**
 * Verified phone credential policy builder for WASM.
 *
 * # JavaScript Usage
 *
 * ```javascript
 * const policy = new VerifiedPhonePolicy()
 *     .withCountryCode("+1")
 *     .withCallback("https://yourapp.com/callback");
 * ```
 */
class VerifiedPhonePolicy {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(VerifiedPhonePolicy.prototype);
        obj.__wbg_ptr = ptr;
        VerifiedPhonePolicyFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        VerifiedPhonePolicyFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_verifiedphonepolicy_free(ptr, 0);
    }
    /**
     * @returns {string}
     */
    get credentialType() {
        let deferred1_0;
        let deferred1_1;
        try {
            const ret = wasm.verifiedphonepolicy_credentialType(this.__wbg_ptr);
            deferred1_0 = ret[0];
            deferred1_1 = ret[1];
            return getStringFromWasm0(ret[0], ret[1]);
        } finally {
            wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
        }
    }
    /**
     * @returns {boolean}
     */
    get isComplete() {
        const ret = wasm.verifiedemailpolicy_isComplete(this.__wbg_ptr);
        return ret !== 0;
    }
    constructor() {
        const ret = wasm.verifiedemailpolicy_new();
        this.__wbg_ptr = ret >>> 0;
        VerifiedPhonePolicyFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * @param {string} url
     * @returns {VerifiedPhonePolicy}
     */
    withCallback(url) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedemailpolicy_withCallback(ptr, ptr0, len0);
        return VerifiedPhonePolicy.__wrap(ret);
    }
    /**
     * Add a country code constraint (e.g., "+1" for US numbers).
     * @param {string} code
     * @returns {VerifiedPhonePolicy}
     */
    withCountryCode(code) {
        const ptr = this.__destroy_into_raw();
        const ptr0 = passStringToWasm0(code, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.verifiedemailpolicy_withDomainConstraint(ptr, ptr0, len0);
        return VerifiedPhonePolicy.__wrap(ret);
    }
}
if (Symbol.dispose) VerifiedPhonePolicy.prototype[Symbol.dispose] = VerifiedPhonePolicy.prototype.free;
exports.VerifiedPhonePolicy = VerifiedPhonePolicy;

/**
 * JavaScript-friendly `LastID` client.
 *
 * Provides methods to request credentials, poll for status, and verify
 * presentations.
 */
class WasmClient {
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        WasmClientFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_wasmclient_free(ptr, 0);
    }
    /**
     * Create a new client with the given configuration.
     *
     * The client will automatically manage OAuth token acquisition and
     * refresh.
     *
     * @param config - The SDK configuration
     * @throws Error if the configuration is invalid
     * @param {WasmConfig} config
     */
    constructor(config) {
        _assertClass(config, WasmConfig);
        const ret = wasm.wasmclient_new(config.__wbg_ptr);
        if (ret[2]) {
            throw takeFromExternrefTable0(ret[1]);
        }
        this.__wbg_ptr = ret[0] >>> 0;
        WasmClientFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * Poll for request status.
     *
     * Returns the status as a JSON object.
     * @param {string} request_id
     * @returns {Promise<any>}
     */
    pollStatus(request_id) {
        const ptr0 = passStringToWasm0(request_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.wasmclient_pollStatus(this.__wbg_ptr, ptr0, len0);
        return ret;
    }
    /**
     * Request an age proof credential.
     * @param {AgeProofPolicy} policy
     * @returns {Promise<any>}
     */
    requestAgeProofCredential(policy) {
        _assertClass(policy, AgeProofPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestAgeProofCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request a credential using a policy builder.
     *
     * Use the fluent API policy builders (e.g., `BaseCredentialPolicy`) to
     * create a policy, then pass it to this method.
     *
     * @param policy - A policy builder (e.g., BaseCredentialPolicy)
     * @returns Response with requestId, requestUri (for QR code), expiresIn,
     * and nonce @throws Error if the policy is invalid or the request
     * fails
     *
     * @example
     * ```javascript
     * const policy = new BaseCredentialPolicy()
     *     .withState(crypto.randomUUID())
     *     .withNonce(crypto.randomUUID())
     *     .withCallback("https://myapp.com/callback");
     *
     * const response = await client.requestCredential(policy);
     * console.log(response.requestUri); // Use for QR code
     * ```
     * @param {BaseCredentialPolicy} policy
     * @returns {Promise<any>}
     */
    requestCredential(policy) {
        _assertClass(policy, BaseCredentialPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request an employment credential.
     * @param {EmploymentPolicy} policy
     * @returns {Promise<any>}
     */
    requestEmploymentCredential(policy) {
        _assertClass(policy, EmploymentPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestEmploymentCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request a persona credential with optional field selection.
     * @param {PersonaPolicy} policy
     * @returns {Promise<any>}
     */
    requestPersonaCredential(policy) {
        _assertClass(policy, PersonaPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestPersonaCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request a trust credential.
     * @param {TrustPolicy} policy
     * @returns {Promise<any>}
     */
    requestTrustCredential(policy) {
        _assertClass(policy, TrustPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestTrustCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request a verified email credential with optional domain constraint.
     * @param {VerifiedEmailPolicy} policy
     * @returns {Promise<any>}
     */
    requestVerifiedEmailCredential(policy) {
        _assertClass(policy, VerifiedEmailPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestVerifiedEmailCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request a verified persona (KYC) credential.
     * @param {VerifiedPersonaPolicy} policy
     * @returns {Promise<any>}
     */
    requestVerifiedPersonaCredential(policy) {
        _assertClass(policy, VerifiedPersonaPolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestVerifiedPersonaCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Request a verified phone credential with optional country code
     * constraint.
     * @param {VerifiedPhonePolicy} policy
     * @returns {Promise<any>}
     */
    requestVerifiedPhoneCredential(policy) {
        _assertClass(policy, VerifiedPhonePolicy);
        var ptr0 = policy.__destroy_into_raw();
        const ret = wasm.wasmclient_requestVerifiedPhoneCredential(this.__wbg_ptr, ptr0);
        return ret;
    }
    /**
     * Validate an issuer DID against the trust registry.
     * @param {string} issuer_did
     * @returns {Promise<any>}
     */
    validateIssuer(issuer_did) {
        const ptr0 = passStringToWasm0(issuer_did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.wasmclient_validateIssuer(this.__wbg_ptr, ptr0, len0);
        return ret;
    }
    /**
     * Verify a presentation string.
     *
     * Returns the verified credential as a JSON object.
     * @param {string} presentation
     * @returns {Promise<any>}
     */
    verifyPresentation(presentation) {
        const ptr0 = passStringToWasm0(presentation, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ret = wasm.wasmclient_verifyPresentation(this.__wbg_ptr, ptr0, len0);
        return ret;
    }
}
if (Symbol.dispose) WasmClient.prototype[Symbol.dispose] = WasmClient.prototype.free;
exports.WasmClient = WasmClient;

/**
 * JavaScript-friendly SDK configuration.
 */
class WasmConfig {
    static __wrap(ptr) {
        ptr = ptr >>> 0;
        const obj = Object.create(WasmConfig.prototype);
        obj.__wbg_ptr = ptr;
        WasmConfigFinalization.register(obj, obj.__wbg_ptr, obj);
        return obj;
    }
    __destroy_into_raw() {
        const ptr = this.__wbg_ptr;
        this.__wbg_ptr = 0;
        WasmConfigFinalization.unregister(this);
        return ptr;
    }
    free() {
        const ptr = this.__destroy_into_raw();
        wasm.__wbg_wasmconfig_free(ptr, 0);
    }
    /**
     * Create a new configuration with the IDP endpoint and client ID.
     *
     * # Arguments
     *
     * * `idp_endpoint` - The IDP endpoint URL (e.g., `https://human.lastid.co`)
     * * `client_id` - OAuth client ID for authentication
     * @param {string} idp_endpoint
     * @param {string} client_id
     */
    constructor(idp_endpoint, client_id) {
        const ptr0 = passStringToWasm0(idp_endpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len1 = WASM_VECTOR_LEN;
        const ret = wasm.wasmconfig_new(ptr0, len0, ptr1, len1);
        if (ret[2]) {
            throw takeFromExternrefTable0(ret[1]);
        }
        this.__wbg_ptr = ret[0] >>> 0;
        WasmConfigFinalization.register(this, this.__wbg_ptr, this);
        return this;
    }
    /**
     * Create configuration with custom settings.
     *
     * # Arguments
     *
     * * `idp_endpoint` - The IDP endpoint URL
     * * `client_id` - OAuth client ID for authentication
     * * `trust_registry_endpoint` - Optional custom trust registry endpoint
     * * `timeout_seconds` - Optional HTTP timeout in seconds
     * @param {string} idp_endpoint
     * @param {string} client_id
     * @param {string | null} [trust_registry_endpoint]
     * @param {bigint | null} [timeout_seconds]
     * @returns {WasmConfig}
     */
    static withOptions(idp_endpoint, client_id, trust_registry_endpoint, timeout_seconds) {
        const ptr0 = passStringToWasm0(idp_endpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len0 = WASM_VECTOR_LEN;
        const ptr1 = passStringToWasm0(client_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        const len1 = WASM_VECTOR_LEN;
        var ptr2 = isLikeNone(trust_registry_endpoint) ? 0 : passStringToWasm0(trust_registry_endpoint, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
        var len2 = WASM_VECTOR_LEN;
        const ret = wasm.wasmconfig_withOptions(ptr0, len0, ptr1, len1, ptr2, len2, !isLikeNone(timeout_seconds), isLikeNone(timeout_seconds) ? BigInt(0) : timeout_seconds);
        if (ret[2]) {
            throw takeFromExternrefTable0(ret[1]);
        }
        return WasmConfig.__wrap(ret[0]);
    }
}
if (Symbol.dispose) WasmConfig.prototype[Symbol.dispose] = WasmConfig.prototype.free;
exports.WasmConfig = WasmConfig;

/**
 * Generate a unique nonce for replay protection.
 * @returns {string}
 */
function generateNonce() {
    let deferred1_0;
    let deferred1_1;
    try {
        const ret = wasm.generateNonce();
        deferred1_0 = ret[0];
        deferred1_1 = ret[1];
        return getStringFromWasm0(ret[0], ret[1]);
    } finally {
        wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
    }
}
exports.generateNonce = generateNonce;

/**
 * Generate a unique state parameter for CSRF protection.
 * @returns {string}
 */
function generateState() {
    let deferred1_0;
    let deferred1_1;
    try {
        const ret = wasm.generateState();
        deferred1_0 = ret[0];
        deferred1_1 = ret[1];
        return getStringFromWasm0(ret[0], ret[1]);
    } finally {
        wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
    }
}
exports.generateState = generateState;

/**
 * Get all supported credential types.
 * @returns {any}
 */
function getSupportedCredentialTypes() {
    const ret = wasm.getSupportedCredentialTypes();
    return ret;
}
exports.getSupportedCredentialTypes = getSupportedCredentialTypes;

/**
 * Get the SDK version.
 * @returns {string}
 */
function getVersion() {
    let deferred1_0;
    let deferred1_1;
    try {
        const ret = wasm.getVersion();
        deferred1_0 = ret[0];
        deferred1_1 = ret[1];
        return getStringFromWasm0(ret[0], ret[1]);
    } finally {
        wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
    }
}
exports.getVersion = getVersion;

/**
 * Initialize panic hook for better error messages in browser console.
 */
function init() {
    wasm.init();
}
exports.init = init;

function __wbg_get_imports() {
    const import0 = {
        __proto__: null,
        __wbg_Error_8c4e43fe74559d73: function(arg0, arg1) {
            const ret = Error(getStringFromWasm0(arg0, arg1));
            return ret;
        },
        __wbg_String_8f0eb39a4a4c2f66: function(arg0, arg1) {
            const ret = String(arg1);
            const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
            const len1 = WASM_VECTOR_LEN;
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
        },
        __wbg___wbindgen_debug_string_0bc8482c6e3508ae: function(arg0, arg1) {
            const ret = debugString(arg1);
            const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
            const len1 = WASM_VECTOR_LEN;
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
        },
        __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
            const ret = typeof(arg0) === 'function';
            return ret;
        },
        __wbg___wbindgen_is_object_5ae8e5880f2c1fbd: function(arg0) {
            const val = arg0;
            const ret = typeof(val) === 'object' && val !== null;
            return ret;
        },
        __wbg___wbindgen_is_string_cd444516edc5b180: function(arg0) {
            const ret = typeof(arg0) === 'string';
            return ret;
        },
        __wbg___wbindgen_is_undefined_9e4d92534c42d778: function(arg0) {
            const ret = arg0 === undefined;
            return ret;
        },
        __wbg___wbindgen_string_get_72fb696202c56729: function(arg0, arg1) {
            const obj = arg1;
            const ret = typeof(obj) === 'string' ? obj : undefined;
            var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
            var len1 = WASM_VECTOR_LEN;
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
        },
        __wbg___wbindgen_throw_be289d5034ed271b: function(arg0, arg1) {
            throw new Error(getStringFromWasm0(arg0, arg1));
        },
        __wbg__wbg_cb_unref_d9b87ff7982e3b21: function(arg0) {
            arg0._wbg_cb_unref();
        },
        __wbg_abort_2f0584e03e8e3950: function(arg0) {
            arg0.abort();
        },
        __wbg_abort_d549b92d3c665de1: function(arg0, arg1) {
            arg0.abort(arg1);
        },
        __wbg_append_a992ccc37aa62dc4: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
            arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
        }, arguments); },
        __wbg_arrayBuffer_bb54076166006c39: function() { return handleError(function (arg0) {
            const ret = arg0.arrayBuffer();
            return ret;
        }, arguments); },
        __wbg_call_389efe28435a9388: function() { return handleError(function (arg0, arg1) {
            const ret = arg0.call(arg1);
            return ret;
        }, arguments); },
        __wbg_call_4708e0c13bdc8e95: function() { return handleError(function (arg0, arg1, arg2) {
            const ret = arg0.call(arg1, arg2);
            return ret;
        }, arguments); },
        __wbg_clearTimeout_42d9ccd50822fd3a: function(arg0) {
            const ret = clearTimeout(arg0);
            return ret;
        },
        __wbg_crypto_86f2631e91b51511: function(arg0) {
            const ret = arg0.crypto;
            return ret;
        },
        __wbg_done_57b39ecd9addfe81: function(arg0) {
            const ret = arg0.done;
            return ret;
        },
        __wbg_error_7534b8e9a36f1ab4: function(arg0, arg1) {
            let deferred0_0;
            let deferred0_1;
            try {
                deferred0_0 = arg0;
                deferred0_1 = arg1;
                console.error(getStringFromWasm0(arg0, arg1));
            } finally {
                wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
            }
        },
        __wbg_fetch_6bbc32f991730587: function(arg0) {
            const ret = fetch(arg0);
            return ret;
        },
        __wbg_fetch_afb6a4b6cacf876d: function(arg0, arg1) {
            const ret = arg0.fetch(arg1);
            return ret;
        },
        __wbg_getRandomValues_9b655bdd369112f2: function() { return handleError(function (arg0, arg1) {
            globalThis.crypto.getRandomValues(getArrayU8FromWasm0(arg0, arg1));
        }, arguments); },
        __wbg_getRandomValues_b3f15fcbfabb0f8b: function() { return handleError(function (arg0, arg1) {
            arg0.getRandomValues(arg1);
        }, arguments); },
        __wbg_getTime_1e3cd1391c5c3995: function(arg0) {
            const ret = arg0.getTime();
            return ret;
        },
        __wbg_get_b3ed3ad4be2bc8ac: function() { return handleError(function (arg0, arg1) {
            const ret = Reflect.get(arg0, arg1);
            return ret;
        }, arguments); },
        __wbg_has_d4e53238966c12b6: function() { return handleError(function (arg0, arg1) {
            const ret = Reflect.has(arg0, arg1);
            return ret;
        }, arguments); },
        __wbg_headers_59a2938db9f80985: function(arg0) {
            const ret = arg0.headers;
            return ret;
        },
        __wbg_instanceof_Response_ee1d54d79ae41977: function(arg0) {
            let result;
            try {
                result = arg0 instanceof Response;
            } catch (_) {
                result = false;
            }
            const ret = result;
            return ret;
        },
        __wbg_instanceof_Window_ed49b2db8df90359: function(arg0) {
            let result;
            try {
                result = arg0 instanceof Window;
            } catch (_) {
                result = false;
            }
            const ret = result;
            return ret;
        },
        __wbg_iterator_6ff6560ca1568e55: function() {
            const ret = Symbol.iterator;
            return ret;
        },
        __wbg_length_32ed9a279acd054c: function(arg0) {
            const ret = arg0.length;
            return ret;
        },
        __wbg_msCrypto_d562bbe83e0d4b91: function(arg0) {
            const ret = arg0.msCrypto;
            return ret;
        },
        __wbg_new_0_73afc35eb544e539: function() {
            const ret = new Date();
            return ret;
        },
        __wbg_new_361308b2356cecd0: function() {
            const ret = new Object();
            return ret;
        },
        __wbg_new_3eb36ae241fe6f44: function() {
            const ret = new Array();
            return ret;
        },
        __wbg_new_64284bd487f9d239: function() { return handleError(function () {
            const ret = new Headers();
            return ret;
        }, arguments); },
        __wbg_new_8a6f238a6ece86ea: function() {
            const ret = new Error();
            return ret;
        },
        __wbg_new_b5d9e2fb389fef91: function(arg0, arg1) {
            try {
                var state0 = {a: arg0, b: arg1};
                var cb0 = (arg0, arg1) => {
                    const a = state0.a;
                    state0.a = 0;
                    try {
                        return wasm_bindgen__convert__closures_____invoke__h5f950470609b6db0(a, state0.b, arg0, arg1);
                    } finally {
                        state0.a = a;
                    }
                };
                const ret = new Promise(cb0);
                return ret;
            } finally {
                state0.a = state0.b = 0;
            }
        },
        __wbg_new_b949e7f56150a5d1: function() { return handleError(function () {
            const ret = new AbortController();
            return ret;
        }, arguments); },
        __wbg_new_dca287b076112a51: function() {
            const ret = new Map();
            return ret;
        },
        __wbg_new_dd2b680c8bf6ae29: function(arg0) {
            const ret = new Uint8Array(arg0);
            return ret;
        },
        __wbg_new_from_slice_a3d2629dc1826784: function(arg0, arg1) {
            const ret = new Uint8Array(getArrayU8FromWasm0(arg0, arg1));
            return ret;
        },
        __wbg_new_no_args_1c7c842f08d00ebb: function(arg0, arg1) {
            const ret = new Function(getStringFromWasm0(arg0, arg1));
            return ret;
        },
        __wbg_new_with_length_a2c39cbe88fd8ff1: function(arg0) {
            const ret = new Uint8Array(arg0 >>> 0);
            return ret;
        },
        __wbg_new_with_str_and_init_a61cbc6bdef21614: function() { return handleError(function (arg0, arg1, arg2) {
            const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
            return ret;
        }, arguments); },
        __wbg_next_3482f54c49e8af19: function() { return handleError(function (arg0) {
            const ret = arg0.next();
            return ret;
        }, arguments); },
        __wbg_next_418f80d8f5303233: function(arg0) {
            const ret = arg0.next;
            return ret;
        },
        __wbg_node_e1f24f89a7336c2e: function(arg0) {
            const ret = arg0.node;
            return ret;
        },
        __wbg_now_a3af9a2f4bbaa4d1: function() {
            const ret = Date.now();
            return ret;
        },
        __wbg_process_3975fd6c72f520aa: function(arg0) {
            const ret = arg0.process;
            return ret;
        },
        __wbg_prototypesetcall_bdcdcc5842e4d77d: function(arg0, arg1, arg2) {
            Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
        },
        __wbg_queueMicrotask_0aa0a927f78f5d98: function(arg0) {
            const ret = arg0.queueMicrotask;
            return ret;
        },
        __wbg_queueMicrotask_5bb536982f78a56f: function(arg0) {
            queueMicrotask(arg0);
        },
        __wbg_randomFillSync_f8c153b79f285817: function() { return handleError(function (arg0, arg1) {
            arg0.randomFillSync(arg1);
        }, arguments); },
        __wbg_require_b74f47fc2d022fd6: function() { return handleError(function () {
            const ret = module.require;
            return ret;
        }, arguments); },
        __wbg_resolve_002c4b7d9d8f6b64: function(arg0) {
            const ret = Promise.resolve(arg0);
            return ret;
        },
        __wbg_setTimeout_4ec014681668a581: function(arg0, arg1) {
            const ret = setTimeout(arg0, arg1);
            return ret;
        },
        __wbg_setTimeout_eff32631ea138533: function() { return handleError(function (arg0, arg1, arg2) {
            const ret = arg0.setTimeout(arg1, arg2);
            return ret;
        }, arguments); },
        __wbg_set_1eb0999cf5d27fc8: function(arg0, arg1, arg2) {
            const ret = arg0.set(arg1, arg2);
            return ret;
        },
        __wbg_set_3f1d0b984ed272ed: function(arg0, arg1, arg2) {
            arg0[arg1] = arg2;
        },
        __wbg_set_body_9a7e00afe3cfe244: function(arg0, arg1) {
            arg0.body = arg1;
        },
        __wbg_set_cache_315a3ed773a41543: function(arg0, arg1) {
            arg0.cache = __wbindgen_enum_RequestCache[arg1];
        },
        __wbg_set_credentials_c4a58d2e05ef24fb: function(arg0, arg1) {
            arg0.credentials = __wbindgen_enum_RequestCredentials[arg1];
        },
        __wbg_set_f43e577aea94465b: function(arg0, arg1, arg2) {
            arg0[arg1 >>> 0] = arg2;
        },
        __wbg_set_headers_cfc5f4b2c1f20549: function(arg0, arg1) {
            arg0.headers = arg1;
        },
        __wbg_set_method_c3e20375f5ae7fac: function(arg0, arg1, arg2) {
            arg0.method = getStringFromWasm0(arg1, arg2);
        },
        __wbg_set_mode_b13642c312648202: function(arg0, arg1) {
            arg0.mode = __wbindgen_enum_RequestMode[arg1];
        },
        __wbg_set_signal_f2d3f8599248896d: function(arg0, arg1) {
            arg0.signal = arg1;
        },
        __wbg_signal_d1285ecab4ebc5ad: function(arg0) {
            const ret = arg0.signal;
            return ret;
        },
        __wbg_stack_0ed75d68575b0f3c: function(arg0, arg1) {
            const ret = arg1.stack;
            const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
            const len1 = WASM_VECTOR_LEN;
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
        },
        __wbg_static_accessor_GLOBAL_12837167ad935116: function() {
            const ret = typeof global === 'undefined' ? null : global;
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
        },
        __wbg_static_accessor_GLOBAL_THIS_e628e89ab3b1c95f: function() {
            const ret = typeof globalThis === 'undefined' ? null : globalThis;
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
        },
        __wbg_static_accessor_SELF_a621d3dfbb60d0ce: function() {
            const ret = typeof self === 'undefined' ? null : self;
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
        },
        __wbg_static_accessor_WINDOW_f8727f0cf888e0bd: function() {
            const ret = typeof window === 'undefined' ? null : window;
            return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
        },
        __wbg_status_89d7e803db911ee7: function(arg0) {
            const ret = arg0.status;
            return ret;
        },
        __wbg_stringify_8d1cc6ff383e8bae: function() { return handleError(function (arg0) {
            const ret = JSON.stringify(arg0);
            return ret;
        }, arguments); },
        __wbg_subarray_a96e1fef17ed23cb: function(arg0, arg1, arg2) {
            const ret = arg0.subarray(arg1 >>> 0, arg2 >>> 0);
            return ret;
        },
        __wbg_text_083b8727c990c8c0: function() { return handleError(function (arg0) {
            const ret = arg0.text();
            return ret;
        }, arguments); },
        __wbg_then_0d9fe2c7b1857d32: function(arg0, arg1, arg2) {
            const ret = arg0.then(arg1, arg2);
            return ret;
        },
        __wbg_then_b9e7b3b5f1a9e1b5: function(arg0, arg1) {
            const ret = arg0.then(arg1);
            return ret;
        },
        __wbg_url_c484c26b1fbf5126: function(arg0, arg1) {
            const ret = arg1.url;
            const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
            const len1 = WASM_VECTOR_LEN;
            getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
            getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
        },
        __wbg_value_0546255b415e96c1: function(arg0) {
            const ret = arg0.value;
            return ret;
        },
        __wbg_versions_4e31226f5e8dc909: function(arg0) {
            const ret = arg0.versions;
            return ret;
        },
        __wbindgen_cast_0000000000000001: function(arg0, arg1) {
            // Cast intrinsic for `Closure(Closure { dtor_idx: 214, function: Function { arguments: [], shim_idx: 215, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
            const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hc9d173ff07719097, wasm_bindgen__convert__closures_____invoke__h1da0cb727c381a5e);
            return ret;
        },
        __wbindgen_cast_0000000000000002: function(arg0, arg1) {
            // Cast intrinsic for `Closure(Closure { dtor_idx: 245, function: Function { arguments: [Externref], shim_idx: 246, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
            const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h0952de6776b7f2f1, wasm_bindgen__convert__closures_____invoke__h716eb4010d2a8927);
            return ret;
        },
        __wbindgen_cast_0000000000000003: function(arg0) {
            // Cast intrinsic for `F64 -> Externref`.
            const ret = arg0;
            return ret;
        },
        __wbindgen_cast_0000000000000004: function(arg0) {
            // Cast intrinsic for `I64 -> Externref`.
            const ret = arg0;
            return ret;
        },
        __wbindgen_cast_0000000000000005: function(arg0, arg1) {
            // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
            const ret = getArrayU8FromWasm0(arg0, arg1);
            return ret;
        },
        __wbindgen_cast_0000000000000006: function(arg0, arg1) {
            // Cast intrinsic for `Ref(String) -> Externref`.
            const ret = getStringFromWasm0(arg0, arg1);
            return ret;
        },
        __wbindgen_cast_0000000000000007: function(arg0) {
            // Cast intrinsic for `U64 -> Externref`.
            const ret = BigInt.asUintN(64, arg0);
            return ret;
        },
        __wbindgen_init_externref_table: function() {
            const table = wasm.__wbindgen_externrefs;
            const offset = table.grow(4);
            table.set(0, undefined);
            table.set(offset + 0, undefined);
            table.set(offset + 1, null);
            table.set(offset + 2, true);
            table.set(offset + 3, false);
        },
    };
    return {
        __proto__: null,
        "./lastid_sdk_bg.js": import0,
    };
}

function wasm_bindgen__convert__closures_____invoke__h1da0cb727c381a5e(arg0, arg1) {
    wasm.wasm_bindgen__convert__closures_____invoke__h1da0cb727c381a5e(arg0, arg1);
}

function wasm_bindgen__convert__closures_____invoke__h716eb4010d2a8927(arg0, arg1, arg2) {
    wasm.wasm_bindgen__convert__closures_____invoke__h716eb4010d2a8927(arg0, arg1, arg2);
}

function wasm_bindgen__convert__closures_____invoke__h5f950470609b6db0(arg0, arg1, arg2, arg3) {
    wasm.wasm_bindgen__convert__closures_____invoke__h5f950470609b6db0(arg0, arg1, arg2, arg3);
}


const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];


const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];


const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
const AgeProofPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_ageproofpolicy_free(ptr >>> 0, 1));
const BaseCredentialPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_basecredentialpolicy_free(ptr >>> 0, 1));
const EmploymentPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_employmentpolicy_free(ptr >>> 0, 1));
const LastIDErrorFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_lastiderror_free(ptr >>> 0, 1));
const PersonaPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_personapolicy_free(ptr >>> 0, 1));
const TrustPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_trustpolicy_free(ptr >>> 0, 1));
const VerifiedEmailPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_verifiedemailpolicy_free(ptr >>> 0, 1));
const VerifiedPersonaPolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_verifiedpersonapolicy_free(ptr >>> 0, 1));
const VerifiedPhonePolicyFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_verifiedphonepolicy_free(ptr >>> 0, 1));
const WasmClientFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_wasmclient_free(ptr >>> 0, 1));
const WasmConfigFinalization = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(ptr => wasm.__wbg_wasmconfig_free(ptr >>> 0, 1));

function addToExternrefTable0(obj) {
    const idx = wasm.__externref_table_alloc();
    wasm.__wbindgen_externrefs.set(idx, obj);
    return idx;
}

function _assertClass(instance, klass) {
    if (!(instance instanceof klass)) {
        throw new Error(`expected instance of ${klass.name}`);
    }
}

const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
    ? { register: () => {}, unregister: () => {} }
    : new FinalizationRegistry(state => state.dtor(state.a, state.b));

function debugString(val) {
    // primitive types
    const type = typeof val;
    if (type == 'number' || type == 'boolean' || val == null) {
        return  `${val}`;
    }
    if (type == 'string') {
        return `"${val}"`;
    }
    if (type == 'symbol') {
        const description = val.description;
        if (description == null) {
            return 'Symbol';
        } else {
            return `Symbol(${description})`;
        }
    }
    if (type == 'function') {
        const name = val.name;
        if (typeof name == 'string' && name.length > 0) {
            return `Function(${name})`;
        } else {
            return 'Function';
        }
    }
    // objects
    if (Array.isArray(val)) {
        const length = val.length;
        let debug = '[';
        if (length > 0) {
            debug += debugString(val[0]);
        }
        for(let i = 1; i < length; i++) {
            debug += ', ' + debugString(val[i]);
        }
        debug += ']';
        return debug;
    }
    // Test for built-in
    const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
    let className;
    if (builtInMatches && builtInMatches.length > 1) {
        className = builtInMatches[1];
    } else {
        // Failed to match the standard '[object ClassName]'
        return toString.call(val);
    }
    if (className == 'Object') {
        // we're a user defined class or Object
        // JSON.stringify avoids problems with cycles, and is generally much
        // easier than looping through ownProperties of `val`.
        try {
            return 'Object(' + JSON.stringify(val) + ')';
        } catch (_) {
            return 'Object';
        }
    }
    // errors
    if (val instanceof Error) {
        return `${val.name}: ${val.message}\n${val.stack}`;
    }
    // TODO we could test for more things here, like `Set`s and `Map`s.
    return className;
}

function getArrayU8FromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
}

let cachedDataViewMemory0 = null;
function getDataViewMemory0() {
    if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
        cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
    }
    return cachedDataViewMemory0;
}

function getStringFromWasm0(ptr, len) {
    ptr = ptr >>> 0;
    return decodeText(ptr, len);
}

let cachedUint8ArrayMemory0 = null;
function getUint8ArrayMemory0() {
    if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
        cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
    }
    return cachedUint8ArrayMemory0;
}

function handleError(f, args) {
    try {
        return f.apply(this, args);
    } catch (e) {
        const idx = addToExternrefTable0(e);
        wasm.__wbindgen_exn_store(idx);
    }
}

function isLikeNone(x) {
    return x === undefined || x === null;
}

function makeMutClosure(arg0, arg1, dtor, f) {
    const state = { a: arg0, b: arg1, cnt: 1, dtor };
    const real = (...args) => {

        // First up with a closure we increment the internal reference
        // count. This ensures that the Rust closure environment won't
        // be deallocated while we're invoking it.
        state.cnt++;
        const a = state.a;
        state.a = 0;
        try {
            return f(a, state.b, ...args);
        } finally {
            state.a = a;
            real._wbg_cb_unref();
        }
    };
    real._wbg_cb_unref = () => {
        if (--state.cnt === 0) {
            state.dtor(state.a, state.b);
            state.a = 0;
            CLOSURE_DTORS.unregister(state);
        }
    };
    CLOSURE_DTORS.register(real, state, state);
    return real;
}

function passArrayJsValueToWasm0(array, malloc) {
    const ptr = malloc(array.length * 4, 4) >>> 0;
    for (let i = 0; i < array.length; i++) {
        const add = addToExternrefTable0(array[i]);
        getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
    }
    WASM_VECTOR_LEN = array.length;
    return ptr;
}

function passStringToWasm0(arg, malloc, realloc) {
    if (realloc === undefined) {
        const buf = cachedTextEncoder.encode(arg);
        const ptr = malloc(buf.length, 1) >>> 0;
        getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
        WASM_VECTOR_LEN = buf.length;
        return ptr;
    }

    let len = arg.length;
    let ptr = malloc(len, 1) >>> 0;

    const mem = getUint8ArrayMemory0();

    let offset = 0;

    for (; offset < len; offset++) {
        const code = arg.charCodeAt(offset);
        if (code > 0x7F) break;
        mem[ptr + offset] = code;
    }
    if (offset !== len) {
        if (offset !== 0) {
            arg = arg.slice(offset);
        }
        ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
        const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
        const ret = cachedTextEncoder.encodeInto(arg, view);

        offset += ret.written;
        ptr = realloc(ptr, len, offset, 1) >>> 0;
    }

    WASM_VECTOR_LEN = offset;
    return ptr;
}

function takeFromExternrefTable0(idx) {
    const value = wasm.__wbindgen_externrefs.get(idx);
    wasm.__externref_table_dealloc(idx);
    return value;
}

let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
cachedTextDecoder.decode();
function decodeText(ptr, len) {
    return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
}

const cachedTextEncoder = new TextEncoder();

if (!('encodeInto' in cachedTextEncoder)) {
    cachedTextEncoder.encodeInto = function (arg, view) {
        const buf = cachedTextEncoder.encode(arg);
        view.set(buf);
        return {
            read: arg.length,
            written: buf.length
        };
    };
}

let WASM_VECTOR_LEN = 0;

const wasmPath = `${__dirname}/lastid_sdk_bg.wasm`;
const wasmBytes = require('fs').readFileSync(wasmPath);
const wasmModule = new WebAssembly.Module(wasmBytes);
const wasm = new WebAssembly.Instance(wasmModule, __wbg_get_imports()).exports;
wasm.__wbindgen_start();
