"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DefaultHandle = DefaultHandle;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _context = require("./context");
var _useTranslation = require("../hooks/use-translation");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
const VERTICAL = 'vertical';
function DefaultHandle({
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  css,
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  styles,
  orientation,
  disabled,
  handleRef,
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
  theme,
  ...props
}) {
  const {
    t
  } = (0, _useTranslation.useTranslation)();
  const {
    testId,
    handleAriaLabel,
    handleAriaValueText,
    ariaLabelledBy
  } = (0, _react.useContext)(_context.AriaContext);
  const ariaContext = {
    key: props['data-handle-key'],
    value: props['aria-valuenow'],
    max: props['aria-valuemax'],
    min: props['aria-valuemin'],
    disabled
  };
  const ariaLabel = typeof handleAriaLabel === 'function' ? handleAriaLabel(ariaContext) : undefined;
  const valueText = typeof handleAriaValueText === 'function' ? handleAriaValueText(ariaContext) : undefined;
  const ariaAttrs = {
    ...(ariaLabel && {
      'aria-label': ariaLabel
    }),
    ...(!ariaLabel && ariaLabelledBy && {
      'aria-labelledby': ariaLabelledBy
    }),
    ...(!ariaLabel && !ariaLabelledBy && {
      'aria-label': t('Slider handle')
    })
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    ...props,
    ...ariaAttrs,
    ref: handleRef,
    "aria-valuetext": valueText,
    "test-id": testId ? `${testId}-handle-${ariaContext.key}` : undefined,
    className: (0, _classnames.default)('DefaultHandle_handle', orientation === VERTICAL ? 'DefaultHandle_handle__vertical' : 'DefaultHandle_handle__horizontal', disabled && 'DefaultHandle_handle__disabled')
  });
}