import { useEffect, useState } from 'react' import { financeStatus } from '../api/ledger' /** * Runtime probe for whether the D3 simulated-finance surface is enabled on THIS deployment. * * `/finance/v1/status` returns `{enabled:true}` when D3 is mounted, `{enabled:false}` when the * runtime isn't ready, and 404 (a thrown ApiRequestError) when the router isn't mounted at all * (D3 dormant — e.g. the public Space). We hide the Wallet/ATM entry points unless it is truly * enabled, so a dormant deployment never shows dead tabs. Returns null while probing. */ export function useD3Enabled(): boolean | null { const [enabled, setEnabled] = useState(null) useEffect(() => { let alive = true financeStatus() .then((s) => { if (alive) setEnabled(!!(s && s.enabled)) }) .catch(() => { if (alive) setEnabled(false) }) return () => { alive = false } }, []) return enabled }