@nimtech/nimpress 2.10.3 → 2.10.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimtech/nimpress",
3
- "version": "2.10.3",
3
+ "version": "2.10.4",
4
4
  "description": "Svelte 5 docs framework that supports it all.",
5
5
  "author": "nimling",
6
6
  "license": "Apache-2.0",
@@ -1,538 +0,0 @@
1
- function M(t) {
2
- const n = String(t ?? "/").trim();
3
- if (!n || n === "/") return "/";
4
- const e = n.startsWith("/") ? n : `/${n}`;
5
- return e.endsWith("/") ? e : `${e}/`;
6
- }
7
- function Mt(t, n) {
8
- const e = M(t);
9
- return e === "/" || !n.startsWith("/") || n.startsWith("//") || n === e.slice(0, -1) || n.startsWith(e) ? n : e.slice(0, -1) + n;
10
- }
11
- function Ct(t, n) {
12
- const e = M(t);
13
- return e === "/" ? n : n === e.slice(0, -1) ? "/" : n.startsWith(e) ? "/" + n.slice(e.length) : n;
14
- }
15
- const H = ["Luke Skywalker", "Leia Organa", "Han Solo", "Obi-Wan Kenobi", "Ahsoka Tano", "Lando Calrissian", "Din Djarin", "Padmé Amidala"], C = ["Luke", "Leia", "Han", "Ahsoka", "Din", "Padmé", "Lando", "Obi-Wan"], R = ["Skywalker", "Organa", "Solo", "Kenobi", "Tano", "Calrissian", "Amidala", "Djarin"], z = ["Tatooine", "Coruscant", "Endor", "Hoth", "Naboo", "Dagobah", "Mos Eisley", "Bespin"], E = ["Millennium Falcon", "X-Wing", "Razor Crest", "Lightsaber", "Holocron", "Beskar Ingot", "Astromech Droid", "Sarlacc Pit"], g = [
16
- "Bantha fodder drifts across the dune sea beyond Mos Eisley.",
17
- "A hyperdrive hums softly as the freighter clears the asteroid field.",
18
- "Womp rats scatter when the landspeeder skims Beggar’s Canyon.",
19
- "The council convened on Coruscant to debate the blockade of Naboo.",
20
- "Moisture vaporators line the ridge above the homestead on Tatooine.",
21
- "A protocol droid recites etiquette while the astromech beeps in protest.",
22
- "Snow swirls over the shield generator on the plains of Hoth.",
23
- "The cantina band strikes up as smugglers haggle over spice."
24
- ], k = ["bantha", "kyber", "hyperdrive", "womp-rat", "sabacc", "holocron", "beskar", "porg"], U = ["leia.organa@rebellion.org", "luke.skywalker@jedi.temple", "han.solo@falcon.crew", "ahsoka.tano@fulcrum.net"], Z = ["#ffe81f", "#2e67f8", "#e5484d", "#30a46c", "#8a63d2"];
25
- function P(t) {
26
- let n = 0;
27
- for (let e = 0; e < t.length; e++) n = n * 31 + t.charCodeAt(e) >>> 0;
28
- return n;
29
- }
30
- function f(t, n = 0) {
31
- return t[(P(String(n)) + n) % t.length];
32
- }
33
- function V(t) {
34
- return !!t && typeof t == "object" && typeof t.__nimpressFn == "string";
35
- }
36
- function A(t) {
37
- return `(...args) => {
38
- console.log(${JSON.stringify(t || "handler")}, ...args)
39
- }`;
40
- }
41
- const K = (t = 0) => f(H, t), X = (t = 0) => f(C, t), Y = (t = 0) => f(R, t), G = (t = 0) => `${f(C, t).toLowerCase()}_${f(k, t + 1)}`, Q = (t = 0) => f(U, t), tt = (t = 0) => `${f(k, t)}-${f(E, t + 1).replace(/\s+/g, "")}`, I = (t = 0) => f(k, t), nt = (t = 0) => f(E, t), T = (t = 0) => f(g, t), et = (t = 0) => `${f(g, t)} ${f(g, t + 1)} ${f(g, t + 2)}`, rt = (t = 0) => f(z, t), ot = (t = 0) => `https://holonet.example/${f(k, t)}`, it = (t = 0) => `https://holonet.example/${f(k, t)}.png`, st = (t = 0) => f(Z, t), at = () => "pi pi-star", ut = () => "1977-05-25", mt = () => "09:41", ct = () => "+47 555 01138", ft = (t = 0) => `${f(k, t)}-1138`, lt = (t = 0) => f(k, t), dt = (t = 0) => ({
42
- [f(k, t)]: f(g, t),
43
- [f(k, t + 3)]: f(g, t + 3)
44
- }), kt = (t = 0) => [f(k, t), f(k, t + 3)], pt = () => !0, yt = () => 42, bt = () => 0, gt = () => 1.618, ht = () => 7, $t = () => 66, vt = () => 320, jt = () => 240, wt = () => 199, xt = () => 1977, Ot = () => 29, St = (t = [], n = 0, e = []) => {
45
- const o = t.filter((r) => !e.includes(r));
46
- return o.length ? o[(P(String(n)) + n) % o.length] : void 0;
47
- }, B = (t = "handler") => ({
48
- __nimpressFn: A(t)
49
- }), Tt = (t = "event") => B(t), At = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
50
- __proto__: null,
51
- fnSource: A,
52
- isFnValue: V,
53
- mockAge: Ot,
54
- mockArray: kt,
55
- mockBoolean: pt,
56
- mockColor: st,
57
- mockCount: ht,
58
- mockDate: ut,
59
- mockEmail: Q,
60
- mockEvent: Tt,
61
- mockFamilyName: Y,
62
- mockFirstName: X,
63
- mockFloat: gt,
64
- mockFullName: K,
65
- mockFunction: B,
66
- mockHeight: jt,
67
- mockIcon: at,
68
- mockId: ft,
69
- mockImageUrl: it,
70
- mockIndex: bt,
71
- mockInt: yt,
72
- mockObject: dt,
73
- mockOption: St,
74
- mockParagraph: et,
75
- mockPassword: tt,
76
- mockPercent: $t,
77
- mockPhone: ct,
78
- mockPlace: rt,
79
- mockPrice: wt,
80
- mockSentence: T,
81
- mockSlug: lt,
82
- mockTime: mt,
83
- mockTitle: nt,
84
- mockUrl: ot,
85
- mockUsername: G,
86
- mockWidth: vt,
87
- mockWord: I,
88
- mockYear: xt
89
- }, Symbol.toStringTag, { value: "Module" })), O = 12;
90
- function Wt(t) {
91
- const n = {}, e = (c, l) => {
92
- const p = t.match(new RegExp(`@${c}\\s+(-?[0-9.]+)`));
93
- p && (n[l] = Number(p[1]));
94
- };
95
- e("minimum", "minimum"), e("maximum", "maximum"), e("exclusiveMinimum", "exclusiveMinimum"), e("exclusiveMaximum", "exclusiveMaximum"), e("multipleOf", "multipleOf"), e("minLength", "minLength"), e("maxLength", "maxLength"), e("minItems", "minItems"), e("maxItems", "maxItems");
96
- const o = (c) => {
97
- try {
98
- return JSON.parse(c);
99
- } catch {
100
- return c;
101
- }
102
- }, r = t.match(/@pattern\s+(.+)/);
103
- r && (n.pattern = r[1].trim());
104
- const s = t.match(/@format\s+(\S+)/);
105
- s && (n.format = s[1]);
106
- const i = t.match(/@default\s+(.+)/);
107
- i && (n.default = o(i[1].trim()));
108
- const a = [...t.matchAll(/@examples?\s+(.+)/g)].map((c) => o(c[1].trim()));
109
- a.length && (n.examples = a), /@deprecated\b/.test(t) && (n.deprecated = !0), /@readonly\b|@readOnly\b/.test(t) && (n.readOnly = !0), /@uniqueItems\b/.test(t) && (n.uniqueItems = !0);
110
- const u = t.replace(/^\s*@\w+.*$/gm, "").trim(), m = t.match(/@mock\s+(\w+)/)?.[1];
111
- return { description: u, annotations: n, mock: m };
112
- }
113
- function W(t) {
114
- let n, e, o, r = t;
115
- for (; ; ) {
116
- const s = r.match(/^\/\*\*?([\s\S]*?)\*\/\s*/);
117
- if (s) {
118
- const a = s[1].replace(/^\s*\*\s?/gm, "").trim(), u = Wt(a);
119
- n = u.description || void 0, Object.keys(u.annotations).length && (e = u.annotations), o = u.mock, r = r.slice(s[0].length);
120
- continue;
121
- }
122
- const i = r.match(/^\/\/\s*([^\n]*)(?:\n\s*|$)/);
123
- if (i) {
124
- n = i[1].trim(), r = r.slice(i[0].length);
125
- continue;
126
- }
127
- return { description: n, annotations: e, mock: o, member: r };
128
- }
129
- }
130
- function qt(t) {
131
- const n = [];
132
- let e = 0, o = "", r = "";
133
- const s = () => {
134
- const u = o.trim();
135
- if (o = "", !u) return;
136
- const { description: m, annotations: c, mock: l, member: p } = W(u), d = p.match(/^(?:readonly\s+)?([A-Za-z_$][\w$]*)(\?)?\s*:\s*([\s\S]+)$/);
137
- d && n.push({ name: d[1], optional: d[2] === "?", type: d[3].trim(), description: m, annotations: c, mock: l });
138
- };
139
- let i = !1;
140
- const a = [...t];
141
- for (let u = 0; u < a.length; u++) {
142
- const m = a[u];
143
- if (!i && m === "/" && a[u + 1] === "*" && (i = !0), i && m === "/" && a[u - 1] === "*" && (i = !1), !i) {
144
- if (m === "{" || m === "(" || m === "[" ? e++ : m === "}" || m === ")" || m === "]" ? e-- : m === "<" && r !== "=" ? e++ : m === ">" && r !== "=" && e--, (m === ";" || m === ",") && e === 0) {
145
- s(), r = m;
146
- continue;
147
- }
148
- if (m === `
149
- ` && e === 0) {
150
- if (W(o.trim()).member === "") {
151
- o += m, r = m;
152
- continue;
153
- }
154
- s(), r = m;
155
- continue;
156
- }
157
- }
158
- o += m, r = m;
159
- }
160
- return s(), n;
161
- }
162
- function Et(t) {
163
- const n = [];
164
- let e = 0, o = "";
165
- for (const r of t) {
166
- if (r === "{" || r === "(" || r === "[" ? e++ : (r === "}" || r === ")" || r === "]") && e--, r === "," && e === 0) {
167
- o.trim() && n.push(o.trim()), o = "";
168
- continue;
169
- }
170
- o += r;
171
- }
172
- return o.trim() && n.push(o.trim()), n;
173
- }
174
- function q(t) {
175
- const n = [];
176
- let e = 0, o = "", r = "";
177
- for (const s of t) {
178
- if (s === "{" || s === "(" || s === "[" ? e++ : s === "}" || s === ")" || s === "]" ? e-- : s === "<" && r !== "=" ? e++ : s === ">" && r !== "=" && e--, s === "|" && e === 0) {
179
- o.trim() && n.push(o.trim()), o = "", r = s;
180
- continue;
181
- }
182
- o += s, r = s;
183
- }
184
- return o.trim() && n.push(o.trim()), n.filter((s) => s !== "undefined" && s !== "null");
185
- }
186
- function L(t) {
187
- const n = t.split("|").map((o) => o.trim()).filter((o) => o !== "" && o !== "undefined" && o !== "null");
188
- if (!n.length) return null;
189
- const e = [];
190
- for (const o of n) {
191
- const r = o.match(/^['"]([^'"]*)['"]$/);
192
- if (!r) return null;
193
- e.push(r[1]);
194
- }
195
- return e;
196
- }
197
- function F(t, n) {
198
- const e = t.trim();
199
- if (!/^[A-Za-z_$][\w$]*$/.test(e)) return t;
200
- const o = new RegExp(`(?:export\\s+)?type\\s+${e}\\s*=\\s*([^\\n;]*(?:\\n\\s*\\|[^\\n;]+)*)`), s = n.match(o)?.[1]?.replace(/\s+/g, " ").trim();
201
- return s || t;
202
- }
203
- function D(t) {
204
- return `{ ${t.map((e) => `${e.name}${e.required ? "" : "?"}: ${e.shape ?? e.type}`).join("; ")} }`;
205
- }
206
- function Lt(t) {
207
- if (t.format) return t.format;
208
- if (t.kind !== "text" && t.kind !== "slot") return;
209
- const n = `${t.name} ${t.description ?? ""}`.toLowerCase();
210
- if (/email/.test(n)) return "email";
211
- if (/url|href|link|website/.test(n)) return "uri";
212
- if (/date-time|datetime|timestamp/.test(n)) return "date-time";
213
- if (/date/.test(t.name.toLowerCase()) || /\bdates?\b/.test((t.description ?? "").toLowerCase())) return "date";
214
- if (/uuid/.test(n)) return "uuid";
215
- }
216
- function J(t, n) {
217
- const e = t.toLowerCase(), o = n.type, r = typeof n.format == "string" ? n.format : void 0;
218
- if (n.enum) return "mockOption";
219
- if (o === "boolean") return "mockBoolean";
220
- if (o === "number" || o === "integer")
221
- return /index|offset|position/.test(e) ? "mockIndex" : /count|total|amount|quantity/.test(e) ? "mockCount" : /percent|progress|opacity/.test(e) ? "mockPercent" : /width/.test(e) ? "mockWidth" : /height/.test(e) ? "mockHeight" : /price|cost/.test(e) ? "mockPrice" : /year/.test(e) ? "mockYear" : /^age$|(^|[^a-z])age$/.test(e) ? "mockAge" : o === "integer" ? "mockInt" : "mockFloat";
222
- if (o === "string")
223
- return r === "email" || /email/.test(e) ? "mockEmail" : /password/.test(e) ? "mockPassword" : /image|avatar|photo|thumbnail|poster|banner|logo|cover/.test(e) ? "mockImageUrl" : r === "uri" || /url|href|link/.test(e) ? "mockUrl" : r === "date" || r === "date-time" || /date/.test(e) ? "mockDate" : r === "uuid" || /uuid|slug/.test(e) ? "mockId" : /color|colour/.test(e) ? "mockColor" : /icon/.test(e) ? "mockIcon" : /username|handle|login/.test(e) ? "mockUsername" : /firstname|first_name/.test(e) ? "mockFirstName" : /lastname|last_name|surname|familyname|family_name/.test(e) ? "mockFamilyName" : /name/.test(e) ? "mockFullName" : /title|label|heading|headline/.test(e) ? "mockTitle" : /description|content|detail|body|paragraph|message|caption|subtitle|placeholder|text|summary/.test(e) ? "mockSentence" : "mockWord";
224
- if (o === "object") return "mockObject";
225
- if (o === "array") return "mockArray";
226
- const s = typeof n.tsType == "string" ? n.tsType : "";
227
- return s.includes("=>") ? "mockEvent" : s.endsWith("[]") || s.startsWith("Array<") ? "mockArray" : s && s !== "unknown" ? "mockObject" : "mockWord";
228
- }
229
- function v(t) {
230
- const n = {};
231
- if (t.description && (n.description = t.description), t.default !== void 0 && (n.default = t.default), t.kind === "select") n.enum = t.options ?? [];
232
- else if (t.kind === "boolean") n.type = "boolean";
233
- else if (t.kind === "number") n.type = "number";
234
- else if (t.kind === "text" || t.kind === "slot") {
235
- n.type = "string";
236
- const e = Lt(t);
237
- e && (n.format = e);
238
- } else if (t.kind === "array")
239
- n.type = "array", n.items = t.item ? v(t.item) : {};
240
- else if (t.kind === "record")
241
- n.type = "object", n.additionalProperties = t.item ? v(t.item) : {};
242
- else if (t.kind === "object") {
243
- n.type = "object", n.properties = Object.fromEntries((t.members ?? []).map((o) => [o.name, v(o)]));
244
- const e = (t.members ?? []).filter((o) => o.required).map((o) => o.name);
245
- e.length && (n.required = e);
246
- } else
247
- n.tsType = t.type;
248
- t.bindable && (n.bindable = !0);
249
- for (const [e, o] of Object.entries(t.annotations ?? {}))
250
- e in n || (n[e] = o);
251
- return n;
252
- }
253
- function Pt(t, n) {
254
- return n.mock && !t.mock && (t.mock = n.mock), n.annotations && (t.annotations = n.annotations, typeof n.annotations.format == "string" && (t.format = n.annotations.format), n.annotations.default !== void 0 && t.default === void 0 && (t.default = n.annotations.default)), t;
255
- }
256
- function _(t, n) {
257
- const e = v(n), o = n.mock ?? (n.kind === "function" || n.kind === "event" ? "mockEvent" : J(t, e));
258
- return { ...e, mock: o };
259
- }
260
- function It(t, n, e = [], o = []) {
261
- return {
262
- $schema: "https://json-schema.org/draft/2020-12/schema",
263
- title: t,
264
- type: "object",
265
- properties: Object.fromEntries(n.map((r) => [r.name, _(r.name, r)])),
266
- required: n.filter((r) => r.required).map((r) => r.name),
267
- slots: Object.fromEntries(e.map((r) => [r.name, _(r.name, r)])),
268
- emits: o
269
- };
270
- }
271
- function Ft(t) {
272
- return t === "array" || t.endsWith("[]") || t.startsWith("Array<") ? "mockArray" : /\bDate\b/.test(t) ? "mockDate" : t === "unknown" ? "mockWord" : "mockObject";
273
- }
274
- function $(t, n = 0, e = []) {
275
- if (t.kind === "function" || t.kind === "event") return { __nimpressFn: A(t.name) };
276
- if (t.default !== void 0 && t.kind !== "object" && t.kind !== "array" && t.kind !== "record") {
277
- const i = t.default;
278
- return typeof i == "object" && i !== null ? JSON.parse(JSON.stringify(i)) : i;
279
- }
280
- if (t.kind === "object") {
281
- const i = {};
282
- for (const a of t.members ?? []) {
283
- const u = $(a, n);
284
- u !== void 0 && (i[a.name] = u);
285
- }
286
- return Object.keys(i).length ? i : void 0;
287
- }
288
- if (t.kind === "array") {
289
- if (!t.item) return;
290
- const i = t.item.kind === "number" && !t.item.annotations && t.annotations ? { ...t.item, annotations: t.annotations } : t.item, a = $(i, n, e);
291
- if (a === void 0) return;
292
- const u = $(i, n + 1, [...e, a]);
293
- return u === void 0 ? [a] : [a, u];
294
- }
295
- if (t.kind === "record") {
296
- const i = {};
297
- for (let a = 0; a < 2; a++) {
298
- const u = I(n + a);
299
- i[u] = t.item ? $(t.item, n + a) ?? T(n + a) : T(n + a);
300
- }
301
- return i;
302
- }
303
- const o = t.mock ?? (t.kind === "select" ? "mockOption" : t.kind === "json" ? Ft(t.type) : J(t.name, {
304
- type: t.kind === "boolean" ? "boolean" : t.kind === "number" ? "number" : "string",
305
- format: t.format
306
- })), r = At[o];
307
- if (typeof r != "function") return;
308
- if (o === "mockOption") return r(t.options ?? [], n, e);
309
- const s = r(n);
310
- if (t.kind === "number" && typeof s == "number") {
311
- const i = typeof t.annotations?.minimum == "number" ? t.annotations.minimum : void 0, a = typeof t.annotations?.maximum == "number" ? t.annotations.maximum : void 0;
312
- if (i !== void 0 && a !== void 0) {
313
- const u = n * 37 % 100 / 100;
314
- return Math.round((i + (a - i) * (u || 0.5)) * 1e3) / 1e3;
315
- }
316
- if (i !== void 0) return Math.max(i, s);
317
- if (a !== void 0) return Math.min(a, s);
318
- }
319
- return s;
320
- }
321
- function Bt(t, n) {
322
- const e = new Set(n.required ?? []), o = Object.entries(n.properties ?? {}).map(
323
- ([i, a]) => h(i, a, e.has(i))
324
- ), r = Object.entries(n.slots ?? {}).map(([i, a]) => ({
325
- ...h(i, a),
326
- kind: "slot"
327
- })), s = Array.isArray(n.emits) ? n.emits : [];
328
- return { component: t, props: o, slots: r, emits: s };
329
- }
330
- function N(t, n = "") {
331
- const e = [];
332
- for (const o of t) {
333
- const r = n ? `${n}.${o.name || "[]"}` : o.name || "[]";
334
- o.kind === "json" && /^[A-Za-z_$][\w$]*(\[\])?$/.test(o.type) && o.type !== "unknown" && e.push({ path: r, type: o.type }), o.members && e.push(...N(o.members, r)), o.item && e.push(...N([o.item], r));
335
- }
336
- return e;
337
- }
338
- function h(t, n, e = !1, o = 0) {
339
- const r = n.description, s = { format: n.format, mock: n.mock, bindable: n.bindable };
340
- if (n.enum) {
341
- const i = n.enum.map(String);
342
- return {
343
- name: t,
344
- kind: "select",
345
- type: n.enum.map((a) => JSON.stringify(a)).join(" | "),
346
- options: i,
347
- required: e,
348
- description: r,
349
- default: n.default,
350
- ...s
351
- };
352
- }
353
- if (n.type === "boolean")
354
- return { name: t, kind: "boolean", type: "boolean", required: e, description: r, default: n.default, ...s };
355
- if (n.type === "number" || n.type === "integer") {
356
- const i = {};
357
- return typeof n.minimum == "number" && (i.minimum = n.minimum), typeof n.maximum == "number" && (i.maximum = n.maximum), {
358
- name: t,
359
- kind: "number",
360
- type: "number",
361
- required: e,
362
- description: r,
363
- default: n.default,
364
- ...Object.keys(i).length ? { annotations: i } : {},
365
- ...s
366
- };
367
- }
368
- if (n.type === "string")
369
- return { name: t, kind: "text", type: "string", required: e, description: r, default: n.default, ...s };
370
- if (n.type === "array" && n.items && o < O) {
371
- const i = h("", n.items, !1, o + 1), a = {};
372
- return typeof n.minimum == "number" && (a.minimum = n.minimum), typeof n.maximum == "number" && (a.maximum = n.maximum), {
373
- name: t,
374
- kind: "array",
375
- type: n.title ?? `${i.type}[]`,
376
- item: i,
377
- required: e,
378
- description: r,
379
- default: n.default,
380
- shape: `${i.shape ?? i.type}[]`,
381
- ...Object.keys(a).length ? { annotations: a } : {},
382
- ...s
383
- };
384
- }
385
- if (n.type === "object" && !n.properties && n.additionalProperties && o < O) {
386
- const i = h("", n.additionalProperties, !1, o + 1);
387
- return {
388
- name: t,
389
- kind: "record",
390
- type: n.title ?? "object",
391
- item: i,
392
- required: e,
393
- description: r,
394
- default: n.default,
395
- shape: `Record<string, ${i.shape ?? i.type}>`,
396
- ...s
397
- };
398
- }
399
- if (n.type === "object" && n.properties && o < O) {
400
- const i = n.required ?? [], a = Object.entries(n.properties).map(
401
- ([u, m]) => h(u, m, i.includes(u), o + 1)
402
- );
403
- return {
404
- name: t,
405
- kind: "object",
406
- type: n.title ?? "object",
407
- members: a,
408
- required: e,
409
- description: r,
410
- default: n.default,
411
- shape: D(a),
412
- ...s
413
- };
414
- }
415
- return n.tsType?.includes("=>") ? { name: t, kind: "function", type: n.tsType, required: e, description: r, default: n.default, ...s } : { name: t, kind: "json", type: n.tsType ?? n.type ?? "unknown", required: e, description: r, default: n.default, ...s };
416
- }
417
- function S(t, n, e, o = "", r, s = 0, i = []) {
418
- const u = F(n, o).replace(/\s+/g, " ").trim(), m = L(u);
419
- if (m) return { name: t, kind: "select", type: u, options: m, required: !e, description: r };
420
- const c = u.replace(/\s*\|\s*(undefined|null)\s*/g, "").trim();
421
- if (c === "boolean") return { name: t, kind: "boolean", type: u, required: !e, description: r };
422
- if (c === "number") return { name: t, kind: "number", type: u, required: !e, description: r };
423
- if (c === "string") return { name: t, kind: "text", type: u, required: !e, description: r };
424
- if (c.includes("|")) {
425
- const l = q(c).flatMap((d) => q(F(d, o))), p = L(l.join(" | "));
426
- if (p) return { name: t, kind: "select", type: u, options: p, required: !e, description: r };
427
- if (l.includes("string")) return { name: t, kind: "text", type: u, required: !e, description: r };
428
- if (l.includes("number")) return { name: t, kind: "number", type: u, required: !e, description: r };
429
- if (l.includes("boolean")) return { name: t, kind: "boolean", type: u, required: !e, description: r };
430
- }
431
- if (/^\([^)]*\)\s*=>/.test(c))
432
- return { name: t, kind: "function", type: u, required: !e, description: r };
433
- if (s < 4) {
434
- const l = c.match(/^Record<\s*string\s*,\s*(.+)>$/)?.[1] ?? c.match(/^\{\s*\[\s*\w+\s*:\s*string\s*\]\s*:\s*(.+?);?\s*\}$/)?.[1];
435
- if (l) {
436
- const y = S("", l, !1, o, void 0, s + 1, i);
437
- return {
438
- name: t,
439
- kind: "record",
440
- type: u,
441
- item: y,
442
- required: !e,
443
- description: r,
444
- shape: `Record<string, ${y.shape ?? y.type}>`
445
- };
446
- }
447
- const p = c.match(/^(.*\S)\[\]$/)?.[1] ?? c.match(/^Array<(.+)>$/)?.[1];
448
- if (p) {
449
- const y = S("", p, !1, o, void 0, s + 1, i);
450
- if (y.kind !== "json")
451
- return {
452
- name: t,
453
- kind: "array",
454
- type: u,
455
- item: y,
456
- required: !e,
457
- description: r,
458
- shape: `${y.shape ?? y.type}[]`
459
- };
460
- }
461
- let d = null, j = "";
462
- if (c.startsWith("{") && c.endsWith("}") ? d = c.slice(1, -1) : /^[A-Za-z_$][\w$]*$/.test(c) && !i.includes(c) && (j = c, d = Nt(o, c)), d !== null) {
463
- const y = j ? [...i, j] : i, w = qt(d).map((b) => {
464
- const x = S(b.name, b.type, b.optional, o, b.description, s + 1, y);
465
- return b.mock && !x.mock && (x.mock = b.mock), x;
466
- });
467
- if (w.length)
468
- return {
469
- name: t,
470
- kind: "object",
471
- type: u,
472
- members: w,
473
- required: !e,
474
- description: r,
475
- shape: D(w)
476
- };
477
- }
478
- }
479
- return { name: t, kind: "json", type: u, required: !e, description: r };
480
- }
481
- function Dt(t) {
482
- const n = t.trim();
483
- if (n === "true") return !0;
484
- if (n === "false") return !1;
485
- if (n === "null") return null;
486
- if (/^-?\d+(\.\d+)?$/.test(n)) return Number(n);
487
- const e = n.match(/^['"]([\s\S]*)['"]$/);
488
- if (e) return e[1];
489
- try {
490
- return JSON.parse(n);
491
- } catch {
492
- return;
493
- }
494
- }
495
- function _t(t, n, e = "{", o = "}") {
496
- let r = 1;
497
- for (let s = n; s < t.length; s++) {
498
- const i = t[s];
499
- if (i === e) r++;
500
- else if (i === o && (r--, r === 0))
501
- return t.slice(n, s);
502
- }
503
- return t.slice(n);
504
- }
505
- function Nt(t, n) {
506
- const e = [
507
- new RegExp(`interface\\s+${n}\\s*(?:extends[^{]+)?\\{`),
508
- new RegExp(`type\\s+${n}\\s*=\\s*\\{`)
509
- ];
510
- for (const o of e) {
511
- const r = o.exec(t);
512
- if (r)
513
- return _t(t, r.index + r[0].length);
514
- }
515
- return null;
516
- }
517
- export {
518
- Ct as a,
519
- Et as b,
520
- qt as c,
521
- Pt as d,
522
- Nt as e,
523
- A as f,
524
- S as g,
525
- Wt as h,
526
- V as i,
527
- Mt as j,
528
- Bt as k,
529
- Lt as l,
530
- $ as m,
531
- M as n,
532
- N as o,
533
- Dt as p,
534
- J as q,
535
- _t as r,
536
- It as s,
537
- v as t
538
- };