import { jsx as n } from "react/jsx-runtime";
import { useContext as e, createContext as i, useState as c } from "react";
const u = i(void 0);
function p({ children: t }) {
  const [o] = c(/* @__PURE__ */ new Map());
  return /* @__PURE__ */ n(u.Provider, { value: o, children: t });
}
function x() {
  const t = e(u);
  if (!t)
    throw new Error("useDatasourceContext must be used within a DatasourceProvider");
  return t;
}
function d(t, o) {
  const a = x();
  if (!t)
    return {
      datasourceId: null,
      data: (o == null ? void 0 : o.examples) ?? [],
      isSample: !0
    };
  const r = t != null && t.id ? a.get(t.id) : null;
  return {
    datasourceId: t == null ? void 0 : t.id,
    data: r ?? (o == null ? void 0 : o.examples) ?? [],
    isSample: !r
  };
}
export {
  p as DatasourceProvider,
  d as useDatasource
};
//# sourceMappingURL=use-datasource.js.map
