import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { EditorWarning } from "../EditorWarning";
import { useEditContext } from "../client/editContext";
export function NoWorkflowWriteAccess({ item }) {
    var editContext = useEditContext();
    if (!editContext)
        return;
    if (!item.canWriteLanguage)
        return;
    if (!item.canWriteWorkflow) {
        // If we're blocked because the item is in a final workflow state, a dedicated warning
        // with a "Create new version" CTA will be shown instead.
        const isFinalState = item.isFinalState ??
            editContext.workboxItems.find((wb) => wb.item.id === item.id &&
                wb.item.language === item.language &&
                wb.item.version === item.version)?.isFinalState ??
            false;
        if (isFinalState && !editContext.user?.isAdministrator) {
            return;
        }
        return (_jsx(EditorWarning, { title: "You dont have write access in the current workflow state.", severity: "warning", children: _jsxs("p", { children: ["The item is in the workflow state", " ", _jsx("span", { className: "font-bold", children: item.workflowState }), " which prevents you from editing."] }) }));
    }
}
//# sourceMappingURL=NoWorkflowWriteAccess.js.map