@tolki/str 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/str.js CHANGED
@@ -1,53 +1,53 @@
1
- import { isArray as x, toLower as M, isString as S, isFunction as Q, isNumber as X, isNull as Y, isUndefined as v } from "@tolki/utils";
2
- import { title as T, upper as D } from "./convertcase/index.js";
3
- import { randomInt as U, randomString as tt } from "./random/index.js";
1
+ import { isArray as x, toLower as M, isString as S, isFunction as X, isNumber as Y, isNull as v, isUndefined as tt } from "@tolki/utils";
2
+ import { title as T, upper as H } from "./convertcase/index.js";
3
+ import { randomInt as U, randomString as nt } from "./random/index.js";
4
4
  import { substr as $ } from "./replacer/index.js";
5
- import { ltrim as j, rtrim as G, trim as nt } from "./trimmer/index.js";
6
- import { createUlidsNormally as et } from "./ulid/index.js";
7
- import { createUuidsNormally as rt } from "./uuid/index.js";
5
+ import { ltrim as j, rtrim as G, trim as et } from "./trimmer/index.js";
6
+ import { createUlidsNormally as rt } from "./ulid/index.js";
7
+ import { createUuidsNormally as st } from "./uuid/index.js";
8
8
  const F = /* @__PURE__ */ new Map(), N = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
9
9
  let R = null;
10
- function H(t, n) {
10
+ function J(t, n) {
11
11
  if (n === "")
12
12
  return t;
13
13
  const e = String(n), r = t.indexOf(e);
14
14
  return r === -1 ? t : t.slice(r + e.length);
15
15
  }
16
- function Et(t, n) {
16
+ function Ct(t, n) {
17
17
  if (n === "")
18
18
  return t;
19
19
  const e = t.lastIndexOf(String(n));
20
20
  return e === -1 ? t : t.slice(e + String(n).length);
21
21
  }
22
- function st(t, n) {
22
+ function ot(t, n) {
23
23
  if (n === "")
24
24
  return t;
25
25
  const e = t.indexOf(String(n));
26
26
  return e === -1 ? t : t.slice(0, e);
27
27
  }
28
- function ot(t, n) {
28
+ function it(t, n) {
29
29
  if (n === "")
30
30
  return t;
31
31
  const e = t.lastIndexOf(String(n));
32
32
  return e === -1 ? t : $(t, 0, e);
33
33
  }
34
- function Ct(t, n, e) {
35
- return n === "" || e === "" ? t : ot(H(t, n), e);
36
- }
37
34
  function Rt(t, n, e) {
38
- return n === "" || e === "" ? t : st(H(t, n), e);
35
+ return n === "" || e === "" ? t : it(J(t, n), e);
36
+ }
37
+ function Ft(t, n, e) {
38
+ return n === "" || e === "" ? t : ot(J(t, n), e);
39
39
  }
40
- function Ft(t) {
40
+ function Nt(t) {
41
41
  if (N.has(t))
42
42
  return N.get(t);
43
- const n = gt(V(t));
43
+ const n = ht(Q(t));
44
44
  return N.set(t, n), n;
45
45
  }
46
- function Nt(t, n) {
46
+ function _t(t, n) {
47
47
  const e = t.length;
48
48
  return (n < 0 ? n < -e : n > e - 1) ? !1 : (n < 0 && (n += e), t.charAt(n));
49
49
  }
50
- function _t(t, n) {
50
+ function zt(t, n) {
51
51
  for (const e of x(n) ? n : [n])
52
52
  if (e !== "" && t.startsWith(e)) {
53
53
  const r = [...t], s = [...e];
@@ -55,7 +55,7 @@ function _t(t, n) {
55
55
  }
56
56
  return t;
57
57
  }
58
- function zt(t, n) {
58
+ function Wt(t, n) {
59
59
  for (const e of x(n) ? n : [n])
60
60
  if (e !== "" && t.endsWith(e)) {
61
61
  const r = [...t], s = [...e];
@@ -63,7 +63,7 @@ function zt(t, n) {
63
63
  }
64
64
  return t;
65
65
  }
66
- function J(t, n, e = !1) {
66
+ function Z(t, n, e = !1) {
67
67
  e && (t = t.toLowerCase());
68
68
  let r;
69
69
  typeof n == "string" ? r = [n] : r = Array.from(n);
@@ -72,28 +72,28 @@ function J(t, n, e = !1) {
72
72
  return !0;
73
73
  return !1;
74
74
  }
75
- function Wt(t, n = "", e = {}) {
76
- const { radius: r = 100, omission: s = "..." } = e, o = String(t ?? ""), i = n ?? "", c = (k) => k.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = new RegExp(`^(.*?)(${c(i)})(.*)$`, "iu").exec(o);
75
+ function Ot(t, n = "", e = {}) {
76
+ const { radius: r = 100, omission: s = "..." } = e, o = String(t ?? ""), i = n ?? "", c = (A) => A.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = new RegExp(`^(.*?)(${c(i)})(.*)$`, "iu").exec(o);
77
77
  if (!l)
78
78
  return null;
79
- const m = String(l[1]), a = String(l[2]), g = String(l[3]), p = j(m), u = Array.from(p).length, y = $(p, Math.max(u - r, 0), r);
80
- let w = j(y);
81
- w !== p && (w = s + w);
82
- const h = G(g), d = $(h, 0, r);
83
- let A = G(d);
84
- return A !== h && (A = A + s), w + a + A;
85
- }
86
- function Ot(t, n, e = !1) {
79
+ const m = String(l[1]), a = String(l[2]), p = String(l[3]), g = j(m), u = Array.from(g).length, w = $(g, Math.max(u - r, 0), r);
80
+ let y = j(w);
81
+ y !== g && (y = s + y);
82
+ const h = G(p), d = $(h, 0, r);
83
+ let k = G(d);
84
+ return k !== h && (k = k + s), y + a + k;
85
+ }
86
+ function Mt(t, n, e = !1) {
87
87
  let r = !1;
88
88
  for (const s of n)
89
- if (r = !0, !J(t, s, e))
89
+ if (r = !0, !Z(t, s, e))
90
90
  return !1;
91
91
  return r;
92
92
  }
93
93
  function Ut(t, n, e = !1) {
94
- return !J(t, n, e);
94
+ return !Z(t, n, e);
95
95
  }
96
- function Mt(t, n = " ") {
96
+ function It(t, n = " ") {
97
97
  return x(n) ? (n.forEach((e) => {
98
98
  t = t.replace(new RegExp(`${e}+`, "g"), e);
99
99
  }), t) : t.replace(new RegExp(`${n}+`, "g"), n);
@@ -107,20 +107,20 @@ function I(t, n) {
107
107
  return !0;
108
108
  return !1;
109
109
  }
110
- function It(t, n) {
110
+ function Pt(t, n) {
111
111
  return !I(t, n);
112
112
  }
113
- function Pt(t, n) {
113
+ function qt(t, n) {
114
114
  const e = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
115
115
  return t.replace(new RegExp(`(?:${e})+$`, "u"), "") + n;
116
116
  }
117
- function qt(t, n, e = null) {
117
+ function Tt(t, n, e = null) {
118
118
  return n + t + (e ?? n);
119
119
  }
120
- function Tt(t, n, e = null) {
120
+ function jt(t, n, e = null) {
121
121
  return P(t, n) && (t = $(t, z(n))), I(t, e ??= n) && (t = $(t, 0, -z(e))), t;
122
122
  }
123
- function jt(t, n, e = !1) {
123
+ function Gt(t, n, e = !1) {
124
124
  n = String(n);
125
125
  let r;
126
126
  typeof t == "string" ? r = [t] : r = Array.from(t);
@@ -134,13 +134,13 @@ function jt(t, n, e = !1) {
134
134
  }
135
135
  return !1;
136
136
  }
137
- function it(t) {
137
+ function ct(t) {
138
138
  for (let n = 0; n < t.length; n++)
139
139
  if (t.charCodeAt(n) > 127)
140
140
  return !1;
141
141
  return !0;
142
142
  }
143
- function Gt(t) {
143
+ function Bt(t) {
144
144
  if (!S(t))
145
145
  return !1;
146
146
  try {
@@ -150,7 +150,7 @@ function Gt(t) {
150
150
  }
151
151
  return !0;
152
152
  }
153
- function Bt(t, n = []) {
153
+ function Dt(t, n = []) {
154
154
  if (!S(t))
155
155
  return !1;
156
156
  const r = (n.length === 0 ? "aaa|aaas|about|acap|acct|acd|acr|adiumxtra|adt|afp|afs|aim|amss|android|appdata|apt|ark|attachment|aw|barion|beshare|bitcoin|bitcoincash|blob|bolo|browserext|calculator|callto|cap|cast|casts|chrome|chrome-extension|cid|coap|coap+tcp|coap+ws|coaps|coaps+tcp|coaps+ws|com-eventbrite-attendee|content|conti|crid|cvs|dab|data|dav|diaspora|dict|did|dis|dlna-playcontainer|dlna-playsingle|dns|dntp|dpp|drm|drop|dtn|dvb|ed2k|elsi|example|facetime|fax|feed|feedready|file|filesystem|finger|first-run-pen-experience|fish|fm|ftp|fuchsia-pkg|geo|gg|git|gizmoproject|go|gopher|graph|gtalk|h323|ham|hcap|hcp|http|https|hxxp|hxxps|hydrazone|iax|icap|icon|im|imap|info|iotdisco|ipn|ipp|ipps|irc|irc6|ircs|iris|iris.beep|iris.lwz|iris.xpc|iris.xpcs|isostore|itms|jabber|jar|jms|keyparc|lastfm|ldap|ldaps|leaptofrogans|lorawan|lvlt|magnet|mailserver|mailto|maps|market|message|mid|mms|modem|mongodb|moz|ms-access|ms-browser-extension|ms-calculator|ms-drive-to|ms-enrollment|ms-excel|ms-eyecontrolspeech|ms-gamebarservices|ms-gamingoverlay|ms-getoffice|ms-help|ms-infopath|ms-inputapp|ms-lockscreencomponent-config|ms-media-stream-id|ms-mixedrealitycapture|ms-mobileplans|ms-officeapp|ms-people|ms-project|ms-powerpoint|ms-publisher|ms-restoretabcompanion|ms-screenclip|ms-screensketch|ms-search|ms-search-repair|ms-secondary-screen-controller|ms-secondary-screen-setup|ms-settings|ms-settings-airplanemode|ms-settings-bluetooth|ms-settings-camera|ms-settings-cellular|ms-settings-cloudstorage|ms-settings-connectabledevices|ms-settings-displays-topology|ms-settings-emailandaccounts|ms-settings-language|ms-settings-location|ms-settings-lock|ms-settings-nfctransactions|ms-settings-notifications|ms-settings-power|ms-settings-privacy|ms-settings-proximity|ms-settings-screenrotation|ms-settings-wifi|ms-settings-workplace|ms-spd|ms-sttoverlay|ms-transit-to|ms-useractivityset|ms-virtualtouchpad|ms-visio|ms-walk-to|ms-whiteboard|ms-whiteboard-cmd|ms-word|msnim|msrp|msrps|mss|mtqp|mumble|mupdate|mvn|news|nfs|ni|nih|nntp|notes|ocf|oid|onenote|onenote-cmd|opaquelocktoken|openpgp4fpr|pack|palm|paparazzi|payto|pkcs11|platform|pop|pres|prospero|proxy|pwid|psyc|pttp|qb|query|redis|rediss|reload|res|resource|rmi|rsync|rtmfp|rtmp|rtsp|rtsps|rtspu|s3|secondlife|service|session|sftp|sgn|shttp|sieve|simpleledger|sip|sips|skype|smb|sms|smtp|snews|snmp|soap.beep|soap.beeps|soldat|spiffe|spotify|ssh|steam|stun|stuns|submit|svn|tag|teamspeak|tel|teliaeid|telnet|tftp|tg|things|thismessage|tip|tn3270|tool|ts3server|turn|turns|tv|udp|unreal|urn|ut2004|v-event|vemmi|ventrilo|videotex|vnc|view-source|wais|webcal|wpid|ws|wss|wtai|wyciwyg|xcon|xcon-userid|xfire|xmlrpc.beep|xmlrpc.beeps|xmpp|xri|ymsgr|z39.50|z39.50r|z39.50s" : n.join("|")).split("|").map((o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
@@ -180,31 +180,31 @@ function Bt(t, n = []) {
180
180
  ].join("");
181
181
  return new RegExp(s, "iu").test(t);
182
182
  }
183
- function Dt(t) {
184
- return mt(t, "-");
183
+ function Ht(t) {
184
+ return gt(t, "-");
185
185
  }
186
186
  function z(t) {
187
187
  return t.length;
188
188
  }
189
- function Ht(t, n = 100, e = "...", r = !1) {
189
+ function Jt(t, n = 100, e = "...", r = !1) {
190
190
  if (t.length <= n)
191
191
  return t;
192
192
  if (!r)
193
193
  return t.slice(0, n).replace(/\s+$/, "") + e;
194
- t = pt(t).replace(/[\n\r]+/g, " ").trim();
194
+ t = mt(t).replace(/[\n\r]+/g, " ").trim();
195
195
  const s = t.slice(0, n).replace(/\s+$/, "");
196
196
  return t.substring(n, n + 1) === " " ? s + e : s.replace(/(.*)\s.*/, "$1") + e;
197
197
  }
198
- function Z(t) {
198
+ function K(t) {
199
199
  return M(t);
200
200
  }
201
- function Jt(t, n = 100, e = "...") {
201
+ function Zt(t, n = 100, e = "...") {
202
202
  if (n <= 0)
203
203
  return t;
204
204
  const r = n, s = new RegExp(`^\\s*(?:\\S+\\s*){1,${r}}`, "u"), o = t.match(s);
205
205
  return !o || z(t) === z(o[0]) ? t : o[0].trimEnd() + e;
206
206
  }
207
- function Zt(t, n, e, r = null) {
207
+ function Kt(t, n, e, r = null) {
208
208
  if (n === "")
209
209
  return t;
210
210
  const s = t.length;
@@ -219,7 +219,7 @@ function Zt(t, n, e, r = null) {
219
219
  const c = t.slice(0, o), f = i.length, l = t.slice(o + f);
220
220
  return c + n.slice(0, 1).repeat(f) + l;
221
221
  }
222
- function Kt(t, n) {
222
+ function Vt(t, n) {
223
223
  let e = "u", r = t;
224
224
  if (t.length >= 2 && t[0] === "/") {
225
225
  let s = -1;
@@ -248,7 +248,7 @@ function Kt(t, n) {
248
248
  return "";
249
249
  }
250
250
  }
251
- function Vt(t, n) {
251
+ function Qt(t, n) {
252
252
  n = String(n);
253
253
  const e = typeof t == "string" ? [t] : Array.from(t);
254
254
  for (const r of e) {
@@ -282,7 +282,7 @@ function Vt(t, n) {
282
282
  }
283
283
  return !1;
284
284
  }
285
- function Qt(t, n) {
285
+ function Xt(t, n) {
286
286
  let e = "u", r = t;
287
287
  if (t.length >= 2 && t[0] === "/") {
288
288
  let o = -1;
@@ -316,24 +316,24 @@ function Qt(t, n) {
316
316
  }
317
317
  return s;
318
318
  }
319
- function Xt(t) {
319
+ function Yt(t) {
320
320
  return x(t) ? t.map((n) => n.replace(/\D/g, "")) : t.replace(/\D/g, "");
321
321
  }
322
- function Yt(t, n, e = " ") {
322
+ function vt(t, n, e = " ") {
323
323
  const r = t.length;
324
324
  if (n <= r || e === "")
325
325
  return t;
326
326
  const s = n - r, o = Math.floor(s / 2), i = s - o;
327
327
  return W(e, o) + t + W(e, i);
328
328
  }
329
- function vt(t, n, e = " ") {
329
+ function tn(t, n, e = " ") {
330
330
  const r = t.length;
331
331
  if (n <= r || e === "")
332
332
  return t;
333
333
  const o = n - r;
334
334
  return W(e, o) + t;
335
335
  }
336
- function tn(t, n, e = " ") {
336
+ function nn(t, n, e = " ") {
337
337
  const r = t.length;
338
338
  if (n <= r || e === "")
339
339
  return t;
@@ -346,7 +346,7 @@ function W(t, n) {
346
346
  const e = Math.ceil(n / t.length);
347
347
  return t.repeat(e).slice(0, n);
348
348
  }
349
- function nn(t = 32, n = !0, e = !0, r = !0, s = !1) {
349
+ function en(t = 32, n = !0, e = !0, r = !0, s = !1) {
350
350
  const l = [
351
351
  n ? [
352
352
  "a",
@@ -432,26 +432,24 @@ function nn(t = 32, n = !0, e = !0, r = !0, s = !1) {
432
432
  ";"
433
433
  ] : null,
434
434
  s ? [" "] : null
435
- ].filter((p) => x(p));
436
- if (l.length === 0 || t <= 0)
437
- return "";
438
- const m = [];
439
- for (const p of l) {
440
- const u = U(0, p.length - 1);
441
- m.push(p[u]);
442
- }
443
- const a = Math.max(0, t - m.length), g = l.flat();
444
- for (let p = 0; p < a; p++) {
445
- const u = U(0, g.length - 1);
446
- m.push(g[u]);
447
- }
448
- for (let p = m.length - 1; p > 0; p--) {
449
- const u = U(0, p), y = m[p];
450
- m[p] = m[u], m[u] = y;
435
+ ].filter((g) => x(g));
436
+ if (l.length === 0)
437
+ throw new Error("At least one character pool must be enabled.");
438
+ const m = l.flat(), a = B(l).slice(0, Math.max(0, t)).map((g) => g[U(0, g.length - 1)]), p = Array.from(
439
+ { length: Math.max(0, t - a.length) },
440
+ () => m[U(0, m.length - 1)]
441
+ );
442
+ return B([...a, ...p]).join("");
443
+ }
444
+ function B(t) {
445
+ const n = [...t];
446
+ for (let e = n.length - 1; e > 0; e--) {
447
+ const r = U(0, e);
448
+ [n[e], n[r]] = [n[r], n[e]];
451
449
  }
452
- return m.join("");
450
+ return n;
453
451
  }
454
- function en(t, n, e = 0) {
452
+ function rn(t, n, e = 0) {
455
453
  if (n === "")
456
454
  return !1;
457
455
  const r = Array.from(t), s = Array.from(n);
@@ -471,29 +469,29 @@ function en(t, n, e = 0) {
471
469
  }
472
470
  return !1;
473
471
  }
474
- function ct(t = 16) {
475
- return (R ?? ((e) => tt(e)))(t);
472
+ function lt(t = 16) {
473
+ return (R ?? ((e) => nt(e)))(t);
476
474
  }
477
- function lt(t) {
475
+ function ft(t) {
478
476
  R = t;
479
477
  }
480
- function rn(t, n) {
478
+ function sn(t, n) {
481
479
  let e = 0;
482
480
  const r = n ?? function(s) {
483
481
  const o = R;
484
482
  R = null;
485
- const i = ct(s);
483
+ const i = lt(s);
486
484
  return R = o, e++, i;
487
485
  };
488
- lt((s) => e < t.length ? String(t[e++]) : r(s));
486
+ ft((s) => e < t.length ? String(t[e++]) : r(s));
489
487
  }
490
- function ft() {
488
+ function at() {
491
489
  R = null;
492
490
  }
493
- function sn(t, n) {
491
+ function on(t, n) {
494
492
  return n <= 0 ? "" : t.repeat(n);
495
493
  }
496
- function on(t, n, e) {
494
+ function cn(t, n, e) {
497
495
  let r;
498
496
  typeof n == "object" && !x(n) ? r = Object.values(n) : r = x(n) ? [...n] : Array.from(n);
499
497
  const s = e.split(t);
@@ -506,7 +504,7 @@ function on(t, n, e) {
506
504
  }
507
505
  return String(o);
508
506
  }
509
- function cn(t, n) {
507
+ function ln(t, n) {
510
508
  try {
511
509
  const e = String(t);
512
510
  if (e.length)
@@ -516,55 +514,55 @@ function cn(t, n) {
516
514
  return n;
517
515
  }
518
516
  }
519
- function ln(t, n, e, r = !0) {
517
+ function fn(t, n, e, r = !0) {
520
518
  if (S(t) && !S(n))
521
519
  throw new TypeError(
522
520
  "The replacement must be a string when the search term is a string."
523
521
  );
524
- const s = S(e) ? e : Array.from(e, (f) => L(f));
522
+ const s = S(e) ? e : Array.from(e, (f) => E(f));
525
523
  if (!r)
526
- return K(
524
+ return V(
527
525
  t,
528
526
  n,
529
527
  s
530
528
  );
531
- const o = S(t) ? [t] : Array.from(t, (f) => L(f)), i = S(n) ? o.map(() => n) : Array.from(n, (f) => L(f)), c = (f) => o.reduce((l, m, a) => m === "" ? l : l.split(m).join(i[a] ?? ""), f);
529
+ const o = S(t) ? [t] : Array.from(t, (f) => E(f)), i = S(n) ? o.map(() => n) : Array.from(n, (f) => E(f)), c = (f) => o.reduce((l, m, a) => m === "" ? l : l.split(m).join(i[a] ?? ""), f);
532
530
  return S(s) ? c(s) : s.map(c);
533
531
  }
534
- function K(t, n, e) {
535
- const r = S(t) ? [t] : Array.from(t, (c) => L(c)), s = S(n) ? r.map(() => n) : Array.from(n, (c) => L(c)), o = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = (c) => r.reduce((f, l, m) => {
532
+ function V(t, n, e) {
533
+ const r = S(t) ? [t] : Array.from(t, (c) => E(c)), s = S(n) ? r.map(() => n) : Array.from(n, (c) => E(c)), o = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = (c) => r.reduce((f, l, m) => {
536
534
  if (l === "")
537
535
  return f;
538
- const a = s[m] ?? "", g = new RegExp(
536
+ const a = s[m] ?? "", p = new RegExp(
539
537
  o(l),
540
- it(l) ? "gi" : "giu"
538
+ ct(l) ? "gi" : "giu"
541
539
  );
542
- return f.replace(g, () => a);
540
+ return f.replace(p, () => a);
543
541
  }, c);
544
542
  return S(e) ? i(e) : e.map(i);
545
543
  }
546
- function L(t) {
547
- return Y(t) || v(t) ? "" : String(t);
544
+ function E(t) {
545
+ return v(t) || tt(t) ? "" : String(t);
548
546
  }
549
- function at(t, n, e) {
547
+ function ut(t, n, e) {
550
548
  if (t = String(t), t === "")
551
549
  return e;
552
550
  const r = e.indexOf(t);
553
551
  return r !== -1 ? e.slice(0, r) + n + e.slice(r + t.length) : e;
554
552
  }
555
- function fn(t, n, e) {
556
- return t = String(t), t === "" ? e : P(e, t) ? at(t, n, e) : e;
553
+ function an(t, n, e) {
554
+ return t = String(t), t === "" ? e : P(e, t) ? ut(t, n, e) : e;
557
555
  }
558
- function ut(t, n, e) {
556
+ function pt(t, n, e) {
559
557
  if (t = String(t), t === "")
560
558
  return e;
561
559
  const r = e.lastIndexOf(t);
562
560
  return r !== -1 ? e.slice(0, r) + n + e.slice(r + t.length) : e;
563
561
  }
564
- function an(t, n, e) {
565
- return t = String(t), t === "" ? e : I(e, t) ? ut(t, n, e) : e;
562
+ function un(t, n, e) {
563
+ return t = String(t), t === "" ? e : I(e, t) ? pt(t, n, e) : e;
566
564
  }
567
- function un(t, n, e, r = -1) {
565
+ function pn(t, n, e, r = -1) {
568
566
  const s = (a) => x(a) ? a : [a], o = s(t);
569
567
  function i(a) {
570
568
  try {
@@ -572,30 +570,30 @@ function un(t, n, e, r = -1) {
572
570
  let u = a.flags;
573
571
  return u.includes("g") || (u += "g"), u.includes("u") || (u += "u"), new RegExp(a.source, u);
574
572
  }
575
- let g = a, p = "gu";
573
+ let p = a, g = "gu";
576
574
  if (a.length >= 2 && a[0] === "/") {
577
575
  let u = -1;
578
- for (let y = a.length - 1; y > 0; y--)
579
- if (a[y] === "/") {
580
- let w = 0;
581
- for (let h = y - 1; h >= 0 && a[h] === "\\"; h--)
582
- w++;
583
- if (w % 2 === 0) {
584
- u = y;
576
+ for (let w = a.length - 1; w > 0; w--)
577
+ if (a[w] === "/") {
578
+ let y = 0;
579
+ for (let h = w - 1; h >= 0 && a[h] === "\\"; h--)
580
+ y++;
581
+ if (y % 2 === 0) {
582
+ u = w;
585
583
  break;
586
584
  }
587
585
  }
588
586
  if (u > 1) {
589
- g = a.slice(1, u);
590
- const y = a.slice(u + 1);
591
- if (y)
592
- for (const w of y)
593
- /[imsuy]/.test(w) && !p.includes(w) && (p += w);
587
+ p = a.slice(1, u);
588
+ const w = a.slice(u + 1);
589
+ if (w)
590
+ for (const y of w)
591
+ /[imsuy]/.test(y) && !g.includes(y) && (g += y);
594
592
  }
595
593
  }
596
594
  return new RegExp(
597
- g,
598
- Array.from(new Set(p.split(""))).join("")
595
+ p,
596
+ Array.from(new Set(g.split(""))).join("")
599
597
  );
600
598
  } catch {
601
599
  return null;
@@ -603,58 +601,58 @@ function un(t, n, e, r = -1) {
603
601
  }
604
602
  const c = [];
605
603
  for (const a of o) {
606
- const g = i(a);
607
- if (!g) return null;
608
- c.push(g);
604
+ const p = i(a);
605
+ if (!p) return null;
606
+ c.push(p);
609
607
  }
610
- const f = Q(n), l = f ? [] : s(n), m = (a) => {
611
- let g = a;
612
- for (let p = 0; p < c.length; p++) {
613
- const u = c[p];
608
+ const f = X(n), l = f ? [] : s(n), m = (a) => {
609
+ let p = a;
610
+ for (let g = 0; g < c.length; g++) {
611
+ const u = c[g];
614
612
  if (f) {
615
- let y = 0;
616
- const w = n;
617
- g = g.replace(
613
+ let w = 0;
614
+ const y = n;
615
+ p = p.replace(
618
616
  u,
619
617
  (h, ...d) => {
620
- if (r >= 0 && y >= r) return h;
621
- y++;
622
- const E = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, k = [];
623
- for (let b = 0; b < E; b++)
624
- k.push(d[b]);
625
- const C = [h, ...k];
626
- return w(C);
618
+ if (r >= 0 && w >= r) return h;
619
+ w++;
620
+ const L = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, A = [];
621
+ for (let b = 0; b < L; b++)
622
+ A.push(d[b]);
623
+ const C = [h, ...A];
624
+ return y(C);
627
625
  }
628
626
  );
629
627
  } else {
630
- const y = l[p] ?? (l.length === 1 ? l[0] : "");
628
+ const w = l[g] ?? (l.length === 1 ? l[0] : "");
631
629
  if (r < 0)
632
- g = g.replace(u, (w, ...h) => {
633
- const A = h.length > 0 && h[h.length - 1] !== null && typeof h[h.length - 1] == "object" ? h.length - 3 : h.length - 2, E = h.slice(0, A).map((k) => String(k));
634
- return y.replace(/\$(\d{1,2})/g, (k, C) => {
630
+ p = p.replace(u, (y, ...h) => {
631
+ const k = h.length > 0 && h[h.length - 1] !== null && typeof h[h.length - 1] == "object" ? h.length - 3 : h.length - 2, L = h.slice(0, k).map((A) => String(A));
632
+ return w.replace(/\$(\d{1,2})/g, (A, C) => {
635
633
  const b = parseInt(C, 10);
636
- return (E[b - 1] ?? "").toUpperCase();
634
+ return (L[b - 1] ?? "").toUpperCase();
637
635
  });
638
636
  });
639
637
  else {
640
- let w = 0;
641
- g = g.replace(u, (h, ...d) => {
642
- if (w >= r) return h;
643
- w++;
644
- const E = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, k = d.slice(0, E).map((C) => String(C));
645
- return y.replace(/\$(\d{1,2})/g, (C, b) => {
638
+ let y = 0;
639
+ p = p.replace(u, (h, ...d) => {
640
+ if (y >= r) return h;
641
+ y++;
642
+ const L = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, A = d.slice(0, L).map((C) => String(C));
643
+ return w.replace(/\$(\d{1,2})/g, (C, b) => {
646
644
  const q = parseInt(b, 10);
647
- return (k[q - 1] ?? "").toUpperCase();
645
+ return (A[q - 1] ?? "").toUpperCase();
648
646
  });
649
647
  });
650
648
  }
651
649
  }
652
650
  }
653
- return g;
651
+ return p;
654
652
  };
655
653
  return x(e) ? e.map(m) : m(e);
656
654
  }
657
- function pt(t) {
655
+ function mt(t) {
658
656
  let n = "", e = !1;
659
657
  for (let r = 0; r < t.length; r++) {
660
658
  const s = t[r];
@@ -662,11 +660,11 @@ function pt(t) {
662
660
  }
663
661
  return n;
664
662
  }
665
- function pn(t, n, e = !0) {
666
- const r = S(n) ? n : Array.from(n, (i) => L(i));
663
+ function mn(t, n, e = !0) {
664
+ const r = S(n) ? n : Array.from(n, (i) => E(i));
667
665
  if (!e)
668
- return K(t, "", r);
669
- const s = S(t) ? [t] : Array.from(t, (i) => L(i)), o = (i) => {
666
+ return V(t, "", r);
667
+ const s = S(t) ? [t] : Array.from(t, (i) => E(i)), o = (i) => {
670
668
  let c = i;
671
669
  for (const f of s)
672
670
  f !== "" && (c = c.split(f).join(""));
@@ -674,25 +672,25 @@ function pn(t, n, e = !0) {
674
672
  };
675
673
  return S(r) ? o(r) : r.map(o);
676
674
  }
677
- function mn(t) {
675
+ function gn(t) {
678
676
  return Array.from(t).reverse().join("");
679
677
  }
680
- function gn(t, n) {
678
+ function hn(t, n) {
681
679
  const e = n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
682
680
  return n + t.replace(new RegExp(`^(?:${e})+`, "u"), "");
683
681
  }
684
- function hn(t) {
682
+ function dn(t) {
685
683
  const n = String(t).trim();
686
684
  if (n === "")
687
685
  return "";
688
686
  let e = n.split(/\s+/u);
689
- return e.length > 1 ? e = e.map((s) => T(s)) : e = ht(e.join("_")).map((s) => T(s)), e.join("_").replace(/[-_ ]+/gu, "_").split("_").filter((s) => s.length > 0).join(" ");
687
+ return e.length > 1 ? e = e.map((s) => T(s)) : e = dt(e.join("_")).map((s) => T(s)), e.join("_").replace(/[-_ ]+/gu, "_").split("_").filter((s) => s.length > 0).join(" ");
690
688
  }
691
- function dn(t, n = !1) {
689
+ function yn(t, n = !1) {
692
690
  const r = t.split(/\s+/u).filter((s) => s.length > 0).map((s) => [...s][0]).join("");
693
- return n ? D(r) : r;
691
+ return n ? H(r) : r;
694
692
  }
695
- function yn(t) {
693
+ function wn(t) {
696
694
  if (t.trim() === "")
697
695
  return t;
698
696
  const n = /* @__PURE__ */ new Set([
@@ -748,21 +746,21 @@ function yn(t) {
748
746
  }
749
747
  return r.join(" ");
750
748
  }
751
- function mt(t, n = "_") {
749
+ function gt(t, n = "_") {
752
750
  const r = `${t}|${n}`;
753
751
  if (F.has(r))
754
752
  return F.get(r);
755
753
  let s = t;
756
- return /^[a-z]+$/.test(t) || (s = dt(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${n}`), s = Z(s)), F.set(r, s), s;
754
+ return /^[a-z]+$/.test(t) || (s = yt(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${n}`), s = K(s)), F.set(r, s), s;
757
755
  }
758
- function wn(t) {
759
- return nt(t).replace(/[\s\u3164\u1160]+/gu, " ");
756
+ function Sn(t) {
757
+ return et(t).replace(/[\s\u3164\u1160]+/gu, " ");
760
758
  }
761
759
  function P(t, n) {
762
760
  if (t == null || n == null)
763
761
  return !1;
764
762
  let e;
765
- S(n) || X(n) ? e = [n] : Symbol.iterator in Object(n) ? e = Array.from(n) : e = [n];
763
+ S(n) || Y(n) ? e = [n] : Symbol.iterator in Object(n) ? e = Array.from(n) : e = [n];
766
764
  const r = String(t);
767
765
  for (const s of e) {
768
766
  if (s == null)
@@ -773,10 +771,10 @@ function P(t, n) {
773
771
  }
774
772
  return !1;
775
773
  }
776
- function Sn(t, n) {
774
+ function xn(t, n) {
777
775
  return !P(t, n);
778
776
  }
779
- function V(t, n = !1) {
777
+ function Q(t, n = !1) {
780
778
  let e = t;
781
779
  n && (e = t.replace(
782
780
  /(^|[-_ \s])([A-Z]+)(?=[-_ \s]|$)/gu,
@@ -792,10 +790,10 @@ function V(t, n = !1) {
792
790
  }, c = o.map(i).join("");
793
791
  return _.set(r, c), c;
794
792
  }
795
- function xn(t, n = !1) {
796
- return V(t, n);
793
+ function $n(t, n = !1) {
794
+ return Q(t, n);
797
795
  }
798
- function $n(t, n) {
796
+ function An(t, n) {
799
797
  if (!t || Object.keys(t).length === 0)
800
798
  return n;
801
799
  const e = Object.keys(t).filter((o) => o !== "");
@@ -808,34 +806,34 @@ function $n(t, n) {
808
806
  function kn(t, n) {
809
807
  return n < 0 ? $(t, n) : $(t, 0, n);
810
808
  }
811
- function gt(t) {
812
- return Z($(t, 0, 1)) + $(t, 1);
809
+ function ht(t) {
810
+ return K($(t, 0, 1)) + $(t, 1);
813
811
  }
814
- function An(t) {
815
- return D($(t, 0, 1)) + $(t, 1);
812
+ function bn(t) {
813
+ return H($(t, 0, 1)) + $(t, 1);
816
814
  }
817
- function ht(t) {
815
+ function dt(t) {
818
816
  return t.split(new RegExp("(?=\\p{Lu})", "u")).filter(Boolean);
819
817
  }
820
- function dt(t, n = ` \r
818
+ function yt(t, n = ` \r
821
819
  \f\v`) {
822
820
  const e = x(n) ? n.join("") : n, r = (c) => c.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), s = e.length ? r(e) : "", o = s.length ? `(?:\\s|[${s}])` : "\\s", i = new RegExp(`(^|${o})(\\p{Ll})`, "gu");
823
821
  return t.replace(i, (c, f, l) => f + l.toUpperCase());
824
822
  }
825
- function bn(t, n = null) {
823
+ function En(t, n = null) {
826
824
  const e = n && n.length > 0 ? n.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&") : "", r = e.length > 0 ? new RegExp(`[\\p{L}\\p{N}${e}]+`, "gu") : /[\p{L}\p{N}]+/gu, s = t.match(r);
827
825
  return s ? s.length : 0;
828
826
  }
829
827
  function O(t) {
830
828
  return t.trim() === "";
831
829
  }
832
- function B(t, n, e) {
830
+ function D(t, n, e) {
833
831
  let r = n;
834
832
  for (; r < e && O(t[r]); )
835
833
  r++;
836
834
  return r;
837
835
  }
838
- function yt(t, n, e) {
836
+ function wt(t, n, e) {
839
837
  let r = e;
840
838
  for (; r > n && O(t[r - 1]); )
841
839
  r--;
@@ -854,12 +852,12 @@ function Ln(t, n = 75, e = `
854
852
  }
855
853
  let l = 0;
856
854
  if (r) {
857
- for (; l < f && (l = B(c, l, f), l !== f); ) {
855
+ for (; l < f && (l = D(c, l, f), l !== f); ) {
858
856
  if (f - l <= n) {
859
857
  o.push(c.slice(l, f).join(""));
860
858
  break;
861
859
  }
862
- const m = yt(
860
+ const m = wt(
863
861
  c,
864
862
  l,
865
863
  l + n
@@ -869,28 +867,28 @@ function Ln(t, n = 75, e = `
869
867
  continue;
870
868
  }
871
869
  for (; f - l > n; ) {
872
- const m = B(c, l, f);
870
+ const m = D(c, l, f);
873
871
  if (m !== l && (l = m, f - l <= n))
874
872
  break;
875
873
  const a = Math.min(f, l + n + 1);
876
- let g = -1;
874
+ let p = -1;
877
875
  for (let u = a - 1; u >= l; u--)
878
876
  if (O(c[u])) {
879
- g = u;
877
+ p = u;
880
878
  break;
881
879
  }
882
- if (g > l) {
883
- o.push(c.slice(l, g).join("")), l = g + 1;
880
+ if (p > l) {
881
+ o.push(c.slice(l, p).join("")), l = p + 1;
884
882
  continue;
885
883
  }
886
- let p = -1;
884
+ let g = -1;
887
885
  for (let u = l; u < f; u++)
888
886
  if (O(c[u])) {
889
- p = u;
887
+ g = u;
890
888
  break;
891
889
  }
892
- if (p >= 0) {
893
- o.push(c.slice(l, p).join("")), l = p + 1;
890
+ if (g >= 0) {
891
+ o.push(c.slice(l, g).join("")), l = g + 1;
894
892
  continue;
895
893
  }
896
894
  o.push(c.slice(l, f).join("")), l = f;
@@ -900,99 +898,99 @@ function Ln(t, n = 75, e = `
900
898
  }
901
899
  return o.join(e);
902
900
  }
903
- function En() {
901
+ function Cn() {
904
902
  return F.size;
905
903
  }
906
- function Cn() {
904
+ function Rn() {
907
905
  return N.size;
908
906
  }
909
- function Rn() {
907
+ function Fn() {
910
908
  return _.size;
911
909
  }
912
- function Fn() {
910
+ function Nn() {
913
911
  F.clear(), N.clear(), _.clear();
914
912
  }
915
- function Nn() {
916
- ft(), et(), rt();
913
+ function _n() {
914
+ at(), rt(), st();
917
915
  }
918
916
  export {
919
- H as after,
920
- Et as afterLast,
921
- yn as apa,
922
- st as before,
923
- ot as beforeLast,
924
- Ct as between,
925
- Rt as betweenFirst,
926
- Ft as camel,
927
- Cn as camelCacheSize,
928
- Nt as charAt,
929
- zt as chopEnd,
930
- _t as chopStart,
931
- J as contains,
932
- Ot as containsAll,
933
- ft as createRandomStringsNormally,
934
- lt as createRandomStringsUsing,
935
- rn as createRandomStringsUsingSequence,
936
- Mt as deduplicate,
917
+ J as after,
918
+ Ct as afterLast,
919
+ wn as apa,
920
+ ot as before,
921
+ it as beforeLast,
922
+ Rt as between,
923
+ Ft as betweenFirst,
924
+ Nt as camel,
925
+ Rn as camelCacheSize,
926
+ _t as charAt,
927
+ Wt as chopEnd,
928
+ zt as chopStart,
929
+ Z as contains,
930
+ Mt as containsAll,
931
+ at as createRandomStringsNormally,
932
+ ft as createRandomStringsUsing,
933
+ sn as createRandomStringsUsingSequence,
934
+ It as deduplicate,
937
935
  Ut as doesntContain,
938
- It as doesntEndWith,
939
- Sn as doesntStartWith,
936
+ Pt as doesntEndWith,
937
+ xn as doesntStartWith,
940
938
  I as endsWith,
941
- Wt as excerpt,
942
- Pt as finish,
943
- Fn as flushCache,
944
- hn as headline,
945
- dn as initials,
946
- jt as is,
947
- it as isAscii,
948
- Gt as isJson,
949
- Vt as isMatch,
950
- Bt as isUrl,
951
- Dt as kebab,
952
- gt as lcfirst,
939
+ Ot as excerpt,
940
+ qt as finish,
941
+ Nn as flushCache,
942
+ dn as headline,
943
+ yn as initials,
944
+ Gt as is,
945
+ ct as isAscii,
946
+ Bt as isJson,
947
+ Qt as isMatch,
948
+ Dt as isUrl,
949
+ Ht as kebab,
950
+ ht as lcfirst,
953
951
  z as length,
954
- Ht as limit,
955
- Z as lower,
952
+ Jt as limit,
953
+ K as lower,
956
954
  W as makePad,
957
- Zt as mask,
958
- Kt as match,
959
- Qt as matchAll,
960
- Xt as numbers,
961
- Yt as padBoth,
962
- vt as padLeft,
963
- tn as padRight,
964
- xn as pascal,
965
- nn as password,
966
- en as position,
967
- ct as random,
968
- pn as remove,
969
- sn as repeat,
970
- ln as replace,
971
- on as replaceArray,
972
- an as replaceEnd,
973
- at as replaceFirst,
974
- ut as replaceLast,
975
- un as replaceMatches,
976
- fn as replaceStart,
977
- Nn as resetFactoryState,
978
- mn as reverse,
979
- mt as snake,
980
- En as snakeCacheSize,
981
- wn as squish,
982
- gn as start,
955
+ Kt as mask,
956
+ Vt as match,
957
+ Xt as matchAll,
958
+ Yt as numbers,
959
+ vt as padBoth,
960
+ tn as padLeft,
961
+ nn as padRight,
962
+ $n as pascal,
963
+ en as password,
964
+ rn as position,
965
+ lt as random,
966
+ mn as remove,
967
+ on as repeat,
968
+ fn as replace,
969
+ cn as replaceArray,
970
+ un as replaceEnd,
971
+ ut as replaceFirst,
972
+ pt as replaceLast,
973
+ pn as replaceMatches,
974
+ an as replaceStart,
975
+ _n as resetFactoryState,
976
+ gn as reverse,
977
+ gt as snake,
978
+ Cn as snakeCacheSize,
979
+ Sn as squish,
980
+ hn as start,
983
981
  P as startsWith,
984
- pt as stripTags,
985
- V as studly,
986
- Rn as studlyCacheSize,
987
- $n as swap,
982
+ mt as stripTags,
983
+ Q as studly,
984
+ Fn as studlyCacheSize,
985
+ An as swap,
988
986
  kn as take,
989
- cn as toStringOr,
990
- An as ucfirst,
991
- ht as ucsplit,
992
- dt as ucwords,
993
- Tt as unwrap,
994
- bn as wordCount,
987
+ ln as toStringOr,
988
+ bn as ucfirst,
989
+ dt as ucsplit,
990
+ yt as ucwords,
991
+ jt as unwrap,
992
+ En as wordCount,
995
993
  Ln as wordWrap,
996
- Jt as words,
997
- qt as wrap
994
+ Zt as words,
995
+ Tt as wrap
998
996
  };