'use strict';

/*!
 * @techmely/utils
 * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
 * MIT Licensed
 */


// src/invariant.ts
var prefix = "Invariant failed";
function invariant(condition, message) {
  if (condition) {
    return;
  }
  if (typeof message === "string" || typeof message === "function") {
    const provided = typeof message === "function" ? message() : message;
    const value = provided ? `${prefix}: ${provided}` : prefix;
    throw new Error(value);
  }
  if (message)
    throw message;
  throw new Error(prefix);
}

// src/isBrowser.ts
function isBrowser() {
  return typeof window !== "undefined";
}

// src/calculateScrollPercentage/index.ts
function calculateScrollPercentage() {
  invariant(isBrowser());
  const scrollPosition = window.scrollY || window.scrollY || document.documentElement.scrollTop;
  const totalHeight = document.documentElement.scrollHeight - window.innerHeight;
  const scrollPercentage = scrollPosition / totalHeight * 100;
  return scrollPercentage;
}

exports.calculateScrollPercentage = calculateScrollPercentage;
