Files
discord-decomp/_bundle/AstBuilder.js
T
2026-11-01 12:12:55 +02:00

121 lines
3.1 KiB
JavaScript

// Metro module 1286 (f1287).
import * as _classCallCheck from "./_classCallCheck";
import * as __createClass from "./_createClass";
import * as _possibleConstructorReturn from "./_possibleConstructorReturn";
import * as _getPrototypeOf from "./_getPrototypeOf";
import * as __inherits from "./_inherits";
import { FormatBuilder } from "./isRichTextTag";
let c1052_0, c1052_5, c1052_6;
let AstBuilder;
let env1052 = {};
env1052[4] = function _isNativeReflectConstruct() {
let c12948_0;
try {
c12948_0 = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
} catch ($e) {}
const _isNativeReflectConstruct2 = function _isNativeReflectConstruct() {
return !!c12948_0;
};
env1052[4] = _isNativeReflectConstruct2;
return _isNativeReflectConstruct2();
};
export function formatToAst(a0, a1) {
return typeof a0 === "string" ? [{
type: c1052_0.Text,
content: a0
}] : this.bindFormatValues(c1052_6, a0, a1);
}
c1052_0 = {};
export { c1052_0 as RichTextNodeType };
c1052_0.Text = "text";
c1052_0.Strong = "strong";
c1052_0.Emphasis = "em";
c1052_0.Strikethrough = "s";
c1052_0.Code = "inlineCode";
c1052_0.Link = "link";
c1052_0.Paragraph = "paragraph";
c1052_5 = {
$b: (a0) => ({
type: c1052_0.Strong,
content: a0
}),
$i: (a0) => ({
type: c1052_0.Emphasis,
content: a0
}),
$del: (a0) => ({
type: c1052_0.Strikethrough,
content: a0
}),
$code: (a0) => ({
type: c1052_0.Code,
content: a0
}),
$link: (a0, a1, a2) => {
const [target] = a2;
return {
type: c1052_0.Link,
target,
content: a0
};
},
$p: (a0) => ({
type: c1052_0.Paragraph,
content: a0
})
};
AstBuilder = function AstBuilder() {
_classCallCheck(this, AstBuilder);
const r8 = _getPrototypeOf(AstBuilder);
const r23 = _possibleConstructorReturn(this, (0, env1052[4])() ? Reflect.construct(r8, arguments, _getPrototypeOf(this).constructor) : r8.apply(this, arguments));
r23.result = [];
return r23;
};
__inherits(AstBuilder, FormatBuilder);
const builder = __createClass(AstBuilder, [{
key: "pushRichTextTag",
value: function pushRichTextTag(a0, a1, a2) {
if (a0 in c1052_5) {
const r19 = c1052_5[a0](a1, "", a2);
const isArray = Array.isArray(r19);
const result = this.result;
const push = result.push;
if (isArray) {
push.apply(result, [...r19]);
} else {
push.call(result, r19);
}
return void 0;
}
throw `${a0} is not a known rich text formatting tag`;
}
}, {
key: "pushLiteralText",
value: function pushLiteralText(a0) {
const r10 = this.result[this.result.length - 1];
if (r10 != null && r10.type === c1052_0.Text) {
r10.content = r10.content + a0;
} else {
this.result.push({
type: c1052_0.Text,
content: a0
});
}
}
}, {
key: "pushObject",
value: function pushObject(a0) {
this.result.push(a0);
}
}, {
key: "finish",
value: function finish() {
return this.result;
}
}]);
c1052_6 = builder;
export const astFormatter = {
format: formatToAst,
builder
};