@warp-ds/elements 2.0.0-next.3 → 2.0.0-next.5
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/dist/index.js +345 -377
- package/dist/index.js.map +4 -4
- package/dist/packages/affix/index.d.ts +13 -6
- package/dist/packages/affix/index.js +32 -65
- package/dist/packages/affix/index.js.map +4 -4
- package/dist/packages/alert/index.js +10 -60
- package/dist/packages/alert/index.js.map +3 -3
- package/dist/packages/attention/index.js +39 -80
- package/dist/packages/attention/index.js.map +4 -4
- package/dist/packages/badge/index.js +26 -72
- package/dist/packages/badge/index.js.map +4 -4
- package/dist/packages/box/index.d.ts +1 -1
- package/dist/packages/box/index.js +25 -64
- package/dist/packages/box/index.js.map +4 -4
- package/dist/packages/breadcrumbs/index.js +8 -52
- package/dist/packages/breadcrumbs/index.js.map +3 -3
- package/dist/packages/button/index.d.ts +6 -0
- package/dist/packages/button/index.js +66 -103
- package/dist/packages/button/index.js.map +3 -3
- package/dist/packages/card/index.d.ts +5 -5
- package/dist/packages/card/index.js +1461 -91
- package/dist/packages/card/index.js.map +4 -4
- package/dist/packages/card/locales/da/messages.d.mts +1 -0
- package/dist/packages/card/locales/en/messages.d.mts +1 -0
- package/dist/packages/card/locales/fi/messages.d.mts +1 -0
- package/dist/packages/card/locales/nb/messages.d.mts +1 -0
- package/dist/packages/expandable/index.d.ts +1 -6
- package/dist/packages/expandable/index.js +70 -85
- package/dist/packages/expandable/index.js.map +4 -4
- package/dist/packages/modal/index.js +7 -51
- package/dist/packages/modal/index.js.map +3 -3
- package/dist/packages/pill/index.js +16 -64
- package/dist/packages/pill/index.js.map +3 -3
- package/dist/packages/select/index.d.ts +10 -0
- package/dist/packages/select/index.js +42 -72
- package/dist/packages/select/index.js.map +3 -3
- package/dist/packages/textfield/index.d.ts +9 -5
- package/dist/packages/textfield/index.js +49 -76
- package/dist/packages/textfield/index.js.map +4 -4
- package/dist/packages/toast/index.js +55 -90
- package/dist/packages/toast/index.js.map +4 -4
- package/dist/packages/toast/toast.d.ts +1 -2
- package/dist/packages/utils/index.d.ts +1 -1
- package/dist/packages/utils/unstyled-heading.d.ts +1 -1
- package/package.json +4 -4
|
@@ -1,57 +1,1403 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2
9
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __objRest = (source, exclude) => {
|
|
22
|
+
var target = {};
|
|
23
|
+
for (var prop in source)
|
|
24
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
25
|
+
target[prop] = source[prop];
|
|
26
|
+
if (source != null && __getOwnPropSymbols)
|
|
27
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
28
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
29
|
+
target[prop] = source[prop];
|
|
30
|
+
}
|
|
31
|
+
return target;
|
|
32
|
+
};
|
|
33
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
34
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
35
|
+
};
|
|
36
|
+
var __copyProps = (to, from, except, desc) => {
|
|
37
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
38
|
+
for (let key of __getOwnPropNames(from))
|
|
39
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
40
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
41
|
+
}
|
|
42
|
+
return to;
|
|
43
|
+
};
|
|
44
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
45
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
46
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
47
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
48
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
49
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
50
|
+
mod
|
|
51
|
+
));
|
|
3
52
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
53
|
|
|
54
|
+
// node_modules/.pnpm/unraw@3.0.0/node_modules/unraw/dist/errors.js
|
|
55
|
+
var require_errors = __commonJS({
|
|
56
|
+
"node_modules/.pnpm/unraw@3.0.0/node_modules/unraw/dist/errors.js"(exports) {
|
|
57
|
+
"use strict";
|
|
58
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
59
|
+
exports.errorMessages = exports.ErrorType = void 0;
|
|
60
|
+
var ErrorType;
|
|
61
|
+
(function(ErrorType2) {
|
|
62
|
+
ErrorType2["MalformedUnicode"] = "MALFORMED_UNICODE";
|
|
63
|
+
ErrorType2["MalformedHexadecimal"] = "MALFORMED_HEXADECIMAL";
|
|
64
|
+
ErrorType2["CodePointLimit"] = "CODE_POINT_LIMIT";
|
|
65
|
+
ErrorType2["OctalDeprecation"] = "OCTAL_DEPRECATION";
|
|
66
|
+
ErrorType2["EndOfString"] = "END_OF_STRING";
|
|
67
|
+
})(ErrorType = exports.ErrorType || (exports.ErrorType = {}));
|
|
68
|
+
exports.errorMessages = /* @__PURE__ */ new Map([
|
|
69
|
+
[ErrorType.MalformedUnicode, "malformed Unicode character escape sequence"],
|
|
70
|
+
[
|
|
71
|
+
ErrorType.MalformedHexadecimal,
|
|
72
|
+
"malformed hexadecimal character escape sequence"
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
ErrorType.CodePointLimit,
|
|
76
|
+
"Unicode codepoint must not be greater than 0x10FFFF in escape sequence"
|
|
77
|
+
],
|
|
78
|
+
[
|
|
79
|
+
ErrorType.OctalDeprecation,
|
|
80
|
+
'"0"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the "0o" prefix instead'
|
|
81
|
+
],
|
|
82
|
+
[ErrorType.EndOfString, "malformed escape sequence at end of string"]
|
|
83
|
+
]);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// node_modules/.pnpm/unraw@3.0.0/node_modules/unraw/dist/index.js
|
|
88
|
+
var require_dist = __commonJS({
|
|
89
|
+
"node_modules/.pnpm/unraw@3.0.0/node_modules/unraw/dist/index.js"(exports) {
|
|
90
|
+
"use strict";
|
|
91
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
92
|
+
exports.unraw = exports.errorMessages = exports.ErrorType = void 0;
|
|
93
|
+
var errors_1 = require_errors();
|
|
94
|
+
Object.defineProperty(exports, "ErrorType", { enumerable: true, get: function() {
|
|
95
|
+
return errors_1.ErrorType;
|
|
96
|
+
} });
|
|
97
|
+
Object.defineProperty(exports, "errorMessages", { enumerable: true, get: function() {
|
|
98
|
+
return errors_1.errorMessages;
|
|
99
|
+
} });
|
|
100
|
+
function parseHexToInt(hex) {
|
|
101
|
+
const isOnlyHexChars = !hex.match(/[^a-f0-9]/i);
|
|
102
|
+
return isOnlyHexChars ? parseInt(hex, 16) : NaN;
|
|
103
|
+
}
|
|
104
|
+
function validateAndParseHex(hex, errorName, enforcedLength) {
|
|
105
|
+
const parsedHex = parseHexToInt(hex);
|
|
106
|
+
if (Number.isNaN(parsedHex) || enforcedLength !== void 0 && enforcedLength !== hex.length) {
|
|
107
|
+
throw new SyntaxError(errors_1.errorMessages.get(errorName));
|
|
108
|
+
}
|
|
109
|
+
return parsedHex;
|
|
110
|
+
}
|
|
111
|
+
function parseHexadecimalCode(code) {
|
|
112
|
+
const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedHexadecimal, 2);
|
|
113
|
+
return String.fromCharCode(parsedCode);
|
|
114
|
+
}
|
|
115
|
+
function parseUnicodeCode(code, surrogateCode) {
|
|
116
|
+
const parsedCode = validateAndParseHex(code, errors_1.ErrorType.MalformedUnicode, 4);
|
|
117
|
+
if (surrogateCode !== void 0) {
|
|
118
|
+
const parsedSurrogateCode = validateAndParseHex(surrogateCode, errors_1.ErrorType.MalformedUnicode, 4);
|
|
119
|
+
return String.fromCharCode(parsedCode, parsedSurrogateCode);
|
|
120
|
+
}
|
|
121
|
+
return String.fromCharCode(parsedCode);
|
|
122
|
+
}
|
|
123
|
+
function isCurlyBraced(text) {
|
|
124
|
+
return text.charAt(0) === "{" && text.charAt(text.length - 1) === "}";
|
|
125
|
+
}
|
|
126
|
+
function parseUnicodeCodePointCode(codePoint) {
|
|
127
|
+
if (!isCurlyBraced(codePoint)) {
|
|
128
|
+
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.MalformedUnicode));
|
|
129
|
+
}
|
|
130
|
+
const withoutBraces = codePoint.slice(1, -1);
|
|
131
|
+
const parsedCode = validateAndParseHex(withoutBraces, errors_1.ErrorType.MalformedUnicode);
|
|
132
|
+
try {
|
|
133
|
+
return String.fromCodePoint(parsedCode);
|
|
134
|
+
} catch (err) {
|
|
135
|
+
throw err instanceof RangeError ? new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.CodePointLimit)) : err;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function parseOctalCode(code, error = false) {
|
|
139
|
+
if (error) {
|
|
140
|
+
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.OctalDeprecation));
|
|
141
|
+
}
|
|
142
|
+
const parsedCode = parseInt(code, 8);
|
|
143
|
+
return String.fromCharCode(parsedCode);
|
|
144
|
+
}
|
|
145
|
+
var singleCharacterEscapes = /* @__PURE__ */ new Map([
|
|
146
|
+
["b", "\b"],
|
|
147
|
+
["f", "\f"],
|
|
148
|
+
["n", "\n"],
|
|
149
|
+
["r", "\r"],
|
|
150
|
+
["t", " "],
|
|
151
|
+
["v", "\v"],
|
|
152
|
+
["0", "\0"]
|
|
153
|
+
]);
|
|
154
|
+
function parseSingleCharacterCode(code) {
|
|
155
|
+
return singleCharacterEscapes.get(code) || code;
|
|
156
|
+
}
|
|
157
|
+
var escapeMatch = /\\(?:(\\)|x([\s\S]{0,2})|u(\{[^}]*\}?)|u([\s\S]{4})\\u([^{][\s\S]{0,3})|u([\s\S]{0,4})|([0-3]?[0-7]{1,2})|([\s\S])|$)/g;
|
|
158
|
+
function unraw2(raw, allowOctals = false) {
|
|
159
|
+
return raw.replace(escapeMatch, function(_, backslash, hex, codePoint, unicodeWithSurrogate, surrogate, unicode, octal, singleCharacter) {
|
|
160
|
+
if (backslash !== void 0) {
|
|
161
|
+
return "\\";
|
|
162
|
+
}
|
|
163
|
+
if (hex !== void 0) {
|
|
164
|
+
return parseHexadecimalCode(hex);
|
|
165
|
+
}
|
|
166
|
+
if (codePoint !== void 0) {
|
|
167
|
+
return parseUnicodeCodePointCode(codePoint);
|
|
168
|
+
}
|
|
169
|
+
if (unicodeWithSurrogate !== void 0) {
|
|
170
|
+
return parseUnicodeCode(unicodeWithSurrogate, surrogate);
|
|
171
|
+
}
|
|
172
|
+
if (unicode !== void 0) {
|
|
173
|
+
return parseUnicodeCode(unicode);
|
|
174
|
+
}
|
|
175
|
+
if (octal === "0") {
|
|
176
|
+
return "\0";
|
|
177
|
+
}
|
|
178
|
+
if (octal !== void 0) {
|
|
179
|
+
return parseOctalCode(octal, !allowOctals);
|
|
180
|
+
}
|
|
181
|
+
if (singleCharacter !== void 0) {
|
|
182
|
+
return parseSingleCharacterCode(singleCharacter);
|
|
183
|
+
}
|
|
184
|
+
throw new SyntaxError(errors_1.errorMessages.get(errors_1.ErrorType.EndOfString));
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
exports.unraw = unraw2;
|
|
188
|
+
exports.default = unraw2;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// node_modules/.pnpm/moo@0.5.2/node_modules/moo/moo.js
|
|
193
|
+
var require_moo = __commonJS({
|
|
194
|
+
"node_modules/.pnpm/moo@0.5.2/node_modules/moo/moo.js"(exports, module) {
|
|
195
|
+
(function(root, factory) {
|
|
196
|
+
if (typeof define === "function" && define.amd) {
|
|
197
|
+
define([], factory);
|
|
198
|
+
} else if (typeof module === "object" && module.exports) {
|
|
199
|
+
module.exports = factory();
|
|
200
|
+
} else {
|
|
201
|
+
root.moo = factory();
|
|
202
|
+
}
|
|
203
|
+
})(exports, function() {
|
|
204
|
+
"use strict";
|
|
205
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
206
|
+
var toString = Object.prototype.toString;
|
|
207
|
+
var hasSticky = typeof new RegExp().sticky === "boolean";
|
|
208
|
+
function isRegExp(o) {
|
|
209
|
+
return o && toString.call(o) === "[object RegExp]";
|
|
210
|
+
}
|
|
211
|
+
function isObject(o) {
|
|
212
|
+
return o && typeof o === "object" && !isRegExp(o) && !Array.isArray(o);
|
|
213
|
+
}
|
|
214
|
+
function reEscape(s) {
|
|
215
|
+
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
216
|
+
}
|
|
217
|
+
function reGroups(s) {
|
|
218
|
+
var re = new RegExp("|" + s);
|
|
219
|
+
return re.exec("").length - 1;
|
|
220
|
+
}
|
|
221
|
+
function reCapture(s) {
|
|
222
|
+
return "(" + s + ")";
|
|
223
|
+
}
|
|
224
|
+
function reUnion(regexps) {
|
|
225
|
+
if (!regexps.length) return "(?!)";
|
|
226
|
+
var source = regexps.map(function(s) {
|
|
227
|
+
return "(?:" + s + ")";
|
|
228
|
+
}).join("|");
|
|
229
|
+
return "(?:" + source + ")";
|
|
230
|
+
}
|
|
231
|
+
function regexpOrLiteral(obj) {
|
|
232
|
+
if (typeof obj === "string") {
|
|
233
|
+
return "(?:" + reEscape(obj) + ")";
|
|
234
|
+
} else if (isRegExp(obj)) {
|
|
235
|
+
if (obj.ignoreCase) throw new Error("RegExp /i flag not allowed");
|
|
236
|
+
if (obj.global) throw new Error("RegExp /g flag is implied");
|
|
237
|
+
if (obj.sticky) throw new Error("RegExp /y flag is implied");
|
|
238
|
+
if (obj.multiline) throw new Error("RegExp /m flag is implied");
|
|
239
|
+
return obj.source;
|
|
240
|
+
} else {
|
|
241
|
+
throw new Error("Not a pattern: " + obj);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function pad(s, length) {
|
|
245
|
+
if (s.length > length) {
|
|
246
|
+
return s;
|
|
247
|
+
}
|
|
248
|
+
return Array(length - s.length + 1).join(" ") + s;
|
|
249
|
+
}
|
|
250
|
+
function lastNLines(string, numLines) {
|
|
251
|
+
var position = string.length;
|
|
252
|
+
var lineBreaks = 0;
|
|
253
|
+
while (true) {
|
|
254
|
+
var idx = string.lastIndexOf("\n", position - 1);
|
|
255
|
+
if (idx === -1) {
|
|
256
|
+
break;
|
|
257
|
+
} else {
|
|
258
|
+
lineBreaks++;
|
|
259
|
+
}
|
|
260
|
+
position = idx;
|
|
261
|
+
if (lineBreaks === numLines) {
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
if (position === 0) {
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
var startPosition = lineBreaks < numLines ? 0 : position + 1;
|
|
269
|
+
return string.substring(startPosition).split("\n");
|
|
270
|
+
}
|
|
271
|
+
function objectToRules(object) {
|
|
272
|
+
var keys2 = Object.getOwnPropertyNames(object);
|
|
273
|
+
var result = [];
|
|
274
|
+
for (var i = 0; i < keys2.length; i++) {
|
|
275
|
+
var key = keys2[i];
|
|
276
|
+
var thing = object[key];
|
|
277
|
+
var rules = [].concat(thing);
|
|
278
|
+
if (key === "include") {
|
|
279
|
+
for (var j = 0; j < rules.length; j++) {
|
|
280
|
+
result.push({ include: rules[j] });
|
|
281
|
+
}
|
|
282
|
+
continue;
|
|
283
|
+
}
|
|
284
|
+
var match = [];
|
|
285
|
+
rules.forEach(function(rule) {
|
|
286
|
+
if (isObject(rule)) {
|
|
287
|
+
if (match.length) result.push(ruleOptions(key, match));
|
|
288
|
+
result.push(ruleOptions(key, rule));
|
|
289
|
+
match = [];
|
|
290
|
+
} else {
|
|
291
|
+
match.push(rule);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
if (match.length) result.push(ruleOptions(key, match));
|
|
295
|
+
}
|
|
296
|
+
return result;
|
|
297
|
+
}
|
|
298
|
+
function arrayToRules(array) {
|
|
299
|
+
var result = [];
|
|
300
|
+
for (var i = 0; i < array.length; i++) {
|
|
301
|
+
var obj = array[i];
|
|
302
|
+
if (obj.include) {
|
|
303
|
+
var include = [].concat(obj.include);
|
|
304
|
+
for (var j = 0; j < include.length; j++) {
|
|
305
|
+
result.push({ include: include[j] });
|
|
306
|
+
}
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (!obj.type) {
|
|
310
|
+
throw new Error("Rule has no type: " + JSON.stringify(obj));
|
|
311
|
+
}
|
|
312
|
+
result.push(ruleOptions(obj.type, obj));
|
|
313
|
+
}
|
|
314
|
+
return result;
|
|
315
|
+
}
|
|
316
|
+
function ruleOptions(type, obj) {
|
|
317
|
+
if (!isObject(obj)) {
|
|
318
|
+
obj = { match: obj };
|
|
319
|
+
}
|
|
320
|
+
if (obj.include) {
|
|
321
|
+
throw new Error("Matching rules cannot also include states");
|
|
322
|
+
}
|
|
323
|
+
var options = {
|
|
324
|
+
defaultType: type,
|
|
325
|
+
lineBreaks: !!obj.error || !!obj.fallback,
|
|
326
|
+
pop: false,
|
|
327
|
+
next: null,
|
|
328
|
+
push: null,
|
|
329
|
+
error: false,
|
|
330
|
+
fallback: false,
|
|
331
|
+
value: null,
|
|
332
|
+
type: null,
|
|
333
|
+
shouldThrow: false
|
|
334
|
+
};
|
|
335
|
+
for (var key in obj) {
|
|
336
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
337
|
+
options[key] = obj[key];
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (typeof options.type === "string" && type !== options.type) {
|
|
341
|
+
throw new Error("Type transform cannot be a string (type '" + options.type + "' for token '" + type + "')");
|
|
342
|
+
}
|
|
343
|
+
var match = options.match;
|
|
344
|
+
options.match = Array.isArray(match) ? match : match ? [match] : [];
|
|
345
|
+
options.match.sort(function(a, b) {
|
|
346
|
+
return isRegExp(a) && isRegExp(b) ? 0 : isRegExp(b) ? -1 : isRegExp(a) ? 1 : b.length - a.length;
|
|
347
|
+
});
|
|
348
|
+
return options;
|
|
349
|
+
}
|
|
350
|
+
function toRules(spec) {
|
|
351
|
+
return Array.isArray(spec) ? arrayToRules(spec) : objectToRules(spec);
|
|
352
|
+
}
|
|
353
|
+
var defaultErrorRule = ruleOptions("error", { lineBreaks: true, shouldThrow: true });
|
|
354
|
+
function compileRules(rules, hasStates) {
|
|
355
|
+
var errorRule = null;
|
|
356
|
+
var fast = /* @__PURE__ */ Object.create(null);
|
|
357
|
+
var fastAllowed = true;
|
|
358
|
+
var unicodeFlag = null;
|
|
359
|
+
var groups = [];
|
|
360
|
+
var parts = [];
|
|
361
|
+
for (var i = 0; i < rules.length; i++) {
|
|
362
|
+
if (rules[i].fallback) {
|
|
363
|
+
fastAllowed = false;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
for (var i = 0; i < rules.length; i++) {
|
|
367
|
+
var options = rules[i];
|
|
368
|
+
if (options.include) {
|
|
369
|
+
throw new Error("Inheritance is not allowed in stateless lexers");
|
|
370
|
+
}
|
|
371
|
+
if (options.error || options.fallback) {
|
|
372
|
+
if (errorRule) {
|
|
373
|
+
if (!options.fallback === !errorRule.fallback) {
|
|
374
|
+
throw new Error("Multiple " + (options.fallback ? "fallback" : "error") + " rules not allowed (for token '" + options.defaultType + "')");
|
|
375
|
+
} else {
|
|
376
|
+
throw new Error("fallback and error are mutually exclusive (for token '" + options.defaultType + "')");
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
errorRule = options;
|
|
380
|
+
}
|
|
381
|
+
var match = options.match.slice();
|
|
382
|
+
if (fastAllowed) {
|
|
383
|
+
while (match.length && typeof match[0] === "string" && match[0].length === 1) {
|
|
384
|
+
var word = match.shift();
|
|
385
|
+
fast[word.charCodeAt(0)] = options;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
if (options.pop || options.push || options.next) {
|
|
389
|
+
if (!hasStates) {
|
|
390
|
+
throw new Error("State-switching options are not allowed in stateless lexers (for token '" + options.defaultType + "')");
|
|
391
|
+
}
|
|
392
|
+
if (options.fallback) {
|
|
393
|
+
throw new Error("State-switching options are not allowed on fallback tokens (for token '" + options.defaultType + "')");
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
if (match.length === 0) {
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
fastAllowed = false;
|
|
400
|
+
groups.push(options);
|
|
401
|
+
for (var j = 0; j < match.length; j++) {
|
|
402
|
+
var obj = match[j];
|
|
403
|
+
if (!isRegExp(obj)) {
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
if (unicodeFlag === null) {
|
|
407
|
+
unicodeFlag = obj.unicode;
|
|
408
|
+
} else if (unicodeFlag !== obj.unicode && options.fallback === false) {
|
|
409
|
+
throw new Error("If one rule is /u then all must be");
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
var pat = reUnion(match.map(regexpOrLiteral));
|
|
413
|
+
var regexp = new RegExp(pat);
|
|
414
|
+
if (regexp.test("")) {
|
|
415
|
+
throw new Error("RegExp matches empty string: " + regexp);
|
|
416
|
+
}
|
|
417
|
+
var groupCount = reGroups(pat);
|
|
418
|
+
if (groupCount > 0) {
|
|
419
|
+
throw new Error("RegExp has capture groups: " + regexp + "\nUse (?: \u2026 ) instead");
|
|
420
|
+
}
|
|
421
|
+
if (!options.lineBreaks && regexp.test("\n")) {
|
|
422
|
+
throw new Error("Rule should declare lineBreaks: " + regexp);
|
|
423
|
+
}
|
|
424
|
+
parts.push(reCapture(pat));
|
|
425
|
+
}
|
|
426
|
+
var fallbackRule = errorRule && errorRule.fallback;
|
|
427
|
+
var flags = hasSticky && !fallbackRule ? "ym" : "gm";
|
|
428
|
+
var suffix2 = hasSticky || fallbackRule ? "" : "|";
|
|
429
|
+
if (unicodeFlag === true) flags += "u";
|
|
430
|
+
var combined = new RegExp(reUnion(parts) + suffix2, flags);
|
|
431
|
+
return { regexp: combined, groups, fast, error: errorRule || defaultErrorRule };
|
|
432
|
+
}
|
|
433
|
+
function compile(rules) {
|
|
434
|
+
var result = compileRules(toRules(rules));
|
|
435
|
+
return new Lexer({ start: result }, "start");
|
|
436
|
+
}
|
|
437
|
+
function checkStateGroup(g, name, map) {
|
|
438
|
+
var state = g && (g.push || g.next);
|
|
439
|
+
if (state && !map[state]) {
|
|
440
|
+
throw new Error("Missing state '" + state + "' (in token '" + g.defaultType + "' of state '" + name + "')");
|
|
441
|
+
}
|
|
442
|
+
if (g && g.pop && +g.pop !== 1) {
|
|
443
|
+
throw new Error("pop must be 1 (in token '" + g.defaultType + "' of state '" + name + "')");
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
function compileStates(states, start) {
|
|
447
|
+
var all = states.$all ? toRules(states.$all) : [];
|
|
448
|
+
delete states.$all;
|
|
449
|
+
var keys2 = Object.getOwnPropertyNames(states);
|
|
450
|
+
if (!start) start = keys2[0];
|
|
451
|
+
var ruleMap = /* @__PURE__ */ Object.create(null);
|
|
452
|
+
for (var i = 0; i < keys2.length; i++) {
|
|
453
|
+
var key = keys2[i];
|
|
454
|
+
ruleMap[key] = toRules(states[key]).concat(all);
|
|
455
|
+
}
|
|
456
|
+
for (var i = 0; i < keys2.length; i++) {
|
|
457
|
+
var key = keys2[i];
|
|
458
|
+
var rules = ruleMap[key];
|
|
459
|
+
var included = /* @__PURE__ */ Object.create(null);
|
|
460
|
+
for (var j = 0; j < rules.length; j++) {
|
|
461
|
+
var rule = rules[j];
|
|
462
|
+
if (!rule.include) continue;
|
|
463
|
+
var splice = [j, 1];
|
|
464
|
+
if (rule.include !== key && !included[rule.include]) {
|
|
465
|
+
included[rule.include] = true;
|
|
466
|
+
var newRules = ruleMap[rule.include];
|
|
467
|
+
if (!newRules) {
|
|
468
|
+
throw new Error("Cannot include nonexistent state '" + rule.include + "' (in state '" + key + "')");
|
|
469
|
+
}
|
|
470
|
+
for (var k = 0; k < newRules.length; k++) {
|
|
471
|
+
var newRule = newRules[k];
|
|
472
|
+
if (rules.indexOf(newRule) !== -1) continue;
|
|
473
|
+
splice.push(newRule);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
rules.splice.apply(rules, splice);
|
|
477
|
+
j--;
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
var map = /* @__PURE__ */ Object.create(null);
|
|
481
|
+
for (var i = 0; i < keys2.length; i++) {
|
|
482
|
+
var key = keys2[i];
|
|
483
|
+
map[key] = compileRules(ruleMap[key], true);
|
|
484
|
+
}
|
|
485
|
+
for (var i = 0; i < keys2.length; i++) {
|
|
486
|
+
var name = keys2[i];
|
|
487
|
+
var state = map[name];
|
|
488
|
+
var groups = state.groups;
|
|
489
|
+
for (var j = 0; j < groups.length; j++) {
|
|
490
|
+
checkStateGroup(groups[j], name, map);
|
|
491
|
+
}
|
|
492
|
+
var fastKeys = Object.getOwnPropertyNames(state.fast);
|
|
493
|
+
for (var j = 0; j < fastKeys.length; j++) {
|
|
494
|
+
checkStateGroup(state.fast[fastKeys[j]], name, map);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
return new Lexer(map, start);
|
|
498
|
+
}
|
|
499
|
+
function keywordTransform(map) {
|
|
500
|
+
var isMap = typeof Map !== "undefined";
|
|
501
|
+
var reverseMap = isMap ? /* @__PURE__ */ new Map() : /* @__PURE__ */ Object.create(null);
|
|
502
|
+
var types = Object.getOwnPropertyNames(map);
|
|
503
|
+
for (var i = 0; i < types.length; i++) {
|
|
504
|
+
var tokenType = types[i];
|
|
505
|
+
var item = map[tokenType];
|
|
506
|
+
var keywordList = Array.isArray(item) ? item : [item];
|
|
507
|
+
keywordList.forEach(function(keyword) {
|
|
508
|
+
if (typeof keyword !== "string") {
|
|
509
|
+
throw new Error("keyword must be string (in keyword '" + tokenType + "')");
|
|
510
|
+
}
|
|
511
|
+
if (isMap) {
|
|
512
|
+
reverseMap.set(keyword, tokenType);
|
|
513
|
+
} else {
|
|
514
|
+
reverseMap[keyword] = tokenType;
|
|
515
|
+
}
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
return function(k) {
|
|
519
|
+
return isMap ? reverseMap.get(k) : reverseMap[k];
|
|
520
|
+
};
|
|
521
|
+
}
|
|
522
|
+
var Lexer = function(states, state) {
|
|
523
|
+
this.startState = state;
|
|
524
|
+
this.states = states;
|
|
525
|
+
this.buffer = "";
|
|
526
|
+
this.stack = [];
|
|
527
|
+
this.reset();
|
|
528
|
+
};
|
|
529
|
+
Lexer.prototype.reset = function(data, info) {
|
|
530
|
+
this.buffer = data || "";
|
|
531
|
+
this.index = 0;
|
|
532
|
+
this.line = info ? info.line : 1;
|
|
533
|
+
this.col = info ? info.col : 1;
|
|
534
|
+
this.queuedToken = info ? info.queuedToken : null;
|
|
535
|
+
this.queuedText = info ? info.queuedText : "";
|
|
536
|
+
this.queuedThrow = info ? info.queuedThrow : null;
|
|
537
|
+
this.setState(info ? info.state : this.startState);
|
|
538
|
+
this.stack = info && info.stack ? info.stack.slice() : [];
|
|
539
|
+
return this;
|
|
540
|
+
};
|
|
541
|
+
Lexer.prototype.save = function() {
|
|
542
|
+
return {
|
|
543
|
+
line: this.line,
|
|
544
|
+
col: this.col,
|
|
545
|
+
state: this.state,
|
|
546
|
+
stack: this.stack.slice(),
|
|
547
|
+
queuedToken: this.queuedToken,
|
|
548
|
+
queuedText: this.queuedText,
|
|
549
|
+
queuedThrow: this.queuedThrow
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
Lexer.prototype.setState = function(state) {
|
|
553
|
+
if (!state || this.state === state) return;
|
|
554
|
+
this.state = state;
|
|
555
|
+
var info = this.states[state];
|
|
556
|
+
this.groups = info.groups;
|
|
557
|
+
this.error = info.error;
|
|
558
|
+
this.re = info.regexp;
|
|
559
|
+
this.fast = info.fast;
|
|
560
|
+
};
|
|
561
|
+
Lexer.prototype.popState = function() {
|
|
562
|
+
this.setState(this.stack.pop());
|
|
563
|
+
};
|
|
564
|
+
Lexer.prototype.pushState = function(state) {
|
|
565
|
+
this.stack.push(this.state);
|
|
566
|
+
this.setState(state);
|
|
567
|
+
};
|
|
568
|
+
var eat = hasSticky ? function(re, buffer) {
|
|
569
|
+
return re.exec(buffer);
|
|
570
|
+
} : function(re, buffer) {
|
|
571
|
+
var match = re.exec(buffer);
|
|
572
|
+
if (match[0].length === 0) {
|
|
573
|
+
return null;
|
|
574
|
+
}
|
|
575
|
+
return match;
|
|
576
|
+
};
|
|
577
|
+
Lexer.prototype._getGroup = function(match) {
|
|
578
|
+
var groupCount = this.groups.length;
|
|
579
|
+
for (var i = 0; i < groupCount; i++) {
|
|
580
|
+
if (match[i + 1] !== void 0) {
|
|
581
|
+
return this.groups[i];
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
throw new Error("Cannot find token type for matched text");
|
|
585
|
+
};
|
|
586
|
+
function tokenToString() {
|
|
587
|
+
return this.value;
|
|
588
|
+
}
|
|
589
|
+
Lexer.prototype.next = function() {
|
|
590
|
+
var index = this.index;
|
|
591
|
+
if (this.queuedGroup) {
|
|
592
|
+
var token = this._token(this.queuedGroup, this.queuedText, index);
|
|
593
|
+
this.queuedGroup = null;
|
|
594
|
+
this.queuedText = "";
|
|
595
|
+
return token;
|
|
596
|
+
}
|
|
597
|
+
var buffer = this.buffer;
|
|
598
|
+
if (index === buffer.length) {
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
var group = this.fast[buffer.charCodeAt(index)];
|
|
602
|
+
if (group) {
|
|
603
|
+
return this._token(group, buffer.charAt(index), index);
|
|
604
|
+
}
|
|
605
|
+
var re = this.re;
|
|
606
|
+
re.lastIndex = index;
|
|
607
|
+
var match = eat(re, buffer);
|
|
608
|
+
var error = this.error;
|
|
609
|
+
if (match == null) {
|
|
610
|
+
return this._token(error, buffer.slice(index, buffer.length), index);
|
|
611
|
+
}
|
|
612
|
+
var group = this._getGroup(match);
|
|
613
|
+
var text = match[0];
|
|
614
|
+
if (error.fallback && match.index !== index) {
|
|
615
|
+
this.queuedGroup = group;
|
|
616
|
+
this.queuedText = text;
|
|
617
|
+
return this._token(error, buffer.slice(index, match.index), index);
|
|
618
|
+
}
|
|
619
|
+
return this._token(group, text, index);
|
|
620
|
+
};
|
|
621
|
+
Lexer.prototype._token = function(group, text, offset) {
|
|
622
|
+
var lineBreaks = 0;
|
|
623
|
+
if (group.lineBreaks) {
|
|
624
|
+
var matchNL = /\n/g;
|
|
625
|
+
var nl = 1;
|
|
626
|
+
if (text === "\n") {
|
|
627
|
+
lineBreaks = 1;
|
|
628
|
+
} else {
|
|
629
|
+
while (matchNL.exec(text)) {
|
|
630
|
+
lineBreaks++;
|
|
631
|
+
nl = matchNL.lastIndex;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
var token = {
|
|
636
|
+
type: typeof group.type === "function" && group.type(text) || group.defaultType,
|
|
637
|
+
value: typeof group.value === "function" ? group.value(text) : text,
|
|
638
|
+
text,
|
|
639
|
+
toString: tokenToString,
|
|
640
|
+
offset,
|
|
641
|
+
lineBreaks,
|
|
642
|
+
line: this.line,
|
|
643
|
+
col: this.col
|
|
644
|
+
};
|
|
645
|
+
var size = text.length;
|
|
646
|
+
this.index += size;
|
|
647
|
+
this.line += lineBreaks;
|
|
648
|
+
if (lineBreaks !== 0) {
|
|
649
|
+
this.col = size - nl + 1;
|
|
650
|
+
} else {
|
|
651
|
+
this.col += size;
|
|
652
|
+
}
|
|
653
|
+
if (group.shouldThrow) {
|
|
654
|
+
var err = new Error(this.formatError(token, "invalid syntax"));
|
|
655
|
+
throw err;
|
|
656
|
+
}
|
|
657
|
+
if (group.pop) this.popState();
|
|
658
|
+
else if (group.push) this.pushState(group.push);
|
|
659
|
+
else if (group.next) this.setState(group.next);
|
|
660
|
+
return token;
|
|
661
|
+
};
|
|
662
|
+
if (typeof Symbol !== "undefined" && Symbol.iterator) {
|
|
663
|
+
var LexerIterator = function(lexer) {
|
|
664
|
+
this.lexer = lexer;
|
|
665
|
+
};
|
|
666
|
+
LexerIterator.prototype.next = function() {
|
|
667
|
+
var token = this.lexer.next();
|
|
668
|
+
return { value: token, done: !token };
|
|
669
|
+
};
|
|
670
|
+
LexerIterator.prototype[Symbol.iterator] = function() {
|
|
671
|
+
return this;
|
|
672
|
+
};
|
|
673
|
+
Lexer.prototype[Symbol.iterator] = function() {
|
|
674
|
+
return new LexerIterator(this);
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
Lexer.prototype.formatError = function(token, message) {
|
|
678
|
+
if (token == null) {
|
|
679
|
+
var text = this.buffer.slice(this.index);
|
|
680
|
+
var token = {
|
|
681
|
+
text,
|
|
682
|
+
offset: this.index,
|
|
683
|
+
lineBreaks: text.indexOf("\n") === -1 ? 0 : 1,
|
|
684
|
+
line: this.line,
|
|
685
|
+
col: this.col
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
var numLinesAround = 2;
|
|
689
|
+
var firstDisplayedLine = Math.max(token.line - numLinesAround, 1);
|
|
690
|
+
var lastDisplayedLine = token.line + numLinesAround;
|
|
691
|
+
var lastLineDigits = String(lastDisplayedLine).length;
|
|
692
|
+
var displayedLines = lastNLines(
|
|
693
|
+
this.buffer,
|
|
694
|
+
this.line - token.line + numLinesAround + 1
|
|
695
|
+
).slice(0, 5);
|
|
696
|
+
var errorLines = [];
|
|
697
|
+
errorLines.push(message + " at line " + token.line + " col " + token.col + ":");
|
|
698
|
+
errorLines.push("");
|
|
699
|
+
for (var i = 0; i < displayedLines.length; i++) {
|
|
700
|
+
var line = displayedLines[i];
|
|
701
|
+
var lineNo = firstDisplayedLine + i;
|
|
702
|
+
errorLines.push(pad(String(lineNo), lastLineDigits) + " " + line);
|
|
703
|
+
if (lineNo === token.line) {
|
|
704
|
+
errorLines.push(pad("", lastLineDigits + token.col + 1) + "^");
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return errorLines.join("\n");
|
|
708
|
+
};
|
|
709
|
+
Lexer.prototype.clone = function() {
|
|
710
|
+
return new Lexer(this.states, this.state);
|
|
711
|
+
};
|
|
712
|
+
Lexer.prototype.has = function(tokenType) {
|
|
713
|
+
return true;
|
|
714
|
+
};
|
|
715
|
+
return {
|
|
716
|
+
compile,
|
|
717
|
+
states: compileStates,
|
|
718
|
+
error: Object.freeze({ error: true }),
|
|
719
|
+
fallback: Object.freeze({ fallback: true }),
|
|
720
|
+
keywords: keywordTransform
|
|
721
|
+
};
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
});
|
|
725
|
+
|
|
726
|
+
// node_modules/.pnpm/@messageformat+parser@5.1.0/node_modules/@messageformat/parser/lib/lexer.js
|
|
727
|
+
var require_lexer = __commonJS({
|
|
728
|
+
"node_modules/.pnpm/@messageformat+parser@5.1.0/node_modules/@messageformat/parser/lib/lexer.js"(exports) {
|
|
729
|
+
"use strict";
|
|
730
|
+
var __importDefault = exports && exports.__importDefault || function(mod) {
|
|
731
|
+
return mod && mod.__esModule ? mod : { "default": mod };
|
|
732
|
+
};
|
|
733
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
734
|
+
exports.lexer = exports.states = void 0;
|
|
735
|
+
var moo_1 = __importDefault(require_moo());
|
|
736
|
+
exports.states = {
|
|
737
|
+
body: {
|
|
738
|
+
doubleapos: { match: "''", value: () => "'" },
|
|
739
|
+
quoted: {
|
|
740
|
+
lineBreaks: true,
|
|
741
|
+
match: /'[{}#](?:[^]*?[^'])?'(?!')/u,
|
|
742
|
+
value: (src) => src.slice(1, -1).replace(/''/g, "'")
|
|
743
|
+
},
|
|
744
|
+
argument: {
|
|
745
|
+
lineBreaks: true,
|
|
746
|
+
match: /\{\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*/u,
|
|
747
|
+
push: "arg",
|
|
748
|
+
value: (src) => src.substring(1).trim()
|
|
749
|
+
},
|
|
750
|
+
octothorpe: "#",
|
|
751
|
+
end: { match: "}", pop: 1 },
|
|
752
|
+
content: { lineBreaks: true, match: /[^][^{}#']*/u }
|
|
753
|
+
},
|
|
754
|
+
arg: {
|
|
755
|
+
select: {
|
|
756
|
+
lineBreaks: true,
|
|
757
|
+
match: /,\s*(?:plural|select|selectordinal)\s*,\s*/u,
|
|
758
|
+
next: "select",
|
|
759
|
+
value: (src) => src.split(",")[1].trim()
|
|
760
|
+
},
|
|
761
|
+
"func-args": {
|
|
762
|
+
lineBreaks: true,
|
|
763
|
+
match: /,\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*,/u,
|
|
764
|
+
next: "body",
|
|
765
|
+
value: (src) => src.split(",")[1].trim()
|
|
766
|
+
},
|
|
767
|
+
"func-simple": {
|
|
768
|
+
lineBreaks: true,
|
|
769
|
+
match: /,\s*[^\p{Pat_Syn}\p{Pat_WS}]+\s*/u,
|
|
770
|
+
value: (src) => src.substring(1).trim()
|
|
771
|
+
},
|
|
772
|
+
end: { match: "}", pop: 1 }
|
|
773
|
+
},
|
|
774
|
+
select: {
|
|
775
|
+
offset: {
|
|
776
|
+
lineBreaks: true,
|
|
777
|
+
match: /\s*offset\s*:\s*\d+\s*/u,
|
|
778
|
+
value: (src) => src.split(":")[1].trim()
|
|
779
|
+
},
|
|
780
|
+
case: {
|
|
781
|
+
lineBreaks: true,
|
|
782
|
+
match: /\s*(?:=\d+|[^\p{Pat_Syn}\p{Pat_WS}]+)\s*\{/u,
|
|
783
|
+
push: "body",
|
|
784
|
+
value: (src) => src.substring(0, src.indexOf("{")).trim()
|
|
785
|
+
},
|
|
786
|
+
end: { match: /\s*\}/u, pop: 1 }
|
|
787
|
+
}
|
|
788
|
+
};
|
|
789
|
+
exports.lexer = moo_1.default.states(exports.states);
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
|
|
793
|
+
// node_modules/.pnpm/@messageformat+parser@5.1.0/node_modules/@messageformat/parser/lib/parser.js
|
|
794
|
+
var require_parser = __commonJS({
|
|
795
|
+
"node_modules/.pnpm/@messageformat+parser@5.1.0/node_modules/@messageformat/parser/lib/parser.js"(exports) {
|
|
796
|
+
"use strict";
|
|
797
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
798
|
+
exports.parse = exports.ParseError = void 0;
|
|
799
|
+
var lexer_js_1 = require_lexer();
|
|
800
|
+
var getContext = (lt) => ({
|
|
801
|
+
offset: lt.offset,
|
|
802
|
+
line: lt.line,
|
|
803
|
+
col: lt.col,
|
|
804
|
+
text: lt.text,
|
|
805
|
+
lineBreaks: lt.lineBreaks
|
|
806
|
+
});
|
|
807
|
+
var isSelectType = (type) => type === "plural" || type === "select" || type === "selectordinal";
|
|
808
|
+
function strictArgStyleParam(lt, param) {
|
|
809
|
+
let value = "";
|
|
810
|
+
let text = "";
|
|
811
|
+
for (const p of param) {
|
|
812
|
+
const pText = p.ctx.text;
|
|
813
|
+
text += pText;
|
|
814
|
+
switch (p.type) {
|
|
815
|
+
case "content":
|
|
816
|
+
value += p.value;
|
|
817
|
+
break;
|
|
818
|
+
case "argument":
|
|
819
|
+
case "function":
|
|
820
|
+
case "octothorpe":
|
|
821
|
+
value += pText;
|
|
822
|
+
break;
|
|
823
|
+
default:
|
|
824
|
+
throw new ParseError(lt, `Unsupported part in strict mode function arg style: ${pText}`);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
const c = {
|
|
828
|
+
type: "content",
|
|
829
|
+
value: value.trim(),
|
|
830
|
+
ctx: Object.assign({}, param[0].ctx, { text })
|
|
831
|
+
};
|
|
832
|
+
return [c];
|
|
833
|
+
}
|
|
834
|
+
var strictArgTypes = [
|
|
835
|
+
"number",
|
|
836
|
+
"date",
|
|
837
|
+
"time",
|
|
838
|
+
"spellout",
|
|
839
|
+
"ordinal",
|
|
840
|
+
"duration"
|
|
841
|
+
];
|
|
842
|
+
var defaultPluralKeys = ["zero", "one", "two", "few", "many", "other"];
|
|
843
|
+
var ParseError = class extends Error {
|
|
844
|
+
/** @internal */
|
|
845
|
+
constructor(lt, msg) {
|
|
846
|
+
super(lexer_js_1.lexer.formatError(lt, msg));
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
exports.ParseError = ParseError;
|
|
850
|
+
var Parser = class {
|
|
851
|
+
constructor(src, opt) {
|
|
852
|
+
var _a, _b, _c, _d;
|
|
853
|
+
this.lexer = lexer_js_1.lexer.reset(src);
|
|
854
|
+
this.cardinalKeys = (_a = opt === null || opt === void 0 ? void 0 : opt.cardinal) !== null && _a !== void 0 ? _a : defaultPluralKeys;
|
|
855
|
+
this.ordinalKeys = (_b = opt === null || opt === void 0 ? void 0 : opt.ordinal) !== null && _b !== void 0 ? _b : defaultPluralKeys;
|
|
856
|
+
this.strict = (_c = opt === null || opt === void 0 ? void 0 : opt.strict) !== null && _c !== void 0 ? _c : false;
|
|
857
|
+
this.strictPluralKeys = (_d = opt === null || opt === void 0 ? void 0 : opt.strictPluralKeys) !== null && _d !== void 0 ? _d : true;
|
|
858
|
+
}
|
|
859
|
+
parse() {
|
|
860
|
+
return this.parseBody(false, true);
|
|
861
|
+
}
|
|
862
|
+
checkSelectKey(lt, type, key) {
|
|
863
|
+
if (key[0] === "=") {
|
|
864
|
+
if (type === "select")
|
|
865
|
+
throw new ParseError(lt, `The case ${key} is not valid with select`);
|
|
866
|
+
} else if (type !== "select") {
|
|
867
|
+
const keys2 = type === "plural" ? this.cardinalKeys : this.ordinalKeys;
|
|
868
|
+
if (this.strictPluralKeys && keys2.length > 0 && !keys2.includes(key)) {
|
|
869
|
+
const msg = `The ${type} case ${key} is not valid in this locale`;
|
|
870
|
+
throw new ParseError(lt, msg);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
parseSelect({ value: arg }, inPlural, ctx, type) {
|
|
875
|
+
const sel = { type, arg, cases: [], ctx };
|
|
876
|
+
if (type === "plural" || type === "selectordinal")
|
|
877
|
+
inPlural = true;
|
|
878
|
+
else if (this.strict)
|
|
879
|
+
inPlural = false;
|
|
880
|
+
for (const lt of this.lexer) {
|
|
881
|
+
switch (lt.type) {
|
|
882
|
+
case "offset":
|
|
883
|
+
if (type === "select")
|
|
884
|
+
throw new ParseError(lt, "Unexpected plural offset for select");
|
|
885
|
+
if (sel.cases.length > 0)
|
|
886
|
+
throw new ParseError(lt, "Plural offset must be set before cases");
|
|
887
|
+
sel.pluralOffset = Number(lt.value);
|
|
888
|
+
ctx.text += lt.text;
|
|
889
|
+
ctx.lineBreaks += lt.lineBreaks;
|
|
890
|
+
break;
|
|
891
|
+
case "case": {
|
|
892
|
+
this.checkSelectKey(lt, type, lt.value);
|
|
893
|
+
sel.cases.push({
|
|
894
|
+
key: lt.value,
|
|
895
|
+
tokens: this.parseBody(inPlural),
|
|
896
|
+
ctx: getContext(lt)
|
|
897
|
+
});
|
|
898
|
+
break;
|
|
899
|
+
}
|
|
900
|
+
case "end":
|
|
901
|
+
return sel;
|
|
902
|
+
default:
|
|
903
|
+
throw new ParseError(lt, `Unexpected lexer token: ${lt.type}`);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
throw new ParseError(null, "Unexpected message end");
|
|
907
|
+
}
|
|
908
|
+
parseArgToken(lt, inPlural) {
|
|
909
|
+
const ctx = getContext(lt);
|
|
910
|
+
const argType = this.lexer.next();
|
|
911
|
+
if (!argType)
|
|
912
|
+
throw new ParseError(null, "Unexpected message end");
|
|
913
|
+
ctx.text += argType.text;
|
|
914
|
+
ctx.lineBreaks += argType.lineBreaks;
|
|
915
|
+
if (this.strict && (argType.type === "func-simple" || argType.type === "func-args") && !strictArgTypes.includes(argType.value)) {
|
|
916
|
+
const msg = `Invalid strict mode function arg type: ${argType.value}`;
|
|
917
|
+
throw new ParseError(lt, msg);
|
|
918
|
+
}
|
|
919
|
+
switch (argType.type) {
|
|
920
|
+
case "end":
|
|
921
|
+
return { type: "argument", arg: lt.value, ctx };
|
|
922
|
+
case "func-simple": {
|
|
923
|
+
const end = this.lexer.next();
|
|
924
|
+
if (!end)
|
|
925
|
+
throw new ParseError(null, "Unexpected message end");
|
|
926
|
+
if (end.type !== "end")
|
|
927
|
+
throw new ParseError(end, `Unexpected lexer token: ${end.type}`);
|
|
928
|
+
ctx.text += end.text;
|
|
929
|
+
if (isSelectType(argType.value.toLowerCase()))
|
|
930
|
+
throw new ParseError(argType, `Invalid type identifier: ${argType.value}`);
|
|
931
|
+
return {
|
|
932
|
+
type: "function",
|
|
933
|
+
arg: lt.value,
|
|
934
|
+
key: argType.value,
|
|
935
|
+
ctx
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
case "func-args": {
|
|
939
|
+
if (isSelectType(argType.value.toLowerCase())) {
|
|
940
|
+
const msg = `Invalid type identifier: ${argType.value}`;
|
|
941
|
+
throw new ParseError(argType, msg);
|
|
942
|
+
}
|
|
943
|
+
let param = this.parseBody(this.strict ? false : inPlural);
|
|
944
|
+
if (this.strict && param.length > 0)
|
|
945
|
+
param = strictArgStyleParam(lt, param);
|
|
946
|
+
return {
|
|
947
|
+
type: "function",
|
|
948
|
+
arg: lt.value,
|
|
949
|
+
key: argType.value,
|
|
950
|
+
param,
|
|
951
|
+
ctx
|
|
952
|
+
};
|
|
953
|
+
}
|
|
954
|
+
case "select":
|
|
955
|
+
if (isSelectType(argType.value))
|
|
956
|
+
return this.parseSelect(lt, inPlural, ctx, argType.value);
|
|
957
|
+
else
|
|
958
|
+
throw new ParseError(argType, `Unexpected select type ${argType.value}`);
|
|
959
|
+
default:
|
|
960
|
+
throw new ParseError(argType, `Unexpected lexer token: ${argType.type}`);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
parseBody(inPlural, atRoot) {
|
|
964
|
+
const tokens = [];
|
|
965
|
+
let content = null;
|
|
966
|
+
for (const lt of this.lexer) {
|
|
967
|
+
if (lt.type === "argument") {
|
|
968
|
+
if (content)
|
|
969
|
+
content = null;
|
|
970
|
+
tokens.push(this.parseArgToken(lt, inPlural));
|
|
971
|
+
} else if (lt.type === "octothorpe" && inPlural) {
|
|
972
|
+
if (content)
|
|
973
|
+
content = null;
|
|
974
|
+
tokens.push({ type: "octothorpe", ctx: getContext(lt) });
|
|
975
|
+
} else if (lt.type === "end" && !atRoot) {
|
|
976
|
+
return tokens;
|
|
977
|
+
} else {
|
|
978
|
+
let value = lt.value;
|
|
979
|
+
if (!inPlural && lt.type === "quoted" && value[0] === "#") {
|
|
980
|
+
if (value.includes("{")) {
|
|
981
|
+
const errMsg = `Unsupported escape pattern: ${value}`;
|
|
982
|
+
throw new ParseError(lt, errMsg);
|
|
983
|
+
}
|
|
984
|
+
value = lt.text;
|
|
985
|
+
}
|
|
986
|
+
if (content) {
|
|
987
|
+
content.value += value;
|
|
988
|
+
content.ctx.text += lt.text;
|
|
989
|
+
content.ctx.lineBreaks += lt.lineBreaks;
|
|
990
|
+
} else {
|
|
991
|
+
content = { type: "content", value, ctx: getContext(lt) };
|
|
992
|
+
tokens.push(content);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
if (atRoot)
|
|
997
|
+
return tokens;
|
|
998
|
+
throw new ParseError(null, "Unexpected message end");
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
function parse2(src, options = {}) {
|
|
1002
|
+
const parser = new Parser(src, options);
|
|
1003
|
+
return parser.parse();
|
|
1004
|
+
}
|
|
1005
|
+
exports.parse = parse2;
|
|
1006
|
+
}
|
|
1007
|
+
});
|
|
1008
|
+
|
|
5
1009
|
// packages/card/index.js
|
|
6
1010
|
import { html, css } from "lit";
|
|
7
1011
|
|
|
8
|
-
// node_modules/.pnpm/@
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
bordered: "border-2 s-border s-bg"
|
|
1012
|
+
// node_modules/.pnpm/@chbphone55+classnames@2.0.0/node_modules/@chbphone55/classnames/dist/index.m.js
|
|
1013
|
+
var r = function() {
|
|
1014
|
+
for (var t = [], n = arguments.length; n--; ) t[n] = arguments[n];
|
|
1015
|
+
return t.reduce(function(t2, n2) {
|
|
1016
|
+
return t2.concat("string" == typeof n2 ? n2 : Array.isArray(n2) ? r.apply(void 0, n2) : "object" == typeof n2 && n2 ? Object.keys(n2).map(function(r2) {
|
|
1017
|
+
return n2[r2] ? r2 : "";
|
|
1018
|
+
}) : "");
|
|
1019
|
+
}, []).join(" ");
|
|
17
1020
|
};
|
|
1021
|
+
|
|
1022
|
+
// node_modules/.pnpm/@lingui+core@4.11.2/node_modules/@lingui/core/dist/index.mjs
|
|
1023
|
+
var import_unraw = __toESM(require_dist(), 1);
|
|
1024
|
+
|
|
1025
|
+
// node_modules/.pnpm/@lingui+message-utils@4.11.2/node_modules/@lingui/message-utils/dist/compileMessage.mjs
|
|
1026
|
+
var import_parser = __toESM(require_parser(), 1);
|
|
1027
|
+
function processTokens(tokens, mapText) {
|
|
1028
|
+
if (!tokens.filter((token) => token.type !== "content").length) {
|
|
1029
|
+
return tokens.map((token) => mapText(token.value)).join("");
|
|
1030
|
+
}
|
|
1031
|
+
return tokens.map((token) => {
|
|
1032
|
+
var _a;
|
|
1033
|
+
if (token.type === "content") {
|
|
1034
|
+
return mapText(token.value);
|
|
1035
|
+
} else if (token.type === "octothorpe") {
|
|
1036
|
+
return "#";
|
|
1037
|
+
} else if (token.type === "argument") {
|
|
1038
|
+
return [token.arg];
|
|
1039
|
+
} else if (token.type === "function") {
|
|
1040
|
+
const _param = (_a = token == null ? void 0 : token.param) == null ? void 0 : _a[0];
|
|
1041
|
+
if (_param) {
|
|
1042
|
+
return [token.arg, token.key, _param.value.trim()];
|
|
1043
|
+
} else {
|
|
1044
|
+
return [token.arg, token.key];
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
const offset = token.pluralOffset;
|
|
1048
|
+
const formatProps = {};
|
|
1049
|
+
token.cases.forEach(({ key, tokens: tokens2 }) => {
|
|
1050
|
+
const prop = key[0] === "=" ? key.slice(1) : key;
|
|
1051
|
+
formatProps[prop] = processTokens(tokens2, mapText);
|
|
1052
|
+
});
|
|
1053
|
+
return [
|
|
1054
|
+
token.arg,
|
|
1055
|
+
token.type,
|
|
1056
|
+
__spreadValues({
|
|
1057
|
+
offset
|
|
1058
|
+
}, formatProps)
|
|
1059
|
+
];
|
|
1060
|
+
});
|
|
1061
|
+
}
|
|
1062
|
+
function compileMessage(message, mapText = (v) => v) {
|
|
1063
|
+
try {
|
|
1064
|
+
return processTokens((0, import_parser.parse)(message), mapText);
|
|
1065
|
+
} catch (e) {
|
|
1066
|
+
console.error(`${e.message}
|
|
1067
|
+
|
|
1068
|
+
Message: ${message}`);
|
|
1069
|
+
return message;
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
// node_modules/.pnpm/@lingui+core@4.11.2/node_modules/@lingui/core/dist/index.mjs
|
|
1074
|
+
var isString = (s) => typeof s === "string";
|
|
1075
|
+
var isFunction = (f) => typeof f === "function";
|
|
1076
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1077
|
+
var defaultLocale = "en";
|
|
1078
|
+
function normalizeLocales(locales) {
|
|
1079
|
+
const out = Array.isArray(locales) ? locales : [locales];
|
|
1080
|
+
return [...out, defaultLocale];
|
|
1081
|
+
}
|
|
1082
|
+
function date(locales, value, format) {
|
|
1083
|
+
const _locales = normalizeLocales(locales);
|
|
1084
|
+
const formatter = getMemoized(
|
|
1085
|
+
() => cacheKey("date", _locales, format),
|
|
1086
|
+
() => new Intl.DateTimeFormat(_locales, format)
|
|
1087
|
+
);
|
|
1088
|
+
return formatter.format(isString(value) ? new Date(value) : value);
|
|
1089
|
+
}
|
|
1090
|
+
function number(locales, value, format) {
|
|
1091
|
+
const _locales = normalizeLocales(locales);
|
|
1092
|
+
const formatter = getMemoized(
|
|
1093
|
+
() => cacheKey("number", _locales, format),
|
|
1094
|
+
() => new Intl.NumberFormat(_locales, format)
|
|
1095
|
+
);
|
|
1096
|
+
return formatter.format(value);
|
|
1097
|
+
}
|
|
1098
|
+
function plural(locales, ordinal, value, _a) {
|
|
1099
|
+
var _b = _a, { offset = 0 } = _b, rules = __objRest(_b, ["offset"]);
|
|
1100
|
+
var _a2, _b2;
|
|
1101
|
+
const _locales = normalizeLocales(locales);
|
|
1102
|
+
const plurals = ordinal ? getMemoized(
|
|
1103
|
+
() => cacheKey("plural-ordinal", _locales),
|
|
1104
|
+
() => new Intl.PluralRules(_locales, { type: "ordinal" })
|
|
1105
|
+
) : getMemoized(
|
|
1106
|
+
() => cacheKey("plural-cardinal", _locales),
|
|
1107
|
+
() => new Intl.PluralRules(_locales, { type: "cardinal" })
|
|
1108
|
+
);
|
|
1109
|
+
return (_b2 = (_a2 = rules[value]) != null ? _a2 : rules[plurals.select(value - offset)]) != null ? _b2 : rules.other;
|
|
1110
|
+
}
|
|
1111
|
+
function getMemoized(getKey, construct) {
|
|
1112
|
+
const key = getKey();
|
|
1113
|
+
let formatter = cache.get(key);
|
|
1114
|
+
if (!formatter) {
|
|
1115
|
+
formatter = construct();
|
|
1116
|
+
cache.set(key, formatter);
|
|
1117
|
+
}
|
|
1118
|
+
return formatter;
|
|
1119
|
+
}
|
|
1120
|
+
function cacheKey(type, locales, options) {
|
|
1121
|
+
const localeKey = locales.join("-");
|
|
1122
|
+
return `${type}-${localeKey}-${JSON.stringify(options)}`;
|
|
1123
|
+
}
|
|
1124
|
+
var UNICODE_REGEX = /\\u[a-fA-F0-9]{4}|\\x[a-fA-F0-9]{2}/g;
|
|
1125
|
+
var OCTOTHORPE_PH = "%__lingui_octothorpe__%";
|
|
1126
|
+
var getDefaultFormats = (locale, passedLocales, formats = {}) => {
|
|
1127
|
+
const locales = passedLocales || locale;
|
|
1128
|
+
const style = (format) => {
|
|
1129
|
+
return typeof format === "object" ? format : formats[format] || { style: format };
|
|
1130
|
+
};
|
|
1131
|
+
const replaceOctothorpe = (value, message) => {
|
|
1132
|
+
const numberFormat = Object.keys(formats).length ? style("number") : void 0;
|
|
1133
|
+
const valueStr = number(locales, value, numberFormat);
|
|
1134
|
+
return message.replace(new RegExp(OCTOTHORPE_PH, "g"), valueStr);
|
|
1135
|
+
};
|
|
1136
|
+
return {
|
|
1137
|
+
plural: (value, cases) => {
|
|
1138
|
+
const { offset = 0 } = cases;
|
|
1139
|
+
const message = plural(locales, false, value, cases);
|
|
1140
|
+
return replaceOctothorpe(value - offset, message);
|
|
1141
|
+
},
|
|
1142
|
+
selectordinal: (value, cases) => {
|
|
1143
|
+
const { offset = 0 } = cases;
|
|
1144
|
+
const message = plural(locales, true, value, cases);
|
|
1145
|
+
return replaceOctothorpe(value - offset, message);
|
|
1146
|
+
},
|
|
1147
|
+
select: selectFormatter,
|
|
1148
|
+
number: (value, format) => number(locales, value, style(format)),
|
|
1149
|
+
date: (value, format) => date(locales, value, style(format))
|
|
1150
|
+
};
|
|
1151
|
+
};
|
|
1152
|
+
var selectFormatter = (value, rules) => {
|
|
1153
|
+
var _a;
|
|
1154
|
+
return (_a = rules[value]) != null ? _a : rules.other;
|
|
1155
|
+
};
|
|
1156
|
+
function interpolate(translation, locale, locales) {
|
|
1157
|
+
return (values = {}, formats) => {
|
|
1158
|
+
const formatters = getDefaultFormats(locale, locales, formats);
|
|
1159
|
+
const formatMessage = (tokens, replaceOctothorpe = false) => {
|
|
1160
|
+
if (!Array.isArray(tokens))
|
|
1161
|
+
return tokens;
|
|
1162
|
+
return tokens.reduce((message, token) => {
|
|
1163
|
+
if (token === "#" && replaceOctothorpe) {
|
|
1164
|
+
return message + OCTOTHORPE_PH;
|
|
1165
|
+
}
|
|
1166
|
+
if (isString(token)) {
|
|
1167
|
+
return message + token;
|
|
1168
|
+
}
|
|
1169
|
+
const [name, type, format] = token;
|
|
1170
|
+
let interpolatedFormat = {};
|
|
1171
|
+
if (type === "plural" || type === "selectordinal" || type === "select") {
|
|
1172
|
+
Object.entries(format).forEach(
|
|
1173
|
+
([key, value2]) => {
|
|
1174
|
+
interpolatedFormat[key] = formatMessage(
|
|
1175
|
+
value2,
|
|
1176
|
+
type === "plural" || type === "selectordinal"
|
|
1177
|
+
);
|
|
1178
|
+
}
|
|
1179
|
+
);
|
|
1180
|
+
} else {
|
|
1181
|
+
interpolatedFormat = format;
|
|
1182
|
+
}
|
|
1183
|
+
let value;
|
|
1184
|
+
if (type) {
|
|
1185
|
+
const formatter = formatters[type];
|
|
1186
|
+
value = formatter(values[name], interpolatedFormat);
|
|
1187
|
+
} else {
|
|
1188
|
+
value = values[name];
|
|
1189
|
+
}
|
|
1190
|
+
if (value == null) {
|
|
1191
|
+
return message;
|
|
1192
|
+
}
|
|
1193
|
+
return message + value;
|
|
1194
|
+
}, "");
|
|
1195
|
+
};
|
|
1196
|
+
const result = formatMessage(translation);
|
|
1197
|
+
if (isString(result) && UNICODE_REGEX.test(result)) {
|
|
1198
|
+
return (0, import_unraw.unraw)(result.trim());
|
|
1199
|
+
}
|
|
1200
|
+
if (isString(result))
|
|
1201
|
+
return result.trim();
|
|
1202
|
+
return result ? String(result) : "";
|
|
1203
|
+
};
|
|
1204
|
+
}
|
|
1205
|
+
var __defProp$1 = Object.defineProperty;
|
|
1206
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1207
|
+
var __publicField$1 = (obj, key, value) => {
|
|
1208
|
+
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1209
|
+
return value;
|
|
1210
|
+
};
|
|
1211
|
+
var EventEmitter = class {
|
|
1212
|
+
constructor() {
|
|
1213
|
+
__publicField$1(this, "_events", {});
|
|
1214
|
+
}
|
|
1215
|
+
on(event, listener) {
|
|
1216
|
+
var _a2;
|
|
1217
|
+
var _a;
|
|
1218
|
+
(_a2 = (_a = this._events)[event]) != null ? _a2 : _a[event] = [];
|
|
1219
|
+
this._events[event].push(listener);
|
|
1220
|
+
return () => this.removeListener(event, listener);
|
|
1221
|
+
}
|
|
1222
|
+
removeListener(event, listener) {
|
|
1223
|
+
const maybeListeners = this._getListeners(event);
|
|
1224
|
+
if (!maybeListeners)
|
|
1225
|
+
return;
|
|
1226
|
+
const index = maybeListeners.indexOf(listener);
|
|
1227
|
+
if (~index)
|
|
1228
|
+
maybeListeners.splice(index, 1);
|
|
1229
|
+
}
|
|
1230
|
+
emit(event, ...args) {
|
|
1231
|
+
const maybeListeners = this._getListeners(event);
|
|
1232
|
+
if (!maybeListeners)
|
|
1233
|
+
return;
|
|
1234
|
+
maybeListeners.map((listener) => listener.apply(this, args));
|
|
1235
|
+
}
|
|
1236
|
+
_getListeners(event) {
|
|
1237
|
+
const maybeListeners = this._events[event];
|
|
1238
|
+
return Array.isArray(maybeListeners) ? maybeListeners : false;
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
var __defProp2 = Object.defineProperty;
|
|
1242
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1243
|
+
var __publicField2 = (obj, key, value) => {
|
|
1244
|
+
__defNormalProp2(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1245
|
+
return value;
|
|
1246
|
+
};
|
|
1247
|
+
var I18n = class extends EventEmitter {
|
|
1248
|
+
constructor(params) {
|
|
1249
|
+
var _a;
|
|
1250
|
+
super();
|
|
1251
|
+
__publicField2(this, "_locale", "");
|
|
1252
|
+
__publicField2(this, "_locales");
|
|
1253
|
+
__publicField2(this, "_localeData", {});
|
|
1254
|
+
__publicField2(this, "_messages", {});
|
|
1255
|
+
__publicField2(this, "_missing");
|
|
1256
|
+
__publicField2(this, "t", this._.bind(this));
|
|
1257
|
+
if (params.missing != null)
|
|
1258
|
+
this._missing = params.missing;
|
|
1259
|
+
if (params.messages != null)
|
|
1260
|
+
this.load(params.messages);
|
|
1261
|
+
if (params.localeData != null)
|
|
1262
|
+
this.loadLocaleData(params.localeData);
|
|
1263
|
+
if (typeof params.locale === "string" || params.locales) {
|
|
1264
|
+
this.activate((_a = params.locale) != null ? _a : defaultLocale, params.locales);
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
get locale() {
|
|
1268
|
+
return this._locale;
|
|
1269
|
+
}
|
|
1270
|
+
get locales() {
|
|
1271
|
+
return this._locales;
|
|
1272
|
+
}
|
|
1273
|
+
get messages() {
|
|
1274
|
+
var _a;
|
|
1275
|
+
return (_a = this._messages[this._locale]) != null ? _a : {};
|
|
1276
|
+
}
|
|
1277
|
+
/**
|
|
1278
|
+
* @deprecated this has no effect. Please remove this from the code. Deprecated in v4
|
|
1279
|
+
*/
|
|
1280
|
+
get localeData() {
|
|
1281
|
+
var _a;
|
|
1282
|
+
return (_a = this._localeData[this._locale]) != null ? _a : {};
|
|
1283
|
+
}
|
|
1284
|
+
_loadLocaleData(locale, localeData) {
|
|
1285
|
+
const maybeLocaleData = this._localeData[locale];
|
|
1286
|
+
if (!maybeLocaleData) {
|
|
1287
|
+
this._localeData[locale] = localeData;
|
|
1288
|
+
} else {
|
|
1289
|
+
Object.assign(maybeLocaleData, localeData);
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* @deprecated Plurals automatically used from Intl.PluralRules you can safely remove this call. Deprecated in v4
|
|
1294
|
+
*/
|
|
1295
|
+
// @ts-ignore deprecated, so ignore the reported error
|
|
1296
|
+
loadLocaleData(localeOrAllData, localeData) {
|
|
1297
|
+
if (localeData != null) {
|
|
1298
|
+
this._loadLocaleData(localeOrAllData, localeData);
|
|
1299
|
+
} else {
|
|
1300
|
+
Object.keys(localeOrAllData).forEach(
|
|
1301
|
+
(locale) => this._loadLocaleData(locale, localeOrAllData[locale])
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
this.emit("change");
|
|
1305
|
+
}
|
|
1306
|
+
_load(locale, messages5) {
|
|
1307
|
+
const maybeMessages = this._messages[locale];
|
|
1308
|
+
if (!maybeMessages) {
|
|
1309
|
+
this._messages[locale] = messages5;
|
|
1310
|
+
} else {
|
|
1311
|
+
Object.assign(maybeMessages, messages5);
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
load(localeOrMessages, messages5) {
|
|
1315
|
+
if (typeof localeOrMessages == "string" && typeof messages5 === "object") {
|
|
1316
|
+
this._load(localeOrMessages, messages5);
|
|
1317
|
+
} else {
|
|
1318
|
+
Object.entries(localeOrMessages).forEach(
|
|
1319
|
+
([locale, messages22]) => this._load(locale, messages22)
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
this.emit("change");
|
|
1323
|
+
}
|
|
1324
|
+
/**
|
|
1325
|
+
* @param options {@link LoadAndActivateOptions}
|
|
1326
|
+
*/
|
|
1327
|
+
loadAndActivate({ locale, locales, messages: messages5 }) {
|
|
1328
|
+
this._locale = locale;
|
|
1329
|
+
this._locales = locales || void 0;
|
|
1330
|
+
this._messages[this._locale] = messages5;
|
|
1331
|
+
this.emit("change");
|
|
1332
|
+
}
|
|
1333
|
+
activate(locale, locales) {
|
|
1334
|
+
if (true) {
|
|
1335
|
+
if (!this._messages[locale]) {
|
|
1336
|
+
console.warn(`Messages for locale "${locale}" not loaded.`);
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
this._locale = locale;
|
|
1340
|
+
this._locales = locales;
|
|
1341
|
+
this.emit("change");
|
|
1342
|
+
}
|
|
1343
|
+
_(id, values, options) {
|
|
1344
|
+
let message = options == null ? void 0 : options.message;
|
|
1345
|
+
if (!id) {
|
|
1346
|
+
id = "";
|
|
1347
|
+
}
|
|
1348
|
+
if (!isString(id)) {
|
|
1349
|
+
values = id.values || values;
|
|
1350
|
+
message = id.message;
|
|
1351
|
+
id = id.id;
|
|
1352
|
+
}
|
|
1353
|
+
const messageForId = this.messages[id];
|
|
1354
|
+
const messageMissing = messageForId === void 0;
|
|
1355
|
+
const missing = this._missing;
|
|
1356
|
+
if (missing && messageMissing) {
|
|
1357
|
+
return isFunction(missing) ? missing(this._locale, id) : missing;
|
|
1358
|
+
}
|
|
1359
|
+
if (messageMissing) {
|
|
1360
|
+
this.emit("missing", { id, locale: this._locale });
|
|
1361
|
+
}
|
|
1362
|
+
let translation = messageForId || message || id;
|
|
1363
|
+
if (true) {
|
|
1364
|
+
translation = isString(translation) ? compileMessage(translation) : translation;
|
|
1365
|
+
}
|
|
1366
|
+
if (isString(translation) && UNICODE_REGEX.test(translation))
|
|
1367
|
+
return JSON.parse(`"${translation}"`);
|
|
1368
|
+
if (isString(translation))
|
|
1369
|
+
return translation;
|
|
1370
|
+
return interpolate(
|
|
1371
|
+
translation,
|
|
1372
|
+
this._locale,
|
|
1373
|
+
this._locales
|
|
1374
|
+
)(values, options == null ? void 0 : options.formats);
|
|
1375
|
+
}
|
|
1376
|
+
date(value, format) {
|
|
1377
|
+
return date(this._locales || this._locale, value, format);
|
|
1378
|
+
}
|
|
1379
|
+
number(value, format) {
|
|
1380
|
+
return number(this._locales || this._locale, value, format);
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
function setupI18n(params = {}) {
|
|
1384
|
+
return new I18n(params);
|
|
1385
|
+
}
|
|
1386
|
+
var i18n = setupI18n();
|
|
1387
|
+
|
|
1388
|
+
// node_modules/.pnpm/@warp-ds+css@2.0.0_@warp-ds+uno@2.0.0_unocss@0.62.0_postcss@8.4.41_rollup@4.20.0_vite@5.3.3_@_vyiy5vwpqfzwy5hpmfkwp3zmle/node_modules/@warp-ds/css/component-classes/index.js
|
|
18
1389
|
var card = {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
1390
|
+
base: "cursor-pointer overflow-hidden relative transition-all",
|
|
1391
|
+
shadow: "group rounded-8 s-surface-elevated-200 hover:s-surface-elevated-200-hover active:s-surface-elevated-200-active",
|
|
1392
|
+
selected: "!s-bg-selected !hover:s-bg-selected-hover !active:s-bg-selected-active",
|
|
1393
|
+
outline: "absolute border-2 rounded-8 inset-0 transition-all",
|
|
1394
|
+
outlineUnselected: "border-transparent group-active:s-border-active",
|
|
1395
|
+
outlineSelected: "s-border-selected group-hover:s-border-selected-hover group-active:s-border-selected-active",
|
|
1396
|
+
flat: "border-2 rounded-4",
|
|
1397
|
+
flatUnselected: "s-bg hover:s-bg-hover active:s-bg-active s-border hover:s-border-hover active:s-border-active",
|
|
1398
|
+
flatSelected: "s-bg-selected hover:s-bg-selected-hover active:s-bg-selected-active s-border-selected hover:s-border-selected-hover active:s-border-selected-active",
|
|
28
1399
|
a11y: "sr-only"
|
|
29
1400
|
};
|
|
30
|
-
var buttonReset = "focus:outline-none appearance-none cursor-pointer bg-transparent border-0 m-0 p-0 inline-block";
|
|
31
|
-
var expandable = {
|
|
32
|
-
expandable: "will-change-height",
|
|
33
|
-
expandableTitle: "font-bold s-text",
|
|
34
|
-
expandableBox: "s-surface-sunken hover:s-bg-hover active:s-bg-active py-0 px-0 " + box.box,
|
|
35
|
-
expandableInfo: "s-bg-info-subtle! hover:s-bg-info-subtle-hover!",
|
|
36
|
-
expandableBleed: box.bleed,
|
|
37
|
-
chevron: "inline-block align-middle s-icon",
|
|
38
|
-
chevronNonBox: "ml-8",
|
|
39
|
-
chevronBox: "",
|
|
40
|
-
chevronTransform: "transform transition-transform transform-gpu ease-in-out",
|
|
41
|
-
chevronExpand: "-rotate-180",
|
|
42
|
-
chevronCollapse: "rotate-180",
|
|
43
|
-
elementsTransformChevronDownPart: "part-[w-icon-chevron-down-16-part]:transform part-[w-icon-chevron-down-16-part]:transition-transform part-[w-icon-chevron-down-16-part]:transform-gpu part-[w-icon-chevron-down-16-part]:ease-in-out",
|
|
44
|
-
elementsChevronDownExpandPart: "part-[w-icon-chevron-down-16-part]:-rotate-180",
|
|
45
|
-
elementsTransformChevronUpPart: "part-[w-icon-chevron-up-16-part]:transform part-[w-icon-chevron-up-16-part]:transition-transform part-[w-icon-chevron-up-16-part]:transform-gpu part-[w-icon-chevron-up-16-part]:ease-in-out",
|
|
46
|
-
elementsChevronUpCollapsePart: "part-[w-icon-chevron-up-16-part]:rotate-180",
|
|
47
|
-
expansion: "overflow-hidden",
|
|
48
|
-
expansionNotExpanded: "h-0 invisible",
|
|
49
|
-
button: buttonReset + " hover:underline focus-visible:underline",
|
|
50
|
-
buttonBox: "w-full text-left relative inline-flex items-center justify-between " + box.box,
|
|
51
|
-
paddingTop: "pt-0",
|
|
52
|
-
title: "flex w-full justify-between items-center",
|
|
53
|
-
titleType: "h4"
|
|
54
|
-
};
|
|
55
1401
|
var buttonDefaultStyling = "font-bold focusable justify-center transition-colors ease-in-out";
|
|
56
1402
|
var buttonColors = {
|
|
57
1403
|
primary: "s-text-inverted bg-[--w-color-button-primary-background] hover:bg-[--w-color-button-primary-background-hover] active:bg-[--w-color-button-primary-background-active]",
|
|
@@ -169,7 +1515,7 @@ var button = {
|
|
|
169
1515
|
};
|
|
170
1516
|
var modal = {
|
|
171
1517
|
backdrop: "fixed inset-0 flex sm:place-content-center sm:place-items-center items-end z-30 [--w-modal-max-height:80%] [--w-modal-width:640px] bg-[--w-black/25]",
|
|
172
|
-
|
|
1518
|
+
base: "pb-safe-[32] shadow-m max-h-[--w-modal-max-height] min-h-[--w-modal-min-height] w-[--w-modal-width] h-[--w-modal-height] relative transition-300 ease-in-out backface-hidden will-change-height rounded-8 mx-0 sm:mx-16 bg-[--w-s-color-surface-elevated-100] flex flex-col overflow-hidden outline-none space-y-16 pt-8 sm:pt-32 sm:pb-32 rounded-b-0 sm:rounded-b-8",
|
|
173
1519
|
content: "block overflow-y-auto overflow-x-hidden last-child:mb-0 grow shrink px-16 sm:px-32 relative",
|
|
174
1520
|
footer: "flex justify-end shrink-0 px-16 sm:px-32",
|
|
175
1521
|
transitionTitle: "transition-all duration-300",
|
|
@@ -183,19 +1529,15 @@ var modal = {
|
|
|
183
1529
|
titleButtonIcon: "h-16 w-16 sm:h-24 sm:w-24",
|
|
184
1530
|
titleButtonIconRotated: "transform rotate-90"
|
|
185
1531
|
};
|
|
186
|
-
var
|
|
187
|
-
label: "antialiased block relative text-s font-bold pb-4 cursor-pointer s-text",
|
|
188
|
-
optional: "pl-8 font-normal text-s s-text-subtle"
|
|
189
|
-
};
|
|
190
|
-
var prefixSuffixWrapperBase = "absolute top-0 bottom-0 flex justify-center items-center focusable rounded-4 focus:[--w-outline-offset:-2px] bg-transparent ";
|
|
1532
|
+
var prefixSuffixWrapper = "absolute top-0 bottom-0 flex justify-center items-center focusable rounded-4 focus:[--w-outline-offset:-2px] bg-transparent ";
|
|
191
1533
|
var suffix = {
|
|
192
|
-
wrapper:
|
|
1534
|
+
wrapper: prefixSuffixWrapper + "right-0",
|
|
193
1535
|
wrapperWithLabel: "w-max pr-12",
|
|
194
1536
|
wrapperWithIcon: "w-40",
|
|
195
1537
|
label: "antialiased block relative cursor-default pb-0 font-bold text-xs s-text"
|
|
196
1538
|
};
|
|
197
1539
|
var prefix = {
|
|
198
|
-
wrapper:
|
|
1540
|
+
wrapper: prefixSuffixWrapper + "left-0",
|
|
199
1541
|
wrapperWithLabel: "w-max pl-12",
|
|
200
1542
|
wrapperWithIcon: "w-40",
|
|
201
1543
|
label: "antialiased block relative cursor-default pb-0 font-bold text-xs s-text"
|
|
@@ -252,15 +1594,9 @@ var deadToggle = {
|
|
|
252
1594
|
wrapper: `${toggle.wrapper} h-20 w-20 pointer-events-none`,
|
|
253
1595
|
input: `${toggle.input} hidden`,
|
|
254
1596
|
inputVue: "hidden",
|
|
1597
|
+
labelVue: "-mt-2",
|
|
255
1598
|
labelRadio: `${toggle.label} ${toggle.labelBefore} ${toggle.radio}`,
|
|
256
|
-
labelCheckbox: `${toggle.label} ${toggle.labelBefore} ${toggle.checkbox}
|
|
257
|
-
labelVue: "-mt-2"
|
|
258
|
-
};
|
|
259
|
-
var clickable = {
|
|
260
|
-
toggle: "absolute inset-0 h-full w-full appearance-none cursor-pointer focusable focusable-inset",
|
|
261
|
-
label: `px-12 ${label.label} py-8! cursor-pointer focusable focusable-inset`,
|
|
262
|
-
buttonOrLink: "bg-transparent focusable",
|
|
263
|
-
buttonOrLinkStretch: "inset-0 absolute"
|
|
1599
|
+
labelCheckbox: `${toggle.label} ${toggle.labelBefore} ${toggle.checkbox}`
|
|
264
1600
|
};
|
|
265
1601
|
var attention = {
|
|
266
1602
|
base: "border-2 relative flex items-start",
|
|
@@ -294,17 +1630,51 @@ var attention = {
|
|
|
294
1630
|
import WarpElement from "@warp-ds/elements-core";
|
|
295
1631
|
import { ifDefined } from "lit/directives/if-defined.js";
|
|
296
1632
|
|
|
297
|
-
// packages/
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
1633
|
+
// packages/i18n.ts
|
|
1634
|
+
var supportedLocales = ["en", "nb", "fi", "da"];
|
|
1635
|
+
var defaultLocale2 = "en";
|
|
1636
|
+
var getSupportedLocale = (usedLocale) => {
|
|
1637
|
+
return supportedLocales.find(
|
|
1638
|
+
(locale) => usedLocale === locale || usedLocale.toLowerCase().includes(locale)
|
|
1639
|
+
) || defaultLocale2;
|
|
1640
|
+
};
|
|
1641
|
+
function detectLocale() {
|
|
1642
|
+
if (typeof window === "undefined") {
|
|
1643
|
+
const serverLocale = process.env.NMP_LANGUAGE || Intl.DateTimeFormat().resolvedOptions().locale;
|
|
1644
|
+
return getSupportedLocale(serverLocale);
|
|
1645
|
+
}
|
|
1646
|
+
try {
|
|
1647
|
+
const htmlLocale = document.documentElement.lang;
|
|
1648
|
+
return getSupportedLocale(htmlLocale);
|
|
1649
|
+
} catch (e) {
|
|
1650
|
+
console.warn("could not detect locale, falling back to source locale", e);
|
|
1651
|
+
return defaultLocale2;
|
|
305
1652
|
}
|
|
306
|
-
return classMap(defn);
|
|
307
1653
|
}
|
|
1654
|
+
var getMessages = (locale, enMsg, nbMsg, fiMsg, daMsg) => {
|
|
1655
|
+
if (locale === "nb") return nbMsg;
|
|
1656
|
+
if (locale === "fi") return fiMsg;
|
|
1657
|
+
if (locale === "da") return daMsg;
|
|
1658
|
+
return enMsg;
|
|
1659
|
+
};
|
|
1660
|
+
var activateI18n = (enMessages, nbMessages, fiMessages, daMessages) => {
|
|
1661
|
+
const locale = detectLocale();
|
|
1662
|
+
const messages5 = getMessages(locale, enMessages, nbMessages, fiMessages, daMessages);
|
|
1663
|
+
i18n.load(locale, messages5);
|
|
1664
|
+
i18n.activate(locale);
|
|
1665
|
+
};
|
|
1666
|
+
|
|
1667
|
+
// packages/card/locales/da/messages.mjs
|
|
1668
|
+
var messages = JSON.parse('{"card.button.text":"V\xE6lg"}');
|
|
1669
|
+
|
|
1670
|
+
// packages/card/locales/en/messages.mjs
|
|
1671
|
+
var messages2 = JSON.parse('{"card.button.text":"Select"}');
|
|
1672
|
+
|
|
1673
|
+
// packages/card/locales/fi/messages.mjs
|
|
1674
|
+
var messages3 = JSON.parse('{"card.button.text":"Valitse"}');
|
|
1675
|
+
|
|
1676
|
+
// packages/card/locales/nb/messages.mjs
|
|
1677
|
+
var messages4 = JSON.parse('{"card.button.text":"Velg"}');
|
|
308
1678
|
|
|
309
1679
|
// packages/card/index.js
|
|
310
1680
|
var keys = {
|
|
@@ -314,30 +1684,31 @@ var keys = {
|
|
|
314
1684
|
var WarpCard = class extends WarpElement {
|
|
315
1685
|
constructor() {
|
|
316
1686
|
super();
|
|
1687
|
+
activateI18n(messages2, messages4, messages3, messages);
|
|
317
1688
|
this.selected = false;
|
|
318
1689
|
this.flat = false;
|
|
319
1690
|
this.clickable = false;
|
|
1691
|
+
this.buttonText = i18n._({
|
|
1692
|
+
id: "card.button.text",
|
|
1693
|
+
message: "Select",
|
|
1694
|
+
comment: "Screenreader message to indicate that the card is clickable"
|
|
1695
|
+
});
|
|
320
1696
|
}
|
|
321
1697
|
get _containerClasses() {
|
|
322
|
-
return
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
});
|
|
1698
|
+
return r([
|
|
1699
|
+
card.base,
|
|
1700
|
+
this.flat ? card.flat : card.shadow,
|
|
1701
|
+
this.selected && !this.flat && card.selected,
|
|
1702
|
+
this.selected && this.flat ? card.flatSelected : card.flatUnselected
|
|
1703
|
+
]);
|
|
329
1704
|
}
|
|
330
1705
|
get _outlineClasses() {
|
|
331
|
-
return
|
|
332
|
-
[card.cardOutline]: true,
|
|
333
|
-
[this.selected ? card.cardOutlineSelected : card.cardOutlineUnselected]: true
|
|
334
|
-
});
|
|
1706
|
+
return r([card.outline, this.selected ? card.outlineSelected : card.outlineUnselected]);
|
|
335
1707
|
}
|
|
336
|
-
get
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
return html`<span role="checkbox" aria-checked="true" aria-disabled="true"></span>`;
|
|
1708
|
+
get _interactiveElement() {
|
|
1709
|
+
const renderButton = () => html`<button class="${card.a11y}" aria-pressed="${this.selected}" tabindex="-1">${this.buttonText}</button>`;
|
|
1710
|
+
const renderSpan = () => html`<span role="checkbox" aria-checked="true" aria-disabled="true"></span>`;
|
|
1711
|
+
return this.clickable ? renderButton() : this.selected ? renderSpan() : "";
|
|
341
1712
|
}
|
|
342
1713
|
keypressed(e) {
|
|
343
1714
|
if (!this.clickable || e.altKey || e.ctrlKey) return;
|
|
@@ -349,13 +1720,17 @@ var WarpCard = class extends WarpElement {
|
|
|
349
1720
|
render() {
|
|
350
1721
|
return html`
|
|
351
1722
|
<div tabindex=${ifDefined(this.clickable ? "0" : void 0)} class="${this._containerClasses}" @keydown=${this.keypressed}>
|
|
352
|
-
${this.
|
|
353
|
-
<div class="${this._outlineClasses}"></div>
|
|
1723
|
+
${this._interactiveElement} ${this.flat ? "" : html`<div class="${this._outlineClasses}"></div>`}
|
|
354
1724
|
<slot></slot>
|
|
355
1725
|
</div>
|
|
356
1726
|
`;
|
|
357
1727
|
}
|
|
358
1728
|
};
|
|
1729
|
+
__publicField(WarpCard, "properties", {
|
|
1730
|
+
selected: { type: Boolean, reflect: true },
|
|
1731
|
+
flat: { type: Boolean },
|
|
1732
|
+
clickable: { type: Boolean }
|
|
1733
|
+
});
|
|
359
1734
|
__publicField(WarpCard, "styles", [
|
|
360
1735
|
WarpElement.styles,
|
|
361
1736
|
css`
|
|
@@ -372,11 +1747,6 @@ __publicField(WarpCard, "styles", [
|
|
|
372
1747
|
}
|
|
373
1748
|
`
|
|
374
1749
|
]);
|
|
375
|
-
__publicField(WarpCard, "properties", {
|
|
376
|
-
selected: { type: Boolean, reflect: true },
|
|
377
|
-
flat: { type: Boolean },
|
|
378
|
-
clickable: { type: Boolean }
|
|
379
|
-
});
|
|
380
1750
|
if (!customElements.get("w-card")) {
|
|
381
1751
|
customElements.define("w-card", WarpCard);
|
|
382
1752
|
}
|