(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/clipboard.ts
  (function() {
    const clipboard = {
      /**
       * Read text from clipboard
       */
      async readText() {
        const result = await invokePlugin("clipboard", "read_text", {});
        return result.text || "";
      },
      /**
       * Write text to clipboard
       */
      async writeText(text) {
        return invokePlugin("clipboard", "write_text", { text });
      },
      /**
       * Clear clipboard contents
       */
      async clear() {
        return invokePlugin("clipboard", "clear", {});
      },
      /**
       * Check if clipboard has text content
       */
      async hasText() {
        const result = await invokePlugin("clipboard", "has_text", {});
        return result.hasText || false;
      },
      /**
       * Read image from clipboard as base64
       */
      async readImage() {
        try {
          const result = await invokePlugin("clipboard", "read_image", {});
          return result.image || null;
        } catch {
          return null;
        }
      },
      /**
       * Write image to clipboard from base64
       */
      async writeImage(base64) {
        return invokePlugin("clipboard", "write_image", { image: base64 });
      }
    };
    initPlugin("clipboard", clipboard);
  })();

})();
