11cb0ef41Sopenharmony_ci'use strict';
21cb0ef41Sopenharmony_ci
31cb0ef41Sopenharmony_cimodule.exports = (string, count = 1, options) => {
41cb0ef41Sopenharmony_ci	options = {
51cb0ef41Sopenharmony_ci		indent: ' ',
61cb0ef41Sopenharmony_ci		includeEmptyLines: false,
71cb0ef41Sopenharmony_ci		...options
81cb0ef41Sopenharmony_ci	};
91cb0ef41Sopenharmony_ci
101cb0ef41Sopenharmony_ci	if (typeof string !== 'string') {
111cb0ef41Sopenharmony_ci		throw new TypeError(
121cb0ef41Sopenharmony_ci			`Expected \`input\` to be a \`string\`, got \`${typeof string}\``
131cb0ef41Sopenharmony_ci		);
141cb0ef41Sopenharmony_ci	}
151cb0ef41Sopenharmony_ci
161cb0ef41Sopenharmony_ci	if (typeof count !== 'number') {
171cb0ef41Sopenharmony_ci		throw new TypeError(
181cb0ef41Sopenharmony_ci			`Expected \`count\` to be a \`number\`, got \`${typeof count}\``
191cb0ef41Sopenharmony_ci		);
201cb0ef41Sopenharmony_ci	}
211cb0ef41Sopenharmony_ci
221cb0ef41Sopenharmony_ci	if (typeof options.indent !== 'string') {
231cb0ef41Sopenharmony_ci		throw new TypeError(
241cb0ef41Sopenharmony_ci			`Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\``
251cb0ef41Sopenharmony_ci		);
261cb0ef41Sopenharmony_ci	}
271cb0ef41Sopenharmony_ci
281cb0ef41Sopenharmony_ci	if (count === 0) {
291cb0ef41Sopenharmony_ci		return string;
301cb0ef41Sopenharmony_ci	}
311cb0ef41Sopenharmony_ci
321cb0ef41Sopenharmony_ci	const regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
331cb0ef41Sopenharmony_ci
341cb0ef41Sopenharmony_ci	return string.replace(regex, options.indent.repeat(count));
351cb0ef41Sopenharmony_ci};
36