@forsakringskassan/vite-lib-config 3.4.4 → 3.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.
@@ -33,6 +33,717 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  mod
34
34
  ));
35
35
 
36
+ // node_modules/@leeoniya/ufuzzy/dist/uFuzzy.cjs
37
+ var require_uFuzzy = __commonJS({
38
+ "node_modules/@leeoniya/ufuzzy/dist/uFuzzy.cjs"(exports, module) {
39
+ "use strict";
40
+ var cmp = (a, b) => a > b ? 1 : a < b ? -1 : 0;
41
+ var inf = Infinity;
42
+ var escapeRegExp = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
43
+ var EXACT_HERE = "eexxaacctt";
44
+ var PUNCT_RE = new RegExp("\\p{P}", "gu");
45
+ var LATIN_UPPER = "A-Z";
46
+ var LATIN_LOWER = "a-z";
47
+ var COLLATE_ARGS = ["en", { numeric: true, sensitivity: "base" }];
48
+ var swapAlpha = (str, upper, lower) => str.replace(LATIN_UPPER, upper).replace(LATIN_LOWER, lower);
49
+ var OPTS = {
50
+ // whether regexps use a /u unicode flag
51
+ unicode: false,
52
+ alpha: null,
53
+ // term segmentation & punct/whitespace merging
54
+ interSplit: "[^A-Za-z\\d']+",
55
+ intraSplit: "[a-z][A-Z]",
56
+ // inter bounds that will be used to increase lft2/rgt2 info counters
57
+ interBound: "[^A-Za-z\\d]",
58
+ // intra bounds that will be used to increase lft1/rgt1 info counters
59
+ intraBound: "[A-Za-z]\\d|\\d[A-Za-z]|[a-z][A-Z]",
60
+ // inter-bounds mode
61
+ // 2 = strict (will only match 'man' on whitepace and punct boundaries: Mega Man, Mega_Man, mega.man)
62
+ // 1 = loose (plus allowance for alpha-num and case-change boundaries: MegaMan, 0007man)
63
+ // 0 = any (will match 'man' as any substring: megamaniac)
64
+ interLft: 0,
65
+ interRgt: 0,
66
+ // allowance between terms
67
+ interChars: ".",
68
+ interIns: inf,
69
+ // allowance between chars in terms
70
+ intraChars: "[a-z\\d']",
71
+ // internally case-insensitive
72
+ intraIns: null,
73
+ intraContr: "'[a-z]{1,2}\\b",
74
+ // multi-insert or single-error mode
75
+ intraMode: 0,
76
+ // single-error bounds for errors within terms, default requires exact first char
77
+ intraSlice: [1, inf],
78
+ // single-error tolerance toggles
79
+ intraSub: null,
80
+ intraTrn: null,
81
+ intraDel: null,
82
+ // can post-filter matches that are too far apart in distance or length
83
+ // (since intraIns is between each char, it can accum to nonsense matches)
84
+ intraFilt: (term, match2, index) => true,
85
+ // should this also accept WIP info?
86
+ toUpper: (str) => str.toLocaleUpperCase(),
87
+ toLower: (str) => str.toLocaleLowerCase(),
88
+ compare: null,
89
+ // final sorting fn
90
+ sort: (info, haystack, needle, compare = cmp) => {
91
+ let {
92
+ idx,
93
+ chars: chars2,
94
+ terms,
95
+ interLft2,
96
+ interLft1,
97
+ // interRgt2,
98
+ // interRgt1,
99
+ start,
100
+ intraIns,
101
+ interIns,
102
+ cases
103
+ } = info;
104
+ return idx.map((v, i) => i).sort((ia, ib) => (
105
+ // most contig chars matched
106
+ chars2[ib] - chars2[ia] || // least char intra-fuzz (most contiguous)
107
+ intraIns[ia] - intraIns[ib] || // most prefix bounds, boosted by full term matches
108
+ terms[ib] + interLft2[ib] + 0.5 * interLft1[ib] - (terms[ia] + interLft2[ia] + 0.5 * interLft1[ia]) || // highest density of match (least span)
109
+ // span[ia] - span[ib] ||
110
+ // highest density of match (least term inter-fuzz)
111
+ interIns[ia] - interIns[ib] || // earliest start of match
112
+ start[ia] - start[ib] || // case match
113
+ cases[ib] - cases[ia] || // alphabetic
114
+ compare(haystack[idx[ia]], haystack[idx[ib]])
115
+ ));
116
+ }
117
+ };
118
+ var lazyRepeat = (chars2, limit) => limit == 0 ? "" : limit == 1 ? chars2 + "??" : limit == inf ? chars2 + "*?" : chars2 + `{0,${limit}}?`;
119
+ var mode2Tpl = "(?:\\b|_)";
120
+ function uFuzzy2(opts) {
121
+ opts = Object.assign({}, OPTS, opts);
122
+ let {
123
+ unicode,
124
+ interLft,
125
+ interRgt,
126
+ intraMode,
127
+ intraSlice,
128
+ intraIns,
129
+ intraSub,
130
+ intraTrn,
131
+ intraDel,
132
+ intraContr,
133
+ intraSplit: _intraSplit,
134
+ interSplit: _interSplit,
135
+ intraBound: _intraBound,
136
+ interBound: _interBound,
137
+ intraChars,
138
+ toUpper,
139
+ toLower,
140
+ compare
141
+ } = opts;
142
+ intraIns ??= intraMode;
143
+ intraSub ??= intraMode;
144
+ intraTrn ??= intraMode;
145
+ intraDel ??= intraMode;
146
+ compare ??= typeof Intl == "undefined" ? cmp : new Intl.Collator(...COLLATE_ARGS).compare;
147
+ let alpha = opts.letters ?? opts.alpha;
148
+ if (alpha != null) {
149
+ let upper = toUpper(alpha);
150
+ let lower = toLower(alpha);
151
+ _interSplit = swapAlpha(_interSplit, upper, lower);
152
+ _intraSplit = swapAlpha(_intraSplit, upper, lower);
153
+ _interBound = swapAlpha(_interBound, upper, lower);
154
+ _intraBound = swapAlpha(_intraBound, upper, lower);
155
+ intraChars = swapAlpha(intraChars, upper, lower);
156
+ intraContr = swapAlpha(intraContr, upper, lower);
157
+ }
158
+ let uFlag = unicode ? "u" : "";
159
+ const quotedAny = '".+?"';
160
+ const EXACTS_RE = new RegExp(quotedAny, "gi" + uFlag);
161
+ const NEGS_RE = new RegExp(`(?:\\s+|^)-(?:${intraChars}+|${quotedAny})`, "gi" + uFlag);
162
+ let { intraRules } = opts;
163
+ if (intraRules == null) {
164
+ intraRules = (p) => {
165
+ let _intraSlice = OPTS.intraSlice, _intraIns = 0, _intraSub = 0, _intraTrn = 0, _intraDel = 0;
166
+ if (/[^\d]/.test(p)) {
167
+ let plen = p.length;
168
+ if (plen <= 4) {
169
+ if (plen >= 3) {
170
+ _intraTrn = Math.min(intraTrn, 1);
171
+ if (plen == 4)
172
+ _intraIns = Math.min(intraIns, 1);
173
+ }
174
+ } else {
175
+ _intraSlice = intraSlice;
176
+ _intraIns = intraIns, _intraSub = intraSub, _intraTrn = intraTrn, _intraDel = intraDel;
177
+ }
178
+ }
179
+ return {
180
+ intraSlice: _intraSlice,
181
+ intraIns: _intraIns,
182
+ intraSub: _intraSub,
183
+ intraTrn: _intraTrn,
184
+ intraDel: _intraDel
185
+ };
186
+ };
187
+ }
188
+ let withIntraSplit = !!_intraSplit;
189
+ let intraSplit = new RegExp(_intraSplit, "g" + uFlag);
190
+ let interSplit = new RegExp(_interSplit, "g" + uFlag);
191
+ let trimRe = new RegExp("^" + _interSplit + "|" + _interSplit + "$", "g" + uFlag);
192
+ let contrsRe = new RegExp(intraContr, "gi" + uFlag);
193
+ const split = (needle, keepCase = false) => {
194
+ let exacts = [];
195
+ needle = needle.replace(EXACTS_RE, (m) => {
196
+ exacts.push(m);
197
+ return EXACT_HERE;
198
+ });
199
+ needle = needle.replace(trimRe, "");
200
+ if (!keepCase)
201
+ needle = toLower(needle);
202
+ if (withIntraSplit)
203
+ needle = needle.replace(intraSplit, (m) => m[0] + " " + m[1]);
204
+ let j = 0;
205
+ return needle.split(interSplit).filter((t) => t != "").map((v) => v === EXACT_HERE ? exacts[j++] : v);
206
+ };
207
+ const NUM_OR_ALPHA_RE = /[^\d]+|\d+/g;
208
+ const prepQuery = (needle, capt = 0, interOR = false) => {
209
+ let parts = split(needle);
210
+ if (parts.length == 0)
211
+ return [];
212
+ let contrs = Array(parts.length).fill("");
213
+ parts = parts.map((p, pi) => p.replace(contrsRe, (m) => {
214
+ contrs[pi] = m;
215
+ return "";
216
+ }));
217
+ let reTpl;
218
+ if (intraMode == 1) {
219
+ reTpl = parts.map((p, pi) => {
220
+ if (p[0] === '"')
221
+ return escapeRegExp(p.slice(1, -1));
222
+ let reTpl2 = "";
223
+ for (let m of p.matchAll(NUM_OR_ALPHA_RE)) {
224
+ let p2 = m[0];
225
+ let {
226
+ intraSlice: intraSlice2,
227
+ intraIns: intraIns2,
228
+ intraSub: intraSub2,
229
+ intraTrn: intraTrn2,
230
+ intraDel: intraDel2
231
+ } = intraRules(p2);
232
+ if (intraIns2 + intraSub2 + intraTrn2 + intraDel2 == 0)
233
+ reTpl2 += p2 + contrs[pi];
234
+ else {
235
+ let [lftIdx, rgtIdx] = intraSlice2;
236
+ let lftChar = p2.slice(0, lftIdx);
237
+ let rgtChar = p2.slice(rgtIdx);
238
+ let chars2 = p2.slice(lftIdx, rgtIdx);
239
+ if (intraIns2 == 1 && lftChar.length == 1 && lftChar != chars2[0])
240
+ lftChar += "(?!" + lftChar + ")";
241
+ let numChars = chars2.length;
242
+ let variants = [p2];
243
+ if (intraSub2) {
244
+ for (let i = 0; i < numChars; i++)
245
+ variants.push(lftChar + chars2.slice(0, i) + intraChars + chars2.slice(i + 1) + rgtChar);
246
+ }
247
+ if (intraTrn2) {
248
+ for (let i = 0; i < numChars - 1; i++) {
249
+ if (chars2[i] != chars2[i + 1])
250
+ variants.push(lftChar + chars2.slice(0, i) + chars2[i + 1] + chars2[i] + chars2.slice(i + 2) + rgtChar);
251
+ }
252
+ }
253
+ if (intraDel2) {
254
+ for (let i = 0; i < numChars; i++)
255
+ variants.push(lftChar + chars2.slice(0, i + 1) + "?" + chars2.slice(i + 1) + rgtChar);
256
+ }
257
+ if (intraIns2) {
258
+ let intraInsTpl = lazyRepeat(intraChars, 1);
259
+ for (let i = 0; i < numChars; i++)
260
+ variants.push(lftChar + chars2.slice(0, i) + intraInsTpl + chars2.slice(i) + rgtChar);
261
+ }
262
+ reTpl2 += "(?:" + variants.join("|") + ")" + contrs[pi];
263
+ }
264
+ }
265
+ return reTpl2;
266
+ });
267
+ } else {
268
+ let intraInsTpl = lazyRepeat(intraChars, intraIns);
269
+ if (capt == 2 && intraIns > 0) {
270
+ intraInsTpl = ")(" + intraInsTpl + ")(";
271
+ }
272
+ reTpl = parts.map((p, pi) => p[0] === '"' ? escapeRegExp(p.slice(1, -1)) : p.split("").map((c, i, chars2) => {
273
+ if (intraIns == 1 && i == 0 && chars2.length > 1 && c != chars2[i + 1])
274
+ c += "(?!" + c + ")";
275
+ return c;
276
+ }).join(intraInsTpl) + contrs[pi]);
277
+ }
278
+ let preTpl = interLft == 2 ? mode2Tpl : "";
279
+ let sufTpl = interRgt == 2 ? mode2Tpl : "";
280
+ let interCharsTpl = sufTpl + lazyRepeat(opts.interChars, opts.interIns) + preTpl;
281
+ if (capt > 0) {
282
+ if (interOR) {
283
+ reTpl = preTpl + "(" + reTpl.join(")" + sufTpl + "|" + preTpl + "(") + ")" + sufTpl;
284
+ } else {
285
+ reTpl = "(" + reTpl.join(")(" + interCharsTpl + ")(") + ")";
286
+ reTpl = "(.??" + preTpl + ")" + reTpl + "(" + sufTpl + ".*)";
287
+ }
288
+ } else {
289
+ reTpl = reTpl.join(interCharsTpl);
290
+ reTpl = preTpl + reTpl + sufTpl;
291
+ }
292
+ return [new RegExp(reTpl, "i" + uFlag), parts, contrs];
293
+ };
294
+ const filter3 = (haystack, needle, idxs) => {
295
+ let [query] = prepQuery(needle);
296
+ if (query == null)
297
+ return null;
298
+ let out = [];
299
+ if (idxs != null) {
300
+ for (let i = 0; i < idxs.length; i++) {
301
+ let idx = idxs[i];
302
+ query.test(haystack[idx]) && out.push(idx);
303
+ }
304
+ } else {
305
+ for (let i = 0; i < haystack.length; i++)
306
+ query.test(haystack[i]) && out.push(i);
307
+ }
308
+ return out;
309
+ };
310
+ let withIntraBound = !!_intraBound;
311
+ let interBound = new RegExp(_interBound, uFlag);
312
+ let intraBound = new RegExp(_intraBound, uFlag);
313
+ const info = (idxs, haystack, needle) => {
314
+ let [query, parts, contrs] = prepQuery(needle, 1);
315
+ let partsCased = split(needle, true);
316
+ let [queryR] = prepQuery(needle, 2);
317
+ let partsLen = parts.length;
318
+ let _terms = Array(partsLen);
319
+ let _termsCased = Array(partsLen);
320
+ for (let j = 0; j < partsLen; j++) {
321
+ let part = parts[j];
322
+ let partCased = partsCased[j];
323
+ let term = part[0] == '"' ? part.slice(1, -1) : part + contrs[j];
324
+ let termCased = partCased[0] == '"' ? partCased.slice(1, -1) : partCased + contrs[j];
325
+ _terms[j] = term;
326
+ _termsCased[j] = termCased;
327
+ }
328
+ let len = idxs.length;
329
+ let field = Array(len).fill(0);
330
+ let info2 = {
331
+ // idx in haystack
332
+ idx: Array(len),
333
+ // start of match
334
+ start: field.slice(),
335
+ // length of match
336
+ // span: field.slice(),
337
+ // contiguous chars matched
338
+ chars: field.slice(),
339
+ // case matched in term (via term.includes(match))
340
+ cases: field.slice(),
341
+ // contiguous (no fuzz) and bounded terms (intra=0, lft2/1, rgt2/1)
342
+ // excludes terms that are contiguous but have < 2 bounds (substrings)
343
+ terms: field.slice(),
344
+ // cumulative length of unmatched chars (fuzz) within span
345
+ interIns: field.slice(),
346
+ // between terms
347
+ intraIns: field.slice(),
348
+ // within terms
349
+ // interLft/interRgt counters
350
+ interLft2: field.slice(),
351
+ interRgt2: field.slice(),
352
+ interLft1: field.slice(),
353
+ interRgt1: field.slice(),
354
+ ranges: Array(len)
355
+ };
356
+ let mayDiscard = interLft == 1 || interRgt == 1;
357
+ let ii = 0;
358
+ for (let i = 0; i < idxs.length; i++) {
359
+ let mhstr = haystack[idxs[i]];
360
+ let m = mhstr.match(query);
361
+ let start = m.index + m[1].length;
362
+ let idxAcc = start;
363
+ let disc = false;
364
+ let lft2 = 0;
365
+ let lft1 = 0;
366
+ let rgt2 = 0;
367
+ let rgt1 = 0;
368
+ let chars2 = 0;
369
+ let terms = 0;
370
+ let cases = 0;
371
+ let inter = 0;
372
+ let intra = 0;
373
+ let refine = [];
374
+ for (let j = 0, k = 2; j < partsLen; j++, k += 2) {
375
+ let group = toLower(m[k]);
376
+ let term = _terms[j];
377
+ let termCased = _termsCased[j];
378
+ let termLen = term.length;
379
+ let groupLen = group.length;
380
+ let fullMatch = group == term;
381
+ if (m[k] == termCased)
382
+ cases++;
383
+ if (!fullMatch && m[k + 1].length >= termLen) {
384
+ let idxOf = toLower(m[k + 1]).indexOf(term);
385
+ if (idxOf > -1) {
386
+ refine.push(idxAcc, groupLen, idxOf, termLen);
387
+ idxAcc += refineMatch(m, k, idxOf, termLen);
388
+ group = term;
389
+ groupLen = termLen;
390
+ fullMatch = true;
391
+ if (j == 0)
392
+ start = idxAcc;
393
+ }
394
+ }
395
+ if (mayDiscard || fullMatch) {
396
+ let lftCharIdx = idxAcc - 1;
397
+ let rgtCharIdx = idxAcc + groupLen;
398
+ let isPre = false;
399
+ let isSuf = false;
400
+ if (lftCharIdx == -1 || interBound.test(mhstr[lftCharIdx])) {
401
+ fullMatch && lft2++;
402
+ isPre = true;
403
+ } else {
404
+ if (interLft == 2) {
405
+ disc = true;
406
+ break;
407
+ }
408
+ if (withIntraBound && intraBound.test(mhstr[lftCharIdx] + mhstr[lftCharIdx + 1])) {
409
+ fullMatch && lft1++;
410
+ isPre = true;
411
+ } else {
412
+ if (interLft == 1) {
413
+ let junk = m[k + 1];
414
+ let junkIdx = idxAcc + groupLen;
415
+ if (junk.length >= termLen) {
416
+ let idxOf = 0;
417
+ let found = false;
418
+ let re = new RegExp(term, "ig" + uFlag);
419
+ let m2;
420
+ while (m2 = re.exec(junk)) {
421
+ idxOf = m2.index;
422
+ let charIdx = junkIdx + idxOf;
423
+ let lftCharIdx2 = charIdx - 1;
424
+ if (lftCharIdx2 == -1 || interBound.test(mhstr[lftCharIdx2])) {
425
+ lft2++;
426
+ found = true;
427
+ break;
428
+ } else if (intraBound.test(mhstr[lftCharIdx2] + mhstr[charIdx])) {
429
+ lft1++;
430
+ found = true;
431
+ break;
432
+ }
433
+ }
434
+ if (found) {
435
+ isPre = true;
436
+ refine.push(idxAcc, groupLen, idxOf, termLen);
437
+ idxAcc += refineMatch(m, k, idxOf, termLen);
438
+ group = term;
439
+ groupLen = termLen;
440
+ fullMatch = true;
441
+ if (j == 0)
442
+ start = idxAcc;
443
+ }
444
+ }
445
+ if (!isPre) {
446
+ disc = true;
447
+ break;
448
+ }
449
+ }
450
+ }
451
+ }
452
+ if (rgtCharIdx == mhstr.length || interBound.test(mhstr[rgtCharIdx])) {
453
+ fullMatch && rgt2++;
454
+ isSuf = true;
455
+ } else {
456
+ if (interRgt == 2) {
457
+ disc = true;
458
+ break;
459
+ }
460
+ if (withIntraBound && intraBound.test(mhstr[rgtCharIdx - 1] + mhstr[rgtCharIdx])) {
461
+ fullMatch && rgt1++;
462
+ isSuf = true;
463
+ } else {
464
+ if (interRgt == 1) {
465
+ disc = true;
466
+ break;
467
+ }
468
+ }
469
+ }
470
+ if (fullMatch) {
471
+ chars2 += termLen;
472
+ if (isPre && isSuf)
473
+ terms++;
474
+ }
475
+ }
476
+ if (groupLen > termLen)
477
+ intra += groupLen - termLen;
478
+ if (j > 0)
479
+ inter += m[k - 1].length;
480
+ if (!opts.intraFilt(term, group, idxAcc)) {
481
+ disc = true;
482
+ break;
483
+ }
484
+ if (j < partsLen - 1)
485
+ idxAcc += groupLen + m[k + 1].length;
486
+ }
487
+ if (!disc) {
488
+ info2.idx[ii] = idxs[i];
489
+ info2.interLft2[ii] = lft2;
490
+ info2.interLft1[ii] = lft1;
491
+ info2.interRgt2[ii] = rgt2;
492
+ info2.interRgt1[ii] = rgt1;
493
+ info2.chars[ii] = chars2;
494
+ info2.terms[ii] = terms;
495
+ info2.cases[ii] = cases;
496
+ info2.interIns[ii] = inter;
497
+ info2.intraIns[ii] = intra;
498
+ info2.start[ii] = start;
499
+ let m2 = mhstr.match(queryR);
500
+ let idxAcc2 = m2.index + m2[1].length;
501
+ let refLen = refine.length;
502
+ let ri = refLen > 0 ? 0 : Infinity;
503
+ let lastRi = refLen - 4;
504
+ for (let i2 = 2; i2 < m2.length; ) {
505
+ let len2 = m2[i2].length;
506
+ if (ri <= lastRi && refine[ri] == idxAcc2) {
507
+ let groupLen = refine[ri + 1];
508
+ let idxOf = refine[ri + 2];
509
+ let termLen = refine[ri + 3];
510
+ let j = i2;
511
+ let v = "";
512
+ for (let _len = 0; _len < groupLen; j++) {
513
+ v += m2[j];
514
+ _len += m2[j].length;
515
+ }
516
+ m2.splice(i2, j - i2, v);
517
+ idxAcc2 += refineMatch(m2, i2, idxOf, termLen);
518
+ ri += 4;
519
+ } else {
520
+ idxAcc2 += len2;
521
+ i2++;
522
+ }
523
+ }
524
+ idxAcc2 = m2.index + m2[1].length;
525
+ let ranges = info2.ranges[ii] = [];
526
+ let from = idxAcc2;
527
+ let to = idxAcc2;
528
+ for (let i2 = 2; i2 < m2.length; i2++) {
529
+ let len2 = m2[i2].length;
530
+ idxAcc2 += len2;
531
+ if (i2 % 2 == 0)
532
+ to = idxAcc2;
533
+ else if (len2 > 0) {
534
+ ranges.push(from, to);
535
+ from = to = idxAcc2;
536
+ }
537
+ }
538
+ if (to > from)
539
+ ranges.push(from, to);
540
+ ii++;
541
+ }
542
+ }
543
+ if (ii < idxs.length) {
544
+ for (let k in info2)
545
+ info2[k] = info2[k].slice(0, ii);
546
+ }
547
+ return info2;
548
+ };
549
+ const refineMatch = (m, k, idxInNext, termLen) => {
550
+ let prepend = m[k] + m[k + 1].slice(0, idxInNext);
551
+ m[k - 1] += prepend;
552
+ m[k] = m[k + 1].slice(idxInNext, idxInNext + termLen);
553
+ m[k + 1] = m[k + 1].slice(idxInNext + termLen);
554
+ return prepend.length;
555
+ };
556
+ const OOO_TERMS_LIMIT = 5;
557
+ const _search = (haystack, needle, outOfOrder, infoThresh = 1e3, preFiltered) => {
558
+ outOfOrder = !outOfOrder ? 0 : outOfOrder === true ? OOO_TERMS_LIMIT : outOfOrder;
559
+ let needles = null;
560
+ let matches = null;
561
+ let negs = [];
562
+ needle = needle.replace(NEGS_RE, (m) => {
563
+ let neg = m.trim().slice(1);
564
+ neg = neg[0] === '"' ? escapeRegExp(neg.slice(1, -1)) : neg.replace(PUNCT_RE, "");
565
+ if (neg != "")
566
+ negs.push(neg);
567
+ return "";
568
+ });
569
+ let terms = split(needle);
570
+ let negsRe;
571
+ if (negs.length > 0) {
572
+ negsRe = new RegExp(negs.join("|"), "i" + uFlag);
573
+ if (terms.length == 0) {
574
+ let idxs = [];
575
+ for (let i = 0; i < haystack.length; i++) {
576
+ if (!negsRe.test(haystack[i]))
577
+ idxs.push(i);
578
+ }
579
+ return [idxs, null, null];
580
+ }
581
+ } else {
582
+ if (terms.length == 0)
583
+ return [null, null, null];
584
+ }
585
+ if (outOfOrder > 0) {
586
+ let terms2 = split(needle);
587
+ if (terms2.length > 1) {
588
+ let terms22 = terms2.slice().sort((a, b) => b.length - a.length);
589
+ for (let ti = 0; ti < terms22.length; ti++) {
590
+ if (preFiltered?.length == 0)
591
+ return [[], null, null];
592
+ preFiltered = filter3(haystack, terms22[ti], preFiltered);
593
+ }
594
+ if (terms2.length > outOfOrder)
595
+ return [preFiltered, null, null];
596
+ needles = permute(terms2).map((perm) => perm.join(" "));
597
+ matches = [];
598
+ let matchedIdxs = /* @__PURE__ */ new Set();
599
+ for (let ni = 0; ni < needles.length; ni++) {
600
+ if (matchedIdxs.size < preFiltered.length) {
601
+ let preFiltered2 = preFiltered.filter((idx) => !matchedIdxs.has(idx));
602
+ let matched = filter3(haystack, needles[ni], preFiltered2);
603
+ for (let j = 0; j < matched.length; j++)
604
+ matchedIdxs.add(matched[j]);
605
+ matches.push(matched);
606
+ } else
607
+ matches.push([]);
608
+ }
609
+ }
610
+ }
611
+ if (needles == null) {
612
+ needles = [needle];
613
+ matches = [preFiltered?.length > 0 ? preFiltered : filter3(haystack, needle)];
614
+ }
615
+ let retInfo = null;
616
+ let retOrder = null;
617
+ if (negs.length > 0)
618
+ matches = matches.map((idxs) => idxs.filter((idx) => !negsRe.test(haystack[idx])));
619
+ let matchCount = matches.reduce((acc, idxs) => acc + idxs.length, 0);
620
+ if (matchCount <= infoThresh) {
621
+ retInfo = {};
622
+ retOrder = [];
623
+ for (let ni = 0; ni < matches.length; ni++) {
624
+ let idxs = matches[ni];
625
+ if (idxs == null || idxs.length == 0)
626
+ continue;
627
+ let needle2 = needles[ni];
628
+ let _info = info(idxs, haystack, needle2);
629
+ let order = opts.sort(_info, haystack, needle2, compare);
630
+ if (ni > 0) {
631
+ for (let i = 0; i < order.length; i++)
632
+ order[i] += retOrder.length;
633
+ }
634
+ for (let k in _info)
635
+ retInfo[k] = (retInfo[k] ?? []).concat(_info[k]);
636
+ retOrder = retOrder.concat(order);
637
+ }
638
+ }
639
+ return [
640
+ [].concat(...matches),
641
+ retInfo,
642
+ retOrder
643
+ ];
644
+ };
645
+ return {
646
+ search: (...args) => {
647
+ let out = _search(...args);
648
+ return out;
649
+ },
650
+ split,
651
+ filter: filter3,
652
+ info,
653
+ sort: opts.sort
654
+ };
655
+ }
656
+ var latinize = (() => {
657
+ let accents = {
658
+ A: "\xC1\xC0\xC3\xC2\xC4\u0104",
659
+ a: "\xE1\xE0\xE3\xE2\xE4\u0105",
660
+ E: "\xC9\xC8\xCA\xCB\u0116",
661
+ e: "\xE9\xE8\xEA\xEB\u0119",
662
+ I: "\xCD\xCC\xCE\xCF\u012E",
663
+ i: "\xED\xEC\xEE\xEF\u012F",
664
+ O: "\xD3\xD2\xD4\xD5\xD6",
665
+ o: "\xF3\xF2\xF4\xF5\xF6",
666
+ U: "\xDA\xD9\xDB\xDC\u016A\u0172",
667
+ u: "\xFA\xF9\xFB\xFC\u016B\u0173",
668
+ C: "\xC7\u010C\u0106",
669
+ c: "\xE7\u010D\u0107",
670
+ L: "\u0141",
671
+ l: "\u0142",
672
+ N: "\xD1\u0143",
673
+ n: "\xF1\u0144",
674
+ S: "\u0160\u015A",
675
+ s: "\u0161\u015B",
676
+ Z: "\u017B\u0179",
677
+ z: "\u017C\u017A"
678
+ };
679
+ let accentsMap = /* @__PURE__ */ new Map();
680
+ let accentsTpl = "";
681
+ for (let r in accents) {
682
+ accents[r].split("").forEach((a) => {
683
+ accentsTpl += a;
684
+ accentsMap.set(a, r);
685
+ });
686
+ }
687
+ let accentsRe = new RegExp(`[${accentsTpl}]`, "g");
688
+ let replacer = (m) => accentsMap.get(m);
689
+ return (strings) => {
690
+ if (typeof strings == "string")
691
+ return strings.replace(accentsRe, replacer);
692
+ let out = Array(strings.length);
693
+ for (let i = 0; i < strings.length; i++)
694
+ out[i] = strings[i].replace(accentsRe, replacer);
695
+ return out;
696
+ };
697
+ })();
698
+ function permute(arr) {
699
+ arr = arr.slice();
700
+ let length = arr.length, result = [arr.slice()], c = new Array(length).fill(0), i = 1, k, p;
701
+ while (i < length) {
702
+ if (c[i] < i) {
703
+ k = i % 2 && c[i];
704
+ p = arr[i];
705
+ arr[i] = arr[k];
706
+ arr[k] = p;
707
+ ++c[i];
708
+ i = 1;
709
+ result.push(arr.slice());
710
+ } else {
711
+ c[i] = 0;
712
+ ++i;
713
+ }
714
+ }
715
+ return result;
716
+ }
717
+ var _mark = (part, matched) => matched ? `<mark>${part}</mark>` : part;
718
+ var _append = (acc, part) => acc + part;
719
+ function highlight(str, ranges, mark = _mark, accum = "", append = _append) {
720
+ accum = append(accum, mark(str.substring(0, ranges[0]), false)) ?? accum;
721
+ for (let i = 0; i < ranges.length; i += 2) {
722
+ let fr = ranges[i];
723
+ let to = ranges[i + 1];
724
+ accum = append(accum, mark(str.substring(fr, to), true)) ?? accum;
725
+ if (i < ranges.length - 3)
726
+ accum = append(accum, mark(str.substring(ranges[i + 1], ranges[i + 2]), false)) ?? accum;
727
+ }
728
+ accum = append(accum, mark(str.substring(ranges[ranges.length - 1]), false)) ?? accum;
729
+ return accum;
730
+ }
731
+ uFuzzy2.latinize = latinize;
732
+ uFuzzy2.permute = (arr) => {
733
+ let idxs = permute([...Array(arr.length).keys()]).sort((a, b) => {
734
+ for (let i = 0; i < a.length; i++) {
735
+ if (a[i] != b[i])
736
+ return a[i] - b[i];
737
+ }
738
+ return 0;
739
+ });
740
+ return idxs.map((pi) => pi.map((i) => arr[i]));
741
+ };
742
+ uFuzzy2.highlight = highlight;
743
+ module.exports = uFuzzy2;
744
+ }
745
+ });
746
+
36
747
  // node_modules/deepmerge/dist/cjs.js
37
748
  var require_cjs = __commonJS({
38
749
  "node_modules/deepmerge/dist/cjs.js"(exports, module) {
@@ -2408,6 +3119,7 @@ var require_semver2 = __commonJS({
2408
3119
  });
2409
3120
 
2410
3121
  // src/vite.config.ts
3122
+ var import_ufuzzy = __toESM(require_uFuzzy());
2411
3123
  var import_deepmerge = __toESM(require_cjs());
2412
3124
  var import_picocolors = __toESM(require_picocolors());
2413
3125
  import { vitePlugin as apimockPlugin } from "@forsakringskassan/apimock-express";
@@ -4885,172 +5597,6 @@ function vuePlugin(rawOptions = {}) {
4885
5597
  };
4886
5598
  }
4887
5599
 
4888
- // src/plugins/babel-plugin.ts
4889
- import * as babel from "@babel/core";
4890
- var filter = /\.(js|ts|vue)$/;
4891
- function babelPlugin() {
4892
- return {
4893
- name: "fk:babel",
4894
- enforce: "post",
4895
- apply: "build",
4896
- async transform(src2, id) {
4897
- const { pathname: filename } = new URL(id, "file://");
4898
- if (!filter.test(filename)) {
4899
- return null;
4900
- }
4901
- const transformed = await babel.transformAsync(src2, {
4902
- sourceMaps: true,
4903
- comments: true,
4904
- filename
4905
- });
4906
- if (!transformed) {
4907
- return null;
4908
- }
4909
- const { code, map } = transformed;
4910
- return {
4911
- code: code ?? src2,
4912
- map: map ?? null
4913
- };
4914
- }
4915
- };
4916
- }
4917
-
4918
- // src/plugins/custom-mapping-plugin.ts
4919
- var folder = {
4920
- es: "esm",
4921
- cjs: "cjs"
4922
- };
4923
- function customMappingPlugin() {
4924
- return {
4925
- name: "fk:custom-mapping",
4926
- renderStart(options) {
4927
- const { format } = options;
4928
- if (format !== "es" && format !== "cjs") {
4929
- return;
4930
- }
4931
- const replacement = folder[format];
4932
- options.dir = options.dir?.replace("[custom-format]", replacement);
4933
- if (typeof options.entryFileNames === "string") {
4934
- options.entryFileNames = options.entryFileNames.replace(
4935
- "[custom-format]",
4936
- replacement
4937
- );
4938
- }
4939
- }
4940
- };
4941
- }
4942
-
4943
- // src/plugins/index-html-plugin.ts
4944
- import fs3 from "node:fs/promises";
4945
- import path2 from "node:path";
4946
-
4947
- // src/utils/lookupFile.ts
4948
- import fs2 from "node:fs";
4949
- var extensions = ["ts", "mts", "mjs", "js"];
4950
- function lookupFile(nameWithoutExtension) {
4951
- for (const extension of extensions) {
4952
- const fileName = `${nameWithoutExtension}.${extension}`;
4953
- if (fs2.existsSync(fileName)) {
4954
- return fileName;
4955
- }
4956
- }
4957
- return `${nameWithoutExtension}.ts`;
4958
- }
4959
-
4960
- // src/plugins/index-html-plugin.ts
4961
- var templateFile = path2.resolve(__dirname, "../assets/index.html");
4962
- var VIRTUAL_ENTRYPOINT = "index.html";
4963
- function isHtmlPage(url) {
4964
- if (!url) {
4965
- return false;
4966
- }
4967
- return url.startsWith(".html") || url === "/";
4968
- }
4969
- function middleware(server) {
4970
- return async (req, res, next) => {
4971
- const { url } = req;
4972
- if (isHtmlPage(url)) {
4973
- try {
4974
- res.end(await server.transformIndexHtml(url, ""));
4975
- } catch (err) {
4976
- console.error(err);
4977
- res.writeHead(500);
4978
- res.end("Internal Server Error");
4979
- }
4980
- } else {
4981
- return next();
4982
- }
4983
- };
4984
- }
4985
- function indexHtmlPlugin() {
4986
- const templateData = {
4987
- entrypoint: "/src/vite-dev/app.vue",
4988
- entrypointLocal: `/${lookupFile("src/local")}`
4989
- };
4990
- return {
4991
- name: "fk:virtual-entrypoint",
4992
- resolveId: {
4993
- order: "pre",
4994
- handler(source) {
4995
- const { base } = path2.parse(source);
4996
- if (base === "index.html") {
4997
- return VIRTUAL_ENTRYPOINT;
4998
- }
4999
- }
5000
- },
5001
- load: {
5002
- order: "pre",
5003
- handler(id) {
5004
- if (id === VIRTUAL_ENTRYPOINT) {
5005
- return "";
5006
- }
5007
- }
5008
- },
5009
- transformIndexHtml: {
5010
- order: "pre",
5011
- async handler() {
5012
- const content = await fs3.readFile(templateFile, "utf-8");
5013
- return content.replace(/{{([^}]+)}}/g, (match2, key) => {
5014
- return templateData[key.trim()] ?? match2;
5015
- });
5016
- }
5017
- },
5018
- config(config) {
5019
- if (config.fk?.entrypoint) {
5020
- templateData.entrypoint = config.fk.entrypoint;
5021
- }
5022
- },
5023
- configureServer(server) {
5024
- server.middlewares.use(middleware(server));
5025
- }
5026
- };
5027
- }
5028
-
5029
- // src/plugins/package-json-plugin.ts
5030
- var mapping = {
5031
- es: "module",
5032
- cjs: "commonjs"
5033
- };
5034
- function packageJsonPlugin() {
5035
- return {
5036
- name: "fk:package-json",
5037
- generateBundle(options) {
5038
- const { format } = options;
5039
- if (format !== "es" && format !== "cjs") {
5040
- return;
5041
- }
5042
- const pkg = {
5043
- type: mapping[format]
5044
- };
5045
- this.emitFile({
5046
- type: "asset",
5047
- fileName: "package.json",
5048
- source: JSON.stringify(pkg, null, 2)
5049
- });
5050
- }
5051
- };
5052
- }
5053
-
5054
5600
  // node_modules/glob/node_modules/minimatch/dist/esm/index.js
5055
5601
  var import_brace_expansion = __toESM(require_brace_expansion(), 1);
5056
5602
 
@@ -5722,11 +6268,11 @@ var qmarksTestNoExtDot = ([$0]) => {
5722
6268
  return (f) => f.length === len && f !== "." && f !== "..";
5723
6269
  };
5724
6270
  var defaultPlatform = typeof process === "object" && process ? typeof process.env === "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
5725
- var path3 = {
6271
+ var path2 = {
5726
6272
  win32: { sep: "\\" },
5727
6273
  posix: { sep: "/" }
5728
6274
  };
5729
- var sep = defaultPlatform === "win32" ? path3.win32.sep : path3.posix.sep;
6275
+ var sep = defaultPlatform === "win32" ? path2.win32.sep : path2.posix.sep;
5730
6276
  minimatch.sep = sep;
5731
6277
  var GLOBSTAR = Symbol("globstar **");
5732
6278
  minimatch.GLOBSTAR = GLOBSTAR;
@@ -5734,8 +6280,8 @@ var qmark2 = "[^/]";
5734
6280
  var star2 = qmark2 + "*?";
5735
6281
  var twoStarDot = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
5736
6282
  var twoStarNoDot = "(?:(?!(?:\\/|^)\\.).)*?";
5737
- var filter2 = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
5738
- minimatch.filter = filter2;
6283
+ var filter = (pattern, options = {}) => (p) => minimatch(p, pattern, options);
6284
+ minimatch.filter = filter;
5739
6285
  var ext = (a, b = {}) => Object.assign({}, a, b);
5740
6286
  var defaults = (def) => {
5741
6287
  if (!def || typeof def !== "object" || !Object.keys(def).length) {
@@ -11329,6 +11875,172 @@ var glob = Object.assign(glob_, {
11329
11875
  });
11330
11876
  glob.glob = glob;
11331
11877
 
11878
+ // src/plugins/babel-plugin.ts
11879
+ import * as babel from "@babel/core";
11880
+ var filter2 = /\.(js|ts|vue)$/;
11881
+ function babelPlugin() {
11882
+ return {
11883
+ name: "fk:babel",
11884
+ enforce: "post",
11885
+ apply: "build",
11886
+ async transform(src2, id) {
11887
+ const { pathname: filename } = new URL(id, "file://");
11888
+ if (!filter2.test(filename)) {
11889
+ return null;
11890
+ }
11891
+ const transformed = await babel.transformAsync(src2, {
11892
+ sourceMaps: true,
11893
+ comments: true,
11894
+ filename
11895
+ });
11896
+ if (!transformed) {
11897
+ return null;
11898
+ }
11899
+ const { code, map } = transformed;
11900
+ return {
11901
+ code: code ?? src2,
11902
+ map: map ?? null
11903
+ };
11904
+ }
11905
+ };
11906
+ }
11907
+
11908
+ // src/plugins/custom-mapping-plugin.ts
11909
+ var folder = {
11910
+ es: "esm",
11911
+ cjs: "cjs"
11912
+ };
11913
+ function customMappingPlugin() {
11914
+ return {
11915
+ name: "fk:custom-mapping",
11916
+ renderStart(options) {
11917
+ const { format } = options;
11918
+ if (format !== "es" && format !== "cjs") {
11919
+ return;
11920
+ }
11921
+ const replacement = folder[format];
11922
+ options.dir = options.dir?.replace("[custom-format]", replacement);
11923
+ if (typeof options.entryFileNames === "string") {
11924
+ options.entryFileNames = options.entryFileNames.replace(
11925
+ "[custom-format]",
11926
+ replacement
11927
+ );
11928
+ }
11929
+ }
11930
+ };
11931
+ }
11932
+
11933
+ // src/plugins/index-html-plugin.ts
11934
+ import fs3 from "node:fs/promises";
11935
+ import path3 from "node:path";
11936
+
11937
+ // src/utils/lookupFile.ts
11938
+ import fs2 from "node:fs";
11939
+ var extensions = ["ts", "mts", "mjs", "js"];
11940
+ function lookupFile(nameWithoutExtension) {
11941
+ for (const extension of extensions) {
11942
+ const fileName = `${nameWithoutExtension}.${extension}`;
11943
+ if (fs2.existsSync(fileName)) {
11944
+ return fileName;
11945
+ }
11946
+ }
11947
+ return `${nameWithoutExtension}.ts`;
11948
+ }
11949
+
11950
+ // src/plugins/index-html-plugin.ts
11951
+ var templateFile = path3.resolve(__dirname, "../assets/index.html");
11952
+ var VIRTUAL_ENTRYPOINT = "index.html";
11953
+ function isHtmlPage(url) {
11954
+ if (!url) {
11955
+ return false;
11956
+ }
11957
+ return url.startsWith(".html") || url === "/";
11958
+ }
11959
+ function middleware(server) {
11960
+ return async (req, res, next) => {
11961
+ const { url } = req;
11962
+ if (isHtmlPage(url)) {
11963
+ try {
11964
+ res.end(await server.transformIndexHtml(url, ""));
11965
+ } catch (err) {
11966
+ console.error(err);
11967
+ res.writeHead(500);
11968
+ res.end("Internal Server Error");
11969
+ }
11970
+ } else {
11971
+ return next();
11972
+ }
11973
+ };
11974
+ }
11975
+ function indexHtmlPlugin() {
11976
+ const templateData = {
11977
+ entrypoint: "/src/vite-dev/app.vue",
11978
+ entrypointLocal: `/${lookupFile("src/local")}`
11979
+ };
11980
+ return {
11981
+ name: "fk:virtual-entrypoint",
11982
+ resolveId: {
11983
+ order: "pre",
11984
+ handler(source) {
11985
+ const { base } = path3.parse(source);
11986
+ if (base === "index.html") {
11987
+ return VIRTUAL_ENTRYPOINT;
11988
+ }
11989
+ }
11990
+ },
11991
+ load: {
11992
+ order: "pre",
11993
+ handler(id) {
11994
+ if (id === VIRTUAL_ENTRYPOINT) {
11995
+ return "";
11996
+ }
11997
+ }
11998
+ },
11999
+ transformIndexHtml: {
12000
+ order: "pre",
12001
+ async handler() {
12002
+ const content = await fs3.readFile(templateFile, "utf-8");
12003
+ return content.replace(/{{([^}]+)}}/g, (match2, key) => {
12004
+ return templateData[key.trim()] ?? match2;
12005
+ });
12006
+ }
12007
+ },
12008
+ config(config) {
12009
+ if (config.fk?.entrypoint) {
12010
+ templateData.entrypoint = config.fk.entrypoint;
12011
+ }
12012
+ },
12013
+ configureServer(server) {
12014
+ server.middlewares.use(middleware(server));
12015
+ }
12016
+ };
12017
+ }
12018
+
12019
+ // src/plugins/package-json-plugin.ts
12020
+ var mapping = {
12021
+ es: "module",
12022
+ cjs: "commonjs"
12023
+ };
12024
+ function packageJsonPlugin() {
12025
+ return {
12026
+ name: "fk:package-json",
12027
+ generateBundle(options) {
12028
+ const { format } = options;
12029
+ if (format !== "es" && format !== "cjs") {
12030
+ return;
12031
+ }
12032
+ const pkg = {
12033
+ type: mapping[format]
12034
+ };
12035
+ this.emitFile({
12036
+ type: "asset",
12037
+ fileName: "package.json",
12038
+ source: JSON.stringify(pkg, null, 2)
12039
+ });
12040
+ }
12041
+ };
12042
+ }
12043
+
11332
12044
  // src/utils/read-json-file.ts
11333
12045
  import fs4 from "node:fs";
11334
12046
  function readJsonFile(filename) {
@@ -11497,6 +12209,28 @@ function vuePlugin2(config) {
11497
12209
  return vuePlugin(resolvedConfig);
11498
12210
  }
11499
12211
  }
12212
+ async function findEntrypoint(pattern) {
12213
+ const defaultEntrypoint = "/src/vite-dev/app.vue";
12214
+ if (!pattern) {
12215
+ return defaultEntrypoint;
12216
+ }
12217
+ const uf = new import_ufuzzy.default({ intraIns: Infinity });
12218
+ const files = await glob("**/*.vue", { posix: true, nodir: true });
12219
+ const idxs = uf.filter(files, pattern);
12220
+ if (!idxs || idxs.length === 0) {
12221
+ throw new Error(`No files matching "${pattern}"`);
12222
+ }
12223
+ const info = uf.info(idxs, files, pattern);
12224
+ const order = uf.sort(info, files, pattern);
12225
+ const matches = order.map((it) => files[info.idx[it]]);
12226
+ if (matches.length > 1) {
12227
+ console.error(
12228
+ `Multiple files matching "${pattern}", using first one from:`,
12229
+ matches
12230
+ );
12231
+ }
12232
+ return matches[0];
12233
+ }
11500
12234
  var vueMajor = detectVueMajor();
11501
12235
  var packageJson = readJsonFile("package.json");
11502
12236
  var dependencies = Object.keys(packageJson.dependencies ?? {});
@@ -11550,11 +12284,19 @@ var defaultConfig = {
11550
12284
  function overwriteMerge(_a, b) {
11551
12285
  return b;
11552
12286
  }
11553
- function defineConfig(config) {
11554
- const { mocks = [] } = config?.fk ?? {};
12287
+ async function defineConfig(config = {}) {
12288
+ const argv = process.argv.slice(2);
12289
+ const positional = argv.filter((it) => !it.startsWith("-"));
12290
+ config.fk ??= {};
12291
+ const { mocks = [] } = config.fk;
11555
12292
  if (mocks.length > 0) {
11556
12293
  defaultConfig.plugins.push(apimockPlugin(mocks));
11557
12294
  }
12295
+ const userEntrypoint = positional.length > 0 && !config.fk.entrypoint;
12296
+ if (userEntrypoint) {
12297
+ const entrypoint = await findEntrypoint(positional[0]);
12298
+ config.fk.entrypoint = `/${entrypoint}`;
12299
+ }
11558
12300
  let result;
11559
12301
  if (config) {
11560
12302
  result = (0, import_deepmerge.default)(
@@ -11580,6 +12322,9 @@ function defineConfig(config) {
11580
12322
  "Bundled dependencies:",
11581
12323
  prettyList(allDependencies, (it) => isBundled(external2, it))
11582
12324
  );
12325
+ if (userEntrypoint) {
12326
+ console.log("Entrypoint:", config.fk.entrypoint);
12327
+ }
11583
12328
  console.groupEnd();
11584
12329
  console.log();
11585
12330
  return result;