moqtail 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/model.mjs CHANGED
@@ -213,7 +213,7 @@ var TerminationError = class extends MOQtailError {
213
213
  * limitations under the License.
214
214
  */
215
215
  const MAX_VALUE_LENGTH = 2 ** 16 - 1;
216
- const MAX_U64 = 2n ** 64n - 1n;
216
+ const MAX_U64$2 = 2n ** 64n - 1n;
217
217
  /**
218
218
  * @public
219
219
  * Represents a key-value pair for MOQT protocol parameters.
@@ -222,6 +222,8 @@ const MAX_U64 = 2n ** 64n - 1n;
222
222
  * - If `typeValue` is **odd**, the value is a binary blob (`Uint8Array`) with a maximum length of 65535 bytes.
223
223
  *
224
224
  * Use {@link KeyValuePair.tryNewVarInt} for varint pairs and {@link KeyValuePair.tryNewBytes} for blob pairs.
225
+ * A Type whose own namespace fixes the value encoding overrides the parity rule; see
226
+ * {@link KeyValuePair.newBytes}.
225
227
  */
226
228
  var KeyValuePair = class KeyValuePair {
227
229
  /**
@@ -260,6 +262,17 @@ var KeyValuePair = class KeyValuePair {
260
262
  return new KeyValuePair(tv, v);
261
263
  }
262
264
  /**
265
+ * Creates a varint KeyValuePair for a Type whose namespace defines a numeric value
266
+ * regardless of parity. Prefer {@link KeyValuePair.tryNewVarInt}.
267
+ * @param typeValue - The key/type identifier; parity is not checked.
268
+ * @param value - The varint value.
269
+ */
270
+ static newVarInt(typeValue, value) {
271
+ const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
272
+ const v = typeof value === "number" ? BigInt(value) : value;
273
+ return new KeyValuePair(tv, v);
274
+ }
275
+ /**
263
276
  * Creates a new blob KeyValuePair.
264
277
  * @param typeValue - Must be odd.
265
278
  * @param value - The binary blob value.
@@ -270,8 +283,19 @@ var KeyValuePair = class KeyValuePair {
270
283
  static tryNewBytes(typeValue, value) {
271
284
  const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
272
285
  if (tv % 2n === 0n) throw new KeyValueFormattingError("KeyValuePair.tryNewBytes");
286
+ return KeyValuePair.newBytes(tv, value);
287
+ }
288
+ /**
289
+ * Creates a blob KeyValuePair for a Type whose namespace defines a byte-string
290
+ * value regardless of parity. Prefer {@link KeyValuePair.tryNewBytes}.
291
+ * @param typeValue - The key/type identifier; parity is not checked.
292
+ * @param value - The binary blob value.
293
+ * @throws LengthExceedsMaxError if value length exceeds 65535 bytes.
294
+ */
295
+ static newBytes(typeValue, value) {
296
+ const tv = typeof typeValue === "number" ? BigInt(typeValue) : typeValue;
273
297
  const len = value.length;
274
- if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.tryNewBytes", MAX_VALUE_LENGTH, len);
298
+ if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.newBytes", MAX_VALUE_LENGTH, len);
275
299
  return new KeyValuePair(tv, value);
276
300
  }
277
301
  /**
@@ -320,7 +344,7 @@ var KeyValuePair = class KeyValuePair {
320
344
  static deserializeDelta(buf, prevType) {
321
345
  const deltaType = buf.getVI();
322
346
  const typeValue = prevType + deltaType;
323
- if (typeValue > MAX_U64) throw new ProtocolViolationError("KeyValuePair.deserializeDelta", `previous type ${prevType} plus delta type ${deltaType} exceeds 2^64 - 1`);
347
+ if (typeValue > MAX_U64$2) throw new ProtocolViolationError("KeyValuePair.deserializeDelta", `previous type ${prevType} plus delta type ${deltaType} exceeds 2^64 - 1`);
324
348
  return KeyValuePair.deserializeValue(buf, typeValue);
325
349
  }
326
350
  /**
@@ -334,12 +358,20 @@ var KeyValuePair = class KeyValuePair {
334
358
  if (typeValue % 2n === 0n) {
335
359
  const value = buf.getVI();
336
360
  return new KeyValuePair(typeValue, value);
337
- } else {
338
- const len = buf.getNumberVI();
339
- if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.deserialize", MAX_VALUE_LENGTH, len);
340
- const value = buf.getBytes(len);
341
- return new KeyValuePair(typeValue, value);
342
361
  }
362
+ return KeyValuePair.deserializeBytesValue(buf, typeValue);
363
+ }
364
+ /**
365
+ * Reads a length-prefixed byte-string Value, independent of Type parity.
366
+ * @param buf - The buffer to read from.
367
+ * @param typeValue - The already-decoded Type.
368
+ * @throws LengthExceedsMaxError if the length exceeds 65535 bytes.
369
+ */
370
+ static deserializeBytesValue(buf, typeValue) {
371
+ const len = buf.getNumberVI();
372
+ if (len > MAX_VALUE_LENGTH) throw new LengthExceedsMaxError("KeyValuePair.deserializeBytesValue", MAX_VALUE_LENGTH, len);
373
+ const value = buf.getBytes(len);
374
+ return new KeyValuePair(typeValue, value);
343
375
  }
344
376
  /**
345
377
  * Checks if this pair is equal to another.
@@ -402,20 +434,20 @@ function deserializeKvpListUntilEmpty(buf) {
402
434
  return items;
403
435
  }
404
436
  /**
405
- * Checks if the KeyValuePair is a varint pair (even typeValue).
437
+ * Checks if the KeyValuePair carries a varint value.
406
438
  * @param pair - The KeyValuePair to check.
407
439
  * @returns True if value is a varint.
408
440
  */
409
441
  function isVarInt(pair) {
410
- return pair.typeValue % 2n === 0n;
442
+ return typeof pair.value === "bigint";
411
443
  }
412
444
  /**
413
- * Checks if the KeyValuePair is a blob pair (odd typeValue).
445
+ * Checks if the KeyValuePair carries a blob value.
414
446
  * @param pair - The KeyValuePair to check.
415
447
  * @returns True if value is a Uint8Array.
416
448
  */
417
449
  function isBytes(pair) {
418
- return pair.typeValue % 2n !== 0n;
450
+ return pair.value instanceof Uint8Array;
419
451
  }
420
452
  //#endregion
421
453
  //#region src/model/common/location.ts
@@ -811,12 +843,12 @@ let TerminationCode = /* @__PURE__ */ function(TerminationCode) {
811
843
  TerminationCode[TerminationCode["DATA_STREAM_TIMEOUT"] = 18] = "DATA_STREAM_TIMEOUT";
812
844
  TerminationCode[TerminationCode["AUTH_TOKEN_CACHE_OVERFLOW"] = 19] = "AUTH_TOKEN_CACHE_OVERFLOW";
813
845
  TerminationCode[TerminationCode["DUPLICATE_AUTH_TOKEN_ALIAS"] = 20] = "DUPLICATE_AUTH_TOKEN_ALIAS";
814
- TerminationCode[TerminationCode["VERSION_NEGOTIATION_FAILED"] = 21] = "VERSION_NEGOTIATION_FAILED";
815
846
  TerminationCode[TerminationCode["MALFORMED_AUTH_TOKEN"] = 22] = "MALFORMED_AUTH_TOKEN";
816
847
  TerminationCode[TerminationCode["UNKNOWN_AUTH_TOKEN_ALIAS"] = 23] = "UNKNOWN_AUTH_TOKEN_ALIAS";
817
848
  TerminationCode[TerminationCode["EXPIRED_AUTH_TOKEN"] = 24] = "EXPIRED_AUTH_TOKEN";
818
849
  TerminationCode[TerminationCode["INVALID_AUTHORITY"] = 25] = "INVALID_AUTHORITY";
819
850
  TerminationCode[TerminationCode["MALFORMED_AUTHORITY"] = 26] = "MALFORMED_AUTHORITY";
851
+ TerminationCode[TerminationCode["TOO_MANY_REQUEST_UPDATES"] = 27] = "TOO_MANY_REQUEST_UPDATES";
820
852
  return TerminationCode;
821
853
  }({});
822
854
  (function(_TerminationCode) {
@@ -836,12 +868,12 @@ let TerminationCode = /* @__PURE__ */ function(TerminationCode) {
836
868
  case 18: return 18;
837
869
  case 19: return 19;
838
870
  case 20: return 20;
839
- case 21: return 21;
840
871
  case 22: return 22;
841
872
  case 23: return 23;
842
873
  case 24: return 24;
843
874
  case 25: return 25;
844
875
  case 26: return 26;
876
+ case 27: return 27;
845
877
  default: throw new InvalidTypeError("TerminationCode.tryFrom", `Unknown termination code: ${code}`);
846
878
  }
847
879
  }
@@ -866,8 +898,7 @@ let TerminationCode = /* @__PURE__ */ function(TerminationCode) {
866
898
  */
867
899
  /**
868
900
  * @public
869
- * Codes carried when resetting a request stream or sending STOP_SENDING on one, per
870
- * draft-18 §3.3.3.
901
+ * Codes carried when resetting a request stream or sending STOP_SENDING on one.
871
902
  *
872
903
  * A separate registry from {@link (RequestErrorCode:enum)}, which disagrees with it on
873
904
  * the same names: `GOING_AWAY` is `0x4` here but `0x6` there.
@@ -922,7 +953,7 @@ let StreamResetCode = /* @__PURE__ */ function(StreamResetCode) {
922
953
  */
923
954
  /**
924
955
  * @public
925
- * Object datagram types for MOQT objects (Draft-16).
956
+ * Object datagram types for MOQT objects.
926
957
  *
927
958
  * Type bit layout (form 0b00X0XXXX):
928
959
  * - Bit 0 (0x01): PROPERTIES - Properties field present
@@ -1226,7 +1257,7 @@ let ObjectStatus = /* @__PURE__ */ function(ObjectStatus) {
1226
1257
  * limitations under the License.
1227
1258
  */
1228
1259
  /**
1229
- * Represents a unified OBJECT_DATAGRAM message (Draft-16).
1260
+ * Represents a unified OBJECT_DATAGRAM message.
1230
1261
  *
1231
1262
  * Type bit layout (form 0b00X0XXXX):
1232
1263
  * - Bit 0 (0x01): PROPERTIES
@@ -1356,53 +1387,6 @@ var FetchHeader = class FetchHeader {
1356
1387
  }
1357
1388
  };
1358
1389
  //#endregion
1359
- //#region src/model/common/grease.ts
1360
- /**
1361
- * Copyright 2026 The MOQtail Authors
1362
- *
1363
- * Licensed under the Apache License, Version 2.0 (the "License");
1364
- * you may not use this file except in compliance with the License.
1365
- * You may obtain a copy of the License at
1366
- *
1367
- * http://www.apache.org/licenses/LICENSE-2.0
1368
- *
1369
- * Unless required by applicable law or agreed to in writing, software
1370
- * distributed under the License is distributed on an "AS IS" BASIS,
1371
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1372
- * See the License for the specific language governing permissions and
1373
- * limitations under the License.
1374
- */
1375
- /**
1376
- * GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
1377
- * several registries (Setup Options, Properties, error codes) so peers can emit them
1378
- * to exercise unknown-value handling. Receivers treat them like any other unknown
1379
- * value: ignore, never fatal.
1380
- */
1381
- /** Step between successive GREASE values. */
1382
- const GREASE_STEP = 127n;
1383
- /** The smallest GREASE value (N = 0). */
1384
- const GREASE_BASE = 157n;
1385
- /** The largest GREASE value that still fits a varint, i.e. `0x3fffffffffffffde`. */
1386
- const GREASE_MAX = 4611686018427387870n;
1387
- /**
1388
- * @public
1389
- * True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
1390
- * non-negative `N`.
1391
- */
1392
- function isGrease(value) {
1393
- const v = BigInt(value);
1394
- return v >= 157n && (v - 157n) % 127n === 0n;
1395
- }
1396
- /**
1397
- * @public
1398
- * The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
1399
- * varint can carry (the pattern is capped at `0x3fffffffffffffde`).
1400
- */
1401
- function greaseValue(n) {
1402
- const value = GREASE_STEP * BigInt(n) + GREASE_BASE;
1403
- return value > GREASE_MAX ? void 0 : value;
1404
- }
1405
- //#endregion
1406
1390
  //#region src/model/control/constant.ts
1407
1391
  /**
1408
1392
  * Copyright 2025 The MOQtail Authors
@@ -1422,21 +1406,10 @@ function greaseValue(n) {
1422
1406
  /**
1423
1407
  * Protocol string array exchanged in wt-available-protocols header
1424
1408
  */
1425
- const SUPPORTED_VERSIONS = ["moqt-18"];
1409
+ const SUPPORTED_VERSIONS = ["moqt-22"];
1426
1410
  /**
1427
1411
  * @public
1428
- * Control message types, per draft-18 Table 5.
1429
- *
1430
- * The comment on each member is the Stream column: `Control` is the control stream
1431
- * (§3.3), `Request` a bidirectional request stream, and `First` means the message MUST
1432
- * be the first on a new request stream.
1433
- *
1434
- * Table 5 reserves `0x01` (SETUP for version 00), `0x40`/`0x41` (CLIENT_SETUP /
1435
- * SERVER_SETUP for versions 10 and below) and `0x20`/`0x21` (CLIENT_SETUP /
1436
- * SERVER_SETUP for versions 16 and below — folded into Setup by #256). All five stay
1437
- * in the enum as documentation, but `tryFrom` rejects every RESERVED codepoint, which
1438
- * is what §10 requires — an endpoint receiving an unknown message type MUST close the
1439
- * session.
1412
+ * Control message types.
1440
1413
  */
1441
1414
  let ControlMessageType = /* @__PURE__ */ function(ControlMessageType) {
1442
1415
  ControlMessageType[ControlMessageType["ReservedSetupV00"] = 1] = "ReservedSetupV00";
@@ -1462,8 +1435,7 @@ let ControlMessageType = /* @__PURE__ */ function(ControlMessageType) {
1462
1435
  ControlMessageType[ControlMessageType["SubscribeTracks"] = 81] = "SubscribeTracks";
1463
1436
  ControlMessageType[ControlMessageType["Publish"] = 29] = "Publish";
1464
1437
  ControlMessageType[ControlMessageType["PublishOk"] = 30] = "PublishOk";
1465
- ControlMessageType[ControlMessageType["PublishBlocked"] = 15] = "PublishBlocked";
1466
- ControlMessageType[ControlMessageType["Switch"] = 34] = "Switch";
1438
+ ControlMessageType[ControlMessageType["PublishSkipped"] = 15] = "PublishSkipped";
1467
1439
  return ControlMessageType;
1468
1440
  }({});
1469
1441
  (function(_ControlMessageType) {
@@ -1520,48 +1492,45 @@ let ControlMessageType = /* @__PURE__ */ function(ControlMessageType) {
1520
1492
  })(ControlMessageType || (ControlMessageType = {}));
1521
1493
  /**
1522
1494
  * @public
1523
- * Filter types for subscription requests.
1524
- */
1525
- let FilterType = /* @__PURE__ */ function(FilterType) {
1526
- FilterType[FilterType["NextGroupStart"] = 1] = "NextGroupStart";
1527
- FilterType[FilterType["LatestObject"] = 2] = "LatestObject";
1528
- FilterType[FilterType["AbsoluteStart"] = 3] = "AbsoluteStart";
1529
- FilterType[FilterType["AbsoluteRange"] = 4] = "AbsoluteRange";
1530
- return FilterType;
1495
+ * Which fields of a LOCATION_FILTER follow its type, and how they are read.
1496
+ */
1497
+ let LocationFilterType = /* @__PURE__ */ function(LocationFilterType) {
1498
+ /** No filter: every Object passes. */
1499
+ LocationFilterType[LocationFilterType["None"] = 0] = "None";
1500
+ /** Starts StartGroup groups before the Next Group. */
1501
+ LocationFilterType[LocationFilterType["RelativeStart"] = 1] = "RelativeStart";
1502
+ LocationFilterType[LocationFilterType["AbsoluteStart"] = 2] = "AbsoluteStart";
1503
+ /** Ends with the last Object of the End Group. */
1504
+ LocationFilterType[LocationFilterType["AbsoluteStartGroupEnd"] = 3] = "AbsoluteStartGroupEnd";
1505
+ /** Ends with End Object of the End Group. */
1506
+ LocationFilterType[LocationFilterType["AbsoluteRange"] = 4] = "AbsoluteRange";
1507
+ /** Starts at the Object after the Largest Object. */
1508
+ LocationFilterType[LocationFilterType["NextObject"] = 5] = "NextObject";
1509
+ return LocationFilterType;
1531
1510
  }({});
1532
- (function(_FilterType) {
1511
+ (function(_LocationFilterType) {
1533
1512
  function tryFrom(v) {
1534
1513
  switch (v) {
1514
+ case 0n: return 0;
1535
1515
  case 1n: return 1;
1536
1516
  case 2n: return 2;
1537
1517
  case 3n: return 3;
1538
1518
  case 4n: return 4;
1539
- default: throw new InvalidEnumValue("FilterType.tryFrom", v);
1519
+ case 5n: return 5;
1520
+ default: throw new InvalidEnumValue("LocationFilterType.tryFrom", v);
1540
1521
  }
1541
1522
  }
1542
- _FilterType.tryFrom = tryFrom;
1543
- })(FilterType || (FilterType = {}));
1523
+ _LocationFilterType.tryFrom = tryFrom;
1524
+ })(LocationFilterType || (LocationFilterType = {}));
1544
1525
  /**
1545
1526
  * @public
1546
- * Fetch request types for MOQT protocol.
1527
+ * Switch modes for subscription switching requests.
1547
1528
  */
1548
- let FetchType = /* @__PURE__ */ function(FetchType) {
1549
- FetchType[FetchType["Standalone"] = 1] = "Standalone";
1550
- FetchType[FetchType["Relative"] = 2] = "Relative";
1551
- FetchType[FetchType["Absolute"] = 3] = "Absolute";
1552
- return FetchType;
1529
+ let SwitchMode = /* @__PURE__ */ function(SwitchMode) {
1530
+ SwitchMode[SwitchMode["Hard"] = 0] = "Hard";
1531
+ SwitchMode[SwitchMode["Soft"] = 1] = "Soft";
1532
+ return SwitchMode;
1553
1533
  }({});
1554
- (function(_FetchType) {
1555
- function tryFrom(v) {
1556
- switch (v) {
1557
- case 1n: return 1;
1558
- case 2n: return 2;
1559
- case 3n: return 3;
1560
- default: throw new InvalidEnumValue("FetchType.tryFrom", v);
1561
- }
1562
- }
1563
- _FetchType.tryFrom = tryFrom;
1564
- })(FetchType || (FetchType = {}));
1565
1534
  /**
1566
1535
  * @public
1567
1536
  * Group ordering options for object delivery.
@@ -1616,7 +1585,6 @@ let PublishDoneStatusCode = /* @__PURE__ */ function(PublishDoneStatusCode) {
1616
1585
  PublishDoneStatusCode[PublishDoneStatusCode["InternalError"] = 0] = "InternalError";
1617
1586
  PublishDoneStatusCode[PublishDoneStatusCode["Unauthorized"] = 1] = "Unauthorized";
1618
1587
  PublishDoneStatusCode[PublishDoneStatusCode["TrackEnded"] = 2] = "TrackEnded";
1619
- PublishDoneStatusCode[PublishDoneStatusCode["SubscriptionEnded"] = 3] = "SubscriptionEnded";
1620
1588
  PublishDoneStatusCode[PublishDoneStatusCode["GoingAway"] = 4] = "GoingAway";
1621
1589
  PublishDoneStatusCode[PublishDoneStatusCode["TooFarBehind"] = 5] = "TooFarBehind";
1622
1590
  PublishDoneStatusCode[PublishDoneStatusCode["Expired"] = 6] = "Expired";
@@ -1631,7 +1599,6 @@ let PublishDoneStatusCode = /* @__PURE__ */ function(PublishDoneStatusCode) {
1631
1599
  case 0n: return 0;
1632
1600
  case 1n: return 1;
1633
1601
  case 2n: return 2;
1634
- case 3n: return 3;
1635
1602
  case 4n: return 4;
1636
1603
  case 5n: return 5;
1637
1604
  case 6n: return 6;
@@ -1670,13 +1637,14 @@ let RequestErrorCode = /* @__PURE__ */ function(RequestErrorCode) {
1670
1637
  RequestErrorCode[RequestErrorCode["DoesNotExist"] = 16] = "DoesNotExist";
1671
1638
  RequestErrorCode[RequestErrorCode["InvalidRange"] = 17] = "InvalidRange";
1672
1639
  RequestErrorCode[RequestErrorCode["MalformedTrack"] = 18] = "MalformedTrack";
1673
- RequestErrorCode[RequestErrorCode["DuplicateSubscription"] = 25] = "DuplicateSubscription";
1674
1640
  RequestErrorCode[RequestErrorCode["Uninterested"] = 32] = "Uninterested";
1675
1641
  RequestErrorCode[RequestErrorCode["PrefixOverlap"] = 48] = "PrefixOverlap";
1676
1642
  RequestErrorCode[RequestErrorCode["NamespaceTooLarge"] = 49] = "NamespaceTooLarge";
1677
- RequestErrorCode[RequestErrorCode["InvalidJoiningRequestId"] = 50] = "InvalidJoiningRequestId";
1643
+ RequestErrorCode[RequestErrorCode["InvalidSwitch"] = 50] = "InvalidSwitch";
1678
1644
  RequestErrorCode[RequestErrorCode["UnsupportedExtension"] = 51] = "UnsupportedExtension";
1679
1645
  RequestErrorCode[RequestErrorCode["Redirect"] = 52] = "Redirect";
1646
+ RequestErrorCode[RequestErrorCode["ConflictingFilters"] = 53] = "ConflictingFilters";
1647
+ RequestErrorCode[RequestErrorCode["InvalidFilter"] = 54] = "InvalidFilter";
1680
1648
  return RequestErrorCode;
1681
1649
  }({});
1682
1650
  (function(_RequestErrorCode) {
@@ -1693,13 +1661,14 @@ let RequestErrorCode = /* @__PURE__ */ function(RequestErrorCode) {
1693
1661
  case 16n: return 16;
1694
1662
  case 17n: return 17;
1695
1663
  case 18n: return 18;
1696
- case 25n: return 25;
1697
1664
  case 32n: return 32;
1698
1665
  case 48n: return 48;
1699
1666
  case 49n: return 49;
1700
1667
  case 50n: return 50;
1701
1668
  case 51n: return 51;
1702
1669
  case 52n: return 52;
1670
+ case 53n: return 53;
1671
+ case 54n: return 54;
1703
1672
  default: throw new InvalidEnumValue("RequestErrorCode.tryFrom", v);
1704
1673
  }
1705
1674
  }
@@ -1742,13 +1711,21 @@ const SUBGROUP_MODE_PRIOR_PLUS_ONE = 2;
1742
1711
  const SUBGROUP_MODE_PRESENT = 3;
1743
1712
  const END_OF_NON_EXISTENT_RANGE = 140n;
1744
1713
  const END_OF_UNKNOWN_RANGE = 268n;
1714
+ const END_OF_TIMED_OUT_RANGE = 524n;
1745
1715
  const MAX_VARINT = 2n ** 64n - 1n;
1746
1716
  /**
1747
- * Kind discriminator for End-of-Range markers (§11.5).
1717
+ * Kind discriminator for End-of-Range markers.
1748
1718
  */
1749
1719
  let EndOfRangeKind = /* @__PURE__ */ function(EndOfRangeKind) {
1720
+ /** Serialization Flags = 0x8C: all objects in the range are known not to exist. */
1750
1721
  EndOfRangeKind[EndOfRangeKind["NonExistent"] = 140] = "NonExistent";
1722
+ /** Serialization Flags = 0x10C: the range is cache-unknown. */
1751
1723
  EndOfRangeKind[EndOfRangeKind["Unknown"] = 268] = "Unknown";
1724
+ /**
1725
+ * Serialization Flags = 0x20C: the range timed out, e.g. a relay ran out of its
1726
+ * fill budget before it could retrieve it.
1727
+ */
1728
+ EndOfRangeKind[EndOfRangeKind["TimedOut"] = 524] = "TimedOut";
1752
1729
  return EndOfRangeKind;
1753
1730
  }({});
1754
1731
  /**
@@ -1783,11 +1760,20 @@ var FetchObject = class FetchObject {
1783
1760
  return this.location.object;
1784
1761
  }
1785
1762
  /**
1786
- * Context to thread into the next call on this stream.
1787
- * Returns null for EndOfRange markers — they MUST NOT update prior state.
1763
+ * What the entry after this one is encoded against, given what this one was
1764
+ * encoded against (`prev`).
1765
+ *
1766
+ * After an Object, that is the Object itself. After an End of Range marker, it is
1767
+ * the marker's Group and Object IDs, with the Subgroup ID and priority still those
1768
+ * of the last Object before the marker, or none if no Object came before it.
1788
1769
  */
1789
- toContext() {
1790
- if (this.kind === "end_of_range") return null;
1770
+ nextContext(prev) {
1771
+ if (this.kind === "end_of_range") return {
1772
+ groupId: this.groupId,
1773
+ subgroupId: prev?.subgroupId ?? null,
1774
+ objectId: this.objectId,
1775
+ publisherPriority: prev?.publisherPriority ?? null
1776
+ };
1791
1777
  return {
1792
1778
  groupId: this.groupId,
1793
1779
  subgroupId: this.subgroupId,
@@ -1804,7 +1790,7 @@ var FetchObject = class FetchObject {
1804
1790
  serialize(prev, groupOrder = 0) {
1805
1791
  const buf = new ByteBuffer();
1806
1792
  if (this.kind === "end_of_range") {
1807
- buf.putVI(this.endOfRange === 140 ? END_OF_NON_EXISTENT_RANGE : END_OF_UNKNOWN_RANGE);
1793
+ buf.putVI(BigInt(this.endOfRange));
1808
1794
  buf.putVI(this.groupId);
1809
1795
  buf.putVI(this.objectId);
1810
1796
  return buf.freeze();
@@ -1830,7 +1816,7 @@ var FetchObject = class FetchObject {
1830
1816
  let subgroupMode;
1831
1817
  if (isDatagram || this.subgroupId === 0n) subgroupMode = SUBGROUP_MODE_ZERO;
1832
1818
  else if (prev && prev.subgroupId === this.subgroupId) subgroupMode = SUBGROUP_MODE_PRIOR;
1833
- else if (prev && prev.subgroupId + 1n === this.subgroupId) subgroupMode = SUBGROUP_MODE_PRIOR_PLUS_ONE;
1819
+ else if (prev && prev.subgroupId !== null && prev.subgroupId + 1n === this.subgroupId) subgroupMode = SUBGROUP_MODE_PRIOR_PLUS_ONE;
1834
1820
  else subgroupMode = SUBGROUP_MODE_PRESENT;
1835
1821
  let flags = subgroupMode & FLAG_SUBGROUP_MODE_MASK;
1836
1822
  if (objectDelta !== null) flags |= FLAG_OBJECT_ID_PRESENT;
@@ -1854,6 +1840,7 @@ var FetchObject = class FetchObject {
1854
1840
  let kind;
1855
1841
  if (flagsRaw === END_OF_NON_EXISTENT_RANGE) kind = 140;
1856
1842
  else if (flagsRaw === END_OF_UNKNOWN_RANGE) kind = 268;
1843
+ else if (flagsRaw === END_OF_TIMED_OUT_RANGE) kind = 524;
1857
1844
  else throw new ProtocolViolationError("FetchObject.deserialize", `invalid Serialization Flags value 0x${flagsRaw.toString(16)}`);
1858
1845
  const groupId = buf.getVI();
1859
1846
  const objectId = buf.getVI();
@@ -1889,11 +1876,11 @@ var FetchObject = class FetchObject {
1889
1876
  subgroupId = 0n;
1890
1877
  break;
1891
1878
  case SUBGROUP_MODE_PRIOR:
1892
- if (!prev) throw new ProtocolViolationError("FetchObject.deserialize", "subgroup_id inherited but no prior object");
1879
+ if (!prev || prev.subgroupId === null) throw new ProtocolViolationError("FetchObject.deserialize", "subgroup_id inherited but no prior object");
1893
1880
  subgroupId = prev.subgroupId;
1894
1881
  break;
1895
1882
  case SUBGROUP_MODE_PRIOR_PLUS_ONE:
1896
- if (!prev) throw new ProtocolViolationError("FetchObject.deserialize", "subgroup_id inherited but no prior object");
1883
+ if (!prev || prev.subgroupId === null) throw new ProtocolViolationError("FetchObject.deserialize", "subgroup_id inherited but no prior object");
1897
1884
  subgroupId = prev.subgroupId + 1n;
1898
1885
  break;
1899
1886
  case SUBGROUP_MODE_PRESENT:
@@ -1915,7 +1902,7 @@ var FetchObject = class FetchObject {
1915
1902
  if (objectId > MAX_VARINT) throw new ProtocolViolationError("FetchObject.deserialize", `object id wraps: prior=${prev.objectId} +1`);
1916
1903
  }
1917
1904
  const publisherPriority = hasPriority ? buf.getU8() : (() => {
1918
- if (!prev) throw new ProtocolViolationError("FetchObject.deserialize", "priority inherited but no prior object");
1905
+ if (!prev || prev.publisherPriority === null) throw new ProtocolViolationError("FetchObject.deserialize", "priority inherited but no prior object");
1919
1906
  return prev.publisherPriority;
1920
1907
  })();
1921
1908
  let properties = null;
@@ -1953,7 +1940,7 @@ const MAX_FULL_TRACK_NAME_LENGTH = 4096;
1953
1940
  * Fully-qualified track identifier = hierarchical namespace (tuple) + leaf name bytes.
1954
1941
  *
1955
1942
  * Constraints enforced (throws {@link TrackNameError}):
1956
- * - Namespace tuple field count: 0 .. {@link MAX_NAMESPACE_TUPLE_COUNT} (draft-18 §2.4.1; an empty namespace is legal).
1943
+ * - Namespace tuple field count: 0 .. {@link MAX_NAMESPACE_TUPLE_COUNT} (an empty namespace is legal).
1957
1944
  * - Total serialized length (namespace tuple + raw name bytes) less than or equals {@link MAX_FULL_TRACK_NAME_LENGTH} bytes.
1958
1945
  *
1959
1946
  * Namespace input may be:
@@ -2050,11 +2037,12 @@ var FullTrackName = class FullTrackName {
2050
2037
  * limitations under the License.
2051
2038
  */
2052
2039
  let LOCPropertyId = /* @__PURE__ */ function(LOCPropertyId) {
2053
- LOCPropertyId[LOCPropertyId["Timestamp"] = 6] = "Timestamp";
2054
2040
  LOCPropertyId[LOCPropertyId["Timescale"] = 8] = "Timescale";
2055
- LOCPropertyId[LOCPropertyId["VideoFrameMarking"] = 10] = "VideoFrameMarking";
2041
+ LOCPropertyId[LOCPropertyId["VideoFrameMarking"] = 9] = "VideoFrameMarking";
2056
2042
  LOCPropertyId[LOCPropertyId["AudioLevel"] = 12] = "AudioLevel";
2057
2043
  LOCPropertyId[LOCPropertyId["VideoConfig"] = 13] = "VideoConfig";
2044
+ LOCPropertyId[LOCPropertyId["AudioConfig"] = 15] = "AudioConfig";
2045
+ LOCPropertyId[LOCPropertyId["Timestamp"] = 16] = "Timestamp";
2058
2046
  return LOCPropertyId;
2059
2047
  }({});
2060
2048
  let TrackPropertyType = /* @__PURE__ */ function(TrackPropertyType) {
@@ -2071,21 +2059,19 @@ let TrackPropertyType = /* @__PURE__ */ function(TrackPropertyType) {
2071
2059
  }({});
2072
2060
  function locPropertyIdFromNumber(value) {
2073
2061
  switch (value) {
2074
- case 6: return 6;
2075
2062
  case 8: return 8;
2076
- case 10: return 10;
2063
+ case 9: return 9;
2077
2064
  case 12: return 12;
2078
2065
  case 13: return 13;
2066
+ case 15: return 15;
2067
+ case 16: return 16;
2079
2068
  default: throw new InvalidTypeError("locPropertyIdFromNumber", `Invalid LOC property id: ${value}`);
2080
2069
  }
2081
2070
  }
2082
2071
  /**
2083
2072
  * @public
2084
- * Registration-policy ranges for the Property Type space (§15.8).
2073
+ * Registration-policy ranges for the Property Type space.
2085
2074
  *
2086
- * §2.5 gives the 1-byte application-specific range as `0x38-0x3F`; that is stale text
2087
- * from before draft-18's varint change, which made the 1-byte space `0x00-0x7F`.
2088
- * §15.8 is the correct table and is what these constants follow.
2089
2075
  */
2090
2076
  const PropertyRanges = {
2091
2077
  /** Standards Action or IESG Approval (1-byte encoding). */
@@ -2147,7 +2133,7 @@ function isApplicationSpecificProperty(typeValue) {
2147
2133
  */
2148
2134
  var Timestamp = class Timestamp {
2149
2135
  timestamp;
2150
- static TYPE = 6;
2136
+ static TYPE = 16;
2151
2137
  constructor(timestamp) {
2152
2138
  this.timestamp = timestamp;
2153
2139
  }
@@ -2205,17 +2191,24 @@ var Timescale = class Timescale {
2205
2191
  * See the License for the specific language governing permissions and
2206
2192
  * limitations under the License.
2207
2193
  */
2194
+ /** The I (independent frame) bit of the RFC 9626 flag octet. */
2195
+ const INDEPENDENT = 32;
2208
2196
  var VideoFrameMarking = class VideoFrameMarking {
2209
2197
  value;
2210
- static TYPE = 10;
2198
+ static TYPE = 9;
2199
+ /** The RFC 9626 frame-marking octets (1 to 4), without the length prefix. */
2211
2200
  constructor(value) {
2212
2201
  this.value = value;
2213
2202
  }
2203
+ /** True if the frame decodes without temporally prior frames (the I bit). */
2204
+ get independent() {
2205
+ return ((this.value[0] ?? 0) & INDEPENDENT) !== 0;
2206
+ }
2214
2207
  toKeyValuePair() {
2215
- return KeyValuePair.tryNewVarInt(VideoFrameMarking.TYPE, this.value);
2208
+ return KeyValuePair.tryNewBytes(VideoFrameMarking.TYPE, this.value);
2216
2209
  }
2217
2210
  static fromKeyValuePair(pair) {
2218
- if (Number(pair.typeValue) === VideoFrameMarking.TYPE && typeof pair.value === "bigint") return new VideoFrameMarking(pair.value);
2211
+ if (Number(pair.typeValue) === VideoFrameMarking.TYPE && pair.value instanceof Uint8Array) return new VideoFrameMarking(pair.value);
2219
2212
  }
2220
2213
  };
2221
2214
  //#endregion
@@ -2279,11 +2272,41 @@ var VideoConfig = class VideoConfig {
2279
2272
  }
2280
2273
  };
2281
2274
  //#endregion
2275
+ //#region src/model/property/audio_config.ts
2276
+ /**
2277
+ * Copyright 2026 The MOQtail Authors
2278
+ *
2279
+ * Licensed under the Apache License, Version 2.0 (the "License");
2280
+ * you may not use this file except in compliance with the License.
2281
+ * You may obtain a copy of the License at
2282
+ *
2283
+ * http://www.apache.org/licenses/LICENSE-2.0
2284
+ *
2285
+ * Unless required by applicable law or agreed to in writing, software
2286
+ * distributed under the License is distributed on an "AS IS" BASIS,
2287
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2288
+ * See the License for the specific language governing permissions and
2289
+ * limitations under the License.
2290
+ */
2291
+ var AudioConfig = class AudioConfig {
2292
+ config;
2293
+ static TYPE = 15;
2294
+ constructor(config) {
2295
+ this.config = config;
2296
+ }
2297
+ toKeyValuePair() {
2298
+ return KeyValuePair.tryNewBytes(AudioConfig.TYPE, this.config);
2299
+ }
2300
+ static fromKeyValuePair(pair) {
2301
+ if (Number(pair.typeValue) === AudioConfig.TYPE && pair.value instanceof Uint8Array) return new AudioConfig(pair.value);
2302
+ }
2303
+ };
2304
+ //#endregion
2282
2305
  //#region src/model/property/loc.ts
2283
2306
  let LOCProperty;
2284
2307
  (function(_LOCProperty) {
2285
2308
  function fromKeyValuePair(pair) {
2286
- return Timestamp.fromKeyValuePair(pair) || Timescale.fromKeyValuePair(pair) || VideoFrameMarking.fromKeyValuePair(pair) || AudioLevel.fromKeyValuePair(pair) || VideoConfig.fromKeyValuePair(pair);
2309
+ return Timestamp.fromKeyValuePair(pair) || Timescale.fromKeyValuePair(pair) || VideoFrameMarking.fromKeyValuePair(pair) || AudioLevel.fromKeyValuePair(pair) || VideoConfig.fromKeyValuePair(pair) || AudioConfig.fromKeyValuePair(pair);
2287
2310
  }
2288
2311
  _LOCProperty.fromKeyValuePair = fromKeyValuePair;
2289
2312
  function toKeyValuePair(header) {
@@ -2310,6 +2333,10 @@ let LOCProperty;
2310
2333
  return header instanceof VideoConfig;
2311
2334
  }
2312
2335
  _LOCProperty.isVideoConfig = isVideoConfig;
2336
+ function isAudioConfig(header) {
2337
+ return header instanceof AudioConfig;
2338
+ }
2339
+ _LOCProperty.isAudioConfig = isAudioConfig;
2313
2340
  })(LOCProperty || (LOCProperty = {}));
2314
2341
  var LOCProperties = class {
2315
2342
  kvps = [];
@@ -2321,8 +2348,9 @@ var LOCProperties = class {
2321
2348
  this.kvps.push(new Timescale(BigInt(timescale)).toKeyValuePair());
2322
2349
  return this;
2323
2350
  }
2324
- addVideoFrameMarking(marking) {
2325
- this.kvps.push(new VideoFrameMarking(BigInt(marking)).toKeyValuePair());
2351
+ /** Marks a whole, non-scalable frame (RFC 9626 short form): S and E set, I set on a keyframe. */
2352
+ addVideoFrameMarking(isKey) {
2353
+ this.kvps.push(new VideoFrameMarking(new Uint8Array([isKey ? 224 : 192])).toKeyValuePair());
2326
2354
  return this;
2327
2355
  }
2328
2356
  addAudioLevel(audioLevel) {
@@ -2333,6 +2361,10 @@ var LOCProperties = class {
2333
2361
  this.kvps.push(new VideoConfig(config).toKeyValuePair());
2334
2362
  return this;
2335
2363
  }
2364
+ addAudioConfig(config) {
2365
+ this.kvps.push(new AudioConfig(config).toKeyValuePair());
2366
+ return this;
2367
+ }
2336
2368
  addRaw(pair) {
2337
2369
  this.kvps.push(pair);
2338
2370
  return this;
@@ -2350,6 +2382,53 @@ var LOCProperties = class {
2350
2382
  }
2351
2383
  };
2352
2384
  //#endregion
2385
+ //#region src/model/common/grease.ts
2386
+ /**
2387
+ * Copyright 2026 The MOQtail Authors
2388
+ *
2389
+ * Licensed under the Apache License, Version 2.0 (the "License");
2390
+ * you may not use this file except in compliance with the License.
2391
+ * You may obtain a copy of the License at
2392
+ *
2393
+ * http://www.apache.org/licenses/LICENSE-2.0
2394
+ *
2395
+ * Unless required by applicable law or agreed to in writing, software
2396
+ * distributed under the License is distributed on an "AS IS" BASIS,
2397
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2398
+ * See the License for the specific language governing permissions and
2399
+ * limitations under the License.
2400
+ */
2401
+ /**
2402
+ * GREASE reservations (§14). Values matching `0x7f * N + 0x9D` are reserved across
2403
+ * several registries (Setup Options, Properties, error codes) so peers can emit them
2404
+ * to exercise unknown-value handling. Receivers treat them like any other unknown
2405
+ * value: ignore, never fatal.
2406
+ */
2407
+ /** Step between successive GREASE values. */
2408
+ const GREASE_STEP = 127n;
2409
+ /** The smallest GREASE value (N = 0). */
2410
+ const GREASE_BASE = 157n;
2411
+ /** The largest GREASE value that still fits a varint, i.e. `0x3fffffffffffffde`. */
2412
+ const GREASE_MAX = 4611686018427387870n;
2413
+ /**
2414
+ * @public
2415
+ * True if `value` is a reserved GREASE value, i.e. `0x7f * N + 0x9D` for some
2416
+ * non-negative `N`.
2417
+ */
2418
+ function isGrease(value) {
2419
+ const v = BigInt(value);
2420
+ return v >= 157n && (v - 157n) % 127n === 0n;
2421
+ }
2422
+ /**
2423
+ * @public
2424
+ * The `N`-th GREASE value, `0x7f * N + 0x9D`, or undefined if it would exceed what a
2425
+ * varint can carry (the pattern is capped at `0x3fffffffffffffde`).
2426
+ */
2427
+ function greaseValue(n) {
2428
+ const value = GREASE_STEP * BigInt(n) + GREASE_BASE;
2429
+ return value > GREASE_MAX ? void 0 : value;
2430
+ }
2431
+ //#endregion
2353
2432
  //#region src/model/property/track_property.ts
2354
2433
  /**
2355
2434
  * Copyright 2026 The MOQtail Authors
@@ -2674,7 +2753,7 @@ var SubgroupObject = class SubgroupObject {
2674
2753
  return new SubgroupObject(objectId, normalizeProperties(properties), null, payload);
2675
2754
  }
2676
2755
  serialize(previousObjectId) {
2677
- let objectIdDelta = previousObjectId ? this.objectId - previousObjectId - BigInt(1) : this.objectId;
2756
+ let objectIdDelta = previousObjectId !== void 0 ? this.objectId - previousObjectId - BigInt(1) : this.objectId;
2678
2757
  const buf = new ByteBuffer();
2679
2758
  buf.putVI(objectIdDelta);
2680
2759
  if (this.properties !== null) buf.putLengthPrefixedBytes(serializeKvpList(this.properties).toUint8Array());
@@ -2761,7 +2840,7 @@ var MoqtObject = class MoqtObject {
2761
2840
  return new MoqtObject(fullTrackName, location, publisherPriority, objectForwardingPreference, subgroupId, objectStatus, properties, null);
2762
2841
  }
2763
2842
  /**
2764
- * Create a MoqtObject from a Datagram (Draft-16).
2843
+ * Create a MoqtObject from a Datagram.
2765
2844
  * @param datagram - The received Datagram.
2766
2845
  * @param fullTrackName - The resolved full track name.
2767
2846
  * @param defaultPriority - The default publisher priority from the control message (used when DEFAULT_PRIORITY bit is set).
@@ -2788,7 +2867,7 @@ var MoqtObject = class MoqtObject {
2788
2867
  return new MoqtObject(fullTrackName, new Location(groupId, subgroupObject.objectId), publisherPriority ?? 128, "Subgroup", subgroupId, subgroupObject.objectStatus || 0, subgroupObject.properties, subgroupObject.payload);
2789
2868
  }
2790
2869
  /**
2791
- * Convert to Datagram for wire transmission (Draft-16).
2870
+ * Convert to Datagram for wire transmission.
2792
2871
  * Automatically creates a payload or status Datagram based on the object's state.
2793
2872
  * @param trackAlias - The track alias to use.
2794
2873
  * @param endOfGroup - Whether this is the last object in the group (only for payload datagrams).
@@ -3236,8 +3315,7 @@ var ByteBuffer = class extends BaseByteBuffer {
3236
3315
  }
3237
3316
  /**
3238
3317
  /**
3239
- * Encode a MOQT draft-18 varint using the minimal length.
3240
- * See section 1.4.1 https://datatracker.ietf.org/doc/draft-ietf-moq-transport/
3318
+ * Encode a MOQT varint using the minimal length.
3241
3319
  */
3242
3320
  putVI(v) {
3243
3321
  const value = typeof v === "number" ? BigInt(v) : v;
@@ -3308,7 +3386,7 @@ var FrozenByteBuffer = class extends BaseByteBuffer {
3308
3386
  }
3309
3387
  };
3310
3388
  //#endregion
3311
- //#region src/model/control/publish_blocked.ts
3389
+ //#region src/model/control/publish_skipped.ts
3312
3390
  /**
3313
3391
  * Copyright 2026 The MOQtail Authors
3314
3392
  *
@@ -3326,15 +3404,13 @@ var FrozenByteBuffer = class extends BaseByteBuffer {
3326
3404
  */
3327
3405
  /**
3328
3406
  * @public
3329
- * PUBLISH_BLOCKED (0xF): a publisher tells the peer it cannot send the PUBLISH that
3330
- * would start a subscription to a track under a SUBSCRIBE_TRACKS namespace, because it
3331
- * is blocked by the peer's bidirectional stream limit. It MUST NOT send PUBLISH for
3332
- * that track until the limit lifts (§10.20).
3407
+ * PUBLISH_SKIPPED (0xF): a publisher tells the peer it cannot send the PUBLISH that
3408
+ * would start a subscription to a track under a SUBSCRIBE_TRACKS namespace.
3333
3409
  *
3334
3410
  * Sent on the SUBSCRIBE_TRACKS response stream, so only the namespace suffix after that
3335
3411
  * subscription's prefix is carried.
3336
3412
  */
3337
- var PublishBlocked = class PublishBlocked {
3413
+ var PublishSkipped = class PublishSkipped {
3338
3414
  trackNamespaceSuffix;
3339
3415
  trackName;
3340
3416
  constructor(trackNamespaceSuffix, trackName) {
@@ -3351,7 +3427,7 @@ var PublishBlocked = class PublishBlocked {
3351
3427
  payload.putTuple(this.trackNamespaceSuffix);
3352
3428
  payload.putLengthPrefixedBytes(this.trackName);
3353
3429
  const payloadBytes = payload.toUint8Array();
3354
- if (payloadBytes.length > 65535) throw new LengthExceedsMaxError("PublishBlocked::serialize(payloadBytes.length)", 65535, payloadBytes.length);
3430
+ if (payloadBytes.length > 65535) throw new LengthExceedsMaxError("PublishSkipped::serialize(payloadBytes.length)", 65535, payloadBytes.length);
3355
3431
  buf.putU16(payloadBytes.length);
3356
3432
  buf.putBytes(payloadBytes);
3357
3433
  return buf.freeze();
@@ -3359,11 +3435,11 @@ var PublishBlocked = class PublishBlocked {
3359
3435
  static parsePayload(buf) {
3360
3436
  const trackNamespaceSuffix = buf.getTuple();
3361
3437
  const trackName = buf.getLengthPrefixedBytes();
3362
- return new PublishBlocked(trackNamespaceSuffix, trackName);
3438
+ return new PublishSkipped(trackNamespaceSuffix, trackName);
3363
3439
  }
3364
3440
  };
3365
3441
  //#endregion
3366
- //#region src/model/common/moqt_url.ts
3442
+ //#region src/model/parameter/constant.ts
3367
3443
  /**
3368
3444
  * Copyright 2026 The MOQtail Authors
3369
3445
  *
@@ -3379,68 +3455,193 @@ var PublishBlocked = class PublishBlocked {
3379
3455
  * See the License for the specific language governing permissions and
3380
3456
  * limitations under the License.
3381
3457
  */
3382
- /**
3383
- * @public
3384
- * A parsed `moqt://authority/path[?query][#fragment]` URI (draft-18 §3.1).
3385
- *
3386
- * `moqt-URI = "moqt" "://" authority path-abempty [ "?" query ]`, with an optional
3387
- * local-only fragment. `authority` is `host[:port]`; `path` keeps its leading `/`
3388
- * (empty when absent); `query` excludes the `?`.
3389
- *
3390
- * This is the TypeScript twin of `MoqtUrl` in `apps/client/src/connection.rs`; the two
3391
- * must agree on what a given URL means.
3392
- */
3393
- var MoqtUrl = class MoqtUrl {
3394
- authority;
3395
- path;
3396
- query;
3397
- fragment;
3398
- constructor(authority, path, query, fragment) {
3399
- this.authority = authority;
3400
- this.path = path;
3401
- this.query = query;
3402
- this.fragment = fragment;
3403
- }
3404
- static parse(input) {
3405
- if (!input.startsWith("moqt://")) throw new ProtocolViolationError("MoqtUrl.parse", `URL must use the moqt:// scheme: ${input}`);
3406
- let rest = input.slice(7);
3407
- let fragment;
3408
- const hashIdx = rest.indexOf("#");
3409
- if (hashIdx !== -1) {
3410
- fragment = parseFragment(rest.slice(hashIdx + 1));
3411
- rest = rest.slice(0, hashIdx);
3412
- }
3413
- let query;
3414
- const queryIdx = rest.indexOf("?");
3415
- if (queryIdx !== -1) {
3416
- query = rest.slice(queryIdx + 1);
3417
- rest = rest.slice(0, queryIdx);
3418
- }
3419
- const slashIdx = rest.indexOf("/");
3420
- const authority = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
3421
- const path = slashIdx === -1 ? "" : rest.slice(slashIdx);
3422
- if (authority.length === 0) throw new ProtocolViolationError("MoqtUrl.parse", `moqt:// URL has an empty authority: ${input}`);
3423
- return new MoqtUrl(authority, path, query, fragment);
3424
- }
3425
- /** The `path[?query]` string carried in the PATH setup option on native QUIC. */
3426
- pathAndQuery() {
3427
- return this.query !== void 0 ? `${this.path}?${this.query}` : this.path;
3428
- }
3429
- /** The equivalent `https://` URL for WebTransport, dropping the local fragment. */
3430
- toHttps() {
3431
- return `https://${this.authority}${this.pathAndQuery()}`;
3458
+ let SetupOptionType = /* @__PURE__ */ function(SetupOptionType) {
3459
+ SetupOptionType[SetupOptionType["Path"] = 1] = "Path";
3460
+ SetupOptionType[SetupOptionType["AuthorizationToken"] = 3] = "AuthorizationToken";
3461
+ SetupOptionType[SetupOptionType["MaxAuthTokenCacheSize"] = 4] = "MaxAuthTokenCacheSize";
3462
+ /** Raw-QUIC only. Client-only; MUST NOT be sent over WebTransport. */
3463
+ SetupOptionType[SetupOptionType["Authority"] = 5] = "Authority";
3464
+ SetupOptionType[SetupOptionType["MaxFilterRanges"] = 6] = "MaxFilterRanges";
3465
+ SetupOptionType[SetupOptionType["MoqtImplementation"] = 7] = "MoqtImplementation";
3466
+ SetupOptionType[SetupOptionType["MaxRequestUpdates"] = 8] = "MaxRequestUpdates";
3467
+ /**
3468
+ * PROVISIONAL: sender-side track switching is not an adopted extension, so this
3469
+ * codepoint is absent from the registry the conformance fixture tracks. It sits in the
3470
+ * 0x07-0x7F range of this space, which that registry leaves free.
3471
+ */
3472
+ SetupOptionType[SetupOptionType["SstsAlgorithms"] = 9] = "SstsAlgorithms";
3473
+ return SetupOptionType;
3474
+ }({});
3475
+ function setupOptionTypeFromNumber(value) {
3476
+ switch (value) {
3477
+ case 1: return 1;
3478
+ case 3: return 3;
3479
+ case 4: return 4;
3480
+ case 5: return 5;
3481
+ case 6: return 6;
3482
+ case 7: return 7;
3483
+ case 8: return 8;
3484
+ case 9: return 9;
3485
+ default: throw new InvalidTypeError("setupOptionTypeFromNumber", `Invalid setup option type: ${value}`);
3432
3486
  }
3433
- };
3434
- /**
3435
- * Parses a fragment `<type>:<value>`. The type identifier must be ASCII lowercase
3436
- * letters, digits, and hyphens; the value is opaque here.
3437
- */
3438
- function parseFragment(fragment) {
3439
- const colonIdx = fragment.indexOf(":");
3440
- if (colonIdx === -1) throw new ProtocolViolationError("MoqtUrl.parse", `moqt:// fragment must be <type>:<value>, got #${fragment}`);
3441
- const kind = fragment.slice(0, colonIdx);
3442
- if (kind.length === 0 || !/^[a-z0-9-]+$/.test(kind)) throw new ProtocolViolationError("MoqtUrl.parse", `moqt:// fragment type must be [a-z0-9-]+, got #${fragment}`);
3443
- return {
3487
+ }
3488
+ let MessageParameterType = /* @__PURE__ */ function(MessageParameterType) {
3489
+ MessageParameterType[MessageParameterType["ObjectDeliveryTimeout"] = 2] = "ObjectDeliveryTimeout";
3490
+ MessageParameterType[MessageParameterType["AuthorizationToken"] = 3] = "AuthorizationToken";
3491
+ MessageParameterType[MessageParameterType["RendezvousTimeout"] = 4] = "RendezvousTimeout";
3492
+ MessageParameterType[MessageParameterType["SubgroupDeliveryTimeout"] = 6] = "SubgroupDeliveryTimeout";
3493
+ MessageParameterType[MessageParameterType["Expires"] = 8] = "Expires";
3494
+ MessageParameterType[MessageParameterType["LargestObject"] = 9] = "LargestObject";
3495
+ MessageParameterType[MessageParameterType["FillTimeout"] = 10] = "FillTimeout";
3496
+ MessageParameterType[MessageParameterType["Forward"] = 16] = "Forward";
3497
+ MessageParameterType[MessageParameterType["SubscriberPriority"] = 32] = "SubscriberPriority";
3498
+ MessageParameterType[MessageParameterType["LocationFilter"] = 33] = "LocationFilter";
3499
+ MessageParameterType[MessageParameterType["GroupOrder"] = 34] = "GroupOrder";
3500
+ MessageParameterType[MessageParameterType["FillParameters"] = 35] = "FillParameters";
3501
+ MessageParameterType[MessageParameterType["SwitchFrom"] = 36] = "SwitchFrom";
3502
+ MessageParameterType[MessageParameterType["SubgroupFilter"] = 37] = "SubgroupFilter";
3503
+ MessageParameterType[MessageParameterType["ObjectIdFilter"] = 38] = "ObjectIdFilter";
3504
+ MessageParameterType[MessageParameterType["PriorityFilter"] = 39] = "PriorityFilter";
3505
+ MessageParameterType[MessageParameterType["ObjectPropertyFilter"] = 40] = "ObjectPropertyFilter";
3506
+ MessageParameterType[MessageParameterType["TrackPropertyFilter"] = 41] = "TrackPropertyFilter";
3507
+ MessageParameterType[MessageParameterType["NewGroupRequest"] = 50] = "NewGroupRequest";
3508
+ /**
3509
+ * Registered codepoint with no typed parameter yet: its consumer is REQUEST_UPDATE for
3510
+ * SUBSCRIBE_TRACKS (TS-11), and the value is a Track Namespace tuple rather than the
3511
+ * varint its even Type implies.
3512
+ */
3513
+ MessageParameterType[MessageParameterType["TrackNamespacePrefix"] = 52] = "TrackNamespacePrefix";
3514
+ MessageParameterType[MessageParameterType["IncludeProperties"] = 53] = "IncludeProperties";
3515
+ /**
3516
+ * PROVISIONAL: sender-side track switching is not an adopted extension, so this
3517
+ * codepoint is absent from the registry the conformance fixture tracks; see its
3518
+ * `local_extensions`.
3519
+ */
3520
+ MessageParameterType[MessageParameterType["SwitchingSetAssignment"] = 65] = "SwitchingSetAssignment";
3521
+ return MessageParameterType;
3522
+ }({});
3523
+ function messageParameterTypeFromNumber(value) {
3524
+ switch (Number(value)) {
3525
+ case 2: return 2;
3526
+ case 3: return 3;
3527
+ case 4: return 4;
3528
+ case 6: return 6;
3529
+ case 8: return 8;
3530
+ case 9: return 9;
3531
+ case 10: return 10;
3532
+ case 16: return 16;
3533
+ case 32: return 32;
3534
+ case 33: return 33;
3535
+ case 34: return 34;
3536
+ case 35: return 35;
3537
+ case 36: return 36;
3538
+ case 37: return 37;
3539
+ case 38: return 38;
3540
+ case 39: return 39;
3541
+ case 40: return 40;
3542
+ case 41: return 41;
3543
+ case 50: return 50;
3544
+ case 52: return 52;
3545
+ case 53: return 53;
3546
+ case 65: return 65;
3547
+ default: throw new InvalidTypeError("messageParameterTypeFromNumber", `Unknown message parameter type: ${value}`);
3548
+ }
3549
+ }
3550
+ let TokenAliasType = /* @__PURE__ */ function(TokenAliasType) {
3551
+ TokenAliasType[TokenAliasType["Delete"] = 0] = "Delete";
3552
+ TokenAliasType[TokenAliasType["Register"] = 1] = "Register";
3553
+ TokenAliasType[TokenAliasType["UseAlias"] = 2] = "UseAlias";
3554
+ TokenAliasType[TokenAliasType["UseValue"] = 3] = "UseValue";
3555
+ return TokenAliasType;
3556
+ }({});
3557
+ function tokenAliasTypeFromNumber(value) {
3558
+ switch (value) {
3559
+ case 0: return 0;
3560
+ case 1: return 1;
3561
+ case 2: return 2;
3562
+ case 3: return 3;
3563
+ default: throw new InvalidTypeError("tokenAliasTypeFromNumber", `Invalid token alias type: ${value}`);
3564
+ }
3565
+ }
3566
+ //#endregion
3567
+ //#region src/model/common/moqt_url.ts
3568
+ /**
3569
+ * Copyright 2026 The MOQtail Authors
3570
+ *
3571
+ * Licensed under the Apache License, Version 2.0 (the "License");
3572
+ * you may not use this file except in compliance with the License.
3573
+ * You may obtain a copy of the License at
3574
+ *
3575
+ * http://www.apache.org/licenses/LICENSE-2.0
3576
+ *
3577
+ * Unless required by applicable law or agreed to in writing, software
3578
+ * distributed under the License is distributed on an "AS IS" BASIS,
3579
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3580
+ * See the License for the specific language governing permissions and
3581
+ * limitations under the License.
3582
+ */
3583
+ /**
3584
+ * @public
3585
+ * A parsed `moqt://authority/path[?query][#fragment]` URI.
3586
+ *
3587
+ * `moqt-URI = "moqt" "://" authority path-abempty [ "?" query ]`, with an optional
3588
+ * local-only fragment. `authority` is `host[:port]`; `path` keeps its leading `/`
3589
+ * (empty when absent); `query` excludes the `?`.
3590
+ *
3591
+ * This is the TypeScript twin of `MoqtUrl` in `apps/client/src/connection.rs`; the two
3592
+ * must agree on what a given URL means.
3593
+ */
3594
+ var MoqtUrl = class MoqtUrl {
3595
+ authority;
3596
+ path;
3597
+ query;
3598
+ fragment;
3599
+ constructor(authority, path, query, fragment) {
3600
+ this.authority = authority;
3601
+ this.path = path;
3602
+ this.query = query;
3603
+ this.fragment = fragment;
3604
+ }
3605
+ static parse(input) {
3606
+ if (!input.startsWith("moqt://")) throw new ProtocolViolationError("MoqtUrl.parse", `URL must use the moqt:// scheme: ${input}`);
3607
+ let rest = input.slice(7);
3608
+ let fragment;
3609
+ const hashIdx = rest.indexOf("#");
3610
+ if (hashIdx !== -1) {
3611
+ fragment = parseFragment(rest.slice(hashIdx + 1));
3612
+ rest = rest.slice(0, hashIdx);
3613
+ }
3614
+ let query;
3615
+ const queryIdx = rest.indexOf("?");
3616
+ if (queryIdx !== -1) {
3617
+ query = rest.slice(queryIdx + 1);
3618
+ rest = rest.slice(0, queryIdx);
3619
+ }
3620
+ const slashIdx = rest.indexOf("/");
3621
+ const authority = slashIdx === -1 ? rest : rest.slice(0, slashIdx);
3622
+ const path = slashIdx === -1 ? "" : rest.slice(slashIdx);
3623
+ if (authority.length === 0) throw new ProtocolViolationError("MoqtUrl.parse", `moqt:// URL has an empty authority: ${input}`);
3624
+ return new MoqtUrl(authority, path, query, fragment);
3625
+ }
3626
+ /** The `path[?query]` string carried in the PATH setup option on native QUIC. */
3627
+ pathAndQuery() {
3628
+ return this.query !== void 0 ? `${this.path}?${this.query}` : this.path;
3629
+ }
3630
+ /** The equivalent `https://` URL for WebTransport, dropping the local fragment. */
3631
+ toHttps() {
3632
+ return `https://${this.authority}${this.pathAndQuery()}`;
3633
+ }
3634
+ };
3635
+ /**
3636
+ * Parses a fragment `<type>:<value>`. The type identifier must be ASCII lowercase
3637
+ * letters, digits, and hyphens; the value is opaque here.
3638
+ */
3639
+ function parseFragment(fragment) {
3640
+ const colonIdx = fragment.indexOf(":");
3641
+ if (colonIdx === -1) throw new ProtocolViolationError("MoqtUrl.parse", `moqt:// fragment must be <type>:<value>, got #${fragment}`);
3642
+ const kind = fragment.slice(0, colonIdx);
3643
+ if (kind.length === 0 || !/^[a-z0-9-]+$/.test(kind)) throw new ProtocolViolationError("MoqtUrl.parse", `moqt:// fragment type must be [a-z0-9-]+, got #${fragment}`);
3644
+ return {
3444
3645
  kind,
3445
3646
  value: fragment.slice(colonIdx + 1)
3446
3647
  };
@@ -3521,111 +3722,6 @@ var Redirect = class Redirect {
3521
3722
  }
3522
3723
  };
3523
3724
  //#endregion
3524
- //#region src/model/parameter/constant.ts
3525
- /**
3526
- * Copyright 2026 The MOQtail Authors
3527
- *
3528
- * Licensed under the Apache License, Version 2.0 (the "License");
3529
- * you may not use this file except in compliance with the License.
3530
- * You may obtain a copy of the License at
3531
- *
3532
- * http://www.apache.org/licenses/LICENSE-2.0
3533
- *
3534
- * Unless required by applicable law or agreed to in writing, software
3535
- * distributed under the License is distributed on an "AS IS" BASIS,
3536
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3537
- * See the License for the specific language governing permissions and
3538
- * limitations under the License.
3539
- */
3540
- let SetupOptionType = /* @__PURE__ */ function(SetupOptionType) {
3541
- SetupOptionType[SetupOptionType["Path"] = 1] = "Path";
3542
- SetupOptionType[SetupOptionType["AuthorizationToken"] = 3] = "AuthorizationToken";
3543
- SetupOptionType[SetupOptionType["MaxAuthTokenCacheSize"] = 4] = "MaxAuthTokenCacheSize";
3544
- /** Raw-QUIC only. Client-only; MUST NOT be sent over WebTransport (draft-18 §10.3.1.1). */
3545
- SetupOptionType[SetupOptionType["Authority"] = 5] = "Authority";
3546
- SetupOptionType[SetupOptionType["MoqtImplementation"] = 7] = "MoqtImplementation";
3547
- /**
3548
- * PROVISIONAL: sender-side track switching is not an adopted extension, so this
3549
- * codepoint is absent from the registry the conformance fixture tracks. It sits in the
3550
- * 0x07-0x7F range of this space, which that registry leaves free.
3551
- */
3552
- SetupOptionType[SetupOptionType["SstsAlgorithms"] = 9] = "SstsAlgorithms";
3553
- return SetupOptionType;
3554
- }({});
3555
- function setupOptionTypeFromNumber(value) {
3556
- switch (value) {
3557
- case 1: return 1;
3558
- case 3: return 3;
3559
- case 4: return 4;
3560
- case 5: return 5;
3561
- case 7: return 7;
3562
- case 9: return 9;
3563
- default: throw new InvalidTypeError("setupOptionTypeFromNumber", `Invalid setup option type: ${value}`);
3564
- }
3565
- }
3566
- let MessageParameterType = /* @__PURE__ */ function(MessageParameterType) {
3567
- MessageParameterType[MessageParameterType["ObjectDeliveryTimeout"] = 2] = "ObjectDeliveryTimeout";
3568
- MessageParameterType[MessageParameterType["AuthorizationToken"] = 3] = "AuthorizationToken";
3569
- MessageParameterType[MessageParameterType["RendezvousTimeout"] = 4] = "RendezvousTimeout";
3570
- MessageParameterType[MessageParameterType["SubgroupDeliveryTimeout"] = 6] = "SubgroupDeliveryTimeout";
3571
- MessageParameterType[MessageParameterType["Expires"] = 8] = "Expires";
3572
- MessageParameterType[MessageParameterType["LargestObject"] = 9] = "LargestObject";
3573
- MessageParameterType[MessageParameterType["FillTimeout"] = 10] = "FillTimeout";
3574
- MessageParameterType[MessageParameterType["Forward"] = 16] = "Forward";
3575
- MessageParameterType[MessageParameterType["SubscriberPriority"] = 32] = "SubscriberPriority";
3576
- MessageParameterType[MessageParameterType["SubscriptionFilter"] = 33] = "SubscriptionFilter";
3577
- MessageParameterType[MessageParameterType["GroupOrder"] = 34] = "GroupOrder";
3578
- MessageParameterType[MessageParameterType["NewGroupRequest"] = 50] = "NewGroupRequest";
3579
- /**
3580
- * Registered codepoint with no typed parameter yet: its consumer is REQUEST_UPDATE for
3581
- * SUBSCRIBE_TRACKS (TS-11), and the value is a Track Namespace tuple rather than the
3582
- * varint its even Type implies.
3583
- */
3584
- MessageParameterType[MessageParameterType["TrackNamespacePrefix"] = 52] = "TrackNamespacePrefix";
3585
- /**
3586
- * PROVISIONAL: sender-side track switching is not an adopted extension, so this
3587
- * codepoint is absent from the registry the conformance fixture tracks; see its
3588
- * `local_extensions`.
3589
- */
3590
- MessageParameterType[MessageParameterType["SwitchingSetAssignment"] = 65] = "SwitchingSetAssignment";
3591
- return MessageParameterType;
3592
- }({});
3593
- function messageParameterTypeFromNumber(value) {
3594
- switch (Number(value)) {
3595
- case 2: return 2;
3596
- case 3: return 3;
3597
- case 4: return 4;
3598
- case 6: return 6;
3599
- case 8: return 8;
3600
- case 9: return 9;
3601
- case 10: return 10;
3602
- case 16: return 16;
3603
- case 32: return 32;
3604
- case 33: return 33;
3605
- case 34: return 34;
3606
- case 50: return 50;
3607
- case 52: return 52;
3608
- case 65: return 65;
3609
- default: throw new InvalidTypeError("messageParameterTypeFromNumber", `Unknown message parameter type: ${value}`);
3610
- }
3611
- }
3612
- let TokenAliasType = /* @__PURE__ */ function(TokenAliasType) {
3613
- TokenAliasType[TokenAliasType["Delete"] = 0] = "Delete";
3614
- TokenAliasType[TokenAliasType["Register"] = 1] = "Register";
3615
- TokenAliasType[TokenAliasType["UseAlias"] = 2] = "UseAlias";
3616
- TokenAliasType[TokenAliasType["UseValue"] = 3] = "UseValue";
3617
- return TokenAliasType;
3618
- }({});
3619
- function tokenAliasTypeFromNumber(value) {
3620
- switch (value) {
3621
- case 0: return 0;
3622
- case 1: return 1;
3623
- case 2: return 2;
3624
- case 3: return 3;
3625
- default: throw new InvalidTypeError("tokenAliasTypeFromNumber", `Invalid token alias type: ${value}`);
3626
- }
3627
- }
3628
- //#endregion
3629
3725
  //#region src/model/parameter/common/authorization_token.ts
3630
3726
  /**
3631
3727
  * Copyright 2026 The MOQtail Authors
@@ -3956,6 +4052,45 @@ var Forward = class Forward {
3956
4052
  }
3957
4053
  };
3958
4054
  //#endregion
4055
+ //#region src/model/parameter/message/include_properties.ts
4056
+ /**
4057
+ * Copyright 2026 The MOQtail Authors
4058
+ *
4059
+ * Licensed under the Apache License, Version 2.0 (the "License");
4060
+ * you may not use this file except in compliance with the License.
4061
+ * You may obtain a copy of the License at
4062
+ *
4063
+ * http://www.apache.org/licenses/LICENSE-2.0
4064
+ *
4065
+ * Unless required by applicable law or agreed to in writing, software
4066
+ * distributed under the License is distributed on an "AS IS" BASIS,
4067
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4068
+ * See the License for the specific language governing permissions and
4069
+ * limitations under the License.
4070
+ */
4071
+ /**
4072
+ * Whether the response carries Track Properties: the OK answering a SUBSCRIBE,
4073
+ * TRACK_STATUS or FETCH, or each PUBLISH a SUBSCRIBE_TRACKS brings. With 0 the
4074
+ * Track Properties field is still there, but empty.
4075
+ * Allowed wire values: 0 or 1; any other value is a PROTOCOL_VIOLATION.
4076
+ * Default (when omitted) is 1 (include them).
4077
+ */
4078
+ var IncludeProperties = class IncludeProperties {
4079
+ include;
4080
+ static TYPE = 53;
4081
+ constructor(include) {
4082
+ this.include = include;
4083
+ }
4084
+ toKeyValuePair() {
4085
+ return KeyValuePair.newVarInt(IncludeProperties.TYPE, this.include ? 1n : 0n);
4086
+ }
4087
+ static fromKeyValuePair(pair) {
4088
+ if (Number(pair.typeValue) !== IncludeProperties.TYPE || typeof pair.value !== "bigint") return void 0;
4089
+ if (pair.value !== 0n && pair.value !== 1n) throw new ProtocolViolationError("IncludeProperties.fromKeyValuePair", `INCLUDE_PROPERTIES must be 0 or 1, got ${pair.value}`);
4090
+ return new IncludeProperties(pair.value === 1n);
4091
+ }
4092
+ };
4093
+ //#endregion
3959
4094
  //#region src/model/parameter/message/group_order_param.ts
3960
4095
  /**
3961
4096
  * Copyright 2026 The MOQtail Authors
@@ -4094,7 +4229,7 @@ var NewGroupRequest = class NewGroupRequest {
4094
4229
  *
4095
4230
  * PROVISIONAL: sender-side track switching is not an adopted extension, so
4096
4231
  * this parameter has no codepoint in the registry the conformance fixture
4097
- * tracks (`dev/conformance/draft18`) and is never asserted against it. Id 0 is
4232
+ * tracks (`dev/conformance/draft22`) and is never asserted against it. Id 0 is
4098
4233
  * the default allocation every implementation runs; other ids select an
4099
4234
  * algorithm specific to one implementation.
4100
4235
  */
@@ -4178,7 +4313,7 @@ var SubscriberPriority = class SubscriberPriority {
4178
4313
  }
4179
4314
  };
4180
4315
  //#endregion
4181
- //#region src/model/parameter/message/subscription_filter.ts
4316
+ //#region src/model/parameter/message/location_filter.ts
4182
4317
  /**
4183
4318
  * Copyright 2026 The MOQtail Authors
4184
4319
  *
@@ -4194,40 +4329,466 @@ var SubscriberPriority = class SubscriberPriority {
4194
4329
  * See the License for the specific language governing permissions and
4195
4330
  * limitations under the License.
4196
4331
  */
4332
+ const MAX_U64$1 = 18446744073709551615n;
4333
+ /** The fields each Location Filter Type carries, in wire order. */
4334
+ const FIELD_COUNT = {
4335
+ [0]: 0,
4336
+ [1]: 1,
4337
+ [2]: 2,
4338
+ [3]: 3,
4339
+ [4]: 4,
4340
+ [5]: 0
4341
+ };
4197
4342
  /**
4198
- * Length-prefixed Subscription Filter specifying what objects the subscriber wants.
4199
- * If omitted from SUBSCRIBE or PUBLISH_OK, the subscription is unfiltered (LatestObject).
4343
+ * The range of Locations a subscription or fetch selects. The Location Filter
4344
+ * Type decides which fields are set, and the value is not length-prefixed.
4345
+ *
4346
+ * Every Group here is absolute, except `startGroup` of a
4347
+ * {@link (LocationFilterType:enum).RelativeStart}, which counts back from the Next
4348
+ * Group: 0 is the Next Group, 1 the current one. The wire carries the End Group
4349
+ * as a delta from the Start Group; that is undone on the way in and redone on
4350
+ * the way out.
4351
+ *
4352
+ * If omitted from SUBSCRIBE or FETCH, the subscription or fetch is unfiltered.
4200
4353
  * If omitted from REQUEST_UPDATE, the value is unchanged.
4201
4354
  */
4202
- var SubscriptionFilter = class SubscriptionFilter {
4355
+ var LocationFilter = class LocationFilter {
4203
4356
  filterType;
4204
- startLocation;
4357
+ startGroup;
4358
+ startObject;
4205
4359
  endGroup;
4360
+ endObject;
4206
4361
  static TYPE = 33;
4207
- constructor(filterType, startLocation, endGroup) {
4362
+ /**
4363
+ * @throws :{@link ProtocolViolationError} When a field the type calls for is
4364
+ * missing, or the End Group is before the Start Group.
4365
+ */
4366
+ constructor(filterType, startGroup, startObject, endGroup, endObject) {
4208
4367
  this.filterType = filterType;
4209
- this.startLocation = startLocation;
4368
+ this.startGroup = startGroup;
4369
+ this.startObject = startObject;
4210
4370
  this.endGroup = endGroup;
4371
+ this.endObject = endObject;
4372
+ const fields = [
4373
+ startGroup,
4374
+ startObject,
4375
+ endGroup,
4376
+ endObject
4377
+ ];
4378
+ const count = FIELD_COUNT[filterType];
4379
+ if (count === void 0) throw new ProtocolViolationError("LocationFilter", `unknown Location Filter Type ${filterType}`);
4380
+ fields.forEach((field, i) => {
4381
+ if (field !== void 0 !== i < count) throw new ProtocolViolationError("LocationFilter", `Location Filter Type ${filterType} carries ${count} fields; field ${i + 1} is ${field === void 0 ? "missing" : "not one of them"}`);
4382
+ });
4383
+ if (endGroup !== void 0 && endGroup < startGroup) throw new ProtocolViolationError("LocationFilter", `End Group ${endGroup} is before Start Group ${startGroup}`);
4384
+ }
4385
+ /**
4386
+ * The first Location the filter passes, given the track's Largest Object, or
4387
+ * `undefined` when there is no filter. A relative start that would fall before
4388
+ * group 0 is group 0; a track with nothing published yet starts a relative
4389
+ * filter at `{0,0}`.
4390
+ */
4391
+ startLocation(largest) {
4392
+ switch (this.filterType) {
4393
+ case 0: return;
4394
+ case 1: {
4395
+ if (!largest) return new Location(0n, 0n);
4396
+ const group = largest.group + 1n - this.startGroup;
4397
+ return new Location(group < 0n ? 0n : group > MAX_U64$1 ? MAX_U64$1 : group, 0n);
4398
+ }
4399
+ case 5: return largest ? new Location(largest.group, largest.object + 1n) : new Location(0n, 0n);
4400
+ default: return new Location(this.startGroup, this.startObject);
4401
+ }
4402
+ }
4403
+ /** The Start Location an absolute filter carries; `undefined` for the others. */
4404
+ get absoluteStart() {
4405
+ switch (this.filterType) {
4406
+ case 2:
4407
+ case 3:
4408
+ case 4: return new Location(this.startGroup, this.startObject);
4409
+ default: return;
4410
+ }
4411
+ }
4412
+ /**
4413
+ * The last Location the filter passes, inclusive, or `undefined` when it is
4414
+ * open-ended. A Group End is the whole of that group, so its Object is 2^64-1.
4415
+ */
4416
+ endLocation() {
4417
+ switch (this.filterType) {
4418
+ case 3: return new Location(this.endGroup, MAX_U64$1);
4419
+ case 4: return new Location(this.endGroup, this.endObject);
4420
+ default: return;
4421
+ }
4422
+ }
4423
+ /**
4424
+ * The inclusive range the filter selects under the rules for a Fetch, which
4425
+ * never reach past the Largest Object: an open end is the Largest Object, and
4426
+ * no filter at all is the whole track up to it.
4427
+ *
4428
+ * `undefined` when that range is empty, which includes a track with nothing
4429
+ * published yet and a Next Object filter, whose start is always past the
4430
+ * Largest Object.
4431
+ */
4432
+ fetchRange(largest) {
4433
+ if (!largest) return void 0;
4434
+ const start = this.startLocation(largest) ?? new Location(0n, 0n);
4435
+ const filterEnd = this.endLocation();
4436
+ const end = filterEnd && filterEnd.compare(largest) < 0 ? filterEnd : largest;
4437
+ return start.compare(end) <= 0 ? {
4438
+ start,
4439
+ end
4440
+ } : void 0;
4441
+ }
4442
+ /** The Location Filter Type and its fields, without the Parameter Type. */
4443
+ serializeValue() {
4444
+ const buf = new ByteBuffer();
4445
+ buf.putVI(this.filterType);
4446
+ const count = FIELD_COUNT[this.filterType];
4447
+ if (count > 0) buf.putVI(this.startGroup);
4448
+ if (count > 1) buf.putVI(this.startObject);
4449
+ if (count > 2) buf.putVI(this.endGroup - this.startGroup);
4450
+ if (count > 3) buf.putVI(this.endObject);
4451
+ return buf.toUint8Array();
4452
+ }
4453
+ /**
4454
+ * Reads a Location Filter Type and exactly the fields it calls for.
4455
+ * @throws :{@link ProtocolViolationError} For an unknown Location Filter Type,
4456
+ * or an End Group past 2^64-1.
4457
+ */
4458
+ static deserializeValue(buf) {
4459
+ const raw = buf.getVI();
4460
+ let filterType;
4461
+ try {
4462
+ filterType = LocationFilterType.tryFrom(raw);
4463
+ } catch {
4464
+ throw new ProtocolViolationError("LocationFilter.deserializeValue", `unknown Location Filter Type ${raw}`);
4465
+ }
4466
+ const count = FIELD_COUNT[filterType];
4467
+ const startGroup = count > 0 ? buf.getVI() : void 0;
4468
+ const startObject = count > 1 ? buf.getVI() : void 0;
4469
+ let endGroup;
4470
+ if (count > 2) {
4471
+ endGroup = startGroup + buf.getVI();
4472
+ if (endGroup > MAX_U64$1) throw new ProtocolViolationError("LocationFilter.deserializeValue", `StartGroup plus EndGroupDelta exceeds 2^64 - 1`);
4473
+ }
4474
+ const endObject = count > 3 ? buf.getVI() : void 0;
4475
+ return new LocationFilter(filterType, startGroup, startObject, endGroup, endObject);
4476
+ }
4477
+ toKeyValuePair() {
4478
+ return KeyValuePair.tryNewBytes(LocationFilter.TYPE, this.serializeValue());
4479
+ }
4480
+ static fromKeyValuePair(pair) {
4481
+ if (Number(pair.typeValue) !== LocationFilter.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
4482
+ const buf = new ByteBuffer();
4483
+ buf.putBytes(pair.value);
4484
+ const frozen = buf.freeze();
4485
+ const filter = LocationFilter.deserializeValue(frozen);
4486
+ if (frozen.remaining > 0) throw new ProtocolViolationError("LocationFilter.fromKeyValuePair", "trailing bytes after the Location Filter");
4487
+ return filter;
4488
+ }
4489
+ };
4490
+ //#endregion
4491
+ //#region src/model/parameter/message/switch_from.ts
4492
+ /**
4493
+ * Copyright 2026 The MOQtail Authors
4494
+ *
4495
+ * Licensed under the Apache License, Version 2.0 (the "License");
4496
+ * you may not use this file except in compliance with the License.
4497
+ * You may obtain a copy of the License at
4498
+ *
4499
+ * http://www.apache.org/licenses/LICENSE-2.0
4500
+ *
4501
+ * Unless required by applicable law or agreed to in writing, software
4502
+ * distributed under the License is distributed on an "AS IS" BASIS,
4503
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4504
+ * See the License for the specific language governing permissions and
4505
+ * limitations under the License.
4506
+ */
4507
+ /**
4508
+ * Identifies the subscription being replaced by a switch request.
4509
+ * The value is two varints followed by a flags byte: bit 7 (MSB) is Publish Done;
4510
+ * bits 0 through 6 are reserved and must be zero.
4511
+ */
4512
+ var SwitchFrom = class SwitchFrom {
4513
+ requestId;
4514
+ mode;
4515
+ publishDone;
4516
+ static TYPE = 36;
4517
+ constructor(requestId, mode, publishDone) {
4518
+ this.requestId = requestId;
4519
+ this.mode = mode;
4520
+ this.publishDone = publishDone;
4521
+ }
4522
+ toKeyValuePair() {
4523
+ const buf = new ByteBuffer();
4524
+ buf.putVI(this.requestId);
4525
+ buf.putVI(this.mode);
4526
+ buf.putU8(this.publishDone ? 128 : 0);
4527
+ return KeyValuePair.newBytes(SwitchFrom.TYPE, buf.toUint8Array());
4528
+ }
4529
+ static fromKeyValuePair(pair) {
4530
+ if (Number(pair.typeValue) !== SwitchFrom.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
4531
+ const buf = new ByteBuffer();
4532
+ buf.putBytes(pair.value);
4533
+ const requestId = buf.getVI();
4534
+ const modeValue = buf.getVI();
4535
+ if (modeValue !== BigInt(0) && modeValue !== BigInt(1)) throw new ProtocolViolationError("SwitchFrom.fromKeyValuePair", `invalid mode ${modeValue}`);
4536
+ const flags = buf.getU8();
4537
+ if ((flags & 127) !== 0) throw new ProtocolViolationError("SwitchFrom.fromKeyValuePair", `reserved bits must be zero, got ${flags}`);
4538
+ if (buf.remaining !== 0) throw new ProtocolViolationError("SwitchFrom.fromKeyValuePair", "unexpected trailing bytes");
4539
+ return new SwitchFrom(requestId, Number(modeValue), (flags & 128) !== 0);
4540
+ }
4541
+ };
4542
+ //#endregion
4543
+ //#region src/model/parameter/message/fill_parameters.ts
4544
+ /**
4545
+ * Copyright 2026 The MOQtail Authors
4546
+ *
4547
+ * Licensed under the Apache License, Version 2.0 (the "License");
4548
+ * you may not use this file except in compliance with the License.
4549
+ * You may obtain a copy of the License at
4550
+ *
4551
+ * http://www.apache.org/licenses/LICENSE-2.0
4552
+ *
4553
+ * Unless required by applicable law or agreed to in writing, software
4554
+ * distributed under the License is distributed on an "AS IS" BASIS,
4555
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4556
+ * See the License for the specific language governing permissions and
4557
+ * limitations under the License.
4558
+ */
4559
+ /** The only parameters that may override anything for the fill fetch stream. */
4560
+ const ALLOWED = [
4561
+ 10,
4562
+ 32,
4563
+ 33,
4564
+ 34,
4565
+ 37,
4566
+ 38,
4567
+ 39,
4568
+ 40
4569
+ ];
4570
+ /**
4571
+ * Requests a fill fetch stream, and overrides for it. An omitted parameter keeps
4572
+ * the value it has for the live subscription; an omitted LOCATION_FILTER fills
4573
+ * over the subscription's own.
4574
+ */
4575
+ var FillParameters = class FillParameters {
4576
+ parameters;
4577
+ static TYPE = 35;
4578
+ constructor(parameters) {
4579
+ this.parameters = parameters;
4580
+ }
4581
+ toKeyValuePair() {
4582
+ const pairs = this.parameters.map((p) => p.toKeyValuePair());
4583
+ for (const pair of pairs) if (!ALLOWED.includes(Number(pair.typeValue))) throw new ProtocolViolationError("FillParameters.toKeyValuePair", `parameter type 0x${pair.typeValue.toString(16)} is not allowed inside FILL_PARAMETERS`);
4584
+ const value = new ByteBuffer();
4585
+ value.putVI(pairs.length);
4586
+ value.putBytes(serializeMessageParameterKvps(pairs).toUint8Array());
4587
+ return KeyValuePair.tryNewBytes(FillParameters.TYPE, value.toUint8Array());
4588
+ }
4589
+ static fromKeyValuePair(pair) {
4590
+ if (Number(pair.typeValue) !== FillParameters.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
4591
+ const buf = new ByteBuffer();
4592
+ buf.putBytes(pair.value);
4593
+ const frozen = buf.freeze();
4594
+ const count = frozen.getVI();
4595
+ const pairs = deserializeMessageParameterKvps(frozen, count);
4596
+ if (frozen.remaining > 0) throw new ProtocolViolationError("FillParameters.fromKeyValuePair", `${frozen.remaining} bytes left after ${count} parameters`);
4597
+ for (const inner of pairs) if (!ALLOWED.includes(Number(inner.typeValue))) throw new ProtocolViolationError("FillParameters.fromKeyValuePair", `parameter type 0x${inner.typeValue.toString(16)} is not allowed inside FILL_PARAMETERS`);
4598
+ return new FillParameters(MessageParameters.fromKeyValuePairs(pairs));
4599
+ }
4600
+ };
4601
+ //#endregion
4602
+ //#region src/model/parameter/message/range_filter.ts
4603
+ /**
4604
+ * Copyright 2026 The MOQtail Authors
4605
+ *
4606
+ * Licensed under the Apache License, Version 2.0 (the "License");
4607
+ * you may not use this file except in compliance with the License.
4608
+ * You may obtain a copy of the License at
4609
+ *
4610
+ * http://www.apache.org/licenses/LICENSE-2.0
4611
+ *
4612
+ * Unless required by applicable law or agreed to in writing, software
4613
+ * distributed under the License is distributed on an "AS IS" BASIS,
4614
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
4615
+ * See the License for the specific language governing permissions and
4616
+ * limitations under the License.
4617
+ */
4618
+ const MAX_U64 = 18446744073709551615n;
4619
+ /**
4620
+ * What a Range Filter selects on. Each kind is its own parameter type, and the two
4621
+ * property kinds also name the Property they read.
4622
+ */
4623
+ let RangeFilterKind = /* @__PURE__ */ function(RangeFilterKind) {
4624
+ RangeFilterKind[RangeFilterKind["Subgroup"] = 37] = "Subgroup";
4625
+ RangeFilterKind[RangeFilterKind["ObjectId"] = 38] = "ObjectId";
4626
+ /** Publisher Priority, which is a single byte. */
4627
+ RangeFilterKind[RangeFilterKind["Priority"] = 39] = "Priority";
4628
+ RangeFilterKind[RangeFilterKind["ObjectProperty"] = 40] = "ObjectProperty";
4629
+ /** Selects tracks rather than Objects, so it only rides SUBSCRIBE_TRACKS. */
4630
+ RangeFilterKind[RangeFilterKind["TrackProperty"] = 41] = "TrackProperty";
4631
+ return RangeFilterKind;
4632
+ }({});
4633
+ (function(_RangeFilterKind) {
4634
+ function hasPropertyType(kind) {
4635
+ return kind === RangeFilterKind.ObjectProperty || kind === RangeFilterKind.TrackProperty;
4636
+ }
4637
+ _RangeFilterKind.hasPropertyType = hasPropertyType;
4638
+ function isRangeFilterType(typeValue) {
4639
+ const n = Number(typeValue);
4640
+ return n >= 37 && n <= 41;
4641
+ }
4642
+ _RangeFilterKind.isRangeFilterType = isRangeFilterType;
4643
+ })(RangeFilterKind || (RangeFilterKind = {}));
4644
+ /**
4645
+ * A Range Filter that cannot be honoured. A peer that sends one is answered with
4646
+ * REQUEST_ERROR INVALID_FILTER rather than a closed session: the request is
4647
+ * well-formed, it just asks for something that cannot be applied.
4648
+ */
4649
+ var InvalidFilterError = class extends MOQtailError {
4650
+ context;
4651
+ details;
4652
+ constructor(context, details) {
4653
+ super(`Invalid filter in ${context}: ${details}`);
4654
+ this.context = context;
4655
+ this.details = details;
4656
+ }
4657
+ };
4658
+ /**
4659
+ * Delta-encodes ascending `ranges`. Only the last may be open-ended.
4660
+ * @throws :{@link InvalidFilterError} When the ranges do not ascend.
4661
+ */
4662
+ function encodeRanges(ranges) {
4663
+ const deltas = [];
4664
+ let priorEnd = 0n;
4665
+ ranges.forEach((range, i) => {
4666
+ if (range.start < priorEnd || range.end !== void 0 && range.end < range.start) throw new InvalidFilterError("encodeRanges", "ranges are not ascending");
4667
+ if (range.end === void 0) {
4668
+ if (i + 1 !== ranges.length) throw new InvalidFilterError("encodeRanges", "only the last range can be open-ended");
4669
+ deltas.push([range.start - priorEnd]);
4670
+ return;
4671
+ }
4672
+ deltas.push([range.start - priorEnd, range.end - range.start]);
4673
+ priorEnd = range.end;
4674
+ });
4675
+ return deltas;
4676
+ }
4677
+ /**
4678
+ * One Range Filter parameter. Unlike other parameters it may repeat in a message,
4679
+ * once per SetID (and Property Type).
4680
+ *
4681
+ * Without a `setId` it is the zero-length form, which in REQUEST_UPDATE removes the
4682
+ * filters of its kind.
4683
+ *
4684
+ * The Ranges are held as the wire's deltas and only added back by {@link
4685
+ * RangeFilter.ranges}: a sum past 2^64-1 is answered with a REQUEST_ERROR for the
4686
+ * request that carried it, which a parser that rejected it could not do.
4687
+ */
4688
+ var RangeFilter = class RangeFilter {
4689
+ kind;
4690
+ setId;
4691
+ propertyType;
4692
+ deltas;
4693
+ /**
4694
+ * @throws :{@link ProtocolViolationError} When the Property Type's presence does not
4695
+ * match the kind, or a removal carries anything but its kind.
4696
+ */
4697
+ constructor(kind, setId, propertyType, deltas = []) {
4698
+ this.kind = kind;
4699
+ this.setId = setId;
4700
+ this.propertyType = propertyType;
4701
+ this.deltas = deltas;
4702
+ if (setId === void 0) {
4703
+ if (propertyType !== void 0 || deltas.length > 0) throw new ProtocolViolationError("RangeFilter", "a removal carries no SetID, Property Type or Ranges");
4704
+ return;
4705
+ }
4706
+ if (!Number.isInteger(setId) || setId < 0 || setId > 255) throw new ProtocolViolationError("RangeFilter", `SetID ${setId} is not a single byte`);
4707
+ if (RangeFilterKind.hasPropertyType(kind) !== (propertyType !== void 0)) throw new ProtocolViolationError("RangeFilter", `${RangeFilterKind[kind]} filter has the wrong Property Type presence`);
4708
+ deltas.forEach(([, end], i) => {
4709
+ if (end === void 0 && i + 1 !== deltas.length) throw new ProtocolViolationError("RangeFilter", "only the last range can be open-ended");
4710
+ });
4211
4711
  }
4212
- toKeyValuePair() {
4712
+ /** The zero-length form, which removes the filters of its kind. */
4713
+ get isRemoval() {
4714
+ return this.setId === void 0;
4715
+ }
4716
+ /** How many Ranges the filter holds, which is what a peer's range limit counts. */
4717
+ get rangeCount() {
4718
+ return this.deltas.length;
4719
+ }
4720
+ /**
4721
+ * The Ranges with their deltas added back.
4722
+ * @throws :{@link InvalidFilterError} When a bound exceeds 2^64-1.
4723
+ */
4724
+ ranges() {
4725
+ const ranges = [];
4726
+ let priorEnd = 0n;
4727
+ for (const [startDelta, endDelta] of this.deltas) {
4728
+ const start = priorEnd + startDelta;
4729
+ if (start > MAX_U64) throw new InvalidFilterError("RangeFilter.ranges", "a range bound exceeds 2^64 - 1");
4730
+ if (endDelta === void 0) {
4731
+ ranges.push({ start });
4732
+ continue;
4733
+ }
4734
+ const end = start + endDelta;
4735
+ if (end > MAX_U64) throw new InvalidFilterError("RangeFilter.ranges", "a range bound exceeds 2^64 - 1");
4736
+ ranges.push({
4737
+ start,
4738
+ end
4739
+ });
4740
+ priorEnd = end;
4741
+ }
4742
+ return ranges;
4743
+ }
4744
+ /**
4745
+ * The Ranges, once everything a filter of this kind has to satisfy holds.
4746
+ * @throws :{@link InvalidFilterError} For an odd Property Type, a priority above
4747
+ * 255, or a bound past 2^64-1.
4748
+ */
4749
+ validate() {
4750
+ if (this.propertyType !== void 0 && this.propertyType % 2n !== 0n) throw new InvalidFilterError("RangeFilter.validate", `property type 0x${this.propertyType.toString(16)} is odd`);
4751
+ const ranges = this.ranges();
4752
+ if (this.kind === RangeFilterKind.Priority) {
4753
+ const over = ranges.flatMap((r) => [r.start, r.end]).find((v) => v !== void 0 && v > 255n);
4754
+ if (over !== void 0) throw new InvalidFilterError("RangeFilter.validate", `priority ${over} is outside 0-255`);
4755
+ }
4756
+ return ranges;
4757
+ }
4758
+ /** The SetID, Property Type if any, and the Ranges, without the Type or Length. */
4759
+ serializeValue() {
4760
+ if (this.setId === void 0) return /* @__PURE__ */ new Uint8Array();
4213
4761
  const buf = new ByteBuffer();
4214
- buf.putVI(this.filterType);
4215
- if (this.filterType === 3 || this.filterType === 4) {
4216
- if (this.startLocation) buf.putLocation(this.startLocation);
4762
+ buf.putU8(this.setId);
4763
+ if (this.propertyType !== void 0) buf.putVI(this.propertyType);
4764
+ for (const [start, end] of this.deltas) {
4765
+ buf.putVI(start);
4766
+ if (end !== void 0) buf.putVI(end);
4217
4767
  }
4218
- if (this.filterType === 4 && this.endGroup != null) buf.putVI(this.endGroup);
4219
- return KeyValuePair.tryNewBytes(SubscriptionFilter.TYPE, buf.toUint8Array());
4768
+ return buf.toUint8Array();
4769
+ }
4770
+ toKeyValuePair() {
4771
+ return KeyValuePair.newBytes(this.kind, this.serializeValue());
4220
4772
  }
4773
+ /**
4774
+ * Decodes a Range Filter value. The Value ends with the last Range, so a Start
4775
+ * with nothing after it is an open-ended last Range.
4776
+ */
4221
4777
  static fromKeyValuePair(pair) {
4222
- if (Number(pair.typeValue) !== SubscriptionFilter.TYPE || !(pair.value instanceof Uint8Array)) return void 0;
4778
+ if (!RangeFilterKind.isRangeFilterType(pair.typeValue) || !(pair.value instanceof Uint8Array)) return void 0;
4779
+ const kind = Number(pair.typeValue);
4780
+ if (pair.value.length === 0) return new RangeFilter(kind);
4223
4781
  const buf = new ByteBuffer();
4224
4782
  buf.putBytes(pair.value);
4225
- const filterType = Number(buf.getVI());
4226
- let startLocation;
4227
- let endGroup;
4228
- if (filterType === 3 || filterType === 4) startLocation = buf.getLocation();
4229
- if (filterType === 4) endGroup = buf.getVI();
4230
- return new SubscriptionFilter(filterType, startLocation, endGroup);
4783
+ const frozen = buf.freeze();
4784
+ const setId = frozen.getU8();
4785
+ const propertyType = RangeFilterKind.hasPropertyType(kind) ? frozen.getVI() : void 0;
4786
+ const deltas = [];
4787
+ while (frozen.remaining > 0) {
4788
+ const start = frozen.getVI();
4789
+ deltas.push(frozen.remaining > 0 ? [start, frozen.getVI()] : [start]);
4790
+ }
4791
+ return new RangeFilter(kind, setId, propertyType, deltas);
4231
4792
  }
4232
4793
  };
4233
4794
  //#endregion
@@ -4250,7 +4811,7 @@ var SubscriptionFilter = class SubscriptionFilter {
4250
4811
  let MessageParameter;
4251
4812
  (function(_MessageParameter) {
4252
4813
  function fromKeyValuePair(pair) {
4253
- return ObjectDeliveryTimeout.fromKeyValuePair(pair) ?? SubgroupDeliveryTimeout.fromKeyValuePair(pair) ?? RendezvousTimeout.fromKeyValuePair(pair) ?? FillTimeout.fromKeyValuePair(pair) ?? AuthorizationToken.fromKeyValuePair(pair) ?? Expires.fromKeyValuePair(pair) ?? LargestObject.fromKeyValuePair(pair) ?? Forward.fromKeyValuePair(pair) ?? SubscriberPriority.fromKeyValuePair(pair) ?? GroupOrderParam.fromKeyValuePair(pair) ?? SubscriptionFilter.fromKeyValuePair(pair) ?? NewGroupRequest.fromKeyValuePair(pair) ?? SwitchingSetAssignment.fromKeyValuePair(pair);
4814
+ return ObjectDeliveryTimeout.fromKeyValuePair(pair) ?? SubgroupDeliveryTimeout.fromKeyValuePair(pair) ?? RendezvousTimeout.fromKeyValuePair(pair) ?? FillTimeout.fromKeyValuePair(pair) ?? AuthorizationToken.fromKeyValuePair(pair) ?? Expires.fromKeyValuePair(pair) ?? LargestObject.fromKeyValuePair(pair) ?? Forward.fromKeyValuePair(pair) ?? SubscriberPriority.fromKeyValuePair(pair) ?? GroupOrderParam.fromKeyValuePair(pair) ?? LocationFilter.fromKeyValuePair(pair) ?? NewGroupRequest.fromKeyValuePair(pair) ?? SwitchFrom.fromKeyValuePair(pair) ?? FillParameters.fromKeyValuePair(pair) ?? RangeFilter.fromKeyValuePair(pair) ?? IncludeProperties.fromKeyValuePair(pair) ?? SwitchingSetAssignment.fromKeyValuePair(pair);
4254
4815
  }
4255
4816
  _MessageParameter.fromKeyValuePair = fromKeyValuePair;
4256
4817
  function toKeyValuePair(param) {
@@ -4305,14 +4866,42 @@ let MessageParameter;
4305
4866
  return params.find(isGroupOrderParam)?.order ?? 0;
4306
4867
  }
4307
4868
  _MessageParameter.groupOrderOf = groupOrderOf;
4308
- function isSubscriptionFilter(param) {
4309
- return param instanceof SubscriptionFilter;
4869
+ function isLocationFilter(param) {
4870
+ return param instanceof LocationFilter;
4310
4871
  }
4311
- _MessageParameter.isSubscriptionFilter = isSubscriptionFilter;
4872
+ _MessageParameter.isLocationFilter = isLocationFilter;
4312
4873
  function isNewGroupRequest(param) {
4313
4874
  return param instanceof NewGroupRequest;
4314
4875
  }
4315
4876
  _MessageParameter.isNewGroupRequest = isNewGroupRequest;
4877
+ function isSwitchFrom(param) {
4878
+ return param instanceof SwitchFrom;
4879
+ }
4880
+ _MessageParameter.isSwitchFrom = isSwitchFrom;
4881
+ function isFillParameters(param) {
4882
+ return param instanceof FillParameters;
4883
+ }
4884
+ _MessageParameter.isFillParameters = isFillParameters;
4885
+ function isRangeFilter(param) {
4886
+ return param instanceof RangeFilter;
4887
+ }
4888
+ _MessageParameter.isRangeFilter = isRangeFilter;
4889
+ function carriesRangeFilter(params) {
4890
+ return params.some((p) => isRangeFilter(p) || isFillParameters(p) && carriesRangeFilter(p.parameters));
4891
+ }
4892
+ _MessageParameter.carriesRangeFilter = carriesRangeFilter;
4893
+ function isIncludeProperties(param) {
4894
+ return param instanceof IncludeProperties;
4895
+ }
4896
+ _MessageParameter.isIncludeProperties = isIncludeProperties;
4897
+ function publishParametersFor(subscribeTracks) {
4898
+ return subscribeTracks.filter((p) => isForward(p) || isGroupOrderParam(p) || isLocationFilter(p));
4899
+ }
4900
+ _MessageParameter.publishParametersFor = publishParametersFor;
4901
+ function includesProperties(params) {
4902
+ return !params.some((p) => isIncludeProperties(p) && !p.include);
4903
+ }
4904
+ _MessageParameter.includesProperties = includesProperties;
4316
4905
  })(MessageParameter || (MessageParameter = {}));
4317
4906
  /**
4318
4907
  * Builder for constructing a list of MessageParameters.
@@ -4345,18 +4934,30 @@ var MessageParameters = class {
4345
4934
  addForward(forward) {
4346
4935
  return this.add(new Forward(forward));
4347
4936
  }
4937
+ addIncludeProperties(include) {
4938
+ return this.add(new IncludeProperties(include));
4939
+ }
4348
4940
  addSubscriberPriority(priority) {
4349
4941
  return this.add(new SubscriberPriority(priority));
4350
4942
  }
4351
4943
  addGroupOrder(order) {
4352
4944
  return this.add(new GroupOrderParam(order));
4353
4945
  }
4354
- addSubscriptionFilter(filter) {
4946
+ addLocationFilter(filter) {
4355
4947
  return this.add(filter);
4356
4948
  }
4357
4949
  addNewGroupRequest(group) {
4358
4950
  return this.add(new NewGroupRequest(BigInt(group)));
4359
4951
  }
4952
+ addSwitchFrom(requestId, mode, publishDone) {
4953
+ return this.add(new SwitchFrom(BigInt(requestId), mode, publishDone));
4954
+ }
4955
+ addFillParameters(parameters) {
4956
+ return this.add(new FillParameters(parameters));
4957
+ }
4958
+ addRangeFilter(filter) {
4959
+ return this.add(filter);
4960
+ }
4360
4961
  build() {
4361
4962
  return [...this.params];
4362
4963
  }
@@ -4374,24 +4975,23 @@ var MessageParameters = class {
4374
4975
  return result;
4375
4976
  }
4376
4977
  };
4377
- /**
4378
- * LARGEST_OBJECT (0x09) is a bare Location -- two consecutive varints with no
4379
- * length prefix. Its Type is odd, so the generic KVP parity rule would read a
4380
- * length prefix and desync. This is a message-parameter encoding: the same Type
4381
- * number in the setup-option namespace means something else, so the rule lives
4382
- * here rather than in the shared codec.
4383
- */
4384
- function isLocationMessageParam(typeValue) {
4385
- return typeValue === 9n;
4386
- }
4387
- /**
4388
- * FORWARD (0x10), SUBSCRIBER_PRIORITY (0x20) and GROUP_ORDER (0x22) carry a
4389
- * single uint8, not the generic even-Type varint. These Types are even, so
4390
- * without this the parity rule would read a varint and desync on any value
4391
- * >= 64 (e.g. the default SUBSCRIBER_PRIORITY of 128 = 0x80).
4392
- */
4393
- function isUint8MessageParam(typeValue) {
4394
- return typeValue === 16n || typeValue === 32n || typeValue === 34n;
4978
+ function valueShapeOf(typeValue) {
4979
+ switch (typeValue) {
4980
+ case BigInt(16):
4981
+ case BigInt(32):
4982
+ case BigInt(34):
4983
+ case BigInt(53): return 1;
4984
+ case BigInt(9): return 2;
4985
+ case BigInt(33): return 3;
4986
+ case BigInt(36):
4987
+ case BigInt(52):
4988
+ case BigInt(37):
4989
+ case BigInt(38):
4990
+ case BigInt(39):
4991
+ case BigInt(40):
4992
+ case BigInt(41): return 4;
4993
+ default: return typeValue % 2n === 0n ? 0 : 4;
4994
+ }
4395
4995
  }
4396
4996
  /**
4397
4997
  * Serializes a list of message-parameter KVPs, delta-encoding the Types.
@@ -4403,12 +5003,22 @@ function serializeMessageParameterKvps(items) {
4403
5003
  let prevType = 0n;
4404
5004
  for (const kvp of sorted) {
4405
5005
  buf.putVI(kvp.typeValue - prevType);
4406
- if (isVarInt(kvp) && isUint8MessageParam(kvp.typeValue)) {
4407
- if (kvp.value < 0n || kvp.value > 255n) throw new ProtocolViolationError("serializeMessageParameterKvps", `uint8 parameter 0x${kvp.typeValue.toString(16)} value ${kvp.value} exceeds 255`);
4408
- buf.putU8(Number(kvp.value));
4409
- } else if (isVarInt(kvp)) buf.putVI(kvp.value);
4410
- else if (isBytes(kvp) && isLocationMessageParam(kvp.typeValue)) buf.putBytes(kvp.value);
4411
- else if (isBytes(kvp)) buf.putLengthPrefixedBytes(kvp.value);
5006
+ switch (valueShapeOf(kvp.typeValue)) {
5007
+ case 1:
5008
+ if (!isVarInt(kvp) || kvp.value < 0n || kvp.value > 255n) throw new ProtocolViolationError("serializeMessageParameterKvps", `uint8 parameter 0x${kvp.typeValue.toString(16)} value ${kvp.value} exceeds 255`);
5009
+ buf.putU8(Number(kvp.value));
5010
+ break;
5011
+ case 2:
5012
+ case 3:
5013
+ if (isBytes(kvp)) buf.putBytes(kvp.value);
5014
+ break;
5015
+ case 4:
5016
+ if (isBytes(kvp)) buf.putLengthPrefixedBytes(kvp.value);
5017
+ break;
5018
+ case 0:
5019
+ if (isVarInt(kvp)) buf.putVI(kvp.value);
5020
+ break;
5021
+ }
4412
5022
  prevType = kvp.typeValue;
4413
5023
  }
4414
5024
  return buf.freeze();
@@ -4419,33 +5029,53 @@ function serializeMessageParameterKvps(items) {
4419
5029
  */
4420
5030
  function deserializeMessageParameterKvps(buf, count) {
4421
5031
  const n = typeof count === "bigint" ? Number(count) : count;
4422
- const items = new Array(n);
5032
+ let read = 0;
5033
+ return readMessageParameterKvps(buf, () => read++ < n);
5034
+ }
5035
+ function readMessageParameterKvps(buf, more) {
5036
+ const items = [];
4423
5037
  let prevType = 0n;
4424
- for (let i = 0; i < n; i++) {
5038
+ while (more()) {
4425
5039
  const typeValue = prevType + buf.getVI();
4426
- if (isUint8MessageParam(typeValue)) items[i] = KeyValuePair.tryNewVarInt(typeValue, BigInt(buf.getU8()));
4427
- else if (isLocationMessageParam(typeValue)) {
4428
- const loc = new ByteBuffer();
4429
- loc.putVI(buf.getVI());
4430
- loc.putVI(buf.getVI());
4431
- items[i] = KeyValuePair.tryNewBytes(typeValue, loc.toUint8Array());
4432
- } else items[i] = KeyValuePair.deserializeValue(buf, typeValue);
5040
+ switch (valueShapeOf(typeValue)) {
5041
+ case 1:
5042
+ items.push(KeyValuePair.newVarInt(typeValue, BigInt(buf.getU8())));
5043
+ break;
5044
+ case 2: {
5045
+ const loc = new ByteBuffer();
5046
+ loc.putVI(buf.getVI());
5047
+ loc.putVI(buf.getVI());
5048
+ items.push(KeyValuePair.newBytes(typeValue, loc.toUint8Array()));
5049
+ break;
5050
+ }
5051
+ case 3:
5052
+ items.push(KeyValuePair.newBytes(typeValue, LocationFilter.deserializeValue(buf).serializeValue()));
5053
+ break;
5054
+ case 4:
5055
+ items.push(KeyValuePair.deserializeBytesValue(buf, typeValue));
5056
+ break;
5057
+ case 0:
5058
+ items.push(KeyValuePair.tryNewVarInt(typeValue, buf.getVI()));
5059
+ break;
5060
+ }
4433
5061
  prevType = typeValue;
4434
5062
  }
4435
5063
  return items;
4436
5064
  }
4437
5065
  /**
4438
5066
  * Applies a set of parameter updates to an existing parameter list.
4439
- * For each update, replaces the matching parameter (by wire type value) or appends it.
4440
- * Per spec: "If omitted from REQUEST_UPDATE/SUBSCRIBE_UPDATE, the value is unchanged."
5067
+ *
5068
+ * A Type the update leaves out keeps its value. A Type it carries is replaced
5069
+ * outright, every instance of it: a Range Filter can repeat, and an update that
5070
+ * names a filter kind states the whole of that kind, so one left over from before
5071
+ * would quietly widen or narrow what the subscriber asked for. A zero-length Range
5072
+ * Filter replaces its kind with nothing.
4441
5073
  */
4442
5074
  function applyMessageParameterUpdate(current, updates) {
4443
- for (const update of updates) {
4444
- const updateType = update.toKeyValuePair().typeValue;
4445
- const idx = current.findIndex((p) => p.toKeyValuePair().typeValue === updateType);
4446
- if (idx >= 0) current[idx] = update;
4447
- else current.push(update);
4448
- }
5075
+ const typeOf = (p) => p.toKeyValuePair().typeValue;
5076
+ const updated = new Set(updates.map(typeOf));
5077
+ const kept = current.filter((p) => !updated.has(typeOf(p)));
5078
+ current.splice(0, current.length, ...kept, ...updates.filter((u) => !(u instanceof RangeFilter && u.isRemoval)));
4449
5079
  }
4450
5080
  //#endregion
4451
5081
  //#region src/model/control/publish_namespace.ts
@@ -4642,11 +5272,10 @@ var NamespaceDone = class NamespaceDone {
4642
5272
  * limitations under the License.
4643
5273
  */
4644
5274
  /**
4645
- * The first message each endpoint sends on its control stream (draft-18 §10.3).
5275
+ * The first message each endpoint sends on its control stream.
4646
5276
  *
4647
5277
  * Both peers send the same message; there are no separate client and server forms and
4648
- * no version fields, since version negotiation happens over ALPN (§3.1). Replaces
4649
- * CLIENT_SETUP / SERVER_SETUP.
5278
+ * no version fields, since version negotiation happens over ALPN.
4650
5279
  *
4651
5280
  * Some options are client-only (see {@link SetupOptionType}); whether a peer is
4652
5281
  * allowed to send a given option depends on which side it is and on the transport,
@@ -4694,13 +5323,20 @@ var Setup = class Setup {
4694
5323
  */
4695
5324
  var Fetch = class Fetch {
4696
5325
  requestId;
4697
- typeAndProps;
5326
+ fullTrackName;
4698
5327
  parameters;
4699
- constructor(requestId, typeAndProps, parameters) {
5328
+ constructor(requestId, fullTrackName, parameters) {
4700
5329
  this.requestId = requestId;
4701
- this.typeAndProps = typeAndProps;
5330
+ this.fullTrackName = fullTrackName;
4702
5331
  this.parameters = parameters;
4703
5332
  }
5333
+ /**
5334
+ * The requested range. A FETCH without a LOCATION_FILTER parameter asks for the
5335
+ * whole track up to the Largest Object, the same as a {@link (LocationFilterType:enum).None} filter.
5336
+ */
5337
+ get locationFilter() {
5338
+ return this.parameters.find(MessageParameter.isLocationFilter) ?? new LocationFilter(0);
5339
+ }
4704
5340
  getType() {
4705
5341
  return 22;
4706
5342
  }
@@ -4709,19 +5345,7 @@ var Fetch = class Fetch {
4709
5345
  buf.putVI(22);
4710
5346
  const payload = new ByteBuffer();
4711
5347
  payload.putVI(this.requestId);
4712
- payload.putVI(this.typeAndProps.type);
4713
- switch (this.typeAndProps.type) {
4714
- case 3:
4715
- case 2:
4716
- payload.putVI(this.typeAndProps.props.joiningRequestId);
4717
- payload.putVI(this.typeAndProps.props.joiningStart);
4718
- break;
4719
- case 1:
4720
- payload.putFullTrackName(this.typeAndProps.props.fullTrackName);
4721
- payload.putLocation(this.typeAndProps.props.startLocation);
4722
- payload.putLocation(this.typeAndProps.props.endLocation);
4723
- break;
4724
- }
5348
+ payload.putFullTrackName(this.fullTrackName);
4725
5349
  payload.putVI(this.parameters.length);
4726
5350
  payload.putBytes(serializeMessageParameterKvps(this.parameters.map((p) => p.toKeyValuePair())).toUint8Array());
4727
5351
  const payloadBytes = payload.toUint8Array();
@@ -4732,35 +5356,10 @@ var Fetch = class Fetch {
4732
5356
  }
4733
5357
  static parsePayload(buf) {
4734
5358
  const requestId = buf.getVI();
4735
- const fetchTypeRaw = buf.getVI();
4736
- const fetchType = FetchType.tryFrom(fetchTypeRaw);
4737
- let props;
4738
- switch (fetchType) {
4739
- case 3:
4740
- case 2:
4741
- props = {
4742
- type: fetchType,
4743
- props: {
4744
- joiningRequestId: buf.getVI(),
4745
- joiningStart: buf.getVI()
4746
- }
4747
- };
4748
- break;
4749
- case 1:
4750
- props = {
4751
- type: 1,
4752
- props: {
4753
- fullTrackName: buf.getFullTrackName(),
4754
- startLocation: buf.getLocation(),
4755
- endLocation: buf.getLocation()
4756
- }
4757
- };
4758
- break;
4759
- default: throw new Error(`Unknown fetch type: ${fetchType}`);
4760
- }
5359
+ const fullTrackName = buf.getFullTrackName();
4761
5360
  const rawParams = deserializeMessageParameterKvps(buf, buf.getNumberVI());
4762
5361
  const parameters = MessageParameters.fromKeyValuePairs(rawParams);
4763
- return new Fetch(requestId, props, parameters);
5362
+ return new Fetch(requestId, fullTrackName, parameters);
4764
5363
  }
4765
5364
  };
4766
5365
  //#endregion
@@ -4849,7 +5448,7 @@ var FetchOk = class FetchOk {
4849
5448
  const MAX_NEW_SESSION_URI_LENGTH = 8192;
4850
5449
  /**
4851
5450
  * GOAWAY (0x10) winds down a session, or — on a request stream — migrates that one
4852
- * request (§10.4).
5451
+ * request.
4853
5452
  */
4854
5453
  var GoAway = class GoAway {
4855
5454
  newSessionUri;
@@ -4859,16 +5458,10 @@ var GoAway = class GoAway {
4859
5458
  * on a request stream it resets the stream with `GOING_AWAY`.
4860
5459
  */
4861
5460
  timeout;
4862
- /**
4863
- * The smallest peer Request ID that was not or might not have been processed. Present
4864
- * only on the control stream, so a GOAWAY migrating a single request omits it.
4865
- */
4866
- requestId;
4867
- constructor(newSessionUri, timeout = 0n, requestId) {
5461
+ constructor(newSessionUri, timeout = 0n) {
4868
5462
  if (newSessionUri && newSessionUri.length === 0) this.newSessionUri = void 0;
4869
5463
  else this.newSessionUri = newSessionUri;
4870
5464
  this.timeout = timeout;
4871
- this.requestId = requestId;
4872
5465
  }
4873
5466
  getType() {
4874
5467
  return 16;
@@ -4887,7 +5480,6 @@ var GoAway = class GoAway {
4887
5480
  payload.putLengthPrefixedBytes(uriBytes);
4888
5481
  } else payload.putVI(0);
4889
5482
  payload.putVI(this.timeout);
4890
- if (this.requestId !== void 0) payload.putVI(this.requestId);
4891
5483
  const payloadBytes = payload.toUint8Array();
4892
5484
  if (payloadBytes.length > 65535) throw new LengthExceedsMaxError("GoAway::serialize(payloadBytes.length)", 65535, payloadBytes.length);
4893
5485
  buf.putU16(payloadBytes.length);
@@ -4908,8 +5500,7 @@ var GoAway = class GoAway {
4908
5500
  }
4909
5501
  }
4910
5502
  const timeout = buf.getVI();
4911
- const requestId = buf.remaining > 0 ? buf.getVI() : void 0;
4912
- return new GoAway(newSessionUri, timeout, requestId);
5503
+ return new GoAway(newSessionUri, timeout);
4913
5504
  }
4914
5505
  };
4915
5506
  //#endregion
@@ -4938,19 +5529,6 @@ var Subscribe = class Subscribe {
4938
5529
  this.fullTrackName = fullTrackName;
4939
5530
  this.parameters = parameters;
4940
5531
  }
4941
- static newNextGroupStart(requestId, fullTrackName, parameters) {
4942
- return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(1)]);
4943
- }
4944
- static newLatestObject(requestId, fullTrackName, parameters) {
4945
- return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(2)]);
4946
- }
4947
- static newAbsoluteStart(requestId, fullTrackName, startLocation, parameters) {
4948
- return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(3, startLocation)]);
4949
- }
4950
- static newAbsoluteRange(requestId, fullTrackName, startLocation, endGroup, parameters) {
4951
- if (endGroup < startLocation.group) throw new Error("End Group must be >= Start Group");
4952
- return new Subscribe(requestId, fullTrackName, [...parameters, new SubscriptionFilter(4, startLocation, endGroup)]);
4953
- }
4954
5532
  getType() {
4955
5533
  return 3;
4956
5534
  }
@@ -5000,6 +5578,11 @@ var PublishDone = class PublishDone {
5000
5578
  statusCode;
5001
5579
  streamCount;
5002
5580
  errorReason;
5581
+ /**
5582
+ * The Stream Count a publisher sends when it cannot name the exact number of streams
5583
+ * it opened. Receivers fall back on a timeout to end the subscription.
5584
+ */
5585
+ static UNKNOWN_STREAM_COUNT = 2n ** 64n - 1n;
5003
5586
  constructor(statusCode, streamCount, errorReason) {
5004
5587
  this.statusCode = statusCode;
5005
5588
  this.streamCount = streamCount;
@@ -5238,35 +5821,18 @@ var TrackStatus = class TrackStatus {
5238
5821
  subscriberPriority;
5239
5822
  groupOrder;
5240
5823
  forward;
5241
- filterType;
5242
- startLocation;
5243
- endGroup;
5824
+ locationFilter;
5244
5825
  subscribeParameters;
5245
- constructor(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, filterType, startLocation, endGroup, subscribeParameters) {
5826
+ constructor(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, locationFilter, subscribeParameters) {
5246
5827
  this.requestId = requestId;
5247
5828
  this.trackAlias = trackAlias;
5248
5829
  this.fullTrackName = fullTrackName;
5249
5830
  this.subscriberPriority = subscriberPriority;
5250
5831
  this.groupOrder = groupOrder;
5251
5832
  this.forward = forward;
5252
- this.filterType = filterType;
5253
- this.startLocation = startLocation;
5254
- this.endGroup = endGroup;
5833
+ this.locationFilter = locationFilter;
5255
5834
  this.subscribeParameters = subscribeParameters;
5256
5835
  }
5257
- static newNextGroupStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
5258
- return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 1, void 0, void 0, subscribeParameters);
5259
- }
5260
- static newLatestObject(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, subscribeParameters) {
5261
- return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 2, void 0, void 0, subscribeParameters);
5262
- }
5263
- static newAbsoluteStart(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, subscribeParameters) {
5264
- return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 3, startLocation, void 0, subscribeParameters);
5265
- }
5266
- static newAbsoluteRange(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, startLocation, endGroup, subscribeParameters) {
5267
- if (endGroup < startLocation.group) throw new Error("End Group must be >= Start Group");
5268
- return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, 4, startLocation, endGroup, subscribeParameters);
5269
- }
5270
5836
  getType() {
5271
5837
  return 13;
5272
5838
  }
@@ -5280,15 +5846,7 @@ var TrackStatus = class TrackStatus {
5280
5846
  payload.putU8(this.subscriberPriority);
5281
5847
  payload.putU8(this.groupOrder);
5282
5848
  payload.putU8(this.forward ? 1 : 0);
5283
- payload.putVI(this.filterType);
5284
- if (this.filterType === 3 || this.filterType === 4) {
5285
- if (!this.startLocation) throw new Error("StartLocation required for selected filterType");
5286
- payload.putLocation(this.startLocation);
5287
- }
5288
- if (this.filterType === 4) {
5289
- if (this.endGroup == null) throw new Error("EndGroup required for AbsoluteRange");
5290
- payload.putVI(this.endGroup);
5291
- }
5849
+ payload.putBytes(this.locationFilter.serializeValue());
5292
5850
  payload.putVI(this.subscribeParameters.length);
5293
5851
  payload.putBytes(serializeMessageParameterKvps(this.subscribeParameters.map((p) => p.toKeyValuePair())).toUint8Array());
5294
5852
  const payloadBytes = payload.toUint8Array();
@@ -5303,14 +5861,10 @@ var TrackStatus = class TrackStatus {
5303
5861
  const subscriberPriority = buf.getU8();
5304
5862
  const groupOrder = buf.getU8();
5305
5863
  const forward = buf.getU8() === 1;
5306
- const filterType = Number(buf.getVI());
5307
- let startLocation = void 0;
5308
- let endGroup = void 0;
5309
- if (filterType === 3 || filterType === 4) startLocation = buf.getLocation();
5310
- if (filterType === 4) endGroup = buf.getVI();
5864
+ const locationFilter = LocationFilter.deserializeValue(buf);
5311
5865
  const rawParams = deserializeMessageParameterKvps(buf, Number(buf.getVI()));
5312
5866
  const subscribeParameters = MessageParameters.fromKeyValuePairs(rawParams);
5313
- return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, filterType, startLocation, endGroup, subscribeParameters);
5867
+ return new TrackStatus(requestId, trackAlias, fullTrackName, subscriberPriority, groupOrder, forward, locationFilter, subscribeParameters);
5314
5868
  }
5315
5869
  };
5316
5870
  //#endregion
@@ -5446,13 +6000,12 @@ var SubscribeTracks = class SubscribeTracks {
5446
6000
  * names (PUBLISH_OK, TRACK_STATUS_OK, ...) are shorthands for logging, not distinct
5447
6001
  * messages. SUBSCRIBE_OK (0x4) and FETCH_OK (0x18) do keep bodies of their own.
5448
6002
  *
5449
- * It carries no Request ID: the request stream it arrives on identifies the request
5450
- * (§10.1).
6003
+ * It carries no Request ID: the request stream it arrives on identifies the request.
5451
6004
  */
5452
6005
  var RequestOk = class RequestOk {
5453
6006
  parameters;
5454
6007
  /**
5455
- * Draft-18 Track Properties, which the trailing bytes of the payload carry with no
6008
+ * Track Properties, which the trailing bytes of the payload carry with no
5456
6009
  * count of their own. Populated only in TRACK_STATUS_OK; empty for every other request
5457
6010
  * type — see {@link RequestOk.validateTrackProperties}.
5458
6011
  */
@@ -5614,7 +6167,7 @@ let ControlMessage;
5614
6167
  case 80: return SubscribeNamespace.parsePayload(payload);
5615
6168
  case 81: return SubscribeTracks.parsePayload(payload);
5616
6169
  case 12032: return Setup.parsePayload(payload);
5617
- case 15: return PublishBlocked.parsePayload(payload);
6170
+ case 15: return PublishSkipped.parsePayload(payload);
5618
6171
  default: throw new Error(`Unknown or unhandled ControlMessageType: ${messageType}`);
5619
6172
  }
5620
6173
  }
@@ -5793,59 +6346,6 @@ var CMSFCatalog = class CMSFCatalog {
5793
6346
  }
5794
6347
  };
5795
6348
  //#endregion
5796
- //#region src/model/control/switch.ts
5797
- /**
5798
- * Copyright 2025 The MOQtail Authors
5799
- *
5800
- * Licensed under the Apache License, Version 2.0 (the "License");
5801
- * you may not use this file except in compliance with the License.
5802
- * You may obtain a copy of the License at
5803
- *
5804
- * http://www.apache.org/licenses/LICENSE-2.0
5805
- *
5806
- * Unless required by applicable law or agreed to in writing, software
5807
- * distributed under the License is distributed on an "AS IS" BASIS,
5808
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5809
- * See the License for the specific language governing permissions and
5810
- * limitations under the License.
5811
- */
5812
- var Switch = class Switch {
5813
- requestId;
5814
- fullTrackName;
5815
- subscriptionRequestId;
5816
- parameters;
5817
- constructor(requestId, fullTrackName, subscriptionRequestId, parameters) {
5818
- this.requestId = requestId;
5819
- this.fullTrackName = fullTrackName;
5820
- this.subscriptionRequestId = subscriptionRequestId;
5821
- this.parameters = parameters;
5822
- }
5823
- getType() {
5824
- return 34;
5825
- }
5826
- serialize() {
5827
- const buf = new ByteBuffer();
5828
- buf.putVI(34);
5829
- const payload = new ByteBuffer();
5830
- payload.putVI(this.requestId);
5831
- payload.putBytes(this.fullTrackName.serialize().toUint8Array());
5832
- payload.putVI(this.subscriptionRequestId);
5833
- payload.putVI(this.parameters.length);
5834
- payload.putBytes(serializeMessageParameterKvps(this.parameters).toUint8Array());
5835
- const payloadBytes = payload.toUint8Array();
5836
- buf.putU16(payloadBytes.length);
5837
- buf.putBytes(payloadBytes);
5838
- return buf.freeze();
5839
- }
5840
- static parsePayload(buf) {
5841
- const requestId = buf.getVI();
5842
- const fullTrackName = buf.getFullTrackName();
5843
- const subscriptionRequestId = buf.getVI();
5844
- const parameters = deserializeMessageParameterKvps(buf, Number(buf.getVI()));
5845
- return new Switch(requestId, fullTrackName, subscriptionRequestId, parameters);
5846
- }
5847
- };
5848
- //#endregion
5849
6349
  //#region src/model/parameter/setup/path.ts
5850
6350
  /**
5851
6351
  * Copyright 2025 The MOQtail Authors
@@ -5928,7 +6428,7 @@ var MaxAuthTokenCacheSize = class MaxAuthTokenCacheSize {
5928
6428
  */
5929
6429
  /**
5930
6430
  * Raw-QUIC only: the authority component of the `moqt://` URI, carried in SETUP because
5931
- * there is no HTTP CONNECT to carry it (draft-18 §10.3.1.1).
6431
+ * there is no HTTP CONNECT to carry it.
5932
6432
  *
5933
6433
  * Client-only; MUST NOT be sent by a server or over WebTransport. moqtail-ts always
5934
6434
  * connects over WebTransport, so its own handshake never sends this — see
@@ -5951,6 +6451,42 @@ var Authority = class Authority {
5951
6451
  }
5952
6452
  };
5953
6453
  //#endregion
6454
+ //#region src/model/parameter/setup/max_filter_ranges.ts
6455
+ /**
6456
+ * Copyright 2026 The MOQtail Authors
6457
+ *
6458
+ * Licensed under the Apache License, Version 2.0 (the "License");
6459
+ * you may not use this file except in compliance with the License.
6460
+ * You may obtain a copy of the License at
6461
+ *
6462
+ * http://www.apache.org/licenses/LICENSE-2.0
6463
+ *
6464
+ * Unless required by applicable law or agreed to in writing, software
6465
+ * distributed under the License is distributed on an "AS IS" BASIS,
6466
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6467
+ * See the License for the specific language governing permissions and
6468
+ * limitations under the License.
6469
+ */
6470
+ /**
6471
+ * Limits the total number of Ranges the peer may have across all Range filter parameters
6472
+ * of a single subscription or fetch. Zero, the default when absent, means the peer may
6473
+ * not send Range filters at all.
6474
+ */
6475
+ var MaxFilterRanges = class MaxFilterRanges {
6476
+ value;
6477
+ static TYPE = 6;
6478
+ constructor(value) {
6479
+ this.value = value;
6480
+ }
6481
+ toKeyValuePair() {
6482
+ return KeyValuePair.tryNewVarInt(MaxFilterRanges.TYPE, this.value);
6483
+ }
6484
+ static fromKeyValuePair(pair) {
6485
+ if (Number(pair.typeValue) !== MaxFilterRanges.TYPE || typeof pair.value !== "bigint") return void 0;
6486
+ return new MaxFilterRanges(pair.value);
6487
+ }
6488
+ };
6489
+ //#endregion
5954
6490
  //#region src/model/parameter/setup/moqt_implementation.ts
5955
6491
  /**
5956
6492
  * Copyright 2026 The MOQtail Authors
@@ -5968,8 +6504,8 @@ var Authority = class Authority {
5968
6504
  * limitations under the License.
5969
6505
  */
5970
6506
  /**
5971
- * Free-form implementation identification string, e.g. for logging and debugging
5972
- * (draft-18 §10.3.1.5). Either peer may send it.
6507
+ * Free-form implementation identification string, e.g. for logging and debugging.
6508
+ * Either peer may send it.
5973
6509
  */
5974
6510
  var MoqtImplementation = class MoqtImplementation {
5975
6511
  info;
@@ -5988,6 +6524,42 @@ var MoqtImplementation = class MoqtImplementation {
5988
6524
  }
5989
6525
  };
5990
6526
  //#endregion
6527
+ //#region src/model/parameter/setup/max_request_updates.ts
6528
+ /**
6529
+ * Copyright 2026 The MOQtail Authors
6530
+ *
6531
+ * Licensed under the Apache License, Version 2.0 (the "License");
6532
+ * you may not use this file except in compliance with the License.
6533
+ * You may obtain a copy of the License at
6534
+ *
6535
+ * http://www.apache.org/licenses/LICENSE-2.0
6536
+ *
6537
+ * Unless required by applicable law or agreed to in writing, software
6538
+ * distributed under the License is distributed on an "AS IS" BASIS,
6539
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6540
+ * See the License for the specific language governing permissions and
6541
+ * limitations under the License.
6542
+ */
6543
+ /**
6544
+ * Maximum number of outstanding REQUEST_UPDATEs per request stream: an update counts
6545
+ * until its REQUEST_OK or REQUEST_ERROR arrives. Zero, the default when absent, means
6546
+ * no limit. Receiving one past the limit closes the session with TOO_MANY_REQUEST_UPDATES.
6547
+ */
6548
+ var MaxRequestUpdates = class MaxRequestUpdates {
6549
+ value;
6550
+ static TYPE = 8;
6551
+ constructor(value) {
6552
+ this.value = value;
6553
+ }
6554
+ toKeyValuePair() {
6555
+ return KeyValuePair.tryNewVarInt(MaxRequestUpdates.TYPE, this.value);
6556
+ }
6557
+ static fromKeyValuePair(pair) {
6558
+ if (Number(pair.typeValue) !== MaxRequestUpdates.TYPE || typeof pair.value !== "bigint") return void 0;
6559
+ return new MaxRequestUpdates(pair.value);
6560
+ }
6561
+ };
6562
+ //#endregion
5991
6563
  //#region src/model/parameter/setup/ssts_algorithms.ts
5992
6564
  /**
5993
6565
  * Copyright 2026 The MOQtail Authors
@@ -6009,7 +6581,7 @@ var MoqtImplementation = class MoqtImplementation {
6009
6581
  *
6010
6582
  * PROVISIONAL: sender-side track switching is not an adopted extension, so
6011
6583
  * this option has no codepoint in the registry the conformance fixture tracks
6012
- * (`dev/conformance/draft18`) and is never asserted against it. An empty list
6584
+ * (`dev/conformance/draft22`) and is never asserted against it. An empty list
6013
6585
  * — or the absence of the option — prohibits the use of SSTS.
6014
6586
  */
6015
6587
  var SstsAlgorithms = class SstsAlgorithms {
@@ -6037,7 +6609,7 @@ var SstsAlgorithms = class SstsAlgorithms {
6037
6609
  let SetupOption;
6038
6610
  (function(_SetupOption) {
6039
6611
  function fromKeyValuePair(pair) {
6040
- return Path.fromKeyValuePair(pair) || MaxAuthTokenCacheSize.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair) || Authority.fromKeyValuePair(pair) || MoqtImplementation.fromKeyValuePair(pair) || SstsAlgorithms.fromKeyValuePair(pair);
6612
+ return Path.fromKeyValuePair(pair) || MaxAuthTokenCacheSize.fromKeyValuePair(pair) || AuthorizationToken.fromKeyValuePair(pair) || Authority.fromKeyValuePair(pair) || MaxFilterRanges.fromKeyValuePair(pair) || MoqtImplementation.fromKeyValuePair(pair) || MaxRequestUpdates.fromKeyValuePair(pair) || SstsAlgorithms.fromKeyValuePair(pair);
6041
6613
  }
6042
6614
  _SetupOption.fromKeyValuePair = fromKeyValuePair;
6043
6615
  function toKeyValuePair(param) {
@@ -6060,6 +6632,14 @@ let SetupOption;
6060
6632
  return param instanceof Authority;
6061
6633
  }
6062
6634
  _SetupOption.isAuthority = isAuthority;
6635
+ function isMaxFilterRanges(param) {
6636
+ return param instanceof MaxFilterRanges;
6637
+ }
6638
+ _SetupOption.isMaxFilterRanges = isMaxFilterRanges;
6639
+ function isMaxRequestUpdates(param) {
6640
+ return param instanceof MaxRequestUpdates;
6641
+ }
6642
+ _SetupOption.isMaxRequestUpdates = isMaxRequestUpdates;
6063
6643
  function isMoqtImplementation(param) {
6064
6644
  return param instanceof MoqtImplementation;
6065
6645
  }
@@ -6071,7 +6651,7 @@ let SetupOption;
6071
6651
  })(SetupOption || (SetupOption = {}));
6072
6652
  /** Throws if `params` carries AUTHORITY, which MUST NOT be sent over WebTransport. */
6073
6653
  function assertNoAuthorityOverWebTransport(params) {
6074
- if (params.some((p) => Number(p.typeValue) === 5)) throw new ProtocolViolationError("assertNoAuthorityOverWebTransport", "AUTHORITY setup option MUST NOT be sent over WebTransport (draft-18 §10.3.1.1)");
6654
+ if (params.some((p) => Number(p.typeValue) === 5)) throw new ProtocolViolationError("assertNoAuthorityOverWebTransport", "AUTHORITY setup option MUST NOT be sent over WebTransport");
6075
6655
  }
6076
6656
  var SetupOptions = class {
6077
6657
  kvps = [];
@@ -6087,6 +6667,14 @@ var SetupOptions = class {
6087
6667
  this.kvps.push(auth.toKeyValuePair());
6088
6668
  return this;
6089
6669
  }
6670
+ addMaxFilterRanges(value) {
6671
+ this.kvps.push(new MaxFilterRanges(BigInt(value)).toKeyValuePair());
6672
+ return this;
6673
+ }
6674
+ addMaxRequestUpdates(value) {
6675
+ this.kvps.push(new MaxRequestUpdates(BigInt(value)).toKeyValuePair());
6676
+ return this;
6677
+ }
6090
6678
  addMoqtImplementation(info) {
6091
6679
  this.kvps.push(new MoqtImplementation(info).toKeyValuePair());
6092
6680
  return this;
@@ -6105,11 +6693,130 @@ var SetupOptions = class {
6105
6693
  static fromKeyValuePairs(kvps) {
6106
6694
  const result = [];
6107
6695
  for (const kvp of kvps) {
6108
- const parsed = Path.fromKeyValuePair(kvp) || MaxAuthTokenCacheSize.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp) || Authority.fromKeyValuePair(kvp) || MoqtImplementation.fromKeyValuePair(kvp) || SstsAlgorithms.fromKeyValuePair(kvp);
6696
+ const parsed = Path.fromKeyValuePair(kvp) || MaxAuthTokenCacheSize.fromKeyValuePair(kvp) || AuthorizationToken.fromKeyValuePair(kvp) || Authority.fromKeyValuePair(kvp) || MaxFilterRanges.fromKeyValuePair(kvp) || MoqtImplementation.fromKeyValuePair(kvp) || MaxRequestUpdates.fromKeyValuePair(kvp) || SstsAlgorithms.fromKeyValuePair(kvp);
6109
6697
  if (parsed) result.push(parsed);
6110
6698
  }
6111
6699
  return result;
6112
6700
  }
6113
6701
  };
6114
6702
  //#endregion
6115
- export { AudioLevel, Authority, AuthorizationToken, BaseByteBuffer, ByteBuffer, CMSFCatalog, CastingError, ControlMessage, ControlMessageType, DEFAULT_PUBLISHER_PRIORITY, Datagram, DefaultPublisherGroupOrderProperty, DefaultPublisherPriorityProperty, DynamicGroupsProperty, EndOfRangeKind, Expires, Fetch, FetchHeader, FetchHeaderType, FetchObject, FetchOk, FetchType, FillTimeout, FilterType, Forward, FrozenByteBuffer, FullTrackName, GREASE_BASE, GREASE_STEP, GoAway, GroupOrder, GroupOrderParam, Header, ImmutablePropertiesObjectProperty, ImmutablePropertiesTrackProperty, InternalError, InvalidEnumValue, InvalidTypeError, InvalidUTF8Error, KeyValueFormattingError, KeyValuePair, LOCProperties, LOCProperty, LOCPropertyId, LargestObject, LengthExceedsMaxError, Location, MAX_FULL_TRACK_NAME_LENGTH, MAX_NAMESPACE_TUPLE_COUNT, MAX_NEW_SESSION_URI_LENGTH, MAX_REASON_PHRASE_LEN, MOQtailError, MaxAuthTokenCacheSize, MaxCacheDurationProperty, MessageParameter, MessageParameterType, MessageParameters, MoqtImplementation, MoqtObject, MoqtUrl, Namespace, NamespaceDone, NewGroupRequest, NotEnoughBytesError, ObjectDatagramType, ObjectDeliveryTimeout, ObjectDeliveryTimeoutProperty, ObjectForwardingPreference, ObjectProperty, ObjectStatus, Path, PriorGroupIdGapProperty, PriorObjectIdGapProperty, PropertyRanges, ProtocolViolationError, Publish, PublishBlocked, PublishDone, PublishDoneStatusCode, PublishNamespace, ReasonPhrase, Redirect, RendezvousTimeout, RequestError, RequestErrorCode, RequestIdError, RequestIdMap, RequestOk, RequestUpdate, SUPPORTED_VERSIONS, Setup, SetupOption, SetupOptionType, SetupOptions, SstsAlgorithms, StreamResetCode, SubgroupDeliveryTimeout, SubgroupDeliveryTimeoutProperty, SubgroupHeader, SubgroupHeaderType, SubgroupObject, Subscribe, SubscribeNamespace, SubscribeOk, SubscribeTracks, SubscriberPriority, SubscriptionFilter, Switch, SwitchingSetAssignment, TerminationCode, TerminationError, TimeoutError, Timescale, Timestamp, TokenAliasType, TrackNameError, TrackProperty, TrackPropertyType, TrackStatus, TrackStatusCode, Tuple, TupleField, UnknownObjectProperty, UnknownTrackProperty, VarIntOverflowError, VideoConfig, VideoFrameMarking, applyMessageParameterUpdate, assertNoAuthorityOverWebTransport, deserializeKvpList, deserializeKvpListUntilEmpty, deserializeMessageParameterKvps, greaseValue, isApplicationSpecificProperty, isBytes, isGrease, isVarInt, locPropertyIdFromNumber, messageParameterTypeFromNumber, resolveTransportUrl, serializeKvpList, serializeMessageParameterKvps, setupOptionTypeFromNumber, tokenAliasTypeFromNumber };
6703
+ //#region src/model/parameter/message/combined_filter.ts
6704
+ /**
6705
+ * Copyright 2026 The MOQtail Authors
6706
+ *
6707
+ * Licensed under the Apache License, Version 2.0 (the "License");
6708
+ * you may not use this file except in compliance with the License.
6709
+ * You may obtain a copy of the License at
6710
+ *
6711
+ * http://www.apache.org/licenses/LICENSE-2.0
6712
+ *
6713
+ * Unless required by applicable law or agreed to in writing, software
6714
+ * distributed under the License is distributed on an "AS IS" BASIS,
6715
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6716
+ * See the License for the specific language governing permissions and
6717
+ * limitations under the License.
6718
+ */
6719
+ const within = (ranges, value) => ranges.some((r) => value >= r.start && (r.end === void 0 || value <= r.end));
6720
+ /**
6721
+ * The object filter a request's Range Filters add up to.
6722
+ *
6723
+ * Ranges within one filter are OR'd, filters sharing a SetID are AND'd, and the
6724
+ * SetIDs are OR'd with each other. No filter at all passes every Object.
6725
+ */
6726
+ var CombinedFilter = class {
6727
+ #sets = /* @__PURE__ */ new Map();
6728
+ /** How many Ranges the filters hold, which is what a range limit counts. */
6729
+ rangeCount;
6730
+ /**
6731
+ * Builds the filter from every Range Filter in `params`; anything else, and a
6732
+ * zero-length removal, is ignored.
6733
+ *
6734
+ * @throws :{@link InvalidFilterError} For a filter that cannot be applied: one
6735
+ * that repeats a Type, SetID and Property Type already given, one with an odd
6736
+ * Property Type, a priority above 255 or a bound past 2^64-1, or a track filter,
6737
+ * which selects tracks rather than Objects.
6738
+ */
6739
+ constructor(params) {
6740
+ let rangeCount = 0;
6741
+ const seen = /* @__PURE__ */ new Set();
6742
+ for (const param of params) {
6743
+ if (!(param instanceof RangeFilter) || param.isRemoval) continue;
6744
+ const filter = param;
6745
+ if (filter.kind === RangeFilterKind.TrackProperty) throw new InvalidFilterError("CombinedFilter", "a track property filter selects tracks, not Objects");
6746
+ const key = `${filter.kind}/${filter.setId}/${filter.propertyType ?? ""}`;
6747
+ if (seen.has(key)) throw new InvalidFilterError("CombinedFilter", `${RangeFilterKind[filter.kind]} filter repeats SetID ${filter.setId}` + (filter.propertyType !== void 0 ? ` for property 0x${filter.propertyType.toString(16)}` : ""));
6748
+ seen.add(key);
6749
+ const ranges = filter.validate();
6750
+ rangeCount += ranges.length;
6751
+ let set = this.#sets.get(filter.setId);
6752
+ if (!set) {
6753
+ set = { properties: /* @__PURE__ */ new Map() };
6754
+ this.#sets.set(filter.setId, set);
6755
+ }
6756
+ switch (filter.kind) {
6757
+ case RangeFilterKind.Subgroup:
6758
+ set.subgroup = ranges;
6759
+ break;
6760
+ case RangeFilterKind.ObjectId:
6761
+ set.objectId = ranges;
6762
+ break;
6763
+ case RangeFilterKind.Priority:
6764
+ set.priority = ranges;
6765
+ break;
6766
+ case RangeFilterKind.ObjectProperty:
6767
+ set.properties.set(filter.propertyType, ranges);
6768
+ break;
6769
+ }
6770
+ }
6771
+ this.rangeCount = rangeCount;
6772
+ }
6773
+ /** Whether the filter passes everything. */
6774
+ get isEmpty() {
6775
+ return this.#sets.size === 0;
6776
+ }
6777
+ /**
6778
+ * Whether `obj` passes.
6779
+ *
6780
+ * @param subgroupId - The Subgroup ID `obj` travels in. It is passed in because an
6781
+ * Object whose Subgroup ID is its subgroup's first Object ID does not know it
6782
+ * itself. `null` — a datagram — has no subgroup, so no subgroup filter passes it.
6783
+ */
6784
+ matches(obj, subgroupId = obj.subgroupId) {
6785
+ if (this.isEmpty) return true;
6786
+ for (const set of this.#sets.values()) {
6787
+ if (set.subgroup && (subgroupId === null || !within(set.subgroup, subgroupId))) continue;
6788
+ if (set.objectId && !within(set.objectId, obj.location.object)) continue;
6789
+ if (set.priority && !within(set.priority, BigInt(obj.publisherPriority))) continue;
6790
+ if (!propertiesPass(set.properties, obj.properties)) continue;
6791
+ return true;
6792
+ }
6793
+ return false;
6794
+ }
6795
+ };
6796
+ /**
6797
+ * Whether each required Property is present with a value in its Ranges. One the
6798
+ * Object does not carry fails. Properties inside ImmutableProperties count as the
6799
+ * Object's own.
6800
+ */
6801
+ function propertiesPass(required, properties) {
6802
+ if (required.size === 0) return true;
6803
+ const values = /* @__PURE__ */ new Map();
6804
+ const collect = (pairs) => {
6805
+ for (const pair of pairs) {
6806
+ if (isVarInt(pair)) {
6807
+ if (!values.has(pair.typeValue)) values.set(pair.typeValue, pair.value);
6808
+ continue;
6809
+ }
6810
+ const immutable = ImmutablePropertiesObjectProperty.fromKeyValuePair(pair);
6811
+ if (immutable) collect(immutable.properties);
6812
+ }
6813
+ };
6814
+ collect(properties ?? []);
6815
+ for (const [type, ranges] of required) {
6816
+ const value = values.get(type);
6817
+ if (value === void 0 || !within(ranges, value)) return false;
6818
+ }
6819
+ return true;
6820
+ }
6821
+ //#endregion
6822
+ export { AudioConfig, AudioLevel, Authority, AuthorizationToken, BaseByteBuffer, ByteBuffer, CMSFCatalog, CastingError, CombinedFilter, ControlMessage, ControlMessageType, DEFAULT_PUBLISHER_PRIORITY, Datagram, DefaultPublisherGroupOrderProperty, DefaultPublisherPriorityProperty, DynamicGroupsProperty, EndOfRangeKind, Expires, Fetch, FetchHeader, FetchHeaderType, FetchObject, FetchOk, FillParameters, FillTimeout, Forward, FrozenByteBuffer, FullTrackName, GREASE_BASE, GREASE_STEP, GoAway, GroupOrder, GroupOrderParam, Header, ImmutablePropertiesObjectProperty, ImmutablePropertiesTrackProperty, IncludeProperties, InternalError, InvalidEnumValue, InvalidFilterError, InvalidTypeError, InvalidUTF8Error, KeyValueFormattingError, KeyValuePair, LOCProperties, LOCProperty, LOCPropertyId, LargestObject, LengthExceedsMaxError, Location, LocationFilter, LocationFilterType, MAX_FULL_TRACK_NAME_LENGTH, MAX_NAMESPACE_TUPLE_COUNT, MAX_NEW_SESSION_URI_LENGTH, MAX_REASON_PHRASE_LEN, MOQtailError, MaxAuthTokenCacheSize, MaxCacheDurationProperty, MaxFilterRanges, MaxRequestUpdates, MessageParameter, MessageParameterType, MessageParameters, MoqtImplementation, MoqtObject, MoqtUrl, Namespace, NamespaceDone, NewGroupRequest, NotEnoughBytesError, ObjectDatagramType, ObjectDeliveryTimeout, ObjectDeliveryTimeoutProperty, ObjectForwardingPreference, ObjectProperty, ObjectStatus, Path, PriorGroupIdGapProperty, PriorObjectIdGapProperty, PropertyRanges, ProtocolViolationError, Publish, PublishDone, PublishDoneStatusCode, PublishNamespace, PublishSkipped, RangeFilter, RangeFilterKind, ReasonPhrase, Redirect, RendezvousTimeout, RequestError, RequestErrorCode, RequestIdError, RequestIdMap, RequestOk, RequestUpdate, SUPPORTED_VERSIONS, Setup, SetupOption, SetupOptionType, SetupOptions, SstsAlgorithms, StreamResetCode, SubgroupDeliveryTimeout, SubgroupDeliveryTimeoutProperty, SubgroupHeader, SubgroupHeaderType, SubgroupObject, Subscribe, SubscribeNamespace, SubscribeOk, SubscribeTracks, SubscriberPriority, SwitchFrom, SwitchMode, SwitchingSetAssignment, TerminationCode, TerminationError, TimeoutError, Timescale, Timestamp, TokenAliasType, TrackNameError, TrackProperty, TrackPropertyType, TrackStatus, TrackStatusCode, Tuple, TupleField, UnknownObjectProperty, UnknownTrackProperty, VarIntOverflowError, VideoConfig, VideoFrameMarking, applyMessageParameterUpdate, assertNoAuthorityOverWebTransport, deserializeKvpList, deserializeKvpListUntilEmpty, deserializeMessageParameterKvps, encodeRanges, greaseValue, isApplicationSpecificProperty, isBytes, isGrease, isVarInt, locPropertyIdFromNumber, messageParameterTypeFromNumber, resolveTransportUrl, serializeKvpList, serializeMessageParameterKvps, setupOptionTypeFromNumber, tokenAliasTypeFromNumber };