/* BasedMTA shared ImGui components. Babel-transpiled. */
/* All names prefixed with Bmta to avoid global collisions when embedded. */
const { useState, useRef, useEffect, useCallback, useMemo } = React;
// ---------- Icon: tiny check tick ----------
function BmtaCheckIcon({ size = 10 }) {
return (
);
}
// ---------- Checkbox ----------
function BmtaCheck({ checked, onChange, label, disabled }) {
return (
);
}
// ---------- Radio (single in a group) ----------
function BmtaRadio({ checked, onChange, label }) {
return (
);
}
// ---------- Button ----------
function BmtaButton({ children, onClick, variant, wide, disabled, style }) {
const cls = ["bmta-btn"];
if (variant) cls.push(variant);
if (wide) cls.push("wide");
return (
);
}
// ---------- Text input ----------
function BmtaInput({ value, onChange, placeholder, type = "text", style, readOnly, monospaceCenter }) {
return (
onChange && onChange(e.target.value)}
readOnly={readOnly}
style={Object.assign({ textAlign: monospaceCenter ? "center" : "left" }, style || {})} />);
}
// ---------- Select / Dropdown ----------
function BmtaSelect({ value, options, onChange, width }) {
const [open, setOpen] = useState(false);
const ref = useRef(null);
useEffect(() => {
if (!open) return;
const f = (e) => {if (ref.current && !ref.current.contains(e.target)) setOpen(false);};
document.addEventListener("mousedown", f);
return () => document.removeEventListener("mousedown", f);
}, [open]);
const display = (() => {
const found = options.find((o) => typeof o === "string" ? o === value : o.value === value);
if (!found) return value;
return typeof found === "string" ? found : found.label;
})();
return (
setOpen((o) => !o)}>
{display}
▼
{open &&
e.stopPropagation()}>
{options.map((o, i) => {
const v = typeof o === "string" ? o : o.value;
const l = typeof o === "string" ? o : o.label;
return (
{onChange && onChange(v);setOpen(false);}}>
{l}
);
})}
}
);
}
// ---------- Slider ----------
function BmtaSlider({ value, min = 0, max = 100, step = 1, onChange, format, width }) {
const ref = useRef(null);
const draggingRef = useRef(false);
const setFromX = useCallback(
(clientX) => {
const el = ref.current;
if (!el) return;
const r = el.getBoundingClientRect();
const t = Math.max(0, Math.min(1, (clientX - r.left) / r.width));
let v = min + t * (max - min);
if (step) v = Math.round(v / step) * step;
v = Math.max(min, Math.min(max, v));
onChange && onChange(v);
},
[min, max, step, onChange]
);
const onDown = (e) => {
draggingRef.current = true;
setFromX(e.clientX);
const move = (ev) => draggingRef.current && setFromX(ev.clientX);
const up = () => {
draggingRef.current = false;
window.removeEventListener("mousemove", move);
window.removeEventListener("mouseup", up);
};
window.addEventListener("mousemove", move);
window.addEventListener("mouseup", up);
};
const pct = (value - min) / (max - min) * 100;
const fmt = typeof format === "function" ? format(value) : String(value) + (format || "");
// Thumb is 9px wide and we want it fully visible at both ends:
// shift left by 0px at pct=0 and by thumbWidth at pct=100 (linear).
const thumbW = 9;
const thumbLeft = `calc(${pct}% - ${pct / 100 * thumbW}px)`;
return (
);
}
// ---------- Sub-header ("General", "Tuning"...) ----------
function BmtaSubheader({ children }) {
return {children}
;
}
// ---------- Top tabs ----------
function BmtaTabs({ tabs, active, onSelect }) {
return (
{tabs.map((t) => {
const id = typeof t === "string" ? t : t.id;
const label = typeof t === "string" ? t : t.label;
return (
onSelect(id)}>
{label}
);
})}
);
}
// ---------- Sidebar (Aimbot/Local/Visuals nav) ----------
function BmtaSidebar({ items, active, onSelect }) {
return (
{items.map((it) => {
const id = typeof it === "string" ? it : it.id;
const label = typeof it === "string" ? it : it.label;
const count = typeof it === "object" ? it.count : null;
return (
onSelect(id)}>
{label}
{count != null && {count}}
);
})}
);
}
// ---------- Sub-tab strip (Logger/Intercept/...) ----------
function BmtaSubtabs({ tabs, active, onSelect }) {
return (
{tabs.map((t) =>
onSelect(t)}>
{t}
)}
);
}
// ---------- Status dot ----------
function BmtaDot({ tone = "info" }) {
return ;
}
// ---------- Section util ----------
function BmtaField({ label, children }) {
return (
);
}
// ---------- Section row (multi-checkbox row) ----------
function BmtaRow({ children, cols }) {
const cls = "bmta-row" + (cols === 2 ? " cols-2" : cols === 4 ? " cols-4" : "");
return {children}
;
}
// ---------- Profile selector (Save as / Reset) ----------
function BmtaProfileBar({ profile, onProfileChange, onSaveAs, onReset, profiles = ["default", "competitive", "stealth"] }) {
return (
Save as
Reset
);
}
// ---------- Faux placeholder area ----------
function BmtaEmpty({ children }) {
return {children}
;
}
// Export to window so panel files can use them
Object.assign(window, {
BmtaCheck,
BmtaCheckIcon,
BmtaRadio,
BmtaButton,
BmtaInput,
BmtaSelect,
BmtaSlider,
BmtaSubheader,
BmtaTabs,
BmtaSidebar,
BmtaSubtabs,
BmtaDot,
BmtaField,
BmtaRow,
BmtaProfileBar,
BmtaEmpty
});