141 lines
3.8 KiB
JavaScript
141 lines
3.8 KiB
JavaScript
// Metro module 16093 (f16094).
|
|
import { FORMAT_RE, MARKDOWN_RE, UNSAFE_RE, UNSAFE_RE_ALL } from "./Module16094";
|
|
import Module16051 from "./Module16051";
|
|
import Module3888 from "./Module3888";
|
|
import { rules } from "./Module16095";
|
|
import * as _updateRules from "./updateRules";
|
|
import { $withEnv } from "../_hermes/prelude";
|
|
function $mk112542($env) {
|
|
return (a0, a1, a2) => {
|
|
const r7 = a0.includes("\n\n");
|
|
const inline = !r7;
|
|
const r4 = r7 ? a0 + "\n\n" : a0;
|
|
const r8 = $env;
|
|
return (0, r8[1])((0, r8[0])(r4, {
|
|
inline,
|
|
context: a1,
|
|
unsafeContext: a2
|
|
}));
|
|
};
|
|
}
|
|
function $mk112543($env) {
|
|
return (a0, a1, a2) => (0, $env[0])(a0 + "\n\n", {
|
|
inline: false,
|
|
context: a1,
|
|
unsafeContext: a2
|
|
});
|
|
}
|
|
let c11519_3, c11519_4;
|
|
class FormattedMessage {
|
|
constructor(a0, a1, a2) {
|
|
const prototype = new.target.prototype;
|
|
const message = a2 ? a0 : a0.replace(UNSAFE_RE_ALL, "");
|
|
const r13 = {
|
|
__proto__: prototype
|
|
};
|
|
r13.message = message;
|
|
r13.hasMarkdown = a2;
|
|
r13.intlMessage = new Module16051(r13.message, a1);
|
|
return r13;
|
|
}
|
|
format(a0) {
|
|
if (this.hasMarkdown) {
|
|
const [context, unsafeContext] = this.getContext(a0);
|
|
const r22 = this.intlMessage.format(context);
|
|
const r9 = r22.includes("\n\n");
|
|
const inline = !r9;
|
|
const r26 = r9 ? r22 + "\n\n" : r22;
|
|
const r27 = c11519_3.$env;
|
|
return (0, r27[1])((0, r27[0])(r26, {
|
|
inline,
|
|
context,
|
|
unsafeContext
|
|
}));
|
|
}
|
|
return this.intlMessage.format(a0);
|
|
}
|
|
astFormat(a0) {
|
|
const [context, unsafeContext] = this.getContext(a0);
|
|
return (0, c11519_4.$env[0])(this.intlMessage.format(context) + "\n\n", {
|
|
inline: false,
|
|
context,
|
|
unsafeContext
|
|
});
|
|
}
|
|
plainFormat(a0) {
|
|
return this.intlMessage.format(a0);
|
|
}
|
|
getContext(a0) {
|
|
const r1 = {};
|
|
if (UNSAFE_RE.test(this.message)) {
|
|
let r31 = 0;
|
|
for (const item of Object.entries(a0)) {
|
|
const [r17, r43] = item;
|
|
if (this.message.includes(`!!{${r17}}!!`)) {
|
|
const r50 = r31 + 1;
|
|
r31 = r50;
|
|
r1[r50] = r43;
|
|
a0[r17] = r50;
|
|
}
|
|
}
|
|
}
|
|
return [a0, r1];
|
|
}
|
|
}
|
|
export { FormattedMessage };
|
|
export function setUpdateRules(a0) {
|
|
let env22783;
|
|
let env22784;
|
|
const r13 = env22783 = {};
|
|
env22783[0] = void 0;
|
|
env22783[1] = void 0;
|
|
env22783[0] = Module3888.parserFor(a0(rules));
|
|
env22783[1] = Module3888.reactFor(Module3888.ruleOutput(rules, "react"));
|
|
c11519_3 = $withEnv($mk112542(r13), r13);
|
|
const r28 = env22784 = {};
|
|
env22784[0] = void 0;
|
|
env22784[0] = Module3888.parserFor(rules);
|
|
c11519_4 = $withEnv($mk112543(r28), r28);
|
|
}
|
|
export function getMessage(a0, a1) {
|
|
let r52;
|
|
if (a0 == null) {
|
|
return "";
|
|
}
|
|
if (c11519_3 == null) {
|
|
let env22785;
|
|
let env22786;
|
|
const r21 = env22785 = {};
|
|
env22785[0] = void 0;
|
|
env22785[1] = void 0;
|
|
env22785[0] = Module3888.parserFor(_updateRules.default(rules));
|
|
env22785[1] = Module3888.reactFor(Module3888.ruleOutput(rules, "react"));
|
|
c11519_3 = $withEnv($mk112542(r21), r21);
|
|
const r36 = env22786 = {};
|
|
env22786[0] = void 0;
|
|
env22786[0] = Module3888.parserFor(rules);
|
|
c11519_4 = $withEnv($mk112543(r36), r36);
|
|
}
|
|
L10: {
|
|
const r45 = a0.replace(/^\n+|\n+$/g, "");
|
|
const r48 = FORMAT_RE.test(r45);
|
|
const hasMarkdown = MARKDOWN_RE.test(r45);
|
|
if (!r48) {
|
|
r52 = r45;
|
|
if (!hasMarkdown) {
|
|
break L10;
|
|
}
|
|
}
|
|
const prototype = FormattedMessage.prototype;
|
|
const message = hasMarkdown ? r45 : r45.replace(UNSAFE_RE_ALL, "");
|
|
const r60 = {
|
|
__proto__: prototype
|
|
};
|
|
r60.message = message;
|
|
r60.hasMarkdown = hasMarkdown;
|
|
r60.intlMessage = new Module16051(r60.message, a1);
|
|
r52 = r60;
|
|
}
|
|
return r52;
|
|
}
|