/*!
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
*/
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("./resizeObserver.js"),i=require("../utils/util.js");var o={pluginGroup:{},init:function(i){var o=i._pluginInfoId;o||(o=(new Date).getTime(),i._pluginInfoId=o),!i.config.closeResizeObserver&&n.addObserver(i.root,function(){i.resize()}),this.pluginGroup[o]={_originalOptions:i.config||{},_plugins:{}}},formatPluginInfo:function(n,i){var o=null,e=null;return n.plugin&&"function"==typeof n.plugin?(o=n.plugin,e=n.options):(o=n,e={}),i&&(e.config=i||{}),{PLUFGIN:o,options:e}},checkPluginIfExits:function(n,i){for(var o=0;o<i.length;o++)if(n.toLowerCase()===i[o].pluginName.toLowerCase())return!0;return!1},getRootByConfig:function(n,o){for(var e=Object.keys(o),t=null,r=0;r<e.length;r++)if(n.toLowerCase()===e[r].toLowerCase()){t=o[e[r]];break}return"Object"===i.default.typeOf(t)?{root:t.root,position:t.position}:{}},lazyRegister:function(n,i){var o=this,e=i.timeout||1500;return Promise.race([i.loader().then(function(i){var e;e=i&&i.__esModule?i.default:i,o.register(n,e,i.options)}),new Promise(function(n,i){setTimeout(function(){i(new Error("timeout"))},e)})])},register:function(n,o){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(n&&o&&"function"==typeof o&&void 0!==o.prototype){var t=n._pluginInfoId;if(t&&this.pluginGroup[t]){this.pluginGroup[t]._plugins||(this.pluginGroup[t]._plugins={});var r=this.pluginGroup[t]._plugins,u=this.pluginGroup[t]._originalOptions;e.player=n;var s=e.pluginName||o.pluginName;if(!s)throw new Error("The property pluginName is necessary");if(!o.isSupported||o.isSupported(n.config.mediaType,n.config.codecType)){e.config||(e.config={});for(var l=Object.keys(u),p=0;p<l.length;p++)if(s.toLowerCase()===l[p].toLowerCase()){var g=u[l[p]];"Object"===i.default.typeOf(g)?e.config=Object.assign({},e.config,u[l[p]]):"Boolean"===i.default.typeOf(g)&&(e.config.disable=!g);break}o.defaultConfig&&Object.keys(o.defaultConfig).forEach(function(n){void 0===e.config[n]&&(e.config[n]=o.defaultConfig[n])}),e.root?"string"==typeof e.root&&(e.root=n[e.root]):e.root=n.root,e.index=e.config.index||0;try{r[s.toLowerCase()]&&(this.unRegister(t,s.toLowerCase()),console.warn("the is one plugin with same pluginName [".concat(s,"] exist, destroy the old instance")));var a=new o(e);return r[s.toLowerCase()]=a,r[s.toLowerCase()].func=o,a&&"function"==typeof a.afterCreate&&a.afterCreate(),a}catch(f){throw console.error(f),f}}else console.warn("not supported plugin [".concat(s,"]"))}}},unRegister:function(n,i){n._pluginInfoId&&(n=n._pluginInfoId),i=i.toLowerCase();try{var o=this.pluginGroup[n]._plugins[i];o&&(o.pluginName&&o.__destroy(),delete this.pluginGroup[n]._plugins[i])}catch(e){console.error("[unRegister:".concat(i,"] cgid:[").concat(n,"] error"),e)}},deletePlugin:function(n,i){var o=n._pluginInfoId;o&&this.pluginGroup[o]&&this.pluginGroup[o]._plugins&&delete this.pluginGroup[o]._plugins[i]},getPlugins:function(n){var i=n._pluginInfoId;return i&&this.pluginGroup[i]?this.pluginGroup[i]._plugins:{}},findPlugin:function(n,i){var o=n._pluginInfoId;if(!o||!this.pluginGroup[o])return null;var e=i.toLowerCase();return this.pluginGroup[o]._plugins[e]},beforeInit:function(n){var i=this;function o(n){return n&&n.then?n:new Promise(function(n){n()})}return new Promise(function(e){if(i.pluginGroup)return(n._loadingPlugins&&n._loadingPlugins.length?Promise.all(n._loadingPlugins):Promise.resolve()).then(function(){var t=n._pluginInfoId;if(i.pluginGroup[t]){var r=i.pluginGroup[t]._plugins,u=[];Object.keys(r).forEach(function(n){if(r[n]&&r[n].beforePlayerInit)try{var i=r[n].beforePlayerInit();u.push(o(i))}catch(e){throw u.push(o(null)),e}}),Promise.all([].concat(u)).then(function(){e()}).catch(function(n){console.error(n),e()})}else e()})})},afterInit:function(n){var i=n._pluginInfoId;if(i&&this.pluginGroup[i]){var o=this.pluginGroup[i]._plugins;Object.keys(o).forEach(function(n){o[n]&&o[n].afterPlayerInit&&o[n].afterPlayerInit()})}},setLang:function(n,i){var o=i._pluginInfoId;if(o&&this.pluginGroup[o]){var e=this.pluginGroup[o]._plugins;Object.keys(e).forEach(function(i){if(e[i].updateLang)e[i].updateLang(n);else try{e[i].lang=n}catch(o){console.warn("".concat(i," setLang"))}})}},reRender:function(n){var i=this,o=n._pluginInfoId;if(o&&this.pluginGroup[o]){var e=[],t=this.pluginGroup[o]._plugins;Object.keys(t).forEach(function(n){"controls"!==n&&t[n]&&(e.push({plugin:t[n].func,options:t[n].__args}),i.unRegister(o,n))}),e.forEach(function(o){i.register(n,o.plugin,o.options)})}},onPluginsReady:function(n){var i=n._pluginInfoId;if(i&&this.pluginGroup[i]){var o=this.pluginGroup[i]._plugins||{};Object.keys(o).forEach(function(n){o[n].onPluginsReady&&"function"==typeof o[n].onPluginsReady&&o[n].onPluginsReady()})}},destroy:function(i){var o=i._pluginInfoId;if(this.pluginGroup[o]){n.unObserver(i.root);for(var e=this.pluginGroup[o]._plugins,t=0,r=Object.keys(e);t<r.length;t++){var u=r[t];this.unRegister(o,u)}delete this.pluginGroup[o],delete i._pluginInfoId}}};exports.default=o;