import { useState as f, useEffect as A } from "react";
function v(t) {
  return t?.did;
}
function o(t) {
  return t?.connectedAccounts || t?.extraConfigs?.connectedAccounts || [];
}
function w(t) {
  return t?.sourceProvider || t?.extraConfigs?.sourceProvider || "wallet";
}
function D(t) {
  return o(t).map((n) => n.provider);
}
function g(t) {
  return o(t).map((e) => e.did);
}
function r(t) {
  return o(t).find((e) => e.provider === "wallet");
}
function P(t) {
  return r(t)?.did;
}
function m({ session: t }) {
  const [c, n] = f({
    did: "",
    wallet: "",
    walletDid: "",
    permanentDid: "",
    connectedDids: [],
    connectedAccounts: [],
    sourceProvider: "",
    sourceProviders: []
  });
  return A(() => {
    if (t?.user) {
      const e = v(t.user), d = P(t.user), u = o(t.user), i = g(t.user), s = r(t.user), l = w(t.user), a = D(t.user);
      n({
        did: e,
        wallet: s,
        walletDid: d,
        permanentDid: e,
        connectedDids: i,
        connectedAccounts: u,
        sourceProvider: l,
        sourceProviders: a
      });
    }
  }, [t?.user]), c;
}
export {
  m as default,
  o as getConnectedAccounts,
  g as getConnectedDids,
  v as getPermanentDid,
  w as getSourceProvider,
  D as getSourceProviders,
  r as getWallet,
  P as getWalletDid
};
