"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const strict_1 = __importDefault(require("node:assert/strict"));
const node_child_process_1 = require("node:child_process");
const fs = __importStar(require("node:fs"));
const os = __importStar(require("node:os"));
const path = __importStar(require("node:path"));
const config_1 = require("../config");
// ─── mergeNullDelimited ────────────────────────────────────────────────────────
(0, node_test_1.describe)('mergeNullDelimited', () => {
    (0, node_test_1.beforeEach)(() => {
        delete process.env['__TEST_MERGE_A'];
        delete process.env['__TEST_MERGE_B'];
        delete process.env['__TEST_MERGE_EXISTING'];
    });
    (0, node_test_1.afterEach)(() => {
        delete process.env['__TEST_MERGE_A'];
        delete process.env['__TEST_MERGE_B'];
        delete process.env['__TEST_MERGE_EXISTING'];
    });
    (0, node_test_1.it)('sets new variables from null-delimited env output', () => {
        (0, config_1.mergeNullDelimited)('__TEST_MERGE_A=hello\0__TEST_MERGE_B=world\0');
        strict_1.default.equal(process.env['__TEST_MERGE_A'], 'hello');
        strict_1.default.equal(process.env['__TEST_MERGE_B'], 'world');
    });
    (0, node_test_1.it)('does not overwrite variables already in process.env', () => {
        process.env['__TEST_MERGE_EXISTING'] = 'original';
        (0, config_1.mergeNullDelimited)('__TEST_MERGE_EXISTING=overwritten\0');
        strict_1.default.equal(process.env['__TEST_MERGE_EXISTING'], 'original');
    });
    (0, node_test_1.it)('handles values containing = signs', () => {
        (0, config_1.mergeNullDelimited)('__TEST_MERGE_A=a=b=c\0');
        strict_1.default.equal(process.env['__TEST_MERGE_A'], 'a=b=c');
    });
    (0, node_test_1.it)('skips entries with no = sign', () => {
        (0, config_1.mergeNullDelimited)('NOEQUALS\0__TEST_MERGE_A=ok\0');
        strict_1.default.equal(process.env['__TEST_MERGE_A'], 'ok');
    });
    (0, node_test_1.it)('handles empty string without throwing', () => {
        strict_1.default.doesNotThrow(() => (0, config_1.mergeNullDelimited)(''));
    });
});
// ─── sourceShellProfile ────────────────────────────────────────────────────────
// These tests only run on POSIX (macOS / Linux) since Windows uses PowerShell + registry.
const itPosix = process.platform === 'win32' ? node_test_1.it.skip : node_test_1.it;
(0, node_test_1.describe)('sourceShellProfile', () => {
    let tmpDir;
    const testKey = '__AIDEV_PROFILE_TEST';
    const testKey2 = '__AIDEV_PROFILE_TEST2';
    (0, node_test_1.beforeEach)(() => {
        tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'aidev-profile-test-'));
        delete process.env[testKey];
        delete process.env[testKey2];
    });
    (0, node_test_1.afterEach)(() => {
        fs.rmSync(tmpDir, { recursive: true, force: true });
        delete process.env[testKey];
        delete process.env[testKey2];
    });
    itPosix('picks up an exported variable from the profile', () => {
        const rc = path.join(tmpDir, '.testrc');
        fs.writeFileSync(rc, `export ${testKey}=from_profile\n`);
        (0, config_1.sourceShellProfile)([rc]);
        strict_1.default.equal(process.env[testKey], 'from_profile');
    });
    itPosix('profile with alias definitions does not break env sourcing', () => {
        // Aliases are shell-internal and won't appear in process.env, but their
        // presence must not prevent exported variables from being captured.
        const rc = path.join(tmpDir, '.testrc');
        fs.writeFileSync(rc, `alias gst='git status'\nexport ${testKey}=alongside_alias\n`);
        (0, config_1.sourceShellProfile)([rc]);
        strict_1.default.equal(process.env[testKey], 'alongside_alias');
        // Aliases are not environment variables — they must not leak into process.env
        strict_1.default.equal(process.env['gst'], undefined);
    });
    itPosix('does not overwrite an already-set variable', () => {
        process.env[testKey] = 'existing';
        const rc = path.join(tmpDir, '.testrc');
        fs.writeFileSync(rc, `export ${testKey}=from_profile\n`);
        (0, config_1.sourceShellProfile)([rc]);
        strict_1.default.equal(process.env[testKey], 'existing');
    });
    itPosix('sources multiple profile files in order', () => {
        const rc1 = path.join(tmpDir, '.rc1');
        const rc2 = path.join(tmpDir, '.rc2');
        fs.writeFileSync(rc1, `export ${testKey}=from_rc1\n`);
        fs.writeFileSync(rc2, `export ${testKey2}=from_rc2\n`);
        (0, config_1.sourceShellProfile)([rc1, rc2]);
        strict_1.default.equal(process.env[testKey], 'from_rc1');
        strict_1.default.equal(process.env[testKey2], 'from_rc2');
    });
    itPosix('silently ignores non-existent profile files', () => {
        const missing = path.join(tmpDir, 'does_not_exist');
        const rc = path.join(tmpDir, '.testrc');
        fs.writeFileSync(rc, `export ${testKey}=still_works\n`);
        strict_1.default.doesNotThrow(() => (0, config_1.sourceShellProfile)([missing, rc]));
        strict_1.default.equal(process.env[testKey], 'still_works');
    });
    itPosix('exported variable propagates to child processes after sourcing', () => {
        const rc = path.join(tmpDir, '.testrc');
        fs.writeFileSync(rc, `export ${testKey}=child_test_value\n`);
        (0, config_1.sourceShellProfile)([rc]);
        strict_1.default.equal(process.env[testKey], 'child_test_value');
        // Simulate how aidev spawns AI runners (claude, cursor, etc.) — they inherit process.env
        const child = (0, node_child_process_1.spawnSync)(process.execPath, // node
        ['-e', `process.stdout.write(process.env['${testKey}'] || 'NOT_FOUND')`], { encoding: 'utf8', env: process.env });
        strict_1.default.equal(child.stdout, 'child_test_value');
    });
    itPosix('variable with special characters in value is captured correctly', () => {
        const rc = path.join(tmpDir, '.testrc');
        fs.writeFileSync(rc, `export ${testKey}="hello=world:path/to/thing"\n`);
        (0, config_1.sourceShellProfile)([rc]);
        strict_1.default.equal(process.env[testKey], 'hello=world:path/to/thing');
    });
});
// ─── applyEnvFiles (AIDEV_ENV_EXTEND) ─────────────────────────────────────────
const EXT_A = '__AIDEV_EXT_A';
const EXT_B = '__AIDEV_EXT_B';
const EXT_C = '__AIDEV_EXT_C';
const EXT_ALL = [EXT_A, EXT_B, EXT_C, 'AIDEV_ENV_EXTEND'];
(0, node_test_1.describe)('applyEnvFiles', () => {
    let tmpDir;
    (0, node_test_1.beforeEach)(() => {
        tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'aidev-envfiles-'));
        EXT_ALL.forEach((k) => delete process.env[k]);
    });
    (0, node_test_1.afterEach)(() => {
        fs.rmSync(tmpDir, { recursive: true, force: true });
        EXT_ALL.forEach((k) => delete process.env[k]);
    });
    (0, node_test_1.it)('loads variables from a local env file', () => {
        const local = path.join(tmpDir, '.env.aidev');
        fs.writeFileSync(local, `${EXT_A}=from_local\n`);
        (0, config_1.applyEnvFiles)(local);
        strict_1.default.equal(process.env[EXT_A], 'from_local');
    });
    (0, node_test_1.it)('loads global extend file values as base', () => {
        const global = path.join(tmpDir, '.aidev.global');
        fs.writeFileSync(global, `${EXT_A}=from_global\n${EXT_B}=global_only\n`);
        const local = path.join(tmpDir, '.env.aidev');
        fs.writeFileSync(local, `${EXT_A}=from_local\n`);
        (0, config_1.applyEnvFiles)(local, global);
        // local wins over global for EXT_A
        strict_1.default.equal(process.env[EXT_A], 'from_local');
        // global-only key is still loaded
        strict_1.default.equal(process.env[EXT_B], 'global_only');
    });
    (0, node_test_1.it)('local .env.aidev AIDEV_ENV_EXTEND entry is used when no explicit path given', () => {
        const global = path.join(tmpDir, '.aidev.global');
        fs.writeFileSync(global, `${EXT_B}=from_global_via_local_ref\n`);
        const local = path.join(tmpDir, '.env.aidev');
        fs.writeFileSync(local, `AIDEV_ENV_EXTEND=${global}\n${EXT_A}=local_val\n`);
        (0, config_1.applyEnvFiles)(local);
        strict_1.default.equal(process.env[EXT_A], 'local_val');
        strict_1.default.equal(process.env[EXT_B], 'from_global_via_local_ref');
    });
    (0, node_test_1.it)('process.env variables override both local and global', () => {
        process.env[EXT_A] = 'shell_value';
        const global = path.join(tmpDir, '.aidev.global');
        fs.writeFileSync(global, `${EXT_A}=global_value\n`);
        const local = path.join(tmpDir, '.env.aidev');
        fs.writeFileSync(local, `${EXT_A}=local_value\n`);
        (0, config_1.applyEnvFiles)(local, global);
        strict_1.default.equal(process.env[EXT_A], 'shell_value');
    });
    (0, node_test_1.it)('explicit envExtend arg overrides AIDEV_ENV_EXTEND entry inside local file', () => {
        const globalA = path.join(tmpDir, 'global_a');
        fs.writeFileSync(globalA, `${EXT_A}=from_global_a\n`);
        const globalB = path.join(tmpDir, 'global_b');
        fs.writeFileSync(globalB, `${EXT_B}=from_global_b\n`);
        const local = path.join(tmpDir, '.env.aidev');
        // local points to globalA via AIDEV_ENV_EXTEND, but caller passes globalB explicitly
        fs.writeFileSync(local, `AIDEV_ENV_EXTEND=${globalA}\n`);
        (0, config_1.applyEnvFiles)(local, globalB);
        // globalB was used (explicit wins)
        strict_1.default.equal(process.env[EXT_B], 'from_global_b');
        // globalA was NOT used
        strict_1.default.equal(process.env[EXT_A], undefined);
    });
    (0, node_test_1.it)('silently skips a missing global file', () => {
        const missing = path.join(tmpDir, 'does_not_exist');
        const local = path.join(tmpDir, '.env.aidev');
        fs.writeFileSync(local, `${EXT_A}=still_works\n`);
        strict_1.default.doesNotThrow(() => (0, config_1.applyEnvFiles)(local, missing));
        strict_1.default.equal(process.env[EXT_A], 'still_works');
    });
    (0, node_test_1.it)('works when no local file exists', () => {
        const global = path.join(tmpDir, '.aidev.global');
        fs.writeFileSync(global, `${EXT_A}=global_only\n`);
        (0, config_1.applyEnvFiles)(undefined, global);
        strict_1.default.equal(process.env[EXT_A], 'global_only');
    });
    (0, node_test_1.it)('vars loaded from global file propagate to child processes', () => {
        const global = path.join(tmpDir, '.aidev.global');
        fs.writeFileSync(global, `${EXT_C}=child_sees_this\n`);
        (0, config_1.applyEnvFiles)(undefined, global);
        strict_1.default.equal(process.env[EXT_C], 'child_sees_this');
        const child = (0, node_child_process_1.spawnSync)(process.execPath, ['-e', `process.stdout.write(process.env['${EXT_C}'] || 'NOT_FOUND')`], { encoding: 'utf8', env: process.env });
        strict_1.default.equal(child.stdout, 'child_sees_this');
    });
    (0, node_test_1.it)('resolves AIDEV_ENV_EXTEND relative path against local file directory', () => {
        // global file sits alongside .env.aidev
        const global = path.join(tmpDir, '.aidev.global');
        fs.writeFileSync(global, `${EXT_B}=relative_global\n`);
        const local = path.join(tmpDir, '.env.aidev');
        // stored as a relative path in the local file
        fs.writeFileSync(local, `AIDEV_ENV_EXTEND=.aidev.global\n${EXT_A}=local_val\n`);
        (0, config_1.applyEnvFiles)(local);
        strict_1.default.equal(process.env[EXT_A], 'local_val');
        strict_1.default.equal(process.env[EXT_B], 'relative_global');
    });
});
// ─── resolveEnvPath ────────────────────────────────────────────────────────────
(0, node_test_1.describe)('resolveEnvPath', () => {
    (0, node_test_1.it)('returns absolute paths unchanged', () => {
        strict_1.default.equal((0, config_1.resolveEnvPath)('/etc/aidev.global', '/any/base'), '/etc/aidev.global');
    });
    (0, node_test_1.it)('expands ~ to the home directory', () => {
        const result = (0, config_1.resolveEnvPath)('~/.aidev.global', '/any/base');
        strict_1.default.equal(result, path.join(os.homedir(), '.aidev.global'));
    });
    (0, node_test_1.it)('expands ~/subdir correctly', () => {
        const result = (0, config_1.resolveEnvPath)('~/conf/aidev.global', '/any/base');
        strict_1.default.equal(result, path.join(os.homedir(), 'conf/aidev.global'));
    });
    (0, node_test_1.it)('resolves relative paths against the supplied base', () => {
        const base = '/projects/myapp';
        const result = (0, config_1.resolveEnvPath)('.aidev.global', base);
        strict_1.default.equal(result, path.resolve(base, '.aidev.global'));
    });
    (0, node_test_1.it)('resolves ../ relative paths correctly', () => {
        const base = '/projects/myapp';
        const result = (0, config_1.resolveEnvPath)('../shared/aidev.global', base);
        strict_1.default.equal(result, path.resolve(base, '../shared/aidev.global'));
    });
});
// ─── loadConfig tag defaults ──────────────────────────────────────────────────
(0, node_test_1.describe)('loadConfig tag defaults', () => {
    const envKeys = [
        'CLICKUP_API_KEY', 'CLICKUP_TEAM_ID', 'CLICKUP_TAG',
        'NON_CODE_TAG', 'JIRA_LABEL', 'PROVIDER',
        'ACCEPTED_TAG',
    ];
    const saved = {};
    let tmpDir;
    let origCwd;
    (0, node_test_1.beforeEach)(() => {
        for (const k of envKeys) {
            saved[k] = process.env[k];
            delete process.env[k];
        }
        tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'aidev-tagdefault-'));
        origCwd = process.cwd();
        process.chdir(tmpDir);
        // Minimal .env.aidev with only required ClickUp fields
        fs.writeFileSync(path.join(tmpDir, '.env.aidev'), 'CLICKUP_API_KEY=pk_test\nCLICKUP_TEAM_ID=12345\n');
    });
    (0, node_test_1.afterEach)(() => {
        process.chdir(origCwd);
        fs.rmSync(tmpDir, { recursive: true, force: true });
        for (const k of envKeys) {
            if (saved[k] !== undefined)
                process.env[k] = saved[k];
            else
                delete process.env[k];
        }
    });
    (0, node_test_1.it)('defaults clickupTag to the folder name when CLICKUP_TAG is unset', () => {
        const config = (0, config_1.loadConfig)();
        const folderName = path.basename(tmpDir);
        strict_1.default.equal(config.clickupTag, folderName);
    });
    (0, node_test_1.it)('defaults nonCodeTag to folder-name + "-other" when NON_CODE_TAG is unset', () => {
        const config = (0, config_1.loadConfig)();
        const folderName = path.basename(tmpDir);
        strict_1.default.equal(config.nonCodeTag, `${folderName}-other`);
    });
    (0, node_test_1.it)('defaults jiraLabel to the folder name when JIRA_LABEL is unset', () => {
        const config = (0, config_1.loadConfig)();
        const folderName = path.basename(tmpDir);
        strict_1.default.equal(config.jiraLabel, folderName);
    });
    (0, node_test_1.it)('respects explicit CLICKUP_TAG when set', () => {
        process.env.CLICKUP_TAG = 'custom-tag';
        const config = (0, config_1.loadConfig)();
        strict_1.default.equal(config.clickupTag, 'custom-tag');
        delete process.env.CLICKUP_TAG;
    });
    (0, node_test_1.it)('respects explicit NON_CODE_TAG when set', () => {
        process.env.NON_CODE_TAG = 'my-noncode';
        const config = (0, config_1.loadConfig)();
        strict_1.default.equal(config.nonCodeTag, 'my-noncode');
        delete process.env.NON_CODE_TAG;
    });
    (0, node_test_1.it)('does not require CLICKUP_TAG in env', () => {
        strict_1.default.doesNotThrow(() => (0, config_1.loadConfig)());
    });
    (0, node_test_1.it)('defaults acceptedTag to "accepted" when ACCEPTED_TAG is unset', () => {
        delete process.env.ACCEPTED_TAG;
        const config = (0, config_1.loadConfig)();
        strict_1.default.equal(config.acceptedTag, 'accepted');
    });
    (0, node_test_1.it)('respects explicit ACCEPTED_TAG when set', () => {
        process.env.ACCEPTED_TAG = 'approved';
        try {
            const config = (0, config_1.loadConfig)();
            strict_1.default.equal(config.acceptedTag, 'approved');
        }
        finally {
            delete process.env.ACCEPTED_TAG;
        }
    });
});
// ─── loadConfig AGENTS parsing ────────────────────────────────────────────────
(0, node_test_1.describe)('loadConfig AGENTS parsing', () => {
    const envKeys = [
        'CLICKUP_API_KEY', 'CLICKUP_TEAM_ID', 'AGENTS', 'PROVIDER',
    ];
    const saved = {};
    let tmpDir;
    let origCwd;
    (0, node_test_1.beforeEach)(() => {
        for (const k of envKeys) {
            saved[k] = process.env[k];
            delete process.env[k];
        }
        tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'aidev-agents-'));
        origCwd = process.cwd();
        process.chdir(tmpDir);
    });
    (0, node_test_1.afterEach)(() => {
        process.chdir(origCwd);
        fs.rmSync(tmpDir, { recursive: true, force: true });
        for (const k of envKeys) {
            if (saved[k] !== undefined)
                process.env[k] = saved[k];
            else
                delete process.env[k];
        }
    });
    function writeEnv(content) {
        fs.writeFileSync(path.join(tmpDir, '.env.aidev'), `CLICKUP_API_KEY=pk_test\nCLICKUP_TEAM_ID=12345\n${content}`);
    }
    (0, node_test_1.it)('defaults to claude,cursor when AGENTS is not set', () => {
        writeEnv('');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['claude', 'cursor']);
    });
    (0, node_test_1.it)('parses AGENTS from env file and preserves order', () => {
        writeEnv('AGENTS=cursor,windsurf,claude');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['cursor', 'windsurf', 'claude']);
    });
    (0, node_test_1.it)('parses AGENTS with reversed order', () => {
        writeEnv('AGENTS=claude,windsurf,cursor');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['claude', 'windsurf', 'cursor']);
    });
    (0, node_test_1.it)('handles single agent', () => {
        writeEnv('AGENTS=cursor');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['cursor']);
    });
    (0, node_test_1.it)('trims whitespace around agent names', () => {
        writeEnv('AGENTS= cursor , claude ');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['cursor', 'claude']);
    });
    (0, node_test_1.it)('handles quoted value in env file (dotenv strips quotes)', () => {
        writeEnv('AGENTS="cursor,windsurf,claude"');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['cursor', 'windsurf', 'claude']);
    });
    (0, node_test_1.it)('throws on invalid agent name', () => {
        writeEnv('AGENTS=cursor,invalid_agent');
        strict_1.default.throws(() => (0, config_1.loadConfig)(), /Invalid agent/);
    });
    (0, node_test_1.it)('falls back to default when AGENTS is empty string (falsy)', () => {
        process.env.AGENTS = '';
        writeEnv('');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['claude', 'cursor']);
    });
    (0, node_test_1.it)('throws when AGENTS contains only commas (no valid agents)', () => {
        process.env.AGENTS = ',,,';
        writeEnv('');
        strict_1.default.throws(() => (0, config_1.loadConfig)(), /at least one agent/);
    });
    (0, node_test_1.it)('process.env AGENTS overrides env file value', () => {
        process.env.AGENTS = 'claude';
        writeEnv('AGENTS=cursor,windsurf,claude');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['claude']);
        delete process.env.AGENTS;
    });
    (0, node_test_1.it)('accepts anthropic-sdk as a valid agent', () => {
        writeEnv('AGENTS=anthropic-sdk');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['anthropic-sdk']);
    });
    (0, node_test_1.it)('accepts anthropic-sdk alongside other agents', () => {
        writeEnv('AGENTS=claude,anthropic-sdk,cursor');
        const config = (0, config_1.loadConfig)();
        strict_1.default.deepEqual(config.agents, ['claude', 'anthropic-sdk', 'cursor']);
    });
});
// ─── parseAnthropicTokens ─────────────────────────────────────────────────────
(0, node_test_1.describe)('parseAnthropicTokens', () => {
    (0, node_test_1.it)('returns an empty array for an empty string', () => {
        strict_1.default.deepEqual((0, config_1.parseAnthropicTokens)(''), []);
    });
    (0, node_test_1.it)('parses a single token', () => {
        strict_1.default.deepEqual((0, config_1.parseAnthropicTokens)('sk-ant-key-1'), ['sk-ant-key-1']);
    });
    (0, node_test_1.it)('parses multiple comma-separated tokens', () => {
        strict_1.default.deepEqual((0, config_1.parseAnthropicTokens)('sk-ant-key-1,sk-ant-key-2,sk-ant-key-3'), ['sk-ant-key-1', 'sk-ant-key-2', 'sk-ant-key-3']);
    });
    (0, node_test_1.it)('trims whitespace around tokens', () => {
        strict_1.default.deepEqual((0, config_1.parseAnthropicTokens)(' sk-ant-key-1 , sk-ant-key-2 '), ['sk-ant-key-1', 'sk-ant-key-2']);
    });
    (0, node_test_1.it)('drops empty entries from trailing or consecutive commas', () => {
        strict_1.default.deepEqual((0, config_1.parseAnthropicTokens)('sk-ant-key-1,,sk-ant-key-2,'), ['sk-ant-key-1', 'sk-ant-key-2']);
    });
    (0, node_test_1.it)('returns an empty array for a string of only commas and whitespace', () => {
        strict_1.default.deepEqual((0, config_1.parseAnthropicTokens)(' , , , '), []);
    });
});
// ─── pickNextToken ────────────────────────────────────────────────────────────
(0, node_test_1.describe)('pickNextToken', () => {
    (0, node_test_1.it)('returns undefined token and cursor 0 for an empty list', () => {
        strict_1.default.deepEqual((0, config_1.pickNextToken)([], 0), { token: undefined, nextCursor: 0 });
        strict_1.default.deepEqual((0, config_1.pickNextToken)([], 5), { token: undefined, nextCursor: 0 });
    });
    (0, node_test_1.it)('returns the only token and wraps cursor to 0 for a single-token list', () => {
        strict_1.default.deepEqual((0, config_1.pickNextToken)(['a'], 0), { token: 'a', nextCursor: 0 });
        strict_1.default.deepEqual((0, config_1.pickNextToken)(['a'], 1), { token: 'a', nextCursor: 0 });
    });
    (0, node_test_1.it)('rotates through tokens in order', () => {
        const tokens = ['a', 'b', 'c'];
        let cursor = 0;
        const seen = [];
        for (let i = 0; i < 6; i++) {
            const { token, nextCursor } = (0, config_1.pickNextToken)(tokens, cursor);
            seen.push(token);
            cursor = nextCursor;
        }
        strict_1.default.deepEqual(seen, ['a', 'b', 'c', 'a', 'b', 'c']);
    });
    (0, node_test_1.it)('wraps cursor back to 0 after the last token', () => {
        strict_1.default.deepEqual((0, config_1.pickNextToken)(['a', 'b'], 1), { token: 'b', nextCursor: 0 });
    });
    (0, node_test_1.it)('normalizes an out-of-range cursor via modulo', () => {
        strict_1.default.deepEqual((0, config_1.pickNextToken)(['a', 'b', 'c'], 7), { token: 'b', nextCursor: 2 });
    });
});
//# sourceMappingURL=config.test.js.map