import { assert } from "../../../../../shared/src/asserts.js";
import { majorVersionToString, stateVersionFromString } from "../../../types/state-version.js";
function toBigInt(lsn) {
  const parts = lsn.split("/");
  assert(parts.length === 2, `Malformed LSN: "${lsn}"`);
  const high = BigInt(`0x${parts[0]}`);
  const low = BigInt(`0x${parts[1]}`);
  const val = (high << 32n) + low;
  return val;
}
function toStateVersionString(lsn) {
  return majorVersionToString(toBigInt(lsn));
}
function fromStateVersionString(ver) {
  const { major } = stateVersionFromString(ver);
  return fromBigInt(major);
}
function fromBigInt(val) {
  const high = val >> 32n;
  const low = val & 0xffffffffn;
  return `${high.toString(16).toUpperCase()}/${low.toString(16).toUpperCase()}`;
}
export {
  fromBigInt,
  fromStateVersionString,
  toBigInt,
  toStateVersionString
};
//# sourceMappingURL=lsn.js.map
