>>=y,p-=y),p<15&&(d+=z[n++]<>>=y=v>>>24,p-=y,!(16&(y=v>>>16&255))){if(0==(64&y)){v=_[(65535&v)+(d&(1<>>=y,p-=y,(y=s-a)>3,d&=(1<<(p-=w<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function s(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new I.Buf16(320),this.work=new I.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function a(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg=\"\",t.wrap&&(e.adler=1&t.wrap),t.mode=P,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new I.Buf32(n),t.distcode=t.distdyn=new I.Buf32(i),t.sane=1,t.back=-1,N):U}function o(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,a(e)):U}function h(e,t){var r,n;return e&&e.state?(n=e.state,t<0?(r=0,t=-t):(r=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15=s.wsize?(I.arraySet(s.window,t,r-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):(n<(i=s.wsize-s.wnext)&&(i=n),I.arraySet(s.window,t,r-n,i,s.wnext),(n-=i)?(I.arraySet(s.window,t,r-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=i,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,r.check=B(r.check,E,2,0),l=u=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&u)<<8)+(u>>8))%31){e.msg=\"incorrect header check\",r.mode=30;break}if(8!=(15&u)){e.msg=\"unknown compression method\",r.mode=30;break}if(l-=4,k=8+(15&(u>>>=4)),0===r.wbits)r.wbits=k;else if(k>r.wbits){e.msg=\"invalid window size\",r.mode=30;break}r.dmax=1<>8&1),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=3;case 3:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>8&255,E[2]=u>>>16&255,E[3]=u>>>24&255,r.check=B(r.check,E,4,0)),l=u=0,r.mode=4;case 4:for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>8),512&r.flags&&(E[0]=255&u,E[1]=u>>>8&255,r.check=B(r.check,E,2,0)),l=u=0,r.mode=5;case 5:if(1024&r.flags){for(;l<16;){if(0===o)break e;o--,u+=n[s++]<>>8&255,r.check=B(r.check,E,2,0)),l=u=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&(o<(d=r.length)&&(d=o),d&&(r.head&&(k=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),I.arraySet(r.head.extra,n,s,d,k)),512&r.flags&&(r.check=B(r.check,n,d,s)),o-=d,s+=d,r.length-=d),r.length))break e;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===o)break e;for(d=0;k=n[s+d++],r.head&&k&&r.length<65536&&(r.head.name+=String.fromCharCode(k)),k&&d>9&1,r.head.done=!0),e.adler=r.check=0,r.mode=12;break;case 10:for(;l<32;){if(0===o)break e;o--,u+=n[s++]<>>=7&l,l-=7&l,r.mode=27;break}for(;l<3;){if(0===o)break e;o--,u+=n[s++]<>>=1)){case 0:r.mode=14;break;case 1:if(j(r),r.mode=20,6!==t)break;u>>>=2,l-=2;break e;case 2:r.mode=17;break;case 3:e.msg=\"invalid block type\",r.mode=30}u>>>=2,l-=2;break;case 14:for(u>>>=7&l,l-=7&l;l<32;){if(0===o)break e;o--,u+=n[s++]<>>16^65535)){e.msg=\"invalid stored block lengths\",r.mode=30;break}if(r.length=65535&u,l=u=0,r.mode=15,6===t)break e;case 15:r.mode=16;case 16:if(d=r.length){if(o>>=5,l-=5,r.ndist=1+(31&u),u>>>=5,l-=5,r.ncode=4+(15&u),u>>>=4,l-=4,286>>=3,l-=3}for(;r.have<19;)r.lens[A[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,S={bits:r.lenbits},x=T(0,r.lens,0,19,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg=\"invalid code lengths set\",r.mode=30;break}r.have=0,r.mode=19;case 19:for(;r.have>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=_,l-=_,r.lens[r.have++]=b;else{if(16===b){for(z=_+2;l>>=_,l-=_,0===r.have){e.msg=\"invalid bit length repeat\",r.mode=30;break}k=r.lens[r.have-1],d=3+(3&u),u>>>=2,l-=2}else if(17===b){for(z=_+3;l>>=_)),u>>>=3,l-=3}else{for(z=_+7;l>>=_)),u>>>=7,l-=7}if(r.have+d>r.nlen+r.ndist){e.msg=\"invalid bit length repeat\",r.mode=30;break}for(;d--;)r.lens[r.have++]=k}}if(30===r.mode)break;if(0===r.lens[256]){e.msg=\"invalid code -- missing end-of-block\",r.mode=30;break}if(r.lenbits=9,S={bits:r.lenbits},x=T(D,r.lens,0,r.nlen,r.lencode,0,r.work,S),r.lenbits=S.bits,x){e.msg=\"invalid literal/lengths set\",r.mode=30;break}if(r.distbits=6,r.distcode=r.distdyn,S={bits:r.distbits},x=T(F,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,S),r.distbits=S.bits,x){e.msg=\"invalid distances set\",r.mode=30;break}if(r.mode=20,6===t)break e;case 20:r.mode=21;case 21:if(6<=o&&258<=h){e.next_out=a,e.avail_out=h,e.next_in=s,e.avail_in=o,r.hold=u,r.bits=l,R(e,c),a=e.next_out,i=e.output,h=e.avail_out,s=e.next_in,n=e.input,o=e.avail_in,u=r.hold,l=r.bits,12===r.mode&&(r.back=-1);break}for(r.back=0;g=(C=r.lencode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,r.length=b,0===g){r.mode=26;break}if(32&g){r.back=-1,r.mode=12;break}if(64&g){e.msg=\"invalid literal/length code\",r.mode=30;break}r.extra=15&g,r.mode=22;case 22:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;g=(C=r.distcode[u&(1<>>16&255,b=65535&C,!((_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>v)])>>>16&255,b=65535&C,!(v+(_=C>>>24)<=l);){if(0===o)break e;o--,u+=n[s++]<>>=v,l-=v,r.back+=v}if(u>>>=_,l-=_,r.back+=_,64&g){e.msg=\"invalid distance code\",r.mode=30;break}r.offset=b,r.extra=15&g,r.mode=24;case 24:if(r.extra){for(z=r.extra;l>>=r.extra,l-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){e.msg=\"invalid distance too far back\",r.mode=30;break}r.mode=25;case 25:if(0===h)break e;if(d=c-h,r.offset>d){if((d=r.offset-d)>r.whave&&r.sane){e.msg=\"invalid distance too far back\",r.mode=30;break}p=d>r.wnext?(d-=r.wnext,r.wsize-d):r.wnext-d,d>r.length&&(d=r.length),m=r.window}else m=i,p=a-r.offset,d=r.length;for(hd?(m=R[T+a[v]],A[I+a[v]]):(m=96,0),h=1<>S)+(u-=h)]=p<<24|m<<16|_|0,0!==u;);for(h=1<>=1;if(0!==h?(E&=h-1,E+=h):E=0,v++,0==--O[b]){if(b===w)break;b=t[r+a[v]]}if(k>>7)]}function U(e,t){e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255}function P(e,t,r){e.bi_valid>d-r?(e.bi_buf|=t<>d-e.bi_valid,e.bi_valid+=r-d):(e.bi_buf|=t<>>=1,r<<=1,0<--t;);return r>>>1}function Z(e,t,r){var n,i,s=new Array(g+1),a=0;for(n=1;n<=g;n++)s[n]=a=a+r[n-1]<<1;for(i=0;i<=t;i++){var o=e[2*i+1];0!==o&&(e[2*i]=j(s[o]++,o))}}function W(e){var t;for(t=0;t>1;1<=r;r--)G(e,s,r);for(i=h;r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],G(e,s,1),n=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=n,s[2*i]=s[2*r]+s[2*n],e.depth[i]=(e.depth[r]>=e.depth[n]?e.depth[r]:e.depth[n])+1,s[2*r+1]=s[2*n+1]=i,e.heap[1]=i++,G(e,s,1),2<=e.heap_len;);e.heap[--e.heap_max]=e.heap[1],function(e,t){var r,n,i,s,a,o,h=t.dyn_tree,u=t.max_code,l=t.stat_desc.static_tree,f=t.stat_desc.has_stree,c=t.stat_desc.extra_bits,d=t.stat_desc.extra_base,p=t.stat_desc.max_length,m=0;for(s=0;s<=g;s++)e.bl_count[s]=0;for(h[2*e.heap[e.heap_max]+1]=0,r=e.heap_max+1;r<_;r++)p<(s=h[2*h[2*(n=e.heap[r])+1]+1]+1)&&(s=p,m++),h[2*n+1]=s,u>=7;n>>=1)if(1&r&&0!==e.dyn_ltree[2*t])return o;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return h;for(t=32;t>>3,(s=e.static_len+3+7>>>3)<=i&&(i=s)):i=s=r+5,r+4<=i&&-1!==t?J(e,t,r,n):4===e.strategy||s===i?(P(e,2+(n?1:0),3),K(e,z,C)):(P(e,4+(n?1:0),3),function(e,t,r,n){var i;for(P(e,t-257,5),P(e,r-1,5),P(e,n-4,4),i=0;i>>8&255,e.pending_buf[e.d_buf+2*e.last_lit+1]=255&t,e.pending_buf[e.l_buf+e.last_lit]=255&r,e.last_lit++,0===t?e.dyn_ltree[2*r]++:(e.matches++,t--,e.dyn_ltree[2*(A[r]+u+1)]++,e.dyn_dtree[2*N(t)]++),e.last_lit===e.lit_bufsize-1},r._tr_align=function(e){P(e,2,3),L(e,m,z),function(e){16===e.bi_valid?(U(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):8<=e.bi_valid&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)}(e)}},{\"../utils/common\":41}],53:[function(e,t,r){\"use strict\";t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg=\"\",this.state=null,this.data_type=2,this.adler=0}},{}],54:[function(e,t,r){(function(e){!function(r,n){\"use strict\";if(!r.setImmediate){var i,s,t,a,o=1,h={},u=!1,l=r.document,e=Object.getPrototypeOf&&Object.getPrototypeOf(r);e=e&&e.setTimeout?e:r,i=\"[object process]\"==={}.toString.call(r.process)?function(e){process.nextTick(function(){c(e)})}:function(){if(r.postMessage&&!r.importScripts){var e=!0,t=r.onmessage;return r.onmessage=function(){e=!1},r.postMessage(\"\",\"*\"),r.onmessage=t,e}}()?(a=\"setImmediate$\"+Math.random()+\"$\",r.addEventListener?r.addEventListener(\"message\",d,!1):r.attachEvent(\"onmessage\",d),function(e){r.postMessage(a+e,\"*\")}):r.MessageChannel?((t=new MessageChannel).port1.onmessage=function(e){c(e.data)},function(e){t.port2.postMessage(e)}):l&&\"onreadystatechange\"in l.createElement(\"script\")?(s=l.documentElement,function(e){var t=l.createElement(\"script\");t.onreadystatechange=function(){c(e),t.onreadystatechange=null,s.removeChild(t),t=null},s.appendChild(t)}):function(e){setTimeout(c,0,e)},e.setImmediate=function(e){\"function\"!=typeof e&&(e=new Function(\"\"+e));for(var t=new Array(arguments.length-1),r=0;r -1\n };\n }\n\n function normalizeName(name) {\n if (typeof name !== 'string') {\n name = String(name);\n }\n if (/[^a-z0-9\\-#$%&'*+.^_`|~]/i.test(name)) {\n throw new TypeError('Invalid character in header field name')\n }\n return name.toLowerCase()\n }\n\n function normalizeValue(value) {\n if (typeof value !== 'string') {\n value = String(value);\n }\n return value\n }\n\n // Build a destructive iterator for the value list\n function iteratorFor(items) {\n var iterator = {\n next: function() {\n var value = items.shift();\n return {done: value === undefined, value: value}\n }\n };\n\n if (support.iterable) {\n iterator[Symbol.iterator] = function() {\n return iterator\n };\n }\n\n return iterator\n }\n\n function Headers(headers) {\n this.map = {};\n\n if (headers instanceof Headers) {\n headers.forEach(function(value, name) {\n this.append(name, value);\n }, this);\n } else if (Array.isArray(headers)) {\n headers.forEach(function(header) {\n this.append(header[0], header[1]);\n }, this);\n } else if (headers) {\n Object.getOwnPropertyNames(headers).forEach(function(name) {\n this.append(name, headers[name]);\n }, this);\n }\n }\n\n Headers.prototype.append = function(name, value) {\n name = normalizeName(name);\n value = normalizeValue(value);\n var oldValue = this.map[name];\n this.map[name] = oldValue ? oldValue + ', ' + value : value;\n };\n\n Headers.prototype['delete'] = function(name) {\n delete this.map[normalizeName(name)];\n };\n\n Headers.prototype.get = function(name) {\n name = normalizeName(name);\n return this.has(name) ? this.map[name] : null\n };\n\n Headers.prototype.has = function(name) {\n return this.map.hasOwnProperty(normalizeName(name))\n };\n\n Headers.prototype.set = function(name, value) {\n this.map[normalizeName(name)] = normalizeValue(value);\n };\n\n Headers.prototype.forEach = function(callback, thisArg) {\n for (var name in this.map) {\n if (this.map.hasOwnProperty(name)) {\n callback.call(thisArg, this.map[name], name, this);\n }\n }\n };\n\n Headers.prototype.keys = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push(name);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.values = function() {\n var items = [];\n this.forEach(function(value) {\n items.push(value);\n });\n return iteratorFor(items)\n };\n\n Headers.prototype.entries = function() {\n var items = [];\n this.forEach(function(value, name) {\n items.push([name, value]);\n });\n return iteratorFor(items)\n };\n\n if (support.iterable) {\n Headers.prototype[Symbol.iterator] = Headers.prototype.entries;\n }\n\n function consumed(body) {\n if (body.bodyUsed) {\n return Promise.reject(new TypeError('Already read'))\n }\n body.bodyUsed = true;\n }\n\n function fileReaderReady(reader) {\n return new Promise(function(resolve, reject) {\n reader.onload = function() {\n resolve(reader.result);\n };\n reader.onerror = function() {\n reject(reader.error);\n };\n })\n }\n\n function readBlobAsArrayBuffer(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsArrayBuffer(blob);\n return promise\n }\n\n function readBlobAsText(blob) {\n var reader = new FileReader();\n var promise = fileReaderReady(reader);\n reader.readAsText(blob);\n return promise\n }\n\n function readArrayBufferAsText(buf) {\n var view = new Uint8Array(buf);\n var chars = new Array(view.length);\n\n for (var i = 0; i < view.length; i++) {\n chars[i] = String.fromCharCode(view[i]);\n }\n return chars.join('')\n }\n\n function bufferClone(buf) {\n if (buf.slice) {\n return buf.slice(0)\n } else {\n var view = new Uint8Array(buf.byteLength);\n view.set(new Uint8Array(buf));\n return view.buffer\n }\n }\n\n function Body() {\n this.bodyUsed = false;\n\n this._initBody = function(body) {\n this._bodyInit = body;\n if (!body) {\n this._bodyText = '';\n } else if (typeof body === 'string') {\n this._bodyText = body;\n } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {\n this._bodyBlob = body;\n } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {\n this._bodyFormData = body;\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this._bodyText = body.toString();\n } else if (support.arrayBuffer && support.blob && isDataView(body)) {\n this._bodyArrayBuffer = bufferClone(body.buffer);\n // IE 10-11 can't handle a DataView body.\n this._bodyInit = new Blob([this._bodyArrayBuffer]);\n } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {\n this._bodyArrayBuffer = bufferClone(body);\n } else {\n this._bodyText = body = Object.prototype.toString.call(body);\n }\n\n if (!this.headers.get('content-type')) {\n if (typeof body === 'string') {\n this.headers.set('content-type', 'text/plain;charset=UTF-8');\n } else if (this._bodyBlob && this._bodyBlob.type) {\n this.headers.set('content-type', this._bodyBlob.type);\n } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {\n this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8');\n }\n }\n };\n\n if (support.blob) {\n this.blob = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return Promise.resolve(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(new Blob([this._bodyArrayBuffer]))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as blob')\n } else {\n return Promise.resolve(new Blob([this._bodyText]))\n }\n };\n\n this.arrayBuffer = function() {\n if (this._bodyArrayBuffer) {\n return consumed(this) || Promise.resolve(this._bodyArrayBuffer)\n } else {\n return this.blob().then(readBlobAsArrayBuffer)\n }\n };\n }\n\n this.text = function() {\n var rejected = consumed(this);\n if (rejected) {\n return rejected\n }\n\n if (this._bodyBlob) {\n return readBlobAsText(this._bodyBlob)\n } else if (this._bodyArrayBuffer) {\n return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer))\n } else if (this._bodyFormData) {\n throw new Error('could not read FormData body as text')\n } else {\n return Promise.resolve(this._bodyText)\n }\n };\n\n if (support.formData) {\n this.formData = function() {\n return this.text().then(decode)\n };\n }\n\n this.json = function() {\n return this.text().then(JSON.parse)\n };\n\n return this\n }\n\n // HTTP methods whose capitalization should be normalized\n var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'];\n\n function normalizeMethod(method) {\n var upcased = method.toUpperCase();\n return methods.indexOf(upcased) > -1 ? upcased : method\n }\n\n function Request(input, options) {\n options = options || {};\n var body = options.body;\n\n if (input instanceof Request) {\n if (input.bodyUsed) {\n throw new TypeError('Already read')\n }\n this.url = input.url;\n this.credentials = input.credentials;\n if (!options.headers) {\n this.headers = new Headers(input.headers);\n }\n this.method = input.method;\n this.mode = input.mode;\n this.signal = input.signal;\n if (!body && input._bodyInit != null) {\n body = input._bodyInit;\n input.bodyUsed = true;\n }\n } else {\n this.url = String(input);\n }\n\n this.credentials = options.credentials || this.credentials || 'same-origin';\n if (options.headers || !this.headers) {\n this.headers = new Headers(options.headers);\n }\n this.method = normalizeMethod(options.method || this.method || 'GET');\n this.mode = options.mode || this.mode || null;\n this.signal = options.signal || this.signal;\n this.referrer = null;\n\n if ((this.method === 'GET' || this.method === 'HEAD') && body) {\n throw new TypeError('Body not allowed for GET or HEAD requests')\n }\n this._initBody(body);\n }\n\n Request.prototype.clone = function() {\n return new Request(this, {body: this._bodyInit})\n };\n\n function decode(body) {\n var form = new FormData();\n body\n .trim()\n .split('&')\n .forEach(function(bytes) {\n if (bytes) {\n var split = bytes.split('=');\n var name = split.shift().replace(/\\+/g, ' ');\n var value = split.join('=').replace(/\\+/g, ' ');\n form.append(decodeURIComponent(name), decodeURIComponent(value));\n }\n });\n return form\n }\n\n function parseHeaders(rawHeaders) {\n var headers = new Headers();\n // Replace instances of \\r\\n and \\n followed by at least one space or horizontal tab with a space\n // https://tools.ietf.org/html/rfc7230#section-3.2\n var preProcessedHeaders = rawHeaders.replace(/\\r?\\n[\\t ]+/g, ' ');\n preProcessedHeaders.split(/\\r?\\n/).forEach(function(line) {\n var parts = line.split(':');\n var key = parts.shift().trim();\n if (key) {\n var value = parts.join(':').trim();\n headers.append(key, value);\n }\n });\n return headers\n }\n\n Body.call(Request.prototype);\n\n function Response(bodyInit, options) {\n if (!options) {\n options = {};\n }\n\n this.type = 'default';\n this.status = options.status === undefined ? 200 : options.status;\n this.ok = this.status >= 200 && this.status < 300;\n this.statusText = 'statusText' in options ? options.statusText : 'OK';\n this.headers = new Headers(options.headers);\n this.url = options.url || '';\n this._initBody(bodyInit);\n }\n\n Body.call(Response.prototype);\n\n Response.prototype.clone = function() {\n return new Response(this._bodyInit, {\n status: this.status,\n statusText: this.statusText,\n headers: new Headers(this.headers),\n url: this.url\n })\n };\n\n Response.error = function() {\n var response = new Response(null, {status: 0, statusText: ''});\n response.type = 'error';\n return response\n };\n\n var redirectStatuses = [301, 302, 303, 307, 308];\n\n Response.redirect = function(url, status) {\n if (redirectStatuses.indexOf(status) === -1) {\n throw new RangeError('Invalid status code')\n }\n\n return new Response(null, {status: status, headers: {location: url}})\n };\n\n exports.DOMException = self.DOMException;\n try {\n new exports.DOMException();\n } catch (err) {\n exports.DOMException = function(message, name) {\n this.message = message;\n this.name = name;\n var error = Error(message);\n this.stack = error.stack;\n };\n exports.DOMException.prototype = Object.create(Error.prototype);\n exports.DOMException.prototype.constructor = exports.DOMException;\n }\n\n function fetch(input, init) {\n return new Promise(function(resolve, reject) {\n var request = new Request(input, init);\n\n if (request.signal && request.signal.aborted) {\n return reject(new exports.DOMException('Aborted', 'AbortError'))\n }\n\n var xhr = new XMLHttpRequest();\n\n function abortXhr() {\n xhr.abort();\n }\n\n xhr.onload = function() {\n var options = {\n status: xhr.status,\n statusText: xhr.statusText,\n headers: parseHeaders(xhr.getAllResponseHeaders() || '')\n };\n options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL');\n var body = 'response' in xhr ? xhr.response : xhr.responseText;\n resolve(new Response(body, options));\n };\n\n xhr.onerror = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.ontimeout = function() {\n reject(new TypeError('Network request failed'));\n };\n\n xhr.onabort = function() {\n reject(new exports.DOMException('Aborted', 'AbortError'));\n };\n\n xhr.open(request.method, request.url, true);\n\n if (request.credentials === 'include') {\n xhr.withCredentials = true;\n } else if (request.credentials === 'omit') {\n xhr.withCredentials = false;\n }\n\n if ('responseType' in xhr && support.blob) {\n xhr.responseType = 'blob';\n }\n\n request.headers.forEach(function(value, name) {\n xhr.setRequestHeader(name, value);\n });\n\n if (request.signal) {\n request.signal.addEventListener('abort', abortXhr);\n\n xhr.onreadystatechange = function() {\n // DONE (success or failure)\n if (xhr.readyState === 4) {\n request.signal.removeEventListener('abort', abortXhr);\n }\n };\n }\n\n xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit);\n })\n }\n\n fetch.polyfill = true;\n\n if (!self.fetch) {\n self.fetch = fetch;\n self.Headers = Headers;\n self.Request = Request;\n self.Response = Response;\n }\n\n exports.Headers = Headers;\n exports.Request = Request;\n exports.Response = Response;\n exports.fetch = fetch;\n\n Object.defineProperty(exports, '__esModule', { value: true });\n\n return exports;\n\n})({});\n})(__self__);\n__self__.fetch.ponyfill = true;\n// Remove \"polyfill\" property added by whatwg-fetch\ndelete __self__.fetch.polyfill;\n// Choose between native implementation (global) or custom implementation (__self__)\n// var ctx = global.fetch ? global : __self__;\nvar ctx = __self__; // this line disable service worker support temporarily\nexports = ctx.fetch // To enable: import fetch from 'cross-fetch'\nexports.default = ctx.fetch // For TypeScript consumers without esModuleInterop.\nexports.fetch = ctx.fetch // To enable: import {fetch} from 'cross-fetch'\nexports.Headers = ctx.Headers\nexports.Request = ctx.Request\nexports.Response = ctx.Response\nmodule.exports = exports\n","import crossFetch from 'cross-fetch';\n\nexport async function fetchArrayBuffer(url) {\n const result = await crossFetch(url);\n return result.arrayBuffer();\n}\n","import JSZip from 'jszip';\n\nimport { fetchArrayBuffer } from './util/fetchArrayBuffer';\n\nconst loadingPromises = {};\n\nexport async function loadCommercials(options = {}) {\n const {\n url = 'https://couch.cheminfo.org/cheminfo-public/d2eb480198c80275a1d05dd3609414f9/upload/commercials.zip',\n } = options;\n\n if (!loadingPromises[url]) {\n loadingPromises[url] = fetchArrayBuffer(url);\n }\n const buffer = await loadingPromises[url];\n const jsZip = new JSZip();\n let zip = await jsZip.loadAsync(buffer);\n let fileData = await zip.files['commercials.json'].async('string');\n let data = JSON.parse(fileData);\n\n data.sort((a, b) => a.em - b.em);\n\n return data;\n}\n","// eslint-disable-next-line no-shadow\nimport fetch from 'cross-fetch';\n\nexport async function fetchText(url) {\n const result = await fetch(url);\n if (result.status !== 200) {\n throw new Error(String(result.status));\n }\n return result.text();\n}\n","import { generateMFs } from 'mf-generator';\nimport { MF } from 'mf-parser';\nimport Papa from 'papaparse';\n\nimport { fetchText } from './util/fetchText.js';\n\nexport async function mfFromGoogleSheet(url, options = {}) {\n let { urlReferences } = options;\n\n if (urlReferences) {\n let results = await Promise.all([fetchText(url), fetchText(urlReferences)]);\n return parse(results[0], results[1]);\n } else {\n let result = await fetchText(url);\n return parse(result);\n }\n\n async function parse(tsv, tsvReferences) {\n let parsed = Papa.parse(tsv, {\n delimiter: '\\t',\n header: true,\n });\n let fields = parsed.meta.fields;\n let infoFields = fields.filter(\n (a) =>\n !['mf', 'modif', 'ESI', 'MALDI', 'positive', 'negative'].includes(a),\n );\n let formulas = parsed.data;\n let references = {};\n if (tsvReferences) {\n let referencesArray = Papa.parse(tsvReferences, {\n delimiter: '\\t',\n header: true,\n }).data;\n\n referencesArray.forEach((r) => {\n references[r.label] = r;\n });\n }\n\n let results = [];\n for (let formula of formulas) {\n if (tsvReferences) {\n // we add references\n let refs = formula.references.split(/[ ,]+/);\n formula.references = [];\n for (let ref of refs) {\n formula.references.push(references[ref]);\n }\n }\n // we need to calculate all the possibilities\n try {\n let mfs = await generateMFs([formula.mf], {\n ionizations: formula.modif,\n });\n for (let mf of mfs) {\n mf.info = {};\n for (let infoField of infoFields) {\n mf.info[infoField] = formula[infoField];\n }\n if (\n !formula.ESI &&\n !formula.MALDI &&\n !formula.positive &&\n !formula.negative\n ) {\n mf.filter = {\n ESI: true,\n MALDI: true,\n positive: true,\n negative: true,\n };\n } else {\n mf.filter = {\n ESI: formula.ESI === 'X',\n MALDI: formula.MALDI === 'X',\n positive: formula.positive === 'X',\n negative: formula.negative === 'X',\n };\n }\n mf.mf = new MF(mf.mf).toMF();\n results.push(mf);\n }\n } catch (e) {\n // eslint-disable-next-line no-console\n console.warn(\n 'Non parsable molecular formula: ',\n formula.mf,\n formula.modif,\n e.toString(),\n );\n }\n }\n\n results = results.filter((a) => {\n return a.ms.em !== 0;\n });\n\n results.sort((a, b) => {\n return a.ms.em - b.ms.em;\n });\n\n let uniqueResults = [results[0]];\n for (let i = 1; i < results.length; i++) {\n if (results[i - 1].ms.em !== results[i].ms.em) {\n uniqueResults.push(results[i]);\n }\n }\n\n return uniqueResults;\n }\n}\n","import { mfFromGoogleSheet } from 'mf-from-google-sheet';\n\nexport async function loadGoogleSheet(options = {}) {\n let {\n refUUID = '1C_H9aiJyu9M9in7sHMOaz-d3Sv758rE72oLxEKH9ioA',\n uuid = '1LrJCl9-xSZKhGA9Y8nKVkYwB-mEOHBkTXg5qYXeFpZY',\n } = options;\n if (options.uuid && !options.refUUID) refUUID = '';\n\n let url = `https://googledocs.cheminfo.org/spreadsheets/d/${uuid}/export?format=tsv`;\n let refURL = refUUID\n ? `https://googledocs.cheminfo.org/spreadsheets/d/${refUUID}/export?format=tsv`\n : '';\n let data = await mfFromGoogleSheet(url, refURL);\n data.sort((a, b) => a.em - b.em);\n return data;\n}\n","import JSZip from 'jszip';\n\nimport { fetchArrayBuffer } from './util/fetchArrayBuffer';\n\nconst loadingPromises = {};\n\nexport async function loadKnapSack(options = {}) {\n const {\n url = 'https://couch.cheminfo.org/cheminfo-public/d2eb480198c80275a1d05dd3609414f9/upload/ms.zip',\n } = options;\n\n if (!loadingPromises[url]) {\n loadingPromises[url] = fetchArrayBuffer(url);\n }\n const buffer = await loadingPromises[url];\n\n const jsZip = new JSZip();\n let zip = await jsZip.loadAsync(buffer);\n let fileData = await zip.files['ms.json'].async('string');\n let data = JSON.parse(fileData);\n\n data.forEach((d) => {\n d.url = `http://kanaya.naist.jp/knapsack_jsp/information.jsp?word=${d.id}`;\n });\n\n data.sort((a, b) => a.em - b.em);\n\n return data;\n}\n","export const GAUSSIAN_EXP_FACTOR = -4 * Math.LN2;\nexport const ROOT_PI_OVER_LN2 = Math.sqrt(Math.PI / Math.LN2);\nexport const ROOT_THREE = Math.sqrt(3);\nexport const ROOT_2LN2 = Math.sqrt(2 * Math.LN2);\nexport const ROOT_2LN2_MINUS_ONE = Math.sqrt(2 * Math.LN2) - 1;\n//# sourceMappingURL=constants.js.map","// https://en.wikipedia.org/wiki/Error_function#Inverse_functions\n// This code yields to a good approximation\n// If needed a better implementation using polynomial can be found on https://en.wikipedia.org/wiki/Error_function#Inverse_functions\nexport default function erfinv(x) {\n let a = 0.147;\n if (x === 0)\n return 0;\n let ln1MinusXSqrd = Math.log(1 - x * x);\n let lnEtcBy2Plus2 = ln1MinusXSqrd / 2 + 2 / (Math.PI * a);\n let firstSqrt = Math.sqrt(lnEtcBy2Plus2 ** 2 - ln1MinusXSqrd / a);\n let secondSqrt = Math.sqrt(firstSqrt - lnEtcBy2Plus2);\n return secondSqrt * (x > 0 ? 1 : -1);\n}\n//# sourceMappingURL=erfinv.js.map","import { ROOT_2LN2, GAUSSIAN_EXP_FACTOR, ROOT_PI_OVER_LN2, } from '../../../util/constants';\nimport erfinv from '../../../util/erfinv';\nexport class Gaussian {\n constructor(options = {}) {\n const { fwhm = 500, sd } = options;\n this.fwhm = sd ? gaussianWidthToFWHM(2 * sd) : fwhm;\n }\n fwhmToWidth(fwhm = this.fwhm) {\n return gaussianFwhmToWidth(fwhm);\n }\n widthToFWHM(width) {\n return gaussianWidthToFWHM(width);\n }\n fct(x) {\n return gaussianFct(x, this.fwhm);\n }\n getArea(height = calculateGaussianHeight({ fwhm: this.fwhm })) {\n return getGaussianArea({ fwhm: this.fwhm, height });\n }\n getFactor(area) {\n return getGaussianFactor(area);\n }\n getData(options = {}) {\n return getGaussianData(this, options);\n }\n calculateHeight(area = 1) {\n return calculateGaussianHeight({ fwhm: this.fwhm, area });\n }\n getParameters() {\n return ['fwhm'];\n }\n}\nexport function calculateGaussianHeight(options) {\n let { fwhm = 500, area = 1, sd } = options;\n if (sd)\n fwhm = gaussianWidthToFWHM(2 * sd);\n return (2 * area) / ROOT_PI_OVER_LN2 / fwhm;\n}\n/**\n * Calculate the height of the gaussian function of a specific width (fwhm) at a speicifc\n * x position (the gaussian is centered on x=0)\n * @param x\n * @param fwhm\n * @returns y\n */\nexport function gaussianFct(x, fwhm) {\n return Math.exp(GAUSSIAN_EXP_FACTOR * Math.pow(x / fwhm, 2));\n}\nexport function gaussianWidthToFWHM(width) {\n return width * ROOT_2LN2;\n}\nexport function gaussianFwhmToWidth(fwhm) {\n return fwhm / ROOT_2LN2;\n}\nexport function getGaussianArea(options) {\n let { fwhm = 500, sd, height = 1 } = options;\n if (sd)\n fwhm = gaussianWidthToFWHM(2 * sd);\n return (height * ROOT_PI_OVER_LN2 * fwhm) / 2;\n}\nexport function getGaussianFactor(area = 0.9999) {\n return Math.sqrt(2) * erfinv(area);\n}\nexport function getGaussianData(shape = {}, options = {}) {\n let { fwhm = 500, sd } = shape;\n if (sd)\n fwhm = gaussianWidthToFWHM(2 * sd);\n let { length, factor = getGaussianFactor(), height = calculateGaussianHeight({ fwhm }), } = options;\n if (!length) {\n length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);\n if (length % 2 === 0)\n length++;\n }\n const center = (length - 1) / 2;\n const data = new Float64Array(length);\n for (let i = 0; i <= center; i++) {\n data[i] = gaussianFct(i - center, fwhm) * height;\n data[length - 1 - i] = data[i];\n }\n return data;\n}\n//# sourceMappingURL=Gaussian.js.map","import { ROOT_THREE } from '../../../util/constants';\nexport class Lorentzian {\n constructor(options = {}) {\n const { fwhm = 500 } = options;\n this.fwhm = fwhm;\n }\n fwhmToWidth(fwhm = this.fwhm) {\n return lorentzianFwhmToWidth(fwhm);\n }\n widthToFWHM(width) {\n return lorentzianWidthToFWHM(width);\n }\n fct(x) {\n return lorentzianFct(x, this.fwhm);\n }\n getArea(height = 1) {\n return getLorentzianArea({ fwhm: this.fwhm, height });\n }\n getFactor(area) {\n return getLorentzianFactor(area);\n }\n getData(options = {}) {\n return getLorentzianData(this, options);\n }\n calculateHeight(area = 1) {\n return calculateLorentzianHeight({ fwhm: this.fwhm, area });\n }\n getParameters() {\n return ['fwhm'];\n }\n}\nexport const calculateLorentzianHeight = ({ fwhm = 1, area = 1 }) => {\n return (2 * area) / Math.PI / fwhm;\n};\nexport const getLorentzianArea = (options) => {\n const { fwhm = 500, height = 1 } = options;\n return (height * Math.PI * fwhm) / 2;\n};\nexport const lorentzianFct = (x, fwhm) => {\n return fwhm ** 2 / (4 * x ** 2 + fwhm ** 2);\n};\nexport const lorentzianWidthToFWHM = (width) => {\n return width * ROOT_THREE;\n};\nexport const lorentzianFwhmToWidth = (fwhm) => {\n return fwhm / ROOT_THREE;\n};\nexport const getLorentzianFactor = (area = 0.9999) => {\n if (area >= 1) {\n throw new Error('area should be (0 - 1)');\n }\n const halfResidual = (1 - area) * 0.5;\n const quantileFunction = (p) => Math.tan(Math.PI * (p - 0.5));\n return ((quantileFunction(1 - halfResidual) - quantileFunction(halfResidual)) / 2);\n};\nexport const getLorentzianData = (shape = {}, options = {}) => {\n let { fwhm = 500 } = shape;\n let { length, factor = getLorentzianFactor(), height = calculateLorentzianHeight({ fwhm, area: 1 }), } = options;\n if (!length) {\n length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);\n if (length % 2 === 0)\n length++;\n }\n const center = (length - 1) / 2;\n const data = new Float64Array(length);\n for (let i = 0; i <= center; i++) {\n data[i] = lorentzianFct(i - center, fwhm) * height;\n data[length - 1 - i] = data[i];\n }\n return data;\n};\n//# sourceMappingURL=Lorentzian.js.map","import { GAUSSIAN_EXP_FACTOR, ROOT_2LN2_MINUS_ONE, ROOT_PI_OVER_LN2, } from '../../../util/constants';\nimport { gaussianFct, getGaussianFactor } from '../gaussian/Gaussian';\nimport { lorentzianFct, getLorentzianFactor } from '../lorentzian/Lorentzian';\nexport class PseudoVoigt {\n constructor(options = {}) {\n const { fwhm = 500, mu = 0.5 } = options;\n this.mu = mu;\n this.fwhm = fwhm;\n }\n fwhmToWidth(fwhm = this.fwhm, mu = this.mu) {\n return pseudoVoigtFwhmToWidth(fwhm, mu);\n }\n widthToFWHM(width, mu = this.mu) {\n return pseudoVoigtWidthToFWHM(width, mu);\n }\n fct(x) {\n return pseudoVoigtFct(x, this.fwhm, this.mu);\n }\n getArea(height = 1) {\n return getPseudoVoigtArea({ fwhm: this.fwhm, height, mu: this.mu });\n }\n getFactor(area) {\n return getPseudoVoigtFactor(area);\n }\n getData(options = {}) {\n const { length, factor, height = calculatePseudoVoigtHeight({\n fwhm: this.fwhm,\n mu: this.mu,\n area: 1,\n }), } = options;\n return getPseudoVoigtData(this, { factor, length, height });\n }\n calculateHeight(area = 1) {\n return calculatePseudoVoigtHeight({ fwhm: this.fwhm, mu: this.mu, area });\n }\n getParameters() {\n return ['fwhm', 'mu'];\n }\n}\nexport const calculatePseudoVoigtHeight = (options = {}) => {\n let { fwhm = 1, mu = 0.5, area = 1 } = options;\n return (2 * area) / (fwhm * (mu * ROOT_PI_OVER_LN2 + (1 - mu) * Math.PI));\n};\nexport const pseudoVoigtFct = (x, fwhm, mu) => {\n return (1 - mu) * lorentzianFct(x, fwhm) + mu * gaussianFct(x, fwhm);\n};\nexport const pseudoVoigtWidthToFWHM = (width, mu = 0.5) => {\n return width * (mu * ROOT_2LN2_MINUS_ONE + 1);\n};\nexport const pseudoVoigtFwhmToWidth = (fwhm, mu = 0.5) => {\n return fwhm / (mu * ROOT_2LN2_MINUS_ONE + 1);\n};\nexport const getPseudoVoigtArea = (options) => {\n const { fwhm = 500, height = 1, mu = 0.5 } = options;\n return (fwhm * height * (mu * ROOT_PI_OVER_LN2 + (1 - mu) * Math.PI)) / 2;\n};\nexport const getPseudoVoigtFactor = (area = 0.9999, mu = 0.5) => {\n return mu < 1 ? getLorentzianFactor(area) : getGaussianFactor(area);\n};\nexport const getPseudoVoigtData = (shape = {}, options = {}) => {\n let { fwhm = 500, mu = 0.5 } = shape;\n let { length, factor = getPseudoVoigtFactor(0.999, mu), height = calculatePseudoVoigtHeight({ fwhm, mu, area: 1 }), } = options;\n if (!height) {\n height =\n 1 /\n ((mu / Math.sqrt(-GAUSSIAN_EXP_FACTOR / Math.PI)) * fwhm +\n ((1 - mu) * fwhm * Math.PI) / 2);\n }\n if (!length) {\n length = Math.min(Math.ceil(fwhm * factor), Math.pow(2, 25) - 1);\n if (length % 2 === 0)\n length++;\n }\n const center = (length - 1) / 2;\n const data = new Float64Array(length);\n for (let i = 0; i <= center; i++) {\n data[i] = pseudoVoigtFct(i - center, fwhm, mu) * height;\n data[length - 1 - i] = data[i];\n }\n return data;\n};\n//# sourceMappingURL=PseudoVoigt.js.map","import { Gaussian } from './gaussian/Gaussian';\nimport { Lorentzian } from './lorentzian/Lorentzian';\nimport { PseudoVoigt } from './pseudoVoigt/PseudoVoigt';\n/**\n * Generate a instance of a specific kind of shape.\n */\nexport function getShape1D(shape) {\n const { kind } = shape;\n switch (kind) {\n case 'gaussian':\n return new Gaussian(shape);\n case 'lorentzian':\n return new Lorentzian(shape);\n case 'pseudoVoigt':\n return new PseudoVoigt(shape);\n default: {\n throw Error(`Unknown distribution ${kind}`);\n }\n }\n}\n//# sourceMappingURL=getShape1D.js.map","import { getShape1D } from 'ml-peak-shape-generator';\nimport addBaseline from './util/addBaseline';\nimport addNoise from './util/addNoise';\nexport class SpectrumGenerator {\n constructor(options = {}) {\n const { from = 0, to = 1000, nbPoints = 10001, peakWidthFct, shape = { kind: 'gaussian', fwhm: 5 }, } = options;\n this.from = from;\n this.to = to;\n this.nbPoints = nbPoints;\n this.interval = (this.to - this.from) / (this.nbPoints - 1);\n this.peakWidthFct = peakWidthFct;\n this.maxPeakHeight = Number.MIN_SAFE_INTEGER;\n this.data = {\n x: new Float64Array(this.nbPoints),\n y: new Float64Array(this.nbPoints),\n };\n let shapeGenerator = getShape1D(shape);\n this.shape = shapeGenerator;\n assertNumber(this.from, 'from');\n assertNumber(this.to, 'to');\n assertInteger(this.nbPoints, 'nbPoints');\n if (this.to <= this.from) {\n throw new RangeError('to option must be larger than from');\n }\n if (this.peakWidthFct && typeof this.peakWidthFct !== 'function') {\n throw new TypeError('peakWidthFct option must be a function');\n }\n this.reset();\n }\n /**\n * Add a series of peaks to the spectrum.\n * @param peaks - Peaks to add.\n */\n addPeaks(peaks, options) {\n if (!Array.isArray(peaks) &&\n (typeof peaks !== 'object' ||\n peaks.x === undefined ||\n peaks.y === undefined ||\n !Array.isArray(peaks.x) ||\n !Array.isArray(peaks.y) ||\n peaks.x.length !== peaks.y.length)) {\n throw new TypeError('peaks must be an array or an object containing x[] and y[]');\n }\n if (Array.isArray(peaks)) {\n for (const peak of peaks) {\n this.addPeak(peak, options);\n }\n }\n else {\n for (let i = 0; i < peaks.x.length; i++) {\n this.addPeak([peaks.x[i], peaks.y[i]], options);\n }\n }\n }\n /**\n * Add a single peak to the spectrum.\n * A peak may be either defined as [x,y,fwhm,...] or as {x, y, shape}\n * @param peak\n * @param options\n */\n addPeak(peak, options = {}) {\n if (Array.isArray(peak) && peak.length < 2) {\n throw new Error('peak must be an array with two (or three) values or an object with {x,y,width?}');\n }\n if (!Array.isArray(peak) &&\n (peak.x === undefined || peak.y === undefined)) {\n throw new Error('peak must be an array with two (or three) values or an object with {x,y,width?}');\n }\n let xPosition;\n let intensity;\n let peakFWHM;\n let peakWidth;\n let peakShapeOptions;\n if (Array.isArray(peak)) {\n [xPosition, intensity, peakFWHM, peakShapeOptions] = peak;\n }\n else {\n xPosition = peak.x;\n intensity = peak.y;\n peakWidth = peak.width;\n peakShapeOptions = peak.shape;\n }\n if (intensity > this.maxPeakHeight)\n this.maxPeakHeight = intensity;\n let { shape: shapeOptions } = options;\n if (peakShapeOptions) {\n shapeOptions = shapeOptions\n ? { ...shapeOptions, ...peakShapeOptions }\n : peakShapeOptions;\n }\n const shape = shapeOptions\n ? getShape1D(shapeOptions)\n : Object.assign(Object.create(Object.getPrototypeOf(this.shape)), this.shape);\n let { width, widthLeft, widthRight } = options;\n /*\n if we don't force the fwhm we just take the one from the shape\n however we have many way to force it:\n - use [x,y,fwhm]\n - define `width` that will be converted to fwhm\n - define `widthLeft` and `widthRight` to define asymmetric peaks\n - have a callback `peakWidthFct`\n This should evolve in the future because we will not always have `fwhm`\n */\n const fwhm = peakFWHM !== undefined\n ? peakFWHM\n : peakWidth\n ? shape.widthToFWHM(peakWidth)\n : this.peakWidthFct\n ? this.peakWidthFct(xPosition)\n : width !== undefined\n ? width\n : shape.fwhm;\n if (!widthLeft)\n widthLeft = fwhm;\n if (!widthRight)\n widthRight = fwhm;\n if (!widthLeft || !widthRight) {\n throw new Error('Width left or right is undefined or zero');\n }\n let factor = options.factor === undefined ? shape.getFactor() : options.factor;\n const firstValue = xPosition - (widthLeft / 2) * factor;\n const lastValue = xPosition + (widthRight / 2) * factor;\n const firstPoint = Math.max(0, Math.floor((firstValue - this.from) / this.interval));\n const lastPoint = Math.min(this.nbPoints - 1, Math.ceil((lastValue - this.from) / this.interval));\n const middlePoint = Math.round((xPosition - this.from) / this.interval);\n // PEAK SHAPE MAY BE ASYMMETRC (widthLeft and widthRight) !\n // we calculate the left part of the shape\n shape.fwhm = widthLeft;\n for (let index = firstPoint; index < Math.max(middlePoint, 0); index++) {\n this.data.y[index] +=\n intensity * shape.fct(this.data.x[index] - xPosition);\n }\n // we calculate the right part of the gaussian\n shape.fwhm = widthRight;\n for (let index = Math.min(middlePoint, lastPoint); index <= lastPoint; index++) {\n this.data.y[index] +=\n intensity * shape.fct(this.data.x[index] - xPosition);\n }\n }\n /**\n * Add a baseline to the spectrum.\n * @param baselineFct - Mathematical function producing the baseline you want.\n */\n addBaseline(baselineFct) {\n addBaseline(this.data, baselineFct);\n return this;\n }\n /**\n * Add noise to the spectrum.\n *\n * @param percent - Noise's amplitude in percents of the spectrum max value. Default: 1.\n */\n addNoise(options) {\n addNoise(this.data, options);\n return this;\n }\n /**\n * Get the generated spectrum.\n */\n getSpectrum(options = {}) {\n if (typeof options === 'boolean') {\n options = { copy: options };\n }\n const { copy = true, threshold = 0 } = options;\n if (threshold) {\n let minPeakHeight = this.maxPeakHeight * threshold;\n let x = [];\n let y = [];\n for (let i = 0; i < this.data.x.length; i++) {\n if (this.data.y[i] >= minPeakHeight) {\n x.push(this.data.x[i]);\n y.push(this.data.y[i]);\n }\n }\n return { x, y };\n }\n if (copy) {\n return {\n x: this.data.x.slice(),\n y: this.data.y.slice(),\n };\n }\n else {\n return this.data;\n }\n }\n /**\n * Resets the generator with an empty spectrum.\n */\n reset() {\n const spectrum = this.data;\n for (let i = 0; i < this.nbPoints; i++) {\n spectrum.x[i] = this.from + i * this.interval;\n }\n return this;\n }\n}\nfunction assertInteger(value, name) {\n if (!Number.isInteger(value)) {\n throw new TypeError(`${name} option must be an integer`);\n }\n}\nfunction assertNumber(value, name) {\n if (!Number.isFinite(value)) {\n throw new TypeError(`${name} option must be a number`);\n }\n}\n/**\n * Generates a spectrum and returns it.\n * @param peaks - List of peaks to put in the spectrum.\n * @param options\n */\nexport function generateSpectrum(peaks, options = {}) {\n const { generator: generatorOptions, noise, baseline, threshold, peakOptions, } = options;\n const generator = new SpectrumGenerator(generatorOptions);\n generator.addPeaks(peaks, peakOptions);\n if (baseline)\n generator.addBaseline(baseline);\n if (noise) {\n generator.addNoise(noise);\n }\n return generator.getSpectrum({\n threshold,\n });\n}\n//# sourceMappingURL=SpectrumGenerator.js.map","export default function addBaseline(data, baselineFct) {\n if (!baselineFct)\n return data;\n let xs = data.x;\n let ys = data.y;\n for (let i = 0; i < xs.length; i++) {\n ys[i] += baselineFct(xs[i]);\n }\n return data;\n}\n//# sourceMappingURL=addBaseline.js.map","import { xMaxValue, xAdd, createRandomArray } from 'ml-spectra-processing';\nexport default function addNoise(data, options = {}) {\n const { seed = 0, distribution = 'normal', percent = 1 } = options;\n const range = (xMaxValue(data.y) * percent) / 100;\n const noise = createRandomArray({\n distribution,\n seed,\n mean: 0,\n standardDeviation: range,\n range,\n length: data.x.length,\n });\n data.y = xAdd(data.y, noise);\n return data;\n}\n//# sourceMappingURL=addNoise.js.map","export function multiply(a, b, options = {}) {\n const { minY = 1e-8, maxLines = 5000, deltaX = 1e-2 } = options;\n const result = new a.constructor();\n\n a.sortY();\n b.sortY();\n\n for (let entryA of a.array) {\n for (let entryB of b.array) {\n let y = entryA.y * entryB.y;\n if (y > minY) {\n const composition = calculateComposition(entryA, entryB);\n if (composition) {\n result.push({ x: entryA.x + entryB.x, y, composition });\n } else {\n result.push({ x: entryA.x + entryB.x, y });\n }\n }\n if (result.length > maxLines * 2) {\n result.joinX(deltaX);\n result.topY(maxLines);\n }\n }\n }\n result.joinX(deltaX);\n result.topY(maxLines);\n a.move(result);\n return a;\n}\n\nfunction calculateComposition(entryA, entryB) {\n if (!entryA.composition || !entryB.composition) return;\n let toReturn = {};\n const keys = [\n ...new Set(\n Object.keys(entryA.composition).concat(Object.keys(entryB.composition)),\n ),\n ];\n for (let key of keys) {\n toReturn[key] =\n (entryA.composition[key] || 0) + (entryB.composition[key] || 0);\n }\n return toReturn;\n}\n","import { closestPointX } from './utils/closestPointX.js';\nimport { joinX } from './utils/joinX.js';\nimport { multiply } from './utils/multiply.js';\nimport { power } from './utils/power.js';\n\n/**\n * Internal class to deal with isotopic distribution calculations\n */\nexport class Distribution {\n constructor(array) {\n if (Array.isArray(array)) {\n this.array = array;\n this.xSorted = false;\n this.ySorted = false;\n } else {\n this.array = [];\n this.xSorted = true;\n this.ySorted = true;\n }\n }\n\n get length() {\n return this.array.length;\n }\n\n get xs() {\n return this.array.map((p) => p.x);\n }\n\n get ys() {\n return this.array.map((p) => p.y);\n }\n\n get minX() {\n if (!this.xSorted) this.sortX();\n return this.array[0].x;\n }\n\n get maxX() {\n if (!this.xSorted) this.sortX();\n return this.array[this.array.length - 1].x;\n }\n\n get minY() {\n if (!this.ySorted) this.sortY();\n return this.array[0].y;\n }\n\n get maxY() {\n if (!this.ySorted) this.sortY();\n return this.array[this.array.length - 1];\n }\n\n multiplyY(value) {\n this.array.forEach((item) => (item.y *= value));\n }\n\n setArray(array) {\n this.array = array;\n this.xSorted = false;\n this.ySorted = false;\n }\n\n move(other) {\n this.xSorted = other.xSorted;\n this.ySorted = other.ySorted;\n this.array = other.array;\n }\n\n push(point) {\n this.array.push(point);\n\n this.xSorted = false;\n this.ySorted = false;\n }\n\n sortX() {\n this.ySorted = false;\n if (this.xSorted) return this;\n this.array.sort((a, b) => a.x - b.x);\n this.xSorted = true;\n return this;\n }\n\n sortY() {\n this.xSorted = false;\n if (this.ySorted) return this;\n this.array.sort((a, b) => b.y - a.y);\n this.ySorted = true;\n return this;\n }\n\n normalize() {\n let sum = 0;\n for (let item of this.array) {\n sum += item.y;\n }\n for (let item of this.array) {\n item.y /= sum;\n }\n return this;\n }\n\n topY(limit) {\n if (!limit) return this;\n if (this.array.length <= limit) return this;\n this.sortY();\n this.array.splice(limit);\n return this;\n }\n\n square(options = {}) {\n return this.multiply(this, options);\n }\n\n multiply(b, options) {\n return multiply(this, b, options);\n }\n\n power(p, options) {\n return power(this, p, options);\n }\n\n copy() {\n let distCopy = new Distribution();\n distCopy.xSorted = this.xSorted;\n distCopy.ySorted = this.ySorted;\n distCopy.array = JSON.parse(JSON.stringify(this.array));\n return distCopy;\n }\n\n maxToOne() {\n if (this.array.length === 0) return this;\n let currentMax = this.array[0].y;\n for (let item of this.array) {\n if (item.y > currentMax) currentMax = item.y;\n }\n for (let item of this.array) {\n item.y /= currentMax;\n }\n return this;\n }\n\n joinX(threshold) {\n return joinX(this, threshold);\n }\n\n append(distribution) {\n for (let item of distribution.array) {\n this.array.push(item);\n }\n this.xSorted = false;\n this.ySorted = false;\n }\n\n closestPointX(target) {\n this.sortX();\n return closestPointX(this.array, target);\n }\n}\n","// https://en.wikipedia.org/wiki/Exponentiation_by_squaring\n\nexport function power(a, p, options = {}) {\n if (p <= 0) throw new Error('power must be larger than 0');\n if (p === 1) return a;\n if (p === 2) {\n return a.square();\n }\n\n p--;\n let base = a.copy(); // linear time\n while (p !== 0) {\n if ((p & 1) !== 0) {\n a.multiply(base, options); // executed <= log2(p) times\n }\n p >>= 1;\n if (p !== 0) base.square(options); // executed <= log2(p) times\n }\n\n return a;\n}\n","/**\n * Join x values if there are similar\n */\n\nexport function joinX(self, threshold = Number.EPSILON) {\n // when we join we will use the center of mass\n if (self.array.length === 0) return [];\n self.sortX();\n let current = self.array[0];\n let result = [current];\n for (let i = 1; i < self.array.length; i++) {\n const item = self.array[i];\n if (item.x - current.x <= threshold) {\n // weighted sum\n current.x =\n (item.y / (current.y + item.y)) * (item.x - current.x) + current.x;\n current.y += item.y;\n } else {\n current = {\n x: item.x,\n y: item.y,\n };\n if (item.composition) current.composition = item.composition;\n result.push(current);\n }\n }\n self.array = result;\n self.ySorted = false;\n return self;\n}\n","export function closestPointX(array, target) {\n let low = 0;\n let high = array.length - 1;\n let middle = 0;\n while (high - low > 1) {\n middle = low + ((high - low) >> 1);\n if (array[middle].x < target) {\n low = middle;\n } else if (array[middle].x > target) {\n high = middle;\n } else {\n return array[middle];\n }\n }\n\n if (low < array.length - 1) {\n if (Math.abs(target - array[low].x) < Math.abs(array[low + 1].x - target)) {\n return array[low];\n } else {\n return array[low + 1];\n }\n } else {\n return array[low];\n }\n}\n","import { stableIsotopesObject } from 'chemical-elements';\nimport { subscript, superscript } from 'mf-parser';\n\nexport function getDerivedCompositionInfo(composition) {\n const shortComposition = {};\n let label = '';\n let shortLabel = '';\n for (let key in composition) {\n let isotopeLabel = '';\n for (let i = 0; i < key.length; i++) {\n if (superscript[key[i]]) {\n isotopeLabel += superscript[key[i]];\n } else {\n isotopeLabel += key[i];\n }\n }\n if (composition[key] > 1) {\n const number = String(composition[key]);\n for (let i = 0; i < number.length; i++) {\n isotopeLabel += subscript[number[i]];\n }\n }\n label += isotopeLabel;\n if (stableIsotopesObject[key].mostAbundant) continue;\n shortLabel += isotopeLabel;\n shortComposition[key] = composition[key];\n }\n\n return { label, shortComposition, shortLabel };\n}\n","import { ELECTRON_MASS } from 'chemical-elements';\nimport { MF } from 'mf-parser';\nimport { preprocessIonizations, getMsInfo } from 'mf-utilities';\nimport { SpectrumGenerator } from 'spectrum-generator';\n\nimport { Distribution } from './Distribution';\nimport { getDerivedCompositionInfo } from './utils/getDerivedCompositionInfo';\n\nconst MINIMAL_FWHM = 1e-8;\n\n/**\n * An object containing two arrays\n * @typedef {object} XY\n * @property {Array} x - The x array\n * @property {Array} y - The y array\n */\n\n/**\n * A class that allows to manage isotopic distribution\n */\nexport class IsotopicDistribution {\n /**\n * Class that manage isotopic distribution\n * @param {string|array} value - Molecular formula or an array of parts\n * @param {object} [options={}]\n * @param {string} [options.ionizations=''] - string containing a comma separated list of modifications\n * @param {number} [options.fwhm=0.01] - Amount of Dalton under which 2 peaks are joined\n * @param {number} [options.maxLines=5000] - Maximal number of lines during calculations\n * @param {number} [options.minY=1e-8] - Minimal signal height during calculations\n * @param {number} [options.ensureCase=false] - Ensure uppercase / lowercase\n * @param {number} [options.allowNeutral=true] - Should we keep the distribution if the molecule has no charge\n */\n\n constructor(value, options = {}) {\n if (Array.isArray(value)) {\n this.parts = JSON.parse(JSON.stringify(value));\n for (let part of this.parts) {\n part.confidence = 0;\n part.isotopesInfo = new MF(\n `${part.mf}(${part.ionization.mf})`,\n ).getIsotopesInfo();\n }\n } else {\n let mf = new MF(value, { ensureCase: options.ensureCase });\n let mfInfo = mf.getInfo();\n let ionizations = preprocessIonizations(options.ionizations);\n let parts = mfInfo.parts || [mfInfo];\n this.parts = [];\n for (let partOriginal of parts) {\n // we calculate information for each part\n for (const ionization of ionizations) {\n let part = JSON.parse(JSON.stringify(partOriginal));\n part.em = part.monoisotopicMass; // TODO: To remove !!! we change the name !?\n part.isotopesInfo = new MF(\n `${part.mf}(${ionization.mf})`,\n ).getIsotopesInfo();\n part.confidence = 0;\n let msInfo = getMsInfo(part, {\n ionization,\n });\n part.ionization = msInfo.ionization;\n part.ms = msInfo.ms;\n this.parts.push(part);\n }\n }\n }\n\n this.cachedDistribution = undefined;\n this.fwhm = options.fwhm === undefined ? 0.01 : options.fwhm;\n // if fwhm is under 1e-8 there are some artifacts in the spectra\n if (this.fwhm < MINIMAL_FWHM) this.fwhm = MINIMAL_FWHM;\n this.minY = options.minY === undefined ? MINIMAL_FWHM : options.minY;\n this.maxLines = options.maxLines || 5000;\n this.allowNeutral =\n options.allowNeutral === undefined ? true : options.allowNeutral;\n }\n\n getParts() {\n return this.parts;\n }\n\n /**\n * @return {Distribution} returns the total distribution (for all parts)\n */\n getDistribution() {\n if (this.cachedDistribution) return this.cachedDistribution;\n let options = {\n maxLines: this.maxLines,\n minY: this.minY,\n deltaX: this.fwhm,\n };\n let finalDistribution = new Distribution();\n this.confidence = 0;\n // TODO need to cache each part without ionization\n // in case of many ionization we don't need to recalculate everything !\n for (let part of this.parts) {\n let totalDistribution = new Distribution([\n {\n x: 0,\n y: 1,\n composition: this.fwhm === MINIMAL_FWHM ? {} : undefined,\n },\n ]);\n let charge = part.ms.charge;\n let absoluteCharge = Math.abs(charge);\n if (charge || this.allowNeutral) {\n for (let isotope of part.isotopesInfo.isotopes) {\n if (isotope.number < 0) return { array: [] };\n if (isotope.number > 0) {\n const newDistribution = JSON.parse(\n JSON.stringify(isotope.distribution),\n );\n if (this.fwhm === MINIMAL_FWHM) {\n // add composition\n for (const entry of newDistribution) {\n entry.composition = { [Math.round(entry.x) + isotope.atom]: 1 };\n }\n }\n let distribution = new Distribution(newDistribution);\n distribution.power(isotope.number, options);\n totalDistribution.multiply(distribution, options);\n }\n }\n this.confidence += totalDistribution.array.reduce(\n (sum, value) => sum + value.y,\n 0,\n );\n\n // we finally deal with the charge\n\n if (charge) {\n totalDistribution.array.forEach((e) => {\n e.x = (e.x - ELECTRON_MASS * charge) / absoluteCharge;\n });\n }\n\n if (totalDistribution.array && totalDistribution.array.length > 0) {\n totalDistribution.sortX();\n part.fromX = totalDistribution.array[0].x;\n part.toX =\n totalDistribution.array[totalDistribution.array.length - 1].x;\n }\n\n if (\n part.ms.target &&\n part.ms.target.intensity &&\n part.ms.target.intensity !== 1\n ) {\n // intensity is the value of the monoisotopic mass !\n // need to find the intensity of the peak corresponding\n // to the monoisotopic mass\n if (part.ms.target.mass) {\n let target = totalDistribution.closestPointX(part.ms.target.mass);\n totalDistribution.multiplyY(part.ms.target.intensity / target.y);\n } else {\n totalDistribution.multiplyY(part.ms.target.intensity);\n }\n } else if (part.intensity && part.intensity !== 1) {\n totalDistribution.multiplyY(part.intensity);\n }\n\n part.isotopicDistribution = totalDistribution.array;\n\n if (finalDistribution.array.length === 0) {\n finalDistribution = totalDistribution;\n } else {\n finalDistribution.append(totalDistribution);\n }\n }\n }\n if (finalDistribution) finalDistribution.joinX(this.fwhm);\n\n for (let entry of finalDistribution.array) {\n if (!entry.composition) continue;\n Object.assign(entry, getDerivedCompositionInfo(entry.composition));\n }\n\n this.confidence /= this.parts.length;\n this.cachedDistribution = finalDistribution;\n return finalDistribution;\n }\n\n getCSV() {\n return this.getText({ delimiter: ', ' });\n }\n\n getTSV() {\n return this.getText({ delimiter: '\\t' });\n }\n\n getTable(options = {}) {\n const { maxValue, xLabel = 'x', yLabel = 'y' } = options;\n let points = this.getDistribution().array;\n let factor = 1;\n if (maxValue) {\n let maxY = this.getMaxY(points);\n factor = maxValue / maxY;\n }\n return points.map((point) => {\n let newPoint = {};\n newPoint[xLabel] = point.x;\n newPoint[yLabel] = point.y * factor;\n return newPoint;\n });\n }\n\n getText(options = {}) {\n const { delimiter = '\\t', numberDecimals = 3 } = options;\n let points = this.getDistribution().array;\n let csv = [];\n for (let point of points) {\n csv.push(\n `${point.x.toFixed(5)}${delimiter}${(point.y * 100).toFixed(\n numberDecimals,\n )}`,\n );\n }\n return csv.join('\\n');\n }\n\n getMaxY(points) {\n let maxY = points[0].y;\n for (let point of points) {\n if (point.y > maxY) maxY = point.y;\n }\n return maxY;\n }\n\n getSumY(points) {\n let sumY = 0;\n for (let point of points) {\n sumY += point.y;\n }\n return sumY;\n }\n\n /**\n * Returns the isotopic distribution as an array of peaks\n * @param {object} [options={}]\n * @param {number} [options.maxValue=100]\n * @param {number} [options.sumValue] // if sumValue is defined, maxValue is ignored\n * @return {Array} an object containing at least the 2 properties: x:[] and y:[]\n */\n getPeaks(options = {}) {\n const { maxValue = 100, sumValue } = options;\n let peaks = this.getDistribution().array;\n if (peaks.length === 0) return [];\n let factor = 1;\n if (sumValue) {\n let sumY = this.getSumY(peaks);\n factor = sumY / sumValue;\n } else if (maxValue) {\n let maxY = this.getMaxY(peaks);\n factor = maxY / maxValue;\n }\n if (factor !== 1) {\n // we need to copy the array because we prefer no side effects\n peaks = JSON.parse(JSON.stringify(peaks));\n for (const peak of peaks) {\n peak.y = peak.y / factor;\n }\n }\n return peaks;\n }\n\n /**\n * Returns the isotopic distirubtion\n * @param {object} [options={}]\n * @param {number} [options.maxValue=100]\n * @param {number} [options.sumValue] // if sumValue is defined, maxValue is ignored\n * @return {XY} an object containing at least the 2 properties: x:[] and y:[]\n */\n getXY(options = {}) {\n let peaks = this.getPeaks(options);\n\n if (peaks.length === 0) {\n return { x: [], y: [] };\n }\n\n const result = {\n x: peaks.map((a) => a.x),\n y: peaks.map((a) => a.y),\n };\n\n for (let key of Object.keys(peaks[0]).filter(\n (k) => k !== 'x' && k !== 'y',\n )) {\n result[key] = peaks.map((a) => a[key]);\n }\n\n return result;\n }\n\n /**\n * Returns the isotopic distribution as the sum of gaussian\n * @param {object} [options={}]\n * @param {number} [options.gaussianWidth=10]\n * @param {number} [options.threshold=0.00001] // minimal height to return point\n * @param {number} [options.maxLength=1e6] // minimal height to return point\n * @param {number} [options.maxValue] // rescale Y to reach maxValue\n * @param {function} [options.peakWidthFct=(mz)=>(this.fwhm)]\n * @return {XY} isotopic distribution as an object containing 2 properties: x:[] and y:[]\n */\n\n getGaussian(options = {}) {\n const {\n peakWidthFct = () => this.fwhm,\n threshold = 0.00001,\n gaussianWidth = 10,\n maxValue,\n maxLength = 1e6,\n } = options;\n\n let points = this.getTable({ maxValue });\n if (points.length === 0) return { x: [], y: [] };\n const from = Math.floor(options.from || points[0].x - 2);\n const to = Math.ceil(options.to || points[points.length - 1].x + 2);\n const nbPoints = Math.round(((to - from) * gaussianWidth) / this.fwhm + 1);\n if (nbPoints > maxLength) {\n throw Error(\n `Number of points is over the maxLength: ${nbPoints}>${maxLength}`,\n );\n }\n let gaussianOptions = {\n from,\n to,\n nbPoints,\n peakWidthFct,\n };\n\n let spectrumGenerator = new SpectrumGenerator(gaussianOptions);\n for (let point of points) {\n spectrumGenerator.addPeak([point.x, point.y]);\n }\n let spectrum = spectrumGenerator.getSpectrum({ threshold });\n return spectrum;\n }\n}\n","export function calculateOverlapFromDiff(diffs) {\n if (diffs[1].length === 0)\n return 0;\n let sumPos = 0;\n for (let i = 0; i < diffs[1].length; i++) {\n sumPos += Math.abs(diffs[1][i]);\n }\n return 1 - sumPos;\n}\n//# sourceMappingURL=calculateOverlapFromDiff.js.map","/**\n * This code requires the use of an array like [[x1,y1],[x2,y2], ...]\n * If it is not the right format, we will just convert it\n * Otherwise we return the correct format\n * @param {Peaks} peaks\n * @returns [number[], number[]]\n */\nexport function checkPeaks(peaks) {\n // if it is already a 2D array of points, we just return them\n if (Array.isArray(peaks) && Array.isArray(peaks[0]) && peaks.length === 2) {\n return peaks;\n }\n if (Array.isArray(peaks.x) && Array.isArray(peaks.y)) {\n return [peaks.x, peaks.y];\n }\n const x = new Array(peaks.length);\n const y = new Array(peaks.length);\n for (let i = 0; i < peaks.length; i++) {\n x[i] = peaks[i][0];\n y[i] = peaks[i][1];\n }\n return [x, y];\n}\n//# sourceMappingURL=checkPeaks.js.map","export function extract(array, from, to) {\n const newArray = [[], []];\n let j = 0;\n const length = array[0] ? array[0].length : 0;\n for (let i = 0; i < length; i++) {\n if ((!from || array[0][i] >= from) && (!to || array[0][i] <= to)) {\n newArray[0][j] = array[0][i];\n newArray[1][j] = array[1][i];\n j++;\n }\n }\n return newArray;\n}\n//# sourceMappingURL=extract.js.map","// returns an new array based on array1 where there is a peak of array2 at a distance under width/2\nexport function getCommonArray(array1, array2, width) {\n const newArray = [[], []];\n let pos2 = 0;\n width /= 2;\n let j = 0;\n const array1Length = array1[0] ? array1[0].length : 0;\n const array2Length = array2[0] ? array2[0].length : 0;\n for (let i = 0; i < array1Length; i++) {\n while (pos2 < array2Length && array1[0][i] > array2[0][pos2] + width) {\n pos2++;\n }\n if (pos2 < array2Length && array1[0][i] > array2[0][pos2] - width) {\n newArray[0][j] = array1[0][i];\n newArray[1][j] = array1[1][i];\n j++;\n }\n }\n return newArray;\n}\n//# sourceMappingURL=getCommonArray.js.map","'use strict';\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\n/**\n * Computes the sum of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.sum = function sum(values) {\n var sum = 0;\n for (var i = 0; i < values.length; i++) {\n sum += values[i];\n }\n return sum;\n};\n\n/**\n * Computes the maximum of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.max = function max(values) {\n var max = values[0];\n var l = values.length;\n for (var i = 1; i < l; i++) {\n if (values[i] > max) max = values[i];\n }\n return max;\n};\n\n/**\n * Computes the minimum of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.min = function min(values) {\n var min = values[0];\n var l = values.length;\n for (var i = 1; i < l; i++) {\n if (values[i] < min) min = values[i];\n }\n return min;\n};\n\n/**\n * Computes the min and max of the given values\n * @param {Array} values\n * @returns {{min: number, max: number}}\n */\nexports.minMax = function minMax(values) {\n var min = values[0];\n var max = values[0];\n var l = values.length;\n for (var i = 1; i < l; i++) {\n if (values[i] < min) min = values[i];\n if (values[i] > max) max = values[i];\n }\n return {\n min: min,\n max: max\n };\n};\n\n/**\n * Computes the arithmetic mean of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.arithmeticMean = function arithmeticMean(values) {\n var sum = 0;\n var l = values.length;\n for (var i = 0; i < l; i++) {\n sum += values[i];\n }\n return sum / l;\n};\n\n/**\n * {@link arithmeticMean}\n */\nexports.mean = exports.arithmeticMean;\n\n/**\n * Computes the geometric mean of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.geometricMean = function geometricMean(values) {\n var mul = 1;\n var l = values.length;\n for (var i = 0; i < l; i++) {\n mul *= values[i];\n }\n return Math.pow(mul, 1 / l);\n};\n\n/**\n * Computes the mean of the log of the given values\n * If the return value is exponentiated, it gives the same result as the\n * geometric mean.\n * @param {Array} values\n * @returns {number}\n */\nexports.logMean = function logMean(values) {\n var lnsum = 0;\n var l = values.length;\n for (var i = 0; i < l; i++) {\n lnsum += Math.log(values[i]);\n }\n return lnsum / l;\n};\n\n/**\n * Computes the weighted grand mean for a list of means and sample sizes\n * @param {Array} means - Mean values for each set of samples\n * @param {Array} samples - Number of original values for each set of samples\n * @returns {number}\n */\nexports.grandMean = function grandMean(means, samples) {\n var sum = 0;\n var n = 0;\n var l = means.length;\n for (var i = 0; i < l; i++) {\n sum += samples[i] * means[i];\n n += samples[i];\n }\n return sum / n;\n};\n\n/**\n * Computes the truncated mean of the given values using a given percentage\n * @param {Array} values\n * @param {number} percent - The percentage of values to keep (range: [0,1])\n * @param {boolean} [alreadySorted=false]\n * @returns {number}\n */\nexports.truncatedMean = function truncatedMean(values, percent, alreadySorted) {\n if (alreadySorted === undefined) alreadySorted = false;\n if (!alreadySorted) {\n values = [].concat(values).sort(compareNumbers);\n }\n var l = values.length;\n var k = Math.floor(l * percent);\n var sum = 0;\n for (var i = k; i < (l - k); i++) {\n sum += values[i];\n }\n return sum / (l - 2 * k);\n};\n\n/**\n * Computes the harmonic mean of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.harmonicMean = function harmonicMean(values) {\n var sum = 0;\n var l = values.length;\n for (var i = 0; i < l; i++) {\n if (values[i] === 0) {\n throw new RangeError('value at index ' + i + 'is zero');\n }\n sum += 1 / values[i];\n }\n return l / sum;\n};\n\n/**\n * Computes the contraharmonic mean of the given values\n * @param {Array} values\n * @returns {number}\n */\nexports.contraHarmonicMean = function contraHarmonicMean(values) {\n var r1 = 0;\n var r2 = 0;\n var l = values.length;\n for (var i = 0; i < l; i++) {\n r1 += values[i] * values[i];\n r2 += values[i];\n }\n if (r2 < 0) {\n throw new RangeError('sum of values is negative');\n }\n return r1 / r2;\n};\n\n/**\n * Computes the median of the given values\n * @param {Array} values\n * @param {boolean} [alreadySorted=false]\n * @returns {number}\n */\nexports.median = function median(values, alreadySorted) {\n if (alreadySorted === undefined) alreadySorted = false;\n if (!alreadySorted) {\n values = [].concat(values).sort(compareNumbers);\n }\n var l = values.length;\n var half = Math.floor(l / 2);\n if (l % 2 === 0) {\n return (values[half - 1] + values[half]) * 0.5;\n } else {\n return values[half];\n }\n};\n\n/**\n * Computes the variance of the given values\n * @param {Array} values\n * @param {boolean} [unbiased=true] - if true, divide by (n-1); if false, divide by n.\n * @returns {number}\n */\nexports.variance = function variance(values, unbiased) {\n if (unbiased === undefined) unbiased = true;\n var theMean = exports.mean(values);\n var theVariance = 0;\n var l = values.length;\n\n for (var i = 0; i < l; i++) {\n var x = values[i] - theMean;\n theVariance += x * x;\n }\n\n if (unbiased) {\n return theVariance / (l - 1);\n } else {\n return theVariance / l;\n }\n};\n\n/**\n * Computes the standard deviation of the given values\n * @param {Array} values\n * @param {boolean} [unbiased=true] - if true, divide by (n-1); if false, divide by n.\n * @returns {number}\n */\nexports.standardDeviation = function standardDeviation(values, unbiased) {\n return Math.sqrt(exports.variance(values, unbiased));\n};\n\nexports.standardError = function standardError(values) {\n return exports.standardDeviation(values) / Math.sqrt(values.length);\n};\n\n/**\n * IEEE Transactions on biomedical engineering, vol. 52, no. 1, january 2005, p. 76-\n * Calculate the standard deviation via the Median of the absolute deviation\n * The formula for the standard deviation only holds for Gaussian random variables.\n * @returns {{mean: number, stdev: number}}\n */\nexports.robustMeanAndStdev = function robustMeanAndStdev(y) {\n var mean = 0, stdev = 0;\n var length = y.length, i = 0;\n for (i = 0; i < length; i++) {\n mean += y[i];\n }\n mean /= length;\n var averageDeviations = new Array(length);\n for (i = 0; i < length; i++)\n averageDeviations[i] = Math.abs(y[i] - mean);\n averageDeviations.sort(compareNumbers);\n if (length % 2 === 1) {\n stdev = averageDeviations[(length - 1) / 2] / 0.6745;\n } else {\n stdev = 0.5 * (averageDeviations[length / 2] + averageDeviations[length / 2 - 1]) / 0.6745;\n }\n\n return {\n mean: mean,\n stdev: stdev\n };\n};\n\nexports.quartiles = function quartiles(values, alreadySorted) {\n if (typeof (alreadySorted) === 'undefined') alreadySorted = false;\n if (!alreadySorted) {\n values = [].concat(values).sort(compareNumbers);\n }\n\n var quart = values.length / 4;\n var q1 = values[Math.ceil(quart) - 1];\n var q2 = exports.median(values, true);\n var q3 = values[Math.ceil(quart * 3) - 1];\n\n return {q1: q1, q2: q2, q3: q3};\n};\n\nexports.pooledStandardDeviation = function pooledStandardDeviation(samples, unbiased) {\n return Math.sqrt(exports.pooledVariance(samples, unbiased));\n};\n\nexports.pooledVariance = function pooledVariance(samples, unbiased) {\n if (typeof (unbiased) === 'undefined') unbiased = true;\n var sum = 0;\n var length = 0, l = samples.length;\n for (var i = 0; i < l; i++) {\n var values = samples[i];\n var vari = exports.variance(values);\n\n sum += (values.length - 1) * vari;\n\n if (unbiased)\n length += values.length - 1;\n else\n length += values.length;\n }\n return sum / length;\n};\n\nexports.mode = function mode(values) {\n var l = values.length,\n itemCount = new Array(l),\n i;\n for (i = 0; i < l; i++) {\n itemCount[i] = 0;\n }\n var itemArray = new Array(l);\n var count = 0;\n\n for (i = 0; i < l; i++) {\n var index = itemArray.indexOf(values[i]);\n if (index >= 0)\n itemCount[index]++;\n else {\n itemArray[count] = values[i];\n itemCount[count] = 1;\n count++;\n }\n }\n\n var maxValue = 0, maxIndex = 0;\n for (i = 0; i < count; i++) {\n if (itemCount[i] > maxValue) {\n maxValue = itemCount[i];\n maxIndex = i;\n }\n }\n\n return itemArray[maxIndex];\n};\n\nexports.covariance = function covariance(vector1, vector2, unbiased) {\n if (typeof (unbiased) === 'undefined') unbiased = true;\n var mean1 = exports.mean(vector1);\n var mean2 = exports.mean(vector2);\n\n if (vector1.length !== vector2.length)\n throw 'Vectors do not have the same dimensions';\n\n var cov = 0, l = vector1.length;\n for (var i = 0; i < l; i++) {\n var x = vector1[i] - mean1;\n var y = vector2[i] - mean2;\n cov += x * y;\n }\n\n if (unbiased)\n return cov / (l - 1);\n else\n return cov / l;\n};\n\nexports.skewness = function skewness(values, unbiased) {\n if (typeof (unbiased) === 'undefined') unbiased = true;\n var theMean = exports.mean(values);\n\n var s2 = 0, s3 = 0, l = values.length;\n for (var i = 0; i < l; i++) {\n var dev = values[i] - theMean;\n s2 += dev * dev;\n s3 += dev * dev * dev;\n }\n var m2 = s2 / l;\n var m3 = s3 / l;\n\n var g = m3 / (Math.pow(m2, 3 / 2.0));\n if (unbiased) {\n var a = Math.sqrt(l * (l - 1));\n var b = l - 2;\n return (a / b) * g;\n } else {\n return g;\n }\n};\n\nexports.kurtosis = function kurtosis(values, unbiased) {\n if (typeof (unbiased) === 'undefined') unbiased = true;\n var theMean = exports.mean(values);\n var n = values.length, s2 = 0, s4 = 0;\n\n for (var i = 0; i < n; i++) {\n var dev = values[i] - theMean;\n s2 += dev * dev;\n s4 += dev * dev * dev * dev;\n }\n var m2 = s2 / n;\n var m4 = s4 / n;\n\n if (unbiased) {\n var v = s2 / (n - 1);\n var a = (n * (n + 1)) / ((n - 1) * (n - 2) * (n - 3));\n var b = s4 / (v * v);\n var c = ((n - 1) * (n - 1)) / ((n - 2) * (n - 3));\n\n return a * b - 3 * c;\n } else {\n return m4 / (m2 * m2) - 3;\n }\n};\n\nexports.entropy = function entropy(values, eps) {\n if (typeof (eps) === 'undefined') eps = 0;\n var sum = 0, l = values.length;\n for (var i = 0; i < l; i++)\n sum += values[i] * Math.log(values[i] + eps);\n return -sum;\n};\n\nexports.weightedMean = function weightedMean(values, weights) {\n var sum = 0, l = values.length;\n for (var i = 0; i < l; i++)\n sum += values[i] * weights[i];\n return sum;\n};\n\nexports.weightedStandardDeviation = function weightedStandardDeviation(values, weights) {\n return Math.sqrt(exports.weightedVariance(values, weights));\n};\n\nexports.weightedVariance = function weightedVariance(values, weights) {\n var theMean = exports.weightedMean(values, weights);\n var vari = 0, l = values.length;\n var a = 0, b = 0;\n\n for (var i = 0; i < l; i++) {\n var z = values[i] - theMean;\n var w = weights[i];\n\n vari += w * (z * z);\n b += w;\n a += w * w;\n }\n\n return vari * (b / (b * b - a));\n};\n\nexports.center = function center(values, inPlace) {\n if (typeof (inPlace) === 'undefined') inPlace = false;\n\n var result = values;\n if (!inPlace)\n result = [].concat(values);\n\n var theMean = exports.mean(result), l = result.length;\n for (var i = 0; i < l; i++)\n result[i] -= theMean;\n};\n\nexports.standardize = function standardize(values, standardDev, inPlace) {\n if (typeof (standardDev) === 'undefined') standardDev = exports.standardDeviation(values);\n if (typeof (inPlace) === 'undefined') inPlace = false;\n var l = values.length;\n var result = inPlace ? values : new Array(l);\n for (var i = 0; i < l; i++)\n result[i] = values[i] / standardDev;\n return result;\n};\n\nexports.cumulativeSum = function cumulativeSum(array) {\n var l = array.length;\n var result = new Array(l);\n result[0] = array[0];\n for (var i = 1; i < l; i++)\n result[i] = result[i - 1] + array[i];\n return result;\n};\n","'use strict';\n\nvar arrayStat = require('./array');\n\nfunction compareNumbers(a, b) {\n return a - b;\n}\n\nexports.max = function max(matrix) {\n var max = -Infinity;\n for (var i = 0; i < matrix.length; i++) {\n for (var j = 0; j < matrix[i].length; j++) {\n if (matrix[i][j] > max) max = matrix[i][j];\n }\n }\n return max;\n};\n\nexports.min = function min(matrix) {\n var min = Infinity;\n for (var i = 0; i < matrix.length; i++) {\n for (var j = 0; j < matrix[i].length; j++) {\n if (matrix[i][j] < min) min = matrix[i][j];\n }\n }\n return min;\n};\n\nexports.minMax = function minMax(matrix) {\n var min = Infinity;\n var max = -Infinity;\n for (var i = 0; i < matrix.length; i++) {\n for (var j = 0; j < matrix[i].length; j++) {\n if (matrix[i][j] < min) min = matrix[i][j];\n if (matrix[i][j] > max) max = matrix[i][j];\n }\n }\n return {\n min:min,\n max:max\n };\n};\n\nexports.entropy = function entropy(matrix, eps) {\n if (typeof (eps) === 'undefined') {\n eps = 0;\n }\n var sum = 0,\n l1 = matrix.length,\n l2 = matrix[0].length;\n for (var i = 0; i < l1; i++) {\n for (var j = 0; j < l2; j++) {\n sum += matrix[i][j] * Math.log(matrix[i][j] + eps);\n }\n }\n return -sum;\n};\n\nexports.mean = function mean(matrix, dimension) {\n if (typeof (dimension) === 'undefined') {\n dimension = 0;\n }\n var rows = matrix.length,\n cols = matrix[0].length,\n theMean, N, i, j;\n\n if (dimension === -1) {\n theMean = [0];\n N = rows * cols;\n for (i = 0; i < rows; i++) {\n for (j = 0; j < cols; j++) {\n theMean[0] += matrix[i][j];\n }\n }\n theMean[0] /= N;\n } else if (dimension === 0) {\n theMean = new Array(cols);\n N = rows;\n for (j = 0; j < cols; j++) {\n theMean[j] = 0;\n for (i = 0; i < rows; i++) {\n theMean[j] += matrix[i][j];\n }\n theMean[j] /= N;\n }\n } else if (dimension === 1) {\n theMean = new Array(rows);\n N = cols;\n for (j = 0; j < rows; j++) {\n theMean[j] = 0;\n for (i = 0; i < cols; i++) {\n theMean[j] += matrix[j][i];\n }\n theMean[j] /= N;\n }\n } else {\n throw new Error('Invalid dimension');\n }\n return theMean;\n};\n\nexports.sum = function sum(matrix, dimension) {\n if (typeof (dimension) === 'undefined') {\n dimension = 0;\n }\n var rows = matrix.length,\n cols = matrix[0].length,\n theSum, i, j;\n\n if (dimension === -1) {\n theSum = [0];\n for (i = 0; i < rows; i++) {\n for (j = 0; j < cols; j++) {\n theSum[0] += matrix[i][j];\n }\n }\n } else if (dimension === 0) {\n theSum = new Array(cols);\n for (j = 0; j < cols; j++) {\n theSum[j] = 0;\n for (i = 0; i < rows; i++) {\n theSum[j] += matrix[i][j];\n }\n }\n } else if (dimension === 1) {\n theSum = new Array(rows);\n for (j = 0; j < rows; j++) {\n theSum[j] = 0;\n for (i = 0; i < cols; i++) {\n theSum[j] += matrix[j][i];\n }\n }\n } else {\n throw new Error('Invalid dimension');\n }\n return theSum;\n};\n\nexports.product = function product(matrix, dimension) {\n if (typeof (dimension) === 'undefined') {\n dimension = 0;\n }\n var rows = matrix.length,\n cols = matrix[0].length,\n theProduct, i, j;\n\n if (dimension === -1) {\n theProduct = [1];\n for (i = 0; i < rows; i++) {\n for (j = 0; j < cols; j++) {\n theProduct[0] *= matrix[i][j];\n }\n }\n } else if (dimension === 0) {\n theProduct = new Array(cols);\n for (j = 0; j < cols; j++) {\n theProduct[j] = 1;\n for (i = 0; i < rows; i++) {\n theProduct[j] *= matrix[i][j];\n }\n }\n } else if (dimension === 1) {\n theProduct = new Array(rows);\n for (j = 0; j < rows; j++) {\n theProduct[j] = 1;\n for (i = 0; i < cols; i++) {\n theProduct[j] *= matrix[j][i];\n }\n }\n } else {\n throw new Error('Invalid dimension');\n }\n return theProduct;\n};\n\nexports.standardDeviation = function standardDeviation(matrix, means, unbiased) {\n var vari = exports.variance(matrix, means, unbiased), l = vari.length;\n for (var i = 0; i < l; i++) {\n vari[i] = Math.sqrt(vari[i]);\n }\n return vari;\n};\n\nexports.variance = function variance(matrix, means, unbiased) {\n if (typeof (unbiased) === 'undefined') {\n unbiased = true;\n }\n means = means || exports.mean(matrix);\n var rows = matrix.length;\n if (rows === 0) return [];\n var cols = matrix[0].length;\n var vari = new Array(cols);\n\n for (var j = 0; j < cols; j++) {\n var sum1 = 0, sum2 = 0, x = 0;\n for (var i = 0; i < rows; i++) {\n x = matrix[i][j] - means[j];\n sum1 += x;\n sum2 += x * x;\n }\n if (unbiased) {\n vari[j] = (sum2 - ((sum1 * sum1) / rows)) / (rows - 1);\n } else {\n vari[j] = (sum2 - ((sum1 * sum1) / rows)) / rows;\n }\n }\n return vari;\n};\n\nexports.median = function median(matrix) {\n var rows = matrix.length, cols = matrix[0].length;\n var medians = new Array(cols);\n\n for (var i = 0; i < cols; i++) {\n var data = new Array(rows);\n for (var j = 0; j < rows; j++) {\n data[j] = matrix[j][i];\n }\n data.sort(compareNumbers);\n var N = data.length;\n if (N % 2 === 0) {\n medians[i] = (data[N / 2] + data[(N / 2) - 1]) * 0.5;\n } else {\n medians[i] = data[Math.floor(N / 2)];\n }\n }\n return medians;\n};\n\nexports.mode = function mode(matrix) {\n var rows = matrix.length,\n cols = matrix[0].length,\n modes = new Array(cols),\n i, j;\n for (i = 0; i < cols; i++) {\n var itemCount = new Array(rows);\n for (var k = 0; k < rows; k++) {\n itemCount[k] = 0;\n }\n var itemArray = new Array(rows);\n var count = 0;\n\n for (j = 0; j < rows; j++) {\n var index = itemArray.indexOf(matrix[j][i]);\n if (index >= 0) {\n itemCount[index]++;\n } else {\n itemArray[count] = matrix[j][i];\n itemCount[count] = 1;\n count++;\n }\n }\n\n var maxValue = 0, maxIndex = 0;\n for (j = 0; j < count; j++) {\n if (itemCount[j] > maxValue) {\n maxValue = itemCount[j];\n maxIndex = j;\n }\n }\n\n modes[i] = itemArray[maxIndex];\n }\n return modes;\n};\n\nexports.skewness = function skewness(matrix, unbiased) {\n if (typeof (unbiased) === 'undefined') unbiased = true;\n var means = exports.mean(matrix);\n var n = matrix.length, l = means.length;\n var skew = new Array(l);\n\n for (var j = 0; j < l; j++) {\n var s2 = 0, s3 = 0;\n for (var i = 0; i < n; i++) {\n var dev = matrix[i][j] - means[j];\n s2 += dev * dev;\n s3 += dev * dev * dev;\n }\n\n var m2 = s2 / n;\n var m3 = s3 / n;\n var g = m3 / Math.pow(m2, 3 / 2);\n\n if (unbiased) {\n var a = Math.sqrt(n * (n - 1));\n var b = n - 2;\n skew[j] = (a / b) * g;\n } else {\n skew[j] = g;\n }\n }\n return skew;\n};\n\nexports.kurtosis = function kurtosis(matrix, unbiased) {\n if (typeof (unbiased) === 'undefined') unbiased = true;\n var means = exports.mean(matrix);\n var n = matrix.length, m = matrix[0].length;\n var kurt = new Array(m);\n\n for (var j = 0; j < m; j++) {\n var s2 = 0, s4 = 0;\n for (var i = 0; i < n; i++) {\n var dev = matrix[i][j] - means[j];\n s2 += dev * dev;\n s4 += dev * dev * dev * dev;\n }\n var m2 = s2 / n;\n var m4 = s4 / n;\n\n if (unbiased) {\n var v = s2 / (n - 1);\n var a = (n * (n + 1)) / ((n - 1) * (n - 2) * (n - 3));\n var b = s4 / (v * v);\n var c = ((n - 1) * (n - 1)) / ((n - 2) * (n - 3));\n kurt[j] = a * b - 3 * c;\n } else {\n kurt[j] = m4 / (m2 * m2) - 3;\n }\n }\n return kurt;\n};\n\nexports.standardError = function standardError(matrix) {\n var samples = matrix.length;\n var standardDeviations = exports.standardDeviation(matrix);\n var l = standardDeviations.length;\n var standardErrors = new Array(l);\n var sqrtN = Math.sqrt(samples);\n\n for (var i = 0; i < l; i++) {\n standardErrors[i] = standardDeviations[i] / sqrtN;\n }\n return standardErrors;\n};\n\nexports.covariance = function covariance(matrix, dimension) {\n return exports.scatter(matrix, undefined, dimension);\n};\n\nexports.scatter = function scatter(matrix, divisor, dimension) {\n if (typeof (dimension) === 'undefined') {\n dimension = 0;\n }\n if (typeof (divisor) === 'undefined') {\n if (dimension === 0) {\n divisor = matrix.length - 1;\n } else if (dimension === 1) {\n divisor = matrix[0].length - 1;\n }\n }\n var means = exports.mean(matrix, dimension);\n var rows = matrix.length;\n if (rows === 0) {\n return [[]];\n }\n var cols = matrix[0].length,\n cov, i, j, s, k;\n\n if (dimension === 0) {\n cov = new Array(cols);\n for (i = 0; i < cols; i++) {\n cov[i] = new Array(cols);\n }\n for (i = 0; i < cols; i++) {\n for (j = i; j < cols; j++) {\n s = 0;\n for (k = 0; k < rows; k++) {\n s += (matrix[k][j] - means[j]) * (matrix[k][i] - means[i]);\n }\n s /= divisor;\n cov[i][j] = s;\n cov[j][i] = s;\n }\n }\n } else if (dimension === 1) {\n cov = new Array(rows);\n for (i = 0; i < rows; i++) {\n cov[i] = new Array(rows);\n }\n for (i = 0; i < rows; i++) {\n for (j = i; j < rows; j++) {\n s = 0;\n for (k = 0; k < cols; k++) {\n s += (matrix[j][k] - means[j]) * (matrix[i][k] - means[i]);\n }\n s /= divisor;\n cov[i][j] = s;\n cov[j][i] = s;\n }\n }\n } else {\n throw new Error('Invalid dimension');\n }\n\n return cov;\n};\n\nexports.correlation = function correlation(matrix) {\n var means = exports.mean(matrix),\n standardDeviations = exports.standardDeviation(matrix, true, means),\n scores = exports.zScores(matrix, means, standardDeviations),\n rows = matrix.length,\n cols = matrix[0].length,\n i, j;\n\n var cor = new Array(cols);\n for (i = 0; i < cols; i++) {\n cor[i] = new Array(cols);\n }\n for (i = 0; i < cols; i++) {\n for (j = i; j < cols; j++) {\n var c = 0;\n for (var k = 0, l = scores.length; k < l; k++) {\n c += scores[k][j] * scores[k][i];\n }\n c /= rows - 1;\n cor[i][j] = c;\n cor[j][i] = c;\n }\n }\n return cor;\n};\n\nexports.zScores = function zScores(matrix, means, standardDeviations) {\n means = means || exports.mean(matrix);\n if (typeof (standardDeviations) === 'undefined') standardDeviations = exports.standardDeviation(matrix, true, means);\n return exports.standardize(exports.center(matrix, means, false), standardDeviations, true);\n};\n\nexports.center = function center(matrix, means, inPlace) {\n means = means || exports.mean(matrix);\n var result = matrix,\n l = matrix.length,\n i, j, jj;\n\n if (!inPlace) {\n result = new Array(l);\n for (i = 0; i < l; i++) {\n result[i] = new Array(matrix[i].length);\n }\n }\n\n for (i = 0; i < l; i++) {\n var row = result[i];\n for (j = 0, jj = row.length; j < jj; j++) {\n row[j] = matrix[i][j] - means[j];\n }\n }\n return result;\n};\n\nexports.standardize = function standardize(matrix, standardDeviations, inPlace) {\n if (typeof (standardDeviations) === 'undefined') standardDeviations = exports.standardDeviation(matrix);\n var result = matrix,\n l = matrix.length,\n i, j, jj;\n\n if (!inPlace) {\n result = new Array(l);\n for (i = 0; i < l; i++) {\n result[i] = new Array(matrix[i].length);\n }\n }\n\n for (i = 0; i < l; i++) {\n var resultRow = result[i];\n var sourceRow = matrix[i];\n for (j = 0, jj = resultRow.length; j < jj; j++) {\n if (standardDeviations[j] !== 0 && !isNaN(standardDeviations[j])) {\n resultRow[j] = sourceRow[j] / standardDeviations[j];\n }\n }\n }\n return result;\n};\n\nexports.weightedVariance = function weightedVariance(matrix, weights) {\n var means = exports.mean(matrix);\n var rows = matrix.length;\n if (rows === 0) return [];\n var cols = matrix[0].length;\n var vari = new Array(cols);\n\n for (var j = 0; j < cols; j++) {\n var sum = 0;\n var a = 0, b = 0;\n\n for (var i = 0; i < rows; i++) {\n var z = matrix[i][j] - means[j];\n var w = weights[i];\n\n sum += w * (z * z);\n b += w;\n a += w * w;\n }\n\n vari[j] = sum * (b / (b * b - a));\n }\n\n return vari;\n};\n\nexports.weightedMean = function weightedMean(matrix, weights, dimension) {\n if (typeof (dimension) === 'undefined') {\n dimension = 0;\n }\n var rows = matrix.length;\n if (rows === 0) return [];\n var cols = matrix[0].length,\n means, i, ii, j, w, row;\n\n if (dimension === 0) {\n means = new Array(cols);\n for (i = 0; i < cols; i++) {\n means[i] = 0;\n }\n for (i = 0; i < rows; i++) {\n row = matrix[i];\n w = weights[i];\n for (j = 0; j < cols; j++) {\n means[j] += row[j] * w;\n }\n }\n } else if (dimension === 1) {\n means = new Array(rows);\n for (i = 0; i < rows; i++) {\n means[i] = 0;\n }\n for (j = 0; j < rows; j++) {\n row = matrix[j];\n w = weights[j];\n for (i = 0; i < cols; i++) {\n means[j] += row[i] * w;\n }\n }\n } else {\n throw new Error('Invalid dimension');\n }\n\n var weightSum = arrayStat.sum(weights);\n if (weightSum !== 0) {\n for (i = 0, ii = means.length; i < ii; i++) {\n means[i] /= weightSum;\n }\n }\n return means;\n};\n\nexports.weightedCovariance = function weightedCovariance(matrix, weights, means, dimension) {\n dimension = dimension || 0;\n means = means || exports.weightedMean(matrix, weights, dimension);\n var s1 = 0, s2 = 0;\n for (var i = 0, ii = weights.length; i < ii; i++) {\n s1 += weights[i];\n s2 += weights[i] * weights[i];\n }\n var factor = s1 / (s1 * s1 - s2);\n return exports.weightedScatter(matrix, weights, means, factor, dimension);\n};\n\nexports.weightedScatter = function weightedScatter(matrix, weights, means, factor, dimension) {\n dimension = dimension || 0;\n means = means || exports.weightedMean(matrix, weights, dimension);\n if (typeof (factor) === 'undefined') {\n factor = 1;\n }\n var rows = matrix.length;\n if (rows === 0) {\n return [[]];\n }\n var cols = matrix[0].length,\n cov, i, j, k, s;\n\n if (dimension === 0) {\n cov = new Array(cols);\n for (i = 0; i < cols; i++) {\n cov[i] = new Array(cols);\n }\n for (i = 0; i < cols; i++) {\n for (j = i; j < cols; j++) {\n s = 0;\n for (k = 0; k < rows; k++) {\n s += weights[k] * (matrix[k][j] - means[j]) * (matrix[k][i] - means[i]);\n }\n cov[i][j] = s * factor;\n cov[j][i] = s * factor;\n }\n }\n } else if (dimension === 1) {\n cov = new Array(rows);\n for (i = 0; i < rows; i++) {\n cov[i] = new Array(rows);\n }\n for (i = 0; i < rows; i++) {\n for (j = i; j < rows; j++) {\n s = 0;\n for (k = 0; k < cols; k++) {\n s += weights[k] * (matrix[j][k] - means[j]) * (matrix[i][k] - means[i]);\n }\n cov[i][j] = s * factor;\n cov[j][i] = s * factor;\n }\n }\n } else {\n throw new Error('Invalid dimension');\n }\n\n return cov;\n};\n","'use strict';\n\nexports.array = require('./array');\nexports.matrix = require('./matrix');\n","import { array as StatArray } from 'ml-stat';\nexport function normalize(array) {\n const min = StatArray.min(array[1]);\n const max = StatArray.max(array[1]);\n const sum = StatArray.sum(array[1]);\n const length = array[1] ? array[1].length : 0;\n if (sum !== 0) {\n for (let i = 0; i < length; i++) {\n array[1][i] /= sum;\n }\n }\n return {\n sum,\n min,\n max,\n };\n}\n//# sourceMappingURL=normalize.js.map","import { extract } from './extract';\nimport { getCommonArray } from './getCommonArray';\nimport { normalize } from './normalize';\nimport { COMMON_SECOND, COMMON_FIRST } from './index';\n// this method will systematically take care of both array\nexport function commonExtractAndNormalize(array1, array2, width, from, to, common) {\n if (!Array.isArray(array1) || !Array.isArray(array2)) {\n return {\n info: undefined,\n data: undefined,\n };\n }\n const extract1 = extract(array1, from, to);\n const extract2 = extract(array2, from, to);\n let common1, common2, info1, info2;\n if (common & COMMON_SECOND) {\n common1 = getCommonArray(extract1, extract2, width);\n info1 = normalize(common1);\n }\n else {\n common1 = extract1;\n info1 = normalize(common1);\n }\n if (common & COMMON_FIRST) {\n common2 = getCommonArray(extract2, extract1, width);\n info2 = normalize(common2);\n }\n else {\n common2 = extract2;\n info2 = normalize(common2);\n }\n return {\n info1,\n info2,\n data1: common1,\n data2: common2,\n };\n}\n//# sourceMappingURL=commonExtractAndNormalize.js.map","import { extract } from './extract';\nimport { normalize } from './normalize';\nexport function extractAndNormalize(array, from, to) {\n if (!Array.isArray(array)) {\n return {\n info: undefined,\n data: undefined,\n };\n }\n const newArray = extract(array, from, to);\n const info = normalize(newArray);\n return {\n info,\n data: newArray,\n };\n}\n//# sourceMappingURL=extractAndNormalize.js.map","// Adapted from: http://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect/1968345#1968345\nexport function getIntersection(segment1, segment2) {\n const p0X = segment1[0][0];\n const p0Y = segment1[0][1];\n const p1X = segment1[1][0];\n const p1Y = segment1[1][1];\n const p2X = segment2[0][0];\n const p2Y = segment2[0][1];\n const p3X = segment2[1][0];\n const p3Y = segment2[1][1];\n const s1X = p1X - p0X;\n const s1Y = p1Y - p0Y;\n const s2X = p3X - p2X;\n const s2Y = p3Y - p2Y;\n const s = (-s1Y * (p0X - p2X) + s1X * (p0Y - p2Y)) / (-s2X * s1Y + s1X * s2Y);\n const t = (s2X * (p0Y - p2Y) - s2Y * (p0X - p2X)) / (-s2X * s1Y + s1X * s2Y);\n if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {\n return {\n x: p0X + t * s1X,\n y: p0Y + t * s1Y,\n };\n }\n return null; // No collision\n}\n//# sourceMappingURL=getIntersection.js.map","import { calculateOverlapFromDiff } from './calculateOverlapFromDiff';\nimport { checkPeaks } from './checkPeaks';\nimport { commonExtractAndNormalize } from './commonExtractAndNormalize';\nimport { extract } from './extract';\nimport { extractAndNormalize } from './extractAndNormalize';\nimport { getCommonArray } from './getCommonArray.js';\nimport { getIntersection } from './getIntersection';\nimport { normalize } from './normalize';\nexport const COMMON_NO = 0;\nexport const COMMON_FIRST = 1;\nexport const COMMON_SECOND = 2;\nexport const COMMON_BOTH = 3;\n/**\n * A number, or a string containing a number.\n * @typedef {([number[],number[]]|[number,number][]|{x:number[],y:number[]})} Peaks\n */\n/**\n * Create a comparator class\n * {object} [options={}]\n * {string} [options.common=''] should we take only common peaks 'first', 'second', 'both', ''\n * {number} [options.widthBottom=2] bottom trapezoid width for similarity evaluation\n * {number} [options.widthTop=1] top trapezoid width for similarity evaluation\n * {number} [options.from] from region used for similarity calculation\n * {number} [options.to] to region used for similarity calculation\n */\nexport class Comparator {\n constructor(options = {}) {\n this.array1 = [];\n this.array2 = [];\n this.setOptions(options);\n }\n /*\n 2 formats are allowed:\n [[x1,x2,...],[y1,y2,...]] or [[x1,y1],[x2,y2], ...]\n */\n setOptions(options = {}) {\n if (typeof options.common === 'string') {\n if (options.common.toLowerCase() === 'first') {\n this.common = COMMON_FIRST;\n }\n else if (options.common.toLowerCase() === 'second') {\n this.common = COMMON_SECOND;\n }\n else if (options.common.toLowerCase() === 'both') {\n this.common = COMMON_BOTH;\n }\n else {\n this.common = COMMON_NO;\n }\n }\n else if (options.common === true) {\n this.common = COMMON_BOTH;\n }\n else {\n this.common = COMMON_NO;\n }\n this.trapezoid = options.trapezoid;\n this.commonFactor = options.commonFactor || this.commonFactor || 4;\n const { widthBottom = this.widthBottom || 2, widthTop = this.widthTop || 1, from = this.from, to = this.to, } = options;\n this.setTrapezoid(widthBottom, widthTop);\n this.setFromTo(from, to);\n }\n /**\n *\n * @param {Peaks} peaks\n */\n setPeaks1(peaks) {\n this.array1 = checkPeaks(peaks);\n if (this.common) {\n const extracts = commonExtractAndNormalize(this.array1, this.array2, this.widthBottom, this.from, this.to, this.common);\n this.array1Extract = extracts.data1;\n this.array1ExtractInfo = extracts.info1;\n this.array2Extract = extracts.data2;\n this.array2ExtractInfo = extracts.info2;\n }\n else {\n const extract = extractAndNormalize(this.array1, this.from, this.to);\n this.array1Extract = extract.data;\n this.array1ExtractInfo = extract.info;\n }\n }\n /**\n *\n * @param {Peaks} peaks\n */\n setPeaks2(peaks) {\n this.array2 = checkPeaks(peaks);\n if (this.common) {\n const extracts = commonExtractAndNormalize(this.array1, this.array2, this.widthBottom, this.from, this.to, this.common);\n this.array1Extract = extracts.data1;\n this.array1ExtractInfo = extracts.info1;\n this.array2Extract = extracts.data2;\n this.array2ExtractInfo = extracts.info2;\n }\n else {\n const extract = extractAndNormalize(this.array2, this.from, this.to);\n this.array2Extract = extract.data;\n this.array2ExtractInfo = extract.info;\n }\n }\n getExtract1() {\n return this.array1Extract;\n }\n getExtract2() {\n return this.array2Extract;\n }\n getExtractInfo1() {\n return this.array1ExtractInfo;\n }\n getExtractInfo2() {\n return this.array2ExtractInfo;\n }\n /**\n * Set the new bottom and top width of the trapezoid\n * @param {number} newWidthBottom\n * @param {number} newWidthTop\n */\n setTrapezoid(newWidthBottom, newWidthTop) {\n this.widthTop = newWidthTop;\n this.widthBottom = newWidthBottom;\n this.widthSlope = (this.widthBottom - this.widthTop) / 2;\n if (this.widthBottom < this.widthTop) {\n throw new Error('widthBottom has to be larger than widthTop');\n }\n }\n /**\n * Set the from / to for comparison\n * @param {number} newFrom - set the new from value\n * @param {number} newTo - set the new to value\n * @returns\n */\n setFromTo(newFrom, newTo) {\n if (newFrom === this.from && newTo === this.to)\n return;\n this.from = newFrom;\n this.to = newTo;\n if (this.common) {\n const extracts = commonExtractAndNormalize(this.array1, this.array2, this.widthBottom, this.from, this.to, this.common, this.commonFactor);\n this.array1Extract = extracts.data1;\n this.array1ExtractInfo = extracts.info1;\n this.array2Extract = extracts.data2;\n this.array2ExtractInfo = extracts.info2;\n }\n else {\n let extract1 = extractAndNormalize(this.array1, this.from, this.to);\n this.array1Extract = extract1.data;\n this.array1ExtractInfo = extract1.info;\n let extract2 = extractAndNormalize(this.array2, this.from, this.to);\n this.array2Extract = extract2.data;\n this.array2ExtractInfo = extract2.info;\n }\n }\n /**\n *\n * @param {number} x1\n * @param {number} y1\n * @param {number} x2\n * @param {number} y2\n * @returns\n */\n getOverlap(x1, y1, x2, y2) {\n if (y1 === 0 || y2 === 0)\n return 0;\n // TAKE CARE !!! We multiply the diff by 2 !!!\n const diff = Math.abs(x1 - x2) * 2;\n if (diff > this.widthBottom)\n return 0;\n if (diff <= this.widthTop) {\n return Math.min(y1, y2);\n }\n const maxValue = (Math.max(y1, y2) * (this.widthBottom - diff)) /\n (this.widthBottom - this.widthTop);\n return Math.min(y1, y2, maxValue);\n }\n /**\n * This is the old trapezoid similarity\n * @param {number} x1\n * @param {number} y1\n * @param {number} x2\n * @param {number} y2\n * @param {number} widthTop\n * @param {number} widthBottom\n * @returns\n */\n getOverlapTrapezoid(x1, y1, x2, y2, widthTop, widthBottom) {\n // eslint-disable-next-line no-console\n console.error('getOverlapTrapezoid should not be used anymore');\n const factor = 2 / (widthTop + widthBottom); // correction for surface=1\n if (y1 === 0 || y2 === 0)\n return 0;\n if (x1 === x2) {\n // they have the same position\n return Math.min(y1, y2);\n }\n const diff = Math.abs(x1 - x2);\n if (diff >= widthBottom)\n return 0;\n if (y1 === y2) {\n // do they have the same height ???\n // we need to find the common length\n if (diff <= widthTop) {\n return ((widthTop + widthBottom) / 2 - diff) * y1 * factor;\n }\n else if (diff <= widthBottom) {\n return ((((((widthBottom - diff) * y1) / 2) * (diff - widthTop)) /\n (widthBottom - widthTop)) *\n factor);\n }\n return 0;\n }\n else {\n // the height are different and not the same position ...\n // we need to consider only one segment to find its intersection\n const small = Math.min(y1, y2);\n const big = Math.max(y1, y2);\n const targets = [\n [\n [0, 0],\n [this.widthSlope, small],\n ],\n [\n [this.widthSlope, small],\n [this.widthSlope + widthTop, small],\n ],\n [\n [widthTop + this.widthSlope, small],\n [widthBottom, 0],\n ],\n ];\n let segment;\n if ((x1 > x2 && y1 > y2) || (x1 < x2 && y1 < y2)) {\n segment = [\n [diff, 0],\n [diff + this.widthSlope, big],\n ];\n }\n else {\n segment = [\n [diff + this.widthSlope, big],\n [diff, 0],\n ];\n }\n for (let i = 0; i < 3; i++) {\n const intersection = getIntersection(targets[i], segment);\n if (intersection) {\n switch (i) {\n case 0:\n return small - ((diff * intersection.y) / 2) * factor;\n case 1: // to simplify ...\n // console.log(\" \",widthSlope,small,big,intersection.x)\n return ((((this.widthSlope * small) / (2 * big)) * small +\n (widthTop + this.widthSlope - intersection.x) * small +\n (this.widthSlope * small) / 2) *\n factor);\n case 2:\n return (((widthBottom - diff) * intersection.y) / 2) * factor;\n default:\n throw new Error(`unexpected intersection value: ${i}`);\n }\n }\n }\n }\n return NaN;\n }\n /**\n * This method calculates the total diff. The sum of positive value will yield to overlap\n * @returns\n */\n calculateDiff() {\n // we need to take 2 pointers\n // and travel progressively between them ...\n const newFirst = [\n this.array1Extract[0].slice(),\n this.array1Extract[1].slice(),\n ];\n const newSecond = [\n this.array2Extract[0].slice(),\n this.array2Extract[1].slice(),\n ];\n const array1Length = this.array1Extract[0]\n ? this.array1Extract[0].length\n : 0;\n const array2Length = this.array2Extract[0]\n ? this.array2Extract[0].length\n : 0;\n let pos1 = 0;\n let pos2 = 0;\n let previous2 = 0;\n while (pos1 < array1Length) {\n const diff = newFirst[0][pos1] - this.array2Extract[0][pos2];\n if (Math.abs(diff) < this.widthBottom) {\n // there is some overlap\n let overlap;\n if (this.trapezoid) {\n // old trapezoid overlap similarity\n overlap = this.getOverlapTrapezoid(newFirst[0][pos1], newFirst[1][pos1], newSecond[0][pos2], newSecond[1][pos2], this.widthTop, this.widthBottom);\n }\n else {\n overlap = this.getOverlap(newFirst[0][pos1], newFirst[1][pos1], newSecond[0][pos2], newSecond[1][pos2], this.widthTop, this.widthBottom);\n }\n newFirst[1][pos1] -= overlap;\n newSecond[1][pos2] -= overlap;\n if (pos2 < array2Length - 1) {\n pos2++;\n }\n else {\n pos1++;\n pos2 = previous2;\n }\n }\n else if (diff > 0 && pos2 < array2Length - 1) {\n pos2++;\n previous2 = pos2;\n }\n else {\n pos1++;\n pos2 = previous2;\n }\n }\n return newSecond;\n }\n /**\n * Set the new peaks and return info\n * @param {Peaks} newPeaks1\n * @param {Peaks} newPeaks2\n * @returns\n */\n getSimilarity(newPeaks1, newPeaks2) {\n if (newPeaks1)\n this.setPeaks1(newPeaks1);\n if (newPeaks2)\n this.setPeaks2(newPeaks2);\n const diff = this.calculateDiff();\n return {\n diff,\n extract1: this.getExtract1(),\n extract2: this.getExtract2(),\n extractInfo1: this.getExtractInfo1(),\n extractInfo2: this.getExtractInfo2(),\n similarity: calculateOverlapFromDiff(diff),\n widthBottom: this.widthBottom,\n widthTop: this.widthTop,\n };\n }\n /**\n * This works mainly when you have a array1 that is fixed\n * newPeaks2 have to be normalized ! (sum to 1)\n * @param {Peaks} newPeaks2\n * @param {number} from\n * @param {number} to\n * @returns\n */\n fastSimilarity(newPeaks2, from, to) {\n this.array1Extract = extract(this.array1, from, to);\n this.array2Extract = newPeaks2;\n if (this.common & COMMON_SECOND) {\n this.array1Extract = getCommonArray(this.array1Extract, this.array2Extract, this.widthBottom);\n }\n normalize(this.array1Extract);\n const diff = this.calculateDiff();\n return calculateOverlapFromDiff(diff);\n }\n}\n//# sourceMappingURL=index.js.map","export default function maybeToPrecision(value, digits) {\n if (value < 0) {\n value = 0 - value;\n if (typeof digits === 'number') {\n return `- ${value.toPrecision(digits)}`;\n } else {\n return `- ${value.toString()}`;\n }\n } else {\n if (typeof digits === 'number') {\n return value.toPrecision(digits);\n } else {\n return value.toString();\n }\n }\n}\n","import { isAnyArray } from 'is-any-array';\n\nexport default function checkArraySize(x, y) {\n if (!isAnyArray(x) || !isAnyArray(y)) {\n throw new TypeError('x and y must be arrays');\n }\n if (x.length !== y.length) {\n throw new RangeError('x and y arrays must have the same length');\n }\n}\n","import { isAnyArray } from 'is-any-array';\n\nexport { default as maybeToPrecision } from './maybeToPrecision';\nexport { default as checkArrayLength } from './checkArrayLength';\n\nexport default class BaseRegression {\n constructor() {\n if (new.target === BaseRegression) {\n throw new Error('BaseRegression must be subclassed');\n }\n }\n\n predict(x) {\n if (typeof x === 'number') {\n return this._predict(x);\n } else if (isAnyArray(x)) {\n const y = [];\n for (let i = 0; i < x.length; i++) {\n y.push(this._predict(x[i]));\n }\n return y;\n } else {\n throw new TypeError('x must be a number or array');\n }\n }\n\n _predict() {\n throw new Error('_predict must be implemented');\n }\n\n train() {\n // Do nothing for this package\n }\n\n toString() {\n return '';\n }\n\n toLaTeX() {\n return '';\n }\n\n /**\n * Return the correlation coefficient of determination (r) and chi-square.\n * @param {Array} x\n * @param {Array} y\n * @return {object}\n */\n score(x, y) {\n if (!isAnyArray(x) || !isAnyArray(y) || x.length !== y.length) {\n throw new Error('x and y must be arrays of the same length');\n }\n\n const n = x.length;\n const y2 = new Array(n);\n for (let i = 0; i < n; i++) {\n y2[i] = this._predict(x[i]);\n }\n\n let xSum = 0;\n let ySum = 0;\n let chi2 = 0;\n let rmsd = 0;\n let xSquared = 0;\n let ySquared = 0;\n let xY = 0;\n for (let i = 0; i < n; i++) {\n xSum += y2[i];\n ySum += y[i];\n xSquared += y2[i] * y2[i];\n ySquared += y[i] * y[i];\n xY += y2[i] * y[i];\n if (y[i] !== 0) {\n chi2 += ((y[i] - y2[i]) * (y[i] - y2[i])) / y[i];\n }\n rmsd += (y[i] - y2[i]) * (y[i] - y2[i]);\n }\n\n const r =\n (n * xY - xSum * ySum) /\n Math.sqrt((n * xSquared - xSum * xSum) * (n * ySquared - ySum * ySum));\n\n return {\n r: r,\n r2: r * r,\n chi2: chi2,\n rmsd: Math.sqrt(rmsd / n),\n };\n }\n}\n","import { Spectrum } from 'ms-spectrum';\n\nimport { appendFragmentsInfo } from './append/appendFragmentsInfo.js';\nimport { fromArray } from './from/fromArray.js';\nimport { fromMonoisotopicMass } from './from/fromMonoisotopicMass.js';\nimport { fromNucleicSequence } from './from/fromNucleicSequence.js';\nimport { fromPeptidicSequence } from './from/fromPeptidicSequence.js';\nimport { fromRange } from './from/fromRange.js';\nimport { loadCommercials } from './loadCommercials.js';\nimport { loadGoogleSheet } from './loadGoogleSheet.js';\nimport { loadKnapSack } from './loadKnapSack.js';\nimport { search } from './search.js';\nimport { searchMSEM } from './searchMSEM.js';\nimport { searchSimilarity } from './searchSimilarity.js';\n\nexport * from './searchPubchem.js';\nexport * from './searchActivesOrNaturals.js';\nexport * from './massShifts.js';\n\n/**\n * A class that deals with database of monoisotopic mass and molecular formula\n */\nexport class EMDB {\n constructor() {\n this.databases = {};\n this.experimentalSpectrum = undefined;\n }\n\n /**\n *\n * @param {*} data\n * @param {object} [options={}]\n * @param {number} [options.normed=true] Should we normed (sum Y to 1) the experimental spectrum ?\n */\n setExperimentalSpectrum(data, options = {}) {\n const { normed = true } = options;\n if (normed) {\n this.experimentalSpectrum = new Spectrum(data).normedY();\n } else {\n this.experimentalSpectrum = new Spectrum(data);\n }\n return this.experimentalSpectrum;\n }\n\n /**\n * Add a new database using the KnapSack content\n * @param {*} options\n */\n async loadKnapSack(options = {}) {\n const { databaseName = 'knapSack', forceReload = false } = options;\n if (this.databases[databaseName] && !forceReload) return;\n this.databases[databaseName] = await loadKnapSack();\n }\n\n /**\n * Add a new database of 12000 commercial products\n * @param {*} options\n */\n async loadCommercials(options = {}) {\n const { databaseName = 'commercials', forceReload = false } = options;\n if (this.databases[databaseName] && !forceReload) return;\n this.databases[databaseName] = await loadCommercials();\n }\n\n get(databaseName) {\n return this.databases[databaseName];\n }\n\n /**\n * Load the contaminants database from a google sheet document\n * @param {object} [options={}]\n * @param {string} [options.databaseName='contaminants']\n * @param {string} [options.forceReload=false]\n */\n async loadContaminants(options = {}) {\n const { databaseName = 'contaminants', forceReload = false } = options;\n if (this.databases[databaseName] && !forceReload) return;\n this.databases[databaseName] = await loadGoogleSheet();\n }\n\n /**\n * Load a google sheet containing MF information\n * @param {object} [options={}]\n * @param {string} [options.databaseName='sheet']\n * @param {string} [options.forceReload=false]\n */\n\n async loadGoogleSheet(options = {}) {\n const { databaseName = 'sheet', forceReload = false } = options;\n if (this.databases[databaseName] && !forceReload) return;\n this.databases[databaseName] = await loadGoogleSheet();\n }\n\n async loadTest() {\n await this.fromArray(['C1-100'], {\n databaseName: 'test',\n ionizations: '+',\n });\n }\n\n async loadNeutralTest(options = {}) {\n const { maxC = 100 } = options;\n await this.fromArray([`C1-${maxC}`], { databaseName: 'test' });\n }\n\n async fromMonoisotopicMass(mass, options = {}) {\n const { databaseName = 'monoisotopic', append = false } = options;\n let result = await fromMonoisotopicMass(mass, options);\n replaceOrAppend(this, databaseName, result.mfs, append);\n return result;\n }\n\n async fromArray(sequence, options = {}) {\n const { databaseName = 'generated', append = false, estimate } = options;\n const results = await fromArray(sequence, options);\n if (estimate) return results;\n replaceOrAppend(this, databaseName, results, append);\n }\n\n async fromRange(sequence, options = {}) {\n const { databaseName = 'generated', append = false, estimate } = options;\n const results = await fromRange(sequence, options);\n if (estimate) return results;\n replaceOrAppend(this, databaseName, results, append);\n }\n\n async fromPeptidicSequence(sequence, options = {}) {\n const { databaseName = 'peptidic', append = false, estimate } = options;\n const results = await fromPeptidicSequence(sequence, options);\n if (estimate) return results;\n replaceOrAppend(this, databaseName, results, append);\n }\n\n /**\n *\n * @param {string} databaseName\n * @param {object} [options={}]\n * @param {number} [options.precision=100]\n * @param {string} [options.ionizations='']\n * @returns\n */\n async appendFragmentsInfo(databaseName, options = {}) {\n const database = this.databases[databaseName];\n await appendFragmentsInfo(this.experimentalSpectrum, database, options);\n return database;\n }\n\n async fromNucleicSequence(sequence, options = {}) {\n const { databaseName = 'nucleic', append = false, estimate } = options;\n const results = await fromNucleicSequence(sequence, options);\n if (estimate) return results;\n replaceOrAppend(this, databaseName, results, append);\n }\n\n listDatabases() {\n return Object.keys(this.databases).sort();\n }\n\n getInfo() {\n return {\n databases: Object.keys(this.databases)\n .sort()\n .map((key) => {\n return { name: key, nbEntries: this.databases[key].length };\n }),\n };\n }\n\n search(filter, options = {}) {\n return search(this, filter, options);\n }\n\n searchMSEM(filter, options = {}) {\n return searchMSEM(this, filter, options);\n }\n\n searchSimilarity(options = {}) {\n return searchSimilarity(this, options);\n }\n}\n\nfunction replaceOrAppend(emdb, databaseName, results, append = false) {\n if (!emdb.databases[databaseName] || !append) {\n emdb.databases[databaseName] = results;\n return;\n }\n emdb.databases[databaseName] = emdb.databases[databaseName].concat(results);\n}\n","import { findMFs } from 'mf-finder';\n\n/**\n * Generates a database 'monoisotopic' from a monoisotopic mass and various options\n * @param {number|string|array} masses - Monoisotopic mass\n * @param {object} [options={}]\n * @param {number} [options.maxIterations=10000000] - Maximum number of iterations\n * @param {function} [options.onStep] - Callback to do after each step\n * @param {boolean} [options.allowNeutral=true]\n * @param {boolean} [options.uniqueMFs=true]\n * @param {number} [options.limit=1000] - Maximum number of results\n * @param {string} [options.ionizations=''] - string containing a comma separated list of modifications\n * @param {string} [options.ranges='C0-100 H0-100 O0-100 N0-100'] - range of mfs to search\n * @param {number} [options.precision=100] - Allowed mass range based on precision\n * @param {object} [options.filter={}]\n * @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n * @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n * @param {object} [options.filter.unsaturation={}]\n * @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {object} [options.filter.atoms] - object of atom:{min, max}\n * @param {function} [options.filter.callback] - a function to filter the MF\n * @returns {Promise}\n */\n\nexport async function fromMonoisotopicMass(masses, options = {}) {\n if (typeof masses === 'string') {\n masses = masses.split(/[ ,;\\r\\n\\t]/).map(Number);\n }\n if (typeof masses === 'number') {\n masses = [masses];\n }\n let results = [];\n for (let mass of masses) {\n results.push(await findMFs(mass, options));\n }\n return {\n mfs: results.map((entry) => entry.mfs).flat(),\n info: {\n numberMFEvaluated: results.reduce(\n (sum, current) => (sum += current.info.numberMFEvaluated),\n 0,\n ),\n numberResults: results.reduce(\n (sum, current) => (sum += current.info.numberResults),\n 0,\n ),\n },\n };\n}\n","import { generateMFs } from 'mf-generator';\n\n/**\n * Generates a database 'generated' from an array of molecular formula\n * @param {array} mfsArray - Array of string or Array of array containing the parts to combine\n * @param {object} [options={}]\n * @param {boolean} [options.estimate=false] - estimate the number of MF without filters\n * @param {string} [options.databaseName='generated']\n * @param {function} [options.onStep] - Callback to do after each step\n * @param {number} [options.limit=10000000] - Maximum number of results\n * @param {boolean} [options.canonizeMF=true] - Canonize molecular formula\n * @param {boolean} [options.uniqueMFs=true] - Force canonization and make MF unique\n * @param {string} [options.ionizations=''] - Comma separated list of ionizations (to charge the molecule)\n * @param {object} [options.filter={}]\n * @param {number} [options.filter.minMass=0] - Minimal monoisotopic mass\n * @param {number} [options.filter.maxMass=+Infinity] - Maximal monoisotopic mass\n * @param {number} [options.filter.minEM=0] - Minimal neutral monoisotopic mass\n * @param {number} [options.filter.maxEM=+Infinity] - Maximal neutral monoisotopic mass\n * @param {number} [options.filter.minMSEM=0] - Minimal observed monoisotopic mass\n * @param {number} [options.filter.maxMSEM=+Infinity] - Maximal observed monoisotopic mass\n * @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n * @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n *\n * @param {object} [options.filter.unsaturation={}]\n * @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {object} [options.filter.atoms] - object of atom:{min, max}\n * @param {function} [options.filter.callback] - a function to filter the MF\n * @param {string} [options.filterFct] - A string representing a function\n *\n * @example\n *\n * const {EMDB} = require('emdb');\n * let emdb = new EMDB();\n * let array = ['C1-10', 'H1-10'];\n * emdb.fromArray(array); // create a database 'generated' combining all possibilies\n * console.log(emdb.get('generated').length); // 100\n *\n * @example\n * const {EMDB} = require('emdb');\n * let emdb = new EMDB();\n * let array = ['C1-10 H1-10'];\n * emdb.fromArray(array); // create a database 'generated' combining all possibilies\n * console.log(emdb.get('generated').length); // 100\n *\n * @example\n * const {EMDB} = require('emdb');\n * let emdb = new EMDB();\n * // in case of an array of array, one of the group is allwed\n * let array = [['C1-10','H1-10'],'Cl0-1 Br0-1'];\n * emdb.fromArray(array); // create a database 'generated' combining all possibilies\n * console.log(emdb.get('generated').length); // 80\n *\n * @example\n * \n * \n *\n * // from the browser\n */\n\nexport async function fromArray(mfsArray, options = {}) {\n return generateMFs(mfsArray, options);\n}\n","import { generateMFs } from 'mf-generator';\n\n/**\n * Generates a database 'generated' from an array of molecular formula\n * @param {string} rangesString - a string representing the range to search\n * @param {object} [options={}]\n * @param {boolean} [options.estimate=false] - estimate the number of MF without filters\n * @param {function} [options.onStep] - Callback to do after each step\n * @param {string} [options.databaseName='generated']\n * @param {number} [options.limit=100000] - Maximum number of results\n * @param {boolean} [options.canonizeMF=true] - Canonize molecular formula\n * @param {boolean} [options.uniqueMFs=true] - Force canonization and make MF unique\n * @param {string} [options.ionizations=''] - Comma separated list of ionizations (to charge the molecule)\n * @param {object} [options.filter={}]\n * @param {number} [options.filter.minMass=0] - Minimal monoisotopic mass\n * @param {number} [options.filter.maxMass=+Infinity] - Maximal monoisotopic mass\n * @param {number} [options.filter.minEM=0] - Minimal neutral monoisotopic mass\n * @param {number} [options.filter.maxEM=+Infinity] - Maximal neutral monoisotopic mass\n * @param {number} [options.filter.minMSEM=0] - Minimal observed monoisotopic mass\n * @param {number} [options.filter.maxMSEM=+Infinity] - Maximal observed monoisotopic mass\n * @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n * @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n *\n * @param {object} [options.filter.unsaturation={}]\n * @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {function} [options.filter.callback] - a function to filter the MF\n * @param {object} [options.filter.atoms] - object of atom:{min, max}\n *\n * @returns {Promise} - list of possible molecular formula\n *\n * @example\n * const {EMDB} = require('emdb');\n * let emdb = new EMDB();\n * // semi-columns separated for combination, comma for 'or'\n * emdb.fromRange('C1-10, H1-10; Cl0-1 Br0-1'); // create a database 'generated' combining all possibilies\n * console.log(emdb.get('generated').length); // 80\n */\n\nexport async function fromRange(rangesString, options = {}) {\n let ranges = rangesString.split(/ *[;\\r\\n] */);\n for (let i = 0; i < ranges.length; i++) {\n let range = ranges[i];\n if (range.includes(',')) {\n ranges[i] = range.split(/ *, */);\n }\n }\n\n return generateMFs(ranges, options);\n}\n","import { groupsToSequence } from 'chemical-groups';\nimport { generateMFs } from 'mf-generator';\n\nimport { fragmentPeptide } from './util/fragmentPeptide';\n\n/**\n * Add a database starting from a peptidic sequence\n *\n * @param {string} [sequences] Sequence as a string of 1 letter or 3 letters code. Could also be a correct molecular formula respecting uppercase, lowercase. It can be comma separated if you have many peptide sequences\n * @param {object} [options={}]\n * @param {boolean} [options.estimate=false] - estimate the number of MF without filters\n * @param {string} [options.ionizations='']\n * @param {function} [options.onStep] - Callback to do after each step\n * @param {array} [options.mfsArray=[]]\n * @param {boolean} [options.protonation=false]\n * @param {number} [options.protonationPH=7]\n * @param {boolean} [options.allowNeutralLoss=false]\n * @param {number} [options.limit=100000]\n *\n * @param {object} [options.digestion={}] Object defining options for digestion\n * @param {number} [options.digestion.minMissed=0] Minimal number of allowed missed cleavage\n * @param {number} [options.digestion.maxMissed=0] Maximal number of allowed missed cleavage\n * @param {number} [options.digestion.minResidue=0] Minimal number of residues\n * @param {number} [options.digestion.maxResidue=+Infinity] Maximal number of residues\n * @param {string} [options.digestion.enzyme] Mandatory field containing the name of the enzyme among: chymotrypsin, trypsin, glucph4, glucph8, thermolysin, cyanogenbromide\n *\n * @param {object} [options.fragmentation={}] Object defining options for fragmentation\n * @param {boolean} [options.fragmentation.a=false] If true allow fragments of type 'a'\n * @param {boolean} [options.fragmentation.b=false] If true allow fragments of type 'b'\n * @param {boolean} [options.fragmentation.c=false] If true allow fragments of type 'c'\n * @param {boolean} [options.fragmentation.x=false] If true allow fragments of type 'x'\n * @param {boolean} [options.fragmentation.y=false] If true allow fragments of type 'y'\n * @param {boolean} [options.fragmentation.z=false] If true allow fragments of type 'z'\n * @param {boolean} [options.fragmentation.ya=false] If true allow fragments of type 'ya'\n * @param {boolean} [options.fragmentation.yb=false] If true allow fragments of type 'yb'\n * @param {boolean} [options.fragmentation.yc=false] If true allow fragments of type 'yc'\n * @param {boolean} [options.fragmentation.zc=false] If true allow fragments of type 'zc'\n * @param {number} [options.fragmentation.minInternal=0] Minimal internal fragment length\n * @param {number} [options.fragmentation.maxInternal=+Infinity] Maximal internal fragment length\n *\n * @param {object} [options.filter={}] Object defining options for molecular formula filter\n * @param {number} [options.filter.precision=1000] - The precision on the experimental mass\n * @param {number} [options.filter.targetMass] - Target mass, allows to calculate error and filter results\n * @param {Array} [options.filter.targetMasses] - Target masses: SORTED array of numbers\n * @param {Array} [options.filter.targetIntensities] - Target intensities: SORTED array of numbers\n * @param {number} [options.filter.minEM=0] - Minimal neutral monoisotopic mass\n * @param {number} [options.filter.maxEM=+Infinity] - Maximal neutral monoisotopic mass\n * @param {number} [options.filter.minMSEM=0] - Minimal observed monoisotopic mass\n * @param {number} [options.filter.maxMSEM=+Infinity] - Maximal observed monoisotopic mass\n * @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n * @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n * @param {object} [options.filter.unsaturation={}]\n * @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @param {function} [options.filter.callback] - a function to filter the MF\n * @returns {Promise}\n */\n\nexport async function fromPeptidicSequence(sequences, options = {}) {\n const {\n digestion = {},\n mfsArray: originalMFsArray = [],\n allowNeutralLoss = false,\n protonation = false,\n protonationPH = 7,\n fragmentation = {},\n filter = {},\n ionizations = '',\n limit = 100000,\n estimate = false,\n onStep,\n links = {},\n } = options;\n\n const hasLinked = sequences.includes('#');\n const mfsArrayLinked = JSON.parse(JSON.stringify(originalMFsArray));\n const mfsArrayUnlinked = JSON.parse(JSON.stringify(originalMFsArray));\n const unlinked = [];\n mfsArrayUnlinked.push(unlinked);\n\n for (const sequence of sequences.split(/[,:]/)) {\n let fragmentsArray = fragmentPeptide(sequence, {\n digestion,\n protonation,\n fragmentation,\n protonationPH,\n allowNeutralLoss,\n });\n mfsArrayLinked.push(\n fragmentsArray.filter((fragment) => fragment.includes('#')),\n );\n unlinked.push(\n ...fragmentsArray.filter((fragment) => !fragment.includes('#')),\n );\n }\n\n let combined = await generateMFs(mfsArrayUnlinked, {\n ionizations,\n filter,\n estimate,\n limit,\n onStep,\n links,\n });\n\n if (hasLinked) {\n combined.push(\n ...(await generateMFs(mfsArrayLinked, {\n ionizations,\n filter,\n estimate,\n limit,\n onStep,\n links,\n })),\n );\n }\n\n if (!estimate) {\n combined.forEach((result) => {\n result.sequence = groupsToSequence(\n result.parts.filter((part) => part).join(' '),\n );\n });\n }\n\n return combined;\n}\n","import { findMFs } from 'mf-finder';\n\n/**\n *\n * @param {object} experimentalSpectrum\n * @param {object} database\n * @param {object} [options={}]\n * @param {function} [options.onStep] - Callback to do after each step\n * @param {string} [options.ionizations=''] - string containing a comma separated list of modifications\n * @param {number} [options.precision=100] - Allowed mass range based on precision\n */\nexport async function appendFragmentsInfo(\n experimentalSpectrum,\n database,\n options = {},\n) {\n const { ionizations, onStep, precision } = options;\n if (!experimentalSpectrum) {\n throw new Error('Experimental spectrum is not defined');\n }\n if (!database) {\n throw new Error('Database is not defined');\n }\n\n const peaks = experimentalSpectrum.getPeaks({ sumValue: 1 });\n for (let entry of database) {\n const ranges = Object.keys(entry.atoms)\n .map((atom) => `${atom}0-${entry.atoms[atom]}`)\n .join(' ');\n\n entry.fragments = {\n nbFound: 0,\n intensityFound: 0,\n assignments: [],\n };\n for (let i = 0; i < peaks.length; i++) {\n if (onStep) await onStep(i);\n const peak = peaks[i];\n const possibleMFs = await findMFs(peak.x, {\n ionizations,\n precision,\n ranges,\n });\n if (possibleMFs.mfs.length > 0) {\n entry.fragments.nbFound++;\n entry.fragments.intensityFound += peak.y;\n entry.fragments.assignments.push({\n peak,\n bestMF: possibleMFs.mfs[0],\n });\n }\n }\n }\n}\n","import { groupsToSequence } from 'chemical-groups';\nimport { generateMFs } from 'mf-generator';\nimport { sequenceToMF, generateFragments, baseLoss } from 'nucleotide';\n\n/**\n * Add a database starting from a peptidic sequence\n *\n * @param {string} [sequencesString] Sequence as a string of 1 letter or 3 letters code. Could also be a correct molecular formula respecting uppercase, lowercase\n * @param {object} [options={}]\n * @param {boolean} [options.estimate=false] - estimate the number of MF without filters\n * @param {function} [options.onStep] - Callback to do after each step\n * @param {number} [options.limit=100000]\n * @param {string} [options.ionizations='']\n * @param {object} [options.info={}]\n * @param {string} [options.info.kind] - rna, ds-dna or dna. Default if contains U: rna, otherwise ds-dna\n * @param {string} [options.info.fivePrime=monophosphate] - alcohol, monophosphate, diphosphate, triphosphate\n * @param {string} [options.info.circular=false]\n * @param {array} [options.mfsArray=[]]\n * @param {object} [options.fragmentation={}] Object defining options for fragmentation\n * @param {boolean} [options.fragmentation.a=false] If true allow fragments of type 'a'\n * @param {boolean} [options.fragmentation.ab=false] If true allow fragments of type 'a' minus base\n * @param {boolean} [options.fragmentation.b=false] If true allow fragments of type 'b'\n * @param {boolean} [options.fragmentation.c=false] If true allow fragments of type 'c'\n * @param {boolean} [options.fragmentation.d=false] If true allow fragments of type 'd'\n * @param {boolean} [options.fragmentation.dh2o=false] If true allow fragments of type 'd' with water loss\n * @param {boolean} [options.fragmentation.w=false] If true allow fragments of type 'w'\n * @param {boolean} [options.fragmentation.x=false] If true allow fragments of type 'x'\n * @param {boolean} [options.fragmentation.y=false] If true allow fragments of type 'y'\n * @param {boolean} [options.fragmentation.z=false] If true allow fragments of type 'z'\n * @param {boolean} [options.baseLoss=false] If true allow base loss at all the positions\n *\n * @param {object} [options.filter={}] Object defining options for molecular formula filter\n * @param {number} [options.filter.minMass=0] - Minimal monoisotopic mass\n * @param {number} [options.filter.maxMass=+Infinity] - Maximal monoisotopic mass\n * @param {number} [options.filter.minEM=0] - Minimal neutral monoisotopic mass\n * @param {number} [options.filter.maxEM=+Infinity] - Maximal neutral monoisotopic mass\n * @param {number} [options.filter.minMSEM=0] - Minimal observed monoisotopic mass\n * @param {number} [options.filter.maxMSEM=+Infinity] - Maximal observed monoisotopic mass\n * @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n * @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n * @param {object} [options.filter.unsaturation={}]\n * @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n * @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n * @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n * @returns {Promise}\n */\n\nexport async function fromNucleicSequence(sequencesString, options = {}) {\n const {\n mfsArray = [],\n fragmentation = {},\n filter = {},\n ionizations = '',\n info = {},\n estimate = false,\n limit = 100000,\n onStep,\n } = options;\n\n let sequences = sequenceToMF(sequencesString, info).split('.');\n let fragmentsArray = sequences.slice();\n\n // calculate fragmentation\n for (let i = 0; i < sequences.length; i++) {\n let sequence = sequences[i];\n let fragments = generateFragments(sequence, fragmentation);\n if (i === 1) {\n // complementary sequence\n fragments = fragments.map((fragment) => fragment.replace(/\\$/g, '$cmp-'));\n }\n fragmentsArray = fragmentsArray.concat(fragments);\n if (fragmentation.baseLoss) {\n fragmentsArray = fragmentsArray.concat(baseLoss(sequence));\n }\n }\n\n mfsArray.push(fragmentsArray);\n\n let combined = await generateMFs(mfsArray, {\n ionizations,\n filter,\n uniqueMFs: false,\n estimate,\n onStep,\n limit,\n });\n\n if (Array.isArray(combined)) {\n // not an estimation\n combined.forEach((result) => {\n result.sequence = groupsToSequence(\n result.parts.filter((part) => part).join(' '),\n );\n });\n }\n\n return combined;\n}\n","import { generalMatcher } from 'mf-matcher';\n\n/**\n Searching by various criteria. This mass will not take into account the mass\n of the mass of the electron\n* @param {object} [filter={}]\n* @param {number} [filter.minMW=0] - Minimal molecular weight\n* @param {number} [filter.maxMW=+Infinity] - Maximal molecular weight\n* @param {number} [filter.minEM=0] - Minimal monoisotopic mass\n* @param {number} [filter.maxEM=+Infinity] - Maximal monoisotopic mass\n* @param {number} [filter.minCharge=-Infinity] - Minimal charge\n* @param {number} [filter.maxCharge=+Infinity] - Maximal charge\n* @param {object} [filter.unsaturation={}]\n* @param {number} [filter.unsaturation.min=-Infinity] - Minimal unsaturation\n* @param {number} [filter.unsaturation.max=+Infinity] - Maximal unsaturation\n* @param {number} [filter.unsaturation.onlyInteger=false] - Integer unsaturation\n* @param {number} [filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n* @param {object} [filter.atoms] - object of atom:{min, max}\n\n* @param {object} [options={}]\n* @param {array} [options.databases] - an array containing the name of the databases so search, by default all\n* @param {boolean} [options.flatten=false] - should we return the array as a flat result\n*/\n\nexport function search(emdb, filter, options = {}) {\n let { databases = Object.keys(emdb.databases), flatten = false } = options;\n\n let results = {};\n for (let database of databases) {\n results[database] = emdb.databases[database].filter((entry) =>\n generalMatcher(entry, filter),\n );\n }\n\n if (flatten) {\n let flattenResults = [];\n for (let database of databases) {\n for (let entry of results[database]) {\n entry.database = database;\n flattenResults.push(entry);\n }\n }\n return flattenResults;\n } else {\n return results;\n }\n}\n","import { msemMatcher } from 'mf-matcher';\nimport { preprocessIonizations } from 'mf-utilities';\n\n/**\nSearch for an experimental monoisotopic mass\n* @param {number} msem - The observed monoisotopic mass\n* @param {object} [options={}]\n* @param {array} [options.databases] - an array containing the name of the databases so search, by default all\n* @param {boolean} [options.flatten=false] - should we return the array as a flat result\n* @param {string} [options.ionizations] - list the allowed ionizations possibilities\n* @param {object} [options.filter={}]\n* @param {number} [options.filter.targetMass] - Target mass, allows to calculate error and filter results\n* @param {Array} [options.filter.targetMasses] - Target masses: SORTED array of numbers\n* @param {Array} [options.filter.targetIntensities] - Target intensities: SORTED array of numbers\n* @param {number} [options.filter.minEM=0] - Minimal monoisotopic mass\n* @param {number} [options.filter.maxEM=+Infinity] - Maximal monoisotopic mass\n* @param {number} [options.filter.minMSEM=0] - Minimal monoisotopic mass observed by mass\n* @param {number} [options.filter.maxMSEM=+Infinity] - Maximal monoisotopic mass observed by mass\n* @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n* @param {object} [options.filter.unsaturation={}]\n* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n* @param {number} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n* @param {number} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n* @param {object} [options.filter.callback] - a function to filter the MF\n* @param {object} [options.filter.atoms] - object of atom:{min, max}\n*/\n\nexport function searchMSEM(emdb, msem, options = {}) {\n let filter = { ...(options.filter || {}), targetMass: msem };\n let { databases = Object.keys(emdb.databases), flatten = false } = options;\n\n let ionizations = preprocessIonizations(options.ionizations);\n let results = {};\n for (let database of databases) {\n results[database] = [];\n }\n for (let ionization of ionizations) {\n filter.ionization = ionization;\n for (let database of databases) {\n for (let entry of emdb.databases[database]) {\n let match = msemMatcher(entry, filter);\n if (match) {\n results[database].push({\n ...entry,\n ms: match.ms,\n ionization: match.ionization,\n });\n }\n }\n }\n }\n if (flatten) {\n let flattenResults = [];\n for (let database of databases) {\n for (let entry of results[database]) {\n entry.database = database;\n flattenResults.push(entry);\n }\n }\n flattenResults.sort((a, b) => Math.abs(a.ms.ppm) - Math.abs(b.ms.ppm));\n return flattenResults;\n } else {\n Object.keys(results).forEach((k) =>\n results[k].sort((a, b) => Math.abs(a.ms.ppm) - Math.abs(b.ms.ppm)),\n );\n return results;\n }\n}\n","import { IsotopicDistribution } from 'isotopic-distribution';\nimport { Comparator } from 'peaks-similarity';\n/**\nSearch for an experimental monoisotopic mass and calculate the similarity\n* @param {object} [options={}]\n* @param {array} [options.databases] - an array containing the name of the databases so search, by default all\n* @param {boolean} [options.flatten] - should we return the array as a flat result\n* @param {function} [options.onStep] - Callback to do after each step\n* @param {string} [options.ionizations=''] - Comma separated list of ionizations (to charge the molecule)\n* @param {object} [options.minSimilarity=0.5] - min similarity value\n\n* @param {object} [options.filter={}]\n* @param {boolean} [options.filter.forceIonization=false] - If true ignore existing ionizations\n* @param {number} [options.filter.msem] - Observed monoisotopic mass in mass spectrometer\n* @param {number} [options.filter.precision=1000] - The precision on the experimental mass\n* @param {number} [options.filter.minCharge=-Infinity] - Minimal charge\n* @param {number} [options.filter.maxCharge=+Infinity] - Maximal charge\n* @param {object} [options.filter.unsaturation={}]\n* @param {number} [options.filter.unsaturation.min=-Infinity] - Minimal unsaturation\n* @param {number} [options.filter.unsaturation.max=+Infinity] - Maximal unsaturation\n* @param {boolean} [options.filter.unsaturation.onlyInteger=false] - Integer unsaturation\n* @param {boolean} [options.filter.unsaturation.onlyNonInteger=false] - Non integer unsaturation\n* @param {object} [options.filter.atoms] - object of atom:{min, max}\n* @param {object} [options.filter.callback] - a function to filter the MF\n* @param {object} [options.similarity={}]\n* @param {object} [options.similarity.widthBottom]\n* @param {object} [options.similarity.widthTop]\n* @param {object} [options.similarity.widthFunction] - function called with mass that should return an object width containing top and bottom\n* @param {object} [options.similarity.zone={}]\n* @param {object} [options.similarity.zone.low=-0.5] - window shift based on observed monoisotopic mass\n* @param {object} [options.similarity.zone.high=2.5] - to value for the comparison window\n* @param {object} [options.similarity.common]\n* @returns {Promise}\n*/\n\nexport async function searchSimilarity(emdb, options = {}) {\n const { similarity = {}, minSimilarity = 0.5, filter = {}, onStep } = options;\n\n let width = {\n bottom: similarity.widthBottom,\n top: similarity.widthTop,\n };\n\n if (\n !emdb.experimentalSpectrum ||\n !emdb.experimentalSpectrum.data.x.length > 0\n ) {\n throw Error(\n 'You need to add an experimental spectrum first using setMassSpectrum',\n );\n }\n\n let experimentalData = emdb.experimentalSpectrum.data;\n let sumY = emdb.experimentalSpectrum.sumY();\n\n // the result of emdb query will be stored in a property 'ms'\n\n let results = emdb.searchMSEM(filter.msem, options);\n let flatEntries = [];\n if (!options.flatten) {\n for (let database of Object.keys(results)) {\n for (let entry of results[database]) {\n flatEntries.push(entry);\n }\n }\n } else {\n flatEntries = results;\n }\n\n let { widthFunction, zone = {} } = similarity;\n\n if (widthFunction && typeof widthFunction === 'string') {\n // eslint-disable-next-line no-new-func\n widthFunction = new Function('mass', widthFunction);\n let checkTopBottom = widthFunction(123);\n if (!checkTopBottom.bottom || !checkTopBottom.top) {\n throw Error(\n 'widthFunction should return an object with bottom and top properties',\n );\n }\n }\n const { low = -0.5, high = 2.5 } = zone;\n\n // we need to calculate the similarity of the isotopic distribution\n let similarityProcessor = new Comparator(similarity);\n similarityProcessor.setPeaks1([experimentalData.x, experimentalData.y]);\n\n for (let i = 0; i < flatEntries.length; i++) {\n const entry = flatEntries[i];\n if (onStep) await onStep(i);\n let isotopicDistribution = new IsotopicDistribution(entry.mf, {\n allowNeutral: false,\n ionizations: [entry.ionization],\n });\n\n let distribution = isotopicDistribution.getDistribution();\n // we need to define the comparison zone that depends of the charge\n let from = entry.ms.em + low / Math.abs(entry.ms.charge);\n let to = entry.ms.em + high / Math.abs(entry.ms.charge);\n similarityProcessor.setFromTo(from, to);\n\n if (widthFunction) {\n width = widthFunction(entry.ms.em);\n similarityProcessor.setTrapezoid(width.bottom, width.top);\n }\n similarityProcessor.setPeaks2([distribution.xs, distribution.ys]);\n let result = similarityProcessor.getSimilarity();\n\n result.extractInfo1.from = from;\n result.extractInfo1.to = to;\n\n if (result.similarity > minSimilarity) {\n entry.ms.similarity = {\n value: result.similarity,\n experimental: result.extract1,\n theoretical: result.extract2,\n difference: result.diff,\n experimentalInfo: result.extractInfo1,\n thereoticalInfo: result.extractInfo2,\n quantity: result.extractInfo1.sum / sumY,\n width,\n };\n }\n }\n\n if (!options.flatten) {\n for (let database of Object.keys(results)) {\n results[database] = results[database]\n .filter((entry) => entry.ms.similarity)\n .sort((a, b) => b.ms.similarity.value - a.ms.similarity.value);\n for (let entry of results[database]) {\n flatEntries.push(entry);\n }\n }\n } else {\n results = results\n .filter((entry) => entry.ms.similarity)\n .sort((a, b) => b.ms.similarity.value - a.ms.similarity.value);\n }\n\n return results;\n}\n","import {\n xyObjectMaxXPoint,\n xyObjectMinXPoint,\n xyObjectSumY,\n} from 'ml-spectra-processing';\n\n/**\n * Filter the array of peaks\n * @param {array} peaks - array of all the peaks\n * @param {object} [options={}]\n * @param {number} [options.from] - min X value of the window to consider\n * @param {number} [options.to] - max X value of the window to consider\n * @param {number} [options.threshold=0.01] - minimal intensity compare to base peak\n * @param {number} [options.limit=undefined] - maximal number of peaks (based on intensity)\n * @param {number} [options.sumValue] // if sumValue is defined, maxValue is ignored\n * @returns {array} - copy of peaks with 'close' annotation\n */\n\nexport function getPeaks(peaks, options = {}) {\n const {\n from = xyObjectMinXPoint(peaks).x,\n to = xyObjectMaxXPoint(peaks).x,\n threshold = 0.01,\n limit,\n sumValue,\n } = options;\n\n let maxY = Number.MIN_SAFE_INTEGER;\n for (let peak of peaks) {\n if (peak.y > maxY) maxY = peak.y;\n }\n let minY = maxY * threshold;\n\n peaks = peaks.filter(\n (peak) => peak.x >= from && peak.x <= to && peak.y >= minY,\n );\n\n if (limit && peaks.length > limit) {\n peaks.sort((a, b) => b.y - a.y);\n peaks = peaks.slice(0, limit);\n }\n if (sumValue) {\n peaks = JSON.parse(JSON.stringify(peaks));\n const currentSum = xyObjectSumY(peaks);\n const ratio = sumValue / currentSum;\n peaks.forEach((peak) => (peak.y *= ratio));\n }\n\n return peaks.sort((a, b) => a.x - b.x);\n}\n","var IDX=256, HEX=[], BUFFER;\nwhile (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);\n\nexport function v4() {\n\tvar i=0, num, out='';\n\n\tif (!BUFFER || ((IDX + 16) > 256)) {\n\t\tBUFFER = Array(i=256);\n\t\twhile (i--) BUFFER[i] = 256 * Math.random() | 0;\n\t\ti = IDX = 0;\n\t}\n\n\tfor (; i < 16; i++) {\n\t\tnum = BUFFER[IDX + i];\n\t\tif (i==6) out += HEX[num & 15 | 64];\n\t\telse if (i==8) out += HEX[num & 63 | 128];\n\t\telse out += HEX[num];\n\n\t\tif (i & 1 && i > 1 && i < 11) out += '-';\n\t}\n\n\tIDX++;\n\treturn out;\n}\n","import { isAnyArray } from 'is-any-array';\n/**\n * Apply Savitzky Golay algorithm\n * @param [ys] Array of y values\n * @param [xs] Array of X or deltaX\n * @return Array containing the new ys (same length)\n */\nexport function sgg(ys, xs, options = {}) {\n let { windowSize = 9, derivative = 0, polynomial = 3 } = options;\n if (windowSize % 2 === 0 || windowSize < 5 || !Number.isInteger(windowSize)) {\n throw new RangeError('Invalid window size (should be odd and at least 5 integer number)');\n }\n if (!isAnyArray(ys)) {\n throw new TypeError('Y values must be an array');\n }\n if (typeof xs === 'undefined') {\n throw new TypeError('X must be defined');\n }\n if (windowSize > ys.length) {\n throw new RangeError(`Window size is higher than the data length ${windowSize}>${ys.length}`);\n }\n if (derivative < 0 || !Number.isInteger(derivative)) {\n throw new RangeError('Derivative should be a positive integer');\n }\n if (polynomial < 1 || !Number.isInteger(polynomial)) {\n throw new RangeError('Polynomial should be a positive integer');\n }\n if (polynomial >= 6) {\n // eslint-disable-next-line no-console\n console.warn('You should not use polynomial grade higher than 5 if you are' +\n ' not sure that your data arises from such a model. Possible polynomial oscillation problems');\n }\n let half = Math.floor(windowSize / 2);\n let np = ys.length;\n let ans = new Float64Array(np);\n let weights = fullWeights(windowSize, polynomial, derivative);\n let hs = 0;\n let constantH = true;\n if (isAnyArray(xs)) {\n constantH = false;\n }\n else {\n hs = Math.pow(xs, derivative);\n }\n //For the borders\n for (let i = 0; i < half; i++) {\n let wg1 = weights[half - i - 1];\n let wg2 = weights[half + i + 1];\n let d1 = 0;\n let d2 = 0;\n for (let l = 0; l < windowSize; l++) {\n d1 += wg1[l] * ys[l];\n d2 += wg2[l] * ys[np - windowSize + l];\n }\n if (constantH) {\n ans[half - i - 1] = d1 / hs;\n ans[np - half + i] = d2 / hs;\n }\n else {\n hs = getHs(xs, half - i - 1, half, derivative);\n ans[half - i - 1] = d1 / hs;\n hs = getHs(xs, np - half + i, half, derivative);\n ans[np - half + i] = d2 / hs;\n }\n }\n //For the internal points\n let wg = weights[half];\n for (let i = windowSize; i <= np; i++) {\n let d = 0;\n for (let l = 0; l < windowSize; l++)\n d += wg[l] * ys[l + i - windowSize];\n if (!constantH) {\n hs = getHs(xs, i - half - 1, half, derivative);\n }\n ans[i - half - 1] = d / hs;\n }\n return ans;\n}\nfunction getHs(h, center, half, derivative) {\n let hs = 0;\n let count = 0;\n for (let i = center - half; i < center + half; i++) {\n if (i >= 0 && i < h.length - 1) {\n hs += h[i + 1] - h[i];\n count++;\n }\n }\n return Math.pow(hs / count, derivative);\n}\nfunction gramPoly(i, m, k, s) {\n let Grampoly = 0;\n if (k > 0) {\n Grampoly =\n ((4 * k - 2) / (k * (2 * m - k + 1))) *\n (i * gramPoly(i, m, k - 1, s) + s * gramPoly(i, m, k - 1, s - 1)) -\n (((k - 1) * (2 * m + k)) / (k * (2 * m - k + 1))) *\n gramPoly(i, m, k - 2, s);\n }\n else {\n if (k === 0 && s === 0) {\n Grampoly = 1;\n }\n else {\n Grampoly = 0;\n }\n }\n return Grampoly;\n}\nfunction genFact(a, b) {\n let gf = 1;\n if (a >= b) {\n for (let j = a - b + 1; j <= a; j++) {\n gf *= j;\n }\n }\n return gf;\n}\nfunction weight(i, t, m, n, s) {\n let sum = 0;\n for (let k = 0; k <= n; k++) {\n sum +=\n (2 * k + 1) *\n (genFact(2 * m, k) / genFact(2 * m + k + 1, k + 1)) *\n gramPoly(i, m, k, 0) *\n gramPoly(t, m, k, s);\n }\n return sum;\n}\n/**\n * @private\n * @param m Number of points\n * @param n Polynomial grade\n * @param s Derivative\n */\nfunction fullWeights(m, n, s) {\n let weights = new Array(m);\n let np = Math.floor(m / 2);\n for (let t = -np; t <= np; t++) {\n weights[t + np] = new Float64Array(m);\n for (let j = -np; j <= np; j++) {\n weights[t + np][j + np] = weight(j, t, np, n, s);\n }\n }\n return weights;\n}\n//# sourceMappingURL=index.js.map","/**\n * Correction of the x and y coordinates using a quadratic optimizations with the peak and its 3 closest neighbors to determine the true x,y values of the peak.\n * This process is done in place and is very fast.\n * @param data\n * @param peaks\n */\nexport function optimizeTop(data, peaks) {\n const { x, y } = data;\n for (const peak of peaks) {\n let currentIndex = peak.index;\n // The detected peak could be moved 1 or 2 units to left or right.\n if (y[currentIndex - 1] >= y[currentIndex - 2] &&\n y[currentIndex - 1] >= y[currentIndex]) {\n currentIndex--;\n }\n else {\n if (y[currentIndex + 1] >= y[currentIndex] &&\n y[currentIndex + 1] >= y[currentIndex + 2]) {\n currentIndex++;\n }\n else {\n if (y[currentIndex - 2] >= y[currentIndex - 3] &&\n y[currentIndex - 2] >= y[currentIndex - 1]) {\n currentIndex -= 2;\n }\n else {\n if (y[currentIndex + 2] >= y[currentIndex + 1] &&\n y[currentIndex + 2] >= y[currentIndex + 3]) {\n currentIndex += 2;\n }\n }\n }\n }\n // interpolation to a sin() function\n if (y[currentIndex - 1] > 0 &&\n y[currentIndex + 1] > 0 &&\n y[currentIndex] >= y[currentIndex - 1] &&\n y[currentIndex] >= y[currentIndex + 1] &&\n (y[currentIndex] !== y[currentIndex - 1] ||\n y[currentIndex] !== y[currentIndex + 1])) {\n let alpha = 20 * Math.log10(y[currentIndex - 1]);\n let beta = 20 * Math.log10(y[currentIndex]);\n let gamma = 20 * Math.log10(y[currentIndex + 1]);\n let p = (0.5 * (alpha - gamma)) / (alpha - 2 * beta + gamma);\n peak.x = x[currentIndex] + (x[currentIndex] - x[currentIndex - 1]) * p;\n peak.y =\n y[currentIndex] -\n 0.25 * (y[currentIndex - 1] - y[currentIndex + 1]) * p;\n }\n }\n}\n//# sourceMappingURL=optimizeTop.js.map","import { v4 as generateID } from '@lukeed/uuid';\nimport { sgg } from 'ml-savitzky-golay-generalized';\nimport { xIsEquallySpaced, xIsMonotoneIncreasing, xMinValue, xMaxValue, xNoiseStandardDeviation, } from 'ml-spectra-processing';\nimport { optimizeTop } from './utils/optimizeTop';\n/**\n * Global spectra deconvolution\n * @param data - Object data with x and y arrays. Values in x has to be growing\n * @param {number} [options.broadRatio = 0.00] - If `broadRatio` is higher than 0, then all the peaks which second derivative\n * smaller than `broadRatio * maxAbsSecondDerivative` will be marked with the soft mask equal to true.\n\n */\nexport function gsd(data, options = {}) {\n let { sgOptions = {\n windowSize: 9,\n polynomial: 3,\n }, noiseLevel, smoothY = false, maxCriteria = true, minMaxRatio = 0.00025, realTopDetection = false, } = options;\n let { x, y } = data;\n if (!xIsMonotoneIncreasing(x)) {\n throw new Error('GSD only accepts monotone increasing x values');\n }\n //rescale;\n y = y.slice();\n // If the max difference between delta x is less than 5%, then,\n // we can assume it to be equally spaced variable\n let equallySpaced = xIsEquallySpaced(x);\n if (noiseLevel === undefined) {\n if (equallySpaced) {\n const noiseInfo = xNoiseStandardDeviation(y);\n if (maxCriteria) {\n noiseLevel = noiseInfo.median + 1.5 * noiseInfo.sd;\n }\n else {\n noiseLevel = -noiseInfo.median + 1.5 * noiseInfo.sd;\n }\n }\n else {\n noiseLevel = 0;\n }\n }\n else {\n if (maxCriteria === false) {\n noiseLevel *= -1;\n }\n }\n if (maxCriteria === false) {\n for (let i = 0; i < y.length; i++) {\n y[i] *= -1;\n }\n }\n if (noiseLevel !== undefined) {\n for (let i = 0; i < y.length; i++) {\n if (y[i] < noiseLevel) {\n y[i] = noiseLevel;\n }\n }\n }\n let yData = y;\n let dY, ddY;\n const { windowSize, polynomial } = sgOptions;\n if (equallySpaced) {\n if (smoothY) {\n yData = sgg(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = sgg(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = sgg(y, x[1] - x[0], {\n windowSize,\n polynomial,\n derivative: 2,\n });\n }\n else {\n if (smoothY) {\n yData = sgg(y, x, {\n windowSize,\n polynomial,\n derivative: 0,\n });\n }\n dY = sgg(y, x, {\n windowSize,\n polynomial,\n derivative: 1,\n });\n ddY = sgg(y, x, {\n windowSize,\n polynomial,\n derivative: 2,\n });\n }\n const minY = xMinValue(yData);\n const maxY = xMaxValue(yData);\n if (minY > maxY || minY === maxY)\n return [];\n const yThreshold = minY + (maxY - minY) * minMaxRatio;\n const dX = x[1] - x[0];\n let lastMax = null;\n let lastMin = null;\n let minddY = [];\n let intervalL = [];\n let intervalR = [];\n // By the intermediate value theorem We cannot find 2 consecutive maximum or minimum\n for (let i = 1; i < yData.length - 1; ++i) {\n if ((dY[i] < dY[i - 1] && dY[i] <= dY[i + 1]) ||\n (dY[i] <= dY[i - 1] && dY[i] < dY[i + 1])) {\n lastMin = {\n x: x[i],\n index: i,\n };\n if (dX > 0 && lastMax !== null) {\n intervalL.push(lastMax);\n intervalR.push(lastMin);\n }\n }\n // Maximum in first derivative\n if ((dY[i] >= dY[i - 1] && dY[i] > dY[i + 1]) ||\n (dY[i] > dY[i - 1] && dY[i] >= dY[i + 1])) {\n lastMax = {\n x: x[i],\n index: i,\n };\n if (dX < 0 && lastMin !== null) {\n intervalL.push(lastMax);\n intervalR.push(lastMin);\n }\n }\n // Minimum in second derivative\n if (ddY[i] < ddY[i - 1] && ddY[i] < ddY[i + 1]) {\n minddY.push(i);\n }\n }\n let lastK = -1;\n const peaks = [];\n for (const minddYIndex of minddY) {\n let deltaX = x[minddYIndex];\n let possible = -1;\n let k = lastK + 1;\n let minDistance = Number.POSITIVE_INFINITY;\n let currentDistance = 0;\n while (possible === -1 && k < intervalL.length) {\n currentDistance = Math.abs(deltaX - (intervalL[k].x + intervalR[k].x) / 2);\n if (currentDistance < (intervalR[k].x - intervalL[k].x) / 2) {\n possible = k;\n lastK = k;\n }\n ++k;\n // Not getting closer?\n if (currentDistance >= minDistance) {\n break;\n }\n minDistance = currentDistance;\n }\n if (possible !== -1) {\n if (yData[minddYIndex] > yThreshold) {\n let width = Math.abs(intervalR[possible].x - intervalL[possible].x);\n peaks.push({\n id: generateID(),\n x: deltaX,\n y: yData[minddYIndex],\n width,\n index: minddYIndex,\n ddY: ddY[minddYIndex],\n inflectionPoints: {\n from: intervalL[possible],\n to: intervalR[possible],\n },\n });\n }\n }\n }\n if (realTopDetection) {\n optimizeTop({ x, y: yData }, peaks);\n }\n peaks.forEach((peak) => {\n if (!maxCriteria) {\n peak.y *= -1;\n peak.ddY = peak.ddY * -1;\n }\n });\n peaks.sort((a, b) => {\n return a.x - b.x;\n });\n return peaks;\n}\n//# sourceMappingURL=gsd.js.map","/**\n * @param {object} [options={}]\n * @param {object} [options.min=1]\n * @param {object} [options.max=10]\n * @param {object} [options.low=-1]\n * @param {object} [options.high=1]\n * @param {object} [options.precision=100]\n */\n\nconst NEUTRON_MASS = 1;\n\nexport function appendPeaksCharge(peaks, options = {}) {\n let {\n precision = 100,\n low = -1,\n high = 1,\n min: minCharge = 1,\n max: maxCharge = 10,\n } = options;\n let fromCharge =\n minCharge * maxCharge > 0\n ? Math.round(Math.min(Math.abs(minCharge), Math.abs(maxCharge)))\n : 1;\n let toCharge = Math.round(Math.max(Math.abs(minCharge), Math.abs(maxCharge)));\n\n let fromIsotope = Math.ceil(low);\n let toIsotope = Math.floor(high);\n let numberIsotopes = toIsotope - fromIsotope + 1;\n let isotopeIntensity = 1 / numberIsotopes;\n let fromIndex = 0;\n let localFromIndex = 0;\n let localToIndex = 0;\n for (let peakIndex = 0; peakIndex < peaks.length; peakIndex++) {\n let peak = peaks[peakIndex];\n\n let targetMass = peak.x;\n localFromIndex = fromIndex;\n let bestCharge = fromCharge;\n let bestChargeMatch = 0;\n for (let charge = fromCharge; charge < toCharge + 1; charge++) {\n let theoreticalPositions = {\n x: [],\n y: new Array(numberIsotopes).fill(isotopeIntensity),\n };\n\n let massRange = precision * 1e-6 * targetMass;\n for (\n let isotopePosition = fromIsotope;\n isotopePosition < toIsotope + 1;\n isotopePosition++\n ) {\n theoreticalPositions.x.push(\n targetMass + (isotopePosition * NEUTRON_MASS) / charge,\n );\n }\n let fromMass = targetMass + low / Math.abs(charge) - massRange;\n let toMass = targetMass + high / Math.abs(charge) + massRange;\n\n if (charge === 1) {\n // we may move the fromIndex\n while (peaks[fromIndex].x < fromMass) {\n fromIndex++;\n }\n }\n\n /*\n * Find the from / to index for the specific peak and specific charge\n */\n while (peaks[localFromIndex].x < fromMass) {\n localFromIndex++;\n }\n localToIndex = localFromIndex;\n let localHeightSum = 0;\n while (localToIndex < peaks.length && peaks[localToIndex].x < toMass) {\n localHeightSum += peaks[localToIndex].y;\n localToIndex++;\n }\n localToIndex--;\n\n // console.log({ localFromIndex, localToIndex });\n /*\n Calculate the overlap for a specific peak and specific charge\n */\n let currentTheoreticalPosition = 0;\n let theoreticalMaxValue = 1 / numberIsotopes;\n let totalMatch = 0;\n\n for (let index = localFromIndex; index <= localToIndex; index++) {\n let minMass =\n theoreticalPositions.x[currentTheoreticalPosition] -\n massRange / charge;\n let maxMass =\n theoreticalPositions.x[currentTheoreticalPosition] +\n massRange / charge;\n\n while (maxMass < peaks[index].x) {\n currentTheoreticalPosition++;\n theoreticalMaxValue = 1 / numberIsotopes;\n minMass =\n theoreticalPositions.x[currentTheoreticalPosition] -\n massRange / charge;\n maxMass =\n theoreticalPositions.x[currentTheoreticalPosition] +\n massRange / charge;\n }\n\n while (index < peaks.length && peaks[index].x < minMass) {\n index++;\n }\n\n // console.log({ index, minMass, maxMass, massRange, localHeightSum });\n if (index < peaks.length && peaks[index].x <= maxMass) {\n while (index < peaks.length && peaks[index].x <= maxMass) {\n if (peaks[index].x >= minMass && peaks[index].x <= maxMass) {\n let value = peaks[index].y / localHeightSum;\n // console.log({ theoreticalMaxValue, value });\n value = Math.min(theoreticalMaxValue, value);\n\n theoreticalMaxValue -= value;\n totalMatch += value;\n }\n index++;\n }\n index--;\n }\n\n if (totalMatch > bestChargeMatch) {\n bestCharge = charge;\n bestChargeMatch = totalMatch;\n }\n }\n }\n peak.charge = bestCharge;\n }\n return peaks;\n}\n","import { gsd } from 'ml-gsd';\nimport { xyEnsureGrowingX } from 'ml-spectra-processing';\n\nimport { appendPeaksCharge } from './appendPeaksCharge';\n\n/**\n * Filter the array of peaks\n * @param {Spectrum} spectrum - array of all the peaks\n * @param {object} [options={}]\n * @param {object} [options.charge={}]\n * @param {number} [options.charge.min=1]\n * @param {number} [options.charge.max=10]\n * @param {number} [options.charge.low=-1]\n * @param {number} [options.charge.high=1]\n * @param {number} [options.charge.precision=30]\n * @returns {array} - copy of peaks with 'close' annotation\n */\n\nexport function peakPicking(spectrum, options = {}) {\n const { charge: chargeOptions = {} } = options;\n if (!spectrum.peaks || spectrum.peaks.length === 0) {\n spectrum.peaks = [];\n const keys = Object.keys(spectrum.data).filter(\n (key) => key !== 'x' && key !== 'y',\n );\n if (spectrum.isContinuous()) {\n // some experimental data are really problematic and we need to add this line\n const data = xyEnsureGrowingX(spectrum.data);\n const gsdPeaks = gsd(data, {\n minMaxRatio: 0.00025, // Threshold to determine if a given peak should be considered as a noise\n realTopDetection: true,\n smoothY: false,\n sgOptions: { windowSize: 7, polynomial: 3 },\n });\n for (let gsdPeak of gsdPeaks) {\n const peak = { x: gsdPeak.x, y: gsdPeak.y, width: gsdPeak.width };\n for (let key of keys) {\n peak[key] = spectrum.data[key][gsdPeak.index];\n }\n spectrum.peaks.push(peak);\n }\n } else {\n spectrum.peaks = [];\n let data = spectrum.data;\n for (let i = 0; i < data.x.length; i++) {\n const peak = {\n x: data.x[i],\n y: data.y[i],\n width: 0,\n };\n for (let key of keys) {\n peak[key] = spectrum.data[key][i];\n }\n spectrum.peaks.push(peak);\n }\n }\n // required and linked to https://github.com/mljs/global-spectral-deconvolution/issues/17\n spectrum.peaks = spectrum.peaks.filter(\n (peak) => !isNaN(peak.x) && !isNaN(peak.y),\n );\n appendPeaksCharge(spectrum.peaks, chargeOptions);\n }\n\n return spectrum.peaks;\n}\n","import BaseRegression, {\r\n checkArrayLength,\r\n maybeToPrecision,\r\n} from 'ml-regression-base';\r\n\r\nexport default class SimpleLinearRegression extends BaseRegression {\r\n constructor(x, y) {\r\n super();\r\n if (x === true) {\r\n this.slope = y.slope;\r\n this.intercept = y.intercept;\r\n this.coefficients = [y.intercept, y.slope];\r\n } else {\r\n checkArrayLength(x, y);\r\n regress(this, x, y);\r\n }\r\n }\r\n\r\n toJSON() {\r\n return {\r\n name: 'simpleLinearRegression',\r\n slope: this.slope,\r\n intercept: this.intercept,\r\n };\r\n }\r\n\r\n _predict(x) {\r\n return this.slope * x + this.intercept;\r\n }\r\n\r\n computeX(y) {\r\n return (y - this.intercept) / this.slope;\r\n }\r\n\r\n toString(precision) {\r\n let result = 'f(x) = ';\r\n if (this.slope !== 0) {\r\n const xFactor = maybeToPrecision(this.slope, precision);\r\n result += `${xFactor === '1' ? '' : `${xFactor} * `}x`;\r\n if (this.intercept !== 0) {\r\n const absIntercept = Math.abs(this.intercept);\r\n const operator = absIntercept === this.intercept ? '+' : '-';\r\n result += ` ${operator} ${maybeToPrecision(absIntercept, precision)}`;\r\n }\r\n } else {\r\n result += maybeToPrecision(this.intercept, precision);\r\n }\r\n return result;\r\n }\r\n\r\n toLaTeX(precision) {\r\n return this.toString(precision);\r\n }\r\n\r\n static load(json) {\r\n if (json.name !== 'simpleLinearRegression') {\r\n throw new TypeError('not a SLR model');\r\n }\r\n return new SimpleLinearRegression(true, json);\r\n }\r\n}\r\n\r\nfunction regress(slr, x, y) {\r\n const n = x.length;\r\n let xSum = 0;\r\n let ySum = 0;\r\n\r\n let xSquared = 0;\r\n let xY = 0;\r\n\r\n for (let i = 0; i < n; i++) {\r\n xSum += x[i];\r\n ySum += y[i];\r\n xSquared += x[i] * x[i];\r\n xY += x[i] * y[i];\r\n }\r\n\r\n const numerator = n * xY - xSum * ySum;\r\n slr.slope = numerator / (n * xSquared - xSum * xSum);\r\n slr.intercept = (1 / n) * ySum - slr.slope * (1 / n) * xSum;\r\n slr.coefficients = [slr.intercept, slr.slope];\r\n}\r\n","import BaseRegression, {\n checkArrayLength,\n maybeToPrecision\n} from 'ml-regression-base';\nimport SimpleLinearRegression from 'ml-regression-simple-linear';\n\nexport default class PowerRegression extends BaseRegression {\n constructor(x, y) {\n super();\n if (x === true) {\n // reloading model\n this.A = y.A;\n this.B = y.B;\n } else {\n checkArrayLength(x, y);\n regress(this, x, y);\n }\n }\n\n _predict(newInputs) {\n return this.A * Math.pow(newInputs, this.B);\n }\n\n toJSON() {\n return {\n name: 'powerRegression',\n A: this.A,\n B: this.B\n };\n }\n\n toString(precision) {\n return `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )} * x^${maybeToPrecision(this.B, precision)}`;\n }\n\n toLaTeX(precision) {\n let latex = '';\n if (this.B >= 0) {\n latex = `f(x) = ${maybeToPrecision(\n this.A,\n precision\n )}x^{${maybeToPrecision(this.B, precision)}}`;\n } else {\n latex = `f(x) = \\\\frac{${maybeToPrecision(\n this.A,\n precision\n )}}{x^{${maybeToPrecision(-this.B, precision)}}}`;\n }\n latex = latex.replace(/e([+-]?[0-9]+)/g, 'e^{$1}');\n return latex;\n }\n\n static load(json) {\n if (json.name !== 'powerRegression') {\n throw new TypeError('not a power regression model');\n }\n return new PowerRegression(true, json);\n }\n}\n\nfunction regress(pr, x, y) {\n const n = x.length;\n const xl = new Array(n);\n const yl = new Array(n);\n for (let i = 0; i < n; i++) {\n xl[i] = Math.log(x[i]);\n yl[i] = Math.log(y[i]);\n }\n\n const linear = new SimpleLinearRegression(xl, yl);\n pr.A = Math.exp(linear.intercept);\n pr.B = linear.slope;\n}\n","import { isAnyArray } from 'is-any-array';\nimport { xMaxValue, xNormed } from 'ml-spectra-processing';\nimport { parseXY } from 'xy-parser';\n\nimport { getBestPeaks } from './getBestPeaks';\nimport { getFragmentPeaks } from './getFragmentPeaks';\nimport { getMassRemainder } from './getMassRemainder';\nimport { getPeakChargeBySimilarity } from './getPeakChargeBySimilarity';\nimport { getPeaks } from './getPeaks';\nimport { isContinuous } from './isContinuous';\nimport { peakPicking } from './peakPicking';\nimport { peaksWidth } from './peaksWidth';\n\n/**\n * Class dealing with mass spectra and peak picking\n */\nexport class Spectrum {\n constructor(data = { x: [], y: [] }) {\n if (\n typeof data !== 'object' ||\n !isAnyArray(data.x) ||\n !isAnyArray(data.y)\n ) {\n throw new TypeError('Spectrum data must be an object with x:[], y:[]');\n }\n this.data = {}; // we make a copy so that we can add new properties\n for (let key in data) {\n this.data[key] = data[key];\n }\n Object.defineProperty(this.data, 'xOriginal', {\n enumerable: false,\n writable: true,\n });\n this.cache = {};\n this.peaks = [];\n }\n\n maxY() {\n return xMaxValue(this.data.y);\n }\n\n sumY() {\n if (!this.cache.sumY) {\n this.cache.sumY = this.data.y.reduce(\n (previous, current) => previous + current,\n 0,\n );\n }\n return this.cache.sumY;\n }\n\n scaleY(intensity = 1) {\n let basePeak = this.maxY() / intensity;\n this.data.y = this.data.y.map((y) => y / basePeak);\n return this;\n }\n\n rescaleX(callback) {\n this.ensureOriginalX();\n\n for (let i = 0; i < this.data.x.length; i++) {\n this.data.x[i] = callback(this.data.xOriginal[i]);\n }\n\n return this;\n }\n\n ensureOriginalX() {\n if (!this.data.xOriginal) {\n this.data.xOriginal = this.data.x.slice(0);\n }\n }\n\n normedY(total = 1) {\n this.data.y = xNormed(this.data.y);\n if (total !== 1) {\n this.data.y = this.data.y.map((y) => y * total);\n }\n return this;\n }\n\n peakPicking() {\n peakPicking(this);\n return this.peaks;\n }\n\n peaksWidth() {\n peakPicking(this);\n return peaksWidth(this.peaks);\n }\n\n getBestPeaks(options) {\n peakPicking(this);\n return getBestPeaks(this.peaks, options);\n }\n\n getPeakChargeBySimilarity(targetMass, options) {\n return getPeakChargeBySimilarity(this, targetMass, options);\n }\n\n getPeaks(options) {\n peakPicking(this);\n return getPeaks(this.peaks, options);\n }\n\n /**\n * Returns also peaks possible for a specific molecular formula\n * @example\n * const spectrum = new Spectrum({x:[], y:[]})\n * await spectrum.getFragmentPeaks();\n * @param {string} mf\n * @param {object} options\n * @returns\n */\n getFragmentPeaksFct(mf, options) {\n peakPicking(this);\n return getFragmentPeaks(this.peaks, mf, options);\n }\n\n isContinuous() {\n return isContinuous(this);\n }\n\n /**\n * Remove an integer number of time the specifiedd monoisotopic mass\n * Mass remainder analysis (MARA): https://doi.org/10.1021/acs.analchem.7b04730\n */\n getMassRemainderFct(mass, options = {}) {\n return getMassRemainder(this.data, mass, options);\n }\n}\n\nexport function fromPeaks(peaks) {\n if (peaks.length === 0) return new Spectrum();\n const data = {};\n for (let key of Object.keys(peaks[0])) {\n data[key] = peaks.map((peak) => peak[key]);\n }\n return new Spectrum(data);\n}\n\nexport function fromText(text) {\n const data = parseXY(text);\n return new Spectrum(data);\n}\n","import Regression from 'ml-regression-power';\nimport { xMaxValue, xMinValue } from 'ml-spectra-processing';\n\nexport function peaksWidth(peaks) {\n let xs = peaks.map((peak) => peak.x);\n let widths = peaks.map((peak) => peak.width);\n\n if (xs.length < 2) {\n throw new Error(\n `peaksWidth: not enough peaks (less than 2) for automatic width calculation: ${xs.length}`,\n );\n }\n let regression = new Regression(xs, widths, {\n computeQuality: true,\n computeCoefficient: true,\n });\n\n if (isNaN(regression.A) || isNaN(regression.B)) {\n throw new Error('peaksWidth: can not calculate regression');\n }\n\n let from = xMinValue(xs);\n let to = xMaxValue(xs);\n\n let regressionChart = { x: [], y: [] };\n for (let x = from; x <= to; x += (to - from) / 1000) {\n regressionChart.x.push(x);\n regressionChart.y.push(regression.predict(x));\n }\n return {\n widths: {\n x: xs,\n y: widths,\n },\n fit: regressionChart,\n score: regression.score(xs, widths),\n\n predictFct: regression.predict.bind(regression),\n tex: regression.toLaTeX(3),\n A: regression.A,\n B: regression.B,\n predictFctString: `${regression.A} * mass ** ${regression.B}`,\n };\n}\n","import { xyObjectMaxXPoint, xyObjectMinXPoint } from 'ml-spectra-processing';\n\n/**\n * Filter the array by taking the higher peaks and only\n * keep one per slot.\n * There are 2 different slots, the smallest one will have the\n * extra annotation `close` to true\n * @param {array} peaks - array of all the peaks\n * @param {object} [options={}]\n * @param {number} [options.from] - min X value of the window to consider\n * @param {number} [options.to] - max X value of the window to consider\n * @param {number} [options.searchMonoisotopicRatio=0] - search previous peaks with at least ratio height\n * @param {number} [options.limit=20] - max number of peaks\n * @param {number} [options.threshold=0.01] - minimal intensity compare to base peak\n * @param {number} [options.numberSlots=10] - define the number of slots and indirectly the slot width\n * @param {number} [options.numberCloseSlots=50]\n * @returns {array} - copy of peaks with 'close' annotation\n */\n\nexport function getBestPeaks(peaks, options = {}) {\n const {\n searchMonoisotopicRatio = 0,\n from = xyObjectMinXPoint(peaks).x,\n to = xyObjectMaxXPoint(peaks).x,\n limit = 20,\n threshold = 0.01,\n numberCloseSlots = 50,\n numberSlots = 10,\n } = options;\n let slot = (to - from) / numberSlots;\n let closeSlot = (to - from) / numberCloseSlots;\n let selected = peaks\n .filter((peak) => peak.x >= from && peak.x <= to)\n .map((peak) => {\n return {\n peak,\n monoisotopic: false,\n };\n });\n\n if (searchMonoisotopicRatio) {\n selected = selected.sort((a, b) => b.peak.x - a.peak.x);\n\n for (let i = 0; i < selected.length; i++) {\n let item = selected[i];\n for (let j = i + 1; j < selected.length; j++) {\n let nextItem = selected[j];\n if (item.peak.x - nextItem.peak.x < 0.09) continue;\n if (item.peak.x - nextItem.peak.x > 1.1) break;\n if (nextItem.peak.y > item.peak.y * searchMonoisotopicRatio) {\n item.monoisotopic = false;\n nextItem.monoisotopic = true;\n break;\n }\n }\n }\n }\n\n selected = selected.sort((a, b) => {\n if (a.monoisotopic && !b.monoisotopic) return -1;\n if (b.monoisotopic && !a.monoisotopic) return 1;\n return b.peak.y - a.peak.y;\n });\n\n let toReturn = [];\n if (selected.length === 0) return [];\n let minY = selected[0].peak.y * threshold;\n peakLoop: for (let item of selected) {\n if (item.peak.y < minY) {\n if (item.monoisotopic) {\n continue;\n } else {\n break;\n }\n }\n let close = false;\n for (let existing of toReturn) {\n if (Math.abs(existing.x - item.peak.x) < closeSlot) {\n continue peakLoop;\n }\n if (Math.abs(existing.x - item.peak.x) < slot) {\n close = true;\n }\n }\n let newPeak = JSON.parse(JSON.stringify(item.peak));\n newPeak.close = close;\n toReturn.push(newPeak);\n if (toReturn.length === limit) break;\n }\n return toReturn.sort((a, b) => a.x - b.x);\n}\n","import { Comparator } from 'peaks-similarity';\n\n/**\n * @param {object} [options={}]\n * @param {object} [options.minCharge=1]\n * @param {object} [options.maxCharge=10]\n * @param {object} [options.similarity={}]\n * @param {object} [options.similarity.widthBottom]\n * @param {object} [options.similarity.widthTop]\n * @param {object} [options.similarity.widthFunction] - function called with mass that should return an object width containing top and bottom\n * @param {object} [options.similarity.zone={}]\n * @param {object} [options.similarity.zone.low=-0.5] - window shift based on observed monoisotopic mass\n * @param {object} [options.similarity.zone.high=2.5] - to value for the comparison window\n * @param {object} [options.similarity.common]\n */\n\nconst NEUTRON_MASS = 1;\n\nexport function getPeakChargeBySimilarity(spectrum, targetMass, options = {}) {\n let { similarity = {}, minCharge = 1, maxCharge = 10 } = options;\n let { zone = {}, widthFunction } = similarity;\n let { low = -0.5, high = 2.5 } = zone;\n\n if (!spectrum || !spectrum.data.x.length > 0) {\n throw Error(\n 'You need to add an experimental spectrum first using setMassSpectrum',\n );\n }\n\n let width = {\n bottom: similarity.widthBottom,\n top: similarity.widthTop,\n };\n\n similarity = JSON.parse(JSON.stringify(similarity));\n similarity.common = 'second';\n\n let experimentalData = spectrum.data;\n let similarityProcessor = new Comparator(similarity);\n similarityProcessor.setPeaks1([experimentalData.x, experimentalData.y]);\n\n if (widthFunction && typeof widthFunction === 'string') {\n // eslint-disable-next-line no-new-func\n widthFunction = new Function('mass', widthFunction);\n let checkTopBottom = widthFunction(123);\n if (!checkTopBottom.bottom || !checkTopBottom.top) {\n throw Error(\n 'widthFunction should return an object with bottom and top properties',\n );\n }\n }\n\n let fromCharge =\n minCharge * maxCharge > 0\n ? Math.round(Math.min(Math.abs(minCharge), Math.abs(maxCharge)))\n : 1;\n let toCharge = Math.round(Math.max(Math.abs(minCharge), Math.abs(maxCharge)));\n\n let fromIsotope = Math.ceil(low);\n let toIsotope = Math.floor(high);\n let isotopeHeight = 1 / (toIsotope - fromIsotope + 1);\n\n let results = [];\n\n for (let charge = fromCharge; charge < toCharge + 1; charge++) {\n let isotopePositions = { x: [], y: [] };\n for (\n let isotopePosition = fromIsotope;\n isotopePosition < toIsotope + 1;\n isotopePosition++\n ) {\n isotopePositions.x.push(\n targetMass + (isotopePosition * NEUTRON_MASS) / charge,\n );\n isotopePositions.y.push(isotopeHeight);\n }\n let from = targetMass + low / Math.abs(charge);\n let to = targetMass + high / Math.abs(charge);\n similarityProcessor.setFromTo(from, to);\n if (widthFunction) {\n width = widthFunction(targetMass);\n similarityProcessor.setTrapezoid(width.bottom, width.top);\n }\n\n similarityProcessor.setPeaks2([isotopePositions.x, isotopePositions.y]);\n let result = similarityProcessor.getSimilarity();\n\n results.push({ charge, similarity: result.similarity });\n }\n\n return results.sort((a, b) => b.similarity - a.similarity)[0].charge;\n}\n","import { EMDB } from 'emdb';\nimport { MF } from 'mf-parser';\n\nimport { getPeaks } from './getPeaks.js';\n\n/**\n * Filter the array of peaks\n * @param {array} peaks - array of all the peaks\n * @param {string} mf - Molecular formula of the parent molecule\n * @param {object} [options={}]\n * @param {number} [options.from] - min X value of the window to consider\n * @param {number} [options.to] - max X value of the window to consider\n * @param {number} [options.threshold=0.01] - minimal intensity compare to base peak\n * @param {number} [options.limit=undefined] - maximal number of peaks (based on intensity)\n * @param {string} [options.ionizations]\n * @param {number} [options.precision]\n * @returns {array} - copy of peaks with 'close' annotation\n */\n\nexport async function getFragmentPeaks(peaks, mf, options = {}) {\n const emdb = new EMDB();\n\n const { ionizations = '', precision } = options;\n\n const mfInfo = new MF(mf).getInfo();\n const ranges = Object.keys(mfInfo.atoms)\n .map((key) => `${key}0-${mfInfo.atoms[key]}`)\n .join(' ');\n peaks = getPeaks(peaks, options);\n for (let peak of peaks) {\n peak.mfs = (\n await emdb.fromMonoisotopicMass(peak.x, {\n precision,\n ranges,\n ionizations,\n })\n ).mfs;\n }\n peaks = peaks.filter((peak) => peak.mfs.length > 0);\n return peaks;\n}\n","import { xMaxValue } from 'ml-spectra-processing';\n/**\n * When a spectrum is continous ?\n * - has more than 100 points\n * - deltaX change can not be more than a factor 2\n * - deltaX may not be larger than 0.1\n * - if y is zero it does not count\n * @param {object} spectrum\n * @param {object} [options={}]\n * @param {number} [options.minLength=100]\n * @param {number} [options.relativeHeightThreshold=0.001] // Under this value the\n * @param {number} [options.maxDeltaRatio=3]\n */\n\nexport function isContinuous(spectrum, options = {}) {\n const {\n minLength = 100,\n maxDeltaRatio = 3,\n relativeHeightThreshold = 0.001,\n } = options;\n const minHeight = xMaxValue(spectrum.data.y) * relativeHeightThreshold;\n const minRadio = 1 / maxDeltaRatio;\n const maxRatio = 1 * maxDeltaRatio;\n if (spectrum.continuous === undefined) {\n let xs = spectrum.data.x;\n let ys = spectrum.data.y;\n if (xs.length < minLength) {\n spectrum.continuous = false;\n } else {\n let previousDelta = xs[1] - xs[0];\n spectrum.continuous = true;\n let success = 0;\n let failed = 0;\n for (let i = 0; i < xs.length - 1; i++) {\n if (ys[i] < minHeight || ys[i + 1] < minHeight) {\n previousDelta = 0;\n continue;\n }\n let delta = xs[i + 1] - xs[i];\n if (previousDelta) {\n let ratio = delta / previousDelta;\n if (\n (Math.abs(delta) > 0.1 || ratio < minRadio || ratio > maxRatio) &&\n ys[i] !== 0 &&\n ys[i + 1] !== 0\n ) {\n failed++;\n break;\n } else {\n success++;\n }\n }\n previousDelta = delta;\n }\n if (success / failed < 10) {\n spectrum.continuous = false;\n }\n }\n }\n return spectrum.continuous;\n}\n","import { xySortX, xyJoinX } from 'ml-spectra-processing';\n\n/**\n * Remove an integer number of time the specifiedd monoisotopic mass\n * Mass remainder analysis (MARA): https://doi.org/10.1021/acs.analchem.7b04730\n * @param {object} spectrum\n * @param {number} mass\n * @param {object} [options={}\n * @param {number} [options.delta=0.001]\n */\nexport function getMassRemainder(spectrum, mass, options = {}) {\n const { delta = 0.001 } = options;\n const x = spectrum.x.slice();\n const y = spectrum.y;\n for (let i = 0; i < x.length; i++) {\n const factor = Math.floor(x[i] / mass);\n x[i] = x[i] - factor * mass;\n }\n // we sort and join\n return xyJoinX(xySortX({ x, y }), { delta });\n}\n","/**\n * openchemlib - Manipulate molecules\n * @version v8.0.1\n * @date 2022-08-15T14:40:00.265Z\n * @link https://github.com/cheminfo/openchemlib-js\n * @license BSD-3-Clause\n*/\n(function (root) {\n 'use strict';\n\n function getExports($wnd) {\n\n var $doc = $wnd.document;\n var $gwt = {};\n var navigator = {\n userAgent: 'webkit'\n };\n\n function noop(){}\n\n var __gwtModuleFunction = noop;\n __gwtModuleFunction.__moduleStartupDone = noop;\n var $sendStats = noop;\n var $moduleName, $moduleBase;\n\n // Start GWT code \nvar Dib='object',Eib='anonymous',Fib='fnStack',Gib='\\n',Hib={4:1,9:1,5:1,8:1},Iib='Unknown',Jib='boolean',Kib='number',Lib='string',Mib=2147483647,Nib='For input string: \"',Oib='null',Pib='__noinit__',Qib={4:1,5:1,8:1},Rib={4:1,15:1,22:1},Sib={4:1,9:1,28:1,5:1,17:1,8:1,29:1},Tib=65536,Uib=65535,Vib=10000,Wib=', length: ',Xib='Index: ',Yib=', Size: ',Zib='fromIndex: ',$ib=', toIndex: ',_ib={11:1,4:1,5:1},ajb={4:1},bjb={7:1,4:1,5:1},cjb=16777215,djb=65280,ejb=0.30000001192092896,fjb=545460846592,gjb=4294967296,hjb=8589934592,ijb=17179869184,jjb=34359738368,kjb=68719476736,ljb=137438953472,mjb=274877906944,njb='',vjb={12:1,4:1,5:1},wjb=536870912,xjb=2.617993878,yjb=3.665191429,zjb=6.283185307179586,Ajb=3.141592653589793,Bjb=1.5707963267948966,Cjb=16384,Djb=4096,Ejb={l:0,m:0,h:1},Fjb={l:0,m:0,h:2},Gjb=1920,Hjb=1024,Ijb=234881024,Jjb=167772160,Kjb=100663296,Ljb=201326592,Mjb=114688,Njb=4063232,Ojb=3538944,Pjb=3014656,Qjb=2097152,Rjb=393216,Sjb=1966080,Tjb=17042430230528,Ujb=16492674416640,Vjb=15942918602752,Wjb=14843406974976,Xjb=12644383719424,Yjb=8796093022208,Zjb=549755813888,$jb=1649267441664,_jb=3848290697216,akb=8246337208320,bkb=29360128,ckb=268435456,dkb=8192,ekb=2048,fkb=-1.5707963267948966,gkb=32640,hkb=1572864,ikb=524288,jkb=229376,kkb=1.0471975511965976,lkb=0.5235987755982988,mkb=262144,nkb=-16777216,okb=16711680,pkb=-32768,qkb='<\\/DrawingObject>',skb={4:1,5:1,13:1},tkb={4:1,5:1},ukb='unsupported atomicNo:',vkb=2.8415926535897933,wkb={26:1,4:1,9:1,5:1,8:1},xkb={4:1,5:1,17:1,8:1},ykb={10:1,4:1,5:1},zkb=131072,Akb=-65536,Bkb={36:1,37:1,45:1},Ckb={36:1,37:1,73:1,45:1,93:1},Dkb={4:1,5:1,36:1,37:1,73:1,18:1,45:1,93:1,151:1},Ekb='??',Fkb=-268435456,Gkb=65011712,Hkb=3072,Ikb=126976,Jkb=1.7976931348623157E308,Kkb={98:1,4:1,9:1,5:1,17:1,8:1},Lkb=67108864,Mkb=134217728,Nkb=16777216,Okb=-67108865,Pkb=-66584577,Qkb=-3.141592653589793,Rkb=4194303,Skb={34:1,4:1,5:1},Tkb=0.7853981633974483,Ukb=3.061592653589793,Vkb=1073741824,Wkb=541165879296,Xkb={14:1,4:1,5:1,8:1},Ykb=281.17,Zkb=289.19,$kb=294.21,_kb='0.0000',alb='M END\\n',blb='ATOMS',clb=-2147483648,dlb='M END',elb='$$$$',flb='M V30 ',glb='M V30 COUNTS ',hlb=')\\n',ilb='M V30 MDLV30/STEREL',jlb='M V30 MDLV30/STERAC',klb=3.4028234663852886E38,llb=1048576,mlb={l:4179966,m:4063288,h:3},nlb={l:4194302,m:4193343,h:3},olb='class=\"event\" ',plb='opacity=\"0\" />',qlb={l:4194303,m:4194303,h:524287},rlb='Assignment of aromatic double bonds failed',slb='Members of ESR groups must only be stereo centers with known configuration.',tlb='Over- or under-specified stereo feature or more than one racemic type bond',ulb='Ambiguous configuration at stereo center because of 2 parallel bonds',vlb={83:1,70:1,24:1,4:1},wlb=100000,xlb=3.1415927410125732,ylb=1.5707963705062866,zlb=0.029999999329447746,Alb=6.2831854820251465,Blb=1.9106119871139526,Clb=2.2639999389648438,Dlb=2.16759991645813,Elb=2.0662999153137207,Flb=2.3561999797821045,Glb=2.2844998836517334,Hlb=1.9106120066311025,Ilb=2.094395160675049,Jlb=0.6000000238418579,Klb=1.7999999523162842,Llb=0.05000000074505806,Mlb=0.2617993950843811,Nlb=2.0943951023931953,Olb=1.2000000476837158,Plb=1.4299999475479126,Qlb=1.659999966621399,Rlb=1.4600000381469727,Slb=1.8200000524520874,Tlb=2.4600000381469727,Ulb=2.4200000762939453,Vlb=2.450000047683716,Wlb=2.440000057220459,Xlb=2.4000000953674316,Ylb=2.319999933242798,Zlb=2.2899999618530273,$lb=1.8600000143051147,_lb=2.5299999713897705,amb=2.490000009536743,bmb=2.4700000286102295,cmb=2.880000114440918,dmb=2.9200000762939453,emb=2.869999885559082,fmb=2.8299999237060547,gmb=2.7899999618530273,hmb=2.809999942779541,imb=2.799999952316284,jmb=3.049999952316284,kmb=1.3300000429153442,lmb=1.3899999856948853,mmb=1.159999966621399,nmb=1.1100000143051147,omb=1.0700000524520874,pmb=1.9600000381469727,qmb=1.7100000381469727,rmb=1.3600000143051147,smb=1.340000033378601,tmb=1.2200000286102295,umb=1.2400000095367432,vmb=1.2100000381469727,wmb=1.850000023841858,xmb=1.6299999952316284,ymb=1.4700000286102295,zmb=1.2799999713897705,Amb=1.440000057220459,Bmb=1.399999976158142,Cmb=1.7599999904632568,Dmb=1.7300000190734863,Emb=1.7200000286102295,Fmb=1.6799999475479126,Gmb=1.690000057220459,Hmb=1.6699999570846558,Imb=1.649999976158142,Jmb=1.7000000476837158,Kmb=1.6200000047683716,Lmb=1.3700000047683716,Mmb=1.2899999618530273,Nmb=1.4500000476837158,Omb=1.5700000524520874,Pmb=-0.5235987755982988,Qmb=-1.0471975511965976,Rmb=-0.7853981633974483,Smb=0.017453292519943295,Tmb=0.17453292519943295,Umb=1.0E-4,Vmb={108:1},Wmb=57.29577951308232,Xmb=0.021922173386725217,Ymb=1.0E-8,Zmb=2.5120960256267386,$mb=1.0E-5,_mb='MMFF94s+',anb='nonbonded cutoff',bnb='dielectric constant',cnb='dielectric model',dnb='angle bend',enb='bond stretch',fnb='electrostatic',gnb='out of plane',hnb='stretch bend',inb='torsion angle',jnb='van der waals',knb={4:1,9:1,5:1,17:1,8:1},lnb=0.001,mnb=0.07000000000000006,nnb=0.1200000000000001,onb=-7.840000000000001,pnb='OCL_RXN_V1.0:',qnb=\"'$MOL' tag not found\",rnb=\"'M END' not found\",snb='\\nActelion Java MolfileCreator 2.0\\n\\n 0 0 0 0 0 0 0 V3000\\n',tnb='M V30 END CTAB',unb=2475109711874,vnb=2475109711875,wnb=2887426572290,xnb=2887426572291,ynb=2887627898882,znb=2887627898883,Anb=2887627997186,Bnb=3437182386178,Cnb=3437182386179,Dnb=3437383712770,Enb=3437383811074,Fnb=3437652148226,Gnb=3437652377602,Hnb=4674132967426,Inb=4674334294018,Jnb=4674334392322,Knb=4674602729474,Lnb=4674602958850,Mnb=5086449827842,Nnb=5086449827848,Onb=5086651154434,Pnb=5086651252738,Qnb=5086651252743,Rnb=5086919589890,Snb=5086919688194,Tnb=5636406968322,Unb=5636407066626,Vnb=5636675502082,Wnb={l:589826,m:590112,h:4},Xnb={l:589827,m:590112,h:4},Ynb={l:589826,m:590160,h:4},Znb={l:589827,m:590160,h:4},$nb={l:688130,m:590160,h:4},_nb={l:589826,m:590224,h:4},aob={l:589827,m:590224,h:4},bob={l:819203,m:590224,h:4},cob={l:589826,m:590368,h:4},dob={l:688130,m:590368,h:4},eob={l:819202,m:590368,h:4},fob={l:819208,m:590368,h:4},gob={l:589826,m:590416,h:4},hob={l:589832,m:590416,h:4},iob={l:688130,m:590416,h:4},job={l:819202,m:590416,h:4},kob={l:589826,m:598304,h:4},lob={l:589827,m:598304,h:4},mob={l:688130,m:598304,h:4},nob={l:1114114,m:598304,h:4},oob={l:1212418,m:598304,h:4},pob={l:589826,m:598308,h:4},qob={l:589826,m:688416,h:4},rob={l:589826,m:688464,h:4},sob={l:589826,m:688720,h:4},tob={l:688130,m:688720,h:4},uob={l:589826,m:590112,h:288},vob={l:589826,m:590112,h:336},wob={l:589826,m:688416,h:336},xob={l:589826,m:688464,h:336},yob={l:688130,m:688464,h:336},zob={l:589826,m:590112,h:400},Aob={l:589826,m:688416,h:400},Bob={l:589826,m:688464,h:400},Cob={l:688130,m:688464,h:400},Dob={l:589826,m:819488,h:400},Eob={l:589826,m:819536,h:400},Fob={l:589826,m:819600,h:400},Gob={l:688130,m:819600,h:400},Hob={l:819202,m:819600,h:400},Iob={l:589831,m:688416,h:592},Job={l:589831,m:688464,h:592},Kob={l:688135,m:688464,h:592},Lob={l:589831,m:819536,h:592},Mob={l:688135,m:819536,h:592},Nob={l:688135,m:819600,h:592},Oob={l:589832,m:1212704,h:592},Pob={l:589832,m:1212752,h:592},Qob={l:688136,m:1212752,h:592},Rob={l:589831,m:688464,h:656},Sob={l:589826,m:590112,h:8480},Tob={l:589826,m:688416,h:8480},Uob={l:589826,m:688464,h:8480},Vob={l:688130,m:688464,h:8480},Wob={l:819202,m:819600,h:8480},Xob={l:688135,m:1212752,h:8480},Yob={l:589832,m:1213008,h:8480},Zob={l:688136,m:1213008,h:8480},$ob={l:589826,m:590112,h:8484},_ob={l:589826,m:590160,h:8484},apb={l:688130,m:598304,h:8484},bpb=0.6262000203132629,cpb=-1.3825000524520874,dpb=0.33169999718666077,epb=-1.4915000200271606,fpb=0.3540000021457672,gpb=0.38179999589920044,hpb=-0.6019999980926514,ipb=-0.7379999756813049,jpb='Atom-types are 64-bit numbers describing atoms and their near surrounding.',kpb='Recognized atom types and their contributions are:',lpb='Druglikeness predictor not properly initialized.',mpb=3.009999990463257,npb=-0.17000000178813934,opb=-0.1809999942779541,ppb=0.004999999888241291,qpb=-0.2029999941587448,rpb='MMFF94',spb='MMFF94s',tpb='117\\nint,int,int,int,float\\n0,2,0,0,0.020\\n1,2,1,2,0.030\\n1,2,2,2,0.027\\n1,2,2,3,0.026\\n1,2,2,5,0.013\\n1,2,2,37,0.032\\n2,2,2,5,0.013\\n2,2,3,5,0.012\\n2,2,5,5,0.006\\n2,2,5,6,0.027\\n2,2,5,37,0.017\\n2,2,5,40,0.012\\n2,2,5,41,0.008\\n0,3,0,0,0.130\\n1,3,1,7,0.146\\n1,3,2,7,0.138\\n1,3,3,7,0.134\\n1,3,5,7,0.122\\n1,3,6,7,0.141\\n1,3,7,10,0.129\\n1,3,7,37,0.138\\n2,3,5,7,0.113\\n2,3,5,9,0.081\\n2,3,6,7,0.127\\n2,3,7,10,0.116\\n3,3,5,7,0.113\\n3,3,6,7,0.127\\n5,3,5,7,0.103\\n5,3,5,9,0.074\\n5,3,5,54,0.078\\n5,3,6,7,0.119\\n5,3,7,10,0.102\\n5,3,9,40,0.067\\n6,3,7,37,0.127\\n7,3,10,10,0.113\\n7,3,20,20,0.151\\n9,3,40,40,0.057\\n0,8,0,0,0.000\\n0,10,0,0,0.015\\n1,10,1,3,0.015\\n1,10,3,6,0.015\\n1,10,3,28,0.015\\n3,10,3,28,0.015\\n3,10,28,28,0.015\\n0,17,0,0,0.000\\n0,26,0,0,0.000\\n0,30,0,0,0.010\\n5,30,20,30,0.008\\n0,37,0,0,0.035\\n1,37,37,37,0.040\\n2,37,37,37,0.031\\n3,37,37,37,0.027\\n5,37,37,37,0.015\\n5,37,37,38,0.046\\n5,37,37,63,0.008\\n5,37,37,64,0.012\\n5,37,37,69,0.016\\n5,37,38,38,0.084\\n6,37,37,37,0.048\\n15,37,37,37,0.025\\n37,37,37,40,0.046\\n0,39,0,0,0.020\\n1,39,63,63,0.012\\n23,39,63,63,-0.014\\n23,39,63,65,0.021\\n23,39,65,65,0.062\\n0,40,0,0,0.030\\n1,40,28,37,0.030\\n2,40,28,28,0.030\\n3,40,28,28,0.030\\n28,40,28,37,0.030\\n0,41,0,0,0.180\\n1,41,32,32,0.178\\n2,41,32,32,0.161\\n5,41,32,32,0.158\\n0,43,0,0,0.000\\n0,45,0,0,0.150\\n0,49,0,0,0.000\\n50,49,50,50,0.000\\n0,54,0,0,0.020\\n1,54,3,36,0.016\\n3,54,36,36,0.018\\n0,55,0,0,0.020\\n1,55,36,57,0.020\\n36,55,36,57,0.020\\n0,56,0,0,0.020\\n1,56,36,57,0.020\\n36,56,36,57,0.020\\n0,57,0,0,0.080\\n5,57,55,55,0.038\\n56,57,56,56,0.158\\n0,58,0,0,0.025\\n0,63,0,0,0.050\\n5,63,39,64,0.019\\n5,63,39,66,0.068\\n5,63,44,64,0.014\\n5,63,44,66,0.055\\n5,63,59,64,0.033\\n5,63,59,66,0.085\\n37,63,39,64,0.010\\n0,64,0,0,0.040\\n5,64,63,64,0.006\\n5,64,63,66,0.043\\n5,64,64,65,0.052\\n5,64,65,66,0.094\\n37,64,63,64,-0.01\\n0,67,0,0,0.070\\n0,69,0,0,0.070\\n32,69,37,37,0.067\\n0,73,0,0,0.000\\n0,78,0,0,0.045\\n5,78,78,81,0.046\\n0,80,0,0,0.080\\n5,80,81,81,0.057\\n0,81,0,0,0.025\\n36,81,78,80,0.016\\n0,82,0,0,0.000\\n',upb='undefined',vpb=0.08726646502812703,wpb=0.003921568859368563,xpb='Too many percent/per mille characters in pattern \"',ypb=1048575,zpb=4194304,Apb=17592186044416,Bpb=1000000000,Cpb=-17592186044416,Dpb='CSS1Compat',Epb=5.56,Fpb=11.12,Gpb=13.34,Hpb=14.44,Ipb=0.3010299956639812,Jpb='BigInteger divide by zero',Kpb=4294967295,Lpb={l:0,m:0,h:524288},Mpb={27:1,80:1},Npb={94:1},Opb={36:1,37:1,45:1,78:1},Ppb='delete',Qpb=15525485,Rpb=5.9604644775390625E-8,Spb={4:1,27:1,57:1,62:1},Tpb='Invalid UTF8 sequence',Upb=0.20000000298023224,Vpb={43:1};var Uhb={};var Vhb={};var Whb={};var Xhb={};var Yhb={};var Zhb={};var $hb={};var _hb={};var aib={};var bib={};var cib={};var dib={};var eib={};var fib={};var gib={};var hib={};var iib={};var jib={};var kib={};var lib={};var mib={};var nib={};var oib={};var pib={};var qib={};var rib={};var sib={};var tib={};var uib={};var vib={};var wib={};var xib={};var yib={};var zib={};var Aib={};var Bib={};var Cib={};var _;var s_;var m_;var B$=-1;Uhb.C$=function C$(){};function r_(a,b){typeof window===Dib&&typeof window['$gwt']===Dib&&(window['$gwt'][a]=b)}\nfunction q_(b,c,d,e){Uhb.p_();var f=m_;$moduleName=c;$moduleBase=d;B$=e;function g(){for(var a=0;a=0;d--){if(Vhb.F2(a[d].d,b)||Vhb.F2(a[d].d,c)){a.length>=d+1&&Yhb.peb(a).splice(0,d+1);break}}return a};Xhb.US=function US(a){var b=/function(?:\\s+([\\w$]+))?\\s*\\(/;var c=b.exec(a);return c&&c[1]||Eib};Xhb.VS=function VS(a){Xhb.QS();return a&&a[Fib]?a[Fib]:[]};Xhb.WS=function WS(a){Xhb.QS();return a.name||(a.name=Xhb.US(a.toString()))};Xhb.XS=function XS(a){Xhb.QS();return parseInt(a)||-1};Xhb.YS=function YS(a){Xhb.QS();var b=a.backingJsObject;if(b&&b.stack){var c=b.stack;var d=b+Gib;c.substring(0,d.length)==d&&(c=c.substring(d.length));return c.split(Gib)}return []};Xhb.ZS=function ZS(){if(Error.stackTraceLimit>0){$wnd.Error.stackTraceLimit=Error.stackTraceLimit=64;return true}return 'stack' in new Error};v_(314,1,{});Xhb.$S=function $S(){};v_(225,314,{},Xhb.$S);_.Qb=function _S(a){var b={};var c=[];a[Fib]=c;var d=arguments.callee.caller;while(d){var e=Xhb.WS(d);c.push(e);var f=':'+e;var g=b[f];if(g){var h,i;for(h=0,i=g.length;h1?(b.c=Vhb.c1(this,a-1)):(b.c=this);return b};_.Ub=function b1(){Vhb.T0(this);return this.b};_.Vb=function d1(){return Vhb.U0(this)};_.Wb=function f1(){Vhb.T0(this);return this.j};_.Xb=function h1(){return Vhb.V0(this)};_.Yb=function i1(){return Vhb.W0(this)};_.lb=function l1(){return ((this.f&2)!=0?'interface ':(this.f&1)!=0?'':'class ')+(Vhb.T0(this),this.n)};_.f=0;_.i=0;var R0=1;Vhb.p1=function p1(a){return Vhb.F2(Kib,typeof(a))||dV(a,$wnd.java.lang.Number$impl)};Vhb.q1=function q1(a){Vhb.o1==null&&(Vhb.o1=new RegExp('^\\\\s*[+-]?(NaN|Infinity|((\\\\d+\\\\.?\\\\d*)|(\\\\.\\\\d+))([eE][+-]?\\\\d+)?[dDfF]?)\\\\s*$'));if(!Vhb.o1.test(a)){throw F$(new Vhb.u2(Nib+a+'\"'))}return parseFloat(a)};Vhb.r1=function r1(a,b,c){var d,e,f,g,h;if(a==null){throw F$(new Vhb.u2(Oib))}f=Yhb.peb(a).length;g=f>0&&(Yhb.keb(0,Yhb.peb(a).length),Yhb.peb(a).charCodeAt(0)==45||(Yhb.keb(0,Yhb.peb(a).length),Yhb.peb(a).charCodeAt(0)==43))?1:0;for(d=g;dc){throw F$(new Vhb.u2(Nib+a+'\"'))}return h};Vhb.s1=function s1(a){return bV(a)?Vhb.w1(a):a.Zb()};Vhb.t1=function t1(a){return bV(a)?Vhb.A1(a):a.$b()};v_(90,1,{4:1,90:1});Vhb.u1=function u1(a,b){return C1(Yhb.reb((Yhb.eeb(a),a)),Yhb.reb((Yhb.eeb(b),b)))};Vhb.v1=function v1(a,b){return Vhb.u1(a,b)};Vhb.w1=function w1(a){return Yhb.reb((Yhb.eeb(a),a))};Vhb.x1=function x1(a,b){return Yhb.eeb(a),hV(a)===hV(b)};Vhb.y1=function y1(){return Uhb.AY};Vhb.z1=function z1(a){return iV(Yhb.reb((Yhb.eeb(a),a)))};Vhb.A1=function A1(a){return iV(Yhb.reb((Yhb.eeb(a),a)))};function B1(a){return Vhb.F2(Kib,typeof(a))}\nfunction C1(a,b){if(ab){return 1}if(a==b){return a==0?C1(1/a,1/b):0}return isNaN(a)?isNaN(b)?0:1:-1}\nfunction D1(a){if(isNaN(a)){return {l:0,m:0,h:524160}}return Yhb.leb(a)}\nXU={4:1,27:1,223:1,90:1};Vhb.Ay=function Ay(a){a.g=VT(Uhb.PY,Hib,64,0,0,1)};Vhb.By=function By(a){Xhb.RS(a)};Vhb.Cy=function Cy(a){return Xhb.SS(a)};Vhb.Dy=function Dy(a){if(a.j){a.backingJsObject!==Pib&&a.Gb();a.g=null}return a};Vhb.Ey=function Ey(a){return a.e};Vhb.Fy=function Fy(d,b){if(b instanceof Object){try{b.__java$exception=d;if(navigator.userAgent.toLowerCase().indexOf('msie')!=-1&&$doc.documentMode<9){return}var c=d;Object.defineProperties(b,{cause:{get:function(){var a=c.Eb();return a&&a.Cb()}},suppressed:{get:function(){return c.Db()}}})}catch(a){}}};Vhb.Gy=function Gy(a,b,c){var d,e,f,g,h;String.fromCharCode(10);Vhb.Hy(a);for(e=(a.i==null&&(a.i=VT(Uhb.UY,Hib,22,0,0,1)),a.i),f=0,g=e.length;f0){e=i.length;while(e>0&&i[e-1]==''){--e}ed&&(Yhb.keb(b-1,Yhb.peb(a).length),Yhb.peb(a).charCodeAt(b-1)<=32)){--b}return d>0||b=Tib){b=55296+(a-Tib>>10&1023)&Uib;c=56320+(a-Tib&1023)&Uib;return String.fromCharCode(b)+(''+String.fromCharCode(c))}else{return String.fromCharCode(a&Uib)}}\nVhb.X2=function X2(a){var b;b=0;while(0<=(b=Yhb.peb(a).indexOf('\\\\',b))){Yhb.keb(b+1,Yhb.peb(a).length);Yhb.peb(a).charCodeAt(b+1)==36?(a=(Yhb.jeb(0,b,Yhb.peb(a).length),Yhb.peb(a).substr(0,b)+'$'+Vhb.R2(a,++b))):(a=(Yhb.jeb(0,b,Yhb.peb(a).length),Yhb.peb(a).substr(0,b)+(''+Vhb.R2(a,++b))))}return a};Vhb.Y2=function Y2(a){return Vhb.Z2(a,0,a.length)};Vhb.Z2=function Z2(a,b,c){var d,e,f,g;f=b+c;Yhb.jeb(b,f,a.length);g='';for(e=b;ea){throw F$(new Vhb.G1('fromIndex: 0 > toIndex: '+a))}if(a>b){throw F$(new Vhb.l0('fromIndex: 0, toIndex: '+a+Wib+b))}};Yhb.aeb=function aeb(a){if(a<0){throw F$(new Vhb.p2('Negative array size: '+a))}};Yhb.beb=function beb(a,b){if(a!=b){throw F$(new _hb.iab)}};Yhb.ceb=function ceb(a){if(!a){throw F$(new _hb.nbb)}};Yhb.deb=function deb(a,b){if(a<0||a>=b){throw F$(new Vhb.j0(Xib+a+Yib+b))}};Yhb.eeb=function eeb(a){if(a==null){throw F$(new Vhb.q2)}return a};Yhb.feb=function feb(a,b){if(a==null){throw F$(new Vhb.s2(b))}};Yhb.geb=function geb(a,b){if(a<0||a>b){throw F$(new Vhb.j0(Xib+a+Yib+b))}};Yhb.heb=function heb(a,b,c){if(a<0||b>c){throw F$(new Vhb.j0(Zib+a+$ib+b+', size: '+c))}if(a>b){throw F$(new Vhb.G1(Zib+a+' > toIndex: '+b))}};Yhb.ieb=function ieb(a){if(!a){throw F$(new Vhb.H1)}};Yhb.jeb=function jeb(a,b,c){if(a<0||b>c||b=b){throw F$(new Vhb.o3(Xib+a+Yib+b))}};Yhb.leb=function leb(a){var b,c;b=new ArrayBuffer(8);Yhb.peb(new Float64Array(b))[0]=a;c=Yhb.peb(new Uint32Array(b));return Yhb.seb(c[0]|0,c[1]|0)};Yhb.meb=function meb(a,b){return a[b]};Yhb.neb=function neb(a){return a===undefined};Yhb.oeb=function oeb(a){return a>>>0};Yhb.peb=function peb(a){return a};Yhb.qeb=function qeb(a){return a};Yhb.reb=function reb(a){return a};v_(313,1,{});Uhb.NY=$0(1);Uhb.ZX=$0(0);Uhb.eY=$0(314);Uhb.bY=$0(225);Uhb.dY=$0(315);Uhb.cY=$0(226);Uhb.xY=$0(222);Uhb.zY=$0(152);Uhb.MY=$0(90);Uhb.AY=$0(223);Uhb.UY=$0(22);Uhb.CY=$0(15);Uhb.OY=$0(41);Uhb.FY=$0(66);Uhb.HY=$0(95);Uhb.KY=$0(61);Uhb.TY=$0(2);Uhb.SY=$0(172);Uhb._Z=$0(312);Uhb.a$=$0(313);Zhb.Gc=function Gc(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I,J,K,L,M,N,O,P,Q;this.c=a.length;this.d=a[0].length;G=$wnd.Math.min(this.c,this.d);this.e=VT(Uhb.lV,_ib,6,$wnd.Math.min(this.c+1,this.d),15,1);this.a=TT(Uhb.lV,[Hib,_ib],[11,6],15,[this.c,G],2);this.b=TT(Uhb.lV,[Hib,_ib],[11,6],15,[this.d,this.d],2);e=VT(Uhb.lV,_ib,6,this.d,15,1);Q=VT(Uhb.lV,_ib,6,this.c,15,1);D=$wnd.Math.min(this.c-1,this.d);F=$wnd.Math.max(0,$wnd.Math.min(this.d-2,this.c));for(v=0;v<$wnd.Math.max(D,F);v++){if(v=0;w--){if(this.e[w]!=0){for(p=w+1;p=0;A--){if(A0){for(u=H-2;u>=-1;u--){if(u==-1){break}if($wnd.Math.abs(e[u])<=h*($wnd.Math.abs(this.e[u])+$wnd.Math.abs(this.e[u+1]))){e[u]=0;break}}if(u==H-2){B=4}else{for(C=H-1;C>=u;C--){if(C==u){break}P=(C!=H?$wnd.Math.abs(e[C]):0)+(C!=u+1?$wnd.Math.abs(e[C-1]):0);if($wnd.Math.abs(this.e[C])<=h*P){this.e[C]=0;break}}if(C==u){B=3}else if(C==H-1){B=1}else{B=2;u=C}}++u;switch(B){case 1:{i=e[H-2];e[H-2]=0;for(p=H-2;p>=u;p--){P=Zhb.Hc(this.e[p],i);d=this.e[p]/P;M=i/P;this.e[p]=P;if(p!=u){i=-M*e[p-1];e[p-1]=d*e[p-1]}for(k=0;k=this.e[u+1]){break}P=this.e[u];this.e[u]=this.e[u+1];this.e[u+1]=P;if(u$wnd.Math.abs(b)){c=b/a;c=$wnd.Math.abs(a)*$wnd.Math.sqrt(1+c*c)}else if(b!=0){c=a/b;c=$wnd.Math.abs(b)*$wnd.Math.sqrt(1+c*c)}else{c=0}return c};v_(123,1,ajb,Zhb.Gc);_.c=0;_.d=0;Uhb.pV=$0(123);$hb.Jc=function Jc(){$hb.Jc=x_;$hb.Ic=bU(PT(Uhb.nV,1),bjb,6,15,[0,cjb,14286847,13402367,12779264,16758197,9474192,3166456,16715021,9494608,11789301,11230450,9109248,12560038,15780000,16744448,16777008,2093087,8442339,9388244,4062976,15132390,12567239,10921643,9083335,10255047,14706227,15765664,5296208,13140019,8224944,12750735,6721423,12419299,16752896,10889513,6076625,7351984,djb,9764863,9756896,7586505,5551541,3907230,2396047,687500,27013,12632256,16767375,10909043,6717568,10380213,13924864,9699476,4366000,5707663,51456,7394559,16777159,14286791,13107143,10747847,9437127,6422471,4587463,3211207,2097095,65436,58997,54354,48952,43812,5096191,5089023,2200790,2522539,2516630,1528967,13684960,16765219,12105936,10900557,5724513,10375093,11230208,7688005,4358806,4325478,32000,7384058,47871,41471,36863,33023,27647,5528818,7888099,9064419,10565332,11739092,11739066,11734438,12389767,13041766,13369433,13697103,14221381,14680120,15073326,15400998,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,13158600,1334015,56540,15075850,15132160,56540,15075850,15461355,8553170,1016335,1016335,1334015,15132160,3289770,14456450,16422400,16422400,11819700,3289770,1016335])};$hb.Kc=function Kc(a){a.t=new lib.XE};$hb.Lc=function Lc(a){var b,c;if((a.C&32)!=0)return;c=$hb.st(a.I);if(c!=null){if(a.u.a==0&&a.u.b==0){b=a.O.c*$hb.lk(a.I);a.t=$hb.Fd(a);$hb.Vc(a,b);$hb.Cd(a,null,b,0)}$hb.ls(a,iV(a.v));a.I.O!=1&&$hb.Dd(a,448);$hb.fs(a,c,a.u.a,a.u.b+ejb*a.v)}};$hb.Mc=function Mc(a,b){return a==null?b:b==null?a:a+','+b};$hb.Nc=function Nc(a){var b;b=a.O.c*$hb.lk(a.I);a.V=b*0.06;a.Q=b*0.15;a.P=b*0.38;a.T=b*0.47;a.U=iV(b*a.G*0.6+0.5);a.S=b*0.12;a.W=b*0.4;a.v=b*0.5+0.5};$hb.Oc=function Oc(a){var b,c;a=H$(a,fjb);for(c=0;c<(kib.NE(),kib.ME).length;c++)if(R$(a,kib.ME[c]))return kib.LE[c];b=new Vhb.n3('R');a_(H$(a,gjb),0)&&(b.a+='0',b);a_(H$(a,hjb),0)&&(b.a+='3',b);a_(H$(a,ijb),0)&&(b.a+='4',b);a_(H$(a,jjb),0)&&(b.a+='5',b);a_(H$(a,kjb),0)&&(b.a+='6',b);a_(H$(a,ljb),0)&&(b.a+='7',b);a_(H$(a,mjb),0)&&(b.a+='8',b);return b.a};$hb.Pc=function Pc(a,b,c,d){var e,f,g;e=new $hb.Ld;f=new $hb.Ld;e.a=b.a;e.c=b.c;e.b=(b.a+b.b)/2;e.d=(b.c+b.d)/2;f.a=e.b;f.c=e.d;f.b=b.b;f.d=b.d;if($hb.zd(a,e)){$hb.Dd(a,a.o[c]);g=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.a),(xib.J5(),xib.F5))))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,g)}if($hb.zd(a,f)){$hb.Dd(a,a.o[d]);g=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(f.a),(xib.J5(),xib.F5))))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(f.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(f.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(f.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,g)}$hb.Dd(a,a.N)};$hb.Qc=function Qc(a,b,c,d){var e,f,g,h,i,j,k,l,m;l=(b.b-b.a)/10;m=(b.d-b.c)/10;e=new $hb.Ld;if($hb.Uk(a.I,$hb.en(a.I,c,d))){f=-3;g=-3}else{f=a.o[c];g=a.o[d]}$hb.Dd(a,f);e.a=b.a;e.c=b.c;e.b=b.a+l*2;e.d=b.c+m*2;i=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.a),(xib.J5(),xib.F5))))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,i);e.a=b.a+l*4;e.c=b.c+m*4;e.b=b.a+l*5;e.d=b.c+m*5;j=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.a),xib.F5)))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,j);$hb.Dd(a,g);e.a=b.a+l*5;e.c=b.c+m*5;e.b=b.a+l*6;e.d=b.c+m*6;k=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.a),xib.F5)))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,k);e.a=b.a+l*8;e.c=b.c+m*8;e.b=b.b;e.d=b.d;h=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.a),xib.F5)))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(e.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,h);$hb.Dd(a,a.N)};$hb.Rc=function Rc(a,b,c){$hb.gs(a,b-a.S/2,c-a.S/2,a.S)};$hb.Sc=function Sc(a,b,c,d){var e;if($hb.Uk(a.I,$hb.en(a.I,c,d))){$hb.Dd(a,-3);e=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.a),(xib.J5(),xib.F5))))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,e);$hb.Dd(a,a.N)}else if(a.o[c]!=a.o[d]){$hb.Pc(a,b,c,d)}else if(a.o[c]!=0){$hb.Dd(a,a.o[c]);e=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.a),(xib.J5(),xib.F5))))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,e);$hb.Dd(a,a.N)}else{e=njb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.a),(xib.J5(),xib.F5))))+ojb+pjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.c),xib.F5)))+ojb+qjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.b),xib.F5)))+ojb+rjb+Vhb.q1(xib.K3(xib.H3(new xib.L3(b.d),xib.F5)))+ojb+sjb+a.d+ojb+tjb+a.i+ujb;$hb.os(a,e)}};$hb.Tc=function Tc(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;l=b.b-b.a;o=b.d-b.c;i=$wnd.Math.sqrt(l*l+o*o);j=2*j_(S$($wnd.Math.round(i/(4*a.V))));m=l/(j-1);p=o/(j-1);if($hb.Uk(a.I,$hb.en(a.I,c,d))){e=-3;f=-3}else{e=a.o[c];f=a.o[d]}k=b.a-a.V/2;n=b.c-a.V/2;$hb.Dd(a,e);for(h=0;h<(j/2|0);h++){$hb.gs(a,k,n,a.V);k+=m;n+=p}$hb.Dd(a,f);for(g=0;g<(j/2|0);g++){$hb.gs(a,k,n,a.V);k+=m;n+=p}$hb.Dd(a,a.N)};$hb.Uc=function Uc(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r;i=(b.c-b.d)/9;n=(b.b-b.a)/9;j=b.b+i;o=b.d+n;k=b.b-i;p=b.d-n;l=(b.a+j)/2;q=(b.c+o)/2;m=(b.a+k)/2;r=(b.c+p)/2;g=new lib.SE(3);h=new lib.SE(4);lib.RE(g,b.a,b.c);lib.RE(g,l,q);lib.RE(g,m,r);lib.RE(h,m,r);lib.RE(h,l,q);lib.RE(h,j,o);lib.RE(h,k,p);if($hb.Uk(a.I,$hb.en(a.I,c,d))){e=-3;f=-3}else{e=a.o[c];f=a.o[d];if(a.I.O!=1){f=$hb.Yc(a,c);e==$hb.Wj(a.I,c)&&(e=f)}}$hb.Dd(a,e);$hb.es(a,g);$hb.Dd(a,f);$hb.es(a,h);$hb.Dd(a,a.N)};$hb.Vc=function Vc(a,b){var c,d;for(d=0;d0?(f=xjb):(f=yjb);o=$hb.ok(a.I,b,c);for(k=0;k<$hb.hn(a.I,b);k++){g=$hb.jn(a.I,b,k);h=o;$hb.pk(a.I,0,g)==b?(l=$hb.pk(a.I,1,g)):(l=$hb.pk(a.I,0,g));if(l==c)continue;n=$hb.ok(a.I,b,l);h0){ixjb&&(i=xjb);i<0.523598776&&(i=0.523598776);if(i<=f){f=i;j=a.Q*$wnd.Math.tan(f-Bjb)/2;e.a=-(j*$wnd.Math.sin(h));e.b=-(j*$wnd.Math.cos(h))}}else{i>=Ajb&&(m=true);i5.759586531&&(i=5.759586531);if(i>=f){f=i;j=a.Q*$wnd.Math.tan(4.712388981-f)/2;e.a=-(j*$wnd.Math.sin(h));e.b=-(j*$wnd.Math.cos(h))}}}return m};$hb.gd=function gd(a,b,c,d){var e;if(b==0){c<0?(d.a=a.Q):(d.a=-a.Q);d.b=0;return}e=$wnd.Math.atan(c/b);b<0&&(e+=Ajb);d.a=-(a.Q*$wnd.Math.sin(e));d.b=a.Q*$wnd.Math.cos(e)};$hb.hd=function hd(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p;e=new $hb.Ld;i=new $hb.Ld;k=new lib.OE;j=new lib.OE;g=$hb.pk(a.I,0,c);h=$hb.pk(a.I,1,c);if(d){m=b.a;b.a=b.b;b.b=m;m=b.c;b.c=b.d;b.d=m;n=g;g=h;h=n}if(!$hb.zd(a,b))return;if($hb.io(a.I,c)){e.a=b.a;e.c=b.c;e.b=b.b;e.d=b.d;l=d?-$hb.yd(a,c):$hb.yd(a,c);l==0&&(l=1);$hb.gd(a,b.b-b.a,b.d-b.c,k);if(l>0){i.a=b.a+k.a;i.c=b.c+k.b;i.b=b.b+k.a;i.d=b.d+k.b;if($hb.fd(a,g,h,1,j)||$hb.hn(a.I,g)>1){i.a+=j.a+k.b;i.c+=j.b-k.a}}else{i.a=b.a-k.a;i.c=b.c-k.b;i.b=b.b-k.a;i.d=b.d-k.b;if($hb.fd(a,g,h,-1,j)||$hb.hn(a.I,g)>1){i.a+=j.a+k.b;i.c+=j.b-k.a}}$hb.Ak(a.I,c)==26&&$hb.xd(e,i);$hb.zd(a,e)&&$hb.Sc(a,e,g,h);$hb.Ak(a.I,c)==64?$hb.zd(a,i)&&$hb.Qc(a,i,g,h):$hb.zd(a,i)&&$hb.Sc(a,i,g,h)}else{$hb.gd(a,b.b-b.a,b.d-b.c,k);o=k.a/2;p=k.b/2;f=false;e.a=b.a+o;e.c=b.c+p;e.b=b.b+o;e.d=b.d+p;if($hb.hn(a.I,g)>1){if($hb.fd(a,g,h,1,j)){e.a+=j.a;e.c+=j.b;if($hb.hn(a.I,g)==2){if(j.a!=0||j.b!=0){e.a+=k.b;e.c-=k.a}}}else{a.n[g]=new lib.PE(e.a,e.c)}}i.a=b.a-o;i.c=b.c-p;i.b=b.b-o;i.d=b.d-p;if($hb.hn(a.I,g)>1){if($hb.fd(a,g,h,0,j)){i.a+=j.a;i.c+=j.b;if($hb.hn(a.I,g)==2){if(j.a!=0||j.b!=0){i.a+=k.b;i.c-=k.a}}}else{a.n[g]=new lib.PE(i.a,i.c);f=true}}$hb.Ak(a.I,c)==26&&$hb.xd(e,i);if($hb.Ak(a.I,c)==64){if(f){$hb.Qc(a,e,g,h);$hb.Sc(a,i,g,h)}else{$hb.Sc(a,e,g,h);$hb.Qc(a,i,g,h)}}else{$hb.Sc(a,e,g,h);$hb.Sc(a,i,g,h)}}};$hb.jd=function jd(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o;k=a.N;l=a.B;if((a.C&Cjb)!=0){a.N=-6;a.B=-8355712;$hb.Dd(a,1)}a.n=VT(Uhb.AX,Qib,48,a.I.q,0,1);for(i=0;i1)&&($hb.sk(a.I,h)==1?(e=$hb.xk(a.I,h)==2?'E':$hb.Wk(a.I,h)?'p':'P'):(e=$hb.xk(a.I,h)==2?'Z':$hb.Wk(a.I,h)?'m':'M')):(e='?');if(e!=null){$hb.ls(a,(a.U*2+1)/3|0);$hb.Dd(a,$hb.Uk(a.I,h)?-3:a.I.O==1||(a.C&Djb)!=0?a.N:448);c=$hb.pk(a.I,0,h);d=$hb.pk(a.I,1,h);n=($hb.Ch(a.O,$hb.hk(a.I,c))+$hb.Ch(a.O,$hb.hk(a.I,d)))/2;o=($hb.Dh(a.O,$hb.ik(a.I,c))+$hb.Dh(a.O,$hb.ik(a.I,d)))/2;f=($hb.Ch(a.O,$hb.hk(a.I,c))-$hb.Ch(a.O,$hb.hk(a.I,d)))/3;g=($hb.Dh(a.O,$hb.ik(a.I,c))-$hb.Dh(a.O,$hb.ik(a.I,d)))/3;$hb.pd(a,n+g,o-f,e,true);$hb.Dd(a,a.N);$hb.ls(a,a.U)}}}}if((a.C&4)!=0){$hb.ls(a,(a.U*2+1)/3|0);$hb.Dd(a,384);for(h=0;h0':D+','+'h>0'):M$(w,384)==0?(D=D==null?'h>1':D+','+'h>1'):M$(w,896)==0?(D=D==null?'h>2':D+','+'h>2'):M$(w,Hjb)==0?(D=D==null?'h<3':D+','+'h<3'):M$(w,1536)==0&&(D=D==null?'h<2':D+','+'h<2')}if(a_(H$(N,Ijb),0)){i=H$(N,Ijb);M$(i,Jjb)==0?(D=D==null?'c0':D+','+'c0'):M$(i,Kjb)==0?(D=D==null?'c+':D+','+'c+'):M$(i,Ljb)==0&&(D=D==null?'c-':D+','+'c-')}if(a_(H$(N,Mjb),0)){L=H$(N,Mjb);M$(L,98304)==0?(D=D==null?'pi0':D+','+'pi0'):M$(L,81920)==0?(D=D==null?'pi1':D+','+'pi1'):M$(L,49152)==0?(D=D==null?'pi2':D+','+'pi2'):M$(L,Cjb)==0&&(D=D==null?'pi>0':D+','+'pi>0')}if(a_(H$(N,Njb),0)){K=H$(N,Njb);M$(K,3801088)==0?(D=D==null?'n1':D+','+'n1'):M$(K,Ojb)==0?(D=D==null?'n2':D+','+'n2'):M$(K,Pjb)==0?(D=D==null?'n3':D+','+'n3'):M$(K,3145728)==0?(D=D==null?'n<3':D+','+'n<3'):M$(K,Qjb)==0?(D=D==null?'n<4':D+','+'n<4'):M$(K,Rjb)==0?(D=D==null?'n>1':D+','+'n>1'):M$(K,917504)==0?(D=D==null?'n>2':D+','+'n>2'):M$(K,Sjb)==0&&(D=D==null?'n>3':D+','+'n>3')}if(a_(H$(N,Tjb),0)){o=H$(N,Tjb);M$(o,Ujb)==0?(D=D==null?'e0':D+','+'e0'):M$(o,Vjb)==0?(D=D==null?'e1':D+','+'e1'):M$(o,Wjb)==0?(D=D==null?'e2':D+','+'e2'):M$(o,Xjb)==0?(D=D==null?'e3':D+','+'e3'):M$(o,15393162788864)==0?(D=D==null?'e<2':D+','+'e<2'):M$(o,13194139533312)==0?(D=D==null?'e<3':D+','+'e<3'):M$(o,Yjb)==0?(D=D==null?'e<4':D+','+'e<4'):M$(o,Zjb)==0?(D=D==null?'e>0':D+','+'e>0'):M$(o,$jb)==0?(D=D==null?'e>1':D+','+'e>1'):M$(o,_jb)==0?(D=D==null?'e>2':D+','+'e>2'):M$(o,akb)==0&&(D=D==null?'e>3':D+','+'e>3')}if(a_(H$(N,120),0)){Q=H$(N,120);M$(Q,112)==0?(D=D==null?'!r':D+','+'!r'):M$(Q,8)==0?(D=D==null?'r':D+','+'r'):M$(Q,96)==0?(D=D==null?'rb<3':D+','+'rb<3'):M$(Q,104)==0?(D=D==null?'rb2':D+','+'rb2'):M$(Q,88)==0?(D=D==null?'rb3':D+','+'rb3'):M$(Q,56)==0&&(D=D==null?'rb4':D+','+'rb4')}a_(H$(N,bkb),0)&&(D=D==null?'r'+k_(e_(H$(N,bkb),22)):D+','+('r'+k_(e_(H$(N,bkb),22))));a_(H$(N,fjb),0)&&(D=$hb.Mc(D,$hb.Oc(N)));a_(H$(N,ckb),0)&&(D=D==null?'f':D+','+'f')}$hb.dk(a.I,b)!=0&&(D=$hb.Mc(D,''+$hb.dk(a.I,b)));T=0;if($hb.gk(a.I,b)!=0){switch($hb.gk(a.I,b)){case 16:M=M==null?'|':M+','+'|';break;case 32:T=1;break;case 48:T=2;}}l=null;if((a.C&64)==0){if($hb.Nk(a.I,b))l='?';else if($hb.Uj(a.I,b)!=0){if($hb.$j(a.I,b)==0||c==null||c[$hb.$j(a.I,b)][$hb.Zj(a.I,b)]>1){if($hb.hn(a.I,b)==2){switch($hb.Uj(a.I,b)){case 2:l=$hb.Pk(a.I,b)?'p':'P';break;case 1:l=$hb.Pk(a.I,b)?'m':'M';break;default:l='*';}}else{switch($hb.Uj(a.I,b)){case 1:l=$hb.Pk(a.I,b)?'r':'R';break;case 2:l=$hb.Pk(a.I,b)?'s':'S';break;default:l='*';}}}}}(a.C&1792)!=0&&(l=$hb.Mc(l,''+$hb.At(a.I,b)));I=null;(a.C&16)!=0&&$hb.ck(a.I,b)!=0&&(I=''+$hb.ck(a.I,b));q=null;if($hb.Mn(a.I,b)!=-1){p=$hb.Zc(a,b);p!=-1&&(q=p==0?'abs':((p&255)==1?'&':'or')+(1+(p>>8)))}A=0;(a.C&dkb)==0&&(a.I.K?a_(H$($hb.fk(a.I,b),ekb),0)&&(A=$hb.wn(a.I,b)):($hb.kk(a.I,b)!=6||$hb.dk(a.I,b)!=0||!a.p[b]||$hb.gk(a.I,b)!=0)&&(A=$hb.wn(a.I,b)));H=false;f=$hb.Xj(a.I,b);if(f!=null&&Vhb.F2(Yhb.peb(f).substr(0,1),']')){D=$hb.Mc((Yhb.keb(1,Yhb.peb(f).length+1),Yhb.peb(f).substr(1)),D);f=null;H=true}if(f!=null){A=0}else if($hb.ak(a.I,b)!=null){e=a_(H$($hb.fk(a.I,b),1),0)?'[!':'[';f=e+$hb.bk(a.I,b)+']';Yhb.peb(f).length>5&&(f=e+$hb.ak(a.I,b).length+']');a_(H$($hb.fk(a.I,b),ekb),0)&&(A=-1)}else if(a_(H$($hb.fk(a.I,b),1),0)){f='?';a_(H$($hb.fk(a.I,b),ekb),0)&&(A=-1)}else ($hb.kk(a.I,b)!=6||M!=null||D!=null||A>0||!a.p[b])&&(f=$hb._j(a.I,b));G=0;!$hb.dl(a.I,b)&a_(H$($hb.fk(a.I,b),wjb),0)&&$hb.Dd(a,-8);if(f!=null){G=(O=(V=uib.K_(a.e,f),new vib.R_(0,0,V,0)).b,O);$hb.pd(a,$hb.Ch(a.O,$hb.hk(a.I,b)),$hb.Dh(a.O,$hb.ik(a.I,b)),f,true);a.q[b]=true}else $hb.ed(a,b)&&$hb.od(a,$hb.Ch(a.O,$hb.hk(a.I,b)),$hb.Dh(a.O,$hb.ik(a.I,b)),b);if(M!=null){$hb.ls(a,(a.U*2+1)/3|0);X=$hb.Ch(a.O,$hb.hk(a.I,b))+((G+(O=(V=uib.K_(a.e,M),new vib.R_(0,0,V,0)).b,O))/2+1);Z=$hb.Dh(a.O,$hb.ik(a.I,b))-((a.j*4-4)/8|0);$hb.pd(a,X,Z,M,true);$hb.ls(a,a.U)}(a.C&2)!=0&&(D=''+b);if(D!=null){H?$hb.ls(a,(a.U*5+1)/6|0):$hb.ls(a,(a.U*2+1)/3|0);X=$hb.Ch(a.O,$hb.hk(a.I,b))-(G+(O=(V=uib.K_(a.e,D),new vib.R_(0,0,V,0)).b,O))/2;Z=$hb.Dh(a.O,$hb.ik(a.I,b))-((a.j*4-4)/8|0);$hb.pd(a,X,Z,D,true);$hb.ls(a,a.U)}if(l!=null){$hb.ls(a,(a.U*2+1)/3|0);X=$hb.Ch(a.O,$hb.hk(a.I,b))-(G+(O=(V=uib.K_(a.e,l),new vib.R_(0,0,V,0)).b,O))/2;Z=$hb.Dh(a.O,$hb.ik(a.I,b))+((a.j*4+4)/8|0);S=a.w;a.I.O!=1&&(a.C&Djb)==0&&$hb.Dd(a,448);$hb.pd(a,X,Z,l,false);$hb.Dd(a,S);$hb.ls(a,a.U)}if(I!=null){$hb.ls(a,(a.U*2+1)/3|0);X=$hb.Ch(a.O,$hb.hk(a.I,b))+((G+(O=(V=uib.K_(a.e,I),new vib.R_(0,0,V,0)).b,O))/2+1);Z=$hb.Dh(a.O,$hb.ik(a.I,b))+((a.j*4+4)/8|0);S=a.w;$hb.Dd(a,$hb.Rk(a.I,b)?384:448);$hb.pd(a,X,Z,I,true);$hb.Dd(a,S);$hb.ls(a,a.U)}if(q!=null){d=$hb.td(a,b);$hb.ls(a,(a.U*2+1)/3|0);X=$hb.Ch(a.O,$hb.hk(a.I,b))+0.7*a.j*$wnd.Math.sin(d);Z=$hb.Dh(a.O,$hb.ik(a.I,b))+0.7*a.j*$wnd.Math.cos(d);S=a.w;!a.H&&a.I.O!=1&&$hb.Dd(a,$hb.Yc(a,b));$hb.pd(a,X,Z,q,false);$hb.Dd(a,S);$hb.ls(a,a.U)}if(A==0&&T==0){a.w==-8&&$hb.Dd(a,-9);return}u=VT(Uhb.lV,_ib,6,4,15,1);for(C=0;C<$hb.Vm(a.I,b);C++){h=$hb.jn(a.I,b,C);for(F=0;F<2;F++){if($hb.pk(a.I,F,h)==b){R=$hb.ok(a.I,$hb.pk(a.I,F,h),$hb.pk(a.I,1-F,h));if(R1){s=''+A;$hb.ls(a,(a.U*2+1)/3|0);t=(O=(V=uib.K_(a.e,s),new vib.R_(0,0,V,0)).b,O)}if(u[1]<0.6||u[3]<0.6){k=$hb.Dh(a.O,$hb.ik(a.I,b));if(u[1]<=u[3]){u[1]+=10;j=$hb.Ch(a.O,$hb.hk(a.I,b))+(G+v)/2}else{u[3]+=10;j=$hb.Ch(a.O,$hb.hk(a.I,b))-(G+v)/2-t}}else{j=$hb.Ch(a.O,$hb.hk(a.I,b));if(u[0]0){X=j+(v+t)/2;Z=k+((a.j*4+4)/8|0);$hb.pd(a,X,Z,s,true);$hb.ls(a,a.U)}$hb.pd(a,j,k,'H',true)}g=0;if(T!=0){J=50;m=0;for(B=0;B<4;B++){n=B>1?B-2:B+2;if(u[B]m){g=B;m=u[n]}}}switch(g){case 0:j=$hb.Ch(a.O,$hb.hk(a.I,b));k=$hb.Dh(a.O,$hb.ik(a.I,b))-a.S-G/2;break;case 1:j=$hb.Ch(a.O,$hb.hk(a.I,b))+a.S+G/2;k=$hb.Dh(a.O,$hb.ik(a.I,b));break;case 2:j=$hb.Ch(a.O,$hb.hk(a.I,b));k=$hb.Dh(a.O,$hb.ik(a.I,b))+a.S+G/2;break;default:j=$hb.Ch(a.O,$hb.hk(a.I,b))-a.S-G/2;k=$hb.Dh(a.O,$hb.ik(a.I,b));}if(T==1){_hb.mi(a.X,new lib.YE(j-a.S,k-a.S,2*a.S,2*a.S));a.H||_hb.mi(a.R,new $hb.Kd(j,k,$hb.cd(a,b)?-3:a.o[b]))}else{switch(g){case 2:case 0:Y=2*a.S;$=0;j-=a.S;break;case 1:Y=0;$=2*a.S;k-=a.S;break;default:Y=0;$=2*a.S;k-=a.S;}_hb.mi(a.X,new lib.YE(j-a.S,k-a.S,2*a.S,2*a.S));a.H||_hb.mi(a.R,new $hb.Kd(j,k,$hb.cd(a,b)?-3:a.o[b]));_hb.mi(a.X,new lib.YE(j+Y-a.S,k+$-a.S,2*a.S,2*a.S));a.H||_hb.mi(a.R,new $hb.Kd(j+Y,k+$,$hb.cd(a,b)?-3:a.o[b]))}}a.w==-8&&$hb.Dd(a,-9)};\n$hb.md=function md(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w;u=new $hb.Ld;c=new $hb.Ld;g=new $hb.Ld;q=new lib.OE;p=new lib.OE;e=$hb.pk(a.I,0,b);f=$hb.pk(a.I,1,b);$hb.is(a,b,$hb.Ch(a.O,$hb.hk(a.I,e)),$hb.Dh(a.O,$hb.ik(a.I,e)),$hb.Ch(a.O,$hb.hk(a.I,f)),$hb.Dh(a.O,$hb.ik(a.I,f)));!$hb.dl(a.I,e)&&!$hb.dl(a.I,f)&&a_(H$(c_($hb.fk(a.I,e),$hb.fk(a.I,f)),wjb),0)&&$hb.Dd(a,-8);if(!a.n[e]){u.a=$hb.Ch(a.O,$hb.hk(a.I,e));u.c=$hb.Dh(a.O,$hb.ik(a.I,e))}else{u.a=a.n[e].a;u.c=a.n[e].b}if(!a.n[f]){u.b=$hb.Ch(a.O,$hb.hk(a.I,f));u.d=$hb.Dh(a.O,$hb.ik(a.I,f))}else{u.b=a.n[f].a;u.d=a.n[f].b}if(($hb.zk(a.I,b)&gkb)!=0){$hb.zd(a,u)&&(r='0){g.a=u.a+q.a;g.c=u.c+q.b;g.b=u.b+q.a;g.d=u.d+q.b;if($hb.fd(a,e,f,1,p)||$hb.hn(a.I,e)>1){g.a+=p.a+q.b;g.c+=p.b-q.a}if($hb.fd(a,f,e,-1,p)||$hb.hn(a.I,f)>1){g.b+=p.a-q.b;g.d+=p.b+q.a}}else{g.a=u.a-q.a;g.c=u.c-q.b;g.b=u.b-q.a;g.d=u.d-q.b;if($hb.fd(a,e,f,-1,p)||$hb.hn(a.I,e)>1){g.a+=p.a+q.b;g.c+=p.b-q.a}if($hb.fd(a,f,e,1,p)||$hb.hn(a.I,f)>1){g.b+=p.a-q.b;g.d+=p.b+q.a}}$hb.Ak(a.I,b)==26&&$hb.xd(c,g);$hb.zd(a,c)&&$hb.Sc(a,c,e,f);h==2?$hb.zd(a,g)&&$hb.Sc(a,g,e,f):$hb.zd(a,g)&&$hb.Qc(a,g,e,f)}break;case 3:if($hb.zd(a,u)){$hb.Sc(a,u,e,f);$hb.gd(a,u.b-u.a,u.d-u.c,q);c.a=u.a+q.a;c.c=u.c+q.b;c.b=u.b+q.a;c.d=u.d+q.b;$hb.Sc(a,c,e,f);c.a=u.a-q.a;c.c=u.c-q.b;c.b=u.b-q.a;c.d=u.d-q.b;$hb.Sc(a,c,e,f)}}a.w==-8&&$hb.Dd(a,-9)};$hb.nd=function nd(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;o=false;for(d=0;d>15;n!=0&&(j=(j==null?'':j)+n);if(j!=null){b=$hb.pk(a.I,0,d);c=$hb.pk(a.I,1,d);if(!o){$hb.ls(a,(a.U*2+1)/3|0);o=true}q=($hb.Ch(a.O,$hb.hk(a.I,b))+$hb.Ch(a.O,$hb.hk(a.I,c)))/2;r=($hb.Dh(a.O,$hb.ik(a.I,b))+$hb.Dh(a.O,$hb.ik(a.I,c)))/2;f=$hb.Ch(a.O,$hb.hk(a.I,c))-$hb.Ch(a.O,$hb.hk(a.I,b));g=$hb.Dh(a.O,$hb.ik(a.I,c))-$hb.Dh(a.O,$hb.ik(a.I,b));e=$wnd.Math.sqrt(f*f+g*g);i=(m=(p=uib.K_(a.e,j),new vib.R_(0,0,p,0)).b,0.6*m);h=0.55*a.j;e!=0&&(f>0?$hb.pd(a,q+i*g/e,r-h*f/e,j,true):$hb.pd(a,q-i*g/e,r+h*f/e,j,true))}}o&&$hb.ls(a,a.U)};$hb.od=function od(a,b,c,d){_hb.mi(a.X,new lib.YE(b-a.S,c-a.S,2*a.S,2*a.S));a.H||_hb.mi(a.R,new $hb.Kd(b,c,$hb.cd(a,d)?-3:a.o[d]))};$hb.pd=function pd(a,b,c,d,e){var f,g,h,i,j;if(e){g=(f=(h=uib.K_(a.e,d),new vib.R_(0,0,h,0)).b,f);i=g/2+(a.j/8|0);j=a.j/2|0;(d=='+'||d=='-')&&(j=j*2/3);_hb.mi(a.X,new lib.YE(b-i,c-j,2*i,2*j))}a.H||$hb.fs(a,d,b,c)};$hb.qd=function qd(a){var b;b=a.a;a.a=a.b;a.b=b;b=a.c;a.c=a.d;a.d=b};$hb.rd=function rd(a,b,c){var d;d=b==0?zjb+a[0]-a[a.length-1]:a[b]-a[b-1];c>-2.0943951023931953&&c0)return (a[b]+a[b-1])/2;c=Ajb+(a[0]+a[a.length-1])/2;return c>Ajb?c-zjb:c};$hb.vd=function vd(a,b,c,d){var e,f,g,h;h=new $hb.Ld;if(b.a==b.b&&b.c==b.d)return;h.a=b.a;h.c=b.c;h.b=b.b;h.d=b.d;g=$hb.sd(h);for(e=0;eg.c+g.b||f.d>g.d+g.a||g.c>f.c+f.b||g.d>f.d+f.a)continue;if($hb.wd(a,h.a,h.c,e)){if($hb.wd(a,h.b,h.d,e))return;$hb.Ad(a,h,0,e);$hb.vd(a,h,c,d);return}if($hb.wd(a,h.b,h.d,e)){$hb.Ad(a,h,1,e);$hb.vd(a,h,c,d);return}}$hb.Uc(a,h,c,d)};$hb.wd=function wd(a,b,c,d){var e;if((a.C&1)!=0)return false;e=_hb.ri(a.X,d);return b>e.c&&be.d&&cf[0]&&c[i]b.b){$hb.qd(b);c=true}for(d=0;dh.c+h.b||f.d>h.d+h.a||h.c>f.c+f.b||h.d>f.d+f.a)continue;if($hb.wd(a,b.a,b.c,d)){if($hb.wd(a,b.b,b.d,d)){c&&$hb.qd(b);return false}$hb.Ad(a,b,0,d);e=$hb.zd(a,b);c&&$hb.qd(b);return e}if($hb.wd(a,b.b,b.d,d)){$hb.Ad(a,b,1,d);e=$hb.zd(a,b);c&&$hb.qd(b);return e}}c&&$hb.qd(b);return true};$hb.Ad=function Ad(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o;if(c==0){l=b.a;n=b.c;m=b.b;o=b.d}else{l=b.b;n=b.d;m=b.a;o=b.c}k=_hb.ri(a.X,d);i=m>l?k.c+k.b:k.c;j=o>n?k.d+k.a:k.d;e=m-l;f=o-n;if($wnd.Math.abs(e)>$wnd.Math.abs(f)){if(n==o){g=i;h=n}else{g=l+e*(j-n)/f;if(m>l==i>g){h=j}else{g=i;h=n+f*(i-l)/e}}}else{if(l==m){g=l;h=j}else{h=n+f*(i-l)/e;if(o>n==j>h){g=i}else{g=l+e*(j-n)/f;h=j}}}if(c==0){b.a=g;b.c=h}else{b.b=g;b.d=h}};$hb.Bd=function Bd(a){var b,c,d,e;if(a.I.q==0)return;$hb.pt(a.I,(a.C&256)!=0?63:(a.C&512)!=0?95:31);$hb.Nc(a);c=$hb.ut(a.I);d=false;a.o=VT(Uhb.nV,bjb,6,a.I.q,15,1);for(b=0;bb.d+b.a-e&&(a.u.b=b.d+b.a-e);break;case ikb:if(b){a.u.a=b.c+b.b/2;a.u.b=b.d+e;break}case mkb:a.u.a=a.t.c+a.t.b/2;a.u.b=a.t.d-e;!!b&&a.u.b>16)+','+((b&djb)>>8)+','+(b&255)+')'};$hb.Fd=function Fd(a){var b,c,d,e,f;e=$hb.Ch(a.O,$hb.hk(a.I,0));c=$hb.Ch(a.O,$hb.hk(a.I,0));f=$hb.Dh(a.O,$hb.ik(a.I,0));d=$hb.Dh(a.O,$hb.ik(a.I,0));for(b=0;b$hb.Ch(a.O,$hb.hk(a.I,b))&&(e=$hb.Ch(a.O,$hb.hk(a.I,b)));c<$hb.Ch(a.O,$hb.hk(a.I,b))&&(c=$hb.Ch(a.O,$hb.hk(a.I,b)));f>$hb.Dh(a.O,$hb.ik(a.I,b))&&(f=$hb.Dh(a.O,$hb.ik(a.I,b)));d<$hb.Dh(a.O,$hb.ik(a.I,b))&&(d=$hb.Dh(a.O,$hb.ik(a.I,b)))}return new lib.YE(e,f,c-e,d-f)};$hb.Gd=function Gd(a,b){var c,d;if(a.I.q==0)return null;a.t=$hb.Fd(a);c=a.O.c*$hb.lk(a.I);d=new $hb.Fh(a.t,b,c);if(d.c==1&&d.a==0&&d.b==0){d=null}else{$hb.yh(d,a.O);$hb.Ah(d,a.t)}$hb.Cd(a,b,c,Tib);return d};$hb.Hd=function Hd(a){var b;b=a.J!=0?a.J:a.A!=0?a.A:-1;a.r=oib.sR(b);a.s=oib.rR(pkb,b);a.D=-24321;a.F=-6291392};$hb.Id=function Id(a,b){var c,d,e,f;if(a.I.q==0)return null;e=$hb.ms(a,b);$hb.pt(a.I,(a.C&256)!=0?63:(a.C&512)!=0?95:31);$hb.dd(a);Yhb.Kdb(a.R.a,0);Yhb.Kdb(a.X.a,0);$hb.Nc(a);$hb.ls(a,a.U);a.H=true;for(d=0;d1){if(!$hb.Sd(a,c,false)){Q=false;break}}else{S=V==5?$hb.Pd(a,c,false):$hb.Qd(a,c,false);if($hb.Sd(a,c,false)){if(N0){$hb.Rd(a,O,true);$hb.be(a,O)}}}}}};$hb.Pd=function Pd(a,b,c){if($hb.kk(a.f,b)==7){if($hb.Um(a.f,b)==3)return 6;else if($hb.hn(a.f,b)==2)return 4}else if($hb.kk(a.f,b)==8){return 10}else if($hb.kk(a.f,b)==15||$hb.kk(a.f,b)==33){if($hb.hn(a.f,b)==3)return 8}else if($hb.kk(a.f,b)==16||$hb.kk(a.f,b)==34||$hb.kk(a.f,b)==52){if($hb.hn(a.f,b)==2)return 12}else if($hb.kk(a.f,b)==6){c&&$hb.xl(a.f,b,-1);return $hb.Um(a.f,b)!=$hb.Vm(a.f,b)?2:3}return 0};$hb.Qd=function Qd(a,b,c){if(a.a){if($hb.Um(a.f,b)!=3)return 0}else{if($hb.Um(a.f,b)>3)return 0}if($hb.kk(a.f,b)==6){c&&$hb.xl(a.f,b,1);return 2}if($hb.kk(a.f,b)==5){return 4}return 0};$hb.Rd=function Rd(a,b,c){if($hb.Vj(a.f,b)!=0)return 0;if(a.a){if($hb.kk(a.f,b)==5){if($hb.Bn(a.f,b)!=2)return 0;c&&$hb.xl(a.f,b,1);return 1}if($hb.kk(a.f,b)==7){if($hb.Bn(a.f,b)!=2)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?6:3}if($hb.kk(a.f,b)==8){if($hb.Bn(a.f,b)!=1)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?7:4}if($hb.kk(a.f,b)==16){if($hb.Bn(a.f,b)!=1)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?5:2}if($hb.kk(a.f,b)==34){if($hb.Bn(a.f,b)!=1)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?4:1}}else{if($hb.kk(a.f,b)==5){if($hb.Bn(a.f,b)>2)return 0;c&&$hb.xl(a.f,b,1);return 1}if($hb.kk(a.f,b)==7){if($hb.Bn(a.f,b)>2)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?5:3}if($hb.kk(a.f,b)==8){if($hb.Bn(a.f,b)>1)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?7:4}if($hb.kk(a.f,b)==16){if($hb.Bn(a.f,b)>1)return 0;c&&$hb.xl(a.f,b,-1);return $hb.Ud(a,b)?5:2}}return 0};$hb.Sd=function Sd(a,b,c){var d,e,f;d=$hb.kk(a.f,b);if(d>=5&&d<=8||d==15||d==16||d==33||d==34||d==52){f=$hb.xn(a.f,b);if(f!=0)return true;e=$hb.Vj(a.f,b);if(d==5&&e>=0){c&&$hb.xl(a.f,b,e-1);return true}if(d!=5&&e<=0){c&&$hb.xl(a.f,b,e+1);return true}}return false};$hb.Td=function Td(a,b,c,d){var e;for(e=0;e<$hb.hn(a.f,b);e++)if(d[$hb.jn(a.f,b,e)]==1&&$hb.gn(a.f,b,e)!=c)return e;return -1};$hb.Ud=function Ud(a,b){var c;for(c=0;c<$hb.hn(a.f,b);c++)if($hb._k(a.f,$hb.gn(a.f,b,c)))return true;return false};$hb.Vd=function Vd(a,b,c){var d;for(d=0;d<$hb.hn(a.f,b);d++)if(c[$hb.jn(a.f,b,d)]>1)return true;return false};$hb.Wd=function Wd(a,b){var c;for(c=0;c<$hb.hn(a.f,b);c++)if(a.e[$hb.jn(a.f,b,c)])return true;return false};$hb.Xd=function Xd(a,b,c){var d,e,f,g,h,i,j,k,l,m;$hb.pt(a.f,1);if(b!=null){a.e=b}else{a.e=VT(Uhb.A$,vjb,6,a.f.g,16,1);for(e=0;e0)&&$hb.be(a,c)};$hb.ee=function ee(a,b){var c,d,e,f,g,h,i,j,k,l,m,n;for(k=0;k3)return false;if((a.u[b]&Djb)!=0){if(a.o[b]!=1)return false;if($hb._m(a,b,7)!=1)return false;u=($hb.pt(a,7),a.p);for(s=0;s0}break}}return false}if(a.o[b]>1)return false;if(a.o[b]==1){m=-1;A=0;for(i=0;i=0}for(h=0;h3&&(o=3);(c&512)==0&&o>1&&(o=1);g=c_(g,Uhb.P$(o<<6))}(c&Hjb)!=0&&(a.u[e]&8)!=0&&(g=c_(g,256));(c&ekb)!=0&&(a.u[e]&Djb)!=0&&(g=c_(g,512));(c&Cjb)!=0&&(a.u[e]&Cjb)!=0&&(g=c_(g,Hjb));k=0;while(M$(g,n[k])<0)++k;for(l=i;l>k;l--)n[l]=n[l-1];n[k]=g;++m}m>4&&(m=4);d=0;for(j=0;j9&&(q=9);q>2&&(q-=2);d=c_(d,Uhb.P$(q<<4))}else (c&1)!=0&&(a.u[b]&8)!=0&&(d=c_(d,64));(c&4)!=0&&(a.u[b]&Djb)!=0&&(d=c_(d,Hjb));(c&8)!=0&&(a.u[b]&dkb)!=0&&(d=c_(d,ekb));(c&16)!=0&&(a.u[b]&Cjb)!=0&&(d=c_(d,Djb));if((c&Djb)!=0){$hb.he(a,b)&&(d=c_(d,dkb));if($hb.ke(a,b)){for(h=0;h>f),e)}}};$hb.te=function te(a){var b,c,d,e,f,g;while(true){f=VT(Uhb.A$,vjb,6,a.S+1,16,1);d=-1;for(c=0;c3||$hb.Um(a.P,f)>3)return false;g=new $hb.ej(a.P,a.d,b,e);if(g.f&&c==1)return false;h=new $hb.ej(a.P,a.d,b,f);if(h.f&&c==1)return false;if(g.f&&h.f)return false;if(c==3){g.f&&g.c&&(a.U[b]=true);h.f&&h.c&&(a.U[b]=true)}d=a.hb?$hb.ye(a,g,h):$hb.xe(g,h);if(c==1){a.bb[b]=d}else if(c==2){g.f&&(d==1?$hb.jg(a.c[g.b],T$(a.d[e])):$hb.jg(a.c[g.d],T$(a.d[e])));h.f&&(d==2?$hb.jg(a.c[h.b],T$(a.d[f])):$hb.jg(a.c[h.d],T$(a.d[f])))}return true};$hb.xe=function xe(a,b){var c,d,e;d=$hb.dj(a);e=$hb.dj(b);if(d==-1||e==-1||(d+e&1)==0)return 3;c=0;switch(d+e){case 3:case 7:c=2;break;case 5:c=1;}return c};$hb.ye=function ye(a,b,c){var d,e;d=VT(Uhb.nV,bjb,6,4,15,1);d[0]=b.b;d[1]=b.a;d[2]=c.a;d[3]=c.b;e=$hb.zj(a.P,d);if($wnd.Math.abs(e)<0.3||$wnd.Math.abs(e)>vkb)return 3;return e<0?2:1};$hb.ze=function ze(a,b,c){var d,e,f,g,h;if(!$hb.Zn(a.P,b))return false;d=$hb.pk(a.P,0,b);e=$hb.pk(a.P,1,b);g=new $hb.ej(a.P,a.d,d,e);if(g.f&&c==1)return false;h=new $hb.ej(a.P,a.d,e,d);if(h.f&&c==1)return false;if(g.f&&h.f)return false;if(c==3){g.f&&(a.T[b]=$hb.Ff(a,e));h.f&&(a.T[b]=$hb.Ff(a,d))}f=a.hb?$hb.Be(a,g,h):$hb.Ae(g,h);if(c==1){a.k[b]=f}else if(c==2){g.f&&(f==2?$hb.jg(a.c[g.b],T$(a.d[e])):$hb.jg(a.c[g.d],T$(a.d[e])));h.f&&(f==2?$hb.jg(a.c[h.b],T$(a.d[d])):$hb.jg(a.c[h.d],T$(a.d[d])))}return true};$hb.Ae=function Ae(a,b){var c,d,e;d=$hb.dj(a);e=$hb.dj(b);if(d==-1||e==-1||(d+e&1)==0)return 3;c=0;switch(d+e){case 3:case 7:c=1;break;case 5:c=2;}return c};$hb.Be=function Be(a,b,c){var d,e;d=VT(Uhb.nV,bjb,6,4,15,1);d[0]=b.b;d[1]=b.a;d[2]=c.a;d[3]=c.b;e=$hb.zj(a.P,d);if($wnd.Math.abs(e)<0.3||$wnd.Math.abs(e)>vkb)return 3;return e<0?1:2};$hb.Ce=function Ce(a,b,c){var d,e,f,g,h;if(a.k[b]!=0)return false;if($hb.xk(a.P,b)==1)return $hb.ze(a,b,c);if($hb.xk(a.P,b)!=2)return false;if($hb.Yn(a.P,b))return false;e=$hb.pk(a.P,0,b);f=$hb.pk(a.P,1,b);if($hb.hn(a.P,e)==1||$hb.hn(a.P,f)==1)return false;if($hb.hn(a.P,e)>3||$hb.hn(a.P,f)>3)return false;if($hb.Ym(a.P,e)==2||$hb.Ym(a.P,f)==2)return false;g=new $hb.ej(a.P,a.d,f,e);if(g.f&&c==1)return false;h=new $hb.ej(a.P,a.d,e,f);if(h.f&&c==1)return false;if(g.f&&h.f)return false;if(c==3){g.f&&g.c&&(a.T[b]=true);h.f&&h.c&&(a.T[b]=true)}d=$hb.Xk(a.P,b)?3:a.hb?$hb.Ee(a,g,h):$hb.De(g,h);if(c==1){a.k[b]=d}else if(c==2){g.f&&(d==1?$hb.jg(a.c[g.b],T$(a.d[e])):d==2&&$hb.jg(a.c[g.d],T$(a.d[e])));h.f&&(d==1?$hb.jg(a.c[h.b],T$(a.d[f])):d==2&&$hb.jg(a.c[h.d],T$(a.d[f])))}return true};$hb.De=function De(a,b){if($hb.dj(a)==-1||$hb.dj(b)==-1)return 3;if((($hb.dj(a)|$hb.dj(b))&1)!=0)return 3;return $hb.dj(a)==$hb.dj(b)?1:2};\n$hb.Ee=function Ee(a,b,c){var d,e,f,g,h,i,j;f=VT(Uhb.lV,_ib,6,3,15,1);f[0]=$hb.hk(a.P,c.a)-$hb.hk(a.P,b.a);f[1]=$hb.ik(a.P,c.a)-$hb.ik(a.P,b.a);f[2]=$hb.jk(a.P,c.a)-$hb.jk(a.P,b.a);i=VT(Uhb.lV,_ib,6,3,15,1);i[0]=$hb.hk(a.P,b.b)-$hb.hk(a.P,b.a);i[1]=$hb.ik(a.P,b.b)-$hb.ik(a.P,b.a);i[2]=$hb.jk(a.P,b.b)-$hb.jk(a.P,b.a);j=VT(Uhb.lV,_ib,6,3,15,1);j[0]=$hb.hk(a.P,c.b)-$hb.hk(a.P,c.a);j[1]=$hb.ik(a.P,c.b)-$hb.ik(a.P,c.a);j[2]=$hb.jk(a.P,c.b)-$hb.jk(a.P,c.a);g=VT(Uhb.lV,_ib,6,3,15,1);g[0]=f[1]*i[2]-f[2]*i[1];g[1]=f[2]*i[0]-f[0]*i[2];g[2]=f[0]*i[1]-f[1]*i[0];h=VT(Uhb.lV,_ib,6,3,15,1);h[0]=f[1]*g[2]-f[2]*g[1];h[1]=f[2]*g[0]-f[0]*g[2];h[2]=f[0]*g[1]-f[1]*g[0];d=(i[0]*h[0]+i[1]*h[1]+i[2]*h[2])/($wnd.Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2])*$wnd.Math.sqrt(h[0]*h[0]+h[1]*h[1]+h[2]*h[2]));e=(j[0]*h[0]+j[1]*h[1]+j[2]*h[2])/($wnd.Math.sqrt(j[0]*j[0]+j[1]*j[1]+j[2]*j[2])*$wnd.Math.sqrt(h[0]*h[0]+h[1]*h[1]+h[2]*h[2]));return d<0^e<0?1:2};$hb.Fe=function Fe(a,b){var c,d,e,f;c=$hb.Tj(a.P,b);d=$hb.vn(a.P,b,false);e=$hb.vn(a.P,b,true);f=-1;if(d!=e){c!=-1&&c>d?(f=c<<24>>24):(f=d<<24>>24)}else if(c!=-1){(c>e||c=$hb.Bn(a.P,b))&&(f=c<<24>>24)}else if(!$hb.Ao(a.P,b)&&$hb.mn(a.P,b)!=0){f=$hb.Bn(a.P,b);f-=$hb.Ek(a.P,b,f)}$hb._e(a,b,f);return f};$hb.Ge=function Ge(a){var b,c,d,e,f,g,h,i,j,k,l;d=VT(Uhb.nV,bjb,6,a.M,15,1);for(b=0;b=$hb.Um(a.P,b)){l=2*a.d[$hb.gn(a.P,b,f)];c=$hb.jn(a.P,b,f);$hb.xk(a.P,c)==2&&($hb.Yn(a.P,c)||++l);for(h=0;hh;i--)d[i]=d[i-1];d[h]=l;++j}}$hb.lg(a.c[b],b);$hb.ig(a.c[b],a.b,T$(a.d[b]));for(g=k;g4)return false;if($hb.Vj(a.P,b)>0&&$hb.kk(a.P,b)==6)return false;if($hb.kk(a.P,b)==5&&$hb.Um(a.P,b)!=4)return false;if($hb.kk(a.P,b)==7&&!a.Q[b])return false;n=VT(Uhb.nV,bjb,6,4,15,1);o=VT(Uhb.nV,bjb,6,4,15,1);j=VT(Uhb.A$,vjb,6,4,16,1);for(h=0;h<$hb.Um(a.P,b);h++){f=-1;e=0;for(i=0;i<$hb.Um(a.P,b);i++){if(!j[i]){if(f>24;if(j!=3)return j;k=0;l=0;for(h=0;h<$hb.Um(a.P,b);h++){e=$hb.jn(a.P,b,c[h]);if($hb.pk(a.P,0,e)==b){if($hb.Ak(a.P,e)==9){l!=0&&$hb.hm(a.P,b);k=h;l=1}if($hb.Ak(a.P,e)==17){l!=0&&$hb.hm(a.P,b);k=h;l=2}}}if(l==0)return 3;for(f=1;f<$hb.Um(a.P,b);f++)d[f]d[2]&&d[1]-d[2]>Ajb)&&(l=3-l);break;case 1:d[2]-d[0]>Ajb&&(l=3-l);break;case 2:d[1]-d[0]0?1:2};$hb.Ke=function Ke(a){var b,c;b=0;_hb.M9(a.c);for(c=0;c7)continue;t=$hb.In(a.P);u=0;while(u=Hjb&&u==t.i.a.length)continue;i=-1;j=-1;for(l=0;l<3;l++){h=$hb.jn(a.P,b,l);if(!$hb._q(t,u,h)){i=$hb.gn(a.P,b,l);j=h;break}}n=VT(Uhb.A$,vjb,6,a.P.g,16,1);n[j]=true;o=VT(Uhb.nV,bjb,6,11,15,1);p=$hb.Dn(a.P,o,i,b,10,n);if(p==-1)continue;d=1;while(!$hb.$q(t,u,o[d]))++d;c=p-d;e=o[d];if(v==6&&c==2&&d==3){if($hb.$m(a.P,o[1])>=3){m=false;s=_hb.ri(t.i,u);for(k=0;k<6;k++){if(b==s[k]){r=$hb.er(t,u,e==s[$hb.er(t,u,k+2)]?k-2:k+2);q=s[r];$hb.$m(a.P,q)>=3&&$hb.Gn(a.P,o[1],q,2,null)==2&&(m=true);break}}if(m){a.Q[b]=true;continue}}}f=$hb.Ym(a.P,e)==1||$hb.Xn(a.P,e)||$hb.co(a.P,e);g=!f&&$hb.kk(a.P,e)==7&&$hb.Vj(a.P,e)!=1;if(c==1){!f&&!g&&v<=4&&d<=3&&(a.Q[b]=true);continue}switch(v){case 4:!f&&!g&&d<=4&&(a.Q[b]=true);break;case 5:g?d<=3&&(a.Q[b]=true):f||d<=4&&(a.Q[b]=true);break;case 6:c==2?f?d<=4&&(a.Q[b]=true):g||d<=3&&(a.Q[b]=true):c==3&&(f?d<=6&&(a.Q[b]=true):d<=4&&(a.Q[b]=true));break;case 7:c==3&&d<=3&&(a.Q[b]=true);}}}}};$hb.Ne=function Ne(a,b){var c,d,e,f;e=false;for(d=0;d1){$hb.Le(a);a.R=0;for(h=new _hb.q9(a.v);h.aB?(A<<16)+B:(B<<16)+A;if(a.k[g.b[p]]==1||a.k[g.b[p]]==2){++w;v=true;if(i0;l--){j=0;i=null;for(d=0;d<32;d++){if(c[d]!=null){if(i==null||i.length=0;h--){if(i[h]>4));if(a.P.K){$hb.ig(a.c[e],39,$hb.fk(a.P,e));$hb.ak(a.P,e)!=null&&(h=true)}}a.S=$hb.Ue(a);if(a.Sm.length;p--)$hb.ig(a.c[b],a.b+5,0);for(n=m.length-1;n>=0;n--)$hb.ig(a.c[b],a.b+5,Uhb.P$(m[n]))}a.S=$hb.Ue(a)}if(h&&a.Ss;o--)$hb.ig(a.c[b],8,0);for(n=s-1;n>=0;n--)$hb.ig(a.c[b],8,Uhb.P$(g[n]))}a.S=$hb.Ue(a)}if(l&&a.S=$hb.Um(a.P,b)){k[q]=T$(a.d[$hb.gn(a.P,b,o)]);k[q]=d_(k[q],21);k[q]=c_(k[q],T$($hb.zk(a.P,$hb.jn(a.P,b,o))));++q}}Yhb.Ldb(k,Yhb.peb(y_(_hb.T9.prototype.ic,_hb.T9,[])));for(p=a.M;p>k.length;p--)$hb.ig(a.c[b],a.b+21,0);for(n=k.length-1;n>=0;n--)$hb.ig(a.c[b],a.b+21,k[n])}a.S=$hb.Ue(a)}if((a.O&8)!=0&&a.S>24;a.$[c]=$hb.Zj(a.P,c)<<24>>24}a.j=VT(Uhb.jV,ykb,6,a.P.g,15,1);a.i=VT(Uhb.jV,ykb,6,a.P.g,15,1);for(d=0;d>24;a.i[d]=$hb.tk(a.P,d)<<24>>24}$hb.Xe(a);a.X=false;a.K=VT(Uhb.A$,vjb,6,a.P.f,16,1);for(b=0;b>24};$hb.af=function af(b,c){var d,e,f,g,h,i;if((b.k[c]==1||b.k[c]==2)&&!$hb.lo(b.P,c)){h=false;try{for(g=0;g<2;g++){d=$hb.pk(b.P,g,c);if($hb.hn(b.P,d)==3){e=VT(Uhb.nV,bjb,6,2,15,1);f=0;for(i=0;i<$hb.hn(b.P,d);i++)$hb.jn(b.P,d,i)!=c&&(e[f++]=$hb.gn(b.P,d,i));b.d[e[0]]>b.d[e[1]]^$hb.cf(b,d,e[0],e[1])&&(h=!h)}}}catch(a){a=E$(a);if(_U(a,15)){b.f[c]=3;return}else throw F$(a)}b.k[c]==1^h?(b.f[c]=1):(b.f[c]=2)}};$hb.bf=function bf(b,c){var d,e,f,g,h,i,j;if(b.bb[c]==1||b.bb[c]==2){i=false;if($hb.Ym(b.P,c)==2){try{for(h=0;h<2;h++){d=$hb.gn(b.P,c,h);if($hb.hn(b.P,d)==3){f=VT(Uhb.nV,bjb,6,2,15,1);g=0;for(j=0;j<$hb.hn(b.P,d);j++)$hb.kn(b.P,d,j)==1&&(f[g++]=$hb.gn(b.P,d,j));b.d[f[0]]>b.d[f[1]]^$hb.cf(b,d,f[0],f[1])&&(i=!i)}}}catch(a){a=E$(a);if(_U(a,15)){b.Y[c]=3;return}else throw F$(a)}}else{try{e=$hb.ef(b,c)}catch(a){a=E$(a);if(_U(a,15)){b.Y[c]=3;return}else throw F$(a)}for(h=1;h$hb.kk(a.P,d);if($hb.dk(a.P,c)!=$hb.dk(a.P,d)){H=$hb.al(a.P,c)?($hb.mj(),$hb.kj)[$hb.kk(a.P,c)]:$hb.dk(a.P,c);I=$hb.al(a.P,d)?($hb.mj(),$hb.kj)[$hb.kk(a.P,d)]:$hb.dk(a.P,d);return H>I}w=a.P.f;s=VT(Uhb.nV,bjb,6,w,15,1);u=VT(Uhb.nV,bjb,6,w,15,1);v=VT(Uhb.nV,bjb,6,w,15,1);t=VT(Uhb.A$,vjb,6,w,16,1);i=VT(Uhb.A$,vjb,6,a.P.q,16,1);s[0]=b;s[1]=c;s[2]=d;u[0]=-1;u[1]=0;u[2]=0;i[b]=true;i[c]=true;i[d]=true;m=1;A=2;G=VT(Uhb.nV,bjb,6,64,15,1);G[1]=1;G[2]=3;o=2;while(m<=A){while(m=w){w+=a.P.f;s=$hb.Of(s,w);u=$hb.Of(u,w);v=$hb.Of(v,w);t=$hb.Pf(t,w)}if($hb.ao(a.P,$hb.jn(a.P,n,C))){++p;q+=$hb.kk(a.P,k)}else{for(F=1;F<$hb.kn(a.P,n,C);F++){++A;s[A]=k;u[A]=m;t[A]=true}}K=u[m];if(k==s[K])continue;h=false;if(i[k]){J=u[K];while(J!=-1){if(k==s[J]){h=true;break}J=u[J]}}if(h){++A;s[A]=k;u[A]=m;t[A]=true}else{++A;s[A]=k;u[A]=m;i[k]=true}}if(p!=0){++A;v[A]=(q<<2)/p|0;u[A]=m;t[A]=true}}++m;if(m==Vib){throw F$(new Vhb.Yy('Emergency break in while loop.'))}}G.length==o+1&&(G=$hb.Of(G,G.length+64));G[o+1]=A+1;for(B=G[o];Bv[2];o>1&&$hb.df(v,u,G,o);++o}l=VT(Uhb.nV,bjb,6,a.P.f,15,1);D=false;for(f=0;fv[2]}_hb.E9(l,l.length,0);r=false;for(j=0;jv[2];_hb.E9(l,l.length,0);L=false;for(e=0;ev[2];throw F$(new Vhb.Yy('no distinction applying CIP rules'))};$hb.df=function df(a,b,c,d){var e,f,g,h,i,j,k,l,m;l=c[d];g=c[d+1]-l;m=VT(Uhb.xV,Qib,135,g,0,1);for(i=0;i1;k--){for(j=0;j1;d--){c=false;for(f=1;f1&&$hb.df(c,d,g,j)}return false};$hb.gf=function gf(a,b,c,d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r;for(l=g;l>1;l--){p=f[l]-f[l-1];r=VT(Uhb.vV,Qib,134,p,0,1);h=f[l];for(o=0;oa.P.f&&!a.P.K){l=true;for(i=0;i1&&o==0){a.q='';return}g=1<15){$hb.kf(a,1,1);$hb.kf(a,15,4);b-=16;++a.u}$hb.kf(a,1,1);$hb.kf(a,Uhb.P$(b),4)};$hb.qf=function qf(a){var b,c,d,e,f,g;if(a.P.f==0){a.L='';return}f=0;d=false;e=false;for(c=0;ca.d[v]&&(v=c);d=VT(Uhb.A$,vjb,6,a.P.f,16,1);g=VT(Uhb.A$,vjb,6,a.P.g,16,1);a.F=VT(Uhb.nV,bjb,6,a.P.f,15,1);a.w=VT(Uhb.nV,bjb,6,a.P.f,15,1);a.C=VT(Uhb.nV,bjb,6,a.P.f,15,1);a.A=VT(Uhb.nV,bjb,6,a.P.g,15,1);a.w[0]=v;a.F[v]=0;d[v]=true;e=1;i=0;j=1;k=0;while(i=$hb.Um(a.P,b)){h=$hb.gn(a.P,b,q);if(!d[h]&&a.d[h]>m){o=h;p=$hb.jn(a.P,b,q);m=a.d[h]}}}if(m==-1)break;a.F[o]=j;a.C[j]=i;a.w[j++]=o;a.A[k++]=p;d[o]=true;g[p]=true}++i}else{n=0;m=-1;for(b=0;bm){n=b;m=a.d[b]}}++e;a.F[n]=j;a.C[j]=-1;a.w[j++]=n;d[n]=true}}a.B=VT(Uhb.nV,bjb,6,2*(a.P.g-k),15,1);while(true){s=a.P.M;t=a.P.M;u=-1;for(f=0;fa.w[n[g]]){k=a.w[n[g]];j=g}}while(f>0){i[n[j]]=true;j=$hb.Uf(j+2,m.length);f-=2}}else{h=0;while($hb.Gf(a,m[h]))++h;while(!$hb.Gf(a,m[h]))h=$hb.Uf(h+1,m.length);while(f>0){i[n[h]]=true;h=$hb.Uf(h+2,m.length);f-=2;while(!$hb.Gf(a,m[h]))h=$hb.Uf(h+1,m.length)}}}}}return i};$hb.vf=function vf(a,b){return a.k[b]};$hb.wf=function wf(a){return $hb.xf(a,a.hb)};$hb.xf=function xf(a,b){if(a.q==null){$hb.tf(a);$hb.nf(a,b,a.P.J)}return a.q};$hb.yf=function yf(a){if(a.L==null){$hb.tf(a);$hb.qf(a)}return a.L};$hb.zf=function zf(a){if(a.H==null){$hb.tf(a);if((a.O&ekb)==0){$hb.If(a);$hb.Jf(a,1);$hb.Jf(a,2)}$hb.Hf(a)}return a.H};$hb.Af=function Af(a,b,c,d,e){var f,g,h;f=c==-1?$wnd.Math.abs(e[b].a-e[a.w[0]].a)/8:$wnd.Math.abs(e[b].a-e[c].a);d1};\n$hb.Hf=function Hf(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,A,B,C,D,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W;$hb.mf(a,false);$hb.kf(a,9,4);S=$wnd.Math.max($hb.Xf(a.P.f),$hb.Xf(a.P.g));$hb.kf(a,Uhb.P$(S),4);if(S==0){$hb.kf(a,T$(a.P.K?1:0),1);$hb.kf(a,0,1);a.H=$hb.lf(a);return}T=V=U=G=0;for(i=0;i0){$hb.pf(a,8);$hb.kf(a,Uhb.P$(H),S);for(t=0;t>4),2)}}}if(a.P.K){$hb.re(a,22,S,ckb,1,-1);$hb.se(a,23,S,mkb,1,-1);$hb.se(a,24,S,hkb,2,19)}if((a.O&16)!=0){for(h=0;ha.d[k[1]]^a.F[k[0]]a.d[g]&&(i=!i);a.F[f]a.d[k[1]]&&(i=!i);a.F[k[0]]>24}for(c=0;c=a.P.f)return false;if(a.bb[c]==1||a.bb[c]==2)return true;if(a.bb[c]==3)return false;d=$hb.Qm(a.P,c);if(d!=-1)return a.k[d]==1||a.k[d]==2;for(e=0;e<$hb.hn(a.P,c);e++){if($hb.kn(a.P,c,e)==2){if(a.bb[$hb.gn(a.P,c,e)]==1||a.bb[$hb.gn(a.P,c,e)]==2)return true}}return false};$hb.Mf=function Mf(a,b){var c;for(c=0;c<$hb.hn(a.P,b);c++)if(a.k[$hb.jn(a.P,b,c)]==3&&$hb.kn(a.P,b,c)==1)return true;return false};$hb.Nf=function Nf(a){var b,c,d,e,f,g,h;g=VT(Uhb.nV,bjb,6,a.S+1,15,1);for(c=0;ca.d[k[1]]^k[0]a.d[g]&&(i=!i);fa.d[k[1]]&&(i=!i);k[0]0){a>>=1;++b}return b};v_(33,1,{},$hb.Vf,$hb.Wf);_.b=0;_.p=false;_.r=0;_.t=0;_.u=0;_.D=false;_.G=0;_.I=false;_.J=false;_.M=0;_.O=0;_.R=0;_.S=0;_.X=false;_.hb=false;Uhb.FV=$0(33);$hb.Yf=function Yf(a,b){var c,d,e,f;if(a.d!=b.d)return a.d>b.d?1:-1;e=a.a.length;f=b.a.length;c=$wnd.Math.min(e,f);for(d=0;db.a[f]?1:-1}if(e!=f)return e>f?1:-1;if(a.b!=b.b)return a.b>b.b?1:-1;return 0};$hb.Zf=function Zf(a,b){return $hb.Yf(a,b)};$hb.$f=function $f(){};v_(227,1,{},$hb.$f);_.pb=function _f(a,b){return $hb.Zf(a,b)};_.ib=function ag(a){return this===a};Uhb.wV=$0(227);$hb.bg=function bg(){};v_(134,1,{134:1},$hb.bg);_.b=0;_.c=0;_.d=0;Uhb.vV=$0(134);$hb.cg=function cg(a,b){if(a.c!=b.c)return a.c>b.c?1:-1;return 0};$hb.dg=function dg(a,b){return $hb.cg(a,b)};$hb.eg=function eg(){};v_(228,1,{},$hb.eg);_.pb=function fg(a,b){return $hb.dg(a,b)};_.ib=function gg(a){return this===a};Uhb.yV=$0(228);$hb.hg=function hg(){};v_(135,1,{135:1},$hb.hg);_.a=0;_.b=0;_.c=0;Uhb.xV=$0(135);$hb.ig=function ig(a,b,c){if(a.b==0){++a.c;a.b=63}if(a.b==63){a.d[a.c]=c_(a.d[a.c],c);a.b-=b}else{if(a.b>=b){a.d[a.c]=d_(a.d[a.c],b);a.d[a.c]=c_(a.d[a.c],c);a.b-=b}else{a.d[a.c]=d_(a.d[a.c],a.b);a.d[a.c]=c_(a.d[a.c],e_(c,b-a.b));b-=a.b;++a.c;a.b=63-b;a.d[a.c]=c_(a.d[a.c],H$(c,Uhb.P$((1<b.b?-1:1;if(a.c!=b.c)return a.c>b.c?-1:1;return 0};$hb.pg=function pg(a,b,c){this.b=$wnd.Math.max(a,b);this.c=$wnd.Math.min(a,b);this.a=c};v_(133,1,{133:1,27:1},$hb.pg);_.qb=function qg(a){return $hb.og(this,a)};_.a=0;_.b=0;_.c=0;Uhb.AV=$0(133);$hb.rg=function rg(a,b,c,d){this.a=(Yhb.aeb(b),_hb.y9(a,VT(Uhb.nV,bjb,6,b,15,1),b));this.b=(Yhb.aeb(d),_hb.y9(c,VT(Uhb.nV,bjb,6,d,15,1),d))};v_(165,1,{165:1},$hb.rg);Uhb.BV=$0(165);$hb.sg=function sg(a,b){var c,d;for(d=0;d2){for(g=1;g<$hb.hn(a.i,l);g++){b=$hb.gn(a.i,l,g);for(h=0;h>24;a.j[g]=c<<24>>24}else if(a.k[g]==d&&a.j[g]==c){a.k[g]=0;a.j[g]=-1}}}}return true};$hb.Bg=function Bg(a,b){var c,d,e,f,g,h;if(!a.b)return false;e=false;for(f=a.b.a.length-1;f>=0;f--){d=false;g=_hb.ri(a.b,f);g.a==2?(d=$hb.Ag(a,g.b,g.c,g.d,b)):g.a==1&&(d=$hb.Fg(a,g.b,b));if(d){_hb.zi(a.b,g);for(h=0;h0){if(c){$hb.Dg(a,e,g.i+g.g++,2);++h}_hb.mi(a.b,new $hb.cj(e,1,-1,-1))}else if(b>0){c&&$hb.Dg(a,e,g.a+g.f++,1);_hb.mi(a.b,new $hb.cj(e,1,-1,-1))}else if(c){$hb.Dg(a,e,g.a+g.f++,1);_hb.mi(a.b,new $hb.cj(e,1,-1,-1))}}else if(d==1){if($hb.sg(a,e)){f=$hb.Mg(g,e);i=$hb.Og(g,e);_hb.mi(a.b,new $hb.cj(e,2,f,i))}else{$hb.Jg(g,e);_hb.mi(a.b,new $hb.cj(e,1,-1,-1))}}}}};$hb.Dg=function Dg(a,b,c,d){var e,f;for(f=0;f>24;a.j[e]=c<<24>>24}}};$hb.Eg=function Eg(a,b,c){var d,e;for(e=0;e>24}}};$hb.Fg=function Fg(a,b,c){var d,e,f,g,h,i,j,k;f=a.g[b];e=1;for(i=0;i2||$hb.kk(a.i,d)==16&&$hb.hn(a.i,d)>2)&&$hb.hn(a.i,d)>2){h=false;for(p=1;p<$hb.hn(a.i,d);p++){u=$hb.gn(a.i,d,p);if(!s.a[u]){for(q=0;q>24)}}}}}};$hb.Kg=function Kg(a,b,c){var d,e,f,g,h;h=false;g=1;b[c]=g;d=true;while(d){d=false;for(e=0;ea.j.a[d]+(f==1?Tib:0)){k=a.j.a[d]+(f==1?Tib:0);i=e;l=f;j=b[h]}}}}}for(c=0;c=-1){f=VT(Uhb.nV,bjb,6,this.b,15,1);if($hb.Kg(this,f,b)){for(l=0;l=1)return 0;if(c<=-1)return Ajb;return $wnd.Math.acos(c)};$hb.lh=function lh(a,b){var c,d,e;c=a.a;d=a.b;e=a.c;a.a=c*b[0][0]+d*b[1][0]+e*b[2][0];a.b=c*b[0][1]+d*b[1][1]+e*b[2][1];a.c=c*b[0][2]+d*b[1][2]+e*b[2][2];return a};$hb.mh=function mh(a){a.a*=0.5;a.b*=0.5;a.c*=0.5;return a};$hb.nh=function nh(a,b,c,d){a.a=b;a.b=c;a.c=d};$hb.oh=function oh(a,b){$hb.nh(a,b.a,b.b,b.c);return a};$hb.ph=function ph(a,b){a.a-=b.a;a.b-=b.b;a.c-=b.c;return a};$hb.qh=function qh(a,b){return new $hb.th(a.a-b.a,a.b-b.b,a.c-b.c)};$hb.rh=function rh(a){var b;b=$wnd.Math.sqrt(a.a*a.a+a.b*a.b+a.c*a.c);if(b==0){Vhb.q3();String.fromCharCode(10);a.a=1;a.b=0;a.c=0;return a}a.a/=b;a.b/=b;a.c/=b;return a};$hb.sh=function sh(){};$hb.th=function th(a,b,c){this.a=a;this.b=b;this.c=c};$hb.uh=function uh(a){$hb.th.call(this,a.a,a.b,a.c)};v_(25,1,{25:1,4:1,27:1},$hb.sh,$hb.th,$hb.uh);_.qb=function vh(a){return $hb.ih(this,a)};_.ib=function wh(a){var b;if(a==null||!_U(a,25))return false;b=a;return $wnd.Math.abs(b.a-this.a)+$wnd.Math.abs(b.b-this.b)+$wnd.Math.abs(b.c-this.c)<1.0E-6};_.lb=function xh(){var a;a=new zib.U5('0.00');return '['+zib.S5(a,this.a)+', '+zib.S5(a,this.b)+', '+zib.S5(a,this.c)+']'};_.a=0;_.b=0;_.c=0;Uhb.GV=$0(25);$hb.yh=function yh(a,b){b.c*=a.c;b.a=b.a*a.c+a.a;b.b=b.b*a.c+a.b};$hb.zh=function zh(a,b){b.a=b.a*a.c+a.a;b.b=b.b*a.c+a.b};$hb.Ah=function Ah(a,b){b.c=b.c*a.c+a.a;b.d=b.d*a.c+a.b;b.b*=a.c;b.a*=a.c};$hb.Bh=function Bh(a){a.a=0;a.b=0;a.c=1};$hb.Ch=function Ch(a,b){return b*a.c+a.a};$hb.Dh=function Dh(a,b){return b*a.c+a.b};$hb.Eh=function Eh(){$hb.Bh(this)};$hb.Fh=function Fh(a,b,c){var d,e,f,g;$hb.Bh(this);e=b.b/a.b;g=b.a/a.a;f=0;f==0&&(f=24);d=f/c;this.c=$wnd.Math.min(d,$wnd.Math.min(e,g));this.a=b.c+b.b/2-this.c*(a.c+a.b/2);this.b=b.d+b.a/2-this.c*(a.d+a.a/2)};v_(136,1,{},$hb.Eh,$hb.Fh);_.lb=function Gh(){return 'DepictorTransformation Offset: '+this.a+','+this.b+' Scaling: '+this.c};_.a=0;_.b=0;_.c=0;Uhb.HV=$0(136);$hb.Hh=function Hh(a){var b,c,d,e;if(!Vhb.F2(Yhb.peb(a).substr(0,21),qkb)||(d=Yhb.peb(rkb).length,!Vhb.F2(Yhb.peb(a).substr(Yhb.peb(a).length-d,d),rkb)))return null;c=Vhb.K2(a,W2(34),21);if(c==-1)return null;e=(Yhb.jeb(21,c,Yhb.peb(a).length),Yhb.peb(a).substr(21,c-21));b=Vhb.S2(a,21+Yhb.peb(e).length+1,Yhb.peb(a).length-17);if(Vhb.F2(e,'arrow'))return new jib.CE(b);if(Vhb.F2(e,'text'))return new $hb.iu(b);return null};_hb.Ih=function Ih(a,b,c){var d,e;for(e=a.rb();e.bc();){d=e.cc();if(hV(b)===hV(d)||b!=null&&Vhb.zc(b,d)){c&&e.dc();return true}}return false};_hb.Jh=function Jh(a,b){var c,d;Yhb.eeb(b);for(d=b.rb();d.bc();){c=d.cc();if(!a.contains(c)){return false}}return true};_hb.Kh=function Kh(a,b){var c,d,e;Yhb.eeb(b);c=false;for(d=a.rb();d.bc();){e=d.cc();if(b.contains(e)){d.dc();c=true}}return c};_hb.Lh=function Lh(a){var b,c,d;d=new _hb.Cbb('[',']');for(c=a.rb();c.bc();){b=c.cc();_hb.Abb(d,hV(b)===hV(a)?'(this Collection)':b==null?Oib:C_(b))}return !d.a?d.c:Yhb.peb(d.e).length==0?d.a.a:d.a.a+(''+d.e)};v_(37,1,Bkb);_.add=function Mh(a){throw F$(new Vhb.u3('Add not supported on this collection'))};_.addAll=function Nh(a){var b,c,d;Yhb.eeb(a);b=false;for(d=a.rb();d.bc();){c=d.cc();b=b|this.add(c)}return b};_.clear=function Oh(){var a;for(a=this.rb();a.bc();){a.cc();a.dc()}};_.contains=function Ph(a){return _hb.Ih(this,a,false)};_.containsAll=function Qh(a){return _hb.Jh(this,a)};_.isEmpty=function Rh(){return this.size()==0};_.remove=function Sh(a){return _hb.Ih(this,a,true)};_.removeAll=function Th(a){return _hb.Kh(this,a)};_.retainAll=function Uh(a){var b,c,d;Yhb.eeb(a);b=false;for(c=this.rb();c.bc();){d=c.cc();if(!a.contains(d)){c.dc();b=true}}return b};_.toArray=function Vh(){return this.sb(VT(Uhb.NY,Qib,1,this.size(),5,1))};_.sb=function Wh(a){var b,c,d,e;e=this.size();a.lengthe&&Uhb.YT(a,e,null);return a};_.lb=function Xh(){return _hb.Lh(this)};Uhb.aZ=$0(37);_hb.Yh=function Yh(a,b,c){return new _hb.t7(a,b,c)};v_(73,37,Ckb);_.addAtIndex=function Zh(a,b){throw F$(new Vhb.u3('Add not supported on this list'))};_.add=function $h(a){this.addAtIndex(this.size(),a);return true};_.addAllAtIndex=function _h(a,b){var c,d,e;Yhb.eeb(b);c=false;for(e=b.rb();e.bc();){d=e.cc();this.addAtIndex(a++,d);c=true}return c};_.clear=function ai(){this.tb(0,this.size())};_.ib=function bi(a){var b,c,d,e,f;if(a===this){return true}if(!_U(a,93)){return false}f=a;if(this.size()!=f.size()){return false}e=f.rb();for(c=this.rb();c.bc();){b=c.cc();d=e.cc();if(!(hV(b)===hV(d)||b!=null&&Vhb.zc(b,d))){return false}}return true};_.kb=function ci(){return _hb.Z9(this)};_.indexOf=function di(a){var b,c;for(b=0,c=this.size();b-1;--b){if(_hb.obb(a,this.getAtIndex(b))){return b}}return -1};_.removeAtIndex=function gi(a){throw F$(new Vhb.u3('Remove not supported on this list'))};_.tb=function hi(a,b){var c,d;d=new _hb.r7(this,a);for(c=a;c=0;--c){if(_hb.obb(b,a.a[c])){return c}}return -1};\n_hb.yi=function yi(a,b){var c;c=(Yhb.deb(b,a.a.length),a.a[b]);Yhb.Jdb(a.a,b,1);return c};_hb.zi=function zi(a,b){var c;c=_hb.ti(a,b,0);if(c==-1){return false}_hb.yi(a,c);return true};_hb.Ai=function Ai(a,b,c){var d;Yhb.heb(b,c,a.a.length);d=c-b;Yhb.Jdb(a.a,b,d)};_hb.Bi=function Bi(a,b,c){var d;d=(Yhb.deb(b,a.a.length),a.a[b]);a.a[b]=c;return d};_hb.Ci=function Ci(a){return a.a.length};_hb.Di=function Di(a,b){_hb.N9(a.a,a.a.length,b)};_hb.Ei=function Ei(a){return Yhb.Cdb(a.a)};_hb.Fi=function Fi(a,b){var c,d;d=a.a.length;b.lengthd&&Uhb.YT(b,d,null);return b};_hb.Gi=function Gi(){_hb.ki(this)};_hb.Hi=function Hi(a){_hb.ki(this);Yhb.$db(a>=0,'Initial capacity must not be negative')};v_(18,73,Dkb,_hb.Gi,_hb.Hi);_.addAtIndex=function Ii(a,b){_hb.li(this,a,b)};_.add=function Ji(a){return _hb.mi(this,a)};_.addAllAtIndex=function Ki(a,b){return _hb.ni(this,a,b)};_.addAll=function Li(a){return _hb.oi(this,a)};_.clear=function Mi(){_hb.pi(this)};_.contains=function Ni(a){return _hb.qi(this,a)};_.getAtIndex=function Oi(a){return _hb.ri(this,a)};_.indexOf=function Pi(a){return _hb.si(this,a)};_.isEmpty=function Qi(){return _hb.ui(this)};_.rb=function Ri(){return _hb.vi(this)};_.lastIndexOf=function Si(a){return _hb.wi(this,a)};_.removeAtIndex=function Ti(a){return _hb.yi(this,a)};_.remove=function Ui(a){return _hb.zi(this,a)};_.tb=function Vi(a,b){_hb.Ai(this,a,b)};_.setAtIndex=function Wi(a,b){return _hb.Bi(this,a,b)};_.size=function Xi(){return _hb.Ci(this)};_.toArray=function Yi(){return _hb.Ei(this)};_.sb=function Zi(a){return _hb.Fi(this,a)};Uhb.yZ=$0(18);$hb.$i=function $i(a){var b,c;c=new Vhb.b3;for(b=0;b3.0915926535897933&&c<3.191592653589793){a.j=-1;return a.j}a.j=c=a.M&&$hb.dm(a,a.M*2);a.C[a.q]=0;$hb.Ql(a,a.q,b);a.s[a.q]=0;a.u[a.q]=0;a.B[a.q]=0;a.w[a.q]=0;$hb.nh(a.J[a.q],0,0,0);a.v!=null&&(a.v[a.q]=null);a.t!=null&&(a.t[a.q]=null);a.T=0;return a.q++};$hb.pj=function pj(a,b,c){return $hb.qj(a,b,c,$hb._k(a,b)||$hb._k(a,c)?32:1)};$hb.qj=function qj(a,b,c,d){var e;if(b==c)return -1;for(e=0;e=a.N&&$hb.em(a,a.N*2);a.D[0][a.r]=b;a.D[1][a.r]=c;a.H[a.r]=d;a.F[a.r]=0;a.G[a.r]=0;a.T=0;return a.r++};$hb.rj=function rj(a,b){return $hb.sj(a,b,b.q,b.r)};$hb.sj=function sj(a,b,c,d){var e,f,g,h,i;a.K=a.K|b.K;f=VT(Uhb.nV,bjb,6,b.q,15,1);h=$hb.rl(a,1);i=$hb.rl(a,2);for(e=0;e=a.M&&$hb.dm(a,a.M*2);i=$hb.oj(a,d);$hb.nh(a.J[i],b,c,0);a.A[i]=e;$hb.vl(a,i,f);$hb.Kl(a,i,g);$hb.Al(a,i,h);return true}j=$hb.Aj(a,i,d,e,f,g);$hb.Al(a,i,h);return j};$hb.uj=function uj(a,b,c,d){var e;for(e=0;e=a.N&&$hb.em(a,a.N*2);a.D[0][a.r]=b;a.D[1][a.r]=c;a.H[a.r]=d;a.F[a.r]=0;a.G[a.r]=0;a.T=0;return a.r++};$hb.vj=function vj(a,b,c,d,e,f){var g,h,i;while(a.q+d>a.M)$hb.dm(a,a.M*2);while(a.r+d>a.N)$hb.em(a,a.N*2);g=$hb.Rj(a,b,c);if(g!=-1)return $hb.wj(a,g,d,e,f);h=$hb.Sj(a,b,c);if(h!=-1)return $hb.xj(a,h,d,e,f);g=$hb.nj(a,b,c,0);i=Ajb*(d-2)/d;$hb.jl(a,g,d,g,e,0,Ajb-i,f);a.T=0;return true};$hb.wj=function wj(a,b,c,d,e){var f,g,h,i,j,k;if(d&&$hb.Bn(a,b)>1||!d&&$hb.Bn(a,b)>2)return false;g=0;f=VT(Uhb.lV,_ib,6,4,15,1);for(i=0;iAjb?(f[0]+f[1])/2:(f[0]+f[1])/2+Ajb;h=Ajb*(c-2)/c;$hb.jl(a,b,c,b,d,k-h/2,Ajb-h,e);a.T=0;return true};$hb.xj=function xj(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o,p;j=VT(Uhb.nV,bjb,6,2,15,1);i=VT(Uhb.lV,_ib,6,2,15,1);j[0]=a.D[0][b];j[1]=a.D[1][b];if($hb.Bn(a,j[0])>3)return false;if($hb.Bn(a,j[1])>3)return false;g=0;f=VT(Uhb.lV,_ib,6,4,15,1);for(m=0;mi[0]&&f[l]0?1-h:h;k=Ajb*(c-2)/c;$hb.jl(a,j[h],c-1,j[1-h],d,i[p>0?0:1]+Ajb-k,Ajb-k,e);a.T=0;return true};$hb.yj=function yj(a,b,c){var d,e,f,g,h;e=VT(Uhb.nV,bjb,6,b.q,15,1);g=$hb.rl(a,1);h=$hb.rl(a,2);for(d=0;d1)return false;a.B[b]=H$(a.B[b],-2);a.v!=null&&(a.v[b]=null);a.t!=null&&(a.t[b]=null);if(c==a.C[b]&&d==a.A[b]&&e==((a.u[b]&Fkb)>>>28)-1&&f==(a.u[b]&48))return false;if(c==151||c==152){d=c-149;c=1}a.u[b]&=960;a.C[b]=c;a.A[b]=d;a.s[b]=0;a.B[b]=0;$hb.vl(a,b,e);$hb.Kl(a,b,f);$hb.pl(a,a.w[b]);a.T=0;return true};$hb.Bj=function Bj(a,b,c){if(c){if(a.s[b]>8)return false;++a.s[b]}else{if(a.s[b]<-8)return false;--a.s[b]}a.T=0;return true};$hb.Cj=function Cj(a,b,c){var d,e,f,g,h;f=false;g=a.H[b];if(c==127){f=$hb.Jk(a,b)}else if($hb.Co(a,b,c)){if(c==17||c==9){d=$hb.kl(a,b,a.D[0][b]);e=$hb.kl(a,b,a.D[1][b]);if(c==g){if(d==e||e){h=a.D[0][b];a.D[0][b]=a.D[1][b];a.D[1][b]=h;f=true}}else{if(!d&&e){h=a.D[0][b];a.D[0][b]=a.D[1][b];a.D[1][b]=h}a.H[b]=c;f=true}}else{a.H[b]=c;f=true}}if(f){a.T=(g&103)==(c&103)?a.T&7:0;a.G[b]=0}return f};$hb.Dj=function Dj(a){a.q=0;a.r=0;a.K=false;a.L=false;a.I=0;a.v=null;a.t=null;a.P=null;a.T=0};$hb.Ej=function Ej(a){var b,c,d,e,f,g,h,i;for(g=0;g=b.M&&$hb.dm(b,b.M*2);h=(a.u[c]&hkb)>>19;g=-1;h==1?d==-1?(g=$hb.rl(b,h)):(g=$wnd.Math.min(31,d+((a.u[c]&hkb)>>19!=1&&(a.u[c]&hkb)>>19!=2?-1:(a.u[c]&Gkb)>>21))):h==2&&(e==-1?(g=$hb.rl(b,h)):(g=$wnd.Math.min(31,e+((a.u[c]&hkb)>>19!=1&&(a.u[c]&hkb)>>19!=2?-1:(a.u[c]&Gkb)>>21))));b.C[f]=a.C[c];b.s[f]=a.s[c];b.A[f]=a.A[c];b.u[f]=a.u[c];b.B[f]=b.K?a.B[c]:0;$hb.oh(b.J[f],a.J[c]);b.w[f]=a.w[c];b.v!=null&&(b.v[f]=null);if(a.v!=null&&a.v[c]!=null&&b.K){b.v==null&&(b.v=VT(Uhb.nV,wkb,7,b.C.length,0,2));b.v[f]=_hb.w9(a.v[c],a.v[c].length)}b.t!=null&&(b.t[f]=null);if(a.t!=null&&a.t[c]!=null){b.t==null&&(b.t=VT(Uhb.jV,Hib,10,b.C.length,0,2));b.t[f]=_hb.u9(a.t[c],a.t[c].length)}if(g!=-1){b.u[f]&=-65011713;b.u[f]|=g<<21}++b.q;b.T=0;return f};$hb.Gj=function Gj(a,b,c,d,e,f,g,h){var i,j,k,l;j=b.r;j>=b.N&&$hb.em(b,b.N*2);l=(a.F[c]&Hkb)>>10;k=-1;l==1&&(d==-1?(k=$hb.rl(b,l)):(k=$wnd.Math.min(32,d+((a.F[c]&Hkb)>>10!=1&&(a.F[c]&Hkb)>>10!=2?-1:(a.F[c]&Ikb)>>12))));l==2&&(e==-1?(k=$hb.rl(b,l)):(k=$wnd.Math.min(32,e+((a.F[c]&Hkb)>>10!=1&&(a.F[c]&Hkb)>>10!=2?-1:(a.F[c]&Ikb)>>12))));b.D[0][j]=f;b.D[1][j]=g;i=h&&(a.F[c]&512)!=0?64:a.H[c];b.H[j]=i;b.F[j]=a.F[c];b.G[j]=b.K?a.G[c]:0;if(k!=-1){b.F[j]&=-126977;b.F[j]|=k<<12}++b.r;b.T=0;return j};$hb.Hj=function Hj(a,b,c,d,e,f,g){return $hb.Gj(a,b,c,d,e,f==null?a.D[0][c]:f[a.D[0][c]],f==null?a.D[1][c]:f[a.D[1][c]],g)};$hb.Ij=function Ij(a,b){var c,d;b.v=null;b.t=null;b.K=a.K;b.q=0;for(c=0;ce/2)continue;if(q==p)j=$wnd.Math.abs(p-b);else{h=(s-r)/(p-q);i=-h*p-r;j=$wnd.Math.abs((h*b+c+i)/$wnd.Math.sqrt(h*h+1))}if(j>>28)-1};$hb.Uj=function Uj(a,b){return (a.u[b]&98304)>>15};$hb.Vj=function Vj(a,b){return a.s[b]};$hb.Wj=function Wj(a,b){return a.u[b]&448};$hb.Xj=function Xj(a,b){return a.t==null?null:a.t[b]==null?null:Vhb.E2(a.t[b])};$hb.Yj=function Yj(a,b){return a.t==null?null:a.t[b]};$hb.Zj=function Zj(a,b){return (a.u[b]&hkb)>>19!=1&&(a.u[b]&hkb)>>19!=2?-1:(a.u[b]&Gkb)>>21};$hb.$j=function $j(a,b){return (a.u[b]&hkb)>>19};$hb._j=function _j(a,b){return $hb.gj[a.C[b]]};$hb.ak=function ak(a,b){return a.v==null?null:a.v[b]};$hb.bk=function bk(a,b){var c,d,e;if(a.v==null||a.v[b]==null)return a_(H$(a.B[b],1),0)?'':$hb.gj[a.C[b]];e='';for(d=0;d0&&(e=(Yhb.eeb(e),e+(Yhb.eeb(','),',')));c=a.v[b][d];e=Vhb.D2(e,$hb.gj[c])}return e};$hb.ck=function ck(a,b){return $wnd.Math.abs(a.w[b])};$hb.dk=function dk(a,b){return a.A[b]};$hb.ek=function ek(a,b){return a.u[b]&3};$hb.fk=function fk(a,b){return a.B[b]};$hb.gk=function gk(a,b){return a.u[b]&48};$hb.hk=function hk(a,b){return a.J[b].a};$hb.ik=function ik(a,b){return a.J[b].b};$hb.jk=function jk(a,b){return a.J[b].c};$hb.kk=function kk(a,b){return a.C[b]};$hb.lk=function lk(a){return $hb.mk(a,a.q,a.r,$hb.lj)};$hb.mk=function mk(a,b,c,d){return $hb.nk(a,b,c,d,a.J)};$hb.nk=function nk(a,b,c,d,e){var f,g,h,i,j,k,l,m,n,o;l=false;m=0;for(j=0;j0&&n>7)+((a.G[b]&30720)>>11)};$hb.rk=function rk(a,b){return (a.G[b]&Gjb)>>7};$hb.sk=function sk(a,b){return (a.F[b]&48)>>4};$hb.tk=function tk(a,b){return (a.F[b]&Hkb)>>10!=1&&(a.F[b]&Hkb)>>10!=2?-1:(a.F[b]&Ikb)>>12};$hb.uk=function uk(a,b){return (a.F[b]&Hkb)>>10};$hb.vk=function vk(a,b){var c,d,e,f;c=a.D[0][b];d=a.D[1][b];e=a.J[d].a-a.J[c].a;f=a.J[d].b-a.J[c].b;return $wnd.Math.sqrt(e*e+f*f)};$hb.wk=function wk(a,b,c){var d;for(d=0;da.J[c].a?(d=a.J[c].a):ea.J[c].b?(f=a.J[c].b):g=171&&a.C[b]<=190)return 0;e=0;(a.u[b]&48)==32&&(e-=1);((a.u[b]&48)==16||(a.u[b]&48)==48)&&(e-=2);d=a.s[b];if(d==0&&a.K){R$(H$(a.B[b],Ijb),Ljb)&&(d=-1);R$(H$(a.B[b],Ijb),Kjb)&&(d=1)}a.C[b]==7||a.C[b]==8||a.C[b]==9?(e+=d):a.C[b]==6||a.C[b]==14||a.C[b]==32?(e-=$wnd.Math.abs(d)):a.C[b]==15||a.C[b]==33?c-e-d<=3?(e+=d):(e-=d):a.C[b]==16||a.C[b]==34||a.C[b]==52?c-e-d<=4?(e+=d):(e-=$wnd.Math.abs(d)):a.C[b]==17||a.C[b]==35||a.C[b]==53?c-e-d<=5?(e+=d):(e-=$wnd.Math.abs(d)):(e-=d);return e};$hb.Fk=function Fk(a,b){var c;c=$hb.Gk(a,b);return c+$hb.Ek(a,b,c)};$hb.Gk=function Gk(a,b){var c,d;c=((a.u[b]&Fkb)>>>28)-1;c==-1&&(c=(d=a.C[b]<$hb.hj.length?$hb.hj[a.C[b]]:null,d==null?6:d[d.length-1]));return c};$hb.Hk=function Hk(a,b){var c,d,e,f,g;f=3;for(d=0;d<2;d++){c=a.D[d][b];e=$hb.xk(a,b)+(g=$hb.Gk(a,c),g+$hb.Ek(a,c,g))-$hb.Bn(a,c);f>e&&(f=e)}return f};$hb.Ik=function Ik(a,b){return (a.u[b]&zkb)!=0};$hb.Jk=function Jk(a,b){var c,d,e;d=$hb.Hk(a,b);c=$hb._k(a,a.D[0][b])||$hb._k(a,a.D[1][b]);e=c?32:1;if(a.H[b]==4){a.H[b]=e;a.T=0;return true}if(a.H[b]==2){a.H[b]=26;a.T&=7;if((a.F[b]&128)==0)return true}if(a.H[b]==26){d==3?(a.H[b]=4):(a.H[b]=e);a.T=0;return true}if((24&a.H[b])!=0){a.H[b]=1;a.T&=7;return true}if(!c&&d<2)return false;if(a.H[b]==1){a.H[b]=2;a.T=0;return true}if(d<1)return false;if(a.H[b]==32){a.H[b]=1;a.T=0;return true}return false};$hb.Kk=function Kk(a){var b;a.T=0;a.C=VT(Uhb.nV,bjb,6,a.M,15,1);a.s=VT(Uhb.nV,bjb,6,a.M,15,1);a.w=VT(Uhb.nV,bjb,6,a.M,15,1);a.J=VT(Uhb.GV,Kkb,25,a.M,0,1);for(b=0;b=3&&c<=4||c>=11&&c<=13||c>=19&&c<=31||c>=37&&c<=51||c>=55&&c<=84||c>=87&&c<=103))return false}}return $hb.Fm(a.C[b])};$hb.al=function al(a,b){return a.A[b]==0};$hb.bl=function bl(a,b){var c,d,e,f;if(a.K){if(a_(H$(a.B[b],1),0))return false;if(a.v!=null&&a.v[b]!=null)for(d=a.v[b],e=0,f=d.length;e=5&&c<=9||c>=14&&c<=17||c>=32&&c<=35||c>=52&&c<=53))return false}}return $hb.Gm(a.C[b])};$hb.cl=function cl(a){var b;for(b=0;b>19==b){h==null&&(h=VT(Uhb.A$,vjb,6,32,16,1));h[(a.u[d]&hkb)>>19!=1&&(a.u[d]&hkb)>>19!=2?-1:(a.u[d]&Gkb)>>21]=true}}for(f=0;f>10==b){h==null&&(h=VT(Uhb.A$,vjb,6,32,16,1));h[(a.F[f]&Hkb)>>10!=1&&(a.F[f]&Hkb)>>10!=2?-1:(a.F[f]&Ikb)>>12]=true}}k=0;if(h!=null){j=VT(Uhb.nV,bjb,6,32,15,1);for(i=0;i<32;i++)h[i]&&(j[i]=k++);for(c=0;c>19==b){g=j[(a.u[c]&hkb)>>19!=1&&(a.u[c]&hkb)>>19!=2?-1:(a.u[c]&Gkb)>>21];a.u[c]&=-65011713;a.u[c]|=g<<21}}for(e=0;e>10==b){g=j[(a.F[e]&Hkb)>>10!=1&&(a.F[e]&Hkb)>>10!=2?-1:(a.F[e]&Ikb)>>12];a.F[e]&=-126977;a.F[e]|=g<<12}}}return k};$hb.sl=function sl(a,b){var c;for(c=0;c=-1&&c<=14){a.u[b]&=268435455;a.u[b]|=1+c<<28;if(a.C[b]==6){if(c==-1||c==0||c==2||c==4){a.u[b]&=-49;c==2&&(a.u[b]|=16)}}}};$hb.wl=function wl(a,b,c){a.u[b]&=-98305;a.u[b]|=c<<15};$hb.xl=function xl(a,b,c){a.s[b]=c;a.T=0};$hb.yl=function yl(a,b,c){a.u[b]&=-449;a.u[b]|=c};$hb.zl=function zl(a,b,c){c?(a.u[b]|=Lkb):(a.u[b]&=Okb);a.T&=7};$hb.Al=function Al(a,b,c){var d,e;if(c!=null){if(Yhb.peb(c).length==0)c=null;else{d=$hb.Cm(c);if(d!=0&&Vhb.F2(c,$hb.gj[d])||Vhb.F2(c,'?')){$hb.Ql(a,b,d);c=null}}}if(c==null){a.t!=null&&(a.t[b]=null)}else{a.t==null&&(a.t=VT(Uhb.jV,Hib,10,a.M,0,2));a.t[b]=Yhb.Sdb((e=c,Yhb.Ndb(),e))}};$hb.Bl=function Bl(a,b,c){c!=null&&c.length==0&&(c=null);if(c==null){a.t!=null&&(a.t[b]=null)}else{a.t==null&&(a.t=VT(Uhb.jV,Hib,10,a.M,0,2));a.t[b]=c}};\n$hb.Cl=function Cl(a,b,c,d){var e,f,g;if(c==0){a.u[b]&=Pkb;a.u[b]|=c<<19}else{if(d>=32)return;if(d==-1){g=-1;for(f=0;f>19&&g<((a.u[f]&hkb)>>19!=1&&(a.u[f]&hkb)>>19!=2?-1:(a.u[f]&Gkb)>>21)&&(g=(a.u[f]&hkb)>>19!=1&&(a.u[f]&hkb)>>19!=2?-1:(a.u[f]&Gkb)>>21);for(e=0;e>10&&g<((a.F[e]&Hkb)>>10!=1&&(a.F[e]&Hkb)>>10!=2?-1:(a.F[e]&Ikb)>>12)&&(g=(a.F[e]&Hkb)>>10!=1&&(a.F[e]&Hkb)>>10!=2?-1:(a.F[e]&Ikb)>>12);d=g+1;if(d>=32)return}a.u[b]&=Pkb;a.u[b]|=c<<19|d<<21}a.T&=7};$hb.Dl=function Dl(a,b,c){a.v==null&&(a.v=VT(Uhb.nV,wkb,7,a.M,0,2));Yhb.Ldb(c,Yhb.peb(y_(_hb.W9.prototype.hc,_hb.W9,[])));a.v[b]=c;a.T=0;a.K=true};$hb.El=function El(a,b,c,d){var e;if(c==null){a.v!=null&&(a.v[b]=null);return}if(c.length==1&&!d){e=c[0];a.C[b]!=e&&$hb.Aj(a,b,e,0,-1,0);a.v!=null&&(a.v[b]=null);return}a.v==null&&(a.v=VT(Uhb.nV,wkb,7,a.M,0,2));a.v[b]=c;d&&(a.B[b]=c_(a.B[b],1));a.T=0;a.K=true};$hb.Fl=function Fl(a,b,c,d){a.w[b]=d?-c:c};$hb.Gl=function Gl(a,b,c){c?(a.u[b]|=mkb):(a.u[b]&=-262145)};$hb.Hl=function Hl(a,b,c){a.A[b]=c;a.T&=7};$hb.Il=function Il(a,b,c,d){a.u[b]&=-8;a.u[b]|=c;d&&(a.u[b]|=4)};$hb.Jl=function Jl(a,b,c,d){d?(a.B[b]=c_(a.B[b],c)):(a.B[b]=H$(a.B[b],b_(c)));a.T=0;a.K=true};$hb.Kl=function Kl(a,b,c){a.u[b]&=-49;a.u[b]|=c;a.T&=7};$hb.Ll=function Ll(a,b,c){c?(a.u[b]|=512):(a.u[b]&=-513)};$hb.Ml=function Ml(a,b,c){a.u[b]&=-134217729;c&&(a.u[b]|=Mkb)};$hb.Nl=function Nl(a,b,c){a.J[b].a=c;a.T&=7};$hb.Ol=function Ol(a,b,c){a.J[b].b=c;a.T&=7};$hb.Pl=function Pl(a,b,c){a.J[b].c=c;a.T&=7};$hb.Ql=function Ql(a,b,c){if(c>=0&&c<=190){if(c==151||c==152){a.C[b]=1;a.A[b]=c-149}else{a.C[b]=c;a.A[b]=0}a.u[b]&=268435455;a.T=0}};$hb.Rl=function Rl(a,b,c,d){a.D[b][c]=d;a.T=0};$hb.Sl=function Sl(a,b,c){c?(a.F[b]|=zkb):(a.F[b]&=-131073)};$hb.Tl=function Tl(a,b,c){a.F[b]&=-49;a.F[b]|=c<<4};$hb.Ul=function Ul(a,b,c,d){var e,f,g;if(c==0){a.F[b]&=-130049;a.F[b]|=c<<10}else{if(d>=32)return;if(d==-1){g=-1;for(f=0;f>19&&g<((a.u[f]&hkb)>>19!=1&&(a.u[f]&hkb)>>19!=2?-1:(a.u[f]&Gkb)>>21)&&(g=(a.u[f]&hkb)>>19!=1&&(a.u[f]&hkb)>>19!=2?-1:(a.u[f]&Gkb)>>21);for(e=0;e>10&&g<((a.F[e]&Hkb)>>10!=1&&(a.F[e]&Hkb)>>10!=2?-1:(a.F[e]&Ikb)>>12)&&(g=(a.F[e]&Hkb)>>10!=1&&(a.F[e]&Hkb)>>10!=2?-1:(a.F[e]&Ikb)>>12);d=g+1;if(d>=32)return}a.F[b]&=-130049;a.F[b]|=c<<10|d<<12}a.T&=7};$hb.Vl=function Vl(a,b,c){c?(a.F[b]|=mkb):(a.F[b]&=-262145)};$hb.Wl=function Wl(a,b,c){a.H[b]=c==1?1:c==2?2:c==3?4:32;a.T=0};$hb.Xl=function Xl(a,b,c,d){a.F[b]&=-16777224;a.F[b]|=c;d&&(a.F[b]|=4)};$hb.Yl=function Yl(a,b){a.F[b]|=Nkb};$hb.Zl=function Zl(a,b,c,d){d?(a.G[b]|=c):(a.G[b]&=~c);a.T=0;a.K=true};$hb.$l=function $l(a,b,c){a.H[b]=c;a.T=0};$hb._l=function _l(a,b){a.I=b};$hb.am=function am(a,b){if(a.K!=b){a.K=b;b||$hb.ql(a);a.T=0}};$hb.bm=function bm(a,b){a.T=b};$hb.cm=function cm(a,b){a.S=b};$hb.dm=function dm(a,b){var c,d;a.C=$hb.um(a.C,b);a.s=$hb.um(a.s,b);a.w=$hb.um(a.w,b);d=a.J.length;a.J=$hb.wm(a.J,b);for(c=d;c=1;case 2:return d>=2;case 4:return d>=3;case 32:return true;default:return false;}};$hb.pm=function pm(a,b,c,d){var e,f,g;for(e=0;e=0&&a<$hb.hj.length&&$hb.hj[a]!=null?$hb.hj[a]:a>=171&&a<=190?$hb.fj:$hb.jj};$hb.Am=function Am(a,b,c,d){$hb.mj();var e,f,g;f=c-a;g=d-b;if(g!=0){e=$wnd.Math.atan(f/g);g<0&&(f<0?(e-=Ajb):(e+=Ajb))}else e=f>0?Bjb:fkb;return e};$hb.Bm=function Bm(a,b){$hb.mj();var c;c=a-b;while(cAjb)c-=zjb;return c};$hb.Cm=function Cm(a){$hb.mj();var b;for(b=1;b<$hb.gj.length;b++)if(Vhb.G2(a,$hb.gj[b]))return b;return 0};$hb.Dm=function Dm(a){$hb.mj();switch(a){case 7:case 8:case 9:case 15:case 16:case 17:case 33:case 34:case 35:case 52:case 53:return true;}return false};$hb.Em=function Em(a){$hb.mj();if(a==1||a==6)return false;if($hb.Dm(a))return false;if(a==2||a==10||a==18||a==36||a==54)return false;if(a>103)return false;return true};$hb.Fm=function Fm(a){return a>=3&&a<=4||a>=11&&a<=13||a>=19&&a<=31||a>=37&&a<=51||a>=55&&a<=84||a>=87&&a<=103};$hb.Gm=function Gm(a){return a==1||a>=5&&a<=9||a>=14&&a<=17||a>=32&&a<=35||a>=52&&a<=53};v_(70,1,{70:1,4:1});_.ub=function tm(a){$hb.Jj(this,a)};_.q=0;_.r=0;_.I=0;_.K=false;_.L=false;_.M=0;_.N=0;_.O=0;_.S=false;_.T=0;_.U=0;_.V=0;$hb.lj=24;Uhb.SV=$0(70);$hb.Hm=function Hm(a,b,c,d){var e,f,g,h,i,j,k,l,m;$hb.pt(b,1);d==null&&(d=VT(Uhb.nV,bjb,6,b.q,15,1));h=$hb.rl(a,1);i=$hb.rl(a,2);m=VT(Uhb.A$,vjb,6,b.q,16,1);j=VT(Uhb.nV,bjb,6,b.q,15,1);j[0]=c;m[c]=true;d[c]=$hb.Fj(b,a,c,h,i);g=0;k=0;while(g<=k){for(l=0;l<$hb.Um(b,j[g]);l++){f=b.i[j[g]][l];if(!m[f]){j[++k]=f;m[f]=true;d[f]=$hb.Fj(b,a,f,h,i)}}++g}for(e=0;e1?(a.o[c]+=m-1):a.H[h]==64&&(a.o[c]=1))}}for(i=a.g;i0&&a.s[a.D[1][i]]<0){f=a.D[0][i];g=a.D[1][i]}else if(a.s[a.D[0][i]]<0&&a.s[a.D[1][i]]>0){f=a.D[1][i];g=a.D[0][i]}else continue;if($hb._k(a,f)||$hb._k(a,g))continue;if(a.C[f]<9&&$hb.Bn(a,f)>3||a.C[g]<9&&$hb.Bn(a,g)>3)continue;l=$hb.wn(a,f)!=0;a.s[f]-=1;a.s[g]+=1;if(!l){s=a.H[i];j==1?(a.H[i]=2):(a.H[i]=4);if(s==9||s==17){w=a.D[0][i];r=$hb.ro(a,w);if(a.D[0][r]!=w){a.D[1][r]=a.D[0][r];a.D[1][r]=w}}}a.T=0}}t=0;p=0;n=0;for(e=0;e0){if(!$hb.Sn(a,h)&&$hb.Yk(a,h)){k=$wnd.Math.min($hb.wn(a,h),a.s[h]);if(k!=0&&v>=k){t-=k;u-=k;v-=k;a.s[h]-=k;a.T&=1}}}}q=c?t:u;if(q<0){o=VT(Uhb.nV,bjb,6,p,15,1);p=0;for(f=0;f=o.length-p;m--){d=o[m]&Rkb;if($hb.Yk(a,d)){k=$wnd.Math.min(-q,-a.s[d]);t+=k;q+=k;a.s[d]+=k;a.T&=1}}}return t};$hb.Km=function Km(a,b){var c,d,e,f;if(a.o[b]==2&&a.j[b]==2&&a.n[b][0]==2){for(e=0;e<2;e++){c=$hb.Pm(a,b,a.i[b][e]);if(c!=-1)for(f=0;f=15){for(e=0;e1&&(a.C[a.i[i][m]]==6?(a.u[e]|=dkb):!$hb.Yn(a,a.k[i][m])&&$hb.Yk(a,a.i[i][m])&&(a.u[e]|=Cjb))}}}while(true){k=false;for(c=0;c0&&(20480&a.u[c])==Cjb){for(l=0;l1){i=a.i[c][l];j=a.k[c][l];for(m=0;m=5)for(c=0;c3&&(a.u[c]|=Hkb)}g=(b&5&-2)!=0;for(k=0;k4)return false;i=VT(Uhb.A$,vjb,6,4,16,1);for(h=0;h0.0872664675116539)return false;e[h]=3&iV(f/Bjb);if(i[e[h]])return false;i[e[h]]=true;if((e[h]&1)==0){if(a.H[a.k[b][c[h]]]!=1)return false}else{if(!$hb.gl(a,a.k[b][c[h]],b))return false}}return i[0]&&i[2]};$hb.on=function on(a,b,c,d,e){var f,g,h,i,j,k,l,m;if((!!a.p&&b24)return 3;f=a.e[b];e==null&&(e=VT(Uhb.nV,bjb,6,f,15,1));if(!$hb.nn(a,b,c,d,e))return 3;i=-1;for(j=0;j=0&&b[e]);for(c=0;c=e)return f[d];return e};$hb.wn=function wn(a,b){var c,d,e,f,g,h;if(a.K&&R$(H$(a.B[b],ekb),0))return 0;if(!$hb.Ao(a,b))return 0;$hb.pt(a,1);g=0;for(e=0;e>1}g-=$hb.Ek(a,b,g);f=((a.u[b]&Fkb)>>>28)-1;if(f==-1){h=$hb.zm(a.C[b]);f=h[0];for(d=1;f>>28)-1;if(f==-1){g=$hb.zm(a.C[b]);d=0;while(e>g[d]+c&&d=171&&a.C[b]<=190){c=a.e[b];c>2&&(e-=(c-2)*$hb.kj[1])}}return e};$hb.An=function An(a,b){var c,d;c=a.j[b];for(d=0;d