ranui
Version:
A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.
71 lines (70 loc) • 2.7 kB
JavaScript
import { t as v } from "./rolldown-runtime-9ZSF5uba.js";
var E = Math.abs, w = Math.atan2, M = Math.cos, p = Math.max, _ = Math.min, P = Math.sin, S = Math.sqrt, b = 1e-12, h = Math.PI, R = h / 2, F = 2 * h;
function y(e) {
return e > 1 ? 0 : e < -1 ? h : Math.acos(e);
}
function x(e) {
return e >= 1 ? R : e <= -1 ? -R : Math.asin(e);
}
var L = /* @__PURE__ */ v(((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 = /^.+(:|:)/gim, e.whitespaceEscapeCharsRegex = /(\\|%5[cC])((%(6[eE]|72|74))|[nrt])/g, e.relativeFirstCharacters = [".", "/"], e.BLANK_URL = "about:blank";
})), A = /* @__PURE__ */ v(((e) => {
Object.defineProperty(e, "__esModule", { value: !0 }), e.sanitizeUrl = f;
var t = L();
function g(a) {
return t.relativeFirstCharacters.indexOf(a[0]) > -1;
}
function d(a) {
return a.replace(t.ctrlCharactersRegex, "").replace(t.htmlEntitiesRegex, function(i, r) {
return String.fromCharCode(r);
});
}
function C(a) {
return URL.canParse(a);
}
function o(a) {
try {
return decodeURIComponent(a);
} catch {
return a;
}
}
function f(a) {
if (!a) return t.BLANK_URL;
var i, r = o(a.trim());
do
r = d(r).replace(t.htmlCtrlEntityRegex, "").replace(t.ctrlCharactersRegex, "").replace(t.whitespaceEscapeCharsRegex, "").trim(), r = o(r), i = r.match(t.ctrlCharactersRegex) || r.match(t.htmlEntitiesRegex) || r.match(t.htmlCtrlEntityRegex) || r.match(t.whitespaceEscapeCharsRegex);
while (i && i.length > 0);
var n = r;
if (!n) return t.BLANK_URL;
if (g(n)) return n;
var u = n.trimStart(), m = u.match(t.urlSchemeRegex);
if (!m) return n;
var c = m[0].toLowerCase().trim();
if (t.invalidProtocolRegex.test(c)) return t.BLANK_URL;
var l = u.replace(/\\/g, "/");
if (c === "mailto:" || c.includes("://")) return l;
if (c === "http:" || c === "https:") {
if (!C(l)) return t.BLANK_URL;
var s = new URL(l);
return s.protocol = s.protocol.toLowerCase(), s.hostname = s.hostname.toLowerCase(), s.toString();
}
return l;
}
}));
export {
w as a,
R as c,
h as d,
P as f,
x as i,
p as l,
F as m,
E as n,
M as o,
S as p,
y as r,
b as s,
A as t,
_ as u
};