"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DateCell = DateCell;
exports.TagsCell = TagsCell;
exports.defaultTableColumns = void 0;

var _react = require("react");

var timeago = _interopRequireWildcard(require("timeago.js"));

var _jsxRuntime = require("react/jsx-runtime");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var defaultTableColumns = [{
  Header: "Type",
  accessor: "config_type",
  cellClass: "px-5 py-2"
}, {
  Header: "Name",
  accessor: "name",
  cellClass: "px-5 py-2"
}, {
  Header: "Tags",
  accessor: "tags",
  Cell: TagsCell,
  cellClass: "px-5 py-2"
}, {
  Header: "Created",
  accessor: "created_at",
  Cell: DateCell,
  cellClass: "px-5 py-2"
}, {
  Header: "Last Updated",
  accessor: "updated_at",
  Cell: DateCell,
  cellClass: "px-5 py-2"
}];
exports.defaultTableColumns = defaultTableColumns;

function TagsCell(_ref) {
  var row = _ref.row,
      column = _ref.column;
  var tags = row === null || row === void 0 ? void 0 : row.values[column.id];
  var tagElements = (0, _react.useMemo)(function () {
    return tags === null || tags === void 0 ? void 0 : tags.map(function (tag) {
      return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "bg-gray-200 px-1 py-0.5 mr-1 rounded-md text-gray-600 font-semibold text-xs",
        children: tag
      }, tag);
    });
  }, [tags]);
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "flex",
    children: (tagElements === null || tagElements === void 0 ? void 0 : tagElements.length) > 0 ? tagElements : /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
      className: "text-gray-400",
      children: "none"
    })
  });
}

function DateCell(_ref2) {
  var row = _ref2.row,
      column = _ref2.column;
  var dateString = row === null || row === void 0 ? void 0 : row.values[column.id];
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: "text-xs",
    children: dateString ? timeago.format(dateString) : "None"
  });
}