'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const camel2hyphen = function(str) {
  return str.replace(/[A-Z]/g, (match) => {
    return `-${match.toLowerCase()}`;
  }).toLowerCase();
};
const isDimension = function(feature) {
  const re = /[height|width]$/;
  return re.test(feature);
};
const obj2mq = function(obj) {
  let mq = "";
  const features = Object.keys(obj);
  features.forEach((feature, index) => {
    let value = obj[feature];
    feature = camel2hyphen(feature);
    if (isDimension(feature) && typeof value === "number")
      value = `${value}px`;
    if (value === true)
      mq += feature;
    else if (value === false)
      mq += `not ${feature}`;
    else
      mq += `(${feature}: ${value})`;
    if (index < features.length - 1)
      mq += " and ";
  });
  return mq;
};
function json2mq(query) {
  let mq = "";
  if (typeof query === "string")
    return query;
  if (query instanceof Array) {
    query.forEach((q, index) => {
      mq += obj2mq(q);
      if (index < query.length - 1)
        mq += ", ";
    });
    return mq;
  }
  return obj2mq(query);
}

exports.default = json2mq;
//# sourceMappingURL=json2mq.cjs.map
