@vope/utils 1.6.1 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __defProp = Object.defineProperty;
3
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -20,23 +19,44 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
19
  // src/index.ts
21
20
  var index_exports = {};
22
21
  __export(index_exports, {
22
+ Cron: () => Cron,
23
+ DayLastValue: () => DayLastValue,
24
+ DigitsValue: () => DigitsValue,
23
25
  FlexTable: () => FlexTable,
26
+ InvalidValue: () => InvalidValue,
24
27
  MemoryBasic: () => MemoryBasic,
25
28
  MemoryList: () => MemoryList,
26
29
  MemoryPower: () => MemoryPower,
27
30
  MemorySimple: () => MemorySimple,
28
31
  Neo4j: () => Neo4j,
29
32
  Neo4jAhchors: () => Neo4jAhchors,
33
+ RangeValue: () => RangeValue,
30
34
  Subscriber: () => Subscriber,
31
35
  Union: () => Union,
36
+ WeekLastValue: () => WeekLastValue,
37
+ WildcardValue: () => WildcardValue,
38
+ calc: () => calc,
32
39
  clamp: () => clamp,
33
40
  classnames: () => classnames,
34
41
  compareVersion: () => compareVersion,
35
42
  connectURLParams: () => connectURLParams,
43
+ createCronRegexText: () => createCronRegexText,
36
44
  css: () => css,
37
45
  cubeURLParams: () => cubeURLParams,
38
46
  deconPowersSum: () => deconPowersSum,
39
47
  deepWeakEqual: () => deepWeakEqual,
48
+ default_max_day: () => default_max_day,
49
+ default_max_hour: () => default_max_hour,
50
+ default_max_minute: () => default_max_minute,
51
+ default_max_month: () => default_max_month,
52
+ default_max_second: () => default_max_second,
53
+ default_max_week: () => default_max_week,
54
+ default_min_day: () => default_min_day,
55
+ default_min_hour: () => default_min_hour,
56
+ default_min_minute: () => default_min_minute,
57
+ default_min_month: () => default_min_month,
58
+ default_min_second: () => default_min_second,
59
+ default_min_week: () => default_min_week,
40
60
  desensDecrypt: () => desensDecrypt,
41
61
  desensEncrypt: () => desensEncrypt,
42
62
  desensReplace: () => desensReplace,
@@ -46,20 +66,48 @@ __export(index_exports, {
46
66
  hash8object: () => hash8object,
47
67
  hash8strings: () => hash8strings,
48
68
  inputRegex: () => inputRegex,
69
+ isCalc: () => isCalc,
49
70
  isClass: () => isClass,
71
+ isDayLastValue: () => isDayLastValue,
72
+ isDigitsValue: () => isDigitsValue,
50
73
  isEmpty: () => isEmpty,
74
+ isInvalidValue: () => isInvalidValue,
51
75
  isKey: () => isKey,
52
76
  isNull: () => isNull,
77
+ isRangeValue: () => isRangeValue,
78
+ isWeekLastValue: () => isWeekLastValue,
79
+ isWildcardValue: () => isWildcardValue,
53
80
  joinPaths: () => joinPaths,
54
81
  loadImage: () => loadImage,
55
82
  once: () => once,
56
83
  parseNum: () => parseNum,
57
84
  rotateAngle: () => rotateAngle,
58
85
  rotateRad: () => rotateRad,
59
- wait: () => wait
86
+ wait: () => wait,
87
+ weekDic: () => weekDic
60
88
  });
61
89
  module.exports = __toCommonJS(index_exports);
62
90
 
91
+ // src/calc.ts
92
+ var import_lodash_es = require("lodash-es");
93
+ var formatter = (value) => (0, import_lodash_es.isNumber)(value) ? value && `${value}px` : value;
94
+ var isCalc = (value) => value.slice(0, 5) === "calc(" && value.slice(-1) === ")";
95
+ var calc = (...list) => {
96
+ const size = list.length;
97
+ if (size === 0) return 0;
98
+ if (size === 1) return formatter(list[1]);
99
+ const value = list.reduce((caches, value2) => {
100
+ let tmp = formatter(value2);
101
+ if (tmp === 0) return caches;
102
+ if (isCalc(tmp)) {
103
+ tmp = tmp.slice(4);
104
+ }
105
+ return caches ? `${caches} + ${tmp}` : tmp;
106
+ }, "");
107
+ return value === "" ? 0 : `calc(${value})`;
108
+ };
109
+ calc.formatter = formatter;
110
+
63
111
  // src/clamp.ts
64
112
  var clamp = (value, min, max) => {
65
113
  if (min > max) {
@@ -71,14 +119,14 @@ var clamp = (value, min, max) => {
71
119
  };
72
120
 
73
121
  // src/classnames.ts
74
- var import_lodash_es = require("lodash-es");
122
+ var import_lodash_es2 = require("lodash-es");
75
123
  var add = (a, b) => a ? a + " " + b : b;
76
124
  var classnames = (...list) => list.reduce((caches, data) => {
77
- if ((0, import_lodash_es.isString)(data)) {
125
+ if ((0, import_lodash_es2.isString)(data)) {
78
126
  data && (caches = add(caches, data));
79
127
  } else if (Array.isArray(data)) {
80
- data.forEach((value) => value && (0, import_lodash_es.isString)(value) && (caches = add(caches, value)));
81
- } else if (!(0, import_lodash_es.isBoolean)(data)) {
128
+ data.forEach((value) => value && (0, import_lodash_es2.isString)(value) && (caches = add(caches, value)));
129
+ } else if (!(0, import_lodash_es2.isBoolean)(data)) {
82
130
  for (const key in data) {
83
131
  key && data[key] && (caches = add(caches, key));
84
132
  }
@@ -149,8 +197,654 @@ var hash8object = (list, key) => list.reduce((caches, data) => {
149
197
  return caches;
150
198
  }, /* @__PURE__ */ new Map());
151
199
 
200
+ // src/cron.ts
201
+ var import_lodash_es3 = require("lodash-es");
202
+ var {
203
+ parseInt,
204
+ isInteger,
205
+ MAX_SAFE_INTEGER
206
+ } = Number;
207
+ var Dic = class {
208
+ constructor(dics) {
209
+ this.dics = dics;
210
+ this.keys = hash8json(dics, "key");
211
+ this.values = hash8json(dics, "value");
212
+ }
213
+ keys;
214
+ values;
215
+ item(key) {
216
+ return this.keys[key]?.value;
217
+ }
218
+ at(value) {
219
+ return this.values[value]?.key;
220
+ }
221
+ reduce(callbackfn, initialValue) {
222
+ return this.dics.reduce(callbackfn, initialValue);
223
+ }
224
+ };
225
+ var weekDic = new Dic([
226
+ {
227
+ key: "SUN",
228
+ value: 0
229
+ },
230
+ {
231
+ key: "MON",
232
+ value: 1
233
+ },
234
+ {
235
+ key: "TUE",
236
+ value: 2
237
+ },
238
+ {
239
+ key: "WED",
240
+ value: 3
241
+ },
242
+ {
243
+ key: "THU",
244
+ value: 4
245
+ },
246
+ {
247
+ key: "FRI",
248
+ value: 5
249
+ },
250
+ {
251
+ key: "SAT",
252
+ value: 6
253
+ }
254
+ ]);
255
+ var place_value = 0;
256
+ var default_max_second = 59;
257
+ var default_min_second = 0;
258
+ var default_max_minute = default_max_second;
259
+ var default_min_minute = default_min_second;
260
+ var default_max_hour = 23;
261
+ var default_min_hour = 0;
262
+ var default_max_day = 31;
263
+ var default_min_day = 1;
264
+ var default_max_month = 12;
265
+ var default_min_month = 1;
266
+ var default_max_week = 6;
267
+ var default_min_week = 0;
268
+ var re_single_number_text = "\\d";
269
+ var createCronRegexText = (options = {}) => {
270
+ const {
271
+ enableSlot = true,
272
+ enableSecond = true,
273
+ enableYear = true,
274
+ enableMax = true,
275
+ enableInvalid = true,
276
+ enableDayLast = true,
277
+ enableWeekLast = true,
278
+ enableWeekSupport7 = true,
279
+ enableWeekSupportDic = true,
280
+ enableDicEnumSupportMixin = true,
281
+ enablePrefixZero
282
+ } = options;
283
+ const enableMaxSplit = enableMax && (options.enableIncrementMax ?? true);
284
+ const singleNumberMatch = (end, fromZero) => {
285
+ const start = fromZero ? 0 : 1;
286
+ if (end === start) {
287
+ return `${end}`;
288
+ } else if (end < 3 + start) {
289
+ let text = "";
290
+ for (let i = start; i <= end; i++) {
291
+ text += i;
292
+ }
293
+ return `[${text}]`;
294
+ } else if (start === 0 && end === 9) {
295
+ return re_single_number_text;
296
+ } else {
297
+ return `[${start}-${end}]`;
298
+ }
299
+ };
300
+ const numberMatch = (max, fromZero) => {
301
+ if (max === place_value) return `[1-9]${re_single_number_text}*`;
302
+ if (max < 10) return singleNumberMatch(max, fromZero);
303
+ const mod = max % 10;
304
+ const quot = (max - mod) / 10;
305
+ let text = "";
306
+ if (fromZero) {
307
+ text = re_single_number_text;
308
+ } else {
309
+ text = singleNumberMatch(9);
310
+ }
311
+ text += "|";
312
+ if (mod === 9) {
313
+ text += singleNumberMatch(quot) + re_single_number_text;
314
+ } else {
315
+ if (quot > 1) {
316
+ text += singleNumberMatch(quot - 1) + re_single_number_text + "|";
317
+ }
318
+ text += `${quot}${singleNumberMatch(mod, true)}`;
319
+ }
320
+ return `(?:${text})`;
321
+ };
322
+ const numberMatchByPrefix = (max, fromZero) => {
323
+ const text = numberMatch(max, fromZero);
324
+ return enablePrefixZero ? "0*" + text : text;
325
+ };
326
+ const mixin = (text) => {
327
+ let tmp = "";
328
+ for (const char of text) {
329
+ const code = char.charCodeAt(0);
330
+ if (code > 64 && code < 91) {
331
+ tmp += `[${char.toLocaleLowerCase()}${char}]`;
332
+ } else if (code > 96 && code < 123) {
333
+ tmp += `[${char}${char.toLocaleUpperCase()}]`;
334
+ } else {
335
+ tmp += char;
336
+ }
337
+ }
338
+ return tmp;
339
+ };
340
+ const generate = ({
341
+ type,
342
+ max,
343
+ split,
344
+ dic,
345
+ invalid,
346
+ last,
347
+ fromZero
348
+ }) => {
349
+ const list = [];
350
+ invalid && list.push("\\?");
351
+ const template = [numberMatchByPrefix(max, fromZero)];
352
+ let lastTemplate;
353
+ if (last) {
354
+ if (type === "D") {
355
+ lastTemplate = `L(?:-${numberMatchByPrefix(max - 1)})?`;
356
+ } else if (type === "w") {
357
+ lastTemplate = `${numberMatchByPrefix(max, true)}L`;
358
+ }
359
+ }
360
+ if (type === "w" && dic) {
361
+ template.push(
362
+ dic.reduce((tmp2, { key }) => {
363
+ const text = enableDicEnumSupportMixin ? mixin(key) : key;
364
+ return tmp2 ? tmp2 + "|" + text : text;
365
+ }, "")
366
+ );
367
+ }
368
+ let tmp = template.length > 1 ? `(?:${template.join("|")})` : template[0];
369
+ if (lastTemplate) {
370
+ tmp = `(?:\\*|(?:${lastTemplate}|${tmp}(?:-${tmp})?)(?:,(?:${lastTemplate}|${tmp}(?:-${tmp})?))*)`;
371
+ } else {
372
+ tmp = `(?:\\*|${tmp}(?:-${tmp})?(?:,${tmp}(?:-${tmp})?)*)`;
373
+ }
374
+ list.push(`${tmp}(?:\\/${numberMatchByPrefix(split)})?`);
375
+ return list.join("|");
376
+ };
377
+ let regex = "";
378
+ const join = (config, isLast) => {
379
+ const space = "\\s+";
380
+ let code = generate(config);
381
+ if (enableSlot) {
382
+ code = `(?<${config.type}>${code})`;
383
+ } else {
384
+ code = `(${code})`;
385
+ }
386
+ if (!isLast) {
387
+ code += space;
388
+ }
389
+ if (config.partial) {
390
+ if (isLast) {
391
+ regex = regex.slice(0, space.length * -1) + `(?:${space}${code})?`;
392
+ return;
393
+ } else {
394
+ code = `(?:${code})?`;
395
+ }
396
+ }
397
+ regex += code;
398
+ };
399
+ enableSecond && join({
400
+ type: "s",
401
+ max: enableMax ? default_max_second : place_value,
402
+ split: enableMaxSplit ? default_max_second : place_value,
403
+ fromZero: !default_min_second
404
+ });
405
+ join({
406
+ type: "m",
407
+ max: enableMax ? default_max_minute : place_value,
408
+ split: enableMaxSplit ? default_max_minute : place_value,
409
+ fromZero: !default_min_minute
410
+ });
411
+ join({
412
+ type: "h",
413
+ max: enableMax ? default_max_hour : place_value,
414
+ split: enableMaxSplit ? default_max_hour : place_value,
415
+ fromZero: !default_min_hour
416
+ });
417
+ join({
418
+ type: "D",
419
+ max: enableMax ? default_max_day : place_value,
420
+ split: enableMaxSplit ? default_max_day : place_value,
421
+ invalid: enableInvalid,
422
+ last: enableDayLast,
423
+ fromZero: !default_min_day
424
+ });
425
+ join({
426
+ type: "M",
427
+ max: enableMax ? default_max_month : place_value,
428
+ split: enableMaxSplit ? default_max_month : place_value,
429
+ fromZero: !default_min_month
430
+ });
431
+ join((() => {
432
+ const max = enableWeekSupport7 ? 7 : default_max_week;
433
+ const config = {
434
+ type: "w",
435
+ max: enableMax ? max : place_value,
436
+ split: enableMaxSplit ? 7 : place_value,
437
+ fromZero: !default_min_week,
438
+ invalid: enableInvalid,
439
+ last: enableWeekLast
440
+ };
441
+ if (enableWeekSupportDic) {
442
+ config.dic = weekDic;
443
+ }
444
+ return config;
445
+ })(), !enableYear);
446
+ enableYear && join({
447
+ type: "Y",
448
+ max: place_value,
449
+ split: place_value,
450
+ fromZero: true,
451
+ partial: true
452
+ }, true);
453
+ return {
454
+ regex,
455
+ enableSlot,
456
+ enableSecond,
457
+ enableYear,
458
+ enableDayLast,
459
+ enableWeekLast,
460
+ enableInvalid
461
+ };
462
+ };
463
+ var InvalidValue = class {
464
+ constructor(isEnableInvalid) {
465
+ this.isEnableInvalid = isEnableInvalid;
466
+ }
467
+ text() {
468
+ return this.isEnableInvalid ? "?" : "*";
469
+ }
470
+ };
471
+ var isInvalidValue = (value) => value instanceof InvalidValue;
472
+ var LastValue = class {
473
+ constructor(value) {
474
+ this.value = value;
475
+ }
476
+ };
477
+ var DayLastValue = class extends LastValue {
478
+ text() {
479
+ const { value } = this;
480
+ return "L" + (value ? `-${value}` : "");
481
+ }
482
+ };
483
+ var isDayLastValue = (value) => value instanceof DayLastValue;
484
+ var WeekLastValue = class extends LastValue {
485
+ text() {
486
+ return `${this.value}L`;
487
+ }
488
+ };
489
+ var isWeekLastValue = (value) => value instanceof WeekLastValue;
490
+ var WildcardValue = class {
491
+ text() {
492
+ return "*";
493
+ }
494
+ };
495
+ var isWildcardValue = (value) => value instanceof WildcardValue;
496
+ var RangeValue = class {
497
+ constructor(start, stop) {
498
+ this.start = start;
499
+ this.stop = stop;
500
+ }
501
+ text() {
502
+ return `${this.start}-${this.stop}`;
503
+ }
504
+ };
505
+ var isRangeValue = (value) => value instanceof RangeValue;
506
+ var DigitsValue = class {
507
+ constructor(values, increment) {
508
+ this.values = values;
509
+ this.increment = increment;
510
+ }
511
+ text() {
512
+ const { values, increment } = this;
513
+ let tmp;
514
+ if (Array.isArray(values)) {
515
+ tmp = values.reduce((caches, data) => {
516
+ let tmp2;
517
+ if ((0, import_lodash_es3.isNumber)(data)) {
518
+ tmp2 = `${data}`;
519
+ } else {
520
+ tmp2 = data.text();
521
+ }
522
+ return caches ? caches + "," + tmp2 : tmp2;
523
+ }, "");
524
+ } else {
525
+ tmp = values.text();
526
+ }
527
+ return increment ? `${tmp}/${increment}` : tmp;
528
+ }
529
+ };
530
+ var isDigitsValue = (value) => value instanceof DigitsValue;
531
+ var re_num = /\d/;
532
+ var parseDigit = (text) => {
533
+ if (re_num.test(text[0])) {
534
+ return parseInt(text);
535
+ } else {
536
+ return weekDic.item(text.toLocaleUpperCase());
537
+ }
538
+ };
539
+ var parseDigits = (text) => {
540
+ return text.split(",").map((text2) => {
541
+ const [a, b] = text2.split("-");
542
+ if (a === "L" && b === void 0) {
543
+ return new DayLastValue(0);
544
+ } else if (b === void 0) {
545
+ if (a.slice(-1) === "L") {
546
+ return new WeekLastValue(parseInt(a.slice(0, -1)));
547
+ } else {
548
+ return parseDigit(a);
549
+ }
550
+ } else {
551
+ if (a === "L") {
552
+ return new DayLastValue(parseInt(b));
553
+ } else {
554
+ return new RangeValue(parseDigit(a), parseDigit(b));
555
+ }
556
+ }
557
+ });
558
+ };
559
+ var validate = (value, min, max) => {
560
+ if (isInteger(value)) {
561
+ return value >= min && value <= max;
562
+ } else if (Array.isArray(value)) {
563
+ if (value.length !== 2) return false;
564
+ const [a, b] = value;
565
+ return isInteger(a) && isInteger(b) && a <= b && a >= min && b <= max;
566
+ }
567
+ return false;
568
+ };
569
+ var validateIncrement = (value, min, max) => {
570
+ return isInteger(value) && value > 0 && value >= min && value <= max;
571
+ };
572
+ var formaterDigits = (value, min, max) => {
573
+ let values;
574
+ if (value === "*") {
575
+ values = new WildcardValue();
576
+ } else if (Array.isArray(value)) {
577
+ const tmp = [];
578
+ value.some((data) => {
579
+ if (validate(data, min, max)) {
580
+ tmp.push(
581
+ (0, import_lodash_es3.isNumber)(data) ? data : new RangeValue(data[0], data[1])
582
+ );
583
+ return false;
584
+ } else {
585
+ return true;
586
+ }
587
+ }) || (values = tmp);
588
+ } else if (validate(value, min, max)) {
589
+ values = [value];
590
+ }
591
+ return values;
592
+ };
593
+ var formaterLastDigits = (value, min, max, prototype) => {
594
+ let values;
595
+ if (value === "*") {
596
+ values = new WildcardValue();
597
+ } else {
598
+ const tmp = [];
599
+ const list = Array.isArray(value) ? value : [value];
600
+ list.some((data) => {
601
+ if ((0, import_lodash_es3.isString)(data)) {
602
+ const result = parseDigits(data);
603
+ if (result.length === 1 && result[0] instanceof prototype && validate(result[0].value, min, max - 1)) {
604
+ tmp.push(result[0]);
605
+ return false;
606
+ }
607
+ } else if (validate(data, min, max)) {
608
+ tmp.push(
609
+ (0, import_lodash_es3.isNumber)(data) ? data : new RangeValue(data[0], data[1])
610
+ );
611
+ return false;
612
+ }
613
+ return true;
614
+ }) || (values = tmp);
615
+ }
616
+ return values;
617
+ };
618
+ var Parse = class {
619
+ constructor(second, minute, hour, day, month, week, year, cron) {
620
+ this.cron = cron;
621
+ if (second) {
622
+ this.second = this.parse(second);
623
+ }
624
+ this.minute = this.parse(minute);
625
+ this.hour = this.parse(hour);
626
+ this.day = this.parse(day);
627
+ this.month = this.parse(month);
628
+ this.week = this.parse(week);
629
+ if (year) {
630
+ this.year = this.parse(year);
631
+ }
632
+ }
633
+ second;
634
+ minute;
635
+ hour;
636
+ day;
637
+ month;
638
+ week;
639
+ year;
640
+ parse(text) {
641
+ if (text === "?") return new InvalidValue(this.cron.isEnableInvalid);
642
+ const [slices, increment] = text.split("/");
643
+ return new DigitsValue(
644
+ slices === "*" ? new WildcardValue() : parseDigits(slices),
645
+ increment ? parseInt(increment) : void 0
646
+ );
647
+ }
648
+ setSecond(value, increment) {
649
+ if (!this.cron.isEnableSecond) return false;
650
+ const values = formaterDigits(value, default_min_second, default_max_second);
651
+ if (!values) return false;
652
+ const second = new DigitsValue(values);
653
+ if (validateIncrement(increment, default_min_second, default_max_second)) {
654
+ second.increment = increment;
655
+ }
656
+ this.second = second;
657
+ return true;
658
+ }
659
+ setMinute(value, increment) {
660
+ const values = formaterDigits(value, default_min_minute, default_max_minute);
661
+ if (!values) return false;
662
+ const minute = new DigitsValue(values);
663
+ if (validateIncrement(increment, default_min_minute, default_max_minute)) {
664
+ minute.increment = increment;
665
+ }
666
+ this.minute = minute;
667
+ return true;
668
+ }
669
+ setHour(value, increment) {
670
+ const values = formaterDigits(value, default_min_hour, default_max_hour);
671
+ if (!values) return false;
672
+ const hour = new DigitsValue(values);
673
+ if (validateIncrement(increment, default_min_hour, default_max_hour)) {
674
+ hour.increment = increment;
675
+ }
676
+ this.hour = hour;
677
+ return true;
678
+ }
679
+ setDayInvalid() {
680
+ this.day = new InvalidValue(this.cron.isEnableInvalid);
681
+ if (this.week instanceof InvalidValue) {
682
+ this.week = new DigitsValue(new WildcardValue());
683
+ }
684
+ }
685
+ setDay(value, increment) {
686
+ let values;
687
+ if (value === "?") {
688
+ this.setDayInvalid();
689
+ return true;
690
+ } else {
691
+ const tmp2 = formaterLastDigits(value, default_min_day, default_max_day, DayLastValue);
692
+ if (!tmp2) return false;
693
+ values = tmp2;
694
+ }
695
+ const tmp = new DigitsValue(values);
696
+ if (validateIncrement(increment, default_min_day, default_max_day)) {
697
+ tmp.increment = increment;
698
+ }
699
+ this.day = tmp;
700
+ const { week } = this;
701
+ if (isDigitsValue(week) && (week.increment !== void 0 || !isWildcardValue(week.values))) {
702
+ if (this.cron.isEnableInvalid) {
703
+ this.week = new InvalidValue(true);
704
+ } else {
705
+ week.values = new WildcardValue();
706
+ week.increment = void 0;
707
+ }
708
+ }
709
+ return true;
710
+ }
711
+ setMonth(value, increment) {
712
+ const values = formaterDigits(value, default_min_month, default_max_month);
713
+ if (!values) return false;
714
+ const month = new DigitsValue(values);
715
+ if (validateIncrement(increment, default_min_month, default_max_month)) {
716
+ month.increment = increment;
717
+ }
718
+ this.month = month;
719
+ return true;
720
+ }
721
+ setWeekInvalid() {
722
+ this.week = new InvalidValue(this.cron.isEnableInvalid);
723
+ if (this.day instanceof InvalidValue) {
724
+ this.day = new DigitsValue(new WildcardValue());
725
+ }
726
+ }
727
+ setWeek(value, increment) {
728
+ let values;
729
+ if (value === "?") {
730
+ this.setWeekInvalid();
731
+ return true;
732
+ } else {
733
+ const tmp2 = formaterLastDigits(value, default_min_week, default_max_week, WeekLastValue);
734
+ if (!tmp2) return false;
735
+ values = tmp2;
736
+ }
737
+ const tmp = new DigitsValue(values);
738
+ if (validateIncrement(increment, default_min_week, default_max_week)) {
739
+ tmp.increment = increment;
740
+ }
741
+ this.week = tmp;
742
+ const { day } = this;
743
+ if (isDigitsValue(day) && (day.increment !== void 0 || !isWildcardValue(day.values))) {
744
+ if (this.cron.isEnableInvalid) {
745
+ this.day = new InvalidValue(true);
746
+ } else {
747
+ day.values = new WildcardValue();
748
+ day.increment = void 0;
749
+ }
750
+ }
751
+ return true;
752
+ }
753
+ setYear(value, increment) {
754
+ if (!this.cron.isEnableYear) return false;
755
+ const values = formaterDigits(value, 0, MAX_SAFE_INTEGER);
756
+ if (!values) return false;
757
+ const year = new DigitsValue(values);
758
+ if (validateIncrement(increment, 0, MAX_SAFE_INTEGER)) {
759
+ year.increment = increment;
760
+ }
761
+ this.year = year;
762
+ return true;
763
+ }
764
+ text() {
765
+ const { cron, second, year } = this;
766
+ const list = [];
767
+ if (cron.isEnableSecond) {
768
+ list.push(second ? second.text() : "0");
769
+ }
770
+ list.push(this.minute.text());
771
+ list.push(this.hour.text());
772
+ list.push(this.day.text());
773
+ list.push(this.month.text());
774
+ list.push(this.week.text());
775
+ if (cron.isEnableYear && year) {
776
+ list.push(year.text());
777
+ }
778
+ return list.join(" ");
779
+ }
780
+ };
781
+ var Cron = class {
782
+ #options;
783
+ #regex;
784
+ get isEnableSecond() {
785
+ return this.#options.enableSecond;
786
+ }
787
+ get isEnableYear() {
788
+ return this.#options.enableYear;
789
+ }
790
+ get isEnableDayLast() {
791
+ return this.#options.enableDayLast;
792
+ }
793
+ get isEnableWeekLast() {
794
+ return this.#options.enableWeekLast;
795
+ }
796
+ get isEnableInvalid() {
797
+ return this.#options.enableInvalid;
798
+ }
799
+ constructor(options) {
800
+ const { regex } = this.#options = createCronRegexText(options);
801
+ this.#regex = new RegExp(`^${regex}$`);
802
+ }
803
+ parse(text) {
804
+ const matchs = text.trim().match(this.#regex);
805
+ if (!matchs) return;
806
+ const config = this.#options;
807
+ const { enableSecond, enableYear } = config;
808
+ let second;
809
+ let minute;
810
+ let hour;
811
+ let day;
812
+ let month;
813
+ let week;
814
+ let year;
815
+ if (config.enableSlot) {
816
+ const groups = matchs.groups;
817
+ if (enableSecond) {
818
+ second = groups.s;
819
+ }
820
+ minute = groups.m;
821
+ hour = groups.h;
822
+ day = groups.D;
823
+ month = groups.M;
824
+ week = groups.w;
825
+ if (enableYear) {
826
+ year = groups.Y;
827
+ }
828
+ } else {
829
+ let count = 1;
830
+ if (enableSecond) {
831
+ second = matchs[count++];
832
+ }
833
+ minute = matchs[count++];
834
+ hour = matchs[count++];
835
+ day = matchs[count++];
836
+ month = matchs[count++];
837
+ week = matchs[count++];
838
+ if (enableYear) {
839
+ year = matchs[count++];
840
+ }
841
+ }
842
+ return new Parse(second, minute, hour, day, month, week, year, this);
843
+ }
844
+ };
845
+
152
846
  // src/desens.ts
153
- var import_lodash_es2 = require("lodash-es");
847
+ var import_lodash_es4 = require("lodash-es");
154
848
  var desensEncrypt = (plaintext, encrypt) => {
155
849
  const rules = [];
156
850
  let point = -1;
@@ -189,7 +883,7 @@ var desensReplace = (ciphertext, rules, replacer = "*") => {
189
883
  return rules.reduce((cache, { range: [start, stop], modify }) => {
190
884
  const part = ciphertext.slice(start + offset, start + offset + modify);
191
885
  const size = stop + 1 - start;
192
- const replaceValue = (0, import_lodash_es2.isString)(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
886
+ const replaceValue = (0, import_lodash_es4.isString)(replacer) ? replacer.repeat(size) : replacer[Symbol.replace](part, size);
193
887
  cache += ciphertext.slice(from, start + offset) + replaceValue;
194
888
  from = start + offset + modify;
195
889
  offset += modify - size;
@@ -939,12 +1633,12 @@ var once = (func, thisArg) => {
939
1633
  };
940
1634
 
941
1635
  // src/parse/num.ts
942
- var import_lodash_es3 = require("lodash-es");
1636
+ var import_lodash_es5 = require("lodash-es");
943
1637
  var pow = Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));
944
- var re_num = /^([-+]?)0*(\d+)(?:(n)|(?:\.(\d+))?(?:[Ee]([-+]?)(\d+))?)$/;
1638
+ var re_num2 = /^([-+]?)0*(\d+)(?:(n)|(?:\.(\d+))?(?:[Ee]([-+]?)(\d+))?)$/;
945
1639
  var parseNum = (num) => {
946
- if ((0, import_lodash_es3.isNumber)(num) || typeof num === "bigint") return num;
947
- const match = num.match(re_num);
1640
+ if ((0, import_lodash_es5.isNumber)(num) || typeof num === "bigint") return num;
1641
+ const match = num.match(re_num2);
948
1642
  if (!match) return Number.NaN;
949
1643
  const [, valueSymbol, integer, bigint, decimal, powSymbol, powValue] = match;
950
1644
  if (bigint === "n") return BigInt(valueSymbol + integer);
@@ -972,7 +1666,7 @@ var parseNum = (num) => {
972
1666
  var rotateAngle = (from, angle, visit) => rotateRad(from, angle / 180 * Math.PI, visit);
973
1667
 
974
1668
  // src/serialize/url-params.ts
975
- var import_lodash_es4 = require("lodash-es");
1669
+ var import_lodash_es6 = require("lodash-es");
976
1670
  var cubes = {
977
1671
  string: (text) => text,
978
1672
  boolean: (text) => text === "true",
@@ -997,7 +1691,7 @@ var cubeURLParams = (text, serializes) => {
997
1691
  for (const [key, value] of params) {
998
1692
  const serialize = serializes[key];
999
1693
  if (!serialize) continue;
1000
- if ((0, import_lodash_es4.isString)(serialize) && isKey(serialize, cubes)) {
1694
+ if ((0, import_lodash_es6.isString)(serialize) && isKey(serialize, cubes)) {
1001
1695
  result[key] = cubes[serialize](value);
1002
1696
  } else {
1003
1697
  result[key] = serialize.cube(value);
@@ -1015,21 +1709,21 @@ var flatURLParams = (data, serializes) => {
1015
1709
  if (!serialize) continue;
1016
1710
  params.append(
1017
1711
  key,
1018
- (0, import_lodash_es4.isString)(serialize) && isKey(serialize, flats) ? flats[serialize](value) : serialize.flat(value)
1712
+ (0, import_lodash_es6.isString)(serialize) && isKey(serialize, flats) ? flats[serialize](value) : serialize.flat(value)
1019
1713
  );
1020
1714
  }
1021
1715
  return params.toString();
1022
1716
  };
1023
1717
 
1024
1718
  // src/style/css.ts
1025
- var import_lodash_es5 = require("lodash-es");
1719
+ var import_lodash_es7 = require("lodash-es");
1026
1720
  var hump = /[A-Z]/g;
1027
1721
  var css = (...args) => {
1028
1722
  const list = [];
1029
1723
  for (let i = 0; i < args.length; i++) {
1030
1724
  const data = args[i];
1031
1725
  if (!data) continue;
1032
- if ((0, import_lodash_es5.isString)(data)) {
1726
+ if ((0, import_lodash_es7.isString)(data)) {
1033
1727
  list.push(data);
1034
1728
  } else if (Array.isArray(data)) {
1035
1729
  const result = css(...data);
@@ -1203,9 +1897,9 @@ var FlexTable = class {
1203
1897
 
1204
1898
  // src/union.ts
1205
1899
  var Union = class {
1206
- constructor(key, formatter) {
1900
+ constructor(key, formatter2) {
1207
1901
  this.key = key;
1208
- this.formatter = formatter;
1902
+ this.formatter = formatter2;
1209
1903
  }
1210
1904
  #data = {};
1211
1905
  #options = {};