/**
 * Flow Weaver Template Registry
 * Central registry for workflow and node templates
 */
// Import workflow templates
import { sequentialTemplate } from './workflows/sequential.js';
import { foreachTemplate } from './workflows/foreach.js';
import { conditionalTemplate } from './workflows/conditional.js';
import { aiAgentTemplate } from './workflows/ai-agent.js';
import { aiReactTemplate } from './workflows/ai-react.js';
import { aiRagTemplate } from './workflows/ai-rag.js';
import { aiChatTemplate } from './workflows/ai-chat.js';
import { aggregatorTemplate } from './workflows/aggregator.js';
import { webhookTemplate } from './workflows/webhook.js';
import { errorHandlerTemplate } from './workflows/error-handler.js';
// Import node templates
import { validatorNodeTemplate } from './nodes/validator.js';
import { transformerNodeTemplate } from './nodes/transformer.js';
import { httpNodeTemplate } from './nodes/http.js';
import { aggregatorNodeTemplate } from './nodes/aggregator.js';
// Import AI node templates
import { llmCallNodeTemplate } from './nodes/llm-call.js';
import { toolExecutorNodeTemplate } from './nodes/tool-executor.js';
import { conversationMemoryNodeTemplate } from './nodes/conversation-memory.js';
// Import agent node templates
import { promptTemplateNodeTemplate } from './nodes/prompt-template.js';
import { jsonExtractorNodeTemplate } from './nodes/json-extractor.js';
import { humanApprovalNodeTemplate } from './nodes/human-approval.js';
import { agentRouterNodeTemplate } from './nodes/agent-router.js';
import { ragRetrieverNodeTemplate } from './nodes/rag-retriever.js';
/**
 * All available workflow templates
 */
export const workflowTemplates = [
    sequentialTemplate,
    foreachTemplate,
    conditionalTemplate,
    aiAgentTemplate,
    aiReactTemplate,
    aiRagTemplate,
    aiChatTemplate,
    aggregatorTemplate,
    webhookTemplate,
    errorHandlerTemplate,
];
/**
 * All available node templates
 */
export const nodeTemplates = [
    validatorNodeTemplate,
    transformerNodeTemplate,
    httpNodeTemplate,
    aggregatorNodeTemplate,
    llmCallNodeTemplate,
    toolExecutorNodeTemplate,
    conversationMemoryNodeTemplate,
    promptTemplateNodeTemplate,
    jsonExtractorNodeTemplate,
    humanApprovalNodeTemplate,
    agentRouterNodeTemplate,
    ragRetrieverNodeTemplate,
];
/**
 * Get a workflow template by ID.
 * Checks both core templates and any dynamically loaded pack templates.
 */
export function getWorkflowTemplate(id) {
    return workflowTemplates.find((t) => t.id === id)
        ?? packWorkflowTemplates.find((t) => t.id === id);
}
/**
 * Get a node template by ID
 */
export function getNodeTemplate(id) {
    return nodeTemplates.find((t) => t.id === id);
}
/**
 * Dynamically loaded pack templates. Populated by loadPackTemplates().
 */
const packWorkflowTemplates = [];
/**
 * Get all workflow templates including pack-contributed ones.
 */
export function getAllWorkflowTemplates() {
    return [...workflowTemplates, ...packWorkflowTemplates];
}
/**
 * Register workflow templates contributed by a built-in extension.
 * Unlike loadPackTemplates (which scans npm packages), this is for
 * in-tree extensions that register at bootstrap time.
 */
export function registerWorkflowTemplates(templates) {
    for (const tmpl of templates) {
        if (!packWorkflowTemplates.some((t) => t.id === tmpl.id)) {
            packWorkflowTemplates.push(tmpl);
        }
    }
}
// loadPackTemplates has been moved to ./pack-loader.ts to keep Node.js-only
// imports (marketplace, fs, child_process) out of the browser bundle.
/**
 * Convert a string to camelCase
 */
export function toCamelCase(str) {
    // Preserve leading underscores/dollar signs
    const leadingMatch = str.match(/^[_$]+/);
    const leading = leadingMatch ? leadingMatch[0] : '';
    const rest = leading ? str.slice(leading.length) : str;
    const result = rest
        .replace(/[-_\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ''))
        .replace(/^[^a-zA-Z_$]+/, '') // Strip leading non-identifier chars
        .replace(/^./, (c) => c.toLowerCase());
    const final = leading + result;
    return final || '_' + str.replace(/[^a-zA-Z0-9_$]/g, '');
}
/**
 * Convert a string to PascalCase (for labels)
 */
export function toPascalCase(str) {
    const camel = toCamelCase(str);
    return camel.charAt(0).toUpperCase() + camel.slice(1);
}
//# sourceMappingURL=index.js.map