@bcts/dcbor 1.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/LICENSE +48 -0
  2. package/README.md +13 -0
  3. package/dist/index.cjs +9151 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +3107 -0
  6. package/dist/index.d.cts.map +1 -0
  7. package/dist/index.d.mts +3107 -0
  8. package/dist/index.d.mts.map +1 -0
  9. package/dist/index.iife.js +9155 -0
  10. package/dist/index.iife.js.map +1 -0
  11. package/dist/index.mjs +9027 -0
  12. package/dist/index.mjs.map +1 -0
  13. package/package.json +80 -0
  14. package/src/.claude-flow/metrics/agent-metrics.json +1 -0
  15. package/src/.claude-flow/metrics/performance.json +87 -0
  16. package/src/.claude-flow/metrics/task-metrics.json +10 -0
  17. package/src/byte-string.ts +300 -0
  18. package/src/cbor-codable.ts +170 -0
  19. package/src/cbor-tagged-codable.ts +72 -0
  20. package/src/cbor-tagged-decodable.ts +184 -0
  21. package/src/cbor-tagged-encodable.ts +138 -0
  22. package/src/cbor-tagged.ts +104 -0
  23. package/src/cbor.ts +869 -0
  24. package/src/conveniences.ts +840 -0
  25. package/src/date.ts +553 -0
  26. package/src/decode.ts +276 -0
  27. package/src/diag.ts +462 -0
  28. package/src/dump.ts +277 -0
  29. package/src/error.ts +259 -0
  30. package/src/exact.ts +714 -0
  31. package/src/float.ts +279 -0
  32. package/src/global.d.ts +34 -0
  33. package/src/globals.d.ts +0 -0
  34. package/src/index.ts +180 -0
  35. package/src/map.ts +308 -0
  36. package/src/prelude.ts +70 -0
  37. package/src/set.ts +515 -0
  38. package/src/simple.ts +153 -0
  39. package/src/stdlib.ts +55 -0
  40. package/src/string-util.ts +55 -0
  41. package/src/tag.ts +53 -0
  42. package/src/tags-store.ts +294 -0
  43. package/src/tags.ts +231 -0
  44. package/src/varint.ts +124 -0
  45. package/src/walk.ts +516 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["key","comparison","at","from","key","basis","basis","basis","branch","basis","Map","overriddenDescriptor","at","e","byteData","u","value: CborNumber","chars: string[]","#tagsByValue","#tagsByName","#summarizers","#valueKey","tagValue","globalTagsStore: TagsStore | undefined","hex","cbor","level: number","data: Uint8Array[]","note?: string","items: DumpItem[]","note: string | undefined","tagValue","noteComponents: string[]","note: string","cbor","formattedPairs: FormattedPair[]","comment: string | undefined","tagObj: Tag","isFloat","isNaN","cbor","value: CborNumber","varIntLen: number","items: Cbor[]","value","c: Cbor","cbor","isSimpleFloat","#dict","SortedMap","#makeKey","cbor","cbor","MajorTypeNames: Record<MajorType, string>","result: Omit<Cbor, keyof CborMethods>","value","tagNumber: CborNumber","hex","tagValue","isSimpleFloat","cbor","tagValue","#datetime","timestamp: number","cbor","#map","cbor","#data","toCbor","cbor"],"sources":["../../../node_modules/.bun/collections@5.1.13/node_modules/collections/shim-function.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/generic-collection.js","../../../node_modules/.bun/weak-map@1.0.8/node_modules/weak-map/weak-map.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/weak-map.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/shim-object.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/generic-order.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/shim-array.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/shim-regexp.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/shim.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/generic-set.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/_list.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/iterator.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/generic-map.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/_dict.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/tree-log.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/_fast-set.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/_set.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/_map.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/listen/change-descriptor.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/listen/property-changes.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/listen/range-changes.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/sorted-set.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/listen/map-changes.js","../../../node_modules/.bun/collections@5.1.13/node_modules/collections/sorted-map.js","../src/tag.ts","../src/error.ts","../src/stdlib.ts","../../../node_modules/.bun/byte-data@19.0.1/node_modules/byte-data/dist/byte-data.js","../src/exact.ts","../src/float.ts","../src/varint.ts","../src/string-util.ts","../src/tags-store.ts","../src/dump.ts","../src/diag.ts","../src/simple.ts","../src/decode.ts","../src/conveniences.ts","../src/map.ts","../src/walk.ts","../src/cbor.ts","../src/cbor-tagged-encodable.ts","../src/cbor-tagged-decodable.ts","../src/date.ts","../src/tags.ts","../src/set.ts","../src/byte-string.ts"],"sourcesContent":["\nmodule.exports = Function;\n\n/**\n A utility to reduce unnecessary allocations of <code>function () {}</code>\n in its many colorful variations. It does nothing and returns\n <code>undefined</code> thus makes a suitable default in some circumstances.\n\n @function external:Function.noop\n*/\nFunction.noop = function () {\n};\n\n/**\n A utility to reduce unnecessary allocations of <code>function (x) {return\n x}</code> in its many colorful but ultimately wasteful parameter name\n variations.\n\n @function external:Function.identity\n @param {Any} any value\n @returns {Any} that value\n*/\nFunction.identity = function (value) {\n return value;\n};\n\n/**\n A utility for creating a comparator function for a particular aspect of a\n figurative class of objects.\n\n @function external:Function.by\n @param {Function} relation A function that accepts a value and returns a\n corresponding value to use as a representative when sorting that object.\n @param {Function} compare an alternate comparator for comparing the\n represented values. The default is <code>Object.compare</code>, which\n does a deep, type-sensitive, polymorphic comparison.\n @returns {Function} a comparator that has been annotated with\n <code>by</code> and <code>compare</code> properties so\n <code>sorted</code> can perform a transform that reduces the need to call\n <code>by</code> on each sorted object to just once.\n */\nFunction.by = function (by , compare) {\n compare = compare || Object.compare;\n by = by || Function.identity;\n var compareBy = function (a, b) {\n return compare(by(a), by(b));\n };\n compareBy.compare = compare;\n compareBy.by = by;\n return compareBy;\n};\n\n// TODO document\nFunction.get = function (key) {\n return function (object) {\n return Object.get(object, key);\n };\n};\n\n","\"use strict\";\n\nmodule.exports = GenericCollection;\nfunction GenericCollection() {\n throw new Error(\"Can't construct. GenericCollection is a mixin.\");\n}\n\nvar DOMTokenList = global.DOMTokenList || function(){};\n\nGenericCollection.EmptyArray = Object.freeze([]);\n\nGenericCollection.prototype.addEach = function (values, mapFn, thisp) {\n //We want to eliminate everything but array like: Strings, Arrays, DOMTokenList\n if(values && (values instanceof Array || (values instanceof DOMTokenList) || values instanceof String)) {\n if(mapFn) {\n for (var i = 0; i < values.length; i++) {\n this.add(mapFn.call(thisp,values[i]), i);\n }\n } else {\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n }\n else if (values && Object(values) === values) {\n if (typeof values.forEach === \"function\") {\n if(mapFn) {\n values.map(mapFn, thisp).forEach(this.add, this);\n } else {\n values.forEach(this.add, this);\n }\n } else if(typeof values.next === \"function\") {\n var value, i=0;\n if(mapFn) {\n while ((value = values.next().value)) {\n this.add(mapFn.call(thisp,value), i++);\n }\n }\n else {\n while ((value = values.next().value)) {\n this.add(value, i++);\n }\n }\n } else if (typeof values.length === \"number\") {\n // Array-like objects that do not implement forEach, ergo,\n // Arguments\n if(mapFn) {\n for (var i = 0; i < values.length; i++) {\n this.add(mapFn.call(thisp,values[i]), i);\n }\n }\n else {\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n } else {\n if(mapFn) {\n Object.keys(values).forEach(function (key) {\n this.add(mapFn.call(thisp,values[key]), key);\n }, this);\n } else {\n Object.keys(values).forEach(function (key) {\n this.add(values[key], key);\n }, this);\n }\n }\n }\n return this;\n};\n\n// This is sufficiently generic for Map (since the value may be a key)\n// and ordered collections (since it forwards the equals argument)\nGenericCollection.prototype.deleteEach = function (values, equals) {\n values.forEach(function (value) {\n this[\"delete\"](value, equals);\n }, this);\n return this;\n};\n\n// all of the following functions are implemented in terms of \"reduce\".\n// some need \"constructClone\".\n\nGenericCollection.prototype.forEach = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (undefined, value, key, object, depth) {\n callback.call(thisp, value, key, object, depth);\n }, undefined);\n};\n\nGenericCollection.prototype.map = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n var result = [];\n this.reduce(function (undefined, value, key, object, depth) {\n result.push(callback.call(thisp, value, key, object, depth));\n }, undefined);\n return result;\n};\n\nGenericCollection.prototype.enumerate = function (start) {\n if (start == null) {\n start = 0;\n }\n var result = [];\n this.reduce(function (undefined, value) {\n result.push([start++, value]);\n }, undefined);\n return result;\n};\n\nGenericCollection.prototype.group = function (callback, thisp, equals) {\n equals = equals || Object.equals;\n var groups = [];\n var keys = [];\n this.forEach(function (value, key, object) {\n var key = callback.call(thisp, value, key, object);\n var index = keys.indexOf(key, equals);\n var group;\n if (index === -1) {\n group = [];\n groups.push([key, group]);\n keys.push(key);\n } else {\n group = groups[index][1];\n }\n group.push(value);\n });\n return groups;\n};\n\nGenericCollection.prototype.toArray = function () {\n return this.map(Function.identity);\n};\n\n// this depends on stringable keys, which apply to Array and Iterator\n// because they have numeric keys and all Maps since they may use\n// strings as keys. List, Set, and SortedSet have nodes for keys, so\n// toObject would not be meaningful.\nGenericCollection.prototype.toObject = function () {\n var object = {};\n this.reduce(function (undefined, value, key) {\n object[key] = value;\n }, undefined);\n return object;\n};\n\nGenericCollection.from = function () {\n return this.apply(this,arguments);\n};\n\nGenericCollection.prototype.filter = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n var result = this.constructClone();\n this.reduce(function (undefined, value, key, object, depth) {\n if (callback.call(thisp, value, key, object, depth)) {\n result.add(value, key);\n }\n }, undefined);\n return result;\n};\n\nGenericCollection.prototype.every = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (result, value, key, object, depth) {\n return result && callback.call(thisp, value, key, object, depth);\n }, true);\n};\n\nGenericCollection.prototype.some = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (result, value, key, object, depth) {\n return result || callback.call(thisp, value, key, object, depth);\n }, false);\n};\n\nGenericCollection.prototype.all = function () {\n return this.every(Boolean);\n};\n\nGenericCollection.prototype.any = function () {\n return this.some(Boolean);\n};\n\nGenericCollection.prototype.min = function (compare) {\n compare = compare || this.contentCompare || Object.compare;\n var first = true;\n return this.reduce(function (result, value) {\n if (first) {\n first = false;\n return value;\n } else {\n return compare(value, result) < 0 ? value : result;\n }\n }, undefined);\n};\n\nGenericCollection.prototype.max = function (compare) {\n compare = compare || this.contentCompare || Object.compare;\n var first = true;\n return this.reduce(function (result, value) {\n if (first) {\n first = false;\n return value;\n } else {\n return compare(value, result) > 0 ? value : result;\n }\n }, undefined);\n};\n\nGenericCollection.prototype.sum = function (zero) {\n zero = zero === undefined ? 0 : zero;\n return this.reduce(function (a, b) {\n return a + b;\n }, zero);\n};\n\nGenericCollection.prototype.average = function (zero) {\n var sum = zero === undefined ? 0 : zero;\n var count = zero === undefined ? 0 : zero;\n this.reduce(function (undefined, value) {\n sum += value;\n count += 1;\n }, undefined);\n return sum / count;\n};\n\nGenericCollection.prototype.concat = function () {\n var result = this.constructClone(this);\n for (var i = 0; i < arguments.length; i++) {\n result.addEach(arguments[i]);\n }\n return result;\n};\n\nGenericCollection.prototype.flatten = function () {\n var self = this;\n return this.reduce(function (result, array) {\n array.forEach(function (value) {\n this.push(value);\n }, result, self);\n return result;\n }, []);\n};\n\nGenericCollection.prototype.zip = function () {\n var table = Array.prototype.slice.call(arguments);\n table.unshift(this);\n return Array.unzip(table);\n}\n\nGenericCollection.prototype.join = function (delimiter) {\n return this.reduce(function (result, string) {\n // work-around for reduce that does not support no-basis form\n if (result === void 0) {\n return string;\n } else {\n return result + delimiter + string;\n }\n }, void 0);\n};\n\nGenericCollection.prototype.sorted = function (compare, by, order) {\n compare = compare || this.contentCompare || Object.compare;\n // account for comparators generated by Function.by\n if (compare.by) {\n by = compare.by;\n compare = compare.compare || this.contentCompare || Object.compare;\n } else {\n by = by || Function.identity;\n }\n if (order === undefined)\n order = 1;\n return this.map(function (item) {\n return {\n by: by(item),\n value: item\n };\n })\n .sort(function (a, b) {\n return compare(a.by, b.by) * order;\n })\n .map(function (pair) {\n return pair.value;\n });\n};\n\nGenericCollection.prototype.reversed = function () {\n return this.constructClone(this).reverse();\n};\n\nGenericCollection.prototype.clone = function (depth, memo) {\n if (depth === undefined) {\n depth = Infinity;\n } else if (depth === 0) {\n return this;\n }\n var clone = this.constructClone();\n this.forEach(function (value, key) {\n clone.add(Object.clone(value, depth - 1, memo), key);\n }, this);\n return clone;\n};\n\nGenericCollection.prototype.only = function () {\n if (this.length === 1) {\n return this.one();\n }\n};\n\nGenericCollection.prototype.iterator = function () {\n return this.iterate.apply(this, arguments);\n};\n\nGenericCollection._sizePropertyDescriptor = {\n get: function() {\n return this.length;\n },\n enumerable: false,\n configurable: true\n};\n\nObject.defineProperty(GenericCollection.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\nrequire(\"./shim-array\");\n","// Copyright (C) 2011 Google Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n/**\n * @fileoverview Install a leaky WeakMap emulation on platforms that\n * don't provide a built-in one.\n *\n * <p>Assumes that an ES5 platform where, if {@code WeakMap} is\n * already present, then it conforms to the anticipated ES6\n * specification. To run this file on an ES5 or almost ES5\n * implementation where the {@code WeakMap} specification does not\n * quite conform, run <code>repairES5.js</code> first.\n *\n * <p>Even though WeakMapModule is not global, the linter thinks it\n * is, which is why it is in the overrides list below.\n *\n * <p>NOTE: Before using this WeakMap emulation in a non-SES\n * environment, see the note below about hiddenRecord.\n *\n * @author Mark S. Miller\n * @requires crypto, ArrayBuffer, Uint8Array, navigator, console\n * @overrides WeakMap, ses, Proxy\n * @overrides WeakMapModule\n */\n\n/**\n * This {@code WeakMap} emulation is observably equivalent to the\n * ES-Harmony WeakMap, but with leakier garbage collection properties.\n *\n * <p>As with true WeakMaps, in this emulation, a key does not\n * retain maps indexed by that key and (crucially) a map does not\n * retain the keys it indexes. A map by itself also does not retain\n * the values associated with that map.\n *\n * <p>However, the values associated with a key in some map are\n * retained so long as that key is retained and those associations are\n * not overridden. For example, when used to support membranes, all\n * values exported from a given membrane will live for the lifetime\n * they would have had in the absence of an interposed membrane. Even\n * when the membrane is revoked, all objects that would have been\n * reachable in the absence of revocation will still be reachable, as\n * far as the GC can tell, even though they will no longer be relevant\n * to ongoing computation.\n *\n * <p>The API implemented here is approximately the API as implemented\n * in FF6.0a1 and agreed to by MarkM, Andreas Gal, and Dave Herman,\n * rather than the offially approved proposal page. TODO(erights):\n * upgrade the ecmascript WeakMap proposal page to explain this API\n * change and present to EcmaScript committee for their approval.\n *\n * <p>The first difference between the emulation here and that in\n * FF6.0a1 is the presence of non enumerable {@code get___, has___,\n * set___, and delete___} methods on WeakMap instances to represent\n * what would be the hidden internal properties of a primitive\n * implementation. Whereas the FF6.0a1 WeakMap.prototype methods\n * require their {@code this} to be a genuine WeakMap instance (i.e.,\n * an object of {@code [[Class]]} \"WeakMap}), since there is nothing\n * unforgeable about the pseudo-internal method names used here,\n * nothing prevents these emulated prototype methods from being\n * applied to non-WeakMaps with pseudo-internal methods of the same\n * names.\n *\n * <p>Another difference is that our emulated {@code\n * WeakMap.prototype} is not itself a WeakMap. A problem with the\n * current FF6.0a1 API is that WeakMap.prototype is itself a WeakMap\n * providing ambient mutability and an ambient communications\n * channel. Thus, if a WeakMap is already present and has this\n * problem, repairES5.js wraps it in a safe wrappper in order to\n * prevent access to this channel. (See\n * PATCH_MUTABLE_FROZEN_WEAKMAP_PROTO in repairES5.js).\n */\n\n/**\n * If this is a full <a href=\n * \"http://code.google.com/p/es-lab/wiki/SecureableES5\"\n * >secureable ES5</a> platform and the ES-Harmony {@code WeakMap} is\n * absent, install an approximate emulation.\n *\n * <p>If WeakMap is present but cannot store some objects, use our approximate\n * emulation as a wrapper.\n *\n * <p>If this is almost a secureable ES5 platform, then WeakMap.js\n * should be run after repairES5.js.\n *\n * <p>See {@code WeakMap} for documentation of the garbage collection\n * properties of this WeakMap emulation.\n */\n(function WeakMapModule() {\n \"use strict\";\n\n if (typeof ses !== 'undefined' && ses.ok && !ses.ok()) {\n // already too broken, so give up\n return;\n }\n\n /**\n * In some cases (current Firefox), we must make a choice betweeen a\n * WeakMap which is capable of using all varieties of host objects as\n * keys and one which is capable of safely using proxies as keys. See\n * comments below about HostWeakMap and DoubleWeakMap for details.\n *\n * This function (which is a global, not exposed to guests) marks a\n * WeakMap as permitted to do what is necessary to index all host\n * objects, at the cost of making it unsafe for proxies.\n *\n * Do not apply this function to anything which is not a genuine\n * fresh WeakMap.\n */\n function weakMapPermitHostObjects(map) {\n // identity of function used as a secret -- good enough and cheap\n if (map.permitHostObjects___) {\n map.permitHostObjects___(weakMapPermitHostObjects);\n }\n }\n if (typeof ses !== 'undefined') {\n ses.weakMapPermitHostObjects = weakMapPermitHostObjects;\n }\n\n // IE 11 has no Proxy but has a broken WeakMap such that we need to patch\n // it using DoubleWeakMap; this flag tells DoubleWeakMap so.\n var doubleWeakMapCheckSilentFailure = false;\n\n // Check if there is already a good-enough WeakMap implementation, and if so\n // exit without replacing it.\n if (typeof WeakMap === 'function') {\n var HostWeakMap = WeakMap;\n // There is a WeakMap -- is it good enough?\n if (typeof navigator !== 'undefined' &&\n /Firefox/.test(navigator.userAgent)) {\n // We're now *assuming not*, because as of this writing (2013-05-06)\n // Firefox's WeakMaps have a miscellany of objects they won't accept, and\n // we don't want to make an exhaustive list, and testing for just one\n // will be a problem if that one is fixed alone (as they did for Event).\n\n // If there is a platform that we *can* reliably test on, here's how to\n // do it:\n // var problematic = ... ;\n // var testHostMap = new HostWeakMap();\n // try {\n // testHostMap.set(problematic, 1); // Firefox 20 will throw here\n // if (testHostMap.get(problematic) === 1) {\n // return;\n // }\n // } catch (e) {}\n\n } else {\n // IE 11 bug: WeakMaps silently fail to store frozen objects.\n var testMap = new HostWeakMap();\n var testObject = Object.freeze({});\n testMap.set(testObject, 1);\n if (testMap.get(testObject) !== 1) {\n doubleWeakMapCheckSilentFailure = true;\n // Fall through to installing our WeakMap.\n } else {\n module.exports = WeakMap;\n return;\n }\n }\n }\n\n var hop = Object.prototype.hasOwnProperty;\n var gopn = Object.getOwnPropertyNames;\n var defProp = Object.defineProperty;\n var isExtensible = Object.isExtensible;\n\n /**\n * Security depends on HIDDEN_NAME being both <i>unguessable</i> and\n * <i>undiscoverable</i> by untrusted code.\n *\n * <p>Given the known weaknesses of Math.random() on existing\n * browsers, it does not generate unguessability we can be confident\n * of.\n *\n * <p>It is the monkey patching logic in this file that is intended\n * to ensure undiscoverability. The basic idea is that there are\n * three fundamental means of discovering properties of an object:\n * The for/in loop, Object.keys(), and Object.getOwnPropertyNames(),\n * as well as some proposed ES6 extensions that appear on our\n * whitelist. The first two only discover enumerable properties, and\n * we only use HIDDEN_NAME to name a non-enumerable property, so the\n * only remaining threat should be getOwnPropertyNames and some\n * proposed ES6 extensions that appear on our whitelist. We monkey\n * patch them to remove HIDDEN_NAME from the list of properties they\n * returns.\n *\n * <p>TODO(erights): On a platform with built-in Proxies, proxies\n * could be used to trap and thereby discover the HIDDEN_NAME, so we\n * need to monkey patch Proxy.create, Proxy.createFunction, etc, in\n * order to wrap the provided handler with the real handler which\n * filters out all traps using HIDDEN_NAME.\n *\n * <p>TODO(erights): Revisit Mike Stay's suggestion that we use an\n * encapsulated function at a not-necessarily-secret name, which\n * uses the Stiegler shared-state rights amplification pattern to\n * reveal the associated value only to the WeakMap in which this key\n * is associated with that value. Since only the key retains the\n * function, the function can also remember the key without causing\n * leakage of the key, so this doesn't violate our general gc\n * goals. In addition, because the name need not be a guarded\n * secret, we could efficiently handle cross-frame frozen keys.\n */\n var HIDDEN_NAME_PREFIX = 'weakmap:';\n var HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'ident:' + Math.random() + '___';\n\n if (typeof crypto !== 'undefined' &&\n typeof crypto.getRandomValues === 'function' &&\n typeof ArrayBuffer === 'function' &&\n typeof Uint8Array === 'function') {\n var ab = new ArrayBuffer(25);\n var u8s = new Uint8Array(ab);\n crypto.getRandomValues(u8s);\n HIDDEN_NAME = HIDDEN_NAME_PREFIX + 'rand:' +\n Array.prototype.map.call(u8s, function(u8) {\n return (u8 % 36).toString(36);\n }).join('') + '___';\n }\n\n function isNotHiddenName(name) {\n return !(\n name.substr(0, HIDDEN_NAME_PREFIX.length) == HIDDEN_NAME_PREFIX &&\n name.substr(name.length - 3) === '___');\n }\n\n /**\n * Monkey patch getOwnPropertyNames to avoid revealing the\n * HIDDEN_NAME.\n *\n * <p>The ES5.1 spec requires each name to appear only once, but as\n * of this writing, this requirement is controversial for ES6, so we\n * made this code robust against this case. If the resulting extra\n * search turns out to be expensive, we can probably relax this once\n * ES6 is adequately supported on all major browsers, iff no browser\n * versions we support at that time have relaxed this constraint\n * without providing built-in ES6 WeakMaps.\n */\n defProp(Object, 'getOwnPropertyNames', {\n value: function fakeGetOwnPropertyNames(obj) {\n return gopn(obj).filter(isNotHiddenName);\n }\n });\n\n /**\n * getPropertyNames is not in ES5 but it is proposed for ES6 and\n * does appear in our whitelist, so we need to clean it too.\n */\n if ('getPropertyNames' in Object) {\n var originalGetPropertyNames = Object.getPropertyNames;\n defProp(Object, 'getPropertyNames', {\n value: function fakeGetPropertyNames(obj) {\n return originalGetPropertyNames(obj).filter(isNotHiddenName);\n }\n });\n }\n\n /**\n * <p>To treat objects as identity-keys with reasonable efficiency\n * on ES5 by itself (i.e., without any object-keyed collections), we\n * need to add a hidden property to such key objects when we\n * can. This raises several issues:\n * <ul>\n * <li>Arranging to add this property to objects before we lose the\n * chance, and\n * <li>Hiding the existence of this new property from most\n * JavaScript code.\n * <li>Preventing <i>certification theft</i>, where one object is\n * created falsely claiming to be the key of an association\n * actually keyed by another object.\n * <li>Preventing <i>value theft</i>, where untrusted code with\n * access to a key object but not a weak map nevertheless\n * obtains access to the value associated with that key in that\n * weak map.\n * </ul>\n * We do so by\n * <ul>\n * <li>Making the name of the hidden property unguessable, so \"[]\"\n * indexing, which we cannot intercept, cannot be used to access\n * a property without knowing the name.\n * <li>Making the hidden property non-enumerable, so we need not\n * worry about for-in loops or {@code Object.keys},\n * <li>monkey patching those reflective methods that would\n * prevent extensions, to add this hidden property first,\n * <li>monkey patching those methods that would reveal this\n * hidden property.\n * </ul>\n * Unfortunately, because of same-origin iframes, we cannot reliably\n * add this hidden property before an object becomes\n * non-extensible. Instead, if we encounter a non-extensible object\n * without a hidden record that we can detect (whether or not it has\n * a hidden record stored under a name secret to us), then we just\n * use the key object itself to represent its identity in a brute\n * force leaky map stored in the weak map, losing all the advantages\n * of weakness for these.\n */\n function getHiddenRecord(key) {\n if (key !== Object(key)) {\n throw new TypeError('Not an object: ' + key);\n }\n var hiddenRecord = key[HIDDEN_NAME];\n if (hiddenRecord && hiddenRecord.key === key) { return hiddenRecord; }\n if (!isExtensible(key)) {\n // Weak map must brute force, as explained in doc-comment above.\n return void 0;\n }\n\n // The hiddenRecord and the key point directly at each other, via\n // the \"key\" and HIDDEN_NAME properties respectively. The key\n // field is for quickly verifying that this hidden record is an\n // own property, not a hidden record from up the prototype chain.\n //\n // NOTE: Because this WeakMap emulation is meant only for systems like\n // SES where Object.prototype is frozen without any numeric\n // properties, it is ok to use an object literal for the hiddenRecord.\n // This has two advantages:\n // * It is much faster in a performance critical place\n // * It avoids relying on Object.create(null), which had been\n // problematic on Chrome 28.0.1480.0. See\n // https://code.google.com/p/google-caja/issues/detail?id=1687\n hiddenRecord = { key: key };\n\n // When using this WeakMap emulation on platforms where\n // Object.prototype might not be frozen and Object.create(null) is\n // reliable, use the following two commented out lines instead.\n // hiddenRecord = Object.create(null);\n // hiddenRecord.key = key;\n\n // Please contact us if you need this to work on platforms where\n // Object.prototype might not be frozen and\n // Object.create(null) might not be reliable.\n\n try {\n defProp(key, HIDDEN_NAME, {\n value: hiddenRecord,\n writable: false,\n enumerable: false,\n configurable: false\n });\n return hiddenRecord;\n } catch (error) {\n // Under some circumstances, isExtensible seems to misreport whether\n // the HIDDEN_NAME can be defined.\n // The circumstances have not been isolated, but at least affect\n // Node.js v0.10.26 on TravisCI / Linux, but not the same version of\n // Node.js on OS X.\n return void 0;\n }\n }\n\n /**\n * Monkey patch operations that would make their argument\n * non-extensible.\n *\n * <p>The monkey patched versions throw a TypeError if their\n * argument is not an object, so it should only be done to functions\n * that should throw a TypeError anyway if their argument is not an\n * object.\n */\n (function(){\n var oldFreeze = Object.freeze;\n defProp(Object, 'freeze', {\n value: function identifyingFreeze(obj) {\n getHiddenRecord(obj);\n return oldFreeze(obj);\n }\n });\n var oldSeal = Object.seal;\n defProp(Object, 'seal', {\n value: function identifyingSeal(obj) {\n getHiddenRecord(obj);\n return oldSeal(obj);\n }\n });\n var oldPreventExtensions = Object.preventExtensions;\n defProp(Object, 'preventExtensions', {\n value: function identifyingPreventExtensions(obj) {\n getHiddenRecord(obj);\n return oldPreventExtensions(obj);\n }\n });\n })();\n\n function constFunc(func) {\n func.prototype = null;\n return Object.freeze(func);\n }\n\n var calledAsFunctionWarningDone = false;\n function calledAsFunctionWarning() {\n // Future ES6 WeakMap is currently (2013-09-10) expected to reject WeakMap()\n // but we used to permit it and do it ourselves, so warn only.\n if (!calledAsFunctionWarningDone && typeof console !== 'undefined') {\n calledAsFunctionWarningDone = true;\n console.warn('WeakMap should be invoked as new WeakMap(), not ' +\n 'WeakMap(). This will be an error in the future.');\n }\n }\n\n var nextId = 0;\n\n var OurWeakMap = function() {\n if (!(this instanceof OurWeakMap)) { // approximate test for new ...()\n calledAsFunctionWarning();\n }\n\n // We are currently (12/25/2012) never encountering any prematurely\n // non-extensible keys.\n var keys = []; // brute force for prematurely non-extensible keys.\n var values = []; // brute force for corresponding values.\n var id = nextId++;\n\n function get___(key, opt_default) {\n var index;\n var hiddenRecord = getHiddenRecord(key);\n if (hiddenRecord) {\n return id in hiddenRecord ? hiddenRecord[id] : opt_default;\n } else {\n index = keys.indexOf(key);\n return index >= 0 ? values[index] : opt_default;\n }\n }\n\n function has___(key) {\n var hiddenRecord = getHiddenRecord(key);\n if (hiddenRecord) {\n return id in hiddenRecord;\n } else {\n return keys.indexOf(key) >= 0;\n }\n }\n\n function set___(key, value) {\n var index;\n var hiddenRecord = getHiddenRecord(key);\n if (hiddenRecord) {\n hiddenRecord[id] = value;\n } else {\n index = keys.indexOf(key);\n if (index >= 0) {\n values[index] = value;\n } else {\n // Since some browsers preemptively terminate slow turns but\n // then continue computing with presumably corrupted heap\n // state, we here defensively get keys.length first and then\n // use it to update both the values and keys arrays, keeping\n // them in sync.\n index = keys.length;\n values[index] = value;\n // If we crash here, values will be one longer than keys.\n keys[index] = key;\n }\n }\n return this;\n }\n\n function delete___(key) {\n var hiddenRecord = getHiddenRecord(key);\n var index, lastIndex;\n if (hiddenRecord) {\n return id in hiddenRecord && delete hiddenRecord[id];\n } else {\n index = keys.indexOf(key);\n if (index < 0) {\n return false;\n }\n // Since some browsers preemptively terminate slow turns but\n // then continue computing with potentially corrupted heap\n // state, we here defensively get keys.length first and then use\n // it to update both the keys and the values array, keeping\n // them in sync. We update the two with an order of assignments,\n // such that any prefix of these assignments will preserve the\n // key/value correspondence, either before or after the delete.\n // Note that this needs to work correctly when index === lastIndex.\n lastIndex = keys.length - 1;\n keys[index] = void 0;\n // If we crash here, there's a void 0 in the keys array, but\n // no operation will cause a \"keys.indexOf(void 0)\", since\n // getHiddenRecord(void 0) will always throw an error first.\n values[index] = values[lastIndex];\n // If we crash here, values[index] cannot be found here,\n // because keys[index] is void 0.\n keys[index] = keys[lastIndex];\n // If index === lastIndex and we crash here, then keys[index]\n // is still void 0, since the aliasing killed the previous key.\n keys.length = lastIndex;\n // If we crash here, keys will be one shorter than values.\n values.length = lastIndex;\n return true;\n }\n }\n\n return Object.create(OurWeakMap.prototype, {\n get___: { value: constFunc(get___) },\n has___: { value: constFunc(has___) },\n set___: { value: constFunc(set___) },\n delete___: { value: constFunc(delete___) }\n });\n };\n\n OurWeakMap.prototype = Object.create(Object.prototype, {\n get: {\n /**\n * Return the value most recently associated with key, or\n * opt_default if none.\n */\n value: function get(key, opt_default) {\n return this.get___(key, opt_default);\n },\n writable: true,\n configurable: true\n },\n\n has: {\n /**\n * Is there a value associated with key in this WeakMap?\n */\n value: function has(key) {\n return this.has___(key);\n },\n writable: true,\n configurable: true\n },\n\n set: {\n /**\n * Associate value with key in this WeakMap, overwriting any\n * previous association if present.\n */\n value: function set(key, value) {\n return this.set___(key, value);\n },\n writable: true,\n configurable: true\n },\n\n 'delete': {\n /**\n * Remove any association for key in this WeakMap, returning\n * whether there was one.\n *\n * <p>Note that the boolean return here does not work like the\n * {@code delete} operator. The {@code delete} operator returns\n * whether the deletion succeeds at bringing about a state in\n * which the deleted property is absent. The {@code delete}\n * operator therefore returns true if the property was already\n * absent, whereas this {@code delete} method returns false if\n * the association was already absent.\n */\n value: function remove(key) {\n return this.delete___(key);\n },\n writable: true,\n configurable: true\n }\n });\n\n if (typeof HostWeakMap === 'function') {\n (function() {\n // If we got here, then the platform has a WeakMap but we are concerned\n // that it may refuse to store some key types. Therefore, make a map\n // implementation which makes use of both as possible.\n\n // In this mode we are always using double maps, so we are not proxy-safe.\n // This combination does not occur in any known browser, but we had best\n // be safe.\n if (doubleWeakMapCheckSilentFailure && typeof Proxy !== 'undefined') {\n Proxy = undefined;\n }\n\n function DoubleWeakMap() {\n if (!(this instanceof OurWeakMap)) { // approximate test for new ...()\n calledAsFunctionWarning();\n }\n\n // Preferable, truly weak map.\n var hmap = new HostWeakMap();\n\n // Our hidden-property-based pseudo-weak-map. Lazily initialized in the\n // 'set' implementation; thus we can avoid performing extra lookups if\n // we know all entries actually stored are entered in 'hmap'.\n var omap = undefined;\n\n // Hidden-property maps are not compatible with proxies because proxies\n // can observe the hidden name and either accidentally expose it or fail\n // to allow the hidden property to be set. Therefore, we do not allow\n // arbitrary WeakMaps to switch to using hidden properties, but only\n // those which need the ability, and unprivileged code is not allowed\n // to set the flag.\n //\n // (Except in doubleWeakMapCheckSilentFailure mode in which case we\n // disable proxies.)\n var enableSwitching = false;\n\n function dget(key, opt_default) {\n if (omap) {\n return hmap.has(key) ? hmap.get(key)\n : omap.get___(key, opt_default);\n } else {\n return hmap.get(key, opt_default);\n }\n }\n\n function dhas(key) {\n return hmap.has(key) || (omap ? omap.has___(key) : false);\n }\n\n var dset;\n if (doubleWeakMapCheckSilentFailure) {\n dset = function(key, value) {\n hmap.set(key, value);\n if (!hmap.has(key)) {\n if (!omap) { omap = new OurWeakMap(); }\n omap.set(key, value);\n }\n return this;\n };\n } else {\n dset = function(key, value) {\n if (enableSwitching) {\n try {\n hmap.set(key, value);\n } catch (e) {\n if (!omap) { omap = new OurWeakMap(); }\n omap.set___(key, value);\n }\n } else {\n hmap.set(key, value);\n }\n return this;\n };\n }\n\n function ddelete(key) {\n var result = !!hmap['delete'](key);\n if (omap) { return omap.delete___(key) || result; }\n return result;\n }\n\n return Object.create(OurWeakMap.prototype, {\n get___: { value: constFunc(dget) },\n has___: { value: constFunc(dhas) },\n set___: { value: constFunc(dset) },\n delete___: { value: constFunc(ddelete) },\n permitHostObjects___: { value: constFunc(function(token) {\n if (token === weakMapPermitHostObjects) {\n enableSwitching = true;\n } else {\n throw new Error('bogus call to permitHostObjects___');\n }\n })}\n });\n }\n DoubleWeakMap.prototype = OurWeakMap.prototype;\n module.exports = DoubleWeakMap;\n\n // define .constructor to hide OurWeakMap ctor\n Object.defineProperty(WeakMap.prototype, 'constructor', {\n value: WeakMap,\n enumerable: false, // as default .constructor is\n configurable: true,\n writable: true\n });\n })();\n } else {\n // There is no host WeakMap, so we must use the emulation.\n\n // Emulated WeakMaps are incompatible with native proxies (because proxies\n // can observe the hidden name), so we must disable Proxy usage (in\n // ArrayLike and Domado, currently).\n if (typeof Proxy !== 'undefined') {\n Proxy = undefined;\n }\n\n module.exports = OurWeakMap;\n }\n})();\n","\nmodule.exports = (typeof WeakMap !== 'undefined') ? WeakMap : require(\"weak-map\");\n","\"use strict\";\n\nvar WeakMap = require(\"./weak-map\");\n\nrequire(\"./shim-function\");\n\nmodule.exports = Object;\n\n/*\n Based in part on extras from Motorola Mobility’s Montage\n Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.\n 3-Clause BSD License\n https://github.com/motorola-mobility/montage/blob/master/LICENSE.md\n*/\n\n/**\n Defines extensions to intrinsic <code>Object</code>.\n @see [Object class]{@link external:Object}\n*/\n\n/**\n A utility object to avoid unnecessary allocations of an empty object\n <code>{}</code>. This object is frozen so it is safe to share.\n\n @object external:Object.empty\n*/\nObject.empty = Object.freeze(Object.create(null));\n\n/**\n Returns whether the given value is an object, as opposed to a value.\n Unboxed numbers, strings, true, false, undefined, and null are not\n objects. Arrays are objects.\n\n @function external:Object.isObject\n @param {Any} value\n @returns {Boolean} whether the given value is an object\n*/\nObject.isObject = function (object) {\n return Object(object) === object;\n};\n\n/**\n Returns the value of an any value, particularly objects that\n implement <code>valueOf</code>.\n\n <p>Note that, unlike the precedent of methods like\n <code>Object.equals</code> and <code>Object.compare</code> would suggest,\n this method is named <code>Object.getValueOf</code> instead of\n <code>valueOf</code>. This is a delicate issue, but the basis of this\n decision is that the JavaScript runtime would be far more likely to\n accidentally call this method with no arguments, assuming that it would\n return the value of <code>Object</code> itself in various situations,\n whereas <code>Object.equals(Object, null)</code> protects against this case\n by noting that <code>Object</code> owns the <code>equals</code> property\n and therefore does not delegate to it.\n\n @function external:Object.getValueOf\n @param {Any} value a value or object wrapping a value\n @returns {Any} the primitive value of that object, if one exists, or passes\n the value through\n*/\nObject.getValueOf = function (value) {\n if (value && typeof value.valueOf === \"function\") {\n value = value.valueOf();\n }\n return value;\n};\n\nvar hashMap = new WeakMap();\nObject.hash = function (object) {\n if (object && typeof object.hash === \"function\") {\n return \"\" + object.hash();\n } else if (Object(object) === object) {\n if (!hashMap.has(object)) {\n hashMap.set(object, Math.random().toString(36).slice(2));\n }\n return hashMap.get(object);\n } else {\n return \"\" + object;\n }\n};\n\n/**\n A shorthand for <code>Object.prototype.hasOwnProperty.call(object,\n key)</code>. Returns whether the object owns a property for the given key.\n It does not consult the prototype chain and works for any string (including\n \"hasOwnProperty\") except \"__proto__\".\n\n @function external:Object.owns\n @param {Object} object\n @param {String} key\n @returns {Boolean} whether the object owns a property wfor the given key.\n*/\nvar owns = Object.prototype.hasOwnProperty;\nObject.owns = function (object, key) {\n return owns.call(object, key);\n};\n\n/**\n A utility that is like Object.owns but is also useful for finding\n properties on the prototype chain, provided that they do not refer to\n methods on the Object prototype. Works for all strings except \"__proto__\".\n\n <p>Alternately, you could use the \"in\" operator as long as the object\n descends from \"null\" instead of the Object.prototype, as with\n <code>Object.create(null)</code>. However,\n <code>Object.create(null)</code> only works in fully compliant EcmaScript 5\n JavaScript engines and cannot be faithfully shimmed.\n\n <p>If the given object is an instance of a type that implements a method\n named \"has\", this function defers to the collection, so this method can be\n used to generically handle objects, arrays, or other collections. In that\n case, the domain of the key depends on the instance.\n\n @param {Object} object\n @param {String} key\n @returns {Boolean} whether the object, or any of its prototypes except\n <code>Object.prototype</code>\n @function external:Object.has\n*/\nObject.has = function (object, key) {\n if (typeof object !== \"object\") {\n throw new Error(\"Object.has can't accept non-object: \" + typeof object);\n }\n // forward to mapped collections that implement \"has\"\n if (object && typeof object.has === \"function\") {\n return object.has(key);\n // otherwise report whether the key is on the prototype chain,\n // as long as it is not one of the methods on object.prototype\n } else if (typeof key === \"string\") {\n return key in object && object[key] !== Object.prototype[key];\n } else {\n throw new Error(\"Key must be a string for Object.has on plain objects\");\n }\n};\n\n/**\n Gets the value for a corresponding key from an object.\n\n <p>Uses Object.has to determine whether there is a corresponding value for\n the given key. As such, <code>Object.get</code> is capable of retriving\n values from the prototype chain as long as they are not from the\n <code>Object.prototype</code>.\n\n <p>If there is no corresponding value, returns the given default, which may\n be <code>undefined</code>.\n\n <p>If the given object is an instance of a type that implements a method\n named \"get\", this function defers to the collection, so this method can be\n used to generically handle objects, arrays, or other collections. In that\n case, the domain of the key depends on the implementation. For a `Map`,\n for example, the key might be any object.\n\n @param {Object} object\n @param {String} key\n @param {Any} value a default to return, <code>undefined</code> if omitted\n @returns {Any} value for key, or default value\n @function external:Object.get\n*/\nObject.get = function (object, key, value) {\n if (typeof object !== \"object\") {\n throw new Error(\"Object.get can't accept non-object: \" + typeof object);\n }\n // forward to mapped collections that implement \"get\"\n if (object && typeof object.get === \"function\") {\n return object.get(key, value);\n } else if (Object.has(object, key)) {\n return object[key];\n } else {\n return value;\n }\n};\n\n/**\n Sets the value for a given key on an object.\n\n <p>If the given object is an instance of a type that implements a method\n named \"set\", this function defers to the collection, so this method can be\n used to generically handle objects, arrays, or other collections. As such,\n the key domain varies by the object type.\n\n @param {Object} object\n @param {String} key\n @param {Any} value\n @returns <code>undefined</code>\n @function external:Object.set\n*/\nObject.set = function (object, key, value) {\n if (object && typeof object.set === \"function\") {\n object.set(key, value);\n } else {\n object[key] = value;\n }\n};\n\nObject.addEach = function (target, source, overrides) {\n var overridesExistingProperty = arguments.length === 3 ? overrides : true;\n if (!source) {\n } else if (typeof source.forEach === \"function\" && !source.hasOwnProperty(\"forEach\")) {\n // copy map-alikes\n if (source.isMap === true) {\n source.forEach(function (value, key) {\n target[key] = value;\n });\n // iterate key value pairs of other iterables\n } else {\n source.forEach(function (pair) {\n target[pair[0]] = pair[1];\n });\n }\n } else if (typeof source.length === \"number\") {\n // arguments, strings\n for (var index = 0; index < source.length; index++) {\n target[index] = source[index];\n }\n } else {\n // copy other objects as map-alikes\n for(var keys = Object.keys(source), i = 0, key;(key = keys[i]); i++) {\n if(overridesExistingProperty || !Object.owns(target,key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n};\n\n\n/*\nvar defineEach = function defineEach(target, prototype) {\n // console.log(\"Map defineEach: \",Object.keys(prototype));\n var proto = Map.prototype;\n for (var name in prototype) {\n if(!proto.hasOwnProperty(name)) {\n Object.defineProperty(proto, name, {\n value: prototype[name],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n }\n }\n}\n*/\nObject.defineEach = function (target, source, overrides, configurable, enumerable, writable) {\n var overridesExistingProperty = arguments.length === 3 ? overrides : true;\n if (!source) {\n } else if (typeof source.forEach === \"function\" && !source.hasOwnProperty(\"forEach\")) {\n // copy map-alikes\n if (source.isMap === true) {\n source.forEach(function (value, key) {\n Object.defineProperty(target, key, {\n value: value,\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n });\n // iterate key value pairs of other iterables\n } else {\n source.forEach(function (pair) {\n Object.defineProperty(target, pair[0], {\n value: pair[1],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n\n });\n }\n } else if (typeof source.length === \"number\") {\n // arguments, strings\n for (var index = 0; index < source.length; index++) {\n Object.defineProperty(target, index, {\n value: source[index],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n\n }\n } else {\n // copy other objects as map-alikes\n for(var keys = Object.keys(source), i = 0, key;(key = keys[i]); i++) {\n if(overridesExistingProperty || !Object.owns(target,key)) {\n Object.defineProperty(target, key, {\n value: source[key],\n writable: writable,\n configurable: configurable,\n enumerable: enumerable\n });\n\n }\n }\n }\n return target;\n};\n\n/**\n Iterates over the owned properties of an object.\n\n @function external:Object.forEach\n @param {Object} object an object to iterate.\n @param {Function} callback a function to call for every key and value\n pair in the object. Receives <code>value</code>, <code>key</code>,\n and <code>object</code> as arguments.\n @param {Object} thisp the <code>this</code> to pass through to the\n callback\n*/\nObject.forEach = function (object, callback, thisp) {\n\n var keys = Object.keys(object), i = 0, iKey;\n for(;(iKey = keys[i]);i++) {\n callback.call(thisp, object[iKey], iKey, object);\n }\n\n};\n\n/**\n Iterates over the owned properties of a map, constructing a new array of\n mapped values.\n\n @function external:Object.map\n @param {Object} object an object to iterate.\n @param {Function} callback a function to call for every key and value\n pair in the object. Receives <code>value</code>, <code>key</code>,\n and <code>object</code> as arguments.\n @param {Object} thisp the <code>this</code> to pass through to the\n callback\n @returns {Array} the respective values returned by the callback for each\n item in the object.\n*/\nObject.map = function (object, callback, thisp) {\n var keys = Object.keys(object), i = 0, result = [], iKey;\n for(;(iKey = keys[i]);i++) {\n result.push(callback.call(thisp, object[iKey], iKey, object));\n }\n return result;\n};\n\n/**\n Returns the values for owned properties of an object.\n\n @function external:Object.map\n @param {Object} object\n @returns {Array} the respective value for each owned property of the\n object.\n*/\nObject.values = function (object) {\n return Object.map(object, Function.identity);\n};\n\n// TODO inline document concat\nObject.concat = function () {\n var object = {};\n for (var i = 0; i < arguments.length; i++) {\n Object.addEach(object, arguments[i]);\n }\n return object;\n};\n\nObject.from = Object.concat;\n\n/**\n Returns whether two values are identical. Any value is identical to itself\n and only itself. This is much more restictive than equivalence and subtly\n different than strict equality, <code>===</code> because of edge cases\n including negative zero and <code>NaN</code>. Identity is useful for\n resolving collisions among keys in a mapping where the domain is any value.\n This method does not delgate to any method on an object and cannot be\n overridden.\n @see http://wiki.ecmascript.org/doku.php?id=harmony:egal\n @param {Any} this\n @param {Any} that\n @returns {Boolean} whether this and that are identical\n @function external:Object.is\n*/\nObject.is = function (x, y) {\n if (x === y) {\n // 0 === -0, but they are not identical\n return x !== 0 || 1 / x === 1 / y;\n }\n // NaN !== NaN, but they are identical.\n // NaNs are the only non-reflexive value, i.e., if x !== x,\n // then x is a NaN.\n // isNaN is broken: it converts its argument to number, so\n // isNaN(\"foo\") => true\n return x !== x && y !== y;\n};\n\n/**\n Performs a polymorphic, type-sensitive deep equivalence comparison of any\n two values.\n\n <p>As a basic principle, any value is equivalent to itself (as in\n identity), any boxed version of itself (as a <code>new Number(10)</code> is\n to 10), and any deep clone of itself.\n\n <p>Equivalence has the following properties:\n\n <ul>\n <li><strong>polymorphic:</strong>\n If the given object is an instance of a type that implements a\n methods named \"equals\", this function defers to the method. So,\n this function can safely compare any values regardless of type,\n including undefined, null, numbers, strings, any pair of objects\n where either implements \"equals\", or object literals that may even\n contain an \"equals\" key.\n <li><strong>type-sensitive:</strong>\n Incomparable types are not equal. No object is equivalent to any\n array. No string is equal to any other number.\n <li><strong>deep:</strong>\n Collections with equivalent content are equivalent, recursively.\n <li><strong>equivalence:</strong>\n Identical values and objects are equivalent, but so are collections\n that contain equivalent content. Whether order is important varies\n by type. For Arrays and lists, order is important. For Objects,\n maps, and sets, order is not important. Boxed objects are mutally\n equivalent with their unboxed values, by virtue of the standard\n <code>valueOf</code> method.\n </ul>\n @param this\n @param that\n @returns {Boolean} whether the values are deeply equivalent\n @function external:Object.equals\n*/\nObject.equals = function (a, b, equals, memo) {\n equals = equals || Object.equals;\n //console.log(\"Object.equals: a:\",a, \"b:\",b, \"equals:\",equals);\n // unbox objects, but do not confuse object literals\n a = Object.getValueOf(a);\n b = Object.getValueOf(b);\n if (a === b)\n return true;\n if (Object.isObject(a)) {\n memo = memo || new WeakMap();\n if (memo.has(a)) {\n return true;\n }\n memo.set(a, true);\n }\n if (Object.isObject(a) && typeof a.equals === \"function\") {\n return a.equals(b, equals, memo);\n }\n // commutative\n if (Object.isObject(b) && typeof b.equals === \"function\") {\n return b.equals(a, equals, memo);\n }\n if (Object.isObject(a) && Object.isObject(b)) {\n if (Object.getPrototypeOf(a) === Object.prototype && Object.getPrototypeOf(b) === Object.prototype) {\n for (var name in a) {\n if (!equals(a[name], b[name], equals, memo)) {\n return false;\n }\n }\n for (var name in b) {\n if (!(name in a) || !equals(b[name], a[name], equals, memo)) {\n return false;\n }\n }\n return true;\n }\n }\n // NaN !== NaN, but they are equal.\n // NaNs are the only non-reflexive value, i.e., if x !== x,\n // then x is a NaN.\n // isNaN is broken: it converts its argument to number, so\n // isNaN(\"foo\") => true\n // We have established that a !== b, but if a !== a && b !== b, they are\n // both NaN.\n if (a !== a && b !== b)\n return true;\n if (!a || !b)\n return a === b;\n return false;\n};\n\n// Because a return value of 0 from a `compare` function may mean either\n// \"equals\" or \"is incomparable\", `equals` cannot be defined in terms of\n// `compare`. However, `compare` *can* be defined in terms of `equals` and\n// `lessThan`. Again however, more often it would be desirable to implement\n// all of the comparison functions in terms of compare rather than the other\n// way around.\n\n/**\n Determines the order in which any two objects should be sorted by returning\n a number that has an analogous relationship to zero as the left value to\n the right. That is, if the left is \"less than\" the right, the returned\n value will be \"less than\" zero, where \"less than\" may be any other\n transitive relationship.\n\n <p>Arrays are compared by the first diverging values, or by length.\n\n <p>Any two values that are incomparable return zero. As such,\n <code>equals</code> should not be implemented with <code>compare</code>\n since incomparability is indistinguishable from equality.\n\n <p>Sorts strings lexicographically. This is not suitable for any\n particular international setting. Different locales sort their phone books\n in very different ways, particularly regarding diacritics and ligatures.\n\n <p>If the given object is an instance of a type that implements a method\n named \"compare\", this function defers to the instance. The method does not\n need to be an owned property to distinguish it from an object literal since\n object literals are incomparable. Unlike <code>Object</code> however,\n <code>Array</code> implements <code>compare</code>.\n\n @param {Any} left\n @param {Any} right\n @returns {Number} a value having the same transitive relationship to zero\n as the left and right values.\n @function external:Object.compare\n*/\nObject.compare = function (a, b) {\n // unbox objects, but do not confuse object literals\n // mercifully handles the Date case\n a = Object.getValueOf(a);\n b = Object.getValueOf(b);\n if (a === b)\n return 0;\n var aType = typeof a;\n var bType = typeof b;\n if (aType === \"number\" && bType === \"number\")\n return a - b;\n if (aType === \"string\" && bType === \"string\")\n return a < b ? -Infinity : Infinity;\n // the possibility of equality elimiated above\n if (a && typeof a.compare === \"function\")\n return a.compare(b);\n // not commutative, the relationship is reversed\n if (b && typeof b.compare === \"function\")\n return -b.compare(a);\n return 0;\n};\n\n/**\n Creates a deep copy of any value. Values, being immutable, are\n returned without alternation. Forwards to <code>clone</code> on\n objects and arrays.\n\n @function external:Object.clone\n @param {Any} value a value to clone\n @param {Number} depth an optional traversal depth, defaults to infinity.\n A value of <code>0</code> means to make no clone and return the value\n directly.\n @param {Map} memo an optional memo of already visited objects to preserve\n reference cycles. The cloned object will have the exact same shape as the\n original, but no identical objects. Te map may be later used to associate\n all objects in the original object graph with their corresponding member of\n the cloned graph.\n @returns a copy of the value\n*/\nObject.clone = function (value, depth, memo) {\n value = Object.getValueOf(value);\n memo = memo || new WeakMap();\n if (depth === undefined) {\n depth = Infinity;\n } else if (depth === 0) {\n return value;\n }\n if (Object.isObject(value)) {\n if (!memo.has(value)) {\n if (value && typeof value.clone === \"function\") {\n memo.set(value, value.clone(depth, memo));\n } else {\n var prototype = Object.getPrototypeOf(value);\n if (prototype === null || prototype === Object.prototype) {\n var clone = Object.create(prototype);\n memo.set(value, clone);\n for (var key in value) {\n clone[key] = Object.clone(value[key], depth - 1, memo);\n }\n } else {\n throw new Error(\"Can't clone \" + value);\n }\n }\n }\n return memo.get(value);\n }\n return value;\n};\n\n/**\n Removes all properties owned by this object making the object suitable for\n reuse.\n\n @function external:Object.clear\n @returns this\n*/\nObject.clear = function (object) {\n if (object && typeof object.clear === \"function\") {\n object.clear();\n } else {\n var keys = Object.keys(object),\n i = keys.length;\n while (i) {\n i--;\n delete object[keys[i]];\n }\n }\n return object;\n};\n","\nvar Object = require(\"./shim-object\");\n\nmodule.exports = GenericOrder;\nfunction GenericOrder() {\n throw new Error(\"Can't construct. GenericOrder is a mixin.\");\n}\n\nGenericOrder.prototype.equals = function (that, equals) {\n equals = equals || this.contentEquals || Object.equals;\n\n if (this === that) {\n return true;\n }\n if (!that) {\n return false;\n }\n\n var self = this;\n return (\n this.length === that.length &&\n this.zip(that).every(function (pair) {\n return equals(pair[0], pair[1]);\n })\n );\n};\n\nGenericOrder.prototype.compare = function (that, compare) {\n compare = compare || this.contentCompare || Object.compare;\n\n if (this === that) {\n return 0;\n }\n if (!that) {\n return 1;\n }\n\n var length = Math.min(this.length, that.length);\n var comparison = this.zip(that).reduce(function (comparison, pair, index) {\n if (comparison === 0) {\n if (index >= length) {\n return comparison;\n } else {\n return compare(pair[0], pair[1]);\n }\n } else {\n return comparison;\n }\n }, 0);\n if (comparison === 0) {\n return this.length - that.length;\n }\n return comparison;\n};\n\nGenericOrder.prototype.toJSON = function () {\n return this.toArray();\n};\n","\"use strict\";\n\n/*\n Based in part on extras from Motorola Mobility’s Montage\n Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.\n 3-Clause BSD License\n https://github.com/motorola-mobility/montage/blob/master/LICENSE.md\n*/\n\nvar Function = require(\"./shim-function\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericOrder = require(\"./generic-order\");\nvar WeakMap = require(\"./weak-map\");\n\nmodule.exports = Array;\n\nvar array_splice = Array.prototype.splice;\nvar array_slice = Array.prototype.slice;\n\nif (!Array.empty) {\n Array.empty = [];\n\n if (Object.freeze) {\n Object.freeze(Array.empty);\n }\n}\n\nif(!Array.nativeFrom ) {\n Array.nativeFrom = Array.from;\n}\n\nvar isSymbolDefined = typeof Symbol !== \"undefined\";\nArray.from = function (values, mapFn, thisArg) {\n if(isSymbolDefined && values && (typeof values[Symbol.iterator] === \"function\" || typeof mapFn === \"function\")) {\n return Array.nativeFrom(values, mapFn, thisArg);\n }\n //Now we add support for values that implement forEach:\n var array = [];\n array.addEach(values);\n return array;\n};\n\nArray.unzip = function (table) {\n var transpose = [];\n var length = Infinity;\n // compute shortest row\n for (var i = 0; i < table.length; i++) {\n var row = table[i];\n table[i] = row.toArray();\n if (row.length < length) {\n length = row.length;\n }\n }\n for (var i = 0; i < table.length; i++) {\n var row = table[i];\n for (var j = 0; j < row.length; j++) {\n if (j < length && j in row) {\n transpose[j] = transpose[j] || [];\n transpose[j][i] = row[j];\n }\n }\n }\n return transpose;\n};\n\nfunction define(key, value) {\n Object.defineProperty(Array.prototype, key, {\n value: value,\n writable: true,\n configurable: true,\n enumerable: false\n });\n}\n\ndefine(\"addEach\", GenericCollection.prototype.addEach);\ndefine(\"deleteEach\", GenericCollection.prototype.deleteEach);\ndefine(\"toArray\", GenericCollection.prototype.toArray);\ndefine(\"toObject\", GenericCollection.prototype.toObject);\ndefine(\"all\", GenericCollection.prototype.all);\ndefine(\"any\", GenericCollection.prototype.any);\ndefine(\"min\", GenericCollection.prototype.min);\ndefine(\"max\", GenericCollection.prototype.max);\ndefine(\"sum\", GenericCollection.prototype.sum);\ndefine(\"average\", GenericCollection.prototype.average);\ndefine(\"only\", GenericCollection.prototype.only);\ndefine(\"flatten\", GenericCollection.prototype.flatten);\ndefine(\"zip\", GenericCollection.prototype.zip);\ndefine(\"enumerate\", GenericCollection.prototype.enumerate);\ndefine(\"group\", GenericCollection.prototype.group);\ndefine(\"sorted\", GenericCollection.prototype.sorted);\ndefine(\"reversed\", GenericCollection.prototype.reversed);\n\ndefine(\"constructClone\", function (values) {\n var clone = new this.constructor();\n clone.addEach(values);\n return clone;\n});\n\ndefine(\"has\", function (value, equals) {\n return this.findValue(value, equals) !== -1;\n});\n\ndefine(\"get\", function (index, defaultValue) {\n if (+index !== index) {\n throw new Error(\"Indicies must be numbers\");\n } else if (!index in this) {\n return defaultValue;\n } else {\n return this[index];\n }\n});\n\ndefine(\"set\", function (index, value) {\n this[index] = value;\n return true;\n});\n\ndefine(\"add\", function (value) {\n this.push(value);\n return true;\n});\n\ndefine(\"delete\", function (value, equals) {\n var index = this.findValue(value, equals);\n if (index !== -1) {\n this.spliceOne(index);\n return true;\n }\n return false;\n});\n\ndefine(\"deleteAll\", function (value, equals) {\n equals = equals || this.contentEquals || Object.equals;\n var count = 0;\n for (var index = 0; index < this.length;) {\n if (equals(value, this[index])) {\n this.swap(index, 1);\n count++;\n } else {\n index++;\n }\n }\n return count;\n});\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find\n// https://tc39.github.io/ecma262/#sec-array.prototype.find\nif (!Array.prototype.find) {\n define(\"find\", function(predicate) {\n // 1. Let O be ? ToObject(this value).\n if (this == null) {\n throw new TypeError('\"this\" is null or not defined');\n }\n\n var o = Object(this);\n\n // 2. Let len be ? ToLength(? Get(O, \"length\")).\n var len = o.length >>> 0;\n\n // 3. If IsCallable(predicate) is false, throw a TypeError exception.\n if (typeof predicate !== 'function') {\n throw new TypeError('predicate must be a function');\n }\n\n // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.\n var thisArg = arguments[1];\n\n // 5. Let k be 0.\n var k = 0;\n\n // 6. Repeat, while k < len\n while (k < len) {\n // a. Let Pk be ! ToString(k).\n // b. Let kValue be ? Get(O, Pk).\n // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).\n // d. If testResult is true, return kValue.\n var kValue = o[k];\n if (predicate.call(thisArg, kValue, k, o)) {\n return kValue;\n }\n // e. Increase k by 1.\n k++;\n }\n });\n}\n\n// TODO remove in v6 (not present in v2)\nvar deprecatedWarnNonce = {};\nfunction deprecatedWarn(msg, notOnce) {\n if (\n typeof console !== 'undefined' &&\n typeof console.warn === 'function' &&\n (notOnce !== true && deprecatedWarnNonce.hasOwnProperty(msg) === false)\n ) {\n console.warn(msg);\n deprecatedWarnNonce[msg]++;\n }\n}\n\n// Save Array.prototype.find in order to support legacy and display warning.\n// TODO remove in v6 (not present in v2)\nvar ArrayFindPrototype = Object.getOwnPropertyDescriptor(Array.prototype, 'find').value;\ndefine(\"find\", function (value, equals, index) {\n if (\n typeof arguments[0] === 'function' &&\n this instanceof Array\n ) {\n return ArrayFindPrototype.apply(this, arguments);\n } else {\n deprecatedWarn('Array#find usage is deprecated please use Array#findValue');\n return this.findValue.apply(this, arguments);\n }\n});\n\ndefine(\"findValue\", function (value, equals, index) {\n if (index) {\n throw new Error(\"Array#findValue does not support third argument: index\");\n }\n equals = equals || this.contentEquals || Object.equals;\n for (var index = 0; index < this.length; index++) {\n if (index in this && equals(value, this[index])) {\n return index;\n }\n }\n return -1;\n});\n\n// TODO remove in v6 (not present in v2)\ndefine(\"findLast\", function (value, equals) {\n deprecatedWarn('Array#findLast function is deprecated please use Array#findLastValue instead.');\n return this.findLastValue.apply(this, arguments);\n});\n\ndefine(\"findLastValue\", function (value, equals) {\n equals = equals || this.contentEquals || Object.equals;\n var index = this.length;\n do {\n index--;\n if (index in this && equals(this[index], value)) {\n return index;\n }\n } while (index > 0);\n return -1;\n});\n\ndefine(\"swap\", function (start, length, plus) {\n var args, plusLength, i, j, returnValue;\n if (start > this.length) {\n this.length = start;\n }\n if (typeof plus !== \"undefined\") {\n args = [start, length];\n if (!Array.isArray(plus)) {\n plus = array_slice.call(plus);\n }\n i = 0;\n plusLength = plus.length;\n // 1000 is a magic number, presumed to be smaller than the remaining\n // stack length. For swaps this small, we take the fast path and just\n // use the underlying Array splice. We could measure the exact size of\n // the remaining stack using a try/catch around an unbounded recursive\n // function, but this would defeat the purpose of short-circuiting in\n // the common case.\n if (plusLength < 1000) {\n for (i; i < plusLength; i++) {\n args[i+2] = plus[i];\n }\n return array_splice.apply(this, args);\n } else {\n // Avoid maximum call stack error.\n // First delete the desired entries.\n returnValue = array_splice.apply(this, args);\n // Second batch in 1000s.\n for (i; i < plusLength;) {\n args = [start+i, 0];\n for (j = 2; j < 1002 && i < plusLength; j++, i++) {\n args[j] = plus[i];\n }\n array_splice.apply(this, args);\n }\n return returnValue;\n }\n // using call rather than apply to cut down on transient objects\n } else if (typeof length !== \"undefined\") {\n return array_splice.call(this, start, length);\n } else if (typeof start !== \"undefined\") {\n return array_splice.call(this, start);\n } else {\n return [];\n }\n});\n\ndefine(\"peek\", function () {\n return this[0];\n});\n\ndefine(\"poke\", function (value) {\n if (this.length > 0) {\n this[0] = value;\n }\n});\n\ndefine(\"peekBack\", function () {\n if (this.length > 0) {\n return this[this.length - 1];\n }\n});\n\ndefine(\"pokeBack\", function (value) {\n if (this.length > 0) {\n this[this.length - 1] = value;\n }\n});\n\ndefine(\"one\", function () {\n for (var i in this) {\n if (Object.owns(this, i)) {\n return this[i];\n }\n }\n});\n\nif (!Array.prototype.clear) {\n define(\"clear\", function () {\n this.length = 0;\n return this;\n });\n}\n\ndefine(\"compare\", function (that, compare) {\n compare = compare || Object.compare;\n var i;\n var length;\n var lhs;\n var rhs;\n var relative;\n\n if (this === that) {\n return 0;\n }\n\n if (!that || !Array.isArray(that)) {\n return GenericOrder.prototype.compare.call(this, that, compare);\n }\n\n length = (this.length < that.length) ? this.length : that.length;\n\n for (i = 0; i < length; i++) {\n if (i in this) {\n if (!(i in that)) {\n return -1;\n } else {\n lhs = this[i];\n rhs = that[i];\n relative = compare(lhs, rhs);\n if (relative) {\n return relative;\n }\n }\n } else if (i in that) {\n return 1;\n }\n }\n\n return this.length - that.length;\n});\n\ndefine(\"equals\", function (that, equals) {\n equals = equals || Object.equals;\n var i = 0;\n var length = this.length;\n var left;\n var right;\n\n if (this === that) {\n return true;\n }\n if (!that || !Array.isArray(that)) {\n return GenericOrder.prototype.equals.call(this, that);\n }\n\n if (length !== that.length) {\n return false;\n } else {\n for (; i < length; ++i) {\n if (i in this) {\n if (!(i in that)) {\n return false;\n }\n left = this[i];\n right = that[i];\n if (!equals(left, right)) {\n return false;\n }\n } else {\n if (i in that) {\n return false;\n }\n }\n }\n }\n return true;\n});\n\ndefine(\"clone\", function (depth, memo) {\n if (depth == null) {\n depth = Infinity;\n } else if (depth === 0) {\n return this;\n }\n memo = memo || new WeakMap();\n if (memo.has(this)) {\n return memo.get(this);\n }\n var clone = new Array(this.length);\n memo.set(this, clone);\n for (var i in this) {\n clone[i] = Object.clone(this[i], depth - 1, memo);\n };\n return clone;\n});\n\ndefine(\"iterate\", function (start, end) {\n return new ArrayIterator(this, start, end);\n});\n\nif(Array.prototype.spliceOne === void 0) {\n define(\"spliceOne\", function (index,itemToAdd) {\n var len=this.length;\n if (!len) { return }\n if(arguments.length === 1) {\n while (index<len) {\n this[index] = this[index+1];\n index++\n }\n this.length--;\n }\n else {\n this[index] = itemToAdd;\n }\n });\n}\n\ndefine(\"Iterator\", ArrayIterator);\n\nfunction ArrayIterator(array, start, end) {\n this.array = array;\n this.start = start == null ? 0 : start;\n this.end = end;\n}\n\nArrayIterator.prototype.__iterationObject = null;\nObject.defineProperty(ArrayIterator.prototype,\"_iterationObject\", {\n get: function() {\n return this.__iterationObject || (this.__iterationObject = { done: false, value:null});\n }\n});\n\nArrayIterator.prototype.next = function () {\n if (this.start === (this.end == null ? this.array.length : this.end)) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n } else {\n this._iterationObject.value = this.array[this.start++];\n }\n return this._iterationObject;\n};\n","\n/**\n accepts a string; returns the string with regex metacharacters escaped.\n the returned string can safely be used within a regex to match a literal\n string. escaped characters are [, ], {, }, (, ), -, *, +, ?, ., \\, ^, $,\n |, #, [comma], and whitespace.\n*/\nif (!RegExp.escape) {\n var special = /[-[\\]{}()*+?.\\\\^$|,#\\s]/g;\n RegExp.escape = function (string) {\n return string.replace(special, \"\\\\$&\");\n };\n}\n\n","\nvar Array = require(\"./shim-array\");\nvar Object = require(\"./shim-object\");\nvar Function = require(\"./shim-function\");\nvar RegExp = require(\"./shim-regexp\");\n\n","\nmodule.exports = GenericSet;\nfunction GenericSet() {\n throw new Error(\"Can't construct. GenericSet is a mixin.\");\n}\n\nGenericSet.prototype.isSet = true;\n\nGenericSet.prototype.union = function (that) {\n var union = this.constructClone(this);\n union.addEach(that);\n return union;\n};\n\nGenericSet.prototype.intersection = function (that) {\n return this.constructClone(this.filter(function (value) {\n return that.has(value);\n }));\n};\n\nGenericSet.prototype.difference = function (that) {\n var union = this.constructClone(this);\n union.deleteEach(that);\n return union;\n};\n\nGenericSet.prototype.symmetricDifference = function (that) {\n var union = this.union(that);\n var intersection = this.intersection(that);\n return union.difference(intersection);\n};\n\nGenericSet.prototype.deleteAll = function (value) {\n // deleteAll is equivalent to delete for sets since they guarantee that\n // only one value exists for an equivalence class, but deleteAll returns\n // the count of deleted values instead of whether a value was deleted.\n return +this[\"delete\"](value);\n};\n\nGenericSet.prototype.equals = function (that, equals) {\n var self = this;\n return (\n that && typeof that.reduce === \"function\" &&\n this.length === that.length &&\n that.reduce(function (equal, value) {\n return equal && self.has(value, equals);\n }, true)\n );\n};\n\nGenericSet.prototype.forEach = function (callback /*, thisp*/) {\n var thisp = arguments[1];\n return this.reduce(function (undefined, value, key, object, depth) {\n //ECMASCRIPT Sets send value twice in callback to forEach\n callback.call(thisp, value, value, object, depth);\n }, undefined);\n};\n\n\nGenericSet.prototype.toJSON = function () {\n return this.toArray();\n};\n\n// W3C DOMTokenList API overlap (does not handle variadic arguments)\n\nGenericSet.prototype.contains = function (value) {\n return this.has(value);\n};\n\nGenericSet.prototype.remove = function (value) {\n return this[\"delete\"](value);\n};\n\nGenericSet.prototype.toggle = function (value) {\n if (this.has(value)) {\n this[\"delete\"](value);\n } else {\n this.add(value);\n }\n};\n\nvar _valuesArrayFunction = function(value,key) {return value;};\nGenericSet.prototype.valuesArray = function() {\n return this.map(_valuesArrayFunction);\n}\nvar _entriesArrayFunction = function(value,key) {return [key,value];};\nGenericSet.prototype.entriesArray = function() {\n return this.map(_entriesArrayFunction);\n}\n","\"use strict\";\n\nmodule.exports = List;\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericOrder = require(\"./generic-order\");\n\nfunction List(values, equals, getDefault) {\n return List._init(List, this, values, equals, getDefault);\n}\n\nList._init = function (constructor, object, values, equals, getDefault) {\n if (!(object instanceof constructor)) {\n return new constructor(values, equals, getDefault);\n }\n var head = object.head = new object.Node();\n head.next = head;\n head.prev = head;\n object.contentEquals = equals || Object.equals;\n object.getDefault = getDefault || Function.noop;\n object.length = 0;\n object.addEach(values);\n}\n\nList.List = List; // hack so require(\"list\").List will work in MontageJS\n\nObject.addEach(List.prototype, GenericCollection.prototype);\nObject.addEach(List.prototype, GenericOrder.prototype);\n\nList.from = GenericCollection.from;\n\nList.prototype.constructClone = function (values) {\n return new this.constructor(values, this.contentEquals, this.getDefault);\n};\n\nList.prototype.find = function (value, equals, index) {\n equals = equals || this.contentEquals;\n var head = this.head;\n var at = this.scan(index, head.next);\n while (at !== head) {\n if (equals(at.value, value)) {\n return at;\n }\n at = at.next;\n }\n};\n\nList.prototype.findLast = function (value, equals, index) {\n equals = equals || this.contentEquals;\n var head = this.head;\n var at = this.scan(index, head.prev);\n while (at !== head) {\n if (equals(at.value, value)) {\n return at;\n }\n at = at.prev;\n }\n};\n\nList.prototype.has = function (value, equals) {\n return !!this.find(value, equals);\n};\n\nList.prototype.get = function (value, equals) {\n var found = this.find(value, equals);\n if (found) {\n return found.value;\n }\n return this.getDefault(value);\n};\n\n// LIFO (delete removes the most recently added equivalent value)\nList.prototype[\"delete\"] = function (value, equals) {\n var found = this.findLast(value, equals);\n if (found) {\n found[\"delete\"]();\n this.length--;\n return true;\n }\n return false;\n};\n\nList.prototype.deleteAll = function (value, equals) {\n equals = equals || this.contentEquals;\n var head = this.head;\n var at = head.next;\n var count = 0;\n while (at !== head) {\n if (equals(value, at.value)) {\n at[\"delete\"]();\n count++;\n }\n at = at.next;\n }\n this.length -= count;\n return count;\n};\n\nList.prototype.clear = function () {\n this.head.next = this.head.prev = this.head;\n this.length = 0;\n};\n\nList.prototype.add = function (value) {\n var node = new this.Node(value)\n return this._addNode(node);\n};\n\nList.prototype._addNode = function (node) {\n this.head.addBefore(node);\n this.length++;\n return true;\n};\n\nList.prototype.push = function () {\n var head = this.head;\n for (var i = 0; i < arguments.length; i++) {\n var value = arguments[i];\n var node = new this.Node(value);\n head.addBefore(node);\n }\n this.length += arguments.length;\n};\n\nList.prototype.unshift = function () {\n var at = this.head;\n for (var i = 0; i < arguments.length; i++) {\n var value = arguments[i];\n var node = new this.Node(value);\n at.addAfter(node);\n at = node;\n }\n this.length += arguments.length;\n};\n\nList.prototype._shouldPop = function () {\n var value;\n var head = this.head;\n if (head.prev !== head) {\n value = head.prev.value;\n }\n return value;\n}\n\nList.prototype.pop = function (_before, _after) {\n var value;\n var head = this.head;\n if (head.prev !== head) {\n value = head.prev.value;\n var index = this.length - 1;\n var popDispatchValueArray = _before ? _before.call(this,value,index) : void 0;\n head.prev['delete']();\n this.length--;\n _after ? _after.call(this,value,index, popDispatchValueArray) : void 0;\n }\n return value;\n};\n\nList.prototype.shift = function (_before, _after) {\n var value;\n var head = this.head;\n if (head.prev !== head) {\n value = head.next.value;\n var dispatchValueArray = _before ? _before.call(this,value,0) : void 0;\n head.next['delete']();\n this.length--;\n _after ? _after.call(this,value,0,dispatchValueArray) : void 0;\n }\n return value;\n};\n\nList.prototype.peek = function () {\n if (this.head !== this.head.next) {\n return this.head.next.value;\n }\n};\n\nList.prototype.poke = function (value) {\n if (this.head !== this.head.next) {\n this.head.next.value = value;\n } else {\n this.push(value);\n }\n};\n\nList.prototype.one = function () {\n return this.peek();\n};\n\n// TODO\n// List.prototype.indexOf = function (value) {\n// };\n\n// TODO\n// List.prototype.lastIndexOf = function (value) {\n// };\n\n// an internal utility for coercing index offsets to nodes\nList.prototype.scan = function (at, fallback) {\n var head = this.head;\n if (typeof at === \"number\") {\n var count = at;\n if (count >= 0) {\n at = head.next;\n while (count) {\n count--;\n at = at.next;\n if (at == head) {\n break;\n }\n }\n } else {\n at = head;\n while (count < 0) {\n count++;\n at = at.prev;\n if (at == head) {\n break;\n }\n }\n }\n return at;\n } else {\n return at || fallback;\n }\n};\n\n// at and end may both be positive or negative numbers (in which cases they\n// correspond to numeric indicies, or nodes)\nList.prototype.slice = function (at, end) {\n var sliced = [];\n var head = this.head;\n at = this.scan(at, head.next);\n end = this.scan(end, head);\n\n while (at !== end && at !== head) {\n sliced.push(at.value);\n at = at.next;\n }\n\n return sliced;\n};\n\nList.prototype.splice = function (at, length /*...plus*/) {\n return this.swap(at, length, Array.prototype.slice.call(arguments, 2));\n};\n\nList.prototype.swap = function (start, length, plus, _before, _after) {\n var initial = start;\n // start will be head if start is null or -1 (meaning from the end), but\n // will be head.next if start is 0 (meaning from the beginning)\n start = this.scan(start, this.head);\n if (length == null) {\n length = Infinity;\n }\n plus = Array.from(plus);\n\n // collect the minus array\n var minus = [];\n var at = start;\n while (length-- && length >= 0 && at !== this.head) {\n minus.push(at.value);\n at = at.next;\n }\n\n // before range change\n var index, startNode;\n index = _before ? _before.call(this, start, plus, minus) : void 0;\n\n // delete minus\n var at = start;\n for (var i = 0, at = start; i < minus.length; i++, at = at.next) {\n at[\"delete\"]();\n }\n // add plus\n if (initial == null && at === this.head) {\n at = this.head.next;\n }\n for (var i = 0; i < plus.length; i++) {\n var node = new this.Node(plus[i]);\n at.addBefore(node);\n }\n // adjust length\n this.length += plus.length - minus.length;\n\n _after ? _after.call(this, start, plus, minus) : void 0;\n\n return minus;\n};\n\nList.prototype.reverse = function () {\n var at = this.head;\n do {\n var temp = at.next;\n at.next = at.prev;\n at.prev = temp;\n at = at.next;\n } while (at !== this.head);\n return this;\n};\n\nList.prototype.sort = function () {\n this.swap(0, this.length, this.sorted.apply(this, arguments));\n};\n\n// TODO account for missing basis argument\nList.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var head = this.head;\n var at = head.next;\n while (at !== head) {\n basis = callback.call(thisp, basis, at.value, at, this);\n at = at.next;\n }\n return basis;\n};\n\nList.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var head = this.head;\n var at = head.prev;\n while (at !== head) {\n basis = callback.call(thisp, basis, at.value, at, this);\n at = at.prev;\n }\n return basis;\n};\n\nList.prototype.updateIndexes = function (node, index) {\n while (node !== this.head) {\n node.index = index++;\n node = node.next;\n }\n};\n\n\nList.prototype.iterate = function () {\n return new ListIterator(this.head);\n};\n\nfunction ListIterator(head) {\n this.head = head;\n this.at = head.next;\n};\n\nListIterator.prototype.__iterationObject = null;\nObject.defineProperty(ListIterator.prototype,\"_iterationObject\", {\n get: function() {\n return this.__iterationObject || (this.__iterationObject = { done: false, value:null});\n }\n});\n\n\nListIterator.prototype.next = function () {\n if (this.at === this.head) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n } else {\n var value = this.at.value;\n this.at = this.at.next;\n this._iterationObject.value = value;\n }\n return this._iterationObject;\n};\n\nList.prototype.Node = Node;\n\nfunction Node(value) {\n this.value = value;\n this.prev = null;\n this.next = null;\n};\n\nNode.prototype[\"delete\"] = function () {\n this.prev.next = this.next;\n this.next.prev = this.prev;\n};\n\nNode.prototype.addBefore = function (node) {\n var prev = this.prev;\n this.prev = node;\n node.prev = prev;\n prev.next = node;\n node.next = this;\n};\n\nNode.prototype.addAfter = function (node) {\n var next = this.next;\n this.next = node;\n node.next = next;\n next.prev = node;\n node.prev = this;\n};\n","\"use strict\";\n\nmodule.exports = Iterator;\n\nvar Object = require(\"./shim-object\");\nvar GenericCollection = require(\"./generic-collection\");\n\n// upgrades an iterable to a Iterator\nfunction Iterator(iterable, standardMode) {\n\n /*\n standardMode should be passed as true by a collection that uses Iterator\n to provide a polyfill of standard iterations methods like entries() and values(),\n as Collection's iterator behaves differently than standards ones when it comes to sparse arrays.\n without passing standardMode, new Iterator instances will behave as intended independently of standards.\n */\n var values = standardMode && iterable && iterable.values && iterable.values();\n if(values && typeof values.next === \"function\" ) {\n return values;\n }\n\n if (!(this instanceof Iterator)) {\n return new Iterator(iterable);\n }\n\n if (Array.isArray(iterable) || typeof iterable === \"string\")\n return Iterator.iterate(iterable);\n\n iterable = Object(iterable);\n\n if (iterable instanceof Iterator) {\n return iterable;\n } else if (iterable.next) {\n this.next = function () {\n return iterable.next();\n };\n } else if (iterable.iterate) {\n var iterator = iterable.iterate();\n this.next = function () {\n return iterator.next();\n };\n } else if (Object.prototype.toString.call(iterable) === \"[object Function]\") {\n this.next = iterable;\n } else {\n throw new TypeError(\"Can't iterate \" + iterable);\n }\n\n}\n\nIterator.prototype.forEach = GenericCollection.prototype.forEach;\nIterator.prototype.map = GenericCollection.prototype.map;\nIterator.prototype.filter = GenericCollection.prototype.filter;\nIterator.prototype.every = GenericCollection.prototype.every;\nIterator.prototype.some = GenericCollection.prototype.some;\nIterator.prototype.any = GenericCollection.prototype.any;\nIterator.prototype.all = GenericCollection.prototype.all;\nIterator.prototype.min = GenericCollection.prototype.min;\nIterator.prototype.max = GenericCollection.prototype.max;\nIterator.prototype.sum = GenericCollection.prototype.sum;\nIterator.prototype.average = GenericCollection.prototype.average;\nIterator.prototype.flatten = GenericCollection.prototype.flatten;\nIterator.prototype.zip = GenericCollection.prototype.zip;\nIterator.prototype.enumerate = GenericCollection.prototype.enumerate;\nIterator.prototype.sorted = GenericCollection.prototype.sorted;\nIterator.prototype.group = GenericCollection.prototype.group;\nIterator.prototype.reversed = GenericCollection.prototype.reversed;\nIterator.prototype.toArray = GenericCollection.prototype.toArray;\nIterator.prototype.toObject = GenericCollection.prototype.toObject;\nIterator.prototype.iterator = GenericCollection.prototype.iterator;\n\nIterator.prototype.__iterationObject = null;\nObject.defineProperty(Iterator.prototype,\"_iterationObject\", {\n get: function() {\n return this.__iterationObject || (this.__iterationObject = { done: false, value:void 0});\n }\n});\n\n\n// this is a bit of a cheat so flatten and such work with the generic\n// reducible\nIterator.prototype.constructClone = function (values) {\n var clone = [];\n clone.addEach(values);\n return clone;\n};\n\nIterator.prototype.mapIterator = function (callback /*, thisp*/) {\n var self = Iterator(this),\n thisp = arguments[1],\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n return new self.constructor(function () {\n if(self._iterationObject.done !== true) {\n var callbackValue = callback.call(thisp, self.next().value, i++, self);\n self._iterationObject.value = callbackValue;\n }\n return self._iterationObject;\n });\n};\n\nIterator.prototype.filterIterator = function (callback /*, thisp*/) {\n var self = Iterator(this),\n thisp = arguments[1],\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n return new self.constructor(function () {\n var nextEntry;\n while (true) {\n nextEntry = self.next();\n if(nextEntry.done !== true) {\n if (callback.call(thisp, nextEntry.value, i++, self))\n return nextEntry;\n }\n else {\n //done true and value undefined at this point\n return nextEntry;\n }\n }\n });\n};\n\nIterator.prototype.reduce = function (callback /*, initial, thisp*/) {\n var self = Iterator(this),\n result = arguments[1],\n thisp = arguments[2],\n i = 0,\n nextEntry;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n // first iteration unrolled\n nextEntry = self.next();\n if(nextEntry.done === true) {\n if (arguments.length > 1) {\n return arguments[1]; // initial\n } else {\n throw TypeError(\"cannot reduce a value from an empty iterator with no initial value\");\n }\n }\n if (arguments.length > 1) {\n result = callback.call(thisp, result, nextEntry.value, i, self);\n } else {\n result = nextEntry.value;\n }\n i++;\n // remaining entries\n while (true) {\n nextEntry = self.next();\n if(nextEntry.done === true) {\n return result;\n }\n result = callback.call(thisp, result, nextEntry.value, i, self);\n i++;\n }\n\n};\n\nIterator.prototype.concat = function () {\n return Iterator.concat(\n Array.prototype.concat.apply(this, arguments)\n );\n};\n\nIterator.prototype.dropWhile = function (callback /*, thisp */) {\n var self = Iterator(this),\n thisp = arguments[1],\n stopped = false,\n stopValue,\n nextEntry,\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n while (true) {\n nextEntry = self.next();\n if(nextEntry.done === true) {\n break;\n }\n if (!callback.call(thisp, nextEntry.value, i, self)) {\n stopped = true;\n stopValue = nextEntry.value;\n break;\n }\n i++;\n }\n\n if (stopped) {\n return self.constructor([stopValue]).concat(self);\n } else {\n return self.constructor([]);\n }\n};\n\nIterator.prototype.takeWhile = function (callback /*, thisp*/) {\n var self = Iterator(this),\n thisp = arguments[1],\n nextEntry,\n i = 0;\n\n if (Object.prototype.toString.call(callback) != \"[object Function]\")\n throw new TypeError();\n\n return new self.constructor(function () {\n if(self._iterationObject.done !== true) {\n var value = self.next().value;\n if(callback.call(thisp, value, i++, self)) {\n self._iterationObject.value = value;\n }\n else {\n self._iterationObject.done = true;\n self._iterationObject.value = void 0;\n }\n }\n return self._iterationObject;\n });\n\n};\n\nIterator.prototype.zipIterator = function () {\n return Iterator.unzip(\n Array.prototype.concat.apply(this, arguments)\n );\n};\n\nIterator.prototype.enumerateIterator = function (start) {\n return Iterator.count(start).zipIterator(this);\n};\n\n// creates an iterator for Array and String\nIterator.iterate = function (iterable) {\n var start;\n start = 0;\n return new Iterator(function () {\n // advance to next owned entry\n if (typeof iterable === \"object\") {\n while (!(start in iterable)) {\n // deliberately late bound\n if (start >= iterable.length) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n break;\n }\n else start += 1;\n }\n } else if (start >= iterable.length) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n\n if(!this._iterationObject.done) {\n this._iterationObject.value = iterable[start];\n start += 1;\n }\n return this._iterationObject;\n });\n};\n\nIterator.cycle = function (cycle, times) {\n var next;\n if (arguments.length < 2)\n times = Infinity;\n //cycle = Iterator(cycle).toArray();\n return new Iterator(function () {\n var iteration, nextEntry;\n\n if(next) {\n nextEntry = next();\n }\n\n if(!next || nextEntry.done === true) {\n if (times > 0) {\n times--;\n iteration = Iterator.iterate(cycle);\n nextEntry = (next = iteration.next.bind(iteration))();\n }\n else {\n this._iterationObject.done = true;\n nextEntry = this._iterationObject; }\n }\n return nextEntry;\n });\n};\n\nIterator.concat = function (iterators) {\n iterators = Iterator(iterators);\n var next;\n return new Iterator(function (){\n var iteration, nextEntry;\n if(next) nextEntry = next();\n if(!nextEntry || nextEntry.done === true) {\n nextEntry = iterators.next();\n if(nextEntry.done === false) {\n iteration = Iterator(nextEntry.value);\n next = iteration.next.bind(iteration);\n return next();\n }\n else {\n return nextEntry;\n }\n }\n else return nextEntry;\n });\n};\n\nIterator.unzip = function (iterators) {\n iterators = Iterator(iterators).map(Iterator);\n if (iterators.length === 0)\n return new Iterator([]);\n return new Iterator(function () {\n var stopped, nextEntry;\n var result = iterators.map(function (iterator) {\n nextEntry = iterator.next();\n if (nextEntry.done === true ) {\n stopped = true;\n }\n return nextEntry.value;\n });\n if (stopped) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n else {\n this._iterationObject.value = result;\n }\n return this._iterationObject;\n });\n};\n\nIterator.zip = function () {\n return Iterator.unzip(\n Array.prototype.slice.call(arguments)\n );\n};\n\nIterator.chain = function () {\n return Iterator.concat(\n Array.prototype.slice.call(arguments)\n );\n};\n\nIterator.range = function (start, stop, step) {\n if (arguments.length < 3) {\n step = 1;\n }\n if (arguments.length < 2) {\n stop = start;\n start = 0;\n }\n start = start || 0;\n step = step || 1;\n return new Iterator(function () {\n if (start >= stop) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n var result = start;\n start += step;\n this._iterationObject.value = result;\n\n return this._iterationObject;\n });\n};\n\nIterator.count = function (start, step) {\n return Iterator.range(start, Infinity, step);\n};\n\nIterator.repeat = function (value, times) {\n return new Iterator.range(times).mapIterator(function () {\n return value;\n });\n};\n","\"use strict\";\n\nvar Object = require(\"./shim-object\");\nvar Iterator = require(\"./iterator\");\n\nmodule.exports = GenericMap;\nfunction GenericMap() {\n throw new Error(\"Can't construct. GenericMap is a mixin.\");\n}\n\n// all of these methods depend on the constructor providing a `store` set\n\nGenericMap.prototype.isMap = true;\n\nGenericMap.prototype.addEach = function (values) {\n var i;\n if (values && Object(values) === values) {\n if (typeof values.forEach === \"function\") {\n // copy map-alikes\n if (values.isMap === true) {\n values.forEach(function (value, key) {\n this.set(key, value);\n }, this);\n // iterate key value pairs of other iterables\n } else {\n values.forEach(function (pair) {\n this.set(pair[0], pair[1]);\n }, this);\n }\n } else if (typeof values.length === \"number\") {\n // Array-like objects that do not implement forEach, ergo,\n // Arguments\n for (i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n } else {\n // copy other objects as map-alikes\n Object.keys(values).forEach(function (key) {\n this.set(key, values[key]);\n }, this);\n }\n } else if (values && typeof values.length === \"number\") {\n // String\n for (i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n return this;\n};\n\nGenericMap.prototype.get = function (key, defaultValue) {\n var item = this.store.get(new this.Item(key));\n if (item) {\n return item.value;\n } else if (arguments.length > 1) {\n console.log(\"Use of a second argument as default value is deprecated to match standards\");\n return defaultValue;\n } else {\n return this.getDefault(key);\n }\n};\n\nGenericMap.prototype.set = function (key, value) {\n var item = new this.Item(key, value);\n var found = this.store.get(item);\n var grew = false;\n if (found) { // update\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, found.value);\n }\n found.value = value;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n } else { // create\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, undefined);\n }\n if (this.store.add(item)) {\n this.length++;\n grew = true;\n }\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n }\n return this;\n};\n\nGenericMap.prototype.add = function (value, key) {\n return this.set(key, value);\n};\n\nGenericMap.prototype.has = function (key) {\n return this.store.has(new this.Item(key));\n};\n\nGenericMap.prototype['delete'] = function (key) {\n var item = new this.Item(key);\n if (this.store.has(item)) {\n var from = this.store.get(item).value;\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, from);\n }\n this.store[\"delete\"](item);\n this.length--;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n};\n\nGenericMap.prototype.clear = function () {\n var keys, key;\n if (this.dispatchesMapChanges) {\n this.forEach(function (value, key) {\n this.dispatchBeforeMapChange(key, value);\n }, this);\n keys = this.keysArray();\n }\n this.store.clear();\n this.length = 0;\n if (this.dispatchesMapChanges) {\n for(var i=0;(key = keys[i]);i++) {\n this.dispatchMapChange(key);\n }\n // keys.forEach(function (key) {\n // this.dispatchMapChange(key);\n // }, this);\n }\n};\n\nGenericMap.prototype.reduce = function (callback, basis, thisp) {\n return this.store.reduce(function (basis, item) {\n return callback.call(thisp, basis, item.value, item.key, this);\n }, basis, this);\n};\n\nGenericMap.prototype.reduceRight = function (callback, basis, thisp) {\n return this.store.reduceRight(function (basis, item) {\n return callback.call(thisp, basis, item.value, item.key, this);\n }, basis, this);\n};\n\nGenericMap.prototype.keysArray = function () {\n return this.map(function (value, key) {\n return key;\n });\n};\nGenericMap.prototype.keys = function () {\n return new Iterator(this.keysArray(), true);\n};\n\nGenericMap.prototype.valuesArray = function () {\n return this.map(Function.identity);\n};\nGenericMap.prototype.values = function () {\n return new Iterator(this.valuesArray(), true);\n};\n\nGenericMap.prototype.entriesArray = function () {\n return this.map(function (value, key) {\n return [key, value];\n });\n};\nGenericMap.prototype.entries = function () {\n return new Iterator(this.entriesArray(), true);\n};\n\n// XXX deprecated\nGenericMap.prototype.items = function () {\n return this.entriesArray();\n};\n\nGenericMap.prototype.equals = function (that, equals) {\n equals = equals || Object.equals;\n if (this === that) {\n return true;\n } else if (that && typeof that.every === \"function\") {\n return that.length === this.length && that.every(function (value, key) {\n return equals(this.get(key), value);\n }, this);\n } else {\n var keys = Object.keys(that);\n return keys.length === this.length && Object.keys(that).every(function (key) {\n return equals(this.get(key), that[key]);\n }, this);\n }\n};\n\nGenericMap.prototype.toJSON = function () {\n return this.entriesArray();\n};\n\n\nGenericMap.prototype.Item = Item;\n\nfunction Item(key, value) {\n this.key = key;\n this.value = value;\n}\n\nItem.prototype.equals = function (that) {\n return Object.equals(this.key, that.key) && Object.equals(this.value, that.value);\n};\n\nItem.prototype.compare = function (that) {\n return Object.compare(this.key, that.key);\n};\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericMap = require(\"./generic-map\");\n\n// Burgled from https://github.com/domenic/dict\n\nmodule.exports = Dict;\nfunction Dict(values, getDefault) {\n if (!(this instanceof Dict)) {\n return new Dict(values, getDefault);\n }\n getDefault = getDefault || Function.noop;\n this.getDefault = getDefault;\n this.store = Object.create(null);\n this.length = 0;\n this.addEach(values);\n}\n\nDict.Dict = Dict; // hack so require(\"dict\").Dict will work in MontageJS.\n\nObject.addEach(Dict.prototype, GenericCollection.prototype);\nObject.addEach(Dict.prototype, GenericMap.prototype);\n\nDict.from = GenericCollection.from;\n\nDict.prototype.constructClone = function (values) {\n return new this.constructor(values, this.getDefault);\n};\n\nDict.prototype.assertString = function (key) {\n if (typeof key !== \"string\") {\n throw new TypeError(\"key must be a string but Got \" + key);\n }\n}\n\nObject.defineProperty(Dict.prototype,\"$__proto__\",{writable:true});\nObject.defineProperty(Dict.prototype,\"_hasProto\",{\n get:function() {\n return this.hasOwnProperty(\"$__proto__\") && typeof this._protoValue !== \"undefined\";\n }\n});\nObject.defineProperty(Dict.prototype,\"_protoValue\",{\n get:function() {\n return this[\"$__proto__\"];\n },\n set: function(value) {\n this[\"$__proto__\"] = value;\n }\n});\n\nObject.defineProperty(Dict.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\n\nDict.prototype.get = function (key, defaultValue) {\n this.assertString(key);\n if (key === \"__proto__\") {\n if (this._hasProto) {\n return this._protoValue;\n } else if (arguments.length > 1) {\n return defaultValue;\n } else {\n return this.getDefault(key);\n }\n }\n else {\n if (key in this.store) {\n return this.store[key];\n } else if (arguments.length > 1) {\n return defaultValue;\n } else {\n return this.getDefault(key);\n }\n }\n};\n\nDict.prototype.set = function (key, value) {\n this.assertString(key);\n var isProtoKey = (key === \"__proto__\");\n\n if (isProtoKey ? this._hasProto : key in this.store) { // update\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, isProtoKey ? this._protoValue : this.store[key]);\n }\n\n isProtoKey\n ? this._protoValue = value\n : this.store[key] = value;\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n return false;\n } else { // create\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, undefined);\n }\n this.length++;\n\n isProtoKey\n ? this._protoValue = value\n : this.store[key] = value;\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n return true;\n }\n};\n\nDict.prototype.has = function (key) {\n this.assertString(key);\n return key === \"__proto__\" ? this._hasProto : key in this.store;\n};\n\nDict.prototype[\"delete\"] = function (key) {\n this.assertString(key);\n if (key === \"__proto__\") {\n if (this._hasProto) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this._protoValue);\n }\n this._protoValue = undefined;\n this.length--;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n }\n else {\n if (key in this.store) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this.store[key]);\n }\n delete this.store[key];\n this.length--;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n }\n};\n\nDict.prototype.clear = function () {\n var key;\n if (this._hasProto) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(\"__proto__\", this._protoValue);\n }\n this._protoValue = undefined;\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(\"__proto__\", undefined);\n }\n }\n for (key in this.store) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this.store[key]);\n }\n delete this.store[key];\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n }\n this.length = 0;\n};\n\nDict.prototype.reduce = function (callback, basis, thisp) {\n if(this._hasProto) {\n basis = callback.call(thisp, basis, \"$__proto__\", \"__proto__\", this);\n }\n var store = this.store;\n for (var key in this.store) {\n basis = callback.call(thisp, basis, store[key], key, this);\n }\n return basis;\n};\n\nDict.prototype.reduceRight = function (callback, basis, thisp) {\n var self = this;\n var store = this.store;\n basis = Object.keys(this.store).reduceRight(function (basis, key) {\n return callback.call(thisp, basis, store[key], key, self);\n }, basis);\n\n if(this._hasProto) {\n return callback.call(thisp, basis, this._protoValue, \"__proto__\", self);\n }\n return basis;\n};\n\nDict.prototype.one = function () {\n var key;\n for (key in this.store) {\n return this.store[key];\n }\n return this._protoValue;\n};\n\nDict.prototype.toJSON = function () {\n return this.toObject();\n};\n","\"use strict\";\n\nmodule.exports = TreeLog;\n\nfunction TreeLog() {\n}\n\nTreeLog.ascii = {\n intersection: \"+\",\n through: \"-\",\n branchUp: \"+\",\n branchDown: \"+\",\n fromBelow: \".\",\n fromAbove: \"'\",\n fromBoth: \"+\",\n strafe: \"|\"\n};\n\nTreeLog.unicodeRound = {\n intersection: \"\\u254b\",\n through: \"\\u2501\",\n branchUp: \"\\u253b\",\n branchDown: \"\\u2533\",\n fromBelow: \"\\u256d\", // round corner\n fromAbove: \"\\u2570\", // round corner\n fromBoth: \"\\u2523\",\n strafe: \"\\u2503\"\n};\n\nTreeLog.unicodeSharp = {\n intersection: \"\\u254b\",\n through: \"\\u2501\",\n branchUp: \"\\u253b\",\n branchDown: \"\\u2533\",\n fromBelow: \"\\u250f\", // sharp corner\n fromAbove: \"\\u2517\", // sharp corner\n fromBoth: \"\\u2523\",\n strafe: \"\\u2503\"\n};\n\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar Dict = require(\"./_dict\");\nvar List = require(\"./_list\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericSet = require(\"./generic-set\");\nvar TreeLog = require(\"./tree-log\");\n\nvar object_has = Object.prototype.hasOwnProperty;\n\nmodule.exports = FastSet;\n\nfunction FastSet(values, equals, hash, getDefault) {\n if (!(this instanceof FastSet)) {\n return new FastSet(values, equals, hash, getDefault);\n }\n equals = equals || Object.equals;\n hash = hash || Object.hash;\n getDefault = getDefault || Function.noop;\n this.contentEquals = equals;\n this.contentHash = hash;\n this.getDefault = getDefault;\n var self = this;\n this.buckets = new this.Buckets(null, function getDefaultBucket() {\n return new self.Bucket();\n });\n this.length = 0;\n this.addEach(values);\n}\n\nFastSet.FastSet = FastSet; // hack so require(\"fast-set\").FastSet will work in MontageJS\n\nObject.addEach(FastSet.prototype, GenericCollection.prototype);\nObject.addEach(FastSet.prototype, GenericSet.prototype);\nFastSet.from = GenericCollection.from;\n\nFastSet.prototype.Buckets = Dict;\nFastSet.prototype.Bucket = List;\n\nFastSet.prototype.constructClone = function (values) {\n return new this.constructor(\n values,\n this.contentEquals,\n this.contentHash,\n this.getDefault\n );\n};\n\nFastSet.prototype.has = function (value) {\n var hash = this.contentHash(value);\n return this.buckets.get(hash).has(value);\n};\n\nFastSet.prototype.get = function (value, equals) {\n if (equals) {\n throw new Error(\"FastSet#get does not support second argument: equals\");\n }\n var hash = this.contentHash(value);\n var buckets = this.buckets;\n if (buckets.has(hash)) {\n return buckets.get(hash).get(value);\n } else {\n return this.getDefault(value);\n }\n};\n\nFastSet.prototype[\"delete\"] = function (value, equals) {\n if (equals) {\n throw new Error(\"FastSet#delete does not support second argument: equals\");\n }\n var hash = this.contentHash(value);\n var buckets = this.buckets;\n if (buckets.has(hash)) {\n var bucket = buckets.get(hash);\n if (bucket[\"delete\"](value)) {\n this.length--;\n if (bucket.length === 0) {\n buckets[\"delete\"](hash);\n }\n return true;\n }\n }\n return false;\n};\n\nFastSet.prototype.clear = function () {\n this.buckets.clear();\n this.length = 0;\n};\n\nFastSet.prototype.add = function (value) {\n var hash = this.contentHash(value);\n var buckets = this.buckets;\n if (!buckets.has(hash)) {\n buckets.set(hash, new this.Bucket(null, this.contentEquals));\n }\n if (!buckets.get(hash).has(value)) {\n buckets.get(hash).add(value);\n this.length++;\n return true;\n }\n return false;\n};\n\nFastSet.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var buckets = this.buckets;\n var index = 0;\n return buckets.reduce(function (basis, bucket) {\n return bucket.reduce(function (basis, value) {\n return callback.call(thisp, basis, value, index++, this);\n }, basis, this);\n }, basis, this);\n};\n\nFastSet.prototype.one = function () {\n if (this.length > 0) {\n return this.buckets.one().one();\n }\n};\n\nFastSet.prototype.iterate = function () {\n return this.buckets.valuesArray().flatten().iterate();\n};\n\nFastSet.prototype.log = function (charmap, logNode, callback, thisp) {\n charmap = charmap || TreeLog.unicodeSharp;\n logNode = logNode || this.logNode;\n if (!callback) {\n callback = console.log;\n thisp = console;\n }\n callback = callback.bind(thisp);\n\n var buckets = this.buckets, bucketsSize = buckets.size,\n mapIter = buckets.keys(), hash, index = 0,\n branch, leader, bucket;\n\n while (hash = mapIter.next().value) {\n if (index === bucketsSize - 1) {\n branch = charmap.fromAbove;\n leader = ' ';\n } else if (index === 0) {\n branch = charmap.branchDown;\n leader = charmap.strafe;\n } else {\n branch = charmap.fromBoth;\n leader = charmap.strafe;\n }\n bucket = buckets.get(hash);\n callback.call(thisp, branch + charmap.through + charmap.branchDown + ' ' + hash);\n bucket.forEach(function (value, node) {\n var branch, below, written;\n if (node === bucket.head.prev) {\n branch = charmap.fromAbove;\n below = ' ';\n } else {\n branch = charmap.fromBoth;\n below = charmap.strafe;\n }\n logNode(\n node,\n function (line) {\n if (!written) {\n callback.call(thisp, leader + ' ' + branch + charmap.through + charmap.through + line);\n written = true;\n } else {\n callback.call(thisp, leader + ' ' + below + ' ' + line);\n }\n },\n function (line) {\n callback.call(thisp, leader + ' ' + charmap.strafe + ' ' + line);\n }\n );\n });\n index++;\n }\n\n //var hashes = buckets.keysArray();\n // hashes.forEach(function (hash, index) {\n // var branch;\n // var leader;\n // if (index === hashes.length - 1) {\n // branch = charmap.fromAbove;\n // leader = ' ';\n // } else if (index === 0) {\n // branch = charmap.branchDown;\n // leader = charmap.strafe;\n // } else {\n // branch = charmap.fromBoth;\n // leader = charmap.strafe;\n // }\n // var bucket = buckets.get(hash);\n // callback.call(thisp, branch + charmap.through + charmap.branchDown + ' ' + hash);\n // bucket.forEach(function (value, node) {\n // var branch, below;\n // if (node === bucket.head.prev) {\n // branch = charmap.fromAbove;\n // below = ' ';\n // } else {\n // branch = charmap.fromBoth;\n // below = charmap.strafe;\n // }\n // var written;\n // logNode(\n // node,\n // function (line) {\n // if (!written) {\n // callback.call(thisp, leader + ' ' + branch + charmap.through + charmap.through + line);\n // written = true;\n // } else {\n // callback.call(thisp, leader + ' ' + below + ' ' + line);\n // }\n // },\n // function (line) {\n // callback.call(thisp, leader + ' ' + charmap.strafe + ' ' + line);\n // }\n // );\n // });\n // });\n};\n\nFastSet.prototype.logNode = function (node, write) {\n var value = node.value;\n if (Object(value) === value) {\n JSON.stringify(value, null, 4).split(\"\\n\").forEach(function (line) {\n write(\" \" + line);\n });\n } else {\n write(\" \" + value);\n }\n};\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericSet = require(\"./generic-set\");\nvar Set, GlobalSet, CollectionsSet;\n\n\nif((global.Set !== void 0) && (typeof global.Set.prototype.values === \"function\")) {\n\n GlobalSet = module.exports = global.Set;\n GlobalSet.Set = GlobalSet; // hack so require(\"set\").Set will work in MontageJS\n\n GlobalSet.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n this.forEach(function(value) {\n basis = callback.call(thisp, basis, value, this);\n });\n return basis;\n };\n\n GlobalSet.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var setIterator = this.values();\n var size = this.size;\n var reverseOrder = new Array(this.size);\n var value, i = size;\n // Fill 'reverseOrder' with values of Set in inverted order.\n while ((value = setIterator.next().value)) {\n reverseOrder[--i] = value;\n }\n // Iterate over reversed values and callback.\n while (i < size) {\n basis = callback.call(thisp, basis, reverseOrder[i++], this);\n }\n return basis;\n };\n\n GlobalSet.prototype.equals = function (that, equals) {\n var self = this;\n return (\n that && typeof that.reduce === \"function\" &&\n this.size === (that.size || that.length) &&\n that.reduce(function (equal, value) {\n return equal && self.has(value, equals);\n }, true)\n );\n };\n\n GlobalSet.prototype.constructClone = function (values) {\n return new this.constructor(values, this.contentEquals, this.contentHash, this.getDefault);\n };\n\n GlobalSet.prototype.toJSON = function () {\n return this.entriesArray();\n };\n\n GlobalSet.prototype.one = function () {\n if (this.size > 0) {\n return this.values().next().value;\n }\n return undefined;\n };\n\n GlobalSet.prototype.pop = function () {\n if (this.size) {\n var setIterator = this.values(), aValue, value;\n while(aValue = setIterator.next().value) {\n value = aValue;\n }\n this[\"delete\"](value,this.size-1);\n return value;\n }\n };\n\n GlobalSet.prototype.shift = function () {\n if (this.size) {\n var firstValue = this.values().next().value;\n this[\"delete\"](firstValue,0);\n return firstValue;\n }\n };\n\n //Backward compatibility:\n Object.defineProperty(GlobalSet.prototype,\"length\",{\n get: function() {\n return this.size;\n },\n enumerable: true,\n configurable:true\n });\n\n GlobalSet.from = function (value) {\n var result = (new this);\n result.addEach(value);\n return result;\n };\n\n Object.addEach(GlobalSet.prototype, GenericCollection.prototype, false);\n Object.addEach(GlobalSet.prototype, GenericSet.prototype, false);\n\n}\n\n\n\n var List = require(\"./_list\");\n var FastSet = require(\"./_fast-set\");\n var Iterator = require(\"./iterator\");\n\n CollectionsSet = function CollectionsSet(values, equals, hash, getDefault) {\n return CollectionsSet._init(CollectionsSet, this, values, equals, hash, getDefault);\n }\n\n CollectionsSet._init = function (constructor, object, values, equals, hash, getDefault) {\n if (!(object instanceof constructor)) {\n return new constructor(values, equals, hash, getDefault);\n }\n equals = equals || Object.equals;\n hash = hash || Object.hash;\n getDefault = getDefault || Function.noop;\n object.contentEquals = equals;\n object.contentHash = hash;\n object.getDefault = getDefault;\n // a list of values in insertion order, used for all operations that depend\n // on iterating in insertion order\n object.order = new object.Order(undefined, equals);\n // a set of nodes from the order list, indexed by the corresponding value,\n // used for all operations that need to quickly seek value in the list\n object.store = new object.Store(\n undefined,\n function (a, b) {\n return equals(a.value, b.value);\n },\n function (node) {\n return hash(node.value);\n }\n );\n object.length = 0;\n object.addEach(values);\n\n }\n\n CollectionsSet.Set = CollectionsSet; // hack so require(\"set\").Set will work in MontageJS\n CollectionsSet.CollectionsSet = CollectionsSet;\n\n Object.addEach(CollectionsSet.prototype, GenericCollection.prototype);\n Object.addEach(CollectionsSet.prototype, GenericSet.prototype);\n\n CollectionsSet.from = GenericCollection.from;\n\n Object.defineProperty(CollectionsSet.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\n //Overrides for consistency:\n // Set.prototype.forEach = GenericCollection.prototype.forEach;\n\n\n CollectionsSet.prototype.Order = List;\n CollectionsSet.prototype.Store = FastSet;\n\n CollectionsSet.prototype.constructClone = function (values) {\n return new this.constructor(values, this.contentEquals, this.contentHash, this.getDefault);\n };\n\n CollectionsSet.prototype.has = function (value) {\n var node = new this.order.Node(value);\n return this.store.has(node);\n };\n\n CollectionsSet.prototype.get = function (value, equals) {\n if (equals) {\n throw new Error(\"Set#get does not support second argument: equals\");\n }\n var node = new this.order.Node(value);\n node = this.store.get(node);\n if (node) {\n return node.value;\n } else {\n return this.getDefault(value);\n }\n };\n\n CollectionsSet.prototype.add = function (value) {\n var node = new this.order.Node(value);\n if (!this.store.has(node)) {\n var index = this.length;\n this.order.add(value);\n node = this.order.head.prev;\n this.store.add(node);\n this.length++;\n return true;\n }\n return false;\n };\n\n CollectionsSet.prototype[\"delete\"] = function (value, equals) {\n if (equals) {\n throw new Error(\"Set#delete does not support second argument: equals\");\n }\n var node = new this.order.Node(value);\n if (this.store.has(node)) {\n node = this.store.get(node);\n this.store[\"delete\"](node); // removes from the set\n this.order.splice(node, 1); // removes the node from the list\n this.length--;\n return true;\n }\n return false;\n };\n\n CollectionsSet.prototype.pop = function () {\n if (this.length) {\n var result = this.order.head.prev.value;\n this[\"delete\"](result);\n return result;\n }\n };\n\n CollectionsSet.prototype.shift = function () {\n if (this.length) {\n var result = this.order.head.next.value;\n this[\"delete\"](result);\n return result;\n }\n };\n\n CollectionsSet.prototype.one = function () {\n if (this.length > 0) {\n return this.store.one().value;\n }\n };\n\n CollectionsSet.prototype.clear = function () {\n this.store.clear();\n this.order.clear();\n this.length = 0;\n };\n Object.defineProperty(CollectionsSet.prototype,\"_clear\", {\n value: CollectionsSet.prototype.clear\n });\n\n CollectionsSet.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var list = this.order;\n var index = 0;\n return list.reduce(function (basis, value) {\n return callback.call(thisp, basis, value, index++, this);\n }, basis, this);\n };\n\n CollectionsSet.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var list = this.order;\n var index = this.length - 1;\n return list.reduceRight(function (basis, value) {\n return callback.call(thisp, basis, value, index--, this);\n }, basis, this);\n };\n\n CollectionsSet.prototype.iterate = function () {\n return this.order.iterate();\n };\n\n CollectionsSet.prototype.values = function () {\n return new Iterator(this.valuesArray(), true);\n };\n\n CollectionsSet.prototype.log = function () {\n var set = this.store;\n return set.log.apply(set, arguments);\n };\n\n\n\nif(!GlobalSet) {\n module.exports = CollectionsSet;\n}\nelse {\n GlobalSet.prototype.valuesArray = GenericSet.prototype.valuesArray;\n GlobalSet.prototype.entriesArray = GenericSet.prototype.entriesArray;\n module.exports = GlobalSet;\n GlobalSet.CollectionsSet = CollectionsSet;\n}\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar Map, GlobalMap, CollectionsMap;\n\nif((global.Map !== void 0) && (typeof global.Set.prototype.values === \"function\")) {\n\n Map = module.exports = global.Map,\n GlobalMap = Map;\n Map.Map = Map; // hack so require(\"map\").Map will work in MontageJS\n\n // use different strategies for making sets observable between Internet\n // Explorer and other browsers.\n var protoIsSupported = {}.__proto__ === Object.prototype,\n map_makeObservable;\n\n if (protoIsSupported) {\n map_makeObservable = function () {\n this.__proto__ = ChangeDispatchMap;\n };\n } else {\n map_makeObservable = function () {\n Object.defineProperties(this, observableSetProperties);\n };\n }\n\n Object.defineProperty(Map.prototype, \"makeObservable\", {\n value: map_makeObservable,\n writable: true,\n configurable: true,\n enumerable: false\n });\n\n //This is a no-op test in property-changes.js - PropertyChanges.prototype.makePropertyObservable, so might as well not pay the price every time....\n Object.defineProperty(Map.prototype, \"makePropertyObservable\", {\n value: function(){},\n writable: true,\n configurable: true,\n enumerable: false\n });\n\n\n Map.prototype.constructClone = function (values) {\n return new this.constructor(values);\n };\n\n Map.prototype.isMap = true;\n Map.prototype.addEach = function (values) {\n if (values && Object(values) === values) {\n if (typeof values.forEach === \"function\") {\n // copy map-alikes\n if (values.isMap === true) {\n values.forEach(function (value, key) {\n this.set(key, value);\n }, this);\n // iterate key value pairs of other iterables\n } else {\n values.forEach(function (pair) {\n this.set(pair[0], pair[1]);\n }, this);\n }\n } else if (typeof values.length === \"number\") {\n // Array-like objects that do not implement forEach, ergo,\n // Arguments\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n } else {\n // copy other objects as map-alikes\n Object.keys(values).forEach(function (key) {\n this.set(key, values[key]);\n }, this);\n }\n } else if (values && typeof values.length === \"number\") {\n // String\n for (var i = 0; i < values.length; i++) {\n this.add(values[i], i);\n }\n }\n return this;\n };\n\n Map.prototype.add = function (value, key) {\n return this.set(key, value);\n };\n\n Map.prototype.reduce = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n this.forEach(function(value, key, map) {\n basis = callback.call(thisp, basis, value, key, this);\n });\n return basis;\n };\n\n Map.prototype.reduceRight = function (callback, basis /*, thisp*/) {\n var thisp = arguments[2];\n var keysIterator = this.keys();\n var size = this.size;\n var reverseOrder = new Array(this.size);\n var aKey, i = 0;\n while ((aKey = keysIterator.next().value)) {\n reverseOrder[--size] = aKey;\n }\n while (i++ < size) {\n basis = callback.call(thisp, basis, this.get(reverseOrder[i]), reverseOrder[i], this);\n }\n return basis;\n };\n\n Map.prototype.equals = function (that, equals) {\n equals = equals || Object.equals;\n if (this === that) {\n return true;\n } else if (that && typeof that.every === \"function\") {\n return that.size === this.size && that.every(function (value, key) {\n return equals(this.get(key), value);\n }, this);\n } else {\n var keys = Object.keys(that);\n return keys.length === this.size && Object.keys(that).every(function (key) {\n return equals(this.get(key), that[key]);\n }, this);\n }\n };\n\n var _keysArrayFunction = function(value,key) {return key;};\n Map.prototype.keysArray = function() {\n return this.map(_keysArrayFunction);\n }\n var _valuesArrayFunction = function(value,key) {return value;};\n Map.prototype.valuesArray = function() {\n return this.map(_valuesArrayFunction);\n }\n var _entriesArrayFunction = function(value,key) {return [key,value];};\n Map.prototype.entriesArray = function() {\n return this.map(_entriesArrayFunction);\n }\n Map.prototype.toJSON = function () {\n return this.entriesArray();\n };\n\n // XXX deprecated\n Map.prototype.items = function () {\n return this.entriesArray();\n };\n\n // Map.prototype.contentEquals = Object.equals;\n // Map.prototype.contentHash = Object.hash;\n\n\n Map.from = function (value) {\n var result = new this;\n result.addEach(value);\n return result;\n };\n\n\n //Backward compatibility:\n Object.defineProperty(Map.prototype,\"length\",{\n get: function() {\n return this.size;\n },\n enumerable: true,\n configurable:true\n });\n\n\n var map_clear = Map.prototype.clear,\n map_set = Map.prototype.set,\n map_delete = Map.prototype.delete;\n\n var observableMapProperties = {\n clear : {\n value: function () {\n var keys;\n if (this.dispatchesMapChanges) {\n this.forEach(function (value, key) {\n this.dispatchBeforeMapChange(key, value);\n }, this);\n keys = this.keysArray();\n }\n map_clear.call(this);\n if (this.dispatchesMapChanges) {\n keys.forEach(function (key) {\n this.dispatchMapChange(key);\n }, this);\n }\n },\n writable: true,\n configurable: true\n\n },\n set : {\n value: function (key, value) {\n var found = this.get(key);\n if (found) { // update\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, found);\n }\n\n map_set.call(this,key, value);\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n } else { // create\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, undefined);\n }\n\n map_set.call(this,key, value);\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, value);\n }\n }\n return this;\n },\n writable: true,\n configurable: true\n },\n\n \"delete\": {\n value: function (key) {\n if (this.has(key)) {\n if (this.dispatchesMapChanges) {\n this.dispatchBeforeMapChange(key, this.get(key));\n }\n map_delete.call(this,key);\n\n if (this.dispatchesMapChanges) {\n this.dispatchMapChange(key, undefined);\n }\n return true;\n }\n return false;\n }\n }\n };\n\n\n\n Object.addEach(Map.prototype, GenericCollection.prototype, false);\n\n var ChangeDispatchMap = Object.create(Map.prototype, observableMapProperties);\n}\n\n var Set = require(\"./_set\").CollectionsSet;\n var GenericMap = require(\"./generic-map\");\n\n CollectionsMap = Map = function Map(values, equals, hash, getDefault) {\n if (!(this instanceof Map)) {\n return new Map(values, equals, hash, getDefault);\n }\n equals = equals || Object.equals;\n hash = hash || Object.hash;\n getDefault = getDefault || Function.noop;\n this.contentEquals = equals;\n this.contentHash = hash;\n this.getDefault = getDefault;\n this.store = new Set(\n undefined,\n function keysEqual(a, b) {\n return equals(a.key, b.key);\n },\n function keyHash(item) {\n return hash(item.key);\n }\n );\n this.length = 0;\n this.addEach(values);\n }\n\n Map.Map = Map; // hack so require(\"map\").Map will work in MontageJS\n\n Object.addEach(Map.prototype, GenericCollection.prototype);\n Object.addEach(Map.prototype, GenericMap.prototype); // overrides GenericCollection\n Object.defineProperty(Map.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\n Map.from = GenericCollection.from;\n\n Map.prototype.constructClone = function (values) {\n return new this.constructor(\n values,\n this.contentEquals,\n this.contentHash,\n this.getDefault\n );\n };\n\n Map.prototype.log = function (charmap, logNode, callback, thisp) {\n logNode = logNode || this.logNode;\n this.store.log(charmap, function (node, log, logBefore) {\n logNode(node.value.value, log, logBefore);\n }, callback, thisp);\n };\n\n Map.prototype.logNode = function (node, log) {\n log(' key: ' + node.key);\n log(' value: ' + node.value);\n };\n\n if(!GlobalMap) {\n module.exports = CollectionsMap;\n }\n else {\n module.exports = GlobalMap;\n GlobalMap.CollectionsMap = CollectionsMap;\n }\n","/*\n Copyright (c) 2016, Montage Studio Inc. All Rights Reserved.\n 3-Clause BSD License\n https://github.com/montagejs/montage/blob/master/LICENSE.md\n*/\n\nvar Map = require(\"../_map\");\n\nvar ObjectChangeDescriptor = module.exports.ObjectChangeDescriptor = function ObjectChangeDescriptor(name) {\n this.name = name;\n this.isActive = false;\n this._willChangeListeners = null;\n this._changeListeners = null;\n\treturn this;\n}\n\nObject.defineProperties(ObjectChangeDescriptor.prototype,{\n name: {\n\t\tvalue:null,\n\t\twritable: true\n\t},\n isActive: {\n\t\tvalue:false,\n\t\twritable: true\n\t},\n\t_willChangeListeners: {\n\t\tvalue:null,\n\t\twritable: true\n\t},\n\twillChangeListeners: {\n\t\tget: function() {\n\t\t\treturn this._willChangeListeners || (this._willChangeListeners = new this.willChangeListenersRecordConstructor(this.name));\n\t\t}\n\t},\n\t_changeListeners: {\n\t\tvalue:null,\n\t\twritable: true\n\t},\n changeListeners: {\n\t\tget: function() {\n\t\t\treturn this._changeListeners || (this._changeListeners = new this.changeListenersRecordConstructor(this.name));\n\t\t}\n\t},\n changeListenersRecordConstructor: {\n value: ChangeListenersRecord,\n writable: true\n },\n willChangeListenersRecordConstructor: {\n value: WillChangeListenersRecord,\n writable: true\n }\n\n});\n\nvar ListenerGhost = module.exports.ListenerGhost = Object.create(null);\nvar ChangeListenerSpecificHandlerMethodName = new Map();\n\n module.exports.ChangeListenersRecord = ChangeListenersRecord;\nfunction ChangeListenersRecord(name) {\n var specificHandlerMethodName = ChangeListenerSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name;\n specificHandlerMethodName += \"Change\";\n ChangeListenerSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this._current = null;\n this._current = null;\n this.specificHandlerMethodName = specificHandlerMethodName;\n return this;\n}\n\nObject.defineProperties(ChangeListenersRecord.prototype,{\n _current: {\n\t\tvalue: null,\n\t\twritable: true\n\t},\n\tcurrent: {\n\t\tget: function() {\n // if(this._current) {\n // console.log(this.constructor.name,\" with \",this._current.length,\" listeners: \", this._current);\n // }\n return this._current;\n //return this._current || (this._current = []);\n\t\t},\n set: function(value) {\n this._current = value;\n }\n\t},\n ListenerGhost: {\n value:ListenerGhost,\n writable: true\n },\n ghostCount: {\n value:0,\n writable: true\n },\n maxListenerGhostRatio: {\n value:0.3,\n writable: true\n },\n listenerGhostFilter: {\n value: function listenerGhostFilter(value) {\n return value !== this.ListenerGhost;\n }\n },\n removeCurrentGostListenersIfNeeded: {\n value: function() {\n if(this._current && this.ghostCount/this._current.length>this.maxListenerGhostRatio) {\n this.ghostCount = 0;\n this._current = this._current.filter(this.listenerGhostFilter,this);\n }\n return this._current;\n }\n },\n dispatchBeforeChange: {\n value: false,\n writable: true\n },\n genericHandlerMethodName: {\n\t\tvalue: \"handlePropertyChange\",\n writable: true\n\t}\n});\n\nmodule.exports.WillChangeListenersRecord = WillChangeListenersRecord;\nvar WillChangeListenerSpecificHandlerMethodName = new Map();\nfunction WillChangeListenersRecord(name) {\n var specificHandlerMethodName = WillChangeListenerSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name;\n specificHandlerMethodName += \"WillChange\";\n WillChangeListenerSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n\treturn this;\n}\nWillChangeListenersRecord.prototype = new ChangeListenersRecord();\nWillChangeListenersRecord.prototype.constructor = WillChangeListenersRecord;\nWillChangeListenersRecord.prototype.genericHandlerMethodName = \"handlePropertyWillChange\";\n","/*\n Based in part on observable arrays from Motorola Mobility’s Montage\n Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved.\n 3-Clause BSD License\n https://github.com/motorola-mobility/montage/blob/master/LICENSE.md\n*/\n\n/*\n This module is responsible for observing changes to owned properties of\n objects and changes to the content of arrays caused by method calls.\n The interface for observing array content changes establishes the methods\n necessary for any collection with observable content.\n*/\n\n\n\n// objectHasOwnProperty.call(myObject, key) will be used instead of\n// myObject.hasOwnProperty(key) to allow myObject have defined\n// a own property called \"hasOwnProperty\".\n\nvar objectHasOwnProperty = Object.prototype.hasOwnProperty;\n\n// Object property descriptors carry information necessary for adding,\n// removing, dispatching, and shorting events to listeners for property changes\n// for a particular key on a particular object. These descriptors are used\n// here for shallow property changes. The current listeners are the ones\n// modified by add and remove own property change listener methods. During\n// property change dispatch, we capture a snapshot of the current listeners in\n// the active change listeners array. The descriptor also keeps a memo of the\n// corresponding handler method names.\n//\n// {\n// willChangeListeners:{current, active:Array<Function>, ...method names}\n// changeListeners:{current, active:Array<Function>, ...method names}\n// }\n\n// Maybe remove entries from this table if the corresponding object no longer\n// has any property change listeners for any key. However, the cost of\n// book-keeping is probably not warranted since it would be rare for an\n// observed object to no longer be observed unless it was about to be disposed\n// of or reused as an observable. The only benefit would be in avoiding bulk\n// calls to dispatchOwnPropertyChange events on objects that have no listeners.\n\n// To observe shallow property changes for a particular key of a particular\n// object, we install a property descriptor on the object that overrides the previous\n// descriptor. The overridden descriptors are stored in this weak map. The\n// weak map associates an object with another object that maps property names\n// to property descriptors.\n//\n// object.__overriddenPropertyDescriptors__[key]\n//\n// We retain the old descriptor for various purposes. For one, if the property\n// is no longer being observed by anyone, we revert the property descriptor to\n// the original. For \"value\" descriptors, we store the actual value of the\n// descriptor on the overridden descriptor, so when the property is reverted, it\n// retains the most recently set value. For \"get\" and \"set\" descriptors,\n// we observe then forward \"get\" and \"set\" operations to the original descriptor.\n\nmodule.exports = PropertyChanges;\n\nfunction PropertyChanges() {\n throw new Error(\"This is an abstract interface. Mix it. Don't construct it\");\n}\n\nrequire(\"../shim\");\nvar Map = require(\"../_map\");\nvar WeakMap = require(\"../weak-map\");\nvar ChangeDescriptor = require(\"./change-descriptor\"),\n ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor,\n ListenerGhost = ChangeDescriptor.ListenerGhost;\n\nPropertyChanges.debug = true;\n\nvar ObjectsPropertyChangeListeners = new WeakMap();\n\nvar ObjectChangeDescriptorName = new Map();\n\nPropertyChanges.ObjectChangeDescriptor = function() {\n\n}\n\nPropertyChanges.prototype.getOwnPropertyChangeDescriptor = function (key) {\n var objectPropertyChangeDescriptors = ObjectsPropertyChangeListeners.get(this), keyChangeDescriptor;\n if (!objectPropertyChangeDescriptors) {\n objectPropertyChangeDescriptors = Object.create(null);\n ObjectsPropertyChangeListeners.set(this,objectPropertyChangeDescriptors);\n }\n if ( (keyChangeDescriptor = objectPropertyChangeDescriptors[key]) === void 0) {\n var propertyName = ObjectChangeDescriptorName.get(key);\n if(!propertyName) {\n propertyName = String(key);\n propertyName = propertyName && propertyName[0].toUpperCase() + propertyName.slice(1);\n ObjectChangeDescriptorName.set(key,propertyName);\n }\n return objectPropertyChangeDescriptors[key] = new ObjectChangeDescriptor(propertyName);\n }\n else return keyChangeDescriptor;\n};\n\nPropertyChanges.prototype.hasOwnPropertyChangeDescriptor = function (key) {\n var objectPropertyChangeDescriptors = ObjectsPropertyChangeListeners.get(this);\n if (!objectPropertyChangeDescriptors) {\n return false;\n }\n if (!key) {\n return true;\n }\n if (objectPropertyChangeDescriptors[key] === void 0) {\n return false;\n }\n return true;\n};\n\nPropertyChanges.prototype.addOwnPropertyChangeListener = function (key, listener, beforeChange) {\n if (this.makeObservable && !this.isObservable) {\n this.makeObservable(); // particularly for observable arrays, for\n // their length property\n }\n var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key),\n listeners = beforeChange ? descriptor.willChangeListeners : descriptor.changeListeners;\n\n PropertyChanges.makePropertyObservable(this, key);\n\n if(!listeners._current) {\n listeners._current = listener;\n }\n else if(!Array.isArray(listeners._current)) {\n listeners._current = [listeners._current,listener]\n }\n else {\n listeners._current.push(listener);\n }\n\n var self = this;\n return function cancelOwnPropertyChangeListener() {\n PropertyChanges.removeOwnPropertyChangeListener(self, key, listener, beforeChange);\n self = null;\n };\n};\n\nPropertyChanges.prototype.addBeforeOwnPropertyChangeListener = function (key, listener) {\n return PropertyChanges.addOwnPropertyChangeListener(this, key, listener, true);\n};\n\nPropertyChanges.prototype.removeOwnPropertyChangeListener = function removeOwnPropertyChangeListener(key, listener, beforeChange) {\n var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key);\n\n var listeners;\n if (beforeChange) {\n listeners = descriptor._willChangeListeners;\n } else {\n listeners = descriptor._changeListeners;\n }\n\n if(listeners) {\n if(listeners._current) {\n if(listeners._current === listener) {\n listeners._current = null;\n }\n else {\n\n var index = listeners._current.lastIndexOf(listener);\n if (index === -1) {\n throw new Error(\"Can't remove property change listener: does not exist: property name\" + JSON.stringify(key));\n }\n if(descriptor.isActive) {\n listeners.ghostCount = listeners.ghostCount+1;\n listeners._current[index]=removeOwnPropertyChangeListener.ListenerGhost;\n }\n else {\n listeners._current.spliceOne(index);\n }\n }\n }\n }\n};\nPropertyChanges.prototype.removeOwnPropertyChangeListener.ListenerGhost = ListenerGhost;\n\nPropertyChanges.prototype.removeBeforeOwnPropertyChangeListener = function (key, listener) {\n return PropertyChanges.removeOwnPropertyChangeListener(this, key, listener, true);\n};\n\nPropertyChanges.prototype.dispatchOwnPropertyChange = function dispatchOwnPropertyChange(key, value, beforeChange) {\n var descriptor = PropertyChanges.getOwnPropertyChangeDescriptor(this, key),\n listeners;\n\n if (!descriptor.isActive) {\n descriptor.isActive = true;\n listeners = beforeChange ? descriptor._willChangeListeners: descriptor._changeListeners;\n try {\n dispatchOwnPropertyChange.dispatchEach(listeners, key, value, this);\n } finally {\n descriptor.isActive = false;\n }\n }\n};\nPropertyChanges.prototype.dispatchOwnPropertyChange.dispatchEach = dispatchEach;\n\nfunction dispatchEach(listeners, key, value, object) {\n if(listeners && listeners._current) {\n // copy snapshot of current listeners to active listeners\n var current,\n listener,\n i,\n countI,\n thisp,\n specificHandlerMethodName = listeners.specificHandlerMethodName,\n genericHandlerMethodName = listeners.genericHandlerMethodName,\n Ghost = ListenerGhost;\n\n if(Array.isArray(listeners._current)) {\n //removeGostListenersIfNeeded returns listeners.current or a new filtered one when conditions are met\n current = listeners.removeCurrentGostListenersIfNeeded();\n //We use a for to guarantee we won't dispatch to listeners that would be added after we started\n for(i=0, countI = current.length;i<countI;i++) {\n if ((thisp = current[i]) !== Ghost) {\n //This is fixing the issue causing a regression in Montage's repetition\n listener = (\n thisp[specificHandlerMethodName] ||\n thisp[genericHandlerMethodName] ||\n thisp\n );\n if (!listener.call) {\n throw new Error(\"No event listener for \" + listeners.specificHandlerName + \" or \" + listeners.genericHandlerName + \" or call on \" + listener);\n }\n listener.call(thisp, value, key, object);\n }\n }\n }\n else {\n thisp = listeners._current;\n listener = (\n thisp[specificHandlerMethodName] ||\n thisp[genericHandlerMethodName] ||\n thisp\n );\n if (!listener.call) {\n throw new Error(\"No event listener for \" + listeners.specificHandlerName + \" or \" + listeners.genericHandlerName + \" or call on \" + listener);\n }\n listener.call(thisp, value, key, object);\n }\n\n }\n}\n\ndispatchEach.ListenerGhost = ListenerGhost;\n\n\nPropertyChanges.prototype.dispatchBeforeOwnPropertyChange = function (key, listener) {\n return PropertyChanges.dispatchOwnPropertyChange(this, key, listener, true);\n};\n\nvar ObjectsOverriddenPropertyDescriptors = new WeakMap(),\n Objects__state__ = new WeakMap(),\n propertyListener = {\n get: void 0,\n set: void 0,\n configurable: true,\n enumerable: false\n };\n\nPropertyChanges.prototype.makePropertyObservable = function (key) {\n // arrays are special. we do not support direct setting of properties\n // on an array. instead, call .set(index, value). this is observable.\n // 'length' property is observable for all mutating methods because\n // our overrides explicitly dispatch that change.\n\n\n var overriddenPropertyDescriptors = ObjectsOverriddenPropertyDescriptors.get(this);\n if (overriddenPropertyDescriptors && overriddenPropertyDescriptors.get(key) !== void 0) {\n // if we have already recorded an overridden property descriptor,\n // we have already installed the observer, so short-here\n return;\n }\n\n // memoize overridden property descriptor table\n if (!overriddenPropertyDescriptors) {\n if (Array.isArray(this)) {\n return;\n }\n if (!Object.isExtensible(this)) {\n throw new Error(\"Can't make property \" + JSON.stringify(key) + \" observable on \" + this + \" because object is not extensible\");\n }\n overriddenPropertyDescriptors = new Map();\n ObjectsOverriddenPropertyDescriptors.set(this,overriddenPropertyDescriptors);\n }\n\n // var state = Objects__state__.get(this);\n // if (typeof state !== \"object\") {\n // Objects__state__.set(this,(state = {}));\n // }\n // state[key] = this[key];\n\n\n\n // walk up the prototype chain to find a property descriptor for\n // the property name\n var overriddenDescriptor;\n var attached = this;\n do {\n overriddenDescriptor = Object.getOwnPropertyDescriptor(attached, key);\n if (overriddenDescriptor) {\n break;\n }\n attached = Object.getPrototypeOf(attached);\n } while (attached);\n // or default to an undefined value\n if (!overriddenDescriptor) {\n overriddenDescriptor = {\n value: void 0,\n enumerable: true,\n writable: true,\n configurable: true\n };\n } else {\n if (!overriddenDescriptor.configurable) {\n return;\n }\n if (!overriddenDescriptor.writable && !overriddenDescriptor.set) {\n return;\n }\n }\n\n // memoize the descriptor so we know not to install another layer,\n // and so we can reuse the overridden descriptor when uninstalling\n overriddenPropertyDescriptors.set(key,overriddenDescriptor);\n\n\n // TODO reflect current value on a displayed property\n\n // in both of these new descriptor variants, we reuse the overridden\n // descriptor to either store the current value or apply getters\n // and setters. this is handy since we can reuse the overridden\n // descriptor if we uninstall the observer. We even preserve the\n // assignment semantics, where we get the value from up the\n // prototype chain, and set as an owned property.\n if ('value' in overriddenDescriptor) {\n propertyListener.get = function dispatchingGetter() {\n return dispatchingGetter.overriddenDescriptor.value;\n };\n propertyListener.set = function dispatchingSetter(value) {\n var descriptor,\n isActive,\n overriddenDescriptor = dispatchingSetter.overriddenDescriptor;\n\n if (value !== overriddenDescriptor.value) {\n if (!(isActive = (descriptor = dispatchingSetter.descriptor).isActive)) {\n descriptor.isActive = true;\n try {\n dispatchingSetter.dispatchEach(descriptor._willChangeListeners, dispatchingSetter.key, overriddenDescriptor.value, this);\n } finally {}\n }\n overriddenDescriptor.value = value;\n if (!isActive) {\n try {\n dispatchingSetter.dispatchEach(descriptor._changeListeners, dispatchingSetter.key, value, this);\n } finally {\n descriptor.isActive = false;\n }\n }\n }\n };\n propertyListener.set.dispatchEach = dispatchEach;\n propertyListener.set.key = key;\n propertyListener.get.overriddenDescriptor = propertyListener.set.overriddenDescriptor = overriddenDescriptor;\n propertyListener.set.descriptor = ObjectsPropertyChangeListeners.get(this)[key];\n\n propertyListener.enumerable = overriddenDescriptor.enumerable;\n\n propertyListener.configurable = true\n\n } else { // 'get' or 'set', but not necessarily both\n propertyListener.get = overriddenDescriptor.get;\n propertyListener.set = function dispatchingSetter() {\n var formerValue = dispatchingSetter.overriddenGetter.call(this),\n descriptor,\n isActive,\n newValue;\n\n\n if(arguments.length === 1) {\n dispatchingSetter.overriddenSetter.call(this,arguments[0]);\n }\n else if(arguments.length === 2) {\n dispatchingSetter.overriddenSetter.call(this,arguments[0],arguments[1]);\n }\n else {\n dispatchingSetter.overriddenSetter.apply(this, arguments);\n }\n\n if ((newValue = dispatchingSetter.overriddenGetter.call(this)) !== formerValue) {\n descriptor = dispatchingSetter.descriptor;\n if (!(isActive = descriptor.isActive)) {\n descriptor.isActive = true;\n try {\n dispatchingSetter.dispatchEach(descriptor._willChangeListeners, key, formerValue, this);\n } finally {}\n }\n if (!isActive) {\n try {\n dispatchingSetter.dispatchEach(descriptor._changeListeners, key, newValue, this);\n } finally {\n descriptor.isActive = false;\n }\n }\n }\n };\n propertyListener.enumerable = overriddenDescriptor.enumerable;\n propertyListener.configurable = true;\n propertyListener.set.dispatchEach = dispatchEach;\n propertyListener.set.overriddenSetter = overriddenDescriptor.set;\n propertyListener.set.overriddenGetter = overriddenDescriptor.get;\n propertyListener.set.descriptor = ObjectsPropertyChangeListeners.get(this)[key];\n }\n\n Object.defineProperty(this, key, propertyListener);\n};\n\n// constructor functions\n\nPropertyChanges.getOwnPropertyChangeDescriptor = function (object, key) {\n if (object.getOwnPropertyChangeDescriptor) {\n return object.getOwnPropertyChangeDescriptor(key);\n } else {\n return PropertyChanges.prototype.getOwnPropertyChangeDescriptor.call(object, key);\n }\n};\n\nPropertyChanges.hasOwnPropertyChangeDescriptor = function (object, key) {\n if (object.hasOwnPropertyChangeDescriptor) {\n return object.hasOwnPropertyChangeDescriptor(key);\n } else {\n return PropertyChanges.prototype.hasOwnPropertyChangeDescriptor.call(object, key);\n }\n};\n\nPropertyChanges.addOwnPropertyChangeListener = function (object, key, listener, beforeChange) {\n if (Object.isObject(object)) {\n return object.addOwnPropertyChangeListener\n ? object.addOwnPropertyChangeListener(key, listener, beforeChange)\n : this.prototype.addOwnPropertyChangeListener.call(object, key, listener, beforeChange);\n }\n};\n\nPropertyChanges.removeOwnPropertyChangeListener = function (object, key, listener, beforeChange) {\n if (!Object.isObject(object)) {\n } else if (object.removeOwnPropertyChangeListener) {\n return object.removeOwnPropertyChangeListener(key, listener, beforeChange);\n } else {\n return PropertyChanges.prototype.removeOwnPropertyChangeListener.call(object, key, listener, beforeChange);\n }\n};\n\nPropertyChanges.dispatchOwnPropertyChange = function (object, key, value, beforeChange) {\n if (!Object.isObject(object)) {\n } else if (object.dispatchOwnPropertyChange) {\n return object.dispatchOwnPropertyChange(key, value, beforeChange);\n } else {\n return PropertyChanges.prototype.dispatchOwnPropertyChange.call(object, key, value, beforeChange);\n }\n};\n\nPropertyChanges.addBeforeOwnPropertyChangeListener = function (object, key, listener) {\n return PropertyChanges.addOwnPropertyChangeListener(object, key, listener, true);\n};\n\nPropertyChanges.removeBeforeOwnPropertyChangeListener = function (object, key, listener) {\n return PropertyChanges.removeOwnPropertyChangeListener(object, key, listener, true);\n};\n\nPropertyChanges.dispatchBeforeOwnPropertyChange = function (object, key, value) {\n return PropertyChanges.dispatchOwnPropertyChange(object, key, value, true);\n};\n\nPropertyChanges.makePropertyObservable = function (object, key) {\n if (object.makePropertyObservable) {\n return object.makePropertyObservable(key);\n } else {\n return PropertyChanges.prototype.makePropertyObservable.call(object, key);\n }\n};\n","\"use strict\";\n\n//TODO:\n// Remove Dict and use native Map as much as possible here\n//Use ObjectChangeDescriptor to avoid creating useless arrays and benefit from similar gains made in property-changes\n\n\nvar WeakMap = require(\"../weak-map\"),\n Map = require(\"../_map\"),\n ChangeDescriptor = require(\"./change-descriptor\"),\n ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor,\n ChangeListenersRecord = ChangeDescriptor.ChangeListenersRecord,\n ListenerGhost = ChangeDescriptor.ListenerGhost;\n\nvar rangeChangeDescriptors = new WeakMap(); // {isActive, willChangeListeners, changeListeners}\n\n\n//\nfunction RangeChangeDescriptor(name) {\n this.name = name;\n this.isActive = false;\n this._willChangeListeners = null;\n this._changeListeners = null;\n};\n\nRangeChangeDescriptor.prototype = new ObjectChangeDescriptor();\nRangeChangeDescriptor.prototype.constructor = RangeChangeDescriptor;\n\nRangeChangeDescriptor.prototype.changeListenersRecordConstructor = RangeChangeListenersRecord;\nRangeChangeDescriptor.prototype.willChangeListenersRecordConstructor = RangeWillChangeListenersRecord;\nObject.defineProperty(RangeChangeDescriptor.prototype,\"active\",{\n get: function() {\n return this._active || (this._active = this._current ? this._current.slice():[]);\n }\n});\n\n\nvar RangeChangeListenersSpecificHandlerMethodName = new Map();\n\nfunction RangeChangeListenersRecord(name) {\n var specificHandlerMethodName = RangeChangeListenersSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name.slice(0, 1).toUpperCase();\n specificHandlerMethodName += name.slice(1);\n specificHandlerMethodName += \"RangeChange\";\n RangeChangeListenersSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n\treturn this;\n}\nRangeChangeListenersRecord.prototype = new ChangeListenersRecord();\nRangeChangeListenersRecord.prototype.constructor = RangeChangeListenersRecord;\n\nvar RangeWillChangeListenersSpecificHandlerMethodName = new Map();\n\nfunction RangeWillChangeListenersRecord(name) {\n var specificHandlerMethodName = RangeWillChangeListenersSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name.slice(0, 1).toUpperCase();\n specificHandlerMethodName += name.slice(1);\n specificHandlerMethodName += \"RangeWillChange\";\n RangeWillChangeListenersSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n return this;\n}\nRangeWillChangeListenersRecord.prototype = new ChangeListenersRecord();\nRangeWillChangeListenersRecord.prototype.constructor = RangeWillChangeListenersRecord;\n\nmodule.exports = RangeChanges;\nfunction RangeChanges() {\n throw new Error(\"Can't construct. RangeChanges is a mixin.\");\n}\n\nRangeChanges.prototype.getAllRangeChangeDescriptors = function () {\n if (!rangeChangeDescriptors.has(this)) {\n rangeChangeDescriptors.set(this, new Map());\n }\n return rangeChangeDescriptors.get(this);\n};\n\nRangeChanges.prototype.getRangeChangeDescriptor = function (token) {\n var tokenChangeDescriptors = this.getAllRangeChangeDescriptors();\n token = token || \"\";\n if (!tokenChangeDescriptors.has(token)) {\n tokenChangeDescriptors.set(token, new RangeChangeDescriptor(token));\n }\n return tokenChangeDescriptors.get(token);\n};\n\nvar ObjectsDispatchesRangeChanges = new WeakMap(),\n dispatchesRangeChangesGetter = function() {\n return ObjectsDispatchesRangeChanges.get(this);\n },\n dispatchesRangeChangesSetter = function(value) {\n return ObjectsDispatchesRangeChanges.set(this,value);\n },\n dispatchesChangesMethodName = \"dispatchesRangeChanges\",\n dispatchesChangesPropertyDescriptor = {\n get: dispatchesRangeChangesGetter,\n set: dispatchesRangeChangesSetter,\n configurable: true,\n enumerable: false\n };\n\nRangeChanges.prototype.addRangeChangeListener = function addRangeChangeListener(listener, token, beforeChange) {\n // a concession for objects like Array that are not inherently observable\n if (!this.isObservable && this.makeObservable) {\n this.makeObservable();\n }\n\n var descriptor = this.getRangeChangeDescriptor(token);\n\n var listeners;\n if (beforeChange) {\n listeners = descriptor.willChangeListeners;\n } else {\n listeners = descriptor.changeListeners;\n }\n\n // even if already registered\n if(!listeners._current) {\n listeners._current = listener;\n }\n else if(!Array.isArray(listeners._current)) {\n listeners._current = [listeners._current,listener]\n }\n else {\n listeners._current.push(listener);\n }\n\n if(Object.getOwnPropertyDescriptor((this.__proto__||Object.getPrototypeOf(this)),dispatchesChangesMethodName) === void 0) {\n Object.defineProperty((this.__proto__||Object.getPrototypeOf(this)), dispatchesChangesMethodName, dispatchesChangesPropertyDescriptor);\n }\n this.dispatchesRangeChanges = true;\n\n var self = this;\n return function cancelRangeChangeListener() {\n if (!self) {\n // TODO throw new Error(\"Range change listener \" + JSON.stringify(token) + \" has already been canceled\");\n return;\n }\n self.removeRangeChangeListener(listener, token, beforeChange);\n self = null;\n };\n};\n\n\nRangeChanges.prototype.removeRangeChangeListener = function (listener, token, beforeChange) {\n var descriptor = this.getRangeChangeDescriptor(token);\n\n var listeners;\n if (beforeChange) {\n listeners = descriptor._willChangeListeners;\n } else {\n listeners = descriptor._changeListeners;\n }\n\n if(listeners._current) {\n if(listeners._current === listener) {\n listeners._current = null;\n }\n else {\n var index = listeners._current.lastIndexOf(listener);\n if (index === -1) {\n throw new Error(\"Can't remove range change listener: does not exist: token \" + JSON.stringify(token));\n }\n else {\n if(descriptor.isActive) {\n listeners.ghostCount = listeners.ghostCount+1\n listeners._current[index]=ListenerGhost\n }\n else {\n listeners._current.spliceOne(index);\n }\n }\n }\n }\n\n};\n\nRangeChanges.prototype.dispatchRangeChange = function (plus, minus, index, beforeChange) {\n var descriptors = this.getAllRangeChangeDescriptors(),\n descriptor,\n mapIter = descriptors.values(),\n listeners,\n tokenName,\n i,\n countI,\n listener,\n currentListeners,\n Ghost;\n\n descriptors.dispatchBeforeChange = beforeChange;\n\n while (descriptor = mapIter.next().value) {\n\n if (descriptor.isActive) {\n return;\n }\n\n // before or after\n listeners = beforeChange ? descriptor._willChangeListeners : descriptor._changeListeners;\n if(listeners && listeners._current) {\n tokenName = listeners.specificHandlerMethodName;\n if(Array.isArray(listeners._current)) {\n if(listeners._current.length) {\n // notably, defaults to \"handleRangeChange\" or \"handleRangeWillChange\"\n // if token is \"\" (the default)\n\n descriptor.isActive = true;\n // dispatch each listener\n try {\n //removeGostListenersIfNeeded returns listeners.current or a new filtered one when conditions are met\n currentListeners = listeners.removeCurrentGostListenersIfNeeded();\n Ghost = ListenerGhost;\n for(i=0, countI = currentListeners.length;i<countI;i++) {\n if ((listener = currentListeners[i]) !== Ghost) {\n if (listener[tokenName]) {\n listener[tokenName](plus, minus, index, this, beforeChange);\n } else if (listener.call) {\n listener.call(this, plus, minus, index, this, beforeChange);\n } else {\n throw new Error(\"Handler \" + listener + \" has no method \" + tokenName + \" and is not callable\");\n }\n }\n }\n } finally {\n descriptor.isActive = false;\n }\n }\n }\n else {\n descriptor.isActive = true;\n // dispatch each listener\n try {\n listener = listeners._current;\n if (listener[tokenName]) {\n listener[tokenName](plus, minus, index, this, beforeChange);\n } else if (listener.call) {\n listener.call(this, plus, minus, index, this, beforeChange);\n } else {\n throw new Error(\"Handler \" + listener + \" has no method \" + tokenName + \" and is not callable\");\n }\n } finally {\n descriptor.isActive = false;\n }\n\n }\n }\n\n }\n};\n\nRangeChanges.prototype.addBeforeRangeChangeListener = function (listener, token) {\n return this.addRangeChangeListener(listener, token, true);\n};\n\nRangeChanges.prototype.removeBeforeRangeChangeListener = function (listener, token) {\n return this.removeRangeChangeListener(listener, token, true);\n};\n\nRangeChanges.prototype.dispatchBeforeRangeChange = function (plus, minus, index) {\n return this.dispatchRangeChange(plus, minus, index, true);\n};\n","\"use strict\";\n\nmodule.exports = SortedSet;\n\nvar Shim = require(\"./shim\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericSet = require(\"./generic-set\");\nvar PropertyChanges = require(\"./listen/property-changes\");\nvar RangeChanges = require(\"./listen/range-changes\");\nvar TreeLog = require(\"./tree-log\");\n\nfunction SortedSet(values, equals, compare, getDefault) {\n if (!(this instanceof SortedSet)) {\n return new SortedSet(values, equals, compare, getDefault);\n }\n this.contentEquals = equals || Object.equals;\n this.contentCompare = compare || Object.compare;\n this.getDefault = getDefault || Function.noop;\n this.root = null;\n this.length = 0;\n this.addEach(values);\n}\n\n// hack so require(\"sorted-set\").SortedSet will work in MontageJS\nSortedSet.SortedSet = SortedSet;\n\nObject.addEach(SortedSet.prototype, GenericCollection.prototype);\nObject.addEach(SortedSet.prototype, GenericSet.prototype);\nObject.addEach(SortedSet.prototype, PropertyChanges.prototype);\nObject.addEach(SortedSet.prototype, RangeChanges.prototype);\nObject.defineProperty(SortedSet.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\nSortedSet.from = GenericCollection.from;\n\nSortedSet.prototype.isSorted = true;\n\nSortedSet.prototype.constructClone = function (values) {\n return new this.constructor(\n values,\n this.contentEquals,\n this.contentCompare,\n this.getDefault\n );\n};\n\nSortedSet.prototype.has = function (value, equals) {\n if (equals) {\n throw new Error(\"SortedSet#has does not support second argument: equals\");\n }\n if (this.root) {\n this.splay(value);\n return this.contentEquals(value, this.root.value);\n } else {\n return false;\n }\n};\n\nSortedSet.prototype.get = function (value, equals) {\n if (equals) {\n throw new Error(\"SortedSet#get does not support second argument: equals\");\n }\n if (this.root) {\n this.splay(value);\n if (this.contentEquals(value, this.root.value)) {\n return this.root.value;\n }\n }\n return this.getDefault(value);\n};\n\nSortedSet.prototype.add = function (value) {\n var node = new this.Node(value);\n if (this.root) {\n this.splay(value);\n if (!this.contentEquals(value, this.root.value)) {\n var comparison = this.contentCompare(value, this.root.value);\n if (comparison === 0) {\n throw new Error(\"SortedSet cannot contain incomparable but inequal values: \" + value + \" and \" + this.root.value);\n }\n if (this.dispatchesRangeChanges) {\n this.dispatchBeforeRangeChange([value], [], this.root.index);\n }\n if (comparison < 0) {\n // rotate right\n // R N\n // / \\ -> / \\\n // l r l R\n // : : : \\\n // r\n // :\n node.right = this.root;\n node.left = this.root.left;\n this.root.left = null;\n this.root.touch();\n } else {\n // rotate left\n // R N\n // / \\ -> / \\\n // l r R r\n // : : / :\n // l\n // :\n node.left = this.root;\n node.right = this.root.right;\n this.root.right = null;\n this.root.touch();\n }\n node.touch();\n this.root = node;\n this.length++;\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange([value], [], this.root.index);\n }\n return true;\n }\n } else {\n if (this.dispatchesRangeChanges) {\n this.dispatchBeforeRangeChange([value], [], 0);\n }\n this.root = node;\n this.length++;\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange([value], [], 0);\n }\n return true;\n }\n return false;\n};\n\nSortedSet.prototype['delete'] = function (value, equals) {\n if (equals) {\n throw new Error(\"SortedSet#delete does not support second argument: equals\");\n }\n if (this.root) {\n this.splay(value);\n if (this.contentEquals(value, this.root.value)) {\n var index = this.root.index;\n if (this.dispatchesRangeChanges) {\n this.dispatchBeforeRangeChange([], [value], index);\n }\n if (!this.root.left) {\n this.root = this.root.right;\n } else {\n // remove the right side of the tree,\n var right = this.root.right;\n this.root = this.root.left;\n // the tree now only contains the left side of the tree, so all\n // values are less than the value deleted.\n // splay so that the root has an empty right child\n this.splay(value);\n // put the right side of the tree back\n this.root.right = right;\n }\n this.length--;\n if (this.root) {\n this.root.touch();\n }\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange([], [value], index);\n }\n return true;\n }\n }\n return false;\n};\n\nSortedSet.prototype.indexOf = function (value, index) {\n if (index) {\n throw new Error(\"SortedSet#indexOf does not support second argument: startIndex\");\n }\n if (this.root) {\n this.splay(value);\n if (this.contentEquals(value, this.root.value)) {\n return this.root.index;\n }\n }\n return -1;\n};\n\nSortedSet.prototype.find = function (value, equals, index) {\n if (equals) {\n throw new Error(\"SortedSet#find does not support second argument: equals\");\n }\n if (index) {\n // TODO contemplate using splayIndex to isolate a subtree in\n // which to search.\n throw new Error(\"SortedSet#find does not support third argument: index\");\n }\n if (this.root) {\n this.splay(value);\n if (this.contentEquals(value, this.root.value)) {\n return this.root;\n }\n }\n};\n\nSortedSet.prototype.findGreatest = function (at) {\n if (this.root) {\n at = at || this.root;\n while (at.right) {\n at = at.right;\n }\n return at;\n }\n};\n\nSortedSet.prototype.findLeast = function (at) {\n if (this.root) {\n at = at || this.root;\n while (at.left) {\n at = at.left;\n }\n return at;\n }\n};\n\nSortedSet.prototype.findGreatestLessThanOrEqual = function (value) {\n if (this.root) {\n this.splay(value);\n if (this.contentCompare(this.root.value, value) > 0) {\n return this.root.getPrevious();\n } else {\n return this.root;\n }\n }\n};\n\nSortedSet.prototype.findGreatestLessThan = function (value) {\n if (this.root) {\n this.splay(value);\n if (this.contentCompare(this.root.value, value) >= 0) {\n return this.root.getPrevious();\n } else {\n return this.root;\n }\n }\n};\n\nSortedSet.prototype.findLeastGreaterThanOrEqual = function (value) {\n if (this.root) {\n this.splay(value);\n if (this.contentCompare(this.root.value, value) >= 0) {\n return this.root;\n } else {\n return this.root.getNext();\n }\n }\n};\n\nSortedSet.prototype.findLeastGreaterThan = function (value) {\n if (this.root) {\n this.splay(value);\n if (this.contentCompare(this.root.value, value) <= 0) {\n return this.root.getNext();\n } else {\n return this.root;\n }\n }\n};\n\nSortedSet.prototype.pop = function () {\n if (this.root) {\n var found = this.findGreatest();\n this[\"delete\"](found.value);\n return found.value;\n }\n};\n\nSortedSet.prototype.shift = function () {\n if (this.root) {\n var found = this.findLeast();\n this[\"delete\"](found.value);\n return found.value;\n }\n};\n\nSortedSet.prototype.push = function () {\n this.addEach(arguments);\n};\n\nSortedSet.prototype.unshift = function () {\n this.addEach(arguments);\n};\n\nSortedSet.prototype.slice = function (start, end) {\n var temp;\n start = start || 0;\n end = end || this.length;\n if (start < 0) {\n start += this.length;\n }\n if (end < 0) {\n end += this.length;\n }\n var sliced = [];\n if (this.root) {\n this.splayIndex(start);\n while (this.root.index < end) {\n sliced.push(this.root.value);\n if (!this.root.right) {\n break;\n }\n this.splay(this.root.getNext().value);\n }\n }\n return sliced;\n};\n\nSortedSet.prototype.splice = function (at, length /*...plus*/) {\n return this.swap(at, length, Array.prototype.slice.call(arguments, 2));\n};\n\nSortedSet.prototype.swap = function (start, length, plus) {\n if (start === undefined && length === undefined) {\n return [];\n }\n start = start || 0;\n if (start < 0) {\n start += this.length;\n }\n if (length === undefined) {\n length = Infinity;\n }\n var swapped = [];\n\n if (this.root) {\n\n // start\n this.splayIndex(start);\n\n // minus length\n for (var i = 0; i < length; i++) {\n swapped.push(this.root.value);\n var next = this.root.getNext();\n this[\"delete\"](this.root.value);\n if (!next) {\n break;\n }\n this.splay(next.value);\n }\n }\n\n // plus\n this.addEach(plus);\n\n return swapped;\n};\n\n// This is the simplified top-down splaying algorithm from: \"Self-adjusting\n// Binary Search Trees\" by Sleator and Tarjan. Guarantees that root.value\n// equals value if value exists. If value does not exist, then root will be\n// the node whose value either immediately preceeds or immediately follows value.\n// - as described in https://github.com/hij1nx/forest\nSortedSet.prototype.splay = function (value) {\n var stub, left, right, temp, root, history;\n\n if (!this.root) {\n return;\n }\n\n // Create a stub node. The use of the stub node is a bit\n // counter-intuitive: The right child of the stub node will hold the L tree\n // of the algorithm. The left child of the stub node will hold the R tree\n // of the algorithm. Using a stub node, left and right will always be\n // nodes and we avoid special cases.\n // - http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/splay-tree-inl.h\n stub = left = right = new this.Node();\n // The history is an upside down tree used to propagate new tree sizes back\n // up the left and right arms of a traversal. The right children of the\n // transitive left side of the tree will be former roots while linking\n // left. The left children of the transitive walk to the right side of the\n // history tree will all be previous roots from linking right. The last\n // node of the left and right traversal will each become a child of the new\n // root.\n history = new this.Node();\n root = this.root;\n\n while (true) {\n var comparison = this.contentCompare(value, root.value);\n if (comparison < 0) {\n if (root.left) {\n if (this.contentCompare(value, root.left.value) < 0) {\n // rotate right\n // Root L(temp)\n // / \\ / \\\n // L(temp) R LL Root\n // / \\ / \\\n // LL LR LR R\n temp = root.left;\n root.left = temp.right;\n root.touch();\n temp.right = root;\n temp.touch();\n root = temp;\n if (!root.left) {\n break;\n }\n }\n // remember former root for repropagating length\n temp = new Node();\n temp.right = root;\n temp.left = history.left;\n history.left = temp;\n // link left\n right.left = root;\n right.touch();\n right = root;\n root = root.left;\n } else {\n break;\n }\n } else if (comparison > 0) {\n if (root.right) {\n if (this.contentCompare(value, root.right.value) > 0) {\n // rotate left\n // Root L(temp)\n // / \\ / \\\n // L(temp) R LL Root\n // / \\ / \\\n // LL LR LR R\n temp = root.right;\n root.right = temp.left;\n root.touch();\n temp.left = root;\n temp.touch();\n root = temp;\n if (!root.right) {\n break;\n }\n }\n // remember former root for repropagating length\n temp = new Node();\n temp.left = root;\n temp.right = history.right;\n history.right = temp;\n // link right\n left.right = root;\n left.touch();\n left = root;\n root = root.right;\n } else {\n break;\n }\n } else { // equal or incomparable\n break;\n }\n }\n\n // reassemble\n left.right = root.left;\n left.touch();\n right.left = root.right;\n right.touch();\n root.left = stub.right;\n root.right = stub.left;\n\n // propagate new lengths\n while (history.left) {\n history.left.right.touch();\n history.left = history.left.left;\n }\n while (history.right) {\n history.right.left.touch();\n history.right = history.right.right;\n }\n root.touch();\n\n this.root = root;\n};\n\n// an internal utility for splaying a node based on its index\nSortedSet.prototype.splayIndex = function (index) {\n if (this.root) {\n var at = this.root;\n var atIndex = this.root.index;\n\n while (atIndex !== index) {\n if (atIndex > index && at.left) {\n at = at.left;\n atIndex -= 1 + (at.right ? at.right.length : 0);\n } else if (atIndex < index && at.right) {\n at = at.right;\n atIndex += 1 + (at.left ? at.left.length : 0);\n } else {\n break;\n }\n }\n\n this.splay(at.value);\n\n return this.root.index === index;\n }\n return false;\n};\n\nSortedSet.prototype.reduce = function (callback, basis, thisp) {\n if (this.root) {\n basis = this.root.reduce(callback, basis, 0, thisp, this);\n }\n return basis;\n};\n\nSortedSet.prototype.reduceRight = function (callback, basis, thisp) {\n if (this.root) {\n basis = this.root.reduceRight(callback, basis, this.length - 1, thisp, this);\n }\n return basis;\n};\n\nSortedSet.prototype.min = function (at) {\n var least = this.findLeast(at);\n if (least) {\n return least.value;\n }\n};\n\nSortedSet.prototype.max = function (at) {\n var greatest = this.findGreatest(at);\n if (greatest) {\n return greatest.value;\n }\n};\n\nSortedSet.prototype.one = function () {\n return this.min();\n};\n\nSortedSet.prototype.clear = function () {\n var minus;\n if (this.dispatchesRangeChanges) {\n minus = this.toArray();\n this.dispatchBeforeRangeChange([], minus, 0);\n }\n this.root = null;\n this.length = 0;\n if (this.dispatchesRangeChanges) {\n this.dispatchRangeChange([], minus, 0);\n }\n};\n\nSortedSet.prototype.iterate = function (start, end) {\n return new this.Iterator(this, start, end);\n};\n\nSortedSet.prototype.Iterator = Iterator;\n\nSortedSet.prototype.summary = function () {\n if (this.root) {\n return this.root.summary();\n } else {\n return \"()\";\n }\n};\n\nSortedSet.prototype.log = function (charmap, logNode, callback, thisp) {\n charmap = charmap || TreeLog.unicodeRound;\n logNode = logNode || this.logNode;\n if (!callback) {\n callback = console.log;\n thisp = console;\n }\n callback = callback.bind(thisp);\n if (this.root) {\n this.root.log(charmap, logNode, callback, callback);\n }\n};\n\nSortedSet.prototype.logNode = function (node, log, logBefore) {\n log(\" \" + node.value);\n};\n\nSortedSet.logCharsets = TreeLog;\n\nSortedSet.prototype.Node = Node;\n\nfunction Node(value) {\n this.value = value;\n this.left = null;\n this.right = null;\n this.length = 1;\n}\n\n// TODO case where no basis is provided for reduction\n\nNode.prototype.reduce = function (callback, basis, index, thisp, tree, depth) {\n depth = depth || 0;\n if (this.left) {\n // prerecord length to be resistant to mutation\n var length = this.left.length;\n basis = this.left.reduce(callback, basis, index, thisp, tree, depth + 1);\n index += length;\n }\n basis = callback.call(thisp, basis, this.value, index, tree, this, depth);\n index += 1;\n if (this.right) {\n basis = this.right.reduce(callback, basis, index, thisp, tree, depth + 1);\n }\n return basis;\n};\n\nNode.prototype.reduceRight = function (callback, basis, index, thisp, tree, depth) {\n depth = depth || 0;\n if (this.right) {\n basis = this.right.reduceRight(callback, basis, index, thisp, tree, depth + 1);\n index -= this.right.length;\n }\n basis = callback.call(thisp, basis, this.value, this.value, tree, this, depth);\n index -= 1;\n if (this.left) {\n basis = this.left.reduceRight(callback, basis, index, thisp, tree, depth + 1);\n }\n return basis;\n};\n\nNode.prototype.touch = function () {\n this.length = 1 +\n (this.left ? this.left.length : 0) +\n (this.right ? this.right.length : 0);\n this.index = this.left ? this.left.length : 0;\n};\n\nNode.prototype.checkIntegrity = function () {\n var length = 1;\n length += this.left ? this.left.checkIntegrity() : 0;\n length += this.right ? this.right.checkIntegrity() : 0;\n if (this.length !== length)\n throw new Error(\"Integrity check failed: \" + this.summary());\n return length;\n}\n\n// get the next node in this subtree\nNode.prototype.getNext = function () {\n var node = this;\n if (node.right) {\n node = node.right;\n while (node.left) {\n node = node.left;\n }\n return node;\n }\n};\n\n// get the previous node in this subtree\nNode.prototype.getPrevious = function () {\n var node = this;\n if (node.left) {\n node = node.left;\n while (node.right) {\n node = node.right;\n }\n return node;\n }\n};\n\nNode.prototype.summary = function () {\n var value = this.value || \"-\";\n value += \" <\" + this.length;\n if (!this.left && !this.right) {\n return \"(\" + value + \")\";\n }\n return \"(\" + value + \" \" + (\n this.left ? this.left.summary() : \"()\"\n ) + \", \" + (\n this.right ? this.right.summary() : \"()\"\n ) + \")\";\n};\n\nNode.prototype.log = function (charmap, logNode, log, logAbove) {\n var self = this;\n\n var branch;\n if (this.left && this.right) {\n branch = charmap.intersection;\n } else if (this.left) {\n branch = charmap.branchUp;\n } else if (this.right) {\n branch = charmap.branchDown;\n } else {\n branch = charmap.through;\n }\n\n var loggedAbove;\n this.left && this.left.log(\n charmap,\n logNode,\n function innerWrite(line) {\n if (!loggedAbove) {\n loggedAbove = true;\n // leader\n logAbove(charmap.fromBelow + charmap.through + line);\n } else {\n // below\n logAbove(charmap.strafe + \" \" + line);\n }\n },\n function innerWriteAbove(line) {\n // above\n logAbove(\" \" + line);\n }\n );\n\n var loggedOn;\n logNode(\n this,\n function innerWrite(line) {\n if (!loggedOn) {\n loggedOn = true;\n log(branch + line);\n } else {\n log((self.right ? charmap.strafe : \" \") + line);\n }\n },\n function innerWriteAbove(line) {\n logAbove((self.left ? charmap.strafe : \" \") + line);\n }\n );\n\n var loggedBelow;\n this.right && this.right.log(\n charmap,\n logNode,\n function innerWrite(line) {\n if (!loggedBelow) {\n loggedBelow = true;\n log(charmap.fromAbove + charmap.through + line);\n } else {\n log(\" \" + line);\n }\n },\n function innerWriteAbove(line) {\n log(charmap.strafe + \" \" + line);\n }\n );\n};\n\nfunction Iterator(set, start, end) {\n this.set = set;\n this.prev = null;\n this.end = end;\n if (start) {\n var next = this.set.findLeastGreaterThanOrEqual(start);\n if (next) {\n this.set.splay(next.value);\n this.prev = next.getPrevious();\n }\n }\n}\nIterator.prototype.__iterationObject = null;\nObject.defineProperty(Iterator.prototype,\"_iterationObject\", {\n get: function() {\n return this.__iterationObject || (this.__iterationObject = { done: false, value:null});\n }\n});\n\nIterator.prototype.next = function () {\n var next;\n if (this.prev) {\n next = this.set.findLeastGreaterThan(this.prev.value);\n } else {\n next = this.set.findLeast();\n }\n if (!next) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n else {\n if (\n this.end !== undefined &&\n this.set.contentCompare(next.value, this.end) >= 0\n ) {\n this._iterationObject.done = true;\n this._iterationObject.value = void 0;\n }\n else {\n this.prev = next;\n this._iterationObject.value = next.value;\n }\n\n }\n return this._iterationObject;\n};\n","\"use strict\";\n\nvar WeakMap = require(\"../weak-map\"),\n Map = require(\"../_map\"),\n ChangeDescriptor = require(\"./change-descriptor\"),\n ObjectChangeDescriptor = ChangeDescriptor.ObjectChangeDescriptor,\n ChangeListenersRecord = ChangeDescriptor.ChangeListenersRecord,\n ListenerGhost = ChangeDescriptor.ListenerGhost;\n\nmodule.exports = MapChanges;\nfunction MapChanges() {\n throw new Error(\"Can't construct. MapChanges is a mixin.\");\n}\n\nvar object_owns = Object.prototype.hasOwnProperty;\n\n/*\n Object map change descriptors carry information necessary for adding,\n removing, dispatching, and shorting events to listeners for map changes\n for a particular key on a particular object. These descriptors are used\n here for shallow map changes.\n\n {\n willChangeListeners:Array(Fgunction)\n changeListeners:Array(Function)\n }\n*/\n\nvar mapChangeDescriptors = new WeakMap();\n\nfunction MapChangeDescriptor(name) {\n this.name = name;\n this.isActive = false;\n this._willChangeListeners = null;\n this._changeListeners = null;\n};\n\nMapChangeDescriptor.prototype = new ObjectChangeDescriptor();\nMapChangeDescriptor.prototype.constructor = MapChangeDescriptor;\n\nMapChangeDescriptor.prototype.changeListenersRecordConstructor = MapChangeListenersRecord;\nMapChangeDescriptor.prototype.willChangeListenersRecordConstructor = MapWillChangeListenersRecord;\n\nvar MapChangeListenersSpecificHandlerMethodName = new Map();\n\nfunction MapChangeListenersRecord(name) {\n var specificHandlerMethodName = MapChangeListenersSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name.slice(0, 1).toUpperCase();\n specificHandlerMethodName += name.slice(1);\n specificHandlerMethodName += \"MapChange\";\n MapChangeListenersSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n\treturn this;\n}\nMapChangeListenersRecord.prototype = new ChangeListenersRecord();\nMapChangeListenersRecord.prototype.constructor = MapChangeListenersRecord;\nMapChangeListenersRecord.prototype.genericHandlerMethodName = \"handleMapChange\";\n\nvar MapWillChangeListenersSpecificHandlerMethodName = new Map();\n\nfunction MapWillChangeListenersRecord(name) {\n var specificHandlerMethodName = MapWillChangeListenersSpecificHandlerMethodName.get(name);\n if(!specificHandlerMethodName) {\n specificHandlerMethodName = \"handle\";\n specificHandlerMethodName += name.slice(0, 1).toUpperCase();\n specificHandlerMethodName += name.slice(1);\n specificHandlerMethodName += \"MapWillChange\";\n MapWillChangeListenersSpecificHandlerMethodName.set(name,specificHandlerMethodName);\n }\n this.specificHandlerMethodName = specificHandlerMethodName;\n return this;\n}\nMapWillChangeListenersRecord.prototype = new ChangeListenersRecord();\nMapWillChangeListenersRecord.prototype.constructor = MapWillChangeListenersRecord;\nMapWillChangeListenersRecord.prototype.genericHandlerMethodName = \"handleMapWillChange\";\n\n\nMapChanges.prototype.getAllMapChangeDescriptors = function () {\n if (!mapChangeDescriptors.has(this)) {\n mapChangeDescriptors.set(this, new Map());\n }\n return mapChangeDescriptors.get(this);\n};\n\nMapChanges.prototype.getMapChangeDescriptor = function (token) {\n var tokenChangeDescriptors = this.getAllMapChangeDescriptors();\n token = token || \"\";\n if (!tokenChangeDescriptors.has(token)) {\n tokenChangeDescriptors.set(token, new MapChangeDescriptor(token));\n }\n return tokenChangeDescriptors.get(token);\n};\n\nvar ObjectsDispatchesMapChanges = new WeakMap(),\n dispatchesMapChangesGetter = function() {\n return ObjectsDispatchesMapChanges.get(this);\n },\n dispatchesMapChangesSetter = function(value) {\n return ObjectsDispatchesMapChanges.set(this,value);\n },\n dispatchesChangesMethodName = \"dispatchesMapChanges\",\n dispatchesChangesPropertyDescriptor = {\n get: dispatchesMapChangesGetter,\n set: dispatchesMapChangesSetter,\n configurable: true,\n enumerable: false\n };\n\nMapChanges.prototype.addMapChangeListener = function addMapChangeListener(listener, token, beforeChange) {\n //console.log(\"this:\",this,\" addMapChangeListener(\",listener,\",\",token,\",\",beforeChange);\n\n if (!this.isObservable && this.makeObservable) {\n // for Array\n this.makeObservable();\n }\n var descriptor = this.getMapChangeDescriptor(token);\n var listeners;\n if (beforeChange) {\n listeners = descriptor.willChangeListeners;\n } else {\n listeners = descriptor.changeListeners;\n }\n\n // console.log(\"addMapChangeListener()\",listener, token);\n //console.log(\"this:\",this,\" addMapChangeListener() listeners._current is \",listeners._current);\n\n if(!listeners._current) {\n listeners._current = listener;\n }\n else if(!Array.isArray(listeners._current)) {\n listeners._current = [listeners._current,listener]\n }\n else {\n listeners._current.push(listener);\n }\n\n if(Object.getOwnPropertyDescriptor((this.__proto__||Object.getPrototypeOf(this)),dispatchesChangesMethodName) === void 0) {\n Object.defineProperty((this.__proto__||Object.getPrototypeOf(this)), dispatchesChangesMethodName, dispatchesChangesPropertyDescriptor);\n }\n this.dispatchesMapChanges = true;\n\n var self = this;\n return function cancelMapChangeListener() {\n if (!self) {\n // TODO throw new Error(\"Can't remove map change listener again\");\n return;\n }\n self.removeMapChangeListener(listener, token, beforeChange);\n self = null;\n };\n};\n\nMapChanges.prototype.removeMapChangeListener = function (listener, token, beforeChange) {\n var descriptor = this.getMapChangeDescriptor(token);\n\n var listeners;\n if (beforeChange) {\n listeners = descriptor.willChangeListeners;\n } else {\n listeners = descriptor.changeListeners;\n }\n\n if(listeners._current) {\n if(listeners._current === listener) {\n listeners._current = null;\n }\n else {\n var index = listeners._current.lastIndexOf(listener);\n if (index === -1) {\n throw new Error(\"Can't remove map change listener: does not exist: token \" + JSON.stringify(token));\n }\n else {\n if(descriptor.isActive) {\n listeners.ghostCount = listeners.ghostCount+1\n listeners._current[index]=ListenerGhost\n }\n else {\n listeners._current.spliceOne(index);\n }\n }\n }\n }\n\n\n};\n\nMapChanges.prototype.dispatchMapChange = function (key, value, beforeChange) {\n var descriptors = this.getAllMapChangeDescriptors(),\n Ghost = ListenerGhost;\n\n descriptors.forEach(function (descriptor, token) {\n\n if (descriptor.isActive) {\n return;\n }\n\n var listeners = beforeChange ? descriptor.willChangeListeners : descriptor.changeListeners;\n if(listeners && listeners._current) {\n\n var tokenName = listeners.specificHandlerMethodName;\n if(Array.isArray(listeners._current)) {\n if(listeners._current.length) {\n //removeGostListenersIfNeeded returns listeners.current or a new filtered one when conditions are met\n var currentListeners = listeners.removeCurrentGostListenersIfNeeded(),\n i, countI, listener;\n descriptor.isActive = true;\n\n try {\n for(i=0, countI = currentListeners.length;i<countI;i++) {\n // dispatch to each listener\n if ((listener = currentListeners[i]) !== Ghost) {\n if (listener[tokenName]) {\n listener[tokenName](value, key, this);\n } else if (listener.call) {\n listener.call(listener, value, key, this);\n } else {\n throw new Error(\"Handler \" + listener + \" has no method \" + tokenName + \" and is not callable\");\n }\n }\n }\n } finally {\n descriptor.isActive = false;\n }\n }\n }\n else {\n descriptor.isActive = true;\n // dispatch each listener\n\n try {\n listener = listeners._current;\n if (listener[tokenName]) {\n listener[tokenName](value, key, this);\n } else if (listener.call) {\n listener.call(listener, value, key, this);\n } else {\n throw new Error(\"Handler \" + listener + \" has no method \" + tokenName + \" and is not callable\");\n }\n } finally {\n descriptor.isActive = false;\n }\n\n }\n }\n\n }, this);\n};\n\nMapChanges.prototype.addBeforeMapChangeListener = function (listener, token) {\n return this.addMapChangeListener(listener, token, true);\n};\n\nMapChanges.prototype.removeBeforeMapChangeListener = function (listener, token) {\n return this.removeMapChangeListener(listener, token, true);\n};\n\nMapChanges.prototype.dispatchBeforeMapChange = function (key, value) {\n return this.dispatchMapChange(key, value, true);\n};\n","\"use strict\";\n\nvar Shim = require(\"./shim\");\nvar SortedSet = require(\"./sorted-set\");\nvar GenericCollection = require(\"./generic-collection\");\nvar GenericMap = require(\"./generic-map\");\nvar PropertyChanges = require(\"./listen/property-changes\");\nvar MapChanges = require(\"./listen/map-changes\");\n\nmodule.exports = SortedMap;\n\nfunction SortedMap(values, equals, compare, getDefault) {\n if (!(this instanceof SortedMap)) {\n return new SortedMap(values, equals, compare, getDefault);\n }\n equals = equals || Object.equals;\n compare = compare || Object.compare;\n getDefault = getDefault || Function.noop;\n this.contentEquals = equals;\n this.contentCompare = compare;\n this.getDefault = getDefault;\n this.store = new SortedSet(\n null,\n function keysEqual(a, b) {\n return equals(a.key, b.key);\n },\n function compareKeys(a, b) {\n return compare(a.key, b.key);\n }\n );\n this.length = 0;\n this.addEach(values);\n}\n\n// hack so require(\"sorted-map\").SortedMap will work in MontageJS\nSortedMap.SortedMap = SortedMap;\n\nSortedMap.from = GenericCollection.from;\n\nObject.addEach(SortedMap.prototype, GenericCollection.prototype);\nObject.addEach(SortedMap.prototype, GenericMap.prototype);\nObject.addEach(SortedMap.prototype, PropertyChanges.prototype);\nObject.addEach(SortedMap.prototype, MapChanges.prototype);\nObject.defineProperty(SortedMap.prototype,\"size\",GenericCollection._sizePropertyDescriptor);\n\nSortedMap.prototype.constructClone = function (values) {\n return new this.constructor(\n values,\n this.contentEquals,\n this.contentCompare,\n this.getDefault\n );\n};\nSortedMap.prototype.iterate = function () {\n return this.store.iterate();\n};\n\nSortedMap.prototype.log = function (charmap, logNode, callback, thisp) {\n logNode = logNode || this.logNode\n this.store.log(charmap, function (node, log, logBefore) {\n logNode(node.value, log, logBefore);\n }, callback, thisp);\n};\n\nSortedMap.prototype.logNode = function (node, log) {\n log(\" key: \" + node.key);\n log(\" value: \" + node.value);\n};\n","/**\n * CBOR Tag support for semantic tagging of values.\n *\n * Tags provide semantic information about CBOR data items.\n * For example, tag 1 indicates a date/time value.\n *\n * @module tag\n */\n\nimport type { CborNumber } from \"./cbor\";\n\n/**\n * A CBOR tag with an optional name.\n *\n * Tags consist of a numeric value and an optional human-readable name.\n */\nexport interface Tag {\n /** The numeric tag value */\n readonly value: CborNumber;\n /** Optional human-readable name for the tag */\n readonly name?: string;\n}\n\n/**\n * Create a new Tag.\n *\n * @param value - The numeric tag value\n * @param name - Optional human-readable name\n * @returns A new Tag object\n *\n * @example\n * ```typescript\n * const dateTag = createTag(1, 'date');\n * const customTag = createTag(12345, 'myCustomTag');\n * ```\n */\nexport const createTag = (value: CborNumber, name?: string): Tag => {\n if (name !== undefined) {\n return { value, name };\n }\n return { value };\n};\n\n/**\n * Get the string representation of a tag.\n * Internal function used for error messages.\n *\n * @param tag - The tag to represent\n * @returns String representation (name if available, otherwise value)\n *\n * @internal\n */\nexport const tagToString = (tag: Tag): string => tag.name ?? tag.value.toString();\n","/**\n * Error types for CBOR encoding and decoding.\n *\n * @module error\n */\n\nimport type { Tag } from \"./tag\";\nimport { tagToString } from \"./tag\";\n\n/**\n * A comprehensive set of errors that can occur during CBOR encoding and\n * decoding operations with special focus on enforcing the deterministic\n * encoding rules specified in the dCBOR specification.\n *\n * The dCBOR implementation validates all encoded CBOR against the\n * deterministic encoding requirements of RFC 8949 §4.2.1, plus additional\n * constraints defined in the dCBOR application profile. These errors represent\n * all the possible validation failures and decoding issues that can arise.\n */\nexport type Error =\n /**\n * The CBOR data ended prematurely during decoding, before a complete CBOR\n * item could be decoded. This typically happens when a CBOR item's\n * structure indicates more data than is actually present.\n */\n | { readonly type: \"Underrun\" }\n /**\n * An unsupported or invalid value was encountered in a CBOR header byte.\n * The parameter contains the unsupported header byte value.\n * This can occur when decoding CBOR that uses unsupported features or is\n * malformed.\n */\n | { readonly type: \"UnsupportedHeaderValue\"; readonly value: number }\n /**\n * A CBOR numeric value was encoded in a non-canonical form, violating the\n * deterministic encoding requirement of dCBOR (per Section 2.3 of the\n * dCBOR specification).\n *\n * This error is triggered when:\n * - An integer is not encoded in its shortest possible form\n * - A floating point value that could be represented as an integer was not\n * reduced\n * - A NaN value was not encoded in its canonical form (`f97e00`)\n */\n | { readonly type: \"NonCanonicalNumeric\" }\n /**\n * An invalid CBOR simple value was encountered during decoding.\n *\n * Per Section 2.4 of the dCBOR specification, only `false`, `true`,\n * `null`, and floating point values are valid simple values in dCBOR.\n * All other major type 7 values are invalid.\n */\n | { readonly type: \"InvalidSimpleValue\" }\n /**\n * A CBOR text string was not valid UTF-8. The parameter contains the\n * specific error message.\n *\n * All CBOR text strings (major type 3) must be valid UTF-8 per RFC 8949.\n */\n | { readonly type: \"InvalidString\"; readonly message: string }\n /**\n * A CBOR text string was not encoded in Unicode Canonical Normalization\n * Form C (NFC).\n *\n * Per Section 2.5 of the dCBOR specification, all text strings must be in\n * NFC form, and decoders must reject any encoded text strings that are\n * not in NFC.\n */\n | { readonly type: \"NonCanonicalString\" }\n /**\n * The decoded CBOR item didn't consume all input data.\n * The parameter contains the number of unused bytes.\n *\n * This error occurs when decoding functions expect exactly one CBOR item\n * but the input contains additional data after a valid CBOR item.\n */\n | { readonly type: \"UnusedData\"; readonly count: number }\n /**\n * The keys in a decoded CBOR map were not in the canonical lexicographic order\n * of their encoding.\n *\n * Per the CDE specification and Section 2.1 of dCBOR, map keys must be in\n * ascending lexicographic order of their encoded representation for\n * deterministic encoding.\n */\n | { readonly type: \"MisorderedMapKey\" }\n /**\n * A decoded CBOR map contains duplicate keys, which is invalid.\n *\n * Per Section 2.2 of the dCBOR specification, CBOR maps must not contain\n * duplicate keys, and decoders must reject encoded maps with duplicate\n * keys.\n */\n | { readonly type: \"DuplicateMapKey\" }\n /**\n * A requested key was not found in a CBOR map during data extraction.\n */\n | { readonly type: \"MissingMapKey\" }\n /**\n * A CBOR numeric value could not be represented in the specified target\n * numeric type.\n *\n * This occurs when attempting to convert a CBOR number to a numeric\n * type that is too small to represent the value without loss of\n * precision.\n */\n | { readonly type: \"OutOfRange\" }\n /**\n * The CBOR value is not of the expected type for a conversion or\n * operation.\n *\n * This occurs when attempting to convert a CBOR value to a type that\n * doesn't match the actual CBOR item's type (e.g., trying to convert a\n * string to an integer).\n */\n | { readonly type: \"WrongType\" }\n /**\n * The CBOR tagged value had a different tag than expected.\n * Contains the expected tag and the actual tag found.\n */\n | { readonly type: \"WrongTag\"; readonly expected: Tag; readonly actual: Tag }\n /**\n * Invalid UTF‑8 in a text string.\n */\n | { readonly type: \"InvalidUtf8\"; readonly message: string }\n /**\n * Invalid ISO 8601 date format.\n */\n | { readonly type: \"InvalidDate\"; readonly message: string }\n /**\n * Custom error message.\n */\n | { readonly type: \"Custom\"; readonly message: string };\n\n/**\n * Create a custom error with a message.\n *\n * Matches Rust's `Error::msg()` method.\n */\nexport const errorMsg = (message: string): Error => ({\n type: \"Custom\",\n message,\n});\n\n/**\n * Convert an Error to a display string.\n *\n * Matches Rust's `Display` trait / `to_string()` method.\n */\nexport const errorToString = (error: Error): string => {\n switch (error.type) {\n case \"Underrun\":\n return \"early end of CBOR data\";\n case \"UnsupportedHeaderValue\":\n return \"unsupported value in CBOR header\";\n case \"NonCanonicalNumeric\":\n return \"a CBOR numeric value was encoded in non-canonical form\";\n case \"InvalidSimpleValue\":\n return \"an invalid CBOR simple value was encountered\";\n case \"InvalidString\":\n return `an invalidly-encoded UTF-8 string was encountered in the CBOR (${error.message})`;\n case \"NonCanonicalString\":\n return \"a CBOR string was not encoded in Unicode Canonical Normalization Form C\";\n case \"UnusedData\":\n return `the decoded CBOR had ${error.count} extra bytes at the end`;\n case \"MisorderedMapKey\":\n return \"the decoded CBOR map has keys that are not in canonical order\";\n case \"DuplicateMapKey\":\n return \"the decoded CBOR map has a duplicate key\";\n case \"MissingMapKey\":\n return \"missing CBOR map key\";\n case \"OutOfRange\":\n return \"the CBOR numeric value could not be represented in the specified numeric type\";\n case \"WrongType\":\n return \"the decoded CBOR value was not the expected type\";\n case \"WrongTag\":\n return `expected CBOR tag ${tagToString(error.expected)}, but got ${tagToString(error.actual)}`;\n case \"InvalidUtf8\":\n return `invalid UTF‑8 string: ${error.message}`;\n case \"InvalidDate\":\n return `invalid ISO 8601 date string: ${error.message}`;\n case \"Custom\":\n return error.message;\n }\n};\n\n/**\n * Result type matching Rust's `Result<T, Error>`.\n *\n * In TypeScript, we use a discriminated union for Result instead of\n * try/catch for better type safety and Rust compatibility.\n */\nexport type Result<T> = { ok: true; value: T } | { ok: false; error: Error };\n\n/**\n * Create a successful Result.\n */\nexport const Ok = <T>(value: T): Result<T> => ({\n ok: true,\n value,\n});\n\n/**\n * Create a failed Result.\n */\nexport const Err = <T>(error: Error): Result<T> => ({\n ok: false,\n error,\n});\n\n/**\n * Typed error class for all CBOR-related errors.\n *\n * Wraps the discriminated union Error type in a JavaScript Error object\n * for proper error handling with stack traces.\n *\n * @example\n * ```typescript\n * throw new CborError({ type: 'Underrun' });\n * throw new CborError({ type: 'WrongTag', expected: tag1, actual: tag2 });\n * ```\n */\nexport class CborError extends Error {\n /**\n * The structured error information.\n */\n public readonly errorType: Error;\n\n /**\n * Create a new CborError.\n *\n * @param errorType - The discriminated union error type\n * @param message - Optional custom message (defaults to errorToString(errorType))\n */\n constructor(errorType: Error, message?: string) {\n super(message ?? errorToString(errorType));\n this.name = \"CborError\";\n this.errorType = errorType;\n\n // Maintains proper stack trace for where error was thrown (V8 only)\n if (\"captureStackTrace\" in Error) {\n (\n Error as {\n captureStackTrace(target: object, constructor: typeof CborError): void;\n }\n ).captureStackTrace(this, CborError);\n }\n }\n\n /**\n * Check if an error is a CborError.\n *\n * @param error - Error to check\n * @returns True if error is a CborError\n */\n static isCborError(error: unknown): error is CborError {\n return error instanceof CborError;\n }\n}\n","/**\n * Standard library re-exports and compatibility layer.\n *\n * In Rust, this handles std/no_std feature flags.\n * In TypeScript, this is primarily documentation.\n *\n * @module stdlib\n */\n\nimport { CborError } from \"./error\";\n\n/**\n * Concatenate multiple byte arrays into one.\n */\nexport const concatBytes = (arrays: Uint8Array[]): Uint8Array => {\n const totalLength = arrays.reduce((sum, arr) => sum + arr.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const arr of arrays) {\n result.set(arr, offset);\n offset += arr.length;\n }\n return result;\n};\n\n/**\n * Check if two byte arrays are equal.\n */\nexport const areBytesEqual = (a: Uint8Array, b: Uint8Array): boolean => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n\n/**\n * Lexicographically compare two byte arrays.\n * Returns: -1 if a < b, 0 if a == b, 1 if a > b\n */\nexport const lexicographicallyCompareBytes = (a: Uint8Array, b: Uint8Array): number => {\n const minLen = Math.min(a.length, b.length);\n for (let i = 0; i < minLen; i++) {\n const aVal = a[i];\n const bVal = b[i];\n if (aVal === undefined || bVal === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Unexpected undefined byte in array\" });\n }\n if (aVal < bVal) return -1;\n if (aVal > bVal) return 1;\n }\n if (a.length < b.length) return -1;\n if (a.length > b.length) return 1;\n return 0;\n};\n","/*! https://github.com/rochars/byte-data\r\nCopyright (c) 2019 Rafael da Silva Rocha */\r\n!function(){if(!Object.defineProperty||!function(){try{return Object.defineProperty({},\"x\",{}),!0}catch(e){return!1}}()){var e=Object.defineProperty;Object.defineProperty=function(t,r,o){if(e)try{return e(t,r,o)}catch(e){}if(t!==Object(t))throw TypeError(\"Object.defineProperty called on non-object\");return Object.prototype.__defineGetter__&&\"get\"in o&&Object.prototype.__defineGetter__.call(t,r,o.get),Object.prototype.__defineSetter__&&\"set\"in o&&Object.prototype.__defineSetter__.call(t,r,o.set),\"value\"in o&&(t[r]=o.value),t}}}();try{Object.getOwnPropertyDescriptor({t:\"o\"},\"t\")}catch(e){Object.getOwnPropertyDescriptor=function(e,t){return null!=(\"function\"==typeof e.__lookupGetter__&&\"function\"==typeof e.__lookupSetter__?e.__lookupGetter__(t)||e.__lookupSetter__(t):null)?{configurable:!0,enumerable:!0,get:e.__lookupGetter__(t),set:e.__lookupSetter__(t)}:{configurable:!0,writable:!0,enumerable:!0,value:e[t]}}};var byteData=(function(exports){var exports=exports||{};var l=\"function\"==typeof Object.defineProperties?Object.defineProperty:function(c,a,d){c!=Array.prototype&&c!=Object.prototype&&(c[a]=d.value)},m=\"undefined\"!=typeof window&&window===this?this:\"undefined\"!=typeof global&&null!=global?global:this;function p(c,a){if(a){for(var d=m,b=c.split(\".\"),e=0;e<b.length-1;e++){var f=b[e];f in d||(d[f]={});d=d[f]}b=b[b.length-1];e=d[b];f=a(e);f!=e&&null!=f&&l(d,b,{configurable:!0,writable:!0,value:f})}}\r\np(\"String.prototype.codePointAt\",function(c){return c?c:function(a){if(null==this)throw new TypeError(\"The 'this' value for String.prototype.codePointAt must not be null or undefined\");var d=this.length;a=Number(a)||0;if(0<=a&&a<d){a|=0;var b=this.charCodeAt(a);if(55296>b||56319<b||a+1===d)return b;a=this.charCodeAt(a+1);return 56320>a||57343<a?b:1024*(b-55296)+a+9216}}});Object.defineProperty(exports,\"__esModule\",{value:!0});\r\nfunction q(c,a,d,b){b=void 0===b?c.length:b;for(d=void 0===d?0:d;d<b;d+=a){var e=c,f=a,h=d;f--;for(var g=0;g<f;g++){var k=e[h+g];e[h+g]=e[h+f];e[h+f]=k;f--}}}function r(c,a,d){d=void 0===d?0:d;if(\"string\"!==typeof c)throw new TypeError;for(var b=0,e=c.length;b<e;){var f=c.codePointAt(b);if(128>f)a[d]=f,d++;else{var h=0,g=0;2047>=f?(h=1,g=192):65535>=f?(h=2,g=224):1114111>=f&&(h=3,g=240,b++);a[d]=(f>>6*h)+g;for(d++;0<h;)a[d]=128|f>>6*(h-1)&63,d++,h--}b++}return d}\r\nfunction t(c,a,d){this.bits=c;this.offset=Math.ceil(c/8);this.max=Math.pow(2,c)-1;this.min=0;this.unpack=this.b;if(void 0===a?0:a)this.max=Math.pow(2,c)/2-1,this.min=-this.max-1,this.unpack=this.f;if(void 0===d?0:d)this.a=this.c}t.prototype.pack=function(c,a,d){d=void 0===d?0:d;if(\"number\"!==typeof a||!isFinite(a)||Math.floor(a)!==a)throw new TypeError;a=this.a(a);for(var b=0,e=this.offset;b<e;b++)c[d]=Math.floor(a/Math.pow(2,8*b))&255,d++;return d};\r\nt.prototype.b=function(c,a){a=void 0===a?0:a;for(var d=0,b=0;b<this.offset;b++)d+=c[a+b]*Math.pow(256,b);return d};t.prototype.f=function(c,a){var d=this.b(c,void 0===a?0:a);d>this.max&&(d-=2*this.max+2);return d};t.prototype.a=function(c){if(c>this.max||c<this.min)throw new RangeError;return c};t.prototype.c=function(c){return c>this.max?this.max:c<this.min?this.min:c};\r\nfunction u(c,a){this.offset=Math.ceil((c+a)/8);this.b=c;this.c=a;this.a=(1<<c-1)-1;this.f=Math.pow(2,this.a+1);this.g=c+a;this.h=Math.pow(2,-(8*this.offset-1-c))}\r\nu.prototype.pack=function(c,a,d){if(\"number\"!==typeof a)throw new TypeError;Math.abs(a)>this.f-2*this.g&&(a=0>a?-Infinity:Infinity);var b=0>((a=+a)||1/a)?1:0>a?1:0;a=Math.abs(a);var e=Math.min(Math.floor(Math.log(a)/Math.LN2),1023),f=v(a/Math.pow(2,e)*Math.pow(2,this.c));a!==a?(f=Math.pow(2,this.c-1),e=(1<<this.b)-1):0!==a&&(a>=Math.pow(2,1-this.a)?(2<=f/Math.pow(2,this.c)&&(e+=1,f=1),e>this.a?(e=(1<<this.b)-1,f=0):(e+=this.a,f=v(f)-Math.pow(2,this.c))):(f=v(a/Math.pow(2,1-this.a-this.c)),e=0));a=\r\n[];a.push(b);for(b=this.b;0<b;--b)a[b]=e%2?1:0,e=Math.floor(e/2);b=a.length;for(e=this.c;0<e;--e)a[b+e]=f%2?1:0,f=Math.floor(f/2);b=a.join(\"\");f=this.offset+d-1;for(a=d;f>=d;)c[f]=parseInt(b.substring(0,8),2),b=b.substring(8),f--,a++;return a};\r\nu.prototype.unpack=function(c,a){for(var d=(1<<this.b)-1,b=\"\",e=this.offset-1;0<=e;e--){var f=c[e+a].toString(2);b+=\"00000000\".substring(f.length)+f}e=\"1\"==b.charAt(0)?-1:1;b=b.substring(1);f=parseInt(b.substring(0,this.b),2);b=b.substring(this.b);if(f==d)return 0!==parseInt(b,2)?NaN:Infinity*e;0===f?(f+=1,d=parseInt(b,2)):d=parseInt(\"1\"+b,2);return e*d*this.h*Math.pow(2,f-this.a)};function v(c){var a=Math.floor(c);c-=a;return.5>c?a:.5<c?a+1:a%2?a+1:a}\r\nfunction w(c,a,d,b,e){b=void 0===b?0:b;a=a||{};var f=x(a.bits,a.fp,a.signed,void 0===e?!1:e),h=Math.ceil(a.bits/8);e=0;var g=b;try{for(var k=c.length;e<k;e++)b=f.pack(d,c[e],b);a.be&&q(d,h,g,b)}catch(n){throw a=n,a.message=a.constructor.name+\" at index \"+e+\": \"+c[e],a;}return b}\r\nfunction y(c,a,d,b,e,f){b=void 0===b?0:b;e=void 0===e?c.length:e;f=void 0===f?!1:f;a=a||{};var h=x(a.bits,a.fp,a.signed,!1),g=h.offset,k=(e-b)%g;if(f&&(k||c.length<g))throw Error(\"Bad buffer length\");e-=k;a.be?(c=c.constructor===Array?c.slice():new Uint8Array(c),a.be&&q(c,h.offset,b,e),z(c,d,b,e,h)):z(c,d,b,e,h)}function A(c,a,d,b,e){return w([c],a,d,void 0===b?0:b,void 0===e?!1:e)}function z(c,a,d,b,e){for(var f=e.offset,h=0;d<b;d+=f,h++)a[h]=e.unpack(c,d)}\r\nfunction x(c,a,d,b){if(a){if(!c||16!==c&&32!==c&&64!==c)throw Error(\"Unsupported type: float, bits: \"+c);}else if(!c||1>c||53<c)throw Error(\"Unsupported type: int, bits: \"+c);return a&&16===c?new u(5,11):a&&32==c?new u(8,23):a&&64==c?new u(11,52):new t(c,d,b)}exports.pack=function(c,a,d){var b=[];A(c,a,b,0,void 0===d?!1:d);return b};exports.packArray=function(c,a,d){var b=[];w(c,a,b,0,void 0===d?!1:d);return b};exports.packArrayTo=w;exports.packString=function(c){var a=[];r(c,a);return a};\r\nexports.packStringTo=function(c,a,d){return r(c,a,void 0===d?0:d)};exports.packTo=A;exports.unpack=function(c,a,d,b){d=void 0===d?0:d;var e=[];y(c,a,e,d,d+Math.ceil(a.bits/8),void 0===b?!1:b);return e[0]};exports.unpackArray=function(c,a,d,b,e){b=void 0===b?c.length:b;var f=[];y(c,a,f,void 0===d?0:d,b,void 0===e?!1:e);return f};exports.unpackArrayTo=y;\r\nexports.unpackString=function(c,a,d){d=void 0===d?c.length:d;var b=void 0===a?0:a;d=void 0===d?c.length:d;a=\"\";for(b=void 0===b?0:b;b<d;){var e=128,f=191,h=!1,g=c[b++];if(0<=g&&127>=g)a+=String.fromCharCode(g);else{var k=0;194<=g&&223>=g?k=1:224<=g&&239>=g?(k=2,224===c[b]&&(e=160),237===c[b]&&(f=159)):240<=g&&244>=g?(k=3,240===c[b]&&(e=144),244===c[b]&&(f=143)):h=!0;g&=(1<<8-k-1)-1;for(var n=0;n<k;n++){if(c[b]<e||c[b]>f)h=!0;g=g<<6|c[b]&63;b++}h?a+=String.fromCharCode(65533):65535>=g?a+=String.fromCharCode(g):\r\n(g-=65536,a+=String.fromCharCode((g>>10&1023)+55296,(g&1023)+56320))}}return a};typeof module!=='undefined'?module.exports=exports :typeof define==='function'&&define.amd?define(['exports'],exports) :typeof global!=='undefined'?global.byteData=exports:null;return exports;})();\r\n","/**\n * Exact numeric conversions.\n *\n * This module is based on the Swift `exactly` initializers.\n * See https://github.com/apple/swift-evolution/blob/main/proposals/0080-failable-numeric-initializers.md\n * See https://github.com/apple/swift/blob/main/stdlib/public/core/IntegerTypes.swift.gyb\n *\n * Provides exact conversions between numeric types (f16/f32/f64/integers).\n * Returns undefined if the conversion cannot be represented exactly.\n *\n * @module exact\n */\n\nimport { binary16ToNumber, binary32ToNumber, numberToBinary16, numberToBinary32 } from \"./float\";\n\n// TypeScript doesn't have native integer types with overflow, so we use number for most operations\n// and bigint for values that exceed Number.MAX_SAFE_INTEGER\n\n// Helper to check if a number has a fractional part\nconst hasFract = (n: number): boolean => {\n return n % 1 !== 0;\n};\n\n/**\n * Exact conversions for i16 (-32768 to 32767).\n */\nexport class ExactI16 {\n static readonly MIN = -32768;\n static readonly MAX = 32767;\n\n static exactFromF16(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -32768.0 || source >= 32768.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF32(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -32769.0 || source >= 32768.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF64(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -32769.0 || source >= 32768.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n > 32767) return undefined;\n return n;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n < -32768 || n > 32767) return undefined;\n return n;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n if (source > 32767n) return undefined;\n return Number(source);\n }\n\n static exactFromI128(source: bigint): number | undefined {\n if (source < -32768n || source > 32767n) return undefined;\n return Number(source);\n }\n}\n\n/**\n * Exact conversions for i32 (-2147483648 to 2147483647).\n */\nexport class ExactI32 {\n static readonly MIN = -2147483648;\n static readonly MAX = 2147483647;\n\n static exactFromF16(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n // A Float16 value, if finite, is always in-range for 32-bit signed integer types\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF32(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -2147483904.0 || source >= 2147483648.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF64(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -2147483649.0 || source >= 2147483648.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n > 2147483647) return undefined;\n return n;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n < -2147483648 || n > 2147483647) return undefined;\n return n;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n if (source > 2147483647n) return undefined;\n return Number(source);\n }\n\n static exactFromI128(source: bigint): number | undefined {\n if (source < -2147483648n || source > 2147483647n) return undefined;\n return Number(source);\n }\n}\n\n/**\n * Exact conversions for i64 (-9223372036854775808 to 9223372036854775807).\n */\nexport class ExactI64 {\n static readonly MIN = -9223372036854775808n;\n static readonly MAX = 9223372036854775807n;\n\n static exactFromF16(source: number): number | bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n // A Float16 value, if finite, is always in-range for 64-bit signed integer types\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF32(source: number): number | bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -9223373136366403584.0 || source >= 9223372036854775808.0) return undefined;\n if (hasFract(source)) return undefined;\n const result = Math.trunc(source);\n return result > Number.MAX_SAFE_INTEGER || result < Number.MIN_SAFE_INTEGER\n ? BigInt(result)\n : result;\n }\n\n static exactFromF64(source: number): number | bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -9223372036854777856.0 || source >= 9223372036854775808.0) return undefined;\n if (hasFract(source)) return undefined;\n const result = Math.trunc(source);\n return result > Number.MAX_SAFE_INTEGER || result < Number.MIN_SAFE_INTEGER\n ? BigInt(result)\n : result;\n }\n\n static exactFromU64(source: number | bigint): number | bigint | undefined {\n const n = typeof source === \"bigint\" ? source : BigInt(source);\n if (n > 9223372036854775807n) return undefined;\n return n <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(n) : n;\n }\n\n static exactFromI64(source: number | bigint): number | bigint | undefined {\n // Identity conversion\n return source;\n }\n\n static exactFromU128(source: bigint): number | bigint | undefined {\n if (source > 9223372036854775807n) return undefined;\n return source <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(source) : source;\n }\n\n static exactFromI128(source: bigint): number | bigint | undefined {\n if (source < -9223372036854775808n || source > 9223372036854775807n) return undefined;\n return source <= BigInt(Number.MAX_SAFE_INTEGER) && source >= BigInt(Number.MIN_SAFE_INTEGER)\n ? Number(source)\n : source;\n }\n}\n\n/**\n * Exact conversions for i128 (JavaScript bigint).\n */\nexport class ExactI128 {\n static readonly MIN = -(2n ** 127n);\n static readonly MAX = 2n ** 127n - 1n;\n\n static exactFromF16(source: number): bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n // A Float16 value, if finite, is always in-range for 128-bit signed integer types\n if (hasFract(source)) return undefined;\n return BigInt(Math.trunc(source));\n }\n\n static exactFromF32(source: number): bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n // f32::MIN and f32::MAX are both in range of i128\n if (hasFract(source)) return undefined;\n return BigInt(Math.trunc(source));\n }\n\n static exactFromF64(source: number): bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n // f64::MIN and f64::MAX are both in range of i128\n if (hasFract(source)) return undefined;\n return BigInt(Math.trunc(source));\n }\n\n static exactFromU64(source: number | bigint): bigint | undefined {\n return BigInt(source);\n }\n\n static exactFromI64(source: number | bigint): bigint | undefined {\n return BigInt(source);\n }\n\n static exactFromU128(source: bigint): bigint | undefined {\n const max = 2n ** 127n - 1n;\n if (source > max) return undefined;\n return source;\n }\n\n static exactFromI128(source: bigint): bigint | undefined {\n // Identity conversion\n return source;\n }\n}\n\n/**\n * Exact conversions for u16 (0 to 65535).\n */\nexport class ExactU16 {\n static readonly MIN = 0;\n static readonly MAX = 65535;\n\n static exactFromF16(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n // A Float16 value, if greater than -1 and finite, is always in-range for 16-bit unsigned integer types\n if (source <= -1.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF32(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0 || source >= 65536.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF64(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0 || source >= 65536.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n > 65535) return undefined;\n return n;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n < 0 || n > 65535) return undefined;\n return n;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n if (source > 65535n) return undefined;\n return Number(source);\n }\n\n static exactFromI128(source: bigint): number | undefined {\n if (source < 0n || source > 65535n) return undefined;\n return Number(source);\n }\n}\n\n/**\n * Exact conversions for u32 (0 to 4294967295).\n */\nexport class ExactU32 {\n static readonly MIN = 0;\n static readonly MAX = 4294967295;\n\n static exactFromF16(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n // A Float16 value, if greater than -1 and finite, is always in-range for 32-bit unsigned integer types\n if (source <= -1.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF32(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0 || source >= 4294967296.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF64(source: number): number | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0 || source >= 4294967296.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n > 4294967295) return undefined;\n return n;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n if (n < 0 || n > 4294967295) return undefined;\n return n;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n if (source > 4294967295n) return undefined;\n return Number(source);\n }\n\n static exactFromI128(source: bigint): number | undefined {\n if (source < 0n || source > 4294967295n) return undefined;\n return Number(source);\n }\n}\n\n/**\n * Exact conversions for u64 (0 to 18446744073709551615).\n */\nexport class ExactU64 {\n static readonly MIN = 0n;\n static readonly MAX = 18446744073709551615n;\n\n static exactFromF16(source: number): number | bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n // A Float16 value, if greater than -1 and finite, is always in-range for 64-bit unsigned integer types\n if (source <= -1.0) return undefined;\n if (hasFract(source)) return undefined;\n return Math.trunc(source);\n }\n\n static exactFromF32(source: number): number | bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0 || source >= 18446744073709551616.0) return undefined;\n if (hasFract(source)) return undefined;\n const result = Math.trunc(source);\n return result > Number.MAX_SAFE_INTEGER ? BigInt(result) : result;\n }\n\n static exactFromF64(source: number): number | bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0 || source >= 18446744073709551616.0) return undefined;\n if (hasFract(source)) return undefined;\n const result = Math.trunc(source);\n return result > Number.MAX_SAFE_INTEGER ? BigInt(result) : result;\n }\n\n static exactFromU64(source: number | bigint): number | bigint | undefined {\n // Identity conversion\n return source;\n }\n\n static exactFromI64(source: number | bigint): number | bigint | undefined {\n const n = typeof source === \"bigint\" ? source : BigInt(source);\n if (n < 0n) return undefined;\n return source;\n }\n\n static exactFromU128(source: bigint): number | bigint | undefined {\n if (source > 18446744073709551615n) return undefined;\n return source <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(source) : source;\n }\n\n static exactFromI128(source: bigint): number | bigint | undefined {\n if (source < 0n || source > 18446744073709551615n) return undefined;\n return source <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(source) : source;\n }\n}\n\n/**\n * Exact conversions for u128 (JavaScript bigint, unsigned).\n */\nexport class ExactU128 {\n static readonly MIN = 0n;\n static readonly MAX = 2n ** 128n - 1n;\n\n static exactFromF16(source: number): bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0) return undefined;\n if (hasFract(source)) return undefined;\n return BigInt(Math.trunc(source));\n }\n\n static exactFromF32(source: number): bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0) return undefined;\n if (hasFract(source)) return undefined;\n return BigInt(Math.trunc(source));\n }\n\n static exactFromF64(source: number): bigint | undefined {\n if (!Number.isFinite(source)) return undefined;\n if (source <= -1.0) return undefined;\n if (hasFract(source)) return undefined;\n return BigInt(Math.trunc(source));\n }\n\n static exactFromU64(source: number | bigint): bigint | undefined {\n return BigInt(source);\n }\n\n static exactFromI64(source: number | bigint): bigint | undefined {\n const n = typeof source === \"bigint\" ? source : BigInt(source);\n if (n < 0n) return undefined;\n return n;\n }\n\n static exactFromU128(source: bigint): bigint | undefined {\n // Identity conversion\n return source;\n }\n\n static exactFromI128(source: bigint): bigint | undefined {\n if (source < 0n) return undefined;\n return source;\n }\n}\n\n/**\n * Exact conversions for f16 (half precision float).\n * In TypeScript, we work with f16 as raw bytes (Uint8Array of length 2).\n */\nexport class ExactF16 {\n static exactFromF16(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n return source;\n }\n\n static exactFromF32(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n if (!Number.isFinite(source)) return source; // Infinity\n\n // Convert to f16 and back to check exactness\n const f16Bytes = numberToBinary16(source);\n const roundTrip = binary16ToNumber(f16Bytes);\n return roundTrip === source ? roundTrip : undefined;\n }\n\n static exactFromF64(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n if (!Number.isFinite(source)) return source; // Infinity\n\n // Convert to f16 and back to check exactness\n const f16Bytes = numberToBinary16(source);\n const roundTrip = binary16ToNumber(f16Bytes);\n return roundTrip === source ? roundTrip : undefined;\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n const f16Bytes = numberToBinary16(n);\n const f = binary16ToNumber(f16Bytes);\n if (!Number.isFinite(f)) return undefined;\n const roundTrip = typeof source === \"bigint\" ? BigInt(Math.trunc(f)) : Math.trunc(f);\n return roundTrip === source ? f : undefined;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n const f16Bytes = numberToBinary16(n);\n const f = binary16ToNumber(f16Bytes);\n if (!Number.isFinite(f)) return undefined;\n const roundTrip = typeof source === \"bigint\" ? BigInt(Math.trunc(f)) : Math.trunc(f);\n return roundTrip === source ? f : undefined;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n const n = Number(source);\n const f16Bytes = numberToBinary16(n);\n const f = binary16ToNumber(f16Bytes);\n if (!Number.isFinite(f)) return undefined;\n const roundTrip = BigInt(Math.trunc(f));\n return roundTrip === source ? f : undefined;\n }\n\n static exactFromI128(source: bigint): number | undefined {\n const n = Number(source);\n const f16Bytes = numberToBinary16(n);\n const f = binary16ToNumber(f16Bytes);\n if (!Number.isFinite(f)) return undefined;\n const roundTrip = BigInt(Math.trunc(f));\n return roundTrip === source ? f : undefined;\n }\n}\n\n/**\n * Exact conversions for f32 (single precision float).\n */\nexport class ExactF32 {\n static exactFromF16(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n return source; // f16 always fits in f32\n }\n\n static exactFromF32(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n return source;\n }\n\n static exactFromF64(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n // JavaScript numbers are f64, need to check if it fits in f32 exactly\n const f32Bytes = numberToBinary32(source);\n const roundTrip = binary32ToNumber(f32Bytes);\n return roundTrip === source ? roundTrip : undefined;\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n const f32Bytes = numberToBinary32(n);\n const f = binary32ToNumber(f32Bytes);\n const roundTrip = typeof source === \"bigint\" ? BigInt(Math.trunc(f)) : Math.trunc(f);\n return roundTrip === source ? f : undefined;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n const f32Bytes = numberToBinary32(n);\n const f = binary32ToNumber(f32Bytes);\n const roundTrip = typeof source === \"bigint\" ? BigInt(Math.trunc(f)) : Math.trunc(f);\n return roundTrip === source ? f : undefined;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n const n = Number(source);\n const f32Bytes = numberToBinary32(n);\n const f = binary32ToNumber(f32Bytes);\n if (!Number.isFinite(f)) return undefined;\n const roundTrip = BigInt(Math.trunc(f));\n return roundTrip === source ? f : undefined;\n }\n\n static exactFromI128(source: bigint): number | undefined {\n // Check the range\n if (source < -0x8000_0000n || source > 0x7fff_ffffn) return undefined;\n\n const absSource = source < 0n ? -source : source;\n\n // Check the magnitude\n if (absSource <= 0xff_ffffn) {\n return Number(source);\n }\n\n // Check divisibility by powers of 2\n const trailingZeros = countTrailingZeros(absSource);\n if (trailingZeros >= 25 && trailingZeros <= 31) {\n return Number(source);\n }\n\n return undefined;\n }\n}\n\n/**\n * Exact conversions for f64 (double precision float).\n */\nexport class ExactF64 {\n static exactFromF16(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n return source; // f16 always fits in f64\n }\n\n static exactFromF32(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n return source; // f32 always fits in f64\n }\n\n static exactFromF64(source: number): number | undefined {\n if (Number.isNaN(source)) return NaN;\n return source;\n }\n\n static exactFromU64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n const roundTrip = typeof source === \"bigint\" ? BigInt(Math.trunc(n)) : Math.trunc(n);\n return roundTrip === source ? n : undefined;\n }\n\n static exactFromI64(source: number | bigint): number | undefined {\n const n = typeof source === \"bigint\" ? Number(source) : source;\n const roundTrip = typeof source === \"bigint\" ? BigInt(Math.trunc(n)) : Math.trunc(n);\n return roundTrip === source ? n : undefined;\n }\n\n static exactFromU128(source: bigint): number | undefined {\n const n = Number(source);\n const roundTrip = BigInt(Math.trunc(n));\n return roundTrip === source ? n : undefined;\n }\n\n static exactFromI128(source: bigint): number | undefined {\n // Check the range\n if (source < -0x8000_0000_0000_0000n || source > 0x7fff_ffff_ffff_ffffn) {\n return undefined;\n }\n\n const absSource = source < 0n ? -source : source;\n\n // Check the magnitude\n if (absSource <= 0xf_ffff_ffff_ffffn) {\n return Number(source);\n }\n\n // Check divisibility by powers of 2\n const trailingZeros = countTrailingZeros(absSource);\n if (trailingZeros >= 53 && trailingZeros <= 63) {\n return Number(source);\n }\n\n return undefined;\n }\n}\n\n// Helper function to count trailing zeros in a bigint\nconst countTrailingZeros = (n: bigint): number => {\n if (n === 0n) return 0;\n let count = 0;\n while ((n & 1n) === 0n) {\n count++;\n n = n >> 1n;\n }\n return count;\n};\n\n// ============================================================================\n// CBOR Type Extraction Utilities\n// ============================================================================\n\nimport { type Cbor, MajorType } from \"./cbor\";\n\n/**\n * Extract exact unsigned integer value.\n * Returns undefined if not an unsigned integer.\n */\nexport const exactUnsigned = (cbor: Cbor): number | bigint | undefined => {\n if (cbor.type === MajorType.Unsigned) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract exact negative integer value (as actual negative number).\n * Returns undefined if not a negative integer.\n */\nexport const exactNegative = (cbor: Cbor): number | bigint | undefined => {\n if (cbor.type === MajorType.Negative) {\n if (typeof cbor.value === \"bigint\") {\n return -(cbor.value + 1n);\n }\n return -(cbor.value + 1);\n }\n return undefined;\n};\n\n/**\n * Extract exact integer value (unsigned or negative).\n * Returns undefined if not an integer.\n */\nexport const exactInteger = (cbor: Cbor): number | bigint | undefined => {\n return exactUnsigned(cbor) ?? exactNegative(cbor);\n};\n\n/**\n * Extract exact string value.\n * Returns undefined if not a text string.\n */\nexport const exactString = (cbor: Cbor): string | undefined => {\n if (cbor.type === MajorType.Text) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract exact byte string value.\n * Returns undefined if not a byte string.\n */\nexport const exactBytes = (cbor: Cbor): Uint8Array | undefined => {\n if (cbor.type === MajorType.ByteString) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract exact array value.\n * Returns undefined if not an array.\n */\nexport const exactArray = (cbor: Cbor): readonly Cbor[] | undefined => {\n if (cbor.type === MajorType.Array) {\n return cbor.value;\n }\n return undefined;\n};\n","/**\n * Float encoding and conversion utilities for dCBOR.\n *\n * # Floating Point Number Support in dCBOR\n *\n * dCBOR provides canonical encoding for floating point values.\n *\n * Per the dCBOR specification, the canonical encoding rules ensure\n * deterministic representation:\n *\n * - Numeric reduction: Floating point values with zero fractional part in\n * range [-2^63, 2^64-1] are automatically encoded as integers (e.g., 42.0\n * becomes 42)\n * - Values are encoded in the smallest possible representation that preserves\n * their value\n * - All NaN values are canonicalized to a single representation: 0xf97e00\n * - Positive/negative infinity are canonicalized to half-precision\n * representations\n *\n * @module float\n */\n\nimport * as byteData from \"byte-data\";\nimport { encodeVarInt } from \"./varint\";\nimport { MajorType } from \"./cbor\";\nimport { ExactU64, ExactU32, ExactU16, ExactI128 } from \"./exact\";\nimport { CborError } from \"./error\";\n\n/**\n * Canonical NaN representation in CBOR: 0xf97e00\n */\nexport const CBOR_NAN = new Uint8Array([0xf9, 0x7e, 0x00]);\n\n/**\n * Check if a number has a fractional part.\n */\nexport const hasFractionalPart = (n: number): boolean => n !== Math.floor(n);\n\n/**\n * Convert 64-bit binary to number.\n * @internal\n */\nexport const binary64ToNumber = (data: Uint8Array): number => {\n return byteData.unpack(data, { bits: 64, fp: true, be: true });\n};\n\n/**\n * Convert number to 32-bit float binary (big-endian).\n */\nexport const numberToBinary32 = (n: number): Uint8Array => {\n const data = new Uint8Array(4);\n byteData.packTo(n, { bits: 32, fp: true, be: true }, data);\n return data;\n};\n\n/**\n * Convert 32-bit binary to number.\n */\nexport const binary32ToNumber = (data: Uint8Array): number => {\n return byteData.unpack(data, { bits: 32, fp: true, be: true });\n};\n\n/**\n * Convert number to 16-bit float binary (big-endian).\n */\nexport const numberToBinary16 = (n: number): Uint8Array => {\n const data = new Uint8Array(2);\n byteData.packTo(n, { bits: 16, fp: true, be: true }, data);\n return data;\n};\n\n/**\n * Convert 16-bit binary to number.\n */\nexport const binary16ToNumber = (data: Uint8Array): number => {\n return byteData.unpack(data, { bits: 16, fp: true, be: true });\n};\n\n/**\n * Encode f64 value to CBOR data bytes.\n * Implements numeric reduction and canonical encoding rules.\n * Matches Rust's f64_cbor_data function.\n * @internal\n */\nexport const f64CborData = (value: number): Uint8Array => {\n const n = value;\n\n // Try to reduce to f32 first\n const f32Bytes = numberToBinary32(n);\n const f = binary32ToNumber(f32Bytes);\n if (f === n) {\n return f32CborData(f);\n }\n\n // Try numeric reduction to negative integer\n if (n < 0.0) {\n const i128 = ExactI128.exactFromF64(n);\n if (i128 !== undefined) {\n const i = ExactU64.exactFromI128(-1n - i128);\n if (i !== undefined) {\n // Encode as a negative integer\n const num = typeof i === \"bigint\" ? Number(i) : i;\n return encodeVarInt(num, MajorType.Negative);\n }\n }\n }\n\n // Try numeric reduction to unsigned integer\n const u = ExactU64.exactFromF64(n);\n if (u !== undefined) {\n const num = typeof u === \"bigint\" ? Number(u) : u;\n return encodeVarInt(num, MajorType.Unsigned);\n }\n\n // Canonical NaN\n if (Number.isNaN(value)) {\n return CBOR_NAN;\n }\n\n // Encode as f64 - create binary manually (always 8 bytes with 0xfb prefix)\n const buffer = new ArrayBuffer(8);\n const view = new DataView(buffer);\n view.setFloat64(0, n, false); // big-endian\n const bytes = new Uint8Array(buffer);\n const majorByte = 0xfb; // 0x1b | (MajorType.Simple << 5) = 0x1b | 0xe0 = 0xfb\n return new Uint8Array([majorByte, ...bytes]);\n};\n\n/**\n * Validate canonical encoding for f64.\n * Matches Rust's validate_canonical_f64 function.\n *\n * TODO: Check if this is legacy code\n */\nexport const validateCanonicalF64 = (n: number): void => {\n const f32Bytes = numberToBinary32(n);\n const f32 = binary32ToNumber(f32Bytes);\n\n if (n === f32 || n === Math.trunc(n) || Number.isNaN(n)) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n};\n\n/**\n * Encode f32 value to CBOR data bytes.\n * Implements numeric reduction and canonical encoding rules.\n * Matches Rust's f32_cbor_data function.\n * @internal\n */\nexport const f32CborData = (value: number): Uint8Array => {\n const n = value;\n\n // Try to reduce to f16\n const f16Bytes = numberToBinary16(n);\n const f = binary16ToNumber(f16Bytes);\n if (f === n) {\n return f16CborData(f);\n }\n\n // Try numeric reduction to negative integer\n if (n < 0.0) {\n const u = ExactU64.exactFromF32(-1.0 - n);\n if (u !== undefined) {\n const num = typeof u === \"bigint\" ? Number(u) : u;\n return encodeVarInt(num, MajorType.Negative);\n }\n }\n\n // Try numeric reduction to unsigned integer\n const u = ExactU32.exactFromF32(n);\n if (u !== undefined) {\n return encodeVarInt(u, MajorType.Unsigned);\n }\n\n // Canonical NaN\n if (Number.isNaN(value)) {\n return CBOR_NAN;\n }\n\n // Encode as f32 - always use 0xfa prefix with 4 bytes\n const bytes = numberToBinary32(n);\n return new Uint8Array([0xfa, ...bytes]);\n};\n\n/**\n * Validate canonical encoding for f32.\n * Matches Rust's validate_canonical_f32 function.\n *\n * TODO: Check if this is legacy code\n */\nexport const validateCanonicalF32 = (n: number): void => {\n const f16Bytes = numberToBinary16(n);\n const f16 = binary16ToNumber(f16Bytes);\n\n if (n === f16 || n === Math.trunc(n) || Number.isNaN(n)) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n};\n\n/**\n * Encode f16 value to CBOR data bytes.\n * Implements numeric reduction and canonical encoding rules.\n * Matches Rust's f16_cbor_data function.\n * @internal\n */\nexport const f16CborData = (value: number): Uint8Array => {\n const n = value;\n\n // Try numeric reduction to negative integer\n if (n < 0.0) {\n const u = ExactU64.exactFromF64(-1.0 - n);\n if (u !== undefined) {\n const num = typeof u === \"bigint\" ? Number(u) : u;\n return encodeVarInt(num, MajorType.Negative);\n }\n }\n\n // Try numeric reduction to unsigned integer\n const u = ExactU16.exactFromF64(n);\n if (u !== undefined) {\n return encodeVarInt(u, MajorType.Unsigned);\n }\n\n // Canonical NaN\n if (Number.isNaN(value)) {\n return CBOR_NAN;\n }\n\n // Encode as f16 - always use 0xf9 prefix with 2 bytes\n const bytes = numberToBinary16(value);\n return new Uint8Array([0xf9, ...bytes]);\n};\n\n/**\n * Validate canonical encoding for f16.\n * Matches Rust's validate_canonical_f16 function.\n *\n * TODO: Check if this is legacy code\n */\nexport const validateCanonicalF16 = (value: number): void => {\n const n = value;\n const f = n;\n\n const f16Bytes = numberToBinary16(value);\n const bits = new DataView(f16Bytes.buffer).getUint16(0, false);\n\n if (f === Math.trunc(f) || (Number.isNaN(value) && bits !== 0x7e00)) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n};\n\n/**\n * Convert the smallest possible float binary representation to number.\n * This is the canonical decoder - validates that larger representations\n * are not reducible to smaller ones.\n * @internal\n */\nexport const numberToBinary = (n: number): Uint8Array => {\n if (Number.isNaN(n)) {\n return new Uint8Array([0x7e, 0x00]);\n }\n\n const n32 = numberToBinary32(n);\n const f32 = binary32ToNumber(n32);\n if (f32 === n) {\n const n16 = numberToBinary16(n);\n const f16 = binary16ToNumber(n16);\n if (f16 === n) {\n return n16;\n }\n return n32;\n }\n\n // Create a 64-bit float binary inline\n const buffer = new ArrayBuffer(8);\n const view = new DataView(buffer);\n view.setFloat64(0, n, false); // big-endian\n return new Uint8Array(buffer);\n};\n","import { type CborNumber, isCborNumber, type MajorType } from \"./cbor\";\nimport { hasFractionalPart } from \"./float\";\nimport { CborError } from \"./error\";\n\nconst typeBits = (t: MajorType): number => {\n return t << 5;\n};\n\nexport const encodeVarInt = (value: CborNumber, majorType: MajorType): Uint8Array => {\n // throw an error if the value is negative.\n if (value < 0) {\n throw new CborError({ type: \"OutOfRange\" });\n }\n // throw an error if the value is a number with a fractional part.\n if (typeof value === \"number\" && hasFractionalPart(value)) {\n throw new CborError({ type: \"OutOfRange\" });\n }\n const type = typeBits(majorType);\n // If the value is a `number` or a `bigint` that can be represented as a `number`, convert it to a `number`.\n if (isCborNumber(value) && value <= Number.MAX_SAFE_INTEGER) {\n value = Number(value);\n if (value <= 23) {\n return new Uint8Array([value | type]);\n } else if (value <= 0xff) {\n // Fits in UInt8\n return new Uint8Array([0x18 | type, value]);\n } else if (value <= 0xffff) {\n // Fits in UInt16\n const buffer = new ArrayBuffer(3);\n const view = new DataView(buffer);\n view.setUint8(0, 0x19 | type);\n view.setUint16(1, value);\n return new Uint8Array(buffer);\n } else if (value <= 0xffffffff) {\n // Fits in UInt32\n const buffer = new ArrayBuffer(5);\n const view = new DataView(buffer);\n view.setUint8(0, 0x1a | type);\n view.setUint32(1, value);\n return new Uint8Array(buffer);\n } else {\n // Fits in MAX_SAFE_INTEGER\n const buffer = new ArrayBuffer(9);\n const view = new DataView(buffer);\n view.setUint8(0, 0x1b | type);\n view.setBigUint64(1, BigInt(value));\n return new Uint8Array(buffer);\n }\n } else {\n value = BigInt(value);\n const bitsNeeded = Math.ceil(Math.log2(Number(value)) / 8) * 8;\n if (bitsNeeded > 64) {\n throw new CborError({ type: \"OutOfRange\" });\n }\n const length = Math.ceil(bitsNeeded / 8) + 1;\n const buffer = new ArrayBuffer(length);\n const view = new DataView(buffer);\n let i = length - 1;\n while (value > 0) {\n view.setUint8(i, Number(value & 0xffn));\n value >>= 8n;\n i--;\n }\n view.setUint8(0, 0x1b | type);\n return new Uint8Array(buffer);\n }\n};\n\nexport const decodeVarIntData = (\n dataView: DataView,\n offset: number,\n): { majorType: MajorType; value: CborNumber; offset: number } => {\n const initialByte = dataView.getUint8(offset);\n const majorType = (initialByte >> 5) as MajorType;\n const additionalInfo = initialByte & 0x1f;\n let value: CborNumber;\n offset += 1;\n switch (additionalInfo) {\n case 24: // 1-byte additional info\n value = dataView.getUint8(offset);\n offset += 1;\n break;\n case 25: // 2-byte additional info\n value = ((dataView.getUint8(offset) << 8) | dataView.getUint8(offset + 1)) >>> 0;\n offset += 2;\n break;\n case 26: // 4-byte additional info\n value =\n ((dataView.getUint8(offset) << 24) |\n (dataView.getUint8(offset + 1) << 16) |\n (dataView.getUint8(offset + 2) << 8) |\n dataView.getUint8(offset + 3)) >>>\n 0;\n offset += 4;\n break;\n case 27: // 8-byte additional info\n value = getUint64(dataView, offset, false);\n if (value <= Number.MAX_SAFE_INTEGER) {\n value = Number(value);\n }\n offset += 8;\n break;\n default: // no additional info\n value = additionalInfo;\n break;\n }\n return { majorType, value, offset };\n};\n\nexport const decodeVarInt = (\n data: Uint8Array,\n): { majorType: MajorType; value: CborNumber; offset: number } => {\n return decodeVarIntData(new DataView(data.buffer, data.byteOffset, data.byteLength), 0);\n};\n\nfunction getUint64(view: DataView, byteOffset: number, littleEndian: boolean): bigint {\n const lowWord = littleEndian\n ? view.getUint32(byteOffset, true)\n : view.getUint32(byteOffset + 4, false);\n const highWord = littleEndian\n ? view.getUint32(byteOffset + 4, true)\n : view.getUint32(byteOffset, false);\n return (BigInt(highWord) << BigInt(32)) + BigInt(lowWord);\n}\n","/**\n * String utilities for dCBOR, including Unicode normalization.\n *\n * @module string-util\n */\n\n/**\n * Flank a string with left and right strings.\n *\n * @param s - String to flank\n * @param left - Left flanking string\n * @param right - Right flanking string\n * @returns Flanked string\n */\nexport const flanked = (s: string, left: string, right: string): string => left + s + right;\n\n/**\n * Check if a character is printable.\n *\n * @param c - Character to check\n * @returns True if printable\n */\nexport const isPrintable = (c: string): boolean => {\n if (c.length !== 1) return false;\n const code = c.charCodeAt(0);\n // Non-ASCII or ASCII printable (32-126)\n return code > 127 || (code >= 32 && code <= 126);\n};\n\n/**\n * Sanitize a string by replacing non-printable characters with dots.\n * Returns None if the string has no printable characters.\n *\n * @param str - String to sanitize\n * @returns Sanitized string or undefined if no printable characters\n */\nexport const sanitized = (str: string): string | undefined => {\n let hasPrintable = false;\n const chars: string[] = [];\n\n for (const c of str) {\n if (isPrintable(c)) {\n hasPrintable = true;\n chars.push(c);\n } else {\n chars.push(\".\");\n }\n }\n\n if (!hasPrintable) {\n return undefined;\n }\n\n return chars.join(\"\");\n};\n","/**\n * Tag registry and management system.\n *\n * The TagsStore provides a centralized registry for CBOR tags,\n * including name resolution and custom summarizer functions.\n *\n * @module tags-store\n */\n\nimport type { Cbor, CborNumber } from \"./cbor\";\nimport type { Tag } from \"./tag\";\n\n/**\n * Function type for custom CBOR value summarizers.\n *\n * Summarizers provide custom string representations for tagged values.\n *\n * @param cbor - The CBOR value to summarize\n * @param flat - If true, produce single-line output\n * @returns String summary of the value\n */\nexport type CborSummarizer = (cbor: Cbor, flat: boolean) => string;\n\n/**\n * Interface for tag store operations.\n */\nexport interface TagsStoreTrait {\n /**\n * Get the assigned name for a tag, if any.\n *\n * @param tag - The tag to look up\n * @returns The assigned name, or undefined if no name is registered\n */\n assignedNameForTag(tag: Tag): string | undefined;\n\n /**\n * Get a display name for a tag.\n *\n * @param tag - The tag to get a name for\n * @returns The assigned name if available, otherwise the tag value as a string\n */\n nameForTag(tag: Tag): string;\n\n /**\n * Look up a tag by its numeric value.\n *\n * @param value - The numeric tag value\n * @returns The Tag object if found, undefined otherwise\n */\n tagForValue(value: CborNumber): Tag | undefined;\n\n /**\n * Look up a tag by its name.\n *\n * @param name - The tag name\n * @returns The Tag object if found, undefined otherwise\n */\n tagForName(name: string): Tag | undefined;\n\n /**\n * Get a display name for a tag value.\n *\n * @param value - The numeric tag value\n * @returns The tag name if registered, otherwise the value as a string\n */\n nameForValue(value: CborNumber): string;\n\n /**\n * Get a custom summarizer function for a tag, if registered.\n *\n * @param tag - The numeric tag value\n * @returns The summarizer function if registered, undefined otherwise\n */\n summarizer(tag: CborNumber): CborSummarizer | undefined;\n}\n\n/**\n * Tag registry implementation.\n *\n * Stores tags with their names and optional summarizer functions.\n */\nexport class TagsStore implements TagsStoreTrait {\n readonly #tagsByValue = new Map<string, Tag>();\n readonly #tagsByName = new Map<string, Tag>();\n readonly #summarizers = new Map<string, CborSummarizer>();\n\n constructor() {\n // Start with empty store, matching Rust's Default implementation\n // Tags must be explicitly registered using insert() or registerTags()\n }\n\n /**\n * Insert a tag into the registry.\n *\n * @param tag - The tag to register\n *\n * @example\n * ```typescript\n * const store = new TagsStore();\n * store.insert(createTag(12345, 'myCustomTag'));\n * ```\n */\n insert(tag: Tag): void {\n const key = this.#valueKey(tag.value);\n this.#tagsByValue.set(key, tag);\n if (tag.name !== undefined) {\n this.#tagsByName.set(tag.name, tag);\n }\n }\n\n /**\n * Insert multiple tags into the registry.\n * Matches Rust's insert_all() method.\n *\n * @param tags - Array of tags to register\n *\n * @example\n * ```typescript\n * const store = new TagsStore();\n * store.insertAll([\n * createTag(1, 'date'),\n * createTag(100, 'custom')\n * ]);\n * ```\n */\n insertAll(tags: Tag[]): void {\n for (const tag of tags) {\n this.insert(tag);\n }\n }\n\n /**\n * Register a custom summarizer function for a tag.\n *\n * @param tagValue - The numeric tag value\n * @param summarizer - The summarizer function\n *\n * @example\n * ```typescript\n * store.setSummarizer(1, (cbor, flat) => {\n * // Custom date formatting\n * return `Date(${extractCbor(cbor)})`;\n * });\n * ```\n */\n setSummarizer(tagValue: CborNumber, summarizer: CborSummarizer): void {\n const key = this.#valueKey(tagValue);\n this.#summarizers.set(key, summarizer);\n }\n\n /**\n * Remove a tag from the registry.\n *\n * @param tagValue - The numeric tag value to remove\n * @returns true if a tag was removed, false otherwise\n */\n remove(tagValue: CborNumber): boolean {\n const key = this.#valueKey(tagValue);\n const tag = this.#tagsByValue.get(key);\n if (tag === undefined) {\n return false;\n }\n\n this.#tagsByValue.delete(key);\n if (tag.name !== undefined) {\n this.#tagsByName.delete(tag.name);\n }\n this.#summarizers.delete(key);\n return true;\n }\n\n assignedNameForTag(tag: Tag): string | undefined {\n const key = this.#valueKey(tag.value);\n const stored = this.#tagsByValue.get(key);\n return stored?.name;\n }\n\n nameForTag(tag: Tag): string {\n return this.assignedNameForTag(tag) ?? tag.value.toString();\n }\n\n tagForValue(value: CborNumber): Tag | undefined {\n const key = this.#valueKey(value);\n return this.#tagsByValue.get(key);\n }\n\n tagForName(name: string): Tag | undefined {\n return this.#tagsByName.get(name);\n }\n\n nameForValue(value: CborNumber): string {\n const tag = this.tagForValue(value);\n return tag !== undefined ? this.nameForTag(tag) : value.toString();\n }\n\n summarizer(tag: CborNumber): CborSummarizer | undefined {\n const key = this.#valueKey(tag);\n return this.#summarizers.get(key);\n }\n\n /**\n * Get all registered tags.\n *\n * @returns Array of all registered tags\n */\n getAllTags(): Tag[] {\n return Array.from(this.#tagsByValue.values());\n }\n\n /**\n * Clear all registered tags and summarizers.\n */\n clear(): void {\n this.#tagsByValue.clear();\n this.#tagsByName.clear();\n this.#summarizers.clear();\n }\n\n /**\n * Get the number of registered tags.\n *\n * @returns Number of tags in the registry\n */\n get size(): number {\n return this.#tagsByValue.size;\n }\n\n /**\n * Create a string key for a numeric tag value.\n * Handles both number and bigint types.\n *\n * @private\n */\n #valueKey(value: CborNumber): string {\n return value.toString();\n }\n}\n\n// ============================================================================\n// Global Tags Store Singleton\n// ============================================================================\n\n/**\n * Global singleton instance of the tags store.\n */\nlet globalTagsStore: TagsStore | undefined;\n\n/**\n * Get the global tags store instance.\n *\n * Creates the instance on first access.\n *\n * @returns The global TagsStore instance\n *\n * @example\n * ```typescript\n * const store = getGlobalTagsStore();\n * store.insert(createTag(999, 'myTag'));\n * ```\n */\nexport const getGlobalTagsStore = (): TagsStore => {\n globalTagsStore ??= new TagsStore();\n return globalTagsStore;\n};\n\n/**\n * Execute a function with access to the global tags store.\n *\n * @template T - Return type of the action function\n * @param action - Function to execute with the tags store\n * @returns Result of the action function\n *\n * @example\n * ```typescript\n * const tagName = withTags(store => store.nameForValue(1));\n * console.log(tagName); // 'date'\n * ```\n */\nexport const withTags = <T>(action: (tags: TagsStore) => T): T => {\n return action(getGlobalTagsStore());\n};\n\n/**\n * Execute a function with mutable access to the global tags store.\n *\n * This is an alias for withTags() for consistency with Rust API.\n *\n * @template T - Return type of the action function\n * @param action - Function to execute with the tags store\n * @returns Result of the action function\n */\nexport const withTagsMut = <T>(action: (tags: TagsStore) => T): T => {\n return action(getGlobalTagsStore());\n};\n","/**\n * Hex dump utilities for CBOR data.\n *\n * Affordances for viewing the encoded binary representation of CBOR as hexadecimal.\n * Optionally annotates the output, breaking it up into semantically meaningful lines,\n * formatting dates, and adding names of known tags.\n *\n * @module dump\n */\n\nimport { type Cbor, MajorType, cborData } from \"./cbor\";\nimport { encodeVarInt } from \"./varint\";\nimport { flanked, sanitized } from \"./string-util\";\nimport type { TagsStore } from \"./tags-store\";\nimport { getGlobalTagsStore } from \"./tags-store\";\nimport { createTag } from \"./tag\";\nimport { CborError } from \"./error\";\n\n/**\n * Options for hex formatting.\n */\nexport interface HexFormatOpts {\n /** Whether to annotate the hex dump with semantic information */\n annotate?: boolean;\n /** Optional tags store for resolving tag names */\n tagsStore?: TagsStore;\n}\n\n/**\n * Convert bytes to hex string.\n */\nexport const bytesToHex = (bytes: Uint8Array): string => {\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, \"0\"))\n .join(\"\");\n};\n\n/**\n * Convert hex string to bytes.\n */\nexport const hexToBytes = (hexString: string): Uint8Array => {\n const hex = hexString.replace(/\\s/g, \"\");\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n bytes[i / 2] = parseInt(hex.slice(i, i + 2), 16);\n }\n return bytes;\n};\n\n/**\n * Returns the encoded hexadecimal representation of CBOR.\n *\n * @param cbor - CBOR value to convert\n * @returns Hex string\n */\nexport const hex = (cbor: Cbor): string => bytesToHex(cborData(cbor));\n\n/**\n * Returns the encoded hexadecimal representation of CBOR with options.\n *\n * Optionally annotates the output, e.g., breaking the output up into\n * semantically meaningful lines, formatting dates, and adding names of\n * known tags.\n *\n * @param cbor - CBOR value to convert\n * @param opts - Formatting options\n * @returns Hex string (possibly annotated)\n */\nexport const hexOpt = (cbor: Cbor, opts: HexFormatOpts = {}): string => {\n if (opts.annotate !== true) {\n return hex(cbor);\n }\n\n const items = dumpItems(cbor, 0, opts);\n const noteColumn = items.reduce((largest, item) => {\n return Math.max(largest, item.formatFirstColumn().length);\n }, 0);\n\n // Round up to nearest multiple of 4\n const roundedNoteColumn = ((noteColumn + 4) & ~3) - 1;\n\n const lines = items.map((item) => item.format(roundedNoteColumn));\n return lines.join(\"\\n\");\n};\n\n/**\n * Returns the encoded hexadecimal representation of CBOR, with annotations.\n *\n * @param cbor - CBOR value to convert\n * @param tagsStore - Optional tags store for tag name resolution\n * @returns Annotated hex string\n */\nexport const hexAnnotated = (cbor: Cbor, tagsStore?: TagsStore): string => {\n // Use global tags store if not provided\n tagsStore ??= getGlobalTagsStore();\n return hexOpt(cbor, { annotate: true, tagsStore });\n};\n\n/**\n * Internal structure for dump items.\n */\nclass DumpItem {\n constructor(\n public level: number,\n public data: Uint8Array[],\n public note?: string,\n ) {}\n\n format(noteColumn: number): string {\n const column1 = this.formatFirstColumn();\n let column2 = \"\";\n let padding = \"\";\n\n if (this.note !== undefined) {\n const paddingCount = Math.max(1, Math.min(39, noteColumn) - column1.length + 1);\n padding = \" \".repeat(paddingCount);\n column2 = `# ${this.note}`;\n }\n\n return column1 + padding + column2;\n }\n\n formatFirstColumn(): string {\n const indent = \" \".repeat(this.level * 4);\n const hexParts = this.data.map(bytesToHex).filter((x) => x.length > 0);\n const hexStr = hexParts.join(\" \");\n return indent + hexStr;\n }\n}\n\n/**\n * Generate dump items for a CBOR value (recursive).\n */\nfunction dumpItems(cbor: Cbor, level: number, opts: HexFormatOpts): DumpItem[] {\n const items: DumpItem[] = [];\n\n switch (cbor.type) {\n case MajorType.Unsigned: {\n const data = cborData(cbor);\n items.push(new DumpItem(level, [data], `unsigned(${cbor.value})`));\n break;\n }\n\n case MajorType.Negative: {\n const data = cborData(cbor);\n const actualValue = typeof cbor.value === \"bigint\" ? -1n - cbor.value : -1 - cbor.value;\n items.push(new DumpItem(level, [data], `negative(${actualValue})`));\n break;\n }\n\n case MajorType.ByteString: {\n const header = encodeVarInt(cbor.value.length, MajorType.ByteString);\n items.push(new DumpItem(level, [header], `bytes(${cbor.value.length})`));\n\n if (cbor.value.length > 0) {\n let note: string | undefined = undefined;\n // Try to decode as UTF-8 string for annotation\n try {\n const text = new TextDecoder(\"utf-8\", { fatal: true }).decode(cbor.value);\n const sanitizedText = sanitized(text);\n if (sanitizedText !== undefined && sanitizedText !== \"\") {\n note = flanked(sanitizedText, '\"', '\"');\n }\n } catch {\n // Not valid UTF-8, no annotation\n }\n\n items.push(new DumpItem(level + 1, [cbor.value], note));\n }\n break;\n }\n\n case MajorType.Text: {\n const utf8Data = new TextEncoder().encode(cbor.value);\n const header = encodeVarInt(utf8Data.length, MajorType.Text);\n const firstByte = header[0];\n if (firstByte === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Invalid varint encoding\" });\n }\n const headerData = [new Uint8Array([firstByte]), header.slice(1)];\n\n items.push(new DumpItem(level, headerData, `text(${utf8Data.length})`));\n\n items.push(new DumpItem(level + 1, [utf8Data], flanked(cbor.value, '\"', '\"')));\n break;\n }\n\n case MajorType.Array: {\n const header = encodeVarInt(cbor.value.length, MajorType.Array);\n const firstByte = header[0];\n if (firstByte === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Invalid varint encoding\" });\n }\n const headerData = [new Uint8Array([firstByte]), header.slice(1)];\n\n items.push(new DumpItem(level, headerData, `array(${cbor.value.length})`));\n\n for (const item of cbor.value) {\n items.push(...dumpItems(item, level + 1, opts));\n }\n break;\n }\n\n case MajorType.Map: {\n const header = encodeVarInt(cbor.value.size, MajorType.Map);\n const firstByte = header[0];\n if (firstByte === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Invalid varint encoding\" });\n }\n const headerData = [new Uint8Array([firstByte]), header.slice(1)];\n\n items.push(new DumpItem(level, headerData, `map(${cbor.value.size})`));\n\n for (const entry of cbor.value.entriesArray) {\n items.push(...dumpItems(entry.key, level + 1, opts));\n items.push(...dumpItems(entry.value, level + 1, opts));\n }\n break;\n }\n\n case MajorType.Tagged: {\n const tagValue = cbor.tag;\n if (tagValue === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Tagged CBOR value must have a tag\" });\n }\n const header = encodeVarInt(\n typeof tagValue === \"bigint\" ? Number(tagValue) : tagValue,\n MajorType.Tagged,\n );\n const firstByte = header[0];\n if (firstByte === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Invalid varint encoding\" });\n }\n const headerData = [new Uint8Array([firstByte]), header.slice(1)];\n\n const noteComponents: string[] = [`tag(${tagValue})`];\n\n // Add tag name if tags store is provided\n const numericTagValue = typeof tagValue === \"bigint\" ? Number(tagValue) : tagValue;\n const tag = createTag(numericTagValue);\n const tagName = opts.tagsStore?.assignedNameForTag(tag);\n if (tagName !== undefined) {\n noteComponents.push(tagName);\n }\n\n const tagNote = noteComponents.join(\" \");\n\n items.push(new DumpItem(level, headerData, tagNote));\n\n items.push(...dumpItems(cbor.value, level + 1, opts));\n break;\n }\n\n case MajorType.Simple: {\n const data = cborData(cbor);\n const simple = cbor.value;\n let note: string;\n\n if (simple.type === \"True\") {\n note = \"true\";\n } else if (simple.type === \"False\") {\n note = \"false\";\n } else if (simple.type === \"Null\") {\n note = \"null\";\n } else if (simple.type === \"Float\") {\n note = `${simple.value}`;\n } else {\n note = \"simple\";\n }\n\n items.push(new DumpItem(level, [data], note));\n break;\n }\n }\n\n return items;\n}\n","/**\n * Enhanced diagnostic formatting for CBOR values.\n *\n * Provides multiple formatting options including\n * - Annotated diagnostics with tag names\n * - Summarized values using custom summarizers\n * - Flat (single-line) vs. pretty (multi-line) formatting\n * - Configurable tag store usage\n *\n * @module diag\n */\n\nimport { type Cbor, MajorType, type Simple } from \"./cbor\";\nimport { bytesToHex } from \"./dump\";\nimport type { CborMap } from \"./map\";\nimport { getGlobalTagsStore, type TagsStore } from \"./tags-store\";\nimport type { Tag } from \"./tag\";\nimport type { WalkElement } from \"./walk\";\n\n/**\n * Options for diagnostic formatting.\n */\nexport interface DiagFormatOpts {\n /**\n * Add tag names as annotations.\n * When true, tagged values are displayed as \"tagName(content)\" instead of \"tagValue(content)\".\n *\n * @default false\n */\n annotate?: boolean;\n\n /**\n * Use custom summarizers for tagged values.\n * When true, calls registered summarizers for tagged values.\n *\n * @default false\n */\n summarize?: boolean;\n\n /**\n * Single-line (flat) output.\n * When true, arrays and maps are formatted without line breaks.\n *\n * @default false\n */\n flat?: boolean;\n\n /**\n * Tag store to use for tag name resolution.\n * - TagsStore instance: Use specific store\n * - 'global': Use global singleton store\n * - 'none': Don't use any store (show tag numbers)\n *\n * @default 'global'\n */\n tags?: TagsStore | \"global\" | \"none\";\n\n /**\n * Current indentation level (internal use for recursion).\n * @internal\n */\n indent?: number;\n\n /**\n * Indentation string (spaces per level).\n * @internal\n */\n indentString?: string;\n}\n\n/**\n * Default formatting options.\n */\nconst DEFAULT_OPTS = {\n annotate: false,\n summarize: false,\n flat: false,\n tags: \"global\" as const,\n indent: 0,\n indentString: \" \", // 4 spaces to match Rust\n} as const satisfies DiagFormatOpts;\n\n/**\n * Format CBOR value as diagnostic notation with options.\n *\n * @param cbor - CBOR value to format\n * @param opts - Formatting options\n * @returns Diagnostic string\n *\n * @example\n * ```typescript\n * const value = cbor({ name: 'Alice', age: 30 });\n * console.log(diagnosticOpt(value, { flat: true }));\n * // {\\\"name\\\": \\\"Alice\\\", \\\"age\\\": 30}\n *\n * const tagged = createTaggedCbor({ ... });\n * console.log(diagnosticOpt(tagged, { annotate: true }));\n * // date(1234567890)\n * ```\n */\nexport function diagnosticOpt(cbor: Cbor, opts?: DiagFormatOpts): string {\n const options = { ...DEFAULT_OPTS, ...opts };\n return formatDiagnostic(cbor, options);\n}\n\n/**\n * Format CBOR value as standard diagnostic notation.\n *\n * @param cbor - CBOR value to format\n * @returns Diagnostic string (pretty-printed with multiple lines for complex structures)\n *\n * @example\n * ```typescript\n * const value = cbor([1, 2, 3]);\n * console.log(diagnostic(value));\n * // For simple arrays: \"[1, 2, 3]\"\n * // For nested structures: multi-line formatted output\n * ```\n */\nexport function diagnostic(cbor: Cbor): string {\n return diagnosticOpt(cbor);\n}\n\n/**\n * Format CBOR value with tag name annotations.\n *\n * Tagged values are displayed with their registered names instead of numeric tags.\n *\n * @param cbor - CBOR value to format\n * @returns Annotated diagnostic string (pretty-printed format)\n *\n * @example\n * ```typescript\n * const date = CborDate.now().taggedCbor();\n * console.log(diagnosticAnnotated(date));\n * // date(1234567890) instead of 1(1234567890)\n * ```\n */\nexport function diagnosticAnnotated(cbor: Cbor): string {\n return diagnosticOpt(cbor, { annotate: true });\n}\n\n/**\n * Format CBOR value as flat (single-line) diagnostic notation.\n *\n * Arrays and maps are formatted without line breaks.\n *\n * @param cbor - CBOR value to format\n * @returns Flat diagnostic string\n *\n * @example\n * ```typescript\n * const nested = cbor([[1, 2], [3, 4]]);\n * console.log(diagnosticFlat(nested));\n * // \"[[1, 2], [3, 4]]\"\n * ```\n */\nexport function diagnosticFlat(cbor: Cbor): string;\n// eslint-disable-next-line no-redeclare\nexport function diagnosticFlat(element: WalkElement): string;\n// eslint-disable-next-line no-redeclare\nexport function diagnosticFlat(input: Cbor | WalkElement): string {\n // Check if it's a WalkElement by checking for 'type' property\n if (\n typeof input === \"object\" &&\n input !== null &&\n \"type\" in input &&\n (input.type === \"single\" || input.type === \"keyvalue\")\n ) {\n const element = input as WalkElement;\n if (element.type === \"single\") {\n return diagnosticOpt(element.cbor, { flat: true });\n } else {\n return `${diagnosticOpt(element.key, { flat: true })}: ${diagnosticOpt(element.value, { flat: true })}`;\n }\n }\n // Otherwise treat as Cbor\n return diagnosticOpt(input as Cbor, { flat: true });\n}\n\n/**\n * Format CBOR value using custom summarizers for tagged values.\n *\n * If a summarizer is registered for a tagged value, uses that instead of\n * showing the full content.\n *\n * @param cbor - CBOR value to format\n * @returns Summarized diagnostic string\n *\n * @example\n * ```typescript\n * // If a summarizer is registered for tag 123:\n * const tagged = cbor({ type: MajorType.Tagged, tag: 123, value: ... });\n * console.log(summary(tagged));\n * // \"custom-summary\" (instead of full content)\n * ```\n */\nexport function summary(cbor: Cbor): string {\n return diagnosticOpt(cbor, { summarize: true, flat: true });\n}\n\n/**\n * Internal recursive formatter.\n *\n * @internal\n */\nfunction formatDiagnostic(cbor: Cbor, opts: DiagFormatOpts): string {\n switch (cbor.type) {\n case MajorType.Unsigned:\n return formatUnsigned(cbor.value);\n\n case MajorType.Negative:\n return formatNegative(cbor.value);\n\n case MajorType.ByteString:\n return formatBytes(cbor.value);\n\n case MajorType.Text:\n return formatText(cbor.value);\n\n case MajorType.Array:\n return formatArray(cbor.value, opts);\n\n case MajorType.Map:\n return formatMap(cbor.value, opts);\n\n case MajorType.Tagged:\n return formatTagged(cbor.tag, cbor.value, opts);\n\n case MajorType.Simple:\n return formatSimple(cbor.value);\n }\n}\n\n/**\n * Format unsigned integer.\n */\nfunction formatUnsigned(value: number | bigint): string {\n return String(value);\n}\n\n/**\n * Format negative integer.\n */\nfunction formatNegative(value: number | bigint): string {\n // Value is stored as magnitude, convert to actual negative value for display\n if (typeof value === \"bigint\") {\n return String(-value - 1n);\n } else {\n return String(-value - 1);\n }\n}\n\n/**\n * Format byte string.\n */\nfunction formatBytes(value: Uint8Array): string {\n return `h'${bytesToHex(value)}'`;\n}\n\n/**\n * Format text string.\n */\nfunction formatText(value: string): string {\n // Escape special characters\n const escaped = value\n .replace(/\\\\/g, \"\\\\\\\\\")\n .replace(/\"/g, '\\\\\"')\n .replace(/\\n/g, \"\\\\n\")\n .replace(/\\r/g, \"\\\\r\")\n .replace(/\\t/g, \"\\\\t\");\n return `\"${escaped}\"`;\n}\n\n/**\n * Format array.\n */\nfunction formatArray(items: readonly Cbor[], opts: DiagFormatOpts): string {\n if (items.length === 0) {\n return \"[]\";\n }\n\n // Format items first to check their lengths\n const formatted = items.map((item) => formatDiagnostic(item, opts));\n\n // Decide between single-line and multi-line based on complexity\n const shouldUseMultiLine =\n opts.flat !== true &&\n (containsComplexStructure(items) ||\n formatted.join(\", \").length > 20 ||\n formatted.some((s) => s.length > 20));\n\n if (shouldUseMultiLine) {\n // Multi-line formatting\n const indent = opts.indent ?? 0;\n const indentStr = (opts.indentString ?? \" \").repeat(indent);\n const itemIndentStr = (opts.indentString ?? \" \").repeat(indent + 1);\n\n const formattedWithIndent = items.map((item) => {\n const childOpts = { ...opts, indent: indent + 1 };\n const itemStr = formatDiagnostic(item, childOpts);\n return `${itemIndentStr}${itemStr}`;\n });\n\n return `[\\n${formattedWithIndent.join(\",\\n\")}\\n${indentStr}]`;\n } else {\n // Single-line formatting\n return `[${formatted.join(\", \")}]`;\n }\n}\n\n/**\n * Check if items contain complex structures (arrays or maps).\n */\nfunction containsComplexStructure(items: readonly Cbor[]): boolean {\n return items.some((item) => item.type === MajorType.Array || item.type === MajorType.Map);\n}\n\n/**\n * Format map.\n */\nfunction formatMap(map: CborMap, opts: DiagFormatOpts): string {\n // Extract entries from CborMap or use empty array\n const entries = map?.entriesArray ?? [];\n\n if (entries.length === 0) {\n return \"{}\";\n }\n\n interface FormattedPair {\n key: string;\n value: string;\n }\n\n // Format each key-value pair\n const formattedPairs: FormattedPair[] = entries.map((entry: { key: Cbor; value: Cbor }) => ({\n key: formatDiagnostic(entry.key, opts),\n value: formatDiagnostic(entry.value, opts),\n }));\n\n // Decide between single-line and multi-line based on complexity\n const totalLength = formattedPairs.reduce(\n (sum: number, pair: FormattedPair) => sum + pair.key.length + pair.value.length + 2,\n 0,\n ); // +2 for \": \"\n\n const shouldUseMultiLine =\n opts.flat !== true &&\n (entries.some(\n (e: { key: Cbor; value: Cbor }) =>\n e.key.type === MajorType.Array ||\n e.key.type === MajorType.Map ||\n e.value.type === MajorType.Array ||\n e.value.type === MajorType.Map,\n ) ||\n totalLength > 40 ||\n entries.length > 3);\n\n if (shouldUseMultiLine) {\n // Multi-line formatting\n const indent = opts.indent ?? 0;\n const indentStr = (opts.indentString ?? \" \").repeat(indent);\n const itemIndentStr = (opts.indentString ?? \" \").repeat(indent + 1);\n\n const formattedEntries = formattedPairs.map((pair: FormattedPair) => {\n return `${itemIndentStr}${pair.key}:\\n${itemIndentStr}${pair.value}`;\n });\n\n return `{\\n${formattedEntries.join(\",\\n\")}\\n${indentStr}}`;\n } else {\n // Single-line formatting\n const pairs = formattedPairs.map((pair: FormattedPair) => `${pair.key}: ${pair.value}`);\n return `{${pairs.join(\", \")}}`;\n }\n}\n\n/**\n * Format tagged value.\n */\nfunction formatTagged(tag: number | bigint, content: Cbor, opts: DiagFormatOpts): string {\n // Check for summarizer first\n if (opts.summarize === true) {\n const store = resolveTagsStore(opts.tags);\n const summarizer = store?.summarizer(tag);\n if (summarizer !== undefined) {\n return summarizer(content, opts.flat ?? false);\n }\n }\n\n // Get tag name as comment if annotation is enabled\n let comment: string | undefined;\n if (opts.annotate === true) {\n const store = resolveTagsStore(opts.tags);\n const tagObj: Tag = { value: tag };\n const assignedName = store?.assignedNameForTag(tagObj);\n if (assignedName !== undefined) {\n comment = assignedName;\n }\n }\n\n // Always use tag number (not name) in the output\n const tagStr = String(tag);\n\n // Format content\n const contentStr = formatDiagnostic(content, opts);\n\n // Add comment if present\n const result = `${tagStr}(${contentStr})`;\n if (comment !== undefined) {\n return `${result} / ${comment} /`;\n }\n return result;\n}\n\n/**\n * Format simple value.\n */\nfunction formatSimple(value: Simple): string {\n // Handle discriminated union\n switch (value.type) {\n case \"True\":\n return \"true\";\n case \"False\":\n return \"false\";\n case \"Null\":\n return \"null\";\n case \"Float\":\n return formatFloat(value.value);\n }\n}\n\n/**\n * Format float value.\n */\nfunction formatFloat(value: number): string {\n if (isNaN(value)) {\n return \"NaN\";\n } else if (!isFinite(value)) {\n return value > 0 ? \"Infinity\" : \"-Infinity\";\n } else {\n // Show decimal point for clarity, unless already in scientific notation\n const str = String(value);\n // Scientific notation (contains 'e') or already has decimal point\n if (str.includes(\".\") || str.includes(\"e\")) {\n return str;\n }\n return `${str}.0`;\n }\n}\n\n/**\n * Resolve tags store from option.\n */\nfunction resolveTagsStore(tags?: TagsStore | \"global\" | \"none\"): TagsStore | undefined {\n if (tags === \"none\") {\n return undefined;\n } else if (tags === \"global\" || tags === undefined) {\n return getGlobalTagsStore();\n } else {\n return tags;\n }\n}\n","/**\n * CBOR Simple Values (Major Type 7).\n *\n * @module simple\n */\n\nimport { MajorType } from \"./cbor\";\nimport { encodeVarInt } from \"./varint\";\nimport { f64CborData } from \"./float\";\n\n/**\n * Represents CBOR simple values (major type 7).\n *\n * In CBOR, simple values are a special category that includes booleans (`true`\n * and `false`), `null`, and floating point numbers.\n *\n * Per Section 2.4 of the dCBOR specification, only these specific simple\n * values are valid in dCBOR. All other major type 7 values (such as undefined\n * or other simple values) are invalid and will be rejected by dCBOR decoders.\n *\n * When encoding floating point values, dCBOR follows specific numeric\n * reduction rules detailed in Section 2.3 of the dCBOR specification,\n * including\n * - Integral floating point values must be reduced to integers when possible\n * - NaN values must be normalized to the canonical form `f97e00`\n */\nexport type Simple =\n | { readonly type: \"False\" }\n | { readonly type: \"True\" }\n | { readonly type: \"Null\" }\n | { readonly type: \"Float\"; readonly value: number };\n\n/**\n * Returns the standard name of the simple value as a string.\n *\n * For `False`, `True`, and `Null`, this returns their lowercase string\n * representation. For `Float` values, it returns their numeric representation.\n */\nexport const simpleName = (simple: Simple): string => {\n switch (simple.type) {\n case \"False\":\n return \"false\";\n case \"True\":\n return \"true\";\n case \"Null\":\n return \"null\";\n case \"Float\": {\n const v = simple.value;\n if (Number.isNaN(v)) {\n return \"NaN\";\n } else if (!Number.isFinite(v)) {\n return v > 0 ? \"Infinity\" : \"-Infinity\";\n } else {\n return String(v);\n }\n }\n }\n};\n\n/**\n * Checks if the simple value is a floating point number.\n */\nexport const isFloat = (simple: Simple): simple is { type: \"Float\"; value: number } =>\n simple.type === \"Float\";\n\n/**\n * Checks if the simple value is the NaN (Not a Number) representation.\n */\nexport const isNaN = (simple: Simple): boolean =>\n simple.type === \"Float\" && Number.isNaN(simple.value);\n\n/**\n * Encodes the simple value to its raw CBOR byte representation.\n *\n * Returns the CBOR bytes that represent this simple value according to the\n * dCBOR deterministic encoding rules:\n * - `False` encodes as `0xf4`\n * - `True` encodes as `0xf5`\n * - `Null` encodes as `0xf6`\n * - `Float` values encode according to the IEEE 754 floating point rules,\n * using the shortest representation that preserves precision.\n */\nexport const simpleCborData = (simple: Simple): Uint8Array => {\n switch (simple.type) {\n case \"False\":\n return encodeVarInt(20, MajorType.Simple);\n case \"True\":\n return encodeVarInt(21, MajorType.Simple);\n case \"Null\":\n return encodeVarInt(22, MajorType.Simple);\n case \"Float\":\n return f64CborData(simple.value);\n }\n};\n\n/**\n * Compare two Simple values for equality.\n *\n * Two `Simple` values are equal if they're the same variant. For `Float`\n * variants, the contained floating point values are compared for equality,\n * with NaN values considered equal to each other.\n */\nexport const simpleEquals = (a: Simple, b: Simple): boolean => {\n if (a.type !== b.type) return false;\n\n switch (a.type) {\n case \"False\":\n case \"True\":\n case \"Null\":\n return true;\n case \"Float\": {\n const bFloat = b as { type: \"Float\"; value: number };\n const v1 = a.value;\n const v2 = bFloat.value;\n return v1 === v2 || (Number.isNaN(v1) && Number.isNaN(v2));\n }\n }\n};\n\n/**\n * Hash a Simple value.\n *\n * Matches Rust's Hash trait implementation.\n */\nexport const simpleHash = (simple: Simple): number => {\n // Simple FNV-1a hash\n let hash = 2166136261;\n\n switch (simple.type) {\n case \"False\":\n hash ^= 0;\n break;\n case \"True\":\n hash ^= 1;\n break;\n case \"Null\":\n hash ^= 2;\n break;\n case \"Float\": {\n // Hash the bit representation of the float\n const buffer = new ArrayBuffer(8);\n const view = new DataView(buffer);\n view.setFloat64(0, simple.value, true);\n for (let i = 0; i < 8; i++) {\n hash ^= view.getUint8(i);\n hash = Math.imul(hash, 16777619);\n }\n break;\n }\n }\n\n return hash >>> 0;\n};\n","import {\n type Cbor,\n type CborNumber,\n MajorType,\n isCbor,\n encodeCbor,\n cborData,\n attachMethods,\n} from \"./cbor\";\nimport { areBytesEqual } from \"./stdlib\";\nimport { binary16ToNumber, binary32ToNumber, binary64ToNumber } from \"./float\";\nimport { CborMap } from \"./map\";\nimport { CborError } from \"./error\";\n\nexport function decodeCbor(data: Uint8Array): Cbor {\n const { cbor, len } = decodeCborInternal(\n new DataView(data.buffer, data.byteOffset, data.byteLength),\n );\n const remaining = data.length - len;\n if (remaining !== 0) {\n throw new CborError({ type: \"UnusedData\", count: remaining });\n }\n return cbor;\n}\n\nfunction parseHeader(header: number): { majorType: MajorType; headerValue: number } {\n const majorType = (header >> 5) as MajorType;\n const headerValue = header & 31;\n return { majorType, headerValue };\n}\n\nfunction at(data: DataView, index: number): number {\n return data.getUint8(index);\n}\n\nfunction from(data: DataView, index: number): DataView {\n return new DataView(data.buffer, data.byteOffset + index);\n}\n\nfunction range(data: DataView, start: number, end: number): DataView {\n return new DataView(data.buffer, data.byteOffset + start, end - start);\n}\n\nfunction parseBytes(data: DataView, len: number): DataView {\n if (data.byteLength < len) {\n throw new CborError({ type: \"Underrun\" });\n }\n return range(data, 0, len);\n}\n\nfunction parseHeaderVarint(data: DataView): {\n majorType: MajorType;\n value: CborNumber;\n varIntLen: number;\n} {\n if (data.byteLength < 1) {\n throw new CborError({ type: \"Underrun\" });\n }\n\n const header = at(data, 0);\n const { majorType, headerValue } = parseHeader(header);\n const dataRemaining = data.byteLength - 1;\n let value: CborNumber;\n let varIntLen: number;\n if (headerValue <= 23) {\n value = headerValue;\n varIntLen = 1;\n } else if (headerValue === 24) {\n if (dataRemaining < 1) {\n throw new CborError({ type: \"Underrun\" });\n }\n value = at(data, 1);\n if (value < 24) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n varIntLen = 2;\n } else if (headerValue === 25) {\n if (dataRemaining < 2) {\n throw new CborError({ type: \"Underrun\" });\n }\n value = ((at(data, 1) << 8) | at(data, 2)) >>> 0;\n // Floats with header 0xf9 are allowed to have values <= 0xFF\n if (value <= 0xff && header !== 0xf9) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n varIntLen = 3;\n } else if (headerValue === 26) {\n if (dataRemaining < 4) {\n throw new CborError({ type: \"Underrun\" });\n }\n value = ((at(data, 1) << 24) | (at(data, 2) << 16) | (at(data, 3) << 8) | at(data, 4)) >>> 0;\n // Floats with header 0xfa are allowed to have values <= 0xFFFF\n if (value <= 0xffff && header !== 0xfa) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n varIntLen = 5;\n } else if (headerValue === 27) {\n if (dataRemaining < 8) {\n throw new CborError({ type: \"Underrun\" });\n }\n const a = BigInt(at(data, 1)) << 56n;\n const b = BigInt(at(data, 2)) << 48n;\n const c = BigInt(at(data, 3)) << 40n;\n const d = BigInt(at(data, 4)) << 32n;\n const e = BigInt(at(data, 5)) << 24n;\n const f = BigInt(at(data, 6)) << 16n;\n const g = BigInt(at(data, 7)) << 8n;\n const h = BigInt(at(data, 8));\n value = a | b | c | d | e | f | g | h;\n if (value <= Number.MAX_SAFE_INTEGER) {\n value = Number(value);\n }\n // Floats with header 0xfb are allowed to have values <= 0xFFFFFFFF\n if (value <= 0xffffffff && header !== 0xfb) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n varIntLen = 9;\n } else {\n throw new CborError({ type: \"UnsupportedHeaderValue\", value: headerValue });\n }\n return { majorType, value, varIntLen };\n}\n\nfunction decodeCborInternal(data: DataView): { cbor: Cbor; len: number } {\n if (data.byteLength < 1) {\n throw new CborError({ type: \"Underrun\" });\n }\n const { majorType, value, varIntLen } = parseHeaderVarint(data);\n switch (majorType) {\n case MajorType.Unsigned: {\n const cborObj = { isCbor: true, type: MajorType.Unsigned, value: value } as const;\n const cbor = attachMethods(cborObj);\n const buf = new Uint8Array(data.buffer, data.byteOffset, varIntLen);\n checkCanonicalEncoding(cbor, buf);\n return { cbor, len: varIntLen };\n }\n case MajorType.Negative: {\n // Store the magnitude as-is, matching Rust's representation\n // The decoded value is what gets encoded (not the actual negative number)\n const cborObj = { isCbor: true, type: MajorType.Negative, value: value } as const;\n const cbor = attachMethods(cborObj);\n const buf = new Uint8Array(data.buffer, data.byteOffset, varIntLen);\n checkCanonicalEncoding(cbor, buf);\n return { cbor, len: varIntLen };\n }\n case MajorType.ByteString: {\n const dataLen = value;\n if (typeof dataLen === \"bigint\") {\n throw new CborError({ type: \"OutOfRange\" });\n }\n const buf = parseBytes(from(data, varIntLen), dataLen);\n const bytes = new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);\n const cborObj = { isCbor: true, type: MajorType.ByteString, value: bytes } as const;\n return { cbor: attachMethods(cborObj), len: varIntLen + dataLen };\n }\n case MajorType.Text: {\n const textLen = value;\n if (typeof textLen === \"bigint\") {\n throw new CborError({ type: \"OutOfRange\" });\n }\n const textBuf = parseBytes(from(data, varIntLen), textLen);\n const text = new TextDecoder().decode(textBuf);\n // dCBOR requires all text strings to be in Unicode Normalization Form C (NFC)\n // Reject any strings that are not already in NFC form\n if (text.normalize(\"NFC\") !== text) {\n throw new CborError({ type: \"NonCanonicalString\" });\n }\n const cborObj = { isCbor: true, type: MajorType.Text, value: text } as const;\n return { cbor: attachMethods(cborObj), len: varIntLen + textLen };\n }\n case MajorType.Array: {\n let pos = varIntLen;\n const items: Cbor[] = [];\n for (let i = 0; i < value; i++) {\n const { cbor: item, len: itemLen } = decodeCborInternal(from(data, pos));\n items.push(item);\n pos += itemLen;\n }\n const cborObj = { isCbor: true, type: MajorType.Array, value: items } as const;\n return { cbor: attachMethods(cborObj), len: pos };\n }\n case MajorType.Map: {\n let pos = varIntLen;\n const map = new CborMap();\n for (let i = 0; i < value; i++) {\n const { cbor: key, len: keyLen } = decodeCborInternal(from(data, pos));\n pos += keyLen;\n const { cbor: value, len: valueLen } = decodeCborInternal(from(data, pos));\n pos += valueLen;\n map.setNext(key, value);\n }\n const cborObj = { isCbor: true, type: MajorType.Map, value: map } as const;\n return { cbor: attachMethods(cborObj), len: pos };\n }\n case MajorType.Tagged: {\n const { cbor: item, len: itemLen } = decodeCborInternal(from(data, varIntLen));\n const cborObj = { isCbor: true, type: MajorType.Tagged, tag: value, value: item } as const;\n return { cbor: attachMethods(cborObj), len: varIntLen + itemLen };\n }\n case MajorType.Simple:\n switch (varIntLen) {\n case 3: {\n const f = binary16ToNumber(new Uint8Array(data.buffer, data.byteOffset + 1, 2));\n checkCanonicalEncoding(f, new Uint8Array(data.buffer, data.byteOffset, varIntLen));\n const cborObj = {\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"Float\", value: f },\n } as const;\n return { cbor: attachMethods(cborObj), len: varIntLen };\n }\n case 5: {\n const f = binary32ToNumber(new Uint8Array(data.buffer, data.byteOffset + 1, 4));\n checkCanonicalEncoding(f, new Uint8Array(data.buffer, data.byteOffset, varIntLen));\n const cborObj = {\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"Float\", value: f },\n } as const;\n return { cbor: attachMethods(cborObj), len: varIntLen };\n }\n case 9: {\n const f = binary64ToNumber(new Uint8Array(data.buffer, data.byteOffset + 1, 8));\n checkCanonicalEncoding(f, new Uint8Array(data.buffer, data.byteOffset, varIntLen));\n const cborObj = {\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"Float\", value: f },\n } as const;\n return { cbor: attachMethods(cborObj), len: varIntLen };\n }\n default:\n switch (value) {\n case 20:\n return {\n cbor: attachMethods({\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"False\" },\n }),\n len: varIntLen,\n };\n case 21:\n return {\n cbor: attachMethods({\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"True\" },\n }),\n len: varIntLen,\n };\n case 22:\n return {\n cbor: attachMethods({\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"Null\" },\n }),\n len: varIntLen,\n };\n default:\n // Per dCBOR spec, only false/true/null/floats are valid\n throw new CborError({ type: \"InvalidSimpleValue\" });\n }\n }\n }\n}\n\nfunction checkCanonicalEncoding(cbor: Cbor | CborNumber, buf: Uint8Array): void {\n // If it's already a CBOR object, encode it directly\n // Otherwise treat it as a native value (for floats, etc.)\n const buf2 = isCbor(cbor) ? cborData(cbor) : encodeCbor(cbor);\n if (!areBytesEqual(buf, buf2)) {\n throw new CborError({ type: \"NonCanonicalNumeric\" });\n }\n}\n","/**\n * Convenience utilities for working with CBOR values.\n *\n * Provides type-safe helpers for checking types, extracting values,\n * and working with arrays, maps, and tagged values.\n *\n * @module conveniences\n */\n\nimport {\n type Cbor,\n MajorType,\n type CborNumber,\n type CborInput,\n type CborUnsignedType,\n type CborNegativeType,\n type CborByteStringType,\n type CborTextType,\n type CborArrayType,\n type CborMapType,\n type CborTaggedType,\n type CborSimpleType,\n type CborMethods,\n} from \"./cbor\";\nimport type { CborMap } from \"./map\";\nimport { isFloat as isSimpleFloat } from \"./simple\";\nimport { decodeCbor } from \"./decode\";\nimport { CborError } from \"./error\";\n\n// ============================================================================\n// Extraction\n// ============================================================================\n\n/**\n * Extract native JavaScript value from CBOR.\n * Converts CBOR types to their JavaScript equivalents.\n */\nexport const extractCbor = (cbor: Cbor | Uint8Array): unknown => {\n let c: Cbor;\n if (cbor instanceof Uint8Array) {\n c = decodeCbor(cbor);\n } else {\n c = cbor;\n }\n switch (c.type) {\n case MajorType.Unsigned:\n return c.value;\n case MajorType.Negative:\n if (typeof c.value === \"bigint\") {\n return -c.value - 1n;\n } else {\n return -c.value - 1;\n }\n case MajorType.ByteString:\n return c.value;\n case MajorType.Text:\n return c.value;\n case MajorType.Array:\n return c.value.map(extractCbor);\n case MajorType.Map:\n return c.value;\n case MajorType.Tagged:\n return c;\n case MajorType.Simple:\n if (c.value.type === \"True\") return true;\n if (c.value.type === \"False\") return false;\n if (c.value.type === \"Null\") return null;\n if (c.value.type === \"Float\") return c.value.value;\n return c;\n }\n return undefined;\n};\n\n// ============================================================================\n// Type Guards\n// ============================================================================\n\n/**\n * Check if CBOR value is an unsigned integer.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is unsigned integer\n *\n * @example\n * ```typescript\n * if (isUnsigned(value)) {\n * console.log('Unsigned:', value.value);\n * }\n * ```\n */\nexport const isUnsigned = (cbor: Cbor): cbor is CborUnsignedType & CborMethods => {\n return cbor.type === MajorType.Unsigned;\n};\n\n/**\n * Check if CBOR value is a negative integer.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is negative integer\n */\nexport const isNegative = (cbor: Cbor): cbor is CborNegativeType & CborMethods => {\n return cbor.type === MajorType.Negative;\n};\n\n/**\n * Check if CBOR value is any integer (unsigned or negative).\n *\n * @param cbor - CBOR value to check\n * @returns True if value is an integer\n */\nexport const isInteger = (\n cbor: Cbor,\n): cbor is (CborUnsignedType | CborNegativeType) & CborMethods => {\n return cbor.type === MajorType.Unsigned || cbor.type === MajorType.Negative;\n};\n\n/**\n * Check if CBOR value is a byte string.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is byte string\n */\nexport const isBytes = (cbor: Cbor): cbor is CborByteStringType & CborMethods => {\n return cbor.type === MajorType.ByteString;\n};\n\n/**\n * Check if CBOR value is a text string.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is text string\n */\nexport const isText = (cbor: Cbor): cbor is CborTextType & CborMethods => {\n return cbor.type === MajorType.Text;\n};\n\n/**\n * Check if CBOR value is an array.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is array\n */\nexport const isArray = (cbor: Cbor): cbor is CborArrayType & CborMethods => {\n return cbor.type === MajorType.Array;\n};\n\n/**\n * Check if CBOR value is a map.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is map\n */\nexport const isMap = (cbor: Cbor): cbor is CborMapType & CborMethods => {\n return cbor.type === MajorType.Map;\n};\n\n/**\n * Check if CBOR value is tagged.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is tagged\n */\nexport const isTagged = (cbor: Cbor): cbor is CborTaggedType & CborMethods => {\n return cbor.type === MajorType.Tagged;\n};\n\n/**\n * Check if CBOR value is a simple value.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is simple\n */\nexport const isSimple = (cbor: Cbor): cbor is CborSimpleType & CborMethods => {\n return cbor.type === MajorType.Simple;\n};\n\n/**\n * Check if CBOR value is a boolean (true or false).\n *\n * @param cbor - CBOR value to check\n * @returns True if value is boolean\n */\nexport const isBoolean = (\n cbor: Cbor,\n): cbor is CborSimpleType &\n CborMethods & { readonly value: { readonly type: \"False\" } | { readonly type: \"True\" } } => {\n if (cbor.type !== MajorType.Simple) {\n return false;\n }\n return cbor.value.type === \"False\" || cbor.value.type === \"True\";\n};\n\n/**\n * Check if CBOR value is null.\n *\n * @param cbor - CBOR value to check\n * @returns True if value is null\n */\nexport const isNull = (\n cbor: Cbor,\n): cbor is CborSimpleType & CborMethods & { readonly value: { readonly type: \"Null\" } } => {\n if (cbor.type !== MajorType.Simple) {\n return false;\n }\n return cbor.value.type === \"Null\";\n};\n\n/**\n * Check if CBOR value is a float (f16, f32, or f64).\n *\n * @param cbor - CBOR value to check\n * @returns True if value is float\n */\nexport const isFloat = (\n cbor: Cbor,\n): cbor is CborSimpleType &\n CborMethods & { readonly value: { readonly type: \"Float\"; readonly value: number } } => {\n if (cbor.type !== MajorType.Simple) {\n return false;\n }\n return isSimpleFloat(cbor.value);\n};\n\n// ============================================================================\n// Safe Extraction (returns undefined on type mismatch)\n// ============================================================================\n\n/**\n * Extract unsigned integer value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Unsigned integer or undefined\n */\nexport const asUnsigned = (cbor: Cbor): number | bigint | undefined => {\n if (cbor.type === MajorType.Unsigned) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract negative integer value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Negative integer or undefined\n */\nexport const asNegative = (cbor: Cbor): number | bigint | undefined => {\n if (cbor.type === MajorType.Negative) {\n // Convert stored magnitude back to actual negative value\n if (typeof cbor.value === \"bigint\") {\n return -cbor.value - 1n;\n } else {\n return -cbor.value - 1;\n }\n }\n return undefined;\n};\n\n/**\n * Extract any integer value (unsigned or negative) if type matches.\n *\n * @param cbor - CBOR value\n * @returns Integer or undefined\n */\nexport const asInteger = (cbor: Cbor): number | bigint | undefined => {\n if (cbor.type === MajorType.Unsigned) {\n return cbor.value;\n } else if (cbor.type === MajorType.Negative) {\n // Convert stored magnitude back to actual negative value\n if (typeof cbor.value === \"bigint\") {\n return -cbor.value - 1n;\n } else {\n return -cbor.value - 1;\n }\n }\n return undefined;\n};\n\n/**\n * Extract byte string value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Byte string or undefined\n */\nexport const asBytes = (cbor: Cbor): Uint8Array | undefined => {\n if (cbor.type === MajorType.ByteString) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract text string value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Text string or undefined\n */\nexport const asText = (cbor: Cbor): string | undefined => {\n if (cbor.type === MajorType.Text) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract array value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Array or undefined\n */\nexport const asArray = (cbor: Cbor): readonly Cbor[] | undefined => {\n if (cbor.type === MajorType.Array) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract map value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Map or undefined\n */\nexport const asMap = (cbor: Cbor): CborMap | undefined => {\n if (cbor.type === MajorType.Map) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract boolean value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Boolean or undefined\n */\nexport const asBoolean = (cbor: Cbor): boolean | undefined => {\n if (cbor.type !== MajorType.Simple) {\n return undefined;\n }\n if (cbor.value.type === \"True\") {\n return true;\n }\n if (cbor.value.type === \"False\") {\n return false;\n }\n return undefined;\n};\n\n/**\n * Extract float value if type matches.\n *\n * @param cbor - CBOR value\n * @returns Float or undefined\n */\nexport const asFloat = (cbor: Cbor): number | undefined => {\n if (cbor.type !== MajorType.Simple) {\n return undefined;\n }\n const simple = cbor.value;\n if (isSimpleFloat(simple)) {\n return simple.value;\n }\n return undefined;\n};\n\n/**\n * Extract any numeric value (integer or float).\n *\n * @param cbor - CBOR value\n * @returns Number or undefined\n */\nexport const asNumber = (cbor: Cbor): CborNumber | undefined => {\n if (cbor.type === MajorType.Unsigned) {\n return cbor.value;\n }\n if (cbor.type === MajorType.Negative) {\n // Convert stored magnitude back to actual negative value\n if (typeof cbor.value === \"bigint\") {\n return -cbor.value - 1n;\n } else {\n return -cbor.value - 1;\n }\n }\n if (cbor.type === MajorType.Simple) {\n const simple = cbor.value;\n if (isSimpleFloat(simple)) {\n return simple.value;\n }\n }\n return undefined;\n};\n\n// ============================================================================\n// Expectations (throw on type mismatch)\n// ============================================================================\n\n/**\n * Extract unsigned integer value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Unsigned integer\n * @throws {CborError} With type 'WrongType' if cbor is not an unsigned integer\n */\nexport const expectUnsigned = (cbor: Cbor): number | bigint => {\n const value = asUnsigned(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract negative integer value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Negative integer\n * @throws {CborError} With type 'WrongType' if cbor is not a negative integer\n */\nexport const expectNegative = (cbor: Cbor): number | bigint => {\n const value = asNegative(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract any integer value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Integer\n * @throws {CborError} With type 'WrongType' if cbor is not an integer\n */\nexport const expectInteger = (cbor: Cbor): number | bigint => {\n const value = asInteger(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract byte string value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Byte string\n * @throws {CborError} With type 'WrongType' if cbor is not a byte string\n */\nexport const expectBytes = (cbor: Cbor): Uint8Array => {\n const value = asBytes(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract text string value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Text string\n * @throws {CborError} With type 'WrongType' if cbor is not a text string\n */\nexport const expectText = (cbor: Cbor): string => {\n const value = asText(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract array value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Array\n * @throws {CborError} With type 'WrongType' if cbor is not an array\n */\nexport const expectArray = (cbor: Cbor): readonly Cbor[] => {\n const value = asArray(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract map value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Map\n * @throws {CborError} With type 'WrongType' if cbor is not a map\n */\nexport const expectMap = (cbor: Cbor): CborMap => {\n const value = asMap(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract boolean value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Boolean\n * @throws {CborError} With type 'WrongType' if cbor is not a boolean\n */\nexport const expectBoolean = (cbor: Cbor): boolean => {\n const value = asBoolean(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract float value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Float\n * @throws {CborError} With type 'WrongType' if cbor is not a float\n */\nexport const expectFloat = (cbor: Cbor): number => {\n const value = asFloat(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n/**\n * Extract any numeric value, throwing if type doesn't match.\n *\n * @param cbor - CBOR value\n * @returns Number\n * @throws {CborError} With type 'WrongType' if cbor is not a number\n */\nexport const expectNumber = (cbor: Cbor): CborNumber => {\n const value = asNumber(cbor);\n if (value === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return value;\n};\n\n// ============================================================================\n// Array Operations\n// ============================================================================\n\n/**\n * Get array item at index.\n *\n * @param cbor - CBOR value (must be array)\n * @param index - Array index\n * @returns Item at index or undefined\n */\nexport const arrayItem = (cbor: Cbor, index: number): Cbor | undefined => {\n if (cbor.type !== MajorType.Array) {\n return undefined;\n }\n const array = cbor.value;\n if (index < 0 || index >= array.length) {\n return undefined;\n }\n return array[index];\n};\n\n/**\n * Get array length.\n *\n * @param cbor - CBOR value (must be array)\n * @returns Array length or undefined\n */\nexport const arrayLength = (cbor: Cbor): number | undefined => {\n if (cbor.type !== MajorType.Array) {\n return undefined;\n }\n return cbor.value.length;\n};\n\n/**\n * Check if array is empty.\n *\n * @param cbor - CBOR value (must be array)\n * @returns True if empty, false if not empty, undefined if not array\n */\nexport const arrayIsEmpty = (cbor: Cbor): boolean | undefined => {\n if (cbor.type !== MajorType.Array) {\n return undefined;\n }\n return cbor.value.length === 0;\n};\n\n// ============================================================================\n// Map Operations\n// ============================================================================\n\n/**\n * Get map value by key.\n *\n * @param cbor - CBOR value (must be map)\n * @param key - Map key\n * @returns Value for key or undefined\n */\nexport function mapValue<K extends CborInput, V>(cbor: Cbor, key: K): V | undefined {\n if (cbor.type !== MajorType.Map) {\n return undefined;\n }\n return cbor.value.get<K, V>(key);\n}\n\n/**\n * Check if map has key.\n *\n * @param cbor - CBOR value (must be map)\n * @param key - Map key\n * @returns True if key exists, false otherwise, undefined if not map\n */\nexport function mapHas<K extends CborInput>(cbor: Cbor, key: K): boolean | undefined {\n if (cbor.type !== MajorType.Map) {\n return undefined;\n }\n return cbor.value.has(key);\n}\n\n/**\n * Get all map keys.\n *\n * @param cbor - CBOR value (must be map)\n * @returns Array of keys or undefined\n */\nexport const mapKeys = (cbor: Cbor): Cbor[] | undefined => {\n if (cbor.type !== MajorType.Map) {\n return undefined;\n }\n return cbor.value.entriesArray.map((e) => e.key);\n};\n\n/**\n * Get all map values.\n *\n * @param cbor - CBOR value (must be map)\n * @returns Array of values or undefined\n */\nexport const mapValues = (cbor: Cbor): Cbor[] | undefined => {\n if (cbor.type !== MajorType.Map) {\n return undefined;\n }\n return cbor.value.entriesArray.map((e) => e.value);\n};\n\n/**\n * Get map size.\n *\n * @param cbor - CBOR value (must be map)\n * @returns Map size or undefined\n */\nexport const mapSize = (cbor: Cbor): number | undefined => {\n if (cbor.type !== MajorType.Map) {\n return undefined;\n }\n return cbor.value.size;\n};\n\n/**\n * Check if map is empty.\n *\n * @param cbor - CBOR value (must be map)\n * @returns True if empty, false if not empty, undefined if not map\n */\nexport const mapIsEmpty = (cbor: Cbor): boolean | undefined => {\n if (cbor.type !== MajorType.Map) {\n return undefined;\n }\n return cbor.value.size === 0;\n};\n\n// ============================================================================\n// Tagged Value Operations\n// ============================================================================\n\n/**\n * Get tag value from tagged CBOR.\n *\n * @param cbor - CBOR value (must be tagged)\n * @returns Tag value or undefined\n */\nexport const tagValue = (cbor: Cbor): number | bigint | undefined => {\n if (cbor.type !== MajorType.Tagged) {\n return undefined;\n }\n return cbor.tag;\n};\n\n/**\n * Get content from tagged CBOR.\n *\n * @param cbor - CBOR value (must be tagged)\n * @returns Tagged content or undefined\n */\nexport const tagContent = (cbor: Cbor): Cbor | undefined => {\n if (cbor.type !== MajorType.Tagged) {\n return undefined;\n }\n return cbor.value;\n};\n\n/**\n * Check if CBOR has a specific tag.\n *\n * @param cbor - CBOR value\n * @param tag - Tag value to check\n * @returns True if has tag, false otherwise\n */\nexport const hasTag = (cbor: Cbor, tag: number | bigint): boolean => {\n if (cbor.type !== MajorType.Tagged) {\n return false;\n }\n return cbor.tag === tag;\n};\n\n/**\n * Extract content if has specific tag.\n *\n * @param cbor - CBOR value\n * @param tag - Expected tag value\n * @returns Tagged content or undefined\n */\nexport const getTaggedContent = (cbor: Cbor, tag: number | bigint): Cbor | undefined => {\n if (cbor.type === MajorType.Tagged && cbor.tag === tag) {\n return cbor.value;\n }\n return undefined;\n};\n\n/**\n * Extract content if has specific tag, throwing if not.\n *\n * @param cbor - CBOR value\n * @param tag - Expected tag value\n * @returns Tagged content\n * @throws {CborError} With type 'WrongType' if cbor is not tagged with the expected tag\n */\nexport const expectTaggedContent = (cbor: Cbor, tag: number | bigint): Cbor => {\n const content = getTaggedContent(cbor, tag);\n if (content === undefined) {\n throw new CborError({ type: \"WrongType\" });\n }\n return content;\n};\n\n// ============================================================================\n// Envelope Compatibility Functions\n// These functions provide the API expected by the envelope package\n// ============================================================================\n\nimport type { Tag } from \"./tag\";\n\n/**\n * Extract tagged value as tuple [Tag, Cbor] if CBOR is tagged.\n * This is used by envelope for decoding.\n *\n * @param cbor - CBOR value\n * @returns [Tag, Cbor] tuple or undefined\n */\nexport const asTaggedValue = (cbor: Cbor): [Tag, Cbor] | undefined => {\n if (cbor.type !== MajorType.Tagged) {\n return undefined;\n }\n const tag: Tag = { value: cbor.tag, name: `tag-${cbor.tag}` };\n return [tag, cbor.value];\n};\n\n/**\n * Alias for asBytes - extract byte string value if type matches.\n * Named asByteString for envelope compatibility.\n *\n * @param cbor - CBOR value\n * @returns Byte string or undefined\n */\nexport const asByteString = asBytes;\n\n/**\n * A wrapper around CBOR arrays that provides a get(index) method\n * for envelope compatibility.\n */\nexport interface CborArrayWrapper {\n readonly length: number;\n get(index: number): Cbor | undefined;\n [Symbol.iterator](): Iterator<Cbor>;\n}\n\n/**\n * Extract array value with get() method for envelope compatibility.\n *\n * @param cbor - CBOR value\n * @returns Array wrapper with get() method or undefined\n */\nexport const asCborArray = (cbor: Cbor): CborArrayWrapper | undefined => {\n if (cbor.type !== MajorType.Array) {\n return undefined;\n }\n const arr = cbor.value;\n return {\n length: arr.length,\n get(index: number): Cbor | undefined {\n return arr[index];\n },\n [Symbol.iterator](): Iterator<Cbor> {\n return arr[Symbol.iterator]();\n },\n };\n};\n\n/**\n * Alias for asMap - extract map value if type matches.\n * Named asCborMap for envelope compatibility.\n *\n * @param cbor - CBOR value\n * @returns Map or undefined\n */\nexport const asCborMap = asMap;\n\n/**\n * Check if CBOR value is any numeric type (unsigned, negative, or float).\n *\n * @param cbor - CBOR value\n * @returns True if value is numeric\n */\nexport const isNumber = (cbor: Cbor): boolean => {\n if (cbor.type === MajorType.Unsigned || cbor.type === MajorType.Negative) {\n return true;\n }\n if (cbor.type === MajorType.Simple) {\n return isSimpleFloat(cbor.value);\n }\n return false;\n};\n","/**\n * Map Support in dCBOR\n *\n * A deterministic CBOR map implementation that ensures maps with the same\n * content always produce identical binary encodings, regardless of insertion\n * order.\n *\n * ## Deterministic Map Representation\n *\n * The `CborMap` type follows strict deterministic encoding rules as specified by\n * dCBOR:\n *\n * - Map keys are always sorted in lexicographic order of their encoded CBOR bytes\n * - Duplicate keys are not allowed (enforced by the implementation)\n * - Keys and values can be any type that can be converted to CBOR\n * - Numeric reduction is applied (e.g., 3.0 is stored as integer 3)\n *\n * This deterministic encoding ensures that equivalent maps always produce\n * identical byte representations, which is crucial for applications that rely\n * on consistent hashing, digital signatures, or other cryptographic operations.\n *\n * @module map\n */\n\nimport { SortedMap } from \"collections/sorted-map\";\nimport { type Cbor, type CborInput, MajorType } from \"./cbor\";\nimport { cbor, cborData, encodeCbor } from \"./cbor\";\nimport { areBytesEqual, lexicographicallyCompareBytes } from \"./stdlib\";\nimport { bytesToHex } from \"./dump\";\nimport { diagnostic } from \"./diag\";\nimport { extractCbor } from \"./conveniences\";\nimport { CborError } from \"./error\";\n\ntype MapKey = Uint8Array;\nexport interface MapEntry {\n readonly key: Cbor;\n readonly value: Cbor;\n}\n\n/**\n * A deterministic CBOR map implementation.\n *\n * Maps are always encoded with keys sorted lexicographically by their\n * encoded CBOR representation, ensuring deterministic encoding.\n */\nexport class CborMap {\n #dict: SortedMap<MapKey, MapEntry>;\n\n /**\n * Creates a new, empty CBOR Map.\n * Optionally initializes from a JavaScript Map.\n */\n constructor(map?: Map<unknown, unknown>) {\n this.#dict = new SortedMap(null, areBytesEqual, lexicographicallyCompareBytes);\n\n if (map !== undefined) {\n for (const [key, value] of map.entries()) {\n this.set(key as CborInput, value as CborInput);\n }\n }\n }\n\n /**\n * Creates a new, empty CBOR Map.\n * Matches Rust's Map::new().\n */\n static new(): CborMap {\n return new CborMap();\n }\n\n /**\n * Inserts a key-value pair into the map.\n * Matches Rust's Map::insert().\n */\n set<K extends CborInput, V extends CborInput>(key: K, value: V): void {\n const keyCbor = cbor(key);\n const valueCbor = cbor(value);\n const keyData = cborData(keyCbor);\n this.#dict.set(keyData, { key: keyCbor, value: valueCbor });\n }\n\n /**\n * Alias for set() to match Rust's insert() method.\n */\n insert<K extends CborInput, V extends CborInput>(key: K, value: V): void {\n this.set(key, value);\n }\n\n #makeKey<K extends CborInput>(key: K): MapKey {\n const keyCbor = cbor(key);\n return cborData(keyCbor);\n }\n\n /**\n * Get a value from the map, given a key.\n * Returns undefined if the key is not present in the map.\n * Matches Rust's Map::get().\n */\n get<K extends CborInput, V>(key: K): V | undefined {\n const keyData = this.#makeKey(key);\n const value = this.#dict.get(keyData);\n if (value === undefined) {\n return undefined;\n }\n // Extract CBOR value: primitives become native types, maps/arrays preserve structure\n return extractCbor(value.value) as V;\n }\n\n /**\n * Get a value from the map, given a key.\n * Throws an error if the key is not present.\n * Matches Rust's Map::extract().\n */\n extract<K extends CborInput, V>(key: K): V {\n const value = this.get<K, V>(key);\n if (value === undefined) {\n throw new CborError({ type: \"MissingMapKey\" });\n }\n return value;\n }\n\n /**\n * Tests if the map contains a key.\n * Matches Rust's Map::contains_key().\n */\n containsKey<K extends CborInput>(key: K): boolean {\n const keyData = this.#makeKey(key);\n return this.#dict.has(keyData);\n }\n\n delete<K extends CborInput>(key: K): boolean {\n const keyData = this.#makeKey(key);\n const existed = this.#dict.has(keyData);\n this.#dict.delete(keyData);\n return existed;\n }\n\n has<K extends CborInput>(key: K): boolean {\n const keyData = this.#makeKey(key);\n return this.#dict.has(keyData);\n }\n\n clear(): void {\n this.#dict = new SortedMap(null, areBytesEqual, lexicographicallyCompareBytes);\n }\n\n /**\n * Returns the number of entries in the map.\n * Matches Rust's Map::len().\n */\n get length(): number {\n return this.#dict.length;\n }\n\n /**\n * Alias for length to match JavaScript Map API.\n * Also matches Rust's Map::len().\n */\n get size(): number {\n return this.#dict.length;\n }\n\n /**\n * Returns the number of entries in the map.\n * Matches Rust's Map::len().\n */\n len(): number {\n return this.#dict.length;\n }\n\n /**\n * Checks if the map is empty.\n * Matches Rust's Map::is_empty().\n */\n isEmpty(): boolean {\n return this.#dict.length === 0;\n }\n\n /**\n * Get the entries of the map as an array.\n * Keys are sorted in lexicographic order of their encoded CBOR bytes.\n */\n get entriesArray(): MapEntry[] {\n return this.#dict.map((value: MapEntry, _key: MapKey) => ({\n key: value.key,\n value: value.value,\n }));\n }\n\n /**\n * Gets an iterator over the entries of the CBOR map, sorted by key.\n * Key sorting order is lexicographic by the key's binary-encoded CBOR.\n * Matches Rust's Map::iter().\n */\n iter(): MapEntry[] {\n return this.entriesArray;\n }\n\n /**\n * Returns an iterator of [key, value] tuples for JavaScript Map API compatibility.\n * This matches the standard JavaScript Map.entries() method behavior.\n */\n *entries(): IterableIterator<[Cbor, Cbor]> {\n for (const entry of this.entriesArray) {\n yield [entry.key, entry.value];\n }\n }\n\n /**\n * Inserts the next key-value pair into the map during decoding.\n * This is used for efficient map building during CBOR decoding.\n * Throws if the key is not in ascending order or is a duplicate.\n * Matches Rust's Map::insert_next().\n */\n setNext<K extends CborInput, V extends CborInput>(key: K, value: V): void {\n const lastEntry = this.#dict.max();\n if (lastEntry === undefined) {\n this.set(key, value);\n return;\n }\n const keyCbor = cbor(key);\n const newKey = cborData(keyCbor);\n if (this.#dict.has(newKey)) {\n throw new CborError({ type: \"DuplicateMapKey\" });\n }\n const lastEntryKey = this.#makeKey(lastEntry.key);\n if (lexicographicallyCompareBytes(newKey, lastEntryKey) <= 0) {\n throw new CborError({ type: \"MisorderedMapKey\" });\n }\n this.#dict.set(newKey, { key: keyCbor, value: cbor(value) });\n }\n\n get debug(): string {\n return `map({${this.entriesArray.map(CborMap.entryDebug).join(\", \")}})`;\n }\n\n get diagnostic(): string {\n return `{${this.entriesArray.map(CborMap.entryDiagnostic).join(\", \")}}`;\n }\n\n private static entryDebug(this: void, entry: MapEntry): string {\n // Format with full type information for debug output\n const keyDebug = CborMap.formatDebug(entry.key);\n const valueDebug = CborMap.formatDebug(entry.value);\n return `0x${bytesToHex(encodeCbor(entry.key))}: (${keyDebug}, ${valueDebug})`;\n }\n\n private static formatDebug(this: void, cbor: Cbor): string {\n switch (cbor.type) {\n case MajorType.Unsigned:\n return `unsigned(${cbor.value})`;\n case MajorType.Negative: {\n const negValue = typeof cbor.value === \"bigint\" ? -cbor.value - 1n : -cbor.value - 1;\n return `negative(${negValue})`;\n }\n case MajorType.ByteString: {\n return `bytes(${bytesToHex(cbor.value)})`;\n }\n case MajorType.Text:\n return `text(\"${cbor.value}\")`;\n case MajorType.Array: {\n const items = cbor.value.map(CborMap.formatDebug);\n return `array([${items.join(\", \")}])`;\n }\n case MajorType.Map: {\n return cbor.value.debug;\n }\n case MajorType.Tagged:\n return `tagged(${cbor.tag}, ${CborMap.formatDebug(cbor.value)})`;\n case MajorType.Simple: {\n const simple = cbor.value;\n if (typeof simple === \"object\" && simple !== null && \"type\" in simple) {\n switch (simple.type) {\n case \"True\":\n return \"simple(true)\";\n case \"False\":\n return \"simple(false)\";\n case \"Null\":\n return \"simple(null)\";\n case \"Float\":\n return `simple(${simple.value})`;\n }\n }\n return \"simple\";\n }\n default:\n return diagnostic(cbor);\n }\n }\n\n private static entryDiagnostic(this: void, entry: MapEntry): string {\n return `${diagnostic(entry.key)}: ${diagnostic(entry.value)}`;\n }\n\n *[Symbol.iterator](): Iterator<[Cbor, Cbor]> {\n for (const entry of this.entriesArray) {\n yield [entry.key, entry.value];\n }\n }\n\n toMap<K, V>(): Map<K, V> {\n const map = new Map<K, V>();\n for (const entry of this.entriesArray) {\n map.set(extractCbor(entry.key) as K, extractCbor(entry.value) as V);\n }\n return map;\n }\n}\n","/**\n * Tree traversal system for CBOR data structures.\n *\n * This module provides a visitor pattern implementation for traversing\n * CBOR trees, allowing users to inspect and process elements at any depth.\n *\n * @module walk\n */\n\nimport {\n type Cbor,\n MajorType,\n type CborMapType,\n type CborArrayType,\n type CborTaggedType,\n} from \"./cbor\";\nimport { CborError } from \"./error\";\n\n/**\n * Types of edges in the CBOR tree traversal.\n */\nexport enum EdgeType {\n /** No specific edge type (root element) */\n None = \"none\",\n /** Element within an array */\n ArrayElement = \"array_element\",\n /** Key-value pair in a map (semantic unit) */\n MapKeyValue = \"map_key_value\",\n /** Key within a map */\n MapKey = \"map_key\",\n /** Value within a map */\n MapValue = \"map_value\",\n /** Content of a tagged value */\n TaggedContent = \"tagged_content\",\n}\n\n/**\n * Discriminated union for edge type information.\n */\nexport type EdgeTypeVariant =\n | { type: EdgeType.None }\n | { type: EdgeType.ArrayElement; index: number }\n | { type: EdgeType.MapKeyValue }\n | { type: EdgeType.MapKey }\n | { type: EdgeType.MapValue }\n | { type: EdgeType.TaggedContent };\n\n/**\n * Returns a short text label for the edge type, or undefined if no label is needed.\n *\n * This is primarily used for tree formatting to identify relationships between elements.\n *\n * @param edge - The edge type variant to get a label for\n * @returns Short label string, or undefined for None edge type\n *\n * @example\n * ```typescript\n * edgeLabel({ type: EdgeType.ArrayElement, index: 0 }); // Returns \"arr[0]\"\n * edgeLabel({ type: EdgeType.MapKeyValue }); // Returns \"kv\"\n * edgeLabel({ type: EdgeType.MapKey }); // Returns \"key\"\n * edgeLabel({ type: EdgeType.MapValue }); // Returns \"val\"\n * edgeLabel({ type: EdgeType.TaggedContent }); // Returns \"content\"\n * edgeLabel({ type: EdgeType.None }); // Returns undefined\n * ```\n */\nexport const edgeLabel = (edge: EdgeTypeVariant): string | undefined => {\n switch (edge.type) {\n case EdgeType.ArrayElement:\n return `arr[${edge.index}]`;\n case EdgeType.MapKeyValue:\n return \"kv\";\n case EdgeType.MapKey:\n return \"key\";\n case EdgeType.MapValue:\n return \"val\";\n case EdgeType.TaggedContent:\n return \"content\";\n case EdgeType.None:\n return undefined;\n }\n};\n\n/**\n * Element visited during tree traversal.\n * Can be either a single CBOR value or a key-value pair from a map.\n */\nexport type WalkElement =\n | { type: \"single\"; cbor: Cbor }\n | { type: \"keyvalue\"; key: Cbor; value: Cbor };\n\n/**\n * Helper functions for WalkElement\n */\n\n/**\n * Returns the single CBOR element if this is a 'single' variant.\n *\n * @param element - The walk element to extract from\n * @returns The CBOR value if single, undefined otherwise\n *\n * @example\n * ```typescript\n * const element: WalkElement = { type: 'single', cbor: someCbor };\n * const cbor = asSingle(element); // Returns someCbor\n * ```\n */\nexport const asSingle = (element: WalkElement): Cbor | undefined => {\n return element.type === \"single\" ? element.cbor : undefined;\n};\n\n/**\n * Returns the key-value pair if this is a 'keyvalue' variant.\n *\n * @param element - The walk element to extract from\n * @returns Tuple of [key, value] if keyvalue, undefined otherwise\n *\n * @example\n * ```typescript\n * const element: WalkElement = { type: 'keyvalue', key: keyValue, value: valValue };\n * const pair = asKeyValue(element); // Returns [keyValue, valValue]\n * ```\n */\nexport const asKeyValue = (element: WalkElement): [Cbor, Cbor] | undefined => {\n return element.type === \"keyvalue\" ? [element.key, element.value] : undefined;\n};\n\n/**\n * Visitor function type with state threading.\n *\n * @template State - The type of state passed through the traversal\n * @param element - The element being visited\n * @param level - The depth level in the tree (0 = root)\n * @param edge - Information about the edge leading to this element\n * @param state - Current state value\n * @returns Tuple of [newState, stopDescent] where:\n * - newState: The updated state to pass to subsequent visits\n * - stopDescent: If true, don't descend into children of this element\n */\nexport type Visitor<State> = (\n element: WalkElement,\n level: number,\n edge: EdgeTypeVariant,\n state: State,\n) => [State, boolean];\n\n/**\n * Walk a CBOR tree, visiting each element with a visitor function.\n *\n * The visitor function is called for each element in the tree, in depth-first order.\n * State is threaded through the traversal, allowing accumulation of results.\n *\n * For maps, the visitor is called with:\n * 1. A 'keyvalue' element containing both key and value\n * 2. The key individually (if descent wasn't stopped)\n * 3. The value individually (if descent wasn't stopped)\n *\n * @template State - The type of state to thread through the traversal\n * @param cbor - The CBOR value to traverse\n * @param initialState - Initial state value\n * @param visitor - Function to call for each element\n * @returns Final state after traversal\n *\n * @example\n * ```typescript\n * // Count all text strings in a structure\n * interface CountState { count: number }\n *\n * const structure = cbor({ name: 'Alice', tags: ['urgent', 'draft'] });\n * const result = walk(structure, { count: 0 }, (element, level, edge, state) => {\n * if (element.type === 'single' && element.cbor.type === MajorType.Text) {\n * return [{ count: state.count + 1 }, false];\n * }\n * return [state, false];\n * });\n * console.log(result.count); // 3 (name, urgent, draft)\n * ```\n *\n * @example\n * ```typescript\n * // Find first occurrence and stop\n * const structure = cbor([1, 2, 3, 'found', 5, 6]);\n * let found = false;\n *\n * walk(structure, null, (element, level, edge) => {\n * if (element.type === 'single' &&\n * element.cbor.type === MajorType.Text &&\n * element.cbor.value === 'found') {\n * found = true;\n * return [null, true]; // Stop descending\n * }\n * return [null, false];\n * });\n * ```\n */\nexport const walk = <State>(cbor: Cbor, initialState: State, visitor: Visitor<State>): State => {\n return walkInternal(cbor, 0, { type: EdgeType.None }, initialState, visitor);\n};\n\n/**\n * Internal recursive walk implementation.\n *\n * @internal\n */\nfunction walkInternal<State>(\n cbor: Cbor,\n level: number,\n edge: EdgeTypeVariant,\n state: State,\n visitor: Visitor<State>,\n skipVisit = false,\n): State {\n let currentState = state;\n let stopDescent = false;\n\n // Visit the current element (unless skipVisit is true)\n if (!skipVisit) {\n const element: WalkElement = { type: \"single\", cbor };\n const [newState, stop] = visitor(element, level, edge, currentState);\n currentState = newState;\n stopDescent = stop;\n\n // If visitor says to stop descending, return immediately\n if (stopDescent) {\n return currentState;\n }\n }\n\n // Recursively visit children based on CBOR type\n // Only container types (Array, Map, Tagged) need special handling; leaf nodes use default\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (cbor.type) {\n case MajorType.Array:\n currentState = walkArray(cbor, level, currentState, visitor);\n break;\n\n case MajorType.Map:\n currentState = walkMap(cbor, level, currentState, visitor);\n break;\n\n case MajorType.Tagged:\n currentState = walkTagged(cbor, level, currentState, visitor);\n break;\n\n // Leaf nodes: Unsigned, Negative, Bytes, Text, Simple\n default:\n // No children to visit\n break;\n }\n\n return currentState;\n}\n\n/**\n * Walk an array's elements.\n *\n * @internal\n */\nfunction walkArray<State>(\n cbor: CborArrayType,\n level: number,\n state: State,\n visitor: Visitor<State>,\n): State {\n let currentState = state;\n\n for (let index = 0; index < cbor.value.length; index++) {\n const item = cbor.value[index];\n if (item === undefined) {\n throw new CborError({\n type: \"Custom\",\n message: `Array element at index ${index} is undefined`,\n });\n }\n currentState = walkInternal(\n item,\n level + 1,\n { type: EdgeType.ArrayElement, index },\n currentState,\n visitor,\n );\n }\n\n return currentState;\n}\n\n/**\n * Walk a map's key-value pairs.\n *\n * For each entry:\n * 1. Visit the key-value pair as a semantic unit\n * 2. If not stopped, visit the key individually\n * 3. If not stopped, visit the value individually\n *\n * @internal\n */\nfunction walkMap<State>(\n cbor: CborMapType,\n level: number,\n state: State,\n visitor: Visitor<State>,\n): State {\n let currentState = state;\n\n for (const entry of cbor.value.entriesArray) {\n const { key, value } = entry;\n\n // First, visit the key-value pair as a semantic unit\n const kvElement: WalkElement = { type: \"keyvalue\", key, value };\n const [kvState, kvStop] = visitor(\n kvElement,\n level + 1,\n { type: EdgeType.MapKeyValue },\n currentState,\n );\n currentState = kvState;\n\n // If not stopped, visit key and value individually\n if (!kvStop) {\n currentState = walkInternal(key, level + 1, { type: EdgeType.MapKey }, currentState, visitor);\n\n currentState = walkInternal(\n value,\n level + 1,\n { type: EdgeType.MapValue },\n currentState,\n visitor,\n );\n }\n }\n\n return currentState;\n}\n\n/**\n * Walk a tagged value's content.\n *\n * @internal\n */\nfunction walkTagged<State>(\n cbor: CborTaggedType,\n level: number,\n state: State,\n visitor: Visitor<State>,\n): State {\n return walkInternal(cbor.value, level + 1, { type: EdgeType.TaggedContent }, state, visitor);\n}\n\n/**\n * Helper: Count all elements in a CBOR tree.\n *\n * @param cbor - The CBOR value to count\n * @returns Total number of elements visited\n *\n * @example\n * ```typescript\n * const structure = cbor([1, 2, [3, 4]]);\n * const count = countElements(structure);\n * console.log(count); // 6 (array, 1, 2, inner array, 3, 4)\n * ```\n */\nexport const countElements = (cbor: Cbor): number => {\n interface CountState {\n count: number;\n }\n\n const result = walk<CountState>(cbor, { count: 0 }, (_element, _level, _edge, state) => {\n return [{ count: state.count + 1 }, false];\n });\n\n return result.count;\n};\n\n/**\n * Helper: Collect all elements at a specific depth level.\n *\n * @param cbor - The CBOR value to traverse\n * @param targetLevel - The depth level to collect (0 = root)\n * @returns Array of CBOR values at the target level\n *\n * @example\n * ```typescript\n * const structure = cbor([[1, 2], [3, 4]]);\n * const level1 = collectAtLevel(structure, 1);\n * // Returns: [[1, 2], [3, 4]]\n * const level2 = collectAtLevel(structure, 2);\n * // Returns: [1, 2, 3, 4]\n * ```\n */\nexport const collectAtLevel = (cbor: Cbor, targetLevel: number): Cbor[] => {\n interface CollectState {\n items: Cbor[];\n }\n\n const result = walk<CollectState>(cbor, { items: [] }, (element, level, _edge, state) => {\n if (level === targetLevel && element.type === \"single\") {\n return [{ items: [...state.items, element.cbor] }, false];\n }\n return [state, false];\n });\n\n return result.items;\n};\n\n/**\n * Helper: Find first element matching a predicate.\n *\n * @template T - Type of extracted value\n * @param cbor - The CBOR value to search\n * @param predicate - Function to test each element\n * @returns First matching element, or undefined if not found\n *\n * @example\n * ```typescript\n * const structure = cbor({ users: [\n * { name: 'Alice', age: 30 },\n * { name: 'Bob', age: 25 }\n * ]});\n *\n * const bob = findFirst(structure, (element) => {\n * if (element.type === 'single' &&\n * element.cbor.type === MajorType.Text &&\n * element.cbor.value === 'Bob') {\n * return true;\n * }\n * return false;\n * });\n * ```\n */\nexport const findFirst = (\n cbor: Cbor,\n predicate: (element: WalkElement) => boolean,\n): Cbor | undefined => {\n interface FindState {\n found?: Cbor;\n }\n\n const result = walk<FindState>(cbor, {}, (element, _level, _edge, state) => {\n if (state.found !== undefined) {\n // Already found, stop descending\n return [state, true];\n }\n\n if (predicate(element)) {\n if (element.type === \"single\") {\n return [{ found: element.cbor }, true]; // Stop after finding\n }\n // Matched but not a single element, stop anyway\n return [state, true];\n }\n\n return [state, false];\n });\n\n return result.found;\n};\n\n/**\n * Helper: Collect all text strings in a CBOR tree.\n *\n * @param cbor - The CBOR value to traverse\n * @returns Array of all text string values found\n *\n * @example\n * ```typescript\n * const doc = cbor({\n * title: 'Document',\n * tags: ['urgent', 'draft'],\n * author: { name: 'Alice' }\n * });\n *\n * const texts = collectAllText(doc);\n * // Returns: ['Document', 'urgent', 'draft', 'Alice']\n * ```\n */\nexport const collectAllText = (cbor: Cbor): string[] => {\n interface TextState {\n texts: string[];\n }\n\n const result = walk<TextState>(cbor, { texts: [] }, (element, _level, _edge, state) => {\n if (element.type === \"single\" && element.cbor.type === MajorType.Text) {\n return [{ texts: [...state.texts, element.cbor.value] }, false];\n }\n return [state, false];\n });\n\n return result.texts;\n};\n\n/**\n * Helper: Get the maximum depth of a CBOR tree.\n *\n * @param cbor - The CBOR value to measure\n * @returns Maximum depth (0 for leaf values, 1+ for containers)\n *\n * @example\n * ```typescript\n * const flat = cbor([1, 2, 3]);\n * console.log(maxDepth(flat)); // 1\n *\n * const nested = cbor([[[1]]]);\n * console.log(maxDepth(nested)); // 3\n * ```\n */\nexport const maxDepth = (cbor: Cbor): number => {\n interface DepthState {\n maxDepth: number;\n }\n\n const result = walk<DepthState>(cbor, { maxDepth: 0 }, (_element, level, _edge, state) => {\n const newMaxDepth = Math.max(state.maxDepth, level);\n return [{ maxDepth: newMaxDepth }, false];\n });\n\n return result.maxDepth;\n};\n","import { CborMap } from \"./map\";\nimport type { Simple } from \"./simple\";\nimport { simpleCborData, isFloat as isSimpleFloat } from \"./simple\";\nimport { hasFractionalPart } from \"./float\";\nimport { encodeVarInt } from \"./varint\";\nimport { concatBytes } from \"./stdlib\";\nimport { bytesToHex, hexOpt } from \"./dump\";\nimport { hexToBytes } from \"./dump\";\nimport type { Tag } from \"./tag\";\nimport type { ByteString } from \"./byte-string\";\nimport type { CborDate } from \"./date\";\nimport { diagnosticOpt } from \"./diag\";\nimport { decodeCbor } from \"./decode\";\nimport type { TagsStore } from \"./tags-store\";\nimport { getGlobalTagsStore } from \"./tags-store\";\nimport type { Visitor } from \"./walk\";\nimport { walk } from \"./walk\";\nimport { CborError } from \"./error\";\n\nexport type { Simple };\n\nexport const MajorType = {\n Unsigned: 0,\n Negative: 1,\n ByteString: 2,\n Text: 3,\n Array: 4,\n Map: 5,\n Tagged: 6,\n Simple: 7,\n} as const;\n\n// eslint-disable-next-line no-redeclare -- Intentionally using same name for value and type\nexport type MajorType = (typeof MajorType)[keyof typeof MajorType];\n\n// Helper to get MajorType name from value (replaces enum reverse mapping)\nconst MajorTypeNames: Record<MajorType, string> = {\n [MajorType.Unsigned]: \"Unsigned\",\n [MajorType.Negative]: \"Negative\",\n [MajorType.ByteString]: \"ByteString\",\n [MajorType.Text]: \"Text\",\n [MajorType.Array]: \"Array\",\n [MajorType.Map]: \"Map\",\n [MajorType.Tagged]: \"Tagged\",\n [MajorType.Simple]: \"Simple\",\n};\n\nconst getMajorTypeName = (type: MajorType): string => MajorTypeNames[type];\n\n/**\n * Numeric type that can be encoded in CBOR.\n *\n * Supports both standard JavaScript numbers and BigInt for large integers.\n * Numbers are automatically encoded as either unsigned or negative integers\n * depending on their value, following dCBOR canonical encoding rules.\n *\n * @example\n * ```typescript\n * const smallNum: CborNumber = 42;\n * const largeNum: CborNumber = 9007199254740992n;\n * ```\n */\nexport type CborNumber = number | bigint;\n\n/**\n * Type for values that can be converted to CBOR.\n *\n * This is a comprehensive union type representing all values that can be encoded\n * as CBOR using the `cbor()` function. It includes:\n * - Already-encoded CBOR values (`Cbor`)\n * - Primitive types: numbers, bigints, strings, booleans, null, undefined\n * - Binary data: `Uint8Array`, `ByteString`\n * - Dates: `CborDate`\n * - Collections: `CborMap`, arrays, JavaScript `Map`, JavaScript `Set`\n * - Objects: Plain objects are converted to CBOR maps\n *\n * Matches Rust's `From<T>` trait implementations for CBOR.\n *\n * @example\n * ```typescript\n * cbor(42); // number\n * cbor(\"hello\"); // string\n * cbor([1, 2, 3]); // array\n * cbor(new Map([[\"key\", \"value\"]])); // Map\n * cbor({ name: \"Alice\", age: 30 }); // plain object -> CborMap\n * ```\n */\nexport type CborInput =\n | Cbor\n | CborNumber\n | string\n | boolean\n | null\n | undefined\n | Uint8Array\n | ByteString\n | CborDate\n | CborMap\n | CborInput[]\n | Map<unknown, unknown>\n | Set<unknown>\n | Record<string, unknown>;\n\nexport const isCborNumber = (value: unknown): value is CborNumber => {\n return typeof value === \"number\" || typeof value === \"bigint\";\n};\n\nexport const isCbor = (value: unknown): value is Cbor => {\n return value !== null && typeof value === \"object\" && \"isCbor\" in value && value.isCbor === true;\n};\n\nexport interface CborUnsignedType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Unsigned;\n readonly value: CborNumber;\n}\nexport interface CborNegativeType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Negative;\n readonly value: CborNumber;\n}\nexport interface CborByteStringType {\n readonly isCbor: true;\n readonly type: typeof MajorType.ByteString;\n readonly value: Uint8Array;\n}\nexport interface CborTextType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Text;\n readonly value: string;\n}\nexport interface CborArrayType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Array;\n readonly value: readonly Cbor[];\n}\nexport interface CborMapType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Map;\n readonly value: CborMap;\n}\nexport interface CborTaggedType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Tagged;\n readonly tag: CborNumber;\n readonly value: Cbor;\n}\nexport interface CborSimpleType {\n readonly isCbor: true;\n readonly type: typeof MajorType.Simple;\n readonly value: Simple;\n}\n\n// Instance methods interface\nexport interface CborMethods {\n // Universal encoding/formatting\n toData(): Uint8Array;\n toHex(): string;\n toHexAnnotated(tagsStore?: TagsStore): string;\n toString(): string;\n toDebugString(): string;\n toDiagnostic(): string;\n toDiagnosticAnnotated(): string;\n\n // Type checking\n isByteString(): boolean;\n isText(): boolean;\n isArray(): boolean;\n isMap(): boolean;\n isTagged(): boolean;\n isSimple(): boolean;\n isBool(): boolean;\n isTrue(): boolean;\n isFalse(): boolean;\n isNull(): boolean;\n isNumber(): boolean;\n isInteger(): boolean;\n isUnsigned(): boolean;\n isNegative(): boolean;\n isNaN(): boolean;\n isFloat(): boolean;\n\n // Safe conversion (returns undefined on mismatch)\n asByteString(): Uint8Array | undefined;\n asText(): string | undefined;\n asArray(): readonly Cbor[] | undefined;\n asMap(): CborMap | undefined;\n asTagged(): [Tag, Cbor] | undefined;\n asBool(): boolean | undefined;\n asInteger(): (number | bigint) | undefined;\n asNumber(): (number | bigint) | undefined;\n asSimpleValue(): Simple | undefined;\n\n // Throwing conversion (throws on mismatch)\n /**\n * Convert to byte string, throwing if type doesn't match.\n * @throws {TypeError} If value is not a byte string type\n */\n toByteString(): Uint8Array;\n /**\n * Convert to text string, throwing if type doesn't match.\n * @throws {TypeError} If value is not a text string type\n */\n toText(): string;\n /**\n * Convert to array, throwing if type doesn't match.\n * @throws {TypeError} If value is not an array type\n */\n toArray(): readonly Cbor[];\n /**\n * Convert to map, throwing if type doesn't match.\n * @throws {TypeError} If value is not a map type\n */\n toMap(): CborMap;\n /**\n * Convert to tagged value, throwing if type doesn't match.\n * @throws {TypeError} If value is not a tagged type\n */\n toTagged(): [Tag, Cbor];\n /**\n * Convert to boolean, throwing if type doesn't match.\n * @throws {TypeError} If value is not a boolean (True/False) type\n */\n toBool(): boolean;\n /**\n * Convert to integer, throwing if type doesn't match.\n * @throws {TypeError} If value is not an integer (Unsigned or Negative) type\n */\n toInteger(): number | bigint;\n /**\n * Convert to number, throwing if type doesn't match.\n * @throws {TypeError} If value is not a numeric (Unsigned, Negative, or Float) type\n */\n toNumber(): number | bigint;\n /**\n * Convert to simple value, throwing if type doesn't match.\n * @throws {TypeError} If value is not a simple type\n */\n toSimpleValue(): Simple;\n /**\n * Expect specific tag and return content, throwing if tag doesn't match.\n * @param tag - Expected tag value\n * @throws {CborError} With type 'WrongType' if value is not tagged, or 'Custom' if tag doesn't match\n */\n expectTag(tag: CborNumber | Tag): Cbor;\n\n // Advanced operations\n /**\n * Walk the CBOR structure with a visitor function.\n * @param initialState - Initial state for the visitor\n * @param visitor - Visitor function called for each element\n */\n walk<State>(initialState: State, visitor: Visitor<State>): State;\n /**\n * Validate that value has one of the expected tags.\n * @param expectedTags - Array of expected tag values\n * @throws {CborError} With type 'WrongType' if value is not tagged, or 'Custom' if tag doesn't match any expected value\n */\n validateTag(expectedTags: Tag[]): Tag;\n /**\n * Remove one level of tagging, returning the inner content.\n */\n untagged(): Cbor;\n}\n\nexport type Cbor = (\n | CborUnsignedType\n | CborNegativeType\n | CborByteStringType\n | CborTextType\n | CborArrayType\n | CborMapType\n | CborTaggedType\n | CborSimpleType\n) &\n CborMethods;\n\n// ============================================================================\n// Encoding Functions (matches Rust CBOR conversion logic)\n// ============================================================================\n\nexport interface ToCbor {\n toCbor(): Cbor;\n}\n\nexport interface TaggedCborEncodable {\n taggedCbor(): Cbor;\n}\n\n/**\n * Type guard to check if value has taggedCbor method.\n */\nconst hasTaggedCbor = (value: unknown): value is TaggedCborEncodable => {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"taggedCbor\" in value &&\n typeof (value as TaggedCborEncodable).taggedCbor === \"function\"\n );\n};\n\n/**\n * Type guard to check if value has toCbor method.\n */\nconst hasToCbor = (value: unknown): value is ToCbor => {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"toCbor\" in value &&\n typeof (value as ToCbor).toCbor === \"function\"\n );\n};\n\n/**\n * Convert any value to a CBOR representation.\n * Matches Rust's `From` trait implementations for CBOR.\n */\nexport const cbor = (value: CborInput): Cbor => {\n // If already CBOR and has methods, return as-is\n if (isCbor(value) && \"toData\" in value) {\n return value;\n }\n\n // If CBOR but no methods, attach them\n if (isCbor(value)) {\n return attachMethods(value as Omit<Cbor, keyof CborMethods>) as Cbor;\n }\n\n let result: Omit<Cbor, keyof CborMethods>;\n\n if (isCborNumber(value)) {\n if (typeof value === \"number\" && Number.isNaN(value)) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"Float\", value: NaN } };\n } else if (typeof value === \"number\" && hasFractionalPart(value)) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"Float\", value: value } };\n } else if (value == Infinity) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"Float\", value: Infinity } };\n } else if (value == -Infinity) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"Float\", value: -Infinity } };\n } else if (value < 0) {\n // Store the magnitude to encode, matching Rust's representation\n // For a negative value n, CBOR encodes it as -1-n, so we store -n-1\n if (typeof value === \"bigint\") {\n result = { isCbor: true, type: MajorType.Negative, value: -value - 1n };\n } else {\n result = { isCbor: true, type: MajorType.Negative, value: -value - 1 };\n }\n } else {\n result = { isCbor: true, type: MajorType.Unsigned, value: value };\n }\n } else if (typeof value === \"string\") {\n // dCBOR requires all text strings to be in Unicode Normalization Form C (NFC)\n // This ensures deterministic encoding regardless of how the string was composed\n const normalized = value.normalize(\"NFC\");\n result = { isCbor: true, type: MajorType.Text, value: normalized };\n } else if (value === null || value === undefined) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"Null\" } };\n } else if (value === true) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"True\" } };\n } else if (value === false) {\n result = { isCbor: true, type: MajorType.Simple, value: { type: \"False\" } };\n } else if (Array.isArray(value)) {\n result = { isCbor: true, type: MajorType.Array, value: value.map(cbor) };\n } else if (value instanceof Uint8Array) {\n result = { isCbor: true, type: MajorType.ByteString, value: value };\n } else if (value instanceof CborMap) {\n result = { isCbor: true, type: MajorType.Map, value: value };\n } else if (value instanceof Map) {\n result = { isCbor: true, type: MajorType.Map, value: new CborMap(value) };\n } else if (value instanceof Set) {\n result = {\n isCbor: true,\n type: MajorType.Array,\n value: Array.from(value).map((v) => cbor(v as CborInput)),\n };\n } else if (hasTaggedCbor(value)) {\n return value.taggedCbor();\n } else if (hasToCbor(value)) {\n return value.toCbor();\n } else if (typeof value === \"object\" && value !== null && \"tag\" in value && \"value\" in value) {\n // Handle plain tagged value format: { tag: number, value: unknown }\n const keys = Object.keys(value);\n const objValue = value as { tag: unknown; value: unknown; [key: string]: unknown };\n if (keys.length === 2 && keys.includes(\"tag\") && keys.includes(\"value\")) {\n return taggedCbor(objValue.tag, objValue.value as CborInput);\n }\n // Not a tagged value, fall through to map handling\n const map = new CborMap();\n for (const [key, val] of Object.entries(value)) {\n map.set(cbor(key as CborInput), cbor(val as CborInput));\n }\n result = { isCbor: true, type: MajorType.Map, value: map };\n } else if (typeof value === \"object\" && value !== null) {\n // Handle plain objects by converting to CborMap\n const map = new CborMap();\n for (const [key, val] of Object.entries(value)) {\n map.set(cbor(key as CborInput), cbor(val as CborInput));\n }\n result = { isCbor: true, type: MajorType.Map, value: map };\n } else {\n throw new CborError({ type: \"Custom\", message: \"Unsupported type for CBOR encoding\" });\n }\n\n return attachMethods(result) as Cbor;\n};\n\nexport const cborHex = (value: CborInput): string => {\n return bytesToHex(cborData(value));\n};\n\n/**\n * Encode a CBOR value to binary data.\n * Matches Rust's `CBOR::to_cbor_data()` method.\n */\nexport const cborData = (value: CborInput): Uint8Array => {\n const c = cbor(value);\n switch (c.type) {\n case MajorType.Unsigned: {\n return encodeVarInt(c.value, MajorType.Unsigned);\n }\n case MajorType.Negative: {\n // Value is already stored as the magnitude to encode (matching Rust)\n return encodeVarInt(c.value, MajorType.Negative);\n }\n case MajorType.ByteString: {\n if (c.value instanceof Uint8Array) {\n const lengthBytes = encodeVarInt(c.value.length, MajorType.ByteString);\n return new Uint8Array([...lengthBytes, ...c.value]);\n }\n break;\n }\n case MajorType.Text: {\n if (typeof c.value === \"string\") {\n const utf8Bytes = new TextEncoder().encode(c.value);\n const lengthBytes = encodeVarInt(utf8Bytes.length, MajorType.Text);\n return new Uint8Array([...lengthBytes, ...utf8Bytes]);\n }\n break;\n }\n case MajorType.Tagged: {\n if (typeof c.tag === \"bigint\" || typeof c.tag === \"number\") {\n const tagBytes = encodeVarInt(c.tag, MajorType.Tagged);\n const valueBytes = cborData(c.value);\n return new Uint8Array([...tagBytes, ...valueBytes]);\n }\n break;\n }\n case MajorType.Simple: {\n // Use the simpleCborData function from simple.ts\n return simpleCborData(c.value);\n }\n case MajorType.Array: {\n const arrayBytes = c.value.map(cborData);\n const flatArrayBytes = concatBytes(arrayBytes);\n const lengthBytes = encodeVarInt(c.value.length, MajorType.Array);\n return new Uint8Array([...lengthBytes, ...flatArrayBytes]);\n }\n case MajorType.Map: {\n const entries = c.value.entriesArray;\n const arrayBytes = entries.map(({ key, value }) =>\n concatBytes([cborData(key), cborData(value)]),\n );\n const flatArrayBytes = concatBytes(arrayBytes);\n const lengthBytes = encodeVarInt(entries.length, MajorType.Map);\n return new Uint8Array([...lengthBytes, ...flatArrayBytes]);\n }\n }\n throw new CborError({ type: \"WrongType\" });\n};\n\nexport const encodeCbor = (value: CborInput): Uint8Array => {\n return cborData(cbor(value));\n};\n\nexport const taggedCbor = (tag: unknown, value: CborInput): Cbor => {\n // Validate and convert tag to CborNumber\n const tagNumber: CborNumber =\n typeof tag === \"number\" || typeof tag === \"bigint\" ? tag : Number(tag);\n return attachMethods({\n isCbor: true,\n type: MajorType.Tagged,\n tag: tagNumber,\n value: cbor(value),\n });\n};\n\n// ============================================================================\n// Static Factory Functions\n// (Keep only essential creation functions)\n// ============================================================================\n\nexport const toByteString = (data: Uint8Array): Cbor => {\n return cbor(data);\n};\n\nexport const toByteStringFromHex = (hex: string): Cbor => {\n return toByteString(hexToBytes(hex));\n};\n\nexport const toTaggedValue = (tag: CborNumber | Tag, item: CborInput): Cbor => {\n const tagValue = typeof tag === \"object\" && \"value\" in tag ? tag.value : tag;\n return attachMethods({\n isCbor: true,\n type: MajorType.Tagged,\n tag: tagValue,\n value: cbor(item),\n });\n};\n\nexport const cborFalse = (): Cbor => {\n return attachMethods({ isCbor: true, type: MajorType.Simple, value: { type: \"False\" } });\n};\n\nexport const cborTrue = (): Cbor => {\n return attachMethods({ isCbor: true, type: MajorType.Simple, value: { type: \"True\" } });\n};\n\nexport const cborNull = (): Cbor => {\n return attachMethods({ isCbor: true, type: MajorType.Simple, value: { type: \"Null\" } });\n};\n\nexport const cborNaN = (): Cbor => {\n return attachMethods({\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"Float\", value: NaN },\n });\n};\n\n// ============================================================================\n// Method Attachment System\n// ============================================================================\n\n/**\n * Attaches instance methods to a CBOR value.\n * This enables method chaining like cbor.toHex() instead of Cbor.toHex(cbor).\n * @internal\n */\nexport const attachMethods = <T extends Omit<Cbor, keyof CborMethods>>(obj: T): T & CborMethods => {\n return Object.assign(obj, {\n // Universal encoding/formatting\n toData(this: Cbor): Uint8Array {\n return cborData(this);\n },\n toHex(this: Cbor): string {\n return bytesToHex(cborData(this));\n },\n toHexAnnotated(this: Cbor, tagsStore?: TagsStore): string {\n tagsStore = tagsStore ?? getGlobalTagsStore();\n return hexOpt(this, { annotate: true, tagsStore });\n },\n toString(this: Cbor): string {\n return diagnosticOpt(this, { flat: true });\n },\n toDebugString(this: Cbor): string {\n return diagnosticOpt(this, { flat: false });\n },\n toDiagnostic(this: Cbor): string {\n return diagnosticOpt(this, { flat: false });\n },\n toDiagnosticAnnotated(this: Cbor): string {\n return diagnosticOpt(this, { annotate: true });\n },\n\n // Type checking\n isByteString(this: Cbor): boolean {\n return this.type === MajorType.ByteString;\n },\n isText(this: Cbor): boolean {\n return this.type === MajorType.Text;\n },\n isArray(this: Cbor): boolean {\n return this.type === MajorType.Array;\n },\n isMap(this: Cbor): boolean {\n return this.type === MajorType.Map;\n },\n isTagged(this: Cbor): boolean {\n return this.type === MajorType.Tagged;\n },\n isSimple(this: Cbor): boolean {\n return this.type === MajorType.Simple;\n },\n isBool(this: Cbor): boolean {\n return (\n this.type === MajorType.Simple &&\n (this.value.type === \"True\" || this.value.type === \"False\")\n );\n },\n isTrue(this: Cbor): boolean {\n return this.type === MajorType.Simple && this.value.type === \"True\";\n },\n isFalse(this: Cbor): boolean {\n return this.type === MajorType.Simple && this.value.type === \"False\";\n },\n isNull(this: Cbor): boolean {\n return this.type === MajorType.Simple && this.value.type === \"Null\";\n },\n isNumber(this: Cbor): boolean {\n if (this.type === MajorType.Unsigned || this.type === MajorType.Negative) {\n return true;\n }\n if (this.type === MajorType.Simple) {\n return isSimpleFloat(this.value);\n }\n return false;\n },\n isInteger(this: Cbor): boolean {\n return this.type === MajorType.Unsigned || this.type === MajorType.Negative;\n },\n isUnsigned(this: Cbor): boolean {\n return this.type === MajorType.Unsigned;\n },\n isNegative(this: Cbor): boolean {\n return this.type === MajorType.Negative;\n },\n isNaN(this: Cbor): boolean {\n return (\n this.type === MajorType.Simple &&\n this.value.type === \"Float\" &&\n Number.isNaN(this.value.value)\n );\n },\n isFloat(this: Cbor): boolean {\n return this.type === MajorType.Simple && isSimpleFloat(this.value);\n },\n\n // Safe conversion (returns undefined on mismatch)\n asByteString(this: Cbor): Uint8Array | undefined {\n return this.type === MajorType.ByteString ? this.value : undefined;\n },\n asText(this: Cbor): string | undefined {\n return this.type === MajorType.Text ? this.value : undefined;\n },\n asArray(this: Cbor): readonly Cbor[] | undefined {\n return this.type === MajorType.Array ? this.value : undefined;\n },\n asMap(this: Cbor): CborMap | undefined {\n return this.type === MajorType.Map ? this.value : undefined;\n },\n asTagged(this: Cbor): [Tag, Cbor] | undefined {\n if (this.type !== MajorType.Tagged) {\n return undefined;\n }\n const tag: Tag = { value: this.tag, name: `tag-${this.tag}` };\n return [tag, this.value];\n },\n asBool(this: Cbor): boolean | undefined {\n if (this.type !== MajorType.Simple) return undefined;\n if (this.value.type === \"True\") return true;\n if (this.value.type === \"False\") return false;\n return undefined;\n },\n asInteger(this: Cbor): (number | bigint) | undefined {\n if (this.type === MajorType.Unsigned) {\n return this.value;\n } else if (this.type === MajorType.Negative) {\n if (typeof this.value === \"bigint\") {\n return -this.value - 1n;\n } else {\n return -this.value - 1;\n }\n }\n return undefined;\n },\n asNumber(this: Cbor): (number | bigint) | undefined {\n if (this.type === MajorType.Unsigned) {\n return this.value;\n } else if (this.type === MajorType.Negative) {\n if (typeof this.value === \"bigint\") {\n return -this.value - 1n;\n } else {\n return -this.value - 1;\n }\n } else if (this.type === MajorType.Simple && isSimpleFloat(this.value)) {\n return this.value.value;\n }\n return undefined;\n },\n asSimpleValue(this: Cbor): Simple | undefined {\n return this.type === MajorType.Simple ? this.value : undefined;\n },\n\n // Throwing conversion (throws on mismatch)\n toByteString(this: Cbor): Uint8Array {\n if (this.type !== MajorType.ByteString) {\n throw new TypeError(\n `Cannot convert CBOR to ByteString: expected ByteString type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return this.value;\n },\n toText(this: Cbor): string {\n if (this.type !== MajorType.Text) {\n throw new TypeError(\n `Cannot convert CBOR to Text: expected Text type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return this.value;\n },\n toArray(this: Cbor): readonly Cbor[] {\n if (this.type !== MajorType.Array) {\n throw new TypeError(\n `Cannot convert CBOR to Array: expected Array type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return this.value;\n },\n toMap(this: Cbor): CborMap {\n if (this.type !== MajorType.Map) {\n throw new TypeError(\n `Cannot convert CBOR to Map: expected Map type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return this.value;\n },\n toTagged(this: Cbor): [Tag, Cbor] {\n if (this.type !== MajorType.Tagged) {\n throw new TypeError(\n `Cannot convert CBOR to Tagged: expected Tagged type, got ${getMajorTypeName(this.type)}`,\n );\n }\n const tag: Tag = { value: this.tag, name: `tag-${this.tag}` };\n return [tag, this.value];\n },\n toBool(this: Cbor): boolean {\n const result = this.asBool();\n if (result === undefined) {\n throw new TypeError(\n `Cannot convert CBOR to boolean: expected Simple(True/False) type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return result;\n },\n toInteger(this: Cbor): number | bigint {\n const result = this.asInteger();\n if (result === undefined) {\n throw new TypeError(\n `Cannot convert CBOR to integer: expected Unsigned or Negative type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return result;\n },\n toNumber(this: Cbor): number | bigint {\n const result = this.asNumber();\n if (result === undefined) {\n throw new TypeError(\n `Cannot convert CBOR to number: expected Unsigned, Negative, or Float type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return result;\n },\n toSimpleValue(this: Cbor): Simple {\n if (this.type !== MajorType.Simple) {\n throw new TypeError(\n `Cannot convert CBOR to Simple: expected Simple type, got ${getMajorTypeName(this.type)}`,\n );\n }\n return this.value;\n },\n expectTag(this: Cbor, expectedTag: CborNumber | Tag): Cbor {\n if (this.type !== MajorType.Tagged) {\n throw new CborError({ type: \"WrongType\" });\n }\n const expectedValue =\n typeof expectedTag === \"object\" && \"value\" in expectedTag ? expectedTag.value : expectedTag;\n if (this.tag !== expectedValue) {\n throw new CborError({\n type: \"Custom\",\n message: `Wrong tag: expected ${expectedValue}, got ${this.tag}`,\n });\n }\n return this.value;\n },\n\n // Advanced operations\n walk<State>(this: Cbor, initialState: State, visitor: Visitor<State>): State {\n return walk(this, initialState, visitor);\n },\n validateTag(this: Cbor, expectedTags: Tag[]): Tag {\n if (this.type !== MajorType.Tagged) {\n throw new CborError({ type: \"WrongType\" });\n }\n const expectedValues = expectedTags.map((t) => t.value);\n const tagValue = this.tag;\n const matchingTag = expectedTags.find((t) => t.value === tagValue);\n if (matchingTag === undefined) {\n const expectedStr = expectedValues.join(\" or \");\n throw new CborError({\n type: \"Custom\",\n message: `Wrong tag: expected ${expectedStr}, got ${tagValue}`,\n });\n }\n return matchingTag;\n },\n untagged(this: Cbor): Cbor {\n if (this.type !== MajorType.Tagged) {\n throw new CborError({ type: \"WrongType\" });\n }\n return this.value;\n },\n });\n};\n\n// ============================================================================\n// Cbor Namespace - Static Constants and Factory Methods\n// ============================================================================\n\n/**\n * CBOR constants and helper methods.\n *\n * Provides constants for common simple values (False, True, Null) and static methods\n * matching the Rust CBOR API for encoding/decoding.\n */\n// eslint-disable-next-line no-redeclare\nexport const Cbor = {\n // Static CBOR simple values (matching Rust naming) - with methods attached\n False: attachMethods({ isCbor: true, type: MajorType.Simple, value: { type: \"False\" } }),\n True: attachMethods({ isCbor: true, type: MajorType.Simple, value: { type: \"True\" } }),\n Null: attachMethods({ isCbor: true, type: MajorType.Simple, value: { type: \"Null\" } }),\n NaN: attachMethods({\n isCbor: true,\n type: MajorType.Simple,\n value: { type: \"Float\", value: NaN },\n }),\n\n // ============================================================================\n // Static Factory/Decoding Methods (matches Rust CBOR static methods)\n // ============================================================================\n\n /**\n * Creates a CBOR value from any JavaScript value.\n *\n * Matches Rust's `CBOR::from()` behavior for various types.\n *\n * @param value - Any JavaScript value (number, string, boolean, null, array, object, etc.)\n * @returns A CBOR symbolic representation with instance methods\n */\n from(value: CborInput): Cbor {\n return cbor(value);\n },\n\n /**\n * Decodes binary data into CBOR symbolic representation.\n *\n * Matches Rust's `CBOR::try_from_data()` method.\n *\n * @param data - The binary data to decode\n * @returns A CBOR value with instance methods\n * @throws Error if the data is not valid CBOR or violates dCBOR encoding rules\n */\n tryFromData(data: Uint8Array): Cbor {\n return decodeCbor(data);\n },\n\n /**\n * Decodes a hexadecimal string into CBOR symbolic representation.\n *\n * Matches Rust's `CBOR::try_from_hex()` method.\n *\n * @param hex - A string containing hexadecimal characters\n * @returns A CBOR value with instance methods\n * @throws Error if the hex string is invalid or the resulting data is not valid dCBOR\n */\n tryFromHex(hex: string): Cbor {\n const data = hexToBytes(hex);\n return this.tryFromData(data);\n },\n};\n","/**\n * Tagged CBOR encoding support.\n *\n * This module provides the `CborTaggedEncodable` interface, which enables types to\n * be encoded as tagged CBOR values.\n *\n * CBOR tags provide semantic information about the encoded data. For example,\n * tag 1 is used for dates, indicating that the value should be interpreted\n * as a timestamp. The dCBOR library ensures these tags are encoded\n * deterministically.\n *\n * This interface enables seamless encoding of TypeScript types to properly tagged CBOR\n * values.\n *\n * @module cbor-tagged-encodable\n */\n\nimport { type Cbor, MajorType, attachMethods } from \"./cbor\";\nimport type { CborTagged } from \"./cbor-tagged\";\nimport { CborError } from \"./error\";\n\n/**\n * Interface for types that can be encoded to CBOR with a specific tag.\n *\n * This interface extends `CborTagged` to provide methods for encoding a value\n * with its associated tag. Types that implement this interface define how they\n * should be represented in CBOR format, both with and without their tag.\n *\n * @example\n * ```typescript\n * // Define a Date type\n * class Date implements CborTaggedEncodable {\n * constructor(private timestamp: number) {}\n *\n * cborTags(): Tag[] {\n * return [createTag(1, 'date')]; // Standard date tag\n * }\n *\n * untaggedCbor(): Cbor {\n * // Date content is represented as a number\n * return cbor(this.timestamp);\n * }\n *\n * taggedCbor(): Cbor {\n * const tags = this.cborTags();\n * return {\n * isCbor: true,\n * type: MajorType.Tagged,\n * tag: tags[0].value,\n * value: this.untaggedCbor()\n * };\n * }\n *\n * taggedCborData(): Uint8Array {\n * return cborData(this.taggedCbor());\n * }\n * }\n *\n * // Create a date and encode it\n * const date = new Date(1609459200);\n *\n * // Get the untagged CBOR (just the timestamp)\n * const untagged = date.untaggedCbor();\n *\n * // Get the tagged CBOR (with tag 1)\n * const tagged = date.taggedCbor();\n *\n * // Get binary representation\n * const data = date.taggedCborData();\n * ```\n */\nexport interface CborTaggedEncodable extends CborTagged {\n /**\n * Returns the untagged CBOR encoding of this instance.\n *\n * This method defines how the value itself (without its tag) should\n * be represented in CBOR format.\n *\n * @returns Untagged CBOR representation\n */\n untaggedCbor(): Cbor;\n\n /**\n * Returns the tagged CBOR encoding of this instance.\n *\n * This method wraps the result of `untaggedCbor()` with the first tag\n * from `cborTags()`, which is considered the \"preferred\" tag for the\n * type.\n *\n * Even if a type supports multiple tags for backward-compatible decoding\n * via `cborTags()`, only the first (preferred) tag is used for encoding.\n * This ensures consistency in newly created data while maintaining the\n * ability to read older formats.\n *\n * In most cases, you don't need to override this method.\n *\n * @returns Tagged CBOR representation\n */\n taggedCbor(): Cbor;\n\n /**\n * Returns the tagged value in CBOR binary representation.\n *\n * This is a convenience method that converts the result of `taggedCbor()`\n * to binary format.\n *\n * @returns Binary CBOR representation\n */\n taggedCborData?(): Uint8Array;\n}\n\n/**\n * Helper function to create tagged CBOR from an encodable object.\n *\n * Uses the first tag from cborTags().\n *\n * @param encodable - Object implementing CborTaggedEncodable\n * @returns Tagged CBOR value\n */\nexport const createTaggedCbor = (encodable: CborTaggedEncodable): Cbor => {\n const tags = encodable.cborTags();\n if (tags.length === 0) {\n throw new CborError({ type: \"Custom\", message: \"No tags defined for this type\" });\n }\n\n const tag = tags[0];\n if (tag === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Tag is undefined\" });\n }\n const untagged = encodable.untaggedCbor();\n\n return attachMethods({\n isCbor: true,\n type: MajorType.Tagged,\n tag: tag.value,\n value: untagged,\n });\n};\n","/**\n * Tagged CBOR decoding support.\n *\n * This module provides the `CborTaggedDecodable` interface, which enables types to\n * be decoded from tagged CBOR values.\n *\n * Tagged CBOR values include semantic information about how to interpret the\n * data. This interface allows TypeScript types to verify that incoming CBOR data has the\n * expected tag(s) and to decode the data appropriately.\n *\n * @module cbor-tagged-decodable\n */\n\nimport { type Cbor, MajorType } from \"./cbor\";\nimport type { CborTagged } from \"./cbor-tagged\";\nimport type { Tag } from \"./tag\";\nimport { CborError } from \"./error\";\n\n/**\n * Interface for types that can be decoded from CBOR with a specific tag.\n *\n * This interface extends `CborTagged` to provide methods for\n * decoding tagged CBOR data into TypeScript types. It handles verification that\n * the CBOR data has the expected tag(s) and provides utilities for both\n * tagged and untagged decoding.\n *\n * @example\n * ```typescript\n * // Define a Date type\n * class Date implements CborTaggedDecodable<Date> {\n * constructor(public timestamp: number) {}\n *\n * cborTags(): Tag[] {\n * return [createTag(1, 'date')]; // Standard date tag\n * }\n *\n * fromUntaggedCbor(cbor: Cbor): Date {\n * // Convert the untagged CBOR to a number\n * if (cbor.type !== MajorType.Unsigned) {\n * throw new Error('Wrong type');\n * }\n * const timestamp = typeof cbor.value === 'bigint' ? Number(cbor.value) : cbor.value;\n * return new Date(timestamp);\n * }\n *\n * fromTaggedCbor(cbor: Cbor): Date {\n * if (cbor.type !== MajorType.Tagged) {\n * throw new Error('Wrong type');\n * }\n *\n * const tags = this.cborTags();\n * const tagValues = tags.map(t => t.value);\n * if (!tagValues.includes(cbor.tag as number)) {\n * throw new Error(`Wrong tag: expected ${tagValues[0]}, got ${cbor.tag}`);\n * }\n *\n * return this.fromUntaggedCbor(cbor.value);\n * }\n *\n * static fromTaggedCborData(data: Uint8Array): Date {\n * const cbor = decodeCbor(data);\n * return new Date(0).fromTaggedCbor(cbor);\n * }\n *\n * static fromUntaggedCborData(data: Uint8Array): Date {\n * const cbor = decodeCbor(data);\n * return new Date(0).fromUntaggedCbor(cbor);\n * }\n * }\n *\n * // Create tagged CBOR data\n * const taggedCbor = {\n * isCbor: true,\n * type: MajorType.Tagged,\n * tag: 1,\n * value: cbor(1609459200)\n * };\n *\n * // Decode using the interface\n * const date = new Date(0).fromTaggedCbor(taggedCbor);\n * assert(date.timestamp === 1609459200);\n * ```\n */\nexport interface CborTaggedDecodable<T> extends CborTagged {\n /**\n * Creates an instance of this type by decoding it from untagged CBOR.\n *\n * This method defines how to interpret the CBOR content (without\n * considering the tag) and convert it to the implementing type.\n *\n * @param cbor - Untagged CBOR value\n * @returns Decoded instance\n * @throws Error if the CBOR value cannot be decoded\n */\n fromUntaggedCbor(cbor: Cbor): T;\n\n /**\n * Creates an instance of this type by decoding it from tagged CBOR.\n *\n * This method first verifies that the CBOR value has one of the expected\n * tags (as defined by `cborTags()`), then delegates to\n * `fromUntaggedCbor()` to decode the content.\n *\n * For backward compatibility, this method accepts any tag from the\n * `cborTags()` array, not just the first one. This allows new\n * versions of types to still accept data tagged with older/alternative\n * tag values.\n *\n * In most cases, you don't need to override this method.\n *\n * @param cbor - Tagged CBOR value\n * @returns Decoded instance\n * @throws Error if the CBOR value has the wrong tag or cannot be decoded\n */\n fromTaggedCbor(cbor: Cbor): T;\n\n /**\n * Creates an instance of this type by decoding it from binary encoded\n * tagged CBOR.\n *\n * This is a convenience method that first parses the binary data into a\n * CBOR value, then uses `fromTaggedCbor()` to decode it.\n *\n * @param data - Binary CBOR data\n * @returns Decoded instance\n * @throws Error if the data cannot be parsed or decoded\n */\n fromTaggedCborData?(data: Uint8Array): T;\n\n /**\n * Creates an instance of this type by decoding it from binary encoded\n * untagged CBOR.\n *\n * This is a convenience method that first parses the binary data into a\n * CBOR value, then uses `fromUntaggedCbor()` to decode it.\n *\n * @param data - Binary CBOR data\n * @returns Decoded instance\n * @throws Error if the data cannot be parsed or decoded\n */\n fromUntaggedCborData?(data: Uint8Array): T;\n}\n\n/**\n * Helper function to validate that a CBOR value has one of the expected tags.\n *\n * @param cbor - CBOR value to validate\n * @param expectedTags - Array of valid tags\n * @returns The matching tag\n * @throws Error if the value is not tagged or has an unexpected tag\n */\nexport const validateTag = (cbor: Cbor, expectedTags: Tag[]): Tag => {\n if (cbor.type !== MajorType.Tagged) {\n throw new CborError({ type: \"WrongType\" });\n }\n\n const expectedValues = expectedTags.map((t) => t.value);\n const tagValue = cbor.tag;\n\n const matchingTag = expectedTags.find((t) => t.value === tagValue);\n if (matchingTag === undefined) {\n const expectedStr = expectedValues.join(\" or \");\n throw new CborError({\n type: \"Custom\",\n message: `Wrong tag: expected ${expectedStr}, got ${tagValue}`,\n });\n }\n\n return matchingTag;\n};\n\n/**\n * Helper function to extract the content from a tagged CBOR value.\n *\n * @param cbor - Tagged CBOR value\n * @returns The untagged content\n * @throws Error if the value is not tagged\n */\nexport const extractTaggedContent = (cbor: Cbor): Cbor => {\n if (cbor.type !== MajorType.Tagged) {\n throw new CborError({ type: \"WrongType\" });\n }\n return cbor.value;\n};\n","/**\n * Date/time support for CBOR with tag(1) encoding.\n *\n * A CBOR-friendly representation of a date and time.\n *\n * The `CborDate` type provides a wrapper around JavaScript's native `Date` that\n * supports encoding and decoding to/from CBOR with tag 1, following the CBOR\n * date/time standard specified in RFC 8949.\n *\n * When encoded to CBOR, dates are represented as tag 1 followed by a numeric\n * value representing the number of seconds since (or before) the Unix epoch\n * (1970-01-01T00:00:00Z). The numeric value can be a positive or negative\n * integer, or a floating-point value for dates with fractional seconds.\n *\n * @module date\n */\n\nimport { type Cbor, MajorType } from \"./cbor\";\nimport { cbor } from \"./cbor\";\nimport { createTag, type Tag } from \"./tag\";\nimport { TAG_EPOCH_DATE_TIME } from \"./tags\";\nimport {\n type CborTaggedEncodable,\n type CborTaggedDecodable,\n type CborTagged,\n createTaggedCbor,\n validateTag,\n extractTaggedContent,\n} from \"./cbor-tagged\";\nimport { CborError } from \"./error\";\n\n/**\n * A CBOR-friendly representation of a date and time.\n *\n * The `CborDate` type provides a wrapper around JavaScript's native `Date` that\n * supports encoding and decoding to/from CBOR with tag 1, following the CBOR\n * date/time standard specified in RFC 8949.\n *\n * When encoded to CBOR, dates are represented as tag 1 followed by a numeric\n * value representing the number of seconds since (or before) the Unix epoch\n * (1970-01-01T00:00:00Z). The numeric value can be a positive or negative\n * integer, or a floating-point value for dates with fractional seconds.\n *\n * # Features\n *\n * - Supports UTC dates with optional fractional seconds\n * - Provides convenient constructors for common date creation patterns\n * - Implements the `CborTagged`, `CborTaggedEncodable`, and\n * `CborTaggedDecodable` interfaces\n * - Supports arithmetic operations with durations and between dates\n *\n * @example\n * ```typescript\n * import { CborDate } from './date';\n *\n * // Create a date from a timestamp (seconds since Unix epoch)\n * const date = CborDate.fromTimestamp(1675854714.0);\n *\n * // Create a date from year, month, day\n * const date2 = CborDate.fromYmd(2023, 2, 8);\n *\n * // Convert to CBOR\n * const cborValue = date.taggedCbor();\n *\n * // Decode from CBOR\n * const decoded = CborDate.fromTaggedCbor(cborValue);\n * ```\n */\nexport class CborDate implements CborTagged, CborTaggedEncodable, CborTaggedDecodable<CborDate> {\n #datetime: Date;\n\n /**\n * Creates a new `CborDate` from the given JavaScript `Date`.\n *\n * This method creates a new `CborDate` instance by wrapping a\n * JavaScript `Date`.\n *\n * @param dateTime - A `Date` instance to wrap\n *\n * @returns A new `CborDate` instance\n *\n * @example\n * ```typescript\n * const datetime = new Date();\n * const date = CborDate.fromDatetime(datetime);\n * ```\n */\n static fromDatetime(dateTime: Date): CborDate {\n const instance = new CborDate();\n instance.#datetime = new Date(dateTime);\n return instance;\n }\n\n /**\n * Creates a new `CborDate` from year, month, and day components.\n *\n * This method creates a new `CborDate` with the time set to 00:00:00 UTC.\n *\n * @param year - The year component (e.g., 2023)\n * @param month - The month component (1-12)\n * @param day - The day component (1-31)\n *\n * @returns A new `CborDate` instance\n *\n * @example\n * ```typescript\n * // Create February 8, 2023\n * const date = CborDate.fromYmd(2023, 2, 8);\n * ```\n *\n * @throws Error if the provided components do not form a valid date.\n */\n static fromYmd(year: number, month: number, day: number): CborDate {\n const dt = new Date(Date.UTC(year, month - 1, day, 0, 0, 0, 0));\n return CborDate.fromDatetime(dt);\n }\n\n /**\n * Creates a new `CborDate` from year, month, day, hour, minute, and second\n * components.\n *\n * @param year - The year component (e.g., 2023)\n * @param month - The month component (1-12)\n * @param day - The day component (1-31)\n * @param hour - The hour component (0-23)\n * @param minute - The minute component (0-59)\n * @param second - The second component (0-59)\n *\n * @returns A new `CborDate` instance\n *\n * @example\n * ```typescript\n * // Create February 8, 2023, 15:30:45 UTC\n * const date = CborDate.fromYmdHms(2023, 2, 8, 15, 30, 45);\n * ```\n *\n * @throws Error if the provided components do not form a valid date and time.\n */\n static fromYmdHms(\n year: number,\n month: number,\n day: number,\n hour: number,\n minute: number,\n second: number,\n ): CborDate {\n const dt = new Date(Date.UTC(year, month - 1, day, hour, minute, second, 0));\n return CborDate.fromDatetime(dt);\n }\n\n /**\n * Creates a new `CborDate` from seconds since (or before) the Unix epoch.\n *\n * This method creates a new `CborDate` representing the specified number of\n * seconds since the Unix epoch (1970-01-01T00:00:00Z). Negative values\n * represent times before the epoch.\n *\n * @param secondsSinceUnixEpoch - Seconds from the Unix epoch (positive or\n * negative), which can include a fractional part for sub-second\n * precision\n *\n * @returns A new `CborDate` instance\n *\n * @example\n * ```typescript\n * // Create a date from a timestamp\n * const date = CborDate.fromTimestamp(1675854714.0);\n *\n * // Create a date one second before the Unix epoch\n * const beforeEpoch = CborDate.fromTimestamp(-1.0);\n *\n * // Create a date with fractional seconds\n * const withFraction = CborDate.fromTimestamp(1675854714.5);\n * ```\n */\n static fromTimestamp(secondsSinceUnixEpoch: number): CborDate {\n const wholeSecondsSinceUnixEpoch = Math.trunc(secondsSinceUnixEpoch);\n const fractionalSeconds = secondsSinceUnixEpoch - wholeSecondsSinceUnixEpoch;\n const milliseconds = wholeSecondsSinceUnixEpoch * 1000 + fractionalSeconds * 1000;\n return CborDate.fromDatetime(new Date(milliseconds));\n }\n\n /**\n * Creates a new `CborDate` from a string containing an ISO-8601 (RFC-3339)\n * date (with or without time).\n *\n * This method parses a string representation of a date or date-time in\n * ISO-8601/RFC-3339 format and creates a new `CborDate` instance. It\n * supports both full date-time strings (e.g., \"2023-02-08T15:30:45Z\")\n * and date-only strings (e.g., \"2023-02-08\").\n *\n * @param value - A string containing a date or date-time in ISO-8601/RFC-3339\n * format\n *\n * @returns A new `CborDate` instance if parsing succeeds\n *\n * @throws Error if the string cannot be parsed as a valid date or date-time\n *\n * @example\n * ```typescript\n * // Parse a date-time string\n * const date = CborDate.fromString(\"2023-02-08T15:30:45Z\");\n *\n * // Parse a date-only string (time will be set to 00:00:00)\n * const date2 = CborDate.fromString(\"2023-02-08\");\n * ```\n */\n static fromString(value: string): CborDate {\n // Try parsing as ISO 8601 date string\n const dt = new Date(value);\n if (isNaN(dt.getTime())) {\n throw new CborError({ type: \"InvalidDate\", message: `Invalid date string: ${value}` });\n }\n return CborDate.fromDatetime(dt);\n }\n\n /**\n * Creates a new `CborDate` containing the current date and time.\n *\n * @returns A new `CborDate` instance representing the current UTC date and time\n *\n * @example\n * ```typescript\n * const now = CborDate.now();\n * ```\n */\n static now(): CborDate {\n return CborDate.fromDatetime(new Date());\n }\n\n /**\n * Creates a new `CborDate` containing the current date and time plus the given\n * duration.\n *\n * @param durationMs - The duration in milliseconds to add to the current time\n *\n * @returns A new `CborDate` instance representing the current UTC date and time plus\n * the duration\n *\n * @example\n * ```typescript\n * // Get a date 1 hour from now\n * const oneHourLater = CborDate.withDurationFromNow(3600 * 1000);\n * ```\n */\n static withDurationFromNow(durationMs: number): CborDate {\n const now = new Date();\n const future = new Date(now.getTime() + durationMs);\n return CborDate.fromDatetime(future);\n }\n\n /**\n * Returns the underlying JavaScript `Date` object.\n *\n * This method provides access to the wrapped JavaScript `Date`\n * instance.\n *\n * @returns The wrapped `Date` instance\n *\n * @example\n * ```typescript\n * const date = CborDate.now();\n * const datetime = date.datetime();\n * const year = datetime.getFullYear();\n * ```\n */\n datetime(): Date {\n return new Date(this.#datetime);\n }\n\n /**\n * Returns the `CborDate` as the number of seconds since the Unix epoch.\n *\n * This method converts the date to a floating-point number representing\n * the number of seconds since the Unix epoch (1970-01-01T00:00:00Z).\n * Negative values represent times before the epoch. The fractional\n * part represents sub-second precision.\n *\n * @returns Seconds since the Unix epoch as a `number`\n *\n * @example\n * ```typescript\n * const date = CborDate.fromYmd(2023, 2, 8);\n * const timestamp = date.timestamp();\n * ```\n */\n timestamp(): number {\n const wholeSecondsSinceUnixEpoch = Math.trunc(this.#datetime.getTime() / 1000);\n const msecs = this.#datetime.getTime() % 1000;\n return wholeSecondsSinceUnixEpoch + msecs / 1000.0;\n }\n\n /**\n * Add seconds to this date.\n *\n * @param seconds - Seconds to add (can be fractional)\n * @returns New CborDate instance\n *\n * @example\n * ```typescript\n * const date = CborDate.fromYmd(2022, 3, 21);\n * const tomorrow = date.add(24 * 60 * 60);\n * ```\n */\n add(seconds: number): CborDate {\n return CborDate.fromTimestamp(this.timestamp() + seconds);\n }\n\n /**\n * Subtract seconds from this date.\n *\n * @param seconds - Seconds to subtract (can be fractional)\n * @returns New CborDate instance\n *\n * @example\n * ```typescript\n * const date = CborDate.fromYmd(2022, 3, 21);\n * const yesterday = date.subtract(24 * 60 * 60);\n * ```\n */\n subtract(seconds: number): CborDate {\n return CborDate.fromTimestamp(this.timestamp() - seconds);\n }\n\n /**\n * Get the difference in seconds between this date and another.\n *\n * @param other - Other CborDate to compare with\n * @returns Difference in seconds (this - other)\n *\n * @example\n * ```typescript\n * const date1 = CborDate.fromYmd(2022, 3, 22);\n * const date2 = CborDate.fromYmd(2022, 3, 21);\n * const diff = date1.difference(date2);\n * // Returns 86400 (one day in seconds)\n * ```\n */\n difference(other: CborDate): number {\n return this.timestamp() - other.timestamp();\n }\n\n /**\n * Implementation of the `CborTagged` interface for `CborDate`.\n *\n * This implementation specifies that `CborDate` values are tagged with CBOR tag 1,\n * which is the standard CBOR tag for date/time values represented as seconds\n * since the Unix epoch per RFC 8949.\n *\n * @returns A vector containing tag 1\n */\n cborTags(): Tag[] {\n return [createTag(TAG_EPOCH_DATE_TIME, \"date\")];\n }\n\n /**\n * Implementation of the `CborTaggedEncodable` interface for `CborDate`.\n *\n * Converts this `CborDate` to an untagged CBOR value.\n *\n * The date is converted to a numeric value representing the number of\n * seconds since the Unix epoch. This value may be an integer or a\n * floating-point number, depending on whether the date has fractional\n * seconds.\n *\n * @returns A CBOR value representing the timestamp\n */\n untaggedCbor(): Cbor {\n return cbor(this.timestamp());\n }\n\n /**\n * Converts this `CborDate` to a tagged CBOR value with tag 1.\n *\n * @returns Tagged CBOR value\n */\n taggedCbor(): Cbor {\n return createTaggedCbor(this);\n }\n\n /**\n * Implementation of the `CborTaggedDecodable` interface for `CborDate`.\n *\n * Creates a `CborDate` from an untagged CBOR value.\n *\n * The CBOR value must be a numeric value (integer or floating-point)\n * representing the number of seconds since the Unix epoch.\n *\n * @param cbor - The untagged CBOR value\n *\n * @returns This CborDate instance (mutated)\n *\n * @throws Error if the CBOR value is not a valid timestamp\n */\n fromUntaggedCbor(cbor: Cbor): CborDate {\n let timestamp: number;\n\n // Only handle numeric types (Unsigned, Negative, Float); others are invalid for dates\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (cbor.type) {\n case MajorType.Unsigned:\n timestamp = typeof cbor.value === \"number\" ? cbor.value : Number(cbor.value);\n break;\n\n case MajorType.Negative:\n // Convert stored magnitude back to actual negative value\n if (typeof cbor.value === \"bigint\") {\n timestamp = Number(-cbor.value - 1n);\n } else {\n timestamp = -cbor.value - 1;\n }\n break;\n\n case MajorType.Simple:\n if (cbor.value.type === \"Float\") {\n timestamp = cbor.value.value;\n } else {\n throw new CborError({\n type: \"Custom\",\n message: \"Invalid date CBOR: expected numeric value\",\n });\n }\n break;\n\n default:\n throw new CborError({\n type: \"Custom\",\n message: \"Invalid date CBOR: expected numeric value\",\n });\n }\n\n const date = CborDate.fromTimestamp(timestamp);\n this.#datetime = date.#datetime;\n return this;\n }\n\n /**\n * Creates a `CborDate` from a tagged CBOR value with tag 1.\n *\n * @param cbor - Tagged CBOR value\n *\n * @returns This CborDate instance (mutated)\n *\n * @throws Error if the CBOR value has the wrong tag or cannot be decoded\n */\n fromTaggedCbor(cbor: Cbor): CborDate {\n const expectedTags = this.cborTags();\n validateTag(cbor, expectedTags);\n const content = extractTaggedContent(cbor);\n return this.fromUntaggedCbor(content);\n }\n\n /**\n * Static method to create a CborDate from tagged CBOR.\n *\n * @param cbor - Tagged CBOR value\n * @returns New CborDate instance\n */\n static fromTaggedCbor(cbor: Cbor): CborDate {\n const instance = new CborDate();\n return instance.fromTaggedCbor(cbor);\n }\n\n /**\n * Static method to create a CborDate from untagged CBOR.\n *\n * @param cbor - Untagged CBOR value\n * @returns New CborDate instance\n */\n static fromUntaggedCbor(cbor: Cbor): CborDate {\n const instance = new CborDate();\n return instance.fromUntaggedCbor(cbor);\n }\n\n /**\n * Implementation of the `toString` method for `CborDate`.\n *\n * This implementation provides a string representation of a `CborDate` in ISO-8601\n * format. For dates with time exactly at midnight (00:00:00), only the date\n * part is shown. For other times, a full date-time string is shown.\n *\n * @returns String representation in ISO-8601 format\n *\n * @example\n * ```typescript\n * // A date at midnight will display as just the date\n * const date = CborDate.fromYmd(2023, 2, 8);\n * // Returns \"2023-02-08\"\n * console.log(date.toString());\n *\n * // A date with time will display as date and time\n * const date2 = CborDate.fromYmdHms(2023, 2, 8, 15, 30, 45);\n * // Returns \"2023-02-08T15:30:45.000Z\"\n * console.log(date2.toString());\n * ```\n */\n toString(): string {\n const dt = this.#datetime;\n // Check only hours, minutes, and seconds (not milliseconds) to match Rust behavior\n const hasTime = dt.getUTCHours() !== 0 || dt.getUTCMinutes() !== 0 || dt.getUTCSeconds() !== 0;\n\n if (!hasTime) {\n // Midnight (with possible subsecond precision) - show only date\n const datePart = dt.toISOString().split(\"T\")[0];\n if (datePart === undefined) {\n throw new CborError({ type: \"Custom\", message: \"Invalid ISO string format\" });\n }\n return datePart;\n } else {\n // Show full ISO datetime without milliseconds (matches Rust's SecondsFormat::Secs)\n const iso = dt.toISOString();\n // Remove milliseconds: \"2023-02-08T15:30:45.000Z\" -> \"2023-02-08T15:30:45Z\"\n return iso.replace(/\\.\\d{3}Z$/, \"Z\");\n }\n }\n\n /**\n * Compare two dates for equality.\n *\n * @param other - Other CborDate to compare\n * @returns true if dates represent the same moment in time\n */\n equals(other: CborDate): boolean {\n return this.#datetime.getTime() === other.#datetime.getTime();\n }\n\n /**\n * Compare two dates.\n *\n * @param other - Other CborDate to compare\n * @returns -1 if this < other, 0 if equal, 1 if this > other\n */\n compare(other: CborDate): number {\n const thisTime = this.#datetime.getTime();\n const otherTime = other.#datetime.getTime();\n if (thisTime < otherTime) return -1;\n if (thisTime > otherTime) return 1;\n return 0;\n }\n\n /**\n * Convert to JSON (returns ISO 8601 string).\n *\n * @returns ISO 8601 string\n */\n toJSON(): string {\n return this.toString();\n }\n\n private constructor() {\n this.#datetime = new Date();\n }\n}\n","/**\n * Standard CBOR tag definitions from the IANA registry.\n *\n * @module tags\n * @see https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml\n */\n\nimport { type Tag, createTag } from \"./tag\";\n\n// ============================================================================\n// Standard Date/Time Tags\n// ============================================================================\n\n/**\n * Tag 0: Standard date/time string (RFC 3339)\n */\nexport const TAG_DATE_TIME_STRING = 0;\n\n/**\n * Tag 1: Epoch-based date/time (seconds since 1970-01-01T00:00:00Z)\n */\nexport const TAG_EPOCH_DATE_TIME = 1;\n\n/**\n * Tag 100: Epoch-based date (days since 1970-01-01)\n */\nexport const TAG_EPOCH_DATE = 100;\n\n// ============================================================================\n// Numeric Tags\n// ============================================================================\n\n/**\n * Tag 2: Positive bignum (unsigned arbitrary-precision integer)\n */\nexport const TAG_POSITIVE_BIGNUM = 2;\n\n/**\n * Tag 3: Negative bignum (signed arbitrary-precision integer)\n */\nexport const TAG_NEGATIVE_BIGNUM = 3;\n\n/**\n * Tag 4: Decimal fraction [exponent, mantissa]\n */\nexport const TAG_DECIMAL_FRACTION = 4;\n\n/**\n * Tag 5: Bigfloat [exponent, mantissa]\n */\nexport const TAG_BIGFLOAT = 5;\n\n// ============================================================================\n// Encoding Hints\n// ============================================================================\n\n/**\n * Tag 21: Expected conversion to base64url encoding\n */\nexport const TAG_BASE64URL = 21;\n\n/**\n * Tag 22: Expected conversion to base64 encoding\n */\nexport const TAG_BASE64 = 22;\n\n/**\n * Tag 23: Expected conversion to base16 encoding\n */\nexport const TAG_BASE16 = 23;\n\n/**\n * Tag 24: Encoded CBOR data item\n */\nexport const TAG_ENCODED_CBOR = 24;\n\n// ============================================================================\n// URI and Network Tags\n// ============================================================================\n\n/**\n * Tag 32: URI (text string)\n */\nexport const TAG_URI = 32;\n\n/**\n * Tag 33: base64url-encoded text\n */\nexport const TAG_BASE64URL_TEXT = 33;\n\n/**\n * Tag 34: base64-encoded text\n */\nexport const TAG_BASE64_TEXT = 34;\n\n/**\n * Tag 35: Regular expression (PCRE/ECMA262)\n */\nexport const TAG_REGEXP = 35;\n\n/**\n * Tag 36: MIME message\n */\nexport const TAG_MIME_MESSAGE = 36;\n\n/**\n * Tag 37: Binary UUID\n */\nexport const TAG_UUID = 37;\n\n// ============================================================================\n// Cryptography Tags\n// ============================================================================\n\n/**\n * Tag 256: string reference (namespace)\n */\nexport const TAG_STRING_REF_NAMESPACE = 256;\n\n/**\n * Tag 257: binary UUID reference\n */\nexport const TAG_BINARY_UUID = 257;\n\n/**\n * Tag 258: Set of values (array with no duplicates)\n */\nexport const TAG_SET = 258;\n\n// ============================================================================\n// NOTE: Blockchain Commons envelope and extension tags (TAG_ENVELOPE, TAG_LEAF,\n// TAG_KNOWN_VALUE, TAG_COMPRESSED, etc.) are defined in the @bcts/tags\n// package, NOT in dcbor. This matches the Rust architecture where bc-dcbor-rust\n// only defines TAG_DATE, and bc-tags-rust defines all envelope-related tags.\n// ============================================================================\n\n// ============================================================================\n// Self-describing CBOR\n// ============================================================================\n\n/**\n * Tag 55799: Self-describe CBOR (magic number 0xd9d9f7)\n */\nexport const TAG_SELF_DESCRIBE_CBOR = 55799;\n\n// ============================================================================\n// Global Tags Store Registration\n// Matches Rust's register_tags() functionality\n// ============================================================================\n\nimport type { TagsStore } from \"./tags-store\";\nimport { getGlobalTagsStore } from \"./tags-store\";\nimport { CborDate } from \"./date\";\nimport type { Cbor } from \"./cbor\";\nimport { diagnostic } from \"./diag\";\n\n// Tag constants matching Rust\nexport const TAG_DATE = 1;\nexport const TAG_NAME_DATE = \"date\";\n\n/**\n * Register standard tags in a specific tags store.\n * Matches Rust's register_tags_in() function.\n *\n * @param tagsStore - The tags store to register tags into\n */\nexport const registerTagsIn = (tagsStore: TagsStore): void => {\n const tags = [createTag(TAG_DATE, TAG_NAME_DATE)];\n tagsStore.insertAll(tags);\n\n // Set summarizer for date tag\n tagsStore.setSummarizer(TAG_DATE, (untaggedCbor: Cbor, _flat: boolean): string => {\n try {\n return CborDate.fromUntaggedCbor(untaggedCbor).toString();\n } catch {\n return diagnostic(untaggedCbor);\n }\n });\n};\n\n/**\n * Register standard tags in the global tags store.\n * Matches Rust's register_tags() function.\n *\n * This function is idempotent - calling it multiple times is safe.\n */\nexport const registerTags = (): void => {\n const globalStore = getGlobalTagsStore();\n registerTagsIn(globalStore);\n};\n\n/**\n * Converts an array of tag values to their corresponding Tag objects.\n * Matches Rust's tags_for_values() function.\n *\n * This function looks up each tag value in the global tag registry and returns\n * an array of complete Tag objects. For any tag values that aren't\n * registered in the global registry, it creates a basic Tag with just the\n * value (no name).\n *\n * @param values - Array of numeric tag values to convert\n * @returns Array of Tag objects corresponding to the input values\n *\n * @example\n * ```typescript\n * // Register some tags first\n * registerTags();\n *\n * // Convert tag values to Tag objects\n * const tags = tagsForValues([1, 42, 999]);\n *\n * // The first tag (value 1) should be registered as \"date\"\n * console.log(tags[0].value); // 1\n * console.log(tags[0].name); // \"date\"\n *\n * // Unregistered tags will have a value but no name\n * console.log(tags[1].value); // 42\n * console.log(tags[2].value); // 999\n * ```\n */\nexport const tagsForValues = (values: (number | bigint)[]): Tag[] => {\n const globalStore = getGlobalTagsStore();\n return values.map((value) => {\n const tag = globalStore.tagForValue(value);\n if (tag !== undefined) {\n return tag;\n }\n // Create basic tag with just the value\n return createTag(value);\n });\n};\n","/**\n * Set data structure for CBOR with tag(258) encoding.\n *\n * A Set is encoded as an array with no duplicate elements,\n * tagged with tag(258) to indicate set semantics.\n *\n * @module set\n */\n\nimport { type Cbor, MajorType, type CborInput } from \"./cbor\";\nimport { cbor, cborData } from \"./cbor\";\nimport { CborMap } from \"./map\";\nimport { createTag, type Tag } from \"./tag\";\nimport { TAG_SET } from \"./tags\";\nimport {\n type CborTaggedEncodable,\n type CborTaggedDecodable,\n createTaggedCbor,\n validateTag,\n extractTaggedContent,\n} from \"./cbor-tagged\";\nimport { extractCbor } from \"./conveniences\";\nimport { CborError } from \"./error\";\n\n/**\n * CBOR Set type with tag(258) encoding.\n *\n * Internally uses a CborMap to ensure unique elements with deterministic ordering.\n * Elements are ordered by their CBOR encoding (lexicographic byte order).\n *\n * @example\n * ```typescript\n * // Create set\n * const set = CborSet.fromArray([1, 2, 3]);\n * const set2 = CborSet.fromSet(new Set([1, 2, 3]));\n *\n * // Add elements\n * set.insert(4);\n * set.insert(2); // Duplicate, no effect\n *\n * // Check membership\n * console.log(set.contains(2)); // true\n * console.log(set.contains(99)); // false\n *\n * // Encode to CBOR\n * const tagged = set.taggedCbor();\n * ```\n */\nexport class CborSet implements CborTaggedEncodable, CborTaggedDecodable<CborSet> {\n readonly #map: CborMap;\n\n constructor() {\n this.#map = new CborMap();\n }\n\n // =========================================================================\n // Factory Methods\n // =========================================================================\n\n /**\n * Create CborSet from array.\n *\n * Duplicates are automatically removed.\n *\n * @param items - Array of items to add to the set\n * @returns New CborSet instance\n *\n * @example\n * ```typescript\n * const set = CborSet.fromArray([1, 2, 3, 2, 1]);\n * console.log(set.size); // 3\n * ```\n */\n static fromArray<T extends CborInput>(items: T[]): CborSet {\n const set = new CborSet();\n for (const item of items) {\n set.insert(item);\n }\n return set;\n }\n\n /**\n * Create CborSet from JavaScript Set.\n *\n * @param items - JavaScript Set of items\n * @returns New CborSet instance\n *\n * @example\n * ```typescript\n * const jsSet = new Set([1, 2, 3]);\n * const cborSet = CborSet.fromSet(jsSet);\n * ```\n */\n static fromSet<T extends CborInput>(items: Set<T>): CborSet {\n return CborSet.fromArray(Array.from(items));\n }\n\n /**\n * Create CborSet from iterable.\n *\n * @param items - Iterable of items\n * @returns New CborSet instance\n */\n static fromIterable<T extends CborInput>(items: Iterable<T>): CborSet {\n return CborSet.fromArray(Array.from(items));\n }\n\n // =========================================================================\n // Core Methods\n // =========================================================================\n\n /**\n * Insert an element into the set.\n *\n * If the element already exists, has no effect.\n *\n * @param value - Value to insert\n *\n * @example\n * ```typescript\n * const set = new CborSet();\n * set.insert(1);\n * set.insert(2);\n * set.insert(1); // No effect, already exists\n * ```\n */\n insert(value: CborInput): void {\n const cborValue = encodeCborValue(value);\n // In a set, key and value are the same\n this.#map.set(cborValue, cborValue);\n }\n\n /**\n * Check if set contains an element.\n *\n * @param value - Value to check\n * @returns true if element is in the set\n *\n * @example\n * ```typescript\n * const set = CborSet.fromArray([1, 2, 3]);\n * console.log(set.contains(2)); // true\n * console.log(set.contains(99)); // false\n * ```\n */\n contains(value: CborInput): boolean {\n const cborValue = encodeCborValue(value);\n return this.#map.has(cborValue);\n }\n\n /**\n * Remove an element from the set.\n *\n * @param value - Value to remove\n * @returns true if element was removed, false if not found\n *\n * @example\n * ```typescript\n * const set = CborSet.fromArray([1, 2, 3]);\n * set.delete(2); // Returns true\n * set.delete(99); // Returns false\n * ```\n */\n delete(value: CborInput): boolean {\n const cborValue = encodeCborValue(value);\n return this.#map.delete(cborValue);\n }\n\n /**\n * Remove all elements from the set.\n */\n clear(): void {\n this.#map.clear();\n }\n\n /**\n * Get the number of elements in the set.\n *\n * @returns Number of elements\n */\n get size(): number {\n return this.#map.size;\n }\n\n /**\n * Check if the set is empty.\n *\n * @returns true if set has no elements\n */\n isEmpty(): boolean {\n return this.#map.size === 0;\n }\n\n // =========================================================================\n // Set Operations\n // =========================================================================\n\n /**\n * Create a new set containing elements in this set or the other set.\n *\n * @param other - Other set\n * @returns New set with union of elements\n *\n * @example\n * ```typescript\n * const set1 = CborSet.fromArray([1, 2, 3]);\n * const set2 = CborSet.fromArray([3, 4, 5]);\n * const union = set1.union(set2);\n * // union contains [1, 2, 3, 4, 5]\n * ```\n */\n union(other: CborSet): CborSet {\n const result = new CborSet();\n for (const value of this) {\n result.insert(extractCbor(value) as CborInput);\n }\n for (const value of other) {\n result.insert(extractCbor(value) as CborInput);\n }\n return result;\n }\n\n /**\n * Create a new set containing elements in both this set and the other set.\n *\n * @param other - Other set\n * @returns New set with intersection of elements\n *\n * @example\n * ```typescript\n * const set1 = CborSet.fromArray([1, 2, 3]);\n * const set2 = CborSet.fromArray([2, 3, 4]);\n * const intersection = set1.intersection(set2);\n * // intersection contains [2, 3]\n * ```\n */\n intersection(other: CborSet): CborSet {\n const result = new CborSet();\n for (const value of this) {\n const extracted = extractCbor(value) as CborInput;\n if (other.contains(extracted)) {\n result.insert(extracted);\n }\n }\n return result;\n }\n\n /**\n * Create a new set containing elements in this set but not in the other set.\n *\n * @param other - Other set\n * @returns New set with difference of elements\n *\n * @example\n * ```typescript\n * const set1 = CborSet.fromArray([1, 2, 3]);\n * const set2 = CborSet.fromArray([2, 3, 4]);\n * const diff = set1.difference(set2);\n * // diff contains [1]\n * ```\n */\n difference(other: CborSet): CborSet {\n const result = new CborSet();\n for (const value of this) {\n const extracted = extractCbor(value) as CborInput;\n if (!other.contains(extracted)) {\n result.insert(extracted);\n }\n }\n return result;\n }\n\n /**\n * Check if this set is a subset of another set.\n *\n * @param other - Other set\n * @returns true if all elements of this set are in the other set\n */\n isSubsetOf(other: CborSet): boolean {\n for (const value of this) {\n if (!other.contains(extractCbor(value) as CborInput)) {\n return false;\n }\n }\n return true;\n }\n\n /**\n * Check if this set is a superset of another set.\n *\n * @param other - Other set\n * @returns true if all elements of the other set are in this set\n */\n isSupersetOf(other: CborSet): boolean {\n return other.isSubsetOf(this);\n }\n\n // =========================================================================\n // Iteration\n // =========================================================================\n\n /**\n * Iterate over elements in the set.\n *\n * Elements are returned in deterministic order (by CBOR encoding).\n *\n * @example\n * ```typescript\n * const set = CborSet.fromArray([3, 1, 2]);\n * for (const value of set) {\n * console.log(extractCbor(value));\n * }\n * ```\n */\n *[Symbol.iterator](): Iterator<Cbor> {\n for (const [_, value] of this.#map) {\n yield value;\n }\n }\n\n /**\n * Get all values as an array.\n *\n * @returns Array of CBOR values in deterministic order\n *\n * @example\n * ```typescript\n * const set = CborSet.fromArray([3, 1, 2]);\n * const values = set.values();\n * // Values in deterministic order\n * ```\n */\n values(): Cbor[] {\n return Array.from(this);\n }\n\n /**\n * Execute a function for each element.\n *\n * @param callback - Function to call for each element\n *\n * @example\n * ```typescript\n * set.forEach(value => {\n * console.log(extractCbor(value));\n * });\n * ```\n */\n forEach(callback: (value: Cbor) => void): void {\n for (const value of this) {\n callback(value);\n }\n }\n\n // =========================================================================\n // CborTagged Implementation\n // =========================================================================\n\n cborTags(): Tag[] {\n return [createTag(TAG_SET, \"set\")];\n }\n\n untaggedCbor(): Cbor {\n // Encode as an array of values\n const values = this.values();\n return cbor(values);\n }\n\n taggedCbor(): Cbor {\n return createTaggedCbor(this);\n }\n\n fromUntaggedCbor(c: Cbor): CborSet {\n if (c.type !== MajorType.Array) {\n throw new CborError({ type: \"WrongType\" });\n }\n\n this.clear();\n for (const value of c.value) {\n this.insert(extractCbor(value) as CborInput);\n }\n\n return this;\n }\n\n fromTaggedCbor(c: Cbor): CborSet {\n const expectedTags = this.cborTags();\n validateTag(c, expectedTags);\n const content = extractTaggedContent(c);\n return this.fromUntaggedCbor(content);\n }\n\n /**\n * Decode a CborSet from tagged CBOR (static method).\n *\n * @param cbor - Tagged CBOR value with tag(258)\n * @returns Decoded CborSet instance\n */\n static fromTaggedCborStatic(cbor: Cbor): CborSet {\n return new CborSet().fromTaggedCbor(cbor);\n }\n\n // =========================================================================\n // Conversion\n // =========================================================================\n\n /**\n * Convert to CBOR array (untagged).\n *\n * @returns CBOR array\n */\n toCbor(): Cbor {\n return this.untaggedCbor();\n }\n\n /**\n * Convert to CBOR bytes (tagged).\n *\n * @returns Encoded CBOR bytes\n */\n toBytes(): Uint8Array {\n return cborData(this.taggedCbor());\n }\n\n /**\n * Convert to JavaScript Set.\n *\n * @returns JavaScript Set with extracted values\n *\n * @example\n * ```typescript\n * const cborSet = CborSet.fromArray([1, 2, 3]);\n * const jsSet = cborSet.toSet();\n * console.log(jsSet.has(1)); // true\n * ```\n */\n toSet(): Set<unknown> {\n const result = new Set();\n for (const value of this) {\n result.add(extractCbor(value));\n }\n return result;\n }\n\n /**\n * Convert to JavaScript Array.\n *\n * @returns Array with extracted values\n */\n toArray(): unknown[] {\n return Array.from(this.toSet());\n }\n\n // =========================================================================\n // Display\n // =========================================================================\n\n /**\n * Get diagnostic notation for the set.\n *\n * @returns String representation\n *\n * @example\n * ```typescript\n * const set = CborSet.fromArray([1, 2, 3]);\n * console.log(set.diagnostic); // \"[1, 2, 3]\"\n * ```\n */\n get diagnostic(): string {\n const items = this.values()\n .map((v) => {\n const extracted = extractCbor(v);\n if (typeof extracted === \"string\") {\n return `\"${extracted}\"`;\n }\n return String(extracted);\n })\n .join(\", \");\n return `[${items}]`;\n }\n\n /**\n * Convert to string (same as diagnostic).\n *\n * @returns String representation\n */\n toString(): string {\n return this.diagnostic;\n }\n\n /**\n * Convert to JSON (returns array of values).\n *\n * @returns Array for JSON serialization\n */\n toJSON(): unknown[] {\n return this.toArray();\n }\n}\n\n// ============================================================================\n// Helper Functions\n// ============================================================================\n\n/**\n * Convert a value to CBOR for use in set operations.\n *\n * @internal\n */\nfunction encodeCborValue(value: CborInput): Cbor {\n if (typeof value === \"object\" && value !== null && \"isCbor\" in value && value.isCbor === true) {\n return value as Cbor;\n }\n return cbor(value);\n}\n","/**\n * Byte string utilities for dCBOR.\n *\n * Represents a CBOR byte string (major type 2).\n *\n * `ByteString` is a wrapper around a byte array, optimized for use in CBOR\n * encoding and decoding operations. It provides a richer API for working with\n * byte data in the context of CBOR compared to using raw `Uint8Array` values.\n *\n * In dCBOR, byte strings follow the general deterministic encoding rules:\n * - They must use definite-length encoding\n * - Their length must be encoded in the shortest possible form\n *\n * @module byte-string\n */\n\nimport { type Cbor, MajorType, cbor as toCbor } from \"./cbor\";\nimport { CborError } from \"./error\";\n\n/**\n * Represents a CBOR byte string (major type 2).\n *\n * Use Cases:\n * - Binary data such as images, audio, or other non-text content\n * - Cryptographic values like hashes, signatures, and public keys\n * - Embedded CBOR (wrapped with tag 24)\n * - Other serialized data formats embedded in CBOR\n *\n * @example\n * ```typescript\n * // Creating a byte string from various sources\n * const bytes1 = new ByteString(new Uint8Array([1, 2, 3, 4]));\n * const bytes2 = ByteString.from([5, 6, 7, 8]);\n * const bytes3 = ByteString.from(new Uint8Array([9, 10, 11, 12]));\n *\n * // Converting to and from CBOR\n * const cborValue = bytes1.toCbor();\n *\n * // ByteString provides Uint8Array-like operations\n * const bytes = new ByteString(new Uint8Array([1, 2]));\n * bytes.extend(new Uint8Array([3, 4]));\n * assert(bytes.len() === 4);\n * assert.deepEqual(bytes.data(), new Uint8Array([1, 2, 3, 4]));\n * ```\n */\nexport class ByteString {\n #data: Uint8Array;\n\n /**\n * Creates a new `ByteString` from a Uint8Array or array of bytes.\n *\n * @param data - The byte data\n *\n * @example\n * ```typescript\n * // From a Uint8Array\n * const bytes1 = new ByteString(new Uint8Array([1, 2, 3, 4]));\n *\n * // From a number array\n * const bytes2 = new ByteString(new Uint8Array([5, 6, 7, 8]));\n * ```\n */\n constructor(data: Uint8Array | number[]) {\n if (Array.isArray(data)) {\n this.#data = new Uint8Array(data);\n } else {\n this.#data = new Uint8Array(data);\n }\n }\n\n /**\n * Creates a new `ByteString` from various input types.\n *\n * @param data - Uint8Array, number array, or string\n * @returns New ByteString instance\n *\n * @example\n * ```typescript\n * const bytes1 = ByteString.from([1, 2, 3, 4]);\n * const bytes2 = ByteString.from(new Uint8Array([5, 6, 7, 8]));\n * const bytes3 = ByteString.from(\"hello\");\n * ```\n */\n static from(data: Uint8Array | number[] | string): ByteString {\n if (typeof data === \"string\") {\n return new ByteString(new TextEncoder().encode(data));\n }\n return new ByteString(data);\n }\n\n /**\n * Returns a reference to the underlying byte data.\n *\n * @returns The raw bytes\n *\n * @example\n * ```typescript\n * const bytes = new ByteString(new Uint8Array([1, 2, 3, 4]));\n * assert.deepEqual(bytes.data(), new Uint8Array([1, 2, 3, 4]));\n *\n * // You can use standard slice operations on the result\n * assert.deepEqual(bytes.data().slice(1, 3), new Uint8Array([2, 3]));\n * ```\n */\n data(): Uint8Array {\n return this.#data;\n }\n\n /**\n * Returns the length of the byte string in bytes.\n *\n * @returns Number of bytes\n *\n * @example\n * ```typescript\n * const empty = new ByteString(new Uint8Array([]));\n * assert(empty.len() === 0);\n *\n * const bytes = new ByteString(new Uint8Array([1, 2, 3, 4]));\n * assert(bytes.len() === 4);\n * ```\n */\n len(): number {\n return this.#data.length;\n }\n\n /**\n * Returns `true` if the byte string contains no bytes.\n *\n * @returns true if empty\n *\n * @example\n * ```typescript\n * const empty = new ByteString(new Uint8Array([]));\n * assert(empty.isEmpty());\n *\n * const bytes = new ByteString(new Uint8Array([1, 2, 3, 4]));\n * assert(!bytes.isEmpty());\n * ```\n */\n isEmpty(): boolean {\n return this.#data.length === 0;\n }\n\n /**\n * Extends the byte string with additional bytes.\n *\n * @param other - Bytes to append\n *\n * @example\n * ```typescript\n * const bytes = new ByteString(new Uint8Array([1, 2]));\n * bytes.extend(new Uint8Array([3, 4]));\n * assert.deepEqual(bytes.data(), new Uint8Array([1, 2, 3, 4]));\n *\n * // You can extend with different types\n * bytes.extend([5, 6]);\n * assert.deepEqual(bytes.data(), new Uint8Array([1, 2, 3, 4, 5, 6]));\n * ```\n */\n extend(other: Uint8Array | number[]): void {\n const otherArray = Array.isArray(other) ? new Uint8Array(other) : other;\n const newData = new Uint8Array(this.#data.length + otherArray.length);\n newData.set(this.#data, 0);\n newData.set(otherArray, this.#data.length);\n this.#data = newData;\n }\n\n /**\n * Creates a new Uint8Array containing a copy of the byte string's data.\n *\n * @returns Copy of the data\n *\n * @example\n * ```typescript\n * const bytes = new ByteString(new Uint8Array([1, 2, 3, 4]));\n * const arr = bytes.toUint8Array();\n * assert.deepEqual(arr, new Uint8Array([1, 2, 3, 4]));\n *\n * // The returned array is a clone, so you can modify it independently\n * const arr2 = bytes.toUint8Array();\n * arr2[0] = 99;\n * assert.deepEqual(bytes.data(), new Uint8Array([1, 2, 3, 4])); // original unchanged\n * ```\n */\n toUint8Array(): Uint8Array {\n return new Uint8Array(this.#data);\n }\n\n /**\n * Returns an iterator over the bytes in the byte string.\n *\n * @returns Iterator yielding each byte\n *\n * @example\n * ```typescript\n * const bytes = new ByteString(new Uint8Array([1, 2, 3]));\n * const iter = bytes.iter();\n *\n * assert(iter.next().value === 1);\n * assert(iter.next().value === 2);\n * assert(iter.next().value === 3);\n * assert(iter.next().done);\n *\n * // You can also use for loops\n * let sum = 0;\n * for (const byte of bytes) {\n * sum += byte;\n * }\n * assert(sum === 6);\n * ```\n */\n iter(): Iterator<number> {\n return this.#data.values();\n }\n\n /**\n * Makes ByteString iterable.\n */\n [Symbol.iterator](): Iterator<number> {\n return this.iter();\n }\n\n /**\n * Converts the ByteString to a CBOR value.\n *\n * @returns CBOR byte string\n *\n * @example\n * ```typescript\n * const bytes = new ByteString(new Uint8Array([1, 2, 3, 4]));\n * const cborValue = bytes.toCbor();\n * ```\n */\n toCbor(): Cbor {\n return toCbor(this.#data);\n }\n\n /**\n * Attempts to convert a CBOR value into a ByteString.\n *\n * @param cbor - CBOR value\n * @returns ByteString if successful\n * @throws Error if the CBOR value is not a byte string\n *\n * @example\n * ```typescript\n * const cborValue = toCbor(new Uint8Array([1, 2, 3, 4]));\n * const bytes = ByteString.fromCbor(cborValue);\n * assert.deepEqual(bytes.data(), new Uint8Array([1, 2, 3, 4]));\n *\n * // Converting from a different CBOR type throws\n * const cborInt = toCbor(42);\n * try {\n * ByteString.fromCbor(cborInt); // throws\n * } catch(e) {\n * // Error: Wrong type\n * }\n * ```\n */\n static fromCbor(cbor: Cbor): ByteString {\n if (cbor.type !== MajorType.ByteString) {\n throw new CborError({ type: \"WrongType\" });\n }\n return new ByteString(cbor.value);\n }\n\n /**\n * Get element at index.\n *\n * @param index - Index to access\n * @returns Byte at index or undefined\n */\n at(index: number): number | undefined {\n return this.#data[index];\n }\n\n /**\n * Equality comparison.\n *\n * @param other - ByteString to compare with\n * @returns true if equal\n */\n equals(other: ByteString): boolean {\n if (this.#data.length !== other.#data.length) return false;\n for (let i = 0; i < this.#data.length; i++) {\n if (this.#data[i] !== other.#data[i]) return false;\n }\n return true;\n }\n\n /**\n * Clone this ByteString.\n *\n * @returns New ByteString with copied data\n */\n clone(): ByteString {\n return new ByteString(this.toUint8Array());\n }\n}\n"],"x_google_ignoreList":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,27],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,QAAO,UAAU;;;;;;;;AASjB,UAAS,OAAO,WAAY;;;;;;;;;;AAY5B,UAAS,WAAW,SAAU,OAAO;AACjC,SAAO;;;;;;;;;;;;;;;;;AAkBX,UAAS,KAAK,SAAU,IAAK,SAAS;AAClC,YAAU,WAAW,OAAO;AAC5B,OAAK,MAAM,SAAS;EACpB,IAAI,YAAY,SAAU,GAAG,GAAG;AAC5B,UAAO,QAAQ,GAAG,EAAE,EAAE,GAAG,EAAE,CAAC;;AAEhC,YAAU,UAAU;AACpB,YAAU,KAAK;AACf,SAAO;;AAIX,UAAS,MAAM,SAAU,KAAK;AAC1B,SAAO,SAAU,QAAQ;AACrB,UAAO,OA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