(function () {
  'use strict';

  // Generated by @auroraview/sdk

  // src/inject/extensions/native_api.ts
  async function callNativeApi(extensionId, api, method, params = {}) {
    if (typeof window.auroraview?.invoke !== "function") {
      console.warn("[Chrome API] AuroraView bridge not available");
      return null;
    }
    try {
      return await window.auroraview.invoke("plugin:extensions|api_call", {
        extensionId,
        api,
        method,
        params
      });
    } catch (e) {
      console.error(`[Chrome API] ${api}.${method} failed:`, e);
      throw e;
    }
  }
  function createNativeApiCaller(extensionId) {
    return (api, method, params = {}) => callNativeApi(extensionId, api, method, params);
  }

  // src/inject/extensions/event_emitter.ts
  var EventEmitter = class {
    constructor() {
      this._listeners = [];
      this._onceListeners = [];
    }
    addListener(callback) {
      if (typeof callback === "function") {
        this._listeners.push(callback);
      }
    }
    removeListener(callback) {
      const idx = this._listeners.indexOf(callback);
      if (idx >= 0) {
        this._listeners.splice(idx, 1);
      }
    }
    hasListener(callback) {
      return this._listeners.includes(callback);
    }
    hasListeners() {
      return this._listeners.length > 0;
    }
    addOnceListener(callback) {
      if (typeof callback === "function") {
        this._onceListeners.push(callback);
      }
    }
    /** @internal */
    _dispatch(...args) {
      for (const listener of this._listeners) {
        try {
          listener(...args);
        } catch (e) {
          console.error("[Chrome API] Event listener error:", e);
        }
      }
      const once = this._onceListeners.splice(0);
      for (const listener of once) {
        try {
          listener(...args);
        } catch (e) {
          console.error("[Chrome API] Once listener error:", e);
        }
      }
    }
  };
  function createWebRequestEvent(eventName, callNativeApi2) {
    const listeners = [];
    return {
      _listeners: listeners,
      addListener(callback, filter, extraInfoSpec) {
        listeners.push({ callback, filter, extraInfoSpec });
        callNativeApi2("webRequest", "addListener", {
          event: eventName,
          filter,
          extraInfoSpec
        });
      },
      removeListener(callback) {
        const idx = listeners.findIndex((l) => l.callback === callback);
        if (idx >= 0) {
          listeners.splice(idx, 1);
          callNativeApi2("webRequest", "removeListener", { event: eventName });
        }
      },
      hasListener(callback) {
        return listeners.some((l) => l.callback === callback);
      },
      hasListeners() {
        return listeners.length > 0;
      }
    };
  }

  // src/inject/extensions/apis/storage.ts
  function createStorageArea(areaName, callNativeApi2, globalOnChanged) {
    const onChanged = new EventEmitter();
    const area = {
      async get(keys) {
        let keyList = null;
        let defaults = {};
        if (keys === null || keys === void 0) {
          keyList = null;
        } else if (typeof keys === "string") {
          keyList = [keys];
        } else if (Array.isArray(keys)) {
          keyList = keys;
        } else if (typeof keys === "object") {
          keyList = Object.keys(keys);
          defaults = keys;
        }
        const result = await callNativeApi2("storage", "get", { area: areaName, keys: keyList });
        return { ...defaults, ...result };
      },
      async set(items) {
        const oldValues = await area.get(Object.keys(items));
        await callNativeApi2("storage", "set", { area: areaName, items });
        const changes = {};
        for (const [key, newValue] of Object.entries(items)) {
          changes[key] = {
            oldValue: oldValues[key],
            newValue
          };
        }
        globalOnChanged._dispatch(changes, areaName);
        onChanged._dispatch(changes, areaName);
      },
      async remove(keys) {
        const keyList = Array.isArray(keys) ? keys : [keys];
        const oldValues = await area.get(keyList);
        await callNativeApi2("storage", "remove", { area: areaName, keys: keyList });
        const changes = {};
        for (const key of keyList) {
          if (key in oldValues) {
            changes[key] = { oldValue: oldValues[key] };
          }
        }
        if (Object.keys(changes).length > 0) {
          globalOnChanged._dispatch(changes, areaName);
          onChanged._dispatch(changes, areaName);
        }
      },
      async clear() {
        const oldValues = await area.get(null);
        await callNativeApi2("storage", "clear", { area: areaName });
        const changes = {};
        for (const [key, value] of Object.entries(oldValues)) {
          changes[key] = { oldValue: value };
        }
        if (Object.keys(changes).length > 0) {
          globalOnChanged._dispatch(changes, areaName);
          onChanged._dispatch(changes, areaName);
        }
      },
      async getBytesInUse(keys) {
        const keyList = keys ? Array.isArray(keys) ? keys : [keys] : null;
        return callNativeApi2("storage", "getBytesInUse", { area: areaName, keys: keyList });
      },
      async setAccessLevel(accessOptions) {
        return callNativeApi2("storage", "setAccessLevel", { area: areaName, accessOptions });
      },
      onChanged,
      // Storage quotas
      QUOTA_BYTES: areaName === "sync" ? 102400 : 10485760,
      QUOTA_BYTES_PER_ITEM: areaName === "sync" ? 8192 : 10485760,
      MAX_ITEMS: areaName === "sync" ? 512 : 1e4,
      MAX_WRITE_OPERATIONS_PER_HOUR: areaName === "sync" ? 1800 : 1e4,
      MAX_WRITE_OPERATIONS_PER_MINUTE: areaName === "sync" ? 120 : 1e3
    };
    return area;
  }
  function createStorageApi(callNativeApi2) {
    const onChanged = new EventEmitter();
    return {
      local: createStorageArea("local", callNativeApi2, onChanged),
      sync: createStorageArea("sync", callNativeApi2, onChanged),
      session: createStorageArea("session", callNativeApi2, onChanged),
      managed: createStorageArea("managed", callNativeApi2, onChanged),
      onChanged
    };
  }

  // src/inject/extensions/apis/runtime.ts
  function createRuntimeApi(callNativeApi2, extensionId, manifest = {}, getLastError = () => null, _setLastError) {
    const onInstalled = new EventEmitter();
    const onStartup = new EventEmitter();
    const onSuspend = new EventEmitter();
    const onSuspendCanceled = new EventEmitter();
    const onUpdateAvailable = new EventEmitter();
    const onMessage = new EventEmitter();
    const onMessageExternal = new EventEmitter();
    const onConnect = new EventEmitter();
    const onConnectExternal = new EventEmitter();
    const onConnectNative = new EventEmitter();
    return {
      id: extensionId,
      getURL(path) {
        const cleanPath = path.replace(/^\//, "");
        return `chrome-extension://${extensionId}/${cleanPath}`;
      },
      getManifest() {
        return manifest;
      },
      async getPlatformInfo() {
        const userAgent = navigator.userAgent.toLowerCase();
        let os = "win";
        if (userAgent.includes("mac")) os = "mac";
        else if (userAgent.includes("linux")) os = "linux";
        else if (userAgent.includes("cros")) os = "cros";
        else if (userAgent.includes("android")) os = "android";
        let arch = "x86-64";
        if (userAgent.includes("arm")) arch = "arm";
        else if (userAgent.includes("x86")) arch = "x86-32";
        return { os, arch, nacl_arch: arch };
      },
      async sendMessage(extensionIdOrMessage, messageOrOptions, options) {
        let targetExtensionId = extensionId;
        let message = extensionIdOrMessage;
        if (typeof extensionIdOrMessage === "string" && extensionIdOrMessage !== extensionId) {
          targetExtensionId = extensionIdOrMessage;
          message = messageOrOptions;
        } else if (typeof extensionIdOrMessage === "object") {
          options = messageOrOptions;
          message = extensionIdOrMessage;
        }
        return callNativeApi2("runtime", "sendMessage", {
          extensionId: targetExtensionId,
          message,
          options
        });
      },
      connect(extensionIdOrConnectInfo, connectInfo) {
        let targetExtensionId = extensionId;
        let info = connectInfo;
        if (typeof extensionIdOrConnectInfo === "object") {
          info = extensionIdOrConnectInfo;
        } else if (typeof extensionIdOrConnectInfo === "string") {
          targetExtensionId = extensionIdOrConnectInfo;
        }
        const portId = `port_${Date.now()}_${Math.random().toString(36).substring(2, 11)}`;
        const portOnMessage = new EventEmitter();
        const portOnDisconnect = new EventEmitter();
        let connected = true;
        const port = {
          name: info?.name || "",
          sender: { id: extensionId },
          onMessage: portOnMessage,
          onDisconnect: portOnDisconnect,
          postMessage(message) {
            if (!connected) {
              throw new Error("Attempting to use a disconnected port object");
            }
            callNativeApi2("runtime", "portPostMessage", { portId, message });
          },
          disconnect() {
            if (connected) {
              connected = false;
              callNativeApi2("runtime", "portDisconnect", { portId });
              portOnDisconnect._dispatch();
            }
          }
        };
        callNativeApi2("runtime", "connect", {
          extensionId: targetExtensionId,
          portId,
          name: port.name
        });
        return port;
      },
      async openOptionsPage() {
        return callNativeApi2("runtime", "openOptionsPage", {});
      },
      async setUninstallURL(url) {
        return callNativeApi2("runtime", "setUninstallURL", { url });
      },
      reload() {
        callNativeApi2("runtime", "reload", {});
      },
      async requestUpdateCheck() {
        return callNativeApi2("runtime", "requestUpdateCheck", {});
      },
      getBackgroundPage(callback) {
        if (callback) callback(null);
        return Promise.resolve(null);
      },
      async getContexts(filter) {
        return callNativeApi2("runtime", "getContexts", { filter });
      },
      getPackageDirectoryEntry(callback) {
        if (callback) callback(null);
      },
      onInstalled,
      onStartup,
      onSuspend,
      onSuspendCanceled,
      onUpdateAvailable,
      onMessage,
      onMessageExternal,
      onConnect,
      onConnectExternal,
      onConnectNative,
      get lastError() {
        return getLastError();
      }
    };
  }

  // src/inject/extensions/apis/tabs.ts
  function createTabsApi(callNativeApi2) {
    return {
      TAB_ID_NONE: -1,
      async query(queryInfo) {
        return callNativeApi2("tabs", "query", queryInfo || {});
      },
      async get(tabId) {
        return callNativeApi2("tabs", "get", { tabId });
      },
      async getCurrent() {
        const tabs = await callNativeApi2("tabs", "query", { active: true, currentWindow: true });
        return tabs[0] || null;
      },
      async create(createProperties) {
        return callNativeApi2("tabs", "create", createProperties);
      },
      async update(tabIdOrProps, updateProperties) {
        if (typeof tabIdOrProps === "object") {
          return callNativeApi2("tabs", "update", tabIdOrProps);
        }
        return callNativeApi2("tabs", "update", { tabId: tabIdOrProps, ...updateProperties });
      },
      async remove(tabIds) {
        const ids = Array.isArray(tabIds) ? tabIds : [tabIds];
        return callNativeApi2("tabs", "remove", { tabIds: ids });
      },
      async reload(tabIdOrProps, reloadProperties) {
        if (typeof tabIdOrProps === "object") {
          return callNativeApi2("tabs", "reload", tabIdOrProps);
        }
        return callNativeApi2("tabs", "reload", { tabId: tabIdOrProps, ...reloadProperties });
      },
      async duplicate(tabId) {
        return callNativeApi2("tabs", "duplicate", { tabId });
      },
      async sendMessage(tabId, message, options) {
        return callNativeApi2("tabs", "sendMessage", { tabId, message, options });
      },
      async captureVisibleTab(windowIdOrOptions, options) {
        if (typeof windowIdOrOptions === "object") {
          return callNativeApi2("tabs", "captureVisibleTab", windowIdOrOptions);
        }
        return callNativeApi2("tabs", "captureVisibleTab", { windowId: windowIdOrOptions, options });
      },
      async executeScript(tabIdOrDetails, details) {
        if (typeof tabIdOrDetails === "object") {
          return callNativeApi2("tabs", "executeScript", tabIdOrDetails);
        }
        return callNativeApi2("tabs", "executeScript", { tabId: tabIdOrDetails, ...details });
      },
      async insertCSS(tabIdOrDetails, details) {
        if (typeof tabIdOrDetails === "object") {
          return callNativeApi2("tabs", "insertCSS", tabIdOrDetails);
        }
        return callNativeApi2("tabs", "insertCSS", { tabId: tabIdOrDetails, ...details });
      },
      async removeCSS(tabIdOrDetails, details) {
        if (typeof tabIdOrDetails === "object") {
          return callNativeApi2("tabs", "removeCSS", tabIdOrDetails);
        }
        return callNativeApi2("tabs", "removeCSS", { tabId: tabIdOrDetails, ...details });
      },
      async setZoom(tabIdOrFactor, zoomFactor) {
        if (typeof zoomFactor === "undefined") {
          return callNativeApi2("tabs", "setZoom", { zoomFactor: tabIdOrFactor });
        }
        return callNativeApi2("tabs", "setZoom", { tabId: tabIdOrFactor, zoomFactor });
      },
      async getZoom(tabId) {
        return callNativeApi2("tabs", "getZoom", { tabId });
      },
      async group(options) {
        return callNativeApi2("tabs", "group", options);
      },
      async ungroup(tabIds) {
        return callNativeApi2("tabs", "ungroup", { tabIds: Array.isArray(tabIds) ? tabIds : [tabIds] });
      },
      // Events
      onCreated: new EventEmitter(),
      onUpdated: new EventEmitter(),
      onMoved: new EventEmitter(),
      onActivated: new EventEmitter(),
      onHighlighted: new EventEmitter(),
      onDetached: new EventEmitter(),
      onAttached: new EventEmitter(),
      onRemoved: new EventEmitter(),
      onReplaced: new EventEmitter(),
      onZoomChange: new EventEmitter()
    };
  }

  // src/inject/extensions/apis/side_panel.ts
  function createSidePanelApi(callNativeApi2) {
    return {
      async setOptions(options) {
        return callNativeApi2("sidePanel", "setOptions", { options });
      },
      async getOptions(options) {
        return callNativeApi2("sidePanel", "getOptions", options || {});
      },
      async open(options) {
        return callNativeApi2("sidePanel", "open", options || {});
      },
      async setPanelBehavior(behavior) {
        return callNativeApi2("sidePanel", "setPanelBehavior", { behavior });
      },
      async getPanelBehavior() {
        return callNativeApi2("sidePanel", "getPanelBehavior", {});
      }
    };
  }

  // src/inject/extensions/apis/action.ts
  function createActionApi(callNativeApi2) {
    const onClicked = new EventEmitter();
    return {
      async setIcon(details) {
        return callNativeApi2("action", "setIcon", details);
      },
      async setTitle(details) {
        return callNativeApi2("action", "setTitle", details);
      },
      async getTitle(details) {
        return callNativeApi2("action", "getTitle", details);
      },
      async setPopup(details) {
        return callNativeApi2("action", "setPopup", details);
      },
      async getPopup(details) {
        return callNativeApi2("action", "getPopup", details);
      },
      async setBadgeText(details) {
        return callNativeApi2("action", "setBadgeText", details);
      },
      async getBadgeText(details) {
        return callNativeApi2("action", "getBadgeText", details);
      },
      async setBadgeBackgroundColor(details) {
        return callNativeApi2("action", "setBadgeBackgroundColor", details);
      },
      async getBadgeBackgroundColor(details) {
        return callNativeApi2("action", "getBadgeBackgroundColor", details);
      },
      async setBadgeTextColor(details) {
        return callNativeApi2("action", "setBadgeTextColor", details);
      },
      async getBadgeTextColor(details) {
        return callNativeApi2("action", "getBadgeTextColor", details);
      },
      async enable(tabId) {
        return callNativeApi2("action", "enable", { tabId });
      },
      async disable(tabId) {
        return callNativeApi2("action", "disable", { tabId });
      },
      async isEnabled(details) {
        return callNativeApi2("action", "isEnabled", details);
      },
      async openPopup(options) {
        return callNativeApi2("action", "openPopup", options || {});
      },
      onClicked
    };
  }

  // src/inject/extensions/apis/scripting.ts
  function createScriptingApi(callNativeApi2) {
    return {
      async executeScript(injection) {
        const params = { ...injection };
        if (injection.func) {
          params.func = injection.func.toString();
        }
        return callNativeApi2("scripting", "executeScript", params);
      },
      async insertCSS(injection) {
        return callNativeApi2("scripting", "insertCSS", injection);
      },
      async removeCSS(injection) {
        return callNativeApi2("scripting", "removeCSS", injection);
      },
      async registerContentScripts(scripts) {
        return callNativeApi2("scripting", "registerContentScripts", { scripts });
      },
      async unregisterContentScripts(filter) {
        return callNativeApi2("scripting", "unregisterContentScripts", filter || {});
      },
      async getRegisteredContentScripts(filter) {
        return callNativeApi2("scripting", "getRegisteredContentScripts", filter || {});
      },
      async updateContentScripts(scripts) {
        return callNativeApi2("scripting", "updateContentScripts", { scripts });
      }
    };
  }

  // src/inject/extensions/apis/context_menus.ts
  function createContextMenusApi(callNativeApi2) {
    const onClicked = new EventEmitter();
    let menuIdCounter = 0;
    return {
      create(createProperties, callback) {
        const id = createProperties.id ?? `menu_${++menuIdCounter}`;
        callNativeApi2("contextMenus", "create", { ...createProperties, id }).then(() => {
          callback?.();
        });
        return id;
      },
      async update(id, updateProperties) {
        return callNativeApi2("contextMenus", "update", { id, ...updateProperties });
      },
      async remove(menuItemId) {
        return callNativeApi2("contextMenus", "remove", { menuItemId });
      },
      async removeAll() {
        return callNativeApi2("contextMenus", "removeAll", {});
      },
      onClicked,
      ACTION_MENU_TOP_LEVEL_LIMIT: 6
    };
  }

  // src/inject/extensions/apis/notifications.ts
  function createNotificationsApi(callNativeApi2) {
    const onClicked = new EventEmitter();
    const onButtonClicked = new EventEmitter();
    const onClosed = new EventEmitter();
    const onPermissionLevelChanged = new EventEmitter();
    const onShowSettings = new EventEmitter();
    return {
      async create(notificationId, options) {
        return callNativeApi2("notifications", "create", { notificationId, options });
      },
      async update(notificationId, options) {
        return callNativeApi2("notifications", "update", { notificationId, options });
      },
      async clear(notificationId) {
        return callNativeApi2("notifications", "clear", { notificationId });
      },
      async getAll() {
        return callNativeApi2("notifications", "getAll", {});
      },
      async getPermissionLevel() {
        return callNativeApi2("notifications", "getPermissionLevel", {});
      },
      onClicked,
      onButtonClicked,
      onClosed,
      onPermissionLevelChanged,
      onShowSettings
    };
  }

  // src/inject/extensions/apis/alarms.ts
  function createAlarmsApi(callNativeApi2) {
    const onAlarm = new EventEmitter();
    return {
      async create(name, alarmInfo) {
        return callNativeApi2("alarms", "create", { name, alarmInfo });
      },
      async get(name) {
        return callNativeApi2("alarms", "get", { name });
      },
      async getAll() {
        return callNativeApi2("alarms", "getAll", {});
      },
      async clear(name) {
        return callNativeApi2("alarms", "clear", { name });
      },
      async clearAll() {
        return callNativeApi2("alarms", "clearAll", {});
      },
      onAlarm
    };
  }

  // src/inject/extensions/apis/web_request.ts
  function createWebRequestApi(callNativeApi2) {
    return {
      onBeforeRequest: createWebRequestEvent("onBeforeRequest", callNativeApi2),
      onBeforeSendHeaders: createWebRequestEvent("onBeforeSendHeaders", callNativeApi2),
      onSendHeaders: createWebRequestEvent("onSendHeaders", callNativeApi2),
      onHeadersReceived: createWebRequestEvent("onHeadersReceived", callNativeApi2),
      onAuthRequired: createWebRequestEvent("onAuthRequired", callNativeApi2),
      onResponseStarted: createWebRequestEvent("onResponseStarted", callNativeApi2),
      onBeforeRedirect: createWebRequestEvent("onBeforeRedirect", callNativeApi2),
      onCompleted: createWebRequestEvent("onCompleted", callNativeApi2),
      onErrorOccurred: createWebRequestEvent("onErrorOccurred", callNativeApi2),
      async handlerBehaviorChanged() {
        return callNativeApi2("webRequest", "handlerBehaviorChanged", {});
      },
      MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES: 20
    };
  }

  // src/inject/extensions/apis/i18n.ts
  function createI18nApi(callNativeApi2, messages = {}) {
    return {
      getMessage(messageName, substitutions) {
        const entry = messages[messageName];
        if (!entry) {
          return "";
        }
        let result = entry.message;
        if (entry.placeholders) {
          for (const [key, value] of Object.entries(entry.placeholders)) {
            let content = value.content;
            if (substitutions) {
              const subs = Array.isArray(substitutions) ? substitutions : [substitutions];
              content = content.replace(/\$(\d+)/g, (_, idx) => subs[parseInt(idx) - 1] || "");
            }
            result = result.replace(new RegExp(`\\$${key}\\$`, "gi"), content);
          }
        }
        if (substitutions) {
          const subs = Array.isArray(substitutions) ? substitutions : [substitutions];
          result = result.replace(/\$(\d+)/g, (_, idx) => subs[parseInt(idx) - 1] || "");
        }
        return result;
      },
      getUILanguage() {
        return navigator.language || "en";
      },
      async getAcceptLanguages() {
        return navigator.languages ? [...navigator.languages] : ["en"];
      },
      async detectLanguage(text) {
        return callNativeApi2("i18n", "detectLanguage", { text });
      }
    };
  }

  // src/inject/extensions/apis/extension.ts
  function createExtensionApi(callNativeApi2, extensionId, extensionPath) {
    return {
      getURL(path) {
        const cleanPath = path.startsWith("/") ? path.slice(1) : path;
        return `file:///${extensionPath.replace(/\\/g, "/")}/${cleanPath}`;
      },
      async getBackgroundPage() {
        return null;
      },
      getViews(_fetchProperties) {
        return [window];
      },
      async isAllowedIncognitoAccess() {
        return false;
      },
      async isAllowedFileSchemeAccess() {
        return true;
      },
      setUpdateUrlData(_data) {
      },
      inIncognitoContext: false
    };
  }

  // src/inject/extensions/apis/windows.ts
  function createWindowsApi(callNativeApi2) {
    const onCreated = new EventEmitter();
    const onRemoved = new EventEmitter();
    const onFocusChanged = new EventEmitter();
    const onBoundsChanged = new EventEmitter();
    return {
      async get(windowId, queryOptions) {
        return callNativeApi2("windows", "get", { windowId, ...queryOptions });
      },
      async getCurrent(queryOptions) {
        return callNativeApi2("windows", "getCurrent", queryOptions || {});
      },
      async getLastFocused(queryOptions) {
        return callNativeApi2("windows", "getLastFocused", queryOptions || {});
      },
      async getAll(queryOptions) {
        return callNativeApi2("windows", "getAll", queryOptions || {});
      },
      async create(createData) {
        return callNativeApi2("windows", "create", createData || {});
      },
      async update(windowId, updateInfo) {
        return callNativeApi2("windows", "update", { windowId, ...updateInfo });
      },
      async remove(windowId) {
        return callNativeApi2("windows", "remove", { windowId });
      },
      onCreated,
      onRemoved,
      onFocusChanged,
      onBoundsChanged,
      WINDOW_ID_NONE: -1,
      WINDOW_ID_CURRENT: -2
    };
  }

  // src/inject/extensions/apis/commands.ts
  function createCommandsApi(callNativeApi2) {
    const onCommand = new EventEmitter();
    return {
      async getAll() {
        return callNativeApi2("commands", "getAll", {});
      },
      onCommand
    };
  }

  // src/inject/extensions/apis/permissions.ts
  function createPermissionsApi(callNativeApi2) {
    const onAdded = new EventEmitter();
    const onRemoved = new EventEmitter();
    return {
      async getAll() {
        return callNativeApi2("permissions", "getAll", {});
      },
      async contains(permissions) {
        return callNativeApi2("permissions", "contains", { permissions });
      },
      async request(permissions) {
        return callNativeApi2("permissions", "request", { permissions });
      },
      async remove(permissions) {
        return callNativeApi2("permissions", "remove", { permissions });
      },
      onAdded,
      onRemoved
    };
  }

  // src/inject/extensions/apis/identity.ts
  function createIdentityApi(callNativeApi2, extensionId) {
    const onSignInChanged = new EventEmitter();
    return {
      async getAuthToken(details) {
        return callNativeApi2("identity", "getAuthToken", details || {});
      },
      async removeCachedAuthToken(details) {
        return callNativeApi2("identity", "removeCachedAuthToken", details);
      },
      async clearAllCachedAuthTokens() {
        return callNativeApi2("identity", "clearAllCachedAuthTokens", {});
      },
      async getProfileUserInfo(details) {
        return callNativeApi2("identity", "getProfileUserInfo", details || {});
      },
      async getAccounts() {
        return callNativeApi2("identity", "getAccounts", {});
      },
      async launchWebAuthFlow(details) {
        return callNativeApi2("identity", "launchWebAuthFlow", details);
      },
      getRedirectURL(path) {
        const base = `https://${extensionId}.chromiumapp.org`;
        return path ? `${base}/${path}` : `${base}/`;
      },
      onSignInChanged
    };
  }

  // src/inject/extensions/apis/declarative_net_request.ts
  function createDeclarativeNetRequestApi(callNativeApi2) {
    const onRuleMatchedDebug = new EventEmitter();
    return {
      async updateDynamicRules(options) {
        return callNativeApi2("declarativeNetRequest", "updateDynamicRules", options);
      },
      async getDynamicRules(filter) {
        return callNativeApi2("declarativeNetRequest", "getDynamicRules", filter || {});
      },
      async updateSessionRules(options) {
        return callNativeApi2("declarativeNetRequest", "updateSessionRules", options);
      },
      async getSessionRules(filter) {
        return callNativeApi2("declarativeNetRequest", "getSessionRules", filter || {});
      },
      async updateEnabledRulesets(options) {
        return callNativeApi2("declarativeNetRequest", "updateEnabledRulesets", options);
      },
      async getEnabledRulesets() {
        return callNativeApi2("declarativeNetRequest", "getEnabledRulesets", {});
      },
      async getAvailableStaticRuleCount() {
        return callNativeApi2("declarativeNetRequest", "getAvailableStaticRuleCount", {});
      },
      async getMatchedRules(filter) {
        return callNativeApi2("declarativeNetRequest", "getMatchedRules", filter || {});
      },
      async setExtensionActionOptions(options) {
        return callNativeApi2("declarativeNetRequest", "setExtensionActionOptions", options);
      },
      async isRegexSupported(regexOptions) {
        return callNativeApi2("declarativeNetRequest", "isRegexSupported", regexOptions);
      },
      onRuleMatchedDebug,
      MAX_NUMBER_OF_DYNAMIC_AND_SESSION_RULES: 5e3,
      MAX_NUMBER_OF_ENABLED_STATIC_RULESETS: 50,
      GETMATCHEDRULES_QUOTA_INTERVAL: 10,
      MAX_GETMATCHEDRULES_CALLS_PER_INTERVAL: 20,
      DYNAMIC_RULESET_ID: "_dynamic",
      SESSION_RULESET_ID: "_session",
      GUARANTEED_MINIMUM_STATIC_RULES: 3e4,
      MAX_NUMBER_OF_REGEX_RULES: 1e3
    };
  }

  // src/inject/extensions/apis/offscreen.ts
  function createOffscreenApi(callNativeApi2) {
    const reasons = {
      TESTING: "TESTING",
      AUDIO_PLAYBACK: "AUDIO_PLAYBACK",
      IFRAME_SCRIPTING: "IFRAME_SCRIPTING",
      DOM_SCRAPING: "DOM_SCRAPING",
      BLOBS: "BLOBS",
      DOM_PARSER: "DOM_PARSER",
      USER_MEDIA: "USER_MEDIA",
      DISPLAY_MEDIA: "DISPLAY_MEDIA",
      WEB_RTC: "WEB_RTC",
      CLIPBOARD: "CLIPBOARD",
      LOCAL_STORAGE: "LOCAL_STORAGE",
      WORKERS: "WORKERS",
      BATTERY_STATUS: "BATTERY_STATUS",
      MATCH_MEDIA: "MATCH_MEDIA",
      GEOLOCATION: "GEOLOCATION"
    };
    return {
      async createDocument(parameters) {
        return callNativeApi2("offscreen", "createDocument", parameters);
      },
      async closeDocument() {
        return callNativeApi2("offscreen", "closeDocument", {});
      },
      async hasDocument() {
        return callNativeApi2("offscreen", "hasDocument", {});
      },
      Reason: reasons
    };
  }

  // src/inject/extensions/apis/bookmarks.ts
  function createBookmarksApi(callNativeApi2) {
    const onCreated = new EventEmitter();
    const onRemoved = new EventEmitter();
    const onChanged = new EventEmitter();
    const onMoved = new EventEmitter();
    const onChildrenReordered = new EventEmitter();
    const onImportBegan = new EventEmitter();
    const onImportEnded = new EventEmitter();
    return {
      async get(idOrIdList) {
        return callNativeApi2("bookmarks", "get", { idOrIdList });
      },
      async getChildren(id) {
        return callNativeApi2("bookmarks", "getChildren", { id });
      },
      async getRecent(numberOfItems) {
        return callNativeApi2("bookmarks", "getRecent", { numberOfItems });
      },
      async getTree() {
        return callNativeApi2("bookmarks", "getTree", {});
      },
      async getSubTree(id) {
        return callNativeApi2("bookmarks", "getSubTree", { id });
      },
      async search(query) {
        return callNativeApi2("bookmarks", "search", { query });
      },
      async create(bookmark) {
        return callNativeApi2("bookmarks", "create", { bookmark });
      },
      async move(id, destination) {
        return callNativeApi2("bookmarks", "move", { id, destination });
      },
      async update(id, changes) {
        return callNativeApi2("bookmarks", "update", { id, changes });
      },
      async remove(id) {
        return callNativeApi2("bookmarks", "remove", { id });
      },
      async removeTree(id) {
        return callNativeApi2("bookmarks", "removeTree", { id });
      },
      onCreated,
      onRemoved,
      onChanged,
      onMoved,
      onChildrenReordered,
      onImportBegan,
      onImportEnded,
      MAX_WRITE_OPERATIONS_PER_HOUR: 1e6,
      MAX_SUSTAINED_WRITE_OPERATIONS_PER_MINUTE: 1e6
    };
  }

  // src/inject/extensions/apis/history.ts
  function createHistoryApi(callNativeApi2) {
    const onVisited = new EventEmitter();
    const onVisitRemoved = new EventEmitter();
    return {
      async search(query) {
        return callNativeApi2("history", "search", query);
      },
      async getVisits(details) {
        return callNativeApi2("history", "getVisits", details);
      },
      async addUrl(details) {
        return callNativeApi2("history", "addUrl", details);
      },
      async deleteUrl(details) {
        return callNativeApi2("history", "deleteUrl", details);
      },
      async deleteRange(range) {
        return callNativeApi2("history", "deleteRange", range);
      },
      async deleteAll() {
        return callNativeApi2("history", "deleteAll", {});
      },
      onVisited,
      onVisitRemoved
    };
  }

  // src/inject/extensions/apis/downloads.ts
  function createDownloadsApi(callNativeApi2) {
    const onCreated = new EventEmitter();
    const onErased = new EventEmitter();
    const onChanged = new EventEmitter();
    const onDeterminingFilename = new EventEmitter();
    return {
      async download(options) {
        return callNativeApi2("downloads", "download", options);
      },
      async search(query) {
        return callNativeApi2("downloads", "search", query);
      },
      async pause(downloadId) {
        return callNativeApi2("downloads", "pause", { downloadId });
      },
      async resume(downloadId) {
        return callNativeApi2("downloads", "resume", { downloadId });
      },
      async cancel(downloadId) {
        return callNativeApi2("downloads", "cancel", { downloadId });
      },
      async getFileIcon(downloadId, options) {
        return callNativeApi2("downloads", "getFileIcon", { downloadId, ...options });
      },
      async open(downloadId) {
        return callNativeApi2("downloads", "open", { downloadId });
      },
      async show(downloadId) {
        return callNativeApi2("downloads", "show", { downloadId });
      },
      showDefaultFolder() {
        callNativeApi2("downloads", "showDefaultFolder", {});
      },
      async erase(query) {
        return callNativeApi2("downloads", "erase", query);
      },
      async removeFile(downloadId) {
        return callNativeApi2("downloads", "removeFile", { downloadId });
      },
      async acceptDanger(downloadId) {
        return callNativeApi2("downloads", "acceptDanger", { downloadId });
      },
      setShelfEnabled(enabled) {
        callNativeApi2("downloads", "setShelfEnabled", { enabled });
      },
      async setUiOptions(options) {
        return callNativeApi2("downloads", "setUiOptions", options);
      },
      onCreated,
      onErased,
      onChanged,
      onDeterminingFilename
    };
  }

  // src/inject/extensions/apis/cookies.ts
  function createCookiesApi(callNativeApi2) {
    const onChanged = new EventEmitter();
    return {
      async get(details) {
        return callNativeApi2("cookies", "get", details);
      },
      async getAll(details) {
        return callNativeApi2("cookies", "getAll", details);
      },
      async set(details) {
        return callNativeApi2("cookies", "set", details);
      },
      async remove(details) {
        return callNativeApi2("cookies", "remove", details);
      },
      async getAllCookieStores() {
        return callNativeApi2("cookies", "getAllCookieStores", {});
      },
      onChanged
    };
  }

  // src/inject/extensions/apis/top_sites.ts
  function createTopSitesApi(callNativeApi2) {
    return {
      async get() {
        return callNativeApi2("topSites", "get", {});
      }
    };
  }

  // src/inject/extensions/apis/omnibox.ts
  function createOmniboxApi(callNativeApi2) {
    const onInputStarted = new EventEmitter();
    const onInputChanged = new EventEmitter();
    const onInputEntered = new EventEmitter();
    const onInputCancelled = new EventEmitter();
    const onDeleteSuggestion = new EventEmitter();
    return {
      setDefaultSuggestion(suggestion) {
        callNativeApi2("omnibox", "setDefaultSuggestion", suggestion);
      },
      onInputStarted,
      onInputChanged,
      onInputEntered,
      onInputCancelled,
      onDeleteSuggestion
    };
  }

  // src/inject/extensions/apis/search.ts
  function createSearchApi(callNativeApi2) {
    return {
      async query(queryInfo) {
        return callNativeApi2("search", "query", queryInfo);
      }
    };
  }

  // src/inject/extensions/apis/sessions.ts
  function createSessionsApi(callNativeApi2) {
    const onChanged = new EventEmitter();
    return {
      async getRecentlyClosed(filter) {
        return callNativeApi2("sessions", "getRecentlyClosed", filter || {});
      },
      async getDevices(filter) {
        return callNativeApi2("sessions", "getDevices", filter || {});
      },
      async restore(sessionId) {
        return callNativeApi2("sessions", "restore", { sessionId });
      },
      onChanged,
      MAX_SESSION_RESULTS: 25
    };
  }

  // src/inject/extensions/apis/tts.ts
  function createTtsApi(callNativeApi2) {
    const onVoicesChanged = new EventEmitter();
    return {
      async speak(utterance, options) {
        if ("speechSynthesis" in window) {
          return new Promise((resolve, reject) => {
            const speech = new SpeechSynthesisUtterance(utterance);
            if (options?.lang) speech.lang = options.lang;
            if (options?.rate) speech.rate = options.rate;
            if (options?.pitch) speech.pitch = options.pitch;
            if (options?.volume) speech.volume = options.volume;
            speech.onend = () => {
              options?.onEvent?.({ type: "end" });
              resolve();
            };
            speech.onerror = (e) => {
              options?.onEvent?.({ type: "error", errorMessage: e.error });
              reject(new Error(e.error));
            };
            speech.onstart = () => options?.onEvent?.({ type: "start" });
            speech.onpause = () => options?.onEvent?.({ type: "pause" });
            speech.onresume = () => options?.onEvent?.({ type: "resume" });
            window.speechSynthesis.speak(speech);
          });
        }
        return callNativeApi2("tts", "speak", { utterance, options });
      },
      stop() {
        if ("speechSynthesis" in window) {
          window.speechSynthesis.cancel();
        } else {
          callNativeApi2("tts", "stop", {});
        }
      },
      pause() {
        if ("speechSynthesis" in window) {
          window.speechSynthesis.pause();
        } else {
          callNativeApi2("tts", "pause", {});
        }
      },
      resume() {
        if ("speechSynthesis" in window) {
          window.speechSynthesis.resume();
        } else {
          callNativeApi2("tts", "resume", {});
        }
      },
      async isSpeaking() {
        if ("speechSynthesis" in window) {
          return window.speechSynthesis.speaking;
        }
        return callNativeApi2("tts", "isSpeaking", {});
      },
      async getVoices() {
        if ("speechSynthesis" in window) {
          return window.speechSynthesis.getVoices().map((v) => ({
            voiceName: v.name,
            lang: v.lang,
            remote: v.localService === false
          }));
        }
        return callNativeApi2("tts", "getVoices", {});
      },
      onVoicesChanged
    };
  }

  // src/inject/extensions/apis/browsing_data.ts
  function createBrowsingDataApi(callNativeApi2) {
    return {
      async settings() {
        return callNativeApi2("browsingData", "settings", {});
      },
      async remove(options, dataToRemove) {
        return callNativeApi2("browsingData", "remove", { options, dataToRemove });
      },
      async removeAppcache(options) {
        return callNativeApi2("browsingData", "removeAppcache", options);
      },
      async removeCache(options) {
        return callNativeApi2("browsingData", "removeCache", options);
      },
      async removeCacheStorage(options) {
        return callNativeApi2("browsingData", "removeCacheStorage", options);
      },
      async removeCookies(options) {
        return callNativeApi2("browsingData", "removeCookies", options);
      },
      async removeDownloads(options) {
        return callNativeApi2("browsingData", "removeDownloads", options);
      },
      async removeFileSystems(options) {
        return callNativeApi2("browsingData", "removeFileSystems", options);
      },
      async removeFormData(options) {
        return callNativeApi2("browsingData", "removeFormData", options);
      },
      async removeHistory(options) {
        return callNativeApi2("browsingData", "removeHistory", options);
      },
      async removeIndexedDB(options) {
        return callNativeApi2("browsingData", "removeIndexedDB", options);
      },
      async removeLocalStorage(options) {
        return callNativeApi2("browsingData", "removeLocalStorage", options);
      },
      async removePasswords(options) {
        return callNativeApi2("browsingData", "removePasswords", options);
      },
      async removeServiceWorkers(options) {
        return callNativeApi2("browsingData", "removeServiceWorkers", options);
      },
      async removeWebSQL(options) {
        return callNativeApi2("browsingData", "removeWebSQL", options);
      }
    };
  }

  // src/inject/extensions/apis/idle.ts
  function createIdleApi(callNativeApi2) {
    const onStateChanged = new EventEmitter();
    return {
      async queryState(detectionIntervalInSeconds) {
        return callNativeApi2("idle", "queryState", { detectionIntervalInSeconds });
      },
      setDetectionInterval(intervalInSeconds) {
        callNativeApi2("idle", "setDetectionInterval", { intervalInSeconds });
      },
      async getAutoLockDelay() {
        return callNativeApi2("idle", "getAutoLockDelay", {});
      },
      onStateChanged
    };
  }

  // src/inject/extensions/apis/power.ts
  function createPowerApi(callNativeApi2) {
    return {
      requestKeepAwake(level) {
        callNativeApi2("power", "requestKeepAwake", { level });
      },
      releaseKeepAwake() {
        callNativeApi2("power", "releaseKeepAwake", {});
      },
      async reportActivity() {
        return callNativeApi2("power", "reportActivity", {});
      }
    };
  }

  // src/inject/extensions/apis/tab_groups.ts
  function createTabGroupsApi(callNativeApi2) {
    const onCreated = new EventEmitter();
    const onUpdated = new EventEmitter();
    const onMoved = new EventEmitter();
    const onRemoved = new EventEmitter();
    const colors = {
      grey: "grey",
      blue: "blue",
      red: "red",
      yellow: "yellow",
      green: "green",
      pink: "pink",
      purple: "purple",
      cyan: "cyan",
      orange: "orange"
    };
    return {
      async get(groupId) {
        return callNativeApi2("tabGroups", "get", { groupId });
      },
      async query(queryInfo) {
        return callNativeApi2("tabGroups", "query", queryInfo);
      },
      async update(groupId, updateProperties) {
        return callNativeApi2("tabGroups", "update", { groupId, ...updateProperties });
      },
      async move(groupId, moveProperties) {
        return callNativeApi2("tabGroups", "move", { groupId, ...moveProperties });
      },
      onCreated,
      onUpdated,
      onMoved,
      onRemoved,
      TAB_GROUP_ID_NONE: -1,
      Color: colors
    };
  }

  // src/inject/extensions/apis/management.ts
  function createManagementApi(callNativeApi2) {
    const onInstalled = new EventEmitter();
    const onUninstalled = new EventEmitter();
    const onEnabled = new EventEmitter();
    const onDisabled = new EventEmitter();
    return {
      async getAll() {
        return callNativeApi2("management", "getAll", {});
      },
      async get(id) {
        return callNativeApi2("management", "get", { id });
      },
      async getSelf() {
        return callNativeApi2("management", "getSelf", {});
      },
      async getPermissionWarningsById(id) {
        return callNativeApi2("management", "getPermissionWarningsById", { id });
      },
      async getPermissionWarningsByManifest(manifestStr) {
        return callNativeApi2("management", "getPermissionWarningsByManifest", { manifestStr });
      },
      async setEnabled(id, enabled) {
        return callNativeApi2("management", "setEnabled", { id, enabled });
      },
      async uninstall(id, options) {
        return callNativeApi2("management", "uninstall", { id, ...options });
      },
      async uninstallSelf(options) {
        return callNativeApi2("management", "uninstallSelf", options || {});
      },
      async launchApp(id) {
        return callNativeApi2("management", "launchApp", { id });
      },
      async createAppShortcut(id) {
        return callNativeApi2("management", "createAppShortcut", { id });
      },
      async setLaunchType(id, launchType) {
        return callNativeApi2("management", "setLaunchType", { id, launchType });
      },
      async generateAppForLink(url, title) {
        return callNativeApi2("management", "generateAppForLink", { url, title });
      },
      onInstalled,
      onUninstalled,
      onEnabled,
      onDisabled
    };
  }

  // src/inject/extensions/apis/font_settings.ts
  function createFontSettingsApi(callNativeApi2) {
    const onFontChanged = new EventEmitter();
    const onDefaultFontSizeChanged = new EventEmitter();
    const onDefaultFixedFontSizeChanged = new EventEmitter();
    const onMinimumFontSizeChanged = new EventEmitter();
    return {
      async clearFont(details) {
        return callNativeApi2("fontSettings", "clearFont", details);
      },
      async getFont(details) {
        return callNativeApi2("fontSettings", "getFont", details);
      },
      async setFont(details) {
        return callNativeApi2("fontSettings", "setFont", details);
      },
      async getFontList() {
        return callNativeApi2("fontSettings", "getFontList", {});
      },
      async clearDefaultFontSize() {
        return callNativeApi2("fontSettings", "clearDefaultFontSize", {});
      },
      async getDefaultFontSize() {
        return callNativeApi2("fontSettings", "getDefaultFontSize", {});
      },
      async setDefaultFontSize(details) {
        return callNativeApi2("fontSettings", "setDefaultFontSize", details);
      },
      async clearDefaultFixedFontSize() {
        return callNativeApi2("fontSettings", "clearDefaultFixedFontSize", {});
      },
      async getDefaultFixedFontSize() {
        return callNativeApi2("fontSettings", "getDefaultFixedFontSize", {});
      },
      async setDefaultFixedFontSize(details) {
        return callNativeApi2("fontSettings", "setDefaultFixedFontSize", details);
      },
      async clearMinimumFontSize() {
        return callNativeApi2("fontSettings", "clearMinimumFontSize", {});
      },
      async getMinimumFontSize() {
        return callNativeApi2("fontSettings", "getMinimumFontSize", {});
      },
      async setMinimumFontSize(details) {
        return callNativeApi2("fontSettings", "setMinimumFontSize", details);
      },
      onFontChanged,
      onDefaultFontSizeChanged,
      onDefaultFixedFontSizeChanged,
      onMinimumFontSizeChanged
    };
  }

  // src/inject/extensions/polyfill.ts
  function createChromePolyfill(config) {
    const { extensionId, extensionPath, manifest = {}, messages = {} } = config;
    const callNativeApi2 = createNativeApiCaller(extensionId);
    let lastError = null;
    const chrome = {
      // Core APIs
      runtime: createRuntimeApi(callNativeApi2, extensionId, manifest, () => lastError),
      storage: createStorageApi(callNativeApi2),
      tabs: createTabsApi(callNativeApi2),
      windows: createWindowsApi(callNativeApi2),
      // UI APIs
      action: createActionApi(callNativeApi2),
      sidePanel: createSidePanelApi(callNativeApi2),
      contextMenus: createContextMenusApi(callNativeApi2),
      notifications: createNotificationsApi(callNativeApi2),
      omnibox: createOmniboxApi(callNativeApi2),
      // Content & Scripting
      scripting: createScriptingApi(callNativeApi2),
      webRequest: createWebRequestApi(callNativeApi2),
      declarativeNetRequest: createDeclarativeNetRequestApi(callNativeApi2),
      // Extension utilities
      extension: createExtensionApi(callNativeApi2, extensionId, extensionPath),
      i18n: createI18nApi(callNativeApi2, messages),
      commands: createCommandsApi(callNativeApi2),
      permissions: createPermissionsApi(callNativeApi2),
      identity: createIdentityApi(callNativeApi2, extensionId),
      management: createManagementApi(callNativeApi2),
      // Data & State
      alarms: createAlarmsApi(callNativeApi2),
      bookmarks: createBookmarksApi(callNativeApi2),
      history: createHistoryApi(callNativeApi2),
      downloads: createDownloadsApi(callNativeApi2),
      cookies: createCookiesApi(callNativeApi2),
      sessions: createSessionsApi(callNativeApi2),
      browsingData: createBrowsingDataApi(callNativeApi2),
      topSites: createTopSitesApi(callNativeApi2),
      // Advanced
      offscreen: createOffscreenApi(callNativeApi2),
      search: createSearchApi(callNativeApi2),
      tts: createTtsApi(callNativeApi2),
      idle: createIdleApi(callNativeApi2),
      power: createPowerApi(callNativeApi2),
      tabGroups: createTabGroupsApi(callNativeApi2),
      fontSettings: createFontSettingsApi(callNativeApi2)
    };
    return chrome;
  }
  function installChromePolyfill(config) {
    const chrome = createChromePolyfill(config);
    window.chrome = chrome;
    window.browser = chrome;
    console.log(`[AuroraView] Chrome API polyfill installed for extension: ${config.extensionId}`);
  }

  // src/inject/extensions/chrome_polyfill.ts
  (function() {
    if (!window.__AURORAVIEW__ || !window.__EXTENSION_ID__) {
      return;
    }
    const config = {
      extensionId: window.__EXTENSION_ID__,
      extensionPath: window.__EXTENSION_PATH__ || "",
      manifest: window.__EXTENSION_MANIFEST__ || {},
      messages: window.__EXTENSION_MESSAGES__ || {}
    };
    installChromePolyfill(config);
  })();

})();
