function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

/*
Copyright (c) Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import * as React from 'react';
import { StyledLink } from '../link';
import { useStyletron } from '../styles';
import Column from './column';
import { COLUMNS } from './constants';

function AnchorFilter(props) {
  return /*#__PURE__*/React.createElement("div", null, "not implemented for anchor column");
}

function AnchorCell(props) {
  const [css] = useStyletron();
  return /*#__PURE__*/React.createElement("div", {
    className: css({
      display: '-webkit-box',
      WebkitLineClamp: 1,
      WebkitBoxOrient: 'vertical',
      overflow: 'hidden'
    })
  }, /*#__PURE__*/React.createElement(StyledLink, {
    $as: props.elementAs,
    href: props.value.href
  }, props.value.content));
}

function AnchorColumn(options) {
  return Column({
    kind: COLUMNS.ANCHOR,
    buildFilter: function (params) {
      return function (data) {
        return true;
      };
    },
    cellBlockAlign: options.cellBlockAlign,
    fillWidth: options.fillWidth,
    filterable: false,
    mapDataToValue: options.mapDataToValue,
    maxWidth: options.maxWidth,
    minWidth: options.minWidth,
    renderCell: function RenderAnchorCell(props) {
      return /*#__PURE__*/React.createElement(AnchorCell, _extends({}, props, {
        elementAs: options.elementAs
      }));
    },
    renderFilter: AnchorFilter,
    sortable: options.sortable === undefined ? true : options.sortable,
    sortFn: function (a, b) {
      return a.content.localeCompare(b.content);
    },
    title: options.title
  });
}

export default AnchorColumn;