function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
import React, { useEffect, useState } from 'react';
import "./VenueWallMarquee.less";
function usePrefersReducedMotion() {
  var _useState = useState(false),
    _useState2 = _slicedToArray(_useState, 2),
    reduced = _useState2[0],
    setReduced = _useState2[1];
  useEffect(function () {
    if (typeof window === 'undefined' || !window.matchMedia) return;
    var mq = window.matchMedia('(prefers-reduced-motion: reduce)');
    setReduced(mq.matches);
    var onChange = function onChange() {
      return setReduced(mq.matches);
    };
    mq.addEventListener('change', onChange);
    return function () {
      return mq.removeEventListener('change', onChange);
    };
  }, []);
  return reduced;
}
var MARQUEE_COPY_COUNT = 3;
/**
 * 底部说明条：短文案省略静态展示，长文案无缝跑马灯（多段 copy 与 `VenueWallMarquee.less` 中 -33.333% 动画配套）。
 * 系统「减少动态效果」时强制静态展示；跑马灯区对读屏 `aria-hidden` 避免重复朗读。
 */
export var NoteTicker = /*#__PURE__*/React.memo(function NoteTicker(_ref) {
  var text = _ref.text,
    color = _ref.color,
    _ref$duration = _ref.duration,
    duration = _ref$duration === void 0 ? 24 : _ref$duration,
    shouldMarquee = _ref.shouldMarquee;
  var reducedMotion = usePrefersReducedMotion();
  var useMarquee = shouldMarquee && !reducedMotion;
  if (!useMarquee) {
    return /*#__PURE__*/React.createElement("div", {
      className: "pisell-resource-wall-note-marquee-static",
      style: {
        color: color
      },
      title: text
    }, text);
  }
  return /*#__PURE__*/React.createElement("div", {
    className: "pisell-resource-wall-note-marquee-wrap",
    "aria-hidden": true
  }, /*#__PURE__*/React.createElement("div", {
    className: "pisell-resource-wall-note-marquee-track",
    style: {
      animationDuration: "".concat(duration, "s"),
      color: color
    }
  }, Array.from({
    length: MARQUEE_COPY_COUNT
  }, function (_, i) {
    return /*#__PURE__*/React.createElement("div", {
      key: i,
      className: "pisell-resource-wall-note-marquee-copy"
    }, text);
  })));
});