var trials = require('trials');
var souls = require('zalgo-souls');

/**
 * Transforms string to zalgo text.
 *
 * @param {string} string string
 * @param {number} [p=0.2] p
 * @param {array} [maxs=[5, 3, 5]] maxs
 * @return {string} string
 *
 * @example
 * var snu = require('s-node-utils');
 *
 * snu.string.zalgolize('this');
 * //=> t̋hiͤsͮ
 */
module.exports = function(str, p = 0.2, maxs = [5, 3, 5]) {
  var res = '';
  for (var i = 0; i < str.length; i += 1) {
    res += str[i];
    for (var k = 0; k < souls.length; k += 1) {
      res += trials.cluster(souls[k], maxs[k], p).join('');
    }
  }
  return res;
};
