"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.template = void 0;
var _locale = require("@mirai/locale");
const template = function () {
  let sample = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  let bindings = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  let translate = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _locale.translate;
  if (typeof sample !== 'string' || typeof bindings !== 'object') return;
  let value = sample;
  value = value.replace(/\[\[([^[\]]*)\]\]/g, (match, id) => translate({
    id
  }));
  Object.keys(bindings).forEach(key => value = value.replace(new RegExp("\\[".concat(key, "\\]"), 'g'), bindings[key]));
  return value;
};
exports.template = template;
//# sourceMappingURL=template.js.map