import { t as m } from "./rolldown-runtime.js";
var v = /* @__PURE__ */ m(((e) => {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.BLANK_URL = e.relativeFirstCharacters = e.whitespaceEscapeCharsRegex = e.urlSchemeRegex = e.ctrlCharactersRegex = e.htmlCtrlEntityRegex = e.htmlEntitiesRegex = e.invalidProtocolRegex = void 0, e.invalidProtocolRegex = /^([^\w]*)(javascript|data|vbscript)/im, e.htmlEntitiesRegex = /&#(\w+)(^\w|;)?/g, e.htmlCtrlEntityRegex = /&(newline|tab);/gi, e.ctrlCharactersRegex = /[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim, e.urlSchemeRegex = /^.+(:|&colon;)/gim, e.whitespaceEscapeCharsRegex = /(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g, e.relativeFirstCharacters = [".", "/"], e.BLANK_URL = "about:blank";
})), L = /* @__PURE__ */ m(((e) => {
  Object.defineProperty(e, "__esModule", { value: !0 }), e.sanitizeUrl = C;
  var t = v();
  function R(r) {
    return t.relativeFirstCharacters.indexOf(r[0]) > -1;
  }
  function g(r) {
    return r.replace(t.ctrlCharactersRegex, "").replace(t.htmlEntitiesRegex, function(i, a) {
      return String.fromCharCode(a);
    });
  }
  function d(r) {
    return URL.canParse(r);
  }
  function o(r) {
    try {
      return decodeURIComponent(r);
    } catch {
      return r;
    }
  }
  function C(r) {
    if (!r) return t.BLANK_URL;
    var i, a = o(r.trim());
    do
      a = g(a).replace(t.htmlCtrlEntityRegex, "").replace(t.ctrlCharactersRegex, "").replace(t.whitespaceEscapeCharsRegex, "").trim(), a = o(a), i = a.match(t.ctrlCharactersRegex) || a.match(t.htmlEntitiesRegex) || a.match(t.htmlCtrlEntityRegex) || a.match(t.whitespaceEscapeCharsRegex);
    while (i && i.length > 0);
    var c = a;
    if (!c) return t.BLANK_URL;
    if (R(c)) return c;
    var s = c.trimStart(), u = s.match(t.urlSchemeRegex);
    if (!u) return c;
    var n = u[0].toLowerCase().trim();
    if (t.invalidProtocolRegex.test(n)) return t.BLANK_URL;
    var h = s.replace(/\\/g, "/");
    if (n === "mailto:" || n.includes("://")) return h;
    if (n === "http:" || n === "https:") {
      if (!d(h)) return t.BLANK_URL;
      var l = new URL(h);
      return l.protocol = l.protocol.toLowerCase(), l.hostname = l.hostname.toLowerCase(), l.toString();
    }
    return h;
  }
}));
export {
  L as t
};

//# sourceMappingURL=dist2.js.map