"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // 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.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var single_player_exports = {};
__export(single_player_exports, {
  createSinglePlayer: () => createSinglePlayer
});
module.exports = __toCommonJS(single_player_exports);
var import_react = __toESM(require("react"));
var import_player = require("./player.js");
var import_props = require("./props.js");
var import_utils = require("./utils.js");
const SUPPORTED_PROPS = Object.keys(import_props.propTypes);
function createSinglePlayer(activePlayer) {
  var _a;
  return _a = class extends import_react.Component {
    constructor() {
      super(...arguments);
      this.config = (0, import_utils.getConfig)(this.props, import_props.defaultProps, true);
      this.getDuration = () => {
        if (!this.player) {
          return null;
        }
        return this.player.getDuration();
      };
      this.getCurrentTime = () => {
        if (!this.player) {
          return null;
        }
        return this.player.getCurrentTime();
      };
      this.getSecondsLoaded = () => {
        if (!this.player) {
          return null;
        }
        return this.player.getSecondsLoaded();
      };
      this.getInternalPlayer = (key = "player") => {
        if (!this.player) {
          return null;
        }
        return this.player.getInternalPlayer(key);
      };
      this.seekTo = (fraction, type) => {
        if (!this.player) {
          return null;
        }
        this.player.seekTo(fraction, type);
      };
      this.ref = (player) => {
        this.player = player;
      };
    }
    shouldComponentUpdate(nextProps) {
      return !(0, import_utils.isEqual)(this.props, nextProps);
    }
    componentDidUpdate() {
      this.config = (0, import_utils.getConfig)(this.props, import_props.defaultProps);
    }
    render() {
      const { forceVideo, forceAudio, forceHLS, forceDASH } = this.config.file;
      const skipCanPlay = forceVideo || forceAudio || forceHLS || forceDASH;
      if (!activePlayer.canPlay(this.props.url) && !skipCanPlay) {
        return null;
      }
      const { style, width, height, wrapper: Wrapper } = this.props;
      const otherProps = (0, import_utils.omit)(this.props, SUPPORTED_PROPS, import_props.DEPRECATED_CONFIG_PROPS);
      return /* @__PURE__ */ import_react.default.createElement(Wrapper, { style: { ...style, width, height }, ...otherProps }, /* @__PURE__ */ import_react.default.createElement(import_player.Player, { ...this.props, ref: this.ref, activePlayer, config: this.config }));
    }
  }, _a.displayName = `${activePlayer.displayName}Player`, _a.propTypes = import_props.propTypes, _a.defaultProps = import_props.defaultProps, _a.canPlay = activePlayer.canPlay, _a;
}
//# sourceMappingURL=single-player.js.map
