import { runtime as s } from "@synnaxlabs/x";
let a = null;
const u = () => (a ??= document.createElement("canvas"), a), c = (t, e, n) => {
  if (s.RUNTIME === "node") return { width: 0, height: 0 };
  n ??= u().getContext("2d"), n.font = e;
  const o = n.measureText(t);
  return i(o);
}, i = (t) => ({
  width: Math.trunc(
    Math.abs(t.actualBoundingBoxLeft) + Math.abs(t.actualBoundingBoxRight)
  ),
  height: Math.trunc(
    Math.abs(t.actualBoundingBoxAscent) + Math.abs(t.actualBoundingBoxDescent)
  )
});
export {
  i as a,
  c as d
};
