/**
 * Shell only.
 * This file exists to give the semantic rewriter something stable to target.
 * None of this is meant to run at runtime.
 */
function makeStubError(apiName) {
    return new Error(`s2client.${apiName} is a compile-time API and must be rewritten by the transform.`);
}
export class S2Query {
    clientId;
    sqlQuery;
    sqlParams;
    executed;
    loading;
    error;
    /** Internal state placeholder (server decides array/object; we don't care here). */
    data = null;
    listeners = {
        success: new Set(),
        failure: new Set()
    };
    constructor(clientId, sqlQuery, sqlParams, executed = false, loading = false, error = null) {
        this.clientId = clientId;
        this.sqlQuery = sqlQuery;
        this.sqlParams = sqlParams;
        this.executed = executed;
        this.loading = loading;
        this.error = error;
    }
    on(event, fn) {
        this.listeners[event].add(fn);
        return () => this.listeners[event].delete(fn);
    }
    /** Shell: rewritten by transform. */
    execute() {
        throw makeStubError('query().execute');
    }
    /** Shell: rewritten by transform. */
    reset() {
        throw makeStubError('query().reset');
    }
}
export class S2Client {
    static serial = 0;
    id;
    constructor(id) {
        this.id = id ?? `s2_${++S2Client.serial}`;
    }
    query(sqlQuery, sqlParams) {
        return new S2Query(this.id, sqlQuery, sqlParams);
    }
}
export const s2client = new S2Client();
export function createS2Client(id) {
    return new S2Client(id);
}
