"use strict";

var __assign = void 0 && (void 0).__assign || function () {
  __assign = Object.assign || function (t) {
    for (var s, i = 1, n = arguments.length; i < n; i++) {
      s = arguments[i];

      for (var p in s) {
        if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
      }
    }

    return t;
  };

  return __assign.apply(this, arguments);
};

var __createBinding = void 0 && (void 0).__createBinding || (Object.create ? function (o, m, k, k2) {
  if (k2 === undefined) k2 = k;
  Object.defineProperty(o, k2, {
    enumerable: true,
    get: function get() {
      return m[k];
    }
  });
} : function (o, m, k, k2) {
  if (k2 === undefined) k2 = k;
  o[k2] = m[k];
});

var __setModuleDefault = void 0 && (void 0).__setModuleDefault || (Object.create ? function (o, v) {
  Object.defineProperty(o, "default", {
    enumerable: true,
    value: v
  });
} : function (o, v) {
  o["default"] = v;
});

var __importStar = void 0 && (void 0).__importStar || function (mod) {
  if (mod && mod.__esModule) return mod;
  var result = {};
  if (mod != null) for (var k in mod) {
    if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
  }

  __setModuleDefault(result, mod);

  return result;
};

var __importDefault = void 0 && (void 0).__importDefault || function (mod) {
  return mod && mod.__esModule ? mod : {
    "default": mod
  };
};

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

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

var React = __importStar(require("react"));

var find_1 = __importDefault(require("lodash/find"));

var dropdown_1 = require("../../dropdown");

var constant_1 = require("./constant");

var DateFilter_1 = require("../DateFilter");

var FastTypes = function FastTypes(_a) {
  var value = _a.value,
      locale = _a.locale,
      getPopupContainer = _a.getPopupContainer,
      labelFastType = _a.labelFastType,
      onClickMenuItem = _a.onClickMenuItem,
      timeShortcuts = _a.timeShortcuts;
  var fastLocale = locale.fastTypeLocale;
  var fastTypeOpts = React.useMemo(function () {
    var res = [{
      title: fastLocale.unlimited,
      key: constant_1.FastTypeKeys.unlimited,
      divider: true
    }, {
      title: fastLocale.yearSelect,
      key: constant_1.FastTypeKeys.yearSelect
    }, {
      title: fastLocale.monthSelect,
      key: constant_1.FastTypeKeys.monthSelect
    }, {
      title: fastLocale.quarterSelect,
      key: constant_1.FastTypeKeys.quarterSelect,
      divider: true
    }, {
      title: fastLocale.untilNow,
      key: constant_1.FastTypeKeys.untilNow
    }, {
      title: fastLocale.today,
      key: constant_1.FastTypeKeys.today
    }, {
      title: fastLocale.yesterday,
      key: constant_1.FastTypeKeys.yesterday
    }, {
      title: fastLocale.last24Hours,
      key: constant_1.FastTypeKeys.last24Hours
    }, {
      title: fastLocale.lastWeek,
      key: constant_1.FastTypeKeys.lastWeek
    }, {
      title: fastLocale.lastMonth,
      key: constant_1.FastTypeKeys.lastMonth
    }, {
      title: fastLocale.lastQuarter,
      key: constant_1.FastTypeKeys.lastQuarter
    }, {
      title: fastLocale.lastYear,
      key: constant_1.FastTypeKeys.lastYear
    }, {
      title: fastLocale.thisWeek,
      key: constant_1.FastTypeKeys.thisWeek
    }, {
      title: fastLocale.thisMonth,
      key: constant_1.FastTypeKeys.thisMonth
    }, {
      title: fastLocale.thisYear,
      key: constant_1.FastTypeKeys.thisYear
    }, {
      title: fastLocale.tomorrow,
      key: constant_1.FastTypeKeys.tomorrow
    }, {
      title: fastLocale.future24Hours,
      key: constant_1.FastTypeKeys.future24Hours
    }, {
      title: fastLocale.nextWeek,
      key: constant_1.FastTypeKeys.nextWeek,
      divider: true
    }, {
      title: fastLocale.customer,
      key: constant_1.FastTypeKeys.customer
    }];

    if (timeShortcuts) {
      res = res.filter(function (item) {
        return timeShortcuts.includes(item.key) || item.key === constant_1.FastTypeKeys.unlimited;
      });
    }

    return res;
  }, [fastLocale.customer, fastLocale.future24Hours, fastLocale.last24Hours, fastLocale.lastMonth, fastLocale.lastQuarter, fastLocale.lastWeek, fastLocale.lastYear, fastLocale.monthSelect, fastLocale.nextWeek, fastLocale.quarterSelect, fastLocale.thisMonth, fastLocale.thisWeek, fastLocale.thisYear, fastLocale.today, fastLocale.tomorrow, fastLocale.unlimited, fastLocale.untilNow, fastLocale.yearSelect, fastLocale.yesterday, timeShortcuts]);
  var item = find_1["default"](fastTypeOpts, function (t) {
    return t.key === value;
  }) || fastTypeOpts[0];
  return jsx_runtime_1.jsxs("div", __assign({
    className: DateFilter_1.prefixCls + "-fast"
  }, {
    children: [jsx_runtime_1.jsxs("div", __assign({
      className: DateFilter_1.prefixCls + "-fast-label"
    }, {
      children: [labelFastType, "\uFF1A"]
    }), void 0), jsx_runtime_1.jsx(dropdown_1.Dropmenu, __assign({
      dropNoBorder: true,
      values: [item.key],
      menus: fastTypeOpts,
      type: 'menu-bg',
      className: DateFilter_1.prefixCls + "-dropmenu",
      getPopupContainer: getPopupContainer,
      onClickMenuItem: onClickMenuItem
    }, {
      children: item.title
    }), void 0)]
  }), void 0);
};

FastTypes.displayName = 'FastTypes';
exports["default"] = FastTypes;
var FastTypesMemo = React.memo(FastTypes);
exports.FastTypesMemo = FastTypesMemo;
FastTypesMemo.displayName = 'FastTypesMemo';

