import D from "react";
import { __require as j } from "../utils.js";
import { __require as L } from "../patterns.js";
var l, _;
function E() {
  if (_) return l;
  _ = 1;
  var y = Object.create, a = Object.defineProperty, m = Object.getOwnPropertyDescriptor, f = Object.getOwnPropertyNames, v = Object.getPrototypeOf, P = Object.prototype.hasOwnProperty, g = (r, e, t) => e in r ? a(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, O = (r, e) => {
    for (var t in e)
      a(r, t, { get: e[t], enumerable: !0 });
  }, p = (r, e, t, s) => {
    if (e && typeof e == "object" || typeof e == "function")
      for (let i of f(e))
        !P.call(r, i) && i !== t && a(r, i, { get: () => e[i], enumerable: !(s = m(e, i)) || s.enumerable });
    return r;
  }, M = (r, e, t) => (t = r != null ? y(v(r)) : {}, p(
    // If the importer is in node compatibility mode or this is not an ESM
    // file that has been converted to a CommonJS file using a Babel-
    // compatible transform (i.e. "__esModule" has not been set), then set
    // "default" to the CommonJS "module.exports" for node compatibility.
    !r || !r.__esModule ? a(t, "default", { value: r, enumerable: !0 }) : t,
    r
  )), w = (r) => p(a({}, "__esModule", { value: !0 }), r), o = (r, e, t) => (g(r, typeof e != "symbol" ? e + "" : e, t), t), c = {};
  O(c, {
    default: () => n
  }), l = w(c);
  var d = M(D), u = /* @__PURE__ */ j(), h = /* @__PURE__ */ L();
  const b = "https://widget.mixcloud.com/media/js/widgetApi.js", x = "Mixcloud";
  class n extends d.Component {
    constructor() {
      super(...arguments), o(this, "callPlayer", u.callPlayer), o(this, "duration", null), o(this, "currentTime", null), o(this, "secondsLoaded", null), o(this, "mute", () => {
      }), o(this, "unmute", () => {
      }), o(this, "ref", (e) => {
        this.iframe = e;
      });
    }
    componentDidMount() {
      this.props.onMount && this.props.onMount(this);
    }
    load(e) {
      (0, u.getSDK)(b, x).then((t) => {
        this.player = t.PlayerWidget(this.iframe), this.player.ready.then(() => {
          this.player.events.play.on(this.props.onPlay), this.player.events.pause.on(this.props.onPause), this.player.events.ended.on(this.props.onEnded), this.player.events.error.on(this.props.error), this.player.events.progress.on((s, i) => {
            this.currentTime = s, this.duration = i;
          }), this.props.onReady();
        });
      }, this.props.onError);
    }
    play() {
      this.callPlayer("play");
    }
    pause() {
      this.callPlayer("pause");
    }
    stop() {
    }
    seekTo(e, t = !0) {
      this.callPlayer("seek", e), t || this.pause();
    }
    setVolume(e) {
    }
    getDuration() {
      return this.duration;
    }
    getCurrentTime() {
      return this.currentTime;
    }
    getSecondsLoaded() {
      return null;
    }
    render() {
      const { url: e, config: t } = this.props, s = e.match(h.MATCH_URL_MIXCLOUD)[1], i = {
        width: "100%",
        height: "100%"
      }, q = (0, u.queryString)({
        ...t.options,
        feed: `/${s}/`
      });
      return /* @__PURE__ */ d.default.createElement(
        "iframe",
        {
          key: s,
          ref: this.ref,
          style: i,
          src: `https://www.mixcloud.com/widget/iframe/?${q}`,
          frameBorder: "0",
          allow: "autoplay"
        }
      );
    }
  }
  return o(n, "displayName", "Mixcloud"), o(n, "canPlay", h.canPlay.mixcloud), o(n, "loopOnEnded", !0), l;
}
export {
  E as __require
};
//# sourceMappingURL=Mixcloud.js.map
