'use strict';

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var neetoCist = require('@bigbinary/neeto-cist');
var Icons = require('@bigbinary/neeto-icons/logos');
var Typography = require('@bigbinary/neetoui/Typography');
var reactI18next = require('react-i18next');
var _commonjsHelpers = require('./_commonjsHelpers-BJu3ubxk.js');
var injectCss = require('./inject-css-B6qYtOJe.js');
var jsxRuntime = require('react/jsx-runtime');

function _interopNamespaceDefault(e) {
	var n = Object.create(null);
	if (e) {
		Object.keys(e).forEach(function (k) {
			if (k !== 'default') {
				var d = Object.getOwnPropertyDescriptor(e, k);
				Object.defineProperty(n, k, d.get ? d : {
					enumerable: true,
					get: function () { return e[k]; }
				});
			}
		});
	}
	n.default = e;
	return Object.freeze(n);
}

var Icons__namespace = /*#__PURE__*/_interopNamespaceDefault(Icons);

function preserveCamelCase(str) {
	let isLastCharLower = false;
	let isLastCharUpper = false;
	let isLastLastCharUpper = false;

	for (let i = 0; i < str.length; i++) {
		const c = str[i];

		if (isLastCharLower && /[a-zA-Z]/.test(c) && c.toUpperCase() === c) {
			str = str.substr(0, i) + '-' + str.substr(i);
			isLastCharLower = false;
			isLastLastCharUpper = isLastCharUpper;
			isLastCharUpper = true;
			i++;
		} else if (isLastCharUpper && isLastLastCharUpper && /[a-zA-Z]/.test(c) && c.toLowerCase() === c) {
			str = str.substr(0, i - 1) + '-' + str.substr(i - 1);
			isLastLastCharUpper = isLastCharUpper;
			isLastCharUpper = false;
			isLastCharLower = true;
		} else {
			isLastCharLower = c.toLowerCase() === c;
			isLastLastCharUpper = isLastCharUpper;
			isLastCharUpper = c.toUpperCase() === c;
		}
	}

	return str;
}

var camelcase = function (str) {
	if (arguments.length > 1) {
		str = Array.from(arguments)
			.map(x => x.trim())
			.filter(x => x.length)
			.join('-');
	} else {
		str = str.trim();
	}

	if (str.length === 0) {
		return '';
	}

	if (str.length === 1) {
		return str.toLowerCase();
	}

	if (/^[a-z0-9]+$/.test(str)) {
		return str;
	}

	const hasUpperCase = str !== str.toLowerCase();

	if (hasUpperCase) {
		str = preserveCamelCase(str);
	}

	return str
		.replace(/^[_.\- ]+/, '')
		.toLowerCase()
		.replace(/[_.\- ]+(\w|$)/g, (m, p1) => p1.toUpperCase());
};

const camelCase = camelcase;

var uppercamelcase = function () {
	const cased = camelCase.apply(camelCase, arguments);
	return cased.charAt(0).toUpperCase() + cased.slice(1);
};

var uppercamelcase$1 = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(uppercamelcase);

var css = ".neeto-molecules-made-with__wrapper{align-items:center;background:#fff;border:.5px solid #dfdfde;border-radius:.375rem;color:#000;display:inline-flex;font-family:-apple-system,BlinkMacSystemFont,Inter,Arial,Segoe UI,Roboto,Oxygen,Ubuntu,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;font-size:.875rem;font-weight:400;gap:.375rem;padding:.375rem .5rem;transition:all;transition-duration:.3s;-webkit-user-select:none;-moz-user-select:none;user-select:none}.neeto-molecules-made-with__wrapper strong{font-weight:700}.neeto-molecules-made-with__wrapper:hover{box-shadow:inset 0 0 0 1px #dfdfde}";
injectCss.n(css,{});

var _excluded = ["productName", "productIcon"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var MadeWith = function MadeWith(_ref) {
  var _globalProps$organiza;
  var productName = _ref.productName,
    ProductIcon = _ref.productIcon,
    otherProps = _objectWithoutProperties(_ref, _excluded);
  var name = neetoCist.capitalize(productName || globalProps.appName || "Neeto");
  var subdomain = (_globalProps$organiza = globalProps.organization) === null || _globalProps$organiza === void 0 ? void 0 : _globalProps$organiza.subdomain;
  var utmParams = "utm_source=madewith".concat(subdomain ? "&utm_campaign=".concat(subdomain) : "");
  var IconComponent = ProductIcon || Icons__namespace[uppercamelcase$1(name)];
  return /*#__PURE__*/jsxRuntime.jsxs("a", _objectSpread(_objectSpread({
    className: "neeto-molecules-made-with__wrapper",
    "data-testid": "made-with-".concat(name.toLowerCase()),
    href: "https://www.neeto.com/".concat(name.toLowerCase(), "?").concat(utmParams),
    rel: "noreferrer",
    target: "_blank"
  }, otherProps), {}, {
    children: [IconComponent && /*#__PURE__*/jsxRuntime.jsx("span", {
      "data-testid": "made-with-".concat(name.toLowerCase(), "-icon"),
      children: /*#__PURE__*/jsxRuntime.jsx(IconComponent, {
        size: 14
      })
    }), /*#__PURE__*/jsxRuntime.jsx(Typography, {
      className: "leading-snug",
      style: "body2",
      children: /*#__PURE__*/jsxRuntime.jsx(reactI18next.Trans, {
        i18nKey: "neetoMolecules.common.madeWith",
        values: {
          productName: name
        }
      })
    })]
  }));
};
var index = /*#__PURE__*/React.memo(MadeWith);

module.exports = index;
//# sourceMappingURL=MadeWith.js.map
