/**
 * task-ref.mjs — task reference parsing/formatting (C29).
 *
 * Mirror of src/helpers/task-ref.ts. Keep the two in sync.
 */
/**
 * Parse a task reference. Accepts:
 *   - "task-id" (bare) — resolves to { scope: currentScope, task_id }
 *   - "scope:task-id" — resolves to { scope, task_id }
 * URLs (http:// / https://) belong in `roadmap_ref_url`, not depends_on;
 * if handed one, we treat it as a bare id with no colon-splitting.
 * Returns null on invalid (empty, just a scope, colon-only).
 */
export function parseTaskRef(ref, currentScope) {
    if (typeof ref !== 'string')
        return null;
    const trimmed = ref.trim();
    if (!trimmed)
        return null;
    // Reject URL forms — depends_on is local-refs-only.
    if (/^https?:\/\//i.test(trimmed))
        return null;
    const colonIdx = trimmed.indexOf(':');
    if (colonIdx === -1) {
        return { scope: currentScope || 'project', task_id: trimmed };
    }
    const scope = trimmed.slice(0, colonIdx).trim();
    const taskId = trimmed.slice(colonIdx + 1).trim();
    if (!scope || !taskId)
        return null;
    return { scope, task_id: taskId };
}
/**
 * Stringify a { scope, task_id } pair back to "scope:task_id" form.
 * Used when we need to normalize depends_on entries for storage.
 */
export function formatTaskRefLocal(resolved) {
    if (!resolved || !resolved.scope || !resolved.task_id)
        return '';
    return `${resolved.scope}:${resolved.task_id}`;
}
//# sourceMappingURL=task-ref.mjs.map