"use strict";
/**
 * Derive a short "run label" — a 1–2 word, plain-English description of the
 * INTENT behind the prompt that kicked off a variant run. Every variant in a
 * run shares this label; it's what the variant table shows on each row so the
 * user can tell which prompt a direction came from.
 *
 * Deterministic (no LLM): strip a leading command phrase ("make it", "add a",
 * …), truncate at the first conjunction so only the primary intent survives
 * ("brighter and more vibrant" → "brighter"), drop filler words, and
 * title-case the first 1–2 content words.
 *
 * Examples:
 *   "make it brighter and more vibrant" → "Brighter"
 *   "add a sticky header"               → "Sticky Header"
 *   "dark mode"                         → "Dark Mode"
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.deriveRunLabel = deriveRunLabel;
// Leading imperative phrasing that carries no intent — stripped from the front.
// Longest-first so "make it" wins over "make".
const LEADING_COMMANDS = [
    'turn it into',
    'i would like',
    'make it more',
    'make it',
    'make the',
    'make',
    'turn it',
    'turn the',
    'turn',
    'can you',
    'could you',
    'please',
    'i want',
    "i'd like",
    "let's",
    'lets',
    'give it',
    'give the',
    'give',
    'add a',
    'add an',
    'add',
    'create a',
    'create an',
    'create',
    'build a',
    'build an',
    'build',
    'change the',
    'change',
    'update the',
    'update',
    'redesign the',
    'redesign',
    'improve the',
    'improve',
    'refactor the',
    'refactor',
    'tweak the',
    'tweak',
    'adjust the',
    'adjust',
    'set the',
    'set',
    'rework the',
    'rework',
];
// Words that split the primary intent from secondary clauses — stop here.
const CONJUNCTIONS = new Set([
    'and',
    'or',
    'but',
    'then',
    'plus',
    'with',
    'while',
    'so',
]);
// Low-signal words dropped from the chosen tokens.
const FILLER = new Set([
    'it',
    'its',
    "it's",
    'the',
    'a',
    'an',
    'more',
    'less',
    'very',
    'really',
    'much',
    'bit',
    'little',
    'some',
    'this',
    'that',
    'into',
    'for',
    'of',
    'on',
    'to',
    'be',
    'is',
    'look',
    'looks',
    'feel',
    'feels',
    'way',
    'overall',
    'all',
]);
const titleCase = (words) => words
    .map((w) => (w ? w[0].toUpperCase() + w.slice(1) : w))
    .join(' ')
    .slice(0, 24);
function deriveRunLabel(prompt) {
    const raw = (prompt ?? '').trim();
    if (!raw)
        return 'Variants';
    let text = raw.toLowerCase().replace(/[`*_#>~"]/g, ' ');
    for (const cmd of LEADING_COMMANDS) {
        if (text.startsWith(cmd + ' ')) {
            text = text.slice(cmd.length).trim();
            break;
        }
    }
    const tokens = [];
    for (const tok of text.split(/[\s,;./]+/)) {
        const w = tok.replace(/[^a-z0-9-]/g, '');
        if (!w)
            continue;
        if (CONJUNCTIONS.has(w))
            break;
        tokens.push(w);
    }
    const content = tokens.filter((w) => !FILLER.has(w));
    const picked = (content.length ? content : tokens).slice(0, 2);
    if (picked.length === 0) {
        const fallback = raw.split(/\s+/).slice(0, 2);
        return titleCase(fallback) || 'Variants';
    }
    return titleCase(picked);
}
//# sourceMappingURL=runLabel.js.map