var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });

// src/utils/constants.ts
var PACKAGE_NAME = "@palmares/databases";

// src/utils/hash.ts
function hashString(stringToHash) {
  const p = 53;
  const m = 1e9 + 9;
  let powerOfP = 1;
  let hashValue = 0;
  for (let i = 0; i < stringToHash.length; i++) {
    hashValue = (hashValue + (stringToHash[i].charCodeAt(0) - "a".charCodeAt(0) + 1) * powerOfP) % m;
    powerOfP = powerOfP * p % m;
  }
  return hashValue.toString();
}
__name(hashString, "hashString");

// src/utils/models.ts
function extractDefaultEventsHandlerFromModel(modelInstance, functionType) {
  if (typeof modelInstance.options?.[functionType] === "function") {
    return modelInstance.options[functionType];
  } else if (typeof modelInstance.options?.[functionType] === "object" && // eslint-disable-next-line ts/no-unnecessary-type-assertion
  modelInstance.options[functionType].handler === "function") {
    return modelInstance.options[functionType].handler;
  }
  return;
}
__name(extractDefaultEventsHandlerFromModel, "extractDefaultEventsHandlerFromModel");

// src/utils/index.ts
function getUniqueCustomImports(customImports, customImportsToAppendDataTo = []) {
  for (const customImport of customImports || []) {
    const doesNotExistYet = customImportsToAppendDataTo.find((alreadyExistingCustom) => alreadyExistingCustom.packageName === customImport.packageName && alreadyExistingCustom.value === customImport.value) === void 0;
    if (doesNotExistYet) customImportsToAppendDataTo.push(customImport);
  }
  return customImportsToAppendDataTo;
}
__name(getUniqueCustomImports, "getUniqueCustomImports");
function generateUUID() {
  let date = (/* @__PURE__ */ new Date()).getTime();
  import("perf_hooks");
  const performance = globalThis.performance;
  let performanceDate = performance && performance.now && performance.now() * 1e3 || 0;
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (character) => {
    let randomNumber = Math.random() * 16;
    if (date > 0) {
      randomNumber = (date + randomNumber) % 16 | 0;
      date = Math.floor(date / 16);
    } else {
      randomNumber = (performanceDate + randomNumber) % 16 | 0;
      performanceDate = Math.floor(performanceDate / 16);
    }
    return (character === "x" ? randomNumber : randomNumber & 3 | 8).toString(16);
  });
}
__name(generateUUID, "generateUUID");
export {
  PACKAGE_NAME,
  extractDefaultEventsHandlerFromModel,
  generateUUID,
  getUniqueCustomImports,
  hashString
};
