(function () {
  'use strict';

  // Generated by @auroraview/sdk

  // src/inject/plugins/utils.ts
  async function invokePlugin(plugin, command, args) {
    if (!window.auroraview || !window.auroraview.invoke) {
      throw new Error("AuroraView bridge not available");
    }
    const result = await window.auroraview.invoke(
      `plugin:${plugin}|${command}`,
      args || {}
    );
    if (result && result.success === false) {
      const error = new Error(result.error || "Unknown error");
      error.code = result.code || "UNKNOWN";
      throw error;
    }
    return result;
  }
  function attachPlugin(name, api) {
    if (window.auroraview) {
      window.auroraview[name] = api;
      console.log(`[AuroraView] ${name.charAt(0).toUpperCase() + name.slice(1)} plugin initialized`);
    }
  }
  function initPlugin(name, api) {
    if (window.auroraview) {
      attachPlugin(name, api);
    } else {
      const observer = setInterval(function() {
        if (window.auroraview) {
          clearInterval(observer);
          attachPlugin(name, api);
        }
      }, 10);
      setTimeout(function() {
        clearInterval(observer);
      }, 5e3);
    }
  }

  // src/inject/plugins/dialog.ts
  (function() {
    const dialog = {
      /**
       * Open a single file picker dialog
       */
      async openFile(options) {
        return invokePlugin("dialog", "open_file", options || {});
      },
      /**
       * Open a multiple file picker dialog
       */
      async openFiles(options) {
        return invokePlugin("dialog", "open_files", options || {});
      },
      /**
       * Open a folder picker dialog
       */
      async openFolder(options) {
        return invokePlugin("dialog", "open_folder", options || {});
      },
      /**
       * Open a multiple folder picker dialog
       */
      async openFolders(options) {
        return invokePlugin("dialog", "open_folders", options || {});
      },
      /**
       * Open a save file dialog
       */
      async saveFile(options) {
        return invokePlugin("dialog", "save_file", options || {});
      },
      /**
       * Show a message dialog
       */
      async message(options) {
        return invokePlugin("dialog", "message", options);
      },
      /**
       * Show a confirmation dialog
       */
      async confirm(options) {
        return invokePlugin("dialog", "confirm", options);
      },
      /**
       * Show an info message
       */
      async info(message, title) {
        return this.message({ message, title, level: "info" });
      },
      /**
       * Show a warning message
       */
      async warning(message, title) {
        return this.message({ message, title, level: "warning" });
      },
      /**
       * Show an error message
       */
      async error(message, title) {
        return this.message({ message, title, level: "error" });
      },
      /**
       * Show a yes/no question dialog
       */
      async ask(message, title) {
        const result = await this.confirm({ message, title });
        return result.confirmed;
      }
    };
    initPlugin("dialog", dialog);
  })();

})();
