@iota-pico/data
Version:
IOTA Pico Framework Data Structures and Helpers
16 lines (14 loc) • 28.2 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@iota-pico/core/dist/helpers/objectHelper"),require("@iota-pico/core/dist/helpers/numberHelper"),require("@iota-pico/core/dist/helpers/stringHelper"),require("@iota-pico/core/dist/error/coreError"),require("@iota-pico/core/dist/helpers/jsonHelper"),require("@iota-pico/core/dist/helpers/arrayHelper")):"function"==typeof define&&define.amd?define("@iota-pico/data",["@iota-pico/core/dist/helpers/objectHelper","@iota-pico/core/dist/helpers/numberHelper","@iota-pico/core/dist/helpers/stringHelper","@iota-pico/core/dist/error/coreError","@iota-pico/core/dist/helpers/jsonHelper","@iota-pico/core/dist/helpers/arrayHelper"],e):"object"==typeof exports?exports["@iota-pico/data"]=e(require("@iota-pico/core/dist/helpers/objectHelper"),require("@iota-pico/core/dist/helpers/numberHelper"),require("@iota-pico/core/dist/helpers/stringHelper"),require("@iota-pico/core/dist/error/coreError"),require("@iota-pico/core/dist/helpers/jsonHelper"),require("@iota-pico/core/dist/helpers/arrayHelper")):t.IotaPicoData=e(t["@iota-pico/core/dist/helpers/objectHelper"],t["@iota-pico/core/dist/helpers/numberHelper"],t["@iota-pico/core/dist/helpers/stringHelper"],t["@iota-pico/core/dist/error/coreError"],t["@iota-pico/core/dist/helpers/jsonHelper"],t["@iota-pico/core/dist/helpers/arrayHelper"])}("undefined"!=typeof self?self:this,function(t,e,r,n,o,s){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=14)}([function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(16);e.DataError=class extends n.CoreError{constructor(t,e,r){super(t,e,r),this.domain="Data"}}},function(e,r){e.exports=t},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(3),o=r(6),s=r(0);class a{constructor(t){this._trytes=t}static fromString(t,e=0){if(!o.StringHelper.isString(t))throw new s.DataError("The value must be a non empty string");if(!n.NumberHelper.isInteger(e)||e<0)throw new s.DataError("The length must be >= 0");if(!a.isValid(t,e))throw new s.DataError("The value and length do not contain valid trytes",{value:t,length:e});return new a(t)}static isValid(t,e=0){return!!o.StringHelper.isString(t)&&new RegExp(`^[9A-Z]{${e||"0,"}}$`).test(t)}toString(){return this._trytes}length(){return this._trytes.length}sub(t,e){if(!n.NumberHelper.isInteger(t)||t<0)throw new s.DataError("The start must be a number >= 0");if(!n.NumberHelper.isInteger(e)||t+e>this._trytes.length)throw new s.DataError(`The start + length must <= ${this._trytes.length}`);return a.fromString(this._trytes.substr(t,e))}}a.ALPHABET="9ABCDEFGHIJKLMNOPQRSTUVWXYZ",e.Trytes=a},function(t,r){t.exports=e},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(2);class a{constructor(t,e){this._addressTrytes=t,this._checksumTrytes=e}static fromTrytes(t){if(!n.ObjectHelper.isType(t,s.Trytes))throw new o.DataError("The address should be a valid Trytes object");const e=t.toString();if(e.length!==a.LENGTH&&e.length!==a.LENGTH_WITH_CHECKSUM)throw new o.DataError(`The address should either be ${a.LENGTH} or ${a.LENGTH_WITH_CHECKSUM} characters in length`,{length:e.length});const r=e.substr(0,a.LENGTH);let i;return e.length===a.LENGTH_WITH_CHECKSUM&&(i=e.substr(a.LENGTH)),new a(r,i)}toTrytes(){return s.Trytes.fromString(this._addressTrytes)}toTrytesWithChecksum(){if(n.ObjectHelper.isEmpty(this._checksumTrytes))throw new o.DataError("This address has no checksum calculated for it");return s.Trytes.fromString(this._addressTrytes+this._checksumTrytes)}toString(){return n.ObjectHelper.isEmpty(this._checksumTrytes)?this._addressTrytes:this._addressTrytes+this._checksumTrytes}}a.LENGTH=81,a.LENGTH_CHECKSUM=9,a.LENGTH_WITH_CHECKSUM=a.LENGTH+a.LENGTH_CHECKSUM,a.EMPTY=a.fromTrytes(s.Trytes.fromString("9".repeat(a.LENGTH))),e.Address=a},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(2);class a{constructor(t){this._trytes=t}static fromTrytes(t){if(!n.ObjectHelper.isType(t,s.Trytes))throw new o.DataError("The tag should be a valid Trytes object");let e=t.toString();if(e.length>a.LENGTH)throw new o.DataError(`The tag should be at most ${a.LENGTH} characters in length`,{length:e.length});for(;e.length<a.LENGTH;)e+="9";return new a(e)}toTrytes(){return s.Trytes.fromString(this._trytes)}toString(){return this._trytes}}a.LENGTH=27,a.EMPTY=a.fromTrytes(s.Trytes.fromString("9".repeat(a.LENGTH))),e.Tag=a},function(t,e){t.exports=r},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(2);class a{constructor(t){this._trytes=t}static fromTrytes(t){if(!n.ObjectHelper.isType(t,s.Trytes))throw new o.DataError("The hash should be a valid Trytes object");const e=t.length();if(e!==a.LENGTH)throw new o.DataError(`The hash should be ${a.LENGTH} characters in length`,{length:e});return new a(t)}toTrytes(){return this._trytes}toString(){return this._trytes.toString()}}a.LENGTH=81,a.EMPTY=a.fromTrytes(s.Trytes.fromString("9".repeat(a.LENGTH))),e.Hash=a},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(2);class a{constructor(t){this._trytes=t}static fromTrytes(t){if(!n.ObjectHelper.isType(t,s.Trytes))throw new o.DataError("The signatureMessageFragment should be a valid Trytes object");const e=t.length();if(e!==a.LENGTH)throw new o.DataError(`The signatureMessageFragment should be ${a.LENGTH} characters in length`,{length:e});return new a(t)}toTrytes(){return this._trytes}toString(){return this._trytes.toString()}}a.LENGTH=2187,a.EMPTY=a.fromTrytes(s.Trytes.fromString("9".repeat(a.LENGTH))),e.SignatureMessageFragment=a},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(3),o=r(1),s=r(0),a=r(13),i=r(2);class u{constructor(t){this._trytes=t}static fromNumber(t,e=u.LENGTH_9){let r;if(!n.NumberHelper.isInteger(e)||e<=0)throw new s.DataError("The length should be a number > 0",{length:e});if(o.ObjectHelper.isEmpty(t))r="9".repeat(e);else{if(!n.NumberHelper.isInteger(t))throw new s.DataError("The value is not an integer",{value:t});const o=a.Trits.fromNumber(t).toNumberArray();for(;o.length<3*e;)o.push(0);r=a.Trits.fromNumberArray(o).toTrytes().toString()}return new u(r)}static fromTrytes(t,e=u.LENGTH_9){if(!o.ObjectHelper.isType(t,i.Trytes))throw new s.DataError("The value should be a valid Trytes object");let r=t.toString();if(!n.NumberHelper.isInteger(e)||e<=0)throw new s.DataError("The length should be a number > 0",{length:e});if(r.length>e)throw new s.DataError("The value contains too many characters",{length:r.length});for(;r.length<e;)r+="9";return new u(r)}toTrytes(){return i.Trytes.fromString(this._trytes)}toNumber(){return a.Trits.fromTrytes(i.Trytes.fromString(this._trytes)).toNumber()}toString(){return this._trytes}valueOf(){return this.toNumber()}}u.LENGTH_9=9,u.EMPTY_9=u.fromNumber(0,u.LENGTH_9),e.TryteNumber=u},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(6),s=r(2),a=r(0);e.AsciiTrytesConverter=class{to(t){if(!o.StringHelper.isString(t))throw new a.DataError("The value must be a string",{value:t});if(!o.StringHelper.isASCII(t))throw new a.DataError("The value contains non ASCII characters",{value:t});let e="";for(let r=0;r<t.length;r++){const n=t.charCodeAt(r),o=n%27,a=(n-o)/27;e+=s.Trytes.ALPHABET[o]+s.Trytes.ALPHABET[a]}return s.Trytes.fromString(e)}from(t){if(!n.ObjectHelper.isType(t,s.Trytes))throw new a.DataError("The trytes parameter is empty or not the correct type");const e=t.toString();if(e.length%2==1)throw new a.DataError("The trytes length must be an even number");let r="";for(let t=0;t<e.length;t+=2){const n=s.Trytes.ALPHABET.indexOf(e[t])+27*s.Trytes.ALPHABET.indexOf(e[t+1]);r+=String.fromCharCode(n)}return r}}},function(t,e){Object.defineProperty(e,"__esModule",{value:!0}),function(t){t[t.low=1]="low",t[t.medium=2]="medium",t[t.high=3]="high"}(e.AddressSecurity||(e.AddressSecurity={}))},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(4),a=r(7),i=r(8),u=r(5),c=r(9),l=r(2);class h{constructor(){}static fromParams(t,e,r,n,o,s,a,i,u,l,T,y,f,m,d){const p=new h;return p.signatureMessageFragment=t,p.address=e,p.value=c.TryteNumber.fromNumber(r,11),p.obsoleteTag=n,p.timestamp=c.TryteNumber.fromNumber(o),p.currentIndex=c.TryteNumber.fromNumber(s),p.lastIndex=c.TryteNumber.fromNumber(a),p.bundle=i,p.trunkTransaction=u,p.branchTransaction=l,p.tag=T,p.attachmentTimestamp=c.TryteNumber.fromNumber(y),p.attachmentTimestampLowerBound=c.TryteNumber.fromNumber(f),p.attachmentTimestampUpperBound=c.TryteNumber.fromNumber(m),p.nonce=d,p}static fromTrytes(t){if(!n.ObjectHelper.isType(t,l.Trytes))throw new o.DataError("The trytes should be a valid Trytes object");const e=t.length();if(e!==h.LENGTH)throw new o.DataError(`The trytes must be ${h.LENGTH} in length`,{length:e});const r=t.sub(2279,16).toString();if(r!==h.CHECK_VALUE)throw new o.DataError("The trytes between 2279 and 2295 should be all 9s",{check:r});const T=new h;let y=0;return T.signatureMessageFragment=i.SignatureMessageFragment.fromTrytes(t.sub(y,i.SignatureMessageFragment.LENGTH)),y+=i.SignatureMessageFragment.LENGTH,T.address=s.Address.fromTrytes(t.sub(y,s.Address.LENGTH)),y+=s.Address.LENGTH,T.value=c.TryteNumber.fromTrytes(t.sub(y,11),11),y+=11,y+=h.CHECK_VALUE_LENGTH,T.obsoleteTag=u.Tag.fromTrytes(t.sub(y,u.Tag.LENGTH)),y+=u.Tag.LENGTH,T.timestamp=c.TryteNumber.fromTrytes(t.sub(y,c.TryteNumber.LENGTH_9)),y+=c.TryteNumber.LENGTH_9,T.currentIndex=c.TryteNumber.fromTrytes(t.sub(y,c.TryteNumber.LENGTH_9)),y+=c.TryteNumber.LENGTH_9,T.lastIndex=c.TryteNumber.fromTrytes(t.sub(y,c.TryteNumber.LENGTH_9)),y+=c.TryteNumber.LENGTH_9,T.bundle=a.Hash.fromTrytes(t.sub(y,a.Hash.LENGTH)),y+=a.Hash.LENGTH,T.trunkTransaction=a.Hash.fromTrytes(t.sub(y,a.Hash.LENGTH)),y+=a.Hash.LENGTH,T.branchTransaction=a.Hash.fromTrytes(t.sub(y,a.Hash.LENGTH)),y+=a.Hash.LENGTH,T.tag=u.Tag.fromTrytes(t.sub(y,u.Tag.LENGTH)),y+=u.Tag.LENGTH,T.attachmentTimestamp=c.TryteNumber.fromTrytes(t.sub(y,c.TryteNumber.LENGTH_9)),y+=c.TryteNumber.LENGTH_9,T.attachmentTimestampLowerBound=c.TryteNumber.fromTrytes(t.sub(y,c.TryteNumber.LENGTH_9)),y+=c.TryteNumber.LENGTH_9,T.attachmentTimestampUpperBound=c.TryteNumber.fromTrytes(t.sub(y,c.TryteNumber.LENGTH_9)),y+=c.TryteNumber.LENGTH_9,T.nonce=u.Tag.fromTrytes(t.sub(y,u.Tag.LENGTH)),T}toTrytes(){if(!n.ObjectHelper.isType(this.signatureMessageFragment,i.SignatureMessageFragment))throw new o.DataError("The signatureMessageFragment must be set to create transaction trytes",{signatureMessageFragment:this.signatureMessageFragment});if(!n.ObjectHelper.isType(this.address,s.Address))throw new o.DataError("The address must be set to create transaction trytes",{address:this.address});if(!n.ObjectHelper.isType(this.obsoleteTag,u.Tag))throw new o.DataError("The obsoleteTag must be set to create transaction trytes",{obsoleteTag:this.obsoleteTag});if(!n.ObjectHelper.isType(this.bundle,a.Hash))throw new o.DataError("The bundle must be set to create transaction trytes",{bundle:this.bundle});if(!n.ObjectHelper.isType(this.trunkTransaction,a.Hash))throw new o.DataError("The trunkTransaction must be set to create transaction trytes",{trunkTransaction:this.trunkTransaction});if(!n.ObjectHelper.isType(this.branchTransaction,a.Hash))throw new o.DataError("The branchTransaction must be set to create transaction trytes",{branchTransaction:this.branchTransaction});if(!n.ObjectHelper.isType(this.nonce,u.Tag))throw new o.DataError("The nonce must be set to create transaction trytes",{nonce:this.nonce});const t=this.signatureMessageFragment.toTrytes().toString()+this.address.toTrytes().toString()+(this.value||h.EMPTY_11).toTrytes().toString()+h.CHECK_VALUE+this.obsoleteTag.toTrytes().toString()+(this.timestamp||c.TryteNumber.EMPTY_9).toTrytes().toString()+(this.currentIndex||c.TryteNumber.EMPTY_9).toTrytes().toString()+(this.lastIndex||c.TryteNumber.EMPTY_9).toTrytes().toString()+this.bundle.toTrytes().toString()+this.trunkTransaction.toTrytes().toString()+this.branchTransaction.toTrytes().toString()+(this.tag||this.obsoleteTag).toTrytes().toString()+(this.attachmentTimestamp||c.TryteNumber.EMPTY_9).toTrytes().toString()+(this.attachmentTimestampLowerBound||c.TryteNumber.EMPTY_9).toTrytes().toString()+(this.attachmentTimestampUpperBound||c.TryteNumber.EMPTY_9).toTrytes().toString()+this.nonce.toTrytes().toString(),e=t.length;if(e!==h.LENGTH)throw new o.DataError(`The trytes must be ${h.LENGTH} in length ${e}`,{length:e});return l.Trytes.fromString(t)}toString(){return`{\n\tsignatureMessageFragment: "${(this.signatureMessageFragment||i.SignatureMessageFragment.EMPTY).toTrytes().toString()}"\n\taddress: "${(this.address||s.Address.EMPTY).toTrytes().toString()}"\n\tvalue: ${(this.value||h.EMPTY_11).toNumber()}\n\tobsoleteTag: "${(this.obsoleteTag||u.Tag.EMPTY).toTrytes().toString()}"\n\ttimestamp: ${(this.timestamp||c.TryteNumber.EMPTY_9).toNumber()}\n\tcurrentIndex: ${(this.currentIndex||c.TryteNumber.EMPTY_9).toNumber()}\n\tlastIndex: ${(this.lastIndex||c.TryteNumber.EMPTY_9).toNumber()}\n\tbundle: "${(this.bundle||a.Hash.EMPTY).toTrytes().toString()}"\n\ttrunkTransaction: "${(this.trunkTransaction||a.Hash.EMPTY).toTrytes().toString()}"\n\tbranchTransaction: "${(this.branchTransaction||a.Hash.EMPTY).toTrytes().toString()}"\n\ttag: "${(this.tag||this.obsoleteTag||u.Tag.EMPTY).toTrytes().toString()}"\n\tattachmentTimestamp: ${(this.attachmentTimestamp||c.TryteNumber.EMPTY_9).toNumber()}\n\tattachmentTimestampLowerBound: ${(this.attachmentTimestampLowerBound||c.TryteNumber.EMPTY_9).toNumber()}\n\tattachmentTimestampUpperBound: ${(this.attachmentTimestampUpperBound||c.TryteNumber.EMPTY_9).toNumber()}\n\tnonce: "${(this.nonce||u.Tag.EMPTY).toTrytes().toString()}"\n}`}}h.LENGTH=2673,h.CHECK_VALUE_LENGTH=16,h.CHECK_VALUE="9".repeat(h.CHECK_VALUE_LENGTH),h.EMPTY_11=c.TryteNumber.fromNumber(0,11),e.Transaction=h},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(20),o=r(3),s=r(1),a=r(0),i=r(2);class u{constructor(t){this._trits=t}static fromArray(t){if(!s.ObjectHelper.isType(t,Int8Array))throw new a.DataError("The value does not contain valid trits");return new u(t)}static fromNumberArray(t){if(!n.ArrayHelper.isTyped(t,Number))throw new a.DataError("The value does not contain valid trits");return new u(new Int8Array(t))}static fromTrytes(t){if(!s.ObjectHelper.isType(t,i.Trytes))throw new a.DataError("The value should be a valid Trytes object");const e=t.toString(),r=new Int8Array(3*e.length);for(let t=0;t<e.length;t++){const n=i.Trytes.ALPHABET.indexOf(e.charAt(t));r[3*t]=u.TRYTES_TRITS[n][0],r[3*t+1]=u.TRYTES_TRITS[n][1],r[3*t+2]=u.TRYTES_TRITS[n][2]}return new u(r)}static fromNumber(t){if(!o.NumberHelper.isInteger(t))throw new a.DataError("The value is not an integer");const e=[];let r=t<0?-t:t;for(;r>0;){let t=r%3;r=Math.floor(r/3),t>1&&(t=-1,r++),e[e.length]=t}if(t<0)for(let t=0;t<e.length;t++)e[t]=-e[t];return new u(new Int8Array(e))}static add(t,e){if(!s.ObjectHelper.isType(t,u))throw new a.DataError("The first should be a valid Trits object");if(!s.ObjectHelper.isType(e,u))throw new a.DataError("The seconds should be a valid Trits object");const r=new Int8Array(Math.max(t._trits.length,e._trits.length));let n,o,i=0;for(let s=0;s<r.length;s++){n=s<t._trits.length?t._trits[s]:0,o=s<e._trits.length?e._trits[s]:0;const a=u.fullAdd(n,o,i);r[s]=a[0],i=a[1]}return u.fromArray(r)}static fullAdd(t,e,r){const n=u.sum(t,e),o=u.cons(t,e),s=u.cons(n,r),a=u.any(o,s),i=u.sum(n,r);return new Int8Array([i,a])}static sum(t,e){const r=t+e;switch(r){case 2:return-1;case-2:return 1;default:return r}}static cons(t,e){return t===e?t:0}static any(t,e){const r=t+e;return r>0?1:r<0?-1:0}toArray(){return this._trits}toNumberArray(){return Array.from(this._trits)}toTrytes(){let t="";for(let e=0;e<this._trits.length;e+=3)for(let r=0;r<i.Trytes.ALPHABET.length;r++)if(u.TRYTES_TRITS[r][0]===this._trits[e]&&u.TRYTES_TRITS[r][1]===this._trits[e+1]&&u.TRYTES_TRITS[r][2]===this._trits[e+2]){t+=i.Trytes.ALPHABET.charAt(r);break}return i.Trytes.fromString(t)}toNumber(){let t=0;for(let e=this._trits.length-1;e>=0;e--)t=3*t+this._trits[e];return t}length(){return this._trits.length}sub(t,e){if(!o.NumberHelper.isInteger(t)||t<0)throw new a.DataError("The start must be a number >= 0");if(!o.NumberHelper.isInteger(e)||t+e>this._trits.length)throw new a.DataError(`The start + length must <= ${this._trits.length}`);return u.fromArray(this._trits.slice(t,t+e))}}u.TRYTES_TRITS=[new Int8Array([0,0,0]),new Int8Array([1,0,0]),new Int8Array([-1,1,0]),new Int8Array([0,1,0]),new Int8Array([1,1,0]),new Int8Array([-1,-1,1]),new Int8Array([0,-1,1]),new Int8Array([1,-1,1]),new Int8Array([-1,0,1]),new Int8Array([0,0,1]),new Int8Array([1,0,1]),new Int8Array([-1,1,1]),new Int8Array([0,1,1]),new Int8Array([1,1,1]),new Int8Array([-1,-1,-1]),new Int8Array([0,-1,-1]),new Int8Array([1,-1,-1]),new Int8Array([-1,0,-1]),new Int8Array([0,0,-1]),new Int8Array([1,0,-1]),new Int8Array([-1,1,-1]),new Int8Array([0,1,-1]),new Int8Array([1,1,-1]),new Int8Array([-1,-1,0]),new Int8Array([0,-1,0]),new Int8Array([1,-1,0]),new Int8Array([-1,0,0])],e.Trits=u},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(15);n.__exportStar(r(10),e),n.__exportStar(r(17),e),n.__exportStar(r(4),e),n.__exportStar(r(11),e),n.__exportStar(r(19),e),n.__exportStar(r(7),e),n.__exportStar(r(21),e),n.__exportStar(r(8),e),n.__exportStar(r(5),e),n.__exportStar(r(12),e),n.__exportStar(r(22),e),n.__exportStar(r(13),e),n.__exportStar(r(9),e),n.__exportStar(r(2),e),n.__exportStar(r(0),e)},function(t,e,r){"use strict";r.r(e),r.d(e,"__extends",function(){return o}),r.d(e,"__assign",function(){return s}),r.d(e,"__rest",function(){return a}),r.d(e,"__decorate",function(){return i}),r.d(e,"__param",function(){return u}),r.d(e,"__metadata",function(){return c}),r.d(e,"__awaiter",function(){return l}),r.d(e,"__generator",function(){return h}),r.d(e,"__exportStar",function(){return T}),r.d(e,"__values",function(){return y}),r.d(e,"__read",function(){return f}),r.d(e,"__spread",function(){return m}),r.d(e,"__await",function(){return d}),r.d(e,"__asyncGenerator",function(){return p}),r.d(e,"__asyncDelegator",function(){return b}),r.d(e,"__asyncValues",function(){return g}),r.d(e,"__makeTemplateObject",function(){return _}),r.d(e,"__importStar",function(){return w}),r.d(e,"__importDefault",function(){return E});
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
var n=function(t,e){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r])})(t,e)};function o(t,e){function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var s=function(){return(s=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function a(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){var o,s=arguments.length,a=s<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,n);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(a=(s<3?o(a):s>3?o(e,r,a):o(e,r))||a);return s>3&&a&&Object.defineProperty(e,r,a),a}function u(t,e){return function(r,n){e(r,n,t)}}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function l(t,e,r,n){return new(r||(r=Promise))(function(o,s){function a(t){try{u(n.next(t))}catch(t){s(t)}}function i(t){try{u(n.throw(t))}catch(t){s(t)}}function u(t){t.done?o(t.value):new r(function(e){e(t.value)}).then(a,i)}u((n=n.apply(t,e||[])).next())})}function h(t,e){var r,n,o,s,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(s){return function(i){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===s[0]||2===s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,i])}}}function T(t,e){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}function y(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}}function f(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,s=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return a}function m(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(f(arguments[e]));return t}function d(t){return this instanceof d?(this.v=t,this):new d(t)}function p(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(t,e||[]),s=[];return n={},a("next"),a("throw"),a("return"),n[Symbol.asyncIterator]=function(){return this},n;function a(t){o[t]&&(n[t]=function(e){return new Promise(function(r,n){s.push([t,e,r,n])>1||i(t,e)})})}function i(t,e){try{!function(t){t.value instanceof d?Promise.resolve(t.value.v).then(u,c):l(s[0][2],t)}(o[t](e))}catch(t){l(s[0][3],t)}}function u(t){i("next",t)}function c(t){i("throw",t)}function l(t,e){t(e),s.shift(),s.length&&i(s[0][0],s[0][1])}}function b(t){var e,r;return e={},n("next"),n("throw",function(t){throw t}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(n,o){e[n]=t[n]?function(e){return(r=!r)?{value:d(t[n](e)),done:"return"===n}:o?o(e):e}:o}}function g(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,r=t[Symbol.asyncIterator];return r?r.call(t):(t=y(t),e={},n("next"),n("throw"),n("return"),e[Symbol.asyncIterator]=function(){return this},e);function n(r){e[r]=t[r]&&function(e){return new Promise(function(n,o){!function(t,e,r,n){Promise.resolve(n).then(function(e){t({value:e,done:r})},e)}(n,o,(e=t[r](e)).done,e.value)})}}}function _(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function w(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var r in t)Object.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e.default=t,e}function E(t){return t&&t.__esModule?t:{default:t}}},function(t,e){t.exports=n},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(18),o=r(1),s=r(6),a=r(2),i=r(0),u=r(10);e.ObjectTrytesConverter=class{to(t){let e;try{e=n.JsonHelper.stringify(t)}catch(t){throw new i.DataError("There was a problem converting the object to JSON",{err:t})}const r=s.StringHelper.encodeNonASCII(e);return(new u.AsciiTrytesConverter).to(r)}from(t){if(!o.ObjectHelper.isType(t,a.Trytes))throw new i.DataError("The trytes parameter is empty or not the correct type");let e=(new u.AsciiTrytesConverter).from(t);e=e.replace(/\0+$/,"");const r=s.StringHelper.decodeNonASCII(e);let n;try{n=JSON.parse(r)}catch(t){throw new i.DataError("There was a problem converting the object from JSON",{err:t})}return n}}},function(t,e){t.exports=o},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(1),o=r(0),s=r(7),a=r(8),i=r(5),u=r(12),c=r(9);e.Bundle=class{constructor(){this.transactions=[]}addTransactions(t,e,r,n,o){for(let s=0;s<t;s++)this.transactions.push(u.Transaction.fromParams(void 0,e,0===s?r:0,n,o,void 0,void 0,void 0,void 0,void 0,n,void 0,void 0,void 0,void 0))}addSignatureMessageFragments(t){if(n.ObjectHelper.isEmpty(t))throw new o.DataError("The signatureMessageFragments should be an array of SignatureMessageFragments");for(let e=0;e<this.transactions.length;e++)this.transactions[e].signatureMessageFragment=t[e]||a.SignatureMessageFragment.EMPTY,this.transactions[e].trunkTransaction=s.Hash.EMPTY,this.transactions[e].branchTransaction=s.Hash.EMPTY,this.transactions[e].attachmentTimestamp=c.TryteNumber.EMPTY_9,this.transactions[e].attachmentTimestampLowerBound=c.TryteNumber.EMPTY_9,this.transactions[e].attachmentTimestampUpperBound=c.TryteNumber.EMPTY_9,this.transactions[e].nonce=i.Tag.EMPTY}}},function(t,e){t.exports=s},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(3),o=r(1),s=r(0),a=r(4),i=r(11);class u{constructor(){}static fromParams(t,e,r,c){if(!o.ObjectHelper.isType(t,a.Address))throw new s.DataError("The address should be a valid Address object");if(!n.NumberHelper.isInteger(e)||e<i.AddressSecurity.low||e>i.AddressSecurity.high)throw new s.DataError(`The security should be a number between ${i.AddressSecurity.low} and ${i.AddressSecurity.high}`);if(!n.NumberHelper.isInteger(r)||r<0)throw new s.DataError("The keyIndex should be a number >= 0");if(!n.NumberHelper.isInteger(c)||c<0)throw new s.DataError("The balance should be a number >= 0");const l=new u;return l.address=t,l.security=e,l.keyIndex=r,l.balance=c,l}}e.Input=u},function(t,e,r){Object.defineProperty(e,"__esModule",{value:!0});const n=r(3),o=r(1),s=r(0),a=r(4),i=r(5),u=r(2);class c{constructor(){}static fromParams(t,e,r,l){if(!o.ObjectHelper.isType(t,a.Address))throw new s.DataError("The address should be a valid Address object");if(!n.NumberHelper.isInteger(e)||e<0)throw new s.DataError("The value should be a number >= 0");if(!o.ObjectHelper.isEmpty(r)&&!o.ObjectHelper.isType(r,u.Trytes))throw new s.DataError("The message should be a valid Trytes object");if(!o.ObjectHelper.isEmpty(l)&&!o.ObjectHelper.isType(l,i.Tag))throw new s.DataError("The tag should be a valid Tag object");const h=new c;return h.address=t,h.value=e,h.message=r,h.tag=l,h}}e.Transfer=c}])});