"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.getCompliedCustomIdProps = exports.getCompliedCustomIdOnlyProps = exports.getCompliedCustomIdOnly = exports["default"] = void 0;

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }

function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }

function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

var AUTOMATION_ID = "data-id";
/**
 * https://zgit.csez.zohocorpin.com/zohodesk/desk-library/-/blob/unified-components-master/jsapps/unifiedcomponents/src/propTypes/Readme.automation.md#automation-props-support-in-component
 * @param {*} param customId, customIdPrefix , customIdSuffix
 * @param {*} defaultCustomId 
 * @param {*} otherCustomOption 
 * @returns 
 */

var getCompliedCustomId = function getCompliedCustomId(_ref, defaultCustomId) {
  var customId = _ref.customId,
      _ref$customIdPrefix = _ref.customIdPrefix,
      customIdPrefix = _ref$customIdPrefix === void 0 ? "" : _ref$customIdPrefix,
      _ref$customIdSuffix = _ref.customIdSuffix,
      customIdSuffix = _ref$customIdSuffix === void 0 ? "" : _ref$customIdSuffix;
  var otherCustomOption = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
  var returnId = defaultCustomId || customId;

  if (typeof defaultCustomId === "function") {
    var options = ['', customIdPrefix, customIdSuffix].concat(_toConsumableArray(otherCustomOption));
    returnId = defaultCustomId.apply(null, options); //returnId = defaultCustomId`${customIdPrefix} ${customIdSuffix}`;
  }

  return returnId ? returnId.toLowerCase() : null;
};
/**
 * https://zgit.csez.zohocorpin.com/zohodesk/desk-library/-/blob/unified-components-master/jsapps/unifiedcomponents/src/propTypes/Readme.automation.md#to-avoid-prefix-and-suffix-in-nested-level-of-tags-in-html-structure-how-to-handle
 * @param  {...any} props 
 * @returns  { data-id : '...' }
 */


var getCompliedCustomIdProps = function getCompliedCustomIdProps() {
  return _defineProperty({}, AUTOMATION_ID, getCompliedCustomId.apply(void 0, arguments));
};
/**
 * https://zgit.csez.zohocorpin.com/zohodesk/desk-library/-/blob/unified-components-master/jsapps/unifiedcomponents/src/propTypes/Readme.automation.md#to-avoid-prefix-and-suffix-in-nested-level-of-tags-in-html-structure-how-to-handle
 * @param  {...any} props 
 * @returns { data-id : '...' }
 */


exports.getCompliedCustomIdProps = getCompliedCustomIdProps;

var getCompliedCustomIdOnlyProps = function getCompliedCustomIdOnlyProps() {
  return _defineProperty({}, AUTOMATION_ID, getCompliedCustomIdOnly.apply(void 0, arguments));
};
/**
 * https://zgit.csez.zohocorpin.com/zohodesk/desk-library/-/blob/unified-components-master/jsapps/unifiedcomponents/src/propTypes/Readme.automation.md#a-componentcustomidjs-in-html-part-of-component-for-only-root-level-supported-prefixsuffix
 * @param {*} defaultCustomId 
 * @param {*} otherCustomOption as array of strings
 * @returns 
 */


exports.getCompliedCustomIdOnlyProps = getCompliedCustomIdOnlyProps;

var getCompliedCustomIdOnly = function getCompliedCustomIdOnly(defaultCustomId) {
  var otherCustomOption = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  var returnId = defaultCustomId;

  if (typeof defaultCustomId === "function") {
    var options = [''].concat(_toConsumableArray(otherCustomOption));
    returnId = defaultCustomId.apply(null, options); //returnId = defaultCustomId`${customIdPrefix} ${customIdSuffix}`;
  }

  return returnId ? returnId.toLowerCase() : null;
};

exports.getCompliedCustomIdOnly = getCompliedCustomIdOnly;
var _default = getCompliedCustomId;
exports["default"] = _default;