import { jsx as _jsx } from "react/jsx-runtime";
import { WandSparkles } from "lucide-react";
import { TemplateBuilderDialog } from "../template-wizard/TemplateBuilderDialog";
export const createTemplateItemCommand = {
    id: "createTemplateItem",
    label: "Create Template",
    icon: _jsx(WandSparkles, { strokeWidth: 1 }),
    execute: async (context) => {
        const parentItem = context.data?.item;
        if (!parentItem)
            return;
        const resolvedParentItem = await context.editContext.itemsRepository.getItem({
            id: parentItem.id,
            language: parentItem.language || "en",
            version: 0,
        });
        if (!resolvedParentItem)
            return;
        let initialBaseTemplates = [];
        const baseTemplateId = context.data?.baseTemplateId;
        if (baseTemplateId) {
            const baseTemplateItem = await context.editContext.itemsRepository.getItem({
                id: baseTemplateId,
                language: "en",
                version: 0,
            });
            if (baseTemplateItem) {
                initialBaseTemplates = [
                    {
                        id: baseTemplateItem.id,
                        name: baseTemplateItem.name,
                        path: baseTemplateItem.path,
                        icon: baseTemplateItem.icon,
                        idPath: baseTemplateItem.idPath,
                    },
                ];
            }
        }
        const createdItem = await context.openDialog(TemplateBuilderDialog, {
            parentItem: resolvedParentItem,
            initialName: "New Template",
            initialBaseTemplates,
        });
        if (!createdItem)
            return;
        await context.editContext.loadItem(createdItem);
        context.editContext.switchWorkspace("editor");
    },
    disabled: () => false,
};
//# sourceMappingURL=templateBuilderCommands.js.map