import { jsx as f } from "react/jsx-runtime";
import { createContext as g, useState as i, use as p, useMemo as C, useEffect as m } from "react";
import { SessionContext as y } from "@arcblock/did-connect-react/lib/Session";
const d = g({}), { Provider: w, Consumer: U } = d;
function h({ children: n }) {
  const [S] = i(!1), { session: a } = p(y), { user: e } = a, [s, t] = i(), c = C(() => e?.didSpace?.endpoint, [e?.didSpace]);
  m(() => {
    t(e?.didSpace);
  }, [e?.didSpace]);
  const u = async () => {
    t(void 0);
  }, r = (o) => {
  };
  return /* @__PURE__ */ f(
    w,
    {
      value: {
        loading: S,
        spaceGateway: s,
        session: a,
        deleteSpaceGateway: u,
        updateSpaceGateway: async (o) => {
          t(o), await r(o.endpoint);
        },
        storageEndpoint: c,
        settingStorageEndpoint: r,
        hasStorageEndpoint: !!(c && s)
      },
      children: n
    }
  );
}
function P() {
  return p(d);
}
export {
  U as ConfigUserSpaceConsumer,
  d as ConfigUserSpaceContext,
  h as ConfigUserSpaceProvider,
  P as useConfigUserSpaceContext
};
