@zinaid/str 0.0.6 → 0.0.8

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 DELETED
@@ -1,993 +0,0 @@
1
- import { substr as x, ltrim as q, rtrim as G, plural as J, randomInt as O, randomString as B, title as j, ascii as H, trim as V, upper as D } from "@zinaid/str";
2
- import { isArray as S, toLower as M, isString as _, isFunction as Q } from "@zinaid/utils";
3
- const R = /* @__PURE__ */ new Map(), E = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map();
4
- let b = null;
5
- function K(t, e) {
6
- if (e === "")
7
- return t;
8
- const n = String(e), r = t.indexOf(n);
9
- return r === -1 ? t : t.slice(r + n.length);
10
- }
11
- function pt(t, e) {
12
- if (e === "")
13
- return t;
14
- const n = t.lastIndexOf(String(e));
15
- return n === -1 ? t : t.slice(n + String(e).length);
16
- }
17
- function X(t, e) {
18
- if (e === "")
19
- return t;
20
- const n = t.indexOf(String(e));
21
- return n === -1 ? t : t.slice(0, n);
22
- }
23
- function Y(t, e) {
24
- if (e === "")
25
- return t;
26
- const n = t.lastIndexOf(String(e));
27
- return n === -1 ? t : x(t, 0, n);
28
- }
29
- function gt(t, e, n) {
30
- return e === "" || n === "" ? t : Y(K(t, e), n);
31
- }
32
- function mt(t, e, n) {
33
- return e === "" || n === "" ? t : X(K(t, e), n);
34
- }
35
- function ht(t) {
36
- if (E.has(t))
37
- return E.get(t);
38
- const e = it(Z(t));
39
- return E.set(t, e), e;
40
- }
41
- function dt(t, e) {
42
- const n = t.length;
43
- return (e < 0 ? e < -n : e > n - 1) ? !1 : (e < 0 && (e += n), t.charAt(e));
44
- }
45
- function yt(t, e) {
46
- for (const n of S(e) ? e : [e])
47
- if (n !== "" && t.startsWith(n)) {
48
- const r = [...t], s = [...n];
49
- return r.slice(s.length).join("");
50
- }
51
- return t;
52
- }
53
- function wt(t, e) {
54
- for (const n of S(e) ? e : [e])
55
- if (n !== "" && t.endsWith(n)) {
56
- const r = [...t], s = [...n];
57
- return r.slice(0, -s.length).join("");
58
- }
59
- return t;
60
- }
61
- function T(t, e, n = !1) {
62
- n && (t = t.toLowerCase());
63
- let r;
64
- typeof e == "string" ? r = [e] : r = Array.from(e);
65
- for (let s of r)
66
- if (n && (s = s.toLowerCase()), s !== "" && t.includes(s))
67
- return !0;
68
- return !1;
69
- }
70
- function xt(t, e = "", n = {}) {
71
- const r = n.radius ?? 100, s = n.omission ?? "...", o = String(t ?? ""), c = e ?? "", i = (w) => w.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`^(.*?)(${i(c)})(.*)$`, "iu").exec(o);
72
- if (!f)
73
- return null;
74
- const m = q(f[1] ?? ""), u = Array.from(m).length, a = x(m, Math.max(u - r, 0), r);
75
- let p = q(a);
76
- p !== m && (p = s + p);
77
- const g = G(f[3] ?? ""), h = x(g, 0, r);
78
- let d = G(h);
79
- d !== g && (d = d + s);
80
- const y = f[2] ?? "";
81
- return p + y + d;
82
- }
83
- function St(t, e, n = !1) {
84
- for (const r of e)
85
- if (!T(t, r, n))
86
- return !1;
87
- return !0;
88
- }
89
- function $t(t, e, n = !1) {
90
- return !T(t, e, n);
91
- }
92
- function At(t, e = " ") {
93
- return S(e) ? (e.forEach((n) => {
94
- t = t.replace(new RegExp(`${n}+`, "g"), n);
95
- }), t) : t.replace(new RegExp(`${e}+`, "g"), e);
96
- }
97
- function W(t, e) {
98
- if (t === null)
99
- return !1;
100
- t = String(t), S(e) ? e = Array.from(e) : e = [String(e)];
101
- for (const n of e)
102
- if (n !== "" && t.endsWith(n))
103
- return !0;
104
- return !1;
105
- }
106
- function kt(t, e) {
107
- return !W(t, e);
108
- }
109
- function bt(t, e) {
110
- const n = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
111
- return t.replace(new RegExp(`(?:${n})+$`, "u"), "") + e;
112
- }
113
- function Lt(t, e, n = null) {
114
- return e + t + (n ?? e);
115
- }
116
- function Rt(t, e, n = null) {
117
- return I(t, e) && (t = x(t, F(e))), W(t, n ??= e) && (t = x(t, 0, -F(n))), t;
118
- }
119
- function Et(t, e, n = !1) {
120
- e = String(e);
121
- let r;
122
- typeof t == "string" ? r = [t] : r = Array.from(t);
123
- for (let s of r) {
124
- if (s = String(s), s === e || n && M(s) === M(e))
125
- return !0;
126
- s = s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), s = s.replace(/\\\*/g, ".*");
127
- const o = n ? "iu" : "u";
128
- if (new RegExp(`^${s}$`, o).test(e))
129
- return !0;
130
- }
131
- return !1;
132
- }
133
- function Ct(t) {
134
- for (let e = 0; e < t.length; e++)
135
- if (t.charCodeAt(e) > 127) return !1;
136
- return !0;
137
- }
138
- function Ft(t) {
139
- if (!_(t))
140
- return !1;
141
- try {
142
- JSON.parse(t);
143
- } catch {
144
- return !1;
145
- }
146
- return !0;
147
- }
148
- function zt(t, e = []) {
149
- if (!_(t))
150
- return !1;
151
- const r = (e.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" : e.join("|")).split("|").map((o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
152
- try {
153
- const c = new URL(t).protocol.replace(":", "");
154
- if (r.split("|").includes(c))
155
- return !0;
156
- } catch {
157
- }
158
- const s = [
159
- "^(",
160
- r,
161
- "):\\/\\/",
162
- "(?:((?:[_.\\p{L}\\p{N}-]|%[0-9A-Fa-f]{2})+:)?((?:[_.\\p{L}\\p{N}-]|%[0-9A-Fa-f]{2})+)@)?",
163
- "(",
164
- "(?:[\\p{L}\\p{N}\\p{S}_\\.-]+(?:\\.?([\\p{L}\\p{N}]|xn--[\\p{L}\\p{N}-]+)+\\.?)",
165
- "|",
166
- "(?:\\d{1,3}\\.){3}\\d{1,3}",
167
- "|",
168
- "\\[(?:[0-9A-Fa-f:.]+)\\]",
169
- ")",
170
- "(?::[0-9]+)?",
171
- '(?:/(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@]|%[0-9A-Fa-f]{2})*)*',
172
- '(?:\\?(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@/?\\[\\]]|%[0-9A-Fa-f]{2})*)?',
173
- '(?:#(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@/?]|%[0-9A-Fa-f]{2})*)?',
174
- "$"
175
- ].join("");
176
- try {
177
- return new RegExp(s, "iu").test(t);
178
- } catch {
179
- return !1;
180
- }
181
- }
182
- function _t(t) {
183
- if (!_(t))
184
- return !1;
185
- const e = t.toUpperCase();
186
- return /^[0-9A-HJKMNP-TV-Z]{26}$/.test(e);
187
- }
188
- function Nt(t) {
189
- return ot(t, "-");
190
- }
191
- function F(t) {
192
- return t.length;
193
- }
194
- function Ot(t, e = 100, n = "...", r = !1) {
195
- if (t.length <= e)
196
- return t;
197
- if (!r)
198
- return t.slice(0, e).replace(/\s+$/, "") + n;
199
- t = st(t).replace(/[\n\r]+/g, " ").trim();
200
- const s = t.slice(0, e).replace(/\s+$/, "");
201
- return t.substring(e, e + 1) === " " ? s + n : s.replace(/(.*)\s.*/, "$1") + n;
202
- }
203
- function U(t) {
204
- return M(t);
205
- }
206
- function Mt(t, e = 100, n = "...") {
207
- if (e <= 0)
208
- return t;
209
- const r = e, s = new RegExp(`^\\s*(?:\\S+\\s*){1,${r}}`, "u"), o = t.match(s);
210
- return !o || F(t) === F(o[0]) ? t : o[0].replace(/\s+$/, "") + n;
211
- }
212
- function Wt(t, e, n, r = null) {
213
- if (e === "")
214
- return t;
215
- const s = t.length;
216
- let o = n;
217
- n < 0 && (o = n < -s ? 0 : s + n);
218
- const c = t.slice(
219
- o,
220
- r !== null ? o + r : void 0
221
- );
222
- if (c === "")
223
- return t;
224
- const i = t.slice(0, o), l = c.length, f = t.slice(o + l);
225
- return i + e.slice(0, 1).repeat(l) + f;
226
- }
227
- function Ut(t, e) {
228
- let n = "u", r = t;
229
- if (t.length >= 2 && t[0] === "/") {
230
- let s = -1;
231
- for (let o = t.length - 1; o > 0; o--)
232
- if (t[o] === "/") {
233
- let c = 0;
234
- for (let i = o - 1; i >= 0 && t[i] === "\\"; i--)
235
- c++;
236
- if (c % 2 === 0) {
237
- s = o;
238
- break;
239
- }
240
- }
241
- if (s > 0) {
242
- r = t.slice(1, s);
243
- const o = t.slice(s + 1);
244
- if (o)
245
- for (const c of o)
246
- /[imsuy]/.test(c) && !n.includes(c) && (n += c);
247
- }
248
- }
249
- try {
250
- const o = new RegExp(r, n).exec(e);
251
- return o ? o[1] !== void 0 ? o[1] : o[0] : "";
252
- } catch {
253
- return "";
254
- }
255
- }
256
- function It(t, e) {
257
- e = String(e);
258
- const n = typeof t == "string" ? [t] : Array.from(t);
259
- for (const r of n) {
260
- if (typeof r != "string" || r === "") continue;
261
- let s = "u", o = r;
262
- if (r.length >= 2 && r[0] === "/") {
263
- let c = -1;
264
- for (let i = r.length - 1; i > 0; i--)
265
- if (r[i] === "/") {
266
- let l = 0;
267
- for (let f = i - 1; f >= 0 && r[f] === "\\"; f--)
268
- l++;
269
- if (l % 2 === 0) {
270
- c = i;
271
- break;
272
- }
273
- }
274
- if (c > 0) {
275
- o = r.slice(1, c);
276
- const i = r.slice(c + 1);
277
- if (i)
278
- for (const l of i)
279
- /[imsuy]/.test(l) && !s.includes(l) && (s += l);
280
- }
281
- }
282
- try {
283
- if (new RegExp(o, s).test(e))
284
- return !0;
285
- } catch {
286
- }
287
- }
288
- return !1;
289
- }
290
- function Pt(t, e) {
291
- let n = "u", r = t;
292
- if (t.length >= 2 && t[0] === "/") {
293
- let o = -1;
294
- for (let c = t.length - 1; c > 0; c--)
295
- if (t[c] === "/") {
296
- let i = 0;
297
- for (let l = c - 1; l >= 0 && t[l] === "\\"; l--)
298
- i++;
299
- if (i % 2 === 0) {
300
- o = c;
301
- break;
302
- }
303
- }
304
- if (o > 0) {
305
- r = t.slice(1, o);
306
- const c = t.slice(o + 1);
307
- if (c)
308
- for (const i of c)
309
- /[imsuy]/.test(i) && !n.includes(i) && (n += i);
310
- }
311
- }
312
- n.includes("g") || (n += "g");
313
- let s = [];
314
- try {
315
- const o = new RegExp(r, n);
316
- let c;
317
- for (; (c = o.exec(e)) !== null; )
318
- s.push(c[1] !== void 0 ? c[1] : c[0]), c[0] === "" && o.lastIndex++;
319
- } catch {
320
- s = [];
321
- }
322
- return s;
323
- }
324
- function qt(t) {
325
- return S(t) ? t.map((e) => e.replace(/[^0-9]/g, "")) : t.replace(/[^0-9]/g, "");
326
- }
327
- function Gt(t, e, n = " ") {
328
- const r = t.length;
329
- if (e <= r || n === "")
330
- return t;
331
- const s = e - r, o = Math.floor(s / 2), c = s - o;
332
- return z(n, o) + t + z(n, c);
333
- }
334
- function jt(t, e, n = " ") {
335
- const r = t.length;
336
- if (e <= r || n === "")
337
- return t;
338
- const o = e - r;
339
- return z(n, o) + t;
340
- }
341
- function Kt(t, e, n = " ") {
342
- const r = t.length;
343
- if (e <= r || n === "")
344
- return t;
345
- const o = e - r;
346
- return t + z(n, o);
347
- }
348
- function z(t, e) {
349
- if (e <= 0) return "";
350
- const n = Math.ceil(e / t.length);
351
- return t.repeat(n).slice(0, e);
352
- }
353
- function v(t, e = 2) {
354
- const n = t.split(/(?=[A-Z])/), r = String(n.pop());
355
- return n.join("") + J(r, e);
356
- }
357
- function Tt(t, e = 2) {
358
- return v(t, e);
359
- }
360
- function Zt(t = 32, e = !0, n = !0, r = !0, s = !1) {
361
- const f = [
362
- e ? [
363
- "a",
364
- "b",
365
- "c",
366
- "d",
367
- "e",
368
- "f",
369
- "g",
370
- "h",
371
- "i",
372
- "j",
373
- "k",
374
- "l",
375
- "m",
376
- "n",
377
- "o",
378
- "p",
379
- "q",
380
- "r",
381
- "s",
382
- "t",
383
- "u",
384
- "v",
385
- "w",
386
- "x",
387
- "y",
388
- "z",
389
- "A",
390
- "B",
391
- "C",
392
- "D",
393
- "E",
394
- "F",
395
- "G",
396
- "H",
397
- "I",
398
- "J",
399
- "K",
400
- "L",
401
- "M",
402
- "N",
403
- "O",
404
- "P",
405
- "Q",
406
- "R",
407
- "S",
408
- "T",
409
- "U",
410
- "V",
411
- "W",
412
- "X",
413
- "Y",
414
- "Z"
415
- ] : null,
416
- n ? ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"] : null,
417
- r ? [
418
- "~",
419
- "!",
420
- "#",
421
- "$",
422
- "%",
423
- "^",
424
- "&",
425
- "*",
426
- "(",
427
- ")",
428
- "-",
429
- "_",
430
- ".",
431
- ",",
432
- "<",
433
- ">",
434
- "?",
435
- "/",
436
- "\\",
437
- "{",
438
- "}",
439
- "[",
440
- "]",
441
- "|",
442
- ":",
443
- ";"
444
- ] : null,
445
- s ? [" "] : null
446
- ].filter((p) => S(p));
447
- if (f.length === 0 || t <= 0)
448
- return "";
449
- const m = [];
450
- for (const p of f) {
451
- const g = O(0, p.length - 1);
452
- m.push(p[g]);
453
- }
454
- const u = Math.max(0, t - m.length), a = f.flat();
455
- for (let p = 0; p < u; p++) {
456
- const g = O(0, a.length - 1);
457
- m.push(a[g]);
458
- }
459
- for (let p = m.length - 1; p > 0; p--) {
460
- const g = O(0, p), h = m[p];
461
- m[p] = m[g], m[g] = h;
462
- }
463
- return m.join("");
464
- }
465
- function Jt(t, e, n = 0) {
466
- if (e === "")
467
- return !1;
468
- const r = Array.from(t), s = Array.from(e);
469
- let o = n >= 0 ? n : r.length + n;
470
- if (o < 0 && (o = 0), o >= r.length)
471
- return !1;
472
- const c = r.length - s.length;
473
- for (let i = o; i <= c; i++) {
474
- let l = !0;
475
- for (let f = 0; f < s.length; f++)
476
- if (r[i + f] !== s[f]) {
477
- l = !1;
478
- break;
479
- }
480
- if (l)
481
- return i;
482
- }
483
- return !1;
484
- }
485
- function tt(t = 16) {
486
- return (b ?? ((n) => B(n)))(t);
487
- }
488
- function et(t) {
489
- b = t;
490
- }
491
- function Bt(t, e) {
492
- let n = 0;
493
- const r = e ?? function(s) {
494
- const o = b;
495
- b = null;
496
- const c = tt(s);
497
- return b = o, n++, c;
498
- };
499
- et((s) => n < t.length ? String(t[n++]) : r(s));
500
- }
501
- function Ht() {
502
- b = null;
503
- }
504
- function Vt(t, e) {
505
- return e <= 0 ? "" : t.repeat(e);
506
- }
507
- function Dt(t, e, n) {
508
- let r;
509
- typeof e == "object" && !S(e) ? r = Object.values(e) : r = S(e) ? [...e] : Array.from(e);
510
- const s = n.split(t);
511
- if (s.length === 1)
512
- return n;
513
- let o = s[0];
514
- for (let c = 1; c < s.length; c++) {
515
- const i = r.length ? r.shift() : t;
516
- o += i + s[c];
517
- }
518
- return String(o);
519
- }
520
- function Qt(t, e) {
521
- try {
522
- const n = String(t);
523
- if (n.length)
524
- return n;
525
- throw new Error("Failed to convert value to string");
526
- } catch {
527
- return e;
528
- }
529
- }
530
- function Xt(t, e, n, r = !0) {
531
- const s = (f) => typeof f == "string" ? [f] : Array.from(f), o = s(t), c = s(e), i = (f) => f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = (f) => o.reduce((m, u, a) => {
532
- if (u === "") return m;
533
- const p = c[a] ?? "";
534
- if (!r)
535
- return m.split(u).join(p);
536
- const g = new RegExp(i(u), "gi");
537
- return m.replace(g, () => p);
538
- }, f);
539
- return _(n) ? l(n) : Array.from(n).map(l);
540
- }
541
- function nt(t, e, n) {
542
- if (t = String(t), t === "")
543
- return n;
544
- const r = n.indexOf(t);
545
- return r !== -1 ? n.slice(0, r) + e + n.slice(r + t.length) : n;
546
- }
547
- function Yt(t, e, n) {
548
- return t = String(t), t === "" ? n : I(n, t) ? nt(t, e, n) : n;
549
- }
550
- function rt(t, e, n) {
551
- if (t = String(t), t === "")
552
- return n;
553
- const r = n.lastIndexOf(t);
554
- return r !== -1 ? n.slice(0, r) + e + n.slice(r + t.length) : n;
555
- }
556
- function vt(t, e, n) {
557
- return t = String(t), t === "" ? n : W(n, t) ? rt(t, e, n) : n;
558
- }
559
- function te(t, e, n, r = -1) {
560
- const s = (u) => S(u) ? u : [u], o = s(t);
561
- function c(u) {
562
- try {
563
- if (u instanceof RegExp) {
564
- let g = u.flags;
565
- return g.includes("g") || (g += "g"), g.includes("u") || (g += "u"), new RegExp(u.source, g);
566
- }
567
- let a = u, p = "gu";
568
- if (u.length >= 2 && u[0] === "/") {
569
- let g = -1;
570
- for (let h = u.length - 1; h > 0; h--)
571
- if (u[h] === "/") {
572
- let d = 0;
573
- for (let y = h - 1; y >= 0 && u[y] === "\\"; y--)
574
- d++;
575
- if (d % 2 === 0) {
576
- g = h;
577
- break;
578
- }
579
- }
580
- if (g > 1) {
581
- a = u.slice(1, g);
582
- const h = u.slice(g + 1);
583
- if (h)
584
- for (const d of h)
585
- /[imsuy]/.test(d) && !p.includes(d) && (p += d);
586
- p.includes("g") || (p += "g"), p.includes("u") || (p += "u");
587
- }
588
- }
589
- return new RegExp(
590
- a,
591
- Array.from(new Set(p.split(""))).join("")
592
- );
593
- } catch {
594
- return null;
595
- }
596
- }
597
- const i = [];
598
- for (const u of o) {
599
- const a = c(u);
600
- if (!a) return null;
601
- i.push(a);
602
- }
603
- const l = Q(e), f = l ? [] : s(e), m = (u) => {
604
- let a = u;
605
- for (let p = 0; p < i.length; p++) {
606
- const g = i[p];
607
- if (l) {
608
- let h = 0;
609
- const d = e;
610
- a = a.replace(
611
- g,
612
- (y, ...w) => {
613
- if (r >= 0 && h >= r) return y;
614
- h++;
615
- const L = typeof w[w.length - 1] == "object" && typeof w[w.length - 2] == "number" ? w.length - 3 : w.length - 2, $ = [];
616
- for (let A = 0; A < L; A++)
617
- $.push(w[A]);
618
- const k = [y, ...$];
619
- return d(k);
620
- }
621
- );
622
- } else {
623
- const h = f[p] ?? (f.length === 1 ? f[0] : "");
624
- if (r < 0)
625
- a = a.replace(g, (d, ...y) => {
626
- const N = typeof y[y.length - 1] == "object" && typeof y[y.length - 2] == "number" ? y.length - 3 : y.length - 2, L = y.slice(0, N).map(($) => String($));
627
- return h.replace(/\$(\d{1,2})/g, ($, k) => {
628
- const A = parseInt(k, 10);
629
- return (L[A - 1] ?? "").toUpperCase();
630
- });
631
- });
632
- else {
633
- let d = 0;
634
- a = a.replace(g, (y, ...w) => {
635
- if (d >= r) return y;
636
- d++;
637
- const L = typeof w[w.length - 1] == "object" && typeof w[w.length - 2] == "number" ? w.length - 3 : w.length - 2, $ = w.slice(0, L).map((k) => String(k));
638
- return h.replace(/\$(\d{1,2})/g, (k, A) => {
639
- const P = parseInt(A, 10);
640
- return ($[P - 1] ?? "").toUpperCase();
641
- });
642
- });
643
- }
644
- }
645
- }
646
- return a;
647
- };
648
- return S(n) ? n.map(m) : m(n);
649
- }
650
- function st(t) {
651
- return t.replace(/<\/?[^>]+(>|$)/g, "");
652
- }
653
- function ee(t, e, n = !0) {
654
- const r = typeof t == "string" ? [t] : Array.from(t), s = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = (c) => {
655
- let i = c;
656
- for (const l of r)
657
- if (l !== "")
658
- if (n)
659
- i = i.split(l).join("");
660
- else {
661
- const f = new RegExp(s(l), "gi");
662
- i = i.replace(f, "");
663
- }
664
- return i;
665
- };
666
- return typeof e == "string" ? o(e) : Array.from(e, (c) => o(String(c)));
667
- }
668
- function ne(t) {
669
- return Array.from(t).reverse().join("");
670
- }
671
- function re(t, e) {
672
- const n = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
673
- return e + t.replace(new RegExp(`^(?:${n})+`, "u"), "");
674
- }
675
- function se(t) {
676
- const e = String(t).trim();
677
- if (e === "")
678
- return "";
679
- let n = e.split(/\s+/u);
680
- return n.length > 1 ? n = n.map((s) => j(s)) : n = ct(n.join("_")).map((s) => j(s)), n.join("_").replace(/[-_ ]+/gu, "_").split("_").filter((s) => s.length > 0).join(" ");
681
- }
682
- function oe(t) {
683
- if (t.trim() === "")
684
- return t;
685
- const e = /* @__PURE__ */ new Set([
686
- "and",
687
- "as",
688
- "but",
689
- "for",
690
- "if",
691
- "nor",
692
- "or",
693
- "so",
694
- "yet",
695
- "a",
696
- "an",
697
- "the",
698
- "at",
699
- "by",
700
- "for",
701
- "in",
702
- "of",
703
- "off",
704
- "on",
705
- "per",
706
- "to",
707
- "up",
708
- "via",
709
- "et",
710
- "ou",
711
- "un",
712
- "une",
713
- "la",
714
- "le",
715
- "les",
716
- "de",
717
- "du",
718
- "des",
719
- "par",
720
- "à"
721
- ]), n = /* @__PURE__ */ new Set([".", "!", "?", ":", "—", ","]), r = t.split(/\s+/u), s = (o) => {
722
- if (!o) return o;
723
- const c = Array.from(o), i = c[0].toLocaleUpperCase(), l = c.slice(1).join("");
724
- return i + l;
725
- };
726
- for (let o = 0; o < r.length; o++) {
727
- const c = r[o].toLocaleLowerCase();
728
- if (c.includes("-")) {
729
- const l = c.split("-").map((f) => e.has(f) && f.length <= 3 ? f : s(f));
730
- r[o] = l.join("-");
731
- } else {
732
- const i = o > 0 ? r[o - 1] : "", l = i ? Array.from(i).slice(-1)[0] : void 0, f = o === 0 || l !== void 0 && n.has(l);
733
- e.has(c) && c.length <= 3 && !f ? r[o] = c : r[o] = s(c);
734
- }
735
- }
736
- return r.join(" ");
737
- }
738
- function ie(t, e = "-", n = { "@": "at" }) {
739
- const r = e, s = (u) => u.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), o = (u) => u.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), c = (u) => {
740
- let a = u;
741
- const p = r === "-" ? "_" : "-";
742
- {
743
- const g = new RegExp(`[${s(p)}]+`, "gu");
744
- a = a.replace(g, r);
745
- }
746
- if (n && typeof n == "object") {
747
- const g = {};
748
- for (const [h, d] of Object.entries(n))
749
- g[h] = (r ?? "") + d + (r ?? "");
750
- for (const [h, d] of Object.entries(g))
751
- h !== "" && (a = a.split(h).join(d));
752
- }
753
- if (a = U(a), r === "")
754
- return a = a.replace(/[^\p{L}\p{N}\s]+/gu, ""), a = a.replace(/[\s]+/gu, ""), a;
755
- {
756
- const g = new RegExp(
757
- `[^${s(r)}\\p{L}\\p{N}\\s]+`,
758
- "gu"
759
- );
760
- a = a.replace(g, "");
761
- const h = new RegExp(
762
- `[${s(r)}\\s]+`,
763
- "gu"
764
- );
765
- a = a.replace(h, r);
766
- const d = new RegExp(
767
- `^${o(r)}+|${o(r)}+$`,
768
- "gu"
769
- );
770
- return a = a.replace(d, ""), a;
771
- }
772
- }, i = c(t), l = c(H(t));
773
- return Object.keys(n || {}).some((u) => /[A-Za-z0-9]/.test(u)) ? l : i;
774
- }
775
- function ot(t, e = "_") {
776
- const r = `${t}|${e}`;
777
- if (R.has(r))
778
- return R.get(r);
779
- let s = t;
780
- return /^[a-z]+$/.test(t) || (s = lt(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${e}`), s = U(s)), R.set(r, s), s;
781
- }
782
- function ce(t) {
783
- return V(t).replace(/[\s\u3164\u1160]+/gu, " ");
784
- }
785
- function I(t, e) {
786
- if (t == null || e == null)
787
- return !1;
788
- let n = [
789
- e
790
- ];
791
- typeof e == "string" || typeof e == "number" ? n = [e] : Symbol.iterator in Object(e) && (n = Array.from(e));
792
- const r = String(t);
793
- for (const s of n) {
794
- if (s == null)
795
- continue;
796
- const o = String(s);
797
- if (o !== "" && r.startsWith(o))
798
- return !0;
799
- }
800
- return !1;
801
- }
802
- function le(t, e) {
803
- return !I(t, e);
804
- }
805
- function Z(t) {
806
- const e = t;
807
- if (C.has(e))
808
- return C.get(e);
809
- const n = String(t).replace(/[-_]+/g, " "), r = n.trim() === "" ? [] : n.split(/\s+/u), s = (c) => {
810
- if (!c) return c;
811
- const i = Array.from(c), l = i[0].toUpperCase(), f = i.slice(1).join("");
812
- return l + f;
813
- }, o = r.map(s).join("");
814
- return C.set(e, o), o;
815
- }
816
- function fe(t) {
817
- return Z(t);
818
- }
819
- function ae(t, e) {
820
- if (!t || Object.keys(t).length === 0)
821
- return e;
822
- const n = Object.keys(t).filter((o) => o !== "");
823
- if (n.length === 0)
824
- return e;
825
- n.sort((o, c) => c.length - o.length);
826
- const r = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), s = new RegExp(n.map(r).join("|"), "gu");
827
- return e.replace(s, (o) => t[o] ?? o);
828
- }
829
- function ue(t, e) {
830
- return e < 0 ? x(t, e) : x(t, 0, e);
831
- }
832
- function it(t) {
833
- return U(x(t, 0, 1)) + x(t, 1);
834
- }
835
- function pe(t) {
836
- return D(x(t, 0, 1)) + x(t, 1);
837
- }
838
- function ct(t) {
839
- return t.split(new RegExp("(?=\\p{Lu})", "u")).filter(Boolean);
840
- }
841
- function lt(t, e = ` \r
842
- \f\v`) {
843
- const n = S(e) ? e.join("") : e, r = (i) => i.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), s = n.length ? r(n) : "", o = s.length ? `(?:\\s|[${s}])` : "\\s", c = new RegExp(`(^|${o})(\\p{Ll})`, "gu");
844
- return t.replace(c, (i, l, f) => l + f.toUpperCase());
845
- }
846
- function ge(t, e = null) {
847
- const n = e && e.length > 0 ? e.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&") : "", r = n.length > 0 ? new RegExp(`[\\p{L}\\p{N}${n}]+`, "gu") : /[\p{L}\p{N}]+/gu, s = t.match(r);
848
- return s ? s.length : 0;
849
- }
850
- function me(t, e = 75, n = `
851
- `, r = !1) {
852
- if (t.length === 0 || e < 1 || n === "")
853
- return t;
854
- const s = t.split(/\r\n|\n|\r/), o = [];
855
- for (const c of s) {
856
- let i = c;
857
- if (i.length === 0) {
858
- o.push("");
859
- continue;
860
- }
861
- if (r) {
862
- for (; i.length > 0 && !(/^\s/u.test(i) && (i = i.replace(/^\s+/u, ""), i.length === 0)); ) {
863
- if (i.length <= e) {
864
- o.push(i), i = "";
865
- break;
866
- }
867
- let l = i.slice(0, e);
868
- l = l.replace(/\s+$/u, ""), o.push(l), i = i.slice(e).replace(/^\s+/u, "");
869
- }
870
- continue;
871
- }
872
- for (; i.length > e; ) {
873
- const l = i.replace(/^\s+/u, "");
874
- if (l.length !== i.length && (i = l, i.length <= e))
875
- break;
876
- const f = i.slice(0, e + 1);
877
- let m = -1;
878
- for (let a = f.length - 1; a >= 0; a--)
879
- if (/\s/u.test(f[a])) {
880
- m = a;
881
- break;
882
- }
883
- if (m > 0) {
884
- o.push(i.slice(0, m)), i = i.slice(m + 1);
885
- continue;
886
- }
887
- const u = i.search(/\s/u);
888
- if (u >= 0) {
889
- o.push(i.slice(0, u)), i = i.slice(u + 1);
890
- continue;
891
- }
892
- o.push(i), i = "";
893
- break;
894
- }
895
- i.length > 0 && o.push(i);
896
- }
897
- return o.join(n);
898
- }
899
- function he() {
900
- return R.size;
901
- }
902
- function de() {
903
- return E.size;
904
- }
905
- function ye() {
906
- return C.size;
907
- }
908
- function we() {
909
- R.clear(), E.clear(), C.clear();
910
- }
911
- export {
912
- K as after,
913
- pt as afterLast,
914
- oe as apa,
915
- X as before,
916
- Y as beforeLast,
917
- gt as between,
918
- mt as betweenFirst,
919
- ht as camel,
920
- de as camelCacheSize,
921
- dt as charAt,
922
- wt as chopEnd,
923
- yt as chopStart,
924
- T as contains,
925
- St as containsAll,
926
- Ht as createRandomStringsNormally,
927
- et as createRandomStringsUsing,
928
- Bt as createRandomStringsUsingSequence,
929
- At as deduplicate,
930
- $t as doesntContain,
931
- kt as doesntEndWith,
932
- le as doesntStartWith,
933
- W as endsWith,
934
- xt as excerpt,
935
- bt as finish,
936
- we as flushCache,
937
- se as headline,
938
- Et as is,
939
- Ct as isAscii,
940
- Ft as isJson,
941
- It as isMatch,
942
- _t as isUlid,
943
- zt as isUrl,
944
- Nt as kebab,
945
- it as lcfirst,
946
- F as length,
947
- Ot as limit,
948
- U as lower,
949
- z as makePad,
950
- Wt as mask,
951
- Ut as match,
952
- Pt as matchAll,
953
- qt as numbers,
954
- Gt as padBoth,
955
- jt as padLeft,
956
- Kt as padRight,
957
- fe as pascal,
958
- Zt as password,
959
- Tt as pluralPascal,
960
- v as pluralStudly,
961
- Jt as position,
962
- tt as random,
963
- ee as remove,
964
- Vt as repeat,
965
- Xt as replace,
966
- Dt as replaceArray,
967
- vt as replaceEnd,
968
- nt as replaceFirst,
969
- rt as replaceLast,
970
- te as replaceMatches,
971
- Yt as replaceStart,
972
- ne as reverse,
973
- ie as slug,
974
- ot as snake,
975
- he as snakeCacheSize,
976
- ce as squish,
977
- re as start,
978
- I as startsWith,
979
- st as stripTags,
980
- Z as studly,
981
- ye as studlyCacheSize,
982
- ae as swap,
983
- ue as take,
984
- Qt as toStringOr,
985
- pe as ucfirst,
986
- ct as ucsplit,
987
- lt as ucwords,
988
- Rt as unwrap,
989
- ge as wordCount,
990
- me as wordWrap,
991
- Mt as words,
992
- Lt as wrap
993
- };