@fluenti/solid 0.4.0-rc.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/components-entry-5CGlUlc5.cjs +2 -0
- package/dist/components-entry-5CGlUlc5.cjs.map +1 -0
- package/dist/components-entry-C-Df62O-.js +632 -0
- package/dist/components-entry-C-Df62O-.js.map +1 -0
- package/dist/components-entry.cjs +1 -2
- package/dist/components-entry.js +2 -293
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +4 -4
- package/dist/solid/src/compile-time-t.d.ts +3 -0
- package/dist/solid/src/compile-time-t.d.ts.map +1 -0
- package/dist/solid/src/compiled.d.ts +43 -0
- package/dist/solid/src/compiled.d.ts.map +1 -0
- package/dist/solid/src/components/DateTime.d.ts.map +1 -0
- package/dist/solid/src/components/NumberFormat.d.ts.map +1 -0
- package/dist/{components-entry.d.ts → solid/src/components-entry.d.ts} +1 -1
- package/dist/solid/src/components-entry.d.ts.map +1 -0
- package/dist/{context.d.ts → solid/src/context.d.ts} +5 -4
- package/dist/solid/src/context.d.ts.map +1 -0
- package/dist/solid/src/hooks/__useI18n.d.ts.map +1 -0
- package/dist/solid/src/index.d.ts +9 -0
- package/dist/solid/src/index.d.ts.map +1 -0
- package/dist/solid/src/msg.d.ts +2 -0
- package/dist/solid/src/msg.d.ts.map +1 -0
- package/dist/solid/src/plain-runtime.d.ts +9 -0
- package/dist/solid/src/plain-runtime.d.ts.map +1 -0
- package/dist/{plural.d.ts → solid/src/plural.d.ts} +1 -1
- package/dist/solid/src/plural.d.ts.map +1 -0
- package/dist/solid/src/provider.d.ts.map +1 -0
- package/dist/solid/src/rich-dom.d.ts.map +1 -0
- package/dist/{select.d.ts → solid/src/select.d.ts} +1 -1
- package/dist/solid/src/select.d.ts.map +1 -0
- package/dist/{server.d.ts → solid/src/server.d.ts} +3 -3
- package/dist/solid/src/server.d.ts.map +1 -0
- package/dist/solid/src/solid-runtime.d.ts +3 -0
- package/dist/solid/src/solid-runtime.d.ts.map +1 -0
- package/dist/solid/src/trans.d.ts.map +1 -0
- package/dist/{types.d.ts → solid/src/types.d.ts} +1 -1
- package/dist/solid/src/types.d.ts.map +1 -0
- package/dist/solid/src/use-i18n.d.ts.map +1 -0
- package/dist/{vite-plugin.d.ts → solid/src/vite-plugin.d.ts} +2 -2
- package/dist/solid/src/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.cjs +1 -1
- package/dist/vite-plugin.cjs.map +1 -1
- package/dist/vite-plugin.js +1 -1
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +14 -14
- package/src/compiled.tsx +158 -0
- package/src/components-entry.ts +7 -3
- package/src/context.ts +5 -3
- package/src/index.ts +11 -10
- package/src/plain-runtime.ts +65 -0
- package/src/plural.tsx +23 -11
- package/src/rich-dom.tsx +1 -2
- package/src/select.tsx +16 -5
- package/src/solid-runtime.ts +1 -1
- package/dist/compile-time-t.d.ts +0 -3
- package/dist/compile-time-t.d.ts.map +0 -1
- package/dist/components/DateTime.d.ts.map +0 -1
- package/dist/components/NumberFormat.d.ts.map +0 -1
- package/dist/components-entry.cjs.map +0 -1
- package/dist/components-entry.d.ts.map +0 -1
- package/dist/components-entry.js.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/hooks/__useI18n.d.ts.map +0 -1
- package/dist/index.d.ts +0 -12
- package/dist/index.d.ts.map +0 -1
- package/dist/msg.d.ts +0 -2
- package/dist/msg.d.ts.map +0 -1
- package/dist/plural.d.ts.map +0 -1
- package/dist/provider.d.ts.map +0 -1
- package/dist/rich-dom.d.ts.map +0 -1
- package/dist/select.d.ts.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/solid-runtime.d.ts +0 -3
- package/dist/solid-runtime.d.ts.map +0 -1
- package/dist/trans.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/use-i18n-5u9iEPWp.js +0 -204
- package/dist/use-i18n-5u9iEPWp.js.map +0 -1
- package/dist/use-i18n-B8NgKzjN.cjs +0 -2
- package/dist/use-i18n-B8NgKzjN.cjs.map +0 -1
- package/dist/use-i18n.d.ts.map +0 -1
- package/dist/vite-plugin.d.ts.map +0 -1
- /package/dist/{components → solid/src/components}/DateTime.d.ts +0 -0
- /package/dist/{components → solid/src/components}/NumberFormat.d.ts +0 -0
- /package/dist/{hooks → solid/src/hooks}/__useI18n.d.ts +0 -0
- /package/dist/{provider.d.ts → solid/src/provider.d.ts} +0 -0
- /package/dist/{rich-dom.d.ts → solid/src/rich-dom.d.ts} +0 -0
- /package/dist/{trans.d.ts → solid/src/trans.d.ts} +0 -0
- /package/dist/{use-i18n.d.ts → solid/src/use-i18n.d.ts} +0 -0
|
@@ -0,0 +1,632 @@
|
|
|
1
|
+
import { children as e, createContext as t, createMemo as n, createSignal as r, useContext as i } from "solid-js";
|
|
2
|
+
import { createFluentiCore as a } from "@fluenti/core";
|
|
3
|
+
import { Dynamic as o, createComponent as s, memo as c } from "solid-js/web";
|
|
4
|
+
import { PLURAL_CATEGORIES as l, buildICUPluralMessage as u, buildICUSelectMessage as d, hashMessage as f, normalizeSelectForms as p, offsetIndices as m } from "@fluenti/core/runtime";
|
|
5
|
+
//#region src/context.ts
|
|
6
|
+
var h = Symbol.for("fluenti.runtime.solid.v1");
|
|
7
|
+
function g() {
|
|
8
|
+
let e = globalThis[h];
|
|
9
|
+
return typeof e == "object" && e ? e : null;
|
|
10
|
+
}
|
|
11
|
+
function _(e) {
|
|
12
|
+
return typeof e == "object" && e && "default" in e ? e.default : e;
|
|
13
|
+
}
|
|
14
|
+
var v = {
|
|
15
|
+
en: "USD",
|
|
16
|
+
"en-US": "USD",
|
|
17
|
+
"en-GB": "GBP",
|
|
18
|
+
"en-AU": "AUD",
|
|
19
|
+
"en-CA": "CAD",
|
|
20
|
+
"zh-CN": "CNY",
|
|
21
|
+
"zh-TW": "TWD",
|
|
22
|
+
"zh-HK": "HKD",
|
|
23
|
+
ja: "JPY",
|
|
24
|
+
"ja-JP": "JPY",
|
|
25
|
+
ko: "KRW",
|
|
26
|
+
"ko-KR": "KRW",
|
|
27
|
+
de: "EUR",
|
|
28
|
+
"de-DE": "EUR",
|
|
29
|
+
"de-AT": "EUR",
|
|
30
|
+
fr: "EUR",
|
|
31
|
+
"fr-FR": "EUR",
|
|
32
|
+
"fr-CA": "CAD",
|
|
33
|
+
es: "EUR",
|
|
34
|
+
"es-ES": "EUR",
|
|
35
|
+
"es-MX": "MXN",
|
|
36
|
+
pt: "EUR",
|
|
37
|
+
"pt-BR": "BRL",
|
|
38
|
+
"pt-PT": "EUR",
|
|
39
|
+
it: "EUR",
|
|
40
|
+
ru: "RUB",
|
|
41
|
+
ar: "SAR",
|
|
42
|
+
hi: "INR"
|
|
43
|
+
}, y = {
|
|
44
|
+
short: {
|
|
45
|
+
year: "numeric",
|
|
46
|
+
month: "numeric",
|
|
47
|
+
day: "numeric"
|
|
48
|
+
},
|
|
49
|
+
long: {
|
|
50
|
+
year: "numeric",
|
|
51
|
+
month: "long",
|
|
52
|
+
day: "numeric",
|
|
53
|
+
weekday: "long"
|
|
54
|
+
},
|
|
55
|
+
time: {
|
|
56
|
+
hour: "numeric",
|
|
57
|
+
minute: "numeric"
|
|
58
|
+
},
|
|
59
|
+
datetime: {
|
|
60
|
+
year: "numeric",
|
|
61
|
+
month: "short",
|
|
62
|
+
day: "numeric",
|
|
63
|
+
hour: "numeric",
|
|
64
|
+
minute: "numeric"
|
|
65
|
+
}
|
|
66
|
+
}, b = {
|
|
67
|
+
currency: (e) => ({
|
|
68
|
+
style: "currency",
|
|
69
|
+
currency: v[e] ?? v[e.split("-")[0]] ?? "USD"
|
|
70
|
+
}),
|
|
71
|
+
percent: { style: "percent" },
|
|
72
|
+
decimal: {
|
|
73
|
+
minimumFractionDigits: 2,
|
|
74
|
+
maximumFractionDigits: 2
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
function x(e) {
|
|
78
|
+
let [t, n] = r(e.locale), [i, o] = r(!1), s = new Set([e.locale]), [c, l] = r(new Set(s)), u = { ...e.messages }, d = e, f = d.lazyLocaleLoading ?? e.splitting ?? !1, p = {
|
|
79
|
+
locale: e.locale,
|
|
80
|
+
messages: e.messages ?? {},
|
|
81
|
+
dateFormats: {
|
|
82
|
+
...y,
|
|
83
|
+
...d.dateFormats
|
|
84
|
+
},
|
|
85
|
+
numberFormats: {
|
|
86
|
+
...b,
|
|
87
|
+
...d.numberFormats
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
e.fallbackLocale !== void 0 && (p.fallbackLocale = e.fallbackLocale), d.fallbackChain !== void 0 && (p.fallbackChain = d.fallbackChain), e.missing !== void 0 && (p.missing = e.missing), d.diagnostics !== void 0 && (p.diagnostics = d.diagnostics), d.interpolate !== void 0 && (p.interpolate = d.interpolate), p.devWarnings = p.devWarnings ?? (typeof process < "u" && process.env.NODE_ENV === "development");
|
|
91
|
+
let m = a(p);
|
|
92
|
+
function h(e, ...n) {
|
|
93
|
+
let r = t();
|
|
94
|
+
return m.locale !== r && (m.locale = r), Array.isArray(e) && "raw" in e ? m.t(e, ...n) : m.t(e, n[0]);
|
|
95
|
+
}
|
|
96
|
+
let v = (e, t) => {
|
|
97
|
+
m.loadMessages(e, t), u[e] = {
|
|
98
|
+
...u[e],
|
|
99
|
+
...t
|
|
100
|
+
}, s.add(e), l(new Set(s));
|
|
101
|
+
}, x = 0, S = async (e) => {
|
|
102
|
+
if (!f || !d.chunkLoader) {
|
|
103
|
+
n(e);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
let t = g();
|
|
107
|
+
if (s.has(e)) {
|
|
108
|
+
try {
|
|
109
|
+
t?.__switchLocale && await t.__switchLocale(e);
|
|
110
|
+
} catch (t) {
|
|
111
|
+
console.warn(`[fluenti] split runtime switch failed for locale "${e}"`, t);
|
|
112
|
+
}
|
|
113
|
+
n(e);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
let r = ++x;
|
|
117
|
+
o(!0);
|
|
118
|
+
try {
|
|
119
|
+
let i = _(await d.chunkLoader(e));
|
|
120
|
+
if (m.loadMessages(e, i), u[e] = {
|
|
121
|
+
...u[e],
|
|
122
|
+
...i
|
|
123
|
+
}, s.add(e), l(new Set(s)), r !== x) return;
|
|
124
|
+
try {
|
|
125
|
+
t?.__switchLocale && await t.__switchLocale(e);
|
|
126
|
+
} catch (t) {
|
|
127
|
+
console.warn(`[fluenti] split runtime switch failed for locale "${e}"`, t);
|
|
128
|
+
}
|
|
129
|
+
if (r !== x) return;
|
|
130
|
+
n(e);
|
|
131
|
+
} finally {
|
|
132
|
+
r === x && o(!1);
|
|
133
|
+
}
|
|
134
|
+
}, C = /* @__PURE__ */ new Set();
|
|
135
|
+
return {
|
|
136
|
+
locale: t,
|
|
137
|
+
setLocale: S,
|
|
138
|
+
t: h,
|
|
139
|
+
loadMessages: v,
|
|
140
|
+
getLocales: () => m.getLocales(),
|
|
141
|
+
d: (e, n) => {
|
|
142
|
+
let r = t();
|
|
143
|
+
return m.locale !== r && (m.locale = r), m.d(e, n);
|
|
144
|
+
},
|
|
145
|
+
n: (e, n) => {
|
|
146
|
+
let r = t();
|
|
147
|
+
return m.locale !== r && (m.locale = r), m.n(e, n);
|
|
148
|
+
},
|
|
149
|
+
format: (e, n) => {
|
|
150
|
+
let r = t();
|
|
151
|
+
return m.locale !== r && (m.locale = r), m.format(e, n);
|
|
152
|
+
},
|
|
153
|
+
isLoading: i,
|
|
154
|
+
loadedLocales: c,
|
|
155
|
+
preloadLocale: (e) => {
|
|
156
|
+
if (!f || s.has(e) || !d.chunkLoader || C.has(e)) return;
|
|
157
|
+
C.add(e);
|
|
158
|
+
let t = g();
|
|
159
|
+
d.chunkLoader(e).then(async (n) => {
|
|
160
|
+
let r = _(n);
|
|
161
|
+
m.loadMessages(e, r), u[e] = {
|
|
162
|
+
...u[e],
|
|
163
|
+
...r
|
|
164
|
+
}, s.add(e), l(new Set(s)), t?.__preloadLocale && await t.__preloadLocale(e);
|
|
165
|
+
}).catch((t) => {
|
|
166
|
+
console.warn("[fluenti] preload failed:", e, t);
|
|
167
|
+
}).finally(() => {
|
|
168
|
+
C.delete(e);
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
te: (e, n) => {
|
|
172
|
+
let r = u[n ?? t()];
|
|
173
|
+
return r !== void 0 && e in r;
|
|
174
|
+
},
|
|
175
|
+
tm: (e, n) => {
|
|
176
|
+
let r = u[n ?? t()];
|
|
177
|
+
return r ? r[e] : void 0;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
var S = x, C = t(), w = (e) => {
|
|
182
|
+
let t = x(e);
|
|
183
|
+
return s(C.Provider, {
|
|
184
|
+
value: t,
|
|
185
|
+
get children() {
|
|
186
|
+
return e.children;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
};
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/use-i18n.ts
|
|
192
|
+
function T() {
|
|
193
|
+
let e = i(C);
|
|
194
|
+
if (e) return e;
|
|
195
|
+
throw Error("useI18n() must be used inside an <I18nProvider>.");
|
|
196
|
+
}
|
|
197
|
+
function E() {
|
|
198
|
+
return T().locale;
|
|
199
|
+
}
|
|
200
|
+
//#endregion
|
|
201
|
+
//#region src/rich-dom.tsx
|
|
202
|
+
function D(e) {
|
|
203
|
+
return typeof Node < "u" && e instanceof Node;
|
|
204
|
+
}
|
|
205
|
+
function O(e) {
|
|
206
|
+
return typeof e == "function" && !e.length ? e() : e;
|
|
207
|
+
}
|
|
208
|
+
function k(e) {
|
|
209
|
+
let t = [], n = "";
|
|
210
|
+
function r(e) {
|
|
211
|
+
let i = O(e);
|
|
212
|
+
if (i == null || typeof i == "boolean") return;
|
|
213
|
+
if (Array.isArray(i)) {
|
|
214
|
+
for (let e of i) r(e);
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
if (typeof i == "string" || typeof i == "number") {
|
|
218
|
+
n += String(i);
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
if (!D(i)) return;
|
|
222
|
+
if (i.nodeType === Node.TEXT_NODE) {
|
|
223
|
+
n += i.textContent ?? "";
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (i.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {
|
|
227
|
+
r(Array.from(i.childNodes));
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
let a = t.length, o = k(Array.from(i.childNodes));
|
|
231
|
+
t.push(i.cloneNode(!1)), t.push(...o.components), o.message === "" && o.components.length === 0 ? n += `<${a}/>` : n += `<${a}>${m(o.message, a + 1)}</${a}>`;
|
|
232
|
+
}
|
|
233
|
+
return r(e), {
|
|
234
|
+
message: n,
|
|
235
|
+
components: t
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
function A(e, t) {
|
|
239
|
+
let n = O(t);
|
|
240
|
+
if (!(n == null || typeof n == "boolean")) {
|
|
241
|
+
if (Array.isArray(n)) {
|
|
242
|
+
for (let t of n) A(e, t);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
if (typeof n == "string" || typeof n == "number") {
|
|
246
|
+
e.appendChild(document.createTextNode(String(n)));
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
D(n) && e.appendChild(n);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function j(e, t) {
|
|
253
|
+
let n = /<(\d+)(?:\/>|(>)([\s\S]*?)<\/\1>)/g, r = [], i = 0, a;
|
|
254
|
+
for (n.lastIndex = 0, a = n.exec(e); a !== null;) {
|
|
255
|
+
a.index > i && r.push(e.slice(i, a.index));
|
|
256
|
+
let o = Number(a[1]), s = a[2] === void 0;
|
|
257
|
+
if (!Number.isInteger(o) || o < 0 || o >= t.length) {
|
|
258
|
+
s || r.push(a[3] ?? ""), i = n.lastIndex, a = n.exec(e);
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
let c = t[o];
|
|
262
|
+
if (s) c && r.push(c.cloneNode(!1));
|
|
263
|
+
else {
|
|
264
|
+
let e = j(a[2] === void 0 ? "" : a[3], t);
|
|
265
|
+
if (c) {
|
|
266
|
+
let t = c.cloneNode(!1);
|
|
267
|
+
A(t, e), r.push(t);
|
|
268
|
+
} else r.push(a[3] ?? "");
|
|
269
|
+
}
|
|
270
|
+
i = n.lastIndex, a = n.exec(e);
|
|
271
|
+
}
|
|
272
|
+
return i < e.length && r.push(e.slice(i)), r.length <= 1 ? r[0] ?? "" : r;
|
|
273
|
+
}
|
|
274
|
+
function M(e, t) {
|
|
275
|
+
let n = {}, r = [];
|
|
276
|
+
for (let i of e) {
|
|
277
|
+
let e = t[i];
|
|
278
|
+
if (e === void 0) continue;
|
|
279
|
+
let a = k(e);
|
|
280
|
+
n[i] = m(a.message, r.length), r.push(...a.components);
|
|
281
|
+
}
|
|
282
|
+
for (let [i, a] of Object.entries(t)) {
|
|
283
|
+
if (e.includes(i) || a === void 0) continue;
|
|
284
|
+
let t = k(a);
|
|
285
|
+
n[i] = m(t.message, r.length), r.push(...t.components);
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
messages: n,
|
|
289
|
+
components: r
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
//#endregion
|
|
293
|
+
//#region src/trans.tsx
|
|
294
|
+
var N = 100;
|
|
295
|
+
function P(e, t = 0) {
|
|
296
|
+
if (t > N) return [{
|
|
297
|
+
type: "text",
|
|
298
|
+
value: e
|
|
299
|
+
}];
|
|
300
|
+
let n = [], r = 0;
|
|
301
|
+
for (; r < e.length;) {
|
|
302
|
+
let i = e.indexOf("<", r);
|
|
303
|
+
if (i === -1) {
|
|
304
|
+
n.push({
|
|
305
|
+
type: "text",
|
|
306
|
+
value: e.slice(r)
|
|
307
|
+
});
|
|
308
|
+
break;
|
|
309
|
+
}
|
|
310
|
+
i > r && n.push({
|
|
311
|
+
type: "text",
|
|
312
|
+
value: e.slice(r, i)
|
|
313
|
+
});
|
|
314
|
+
let a = e.slice(i).match(/^<(\w+)\s*\/>/);
|
|
315
|
+
if (a) {
|
|
316
|
+
n.push({
|
|
317
|
+
type: "tag",
|
|
318
|
+
name: a[1],
|
|
319
|
+
children: []
|
|
320
|
+
}), r = i + a[0].length;
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
let o = e.slice(i).match(/^<(\w+)>/);
|
|
324
|
+
if (!o) {
|
|
325
|
+
n.push({
|
|
326
|
+
type: "text",
|
|
327
|
+
value: "<"
|
|
328
|
+
}), r = i + 1;
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
let s = o[1], c = i + o[0].length, l = F(e, s, c);
|
|
332
|
+
if (l === -1) {
|
|
333
|
+
n.push({
|
|
334
|
+
type: "text",
|
|
335
|
+
value: e.slice(i, c)
|
|
336
|
+
}), r = c;
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
let u = e.slice(c, l), d = `</${s}>`;
|
|
340
|
+
n.push({
|
|
341
|
+
type: "tag",
|
|
342
|
+
name: s,
|
|
343
|
+
children: P(u, t + 1)
|
|
344
|
+
}), r = l + d.length;
|
|
345
|
+
}
|
|
346
|
+
return n;
|
|
347
|
+
}
|
|
348
|
+
function F(e, t, n) {
|
|
349
|
+
let r = `<${t}>`, i = `</${t}>`, a = 1, o = n;
|
|
350
|
+
for (; o < e.length && a > 0;) {
|
|
351
|
+
let t = e.indexOf(r, o), n = e.indexOf(i, o);
|
|
352
|
+
if (n === -1) return -1;
|
|
353
|
+
if (t !== -1 && t < n) a++, o = t + r.length;
|
|
354
|
+
else {
|
|
355
|
+
if (a--, a === 0) return n;
|
|
356
|
+
o = n + i.length;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return -1;
|
|
360
|
+
}
|
|
361
|
+
function I(e, t) {
|
|
362
|
+
let n = e.map((e) => {
|
|
363
|
+
if (e.type === "text") return e.value;
|
|
364
|
+
let n = t[e.name];
|
|
365
|
+
return n ? s(o, {
|
|
366
|
+
component: n,
|
|
367
|
+
children: e.children.length > 0 ? I(e.children, t) : void 0
|
|
368
|
+
}) : I(e.children, t);
|
|
369
|
+
});
|
|
370
|
+
return n.length === 1 ? n[0] : n;
|
|
371
|
+
}
|
|
372
|
+
var L = (t) => {
|
|
373
|
+
let { t: r } = T(), i = e(() => t.children), a = n(() => {
|
|
374
|
+
let e = t.__message ?? t.message;
|
|
375
|
+
return typeof e == "function" ? e() : e;
|
|
376
|
+
}), c = n(() => t.__components ?? t.components);
|
|
377
|
+
return (() => {
|
|
378
|
+
let e = a(), n = c();
|
|
379
|
+
if (e !== void 0 && n) return I(P(r({
|
|
380
|
+
...t.id === void 0 ? {} : { id: t.id },
|
|
381
|
+
message: e,
|
|
382
|
+
...t.context === void 0 ? {} : { context: t.context },
|
|
383
|
+
...t.comment === void 0 ? {} : { comment: t.comment }
|
|
384
|
+
})), n);
|
|
385
|
+
let l = i.toArray();
|
|
386
|
+
if (l.length === 0) return null;
|
|
387
|
+
let u = k(l), d = r({
|
|
388
|
+
...t.id === void 0 ? {} : { id: t.id },
|
|
389
|
+
message: u.message,
|
|
390
|
+
...t.context === void 0 ? {} : { context: t.context },
|
|
391
|
+
...t.comment === void 0 ? {} : { comment: t.comment }
|
|
392
|
+
}), f = u.components.length > 0 ? j(d, u.components) : d;
|
|
393
|
+
return Array.isArray(f) && f.length > 1 && t.tag ? s(o, {
|
|
394
|
+
get component() {
|
|
395
|
+
return t.tag;
|
|
396
|
+
},
|
|
397
|
+
children: f
|
|
398
|
+
}) : f;
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
//#endregion
|
|
402
|
+
//#region src/plain-runtime.ts
|
|
403
|
+
function R(e) {
|
|
404
|
+
return typeof e == "function" && !e.length ? e() : e;
|
|
405
|
+
}
|
|
406
|
+
function z(e, t, n) {
|
|
407
|
+
return e ?? (n === void 0 ? t : f(t, n));
|
|
408
|
+
}
|
|
409
|
+
function B(e) {
|
|
410
|
+
return typeof e == "string" || typeof e == "number";
|
|
411
|
+
}
|
|
412
|
+
function V(e, t) {
|
|
413
|
+
let n = {};
|
|
414
|
+
for (let t of l) {
|
|
415
|
+
let r = R(e[t]);
|
|
416
|
+
if (r !== void 0) {
|
|
417
|
+
if (!B(r)) return;
|
|
418
|
+
n[t] = String(r);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
if (n.other !== void 0) return u(n, t);
|
|
422
|
+
}
|
|
423
|
+
function H(e) {
|
|
424
|
+
let t = {};
|
|
425
|
+
for (let [n, r] of Object.entries(e)) {
|
|
426
|
+
let e = R(r);
|
|
427
|
+
if (e !== void 0) {
|
|
428
|
+
if (!B(e)) return;
|
|
429
|
+
t[n] = String(e);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
if (t.other === void 0) return;
|
|
433
|
+
let n = p(t);
|
|
434
|
+
return {
|
|
435
|
+
message: d(n.forms),
|
|
436
|
+
valueMap: n.valueMap
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
//#endregion
|
|
440
|
+
//#region src/plural.tsx
|
|
441
|
+
var U = (e) => {
|
|
442
|
+
let { t } = T();
|
|
443
|
+
return (() => {
|
|
444
|
+
let n = {};
|
|
445
|
+
for (let t of l) {
|
|
446
|
+
let r = R(e[t]);
|
|
447
|
+
r !== void 0 && (n[t] = r);
|
|
448
|
+
}
|
|
449
|
+
let r = V(n, e.offset);
|
|
450
|
+
if (r !== void 0) {
|
|
451
|
+
let n = t({
|
|
452
|
+
id: z(e.id, r, e.context),
|
|
453
|
+
message: r,
|
|
454
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
455
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
456
|
+
}, { count: e.value });
|
|
457
|
+
return e.tag ? s(o, {
|
|
458
|
+
get component() {
|
|
459
|
+
return e.tag;
|
|
460
|
+
},
|
|
461
|
+
children: n
|
|
462
|
+
}) : n;
|
|
463
|
+
}
|
|
464
|
+
let { messages: i, components: a } = M(l, n), c = u({
|
|
465
|
+
...i.zero !== void 0 && { zero: i.zero },
|
|
466
|
+
...i.one !== void 0 && { one: i.one },
|
|
467
|
+
...i.two !== void 0 && { two: i.two },
|
|
468
|
+
...i.few !== void 0 && { few: i.few },
|
|
469
|
+
...i.many !== void 0 && { many: i.many },
|
|
470
|
+
other: i.other ?? ""
|
|
471
|
+
}, e.offset), d = t({
|
|
472
|
+
id: z(e.id, c, e.context),
|
|
473
|
+
message: c,
|
|
474
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
475
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
476
|
+
}, { count: e.value }), f = a.length > 0 ? j(d, a) : d;
|
|
477
|
+
return e.tag ? s(o, {
|
|
478
|
+
get component() {
|
|
479
|
+
return e.tag;
|
|
480
|
+
},
|
|
481
|
+
children: f
|
|
482
|
+
}) : f;
|
|
483
|
+
});
|
|
484
|
+
}, W = (e) => {
|
|
485
|
+
let { t } = T(), n = () => {
|
|
486
|
+
let n = new Set([
|
|
487
|
+
"value",
|
|
488
|
+
"id",
|
|
489
|
+
"context",
|
|
490
|
+
"comment",
|
|
491
|
+
"options",
|
|
492
|
+
"other",
|
|
493
|
+
"tag",
|
|
494
|
+
"children",
|
|
495
|
+
"ref",
|
|
496
|
+
"class",
|
|
497
|
+
"className",
|
|
498
|
+
"style",
|
|
499
|
+
"classList",
|
|
500
|
+
"on",
|
|
501
|
+
"oncapture",
|
|
502
|
+
"use",
|
|
503
|
+
"prop"
|
|
504
|
+
]), r = e.options === void 0 ? {
|
|
505
|
+
...Object.fromEntries(Object.entries(e).filter(([e]) => !n.has(e) && !e.startsWith("data-") && !e.startsWith("aria-") && !e.startsWith("on"))),
|
|
506
|
+
other: e.other
|
|
507
|
+
} : {
|
|
508
|
+
...e.options,
|
|
509
|
+
other: e.other
|
|
510
|
+
}, i = H(r);
|
|
511
|
+
if (i !== void 0) return t({
|
|
512
|
+
id: z(e.id, i.message, e.context),
|
|
513
|
+
message: i.message,
|
|
514
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
515
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
516
|
+
}, { value: i.valueMap[e.value] ?? "other" });
|
|
517
|
+
let a = [...Object.keys(r).filter((e) => e !== "other"), "other"], { messages: o, components: s } = M(a, r), c = p(Object.fromEntries([...a].map((e) => [e, o[e] ?? ""]))), l = t({
|
|
518
|
+
id: z(e.id, d(c.forms), e.context),
|
|
519
|
+
message: d(c.forms),
|
|
520
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
521
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
522
|
+
}, { value: c.valueMap[e.value] ?? "other" });
|
|
523
|
+
return s.length > 0 ? j(l, s) : l;
|
|
524
|
+
};
|
|
525
|
+
return (() => e.tag ? s(o, {
|
|
526
|
+
get component() {
|
|
527
|
+
return e.tag;
|
|
528
|
+
},
|
|
529
|
+
get children() {
|
|
530
|
+
return n();
|
|
531
|
+
}
|
|
532
|
+
}) : c(n));
|
|
533
|
+
};
|
|
534
|
+
//#endregion
|
|
535
|
+
//#region src/components/DateTime.tsx
|
|
536
|
+
function G(e) {
|
|
537
|
+
let { d: t } = T();
|
|
538
|
+
return c(() => t(e.value, e.format));
|
|
539
|
+
}
|
|
540
|
+
//#endregion
|
|
541
|
+
//#region src/components/NumberFormat.tsx
|
|
542
|
+
function K(e) {
|
|
543
|
+
let { n: t } = T();
|
|
544
|
+
return c(() => t(e.value, e.format));
|
|
545
|
+
}
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region src/compiled.tsx
|
|
548
|
+
var q = (e) => {
|
|
549
|
+
let { t } = T();
|
|
550
|
+
return (() => {
|
|
551
|
+
let n = t({
|
|
552
|
+
id: e.id ?? f(e.message, e.context),
|
|
553
|
+
message: e.message,
|
|
554
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
555
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
556
|
+
}), r = e.components && e.components.length > 0 ? j(n, e.components) : n;
|
|
557
|
+
return e.tag ? s(o, {
|
|
558
|
+
get component() {
|
|
559
|
+
return e.tag;
|
|
560
|
+
},
|
|
561
|
+
children: r
|
|
562
|
+
}) : r;
|
|
563
|
+
});
|
|
564
|
+
}, J = (e) => {
|
|
565
|
+
let { t } = T();
|
|
566
|
+
return (() => {
|
|
567
|
+
let n = t({
|
|
568
|
+
id: z(e.id, e.message, e.context),
|
|
569
|
+
message: e.message,
|
|
570
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
571
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
572
|
+
}, { count: e.value });
|
|
573
|
+
return e.tag ? s(o, {
|
|
574
|
+
get component() {
|
|
575
|
+
return e.tag;
|
|
576
|
+
},
|
|
577
|
+
children: n
|
|
578
|
+
}) : n;
|
|
579
|
+
});
|
|
580
|
+
}, Y = (e) => {
|
|
581
|
+
let { t } = T();
|
|
582
|
+
return (() => {
|
|
583
|
+
let n = t({
|
|
584
|
+
id: z(e.id, e.message, e.context),
|
|
585
|
+
message: e.message,
|
|
586
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
587
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
588
|
+
}, { value: e.valueMap?.[e.value] ?? "other" });
|
|
589
|
+
return e.tag ? s(o, {
|
|
590
|
+
get component() {
|
|
591
|
+
return e.tag;
|
|
592
|
+
},
|
|
593
|
+
children: n
|
|
594
|
+
}) : n;
|
|
595
|
+
});
|
|
596
|
+
}, X = (e) => {
|
|
597
|
+
let { t } = T();
|
|
598
|
+
return (() => {
|
|
599
|
+
let n = t({
|
|
600
|
+
id: z(e.id, e.message, e.context),
|
|
601
|
+
message: e.message,
|
|
602
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
603
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
604
|
+
}, { count: e.value }), r = e.components.length > 0 ? j(n, e.components) : n;
|
|
605
|
+
return e.tag ? s(o, {
|
|
606
|
+
get component() {
|
|
607
|
+
return e.tag;
|
|
608
|
+
},
|
|
609
|
+
children: r
|
|
610
|
+
}) : r;
|
|
611
|
+
});
|
|
612
|
+
}, Z = (e) => {
|
|
613
|
+
let { t } = T();
|
|
614
|
+
return (() => {
|
|
615
|
+
let n = t({
|
|
616
|
+
id: z(e.id, e.message, e.context),
|
|
617
|
+
message: e.message,
|
|
618
|
+
...e.context === void 0 ? {} : { context: e.context },
|
|
619
|
+
...e.comment === void 0 ? {} : { comment: e.comment }
|
|
620
|
+
}, { value: e.valueMap?.[e.value] ?? "other" }), r = e.components.length > 0 ? j(n, e.components) : n;
|
|
621
|
+
return e.tag ? s(o, {
|
|
622
|
+
get component() {
|
|
623
|
+
return e.tag;
|
|
624
|
+
},
|
|
625
|
+
children: r
|
|
626
|
+
}) : r;
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
//#endregion
|
|
630
|
+
export { q as a, W as c, T as d, E as f, Y as i, U as l, S as m, X as n, K as o, w as p, Z as r, G as s, J as t, L as u };
|
|
631
|
+
|
|
632
|
+
//# sourceMappingURL=components-entry-C-Df62O-.js.map
|