/*!
Copyright (c) 2026 Lenovo SSG BASD. All rights reserved.
@license Proprietary

This software is the confidential and proprietary property of Lenovo SSG BASD.
You shall not disclose such Confidential Information and shall use it only in
accordance with the terms of the license agreement.

--- Build Info ---
Version: 1.1.1
Build Time: 2026/2/26 17:21:00
Build Commit: 81e556ed827e2f043668506dae6fae8dbb9ef395
*/
import{inherits as e,createSuper as t,classCallCheck as r,createClass as n}from"./_virtual/_rollupPluginBabelHelpers.js";import{e as i}from"../../../_virtual/index.js";var a={},s=null,u=/* @__PURE__ */function(i){e(l,i);var u=t(l);function l(){return r(this,l),u.apply(this,arguments)}return n(l,[{key:"add",value:function(e){e&&(a[e.playerId]=e,1===Object.keys(a).length&&this.setActive(e.playerId,!0))}},{key:"remove",value:function(e){e&&(e.isUserActive,delete a[e.playerId])}},{key:"_iterate",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];for(var r in a)if(Object.prototype.hasOwnProperty.call(a,r)){var n=a[r];if(t){if(e(n))break}else e(n)}}},{key:"forEach",value:function(e){this._iterate(e)}},{key:"find",value:function(e){var t=null;return this._iterate(function(r){var n=e(r);return n&&(t=r),n},!0),t}},{key:"findAll",value:function(e){var t=[];return this._iterate(function(r){e(r)&&t.push(r)}),t}},{key:"setActive",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(a[e])return t?this.forEach(function(t){e===t.playerId?(t.isUserActive=!0,t.isInstNext=!1):t.isUserActive=!1}):a[e].isUserActive=t,e}},{key:"getActiveId",value:function(){for(var e=Object.keys(a),t=0;t<e.length;t++){var r=a[e[t]];if(r&&r.isUserActive)return e[t]}return null}},{key:"setNext",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(a[e])return t?this.forEach(function(t){e===t.playerId?(t.isUserActive=!1,t.isInstNext=!0):t.isInstNext=!1}):a[e].isInstNext=t,e}}],[{key:"getInstance",value:function(){return s||(s=new l),s}}]),l}(i.EventEmitter);function l(e){for(var t=Object.keys(a),r=0;r<t.length;r++){var n=a[t[r]];if(n.root===e)return n}return null}export{u as InstManager,l as checkPlayerRoot};