import { slugifyTagLabel } from "@open-mercato/shared/lib/utils";
function generateTempId() {
  if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
    return crypto.randomUUID();
  }
  return `tmp-${Math.random().toString(36).slice(2)}`;
}
function isValidSocialUrl(rawValue, options) {
  const { hosts, pathRequired = false } = options;
  let parsed;
  try {
    parsed = new URL(rawValue);
  } catch {
    return false;
  }
  const protocol = parsed.protocol.toLowerCase();
  if (protocol !== "https:" && protocol !== "http:") {
    return false;
  }
  const hostname = parsed.hostname.toLowerCase();
  const matchesHost = hosts.some((host) => hostname === host || hostname.endsWith(`.${host}`));
  if (!matchesHost) {
    return false;
  }
  if (!pathRequired) {
    return true;
  }
  const normalizedPath = parsed.pathname.replace(/\/+/g, "/").replace(/(?:^\/|\/$)/g, "");
  return normalizedPath.length > 0;
}
export {
  generateTempId,
  isValidSocialUrl,
  slugifyTagLabel
};
//# sourceMappingURL=detailHelpers.js.map
