"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const basic = require("./basic.js");
const format = require("./format.js");
const index = require("../locale/index.js");
function createTranslate(name) {
  const prefix = format.camelize(name) + ".";
  return (path, ...args) => {
    const messages = index.default.messages();
    const message = basic.get(messages, prefix + path) || basic.get(messages, path);
    return basic.isFunction(message) ? message(...args) : message;
  };
}
function genBem(name, mods) {
  if (!mods) {
    return "";
  }
  if (typeof mods === "string") {
    return ` ${name}--${mods}`;
  }
  if (Array.isArray(mods)) {
    return mods.reduce(
      (ret, item) => ret + genBem(name, item),
      ""
    );
  }
  return Object.keys(mods).reduce(
    (ret, key) => ret + (mods[key] ? genBem(name, key) : ""),
    ""
  );
}
function createBEM(name) {
  return (el, mods) => {
    if (el && typeof el !== "string") {
      mods = el;
      el = "";
    }
    el = el ? `${name}__${el}` : name;
    return `${el}${genBem(el, mods)}`;
  };
}
function createNamespace(name) {
  const prefixedName = `van-${name}`;
  return [
    prefixedName,
    createBEM(prefixedName),
    createTranslate(prefixedName)
  ];
}
exports.createBEM = createBEM;
exports.createNamespace = createNamespace;
exports.createTranslate = createTranslate;
