/* tslint:disable */
/* eslint-disable */
/**
 * The `ReadableStreamType` enum.
 *
 * *This API requires the following crate features to be activated: `ReadableStreamType`*
 */

export type ReadableStreamType = "bytes";

export class Engine {
    free(): void;
    [Symbol.dispose](): void;
    /**
     * Download Lemma source for a registry identifier via [`crate::registry::LemmaBase`]. Returns `{ source, id }`.
     * Does not load this [`WasmEngine`]; call [`Self::load_batch`], etc., yourself.
     */
    fetch(name: string): Promise<any>;
    /**
     * Returns formatted source string on success; throws with error message on failure.
     */
    format(code: string, attribute?: string | null): any;
    /**
     * Canonical Lemma source for `repository`, formatted from the in-engine AST (e.g. `"lemma"`).
     */
    format_repository(repository: string): string;
    invert(_spec_name: string, _rule_name: string, _target_json: string, _provided_values_json: string): any;
    /**
     * Same data as [`Engine::list`]: grouped [`ResolvedRepository`] JSON without planning.
     */
    list(): any;
    /**
     * Load Lemma source. Throws with an array of serialized errors
     * (same shape as `EngineError` in `engine/packages/npm/lemma.d.ts`).
     */
    load(code: string, attribute: string): void;
    /**
     * Load multiple Lemma sources in one planning pass (same as [`Engine::load_batch`]).
     *
     * `sources` is a plain object mapping path labels to source text. Labels become
     * [`SourceType::Path`]; use `""` as a key for [`SourceType::Volatile`].
     *
     * `dependency`: when non-empty after trim, sources are tagged as that dependency id.
     *
     * Throws with an array of `JsError` on failure.
     */
    load_batch(sources: any, dependency?: string | null): void;
    constructor();
    /**
     * Loaded repositories (workspace and dependencies): `{ name, dependency }`.
     */
    repositories(): any;
    /**
     * Evaluate spec. Returns [`crate::evaluation::Response`] as a JS object. Throws on planning/runtime error.
     *
     * `repository`: repository qualifier (`@org/pkg`), or `null`/empty for workspace (same as
     * [`Engine::run`] `repo: None`).
     */
    run(repository: string | null | undefined, spec: string, rule_names: any, data_values: any, rule_result_units: any, effective?: string | null): any;
    /**
     * Planning schema for the spec ([`crate::planning::execution_plan::SpecSchema`]). Throws on error.
     *
     * `repository`: qualifier string or `null`/empty for workspace ([`Engine::schema`]).
     */
    schema(repository: string | null | undefined, spec: string, effective?: string | null): any;
}

export class IntoUnderlyingByteSource {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    cancel(): void;
    pull(controller: ReadableByteStreamController): Promise<any>;
    start(controller: ReadableByteStreamController): void;
    readonly autoAllocateChunkSize: number;
    readonly type: ReadableStreamType;
}

export class IntoUnderlyingSink {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    abort(reason: any): Promise<any>;
    close(): Promise<any>;
    write(chunk: any): Promise<any>;
}

export class IntoUnderlyingSource {
    private constructor();
    free(): void;
    [Symbol.dispose](): void;
    cancel(): void;
    pull(controller: ReadableStreamDefaultController): Promise<any>;
}

export class ServerConfig {
    free(): void;
    [Symbol.dispose](): void;
    constructor(into_server: AsyncIterator<any>, from_server: WritableStream);
}

/**
 * Run the Lemma LSP over the given streams. Call from JS after creating
 * an AsyncIterator (client → server messages) and a WritableStream (server → client).
 */
export function serve(config: ServerConfig): Promise<void>;

export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;

export interface InitOutput {
    readonly memory: WebAssembly.Memory;
    readonly __wbg_serverconfig_free: (a: number, b: number) => void;
    readonly serve: (a: number) => number;
    readonly serverconfig_new: (a: number, b: number) => number;
    readonly __wbg_intounderlyingbytesource_free: (a: number, b: number) => void;
    readonly __wbg_intounderlyingsink_free: (a: number, b: number) => void;
    readonly __wbg_intounderlyingsource_free: (a: number, b: number) => void;
    readonly intounderlyingbytesource_autoAllocateChunkSize: (a: number) => number;
    readonly intounderlyingbytesource_cancel: (a: number) => void;
    readonly intounderlyingbytesource_pull: (a: number, b: number) => number;
    readonly intounderlyingbytesource_start: (a: number, b: number) => void;
    readonly intounderlyingbytesource_type: (a: number) => number;
    readonly intounderlyingsink_abort: (a: number, b: number) => number;
    readonly intounderlyingsink_close: (a: number) => number;
    readonly intounderlyingsink_write: (a: number, b: number) => number;
    readonly intounderlyingsource_cancel: (a: number) => void;
    readonly intounderlyingsource_pull: (a: number, b: number) => number;
    readonly __wbg_engine_free: (a: number, b: number) => void;
    readonly wasmengine_fetch: (a: number, b: number, c: number) => number;
    readonly wasmengine_format: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
    readonly wasmengine_format_repository: (a: number, b: number, c: number, d: number) => void;
    readonly wasmengine_invert: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
    readonly wasmengine_list: (a: number, b: number) => void;
    readonly wasmengine_load: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
    readonly wasmengine_load_batch: (a: number, b: number, c: number, d: number, e: number) => void;
    readonly wasmengine_new: () => number;
    readonly wasmengine_repositories: (a: number, b: number) => void;
    readonly wasmengine_run: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number) => void;
    readonly wasmengine_schema: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
    readonly __wasm_bindgen_func_elem_11787: (a: number, b: number, c: number, d: number) => void;
    readonly __wasm_bindgen_func_elem_2722: (a: number, b: number, c: number, d: number) => void;
    readonly __wasm_bindgen_func_elem_11799: (a: number, b: number, c: number, d: number) => void;
    readonly __wbindgen_export: (a: number, b: number) => number;
    readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
    readonly __wbindgen_export3: (a: number) => void;
    readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
    readonly __wbindgen_export5: (a: number, b: number) => void;
    readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
}

export type SyncInitInput = BufferSource | WebAssembly.Module;

/**
 * Instantiates the given `module`, which can either be bytes or
 * a precompiled `WebAssembly.Module`.
 *
 * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
 *
 * @returns {InitOutput}
 */
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;

/**
 * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
 * for everything else, calls `WebAssembly.instantiate` directly.
 *
 * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
 *
 * @returns {Promise<InitOutput>}
 */
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
