@hexclave/dashboard-ui-components 1.0.0 → 1.0.1

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 (83) hide show
  1. package/dist/components/alert.js +4 -4
  2. package/dist/components/alert.js.map +1 -1
  3. package/dist/components/analytics-chart/analytics-chart-pie.js +33 -11
  4. package/dist/components/analytics-chart/analytics-chart-pie.js.map +1 -1
  5. package/dist/components/analytics-chart/analytics-chart.js +3 -3
  6. package/dist/components/analytics-chart/analytics-chart.js.map +1 -1
  7. package/dist/components/analytics-chart/default-analytics-chart-tooltip.js +4 -4
  8. package/dist/components/analytics-chart/default-analytics-chart-tooltip.js.map +1 -1
  9. package/dist/components/analytics-chart/types.d.ts +1 -0
  10. package/dist/components/analytics-chart/types.d.ts.map +1 -1
  11. package/dist/components/analytics-chart/types.js.map +1 -1
  12. package/dist/components/badge.js +2 -2
  13. package/dist/components/badge.js.map +1 -1
  14. package/dist/components/button.js +11 -11
  15. package/dist/components/button.js.map +1 -1
  16. package/dist/components/card.js +7 -7
  17. package/dist/components/card.js.map +1 -1
  18. package/dist/components/chart-card.js +3 -3
  19. package/dist/components/chart-card.js.map +1 -1
  20. package/dist/components/chart-container.js +2 -2
  21. package/dist/components/chart-container.js.map +1 -1
  22. package/dist/components/chart-legend.js +3 -3
  23. package/dist/components/chart-legend.js.map +1 -1
  24. package/dist/components/chart-tooltip.js +7 -7
  25. package/dist/components/chart-tooltip.js.map +1 -1
  26. package/dist/components/data-grid/data-grid-toolbar.js +7 -7
  27. package/dist/components/data-grid/data-grid-toolbar.js.map +1 -1
  28. package/dist/components/data-grid/data-grid.js +16 -16
  29. package/dist/components/data-grid/data-grid.js.map +1 -1
  30. package/dist/components/data-grid/state.js +2 -2
  31. package/dist/components/data-grid/state.js.map +1 -1
  32. package/dist/components/dialog.js +22 -22
  33. package/dist/components/dialog.js.map +1 -1
  34. package/dist/components/empty-state.js +2 -2
  35. package/dist/components/empty-state.js.map +1 -1
  36. package/dist/components/input.js +8 -8
  37. package/dist/components/input.js.map +1 -1
  38. package/dist/components/metric-card.js +5 -5
  39. package/dist/components/metric-card.js.map +1 -1
  40. package/dist/components/pill-toggle.js +11 -10
  41. package/dist/components/pill-toggle.js.map +1 -1
  42. package/dist/components/progress-bar.js +4 -4
  43. package/dist/components/progress-bar.js.map +1 -1
  44. package/dist/components/separator.js +2 -2
  45. package/dist/components/separator.js.map +1 -1
  46. package/dist/components/skeleton.js +2 -2
  47. package/dist/components/skeleton.js.map +1 -1
  48. package/dist/components/table.js +14 -14
  49. package/dist/components/table.js.map +1 -1
  50. package/dist/components/tabs.js +10 -10
  51. package/dist/components/tabs.js.map +1 -1
  52. package/dist/dashboard-ui-components.global.js +1647 -1605
  53. package/dist/dashboard-ui-components.global.js.map +4 -4
  54. package/dist/esm/components/alert.js.map +1 -1
  55. package/dist/esm/components/analytics-chart/analytics-chart-pie.js +33 -11
  56. package/dist/esm/components/analytics-chart/analytics-chart-pie.js.map +1 -1
  57. package/dist/esm/components/analytics-chart/analytics-chart.js.map +1 -1
  58. package/dist/esm/components/analytics-chart/default-analytics-chart-tooltip.js.map +1 -1
  59. package/dist/esm/components/analytics-chart/types.d.ts +1 -0
  60. package/dist/esm/components/analytics-chart/types.d.ts.map +1 -1
  61. package/dist/esm/components/analytics-chart/types.js.map +1 -1
  62. package/dist/esm/components/badge.js.map +1 -1
  63. package/dist/esm/components/button.js.map +1 -1
  64. package/dist/esm/components/card.js.map +1 -1
  65. package/dist/esm/components/chart-card.js.map +1 -1
  66. package/dist/esm/components/chart-container.js.map +1 -1
  67. package/dist/esm/components/chart-legend.js.map +1 -1
  68. package/dist/esm/components/chart-tooltip.js.map +1 -1
  69. package/dist/esm/components/data-grid/data-grid-toolbar.js.map +1 -1
  70. package/dist/esm/components/data-grid/data-grid.js.map +1 -1
  71. package/dist/esm/components/data-grid/state.js.map +1 -1
  72. package/dist/esm/components/dialog.js.map +1 -1
  73. package/dist/esm/components/empty-state.js.map +1 -1
  74. package/dist/esm/components/input.js.map +1 -1
  75. package/dist/esm/components/metric-card.js.map +1 -1
  76. package/dist/esm/components/pill-toggle.js +1 -0
  77. package/dist/esm/components/pill-toggle.js.map +1 -1
  78. package/dist/esm/components/progress-bar.js.map +1 -1
  79. package/dist/esm/components/separator.js.map +1 -1
  80. package/dist/esm/components/skeleton.js.map +1 -1
  81. package/dist/esm/components/table.js.map +1 -1
  82. package/dist/esm/components/tabs.js.map +1 -1
  83. package/package.json +4 -4
@@ -1641,19 +1641,23 @@ This is likely an error in Hexclave. Please make sure you are running the newest
1641
1641
  if (errorSinks.has(sink)) return;
1642
1642
  errorSinks.add(sink);
1643
1643
  }
1644
- registerErrorSink((location, error, ...extraArgs) => {
1645
- console.error(`\x1B[41mCaptured error in ${location}:`, errorToNiceString(error), ...extraArgs, "\x1B[0m");
1644
+ registerErrorSink((location, error, level, ...extraArgs) => {
1645
+ (level === "warning" ? console.warn : console.error)(`${level === "warning" ? "\x1B[43m" : "\x1B[41m"}Captured ${level === "warning" ? "warning" : "error"} in ${location}:`, errorToNiceString(error), ...extraArgs, "\x1B[0m");
1646
1646
  });
1647
- registerErrorSink((location, error, ...extraArgs) => {
1647
+ registerErrorSink((location, error, level, ...extraArgs) => {
1648
1648
  globalVar.stackCapturedErrors = globalVar.stackCapturedErrors ?? [];
1649
1649
  globalVar.stackCapturedErrors.push({
1650
1650
  location,
1651
1651
  error,
1652
+ level,
1652
1653
  extraArgs
1653
1654
  });
1654
1655
  });
1656
+ function dispatchToSinks(location, error, level) {
1657
+ for (const sink of errorSinks) sink(location, error, level, ...error && (typeof error === "object" || typeof error === "function") && "customCaptureExtraArgs" in error && Array.isArray(error.customCaptureExtraArgs) ? error.customCaptureExtraArgs : []);
1658
+ }
1655
1659
  function captureError(location, error) {
1656
- for (const sink of errorSinks) sink(location, error, ...error && (typeof error === "object" || typeof error === "function") && "customCaptureExtraArgs" in error && Array.isArray(error.customCaptureExtraArgs) ? error.customCaptureExtraArgs : []);
1660
+ dispatchToSinks(location, error, "error");
1657
1661
  }
1658
1662
  var _a;
1659
1663
  var StatusError = (_a = class extends Error {
@@ -4442,1322 +4446,444 @@ This is likely an error in Hexclave. Please make sure you are running the newest
4442
4446
  return Object.assign(Result.error(new RetryError(errors)), { attempts: totalAttempts });
4443
4447
  }
4444
4448
 
4445
- // ../stack-shared/dist/esm/utils/maps.js
4446
- var _Symbol$toStringTag;
4447
- var _Symbol$toStringTag2;
4448
- var _Symbol$toStringTag3;
4449
- var WeakRefIfAvailable = class {
4450
- constructor(value) {
4451
- if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
4452
- else this._ref = new WeakRef(value);
4453
- }
4454
- deref() {
4455
- return this._ref.deref();
4456
- }
4457
- };
4458
- var _a2;
4459
- var IterableWeakMap = (_a2 = class {
4460
- constructor(entries) {
4461
- this[_Symbol$toStringTag] = "IterableWeakMap";
4462
- const mappedEntries = entries?.map((e40) => [e40[0], {
4463
- value: e40[1],
4464
- keyRef: new WeakRefIfAvailable(e40[0])
4465
- }]);
4466
- this._weakMap = new WeakMap(mappedEntries ?? []);
4467
- this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
4468
- }
4469
- get(key) {
4470
- return this._weakMap.get(key)?.value;
4471
- }
4472
- set(key, value) {
4473
- const updated = {
4474
- value,
4475
- keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
4476
- };
4477
- this._weakMap.set(key, updated);
4478
- this._keyRefs.add(updated.keyRef);
4479
- return this;
4480
- }
4481
- delete(key) {
4482
- const res = this._weakMap.get(key);
4483
- if (res) {
4484
- this._weakMap.delete(key);
4485
- this._keyRefs.delete(res.keyRef);
4486
- return true;
4487
- }
4488
- return false;
4489
- }
4490
- has(key) {
4491
- return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
4492
- }
4493
- *[Symbol.iterator]() {
4494
- for (const keyRef of this._keyRefs) {
4495
- const key = keyRef.deref();
4496
- const existing = key ? this._weakMap.get(key) : void 0;
4497
- if (!key) this._keyRefs.delete(keyRef);
4498
- else if (existing) yield [key, existing.value];
4499
- }
4449
+ // ../stack-shared/dist/esm/utils/bytes.js
4450
+ function decodeBase64(input) {
4451
+ return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
4452
+ }
4453
+ function isBase64(input) {
4454
+ return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
4455
+ }
4456
+
4457
+ // ../stack-shared/dist/esm/utils/urls.js
4458
+ function createUrlIfValid(...args) {
4459
+ try {
4460
+ return new URL(...args);
4461
+ } catch (e40) {
4462
+ return null;
4500
4463
  }
4501
- }, _Symbol$toStringTag = Symbol.toStringTag, _a2);
4502
- var _a3;
4503
- var MaybeWeakMap = (_a3 = class {
4504
- constructor(entries) {
4505
- this[_Symbol$toStringTag2] = "MaybeWeakMap";
4506
- const entriesArray = [...entries ?? []];
4507
- this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
4508
- this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
4464
+ }
4465
+ function isValidUrl(url) {
4466
+ return !!createUrlIfValid(url);
4467
+ }
4468
+ function isValidHostname(hostname) {
4469
+ if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
4470
+ const url = createUrlIfValid(`https://${hostname}`);
4471
+ if (!url) return false;
4472
+ return url.hostname === hostname;
4473
+ }
4474
+ function isValidHostnameWithWildcards(hostname) {
4475
+ if (!hostname) return false;
4476
+ if (!hostname.includes("*")) return isValidHostname(hostname);
4477
+ if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
4478
+ if (hostname.includes("..")) return false;
4479
+ const testHostname = hostname.replace(/\*+/g, "wildcard");
4480
+ if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
4481
+ const segments = hostname.split(/\*+/);
4482
+ for (let i = 0; i < segments.length; i++) {
4483
+ const segment = segments[i];
4484
+ if (segment === "") continue;
4485
+ if (i === 0 && segment.startsWith(".")) return false;
4486
+ if (i === segments.length - 1 && segment.endsWith(".")) return false;
4487
+ if (segment.includes("..")) return false;
4509
4488
  }
4510
- _isAllowedInWeakMap(key) {
4511
- return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
4489
+ return true;
4490
+ }
4491
+
4492
+ // ../stack-shared/dist/esm/known-errors.js
4493
+ var KnownError = class extends StatusError {
4494
+ constructor(statusCode, humanReadableMessage, details) {
4495
+ super(statusCode, humanReadableMessage);
4496
+ this.statusCode = statusCode;
4497
+ this.humanReadableMessage = humanReadableMessage;
4498
+ this.details = details;
4499
+ this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
4500
+ this.name = "KnownError";
4512
4501
  }
4513
- get(key) {
4514
- if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
4515
- else return this._primitiveMap.get(key);
4502
+ static isKnownError(error) {
4503
+ return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
4516
4504
  }
4517
- set(key, value) {
4518
- if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
4519
- else this._primitiveMap.set(key, value);
4520
- return this;
4505
+ getBody() {
4506
+ return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
4521
4507
  }
4522
- delete(key) {
4523
- if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
4524
- else return this._primitiveMap.delete(key);
4508
+ getHeaders() {
4509
+ return {
4510
+ "Content-Type": ["application/json; charset=utf-8"],
4511
+ "X-Stack-Known-Error": [this.errorCode],
4512
+ "X-Hexclave-Known-Error": [this.errorCode]
4513
+ };
4525
4514
  }
4526
- has(key) {
4527
- if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
4528
- else return this._primitiveMap.has(key);
4515
+ toDescriptiveJson() {
4516
+ return {
4517
+ code: this.errorCode,
4518
+ ...this.details ? { details: this.details } : {},
4519
+ error: this.humanReadableMessage
4520
+ };
4529
4521
  }
4530
- *[Symbol.iterator]() {
4531
- yield* this._primitiveMap;
4532
- yield* this._weakMap;
4522
+ get errorCode() {
4523
+ return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
4533
4524
  }
4534
- }, _Symbol$toStringTag2 = Symbol.toStringTag, _a3);
4535
- var _a4;
4536
- var DependenciesMap = (_a4 = class {
4537
- constructor() {
4538
- this._inner = {
4539
- map: new MaybeWeakMap(),
4540
- hasValue: false,
4541
- value: void 0
4542
- };
4543
- this[_Symbol$toStringTag3] = "DependenciesMap";
4525
+ static constructorArgsFromJson(json) {
4526
+ return [
4527
+ 400,
4528
+ json.message,
4529
+ json
4530
+ ];
4544
4531
  }
4545
- _valueToResult(inner) {
4546
- if (inner.hasValue) return Result.ok(inner.value);
4547
- else return Result.error(void 0);
4532
+ static fromJson(json) {
4533
+ for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
4534
+ throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
4548
4535
  }
4549
- _unwrapFromInner(dependencies, inner) {
4550
- if (dependencies.length === 0) return this._valueToResult(inner);
4551
- else {
4552
- const [key, ...rest] = dependencies;
4553
- const newInner = inner.map.get(key);
4554
- if (!newInner) return Result.error(void 0);
4555
- return this._unwrapFromInner(rest, newInner);
4536
+ };
4537
+ function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
4538
+ const createFn = create === "inherit" ? identityArgs : create;
4539
+ const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
4540
+ const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
4541
+ constructor(...args) {
4542
+ super(...createFn(...args));
4543
+ this.name = `KnownError<${errorCode}>`;
4544
+ this.constructorArgs = args;
4556
4545
  }
4557
- }
4558
- _setInInner(dependencies, value, inner) {
4559
- if (dependencies.length === 0) {
4560
- const res = this._valueToResult(inner);
4561
- if (value.status === "ok") {
4562
- inner.hasValue = true;
4563
- inner.value = value.data;
4564
- } else {
4565
- inner.hasValue = false;
4566
- inner.value = void 0;
4546
+ static constructorArgsFromJson(json) {
4547
+ return constructorArgsFromJsonFn(json.details);
4548
+ }
4549
+ static isInstance(error) {
4550
+ if (!KnownError.isKnownError(error)) return false;
4551
+ let current = error;
4552
+ while (true) {
4553
+ current = Object.getPrototypeOf(current);
4554
+ if (!current) break;
4555
+ if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
4567
4556
  }
4568
- return res;
4569
- } else {
4570
- const [key, ...rest] = dependencies;
4571
- let newInner = inner.map.get(key);
4572
- if (!newInner) inner.map.set(key, newInner = {
4573
- map: new MaybeWeakMap(),
4574
- hasValue: false,
4575
- value: void 0
4576
- });
4577
- return this._setInInner(rest, value, newInner);
4557
+ return false;
4578
4558
  }
4579
- }
4580
- *_iterateInner(dependencies, inner) {
4581
- if (inner.hasValue) yield [dependencies, inner.value];
4582
- for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
4583
- }
4584
- get(dependencies) {
4585
- return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
4586
- }
4587
- set(dependencies, value) {
4588
- this._setInInner(dependencies, Result.ok(value), this._inner);
4589
- return this;
4590
- }
4591
- delete(dependencies) {
4592
- return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
4593
- }
4594
- has(dependencies) {
4595
- return this._unwrapFromInner(dependencies, this._inner).status === "ok";
4596
- }
4597
- clear() {
4598
- this._inner = {
4599
- map: new MaybeWeakMap(),
4600
- hasValue: false,
4601
- value: void 0
4602
- };
4603
- }
4604
- *[Symbol.iterator]() {
4605
- yield* this._iterateInner([], this._inner);
4606
- }
4607
- }, _Symbol$toStringTag3 = Symbol.toStringTag, _a4);
4608
-
4609
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
4610
- var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
4611
-
4612
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
4613
- var VERSION = "1.9.0";
4614
-
4615
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
4616
- var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
4617
- function _makeCompatibilityCheck(ownVersion) {
4618
- var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
4619
- var rejectedVersions = /* @__PURE__ */ new Set();
4620
- var myVersionMatch = ownVersion.match(re);
4621
- if (!myVersionMatch) {
4622
- return function() {
4623
- return false;
4624
- };
4625
- }
4626
- var ownVersionParsed = {
4627
- major: +myVersionMatch[1],
4628
- minor: +myVersionMatch[2],
4629
- patch: +myVersionMatch[3],
4630
- prerelease: myVersionMatch[4]
4631
- };
4632
- if (ownVersionParsed.prerelease != null) {
4633
- return function isExactmatch(globalVersion) {
4634
- return globalVersion === ownVersion;
4635
- };
4636
- }
4637
- function _reject(v) {
4638
- rejectedVersions.add(v);
4639
- return false;
4640
- }
4641
- function _accept(v) {
4642
- acceptedVersions.add(v);
4643
- return true;
4644
- }
4645
- return function isCompatible2(globalVersion) {
4646
- if (acceptedVersions.has(globalVersion)) {
4647
- return true;
4648
- }
4649
- if (rejectedVersions.has(globalVersion)) {
4650
- return false;
4651
- }
4652
- var globalVersionMatch = globalVersion.match(re);
4653
- if (!globalVersionMatch) {
4654
- return _reject(globalVersion);
4655
- }
4656
- var globalVersionParsed = {
4657
- major: +globalVersionMatch[1],
4658
- minor: +globalVersionMatch[2],
4659
- patch: +globalVersionMatch[3],
4660
- prerelease: globalVersionMatch[4]
4661
- };
4662
- if (globalVersionParsed.prerelease != null) {
4663
- return _reject(globalVersion);
4664
- }
4665
- if (ownVersionParsed.major !== globalVersionParsed.major) {
4666
- return _reject(globalVersion);
4667
- }
4668
- if (ownVersionParsed.major === 0) {
4669
- if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
4670
- return _accept(globalVersion);
4671
- }
4672
- return _reject(globalVersion);
4673
- }
4674
- if (ownVersionParsed.minor <= globalVersionParsed.minor) {
4675
- return _accept(globalVersion);
4676
- }
4677
- return _reject(globalVersion);
4678
4559
  };
4560
+ _KnownErrorImpl.errorCode = errorCode;
4561
+ let KnownErrorImpl = _KnownErrorImpl;
4562
+ return KnownErrorImpl;
4679
4563
  }
4680
- var isCompatible = _makeCompatibilityCheck(VERSION);
4564
+ var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
4565
+ 500,
4566
+ `An error occurred that is not currently supported (possibly because it was added in a version of Stack that is newer than this client). The original unsupported error code was: ${originalErrorCode}`,
4567
+ { originalErrorCode }
4568
+ ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
4569
+ var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message) => [400, message], (json) => [json.message]);
4570
+ var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message) => [
4571
+ 400,
4572
+ message || throwErr("SchemaError requires a message"),
4573
+ { message }
4574
+ ], (json) => [json.message]);
4575
+ var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
4576
+ 400,
4577
+ deindent`
4578
+ This endpoint has multiple overloads, but they all failed to process the request.
4681
4579
 
4682
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
4683
- var major = VERSION.split(".")[0];
4684
- var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
4685
- var _global = _globalThis;
4686
- function registerGlobal(type, instance, diag, allowOverride) {
4687
- var _a5;
4688
- if (allowOverride === void 0) {
4689
- allowOverride = false;
4690
- }
4691
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
4692
- version: VERSION
4693
- };
4694
- if (!allowOverride && api[type]) {
4695
- var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
4696
- diag.error(err.stack || err.message);
4697
- return false;
4698
- }
4699
- if (api.version !== VERSION) {
4700
- var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
4701
- diag.error(err.stack || err.message);
4702
- return false;
4703
- }
4704
- api[type] = instance;
4705
- diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
4706
- return true;
4707
- }
4708
- function getGlobal(type) {
4709
- var _a5, _b;
4710
- var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
4711
- if (!globalVersion || !isCompatible(globalVersion)) {
4712
- return;
4713
- }
4714
- return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
4715
- }
4716
- function unregisterGlobal(type, diag) {
4717
- diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
4718
- var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
4719
- if (api) {
4720
- delete api[type];
4580
+ ${overloadErrors.map((e40, i) => deindent`
4581
+ Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
4582
+ `).join("\n\n")}
4583
+ `,
4584
+ { overload_errors: overloadErrors }
4585
+ ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
4586
+ var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
4587
+ var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
4588
+ var ProjectKeyWithoutAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "PROJECT_KEY_WITHOUT_ACCESS_TYPE", () => [400, "Either an API key or an admin access token was provided, but the x-hexclave-access-type header is missing. Set it to 'client', 'server', or 'admin' as appropriate. (The legacy x-stack-access-type header is also accepted.)"], () => []);
4589
+ var InvalidAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ACCESS_TYPE", (accessType) => [400, `The x-hexclave-access-type header must be 'client', 'server', or 'admin', but was '${accessType}'. (The legacy x-stack-access-type header is also accepted.)`], (json) => [json?.accessType ?? throwErr("accessType not found in InvalidAccessType details")]);
4590
+ var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
4591
+ 400,
4592
+ deindent`
4593
+ The x-hexclave-access-type header was '${accessType}', but the x-hexclave-project-id header was not provided. (The legacy x-stack-access-type and x-stack-project-id headers are also accepted.)
4594
+
4595
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/rest-api/overview#authentication
4596
+ `,
4597
+ { request_type: accessType }
4598
+ ], (json) => [json.request_type]);
4599
+ var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
4600
+ You must specify an access level for this Hexclave project. Make sure project API keys are provided (eg. x-hexclave-publishable-client-key) and you set the x-hexclave-access-type header to 'client', 'server', or 'admin'. (The legacy x-stack-* equivalents are also accepted.)
4601
+
4602
+ For more information, see the docs on REST API authentication: https://docs.hexclave.com/rest-api/overview#authentication
4603
+ `], () => []);
4604
+ var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
4605
+ 401,
4606
+ `The x-hexclave-access-type header must be ${allowedAccessTypes.map((s8) => `'${s8}'`).join(" or ")}, but was '${actualAccessType}'. (The legacy x-stack-access-type header is also accepted.)`,
4607
+ {
4608
+ actual_access_type: actualAccessType,
4609
+ allowed_access_types: allowedAccessTypes
4721
4610
  }
4722
- }
4611
+ ], (json) => [json.actual_access_type, json.allowed_access_types]);
4612
+ var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
4613
+ 401,
4614
+ `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4615
+ { project_id: projectId }
4616
+ ], (json) => [json.project_id]);
4617
+ var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
4618
+ 401,
4619
+ `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4620
+ { project_id: projectId }
4621
+ ], (json) => [json.project_id]);
4622
+ var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
4623
+ 401,
4624
+ `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
4625
+ { project_id: projectId }
4626
+ ], (json) => [json.project_id]);
4627
+ var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
4628
+ var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
4629
+ var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
4630
+ 401,
4631
+ `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
4632
+ { expired_at_millis: expiredAt?.getTime() ?? null }
4633
+ ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
4634
+ var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
4635
+ var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
4636
+ var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
4637
+ var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
4638
+ var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
4639
+ 401,
4640
+ "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
4641
+ { project_id: projectId ?? null }
4642
+ ], (json) => [json.project_id ?? void 0]);
4643
+ var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
4644
+ var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
4645
+ var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
4646
+ var ClientOrServerOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key, the secret server key, or the super secret admin key must be provided."], () => []);
4647
+ var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
4648
+ var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
4649
+ var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
4650
+ var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
4651
+ var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
4652
+ var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
4653
+ var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
4654
+ 401,
4655
+ deindent`
4656
+ Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}${projectId ? ` Project ID: ${projectId}.` : ""}${userId ? ` User ID: ${userId}.` : ""}${refreshTokenId ? ` Refresh token ID: ${refreshTokenId}.` : ""}
4723
4657
 
4724
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
4725
- var __read = function(o21, n9) {
4726
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
4727
- if (!m5) return o21;
4728
- var i = m5.call(o21), r7, ar = [], e40;
4729
- try {
4730
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4731
- } catch (error) {
4732
- e40 = { error };
4733
- } finally {
4734
- try {
4735
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
4736
- } finally {
4737
- if (e40) throw e40.error;
4738
- }
4658
+ Debug info: Most likely, you fetched the access token before it expired (for example, in a server component, pre-rendered page, or on page load), but then didn't refresh it before it expired. If this is the case, and you're using the SDK, make sure you call getAccessToken() every time you need to use the access token. If you're not using the SDK, make sure you refresh the access token with the refresh endpoint.
4659
+ `,
4660
+ {
4661
+ expired_at_millis: expiredAt?.getTime() ?? null,
4662
+ project_id: projectId ?? null,
4663
+ user_id: userId ?? null,
4664
+ refresh_token_id: refreshTokenId ?? null
4739
4665
  }
4740
- return ar;
4741
- };
4742
- var __spreadArray = function(to, from, pack) {
4743
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4744
- if (ar || !(i in from)) {
4745
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4746
- ar[i] = from[i];
4747
- }
4666
+ ], (json) => [
4667
+ json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
4668
+ json.project_id ?? void 0,
4669
+ json.user_id ?? void 0,
4670
+ json.refresh_token_id ?? void 0
4671
+ ]);
4672
+ var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
4673
+ 401,
4674
+ `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
4675
+ {
4676
+ expected_project_id: expectedProjectId,
4677
+ actual_project_id: actualProjectId
4748
4678
  }
4749
- return to.concat(ar || Array.prototype.slice.call(from));
4750
- };
4751
- var DiagComponentLogger = (
4752
- /** @class */
4753
- function() {
4754
- function DiagComponentLogger2(props) {
4755
- this._namespace = props.namespace || "DiagComponentLogger";
4756
- }
4757
- DiagComponentLogger2.prototype.debug = function() {
4758
- var args = [];
4759
- for (var _i = 0; _i < arguments.length; _i++) {
4760
- args[_i] = arguments[_i];
4761
- }
4762
- return logProxy("debug", this._namespace, args);
4763
- };
4764
- DiagComponentLogger2.prototype.error = function() {
4765
- var args = [];
4766
- for (var _i = 0; _i < arguments.length; _i++) {
4767
- args[_i] = arguments[_i];
4768
- }
4769
- return logProxy("error", this._namespace, args);
4770
- };
4771
- DiagComponentLogger2.prototype.info = function() {
4772
- var args = [];
4773
- for (var _i = 0; _i < arguments.length; _i++) {
4774
- args[_i] = arguments[_i];
4775
- }
4776
- return logProxy("info", this._namespace, args);
4777
- };
4778
- DiagComponentLogger2.prototype.warn = function() {
4779
- var args = [];
4780
- for (var _i = 0; _i < arguments.length; _i++) {
4781
- args[_i] = arguments[_i];
4782
- }
4783
- return logProxy("warn", this._namespace, args);
4784
- };
4785
- DiagComponentLogger2.prototype.verbose = function() {
4786
- var args = [];
4787
- for (var _i = 0; _i < arguments.length; _i++) {
4788
- args[_i] = arguments[_i];
4789
- }
4790
- return logProxy("verbose", this._namespace, args);
4791
- };
4792
- return DiagComponentLogger2;
4793
- }()
4794
- );
4795
- function logProxy(funcName, namespace, args) {
4796
- var logger = getGlobal("diag");
4797
- if (!logger) {
4798
- return;
4679
+ ], (json) => [json.expected_project_id, json.actual_project_id]);
4680
+ var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
4681
+ var RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(RefreshTokenError, "REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED", () => [401, "Refresh token not found for this project, or the session has expired/been revoked."], () => []);
4682
+ var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
4683
+ var ProviderRejected = createKnownErrorConstructor(RefreshTokenError, "PROVIDER_REJECTED", () => [401, "The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate."], () => []);
4684
+ var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
4685
+ 409,
4686
+ `A user with email ${JSON.stringify(email)} already exists${wouldWorkIfEmailWasVerified ? " but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method." : "."}`,
4687
+ {
4688
+ email,
4689
+ would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
4799
4690
  }
4800
- args.unshift(namespace);
4801
- return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
4802
- }
4803
-
4804
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
4805
- var DiagLogLevel;
4806
- (function(DiagLogLevel2) {
4807
- DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
4808
- DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
4809
- DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
4810
- DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
4811
- DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
4812
- DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
4813
- DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
4814
- })(DiagLogLevel || (DiagLogLevel = {}));
4815
-
4816
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
4817
- function createLogLevelDiagLogger(maxLevel, logger) {
4818
- if (maxLevel < DiagLogLevel.NONE) {
4819
- maxLevel = DiagLogLevel.NONE;
4820
- } else if (maxLevel > DiagLogLevel.ALL) {
4821
- maxLevel = DiagLogLevel.ALL;
4691
+ ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
4692
+ var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
4693
+ var CannotGetOwnUserWithoutUser = createKnownErrorConstructor(KnownError, "CANNOT_GET_OWN_USER_WITHOUT_USER", () => [400, "You have specified 'me' as a userId, but did not provide authentication for a user."], () => []);
4694
+ var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
4695
+ 400,
4696
+ `The given user with the ID ${userId} does not exist.`,
4697
+ { user_id: userId }
4698
+ ], (json) => [json.user_id]);
4699
+ var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
4700
+ var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
4701
+ 403,
4702
+ `The user in the access token is in restricted state. Reason: ${restrictedReason.type}. Please pass the X-Stack-Allow-Restricted-User header if this is intended.`,
4703
+ { restricted_reason: restrictedReason }
4704
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
4705
+ var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
4706
+ if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
4707
+ return [
4708
+ 404,
4709
+ `Project ${projectId} not found or is not accessible with the current user.`,
4710
+ { project_id: projectId }
4711
+ ];
4712
+ }, (json) => [json.project_id]);
4713
+ var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
4714
+ 400,
4715
+ `The current project with ID ${projectId} was not found. Please check the value of the x-hexclave-project-id header. (The legacy x-stack-project-id header is also accepted.)`,
4716
+ { project_id: projectId }
4717
+ ], (json) => [json.project_id]);
4718
+ var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
4719
+ 400,
4720
+ `The branch with ID ${branchId} does not exist.`,
4721
+ { branch_id: branchId }
4722
+ ], (json) => [json.branch_id]);
4723
+ var SignUpNotEnabled = createKnownErrorConstructor(KnownError, "SIGN_UP_NOT_ENABLED", () => [400, "Creation of new accounts is not enabled for this project. Please ask the project owner to enable it."], () => []);
4724
+ var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message) => [
4725
+ 403,
4726
+ message ?? "Your sign up was rejected by an administrator's sign-up rule.",
4727
+ { message: message ?? "Your sign up was rejected by an administrator's sign-up rule." }
4728
+ ], (json) => [json.message]);
4729
+ var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
4730
+ var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message) => [
4731
+ 400,
4732
+ message,
4733
+ { message }
4734
+ ], (json) => [json.message]);
4735
+ var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
4736
+ var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
4737
+ 400,
4738
+ `Data vault store with ID ${storeId} does not exist.`,
4739
+ { store_id: storeId }
4740
+ ], (json) => [json.store_id]);
4741
+ var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
4742
+ 400,
4743
+ `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
4744
+ {
4745
+ store_id: storeId,
4746
+ hashed_key: hashedKey
4822
4747
  }
4823
- logger = logger || {};
4824
- function _filterFunc(funcName, theLevel) {
4825
- var theFunc = logger[funcName];
4826
- if (typeof theFunc === "function" && maxLevel >= theLevel) {
4827
- return theFunc.bind(logger);
4828
- }
4829
- return function() {
4830
- };
4748
+ ], (json) => [json.store_id, json.hashed_key]);
4749
+ var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
4750
+ var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
4751
+ var AnonymousAuthenticationNotAllowed = createKnownErrorConstructor(KnownError, "ANONYMOUS_AUTHENTICATION_NOT_ALLOWED", () => [401, "X-Stack-Access-Token is for an anonymous user, but anonymous users are not enabled. Set the X-Stack-Allow-Anonymous-User header of this request to 'true' to allow anonymous users."], () => []);
4752
+ var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
4753
+ var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", () => [400, "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?"], () => []);
4754
+ var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
4755
+ var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
4756
+ 400,
4757
+ `Password too short. Minimum length is ${minLength}.`,
4758
+ { min_length: minLength }
4759
+ ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
4760
+ var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
4761
+ 400,
4762
+ `Password too long. Maximum length is ${maxLength}.`,
4763
+ { maxLength }
4764
+ ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
4765
+ var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
4766
+ var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
4767
+ var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
4768
+ var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
4769
+ var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
4770
+ var VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_MAX_ATTEMPTS_REACHED", () => [400, "The verification code nonce has reached the maximum number of attempts. This code is not valid anymore."], () => []);
4771
+ var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
4772
+ var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
4773
+ var EmailNotAssociatedWithUser = createKnownErrorConstructor(KnownError, "EMAIL_NOT_ASSOCIATED_WITH_USER", () => [400, "The e-mail is not associated with a user that could log in with that e-mail."], () => []);
4774
+ var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
4775
+ 400,
4776
+ `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
4777
+ {
4778
+ email,
4779
+ primary_email: primaryEmail
4831
4780
  }
4832
- return {
4833
- error: _filterFunc("error", DiagLogLevel.ERROR),
4834
- warn: _filterFunc("warn", DiagLogLevel.WARN),
4835
- info: _filterFunc("info", DiagLogLevel.INFO),
4836
- debug: _filterFunc("debug", DiagLogLevel.DEBUG),
4837
- verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
4838
- };
4839
- }
4840
-
4841
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
4842
- var __read2 = function(o21, n9) {
4843
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
4844
- if (!m5) return o21;
4845
- var i = m5.call(o21), r7, ar = [], e40;
4846
- try {
4847
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4848
- } catch (error) {
4849
- e40 = { error };
4850
- } finally {
4851
- try {
4852
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
4853
- } finally {
4854
- if (e40) throw e40.error;
4855
- }
4781
+ ], (json) => [json.email, json.primary_email]);
4782
+ var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message) => [400, message], (json) => [json.message]);
4783
+ var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message, code) => [
4784
+ 400,
4785
+ message,
4786
+ {
4787
+ message,
4788
+ code
4856
4789
  }
4857
- return ar;
4858
- };
4859
- var __spreadArray2 = function(to, from, pack) {
4860
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4861
- if (ar || !(i in from)) {
4862
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4863
- ar[i] = from[i];
4864
- }
4790
+ ], (json) => [json.message, json.code]);
4791
+ var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message) => [400, message], (json) => [json.message]);
4792
+ var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
4793
+ 404,
4794
+ `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
4795
+ { permission_id: permissionId }
4796
+ ], (json) => [json.permission_id]);
4797
+ var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
4798
+ 404,
4799
+ `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
4800
+ {
4801
+ permission_id: permissionId,
4802
+ expected_scope: expectedScope,
4803
+ actual_scope: actualScope
4865
4804
  }
4866
- return to.concat(ar || Array.prototype.slice.call(from));
4867
- };
4868
- var API_NAME = "diag";
4869
- var DiagAPI = (
4870
- /** @class */
4871
- function() {
4872
- function DiagAPI2() {
4873
- function _logProxy(funcName) {
4874
- return function() {
4875
- var args = [];
4876
- for (var _i = 0; _i < arguments.length; _i++) {
4877
- args[_i] = arguments[_i];
4878
- }
4879
- var logger = getGlobal("diag");
4880
- if (!logger)
4881
- return;
4882
- return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
4883
- };
4884
- }
4885
- var self2 = this;
4886
- var setLogger = function(logger, optionsOrLogLevel) {
4887
- var _a5, _b, _c;
4888
- if (optionsOrLogLevel === void 0) {
4889
- optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
4890
- }
4891
- if (logger === self2) {
4892
- var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
4893
- self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
4894
- return false;
4895
- }
4896
- if (typeof optionsOrLogLevel === "number") {
4897
- optionsOrLogLevel = {
4898
- logLevel: optionsOrLogLevel
4899
- };
4900
- }
4901
- var oldLogger = getGlobal("diag");
4902
- var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
4903
- if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
4904
- var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
4905
- oldLogger.warn("Current logger will be overwritten from " + stack);
4906
- newLogger.warn("Current logger will overwrite one already registered from " + stack);
4907
- }
4908
- return registerGlobal("diag", newLogger, self2, true);
4909
- };
4910
- self2.setLogger = setLogger;
4911
- self2.disable = function() {
4912
- unregisterGlobal(API_NAME, self2);
4913
- };
4914
- self2.createComponentLogger = function(options) {
4915
- return new DiagComponentLogger(options);
4916
- };
4917
- self2.verbose = _logProxy("verbose");
4918
- self2.debug = _logProxy("debug");
4919
- self2.info = _logProxy("info");
4920
- self2.warn = _logProxy("warn");
4921
- self2.error = _logProxy("error");
4922
- }
4923
- DiagAPI2.instance = function() {
4924
- if (!this._instance) {
4925
- this._instance = new DiagAPI2();
4926
- }
4927
- return this._instance;
4928
- };
4929
- return DiagAPI2;
4930
- }()
4931
- );
4932
-
4933
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
4934
- function createContextKey(description) {
4935
- return Symbol.for(description);
4936
- }
4937
- var BaseContext = (
4938
- /** @class */
4939
- /* @__PURE__ */ function() {
4940
- function BaseContext2(parentContext) {
4941
- var self2 = this;
4942
- self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
4943
- self2.getValue = function(key) {
4944
- return self2._currentContext.get(key);
4945
- };
4946
- self2.setValue = function(key, value) {
4947
- var context = new BaseContext2(self2._currentContext);
4948
- context._currentContext.set(key, value);
4949
- return context;
4950
- };
4951
- self2.deleteValue = function(key) {
4952
- var context = new BaseContext2(self2._currentContext);
4953
- context._currentContext.delete(key);
4954
- return context;
4955
- };
4956
- }
4957
- return BaseContext2;
4958
- }()
4959
- );
4960
- var ROOT_CONTEXT = new BaseContext();
4961
-
4962
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
4963
- var __read3 = function(o21, n9) {
4964
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
4965
- if (!m5) return o21;
4966
- var i = m5.call(o21), r7, ar = [], e40;
4967
- try {
4968
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
4969
- } catch (error) {
4970
- e40 = { error };
4971
- } finally {
4972
- try {
4973
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
4974
- } finally {
4975
- if (e40) throw e40.error;
4976
- }
4805
+ ], (json) => [
4806
+ json.permission_id,
4807
+ json.expected_scope,
4808
+ json.actual_scope
4809
+ ]);
4810
+ var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
4811
+ 400,
4812
+ `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
4813
+ { permission_id: permissionId }
4814
+ ], (json) => [json.permission_id]);
4815
+ var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
4816
+ 404,
4817
+ `Team ${teamId} not found.`,
4818
+ { team_id: teamId }
4819
+ ], (json) => [json.team_id]);
4820
+ createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
4821
+ 409,
4822
+ `Team ${teamId} already exists.`,
4823
+ { team_id: teamId }
4824
+ ], (json) => [json.team_id]);
4825
+ var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
4826
+ 404,
4827
+ `User ${userId} is not found in team ${teamId}.`,
4828
+ {
4829
+ team_id: teamId,
4830
+ user_id: userId
4977
4831
  }
4978
- return ar;
4979
- };
4980
- var __spreadArray3 = function(to, from, pack) {
4981
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
4982
- if (ar || !(i in from)) {
4983
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
4984
- ar[i] = from[i];
4985
- }
4832
+ ], (json) => [json.team_id, json.user_id]);
4833
+ var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
4834
+ 403,
4835
+ `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
4836
+ { restricted_reason: restrictedReason }
4837
+ ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
4838
+ var TeamInvitationEmailMismatch = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_EMAIL_MISMATCH", () => [403, "This team invitation was sent to a different email address. Sign in with the invited email, or add and verify that email on your account, then try again."], () => []);
4839
+ var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
4840
+ var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
4841
+ var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
4842
+ var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
4843
+ var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
4844
+ 400,
4845
+ `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
4846
+ {
4847
+ provider,
4848
+ details
4986
4849
  }
4987
- return to.concat(ar || Array.prototype.slice.call(from));
4988
- };
4989
- var NoopContextManager = (
4990
- /** @class */
4991
- function() {
4992
- function NoopContextManager2() {
4993
- }
4994
- NoopContextManager2.prototype.active = function() {
4995
- return ROOT_CONTEXT;
4996
- };
4997
- NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
4998
- var args = [];
4999
- for (var _i = 3; _i < arguments.length; _i++) {
5000
- args[_i - 3] = arguments[_i];
5001
- }
5002
- return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
5003
- };
5004
- NoopContextManager2.prototype.bind = function(_context, target) {
5005
- return target;
5006
- };
5007
- NoopContextManager2.prototype.enable = function() {
5008
- return this;
5009
- };
5010
- NoopContextManager2.prototype.disable = function() {
5011
- return this;
5012
- };
5013
- return NoopContextManager2;
5014
- }()
5015
- );
5016
-
5017
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
5018
- var __read4 = function(o21, n9) {
5019
- var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
5020
- if (!m5) return o21;
5021
- var i = m5.call(o21), r7, ar = [], e40;
5022
- try {
5023
- while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
5024
- } catch (error) {
5025
- e40 = { error };
5026
- } finally {
5027
- try {
5028
- if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
5029
- } finally {
5030
- if (e40) throw e40.error;
5031
- }
4850
+ ], (json) => [json.provider, json.details]);
4851
+ var OAuthExtraScopeNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_EXTRA_SCOPE_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Extra scopes are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use extra scopes."], () => []);
4852
+ var OAuthAccessTokenNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Access tokens are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use access tokens."], () => []);
4853
+ var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
4854
+ 400,
4855
+ "The OAuth client ID or secret is invalid. The client ID must be equal to the project ID (potentially with a hash and a branch ID), and the client secret must be a publishable client key.",
4856
+ { client_id: clientId ?? null }
4857
+ ], (json) => [json.client_id ?? void 0]);
4858
+ var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
4859
+ var UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor(KnownError, "USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION", () => [409, "The user is already connected to another OAuth account. Did you maybe selected the wrong account?"], () => []);
4860
+ var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
4861
+ var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
4862
+ var AppleBundleIdNotConfigured = createKnownErrorConstructor(KnownError, "APPLE_BUNDLE_ID_NOT_CONFIGURED", () => [400, "Apple Sign In is enabled, but no Bundle IDs are configured. Please add your app's Bundle ID in the Hexclave dashboard under OAuth Providers > Apple > Apple Bundle IDs."], () => []);
4863
+ var OAuthProviderAccountIdAlreadyUsedForSignIn = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_ACCOUNT_ID_ALREADY_USED_FOR_SIGN_IN", () => [400, `A provider with the same account ID is already used for signing in.`], () => []);
4864
+ var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
4865
+ 400,
4866
+ `Multi-factor authentication is required for this user.`,
4867
+ { attempt_code: attemptCode }
4868
+ ], (json) => [json.attempt_code]);
4869
+ var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
4870
+ var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
4871
+ var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
4872
+ var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
4873
+ 401,
4874
+ `User ${userId} does not have permission ${permissionId}.`,
4875
+ {
4876
+ user_id: userId,
4877
+ permission_id: permissionId
5032
4878
  }
5033
- return ar;
5034
- };
5035
- var __spreadArray4 = function(to, from, pack) {
5036
- if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
5037
- if (ar || !(i in from)) {
5038
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
5039
- ar[i] = from[i];
5040
- }
5041
- }
5042
- return to.concat(ar || Array.prototype.slice.call(from));
5043
- };
5044
- var API_NAME2 = "context";
5045
- var NOOP_CONTEXT_MANAGER = new NoopContextManager();
5046
- var ContextAPI = (
5047
- /** @class */
5048
- function() {
5049
- function ContextAPI2() {
5050
- }
5051
- ContextAPI2.getInstance = function() {
5052
- if (!this._instance) {
5053
- this._instance = new ContextAPI2();
5054
- }
5055
- return this._instance;
5056
- };
5057
- ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
5058
- return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
5059
- };
5060
- ContextAPI2.prototype.active = function() {
5061
- return this._getContextManager().active();
5062
- };
5063
- ContextAPI2.prototype.with = function(context, fn, thisArg) {
5064
- var _a5;
5065
- var args = [];
5066
- for (var _i = 3; _i < arguments.length; _i++) {
5067
- args[_i - 3] = arguments[_i];
5068
- }
5069
- return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
5070
- };
5071
- ContextAPI2.prototype.bind = function(context, target) {
5072
- return this._getContextManager().bind(context, target);
5073
- };
5074
- ContextAPI2.prototype._getContextManager = function() {
5075
- return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
5076
- };
5077
- ContextAPI2.prototype.disable = function() {
5078
- this._getContextManager().disable();
5079
- unregisterGlobal(API_NAME2, DiagAPI.instance());
5080
- };
5081
- return ContextAPI2;
5082
- }()
5083
- );
5084
-
5085
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
5086
- var TraceFlags;
5087
- (function(TraceFlags2) {
5088
- TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
5089
- TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
5090
- })(TraceFlags || (TraceFlags = {}));
5091
-
5092
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
5093
- var INVALID_SPANID = "0000000000000000";
5094
- var INVALID_TRACEID = "00000000000000000000000000000000";
5095
- var INVALID_SPAN_CONTEXT = {
5096
- traceId: INVALID_TRACEID,
5097
- spanId: INVALID_SPANID,
5098
- traceFlags: TraceFlags.NONE
5099
- };
5100
-
5101
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
5102
- var NonRecordingSpan = (
5103
- /** @class */
5104
- function() {
5105
- function NonRecordingSpan2(_spanContext) {
5106
- if (_spanContext === void 0) {
5107
- _spanContext = INVALID_SPAN_CONTEXT;
5108
- }
5109
- this._spanContext = _spanContext;
5110
- }
5111
- NonRecordingSpan2.prototype.spanContext = function() {
5112
- return this._spanContext;
5113
- };
5114
- NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
5115
- return this;
5116
- };
5117
- NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
5118
- return this;
5119
- };
5120
- NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
5121
- return this;
5122
- };
5123
- NonRecordingSpan2.prototype.addLink = function(_link) {
5124
- return this;
5125
- };
5126
- NonRecordingSpan2.prototype.addLinks = function(_links) {
5127
- return this;
5128
- };
5129
- NonRecordingSpan2.prototype.setStatus = function(_status) {
5130
- return this;
5131
- };
5132
- NonRecordingSpan2.prototype.updateName = function(_name) {
5133
- return this;
5134
- };
5135
- NonRecordingSpan2.prototype.end = function(_endTime) {
5136
- };
5137
- NonRecordingSpan2.prototype.isRecording = function() {
5138
- return false;
5139
- };
5140
- NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
5141
- };
5142
- return NonRecordingSpan2;
5143
- }()
5144
- );
5145
-
5146
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
5147
- var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
5148
- function getSpan(context) {
5149
- return context.getValue(SPAN_KEY) || void 0;
5150
- }
5151
- function getActiveSpan() {
5152
- return getSpan(ContextAPI.getInstance().active());
5153
- }
5154
- function setSpan(context, span) {
5155
- return context.setValue(SPAN_KEY, span);
5156
- }
5157
- function deleteSpan(context) {
5158
- return context.deleteValue(SPAN_KEY);
5159
- }
5160
- function setSpanContext(context, spanContext) {
5161
- return setSpan(context, new NonRecordingSpan(spanContext));
5162
- }
5163
- function getSpanContext(context) {
5164
- var _a5;
5165
- return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
5166
- }
5167
-
5168
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
5169
- var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
5170
- var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
5171
- function isValidTraceId(traceId) {
5172
- return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
5173
- }
5174
- function isValidSpanId(spanId) {
5175
- return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
5176
- }
5177
- function isSpanContextValid(spanContext) {
5178
- return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
5179
- }
5180
- function wrapSpanContext(spanContext) {
5181
- return new NonRecordingSpan(spanContext);
5182
- }
5183
-
5184
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
5185
- var contextApi = ContextAPI.getInstance();
5186
- var NoopTracer = (
5187
- /** @class */
5188
- function() {
5189
- function NoopTracer2() {
5190
- }
5191
- NoopTracer2.prototype.startSpan = function(name, options, context) {
5192
- if (context === void 0) {
5193
- context = contextApi.active();
5194
- }
5195
- var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
5196
- if (root) {
5197
- return new NonRecordingSpan();
5198
- }
5199
- var parentFromContext = context && getSpanContext(context);
5200
- if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
5201
- return new NonRecordingSpan(parentFromContext);
5202
- } else {
5203
- return new NonRecordingSpan();
5204
- }
5205
- };
5206
- NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
5207
- var opts;
5208
- var ctx;
5209
- var fn;
5210
- if (arguments.length < 2) {
5211
- return;
5212
- } else if (arguments.length === 2) {
5213
- fn = arg2;
5214
- } else if (arguments.length === 3) {
5215
- opts = arg2;
5216
- fn = arg3;
5217
- } else {
5218
- opts = arg2;
5219
- ctx = arg3;
5220
- fn = arg4;
5221
- }
5222
- var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
5223
- var span = this.startSpan(name, opts, parentContext);
5224
- var contextWithSpanSet = setSpan(parentContext, span);
5225
- return contextApi.with(contextWithSpanSet, fn, void 0, span);
5226
- };
5227
- return NoopTracer2;
5228
- }()
5229
- );
5230
- function isSpanContext(spanContext) {
5231
- return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
5232
- }
5233
-
5234
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
5235
- var NOOP_TRACER = new NoopTracer();
5236
- var ProxyTracer = (
5237
- /** @class */
5238
- function() {
5239
- function ProxyTracer2(_provider, name, version, options) {
5240
- this._provider = _provider;
5241
- this.name = name;
5242
- this.version = version;
5243
- this.options = options;
5244
- }
5245
- ProxyTracer2.prototype.startSpan = function(name, options, context) {
5246
- return this._getTracer().startSpan(name, options, context);
5247
- };
5248
- ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
5249
- var tracer2 = this._getTracer();
5250
- return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
5251
- };
5252
- ProxyTracer2.prototype._getTracer = function() {
5253
- if (this._delegate) {
5254
- return this._delegate;
5255
- }
5256
- var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
5257
- if (!tracer2) {
5258
- return NOOP_TRACER;
5259
- }
5260
- this._delegate = tracer2;
5261
- return this._delegate;
5262
- };
5263
- return ProxyTracer2;
5264
- }()
5265
- );
5266
-
5267
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
5268
- var NoopTracerProvider = (
5269
- /** @class */
5270
- function() {
5271
- function NoopTracerProvider2() {
5272
- }
5273
- NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
5274
- return new NoopTracer();
5275
- };
5276
- return NoopTracerProvider2;
5277
- }()
5278
- );
5279
-
5280
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
5281
- var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
5282
- var ProxyTracerProvider = (
5283
- /** @class */
5284
- function() {
5285
- function ProxyTracerProvider2() {
5286
- }
5287
- ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
5288
- var _a5;
5289
- return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
5290
- };
5291
- ProxyTracerProvider2.prototype.getDelegate = function() {
5292
- var _a5;
5293
- return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
5294
- };
5295
- ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
5296
- this._delegate = delegate;
5297
- };
5298
- ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
5299
- var _a5;
5300
- return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
5301
- };
5302
- return ProxyTracerProvider2;
5303
- }()
5304
- );
5305
-
5306
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
5307
- var API_NAME3 = "trace";
5308
- var TraceAPI = (
5309
- /** @class */
5310
- function() {
5311
- function TraceAPI2() {
5312
- this._proxyTracerProvider = new ProxyTracerProvider();
5313
- this.wrapSpanContext = wrapSpanContext;
5314
- this.isSpanContextValid = isSpanContextValid;
5315
- this.deleteSpan = deleteSpan;
5316
- this.getSpan = getSpan;
5317
- this.getActiveSpan = getActiveSpan;
5318
- this.getSpanContext = getSpanContext;
5319
- this.setSpan = setSpan;
5320
- this.setSpanContext = setSpanContext;
5321
- }
5322
- TraceAPI2.getInstance = function() {
5323
- if (!this._instance) {
5324
- this._instance = new TraceAPI2();
5325
- }
5326
- return this._instance;
5327
- };
5328
- TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
5329
- var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
5330
- if (success) {
5331
- this._proxyTracerProvider.setDelegate(provider);
5332
- }
5333
- return success;
5334
- };
5335
- TraceAPI2.prototype.getTracerProvider = function() {
5336
- return getGlobal(API_NAME3) || this._proxyTracerProvider;
5337
- };
5338
- TraceAPI2.prototype.getTracer = function(name, version) {
5339
- return this.getTracerProvider().getTracer(name, version);
5340
- };
5341
- TraceAPI2.prototype.disable = function() {
5342
- unregisterGlobal(API_NAME3, DiagAPI.instance());
5343
- this._proxyTracerProvider = new ProxyTracerProvider();
5344
- };
5345
- return TraceAPI2;
5346
- }()
5347
- );
5348
-
5349
- // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
5350
- var trace = TraceAPI.getInstance();
5351
-
5352
- // ../stack-shared/dist/esm/utils/telemetry.js
5353
- var tracer = trace.getTracer("stack-tracer");
5354
- async function traceSpan(optionsOrDescription, fn) {
5355
- let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
5356
- return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
5357
- if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
5358
- try {
5359
- return await fn(span);
5360
- } finally {
5361
- span.end();
5362
- }
5363
- });
5364
- }
5365
-
5366
- // ../stack-shared/dist/esm/known-errors.js
5367
- var KnownError = class extends StatusError {
5368
- constructor(statusCode, humanReadableMessage, details) {
5369
- super(statusCode, humanReadableMessage);
5370
- this.statusCode = statusCode;
5371
- this.humanReadableMessage = humanReadableMessage;
5372
- this.details = details;
5373
- this.__stackKnownErrorBrand = "stack-known-error-brand-sentinel";
5374
- this.name = "KnownError";
5375
- }
5376
- static isKnownError(error) {
5377
- return typeof error === "object" && error !== null && "__stackKnownErrorBrand" in error && error.__stackKnownErrorBrand === "stack-known-error-brand-sentinel";
5378
- }
5379
- getBody() {
5380
- return new TextEncoder().encode(JSON.stringify(this.toDescriptiveJson(), void 0, 2));
5381
- }
5382
- getHeaders() {
5383
- return {
5384
- "Content-Type": ["application/json; charset=utf-8"],
5385
- "X-Stack-Known-Error": [this.errorCode],
5386
- "X-Hexclave-Known-Error": [this.errorCode]
5387
- };
5388
- }
5389
- toDescriptiveJson() {
5390
- return {
5391
- code: this.errorCode,
5392
- ...this.details ? { details: this.details } : {},
5393
- error: this.humanReadableMessage
5394
- };
5395
- }
5396
- get errorCode() {
5397
- return this.constructor.errorCode ?? throwErr(`Can't find error code for this KnownError. Is its constructor a KnownErrorConstructor? ${this}`);
5398
- }
5399
- static constructorArgsFromJson(json) {
5400
- return [
5401
- 400,
5402
- json.message,
5403
- json
5404
- ];
5405
- }
5406
- static fromJson(json) {
5407
- for (const [_, KnownErrorType] of Object.entries(KnownErrors)) if (json.code === KnownErrorType.prototype.errorCode) return new KnownErrorType(...KnownErrorType.constructorArgsFromJson(json));
5408
- throw new Error(`An error occurred. Please update your version of the Hexclave SDK. ${json.code}: ${json.message}`);
5409
- }
5410
- };
5411
- function createKnownErrorConstructor(SuperClass, errorCode, create, constructorArgsFromJson) {
5412
- const createFn = create === "inherit" ? identityArgs : create;
5413
- const constructorArgsFromJsonFn = constructorArgsFromJson === "inherit" ? SuperClass.constructorArgsFromJson : constructorArgsFromJson;
5414
- const _KnownErrorImpl = class _KnownErrorImpl extends SuperClass {
5415
- constructor(...args) {
5416
- super(...createFn(...args));
5417
- this.name = `KnownError<${errorCode}>`;
5418
- this.constructorArgs = args;
5419
- }
5420
- static constructorArgsFromJson(json) {
5421
- return constructorArgsFromJsonFn(json.details);
5422
- }
5423
- static isInstance(error) {
5424
- if (!KnownError.isKnownError(error)) return false;
5425
- let current = error;
5426
- while (true) {
5427
- current = Object.getPrototypeOf(current);
5428
- if (!current) break;
5429
- if ("errorCode" in current.constructor && current.constructor.errorCode === errorCode) return true;
5430
- }
5431
- return false;
5432
- }
5433
- };
5434
- _KnownErrorImpl.errorCode = errorCode;
5435
- let KnownErrorImpl = _KnownErrorImpl;
5436
- return KnownErrorImpl;
5437
- }
5438
- var UnsupportedError = createKnownErrorConstructor(KnownError, "UNSUPPORTED_ERROR", (originalErrorCode) => [
5439
- 500,
5440
- `An error occurred that is not currently supported (possibly because it was added in a version of Stack that is newer than this client). The original unsupported error code was: ${originalErrorCode}`,
5441
- { originalErrorCode }
5442
- ], (json) => [json?.originalErrorCode ?? throwErr("originalErrorCode not found in UnsupportedError details")]);
5443
- var BodyParsingError = createKnownErrorConstructor(KnownError, "BODY_PARSING_ERROR", (message) => [400, message], (json) => [json.message]);
5444
- var SchemaError = createKnownErrorConstructor(KnownError, "SCHEMA_ERROR", (message) => [
5445
- 400,
5446
- message || throwErr("SchemaError requires a message"),
5447
- { message }
5448
- ], (json) => [json.message]);
5449
- var AllOverloadsFailed = createKnownErrorConstructor(KnownError, "ALL_OVERLOADS_FAILED", (overloadErrors) => [
5450
- 400,
5451
- deindent`
5452
- This endpoint has multiple overloads, but they all failed to process the request.
5453
-
5454
- ${overloadErrors.map((e40, i) => deindent`
5455
- Overload ${i + 1}: ${JSON.stringify(e40, void 0, 2)}
5456
- `).join("\n\n")}
5457
- `,
5458
- { overload_errors: overloadErrors }
5459
- ], (json) => [json?.overload_errors ?? throwErr("overload_errors not found in AllOverloadsFailed details")]);
5460
- var ProjectAuthenticationError = createKnownErrorConstructor(KnownError, "PROJECT_AUTHENTICATION_ERROR", "inherit", "inherit");
5461
- var InvalidProjectAuthentication = createKnownErrorConstructor(ProjectAuthenticationError, "INVALID_PROJECT_AUTHENTICATION", "inherit", "inherit");
5462
- var ProjectKeyWithoutAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "PROJECT_KEY_WITHOUT_ACCESS_TYPE", () => [400, "Either an API key or an admin access token was provided, but the x-hexclave-access-type header is missing. Set it to 'client', 'server', or 'admin' as appropriate. (The legacy x-stack-access-type header is also accepted.)"], () => []);
5463
- var InvalidAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ACCESS_TYPE", (accessType) => [400, `The x-hexclave-access-type header must be 'client', 'server', or 'admin', but was '${accessType}'. (The legacy x-stack-access-type header is also accepted.)`], (json) => [json?.accessType ?? throwErr("accessType not found in InvalidAccessType details")]);
5464
- var AccessTypeWithoutProjectId = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_WITHOUT_PROJECT_ID", (accessType) => [
5465
- 400,
5466
- deindent`
5467
- The x-hexclave-access-type header was '${accessType}', but the x-hexclave-project-id header was not provided. (The legacy x-stack-access-type and x-stack-project-id headers are also accepted.)
5468
-
5469
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/rest-api/overview#authentication
5470
- `,
5471
- { request_type: accessType }
5472
- ], (json) => [json.request_type]);
5473
- var AccessTypeRequired = createKnownErrorConstructor(InvalidProjectAuthentication, "ACCESS_TYPE_REQUIRED", () => [400, deindent`
5474
- You must specify an access level for this Hexclave project. Make sure project API keys are provided (eg. x-hexclave-publishable-client-key) and you set the x-hexclave-access-type header to 'client', 'server', or 'admin'. (The legacy x-stack-* equivalents are also accepted.)
5475
-
5476
- For more information, see the docs on REST API authentication: https://docs.hexclave.com/rest-api/overview#authentication
5477
- `], () => []);
5478
- var InsufficientAccessType = createKnownErrorConstructor(InvalidProjectAuthentication, "INSUFFICIENT_ACCESS_TYPE", (actualAccessType, allowedAccessTypes) => [
5479
- 401,
5480
- `The x-hexclave-access-type header must be ${allowedAccessTypes.map((s8) => `'${s8}'`).join(" or ")}, but was '${actualAccessType}'. (The legacy x-stack-access-type header is also accepted.)`,
5481
- {
5482
- actual_access_type: actualAccessType,
5483
- allowed_access_types: allowedAccessTypes
5484
- }
5485
- ], (json) => [json.actual_access_type, json.allowed_access_types]);
5486
- var InvalidPublishableClientKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_PUBLISHABLE_CLIENT_KEY", (projectId) => [
5487
- 401,
5488
- `The publishable key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5489
- { project_id: projectId }
5490
- ], (json) => [json.project_id]);
5491
- var InvalidSecretServerKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SECRET_SERVER_KEY", (projectId) => [
5492
- 401,
5493
- `The secret server key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5494
- { project_id: projectId }
5495
- ], (json) => [json.project_id]);
5496
- var InvalidSuperSecretAdminKey = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_SUPER_SECRET_ADMIN_KEY", (projectId) => [
5497
- 401,
5498
- `The super secret admin key is not valid for the project ${JSON.stringify(projectId)}. Does the project and/or the key exist?`,
5499
- { project_id: projectId }
5500
- ], (json) => [json.project_id]);
5501
- var InvalidAdminAccessToken = createKnownErrorConstructor(InvalidProjectAuthentication, "INVALID_ADMIN_ACCESS_TOKEN", "inherit", "inherit");
5502
- var UnparsableAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "UNPARSABLE_ADMIN_ACCESS_TOKEN", () => [401, "Admin access token is not parsable."], () => []);
5503
- var AdminAccessTokenExpired = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_EXPIRED", (expiredAt) => [
5504
- 401,
5505
- `Admin access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}`,
5506
- { expired_at_millis: expiredAt?.getTime() ?? null }
5507
- ], (json) => [json.expired_at_millis ? new Date(json.expired_at_millis) : void 0]);
5508
- var InvalidProjectForAdminAccessToken = createKnownErrorConstructor(InvalidAdminAccessToken, "INVALID_PROJECT_FOR_ADMIN_ACCESS_TOKEN", () => [401, "Admin access tokens must be created on the internal project."], () => []);
5509
- var AdminAccessTokenIsNotAdmin = createKnownErrorConstructor(InvalidAdminAccessToken, "ADMIN_ACCESS_TOKEN_IS_NOT_ADMIN", () => [401, "Admin access token does not have the required permissions to access this project."], () => []);
5510
- var ProjectAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationError, "PROJECT_AUTHENTICATION_REQUIRED", "inherit", "inherit");
5511
- var ClientAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_AUTHENTICATION_REQUIRED", () => [401, "The publishable client key must be provided."], () => []);
5512
- var PublishableClientKeyRequiredForProject = createKnownErrorConstructor(ProjectAuthenticationRequired, "PUBLISHABLE_CLIENT_KEY_REQUIRED_FOR_PROJECT", (projectId) => [
5513
- 401,
5514
- "Publishable client keys are required for this project. Create one in Project Keys, or disable this requirement there to allow keyless client access.",
5515
- { project_id: projectId ?? null }
5516
- ], (json) => [json.project_id ?? void 0]);
5517
- var ServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "SERVER_AUTHENTICATION_REQUIRED", () => [401, "The secret server key must be provided."], () => []);
5518
- var ClientOrServerAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the secret server key must be provided."], () => []);
5519
- var ClientOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key or the super secret admin key must be provided."], () => []);
5520
- var ClientOrServerOrAdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "CLIENT_OR_SERVER_OR_ADMIN_AUTHENTICATION_REQUIRED", () => [401, "Either the publishable client key, the secret server key, or the super secret admin key must be provided."], () => []);
5521
- var AdminAuthenticationRequired = createKnownErrorConstructor(ProjectAuthenticationRequired, "ADMIN_AUTHENTICATION_REQUIRED", () => [401, "The super secret admin key must be provided."], () => []);
5522
- var ExpectedInternalProject = createKnownErrorConstructor(ProjectAuthenticationError, "EXPECTED_INTERNAL_PROJECT", () => [401, "The project ID is expected to be internal."], () => []);
5523
- var SessionAuthenticationError = createKnownErrorConstructor(KnownError, "SESSION_AUTHENTICATION_ERROR", "inherit", "inherit");
5524
- var InvalidSessionAuthentication = createKnownErrorConstructor(SessionAuthenticationError, "INVALID_SESSION_AUTHENTICATION", "inherit", "inherit");
5525
- var InvalidAccessToken = createKnownErrorConstructor(InvalidSessionAuthentication, "INVALID_ACCESS_TOKEN", "inherit", "inherit");
5526
- var UnparsableAccessToken = createKnownErrorConstructor(InvalidAccessToken, "UNPARSABLE_ACCESS_TOKEN", () => [401, "Access token is not parsable."], () => []);
5527
- var AccessTokenExpired = createKnownErrorConstructor(InvalidAccessToken, "ACCESS_TOKEN_EXPIRED", (expiredAt, projectId, userId, refreshTokenId) => [
5528
- 401,
5529
- deindent`
5530
- Access token has expired. Please refresh it and try again.${expiredAt ? ` (The access token expired at ${expiredAt.toISOString()}.)` : ""}${projectId ? ` Project ID: ${projectId}.` : ""}${userId ? ` User ID: ${userId}.` : ""}${refreshTokenId ? ` Refresh token ID: ${refreshTokenId}.` : ""}
5531
-
5532
- Debug info: Most likely, you fetched the access token before it expired (for example, in a server component, pre-rendered page, or on page load), but then didn't refresh it before it expired. If this is the case, and you're using the SDK, make sure you call getAccessToken() every time you need to use the access token. If you're not using the SDK, make sure you refresh the access token with the refresh endpoint.
5533
- `,
5534
- {
5535
- expired_at_millis: expiredAt?.getTime() ?? null,
5536
- project_id: projectId ?? null,
5537
- user_id: userId ?? null,
5538
- refresh_token_id: refreshTokenId ?? null
5539
- }
5540
- ], (json) => [
5541
- json.expired_at_millis ? new Date(json.expired_at_millis) : void 0,
5542
- json.project_id ?? void 0,
5543
- json.user_id ?? void 0,
5544
- json.refresh_token_id ?? void 0
5545
- ]);
5546
- var InvalidProjectForAccessToken = createKnownErrorConstructor(InvalidAccessToken, "INVALID_PROJECT_FOR_ACCESS_TOKEN", (expectedProjectId, actualProjectId) => [
5547
- 401,
5548
- `Access token not valid for this project. Expected project ID ${JSON.stringify(expectedProjectId)}, but the token is for project ID ${JSON.stringify(actualProjectId)}.`,
5549
- {
5550
- expected_project_id: expectedProjectId,
5551
- actual_project_id: actualProjectId
5552
- }
5553
- ], (json) => [json.expected_project_id, json.actual_project_id]);
5554
- var RefreshTokenError = createKnownErrorConstructor(KnownError, "REFRESH_TOKEN_ERROR", "inherit", "inherit");
5555
- var RefreshTokenNotFoundOrExpired = createKnownErrorConstructor(RefreshTokenError, "REFRESH_TOKEN_NOT_FOUND_OR_EXPIRED", () => [401, "Refresh token not found for this project, or the session has expired/been revoked."], () => []);
5556
- var CannotDeleteCurrentSession = createKnownErrorConstructor(RefreshTokenError, "CANNOT_DELETE_CURRENT_SESSION", () => [400, "Cannot delete the current session."], () => []);
5557
- var ProviderRejected = createKnownErrorConstructor(RefreshTokenError, "PROVIDER_REJECTED", () => [401, "The provider refused to refresh their token. This usually means that the provider used to authenticate the user no longer regards this session as valid, and the user must re-authenticate."], () => []);
5558
- var UserWithEmailAlreadyExists = createKnownErrorConstructor(KnownError, "USER_EMAIL_ALREADY_EXISTS", (email, wouldWorkIfEmailWasVerified = false) => [
5559
- 409,
5560
- `A user with email ${JSON.stringify(email)} already exists${wouldWorkIfEmailWasVerified ? " but the email is not verified. Please login to your existing account with the method you used to sign up, and then verify your email to sign in with this login method." : "."}`,
5561
- {
5562
- email,
5563
- would_work_if_email_was_verified: wouldWorkIfEmailWasVerified
5564
- }
5565
- ], (json) => [json.email, json.would_work_if_email_was_verified ?? false]);
5566
- var EmailNotVerified = createKnownErrorConstructor(KnownError, "EMAIL_NOT_VERIFIED", () => [400, "The email is not verified."], () => []);
5567
- var CannotGetOwnUserWithoutUser = createKnownErrorConstructor(KnownError, "CANNOT_GET_OWN_USER_WITHOUT_USER", () => [400, "You have specified 'me' as a userId, but did not provide authentication for a user."], () => []);
5568
- var UserIdDoesNotExist = createKnownErrorConstructor(KnownError, "USER_ID_DOES_NOT_EXIST", (userId) => [
5569
- 400,
5570
- `The given user with the ID ${userId} does not exist.`,
5571
- { user_id: userId }
5572
- ], (json) => [json.user_id]);
5573
- var UserNotFound = createKnownErrorConstructor(KnownError, "USER_NOT_FOUND", () => [404, "User not found."], () => []);
5574
- var RestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5575
- 403,
5576
- `The user in the access token is in restricted state. Reason: ${restrictedReason.type}. Please pass the X-Stack-Allow-Restricted-User header if this is intended.`,
5577
- { restricted_reason: restrictedReason }
5578
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5579
- var ProjectNotFound = createKnownErrorConstructor(KnownError, "PROJECT_NOT_FOUND", (projectId) => {
5580
- if (typeof projectId !== "string") throw new HexclaveAssertionError("projectId of KnownErrors.ProjectNotFound must be a string");
5581
- return [
5582
- 404,
5583
- `Project ${projectId} not found or is not accessible with the current user.`,
5584
- { project_id: projectId }
5585
- ];
5586
- }, (json) => [json.project_id]);
5587
- var CurrentProjectNotFound = createKnownErrorConstructor(KnownError, "CURRENT_PROJECT_NOT_FOUND", (projectId) => [
5588
- 400,
5589
- `The current project with ID ${projectId} was not found. Please check the value of the x-hexclave-project-id header. (The legacy x-stack-project-id header is also accepted.)`,
5590
- { project_id: projectId }
5591
- ], (json) => [json.project_id]);
5592
- var BranchDoesNotExist = createKnownErrorConstructor(KnownError, "BRANCH_DOES_NOT_EXIST", (branchId) => [
5593
- 400,
5594
- `The branch with ID ${branchId} does not exist.`,
5595
- { branch_id: branchId }
5596
- ], (json) => [json.branch_id]);
5597
- var SignUpNotEnabled = createKnownErrorConstructor(KnownError, "SIGN_UP_NOT_ENABLED", () => [400, "Creation of new accounts is not enabled for this project. Please ask the project owner to enable it."], () => []);
5598
- var SignUpRejected = createKnownErrorConstructor(KnownError, "SIGN_UP_REJECTED", (message) => [
5599
- 403,
5600
- message ?? "Your sign up was rejected by an administrator's sign-up rule.",
5601
- { message: message ?? "Your sign up was rejected by an administrator's sign-up rule." }
5602
- ], (json) => [json.message]);
5603
- var BotChallengeRequired = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_REQUIRED", () => [409, "An additional bot challenge is required before sign-up can continue."], () => []);
5604
- var BotChallengeFailed = createKnownErrorConstructor(KnownError, "BOT_CHALLENGE_FAILED", (message) => [
5605
- 400,
5606
- message,
5607
- { message }
5608
- ], (json) => [json.message]);
5609
- var PasswordAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSWORD_AUTHENTICATION_NOT_ENABLED", () => [400, "Password authentication is not enabled for this project."], () => []);
5610
- var DataVaultStoreDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_DOES_NOT_EXIST", (storeId) => [
5611
- 400,
5612
- `Data vault store with ID ${storeId} does not exist.`,
5613
- { store_id: storeId }
5614
- ], (json) => [json.store_id]);
5615
- var DataVaultStoreHashedKeyDoesNotExist = createKnownErrorConstructor(KnownError, "DATA_VAULT_STORE_HASHED_KEY_DOES_NOT_EXIST", (storeId, hashedKey) => [
5616
- 400,
5617
- `Data vault store with ID ${storeId} does not contain a key with hash ${hashedKey}.`,
5618
- {
5619
- store_id: storeId,
5620
- hashed_key: hashedKey
5621
- }
5622
- ], (json) => [json.store_id, json.hashed_key]);
5623
- var PasskeyAuthenticationNotEnabled = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_NOT_ENABLED", () => [400, "Passkey authentication is not enabled for this project."], () => []);
5624
- var AnonymousAccountsNotEnabled = createKnownErrorConstructor(KnownError, "ANONYMOUS_ACCOUNTS_NOT_ENABLED", () => [400, "Anonymous accounts are not enabled for this project."], () => []);
5625
- var AnonymousAuthenticationNotAllowed = createKnownErrorConstructor(KnownError, "ANONYMOUS_AUTHENTICATION_NOT_ALLOWED", () => [401, "X-Stack-Access-Token is for an anonymous user, but anonymous users are not enabled. Set the X-Stack-Allow-Anonymous-User header of this request to 'true' to allow anonymous users."], () => []);
5626
- var EmailPasswordMismatch = createKnownErrorConstructor(KnownError, "EMAIL_PASSWORD_MISMATCH", () => [400, "Wrong e-mail or password."], () => []);
5627
- var RedirectUrlNotWhitelisted = createKnownErrorConstructor(KnownError, "REDIRECT_URL_NOT_WHITELISTED", () => [400, "Redirect URL not whitelisted. Did you forget to add this domain to the trusted domains list on the Hexclave dashboard?"], () => []);
5628
- var PasswordRequirementsNotMet = createKnownErrorConstructor(KnownError, "PASSWORD_REQUIREMENTS_NOT_MET", "inherit", "inherit");
5629
- var PasswordTooShort = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_SHORT", (minLength) => [
5630
- 400,
5631
- `Password too short. Minimum length is ${minLength}.`,
5632
- { min_length: minLength }
5633
- ], (json) => [json?.min_length ?? throwErr("min_length not found in PasswordTooShort details")]);
5634
- var PasswordTooLong = createKnownErrorConstructor(PasswordRequirementsNotMet, "PASSWORD_TOO_LONG", (maxLength) => [
5635
- 400,
5636
- `Password too long. Maximum length is ${maxLength}.`,
5637
- { maxLength }
5638
- ], (json) => [json?.maxLength ?? throwErr("maxLength not found in PasswordTooLong details")]);
5639
- var UserDoesNotHavePassword = createKnownErrorConstructor(KnownError, "USER_DOES_NOT_HAVE_PASSWORD", () => [400, "This user does not have password authentication enabled."], () => []);
5640
- var VerificationCodeError = createKnownErrorConstructor(KnownError, "VERIFICATION_ERROR", "inherit", "inherit");
5641
- var VerificationCodeNotFound = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_NOT_FOUND", () => [404, "The verification code does not exist for this project."], () => []);
5642
- var VerificationCodeExpired = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_EXPIRED", () => [400, "The verification code has expired."], () => []);
5643
- var VerificationCodeAlreadyUsed = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_ALREADY_USED", () => [409, "The verification link has already been used."], () => []);
5644
- var VerificationCodeMaxAttemptsReached = createKnownErrorConstructor(VerificationCodeError, "VERIFICATION_CODE_MAX_ATTEMPTS_REACHED", () => [400, "The verification code nonce has reached the maximum number of attempts. This code is not valid anymore."], () => []);
5645
- var PasswordConfirmationMismatch = createKnownErrorConstructor(KnownError, "PASSWORD_CONFIRMATION_MISMATCH", () => [400, "Passwords do not match."], () => []);
5646
- var EmailAlreadyVerified = createKnownErrorConstructor(KnownError, "EMAIL_ALREADY_VERIFIED", () => [409, "The e-mail is already verified."], () => []);
5647
- var EmailNotAssociatedWithUser = createKnownErrorConstructor(KnownError, "EMAIL_NOT_ASSOCIATED_WITH_USER", () => [400, "The e-mail is not associated with a user that could log in with that e-mail."], () => []);
5648
- var EmailIsNotPrimaryEmail = createKnownErrorConstructor(KnownError, "EMAIL_IS_NOT_PRIMARY_EMAIL", (email, primaryEmail) => [
5649
- 400,
5650
- `The given e-mail (${email}) must equal the user's primary e-mail (${primaryEmail}).`,
5651
- {
5652
- email,
5653
- primary_email: primaryEmail
5654
- }
5655
- ], (json) => [json.email, json.primary_email]);
5656
- var PasskeyRegistrationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_REGISTRATION_FAILED", (message) => [400, message], (json) => [json.message]);
5657
- var PasskeyWebAuthnError = createKnownErrorConstructor(KnownError, "PASSKEY_WEBAUTHN_ERROR", (message, code) => [
5658
- 400,
5659
- message,
5660
- {
5661
- message,
5662
- code
5663
- }
5664
- ], (json) => [json.message, json.code]);
5665
- var PasskeyAuthenticationFailed = createKnownErrorConstructor(KnownError, "PASSKEY_AUTHENTICATION_FAILED", (message) => [400, message], (json) => [json.message]);
5666
- var PermissionNotFound = createKnownErrorConstructor(KnownError, "PERMISSION_NOT_FOUND", (permissionId) => [
5667
- 404,
5668
- `Permission "${permissionId}" not found. Make sure you created it on the dashboard.`,
5669
- { permission_id: permissionId }
5670
- ], (json) => [json.permission_id]);
5671
- var PermissionScopeMismatch = createKnownErrorConstructor(KnownError, "WRONG_PERMISSION_SCOPE", (permissionId, expectedScope, actualScope) => [
5672
- 404,
5673
- `Permission ${JSON.stringify(permissionId)} not found. (It was found for a different scope ${JSON.stringify(actualScope)}, but scope ${JSON.stringify(expectedScope)} was expected.)`,
5674
- {
5675
- permission_id: permissionId,
5676
- expected_scope: expectedScope,
5677
- actual_scope: actualScope
5678
- }
5679
- ], (json) => [
5680
- json.permission_id,
5681
- json.expected_scope,
5682
- json.actual_scope
5683
- ]);
5684
- var ContainedPermissionNotFound = createKnownErrorConstructor(KnownError, "CONTAINED_PERMISSION_NOT_FOUND", (permissionId) => [
5685
- 400,
5686
- `Contained permission with ID "${permissionId}" not found. Make sure you created it on the dashboard.`,
5687
- { permission_id: permissionId }
5688
- ], (json) => [json.permission_id]);
5689
- var TeamNotFound = createKnownErrorConstructor(KnownError, "TEAM_NOT_FOUND", (teamId) => [
5690
- 404,
5691
- `Team ${teamId} not found.`,
5692
- { team_id: teamId }
5693
- ], (json) => [json.team_id]);
5694
- createKnownErrorConstructor(KnownError, "TEAM_ALREADY_EXISTS", (teamId) => [
5695
- 409,
5696
- `Team ${teamId} already exists.`,
5697
- { team_id: teamId }
5698
- ], (json) => [json.team_id]);
5699
- var TeamMembershipNotFound = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_NOT_FOUND", (teamId, userId) => [
5700
- 404,
5701
- `User ${userId} is not found in team ${teamId}.`,
5702
- {
5703
- team_id: teamId,
5704
- user_id: userId
5705
- }
5706
- ], (json) => [json.team_id, json.user_id]);
5707
- var TeamInvitationRestrictedUserNotAllowed = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_RESTRICTED_USER_NOT_ALLOWED", (restrictedReason) => [
5708
- 403,
5709
- `Restricted users cannot accept team invitations. Reason: ${restrictedReason.type}. Please complete the onboarding process before accepting team invitations.`,
5710
- { restricted_reason: restrictedReason }
5711
- ], (json) => [json.restricted_reason ?? { type: "anonymous" }]);
5712
- var TeamInvitationEmailMismatch = createKnownErrorConstructor(KnownError, "TEAM_INVITATION_EMAIL_MISMATCH", () => [403, "This team invitation was sent to a different email address. Sign in with the invited email, or add and verify that email on your account, then try again."], () => []);
5713
- var EmailTemplateAlreadyExists = createKnownErrorConstructor(KnownError, "EMAIL_TEMPLATE_ALREADY_EXISTS", () => [409, "Email template already exists."], () => []);
5714
- var OAuthConnectionNotConnectedToUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_NOT_CONNECTED_TO_USER", () => [400, "The OAuth connection is not connected to any user."], () => []);
5715
- var OAuthConnectionAlreadyConnectedToAnotherUser = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_ALREADY_CONNECTED_TO_ANOTHER_USER", () => [409, "The OAuth connection is already connected to another user."], () => []);
5716
- var OAuthConnectionDoesNotHaveRequiredScope = createKnownErrorConstructor(KnownError, "OAUTH_CONNECTION_DOES_NOT_HAVE_REQUIRED_SCOPE", () => [400, "The OAuth connection does not have the required scope."], () => []);
5717
- var OAuthAccessTokenNotAvailable = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE", (provider, details) => [
5718
- 400,
5719
- `Failed to retrieve an OAuth access token for the connected account (provider: ${provider}). ${details}`,
5720
- {
5721
- provider,
5722
- details
5723
- }
5724
- ], (json) => [json.provider, json.details]);
5725
- var OAuthExtraScopeNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_EXTRA_SCOPE_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Extra scopes are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use extra scopes."], () => []);
5726
- var OAuthAccessTokenNotAvailableWithSharedOAuthKeys = createKnownErrorConstructor(KnownError, "OAUTH_ACCESS_TOKEN_NOT_AVAILABLE_WITH_SHARED_OAUTH_KEYS", () => [400, "Access tokens are not available with shared OAuth keys. Please add your own OAuth keys on the Stack dashboard to use access tokens."], () => []);
5727
- var InvalidOAuthClientIdOrSecret = createKnownErrorConstructor(KnownError, "INVALID_OAUTH_CLIENT_ID_OR_SECRET", (clientId) => [
5728
- 400,
5729
- "The OAuth client ID or secret is invalid. The client ID must be equal to the project ID (potentially with a hash and a branch ID), and the client secret must be a publishable client key.",
5730
- { client_id: clientId ?? null }
5731
- ], (json) => [json.client_id ?? void 0]);
5732
- var InvalidScope = createKnownErrorConstructor(KnownError, "INVALID_SCOPE", (scope) => [400, `The scope "${scope}" is not a valid OAuth scope for Stack.`], (json) => [json.scope]);
5733
- var UserAlreadyConnectedToAnotherOAuthConnection = createKnownErrorConstructor(KnownError, "USER_ALREADY_CONNECTED_TO_ANOTHER_OAUTH_CONNECTION", () => [409, "The user is already connected to another OAuth account. Did you maybe selected the wrong account?"], () => []);
5734
- var OuterOAuthTimeout = createKnownErrorConstructor(KnownError, "OUTER_OAUTH_TIMEOUT", () => [408, "The OAuth flow has timed out. Please sign in again."], () => []);
5735
- var OAuthProviderNotFoundOrNotEnabled = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_NOT_FOUND_OR_NOT_ENABLED", () => [400, "The OAuth provider is not found or not enabled."], () => []);
5736
- var AppleBundleIdNotConfigured = createKnownErrorConstructor(KnownError, "APPLE_BUNDLE_ID_NOT_CONFIGURED", () => [400, "Apple Sign In is enabled, but no Bundle IDs are configured. Please add your app's Bundle ID in the Hexclave dashboard under OAuth Providers > Apple > Apple Bundle IDs."], () => []);
5737
- var OAuthProviderAccountIdAlreadyUsedForSignIn = createKnownErrorConstructor(KnownError, "OAUTH_PROVIDER_ACCOUNT_ID_ALREADY_USED_FOR_SIGN_IN", () => [400, `A provider with the same account ID is already used for signing in.`], () => []);
5738
- var MultiFactorAuthenticationRequired = createKnownErrorConstructor(KnownError, "MULTI_FACTOR_AUTHENTICATION_REQUIRED", (attemptCode) => [
5739
- 400,
5740
- `Multi-factor authentication is required for this user.`,
5741
- { attempt_code: attemptCode }
5742
- ], (json) => [json.attempt_code]);
5743
- var InvalidTotpCode = createKnownErrorConstructor(KnownError, "INVALID_TOTP_CODE", () => [400, "The TOTP code is invalid. Please try again."], () => []);
5744
- var UserAuthenticationRequired = createKnownErrorConstructor(KnownError, "USER_AUTHENTICATION_REQUIRED", () => [401, "User authentication required for this endpoint."], () => []);
5745
- var TeamMembershipAlreadyExists = createKnownErrorConstructor(KnownError, "TEAM_MEMBERSHIP_ALREADY_EXISTS", () => [409, "Team membership already exists."], () => []);
5746
- var ProjectPermissionRequired = createKnownErrorConstructor(KnownError, "PROJECT_PERMISSION_REQUIRED", (userId, permissionId) => [
5747
- 401,
5748
- `User ${userId} does not have permission ${permissionId}.`,
5749
- {
5750
- user_id: userId,
5751
- permission_id: permissionId
5752
- }
5753
- ], (json) => [json.user_id, json.permission_id]);
5754
- var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
5755
- 401,
5756
- `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
5757
- {
5758
- team_id: teamId,
5759
- user_id: userId,
5760
- permission_id: permissionId
4879
+ ], (json) => [json.user_id, json.permission_id]);
4880
+ var TeamPermissionRequired = createKnownErrorConstructor(KnownError, "TEAM_PERMISSION_REQUIRED", (teamId, userId, permissionId) => [
4881
+ 401,
4882
+ `User ${userId} does not have permission ${permissionId} in team ${teamId}.`,
4883
+ {
4884
+ team_id: teamId,
4885
+ user_id: userId,
4886
+ permission_id: permissionId
5761
4887
  }
5762
4888
  ], (json) => [
5763
4889
  json.team_id,
@@ -6117,49 +5243,6 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6117
5243
  knownErrorCodes.add(KnownError2.errorCode);
6118
5244
  }
6119
5245
 
6120
- // ../stack-shared/dist/esm/utils/bytes.js
6121
- function decodeBase64(input) {
6122
- return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
6123
- }
6124
- function isBase64(input) {
6125
- return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(input);
6126
- }
6127
-
6128
- // ../stack-shared/dist/esm/utils/urls.js
6129
- function createUrlIfValid(...args) {
6130
- try {
6131
- return new URL(...args);
6132
- } catch (e40) {
6133
- return null;
6134
- }
6135
- }
6136
- function isValidUrl(url) {
6137
- return !!createUrlIfValid(url);
6138
- }
6139
- function isValidHostname(hostname) {
6140
- if (!hostname || hostname.startsWith(".") || hostname.endsWith(".") || hostname.includes("..")) return false;
6141
- const url = createUrlIfValid(`https://${hostname}`);
6142
- if (!url) return false;
6143
- return url.hostname === hostname;
6144
- }
6145
- function isValidHostnameWithWildcards(hostname) {
6146
- if (!hostname) return false;
6147
- if (!hostname.includes("*")) return isValidHostname(hostname);
6148
- if (hostname.startsWith(".") || hostname.endsWith(".")) return false;
6149
- if (hostname.includes("..")) return false;
6150
- const testHostname = hostname.replace(/\*+/g, "wildcard");
6151
- if (!/^[a-zA-Z0-9.-]+$/.test(testHostname)) return false;
6152
- const segments = hostname.split(/\*+/);
6153
- for (let i = 0; i < segments.length; i++) {
6154
- const segment = segments[i];
6155
- if (segment === "") continue;
6156
- if (i === 0 && segment.startsWith(".")) return false;
6157
- if (i === segments.length - 1 && segment.endsWith(".")) return false;
6158
- if (segment.includes("..")) return false;
6159
- }
6160
- return true;
6161
- }
6162
-
6163
5246
  // ../../node_modules/.pnpm/yup@1.7.1/node_modules/yup/index.esm.js
6164
5247
  var import_property_expr = __toESM(require_property_expr());
6165
5248
  var import_tiny_case = __toESM(require_tiny_case());
@@ -6199,11 +5282,11 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6199
5282
  function toArray(value) {
6200
5283
  return value == null ? [] : [].concat(value);
6201
5284
  }
6202
- var _Symbol$toStringTag4;
5285
+ var _Symbol$toStringTag;
6203
5286
  var _Symbol$hasInstance;
6204
- var _Symbol$toStringTag22;
5287
+ var _Symbol$toStringTag2;
6205
5288
  var strReg = /\$\{\s*(\w+)\s*\}/g;
6206
- _Symbol$toStringTag4 = Symbol.toStringTag;
5289
+ _Symbol$toStringTag = Symbol.toStringTag;
6207
5290
  var ValidationErrorNoStack = class {
6208
5291
  constructor(errorOrErrors, value, field, type) {
6209
5292
  this.name = void 0;
@@ -6214,7 +5297,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6214
5297
  this.params = void 0;
6215
5298
  this.errors = void 0;
6216
5299
  this.inner = void 0;
6217
- this[_Symbol$toStringTag4] = "Error";
5300
+ this[_Symbol$toStringTag] = "Error";
6218
5301
  this.name = "ValidationError";
6219
5302
  this.value = value;
6220
5303
  this.path = field;
@@ -6234,7 +5317,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6234
5317
  }
6235
5318
  };
6236
5319
  _Symbol$hasInstance = Symbol.hasInstance;
6237
- _Symbol$toStringTag22 = Symbol.toStringTag;
5320
+ _Symbol$toStringTag2 = Symbol.toStringTag;
6238
5321
  var ValidationError = class _ValidationError extends Error {
6239
5322
  static formatError(message, params) {
6240
5323
  const path = params.label || params.path || "this";
@@ -6261,7 +5344,7 @@ This is likely an error in Hexclave. Please make sure you are running the newest
6261
5344
  this.params = void 0;
6262
5345
  this.errors = [];
6263
5346
  this.inner = [];
6264
- this[_Symbol$toStringTag22] = "Error";
5347
+ this[_Symbol$toStringTag2] = "Error";
6265
5348
  this.name = errorNoStack.name;
6266
5349
  this.message = errorNoStack.message;
6267
5350
  this.type = errorNoStack.type;
@@ -8954,6 +8037,10 @@ attempted value: ${formattedValue}
8954
8037
  description: 'OAuth client secret. Needs to be specified when using type="standard"',
8955
8038
  exampleValue: "google-oauth-client-secret"
8956
8039
  } });
8040
+ var oauthCustomCallbackUrlSchema = urlSchema.meta({ openapiField: {
8041
+ description: "The OAuth redirect/callback URL sent to the provider. When omitted, the default callback URL is used. Cannot be set for shared providers.",
8042
+ exampleValue: "https://api.hexclave.com/api/v1/auth/oauth/callback/google"
8043
+ } });
8957
8044
  var oauthFacebookConfigIdSchema = yupString().meta({ openapiField: { description: "The configuration id for Facebook business login (for things like ads and marketing). This is only required if you are using the standard OAuth with Facebook and you are using Facebook business login." } });
8958
8045
  var oauthMicrosoftTenantIdSchema = yupString().meta({ openapiField: { description: "The Microsoft tenant id for Microsoft directory. This is only required if you are using the standard OAuth with Microsoft and you have an Azure AD tenant." } });
8959
8046
  var oauthAppleBundleIdsSchema = yupArray(yupString().defined()).meta({ openapiField: {
@@ -9424,283 +8511,1204 @@ attempted value: ${formattedValue}
9424
8511
  workflow_path: yupString().optional()
9425
8512
  }), yupObject({ type: yupString().oneOf(["pushed-from-unknown"]).defined() }), yupObject({ type: yupString().oneOf(["unlinked"]).defined() }));
9426
8513
 
9427
- // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
9428
- var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
9429
- var E_ALREADY_LOCKED = new Error("mutex already locked");
9430
- var E_CANCELED = new Error("request for lock canceled");
9431
- var __awaiter$2 = function(thisArg, _arguments, P, generator) {
9432
- function adopt(value) {
9433
- return value instanceof P ? value : new P(function(resolve) {
9434
- resolve(value);
9435
- });
8514
+ // ../../node_modules/.pnpm/async-mutex@0.5.0/node_modules/async-mutex/index.mjs
8515
+ var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
8516
+ var E_ALREADY_LOCKED = new Error("mutex already locked");
8517
+ var E_CANCELED = new Error("request for lock canceled");
8518
+ var __awaiter$2 = function(thisArg, _arguments, P, generator) {
8519
+ function adopt(value) {
8520
+ return value instanceof P ? value : new P(function(resolve) {
8521
+ resolve(value);
8522
+ });
8523
+ }
8524
+ return new (P || (P = Promise))(function(resolve, reject) {
8525
+ function fulfilled(value) {
8526
+ try {
8527
+ step(generator.next(value));
8528
+ } catch (e40) {
8529
+ reject(e40);
8530
+ }
8531
+ }
8532
+ function rejected2(value) {
8533
+ try {
8534
+ step(generator["throw"](value));
8535
+ } catch (e40) {
8536
+ reject(e40);
8537
+ }
8538
+ }
8539
+ function step(result) {
8540
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
8541
+ }
8542
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8543
+ });
8544
+ };
8545
+ var Semaphore = class {
8546
+ constructor(_value, _cancelError = E_CANCELED) {
8547
+ this._value = _value;
8548
+ this._cancelError = _cancelError;
8549
+ this._queue = [];
8550
+ this._weightedWaiters = [];
8551
+ }
8552
+ acquire(weight = 1, priority = 0) {
8553
+ if (weight <= 0)
8554
+ throw new Error(`invalid weight ${weight}: must be positive`);
8555
+ return new Promise((resolve, reject) => {
8556
+ const task = { resolve, reject, weight, priority };
8557
+ const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
8558
+ if (i === -1 && weight <= this._value) {
8559
+ this._dispatchItem(task);
8560
+ } else {
8561
+ this._queue.splice(i + 1, 0, task);
8562
+ }
8563
+ });
8564
+ }
8565
+ runExclusive(callback_1) {
8566
+ return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
8567
+ const [value, release] = yield this.acquire(weight, priority);
8568
+ try {
8569
+ return yield callback(value);
8570
+ } finally {
8571
+ release();
8572
+ }
8573
+ });
8574
+ }
8575
+ waitForUnlock(weight = 1, priority = 0) {
8576
+ if (weight <= 0)
8577
+ throw new Error(`invalid weight ${weight}: must be positive`);
8578
+ if (this._couldLockImmediately(weight, priority)) {
8579
+ return Promise.resolve();
8580
+ } else {
8581
+ return new Promise((resolve) => {
8582
+ if (!this._weightedWaiters[weight - 1])
8583
+ this._weightedWaiters[weight - 1] = [];
8584
+ insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
8585
+ });
8586
+ }
8587
+ }
8588
+ isLocked() {
8589
+ return this._value <= 0;
8590
+ }
8591
+ getValue() {
8592
+ return this._value;
8593
+ }
8594
+ setValue(value) {
8595
+ this._value = value;
8596
+ this._dispatchQueue();
8597
+ }
8598
+ release(weight = 1) {
8599
+ if (weight <= 0)
8600
+ throw new Error(`invalid weight ${weight}: must be positive`);
8601
+ this._value += weight;
8602
+ this._dispatchQueue();
8603
+ }
8604
+ cancel() {
8605
+ this._queue.forEach((entry) => entry.reject(this._cancelError));
8606
+ this._queue = [];
8607
+ }
8608
+ _dispatchQueue() {
8609
+ this._drainUnlockWaiters();
8610
+ while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
8611
+ this._dispatchItem(this._queue.shift());
8612
+ this._drainUnlockWaiters();
8613
+ }
8614
+ }
8615
+ _dispatchItem(item) {
8616
+ const previousValue = this._value;
8617
+ this._value -= item.weight;
8618
+ item.resolve([previousValue, this._newReleaser(item.weight)]);
8619
+ }
8620
+ _newReleaser(weight) {
8621
+ let called = false;
8622
+ return () => {
8623
+ if (called)
8624
+ return;
8625
+ called = true;
8626
+ this.release(weight);
8627
+ };
8628
+ }
8629
+ _drainUnlockWaiters() {
8630
+ if (this._queue.length === 0) {
8631
+ for (let weight = this._value; weight > 0; weight--) {
8632
+ const waiters = this._weightedWaiters[weight - 1];
8633
+ if (!waiters)
8634
+ continue;
8635
+ waiters.forEach((waiter) => waiter.resolve());
8636
+ this._weightedWaiters[weight - 1] = [];
8637
+ }
8638
+ } else {
8639
+ const queuedPriority = this._queue[0].priority;
8640
+ for (let weight = this._value; weight > 0; weight--) {
8641
+ const waiters = this._weightedWaiters[weight - 1];
8642
+ if (!waiters)
8643
+ continue;
8644
+ const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
8645
+ (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
8646
+ }
8647
+ }
8648
+ }
8649
+ _couldLockImmediately(weight, priority) {
8650
+ return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
8651
+ }
8652
+ };
8653
+ function insertSorted(a26, v) {
8654
+ const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
8655
+ a26.splice(i + 1, 0, v);
8656
+ }
8657
+ function findIndexFromEnd(a26, predicate) {
8658
+ for (let i = a26.length - 1; i >= 0; i--) {
8659
+ if (predicate(a26[i])) {
8660
+ return i;
8661
+ }
8662
+ }
8663
+ return -1;
8664
+ }
8665
+
8666
+ // ../stack-shared/dist/esm/utils/locks.js
8667
+ var ReadWriteLock = class {
8668
+ constructor() {
8669
+ this.semaphore = new Semaphore(1);
8670
+ this.readers = 0;
8671
+ this.readersMutex = new Semaphore(1);
8672
+ }
8673
+ async withReadLock(callback) {
8674
+ await this._acquireReadLock();
8675
+ try {
8676
+ return await callback();
8677
+ } finally {
8678
+ await this._releaseReadLock();
8679
+ }
8680
+ }
8681
+ async withWriteLock(callback) {
8682
+ await this._acquireWriteLock();
8683
+ try {
8684
+ return await callback();
8685
+ } finally {
8686
+ await this._releaseWriteLock();
8687
+ }
8688
+ }
8689
+ async _acquireReadLock() {
8690
+ await this.readersMutex.acquire();
8691
+ try {
8692
+ this.readers += 1;
8693
+ if (this.readers === 1) await this.semaphore.acquire();
8694
+ } finally {
8695
+ this.readersMutex.release();
8696
+ }
8697
+ }
8698
+ async _releaseReadLock() {
8699
+ await this.readersMutex.acquire();
8700
+ try {
8701
+ this.readers -= 1;
8702
+ if (this.readers === 0) this.semaphore.release();
8703
+ } finally {
8704
+ this.readersMutex.release();
8705
+ }
8706
+ }
8707
+ async _acquireWriteLock() {
8708
+ await this.semaphore.acquire();
8709
+ }
8710
+ async _releaseWriteLock() {
8711
+ this.semaphore.release();
8712
+ }
8713
+ };
8714
+
8715
+ // ../stack-shared/dist/esm/utils/stores.js
8716
+ var storeLock = new ReadWriteLock();
8717
+
8718
+ // ../stack-shared/dist/esm/interface/client-interface.js
8719
+ var USER_AGENT;
8720
+ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.3`;
8721
+ var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
8722
+ function CodedTypeError(message, code, cause) {
8723
+ const err = new TypeError(message, { cause });
8724
+ Object.assign(err, { code });
8725
+ return err;
8726
+ }
8727
+ var allowInsecureRequests = Symbol();
8728
+ var clockSkew = Symbol();
8729
+ var clockTolerance = Symbol();
8730
+ var customFetch = Symbol();
8731
+ var jweDecrypt = Symbol();
8732
+ var encoder = new TextEncoder();
8733
+ var decoder = new TextDecoder();
8734
+ var encodeBase64Url;
8735
+ if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
8736
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8737
+ return input.toBase64({
8738
+ alphabet: "base64url",
8739
+ omitPadding: true
8740
+ });
8741
+ };
8742
+ else {
8743
+ const CHUNK_SIZE = 32768;
8744
+ encodeBase64Url = (input) => {
8745
+ if (input instanceof ArrayBuffer) input = new Uint8Array(input);
8746
+ const arr = [];
8747
+ for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
8748
+ return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
8749
+ };
8750
+ }
8751
+ var decodeBase64Url;
8752
+ if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
8753
+ try {
8754
+ return Uint8Array.fromBase64(input, { alphabet: "base64url" });
8755
+ } catch (cause) {
8756
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
8757
+ }
8758
+ };
8759
+ else decodeBase64Url = (input) => {
8760
+ try {
8761
+ const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
8762
+ const bytes = new Uint8Array(binary.length);
8763
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
8764
+ return bytes;
8765
+ } catch (cause) {
8766
+ throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
8767
+ }
8768
+ };
8769
+ var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
8770
+ try {
8771
+ return new URL(url, base);
8772
+ } catch {
8773
+ return null;
8774
+ }
8775
+ };
8776
+ var tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
8777
+ var token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
8778
+ var quotedParamMatcher = "(" + tokenMatch + ')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"';
8779
+ var paramMatcher = "(" + tokenMatch + ")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)";
8780
+ var schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
8781
+ var quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
8782
+ var unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
8783
+ var token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
8784
+ var nopkce = Symbol();
8785
+ var expectNoNonce = Symbol();
8786
+ var skipAuthTimeCheck = Symbol();
8787
+ var skipStateCheck = Symbol();
8788
+ var expectNoState = Symbol();
8789
+ var _expectedIssuer = Symbol();
8790
+ var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
8791
+
8792
+ // ../stack-shared/dist/esm/utils/maps.js
8793
+ var _Symbol$toStringTag3;
8794
+ var _Symbol$toStringTag22;
8795
+ var _Symbol$toStringTag32;
8796
+ var WeakRefIfAvailable = class {
8797
+ constructor(value) {
8798
+ if (typeof WeakRef === "undefined") this._ref = { deref: () => value };
8799
+ else this._ref = new WeakRef(value);
8800
+ }
8801
+ deref() {
8802
+ return this._ref.deref();
8803
+ }
8804
+ };
8805
+ var _a2;
8806
+ var IterableWeakMap = (_a2 = class {
8807
+ constructor(entries) {
8808
+ this[_Symbol$toStringTag3] = "IterableWeakMap";
8809
+ const mappedEntries = entries?.map((e40) => [e40[0], {
8810
+ value: e40[1],
8811
+ keyRef: new WeakRefIfAvailable(e40[0])
8812
+ }]);
8813
+ this._weakMap = new WeakMap(mappedEntries ?? []);
8814
+ this._keyRefs = new Set(mappedEntries?.map((e40) => e40[1].keyRef) ?? []);
8815
+ }
8816
+ get(key) {
8817
+ return this._weakMap.get(key)?.value;
8818
+ }
8819
+ set(key, value) {
8820
+ const updated = {
8821
+ value,
8822
+ keyRef: this._weakMap.get(key)?.keyRef ?? new WeakRefIfAvailable(key)
8823
+ };
8824
+ this._weakMap.set(key, updated);
8825
+ this._keyRefs.add(updated.keyRef);
8826
+ return this;
8827
+ }
8828
+ delete(key) {
8829
+ const res = this._weakMap.get(key);
8830
+ if (res) {
8831
+ this._weakMap.delete(key);
8832
+ this._keyRefs.delete(res.keyRef);
8833
+ return true;
8834
+ }
8835
+ return false;
8836
+ }
8837
+ has(key) {
8838
+ return this._weakMap.has(key) && this._keyRefs.has(this._weakMap.get(key).keyRef);
8839
+ }
8840
+ *[Symbol.iterator]() {
8841
+ for (const keyRef of this._keyRefs) {
8842
+ const key = keyRef.deref();
8843
+ const existing = key ? this._weakMap.get(key) : void 0;
8844
+ if (!key) this._keyRefs.delete(keyRef);
8845
+ else if (existing) yield [key, existing.value];
8846
+ }
8847
+ }
8848
+ }, _Symbol$toStringTag3 = Symbol.toStringTag, _a2);
8849
+ var _a3;
8850
+ var MaybeWeakMap = (_a3 = class {
8851
+ constructor(entries) {
8852
+ this[_Symbol$toStringTag22] = "MaybeWeakMap";
8853
+ const entriesArray = [...entries ?? []];
8854
+ this._primitiveMap = new Map(entriesArray.filter((e40) => !this._isAllowedInWeakMap(e40[0])));
8855
+ this._weakMap = new IterableWeakMap(entriesArray.filter((e40) => this._isAllowedInWeakMap(e40[0])));
8856
+ }
8857
+ _isAllowedInWeakMap(key) {
8858
+ return typeof key === "object" && key !== null || typeof key === "symbol" && Symbol.keyFor(key) === void 0;
8859
+ }
8860
+ get(key) {
8861
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.get(key);
8862
+ else return this._primitiveMap.get(key);
8863
+ }
8864
+ set(key, value) {
8865
+ if (this._isAllowedInWeakMap(key)) this._weakMap.set(key, value);
8866
+ else this._primitiveMap.set(key, value);
8867
+ return this;
8868
+ }
8869
+ delete(key) {
8870
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.delete(key);
8871
+ else return this._primitiveMap.delete(key);
8872
+ }
8873
+ has(key) {
8874
+ if (this._isAllowedInWeakMap(key)) return this._weakMap.has(key);
8875
+ else return this._primitiveMap.has(key);
8876
+ }
8877
+ *[Symbol.iterator]() {
8878
+ yield* this._primitiveMap;
8879
+ yield* this._weakMap;
8880
+ }
8881
+ }, _Symbol$toStringTag22 = Symbol.toStringTag, _a3);
8882
+ var _a4;
8883
+ var DependenciesMap = (_a4 = class {
8884
+ constructor() {
8885
+ this._inner = {
8886
+ map: new MaybeWeakMap(),
8887
+ hasValue: false,
8888
+ value: void 0
8889
+ };
8890
+ this[_Symbol$toStringTag32] = "DependenciesMap";
8891
+ }
8892
+ _valueToResult(inner) {
8893
+ if (inner.hasValue) return Result.ok(inner.value);
8894
+ else return Result.error(void 0);
8895
+ }
8896
+ _unwrapFromInner(dependencies, inner) {
8897
+ if (dependencies.length === 0) return this._valueToResult(inner);
8898
+ else {
8899
+ const [key, ...rest] = dependencies;
8900
+ const newInner = inner.map.get(key);
8901
+ if (!newInner) return Result.error(void 0);
8902
+ return this._unwrapFromInner(rest, newInner);
8903
+ }
8904
+ }
8905
+ _setInInner(dependencies, value, inner) {
8906
+ if (dependencies.length === 0) {
8907
+ const res = this._valueToResult(inner);
8908
+ if (value.status === "ok") {
8909
+ inner.hasValue = true;
8910
+ inner.value = value.data;
8911
+ } else {
8912
+ inner.hasValue = false;
8913
+ inner.value = void 0;
8914
+ }
8915
+ return res;
8916
+ } else {
8917
+ const [key, ...rest] = dependencies;
8918
+ let newInner = inner.map.get(key);
8919
+ if (!newInner) inner.map.set(key, newInner = {
8920
+ map: new MaybeWeakMap(),
8921
+ hasValue: false,
8922
+ value: void 0
8923
+ });
8924
+ return this._setInInner(rest, value, newInner);
8925
+ }
8926
+ }
8927
+ *_iterateInner(dependencies, inner) {
8928
+ if (inner.hasValue) yield [dependencies, inner.value];
8929
+ for (const [key, value] of inner.map) yield* this._iterateInner([...dependencies, key], value);
8930
+ }
8931
+ get(dependencies) {
8932
+ return Result.or(this._unwrapFromInner(dependencies, this._inner), void 0);
8933
+ }
8934
+ set(dependencies, value) {
8935
+ this._setInInner(dependencies, Result.ok(value), this._inner);
8936
+ return this;
8937
+ }
8938
+ delete(dependencies) {
8939
+ return this._setInInner(dependencies, Result.error(void 0), this._inner).status === "ok";
8940
+ }
8941
+ has(dependencies) {
8942
+ return this._unwrapFromInner(dependencies, this._inner).status === "ok";
8943
+ }
8944
+ clear() {
8945
+ this._inner = {
8946
+ map: new MaybeWeakMap(),
8947
+ hasValue: false,
8948
+ value: void 0
8949
+ };
8950
+ }
8951
+ *[Symbol.iterator]() {
8952
+ yield* this._iterateInner([], this._inner);
8953
+ }
8954
+ }, _Symbol$toStringTag32 = Symbol.toStringTag, _a4);
8955
+
8956
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/platform/browser/globalThis.js
8957
+ var _globalThis = typeof globalThis === "object" ? globalThis : typeof self === "object" ? self : typeof window === "object" ? window : typeof global === "object" ? global : {};
8958
+
8959
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/version.js
8960
+ var VERSION = "1.9.0";
8961
+
8962
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/semver.js
8963
+ var re = /^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;
8964
+ function _makeCompatibilityCheck(ownVersion) {
8965
+ var acceptedVersions = /* @__PURE__ */ new Set([ownVersion]);
8966
+ var rejectedVersions = /* @__PURE__ */ new Set();
8967
+ var myVersionMatch = ownVersion.match(re);
8968
+ if (!myVersionMatch) {
8969
+ return function() {
8970
+ return false;
8971
+ };
8972
+ }
8973
+ var ownVersionParsed = {
8974
+ major: +myVersionMatch[1],
8975
+ minor: +myVersionMatch[2],
8976
+ patch: +myVersionMatch[3],
8977
+ prerelease: myVersionMatch[4]
8978
+ };
8979
+ if (ownVersionParsed.prerelease != null) {
8980
+ return function isExactmatch(globalVersion) {
8981
+ return globalVersion === ownVersion;
8982
+ };
8983
+ }
8984
+ function _reject(v) {
8985
+ rejectedVersions.add(v);
8986
+ return false;
8987
+ }
8988
+ function _accept(v) {
8989
+ acceptedVersions.add(v);
8990
+ return true;
8991
+ }
8992
+ return function isCompatible2(globalVersion) {
8993
+ if (acceptedVersions.has(globalVersion)) {
8994
+ return true;
8995
+ }
8996
+ if (rejectedVersions.has(globalVersion)) {
8997
+ return false;
8998
+ }
8999
+ var globalVersionMatch = globalVersion.match(re);
9000
+ if (!globalVersionMatch) {
9001
+ return _reject(globalVersion);
9002
+ }
9003
+ var globalVersionParsed = {
9004
+ major: +globalVersionMatch[1],
9005
+ minor: +globalVersionMatch[2],
9006
+ patch: +globalVersionMatch[3],
9007
+ prerelease: globalVersionMatch[4]
9008
+ };
9009
+ if (globalVersionParsed.prerelease != null) {
9010
+ return _reject(globalVersion);
9011
+ }
9012
+ if (ownVersionParsed.major !== globalVersionParsed.major) {
9013
+ return _reject(globalVersion);
9014
+ }
9015
+ if (ownVersionParsed.major === 0) {
9016
+ if (ownVersionParsed.minor === globalVersionParsed.minor && ownVersionParsed.patch <= globalVersionParsed.patch) {
9017
+ return _accept(globalVersion);
9018
+ }
9019
+ return _reject(globalVersion);
9020
+ }
9021
+ if (ownVersionParsed.minor <= globalVersionParsed.minor) {
9022
+ return _accept(globalVersion);
9023
+ }
9024
+ return _reject(globalVersion);
9025
+ };
9026
+ }
9027
+ var isCompatible = _makeCompatibilityCheck(VERSION);
9028
+
9029
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/internal/global-utils.js
9030
+ var major = VERSION.split(".")[0];
9031
+ var GLOBAL_OPENTELEMETRY_API_KEY = Symbol.for("opentelemetry.js.api." + major);
9032
+ var _global = _globalThis;
9033
+ function registerGlobal(type, instance, diag, allowOverride) {
9034
+ var _a5;
9035
+ if (allowOverride === void 0) {
9036
+ allowOverride = false;
9037
+ }
9038
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a5 !== void 0 ? _a5 : {
9039
+ version: VERSION
9040
+ };
9041
+ if (!allowOverride && api[type]) {
9042
+ var err = new Error("@opentelemetry/api: Attempted duplicate registration of API: " + type);
9043
+ diag.error(err.stack || err.message);
9044
+ return false;
9045
+ }
9046
+ if (api.version !== VERSION) {
9047
+ var err = new Error("@opentelemetry/api: Registration of version v" + api.version + " for " + type + " does not match previously registered API v" + VERSION);
9048
+ diag.error(err.stack || err.message);
9049
+ return false;
9050
+ }
9051
+ api[type] = instance;
9052
+ diag.debug("@opentelemetry/api: Registered a global for " + type + " v" + VERSION + ".");
9053
+ return true;
9054
+ }
9055
+ function getGlobal(type) {
9056
+ var _a5, _b;
9057
+ var globalVersion = (_a5 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a5 === void 0 ? void 0 : _a5.version;
9058
+ if (!globalVersion || !isCompatible(globalVersion)) {
9059
+ return;
9060
+ }
9061
+ return (_b = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _b === void 0 ? void 0 : _b[type];
9062
+ }
9063
+ function unregisterGlobal(type, diag) {
9064
+ diag.debug("@opentelemetry/api: Unregistering a global for " + type + " v" + VERSION + ".");
9065
+ var api = _global[GLOBAL_OPENTELEMETRY_API_KEY];
9066
+ if (api) {
9067
+ delete api[type];
9068
+ }
9069
+ }
9070
+
9071
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/ComponentLogger.js
9072
+ var __read = function(o21, n9) {
9073
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9074
+ if (!m5) return o21;
9075
+ var i = m5.call(o21), r7, ar = [], e40;
9076
+ try {
9077
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9078
+ } catch (error) {
9079
+ e40 = { error };
9080
+ } finally {
9081
+ try {
9082
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9083
+ } finally {
9084
+ if (e40) throw e40.error;
9085
+ }
9086
+ }
9087
+ return ar;
9088
+ };
9089
+ var __spreadArray = function(to, from, pack) {
9090
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9091
+ if (ar || !(i in from)) {
9092
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9093
+ ar[i] = from[i];
9094
+ }
9095
+ }
9096
+ return to.concat(ar || Array.prototype.slice.call(from));
9097
+ };
9098
+ var DiagComponentLogger = (
9099
+ /** @class */
9100
+ function() {
9101
+ function DiagComponentLogger2(props) {
9102
+ this._namespace = props.namespace || "DiagComponentLogger";
9103
+ }
9104
+ DiagComponentLogger2.prototype.debug = function() {
9105
+ var args = [];
9106
+ for (var _i = 0; _i < arguments.length; _i++) {
9107
+ args[_i] = arguments[_i];
9108
+ }
9109
+ return logProxy("debug", this._namespace, args);
9110
+ };
9111
+ DiagComponentLogger2.prototype.error = function() {
9112
+ var args = [];
9113
+ for (var _i = 0; _i < arguments.length; _i++) {
9114
+ args[_i] = arguments[_i];
9115
+ }
9116
+ return logProxy("error", this._namespace, args);
9117
+ };
9118
+ DiagComponentLogger2.prototype.info = function() {
9119
+ var args = [];
9120
+ for (var _i = 0; _i < arguments.length; _i++) {
9121
+ args[_i] = arguments[_i];
9122
+ }
9123
+ return logProxy("info", this._namespace, args);
9124
+ };
9125
+ DiagComponentLogger2.prototype.warn = function() {
9126
+ var args = [];
9127
+ for (var _i = 0; _i < arguments.length; _i++) {
9128
+ args[_i] = arguments[_i];
9129
+ }
9130
+ return logProxy("warn", this._namespace, args);
9131
+ };
9132
+ DiagComponentLogger2.prototype.verbose = function() {
9133
+ var args = [];
9134
+ for (var _i = 0; _i < arguments.length; _i++) {
9135
+ args[_i] = arguments[_i];
9136
+ }
9137
+ return logProxy("verbose", this._namespace, args);
9138
+ };
9139
+ return DiagComponentLogger2;
9140
+ }()
9141
+ );
9142
+ function logProxy(funcName, namespace, args) {
9143
+ var logger = getGlobal("diag");
9144
+ if (!logger) {
9145
+ return;
9146
+ }
9147
+ args.unshift(namespace);
9148
+ return logger[funcName].apply(logger, __spreadArray([], __read(args), false));
9149
+ }
9150
+
9151
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/types.js
9152
+ var DiagLogLevel;
9153
+ (function(DiagLogLevel2) {
9154
+ DiagLogLevel2[DiagLogLevel2["NONE"] = 0] = "NONE";
9155
+ DiagLogLevel2[DiagLogLevel2["ERROR"] = 30] = "ERROR";
9156
+ DiagLogLevel2[DiagLogLevel2["WARN"] = 50] = "WARN";
9157
+ DiagLogLevel2[DiagLogLevel2["INFO"] = 60] = "INFO";
9158
+ DiagLogLevel2[DiagLogLevel2["DEBUG"] = 70] = "DEBUG";
9159
+ DiagLogLevel2[DiagLogLevel2["VERBOSE"] = 80] = "VERBOSE";
9160
+ DiagLogLevel2[DiagLogLevel2["ALL"] = 9999] = "ALL";
9161
+ })(DiagLogLevel || (DiagLogLevel = {}));
9162
+
9163
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/diag/internal/logLevelLogger.js
9164
+ function createLogLevelDiagLogger(maxLevel, logger) {
9165
+ if (maxLevel < DiagLogLevel.NONE) {
9166
+ maxLevel = DiagLogLevel.NONE;
9167
+ } else if (maxLevel > DiagLogLevel.ALL) {
9168
+ maxLevel = DiagLogLevel.ALL;
9169
+ }
9170
+ logger = logger || {};
9171
+ function _filterFunc(funcName, theLevel) {
9172
+ var theFunc = logger[funcName];
9173
+ if (typeof theFunc === "function" && maxLevel >= theLevel) {
9174
+ return theFunc.bind(logger);
9175
+ }
9176
+ return function() {
9177
+ };
9178
+ }
9179
+ return {
9180
+ error: _filterFunc("error", DiagLogLevel.ERROR),
9181
+ warn: _filterFunc("warn", DiagLogLevel.WARN),
9182
+ info: _filterFunc("info", DiagLogLevel.INFO),
9183
+ debug: _filterFunc("debug", DiagLogLevel.DEBUG),
9184
+ verbose: _filterFunc("verbose", DiagLogLevel.VERBOSE)
9185
+ };
9186
+ }
9187
+
9188
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/diag.js
9189
+ var __read2 = function(o21, n9) {
9190
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9191
+ if (!m5) return o21;
9192
+ var i = m5.call(o21), r7, ar = [], e40;
9193
+ try {
9194
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9195
+ } catch (error) {
9196
+ e40 = { error };
9197
+ } finally {
9198
+ try {
9199
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9200
+ } finally {
9201
+ if (e40) throw e40.error;
9202
+ }
9203
+ }
9204
+ return ar;
9205
+ };
9206
+ var __spreadArray2 = function(to, from, pack) {
9207
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9208
+ if (ar || !(i in from)) {
9209
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9210
+ ar[i] = from[i];
9211
+ }
9212
+ }
9213
+ return to.concat(ar || Array.prototype.slice.call(from));
9214
+ };
9215
+ var API_NAME = "diag";
9216
+ var DiagAPI = (
9217
+ /** @class */
9218
+ function() {
9219
+ function DiagAPI2() {
9220
+ function _logProxy(funcName) {
9221
+ return function() {
9222
+ var args = [];
9223
+ for (var _i = 0; _i < arguments.length; _i++) {
9224
+ args[_i] = arguments[_i];
9225
+ }
9226
+ var logger = getGlobal("diag");
9227
+ if (!logger)
9228
+ return;
9229
+ return logger[funcName].apply(logger, __spreadArray2([], __read2(args), false));
9230
+ };
9231
+ }
9232
+ var self2 = this;
9233
+ var setLogger = function(logger, optionsOrLogLevel) {
9234
+ var _a5, _b, _c;
9235
+ if (optionsOrLogLevel === void 0) {
9236
+ optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
9237
+ }
9238
+ if (logger === self2) {
9239
+ var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
9240
+ self2.error((_a5 = err.stack) !== null && _a5 !== void 0 ? _a5 : err.message);
9241
+ return false;
9242
+ }
9243
+ if (typeof optionsOrLogLevel === "number") {
9244
+ optionsOrLogLevel = {
9245
+ logLevel: optionsOrLogLevel
9246
+ };
9247
+ }
9248
+ var oldLogger = getGlobal("diag");
9249
+ var newLogger = createLogLevelDiagLogger((_b = optionsOrLogLevel.logLevel) !== null && _b !== void 0 ? _b : DiagLogLevel.INFO, logger);
9250
+ if (oldLogger && !optionsOrLogLevel.suppressOverrideMessage) {
9251
+ var stack = (_c = new Error().stack) !== null && _c !== void 0 ? _c : "<failed to generate stacktrace>";
9252
+ oldLogger.warn("Current logger will be overwritten from " + stack);
9253
+ newLogger.warn("Current logger will overwrite one already registered from " + stack);
9254
+ }
9255
+ return registerGlobal("diag", newLogger, self2, true);
9256
+ };
9257
+ self2.setLogger = setLogger;
9258
+ self2.disable = function() {
9259
+ unregisterGlobal(API_NAME, self2);
9260
+ };
9261
+ self2.createComponentLogger = function(options) {
9262
+ return new DiagComponentLogger(options);
9263
+ };
9264
+ self2.verbose = _logProxy("verbose");
9265
+ self2.debug = _logProxy("debug");
9266
+ self2.info = _logProxy("info");
9267
+ self2.warn = _logProxy("warn");
9268
+ self2.error = _logProxy("error");
9269
+ }
9270
+ DiagAPI2.instance = function() {
9271
+ if (!this._instance) {
9272
+ this._instance = new DiagAPI2();
9273
+ }
9274
+ return this._instance;
9275
+ };
9276
+ return DiagAPI2;
9277
+ }()
9278
+ );
9279
+
9280
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/context.js
9281
+ function createContextKey(description) {
9282
+ return Symbol.for(description);
9283
+ }
9284
+ var BaseContext = (
9285
+ /** @class */
9286
+ /* @__PURE__ */ function() {
9287
+ function BaseContext2(parentContext) {
9288
+ var self2 = this;
9289
+ self2._currentContext = parentContext ? new Map(parentContext) : /* @__PURE__ */ new Map();
9290
+ self2.getValue = function(key) {
9291
+ return self2._currentContext.get(key);
9292
+ };
9293
+ self2.setValue = function(key, value) {
9294
+ var context = new BaseContext2(self2._currentContext);
9295
+ context._currentContext.set(key, value);
9296
+ return context;
9297
+ };
9298
+ self2.deleteValue = function(key) {
9299
+ var context = new BaseContext2(self2._currentContext);
9300
+ context._currentContext.delete(key);
9301
+ return context;
9302
+ };
9303
+ }
9304
+ return BaseContext2;
9305
+ }()
9306
+ );
9307
+ var ROOT_CONTEXT = new BaseContext();
9308
+
9309
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/context/NoopContextManager.js
9310
+ var __read3 = function(o21, n9) {
9311
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9312
+ if (!m5) return o21;
9313
+ var i = m5.call(o21), r7, ar = [], e40;
9314
+ try {
9315
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9316
+ } catch (error) {
9317
+ e40 = { error };
9318
+ } finally {
9319
+ try {
9320
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9321
+ } finally {
9322
+ if (e40) throw e40.error;
9323
+ }
9436
9324
  }
9437
- return new (P || (P = Promise))(function(resolve, reject) {
9438
- function fulfilled(value) {
9439
- try {
9440
- step(generator.next(value));
9441
- } catch (e40) {
9442
- reject(e40);
9325
+ return ar;
9326
+ };
9327
+ var __spreadArray3 = function(to, from, pack) {
9328
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9329
+ if (ar || !(i in from)) {
9330
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9331
+ ar[i] = from[i];
9332
+ }
9333
+ }
9334
+ return to.concat(ar || Array.prototype.slice.call(from));
9335
+ };
9336
+ var NoopContextManager = (
9337
+ /** @class */
9338
+ function() {
9339
+ function NoopContextManager2() {
9340
+ }
9341
+ NoopContextManager2.prototype.active = function() {
9342
+ return ROOT_CONTEXT;
9343
+ };
9344
+ NoopContextManager2.prototype.with = function(_context, fn, thisArg) {
9345
+ var args = [];
9346
+ for (var _i = 3; _i < arguments.length; _i++) {
9347
+ args[_i - 3] = arguments[_i];
9443
9348
  }
9349
+ return fn.call.apply(fn, __spreadArray3([thisArg], __read3(args), false));
9350
+ };
9351
+ NoopContextManager2.prototype.bind = function(_context, target) {
9352
+ return target;
9353
+ };
9354
+ NoopContextManager2.prototype.enable = function() {
9355
+ return this;
9356
+ };
9357
+ NoopContextManager2.prototype.disable = function() {
9358
+ return this;
9359
+ };
9360
+ return NoopContextManager2;
9361
+ }()
9362
+ );
9363
+
9364
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/context.js
9365
+ var __read4 = function(o21, n9) {
9366
+ var m5 = typeof Symbol === "function" && o21[Symbol.iterator];
9367
+ if (!m5) return o21;
9368
+ var i = m5.call(o21), r7, ar = [], e40;
9369
+ try {
9370
+ while ((n9 === void 0 || n9-- > 0) && !(r7 = i.next()).done) ar.push(r7.value);
9371
+ } catch (error) {
9372
+ e40 = { error };
9373
+ } finally {
9374
+ try {
9375
+ if (r7 && !r7.done && (m5 = i["return"])) m5.call(i);
9376
+ } finally {
9377
+ if (e40) throw e40.error;
9444
9378
  }
9445
- function rejected2(value) {
9446
- try {
9447
- step(generator["throw"](value));
9448
- } catch (e40) {
9449
- reject(e40);
9379
+ }
9380
+ return ar;
9381
+ };
9382
+ var __spreadArray4 = function(to, from, pack) {
9383
+ if (pack || arguments.length === 2) for (var i = 0, l3 = from.length, ar; i < l3; i++) {
9384
+ if (ar || !(i in from)) {
9385
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
9386
+ ar[i] = from[i];
9387
+ }
9388
+ }
9389
+ return to.concat(ar || Array.prototype.slice.call(from));
9390
+ };
9391
+ var API_NAME2 = "context";
9392
+ var NOOP_CONTEXT_MANAGER = new NoopContextManager();
9393
+ var ContextAPI = (
9394
+ /** @class */
9395
+ function() {
9396
+ function ContextAPI2() {
9397
+ }
9398
+ ContextAPI2.getInstance = function() {
9399
+ if (!this._instance) {
9400
+ this._instance = new ContextAPI2();
9401
+ }
9402
+ return this._instance;
9403
+ };
9404
+ ContextAPI2.prototype.setGlobalContextManager = function(contextManager) {
9405
+ return registerGlobal(API_NAME2, contextManager, DiagAPI.instance());
9406
+ };
9407
+ ContextAPI2.prototype.active = function() {
9408
+ return this._getContextManager().active();
9409
+ };
9410
+ ContextAPI2.prototype.with = function(context, fn, thisArg) {
9411
+ var _a5;
9412
+ var args = [];
9413
+ for (var _i = 3; _i < arguments.length; _i++) {
9414
+ args[_i - 3] = arguments[_i];
9415
+ }
9416
+ return (_a5 = this._getContextManager()).with.apply(_a5, __spreadArray4([context, fn, thisArg], __read4(args), false));
9417
+ };
9418
+ ContextAPI2.prototype.bind = function(context, target) {
9419
+ return this._getContextManager().bind(context, target);
9420
+ };
9421
+ ContextAPI2.prototype._getContextManager = function() {
9422
+ return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
9423
+ };
9424
+ ContextAPI2.prototype.disable = function() {
9425
+ this._getContextManager().disable();
9426
+ unregisterGlobal(API_NAME2, DiagAPI.instance());
9427
+ };
9428
+ return ContextAPI2;
9429
+ }()
9430
+ );
9431
+
9432
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js
9433
+ var TraceFlags;
9434
+ (function(TraceFlags2) {
9435
+ TraceFlags2[TraceFlags2["NONE"] = 0] = "NONE";
9436
+ TraceFlags2[TraceFlags2["SAMPLED"] = 1] = "SAMPLED";
9437
+ })(TraceFlags || (TraceFlags = {}));
9438
+
9439
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/invalid-span-constants.js
9440
+ var INVALID_SPANID = "0000000000000000";
9441
+ var INVALID_TRACEID = "00000000000000000000000000000000";
9442
+ var INVALID_SPAN_CONTEXT = {
9443
+ traceId: INVALID_TRACEID,
9444
+ spanId: INVALID_SPANID,
9445
+ traceFlags: TraceFlags.NONE
9446
+ };
9447
+
9448
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NonRecordingSpan.js
9449
+ var NonRecordingSpan = (
9450
+ /** @class */
9451
+ function() {
9452
+ function NonRecordingSpan2(_spanContext) {
9453
+ if (_spanContext === void 0) {
9454
+ _spanContext = INVALID_SPAN_CONTEXT;
9450
9455
  }
9456
+ this._spanContext = _spanContext;
9451
9457
  }
9452
- function step(result) {
9453
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected2);
9458
+ NonRecordingSpan2.prototype.spanContext = function() {
9459
+ return this._spanContext;
9460
+ };
9461
+ NonRecordingSpan2.prototype.setAttribute = function(_key, _value) {
9462
+ return this;
9463
+ };
9464
+ NonRecordingSpan2.prototype.setAttributes = function(_attributes) {
9465
+ return this;
9466
+ };
9467
+ NonRecordingSpan2.prototype.addEvent = function(_name, _attributes) {
9468
+ return this;
9469
+ };
9470
+ NonRecordingSpan2.prototype.addLink = function(_link) {
9471
+ return this;
9472
+ };
9473
+ NonRecordingSpan2.prototype.addLinks = function(_links) {
9474
+ return this;
9475
+ };
9476
+ NonRecordingSpan2.prototype.setStatus = function(_status) {
9477
+ return this;
9478
+ };
9479
+ NonRecordingSpan2.prototype.updateName = function(_name) {
9480
+ return this;
9481
+ };
9482
+ NonRecordingSpan2.prototype.end = function(_endTime) {
9483
+ };
9484
+ NonRecordingSpan2.prototype.isRecording = function() {
9485
+ return false;
9486
+ };
9487
+ NonRecordingSpan2.prototype.recordException = function(_exception, _time) {
9488
+ };
9489
+ return NonRecordingSpan2;
9490
+ }()
9491
+ );
9492
+
9493
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/context-utils.js
9494
+ var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
9495
+ function getSpan(context) {
9496
+ return context.getValue(SPAN_KEY) || void 0;
9497
+ }
9498
+ function getActiveSpan() {
9499
+ return getSpan(ContextAPI.getInstance().active());
9500
+ }
9501
+ function setSpan(context, span) {
9502
+ return context.setValue(SPAN_KEY, span);
9503
+ }
9504
+ function deleteSpan(context) {
9505
+ return context.deleteValue(SPAN_KEY);
9506
+ }
9507
+ function setSpanContext(context, spanContext) {
9508
+ return setSpan(context, new NonRecordingSpan(spanContext));
9509
+ }
9510
+ function getSpanContext(context) {
9511
+ var _a5;
9512
+ return (_a5 = getSpan(context)) === null || _a5 === void 0 ? void 0 : _a5.spanContext();
9513
+ }
9514
+
9515
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js
9516
+ var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
9517
+ var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
9518
+ function isValidTraceId(traceId) {
9519
+ return VALID_TRACEID_REGEX.test(traceId) && traceId !== INVALID_TRACEID;
9520
+ }
9521
+ function isValidSpanId(spanId) {
9522
+ return VALID_SPANID_REGEX.test(spanId) && spanId !== INVALID_SPANID;
9523
+ }
9524
+ function isSpanContextValid(spanContext) {
9525
+ return isValidTraceId(spanContext.traceId) && isValidSpanId(spanContext.spanId);
9526
+ }
9527
+ function wrapSpanContext(spanContext) {
9528
+ return new NonRecordingSpan(spanContext);
9529
+ }
9530
+
9531
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracer.js
9532
+ var contextApi = ContextAPI.getInstance();
9533
+ var NoopTracer = (
9534
+ /** @class */
9535
+ function() {
9536
+ function NoopTracer2() {
9454
9537
  }
9455
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9456
- });
9457
- };
9458
- var Semaphore = class {
9459
- constructor(_value, _cancelError = E_CANCELED) {
9460
- this._value = _value;
9461
- this._cancelError = _cancelError;
9462
- this._queue = [];
9463
- this._weightedWaiters = [];
9464
- }
9465
- acquire(weight = 1, priority = 0) {
9466
- if (weight <= 0)
9467
- throw new Error(`invalid weight ${weight}: must be positive`);
9468
- return new Promise((resolve, reject) => {
9469
- const task = { resolve, reject, weight, priority };
9470
- const i = findIndexFromEnd(this._queue, (other) => priority <= other.priority);
9471
- if (i === -1 && weight <= this._value) {
9472
- this._dispatchItem(task);
9538
+ NoopTracer2.prototype.startSpan = function(name, options, context) {
9539
+ if (context === void 0) {
9540
+ context = contextApi.active();
9541
+ }
9542
+ var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
9543
+ if (root) {
9544
+ return new NonRecordingSpan();
9545
+ }
9546
+ var parentFromContext = context && getSpanContext(context);
9547
+ if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
9548
+ return new NonRecordingSpan(parentFromContext);
9473
9549
  } else {
9474
- this._queue.splice(i + 1, 0, task);
9550
+ return new NonRecordingSpan();
9475
9551
  }
9476
- });
9477
- }
9478
- runExclusive(callback_1) {
9479
- return __awaiter$2(this, arguments, void 0, function* (callback, weight = 1, priority = 0) {
9480
- const [value, release] = yield this.acquire(weight, priority);
9481
- try {
9482
- return yield callback(value);
9483
- } finally {
9484
- release();
9552
+ };
9553
+ NoopTracer2.prototype.startActiveSpan = function(name, arg2, arg3, arg4) {
9554
+ var opts;
9555
+ var ctx;
9556
+ var fn;
9557
+ if (arguments.length < 2) {
9558
+ return;
9559
+ } else if (arguments.length === 2) {
9560
+ fn = arg2;
9561
+ } else if (arguments.length === 3) {
9562
+ opts = arg2;
9563
+ fn = arg3;
9564
+ } else {
9565
+ opts = arg2;
9566
+ ctx = arg3;
9567
+ fn = arg4;
9485
9568
  }
9486
- });
9487
- }
9488
- waitForUnlock(weight = 1, priority = 0) {
9489
- if (weight <= 0)
9490
- throw new Error(`invalid weight ${weight}: must be positive`);
9491
- if (this._couldLockImmediately(weight, priority)) {
9492
- return Promise.resolve();
9493
- } else {
9494
- return new Promise((resolve) => {
9495
- if (!this._weightedWaiters[weight - 1])
9496
- this._weightedWaiters[weight - 1] = [];
9497
- insertSorted(this._weightedWaiters[weight - 1], { resolve, priority });
9498
- });
9499
- }
9500
- }
9501
- isLocked() {
9502
- return this._value <= 0;
9503
- }
9504
- getValue() {
9505
- return this._value;
9506
- }
9507
- setValue(value) {
9508
- this._value = value;
9509
- this._dispatchQueue();
9510
- }
9511
- release(weight = 1) {
9512
- if (weight <= 0)
9513
- throw new Error(`invalid weight ${weight}: must be positive`);
9514
- this._value += weight;
9515
- this._dispatchQueue();
9516
- }
9517
- cancel() {
9518
- this._queue.forEach((entry) => entry.reject(this._cancelError));
9519
- this._queue = [];
9520
- }
9521
- _dispatchQueue() {
9522
- this._drainUnlockWaiters();
9523
- while (this._queue.length > 0 && this._queue[0].weight <= this._value) {
9524
- this._dispatchItem(this._queue.shift());
9525
- this._drainUnlockWaiters();
9569
+ var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
9570
+ var span = this.startSpan(name, opts, parentContext);
9571
+ var contextWithSpanSet = setSpan(parentContext, span);
9572
+ return contextApi.with(contextWithSpanSet, fn, void 0, span);
9573
+ };
9574
+ return NoopTracer2;
9575
+ }()
9576
+ );
9577
+ function isSpanContext(spanContext) {
9578
+ return typeof spanContext === "object" && typeof spanContext["spanId"] === "string" && typeof spanContext["traceId"] === "string" && typeof spanContext["traceFlags"] === "number";
9579
+ }
9580
+
9581
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracer.js
9582
+ var NOOP_TRACER = new NoopTracer();
9583
+ var ProxyTracer = (
9584
+ /** @class */
9585
+ function() {
9586
+ function ProxyTracer2(_provider, name, version, options) {
9587
+ this._provider = _provider;
9588
+ this.name = name;
9589
+ this.version = version;
9590
+ this.options = options;
9526
9591
  }
9527
- }
9528
- _dispatchItem(item) {
9529
- const previousValue = this._value;
9530
- this._value -= item.weight;
9531
- item.resolve([previousValue, this._newReleaser(item.weight)]);
9532
- }
9533
- _newReleaser(weight) {
9534
- let called = false;
9535
- return () => {
9536
- if (called)
9537
- return;
9538
- called = true;
9539
- this.release(weight);
9592
+ ProxyTracer2.prototype.startSpan = function(name, options, context) {
9593
+ return this._getTracer().startSpan(name, options, context);
9540
9594
  };
9541
- }
9542
- _drainUnlockWaiters() {
9543
- if (this._queue.length === 0) {
9544
- for (let weight = this._value; weight > 0; weight--) {
9545
- const waiters = this._weightedWaiters[weight - 1];
9546
- if (!waiters)
9547
- continue;
9548
- waiters.forEach((waiter) => waiter.resolve());
9549
- this._weightedWaiters[weight - 1] = [];
9595
+ ProxyTracer2.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
9596
+ var tracer2 = this._getTracer();
9597
+ return Reflect.apply(tracer2.startActiveSpan, tracer2, arguments);
9598
+ };
9599
+ ProxyTracer2.prototype._getTracer = function() {
9600
+ if (this._delegate) {
9601
+ return this._delegate;
9550
9602
  }
9551
- } else {
9552
- const queuedPriority = this._queue[0].priority;
9553
- for (let weight = this._value; weight > 0; weight--) {
9554
- const waiters = this._weightedWaiters[weight - 1];
9555
- if (!waiters)
9556
- continue;
9557
- const i = waiters.findIndex((waiter) => waiter.priority <= queuedPriority);
9558
- (i === -1 ? waiters : waiters.splice(0, i)).forEach((waiter) => waiter.resolve());
9603
+ var tracer2 = this._provider.getDelegateTracer(this.name, this.version, this.options);
9604
+ if (!tracer2) {
9605
+ return NOOP_TRACER;
9559
9606
  }
9560
- }
9561
- }
9562
- _couldLockImmediately(weight, priority) {
9563
- return (this._queue.length === 0 || this._queue[0].priority < priority) && weight <= this._value;
9564
- }
9565
- };
9566
- function insertSorted(a26, v) {
9567
- const i = findIndexFromEnd(a26, (other) => v.priority <= other.priority);
9568
- a26.splice(i + 1, 0, v);
9569
- }
9570
- function findIndexFromEnd(a26, predicate) {
9571
- for (let i = a26.length - 1; i >= 0; i--) {
9572
- if (predicate(a26[i])) {
9573
- return i;
9574
- }
9575
- }
9576
- return -1;
9577
- }
9607
+ this._delegate = tracer2;
9608
+ return this._delegate;
9609
+ };
9610
+ return ProxyTracer2;
9611
+ }()
9612
+ );
9578
9613
 
9579
- // ../stack-shared/dist/esm/utils/locks.js
9580
- var ReadWriteLock = class {
9581
- constructor() {
9582
- this.semaphore = new Semaphore(1);
9583
- this.readers = 0;
9584
- this.readersMutex = new Semaphore(1);
9585
- }
9586
- async withReadLock(callback) {
9587
- await this._acquireReadLock();
9588
- try {
9589
- return await callback();
9590
- } finally {
9591
- await this._releaseReadLock();
9614
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/NoopTracerProvider.js
9615
+ var NoopTracerProvider = (
9616
+ /** @class */
9617
+ function() {
9618
+ function NoopTracerProvider2() {
9592
9619
  }
9593
- }
9594
- async withWriteLock(callback) {
9595
- await this._acquireWriteLock();
9596
- try {
9597
- return await callback();
9598
- } finally {
9599
- await this._releaseWriteLock();
9620
+ NoopTracerProvider2.prototype.getTracer = function(_name, _version, _options) {
9621
+ return new NoopTracer();
9622
+ };
9623
+ return NoopTracerProvider2;
9624
+ }()
9625
+ );
9626
+
9627
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace/ProxyTracerProvider.js
9628
+ var NOOP_TRACER_PROVIDER = new NoopTracerProvider();
9629
+ var ProxyTracerProvider = (
9630
+ /** @class */
9631
+ function() {
9632
+ function ProxyTracerProvider2() {
9600
9633
  }
9601
- }
9602
- async _acquireReadLock() {
9603
- await this.readersMutex.acquire();
9604
- try {
9605
- this.readers += 1;
9606
- if (this.readers === 1) await this.semaphore.acquire();
9607
- } finally {
9608
- this.readersMutex.release();
9634
+ ProxyTracerProvider2.prototype.getTracer = function(name, version, options) {
9635
+ var _a5;
9636
+ return (_a5 = this.getDelegateTracer(name, version, options)) !== null && _a5 !== void 0 ? _a5 : new ProxyTracer(this, name, version, options);
9637
+ };
9638
+ ProxyTracerProvider2.prototype.getDelegate = function() {
9639
+ var _a5;
9640
+ return (_a5 = this._delegate) !== null && _a5 !== void 0 ? _a5 : NOOP_TRACER_PROVIDER;
9641
+ };
9642
+ ProxyTracerProvider2.prototype.setDelegate = function(delegate) {
9643
+ this._delegate = delegate;
9644
+ };
9645
+ ProxyTracerProvider2.prototype.getDelegateTracer = function(name, version, options) {
9646
+ var _a5;
9647
+ return (_a5 = this._delegate) === null || _a5 === void 0 ? void 0 : _a5.getTracer(name, version, options);
9648
+ };
9649
+ return ProxyTracerProvider2;
9650
+ }()
9651
+ );
9652
+
9653
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/api/trace.js
9654
+ var API_NAME3 = "trace";
9655
+ var TraceAPI = (
9656
+ /** @class */
9657
+ function() {
9658
+ function TraceAPI2() {
9659
+ this._proxyTracerProvider = new ProxyTracerProvider();
9660
+ this.wrapSpanContext = wrapSpanContext;
9661
+ this.isSpanContextValid = isSpanContextValid;
9662
+ this.deleteSpan = deleteSpan;
9663
+ this.getSpan = getSpan;
9664
+ this.getActiveSpan = getActiveSpan;
9665
+ this.getSpanContext = getSpanContext;
9666
+ this.setSpan = setSpan;
9667
+ this.setSpanContext = setSpanContext;
9609
9668
  }
9610
- }
9611
- async _releaseReadLock() {
9612
- await this.readersMutex.acquire();
9669
+ TraceAPI2.getInstance = function() {
9670
+ if (!this._instance) {
9671
+ this._instance = new TraceAPI2();
9672
+ }
9673
+ return this._instance;
9674
+ };
9675
+ TraceAPI2.prototype.setGlobalTracerProvider = function(provider) {
9676
+ var success = registerGlobal(API_NAME3, this._proxyTracerProvider, DiagAPI.instance());
9677
+ if (success) {
9678
+ this._proxyTracerProvider.setDelegate(provider);
9679
+ }
9680
+ return success;
9681
+ };
9682
+ TraceAPI2.prototype.getTracerProvider = function() {
9683
+ return getGlobal(API_NAME3) || this._proxyTracerProvider;
9684
+ };
9685
+ TraceAPI2.prototype.getTracer = function(name, version) {
9686
+ return this.getTracerProvider().getTracer(name, version);
9687
+ };
9688
+ TraceAPI2.prototype.disable = function() {
9689
+ unregisterGlobal(API_NAME3, DiagAPI.instance());
9690
+ this._proxyTracerProvider = new ProxyTracerProvider();
9691
+ };
9692
+ return TraceAPI2;
9693
+ }()
9694
+ );
9695
+
9696
+ // ../../node_modules/.pnpm/@opentelemetry+api@1.9.0/node_modules/@opentelemetry/api/build/esm/trace-api.js
9697
+ var trace = TraceAPI.getInstance();
9698
+
9699
+ // ../stack-shared/dist/esm/utils/telemetry.js
9700
+ var tracer = trace.getTracer("stack-tracer");
9701
+ async function traceSpan(optionsOrDescription, fn) {
9702
+ let options = typeof optionsOrDescription === "string" ? { description: optionsOrDescription } : optionsOrDescription;
9703
+ return await tracer.startActiveSpan(`STACK: ${options.description}`, async (span) => {
9704
+ if (options.attributes) for (const [key, value] of Object.entries(options.attributes)) span.setAttribute(key, value);
9613
9705
  try {
9614
- this.readers -= 1;
9615
- if (this.readers === 0) this.semaphore.release();
9706
+ return await fn(span);
9616
9707
  } finally {
9617
- this.readersMutex.release();
9708
+ span.end();
9618
9709
  }
9619
- }
9620
- async _acquireWriteLock() {
9621
- await this.semaphore.acquire();
9622
- }
9623
- async _releaseWriteLock() {
9624
- this.semaphore.release();
9625
- }
9626
- };
9627
-
9628
- // ../stack-shared/dist/esm/utils/stores.js
9629
- var storeLock = new ReadWriteLock();
9630
-
9631
- // ../stack-shared/dist/esm/interface/client-interface.js
9632
- var USER_AGENT;
9633
- if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) USER_AGENT = `oauth4webapi/v3.8.3`;
9634
- var ERR_INVALID_ARG_VALUE = "ERR_INVALID_ARG_VALUE";
9635
- function CodedTypeError(message, code, cause) {
9636
- const err = new TypeError(message, { cause });
9637
- Object.assign(err, { code });
9638
- return err;
9639
- }
9640
- var allowInsecureRequests = Symbol();
9641
- var clockSkew = Symbol();
9642
- var clockTolerance = Symbol();
9643
- var customFetch = Symbol();
9644
- var jweDecrypt = Symbol();
9645
- var encoder = new TextEncoder();
9646
- var decoder = new TextDecoder();
9647
- var encodeBase64Url;
9648
- if (Uint8Array.prototype.toBase64) encodeBase64Url = (input) => {
9649
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9650
- return input.toBase64({
9651
- alphabet: "base64url",
9652
- omitPadding: true
9653
9710
  });
9654
- };
9655
- else {
9656
- const CHUNK_SIZE = 32768;
9657
- encodeBase64Url = (input) => {
9658
- if (input instanceof ArrayBuffer) input = new Uint8Array(input);
9659
- const arr = [];
9660
- for (let i = 0; i < input.byteLength; i += CHUNK_SIZE) arr.push(String.fromCharCode.apply(null, input.subarray(i, i + CHUNK_SIZE)));
9661
- return btoa(arr.join("")).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
9662
- };
9663
9711
  }
9664
- var decodeBase64Url;
9665
- if (Uint8Array.fromBase64) decodeBase64Url = (input) => {
9666
- try {
9667
- return Uint8Array.fromBase64(input, { alphabet: "base64url" });
9668
- } catch (cause) {
9669
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9670
- }
9671
- };
9672
- else decodeBase64Url = (input) => {
9673
- try {
9674
- const binary = atob(input.replace(/-/g, "+").replace(/_/g, "/").replace(/\s/g, ""));
9675
- const bytes = new Uint8Array(binary.length);
9676
- for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
9677
- return bytes;
9678
- } catch (cause) {
9679
- throw CodedTypeError("The input to be decoded is not correctly encoded.", ERR_INVALID_ARG_VALUE, cause);
9680
- }
9681
- };
9682
- var URLParse = URL.parse ? (url, base) => URL.parse(url, base) : (url, base) => {
9683
- try {
9684
- return new URL(url, base);
9685
- } catch {
9686
- return null;
9687
- }
9688
- };
9689
- var tokenMatch = "[a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+";
9690
- var token68Match = "[a-zA-Z0-9\\-\\._\\~\\+\\/]+={0,2}";
9691
- var quotedParamMatcher = "(" + tokenMatch + ')\\s*=\\s*"((?:[^"\\\\]|\\\\[\\s\\S])*)"';
9692
- var paramMatcher = "(" + tokenMatch + ")\\s*=\\s*([a-zA-Z0-9!#$%&\\'\\*\\+\\-\\.\\^_`\\|~]+)";
9693
- var schemeRE = new RegExp("^[,\\s]*(" + tokenMatch + ")");
9694
- var quotedParamRE = new RegExp("^[,\\s]*" + quotedParamMatcher + "[,\\s]*(.*)");
9695
- var unquotedParamRE = new RegExp("^[,\\s]*" + paramMatcher + "[,\\s]*(.*)");
9696
- var token68ParamRE = new RegExp("^(" + token68Match + ")(?:$|[,\\s])(.*)");
9697
- var nopkce = Symbol();
9698
- var expectNoNonce = Symbol();
9699
- var skipAuthTimeCheck = Symbol();
9700
- var skipStateCheck = Symbol();
9701
- var expectNoState = Symbol();
9702
- var _expectedIssuer = Symbol();
9703
- var botChallengeKnownErrors = [KnownErrors.BotChallengeRequired, KnownErrors.BotChallengeFailed];
9704
9712
 
9705
9713
  // ../stack-shared/dist/esm/utils/promises.js
9706
9714
  var neverResolvePromise = pending(new Promise(() => {
@@ -17568,6 +17576,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/${titl
17568
17576
  const pill = /* @__PURE__ */ jsxs(
17569
17577
  "button",
17570
17578
  {
17579
+ type: "button",
17571
17580
  onClick: () => handleClick(option.id),
17572
17581
  disabled: loadingOptionId !== null,
17573
17582
  className: cn(
@@ -18663,6 +18672,11 @@ ${colorConfig.map(([key, itemConfig]) => {
18663
18672
  const compareInnerRadius = pie?.compareInnerRadius ?? 36;
18664
18673
  const compareOuterRadius = pie?.compareOuterRadius ?? 52;
18665
18674
  const containerClassName = pie?.className ?? DEFAULT_PIE_CLASSNAME;
18675
+ const showDateRange = pie?.showDateRange ?? true;
18676
+ const centerTextMaxWidth = Math.max(64, innerRadius * 2 - 28);
18677
+ const segmentTransitionStyle = {
18678
+ transition: "opacity 180ms ease-out"
18679
+ };
18666
18680
  const canonicalSeries = primarySegmentSeries.length > 0 ? primarySegmentSeries : compareSegmentSeries;
18667
18681
  const usePrimaryForCanonical = primarySegmentSeries.length > 0;
18668
18682
  const compareValueByKey = (0, import_react28.useMemo)(() => {
@@ -18728,14 +18742,31 @@ ${colorConfig.map(([key, itemConfig]) => {
18728
18742
  });
18729
18743
  return config;
18730
18744
  }, [canonicalSeries, segmentColors]);
18731
- const activeRow = hoverKey ? legendRows.find((r7) => r7.key === hoverKey) ?? null : null;
18745
+ const activeRow = hoverKey != null ? legendRows.find((r7) => r7.key === hoverKey) ?? null : null;
18746
+ const [centerDisplayKey, setCenterDisplayKey] = (0, import_react28.useState)(null);
18747
+ const [centerDisplayVisible, setCenterDisplayVisible] = (0, import_react28.useState)(true);
18748
+ const centerDisplayRow = centerDisplayKey != null ? legendRows.find((r7) => r7.key === centerDisplayKey) ?? null : null;
18749
+ (0, import_react28.useEffect)(() => {
18750
+ const nextKey = activeRow?.key ?? null;
18751
+ if (nextKey === centerDisplayKey) {
18752
+ return;
18753
+ }
18754
+ setCenterDisplayVisible(false);
18755
+ const timeoutId = window.setTimeout(() => {
18756
+ setCenterDisplayKey(nextKey);
18757
+ setCenterDisplayVisible(true);
18758
+ }, 120);
18759
+ return () => {
18760
+ window.clearTimeout(timeoutId);
18761
+ };
18762
+ }, [activeRow?.key, centerDisplayKey]);
18732
18763
  const activeDelta = activeRow ? formatDelta(activeRow.value, activeRow.prevValue) : formatDelta(aggregatedPrimaryTotal, aggregatedCompareTotal);
18733
18764
  const windowDays = visibleEnd - visibleStart + 1;
18734
18765
  const startLabel = fmtValue(fullData[visibleStart].ts, xFormatKind);
18735
18766
  const endLabel = fmtValue(fullData[visibleEnd].ts, xFormatKind);
18736
18767
  const outerData = legendRows.map((r7) => ({ name: cssIdent(r7.key), hoverKey: r7.key, value: r7.value, fill: r7.fill }));
18737
18768
  const innerData = legendRows.map((r7) => ({ name: cssIdent(r7.key), hoverKey: r7.key, value: r7.prevValue, fill: r7.fillCompare }));
18738
- const activeIdx = hoverKey ? legendRows.findIndex((r7) => r7.key === hoverKey) : -1;
18769
+ const activeIdx = hoverKey != null ? legendRows.findIndex((r7) => r7.key === hoverKey) : -1;
18739
18770
  return /* @__PURE__ */ jsxs(
18740
18771
  "div",
18741
18772
  {
@@ -18789,6 +18820,7 @@ ${colorConfig.map(([key, itemConfig]) => {
18789
18820
  {
18790
18821
  fill: `var(--color-${d.name})`,
18791
18822
  opacity: inactive ? 0.22 : 1,
18823
+ style: segmentTransitionStyle,
18792
18824
  onMouseEnter: () => setHoverKey(d.hoverKey),
18793
18825
  onMouseLeave: () => setHoverKey(null)
18794
18826
  },
@@ -18819,6 +18851,7 @@ ${colorConfig.map(([key, itemConfig]) => {
18819
18851
  {
18820
18852
  fill: `var(--color-compare-${d.name})`,
18821
18853
  opacity: inactive ? 0.22 : 0.95,
18854
+ style: segmentTransitionStyle,
18822
18855
  onMouseEnter: () => setHoverKey(d.hoverKey),
18823
18856
  onMouseLeave: () => setHoverKey(null)
18824
18857
  },
@@ -18830,13 +18863,22 @@ ${colorConfig.map(([key, itemConfig]) => {
18830
18863
  ]
18831
18864
  }
18832
18865
  ) }),
18833
- /* @__PURE__ */ jsxs("div", { className: "pointer-events-none absolute inset-0 flex flex-col items-center justify-center text-center", children: [
18834
- /* @__PURE__ */ jsx("span", { className: "block max-w-[68px] truncate font-mono text-[9px] uppercase tracking-wider text-muted-foreground", children: activeRow ? activeRow.label : strings.pieTotalCenter }),
18835
- /* @__PURE__ */ jsx("span", { className: "mt-0.5 block max-w-[72px] truncate font-mono text-xl font-semibold leading-none tabular-nums text-foreground", children: fmtValue(activeRow ? activeRow.value : canonicalTotal, yFormatKind) })
18836
- ] })
18866
+ /* @__PURE__ */ jsxs(
18867
+ "div",
18868
+ {
18869
+ className: cn(
18870
+ "pointer-events-none absolute inset-0 flex flex-col items-center justify-center text-center transition-opacity duration-200 ease-out",
18871
+ centerDisplayVisible ? "opacity-100" : "opacity-35"
18872
+ ),
18873
+ children: [
18874
+ /* @__PURE__ */ jsx("span", { className: "block truncate font-mono text-[9px] uppercase tracking-wider text-muted-foreground", style: { maxWidth: centerTextMaxWidth }, children: centerDisplayRow ? centerDisplayRow.label : strings.pieTotalCenter }),
18875
+ /* @__PURE__ */ jsx("span", { className: "mt-0.5 block truncate font-mono text-xl font-semibold leading-none tabular-nums text-foreground", style: { maxWidth: centerTextMaxWidth }, children: fmtValue(centerDisplayRow ? centerDisplayRow.value : canonicalTotal, yFormatKind) })
18876
+ ]
18877
+ }
18878
+ )
18837
18879
  ] }),
18838
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-center", children: [
18839
- /* @__PURE__ */ jsxs("span", { className: "font-mono text-[10px] uppercase tracking-wider text-muted-foreground/80", children: [
18880
+ (showDateRange || showCompare) && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-center", children: [
18881
+ showDateRange && /* @__PURE__ */ jsxs("span", { className: "font-mono text-[10px] uppercase tracking-wider text-muted-foreground/80", children: [
18840
18882
  startLabel,
18841
18883
  " \u2013 ",
18842
18884
  endLabel
@@ -18857,7 +18899,7 @@ ${colorConfig.map(([key, itemConfig]) => {
18857
18899
  onFocus: () => setHoverKey(r7.key),
18858
18900
  onBlur: () => setHoverKey(null),
18859
18901
  className: cn(
18860
- "flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left transition-[background-color,opacity] duration-150 hover:bg-foreground/[0.04] hover:transition-none focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/20",
18902
+ "flex w-full items-center gap-2.5 rounded-md px-2 py-1.5 text-left transition-[background-color,opacity] duration-200 ease-out hover:bg-foreground/[0.04] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-foreground/20",
18861
18903
  isActive && "bg-foreground/[0.05]",
18862
18904
  dimmed && "opacity-50"
18863
18905
  ),