"use strict";

exports.__esModule = true;
exports.switchEnum = exports.ifFlag = exports.getThemeProp = void 0;

var _safeGet = _interopRequireDefault(require("./safeGet"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var feedPropFunc = function feedPropFunc(props) {
  return function (value) {
    return typeof value === "function" ? value(props) : value;
  };
};
/* Safely gets a (potentially nested) theme property, can run a function on the resulting value */


var getThemeProp = function getThemeProp(path, defaultValue, func) {
  if (func === void 0) {
    func = function func(x) {
      return x;
    };
  }

  return function (props) {
    return func(_safeGet.default.apply(void 0, [props, "theme"].concat(path.map(feedPropFunc(props)))) || feedPropFunc(props)(defaultValue));
  };
};
/* Use in styled components to check if a prop has a truthy value and
   return values based on that. */


exports.getThemeProp = getThemeProp;

var ifFlag = function ifFlag(name, thenVal, elseVal) {
  if (elseVal === void 0) {
    elseVal = "";
  }

  return function (props) {
    return props[name] ? feedPropFunc(props)(thenVal) : feedPropFunc(props)(elseVal);
  };
};
/* Creates a prop function that checks a field against a list of cases,
	 	 and gives back a found case, or a default */


exports.ifFlag = ifFlag;

var switchEnum = function switchEnum(enumField, cases) {
  return function (props) {
    return cases[props[enumField]] || cases["default"];
  };
};

exports.switchEnum = switchEnum;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(feedPropFunc, "feedPropFunc", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
  reactHotLoader.register(getThemeProp, "getThemeProp", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
  reactHotLoader.register(ifFlag, "ifFlag", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
  reactHotLoader.register(switchEnum, "switchEnum", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(feedPropFunc, "feedPropFunc", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
  reactHotLoader.register(getThemeProp, "getThemeProp", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
  reactHotLoader.register(ifFlag, "ifFlag", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
  reactHotLoader.register(switchEnum, "switchEnum", "/home/vsts/work/1/s/src/utils/styledPropFuncs.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();