import { jsx as _jsx } from "react/jsx-runtime";
// (C) 2019-2025 GoodData Corporation
import { createContext, useContext } from "react";
import { UnexpectedSdkError } from "@gooddata/sdk-ui";
import { useFetchOrganization } from "./useFetchOrganization.js";
/**
 * @beta
 */
const OrganizationContext = createContext(null);
OrganizationContext.displayName = "OrganizationContext";
/**
 * @beta
 */
export const useOrganization = () => {
    const organization = useContext(OrganizationContext);
    if (!organization) {
        throw new UnexpectedSdkError("useOrganization must be used within a OrganizationProvider");
    }
    return organization;
};
/**
 * @beta
 */
export function OrganizationProvider({ children, backend, organizationId }) {
    const organization = useFetchOrganization({ backend, organizationId });
    return _jsx(OrganizationContext.Provider, { value: organization, children: children });
}
//# sourceMappingURL=OrganizationContext.js.map