"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const liveQueryCollection = require("./live-query-collection.cjs");
async function queryOnce(configOrQuery) {
  const config = typeof configOrQuery === `function` ? { query: configOrQuery } : configOrQuery;
  const query = (q) => {
    const queryConfig = config.query;
    return typeof queryConfig === `function` ? queryConfig(q) : queryConfig;
  };
  const collection = liveQueryCollection.createLiveQueryCollection({
    query,
    gcTime: 1
    // Cleanup in next tick when no subscribers (0 disables GC)
  });
  try {
    await collection.preload();
    const isSingleResult = collection.config.singleResult === true;
    if (isSingleResult) {
      const first = collection.values().next().value;
      return first;
    }
    return collection.toArray;
  } finally {
    await collection.cleanup();
  }
}
exports.queryOnce = queryOnce;
//# sourceMappingURL=query-once.cjs.map
