"use strict";
if (!window.__browserAgentContentScriptLoaded) {
    window.__browserAgentContentScriptLoaded = true;
    chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
        handleContentMessage(message)
            .then(sendResponse)
            .catch((error) => sendResponse({ ok: false, error: BrowserAgent.normalizeError(error) }));
        return true;
    });
}
async function handleContentMessage(message) {
    switch (message.type) {
        case "PING":
            return { ok: true };
        case "GET_PAGE_SNAPSHOT":
            return { ok: true, snapshot: buildPageSnapshot(message.payload?.maxTextChars || BrowserAgent.DEFAULT_CONFIG.maxDomTextChars) };
        case "SHOW_TOAST":
            showToast(String(message.payload?.message || "Browser Agent action"));
            return { ok: true };
        case "EXECUTE_ACTION":
            return {
                ok: true,
                result: await executePageAction(message.payload?.action, message.payload?.maxTextChars || BrowserAgent.DEFAULT_CONFIG.maxDomTextChars)
            };
        case "EXECUTE_SKILL":
            return await executeSkill(message.payload?.js || "", message.payload?.parameters || {});
        default:
            return { ok: false, error: { code: "UNKNOWN_CONTENT_MESSAGE", message: `Unknown content message: ${message.type}` } };
    }
}
function buildPageSnapshot(maxTextChars) {
    const fullVisibleText = normalizeWhitespace(document.body?.innerText || "");
    const truncated = BrowserAgent.truncateText(fullVisibleText, maxTextChars);
    const interactiveElements = collectInteractiveElements();
    window.__browserAgentInteractiveElements = interactiveElements;
    const links = collectLinks();
    const forms = collectForms();
    const tables = collectTables();
    const documentElement = document.documentElement;
    return {
        url: location.href,
        title: document.title,
        viewport: {
            width: window.innerWidth,
            height: window.innerHeight,
            devicePixelRatio: window.devicePixelRatio
        },
        scroll: {
            x: window.scrollX,
            y: window.scrollY,
            maxY: Math.max(0, documentElement.scrollHeight - window.innerHeight)
        },
        selection: getSelectionText(),
        focusedElement: document.activeElement instanceof HTMLElement ? summarizeElement(document.activeElement, -1) : null,
        textChunks: splitTextChunks(truncated.text),
        visibleText: truncated.text,
        interactiveElements: interactiveElements.map((element, index) => summarizeElement(element, index)),
        links,
        forms,
        tables,
        metadata: {
            totalTextChars: fullVisibleText.length,
            includedTextChars: truncated.text.length,
            interactiveElementCount: interactiveElements.length,
            linkCount: links.length,
            formCount: forms.length,
            tableCount: tables.length,
            truncated: truncated.truncated,
            truncationReason: truncated.truncated ? `Visible text exceeded ${maxTextChars} characters.` : undefined
        }
    };
}
async function executePageAction(action, maxTextChars) {
    const startedAt = BrowserAgent.nowIso();
    const startedTime = performance.now();
    if (!action) {
        return withTiming({ ok: false, message: "Action is missing.", error: { code: "ACTION_MISSING", message: "Action is missing." } }, startedAt, startedTime);
    }
    const actionId = BrowserAgent.actionId(action);
    try {
        let result;
        switch (action.type) {
            case "getPageSnapshot":
                result = { ok: true, actionId, message: "Captured page snapshot.", data: buildPageSnapshot(maxTextChars) };
                break;
            case "getSelection":
                result = { ok: true, actionId, message: "Read selected text.", data: { selection: getSelectionText() } };
                break;
            case "getVisibleText":
                result = { ok: true, actionId, message: "Read visible text.", data: { text: buildPageSnapshot(maxTextChars).visibleText } };
                break;
            case "getLinks":
                result = { ok: true, actionId, message: "Read links.", data: { links: collectLinks() } };
                break;
            case "getForms":
                result = { ok: true, actionId, message: "Read forms.", data: { forms: collectForms() } };
                break;
            case "getTables":
                result = { ok: true, actionId, message: "Read tables.", data: { tables: collectTables() } };
                break;
            case "click":
                result = await clickAction(action, actionId);
                break;
            case "type":
                result = await typeAction(action, actionId);
                break;
            case "pressKey":
                result = await pressKeyAction(action, actionId);
                break;
            case "scroll":
                result = await scrollAction(action, actionId);
                break;
            case "selectText":
                result = await selectTextAction(action, actionId);
                break;
            case "copyToClipboard":
                result = await copyAction(action, actionId, maxTextChars);
                break;
            case "waitForElement":
                result = await waitForElementAction(action, actionId);
                break;
            default:
                result = { ok: false, actionId, message: `Unsupported in-page action: ${action.type}` };
        }
        return withTiming(result, startedAt, startedTime);
    }
    catch (error) {
        const normalized = BrowserAgent.normalizeError(error, "PAGE_ACTION_FAILED");
        await animateFailure(action.target);
        return withTiming({ ok: false, actionId, message: normalized.message, error: normalized }, startedAt, startedTime);
    }
}
async function clickAction(action, actionId) {
    const element = resolveTarget(action.target);
    ensureElement(element, "Click target was not found.");
    ensureHTMLElement(element);
    element.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
    await wait(180);
    const animation = await animateElement(element, "click", action.target);
    element.click();
    return { ok: true, actionId, message: elementLabel(element, "Clicked element."), targetRect: animation.rect, animation };
}
async function typeAction(action, actionId) {
    const element = resolveTarget(action.target) || document.activeElement;
    ensureElement(element, "Type target was not found.");
    ensureHTMLElement(element);
    const text = String(action.args?.text ?? "");
    const mode = String(action.args?.mode || "replace");
    element.scrollIntoView({ behavior: "smooth", block: "center", inline: "center" });
    element.focus();
    await wait(120);
    const animation = await animateElement(element, "type", action.target);
    if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
        if (mode === "append") {
            element.value += text;
        }
        else {
            element.value = text;
        }
        element.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertText", data: text }));
        element.dispatchEvent(new Event("change", { bubbles: true }));
        return { ok: true, actionId, message: `Typed ${text.length} characters.`, targetRect: animation.rect, animation };
    }
    if (element instanceof HTMLElement && element.isContentEditable) {
        if (mode === "append") {
            element.textContent = `${element.textContent || ""}${text}`;
        }
        else {
            element.textContent = text;
        }
        element.dispatchEvent(new InputEvent("input", { bubbles: true, inputType: "insertText", data: text }));
        return { ok: true, actionId, message: `Typed ${text.length} characters into editable content.`, targetRect: animation.rect, animation };
    }
    throw new Error("Target is not editable.");
}
async function pressKeyAction(action, actionId) {
    const key = String(action.args?.key || "");
    if (!key) {
        throw new Error("pressKey requires args.key.");
    }
    const target = resolveTarget(action.target) || document.activeElement || document.body;
    ensureElement(target, "Key target was not found.");
    const animation = target instanceof Element ? await animateElement(target, "highlight", action.target) : undefined;
    const eventInit = { key, bubbles: true, cancelable: true };
    target.dispatchEvent(new KeyboardEvent("keydown", eventInit));
    target.dispatchEvent(new KeyboardEvent("keyup", eventInit));
    return { ok: true, actionId, message: `Pressed ${key}.`, targetRect: animation?.rect, animation };
}
async function scrollAction(action, actionId) {
    const amount = Number(action.args?.amount ?? 700);
    const direction = String(action.args?.direction || "down");
    const multiplier = direction === "up" || direction === "left" ? -1 : 1;
    const horizontal = direction === "left" || direction === "right";
    const element = action.target ? resolveTarget(action.target) : null;
    if (element instanceof HTMLElement) {
        await animateElement(element, "scroll", action.target);
        element.scrollBy({ top: horizontal ? 0 : amount * multiplier, left: horizontal ? amount * multiplier : 0, behavior: "smooth" });
    }
    else {
        showToast(`Scrolling ${direction}`);
        animateScrollTrail(direction);
        window.scrollBy({ top: horizontal ? 0 : amount * multiplier, left: horizontal ? amount * multiplier : 0, behavior: "smooth" });
    }
    return {
        ok: true,
        actionId,
        message: `Scrolled ${direction} by ${amount}px.`,
        animation: { type: "scroll", durationMs: 650, target: action.target }
    };
}
async function selectTextAction(action, actionId) {
    const element = resolveTarget(action.target) || document.body;
    ensureElement(element, "Selection target was not found.");
    const range = document.createRange();
    range.selectNodeContents(element);
    const selection = window.getSelection();
    selection?.removeAllRanges();
    selection?.addRange(range);
    const animation = await animateElement(element, "select", action.target);
    return { ok: true, actionId, message: "Selected target text.", data: { selection: getSelectionText() }, targetRect: animation.rect, animation };
}
async function copyAction(action, actionId, maxTextChars) {
    const source = String(action.args?.source || "");
    const text = String(action.args?.text || (source === "selection" ? getSelectionText()
        : source === "visibleText" ? buildPageSnapshot(maxTextChars).visibleText
            : getSelectionText() || buildPageSnapshot(maxTextChars).visibleText));
    if (!text) {
        throw new Error("Nothing to copy.");
    }
    await writeClipboard(text);
    showToast(`Copied ${text.length} characters`);
    return {
        ok: true,
        actionId,
        message: `Copied ${text.length} characters to clipboard.`,
        data: { chars: text.length },
        animation: { type: "toast", durationMs: 1800 }
    };
}
async function waitForElementAction(action, actionId) {
    const timeoutMs = Number(action.args?.timeoutMs || 8000);
    const startedAt = Date.now();
    while (Date.now() - startedAt < timeoutMs) {
        const element = resolveTarget(action.target);
        if (element) {
            const animation = await animateElement(element, "wait", action.target);
            return { ok: true, actionId, message: "Element is available.", data: summarizeElement(element, -1), targetRect: animation.rect, animation };
        }
        await new Promise((resolve) => setTimeout(resolve, 250));
    }
    throw new Error(`Timed out waiting for element after ${timeoutMs}ms.`);
}
function withTiming(result, startedAt, startedTime) {
    const endedAt = BrowserAgent.nowIso();
    return {
        ...result,
        startedAt,
        endedAt,
        durationMs: Math.round(performance.now() - startedTime)
    };
}
function resolveTarget(target) {
    if (!target) {
        return null;
    }
    if (typeof target.index === "number") {
        const elements = window.__browserAgentInteractiveElements || collectInteractiveElements();
        if (elements[target.index]) {
            return elements[target.index];
        }
    }
    if (target.selector) {
        const element = document.querySelector(target.selector);
        if (element) {
            return element;
        }
    }
    if (target.coordinates) {
        const element = document.elementFromPoint(target.coordinates.x, target.coordinates.y);
        if (element) {
            return element;
        }
    }
    const textTarget = normalizeWhitespace(target.text || target.name || "");
    if (textTarget) {
        const candidates = collectInteractiveElements().concat(Array.from(document.querySelectorAll("h1,h2,h3,p,span,div,label,td,th")));
        return candidates.find((element) => normalizeWhitespace(elementText(element)).includes(textTarget)) || null;
    }
    return null;
}
function collectInteractiveElements() {
    const selector = [
        "a[href]",
        "button",
        "input",
        "textarea",
        "select",
        "summary",
        "[role='button']",
        "[role='link']",
        "[role='menuitem']",
        "[contenteditable='true']",
        "[tabindex]:not([tabindex='-1'])",
        "[onclick]"
    ].join(",");
    return Array.from(document.querySelectorAll(selector))
        .filter(isElementVisible)
        .slice(0, 160);
}
function collectLinks() {
    return Array.from(document.querySelectorAll("a[href]"))
        .filter(isElementVisible)
        .slice(0, 120)
        .map((element, index) => ({
        index,
        selector: stableSelector(element),
        text: normalizeWhitespace(element.innerText || element.textContent || ""),
        href: element.href
    }));
}
function collectForms() {
    return Array.from(document.querySelectorAll("form"))
        .slice(0, 25)
        .map((form, index) => ({
        index,
        selector: stableSelector(form),
        fields: Array.from(form.querySelectorAll("input,textarea,select"))
            .slice(0, 60)
            .map((field) => ({
            selector: stableSelector(field),
            name: field.name || field.id || "",
            type: field instanceof HTMLInputElement ? field.type : field.tagName.toLowerCase(),
            label: labelFor(field),
            value: field.value || ""
        }))
    }));
}
function collectTables() {
    return Array.from(document.querySelectorAll("table"))
        .slice(0, 20)
        .map((table, index) => {
        const headers = Array.from(table.querySelectorAll("thead th, tr:first-child th"))
            .map((cell) => normalizeWhitespace(cell.textContent || ""))
            .filter(Boolean);
        const rows = Array.from(table.querySelectorAll("tbody tr, tr"))
            .slice(headers.length ? 0 : 1, 25)
            .map((row) => Array.from(row.querySelectorAll("th,td")).map((cell) => normalizeWhitespace(cell.textContent || "")));
        return {
            index,
            selector: stableSelector(table),
            caption: normalizeWhitespace(table.querySelector("caption")?.textContent || ""),
            headers,
            rows
        };
    });
}
function summarizeElement(element, index) {
    const htmlElement = element instanceof HTMLElement ? element : null;
    const rect = element.getBoundingClientRect();
    const input = element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement || element instanceof HTMLSelectElement ? element : null;
    const anchor = element instanceof HTMLAnchorElement ? element : null;
    return {
        index,
        selector: stableSelector(element),
        tag: element.tagName.toLowerCase(),
        role: element.getAttribute("role") || inferredRole(element),
        name: accessibleName(element),
        text: normalizeWhitespace(elementText(element)).slice(0, 240),
        value: input?.value,
        placeholder: input && "placeholder" in input ? input.placeholder : undefined,
        href: anchor?.href,
        visible: isElementVisible(element),
        disabled: Boolean(element.disabled || element.getAttribute("aria-disabled") === "true"),
        rect: {
            x: Math.round(rect.x),
            y: Math.round(rect.y),
            width: Math.round(rect.width),
            height: Math.round(rect.height)
        }
    };
}
function stableSelector(element) {
    if (element.id) {
        return `#${cssEscape(element.id)}`;
    }
    const testId = element.getAttribute("data-testid") || element.getAttribute("data-test");
    if (testId) {
        return `[data-testid="${escapeAttribute(testId)}"]`;
    }
    const name = element.getAttribute("name");
    if (name) {
        return `${element.tagName.toLowerCase()}[name="${escapeAttribute(name)}"]`;
    }
    const aria = element.getAttribute("aria-label");
    if (aria) {
        return `${element.tagName.toLowerCase()}[aria-label="${escapeAttribute(aria)}"]`;
    }
    const parts = [];
    let current = element;
    while (current && current !== document.body && parts.length < 5) {
        const parent = current.parentElement;
        const tag = current.tagName.toLowerCase();
        const currentTag = current.tagName;
        if (!parent) {
            parts.unshift(tag);
            break;
        }
        const siblings = Array.from(parent.children).filter((child) => child.tagName === currentTag);
        const index = siblings.indexOf(current) + 1;
        parts.unshift(`${tag}:nth-of-type(${index})`);
        current = parent;
    }
    return parts.length ? parts.join(" > ") : element.tagName.toLowerCase();
}
function cssEscape(value) {
    if ("CSS" in window && typeof CSS.escape === "function") {
        return CSS.escape(value);
    }
    return value.replace(/[^a-zA-Z0-9_-]/g, "\\$&");
}
function escapeAttribute(value) {
    return value.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
}
function isElementVisible(element) {
    if (!(element instanceof HTMLElement)) {
        return false;
    }
    const rect = element.getBoundingClientRect();
    const style = getComputedStyle(element);
    return rect.width > 0 && rect.height > 0 && style.visibility !== "hidden" && style.display !== "none" && Number(style.opacity || 1) > 0;
}
function accessibleName(element) {
    const aria = element.getAttribute("aria-label");
    if (aria) {
        return normalizeWhitespace(aria);
    }
    const labelledBy = element.getAttribute("aria-labelledby");
    if (labelledBy) {
        return labelledBy
            .split(/\s+/)
            .map((id) => document.getElementById(id)?.textContent || "")
            .join(" ")
            .trim();
    }
    return labelFor(element) || normalizeWhitespace(elementText(element)).slice(0, 120);
}
function labelFor(element) {
    if (!(element instanceof HTMLElement)) {
        return "";
    }
    if (element.id) {
        const label = document.querySelector(`label[for="${escapeAttribute(element.id)}"]`);
        if (label?.textContent) {
            return normalizeWhitespace(label.textContent);
        }
    }
    const wrappingLabel = element.closest("label");
    return normalizeWhitespace(wrappingLabel?.textContent || "");
}
function inferredRole(element) {
    const tag = element.tagName.toLowerCase();
    if (tag === "a")
        return "link";
    if (tag === "button")
        return "button";
    if (["input", "textarea", "select"].includes(tag))
        return "field";
    if (element instanceof HTMLElement && element.isContentEditable)
        return "textbox";
    return tag;
}
function elementText(element) {
    if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
        return element.value || element.placeholder || element.getAttribute("aria-label") || "";
    }
    if (element instanceof HTMLSelectElement) {
        return element.value || element.getAttribute("aria-label") || "";
    }
    return element.textContent || "";
}
function normalizeWhitespace(text) {
    return text.replace(/\s+/g, " ").trim();
}
function splitTextChunks(text) {
    return text
        .split(/(?<=[.!?])\s+|\n+/)
        .map((chunk) => chunk.trim())
        .filter(Boolean)
        .slice(0, 80);
}
function getSelectionText() {
    return window.getSelection()?.toString() || "";
}
function ensureElement(element, message) {
    if (!element) {
        throw new Error(message);
    }
}
function ensureHTMLElement(element) {
    if (!(element instanceof HTMLElement)) {
        throw new Error("Target is not an HTML element.");
    }
}
async function writeClipboard(text) {
    if (navigator.clipboard?.writeText) {
        await navigator.clipboard.writeText(text);
        return;
    }
    const textarea = document.createElement("textarea");
    textarea.value = text;
    textarea.style.position = "fixed";
    textarea.style.opacity = "0";
    document.body.appendChild(textarea);
    textarea.select();
    const copied = document.execCommand("copy");
    textarea.remove();
    if (!copied) {
        throw new Error("Clipboard write failed.");
    }
}
function elementLabel(element, fallback) {
    const label = accessibleName(element);
    return label ? `${fallback} (${label})` : fallback;
}
async function animateElement(element, type, target) {
    ensureOverlayStyles();
    const rect = rectFromElement(element);
    const durationMs = type === "wait" ? 900 : type === "scroll" ? 650 : 720;
    const overlay = document.createElement("div");
    overlay.className = `browser-agent-overlay browser-agent-${type}`;
    Object.assign(overlay.style, {
        left: `${rect.x}px`,
        top: `${rect.y}px`,
        width: `${Math.max(rect.width, 12)}px`,
        height: `${Math.max(rect.height, 12)}px`
    });
    document.documentElement.appendChild(overlay);
    window.setTimeout(() => overlay.remove(), durationMs + 100);
    await wait(Math.min(durationMs, 420));
    return { type, durationMs, target, rect };
}
async function animateFailure(target) {
    const element = resolveTarget(target);
    if (element) {
        await animateElement(element, "failure", target);
        return;
    }
    showToast("Action failed", "failure");
}
function animateScrollTrail(direction) {
    ensureOverlayStyles();
    const trail = document.createElement("div");
    trail.className = "browser-agent-scroll-trail";
    trail.textContent = direction === "up" ? "↑" : direction === "left" ? "←" : direction === "right" ? "→" : "↓";
    document.documentElement.appendChild(trail);
    window.setTimeout(() => trail.remove(), 900);
}
function showToast(message, tone = "info") {
    ensureOverlayStyles();
    const toast = document.createElement("div");
    toast.className = `browser-agent-toast browser-agent-toast-${tone}`;
    toast.textContent = message;
    document.documentElement.appendChild(toast);
    window.setTimeout(() => toast.remove(), 2200);
}
function rectFromElement(element) {
    const rect = element.getBoundingClientRect();
    return {
        x: Math.round(rect.x),
        y: Math.round(rect.y),
        width: Math.round(rect.width),
        height: Math.round(rect.height)
    };
}
async function executeSkill(js, parameters) {
    if (!js) {
        return { ok: false, error: { code: "SKILL_EMPTY", message: "No JS code provided for skill execution." } };
    }
    const startedAt = performance.now();
    try {
        // Create a function from the JS string that has access to `params`
        const wrappedCode = `(function() { var params = ${JSON.stringify(parameters)}; return ${js} })()`;
        const result = eval(wrappedCode);
        // If the skill returns a promise, await it
        const resolvedResult = result instanceof Promise ? await result : result;
        const durationMs = Math.round(performance.now() - startedAt);
        return {
            ok: true,
            result: {
                ok: resolvedResult?.ok !== false,
                data: resolvedResult,
                tabUrl: location.href,
                durationMs
            }
        };
    }
    catch (error) {
        const durationMs = Math.round(performance.now() - startedAt);
        const message = error instanceof Error ? error.message : String(error);
        const stack = error instanceof Error ? error.stack : undefined;
        return {
            ok: false,
            result: {
                ok: false,
                tabUrl: location.href,
                durationMs,
                error: { code: "SKILL_RUNTIME_ERROR", message, stack }
            }
        };
    }
}
function wait(ms) {
    return new Promise((resolve) => window.setTimeout(resolve, ms));
}
function ensureOverlayStyles() {
    if (document.getElementById("browser-agent-overlay-styles")) {
        return;
    }
    const style = document.createElement("style");
    style.id = "browser-agent-overlay-styles";
    style.textContent = `
    .browser-agent-overlay {
      position: fixed;
      z-index: 2147483647;
      pointer-events: none;
      border: 3px solid #10b981;
      border-radius: 8px;
      box-shadow: 0 0 0 9999px rgba(16, 185, 129, 0.045), 0 0 24px rgba(16, 185, 129, 0.85);
      animation: browser-agent-pulse 720ms ease-out forwards;
    }
    .browser-agent-click::after {
      content: "";
      position: absolute;
      left: 50%;
      top: 50%;
      width: 18px;
      height: 18px;
      border-radius: 50%;
      background: rgba(20, 184, 166, 0.45);
      transform: translate(-50%, -50%);
      animation: browser-agent-ripple 680ms ease-out forwards;
    }
    .browser-agent-type {
      border-color: #2563eb;
      box-shadow: 0 0 0 9999px rgba(37, 99, 235, 0.035), 0 0 22px rgba(37, 99, 235, 0.8);
    }
    .browser-agent-select {
      border-color: #a21caf;
      box-shadow: 0 0 0 9999px rgba(162, 28, 175, 0.035), 0 0 22px rgba(162, 28, 175, 0.8);
    }
    .browser-agent-scroll {
      border-color: #f59e0b;
      box-shadow: 0 0 0 9999px rgba(245, 158, 11, 0.035), 0 0 22px rgba(245, 158, 11, 0.8);
    }
    .browser-agent-wait {
      border-style: dashed;
      animation: browser-agent-wait 900ms linear forwards;
    }
    .browser-agent-failure {
      border-color: #dc2626;
      box-shadow: 0 0 0 9999px rgba(220, 38, 38, 0.04), 0 0 22px rgba(220, 38, 38, 0.85);
      animation: browser-agent-shake 520ms ease-in-out forwards;
    }
    .browser-agent-toast {
      position: fixed;
      right: 18px;
      bottom: 18px;
      z-index: 2147483647;
      max-width: min(360px, calc(100vw - 36px));
      padding: 10px 12px;
      border-radius: 8px;
      background: #10231e;
      color: #ffffff;
      font: 700 13px/1.35 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
      animation: browser-agent-toast 2200ms ease forwards;
      pointer-events: none;
    }
    .browser-agent-toast-failure {
      background: #7f1d1d;
    }
    .browser-agent-scroll-trail {
      position: fixed;
      left: 50%;
      top: 50%;
      z-index: 2147483647;
      width: 58px;
      height: 58px;
      display: grid;
      place-items: center;
      border-radius: 50%;
      transform: translate(-50%, -50%);
      background: rgba(15, 23, 42, 0.86);
      color: #ffffff;
      font: 800 30px/1 system-ui, sans-serif;
      pointer-events: none;
      animation: browser-agent-scroll-trail 900ms ease-out forwards;
    }
    @keyframes browser-agent-pulse {
      0% { opacity: 0; transform: scale(0.96); }
      18% { opacity: 1; transform: scale(1.02); }
      100% { opacity: 0; transform: scale(1.08); }
    }
    @keyframes browser-agent-ripple {
      0% { opacity: 0.75; transform: translate(-50%, -50%) scale(0.4); }
      100% { opacity: 0; transform: translate(-50%, -50%) scale(4.4); }
    }
    @keyframes browser-agent-wait {
      0% { opacity: 1; transform: scale(0.98) rotate(0deg); }
      100% { opacity: 0; transform: scale(1.04) rotate(12deg); }
    }
    @keyframes browser-agent-shake {
      0%, 100% { opacity: 0; transform: translateX(0); }
      12%, 84% { opacity: 1; }
      25% { transform: translateX(-7px); }
      50% { transform: translateX(7px); }
      75% { transform: translateX(-4px); }
    }
    @keyframes browser-agent-toast {
      0% { opacity: 0; transform: translateY(8px); }
      12%, 82% { opacity: 1; transform: translateY(0); }
      100% { opacity: 0; transform: translateY(8px); }
    }
    @keyframes browser-agent-scroll-trail {
      0% { opacity: 0; transform: translate(-50%, -42%) scale(0.85); }
      20%, 70% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
      100% { opacity: 0; transform: translate(-50%, -58%) scale(1.1); }
    }
  `;
    document.documentElement.appendChild(style);
}
//# sourceMappingURL=content-script.js.map