@cosyte/dicom 0.0.13 → 0.0.15

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/index.mjs CHANGED
@@ -9,7 +9,7 @@ var __export = (target, all) => {
9
9
  };
10
10
 
11
11
  // src/version.ts
12
- var VERSION = "0.0.13";
12
+ var VERSION = "0.0.15";
13
13
 
14
14
  // src/dictionary/index.ts
15
15
  var dictionary_exports = {};
@@ -11785,6 +11785,11 @@ function safePrivateCreator(creator, profile) {
11785
11785
  function renderVr(vr) {
11786
11786
  return vr !== void 0 && KNOWN_VRS.has(vr) ? vr : WITHHELD;
11787
11787
  }
11788
+ var TAG_SHAPE = /^[0-9A-F]{8}$/u;
11789
+ function renderTag(tag) {
11790
+ if (tag === void 0 || !TAG_SHAPE.test(tag)) return WITHHELD;
11791
+ return lookup(tag) === void 0 ? WITHHELD : tag;
11792
+ }
11788
11793
 
11789
11794
  // src/parser/fatals.ts
11790
11795
  var SUPPORTED_TRANSFER_SYNTAXES = "1.2.840.10008.1.2, 1.2.840.10008.1.2.1, 1.2.840.10008.1.2.2, 1.2.840.10008.1.2.1.99";
@@ -11833,7 +11838,7 @@ var FATAL_MESSAGES = Object.freeze({
11833
11838
  // four bytes are not what they claim to be.
11834
11839
  FILE_META_GROUP_LENGTH_OVERRUNS: {
11835
11840
  code: FATAL_CODES.INVALID_FILE_META,
11836
- message: "(0002,0000) FileMetaInformationGroupLength declares more bytes than remain in the input; {n} bytes remain. The declared length is withheld; the byte offset locates the group."
11841
+ message: "(0002,0000) FileMetaInformationGroupLength declares more bytes than remain in the input. The declared length and the count of bytes that remain are withheld; the byte offset locates the group."
11837
11842
  },
11838
11843
  FILE_META_TRANSFER_SYNTAX_MISSING: {
11839
11844
  code: FATAL_CODES.INVALID_FILE_META,
@@ -11876,7 +11881,7 @@ var FATAL_MESSAGES = Object.freeze({
11876
11881
  },
11877
11882
  ELEMENT_LENGTH_EXCEEDS_BUFFER: {
11878
11883
  code: FATAL_CODES.INVALID_FILE_META,
11879
- message: "An element declares a Value Length reaching past the end of the bytes being read; {n} bytes remain. Its tag and its declared length are withheld; the byte offset locates it."
11884
+ message: "An element declares a Value Length reaching past the end of the bytes being read. Its tag, its declared length and the count of bytes that remain are withheld; the byte offset locates it."
11880
11885
  },
11881
11886
  UNEXPECTED_TAG_INSIDE_SEQUENCE: {
11882
11887
  code: FATAL_CODES.INVALID_FILE_META,
@@ -11947,8 +11952,8 @@ function unsupportedTransferSyntax(buffer, offset, ts) {
11947
11952
  function fileMetaTruncated(buffer, offset) {
11948
11953
  return at("FILE_META_TRUNCATED", buffer, offset);
11949
11954
  }
11950
- function fileMetaGroupLengthOverruns(buffer, offset, remaining) {
11951
- return at("FILE_META_GROUP_LENGTH_OVERRUNS", buffer, offset, { n: remaining });
11955
+ function fileMetaGroupLengthOverruns(buffer, offset) {
11956
+ return at("FILE_META_GROUP_LENGTH_OVERRUNS", buffer, offset);
11952
11957
  }
11953
11958
  function fileMetaTransferSyntaxMissing(buffer, offset) {
11954
11959
  return at("FILE_META_TRANSFER_SYNTAX_MISSING", buffer, offset);
@@ -11977,8 +11982,8 @@ function undefinedLengthOnNonSqExplicit(buffer, offset, vr) {
11977
11982
  function undefinedLengthOnNonSqImplicit(buffer, offset, vr) {
11978
11983
  return at("UNDEFINED_LENGTH_ON_NON_SQ_IMPLICIT", buffer, offset, { vr });
11979
11984
  }
11980
- function elementLengthExceedsBuffer(buffer, offset, remaining) {
11981
- return at("ELEMENT_LENGTH_EXCEEDS_BUFFER", buffer, offset, { n: remaining });
11985
+ function elementLengthExceedsBuffer(buffer, offset) {
11986
+ return at("ELEMENT_LENGTH_EXCEEDS_BUFFER", buffer, offset);
11982
11987
  }
11983
11988
  function unexpectedTagInsideSequence(buffer, offset) {
11984
11989
  return at("UNEXPECTED_TAG_INSIDE_SEQUENCE", buffer, offset);
@@ -12204,15 +12209,38 @@ var WARNING_MESSAGES = Object.freeze({
12204
12209
  DICOM_FILE_META_GROUP_LENGTH_MISSING: "(0002,0000) FileMetaInformationGroupLength missing; scanning forward to first non-(0002,xxxx) element.",
12205
12210
  DICOM_FILE_META_GROUP_LENGTH_MISMATCH: "(0002,0000) FileMetaInformationGroupLength declared {n} bytes; actual File Meta group size is {n2} bytes. Trusting actual.",
12206
12211
  DICOM_UNDEFINED_LENGTH_IN_EXPLICIT_VR: "Element ({tag}) uses undefined length (0xFFFFFFFF) under an Explicit VR transfer syntax.",
12207
- DICOM_ODD_LENGTH_VALUE_PADDED: "Element ({tag}) has odd declared length {n}; cursor advanced by one padding byte to maintain alignment.",
12212
+ // The declared length is gone from this string and the reason is measured, not
12213
+ // cautious: this code fires on ANY element header, including one a lying Value
12214
+ // Length upstream composed out of somebody's value, and it then rendered four
12215
+ // payload bytes as {tag} and four more as the decimal {n} - eight consecutive
12216
+ // bytes of a name in one message. See `oddLengthValuePadded`.
12217
+ DICOM_ODD_LENGTH_VALUE_PADDED: "Element ({tag}) has an odd declared length; cursor advanced by one padding byte to maintain alignment. The declared length is withheld; the byte offset identifies the element.",
12208
12218
  DICOM_VR_MISMATCH: "Element ({tag}) on-wire VR is {vr2}; dictionary lists {vr}. Trusting on-wire VR.",
12209
- DICOM_PRIVATE_TAG_NO_CREATOR: "Private element ({tag}) has no Private Creator registered for its block; treating as VR=UN.",
12210
- DICOM_GROUP_LENGTH_IN_DATASET: "Retired Group Length element ({tag}) encountered in dataset; preserved as-is.",
12219
+ // No tag, and the reason is the one `nonzeroReservedBytes` states: this code's
12220
+ // three siblings below fire only on an ODD group, and an odd group is the one
12221
+ // class of tag no closed table this library holds can ever vouch for. See
12222
+ // `privateTagNoCreator`.
12223
+ DICOM_PRIVATE_TAG_NO_CREATOR: "A private element has no Private Creator registered for its block; treating as VR=UN. Its tag is withheld; the byte offset identifies the element.",
12224
+ // No tag, and it is the membership bound in `renderTag` that made the slot
12225
+ // dead rather than a judgement here: this code fires on a (gggg,0000), the
12226
+ // element number is a constant of the code, and PS3.6 carries a literal row
12227
+ // for exactly one such tag - (0002,0000), which is File Meta and never
12228
+ // reaches this code. So every tag this slot could ever have rendered was one
12229
+ // no closed table names, leaving the group number as sixteen free bits of a
12230
+ // header that may itself be fabricated. See `groupLengthInDataset`.
12231
+ DICOM_GROUP_LENGTH_IN_DATASET: "A retired Group Length element (gggg,0000) was encountered in the dataset; preserved as-is. Its group number is withheld; the byte offset identifies the element.",
12211
12232
  // The tag is deliberately absent, and this is the only *parser* message where
12212
12233
  // that is true. See `nonzeroReservedBytes`. Kept terse for the same reason the
12213
12234
  // de-identify messages are: it is emitted once per element, and element count
12214
12235
  // is attacker-chosen.
12215
- DICOM_NONZERO_RESERVED_BYTES: "Non-zero reserved bytes between VR and length (first byte {n}, second byte {n2}); ignoring. Tag withheld; the byte offset identifies the element.",
12236
+ // 🩺 THE TWO BYTE VALUES ARE GONE FOR THE REASON THE TAG WAS ALREADY GONE, AND
12237
+ // LEAVING THEM MADE THAT BOUND HALF A BOUND. This code's trigger is "these two
12238
+ // bytes are not what PS3.5 7.1.2 says they must be", so the header may not be
12239
+ // a header - and then the reserved pair is two bytes from inside some
12240
+ // element's value, printed as two decimals that reverse with no work at all.
12241
+ // Measured on a name-bearing payload across six under-declare deltas. See
12242
+ // `nonzeroReservedBytes`.
12243
+ DICOM_NONZERO_RESERVED_BYTES: "Non-zero reserved bytes between VR and length; ignoring. Their two values are withheld with the tag; the byte offset identifies the element.",
12216
12244
  DICOM_SQ_NOT_DESCENDED: "Element ({tag}) resolved to VR=SQ from the dictionary but its defined-length value is not a valid item stream; kept as opaque bytes and NOT descended, so nothing nested inside it is visible to navigation, and deidentify() cannot audit it. See DICOM_DEIDENT_SEQUENCE_NOT_AUDITABLE.",
12217
12245
  DICOM_UN_PARSED_AS_SQ: "Element ({tag}) has VR=UN with undefined length; descended as Implicit VR LE sequence per CP-246.",
12218
12246
  DICOM_EMPTY_ITEM_IN_SEQUENCE: "Sequence ({tag}) contains an empty item (length=0); tolerated.",
@@ -12247,15 +12275,22 @@ var WARNING_MESSAGES = Object.freeze({
12247
12275
  // No value and no length, for the same reason as the code above: the retained
12248
12276
  // text is the file's own. The tag is a constant of this code.
12249
12277
  DICOM_DEIDENT_METHOD_PRIOR_RETAINED: "A De-identification Method (0012,0063) value the source file already carried was kept beside the one this run recorded, as PS3.15 E.1.1 requires. That attribute is not in Table E.1-1, so no rule in this run inspected, audited or redacted those bytes: if the sender wrote identifying text there it is in the de-identified output, under (0012,0062) = YES. The text is withheld from this message.",
12250
- // The Item's own declared length is deliberately absent. See
12251
- // `itemCrossesSequenceEnd`; `{n2}` stays because the emit site's
12252
- // `endLimit < buffer.length` conjunct bounds it by the buffer.
12253
- DICOM_ITEM_CROSSES_SEQUENCE_END: "Item ({tag}) declares a length reaching past its enclosing sequence's declared end, so it reads the enclosing Data Set's bytes; {n2} bytes remained inside the sequence. The file's two length fields disagree (PS3.5 7.5.1 and 7.5.2 govern them); the item's is used. The declared length is withheld; the byte offset locates the item.",
12254
- DICOM_PIXEL_DATA_LENGTH_MISMATCH: "(7FE0,0010) PixelData declared length {n} does not match computed {n2} bytes.",
12255
- DICOM_IMPLICIT_VR_FOR_PRIVATE_TAG_WITHOUT_VR: "Private element ({tag}) under Implicit VR LE has no VR override; falling back to UN.",
12256
- DICOM_PRIVATE_CREATOR_UNKNOWN: "Private element ({tag}) has a Private Creator the active profile's private dictionary does not name; falling back to UN. The creator string is not reproduced here - read the (gggg,00EE) element if you need it.",
12278
+ // BOTH of the disagreeing length fields are deliberately absent, and the
12279
+ // second one is the eighth instance of `DICOM-DIAGNOSTIC-PHI-RESIDUALS`: the
12280
+ // remaining-bytes count this string used to carry was the enclosing sequence's
12281
+ // declared Value Length less the bytes of that sequence already consumed. See
12282
+ // `itemCrossesSequenceEnd`.
12283
+ DICOM_ITEM_CROSSES_SEQUENCE_END: "Item ({tag}) declares a length reaching past its enclosing sequence's declared end, so it reads the enclosing Data Set's bytes. The file's two length fields disagree (PS3.5 7.5.1 and 7.5.2 govern them); the item's is used. Both declared lengths are withheld; the byte offset locates the item.",
12284
+ // Declared but not emitted by this build. The declared length is bound out
12285
+ // anyway: it is a raw 32-bit read off a header, so activating this code later
12286
+ // with the slot still here would ship the leak this slice closed one code
12287
+ // over. `{n2}` stays - it is the product this parser computed from the image
12288
+ // description attributes, not a number it read. The tag is a constant.
12289
+ DICOM_PIXEL_DATA_LENGTH_MISMATCH: "(7FE0,0010) PixelData declared length does not match the computed {n2} bytes. The declared length is withheld; the byte offset identifies the element.",
12290
+ DICOM_IMPLICIT_VR_FOR_PRIVATE_TAG_WITHOUT_VR: "A private element under Implicit VR LE has no VR override; falling back to UN. Its tag is withheld; the byte offset identifies the element.",
12291
+ DICOM_PRIVATE_CREATOR_UNKNOWN: "A private element has a Private Creator the active profile's private dictionary does not name; falling back to UN. The creator string is not reproduced here - read the (gggg,00EE) element if you need it. Its tag is withheld; the byte offset identifies the element.",
12257
12292
  DICOM_BURNED_IN_ANNOTATION_NOT_REMOVED: "Pixel Data is present and Burned In Annotation is not 'NO'; this metadata-only de-identifier cannot inspect or clean pixels. Recognizable text may remain burned into the image.",
12258
- DICOM_DEIDENT_EMBEDDED_ATTRIBUTE_REMOVED: "Element ({tag}) {vr} was kept by the action table, but its value ends with {n} whole Data Element(s) - an over-declared Value Length swallowed what followed it. Emptied rather than kept, because the action table cannot see an attribute encoded inside a value. Read report.embeddedAttributes for the tags that were hidden there.",
12293
+ DICOM_DEIDENT_EMBEDDED_ATTRIBUTE_REMOVED: "Element ({tag}) {vr} was kept by the action table, but its value ends with {n} whole Data Element(s) - an over-declared Value Length swallowed what followed it. Emptied rather than kept, because the action table cannot see an attribute encoded inside a value. report.embeddedAttributes names the ones this run acts on that also have a literal Table E.1-1 row, which may be none of them.",
12259
12294
  // Deliberately short. One of these is raised per un-auditable element, so a
12260
12295
  // long message is multiplied by an element count the input controls; the
12261
12296
  // reasoning belongs in the docs, not in a string repeated thousands of times.
@@ -12263,19 +12298,31 @@ var WARNING_MESSAGES = Object.freeze({
12263
12298
  // its two producers is an element the profile declares a Sequence while the
12264
12299
  // wire says UN or OB, so naming a VR here would state a fact about the file
12265
12300
  // that the file contradicts - on the one channel this class designates.
12266
- DICOM_DEIDENT_SEQUENCE_NOT_AUDITABLE: "Element ({tag}) is a Sequence carrier with no parsed items, so its {n} recorded bytes could not be audited (PS3.15 E.1.1); emptied. See report.unauditableSequences.",
12301
+ // The recorded byte count is gone from this string, and the reason is the same
12302
+ // one that took the declared length out of `DICOM_ODD_LENGTH_VALUE_PADDED`:
12303
+ // `Element.rawBytes.length` EQUALS the Value Length off the element header, so
12304
+ // when that header is fabricated the decimal is four document bytes. See
12305
+ // `sequenceNotAuditable`. `report.unauditableSequences[].byteLength` still
12306
+ // carries it, on a type documented as not value-free.
12307
+ DICOM_DEIDENT_SEQUENCE_NOT_AUDITABLE: "Element ({tag}) is a Sequence carrier with no parsed items, so its recorded bytes could not be audited (PS3.15 E.1.1); emptied. The byte count is withheld; see report.unauditableSequences.",
12267
12308
  // Deliberately short for the same reason as the code above: one per element,
12268
12309
  // and the element count is chosen by the input.
12269
12310
  //
12270
- // NEITHER THE TAG NOR THE VR IS ECHOED, and that is specific to this code
12271
- // rather than caution. Every other factory's {tag} is composed from a real
12272
- // Data Element header; the condition that raises THIS one is that the header
12273
- // was fabricated from bytes inside some element's value, so its four tag bytes
12274
- // and its two VR bytes are document content. `renderTag` shape-checks a tag
12275
- // and cannot refuse one, so the withholding has to happen at the call site.
12311
+ // NEITHER THE TAG NOR THE VR NOR THE BYTE COUNT IS ECHOED, and that is
12312
+ // specific to this code rather than caution. Every other factory's {tag} is
12313
+ // composed from a real Data Element header; the condition that raises THIS one
12314
+ // is that the header was fabricated from bytes inside some element's value, so
12315
+ // its four tag bytes, its two VR bytes AND its four length bytes are document
12316
+ // content. `renderTag` is a membership test against PS3.6's registry and would
12317
+ // refuse this one - but a slot that has to rely on that is a slot a future
12318
+ // call site can still be handed, so the withholding stays at the call site
12319
+ // where it does not depend on a table. The length had no table to fall back on
12320
+ // at all: the message withheld the two fields a renderer could check and then
12321
+ // printed the one it could not, which is the shape this code was already
12322
+ // written to refuse.
12276
12323
  // The byte offset locates the element instead, and is a position this parser
12277
12324
  // counted rather than anything the document said.
12278
- DICOM_DEIDENT_UNDEFINED_VR_NOT_AUDITABLE: "An element at byte offset {n2} carries an on-wire VR that is not one of the 34 PS3.5 6.2 defines, so its {n} value bytes are not a Value Field this library decoded; emptied (PS3.15 E.1.1). Its tag and VR are withheld: an earlier under-declared length can make them fragments of some element's value. See report.undefinedVrElements.",
12325
+ DICOM_DEIDENT_UNDEFINED_VR_NOT_AUDITABLE: "An element at byte offset {n2} carries an on-wire VR that is not one of the 34 PS3.5 6.2 defines, so its value bytes are not a Value Field this library decoded; emptied (PS3.15 E.1.1). Its tag, VR and byte count are withheld: an earlier under-declared length can make them fragments of some element's value. See report.undefinedVrElements.",
12279
12326
  DICOM_BOM_IN_TEXT_VR: "Element ({tag}) {vr} value begins with a UTF-8 BOM; stripped on decode.",
12280
12327
  DICOM_TRAILING_NULL_IN_TEXT_VR: "Element ({tag}) {vr} value has a trailing NULL pad where SPACE is expected; trimmed.",
12281
12328
  DICOM_UI_TRAILING_SPACE: "Element ({tag}) UI value is SPACE-padded; UI requires NULL padding (PS3.5 \xA76.2). Trimmed.",
@@ -12286,10 +12333,6 @@ var WARNING_MESSAGES = Object.freeze({
12286
12333
  DICOM_UNSUPPORTED_CHARSET: "(0008,0005) Specific Character Set value {n} names a defined term this build does not support; decoding text as UTF-8 best-effort. The term is not reproduced here - read the element if you need it.",
12287
12334
  DICOM_CHARSET_AMBIGUOUS_SEPARATOR: "(0008,0005) Specific Character Set value {n} is ambiguous under the active code extensions; decoding text as UTF-8 best-effort."
12288
12335
  });
12289
- var TAG_SHAPE = /^[0-9A-F]{8}$/u;
12290
- function renderTag(tag) {
12291
- return tag !== void 0 && TAG_SHAPE.test(tag) ? tag : WITHHELD;
12292
- }
12293
12336
  function build2(code, position, tokens = {}) {
12294
12337
  const message = WARNING_MESSAGES[code].replace("{tag}", renderTag(tokens.tag)).replace("{vr2}", renderVr(tokens.vr2)).replace("{vr}", renderVr(tokens.vr)).replace("{n2}", String(tokens.n2 ?? 0)).replace("{n}", String(tokens.n ?? 0));
12295
12338
  return { code, message, position };
@@ -12309,26 +12352,20 @@ function fileMetaGroupLengthMismatch(position, declared, actual) {
12309
12352
  function undefinedLengthInExplicitVR(position, tag) {
12310
12353
  return build2(WARNING_CODES.DICOM_UNDEFINED_LENGTH_IN_EXPLICIT_VR, position, { tag });
12311
12354
  }
12312
- function oddLengthValuePadded(position, tag, declaredLength) {
12313
- return build2(WARNING_CODES.DICOM_ODD_LENGTH_VALUE_PADDED, position, {
12314
- tag,
12315
- n: declaredLength
12316
- });
12355
+ function oddLengthValuePadded(position, tag) {
12356
+ return build2(WARNING_CODES.DICOM_ODD_LENGTH_VALUE_PADDED, position, { tag });
12317
12357
  }
12318
12358
  function vrMismatch(position, tag, dictVR, fileVR) {
12319
12359
  return build2(WARNING_CODES.DICOM_VR_MISMATCH, position, { tag, vr: dictVR, vr2: fileVR });
12320
12360
  }
12321
- function privateTagNoCreator(position, tag) {
12322
- return build2(WARNING_CODES.DICOM_PRIVATE_TAG_NO_CREATOR, position, { tag });
12361
+ function privateTagNoCreator(position) {
12362
+ return build2(WARNING_CODES.DICOM_PRIVATE_TAG_NO_CREATOR, position);
12323
12363
  }
12324
- function groupLengthInDataset(position, tag) {
12325
- return build2(WARNING_CODES.DICOM_GROUP_LENGTH_IN_DATASET, position, { tag });
12364
+ function groupLengthInDataset(position) {
12365
+ return build2(WARNING_CODES.DICOM_GROUP_LENGTH_IN_DATASET, position);
12326
12366
  }
12327
- function nonzeroReservedBytes(position, first, second) {
12328
- return build2(WARNING_CODES.DICOM_NONZERO_RESERVED_BYTES, position, {
12329
- n: first,
12330
- n2: second
12331
- });
12367
+ function nonzeroReservedBytes(position) {
12368
+ return build2(WARNING_CODES.DICOM_NONZERO_RESERVED_BYTES, position);
12332
12369
  }
12333
12370
  function unParsedAsSQ(position, tag) {
12334
12371
  return build2(WARNING_CODES.DICOM_UN_PARSED_AS_SQ, position, { tag });
@@ -12336,11 +12373,8 @@ function unParsedAsSQ(position, tag) {
12336
12373
  function sqNotDescended(position, tag) {
12337
12374
  return build2(WARNING_CODES.DICOM_SQ_NOT_DESCENDED, position, { tag });
12338
12375
  }
12339
- function itemCrossesSequenceEnd(position, tag, availableLength) {
12340
- return build2(WARNING_CODES.DICOM_ITEM_CROSSES_SEQUENCE_END, position, {
12341
- tag,
12342
- n2: availableLength
12343
- });
12376
+ function itemCrossesSequenceEnd(position, tag) {
12377
+ return build2(WARNING_CODES.DICOM_ITEM_CROSSES_SEQUENCE_END, position, { tag });
12344
12378
  }
12345
12379
  function emptyItemInSequence(position, tag) {
12346
12380
  return build2(WARNING_CODES.DICOM_EMPTY_ITEM_IN_SEQUENCE, position, { tag });
@@ -12351,11 +12385,11 @@ function duplicateTagInDataSet(position) {
12351
12385
  function duplicateFileMetaElement(position) {
12352
12386
  return build2(WARNING_CODES.DICOM_DUPLICATE_FILE_META_ELEMENT, position);
12353
12387
  }
12354
- function implicitVRForPrivateTagWithoutVR(position, tag) {
12355
- return build2(WARNING_CODES.DICOM_IMPLICIT_VR_FOR_PRIVATE_TAG_WITHOUT_VR, position, { tag });
12388
+ function implicitVRForPrivateTagWithoutVR(position) {
12389
+ return build2(WARNING_CODES.DICOM_IMPLICIT_VR_FOR_PRIVATE_TAG_WITHOUT_VR, position);
12356
12390
  }
12357
- function privateCreatorUnknown(position, tag) {
12358
- return build2(WARNING_CODES.DICOM_PRIVATE_CREATOR_UNKNOWN, position, { tag });
12391
+ function privateCreatorUnknown(position) {
12392
+ return build2(WARNING_CODES.DICOM_PRIVATE_CREATOR_UNKNOWN, position);
12359
12393
  }
12360
12394
  function burnedInAnnotationNotRemoved(position) {
12361
12395
  return build2(WARNING_CODES.DICOM_BURNED_IN_ANNOTATION_NOT_REMOVED, position);
@@ -12376,15 +12410,11 @@ function embeddedAttributeRemoved(position, tag, vr, count) {
12376
12410
  n: count
12377
12411
  });
12378
12412
  }
12379
- function sequenceNotAuditable(position, tag, byteLength) {
12380
- return build2(WARNING_CODES.DICOM_DEIDENT_SEQUENCE_NOT_AUDITABLE, position, {
12381
- tag,
12382
- n: byteLength
12383
- });
12413
+ function sequenceNotAuditable(position, tag) {
12414
+ return build2(WARNING_CODES.DICOM_DEIDENT_SEQUENCE_NOT_AUDITABLE, position, { tag });
12384
12415
  }
12385
- function undefinedVrNotAuditable(position, byteLength) {
12416
+ function undefinedVrNotAuditable(position) {
12386
12417
  return build2(WARNING_CODES.DICOM_DEIDENT_UNDEFINED_VR_NOT_AUDITABLE, position, {
12387
- n: byteLength,
12388
12418
  n2: position.byteOffset
12389
12419
  });
12390
12420
  }
@@ -12460,18 +12490,18 @@ function resolveImplicitVR(tag, ctx, emit, position) {
12460
12490
  }
12461
12491
  const creator = resolvePrivateCreator(tag, ctx);
12462
12492
  if (creator === void 0) {
12463
- emit(privateTagNoCreator(position, tag));
12464
- emit(implicitVRForPrivateTagWithoutVR(position, tag));
12493
+ emit(privateTagNoCreator(position));
12494
+ emit(implicitVRForPrivateTagWithoutVR(position));
12465
12495
  return "UN";
12466
12496
  }
12467
12497
  if (ctx.profile !== void 0) {
12468
12498
  const def = resolvePrivateTag(ctx.profile, tag, creator);
12469
12499
  if (def !== void 0) return def.vr;
12470
12500
  if (!ctx.profile.privateDictionary.has(creator)) {
12471
- emit(privateCreatorUnknown(position, tag));
12501
+ emit(privateCreatorUnknown(position));
12472
12502
  }
12473
12503
  }
12474
- emit(implicitVRForPrivateTagWithoutVR(position, tag));
12504
+ emit(implicitVRForPrivateTagWithoutVR(position));
12475
12505
  return "UN";
12476
12506
  }
12477
12507
  const direct = TAGS[tag];
@@ -12555,7 +12585,7 @@ function readExplicitElementHeader(cursor, _ctx, emit) {
12555
12585
  const reserved1 = cursor.buffer[cursor.position + 1];
12556
12586
  cursor.position += 2;
12557
12587
  if ((reserved0 ?? 0) !== 0 || (reserved1 ?? 0) !== 0) {
12558
- emit(nonzeroReservedBytes({ byteOffset: headerStart }, reserved0 ?? 0, reserved1 ?? 0));
12588
+ emit(nonzeroReservedBytes({ byteOffset: headerStart }));
12559
12589
  }
12560
12590
  length = cursor.readUInt32();
12561
12591
  headerLength = 12;
@@ -12595,7 +12625,7 @@ function parseFileMeta(buffer, datasetStart, ctx, emit) {
12595
12625
  if (firstElement.tag === "00020000" && firstElement.vr === "UL" && firstElement.value.length === 4) {
12596
12626
  declaredFmLength = firstElement.value.readUInt32LE(0);
12597
12627
  if (cursor.position + declaredFmLength > buffer.length) {
12598
- throw fileMetaGroupLengthOverruns(buffer, fmStart, buffer.length - cursor.position);
12628
+ throw fileMetaGroupLengthOverruns(buffer, fmStart);
12599
12629
  }
12600
12630
  } else {
12601
12631
  emit(fileMetaGroupLengthMissing({ byteOffset: fmStart, fileMeta: true }));
@@ -13234,13 +13264,7 @@ function parseSequence(buffer, valueStart, ctx, emit, opts) {
13234
13264
  cursor.position = inner.endOffset;
13235
13265
  } else {
13236
13266
  if (opts.explicitLength !== void 0 && endLimit < buffer.length && cursor.position + itemLength > endLimit) {
13237
- emit(
13238
- itemCrossesSequenceEnd(
13239
- { byteOffset: itemHeaderStart },
13240
- itemTag,
13241
- Math.max(0, endLimit - cursor.position)
13242
- )
13243
- );
13267
+ emit(itemCrossesSequenceEnd({ byteOffset: itemHeaderStart }, itemTag));
13244
13268
  }
13245
13269
  if (cursor.position + itemLength > buffer.length) {
13246
13270
  throw itemLengthExceedsBuffer(buffer, itemHeaderStart);
@@ -13438,7 +13462,7 @@ function parseImplicitLE(buffer, datasetStart, ctx, emit, opts = {}) {
13438
13462
  throw undefinedLengthOnNonSqImplicit(buffer, headerStart, vr);
13439
13463
  }
13440
13464
  if (cursor.position + length > buffer.length) {
13441
- throw elementLengthExceedsBuffer(buffer, headerStart, buffer.length - cursor.position);
13465
+ throw elementLengthExceedsBuffer(buffer, headerStart);
13442
13466
  }
13443
13467
  const valueStart = cursor.position;
13444
13468
  const valueEnd = valueStart + length;
@@ -13475,7 +13499,7 @@ function parseImplicitLE(buffer, datasetStart, ctx, emit, opts = {}) {
13475
13499
  }
13476
13500
  }
13477
13501
  if (element === 0 && group !== 2) {
13478
- emit(groupLengthInDataset(position, tag));
13502
+ emit(groupLengthInDataset(position));
13479
13503
  }
13480
13504
  if (group % 2 === 1 && element >= 16 && element <= 255) {
13481
13505
  registerPrivateCreator(tag, valueSlice, ctx);
@@ -13558,7 +13582,7 @@ function _parseExplicit(buffer, datasetStart, ctx, emit, mode, opts = {}) {
13558
13582
  }
13559
13583
  }
13560
13584
  if (length !== UNDEFINED_LENGTH2 && length % 2 === 1) {
13561
- emit(oddLengthValuePadded(position, tag, length));
13585
+ emit(oddLengthValuePadded(position, tag));
13562
13586
  }
13563
13587
  if (vr === "SQ") {
13564
13588
  const valueStart2 = cursor.position;
@@ -13685,7 +13709,7 @@ function _parseExplicit(buffer, datasetStart, ctx, emit, mode, opts = {}) {
13685
13709
  throw undefinedLengthOnNonSqExplicit(buffer, headerStart, vr);
13686
13710
  }
13687
13711
  if (cursor.position + length > buffer.length) {
13688
- throw elementLengthExceedsBuffer(buffer, headerStart, buffer.length - cursor.position);
13712
+ throw elementLengthExceedsBuffer(buffer, headerStart);
13689
13713
  }
13690
13714
  const valueStart = cursor.position;
13691
13715
  const valueEnd = valueStart + length;
@@ -13693,7 +13717,7 @@ function _parseExplicit(buffer, datasetStart, ctx, emit, mode, opts = {}) {
13693
13717
  cursor.position = valueEnd;
13694
13718
  const elementHexNum = parseInt(tag.slice(4, 8), 16);
13695
13719
  if (elementHexNum === 0 && groupNum !== 2) {
13696
- emit(groupLengthInDataset(position, tag));
13720
+ emit(groupLengthInDataset(position));
13697
13721
  }
13698
13722
  if (groupNum % 2 === 1 && elementHexNum >= 16 && elementHexNum <= 255) {
13699
13723
  registerPrivateCreator(tag, valueSlice, ctx);
@@ -15223,6 +15247,10 @@ function hasByteOutsideRepertoire(region, carrierVr) {
15223
15247
  }
15224
15248
  return false;
15225
15249
  }
15250
+ function isTableBound(tag) {
15251
+ const action = annexE(tag);
15252
+ return action !== void 0 && action.repeatingGroup === void 0;
15253
+ }
15226
15254
  function findEmbeddedAttributes(value, carrierVr, encoding, isActionable) {
15227
15255
  if (!isScannableCarrier(carrierVr)) return void 0;
15228
15256
  if (value.length < MIN_HEADER) return void 0;
@@ -15246,15 +15274,19 @@ function findEmbeddedAttributes(value, carrierVr, encoding, isActionable) {
15246
15274
  for (let off = 0; off + MIN_HEADER <= n; off += 2) {
15247
15275
  if (hit[off >> 1] !== 1) continue;
15248
15276
  if (!hasByteOutsideRepertoire(window.subarray(off), carrierVr)) return void 0;
15249
- const tags = [];
15277
+ const hidden = [];
15278
+ let elementCount = 0;
15250
15279
  let pos = off;
15251
15280
  while (pos < n) {
15252
15281
  const decoded = decodeAt(window, pos, encoding);
15253
15282
  if (decoded === void 0) break;
15254
- if (decoded.tag !== void 0) tags.push(decoded.tag);
15283
+ if (decoded.tag !== void 0) {
15284
+ elementCount += 1;
15285
+ if (isActionable(decoded.tag) && isTableBound(decoded.tag)) hidden.push(decoded.tag);
15286
+ }
15255
15287
  pos = decoded.next;
15256
15288
  }
15257
- return tags;
15289
+ return { hidden, elementCount };
15258
15290
  }
15259
15291
  return void 0;
15260
15292
  }
@@ -15459,8 +15491,8 @@ function keepOrEmpty(el, ctx, contextPath, out) {
15459
15491
  emptyUndefinedVrElement(el, ctx, contextPath, out);
15460
15492
  return false;
15461
15493
  }
15462
- const hidden = findEmbeddedAttributes(el.rawBytes, el.vr, ctx.encoding, (t) => actsOnTag(t, ctx));
15463
- if (hidden === void 0) {
15494
+ const run = findEmbeddedAttributes(el.rawBytes, el.vr, ctx.encoding, (t) => actsOnTag(t, ctx));
15495
+ if (run === void 0) {
15464
15496
  out.elements.set(el.tag, el);
15465
15497
  return true;
15466
15498
  }
@@ -15468,11 +15500,11 @@ function keepOrEmpty(el, ctx, contextPath, out) {
15468
15500
  out.embeddedAttributes.push({
15469
15501
  tag: el.tag,
15470
15502
  vr: el.vr,
15471
- hidden,
15503
+ hidden: run.hidden,
15472
15504
  ...contextPath.length > 0 ? { contextPath: [...contextPath] } : {}
15473
15505
  });
15474
15506
  out.warnings.push(
15475
- embeddedAttributeRemoved({ byteOffset: el.byteOffset }, el.tag, el.vr, hidden.length)
15507
+ embeddedAttributeRemoved({ byteOffset: el.byteOffset }, el.tag, el.vr, run.elementCount)
15476
15508
  );
15477
15509
  return false;
15478
15510
  }
@@ -15485,7 +15517,7 @@ function emptyUndefinedVrElement(el, ctx, contextPath, out) {
15485
15517
  byteLength: el.rawBytes.length,
15486
15518
  ...contextPath.length > 0 ? { contextPath: [...contextPath] } : {}
15487
15519
  });
15488
- out.warnings.push(undefinedVrNotAuditable({ byteOffset: el.byteOffset }, el.rawBytes.length));
15520
+ out.warnings.push(undefinedVrNotAuditable({ byteOffset: el.byteOffset }));
15489
15521
  }
15490
15522
  function isUnauditableSequence(el) {
15491
15523
  return el.vr === "SQ" && el.items === void 0;
@@ -15502,9 +15534,7 @@ function emptyUnauditableCarrier(el, ctx, contextPath, out, replacement) {
15502
15534
  byteLength: el.rawBytes.length,
15503
15535
  ...contextPath.length > 0 ? { contextPath: [...contextPath] } : {}
15504
15536
  });
15505
- out.warnings.push(
15506
- sequenceNotAuditable({ byteOffset: el.byteOffset }, el.tag, el.rawBytes.length)
15507
- );
15537
+ out.warnings.push(sequenceNotAuditable({ byteOffset: el.byteOffset }, el.tag));
15508
15538
  }
15509
15539
  function creatorsInScope(source) {
15510
15540
  const byBlock = /* @__PURE__ */ new Map();