@anoki/fse-ui
Version:
FSE UI components library
229 lines (228 loc) • 10.4 kB
JavaScript
import { __exports as m } from "./index.es766.js";
import { __require as Z } from "./index.es767.js";
import { __require as X } from "./index.es768.js";
import { __require as H } from "./index.es769.js";
var b;
function Q() {
return b ? m : (b = 1, (function(u) {
var S = m && m.__createBinding || (Object.create ? (function(e, t, i, r) {
r === void 0 && (r = i);
var n = Object.getOwnPropertyDescriptor(t, i);
(!n || ("get" in n ? !t.__esModule : n.writable || n.configurable)) && (n = { enumerable: !0, get: function() {
return t[i];
} }), Object.defineProperty(e, r, n);
}) : (function(e, t, i, r) {
r === void 0 && (r = i), e[r] = t[i];
})), D = m && m.__setModuleDefault || (Object.create ? (function(e, t) {
Object.defineProperty(e, "default", { enumerable: !0, value: t });
}) : function(e, t) {
e.default = t;
}), I = m && m.__importStar || function(e) {
if (e && e.__esModule) return e;
var t = {};
if (e != null) for (var i in e) i !== "default" && Object.prototype.hasOwnProperty.call(e, i) && S(t, e, i);
return D(t, e), t;
}, L = m && m.__importDefault || function(e) {
return e && e.__esModule ? e : { default: e };
};
Object.defineProperty(u, "__esModule", { value: !0 }), u.decodeXML = u.decodeHTMLStrict = u.decodeHTMLAttribute = u.decodeHTML = u.determineBranch = u.EntityDecoder = u.DecodingMode = u.BinTrieFlags = u.fromCodePoint = u.replaceCodePoint = u.decodeCodePoint = u.xmlDecodeTree = u.htmlDecodeTree = void 0;
var y = L(/* @__PURE__ */ Z());
u.htmlDecodeTree = y.default;
var P = L(/* @__PURE__ */ X());
u.xmlDecodeTree = P.default;
var N = I(/* @__PURE__ */ H());
u.decodeCodePoint = N.default;
var A = /* @__PURE__ */ H();
Object.defineProperty(u, "replaceCodePoint", { enumerable: !0, get: function() {
return A.replaceCodePoint;
} }), Object.defineProperty(u, "fromCodePoint", { enumerable: !0, get: function() {
return A.fromCodePoint;
} });
var c;
(function(e) {
e[e.NUM = 35] = "NUM", e[e.SEMI = 59] = "SEMI", e[e.EQUALS = 61] = "EQUALS", e[e.ZERO = 48] = "ZERO", e[e.NINE = 57] = "NINE", e[e.LOWER_A = 97] = "LOWER_A", e[e.LOWER_F = 102] = "LOWER_F", e[e.LOWER_X = 120] = "LOWER_X", e[e.LOWER_Z = 122] = "LOWER_Z", e[e.UPPER_A = 65] = "UPPER_A", e[e.UPPER_F = 70] = "UPPER_F", e[e.UPPER_Z = 90] = "UPPER_Z";
})(c || (c = {}));
var U = 32, l;
(function(e) {
e[e.VALUE_LENGTH = 49152] = "VALUE_LENGTH", e[e.BRANCH_LENGTH = 16256] = "BRANCH_LENGTH", e[e.JUMP_TABLE = 127] = "JUMP_TABLE";
})(l = u.BinTrieFlags || (u.BinTrieFlags = {}));
function f(e) {
return e >= c.ZERO && e <= c.NINE;
}
function p(e) {
return e >= c.UPPER_A && e <= c.UPPER_F || e >= c.LOWER_A && e <= c.LOWER_F;
}
function g(e) {
return e >= c.UPPER_A && e <= c.UPPER_Z || e >= c.LOWER_A && e <= c.LOWER_Z || f(e);
}
function W(e) {
return e === c.EQUALS || g(e);
}
var a;
(function(e) {
e[e.EntityStart = 0] = "EntityStart", e[e.NumericStart = 1] = "NumericStart", e[e.NumericDecimal = 2] = "NumericDecimal", e[e.NumericHex = 3] = "NumericHex", e[e.NamedEntity = 4] = "NamedEntity";
})(a || (a = {}));
var h;
(function(e) {
e[e.Legacy = 0] = "Legacy", e[e.Strict = 1] = "Strict", e[e.Attribute = 2] = "Attribute";
})(h = u.DecodingMode || (u.DecodingMode = {}));
var R = (
/** @class */
(function() {
function e(t, i, r) {
this.decodeTree = t, this.emitCodePoint = i, this.errors = r, this.state = a.EntityStart, this.consumed = 1, this.result = 0, this.treeIndex = 0, this.excess = 1, this.decodeMode = h.Strict;
}
return e.prototype.startEntity = function(t) {
this.decodeMode = t, this.state = a.EntityStart, this.result = 0, this.treeIndex = 0, this.excess = 1, this.consumed = 1;
}, e.prototype.write = function(t, i) {
switch (this.state) {
case a.EntityStart:
return t.charCodeAt(i) === c.NUM ? (this.state = a.NumericStart, this.consumed += 1, this.stateNumericStart(t, i + 1)) : (this.state = a.NamedEntity, this.stateNamedEntity(t, i));
case a.NumericStart:
return this.stateNumericStart(t, i);
case a.NumericDecimal:
return this.stateNumericDecimal(t, i);
case a.NumericHex:
return this.stateNumericHex(t, i);
case a.NamedEntity:
return this.stateNamedEntity(t, i);
}
}, e.prototype.stateNumericStart = function(t, i) {
return i >= t.length ? -1 : (t.charCodeAt(i) | U) === c.LOWER_X ? (this.state = a.NumericHex, this.consumed += 1, this.stateNumericHex(t, i + 1)) : (this.state = a.NumericDecimal, this.stateNumericDecimal(t, i));
}, e.prototype.addToNumericResult = function(t, i, r, n) {
if (i !== r) {
var d = r - i;
this.result = this.result * Math.pow(n, d) + parseInt(t.substr(i, d), n), this.consumed += d;
}
}, e.prototype.stateNumericHex = function(t, i) {
for (var r = i; i < t.length; ) {
var n = t.charCodeAt(i);
if (f(n) || p(n))
i += 1;
else
return this.addToNumericResult(t, r, i, 16), this.emitNumericEntity(n, 3);
}
return this.addToNumericResult(t, r, i, 16), -1;
}, e.prototype.stateNumericDecimal = function(t, i) {
for (var r = i; i < t.length; ) {
var n = t.charCodeAt(i);
if (f(n))
i += 1;
else
return this.addToNumericResult(t, r, i, 10), this.emitNumericEntity(n, 2);
}
return this.addToNumericResult(t, r, i, 10), -1;
}, e.prototype.emitNumericEntity = function(t, i) {
var r;
if (this.consumed <= i)
return (r = this.errors) === null || r === void 0 || r.absenceOfDigitsInNumericCharacterReference(this.consumed), 0;
if (t === c.SEMI)
this.consumed += 1;
else if (this.decodeMode === h.Strict)
return 0;
return this.emitCodePoint((0, N.replaceCodePoint)(this.result), this.consumed), this.errors && (t !== c.SEMI && this.errors.missingSemicolonAfterCharacterReference(), this.errors.validateNumericCharacterReference(this.result)), this.consumed;
}, e.prototype.stateNamedEntity = function(t, i) {
for (var r = this.decodeTree, n = r[this.treeIndex], d = (n & l.VALUE_LENGTH) >> 14; i < t.length; i++, this.excess++) {
var o = t.charCodeAt(i);
if (this.treeIndex = M(r, n, this.treeIndex + Math.max(1, d), o), this.treeIndex < 0)
return this.result === 0 || // If we are parsing an attribute
this.decodeMode === h.Attribute && // We shouldn't have consumed any characters after the entity,
(d === 0 || // And there should be no invalid characters.
W(o)) ? 0 : this.emitNotTerminatedNamedEntity();
if (n = r[this.treeIndex], d = (n & l.VALUE_LENGTH) >> 14, d !== 0) {
if (o === c.SEMI)
return this.emitNamedEntityData(this.treeIndex, d, this.consumed + this.excess);
this.decodeMode !== h.Strict && (this.result = this.treeIndex, this.consumed += this.excess, this.excess = 0);
}
}
return -1;
}, e.prototype.emitNotTerminatedNamedEntity = function() {
var t, i = this, r = i.result, n = i.decodeTree, d = (n[r] & l.VALUE_LENGTH) >> 14;
return this.emitNamedEntityData(r, d, this.consumed), (t = this.errors) === null || t === void 0 || t.missingSemicolonAfterCharacterReference(), this.consumed;
}, e.prototype.emitNamedEntityData = function(t, i, r) {
var n = this.decodeTree;
return this.emitCodePoint(i === 1 ? n[t] & ~l.VALUE_LENGTH : n[t + 1], r), i === 3 && this.emitCodePoint(n[t + 2], r), r;
}, e.prototype.end = function() {
var t;
switch (this.state) {
case a.NamedEntity:
return this.result !== 0 && (this.decodeMode !== h.Attribute || this.result === this.treeIndex) ? this.emitNotTerminatedNamedEntity() : 0;
// Otherwise, emit a numeric entity if we have one.
case a.NumericDecimal:
return this.emitNumericEntity(0, 2);
case a.NumericHex:
return this.emitNumericEntity(0, 3);
case a.NumericStart:
return (t = this.errors) === null || t === void 0 || t.absenceOfDigitsInNumericCharacterReference(this.consumed), 0;
case a.EntityStart:
return 0;
}
}, e;
})()
);
u.EntityDecoder = R;
function T(e) {
var t = "", i = new R(e, function(r) {
return t += (0, N.fromCodePoint)(r);
});
return function(n, d) {
for (var o = 0, s = 0; (s = n.indexOf("&", s)) >= 0; ) {
t += n.slice(o, s), i.startEntity(d);
var _ = i.write(
n,
// Skip the "&"
s + 1
);
if (_ < 0) {
o = s + i.end();
break;
}
o = s + _, s = _ === 0 ? o + 1 : o;
}
var E = t + n.slice(o);
return t = "", E;
};
}
function M(e, t, i, r) {
var n = (t & l.BRANCH_LENGTH) >> 7, d = t & l.JUMP_TABLE;
if (n === 0)
return d !== 0 && r === d ? i : -1;
if (d) {
var o = r - d;
return o < 0 || o >= n ? -1 : e[i + o] - 1;
}
for (var s = i, _ = s + n - 1; s <= _; ) {
var E = s + _ >>> 1, O = e[E];
if (O < r)
s = E + 1;
else if (O > r)
_ = E - 1;
else
return e[E + n];
}
return -1;
}
u.determineBranch = M;
var v = T(y.default), j = T(P.default);
function w(e, t) {
return t === void 0 && (t = h.Legacy), v(e, t);
}
u.decodeHTML = w;
function B(e) {
return v(e, h.Attribute);
}
u.decodeHTMLAttribute = B;
function q(e) {
return v(e, h.Strict);
}
u.decodeHTMLStrict = q;
function G(e) {
return j(e, h.Strict);
}
u.decodeXML = G;
})(m), m);
}
export {
Q as __require
};
//# sourceMappingURL=index.es714.js.map