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original file: /npm/yt-player-es@1.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","// Forked from https://github.com/feross/yt-player\n\nimport { EventEmitter } from 'events'\n\nconst YOUTUBE_IFRAME_API_SRC = 'https://www.youtube.com/iframe_api'\n\nconst YOUTUBE_STATES = {\n  '-1': 'unstarted',\n  0: 'ended',\n  1: 'playing',\n  2: 'paused',\n  3: 'buffering',\n  5: 'cued'\n}\n\n/**\n * @author Feross Aboukhadijeh https://github.com/feross https://feross.org/opensource\n * @licence MIT\n * @param src\n * @param attrs\n * @param parentNode\n * @returns {Promise}\n */\nfunction loadScript2 (src, attrs, parentNode) {\n  return new Promise((resolve, reject) => {\n    const script = document.createElement('script')\n    script.async = true\n    script.src = src\n\n    for (const [k, v] of Object.entries(attrs || {})) {\n      script.setAttribute(k, v)\n    }\n\n    script.onload = () => {\n      script.onerror = script.onload = null\n      resolve(script)\n    }\n\n    script.onerror = () => {\n      script.onerror = script.onload = null\n      reject(new Error(`Failed to load ${src}`))\n    }\n\n    const node = parentNode || document.head || document.getElementsByTagName('head')[0]\n    node.appendChild(script)\n  })\n}\n\nconst YOUTUBE_ERROR = {\n  // The request contains an invalid parameter value. For example, this error\n  // occurs if you specify a videoId that does not have 11 characters, or if the\n  // videoId contains invalid characters, such as exclamation points or asterisks.\n  INVALID_PARAM: 2,\n\n  // The requested content cannot be played in an HTML5 player or another error\n  // related to the HTML5 player has occurred.\n  HTML5_ERROR: 5,\n\n  // The video requested was not found. This error occurs when a video has been\n  // removed (for any reason) or has been marked as private.\n  NOT_FOUND: 100,\n\n  // The owner of the requested video does not allow it to be played in embedded\n  // players.\n  UNPLAYABLE_1: 101,\n\n  // This error is the same as 101. It's just a 101 error in disguise!\n  UNPLAYABLE_2: 150\n}\n\nconst loadIframeAPICallbacks = []\n\n/**\n * YouTube Player. Exposes a better API, with nicer events.\n * @param {HTMLElement|selector} element\n * @author Feross Aboukhadijeh https://github.com/feross https://feross.org/opensource\n * @licence MIT\n */\nexport class YouTubePlayer extends EventEmitter {\n  constructor (element, opts) {\n    super()\n\n    const elem = typeof element === 'string'\n      ? document.querySelector(element)\n      : element\n\n    if (elem.id) {\n      this._id = elem.id // use existing element id\n    } else {\n      this._id = elem.id = 'ytplayer-' + Math.random().toString(16).slice(2, 8)\n    }\n\n    this._opts = Object.assign({\n      width: 640,\n      height: 360,\n      autoplay: false,\n      captions: undefined,\n      controls: true,\n      keyboard: true,\n      fullscreen: true,\n      annotations: true,\n      modestBranding: false,\n      related: true,\n      timeupdateFrequency: 1000,\n      playsInline: true\n    }, opts)\n\n    this.videoId = null\n    this.destroyed = false\n\n    this._api = null\n    this._autoplay = false // autoplay the first video?\n    this._player = null\n    this._ready = false // is player ready?\n    this._queue = []\n\n    this._interval = null\n\n    // Setup listeners for 'timeupdate' events. The YouTube Player does not fire\n    // 'timeupdate' events, so they are simulated using a setInterval().\n    this._startInterval = this._startInterval.bind(this)\n    this._stopInterval = this._stopInterval.bind(this)\n\n    this.on('playing', this._startInterval)\n    this.on('unstarted', this._stopInterval)\n    this.on('ended', this._stopInterval)\n    this.on('paused', this._stopInterval)\n    this.on('buffering', this._stopInterval)\n\n    this._loadIframeAPI((err, api) => {\n      if (err) return this._destroy(new Error('YouTube Iframe API failed to load'))\n      this._api = api\n\n      // If load(videoId, [autoplay]) was called before Iframe API loaded, ensure it gets\n      // called again now\n      if (this.videoId) this.load(this.videoId, this._autoplay)\n    })\n  }\n\n  load (videoId, autoplay = false) {\n    if (this.destroyed) return\n\n    this.videoId = videoId\n    this._autoplay = autoplay\n\n    // If the Iframe API is not ready yet, do nothing. Once the Iframe API is\n    // ready, `load(this.videoId)` will be called.\n    if (!this._api) return\n\n    // If there is no player instance, create one.\n    if (!this._player) {\n      this._createPlayer(videoId)\n      return\n    }\n\n    // If the player instance is not ready yet, do nothing. Once the player\n    // instance is ready, `load(this.videoId)` will be called. This ensures that\n    // the last call to `load()` is the one that takes effect.\n    if (!this._ready) return\n\n    // If the player instance is ready, load the given `videoId`.\n    if (autoplay) {\n      this._player.loadVideoById(videoId)\n    } else {\n      this._player.cueVideoById(videoId)\n    }\n  }\n\n  play () {\n    if (this._ready) this._player.playVideo()\n    else this._queueCommand('play')\n  }\n\n  pause () {\n    if (this._ready) this._player.pauseVideo()\n    else this._queueCommand('pause')\n  }\n\n  stop () {\n    if (this._ready) this._player.stopVideo()\n    else this._queueCommand('stop')\n  }\n\n  seek (seconds) {\n    if (this._ready) this._player.seekTo(seconds, true)\n    else this._queueCommand('seek', seconds)\n  }\n\n  setVolume (volume) {\n    if (this._ready) this._player.setVolume(volume)\n    else this._queueCommand('setVolume', volume)\n  }\n\n  getVolume () {\n    return (this._ready && this._player.getVolume()) || 0\n  }\n\n  mute () {\n    if (this._ready) this._player.mute()\n    else this._queueCommand('mute')\n  }\n\n  unMute () {\n    if (this._ready) this._player.unMute()\n    else this._queueCommand('unMute')\n  }\n\n  isMuted () {\n    return (this._ready && this._player.isMuted()) || false\n  }\n\n  setSize (width, height) {\n    if (this._ready) this._player.setSize(width, height)\n    else this._queueCommand('setSize', width, height)\n  }\n\n  setPlaybackRate (rate) {\n    if (this._ready) this._player.setPlaybackRate(rate)\n    else this._queueCommand('setPlaybackRate', rate)\n  }\n\n  setPlaybackQuality (suggestedQuality) {\n    if (this._ready) this._player.setPlaybackQuality(suggestedQuality)\n    else this._queueCommand('setPlaybackQuality', suggestedQuality)\n  }\n\n  getPlaybackRate () {\n    return (this._ready && this._player.getPlaybackRate()) || 1\n  }\n\n  getAvailablePlaybackRates () {\n    return (this._ready && this._player.getAvailablePlaybackRates()) || [1]\n  }\n\n  getDuration () {\n    return (this._ready && this._player.getDuration()) || 0\n  }\n\n  getProgress () {\n    return (this._ready && this._player.getVideoLoadedFraction()) || 0\n  }\n\n  getState () {\n    return (this._ready && YOUTUBE_STATES[this._player.getPlayerState()]) || 'unstarted'\n  }\n\n  getCurrentTime () {\n    return (this._ready && this._player.getCurrentTime()) || 0\n  }\n\n  destroy () {\n    this._destroy()\n  }\n\n  _destroy (err) {\n    if (this.destroyed) return\n    this.destroyed = true\n\n    if (this._player) {\n      this._player.stopVideo && this._player.stopVideo()\n      this._player.destroy()\n    }\n\n    this.videoId = null\n\n    this._id = null\n    this._opts = null\n    this._api = null\n    this._player = null\n    this._ready = false\n    this._queue = null\n\n    this._stopInterval()\n\n    this.removeListener('playing', this._startInterval)\n    this.removeListener('paused', this._stopInterval)\n    this.removeListener('buffering', this._stopInterval)\n    this.removeListener('unstarted', this._stopInterval)\n    this.removeListener('ended', this._stopInterval)\n\n    if (err) this.emit('error', err)\n  }\n\n  _queueCommand (command, ...args) {\n    if (this.destroyed) return\n    this._queue.push([command, args])\n  }\n\n  _flushQueue () {\n    while (this._queue.length) {\n      const command = this._queue.shift()\n      this[command[0]].apply(this, command[1])\n    }\n  }\n\n  _loadIframeAPI (cb) {\n    // If API is loaded, there is nothing else to do\n    if (window.YT && typeof window.YT.Player === 'function') {\n      return cb(null, window.YT)\n    }\n\n    // Otherwise, queue callback until API is loaded\n    loadIframeAPICallbacks.push(cb)\n\n    const scripts = Array.from(document.getElementsByTagName('script'))\n    const isLoading = scripts.some(script => script.src === YOUTUBE_IFRAME_API_SRC)\n\n    // If API <script> tag is not present in the page, inject it. Ensures that\n    // if user includes a hardcoded <script> tag in HTML for performance, another\n    // one will not be added\n    if (!isLoading) {\n      loadScript2(YOUTUBE_IFRAME_API_SRC).catch(err => {\n        while (loadIframeAPICallbacks.length) {\n          const loadCb = loadIframeAPICallbacks.shift()\n          loadCb(err)\n        }\n      })\n    }\n\n    // If ready function is not present, create it\n    if (typeof window.onYouTubeIframeAPIReady !== 'function') {\n      window.onYouTubeIframeAPIReady = () => {\n        while (loadIframeAPICallbacks.length) {\n          const loadCb = loadIframeAPICallbacks.shift()\n          loadCb(null, window.YT)\n        }\n      }\n    }\n  }\n\n  _createPlayer (videoId) {\n    if (this.destroyed) return\n\n    const opts = this._opts\n\n    this._player = new this._api.Player(this._id, {\n      width: opts.width,\n      height: opts.height,\n      videoId: videoId,\n      playerVars: {\n        // This parameter specifies whether the initial video will automatically\n        // start to play when the player loads. Supported values are 0 or 1. The\n        // default value is 0.\n        autoplay: opts.autoplay ? 1 : 0,\n\n        // Setting the parameter's value to 1 causes closed captions to be shown\n        // by default, even if the user has turned captions off. The default\n        // behavior is based on user preference.\n        cc_load_policy: opts.captions != null\n          ? opts.captions !== false ? 1 : 0\n          : undefined, // default to not setting this option\n\n        // Sets the player's interface language. The parameter value is an ISO\n        // 639-1 two-letter language code or a fully specified locale. For\n        // example, fr and fr-ca are both valid values. Other language input\n        // codes, such as IETF language tags (BCP 47) might also be handled\n        // properly.\n        hl: (opts.captions != null && opts.captions !== false)\n          ? opts.captions\n          : undefined, // default to not setting this option\n\n        // This parameter specifies the default language that the player will\n        // use to display captions. Set the parameter's value to an ISO 639-1\n        // two-letter language code.\n        cc_lang_pref: (opts.captions != null && opts.captions !== false)\n          ? opts.captions\n          : undefined, // default to not setting this option\n\n        // This parameter indicates whether the video player controls are\n        // displayed. For IFrame embeds that load a Flash player, it also defines\n        // when the controls display in the player as well as when the player\n        // will load. Supported values are:\n        //   - controls=0 – Player controls do not display in the player. For\n        //                  IFrame embeds, the Flash player loads immediately.\n        //   - controls=1 – (default) Player controls display in the player. For\n        //                  IFrame embeds, the controls display immediately and\n        //                  the Flash player also loads immediately.\n        //   - controls=2 – Player controls display in the player. For IFrame\n        //                  embeds, the controls display and the Flash player\n        //                  loads after the user initiates the video playback.\n        controls: opts.controls ? 2 : 0,\n\n        // Setting the parameter's value to 1 causes the player to not respond to\n        // keyboard controls. The default value is 0, which means that keyboard\n        // controls are enabled.\n        disablekb: opts.keyboard ? 0 : 1,\n\n        // Setting the parameter's value to 1 enables the player to be\n        // controlled via IFrame or JavaScript Player API calls. The default\n        // value is 0, which means that the player cannot be controlled using\n        // those APIs.\n        enablejsapi: 1,\n\n        // Setting this parameter to 0 prevents the fullscreen button from\n        // displaying in the player. The default value is 1, which causes the\n        // fullscreen button to display.\n        fs: opts.fullscreen ? 1 : 0,\n\n        // Setting the parameter's value to 1 causes video annotations to be\n        // shown by default, whereas setting to 3 causes video annotations to not\n        // be shown by default. The default value is 1.\n        iv_load_policy: opts.annotations ? 1 : 3,\n\n        // This parameter lets you use a YouTube player that does not show a\n        // YouTube logo. Set the parameter value to 1 to prevent the YouTube logo\n        // from displaying in the control bar. Note that a small YouTube text\n        // label will still display in the upper-right corner of a paused video\n        // when the user's mouse pointer hovers over the player.\n        modestbranding: opts.modestBranding ? 1 : 0,\n\n        // This parameter provides an extra security measure for the IFrame API\n        // and is only supported for IFrame embeds. If you are using the IFrame\n        // API, which means you are setting the enablejsapi parameter value to 1,\n        // you should always specify your domain as the origin parameter value.\n        origin: window.location.origin,\n\n        // This parameter controls whether videos play inline or fullscreen in an\n        // HTML5 player on iOS. Valid values are:\n        //   - 0: This value causes fullscreen playback. This is currently the\n        //        default value, though the default is subject to change.\n        //   - 1: This value causes inline playback for UIWebViews created with\n        //        the allowsInlineMediaPlayback property set to TRUE.\n        playsinline: opts.playsInline ? 1 : 0,\n\n        // This parameter indicates whether the player should show related\n        // videos from the same channel (0) or from any channel (1) when\n        // playback of the video ends. The default value is 1.\n        rel: opts.related ? 1 : 0,\n\n        // (Not part of documented API) Allow html elements with higher z-index\n        // to be shown on top of the YouTube player.\n        wmode: 'opaque'\n      },\n      events: {\n        onReady: () => this._onReady(videoId),\n        onStateChange: (data) => this._onStateChange(data),\n        onPlaybackQualityChange: (data) => this._onPlaybackQualityChange(data),\n        onPlaybackRateChange: (data) => this._onPlaybackRateChange(data),\n        onError: (data) => this._onError(data)\n      }\n    })\n  }\n\n  /**\n   * This event fires when the player has finished loading and is ready to begin\n   * receiving API calls.\n   */\n  _onReady (videoId) {\n    if (this.destroyed) return\n\n    this._ready = true\n\n    // Once the player is ready, always call `load(videoId, [autoplay])` to handle\n    // these possible cases:\n    //\n    //   1. `load(videoId, true)` was called before the player was ready. Ensure that\n    //      the selected video starts to play.\n    //\n    //   2. `load(videoId, false)` was called before the player was ready. Now the\n    //      player is ready and there's nothing to do.\n    //\n    //   3. `load(videoId, [autoplay])` was called multiple times before the player\n    //      was ready. Therefore, the player was initialized with the wrong videoId,\n    //      so load the latest videoId and potentially autoplay it.\n    this.load(this.videoId, this._autoplay)\n\n    this._flushQueue()\n  }\n\n  /**\n   * Called when the player's state changes. We emit friendly events so the user\n   * doesn't need to use YouTube's YT.PlayerState.* event constants.\n   */\n  _onStateChange (data) {\n    if (this.destroyed) return\n\n    const state = YOUTUBE_STATES[data.data]\n\n    if (state) {\n      // Send a 'timeupdate' anytime the state changes. When the video halts for any\n      // reason ('paused', 'buffering', or 'ended') no further 'timeupdate' events\n      // should fire until the video unhalts.\n      if (['paused', 'buffering', 'ended'].includes(state)) this._onTimeupdate()\n\n      this.emit(state)\n\n      // When the video changes ('unstarted' or 'cued') or starts ('playing') then a\n      // 'timeupdate' should follow afterwards (never before!) to reset the time.\n      if (['unstarted', 'playing', 'cued'].includes(state)) this._onTimeupdate()\n    } else {\n      throw new Error('Unrecognized state change: ' + data)\n    }\n  }\n\n  /**\n   * This event fires whenever the video playback quality changes. Possible\n   * values are: 'small', 'medium', 'large', 'hd720', 'hd1080', 'highres'.\n   */\n  _onPlaybackQualityChange (data) {\n    if (this.destroyed) return\n    this.emit('playbackQualityChange', data.data)\n  }\n\n  /**\n   * This event fires whenever the video playback rate changes.\n   */\n  _onPlaybackRateChange (data) {\n    if (this.destroyed) return\n    this.emit('playbackRateChange', data.data)\n  }\n\n  /**\n   * This event fires if an error occurs in the player.\n   */\n  _onError (data) {\n    if (this.destroyed) return\n\n    const code = data.data\n\n    // The HTML5_ERROR error occurs when the YouTube player needs to switch from\n    // HTML5 to Flash to show an ad. Ignore it.\n    if (code === YOUTUBE_ERROR.HTML5_ERROR) return\n\n    // The remaining error types occur when the YouTube player cannot play the\n    // given video. This is not a fatal error. Report it as unplayable so the user\n    // has an opportunity to play another video.\n    if (code === YOUTUBE_ERROR.UNPLAYABLE_1 ||\n        code === YOUTUBE_ERROR.UNPLAYABLE_2 ||\n        code === YOUTUBE_ERROR.NOT_FOUND ||\n        code === YOUTUBE_ERROR.INVALID_PARAM) {\n      return this.emit('unplayable', this.videoId)\n    }\n\n    // Unexpected error, does not match any known type\n    this._destroy(new Error('YouTube Player Error. Unknown error code: ' + code))\n  }\n\n  /**\n   * This event fires when the time indicated by the `getCurrentTime()` method\n   * has been updated.\n   */\n  _onTimeupdate () {\n    this.emit('timeupdate', this.getCurrentTime())\n  }\n\n  _startInterval () {\n    this._interval = setInterval(() => this._onTimeupdate(), this._opts.timeupdateFrequency)\n  }\n\n  _stopInterval () {\n    clearInterval(this._interval)\n    this._interval = null\n  }\n}\n"]}