import useSWR from '../../../../../node_modules/swr/core/dist/index.mjs';
import { useStytchClient } from './useStytchClient.mjs';
import { useOrgInfo } from './useOrgInfo.mjs';

const scimGetConnectionKey = (connectionId)=>connectionId ? [
        'scim.getConnection',
        connectionId
    ] : null;
const useScimConnection = ({ shouldFetch })=>{
    const client = useStytchClient();
    const { data } = useOrgInfo();
    const connectionId = data?.scim_active_connection?.connection_id;
    return useSWR(shouldFetch ? scimGetConnectionKey(connectionId) : null, async ()=>{
        const result = await client.scim.getConnection(connectionId);
        return result.connection;
    });
};

export { scimGetConnectionKey, useScimConnection };
//# sourceMappingURL=useScimConnection.mjs.map
