import { AbstractProcessor } from './AbstractProcessor.js';
export class LifecycleProcessor extends AbstractProcessor {
    /**
     * Process lifecycle definition (shorthand or structured)
     */
    process(name, definition) {
        if (definition.flow) {
            // Shorthand: "draft -> active -> suspended"
            const states = definition.flow.split('->').map((s) => s.trim());
            const actions = states.slice(1).map((state) => `to_${state}`);
            return {
                name,
                type: 'shorthand',
                states,
                actions
            };
        }
        else if (definition.states && definition.transitions) {
            // Structured: explicit states and transitions
            const transitions = {};
            const actions = [];
            for (const [action, transitionDef] of Object.entries(definition.transitions)) {
                const match = transitionDef.match(/^(\w+)\s*->\s*(\w+)(?:\s+when=(.+))?$/);
                if (match) {
                    const [, from, to, condition] = match;
                    transitions[action] = { from, to, condition };
                    actions.push(action);
                }
            }
            return {
                name,
                type: 'structured',
                states: definition.states,
                transitions,
                actions
            };
        }
        throw new Error(`Invalid lifecycle definition for ${name}`);
    }
}
//# sourceMappingURL=LifecycleProcessor.js.map