/**
 * Centralized custom element registration for Matrix webapps.
 *
 * Usage:
 *   import { registerMatrixElements } from '@open-matrix/browser-kit';
 *   import { MxSplit } from '@open-matrix/core';
 *   import { MyApp } from './MyApp';
 *
 *   registerMatrixElements([
 *     ['my-app', MyApp],
 *     ['mx-split', MxSplit],
 *   ]);
 */
export function registerMatrixElements(
  elements: Array<[string, CustomElementConstructor]>,
): void {
  if (typeof customElements === 'undefined') return;

  for (const [tag, cls] of elements) {
    if (!customElements.get(tag)) {
      customElements.define(tag, cls);
    }
  }
}
