import { jsx as _jsx } from "react/jsx-runtime";
import { getCreateAndSwitchToNewVersionCommand } from "../commands/createVersionCommand";
import { TriangleAlert } from "lucide-react";
import { getItemDescriptor } from "../utils";
export const confirmCreateVersion = (editContext, language) => {
    const currentItem = editContext.currentItemDescriptor;
    editContext.confirm({
        message: "This page has no version in language " +
            language.name +
            " (" +
            language.languageCode +
            "). Do you want to create a new version?",
        header: "Create Language Version?",
        icon: _jsx(TriangleAlert, { strokeWidth: 1, className: "h-4 w-4" }),
        acceptLabel: "Create version",
        rejectLabel: "Switch without creating",
        showCancel: true,
        accept: async () => {
            await editContext?.executeCommand({
                command: getCreateAndSwitchToNewVersionCommand({
                    language: language.languageCode,
                }),
            });
        },
        reject: () => {
            // Switch to the language without creating a new version
            if (currentItem) {
                editContext.loadItem({
                    ...getItemDescriptor(currentItem),
                    language: language.languageCode,
                    version: 0,
                });
            }
        },
    });
};
//# sourceMappingURL=itemutils.js.map