@base-web-kits/base-tools-web 1.2.5 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,9 +1,12 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
6
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __pow = Math.pow;
7
10
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
11
  var __spreadValues = (a, b) => {
9
12
  for (var prop in b || (b = {}))
@@ -17,6 +20,20 @@ var __spreadValues = (a, b) => {
17
20
  return a;
18
21
  };
19
22
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
+ var __export = (target, all) => {
24
+ for (var name in all)
25
+ __defProp(target, name, { get: all[name], enumerable: true });
26
+ };
27
+ var __copyProps = (to, from, except, desc) => {
28
+ if (from && typeof from === "object" || typeof from === "function") {
29
+ for (let key of __getOwnPropNames(from))
30
+ if (!__hasOwnProp.call(to, key) && key !== except)
31
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
+ }
33
+ return to;
34
+ };
35
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
36
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
20
37
  var __async = (__this, __arguments, generator) => {
21
38
  return new Promise((resolve, reject) => {
22
39
  var fulfilled = (value) => {
@@ -240,10 +257,10 @@ function execCopyFromHtml(html) {
240
257
  div.innerHTML = html;
241
258
  document.body.appendChild(div);
242
259
  const selection = window.getSelection();
243
- const range2 = document.createRange();
244
- range2.selectNodeContents(div);
260
+ const range = document.createRange();
261
+ range.selectNodeContents(div);
245
262
  selection == null ? void 0 : selection.removeAllRanges();
246
- selection == null ? void 0 : selection.addRange(range2);
263
+ selection == null ? void 0 : selection.addRange(range);
247
264
  const ok = document.execCommand("copy");
248
265
  document.body.removeChild(div);
249
266
  selection == null ? void 0 : selection.removeAllRanges();
@@ -552,6 +569,149 @@ function preloadImage(src) {
552
569
  });
553
570
  }
554
571
 
572
+ // src/ts/index.ts
573
+ var ts_exports = {};
574
+ __export(ts_exports, {
575
+ BigNumber: () => BigNumber,
576
+ EventBus: () => EventBus,
577
+ appendUrlParam: () => appendUrlParam,
578
+ arrayMove: () => arrayMove,
579
+ buildOSSUrl: () => buildOSSUrl,
580
+ createTimeRandId: () => createTimeRandId,
581
+ createUUID: () => createUUID,
582
+ createViewRandId: () => createViewRandId,
583
+ dayjs: () => dayjs,
584
+ getAgeByBirthdate: () => getAgeByBirthdate,
585
+ getByteLength: () => getByteLength,
586
+ getCountdownParts: () => getCountdownParts,
587
+ getDateRangeAfter: () => getDateRangeAfter,
588
+ getDateRangeBefore: () => getDateRangeBefore,
589
+ getFileSuffix: () => getFileSuffix,
590
+ getFileType: () => getFileType,
591
+ getOSSAudio: () => getOSSAudio,
592
+ getOSSHls: () => getOSSHls,
593
+ getOSSImg: () => getOSSImg,
594
+ getOSSVideo: () => getOSSVideo,
595
+ getObjectKeys: () => getObjectKeys,
596
+ getObjectValue: () => getObjectValue,
597
+ getQnAudio: () => getQnAudio,
598
+ getQnHls: () => getQnHls,
599
+ getQnImg: () => getQnImg,
600
+ getQnVideo: () => getQnVideo,
601
+ isBankCard: () => isBankCard,
602
+ isChinese: () => isChinese,
603
+ isChineseName: () => isChineseName,
604
+ isDigits: () => isDigits,
605
+ isEmail: () => isEmail,
606
+ isHKMOPermit: () => isHKMOPermit,
607
+ isHexColor: () => isHexColor,
608
+ isIP: () => isIP,
609
+ isIPRange: () => isIPRange,
610
+ isIPv6: () => isIPv6,
611
+ isIdentityCard: () => isIdentityCard,
612
+ isLandline: () => isLandline,
613
+ isLatitude: () => isLatitude,
614
+ isLetter: () => isLetter,
615
+ isLicensePlate: () => isLicensePlate,
616
+ isLongitude: () => isLongitude,
617
+ isMilitaryId: () => isMilitaryId,
618
+ isMobilePhone: () => isMobilePhone,
619
+ isNumeric: () => isNumeric,
620
+ isOfficerId: () => isOfficerId,
621
+ isPassport: () => isPassport,
622
+ isPhone: () => isPhone,
623
+ isPortNumber: () => isPortNumber,
624
+ isSoldierId: () => isSoldierId,
625
+ isTaiwanPermit: () => isTaiwanPermit,
626
+ isTaxID: () => isTaxID,
627
+ isURL: () => isURL,
628
+ mathCompare: () => mathCompare,
629
+ mathDiv: () => mathDiv,
630
+ mathEqual: () => mathEqual,
631
+ mathFixed: () => mathFixed,
632
+ mathGreaterThan: () => mathGreaterThan,
633
+ mathGreaterThanOrEqual: () => mathGreaterThanOrEqual,
634
+ mathLessThan: () => mathLessThan,
635
+ mathLessThanOrEqual: () => mathLessThanOrEqual,
636
+ mathMinus: () => mathMinus,
637
+ mathPlus: () => mathPlus,
638
+ mathPow: () => mathPow,
639
+ mathRound: () => mathRound,
640
+ mathTimes: () => mathTimes,
641
+ randomBoolean: () => randomBoolean,
642
+ setObjectValue: () => setObjectValue,
643
+ toAsync: () => toAsync,
644
+ toChineseCurrency: () => toChineseCurrency,
645
+ toChineseNum: () => toChineseNum,
646
+ toDayjs: () => toDayjs,
647
+ toMaskName: () => toMaskName,
648
+ toMaskPhone: () => toMaskPhone,
649
+ toMaskText: () => toMaskText,
650
+ toThousandth: () => toThousandth,
651
+ withDistance: () => withDistance,
652
+ withUnit: () => withUnit,
653
+ withUnitPx: () => withUnitPx,
654
+ zeroPad: () => zeroPad
655
+ });
656
+
657
+ // src/ts/array/index.ts
658
+ function arrayMove(list, fromIndex, toIndex) {
659
+ const newList = [...list];
660
+ const [removed] = newList.splice(fromIndex, 1);
661
+ newList.splice(toIndex, 0, removed);
662
+ return newList;
663
+ }
664
+
665
+ // src/ts/async/index.ts
666
+ function toAsync(p) {
667
+ return __async(this, null, function* () {
668
+ try {
669
+ const data = yield p;
670
+ return [data, null];
671
+ } catch (err) {
672
+ return [null, err];
673
+ }
674
+ });
675
+ }
676
+
677
+ // src/ts/bean/EventBus.ts
678
+ import mitt from "mitt";
679
+ var EventBus = class {
680
+ constructor() {
681
+ __publicField(this, "_emitter", mitt());
682
+ }
683
+ /** 订阅 */
684
+ on(type, fn) {
685
+ this._emitter.on(type, fn);
686
+ return this;
687
+ }
688
+ /** 订阅一次 */
689
+ once(type, fn) {
690
+ const wrap = (event) => {
691
+ this._emitter.off(type, wrap);
692
+ fn(event);
693
+ };
694
+ this._emitter.on(type, wrap);
695
+ return this;
696
+ }
697
+ /** 发布 */
698
+ emit(type, event) {
699
+ this._emitter.emit(type, event);
700
+ return this;
701
+ }
702
+ /** 移除 */
703
+ off(type, fn) {
704
+ this._emitter.off(type, fn);
705
+ return this;
706
+ }
707
+ /** 清空 */
708
+ clear() {
709
+ this._emitter.all.clear();
710
+ return this;
711
+ }
712
+ };
713
+ var EventBus_default = new EventBus();
714
+
555
715
  // src/ts/day/index.ts
556
716
  import dayjs from "dayjs";
557
717
  import customParseFormat from "dayjs/plugin/customParseFormat";
@@ -560,6 +720,198 @@ import timezone from "dayjs/plugin/timezone";
560
720
  import relativeTime from "dayjs/plugin/relativeTime";
561
721
  import advancedFormat from "dayjs/plugin/advancedFormat";
562
722
  import "dayjs/locale/zh-cn";
723
+
724
+ // src/ts/number/big.ts
725
+ import BigNumber from "bignumber.js";
726
+ function big(x) {
727
+ return x instanceof BigNumber ? x : new BigNumber(x);
728
+ }
729
+ function mathPlus(...rest) {
730
+ let acc = big(rest[0]);
731
+ for (const x of rest.slice(1)) acc = acc.plus(big(x));
732
+ return acc.toNumber();
733
+ }
734
+ function mathMinus(...rest) {
735
+ let acc = big(rest[0]);
736
+ for (const x of rest.slice(1)) acc = acc.minus(big(x));
737
+ return acc.toNumber();
738
+ }
739
+ function mathTimes(...rest) {
740
+ let acc = big(rest[0]);
741
+ for (const x of rest.slice(1)) acc = acc.times(big(x));
742
+ return acc.toNumber();
743
+ }
744
+ function mathDiv(...rest) {
745
+ let acc = big(rest[0]);
746
+ for (const x of rest.slice(1)) acc = acc.div(big(x));
747
+ return acc.toNumber();
748
+ }
749
+ function mathPow(x, y) {
750
+ return big(x).pow(big(y)).toNumber();
751
+ }
752
+ function mathRound(x, dp = 0, rm = BigNumber.ROUND_HALF_UP) {
753
+ return big(x).decimalPlaces(dp, rm).toNumber();
754
+ }
755
+ function mathFixed(x, dp = 2, rm = BigNumber.ROUND_HALF_UP) {
756
+ return big(x).toFixed(dp, rm);
757
+ }
758
+ function mathCompare(a, b) {
759
+ return big(a).comparedTo(big(b));
760
+ }
761
+ function mathEqual(a, b) {
762
+ return big(a).isEqualTo(big(b));
763
+ }
764
+ function mathGreaterThan(a, b) {
765
+ return big(a).isGreaterThan(big(b));
766
+ }
767
+ function mathGreaterThanOrEqual(a, b) {
768
+ return big(a).isGreaterThanOrEqualTo(big(b));
769
+ }
770
+ function mathLessThan(a, b) {
771
+ return big(a).isLessThan(big(b));
772
+ }
773
+ function mathLessThanOrEqual(a, b) {
774
+ return big(a).isLessThanOrEqualTo(big(b));
775
+ }
776
+
777
+ // src/ts/number/format.ts
778
+ function zeroPad(n, len = 2) {
779
+ return String(n).padStart(len, "0");
780
+ }
781
+ function withUnit(num, unit = "") {
782
+ if (num === null || num === void 0 || num === "") return "";
783
+ if (typeof num === "number") return `${num}${unit}`;
784
+ const str = String(num).trim();
785
+ if (str === "") return "";
786
+ return isNaN(+str) ? str : `${str}${unit}`;
787
+ }
788
+ function withUnitPx(num) {
789
+ return withUnit(num, "px");
790
+ }
791
+ function withDistance(m) {
792
+ const n = Number(m != null ? m : 0);
793
+ if (!Number.isFinite(n)) return "0m";
794
+ return n >= 1e3 ? `${+(n / 1e3).toFixed(2)}km` : `${+n.toFixed(2)}m`;
795
+ }
796
+ function toThousandth(str) {
797
+ const v = String(str != null ? str : "").trim();
798
+ if (v === "") return "";
799
+ let sign = "";
800
+ let num = v;
801
+ if (num[0] === "-" || num[0] === "+") {
802
+ sign = num[0];
803
+ num = num.slice(1);
804
+ }
805
+ const [intPart, decPart] = num.split(".");
806
+ const groupedInt = intPart.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
807
+ return decPart !== void 0 && decPart !== "" ? `${sign}${groupedInt}.${decPart}` : `${sign}${groupedInt}`;
808
+ }
809
+ function toChineseNum(num) {
810
+ const numInt = Math.trunc(+num);
811
+ if (numInt === 0) return "\u96F6";
812
+ const digit = ["\u96F6", "\u4E00", "\u4E8C", "\u4E09", "\u56DB", "\u4E94", "\u516D", "\u4E03", "\u516B", "\u4E5D"];
813
+ const unit = ["", "\u5341", "\u767E", "\u5343"];
814
+ const bigUnit = ["", "\u4E07", "\u4EBF", "\u5146"];
815
+ const section4 = (n2) => {
816
+ let str = "", zeroFlag = false;
817
+ for (let i = 0; i < 4; i++) {
818
+ const d = n2 % 10;
819
+ n2 = Math.floor(n2 / 10);
820
+ if (d === 0) {
821
+ zeroFlag = true;
822
+ continue;
823
+ }
824
+ if (zeroFlag) str = digit[0] + str;
825
+ str = digit[d] + unit[i] + str;
826
+ zeroFlag = false;
827
+ }
828
+ return str;
829
+ };
830
+ let res = "";
831
+ let sectionIndex = 0;
832
+ let n = Math.abs(numInt);
833
+ while (n > 0) {
834
+ const seg = n % 1e4;
835
+ n = Math.floor(n / 1e4);
836
+ if (seg) {
837
+ const segStr = section4(seg);
838
+ res = segStr + (sectionIndex ? bigUnit[sectionIndex] : "") + res;
839
+ } else if (res && !res.startsWith("\u96F6")) {
840
+ res = `\u96F6${res}`;
841
+ }
842
+ sectionIndex++;
843
+ }
844
+ res = res.replace(/^一十/, "\u5341");
845
+ return numInt < 0 ? `\u8D1F${res}` : res;
846
+ }
847
+ function toChineseCurrency(amount, opts = {}) {
848
+ var _a, _b, _c;
849
+ const dp = (_a = opts.precision) != null ? _a : 2;
850
+ const rm = (_b = opts.rm) != null ? _b : BigNumber.ROUND_HALF_UP;
851
+ const yuan = (_c = opts.yuanChar) != null ? _c : "\u5143";
852
+ if (amount === null || amount === void 0) return "";
853
+ const bn = new BigNumber(amount);
854
+ if (!bn.isFinite()) return "";
855
+ const s = bn.toFixed(dp, rm);
856
+ const sign = s.startsWith("-") ? "\u8D1F" : "";
857
+ const [intStr, decStr = ""] = s.replace(/^-/, "").split(".");
858
+ const digit = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
859
+ const unit = ["", "\u62FE", "\u4F70", "\u4EDF"];
860
+ const bigUnit = ["", "\u4E07", "\u4EBF", "\u5146"];
861
+ const smallUnit = ["\u89D2", "\u5206", "\u5398"];
862
+ const section4 = (n) => {
863
+ let str = "";
864
+ let zeroFlag = false;
865
+ for (let i = 0; i < 4; i++) {
866
+ const d = n.mod(10).toNumber();
867
+ n = n.idiv(10);
868
+ if (d === 0) {
869
+ zeroFlag = true;
870
+ continue;
871
+ }
872
+ if (zeroFlag) str = digit[0] + str;
873
+ str = digit[d] + unit[i] + str;
874
+ zeroFlag = false;
875
+ }
876
+ return str.replace(/零+$/g, "");
877
+ };
878
+ const intNum = new BigNumber(intStr);
879
+ let res = "";
880
+ if (intNum.isZero()) {
881
+ res = digit[0];
882
+ } else {
883
+ let n = intNum.abs();
884
+ let sectionIndex = 0;
885
+ while (n.gt(0)) {
886
+ const seg = n.mod(1e4);
887
+ n = n.idiv(1e4);
888
+ if (seg.gt(0)) {
889
+ const segStr = section4(seg);
890
+ const needZero = res && !res.startsWith(digit[0]) && (seg.lt(1e3) || seg.mod(1e3).isZero());
891
+ const bu = sectionIndex ? bigUnit[sectionIndex] : "";
892
+ res = segStr + bu + (needZero ? digit[0] : "") + res;
893
+ } else if (res && !res.startsWith(digit[0])) {
894
+ res = digit[0] + res;
895
+ }
896
+ sectionIndex++;
897
+ }
898
+ res = res.replace(/^壹拾/, "\u62FE");
899
+ }
900
+ let frac = "";
901
+ for (let i = 0; i < Math.min(3, dp); i++) {
902
+ const ch = decStr[i] || "0";
903
+ const d = ch.charCodeAt(0) - 48;
904
+ if (d > 0) frac += digit[d] + smallUnit[i];
905
+ }
906
+ return frac ? `${sign}${res}${yuan}${frac}` : `${sign}${res}${yuan}\u6574`;
907
+ }
908
+
909
+ // src/ts/number/random.ts
910
+ function randomBoolean() {
911
+ return Math.random() < 0.5;
912
+ }
913
+
914
+ // src/ts/day/index.ts
563
915
  dayjs.extend(customParseFormat);
564
916
  dayjs.extend(utc);
565
917
  dayjs.extend(timezone);
@@ -586,197 +938,219 @@ function toDayjs(t, fmt) {
586
938
  }
587
939
  return dayjs(t, fmt);
588
940
  }
941
+ function getDateRangeBefore(offset, fmt = "YYYY-MM-DD") {
942
+ const now = toDayjs(Date.now());
943
+ const n = Math.max(0, Math.trunc(offset));
944
+ const hasTime = /H|h|m|s|S|A|a|x|X/.test(fmt);
945
+ const startDay = now.add(-n, "day");
946
+ const endDay = now;
947
+ const start = (hasTime ? startDay.startOf("day") : startDay).format(fmt);
948
+ const end = (hasTime ? endDay.endOf("day") : endDay).format(fmt);
949
+ return [start, end];
950
+ }
951
+ function getDateRangeAfter(offset, fmt = "YYYY-MM-DD") {
952
+ const now = toDayjs(Date.now());
953
+ const n = Math.max(0, Math.trunc(offset));
954
+ const hasTime = /H|h|m|s|S|A|a|x|X/.test(fmt);
955
+ const startDay = now;
956
+ const endDay = now.add(n, "day");
957
+ const start = (hasTime ? startDay.startOf("day") : startDay).format(fmt);
958
+ const end = (hasTime ? endDay.endOf("day") : endDay).format(fmt);
959
+ return [start, end];
960
+ }
961
+ function getCountdownParts(diff) {
962
+ if (diff <= 0) return { d: "00", h: "00", m: "00", s: "00", ms: "000" };
963
+ const d = Math.floor(diff / (1e3 * 60 * 60 * 24));
964
+ const h = Math.floor(diff / (1e3 * 60 * 60) % 24);
965
+ const m = Math.floor(diff / (1e3 * 60) % 60);
966
+ const s = Math.floor(diff / 1e3 % 60);
967
+ const ms = diff % 1e3;
968
+ return {
969
+ d: zeroPad(d),
970
+ h: zeroPad(h),
971
+ m: zeroPad(m),
972
+ s: zeroPad(s),
973
+ ms: zeroPad(ms, 3)
974
+ };
975
+ }
976
+ function getAgeByBirthdate(birthdate) {
977
+ const birth = toDayjs(birthdate, "YYYY-MM-DD");
978
+ const now = toDayjs(Date.now());
979
+ const totalMonths = (now.year() - birth.year()) * 12 + (now.month() - birth.month());
980
+ const adjustedMonths = now.date() < birth.date() ? totalMonths - 1 : totalMonths;
981
+ if (adjustedMonths >= 12) {
982
+ let age = Math.floor(adjustedMonths / 12);
983
+ const birthdayThisYear = birth.add(age, "year");
984
+ if (now.isBefore(birthdayThisYear)) {
985
+ age--;
986
+ }
987
+ return { age, type: "year" };
988
+ }
989
+ return { age: adjustedMonths, type: "month" };
990
+ }
589
991
 
590
992
  // src/ts/es-toolkit/index.ts
591
- import {
592
- AbortError,
593
- Mutex,
594
- Semaphore,
595
- TimeoutError,
596
- after,
597
- ary,
598
- assert,
599
- asyncNoop,
600
- at,
601
- attempt,
602
- attemptAsync,
603
- before,
604
- camelCase,
605
- capitalize,
606
- chunk,
607
- clamp,
608
- clone,
609
- cloneDeep,
610
- cloneDeepWith,
611
- compact,
612
- constantCase,
613
- countBy,
614
- curry,
615
- curryRight,
616
- debounce,
617
- deburr,
618
- delay,
619
- difference,
620
- differenceBy,
621
- differenceWith,
622
- drop,
623
- dropRight,
624
- dropRightWhile,
625
- dropWhile,
626
- escape,
627
- escapeRegExp,
628
- fill,
629
- filterAsync,
630
- findKey,
631
- flatMap,
632
- flatMapAsync,
633
- flatMapDeep,
634
- flatten,
635
- flattenDeep,
636
- flattenObject,
637
- flow,
638
- flowRight,
639
- forEachAsync,
640
- forEachRight,
641
- groupBy,
642
- head,
643
- identity,
644
- inRange,
645
- initial,
646
- intersection,
647
- intersectionBy,
648
- intersectionWith,
649
- invariant,
650
- invert,
651
- isArrayBuffer,
652
- isBlob,
653
- isBoolean,
654
- isBrowser,
655
- isBuffer,
656
- isDate,
657
- isEmptyObject,
658
- isEqual,
659
- isEqualWith,
660
- isError,
661
- isFile,
662
- isFunction,
663
- isJSON,
664
- isJSONArray,
665
- isJSONObject,
666
- isJSONValue,
667
- isLength,
668
- isMap,
669
- isNil,
670
- isNode,
671
- isNotNil,
672
- isNull,
673
- isNumber,
674
- isPlainObject,
675
- isPrimitive,
676
- isPromise,
677
- isRegExp,
678
- isSet,
679
- isString,
680
- isSubset,
681
- isSubsetWith,
682
- isSymbol,
683
- isTypedArray,
684
- isUndefined,
685
- isWeakMap,
686
- isWeakSet,
687
- kebabCase,
688
- keyBy,
689
- last,
690
- limitAsync,
691
- lowerCase,
692
- lowerFirst,
693
- mapAsync,
694
- mapKeys,
695
- mapValues,
696
- maxBy,
697
- mean,
698
- meanBy,
699
- median,
700
- medianBy,
701
- memoize,
702
- merge,
703
- mergeWith,
704
- minBy,
705
- negate,
706
- noop,
707
- omit,
708
- omitBy,
709
- once,
710
- orderBy,
711
- pad,
712
- partial,
713
- partialRight,
714
- partition,
715
- pascalCase,
716
- pick,
717
- pickBy,
718
- pull,
719
- pullAt,
720
- random,
721
- randomInt,
722
- range,
723
- rangeRight,
724
- reduceAsync,
725
- remove,
726
- rest,
727
- retry,
728
- reverseString,
729
- round,
730
- sample,
731
- sampleSize,
732
- shuffle,
733
- snakeCase,
734
- sortBy,
735
- spread,
736
- startCase,
737
- sum,
738
- sumBy,
739
- tail,
740
- take,
741
- takeRight,
742
- takeRightWhile,
743
- takeWhile,
744
- throttle,
745
- timeout,
746
- toCamelCaseKeys,
747
- toFilled,
748
- toMerged,
749
- toSnakeCaseKeys,
750
- trim,
751
- trimEnd,
752
- trimStart,
753
- unary,
754
- unescape,
755
- union,
756
- unionBy,
757
- unionWith,
758
- uniq,
759
- uniqBy,
760
- uniqWith,
761
- unzip,
762
- unzipWith,
763
- upperCase,
764
- upperFirst,
765
- windowed,
766
- withTimeout,
767
- without,
768
- words,
769
- xor,
770
- xorBy,
771
- xorWith,
772
- zip,
773
- zipObject,
774
- zipWith
775
- } from "es-toolkit";
993
+ var es_toolkit_exports = {};
994
+ __reExport(es_toolkit_exports, es_toolkit_star);
995
+ import * as es_toolkit_star from "es-toolkit";
996
+
997
+ // src/ts/index.ts
998
+ __reExport(ts_exports, es_toolkit_exports);
776
999
 
777
1000
  // src/ts/object/index.ts
778
1001
  import { get, set } from "es-toolkit/compat";
1002
+ function getObjectKeys(obj) {
1003
+ return Object.keys(obj);
1004
+ }
779
1005
  var getObjectValue = get;
1006
+ var setObjectValue = set;
1007
+
1008
+ // src/ts/string/format.ts
1009
+ function toMaskText(s, keepLeft = 1, keepRight = 0, maskChar = "*") {
1010
+ if (!s) return "";
1011
+ const v = String(s);
1012
+ const l = Math.max(0, keepLeft);
1013
+ const r = Math.max(0, keepRight);
1014
+ const len = v.length;
1015
+ const left = Math.min(l, len);
1016
+ const right = Math.min(r, len - left);
1017
+ const mid = len - left - right;
1018
+ if (mid <= 0) return v;
1019
+ const m = maskChar && maskChar.length > 0 ? maskChar : "*";
1020
+ return v.slice(0, left) + m.repeat(mid) + v.slice(len - right);
1021
+ }
1022
+ function toMaskPhone(phone) {
1023
+ return toMaskText(phone, 3, 4);
1024
+ }
1025
+ function toMaskName(name) {
1026
+ if (!name) return "";
1027
+ const v = String(name);
1028
+ return v.length <= 2 ? toMaskText(v, 1, 0) : toMaskText(v, 1, 1);
1029
+ }
1030
+
1031
+ // src/ts/string/random.ts
1032
+ function createUUID() {
1033
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
1034
+ const r = Math.random() * 16 | 0, v = c === "x" ? r : r & 3 | 8;
1035
+ return v.toString(16);
1036
+ });
1037
+ }
1038
+ function createViewRandId(prefix = "id_") {
1039
+ return `${prefix}${Math.random().toString(36).substring(2, 16)}`;
1040
+ }
1041
+ function createTimeRandId(digits = 6) {
1042
+ const base = __pow(10, digits - 1);
1043
+ const range = 9 * base;
1044
+ const int = Math.floor(Math.random() * range) + base;
1045
+ return `${Date.now()}${int}`;
1046
+ }
1047
+
1048
+ // src/ts/string/other.ts
1049
+ function getByteLength(data) {
1050
+ if (typeof data === "string") {
1051
+ let byteLen = 0;
1052
+ for (let i = 0; i < data.length; i++) {
1053
+ const code = data.charCodeAt(i);
1054
+ if (code <= 127) {
1055
+ byteLen += 1;
1056
+ } else if (code <= 2047) {
1057
+ byteLen += 2;
1058
+ } else if (code >= 55296 && code <= 56319) {
1059
+ byteLen += 4;
1060
+ i++;
1061
+ } else {
1062
+ byteLen += 3;
1063
+ }
1064
+ }
1065
+ return byteLen;
1066
+ }
1067
+ if ("byteLength" in data) return data.byteLength;
1068
+ if ("size" in data) return data.size;
1069
+ throw new TypeError("getByteLength: Unsupported type");
1070
+ }
1071
+
1072
+ // src/ts/url/file/index.ts
1073
+ var FILE_TYPE = {
1074
+ img: ["png", "jpg", "jpeg", "gif", "svg", "webp"],
1075
+ video: ["mp4", "mov", "m4v"],
1076
+ voice: ["mp3", "wav", "m4a"],
1077
+ excel: ["csv", "xls", "xlsx", "xlsm", "ods"],
1078
+ word: ["txt", "doc", "docx", "pdf", "md", "wps"],
1079
+ zip: ["zip", "gz", "tar", "rar", "7z"],
1080
+ ppt: ["ppt", "pptx", "odp"],
1081
+ app: ["apk", "ipa"]
1082
+ };
1083
+ function getFileSuffix(fileName) {
1084
+ if (fileName.startsWith(".")) return "";
1085
+ const idx = fileName.lastIndexOf(".");
1086
+ return idx > 0 ? fileName.slice(idx + 1).toLowerCase() : "";
1087
+ }
1088
+ function getFileType(fileName) {
1089
+ const suffix = getFileSuffix(fileName);
1090
+ if (!suffix) return "unknown";
1091
+ const keys = getObjectKeys(FILE_TYPE);
1092
+ for (const key of keys) {
1093
+ if (FILE_TYPE[key].includes(suffix)) {
1094
+ return key;
1095
+ }
1096
+ }
1097
+ return "unknown";
1098
+ }
1099
+
1100
+ // src/ts/url/oss/index.ts
1101
+ function getOSSImg(src, option) {
1102
+ return buildOSSUrl(src, "image", option);
1103
+ }
1104
+ function getOSSVideo(src, option) {
1105
+ return buildOSSUrl(src, "video", option);
1106
+ }
1107
+ function getOSSAudio(src, option) {
1108
+ return buildOSSUrl(src, "audio", option);
1109
+ }
1110
+ function getOSSHls(src, option) {
1111
+ return buildOSSUrl(src, "hls", option);
1112
+ }
1113
+ function buildOSSUrl(src, type, option) {
1114
+ if (!src || !option) return src;
1115
+ if (src.startsWith("blob:")) return src;
1116
+ if (src.includes(".svg")) return src;
1117
+ const segs = [];
1118
+ for (const [k, v] of Object.entries(option)) {
1119
+ const seg = k === "watermark" ? getWatermark(v) : getOSSSegs(k, v);
1120
+ if (seg) segs.push(seg);
1121
+ }
1122
+ if (!segs.length) return src;
1123
+ const base = src.split("?")[0];
1124
+ return `${base}?x-oss-process=${type}/${segs.join("/")}`;
1125
+ }
1126
+ function getOSSSegs(type, option) {
1127
+ if (!option && option !== 0) return "";
1128
+ if (option === true) return type;
1129
+ if (typeof option === "number" || typeof option === "string") return `${type},${option}`;
1130
+ const segs = Object.entries(option).map(([k, v]) => `${k}_${v}`).join(",");
1131
+ return segs ? `${type},${segs}` : "";
1132
+ }
1133
+ function getWatermark(w) {
1134
+ if (!w) return "";
1135
+ if (w.image) w.image = toBase64Url(w.image);
1136
+ if (w.text) w.text = toBase64Url(w.text);
1137
+ if (w.type) w.type = toBase64Url(w.type);
1138
+ return getOSSSegs("watermark", w);
1139
+ }
1140
+ function toBase64Url(s) {
1141
+ let b64 = "";
1142
+ if (typeof Buffer !== "undefined") {
1143
+ const buf = Buffer.from(s, "utf-8");
1144
+ b64 = buf.toString("base64");
1145
+ } else {
1146
+ try {
1147
+ b64 = btoa(unescape(encodeURIComponent(s)));
1148
+ } catch (e) {
1149
+ b64 = "";
1150
+ }
1151
+ }
1152
+ return b64.replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1153
+ }
780
1154
 
781
1155
  // src/ts/url/param/index.ts
782
1156
  function appendUrlParam(url, param) {
@@ -797,6 +1171,398 @@ function appendUrlParam(url, param) {
797
1171
  return base + (qs ? `?${qs}` : "") + hash;
798
1172
  }
799
1173
 
1174
+ // src/ts/url/qn/index.ts
1175
+ function getQnImg(src, option) {
1176
+ var _a;
1177
+ if (!src || !option) return src;
1178
+ if (src.startsWith("blob:")) return src;
1179
+ if (src.includes(".svg")) return src;
1180
+ const segs = [];
1181
+ if (option.imageslim) segs.push("imageslim");
1182
+ if (option.imageView2) segs.push(getImageView2(option.imageView2));
1183
+ const mogr = getImageMogr2((_a = option.imageMogr2) != null ? _a : option);
1184
+ if (mogr) segs.push(mogr);
1185
+ if (option.watermark) segs.push(getWatermark2(option.watermark));
1186
+ if (option.imageInfo) segs.push("imageInfo");
1187
+ if (!segs.length) return src;
1188
+ const base = src.split("?")[0];
1189
+ return `${base}?${segs.join("|")}`;
1190
+ }
1191
+ function getQnVideo(src, option) {
1192
+ if (!src || !option) return src;
1193
+ if (src.startsWith("blob:")) return src;
1194
+ if (src.includes(".svg")) return src;
1195
+ const segs = [];
1196
+ if (option.avthumb) segs.push(getAvthumb(option.avthumb));
1197
+ if (option.vframe) segs.push(getVframe(option.vframe));
1198
+ if (!segs.length) return src;
1199
+ const base = src.split("?")[0];
1200
+ return `${base}?${segs.join("|")}`;
1201
+ }
1202
+ function getQnAudio(src, option) {
1203
+ if (!src || !option) return src;
1204
+ if (src.startsWith("blob:")) return src;
1205
+ const segs = [];
1206
+ if (option.avthumb) segs.push(getAvthumb(option.avthumb));
1207
+ if (!segs.length) return src;
1208
+ const base = src.split("?")[0];
1209
+ return `${base}?${segs.join("|")}`;
1210
+ }
1211
+ function getQnHls(src, option) {
1212
+ if (!src || !option) return src;
1213
+ if (src.startsWith("blob:")) return src;
1214
+ const seg = getAvcvt(option);
1215
+ if (!seg) return src;
1216
+ const base = src.split("?")[0];
1217
+ return `${base}?${seg}`;
1218
+ }
1219
+ function getImageView2(opt) {
1220
+ if (!opt) return "";
1221
+ const mode = typeof opt.mode === "number" ? opt.mode : 0;
1222
+ const kv = [];
1223
+ for (const [k, v] of Object.entries(opt)) {
1224
+ if (k === "mode") continue;
1225
+ if (typeof v === "boolean") {
1226
+ if (v) kv.push(`${k}/1`);
1227
+ } else if (typeof v === "number" || typeof v === "string") {
1228
+ kv.push(`${k}/${v}`);
1229
+ }
1230
+ }
1231
+ return kv.length ? `imageView2/${mode}/${kv.join("/")}` : `imageView2/${mode}`;
1232
+ }
1233
+ function getImageMogr2(opt) {
1234
+ if (!opt) return "";
1235
+ const parts = [];
1236
+ const tn = opt.thumbnail;
1237
+ if (typeof tn !== "undefined") parts.push(`thumbnail/${tn}`);
1238
+ const cp = opt.crop;
1239
+ if (typeof cp !== "undefined") parts.push(`crop/${cp}`);
1240
+ const rot = opt.rotate;
1241
+ if (typeof rot === "number") parts.push(`rotate/${rot}`);
1242
+ const ao = opt["auto-orient"];
1243
+ if (ao) parts.push("auto-orient");
1244
+ const fmt = opt.format;
1245
+ if (typeof fmt === "string") parts.push(`format/${fmt}`);
1246
+ const il = opt.interlace;
1247
+ if (il === 0 || il === 1) parts.push(`interlace/${il}`);
1248
+ const bg = opt.background;
1249
+ if (typeof bg === "string") parts.push(`background/${bg}`);
1250
+ const q = opt.q;
1251
+ if (typeof q === "number") parts.push(`q/${q}`);
1252
+ const blur = opt.blur;
1253
+ if (typeof blur !== "undefined") {
1254
+ if (typeof blur === "string") parts.push(`blur/${blur}`);
1255
+ else parts.push(`blur/${blur.r}x${blur.s}`);
1256
+ }
1257
+ const colors = opt.colors;
1258
+ if (typeof colors === "number") parts.push(`colors/${colors}`);
1259
+ return parts.length ? `imageMogr2/${parts.join("/")}` : "";
1260
+ }
1261
+ function getWatermark2(w) {
1262
+ if (!w) return "";
1263
+ const mode = w.type === "image" ? 1 : w.type === "text" ? 2 : typeof w.type === "number" ? w.type : 2;
1264
+ const segs = [`watermark/${mode}`];
1265
+ if (mode === 1 && w.image) segs.push(`image/${toBase64Url2(w.image)}`);
1266
+ if (mode === 2 && w.text) segs.push(`text/${toBase64Url2(w.text)}`);
1267
+ if (w.font) segs.push(`font/${toBase64Url2(w.font)}`);
1268
+ if (typeof w.fontsize === "number") segs.push(`fontsize/${w.fontsize}`);
1269
+ if (w.fill) segs.push(`fill/${toBase64Url2(w.fill)}`);
1270
+ if (w.gravity) segs.push(`gravity/${w.gravity}`);
1271
+ if (typeof w.dx === "number") segs.push(`dx/${w.dx}`);
1272
+ if (typeof w.dy === "number") segs.push(`dy/${w.dy}`);
1273
+ if (typeof w.dissolve === "number") segs.push(`dissolve/${w.dissolve}`);
1274
+ return segs.join("/");
1275
+ }
1276
+ function toBase64Url2(s) {
1277
+ let b64 = "";
1278
+ if (typeof Buffer !== "undefined") {
1279
+ const buf = Buffer.from(s, "utf-8");
1280
+ b64 = buf.toString("base64");
1281
+ } else {
1282
+ try {
1283
+ b64 = btoa(unescape(encodeURIComponent(s)));
1284
+ } catch (e) {
1285
+ b64 = "";
1286
+ }
1287
+ }
1288
+ return b64.replace(/=+$/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1289
+ }
1290
+ function getAvthumb(opt) {
1291
+ const parts = [];
1292
+ if (opt.format) parts.push(`avthumb/${opt.format}`);
1293
+ else parts.push("avthumb");
1294
+ if (opt.s) parts.push(`s/${opt.s}`);
1295
+ if (opt.vcodec) parts.push(`vcodec/${opt.vcodec}`);
1296
+ if (typeof opt.vb !== "undefined") parts.push(`vb/${opt.vb}`);
1297
+ if (typeof opt.r === "number") parts.push(`r/${opt.r}`);
1298
+ if (typeof opt.ab !== "undefined") parts.push(`ab/${opt.ab}`);
1299
+ if (typeof opt.ar === "number") parts.push(`ar/${opt.ar}`);
1300
+ if (opt.acodec) parts.push(`acodec/${opt.acodec}`);
1301
+ return parts.join("/");
1302
+ }
1303
+ function getVframe(opt) {
1304
+ const parts = [];
1305
+ parts.push(`vframe/${opt.format || "jpg"}`);
1306
+ if (typeof opt.offset === "number") parts.push(`offset/${opt.offset}`);
1307
+ if (typeof opt.w === "number") parts.push(`w/${opt.w}`);
1308
+ if (typeof opt.h === "number") parts.push(`h/${opt.h}`);
1309
+ return parts.join("/");
1310
+ }
1311
+ function getAvcvt(opt) {
1312
+ const parts = [];
1313
+ const level = typeof opt.level === "number" ? `/${opt.level}` : "/3";
1314
+ parts.push(`avcvt${level}`);
1315
+ parts.push(`format/${opt.format || "m3u8"}`);
1316
+ if (typeof opt.segtime === "number") parts.push(`segtime/${opt.segtime}`);
1317
+ if (typeof opt.t === "string") parts.push(`t/${opt.t}`);
1318
+ if (opt.vcodec) parts.push(`vcodec/${opt.vcodec}`);
1319
+ if (typeof opt.vb !== "undefined") parts.push(`vb/${opt.vb}`);
1320
+ if (typeof opt.r === "number") parts.push(`r/${opt.r}`);
1321
+ if (typeof opt.s === "string") parts.push(`s/${opt.s}`);
1322
+ if (opt.acodec) parts.push(`acodec/${opt.acodec}`);
1323
+ if (typeof opt.ab !== "undefined") parts.push(`ab/${opt.ab}`);
1324
+ if (typeof opt.ar === "number") parts.push(`ar/${opt.ar}`);
1325
+ if (typeof opt.output === "string") parts.push(`output/${toBase64Url2(opt.output)}`);
1326
+ return parts.join("/");
1327
+ }
1328
+
1329
+ // src/ts/validator/index.ts
1330
+ function isLetter(s) {
1331
+ return /^[a-zA-Z]*$/.test(s);
1332
+ }
1333
+ function isChinese(s) {
1334
+ const v = String(s != null ? s : "").trim();
1335
+ return /^[\u4E00-\u9FA5]+$/.test(v);
1336
+ }
1337
+ function isDigits(s) {
1338
+ return /^[0-9]+$/.test(s);
1339
+ }
1340
+ function isNumeric(value, options) {
1341
+ const { negative = false, decimal = 2, thousands = false, leadZero = false } = options || {};
1342
+ if (value === null || value === void 0 || value === "") return false;
1343
+ const str = String(value).trim();
1344
+ const sign = negative && str.startsWith("-") ? "-" : "";
1345
+ const body = sign ? str.slice(1) : str;
1346
+ const thousandsPart = thousands ? "(?:[1-9]\\d{0,2}(,\\d{3})*|0)" : "(?:\\d+)";
1347
+ const intPart = thousands ? thousandsPart : leadZero ? "(?:\\d+)" : "(?:0|[1-9]\\d*)";
1348
+ const fracPart = decimal === 0 ? "" : `(\\.\\d{1,${decimal}})`;
1349
+ const pattern = `^${intPart}${fracPart}$`;
1350
+ const reg = new RegExp(pattern);
1351
+ return reg.test(body);
1352
+ }
1353
+ function isMobilePhone(s) {
1354
+ const v = String(s != null ? s : "").trim();
1355
+ return /^1[3-9]\d{9}$/.test(v);
1356
+ }
1357
+ function isLandline(s) {
1358
+ const v = String(s != null ? s : "").trim();
1359
+ return /^0\d{2,3}-?\d{7,8}(?:-\d{1,6})?$/.test(v);
1360
+ }
1361
+ function isPhone(s) {
1362
+ return isMobilePhone(s) || isLandline(s);
1363
+ }
1364
+ function isEmail(s) {
1365
+ const v = String(s != null ? s : "").trim();
1366
+ if (v === "") return false;
1367
+ const emailRegex = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?(?:\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)+$/;
1368
+ return emailRegex.test(v);
1369
+ }
1370
+ function isChineseName(s) {
1371
+ const v = String(s != null ? s : "").trim();
1372
+ return /^[\u4E00-\u9FA5·]{2,20}$/.test(v);
1373
+ }
1374
+ function isIdentityCard(code) {
1375
+ const v = String(code != null ? code : "").trim();
1376
+ if (v === "") return false;
1377
+ const isValidDate = (yyyymmdd) => {
1378
+ const y = Number(yyyymmdd.slice(0, 4));
1379
+ const m = Number(yyyymmdd.slice(4, 6));
1380
+ const d = Number(yyyymmdd.slice(6, 8));
1381
+ if (y < 1900 || y > 2100) return false;
1382
+ const date = new Date(y, m - 1, d);
1383
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
1384
+ };
1385
+ if (/^\d{17}[\dXx]$/.test(v)) {
1386
+ const birth = v.slice(6, 14);
1387
+ if (!isValidDate(birth)) return false;
1388
+ const weights = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];
1389
+ const checkMap = ["1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"];
1390
+ let sum = 0;
1391
+ for (let i = 0; i < 17; i++) sum += Number(v[i]) * weights[i];
1392
+ const mod = sum % 11;
1393
+ const code18 = v[17].toUpperCase();
1394
+ return checkMap[mod] === code18;
1395
+ }
1396
+ if (/^\d{15}$/.test(v)) {
1397
+ const birth = v.slice(6, 12);
1398
+ const y = Number(`19${birth.slice(0, 2)}`);
1399
+ const m = Number(birth.slice(2, 4));
1400
+ const d = Number(birth.slice(4, 6));
1401
+ const date = new Date(y, m - 1, d);
1402
+ return date.getFullYear() === y && date.getMonth() === m - 1 && date.getDate() === d;
1403
+ }
1404
+ if (/^[A-Za-z][12]\d{8}$/.test(v)) return true;
1405
+ if (/^[A-Za-z]{1,2}\d{6}\(?[0-9A]\)?$/.test(v)) return true;
1406
+ if (/^[157]\d{6}\(?\d\)?$/.test(v)) return true;
1407
+ return false;
1408
+ }
1409
+ function isPassport(s) {
1410
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim();
1411
+ if (t === "") return false;
1412
+ if (/^[EG]\d{8}$/.test(t)) return true;
1413
+ if (/^[DPS]\d{7}$/.test(t)) return true;
1414
+ if (/^[A-Za-z]\d{8}$/.test(t)) return true;
1415
+ if (/^[A-Za-z0-9]{6,9}$/.test(t)) return true;
1416
+ return false;
1417
+ }
1418
+ function isHKMOPermit(s) {
1419
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1420
+ return /^[HM]\d{8,10}$/.test(t);
1421
+ }
1422
+ function isTaiwanPermit(s) {
1423
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1424
+ if (/^\d{8}$/.test(t)) return true;
1425
+ if (/^[A-Z]\d{8}$/.test(t)) return true;
1426
+ if (/^\d{10}$/.test(t)) return true;
1427
+ return false;
1428
+ }
1429
+ function isOfficerId(s) {
1430
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1431
+ return /^[A-Z0-9]{7,18}$/.test(t);
1432
+ }
1433
+ function isSoldierId(s) {
1434
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim().toUpperCase();
1435
+ return /^[A-Z0-9]{7,18}$/.test(t);
1436
+ }
1437
+ function isMilitaryId(s) {
1438
+ return isOfficerId(s) || isSoldierId(s);
1439
+ }
1440
+ function isBankCard(s) {
1441
+ const t = String(s != null ? s : "").replace(/[-\s]/g, "").trim();
1442
+ if (!/^\d{12,19}$/.test(t)) return false;
1443
+ let sum = 0;
1444
+ let shouldDouble = false;
1445
+ for (let i = t.length - 1; i >= 0; i--) {
1446
+ let digit = Number(t[i]);
1447
+ if (shouldDouble) {
1448
+ digit *= 2;
1449
+ if (digit > 9) digit -= 9;
1450
+ }
1451
+ sum += digit;
1452
+ shouldDouble = !shouldDouble;
1453
+ }
1454
+ return sum % 10 === 0;
1455
+ }
1456
+ function isLicensePlate(s) {
1457
+ const v = String(s != null ? s : "").trim().toUpperCase();
1458
+ const prov = "\u4EAC\u6CAA\u6D25\u6E1D\u5180\u8C6B\u4E91\u8FBD\u9ED1\u6E58\u7696\u9C81\u65B0\u82CF\u6D59\u8D63\u9102\u6842\u7518\u664B\u8499\u9655\u5409\u95FD\u8D35\u9752\u85CF\u5DDD\u5B81\u743C\u7CA4";
1459
+ const std = new RegExp(`^[${prov}][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9\u6302\u5B66\u8B66\u6E2F\u6FB3]$`);
1460
+ const ne1 = new RegExp(`^[${prov}][A-HJ-NP-Z][DF][A-HJ-NP-Z0-9]{5}$`);
1461
+ const ne2 = new RegExp(`^[${prov}][A-HJ-NP-Z][A-HJ-NP-Z0-9]{5}[DF]$`);
1462
+ return std.test(v) || ne1.test(v) || ne2.test(v);
1463
+ }
1464
+ function isTaxID(code) {
1465
+ const v = String(code != null ? code : "").trim();
1466
+ if (!/^[0-9A-HJ-NPQRTUWXY]{18}$/.test(v)) return false;
1467
+ const charset = "0123456789ABCDEFGHJKLMNPQRTUWXY";
1468
+ const weights = [1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28];
1469
+ const map = {};
1470
+ for (let i = 0; i < charset.length; i++) map[charset[i]] = i;
1471
+ let sum = 0;
1472
+ for (let i = 0; i < 17; i++) {
1473
+ sum += map[v[i]] * weights[i];
1474
+ }
1475
+ const logicCheck = (31 - sum % 31) % 31;
1476
+ const expected = charset[logicCheck];
1477
+ return v[17] === expected;
1478
+ }
1479
+ function isHexColor(s) {
1480
+ const v = String(s != null ? s : "").trim();
1481
+ return /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(v);
1482
+ }
1483
+ function isURL(s) {
1484
+ const v = String(s != null ? s : "").trim();
1485
+ if (v === "") return false;
1486
+ try {
1487
+ const u = new URL(v);
1488
+ return ["http:", "https:", "ftp:"].includes(u.protocol) && !!u.hostname;
1489
+ } catch (e) {
1490
+ return false;
1491
+ }
1492
+ }
1493
+ function isIPv4(s) {
1494
+ const v = String(s != null ? s : "").trim();
1495
+ if (v === "") return false;
1496
+ const parts = v.split(".");
1497
+ if (parts.length !== 4) return false;
1498
+ for (const p of parts) {
1499
+ if (!/^\d+$/.test(p)) return false;
1500
+ if (p.length > 1 && p.startsWith("0")) return false;
1501
+ const n = Number(p);
1502
+ if (n < 0 || n > 255) return false;
1503
+ }
1504
+ return true;
1505
+ }
1506
+ function isIPv6(s) {
1507
+ const v = String(s != null ? s : "").trim();
1508
+ if (v === "") return false;
1509
+ const lastColon = v.lastIndexOf(":");
1510
+ if (lastColon !== -1 && v.includes(".")) {
1511
+ const ipv6Part = v.slice(0, lastColon);
1512
+ const ipv4Part = v.slice(lastColon + 1);
1513
+ return isIPv6(ipv6Part) && isIPv4(ipv4Part);
1514
+ }
1515
+ const dblColonCount = (v.match(/::/g) || []).length;
1516
+ if (dblColonCount > 1) return false;
1517
+ const segments = v.split(":");
1518
+ if (v.startsWith("::")) segments.shift();
1519
+ if (v.endsWith("::")) segments.pop();
1520
+ const segmentsFiltered = segments.filter((seg) => seg !== "");
1521
+ if (dblColonCount === 0 && segmentsFiltered.length !== 8) return false;
1522
+ if (dblColonCount === 1 && segmentsFiltered.length >= 1 && segmentsFiltered.length <= 7) {
1523
+ } else if (dblColonCount === 1 && segments.length === 0) {
1524
+ return true;
1525
+ } else if (dblColonCount === 0 && segmentsFiltered.length === 8) {
1526
+ } else {
1527
+ return false;
1528
+ }
1529
+ return segmentsFiltered.every(
1530
+ (seg) => seg.length >= 1 && seg.length <= 4 && /^[0-9a-fA-F]{1,4}$/.test(seg)
1531
+ );
1532
+ }
1533
+ function isIP(s, version) {
1534
+ if (version === 4 || version === "4") return isIPv4(s);
1535
+ if (version === 6 || version === "6") return isIPv6(s);
1536
+ return isIPv4(s) || isIPv6(s);
1537
+ }
1538
+ function isIPRange(s) {
1539
+ const v = String(s != null ? s : "").trim();
1540
+ if (v === "") return false;
1541
+ const parts = v.split("/");
1542
+ if (parts.length !== 2) return false;
1543
+ const [ip, prefixStr] = parts;
1544
+ if (!/^\d+$/.test(prefixStr)) return false;
1545
+ const prefix = Number(prefixStr);
1546
+ if (ip.includes(":")) {
1547
+ if (!isIPv6(ip)) return false;
1548
+ return prefix >= 0 && prefix <= 128;
1549
+ }
1550
+ if (!isIPv4(ip)) return false;
1551
+ return prefix >= 0 && prefix <= 32;
1552
+ }
1553
+ function isPortNumber(s) {
1554
+ const v = typeof s === "number" ? s : Number(String(s != null ? s : "").trim());
1555
+ return Number.isInteger(v) && v >= 0 && v <= 65535;
1556
+ }
1557
+ function isLatitude(s) {
1558
+ const v = typeof s === "number" ? s : Number(String(s != null ? s : "").trim());
1559
+ return Number.isFinite(v) && v >= -90 && v <= 90;
1560
+ }
1561
+ function isLongitude(s) {
1562
+ const v = typeof s === "number" ? s : Number(String(s != null ? s : "").trim());
1563
+ return Number.isFinite(v) && v >= -180 && v <= 180;
1564
+ }
1565
+
800
1566
  // src/web/network/request.ts
801
1567
  var requestCache = /* @__PURE__ */ new Map();
802
1568
  function request(config) {
@@ -817,7 +1583,7 @@ function request(config) {
817
1583
  cacheTime,
818
1584
  resMap,
819
1585
  responseType = "json",
820
- timeout: timeout2 = 6e4,
1586
+ timeout = 6e4,
821
1587
  onTaskReady
822
1588
  } = config;
823
1589
  const controller = new AbortController();
@@ -837,7 +1603,7 @@ function request(config) {
837
1603
  const execute = () => __async(null, null, function* () {
838
1604
  var _a, _b, _c, _d, _e, _f, _g, _h;
839
1605
  const isGet = method === "GET";
840
- const isObjectData = isPlainObject(data);
1606
+ const isObjectData = (0, ts_exports.isPlainObject)(data);
841
1607
  const isArrayData = !isObjectData && Array.isArray(data);
842
1608
  const fillData = isObjectData ? filterRequestData(data) : data;
843
1609
  const fillHeader = filterRequestHeader(header);
@@ -887,7 +1653,7 @@ function request(config) {
887
1653
  const timeoutId = setTimeout(() => {
888
1654
  isTimeout = true;
889
1655
  controller.abort();
890
- }, timeout2);
1656
+ }, timeout);
891
1657
  try {
892
1658
  const response = yield fetch(fillUrl, {
893
1659
  method,
@@ -982,7 +1748,7 @@ function logRequestInfo(options) {
982
1748
  duration: endTime - startTime
983
1749
  }, logExtra);
984
1750
  if (status === "success") {
985
- info.res = cloneDeep(res);
1751
+ info.res = (0, ts_exports.cloneDeep)(res);
986
1752
  log("info", info);
987
1753
  } else {
988
1754
  info.e = e;
@@ -1100,9 +1866,9 @@ function enhanceWebApi(webApi, apiName) {
1100
1866
  const logData = __spreadValues({ name: fname, status: "success", option }, logExtra);
1101
1867
  if (resMap) {
1102
1868
  logData.res = res;
1103
- logData.resMap = cloneDeep(finalRes);
1869
+ logData.resMap = (0, ts_exports.cloneDeep)(finalRes);
1104
1870
  } else {
1105
- logData.res = cloneDeep(res);
1871
+ logData.res = (0, ts_exports.cloneDeep)(res);
1106
1872
  }
1107
1873
  log == null ? void 0 : log("info", logData);
1108
1874
  }
@@ -1130,7 +1896,7 @@ function upload(option, config) {
1130
1896
  return new Promise((resolve, reject) => {
1131
1897
  var _a;
1132
1898
  const xhr = new XMLHttpRequest();
1133
- const { url, file, name = "file", header, formData, timeout: timeout2 = 0 } = option;
1899
+ const { url, file, name = "file", header, formData, timeout = 0 } = option;
1134
1900
  const fail = (error) => reject(error);
1135
1901
  const success = (responseText) => {
1136
1902
  resolve(responseText);
@@ -1168,7 +1934,7 @@ function upload(option, config) {
1168
1934
  if (v !== void 0 && v !== null && v !== "") xhr.setRequestHeader(k, String(v));
1169
1935
  });
1170
1936
  }
1171
- xhr.timeout = timeout2;
1937
+ xhr.timeout = timeout;
1172
1938
  const data = new FormData();
1173
1939
  if (formData) {
1174
1940
  Object.entries(formData).forEach(([k, v]) => {