"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;

exports.__esModule = true;
exports.Sound = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _react = _interopRequireDefault(require("react"));

var _core = require("../core");

var _EventListener = _interopRequireDefault(require("../event/EventListener"));

function toSoundProps(_ref) {
  var autoplay = _ref.autoplay,
      loop = _ref.loop,
      on = _ref.on,
      src = _ref.src,
      volume = _ref.volume;
  return {
    autoplay: autoplay,
    loop: loop,
    on: on,
    src: src,
    volume: volume
  };
}
/**
 * The sound primitive wraps the [sound component](https://aframe.io/docs/1.3.0/components/sound.html).
 *
 * @see https://aframe.io/docs/1.3.0/primitives/a-sound.html
 *
 * @example
 * ```tsx
 * <Scene>
 *   <Sound
 *     src="src: url(click.mp3)"
 *     autoplay={true}
 *     position={{ x: 0, y: 2, z: 5 }}
 *   />
 * </Scene>
 * ```
 */


var Sound = function Sound(props) {
  var volumeKeys = ['autoplay', 'loop', 'on', 'src', 'volume'];
  var children = props.children;
  return /*#__PURE__*/_react.default.createElement(_EventListener.default, (0, _extends2.default)({
    primitive: "a-sound"
  }, (0, _core.toProps)(props, volumeKeys), toSoundProps(props)), children);
};

exports.Sound = Sound;