@retailcrm/embed-ui-v1-components 0.9.11-alpha.1 → 0.9.11-alpha.2
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/host.cjs +266 -1809
- package/dist/host.css +36 -0
- package/dist/host.d.ts +30 -1
- package/dist/host.js +220 -1763
- package/dist/remote.cjs +230 -2702
- package/dist/remote.d.ts +5 -1
- package/dist/remote.js +157 -2629
- package/package.json +3 -2
package/dist/remote.js
CHANGED
|
@@ -1,1022 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
1
|
+
import { defineRemoteComponent, createRemoteRoot } from "@omnicajs/vue-remote/remote";
|
|
2
|
+
import { openBlock, createElementBlock, createElementVNode, defineComponent, mergeProps, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createVNode, unref, withCtx, reactive, computed, inject, ref, provide, watch, createBlock, onBeforeMount, onBeforeUnmount, createSlots, onMounted, getCurrentInstance } from "vue";
|
|
3
3
|
import isEqual from "lodash.isequal";
|
|
4
4
|
import { preview } from "@retailcrm/image-preview";
|
|
5
|
+
import { ru, es, enGB } from "date-fns/locale";
|
|
5
6
|
import { format } from "date-fns";
|
|
6
|
-
const ACTION_MOUNT = "mount";
|
|
7
|
-
const ACTION_INSERT_CHILD = "insert-child";
|
|
8
|
-
const ACTION_REMOVE_CHILD = "remove-child";
|
|
9
|
-
const ACTION_UPDATE_TEXT = "update-text";
|
|
10
|
-
const ACTION_UPDATE_PROPERTIES = "update-properties";
|
|
11
|
-
const ACTION_INVOKE = "invoke";
|
|
12
|
-
const KIND_COMMENT = "comment";
|
|
13
|
-
const KIND_COMPONENT = "component";
|
|
14
|
-
const KIND_FRAGMENT = "fragment";
|
|
15
|
-
const KIND_ROOT = "root";
|
|
16
|
-
const KIND_TEXT = "text";
|
|
17
|
-
const ROOT_ID = "~";
|
|
18
|
-
const addMethod = (o, name, fn) => {
|
|
19
|
-
return Object.defineProperty(o, name, {
|
|
20
|
-
value: fn,
|
|
21
|
-
configurable: true,
|
|
22
|
-
writable: false,
|
|
23
|
-
enumerable: false
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
const arraify = (value) => Array.isArray(value) ? [...value] : [value];
|
|
27
|
-
const capture = (o, freeze) => {
|
|
28
|
-
return freeze ? Object.freeze(o) : o;
|
|
29
|
-
};
|
|
30
|
-
const isFunction = (value) => {
|
|
31
|
-
return typeof value === "function";
|
|
32
|
-
};
|
|
33
|
-
const isObject = (value) => {
|
|
34
|
-
if (value == null || typeof value !== "object") {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
const prototype = Object.getPrototypeOf(value);
|
|
38
|
-
return prototype == null || prototype === Object.prototype;
|
|
39
|
-
};
|
|
40
|
-
const keysOf = (o) => Object.keys(o);
|
|
41
|
-
const visitArray = (value, visited, visit) => {
|
|
42
|
-
const result = [];
|
|
43
|
-
visited.set(value, result);
|
|
44
|
-
for (const nested of value) {
|
|
45
|
-
result.push(visit(nested, visited));
|
|
46
|
-
}
|
|
47
|
-
return result;
|
|
48
|
-
};
|
|
49
|
-
const visitObject = (value, visited, visit) => {
|
|
50
|
-
const result = {};
|
|
51
|
-
visited.set(value, result);
|
|
52
|
-
for (const key of keysOf(value)) {
|
|
53
|
-
result[key] = visit(value[key], visited);
|
|
54
|
-
}
|
|
55
|
-
return result;
|
|
56
|
-
};
|
|
57
|
-
const REMOTE_SLOT = "RemoteSlot";
|
|
58
|
-
const HTMLTagList = [
|
|
59
|
-
"a",
|
|
60
|
-
"abbr",
|
|
61
|
-
"address",
|
|
62
|
-
"area",
|
|
63
|
-
"article",
|
|
64
|
-
"aside",
|
|
65
|
-
"audio",
|
|
66
|
-
"b",
|
|
67
|
-
"base",
|
|
68
|
-
"bdi",
|
|
69
|
-
"bdo",
|
|
70
|
-
"blockquote",
|
|
71
|
-
"body",
|
|
72
|
-
"br",
|
|
73
|
-
"button",
|
|
74
|
-
"canvas",
|
|
75
|
-
"caption",
|
|
76
|
-
"cite",
|
|
77
|
-
"code",
|
|
78
|
-
"col",
|
|
79
|
-
"colgroup",
|
|
80
|
-
"datalist",
|
|
81
|
-
"dd",
|
|
82
|
-
"del",
|
|
83
|
-
"details",
|
|
84
|
-
"dfn",
|
|
85
|
-
"dialog",
|
|
86
|
-
"div",
|
|
87
|
-
"dl",
|
|
88
|
-
"dt",
|
|
89
|
-
"em",
|
|
90
|
-
"embed",
|
|
91
|
-
"fieldset",
|
|
92
|
-
"figcaption",
|
|
93
|
-
"figure",
|
|
94
|
-
"footer",
|
|
95
|
-
"form",
|
|
96
|
-
"h1",
|
|
97
|
-
"h2",
|
|
98
|
-
"h3",
|
|
99
|
-
"h4",
|
|
100
|
-
"h5",
|
|
101
|
-
"h6",
|
|
102
|
-
"head",
|
|
103
|
-
"header",
|
|
104
|
-
"hgroup",
|
|
105
|
-
"hr",
|
|
106
|
-
"html",
|
|
107
|
-
"i",
|
|
108
|
-
"iframe",
|
|
109
|
-
"img",
|
|
110
|
-
"input",
|
|
111
|
-
"ins",
|
|
112
|
-
"kbd",
|
|
113
|
-
"keygen",
|
|
114
|
-
"label",
|
|
115
|
-
"legend",
|
|
116
|
-
"li",
|
|
117
|
-
"link",
|
|
118
|
-
"main",
|
|
119
|
-
"map",
|
|
120
|
-
"mark",
|
|
121
|
-
"menu",
|
|
122
|
-
"menuitem",
|
|
123
|
-
"meta",
|
|
124
|
-
"meter",
|
|
125
|
-
"nav",
|
|
126
|
-
"noscript",
|
|
127
|
-
"object",
|
|
128
|
-
"ol",
|
|
129
|
-
"optgroup",
|
|
130
|
-
"option",
|
|
131
|
-
"output",
|
|
132
|
-
"p",
|
|
133
|
-
"param",
|
|
134
|
-
"picture",
|
|
135
|
-
"pre",
|
|
136
|
-
"progress",
|
|
137
|
-
"q",
|
|
138
|
-
"rp",
|
|
139
|
-
"rt",
|
|
140
|
-
"ruby",
|
|
141
|
-
"s",
|
|
142
|
-
"samp",
|
|
143
|
-
"script",
|
|
144
|
-
"section",
|
|
145
|
-
"select",
|
|
146
|
-
"small",
|
|
147
|
-
"source",
|
|
148
|
-
"span",
|
|
149
|
-
"strong",
|
|
150
|
-
"style",
|
|
151
|
-
"sub",
|
|
152
|
-
"summary",
|
|
153
|
-
"sup",
|
|
154
|
-
"table",
|
|
155
|
-
"tbody",
|
|
156
|
-
"td",
|
|
157
|
-
"textarea",
|
|
158
|
-
"tfoot",
|
|
159
|
-
"th",
|
|
160
|
-
"thead",
|
|
161
|
-
"time",
|
|
162
|
-
"title",
|
|
163
|
-
"tr",
|
|
164
|
-
"track",
|
|
165
|
-
"u",
|
|
166
|
-
"ul",
|
|
167
|
-
"var",
|
|
168
|
-
"video",
|
|
169
|
-
"wbr"
|
|
170
|
-
];
|
|
171
|
-
const MathMLTagList = [
|
|
172
|
-
"math",
|
|
173
|
-
"maction",
|
|
174
|
-
"maligngroup",
|
|
175
|
-
"malignmark",
|
|
176
|
-
"menclose",
|
|
177
|
-
"merror",
|
|
178
|
-
"mfenced",
|
|
179
|
-
"mfrac",
|
|
180
|
-
"mglyph",
|
|
181
|
-
"mi",
|
|
182
|
-
"mlabeledtr",
|
|
183
|
-
"mlongdiv",
|
|
184
|
-
"mmultiscripts",
|
|
185
|
-
"mn",
|
|
186
|
-
"mo",
|
|
187
|
-
"mover",
|
|
188
|
-
"mpadded",
|
|
189
|
-
"mphantom",
|
|
190
|
-
"mroot",
|
|
191
|
-
"mrow",
|
|
192
|
-
"ms",
|
|
193
|
-
"mscarries",
|
|
194
|
-
"mscarry",
|
|
195
|
-
"msgroup",
|
|
196
|
-
"msline",
|
|
197
|
-
"mstack",
|
|
198
|
-
"mspace",
|
|
199
|
-
"msqrt",
|
|
200
|
-
"msrow",
|
|
201
|
-
"mstyle",
|
|
202
|
-
"msub",
|
|
203
|
-
"msup",
|
|
204
|
-
"msubsup",
|
|
205
|
-
"mtable",
|
|
206
|
-
"mtd",
|
|
207
|
-
"mtext",
|
|
208
|
-
"mtr",
|
|
209
|
-
"munder",
|
|
210
|
-
"munderover",
|
|
211
|
-
"none",
|
|
212
|
-
"semantics",
|
|
213
|
-
"annotation",
|
|
214
|
-
"annotation-xml"
|
|
215
|
-
];
|
|
216
|
-
const SVGTagList = [
|
|
217
|
-
"a",
|
|
218
|
-
"altGlyph",
|
|
219
|
-
"altGlyphDef",
|
|
220
|
-
"altGlyphItem",
|
|
221
|
-
"animate",
|
|
222
|
-
"animateColor",
|
|
223
|
-
"animateMotion",
|
|
224
|
-
"animateTransform",
|
|
225
|
-
"circle",
|
|
226
|
-
"clipPath",
|
|
227
|
-
"color-profile",
|
|
228
|
-
"cursor",
|
|
229
|
-
"defs",
|
|
230
|
-
"desc",
|
|
231
|
-
"discard",
|
|
232
|
-
"ellipse",
|
|
233
|
-
"feBlend",
|
|
234
|
-
"feColorMatrix",
|
|
235
|
-
"feComponentTransfer",
|
|
236
|
-
"feComposite",
|
|
237
|
-
"feConvolveMatrix",
|
|
238
|
-
"feDiffuseLighting",
|
|
239
|
-
"feDisplacementMap",
|
|
240
|
-
"feDistantLight",
|
|
241
|
-
"feDropShadow",
|
|
242
|
-
"feFlood",
|
|
243
|
-
"feFuncA",
|
|
244
|
-
"feFuncB",
|
|
245
|
-
"feFuncG",
|
|
246
|
-
"feFuncR",
|
|
247
|
-
"feGaussianBlur",
|
|
248
|
-
"feImage",
|
|
249
|
-
"feMerge",
|
|
250
|
-
"feMergeNode",
|
|
251
|
-
"feMorphology",
|
|
252
|
-
"feOffset",
|
|
253
|
-
"fePointLight",
|
|
254
|
-
"feSpecularLighting",
|
|
255
|
-
"feSpotLight",
|
|
256
|
-
"feTile",
|
|
257
|
-
"feTurbulence",
|
|
258
|
-
"filter",
|
|
259
|
-
"font",
|
|
260
|
-
"font-face",
|
|
261
|
-
"font-face-format",
|
|
262
|
-
"font-face-name",
|
|
263
|
-
"font-face-src",
|
|
264
|
-
"font-face-uri",
|
|
265
|
-
"foreignObject",
|
|
266
|
-
"g",
|
|
267
|
-
"glyph",
|
|
268
|
-
"glyphRef",
|
|
269
|
-
"hkern",
|
|
270
|
-
"image",
|
|
271
|
-
"line",
|
|
272
|
-
"linearGradient",
|
|
273
|
-
"marker",
|
|
274
|
-
"mask",
|
|
275
|
-
"metadata",
|
|
276
|
-
"missing-glyph",
|
|
277
|
-
"mpath",
|
|
278
|
-
"path",
|
|
279
|
-
"pattern",
|
|
280
|
-
"polygon",
|
|
281
|
-
"polyline",
|
|
282
|
-
"radialGradient",
|
|
283
|
-
"rect",
|
|
284
|
-
"script",
|
|
285
|
-
"set",
|
|
286
|
-
"stop",
|
|
287
|
-
"style",
|
|
288
|
-
"svg",
|
|
289
|
-
"switch",
|
|
290
|
-
"symbol",
|
|
291
|
-
"text",
|
|
292
|
-
"textPath",
|
|
293
|
-
"title",
|
|
294
|
-
"tref",
|
|
295
|
-
"tspan",
|
|
296
|
-
"use",
|
|
297
|
-
"view",
|
|
298
|
-
"vkern"
|
|
299
|
-
];
|
|
300
|
-
function isRemoteFragment(value) {
|
|
301
|
-
return value != null && value.kind === KIND_FRAGMENT;
|
|
302
|
-
}
|
|
303
|
-
const normalizeChild = (child, root) => typeof child === "string" ? root.createText(child) : child;
|
|
304
|
-
const normalizeChildren = (children, root) => children.map((child) => normalizeChild(child, root));
|
|
305
|
-
const traverse = (element, each) => {
|
|
306
|
-
const _traverse = (element2) => {
|
|
307
|
-
if ("children" in element2) {
|
|
308
|
-
for (const child of element2.children) {
|
|
309
|
-
each(child);
|
|
310
|
-
_traverse(child);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
_traverse(element);
|
|
315
|
-
};
|
|
316
|
-
function attach(context, parent, node) {
|
|
317
|
-
const { progenitors, parents } = context;
|
|
318
|
-
const progenitor = parent.kind === KIND_ROOT ? parent : parent.progenitor;
|
|
319
|
-
if (progenitor) {
|
|
320
|
-
progenitors.set(node, progenitor);
|
|
321
|
-
}
|
|
322
|
-
parents.set(node, parent);
|
|
323
|
-
attachFragments(context, node);
|
|
324
|
-
traverse(node, (descendant) => {
|
|
325
|
-
if (progenitor) {
|
|
326
|
-
progenitors.set(descendant, progenitor);
|
|
327
|
-
}
|
|
328
|
-
attachFragments(context, descendant);
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
function attachFragments(context, node) {
|
|
332
|
-
if (node.kind === KIND_COMPONENT) {
|
|
333
|
-
Object.values(node.properties).forEach((prop) => {
|
|
334
|
-
if (isRemoteFragment(prop)) {
|
|
335
|
-
attach(context, node, prop);
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
function detach(context, node) {
|
|
341
|
-
const { progenitors, parents } = context;
|
|
342
|
-
progenitors.delete(node);
|
|
343
|
-
parents.delete(node);
|
|
344
|
-
traverse(node, (descendant) => {
|
|
345
|
-
progenitors.delete(descendant);
|
|
346
|
-
detachFragments(context, descendant);
|
|
347
|
-
});
|
|
348
|
-
detachFragments(context, node);
|
|
349
|
-
}
|
|
350
|
-
function detachFragments(context, node) {
|
|
351
|
-
if (node.kind !== KIND_COMPONENT) {
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
const properties = node.properties;
|
|
355
|
-
for (const key of Object.keys(properties)) {
|
|
356
|
-
const p = properties[key];
|
|
357
|
-
if (isRemoteFragment(p)) {
|
|
358
|
-
detach(context, p);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
const update = (context, node, remote, local) => {
|
|
363
|
-
var _a;
|
|
364
|
-
if (context.mounted && (node.kind === KIND_ROOT || ((_a = node.progenitor) == null ? void 0 : _a.kind) === KIND_ROOT)) {
|
|
365
|
-
remote(context.channel);
|
|
366
|
-
}
|
|
367
|
-
local();
|
|
368
|
-
};
|
|
369
|
-
function dataOf(context, parent) {
|
|
370
|
-
switch (parent == null ? void 0 : parent.kind) {
|
|
371
|
-
case KIND_COMPONENT:
|
|
372
|
-
return context.components.get(parent);
|
|
373
|
-
case KIND_FRAGMENT:
|
|
374
|
-
return context.fragments.get(parent);
|
|
375
|
-
case KIND_ROOT:
|
|
376
|
-
return context;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
const insertToArray = (target, el, before) => {
|
|
380
|
-
if (before == null) {
|
|
381
|
-
target.push(el);
|
|
382
|
-
} else {
|
|
383
|
-
target.splice(target.indexOf(before), 0, el);
|
|
384
|
-
}
|
|
385
|
-
return target;
|
|
386
|
-
};
|
|
387
|
-
const remoteFromArray = (target, index) => {
|
|
388
|
-
const result = [...target];
|
|
389
|
-
result.splice(index, 1);
|
|
390
|
-
return result;
|
|
391
|
-
};
|
|
392
|
-
const insert = (context, parent, child, before = null) => {
|
|
393
|
-
const currentParent = child.parent;
|
|
394
|
-
const currentIndex = (currentParent == null ? void 0 : currentParent.children.indexOf(child)) ?? -1;
|
|
395
|
-
attach(context, parent, child);
|
|
396
|
-
let newChildren;
|
|
397
|
-
const parentData = dataOf(context, parent);
|
|
398
|
-
if (currentParent) {
|
|
399
|
-
const currentParentData = dataOf(context, currentParent);
|
|
400
|
-
const currentChildren = remoteFromArray(currentParentData.children, currentIndex);
|
|
401
|
-
if (currentParent === parent) {
|
|
402
|
-
newChildren = currentChildren;
|
|
403
|
-
} else {
|
|
404
|
-
currentParentData.children = capture(currentChildren, context.strict);
|
|
405
|
-
newChildren = [...parentData.children];
|
|
406
|
-
}
|
|
407
|
-
} else {
|
|
408
|
-
newChildren = [...parentData.children];
|
|
409
|
-
}
|
|
410
|
-
parentData.children = capture(insertToArray(newChildren, child, before), context.strict);
|
|
411
|
-
};
|
|
412
|
-
const appendChild = (context, parent, child) => {
|
|
413
|
-
if (!context.nodes.has(child)) {
|
|
414
|
-
throw new Error("Cannot append a node that was not created by this remote root");
|
|
415
|
-
}
|
|
416
|
-
const currentParent = child.parent;
|
|
417
|
-
const currentIndex = (currentParent == null ? void 0 : currentParent.children.indexOf(child)) ?? -1;
|
|
418
|
-
return update(context, parent, (channel) => {
|
|
419
|
-
channel(
|
|
420
|
-
ACTION_INSERT_CHILD,
|
|
421
|
-
parent.id,
|
|
422
|
-
currentIndex < 0 ? parent.children.length : parent.children.length - 1,
|
|
423
|
-
child.serialize(),
|
|
424
|
-
currentParent ? currentParent.id : false
|
|
425
|
-
);
|
|
426
|
-
}, () => insert(context, parent, child));
|
|
427
|
-
};
|
|
428
|
-
const insertBefore = (context, parent, child, before) => {
|
|
429
|
-
if (!context.nodes.has(child)) {
|
|
430
|
-
throw new Error("Cannot insert a node that was not created by this remote root");
|
|
431
|
-
}
|
|
432
|
-
if (before && before.id === child.id) return;
|
|
433
|
-
if (before && !parent.children.includes(before)) {
|
|
434
|
-
throw new DOMException(
|
|
435
|
-
"Cannot add a child before an element that is not a child of the target parent.",
|
|
436
|
-
"HierarchyRequestError"
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
const oldIndex = parent.children.indexOf(child) ?? -1;
|
|
440
|
-
const oldParent = child.parent;
|
|
441
|
-
const beforeIndex = before ? parent.children.indexOf(before) : -1;
|
|
442
|
-
return update(context, parent, (channel) => channel(
|
|
443
|
-
ACTION_INSERT_CHILD,
|
|
444
|
-
parent.id,
|
|
445
|
-
beforeIndex < 0 ? parent.children.length : oldIndex < 0 || oldIndex > beforeIndex ? beforeIndex : beforeIndex - 1,
|
|
446
|
-
child.serialize(),
|
|
447
|
-
oldParent ? oldParent.id : false
|
|
448
|
-
), () => insert(context, parent, child, before));
|
|
449
|
-
};
|
|
450
|
-
const removeChild = (context, parent, child) => {
|
|
451
|
-
const data = dataOf(context, parent);
|
|
452
|
-
return update(context, parent, (channel) => channel(
|
|
453
|
-
ACTION_REMOVE_CHILD,
|
|
454
|
-
parent.id,
|
|
455
|
-
parent.children.indexOf(child)
|
|
456
|
-
), () => {
|
|
457
|
-
detach(context, child);
|
|
458
|
-
data.children = capture(remoteFromArray(
|
|
459
|
-
data.children,
|
|
460
|
-
data.children.indexOf(child)
|
|
461
|
-
), context.strict);
|
|
462
|
-
});
|
|
463
|
-
};
|
|
464
|
-
const addAttachMethod = (context) => addMethod(context, "attach", (parent, node) => attach(context, parent, node));
|
|
465
|
-
const addDetachMethod = (context) => addMethod(context, "detach", (node) => detach(context, node));
|
|
466
|
-
const addAppendMethod$1 = (context) => addMethod(context, "append", (parent, children) => {
|
|
467
|
-
for (const child of children) {
|
|
468
|
-
appendChild(context, parent, child);
|
|
469
|
-
}
|
|
470
|
-
});
|
|
471
|
-
const addUpdateMethod = (context) => addMethod(context, "update", (node, remote, local) => update(context, node, remote, local));
|
|
472
|
-
const addReplaceMethod$1 = (context) => addMethod(context, "replace", (parent, children) => {
|
|
473
|
-
for (const child of parent.children) {
|
|
474
|
-
removeChild(context, parent, child);
|
|
475
|
-
}
|
|
476
|
-
for (const child of children) {
|
|
477
|
-
appendChild(context, parent, child);
|
|
478
|
-
}
|
|
479
|
-
});
|
|
480
|
-
const addCollectMethod = (context) => addMethod(context, "collect", (node) => {
|
|
481
|
-
if (context.nodes.has(node)) {
|
|
482
|
-
return;
|
|
483
|
-
}
|
|
484
|
-
context.nodes.add(node);
|
|
485
|
-
Object.defineProperty(node, "parent", {
|
|
486
|
-
get: () => context.parents.get(node) ?? null,
|
|
487
|
-
configurable: true,
|
|
488
|
-
enumerable: true
|
|
489
|
-
});
|
|
490
|
-
Object.defineProperty(node, "progenitor", {
|
|
491
|
-
get: () => context.progenitors.get(node) ?? null,
|
|
492
|
-
configurable: true,
|
|
493
|
-
enumerable: true
|
|
494
|
-
});
|
|
495
|
-
});
|
|
496
|
-
const addInvokeMethod = (context) => addMethod(context, "invoke", (node, method, payload) => {
|
|
497
|
-
if (!context.nodes.has(node)) {
|
|
498
|
-
throw new Error("Cannot invoke method for a node that was not created by this remote root");
|
|
499
|
-
}
|
|
500
|
-
return new Promise((resolve, reject) => {
|
|
501
|
-
context.channel(
|
|
502
|
-
ACTION_INVOKE,
|
|
503
|
-
node.id,
|
|
504
|
-
method,
|
|
505
|
-
payload,
|
|
506
|
-
resolve,
|
|
507
|
-
reject
|
|
508
|
-
);
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
const createRemoteRootData = (channel, { components, strict = true } = {}) => {
|
|
512
|
-
if (strict) {
|
|
513
|
-
Object.freeze(components);
|
|
514
|
-
}
|
|
515
|
-
return {
|
|
516
|
-
strict,
|
|
517
|
-
mounted: false,
|
|
518
|
-
channel,
|
|
519
|
-
children: [],
|
|
520
|
-
nodes: /* @__PURE__ */ new WeakSet(),
|
|
521
|
-
parents: /* @__PURE__ */ new WeakMap(),
|
|
522
|
-
progenitors: /* @__PURE__ */ new WeakMap(),
|
|
523
|
-
components: /* @__PURE__ */ new WeakMap(),
|
|
524
|
-
fragments: /* @__PURE__ */ new WeakMap()
|
|
525
|
-
};
|
|
526
|
-
};
|
|
527
|
-
const createTreeContext = (channel, options = {}) => {
|
|
528
|
-
const context = createRemoteRootData(channel, options);
|
|
529
|
-
let lastId = 0;
|
|
530
|
-
addMethod(context, "nextId", () => `${++lastId}`);
|
|
531
|
-
addCollectMethod(context);
|
|
532
|
-
addAttachMethod(context);
|
|
533
|
-
addDetachMethod(context);
|
|
534
|
-
addAppendMethod$1(context);
|
|
535
|
-
addUpdateMethod(context);
|
|
536
|
-
addMethod(context, "insert", (parent, child, before) => insertBefore(context, parent, child, before));
|
|
537
|
-
addMethod(context, "removeChild", (parent, child) => removeChild(context, parent, child));
|
|
538
|
-
addReplaceMethod$1(context);
|
|
539
|
-
addInvokeMethod(context);
|
|
540
|
-
return context;
|
|
541
|
-
};
|
|
542
|
-
const createRemoteComment = (content, root, context) => {
|
|
543
|
-
const id = context.nextId();
|
|
544
|
-
const data = { text: content };
|
|
545
|
-
const node = {
|
|
546
|
-
kind: KIND_COMMENT,
|
|
547
|
-
get id() {
|
|
548
|
-
return id;
|
|
549
|
-
},
|
|
550
|
-
get root() {
|
|
551
|
-
return root;
|
|
552
|
-
},
|
|
553
|
-
get text() {
|
|
554
|
-
return data.text;
|
|
555
|
-
},
|
|
556
|
-
update: (text) => context.update(
|
|
557
|
-
node,
|
|
558
|
-
(channel) => channel(ACTION_UPDATE_TEXT, node.id, text),
|
|
559
|
-
() => data.text = text
|
|
560
|
-
),
|
|
561
|
-
serialize: () => ({ id, kind: KIND_COMMENT, text: data.text }),
|
|
562
|
-
remove: () => {
|
|
563
|
-
var _a;
|
|
564
|
-
return (_a = node.parent) == null ? void 0 : _a.removeChild(node);
|
|
565
|
-
},
|
|
566
|
-
print: () => `Comment(${data.text})`
|
|
567
|
-
};
|
|
568
|
-
context.collect(node);
|
|
569
|
-
return node;
|
|
570
|
-
};
|
|
571
|
-
const isProxy = (value) => {
|
|
572
|
-
return value instanceof Function && "__current" in value;
|
|
573
|
-
};
|
|
574
|
-
const toProxy = (value) => {
|
|
575
|
-
const _proxy = (...args) => {
|
|
576
|
-
return _proxy.__current ? _proxy.__current(...args) : void 0;
|
|
577
|
-
};
|
|
578
|
-
Object.defineProperty(_proxy, "__current", {
|
|
579
|
-
value,
|
|
580
|
-
configurable: false,
|
|
581
|
-
enumerable: false,
|
|
582
|
-
writable: true
|
|
583
|
-
});
|
|
584
|
-
return _proxy;
|
|
585
|
-
};
|
|
586
|
-
function proxyFunctionsIn(value, visited = /* @__PURE__ */ new Map()) {
|
|
587
|
-
if (visited.has(value)) {
|
|
588
|
-
return visited.get(value);
|
|
589
|
-
}
|
|
590
|
-
if (isRemoteFragment(value)) {
|
|
591
|
-
visited.set(value, value);
|
|
592
|
-
return value;
|
|
593
|
-
}
|
|
594
|
-
if (Array.isArray(value)) {
|
|
595
|
-
return visitArray(value, visited, proxyFunctionsIn);
|
|
596
|
-
}
|
|
597
|
-
if (isObject(value)) {
|
|
598
|
-
return visitObject(value, visited, proxyFunctionsIn);
|
|
599
|
-
}
|
|
600
|
-
if (isFunction(value)) {
|
|
601
|
-
const proxy = toProxy(value);
|
|
602
|
-
visited.set(value, proxy);
|
|
603
|
-
return proxy;
|
|
604
|
-
}
|
|
605
|
-
visited.set(value, value);
|
|
606
|
-
return value;
|
|
607
|
-
}
|
|
608
|
-
const collectProxies = (value, visited = /* @__PURE__ */ new Set()) => {
|
|
609
|
-
if (visited.has(value)) {
|
|
610
|
-
return void 0;
|
|
611
|
-
}
|
|
612
|
-
visited.add(value);
|
|
613
|
-
if (Array.isArray(value)) {
|
|
614
|
-
return value.reduce((all, element) => {
|
|
615
|
-
const nested = collectProxies(element, visited);
|
|
616
|
-
return nested ? [...all, ...nested] : all;
|
|
617
|
-
}, []);
|
|
618
|
-
}
|
|
619
|
-
if (isObject(value)) {
|
|
620
|
-
return keysOf(value).reduce((all, key) => {
|
|
621
|
-
const nested = collectProxies(value[key], visited);
|
|
622
|
-
return nested ? [...all, ...nested] : all;
|
|
623
|
-
}, []);
|
|
624
|
-
}
|
|
625
|
-
return isProxy(value) ? [value] : void 0;
|
|
626
|
-
};
|
|
627
|
-
const prepareProxiesUnset = (value) => {
|
|
628
|
-
var _a;
|
|
629
|
-
return ((_a = collectProxies(value)) == null ? void 0 : _a.map((p) => [p, void 0])) ?? [];
|
|
630
|
-
};
|
|
631
|
-
function prepareProxies(oldValue, newValue, visited = /* @__PURE__ */ new Set()) {
|
|
632
|
-
if (visited.has(oldValue)) {
|
|
633
|
-
return [oldValue, [], true];
|
|
634
|
-
}
|
|
635
|
-
visited.add(oldValue);
|
|
636
|
-
if (isProxy(oldValue)) {
|
|
637
|
-
return isFunction(newValue) ? [oldValue, [[oldValue, newValue]], true] : [proxyFunctionsIn(newValue), [], false];
|
|
638
|
-
}
|
|
639
|
-
if (Array.isArray(oldValue)) {
|
|
640
|
-
return !Array.isArray(newValue) ? [proxyFunctionsIn(newValue), prepareProxiesUnset(oldValue), false] : prepareProxiesInArray(oldValue, newValue, visited);
|
|
641
|
-
}
|
|
642
|
-
if (isObject(oldValue) && !isRemoteFragment(oldValue)) {
|
|
643
|
-
return !isObject(newValue) ? [proxyFunctionsIn(newValue), prepareProxiesUnset(oldValue), false] : prepareProxiesInObject(oldValue, newValue, visited);
|
|
644
|
-
}
|
|
645
|
-
return [newValue, [], oldValue === newValue];
|
|
646
|
-
}
|
|
647
|
-
function prepareProxiesInObject(oldValue, newValue, visited) {
|
|
648
|
-
const normalized = {};
|
|
649
|
-
const records = [];
|
|
650
|
-
let changed = false;
|
|
651
|
-
for (const key of keysOf(oldValue)) {
|
|
652
|
-
const oldEl = oldValue[key];
|
|
653
|
-
if (!(key in newValue)) {
|
|
654
|
-
records.push(...prepareProxiesUnset(oldEl));
|
|
655
|
-
changed = true;
|
|
656
|
-
}
|
|
657
|
-
const newEl = newValue[key];
|
|
658
|
-
const [updated, record, skip] = prepareProxies(oldEl, newEl, visited);
|
|
659
|
-
records.push(...record);
|
|
660
|
-
if (!skip) {
|
|
661
|
-
normalized[key] = updated;
|
|
662
|
-
changed = true;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
for (const key of keysOf(newValue)) {
|
|
666
|
-
if (!(key in normalized)) {
|
|
667
|
-
normalized[key] = proxyFunctionsIn(newValue[key]);
|
|
668
|
-
changed = true;
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
return [normalized, records, !changed];
|
|
672
|
-
}
|
|
673
|
-
function prepareProxiesInArray(oldValue, newValue, visited) {
|
|
674
|
-
const normalized = [];
|
|
675
|
-
const records = [];
|
|
676
|
-
let changed = false;
|
|
677
|
-
for (let i = 0; i < Math.max(oldValue.length, newValue.length); i++) {
|
|
678
|
-
const oldEl = oldValue[i];
|
|
679
|
-
const newEl = newValue[i];
|
|
680
|
-
if (i >= newValue.length) {
|
|
681
|
-
records.push(...prepareProxiesUnset(oldEl));
|
|
682
|
-
changed = true;
|
|
683
|
-
continue;
|
|
684
|
-
}
|
|
685
|
-
if (i >= oldValue.length) {
|
|
686
|
-
normalized[i] = proxyFunctionsIn(newEl);
|
|
687
|
-
changed = true;
|
|
688
|
-
continue;
|
|
689
|
-
}
|
|
690
|
-
const [updated, record, skip] = prepareProxies(oldEl, newEl, visited);
|
|
691
|
-
records.push(...record);
|
|
692
|
-
normalized[i] = skip ? oldEl : updated;
|
|
693
|
-
changed = !skip || changed;
|
|
694
|
-
}
|
|
695
|
-
return [normalized, records, !changed];
|
|
696
|
-
}
|
|
697
|
-
const updateProxies = (records) => {
|
|
698
|
-
for (const [fn, current] of records) {
|
|
699
|
-
if (fn.__current !== current) {
|
|
700
|
-
fn.__current = current;
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
};
|
|
704
|
-
function createRemoteComponent(type, properties, children, root, context) {
|
|
705
|
-
const id = context.nextId();
|
|
706
|
-
const descriptor = typeof type === "object" && "type" in type ? type : null;
|
|
707
|
-
const data = createRemoteComponentData(properties, children, root, context);
|
|
708
|
-
const node = {
|
|
709
|
-
kind: KIND_COMPONENT,
|
|
710
|
-
get id() {
|
|
711
|
-
return id;
|
|
712
|
-
},
|
|
713
|
-
get type() {
|
|
714
|
-
return descriptor ? descriptor.type : type;
|
|
715
|
-
},
|
|
716
|
-
get root() {
|
|
717
|
-
return root;
|
|
718
|
-
},
|
|
719
|
-
get children() {
|
|
720
|
-
return data.children;
|
|
721
|
-
},
|
|
722
|
-
get properties() {
|
|
723
|
-
return data.properties.original;
|
|
724
|
-
},
|
|
725
|
-
append: (...children2) => context.append(
|
|
726
|
-
node,
|
|
727
|
-
normalizeChildren(children2, root)
|
|
728
|
-
),
|
|
729
|
-
insertBefore: (child, before) => context.insert(
|
|
730
|
-
node,
|
|
731
|
-
normalizeChild(child, root),
|
|
732
|
-
before
|
|
733
|
-
),
|
|
734
|
-
updateProperties: (properties2) => updateProperties(
|
|
735
|
-
context,
|
|
736
|
-
node,
|
|
737
|
-
properties2
|
|
738
|
-
),
|
|
739
|
-
replace: (...children2) => context.replace(
|
|
740
|
-
node,
|
|
741
|
-
normalizeChildren(children2, root)
|
|
742
|
-
),
|
|
743
|
-
removeChild: (child) => context.removeChild(node, child),
|
|
744
|
-
remove: () => node.parent ? context.removeChild(node.parent, node) : null,
|
|
745
|
-
invoke: (method, ...payload) => !descriptor || (descriptor == null ? void 0 : descriptor.hasMethod(method)) ? context.invoke(node, method, payload) : Promise.reject(`Method ${method} is not supported`),
|
|
746
|
-
serialize: () => ({
|
|
747
|
-
id,
|
|
748
|
-
kind: KIND_COMPONENT,
|
|
749
|
-
type,
|
|
750
|
-
properties: data.properties.serializable,
|
|
751
|
-
children: data.children.map((c) => c.serialize())
|
|
752
|
-
}),
|
|
753
|
-
print: () => _print(id, type, data.properties.original, data.children)
|
|
754
|
-
};
|
|
755
|
-
context.collect(node);
|
|
756
|
-
context.components.set(node, data);
|
|
757
|
-
data.children.forEach((c) => context.attach(node, c));
|
|
758
|
-
return node;
|
|
759
|
-
}
|
|
760
|
-
const RESERVED = ["children"];
|
|
761
|
-
const notReserved = (name) => !RESERVED.includes(name);
|
|
762
|
-
function createRemoteComponentData(properties, children, root, context) {
|
|
763
|
-
const original = properties ?? {};
|
|
764
|
-
const serializable = {};
|
|
765
|
-
for (const key of keysOf(original).filter(notReserved)) {
|
|
766
|
-
serializable[key] = proxyFunctionsIn(serializeProperty(original[key]));
|
|
767
|
-
}
|
|
768
|
-
return {
|
|
769
|
-
properties: {
|
|
770
|
-
original: capture(original, context.strict),
|
|
771
|
-
serializable
|
|
772
|
-
},
|
|
773
|
-
children: capture(normalizeChildren(children, root), context.strict)
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
function updateProperties(context, component, properties) {
|
|
777
|
-
const componentData = context.components.get(component);
|
|
778
|
-
const normalized = {};
|
|
779
|
-
const records = [];
|
|
780
|
-
let changed = false;
|
|
781
|
-
for (const key of keysOf(properties).filter(notReserved)) {
|
|
782
|
-
const oldOriginal = componentData.properties.original[key];
|
|
783
|
-
const newOriginal = properties[key];
|
|
784
|
-
const oldSerializable = componentData.properties.serializable[key];
|
|
785
|
-
const newSerializable = serializeProperty(newOriginal);
|
|
786
|
-
if (oldSerializable === newSerializable && (newSerializable == null || typeof newSerializable !== "object")) {
|
|
787
|
-
continue;
|
|
788
|
-
}
|
|
789
|
-
const [value, record, skip] = prepareProxies(oldSerializable, newSerializable);
|
|
790
|
-
records.push(...record);
|
|
791
|
-
if (!skip) {
|
|
792
|
-
normalized[key] = value;
|
|
793
|
-
changed = true;
|
|
794
|
-
if (isRemoteFragment(oldOriginal)) {
|
|
795
|
-
context.detach(oldOriginal);
|
|
796
|
-
}
|
|
797
|
-
if (isRemoteFragment(newOriginal)) {
|
|
798
|
-
context.attach(component, newOriginal);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
}
|
|
802
|
-
return context.update(component, (channel) => {
|
|
803
|
-
if (changed) {
|
|
804
|
-
channel(ACTION_UPDATE_PROPERTIES, component.id, normalized);
|
|
805
|
-
}
|
|
806
|
-
}, () => {
|
|
807
|
-
componentData.properties.original = capture({ ...componentData.properties.original, ...properties }, context.strict);
|
|
808
|
-
componentData.properties.serializable = { ...componentData.properties.serializable, ...normalized };
|
|
809
|
-
updateProxies(records);
|
|
810
|
-
});
|
|
811
|
-
}
|
|
812
|
-
function serializeProperty(property) {
|
|
813
|
-
return isRemoteFragment(property) ? property.serialize() : property;
|
|
814
|
-
}
|
|
815
|
-
function _print(id, type, _properties, children) {
|
|
816
|
-
const _head = `${typeof type === "string" ? type : type.type}:${id}`;
|
|
817
|
-
const _children = children.map((c) => typeof c === "string" ? c : c.print());
|
|
818
|
-
const _body = _children.length > 0 ? `
|
|
819
|
-
${_indent(_children.join(",\n"))}
|
|
820
|
-
` : "";
|
|
821
|
-
return `${_head}[${_body}]`;
|
|
822
|
-
}
|
|
823
|
-
function _indent(text) {
|
|
824
|
-
return text.split("\n").map((line) => ` ${line}`).join("\n");
|
|
825
|
-
}
|
|
826
|
-
const createRemoteFragment = (root, context) => {
|
|
827
|
-
const id = context.nextId();
|
|
828
|
-
const data = { children: capture([], context.strict) };
|
|
829
|
-
const fragment = {
|
|
830
|
-
kind: KIND_FRAGMENT,
|
|
831
|
-
get id() {
|
|
832
|
-
return id;
|
|
833
|
-
},
|
|
834
|
-
get root() {
|
|
835
|
-
return root;
|
|
836
|
-
},
|
|
837
|
-
get children() {
|
|
838
|
-
return data.children;
|
|
839
|
-
},
|
|
840
|
-
append: (...children) => context.append(fragment, normalizeChildren(children, root)),
|
|
841
|
-
insertBefore: (child, before) => context.insert(
|
|
842
|
-
fragment,
|
|
843
|
-
normalizeChild(child, root),
|
|
844
|
-
before
|
|
845
|
-
),
|
|
846
|
-
replace: (...children) => context.replace(fragment, normalizeChildren(children, root)),
|
|
847
|
-
removeChild: (child) => context.removeChild(fragment, child),
|
|
848
|
-
serialize: () => ({
|
|
849
|
-
id,
|
|
850
|
-
kind: KIND_FRAGMENT,
|
|
851
|
-
children: data.children.map((c) => c.serialize())
|
|
852
|
-
})
|
|
853
|
-
};
|
|
854
|
-
context.collect(fragment);
|
|
855
|
-
context.fragments.set(fragment, data);
|
|
856
|
-
return fragment;
|
|
857
|
-
};
|
|
858
|
-
const createRemoteText = (content, root, context) => {
|
|
859
|
-
const id = context.nextId();
|
|
860
|
-
const data = { text: content };
|
|
861
|
-
const node = {
|
|
862
|
-
kind: KIND_TEXT,
|
|
863
|
-
get id() {
|
|
864
|
-
return id;
|
|
865
|
-
},
|
|
866
|
-
get root() {
|
|
867
|
-
return root;
|
|
868
|
-
},
|
|
869
|
-
get text() {
|
|
870
|
-
return data.text;
|
|
871
|
-
},
|
|
872
|
-
update: (text) => context.update(
|
|
873
|
-
node,
|
|
874
|
-
(channel) => channel(ACTION_UPDATE_TEXT, node.id, text),
|
|
875
|
-
() => data.text = text
|
|
876
|
-
),
|
|
877
|
-
serialize: () => ({ id, kind: KIND_TEXT, text: data.text }),
|
|
878
|
-
remove: () => {
|
|
879
|
-
var _a;
|
|
880
|
-
return (_a = node.parent) == null ? void 0 : _a.removeChild(node);
|
|
881
|
-
},
|
|
882
|
-
print: () => `Text(${data.text})`
|
|
883
|
-
};
|
|
884
|
-
context.collect(node);
|
|
885
|
-
return node;
|
|
886
|
-
};
|
|
887
|
-
function createRemoteRoot$1(channel, {
|
|
888
|
-
components,
|
|
889
|
-
strict = true
|
|
890
|
-
} = {}) {
|
|
891
|
-
const context = createTreeContext(channel, {
|
|
892
|
-
components,
|
|
893
|
-
strict
|
|
894
|
-
});
|
|
895
|
-
const root = {
|
|
896
|
-
kind: KIND_ROOT,
|
|
897
|
-
options: capture({ strict, components }, strict),
|
|
898
|
-
get id() {
|
|
899
|
-
return ROOT_ID;
|
|
900
|
-
},
|
|
901
|
-
get children() {
|
|
902
|
-
return context.children;
|
|
903
|
-
},
|
|
904
|
-
removeChild: (child) => context.removeChild(root, child)
|
|
905
|
-
};
|
|
906
|
-
addCreateCommentMethod(root, context);
|
|
907
|
-
addCreateComponentMethod(root, context);
|
|
908
|
-
addCreateFragmentMethod(root, context);
|
|
909
|
-
addCreateTextMethod(root, context);
|
|
910
|
-
addMountMethod(root, context);
|
|
911
|
-
addAppendMethod(root, context);
|
|
912
|
-
addInsertMethod(root, context);
|
|
913
|
-
addReplaceMethod(root, context);
|
|
914
|
-
return root;
|
|
915
|
-
}
|
|
916
|
-
function addCreateCommentMethod(root, context) {
|
|
917
|
-
addMethod(root, "createComment", (text = "") => {
|
|
918
|
-
return createRemoteComment(text, root, context);
|
|
919
|
-
});
|
|
920
|
-
}
|
|
921
|
-
function addCreateComponentMethod(root, context) {
|
|
922
|
-
addMethod(root, "createComponent", (type, ...rest) => {
|
|
923
|
-
const components = root.options.components;
|
|
924
|
-
if (components && !components.some((c) => c === type || c.type === type)) {
|
|
925
|
-
throw new Error(`Unsupported component: ${type}`);
|
|
926
|
-
}
|
|
927
|
-
const _type = (components == null ? void 0 : components.find((c) => c === type || c.type === type)) ?? type;
|
|
928
|
-
const [properties, children, ...restChildren] = rest;
|
|
929
|
-
return createRemoteComponent(_type, properties, [
|
|
930
|
-
...arraify(children ?? []),
|
|
931
|
-
...restChildren
|
|
932
|
-
], root, context);
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
function addCreateFragmentMethod(root, context) {
|
|
936
|
-
addMethod(root, "createFragment", () => createRemoteFragment(root, context));
|
|
937
|
-
}
|
|
938
|
-
function addCreateTextMethod(root, context) {
|
|
939
|
-
addMethod(root, "createText", (text = "") => {
|
|
940
|
-
return createRemoteText(text, root, context);
|
|
941
|
-
});
|
|
942
|
-
}
|
|
943
|
-
function addMountMethod(root, context) {
|
|
944
|
-
addMethod(root, "mount", () => {
|
|
945
|
-
if (context.mounted) {
|
|
946
|
-
return Promise.resolve();
|
|
947
|
-
}
|
|
948
|
-
context.mounted = true;
|
|
949
|
-
return Promise.resolve(context.channel(
|
|
950
|
-
ACTION_MOUNT,
|
|
951
|
-
context.children.map((c) => c.serialize())
|
|
952
|
-
));
|
|
953
|
-
});
|
|
954
|
-
}
|
|
955
|
-
function addAppendMethod(root, context) {
|
|
956
|
-
addMethod(root, "append", (...children) => {
|
|
957
|
-
context.append(root, normalizeChildren(children, root));
|
|
958
|
-
});
|
|
959
|
-
}
|
|
960
|
-
function addInsertMethod(root, context) {
|
|
961
|
-
addMethod(root, "insertBefore", (child, before) => {
|
|
962
|
-
context.insert(root, normalizeChild(child, root), before);
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
function addReplaceMethod(root, context) {
|
|
966
|
-
addMethod(root, "replace", (...children) => {
|
|
967
|
-
context.replace(root, normalizeChildren(children, root));
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
const createRemoteRoot = (channel, options = {}) => createRemoteRoot$1(channel, {
|
|
971
|
-
...options,
|
|
972
|
-
components: [
|
|
973
|
-
...HTMLTagList,
|
|
974
|
-
...MathMLTagList,
|
|
975
|
-
...SVGTagList,
|
|
976
|
-
REMOTE_SLOT,
|
|
977
|
-
...options.components ?? []
|
|
978
|
-
]
|
|
979
|
-
});
|
|
980
|
-
const toRemoteSlots = (named, slots) => {
|
|
981
|
-
const actual = named.filter((slotName) => slotName in slots);
|
|
982
|
-
if (actual.length === 0) {
|
|
983
|
-
return slots;
|
|
984
|
-
}
|
|
985
|
-
return {
|
|
986
|
-
default: () => {
|
|
987
|
-
var _a;
|
|
988
|
-
return [
|
|
989
|
-
..."default" in slots ? [(_a = slots.default) == null ? void 0 : _a.call(slots)] : [],
|
|
990
|
-
...actual.map((slotName) => h(REMOTE_SLOT, { name: slotName }, {
|
|
991
|
-
default: slots[slotName]
|
|
992
|
-
}))
|
|
993
|
-
];
|
|
994
|
-
}
|
|
995
|
-
};
|
|
996
|
-
};
|
|
997
|
-
const capitalize = (text) => text.charAt(0).toUpperCase() + text.slice(1);
|
|
998
|
-
const fallthroughEvents = (emits, emit) => {
|
|
999
|
-
if (emits === void 0) {
|
|
1000
|
-
return {};
|
|
1001
|
-
}
|
|
1002
|
-
const events2 = Array.isArray(emits) ? emits : Object.keys(emits);
|
|
1003
|
-
return events2.reduce((processed, event) => {
|
|
1004
|
-
processed["on" + capitalize(event)] = (...args) => emit(event, ...args);
|
|
1005
|
-
return processed;
|
|
1006
|
-
}, {});
|
|
1007
|
-
};
|
|
1008
|
-
const defineRemoteComponent = (type, emits = void 0, slots = []) => defineComponent({
|
|
1009
|
-
name: type,
|
|
1010
|
-
inheritAttrs: false,
|
|
1011
|
-
...emits ? { emits } : {},
|
|
1012
|
-
setup(props, { attrs, emit, slots: internalSlots }) {
|
|
1013
|
-
return () => h(type, {
|
|
1014
|
-
...props,
|
|
1015
|
-
...attrs,
|
|
1016
|
-
...fallthroughEvents(emits, emit)
|
|
1017
|
-
}, toRemoteSlots(slots, internalSlots));
|
|
1018
|
-
}
|
|
1019
|
-
});
|
|
1020
7
|
const UiAddButtonType = "UiAddButton";
|
|
1021
8
|
const UiAddButton = defineRemoteComponent(
|
|
1022
9
|
UiAddButtonType,
|
|
@@ -1599,7 +586,7 @@ class I18n {
|
|
|
1599
586
|
compute(locale, key, values) {
|
|
1600
587
|
const computed2 = this.computed[key];
|
|
1601
588
|
if (computed2) {
|
|
1602
|
-
return computed2(localize
|
|
589
|
+
return computed2(localize(this, locale), values);
|
|
1603
590
|
}
|
|
1604
591
|
if (this.parent) {
|
|
1605
592
|
return this.parent.compute(locale, key, values);
|
|
@@ -1614,7 +601,7 @@ class I18n {
|
|
|
1614
601
|
}, this);
|
|
1615
602
|
}
|
|
1616
603
|
}
|
|
1617
|
-
const localize
|
|
604
|
+
const localize = (i18n, locale) => ({
|
|
1618
605
|
t(path, values = void 0) {
|
|
1619
606
|
return i18n.t(locale, path, values);
|
|
1620
607
|
},
|
|
@@ -1634,7 +621,7 @@ const define = (options = void 0, parent = void 0) => {
|
|
|
1634
621
|
const extend = (i18n2, options2 = void 0) => options2 ? i18n2.extend(options2) : i18n2;
|
|
1635
622
|
return {
|
|
1636
623
|
i18n,
|
|
1637
|
-
init: (locale, options2 = void 0) => localize
|
|
624
|
+
init: (locale, options2 = void 0) => localize(
|
|
1638
625
|
extend(i18n, options2),
|
|
1639
626
|
locale
|
|
1640
627
|
),
|
|
@@ -1696,6 +683,7 @@ const FilterKey = Symbol("UiSelectFilter");
|
|
|
1696
683
|
const FilteredKey = Symbol("UiSelectFiltered");
|
|
1697
684
|
const TickerKey = Symbol("UiSelectTicker");
|
|
1698
685
|
const MultipleKey = Symbol("UiSelectMultiple");
|
|
686
|
+
const ActiveOptionIdKey = Symbol("UiSelectActiveOptionId");
|
|
1699
687
|
const FastenedKey = Symbol("UiSelectFastened");
|
|
1700
688
|
const UnregisterOptionKey = Symbol("UiSelectUnregisterOption");
|
|
1701
689
|
const RegisterOptionKey = Symbol("UiSelectRegisterOption");
|
|
@@ -1711,6 +699,7 @@ const UiSelectTrigger = defineRemoteComponent(
|
|
|
1711
699
|
"input",
|
|
1712
700
|
"focus",
|
|
1713
701
|
"blur",
|
|
702
|
+
"keydown",
|
|
1714
703
|
"clear",
|
|
1715
704
|
"update:value",
|
|
1716
705
|
"update:expanded"
|
|
@@ -1857,11 +846,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1857
846
|
filter: "",
|
|
1858
847
|
value: props.value
|
|
1859
848
|
});
|
|
849
|
+
const localId = uid("ui-v1-select");
|
|
850
|
+
const resolvedId = computed(() => props.id ?? localId);
|
|
1860
851
|
const i18n = computed(() => _18n.init(inject(I18nInjectKey, null)?.locale ?? _18n.fallback));
|
|
1861
852
|
const noResult = computed(() => i18n.value.t("search.noResult", { filter: state.filter }));
|
|
1862
853
|
const optionsRegistry = ref([]);
|
|
854
|
+
const activeOptionId = ref(null);
|
|
1863
855
|
const selection = computed(() => {
|
|
1864
|
-
const model =
|
|
856
|
+
const model = arraify(state.value);
|
|
1865
857
|
const selectedOptions = [];
|
|
1866
858
|
model.forEach((item) => {
|
|
1867
859
|
const option = optionsRegistry.value.find((o) => equals(o.value, item));
|
|
@@ -1871,9 +863,10 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1871
863
|
});
|
|
1872
864
|
return selectedOptions;
|
|
1873
865
|
});
|
|
1874
|
-
const
|
|
866
|
+
const arraify = (value) => Array.isArray(value) ? [...value] : typeof value === "number" || typeof value === "boolean" || value ? [value] : [];
|
|
1875
867
|
const equals = (a, b) => props.equalsFn(a, b);
|
|
1876
868
|
const contains = (array, value) => array.some((v) => equals(v, value));
|
|
869
|
+
const navigableOptions = computed(() => optionsRegistry.value.filter((option) => option.isMatched() && !option.disabled));
|
|
1877
870
|
provide(RegisterKey, (option) => {
|
|
1878
871
|
if (optionsRegistry.value.some((item) => item.id === option.id)) {
|
|
1879
872
|
throw new Error(`[UiSelect] Component with id ${option.id} already registered. Unregister it before using again.`);
|
|
@@ -1885,6 +878,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1885
878
|
if (option) {
|
|
1886
879
|
option.label = data.label;
|
|
1887
880
|
option.value = data.value;
|
|
881
|
+
option.disabled = data.disabled;
|
|
1888
882
|
}
|
|
1889
883
|
});
|
|
1890
884
|
provide(UnregisterKey, (id) => {
|
|
@@ -1898,7 +892,7 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1898
892
|
}));
|
|
1899
893
|
provide(ToggleKey, (value) => {
|
|
1900
894
|
if (props.multiple) {
|
|
1901
|
-
const model =
|
|
895
|
+
const model = arraify(state.value);
|
|
1902
896
|
const index = model.findIndex((item) => equals(item, value));
|
|
1903
897
|
if (index !== -1) {
|
|
1904
898
|
model.splice(index, 1);
|
|
@@ -1918,29 +912,149 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1918
912
|
provide(FilteredKey, computed(() => props.filterable && state.filter.length > 0));
|
|
1919
913
|
provide(TickerKey, computed(() => props.ticker));
|
|
1920
914
|
provide(MultipleKey, computed(() => props.multiple));
|
|
915
|
+
provide(ActiveOptionIdKey, computed(() => activeOptionId.value));
|
|
1921
916
|
const onInput = (value) => {
|
|
1922
917
|
state.filter = value;
|
|
1923
918
|
};
|
|
919
|
+
const resolveHighlightedOption = (mode = "selected-first") => {
|
|
920
|
+
const options = navigableOptions.value;
|
|
921
|
+
if (options.length === 0) {
|
|
922
|
+
activeOptionId.value = null;
|
|
923
|
+
return;
|
|
924
|
+
}
|
|
925
|
+
if (mode === "first") {
|
|
926
|
+
activeOptionId.value = options[0].id;
|
|
927
|
+
return;
|
|
928
|
+
}
|
|
929
|
+
if (mode === "last") {
|
|
930
|
+
activeOptionId.value = options[options.length - 1].id;
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
const selectedOption = options.find((option) => {
|
|
934
|
+
return Array.isArray(state.value) ? contains(state.value, option.value) : equals(state.value, option.value);
|
|
935
|
+
});
|
|
936
|
+
activeOptionId.value = selectedOption?.id ?? options[0].id;
|
|
937
|
+
};
|
|
938
|
+
const moveHighlight = (step) => {
|
|
939
|
+
const options = navigableOptions.value;
|
|
940
|
+
if (options.length === 0) {
|
|
941
|
+
activeOptionId.value = null;
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
const currentIndex = options.findIndex((option) => option.id === activeOptionId.value);
|
|
945
|
+
const nextIndex = currentIndex === -1 ? step > 0 ? 0 : options.length - 1 : (currentIndex + step + options.length) % options.length;
|
|
946
|
+
activeOptionId.value = options[nextIndex].id;
|
|
947
|
+
};
|
|
948
|
+
const selectHighlightedOption = () => {
|
|
949
|
+
const option = navigableOptions.value.find((item) => item.id === activeOptionId.value);
|
|
950
|
+
if (!option) {
|
|
951
|
+
return;
|
|
952
|
+
}
|
|
953
|
+
if (props.multiple) {
|
|
954
|
+
const model = arraify(state.value);
|
|
955
|
+
const index = model.findIndex((item) => equals(item, option.value));
|
|
956
|
+
if (index !== -1) {
|
|
957
|
+
model.splice(index, 1);
|
|
958
|
+
} else {
|
|
959
|
+
model.push(option.value);
|
|
960
|
+
}
|
|
961
|
+
state.value = model;
|
|
962
|
+
} else {
|
|
963
|
+
state.value = option.value;
|
|
964
|
+
close();
|
|
965
|
+
}
|
|
966
|
+
};
|
|
967
|
+
const onKeyDown = (event) => {
|
|
968
|
+
if (props.disabled || props.readonly) {
|
|
969
|
+
return;
|
|
970
|
+
}
|
|
971
|
+
if (event.key === "Escape") {
|
|
972
|
+
close();
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
975
|
+
if (event.key === "Tab") {
|
|
976
|
+
close();
|
|
977
|
+
return;
|
|
978
|
+
}
|
|
979
|
+
if (event.key === "Home") {
|
|
980
|
+
if (!state.expanded) {
|
|
981
|
+
state.expanded = true;
|
|
982
|
+
}
|
|
983
|
+
resolveHighlightedOption("first");
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
if (event.key === "End") {
|
|
987
|
+
if (!state.expanded) {
|
|
988
|
+
state.expanded = true;
|
|
989
|
+
}
|
|
990
|
+
resolveHighlightedOption("last");
|
|
991
|
+
return;
|
|
992
|
+
}
|
|
993
|
+
if (event.key === "ArrowDown") {
|
|
994
|
+
if (!state.expanded) {
|
|
995
|
+
state.expanded = true;
|
|
996
|
+
resolveHighlightedOption("first");
|
|
997
|
+
return;
|
|
998
|
+
}
|
|
999
|
+
moveHighlight(1);
|
|
1000
|
+
return;
|
|
1001
|
+
}
|
|
1002
|
+
if (event.key === "ArrowUp") {
|
|
1003
|
+
if (!state.expanded) {
|
|
1004
|
+
state.expanded = true;
|
|
1005
|
+
resolveHighlightedOption("last");
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
moveHighlight(-1);
|
|
1009
|
+
return;
|
|
1010
|
+
}
|
|
1011
|
+
if (event.key === "Enter") {
|
|
1012
|
+
if (!state.expanded) {
|
|
1013
|
+
state.expanded = true;
|
|
1014
|
+
resolveHighlightedOption("selected-first");
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
selectHighlightedOption();
|
|
1018
|
+
}
|
|
1019
|
+
};
|
|
1924
1020
|
const close = () => {
|
|
1925
1021
|
if (state.expanded) {
|
|
1926
1022
|
state.expanded = false;
|
|
1927
1023
|
state.filter = "";
|
|
1024
|
+
activeOptionId.value = null;
|
|
1928
1025
|
}
|
|
1929
1026
|
};
|
|
1930
1027
|
watch(() => props.expanded, (newVal) => {
|
|
1931
1028
|
state.expanded = newVal;
|
|
1932
1029
|
if (!newVal) {
|
|
1933
1030
|
state.filter = "";
|
|
1031
|
+
activeOptionId.value = null;
|
|
1934
1032
|
}
|
|
1935
1033
|
});
|
|
1936
1034
|
watch(() => props.value, (newVal) => {
|
|
1937
1035
|
state.value = newVal;
|
|
1938
1036
|
});
|
|
1037
|
+
watch(() => state.expanded, (expanded) => {
|
|
1038
|
+
if (expanded) {
|
|
1039
|
+
resolveHighlightedOption("selected-first");
|
|
1040
|
+
} else {
|
|
1041
|
+
activeOptionId.value = null;
|
|
1042
|
+
}
|
|
1043
|
+
});
|
|
1044
|
+
watch(navigableOptions, () => {
|
|
1045
|
+
if (!state.expanded) {
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
const exists = navigableOptions.value.some((option) => option.id === activeOptionId.value);
|
|
1049
|
+
if (!exists) {
|
|
1050
|
+
resolveHighlightedOption("selected-first");
|
|
1051
|
+
}
|
|
1052
|
+
});
|
|
1939
1053
|
return (_ctx, _cache) => {
|
|
1940
1054
|
return openBlock(), createBlock(unref(UiPopperConnector), null, {
|
|
1941
1055
|
default: withCtx(() => [
|
|
1942
1056
|
createVNode(unref(UiSelectTrigger), {
|
|
1943
|
-
id:
|
|
1057
|
+
id: resolvedId.value,
|
|
1944
1058
|
value: state.value,
|
|
1945
1059
|
multiple: __props.multiple,
|
|
1946
1060
|
selection: selection.value,
|
|
@@ -1954,12 +1068,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
1954
1068
|
"placeholder-only": __props.placeholderOnly,
|
|
1955
1069
|
placeholder: __props.placeholder,
|
|
1956
1070
|
"textbox-size": __props.textboxSize,
|
|
1071
|
+
"active-descendant": activeOptionId.value,
|
|
1957
1072
|
onInput,
|
|
1073
|
+
onKeydown: onKeyDown,
|
|
1958
1074
|
"onUpdate:value": _cache[0] || (_cache[0] = ($event) => state.value = $event),
|
|
1959
1075
|
"onUpdate:expanded": _cache[1] || (_cache[1] = ($event) => state.expanded = $event)
|
|
1960
|
-
}, null, 8, ["id", "value", "multiple", "selection", "filter", "filterable", "clearable", "expanded", "invalid", "disabled", "readonly", "placeholder-only", "placeholder", "textbox-size"]),
|
|
1076
|
+
}, null, 8, ["id", "value", "multiple", "selection", "filter", "filterable", "clearable", "expanded", "invalid", "disabled", "readonly", "placeholder-only", "placeholder", "textbox-size", "active-descendant"]),
|
|
1961
1077
|
createVNode(unref(UiSelectPopper), {
|
|
1962
|
-
id:
|
|
1078
|
+
id: resolvedId.value,
|
|
1963
1079
|
disabled: __props.disabled || __props.readonly,
|
|
1964
1080
|
multiple: __props.multiple,
|
|
1965
1081
|
opened: state.expanded,
|
|
@@ -2024,7 +1140,7 @@ var SIZE = /* @__PURE__ */ ((SIZE2) => {
|
|
|
2024
1140
|
SIZE2["LG"] = "lg";
|
|
2025
1141
|
return SIZE2;
|
|
2026
1142
|
})(SIZE || {});
|
|
2027
|
-
const _hoisted_1 = ["aria-selected"];
|
|
1143
|
+
const _hoisted_1 = ["id", "aria-selected", "aria-current"];
|
|
2028
1144
|
const _hoisted_2 = ["innerHTML"];
|
|
2029
1145
|
const _hoisted_3 = ["innerHTML"];
|
|
2030
1146
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
@@ -2080,8 +1196,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2080
1196
|
IsSelectedKey,
|
|
2081
1197
|
computed(() => () => false)
|
|
2082
1198
|
);
|
|
2083
|
-
const syncInSelect = inject(SyncKey, () =>
|
|
2084
|
-
});
|
|
1199
|
+
const syncInSelect = inject(SyncKey, (() => void 0));
|
|
2085
1200
|
const registerInGroup = inject(RegisterOptionKey, () => {
|
|
2086
1201
|
});
|
|
2087
1202
|
const registerInSelect = inject(RegisterKey, () => {
|
|
@@ -2093,6 +1208,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2093
1208
|
const toggle = inject(ToggleKey, () => {
|
|
2094
1209
|
});
|
|
2095
1210
|
const fastened = inject(FastenedKey, false);
|
|
1211
|
+
const activeOptionId = inject(ActiveOptionIdKey, ref(null));
|
|
2096
1212
|
const filter = inject(FilterKey, ref(""));
|
|
2097
1213
|
const filtered = inject(FilteredKey, ref(false));
|
|
2098
1214
|
const ticker = inject(TickerKey, ref(false));
|
|
@@ -2103,6 +1219,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2103
1219
|
description: filtered.value ? highlight$1(props.description, "font-weight: 600;") : props.description
|
|
2104
1220
|
}));
|
|
2105
1221
|
const matched = computed(() => texts.value.label !== props.label || texts.value.description !== props.description);
|
|
1222
|
+
const active = computed(() => props.active || activeOptionId.value === id);
|
|
2106
1223
|
const selected2 = computed(() => props.active || isSelected.value(props.value));
|
|
2107
1224
|
const hidden = computed(() => !(fastened || !filtered.value || matched.value));
|
|
2108
1225
|
const onClick = () => {
|
|
@@ -2112,12 +1229,14 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2112
1229
|
};
|
|
2113
1230
|
const off = watch([
|
|
2114
1231
|
() => props.label,
|
|
2115
|
-
() => props.value
|
|
2116
|
-
|
|
2117
|
-
|
|
1232
|
+
() => props.value,
|
|
1233
|
+
() => props.disabled
|
|
1234
|
+
], ([newLabel, newValue, newDisabled], [oldLabel, oldValue, oldDisabled]) => {
|
|
1235
|
+
if (newLabel !== oldLabel || !isEqual(newValue, oldValue) || newDisabled !== oldDisabled) {
|
|
2118
1236
|
syncInSelect(id, {
|
|
2119
1237
|
label: newLabel,
|
|
2120
|
-
value: newValue
|
|
1238
|
+
value: newValue,
|
|
1239
|
+
disabled: newDisabled
|
|
2121
1240
|
});
|
|
2122
1241
|
}
|
|
2123
1242
|
});
|
|
@@ -2126,6 +1245,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2126
1245
|
id,
|
|
2127
1246
|
value: props.value,
|
|
2128
1247
|
label: props.label,
|
|
1248
|
+
disabled: props.disabled,
|
|
2129
1249
|
isMatched: () => !filtered.value || matched.value
|
|
2130
1250
|
};
|
|
2131
1251
|
registerInSelect(option);
|
|
@@ -2137,10 +1257,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2137
1257
|
unregisterInGroup(id);
|
|
2138
1258
|
});
|
|
2139
1259
|
return (_ctx, _cache) => {
|
|
2140
|
-
return openBlock(), createElementBlock("div", mergeProps(_ctx.$attrs, {
|
|
1260
|
+
return openBlock(), createElementBlock("div", mergeProps({ id: unref(id) }, _ctx.$attrs, {
|
|
2141
1261
|
"aria-selected": selected2.value ? "true" : "false",
|
|
1262
|
+
"aria-current": active.value ? "true" : void 0,
|
|
2142
1263
|
class: {
|
|
2143
1264
|
"ui-v1-select-option": true,
|
|
1265
|
+
"ui-v1-select-option_active": active.value,
|
|
2144
1266
|
"ui-v1-select-option_selected": selected2.value,
|
|
2145
1267
|
"ui-v1-select-option_disabled": __props.disabled,
|
|
2146
1268
|
"ui-v1-select-option_hidden": hidden.value
|
|
@@ -2154,6 +1276,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2154
1276
|
}, () => [
|
|
2155
1277
|
createVNode(unref(UiMenuItem), {
|
|
2156
1278
|
accent: __props.accent,
|
|
1279
|
+
active: active.value,
|
|
2157
1280
|
counter: __props.counter,
|
|
2158
1281
|
disabled: __props.disabled,
|
|
2159
1282
|
size: __props.size,
|
|
@@ -2197,7 +1320,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
2197
1320
|
]),
|
|
2198
1321
|
key: "1"
|
|
2199
1322
|
} : void 0
|
|
2200
|
-
]), 1032, ["accent", "counter", "disabled", "size", "ticker"])
|
|
1323
|
+
]), 1032, ["accent", "active", "counter", "disabled", "size", "ticker"])
|
|
2201
1324
|
])
|
|
2202
1325
|
], 16, _hoisted_1);
|
|
2203
1326
|
};
|
|
@@ -2388,1601 +1511,6 @@ const usePreview = (workers = ref([])) => {
|
|
|
2388
1511
|
preview: (url, resize = void 0, crop = void 0) => preview(_workers.value, url, resize, crop)
|
|
2389
1512
|
};
|
|
2390
1513
|
};
|
|
2391
|
-
function buildFormatLongFn(args) {
|
|
2392
|
-
return (options = {}) => {
|
|
2393
|
-
const width = options.width ? String(options.width) : args.defaultWidth;
|
|
2394
|
-
const format2 = args.formats[width] || args.formats[args.defaultWidth];
|
|
2395
|
-
return format2;
|
|
2396
|
-
};
|
|
2397
|
-
}
|
|
2398
|
-
function buildLocalizeFn(args) {
|
|
2399
|
-
return (value, options) => {
|
|
2400
|
-
const context = options?.context ? String(options.context) : "standalone";
|
|
2401
|
-
let valuesArray;
|
|
2402
|
-
if (context === "formatting" && args.formattingValues) {
|
|
2403
|
-
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
2404
|
-
const width = options?.width ? String(options.width) : defaultWidth;
|
|
2405
|
-
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
2406
|
-
} else {
|
|
2407
|
-
const defaultWidth = args.defaultWidth;
|
|
2408
|
-
const width = options?.width ? String(options.width) : args.defaultWidth;
|
|
2409
|
-
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
2410
|
-
}
|
|
2411
|
-
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
2412
|
-
return valuesArray[index];
|
|
2413
|
-
};
|
|
2414
|
-
}
|
|
2415
|
-
function buildMatchFn(args) {
|
|
2416
|
-
return (string, options = {}) => {
|
|
2417
|
-
const width = options.width;
|
|
2418
|
-
const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
|
|
2419
|
-
const matchResult = string.match(matchPattern);
|
|
2420
|
-
if (!matchResult) {
|
|
2421
|
-
return null;
|
|
2422
|
-
}
|
|
2423
|
-
const matchedString = matchResult[0];
|
|
2424
|
-
const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
|
|
2425
|
-
const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
|
|
2426
|
-
// [TODO] -- I challenge you to fix the type
|
|
2427
|
-
findKey(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
2428
|
-
);
|
|
2429
|
-
let value;
|
|
2430
|
-
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
2431
|
-
value = options.valueCallback ? (
|
|
2432
|
-
// [TODO] -- I challenge you to fix the type
|
|
2433
|
-
options.valueCallback(value)
|
|
2434
|
-
) : value;
|
|
2435
|
-
const rest = string.slice(matchedString.length);
|
|
2436
|
-
return { value, rest };
|
|
2437
|
-
};
|
|
2438
|
-
}
|
|
2439
|
-
function findKey(object, predicate) {
|
|
2440
|
-
for (const key in object) {
|
|
2441
|
-
if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
|
|
2442
|
-
return key;
|
|
2443
|
-
}
|
|
2444
|
-
}
|
|
2445
|
-
return void 0;
|
|
2446
|
-
}
|
|
2447
|
-
function findIndex(array, predicate) {
|
|
2448
|
-
for (let key = 0; key < array.length; key++) {
|
|
2449
|
-
if (predicate(array[key])) {
|
|
2450
|
-
return key;
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
return void 0;
|
|
2454
|
-
}
|
|
2455
|
-
function buildMatchPatternFn(args) {
|
|
2456
|
-
return (string, options = {}) => {
|
|
2457
|
-
const matchResult = string.match(args.matchPattern);
|
|
2458
|
-
if (!matchResult) return null;
|
|
2459
|
-
const matchedString = matchResult[0];
|
|
2460
|
-
const parseResult = string.match(args.parsePattern);
|
|
2461
|
-
if (!parseResult) return null;
|
|
2462
|
-
let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
|
|
2463
|
-
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
2464
|
-
const rest = string.slice(matchedString.length);
|
|
2465
|
-
return { value, rest };
|
|
2466
|
-
};
|
|
2467
|
-
}
|
|
2468
|
-
const constructFromSymbol = Symbol.for("constructDateFrom");
|
|
2469
|
-
function constructFrom(date, value) {
|
|
2470
|
-
if (typeof date === "function") return date(value);
|
|
2471
|
-
if (date && typeof date === "object" && constructFromSymbol in date)
|
|
2472
|
-
return date[constructFromSymbol](value);
|
|
2473
|
-
if (date instanceof Date) return new date.constructor(value);
|
|
2474
|
-
return new Date(value);
|
|
2475
|
-
}
|
|
2476
|
-
function normalizeDates(context, ...dates) {
|
|
2477
|
-
const normalize = constructFrom.bind(
|
|
2478
|
-
null,
|
|
2479
|
-
context || dates.find((date) => typeof date === "object")
|
|
2480
|
-
);
|
|
2481
|
-
return dates.map(normalize);
|
|
2482
|
-
}
|
|
2483
|
-
let defaultOptions = {};
|
|
2484
|
-
function getDefaultOptions() {
|
|
2485
|
-
return defaultOptions;
|
|
2486
|
-
}
|
|
2487
|
-
function toDate(argument, context) {
|
|
2488
|
-
return constructFrom(context || argument, argument);
|
|
2489
|
-
}
|
|
2490
|
-
function startOfWeek(date, options) {
|
|
2491
|
-
const defaultOptions2 = getDefaultOptions();
|
|
2492
|
-
const weekStartsOn = options?.weekStartsOn ?? options?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
|
|
2493
|
-
const _date = toDate(date, options?.in);
|
|
2494
|
-
const day = _date.getDay();
|
|
2495
|
-
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
2496
|
-
_date.setDate(_date.getDate() - diff);
|
|
2497
|
-
_date.setHours(0, 0, 0, 0);
|
|
2498
|
-
return _date;
|
|
2499
|
-
}
|
|
2500
|
-
function isSameWeek(laterDate, earlierDate, options) {
|
|
2501
|
-
const [laterDate_, earlierDate_] = normalizeDates(
|
|
2502
|
-
options?.in,
|
|
2503
|
-
laterDate,
|
|
2504
|
-
earlierDate
|
|
2505
|
-
);
|
|
2506
|
-
return +startOfWeek(laterDate_, options) === +startOfWeek(earlierDate_, options);
|
|
2507
|
-
}
|
|
2508
|
-
const formatDistanceLocale$2 = {
|
|
2509
|
-
lessThanXSeconds: {
|
|
2510
|
-
one: "less than a second",
|
|
2511
|
-
other: "less than {{count}} seconds"
|
|
2512
|
-
},
|
|
2513
|
-
xSeconds: {
|
|
2514
|
-
one: "1 second",
|
|
2515
|
-
other: "{{count}} seconds"
|
|
2516
|
-
},
|
|
2517
|
-
halfAMinute: "half a minute",
|
|
2518
|
-
lessThanXMinutes: {
|
|
2519
|
-
one: "less than a minute",
|
|
2520
|
-
other: "less than {{count}} minutes"
|
|
2521
|
-
},
|
|
2522
|
-
xMinutes: {
|
|
2523
|
-
one: "1 minute",
|
|
2524
|
-
other: "{{count}} minutes"
|
|
2525
|
-
},
|
|
2526
|
-
aboutXHours: {
|
|
2527
|
-
one: "about 1 hour",
|
|
2528
|
-
other: "about {{count}} hours"
|
|
2529
|
-
},
|
|
2530
|
-
xHours: {
|
|
2531
|
-
one: "1 hour",
|
|
2532
|
-
other: "{{count}} hours"
|
|
2533
|
-
},
|
|
2534
|
-
xDays: {
|
|
2535
|
-
one: "1 day",
|
|
2536
|
-
other: "{{count}} days"
|
|
2537
|
-
},
|
|
2538
|
-
aboutXWeeks: {
|
|
2539
|
-
one: "about 1 week",
|
|
2540
|
-
other: "about {{count}} weeks"
|
|
2541
|
-
},
|
|
2542
|
-
xWeeks: {
|
|
2543
|
-
one: "1 week",
|
|
2544
|
-
other: "{{count}} weeks"
|
|
2545
|
-
},
|
|
2546
|
-
aboutXMonths: {
|
|
2547
|
-
one: "about 1 month",
|
|
2548
|
-
other: "about {{count}} months"
|
|
2549
|
-
},
|
|
2550
|
-
xMonths: {
|
|
2551
|
-
one: "1 month",
|
|
2552
|
-
other: "{{count}} months"
|
|
2553
|
-
},
|
|
2554
|
-
aboutXYears: {
|
|
2555
|
-
one: "about 1 year",
|
|
2556
|
-
other: "about {{count}} years"
|
|
2557
|
-
},
|
|
2558
|
-
xYears: {
|
|
2559
|
-
one: "1 year",
|
|
2560
|
-
other: "{{count}} years"
|
|
2561
|
-
},
|
|
2562
|
-
overXYears: {
|
|
2563
|
-
one: "over 1 year",
|
|
2564
|
-
other: "over {{count}} years"
|
|
2565
|
-
},
|
|
2566
|
-
almostXYears: {
|
|
2567
|
-
one: "almost 1 year",
|
|
2568
|
-
other: "almost {{count}} years"
|
|
2569
|
-
}
|
|
2570
|
-
};
|
|
2571
|
-
const formatDistance$2 = (token, count, options) => {
|
|
2572
|
-
let result;
|
|
2573
|
-
const tokenValue = formatDistanceLocale$2[token];
|
|
2574
|
-
if (typeof tokenValue === "string") {
|
|
2575
|
-
result = tokenValue;
|
|
2576
|
-
} else if (count === 1) {
|
|
2577
|
-
result = tokenValue.one;
|
|
2578
|
-
} else {
|
|
2579
|
-
result = tokenValue.other.replace("{{count}}", count.toString());
|
|
2580
|
-
}
|
|
2581
|
-
if (options?.addSuffix) {
|
|
2582
|
-
if (options.comparison && options.comparison > 0) {
|
|
2583
|
-
return "in " + result;
|
|
2584
|
-
} else {
|
|
2585
|
-
return result + " ago";
|
|
2586
|
-
}
|
|
2587
|
-
}
|
|
2588
|
-
return result;
|
|
2589
|
-
};
|
|
2590
|
-
const formatRelativeLocale$2 = {
|
|
2591
|
-
lastWeek: "'last' eeee 'at' p",
|
|
2592
|
-
yesterday: "'yesterday at' p",
|
|
2593
|
-
today: "'today at' p",
|
|
2594
|
-
tomorrow: "'tomorrow at' p",
|
|
2595
|
-
nextWeek: "eeee 'at' p",
|
|
2596
|
-
other: "P"
|
|
2597
|
-
};
|
|
2598
|
-
const formatRelative$2 = (token, _date, _baseDate, _options) => formatRelativeLocale$2[token];
|
|
2599
|
-
const eraValues$2 = {
|
|
2600
|
-
narrow: ["B", "A"],
|
|
2601
|
-
abbreviated: ["BC", "AD"],
|
|
2602
|
-
wide: ["Before Christ", "Anno Domini"]
|
|
2603
|
-
};
|
|
2604
|
-
const quarterValues$2 = {
|
|
2605
|
-
narrow: ["1", "2", "3", "4"],
|
|
2606
|
-
abbreviated: ["Q1", "Q2", "Q3", "Q4"],
|
|
2607
|
-
wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
|
|
2608
|
-
};
|
|
2609
|
-
const monthValues$2 = {
|
|
2610
|
-
narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
|
|
2611
|
-
abbreviated: [
|
|
2612
|
-
"Jan",
|
|
2613
|
-
"Feb",
|
|
2614
|
-
"Mar",
|
|
2615
|
-
"Apr",
|
|
2616
|
-
"May",
|
|
2617
|
-
"Jun",
|
|
2618
|
-
"Jul",
|
|
2619
|
-
"Aug",
|
|
2620
|
-
"Sep",
|
|
2621
|
-
"Oct",
|
|
2622
|
-
"Nov",
|
|
2623
|
-
"Dec"
|
|
2624
|
-
],
|
|
2625
|
-
wide: [
|
|
2626
|
-
"January",
|
|
2627
|
-
"February",
|
|
2628
|
-
"March",
|
|
2629
|
-
"April",
|
|
2630
|
-
"May",
|
|
2631
|
-
"June",
|
|
2632
|
-
"July",
|
|
2633
|
-
"August",
|
|
2634
|
-
"September",
|
|
2635
|
-
"October",
|
|
2636
|
-
"November",
|
|
2637
|
-
"December"
|
|
2638
|
-
]
|
|
2639
|
-
};
|
|
2640
|
-
const dayValues$2 = {
|
|
2641
|
-
narrow: ["S", "M", "T", "W", "T", "F", "S"],
|
|
2642
|
-
short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
|
|
2643
|
-
abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
|
2644
|
-
wide: [
|
|
2645
|
-
"Sunday",
|
|
2646
|
-
"Monday",
|
|
2647
|
-
"Tuesday",
|
|
2648
|
-
"Wednesday",
|
|
2649
|
-
"Thursday",
|
|
2650
|
-
"Friday",
|
|
2651
|
-
"Saturday"
|
|
2652
|
-
]
|
|
2653
|
-
};
|
|
2654
|
-
const dayPeriodValues$2 = {
|
|
2655
|
-
narrow: {
|
|
2656
|
-
am: "a",
|
|
2657
|
-
pm: "p",
|
|
2658
|
-
midnight: "mi",
|
|
2659
|
-
noon: "n",
|
|
2660
|
-
morning: "morning",
|
|
2661
|
-
afternoon: "afternoon",
|
|
2662
|
-
evening: "evening",
|
|
2663
|
-
night: "night"
|
|
2664
|
-
},
|
|
2665
|
-
abbreviated: {
|
|
2666
|
-
am: "AM",
|
|
2667
|
-
pm: "PM",
|
|
2668
|
-
midnight: "midnight",
|
|
2669
|
-
noon: "noon",
|
|
2670
|
-
morning: "morning",
|
|
2671
|
-
afternoon: "afternoon",
|
|
2672
|
-
evening: "evening",
|
|
2673
|
-
night: "night"
|
|
2674
|
-
},
|
|
2675
|
-
wide: {
|
|
2676
|
-
am: "a.m.",
|
|
2677
|
-
pm: "p.m.",
|
|
2678
|
-
midnight: "midnight",
|
|
2679
|
-
noon: "noon",
|
|
2680
|
-
morning: "morning",
|
|
2681
|
-
afternoon: "afternoon",
|
|
2682
|
-
evening: "evening",
|
|
2683
|
-
night: "night"
|
|
2684
|
-
}
|
|
2685
|
-
};
|
|
2686
|
-
const formattingDayPeriodValues$2 = {
|
|
2687
|
-
narrow: {
|
|
2688
|
-
am: "a",
|
|
2689
|
-
pm: "p",
|
|
2690
|
-
midnight: "mi",
|
|
2691
|
-
noon: "n",
|
|
2692
|
-
morning: "in the morning",
|
|
2693
|
-
afternoon: "in the afternoon",
|
|
2694
|
-
evening: "in the evening",
|
|
2695
|
-
night: "at night"
|
|
2696
|
-
},
|
|
2697
|
-
abbreviated: {
|
|
2698
|
-
am: "AM",
|
|
2699
|
-
pm: "PM",
|
|
2700
|
-
midnight: "midnight",
|
|
2701
|
-
noon: "noon",
|
|
2702
|
-
morning: "in the morning",
|
|
2703
|
-
afternoon: "in the afternoon",
|
|
2704
|
-
evening: "in the evening",
|
|
2705
|
-
night: "at night"
|
|
2706
|
-
},
|
|
2707
|
-
wide: {
|
|
2708
|
-
am: "a.m.",
|
|
2709
|
-
pm: "p.m.",
|
|
2710
|
-
midnight: "midnight",
|
|
2711
|
-
noon: "noon",
|
|
2712
|
-
morning: "in the morning",
|
|
2713
|
-
afternoon: "in the afternoon",
|
|
2714
|
-
evening: "in the evening",
|
|
2715
|
-
night: "at night"
|
|
2716
|
-
}
|
|
2717
|
-
};
|
|
2718
|
-
const ordinalNumber$2 = (dirtyNumber, _options) => {
|
|
2719
|
-
const number = Number(dirtyNumber);
|
|
2720
|
-
const rem100 = number % 100;
|
|
2721
|
-
if (rem100 > 20 || rem100 < 10) {
|
|
2722
|
-
switch (rem100 % 10) {
|
|
2723
|
-
case 1:
|
|
2724
|
-
return number + "st";
|
|
2725
|
-
case 2:
|
|
2726
|
-
return number + "nd";
|
|
2727
|
-
case 3:
|
|
2728
|
-
return number + "rd";
|
|
2729
|
-
}
|
|
2730
|
-
}
|
|
2731
|
-
return number + "th";
|
|
2732
|
-
};
|
|
2733
|
-
const localize$2 = {
|
|
2734
|
-
ordinalNumber: ordinalNumber$2,
|
|
2735
|
-
era: buildLocalizeFn({
|
|
2736
|
-
values: eraValues$2,
|
|
2737
|
-
defaultWidth: "wide"
|
|
2738
|
-
}),
|
|
2739
|
-
quarter: buildLocalizeFn({
|
|
2740
|
-
values: quarterValues$2,
|
|
2741
|
-
defaultWidth: "wide",
|
|
2742
|
-
argumentCallback: (quarter) => quarter - 1
|
|
2743
|
-
}),
|
|
2744
|
-
month: buildLocalizeFn({
|
|
2745
|
-
values: monthValues$2,
|
|
2746
|
-
defaultWidth: "wide"
|
|
2747
|
-
}),
|
|
2748
|
-
day: buildLocalizeFn({
|
|
2749
|
-
values: dayValues$2,
|
|
2750
|
-
defaultWidth: "wide"
|
|
2751
|
-
}),
|
|
2752
|
-
dayPeriod: buildLocalizeFn({
|
|
2753
|
-
values: dayPeriodValues$2,
|
|
2754
|
-
defaultWidth: "wide",
|
|
2755
|
-
formattingValues: formattingDayPeriodValues$2,
|
|
2756
|
-
defaultFormattingWidth: "wide"
|
|
2757
|
-
})
|
|
2758
|
-
};
|
|
2759
|
-
const matchOrdinalNumberPattern$2 = /^(\d+)(th|st|nd|rd)?/i;
|
|
2760
|
-
const parseOrdinalNumberPattern$2 = /\d+/i;
|
|
2761
|
-
const matchEraPatterns$2 = {
|
|
2762
|
-
narrow: /^(b|a)/i,
|
|
2763
|
-
abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
|
|
2764
|
-
wide: /^(before christ|before common era|anno domini|common era)/i
|
|
2765
|
-
};
|
|
2766
|
-
const parseEraPatterns$2 = {
|
|
2767
|
-
any: [/^b/i, /^(a|c)/i]
|
|
2768
|
-
};
|
|
2769
|
-
const matchQuarterPatterns$2 = {
|
|
2770
|
-
narrow: /^[1234]/i,
|
|
2771
|
-
abbreviated: /^q[1234]/i,
|
|
2772
|
-
wide: /^[1234](th|st|nd|rd)? quarter/i
|
|
2773
|
-
};
|
|
2774
|
-
const parseQuarterPatterns$2 = {
|
|
2775
|
-
any: [/1/i, /2/i, /3/i, /4/i]
|
|
2776
|
-
};
|
|
2777
|
-
const matchMonthPatterns$2 = {
|
|
2778
|
-
narrow: /^[jfmasond]/i,
|
|
2779
|
-
abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
|
|
2780
|
-
wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
|
|
2781
|
-
};
|
|
2782
|
-
const parseMonthPatterns$2 = {
|
|
2783
|
-
narrow: [
|
|
2784
|
-
/^j/i,
|
|
2785
|
-
/^f/i,
|
|
2786
|
-
/^m/i,
|
|
2787
|
-
/^a/i,
|
|
2788
|
-
/^m/i,
|
|
2789
|
-
/^j/i,
|
|
2790
|
-
/^j/i,
|
|
2791
|
-
/^a/i,
|
|
2792
|
-
/^s/i,
|
|
2793
|
-
/^o/i,
|
|
2794
|
-
/^n/i,
|
|
2795
|
-
/^d/i
|
|
2796
|
-
],
|
|
2797
|
-
any: [
|
|
2798
|
-
/^ja/i,
|
|
2799
|
-
/^f/i,
|
|
2800
|
-
/^mar/i,
|
|
2801
|
-
/^ap/i,
|
|
2802
|
-
/^may/i,
|
|
2803
|
-
/^jun/i,
|
|
2804
|
-
/^jul/i,
|
|
2805
|
-
/^au/i,
|
|
2806
|
-
/^s/i,
|
|
2807
|
-
/^o/i,
|
|
2808
|
-
/^n/i,
|
|
2809
|
-
/^d/i
|
|
2810
|
-
]
|
|
2811
|
-
};
|
|
2812
|
-
const matchDayPatterns$2 = {
|
|
2813
|
-
narrow: /^[smtwf]/i,
|
|
2814
|
-
short: /^(su|mo|tu|we|th|fr|sa)/i,
|
|
2815
|
-
abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
|
|
2816
|
-
wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
|
|
2817
|
-
};
|
|
2818
|
-
const parseDayPatterns$2 = {
|
|
2819
|
-
narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
|
|
2820
|
-
any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
|
|
2821
|
-
};
|
|
2822
|
-
const matchDayPeriodPatterns$2 = {
|
|
2823
|
-
narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
|
|
2824
|
-
any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
|
|
2825
|
-
};
|
|
2826
|
-
const parseDayPeriodPatterns$2 = {
|
|
2827
|
-
any: {
|
|
2828
|
-
am: /^a/i,
|
|
2829
|
-
pm: /^p/i,
|
|
2830
|
-
midnight: /^mi/i,
|
|
2831
|
-
noon: /^no/i,
|
|
2832
|
-
morning: /morning/i,
|
|
2833
|
-
afternoon: /afternoon/i,
|
|
2834
|
-
evening: /evening/i,
|
|
2835
|
-
night: /night/i
|
|
2836
|
-
}
|
|
2837
|
-
};
|
|
2838
|
-
const match$2 = {
|
|
2839
|
-
ordinalNumber: buildMatchPatternFn({
|
|
2840
|
-
matchPattern: matchOrdinalNumberPattern$2,
|
|
2841
|
-
parsePattern: parseOrdinalNumberPattern$2,
|
|
2842
|
-
valueCallback: (value) => parseInt(value, 10)
|
|
2843
|
-
}),
|
|
2844
|
-
era: buildMatchFn({
|
|
2845
|
-
matchPatterns: matchEraPatterns$2,
|
|
2846
|
-
defaultMatchWidth: "wide",
|
|
2847
|
-
parsePatterns: parseEraPatterns$2,
|
|
2848
|
-
defaultParseWidth: "any"
|
|
2849
|
-
}),
|
|
2850
|
-
quarter: buildMatchFn({
|
|
2851
|
-
matchPatterns: matchQuarterPatterns$2,
|
|
2852
|
-
defaultMatchWidth: "wide",
|
|
2853
|
-
parsePatterns: parseQuarterPatterns$2,
|
|
2854
|
-
defaultParseWidth: "any",
|
|
2855
|
-
valueCallback: (index) => index + 1
|
|
2856
|
-
}),
|
|
2857
|
-
month: buildMatchFn({
|
|
2858
|
-
matchPatterns: matchMonthPatterns$2,
|
|
2859
|
-
defaultMatchWidth: "wide",
|
|
2860
|
-
parsePatterns: parseMonthPatterns$2,
|
|
2861
|
-
defaultParseWidth: "any"
|
|
2862
|
-
}),
|
|
2863
|
-
day: buildMatchFn({
|
|
2864
|
-
matchPatterns: matchDayPatterns$2,
|
|
2865
|
-
defaultMatchWidth: "wide",
|
|
2866
|
-
parsePatterns: parseDayPatterns$2,
|
|
2867
|
-
defaultParseWidth: "any"
|
|
2868
|
-
}),
|
|
2869
|
-
dayPeriod: buildMatchFn({
|
|
2870
|
-
matchPatterns: matchDayPeriodPatterns$2,
|
|
2871
|
-
defaultMatchWidth: "any",
|
|
2872
|
-
parsePatterns: parseDayPeriodPatterns$2,
|
|
2873
|
-
defaultParseWidth: "any"
|
|
2874
|
-
})
|
|
2875
|
-
};
|
|
2876
|
-
const dateFormats$2 = {
|
|
2877
|
-
full: "EEEE, d MMMM yyyy",
|
|
2878
|
-
long: "d MMMM yyyy",
|
|
2879
|
-
medium: "d MMM yyyy",
|
|
2880
|
-
short: "dd/MM/yyyy"
|
|
2881
|
-
};
|
|
2882
|
-
const timeFormats$2 = {
|
|
2883
|
-
full: "HH:mm:ss zzzz",
|
|
2884
|
-
long: "HH:mm:ss z",
|
|
2885
|
-
medium: "HH:mm:ss",
|
|
2886
|
-
short: "HH:mm"
|
|
2887
|
-
};
|
|
2888
|
-
const dateTimeFormats$2 = {
|
|
2889
|
-
full: "{{date}} 'at' {{time}}",
|
|
2890
|
-
long: "{{date}} 'at' {{time}}",
|
|
2891
|
-
medium: "{{date}}, {{time}}",
|
|
2892
|
-
short: "{{date}}, {{time}}"
|
|
2893
|
-
};
|
|
2894
|
-
const formatLong$2 = {
|
|
2895
|
-
date: buildFormatLongFn({
|
|
2896
|
-
formats: dateFormats$2,
|
|
2897
|
-
defaultWidth: "full"
|
|
2898
|
-
}),
|
|
2899
|
-
time: buildFormatLongFn({
|
|
2900
|
-
formats: timeFormats$2,
|
|
2901
|
-
defaultWidth: "full"
|
|
2902
|
-
}),
|
|
2903
|
-
dateTime: buildFormatLongFn({
|
|
2904
|
-
formats: dateTimeFormats$2,
|
|
2905
|
-
defaultWidth: "full"
|
|
2906
|
-
})
|
|
2907
|
-
};
|
|
2908
|
-
const enGB = {
|
|
2909
|
-
code: "en-GB",
|
|
2910
|
-
formatDistance: formatDistance$2,
|
|
2911
|
-
formatLong: formatLong$2,
|
|
2912
|
-
formatRelative: formatRelative$2,
|
|
2913
|
-
localize: localize$2,
|
|
2914
|
-
match: match$2,
|
|
2915
|
-
options: {
|
|
2916
|
-
weekStartsOn: 1,
|
|
2917
|
-
firstWeekContainsDate: 4
|
|
2918
|
-
}
|
|
2919
|
-
};
|
|
2920
|
-
const formatDistanceLocale$1 = {
|
|
2921
|
-
lessThanXSeconds: {
|
|
2922
|
-
one: "menos de un segundo",
|
|
2923
|
-
other: "menos de {{count}} segundos"
|
|
2924
|
-
},
|
|
2925
|
-
xSeconds: {
|
|
2926
|
-
one: "1 segundo",
|
|
2927
|
-
other: "{{count}} segundos"
|
|
2928
|
-
},
|
|
2929
|
-
halfAMinute: "medio minuto",
|
|
2930
|
-
lessThanXMinutes: {
|
|
2931
|
-
one: "menos de un minuto",
|
|
2932
|
-
other: "menos de {{count}} minutos"
|
|
2933
|
-
},
|
|
2934
|
-
xMinutes: {
|
|
2935
|
-
one: "1 minuto",
|
|
2936
|
-
other: "{{count}} minutos"
|
|
2937
|
-
},
|
|
2938
|
-
aboutXHours: {
|
|
2939
|
-
one: "alrededor de 1 hora",
|
|
2940
|
-
other: "alrededor de {{count}} horas"
|
|
2941
|
-
},
|
|
2942
|
-
xHours: {
|
|
2943
|
-
one: "1 hora",
|
|
2944
|
-
other: "{{count}} horas"
|
|
2945
|
-
},
|
|
2946
|
-
xDays: {
|
|
2947
|
-
one: "1 día",
|
|
2948
|
-
other: "{{count}} días"
|
|
2949
|
-
},
|
|
2950
|
-
aboutXWeeks: {
|
|
2951
|
-
one: "alrededor de 1 semana",
|
|
2952
|
-
other: "alrededor de {{count}} semanas"
|
|
2953
|
-
},
|
|
2954
|
-
xWeeks: {
|
|
2955
|
-
one: "1 semana",
|
|
2956
|
-
other: "{{count}} semanas"
|
|
2957
|
-
},
|
|
2958
|
-
aboutXMonths: {
|
|
2959
|
-
one: "alrededor de 1 mes",
|
|
2960
|
-
other: "alrededor de {{count}} meses"
|
|
2961
|
-
},
|
|
2962
|
-
xMonths: {
|
|
2963
|
-
one: "1 mes",
|
|
2964
|
-
other: "{{count}} meses"
|
|
2965
|
-
},
|
|
2966
|
-
aboutXYears: {
|
|
2967
|
-
one: "alrededor de 1 año",
|
|
2968
|
-
other: "alrededor de {{count}} años"
|
|
2969
|
-
},
|
|
2970
|
-
xYears: {
|
|
2971
|
-
one: "1 año",
|
|
2972
|
-
other: "{{count}} años"
|
|
2973
|
-
},
|
|
2974
|
-
overXYears: {
|
|
2975
|
-
one: "más de 1 año",
|
|
2976
|
-
other: "más de {{count}} años"
|
|
2977
|
-
},
|
|
2978
|
-
almostXYears: {
|
|
2979
|
-
one: "casi 1 año",
|
|
2980
|
-
other: "casi {{count}} años"
|
|
2981
|
-
}
|
|
2982
|
-
};
|
|
2983
|
-
const formatDistance$1 = (token, count, options) => {
|
|
2984
|
-
let result;
|
|
2985
|
-
const tokenValue = formatDistanceLocale$1[token];
|
|
2986
|
-
if (typeof tokenValue === "string") {
|
|
2987
|
-
result = tokenValue;
|
|
2988
|
-
} else if (count === 1) {
|
|
2989
|
-
result = tokenValue.one;
|
|
2990
|
-
} else {
|
|
2991
|
-
result = tokenValue.other.replace("{{count}}", count.toString());
|
|
2992
|
-
}
|
|
2993
|
-
if (options?.addSuffix) {
|
|
2994
|
-
if (options.comparison && options.comparison > 0) {
|
|
2995
|
-
return "en " + result;
|
|
2996
|
-
} else {
|
|
2997
|
-
return "hace " + result;
|
|
2998
|
-
}
|
|
2999
|
-
}
|
|
3000
|
-
return result;
|
|
3001
|
-
};
|
|
3002
|
-
const dateFormats$1 = {
|
|
3003
|
-
full: "EEEE, d 'de' MMMM 'de' y",
|
|
3004
|
-
long: "d 'de' MMMM 'de' y",
|
|
3005
|
-
medium: "d MMM y",
|
|
3006
|
-
short: "dd/MM/y"
|
|
3007
|
-
};
|
|
3008
|
-
const timeFormats$1 = {
|
|
3009
|
-
full: "HH:mm:ss zzzz",
|
|
3010
|
-
long: "HH:mm:ss z",
|
|
3011
|
-
medium: "HH:mm:ss",
|
|
3012
|
-
short: "HH:mm"
|
|
3013
|
-
};
|
|
3014
|
-
const dateTimeFormats$1 = {
|
|
3015
|
-
full: "{{date}} 'a las' {{time}}",
|
|
3016
|
-
long: "{{date}} 'a las' {{time}}",
|
|
3017
|
-
medium: "{{date}}, {{time}}",
|
|
3018
|
-
short: "{{date}}, {{time}}"
|
|
3019
|
-
};
|
|
3020
|
-
const formatLong$1 = {
|
|
3021
|
-
date: buildFormatLongFn({
|
|
3022
|
-
formats: dateFormats$1,
|
|
3023
|
-
defaultWidth: "full"
|
|
3024
|
-
}),
|
|
3025
|
-
time: buildFormatLongFn({
|
|
3026
|
-
formats: timeFormats$1,
|
|
3027
|
-
defaultWidth: "full"
|
|
3028
|
-
}),
|
|
3029
|
-
dateTime: buildFormatLongFn({
|
|
3030
|
-
formats: dateTimeFormats$1,
|
|
3031
|
-
defaultWidth: "full"
|
|
3032
|
-
})
|
|
3033
|
-
};
|
|
3034
|
-
const formatRelativeLocale$1 = {
|
|
3035
|
-
lastWeek: "'el' eeee 'pasado a la' p",
|
|
3036
|
-
yesterday: "'ayer a la' p",
|
|
3037
|
-
today: "'hoy a la' p",
|
|
3038
|
-
tomorrow: "'mañana a la' p",
|
|
3039
|
-
nextWeek: "eeee 'a la' p",
|
|
3040
|
-
other: "P"
|
|
3041
|
-
};
|
|
3042
|
-
const formatRelativeLocalePlural = {
|
|
3043
|
-
lastWeek: "'el' eeee 'pasado a las' p",
|
|
3044
|
-
yesterday: "'ayer a las' p",
|
|
3045
|
-
today: "'hoy a las' p",
|
|
3046
|
-
tomorrow: "'mañana a las' p",
|
|
3047
|
-
nextWeek: "eeee 'a las' p",
|
|
3048
|
-
other: "P"
|
|
3049
|
-
};
|
|
3050
|
-
const formatRelative$1 = (token, date, _baseDate, _options) => {
|
|
3051
|
-
if (date.getHours() !== 1) {
|
|
3052
|
-
return formatRelativeLocalePlural[token];
|
|
3053
|
-
} else {
|
|
3054
|
-
return formatRelativeLocale$1[token];
|
|
3055
|
-
}
|
|
3056
|
-
};
|
|
3057
|
-
const eraValues$1 = {
|
|
3058
|
-
narrow: ["AC", "DC"],
|
|
3059
|
-
abbreviated: ["AC", "DC"],
|
|
3060
|
-
wide: ["antes de cristo", "después de cristo"]
|
|
3061
|
-
};
|
|
3062
|
-
const quarterValues$1 = {
|
|
3063
|
-
narrow: ["1", "2", "3", "4"],
|
|
3064
|
-
abbreviated: ["T1", "T2", "T3", "T4"],
|
|
3065
|
-
wide: ["1º trimestre", "2º trimestre", "3º trimestre", "4º trimestre"]
|
|
3066
|
-
};
|
|
3067
|
-
const monthValues$1 = {
|
|
3068
|
-
narrow: ["e", "f", "m", "a", "m", "j", "j", "a", "s", "o", "n", "d"],
|
|
3069
|
-
abbreviated: [
|
|
3070
|
-
"ene",
|
|
3071
|
-
"feb",
|
|
3072
|
-
"mar",
|
|
3073
|
-
"abr",
|
|
3074
|
-
"may",
|
|
3075
|
-
"jun",
|
|
3076
|
-
"jul",
|
|
3077
|
-
"ago",
|
|
3078
|
-
"sep",
|
|
3079
|
-
"oct",
|
|
3080
|
-
"nov",
|
|
3081
|
-
"dic"
|
|
3082
|
-
],
|
|
3083
|
-
wide: [
|
|
3084
|
-
"enero",
|
|
3085
|
-
"febrero",
|
|
3086
|
-
"marzo",
|
|
3087
|
-
"abril",
|
|
3088
|
-
"mayo",
|
|
3089
|
-
"junio",
|
|
3090
|
-
"julio",
|
|
3091
|
-
"agosto",
|
|
3092
|
-
"septiembre",
|
|
3093
|
-
"octubre",
|
|
3094
|
-
"noviembre",
|
|
3095
|
-
"diciembre"
|
|
3096
|
-
]
|
|
3097
|
-
};
|
|
3098
|
-
const dayValues$1 = {
|
|
3099
|
-
narrow: ["d", "l", "m", "m", "j", "v", "s"],
|
|
3100
|
-
short: ["do", "lu", "ma", "mi", "ju", "vi", "sá"],
|
|
3101
|
-
abbreviated: ["dom", "lun", "mar", "mié", "jue", "vie", "sáb"],
|
|
3102
|
-
wide: [
|
|
3103
|
-
"domingo",
|
|
3104
|
-
"lunes",
|
|
3105
|
-
"martes",
|
|
3106
|
-
"miércoles",
|
|
3107
|
-
"jueves",
|
|
3108
|
-
"viernes",
|
|
3109
|
-
"sábado"
|
|
3110
|
-
]
|
|
3111
|
-
};
|
|
3112
|
-
const dayPeriodValues$1 = {
|
|
3113
|
-
narrow: {
|
|
3114
|
-
am: "a",
|
|
3115
|
-
pm: "p",
|
|
3116
|
-
midnight: "mn",
|
|
3117
|
-
noon: "md",
|
|
3118
|
-
morning: "mañana",
|
|
3119
|
-
afternoon: "tarde",
|
|
3120
|
-
evening: "tarde",
|
|
3121
|
-
night: "noche"
|
|
3122
|
-
},
|
|
3123
|
-
abbreviated: {
|
|
3124
|
-
am: "AM",
|
|
3125
|
-
pm: "PM",
|
|
3126
|
-
midnight: "medianoche",
|
|
3127
|
-
noon: "mediodia",
|
|
3128
|
-
morning: "mañana",
|
|
3129
|
-
afternoon: "tarde",
|
|
3130
|
-
evening: "tarde",
|
|
3131
|
-
night: "noche"
|
|
3132
|
-
},
|
|
3133
|
-
wide: {
|
|
3134
|
-
am: "a.m.",
|
|
3135
|
-
pm: "p.m.",
|
|
3136
|
-
midnight: "medianoche",
|
|
3137
|
-
noon: "mediodia",
|
|
3138
|
-
morning: "mañana",
|
|
3139
|
-
afternoon: "tarde",
|
|
3140
|
-
evening: "tarde",
|
|
3141
|
-
night: "noche"
|
|
3142
|
-
}
|
|
3143
|
-
};
|
|
3144
|
-
const formattingDayPeriodValues$1 = {
|
|
3145
|
-
narrow: {
|
|
3146
|
-
am: "a",
|
|
3147
|
-
pm: "p",
|
|
3148
|
-
midnight: "mn",
|
|
3149
|
-
noon: "md",
|
|
3150
|
-
morning: "de la mañana",
|
|
3151
|
-
afternoon: "de la tarde",
|
|
3152
|
-
evening: "de la tarde",
|
|
3153
|
-
night: "de la noche"
|
|
3154
|
-
},
|
|
3155
|
-
abbreviated: {
|
|
3156
|
-
am: "AM",
|
|
3157
|
-
pm: "PM",
|
|
3158
|
-
midnight: "medianoche",
|
|
3159
|
-
noon: "mediodia",
|
|
3160
|
-
morning: "de la mañana",
|
|
3161
|
-
afternoon: "de la tarde",
|
|
3162
|
-
evening: "de la tarde",
|
|
3163
|
-
night: "de la noche"
|
|
3164
|
-
},
|
|
3165
|
-
wide: {
|
|
3166
|
-
am: "a.m.",
|
|
3167
|
-
pm: "p.m.",
|
|
3168
|
-
midnight: "medianoche",
|
|
3169
|
-
noon: "mediodia",
|
|
3170
|
-
morning: "de la mañana",
|
|
3171
|
-
afternoon: "de la tarde",
|
|
3172
|
-
evening: "de la tarde",
|
|
3173
|
-
night: "de la noche"
|
|
3174
|
-
}
|
|
3175
|
-
};
|
|
3176
|
-
const ordinalNumber$1 = (dirtyNumber, _options) => {
|
|
3177
|
-
const number = Number(dirtyNumber);
|
|
3178
|
-
return number + "º";
|
|
3179
|
-
};
|
|
3180
|
-
const localize$1 = {
|
|
3181
|
-
ordinalNumber: ordinalNumber$1,
|
|
3182
|
-
era: buildLocalizeFn({
|
|
3183
|
-
values: eraValues$1,
|
|
3184
|
-
defaultWidth: "wide"
|
|
3185
|
-
}),
|
|
3186
|
-
quarter: buildLocalizeFn({
|
|
3187
|
-
values: quarterValues$1,
|
|
3188
|
-
defaultWidth: "wide",
|
|
3189
|
-
argumentCallback: (quarter) => Number(quarter) - 1
|
|
3190
|
-
}),
|
|
3191
|
-
month: buildLocalizeFn({
|
|
3192
|
-
values: monthValues$1,
|
|
3193
|
-
defaultWidth: "wide"
|
|
3194
|
-
}),
|
|
3195
|
-
day: buildLocalizeFn({
|
|
3196
|
-
values: dayValues$1,
|
|
3197
|
-
defaultWidth: "wide"
|
|
3198
|
-
}),
|
|
3199
|
-
dayPeriod: buildLocalizeFn({
|
|
3200
|
-
values: dayPeriodValues$1,
|
|
3201
|
-
defaultWidth: "wide",
|
|
3202
|
-
formattingValues: formattingDayPeriodValues$1,
|
|
3203
|
-
defaultFormattingWidth: "wide"
|
|
3204
|
-
})
|
|
3205
|
-
};
|
|
3206
|
-
const matchOrdinalNumberPattern$1 = /^(\d+)(º)?/i;
|
|
3207
|
-
const parseOrdinalNumberPattern$1 = /\d+/i;
|
|
3208
|
-
const matchEraPatterns$1 = {
|
|
3209
|
-
narrow: /^(ac|dc|a|d)/i,
|
|
3210
|
-
abbreviated: /^(a\.?\s?c\.?|a\.?\s?e\.?\s?c\.?|d\.?\s?c\.?|e\.?\s?c\.?)/i,
|
|
3211
|
-
wide: /^(antes de cristo|antes de la era com[uú]n|despu[eé]s de cristo|era com[uú]n)/i
|
|
3212
|
-
};
|
|
3213
|
-
const parseEraPatterns$1 = {
|
|
3214
|
-
any: [/^ac/i, /^dc/i],
|
|
3215
|
-
wide: [
|
|
3216
|
-
/^(antes de cristo|antes de la era com[uú]n)/i,
|
|
3217
|
-
/^(despu[eé]s de cristo|era com[uú]n)/i
|
|
3218
|
-
]
|
|
3219
|
-
};
|
|
3220
|
-
const matchQuarterPatterns$1 = {
|
|
3221
|
-
narrow: /^[1234]/i,
|
|
3222
|
-
abbreviated: /^T[1234]/i,
|
|
3223
|
-
wide: /^[1234](º)? trimestre/i
|
|
3224
|
-
};
|
|
3225
|
-
const parseQuarterPatterns$1 = {
|
|
3226
|
-
any: [/1/i, /2/i, /3/i, /4/i]
|
|
3227
|
-
};
|
|
3228
|
-
const matchMonthPatterns$1 = {
|
|
3229
|
-
narrow: /^[efmajsond]/i,
|
|
3230
|
-
abbreviated: /^(ene|feb|mar|abr|may|jun|jul|ago|sep|oct|nov|dic)/i,
|
|
3231
|
-
wide: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i
|
|
3232
|
-
};
|
|
3233
|
-
const parseMonthPatterns$1 = {
|
|
3234
|
-
narrow: [
|
|
3235
|
-
/^e/i,
|
|
3236
|
-
/^f/i,
|
|
3237
|
-
/^m/i,
|
|
3238
|
-
/^a/i,
|
|
3239
|
-
/^m/i,
|
|
3240
|
-
/^j/i,
|
|
3241
|
-
/^j/i,
|
|
3242
|
-
/^a/i,
|
|
3243
|
-
/^s/i,
|
|
3244
|
-
/^o/i,
|
|
3245
|
-
/^n/i,
|
|
3246
|
-
/^d/i
|
|
3247
|
-
],
|
|
3248
|
-
any: [
|
|
3249
|
-
/^en/i,
|
|
3250
|
-
/^feb/i,
|
|
3251
|
-
/^mar/i,
|
|
3252
|
-
/^abr/i,
|
|
3253
|
-
/^may/i,
|
|
3254
|
-
/^jun/i,
|
|
3255
|
-
/^jul/i,
|
|
3256
|
-
/^ago/i,
|
|
3257
|
-
/^sep/i,
|
|
3258
|
-
/^oct/i,
|
|
3259
|
-
/^nov/i,
|
|
3260
|
-
/^dic/i
|
|
3261
|
-
]
|
|
3262
|
-
};
|
|
3263
|
-
const matchDayPatterns$1 = {
|
|
3264
|
-
narrow: /^[dlmjvs]/i,
|
|
3265
|
-
short: /^(do|lu|ma|mi|ju|vi|s[áa])/i,
|
|
3266
|
-
abbreviated: /^(dom|lun|mar|mi[ée]|jue|vie|s[áa]b)/i,
|
|
3267
|
-
wide: /^(domingo|lunes|martes|mi[ée]rcoles|jueves|viernes|s[áa]bado)/i
|
|
3268
|
-
};
|
|
3269
|
-
const parseDayPatterns$1 = {
|
|
3270
|
-
narrow: [/^d/i, /^l/i, /^m/i, /^m/i, /^j/i, /^v/i, /^s/i],
|
|
3271
|
-
any: [/^do/i, /^lu/i, /^ma/i, /^mi/i, /^ju/i, /^vi/i, /^sa/i]
|
|
3272
|
-
};
|
|
3273
|
-
const matchDayPeriodPatterns$1 = {
|
|
3274
|
-
narrow: /^(a|p|mn|md|(de la|a las) (mañana|tarde|noche))/i,
|
|
3275
|
-
any: /^([ap]\.?\s?m\.?|medianoche|mediodia|(de la|a las) (mañana|tarde|noche))/i
|
|
3276
|
-
};
|
|
3277
|
-
const parseDayPeriodPatterns$1 = {
|
|
3278
|
-
any: {
|
|
3279
|
-
am: /^a/i,
|
|
3280
|
-
pm: /^p/i,
|
|
3281
|
-
midnight: /^mn/i,
|
|
3282
|
-
noon: /^md/i,
|
|
3283
|
-
morning: /mañana/i,
|
|
3284
|
-
afternoon: /tarde/i,
|
|
3285
|
-
evening: /tarde/i,
|
|
3286
|
-
night: /noche/i
|
|
3287
|
-
}
|
|
3288
|
-
};
|
|
3289
|
-
const match$1 = {
|
|
3290
|
-
ordinalNumber: buildMatchPatternFn({
|
|
3291
|
-
matchPattern: matchOrdinalNumberPattern$1,
|
|
3292
|
-
parsePattern: parseOrdinalNumberPattern$1,
|
|
3293
|
-
valueCallback: function(value) {
|
|
3294
|
-
return parseInt(value, 10);
|
|
3295
|
-
}
|
|
3296
|
-
}),
|
|
3297
|
-
era: buildMatchFn({
|
|
3298
|
-
matchPatterns: matchEraPatterns$1,
|
|
3299
|
-
defaultMatchWidth: "wide",
|
|
3300
|
-
parsePatterns: parseEraPatterns$1,
|
|
3301
|
-
defaultParseWidth: "any"
|
|
3302
|
-
}),
|
|
3303
|
-
quarter: buildMatchFn({
|
|
3304
|
-
matchPatterns: matchQuarterPatterns$1,
|
|
3305
|
-
defaultMatchWidth: "wide",
|
|
3306
|
-
parsePatterns: parseQuarterPatterns$1,
|
|
3307
|
-
defaultParseWidth: "any",
|
|
3308
|
-
valueCallback: (index) => index + 1
|
|
3309
|
-
}),
|
|
3310
|
-
month: buildMatchFn({
|
|
3311
|
-
matchPatterns: matchMonthPatterns$1,
|
|
3312
|
-
defaultMatchWidth: "wide",
|
|
3313
|
-
parsePatterns: parseMonthPatterns$1,
|
|
3314
|
-
defaultParseWidth: "any"
|
|
3315
|
-
}),
|
|
3316
|
-
day: buildMatchFn({
|
|
3317
|
-
matchPatterns: matchDayPatterns$1,
|
|
3318
|
-
defaultMatchWidth: "wide",
|
|
3319
|
-
parsePatterns: parseDayPatterns$1,
|
|
3320
|
-
defaultParseWidth: "any"
|
|
3321
|
-
}),
|
|
3322
|
-
dayPeriod: buildMatchFn({
|
|
3323
|
-
matchPatterns: matchDayPeriodPatterns$1,
|
|
3324
|
-
defaultMatchWidth: "any",
|
|
3325
|
-
parsePatterns: parseDayPeriodPatterns$1,
|
|
3326
|
-
defaultParseWidth: "any"
|
|
3327
|
-
})
|
|
3328
|
-
};
|
|
3329
|
-
const es = {
|
|
3330
|
-
code: "es",
|
|
3331
|
-
formatDistance: formatDistance$1,
|
|
3332
|
-
formatLong: formatLong$1,
|
|
3333
|
-
formatRelative: formatRelative$1,
|
|
3334
|
-
localize: localize$1,
|
|
3335
|
-
match: match$1,
|
|
3336
|
-
options: {
|
|
3337
|
-
weekStartsOn: 1,
|
|
3338
|
-
firstWeekContainsDate: 1
|
|
3339
|
-
}
|
|
3340
|
-
};
|
|
3341
|
-
function declension(scheme, count) {
|
|
3342
|
-
if (scheme.one !== void 0 && count === 1) {
|
|
3343
|
-
return scheme.one;
|
|
3344
|
-
}
|
|
3345
|
-
const rem10 = count % 10;
|
|
3346
|
-
const rem100 = count % 100;
|
|
3347
|
-
if (rem10 === 1 && rem100 !== 11) {
|
|
3348
|
-
return scheme.singularNominative.replace("{{count}}", String(count));
|
|
3349
|
-
} else if (rem10 >= 2 && rem10 <= 4 && (rem100 < 10 || rem100 > 20)) {
|
|
3350
|
-
return scheme.singularGenitive.replace("{{count}}", String(count));
|
|
3351
|
-
} else {
|
|
3352
|
-
return scheme.pluralGenitive.replace("{{count}}", String(count));
|
|
3353
|
-
}
|
|
3354
|
-
}
|
|
3355
|
-
function buildLocalizeTokenFn(scheme) {
|
|
3356
|
-
return (count, options) => {
|
|
3357
|
-
if (options?.addSuffix) {
|
|
3358
|
-
if (options.comparison && options.comparison > 0) {
|
|
3359
|
-
if (scheme.future) {
|
|
3360
|
-
return declension(scheme.future, count);
|
|
3361
|
-
} else {
|
|
3362
|
-
return "через " + declension(scheme.regular, count);
|
|
3363
|
-
}
|
|
3364
|
-
} else {
|
|
3365
|
-
if (scheme.past) {
|
|
3366
|
-
return declension(scheme.past, count);
|
|
3367
|
-
} else {
|
|
3368
|
-
return declension(scheme.regular, count) + " назад";
|
|
3369
|
-
}
|
|
3370
|
-
}
|
|
3371
|
-
} else {
|
|
3372
|
-
return declension(scheme.regular, count);
|
|
3373
|
-
}
|
|
3374
|
-
};
|
|
3375
|
-
}
|
|
3376
|
-
const formatDistanceLocale = {
|
|
3377
|
-
lessThanXSeconds: buildLocalizeTokenFn({
|
|
3378
|
-
regular: {
|
|
3379
|
-
one: "меньше секунды",
|
|
3380
|
-
singularNominative: "меньше {{count}} секунды",
|
|
3381
|
-
singularGenitive: "меньше {{count}} секунд",
|
|
3382
|
-
pluralGenitive: "меньше {{count}} секунд"
|
|
3383
|
-
},
|
|
3384
|
-
future: {
|
|
3385
|
-
one: "меньше, чем через секунду",
|
|
3386
|
-
singularNominative: "меньше, чем через {{count}} секунду",
|
|
3387
|
-
singularGenitive: "меньше, чем через {{count}} секунды",
|
|
3388
|
-
pluralGenitive: "меньше, чем через {{count}} секунд"
|
|
3389
|
-
}
|
|
3390
|
-
}),
|
|
3391
|
-
xSeconds: buildLocalizeTokenFn({
|
|
3392
|
-
regular: {
|
|
3393
|
-
singularNominative: "{{count}} секунда",
|
|
3394
|
-
singularGenitive: "{{count}} секунды",
|
|
3395
|
-
pluralGenitive: "{{count}} секунд"
|
|
3396
|
-
},
|
|
3397
|
-
past: {
|
|
3398
|
-
singularNominative: "{{count}} секунду назад",
|
|
3399
|
-
singularGenitive: "{{count}} секунды назад",
|
|
3400
|
-
pluralGenitive: "{{count}} секунд назад"
|
|
3401
|
-
},
|
|
3402
|
-
future: {
|
|
3403
|
-
singularNominative: "через {{count}} секунду",
|
|
3404
|
-
singularGenitive: "через {{count}} секунды",
|
|
3405
|
-
pluralGenitive: "через {{count}} секунд"
|
|
3406
|
-
}
|
|
3407
|
-
}),
|
|
3408
|
-
halfAMinute: (_count, options) => {
|
|
3409
|
-
if (options?.addSuffix) {
|
|
3410
|
-
if (options.comparison && options.comparison > 0) {
|
|
3411
|
-
return "через полминуты";
|
|
3412
|
-
} else {
|
|
3413
|
-
return "полминуты назад";
|
|
3414
|
-
}
|
|
3415
|
-
}
|
|
3416
|
-
return "полминуты";
|
|
3417
|
-
},
|
|
3418
|
-
lessThanXMinutes: buildLocalizeTokenFn({
|
|
3419
|
-
regular: {
|
|
3420
|
-
one: "меньше минуты",
|
|
3421
|
-
singularNominative: "меньше {{count}} минуты",
|
|
3422
|
-
singularGenitive: "меньше {{count}} минут",
|
|
3423
|
-
pluralGenitive: "меньше {{count}} минут"
|
|
3424
|
-
},
|
|
3425
|
-
future: {
|
|
3426
|
-
one: "меньше, чем через минуту",
|
|
3427
|
-
singularNominative: "меньше, чем через {{count}} минуту",
|
|
3428
|
-
singularGenitive: "меньше, чем через {{count}} минуты",
|
|
3429
|
-
pluralGenitive: "меньше, чем через {{count}} минут"
|
|
3430
|
-
}
|
|
3431
|
-
}),
|
|
3432
|
-
xMinutes: buildLocalizeTokenFn({
|
|
3433
|
-
regular: {
|
|
3434
|
-
singularNominative: "{{count}} минута",
|
|
3435
|
-
singularGenitive: "{{count}} минуты",
|
|
3436
|
-
pluralGenitive: "{{count}} минут"
|
|
3437
|
-
},
|
|
3438
|
-
past: {
|
|
3439
|
-
singularNominative: "{{count}} минуту назад",
|
|
3440
|
-
singularGenitive: "{{count}} минуты назад",
|
|
3441
|
-
pluralGenitive: "{{count}} минут назад"
|
|
3442
|
-
},
|
|
3443
|
-
future: {
|
|
3444
|
-
singularNominative: "через {{count}} минуту",
|
|
3445
|
-
singularGenitive: "через {{count}} минуты",
|
|
3446
|
-
pluralGenitive: "через {{count}} минут"
|
|
3447
|
-
}
|
|
3448
|
-
}),
|
|
3449
|
-
aboutXHours: buildLocalizeTokenFn({
|
|
3450
|
-
regular: {
|
|
3451
|
-
singularNominative: "около {{count}} часа",
|
|
3452
|
-
singularGenitive: "около {{count}} часов",
|
|
3453
|
-
pluralGenitive: "около {{count}} часов"
|
|
3454
|
-
},
|
|
3455
|
-
future: {
|
|
3456
|
-
singularNominative: "приблизительно через {{count}} час",
|
|
3457
|
-
singularGenitive: "приблизительно через {{count}} часа",
|
|
3458
|
-
pluralGenitive: "приблизительно через {{count}} часов"
|
|
3459
|
-
}
|
|
3460
|
-
}),
|
|
3461
|
-
xHours: buildLocalizeTokenFn({
|
|
3462
|
-
regular: {
|
|
3463
|
-
singularNominative: "{{count}} час",
|
|
3464
|
-
singularGenitive: "{{count}} часа",
|
|
3465
|
-
pluralGenitive: "{{count}} часов"
|
|
3466
|
-
}
|
|
3467
|
-
}),
|
|
3468
|
-
xDays: buildLocalizeTokenFn({
|
|
3469
|
-
regular: {
|
|
3470
|
-
singularNominative: "{{count}} день",
|
|
3471
|
-
singularGenitive: "{{count}} дня",
|
|
3472
|
-
pluralGenitive: "{{count}} дней"
|
|
3473
|
-
}
|
|
3474
|
-
}),
|
|
3475
|
-
aboutXWeeks: buildLocalizeTokenFn({
|
|
3476
|
-
regular: {
|
|
3477
|
-
singularNominative: "около {{count}} недели",
|
|
3478
|
-
singularGenitive: "около {{count}} недель",
|
|
3479
|
-
pluralGenitive: "около {{count}} недель"
|
|
3480
|
-
},
|
|
3481
|
-
future: {
|
|
3482
|
-
singularNominative: "приблизительно через {{count}} неделю",
|
|
3483
|
-
singularGenitive: "приблизительно через {{count}} недели",
|
|
3484
|
-
pluralGenitive: "приблизительно через {{count}} недель"
|
|
3485
|
-
}
|
|
3486
|
-
}),
|
|
3487
|
-
xWeeks: buildLocalizeTokenFn({
|
|
3488
|
-
regular: {
|
|
3489
|
-
singularNominative: "{{count}} неделя",
|
|
3490
|
-
singularGenitive: "{{count}} недели",
|
|
3491
|
-
pluralGenitive: "{{count}} недель"
|
|
3492
|
-
}
|
|
3493
|
-
}),
|
|
3494
|
-
aboutXMonths: buildLocalizeTokenFn({
|
|
3495
|
-
regular: {
|
|
3496
|
-
singularNominative: "около {{count}} месяца",
|
|
3497
|
-
singularGenitive: "около {{count}} месяцев",
|
|
3498
|
-
pluralGenitive: "около {{count}} месяцев"
|
|
3499
|
-
},
|
|
3500
|
-
future: {
|
|
3501
|
-
singularNominative: "приблизительно через {{count}} месяц",
|
|
3502
|
-
singularGenitive: "приблизительно через {{count}} месяца",
|
|
3503
|
-
pluralGenitive: "приблизительно через {{count}} месяцев"
|
|
3504
|
-
}
|
|
3505
|
-
}),
|
|
3506
|
-
xMonths: buildLocalizeTokenFn({
|
|
3507
|
-
regular: {
|
|
3508
|
-
singularNominative: "{{count}} месяц",
|
|
3509
|
-
singularGenitive: "{{count}} месяца",
|
|
3510
|
-
pluralGenitive: "{{count}} месяцев"
|
|
3511
|
-
}
|
|
3512
|
-
}),
|
|
3513
|
-
aboutXYears: buildLocalizeTokenFn({
|
|
3514
|
-
regular: {
|
|
3515
|
-
singularNominative: "около {{count}} года",
|
|
3516
|
-
singularGenitive: "около {{count}} лет",
|
|
3517
|
-
pluralGenitive: "около {{count}} лет"
|
|
3518
|
-
},
|
|
3519
|
-
future: {
|
|
3520
|
-
singularNominative: "приблизительно через {{count}} год",
|
|
3521
|
-
singularGenitive: "приблизительно через {{count}} года",
|
|
3522
|
-
pluralGenitive: "приблизительно через {{count}} лет"
|
|
3523
|
-
}
|
|
3524
|
-
}),
|
|
3525
|
-
xYears: buildLocalizeTokenFn({
|
|
3526
|
-
regular: {
|
|
3527
|
-
singularNominative: "{{count}} год",
|
|
3528
|
-
singularGenitive: "{{count}} года",
|
|
3529
|
-
pluralGenitive: "{{count}} лет"
|
|
3530
|
-
}
|
|
3531
|
-
}),
|
|
3532
|
-
overXYears: buildLocalizeTokenFn({
|
|
3533
|
-
regular: {
|
|
3534
|
-
singularNominative: "больше {{count}} года",
|
|
3535
|
-
singularGenitive: "больше {{count}} лет",
|
|
3536
|
-
pluralGenitive: "больше {{count}} лет"
|
|
3537
|
-
},
|
|
3538
|
-
future: {
|
|
3539
|
-
singularNominative: "больше, чем через {{count}} год",
|
|
3540
|
-
singularGenitive: "больше, чем через {{count}} года",
|
|
3541
|
-
pluralGenitive: "больше, чем через {{count}} лет"
|
|
3542
|
-
}
|
|
3543
|
-
}),
|
|
3544
|
-
almostXYears: buildLocalizeTokenFn({
|
|
3545
|
-
regular: {
|
|
3546
|
-
singularNominative: "почти {{count}} год",
|
|
3547
|
-
singularGenitive: "почти {{count}} года",
|
|
3548
|
-
pluralGenitive: "почти {{count}} лет"
|
|
3549
|
-
},
|
|
3550
|
-
future: {
|
|
3551
|
-
singularNominative: "почти через {{count}} год",
|
|
3552
|
-
singularGenitive: "почти через {{count}} года",
|
|
3553
|
-
pluralGenitive: "почти через {{count}} лет"
|
|
3554
|
-
}
|
|
3555
|
-
})
|
|
3556
|
-
};
|
|
3557
|
-
const formatDistance = (token, count, options) => {
|
|
3558
|
-
return formatDistanceLocale[token](count, options);
|
|
3559
|
-
};
|
|
3560
|
-
const dateFormats = {
|
|
3561
|
-
full: "EEEE, d MMMM y 'г.'",
|
|
3562
|
-
long: "d MMMM y 'г.'",
|
|
3563
|
-
medium: "d MMM y 'г.'",
|
|
3564
|
-
short: "dd.MM.y"
|
|
3565
|
-
};
|
|
3566
|
-
const timeFormats = {
|
|
3567
|
-
full: "H:mm:ss zzzz",
|
|
3568
|
-
long: "H:mm:ss z",
|
|
3569
|
-
medium: "H:mm:ss",
|
|
3570
|
-
short: "H:mm"
|
|
3571
|
-
};
|
|
3572
|
-
const dateTimeFormats = {
|
|
3573
|
-
any: "{{date}}, {{time}}"
|
|
3574
|
-
};
|
|
3575
|
-
const formatLong = {
|
|
3576
|
-
date: buildFormatLongFn({
|
|
3577
|
-
formats: dateFormats,
|
|
3578
|
-
defaultWidth: "full"
|
|
3579
|
-
}),
|
|
3580
|
-
time: buildFormatLongFn({
|
|
3581
|
-
formats: timeFormats,
|
|
3582
|
-
defaultWidth: "full"
|
|
3583
|
-
}),
|
|
3584
|
-
dateTime: buildFormatLongFn({
|
|
3585
|
-
formats: dateTimeFormats,
|
|
3586
|
-
defaultWidth: "any"
|
|
3587
|
-
})
|
|
3588
|
-
};
|
|
3589
|
-
const accusativeWeekdays = [
|
|
3590
|
-
"воскресенье",
|
|
3591
|
-
"понедельник",
|
|
3592
|
-
"вторник",
|
|
3593
|
-
"среду",
|
|
3594
|
-
"четверг",
|
|
3595
|
-
"пятницу",
|
|
3596
|
-
"субботу"
|
|
3597
|
-
];
|
|
3598
|
-
function lastWeek(day) {
|
|
3599
|
-
const weekday = accusativeWeekdays[day];
|
|
3600
|
-
switch (day) {
|
|
3601
|
-
case 0:
|
|
3602
|
-
return "'в прошлое " + weekday + " в' p";
|
|
3603
|
-
case 1:
|
|
3604
|
-
case 2:
|
|
3605
|
-
case 4:
|
|
3606
|
-
return "'в прошлый " + weekday + " в' p";
|
|
3607
|
-
case 3:
|
|
3608
|
-
case 5:
|
|
3609
|
-
case 6:
|
|
3610
|
-
return "'в прошлую " + weekday + " в' p";
|
|
3611
|
-
}
|
|
3612
|
-
}
|
|
3613
|
-
function thisWeek(day) {
|
|
3614
|
-
const weekday = accusativeWeekdays[day];
|
|
3615
|
-
if (day === 2) {
|
|
3616
|
-
return "'во " + weekday + " в' p";
|
|
3617
|
-
} else {
|
|
3618
|
-
return "'в " + weekday + " в' p";
|
|
3619
|
-
}
|
|
3620
|
-
}
|
|
3621
|
-
function nextWeek(day) {
|
|
3622
|
-
const weekday = accusativeWeekdays[day];
|
|
3623
|
-
switch (day) {
|
|
3624
|
-
case 0:
|
|
3625
|
-
return "'в следующее " + weekday + " в' p";
|
|
3626
|
-
case 1:
|
|
3627
|
-
case 2:
|
|
3628
|
-
case 4:
|
|
3629
|
-
return "'в следующий " + weekday + " в' p";
|
|
3630
|
-
case 3:
|
|
3631
|
-
case 5:
|
|
3632
|
-
case 6:
|
|
3633
|
-
return "'в следующую " + weekday + " в' p";
|
|
3634
|
-
}
|
|
3635
|
-
}
|
|
3636
|
-
const formatRelativeLocale = {
|
|
3637
|
-
lastWeek: (date, baseDate, options) => {
|
|
3638
|
-
const day = date.getDay();
|
|
3639
|
-
if (isSameWeek(date, baseDate, options)) {
|
|
3640
|
-
return thisWeek(day);
|
|
3641
|
-
} else {
|
|
3642
|
-
return lastWeek(day);
|
|
3643
|
-
}
|
|
3644
|
-
},
|
|
3645
|
-
yesterday: "'вчера в' p",
|
|
3646
|
-
today: "'сегодня в' p",
|
|
3647
|
-
tomorrow: "'завтра в' p",
|
|
3648
|
-
nextWeek: (date, baseDate, options) => {
|
|
3649
|
-
const day = date.getDay();
|
|
3650
|
-
if (isSameWeek(date, baseDate, options)) {
|
|
3651
|
-
return thisWeek(day);
|
|
3652
|
-
} else {
|
|
3653
|
-
return nextWeek(day);
|
|
3654
|
-
}
|
|
3655
|
-
},
|
|
3656
|
-
other: "P"
|
|
3657
|
-
};
|
|
3658
|
-
const formatRelative = (token, date, baseDate, options) => {
|
|
3659
|
-
const format2 = formatRelativeLocale[token];
|
|
3660
|
-
if (typeof format2 === "function") {
|
|
3661
|
-
return format2(date, baseDate, options);
|
|
3662
|
-
}
|
|
3663
|
-
return format2;
|
|
3664
|
-
};
|
|
3665
|
-
const eraValues = {
|
|
3666
|
-
narrow: ["до н.э.", "н.э."],
|
|
3667
|
-
abbreviated: ["до н. э.", "н. э."],
|
|
3668
|
-
wide: ["до нашей эры", "нашей эры"]
|
|
3669
|
-
};
|
|
3670
|
-
const quarterValues = {
|
|
3671
|
-
narrow: ["1", "2", "3", "4"],
|
|
3672
|
-
abbreviated: ["1-й кв.", "2-й кв.", "3-й кв.", "4-й кв."],
|
|
3673
|
-
wide: ["1-й квартал", "2-й квартал", "3-й квартал", "4-й квартал"]
|
|
3674
|
-
};
|
|
3675
|
-
const monthValues = {
|
|
3676
|
-
narrow: ["Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"],
|
|
3677
|
-
abbreviated: [
|
|
3678
|
-
"янв.",
|
|
3679
|
-
"фев.",
|
|
3680
|
-
"март",
|
|
3681
|
-
"апр.",
|
|
3682
|
-
"май",
|
|
3683
|
-
"июнь",
|
|
3684
|
-
"июль",
|
|
3685
|
-
"авг.",
|
|
3686
|
-
"сент.",
|
|
3687
|
-
"окт.",
|
|
3688
|
-
"нояб.",
|
|
3689
|
-
"дек."
|
|
3690
|
-
],
|
|
3691
|
-
wide: [
|
|
3692
|
-
"январь",
|
|
3693
|
-
"февраль",
|
|
3694
|
-
"март",
|
|
3695
|
-
"апрель",
|
|
3696
|
-
"май",
|
|
3697
|
-
"июнь",
|
|
3698
|
-
"июль",
|
|
3699
|
-
"август",
|
|
3700
|
-
"сентябрь",
|
|
3701
|
-
"октябрь",
|
|
3702
|
-
"ноябрь",
|
|
3703
|
-
"декабрь"
|
|
3704
|
-
]
|
|
3705
|
-
};
|
|
3706
|
-
const formattingMonthValues = {
|
|
3707
|
-
narrow: ["Я", "Ф", "М", "А", "М", "И", "И", "А", "С", "О", "Н", "Д"],
|
|
3708
|
-
abbreviated: [
|
|
3709
|
-
"янв.",
|
|
3710
|
-
"фев.",
|
|
3711
|
-
"мар.",
|
|
3712
|
-
"апр.",
|
|
3713
|
-
"мая",
|
|
3714
|
-
"июн.",
|
|
3715
|
-
"июл.",
|
|
3716
|
-
"авг.",
|
|
3717
|
-
"сент.",
|
|
3718
|
-
"окт.",
|
|
3719
|
-
"нояб.",
|
|
3720
|
-
"дек."
|
|
3721
|
-
],
|
|
3722
|
-
wide: [
|
|
3723
|
-
"января",
|
|
3724
|
-
"февраля",
|
|
3725
|
-
"марта",
|
|
3726
|
-
"апреля",
|
|
3727
|
-
"мая",
|
|
3728
|
-
"июня",
|
|
3729
|
-
"июля",
|
|
3730
|
-
"августа",
|
|
3731
|
-
"сентября",
|
|
3732
|
-
"октября",
|
|
3733
|
-
"ноября",
|
|
3734
|
-
"декабря"
|
|
3735
|
-
]
|
|
3736
|
-
};
|
|
3737
|
-
const dayValues = {
|
|
3738
|
-
narrow: ["В", "П", "В", "С", "Ч", "П", "С"],
|
|
3739
|
-
short: ["вс", "пн", "вт", "ср", "чт", "пт", "сб"],
|
|
3740
|
-
abbreviated: ["вск", "пнд", "втр", "срд", "чтв", "птн", "суб"],
|
|
3741
|
-
wide: [
|
|
3742
|
-
"воскресенье",
|
|
3743
|
-
"понедельник",
|
|
3744
|
-
"вторник",
|
|
3745
|
-
"среда",
|
|
3746
|
-
"четверг",
|
|
3747
|
-
"пятница",
|
|
3748
|
-
"суббота"
|
|
3749
|
-
]
|
|
3750
|
-
};
|
|
3751
|
-
const dayPeriodValues = {
|
|
3752
|
-
narrow: {
|
|
3753
|
-
am: "ДП",
|
|
3754
|
-
pm: "ПП",
|
|
3755
|
-
midnight: "полн.",
|
|
3756
|
-
noon: "полд.",
|
|
3757
|
-
morning: "утро",
|
|
3758
|
-
afternoon: "день",
|
|
3759
|
-
evening: "веч.",
|
|
3760
|
-
night: "ночь"
|
|
3761
|
-
},
|
|
3762
|
-
abbreviated: {
|
|
3763
|
-
am: "ДП",
|
|
3764
|
-
pm: "ПП",
|
|
3765
|
-
midnight: "полн.",
|
|
3766
|
-
noon: "полд.",
|
|
3767
|
-
morning: "утро",
|
|
3768
|
-
afternoon: "день",
|
|
3769
|
-
evening: "веч.",
|
|
3770
|
-
night: "ночь"
|
|
3771
|
-
},
|
|
3772
|
-
wide: {
|
|
3773
|
-
am: "ДП",
|
|
3774
|
-
pm: "ПП",
|
|
3775
|
-
midnight: "полночь",
|
|
3776
|
-
noon: "полдень",
|
|
3777
|
-
morning: "утро",
|
|
3778
|
-
afternoon: "день",
|
|
3779
|
-
evening: "вечер",
|
|
3780
|
-
night: "ночь"
|
|
3781
|
-
}
|
|
3782
|
-
};
|
|
3783
|
-
const formattingDayPeriodValues = {
|
|
3784
|
-
narrow: {
|
|
3785
|
-
am: "ДП",
|
|
3786
|
-
pm: "ПП",
|
|
3787
|
-
midnight: "полн.",
|
|
3788
|
-
noon: "полд.",
|
|
3789
|
-
morning: "утра",
|
|
3790
|
-
afternoon: "дня",
|
|
3791
|
-
evening: "веч.",
|
|
3792
|
-
night: "ночи"
|
|
3793
|
-
},
|
|
3794
|
-
abbreviated: {
|
|
3795
|
-
am: "ДП",
|
|
3796
|
-
pm: "ПП",
|
|
3797
|
-
midnight: "полн.",
|
|
3798
|
-
noon: "полд.",
|
|
3799
|
-
morning: "утра",
|
|
3800
|
-
afternoon: "дня",
|
|
3801
|
-
evening: "веч.",
|
|
3802
|
-
night: "ночи"
|
|
3803
|
-
},
|
|
3804
|
-
wide: {
|
|
3805
|
-
am: "ДП",
|
|
3806
|
-
pm: "ПП",
|
|
3807
|
-
midnight: "полночь",
|
|
3808
|
-
noon: "полдень",
|
|
3809
|
-
morning: "утра",
|
|
3810
|
-
afternoon: "дня",
|
|
3811
|
-
evening: "вечера",
|
|
3812
|
-
night: "ночи"
|
|
3813
|
-
}
|
|
3814
|
-
};
|
|
3815
|
-
const ordinalNumber = (dirtyNumber, options) => {
|
|
3816
|
-
const number = Number(dirtyNumber);
|
|
3817
|
-
const unit = options?.unit;
|
|
3818
|
-
let suffix;
|
|
3819
|
-
if (unit === "date") {
|
|
3820
|
-
suffix = "-е";
|
|
3821
|
-
} else if (unit === "week" || unit === "minute" || unit === "second") {
|
|
3822
|
-
suffix = "-я";
|
|
3823
|
-
} else {
|
|
3824
|
-
suffix = "-й";
|
|
3825
|
-
}
|
|
3826
|
-
return number + suffix;
|
|
3827
|
-
};
|
|
3828
|
-
const localize = {
|
|
3829
|
-
ordinalNumber,
|
|
3830
|
-
era: buildLocalizeFn({
|
|
3831
|
-
values: eraValues,
|
|
3832
|
-
defaultWidth: "wide"
|
|
3833
|
-
}),
|
|
3834
|
-
quarter: buildLocalizeFn({
|
|
3835
|
-
values: quarterValues,
|
|
3836
|
-
defaultWidth: "wide",
|
|
3837
|
-
argumentCallback: (quarter) => quarter - 1
|
|
3838
|
-
}),
|
|
3839
|
-
month: buildLocalizeFn({
|
|
3840
|
-
values: monthValues,
|
|
3841
|
-
defaultWidth: "wide",
|
|
3842
|
-
formattingValues: formattingMonthValues,
|
|
3843
|
-
defaultFormattingWidth: "wide"
|
|
3844
|
-
}),
|
|
3845
|
-
day: buildLocalizeFn({
|
|
3846
|
-
values: dayValues,
|
|
3847
|
-
defaultWidth: "wide"
|
|
3848
|
-
}),
|
|
3849
|
-
dayPeriod: buildLocalizeFn({
|
|
3850
|
-
values: dayPeriodValues,
|
|
3851
|
-
defaultWidth: "any",
|
|
3852
|
-
formattingValues: formattingDayPeriodValues,
|
|
3853
|
-
defaultFormattingWidth: "wide"
|
|
3854
|
-
})
|
|
3855
|
-
};
|
|
3856
|
-
const matchOrdinalNumberPattern = /^(\d+)(-?(е|я|й|ое|ье|ая|ья|ый|ой|ий|ый))?/i;
|
|
3857
|
-
const parseOrdinalNumberPattern = /\d+/i;
|
|
3858
|
-
const matchEraPatterns = {
|
|
3859
|
-
narrow: /^((до )?н\.?\s?э\.?)/i,
|
|
3860
|
-
abbreviated: /^((до )?н\.?\s?э\.?)/i,
|
|
3861
|
-
wide: /^(до нашей эры|нашей эры|наша эра)/i
|
|
3862
|
-
};
|
|
3863
|
-
const parseEraPatterns = {
|
|
3864
|
-
any: [/^д/i, /^н/i]
|
|
3865
|
-
};
|
|
3866
|
-
const matchQuarterPatterns = {
|
|
3867
|
-
narrow: /^[1234]/i,
|
|
3868
|
-
abbreviated: /^[1234](-?[ыои]?й?)? кв.?/i,
|
|
3869
|
-
wide: /^[1234](-?[ыои]?й?)? квартал/i
|
|
3870
|
-
};
|
|
3871
|
-
const parseQuarterPatterns = {
|
|
3872
|
-
any: [/1/i, /2/i, /3/i, /4/i]
|
|
3873
|
-
};
|
|
3874
|
-
const matchMonthPatterns = {
|
|
3875
|
-
narrow: /^[яфмаисонд]/i,
|
|
3876
|
-
abbreviated: /^(янв|фев|март?|апр|ма[йя]|июн[ья]?|июл[ья]?|авг|сент?|окт|нояб?|дек)\.?/i,
|
|
3877
|
-
wide: /^(январ[ья]|феврал[ья]|марта?|апрел[ья]|ма[йя]|июн[ья]|июл[ья]|августа?|сентябр[ья]|октябр[ья]|октябр[ья]|ноябр[ья]|декабр[ья])/i
|
|
3878
|
-
};
|
|
3879
|
-
const parseMonthPatterns = {
|
|
3880
|
-
narrow: [
|
|
3881
|
-
/^я/i,
|
|
3882
|
-
/^ф/i,
|
|
3883
|
-
/^м/i,
|
|
3884
|
-
/^а/i,
|
|
3885
|
-
/^м/i,
|
|
3886
|
-
/^и/i,
|
|
3887
|
-
/^и/i,
|
|
3888
|
-
/^а/i,
|
|
3889
|
-
/^с/i,
|
|
3890
|
-
/^о/i,
|
|
3891
|
-
/^н/i,
|
|
3892
|
-
/^я/i
|
|
3893
|
-
],
|
|
3894
|
-
any: [
|
|
3895
|
-
/^я/i,
|
|
3896
|
-
/^ф/i,
|
|
3897
|
-
/^мар/i,
|
|
3898
|
-
/^ап/i,
|
|
3899
|
-
/^ма[йя]/i,
|
|
3900
|
-
/^июн/i,
|
|
3901
|
-
/^июл/i,
|
|
3902
|
-
/^ав/i,
|
|
3903
|
-
/^с/i,
|
|
3904
|
-
/^о/i,
|
|
3905
|
-
/^н/i,
|
|
3906
|
-
/^д/i
|
|
3907
|
-
]
|
|
3908
|
-
};
|
|
3909
|
-
const matchDayPatterns = {
|
|
3910
|
-
narrow: /^[впсч]/i,
|
|
3911
|
-
short: /^(вс|во|пн|по|вт|ср|чт|че|пт|пя|сб|су)\.?/i,
|
|
3912
|
-
abbreviated: /^(вск|вос|пнд|пон|втр|вто|срд|сре|чтв|чет|птн|пят|суб).?/i,
|
|
3913
|
-
wide: /^(воскресень[ея]|понедельника?|вторника?|сред[аы]|четверга?|пятниц[аы]|суббот[аы])/i
|
|
3914
|
-
};
|
|
3915
|
-
const parseDayPatterns = {
|
|
3916
|
-
narrow: [/^в/i, /^п/i, /^в/i, /^с/i, /^ч/i, /^п/i, /^с/i],
|
|
3917
|
-
any: [/^в[ос]/i, /^п[он]/i, /^в/i, /^ср/i, /^ч/i, /^п[ят]/i, /^с[уб]/i]
|
|
3918
|
-
};
|
|
3919
|
-
const matchDayPeriodPatterns = {
|
|
3920
|
-
narrow: /^([дп]п|полн\.?|полд\.?|утр[оа]|день|дня|веч\.?|ноч[ьи])/i,
|
|
3921
|
-
abbreviated: /^([дп]п|полн\.?|полд\.?|утр[оа]|день|дня|веч\.?|ноч[ьи])/i,
|
|
3922
|
-
wide: /^([дп]п|полночь|полдень|утр[оа]|день|дня|вечера?|ноч[ьи])/i
|
|
3923
|
-
};
|
|
3924
|
-
const parseDayPeriodPatterns = {
|
|
3925
|
-
any: {
|
|
3926
|
-
am: /^дп/i,
|
|
3927
|
-
pm: /^пп/i,
|
|
3928
|
-
midnight: /^полн/i,
|
|
3929
|
-
noon: /^полд/i,
|
|
3930
|
-
morning: /^у/i,
|
|
3931
|
-
afternoon: /^д[ен]/i,
|
|
3932
|
-
evening: /^в/i,
|
|
3933
|
-
night: /^н/i
|
|
3934
|
-
}
|
|
3935
|
-
};
|
|
3936
|
-
const match = {
|
|
3937
|
-
ordinalNumber: buildMatchPatternFn({
|
|
3938
|
-
matchPattern: matchOrdinalNumberPattern,
|
|
3939
|
-
parsePattern: parseOrdinalNumberPattern,
|
|
3940
|
-
valueCallback: (value) => parseInt(value, 10)
|
|
3941
|
-
}),
|
|
3942
|
-
era: buildMatchFn({
|
|
3943
|
-
matchPatterns: matchEraPatterns,
|
|
3944
|
-
defaultMatchWidth: "wide",
|
|
3945
|
-
parsePatterns: parseEraPatterns,
|
|
3946
|
-
defaultParseWidth: "any"
|
|
3947
|
-
}),
|
|
3948
|
-
quarter: buildMatchFn({
|
|
3949
|
-
matchPatterns: matchQuarterPatterns,
|
|
3950
|
-
defaultMatchWidth: "wide",
|
|
3951
|
-
parsePatterns: parseQuarterPatterns,
|
|
3952
|
-
defaultParseWidth: "any",
|
|
3953
|
-
valueCallback: (index) => index + 1
|
|
3954
|
-
}),
|
|
3955
|
-
month: buildMatchFn({
|
|
3956
|
-
matchPatterns: matchMonthPatterns,
|
|
3957
|
-
defaultMatchWidth: "wide",
|
|
3958
|
-
parsePatterns: parseMonthPatterns,
|
|
3959
|
-
defaultParseWidth: "any"
|
|
3960
|
-
}),
|
|
3961
|
-
day: buildMatchFn({
|
|
3962
|
-
matchPatterns: matchDayPatterns,
|
|
3963
|
-
defaultMatchWidth: "wide",
|
|
3964
|
-
parsePatterns: parseDayPatterns,
|
|
3965
|
-
defaultParseWidth: "any"
|
|
3966
|
-
}),
|
|
3967
|
-
dayPeriod: buildMatchFn({
|
|
3968
|
-
matchPatterns: matchDayPeriodPatterns,
|
|
3969
|
-
defaultMatchWidth: "wide",
|
|
3970
|
-
parsePatterns: parseDayPeriodPatterns,
|
|
3971
|
-
defaultParseWidth: "any"
|
|
3972
|
-
})
|
|
3973
|
-
};
|
|
3974
|
-
const ru = {
|
|
3975
|
-
code: "ru",
|
|
3976
|
-
formatDistance,
|
|
3977
|
-
formatLong,
|
|
3978
|
-
formatRelative,
|
|
3979
|
-
localize,
|
|
3980
|
-
match,
|
|
3981
|
-
options: {
|
|
3982
|
-
weekStartsOn: 1,
|
|
3983
|
-
firstWeekContainsDate: 1
|
|
3984
|
-
}
|
|
3985
|
-
};
|
|
3986
1514
|
const formatDateLat = (date) => format(date, "dd/MM/yyyy", { locale: enGB });
|
|
3987
1515
|
const formatDateEs = (date) => format(date, "dd.MM.yyyy", { locale: es });
|
|
3988
1516
|
const formatDateRu = (date) => format(date, "dd.MM.yyyy", { locale: ru });
|