import React from "react";
import { getAudioSrc } from "../consts.js";
import { ROOT } from "../data-hooks.js";
import styles from "../statics/styles/audio-scss.js";
import AudioEmbedViewer from "./audio-embed-viewer.js";
import { ReactPlayerWrapper } from "./react-player-wrapper.js";
const AudioViewer = ({
  node,
  settings,
  disabled,
  isLoading,
  updateAttributes
}) => {
  const { audio, authorName, name, coverImage, disableDownload, html } = node.audioData || {};
  const url = getAudioSrc(audio?.src, settings);
  const shouldEmbed = !!html;
  const saveDurationToData = (duration) => updateAttributes?.({ audio: { ...audio, duration } });
  return /* @__PURE__ */ React.createElement("div", { className: styles.container, "data-hook": ROOT }, !shouldEmbed ? /* @__PURE__ */ React.createElement(
    ReactPlayerWrapper,
    {
      url,
      name,
      authorName,
      coverImage: { src: coverImage?.src.id },
      disableDownload,
      helpers: {},
      disabled,
      isLoading,
      saveDurationToData,
      initialDuration: audio?.duration
    }
  ) : /* @__PURE__ */ React.createElement(AudioEmbedViewer, { node, settings }));
};
var audio_viewer_default = AudioViewer;
export {
  audio_viewer_default as default
};
//# sourceMappingURL=audio-viewer.js.map
