import { useState as c } from "react";
import { v as o } from "./index-jYYVpIDL.js";
function f(e) {
  const { getAppData: a, setAppData: i } = o(), [l, s] = c(() => {
    const t = a("enabled");
    if (!e.credentialOwner)
      return t ?? !1;
    const n = a("credentialId");
    return (t && (e.userCredentialIds.some((d) => d === n) || e.credentialOwner.credentialId === n)) ?? !1;
  });
  return { enabled: l, updateEnabled: (t) => {
    var n, r, d;
    t || i("credentialId", void 0), t && ((n = e.userCredentialIds) != null && n.length || (r = e.credentialOwner) != null && r.credentialId) && i("credentialId", ((d = e.credentialOwner) == null ? void 0 : d.credentialId) || e.userCredentialIds[0]), s(t);
  } };
}
export {
  f as u
};
