"use strict";
/**
 * Shared vendor-code masking utility.
 *
 * Vendor codes follow the format `cxni_v1_<14-char-suffix>`. For display
 * (audit logs, dashboards, error responses, etc.) we mask the suffix to
 * the first 4 + last 4 chars to prevent shoulder-surfing leaks of full
 * codes while still letting an operator visually correlate a masked code
 * back to a known full code.
 *
 * Previously duplicated in:
 *   - packages/license-server/src/billing-vendor-codes-routes.ts
 *   - packages/governance-server/src/runtime-link-routes.ts
 *
 * Extracted per GitHub issue #1296 (Stern condition 5 from PR #1294 review).
 *
 * @connexum/ai-governance  shared billing util
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.maskVendorCode = maskVendorCode;
/**
 * Mask a vendor code for display.
 *
 * Examples:
 *   maskVendorCode('cxni_v1_abcdefghijklmn')  → 'cxni_v1_abcd...klmn'
 *   maskVendorCode('cxni_v1_short')           → 'cxni_v1_short'  (suffix ≤ 8 chars; nothing to mask)
 *   maskVendorCode('something-else')          → 'somethin...'    (non-standard prefix; first 8 + ellipsis)
 *
 * Pure function. Side-effect free. Same input → same output.
 */
function maskVendorCode(fullCode) {
    const prefix = 'cxni_v1_';
    if (!fullCode.startsWith(prefix)) {
        return fullCode.slice(0, 8) + '...';
    }
    const suffix = fullCode.slice(prefix.length);
    if (suffix.length <= 8)
        return prefix + suffix;
    return `${prefix}${suffix.slice(0, 4)}...${suffix.slice(-4)}`;
}
//# sourceMappingURL=vendor-code-mask.js.map