@ghostlytools/cli 1.11.0 → 1.11.2

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 (104) hide show
  1. package/README.md +24 -16
  2. package/dist/assets/{api-CTqIcdu7.js → api-BM3PsXbB.js} +372 -123
  3. package/dist/assets/api-BM3PsXbB.js.map +1 -0
  4. package/dist/assets/{api-B-52sVYp.js → api-CtXgscmK.js} +2 -2
  5. package/dist/assets/{apiKit-CZq4Lq4f.js → apiKit-lCTQ0EBG.js} +17 -7
  6. package/dist/assets/apiKit-lCTQ0EBG.js.map +1 -0
  7. package/dist/assets/appFetch-BKHy5H8J.js +194 -0
  8. package/dist/assets/appFetch-BKHy5H8J.js.map +1 -0
  9. package/dist/assets/{apps-kRsY9S2S.js → apps-DO_gAZgm.js} +1 -1
  10. package/dist/assets/{apps-C_X0zgSG.js → apps-Do26w3c7.js} +44 -40
  11. package/dist/assets/apps-Do26w3c7.js.map +1 -0
  12. package/dist/assets/{arkade-_aaB7VbW.js → arkade-CZrLbz-M.js} +2 -2
  13. package/dist/assets/{arkade-_aaB7VbW.js.map → arkade-CZrLbz-M.js.map} +1 -1
  14. package/dist/assets/{backup-DBg388Ke.js → backup-D21x1f5P.js} +1 -1
  15. package/dist/assets/{backup-OTvrmk-w.js → backup-j47AzDvG.js} +84 -33
  16. package/dist/assets/backup-j47AzDvG.js.map +1 -0
  17. package/dist/assets/{bitcoind-CZchoh43.js → bitcoind-CdSmvy2y.js} +3 -3
  18. package/dist/assets/{bitcoind-CZchoh43.js.map → bitcoind-CdSmvy2y.js.map} +1 -1
  19. package/dist/assets/{bitcoindProvider-DGw3xBSa.js → bitcoindProvider-BvoRh0D5.js} +2 -2
  20. package/dist/assets/{bitcoindProvider-DGw3xBSa.js.map → bitcoindProvider-BvoRh0D5.js.map} +1 -1
  21. package/dist/assets/{buttons-DUu7hxxT.js → buttons-CiGlBVBT.js} +18 -7
  22. package/dist/assets/buttons-CiGlBVBT.js.map +1 -0
  23. package/dist/assets/buttons-D2l2bVCG.js +2 -0
  24. package/dist/assets/{childEnv-BVOQK9EA.js → childEnv-K_IzUqQx.js} +4 -3
  25. package/dist/assets/childEnv-K_IzUqQx.js.map +1 -0
  26. package/dist/assets/{client-DDpZP1R1.js → client-raIncVtF.js} +31 -3
  27. package/dist/assets/client-raIncVtF.js.map +1 -0
  28. package/dist/assets/{codec-DrryGcPT.js → codec-DcG2AeyE.js} +2 -2
  29. package/dist/assets/{codec-DrryGcPT.js.map → codec-DcG2AeyE.js.map} +1 -1
  30. package/dist/assets/endpoint-DarqblYE.js +5052 -0
  31. package/dist/assets/endpoint-DarqblYE.js.map +1 -0
  32. package/dist/assets/{envelope-Q_rMgoE9.js → envelope-Dud6lntA.js} +2 -2
  33. package/dist/assets/{envelope-Q_rMgoE9.js.map → envelope-Dud6lntA.js.map} +1 -1
  34. package/dist/assets/{fedimintSdk-CqTeMdF0.js → fedimintSdk-DRKRSw14.js} +6 -3
  35. package/dist/assets/fedimintSdk-DRKRSw14.js.map +1 -0
  36. package/dist/assets/{fixedHosts-BV5GDiTU.js → fixedHosts-CNX7QiUD.js} +3 -3
  37. package/dist/assets/{fixedHosts-BV5GDiTU.js.map → fixedHosts-CNX7QiUD.js.map} +1 -1
  38. package/dist/assets/{host-BlUzZgQL.js → host-8RskzQgB.js} +306 -84
  39. package/dist/assets/host-8RskzQgB.js.map +1 -0
  40. package/dist/assets/{hyperdhtRelay-BvI_uNZO.js → hyperdhtRelay-uAThbFub.js} +2 -2
  41. package/dist/assets/{hyperdhtRelay-BvI_uNZO.js.map → hyperdhtRelay-uAThbFub.js.map} +1 -1
  42. package/dist/assets/{irohWeb-CqPN8VPY.js → irohWeb-DGelfgDJ.js} +695 -40
  43. package/dist/assets/irohWeb-DGelfgDJ.js.map +1 -0
  44. package/dist/assets/jsonOut-POtMBS_V.js +16 -0
  45. package/dist/assets/jsonOut-POtMBS_V.js.map +1 -0
  46. package/dist/assets/{main-vQjlgEnt.js → main-BC33ooYg.js} +175 -107
  47. package/dist/assets/main-BC33ooYg.js.map +1 -0
  48. package/dist/assets/{mainline-p6HOW7sb.js → mainline-DYrjsS1t.js} +27 -8
  49. package/dist/assets/mainline-DYrjsS1t.js.map +1 -0
  50. package/dist/assets/{networkReason-DMffkiJ6.js → networkReason-n2oBs4by.js} +3 -3
  51. package/dist/assets/{networkReason-DMffkiJ6.js.map → networkReason-n2oBs4by.js.map} +1 -1
  52. package/dist/assets/{nwc-2vH18oNy.js → nwc-Do3VSlIS.js} +6 -5
  53. package/dist/assets/nwc-Do3VSlIS.js.map +1 -0
  54. package/dist/assets/{nwcProvider-DpeDy0bV.js → nwcProvider-Du5aWNIn.js} +6 -3
  55. package/dist/assets/{nwcProvider-DpeDy0bV.js.map → nwcProvider-Du5aWNIn.js.map} +1 -1
  56. package/dist/assets/{ownDid-iKz8u_fM.js → ownDid-CwwYu8s2.js} +3 -3
  57. package/dist/assets/{ownDid-iKz8u_fM.js.map → ownDid-CwwYu8s2.js.map} +1 -1
  58. package/dist/assets/{ownStatus-BlRKnM5F.js → ownStatus-D7dB4zJB.js} +4 -3
  59. package/dist/assets/{ownStatus-BlRKnM5F.js.map → ownStatus-D7dB4zJB.js.map} +1 -1
  60. package/dist/assets/{profiles-B5e0TyvS.js → profiles-NyF5FnYF.js} +82 -6
  61. package/dist/assets/profiles-NyF5FnYF.js.map +1 -0
  62. package/dist/assets/{registry-Cc_PQb3k.js → registry-C734VrO9.js} +1 -1
  63. package/dist/assets/{registry-CnFO2Pp5.js → registry-DKDInr0A.js} +75 -23
  64. package/dist/assets/registry-DKDInr0A.js.map +1 -0
  65. package/dist/assets/{resolve-DI8uAM_Y.js → resolve-3Tqh9AWQ.js} +4 -3
  66. package/dist/assets/resolve-3Tqh9AWQ.js.map +1 -0
  67. package/dist/assets/{server-DdtPxkqI.js → server-B6PQ6iae.js} +430 -868
  68. package/dist/assets/server-B6PQ6iae.js.map +1 -0
  69. package/dist/assets/{src-BnpEQqzk.js → src-ChJijTlM.js} +1139 -243
  70. package/dist/assets/src-ChJijTlM.js.map +1 -0
  71. package/dist/assets/{sshForges-cdIAraDw.js → sshForges-Brf0fslM.js} +2 -2
  72. package/dist/assets/{sshForges-cdIAraDw.js.map → sshForges-Brf0fslM.js.map} +1 -1
  73. package/dist/assets/{translate-kNopA04L.js → translate-xLme9Rdh.js} +10 -8
  74. package/dist/assets/translate-xLme9Rdh.js.map +1 -0
  75. package/dist/assets/{types-C4_KafL_.js → types-Clyb52K2.js} +2 -1
  76. package/dist/assets/types-Clyb52K2.js.map +1 -0
  77. package/dist/assets/{usdt-CDaLhEYh.js → usdt-CSU5KzTV.js} +3 -3
  78. package/dist/assets/{usdt-CDaLhEYh.js.map → usdt-CSU5KzTV.js.map} +1 -1
  79. package/dist/ghostly.mjs +1 -1
  80. package/npm-shrinkwrap.json +3592 -0
  81. package/package.json +5 -3
  82. package/dist/assets/api-CTqIcdu7.js.map +0 -1
  83. package/dist/assets/apiKit-CZq4Lq4f.js.map +0 -1
  84. package/dist/assets/apps-C_X0zgSG.js.map +0 -1
  85. package/dist/assets/backup-OTvrmk-w.js.map +0 -1
  86. package/dist/assets/buttons-4EKtQl-7.js +0 -2
  87. package/dist/assets/buttons-DUu7hxxT.js.map +0 -1
  88. package/dist/assets/childEnv-BVOQK9EA.js.map +0 -1
  89. package/dist/assets/client-DDpZP1R1.js.map +0 -1
  90. package/dist/assets/endpoint-DWHkXWVM.js +0 -419
  91. package/dist/assets/endpoint-DWHkXWVM.js.map +0 -1
  92. package/dist/assets/fedimintSdk-CqTeMdF0.js.map +0 -1
  93. package/dist/assets/host-BlUzZgQL.js.map +0 -1
  94. package/dist/assets/irohWeb-CqPN8VPY.js.map +0 -1
  95. package/dist/assets/main-vQjlgEnt.js.map +0 -1
  96. package/dist/assets/mainline-p6HOW7sb.js.map +0 -1
  97. package/dist/assets/nwc-2vH18oNy.js.map +0 -1
  98. package/dist/assets/profiles-B5e0TyvS.js.map +0 -1
  99. package/dist/assets/registry-CnFO2Pp5.js.map +0 -1
  100. package/dist/assets/resolve-DI8uAM_Y.js.map +0 -1
  101. package/dist/assets/server-DdtPxkqI.js.map +0 -1
  102. package/dist/assets/src-BnpEQqzk.js.map +0 -1
  103. package/dist/assets/translate-kNopA04L.js.map +0 -1
  104. package/dist/assets/types-C4_KafL_.js.map +0 -1
@@ -1,3 +1,4 @@
1
+ import b4a from "b4a";
1
2
  import { xsalsa20poly1305 } from "@noble/ciphers/salsa.js";
2
3
  import { ed25519, x25519 } from "@noble/curves/ed25519.js";
3
4
  import { sha256, sha512 } from "@noble/hashes/sha2.js";
@@ -6,7 +7,6 @@ import { base58, base64, base64urlnopad, bech32, bech32m, createBase58check } fr
6
7
  import { xchacha20poly1305 } from "@noble/ciphers/chacha.js";
7
8
  import { hmac } from "@noble/hashes/hmac.js";
8
9
  import { hexToBytes } from "@noble/hashes/utils.js";
9
- import b4a from "b4a";
10
10
  import { schnorr, secp256k1 } from "@noble/curves/secp256k1.js";
11
11
  import { p256, p384, p521 } from "@noble/curves/nist.js";
12
12
  import { gcm } from "@noble/ciphers/aes.js";
@@ -333,14 +333,24 @@ function tryDecrypt(encoded, key) {
333
333
  var publicKeys = /* @__PURE__ */ new Map();
334
334
  function publicKeyOf(seed) {
335
335
  const id = toBase64Url(sha256(seed));
336
- let key = publicKeys.get(id);
337
- if (key) publicKeys.delete(id);
338
- else {
339
- key = ed25519.getPublicKey(seed);
340
- if (publicKeys.size >= 1024) publicKeys.delete(publicKeys.keys().next().value);
336
+ const now = Date.now();
337
+ let entry = publicKeys.get(id);
338
+ if (entry) {
339
+ publicKeys.delete(id);
340
+ entry.at = now;
341
+ } else {
342
+ entry = {
343
+ key: ed25519.getPublicKey(seed),
344
+ at: now
345
+ };
346
+ for (const [oldest, { at }] of publicKeys) {
347
+ if (publicKeys.size < 1024) break;
348
+ if (publicKeys.size < 16384 && now - at < 6e5) break;
349
+ publicKeys.delete(oldest);
350
+ }
341
351
  }
342
- publicKeys.set(id, key);
343
- return key.slice();
352
+ publicKeys.set(id, entry);
353
+ return entry.key.slice();
344
354
  }
345
355
  function identityFromSeed(seed) {
346
356
  if (seed.length !== 32) throw new Error("Seed must be exactly 32 bytes");
@@ -1431,8 +1441,8 @@ var RelayTransport = class {
1431
1441
  spentAnswerAllowance = /* @__PURE__ */ new Map();
1432
1442
  /** Per contact, its departed reads past the limit in the last minute, every relay together (`DEPARTED_READS`). */
1433
1443
  departedOver = /* @__PURE__ */ new Map();
1434
- /** Per invite, its awaited reads past the limit in the last minute, every relay together (`AWAITED_READS`). */
1435
- awaitedOver = /* @__PURE__ */ new Map();
1444
+ /** The awaited reads past the limit in the last minute, every invite and every relay together (`AWAITED_READS`). */
1445
+ awaitedOver = [];
1436
1446
  /** When an awaited invite's read last asked: the departed reads leave it room for a minute (`AWAITED_READS`). */
1437
1447
  awaitedAt = -Infinity;
1438
1448
  /**
@@ -2314,7 +2324,7 @@ var RelayTransport = class {
2314
2324
  if (isGroupSignal(who)) this.spentGroupSignal.get(relay).push(now);
2315
2325
  const departedOver = isDepartedRead(who) && this.spent.get(relay).length >= this.limitOf(relay);
2316
2326
  if (departedOver) this.overAdd(this.departedOver, key, now);
2317
- if (isAwaitedRead(who) && this.spent.get(relay).length >= this.limitOf(relay)) this.overAdd(this.awaitedOver, key, now);
2327
+ if (isAwaitedRead(who) && this.spent.get(relay).length >= this.limitOf(relay)) this.awaitedOver = [...within(this.awaitedOver, now, 6e4), now];
2318
2328
  this.spent.get(relay).push(now);
2319
2329
  if (who.background) this.spentBackground.get(relay).push(now);
2320
2330
  if (who.background && who.write) this.spentBackgroundWrites.get(relay).push(now);
@@ -2358,7 +2368,8 @@ var RelayTransport = class {
2358
2368
  const over = (list, limit) => list.length >= limit ? list[list.length - limit] + 6e4 - now : 0;
2359
2369
  const limit = this.limitOf(relay);
2360
2370
  const departed = isDepartedRead(who) && key !== void 0 && recent.length >= limit && this.overReads(this.departedOver, key, now) < 6;
2361
- const awaited = isAwaitedRead(who) && key !== void 0 && recent.length >= limit && this.overReads(this.awaitedOver, key, now) < 4;
2371
+ if (isAwaitedRead(who)) this.awaitedOver = within(this.awaitedOver, now, 6e4);
2372
+ const awaited = isAwaitedRead(who) && key !== void 0 && recent.length >= limit && this.awaitedOver.length < 4;
2362
2373
  const share = isChatSignal(who) || departed || awaited ? SIGNALING_ALLOWANCE_SHARE : isGroupSignal(who) ? GROUP_SIGNALING_ALLOWANCE_SHARE : 0;
2363
2374
  let allowance = share ? Math.max(0, Math.floor(limit * share) - (who.write ? 0 : 1)) : 0;
2364
2375
  if (departed && now - this.awaitedAt < 6e4) allowance = Math.max(0, allowance - 2);
@@ -2542,7 +2553,7 @@ var RelayTransport = class {
2542
2553
  const since = this.heldBack.get(key)?.since;
2543
2554
  return !who.group && !who.write && !who.door && since !== void 0 && now - since >= READ_STARVED_MS;
2544
2555
  }
2545
- /** This key's departed or awaited reads past the limit in the last minute (`DEPARTED_READS`, `AWAITED_READS`). */
2556
+ /** This key's departed reads past the limit in the last minute (`DEPARTED_READS`). */
2546
2557
  overReads(over, key, now) {
2547
2558
  const reads = within(over.get(key) ?? [], now, 6e4);
2548
2559
  if (reads.length) over.set(key, reads);
@@ -4746,7 +4757,7 @@ function findAppForbiddenKey(value) {
4746
4757
  var MAX_CLIENTS = 16;
4747
4758
  var SEMVER$1 = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
4748
4759
  var HOST = /^>=(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))?$/;
4749
- var SEGMENT$1 = /^[A-Za-z0-9._-]+$/;
4760
+ var SEGMENT$2 = /^[A-Za-z0-9._-]+$/;
4750
4761
  var codePoints = (s) => [...s].length;
4751
4762
  /** Text of several lines: no control character but the line feed. */
4752
4763
  var isText$2 = (v, max) => typeof v === "string" && codePoints(v) <= max && !/[^\P{Cc}\n]/u.test(v);
@@ -4818,7 +4829,7 @@ function isAppLicense(value) {
4818
4829
  /** A path of a bundle: relative, `/`-separated, `[A-Za-z0-9._-]` per segment, no `.` or `..`, at most 128 bytes. */
4819
4830
  function isAppPath(value) {
4820
4831
  if (typeof value !== "string" || value.length < 1 || value.length > APP_BUNDLE_LIMITS.pathBytes) return false;
4821
- return value.split("/").every((s) => SEGMENT$1.test(s) && s !== "." && s !== "..");
4832
+ return value.split("/").every((s) => SEGMENT$2.test(s) && s !== "." && s !== "..");
4822
4833
  }
4823
4834
  var bad = (field, detail = `${field} is not valid`) => ({
4824
4835
  ok: false,
@@ -7357,6 +7368,12 @@ var LIMITS = {
7357
7368
  maxPathBytes: 8192,
7358
7369
  /** Requests a host serves at once for one peer. */
7359
7370
  maxConcurrentRequestsPerPeer: 32,
7371
+ /**
7372
+ * Request-body bytes a host holds for one peer at once, from a body's first chunk until its local fetch settles.
7373
+ * Past it a request is refused (`busy`). As much as a client's in-flight requests can carry, so only a peer that
7374
+ * ignores that limit reaches it.
7375
+ */
7376
+ maxHostBodyBytesPerPeer: 134217728,
7360
7377
  /** Requests a client keeps in flight; the rest wait in a queue. */
7361
7378
  maxClientInFlight: 16,
7362
7379
  /**
@@ -7373,6 +7390,11 @@ var LIMITS = {
7373
7390
  maxStoredIncomingBytesPerPeer: 524288e3,
7374
7391
  requestTimeoutMs: 6e4,
7375
7392
  bodyIdleTimeoutMs: 3e4,
7393
+ /**
7394
+ * What a request body must bring in each `bodyIdleTimeoutMs` (unless it ends) to count as moving: a peer that sends a
7395
+ * few bytes at a time is let go like one that stalls.
7396
+ */
7397
+ minRequestBodyBytesPerIdle: 16384,
7376
7398
  /** Stop writing to the channel above this many buffered bytes. */
7377
7399
  sendHighWaterMark: 1048576,
7378
7400
  sendLowWaterMark: 262144
@@ -7825,6 +7847,22 @@ function sanitizeResponseHeaders(headers, target) {
7825
7847
  }
7826
7848
  return out;
7827
7849
  }
7850
+ [
7851
+ "camera",
7852
+ "microphone",
7853
+ "display-capture",
7854
+ "geolocation",
7855
+ "midi",
7856
+ "usb",
7857
+ "serial",
7858
+ "hid",
7859
+ "clipboard-read",
7860
+ "idle-detection",
7861
+ "local-fonts",
7862
+ "window-management",
7863
+ "storage-access",
7864
+ "publickey-credentials-create"
7865
+ ].map((feature) => `${feature}=()`).join(", ");
7828
7866
  /**
7829
7867
  * Turns `http://localhost:3400/base/x` into `/x` so the client never learns or
7830
7868
  * follows the local address. Null when the location is not on the target origin
@@ -7872,6 +7910,8 @@ var HttpHost = class {
7872
7910
  * so a stream counts toward the limit until its fetch has settled.
7873
7911
  */
7874
7912
  live = /* @__PURE__ */ new Set();
7913
+ /** Body bytes of the streams in `live`: a peer cannot make the host hold more than `maxHostBodyBytesPerPeer`. */
7914
+ heldBodyBytes = 0;
7875
7915
  constructor(channel, getService, localFetch) {
7876
7916
  this.channel = channel;
7877
7917
  this.getService = getService;
@@ -7898,25 +7938,32 @@ var HttpHost = class {
7898
7938
  url,
7899
7939
  body: [],
7900
7940
  bodyBytes: 0,
7941
+ movedBytes: 0,
7901
7942
  abort: new AbortController(),
7902
7943
  started: false
7903
7944
  };
7904
7945
  this.streams.set(frame.id, stream);
7905
7946
  this.live.add(stream);
7906
- if (frame.b && !BODYLESS_METHODS.has(method)) this.armIdleTimer(stream);
7947
+ if (frame.b && !BODYLESS_METHODS.has(method)) this.watchPace(stream);
7907
7948
  else this.run(stream);
7908
7949
  }
7909
7950
  handleChunk(chunk) {
7910
7951
  const stream = this.streams.get(chunk.id);
7911
7952
  if (!stream || stream.started) return;
7912
- stream.bodyBytes += chunk.payload.length;
7913
- if (stream.bodyBytes > LIMITS.maxRequestBodyBytes) {
7953
+ const bytes = chunk.payload.length;
7954
+ if (stream.bodyBytes + bytes > LIMITS.maxRequestBodyBytes) {
7914
7955
  this.end(stream);
7915
7956
  return this.fail(chunk.id, 413, "request-too-large", "Request body too large.");
7916
7957
  }
7958
+ if (this.heldBodyBytes + bytes > LIMITS.maxHostBodyBytesPerPeer) {
7959
+ this.end(stream);
7960
+ return this.fail(chunk.id, 503, "busy", "Too many request bodies at once.");
7961
+ }
7962
+ stream.bodyBytes += bytes;
7963
+ this.heldBodyBytes += bytes;
7964
+ stream.movedBytes += bytes;
7917
7965
  if (chunk.payload.length > 0) stream.body.push(chunk.payload.slice());
7918
7966
  if (chunk.end) this.run(stream);
7919
- else this.armIdleTimer(stream);
7920
7967
  }
7921
7968
  handleReset(frame) {
7922
7969
  const stream = this.streams.get(frame.id);
@@ -7925,9 +7972,13 @@ var HttpHost = class {
7925
7972
  closeAll() {
7926
7973
  for (const stream of [...this.streams.values()]) this.end(stream);
7927
7974
  }
7928
- armIdleTimer(stream) {
7929
- clearTimeout(stream.idleTimer);
7930
- stream.idleTimer = setTimeout(() => {
7975
+ /** A body that brings less than `minRequestBodyBytesPerIdle` in a `bodyIdleTimeoutMs` is let go, even if it trickles. */
7976
+ watchPace(stream) {
7977
+ stream.paceTimer = setTimeout(() => {
7978
+ if (stream.movedBytes >= LIMITS.minRequestBodyBytesPerIdle) {
7979
+ stream.movedBytes = 0;
7980
+ return this.watchPace(stream);
7981
+ }
7931
7982
  this.end(stream);
7932
7983
  this.fail(stream.frame.id, 408, "request-timeout", "Request body timed out.");
7933
7984
  }, LIMITS.bodyIdleTimeoutMs);
@@ -7937,10 +7988,16 @@ var HttpHost = class {
7937
7988
  return this.streams.get(stream.frame.id) === stream;
7938
7989
  }
7939
7990
  end(stream) {
7940
- clearTimeout(stream.idleTimer);
7991
+ clearTimeout(stream.paceTimer);
7941
7992
  stream.abort.abort();
7942
7993
  if (this.isCurrent(stream)) this.streams.delete(stream.frame.id);
7943
- if (!stream.started) this.live.delete(stream);
7994
+ if (!stream.started) this.release(stream);
7995
+ }
7996
+ /** The stream no longer counts toward the limits: its body is dropped, or its local fetch has settled. */
7997
+ release(stream) {
7998
+ this.live.delete(stream);
7999
+ this.heldBodyBytes -= stream.bodyBytes;
8000
+ stream.bodyBytes = 0;
7944
8001
  }
7945
8002
  fail(id, status, code, message) {
7946
8003
  const body = utf8Encode(`${message}\n`);
@@ -7957,19 +8014,20 @@ var HttpHost = class {
7957
8014
  }
7958
8015
  async run(stream) {
7959
8016
  stream.started = true;
7960
- clearTimeout(stream.idleTimer);
8017
+ clearTimeout(stream.paceTimer);
7961
8018
  const { frame, service } = stream;
7962
8019
  const timeout = setTimeout(() => stream.abort.abort(), LIMITS.requestTimeoutMs);
7963
8020
  let headersSent = false;
8021
+ const body = stream.body.length > 0 ? concatBytes$1(...stream.body) : null;
8022
+ stream.body = [];
7964
8023
  try {
7965
8024
  const response = await this.localFetch({
7966
8025
  url: stream.url,
7967
8026
  method: frame.m,
7968
8027
  headers: sanitizeRequestHeaders(frame.h),
7969
- body: stream.body.length > 0 ? concatBytes$1(...stream.body) : null,
8028
+ body,
7970
8029
  signal: stream.abort.signal
7971
8030
  });
7972
- stream.body = [];
7973
8031
  clearTimeout(timeout);
7974
8032
  if (!this.isCurrent(stream)) return;
7975
8033
  if (response.finalUrl && response.finalUrl !== stream.url) {
@@ -8017,7 +8075,7 @@ var HttpHost = class {
8017
8075
  else if (timedOut && error?.name === "AbortError") this.fail(frame.id, 504, "timeout", "The local service did not answer in time.");
8018
8076
  else this.fail(frame.id, 502, "unreachable", "The local service is not reachable.");
8019
8077
  } finally {
8020
- this.live.delete(stream);
8078
+ this.release(stream);
8021
8079
  }
8022
8080
  }
8023
8081
  };
@@ -9013,7 +9071,7 @@ var LinkSession = class {
9013
9071
  receivedNew = true;
9014
9072
  if (fresh.length > 0) this.events.onMessages?.(fresh, batch);
9015
9073
  }
9016
- if (read && batch.packetTimestamp > this.peerPacketAt) this.peerPacketAt = batch.packetTimestamp;
9074
+ if (read && batch.packetTimestamp > this.peerPacketAt) this.peerPacketAt = Math.min(batch.packetTimestamp, Date.now() + PKARR_FUTURE_SKEW_MS);
9017
9075
  const seenAt = batch.packetTimestamp === wasSeen ? presenceSeenAt(this.presence) : Math.max(readBefore, Math.min(batch.packetTimestamp, Date.now()));
9018
9076
  const online = batch.services !== null && Date.now() - seenAt < 6e5;
9019
9077
  this.presence = {
@@ -13488,7 +13546,8 @@ var DhtDelivery = class DhtDelivery {
13488
13546
  * envelope was seen in the pinned mailbox, the invite's is not read any more.
13489
13547
  */
13490
13548
  async read(background, signal = false) {
13491
- const pinned = this.pinned(), options = signal ? { signal } : background ? { background } : void 0;
13549
+ const departed = !signal && !background && this.departedRead();
13550
+ const pinned = this.pinned(), options = signal ? { signal } : background ? { background } : departed ? { departed } : void 0;
13492
13551
  const before = this.state.peerPinned;
13493
13552
  const boxes = !pinned ? ["invite"] : before === "seen" ? ["pinned"] : before ? ["pinned", "invite"] : ["invite", "pinned"];
13494
13553
  let found = null;
@@ -13623,6 +13682,21 @@ var DhtDelivery = class DhtDelivery {
13623
13682
  return this.state.peerMode === "dht" && this.options.peerDhtPollMs && there ? Math.min(this.options.peerDhtPollMs, STREAM_POLL_MS) : STREAM_POLL_MS;
13624
13683
  }
13625
13684
  /**
13685
+ * The contact is on DHT only and this side is not: a live link waits on the contact's envelope saying it left, and
13686
+ * nothing else of the contact's shows before it (no offer is read, no dial taken, while its mailbox says DHT only). Its
13687
+ * reads that are not background ones (the chat open, a text awaiting its receipt) then say `departed`: a few may go over
13688
+ * the relays' minute (`DEPARTED_READS` in relay.ts, per mailbox, every relay together, 6 at the open chat's 10 s pace).
13689
+ * As plain reads, an extension that stayed on Automatic, its minute spent by what it did before, read nothing of its
13690
+ * contact for 40 s after the contact left DHT only, and the matrix's chat stayed "On DHT · retrying live" (E2E full,
13691
+ * 2026-11-07 and 11-08). No more reads than before: those it made anyway, the minute spent, go within the allowance.
13692
+ * Not while this side is leaving DHT only itself (`signalReads` left, `leavingRead`): its read at the switch stays a
13693
+ * plain one, the rest are signaling, so the few requests past a spent minute stay for the dialling side's read of the
13694
+ * answer. As a departed read, the switch's took one, and both sides leaving went live in 34 s, against 10.
13695
+ */
13696
+ departedRead() {
13697
+ return this.mode !== "dht" && this.state.peerMode === "dht" && this.signalReads === 0 && !!this.options.credentials.peerKey;
13698
+ }
13699
+ /**
13626
13700
  * This side is DHT only, and nothing waits on the contact's mailbox: the contact, pinned, is away (nothing new of its
13627
13701
  * own in `PRESENCE_WINDOW`; it puts a keep-alive every four minutes while there), no text of ours awaits its receipt,
13628
13702
  * and the chat is not on screen. Its mailbox is then read at the background pace, as background reads, not every 4 s:
@@ -14132,18 +14206,23 @@ var DNS_TYPE = {
14132
14206
  TXT: 16,
14133
14207
  AAAA: 28
14134
14208
  };
14209
+ /**
14210
+ * EDNS0 OPT record (RFC 6891) with one Client Subnet option of source prefix 0 (RFC 7871 §7.1.2): a resolver must
14211
+ * not add this device's subnet to its queries to the name's servers, as Google Public DNS otherwise does.
14212
+ */
14213
+ var NO_CLIENT_SUBNET = Uint8Array.of(0, 0, 41, 4, 208, 0, 0, 0, 0, 0, 8, 0, 8, 0, 4, 0, 1, 0, 0);
14135
14214
  /** A recursive query for one name and type. ID 0, as RFC 8484 recommends for caching;
14136
14215
  * the AD bit asks the resolver to report DNSSEC validation (RFC 6840 §5.7). */
14137
14216
  function encodeDnsQuery(name, type) {
14138
14217
  const labels = name.replace(/\.$/, "").split(".");
14139
- const parts = [Uint8Array.of(0, 0, 1, 32, 0, 1, 0, 0, 0, 0, 0, 0)];
14218
+ const parts = [Uint8Array.of(0, 0, 1, 32, 0, 1, 0, 0, 0, 0, 0, 1)];
14140
14219
  for (const label of labels) {
14141
14220
  const bytes = utf8Encode(label);
14142
14221
  if (!bytes.length || bytes.length > 63) throw new Error("Invalid DNS name");
14143
14222
  parts.push(Uint8Array.of(bytes.length), bytes);
14144
14223
  }
14145
14224
  const code = DNS_TYPE[type];
14146
- parts.push(Uint8Array.of(0, code >> 8, code & 255, 0, 1));
14225
+ parts.push(Uint8Array.of(0, code >> 8, code & 255, 0, 1), NO_CLIENT_SUBNET);
14147
14226
  return concatBytes$1(...parts);
14148
14227
  }
14149
14228
  function readName(data, start) {
@@ -16102,6 +16181,7 @@ var IdentityExchange = class {
16102
16181
  id,
16103
16182
  provider,
16104
16183
  subject,
16184
+ account: local.account ?? subject,
16105
16185
  status: "queued",
16106
16186
  at: this.now()
16107
16187
  };
@@ -16260,7 +16340,7 @@ var IdentityExchange = class {
16260
16340
  at: this.now(),
16261
16341
  error
16262
16342
  };
16263
- const replaced = (x) => ok && x.status === "accepted" && x.provider === s.provider && x.subject === s.subject;
16343
+ const replaced = (x) => ok && x.status === "accepted" && x.provider === s.provider && x.account !== void 0 && x.account === s.account;
16264
16344
  await this.options.storage.update((l) => l.shared.filter((x) => x.id !== s.id && replaced(x)).reduce((out, x) => this.log(out, {
16265
16345
  type: "stopped",
16266
16346
  side: "mine",
@@ -18079,7 +18159,12 @@ var APP_RANGE_LIMITS = {
18079
18159
  * The bytes a server takes asks for in one second, its apps together: one more is answered `busy`. Counted as they
18080
18160
  * are asked, so a cancelled one counts as the read it started. Twice the asking app's own budget (16 MiB a second).
18081
18161
  */
18082
- bytesPerSecond: 33554432
18162
+ bytesPerSecond: 33554432,
18163
+ /**
18164
+ * The least one ask counts in `bytesPerSecond`, however few bytes it asked or the file held from its offset: each is
18165
+ * a read on this device, so a contact gets at most 512 a second.
18166
+ */
18167
+ askFloorBytes: 65536
18083
18168
  };
18084
18169
  /**
18085
18170
  * What an `ar-err` says. `not-served`: no serve of that id (never given, or ended); `changed` and
@@ -18348,16 +18433,17 @@ var AppRanges = class {
18348
18433
  old.out = true;
18349
18434
  this.takenBytes -= old.bytes;
18350
18435
  }
18351
- if (this.takenBytes + frame.n > APP_RANGE_LIMITS.bytesPerSecond) {
18436
+ const bytes = Math.max(frame.n, APP_RANGE_LIMITS.askFloorBytes);
18437
+ if (this.takenBytes + bytes > APP_RANGE_LIMITS.bytesPerSecond) {
18352
18438
  this.send(appRangeErrorFrame(app, request, "busy"));
18353
18439
  return null;
18354
18440
  }
18355
18441
  const charge = {
18356
18442
  at,
18357
- bytes: frame.n
18443
+ bytes
18358
18444
  };
18359
18445
  this.taken.push(charge);
18360
- this.takenBytes += frame.n;
18446
+ this.takenBytes += bytes;
18361
18447
  const task = {
18362
18448
  app,
18363
18449
  request,
@@ -18379,7 +18465,7 @@ var AppRanges = class {
18379
18465
  /** Every byte of `task` was sent: `ar-end` goes with the file's size, unless the task was dropped meanwhile. */
18380
18466
  finish(task, size) {
18381
18467
  if (!this.take(task)) return;
18382
- const charge = task.charge, sent = Math.max(0, Math.min(task.length, size - task.offset));
18468
+ const charge = task.charge, sent = Math.max(APP_RANGE_LIMITS.askFloorBytes, Math.min(task.length, size - task.offset));
18383
18469
  if (charge && !charge.out && charge.bytes > sent) {
18384
18470
  this.takenBytes -= charge.bytes - sent;
18385
18471
  charge.bytes = sent;
@@ -19761,6 +19847,12 @@ var ChatFiles = class {
19761
19847
  moving = /* @__PURE__ */ new Set();
19762
19848
  /** Files that stopped sending for the chat's window alone: they go on once another's bytes are confirmed. */
19763
19849
  held = /* @__PURE__ */ new Set();
19850
+ /**
19851
+ * Files this side cancelled while no session carried the cancel (`pf-abort`), said on the next one. The session also
19852
+ * goes for a moment when a move swaps it (its capabilities are agreed again): unsaid, the receiver showed the file
19853
+ * moving, its bytes kept, until its idle nudge asked 30 s later.
19854
+ */
19855
+ unsaid = /* @__PURE__ */ new Set();
19764
19856
  attached = false;
19765
19857
  peerRoomValue = null;
19766
19858
  /** What the chat's files may have in flight, sized by the path. */
@@ -19859,6 +19951,10 @@ var ChatFiles = class {
19859
19951
  this.refill = 0;
19860
19952
  this.host.uplink?.join(this);
19861
19953
  this.sayRoom();
19954
+ for (const id of this.unsaid) if (this.send({
19955
+ t: "pf-abort",
19956
+ id
19957
+ })) this.unsaid.delete(id);
19862
19958
  this.sweep();
19863
19959
  for (const entry of this.entries.values()) {
19864
19960
  if (transferEnded(entry.record)) continue;
@@ -20864,10 +20960,10 @@ var ChatFiles = class {
20864
20960
  const entry = this.entry(direction, id);
20865
20961
  if (transferEnded(entry.record)) return;
20866
20962
  if (direction === "out") {
20867
- this.send({
20963
+ if (!this.send({
20868
20964
  t: "pf-abort",
20869
20965
  id
20870
- });
20966
+ })) this.unsaid.add(id);
20871
20967
  this.end(entry, "cancelled", "You cancelled it");
20872
20968
  } else {
20873
20969
  this.discardStored(entry);
@@ -22418,6 +22514,22 @@ var QUIET_FRAMES = /* @__PURE__ */ new Set([
22418
22514
  CONTACT_ASKER_FRAME
22419
22515
  ]);
22420
22516
  /**
22517
+ * What a session a move replaced still reads while its channel retires (`SWITCH_RETIRE_MS`): the contact's texts,
22518
+ * reactions, pins and edits, and its receipts of this side's, which it sends on that session until its own side moves.
22519
+ * Its files/3 frames too (a cancel, a pause, a file's check): `ChatFiles` answers them on the session now.
22520
+ */
22521
+ var RETIRING_FRAMES = /* @__PURE__ */ new Set([
22522
+ "paired-message",
22523
+ "paired-received",
22524
+ REACTION_FRAME,
22525
+ REACTED_FRAME,
22526
+ PIN_FRAME,
22527
+ PINNED_FRAME,
22528
+ EDIT_FRAME,
22529
+ EDITED_FRAME,
22530
+ ...FILE_FRAMES
22531
+ ]);
22532
+ /**
22421
22533
  * A ping with nothing at all back this long after it went: the contact may have crashed and started again, with its new
22422
22534
  * offer waiting on the relays, while this side still holds the old session and reads them at a live chat's pace (30 s).
22423
22535
  * They are read now. Nothing more: the session is let go only by `LIVENESS_MISSED_PINGS`, or by the contact's offer
@@ -22473,6 +22585,17 @@ var APP_AHEAD_OF_FILES = 16384;
22473
22585
  */
22474
22586
  var APP_IN_FLIGHT = 65536;
22475
22587
  /**
22588
+ * Texts a contact's link takes: a burst per short window (a reconnect flushes every queued text at once) and a total
22589
+ * per hour, both well above what a person or a bot sends. The rest go unconfirmed and come again (the sender's outbox
22590
+ * resends with backoff), so a catch-up only slows.
22591
+ */
22592
+ var MESSAGE_RECEIVE_LIMITS = {
22593
+ burst: 200,
22594
+ burstWindowMs: 1e4,
22595
+ hourly: 1800,
22596
+ hourWindowMs: 36e5
22597
+ };
22598
+ /**
22476
22599
  * A `paired-message` frame. The preview (`pv`) is left out when the frame would pass `MAX_PAIRED_MESSAGE_FRAME`
22477
22600
  * with it: the text matters, the card does not. A reply (`r`, WISP 401 § Replies) is a few hundred bytes at most
22478
22601
  * and always goes, and so does a forwarded message's hop count (`fw`, WISP 401 § Forwards) and a status card (`sc`,
@@ -22690,6 +22813,8 @@ var GhostLink = class {
22690
22813
  pinsReceived = new ReactionWindow(PIN_LIMITS.receive, PIN_LIMITS.windowMs);
22691
22814
  /** Edit frames the contact may send per window; the rest go unconfirmed and come again. */
22692
22815
  editsReceived = new RateWindow(30, EDIT_RATE_WINDOW_MS);
22816
+ /** Text frames the contact may send per window (`MESSAGE_RECEIVE_LIMITS`); the rest go unconfirmed and come again. */
22817
+ messagesReceived = [new RateWindow(MESSAGE_RECEIVE_LIMITS.burst, MESSAGE_RECEIVE_LIMITS.burstWindowMs), new RateWindow(MESSAGE_RECEIVE_LIMITS.hourly, MESSAGE_RECEIVE_LIMITS.hourWindowMs)];
22693
22818
  /** Call signals the contact may send per window; the rest are dropped. */
22694
22819
  callsReceived = new RateWindow(150, CALL_RATE_WINDOW_MS);
22695
22820
  /** WebRTC signals the contact may send on the session (`paired-rtc`) per window; the rest are dropped. */
@@ -23718,6 +23843,18 @@ var GhostLink = class {
23718
23843
  });
23719
23844
  }
23720
23845
  /**
23846
+ * Where the receipt of a frame read on `channel` goes: that session while it carries the chat, the one now when a move
23847
+ * replaced it (or moved while the frame was shown), or nowhere.
23848
+ */
23849
+ answerOn(channel) {
23850
+ const live = this.channel;
23851
+ return live && (live === channel || this.retiring.has(channel)) && this.isDataLinkOpen ? live : null;
23852
+ }
23853
+ /** Counts one text the contact sent; false (and not counted) when either of `messagesReceived` is full. */
23854
+ takeMessage() {
23855
+ return this.messagesReceived.every((window) => window.wait() === 0) && this.messagesReceived.every((window) => window.take());
23856
+ }
23857
+ /**
23721
23858
  * The WebRTC session a switch moved off is still retiring (`SWITCH_RETIRE_MS`): its data link is open, and a new offer
23722
23859
  * cannot go until it closes. Resolves once it has (at once when none is).
23723
23860
  */
@@ -26613,6 +26750,12 @@ var GhostLink = class {
26613
26750
  if (this.channel === channel && (!this.unproven(channel) && !this.pinnedSince(channel, paired) || paired.state.status === "ready")) this.emitPairingState();
26614
26751
  },
26615
26752
  onFailure: () => {
26753
+ const retiring = this.channel !== channel ? this.retiring.get(channel) : void 0;
26754
+ if (retiring) {
26755
+ clearTimeout(retiring.timer);
26756
+ retiring.close();
26757
+ return;
26758
+ }
26616
26759
  if (paired.state.keyMismatch) this.options.events?.onPeerKeyRefused?.();
26617
26760
  if (this.unproven(channel) || this.pinnedSince(channel, paired) || paired.authTimedOut || paired.overloaded) {
26618
26761
  if (paired.state.keyMismatch) this.dht?.foreignKeySeen("stream");
@@ -26660,11 +26803,12 @@ var GhostLink = class {
26660
26803
  this.paired = paired;
26661
26804
  this.activeBinding = binding;
26662
26805
  this.channelSince = Date.now();
26663
- oldPaired?.stop();
26664
26806
  const oldRtc = oldBinding ? null : this.dataLink.connection;
26665
26807
  if (oldChannel) this.retire(oldChannel, () => {
26808
+ oldPaired?.stop();
26666
26809
  if (oldRtc && this.activeBinding && this.dataLink.connection === oldRtc) this.dataLink.close();
26667
26810
  }, !oldBinding);
26811
+ else oldPaired?.stop();
26668
26812
  if (migration.plan && binding && oldBinding && WEBRTC_ATTEMPT.has(this.dataLink.state)) this.dataLink.close();
26669
26813
  this.session.setDataLinkOpen(true);
26670
26814
  if (migration.plan) switched = {
@@ -26743,10 +26887,13 @@ var GhostLink = class {
26743
26887
  }
26744
26888
  },
26745
26889
  onApplication: async (data) => {
26746
- if (this.channel !== channel) return;
26747
- this.unansweredPings = 0;
26748
- this.heardFromPeer();
26749
- this.framesHeard++;
26890
+ const retired = this.channel !== channel;
26891
+ if (retired && !this.retiring.has(channel)) return;
26892
+ if (!retired) {
26893
+ this.unansweredPings = 0;
26894
+ this.heardFromPeer();
26895
+ this.framesHeard++;
26896
+ } else if (typeof data !== "string") return;
26750
26897
  if (typeof data !== "string") {
26751
26898
  if (data[0] === 5) {
26752
26899
  const range = this.supportsAppRanges && this.supportsBinaryFiles ? decodeAppRangeData(data) : null;
@@ -26769,6 +26916,7 @@ var GhostLink = class {
26769
26916
  } catch {
26770
26917
  return;
26771
26918
  }
26919
+ if (retired && !RETIRING_FRAMES.has(String(frame?.t))) return;
26772
26920
  if (frame && typeof frame === "object" && !QUIET_FRAMES.has(String(frame.t))) this.activityAt = Date.now();
26773
26921
  if (frame?.t === "paired-ping") {
26774
26922
  try {
@@ -26924,8 +27072,9 @@ var GhostLink = class {
26924
27072
  if (!this.supportsReactions || !this.reactionsReceived.take()) return;
26925
27073
  const reaction = parseReactionFrame(frame);
26926
27074
  if (!reaction) return;
26927
- if (await this.options.events?.onReaction?.(reaction) && this.channel === channel && this.isDataLinkOpen) try {
26928
- channel.send(reactedFrame(reaction.n));
27075
+ const reacted = await this.options.events?.onReaction?.(reaction), live = this.answerOn(channel);
27076
+ if (reacted && live) try {
27077
+ live.send(reactedFrame(reaction.n));
26929
27078
  } catch {}
26930
27079
  return;
26931
27080
  }
@@ -26938,8 +27087,9 @@ var GhostLink = class {
26938
27087
  if (!this.supportsPins || !this.pinsReceived.take()) return;
26939
27088
  const pin = parsePinFrame(frame);
26940
27089
  if (!pin) return;
26941
- if (await this.options.events?.onPin?.(pin) && this.channel === channel && this.isDataLinkOpen) try {
26942
- channel.send(pinnedFrame(pin.n));
27090
+ const pinned = await this.options.events?.onPin?.(pin), live = this.answerOn(channel);
27091
+ if (pinned && live) try {
27092
+ live.send(pinnedFrame(pin.n));
26943
27093
  } catch {}
26944
27094
  return;
26945
27095
  }
@@ -26952,7 +27102,8 @@ var GhostLink = class {
26952
27102
  if (!this.supportsEdits || !this.editsReceived.take()) return;
26953
27103
  const edit = parseEditFrame(frame);
26954
27104
  if (!edit) return;
26955
- if (await this.options.events?.onMessageEdit?.(edit) && this.channel === channel && this.isDataLinkOpen) channel.send(editedFrame(edit.id, edit.e));
27105
+ const edited = await this.options.events?.onMessageEdit?.(edit), live = this.answerOn(channel);
27106
+ if (edited && live) live.send(editedFrame(edit.id, edit.e));
26956
27107
  return;
26957
27108
  }
26958
27109
  if (frame?.t === "paired-edited") {
@@ -27048,6 +27199,7 @@ var GhostLink = class {
27048
27199
  return;
27049
27200
  }
27050
27201
  if (!frame || typeof frame.id !== "string" || !/^[A-Za-z0-9_-]{22}$/.test(frame.id)) return;
27202
+ if (frame.t === "paired-message" && !this.takeMessage()) return;
27051
27203
  if (frame.t === "paired-message" && typeof frame.m === "string" && utf8Encode(frame.m).length <= LIMITS.maxChatMessageBytes && typeof frame.ts === "number" && Number.isSafeInteger(frame.ts) && frame.ts > 0) {
27052
27204
  const preview = frame.pv === void 0 ? void 0 : parseLinkPreview(frame.pv, frame.m);
27053
27205
  this.typingReceiver.clear();
@@ -27064,7 +27216,8 @@ var GhostLink = class {
27064
27216
  ...forwarded && { forwarded },
27065
27217
  ...card && { card }
27066
27218
  });
27067
- if (this.channel === channel && this.isDataLinkOpen) channel.send(JSON.stringify({
27219
+ const live = this.answerOn(channel);
27220
+ if (live) live.send(JSON.stringify({
27068
27221
  t: "paired-received",
27069
27222
  id: frame.id
27070
27223
  }));
@@ -27541,6 +27694,7 @@ var GhostLink = class {
27541
27694
  break;
27542
27695
  }
27543
27696
  case "m":
27697
+ if (!this.takeMessage()) break;
27544
27698
  this.options.events?.onMessage?.({
27545
27699
  text: frame.m,
27546
27700
  timestamp: frame.ts,
@@ -27660,9 +27814,9 @@ var HEIF_BRANDS = /* @__PURE__ */ new Set([
27660
27814
  ]);
27661
27815
  var u16be = (b, at) => b[at] << 8 | b[at + 1];
27662
27816
  var u32be$1 = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
27663
- var u32le = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
27664
- var text$1 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
27665
- var starts = (b, at, prefix) => at + prefix.length <= b.length && text$1(b, at, prefix.length) === prefix;
27817
+ var u32le$1 = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
27818
+ var text$2 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
27819
+ var starts = (b, at, prefix) => at + prefix.length <= b.length && text$2(b, at, prefix.length) === prefix;
27666
27820
  /** A picture this strips, by its first bytes. */
27667
27821
  function kindOf(b) {
27668
27822
  if (b.length >= 3 && b[0] === 255 && b[1] === 216 && b[2] === 255) return "jpeg";
@@ -27672,11 +27826,11 @@ function kindOf(b) {
27672
27826
  if (starts(b, 0, "II*\0") || starts(b, 0, "MM\0*") || starts(b, 0, "II+\0") || starts(b, 0, "MM\0+")) return "tiff";
27673
27827
  if (b.length >= 16 && starts(b, 4, "ftyp")) {
27674
27828
  const end = Math.min(b.length, u32be$1(b, 0));
27675
- for (let at = 8; at + 4 <= end; at += 4) if (at !== 12 && HEIF_BRANDS.has(text$1(b, at, 4))) return "heif";
27829
+ for (let at = 8; at + 4 <= end; at += 4) if (at !== 12 && HEIF_BRANDS.has(text$2(b, at, 4))) return "heif";
27676
27830
  }
27677
27831
  }
27678
27832
  /** Refuses the picture where its bytes are not what this expects. */
27679
- function check$1(ok) {
27833
+ function check$2(ok) {
27680
27834
  if (!ok) throw new Error(NO_PICTURE_METADATA);
27681
27835
  }
27682
27836
  /** SOFn markers: every frame type but DHT (C4), JPG (C8) and DAC (CC). */
@@ -27710,12 +27864,12 @@ function stripJpeg(b) {
27710
27864
  const parts = [b.subarray(0, 2)];
27711
27865
  let at = 2, framed = false, scanned = false, exif = false;
27712
27866
  for (;;) {
27713
- check$1(at < b.length && b[at] === 255);
27867
+ check$2(at < b.length && b[at] === 255);
27714
27868
  while (at < b.length && b[at] === 255) at++;
27715
- check$1(at < b.length);
27869
+ check$2(at < b.length);
27716
27870
  const marker = b[at++];
27717
27871
  if (marker === 217) {
27718
- check$1(framed && scanned);
27872
+ check$2(framed && scanned);
27719
27873
  parts.push(Uint8Array.of(255, 217));
27720
27874
  return parts;
27721
27875
  }
@@ -27723,9 +27877,9 @@ function stripJpeg(b) {
27723
27877
  parts.push(Uint8Array.of(255, marker));
27724
27878
  continue;
27725
27879
  }
27726
- check$1(marker !== 0 && marker !== 216 && at + 2 <= b.length);
27880
+ check$2(marker !== 0 && marker !== 216 && at + 2 <= b.length);
27727
27881
  const length = u16be(b, at);
27728
- check$1(length >= 2 && at + length <= b.length);
27882
+ check$2(length >= 2 && at + length <= b.length);
27729
27883
  if (marker === 224 && length > 16 && starts(b, at + 2, "JFIF\0")) parts.push(Uint8Array.of(255, 224, 0, 16, ...b.subarray(at + 2, at + 14), 0, 0));
27730
27884
  else if (jpegKeeps(marker, b, at + 2)) {
27731
27885
  parts.push(Uint8Array.of(255, marker), b.subarray(at, at + length));
@@ -27737,15 +27891,15 @@ function stripJpeg(b) {
27737
27891
  }
27738
27892
  at += length;
27739
27893
  if (marker !== 218) continue;
27740
- check$1(framed);
27894
+ check$2(framed);
27741
27895
  scanned = true;
27742
27896
  let end = at;
27743
27897
  for (;;) {
27744
27898
  end = b.indexOf(255, end);
27745
- check$1(end >= 0);
27899
+ check$2(end >= 0);
27746
27900
  let next = end + 1;
27747
27901
  while (next < b.length && b[next] === 255) next++;
27748
- check$1(next < b.length);
27902
+ check$2(next < b.length);
27749
27903
  if (b[next] !== 0 && !(b[next] >= 208 && b[next] <= 215)) break;
27750
27904
  end = next + 1;
27751
27905
  }
@@ -27794,11 +27948,11 @@ function stripPng(b) {
27794
27948
  const parts = [b.subarray(0, 8)];
27795
27949
  let at = 8, exif = false, imaged = false;
27796
27950
  for (;;) {
27797
- check$1(at + 12 <= b.length);
27798
- const length = u32be$1(b, at), type = text$1(b, at + 4, 4);
27799
- check$1(at + 12 + length <= b.length && (at > 8 || type === "IHDR"));
27951
+ check$2(at + 12 <= b.length);
27952
+ const length = u32be$1(b, at), type = text$2(b, at + 4, 4);
27953
+ check$2(at + 12 + length <= b.length && (at > 8 || type === "IHDR"));
27800
27954
  const critical = (b[at + 4] & 32) === 0;
27801
- check$1(!critical || PNG_CRITICAL.has(type));
27955
+ check$2(!critical || PNG_CRITICAL.has(type));
27802
27956
  if (critical || PNG_DRAWS.has(type)) parts.push(b.subarray(at, at + 12 + length));
27803
27957
  else if (type === "eXIf" && !exif && !imaged) {
27804
27958
  exif = true;
@@ -27820,20 +27974,20 @@ var WEBP_KEEPS = /* @__PURE__ */ new Set([
27820
27974
  "ICCP"
27821
27975
  ]);
27822
27976
  function stripWebp(b) {
27823
- check$1(b.length >= 20);
27824
- const riffEnd = 8 + u32le(b, 4);
27825
- check$1(riffEnd <= b.length && riffEnd % 2 === 0);
27977
+ check$2(b.length >= 20);
27978
+ const riffEnd = 8 + u32le$1(b, 4);
27979
+ check$2(riffEnd <= b.length && riffEnd % 2 === 0);
27826
27980
  const parts = [];
27827
27981
  let at = 12, size = 4, drawn = false, exif = false, vp8x;
27828
27982
  while (at < riffEnd) {
27829
- check$1(at + 8 <= riffEnd);
27830
- const type = text$1(b, at, 4), length = u32le(b, at + 4), end = at + 8 + length + (length & 1);
27831
- check$1(end <= riffEnd && (at > 12 || type === "VP8 " || type === "VP8L" || type === "VP8X"));
27983
+ check$2(at + 8 <= riffEnd);
27984
+ const type = text$2(b, at, 4), length = u32le$1(b, at + 4), end = at + 8 + length + (length & 1);
27985
+ check$2(end <= riffEnd && (at > 12 || type === "VP8 " || type === "VP8L" || type === "VP8X"));
27832
27986
  let chunk;
27833
27987
  if (WEBP_KEEPS.has(type)) {
27834
27988
  chunk = b.subarray(at, end);
27835
27989
  if (type === "VP8X") {
27836
- check$1(length >= 10);
27990
+ check$2(length >= 10);
27837
27991
  chunk = vp8x = chunk.slice();
27838
27992
  chunk[8] = chunk[8] & -13;
27839
27993
  }
@@ -27861,7 +28015,7 @@ function stripWebp(b) {
27861
28015
  }
27862
28016
  at = end;
27863
28017
  }
27864
- check$1(drawn);
28018
+ check$2(drawn);
27865
28019
  const header = /* @__PURE__ */ new Uint8Array(12);
27866
28020
  header.set(b.subarray(0, 12));
27867
28021
  new DataView(header.buffer).setUint32(4, size, true);
@@ -27944,16 +28098,16 @@ var HEIF_ABOUT = /* @__PURE__ */ new Set([
27944
28098
  function boxes$1(b, start, end) {
27945
28099
  const found = [];
27946
28100
  for (let at = start; at < end;) {
27947
- check$1(at + 8 <= end);
28101
+ check$2(at + 8 <= end);
27948
28102
  let size = u32be$1(b, at), body = at + 8;
27949
- const type = text$1(b, at + 4, 4);
28103
+ const type = text$2(b, at + 4, 4);
27950
28104
  if (size === 1) {
27951
- check$1(at + 16 <= end);
28105
+ check$2(at + 16 <= end);
27952
28106
  size = u32be$1(b, at + 8) * 2 ** 32 + u32be$1(b, at + 12);
27953
28107
  body = at + 16;
27954
28108
  } else if (size === 0) size = end - at;
27955
28109
  if (type === "uuid") body += 16;
27956
- check$1(size >= body - at && at + size <= end);
28110
+ check$2(size >= body - at && at + size <= end);
27957
28111
  found.push({
27958
28112
  type,
27959
28113
  start: at,
@@ -27966,58 +28120,58 @@ function boxes$1(b, start, end) {
27966
28120
  }
27967
28121
  function stripHeif(b) {
27968
28122
  const top = boxes$1(b, 0, b.length);
27969
- check$1(top[0]?.type === "ftyp" && top.every((box) => HEIF_TOP.has(box.type)));
28123
+ check$2(top[0]?.type === "ftyp" && top.every((box) => HEIF_TOP.has(box.type)));
27970
28124
  const metas = top.filter((box) => box.type === "meta");
27971
- check$1(metas.length === 1);
28125
+ check$2(metas.length === 1);
27972
28126
  const meta = metas[0];
27973
28127
  const children = boxes$1(b, meta.body + 4, meta.end);
27974
- check$1(children.every((box) => HEIF_META.has(box.type)));
28128
+ check$2(children.every((box) => HEIF_META.has(box.type)));
27975
28129
  const one = (type) => {
27976
28130
  const of = children.filter((box) => box.type === type);
27977
- check$1(of.length <= 1);
28131
+ check$2(of.length <= 1);
27978
28132
  return of[0];
27979
28133
  };
27980
28134
  const iinf = one("iinf"), iloc = one("iloc"), idat = one("idat");
27981
- check$1(!!iinf && !!iloc);
28135
+ check$2(!!iinf && !!iloc);
27982
28136
  const metadata = /* @__PURE__ */ new Set();
27983
28137
  const infeVersion = b[iinf.body];
27984
28138
  const entries = boxes$1(b, iinf.body + 4 + (infeVersion === 0 ? 2 : 4), iinf.end);
27985
28139
  for (const infe of entries) {
27986
- check$1(infe.type === "infe" && infe.body + 4 <= infe.end);
28140
+ check$2(infe.type === "infe" && infe.body + 4 <= infe.end);
27987
28141
  const version = b[infe.body];
27988
- check$1(version === 2 || version === 3);
28142
+ check$2(version === 2 || version === 3);
27989
28143
  let at = infe.body + 4;
27990
28144
  const id = version === 2 ? u16be(b, at) : u32be$1(b, at);
27991
28145
  at += version === 2 ? 2 : 4;
27992
- check$1(at + 6 <= infe.end);
27993
- if (HEIF_METADATA_ITEMS.has(text$1(b, at + 2, 4))) metadata.add(id);
28146
+ check$2(at + 6 <= infe.end);
28147
+ if (HEIF_METADATA_ITEMS.has(text$2(b, at + 2, 4))) metadata.add(id);
27994
28148
  }
27995
28149
  const iprp = one("iprp"), properties = [];
27996
28150
  if (iprp) {
27997
28151
  const held = boxes$1(b, iprp.body, iprp.end);
27998
28152
  const ipco = held.filter((box) => box.type === "ipco");
27999
- check$1(ipco.length === 1 && held.every((box) => box.type === "ipco" || box.type === "ipma"));
28153
+ check$2(ipco.length === 1 && held.every((box) => box.type === "ipco" || box.type === "ipma"));
28000
28154
  properties.push(...boxes$1(b, ipco[0].body, ipco[0].end));
28001
- check$1(properties.every((box) => HEIF_DRAWS.has(box.type) || HEIF_ABOUT.has(box.type)));
28155
+ check$2(properties.every((box) => HEIF_DRAWS.has(box.type) || HEIF_ABOUT.has(box.type)));
28002
28156
  }
28003
28157
  /** `free` and `skip` boxes, at the top and in `meta`, and the properties about the picture: their bodies go as zeros. */
28004
28158
  const space = [...[...top, ...children].filter((box) => box.type === "free" || box.type === "skip"), ...properties.filter((box) => HEIF_ABOUT.has(box.type))];
28005
28159
  const out = b.slice();
28006
28160
  const version = b[iloc.body];
28007
- check$1(version <= 2);
28161
+ check$2(version <= 2);
28008
28162
  let at = iloc.body + 4;
28009
28163
  /** The next field of `size` bytes (0, 2, 4 or 8), big-endian. */
28010
28164
  const read = (size) => {
28011
- check$1(at + size <= iloc.end);
28165
+ check$2(at + size <= iloc.end);
28012
28166
  const value = size === 0 ? 0 : size === 2 ? u16be(b, at) : size === 4 ? u32be$1(b, at) : size === 8 ? u32be$1(b, at) * 2 ** 32 + u32be$1(b, at + 4) : NaN;
28013
- check$1(Number.isSafeInteger(value));
28167
+ check$2(Number.isSafeInteger(value));
28014
28168
  at += size;
28015
28169
  return value;
28016
28170
  };
28017
28171
  const read2 = () => read(2);
28018
- check$1(at + 2 <= iloc.end);
28172
+ check$2(at + 2 <= iloc.end);
28019
28173
  const offsetSize = b[at] >> 4, lengthSize = b[at] & 15, baseSize = b[at + 1] >> 4, indexSize = version > 0 ? b[at + 1] & 15 : 0;
28020
- check$1([
28174
+ check$2([
28021
28175
  offsetSize,
28022
28176
  lengthSize,
28023
28177
  baseSize,
@@ -28036,12 +28190,12 @@ function stripHeif(b) {
28036
28190
  const offset = read(offsetSize), length = read(lengthSize);
28037
28191
  if (!metadata.has(id)) {
28038
28192
  const start = base + offset, end = length ? start + length : b.length;
28039
- check$1(reference !== 0 || method !== 0 || !space.some((box) => start < box.end && end > box.body));
28193
+ check$2(reference !== 0 || method !== 0 || !space.some((box) => start < box.end && end > box.body));
28040
28194
  continue;
28041
28195
  }
28042
- check$1(reference === 0 && length > 0 && (method === 0 || method === 1 && !!idat));
28196
+ check$2(reference === 0 && length > 0 && (method === 0 || method === 1 && !!idat));
28043
28197
  const start = (method === 1 ? idat.body : 0) + base + offset, limit = method === 1 ? idat.end : b.length;
28044
- check$1(start + length <= limit);
28198
+ check$2(start + length <= limit);
28045
28199
  out.fill(0, start, start + length);
28046
28200
  }
28047
28201
  }
@@ -28054,44 +28208,44 @@ var GIF_APPS_KEPT = /* @__PURE__ */ new Set([
28054
28208
  "ICCRGBG1012"
28055
28209
  ]);
28056
28210
  function stripGif(b) {
28057
- check$1(b.length >= 13);
28211
+ check$2(b.length >= 13);
28058
28212
  /** A colour table's bytes, from the flags that say it is there and its size. */
28059
28213
  const table = (flags) => flags & 128 ? 3 << (flags & 7) + 1 : 0;
28060
28214
  /** The end of the data sub-blocks at `at`, past their empty block. */
28061
28215
  const blocks = (at) => {
28062
28216
  for (;;) {
28063
- check$1(at < b.length);
28217
+ check$2(at < b.length);
28064
28218
  const length = b[at];
28065
28219
  at += 1 + length;
28066
28220
  if (!length) return at;
28067
28221
  }
28068
28222
  };
28069
28223
  let at = 13 + table(b[10]), framed = false;
28070
- check$1(at <= b.length);
28224
+ check$2(at <= b.length);
28071
28225
  const parts = [b.subarray(0, at)];
28072
28226
  for (;;) {
28073
- check$1(at < b.length);
28227
+ check$2(at < b.length);
28074
28228
  const introducer = b[at];
28075
28229
  if (introducer === 59) {
28076
- check$1(framed);
28230
+ check$2(framed);
28077
28231
  parts.push(Uint8Array.of(59));
28078
28232
  return parts;
28079
28233
  }
28080
28234
  if (introducer === 44) {
28081
- check$1(at + 10 <= b.length);
28235
+ check$2(at + 10 <= b.length);
28082
28236
  const data = at + 10 + table(b[at + 9]);
28083
- check$1(data < b.length);
28237
+ check$2(data < b.length);
28084
28238
  const end = blocks(data + 1);
28085
28239
  parts.push(b.subarray(at, end));
28086
28240
  framed = true;
28087
28241
  at = end;
28088
28242
  continue;
28089
28243
  }
28090
- check$1(introducer === 33 && at + 2 < b.length);
28244
+ check$2(introducer === 33 && at + 2 < b.length);
28091
28245
  const label = b[at + 1], end = blocks(at + 2);
28092
- const app = label === 255 && b[at + 2] === 11 && GIF_APPS_KEPT.has(text$1(b, at + 3, 11));
28246
+ const app = label === 255 && b[at + 2] === 11 && GIF_APPS_KEPT.has(text$2(b, at + 3, 11));
28093
28247
  if (label === 249 || label === 1 || app) parts.push(b.subarray(at, end));
28094
- else check$1(label === 254 || label === 255);
28248
+ else check$2(label === 254 || label === 255);
28095
28249
  at = end;
28096
28250
  }
28097
28251
  }
@@ -28210,18 +28364,18 @@ var TIFF_TYPE_BYTES = [
28210
28364
  function stripTiff(b) {
28211
28365
  const little = b[0] === 73;
28212
28366
  const u16 = (at) => {
28213
- check$1(at + 2 <= b.length);
28367
+ check$2(at + 2 <= b.length);
28214
28368
  return little ? b[at] | b[at + 1] << 8 : u16be(b, at);
28215
28369
  };
28216
28370
  const u32 = (at) => {
28217
- check$1(at + 4 <= b.length);
28218
- return little ? u32le(b, at) : u32be$1(b, at);
28371
+ check$2(at + 4 <= b.length);
28372
+ return little ? u32le$1(b, at) : u32be$1(b, at);
28219
28373
  };
28220
- check$1(b.length >= 8 && u16(2) === 42);
28374
+ check$2(b.length >= 8 && u16(2) === 42);
28221
28375
  const out = b.slice(), seen = /* @__PURE__ */ new Set();
28222
28376
  /** An IFD's entries: tag, type, the value's first byte (in the entry or where it points) and its bytes. */
28223
28377
  const entries = (ifd) => {
28224
- check$1(ifd >= 8 && !seen.has(ifd) && seen.size < 1024);
28378
+ check$2(ifd >= 8 && !seen.has(ifd) && seen.size < 1024);
28225
28379
  seen.add(ifd);
28226
28380
  const count = u16(ifd), next = ifd + 2 + count * 12;
28227
28381
  u32(next);
@@ -28229,10 +28383,10 @@ function stripTiff(b) {
28229
28383
  next,
28230
28384
  list: Array.from({ length: count }, (_, i) => {
28231
28385
  const at = ifd + 2 + i * 12, tag = u16(at), type = u16(at + 2);
28232
- check$1(type >= 1 && type < TIFF_TYPE_BYTES.length);
28386
+ check$2(type >= 1 && type < TIFF_TYPE_BYTES.length);
28233
28387
  const bytes = TIFF_TYPE_BYTES[type] * u32(at + 4);
28234
28388
  const value = bytes <= 4 ? at + 8 : u32(at + 8);
28235
- check$1(Number.isSafeInteger(bytes) && value + bytes <= b.length);
28389
+ check$2(Number.isSafeInteger(bytes) && value + bytes <= b.length);
28236
28390
  return {
28237
28391
  at,
28238
28392
  tag,
@@ -28247,7 +28401,7 @@ function stripTiff(b) {
28247
28401
  const empty = (ifd) => {
28248
28402
  const { next, list } = entries(ifd);
28249
28403
  for (const entry of list) {
28250
- check$1(entry.tag !== 37500);
28404
+ check$2(entry.tag !== 37500);
28251
28405
  if (TIFF_METADATA_IFDS.has(entry.tag)) empty(u32(entry.value));
28252
28406
  out.fill(0, entry.value, entry.value + entry.bytes);
28253
28407
  }
@@ -28257,16 +28411,16 @@ function stripTiff(b) {
28257
28411
  const { next, list } = entries(ifd);
28258
28412
  let kept = 0;
28259
28413
  for (const { at, tag, value, bytes } of list) {
28260
- if (tag === 259) check$1(TIFF_COMPRESSION.has(u16(value)));
28414
+ if (tag === 259) check$2(TIFF_COMPRESSION.has(u16(value)));
28261
28415
  if (TIFF_METADATA_IFDS.has(tag)) {
28262
28416
  empty(u32(value));
28263
28417
  continue;
28264
28418
  }
28265
28419
  if (TIFF_METADATA.has(tag)) out.fill(0, value, value + bytes);
28266
- else check$1(TIFF_DRAWS.has(tag));
28420
+ else check$2(TIFF_DRAWS.has(tag));
28267
28421
  out.copyWithin(ifd + 2 + kept++ * 12, at, at + 12);
28268
28422
  }
28269
- check$1(kept > 0);
28423
+ check$2(kept > 0);
28270
28424
  const end = ifd + 2 + kept * 12;
28271
28425
  out.set(little ? [kept & 255, kept >> 8] : [kept >> 8, kept & 255], ifd);
28272
28426
  out.set(b.subarray(next, next + 4), end);
@@ -28332,7 +28486,8 @@ async function withoutPictureMetadata(source, mime) {
28332
28486
  *
28333
28487
  * Fail-closed: a file that is an MP4 or QuickTime video, by its bytes or by its type, and whose metadata cannot be
28334
28488
  * removed (truncated, malformed, a part of its movie this does not know) is refused with `NO_VIDEO_METADATA`, never sent as it was.
28335
- * A picture (HEIF is pictureMetadata.ts's), a file without a video track (an M4A) and any other file go as they are.
28489
+ * A picture (HEIF is pictureMetadata.ts's) and any other file go as they are; so does a file without a video track (an
28490
+ * M4A) here: audioMetadata.ts strips it.
28336
28491
  */
28337
28492
  var VIDEO_METADATA_LIMITS = {
28338
28493
  /** The largest `moov` or `moof` read whole, and the most bytes of a metadata track's chunk: past this the video is refused. */
@@ -28468,25 +28623,25 @@ var VISUAL = /* @__PURE__ */ new Set([
28468
28623
  "pict"
28469
28624
  ]);
28470
28625
  /** Zeros put in a Blob a slice at a time: a Blob's Blob parts are not copied, so a zeroed range of any size holds no more. */
28471
- var ZEROS = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
28626
+ var ZEROS$1 = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
28472
28627
  var u32be = (b, at) => (b[at] << 24 >>> 0) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
28473
- var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
28628
+ var text$1 = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
28474
28629
  /** Refuses the video where its bytes are not what this expects. */
28475
- function check(ok) {
28630
+ function check$1(ok) {
28476
28631
  if (!ok) throw new Error(NO_VIDEO_METADATA);
28477
28632
  }
28478
28633
  /** A box's header at `at` of `b` (`base` its offset in the file), up to `end` (a size of 0 runs to it). */
28479
28634
  function header(b, at, end, base = 0) {
28480
- check(at + 8 <= b.length);
28635
+ check$1(at + 8 <= b.length);
28481
28636
  let size = u32be(b, at), body = at + 8;
28482
- const type = text(b, at + 4, 4);
28637
+ const type = text$1(b, at + 4, 4);
28483
28638
  if (size === 1) {
28484
- check(at + 16 <= b.length);
28639
+ check$1(at + 16 <= b.length);
28485
28640
  size = u32be(b, at + 8) * 2 ** 32 + u32be(b, at + 12);
28486
28641
  body = at + 16;
28487
28642
  } else if (size === 0) size = end - (base + at);
28488
28643
  if (type === "uuid") body += 16;
28489
- check(Number.isSafeInteger(size) && size >= body - at && base + at + size <= end);
28644
+ check$1(Number.isSafeInteger(size) && size >= body - at && base + at + size <= end);
28490
28645
  return {
28491
28646
  type,
28492
28647
  start: base + at,
@@ -28497,7 +28652,7 @@ function header(b, at, end, base = 0) {
28497
28652
  function boxes(b, start, end) {
28498
28653
  const found = [];
28499
28654
  for (let at = start; at < end;) {
28500
- check(at + 8 <= end);
28655
+ check$1(at + 8 <= end);
28501
28656
  const box = header(b.subarray(0, end), at, end);
28502
28657
  found.push(box);
28503
28658
  at = box.end;
@@ -28531,32 +28686,32 @@ function emptyWithin(b, start, end) {
28531
28686
  */
28532
28687
  function zeroCompressorNames(b, stbl) {
28533
28688
  const stsd = child(b, stbl, "stsd");
28534
- check(!!stsd && stsd.body + 8 <= stsd.end);
28689
+ check$1(!!stsd && stsd.body + 8 <= stsd.end);
28535
28690
  for (const entry of boxes(b, stsd.body + 8, stsd.end)) {
28536
- check(entry.body + 74 <= entry.end);
28691
+ check$1(entry.body + 74 <= entry.end);
28537
28692
  b.fill(0, entry.body + 42, entry.body + 74);
28538
28693
  }
28539
28694
  }
28540
28695
  /** A `mvhd`, `tkhd` or `mdhd` with its creation and modification times zeroed: 32 bits each in version 0, 64 in 1. */
28541
28696
  function zeroTimes(b, box) {
28542
28697
  const version = b[box.body], bytes = version === 1 ? 16 : 8;
28543
- check(version <= 1 && box.body + 4 + bytes <= box.end);
28698
+ check$1(version <= 1 && box.body + 4 + bytes <= box.end);
28544
28699
  b.fill(0, box.body + 4, box.body + 4 + bytes);
28545
28700
  }
28546
28701
  var child = (b, parent, type) => {
28547
28702
  if (!parent) return void 0;
28548
28703
  const of = boxes(b, parent.body, parent.end).filter((box) => box.type === type);
28549
- check(of.length <= 1);
28704
+ check$1(of.length <= 1);
28550
28705
  return of[0];
28551
28706
  };
28552
28707
  /** A sample table's chunks, from its `stco` or `co64`: how many, and where each starts in the file. */
28553
28708
  function chunkOffsets(b, stbl) {
28554
28709
  const stco = child(b, stbl, "stco"), co64 = child(b, stbl, "co64");
28555
- check(!!stco !== !!co64);
28710
+ check$1(!!stco !== !!co64);
28556
28711
  const offsets = stco ?? co64;
28557
- check(offsets.body + 8 <= offsets.end);
28712
+ check$1(offsets.body + 8 <= offsets.end);
28558
28713
  const chunks = u32be(b, offsets.body + 4);
28559
- check(offsets.body + 8 + chunks * (co64 ? 8 : 4) <= offsets.end);
28714
+ check$1(offsets.body + 8 + chunks * (co64 ? 8 : 4) <= offsets.end);
28560
28715
  const offsetOf = (i) => co64 ? u32be(b, co64.body + 8 + i * 8) * 2 ** 32 + u32be(b, co64.body + 12 + i * 8) : u32be(b, stco.body + 8 + i * 4);
28561
28716
  return {
28562
28717
  chunks,
@@ -28566,8 +28721,8 @@ function chunkOffsets(b, stbl) {
28566
28721
  /** The byte ranges of a track's samples in the file, one per chunk, from its sample table. */
28567
28722
  function sampleRanges(b, stbl) {
28568
28723
  const stsz = child(b, stbl, "stsz"), stz2 = child(b, stbl, "stz2"), stsc = child(b, stbl, "stsc");
28569
- check(!!stsc && !!stsz !== !!stz2);
28570
- const need = (box, at, bytes) => check(at + bytes <= box.end);
28724
+ check$1(!!stsc && !!stsz !== !!stz2);
28725
+ const need = (box, at, bytes) => check$1(at + bytes <= box.end);
28571
28726
  const sizeTable = stsz ?? stz2;
28572
28727
  need(sizeTable, sizeTable.body, 12);
28573
28728
  const count = u32be(b, sizeTable.body + 8);
@@ -28580,7 +28735,7 @@ function sampleRanges(b, stbl) {
28580
28735
  sizeOf = (i) => u32be(b, stsz.body + 12 + i * 4);
28581
28736
  } else {
28582
28737
  const field = b[stz2.body + 7];
28583
- check(field === 4 || field === 8 || field === 16);
28738
+ check$1(field === 4 || field === 8 || field === 16);
28584
28739
  need(stz2, stz2.body + 12, Math.ceil(count * field / 8));
28585
28740
  const at = stz2.body + 12;
28586
28741
  sizeOf = field === 16 ? (i) => b[at + i * 2] << 8 | b[at + i * 2 + 1] : field === 8 ? (i) => b[at + i] : (i) => i & 1 ? b[at + (i >> 1)] & 15 : b[at + (i >> 1)] >> 4;
@@ -28594,18 +28749,18 @@ function sampleRanges(b, stbl) {
28594
28749
  for (let run = 0; run < runs; run++) {
28595
28750
  const first = u32be(b, stsc.body + 8 + run * 12), perChunk = u32be(b, stsc.body + 12 + run * 12);
28596
28751
  const last = run + 1 < runs ? u32be(b, stsc.body + 8 + (run + 1) * 12) : chunks + 1;
28597
- check(first >= 1 && last > first && last <= chunks + 1);
28752
+ check$1(first >= 1 && last > first && last <= chunks + 1);
28598
28753
  for (let chunk = first; chunk < last; chunk++) {
28599
28754
  const start = offsetOf(chunk - 1);
28600
- check(sample + perChunk <= count);
28755
+ check$1(sample + perChunk <= count);
28601
28756
  let length = uniform * perChunk;
28602
28757
  if (!uniform) for (let i = 0; i < perChunk; i++) length += sizeOf(sample + i);
28603
28758
  sample += perChunk;
28604
- check(Number.isSafeInteger(start) && length <= VIDEO_METADATA_LIMITS.maxBoxBytes);
28759
+ check$1(Number.isSafeInteger(start) && length <= VIDEO_METADATA_LIMITS.maxBoxBytes);
28605
28760
  if (length) ranges.push([start, start + length]);
28606
28761
  }
28607
28762
  }
28608
- check(sample === count);
28763
+ check$1(sample === count);
28609
28764
  return ranges;
28610
28765
  }
28611
28766
  /** Each track's default sample size in fragments, from `moov`'s `mvex/trex` boxes, by track ID. */
@@ -28614,7 +28769,7 @@ function defaultSampleSizes(moov) {
28614
28769
  const mvex = child(moov, header(moov, 0, moov.length), "mvex");
28615
28770
  for (const trex of mvex ? boxes(moov, mvex.body, mvex.end) : []) {
28616
28771
  if (trex.type !== "trex") continue;
28617
- check(trex.body + 24 <= trex.end);
28772
+ check$1(trex.body + 24 <= trex.end);
28618
28773
  sizes.set(u32be(moov, trex.body + 4), u32be(moov, trex.body + 16));
28619
28774
  }
28620
28775
  return sizes;
@@ -28632,11 +28787,11 @@ function fragmentRanges(b, at, sizes) {
28632
28787
  for (const traf of boxes(b, header(b, 0, b.length).body, b.length)) {
28633
28788
  if (traf.type !== "traf") continue;
28634
28789
  const tfhd = child(b, traf, "tfhd");
28635
- check(!!tfhd && tfhd.body + 8 <= tfhd.end);
28790
+ check$1(!!tfhd && tfhd.body + 8 <= tfhd.end);
28636
28791
  const flags = u32be(b, tfhd.body) & 16777215;
28637
28792
  let field = tfhd.body + 8, base = flags & 131072 ? at : previous;
28638
28793
  if (flags & 1) {
28639
- check(field + 8 <= tfhd.end);
28794
+ check$1(field + 8 <= tfhd.end);
28640
28795
  base = u32be(b, field) * 2 ** 32 + u32be(b, field + 4);
28641
28796
  field += 8;
28642
28797
  }
@@ -28645,17 +28800,17 @@ function fragmentRanges(b, at, sizes) {
28645
28800
  const track = u32be(b, tfhd.body + 4);
28646
28801
  let size = sizes.get(track);
28647
28802
  if (flags & 16) {
28648
- check(field + 4 <= tfhd.end);
28803
+ check$1(field + 4 <= tfhd.end);
28649
28804
  size = u32be(b, field);
28650
28805
  }
28651
28806
  let next = base;
28652
28807
  for (const trun of boxes(b, traf.body, traf.end)) {
28653
28808
  if (trun.type !== "trun") continue;
28654
- check(trun.body + 8 <= trun.end);
28809
+ check$1(trun.body + 8 <= trun.end);
28655
28810
  const runFlags = u32be(b, trun.body) & 16777215, count = u32be(b, trun.body + 4);
28656
28811
  let field = trun.body + 8;
28657
28812
  if (runFlags & 1) {
28658
- check(field + 4 <= trun.end);
28813
+ check$1(field + 4 <= trun.end);
28659
28814
  next = base + (u32be(b, field) | 0);
28660
28815
  field += 4;
28661
28816
  }
@@ -28666,16 +28821,16 @@ function fragmentRanges(b, at, sizes) {
28666
28821
  1024,
28667
28822
  2048
28668
28823
  ].filter((flag) => runFlags & flag).length * 4;
28669
- check(field + count * stride <= trun.end);
28824
+ check$1(field + count * stride <= trun.end);
28670
28825
  let length = 0;
28671
28826
  if (runFlags & 512) {
28672
28827
  const sizeAt = field + (runFlags & 256 ? 4 : 0);
28673
28828
  for (let i = 0; i < count; i++) length += u32be(b, sizeAt + i * stride);
28674
28829
  } else if (count) {
28675
- check(size !== void 0);
28830
+ check$1(size !== void 0);
28676
28831
  length = count * size;
28677
28832
  }
28678
- check(Number.isSafeInteger(next) && Number.isSafeInteger(next + length));
28833
+ check$1(Number.isSafeInteger(next) && Number.isSafeInteger(next + length));
28679
28834
  if (length) ranges.push([
28680
28835
  next,
28681
28836
  next + length,
@@ -28707,7 +28862,7 @@ function stripMoov(b) {
28707
28862
  empty(b, box);
28708
28863
  continue;
28709
28864
  }
28710
- check(MOOV_KEEPS.has(box.type));
28865
+ check$1(MOOV_KEEPS.has(box.type));
28711
28866
  if (SPACE.has(box.type)) b.fill(0, box.body, box.end);
28712
28867
  if (box.type === "mvhd") zeroTimes(b, box);
28713
28868
  if (box.type === "mvex") {
@@ -28721,39 +28876,39 @@ function stripMoov(b) {
28721
28876
  empty(b, part);
28722
28877
  continue;
28723
28878
  }
28724
- check(TRAK_KEEPS.has(part.type));
28879
+ check$1(TRAK_KEEPS.has(part.type));
28725
28880
  if (part.type === "tkhd") {
28726
- check(!tkhd);
28881
+ check$1(!tkhd);
28727
28882
  tkhd = part;
28728
28883
  zeroTimes(b, part);
28729
28884
  }
28730
28885
  if (part.type === "mdia") {
28731
- check(!mdia);
28886
+ check$1(!mdia);
28732
28887
  mdia = part;
28733
28888
  }
28734
28889
  }
28735
- check(!!mdia);
28890
+ check$1(!!mdia);
28736
28891
  const hdlr = child(b, mdia, "hdlr"), minf = child(b, mdia, "minf"), mdhd = child(b, mdia, "mdhd");
28737
- check(!!hdlr && !!minf && hdlr.body + 12 <= hdlr.end);
28892
+ check$1(!!hdlr && !!minf && hdlr.body + 12 <= hdlr.end);
28738
28893
  if (mdhd) zeroTimes(b, mdhd);
28739
- const handler = text(b, hdlr.body + 8, 4);
28894
+ const handler = text$1(b, hdlr.body + 8, 4);
28740
28895
  const stbl = child(b, minf, "stbl");
28741
- check(!!stbl);
28896
+ check$1(!!stbl);
28742
28897
  tables.push(stbl);
28743
28898
  if (handler === "meta") {
28744
- check(selfContained(b, minf));
28899
+ check$1(selfContained(b, minf));
28745
28900
  metadata = true;
28746
28901
  for (const range of sampleRanges(b, stbl)) zeroed.push(range);
28747
28902
  } else if (handler === "tmcd" && selfContained(b, minf)) {
28748
28903
  metadata = true;
28749
28904
  for (const range of sampleRanges(b, stbl)) zeroed.push(range);
28750
28905
  } else if (CAPTIONS.has(handler)) {
28751
- check(selfContained(b, minf) && !!tkhd);
28906
+ check$1(selfContained(b, minf) && !!tkhd);
28752
28907
  const id = tkhd.body + 4 + (b[tkhd.body] === 1 ? 16 : 8);
28753
- check(id + 4 <= tkhd.end);
28908
+ check$1(id + 4 <= tkhd.end);
28754
28909
  captions.add(u32be(b, id));
28755
28910
  for (const range of sampleRanges(b, stbl)) zeroed.push(range);
28756
- } else check(HANDLERS.has(handler));
28911
+ } else check$1(HANDLERS.has(handler));
28757
28912
  if (handler === "vide") video = true;
28758
28913
  if (VISUAL.has(handler)) zeroCompressorNames(b, stbl);
28759
28914
  emptyWithin(b, box.body, box.end);
@@ -28811,9 +28966,9 @@ async function headerAt(source, at) {
28811
28966
  }
28812
28967
  /** A box read whole, within the limit. */
28813
28968
  async function whole(source, box) {
28814
- check(box.end - box.start <= VIDEO_METADATA_LIMITS.maxBoxBytes);
28969
+ check$1(box.end - box.start <= VIDEO_METADATA_LIMITS.maxBoxBytes);
28815
28970
  const bytes = await source.read(box.start, box.end - box.start);
28816
- check(bytes.length === box.end - box.start);
28971
+ check$1(bytes.length === box.end - box.start);
28817
28972
  return bytes;
28818
28973
  }
28819
28974
  /**
@@ -28822,7 +28977,7 @@ async function whole(source, box) {
28822
28977
  * pictureMetadata.ts's.
28823
28978
  */
28824
28979
  function containerOf(head, mime) {
28825
- const first = head.length >= 8 ? text(head, 4, 4) : "";
28980
+ const first = head.length >= 8 ? text$1(head, 4, 4) : "";
28826
28981
  if (isStrippedPicture(head, mime)) return void 0;
28827
28982
  if (FIRST_BOXES.has(first)) return "movie";
28828
28983
  return TOP_KEEPS.has(first) || TOP_EMPTIED.has(first) ? "boxes" : void 0;
@@ -28843,7 +28998,7 @@ async function withoutVideoMetadata(source, mime) {
28843
28998
  for (const patch of patches) {
28844
28999
  if (patch.start > at) parts.push(source.slice(at, patch.start));
28845
29000
  if (patch.bytes) parts.push(patch.bytes);
28846
- else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.size) parts.push(ZEROS.slice(0, Math.min(left, ZEROS.size)));
29001
+ else for (let left = patch.end - patch.start; left > 0; left -= ZEROS$1.size) parts.push(ZEROS$1.slice(0, Math.min(left, ZEROS$1.size)));
28847
29002
  at = patch.end;
28848
29003
  }
28849
29004
  if (at < source.size) parts.push(source.slice(at));
@@ -28852,9 +29007,9 @@ async function withoutVideoMetadata(source, mime) {
28852
29007
  /**
28853
29008
  * What `withoutVideoMetadata` changes in a video read from `source` (one not held in a Blob: a file kept in storage):
28854
29009
  * the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as it is.
28855
- * Throws `NO_VIDEO_METADATA` as it does.
29010
+ * Throws `NO_VIDEO_METADATA` as it does. With `audio`, a movie without a video track (an M4A) is stripped too.
28856
29011
  */
28857
- async function videoMetadataPatches(file, mime) {
29012
+ async function videoMetadataPatches(file, mime, audio = false) {
28858
29013
  const source = readingAhead(file);
28859
29014
  const head = await source.read(0, VIDEO_METADATA_LIMITS.headBytes);
28860
29015
  const typed = STRIPPED_TYPES.has(mime.split(";")[0].trim().toLowerCase());
@@ -28870,7 +29025,7 @@ async function videoMetadataPatches(file, mime) {
28870
29025
  const dropped = [];
28871
29026
  let trailer = false;
28872
29027
  for (let at = 0; at < source.size;) {
28873
- check(top.length < VIDEO_METADATA_LIMITS.maxBoxes);
29028
+ check$1(top.length < VIDEO_METADATA_LIMITS.maxBoxes);
28874
29029
  const box = await headerAt(source, at);
28875
29030
  if (!box || top.length && box.type === "\0\0\0\0") {
28876
29031
  patches.push({
@@ -28888,13 +29043,13 @@ async function videoMetadataPatches(file, mime) {
28888
29043
  }
28889
29044
  const moovs = top.filter((box) => box.type === "moov");
28890
29045
  if (!moovs.length && container === "boxes" && !typed) {
28891
- check(!trailer && top.every((box) => TOP_KEEPS.has(box.type) || TOP_EMPTIED.has(box.type)));
29046
+ check$1(!trailer && top.every((box) => TOP_KEEPS.has(box.type) || TOP_EMPTIED.has(box.type)));
28892
29047
  return;
28893
29048
  }
28894
- check(moovs.length === 1);
29049
+ check$1(moovs.length === 1);
28895
29050
  const moov = await whole(source, moovs[0]);
28896
29051
  const { video, fragmented, metadata, zeroed, tables, captions } = stripMoov(moov);
28897
- if (!video && !typed) return void 0;
29052
+ if (!video && !typed && !audio) return void 0;
28898
29053
  patches.push({
28899
29054
  start: moovs[0].start,
28900
29055
  end: moovs[0].end,
@@ -28904,15 +29059,15 @@ async function videoMetadataPatches(file, mime) {
28904
29059
  const { chunks, offsetOf } = chunkOffsets(moov, stbl);
28905
29060
  for (let i = 0; i < chunks; i++) {
28906
29061
  const offset = offsetOf(i);
28907
- check(!meets(dropped, offset, offset + 1));
29062
+ check$1(!meets(dropped, offset, offset + 1));
28908
29063
  }
28909
29064
  }
28910
- check(!fragmented || !metadata);
29065
+ check$1(!fragmented || !metadata);
28911
29066
  const sizes = (dropped.length || captions.size) && fragmented ? defaultSampleSizes(moov) : void 0;
28912
29067
  for (const box of top) if (box.type === "moof") {
28913
29068
  const moof = await whole(source, box);
28914
29069
  if (dropped.length || captions.size) for (const [start, end, track] of fragmentRanges(moof, box.start, sizes ?? /* @__PURE__ */ new Map())) {
28915
- check(!meets(dropped, start, end));
29070
+ check$1(!meets(dropped, start, end));
28916
29071
  if (captions.has(track)) zeroed.push([start, end]);
28917
29072
  }
28918
29073
  emptyWithin(moof, box.body - box.start, moof.length);
@@ -28946,7 +29101,7 @@ async function videoMetadataPatches(file, mime) {
28946
29101
  const mdats = top.filter((box) => box.type === "mdat");
28947
29102
  const merged = [];
28948
29103
  for (const [start, end] of zeroed.sort((a, b) => a[0] - b[0])) {
28949
- check(mdats.some((mdat) => start >= mdat.body && end <= mdat.end));
29104
+ check$1(mdats.some((mdat) => start >= mdat.body && end <= mdat.end));
28950
29105
  const last = merged[merged.length - 1];
28951
29106
  if (last && start <= last[1]) last[1] = Math.max(last[1], end);
28952
29107
  else merged.push([start, end]);
@@ -28957,12 +29112,709 @@ async function videoMetadataPatches(file, mime) {
28957
29112
  });
28958
29113
  let at = 0;
28959
29114
  for (const patch of patches.sort((a, b) => a.start - b.start)) {
28960
- check(patch.start >= at);
29115
+ check$1(patch.start >= at);
28961
29116
  at = patch.end;
28962
29117
  }
28963
29118
  return patches;
28964
29119
  }
28965
29120
  //#endregion
29121
+ //#region ../core/src/audioMetadata.ts
29122
+ /**
29123
+ * What an audio file leaves with. A recording made in another app, or a song a tagger went through, says more than its
29124
+ * sound: a title or a file name that is where it was recorded (a phone's recorder names it after the place), a comment,
29125
+ * a location tag, a picture, the date. The sender removes them before the file is stored and its digest computed, as
29126
+ * pictures' and videos' are (pictureMetadata.ts, videoMetadata.ts), without decoding or re-encoding a sample, and the
29127
+ * file keeps its size, so no offset in it moves and it plays as it did:
29128
+ *
29129
+ * - MP4 audio (M4A, a voice note recorded in MP4): videoMetadata.ts's box walk, its `udta` and `meta` emptied.
29130
+ * - MP3 and AAC: an ID3v2 tag at the start becomes an empty one (its frames zeros: padding), one at the end (with its
29131
+ * footer), an APEv2 tag's items, a Lyrics3v2 tag and an ID3v1 tag's fields become zeros. One typed as MP3 or AAC
29132
+ * whose first bytes are neither (junk before its first frame) still has the tags at its end emptied.
29133
+ * - FLAC: every metadata block but its stream info and seek table (a Vorbis comment, a picture, a cue sheet, an
29134
+ * application's) becomes padding, zeroed.
29135
+ * - Ogg Opus, Vorbis, Speex and Theora: the comment header keeps its vendor (the encoder's name) and has no comment,
29136
+ * the bytes after it zeros. FLAC in Ogg: its metadata blocks as a FLAC's. Each page changed has its checksum made again.
29137
+ * - WAV (RIFF, RF64 or BW64): every chunk but its format, data and the ones of the sound itself (`fact`, `cue `,
29138
+ * `smpl`, `inst`, an RF64's `ds64`) becomes `JUNK`, zeroed (an INFO list, an `id3 ` chunk, a broadcast `bext` with
29139
+ * its date and originator, iXML, XMP).
29140
+ * - WebM and Matroska, audio or video: `Tags`, `Attachments`, `Chapters`, the title, the date, the file names and each
29141
+ * track's name become `Void` elements (and the SeekHead's entries for them); the muxer's and the writing app's names
29142
+ * are zeroed. A Vorbis, Theora or FLAC track's CodecPrivate (its Ogg headers or its FLAC metadata blocks) has its
29143
+ * comments emptied as an Ogg's or a FLAC's. Clusters, cues and other track settings are kept as they are.
29144
+ *
29145
+ * Fail-closed: a file that is one of these by its bytes and whose tags cannot be removed (truncated, malformed) is
29146
+ * refused with `NO_AUDIO_METADATA`, never sent as it was. Any other file goes as it is (other audio formats too).
29147
+ */
29148
+ var AUDIO_METADATA_LIMITS = {
29149
+ /** The largest header, element or tag read whole (an Ogg comment header with a picture in it): past this the file is refused. */
29150
+ maxReadBytes: 67108864,
29151
+ /** The most pages, chunks, blocks or elements walked. */
29152
+ maxParts: 1e6,
29153
+ /** Bytes read first to tell an audio file from another file. */
29154
+ headBytes: 64
29155
+ };
29156
+ /** Why an audio file is refused: its tags could not be removed, so it does not go at all. */
29157
+ var NO_AUDIO_METADATA = "This audio cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded";
29158
+ /** Zeros put in a Blob a slice at a time: a Blob's Blob parts are not copied, so a zeroed range of any size holds no more. */
29159
+ var ZEROS = new Blob([/* @__PURE__ */ new Uint8Array(1048576)]);
29160
+ var text = (b, at, length) => String.fromCharCode(...b.subarray(at, at + length));
29161
+ var u32le = (b, at) => (b[at] | b[at + 1] << 8 | b[at + 2] << 16 | b[at + 3] << 24) >>> 0;
29162
+ var syncsafe = (b, at) => b[at] << 21 | b[at + 1] << 14 | b[at + 2] << 7 | b[at + 3];
29163
+ var latin = (s) => Uint8Array.from(s, (c) => c.charCodeAt(0));
29164
+ /** Refuses the file where its bytes are not what this expects. */
29165
+ function check(ok) {
29166
+ if (!ok) throw new Error(NO_AUDIO_METADATA);
29167
+ }
29168
+ function exactly(source) {
29169
+ return async (offset, length) => {
29170
+ check(offset >= 0 && length >= 0 && length <= AUDIO_METADATA_LIMITS.maxReadBytes && offset + length <= source.size);
29171
+ const bytes = await source.read(offset, length);
29172
+ check(bytes.length === length);
29173
+ return bytes;
29174
+ };
29175
+ }
29176
+ /** Counts the parts walked, so a file of millions of tiny ones is refused rather than walked forever. */
29177
+ function counter() {
29178
+ let parts = 0;
29179
+ return () => check(++parts <= AUDIO_METADATA_LIMITS.maxParts);
29180
+ }
29181
+ /** An ID3v2 header at `at` of `b`: its version 2 to 4 and its size four 7-bit bytes, or none. */
29182
+ var isId3 = (b, at = 0) => b.length >= at + 10 && text(b, at, 3) === "ID3" && b[at + 3] >= 2 && b[at + 3] <= 4 && b[at + 4] !== 255 && [
29183
+ 6,
29184
+ 7,
29185
+ 8,
29186
+ 9
29187
+ ].every((i) => b[at + i] < 128);
29188
+ /**
29189
+ * The ID3v2 tag whose header is `head`, at `at`: made an empty one where it is, its frames (and an extended header)
29190
+ * zeros, which is its padding, its flags but the footer's cleared. Returns where it ends.
29191
+ */
29192
+ async function emptyId3(read, size, at, head, patches) {
29193
+ const body = syncsafe(head, 6), footer = head[3] === 4 && head[5] & 16 ? 10 : 0, end = at + 10 + body + footer;
29194
+ check(end <= size);
29195
+ const flags = Uint8Array.of(footer ? 16 : 0);
29196
+ patches.push({
29197
+ start: at + 5,
29198
+ end: at + 6,
29199
+ bytes: flags
29200
+ });
29201
+ if (body) patches.push({
29202
+ start: at + 10,
29203
+ end: at + 10 + body
29204
+ });
29205
+ if (footer) {
29206
+ check(text(await read(at + 10 + body, 3), 0, 3) === "3DI");
29207
+ patches.push({
29208
+ start: at + 10 + body + 5,
29209
+ end: at + 10 + body + 6,
29210
+ bytes: flags
29211
+ });
29212
+ }
29213
+ return end;
29214
+ }
29215
+ /**
29216
+ * The tags at the end of an MP3 or AAC file (after `start`): an ID3v1 (and its extended part), then any of an APEv2
29217
+ * tag, a Lyrics3v2 tag and an ID3v2 tag with a footer, in any order. Each found is emptied where it is.
29218
+ */
29219
+ async function trailingTags(read, size, start, patches) {
29220
+ let end = size;
29221
+ if (end - 128 >= start && text(await read(end - 128, 3), 0, 3) === "TAG") {
29222
+ patches.push({
29223
+ start: end - 125,
29224
+ end: end - 1
29225
+ }, {
29226
+ start: end - 1,
29227
+ end,
29228
+ bytes: Uint8Array.of(255)
29229
+ });
29230
+ end -= 128;
29231
+ if (end - 227 >= start && text(await read(end - 227, 4), 0, 4) === "TAG+") {
29232
+ patches.push({
29233
+ start: end - 223,
29234
+ end
29235
+ });
29236
+ end -= 227;
29237
+ }
29238
+ }
29239
+ const count = counter();
29240
+ for (;;) {
29241
+ count();
29242
+ if (end - 32 >= start) {
29243
+ const footer = await read(end - 32, 32);
29244
+ if (text(footer, 0, 8) === "APETAGEX") {
29245
+ const length = u32le(footer, 12), header = footer[23] & 128 ? 32 : 0, tagStart = end - length - header;
29246
+ check(length >= 32 && tagStart >= start);
29247
+ if (header) {
29248
+ check(text(await read(tagStart, 8), 0, 8) === "APETAGEX");
29249
+ patches.push({
29250
+ start: tagStart + 16,
29251
+ end: tagStart + 20
29252
+ });
29253
+ }
29254
+ if (length > 32) patches.push({
29255
+ start: tagStart + header,
29256
+ end: end - 32
29257
+ });
29258
+ patches.push({
29259
+ start: end - 16,
29260
+ end: end - 12
29261
+ });
29262
+ end = tagStart;
29263
+ continue;
29264
+ }
29265
+ }
29266
+ if (end - 15 >= start) {
29267
+ const footer = await read(end - 15, 15);
29268
+ if (text(footer, 6, 9) === "LYRICS200") {
29269
+ const length = /^\d{6}$/.test(text(footer, 0, 6)) ? Number(text(footer, 0, 6)) : -1, tagStart = end - 15 - length;
29270
+ check(length >= 11 && tagStart >= start && text(await read(tagStart, 11), 0, 11) === "LYRICSBEGIN");
29271
+ if (length > 11) patches.push({
29272
+ start: tagStart + 11,
29273
+ end: end - 15
29274
+ });
29275
+ end = tagStart;
29276
+ continue;
29277
+ }
29278
+ }
29279
+ if (end - 10 >= start) {
29280
+ const footer = await read(end - 10, 10);
29281
+ if (text(footer, 0, 3) === "3DI") {
29282
+ check([
29283
+ 6,
29284
+ 7,
29285
+ 8,
29286
+ 9
29287
+ ].every((i) => footer[i] < 128));
29288
+ const tagStart = end - 20 - syncsafe(footer, 6);
29289
+ check(tagStart >= start);
29290
+ const head = await read(tagStart, 10);
29291
+ check(isId3(head));
29292
+ check(await emptyId3(read, size, tagStart, head, patches) === end);
29293
+ end = tagStart;
29294
+ continue;
29295
+ }
29296
+ }
29297
+ return;
29298
+ }
29299
+ }
29300
+ /** The types an MP3 or AAC file is sent as: one whose first bytes are no frame still has its tags at the end read. */
29301
+ var MPEG_AUDIO = /* @__PURE__ */ new Set([
29302
+ "audio/mpeg",
29303
+ "audio/mp3",
29304
+ "audio/mpeg3",
29305
+ "audio/x-mpeg",
29306
+ "audio/x-mp3",
29307
+ "audio/aac",
29308
+ "audio/x-aac",
29309
+ "audio/aacp"
29310
+ ]);
29311
+ /** An MPEG audio frame's or an ADTS header's first bytes: 11 bits set, a version and a layer that are some. */
29312
+ var isFrame = (b, at) => b.length >= at + 2 && b[at] === 255 && (b[at + 1] & 224) === 224 && (b[at + 1] & 24) !== 8;
29313
+ var FLAC_KEEPS = /* @__PURE__ */ new Set([0, 3]);
29314
+ /** A FLAC's metadata blocks from `at` (its `fLaC`): all but its stream info and seek table become padding, zeroed. */
29315
+ async function flac(read, size, at, patches) {
29316
+ const count = counter();
29317
+ for (at += 4;;) {
29318
+ count();
29319
+ const head = await read(at, 4);
29320
+ const last = head[0] & 128, type = head[0] & 127, end = at + 4 + (head[1] << 16 | head[2] << 8 | head[3]);
29321
+ check(type !== 127 && end <= size);
29322
+ if (!FLAC_KEEPS.has(type)) {
29323
+ if (type !== 1) patches.push({
29324
+ start: at,
29325
+ end: at + 1,
29326
+ bytes: Uint8Array.of(last | 1)
29327
+ });
29328
+ if (end > at + 4) patches.push({
29329
+ start: at + 4,
29330
+ end
29331
+ });
29332
+ }
29333
+ at = end;
29334
+ if (last) return at;
29335
+ }
29336
+ }
29337
+ var OGG_CRC = (() => {
29338
+ const table = /* @__PURE__ */ new Uint32Array(256);
29339
+ for (let i = 0; i < 256; i++) {
29340
+ let crc = i << 24;
29341
+ for (let bit = 0; bit < 8; bit++) crc = crc & 2147483648 ? crc << 1 ^ 79764919 : crc << 1;
29342
+ table[i] = crc >>> 0;
29343
+ }
29344
+ return table;
29345
+ })();
29346
+ /** Ogg's page checksum, over the page with its checksum's four bytes zeroed. */
29347
+ function oggCrc(page) {
29348
+ let crc = 0;
29349
+ for (let i = 0; i < page.length; i++) crc = (crc << 8 ^ OGG_CRC[(crc >>> 24 ^ (i >= 22 && i < 26 ? 0 : page[i])) & 255]) >>> 0;
29350
+ return crc;
29351
+ }
29352
+ /**
29353
+ * A comment header with no comment: its magic and vendor kept, its count 0 (and Vorbis's framing bit set), the rest
29354
+ * zeros: padding after the comments, which Opus says may be there and Vorbis's, Speex's and Theora's readers do not read.
29355
+ */
29356
+ function noComments(packet, comments, framing) {
29357
+ const magic = comments.length;
29358
+ check(text(packet, 0, magic) === comments && packet.length >= magic + 4);
29359
+ const count = magic + 4 + u32le(packet, magic);
29360
+ check(count + 4 + (framing ? 1 : 0) <= packet.length);
29361
+ const out = new Uint8Array(packet.length);
29362
+ out.set(packet.subarray(0, count));
29363
+ if (framing) out[count + 4] = 1;
29364
+ return out;
29365
+ }
29366
+ /** A FLAC metadata block that is a whole packet (FLAC in Ogg): kept, or made padding as `flac` makes it. */
29367
+ function noFlacBlock(packet) {
29368
+ check(packet.length >= 4 && packet.length === 4 + (packet[1] << 16 | packet[2] << 8 | packet[3]) && (packet[0] & 127) !== 127);
29369
+ const type = packet[0] & 127;
29370
+ if (FLAC_KEEPS.has(type)) return packet;
29371
+ const out = new Uint8Array(packet.length);
29372
+ out[0] = type === 1 ? packet[0] : packet[0] & 128 | 1;
29373
+ return out;
29374
+ }
29375
+ /** A codec whose second packet is its comment header: its magic, and whether a framing bit follows its comments (Vorbis). */
29376
+ var commentHeader = (head, comments, framing) => ({
29377
+ head,
29378
+ tagged: (_, index) => index === 0,
29379
+ empty: (packet) => noComments(packet, comments, framing)
29380
+ });
29381
+ var OGG_CODECS = [
29382
+ commentHeader("OpusHead", "OpusTags", false),
29383
+ commentHeader("vorbis", "vorbis", true),
29384
+ commentHeader("Speex ", "", false),
29385
+ commentHeader("€theora", "theora", false),
29386
+ {
29387
+ head: "FLAC",
29388
+ tagged: (packet, index) => {
29389
+ if (index) return !(packet[0] & 128);
29390
+ check(packet.length >= 17 && text(packet, 9, 4) === "fLaC");
29391
+ return !(packet[13] & 128);
29392
+ },
29393
+ empty: noFlacBlock
29394
+ }
29395
+ ];
29396
+ /**
29397
+ * An Ogg file's pages walked: each logical stream's comment header (a chained file has one per link) made one with no
29398
+ * comment where it is, across the pages it spans, and those pages' checksums made again.
29399
+ */
29400
+ async function ogg(read, size, patches) {
29401
+ const streams = /* @__PURE__ */ new Map();
29402
+ /** The bytes put in the pages changed, by where each page starts: by where they go in the file. */
29403
+ const pages = /* @__PURE__ */ new Map();
29404
+ const packetOf = async (ranges) => {
29405
+ const length = ranges.reduce((sum, [start, end]) => sum + end - start, 0);
29406
+ check(length <= AUDIO_METADATA_LIMITS.maxReadBytes);
29407
+ const packet = new Uint8Array(length);
29408
+ let at = 0;
29409
+ for (const [start, end] of ranges) {
29410
+ packet.set(await read(start, end - start), at);
29411
+ at += end - start;
29412
+ }
29413
+ return packet;
29414
+ };
29415
+ const count = counter();
29416
+ for (let at = 0; at < size;) {
29417
+ count();
29418
+ const head = await read(at, 27);
29419
+ check(text(head, 0, 4) === "OggS" && head[4] === 0);
29420
+ const lacing = await read(at + 27, head[26]);
29421
+ const end = at + 27 + lacing.length + lacing.reduce((sum, l) => sum + l, 0);
29422
+ check(end <= size);
29423
+ const serial = u32le(head, 14);
29424
+ if (head[5] & 2) streams.set(serial, {
29425
+ packet: 0,
29426
+ ranges: [],
29427
+ tagged: true
29428
+ });
29429
+ const stream = streams.get(serial);
29430
+ check(!!stream);
29431
+ let offset = at + 27 + lacing.length;
29432
+ for (const length of lacing) {
29433
+ if (stream.tagged) stream.ranges.push([
29434
+ offset,
29435
+ offset + length,
29436
+ at
29437
+ ]);
29438
+ offset += length;
29439
+ if (length === 255) continue;
29440
+ if (stream.packet === 0) {
29441
+ const first = await packetOf(stream.ranges);
29442
+ stream.codec = OGG_CODECS.find((codec) => text(first, 0, codec.head.length) === codec.head) ?? null;
29443
+ stream.tagged = !!stream.codec?.tagged(first, 0);
29444
+ } else if (stream.tagged && stream.codec) {
29445
+ const packet = await packetOf(stream.ranges), emptied = stream.codec.empty(packet);
29446
+ stream.tagged = stream.codec.tagged(packet, stream.packet);
29447
+ let from = 0;
29448
+ for (const [start, until, page] of stream.ranges) {
29449
+ if (!pages.has(page)) pages.set(page, []);
29450
+ pages.get(page).push([start, emptied.subarray(from, from + until - start)]);
29451
+ from += until - start;
29452
+ }
29453
+ }
29454
+ stream.packet++;
29455
+ stream.ranges = [];
29456
+ }
29457
+ at = end;
29458
+ }
29459
+ for (const stream of streams.values()) check(!stream.tagged);
29460
+ for (const [start, changes] of pages) {
29461
+ const head = await read(start, 27), lacing = await read(start + 27, head[26]);
29462
+ const end = start + 27 + lacing.length + lacing.reduce((sum, l) => sum + l, 0);
29463
+ const page = (await read(start, end - start)).slice();
29464
+ for (const [where, bytes] of changes) page.set(bytes, where - start);
29465
+ const crc = oggCrc(page);
29466
+ page.set([
29467
+ crc & 255,
29468
+ crc >>> 8 & 255,
29469
+ crc >>> 16 & 255,
29470
+ crc >>> 24
29471
+ ], 22);
29472
+ patches.push({
29473
+ start,
29474
+ end,
29475
+ bytes: page
29476
+ });
29477
+ }
29478
+ }
29479
+ /** The chunks a WAV's sound is made of, kept; any other becomes `JUNK`. */
29480
+ var WAV_KEEPS = /* @__PURE__ */ new Set([
29481
+ "fmt ",
29482
+ "data",
29483
+ "fact",
29484
+ "cue ",
29485
+ "smpl",
29486
+ "inst"
29487
+ ]);
29488
+ var WAV_SPACE = /* @__PURE__ */ new Set([
29489
+ "JUNK",
29490
+ "junk",
29491
+ "PAD ",
29492
+ "FLLR"
29493
+ ]);
29494
+ /** A WAV's chunks from its `WAVE`; an RF64 or BW64 one (`rf64`) has its `ds64` first, which says `data`'s size when its own is all ones. */
29495
+ async function wav(read, size, rf64, patches) {
29496
+ let dataSize;
29497
+ if (rf64) {
29498
+ const ds64 = await read(12, 24);
29499
+ check(text(ds64, 0, 4) === "ds64" && u32le(ds64, 4) >= 28);
29500
+ dataSize = u32le(ds64, 16) + u32le(ds64, 20) * 2 ** 32;
29501
+ }
29502
+ const count = counter();
29503
+ for (let at = 12; at + 8 <= size;) {
29504
+ count();
29505
+ const head = await read(at, 8);
29506
+ const id = text(head, 0, 4), length = id === "data" && dataSize !== void 0 && u32le(head, 4) === 4294967295 ? dataSize : u32le(head, 4);
29507
+ let end = at + 8 + length + length % 2;
29508
+ if (id === "data") end = length ? Math.min(end, size) : size;
29509
+ else check(at + 8 + length <= size);
29510
+ if (!WAV_KEEPS.has(id) && !(rf64 && at === 12)) {
29511
+ if (!WAV_SPACE.has(id)) patches.push({
29512
+ start: at,
29513
+ end: at + 4,
29514
+ bytes: latin("JUNK")
29515
+ });
29516
+ if (length) patches.push({
29517
+ start: at + 8,
29518
+ end: at + 8 + length
29519
+ });
29520
+ }
29521
+ at = Math.min(end, size);
29522
+ }
29523
+ }
29524
+ var EBML_HEADER = 440786851;
29525
+ var SEGMENT$1 = 408125543;
29526
+ var CLUSTER = 524531317;
29527
+ var VOID = 236;
29528
+ var CRC32 = 191;
29529
+ var SEEK_HEAD = 290298740;
29530
+ var INFO = 357149030;
29531
+ var TRACKS = 374648427;
29532
+ /** What a segment's sound and pictures are made of, kept; any other top-level element (Tags, Attachments, Chapters) becomes Void. */
29533
+ var SEGMENT_KEEPS = /* @__PURE__ */ new Set([
29534
+ SEEK_HEAD,
29535
+ INFO,
29536
+ TRACKS,
29537
+ CLUSTER,
29538
+ 475249515
29539
+ ]);
29540
+ /** What a cluster holds: one of unknown size ends where an element that is none of these starts. */
29541
+ var CLUSTER_CHILDREN = /* @__PURE__ */ new Set([
29542
+ 231,
29543
+ 22612,
29544
+ 167,
29545
+ 171,
29546
+ 163,
29547
+ 160,
29548
+ 175,
29549
+ VOID,
29550
+ CRC32
29551
+ ]);
29552
+ /** What Info keeps: the timing, the segment's IDs; the muxer's and writing app's names, zeroed. Any other (a title, a date, file names) becomes Void. */
29553
+ var INFO_KEEPS = /* @__PURE__ */ new Set([
29554
+ 2807729,
29555
+ 17545,
29556
+ 29604,
29557
+ 17476,
29558
+ 3979555,
29559
+ 4110627,
29560
+ 26916
29561
+ ]);
29562
+ var INFO_ZEROED = /* @__PURE__ */ new Set([19840, 22337]);
29563
+ var TRACK_ENTRY = 174;
29564
+ var TRACK_NAME = 21358;
29565
+ var CODEC_ID = 134;
29566
+ var CODEC_PRIVATE = 25506;
29567
+ var SEEK = 19899;
29568
+ var SEEK_ID = 21419;
29569
+ /** The codecs whose CodecPrivate is their Ogg headers Xiph-laced: the second a comment header, its magic, and whether a framing bit follows its comments. */
29570
+ var XIPH_PRIVATE = /* @__PURE__ */ new Map([["A_VORBIS", ["vorbis", true]], ["V_THEORA", ["theora", false]]]);
29571
+ /** The element whose header is at `at` of `b` (`base` its offset in the file); one of unknown size ends at `limit`. */
29572
+ function element(b, at, limit, base = 0) {
29573
+ check(at < b.length);
29574
+ const idLength = Math.clz32(b[at]) - 23;
29575
+ check(idLength >= 1 && idLength <= 4 && at + idLength < b.length);
29576
+ let id = 0;
29577
+ for (let i = 0; i < idLength; i++) id = id * 256 + b[at + i];
29578
+ const sizeAt = at + idLength, sizeLength = Math.clz32(b[sizeAt]) - 23;
29579
+ check(sizeLength >= 1 && sizeLength <= 8 && sizeAt + sizeLength <= b.length);
29580
+ let size = b[sizeAt] & 255 >> sizeLength, ones = size === 255 >> sizeLength;
29581
+ for (let i = 1; i < sizeLength; i++) {
29582
+ size = size * 256 + b[sizeAt + i];
29583
+ ones &&= b[sizeAt + i] === 255;
29584
+ }
29585
+ const body = base + sizeAt + sizeLength;
29586
+ return {
29587
+ id,
29588
+ start: base + at,
29589
+ body,
29590
+ end: ones ? limit : body + size,
29591
+ unknown: ones
29592
+ };
29593
+ }
29594
+ /** An element's header read from the file at `at`. */
29595
+ async function elementAt(source, at, limit) {
29596
+ return element(await source.read(at, 12), 0, limit, at);
29597
+ }
29598
+ /** A Void element `length` bytes long: its ID, its size in as many bytes as it takes to fill it, the rest zeros. */
29599
+ function voidHeader(length) {
29600
+ for (let sizeLength = 1; sizeLength <= 8; sizeLength++) {
29601
+ const body = length - 1 - sizeLength;
29602
+ if (body < 0 || body >= 2 ** (7 * sizeLength) - 1) continue;
29603
+ const header = new Uint8Array(1 + sizeLength);
29604
+ header[0] = VOID;
29605
+ for (let i = sizeLength, rest = body; i >= 1; i--, rest = Math.floor(rest / 256)) header[i] = rest % 256;
29606
+ header[1] |= 128 >> sizeLength - 1;
29607
+ return header;
29608
+ }
29609
+ check(false);
29610
+ }
29611
+ /** `el` of `b` (read whole, `el`'s offsets in it) made Void where it is. */
29612
+ function voidIn(b, el) {
29613
+ const header = voidHeader(el.end - el.start);
29614
+ b.fill(0, el.start, el.end);
29615
+ b.set(header, el.start);
29616
+ }
29617
+ /** The children of `parent` (in `b`, read whole) as elements, each within it. */
29618
+ function childrenOf(b, parent) {
29619
+ const found = [];
29620
+ for (let at = parent.body; at < parent.end;) {
29621
+ const child = element(b.subarray(0, parent.end), at, parent.end);
29622
+ check(!child.unknown && child.end <= parent.end);
29623
+ found.push(child);
29624
+ at = child.end;
29625
+ }
29626
+ return found;
29627
+ }
29628
+ /**
29629
+ * A track's CodecPrivate (`b`, changed in it) by its codec: a Vorbis or Theora track's headers (their count less one,
29630
+ * each size but the last's in Xiph lacing, them) with a comment header that has no comment, its sizes kept; a FLAC
29631
+ * track's `fLaC` and metadata blocks as a FLAC's, any byte after the last zeroed. Another codec's is kept as it is.
29632
+ */
29633
+ async function noPrivateTags(b, codec) {
29634
+ const xiph = XIPH_PRIVATE.get(codec);
29635
+ if (xiph) {
29636
+ check(b.length >= 1 && b[0] === 2);
29637
+ let at = 1;
29638
+ const sizes = [];
29639
+ while (sizes.length < 2) {
29640
+ let size = 0;
29641
+ for (let byte = 255; byte === 255; size += byte) {
29642
+ check(at < b.length);
29643
+ byte = b[at++];
29644
+ }
29645
+ sizes.push(size);
29646
+ }
29647
+ const start = at + sizes[0], end = start + sizes[1];
29648
+ check(end <= b.length);
29649
+ b.set(noComments(b.subarray(start, end), ...xiph), start);
29650
+ } else if (codec === "A_FLAC") {
29651
+ check(b.length >= 4 && text(b, 0, 4) === "fLaC");
29652
+ const patches = [];
29653
+ const end = await flac(async (offset, length) => {
29654
+ check(offset >= 0 && length >= 0 && offset + length <= b.length);
29655
+ return b.subarray(offset, offset + length);
29656
+ }, b.length, 0, patches);
29657
+ for (const patch of patches) if (patch.bytes) b.set(patch.bytes, patch.start);
29658
+ else b.fill(0, patch.start, patch.end);
29659
+ b.fill(0, end);
29660
+ }
29661
+ }
29662
+ /**
29663
+ * A top-level element of a segment read whole and changed in it: Info without its title, date and file names (its
29664
+ * muxer's and writing app's names zeroed), Tracks without their names and the comments in their CodecPrivate, a
29665
+ * SeekHead without the entries for what became Void. A CRC-32 in them, wrong once they changed, becomes Void too.
29666
+ */
29667
+ async function stripTopLevel(b) {
29668
+ const top = element(b, 0, b.length);
29669
+ check(!top.unknown && top.end === b.length);
29670
+ for (const child of childrenOf(b, top)) {
29671
+ if (child.id === CRC32) voidIn(b, child);
29672
+ else if (top.id === INFO) {
29673
+ if (INFO_ZEROED.has(child.id)) b.fill(0, child.body, child.end);
29674
+ else if (!INFO_KEEPS.has(child.id) && child.id !== VOID) voidIn(b, child);
29675
+ } else if (top.id === TRACKS && child.id === TRACK_ENTRY) {
29676
+ const parts = childrenOf(b, child), ids = parts.filter((part) => part.id === CODEC_ID);
29677
+ check(ids.length <= 1);
29678
+ const codec = ids[0] ? text(b, ids[0].body, ids[0].end - ids[0].body).replace(/\0+$/, "") : "";
29679
+ for (const part of parts) if (part.id === TRACK_NAME || part.id === CRC32) voidIn(b, part);
29680
+ else if (part.id === CODEC_PRIVATE) await noPrivateTags(b.subarray(part.body, part.end), codec);
29681
+ } else if (top.id === SEEK_HEAD && child.id === SEEK) {
29682
+ const target = childrenOf(b, child).find((part) => part.id === SEEK_ID);
29683
+ let id = 0;
29684
+ if (target) for (let i = target.body; i < target.end; i++) id = id * 256 + b[i];
29685
+ if (!SEGMENT_KEEPS.has(id)) voidIn(b, child);
29686
+ }
29687
+ if (child.id === VOID) b.fill(0, child.body, child.end);
29688
+ }
29689
+ }
29690
+ /** Where a cluster of unknown size ends: at the first element that is not a cluster's, or the segment's end. */
29691
+ async function clusterEnd(source, at, limit, count) {
29692
+ for (;;) {
29693
+ count();
29694
+ if (at >= limit) return limit;
29695
+ const child = await elementAt(source, at, limit);
29696
+ if (!CLUSTER_CHILDREN.has(child.id)) return at;
29697
+ check(!child.unknown);
29698
+ if (child.end >= limit) return limit;
29699
+ at = child.end;
29700
+ }
29701
+ }
29702
+ async function matroska(source, read, patches) {
29703
+ const count = counter();
29704
+ const toVoid = (el) => {
29705
+ const header = voidHeader(el.end - el.start);
29706
+ patches.push({
29707
+ start: el.start,
29708
+ end: el.start + header.length,
29709
+ bytes: header
29710
+ });
29711
+ if (el.end > el.start + header.length) patches.push({
29712
+ start: el.start + header.length,
29713
+ end: el.end
29714
+ });
29715
+ };
29716
+ for (let at = 0; at < source.size;) {
29717
+ count();
29718
+ const top = await elementAt(source, at, source.size);
29719
+ check(top.end <= source.size);
29720
+ if (top.id === EBML_HEADER) check(!top.unknown);
29721
+ else if (top.id === VOID) {
29722
+ if (top.end > top.body) patches.push({
29723
+ start: top.body,
29724
+ end: top.end
29725
+ });
29726
+ } else if (top.id !== SEGMENT$1) {
29727
+ check(!top.unknown);
29728
+ toVoid(top);
29729
+ } else for (let in_ = top.body; in_ < top.end;) {
29730
+ count();
29731
+ const el = await elementAt(source, in_, top.end);
29732
+ if (el.id === CLUSTER) {
29733
+ in_ = el.unknown ? await clusterEnd(source, el.body, top.end, count) : Math.min(el.end, top.end);
29734
+ continue;
29735
+ }
29736
+ check(!el.unknown && el.end <= top.end);
29737
+ if (el.id === INFO || el.id === TRACKS || el.id === SEEK_HEAD) {
29738
+ const bytes = (await read(el.start, el.end - el.start)).slice();
29739
+ await stripTopLevel(bytes);
29740
+ patches.push({
29741
+ start: el.start,
29742
+ end: el.end,
29743
+ bytes
29744
+ });
29745
+ } else if (el.id === VOID) {
29746
+ if (el.end > el.body) patches.push({
29747
+ start: el.body,
29748
+ end: el.end
29749
+ });
29750
+ } else if (!SEGMENT_KEEPS.has(el.id)) toVoid(el);
29751
+ in_ = el.end;
29752
+ }
29753
+ at = top.end;
29754
+ }
29755
+ }
29756
+ /**
29757
+ * What `withoutAudioMetadata` changes in an audio file read from `source` (one not held in a Blob: a file kept in
29758
+ * storage): the parts replaced, in order and apart, the rest of its bytes going as they are; undefined when it goes as
29759
+ * it is. Throws `NO_AUDIO_METADATA` for one whose tags cannot be removed; an error reading `source` as it is.
29760
+ */
29761
+ async function audioMetadataPatches(file, mime) {
29762
+ const source = readingAhead(file), read = exactly(source), size = source.size;
29763
+ const head = await source.read(0, Math.min(AUDIO_METADATA_LIMITS.headBytes, size));
29764
+ const patches = [];
29765
+ if (head.length >= 8 && text(head, 4, 4) === "ftyp") try {
29766
+ return await videoMetadataPatches(file, mime, true);
29767
+ } catch (error) {
29768
+ if (error instanceof Error && error.message === "This video cannot be sent: Ghostly could not remove the details saved in it, like where it was recorded") throw Object.assign(/* @__PURE__ */ new Error(NO_AUDIO_METADATA), { cause: error });
29769
+ throw error;
29770
+ }
29771
+ else if (text(head, 0, 4) === "OggS") await ogg(read, size, patches);
29772
+ else if (head.length >= 12 && [
29773
+ "RIFF",
29774
+ "RF64",
29775
+ "BW64"
29776
+ ].includes(text(head, 0, 4)) && text(head, 8, 4) === "WAVE") await wav(read, size, text(head, 0, 4) !== "RIFF", patches);
29777
+ else if (text(head, 0, 4) === "Eߣ") await matroska(source, read, patches);
29778
+ else if (text(head, 0, 4) === "fLaC") await trailingTags(read, size, await flac(read, size, 0, patches), patches);
29779
+ else if (isId3(head) || isFrame(head, 0)) {
29780
+ let at = 0;
29781
+ const count = counter();
29782
+ for (let next = head; isId3(next); next = at + 10 <= size ? await read(at, 10) : /* @__PURE__ */ new Uint8Array(0)) {
29783
+ count();
29784
+ at = await emptyId3(read, size, at, next, patches);
29785
+ }
29786
+ if (at + 4 <= size && text(await read(at, 4), 0, 4) === "fLaC") at = await flac(read, size, at, patches);
29787
+ await trailingTags(read, size, at, patches);
29788
+ } else if (MPEG_AUDIO.has(baseMime(mime))) await trailingTags(read, size, 0, patches);
29789
+ else return void 0;
29790
+ if (!patches.length) return void 0;
29791
+ patches.sort((a, b) => a.start - b.start);
29792
+ for (let i = 1; i < patches.length; i++) check(patches[i].start >= patches[i - 1].end);
29793
+ return patches;
29794
+ }
29795
+ /**
29796
+ * `source` as it is sent: an audio file without its tags, made of `source`'s own bytes but for the parts emptied;
29797
+ * undefined when it goes as it is (not one of these, or one with nothing to remove). Throws `NO_AUDIO_METADATA` for
29798
+ * one whose tags cannot be removed; an error reading `source` as it is.
29799
+ */
29800
+ async function withoutAudioMetadata(source, mime) {
29801
+ const patches = await audioMetadataPatches({
29802
+ size: source.size,
29803
+ read: async (offset, length) => new Uint8Array(await source.slice(offset, offset + length).arrayBuffer())
29804
+ }, mime);
29805
+ if (!patches) return void 0;
29806
+ const parts = [];
29807
+ let at = 0;
29808
+ for (const patch of patches) {
29809
+ if (patch.start > at) parts.push(source.slice(at, patch.start));
29810
+ if (patch.bytes) parts.push(patch.bytes);
29811
+ else for (let left = patch.end - patch.start; left > 0; left -= ZEROS.size) parts.push(ZEROS.slice(0, Math.min(left, ZEROS.size)));
29812
+ at = patch.end;
29813
+ }
29814
+ if (at < source.size) parts.push(source.slice(at));
29815
+ return new Blob(parts, { type: mime });
29816
+ }
29817
+ //#endregion
28966
29818
  //#region ../core/src/payments.ts
28967
29819
  /**
28968
29820
  * Payments between two linked peers. Ghostly does not move money itself: it
@@ -30332,45 +31184,35 @@ function seqDate(seq) {
30332
31184
  return Number.isNaN(date.getTime()) ? (/* @__PURE__ */ new Date(0)).toISOString() : date.toISOString();
30333
31185
  }
30334
31186
  /**
30335
- * Resolves a did:dht through Pkarr relays: one GET per relay, in turn, the next only when one has
30336
- * nothing, fails or serves a packet that does not check out. The answer is bounded to a BEP44 item,
30337
- * its signature checked against the DID's key and its records parsed strictly. A deactivated DID
31187
+ * Resolves a did:dht through Pkarr relays: one GET to each, all at once, and the newest packet that
31188
+ * checks out wins (the highest sequence number; on a tie, the relay listed first), so a relay holding
31189
+ * an older version cannot bring back a removed key or undo a deactivation. Each answer is bounded to
31190
+ * a BEP44 item, its signature checked against the DID's key and its records parsed strictly; a relay
31191
+ * that has nothing, fails or serves a packet that does not check out does not count. A deactivated DID
30338
31192
  * resolves (`metadata.deactivated`); everything else that goes wrong throws a `DidDhtError`.
30339
31193
  */
30340
31194
  async function resolveDidDht(did, options) {
30341
31195
  const { z32 } = didDhtKey(did);
30342
31196
  const relays = [...new Set((options.relays ?? DEFAULT_RELAYS).map(normalizeRelayUrl).filter((r) => r !== null))];
30343
31197
  if (relays.length === 0) throw new DidDhtError("No Pkarr relay to ask", "unreachable");
31198
+ options.signal?.throwIfAborted();
31199
+ const responses = await Promise.all(relays.map((relay) => options.fetch(`${relay}/${z32}`, {
31200
+ maxBytes: DID_DHT_MAX_PAYLOAD,
31201
+ signal: options.signal,
31202
+ redirect: "error"
31203
+ }).catch(() => void 0)));
31204
+ options.signal?.throwIfAborted();
30344
31205
  let notFound = false;
30345
31206
  let refused;
30346
- for (const relay of relays) {
30347
- options.signal?.throwIfAborted();
30348
- let response;
30349
- try {
30350
- response = await options.fetch(`${relay}/${z32}`, {
30351
- maxBytes: DID_DHT_MAX_PAYLOAD,
30352
- signal: options.signal,
30353
- redirect: "error"
30354
- });
30355
- } catch (error) {
30356
- if (options.signal?.aborted) throw error;
30357
- continue;
30358
- }
30359
- if (response.status === 404) {
30360
- notFound = true;
30361
- continue;
30362
- }
30363
- if (response.status !== 200) continue;
31207
+ let newest;
31208
+ for (const [i, relay] of relays.entries()) {
31209
+ const response = responses[i];
31210
+ if (response?.status === 404) notFound = true;
31211
+ if (response?.status !== 200) continue;
30364
31212
  try {
30365
31213
  const opened = openDidDhtPayload(did, response.bytes);
30366
- return {
30367
- document: opened.document,
30368
- metadata: {
30369
- versionId: opened.seq.toString(),
30370
- updated: seqDate(opened.seq),
30371
- ...opened.deactivated ? { deactivated: true } : {},
30372
- ...opened.types ? { types: opened.types } : {}
30373
- },
31214
+ if (!newest || opened.seq > newest.seq) newest = {
31215
+ ...opened,
30374
31216
  relay
30375
31217
  };
30376
31218
  } catch (error) {
@@ -30378,6 +31220,16 @@ async function resolveDidDht(did, options) {
30378
31220
  refused = error;
30379
31221
  }
30380
31222
  }
31223
+ if (newest) return {
31224
+ document: newest.document,
31225
+ metadata: {
31226
+ versionId: newest.seq.toString(),
31227
+ updated: seqDate(newest.seq),
31228
+ ...newest.deactivated ? { deactivated: true } : {},
31229
+ ...newest.types ? { types: newest.types } : {}
31230
+ },
31231
+ relay: newest.relay
31232
+ };
30381
31233
  if (refused) throw refused;
30382
31234
  if (notFound) throw new DidDhtError("No document is published for this did:dht", "not-found");
30383
31235
  throw new DidDhtError("No Pkarr relay answered for this did:dht", "unreachable");
@@ -32884,6 +33736,10 @@ var CatchUpAnswers = class {
32884
33736
  }
32885
33737
  })();
32886
33738
  }
33739
+ /** Whether an answer to `to` still has frames to send, or sent ones its app has not said it handled yet (`hooks.handled`). */
33740
+ busy(to) {
33741
+ return this.going.has(to) || !!this.onTheirWay.get(to)?.size;
33742
+ }
32887
33743
  /** The next slice of `rest` to `to`, as sent: undefined, and nothing left, when the edge did not take one. */
32888
33744
  sendSlice(to, rest) {
32889
33745
  const slice = rest.splice(0, 16);
@@ -32994,6 +33850,11 @@ var GROUP_READ_NOTE = `Everyone in the group can read everything sent while they
32994
33850
  */
32995
33851
  var ANSWER_WINDOW_MS$1 = 5e3;
32996
33852
  /**
33853
+ * How long a name an edge took away can still come back when I am taken out of the group (`nameKept`): the commit
33854
+ * that removed me comes over the admin's kept edge right after it opens, within the minute that edge stays open.
33855
+ */
33856
+ var UNNAMED_KEPT_MS = 6e4;
33857
+ /**
32997
33858
  * One member's messages (or edits) taken: its whole log handed back at once twice over (`AUTHOR_BURST`: an edge opening
32998
33859
  * hears it, with what the member says live beside it, and the edits its app says again), then
32999
33860
  * `GROUP_LIMITS.messagesPerAuthor` and `messageBytesPerAuthor` per `messageWindowMs`, as a community's `MessagePace`.
@@ -33427,6 +34288,12 @@ var GroupSession = class {
33427
34288
  * said it (`heardName`). In memory only; the records held start it.
33428
34289
  */
33429
34290
  nickAt = /* @__PURE__ */ new Map();
34291
+ /**
34292
+ * Member → the name an edge's empty one took away a moment ago (`setNick`), and when. The admin that removed me while
34293
+ * I was away says no name on the edge it kept to tell me, as its app opens it, and the commit that removes me comes
34294
+ * right after on that edge: that name comes back for the history I keep (`nameKept`). In memory only.
34295
+ */
34296
+ unnamed = /* @__PURE__ */ new Map();
33430
34297
  /** The version of my name record last said to every member (`sayName`). In memory only: said again once per start. */
33431
34298
  nameSaid;
33432
34299
  /** New name records taken per member, a few a minute (`GROUP_LIMITS.namesPerMember`). In memory only. */
@@ -33435,8 +34302,8 @@ var GroupSession = class {
33435
34302
  messagePace = /* @__PURE__ */ new Map();
33436
34303
  editPace = /* @__PURE__ */ new Map();
33437
34304
  queue = Promise.resolve();
33438
- /** One metadata frame that names a commit or an epoch I do not have yet: tried again when the chain moves. */
33439
- pendingMeta;
34305
+ /** Metadata frames that name a commit or an epoch I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain moves. */
34306
+ pendingMeta = {};
33440
34307
  /** While `handle` runs: the frames it took that a hub passes on (`handle`'s result). */
33441
34308
  passOn = null;
33442
34309
  /** The frames kept to hand on that the app holds with its messages, oldest first; undefined when the state holds them all. */
@@ -34137,6 +35004,16 @@ var GroupSession = class {
34137
35004
  this.waiting = [];
34138
35005
  this.waitingBytes = 0;
34139
35006
  this.pendingCommits.clear();
35007
+ this.nameKept();
35008
+ }
35009
+ /**
35010
+ * Out of the group: a name an edge took away a moment before comes back, as the history I keep still shows it. The
35011
+ * edge the admin kept to tell me I was removed says no name as it opens, just before the commit that removed me.
35012
+ */
35013
+ nameKept() {
35014
+ const now = this.now();
35015
+ for (const [key, { nick, at }] of this.unnamed) if (now - at <= UNNAMED_KEPT_MS && !this.state.nicks[key]) this.state.nicks[key] = nick;
35016
+ this.unnamed.clear();
34140
35017
  }
34141
35018
  /**
34142
35019
  * Encrypts and signs a text, keeps it for catch-up and sends it to every other member. `mentions`: places of the
@@ -34643,10 +35520,17 @@ var GroupSession = class {
34643
35520
  setNick(key, nick) {
34644
35521
  return this.serialize(async () => {
34645
35522
  const clean = sanitizeNick(nick);
35523
+ if (!clean && this.state.status !== "active") return;
34646
35524
  this.nickAt.set(key, this.now());
34647
- if ((this.state.nicks[key] ?? void 0) === clean) return;
35525
+ const was = this.state.nicks[key];
35526
+ if ((was ?? void 0) === clean) return;
34648
35527
  if (clean) this.state.nicks[key] = clean;
34649
35528
  else delete this.state.nicks[key];
35529
+ if (!clean && was) this.unnamed.set(key, {
35530
+ nick: was,
35531
+ at: this.now()
35532
+ });
35533
+ else this.unnamed.delete(key);
34650
35534
  if (key === this.myKey) await this.persist();
34651
35535
  else this.persistSoon();
34652
35536
  this.hooks.changed();
@@ -35520,22 +36404,14 @@ var GroupSession = class {
35520
36404
  const s = frame.statement;
35521
36405
  if (!groupMetaNewer(s, this.state.meta)) return;
35522
36406
  if (s.e > this.epoch || frame.k > this.epoch) {
35523
- this.pendingMeta = {
35524
- from,
35525
- frame: raw
35526
- };
35527
- this.ask(from);
36407
+ this.waitMeta(from, raw, s);
35528
36408
  return;
35529
36409
  }
35530
36410
  const commit = this.state.chain[s.e];
35531
36411
  if (commitHash(commit) !== s.h || rosterAdmin(commit.m) !== s.by || this.admin !== s.by || !verifyGroupMetaSignature(s)) return;
35532
36412
  const secret = this.secret(frame.k);
35533
36413
  if (!secret) {
35534
- this.pendingMeta = {
35535
- from,
35536
- frame: raw
35537
- };
35538
- this.ask(from);
36414
+ this.waitMeta(from, raw, s);
35539
36415
  return;
35540
36416
  }
35541
36417
  const opened = openGroupMeta(frame, epochKeys(secret, this.id, frame.k).message);
@@ -35556,6 +36432,21 @@ var GroupSession = class {
35556
36432
  });
35557
36433
  }
35558
36434
  /**
36435
+ * A statement that waits for the chain: only one its signer signed, so an altered copy cannot push out the one
36436
+ * waiting. The admin I know has a place of their own, which another member's statement cannot take, and in each
36437
+ * place only a later statement takes the one waiting.
36438
+ */
36439
+ waitMeta(from, raw, s) {
36440
+ if (!verifyGroupMetaSignature(s)) return;
36441
+ const place = s.by === this.admin ? "admin" : "other", waiting = this.pendingMeta[place];
36442
+ if (!waiting || groupMetaNewer(s, waiting.s)) this.pendingMeta[place] = {
36443
+ from,
36444
+ frame: raw,
36445
+ s
36446
+ };
36447
+ this.ask(from);
36448
+ }
36449
+ /**
35559
36450
  * Who made the change a statement brings me: its signer, when they were the admin all along since the statement I
35560
36451
  * held (or, with none, since I got in). A new admin signs again what the last one set (`metaFollowsChain`): to a
35561
36452
  * member that missed that, it is no change of theirs it can tell apart, so nobody is named. With none held, theirs is
@@ -35572,9 +36463,9 @@ var GroupSession = class {
35572
36463
  }
35573
36464
  /** After the chain or my secrets moved: the waiting statement, and, if I became the admin, the name and picture signed again as mine. */
35574
36465
  async metaFollowsChain() {
35575
- const pending = this.pendingMeta;
35576
- this.pendingMeta = void 0;
35577
- if (pending) await this.receiveMeta(pending.from, pending.frame);
36466
+ const { admin, other } = this.pendingMeta;
36467
+ this.pendingMeta = {};
36468
+ for (const pending of [admin, other]) if (pending) await this.receiveMeta(pending.from, pending.frame);
35578
36469
  if (this.isAdmin && this.state.meta && this.state.meta.by !== this.myKey) await this.publishMeta(this.state.meta.body, this.state.meta.ts, true);
35579
36470
  }
35580
36471
  async fork(reason) {
@@ -36383,8 +37274,8 @@ var CommunitySession = class CommunitySession {
36383
37274
  /** My frames said again in this run (`e:h16:n`) → the id of the message they first were. In memory only. */
36384
37275
  resealedFrom = /* @__PURE__ */ new Map();
36385
37276
  saveTimer;
36386
- /** One metadata frame naming a commit or a secret I do not have yet: tried again when the chain or my secrets move. */
36387
- pendingMeta;
37277
+ /** Metadata frames naming a commit or a secret I do not have yet, one signed by the admin and one by anyone else (`waitMeta`): tried again when the chain or my secrets move. */
37278
+ pendingMeta = {};
36388
37279
  /** The store's frames the app holds with their messages (`storeKey` → message id): in memory here, not in what is saved. */
36389
37280
  onRows = /* @__PURE__ */ new Map();
36390
37281
  /** The oldest epoch whose seen marks are kept, as of the last `pruneSeen`. In memory only. */
@@ -38942,23 +39833,13 @@ var CommunitySession = class CommunitySession {
38942
39833
  if (!groupMetaNewer(s, this.state.meta)) return false;
38943
39834
  const at = this.mainIndex.get(s.h);
38944
39835
  if (at === void 0) {
38945
- if (s.e >= this.epoch - COMMUNITY_LIMITS.window) {
38946
- this.pendingMeta = {
38947
- from,
38948
- frame: raw
38949
- };
38950
- this.ask(from);
38951
- }
39836
+ if (s.e >= this.epoch - COMMUNITY_LIMITS.window) this.waitMeta(from, raw, s);
38952
39837
  return false;
38953
39838
  }
38954
39839
  if (at !== s.e || rosterAdmin(this.rosterAt(s.h) ?? []) !== s.by || this.admin !== s.by || !verifyGroupMetaSignature(s)) return false;
38955
39840
  const secret = this.state.secrets[frame.k], sealedUnder = this.known.get(frame.k);
38956
39841
  if (!secret || !sealedUnder) {
38957
- this.pendingMeta = {
38958
- from,
38959
- frame: raw
38960
- };
38961
- this.ask(from);
39842
+ this.waitMeta(from, raw, s);
38962
39843
  return false;
38963
39844
  }
38964
39845
  const opened = openGroupMeta(frame, epochKeys(fromBase64Url(secret), this.id, sealedUnder.e).message);
@@ -38973,6 +39854,21 @@ var CommunitySession = class CommunitySession {
38973
39854
  return true;
38974
39855
  }
38975
39856
  /**
39857
+ * A statement that waits for the chain: only one its signer signed, so an altered copy cannot push out the one
39858
+ * waiting. The admin I know has a place of their own, which another member's statement cannot take, and in each
39859
+ * place only a later statement takes the one waiting.
39860
+ */
39861
+ waitMeta(from, raw, s) {
39862
+ if (!verifyGroupMetaSignature(s)) return;
39863
+ const place = s.by === this.admin ? "admin" : "other", waiting = this.pendingMeta[place];
39864
+ if (!waiting || groupMetaNewer(s, waiting.s)) this.pendingMeta[place] = {
39865
+ from,
39866
+ frame: raw,
39867
+ s
39868
+ };
39869
+ this.ask(from);
39870
+ }
39871
+ /**
38976
39872
  * Who made the change a statement brings me (`at`: its commit's place on my main branch): its signer, when they were
38977
39873
  * the admin all along since the statement I held (or, with none, since I got in). A new admin signs again what the
38978
39874
  * last one set (`metaFollowsChain`): to a member that missed that, it is no change of theirs it can tell apart. With
@@ -38997,9 +39893,9 @@ var CommunitySession = class CommunitySession {
38997
39893
  * went with a branch that lost a fork, the name and picture signed again as mine under the main branch.
38998
39894
  */
38999
39895
  async metaFollowsChain() {
39000
- const pending = this.pendingMeta;
39001
- this.pendingMeta = void 0;
39002
- if (pending && await this.receiveMeta(pending.from, pending.frame)) this.hooks.relay?.(pending.frame);
39896
+ const { admin, other } = this.pendingMeta;
39897
+ this.pendingMeta = {};
39898
+ for (const pending of [admin, other]) if (pending && await this.receiveMeta(pending.from, pending.frame)) this.hooks.relay?.(pending.frame);
39003
39899
  const meta = this.state.meta;
39004
39900
  if (this.isAdmin && meta && (meta.by !== this.myKey || !this.mainIndex.has(meta.h))) await this.publishMeta(meta.body, meta.ts, true);
39005
39901
  }
@@ -39671,6 +40567,6 @@ function readX401SdJwtVc(text) {
39671
40567
  };
39672
40568
  }
39673
40569
  //#endregion
39674
- export { SSHSIG_NAMESPACE as $, LINK_TRAILING as $a, contactAskerFrame as $c, emptyProofLedger as $i, OwnInviteError as $l, engineError as $n, RATCHET_CAPABILITY as $o, TYPING_REFRESH_MS as $r, handoffContext as $s, ONCHAIN_PROVIDER as $t, openRelayPayload as $u, knockIdentity as A, DHT_MESSAGE_TTL as Aa, ENROLL_GRANT as Ac, STATUS_CARD_CAPABILITY as Ai, appRefPublisher as Al, ENDPOINT as An, buttonLabelClash as Ao, lobbyKeys as Ar, signalHasVideo as As, didJwsAlg as At, turnKeys as Au, GROUP_REACTED_FRAME as B, baseMime as Ba, readEnrollGrant as Bc, IdentityExchange as Bi, signAppObject as Bl, NO_PICTURE_METADATA as Bn, heardTime as Bo, shouldBeHub as Br, HANDOFF_OFFER as Bs, parseDidSignaturePaste as Bt, currentRelays as Bu, communityHasFrame as C, recordsFromTxt as Ca, SET_UPDATE as Cc, isServeId as Ci, readAppBundle as Cl, pubkyProofFile as Cn, PR_STATES as Co, pickMeshHubs as Cr, answersOffer as Cs, DID_DOCUMENT_MAX_BYTES as Ct, TURN_MAX as Cu, decodeGroupEntryLink as D, wellKnownUrl as Da, signTombstone as Dc, APPS_CAPABILITY as Di, APP_STATEMENT_LIMITS as Dl, requestLnurlInvoice as Dn, TASK_STATUSES as Do, doorHubs as Dr, contactRtcConfig as Ds, checkDidJws as Dt, signTurnPacket as Du, KNOCK_TTL_MS as E, txtValue as Ea, setUpdateFrame as Ec, isAppVersion as Ei, APP_PREFIXES as El, pubkyHomeserverOf as En, STATUS_CARD_LIMITS as Eo, beaconRecords as Er, callSignalHeardAt as Es, DidError as Et, readTurnPacket as Eu, GroupWakeLimiter as F, sanitizeFileName as Fa, enrollDigits as Fc, dialDescriptors as Fi, isAppRef as Fl, parseCashuRequestPayload as Fn, statusCardBytes as Fo, pickHubs as Fr, HANDOFF_ACK as Fs, didWebFileUrl as Ft, HEDGE_MISSING_MS as Fu, GROUP_EDIT_FRAME as G, voiceLevel as Ga, inboxRecord as Gc, identityRevocationValue as Gi, canonicalJsonBytes as Gl, GhostLink as Gn, MAX_GROUP_CHAIN as Go, transferEnded as Gr, HANDOFF_VERIFIED as Gs, didDhtDocument as Gt, DiscoveryBudgetError as Gu, GroupSession as H, fileMessageText as Ha, verifyEnrollProof as Hc, boundVerifiedIdentity as Hi, parseImageMeta as Hl, isStrippedPicture as Hn, shownTime as Ho, FILE_LIMITS as Hr, HANDOFF_PIECE_BYTES as Hs, staticDidDocument as Ht, relayUrlProblem as Hu, groupWakeFrame as I, sanitizeMime as Ia, enrollDoneFrame as Ic, IDENTITY_MAX_EVIDENCE as Ii, readAppRevocation as Il, parseFedimintRequestPayload as In, statusCardText as Io, rankHubs as Ir, HANDOFF_CANCEL as Is, didWebHost as It, HEDGE_MS as Iu, meshMessageRef as J, EDIT_RATE_WINDOW_MS as Ja, settleRequest as Jc, newIdentityBinding as Ji, encodeContactLink as Jl, PAIRED_FRAME_TOO_LARGE as Jn, parseGroupCommit as Jo, STATUS_IDLE_AFTER_MS as Jr, handoffAttemptAllowed as Js, encodeDidDhtPacket as Jt, withRequestOptions as Ju, GROUP_EDIT_TEXT_BYTES as K, parseVideoMeta as Ka, newInbox as Kc, identityStatement as Ki, readCanonicalJson as Kl, INVITE_TAKEN as Kn, MEMBER_KEY as Ko, transferStalled as Kr, NO_ATTEMPTS as Ks, didDhtFromPublicKey as Kt, budgetRetryMs as Ku, groupWakes as L, PLAYABLE_AUDIO as La, enrollGrantFrame as Lc, IDENTITY_MAX_VALIDITY as Li, readAppRevocationShape as Ll, NO_VIDEO_METADATA as Ln, MESSAGE_CLOCK_SKEW_MS as Lo, readBeacon as Lr, HANDOFF_DONE as Ls, normalizeDid as Lt, RelayTransport as Lu, mergeKnocks as M, DHT_FILE_CAPABILITY as Ma, ENROLL_PROOF as Mc, CapsExchange as Mi, isAppHash as Ml, fedimintRequestPayload as Mn, cardUrl as Mo, mergeBeacon as Mr, HTTP_SERVICE_PROTO as Ms, didWebDocumentUrl as Mt, turnStatedVerifier as Mu, readKnocks as N, dhtFileId as Na, enrollCancelFrame as Nc, DHT_TEXT_CAPABILITY as Ni, isAppKey as Nl, findEndpoint as Nn, checkStatusCard as No, mergeLobby as Nr, LEGACY_SERVICES as Ns, didWebFile as Nt, turnVerifierMark as Nu, encodeGroupEntryLink as O, ACTIVE_DHT_POLL_MS as Oa, verifySetUpdate as Oc, BUTTONS_CAPABILITY as Oi, appFingerprint as Ol, resolveLightningDestination as On, appCardId as Oo, freshHubs as Or, extractParamsFromSdp as Os, checkDidSignature as Ot, signTurnRelease as Ou, GROUP_WAKE_FRAME as P, formatFileSize as Pa, enrollCancelReason as Pc, capsDescriptors as Pi, isAppLine as Pl, isFederationId as Pn, sameButtonText as Po, newerHead as Pr, serviceIdFromName as Ps, didWebFileNames as Pt, DEFAULT_RELAYS as Pu, SSHSIG_MAX_ARMOR as Q, dhtEditId as Qa, REQUEST_LIFETIME_MS as Qc, PeerProofs as Qi, readDeviceInvite as Ql, EngineError as Qn, edgeParams as Qo, TYPING_KINDS as Qr, handoffCancelFrame as Qs, EVM_TEST_CHAINS as Qt, newerPacket as Qu, parseGroupWakeFrame as R, VOICE_LIMITS as Ra, enrollHelloFrame as Rc, IDENTITY_REVOCATION_LABEL as Ri, readAppRevocations as Rl, videoMetadataPatches as Rn, arrivalKey as Ro, readBeaconHead as Rr, HANDOFF_HAVE as Rs, parseDid as Rt, RelaysFailedError as Ru, GROUP_READ_NOTE_COMMUNITY as S, normalizeDomain as Sa, SET_ACK as Sc, APP_RANGE_LIMITS as Si, pacer as Sl, pubkyProofCapability as Sn, PR_CHECKS as So, meshHubs as Sr, RTC_CONFIG as Ss, verifyAtprotoRecordProof as St, TURN_LAST_SEQUENCE as Su, encodeCommunityLink as T, recordsName as Ta, setAckFrame as Tc, chatAppId as Ti, sha256Paced as Tl, homeserverWebEndpoint as Tn, RUN_RESULTS as To, beaconKeys as Tr, callRtcConfig as Ts, DID_JWS_MAX_LENGTH as Tt, nextTurnPosition as Tu, frameBytes as U, parseVoiceMeta as Ua, clearMissed as Uc, emptyIdentityLedger as Ui, readImageMeta as Ul, stripPictureMetadata as Un, GROUP_ADMIN_OFF_ERROR as Uo, FileUplink as Ur, HANDOFF_REQUEST as Us, strictBase64Url as Ut, setLinkTraceSink as Uu, GROUP_READ_NOTE as V, downsamplePeaks as Va, readEnrollHello as Vc, boundIdentityDisplay as Vi, signAppRevocation as Vl, PICTURE_METADATA_LIMITS as Vn, receivedTimestamp as Vo, ChatFiles as Vr, HANDOFF_PAKE as Vs, signingKeys as Vt, normalizeRelayUrl as Vu, COMMUNITY_EDIT_FRAME as W, voiceDownloadName as Wa, endedRequests as Wc, identityRefusal as Wi, canonicalJson as Wl, withoutPictureMetadata as Wn, GROUP_MEMBER_CAP as Wo, sentWhole as Wr, HANDOFF_TIMINGS as Ws, DidDhtError as Wt, traceLink as Wu, mentionsMember as X, REMOVED_TEXT as Xa, turnOff as Xc, revokesIdentity as Xi, createDeviceInvite as Xl, pairedMessageFits as Xn, rosterHas as Xo, personStatus as Xr, handoffAttemptSucceeded as Xs, signDidDhtPacket as Xt, RELAY_PAYLOAD_MAX_BYTES as Xu, parseCommunityEdit as Y, MAX_REMOVAL_NUMBER as Ya, takeRequest as Yc, receivedIdentityStatus as Yi, readContactLink as Yl, pairedEditFits as Yn, rosterAdmin as Yo, liveStatus as Yr, handoffAttemptFailed as Ys, resolveDidDht as Yt, PacketTooLargeError as Yu, groupName as Z, RateWindow as Za, ContactRequestError as Zc, lastSharedWithMe as Zi, deviceInviteJoinerParams as Zl, pairedMessageFrame as Zn, verifyCommitSignature as Zo, sanitizeStatusText as Zr, handoffBusyFrame as Zs, ETHEREUM_USDT as Zt, createRelayPayload as Zu, groupTypingEpoch as _, domainTxtRecord as _a, readHandoffHello as _c, utf8Decode as _d, parseWakeFrame as _i, appDigest as _l, PUBKY_PROOF_MAX_BYTES as _n, replySnippet as _o, SIGNAL_REPLY_MS as _r, decodeControl as _s, isAtprotoDid as _t, TURN_PUT_WINDOW_MS as _u, appRevocationFor as a, irohRelayUrl as aa, handoffManifestFrames as ac, verify as ad, mayPin as ai, linkRecords as al, WALLET_NETWORKS as an, GROUP_REACTION_FRAME as ao, GROUP_WANT_NO_FRAME as ar, DAEMON_WATCH_PEER_IDLE_MS as as, verifySshSignature as at, ownInviteRefusal as au, COMMUNITY_LIMITS as b, isPublicAddress as ba, readHandoffVerified as bc, checkPushEndpoint as bi, checkAppManifest as bl, newPubkyProofFolder as bn, CRON_LINE as bo, MESH_HUBS as br, CALL_SIGNAL_MAX_AGE_MS as bs, shortAtprotoDid as bt, classifyTurnRead as bu, checkAppBeforeRun as c, HOLD_LIMITS as ca, handoffReleaseFrame as cc, hasVisible as cd, pinNumberHolds as ci, openRequest as cl, assertWholeSats as cn, nextReactionNumber as co, isGroupMessageId as cr, PRESENCE_WINDOW as cs, decodeAnyBitcoinAddress as ct, HANDOFF_CAPABILITY as cu, checkAppStoreIndex as d, isHoldUrl as da, handoffVersions as dc, bytesEqual as dd, WAKE_ONLINE_BATCH_MS as di, requestRecords as dl, walletNetworkOf as dn, reactionIsNewer as do, readGroupWant as dr, presenceSeenAt as ds, ATPROTO_PROOF_COLLECTION as dt, deviceKeyZ32 as du, validExternalKey as ea, handoffContextProof as ec, parseRelayPayload as ed, TypingSender as ei, contactAskerHolds as el, PaymentPreflightError as en, linkStop as eo, engineText as er, RatchetBox as es, SshSigError as et, createChatInvite as eu, readAppStore as f, newMailbox as fa, newHandoffId as fc, fromBase64Url as fd, WAKE_ONLINE_DELAY_MS as fi, seenEntry as fl, SPARK_NETWORKS as fn, readReaction as fo, readGroupWantNo as fr, GhostlyHttpError as fs, ATPROTO_PROOF_SCOPE as ft, deviceLinkPairing as fu, GroupTypingBoard as g, dnsProofName as ga, readHandoffHave as gc, toZ32 as gd, newWakeToken as gi, APP_PERMISSIONS as gl, isBitcoinAddress as gn, readReply as go, SIGNAL_HOLD_MS as gr, LIMITS as gs, checkAtprotoProofRecord as gt, webCryptoSigner as gu, GROUP_TYPING_FRAME as h, decodeDnsResponse as ha, readHandoffDone as hc, toBase64Url as hd, deviceWakeRequest as hi, APP_ICON_PATH as hl, sparkInvoiceDetails as hn, pairedReplyAuthor as ho, SIGNAL_FRESH_MS as hr, webLocalFetch as hs, atprotoProofRkey as ht, seedSigner as hu, addedAppPermissions as i, irohDescriptor as ia, handoffHelloFrame as ic, publicKeyFromZ32 as id, PIN_LIMITS as ii, knockSlotRecords as il, USDT_PUBLIC_RPC as in, COMMUNITY_REACTION_FRAME as io, GROUP_WANT_FRAME as ir, AWAITING_PEER_MS as is, sshSignCommand as it, inviteOwnership as iu, knockRecords as j, peekDhtMailbox as ja, ENROLL_HELLO as jc, UPGRADE_CAPABILITY as ji, checkAppRevokeStatement as jl, cashuRequestPayload as jn, cardLine as jo, lobbyRecords as jr, emptyLinkRecords as js, didSignedMessages as jt, turnName as ju, entryParams as k, DHT_FILE_TOO_LARGE as ka, ENROLL_DONE as kc, EDIT_CAPABILITY as ki, appRef as kl, decodeBolt11 as kn, appCardUrl as ko, hubRank as kr, parseCallSignal as ks, didGhostlyServiceEntry as kt, turnInstance as ku, planAppUpdate as l, HoldKeys as la, handoffRetryAfter as lc, sanitizeDisplayText as ld, readPin as li, readKnockSlot as ll, formatPaymentAmount as ln, queueReaction as lo, readGroupFileMeta as lr, RELAY_POLL_INTERVALS as ls, ATPROTO_DECLARED_SCOPE as lt, deviceEchoFrame as lu, signAppStore as m, DOMAIN_FILE_MAX_BYTES as ma, readHandoffCancel as mc, randomBytes as md, WakeLimiter as mi, APP_BUNDLE_MAGIC as ml, sparkAddressKind as mn, wireReaction as mo, GROUP_SIGNAL_FRAME as mr, parseLocalTarget as ms, atprotoProofRecord as mt, newDeviceSetSecret as mu, readX401SdJwtVc as n, automaticTransport as na, handoffDigest as nc, identityFromSeed as nd, typingActivity as ni, knockSlotIdentity as nl, SEPOLIA_TEST_USDT_FAUCET as nn, forwardedAgain as no, GROUP_FILE_LIMITS as nr, ratchetSessionOf as ns, parseSshSignature as nt, encodeInviteCode as nu, appStoreDecision as o, HOLD_CAPABILITY as oa, handoffOfferFrame as oc, MAX_AVATAR_LENGTH as od, nextPinNumber as oi, makeStampPaced as ol, arkAddressPrefix as on, REACTION_LIMITS as oo, fetchesByItself as or, DHT_POLL_INTERVALS as os, verifyBitcoinMessage as ot, DEVICES_CAPABILITY as ou, readAppStoreSteps as p, readManifest as pa, readHandoffAck as pc, isZ32Key as pd, WAKE_ONLINE_INTERVAL_MS as pi, APP_BUNDLE_LIMITS as pl, SPARK_PROVIDER as pn, validReactionNumber as po, CarriedTransport as pr, formatLocalTarget as ps, atprotoDidMethod as pt, devicePingFrame as pu, carryMentions as q, EDIT_BUFFER_MS as qa, planKnocks as qc, isIdentityBinding as qi, createContactLink as ql, LIVENESS_PING_MS as qn, commitHash as qo, STATUS_AVAILABILITIES as qr, filePartName as qs, encodeDidDhtDeactivated as qt, isDiscoveryBudgetError as qu, sameX401HolderJwk as r, dialableIrohRelay as ra, handoffEphemeral as rc, identityFromSeedB64 as rd, GROUP_PIN_FRAME as ri, knockSlotOf as rl, TEST_USDT_FAUCET_AMOUNT as rn, readForwarded as ro, GROUP_HAVE_FRAME as rr, DirectPathWatch as rs, sameSshKey as rt, inviteLink as ru, appUpdateDecision as s, HOLD_DATED_BACK_MS as sa, handoffPakeFrame as sc, sanitizeAvatar as sd, pinIsNewer as si, mergeContactKnocks as sl, assertTokenUnits as sn, ReactionWindow as so, groupFileFallback as sr, EXPECT_PEER_MS as ss, BitcoinAddressError as st, ENROLL_CAPABILITY as su, newX401HolderKey as t, TRANSPORTS as ta, handoffDataFrame as tc, createIdentity as td, sanitizeTypingStatus as ti, contactDay as tl, SEPOLIA_TEST_USDT as tn, parseLinkPreview as to, parseEngineError as tr, emptyRatchetState as ts, parseSshPublicKey as tt, decodeInviteCode as tu, APP_STORE_LIMITS as u, HoldRefusedError as ua, handoffStreamKey as uc, stripHidden as ud, WAKE_CALL_INTERVAL_MS as ui, readLinkRecord as ul, validatePaymentTarget as un, reactionEmoji as uo, readGroupHave as ur, WATCH_PEER_MS as us, ATPROTO_FULL_SCOPE as ut, deviceEchoNonce as uu, openGroupTyping as v, domainWellKnownFile as va, readHandoffPake as vc, utf8Encode as vd, relayRequest as vi, appViewOf as vl, isPubkyKey as vn, BUTTON_ID as vo, groupSignalFrame as vr, encodeControl as vs, normalizeAtprotoHandle as vt, TURN_RAISE_READ_TIMEOUT_MS as vu, decodeCommunityLink as w, recordsFromWellKnown as wa, readSetUpdate as wc, APP_DATA_MAX_BYTES as wi, readAppBundleAsync as wl, pubkyProofPath as wn, ROUTINE_STATES as wo, COMMUNITY_TOPOLOGY as wr, buildSdpFromSignal as ws, DID_FILE_MAX_BYTES as wt, firstDeviceSetSecret as wu, CommunitySession as x, nip05RootKey as xa, sealHandoffPiece as xc, vapidKeysMatch as xi, isAppUrl as xl, normalizePubkyKey as xn, ITEM_STATES as xo, mayBeHub as xr, QUICK_REDIAL_MS as xs, AtprotoProofError as xt, turnPutSummary as xu, sealGroupTyping as y, encodeDnsQuery as ya, readHandoffTurnFrame as yc, wakeRequest as yi, assembleAppBundle as yl, isPubkyProofFolder as yn, BUTTON_STYLES as yo, readGroupSignal as yr, BURST_RING_MS as ys, parseAtprotoDidDocument as yt, TURN_SETTLE_MS as yu, GROUP_LIMITS as z, VOICE_METER as za, enrollProofFrame as zc, IdentityCheckUnavailable as zi, setAppSignatureFastPath as zl, withoutVideoMetadata as zn, claimedTime as zo, readLobby as zr, HANDOFF_HELLO as zs, parseDidDocument as zt, SLOW_MS as zu };
40570
+ export { SSHSIG_MAX_ARMOR as $, MAX_REMOVAL_NUMBER as $a, takeRequest as $c, receivedIdentityStatus as $i, readContactLink as $l, pairedEditFits as $n, rosterAdmin as $o, liveStatus as $r, handoffAttemptFailed as $s, EVM_TEST_CHAINS as $t, PacketTooLargeError as $u, knockIdentity as A, txtValue as Aa, setUpdateFrame as Ac, isAppVersion as Ai, APP_PREFIXES as Al, decodeBolt11 as An, STATUS_CARD_LIMITS as Ao, beaconRecords as Ar, callSignalHeardAt as As, didGhostlyServiceEntry as At, readTurnPacket as Au, GROUP_REACTED_FRAME as B, sanitizeMime as Ba, enrollDoneFrame as Bc, IDENTITY_MAX_EVIDENCE as Bi, readAppRevocation as Bl, withoutAudioMetadata as Bn, statusCardText as Bo, rankHubs as Br, HANDOFF_CANCEL as Bs, parseDidDocument as Bt, HEDGE_MS as Bu, communityHasFrame as C, encodeDnsQuery as Ca, readHandoffTurnFrame as Cc, utf8Encode as Cd, wakeRequest as Ci, assembleAppBundle as Cl, pubkyProofCapability as Cn, BUTTON_STYLES as Co, readGroupSignal as Cr, BURST_RING_MS as Cs, verifyAtprotoRecordProof as Ct, TURN_SETTLE_MS as Cu, decodeGroupEntryLink as D, recordsFromTxt as Da, SET_UPDATE as Dc, isServeId as Di, readAppBundle as Dl, pubkyHomeserverOf as Dn, PR_STATES as Do, pickMeshHubs as Dr, answersOffer as Ds, DidError as Dt, TURN_MAX as Du, KNOCK_TTL_MS as E, normalizeDomain as Ea, SET_ACK as Ec, APP_RANGE_LIMITS as Ei, pacer as El, homeserverWebEndpoint as En, PR_CHECKS as Eo, meshHubs as Er, RTC_CONFIG as Es, DID_JWS_MAX_LENGTH as Et, TURN_LAST_SEQUENCE as Eu, GroupWakeLimiter as F, peekDhtMailbox as Fa, ENROLL_HELLO as Fc, UPGRADE_CAPABILITY as Fi, checkAppRevokeStatement as Fl, isFederationId as Fn, cardLine as Fo, lobbyRecords as Fr, emptyLinkRecords as Fs, didWebFileNames as Ft, turnName as Fu, COMMUNITY_EDIT_FRAME as G, downsamplePeaks as Ga, readEnrollHello as Gc, boundIdentityDisplay as Gi, signAppRevocation as Gl, PICTURE_METADATA_LIMITS as Gn, receivedTimestamp as Go, ChatFiles as Gr, HANDOFF_PAKE as Gs, DidDhtError as Gt, normalizeRelayUrl as Gu, GroupSession as H, VOICE_LIMITS as Ha, enrollHelloFrame as Hc, IDENTITY_REVOCATION_LABEL as Hi, readAppRevocations as Hl, videoMetadataPatches as Hn, arrivalKey as Ho, readBeaconHead as Hr, HANDOFF_HAVE as Hs, signingKeys as Ht, RelaysFailedError as Hu, groupWakeFrame as I, DHT_FILE_CAPABILITY as Ia, ENROLL_PROOF as Ic, CapsExchange as Ii, isAppHash as Il, parseCashuRequestPayload as In, cardUrl as Io, mergeBeacon as Ir, HTTP_SERVICE_PROTO as Is, didWebFileUrl as It, turnStatedVerifier as Iu, carryMentions as J, voiceDownloadName as Ja, endedRequests as Jc, identityRefusal as Ji, canonicalJson as Jl, withoutPictureMetadata as Jn, GROUP_MEMBER_CAP as Jo, sentWhole as Jr, HANDOFF_TIMINGS as Js, encodeDidDhtDeactivated as Jt, traceLink as Ju, GROUP_EDIT_FRAME as K, fileMessageText as Ka, verifyEnrollProof as Kc, boundVerifiedIdentity as Ki, parseImageMeta as Kl, isStrippedPicture as Kn, shownTime as Ko, FILE_LIMITS as Kr, HANDOFF_PIECE_BYTES as Ks, didDhtDocument as Kt, relayUrlProblem as Ku, groupWakes as L, dhtFileId as La, enrollCancelFrame as Lc, DHT_TEXT_CAPABILITY as Li, isAppKey as Ll, parseFedimintRequestPayload as Ln, checkStatusCard as Lo, mergeLobby as Lr, LEGACY_SERVICES as Ls, didWebHost as Lt, turnVerifierMark as Lu, mergeKnocks as M, ACTIVE_DHT_POLL_MS as Ma, verifySetUpdate as Mc, BUTTONS_CAPABILITY as Mi, appFingerprint as Ml, cashuRequestPayload as Mn, appCardId as Mo, freshHubs as Mr, extractParamsFromSdp as Ms, didSignedMessages as Mt, signTurnRelease as Mu, readKnocks as N, DHT_FILE_TOO_LARGE as Na, ENROLL_DONE as Nc, EDIT_CAPABILITY as Ni, appRef as Nl, fedimintRequestPayload as Nn, appCardUrl as No, hubRank as Nr, parseCallSignal as Ns, didWebDocumentUrl as Nt, turnInstance as Nu, encodeGroupEntryLink as O, recordsFromWellKnown as Oa, readSetUpdate as Oc, APP_DATA_MAX_BYTES as Oi, readAppBundleAsync as Ol, requestLnurlInvoice as On, ROUTINE_STATES as Oo, COMMUNITY_TOPOLOGY as Or, buildSdpFromSignal as Os, checkDidJws as Ot, firstDeviceSetSecret as Ou, GROUP_WAKE_FRAME as P, DHT_MESSAGE_TTL as Pa, ENROLL_GRANT as Pc, STATUS_CARD_CAPABILITY as Pi, appRefPublisher as Pl, findEndpoint as Pn, buttonLabelClash as Po, lobbyKeys as Pr, signalHasVideo as Ps, didWebFile as Pt, turnKeys as Pu, groupName as Q, EDIT_RATE_WINDOW_MS as Qa, settleRequest as Qc, newIdentityBinding as Qi, encodeContactLink as Ql, PAIRED_FRAME_TOO_LARGE as Qn, parseGroupCommit as Qo, STATUS_IDLE_AFTER_MS as Qr, handoffAttemptAllowed as Qs, ETHEREUM_USDT as Qt, withRequestOptions as Qu, parseGroupWakeFrame as R, formatFileSize as Ra, enrollCancelReason as Rc, capsDescriptors as Ri, isAppLine as Rl, NO_AUDIO_METADATA as Rn, sameButtonText as Ro, newerHead as Rr, serviceIdFromName as Rs, normalizeDid as Rt, DEFAULT_RELAYS as Ru, GROUP_READ_NOTE_COMMUNITY as S, domainWellKnownFile as Sa, readHandoffPake as Sc, utf8Decode as Sd, relayRequest as Si, appViewOf as Sl, normalizePubkyKey as Sn, BUTTON_ID as So, groupSignalFrame as Sr, encodeControl as Ss, AtprotoProofError as St, TURN_RAISE_READ_TIMEOUT_MS as Su, encodeCommunityLink as T, nip05RootKey as Ta, sealHandoffPiece as Tc, vapidKeysMatch as Ti, isAppUrl as Tl, pubkyProofPath as Tn, ITEM_STATES as To, mayBeHub as Tr, QUICK_REDIAL_MS as Ts, DID_FILE_MAX_BYTES as Tt, turnPutSummary as Tu, frameBytes as U, VOICE_METER as Ua, enrollProofFrame as Uc, IdentityCheckUnavailable as Ui, setAppSignatureFastPath as Ul, withoutVideoMetadata as Un, claimedTime as Uo, readLobby as Ur, HANDOFF_HELLO as Us, staticDidDocument as Ut, SLOW_MS as Uu, GROUP_READ_NOTE as V, PLAYABLE_AUDIO as Va, enrollGrantFrame as Vc, IDENTITY_MAX_VALIDITY as Vi, readAppRevocationShape as Vl, NO_VIDEO_METADATA as Vn, MESSAGE_CLOCK_SKEW_MS as Vo, readBeacon as Vr, HANDOFF_DONE as Vs, parseDidSignaturePaste as Vt, RelayTransport as Vu, CatchUpAnswers as W, baseMime as Wa, readEnrollGrant as Wc, IdentityExchange as Wi, signAppObject as Wl, NO_PICTURE_METADATA as Wn, heardTime as Wo, shouldBeHub as Wr, HANDOFF_OFFER as Ws, strictBase64Url as Wt, currentRelays as Wu, parseCommunityEdit as X, parseVideoMeta as Xa, newInbox as Xc, identityStatement as Xi, readCanonicalJson as Xl, INVITE_TAKEN as Xn, MEMBER_KEY as Xo, transferStalled as Xr, NO_ATTEMPTS as Xs, resolveDidDht as Xt, budgetRetryMs as Xu, meshMessageRef as Y, voiceLevel as Ya, inboxRecord as Yc, identityRevocationValue as Yi, canonicalJsonBytes as Yl, GhostLink as Yn, MAX_GROUP_CHAIN as Yo, transferEnded as Yr, HANDOFF_VERIFIED as Ys, encodeDidDhtPacket as Yt, DiscoveryBudgetError as Yu, mentionsMember as Z, EDIT_BUFFER_MS as Za, planKnocks as Zc, isIdentityBinding as Zi, createContactLink as Zl, LIVENESS_PING_MS as Zn, commitHash as Zo, STATUS_AVAILABILITIES as Zr, filePartName as Zs, signDidDhtPacket as Zt, isDiscoveryBudgetError as Zu, groupTypingEpoch as _, readManifest as _a, readHandoffAck as _c, fromBase64Url as _d, WAKE_ONLINE_INTERVAL_MS as _i, APP_BUNDLE_LIMITS as _l, isBitcoinAddress as _n, validReactionNumber as _o, CarriedTransport as _r, formatLocalTarget as _s, checkAtprotoProofRecord as _t, devicePingFrame as _u, appRevocationFor as a, TRANSPORTS as aa, handoffDataFrame as ac, createIdentity as ad, sanitizeTypingStatus as ai, contactDay as al, USDT_PUBLIC_RPC as an, parseLinkPreview as ao, parseEngineError as ar, emptyRatchetState as as, sshSignCommand as at, decodeInviteCode as au, COMMUNITY_LIMITS as b, dnsProofName as ba, readHandoffHave as bc, toBase64Url as bd, newWakeToken as bi, APP_PERMISSIONS as bl, isPubkyProofFolder as bn, readReply as bo, SIGNAL_HOLD_MS as br, LIMITS as bs, parseAtprotoDidDocument as bt, webCryptoSigner as bu, checkAppBeforeRun as c, irohDescriptor as ca, handoffHelloFrame as cc, publicKeyFromZ32 as cd, PIN_LIMITS as ci, knockSlotRecords as cl, assertTokenUnits as cn, COMMUNITY_REACTION_FRAME as co, GROUP_WANT_FRAME as cr, AWAITING_PEER_MS as cs, BitcoinAddressError as ct, inviteOwnership as cu, checkAppStoreIndex as d, HOLD_DATED_BACK_MS as da, handoffPakeFrame as dc, sanitizeAvatar as dd, pinIsNewer as di, mergeContactKnocks as dl, validatePaymentTarget as dn, ReactionWindow as do, groupFileFallback as dr, EXPECT_PEER_MS as ds, ATPROTO_FULL_SCOPE as dt, ENROLL_CAPABILITY as du, revokesIdentity as ea, handoffAttemptSucceeded as ec, RELAY_PAYLOAD_MAX_BYTES as ed, personStatus as ei, turnOff as el, ONCHAIN_PROVIDER as en, REMOVED_TEXT as eo, pairedMessageFits as er, rosterHas as es, SSHSIG_NAMESPACE as et, createDeviceInvite as eu, readAppStore as f, HOLD_LIMITS as fa, handoffReleaseFrame as fc, dropLoneJoiners as fd, pinNumberHolds as fi, openRequest as fl, walletNetworkOf as fn, nextReactionNumber as fo, isGroupMessageId as fr, PRESENCE_WINDOW as fs, ATPROTO_PROOF_COLLECTION as ft, HANDOFF_CAPABILITY as fu, GroupTypingBoard as g, newMailbox as ga, newHandoffId as gc, bytesEqual as gd, WAKE_ONLINE_DELAY_MS as gi, seenEntry as gl, sparkInvoiceDetails as gn, readReaction as go, readGroupWantNo as gr, GhostlyHttpError as gs, atprotoProofRkey as gt, deviceLinkPairing as gu, GROUP_TYPING_FRAME as h, isHoldUrl as ha, handoffVersions as hc, stripHidden as hd, WAKE_ONLINE_BATCH_MS as hi, requestRecords as hl, sparkAddressKind as hn, reactionIsNewer as ho, readGroupWant as hr, presenceSeenAt as hs, atprotoProofRecord as ht, deviceKeyZ32 as hu, addedAppPermissions as i, validExternalKey as ia, handoffContextProof as ic, parseRelayPayload as id, TypingSender as ii, contactAskerHolds as il, TEST_USDT_FAUCET_AMOUNT as in, linkStop as io, engineText as ir, RatchetBox as is, sameSshKey as it, createChatInvite as iu, knockRecords as j, wellKnownUrl as ja, signTombstone as jc, APPS_CAPABILITY as ji, APP_STATEMENT_LIMITS as jl, ENDPOINT as jn, TASK_STATUSES as jo, doorHubs as jr, contactRtcConfig as js, didJwsAlg as jt, signTurnPacket as ju, entryParams as k, recordsName as ka, setAckFrame as kc, chatAppId as ki, sha256Paced as kl, resolveLightningDestination as kn, RUN_RESULTS as ko, beaconKeys as kr, callRtcConfig as ks, checkDidSignature as kt, nextTurnPosition as ku, planAppUpdate as l, irohRelayUrl as la, handoffManifestFrames as lc, verify as ld, mayPin as li, linkRecords as ll, assertWholeSats as ln, GROUP_REACTION_FRAME as lo, GROUP_WANT_NO_FRAME as lr, DAEMON_WATCH_PEER_IDLE_MS as ls, decodeAnyBitcoinAddress as lt, ownInviteRefusal as lu, signAppStore as m, HoldRefusedError as ma, handoffStreamKey as mc, sanitizeDisplayText as md, WAKE_CALL_INTERVAL_MS as mi, readLinkRecord as ml, SPARK_PROVIDER as mn, reactionEmoji as mo, readGroupHave as mr, WATCH_PEER_MS as ms, atprotoDidMethod as mt, deviceEchoNonce as mu, readX401SdJwtVc as n, PeerProofs as na, handoffCancelFrame as nc, newerPacket as nd, TYPING_KINDS as ni, REQUEST_LIFETIME_MS as nl, SEPOLIA_TEST_USDT as nn, dhtEditId as no, EngineError as nr, edgeParams as ns, parseSshPublicKey as nt, readDeviceInvite as nu, appStoreDecision as o, automaticTransport as oa, handoffDigest as oc, identityFromSeed as od, typingActivity as oi, knockSlotIdentity as ol, WALLET_NETWORKS as on, forwardedAgain as oo, GROUP_FILE_LIMITS as or, ratchetSessionOf as os, verifySshSignature as ot, encodeInviteCode as ou, readAppStoreSteps as p, HoldKeys as pa, handoffRetryAfter as pc, hasVisible as pd, readPin as pi, readKnockSlot as pl, SPARK_NETWORKS as pn, queueReaction as po, readGroupFileMeta as pr, RELAY_POLL_INTERVALS as ps, ATPROTO_PROOF_SCOPE as pt, deviceEchoFrame as pu, GROUP_EDIT_TEXT_BYTES as q, parseVoiceMeta as qa, clearMissed as qc, emptyIdentityLedger as qi, readImageMeta as ql, stripPictureMetadata as qn, GROUP_ADMIN_OFF_ERROR as qo, FileUplink as qr, HANDOFF_REQUEST as qs, didDhtFromPublicKey as qt, setLinkTraceSink as qu, sameX401HolderJwk as r, emptyProofLedger as ra, handoffContext as rc, openRelayPayload as rd, TYPING_REFRESH_MS as ri, contactAskerFrame as rl, SEPOLIA_TEST_USDT_FAUCET as rn, LINK_TRAILING as ro, engineError as rr, RATCHET_CAPABILITY as rs, parseSshSignature as rt, OwnInviteError as ru, appUpdateDecision as s, dialableIrohRelay as sa, handoffEphemeral as sc, identityFromSeedB64 as sd, GROUP_PIN_FRAME as si, knockSlotOf as sl, arkAddressPrefix as sn, readForwarded as so, GROUP_HAVE_FRAME as sr, DirectPathWatch as ss, verifyBitcoinMessage as st, inviteLink as su, newX401HolderKey as t, lastSharedWithMe as ta, handoffBusyFrame as tc, createRelayPayload as td, sanitizeStatusText as ti, ContactRequestError as tl, PaymentPreflightError as tn, RateWindow as to, pairedMessageFrame as tr, verifyCommitSignature as ts, SshSigError as tt, deviceInviteJoinerParams as tu, APP_STORE_LIMITS as u, HOLD_CAPABILITY as ua, handoffOfferFrame as uc, MAX_AVATAR_LENGTH as ud, nextPinNumber as ui, makeStampPaced as ul, formatPaymentAmount as un, REACTION_LIMITS as uo, fetchesByItself as ur, DHT_POLL_INTERVALS as us, ATPROTO_DECLARED_SCOPE as ut, DEVICES_CAPABILITY as uu, openGroupTyping as v, DOMAIN_FILE_MAX_BYTES as va, readHandoffCancel as vc, isZ32Key as vd, WakeLimiter as vi, APP_BUNDLE_MAGIC as vl, PUBKY_PROOF_MAX_BYTES as vn, wireReaction as vo, GROUP_SIGNAL_FRAME as vr, parseLocalTarget as vs, isAtprotoDid as vt, newDeviceSetSecret as vu, decodeCommunityLink as w, isPublicAddress as wa, readHandoffVerified as wc, checkPushEndpoint as wi, checkAppManifest as wl, pubkyProofFile as wn, CRON_LINE as wo, MESH_HUBS as wr, CALL_SIGNAL_MAX_AGE_MS as ws, DID_DOCUMENT_MAX_BYTES as wt, classifyTurnRead as wu, CommunitySession as x, domainTxtRecord as xa, readHandoffHello as xc, toZ32 as xd, parseWakeFrame as xi, appDigest as xl, newPubkyProofFolder as xn, replySnippet as xo, SIGNAL_REPLY_MS as xr, decodeControl as xs, shortAtprotoDid as xt, TURN_PUT_WINDOW_MS as xu, sealGroupTyping as y, decodeDnsResponse as ya, readHandoffDone as yc, randomBytes as yd, deviceWakeRequest as yi, APP_ICON_PATH as yl, isPubkyKey as yn, pairedReplyAuthor as yo, SIGNAL_FRESH_MS as yr, webLocalFetch as ys, normalizeAtprotoHandle as yt, seedSigner as yu, GROUP_LIMITS as z, sanitizeFileName as za, enrollDigits as zc, dialDescriptors as zi, isAppRef as zl, audioMetadataPatches as zn, statusCardBytes as zo, pickHubs as zr, HANDOFF_ACK as zs, parseDid as zt, HEDGE_MISSING_MS as zu };
39675
40571
 
39676
- //# sourceMappingURL=src-BnpEQqzk.js.map
40572
+ //# sourceMappingURL=src-ChJijTlM.js.map