/*
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 async_error_handler_component_exports = {};
__export(async_error_handler_component_exports, {
  AsyncErrorHandlerComponent: () => AsyncErrorHandlerComponent
});
module.exports = __toCommonJS(async_error_handler_component_exports);
var import_error = require('../../error.cjs');
var import_i18n = require('../i18n/i18n.cjs');
var import_component_ex = require('./component-ex.cjs');
var import_plugin_notice_component = require('./plugin-notice-component.cjs');
class AsyncErrorHandlerComponent extends import_component_ex.ComponentEx {
  /**
   * Creates a new async error handler component.
   *
   * @param pluginNoticeComponent - The notice component used to display error messages.
   */
  constructor(pluginNoticeComponent) {
    super();
    this.pluginNoticeComponent = pluginNoticeComponent;
  }
  pluginNoticeComponent;
  /**
   * Registers the error handler.
   */
  onload() {
    this.register((0, import_error.registerAsyncErrorEventHandler)(this.handleAsyncError.bind(this)));
  }
  /**
   * Called when an async error occurs.
   *
   * @param _asyncError - The async error.
   */
  handleAsyncError(_asyncError) {
    this.pluginNoticeComponent.showNotice((0, import_i18n.t)(($) => $.obsidianDevUtils.notices.unhandledError));
  }
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  AsyncErrorHandlerComponent
});
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vLi4vLi4vLi4vc3JjL29ic2lkaWFuL2NvbXBvbmVudHMvYXN5bmMtZXJyb3ItaGFuZGxlci1jb21wb25lbnQudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbIi8qKlxuICogQGZpbGVcbiAqXG4gKiBDb21wb25lbnQgdGhhdCBoYW5kbGVzIGFzeW5jIGVycm9ycyBieSBzaG93aW5nIGEgbm90aWNlIHRvIHRoZSB1c2VyLlxuICovXG5cbmltcG9ydCB7IHJlZ2lzdGVyQXN5bmNFcnJvckV2ZW50SGFuZGxlciB9IGZyb20gJy4uLy4uL2Vycm9yLnRzJztcbmltcG9ydCB7IHQgfSBmcm9tICcuLi9pMThuL2kxOG4udHMnO1xuaW1wb3J0IHsgQ29tcG9uZW50RXggfSBmcm9tICcuL2NvbXBvbmVudC1leC50cyc7XG5pbXBvcnQgeyBQbHVnaW5Ob3RpY2VDb21wb25lbnQgfSBmcm9tICcuL3BsdWdpbi1ub3RpY2UtY29tcG9uZW50LnRzJztcblxuLyoqXG4gKiBSZWdpc3RlcnMgYSBnbG9iYWwgYXN5bmMgZXJyb3IgaGFuZGxlciB0aGF0IHNob3dzIGEgbm90aWNlIHRvIHRoZSB1c2VyLlxuICovXG5leHBvcnQgY2xhc3MgQXN5bmNFcnJvckhhbmRsZXJDb21wb25lbnQgZXh0ZW5kcyBDb21wb25lbnRFeCB7XG4gIC8qKlxuICAgKiBDcmVhdGVzIGEgbmV3IGFzeW5jIGVycm9yIGhhbmRsZXIgY29tcG9uZW50LlxuICAgKl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