UNPKG

dgtek-portal-map-package

Version:

This package draws DGtek footprint polygons & checks the address to be in the footprint. This package provides a number of methods for creating, searching and updating the buildings data in DB. Uses web-worker, remote and local DB. For DGtek provisionin

1 lines 101 kB
(()=>{var t={331:function(t,e,r){!function(t){"use strict";var e;function n(){}function i(){i.init.call(this)}function s(t){return void 0===t._maxListeners?i.defaultMaxListeners:t._maxListeners}function o(t,e,r){if(e)t.call(r);else for(var n=t.length,i=p(t,n),s=0;s<n;++s)i[s].call(r)}function a(t,e,r,n){if(e)t.call(r,n);else for(var i=t.length,s=p(t,i),o=0;o<i;++o)s[o].call(r,n)}function u(t,e,r,n,i){if(e)t.call(r,n,i);else for(var s=t.length,o=p(t,s),a=0;a<s;++a)o[a].call(r,n,i)}function l(t,e,r,n,i,s){if(e)t.call(r,n,i,s);else for(var o=t.length,a=p(t,o),u=0;u<o;++u)a[u].call(r,n,i,s)}function f(t,e,r,n){if(e)t.apply(r,n);else for(var i=t.length,s=p(t,i),o=0;o<i;++o)s[o].apply(r,n)}function c(t,e,r,i){var o,a,u,l;if("function"!=typeof r)throw new TypeError('"listener" argument must be a function');if((a=t._events)?(a.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),a=t._events),u=a[e]):(a=t._events=new n,t._eventsCount=0),u){if("function"==typeof u?u=a[e]=i?[r,u]:[u,r]:i?u.unshift(r):u.push(r),!u.warned&&(o=s(t))&&o>0&&u.length>o){u.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+u.length+" "+e+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=u.length,l=f,"function"==typeof console.warn?console.warn(l):console.log(l)}}else u=a[e]=r,++t._eventsCount;return t}function h(t,e,r){var n=!1;function i(){t.removeListener(e,i),n||(n=!0,r.apply(t,arguments))}return i.listener=r,i}function d(t){var e=this._events;if(e){var r=e[t];if("function"==typeof r)return 1;if(r)return r.length}return 0}function p(t,e){for(var r=new Array(e);e--;)r[e]=t[e];return r}n.prototype=Object.create(null),i.EventEmitter=i,i.usingDomains=!1,i.prototype.domain=void 0,i.prototype._events=void 0,i.prototype._maxListeners=void 0,i.defaultMaxListeners=10,i.init=function(){this.domain=null,i.usingDomains&&e.active&&e.Domain,this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=new n,this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},i.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||isNaN(t))throw new TypeError('"n" argument must be a positive number');return this._maxListeners=t,this},i.prototype.getMaxListeners=function(){return s(this)},i.prototype.emit=function(t){var e,r,n,i,s,c,h,d="error"===t;if(c=this._events)d=d&&null==c.error;else if(!d)return!1;if(h=this.domain,d){if(e=arguments[1],!h){if(e instanceof Error)throw e;var p=new Error('Uncaught, unspecified "error" event. ('+e+")");throw p.context=e,p}return e||(e=new Error('Uncaught, unspecified "error" event')),e.domainEmitter=this,e.domain=h,e.domainThrown=!1,h.emit("error",e),!1}if(!(r=c[t]))return!1;var g="function"==typeof r;switch(n=arguments.length){case 1:o(r,g,this);break;case 2:a(r,g,this,arguments[1]);break;case 3:u(r,g,this,arguments[1],arguments[2]);break;case 4:l(r,g,this,arguments[1],arguments[2],arguments[3]);break;default:for(i=new Array(n-1),s=1;s<n;s++)i[s-1]=arguments[s];f(r,g,this,i)}return!0},i.prototype.addListener=function(t,e){return c(this,t,e,!1)},i.prototype.on=i.prototype.addListener,i.prototype.prependListener=function(t,e){return c(this,t,e,!0)},i.prototype.once=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.on(t,h(this,t,e)),this},i.prototype.prependOnceListener=function(t,e){if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');return this.prependListener(t,h(this,t,e)),this},i.prototype.removeListener=function(t,e){var r,i,s,o,a;if("function"!=typeof e)throw new TypeError('"listener" argument must be a function');if(!(i=this._events))return this;if(!(r=i[t]))return this;if(r===e||r.listener&&r.listener===e)0==--this._eventsCount?this._events=new n:(delete i[t],i.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(s=-1,o=r.length;o-- >0;)if(r[o]===e||r[o].listener&&r[o].listener===e){a=r[o].listener,s=o;break}if(s<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new n,this;delete i[t]}else!function(t,e){for(var r=e,n=r+1,i=t.length;n<i;r+=1,n+=1)t[r]=t[n];t.pop()}(r,s);i.removeListener&&this.emit("removeListener",t,a||e)}return this},i.prototype.removeAllListeners=function(t){var e,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new n,this._eventsCount=0):r[t]&&(0==--this._eventsCount?this._events=new n:delete r[t]),this;if(0===arguments.length){for(var i,s=Object.keys(r),o=0;o<s.length;++o)"removeListener"!==(i=s[o])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=new n,this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(e)do{this.removeListener(t,e[e.length-1])}while(e[0]);return this},i.prototype.listeners=function(t){var e,r=this._events;return r&&(e=r[t])?"function"==typeof e?[e.listener||e]:function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(e):[]},i.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):d.call(t,e)},i.prototype.listenerCount=d,i.prototype.eventNames=function(){return this._eventsCount>0?Reflect.ownKeys(this._events):[]};var g=void 0!==r.g?r.g:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},y=[],v=[],m="undefined"!=typeof Uint8Array?Uint8Array:Array,b=!1;function w(){b=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",e=0,r=t.length;e<r;++e)y[e]=t[e],v[t.charCodeAt(e)]=e;v["-".charCodeAt(0)]=62,v["_".charCodeAt(0)]=63}function _(t,e,r){for(var n,i=[],s=e;s<r;s+=3)n=(t[s]<<16)+(t[s+1]<<8)+t[s+2],i.push(y[(o=n)>>18&63]+y[o>>12&63]+y[o>>6&63]+y[63&o]);var o;return i.join("")}function S(t){var e;b||w();for(var r=t.length,n=r%3,i="",s=[],o=16383,a=0,u=r-n;a<u;a+=o)s.push(_(t,a,a+o>u?u:a+o));return 1===n?(e=t[r-1],i+=y[e>>2],i+=y[e<<4&63],i+="=="):2===n&&(e=(t[r-2]<<8)+t[r-1],i+=y[e>>10],i+=y[e>>4&63],i+=y[e<<2&63],i+="="),s.push(i),s.join("")}function E(t,e,r,n,i){var s,o,a=8*i-n-1,u=(1<<a)-1,l=u>>1,f=-7,c=r?i-1:0,h=r?-1:1,d=t[e+c];for(c+=h,s=d&(1<<-f)-1,d>>=-f,f+=a;f>0;s=256*s+t[e+c],c+=h,f-=8);for(o=s&(1<<-f)-1,s>>=-f,f+=n;f>0;o=256*o+t[e+c],c+=h,f-=8);if(0===s)s=1-l;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=l}return(d?-1:1)*o*Math.pow(2,s-n)}function O(t,e,r,n,i,s){var o,a,u,l=8*s-i-1,f=(1<<l)-1,c=f>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=f):(o=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-o))<1&&(o--,u*=2),(e+=o+c>=1?h/u:h*Math.pow(2,1-c))*u>=2&&(o++,u/=2),o+c>=f?(a=0,o=f):o+c>=1?(a=(e*u-1)*Math.pow(2,i),o+=c):(a=e*Math.pow(2,c-1)*Math.pow(2,i),o=0));i>=8;t[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,l+=i;l>0;t[r+d]=255&o,d+=p,o/=256,l-=8);t[r+d-p]|=128*g}var T={}.toString,k=Array.isArray||function(t){return"[object Array]"==T.call(t)};function C(){return A.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function R(t,e){if(C()<e)throw new RangeError("Invalid typed array length");return A.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(e)).__proto__=A.prototype:(null===t&&(t=new A(e)),t.length=e),t}function A(t,e,r){if(!(A.TYPED_ARRAY_SUPPORT||this instanceof A))return new A(t,e,r);if("number"==typeof t){if("string"==typeof e)throw new Error("If encoding is specified then the first argument must be a string");return B(this,t)}return j(this,t,e,r)}function j(t,e,r,n){if("number"==typeof e)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer?function(t,e,r,n){if(e.byteLength,r<0||e.byteLength<r)throw new RangeError("'offset' is out of bounds");if(e.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return e=void 0===r&&void 0===n?new Uint8Array(e):void 0===n?new Uint8Array(e,r):new Uint8Array(e,r,n),A.TYPED_ARRAY_SUPPORT?(t=e).__proto__=A.prototype:t=P(t,e),t}(t,e,r,n):"string"==typeof e?function(t,e,r){if("string"==typeof r&&""!==r||(r="utf8"),!A.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|x(e,r),i=(t=R(t,n)).write(e,r);return i!==n&&(t=t.slice(0,i)),t}(t,e,r):function(t,e){if(I(e)){var r=0|L(e.length);return 0===(t=R(t,r)).length||e.copy(t,0,0,r),t}if(e){if("undefined"!=typeof ArrayBuffer&&e.buffer instanceof ArrayBuffer||"length"in e)return"number"!=typeof e.length||(n=e.length)!=n?R(t,0):P(t,e);if("Buffer"===e.type&&k(e.data))return P(t,e.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,e)}function M(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function B(t,e){if(M(e),t=R(t,e<0?0:0|L(e)),!A.TYPED_ARRAY_SUPPORT)for(var r=0;r<e;++r)t[r]=0;return t}function P(t,e){var r=e.length<0?0:0|L(e.length);t=R(t,r);for(var n=0;n<r;n+=1)t[n]=255&e[n];return t}function L(t){if(t>=C())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+C().toString(16)+" bytes");return 0|t}function I(t){return!(null==t||!t._isBuffer)}function x(t,e){if(I(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var r=t.length;if(0===r)return 0;for(var n=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return ut(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return lt(t).length;default:if(n)return ut(t).length;e=(""+e).toLowerCase(),n=!0}}function D(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return Z(this,e,r);case"utf8":case"utf-8":return G(this,e,r);case"ascii":return K(this,e,r);case"latin1":case"binary":return Q(this,e,r);case"base64":return H(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return X(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function U(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function N(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=A.from(e,n)),I(e))return 0===e.length?-1:q(t,e,r,n,i);if("number"==typeof e)return e&=255,A.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):q(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function q(t,e,r,n,i){var s,o=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;o=2,a/=2,u/=2,r/=2}function l(t,e){return 1===o?t[e]:t.readUInt16BE(e*o)}if(i){var f=-1;for(s=r;s<a;s++)if(l(t,s)===l(e,-1===f?0:s-f)){if(-1===f&&(f=s),s-f+1===u)return f*o}else-1!==f&&(s-=s-f),f=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){for(var c=!0,h=0;h<u;h++)if(l(t,s+h)!==l(e,h)){c=!1;break}if(c)return s}return-1}function F(t,e,r,n){r=Number(r)||0;var i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=e.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(e.substr(2*o,2),16);if(isNaN(a))return o;t[r+o]=a}return o}function $(t,e,r,n){return ft(ut(e,t.length-r),t,r,n)}function Y(t,e,r,n){return ft(function(t){for(var e=[],r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function z(t,e,r,n){return Y(t,e,r,n)}function W(t,e,r,n){return ft(lt(e),t,r,n)}function J(t,e,r,n){return ft(function(t,e){for(var r,n,i,s=[],o=0;o<t.length&&!((e-=2)<0);++o)n=(r=t.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(e,t.length-r),t,r,n)}function H(t,e,r){return 0===e&&r===t.length?S(t):S(t.slice(e,r))}function G(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i<r;){var s,o,a,u,l=t[i],f=null,c=l>239?4:l>223?3:l>191?2:1;if(i+c<=r)switch(c){case 1:l<128&&(f=l);break;case 2:128==(192&(s=t[i+1]))&&(u=(31&l)<<6|63&s)>127&&(f=u);break;case 3:s=t[i+1],o=t[i+2],128==(192&s)&&128==(192&o)&&(u=(15&l)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(f=u);break;case 4:s=t[i+1],o=t[i+2],a=t[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&l)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(f=u)}null===f?(f=65533,c=1):f>65535&&(f-=65536,n.push(f>>>10&1023|55296),f=56320|1023&f),n.push(f),i+=c}return function(t){var e=t.length;if(e<=V)return String.fromCharCode.apply(String,t);for(var r="",n=0;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=V));return r}(n)}A.TYPED_ARRAY_SUPPORT=void 0===g.TYPED_ARRAY_SUPPORT||g.TYPED_ARRAY_SUPPORT,A.poolSize=8192,A._augment=function(t){return t.__proto__=A.prototype,t},A.from=function(t,e,r){return j(null,t,e,r)},A.TYPED_ARRAY_SUPPORT&&(A.prototype.__proto__=Uint8Array.prototype,A.__proto__=Uint8Array),A.alloc=function(t,e,r){return function(t,e,r,n){return M(e),e<=0?R(t,e):void 0!==r?"string"==typeof n?R(t,e).fill(r,n):R(t,e).fill(r):R(t,e)}(null,t,e,r)},A.allocUnsafe=function(t){return B(null,t)},A.allocUnsafeSlow=function(t){return B(null,t)},A.isBuffer=ct,A.compare=function(t,e){if(!I(t)||!I(e))throw new TypeError("Arguments must be Buffers");if(t===e)return 0;for(var r=t.length,n=e.length,i=0,s=Math.min(r,n);i<s;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},A.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},A.concat=function(t,e){if(!k(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return A.alloc(0);var r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;var n=A.allocUnsafe(e),i=0;for(r=0;r<t.length;++r){var s=t[r];if(!I(s))throw new TypeError('"list" argument must be an Array of Buffers');s.copy(n,i),i+=s.length}return n},A.byteLength=x,A.prototype._isBuffer=!0,A.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;e<t;e+=2)U(this,e,e+1);return this},A.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var e=0;e<t;e+=4)U(this,e,e+3),U(this,e+1,e+2);return this},A.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var e=0;e<t;e+=8)U(this,e,e+7),U(this,e+1,e+6),U(this,e+2,e+5),U(this,e+3,e+4);return this},A.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?G(this,0,t):D.apply(this,arguments)},A.prototype.equals=function(t){if(!I(t))throw new TypeError("Argument must be a Buffer");return this===t||0===A.compare(this,t)},A.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},A.prototype.compare=function(t,e,r,n,i){if(!I(t))throw new TypeError("Argument must be a Buffer");if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(e>>>=0),a=Math.min(s,o),u=this.slice(n,i),l=t.slice(e,r),f=0;f<a;++f)if(u[f]!==l[f]){s=u[f],o=l[f];break}return s<o?-1:o<s?1:0},A.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},A.prototype.indexOf=function(t,e,r){return N(this,t,e,r,!0)},A.prototype.lastIndexOf=function(t,e,r){return N(this,t,e,r,!1)},A.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return F(this,t,e,r);case"utf8":case"utf-8":return $(this,t,e,r);case"ascii":return Y(this,t,e,r);case"latin1":case"binary":return z(this,t,e,r);case"base64":return W(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return J(this,t,e,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},A.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var V=4096;function K(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function Q(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function Z(t,e,r){var n,i=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>i)&&(r=i);for(var s="",o=e;o<r;++o)s+=(n=t[o])<16?"0"+n.toString(16):n.toString(16);return s}function X(t,e,r){for(var n=t.slice(e,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function tt(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function et(t,e,r,n,i,s){if(!I(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<s)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function rt(t,e,r,n){e<0&&(e=65535+e+1);for(var i=0,s=Math.min(t.length-r,2);i<s;++i)t[r+i]=(e&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function nt(t,e,r,n){e<0&&(e=4294967295+e+1);for(var i=0,s=Math.min(t.length-r,4);i<s;++i)t[r+i]=e>>>8*(n?i:3-i)&255}function it(t,e,r,n,i,s){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function st(t,e,r,n,i){return i||it(t,0,r,4),O(t,e,r,n,23,4),r+4}function ot(t,e,r,n,i){return i||it(t,0,r,8),O(t,e,r,n,52,8),r+8}A.prototype.slice=function(t,e){var r,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(e=void 0===e?n:~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),e<t&&(e=t),A.TYPED_ARRAY_SUPPORT)(r=this.subarray(t,e)).__proto__=A.prototype;else{var i=e-t;r=new A(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+t]}return r},A.prototype.readUIntLE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n},A.prototype.readUIntBE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},A.prototype.readUInt8=function(t,e){return e||tt(t,1,this.length),this[t]},A.prototype.readUInt16LE=function(t,e){return e||tt(t,2,this.length),this[t]|this[t+1]<<8},A.prototype.readUInt16BE=function(t,e){return e||tt(t,2,this.length),this[t]<<8|this[t+1]},A.prototype.readUInt32LE=function(t,e){return e||tt(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},A.prototype.readUInt32BE=function(t,e){return e||tt(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},A.prototype.readIntLE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=this[t],i=1,s=0;++s<e&&(i*=256);)n+=this[t+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*e)),n},A.prototype.readIntBE=function(t,e,r){t|=0,e|=0,r||tt(t,e,this.length);for(var n=e,i=1,s=this[t+--n];n>0&&(i*=256);)s+=this[t+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*e)),s},A.prototype.readInt8=function(t,e){return e||tt(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},A.prototype.readInt16LE=function(t,e){e||tt(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},A.prototype.readInt16BE=function(t,e){e||tt(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},A.prototype.readInt32LE=function(t,e){return e||tt(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},A.prototype.readInt32BE=function(t,e){return e||tt(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},A.prototype.readFloatLE=function(t,e){return e||tt(t,4,this.length),E(this,t,!0,23,4)},A.prototype.readFloatBE=function(t,e){return e||tt(t,4,this.length),E(this,t,!1,23,4)},A.prototype.readDoubleLE=function(t,e){return e||tt(t,8,this.length),E(this,t,!0,52,8)},A.prototype.readDoubleBE=function(t,e){return e||tt(t,8,this.length),E(this,t,!1,52,8)},A.prototype.writeUIntLE=function(t,e,r,n){t=+t,e|=0,r|=0,n||et(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[e]=255&t;++s<r&&(i*=256);)this[e+s]=t/i&255;return e+r},A.prototype.writeUIntBE=function(t,e,r,n){t=+t,e|=0,r|=0,n||et(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[e+i]=255&t;--i>=0&&(s*=256);)this[e+i]=t/s&255;return e+r},A.prototype.writeUInt8=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,1,255,0),A.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[e]=255&t,e+1},A.prototype.writeUInt16LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,65535,0),A.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):rt(this,t,e,!0),e+2},A.prototype.writeUInt16BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,65535,0),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):rt(this,t,e,!1),e+2},A.prototype.writeUInt32LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,4294967295,0),A.TYPED_ARRAY_SUPPORT?(this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t):nt(this,t,e,!0),e+4},A.prototype.writeUInt32BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,4294967295,0),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):nt(this,t,e,!1),e+4},A.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);et(this,t,e,r,i-1,-i)}var s=0,o=1,a=0;for(this[e]=255&t;++s<r&&(o*=256);)t<0&&0===a&&0!==this[e+s-1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},A.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e|=0,!n){var i=Math.pow(2,8*r-1);et(this,t,e,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[e+s]=255&t;--s>=0&&(o*=256);)t<0&&0===a&&0!==this[e+s+1]&&(a=1),this[e+s]=(t/o>>0)-a&255;return e+r},A.prototype.writeInt8=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,1,127,-128),A.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[e]=255&t,e+1},A.prototype.writeInt16LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,32767,-32768),A.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8):rt(this,t,e,!0),e+2},A.prototype.writeInt16BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,2,32767,-32768),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>8,this[e+1]=255&t):rt(this,t,e,!1),e+2},A.prototype.writeInt32LE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,2147483647,-2147483648),A.TYPED_ARRAY_SUPPORT?(this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24):nt(this,t,e,!0),e+4},A.prototype.writeInt32BE=function(t,e,r){return t=+t,e|=0,r||et(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),A.TYPED_ARRAY_SUPPORT?(this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t):nt(this,t,e,!1),e+4},A.prototype.writeFloatLE=function(t,e,r){return st(this,t,e,!0,r)},A.prototype.writeFloatBE=function(t,e,r){return st(this,t,e,!1,r)},A.prototype.writeDoubleLE=function(t,e,r){return ot(this,t,e,!0,r)},A.prototype.writeDoubleBE=function(t,e,r){return ot(this,t,e,!1,r)},A.prototype.copy=function(t,e,r,n){if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);var i,s=n-r;if(this===t&&r<e&&e<n)for(i=s-1;i>=0;--i)t[i+e]=this[i+r];else if(s<1e3||!A.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)t[i+e]=this[i+r];else Uint8Array.prototype.set.call(t,this.subarray(r,r+s),e);return s},A.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===t.length){var i=t.charCodeAt(0);i<256&&(t=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!A.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;var s;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(s=e;s<r;++s)this[s]=t;else{var o=I(t)?t:ut(new A(t,n).toString()),a=o.length;for(s=0;s<r-e;++s)this[s+e]=o[s%a]}return this};var at=/[^+\/0-9A-Za-z-_]/g;function ut(t,e){var r;e=e||1/0;for(var n=t.length,i=null,s=[],o=0;o<n;++o){if((r=t.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(e-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;s.push(r)}else if(r<2048){if((e-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function lt(t){return function(t){var e,r,n,i,s,o;b||w();var a=t.length;if(a%4>0)throw new Error("Invalid string. Length must be a multiple of 4");s="="===t[a-2]?2:"="===t[a-1]?1:0,o=new m(3*a/4-s),n=s>0?a-4:a;var u=0;for(e=0,r=0;e<n;e+=4,r+=3)i=v[t.charCodeAt(e)]<<18|v[t.charCodeAt(e+1)]<<12|v[t.charCodeAt(e+2)]<<6|v[t.charCodeAt(e+3)],o[u++]=i>>16&255,o[u++]=i>>8&255,o[u++]=255&i;return 2===s?(i=v[t.charCodeAt(e)]<<2|v[t.charCodeAt(e+1)]>>4,o[u++]=255&i):1===s&&(i=v[t.charCodeAt(e)]<<10|v[t.charCodeAt(e+1)]<<4|v[t.charCodeAt(e+2)]>>2,o[u++]=i>>8&255,o[u++]=255&i),o}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(at,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function ft(t,e,r,n){for(var i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function ct(t){return null!=t&&(!!t._isBuffer||ht(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&ht(t.slice(0,0))}(t))}function ht(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}function dt(){throw new Error("setTimeout has not been defined")}function pt(){throw new Error("clearTimeout has not been defined")}var gt=dt,yt=pt;function vt(t){if(gt===setTimeout)return setTimeout(t,0);if((gt===dt||!gt)&&setTimeout)return gt=setTimeout,setTimeout(t,0);try{return gt(t,0)}catch(e){try{return gt.call(null,t,0)}catch(e){return gt.call(this,t,0)}}}"function"==typeof g.setTimeout&&(gt=setTimeout),"function"==typeof g.clearTimeout&&(yt=clearTimeout);var mt,bt=[],wt=!1,_t=-1;function St(){wt&&mt&&(wt=!1,mt.length?bt=mt.concat(bt):_t=-1,bt.length&&Et())}function Et(){if(!wt){var t=vt(St);wt=!0;for(var e=bt.length;e;){for(mt=bt,bt=[];++_t<e;)mt&&mt[_t].run();_t=-1,e=bt.length}mt=null,wt=!1,function(t){if(yt===clearTimeout)return clearTimeout(t);if((yt===pt||!yt)&&clearTimeout)return yt=clearTimeout,clearTimeout(t);try{yt(t)}catch(e){try{return yt.call(null,t)}catch(e){return yt.call(this,t)}}}(t)}}function Ot(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];bt.push(new Tt(t,e)),1!==bt.length||wt||vt(Et)}function Tt(t,e){this.fun=t,this.array=e}Tt.prototype.run=function(){this.fun.apply(null,this.array)};var kt=g.performance||{};kt.now||kt.mozNow||kt.msNow||kt.oNow||kt.webkitNow;var Ct="function"==typeof Object.create?function(t,e){t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}})}:function(t,e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t},Rt=/%[sdj%]/g;function At(t){if(!Ft(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(Pt(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,s=String(t).replace(Rt,(function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),o=n[r];r<i;o=n[++r])qt(o)||!zt(o)?s+=" "+o:s+=" "+Pt(o);return s}function jt(t,e){if($t(g.process))return function(){return jt(t,e).apply(this,arguments)};var r=!1;return function(){return r||(console.error(e),r=!0),t.apply(this,arguments)}}var Mt,Bt={};function Pt(t,e){var r={seen:[],stylize:It};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),Nt(e)?r.showHidden=e:e&&Vt(r,e),$t(r.showHidden)&&(r.showHidden=!1),$t(r.depth)&&(r.depth=2),$t(r.colors)&&(r.colors=!1),$t(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=Lt),xt(r,t,r.depth)}function Lt(t,e){var r=Pt.styles[e];return r?"["+Pt.colors[r][0]+"m"+t+"["+Pt.colors[r][1]+"m":t}function It(t,e){return t}function xt(t,e,r){if(t.customInspect&&e&&Ht(e.inspect)&&e.inspect!==Pt&&(!e.constructor||e.constructor.prototype!==e)){var n=e.inspect(r,t);return Ft(n)||(n=xt(t,n,r)),n}var i=function(t,e){if($t(e))return t.stylize("undefined","undefined");if(Ft(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return n=e,"number"==typeof n?t.stylize(""+e,"number"):Nt(e)?t.stylize(""+e,"boolean"):qt(e)?t.stylize("null","null"):void 0;var n}(t,e);if(i)return i;var s=Object.keys(e),o=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(s);if(t.showHidden&&(s=Object.getOwnPropertyNames(e)),Jt(e)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return Dt(e);if(0===s.length){if(Ht(e)){var a=e.name?": "+e.name:"";return t.stylize("[Function"+a+"]","special")}if(Yt(e))return t.stylize(RegExp.prototype.toString.call(e),"regexp");if(Wt(e))return t.stylize(Date.prototype.toString.call(e),"date");if(Jt(e))return Dt(e)}var u,l,f="",c=!1,h=["{","}"];return l=e,Array.isArray(l)&&(c=!0,h=["[","]"]),Ht(e)&&(f=" [Function"+(e.name?": "+e.name:"")+"]"),Yt(e)&&(f=" "+RegExp.prototype.toString.call(e)),Wt(e)&&(f=" "+Date.prototype.toUTCString.call(e)),Jt(e)&&(f=" "+Dt(e)),0!==s.length||c&&0!=e.length?r<0?Yt(e)?t.stylize(RegExp.prototype.toString.call(e),"regexp"):t.stylize("[Object]","special"):(t.seen.push(e),u=c?function(t,e,r,n,i){for(var s=[],o=0,a=e.length;o<a;++o)Kt(e,String(o))?s.push(Ut(t,e,r,n,String(o),!0)):s.push("");return i.forEach((function(i){i.match(/^\d+$/)||s.push(Ut(t,e,r,n,i,!0))})),s}(t,e,r,o,s):s.map((function(n){return Ut(t,e,r,o,n,c)})),t.seen.pop(),function(t,e,r){return t.reduce((function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n  ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(u,f,h)):h[0]+f+h[1]}function Dt(t){return"["+Error.prototype.toString.call(t)+"]"}function Ut(t,e,r,n,i,s){var o,a,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?a=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(a=t.stylize("[Setter]","special")),Kt(n,i)||(o="["+i+"]"),a||(t.seen.indexOf(u.value)<0?(a=qt(r)?xt(t,u.value,null):xt(t,u.value,r-1)).indexOf("\n")>-1&&(a=s?a.split("\n").map((function(t){return"  "+t})).join("\n").substr(2):"\n"+a.split("\n").map((function(t){return"   "+t})).join("\n")):a=t.stylize("[Circular]","special")),$t(o)){if(s&&i.match(/^\d+$/))return a;(o=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(o=o.substr(1,o.length-2),o=t.stylize(o,"name")):(o=o.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),o=t.stylize(o,"string"))}return o+": "+a}function Nt(t){return"boolean"==typeof t}function qt(t){return null===t}function Ft(t){return"string"==typeof t}function $t(t){return void 0===t}function Yt(t){return zt(t)&&"[object RegExp]"===Gt(t)}function zt(t){return"object"==typeof t&&null!==t}function Wt(t){return zt(t)&&"[object Date]"===Gt(t)}function Jt(t){return zt(t)&&("[object Error]"===Gt(t)||t instanceof Error)}function Ht(t){return"function"==typeof t}function Gt(t){return Object.prototype.toString.call(t)}function Vt(t,e){if(!e||!zt(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t}function Kt(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function Qt(){this.head=null,this.tail=null,this.length=0}Pt.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},Pt.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},Qt.prototype.push=function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length},Qt.prototype.unshift=function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length},Qt.prototype.shift=function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}},Qt.prototype.clear=function(){this.head=this.tail=null,this.length=0},Qt.prototype.join=function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r},Qt.prototype.concat=function(t){if(0===this.length)return A.alloc(0);if(1===this.length)return this.head.data;for(var e=A.allocUnsafe(t>>>0),r=this.head,n=0;r;)r.data.copy(e,n),n+=r.data.length,r=r.next;return e};var Zt=A.isEncoding||function(t){switch(t&&t.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function Xt(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!Zt(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=ee;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=re;break;default:return void(this.write=te)}this.charBuffer=new A(6),this.charReceived=0,this.charLength=0}function te(t){return t.toString(this.encoding)}function ee(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function re(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}Xt.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var s=this.surrogateSize;return this.charLength+=s,this.charReceived+=s,this.charBuffer.copy(this.charBuffer,s,0,s),t.copy(this.charBuffer,0,0,s),e.substring(0,i)}return e},Xt.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},Xt.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e},se.ReadableState=ie;var ne=function(t){if($t(Mt)&&(Mt=""),t=t.toUpperCase(),!Bt[t])if(new RegExp("\\b"+t+"\\b","i").test(Mt)){Bt[t]=function(){var e=At.apply(null,arguments);console.error("%s %d: %s",t,0,e)}}else Bt[t]=function(){};return Bt[t]}("stream");function ie(t,e){t=t||{},this.objectMode=!!t.objectMode,e instanceof Le&&(this.objectMode=this.objectMode||!!t.readableObjectMode);var r=t.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new Qt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(this.decoder=new Xt(t.encoding),this.encoding=t.encoding)}function se(t){if(!(this instanceof se))return new se(t);this._readableState=new ie(t,this),this.readable=!0,t&&"function"==typeof t.read&&(this._read=t.read),i.call(this)}function oe(t,e,r,n,i){var s=function(t,e){var r=null;return ct(e)||"string"==typeof e||null==e||t.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}(e,r);if(s)t.emit("error",s);else if(null===r)e.reading=!1,function(t,e){if(!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,le(t)}}(t,e);else if(e.objectMode||r&&r.length>0)if(e.ended&&!i){var o=new Error("stream.push() after EOF");t.emit("error",o)}else if(e.endEmitted&&i){var a=new Error("stream.unshift() after end event");t.emit("error",a)}else{var u;!e.decoder||i||n||(r=e.decoder.write(r),u=!e.objectMode&&0===r.length),i||(e.reading=!1),u||(e.flowing&&0===e.length&&!e.sync?(t.emit("data",r),t.read(0)):(e.length+=e.objectMode?1:r.length,i?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&le(t))),function(t,e){e.readingMore||(e.readingMore=!0,Ot(ce,t,e))}(t,e)}else i||(e.reading=!1);return function(t){return!t.ended&&(t.needReadable||t.length<t.highWaterMark||0===t.length)}(e)}Ct(se,i),se.prototype.push=function(t,e){var r=this._readableState;return r.objectMode||"string"!=typeof t||(e=e||r.defaultEncoding)!==r.encoding&&(t=A.from(t,e),e=""),oe(this,r,t,e,!1)},se.prototype.unshift=function(t){return oe(this,this._readableState,t,"",!0)},se.prototype.isPaused=function(){return!1===this._readableState.flowing},se.prototype.setEncoding=function(t){return this._readableState.decoder=new Xt(t),this._readableState.encoding=t,this};var ae=8388608;function ue(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=ae?t=ae:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function le(t){var e=t._readableState;e.needReadable=!1,e.emittedReadable||(ne("emitReadable",e.flowing),e.emittedReadable=!0,e.sync?Ot(fe,t):fe(t))}function fe(t){ne("emit readable"),t.emit("readable"),pe(t)}function ce(t,e){for(var r=e.length;!e.reading&&!e.flowing&&!e.ended&&e.length<e.highWaterMark&&(ne("maybeReadMore read 0"),t.read(0),r!==e.length);)r=e.length;e.readingMore=!1}function he(t){ne("readable nexttick read 0"),t.read(0)}function de(t,e){e.reading||(ne("resume read 0"),t.read(0)),e.resumeScheduled=!1,e.awaitDrain=0,t.emit("resume"),pe(t),e.flowing&&!e.reading&&t.read(0)}function pe(t){var e=t._readableState;for(ne("flow",e.flowing);e.flowing&&null!==t.read(););}function ge(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.head.data:e.buffer.concat(e.length),e.buffer.clear()):r=function(t,e,r){var n;return t<e.head.data.length?(n=e.head.data.slice(0,t),e.head.data=e.head.data.slice(t)):n=t===e.head.data.length?e.shift():r?function(t,e){var r=e.head,n=1,i=r.data;for(t-=i.length;r=r.next;){var s=r.data,o=t>s.length?s.length:t;if(o===s.length?i+=s:i+=s.slice(0,t),0==(t-=o)){o===s.length?(++n,r.next?e.head=r.next:e.head=e.tail=null):(e.head=r,r.data=s.slice(o));break}++n}return e.length-=n,i}(t,e):function(t,e){var r=A.allocUnsafe(t),n=e.head,i=1;for(n.data.copy(r),t-=n.data.length;n=n.next;){var s=n.data,o=t>s.length?s.length:t;if(s.copy(r,r.length-t,0,o),0==(t-=o)){o===s.length?(++i,n.next?e.head=n.next:e.head=e.tail=null):(e.head=n,n.data=s.slice(o));break}++i}return e.length-=i,r}(t,e),n}(t,e.buffer,e.decoder),r);var r}function ye(t){var e=t._readableState;if(e.length>0)throw new Error('"endReadable()" called on non-empty stream');e.endEmitted||(e.ended=!0,Ot(ve,e,t))}function ve(t,e){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}function me(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}function be(){}function we(t,e,r){this.chunk=t,this.encoding=e,this.callback=r,this.next=null}function _e(t,e){Object.defineProperty(this,"buffer",{get:jt((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.")}),t=t||{},this.objectMode=!!t.objectMode,e instanceof Le&&(this.objectMode=this.objectMode||!!t.writableObjectMode);var r=t.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var i=!1===t.decodeStrings;this.decodeStrings=!i,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,i=r.writecb;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,i){--e.pendingcb,r?Ot(i,n):i(n),t._writableState.errorEmitted=!0,t.emit("error",n)}(t,r,n,e,i);else{var s=Ce(r);s||r.corked||r.bufferProcessing||!r.bufferedRequest||ke(t,r),n?Ot(Te,t,r,s,i):Te(t,r,s,i)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new je(this)}function Se(t){if(!(this instanceof Se||this instanceof Le))return new Se(t);this._writableState=new _e(t,this),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev)),i.call(this)}function Ee(t,e,r,n,i){r=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=A.from(e,r)),e}(e,r,n),A.isBuffer(r)&&(n="buffer");var s=e.objectMode?1:r.length;e.length+=s;var o=e.length<e.highWaterMark;if(o||(e.needDrain=!0),e.writing||e.corked){var a=e.lastBufferedRequest;e.lastBufferedRequest=new we(r,n,i),a?a.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else Oe(t,e,!1,s,r,n,i);return o}function Oe(t,e,r,n,i,s,o){e.writelen=n,e.writecb=o,e.writing=!0,e.sync=!0,r?t._writev(i,e.onwrite):t._write(i,s,e.onwrite),e.sync=!1}function Te(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),Ae(t,e)}function ke(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var o=0;r;)i[o]=r,r=r.next,o+=1;Oe(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new je(e)}else{for(;r;){var a=r.chunk,u=r.encoding,l=r.callback;if(Oe(t,e,!1,e.objectMode?1:a.length,a,u,l),r=r.next,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequestCount=0,e.bufferedRequest=r,e.bufferProcessing=!1}function Ce(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function Re(t,e){e.prefinished||(e.prefinished=!0,t.emit("prefinish"))}function Ae(t,e){var r=Ce(e);return r&&(0===e.pendingcb?(Re(t,e),e.finished=!0,t.emit("finish")):Re(t,e)),r}function je(t){var e=this;this.next=null,this.entry=null,this.finish=function(r){var n=e.entry;for(e.entry=null;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}}se.prototype.read=function(t){ne("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&(e.length>=e.highWaterMark||e.ended))return ne("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?ye(this):le(this),null;if(0===(t=ue(t,e))&&e.ended)return 0===e.length&&ye(this),null;var n,i=e.needReadable;return ne("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&ne("length less than watermark",i=!0),e.ended||e.reading?ne("reading or ended",i=!1):i&&(ne("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=ue(r,e))),null===(n=t>0?ge(t,e):null)?(e.needReadable=!0,t=0):e.length-=t,0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&ye(this)),null!==n&&this.emit("data",n),n},se.prototype._read=function(t){this.emit("error",new Error("not implemented"))},se.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,ne("pipe count=%d opts=%j",n.pipesCount,e);var i=e&&!1===e.end?l:o;function s(t){ne("onunpipe"),t===r&&l()}function o(){ne("onend"),t.end()}n.endEmitted?Ot(i):r.once("end",i),t.on("unpipe",s);var a=function(t){return function(){var e=t._readableState;ne("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&t.listeners("data").length&&(e.flowing=!0,pe(t))}}(r);t.on("drain",a);var u=!1;function l(){ne("cleanup"),t.removeListener("close",d),t.removeListener("finish",p),t.removeListener("drain",a),t.removeListener("error",h),t.removeListener("unpipe",s),r.removeListener("end",o),r.removeListener("end",l),r.removeListener("data",c),u=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||a()}var f=!1;function c(e){ne("ondata"),f=!1,!1!==t.write(e)||f||((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==me(n.pipes,t))&&!u&&(ne("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,f=!0),r.pause())}function h(e){ne("onerror",e),g(),t.removeListener("error",h),0===function(t,e){return t.listeners(e).length}(t,"error")&&t.emit("error",e)}function d(){t.removeListener("finish",p),g()}function p(){ne("onfinish"),t.removeListener("close",d),g()}function g(){ne("unpipe"),r.unpipe(t)}return r.on("data",c),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",d),t.once("finish",p),t.emit("pipe",r),n.flowing||(ne("pipe resume"),r.resume()),t},se.prototype.unpipe=function(t){var e=this._readableState;if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this)),this;if(!t){var r=e.pipes,n=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var i=0;i<n;i++)r[i].emit("unpipe",this);return this}var s=me(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this)),this},se.prototype.on=function(t,e){var r=i.prototype.on.call(this,t,e);if("data"===t)!1!==this._readableState.flowing&&this.resume();else if("readable"===t){var n=this._readableState;n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.emittedReadable=!1,n.reading?n.length&&le(this):Ot(he,this))}return r},se.prototype.addListener=se.prototype.on,se.prototype.resume=function(){var t=this._readableState;return t.flowing||(ne("resume"),t.flowing=!0,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,Ot(de,t,e))}(this,t)),this},se.prototype.pause=function(){return ne("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(ne("pause"),this._readableState.flowing=!1,this.emit("pause")),this},se.prototype.wrap=function(t){var e=this._readableState,r=!1,n=this;for(var i in t.on("end",(function(){if(ne("wrapped end"),e.decoder&&!e.ended){var t=e.decoder.end();t&&t.length&&n.push(t)}n.push(null)})),t.on("data",(function(i){ne("wrapped data"),e.decoder&&(i=e.decoder.write(i)),e.objectMode&&null==i||(e.objectMode||i&&i.length)&&(n.push(i)||(r=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));return function(t,e){for(var r=0,n=t.length;r<n;r++)e(t[r],r)}(["error","close","destroy","pause","resume"],(function(e){t.on(e,n.emit.bind(n,e))})),n._read=function(e){ne("wrapped _read",e),r&&(r=!1,t.resume())},n},se._fromList=ge,Se.WritableState=_e,Ct(Se,i),_e.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},Se.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},Se.prototype.write=function(t,e,r){var n=this._writableState,i=!1;return"function"==typeof e&&(r=e,e=null),A.isBuffer(t)?e="buffer":e||(e=n.defaultEncoding),"function"!=typeof r&&(r=be),n.ended?function(t,e){var r=new Error("write after end");t.emit("error",r),Ot(e,r)}(this,r):function(t,e,r,n){var i=!0,s=!1;return null===r?s=new TypeError("May not write null values to stream"):A.isBuffer(r)||"string"==typeof r||void 0===r||e.objectMode||(s=new TypeError("Invalid non-string/buffer chunk")),s&&(t.emit("error",s),Ot(n,s),i=!1),i}(this,n,t,r)&&(n.pendingcb++,i=Ee(this,n,t,e,r)),i},Se.prototype.cork=function(){this._writableState.corked++},Se.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.finished||t.bufferProcessing||!t.bufferedRequest||ke(this,t))},Se.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new TypeError("Unknown encoding: "+t);return this._writableState.defaultEncoding=t,this},Se.prototype._write=function(t,e,r){r(new Error("not implemented"))},Se.prototype._writev=null,Se.prototype.end=function(t,e,r){var n=this._writableState;"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(t,e,r){e.ending=!0,Ae(t,e),r&&(e.finished?Ot(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r)},Ct(Le,se);for(var Me=Object.keys(Se.prototype),Be=0;Be<Me.length;Be++){var Pe=Me[Be];Le.prototype[Pe]||(Le.prototype[Pe]=Se.prototype[Pe])}function Le(t){if(!(this instanceof Le))return new Le(t);se.call(this,t),Se.call(this,t),t&&!1===t.readable&&(this.readable=!1),t&&!1===t.writable&&(this.writable=!1),this.allowHalfOpen=!0,t&&!1===t.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",Ie)}function Ie(){this.allowHalfOpen||this._writableState.ended||Ot(xe,this)}function xe(t){t.end()}function De(t){this.afterTransform=function(e,r){return function(t,e,r){var n=t._transformState;n.transforming=!1;var i=n.writecb;if(!i)return t.emit("error",new Error("no writecb in Transform class"));n.writechunk=null,n.writecb=null,null!=r&&t.push(r),i(e);var s=t._readableState;s.reading=!1,(s.needReadable||s.length<s.highWaterMark)&&t._read(s.highWaterMark)}(t,e,r)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null,this.writeencoding=null}function Ue(t){if(!(this instanceof Ue))return new Ue(t);Le.call(this,t),this._transformState=new De(this);var e=this;this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.once("prefinish",(function(){"function"==typeof this._flush?this._flush((function(t){Ne(e,t)})):Ne(e)}))}function Ne(t,e){if(e)return t.emit("error",e);var r=t._writableState,n=t._transformState;if(r.length)throw new Error("Calling transform done when ws.length != 0");if(n.transforming)throw new Error("Calling transform done when still transforming");return t.push(null)}function qe(t){if(!(this instanceof qe))return new qe(t);Ue.call(this,t)}function Fe(){i.call(this)}function $e(t){return($e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function Ye(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function ze(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}function We(t,e,r){return e&&ze(t.prototype,e),r&&ze(t,r),t}function Je(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function He(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter((function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})))),n.forEach((function(e){Je(t,e,r[e])}))}return t}function Ge(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&Ke(t,e)}function Ve(t){return(Ve=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function Ke(t,e){return(Ke=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function Qe(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t):e}function Ze(t){return function(t){if(Array.isArray(t))return t}(t)||tr(t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function Xe(t){return function(t){if(Array.isArray(t)){for(var e=0,r=new Array(t.length);e<t.length;e++)r[e]=t[e];return r}}(t)||tr(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function tr(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}Ct(Ue,Le),Ue.prototype.push=function(t,e){return this._transformState.needTransform=!1,Le.prototype.push.call(this,t,e)},Ue.prototype._transform=function(t,e,r){throw new Error("Not implemented")},Ue.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},Ue.prototype._read=function(t){var e=this._transformState;null!==e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0},Ct(qe,Ue),qe.prototype._transform=function(t,e,r){r(null,t)},Ct(Fe,i),Fe.Readable=se,Fe.Writable=Se,Fe.Duplex=Le,Fe.Transform=Ue,Fe.PassThrough=qe,Fe.Stream=Fe,Fe.prototype.pipe=function(t,e){var r=this;function n(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function s(){r.readable&&r.resume&&r.resume()}r.on("data",n),t.on("drain",s),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var o=!1;function a(){o||(o=!0,t.end())}function u(){o||(o=!0,"function"==typeof t.destroy&&t.destroy())}function l(t){if(f(),0===i.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",n),t.removeListener("drain",s),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",l),t.removeListener("error",l),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",l),t.on("error",l),r.on("end",f),r.on("close",f),t.on("close",f),t.emit("pipe",r),t};var er="\n",rr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==r.g?r.g:"undefined"!=typeof self?self:{},nr="__lodash_hash_undefined__",ir="[object Function]",sr="[object GeneratorFunction]",or=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ar=/^\w*$/,ur=/^\./,lr=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fr=/\\(\\)?/g,cr=/^\[object .+?Constructor\]$/,hr="object"==typeof rr&&rr&&rr.Object===Object&&rr,dr="object"==typeof self&&self&&self.Object===Object&&self,pr=hr||dr||Function("return this")();var gr,yr=Array.prototype,vr=Function.prototype,mr=Object.prototype,br=pr["__core-js_shared__"],wr=(gr=/[^.]+$/.exec(br&&br.keys&&br.keys.IE_PROTO||""))?"Symbol(src)_1."+gr:"",_r=vr.toString,Sr=mr.hasOwnProperty,Er=mr.toString,Or=RegExp("^"+_r.call(Sr).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Tr=pr.Symbol,kr=yr.splice,Cr=Ur(pr,"Map"),Rr=Ur(Object,"create"),Ar=Tr?Tr.prototype:void 0,jr=Ar?Ar.toString:void 0;function Mr(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Br(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Pr(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Lr(t,e){for(var r=t.length;r--;)if((n=t[r][0])===(i=e)||n!=n&&i!=i)return r;var n,i;return-1}function Ir(t,e){for(var r=0,n=(e=function(t,e){if($r(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!zr(t))||ar.test(t)||!or.test(t)||null!=e&&t in Object(e)}(e,t)?[e]:(i=e,$r(i)?i:Nr(i))).length;null!=t&&r<n;)t=t[qr(e[r++])];var i;return r&&r==n?t:void 0}function xr(t){return!(!Yr(t)||(e=t,wr&&wr in e))&&(function(t){var e=Yr(t)?Er.call(t):"";return e==ir||e==sr}(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t)?Or:cr).test(function(t){if(null!=t){try{return _r.call(t)}catch(t){}try{return t+""}catch(t){}}return""}(t));var e}function Dr(t,e){var r=t.__data__;return function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t}(e)?r["string"==typeof e?"string":"hash"]:r.map}function Ur(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return xr(r)?r:void 0}Mr.prototype.clear=function(){this.__data__=Rr?Rr(null):{}},Mr.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Mr.prototype.get=function(t){var e=this.__data__;if(Rr){var r=e[t];return r===nr?void 0:r}return Sr.call(e,t)?e[t]:void 0},Mr.prototype.has=function(t){var e=this.__data__;return Rr?void 0!==e[t]:Sr.call(e,t)},Mr.prototype.set=function(t,e){return this.__data__[t]=Rr&&void 0===e?nr:e,this},Br.prototype.clear=function(){this.__data__=[]},Br.prototype.delete=function(t){var e=this.__data__,r=Lr(e,t);return!(r<0||(r==e.length-1?e.pop():kr.call(e,r,1),0))},Br.prototype.get=function(t){var e=this.__data__,r=Lr(e,t);return r<0?void 0:e[r][1]},Br.prototype.has=function(t){return Lr(this.__data__,t)>-1},Br.prototype.set=function(t,e){var r=this.__data__,n=Lr(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Pr.prototype.clear=function(){this.__data__={hash:new Mr,map:new(Cr||Br),string:new Mr}},Pr.prototype.delete=function(t){return Dr(this,t).delete(t)},Pr.prototype.get=function(t){return Dr(this,t).get(t)},Pr.prototype.has=function(t){return Dr(this,t).has(t)},Pr.prototype.set=function(t,e){return Dr(this,t).set(t,e),this};var Nr=Fr((function(t){var e;t=null==(e=t)?"":function(t){if("string"==typeof t)return t;if(zr(t))return jr?jr.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}(e);var r=[];return ur.test(t)&&r.push(""),t.replace(lr,(function(t,e,n,i){r.push(n?i.replace(fr,"$1"):e||t)})),r}));function qr(t){if("string"==typeof t||zr(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Fr(t,e){if("function"!=typeof t||e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],s=r.cache;if(s.has(i))return s.get(i);var o=t.apply(this,n);return r.cache=s.set(i,o),o};return r.cache=new(Fr.Cache||Pr),r}Fr.Cache=Pr;var $r=Array.isArray;function Yr(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function zr(t){return"symbol"==typeof t||function(t){return!!t&&"object"==typeof t}(t)&&"[object Symbol]"==Er.call(t)}var Wr=function(t,e,r){var n=null==t?void 0:Ir(t,e);return void 0===n?r:n};var Jr=function t(e,r,n){var i=Array.isArray(r)?r:r.split("."),s=Ze(i),o=s[0],a=s.slice(1);return He({},e,Je({},o,i.length>1?t(e[o]||{},a,n):n))},Hr=function t(e,r){var n=Array.isArray(r)?r:r.split("."),i=Ze(n),s=i[0],o=i.slice(1);return"object"!==$e(e[s])?e:1===n.length?Object.keys(e).filter((function(t){return t!==s})).reduce((function(t,r){return Object.assign(t,Je({},r,e[r]))}),{}):Object.keys(e).reduce((function(r,n){return He({},r,Je({},n,n!==s?e[n]:t(e[s],o)))}),{})},Gr=function(t,e){var r=!0;return t.reduce((function(t,n){return null==n&&(n=""),r?(r=!1,"".concat(n)):"".concat(t).concat(e).concat(n)}),"")},Vr=function(t,e){try{return t.push.apply(t,Xe(e)),t}catch(r){return t.concat(e)}},Kr=function(t,e,r){return void 0===t[e]?r:t[e]},Qr=Gr,Zr=Vr,Xr=function(){function t(e){Ye(this,t),this.opts=this.preprocessOpts(e)}return We(t,[{key:"preprocessOpts",value:function(t){var e=Object.assign({},t);return e.transforms=Array.isArray(e.transforms)?e.transforms:e.transforms?[e.transforms]:[],e.delimiter=e.delimiter||",",e.eol=e.eol||er,e.quote="string"==typeof e.quote?e.quote:'"',e.escapedQuote="string"==typeof e.escapedQuote?e.escapedQuote:"".concat(e.quote).concat(e.quote),e.header=!1!==e.header,e.includeEmptyRows=e.includeEmptyRows||!1,e.withBOM=e.withBOM||!1,e}},{key:"preprocessFieldsInfo",value:function(t){var e=this;return t.map((function(t){if("string"==typeof t)return{label:t,value:t.includes(".")||t.includes("[")?function(r){return Wr(r,t,e.opts.defaultValue)}:function(r){return Kr(r,t,e.opts.defaultValue)}};if("object"===$e(t)){var r="default"in t?t.default:e.opts.defaultValue;if("string"==typeof t.value)return{label:t.label||t.value,value:t.value.includes(".")||t.value.includes("[")?function(e){return Wr(e,t.value,r)}:function(e){return Kr(e,t.value,r)}};if("function"==typeof t.value){var n=t.label||t.value.name||"",i={label:n,default:r};return{label:n,value:function(e){var n=t.value(e,i);return null==n?r:n}}}}throw new Error("Invalid field info option. "+JSON.stringify(t))}))}},{key:"getHeader",value:function(){var t=this;return Qr(this.opts.fields.map((function(e){return t.processValue(e.label)})),this.opts.delimiter)}},{key:"preprocessRow",value:function(t){return this.opts.transforms.reduce((function(t,e){return t.map((function(t){return e(t)})).reduce(Zr,[])}),[t])}},{key:"processRow",value:function(t){var e=this;if(t){var r=this.opts.fields.map((function(r){return e.processCell(t,r)}));if(this.opts.includeEmptyRows||!r.every((function(t){return void 0===t})))return Qr(r,this.opts.delimiter)}}},{key:"processCell",value:function(t,e){return this.processValue(e.value(t))}},{key:"processValue",value:function(t){if(null!=t){var e=$e(t);if("boolean"!==e&&"number"!==e&&"string"!==e){if(void 0===(t=JSON.stringify(t)))return;'"'===t[0]&&(t=t.replace(/^"(.+)"$/,"$1"))}return"string"==typeof t&&(this.opts.excelStrings?(t.includes(this.opts.quote)&&(t=t.replace(new RegExp(this.opts.quote,"g"),"".concat(this.opts.escapedQuote).concat(this.opts.escapedQuote))),t='"=""'.concat(t,'"""')):(t.includes(this.opts.quote)&&(t=t.replace(new RegExp(this.opts.quote,"g"),this.opts.escapedQuote)),t="".concat(this.opts.quote).concat(t).concat(this.opts.quote))),t}}}]),t}(),tn=Gr,en=Vr,rn=function(t){function e(t){var r;return Ye(this,e),(r=Qe(this,Ve(e).call(this,t))).opts.fields&&(r.opts.fields=r.preprocessFieldsInfo(r.opts.fields)),r}return Ge(e,t),We(e,[{key:"parse",value:function(t){var e=this.preprocessData(t);this.opts.fields||(this.opts.fields=e.reduce((function(t,e){return Object.keys(e).forEach((function(e){t.includes(e)||t.push(e)})),t}),[]),this.opts.fields=this.preprocessFieldsInfo(this.opts.fields));var r=this.opts.header?this.getHeader():"",n=this.processData(e);return(this.opts.withBOM?"\ufeff":"")+r+(r&&n?this.opts.eol:"")+n}},{key:"preprocessData",value:function(t){var e=this,r=Array.isArray(t)?t:[t];if(!this.opts.fields&&(0===r.length||"object"!==$e(r[0])))throw new Error('Data should not be empty or the "fields" option should be included');return 0===this.opts.transforms.length?r:r.map((function(t){return e.preprocessRow(t)})).reduce(en,[])}},{key:"processData",value:function(t){var e=this;return tn(t.map((function(t){return e.processRow(t)})).filter((function(t){return t})),this.opts.eol)}}]),e}(Xr),nn={},sn=nn.LEFT_BRACE=1,on=nn.RIGHT_BRACE=2,an=nn.LEFT_BRACKET=3,un=nn.RIGHT_BRACKET=4,ln=nn.COLON=5,fn=nn.COMMA=6,cn=nn.TRUE=7,hn=nn.FALSE=8,dn=nn.NULL=9,pn=nn.STRING=10,gn=nn.NUMBER=11,yn=nn.START=17,vn=nn.STOP=18,mn=nn.TRUE1=33,bn=nn.TRUE2=34,wn=nn.TRUE3=35,_n=nn.FALSE1=49,Sn=nn.FALSE2=50,En=nn.FALSE3=51,On=nn.FALSE4=52,Tn=nn.NULL1=65,kn=nn.NULL2=66,Cn=nn.NULL3=67,Rn=nn.NUMBER1=81,An=nn.NUMBER3=83,jn=nn.STRING1=97,Mn=nn.STRING2=98,Bn=nn.STRING3=99,Pn=nn.STRING4=100,Ln=nn.STRING5=101,In=nn.STRING6=102,xn=nn.VALUE=113,Dn=nn.KEY=114,Un=nn.OBJECT=129,Nn=nn.ARRAY=130,qn="\\".charCodeAt(0),Fn="/".charCodeAt(0),$n="\b".charCodeAt(0),Yn="\f".charCodeAt(0),zn="\n".charCodeAt(0),Wn="\r".charCodeAt(0),Jn="\t".charCodeAt(0),Hn=65536;function Gn(){this.tState=yn,this.value=void 0,this.string=void 0,this.stringBuffer=A.alloc?A.alloc(Hn):new A(Hn),this.stringBufferOffset=0,this.unicode=void 0,this.highSurrogate=void 0,this.key=void 0,this.mode=void 0,this.stack=[],this.state=xn,this.bytes_remaining=0,this.bytes_in_sequence=0,this.temp_buffs={2:new A(2),3:new A(3),4:new A(4)},this.offset=-1}Gn.toknam=function(t){for(var e=Object.keys(nn),r=0,n=e.length;r<n;r++){var i=e[r];if(nn[i]===t)return i}return t&&"0x"+t.toString(16)};var Vn=Gn.prototype;Vn.onError=function(t){throw t},Vn.charError=function(t,e){this.tState=vn,this.onError(new Error("Unexpected "+JSON.stringify(String.fromCharCode(t[e]))+" at position "+e+" in state "+Gn.toknam(this.tState)))},Vn.appendStringChar=function(t){this.stringBufferOffset>=Hn&&(this.string+=this.stringBuffer.toString("utf8"),this.stringBufferOffset=0),this.stringBuffer[this.stringBufferOffset++]=t},Vn.appendStringBuf=function(t,e,r){var n=t.length;"number"==typeof e&&(n="number"==typeof r?r<0?t.length-e+r:r-e:t.length-e),n<0&&(n=0),this.stringBufferOffset+n>Hn&&(this.string+=this.stringBuffer.toString("utf8",0,this.stringBufferOffset),this.stringBufferOffset=0),t.copy(this.stringBuffer,this.stringBufferOffset,e,r),this.stringBufferOffset+=n},Vn.write=function(t){var e;"string"==typeof t&&(t=new A(t));for(var r=0,n=t.length;r<n;r++)if(this.tState===yn){if(e=t[r],this.offset++,123===e)this.onToken(sn,"{");else if(125===e)this.onToken(on,"}");else if(91===e)this.onToken(an,"[");else if(93===e)this.onToken(un,"]");else if(58===e)this.onToken(ln,":");else if(44===e)this.onToken(fn,",");else if(116===e)this.tState=mn;else if(102===e)this.tState=_n;else if(110===e)this.tState=Tn;else if(34===e)this.string="",this.stringBufferOffset=0,this.tState=jn;else if(45===e)this.string="-",this.tState=Rn;else if(e>=48&&e<64)this.string=String.fromCharCode(e),this.tState=An;else if(32!==e&&9!==e&&10!==e&&13!==e)return this.charError(t,r)}else if(this.tState===jn)if(e=t[r],this.bytes_remaining>0){for(var i=0;i<this.bytes_remaining;i++)this.temp_buffs[this.bytes_in_sequence][this.bytes_in_sequence-this.bytes_remaining+i]=t[i];this.appendStringBuf(this.temp_buffs[this.bytes_in_sequence]),this.bytes_in_sequence=this.bytes_remaining=0,r=r+i-1}else if(0===this.bytes_remaining&&e>=128){if(e<=193||e>244)return this.onError(new Error("Invalid UTF-8 character at position "+r+" in state "+Gn.toknam(this.tState)));if(e>=194&&e<=223&&(this.bytes_in_sequence=2),e>=224&&e<=239&&(this.bytes_in_sequence=3),e>=240&&e<=244&&(this.bytes_in_sequence=4),this.bytes_in_sequence+r>t.length){for(var s=0;s<=t.length-1-r;s++)this.temp_buffs[this.bytes_in_sequence][s]=t[r+s];this.bytes_remaining=r+this.bytes_in_sequence-t.length,r=t.length-1}else this.appendStringBuf(t,r,r+this.bytes_in_sequence),r=r+this.bytes_in_sequence-1}else if(34===e)this.tState=yn,this.string+=this.stringBuffer.toString("utf8",0,this.stringBufferOffset),this.stringBufferOffset=0,this.onToken(pn,this.string),this.offset+=A.byteLength(this.string,"utf8")+1,this.string=void 0;else if(92===e)this.tState=Mn;else{if(!(e>=32))return this.charError(t,r);this.appendStringChar(e)}else if(this.tState===Mn)if(34===(e=t[r]))this.appendStringChar(e),this.tState=jn;else if(92===e)this.appendStringChar(qn),this.tState=jn;else if(47===e)this.appendStringChar(Fn),this.tState=jn;else if(98===e)this.appendStringChar($n),this.tState=jn;else if(102===e)this.appendStringChar(Yn),this.tState=jn;else if(110===e)this.appendStringChar(zn),this.tState=jn;else if(114===e)this.appendStringChar(Wn),this.tState=jn;else if(116===e)this.appendStringChar(Jn),this.tState=jn;else{if(117!==e)return this.charError(t,r);this.unicode="",this.tState=Bn}else if(this.tState===Bn||this.tState===Pn||this.tState===Ln||this.tState===In){if(!((e=t[r])>=48&&e<64||e>64&&e<=70||e>96&&e<=102))return this.charError(t,r);if(this.unicode+=String.fromCharCode(e),this.tState++===In){var o=parseInt(this.unicode,16);this.unicode=void 0,void 0!==this.highSurrogate&&o>=56320&&o<57344?(this.appendStringBuf(new A(String.fromCharCode(this.highSurrogate,o))),this.highSurrogate=void 0):void 0===this.highSurrogate&&o>=55296&&o<56320?this.highSurrogate=o:(void 0!==this.highSurrogate&&(this.appendStringBuf(new A(String.fromCharCode(this.highSurrogate))),this.highSurrogate=void 0),this.appendStringBuf(new A(String.fromCharCode(o)))),this.tState=jn}}else if(this.tState===Rn||this.tState===An)switch(e=t[r]){case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:case 46:case 101:case 69:case 43:case 45:this.string+=String.fromCharCode(e),this.tState=An;break;default:this.tState=yn;var a=Number(this.string);if(isNaN(a))return this.charError(t,r);this.string.match(/[0-9]+/)==this.string&&a.toString()!=this.string?this.onToken(pn,this.string):this.onToken(gn,a),this.offset+=this.string.length-1,this.string=void 0,r--}else if(this.tState===mn){if(114!==t[r])return this.charError(t,r);this.tState=bn}else if(this.tState===bn){if(117!==t[r])return this.charError(t,r);this.tState=wn}else if(this.tState===wn){if(101!==t[r])return this.charError(t,r);this.tState=yn,this.onToken(cn,!0),this.offset+=3}else if(this.tState===_n){if(97!==t[r])return this.charError(t,r);this.tState=Sn}else if(this.tState===Sn){if(108!==t[r])return this.charError(t,r);this.tState=En}else if(this.tState===En){if(115!==t[r])return this.charError(t,r);this.tState=On}else if(this.tState===On){if(101!==t[r])return this.charError(t,r);this.tState=yn,this.onToken(hn,!1),this.offset+=4}else if(this.tState===Tn){if(117!==t[r])return this.charError(t,r);this.tState=kn}else if(this.tState===kn){if(108!==t[r])return this.charError(t,r);this.tState=Cn}else if(this.tState===Cn){if(108!==t[r])return this.charError(t,r);this.tState=yn,this.onToken(dn,null),this.offset+=3}},Vn.onToken=function(t,e){},Vn.parseError=function(t,e){this.tState=vn,this.onError(new Error("Unexpected "+Gn.toknam(t)+(e?"("+JSON.stringify(e)+")":"")+" in state "+Gn.toknam(this.state)))},Vn.push=function(){this.stack.push({value:this.value,key:this.key,mode:this.mode})},Vn.pop=function(){var t=this.value,e=this.stack.pop();this.value=e.value,this.key=e.key,this.mode=e.mode,this.emit(t),this.mode||(this.state=xn)},Vn.emit=function(t){this.mode&&(this.state=fn),this.onValue(t)},Vn.onValue=function(t){},Vn.onToken=function(t,e){if(this.state===xn)if(t===pn||t===gn||t===cn||t===hn||t===dn)this.value&&(this.value[this.key]=e),this.emit(e);else if(t===sn)this.push(),this.value?this.value=this.value[this.key]={}:this.value={},this.key=void 0,this.state=Dn,this.mode=Un;else if(t===an)this.push(),this.value?this.value=this.value[this.key]=[]:this.value=[],this.key=0,this.mode=Nn,this.state=xn;else if(t===on){if(this.mode!==Un)return this.parseError(t,e);this.pop()}else{if(t!==un)return this.parseError(t,e);if(this.mode!==Nn)return this.parseError(t,e);this.pop()}else if(this.state===Dn)if(t===pn)this.key=e,this.state=ln;else{if(t!==on)return this.parseError(t,e);this.pop()}else if(this.state===ln){if(t!==ln)return this.parseError(t,e);this.state=xn}else{if(this.state!==fn)return this.parseError(t,e);if(t===fn)this.mode===Nn?(this.key++,this.state=xn):this.mode===Un&&(this.state=Dn);else{if(!(t===un&&this.mode===Nn||t===on&&this.mode===Un))return this.parseError(t,e);this.pop()}}},Gn.C=nn;var Kn=Gn,Qn=function(t){function e(t,r){var n;return Ye(this,e),n=Qe(this,Ve(e).call(this,r)),Object.getOwnPropertyNames(Xr.prototype).forEach((function(t){return n[t]=Xr.prototype[t]})),n.opts=n.preprocessOpts(t),n._data="",n._hasWritten=!1,n._readableState.objectMode?n.initObjectModeParse():n.opts.ndjson?n.initNDJSONParse():n.initJSONParser(),n.opts.withBOM&&n.push("\ufeff"),n.opts.fields&&(n.opts.fields=n.preprocessFieldsInfo(n.opts.fields),n.pushHeader()),n}return Ge(e,t),We(e,[{key:"initObjectModeParse",value:function(){var t=this;this.parser={write:function(e){t.pushLine(e)},getPendingData:function(){}}}},{key:"initNDJSONParse",value:function(){var t=this;this.parser={_data:"",write:function(e){this._data+=e.toString();var r=this._data.split("\n").map((function(t){return t.trim()})).filter((function(t){return""!==t})),n=!1;r.forEach((function(e,i){try{t.pushLine(JSON.parse(e))}catch(s){i===r.length-1?n=!0:(s.message="Invalid JSON (".concat(e,")"),t.emit("error",s))}})),this._data=n?this._data.slice(this._data.lastIndexOf("\n")):""},getPendingData:function(){return this._data}}}},{key:"initJSONParser",value:function(){var t=this;this.parser=new Kn,this.parser.onValue=function(e){this.stack.length===this.depthToEmit&&t.pushLine(e)},this.parser._onToken=this.parser.onToken,this.parser.onToken=function(e,r){t.parser._onToken(e,r),0!==this.stack.length||t.opts.fields||this.mode===Kn.C.ARRAY||this.mode===Kn.C.OBJECT||this.onError(new Error('Data should not be empty or the "fields" option should be included')),1===this.stack.length&&(void 0===this.depthToEmit&&(this.depthToEmit=this.mode===Kn.C.ARRAY?1:0),0!==this.depthToEmit&&1===this.stack.length&&(this.value=void 0))},this.parser.getPendingData=function(){return this.value},this.parser.onError=function(e){e.message.includes("Unexpected")&&(e.message="Invalid JSON (".concat(e.message,")")),t.emit("error",e)}}},{key:"_transform",value:function(t,e,r){this.parser.write(t),r()}},{key:"_flush",value:function(t){this.parser.getPendingData()&&t(new Error("Invalid data received from stdin",this.parser.getPendingData())),t()}},{key:"pushHeader",value:function(){if(this.opts.header){var t=this.getHeader();this.emit("header",t),this.push(t),this._hasWritten=!0}}},{key:"pushLine",value:function(t){var e=this,r=this.preprocessRow(t);this._hasWritten||(this.opts.fields=this.opts.fields||this.preprocessFieldsInfo(Object.keys(r[0])),this.pushHeader()),r.forEach((function(t){var r=e.processRow(t,e.opts);void 0!==r&&(e.emit("line",r),e.push(e._hasWritten?e.opts.eol+r:r),e._hasWritten=!0)}))}}]),e}(Fe.Transform),Zn=Fe.Transform,Xn=Gr,ti=function(){function t(e,r){Ye(this,t),this.input=new Zn(r),this.input._read=function(){},this.transform=new Qn(e,r),this.processor=this.input.pipe(this.transform)}return We(t,[{key:"fromInput",value:function(t){if(this._input)throw new Error("Async parser already has an input.");return this._input=t,this.input=this._input.pipe(this.processor),this}},{key:"throughTransform",value:function(t){if(this._output)throw new Error("Can't add transforms once an output has been added.");return this.processor=this.processor.pipe(t),this}},{key:"toOutput",value:function(t){if(this._output)throw new Error("Async parser already has an output.");return this._output=t,this.processor=this.processor.pipe(t),this}},{key:"promise",value:function(){var t=this,e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return new Promise((function(r,n){if(e){var i=[];t.processor.on("data",(function(t){return i.push(t.toString())})).on("finish",(function(){return r(Xn(i,""))})).on("error",(function(t){return n(t)}))}else t.processor.on("finish",(function(){return r()})).on("error",(function(t){return n(t)}))}))}}]),t}();var ei=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.objects,r=void 0===e||e,n=t.arrays,i=void 0!==n&&n,s=t.separator,o=void 0===s?".":s;function a(t,e,n){return Object.keys(t).forEach((function(s){var u=n?"".concat(n).concat(o).concat(s):s,l=t[s];r&&"object"===$e(l)&&null!==l&&!Array.isArray(l)&&"[object Function]"!==Object.prototype.toString.call(l.toJSON)&&Object.keys(l).length||i&&Array.isArray(l)?a(l,e,u):e[u]=l})),e}return function(t){return a(t,{})}},ri=Jr,ni=Hr,ii=Vr;function si(t,e){return Object.keys(t).reduce((function(r,n){var i=e?"".concat(e,".").concat(n):n,s=t[n];return"object"===$e(s)&&null!==s&&!Array.isArray(s)&&"[object Function]"!==Object.prototype.toString.call(s.toJSON)&&Object.keys(s).length?r=r.concat(si(s,i)):Array.isArray(s)&&(r.push(i),r=r.concat(s.map((function(t){return si(t,i)})).reduce(ii,[]).filter((function(t,e,r){return r.indexOf(t)!==e})))),r}),[])}var oi=function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},e=t.paths,r=void 0===e?void 0:e,n=t.blankOut,i=void 0!==n&&n;function s(t,e){return t.map((function(t){var r=Wr(t,e);return Array.isArray(r)?r.length?r.map((function(r,n){return ri(i&&n>0?{}:t,e,r)})):ni(t,e):t})).reduce(ii,[])}return r=Array.isArray(r)?r:r?[r]:void 0,function(t){return(r||si(t)).reduce(s,[t])}},ai=Fe.Readable,ui=rn,li=ti,fi=Qn,ci=function(t,e){return new rn(e).parse(t)},hi=function(t,e,r){try{t instanceof ai||(r=Object.assign({},r,{objectMode:!0}));var n=new ti(e,r),i=n.promise();return Array.isArray(t)?(t.forEach((function(t){return n.input.push(t)})),n.input.push(null)):t instanceof ai?n.fromInput(t):(n.input.push(t),n.input.push(null)),i}catch(t){return Promise.reject(t)}},di={flatten:ei,unwind:oi},pi={Parser:ui,AsyncParser:li,Transform:fi,parse:ci,parseAsync:hi,transforms:di};t.AsyncParser=li,t.Parser=ui,t.Transform=fi,t.default=pi,t.parse=ci,t.parseAsync=hi,t.transforms=di,Object.defineProperty(t,"__esModule",{value:!0})}(e)}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,r),s.exports}r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),(()=>{"use strict";const t=function(){let t="";return function(e){if(!e)return t;t=e}}(),e=function(){let t="";return function(e){if(!e)return t;t=e}}(),n=function(){let t="";return function(e){if(!e)return t;t=e}}(),i=function(){let t="";return function(e){if(!e)return t;t=e}}(),s=function(){let t="";return function(e){if(!e)return t;t=e}}(),o="init",a=new class{init(r){const{host:a,key:u,credentials:l,role:f,secret:c}=r.data;a||self.postMessage({status:422,action:o,error:!0,errorType:"Init",errorMessage:"API host required"}),u||self.postMessage({status:422,action:o,error:!0,errorType:"Init",errorMessage:"App key for access API required"}),l||self.postMessage({status:401,action:o,error:!0,errorType:"Buildings worker warning",errorMessage:"Access denied"}),a&&i(a),u&&n(u),l&&t(l),f&&e(f),c&&s(c),self.postMessage({status:200,action:o,host:i(),apiKey:n(),credentials:t(),role:e()})}setAPIHostURL(t){t.host&&i(t.host)}setAPIKey(t){t.key&&n(t.key)}setCredentials(e){e.credentials&&t(e.credentials)}setRole(t){t.role&&e(t.credentials)}},u=function(t){if(!t)return"";let{number:e,postCode:r,street:n,streetType:i}=t;return i="PDE"===i?"PD":"LINE"===i?"LN":i,`${r}.${function(t){t=t.split(" ").join("");for(let e of"aeiouyAEIOU".split(""))t=t[0]+t.slice(1).split(e).join("");return t.toUpperCase()}(n)}.${i}.${e}`},l=()=>new Promise((t=>Object.assign(indexedDB.open("buildings"),{onupgradeneeded:t=>{for(const e of rt)t.target.result.createObjectStore(e);return t.target.result},onsuccess:e=>t({status:200,result:e.target.result}),onerror:e=>t({status:700,result:null})}))),f=async(t,e,r)=>new Promise((n=>{l().then((i=>{const{status:s,result:o}=i;if(200!==s)return void n({status:s,result:"Open local DB error"});const a=o.transaction([t],"readwrite").objectStore(t);Object.assign(a.put(r,e),{onsuccess:()=>n({status:200,result:r}),onerror:()=>n({status:400,result:null,error:!0,errorType:"Local DB error",errorMessage:`Failed to save data to local DB: ${e}`})})}))})),c=(t,e)=>new Promise((r=>{l().then((n=>{const{status:i,result:s}=n;if(200!==i)return void r({status:i,result:null});const o=s.transaction([t]).objectStore(t);Object.assign(o.get(e),{onsuccess:n=>r({status:n.target.result?200:404,result:n.target.result?n.target.result:`The data ${e} not found in db store ${t}`}),onerror:t=>r({status:704,result:t.target.error})})}))})),h=t=>new Promise((e=>{l().then((r=>{const{status:n,result:i}=r;if(200!==n)return void e({status:n,result:null});const s=i.transaction([t]).objectStore(t);return Object.assign(s.getAll(),{onsuccess:r=>e({status:r.target.result?200:404,result:r.target.result?r.target.result:`No one key found in db store ${t}`}),onerror:t=>e({status:704,result:t.target.error})})}))})),d=(t,e)=>new Promise((r=>{l().then((n=>{const{status:i,result:s}=n;if(200!==i)return void r({status:i,result:null});const o=s.transaction([t],"readwrite").objectStore(t);Object.assign(o.delete(e),{onsuccess:n=>r({action:"delete",store:t,key:e,status:200,result:null}),onerror:t=>r({status:400,result:t.target.error})})}))})),p=async function(t){const e=[],r=it[t[0].status];for(const n of t){const{address:t}=n;e.push(f(r,t,n))}return await Promise.all(e)},g=["lit","footprint","build","soon"],y="search-by-part-of-address",v={status:403,result:null,error:!0,errorType:"Forbidden action",errorMessage:"You have no rights to perform this action"},m={error:!0,errorType:"Remote server error",errorMessage:"Operation failed"},b={status:400,error:!0,errorType:"Buildings",errorMessage:"Operation failed: local DB error"},w={status:500,action:"post",error:!0,errorType:"Create new building",errorMessage:"Operation failed: remote server error"},_=(t,e)=>({status:400,action:t,key:e,error:!0,errorType:`Update ${e} details`,errorMessage:"Operation failed: local DB error"}),S=async function(e){if(!navigator.onLine)return{status:0,result:"Offline mode: Data has not been saved. Try later"};if(!i()||!n())return{status:409,action:"get",error:!0,errorType:"Worker configuration",errorMessage:"Missing map-worker settings"};const r={error:!0,errorType:e,errorMessage:"Not found"},s=await fetch(`${i()}/${e}`,{method:"GET",headers:{Authorization:n(),Credentials:t(),"Content-Type":"application/json"}}),o=await s.json(),a={status:s.status,result:o.data,page:o.page,pages:o.pages};return Object.assign(a,200===s.status?{}:404===s.status?r:m)},E={message:!0,messageType:"Create new",messageText:"Data successfully created"},O={message:!0,messageType:"Update",messageText:"Data successfully updated"},T=async function(e,r,s){if(!i()||!n())return{status:409,action:"patch",error:!0,errorType:"Worker configuration",errorMessage:"Missing map-worker settings"};if(!t())return v;const o=await fetch(`${i()}/${e}/${r}`,{method:"PATCH",headers:{Authorization:n(),Credentials:t(),"Content-Type":"application/json"},body:JSON.stringify(s)}),a={status:o.status,action:"patch",result:(await o.json()).data};return Object.assign(a,200===o.status?O:m)},k={message:!0,messageType:"Update",messageText:"Data successfully updated"},C={message:!0,messageType:"Delete data",messageText:"Data successfully deleted"},[R,A]=["refresh","Refresh buildings data"],j={action:R,error:!0,errorType:A},M=Object.assign(j,{status:500,errorMessage:"Operation failed: remote server error"}),B=Object.assign(j,{status:400,errorMessage:"Operation failed: local DB error"}),P="get-by-list",L="table",I=async t=>{if(-1===Object.keys(nt).indexOf(t))return{status:422,action:L,key:t,result:`Invalid request: type ${t} not found`};const{status:e,result:r}=await h(t),n=r.map((t=>({id:t._id,address:t.address,uniqueCode:t.uniqueCode||u(t.addressComponents),buildingName:t.buildingName||"",addressComponents:t.addressComponents,estimatedServiceDeliveryTime:t.estimatedServiceDeliveryTime,numberOfDwellings:t.numberOfDwellings})));return n.forEach((t=>{t.addressComponents.internalInstallationCosts=parseFloat(t.addressComponents.internalInstallationCosts)||0,t.addressComponents.buildingConnectionCosts=parseFloat(t.addressComponents.buildingConnectionCosts)||0})),{status:e,action:L,key:t,result:Object.assign(n,{event:ot[t].event,buildingStatus:ot[t].buildingStatus,polygonStatus:ot[t].polygonStatus})}},x="details",D=async t=>{const e=t,r=await S(`building/${t}`);return 200!==r.status?Object.assign(r,{action:x}):(r.result.uniqueCode=r.result.uniqueCode||u(r.result.addressComponents),await f("current","data",r.result),{status:r.status,action:x,store:r.result.status,key:e,result:r.result})},U="address",N="search",q=async t=>{for(const e in nt){let{status:r,result:n}=await c(e,t);if(200!==r)continue;const{isMaster:i,isSlave:s,masterBuildingId:o}=n.addressComponents;if(!i&&s&&o){const{status:t,result:r}=await D(o);return{status:t,action:N,key:e,address:r.address,result:r}}return{status:r,action:N,key:e,address:t,result:n}}return{status:404,action:N,key:"Not found",address:t,result:null}},F="post",$="patch",Y="remove",z={action:Y,result:null,error:!0,errorType:"Delete bulding"},W=Object.assign(z,{status:404,errorMessage:"Operation failed: building was not found"}),J=["lit","footprint","build","soon","other"],H=async t=>{for(const e of J){const{status:r,result:n}=await c(e,t);if(200===r)return{status:(await d(e,t)).status,action:"remove",key:t,result:n}}},G="group-update",V={action:G,status:200,message:!0,messageType:"Group update",messageText:"Buildings of group details updated"},K=(t,e)=>t.map((t=>({[t.title]:t.prop.split(".").reduce(((e,r)=>e?e[r]:t.defaultValue),e)})));const{Parser:Q}=r(331),Z=new class{async refresh(){self.postMessage(await(async()=>{if(!navigator.onLine)return offlineError(R,"received");await Promise.all(Object.keys(nt).map((t=>(t=>new Promise((e=>{l().then((r=>{const{status:n,result:i}=r;if(200!==n)return void e({status:n,result:null});const s=i.transaction([t],"readwrite").objectStore(t);Object.assign(s.clear(),{onsuccess:t=>e({status:200,result:null}),onerror:r=>e({status:704,result:`Cleaning ${t}: operation failed`})})}))})))(t))));for(const i of et){var t=0;do{var e=await S(`building/${i}?per_page=100&page=${t+1||1}`);if(200!==e.status)return M;var{page:t,pages:r,result:n}=await e;if(!n||!n.length)continue;const s=await p(n);if(!s||!Array.isArray(s)||s.filter((t=>200!==t.status)).length)return B}while(t<r)}return{status:200,action:R}})())}async getList(t){self.postMessage(await(async t=>{const[e,r]=["list",t];if(-1===Object.keys(nt).indexOf(t))return{status:422,action:e,store:r,result:`Invalid request: type ${t} not found`};const{status:n,result:i}=await(s=t,new Promise((t=>{l().then((e=>{const{status:r,result:n}=e;if(200!==r)return void t({status:r,result:null});const i=n.transaction([s]).objectStore(s);return Object.assign(i.getAllKeys(),{onsuccess:e=>t({status:e.target.result?200:404,result:e.target.result?e.target.result:`No one key found in db store ${s}`}),onerror:e=>t({status:704,result:e.target.error})})}))})));var s;return{status:n,key:r,action:e,result:Object.assign(i,{event:ot[r].event,buildingStatus:ot[r].buildingStatus,polygonStatus:ot[r].polygonStatus})}})(t.key))}async getBuildingsByList(t){self.postMessage(await(async t=>{if(!t||!Array.isArray(t)||!t.length)return{status:422,action:P,key,result:"Invalid request: list of building id required"};const e=t.map((t=>S(`building/${t}`))),r=await Promise.all(e);return{status:200,action:P,result:r.map((t=>({address:t.result.address,uniqueCode:t.result.uniqueCode||u(t.result.addressComponents),id:t.result._id,buildingType:t.result.addressComponents.buildingType,buildingClass:t.result.addressComponents.buildingClass,buildingCategory:t.result.addressComponents.buildingCategory,buildingConnectionDate:t.addressComponents.buildingConnectionDate,buildingConnectionCosts:t.result.addressComponents.buildingConnectionCosts,internalInstallationCosts:t.result.addressComponents.internalInstallationCosts,status:t.result.status,estimatedServiceDeliveryTime:t.result.estimatedServiceDeliveryTime,numberOfDwellings:t.result.numberOfDwellings})))}})(t.list))}async getBuildingsListForTable(t){t.channel?self.channelPort.postMessage(Object.assign({route:"channel"},await I(t.key))):self.postMessage(await I(t.key))}async getMasterBuildingsList(){self.postMessage(await(async()=>{const t=[];for(const e of["lit","footprint","build","soon"]){const{status:r,result:n}=await h(e);if(200!==r){console.error(`Error reading local DB ${e}`);continue}const i=n.filter((t=>t.addressComponents.isMaster)).map((t=>({id:t._id,status:t.status,address:t.address,uniqueCode:t.uniqueCode||u(t.addressComponents),buildingName:t.buildingName||"",slaves:t.addressComponents.slaves})));t.push(...i)}return{status:200,action:"master-list",result:t}})())}async getSlavesForMaster(t){self.postMessage(await(async t=>{const{status:e,result:r}=await h("lit");return{status:e,action:"slave-list",result:r.filter((e=>e.addressComponents.isSlave&&e.addressComponents.masterBuildingId===t)).map((t=>({id:t._id,address:t.address,uniqueCode:t.uniqueCode||u(t.addressComponents),buildingName:t.buildingName||"",masterBuildingId:t.addressComponents.masterBuildingId})))}})(t.masterId))}async search(t){self.postMessage(await q(t.key))}async searchByPartOfAddress(t){self.postMessage(await(async t=>{if(!t||t.length<3)return{status:422,action:y,key:t,result:`Invalid request: length of search string ${t} is too short`};const{status:e,result:r}=await l();if(200!==e)return{status:e,result:r,action:y};const n=r.transaction(g,"readwrite"),i=g.map((t=>n.objectStore(t))).map((e=>new Promise((r=>{const n=[];e.openCursor().onsuccess=async e=>{const i=e.target.result;if(i){const{address:e,_id:r,status:s,addressComponents:o,uniqueCode:a}=i.value;-1===e.indexOf(t)||o.isSlave||n.push({address:e,buildingId:r,status:s,buildingUniqueCode:a||u(o),postCode:o.postCode}),i.continue()}else r(n)}})))),s=(await Promise.all(i)).flatMap((t=>t));return{status:200,action:y,key:t,result:s}})(t.part))}async getBuildingDataById(t){self.postMessage(await D(t.key))}async getBuildingDataByAddress(t){self.postMessage(await(async t=>{const e=await q(t);if(self.postMessage({status:300,response:e}),200!==e.status)return((t=404,e="Building")=>({status:t,store:"Not found",action:U,key:e,result:null,error:!0,errorType:"Search building by address",errorMessage:`${e} was not found`}))(e.status,t);const{status:r,store:n,result:i}=await D(e.result._id);return{status:r,action:U,store:e.store,key:t,result:i}})(t.key))}async put(e){self.postMessage(await async function(e,r){const s=e;let o=await D(e);if(200!==o.status)return getError(o.status,e);if(Object.assign(o.result,{...r}),o=await async function(e,r,s){if(!i()||!n())return{status:409,action:"put",error:!0,errorType:"Worker configuration",errorMessage:"Missing map-worker settings"};if(!t())return v;const o=await fetch(`${i()}/building/${r}`,{method:"PUT",headers:{Authorization:n(),Credentials:t(),"Content-Type":"application/json"},body:JSON.stringify(void 0)}),a={status:o.status,action:"put",result:(await o.json()).data};return Object.assign(a,200===o.status?k:m)}(0,e),200!==o.status)return putError(o.status,r.address);const{address:a,addressComponents:u,coordinates:l,distanceFromFootprint:c,estimatedServiceDeliveryTime:h,status:d}=await o.json(),p=it[d],g=await f(p,a,{address:a,addressComponents:u,coordinates:l,estimatedServiceDeliveryTime:h,status:d,_id:e});return 200!==g.status?putError(g.status,r.address):{action:"put",key:s,status:o.status,result:g}}(e.key,e.data))}async patch(t){self.postMessage(await async function(t,e){const r=t;let n=Boolean(e.status);if(e.status&&!Object.keys(nt).map((t=>nt[t])).includes(e.status))return i=e.status,{action:$,status:422,error:!0,errorType:"Update building details",errorMessage:`Invalid building status ${i}`};var i;const s=await T("building",t,e);if(200!==s.status)return s;const{address:o,addressComponents:a,coordinates:l,buildingName:c,estimatedServiceDeliveryTime:h,status:d}=s.result,p=u(a);if(n&&await H(o),200!==s.status)return((t=400,e="building")=>({status:t,action:"put",key:e,error:!0,errorType:`Update ${e} details`,errorMessage:"Operation failed"}))("patch",s.status);const g=Object.keys(nt).find((t=>nt[t]===d)),y=await f(g,o,{address:o,addressComponents:a,coordinates:l,buildingName:c,estimatedServiceDeliveryTime:h,status:d,uniqueCode:p,_id:t});return 200!==y.status?_("patch",o):Object.assign(y,{status:200,action:$,key:r},(t=>({action:$,status:200,message:!0,messageType:t,messageText:"Building details updated"}))(o))}(t.key,t.data))}async post(e){self.postMessage(await(async e=>{if(!navigator.onLine)return((t,e="saved")=>({status:0,action:t,error:!0,errorType:"Offline",message:`Offline mode: Data has not been ${e}. Try later`,result:`Offline mode: Data has not been ${e}. Try later`}))(F,"saved");if(!e.status)return postError(422,"Building status not defined");const r=it[e.status];if(!r)return postError(422,`Invalid building status ${e.status}`);Object.keys(e).includes("buildingId")&&delete e.buildingId;const s=await q(e.address);if(s.result)return{status:409,action:F,store:r,key:e.address,result:s.result._id,message:!0,messageType:"Creating new building",messageText:`Building ${e.address} already exists`};const o=Object.assign(JSON.parse(JSON.stringify(st)),e),a=await async function(e,r){if(!i()||!n())return{status:409,action:"post",error:!0,errorType:"Worker configuration",errorMessage:"Missing map-worker settings"};if(!t())return v;const s=await fetch(`${i()}/building`,{method:"POST",headers:{Authorization:n(),Credentials:t(),"Content-Type":"application/json"},body:JSON.stringify(r)}),o={status:s.status,action:"post",result:(await s.json()).data};return Object.assign(o,200===s.status?E:m)}(0,o);if(403===a.status)return a;if(200!==a.status)return w;const u=a.result,{address:l,addressComponents:c,coordinates:h,status:d,estimatedServiceDeliveryTime:p="",buildingName:g="",distanceFromFootprint:y=0}=e,_={address:l,addressComponents:c,coordinates:h,status:d,estimatedServiceDeliveryTime:p,_id:u},{status:S,result:O}=await f(r,e.address,_);return 200!==S?b:{status:200,action:F,store:r,key:e.address,result:u}})(e.data))}async remove(e){self.postMessage(await(async e=>{if(!navigator.onLine)return{status:0,result:"Offline mode: Data has not been saved. Try later"};let r=await S(`building/${e}`);if(200!==r.status)return W;const{address:s,status:o}=r.result,a=it[o];return 200!==(await async function(e){if(!i()||!n())return{status:409,action:"remove",error:!0,errorType:"Worker configuration",errorMessage:"Missing map-worker settings"};if(!t())return v;const r=await fetch(`${i()}/${e}`,{method:"DELETE",headers:{Authorization:n(),Credentials:t(),"Content-Type":"application/json"}}),s=await r.json(),o={status:r.status,action:"remove",result:s};return Object.assign(o,200===r.status?C:m)}(`building/${e}`)).status?(t=>Object.assign(z,{status:500,errorType:t,errorMessage:"Operation failed: remote server error"}))(s):200!==(await d(a,s)).status?(t=>Object.assign(z,{status:400,errorType:t,errorMessage:"Operation partially failed: local DB error"}))(s):{status:200,action:Y,store:a,key:s,result:!0}})(e.key))}async groupUpdate(t){self.postMessage(await async function(t,e){let r=Boolean(e.status);if(e.status&&!Object.keys(nt).map((t=>nt[t])).includes(e.status))return n=e.status,{action:G,status:422,error:!0,errorType:"Update building details",errorMessage:`Invalid building status ${n}`};var n;for(const n of t){const{result:t}=await T("building",n,e);let{address:i,addressComponents:s,coordinates:o,buildingName:a,uniqueCode:l,estimatedServiceDeliveryTime:c,status:h,_id:d}=t;const p=Object.keys(nt).find((t=>nt[t]===h));r&&await H(i),200!==(await f(p,i,{address:i,addressComponents:s,coordinates:o,buildingName:a,estimatedServiceDeliveryTime:c,status:h,uniqueCode:l||u(s),_id:d})).status&&self.postMessage(_(G,i))}return Object.assign({},{status:200,action:G},V)}(t.group,t.details))}async exportBuildingsToCsv(t){self.postMessage(await(async t=>{const e=new Q({fields:t.map((t=>t.title))}).parse(await async function(t){const e=await async function(){let t=1;const e=[];do{var{data:r,pages:n}=await(await fetch(`${i()}/building?page=${t}&per_page=500`)).json();if(!r)break;e.push(r.map((t=>t._id)))}while(t++<n);return e}(),r=[];for(const n of e){const e=n.map((t=>fetch(`${i()}/building/${t}`))),s=await Promise.all(e),o=(await Promise.all(s.map((t=>200===t.status?t.json():[])))).map((e=>Object.assign({},...K(t,e.data))));r.push(...o)}return r}(t));return{status:200,action:"csv",result:new Blob([e],{type:"text/csv;charset=utf-8;"})}})(t.requestedFields))}},X=new class{async getPolygonsByType(t){self.postMessage(await async function(t){const e=await S(`polygons/${t.key}`);return 200!==e.status?Object.assign(e,{action:"polygons"}):{status:e.status,action:"polygons",key:t.key,type:e.result[0].properties.typeOf,result:e.result.map((t=>({coordinates:t.geometry.coordinates[0]})))}}(t))}},tt={init:a.init,refresh:Z.refresh,list:Z.getList,table:Z.getBuildingsListForTable,"master-list":Z.getMasterBuildingsList,"slave-list":Z.getSlavesForMaster,"get-by-list":Z.getBuildingsByList,search:Z.search,"search-by-part-of-address":Z.searchByPartOfAddress,csv:Z.exportBuildingsToCsv,details:Z.getBuildingDataById,address:Z.getBuildingDataByAddress,put:Z.put,post:Z.post,patch:Z.patch,remove:Z.remove,"group-update":Z.groupUpdate,polygons:X.getPolygonsByType},et=["lit","footprint","build-commenced","coming-soon","other"],rt=["lit","footprint","build","soon","other","current"],nt={lit:"LIT",footprint:"Footprint",build:"BuildCommenced",soon:"ComingSoon",other:"Other"},it={LIT:"lit",Footprint:"footprint",BuildCommenced:"build",UnderConstruction:"build",ConstructionCommenced:"build",ComingSoon:"soon",Other:"other"},st={status:"Footprint",estimatedServiceDeliveryTime:"",coordinates:[0,0],address:"",addressComponents:{number:"",street:"",streetType:"",city:"",state:"",postCode:"",cadastralIdentifier:""},owner:{corporationName:"",contactPerson:"",corporationPhoneWork:"",corporationPhoneMobile:"",corporationEmailPrimary:"",corporationEmailAlternative:""},management:{managerName:"",managerPhoneWork:"",phoneWork:"",phoneMobile:"",emailPrimary:"",emailAlternative:""},buildingName:"",buildingType:"dwelling=,type=,category=,field=",customerInstallApprovalRequired:!0,inductionRequired:!0,difficultyLevel:{leadInInstallation:0,backboneInstallation:0,customerInstallation:0},infrastructure:{type:"",leadIn:{planned:!1,installed:!1},backbone:{planned:!1,installed:!1},customerAccessCabling:{planned:!1,installed:!1},gPOinMDF:{exist:!1,planned:!1,installed:!1},uPSinMDF:{planned:!1,installed:!1},gPOinRisers:{exist:!1,planned:!1,installed:!1},uPSinRisers:{planned:!1,installed:!1}},files:{design:"",laanInspect:"",laanInstall:"",scope:"",photos:[],approoval:""},numberOfLevels:0,numberOfDwellings:0,avgFloorHeight:0,levels:[{plannedRouter:!1,plannedSplicingBox:!1,plannedSplitter:!1,plannedOFTU:!1,plannedRack:!1,installedRouter:!1,installedSplicingBox:!1,installedSplitter:!1,installedOFTU:!1,installedRack:!1,routerId:""}]},ot={lit:{event:"on-net",buildingStatus:"LIT",polygonStatus:"ServiceAvailable"},footprint:{event:"footprint",buildingStatus:"Footprint",polygonStatus:"ServiceAvailable"},build:{event:"construction-commenced",buildingStatus:"BuildCommenced",polygonStatus:"UnderConstruction"},soon:{event:"coming-soon",buildingStatus:"ComingSoon",polygonStatus:"ComingSoon"},other:{event:"not-available",buildingStatus:"Other",polygonStatus:null}},at=t=>tt[t]&&"function"==typeof tt[t]?null:self.channelPort.postMessage({status:422,action:t,result:"Invalid request"});self.onmessage=function(t){const{action:e}=t.data;if("port"===e)return void(self.channelPort=Object.assign(t.data.port,{onmessage:function(t){const{action:e}=t.data,r=at(e);if(r)return self.channelPort.postMessage(Object.assign(r,{route:"channel"}));tt[e](Object.assign(t.data,{channel:!0}))}}));const r=at(e);if(r)return r;tt[e](t.data)}})()})();