"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.DynamicSelectMemo = void 0;

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

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

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

var select_1 = __importDefault(require("../../select"));

var input_1 = require("../../input");

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

var checkbox_1 = __importDefault(require("../../checkbox"));

var DynamicSelect = function DynamicSelect(_a) {
  var _b;

  var type = _a.type,
      unit = _a.unit,
      locale = _a.locale,
      onTypeChange = _a.onTypeChange,
      dynamicVal = _a.dynamicVal,
      onNumChange = _a.onNumChange,
      onUnitChange = _a.onUnitChange,
      getPopupContainer = _a.getPopupContainer,
      nature = _a.nature,
      onNatureChange = _a.onNatureChange;
  var fLocale = locale.filterLocale,
      dLocale = locale.dateUnitLocale;
  var typeOptions = [constant_1.DynamincType.after, constant_1.DynamincType.before].map(function (t) {
    return {
      label: fLocale[t],
      key: t,
      value: t
    };
  });
  var natureTitle = (_b = {}, _b[constant_1.DateUnitKeys.years] = dLocale.yearsInclude, _b[constant_1.DateUnitKeys.quarter] = dLocale.quarterInclude, _b[constant_1.DateUnitKeys.month] = dLocale.monthInclude, _b[constant_1.DateUnitKeys.week] = dLocale.weekInclude, _b);
  var unitOptions = [constant_1.DateUnitKeys.years, constant_1.DateUnitKeys.quarter, constant_1.DateUnitKeys.month, constant_1.DateUnitKeys.week, constant_1.DateUnitKeys.day, constant_1.DateUnitKeys.hour, constant_1.DateUnitKeys.minute // DateUnitKeys.second,
  ].map(function (t) {
    return {
      label: dLocale[t],
      value: t,
      key: t
    };
  });
  return jsx_runtime_1.jsxs("div", __assign({
    className: DateFilter_1.prefixCls + "-dynamic"
  }, {
    children: [jsx_runtime_1.jsxs("div", __assign({
      className: DateFilter_1.prefixCls + "-dynamic-label"
    }, {
      children: [fLocale.labelDynamic, "\uFF1A"]
    }), void 0), jsx_runtime_1.jsx(select_1["default"], {
      size: "mini",
      type: "menu-bg",
      value: type,
      options: typeOptions,
      onChange: onTypeChange,
      getPopupContainer: getPopupContainer
    }, void 0), jsx_runtime_1.jsx(input_1.InputNumber, {
      size: "compact",
      type: "menu-bg",
      value: dynamicVal,
      onChange: onNumChange,
      style: {
        width: 89
      },
      visibilityHandler: true,
      placeholder: fLocale.placeholder,
      className: DateFilter_1.prefixCls + "-dynamic-input"
    }, void 0), jsx_runtime_1.jsx(select_1["default"], {
      size: "mini",
      type: "menu-bg",
      value: unit,
      options: unitOptions,
      onChange: onUnitChange,
      getPopupContainer: getPopupContainer
    }, void 0), natureTitle[unit] && jsx_runtime_1.jsx(checkbox_1["default"], {
      className: DateFilter_1.prefixCls + "-dynamic-checkbox",
      title: natureTitle[unit],
      checked: nature,
      onChange: onNatureChange
    }, void 0)]
  }), void 0);
};

DynamicSelect.displayName = 'DynamicSelect';
exports["default"] = DynamicSelect;
var DynamicSelectMemo = React.memo(DynamicSelect);
exports.DynamicSelectMemo = DynamicSelectMemo;
DynamicSelectMemo.displayName = 'DynamicSelectMemo';

