(() => {
  var __create = Object.create;
  var __defProp = Object.defineProperty;
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
  var __getOwnPropNames = Object.getOwnPropertyNames;
  var __getProtoOf = Object.getPrototypeOf;
  var __hasOwnProp = Object.prototype.hasOwnProperty;
  var __commonJS = (cb, mod) => function __require() {
    return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
  };
  var __copyProps = (to, from, except, desc) => {
    if (from && typeof from === "object" || typeof from === "function") {
      for (let key of __getOwnPropNames(from))
        if (!__hasOwnProp.call(to, key) && key !== except)
          __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
    }
    return to;
  };
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
    // If the importer is in node compatibility mode or this is not an ESM
    // file that has been converted to a CommonJS file using a Babel-
    // compatible transform (i.e. "__esModule" has not been set), then set
    // "default" to the CommonJS "module.exports" for node compatibility.
    isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
    mod
  ));

  // src/shared/version.js
  var require_version = __commonJS({
    "src/shared/version.js"(exports, module) {
      (function attachBuildIdentity(root, factory) {
        const api = factory();
        if (typeof module === "object" && module.exports) module.exports = api;
        root.TfaBuildIdentity = api;
      })(typeof globalThis === "object" ? globalThis : exports, function createBuildIdentity() {
        "use strict";
        const EXTENSION_VERSION = "1.25.34";
        const injectedFingerprint = true ? "ad6e691b8aca11ed33afdee80003f6267e631e774c668aa45122b2917e7c7890" : "";
        const fingerprint = injectedFingerprint || `source:${EXTENSION_VERSION}`;
        return Object.freeze({ version: EXTENSION_VERSION, fingerprint });
      });
    }
  });

  // src/page-world/runtime.js
  var require_runtime = __commonJS({
    "src/page-world/runtime.js"() {
      (() => {
        "use strict";
        const build = globalThis.TfaBuildIdentity || {};
        const injectedFingerprint = true ? "ad6e691b8aca11ed33afdee80003f6267e631e774c668aa45122b2917e7c7890" : "";
        const fingerprint = String(injectedFingerprint || build.fingerprint || `legacy:${build.version || "unknown"}`);
        const OWNER_KEY = Symbol.for("tfa.page-world-runtime.v1.owner");
        const previousOwner = window[OWNER_KEY] || window.__TFA_PAGE_WORLD_LOCK__;
        if (previousOwner) {
          if (previousOwner.fingerprint === fingerprint && previousOwner.state === "active") return;
          if (typeof previousOwner.dispose !== "function") return;
          previousOwner.dispose();
        }
        const ownerRecord = {
          fingerprint,
          generation: Math.max(0, Number(previousOwner?.generation) || 0) + 1,
          state: "booting",
          dispose: null
        };
        window[OWNER_KEY] = ownerRecord;
        window.__TFA_PAGE_WORLD_LOCK__ = ownerRecord;
        const ALT_CODES = ["AltLeft", "AltRight"];
        const DETAIL_KEY = "__tfaAltKeyboardLock";
        let activeOwner = "";
        let lockEpoch = 0;
        const isCurrent = () => ownerRecord.state === "active" && window[OWNER_KEY] === ownerRecord;
        function emit(type, owner = "", detail = {}) {
          window.dispatchEvent(new CustomEvent("__TFA_ALT_LOCK_RESULT__", {
            detail: { type, owner, ...detail }
          }));
        }
        async function reconcilePhysicalState(observedEpoch) {
          if (!isCurrent()) return;
          if (observedEpoch === lockEpoch) return;
          const desiredEpoch = lockEpoch;
          const desiredOwner = activeOwner;
          const keyboard = navigator.keyboard;
          if (!keyboard) return;
          if (!desiredOwner) {
            try {
              keyboard.unlock?.();
            } catch (error) {
            }
            return;
          }
          if (typeof keyboard.lock !== "function") return;
          try {
            await keyboard.lock(ALT_CODES);
          } catch (error) {
            if (!isCurrent()) return;
            if (desiredEpoch !== lockEpoch || activeOwner !== desiredOwner) {
              await reconcilePhysicalState(desiredEpoch);
              return;
            }
            try {
              await keyboard.lock();
            } catch (fallbackError) {
            }
          }
          if (!isCurrent()) return;
          if (desiredEpoch !== lockEpoch || activeOwner !== desiredOwner) {
            await reconcilePhysicalState(desiredEpoch);
          }
        }
        async function lockAlt(owner) {
          const epoch = ++lockEpoch;
          activeOwner = owner;
          const keyboard = navigator.keyboard;
          if (!window.isSecureContext || !keyboard || typeof keyboard.lock !== "function") {
            if (epoch === lockEpoch && activeOwner === owner) emit("unsupported", owner);
            return;
          }
          try {
            await keyboard.lock(ALT_CODES);
            if (!isCurrent()) return;
            if (epoch === lockEpoch && activeOwner === owner) emit("locked", owner, { mode: "alt" });
            else await reconcilePhysicalState(epoch);
          } catch (error) {
            if (!isCurrent()) return;
            if (epoch !== lockEpoch || activeOwner !== owner) {
              await reconcilePhysicalState(epoch);
              return;
            }
            try {
              await keyboard.lock();
              if (!isCurrent()) return;
              if (epoch === lockEpoch && activeOwner === owner) emit("locked", owner, { mode: "all" });
              else await reconcilePhysicalState(epoch);
              return;
            } catch (fallbackError) {
              if (!isCurrent()) return;
              error = fallbackError;
            }
            if (epoch !== lockEpoch || activeOwner !== owner) {
              await reconcilePhysicalState(epoch);
              return;
            }
            emit("error", owner, {
              name: error && error.name ? error.name : "",
              message: error && error.message ? error.message : ""
            });
          }
        }
        function unlockAlt(owner) {
          if (!isCurrent() || !owner || activeOwner !== owner) return false;
          lockEpoch += 1;
          activeOwner = "";
          const keyboard = navigator.keyboard;
          if (!keyboard || typeof keyboard.unlock !== "function") return true;
          try {
            keyboard.unlock();
          } catch (error) {
          }
          return true;
        }
        function handleLockRequest(event) {
          if (!isCurrent()) return;
          const detail = event && event.detail ? event.detail : {};
          if (!detail || detail.key !== DETAIL_KEY) return;
          if (detail.action === "probe") {
            emit("ready", detail.owner || "");
            return;
          }
          if (detail.action === "lock") {
            if (!detail.owner) return;
            lockAlt(detail.owner);
            return;
          }
          if (detail.action === "unlock") {
            if (unlockAlt(detail.owner)) emit("unlocked", detail.owner);
          }
        }
        function dispose() {
          if (ownerRecord.state === "disposed") return false;
          ownerRecord.state = "disposed";
          lockEpoch += 1;
          activeOwner = "";
          window.removeEventListener("__TFA_ALT_LOCK_REQUEST__", handleLockRequest, true);
          try {
            navigator.keyboard?.unlock?.();
          } catch (error) {
          }
          if (window[OWNER_KEY] === ownerRecord) delete window[OWNER_KEY];
          if (window.__TFA_PAGE_WORLD_LOCK__ === ownerRecord) delete window.__TFA_PAGE_WORLD_LOCK__;
          return true;
        }
        ownerRecord.dispose = dispose;
        window.addEventListener("__TFA_ALT_LOCK_REQUEST__", handleLockRequest, true);
        ownerRecord.state = "active";
        emit("ready");
      })();
    }
  });

  // src/page-world/index.js
  var require_index = __commonJS({
    "src/page-world/index.js"() {
      var import_version = __toESM(require_version());
      var import_runtime = __toESM(require_runtime());
    }
  });
  require_index();
})();
