function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
var _excluded = ["style", "className", "dateCellRender", "height"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import { Calendar, Progress } from 'antd';
import locale from 'antd/lib/calendar/locale/zh_CN.js';
import classnames from 'classnames';
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import useSettings from "../../_hooks/useSettings";
import "./style";
dayjs.locale('zh-cn');
import BlockA from "../../_imgs/block_alarm.png";
import BlockN from "../../_imgs/block_normal.png";
import { transformRgb } from "../../_util";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var prefix = 'vm-calendar';
function VmCalendar(props) {
  var _props$style = props.style,
    style = _props$style === void 0 ? {} : _props$style,
    className = props.className,
    dateCellRender = props.dateCellRender,
    _props$height = props.height,
    height = _props$height === void 0 ? 86 : _props$height,
    rest = _objectWithoutProperties(props, _excluded);
  return /*#__PURE__*/_jsx("div", {
    className: classnames("".concat(prefix), className),
    style: _objectSpread(_objectSpread({}, style), {}, {
      '--height': height + 'px'
    }),
    children: /*#__PURE__*/_jsx(Calendar, _objectSpread({
      locale: locale,
      headerRender: function headerRender() {
        return null;
      },
      dateCellRender: dateCellRender,
      cellRender: dateCellRender
    }, rest))
  });
}
export default VmCalendar;
export function VmCalendarPercent(_ref) {
  var percent = _ref.percent,
    color = _ref.color;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var colorMap = {
    blue: '#1677FF',
    red: '#F5222D',
    green: '#0FB964',
    yellow: '#FFAA00',
    gray: '#595959'
  };
  if (isDark) {
    colorMap.blue = '#009DFF';
    colorMap.red = '#FF5861';
    colorMap.gray = '#FFFFFF';
  }
  var _color = colorMap[color];
  return /*#__PURE__*/_jsxs("div", {
    className: 'vm-calendar-percent',
    children: [/*#__PURE__*/_jsx("div", {
      style: {
        width: 40
      },
      children: /*#__PURE__*/_jsx(Progress, {
        percent: percent,
        strokeColor: _color,
        trailColor: transformRgb(_color, 0.1),
        railColor: transformRgb(_color, 0.1),
        showInfo: false,
        strokeWidth: 4,
        size: {
          width: 40,
          height: 4
        }
      })
    }), /*#__PURE__*/_jsxs("div", {
      style: {
        color: color === 'gray' && isDark ? '#ADADAD' : _color
      },
      children: [percent, "%"]
    })]
  });
}
export function VmCalendarInner(props) {
  var _useSettings2 = useSettings(),
    isDark = _useSettings2.isDark;
  var _props$style2 = props.style,
    style = _props$style2 === void 0 ? {} : _props$style2,
    img = props.img,
    _props$imgType = props.imgType,
    imgType = _props$imgType === void 0 ? 'normal' : _props$imgType,
    _props$value = props.value,
    value = _props$value === void 0 ? '' : _props$value,
    _props$type = props.type,
    type = _props$type === void 0 ? 'blue' : _props$type,
    _props$isAlarm = props.isAlarm,
    isAlarm = _props$isAlarm === void 0 ? false : _props$isAlarm,
    onMouseOut = props.onMouseOut,
    onMouseOver = props.onMouseOver,
    _props$content = props.content,
    content = _props$content === void 0 ? '' : _props$content;
  var innerImg = {
    normal: BlockN,
    alarm: BlockA
  };
  return /*#__PURE__*/_jsxs("div", {
    className: "vm-calendar-head-item ".concat(isDark ? 'dark' : '', " ").concat(type),
    style: _objectSpread({}, style),
    onMouseOut: onMouseOut && onMouseOut,
    onMouseOver: onMouseOver && onMouseOver,
    children: [/*#__PURE__*/_jsx("img", {
      src: img || innerImg[imgType]
    }), content ? content : /*#__PURE__*/_jsx("div", {
      style: isAlarm ? {
        color: '#FF5861'
      } : {},
      children: value
    })]
  });
}