@hexclave/dashboard-ui-components 1.0.75 → 1.0.77

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.
@@ -3981,236 +3981,6 @@ var DashboardUI = (() => {
3981
3981
  // ../shared/dist/esm/utils/react.js
3982
3982
  var import_react7 = __toESM(require_react(), 1);
3983
3983
 
3984
- // ../shared/dist/esm/utils/arrays.js
3985
- function findLastIndex(arr, predicate) {
3986
- for (let i = arr.length - 1; i >= 0; i--) if (predicate(arr[i])) return i;
3987
- return -1;
3988
- }
3989
- function unique(arr) {
3990
- return [...new Set(arr)];
3991
- }
3992
-
3993
- // ../shared/dist/esm/utils/strings.js
3994
- function stringCompare(a26, b) {
3995
- if (typeof a26 !== "string" || typeof b !== "string") throw new HexclaveAssertionError(`Expected two strings for stringCompare, found ${typeof a26} and ${typeof b}`, {
3996
- a: a26,
3997
- b
3998
- });
3999
- const cmp = (a27, b2) => a27 < b2 ? -1 : a27 > b2 ? 1 : 0;
4000
- return cmp(a26.toUpperCase(), b.toUpperCase()) || cmp(b, a26);
4001
- }
4002
- function getWhitespacePrefix(s8) {
4003
- return s8.substring(0, s8.length - s8.trimStart().length);
4004
- }
4005
- function trimEmptyLinesStart(s8) {
4006
- const lines = s8.split("\n");
4007
- const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== "");
4008
- if (firstNonEmptyLineIndex === -1) return "";
4009
- return lines.slice(firstNonEmptyLineIndex).join("\n");
4010
- }
4011
- function trimEmptyLinesEnd(s8) {
4012
- const lines = s8.split("\n");
4013
- const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== "");
4014
- return lines.slice(0, lastNonEmptyLineIndex + 1).join("\n");
4015
- }
4016
- function templateIdentity(strings, ...values) {
4017
- if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4018
- strings,
4019
- values
4020
- });
4021
- return strings.reduce((result, str, i) => result + str + (values[i] ?? ""), "");
4022
- }
4023
- function deindent(strings, ...values) {
4024
- if (typeof strings === "string") return deindent([strings]);
4025
- return templateIdentity(...deindentTemplate(strings, ...values));
4026
- }
4027
- function deindentTemplate(strings, ...values) {
4028
- if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4029
- strings,
4030
- values
4031
- });
4032
- const trimmedStrings = [...strings];
4033
- trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + "+").slice(0, -1);
4034
- trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd("+" + trimmedStrings[trimmedStrings.length - 1]).slice(1);
4035
- const indentation = trimmedStrings.join("${SOME_VALUE}").split("\n").filter((line) => line.trim() !== "").map((line) => getWhitespacePrefix(line).length).reduce((min4, current) => Math.min(min4, current), Infinity);
4036
- const deindentedStrings = trimmedStrings.map((string2, stringIndex) => {
4037
- return string2.split("\n").map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation)).join("\n");
4038
- });
4039
- return [deindentedStrings, ...values.map((value, i) => {
4040
- const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split("\n").at(-1));
4041
- return `${value}`.replaceAll("\n", `
4042
- ${firstLineIndentation}`);
4043
- })];
4044
- }
4045
- function escapeTemplateLiteral(s8) {
4046
- return s8.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${");
4047
- }
4048
- var nicifiableClassNameOverrides = new Map(Object.entries({ Headers }).map(([k3, v]) => [v, k3]));
4049
- function nicify(value, options = {}) {
4050
- const fullOptions = {
4051
- maxDepth: 5,
4052
- currentIndent: "",
4053
- lineIndent: " ",
4054
- multiline: true,
4055
- refs: /* @__PURE__ */ new Map(),
4056
- path: "value",
4057
- parent: null,
4058
- overrides: () => null,
4059
- keyInParent: null,
4060
- hideFields: [],
4061
- ...filterUndefined(options)
4062
- };
4063
- const { maxDepth, currentIndent, lineIndent, multiline, refs, path, overrides, hideFields } = fullOptions;
4064
- const nl = `
4065
- ${currentIndent}`;
4066
- const overrideResult = overrides(value, options);
4067
- if (overrideResult !== null) return overrideResult;
4068
- if ([
4069
- "function",
4070
- "object",
4071
- "symbol"
4072
- ].includes(typeof value) && value !== null) {
4073
- if (refs.has(value)) return `Ref<${refs.get(value)}>`;
4074
- refs.set(value, path);
4075
- }
4076
- const newOptions = {
4077
- maxDepth: maxDepth - 1,
4078
- currentIndent,
4079
- lineIndent,
4080
- multiline,
4081
- refs,
4082
- path: path + "->[unknown property]",
4083
- overrides,
4084
- parent: {
4085
- value,
4086
- options: fullOptions
4087
- },
4088
- keyInParent: null,
4089
- hideFields: []
4090
- };
4091
- const nestedNicify = (newValue, newPath, keyInParent, options2 = {}) => {
4092
- return nicify(newValue, {
4093
- ...newOptions,
4094
- path: newPath,
4095
- currentIndent: currentIndent + lineIndent,
4096
- keyInParent,
4097
- ...options2
4098
- });
4099
- };
4100
- switch (typeof value) {
4101
- case "boolean":
4102
- case "number":
4103
- return JSON.stringify(value);
4104
- case "string": {
4105
- const isDeindentable = (v) => deindent(v) === v && v.includes("\n");
4106
- const wrapInDeindent = (v) => deindent`
4107
- deindent\`
4108
- ${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll("\n", nl + lineIndent)}
4109
- ${currentIndent}\`
4110
- `;
4111
- if (isDeindentable(value)) return wrapInDeindent(value);
4112
- else if (value.endsWith("\n") && isDeindentable(value.slice(0, -1))) return wrapInDeindent(value.slice(0, -1)) + ' + "\\n"';
4113
- else return JSON.stringify(value);
4114
- }
4115
- case "undefined":
4116
- return "undefined";
4117
- case "symbol":
4118
- return value.toString();
4119
- case "bigint":
4120
- return `${value}n`;
4121
- case "function":
4122
- if (value.name) return `function ${value.name}(...) { ... }`;
4123
- return `(...) => { ... }`;
4124
- case "object": {
4125
- if (value === null) return "null";
4126
- if (Array.isArray(value)) {
4127
- const extraLines2 = getNicifiedObjectExtraLines(value);
4128
- const resValueLength2 = value.length + extraLines2.length;
4129
- if (resValueLength2 === 0) return "[]";
4130
- if (maxDepth <= 0) return `[...]`;
4131
- const resValues2 = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));
4132
- resValues2.push(...extraLines2);
4133
- if (resValues2.length !== resValueLength2) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4134
- value,
4135
- resValues: resValues2,
4136
- resValueLength: resValueLength2
4137
- });
4138
- if (resValues2.length > 4 || resValues2.some((x) => resValues2.length > 1 && x.length > 4 || x.includes("\n"))) return `[${nl}${resValues2.map((x) => `${lineIndent}${x},${nl}`).join("")}]`;
4139
- else return `[${resValues2.join(", ")}]`;
4140
- }
4141
- if (value instanceof Date) return `Date(${nestedNicify(value.toISOString(), `${path}.toISOString()`, null)})`;
4142
- if (value instanceof URL) return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;
4143
- if (ArrayBuffer.isView(value)) return `${value.constructor.name}([${value.toString()}])`;
4144
- if (value instanceof ArrayBuffer) return `ArrayBuffer [${new Uint8Array(value).toString()}]`;
4145
- if (value instanceof Error) {
4146
- let stack = value.stack ?? "";
4147
- const toString3 = value.toString();
4148
- if (!stack.startsWith(toString3)) stack = `${toString3}
4149
- ${stack}`;
4150
- stack = stack.trimEnd();
4151
- stack = stack.replace(/\n\s+/g, `
4152
- ${lineIndent}${lineIndent}`);
4153
- stack = stack.replace("\n", `
4154
- ${lineIndent}Stack:
4155
- `);
4156
- if (Object.keys(value).length > 0) stack += `
4157
- ${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;
4158
- if (value.cause) stack += `
4159
- ${lineIndent}Cause:
4160
- ${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;
4161
- stack = stack.replaceAll("\n", `
4162
- ${currentIndent}`);
4163
- return stack;
4164
- }
4165
- const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name;
4166
- const constructorString = constructorName ? `${constructorName} ` : "";
4167
- const entries = getNicifiableEntries(value).filter(([k3]) => !hideFields.includes(k3));
4168
- const extraLines = [...getNicifiedObjectExtraLines(value), ...hideFields.length > 0 ? [`<some fields may have been hidden>`] : []];
4169
- const resValueLength = entries.length + extraLines.length;
4170
- if (resValueLength === 0) return `${constructorString}{}`;
4171
- if (maxDepth <= 0) return `${constructorString}{ ... }`;
4172
- const resValues = entries.map(([k3, v], keyIndex) => {
4173
- const keyNicified = nestedNicify(k3, `Object.keys(${path})[${keyIndex}]`, null);
4174
- const keyInObjectLiteral = typeof k3 === "string" ? nicifyPropertyString(k3) : `[${keyNicified}]`;
4175
- if (typeof v === "function" && v.name === k3) return `${keyInObjectLiteral}(...): { ... }`;
4176
- else return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k3)}`;
4177
- });
4178
- resValues.push(...extraLines);
4179
- if (resValues.length !== resValueLength) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4180
- value,
4181
- resValues,
4182
- resValueLength
4183
- });
4184
- const shouldIndent = resValues.length > 1 || resValues.some((x) => x.includes("\n"));
4185
- if (resValues.length === 0) return `${constructorString}{}`;
4186
- if (shouldIndent) return `${constructorString}{${nl}${resValues.map((x) => `${lineIndent}${x},${nl}`).join("")}}`;
4187
- else return `${constructorString}{ ${resValues.join(", ")} }`;
4188
- }
4189
- default:
4190
- return `${typeof value}<${value}>`;
4191
- }
4192
- }
4193
- function nicifyPropertyString(str) {
4194
- return JSON.stringify(str);
4195
- }
4196
- function getNicifiableKeys(value) {
4197
- const overridden = ("getNicifiableKeys" in value ? value.getNicifiableKeys?.bind(value) : null)?.();
4198
- if (overridden != null) return overridden;
4199
- if (value instanceof Response) return ["status", "headers"];
4200
- return unique(Object.keys(value).sort());
4201
- }
4202
- function getNicifiableEntries(value) {
4203
- const recordLikes = [Headers];
4204
- function isRecordLike(value2) {
4205
- return recordLikes.some((x) => value2 instanceof x);
4206
- }
4207
- if (isRecordLike(value)) return [...value.entries()].sort(([a26], [b]) => stringCompare(`${a26}`, `${b}`));
4208
- return getNicifiableKeys(value).map((k3) => [k3, value[k3]]);
4209
- }
4210
- function getNicifiedObjectExtraLines(value) {
4211
- return ("getNicifiedObjectExtraLines" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];
4212
- }
4213
-
4214
3984
  // ../shared/dist/esm/utils/functions.js
4215
3985
  function identityArgs(...args) {
4216
3986
  return args;
@@ -4324,6 +4094,38 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4324
4094
  }
4325
4095
  };
4326
4096
  HexclaveAssertionError.prototype.name = "HexclaveAssertionError";
4097
+ var hexclaveSetupErrorBrand = "hexclave-setup-error-brand-sentinel";
4098
+ var HexclaveSetupError = class extends Error {
4099
+ constructor(options) {
4100
+ super(options.message, pick(options.extraData ?? {}, ["cause"]));
4101
+ this.title = options.title;
4102
+ this.howToFix = options.howToFix;
4103
+ Object.defineProperty(this, hexclaveSetupErrorBrand, {
4104
+ value: true,
4105
+ enumerable: false
4106
+ });
4107
+ Object.defineProperty(this, "customCaptureExtraArgs", {
4108
+ get() {
4109
+ return [{
4110
+ ...options.extraData,
4111
+ howToFix: options.howToFix
4112
+ }];
4113
+ },
4114
+ enumerable: false
4115
+ });
4116
+ }
4117
+ /**
4118
+ * Like `instanceof`, but also true for setup errors thrown by another copy of this package — an app can easily end up
4119
+ * with two of them, and a setup error from either must still show up as one.
4120
+ */
4121
+ static isSetupError(error) {
4122
+ if (typeof error !== "object" || error === null) return false;
4123
+ if (!Object.prototype.hasOwnProperty.call(error, hexclaveSetupErrorBrand)) return false;
4124
+ if (Reflect.get(error, hexclaveSetupErrorBrand) !== true) return false;
4125
+ return typeof Reflect.get(error, "title") === "string" && Array.isArray(Reflect.get(error, "howToFix"));
4126
+ }
4127
+ };
4128
+ HexclaveSetupError.prototype.name = "HexclaveSetupError";
4327
4129
  function errorToNiceString(error) {
4328
4130
  if (!(error instanceof Error)) return `${typeof error}<${nicify(error)}>`;
4329
4131
  return nicify(error, { maxDepth: 8 });
@@ -4522,25 +4324,234 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4522
4324
  }, _a);
4523
4325
  StatusError.prototype.name = "StatusError";
4524
4326
 
4525
- // ../shared/dist/esm/utils/env.js
4526
- function resolveHexclaveStackEnvVarValue(hexclaveName, stackName, hexclaveValue, stackValue) {
4527
- if (hexclaveValue && stackValue && hexclaveValue !== stackValue) throw new Error(`Environment variables ${hexclaveName} and ${stackName} are both set to different values. Remove one of them or set them to the same value.`);
4528
- return hexclaveValue || stackValue || void 0;
4327
+ // ../shared/dist/esm/utils/arrays.js
4328
+ function findLastIndex(arr, predicate) {
4329
+ for (let i = arr.length - 1; i >= 0; i--) if (predicate(arr[i])) return i;
4330
+ return -1;
4529
4331
  }
4530
- function getEnvVarWithHexclaveFallback(name) {
4531
- if (name.includes("STACK_")) {
4532
- const hexclaveName = name.replace("STACK_", "HEXCLAVE_");
4533
- return resolveHexclaveStackEnvVarValue(hexclaveName, name, process.env[hexclaveName], process.env[name]);
4332
+ function unique(arr) {
4333
+ return [...new Set(arr)];
4334
+ }
4335
+
4336
+ // ../shared/dist/esm/utils/strings.js
4337
+ function stringCompare(a26, b) {
4338
+ if (typeof a26 !== "string" || typeof b !== "string") throw new HexclaveAssertionError(`Expected two strings for stringCompare, found ${typeof a26} and ${typeof b}`, {
4339
+ a: a26,
4340
+ b
4341
+ });
4342
+ const cmp = (a27, b2) => a27 < b2 ? -1 : a27 > b2 ? 1 : 0;
4343
+ return cmp(a26.toUpperCase(), b.toUpperCase()) || cmp(b, a26);
4344
+ }
4345
+ function getWhitespacePrefix(s8) {
4346
+ return s8.substring(0, s8.length - s8.trimStart().length);
4347
+ }
4348
+ function trimEmptyLinesStart(s8) {
4349
+ const lines = s8.split("\n");
4350
+ const firstNonEmptyLineIndex = lines.findIndex((line) => line.trim() !== "");
4351
+ if (firstNonEmptyLineIndex === -1) return "";
4352
+ return lines.slice(firstNonEmptyLineIndex).join("\n");
4353
+ }
4354
+ function trimEmptyLinesEnd(s8) {
4355
+ const lines = s8.split("\n");
4356
+ const lastNonEmptyLineIndex = findLastIndex(lines, (line) => line.trim() !== "");
4357
+ return lines.slice(0, lastNonEmptyLineIndex + 1).join("\n");
4358
+ }
4359
+ function templateIdentity(strings, ...values) {
4360
+ if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4361
+ strings,
4362
+ values
4363
+ });
4364
+ return strings.reduce((result, str, i) => result + str + (values[i] ?? ""), "");
4365
+ }
4366
+ function deindent(strings, ...values) {
4367
+ if (typeof strings === "string") return deindent([strings]);
4368
+ return templateIdentity(...deindentTemplate(strings, ...values));
4369
+ }
4370
+ function deindentTemplate(strings, ...values) {
4371
+ if (values.length !== strings.length - 1) throw new HexclaveAssertionError("Invalid number of values; must be one less than strings", {
4372
+ strings,
4373
+ values
4374
+ });
4375
+ const trimmedStrings = [...strings];
4376
+ trimmedStrings[0] = trimEmptyLinesStart(trimmedStrings[0] + "+").slice(0, -1);
4377
+ trimmedStrings[trimmedStrings.length - 1] = trimEmptyLinesEnd("+" + trimmedStrings[trimmedStrings.length - 1]).slice(1);
4378
+ const indentation = trimmedStrings.join("${SOME_VALUE}").split("\n").filter((line) => line.trim() !== "").map((line) => getWhitespacePrefix(line).length).reduce((min4, current) => Math.min(min4, current), Infinity);
4379
+ const deindentedStrings = trimmedStrings.map((string2, stringIndex) => {
4380
+ return string2.split("\n").map((line, lineIndex) => stringIndex !== 0 && lineIndex === 0 ? line : line.substring(indentation)).join("\n");
4381
+ });
4382
+ return [deindentedStrings, ...values.map((value, i) => {
4383
+ const firstLineIndentation = getWhitespacePrefix(deindentedStrings[i].split("\n").at(-1));
4384
+ return `${value}`.replaceAll("\n", `
4385
+ ${firstLineIndentation}`);
4386
+ })];
4387
+ }
4388
+ function escapeTemplateLiteral(s8) {
4389
+ return s8.replaceAll("\\", "\\\\").replaceAll("`", "\\`").replaceAll("${", "\\${");
4390
+ }
4391
+ var nicifiableClassNameOverrides = new Map(Object.entries({ Headers }).map(([k3, v]) => [v, k3]));
4392
+ function nicify(value, options = {}) {
4393
+ const fullOptions = {
4394
+ maxDepth: 5,
4395
+ currentIndent: "",
4396
+ lineIndent: " ",
4397
+ multiline: true,
4398
+ refs: /* @__PURE__ */ new Map(),
4399
+ path: "value",
4400
+ parent: null,
4401
+ overrides: () => null,
4402
+ keyInParent: null,
4403
+ hideFields: [],
4404
+ ...filterUndefined(options)
4405
+ };
4406
+ const { maxDepth, currentIndent, lineIndent, multiline, refs, path, overrides, hideFields } = fullOptions;
4407
+ const nl = `
4408
+ ${currentIndent}`;
4409
+ const overrideResult = overrides(value, options);
4410
+ if (overrideResult !== null) return overrideResult;
4411
+ if ([
4412
+ "function",
4413
+ "object",
4414
+ "symbol"
4415
+ ].includes(typeof value) && value !== null) {
4416
+ if (refs.has(value)) return `Ref<${refs.get(value)}>`;
4417
+ refs.set(value, path);
4418
+ }
4419
+ const newOptions = {
4420
+ maxDepth: maxDepth - 1,
4421
+ currentIndent,
4422
+ lineIndent,
4423
+ multiline,
4424
+ refs,
4425
+ path: path + "->[unknown property]",
4426
+ overrides,
4427
+ parent: {
4428
+ value,
4429
+ options: fullOptions
4430
+ },
4431
+ keyInParent: null,
4432
+ hideFields: []
4433
+ };
4434
+ const nestedNicify = (newValue, newPath, keyInParent, options2 = {}) => {
4435
+ return nicify(newValue, {
4436
+ ...newOptions,
4437
+ path: newPath,
4438
+ currentIndent: currentIndent + lineIndent,
4439
+ keyInParent,
4440
+ ...options2
4441
+ });
4442
+ };
4443
+ switch (typeof value) {
4444
+ case "boolean":
4445
+ case "number":
4446
+ return JSON.stringify(value);
4447
+ case "string": {
4448
+ const isDeindentable = (v) => deindent(v) === v && v.includes("\n");
4449
+ const wrapInDeindent = (v) => deindent`
4450
+ deindent\`
4451
+ ${currentIndent + lineIndent}${escapeTemplateLiteral(v).replaceAll("\n", nl + lineIndent)}
4452
+ ${currentIndent}\`
4453
+ `;
4454
+ if (isDeindentable(value)) return wrapInDeindent(value);
4455
+ else if (value.endsWith("\n") && isDeindentable(value.slice(0, -1))) return wrapInDeindent(value.slice(0, -1)) + ' + "\\n"';
4456
+ else return JSON.stringify(value);
4457
+ }
4458
+ case "undefined":
4459
+ return "undefined";
4460
+ case "symbol":
4461
+ return value.toString();
4462
+ case "bigint":
4463
+ return `${value}n`;
4464
+ case "function":
4465
+ if (value.name) return `function ${value.name}(...) { ... }`;
4466
+ return `(...) => { ... }`;
4467
+ case "object": {
4468
+ if (value === null) return "null";
4469
+ if (Array.isArray(value)) {
4470
+ const extraLines2 = getNicifiedObjectExtraLines(value);
4471
+ const resValueLength2 = value.length + extraLines2.length;
4472
+ if (resValueLength2 === 0) return "[]";
4473
+ if (maxDepth <= 0) return `[...]`;
4474
+ const resValues2 = value.map((v, i) => nestedNicify(v, `${path}[${i}]`, i));
4475
+ resValues2.push(...extraLines2);
4476
+ if (resValues2.length !== resValueLength2) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4477
+ value,
4478
+ resValues: resValues2,
4479
+ resValueLength: resValueLength2
4480
+ });
4481
+ if (resValues2.length > 4 || resValues2.some((x) => resValues2.length > 1 && x.length > 4 || x.includes("\n"))) return `[${nl}${resValues2.map((x) => `${lineIndent}${x},${nl}`).join("")}]`;
4482
+ else return `[${resValues2.join(", ")}]`;
4483
+ }
4484
+ if (value instanceof Date) return `Date(${nestedNicify(value.toISOString(), `${path}.toISOString()`, null)})`;
4485
+ if (value instanceof URL) return `URL(${nestedNicify(value.toString(), `${path}.toString()`, null)})`;
4486
+ if (ArrayBuffer.isView(value)) return `${value.constructor.name}([${value.toString()}])`;
4487
+ if (value instanceof ArrayBuffer) return `ArrayBuffer [${new Uint8Array(value).toString()}]`;
4488
+ if (value instanceof Error) {
4489
+ let stack = value.stack ?? "";
4490
+ const toString3 = value.toString();
4491
+ if (!stack.startsWith(toString3)) stack = `${toString3}
4492
+ ${stack}`;
4493
+ stack = stack.trimEnd();
4494
+ stack = stack.replace(/\n\s+/g, `
4495
+ ${lineIndent}${lineIndent}`);
4496
+ stack = stack.replace("\n", `
4497
+ ${lineIndent}Stack:
4498
+ `);
4499
+ if (Object.keys(value).length > 0) stack += `
4500
+ ${lineIndent}Extra properties: ${nestedNicify(Object.fromEntries(Object.entries(value)), path, null)}`;
4501
+ if (value.cause) stack += `
4502
+ ${lineIndent}Cause:
4503
+ ${lineIndent}${lineIndent}${nestedNicify(value.cause, path, null, { currentIndent: currentIndent + lineIndent + lineIndent })}`;
4504
+ stack = stack.replaceAll("\n", `
4505
+ ${currentIndent}`);
4506
+ return stack;
4507
+ }
4508
+ const constructorName = [null, Object.prototype].includes(Object.getPrototypeOf(value)) ? null : nicifiableClassNameOverrides.get(value.constructor) ?? value.constructor.name;
4509
+ const constructorString = constructorName ? `${constructorName} ` : "";
4510
+ const entries = getNicifiableEntries(value).filter(([k3]) => !hideFields.includes(k3));
4511
+ const extraLines = [...getNicifiedObjectExtraLines(value), ...hideFields.length > 0 ? [`<some fields may have been hidden>`] : []];
4512
+ const resValueLength = entries.length + extraLines.length;
4513
+ if (resValueLength === 0) return `${constructorString}{}`;
4514
+ if (maxDepth <= 0) return `${constructorString}{ ... }`;
4515
+ const resValues = entries.map(([k3, v], keyIndex) => {
4516
+ const keyNicified = nestedNicify(k3, `Object.keys(${path})[${keyIndex}]`, null);
4517
+ const keyInObjectLiteral = typeof k3 === "string" ? nicifyPropertyString(k3) : `[${keyNicified}]`;
4518
+ if (typeof v === "function" && v.name === k3) return `${keyInObjectLiteral}(...): { ... }`;
4519
+ else return `${keyInObjectLiteral}: ${nestedNicify(v, `${path}[${keyNicified}]`, k3)}`;
4520
+ });
4521
+ resValues.push(...extraLines);
4522
+ if (resValues.length !== resValueLength) throw new HexclaveAssertionError("nicify of object: resValues.length !== resValueLength", {
4523
+ value,
4524
+ resValues,
4525
+ resValueLength
4526
+ });
4527
+ const shouldIndent = resValues.length > 1 || resValues.some((x) => x.includes("\n"));
4528
+ if (resValues.length === 0) return `${constructorString}{}`;
4529
+ if (shouldIndent) return `${constructorString}{${nl}${resValues.map((x) => `${lineIndent}${x},${nl}`).join("")}}`;
4530
+ else return `${constructorString}{ ${resValues.join(", ")} }`;
4531
+ }
4532
+ default:
4533
+ return `${typeof value}<${value}>`;
4534
4534
  }
4535
- if (name.includes("HEXCLAVE_")) {
4536
- const stackName = name.replace("HEXCLAVE_", "STACK_");
4537
- return resolveHexclaveStackEnvVarValue(name, stackName, process.env[name], process.env[stackName]);
4535
+ }
4536
+ function nicifyPropertyString(str) {
4537
+ return JSON.stringify(str);
4538
+ }
4539
+ function getNicifiableKeys(value) {
4540
+ const overridden = ("getNicifiableKeys" in value ? value.getNicifiableKeys?.bind(value) : null)?.();
4541
+ if (overridden != null) return overridden;
4542
+ if (value instanceof Response) return ["status", "headers"];
4543
+ return unique(Object.keys(value).sort());
4544
+ }
4545
+ function getNicifiableEntries(value) {
4546
+ const recordLikes = [Headers];
4547
+ function isRecordLike(value2) {
4548
+ return recordLikes.some((x) => value2 instanceof x);
4538
4549
  }
4539
- return process.env[name];
4550
+ if (isRecordLike(value)) return [...value.entries()].sort(([a26], [b]) => stringCompare(`${a26}`, `${b}`));
4551
+ return getNicifiableKeys(value).map((k3) => [k3, value[k3]]);
4540
4552
  }
4541
- function getProcessEnv(name) {
4542
- if (typeof process === "undefined" || typeof process.env === "undefined") return;
4543
- return getEnvVarWithHexclaveFallback(name);
4553
+ function getNicifiedObjectExtraLines(value) {
4554
+ return ("getNicifiedObjectExtraLines" in value ? value.getNicifiedObjectExtraLines : null)?.() ?? [];
4544
4555
  }
4545
4556
 
4546
4557
  // ../shared/dist/esm/utils/results.js
@@ -4665,6 +4676,49 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4665
4676
  return Object.assign(Result.error(new RetryError(errors)), { attempts: totalAttempts });
4666
4677
  }
4667
4678
 
4679
+ // ../shared/dist/esm/utils/bytes.js
4680
+ function decodeBase64(input) {
4681
+ return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
4682
+ }
4683
+ function isBase64(input) {
4684
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
4685
+ }
4686
+
4687
+ // ../shared/dist/esm/utils/urls.js
4688
+ function createUrlIfValid(...args) {
4689
+ try {
4690
+ return new URL(...args);
4691
+ } catch (e40) {
4692
+ return null;
4693
+ }
4694
+ }
4695
+ function isValidUrl(url) {
4696
+ return !!createUrlIfValid(url);
4697
+ }
4698
+ function isValidHostname(hostname) {
4699
+ if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
4700
+ const url = createUrlIfValid(`https://${hostname}`);
4701
+ if (!url) return false;
4702
+ return url.hostname === hostname;
4703
+ }
4704
+ function isValidHostnameWithWildcards(hostname) {
4705
+ if (!hostname) return false;
4706
+ if (!hostname.includes("*")) return isValidHostname(hostname);
4707
+ if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
4708
+ if (hostname.includes("..")) return false;
4709
+ const testHostname = hostname.replace(/\*+/g, "wildcard");
4710
+ if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
4711
+ const segments = hostname.split(/\*+/);
4712
+ for (let i = 0; i < segments.length; i++) {
4713
+ const segment = segments[i];
4714
+ if (segment === "") continue;
4715
+ if (i === 0 && segment.startsWith(".")) return false;
4716
+ if (i === segments.length - 1 && segment.endsWith(".")) return false;
4717
+ if (segment.includes("..")) return false;
4718
+ }
4719
+ return true;
4720
+ }
4721
+
4668
4722
  // ../shared/dist/esm/known-errors.js
4669
4723
  var KnownError = class extends StatusError {
4670
4724
  constructor(statusCode, humanReadableMessage, details) {
@@ -5421,49 +5475,6 @@ This is likely an error in Hexclave. Please make sure you are running the newest
5421
5475
  knownErrorCodes.add(KnownError2.errorCode);
5422
5476
  }
5423
5477
 
5424
- // ../shared/dist/esm/utils/bytes.js
5425
- function decodeBase64(input) {
5426
- return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
5427
- }
5428
- function isBase64(input) {
5429
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
5430
- }
5431
-
5432
- // ../shared/dist/esm/utils/urls.js
5433
- function createUrlIfValid(...args) {
5434
- try {
5435
- return new URL(...args);
5436
- } catch (e40) {
5437
- return null;
5438
- }
5439
- }
5440
- function isValidUrl(url) {
5441
- return !!createUrlIfValid(url);
5442
- }
5443
- function isValidHostname(hostname) {
5444
- if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
5445
- const url = createUrlIfValid(`https://${hostname}`);
5446
- if (!url) return false;
5447
- return url.hostname === hostname;
5448
- }
5449
- function isValidHostnameWithWildcards(hostname) {
5450
- if (!hostname) return false;
5451
- if (!hostname.includes("*")) return isValidHostname(hostname);
5452
- if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
5453
- if (hostname.includes("..")) return false;
5454
- const testHostname = hostname.replace(/\*+/g, "wildcard");
5455
- if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
5456
- const segments = hostname.split(/\*+/);
5457
- for (let i = 0; i < segments.length; i++) {
5458
- const segment = segments[i];
5459
- if (segment === "") continue;
5460
- if (i === 0 && segment.startsWith(".")) return false;
5461
- if (i === segments.length - 1 && segment.endsWith(".")) return false;
5462
- if (segment.includes("..")) return false;
5463
- }
5464
- return true;
5465
- }
5466
-
5467
5478
  // ../../node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.esm.js
5468
5479
  var import_property_expr = __toESM(require_property_expr());
5469
5480
  var import_tiny_case = __toESM(require_tiny_case());
@@ -7817,6 +7828,27 @@ attempted value: ${formattedValue}
7817
7828
  }
7818
7829
  ];
7819
7830
 
7831
+ // ../shared/dist/esm/utils/env.js
7832
+ function resolveHexclaveStackEnvVarValue(hexclaveName, stackName, hexclaveValue, stackValue) {
7833
+ if (hexclaveValue && stackValue && hexclaveValue !== stackValue) throw new Error(`Environment variables ${hexclaveName} and ${stackName} are both set to different values. Remove one of them or set them to the same value.`);
7834
+ return hexclaveValue || stackValue || void 0;
7835
+ }
7836
+ function getEnvVarWithHexclaveFallback(name) {
7837
+ if (name.includes("STACK_")) {
7838
+ const hexclaveName = name.replace("STACK_", "HEXCLAVE_");
7839
+ return resolveHexclaveStackEnvVarValue(hexclaveName, name, process.env[hexclaveName], process.env[name]);
7840
+ }
7841
+ if (name.includes("HEXCLAVE_")) {
7842
+ const stackName = name.replace("HEXCLAVE_", "STACK_");
7843
+ return resolveHexclaveStackEnvVarValue(name, stackName, process.env[name], process.env[stackName]);
7844
+ }
7845
+ return process.env[name];
7846
+ }
7847
+ function getProcessEnv(name) {
7848
+ if (typeof process === "undefined" || typeof process.env === "undefined") return;
7849
+ return getEnvVarWithHexclaveFallback(name);
7850
+ }
7851
+
7820
7852
  // ../shared/dist/esm/utils/http.js
7821
7853
  function decodeBasicAuthorizationHeader(value) {
7822
7854
  const [type, encoded, ...rest] = value.split(" ");
@@ -8774,210 +8806,6 @@ attempted value: ${formattedValue}
8774
8806
  diff: yupString().optional()
8775
8807
  });
8776
8808
 
8777
- // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
8778
- var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
8779
- var E_ALREADY_LOCKED = new Error("mutex already locked");
8780
- var E_CANCELED = new Error("request for lock canceled");
8781
- var __awaiter$2 = function(thisArg, _arguments, P2, generator) {
8782
- function adopt(value) {
8783
- return value instanceof P2 ? value : new P2(function(resolve) {
8784
- resolve(value);
8785
- });
8786
- }
8787
- return new (P2 || (P2 = Promise))(function(resolve, reject) {
8788
- function fulfilled(value) {
8789
- try {
8790
- step(generator.next(value));
8791
- } catch (e40) {
8792
- reject(e40);
8793
- }
8794
- }
8795
- function rejected2(value) {
8796
- try {
8797
- step(generator["throw"](value));
8798
- } catch (e40) {
8799
- reject(e40);
8800
- }
8801
- }
8802
- function step(result) {
8803
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
8804
- }
8805
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8806
- });
8807
- };
8808
- var Semaphore = class {
8809
- constructor(_value, _cancelError = E_CANCELED) {
8810
- this._value = _value;
8811
- this._cancelError = _cancelError;
8812
- this._queue = [];
8813
- this._weightedWaiters = [];
8814
- }
8815
- acquire(weight = 1, priority = 0) {
8816
- if (weight <= 0)
8817
- throw new Error(`invalid weight ${weight}: must be positive`);
8818
- return new Promise((resolve, reject) => {
8819
- const task = { resolve, reject, weight, priority };
8820
- const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
8821
- if (i === -1 && weight <= this._value) {
8822
- this._dispatchItem(task);
8823
- } else {
8824
- this._queue.splice(i + 1, 0, task);
8825
- }
8826
- });
8827
- }
8828
- runExclusive(callback_1) {
8829
- return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
8830
- const [value, release] = yield this.acquire(weight, priority);
8831
- try {
8832
- return yield callback(value);
8833
- } finally {
8834
- release();
8835
- }
8836
- });
8837
- }
8838
- waitForUnlock(weight = 1, priority = 0) {
8839
- if (weight <= 0)
8840
- throw new Error(`invalid weight ${weight}: must be positive`);
8841
- if (this._couldLockImmediately(weight, priority)) {
8842
- return Promise.resolve();
8843
- } else {
8844
- return new Promise((resolve) => {
8845
- if (!this._weightedWaiters[weight - 1])
8846
- this._weightedWaiters[weight - 1] = [];
8847
- insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
8848
- });
8849
- }
8850
- }
8851
- isLocked() {
8852
- return this._value <= 0;
8853
- }
8854
- getValue() {
8855
- return this._value;
8856
- }
8857
- setValue(value) {
8858
- this._value = value;
8859
- this._dispatchQueue();
8860
- }
8861
- release(weight = 1) {
8862
- if (weight <= 0)
8863
- throw new Error(`invalid weight ${weight}: must be positive`);
8864
- this._value += weight;
8865
- this._dispatchQueue();
8866
- }
8867
- cancel() {
8868
- this._queue.forEach((entry) => entry.reject(this._cancelError));
8869
- this._queue = [];
8870
- }
8871
- _dispatchQueue() {
8872
- this._drainUnlockWaiters();
8873
- while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
8874
- this._dispatchItem(this._queue.shift());
8875
- this._drainUnlockWaiters();
8876
- }
8877
- }
8878
- _dispatchItem(item) {
8879
- const previousValue = this._value;
8880
- this._value -= item.weight;
8881
- item.resolve([previousValue, this._newReleaser(item.weight)]);
8882
- }
8883
- _newReleaser(weight) {
8884
- let called = false;
8885
- return () => {
8886
- if (called)
8887
- return;
8888
- called = true;
8889
- this.release(weight);
8890
- };
8891
- }
8892
- _drainUnlockWaiters() {
8893
- if (this._queue.length === 0) {
8894
- for (let weight = this._value; weight > 0; weight--) {
8895
- const waiters = this._weightedWaiters[weight - 1];
8896
- if (!waiters)
8897
- continue;
8898
- waiters.forEach((waiter) => waiter.resolve());
8899
- this._weightedWaiters[weight - 1] = [];
8900
- }
8901
- } else {
8902
- const queuedPriority = this._queue[0].priority;
8903
- for (let weight = this._value; weight > 0; weight--) {
8904
- const waiters = this._weightedWaiters[weight - 1];
8905
- if (!waiters)
8906
- continue;
8907
- const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
8908
- (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
8909
- }
8910
- }
8911
- }
8912
- _couldLockImmediately(weight, priority) {
8913
- return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
8914
- }
8915
- };
8916
- function insertSorted(a26, v) {
8917
- const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
8918
- a26.splice(i + 1, 0, v);
8919
- }
8920
- function findIndexFromEnd(a26, predicate) {
8921
- for (let i = a26.length - 1; i >= 0; i--) {
8922
- if (predicate(a26[i])) {
8923
- return i;
8924
- }
8925
- }
8926
- return -1;
8927
- }
8928
-
8929
- // ../shared/dist/esm/utils/locks.js
8930
- var ReadWriteLock = class {
8931
- constructor() {
8932
- this.semaphore = new Semaphore(1);
8933
- this.readers = 0;
8934
- this.readersMutex = new Semaphore(1);
8935
- }
8936
- async withReadLock(callback) {
8937
- await this._acquireReadLock();
8938
- try {
8939
- return await callback();
8940
- } finally {
8941
- await this._releaseReadLock();
8942
- }
8943
- }
8944
- async withWriteLock(callback) {
8945
- await this._acquireWriteLock();
8946
- try {
8947
- return await callback();
8948
- } finally {
8949
- await this._releaseWriteLock();
8950
- }
8951
- }
8952
- async _acquireReadLock() {
8953
- await this.readersMutex.acquire();
8954
- try {
8955
- this.readers += 1;
8956
- if (this.readers === 1) await this.semaphore.acquire();
8957
- } finally {
8958
- this.readersMutex.release();
8959
- }
8960
- }
8961
- async _releaseReadLock() {
8962
- await this.readersMutex.acquire();
8963
- try {
8964
- this.readers -= 1;
8965
- if (this.readers === 0) this.semaphore.release();
8966
- } finally {
8967
- this.readersMutex.release();
8968
- }
8969
- }
8970
- async _acquireWriteLock() {
8971
- await this.semaphore.acquire();
8972
- }
8973
- async _releaseWriteLock() {
8974
- this.semaphore.release();
8975
- }
8976
- };
8977
-
8978
- // ../shared/dist/esm/utils/stores.js
8979
- var storeLock = new ReadWriteLock();
8980
-
8981
8809
  // ../shared/dist/esm/interface/client-interface.js
8982
8810
  var USER_AGENT;
8983
8811
  if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.5`;