"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.maskNotePreviewByWord = maskNotePreviewByWord;
function maskNotePreviewByWord(note) {
    var trimmed = note.trim();
    if (!trimmed) {
        return '요청 내용이 마스킹되었습니다.';
    }
    return note
        .split(/(\s+)/)
        .map(function (segment) {
        if (!segment || /\s+/.test(segment)) {
            return segment;
        }
        if (segment.length === 1) {
            return '*';
        }
        var visiblePrefixLength = segment.length >= 4 ? 1 : 0;
        var visibleSuffixLength = segment.length >= 6 ? 1 : 0;
        var maxMaskLength = Math.max(1, segment.length - visiblePrefixLength - visibleSuffixLength);
        var maskLength = Math.min(maxMaskLength, Math.max(1, Math.ceil(segment.length * 0.4)));
        var maskStart = Math.max(visiblePrefixLength, Math.floor((segment.length - maskLength) / 2));
        var maskEnd = Math.min(segment.length - visibleSuffixLength, maskStart + maskLength);
        return "".concat(segment.slice(0, maskStart)).concat('*'.repeat(maskEnd - maskStart)).concat(segment.slice(maskEnd));
    })
        .join('');
}
