/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/

(function initCjs() {
  // eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
  const globalThisRecord = globalThis;
  globalThisRecord['__name'] ??= name;
  const originalRequire = require;
  if (originalRequire && !originalRequire.__isPatched) {
    // eslint-disable-next-line no-global-assign, no-implicit-globals -- We need to patch the `require()` function.
    require = Object.assign(
      (id) => requirePatched(id),
      originalRequire,
      {
        __isPatched: true
      }
    );
  }

  const newFuncs = {
    __extractDefault() {
      return extractDefault;
    },
    process() {
      const browserProcess = {
        browser: true,
        cwd() {
          return '/';
        },
        env: {},
        platform: 'android'
      };
      return browserProcess;
    }
  };

  for (const key of Object.keys(newFuncs)) {
    globalThisRecord[key] ??= newFuncs[key]?.();
  }

  function name(obj) {
    return obj;
  }

  function extractDefault(module) {
    return module && module.__esModule && 'default' in module ? module.default : module;
  }

  const OBSIDIAN_BUILT_IN_MODULE_NAMES = [
  'obsidian',
  '@codemirror/autocomplete',
  '@codemirror/collab',
  '@codemirror/commands',
  '@codemirror/language',
  '@codemirror/lint',
  '@codemirror/search',
  '@codemirror/state',
  '@codemirror/text',
  '@codemirror/view',
  '@lezer/common',
  '@lezer/lr',
  '@lezer/highlight'];


  const DEPRECATED_OBSIDIAN_BUILT_IN_MODULE_NAMES = [
  '@codemirror/closebrackets',
  '@codemirror/comment',
  '@codemirror/fold',
  '@codemirror/gutter',
  '@codemirror/highlight',
  '@codemirror/history',
  '@codemirror/matchbrackets',
  '@codemirror/panel',
  '@codemirror/rangeset',
  '@codemirror/rectangular-selection',
  '@codemirror/stream-parser',
  '@codemirror/tooltip'];


  function requirePatched(id) {
    if (OBSIDIAN_BUILT_IN_MODULE_NAMES.includes(id) || DEPRECATED_OBSIDIAN_BUILT_IN_MODULE_NAMES.includes(id)) {
      return originalRequire?.(id);
    }

    // eslint-disable-next-line @typescript-eslint/no-deprecated, obsidianmd/no-global-this  -- Need access to app. Actively use globalThis.
    if (globalThis.app.isMobile) {
      if (id === 'process' || id === 'node:process') {
        // eslint-disable-next-line no-console -- Valid usage.
        console.debug(`The most likely you can safely ignore this error. Module not found: ${id}. Fake process object is returned instead.`);
        // eslint-disable-next-line obsidianmd/no-global-this -- Actively use globalThis.
        return globalThis.process;
      }
    } else {
      const module = originalRequire?.(id);
      if (module) {
        return extractDefault(module);
      }
    }

    // eslint-disable-next-line no-console -- Valid usage.
    console.debug(`The most likely you can safely ignore this error. Module not found: ${id}. Empty object is returned instead.`);
    return {};
  }
})();

"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var registry_component_exports = {};
__export(registry_component_exports, {
  RegistryComponent: () => RegistryComponent
});
module.exports = __toCommonJS(registry_component_exports);
var import_type_guards = require('../../type-guards.cjs');
var import_component_ex = require('./component-ex.cjs');
class RegistryComponent extends import_component_ex.ComponentEx {
  /**
   * Get the single child of the given type.
   *
   * @typeParam TComponent - The type of component to get.
   * @param componentClass - The class of the component to get.
   * @returns The single registered child of the given type.
   */
  getChild(componentClass) {
    const child = this.getChildOrNull(componentClass);
    if (child) {
      return child;
    }
    throw new Error(`No instance of ${componentClass.name} registered`);
  }
  /**
   * Get the single child of the given type.
   *
   * @typeParam TComponent - The type of component to get.
   * @param componentClass - The class of the component to get.
   * @returns The single registered child of the given type, or `null` if none are registered.
   */
  getChildOrNull(componentClass) {
    const children = this.getChildren(componentClass);
    if (children.length === 0) {
      return null;
    }
    if (children.length === 1) {
      return (0, import_type_guards.ensureNonNullable)(children[0]);
    }
    throw new Error(`Multiple instances of ${componentClass.name} registered`);
  }
  /**
   * Get all children of the given type.
   *
   * @typeParam TComponent - The type of component to get.
   * @param componentClass - The class of the component to get.
   * @returns All registered children of the given type.
   */
  getChildren(componentClass) {
    return this._children.filter((child) => child instanceof componentClass);
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  RegistryComponent
});
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL2NvbXBvbmVudHMvcmVnaXN0cnktY29tcG9uZW50LnRzIl0sCiAgInNvdXJjZXNDb250ZW50IjogWyIvKipcbiAqIEBmaWxlXG4gKlxuICoge0BsaW5rIFJlZ2lzdHJ5Q29tcG9uZW50fS5cbiAqL1xuXG5pbXBvcnQgdHlwZSB7IENvbnN0cnVjdG9yIH0gZnJvbSAndHlwZS1mZXN0JztcblxuaW1wb3J0IHsgZW5zdXJlTm9uTnVsbGFibGUgfSBmcm9tICcuLi8uLi90eXBlLWd1YXJkcy50cyc7XG5pbXBvcnQgeyBDb21wb25lbnRFeCB9IGZyb20gJy4vY29tcG9uZW50LWV4LnRzJztcblxuLyoqXG4gKiBBIGNvbXBvbmVudCB0aGF0IGtlZXBzIHJlZ2lzdHJ5IG9mIGl0cyBjaGlsZHJlbi5cbiAqL1xuZXhwb3J0IGNsYXNzIFJlZ2lzdHJ5Q29tcG9uZW50IGV4dGVuZHMgQ29tcG9uZW50RXgge1xuICAvKipcbiAgICogR2V0IHRoZSBzaW5nbGUgY2hpbGQgb2YgdGhlIGdpdmVuIHR5cGUuXG4gICAqXG4gICAqIEB0eXBlUGFyYW0gVENvbXBvbmVudCAtIFRoZSB0eXBlIG9mIGNvbXBvbmVudCB0byBnZXQuXG4gICAqIEBwYXJ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