var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellUrl/utils/urlFormatter.ts
var urlFormatter_exports = {};
__export(urlFormatter_exports, {
  formatUrlDisplay: () => formatUrlDisplay,
  hideUrlProtocol: () => hideUrlProtocol,
  hideWwwPrefix: () => hideWwwPrefix
});
module.exports = __toCommonJS(urlFormatter_exports);
var import_urlHelper = require("./urlHelper");
function formatUrlDisplay(url, options) {
  if (!url) return "";
  if (options.displayFormat === "custom" && options.customFormat) {
    return options.customFormat(url);
  }
  if (options.displayFormat === "domain") {
    return (0, import_urlHelper.extractDomain)(url);
  }
  let display = url;
  if (options.showProtocol === false) {
    display = display.replace(/^https?:\/\//, "");
  }
  if (options.showWww === false) {
    display = display.replace(/^(https?:\/\/)?(www\.)/, "$1");
  }
  if (options.showPathname === false) {
    try {
      const urlObj = new URL(url.startsWith("http") ? url : "https://" + url);
      display = urlObj.hostname;
      if (options.showProtocol !== false && urlObj.protocol) {
        display = urlObj.protocol + "//" + display;
      }
    } catch {
    }
  }
  return display;
}
function hideUrlProtocol(url) {
  return url.replace(/^https?:\/\//, "");
}
function hideWwwPrefix(url) {
  return url.replace(/^(https?:\/\/)?(www\.)/, "$1");
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  formatUrlDisplay,
  hideUrlProtocol,
  hideWwwPrefix
});
