(function humanize() {
const body = document.body || document.documentElement;
if (!body) return;
const _markTrusted = (typeof globalThis.__bo_mark_trusted === 'function')
? globalThis.__bo_mark_trusted
: null;
try { delete globalThis.__bo_mark_trusted; } catch (_) {}
const _rand = globalThis[Symbol.for('__browser_oxide_behavior_rand__')]
|| Math.random;
const _sched = globalThis.__bgSetTimeout || globalThis.setTimeout;
if (!globalThis.__bo_input_events) {
Object.defineProperty(globalThis, '__bo_input_events', {
value: { mouse: [], key: [], touch: [], scroll: [], counters: { key: 0, mouse: 0, touch: 0, scroll: 0, accel: 0 } },
writable: true,
configurable: true,
enumerable: false,
});
}
const _akEvents = globalThis.__bo_input_events;
const _akT0 = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now();
function _akT() {
const now = (typeof performance !== 'undefined' && performance.now) ? performance.now() : Date.now();
return Math.round(now - _akT0);
}
function _akRecMouse(x, y, kind, button) {
if (_akEvents.mouse.length < 200) {
_akEvents.mouse.push({ x: x|0, y: y|0, t: _akT(), kind: kind|0, button: button|0 });
}
_akEvents.counters.mouse++;
}
function _akRecKey(code, kind) {
if (_akEvents.key.length < 200) {
_akEvents.key.push({ code: String(code), t: _akT(), kind: kind|0 });
}
_akEvents.counters.key++;
}
function _akRecScroll(dy) {
if (_akEvents.scroll.length < 100) {
_akEvents.scroll.push({ dy: dy|0, t: _akT() });
}
_akEvents.counters.scroll++;
}
function _dispatch(target, event) {
if (_markTrusted) _markTrusted(event);
target.dispatchEvent(event);
}
const _ksFn = globalThis[Symbol.for('__browser_oxide_keystroke_schedule__')];
if (typeof _ksFn === 'function') {
const _typedSym = Symbol.for('__browser_oxide_humanize_typed__');
document.addEventListener('focusin', function (e) {
try {
const t = e && e.target;
if (!t) return;
const tag = t.tagName;
if (tag !== 'INPUT' && tag !== 'TEXTAREA') return;
if (t[_typedSym]) return;
t[_typedSym] = true;
const schedule = _ksFn('hi', 50);
for (const slot of schedule) {
const key = slot.key, code = slot.code;
_sched(function () {
try {
const ev = new KeyboardEvent('keydown', {
key, code, bubbles: true, cancelable: true,
});
_dispatch(t, ev);
_akRecKey(code, 0);
} catch (_) {}
}, slot.down_ms | 0);
_sched(function () {
try {
const ev = new KeyboardEvent('keyup', {
key, code, bubbles: true, cancelable: true,
});
_dispatch(t, ev);
_akRecKey(code, 1);
} catch (_) {}
}, slot.up_ms | 0);
}
} catch (_e) {}
}, true);
}
function _gauss() {
let u = 0, v = 0;
while (u === 0) u = _rand();
while (v === 0) v = _rand();
return Math.sqrt(-2 * Math.log(u)) * Math.cos(2 * Math.PI * v);
}
function _lerp(a, b, t) {
return [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];
}
function _sigmaLognormalTimes(n, sigma) {
sigma = sigma || (0.22 + _rand() * 0.10);
const mu = -0.4;
const out = [];
for (let i = 0; i < n; i++) {
const q = (i + 0.5) / n;
const z = _normalQuantile(q);
const tau = Math.exp(mu + sigma * z);
out.push(tau);
}
const maxTau = Math.max(...out);
return out.map(x => x / maxTau);
}
function _normalQuantile(p) {
if (p <= 0) return -8;
if (p >= 1) return 8;
const a = [-3.969683028665376e+01, 2.209460984245205e+02,
-2.759285104469687e+02, 1.383577518672690e+02,
-3.066479806614716e+01, 2.506628277459239e+00];
const b = [-5.447609879822406e+01, 1.615858368580409e+02,
-1.556989798598866e+02, 6.680131188771972e+01,
-1.328068155288572e+01];
const c = [-7.784894002430293e-03, -3.223964580411365e-01,
-2.400758277161838e+00, -2.549732539343734e+00,
4.374664141464968e+00, 2.938163982698783e+00];
const d = [ 7.784695709041462e-03, 3.224671290700398e-01,
2.445134137142996e+00, 3.754408661907416e+00];
const plow = 0.02425, phigh = 1 - plow;
let q, r;
if (p < plow) {
q = Math.sqrt(-2 * Math.log(p));
return (((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /
((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1);
} else if (p <= phigh) {
q = p - 0.5;
r = q*q;
return (((((a[0]*r+a[1])*r+a[2])*r+a[3])*r+a[4])*r+a[5])*q /
(((((b[0]*r+b[1])*r+b[2])*r+b[3])*r+b[4])*r+1);
} else {
q = Math.sqrt(-2 * Math.log(1 - p));
return -(((((c[0]*q+c[1])*q+c[2])*q+c[3])*q+c[4])*q+c[5]) /
((((d[0]*q+d[1])*q+d[2])*q+d[3])*q+1);
}
}
function _fireMove(x, y, prev) {
const cx = Math.round(x), cy = Math.round(y);
const mx = prev ? Math.round(x - prev[0]) : 0;
const my = prev ? Math.round(y - prev[1]) : 0;
const mouseEv = new MouseEvent('mousemove', {
bubbles: true, cancelable: true, view: window,
clientX: cx, clientY: cy,
screenX: cx, screenY: cy + 90,
movementX: mx, movementY: my,
button: 0, buttons: 0,
});
try { _dispatch(window, mouseEv); } catch (_) {}
_dispatch(document, mouseEv);
_dispatch(body, mouseEv);
try {
const PE = (typeof PointerEvent === 'function') ? PointerEvent : null;
if (PE) {
const pEv = new PE('pointermove', {
bubbles: true, cancelable: true, view: window,
clientX: cx, clientY: cy,
screenX: cx, screenY: cy + 90,
movementX: mx, movementY: my,
button: -1, buttons: 0,
pointerType: 'mouse', pointerId: 1,
isPrimary: true, pressure: 0,
width: 1, height: 1,
});
try { _dispatch(window, pEv); } catch (_) {}
_dispatch(document, pEv);
_dispatch(body, pEv);
}
} catch (_) {}
_akRecMouse(x, y, 0, 0); }
function _fireScrollStep(deltaY) {
try {
const wheel = new WheelEvent('wheel', {
bubbles: true, cancelable: true, view: window,
deltaY, deltaMode: 0,
});
_dispatch(document, wheel);
window.scrollBy({ top: deltaY, behavior: 'instant' });
_dispatch(document, new Event('scroll', { bubbles: true }));
_dispatch(window, new Event('scroll', { bubbles: false }));
_akRecScroll(deltaY);
} catch (e) {}
}
function runCycle() {
try { _dispatch(window, new Event('focus', { bubbles: false })); } catch (e) {}
try { _dispatch(document, new Event('visibilitychange', { bubbles: true })); } catch (e) {}
const _vw = (window.innerWidth || 1920);
const _vh = (window.innerHeight || 1080);
const _ops = (typeof Deno !== 'undefined' && Deno.core && Deno.core.ops) || null;
let _from = (globalThis.__bo_input_events
&& Array.isArray(globalThis.__bo_input_events._lastPos)
&& globalThis.__bo_input_events._lastPos.length === 2)
? globalThis.__bo_input_events._lastPos.slice()
: [_vw * 0.5, _vh * 0.45];
const _nAnchors = 2 + (_rand() < 0.5 ? 0 : 1); let mouseT = 40 + _rand() * 40;
let prev = null;
for (let s = 0; s < _nAnchors; s++) {
const toX = 60 + _rand() * (_vw - 120);
const toY = 60 + _rand() * (_vh - 120);
const targetW = 28 + _rand() * 48;
let traj = [];
try {
if (_ops && typeof _ops.op_behavior_mouse_trajectory === 'function') {
const raw = _ops.op_behavior_mouse_trajectory(_from[0], _from[1], toX, toY, targetW);
traj = JSON.parse(raw || '[]');
}
} catch (_) {}
if (!Array.isArray(traj) || traj.length === 0) {
traj = [];
const n = 10;
for (let i = 0; i < n; i++) {
const u = i / (n - 1);
traj.push({ t_ms: u * 700, x: _from[0] + (toX - _from[0]) * u, y: _from[1] + (toY - _from[1]) * u });
}
}
const base = mouseT;
for (let i = 0; i < traj.length; i++) {
const p = traj[i];
const px = p.x, py = p.y;
const at = base + Math.round(p.t_ms || 0);
const prevSnapshot = prev ? prev.slice() : null;
_sched(() => _fireMove(px, py, prevSnapshot), at);
prev = [px, py];
}
const total = traj.length > 0 ? (traj[traj.length - 1].t_ms || 700) : 700;
mouseT = base + Math.round(total) + (50 + _rand() * 120); _from = [toX, toY];
}
if (globalThis.__bo_input_events) globalThis.__bo_input_events._lastPos = _from.slice();
const scStartT = mouseT + 100;
const steps = [80 + _rand() * 40, 60 + _rand() * 30];
let curScT = scStartT;
for (const step of steps) {
_sched(() => _fireScrollStep(step), curScT);
curScT += 100 + _rand() * 100;
}
}
(function _seedHistoricalCoords() {
const vw = (window.innerWidth || 1920);
const vh = (window.innerHeight || 1080);
const fromX = vw * 0.5 + (_rand() - 0.5) * 80;
const fromY = vh * 0.4 + (_rand() - 0.5) * 80;
const toX = vw * 0.45 + (_rand() - 0.5) * 200;
const toY = vh * 0.55 + (_rand() - 0.5) * 200;
const targetW = 40 + _rand() * 40;
let traj = [];
try {
const ops = Deno && Deno.core && Deno.core.ops;
if (ops && typeof ops.op_behavior_mouse_trajectory === 'function') {
const raw = ops.op_behavior_mouse_trajectory(fromX, fromY, toX, toY, targetW);
traj = JSON.parse(raw || '[]');
}
} catch (_) {}
if (!Array.isArray(traj) || traj.length === 0) {
traj = [];
const n = 12;
for (let i = 0; i < n; i++) {
const u = i / (n - 1);
traj.push({
t_ms: u * 1000,
x: fromX + (toX - fromX) * u,
y: fromY + (toY - fromY) * u,
});
}
}
const maxT = traj.length > 0 ? traj[traj.length - 1].t_ms : 1;
const stride = Math.max(1, Math.ceil(traj.length / 14));
let lastX = fromX | 0, lastY = fromY | 0;
for (let i = 0; i < traj.length; i += stride) {
const p = traj[i];
const u = p.t_ms / Math.max(1, maxT);
const dt = -1800 + u * 1700;
const x = Math.max(0, Math.min(vw, p.x)) | 0;
const y = Math.max(0, Math.min(vh, p.y)) | 0;
if (_akEvents.mouse.length < 200) {
_akEvents.mouse.push({
x: x, y: y, t: Math.round(dt),
kind: 0, button: 0,
});
}
_akEvents.counters.mouse++;
lastX = x; lastY = y;
}
try {
const evOpts = {
bubbles: true, cancelable: true, view: window,
clientX: lastX, clientY: lastY,
screenX: lastX, screenY: lastY + 90,
movementX: 1, movementY: 0,
button: 0, buttons: 0,
};
const mev = new MouseEvent('mousemove', evOpts);
if (_markTrusted) _markTrusted(mev);
try { window.dispatchEvent(mev); } catch (_) {}
try { document.dispatchEvent(mev); } catch (_) {}
try { body.dispatchEvent(mev); } catch (_) {}
const PE = (typeof PointerEvent === 'function') ? PointerEvent : null;
if (PE) {
const pev = new PE('pointermove', {
...evOpts,
button: -1,
pointerType: 'mouse', pointerId: 1,
isPrimary: true, pressure: 0, width: 1, height: 1,
});
if (_markTrusted) _markTrusted(pev);
try { window.dispatchEvent(pev); } catch (_) {}
try { document.dispatchEvent(pev); } catch (_) {}
try { body.dispatchEvent(pev); } catch (_) {}
}
} catch (_) {}
try {
globalThis.__bo_input_events._lastPos = [lastX, lastY];
} catch (_) {}
})();
runCycle();
setInterval(runCycle, 4000);
})();