@ryuzaki13/react-foundation-lib 2.0.0 → 2.1.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.
@@ -0,0 +1,874 @@
1
+ import { z as e } from "zod";
2
+ import { createHash as t } from "node:crypto";
3
+ import { lstat as n, mkdir as r, readFile as i, readdir as a, realpath as o, rename as s, rm as c, stat as l, unlink as u, writeFile as d } from "node:fs/promises";
4
+ import f from "node:path";
5
+ //#region \0rolldown/runtime.js
6
+ var p = Object.create, m = Object.defineProperty, h = Object.getOwnPropertyDescriptor, g = Object.getOwnPropertyNames, _ = Object.getPrototypeOf, v = Object.prototype.hasOwnProperty, ee = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), te = (e, t, n, r) => {
7
+ if (t && typeof t == "object" || typeof t == "function") for (var i = g(t), a = 0, o = i.length, s; a < o; a++) s = i[a], !v.call(e, s) && s !== n && m(e, s, {
8
+ get: ((e) => t[e]).bind(null, s),
9
+ enumerable: !(r = h(t, s)) || r.enumerable
10
+ });
11
+ return e;
12
+ }, ne = (e, t, n) => (n = e == null ? {} : p(_(e)), te(t || !e || !e.__esModule || !v.call(e, "default") ? m(n, "default", {
13
+ value: e,
14
+ enumerable: !0
15
+ }) : n, e)), re = 1, y = /^[0-9a-f]{40}$/, ie = 2097152, b = 33554432, x = 268435456, ae = 83808e5, S = /^[a-z0-9]+(?:[.-][a-z0-9]+)*$/, oe = /^[0-9a-f]{64}$/;
16
+ function C(e) {
17
+ return !e || e.startsWith("/") || e.includes("\\") || e.includes("\0") ? !1 : e.split("/").every((e) => e !== "" && e !== "." && e !== "..");
18
+ }
19
+ function se(e, t) {
20
+ return e.includes("\\") || e.includes("\0") || e.includes("?") || e.includes("#") ? !1 : t === "client" ? e.startsWith("/") && C(e.slice(1)) : e.startsWith("server/") && C(e);
21
+ }
22
+ var ce = e.object({
23
+ kind: e.enum(["client", "server"]),
24
+ bundle: e.string().max(1024),
25
+ map: e.string().max(1024),
26
+ sha256: e.string().regex(oe),
27
+ size: e.number().int().positive().max(b)
28
+ }).strict().superRefine((e, t) => {
29
+ se(e.bundle, e.kind) || t.addIssue({
30
+ code: "custom",
31
+ path: ["bundle"],
32
+ message: "Bundle path должен быть нормализован."
33
+ }), (!C(e.map) || !e.map.startsWith(`${e.kind}/`) || !e.map.endsWith(".map")) && t.addIssue({
34
+ code: "custom",
35
+ path: ["map"],
36
+ message: "Map path должен оставаться внутри kind-каталога."
37
+ });
38
+ }), le = e.object({
39
+ version: e.literal(1),
40
+ application: e.string().min(1).max(128).regex(S),
41
+ buildId: e.string().regex(y),
42
+ createdUtc: e.iso.datetime({ offset: !0 }),
43
+ entries: e.array(ce).max(1e4)
44
+ }).strict().superRefine((e, t) => {
45
+ let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = 0;
46
+ for (let [a, o] of e.entries.entries()) n.has(o.bundle) && t.addIssue({
47
+ code: "custom",
48
+ path: [
49
+ "entries",
50
+ a,
51
+ "bundle"
52
+ ],
53
+ message: "Bundle должен быть уникальным."
54
+ }), r.has(o.map) && t.addIssue({
55
+ code: "custom",
56
+ path: [
57
+ "entries",
58
+ a,
59
+ "map"
60
+ ],
61
+ message: "Map path должен быть уникальным."
62
+ }), n.add(o.bundle), r.add(o.map), i += o.size;
63
+ i > 268435456 && t.addIssue({
64
+ code: "custom",
65
+ path: ["entries"],
66
+ message: "Private source-map artifact превышает общий предел."
67
+ });
68
+ });
69
+ function ue(e) {
70
+ let t = le.safeParse(e);
71
+ return t.success ? t.data : null;
72
+ }
73
+ function w(e) {
74
+ return typeof e == "string" && e.length <= 128 && S.test(e);
75
+ }
76
+ function T(e) {
77
+ return typeof e == "string" && y.test(e);
78
+ }
79
+ //#endregion
80
+ //#region src/error-report-source-maps/artifact.ts
81
+ var E = class extends Error {
82
+ constructor() {
83
+ super("Private source-map artifact не прошёл проверку целостности."), this.name = "PrivateSourceMapArtifactError";
84
+ }
85
+ };
86
+ function de(e) {
87
+ return e instanceof Error && "code" in e && e.code === "ENOENT";
88
+ }
89
+ function D(e, t) {
90
+ let n = f.relative(e, t);
91
+ return n !== "" && !n.startsWith("..") && !f.isAbsolute(n);
92
+ }
93
+ async function O(e, t, r) {
94
+ let a = await n(e);
95
+ if (!a.isFile() || a.isSymbolicLink() || a.size <= 0 || a.size > r) throw new E();
96
+ let s = await o(e);
97
+ if (!D(t, s)) throw new E();
98
+ let c = await i(s);
99
+ if (c.byteLength !== a.size) throw new E();
100
+ return c;
101
+ }
102
+ async function k(e, t, n) {
103
+ if (!w(t) || !T(n)) throw new E();
104
+ let r, i;
105
+ try {
106
+ r = await o(f.resolve(e)), i = await o(f.join(r, t, n));
107
+ } catch (e) {
108
+ if (de(e)) return null;
109
+ throw new E();
110
+ }
111
+ if (!D(r, i)) throw new E();
112
+ let a;
113
+ try {
114
+ a = await O(f.join(i, "manifest.json"), i, ie);
115
+ } catch (e) {
116
+ if (de(e)) return null;
117
+ throw e instanceof E ? e : new E();
118
+ }
119
+ let s;
120
+ try {
121
+ s = JSON.parse(a.toString("utf8"));
122
+ } catch {
123
+ throw new E();
124
+ }
125
+ let c = ue(s);
126
+ if (!c || c.application !== t || c.buildId !== n) throw new E();
127
+ return {
128
+ buildDirectory: i,
129
+ manifest: c,
130
+ entriesByBundle: new Map(c.entries.map((e) => [e.bundle, e]))
131
+ };
132
+ }
133
+ async function A(e, n) {
134
+ try {
135
+ let r = await O(f.join(e.buildDirectory, n.map), e.buildDirectory, n.size);
136
+ if (r.byteLength !== n.size || t("sha256").update(r).digest("hex") !== n.sha256) throw new E();
137
+ return r.toString("utf8");
138
+ } catch (e) {
139
+ throw e instanceof E ? e : new E();
140
+ }
141
+ }
142
+ //#endregion
143
+ //#region src/error-report-source-maps/archive.ts
144
+ var fe = 864e5;
145
+ async function pe(e, t, n, i) {
146
+ let a = f.join(f.resolve(t), n), o = f.join(a, i), l = f.join(a, `.${i}.tmp-${process.pid}`);
147
+ await r(a, { recursive: !0 }), await c(l, {
148
+ force: !0,
149
+ recursive: !0
150
+ }), await r(l, { recursive: !1 });
151
+ try {
152
+ for (let t of e.manifest.entries) {
153
+ let n = await A(e, t), i = f.join(l, t.map);
154
+ await r(f.dirname(i), { recursive: !0 }), await d(i, n, {
155
+ encoding: "utf8",
156
+ flag: "wx"
157
+ });
158
+ }
159
+ await d(f.join(l, "manifest.json"), `${JSON.stringify(e.manifest, null, 2)}\n`, {
160
+ encoding: "utf8",
161
+ flag: "wx"
162
+ }), await s(l, o);
163
+ } catch (e) {
164
+ if (await c(l, {
165
+ force: !0,
166
+ recursive: !0
167
+ }), !await k(t, n, i).catch(() => null)) throw e;
168
+ }
169
+ }
170
+ async function j(e) {
171
+ if (!T(e.buildId)) return;
172
+ await r(e.archiveRoot, { recursive: !0 });
173
+ let t = await k(e.archiveRoot, e.application, e.buildId), n = e.seedRoot ? await k(e.seedRoot, e.application, e.buildId) : null;
174
+ if (t && n && JSON.stringify(t.manifest.entries) !== JSON.stringify(n.manifest.entries)) throw Error("Persistent source-map artifact не совпадает с image seed для того же build ID.");
175
+ !t && n && await pe(n, e.archiveRoot, e.application, e.buildId);
176
+ let i = f.join(f.resolve(e.archiveRoot), e.application);
177
+ await r(i, { recursive: !0 });
178
+ let o = (e.now ?? (() => /* @__PURE__ */ new Date()))().getTime();
179
+ for (let t of await a(i, { withFileTypes: !0 })) if (!(!t.isDirectory() || !T(t.name) || t.name === e.buildId)) try {
180
+ let n = await k(e.archiveRoot, e.application, t.name);
181
+ if (!n) continue;
182
+ let r = Date.parse(n.manifest.createdUtc);
183
+ Number.isFinite(r) && r + 83808e5 <= o && await c(n.buildDirectory, { recursive: !0 });
184
+ } catch {}
185
+ }
186
+ function me(e) {
187
+ let t = () => void j(e).catch((t) => e.onError?.(t));
188
+ t();
189
+ let n = setInterval(t, fe);
190
+ return n.unref(), () => clearInterval(n);
191
+ }
192
+ //#endregion
193
+ //#region src/error-report-source-maps/package.ts
194
+ var he = /(?:\/\*[#@]\s*sourceMappingURL=[^*]*\*\/|\/\/[#@]\s*sourceMappingURL=.*)$/gm, M = /\.(?:css|html|js|mjs)$/, ge = /"(\/[^"\n]+\.map)"\s*:\s*\{/, N = ".private-source-maps-staging/client";
195
+ async function P(e) {
196
+ let t = [];
197
+ for (let n of await a(e, { withFileTypes: !0 })) {
198
+ let r = f.join(e, n.name);
199
+ if (n.isSymbolicLink()) throw Error(`Build output содержит недопустимую symbolic link: ${r}`);
200
+ n.isDirectory() ? t.push(...await P(r)) : n.isFile() && t.push(r);
201
+ }
202
+ return t.sort((e, t) => e.localeCompare(t));
203
+ }
204
+ function _e(e, t) {
205
+ if (e.byteLength === 0 || e.byteLength > 33554432) throw Error(`Source map выходит за предел ${b} bytes: ${t}`);
206
+ let n;
207
+ try {
208
+ n = JSON.parse(e.toString("utf8"));
209
+ } catch {
210
+ throw Error(`Source map содержит некорректный JSON: ${t}`);
211
+ }
212
+ if (!n || typeof n != "object" || !("version" in n) || n.version !== 3) throw Error(`Source map имеет неподдерживаемый формат: ${t}`);
213
+ let r = "sources" in n ? n.sources : void 0, i = "sourcesContent" in n ? n.sourcesContent : void 0;
214
+ if (!Array.isArray(r) || r.length > 0 && (!Array.isArray(i) || i.length !== r.length)) throw Error(`Source map не содержит полный sourcesContent: ${t}`);
215
+ }
216
+ function ve(e, t) {
217
+ let n = f.join(e, "public"), r = f.join(e, "server"), i = f.join(e, N), a = f.relative(n, t);
218
+ if (a && !a.startsWith("..") && !f.isAbsolute(a)) {
219
+ let e = a.split(f.sep).join("/");
220
+ return {
221
+ kind: "client",
222
+ bundle: `/${e.slice(0, -4)}`,
223
+ map: `client/${e}`
224
+ };
225
+ }
226
+ let o = f.relative(i, t);
227
+ if (o && !o.startsWith("..") && !f.isAbsolute(o)) {
228
+ let e = o.split(f.sep).join("/");
229
+ return {
230
+ kind: "client",
231
+ bundle: `/${e.slice(0, -4)}`,
232
+ map: `client/${e}`
233
+ };
234
+ }
235
+ let s = f.relative(r, t);
236
+ if (s && !s.startsWith("..") && !f.isAbsolute(s)) {
237
+ let e = s.split(f.sep).join("/");
238
+ return {
239
+ kind: "server",
240
+ bundle: `server/${e.slice(0, -4)}`,
241
+ map: `server/${e}`
242
+ };
243
+ }
244
+ throw Error(`Source map находится вне public/server output: ${t}`);
245
+ }
246
+ async function F(e) {
247
+ let t = await i(e, "utf8"), n = t.replace(he, "");
248
+ n !== t && await d(e, n, "utf8");
249
+ }
250
+ async function ye(e) {
251
+ let t = f.resolve(e), n = f.join(t, "public"), i = f.join(t, N), a = await P(n), o = a.filter((e) => e.endsWith(".map"));
252
+ for (let e of o) {
253
+ let t = f.relative(n, e), a = f.join(i, t);
254
+ await r(f.dirname(a), { recursive: !0 }), await s(e, a);
255
+ }
256
+ for (let e of a) !e.endsWith(".map") && M.test(e) && await F(e);
257
+ return o.length;
258
+ }
259
+ async function I(e) {
260
+ let t = await i(e, "utf8"), n = ge.exec(t)?.[1];
261
+ if (n) throw Error(`Nitro static asset manifest содержит source map: ${n}`);
262
+ }
263
+ async function L(e) {
264
+ for (let t of await P(e)) {
265
+ if (t.endsWith(".map")) throw Error(`Public output содержит source map: ${t}`);
266
+ if (M.test(t) && (await i(t, "utf8")).includes("sourceMappingURL")) throw Error(`Public output содержит sourceMappingURL: ${t}`);
267
+ }
268
+ }
269
+ async function be(e) {
270
+ if (!w(e.application) || !T(e.buildId)) throw Error("Application или build ID private source-map artifact недопустим.");
271
+ let n = f.resolve(e.outputRoot), a = f.resolve(e.artifactRoot), o = f.join(a, e.application, e.buildId), p = `${o}.tmp-${process.pid}`, m = await P(n), h = m.filter((e) => e.endsWith(".map"));
272
+ if (h.length === 0) throw Error("Production build не создал private source maps.");
273
+ await c(p, {
274
+ force: !0,
275
+ recursive: !0
276
+ }), await r(p, { recursive: !0 });
277
+ let g = [], _ = 0;
278
+ try {
279
+ for (let e of h) {
280
+ let a = await i(e);
281
+ if (_e(a, e), _ += a.byteLength, _ > 268435456) throw Error(`Private source-map artifact превышает ${x} bytes.`);
282
+ let o = ve(n, e), s = f.join(p, o.map);
283
+ await r(f.dirname(s), { recursive: !0 }), await d(s, a, { flag: "wx" }), g.push({
284
+ ...o,
285
+ sha256: t("sha256").update(a).digest("hex"),
286
+ size: a.byteLength
287
+ });
288
+ }
289
+ if (!g.some((e) => e.kind === "client")) throw Error("Private source-map artifact не содержит client maps.");
290
+ if (!g.some((e) => e.kind === "server")) throw Error("Private source-map artifact не содержит server maps.");
291
+ g.sort((e, t) => e.bundle.localeCompare(t.bundle));
292
+ let a = {
293
+ version: 1,
294
+ application: e.application,
295
+ buildId: e.buildId,
296
+ createdUtc: e.createdUtc ?? (/* @__PURE__ */ new Date()).toISOString(),
297
+ entries: g
298
+ };
299
+ await d(f.join(p, "manifest.json"), `${JSON.stringify(a, null, 2)}\n`, {
300
+ encoding: "utf8",
301
+ flag: "wx"
302
+ }), await c(o, {
303
+ force: !0,
304
+ recursive: !0
305
+ }), await r(f.dirname(o), { recursive: !0 }), await s(p, o);
306
+ for (let e of h) await u(e);
307
+ for (let e of m) !e.endsWith(".map") && M.test(e) && await F(e);
308
+ if (await L(f.join(n, "public")), await I(f.join(n, "server/index.mjs")), !(await l(f.join(o, "manifest.json"))).isFile()) throw Error("Private source-map manifest не был создан.");
309
+ return a;
310
+ } catch (e) {
311
+ throw await c(p, {
312
+ force: !0,
313
+ recursive: !0
314
+ }), e;
315
+ }
316
+ }
317
+ //#endregion
318
+ //#region node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs
319
+ var xe = 44, R = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", Se = /* @__PURE__ */ new Uint8Array(64), z = /* @__PURE__ */ new Uint8Array(128);
320
+ for (let e = 0; e < R.length; e++) {
321
+ let t = R.charCodeAt(e);
322
+ Se[e] = t, z[t] = e;
323
+ }
324
+ function B(e, t) {
325
+ let n = 0, r = 0, i = 0;
326
+ do
327
+ i = z[e.next()], n |= (i & 31) << r, r += 5;
328
+ while (i & 32);
329
+ let a = n & 1;
330
+ return n >>>= 1, a && (n = -2147483648 | -n), t + n;
331
+ }
332
+ function V(e, t) {
333
+ return e.pos >= t ? !1 : e.peek() !== xe;
334
+ }
335
+ var Ce = class {
336
+ constructor(e) {
337
+ this.pos = 0, this.buffer = e;
338
+ }
339
+ next() {
340
+ return this.buffer.charCodeAt(this.pos++);
341
+ }
342
+ peek() {
343
+ return this.buffer.charCodeAt(this.pos);
344
+ }
345
+ indexOf(e) {
346
+ let { buffer: t, pos: n } = this, r = t.indexOf(e, n);
347
+ return r === -1 ? t.length : r;
348
+ }
349
+ };
350
+ function we(e) {
351
+ let { length: t } = e, n = new Ce(e), r = [], i = 0, a = 0, o = 0, s = 0, c = 0;
352
+ do {
353
+ let e = n.indexOf(";"), t = [], l = !0, u = 0;
354
+ for (i = 0; n.pos < e;) {
355
+ let r;
356
+ i = B(n, i), i < u && (l = !1), u = i, V(n, e) ? (a = B(n, a), o = B(n, o), s = B(n, s), V(n, e) ? (c = B(n, c), r = [
357
+ i,
358
+ a,
359
+ o,
360
+ s,
361
+ c
362
+ ]) : r = [
363
+ i,
364
+ a,
365
+ o,
366
+ s
367
+ ]) : r = [i], t.push(r), n.pos++;
368
+ }
369
+ l || Te(t), r.push(t), n.pos = e + 1;
370
+ } while (n.pos <= t);
371
+ return r;
372
+ }
373
+ function Te(e) {
374
+ e.sort(Ee);
375
+ }
376
+ function Ee(e, t) {
377
+ return e[0] - t[0];
378
+ }
379
+ //#endregion
380
+ //#region node_modules/@jridgewell/trace-mapping/dist/trace-mapping.mjs
381
+ var De = /* @__PURE__ */ ne((/* @__PURE__ */ ee(((e, t) => {
382
+ (function(n, r) {
383
+ typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self, n.resolveURI = r());
384
+ })(e, (function() {
385
+ let e = /^[\w+.-]+:\/\//, t = /^([\w+.-]+:)\/\/([^@/#?]*@)?([^:/#?]*)(:\d+)?(\/[^#?]*)?(\?[^#]*)?(#.*)?/, n = /^file:(?:\/\/((?![a-z]:)[^/#?]*)?)?(\/?[^#?]*)(\?[^#]*)?(#.*)?/i;
386
+ function r(t) {
387
+ return e.test(t);
388
+ }
389
+ function i(e) {
390
+ return e.startsWith("//");
391
+ }
392
+ function a(e) {
393
+ return e.startsWith("/");
394
+ }
395
+ function o(e) {
396
+ return e.startsWith("file:");
397
+ }
398
+ function s(e) {
399
+ return /^[.?#]/.test(e);
400
+ }
401
+ function c(e) {
402
+ let n = t.exec(e);
403
+ return u(n[1], n[2] || "", n[3], n[4] || "", n[5] || "/", n[6] || "", n[7] || "");
404
+ }
405
+ function l(e) {
406
+ let t = n.exec(e), r = t[2];
407
+ return u("file:", "", t[1] || "", "", a(r) ? r : "/" + r, t[3] || "", t[4] || "");
408
+ }
409
+ function u(e, t, n, r, i, a, o) {
410
+ return {
411
+ scheme: e,
412
+ user: t,
413
+ host: n,
414
+ port: r,
415
+ path: i,
416
+ query: a,
417
+ hash: o,
418
+ type: 7
419
+ };
420
+ }
421
+ function d(e) {
422
+ if (i(e)) {
423
+ let t = c("http:" + e);
424
+ return t.scheme = "", t.type = 6, t;
425
+ }
426
+ if (a(e)) {
427
+ let t = c("http://foo.com" + e);
428
+ return t.scheme = "", t.host = "", t.type = 5, t;
429
+ }
430
+ if (o(e)) return l(e);
431
+ if (r(e)) return c(e);
432
+ let t = c("http://foo.com/" + e);
433
+ return t.scheme = "", t.host = "", t.type = e ? e.startsWith("?") ? 3 : e.startsWith("#") ? 2 : 4 : 1, t;
434
+ }
435
+ function f(e) {
436
+ if (e.endsWith("/..")) return e;
437
+ let t = e.lastIndexOf("/");
438
+ return e.slice(0, t + 1);
439
+ }
440
+ function p(e, t) {
441
+ m(t, t.type), e.path = e.path === "/" ? t.path : f(t.path) + e.path;
442
+ }
443
+ function m(e, t) {
444
+ let n = t <= 4, r = e.path.split("/"), i = 1, a = 0, o = !1;
445
+ for (let e = 1; e < r.length; e++) {
446
+ let t = r[e];
447
+ if (!t) {
448
+ o = !0;
449
+ continue;
450
+ }
451
+ if (o = !1, t !== ".") {
452
+ if (t === "..") {
453
+ a ? (o = !0, a--, i--) : n && (r[i++] = t);
454
+ continue;
455
+ }
456
+ r[i++] = t, a++;
457
+ }
458
+ }
459
+ let s = "";
460
+ for (let e = 1; e < i; e++) s += "/" + r[e];
461
+ (!s || o && !s.endsWith("/..")) && (s += "/"), e.path = s;
462
+ }
463
+ function h(e, t) {
464
+ if (!e && !t) return "";
465
+ let n = d(e), r = n.type;
466
+ if (t && r !== 7) {
467
+ let e = d(t), i = e.type;
468
+ switch (r) {
469
+ case 1: n.hash = e.hash;
470
+ case 2: n.query = e.query;
471
+ case 3:
472
+ case 4: p(n, e);
473
+ case 5: n.user = e.user, n.host = e.host, n.port = e.port;
474
+ case 6: n.scheme = e.scheme;
475
+ }
476
+ i > r && (r = i);
477
+ }
478
+ m(n, r);
479
+ let i = n.query + n.hash;
480
+ switch (r) {
481
+ case 2:
482
+ case 3: return i;
483
+ case 4: {
484
+ let r = n.path.slice(1);
485
+ return r ? s(t || e) && !s(r) ? "./" + r + i : r + i : i || ".";
486
+ }
487
+ case 5: return n.path + i;
488
+ default: return n.scheme + "//" + n.user + n.host + n.port + n.path + i;
489
+ }
490
+ }
491
+ return h;
492
+ }));
493
+ })))(), 1);
494
+ function Oe(e) {
495
+ if (!e) return "";
496
+ let t = e.lastIndexOf("/");
497
+ return e.slice(0, t + 1);
498
+ }
499
+ function ke(e, t) {
500
+ let n = Oe(e), r = t ? t + "/" : "";
501
+ return (e) => (0, De.default)(r + (e || ""), n);
502
+ }
503
+ var H = 0, U = 1, W = 2, G = 3, K = 4;
504
+ function Ae(e, t) {
505
+ let n = q(e, 0);
506
+ if (n === e.length) return e;
507
+ t || (e = e.slice());
508
+ for (let r = n; r < e.length; r = q(e, r + 1)) e[r] = Me(e[r], t);
509
+ return e;
510
+ }
511
+ function q(e, t) {
512
+ for (let n = t; n < e.length; n++) if (!je(e[n])) return n;
513
+ return e.length;
514
+ }
515
+ function je(e) {
516
+ for (let t = 1; t < e.length; t++) if (e[t][H] < e[t - 1][H]) return !1;
517
+ return !0;
518
+ }
519
+ function Me(e, t) {
520
+ return t || (e = e.slice()), e.sort(Ne);
521
+ }
522
+ function Ne(e, t) {
523
+ return e[H] - t[H];
524
+ }
525
+ var J = !1;
526
+ function Pe(e, t, n, r) {
527
+ for (; n <= r;) {
528
+ let i = n + (r - n >> 1), a = e[i][H] - t;
529
+ if (a === 0) return J = !0, i;
530
+ a < 0 ? n = i + 1 : r = i - 1;
531
+ }
532
+ return J = !1, n - 1;
533
+ }
534
+ function Fe(e, t, n) {
535
+ for (let r = n + 1; r < e.length && e[r][H] === t; n = r++);
536
+ return n;
537
+ }
538
+ function Ie(e, t, n) {
539
+ for (let r = n - 1; r >= 0 && e[r][H] === t; n = r--);
540
+ return n;
541
+ }
542
+ function Le() {
543
+ return {
544
+ lastKey: -1,
545
+ lastNeedle: -1,
546
+ lastIndex: -1
547
+ };
548
+ }
549
+ function Re(e, t, n, r) {
550
+ let { lastKey: i, lastNeedle: a, lastIndex: o } = n, s = 0, c = e.length - 1;
551
+ if (r === i) {
552
+ if (t === a) return J = o !== -1 && e[o][H] === t, o;
553
+ t >= a ? s = o === -1 ? 0 : o : c = o;
554
+ }
555
+ return n.lastKey = r, n.lastNeedle = t, n.lastIndex = Pe(e, t, s, c);
556
+ }
557
+ function Y(e) {
558
+ return typeof e == "string" ? JSON.parse(e) : e;
559
+ }
560
+ var ze = function(e, t) {
561
+ let n = Y(e);
562
+ if (!("sections" in n)) return new Z(n, t);
563
+ let r = [], i = [], a = [], o = [], s = [];
564
+ return Be(n, t, r, i, a, o, s, 0, 0, Infinity, Infinity), Ye({
565
+ version: 3,
566
+ file: n.file,
567
+ names: o,
568
+ sources: i,
569
+ sourcesContent: a,
570
+ mappings: r,
571
+ ignoreList: s
572
+ });
573
+ };
574
+ function Be(e, t, n, r, i, a, o, s, c, l, u) {
575
+ let { sections: d } = e;
576
+ for (let e = 0; e < d.length; e++) {
577
+ let { map: f, offset: p } = d[e], m = l, h = u;
578
+ if (e + 1 < d.length) {
579
+ let t = d[e + 1].offset;
580
+ m = Math.min(l, s + t.line), m === l ? h = Math.min(u, c + t.column) : m < l && (h = c + t.column);
581
+ }
582
+ Ve(f, t, n, r, i, a, o, s + p.line, c + p.column, m, h);
583
+ }
584
+ }
585
+ function Ve(e, t, n, r, i, a, o, s, c, l, u) {
586
+ let d = Y(e);
587
+ if ("sections" in d) return Be(...arguments);
588
+ let f = new Z(d, t), p = r.length, m = a.length, h = Ge(f), { resolvedSources: g, sourcesContent: _, ignoreList: v } = f;
589
+ if (X(r, g), X(a, f.names), _) X(i, _);
590
+ else for (let e = 0; e < g.length; e++) i.push(null);
591
+ if (v) for (let e = 0; e < v.length; e++) o.push(v[e] + p);
592
+ for (let e = 0; e < h.length; e++) {
593
+ let t = s + e;
594
+ if (t > l) return;
595
+ let r = He(n, t), i = e === 0 ? c : 0, a = h[e];
596
+ for (let e = 0; e < a.length; e++) {
597
+ let n = a[e], o = i + n[H];
598
+ if (t === l && o >= u) return;
599
+ if (n.length === 1) {
600
+ r.push([o]);
601
+ continue;
602
+ }
603
+ let s = p + n[U], c = n[W], d = n[G];
604
+ r.push(n.length === 4 ? [
605
+ o,
606
+ s,
607
+ c,
608
+ d
609
+ ] : [
610
+ o,
611
+ s,
612
+ c,
613
+ d,
614
+ m + n[K]
615
+ ]);
616
+ }
617
+ }
618
+ }
619
+ function X(e, t) {
620
+ for (let n = 0; n < t.length; n++) e.push(t[n]);
621
+ }
622
+ function He(e, t) {
623
+ for (let n = e.length; n <= t; n++) e[n] = [];
624
+ return e[t];
625
+ }
626
+ var Ue = "`line` must be greater than 0 (lines start at line 1)", We = "`column` must be greater than or equal to 0 (columns start at column 0)", Z = class {
627
+ constructor(e, t) {
628
+ let n = typeof e == "string";
629
+ if (!n && e._decodedMemo) return e;
630
+ let r = Y(e), { version: i, file: a, names: o, sourceRoot: s, sources: c, sourcesContent: l } = r;
631
+ this.version = i, this.file = a, this.names = o || [], this.sourceRoot = s, this.sources = c, this.sourcesContent = l, this.ignoreList = r.ignoreList || r.x_google_ignoreList || void 0;
632
+ let u = ke(t, s);
633
+ this.resolvedSources = c.map(u);
634
+ let { mappings: d } = r;
635
+ if (typeof d == "string") this._encoded = d, this._decoded = void 0;
636
+ else if (Array.isArray(d)) this._encoded = void 0, this._decoded = Ae(d, n);
637
+ else if (r.sections) throw Error("TraceMap passed sectioned source map, please use FlattenMap export instead");
638
+ else throw Error(`invalid source map: ${JSON.stringify(r)}`);
639
+ this._decodedMemo = Le(), this._bySources = void 0, this._bySourceMemos = void 0;
640
+ }
641
+ };
642
+ function Q(e) {
643
+ return e;
644
+ }
645
+ function Ge(e) {
646
+ var t;
647
+ return (t = Q(e))._decoded || (t._decoded = we(Q(e)._encoded));
648
+ }
649
+ function Ke(e, t) {
650
+ let { line: n, column: r, bias: i } = t;
651
+ if (n--, n < 0) throw Error(Ue);
652
+ if (r < 0) throw Error(We);
653
+ let a = Ge(e);
654
+ if (n >= a.length) return $(null, null, null, null);
655
+ let o = a[n], s = Ze(o, Q(e)._decodedMemo, n, r, i || 1);
656
+ if (s === -1) return $(null, null, null, null);
657
+ let c = o[s];
658
+ if (c.length === 1) return $(null, null, null, null);
659
+ let { names: l, resolvedSources: u } = e;
660
+ return $(u[c[U]], c[W] + 1, c[G], c.length === 5 ? l[c[K]] : null);
661
+ }
662
+ function qe(e, t) {
663
+ let { sources: n, resolvedSources: r } = e, i = n.indexOf(t);
664
+ return i === -1 && (i = r.indexOf(t)), i;
665
+ }
666
+ function Je(e, t) {
667
+ let { sourcesContent: n } = e;
668
+ if (n == null) return null;
669
+ let r = qe(e, t);
670
+ return r === -1 ? null : n[r];
671
+ }
672
+ function Ye(e, t) {
673
+ let n = new Z(Xe(e, []), t);
674
+ return Q(n)._decoded = e.mappings, n;
675
+ }
676
+ function Xe(e, t) {
677
+ return {
678
+ version: e.version,
679
+ file: e.file,
680
+ names: e.names,
681
+ sourceRoot: e.sourceRoot,
682
+ sources: e.sources,
683
+ sourcesContent: e.sourcesContent,
684
+ mappings: t,
685
+ ignoreList: e.ignoreList || e.x_google_ignoreList
686
+ };
687
+ }
688
+ function $(e, t, n, r) {
689
+ return {
690
+ source: e,
691
+ line: t,
692
+ column: n,
693
+ name: r
694
+ };
695
+ }
696
+ function Ze(e, t, n, r, i) {
697
+ let a = Re(e, r, t, n);
698
+ return J ? a = (i === -1 ? Fe : Ie)(e, r, a) : i === -1 && a++, a === -1 || a === e.length ? -1 : a;
699
+ }
700
+ //#endregion
701
+ //#region src/error-report-source-maps/symbolicate.ts
702
+ var Qe = 40, $e = 10, et = 2, tt = 500, nt = 262144;
703
+ function rt(e) {
704
+ let t = Number(e);
705
+ return Number.isSafeInteger(t) && t > 0 ? t : null;
706
+ }
707
+ function it(e) {
708
+ return e?.trim().replace(/^async\s+/, "").slice(0, 256) || void 0;
709
+ }
710
+ function at(e) {
711
+ try {
712
+ return new URL(e).pathname;
713
+ } catch {
714
+ return null;
715
+ }
716
+ }
717
+ function ot(e) {
718
+ let t = e.replace(/[?#].*$/, "").replaceAll("\\", "/"), n = (at(t) ?? t).replaceAll("\\", "/");
719
+ if (n.startsWith("/static/") || n === "/sw.js" || n === "/sw.mjs" || n.startsWith("server/")) return n;
720
+ let r = n.lastIndexOf("/server/");
721
+ return r >= 0 ? `server/${n.slice(r + 8)}` : null;
722
+ }
723
+ function st(e, t) {
724
+ let n = /^\s*at\s+(.+?)\s+\((.+):(\d+):(\d+)\)\s*$/.exec(e), r = /^\s*at\s+(.+):(\d+):(\d+)\s*$/.exec(e), i = /^([^@]*)@(.+):(\d+):(\d+)\s*$/.exec(e), a = n ?? r ?? i;
725
+ if (!a) return null;
726
+ let o = a === n, s = a === i, c = o || s ? 2 : 1, l = a[c], u = a[c + 1] ? rt(a[c + 1]) : null, d = a[c + 2] ? rt(a[c + 2]) : null;
727
+ if (!l || u === null || d === null) return null;
728
+ let f = ot(l);
729
+ return f ? {
730
+ lineIndex: t,
731
+ style: s ? "safari" : "chromium",
732
+ functionName: it(o || s ? a[1] : void 0),
733
+ source: l,
734
+ line: u,
735
+ column: d,
736
+ bundle: f
737
+ } : null;
738
+ }
739
+ function ct(e) {
740
+ let t = e.replaceAll("\\", "/").replace(/[?#].*$/, "").replaceAll("\0", "");
741
+ for (let e of [
742
+ "/src/",
743
+ "/config/",
744
+ "/scripts/",
745
+ "/node_modules/"
746
+ ]) {
747
+ let n = t.lastIndexOf(e);
748
+ if (n >= 0) return t.slice(n + 1).slice(0, 1024);
749
+ }
750
+ for (let e of [
751
+ "src/",
752
+ "config/",
753
+ "scripts/",
754
+ "node_modules/"
755
+ ]) {
756
+ let n = t.indexOf(e);
757
+ if (n >= 0) return t.slice(n).slice(0, 1024);
758
+ }
759
+ return `source/${(t.split("/").filter(Boolean).at(-1) ?? "unknown-source").slice(0, 512)}`;
760
+ }
761
+ function lt(e, t, n) {
762
+ let r = Je(e, t);
763
+ if (r === null) return;
764
+ let i = r.split(/\r?\n/), a = Math.max(1, n - et), o = Math.min(i.length, n + et);
765
+ return Array.from({ length: o - a + 1 }, (e, t) => {
766
+ let r = a + t;
767
+ return {
768
+ line: r,
769
+ content: (i[r - 1] ?? "").slice(0, tt),
770
+ focus: r === n
771
+ };
772
+ });
773
+ }
774
+ function ut(e, t) {
775
+ let n = t.original;
776
+ if (!n) return "";
777
+ let r = n.name ?? e.functionName, i = `${n.source}:${n.line}:${n.column}`;
778
+ return e.style === "safari" ? `${r ?? "global code"}@${i}` : r ? ` at ${r} (${i})` : ` at ${i}`;
779
+ }
780
+ async function dt(e, t, n) {
781
+ for (let r of e) {
782
+ let e = await k(r, t, n);
783
+ if (e) return e;
784
+ }
785
+ return null;
786
+ }
787
+ function ft() {
788
+ return [process.env.ERROR_REPORT_SOURCE_MAP_SEED_ROOT, process.env.ERROR_REPORT_SOURCE_MAP_ROOT].filter((e) => !!e);
789
+ }
790
+ async function pt(e, t, n, r = {}) {
791
+ if (!n?.trim()) return { status: "not-required" };
792
+ let i = n.split("\n"), a = i.map(st).filter((e) => e !== null);
793
+ if (a.length === 0) return { status: "not-required" };
794
+ let o = a.slice(0, Qe), s = o.map((e) => ({
795
+ ...e.functionName ? { functionName: e.functionName } : {},
796
+ generated: {
797
+ source: e.bundle,
798
+ line: e.line,
799
+ column: e.column
800
+ }
801
+ }));
802
+ try {
803
+ let n = await dt(r.artifactRoots ?? ft(), e, t);
804
+ if (!n) return {
805
+ status: "maps-unavailable",
806
+ frames: s
807
+ };
808
+ let c = /* @__PURE__ */ new Map(), l = [], u = a.length > Qe, d = 0;
809
+ for (let e of o) {
810
+ let t = n.entriesByBundle.get(e.bundle);
811
+ if (!t) {
812
+ u = !0, l.push({
813
+ ...e.functionName ? { functionName: e.functionName } : {},
814
+ generated: {
815
+ source: e.bundle,
816
+ line: e.line,
817
+ column: e.column
818
+ }
819
+ });
820
+ continue;
821
+ }
822
+ let r = c.get(t.map);
823
+ r || (r = new ze(await A(n, t), t.map), c.set(t.map, r));
824
+ let a = Ke(r, {
825
+ line: e.line,
826
+ column: e.column - 1
827
+ });
828
+ if (a.source === null || a.line === null || a.column === null) {
829
+ u = !0, l.push({
830
+ ...e.functionName ? { functionName: e.functionName } : {},
831
+ generated: {
832
+ source: e.bundle,
833
+ line: e.line,
834
+ column: e.column
835
+ }
836
+ });
837
+ continue;
838
+ }
839
+ let o = d < $e ? lt(r, a.source, a.line) : void 0;
840
+ o && (d += 1);
841
+ let s = {
842
+ ...e.functionName ? { functionName: e.functionName } : {},
843
+ generated: {
844
+ source: e.bundle,
845
+ line: e.line,
846
+ column: e.column
847
+ },
848
+ original: {
849
+ source: ct(a.source),
850
+ line: a.line,
851
+ column: a.column + 1,
852
+ ...a.name ? { name: a.name.slice(0, 256) } : {}
853
+ },
854
+ ...o ? { sourceContext: o } : {}
855
+ };
856
+ l.push(s), i[e.lineIndex] = ut(e, s);
857
+ }
858
+ let f = l.some((e) => e.original !== void 0);
859
+ return {
860
+ status: u || !f ? "failed" : "resolved",
861
+ ...f ? { stackTrace: i.join("\n").slice(0, nt) } : {},
862
+ frames: l
863
+ };
864
+ } catch {
865
+ return {
866
+ status: "failed",
867
+ frames: s
868
+ };
869
+ }
870
+ }
871
+ //#endregion
872
+ export { y as ERROR_REPORT_BUILD_ID_PATTERN, x as PRIVATE_SOURCE_MAP_ARTIFACT_MAX_BYTES, ae as PRIVATE_SOURCE_MAP_ARTIFACT_RETENTION_MS, ie as PRIVATE_SOURCE_MAP_MANIFEST_MAX_BYTES, re as PRIVATE_SOURCE_MAP_MANIFEST_VERSION, b as PRIVATE_SOURCE_MAP_MAX_BYTES, E as PrivateSourceMapArtifactError, N as STAGED_CLIENT_SOURCE_MAP_DIRECTORY, I as assertNoNitroSourceMapManifestLeaks, L as assertNoPublicSourceMapLeaks, T as isErrorReportBuildId, w as isPrivateSourceMapApplicationId, k as loadPrivateSourceMapArtifact, j as maintainPrivateSourceMapArchive, be as packageErrorReportSourceMaps, ue as parsePrivateSourceMapManifest, A as readPrivateSourceMap, ye as stageClientSourceMapsForNitro, me as startPrivateSourceMapArchiveMaintenance, pt as symbolicateErrorReportStack };
873
+
874
+ //# sourceMappingURL=index.js.map