@hintergrund/ui 0.2.2 → 0.2.3

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.
Files changed (42) hide show
  1. package/dist/Builder-H8tY8V9I.js +14172 -0
  2. package/dist/admin.js +11084 -9645
  3. package/dist/{anthropic-CwpwmW2G.js → anthropic-messages-C3hIUlsA.js} +1134 -1055
  4. package/dist/azure-openai-responses-t7u41KMr.js +222 -0
  5. package/dist/builder.js +2 -2
  6. package/dist/client-Cd7yMX39.js +7860 -0
  7. package/dist/deferred-tools-BZWMWBYN.js +28 -0
  8. package/dist/error-body-BUPcH4GF.js +71 -0
  9. package/dist/github-copilot-headers-B1RBGoZi.js +21 -0
  10. package/dist/{global-DdaMTl90.js → global-Bk9T4Af5.js} +17850 -16460
  11. package/dist/google-generative-ai-6ZG79NDC.js +264 -0
  12. package/dist/{google-shared-zl4aoTwW.js → google-shared-C6y4fA42.js} +1135 -1104
  13. package/dist/google-vertex-f2myaAmm.js +305 -0
  14. package/dist/headers-D4iLzGaS.js +21 -0
  15. package/dist/json-parse-LZdWp-Nd.js +232 -0
  16. package/dist/login.js +48 -48
  17. package/dist/mistral-conversations-D16H8Mgq.js +513 -0
  18. package/dist/openai-codex-responses-DIHPbnIS.js +947 -0
  19. package/dist/openai-completions-vDHGFsWV.js +741 -0
  20. package/dist/{headers-u7rXGJ9f.js → openai-prompt-cache-BJwqbEDx.js} +7 -6
  21. package/dist/openai-responses-B0rjAJxx.js +184 -0
  22. package/dist/openai-responses-shared-DqdzMfa_.js +477 -0
  23. package/dist/pi-messages-DB2BtH-g.js +251 -0
  24. package/dist/pi-user-agent-CUqx-qiX.js +13 -0
  25. package/dist/provider-env-D2VjEV3S.js +26 -0
  26. package/dist/provider-retry-BsigVlMg.js +67 -0
  27. package/dist/setup.js +230 -228
  28. package/dist/transform-messages-CsKsy6b4.js +398 -0
  29. package/package.json +4 -5
  30. package/dist/Builder-BhGmzNTC.js +0 -163449
  31. package/dist/azure-openai-responses-yWEFYMG1.js +0 -203
  32. package/dist/client-Sh7wNjbG.js +0 -5277
  33. package/dist/github-copilot-headers-DWh_6bE3.js +0 -35
  34. package/dist/google-BgPPfrTM.js +0 -248
  35. package/dist/google-vertex-D7kAAkZn.js +0 -285
  36. package/dist/json-parse-Dk_xwHcS.js +0 -93
  37. package/dist/mistral-BJWDROjc.js +0 -22932
  38. package/dist/openai-codex-responses-rzy0Aqwg.js +0 -700
  39. package/dist/openai-completions-CUEO2YVR.js +0 -535
  40. package/dist/openai-responses-k6plMvd9.js +0 -142
  41. package/dist/openai-responses-shared-CCD7nRqy.js +0 -324
  42. package/dist/transform-messages-CkpQp6fJ.js +0 -132
@@ -0,0 +1,305 @@
1
+ import { r as v, i as R, a as O, m as _, G as L, c as M, s as S, b as G, d as P, T as h, R as A } from "./google-shared-C6y4fA42.js";
2
+ import { d as N, f as U, e as D } from "./Builder-H8tY8V9I.js";
3
+ import { f as V, n as H } from "./error-body-BUPcH4GF.js";
4
+ import { p as K } from "./headers-D4iLzGaS.js";
5
+ import { g as m } from "./provider-env-D2VjEV3S.js";
6
+ import { b as W, s as j } from "./transform-messages-CsKsy6b4.js";
7
+ typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
8
+ return Promise.resolve().then(e);
9
+ } });
10
+ const w = "v1", $ = "gcp-vertex-credentials", B = {
11
+ THINKING_LEVEL_UNSPECIFIED: h.THINKING_LEVEL_UNSPECIFIED,
12
+ MINIMAL: h.MINIMAL,
13
+ LOW: h.LOW,
14
+ MEDIUM: h.MEDIUM,
15
+ HIGH: h.HIGH
16
+ };
17
+ let q = 0;
18
+ const I = (e, t, i) => {
19
+ const o = new N();
20
+ return (async () => {
21
+ const n = {
22
+ role: "assistant",
23
+ content: [],
24
+ api: "google-vertex",
25
+ provider: e.provider,
26
+ model: e.id,
27
+ usage: {
28
+ input: 0,
29
+ output: 0,
30
+ cacheRead: 0,
31
+ cacheWrite: 0,
32
+ totalTokens: 0,
33
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 }
34
+ },
35
+ stopReason: "pending",
36
+ timestamp: Date.now()
37
+ };
38
+ try {
39
+ if (i?.fetch && i.fetch !== globalThis.fetch)
40
+ throw new Error("Custom fetch is not supported by the Google Vertex adapter");
41
+ const s = Y(i), u = s ? J(e, s, i?.headers) : F(e, ee(i), te(i), i?.headers, i?.env);
42
+ let d = ne(e, t, i);
43
+ const k = await i?.onPayload?.(d, e);
44
+ k !== void 0 && (d = k);
45
+ const p = await v(() => u.models.generateContentStream(d), i);
46
+ o.push({ type: "start", partial: n });
47
+ let a = null;
48
+ const T = n.content, l = () => T.length - 1;
49
+ for await (const c of p) {
50
+ n.responseId ||= c.responseId;
51
+ const f = c.candidates?.[0];
52
+ if (f?.content?.parts)
53
+ for (const r of f.content.parts) {
54
+ if (r.text !== void 0) {
55
+ const g = R(r);
56
+ (!a || g && a.type !== "thinking" || !g && a.type !== "text") && (a && (a.type === "text" ? o.push({
57
+ type: "text_end",
58
+ contentIndex: T.length - 1,
59
+ content: a.text,
60
+ partial: n
61
+ }) : o.push({
62
+ type: "thinking_end",
63
+ contentIndex: l(),
64
+ content: a.thinking,
65
+ partial: n
66
+ })), g ? (a = { type: "thinking", thinking: "", thinkingSignature: void 0 }, n.content.push(a), o.push({ type: "thinking_start", contentIndex: l(), partial: n })) : (a = { type: "text", text: "" }, n.content.push(a), o.push({ type: "text_start", contentIndex: l(), partial: n }))), a.type === "thinking" ? (a.thinking += r.text, a.thinkingSignature = O(a.thinkingSignature, r.thoughtSignature), o.push({
67
+ type: "thinking_delta",
68
+ contentIndex: l(),
69
+ delta: r.text,
70
+ partial: n
71
+ })) : (a.text += r.text, a.textSignature = O(a.textSignature, r.thoughtSignature), o.push({
72
+ type: "text_delta",
73
+ contentIndex: l(),
74
+ delta: r.text,
75
+ partial: n
76
+ }));
77
+ }
78
+ if (r.functionCall) {
79
+ a && (a.type === "text" ? o.push({
80
+ type: "text_end",
81
+ contentIndex: l(),
82
+ content: a.text,
83
+ partial: n
84
+ }) : o.push({
85
+ type: "thinking_end",
86
+ contentIndex: l(),
87
+ content: a.thinking,
88
+ partial: n
89
+ }), a = null);
90
+ const g = r.functionCall.id, C = {
91
+ type: "toolCall",
92
+ id: !g || n.content.some((b) => b.type === "toolCall" && b.id === g) ? `${r.functionCall.name}_${Date.now()}_${++q}` : g,
93
+ name: r.functionCall.name || "",
94
+ arguments: r.functionCall.args ?? {},
95
+ ...r.thoughtSignature && { thoughtSignature: r.thoughtSignature }
96
+ };
97
+ n.content.push(C), o.push({ type: "toolcall_start", contentIndex: l(), partial: n }), o.push({
98
+ type: "toolcall_delta",
99
+ contentIndex: l(),
100
+ delta: JSON.stringify(C.arguments),
101
+ partial: n
102
+ }), o.push({ type: "toolcall_end", contentIndex: l(), toolCall: C, partial: n });
103
+ }
104
+ }
105
+ f?.finishReason && (n.rawStopReason = f.finishReason, n.stopReason = _(f.finishReason), n.content.some((r) => r.type === "toolCall") && n.stopReason === "stop" && (n.stopReason = "toolUse")), c.usageMetadata && (n.usage = {
106
+ input: (c.usageMetadata.promptTokenCount || 0) - (c.usageMetadata.cachedContentTokenCount || 0),
107
+ output: (c.usageMetadata.candidatesTokenCount || 0) + (c.usageMetadata.thoughtsTokenCount || 0),
108
+ cacheRead: c.usageMetadata.cachedContentTokenCount || 0,
109
+ cacheWrite: 0,
110
+ reasoning: c.usageMetadata.thoughtsTokenCount || 0,
111
+ totalTokens: c.usageMetadata.totalTokenCount || 0,
112
+ cost: {
113
+ input: 0,
114
+ output: 0,
115
+ cacheRead: 0,
116
+ cacheWrite: 0,
117
+ total: 0
118
+ }
119
+ }, U(e, n.usage));
120
+ }
121
+ if (a && (a.type === "text" ? o.push({
122
+ type: "text_end",
123
+ contentIndex: l(),
124
+ content: a.text,
125
+ partial: n
126
+ }) : o.push({
127
+ type: "thinking_end",
128
+ contentIndex: l(),
129
+ content: a.thinking,
130
+ partial: n
131
+ })), i?.signal?.aborted)
132
+ throw new Error("Request was aborted");
133
+ if (n.stopReason === "pending")
134
+ throw new Error("Google Vertex stream ended without a finish reason");
135
+ if (n.stopReason === "aborted" || n.stopReason === "error") {
136
+ const c = n.rawStopReason ? `Provider stopped with: ${n.rawStopReason}` : "An unknown error occurred";
137
+ throw new Error(c);
138
+ }
139
+ o.push({ type: "done", reason: n.stopReason, message: n }), o.end();
140
+ } catch (s) {
141
+ for (const u of n.content)
142
+ "index" in u && delete u.index;
143
+ n.stopReason = i?.signal?.aborted ? "aborted" : "error", n.errorMessage = V(H(s)), o.push({ type: "error", reason: n.stopReason, error: n }), o.end();
144
+ }
145
+ })(), o;
146
+ }, pe = (e, t, i) => {
147
+ const o = W(e, t, i, void 0);
148
+ if (!i?.reasoning)
149
+ return I(e, t, {
150
+ ...o,
151
+ thinking: { enabled: !1 }
152
+ });
153
+ const n = D(e, i.reasoning), s = n === "off" ? "high" : n, u = e;
154
+ return y(u) || E(u) ? I(e, t, {
155
+ ...o,
156
+ thinking: {
157
+ enabled: !0,
158
+ level: oe(s, u)
159
+ }
160
+ }) : I(e, t, {
161
+ ...o,
162
+ thinking: {
163
+ enabled: !0,
164
+ budgetTokens: ae(u, s, i.thinkingBudgets)
165
+ }
166
+ });
167
+ };
168
+ function F(e, t, i, o, n) {
169
+ const s = Q(n);
170
+ return new L({
171
+ vertexai: !0,
172
+ project: t,
173
+ location: i,
174
+ apiVersion: w,
175
+ ...s ? { googleAuthOptions: s } : {},
176
+ httpOptions: x(e, o)
177
+ });
178
+ }
179
+ function J(e, t, i) {
180
+ return new L({
181
+ vertexai: !0,
182
+ apiKey: t,
183
+ apiVersion: w,
184
+ httpOptions: x(e, i)
185
+ });
186
+ }
187
+ function x(e, t) {
188
+ const i = {}, o = z(e.baseUrl);
189
+ o && (i.baseUrl = o, i.baseUrlResourceScope = A.COLLECTION, X(o) && (i.apiVersion = ""));
190
+ const n = K({ ...e.headers, ...t });
191
+ return n && (i.headers = n), Object.keys(i).length > 0 ? i : void 0;
192
+ }
193
+ function z(e) {
194
+ const t = e.trim();
195
+ if (!(!t || t.includes("{location}")))
196
+ return t;
197
+ }
198
+ function X(e) {
199
+ try {
200
+ return new URL(e).pathname.split("/").some((i) => /^v\d+(?:beta\d*)?$/.test(i));
201
+ } catch {
202
+ return /(?:^|\/)v\d+(?:beta\d*)?(?:\/|$)/.test(e);
203
+ }
204
+ }
205
+ function Q(e) {
206
+ const t = m("GOOGLE_APPLICATION_CREDENTIALS", e);
207
+ return t ? { keyFilename: t } : void 0;
208
+ }
209
+ function Y(e) {
210
+ const t = e?.apiKey?.trim();
211
+ if (!(!t || t === $ || Z(t)))
212
+ return t;
213
+ }
214
+ function Z(e) {
215
+ return /^<[^>]+>$/.test(e);
216
+ }
217
+ function ee(e) {
218
+ const t = e?.project || m("GOOGLE_CLOUD_PROJECT", e?.env) || m("GCLOUD_PROJECT", e?.env);
219
+ if (!t)
220
+ throw new Error("Vertex AI requires a project ID. Set GOOGLE_CLOUD_PROJECT/GCLOUD_PROJECT or pass project in options.");
221
+ return t;
222
+ }
223
+ function te(e) {
224
+ const t = e?.location || m("GOOGLE_CLOUD_LOCATION", e?.env);
225
+ if (!t)
226
+ throw new Error("Vertex AI requires a location. Set GOOGLE_CLOUD_LOCATION or pass location in options.");
227
+ return t;
228
+ }
229
+ function ne(e, t, i = {}) {
230
+ const o = M(e, t), n = {};
231
+ i.temperature !== void 0 && (n.temperature = i.temperature), i.maxTokens !== void 0 && (n.maxOutputTokens = i.maxTokens);
232
+ const s = S(e.id), u = t.tools?.length ? G(t.tools, i.toolChoice, s) : void 0, d = {
233
+ ...Object.keys(n).length > 0 && n,
234
+ ...t.systemPrompt && { systemInstruction: j(t.systemPrompt) },
235
+ ...t.tools && t.tools.length > 0 && {
236
+ tools: P(t.tools, !1, s)
237
+ },
238
+ ...u !== void 0 && {
239
+ toolConfig: { functionCallingConfig: { mode: u } }
240
+ }
241
+ };
242
+ if (i.thinking?.enabled && e.reasoning) {
243
+ const p = { includeThoughts: !0 };
244
+ i.thinking.level !== void 0 ? p.thinkingLevel = B[i.thinking.level] : i.thinking.budgetTokens !== void 0 && (p.thinkingBudget = i.thinking.budgetTokens), d.thinkingConfig = p;
245
+ } else e.reasoning && i.thinking && !i.thinking.enabled && (d.thinkingConfig = ie(e));
246
+ if (i.signal) {
247
+ if (i.signal.aborted)
248
+ throw new Error("Request aborted");
249
+ d.abortSignal = i.signal;
250
+ }
251
+ return {
252
+ model: e.id,
253
+ contents: o,
254
+ config: d
255
+ };
256
+ }
257
+ function y(e) {
258
+ return /gemini-3(?:\.\d+)?-pro/.test(e.id.toLowerCase());
259
+ }
260
+ function E(e) {
261
+ const t = e.id.toLowerCase();
262
+ return /gemini-3(?:\.\d+)?-flash/.test(t) || t === "gemini-flash-latest" || t === "gemini-flash-lite-latest";
263
+ }
264
+ function ie(e) {
265
+ const t = e;
266
+ return y(t) ? { thinkingLevel: h.LOW } : E(t) ? { thinkingLevel: h.MINIMAL } : { thinkingBudget: 0 };
267
+ }
268
+ function oe(e, t) {
269
+ if (y(t))
270
+ switch (e) {
271
+ case "minimal":
272
+ case "low":
273
+ return "LOW";
274
+ case "medium":
275
+ case "high":
276
+ return "HIGH";
277
+ }
278
+ switch (e) {
279
+ case "minimal":
280
+ return "MINIMAL";
281
+ case "low":
282
+ return "LOW";
283
+ case "medium":
284
+ return "MEDIUM";
285
+ case "high":
286
+ return "HIGH";
287
+ }
288
+ }
289
+ function ae(e, t, i) {
290
+ return i?.[t] !== void 0 ? i[t] : e.id.includes("2.5-pro") ? {
291
+ minimal: 128,
292
+ low: 2048,
293
+ medium: 8192,
294
+ high: 32768
295
+ }[t] : e.id.includes("2.5-flash") ? {
296
+ minimal: 128,
297
+ low: 2048,
298
+ medium: 8192,
299
+ high: 24576
300
+ }[t] : -1;
301
+ }
302
+ export {
303
+ I as stream,
304
+ pe as streamSimple
305
+ };
@@ -0,0 +1,21 @@
1
+ typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
2
+ return Promise.resolve().then(e);
3
+ } });
4
+ function s(e) {
5
+ const r = {};
6
+ for (const [o, n] of e.entries())
7
+ r[o] = n;
8
+ return r;
9
+ }
10
+ function t(e) {
11
+ if (!e)
12
+ return;
13
+ const r = {};
14
+ for (const [o, n] of Object.entries(e))
15
+ n !== null && (r[o] = n);
16
+ return Object.keys(r).length > 0 ? r : void 0;
17
+ }
18
+ export {
19
+ s as h,
20
+ t as p
21
+ };
@@ -0,0 +1,232 @@
1
+ typeof globalThis.process > "u" && (globalThis.process = { env: {}, platform: "browser", version: "", versions: {}, browser: !0, nextTick: function(e) {
2
+ return Promise.resolve().then(e);
3
+ } });
4
+ var d = {}, y = {}, T;
5
+ function J() {
6
+ return T || (T = 1, (function(e) {
7
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.Allow = e.ALL = e.COLLECTION = e.ATOM = e.SPECIAL = e.INF = e._INFINITY = e.INFINITY = e.NAN = e.BOOL = e.NULL = e.OBJ = e.ARR = e.NUM = e.STR = void 0, e.STR = 1, e.NUM = 2, e.ARR = 4, e.OBJ = 8, e.NULL = 16, e.BOOL = 32, e.NAN = 64, e.INFINITY = 128, e._INFINITY = 256, e.INF = e.INFINITY | e._INFINITY, e.SPECIAL = e.NULL | e.BOOL | e.INF | e.NAN, e.ATOM = e.STR | e.NUM | e.SPECIAL, e.COLLECTION = e.ARR | e.OBJ, e.ALL = e.ATOM | e.COLLECTION, e.Allow = { STR: e.STR, NUM: e.NUM, ARR: e.ARR, OBJ: e.OBJ, NULL: e.NULL, BOOL: e.BOOL, NAN: e.NAN, INFINITY: e.INFINITY, _INFINITY: e._INFINITY, INF: e.INF, SPECIAL: e.SPECIAL, ATOM: e.ATOM, COLLECTION: e.COLLECTION, ALL: e.ALL }, e.default = e.Allow;
8
+ })(y)), y;
9
+ }
10
+ var _;
11
+ function B() {
12
+ return _ || (_ = 1, (function(e) {
13
+ var c = d && d.__createBinding || (Object.create ? (function(r, n, u, t) {
14
+ t === void 0 && (t = u);
15
+ var f = Object.getOwnPropertyDescriptor(n, u);
16
+ (!f || ("get" in f ? !n.__esModule : f.writable || f.configurable)) && (f = { enumerable: !0, get: function() {
17
+ return n[u];
18
+ } }), Object.defineProperty(r, t, f);
19
+ }) : (function(r, n, u, t) {
20
+ t === void 0 && (t = u), r[t] = n[u];
21
+ })), s = d && d.__exportStar || function(r, n) {
22
+ for (var u in r) u !== "default" && !Object.prototype.hasOwnProperty.call(n, u) && c(n, r, u);
23
+ };
24
+ Object.defineProperty(e, "__esModule", { value: !0 }), e.Allow = e.MalformedJSON = e.PartialJSON = e.parseJSON = e.parse = void 0;
25
+ const i = J();
26
+ Object.defineProperty(e, "Allow", { enumerable: !0, get: function() {
27
+ return i.Allow;
28
+ } }), s(J(), e);
29
+ class l extends Error {
30
+ }
31
+ e.PartialJSON = l;
32
+ class I extends Error {
33
+ }
34
+ e.MalformedJSON = I;
35
+ function b(r, n = i.Allow.ALL) {
36
+ if (typeof r != "string")
37
+ throw new TypeError(`expecting str, got ${typeof r}`);
38
+ if (!r.trim())
39
+ throw new Error(`${r} is empty`);
40
+ return E(r.trim(), n);
41
+ }
42
+ e.parseJSON = b;
43
+ const E = (r, n) => {
44
+ const u = r.length;
45
+ let t = 0;
46
+ const f = (a) => {
47
+ throw new l(`${a} at position ${t}`);
48
+ }, h = (a) => {
49
+ throw new I(`${a} at position ${t}`);
50
+ }, L = () => (A(), t >= u && f("Unexpected end of input"), r[t] === '"' ? w() : r[t] === "{" ? o() : r[t] === "[" ? M() : r.substring(t, t + 4) === "null" || i.Allow.NULL & n && u - t < 4 && "null".startsWith(r.substring(t)) ? (t += 4, null) : r.substring(t, t + 4) === "true" || i.Allow.BOOL & n && u - t < 4 && "true".startsWith(r.substring(t)) ? (t += 4, !0) : r.substring(t, t + 5) === "false" || i.Allow.BOOL & n && u - t < 5 && "false".startsWith(r.substring(t)) ? (t += 5, !1) : r.substring(t, t + 8) === "Infinity" || i.Allow.INFINITY & n && u - t < 8 && "Infinity".startsWith(r.substring(t)) ? (t += 8, 1 / 0) : r.substring(t, t + 9) === "-Infinity" || i.Allow._INFINITY & n && 1 < u - t && u - t < 9 && "-Infinity".startsWith(r.substring(t)) ? (t += 9, -1 / 0) : r.substring(t, t + 3) === "NaN" || i.Allow.NAN & n && u - t < 3 && "NaN".startsWith(r.substring(t)) ? (t += 3, NaN) : v()), w = () => {
51
+ const a = t;
52
+ let N = !1;
53
+ for (t++; t < u && (r[t] !== '"' || N && r[t - 1] === "\\"); )
54
+ N = r[t] === "\\" ? !N : !1, t++;
55
+ if (r.charAt(t) == '"')
56
+ try {
57
+ return JSON.parse(r.substring(a, ++t - Number(N)));
58
+ } catch (O) {
59
+ h(String(O));
60
+ }
61
+ else if (i.Allow.STR & n)
62
+ try {
63
+ return JSON.parse(r.substring(a, t - Number(N)) + '"');
64
+ } catch {
65
+ return JSON.parse(r.substring(a, r.lastIndexOf("\\")) + '"');
66
+ }
67
+ f("Unterminated string literal");
68
+ }, o = () => {
69
+ t++, A();
70
+ const a = {};
71
+ try {
72
+ for (; r[t] !== "}"; ) {
73
+ if (A(), t >= u && i.Allow.OBJ & n)
74
+ return a;
75
+ const N = w();
76
+ A(), t++;
77
+ try {
78
+ const O = L();
79
+ a[N] = O;
80
+ } catch (O) {
81
+ if (i.Allow.OBJ & n)
82
+ return a;
83
+ throw O;
84
+ }
85
+ A(), r[t] === "," && t++;
86
+ }
87
+ } catch {
88
+ if (i.Allow.OBJ & n)
89
+ return a;
90
+ f("Expected '}' at end of object");
91
+ }
92
+ return t++, a;
93
+ }, M = () => {
94
+ t++;
95
+ const a = [];
96
+ try {
97
+ for (; r[t] !== "]"; )
98
+ a.push(L()), A(), r[t] === "," && t++;
99
+ } catch {
100
+ if (i.Allow.ARR & n)
101
+ return a;
102
+ f("Expected ']' at end of array");
103
+ }
104
+ return t++, a;
105
+ }, v = () => {
106
+ if (t === 0) {
107
+ r === "-" && h("Not sure what '-' is");
108
+ try {
109
+ return JSON.parse(r);
110
+ } catch (N) {
111
+ if (i.Allow.NUM & n)
112
+ try {
113
+ return JSON.parse(r.substring(0, r.lastIndexOf("e")));
114
+ } catch {
115
+ }
116
+ h(String(N));
117
+ }
118
+ }
119
+ const a = t;
120
+ for (r[t] === "-" && t++; r[t] && ",]}".indexOf(r[t]) === -1; )
121
+ t++;
122
+ t == u && !(i.Allow.NUM & n) && f("Unterminated number literal");
123
+ try {
124
+ return JSON.parse(r.substring(a, t));
125
+ } catch {
126
+ r.substring(a, t) === "-" && f("Not sure what '-' is");
127
+ try {
128
+ return JSON.parse(r.substring(a, r.lastIndexOf("e")));
129
+ } catch (O) {
130
+ h(String(O));
131
+ }
132
+ }
133
+ }, A = () => {
134
+ for (; t < u && `
135
+ \r `.includes(r[t]); )
136
+ t++;
137
+ };
138
+ return L();
139
+ }, P = b;
140
+ e.parse = P;
141
+ })(d)), d;
142
+ }
143
+ var C = B();
144
+ const F = /* @__PURE__ */ new Set(['"', "\\", "/", "b", "f", "n", "r", "t", "u"]);
145
+ function m(e) {
146
+ const c = e.codePointAt(0);
147
+ return c !== void 0 && c >= 0 && c <= 31;
148
+ }
149
+ function U(e) {
150
+ switch (e) {
151
+ case "\b":
152
+ return "\\b";
153
+ case "\f":
154
+ return "\\f";
155
+ case `
156
+ `:
157
+ return "\\n";
158
+ case "\r":
159
+ return "\\r";
160
+ case " ":
161
+ return "\\t";
162
+ default:
163
+ return `\\u${e.codePointAt(0)?.toString(16).padStart(4, "0") ?? "0000"}`;
164
+ }
165
+ }
166
+ function R(e) {
167
+ let c = "", s = !1;
168
+ for (let i = 0; i < e.length; i++) {
169
+ const l = e[i];
170
+ if (!s) {
171
+ c += l, l === '"' && (s = !0);
172
+ continue;
173
+ }
174
+ if (l === '"') {
175
+ c += l, s = !1;
176
+ continue;
177
+ }
178
+ if (l === "\\") {
179
+ const I = e[i + 1];
180
+ if (I === void 0) {
181
+ c += "\\\\";
182
+ continue;
183
+ }
184
+ if (I === "u") {
185
+ const b = e.slice(i + 2, i + 6);
186
+ if (/^[0-9a-fA-F]{4}$/.test(b)) {
187
+ c += `\\u${b}`, i += 5;
188
+ continue;
189
+ }
190
+ }
191
+ if (F.has(I)) {
192
+ c += `\\${I}`, i += 1;
193
+ continue;
194
+ }
195
+ c += "\\\\";
196
+ continue;
197
+ }
198
+ c += m(l) ? U(l) : l;
199
+ }
200
+ return c;
201
+ }
202
+ function Y(e) {
203
+ try {
204
+ return JSON.parse(e);
205
+ } catch (c) {
206
+ const s = R(e);
207
+ if (s !== e)
208
+ return JSON.parse(s);
209
+ throw c;
210
+ }
211
+ }
212
+ function $(e) {
213
+ if (!e || e.trim() === "")
214
+ return {};
215
+ try {
216
+ return Y(e);
217
+ } catch {
218
+ try {
219
+ return C.parse(e) ?? {};
220
+ } catch {
221
+ try {
222
+ return C.parse(R(e)) ?? {};
223
+ } catch {
224
+ return {};
225
+ }
226
+ }
227
+ }
228
+ }
229
+ export {
230
+ Y as a,
231
+ $ as p
232
+ };