/**
 * # Flow Weaver Constants
 *
 * This module defines reserved names and constants used throughout the Flow Weaver system.
 *
 * ## Scoped Port Architecture
 *
 * Scoped ports enable iteration patterns (forEach, map) WITHOUT graph cycles.
 * The key insight is that port directions are INVERTED for scoped ports:
 *
 * ```
 * ┌─────────────────────────────────────────────────────────────────────┐
 * │                    SCOPED PORT DIRECTION MAPPING                    │
 * ├─────────────────┬──────────┬────────────────────────────────────────┤
 * │ Scoped OUTPUT   │ Parent→  │ Parameters TO children (start, item)   │
 * │ Scoped INPUT    │ →Parent  │ Returns FROM children (success, result)│
 * └─────────────────┴──────────┴────────────────────────────────────────┘
 * ```
 *
 * **Why this inversion?**
 * - Scoped OUTPUT ports (like `start`, `item`) are data the parent SENDS to nested nodes
 * - Scoped INPUT ports (like `success`, `result`) are data the parent RECEIVES from nested nodes
 * - The loop iteration happens in the parent's imperative code, not as graph cycles
 *
 * ## Mandatory Scoped Ports
 *
 * Every scoped node must have these ports for each scope it declares:
 * - `start` (OUTPUT) - Triggers scope execution, passed as first param
 * - `success` (INPUT) - Signals successful completion from child
 * - `failure` (INPUT) - Signals failure from child
 *
 * ## Example: forEach Node
 *
 * ```typescript
 * @scope processItem
 * @output start scope:processItem    // OUTPUT → function param (triggers iteration)
 * @output item scope:processItem     // OUTPUT → function param (current item)
 * @input success scope:processItem   // INPUT → return value (completion signal)
 * @input processed scope:processItem // INPUT → return value (processed data)
 *
 * function forEach(execute, items, processItem) {
 *   const results = [];
 *   for (const item of items) {
 *     const r = processItem(true, item); // Calls generated closure
 *     if (r.success) results.push(r.processed);
 *   }
 *   return { onSuccess: true, results };
 * }
 * ```
 */
export const RESERVED_NODE_NAMES = {
    START: "Start",
    EXIT: "Exit",
};
export const RESERVED_PORT_NAMES = {
    EXECUTE: "execute",
    ON_SUCCESS: "onSuccess",
    ON_FAILURE: "onFailure",
};
// Scoped mandatory ports (different from external)
export const SCOPED_PORT_NAMES = {
    START: "start", // OUTPUT - starts scope iteration
    SUCCESS: "success", // INPUT - success signal from scope
    FAILURE: "failure", // INPUT - failure signal from scope
};
export const EXECUTION_STRATEGIES = {
    CONJUNCTION: "CONJUNCTION",
    DISJUNCTION: "DISJUNCTION",
    CUSTOM: "CUSTOM",
};
export const BRANCHING_STRATEGIES = {
    VALUE_BASED: "value-based",
    EXCEPTION_BASED: "exception-based",
    NONE: "none",
};
export function isReservedNodeName(name) {
    return Object.values(RESERVED_NODE_NAMES).includes(name);
}
export function isReservedPortName(name) {
    return Object.values(RESERVED_PORT_NAMES).includes(name);
}
export function isStartNode(nodeName) {
    return nodeName === RESERVED_NODE_NAMES.START;
}
export function isExitNode(nodeName) {
    return nodeName === RESERVED_NODE_NAMES.EXIT;
}
export function isSpecialNode(nodeName) {
    return isStartNode(nodeName) || isExitNode(nodeName);
}
/** Pseudo-nodes like `secret:NAME` are connection sources that don't correspond to real node instances. */
export function isPseudoNode(nodeName) {
    return nodeName.startsWith('secret:');
}
export function isExecutePort(portName) {
    return portName === RESERVED_PORT_NAMES.EXECUTE;
}
export function isSuccessPort(portName) {
    return portName === RESERVED_PORT_NAMES.ON_SUCCESS;
}
export function isFailurePort(portName) {
    return portName === RESERVED_PORT_NAMES.ON_FAILURE;
}
// Scoped port checks
export function isScopedStartPort(portName) {
    return portName === SCOPED_PORT_NAMES.START;
}
export function isScopedSuccessPort(portName) {
    return portName === SCOPED_PORT_NAMES.SUCCESS;
}
export function isScopedFailurePort(portName) {
    return portName === SCOPED_PORT_NAMES.FAILURE;
}
export function isScopedMandatoryPort(portName) {
    return isScopedStartPort(portName) || isScopedSuccessPort(portName) || isScopedFailurePort(portName);
}
export function isControlFlowPort(portName) {
    return (isExecutePort(portName) ||
        isSuccessPort(portName) ||
        isFailurePort(portName));
}
/**
 * Check if a port definition represents a scoped port
 * Scoped ports are FUNCTION type with a scope attribute
 */
export function isScopedPort(portDef) {
    return portDef.dataType === "FUNCTION" && portDef.scope !== undefined;
}
// ── Valid annotation values ───────────────────────────────────────────
export const VALID_NODE_COLORS = [
    'blue', 'purple', 'cyan', 'orange', 'pink', 'green', 'red', 'yellow', 'teal',
];
// ── Known annotation tags per block type ──────────────────────────────
export const KNOWN_NODETYPE_TAGS = new Set([
    'flowWeaver', 'name', 'label', 'description', 'color', 'icon', 'tag',
    'executeWhen', 'scope', 'expression', 'pullExecution', 'input', 'output', 'step',
    // Deployment annotations
    'deploy',
]);
export const KNOWN_WORKFLOW_TAGS = new Set([
    'flowWeaver', 'name', 'fwImport', 'description', 'strictTypes', 'autoConnect',
    'node', 'position', 'connect', 'scope', 'map', 'path', 'fanOut', 'fanIn',
    'coerce', 'trigger', 'cancelOn', 'retries', 'timeout', 'throttle', 'param',
    'return', 'returns',
    // Deployment annotations
    'deploy',
]);
export const KNOWN_PATTERN_TAGS = new Set([
    'flowWeaver', 'name', 'description', 'node', 'position', 'connect', 'port',
]);
export const STANDARD_JSDOC_TAGS = new Set([
    'example', 'see', 'deprecated', 'type', 'typedef', 'template',
    'link', 'since', 'version', 'author',
]);
/**
 * Build a dynamic known-workflow-tags set that includes core tags
 * plus any extra tags contributed by pack registries.
 */
export function getKnownWorkflowTags(extraTags) {
    if (!extraTags || extraTags.length === 0)
        return KNOWN_WORKFLOW_TAGS;
    return new Set([...KNOWN_WORKFLOW_TAGS, ...extraTags]);
}
//# sourceMappingURL=constants.js.map