"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.addMermaid = void 0;
const utils_1 = require("../../behavior/SharedState/utils.js");
const entity_id_1 = require("../../../utils/entity-id.js");
const MermaidSpecs_1 = require("./MermaidSpecs/index.js");
exports.addMermaid = {
    isEnable(state) {
        return state.selection.empty;
    },
    run(state, dispatch, _view) {
        const newEntityId = (0, entity_id_1.generateEntityId)(MermaidSpecs_1.MermaidConsts.NodeName);
        const sharedKey = utils_1.SharedStateKey.define({ name: newEntityId });
        const tr = state.tr.insert(state.selection.from, MermaidSpecs_1.MermaidConsts.nodeType(state.schema).create({
            [MermaidSpecs_1.MermaidConsts.NodeAttrs.content]: [
                'sequenceDiagram',
                '\tAlice->>Bob: Hi Bob',
                '\tBob->>Alice: Hi Alice',
            ].join('\n'),
            [MermaidSpecs_1.MermaidConsts.NodeAttrs.newCreated]: true,
            [MermaidSpecs_1.MermaidConsts.NodeAttrs.EntityId]: newEntityId,
        }));
        sharedKey.appendTransaction.set(tr, { editing: true });
        dispatch(tr);
    },
};
//# sourceMappingURL=actions.js.map
