diff --git a/package.json b/package.json index 41cbb16..fa13b23 100644 --- a/package.json +++ b/package.json @@ -45,10 +45,16 @@ "es" ], "configuration": "./syntaxes/es.configuration.json" - },{ + }, + { "id": "sql", - "extensions": [ ".sql", ".dsql" ], - "aliases": [ "SQL" ], + "extensions": [ + ".sql", + ".dsql" + ], + "aliases": [ + "SQL" + ], "configuration": "./syntaxes/language-configuration.json" } ], @@ -1019,10 +1025,13 @@ "date-format": "^3.0.0", "deepmerge": "^3.2.0", "element-ui": "^2.13.2", + "g2": "^2.3.13", "ioredis": "^4.23.0", "json-format-highlight": "^1.0.4", "lodash": "^4.17.20", "lodash.defaults": "^4.1.0", + "mockjs": "^1.1.0", + "mongodb": "^3.6.9", "mysql2": "^2.2.5", "officegen": "^0.6.5", "pg": "^8.5.1", diff --git a/src/bin/g2.js b/src/bin/g2.js deleted file mode 100644 index df09dfb..0000000 --- a/src/bin/g2.js +++ /dev/null @@ -1,76 +0,0 @@ -module.exports=function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=133)}([function(t,e,n){"use strict";n.r(e),n.d(e,"contains",(function(){return r})),n.d(e,"includes",(function(){return r})),n.d(e,"difference",(function(){return a})),n.d(e,"find",(function(){return m})),n.d(e,"findIndex",(function(){return x})),n.d(e,"firstValue",(function(){return b})),n.d(e,"flatten",(function(){return _})),n.d(e,"flattenDeep",(function(){return C})),n.d(e,"getRange",(function(){return w})),n.d(e,"pull",(function(){return P})),n.d(e,"pullAt",(function(){return T})),n.d(e,"reduce",(function(){return E})),n.d(e,"remove",(function(){return j})),n.d(e,"sortBy",(function(){return k})),n.d(e,"union",(function(){return D})),n.d(e,"uniq",(function(){return B})),n.d(e,"valuesOfKey",(function(){return F})),n.d(e,"head",(function(){return R})),n.d(e,"last",(function(){return N})),n.d(e,"startsWith",(function(){return G})),n.d(e,"endsWith",(function(){return Y})),n.d(e,"filter",(function(){return o})),n.d(e,"every",(function(){return V})),n.d(e,"some",(function(){return X})),n.d(e,"group",(function(){return q})),n.d(e,"groupBy",(function(){return H})),n.d(e,"groupToMap",(function(){return W})),n.d(e,"getWrapBehavior",(function(){return U})),n.d(e,"wrapBehavior",(function(){return Z})),n.d(e,"number2color",(function(){return K})),n.d(e,"parseRadius",(function(){return $})),n.d(e,"clamp",(function(){return J})),n.d(e,"fixedBase",(function(){return tt})),n.d(e,"isDecimal",(function(){return nt})),n.d(e,"isEven",(function(){return it})),n.d(e,"isInteger",(function(){return rt})),n.d(e,"isNegative",(function(){return ot})),n.d(e,"isNumberEqual",(function(){return at})),n.d(e,"isOdd",(function(){return st})),n.d(e,"isPositive",(function(){return ut})),n.d(e,"maxBy",(function(){return lt})),n.d(e,"minBy",(function(){return ct})),n.d(e,"mod",(function(){return ht})),n.d(e,"toDegree",(function(){return pt})),n.d(e,"toInteger",(function(){return dt})),n.d(e,"toRadian",(function(){return yt})),n.d(e,"forIn",(function(){return vt})),n.d(e,"has",(function(){return mt})),n.d(e,"hasKey",(function(){return xt})),n.d(e,"hasValue",(function(){return _t})),n.d(e,"keys",(function(){return d})),n.d(e,"isMatch",(function(){return g})),n.d(e,"values",(function(){return bt})),n.d(e,"lowerCase",(function(){return Ct})),n.d(e,"lowerFirst",(function(){return wt})),n.d(e,"substitute",(function(){return Ot})),n.d(e,"upperCase",(function(){return St})),n.d(e,"upperFirst",(function(){return At})),n.d(e,"getType",(function(){return It})),n.d(e,"isArguments",(function(){return Tt})),n.d(e,"isArray",(function(){return h})),n.d(e,"isArrayLike",(function(){return i})),n.d(e,"isBoolean",(function(){return Et})),n.d(e,"isDate",(function(){return jt})),n.d(e,"isError",(function(){return Lt})),n.d(e,"isFunction",(function(){return l})),n.d(e,"isFinite",(function(){return kt})),n.d(e,"isNil",(function(){return c})),n.d(e,"isNull",(function(){return Bt})),n.d(e,"isNumber",(function(){return et})),n.d(e,"isObject",(function(){return f})),n.d(e,"isObjectLike",(function(){return y})),n.d(e,"isPlainObject",(function(){return v})),n.d(e,"isPrototype",(function(){return Ft})),n.d(e,"isRegExp",(function(){return Rt})),n.d(e,"isString",(function(){return L})),n.d(e,"isType",(function(){return u})),n.d(e,"isUndefined",(function(){return Nt})),n.d(e,"isElement",(function(){return Gt})),n.d(e,"requestAnimationFrame",(function(){return Yt})),n.d(e,"clearAnimationFrame",(function(){return Vt})),n.d(e,"augment",(function(){return Ht})),n.d(e,"clone",(function(){return qt})),n.d(e,"debounce",(function(){return Ut})),n.d(e,"memoize",(function(){return Zt})),n.d(e,"deepMix",(function(){return Kt})),n.d(e,"each",(function(){return p})),n.d(e,"extend",(function(){return $t})),n.d(e,"indexOf",(function(){return Jt})),n.d(e,"isEmpty",(function(){return ee})),n.d(e,"isEqual",(function(){return ie})),n.d(e,"isEqualWith",(function(){return re})),n.d(e,"map",(function(){return oe})),n.d(e,"mapValues",(function(){return se})),n.d(e,"mix",(function(){return zt})),n.d(e,"assign",(function(){return zt})),n.d(e,"get",(function(){return ue})),n.d(e,"set",(function(){return le})),n.d(e,"pick",(function(){return he})),n.d(e,"throttle",(function(){return fe})),n.d(e,"toArray",(function(){return pe})),n.d(e,"toString",(function(){return Mt})),n.d(e,"uniqueId",(function(){return ge})),n.d(e,"noop",(function(){return ye})),n.d(e,"identity",(function(){return ve})),n.d(e,"size",(function(){return me})),n.d(e,"Cache",(function(){return xe}));var i=function(t){return null!==t&&"function"!=typeof t&&isFinite(t.length)},r=function(t,e){return!!i(t)&&t.indexOf(e)>-1},o=function(t,e){if(!i(t))return t;for(var n=[],r=0;r-1;)S.call(t,o,1);return t},I=Array.prototype.splice,T=function(t,e){if(!i(t))return[];for(var n=t?e.length:0,r=n-1;n--;){var o=void 0,a=e[n];n!==r&&a===o||(o=a,I.call(t,a,1))}return t},E=function(t,e,n){if(!h(t)&&!v(t))return t;var i=n;return p(t,(function(t,n){i=e(i,t,n)})),i},j=function(t,e){var n=[];if(!i(t))return n;for(var r=-1,o=[],a=t.length;++re[r])return 1;if(t[r]n?n:t},tt=function(t,e){var n=e.toString(),i=n.indexOf(".");if(-1===i)return Math.round(t);var r=n.substr(i+1).length;return r>20&&(r=20),parseFloat(t.toFixed(r))},et=function(t){return u(t,"Number")},nt=function(t){return et(t)&&t%1!=0},it=function(t){return et(t)&&t%2==0},rt=Number.isInteger?Number.isInteger:function(t){return et(t)&&t%1==0},ot=function(t){return et(t)&&t<0};function at(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)0},lt=function(t,e){if(h(t)){var n,i,r=t[0];return n=l(e)?e(t[0]):t[0][e],p(t,(function(t){(i=l(e)?e(t):t[e])>n&&(r=t,n=i)})),r}},ct=function(t,e){if(h(t)){var n,i,r=t[0];return n=l(e)?e(t[0]):t[0][e],p(t,(function(t){(i=l(e)?e(t):t[e])e?(i&&(clearTimeout(i),i=null),s=l,a=t.apply(r,o),i||(r=o=null)):i||!1===n.trailing||(i=setTimeout(u,c)),a};return l.cancel=function(){clearTimeout(i),s=0,i=r=o=null},l},pe=function(t){return i(t)?Array.prototype.slice.call(t):[]},de={},ge=function(t){return de[t=t||"g"]?de[t]+=1:de[t]=1,t+de[t]},ye=function(){},ve=function(t){return t};function me(t){return c(t)?0:i(t)?t.length:Object.keys(t).length}var xe=function(){function t(){this.map={}}return t.prototype.has=function(t){return void 0!==this.map[t]},t.prototype.get=function(t,e){var n=this.map[t];return void 0===n?e:n},t.prototype.set=function(t,e){this.map[t]=e},t.prototype.clear=function(){this.map={}},t.prototype.delete=function(t){delete this.map[t]},t.prototype.size=function(){return Object.keys(this.map).length},t}()},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return r})),n.d(e,"__assign",(function(){return o})),n.d(e,"__rest",(function(){return a})),n.d(e,"__decorate",(function(){return s})),n.d(e,"__param",(function(){return u})),n.d(e,"__metadata",(function(){return l})),n.d(e,"__awaiter",(function(){return c})),n.d(e,"__generator",(function(){return h})),n.d(e,"__createBinding",(function(){return f})),n.d(e,"__exportStar",(function(){return p})),n.d(e,"__values",(function(){return d})),n.d(e,"__read",(function(){return g})),n.d(e,"__spread",(function(){return y})),n.d(e,"__spreadArrays",(function(){return v})),n.d(e,"__await",(function(){return m})),n.d(e,"__asyncGenerator",(function(){return x})),n.d(e,"__asyncDelegator",(function(){return b})),n.d(e,"__asyncValues",(function(){return _})),n.d(e,"__makeTemplateObject",(function(){return M})),n.d(e,"__importStar",(function(){return w})),n.d(e,"__importDefault",(function(){return O})),n.d(e,"__classPrivateFieldGet",(function(){return S})),n.d(e,"__classPrivateFieldSet",(function(){return A})); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function r(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;s--)(r=t[s])&&(a=(o<3?r(a):o>3?r(e,n,a):r(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function u(t,e){return function(n,i){e(n,i,t)}}function l(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function h(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function y(){for(var t=[],e=0;e1||s(t,e)}))})}function s(t,e){try{(n=r[t](e)).value instanceof m?Promise.resolve(n.value.v).then(u,l):c(o[0][2],n)}catch(t){c(o[0][3],t)}var n}function u(t){s("next",t)}function l(t){s("throw",t)}function c(t,e){t(e),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:m(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=d(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}function M(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var C=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function w(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)"default"!==n&&Object.prototype.hasOwnProperty.call(t,n)&&f(e,t,n);return C(e,t),e}function O(t){return t&&t.__esModule?t:{default:t}}function S(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function A(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n}},function(t,e,n){"use strict";n.r(e),n.d(e,"mat3",(function(){return r})),n.d(e,"vec2",(function(){return o})),n.d(e,"vec3",(function(){return a})),n.d(e,"ext",(function(){return i}));var i={};n.r(i),n.d(i,"leftTranslate",(function(){return s})),n.d(i,"leftRotate",(function(){return u})),n.d(i,"leftScale",(function(){return l})),n.d(i,"transform",(function(){return c})),n.d(i,"direction",(function(){return h})),n.d(i,"angleTo",(function(){return f})),n.d(i,"vertical",(function(){return p}));var r=n(42),o=n(69),a=n(56);function s(t,e,n){var i=[0,0,0,0,0,0,0,0,0];return r.fromTranslation(i,n),r.multiply(t,i,e)}function u(t,e,n){var i=[0,0,0,0,0,0,0,0,0];return r.fromRotation(i,n),r.multiply(t,i,e)}function l(t,e,n){var i=[0,0,0,0,0,0,0,0,0];return r.fromScaling(i,n),r.multiply(t,i,e)}function c(t,e){for(var n,i,o,a=t?[].concat(t):[1,0,0,0,1,0,0,0,1],c=0,h=e.length;c=0;return n?r?2*Math.PI-i:i:r?i:2*Math.PI-i}function p(t,e,n){return n?(t[0]=e[1],t[1]=-1*e[0]):(t[0]=-1*e[1],t[1]=e[0]),t}},function(t,e,n){"use strict";n.d(e,"d",(function(){return _})),n.d(e,"b",(function(){return M})),n.d(e,"e",(function(){return C})),n.d(e,"f",(function(){return w})),n.d(e,"l",(function(){return O})),n.d(e,"j",(function(){return S}));var i=n(31),r=n.n(i);n.d(e,"i",(function(){return r.a}));var o=n(23),a=n.n(o);n.d(e,"k",(function(){return a.a}));var s=n(36),u=n.n(s);n.d(e,"h",(function(){return u.a}));var l=n(17),c=n.n(l);n.d(e,"g",(function(){return c.a}));var h=n(24),f=n.n(h);n.d(e,"c",(function(){return f.a}));var p=n(40),d=n.n(p);n.d(e,"o",(function(){return d.a}));var g=n(39),y=n.n(g);n.d(e,"m",(function(){return y.a}));n(53);var v=n(74),m=n.n(v);n.d(e,"n",(function(){return m.a}));var x=n(75),b=n.n(x);function _(){return window?window.devicePixelRatio:1}function M(t,e,n,i){var r=t-n,o=e-i;return Math.sqrt(r*r+o*o)}function C(t,e,n,i,r,o){return r>=t&&r<=t+n&&o>=e&&o<=e+i}function w(t,e){return!(e.minX>t.maxX||e.maxXt.maxY||e.maxY]*>/,s={tr:document.createElement("tbody"),tbody:r,thead:r,tfoot:r,td:o,th:o,"*":document.createElement("div")});var e=a.test(t)&&RegExp.$1;e&&e in s||(e="*");var n=s[e];t=t.replace(/(^\s*)|(\s*$)/g,""),n.innerHTML=""+t;var i=n.childNodes[0];return n.removeChild(i),i}function l(t,e,n){var i;try{i=window.getComputedStyle?window.getComputedStyle(t,null)[e]:t.style[e]}catch(t){}finally{i=void 0===i?n:i}return i}function c(t,e){var n=l(t,"height",e);return"auto"===n&&(n=t.offsetHeight),parseFloat(n)}function h(t,e){var n=c(t,e),i=parseFloat(l(t,"borderTopWidth"))||0,r=parseFloat(l(t,"paddingTop"))||0,o=parseFloat(l(t,"paddingBottom"))||0;return n+i+(parseFloat(l(t,"borderBottomWidth"))||0)+r+o+(parseFloat(l(t,"marginTop"))||0)+(parseFloat(l(t,"marginBottom"))||0)}function f(t,e){var n=l(t,"width",e);return"auto"===n&&(n=t.offsetWidth),parseFloat(n)}function p(t,e){var n=f(t,e),i=parseFloat(l(t,"borderLeftWidth"))||0,r=parseFloat(l(t,"paddingLeft"))||0,o=parseFloat(l(t,"paddingRight"))||0,a=parseFloat(l(t,"borderRightWidth"))||0,s=parseFloat(l(t,"marginRight"))||0;return n+i+a+r+o+(parseFloat(l(t,"marginLeft"))||0)+s}function d(){return window.devicePixelRatio?window.devicePixelRatio:2}function g(t,e){if(t)for(var n in e)e.hasOwnProperty(n)&&(t.style[n]=e[n]);return t}n.r(e),n.d(e,"addEventListener",(function(){return i})),n.d(e,"createDom",(function(){return u})),n.d(e,"getHeight",(function(){return c})),n.d(e,"getOuterHeight",(function(){return h})),n.d(e,"getOuterWidth",(function(){return p})),n.d(e,"getRatio",(function(){return d})),n.d(e,"getStyle",(function(){return l})),n.d(e,"getWidth",(function(){return f})),n.d(e,"modifyCSS",(function(){return g}))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.COMPONENT_MAX_VIEW_PERCENTAGE=e.MIN_CHART_HEIGHT=e.MIN_CHART_WIDTH=e.FIELD_ORIGIN=e.GROUP_ATTRS=e.ELEMENT_STATE=e.PLOT_EVENTS=e.VIEW_LIFE_CIRCLE=e.GROUP_Z_INDEX=e.COMPONENT_TYPE=e.DIRECTION=e.LAYER=void 0,function(t){t.FORE="fore",t.MID="mid",t.BG="bg"}(e.LAYER||(e.LAYER={})),function(t){t.TOP="top",t.TOP_LEFT="top-left",t.TOP_RIGHT="top-right",t.RIGHT="right",t.RIGHT_TOP="right-top",t.RIGHT_BOTTOM="right-bottom",t.LEFT="left",t.LEFT_TOP="left-top",t.LEFT_BOTTOM="left-bottom",t.BOTTOM="bottom",t.BOTTOM_LEFT="bottom-left",t.BOTTOM_RIGHT="bottom-right",t.RADIUS="radius",t.CIRCLE="circle",t.NONE="none"}(e.DIRECTION||(e.DIRECTION={})),function(t){t.AXIS="axis",t.GRID="grid",t.LEGEND="legend",t.TOOLTIP="tooltip",t.ANNOTATION="annotation",t.OTHER="other"}(e.COMPONENT_TYPE||(e.COMPONENT_TYPE={})),e.GROUP_Z_INDEX={FORE:3,MID:2,BG:1},function(t){t.BEFORE_RENDER="beforerender",t.AFTER_RENDER="afterrender",t.BEFORE_PAINT="beforepaint",t.AFTER_PAINT="afterpaint",t.BEFORE_CHANGE_DATA="beforechangedata",t.AFTER_CHANGE_DATA="afterchangedata",t.BEFORE_CLEAR="beforeclear",t.AFTER_CLEAR="afterclear",t.BEFORE_DESTROY="beforedestroy"}(e.VIEW_LIFE_CIRCLE||(e.VIEW_LIFE_CIRCLE={})),function(t){t.MOUSE_ENTER="plot:mouseenter",t.MOUSE_DOWN="plot:mousedown",t.MOUSE_MOVE="plot:mousemove",t.MOUSE_UP="plot:mouseup",t.MOUSE_LEAVE="plot:mouseleave",t.TOUCH_START="plot:touchstart",t.TOUCH_MOVE="plot:touchmove",t.TOUCH_END="plot:touchend",t.TOUCH_CANCEL="plot:touchcancel",t.CLICK="plot:click",t.DBLCLICK="plot:dblclick",t.CONTEXTMENU="plot:contextmenu",t.LEAVE="plot:leave",t.ENTER="plot:enter"}(e.PLOT_EVENTS||(e.PLOT_EVENTS={})),function(t){t.ACTIVE="active",t.INACTIVE="inactive",t.SELECTED="selected",t.DEFAULT="default"}(e.ELEMENT_STATE||(e.ELEMENT_STATE={})),e.GROUP_ATTRS=["color","shape","size"],e.FIELD_ORIGIN="_origin",e.MIN_CHART_WIDTH=1,e.MIN_CHART_HEIGHT=1,e.COMPONENT_MAX_VIEW_PERCENTAGE=.25},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getShapeFactory=e.registerShape=e.registerShapeFactory=void 0;var i=n(1),r=n(94),o=n(0),a=n(43),s={coordinate:null,defaultShapeType:null,theme:null,getShapePoints:function(t,e){var n=this.getShape(t);return n.getPoints?n.getPoints(e):this.getDefaultPoints(e)},getShape:function(t){var e=this[t]||this[this.defaultShapeType];return e.coordinate=this.coordinate,e},getDefaultPoints:function(){return[]},getMarker:function(t,e){var n=this.getShape(t);if(!n.getMarker){var i=this.defaultShapeType;n=this.getShape(i)}var r=this.theme,a=o.get(r,[t,"default"],{}),s=n.getMarker(e);return o.deepMix({},a,s)},drawShape:function(t,e,n){return this.getShape(t).draw(e,n)}},u={coordinate:null,parsePath:function(t){var e=this.coordinate,n=r.parsePathString(t);return n=e.isPolar?a.convertPolarPath(e,n):a.convertNormalPath(e,n)},parsePoint:function(t){return this.coordinate.convert(t)},parsePoints:function(t){var e=this.coordinate;return t.map((function(t){return e.convert(t)}))},draw:function(t,e){}},l={};e.registerShapeFactory=function(t,e){var n=o.upperFirst(t),r=i.__assign(i.__assign(i.__assign({},s),e),{geometryType:t});return l[n]=r,r},e.registerShape=function(t,e,n){var r=o.upperFirst(t),a=l[r],s=i.__assign(i.__assign({},u),n);return a[e]=s,s},e.getShapeFactory=function(t){var e=o.upperFirst(t);return l[e]}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getScaleByField=e.isInRecords=e.getSiblingPoint=e.getSilbings=e.isInBox=e.getSpline=e.distance=e.getComponents=e.getElementsByPath=e.getIntersectElements=e.intersectRect=e.getElementValue=e.getElementsByState=e.getElementsByField=e.getElements=e.getSiblingMaskElements=e.getMaskedElements=e.isMask=e.isSlider=e.isList=e.isElementChange=e.getDelegationObject=e.getCurrentElement=void 0;var i=n(1),r=n(0),o=n(43),a=n(44),s=i.__importDefault(n(157));function u(t,e){var n=t.event.target.getCanvasBBox();return n.width>=e||n.height>=e?n:null}function l(t){var e=t.geometries,n=[];return r.each(e,(function(t){var e=t.elements;n=n.concat(e)})),t.views&&t.views.length&&r.each(t.views,(function(t){n=n.concat(l(t))})),n}function c(t,e){var n=t.getModel().data;return r.isArray(n)?n[0][e]:n[e]}function h(t,e){return!(e.minX>t.maxX||e.maxXt.maxY||e.maxY=e||i.height>=e?n.attr("path"):null}(t,e);if(!n)return;return d(t.view,n)}var i=u(t,e);return i?f(t.view,i):null},e.getSiblingMaskElements=function(t,e,n){var i=u(t,n);if(!i)return null;var r=t.view,o=g(r,e,{x:i.x,y:i.y}),a=g(r,e,{x:i.maxX,y:i.maxY});return f(e,{minX:o.x,minY:o.y,maxX:a.x,maxY:a.y})},e.getElements=l,e.getElementsByField=function(t,e,n){return l(t).filter((function(t){return c(t,e)===n}))},e.getElementsByState=function(t,e){var n=t.geometries,i=[];return r.each(n,(function(t){var n=t.getElementsBy((function(t){return t.hasState(e)}));i=i.concat(n)})),i},e.getElementValue=c,e.intersectRect=h,e.getIntersectElements=f,e.getElementsByPath=d,e.getComponents=function(t){return t.getComponents().map((function(t){return t.component}))},e.distance=function(t,e){var n=e.x-t.x,i=e.y-t.y;return Math.sqrt(n*n+i*i)},e.getSpline=function(t,e){if(t.length<=2)return o.getLinePath(t,!1);var n=t[0],i=[];r.each(t,(function(t){i.push(t.x),i.push(t.y)}));var a=o.catmullRom2bezier(i,e,null);return a.unshift(["M",n.x,n.y]),a},e.isInBox=function(t,e){return t.x<=e.x&&t.maxX>=e.x&&t.y<=e.y&&t.maxY>e.y},e.getSilbings=function(t){var e=t.parent,n=null;return e&&(n=e.views.filter((function(e){return e!==t}))),n},e.getSiblingPoint=g,e.isInRecords=function(t,e,n,i){var o=!1;return r.each(t,(function(t){if(t[n]===e[n]&&t[i]===e[i])return o=!0,!1})),o},e.getScaleByField=function t(e,n){var i=e.getScaleByField(n);return!i&&e.views&&r.each(e.views,(function(e){if(i=t(e,n))return!1})),i}},function(t,e,n){"use strict";n.r(e),n.d(e,"version",(function(){return En})),n.d(e,"Event",(function(){return N})),n.d(e,"Base",(function(){return at})),n.d(e,"AbstractCanvas",(function(){return Pn})),n.d(e,"AbstractGroup",(function(){return In})),n.d(e,"AbstractShape",(function(){return Tn})),n.d(e,"PathUtil",(function(){return i}));var i={};n.r(i),n.d(i,"catmullRomToBezier",(function(){return c})),n.d(i,"fillPath",(function(){return j})),n.d(i,"fillPathByDiff",(function(){return B})),n.d(i,"formatPath",(function(){return R})),n.d(i,"intersection",(function(){return I})),n.d(i,"parsePathArray",(function(){return m})),n.d(i,"parsePathString",(function(){return l})),n.d(i,"pathToAbsolute",(function(){return f})),n.d(i,"pathToCurve",(function(){return y})),n.d(i,"rectPath",(function(){return w}));var r={};n.r(r),n.d(r,"easeLinear",(function(){return Wt})),n.d(r,"easeQuad",(function(){return Zt})),n.d(r,"easeQuadIn",(function(){return qt})),n.d(r,"easeQuadOut",(function(){return Ut})),n.d(r,"easeQuadInOut",(function(){return Zt})),n.d(r,"easeCubic",(function(){return $t})),n.d(r,"easeCubicIn",(function(){return Qt})),n.d(r,"easeCubicOut",(function(){return Kt})),n.d(r,"easeCubicInOut",(function(){return $t})),n.d(r,"easePoly",(function(){return ee})),n.d(r,"easePolyIn",(function(){return Jt})),n.d(r,"easePolyOut",(function(){return te})),n.d(r,"easePolyInOut",(function(){return ee})),n.d(r,"easeSin",(function(){return ae})),n.d(r,"easeSinIn",(function(){return re})),n.d(r,"easeSinOut",(function(){return oe})),n.d(r,"easeSinInOut",(function(){return ae})),n.d(r,"easeExp",(function(){return ce})),n.d(r,"easeExpIn",(function(){return ue})),n.d(r,"easeExpOut",(function(){return le})),n.d(r,"easeExpInOut",(function(){return ce})),n.d(r,"easeCircle",(function(){return pe})),n.d(r,"easeCircleIn",(function(){return he})),n.d(r,"easeCircleOut",(function(){return fe})),n.d(r,"easeCircleInOut",(function(){return pe})),n.d(r,"easeBounce",(function(){return ye})),n.d(r,"easeBounceIn",(function(){return ge})),n.d(r,"easeBounceOut",(function(){return ye})),n.d(r,"easeBounceInOut",(function(){return ve})),n.d(r,"easeBack",(function(){return be})),n.d(r,"easeBackIn",(function(){return me})),n.d(r,"easeBackOut",(function(){return xe})),n.d(r,"easeBackInOut",(function(){return be})),n.d(r,"easeElastic",(function(){return Ce})),n.d(r,"easeElasticIn",(function(){return Me})),n.d(r,"easeElasticOut",(function(){return Ce})),n.d(r,"easeElasticInOut",(function(){return we}));var o=n(0),a="\t\n\v\f\r   ᠎              \u2028\u2029",s=new RegExp("([a-z])["+a+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+a+"]*,?["+a+"]*)+)","ig"),u=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+a+"]*,?["+a+"]*","ig"),l=function(t){if(!t)return null;if(Object(o.isArray)(t))return t;var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},n=[];return String(t).replace(s,(function(i,r,o){var a=[],s=r.toLowerCase();if(o.replace(u,(function(t,e){e&&a.push(+e)})),"m"===s&&a.length>2&&(n.push([r].concat(a.splice(0,2))),s="l",r="m"===r?"l":"L"),"o"===s&&1===a.length&&n.push([r,a[0]]),"r"===s)n.push([r].concat(a));else for(;a.length>=e[s]&&(n.push([r].concat(a.splice(0,e[s]))),e[s]););return t})),n},c=function(t,e){for(var n=[],i=0,r=t.length;r-2*!e>i;i+=2){var o=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?r-4===i?o[3]={x:+t[0],y:+t[1]}:r-2===i&&(o[2]={x:+t[0],y:+t[1]},o[3]={x:+t[2],y:+t[3]}):o[0]={x:+t[r-2],y:+t[r-1]}:r-4===i?o[3]=o[2]:i||(o[0]={x:+t[i],y:+t[i+1]}),n.push(["C",(-o[0].x+6*o[1].x+o[2].x)/6,(-o[0].y+6*o[1].y+o[2].y)/6,(o[1].x+6*o[2].x-o[3].x)/6,(o[1].y+6*o[2].y-o[3].y)/6,o[2].x,o[2].y])}return n},h=function(t,e,n,i,r){var o=[];if(null===r&&null===i&&(i=n),t=+t,e=+e,n=+n,i=+i,null!==r){var a=Math.PI/180,s=t+n*Math.cos(-i*a),u=t+n*Math.cos(-r*a);o=[["M",s,e+n*Math.sin(-i*a)],["A",n,n,0,+(r-i>180),0,u,e+n*Math.sin(-r*a)]]}else o=[["M",t,e],["m",0,-i],["a",n,i,0,1,1,0,2*i],["a",n,i,0,1,1,0,-2*i],["z"]];return o},f=function(t){if(!(t=l(t))||!t.length)return[["M",0,0]];var e,n,i=[],r=0,o=0,a=0,s=0,u=0;"M"===t[0][0]&&(a=r=+t[0][1],s=o=+t[0][2],u++,i[0]=["M",r,o]);for(var f=3===t.length&&"M"===t[0][0]&&"R"===t[1][0].toUpperCase()&&"Z"===t[2][0].toUpperCase(),p=void 0,d=void 0,g=u,y=t.length;g1&&(n*=M=Math.sqrt(M),i*=M);var C=n*n,w=i*i,O=(o===a?-1:1)*Math.sqrt(Math.abs((C*w-C*_*_-w*b*b)/(C*_*_+w*b*b)));p=O*n*_/i+(t+s)/2,d=O*-i*b/n+(e+u)/2,h=Math.asin(((e-d)/i).toFixed(9)),f=Math.asin(((u-d)/i).toFixed(9)),h=tf&&(h-=2*Math.PI),!a&&f>h&&(f-=2*Math.PI)}var S=f-h;if(Math.abs(S)>y){var A=f,P=s,I=u;f=h+y*(a&&f>h?1:-1),s=p+n*Math.cos(f),u=d+i*Math.sin(f),m=g(s,u,n,i,r,0,a,P,I,[f,A,p,d])}S=f-h;var T=Math.cos(h),E=Math.sin(h),j=Math.cos(f),L=Math.sin(f),k=Math.tan(S/4),B=4/3*n*k,D=4/3*i*k,F=[t,e],R=[t+B*E,e-D*T],N=[s+B*L,u-D*j],G=[s,u];if(R[0]=2*F[0]-R[0],R[1]=2*F[1]-R[1],l)return[R,N,G].concat(m);for(var Y=[],V=0,X=(m=[R,N,G].concat(m).join().split(",")).length;V7){t[e].shift();for(var o=t[e];o.length;)s[e]="A",r&&(u[e]="A"),t.splice(e++,0,["C"].concat(o.splice(0,6)));t.splice(e,1),n=Math.max(i.length,r&&r.length||0)}},v=function(t,e,o,a,s){t&&e&&"M"===t[s][0]&&"M"!==e[s][0]&&(e.splice(s,0,["M",a.x,a.y]),o.bx=0,o.by=0,o.x=t[s][1],o.y=t[s][2],n=Math.max(i.length,r&&r.length||0))};n=Math.max(i.length,r&&r.length||0);for(var m=0;m1?1:u<0?0:u)/2,c=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],h=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],f=0,p=0;p<12;p++){var d=l*c[p]+l,g=x(d,t,n,r,a),y=x(d,e,i,o,s),v=g*g+y*y;f+=h[p]*Math.sqrt(v)}return l*f},_=function(t,e,n,i,r,o,a,s){for(var u,l,c,h,f=[],p=[[],[]],d=0;d<2;++d)if(0===d?(l=6*t-12*n+6*r,u=-3*t+9*n-9*r+3*a,c=3*n-3*t):(l=6*e-12*i+6*o,u=-3*e+9*i-9*o+3*s,c=3*i-3*e),Math.abs(u)<1e-12){if(Math.abs(l)<1e-12)continue;(h=-c/l)>0&&h<1&&f.push(h)}else{var g=l*l-4*c*u,y=Math.sqrt(g);if(!(g<0)){var v=(-l+y)/(2*u);v>0&&v<1&&f.push(v);var m=(-l-y)/(2*u);m>0&&m<1&&f.push(m)}}for(var x,b=f.length,_=b;b--;)x=1-(h=f[b]),p[0][b]=x*x*x*t+3*x*x*h*n+3*x*h*h*r+h*h*h*a,p[1][b]=x*x*x*e+3*x*x*h*i+3*x*h*h*o+h*h*h*s;return p[0][_]=t,p[1][_]=e,p[0][_+1]=a,p[1][_+1]=s,p[0].length=p[1].length=_+2,{min:{x:Math.min.apply(0,p[0]),y:Math.min.apply(0,p[1])},max:{x:Math.max.apply(0,p[0]),y:Math.max.apply(0,p[1])}}},M=function(t,e,n,i,r,o,a,s){if(!(Math.max(t,n)Math.max(r,a)||Math.max(e,i)Math.max(o,s))){var u=(t-n)*(o-s)-(e-i)*(r-a);if(u){var l=((t*i-e*n)*(r-a)-(t-n)*(r*s-o*a))/u,c=((t*i-e*n)*(o-s)-(e-i)*(r*s-o*a))/u,h=+l.toFixed(2),f=+c.toFixed(2);if(!(h<+Math.min(t,n).toFixed(2)||h>+Math.max(t,n).toFixed(2)||h<+Math.min(r,a).toFixed(2)||h>+Math.max(r,a).toFixed(2)||f<+Math.min(e,i).toFixed(2)||f>+Math.max(e,i).toFixed(2)||f<+Math.min(o,s).toFixed(2)||f>+Math.max(o,s).toFixed(2)))return{x:l,y:c}}}},C=function(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height},w=function(t,e,n,i,r){if(r)return[["M",+t+ +r,e],["l",n-2*r,0],["a",r,r,0,0,1,r,r],["l",0,i-2*r],["a",r,r,0,0,1,-r,r],["l",2*r-n,0],["a",r,r,0,0,1,-r,-r],["l",0,2*r-i],["a",r,r,0,0,1,r,-r],["z"]];var o=[["M",t,e],["l",n,0],["l",0,i],["l",-n,0],["z"]];return o.parsePathArray=m,o},O=function(t,e,n,i){return null===t&&(t=e=n=i=0),null===e&&(e=t.y,n=t.width,i=t.height,t=t.x),{x:t,y:e,width:n,w:n,height:i,h:i,x2:t+n,y2:e+i,cx:t+n/2,cy:e+i/2,r1:Math.min(n,i)/2,r2:Math.max(n,i)/2,r0:Math.sqrt(n*n+i*i)/2,path:w(t,e,n,i),vb:[t,e,n,i].join(" ")}},S=function(t,e,n,i,r,a,s,u){Object(o.isArray)(t)||(t=[t,e,n,i,r,a,s,u]);var l=_.apply(null,t);return O(l.min.x,l.min.y,l.max.x-l.min.x,l.max.y-l.min.y)},A=function(t,e,n,i,r,o,a,s,u){var l=1-u,c=Math.pow(l,3),h=Math.pow(l,2),f=u*u,p=f*u,d=t+2*u*(n-t)+f*(r-2*n+t),g=e+2*u*(i-e)+f*(o-2*i+e),y=n+2*u*(r-n)+f*(a-2*r+n),v=i+2*u*(o-i)+f*(s-2*o+i);return{x:c*t+3*h*u*n+3*l*u*u*r+p*a,y:c*e+3*h*u*i+3*l*u*u*o+p*s,m:{x:d,y:g},n:{x:y,y:v},start:{x:l*t+u*n,y:l*e+u*i},end:{x:l*r+u*a,y:l*o+u*s},alpha:90-180*Math.atan2(d-y,g-v)/Math.PI}},P=function(t,e,n){if(!function(t,e){return t=O(t),e=O(e),C(e,t.x,t.y)||C(e,t.x2,t.y)||C(e,t.x,t.y2)||C(e,t.x2,t.y2)||C(t,e.x,e.y)||C(t,e.x2,e.y)||C(t,e.x,e.y2)||C(t,e.x2,e.y2)||(t.xe.x||e.xt.x)&&(t.ye.y||e.yt.y)}(S(t),S(e)))return n?0:[];for(var i=~~(b.apply(0,t)/8),r=~~(b.apply(0,e)/8),o=[],a=[],s={},u=n?0:[],l=0;l=0&&x<=1&&_>=0&&_<=1&&(n?u+=1:u.push({x:m.x,y:m.y,t1:x,t2:_}))}}return u},I=function(t,e){return function(t,e,n){var i,r,o,a,s,u,l,c,h,f;t=y(t),e=y(e);for(var p=n?0:[],d=0,g=t.length;d=3&&(3===t.length&&e.push("Q"),e=e.concat(t[1])),2===t.length&&e.push("L"),e=e.concat(t[t.length-1])}))}(t,e,n));else{var r=[].concat(t);"M"===r[0]&&(r[0]="L");for(var o=0;o<=n-1;o++)i.push(r)}return i},j=function(t,e){if(1===t.length)return t;var n=t.length-1,i=e.length-1,r=n/i,o=[];if(1===t.length&&"M"===t[0][0]){for(var a=0;a=0;u--)a=o[u].index,"add"===o[u].type?t.splice(a,0,[].concat(t[a])):t.splice(a,1)}var h=r-(i=t.length);if(i0)){t[i]=e[i];break}n=D(n,t[i-1],1)}t[i]=["Q"].concat(n.reduce((function(t,e){return t.concat(e)}),[]));break;case"T":t[i]=["T"].concat(n[0]);break;case"C":if(n.length<3){if(!(i>0)){t[i]=e[i];break}n=D(n,t[i-1],2)}t[i]=["C"].concat(n.reduce((function(t,e){return t.concat(e)}),[]));break;case"S":if(n.length<2){if(!(i>0)){t[i]=e[i];break}n=D(n,t[i-1],1)}t[i]=["S"].concat(n.reduce((function(t,e){return t.concat(e)}),[]));break;default:t[i]=e[i]}return t},N=function(){function t(t,e){this.bubbles=!0,this.target=null,this.currentTarget=null,this.delegateTarget=null,this.delegateObject=null,this.defaultPrevented=!1,this.propagationStopped=!1,this.shape=null,this.fromShape=null,this.toShape=null,this.propagationPath=[],this.type=t,this.name=t,this.originalEvent=e,this.timeStamp=e.timeStamp}return t.prototype.preventDefault=function(){this.defaultPrevented=!0,this.originalEvent.preventDefault&&this.originalEvent.preventDefault()},t.prototype.stopPropagation=function(){this.propagationStopped=!0},t.prototype.toString=function(){return"[Event (type="+this.type+")]"},t.prototype.save=function(){},t.prototype.restore=function(){},t}(),G=n(1),Y=n(88),V=n(31),X=n.n(V),z=n(36),H=n.n(z),W=n(23),q=n.n(W),U=n(49),Z=n.n(U),Q=(n(17),n(67)),K=n.n(Q),$=n(24),J=n.n($),tt=n(68),et=n.n(tt);function nt(t,e){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}var it="undefined"!=typeof window&&void 0!==window.document;function rt(t,e){if(t.isCanvas())return!0;for(var n=e.getParent(),i=!1;n;){if(n===t){i=!0;break}n=n.getParent()}return i}function ot(t){return t.cfg.visible&&t.cfg.capture}var at=function(t){function e(e){var n=t.call(this)||this;n.destroyed=!1;var i=n.getDefaultCfg();return n.cfg=K()(i,e),n}return Object(G.__extends)(e,t),e.prototype.getDefaultCfg=function(){return{}},e.prototype.get=function(t){return this.cfg[t]},e.prototype.set=function(t,e){this.cfg[t]=e},e.prototype.destroy=function(){this.cfg={destroyed:!0},this.off(),this.destroyed=!0},e}(Y.default),st=function(){for(var t=0,e=0,n=arguments.length;et.delay&&Object(o.each)(e.toAttrs,(function(e,n){a.call(t.toAttrs,n)&&(delete t.toAttrs[n],delete t.fromAttrs[n])}))})),t}var St=function(t){function e(e){var n=t.call(this,e)||this;n.attrs={};var i=n.getDefaultAttrs();return Object(o.mix)(i,e.attrs),n.attrs=i,n.initAttrs(i),n.initAnimate(),n}return Object(G.__extends)(e,t),e.prototype.getDefaultCfg=function(){return{visible:!0,capture:!0,zIndex:0}},e.prototype.getDefaultAttrs=function(){return{matrix:this.getDefaultMatrix(),opacity:1}},e.prototype.onCanvasChange=function(t){},e.prototype.initAttrs=function(t){},e.prototype.initAnimate=function(){this.set("animable",!0),this.set("animating",!1)},e.prototype.isGroup=function(){return!1},e.prototype.getParent=function(){return this.get("parent")},e.prototype.getCanvas=function(){return this.get("canvas")},e.prototype.attr=function(){for(var t,e=[],n=0;n0?i=Ot(i,x):n.addAnimator(this),i.push(x),this.set("animations",i),this.set("_pause",{isPaused:!1})},e.prototype.stopAnimate=function(t){var e=this;void 0===t&&(t=!0);var n=this.get("animations");Object(o.each)(n,(function(n){t&&(n.onFrame?e.attr(n.onFrame(1)):e.attr(n.toAttrs)),n.callback&&n.callback()})),this.set("animating",!1),this.set("animations",[])},e.prototype.pauseAnimate=function(){var t=this.get("timeline"),e=this.get("animations"),n=t.getTime();return Object(o.each)(e,(function(t){t._paused=!0,t._pauseTime=n,t.pauseCallback&&t.pauseCallback()})),this.set("_pause",{isPaused:!0,pauseTime:n}),this},e.prototype.resumeAnimate=function(){var t=this.get("timeline").getTime(),e=this.get("animations"),n=this.get("_pause").pauseTime;return Object(o.each)(e,(function(e){e.startTime=e.startTime+(t-n),e._paused=!1,e._pauseTime=null,e.resumeCallback&&e.resumeCallback()})),this.set("_pause",{isPaused:!1}),this.set("animations",e),this},e.prototype.emitDelegation=function(t,e){var n,i=this,r=e.propagationPath;this.getEvents();"mouseenter"===t?n=e.fromShape:"mouseleave"===t&&(n=e.toShape);for(var a=function(t){var a=r[t],u=a.get("name");if(u){if((a.isGroup()||a.isCanvas&&a.isCanvas())&&n&&rt(a,n))return"break";Object(o.isArray)(u)?Object(o.each)(u,(function(t){i.emitDelegateEvent(a,t,e)})):s.emitDelegateEvent(a,u,e)}},s=this,u=0;u0)}));return a.length>0?(J()(a,(function(t){var e=t.getBBox();r.push(e.minX,e.maxX),o.push(e.minY,e.maxY)})),t=Math.min.apply(null,r),e=Math.max.apply(null,r),n=Math.min.apply(null,o),i=Math.max.apply(null,o)):(t=0,e=0,n=0,i=0),{x:t,y:n,minX:t,minY:n,maxX:e,maxY:i,width:e-t,height:i-n}},e.prototype.getCanvasBBox=function(){var t=1/0,e=-1/0,n=1/0,i=-1/0,r=[],o=[],a=this.getChildren().filter((function(t){return t.get("visible")&&(!t.isGroup()||t.isGroup()&&t.getChildren().length>0)}));return a.length>0?(J()(a,(function(t){var e=t.getCanvasBBox();r.push(e.minX,e.maxX),o.push(e.minY,e.maxY)})),t=Math.min.apply(null,r),e=Math.max.apply(null,r),n=Math.min.apply(null,o),i=Math.max.apply(null,o)):(t=0,e=0,n=0,i=0),{x:t,y:n,minX:t,minY:n,maxX:e,maxY:i,width:e-t,height:i-n}},e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.children=[],e},e.prototype.onAttrChange=function(e,n,i){if(t.prototype.onAttrChange.call(this,e,n,i),"matrix"===e){var r=this.getTotalMatrix();this._applyChildrenMarix(r)}},e.prototype.applyMatrix=function(e){var n=this.getTotalMatrix();t.prototype.applyMatrix.call(this,e);var i=this.getTotalMatrix();i!==n&&this._applyChildrenMarix(i)},e.prototype._applyChildrenMarix=function(t){var e=this.getChildren();J()(e,(function(e){e.applyMatrix(t)}))},e.prototype.addShape=function(){for(var t=[],e=0;e=0;o--){var a=t[o];if(ot(a)&&(a.isGroup()?r=a.getShape(e,n,i):a.isHit(e,n)&&(r=a)),r)break}return r},e.prototype.add=function(t){var e=this.getCanvas(),n=this.getChildren(),i=this.get("timeline"),r=t.getParent();r&&function(t,e,n){void 0===n&&(n=!0),n?e.destroy():(e.set("parent",null),e.set("canvas",null)),nt(t.getChildren(),e)}(r,t,!1),t.set("parent",this),e&&function t(e,n){if(e.set("canvas",n),e.isGroup()){var i=e.get("children");i.length&&i.forEach((function(e){t(e,n)}))}}(t,e),i&&function t(e,n){if(e.set("timeline",n),e.isGroup()){var i=e.get("children");i.length&&i.forEach((function(e){t(e,n)}))}}(t,i),n.push(t),function(t){t.isGroup()?(t.isEntityGroup()||t.get("children").length)&&t.onCanvasChange("add"):t.onCanvasChange("add")}(t),this._applyElementMatrix(t)},e.prototype._applyElementMatrix=function(t){var e=this.getTotalMatrix();e&&t.applyMatrix(e)},e.prototype.getChildren=function(){return this.get("children")},e.prototype.sort=function(){var t,e=this.getChildren();J()(e,(function(t,e){return t._INDEX=e,t})),e.sort((t=function(t,e){return t.get("zIndex")-e.get("zIndex")},function(e,n){var i=t(e,n);return 0===i?e._INDEX-n._INDEX:i})),this.onCanvasChange("sort")},e.prototype.clear=function(){if(this.set("clearing",!0),!this.destroyed){for(var t=this.getChildren(),e=t.length-1;e>=0;e--)t[e].destroy();this.set("children",[]),this.onCanvasChange("clear"),this.set("clearing",!1)}},e.prototype.destroy=function(){this.get("destroyed")||(this.clear(),t.prototype.destroy.call(this))},e.prototype.getFirst=function(){return this.getChildByIndex(0)},e.prototype.getLast=function(){var t=this.getChildren();return this.getChildByIndex(t.length-1)},e.prototype.getChildByIndex=function(t){return this.getChildren()[t]},e.prototype.getCount=function(){return this.getChildren().length},e.prototype.contain=function(t){return this.getChildren().indexOf(t)>-1},e.prototype.removeChild=function(t,e){void 0===e&&(e=!0),this.contain(t)&&t.remove(e)},e.prototype.findAll=function(t){var e=[],n=this.getChildren();return J()(n,(function(n){t(n)&&e.push(n),n.isGroup()&&(e=e.concat(n.findAll(t)))})),e},e.prototype.find=function(t){var e=null,n=this.getChildren();return J()(n,(function(n){if(t(n)?e=n:n.isGroup()&&(e=n.find(t)),e)return!1})),e},e.prototype.findById=function(t){return this.find((function(e){return e.get("id")===t}))},e.prototype.findByClassName=function(t){return this.find((function(e){return e.get("className")===t}))},e.prototype.findAllByName=function(t){return this.findAll((function(e){return e.get("name")===t}))},e}(St),Et=0,jt=0,Lt=0,kt=0,Bt=0,Dt=0,Ft="object"==typeof performance&&performance.now?performance:Date,Rt="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Nt(){return Bt||(Rt(Gt),Bt=Ft.now()+Dt)}function Gt(){Bt=0}function Yt(){this._call=this._time=this._next=null}function Vt(t,e,n){var i=new Yt;return i.restart(t,e,n),i}function Xt(){Bt=(kt=Ft.now())+Dt,Et=jt=0;try{!function(){Nt(),++Et;for(var t,e=Pt;e;)(t=Bt-e._time)>=0&&e._call.call(null,t),e=e._next;--Et}()}finally{Et=0,function(){var t,e,n=Pt,i=1/0;for(;n;)n._call?(i>n._time&&(i=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:Pt=e);It=t,Ht(i)}(),Bt=0}}function zt(){var t=Ft.now(),e=t-kt;e>1e3&&(Dt-=e,kt=t)}function Ht(t){Et||(jt&&(jt=clearTimeout(jt)),t-Bt>24?(t<1/0&&(jt=setTimeout(Xt,t-Ft.now()-Dt)),Lt&&(Lt=clearInterval(Lt))):(Lt||(kt=Ft.now(),Lt=setInterval(zt,1e3)),Et=1,Rt(Xt)))}function Wt(t){return+t}function qt(t){return t*t}function Ut(t){return t*(2-t)}function Zt(t){return((t*=2)<=1?t*t:--t*(2-t)+1)/2}function Qt(t){return t*t*t}function Kt(t){return--t*t*t+1}function $t(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}Yt.prototype=Vt.prototype={constructor:Yt,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?Nt():+n)+(null==e?0:+e),this._next||It===this||(It?It._next=this:Pt=this,It=this),this._call=t,this._time=n,Ht()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ht())}};var Jt=function t(e){function n(t){return Math.pow(t,e)}return e=+e,n.exponent=t,n}(3),te=function t(e){function n(t){return 1-Math.pow(1-t,e)}return e=+e,n.exponent=t,n}(3),ee=function t(e){function n(t){return((t*=2)<=1?Math.pow(t,e):2-Math.pow(2-t,e))/2}return e=+e,n.exponent=t,n}(3),ne=Math.PI,ie=ne/2;function re(t){return 1==+t?1:1-Math.cos(t*ie)}function oe(t){return Math.sin(t*ie)}function ae(t){return(1-Math.cos(ne*t))/2}function se(t){return 1.0009775171065494*(Math.pow(2,-10*t)-.0009765625)}function ue(t){return se(1-+t)}function le(t){return 1-se(t)}function ce(t){return((t*=2)<=1?se(1-t):2-se(t-1))/2}function he(t){return 1-Math.sqrt(1-t*t)}function fe(t){return Math.sqrt(1- --t*t)}function pe(t){return((t*=2)<=1?1-Math.sqrt(1-t*t):Math.sqrt(1-(t-=2)*t)+1)/2}var de=7.5625;function ge(t){return 1-ye(1-t)}function ye(t){return(t=+t)<4/11?de*t*t:t<8/11?de*(t-=6/11)*t+3/4:t<10/11?de*(t-=9/11)*t+15/16:de*(t-=21/22)*t+63/64}function ve(t){return((t*=2)<=1?1-ye(1-t):ye(t-1)+1)/2}var me=function t(e){function n(t){return(t=+t)*t*(e*(t-1)+t)}return e=+e,n.overshoot=t,n}(1.70158),xe=function t(e){function n(t){return--t*t*((t+1)*e+t)+1}return e=+e,n.overshoot=t,n}(1.70158),be=function t(e){function n(t){return((t*=2)<1?t*t*((e+1)*t-e):(t-=2)*t*((e+1)*t+e)+2)/2}return e=+e,n.overshoot=t,n}(1.70158),_e=2*Math.PI,Me=function t(e,n){var i=Math.asin(1/(e=Math.max(1,e)))*(n/=_e);function r(t){return e*se(- --t)*Math.sin((i-t)/n)}return r.amplitude=function(e){return t(e,n*_e)},r.period=function(n){return t(e,n)},r}(1,.3),Ce=function t(e,n){var i=Math.asin(1/(e=Math.max(1,e)))*(n/=_e);function r(t){return 1-e*se(t=+t)*Math.sin((t+i)/n)}return r.amplitude=function(e){return t(e,n*_e)},r.period=function(n){return t(e,n)},r}(1,.3),we=function t(e,n){var i=Math.asin(1/(e=Math.max(1,e)))*(n/=_e);function r(t){return((t=2*t-1)<0?e*se(-t)*Math.sin((i-t)/n):2-e*se(t)*Math.sin((i+t)/n))/2}return r.amplitude=function(e){return t(e,n*_e)},r.period=function(n){return t(e,n)},r}(1,.3),Oe=function(t,e,n){t.prototype=e.prototype=n,n.constructor=t};function Se(t,e){var n=Object.create(t.prototype);for(var i in e)n[i]=e[i];return n}function Ae(){}var Pe="\\s*([+-]?\\d+)\\s*",Ie="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",Te="\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Ee=/^#([0-9a-f]{3,8})$/,je=new RegExp("^rgb\\("+[Pe,Pe,Pe]+"\\)$"),Le=new RegExp("^rgb\\("+[Te,Te,Te]+"\\)$"),ke=new RegExp("^rgba\\("+[Pe,Pe,Pe,Ie]+"\\)$"),Be=new RegExp("^rgba\\("+[Te,Te,Te,Ie]+"\\)$"),De=new RegExp("^hsl\\("+[Ie,Te,Te]+"\\)$"),Fe=new RegExp("^hsla\\("+[Ie,Te,Te,Ie]+"\\)$"),Re={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Ne(){return this.rgb().formatHex()}function Ge(){return this.rgb().formatRgb()}function Ye(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=Ee.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Ve(e):3===n?new We(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Xe(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Xe(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=je.exec(t))?new We(e[1],e[2],e[3],1):(e=Le.exec(t))?new We(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=ke.exec(t))?Xe(e[1],e[2],e[3],e[4]):(e=Be.exec(t))?Xe(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=De.exec(t))?Qe(e[1],e[2]/100,e[3]/100,1):(e=Fe.exec(t))?Qe(e[1],e[2]/100,e[3]/100,e[4]):Re.hasOwnProperty(t)?Ve(Re[t]):"transparent"===t?new We(NaN,NaN,NaN,0):null}function Ve(t){return new We(t>>16&255,t>>8&255,255&t,1)}function Xe(t,e,n,i){return i<=0&&(t=e=n=NaN),new We(t,e,n,i)}function ze(t){return t instanceof Ae||(t=Ye(t)),t?new We((t=t.rgb()).r,t.g,t.b,t.opacity):new We}function He(t,e,n,i){return 1===arguments.length?ze(t):new We(t,e,n,null==i?1:i)}function We(t,e,n,i){this.r=+t,this.g=+e,this.b=+n,this.opacity=+i}function qe(){return"#"+Ze(this.r)+Ze(this.g)+Ze(this.b)}function Ue(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"rgb(":"rgba(")+Math.max(0,Math.min(255,Math.round(this.r)||0))+", "+Math.max(0,Math.min(255,Math.round(this.g)||0))+", "+Math.max(0,Math.min(255,Math.round(this.b)||0))+(1===t?")":", "+t+")")}function Ze(t){return((t=Math.max(0,Math.min(255,Math.round(t)||0)))<16?"0":"")+t.toString(16)}function Qe(t,e,n,i){return i<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new $e(t,e,n,i)}function Ke(t){if(t instanceof $e)return new $e(t.h,t.s,t.l,t.opacity);if(t instanceof Ae||(t=Ye(t)),!t)return new $e;if(t instanceof $e)return t;var e=(t=t.rgb()).r/255,n=t.g/255,i=t.b/255,r=Math.min(e,n,i),o=Math.max(e,n,i),a=NaN,s=o-r,u=(o+r)/2;return s?(a=e===o?(n-i)/s+6*(n0&&u<1?0:a,new $e(a,s,u,t.opacity)}function $e(t,e,n,i){this.h=+t,this.s=+e,this.l=+n,this.opacity=+i}function Je(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}function tn(t,e,n,i,r){var o=t*t,a=o*t;return((1-3*t+3*o-a)*e+(4-6*o+3*a)*n+(1+3*t+3*o-3*a)*i+a*r)/6}Oe(Ae,Ye,{copy:function(t){return Object.assign(new this.constructor,this,t)},displayable:function(){return this.rgb().displayable()},hex:Ne,formatHex:Ne,formatHsl:function(){return Ke(this).formatHsl()},formatRgb:Ge,toString:Ge}),Oe(We,He,Se(Ae,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new We(this.r*t,this.g*t,this.b*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new We(this.r*t,this.g*t,this.b*t,this.opacity)},rgb:function(){return this},displayable:function(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:qe,formatHex:qe,formatRgb:Ue,toString:Ue})),Oe($e,(function(t,e,n,i){return 1===arguments.length?Ke(t):new $e(t,e,n,null==i?1:i)}),Se(Ae,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new $e(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new $e(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,i=n+(n<.5?n:1-n)*e,r=2*n-i;return new We(Je(t>=240?t-240:t+120,r,i),Je(t,r,i),Je(t<120?t+240:t-120,r,i),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl:function(){var t=this.opacity;return(1===(t=isNaN(t)?1:Math.max(0,Math.min(1,t)))?"hsl(":"hsla(")+(this.h||0)+", "+100*(this.s||0)+"%, "+100*(this.l||0)+"%"+(1===t?")":", "+t+")")}}));var en=function(t){return function(){return t}};function nn(t,e){return function(n){return t+n*e}}function rn(t){return 1==(t=+t)?on:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(i){return Math.pow(t+i*e,n)}}(e,n,t):en(isNaN(e)?n:e)}}function on(t,e){var n=e-t;return n?nn(t,n):en(isNaN(t)?e:t)}var an=function t(e){var n=rn(e);function i(t,e){var i=n((t=He(t)).r,(e=He(e)).r),r=n(t.g,e.g),o=n(t.b,e.b),a=on(t.opacity,e.opacity);return function(e){return t.r=i(e),t.g=r(e),t.b=o(e),t.opacity=a(e),t+""}}return i.gamma=t,i}(1);function sn(t){return function(e){var n,i,r=e.length,o=new Array(r),a=new Array(r),s=new Array(r);for(n=0;n=1?(n=1,e-1):Math.floor(n*e),r=t[i],o=t[i+1],a=i>0?t[i-1]:2*r-o,s=io&&(r=e.slice(o,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,u.push({i:a,x:fn(n,i)})),o=gn.lastIndex;return od.length?(p=l(a[f]),d=l(r[f]),d=B(d,p),d=R(d,p),e.fromAttrs.path=d,e.toAttrs.path=p):e.pathFormatted||(p=l(a[f]),d=l(r[f]),d=R(d,p),e.fromAttrs.path=d,e.toAttrs.path=p,e.pathFormatted=!0),i[f]=[];for(var g=0;g0){for(var o=i.animators.length-1;o>=0;o--)if((t=i.animators[o]).destroyed)i.removeAnimator(o);else{if(!t.isAnimatePaused())for(var a=(e=t.get("animations")).length-1;a>=0;a--)n=e[a],xn(t,n,r)&&(e.splice(a,1),!1,n.callback&&n.callback());0===e.length&&i.removeAnimator(o)}i.canvas.get("autoDraw")||i.canvas.draw()}}))},t.prototype.addAnimator=function(t){this.animators.push(t)},t.prototype.removeAnimator=function(t){this.animators.splice(t,1)},t.prototype.isAnimating=function(){return!!this.animators.length},t.prototype.stop=function(){this.timer&&this.timer.stop()},t.prototype.stopAllAnimations=function(t){void 0===t&&(t=!0),this.animators.forEach((function(e){e.stopAnimate(t)})),this.animators=[],this.canvas.draw()},t.prototype.getTime=function(){return this.current},t}(),_n=["mousedown","mouseup","dblclick","mouseout","mouseover","mousemove","mouseleave","mouseenter","touchstart","touchmove","touchend","dragenter","dragover","dragleave","drop","contextmenu","mousewheel"];function Mn(t,e,n){n.name=e,n.target=t,n.currentTarget=t,n.delegateTarget=t,t.emit(e,n)}function Cn(t,e,n){if(n.bubbles){var i=void 0,r=!1;if("mouseenter"===e?(i=n.fromShape,r=!0):"mouseleave"===e&&(r=!0,i=n.toShape),t.isCanvas()&&r)return;if(i&&rt(t,i))return void(n.bubbles=!1);n.name=e,n.currentTarget=t,n.delegateTarget=t,t.emit(e,n)}}var wn,On=function(){function t(t){var e=this;this.draggingShape=null,this.dragging=!1,this.currentShape=null,this.mousedownShape=null,this.mousedownPoint=null,this._eventCallback=function(t){var n=t.type;e._triggerEvent(n,t)},this._onDocumentMove=function(t){if(e.canvas.get("el")!==t.target&&(e.dragging||e.currentShape)){var n=e._getPointInfo(t);e.dragging&&e._emitEvent("drag",t,n,e.draggingShape)}},this._onDocumentMouseUp=function(t){if(e.canvas.get("el")!==t.target&&e.dragging){var n=e._getPointInfo(t);e.draggingShape&&e._emitEvent("drop",t,n,null),e._emitEvent("dragend",t,n,e.draggingShape),e._afterDrag(e.draggingShape,n,t)}},this.canvas=t.canvas}return t.prototype.init=function(){this._bindEvents()},t.prototype._bindEvents=function(){var t=this,e=this.canvas.get("el");J()(_n,(function(n){e.addEventListener(n,t._eventCallback)})),document&&(document.addEventListener("mousemove",this._onDocumentMove),document.addEventListener("mouseup",this._onDocumentMouseUp))},t.prototype._clearEvents=function(){var t=this,e=this.canvas.get("el");J()(_n,(function(n){e.removeEventListener(n,t._eventCallback)})),document&&(document.removeEventListener("mousemove",this._onDocumentMove),document.removeEventListener("mouseup",this._onDocumentMouseUp))},t.prototype._getEventObj=function(t,e,n,i,r,o){var a=new N(t,e);return a.fromShape=r,a.toShape=o,a.x=n.x,a.y=n.y,a.clientX=n.clientX,a.clientY=n.clientY,a.propagationPath.push(i),a},t.prototype._getShape=function(t,e){return this.canvas.getShape(t.x,t.y,e)},t.prototype._getPointInfo=function(t){var e=this.canvas,n=e.getClientByEvent(t),i=e.getPointByEvent(t);return{x:i.x,y:i.y,clientX:n.x,clientY:n.y}},t.prototype._triggerEvent=function(t,e){var n=this._getPointInfo(e),i=this._getShape(n,e),r=this["_on"+t],o=!1;if(r)r.call(this,n,i,e);else{var a=this.currentShape;"mouseenter"===t||"dragenter"===t||"mouseover"===t?(this._emitEvent(t,e,n,null,null,i),i&&this._emitEvent(t,e,n,i,null,i),"mouseenter"===t&&this.draggingShape&&this._emitEvent("dragenter",e,n,null)):"mouseleave"===t||"dragleave"===t||"mouseout"===t?(o=!0,a&&this._emitEvent(t,e,n,a,a,null),this._emitEvent(t,e,n,null,a,null),"mouseleave"===t&&this.draggingShape&&this._emitEvent("dragleave",e,n,null)):this._emitEvent(t,e,n,i,null,null)}if(o||(this.currentShape=i),i&&!i.get("destroyed")){var s=this.canvas;s.get("el").style.cursor=i.attr("cursor")||s.get("cursor")}},t.prototype._onmousedown=function(t,e,n){0===n.button&&(this.mousedownShape=e,this.mousedownPoint=t,this.mousedownTimeStamp=n.timeStamp),this._emitEvent("mousedown",n,t,e,null,null)},t.prototype._emitMouseoverEvents=function(t,e,n,i){var r=this.canvas.get("el");n!==i&&(n&&(this._emitEvent("mouseout",t,e,n,n,i),this._emitEvent("mouseleave",t,e,n,n,i),i&&!i.get("destroyed")||(r.style.cursor=this.canvas.get("cursor"))),i&&(this._emitEvent("mouseover",t,e,i,n,i),this._emitEvent("mouseenter",t,e,i,n,i)))},t.prototype._emitDragoverEvents=function(t,e,n,i,r){i?(i!==n&&(n&&this._emitEvent("dragleave",t,e,n,n,i),this._emitEvent("dragenter",t,e,i,n,i)),r||this._emitEvent("dragover",t,e,i)):n&&this._emitEvent("dragleave",t,e,n,n,i),r&&this._emitEvent("dragover",t,e,i)},t.prototype._afterDrag=function(t,e,n){t&&(t.set("capture",!0),this.draggingShape=null),this.dragging=!1;var i=this._getShape(e,n);i!==t&&this._emitMouseoverEvents(n,e,t,i),this.currentShape=i},t.prototype._onmouseup=function(t,e,n){if(0===n.button){var i=this.draggingShape;this.dragging?(i&&this._emitEvent("drop",n,t,e),this._emitEvent("dragend",n,t,i),this._afterDrag(i,t,n)):(this._emitEvent("mouseup",n,t,e),e===this.mousedownShape&&this._emitEvent("click",n,t,e),this.mousedownShape=null,this.mousedownPoint=null)}},t.prototype._ondragover=function(t,e,n){n.preventDefault();var i=this.currentShape;this._emitDragoverEvents(n,t,i,e,!0)},t.prototype._onmousemove=function(t,e,n){var i=this.canvas,r=this.currentShape,o=this.draggingShape;if(this.dragging)o&&this._emitDragoverEvents(n,t,r,e,!1),this._emitEvent("drag",n,t,o);else{var a=this.mousedownPoint;if(a){var s=this.mousedownShape,u=n.timeStamp-this.mousedownTimeStamp,l=a.clientX-t.clientX,c=a.clientY-t.clientY;u>120||l*l+c*c>40?s&&s.get("draggable")?((o=this.mousedownShape).set("capture",!1),this.draggingShape=o,this.dragging=!0,this._emitEvent("dragstart",n,t,o),this.mousedownShape=null,this.mousedownPoint=null):!s&&i.get("draggable")?(this.dragging=!0,this._emitEvent("dragstart",n,t,null),this.mousedownShape=null,this.mousedownPoint=null):(this._emitMouseoverEvents(n,t,r,e),this._emitEvent("mousemove",n,t,e)):(this._emitMouseoverEvents(n,t,r,e),this._emitEvent("mousemove",n,t,e))}else this._emitMouseoverEvents(n,t,r,e),this._emitEvent("mousemove",n,t,e)}},t.prototype._emitEvent=function(t,e,n,i,r,o){var a=this._getEventObj(t,e,n,i,r,o);if(i){a.shape=i,Mn(i,t,a);for(var s=i.getParent();s;)s.emitDelegation(t,a),a.propagationStopped||Cn(s,t,a),a.propagationPath.push(s),s=s.getParent()}else{Mn(this.canvas,t,a)}},t.prototype.destroy=function(){this._clearEvents(),this.canvas=null,this.currentShape=null,this.draggingShape=null,this.mousedownPoint=null,this.mousedownShape=null,this.mousedownTimeStamp=null},t}(),Sn=wn?vt(wn):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new ft:"undefined"!=typeof navigator?vt(navigator.userAgent):"undefined"!=typeof process&&process.version?new lt(process.version.slice(1)):null,An=Sn&&"firefox"===Sn.name,Pn=function(t){function e(e){var n=t.call(this,e)||this;return n.initContainer(),n.initDom(),n.initEvents(),n.initTimeline(),n}return Object(G.__extends)(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.cursor="default",e.supportCSSTransform=!1,e},e.prototype.initContainer=function(){var t=this.get("container");q()(t)&&(t=document.getElementById(t),this.set("container",t))},e.prototype.initDom=function(){var t=this.createDom();this.set("el",t),this.get("container").appendChild(t),this.setDOMSize(this.get("width"),this.get("height"))},e.prototype.initEvents=function(){var t=new On({canvas:this});t.init(),this.set("eventController",t)},e.prototype.initTimeline=function(){var t=new bn(this);this.set("timeline",t)},e.prototype.setDOMSize=function(t,e){var n=this.get("el");it&&(n.style.width=t+"px",n.style.height=e+"px")},e.prototype.changeSize=function(t,e){this.setDOMSize(t,e),this.set("width",t),this.set("height",e),this.onCanvasChange("changeSize")},e.prototype.getRenderer=function(){return this.get("renderer")},e.prototype.getCursor=function(){return this.get("cursor")},e.prototype.setCursor=function(t){this.set("cursor",t);var e=this.get("el");it&&e&&(e.style.cursor=t)},e.prototype.getPointByEvent=function(t){if(this.get("supportCSSTransform")){if(An&&!X()(t.layerX)&&t.layerX!==t.offsetX)return{x:t.layerX,y:t.layerY};if(!X()(t.offsetX))return{x:t.offsetX,y:t.offsetY}}var e=this.getClientByEvent(t),n=e.x,i=e.y;return this.getPointByClient(n,i)},e.prototype.getClientByEvent=function(t){var e=t;return t.touches&&(e="touchend"===t.type?t.changedTouches[0]:t.touches[0]),{x:e.clientX,y:e.clientY}},e.prototype.getPointByClient=function(t,e){var n=this.get("el").getBoundingClientRect();return{x:t-n.left,y:e-n.top}},e.prototype.getClientByPoint=function(t,e){var n=this.get("el").getBoundingClientRect();return{x:t+n.left,y:e+n.top}},e.prototype.draw=function(){},e.prototype.removeDom=function(){var t=this.get("el");t.parentNode.removeChild(t)},e.prototype.clearEvents=function(){this.get("eventController").destroy()},e.prototype.isCanvas=function(){return!0},e.prototype.getParent=function(){return null},e.prototype.destroy=function(){var e=this.get("timeline");this.get("destroyed")||(this.clear(),e&&e.stop(),this.clearEvents(),this.removeDom(),t.prototype.destroy.call(this))},e}(Tt),In=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(G.__extends)(e,t),e.prototype.isGroup=function(){return!0},e.prototype.isEntityGroup=function(){return!1},e.prototype.clone=function(){for(var e=t.prototype.clone.call(this),n=this.getChildren(),i=0;i=t&&n.minY<=e&&n.maxY>=e},e.prototype.afterAttrsChange=function(e){t.prototype.afterAttrsChange.call(this,e),this.clearCacheBBox()},e.prototype.getBBox=function(){var t=this.get("bbox");return t||(t=this.calculateBBox(),this.set("bbox",t)),t},e.prototype.getCanvasBBox=function(){var t=this.get("canvasBox");return t||(t=this.calculateCanvasBBox(),this.set("canvasBox",t)),t},e.prototype.applyMatrix=function(e){t.prototype.applyMatrix.call(this,e),this.set("canvasBox",null)},e.prototype.calculateCanvasBBox=function(){var t=this.getBBox(),e=this.getTotalMatrix(),n=t.minX,i=t.minY,r=t.maxX,o=t.maxY;if(e){var a=bt(e,[t.minX,t.minY]),s=bt(e,[t.maxX,t.minY]),u=bt(e,[t.minX,t.maxY]),l=bt(e,[t.maxX,t.maxY]);n=Math.min(a[0],s[0],u[0],l[0]),r=Math.max(a[0],s[0],u[0],l[0]),i=Math.min(a[1],s[1],u[1],l[1]),o=Math.max(a[1],s[1],u[1],l[1])}var c=this.attrs;if(c.shadowColor){var h=c.shadowBlur,f=void 0===h?0:h,p=c.shadowOffsetX,d=void 0===p?0:p,g=c.shadowOffsetY,y=void 0===g?0:g,v=n-f+d,m=r+f+d,x=i-f+y,b=o+f+y;n=Math.min(n,v),r=Math.max(r,m),i=Math.min(i,x),o=Math.max(o,b)}return{x:n,y:i,minX:n,minY:i,maxX:r,maxY:o,width:r-n,height:o-i}},e.prototype.clearCacheBBox=function(){this.set("bbox",null),this.set("canvasBox",null)},e.prototype.isClipShape=function(){return this.get("isClipShape")},e.prototype.isInShape=function(t,e){return!1},e.prototype.isOnlyHitBox=function(){return!1},e.prototype.isHit=function(t,e){var n=this.get("startArrowShape"),i=this.get("endArrowShape"),r=[t,e,1],o=(r=this.invertFromMatrix(r))[0],a=r[1],s=this._isInBBox(o,a);if(this.isOnlyHitBox())return s;if(s&&!this.isClipped(o,a)){if(this.isInShape(o,a))return!0;if(n&&n.isHit(o,a))return!0;if(i&&i.isHit(o,a))return!0}return!1},e}(St),En=n(143).version},function(t,e,n){"use strict";n.d(e,"a",(function(){return f})),n.d(e,"b",(function(){return p})),n.d(e,"c",(function(){return d})),n.d(e,"f",(function(){return g})),n.d(e,"d",(function(){return y})),n.d(e,"e",(function(){return v}));var i=n(0),r=n(57),o=n(3);function a(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function s(t,e){return a(t)*a(e)?(t[0]*e[0]+t[1]*e[1])/(a(t)*a(e)):1}function u(t,e){return(t[0]*e[1]1&&(n*=Math.sqrt(y),i*=Math.sqrt(y));var v=n*n*(g*g)+i*i*(d*d),m=v?Math.sqrt((n*n*(i*i)-v)/v):1;a===l&&(m*=-1),isNaN(m)&&(m=0);var x=i?m*n*g/i:0,b=n?m*-i*d/n:0,_=(c+f)/2+Math.cos(r)*x-Math.sin(r)*b,M=(h+p)/2+Math.sin(r)*x+Math.cos(r)*b,C=[(d-x)/n,(g-b)/i],w=[(-1*d-x)/n,(-1*g-b)/i],O=u([1,0],C),S=u(C,w);return s(C,w)<=-1&&(S=Math.PI),s(C,w)>=1&&(S=0),0===l&&S>0&&(S-=2*Math.PI),1===l&&S<0&&(S+=2*Math.PI),{cx:_,cy:M,rx:Object(o.j)(t,[f,p])?0:n,ry:Object(o.j)(t,[f,p])?0:i,startAngle:O,endAngle:O+S,xRotation:r,arcFlag:a,sweepFlag:l}}var c=n(15),h={fill:"fillStyle",stroke:"strokeStyle",opacity:"globalAlpha"};function f(t,e){var n=e.attr();for(var o in n){var a=n[o],s=h[o]?h[o]:o;"matrix"===s&&a?t.transform(a[0],a[1],a[3],a[4],a[6],a[7]):"lineDash"===s&&t.setLineDash?Object(i.isArray)(a)&&t.setLineDash(a):("strokeStyle"===s||"fillStyle"===s?a=Object(r.b)(t,e,a):"globalAlpha"===s&&(a*=t.globalAlpha),t[s]=a)}}function p(t,e,n){for(var i=0;iM?_:M,P=_>M?1:_/M,I=_>M?M/_:1;e.translate(x,b),e.rotate(O),e.scale(P,I),e.arc(0,0,A,C,w,1-S),e.scale(1/P,1/I),e.rotate(-O),e.translate(-x,-b)}break;case"Z":e.closePath()}if("Z"===d)s=u;else{var T=p.length;s=[p[T-2],p[T-1]]}}}function g(t,e){var n=t.get("canvas");n&&("remove"===e&&(t._cacheCanvasBBox=t.get("cacheCanvasBBox")),t.get("hasChanged")||(n.refreshElement(t,e,n),n.get("autoDraw")&&n.draw(),t.set("hasChanged",!0)))}function y(t){if(!t.length)return null;var e=[],n=[],r=[],a=[];return Object(i.each)(t,(function(t){var i=function(t){var e;if(t.destroyed)e=t._cacheCanvasBBox;else{var n=t.get("cacheCanvasBBox"),i=n&&!(!n.width||!n.height),r=t.getCanvasBBox(),a=r&&!(!r.width||!r.height);i&&a?e=Object(o.l)(n,r):i?e=n:a&&(e=r)}return e}(t);i&&(e.push(i.minX),n.push(i.minY),r.push(i.maxX),a.push(i.maxY))})),{minX:Math.min.apply(null,e),minY:Math.min.apply(null,n),maxX:Math.max.apply(null,r),maxY:Math.max.apply(null,a)}}function v(t,e){return t&&e&&Object(o.f)(t,e)?{minX:Math.max(t.minX,e.minX),minY:Math.max(t.minY,e.minY),maxX:Math.min(t.maxX,e.maxX),maxY:Math.min(t.maxY,e.maxY)}:null}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getStyle=void 0;var i=n(1),r=n(0);e.getStyle=function(t,e,n,o){void 0===o&&(o="");var a=t.style,s=void 0===a?{}:a,u=t.defaultStyle,l=t.color,c=t.size,h=i.__assign(i.__assign({},u),s);return l&&(e&&(s.stroke||(h.stroke=l)),n&&(s.fill||(h.fill=l))),o&&r.isNil(s[o])&&!r.isNil(c)&&(h[o]=c),h}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),r=function(){function t(t,e){this.context=t,this.cfg=e,t.addAction(this)}return t.prototype.applyCfg=function(t){i.assign(this,t)},t.prototype.init=function(){this.applyCfg(this.cfg)},t.prototype.destroy=function(){this.context.removeAction(this),this.context=null},t}();e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(22),r=n(69);e.default={box:function(t,e,n,r){return i.getBBoxByArray([t,n],[e,r])},length:function(t,e,n,r){return i.distance(t,e,n,r)},pointAt:function(t,e,n,i,r){return{x:(1-r)*t+r*n,y:(1-r)*e+r*i}},pointDistance:function(t,e,n,r,o,a){var s=(n-t)*(o-t)+(r-e)*(a-e);return s<0?i.distance(t,e,o,a):s>(n-t)*(n-t)+(r-e)*(r-e)?i.distance(n,r,o,a):this.pointToLine(t,e,n,r,o,a)},pointToLine:function(t,e,n,i,o,a){var s=[n-t,i-e];if(r.exactEquals(s,[0,0]))return Math.sqrt((o-t)*(o-t)+(a-e)*(a-e));var u=[-s[1],s[0]];r.normalize(u,u);var l=[o-t,a-e];return Math.abs(r.dot(l,u))},tangentAngle:function(t,e,n,i){return Math.atan2(i-e,n-t)}}},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return r})),n.d(e,"__assign",(function(){return o})),n.d(e,"__rest",(function(){return a})),n.d(e,"__decorate",(function(){return s})),n.d(e,"__param",(function(){return u})),n.d(e,"__metadata",(function(){return l})),n.d(e,"__awaiter",(function(){return c})),n.d(e,"__generator",(function(){return h})),n.d(e,"__createBinding",(function(){return f})),n.d(e,"__exportStar",(function(){return p})),n.d(e,"__values",(function(){return d})),n.d(e,"__read",(function(){return g})),n.d(e,"__spread",(function(){return y})),n.d(e,"__spreadArrays",(function(){return v})),n.d(e,"__await",(function(){return m})),n.d(e,"__asyncGenerator",(function(){return x})),n.d(e,"__asyncDelegator",(function(){return b})),n.d(e,"__asyncValues",(function(){return _})),n.d(e,"__makeTemplateObject",(function(){return M})),n.d(e,"__importStar",(function(){return C})),n.d(e,"__importDefault",(function(){return w})),n.d(e,"__classPrivateFieldGet",(function(){return O})),n.d(e,"__classPrivateFieldSet",(function(){return S})); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function r(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;s--)(r=t[s])&&(a=(o<3?r(a):o>3?r(e,n,a):r(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function u(t,e){return function(n,i){e(n,i,t)}}function l(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function h(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function y(){for(var t=[],e=0;e1||s(t,e)}))})}function s(t,e){try{(n=r[t](e)).value instanceof m?Promise.resolve(n.value.v).then(u,l):c(o[0][2],n)}catch(t){c(o[0][3],t)}var n}function u(t){s("next",t)}function l(t){s("throw",t)}function c(t,e){t(e),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:m(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=d(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}function M(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function C(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function w(t){return t&&t.__esModule?t:{default:t}}function O(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function S(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n}},function(t,e,n){"use strict";n.d(e,"c",(function(){return h})),n.d(e,"b",(function(){return f})),n.d(e,"a",(function(){return p}));var i=n(1),r=n(25),o=Math.sin,a=Math.cos,s=Math.atan2,u=Math.PI;function l(t,e,n,i,l,c,h){var f=e.stroke,p=e.lineWidth,d=s(i-c,n-l),g=new r.Path({type:"path",canvas:t.get("canvas"),isArrowShape:!0,attrs:{path:"M"+10*a(u/6)+","+10*o(u/6)+" L0,0 L"+10*a(u/6)+",-"+10*o(u/6),stroke:f,lineWidth:p}});g.translate(l,c),g.rotateAtPoint(l,c,d),t.set(h?"startArrowShape":"endArrowShape",g)}function c(t,e,n,u,l,c,h){var f=e.startArrow,p=e.endArrow,d=e.stroke,g=e.lineWidth,y=h?f:p,v=y.d,m=y.fill,x=y.stroke,b=y.lineWidth,_=Object(i.__rest)(y,["d","fill","stroke","lineWidth"]),M=s(u-c,n-l);v&&(l-=a(M)*v,c-=o(M)*v);var C=new r.Path({type:"path",canvas:t.get("canvas"),isArrowShape:!0,attrs:Object(i.__assign)(Object(i.__assign)({},_),{stroke:x||d,lineWidth:b||g,fill:m})});C.translate(l,c),C.rotateAtPoint(l,c,M),t.set(h?"startArrowShape":"endArrowShape",C)}function h(t,e,n,i,r){var u=s(i-e,n-t);return{dx:a(u)*r,dy:o(u)*r}}function f(t,e,n,i,r,o){"object"==typeof e.startArrow?c(t,e,n,i,r,o,!0):e.startArrow?l(t,e,n,i,r,o,!0):t.set("startArrowShape",null)}function p(t,e,n,i,r,o){"object"==typeof e.endArrow?c(t,e,n,i,r,o,!1):e.endArrow?l(t,e,n,i,r,o,!1):t.set("startArrowShape",null)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getReplaceAttrs=e.getPolygonCentroid=e.getAngle=e.getArcPath=e.getSectorPath=e.polarToCartesian=void 0;var i=n(0);function r(t,e,n,i){return{x:t+n*Math.cos(i),y:e+n*Math.sin(i)}}e.polarToCartesian=r,e.getSectorPath=function(t,e,n,i,o,a){void 0===a&&(a=0);var s=r(t,e,n,i),u=r(t,e,n,o),l=r(t,e,a,i),c=r(t,e,a,o);if(o-i==2*Math.PI){var h=r(t,e,n,i+Math.PI),f=r(t,e,a,i+Math.PI),p=[["M",s.x,s.y],["A",n,n,0,1,1,h.x,h.y],["A",n,n,0,1,1,u.x,u.y],["M",l.x,l.y]];return a&&(p.push(["A",a,a,0,1,0,f.x,f.y]),p.push(["A",a,a,0,1,0,c.x,c.y])),p.push(["M",s.x,s.y]),p.push(["Z"]),p}var d=o-i<=Math.PI?0:1,g=[["M",s.x,s.y],["A",n,n,0,d,1,u.x,u.y],["L",c.x,c.y]];return a&&g.push(["A",a,a,0,d,0,l.x,l.y]),g.push(["L",s.x,s.y]),g.push(["Z"]),g},e.getArcPath=function(t,e,n,o,a){var s=r(t,e,n,o),u=r(t,e,n,a);if(i.isNumberEqual(a-o,2*Math.PI)){var l=r(t,e,n,o+Math.PI);return[["M",s.x,s.y],["A",n,n,0,1,1,l.x,l.y],["A",n,n,0,1,1,s.x,s.y],["A",n,n,0,1,0,l.x,l.y],["A",n,n,0,1,0,s.x,s.y],["Z"]]}var c=a-o<=Math.PI?0:1;return[["M",s.x,s.y],["A",n,n,0,c,1,u.x,u.y]]},e.getAngle=function(t,e){var n,r,o=function(t){if(i.isEmpty(t))return null;var e=t[0].x,n=t[0].x,r=t[0].y,o=t[0].y;return i.each(t,(function(t){e=e>t.x?t.x:e,n=nt.y?t.y:r,o=o=0},t.prototype.getAdjustRange=function(t,e,n){var i,r,o=this.yField,a=n.indexOf(e),s=n.length;return!o&&this.isAdjust("y")?(i=0,r=1):s>1?(i=n[0===a?0:a-1],r=n[a===s-1?s-1:a+1],0!==a?i+=(e-i)/2:i-=(r-e)/2,a!==s-1?r-=(r-e)/2:r+=(e-n[s-2])/2):(i=0===e?0:e-.5,r=0===e?1:e+.5),{pre:i,next:r}},t.prototype.adjustData=function(t,e){var n=this,r=this.getDimValues(e);i.each(t,(function(t,e){i.each(r,(function(i,r){n.adjustDim(r,i,t,e)}))}))},t.prototype.groupData=function(t,e){return i.each(t,(function(t){void 0===t[e]&&(t[e]=r.a)})),i.groupBy(t,e)},t.prototype.adjustDim=function(t,e,n,i){},t.prototype.getDimValues=function(t){var e=this.xField,n=this.yField,o={},a=[];if(e&&this.isAdjust("x")&&a.push(e),n&&this.isAdjust("y")&&a.push(n),a.forEach((function(e){o[e]=i.valuesOfKey(t,e).sort((function(t,e){return t-e}))})),!n&&this.isAdjust("y")){o.y=[r.a,1]}return o},t}();e.a=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Types=e.VERSION=void 0;var i=n(1);e.VERSION="4.0.15";var r=n(62);Object.defineProperty(e,"Chart",{enumerable:!0,get:function(){return r.Chart}}),Object.defineProperty(e,"View",{enumerable:!0,get:function(){return r.View}}),Object.defineProperty(e,"Event",{enumerable:!0,get:function(){return r.Event}});var o=n(37);Object.defineProperty(e,"ComponentController",{enumerable:!0,get:function(){return o.Controller}});var a=n(28);Object.defineProperty(e,"Geometry",{enumerable:!0,get:function(){return a.default}});var s=n(52);Object.defineProperty(e,"GeometryLabel",{enumerable:!0,get:function(){return s.default}});var u=n(70);Object.defineProperty(e,"Interaction",{enumerable:!0,get:function(){return u.Interaction}});var l=n(64);Object.defineProperty(e,"Facet",{enumerable:!0,get:function(){return l.Facet}});var c=n(12);Object.defineProperty(e,"InteractionAction",{enumerable:!0,get:function(){return c.default}});var h=n(62);Object.defineProperty(e,"registerComponentController",{enumerable:!0,get:function(){return h.registerComponentController}});var f=n(62);Object.defineProperty(e,"registerGeometry",{enumerable:!0,get:function(){return f.registerGeometry}});var p=n(7);Object.defineProperty(e,"registerShape",{enumerable:!0,get:function(){return p.registerShape}}),Object.defineProperty(e,"registerShapeFactory",{enumerable:!0,get:function(){return p.registerShapeFactory}}),Object.defineProperty(e,"getShapeFactory",{enumerable:!0,get:function(){return p.getShapeFactory}});var d=n(72);Object.defineProperty(e,"registerGeometryLabel",{enumerable:!0,get:function(){return d.registerGeometryLabel}}),Object.defineProperty(e,"registerGeometryLabelLayout",{enumerable:!0,get:function(){return d.registerGeometryLabelLayout}}),Object.defineProperty(e,"getGeometryLabel",{enumerable:!0,get:function(){return d.getGeometryLabel}}),Object.defineProperty(e,"getGeometryLabelLayout",{enumerable:!0,get:function(){return d.getGeometryLabelLayout}});var g=n(70);Object.defineProperty(e,"getInteraction",{enumerable:!0,get:function(){return g.getInteraction}}),Object.defineProperty(e,"registerInteraction",{enumerable:!0,get:function(){return g.registerInteraction}}),Object.defineProperty(e,"registerAction",{enumerable:!0,get:function(){return g.registerAction}}),Object.defineProperty(e,"getActionClass",{enumerable:!0,get:function(){return g.getActionClass}});var y=n(64);Object.defineProperty(e,"getFacet",{enumerable:!0,get:function(){return y.getFacet}}),Object.defineProperty(e,"registerFacet",{enumerable:!0,get:function(){return y.registerFacet}});var v=n(100);Object.defineProperty(e,"getTheme",{enumerable:!0,get:function(){return v.getTheme}}),Object.defineProperty(e,"registerTheme",{enumerable:!0,get:function(){return v.registerTheme}});var m=n(96);Object.defineProperty(e,"registerEngine",{enumerable:!0,get:function(){return m.registerEngine}}),Object.defineProperty(e,"getEngine",{enumerable:!0,get:function(){return m.getEngine}});var x=n(105);Object.defineProperty(e,"registerAnimation",{enumerable:!0,get:function(){return x.registerAnimation}}),Object.defineProperty(e,"getAnimation",{enumerable:!0,get:function(){return x.getAnimation}});var b=n(6);Object.defineProperty(e,"LAYER",{enumerable:!0,get:function(){return b.LAYER}}),Object.defineProperty(e,"DIRECTION",{enumerable:!0,get:function(){return b.DIRECTION}});var _=i.__importStar(n(172));e.Types=_},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCoordinateClipCfg=e.getAngleByPoint=e.isPointInCoordinate=e.getDistanceToCenter=e.isFullCircle=e.getXDimensionLength=void 0;var i=n(16),r=n(27);e.getXDimensionLength=function(t){if(t.isPolar&&!t.isTransposed)return(t.endAngle-t.startAngle)*t.getRadius();var e=t.convert({x:0,y:0}),n=t.convert({x:1,y:0});return Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2))},e.isFullCircle=function(t){if(t.isPolar){var e=t.startAngle;return t.endAngle-e==2*Math.PI}return!1},e.getDistanceToCenter=function(t,e){var n=t.getCenter();return Math.sqrt(Math.pow(e.x-n.x,2)+Math.pow(e.y-n.y,2))},e.isPointInCoordinate=function(t,e){var n=!1;if(t)if("theta"===t.type){var i=t.start,o=t.end;n=r.isBetween(e.x,i.x,o.x)&&r.isBetween(e.y,i.y,o.y)}else{var a=t.invert(e);n=r.isBetween(a.x,0,1)&&r.isBetween(a.y,0,1)}return n},e.getAngleByPoint=function(t,e){var n=t.getCenter();return Math.atan2(e.y-n.y,e.x-n.x)},e.getCoordinateClipCfg=function(t,e){void 0===e&&(e=0);var n,r=t.start,o=t.end,a=t.getWidth(),s=t.getHeight();if(t.isPolar){var u=t.startAngle,l=t.endAngle,c=t.getCenter(),h=t.getRadius();return{type:"path",startState:{path:i.getSectorPath(c.x,c.y,h+e,u,u)},endState:function(t){var n=(l-u)*t+u;return{path:i.getSectorPath(c.x,c.y,h+e,u,n)}},attrs:{path:i.getSectorPath(c.x,c.y,h+e,u,l)}}}return n=t.isTransposed?{height:s+2*e}:{width:a+2*e},{type:"rect",startState:{x:r.x-e,y:o.y-e,width:t.isTransposed?a+2*e:0,height:t.isTransposed?0:s+2*e},endState:n,attrs:{x:r.x-e,y:o.y-e,width:a+2*e,height:s+2*e}}}},function(t,e,n){"use strict";n.r(e),n.d(e,"__extends",(function(){return r})),n.d(e,"__assign",(function(){return o})),n.d(e,"__rest",(function(){return a})),n.d(e,"__decorate",(function(){return s})),n.d(e,"__param",(function(){return u})),n.d(e,"__metadata",(function(){return l})),n.d(e,"__awaiter",(function(){return c})),n.d(e,"__generator",(function(){return h})),n.d(e,"__createBinding",(function(){return f})),n.d(e,"__exportStar",(function(){return p})),n.d(e,"__values",(function(){return d})),n.d(e,"__read",(function(){return g})),n.d(e,"__spread",(function(){return y})),n.d(e,"__spreadArrays",(function(){return v})),n.d(e,"__await",(function(){return m})),n.d(e,"__asyncGenerator",(function(){return x})),n.d(e,"__asyncDelegator",(function(){return b})),n.d(e,"__asyncValues",(function(){return _})),n.d(e,"__makeTemplateObject",(function(){return M})),n.d(e,"__importStar",(function(){return C})),n.d(e,"__importDefault",(function(){return w})),n.d(e,"__classPrivateFieldGet",(function(){return O})),n.d(e,"__classPrivateFieldSet",(function(){return S})); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function r(t,e){function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var o=function(){return(o=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;s--)(r=t[s])&&(a=(o<3?r(a):o>3?r(e,n,a):r(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function u(t,e){return function(n,i){e(n,i,t)}}function l(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function c(t,e,n,i){return new(n||(n=Promise))((function(r,o){function a(t){try{u(i.next(t))}catch(t){o(t)}}function s(t){try{u(i.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((i=i.apply(t,e||[])).next())}))}function h(t,e){var n,i,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,i=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var i,r,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(i=o.next()).done;)a.push(i.value)}catch(t){r={error:t}}finally{try{i&&!i.done&&(n=o.return)&&n.call(o)}finally{if(r)throw r.error}}return a}function y(){for(var t=[],e=0;e1||s(t,e)}))})}function s(t,e){try{(n=r[t](e)).value instanceof m?Promise.resolve(n.value.v).then(u,l):c(o[0][2],n)}catch(t){c(o[0][3],t)}var n}function u(t){s("next",t)}function l(t){s("throw",t)}function c(t,e){t(e),o.shift(),o.length&&s(o[0][0],o[0][1])}}function b(t){var e,n;return e={},i("next"),i("throw",(function(t){throw t})),i("return"),e[Symbol.iterator]=function(){return this},e;function i(i,r){e[i]=t[i]?function(e){return(n=!n)?{value:m(t[i](e)),done:"return"===i}:r?r(e):e}:r}}function _(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=d(t),e={},i("next"),i("throw"),i("return"),e[Symbol.asyncIterator]=function(){return this},e);function i(n){e[n]=t[n]&&function(e){return new Promise((function(i,r){(function(t,e,n,i){Promise.resolve(i).then((function(e){t({value:e,done:n})}),e)})(i,r,(e=t[n](e)).done,e.value)}))}}}function M(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function C(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function w(t){return t&&t.__esModule?t:{default:t}}function O(t,e){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return e.get(t)}function S(t,e,n){if(!e.has(t))throw new TypeError("attempted to set private field on non-instance");return e.set(t,n),n}},function(t,e,n){"use strict";function i(t){return Math.min.apply(null,t)}function r(t){return Math.max.apply(null,t)}Object.defineProperty(e,"__esModule",{value:!0}),e.piMod=e.getBBoxRange=e.getBBoxByArray=e.isNumberEqual=e.distance=void 0,e.distance=function(t,e,n,i){var r=t-n,o=e-i;return Math.sqrt(r*r+o*o)},e.isNumberEqual=function(t,e){return Math.abs(t-e)<.001},e.getBBoxByArray=function(t,e){var n=i(t),o=i(e);return{x:n,y:o,width:r(t)-n,height:r(e)-o}},e.getBBoxRange=function(t,e,n,o){return{minX:i([t,n]),maxX:r([t,n]),minY:i([e,o]),maxY:r([e,o])}},e.piMod=function(t){return(t+2*Math.PI)%(2*Math.PI)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(66);e.default=function(t){return i.default(t,"String")}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(17),r=n(49);e.default=function(t,e){if(t)if(i.default(t))for(var n=0,o=t.length;n0&&(Object(a.i)(r)||1===r||(t.globalAlpha=r),this.stroke(t)),this.afterDrawPath(t)},e.prototype.createPath=function(t){},e.prototype.afterDrawPath=function(t){},e.prototype.isInShape=function(t,e){var n=this.isStroke(),i=this.isFill(),r=this.getHitLineWidth();return this.isInStrokeOrPath(t,e,n,i,r)},e.prototype.isInStrokeOrPath=function(t,e,n,i,r){return!1},e.prototype.getHitLineWidth=function(){if(!this.isStroke())return 0;var t=this.attrs;return t.lineWidth+t.lineAppendWidth},e}(o.AbstractShape),h=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,r:0})},e.prototype.isInStrokeOrPath=function(t,e,n,i,r){var o=this.attr(),s=o.x,u=o.y,l=o.r,c=r/2,h=Object(a.b)(s,u,t,e);return i&&n?h<=l+c:i?h<=l:!!n&&(h>=l-c&&h<=l+c)},e.prototype.createPath=function(t){var e=this.attr(),n=e.x,i=e.y,r=e.r;t.beginPath(),t.arc(n,i,r,0,2*Math.PI,!1),t.closePath()},e}(c);function f(t,e,n,i){return t/(n*n)+e/(i*i)}var p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,rx:0,ry:0})},e.prototype.isInStrokeOrPath=function(t,e,n,i,r){var o=this.attr(),a=r/2,s=o.x,u=o.y,l=o.rx,c=o.ry,h=(t-s)*(t-s),p=(e-u)*(e-u);return i&&n?f(h,p,l+a,c+a)<=1:i?f(h,p,l,c)<=1:!!n&&(f(h,p,l-a,c-a)>=1&&f(h,p,l+a,c+a)<=1)},e.prototype.createPath=function(t){var e=this.attr(),n=e.x,i=e.y,r=e.rx,o=e.ry;if(t.beginPath(),t.ellipse)t.ellipse(n,i,r,o,0,0,2*Math.PI,!1);else{var a=r>o?r:o,s=r>o?1:r/o,u=r>o?o/r:1;t.save(),t.translate(n,i),t.scale(s,u),t.arc(0,0,a,0,2*Math.PI),t.restore(),t.closePath()}},e}(c);function d(t){return t instanceof HTMLElement&&Object(a.k)(t.nodeName)&&"CANVAS"===t.nodeName.toUpperCase()}var g=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,width:0,height:0})},e.prototype.initAttrs=function(t){this._setImage(t.img)},e.prototype.isStroke=function(){return!1},e.prototype.isOnlyHitBox=function(){return!0},e.prototype._afterLoading=function(){if(!0===this.get("toDraw")){var t=this.get("canvas");t?t.draw():this.createPath(this.get("context"))}},e.prototype._setImage=function(t){var e=this,n=this.attrs;if(Object(a.k)(t)){var i=new Image;i.onload=function(){if(e.destroyed)return!1;e.attr("img",i),e.set("loading",!1),e._afterLoading();var t=e.get("callback");t&&t.call(e)},i.crossOrigin="Anonymous",i.src=t,this.set("loading",!0)}else t instanceof Image?(n.width||(n.width=t.width),n.height||(n.height=t.height)):d(t)&&(n.width||(n.width=Number(t.getAttribute("width"))),n.height||(n.height,Number(t.getAttribute("height"))))},e.prototype.onAttrChange=function(e,n,i){t.prototype.onAttrChange.call(this,e,n,i),"img"===e&&this._setImage(n)},e.prototype.createPath=function(t){if(this.get("loading"))return this.set("toDraw",!0),void this.set("context",t);var e=this.attr(),n=e.x,i=e.y,r=e.width,o=e.height,s=e.sx,u=e.sy,l=e.swidth,c=e.sheight,h=e.img;(h instanceof Image||d(h))&&(Object(a.i)(s)||Object(a.i)(u)||Object(a.i)(l)||Object(a.i)(c)?t.drawImage(h,n,i,r,o):t.drawImage(h,s,u,l,c,n,i,r,o))},e}(c),y=n(13),v=n.n(y);function m(t,e,n,i,r,o,a){var s=Math.min(t,n),u=Math.max(t,n),l=Math.min(e,i),c=Math.max(e,i),h=r/2;return o>=s-h&&o<=u+h&&a>=l-h&&a<=c+h&&v.a.pointToLine(t,e,n,i,o,a)<=r/2}var x=n(15),b=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x1:0,y1:0,x2:0,y2:0,startArrow:!1,endArrow:!1})},e.prototype.initAttrs=function(t){this.setArrow()},e.prototype.onAttrChange=function(e,n,i){t.prototype.onAttrChange.call(this,e,n,i),this.setArrow()},e.prototype.setArrow=function(){var t=this.attr(),e=t.x1,n=t.y1,i=t.x2,r=t.y2,o=t.startArrow,a=t.endArrow;o&&x.b(this,t,i,r,e,n),a&&x.a(this,t,e,n,i,r)},e.prototype.isInStrokeOrPath=function(t,e,n,i,r){if(!n||!r)return!1;var o=this.attr();return m(o.x1,o.y1,o.x2,o.y2,r,t,e)},e.prototype.createPath=function(t){var e=this.attr(),n=e.x1,i=e.y1,r=e.x2,o=e.y2,a=e.startArrow,s=e.endArrow,u={dx:0,dy:0},l={dx:0,dy:0};a&&a.d&&(u=x.c(n,i,r,o,e.startArrow.d)),s&&s.d&&(l=x.c(n,i,r,o,e.endArrow.d)),t.beginPath(),t.moveTo(n+u.dx,i+u.dy),t.lineTo(r-l.dx,o-l.dy)},e.prototype.afterDrawPath=function(t){var e=this.get("startArrowShape"),n=this.get("endArrowShape");e&&e.draw(t),n&&n.draw(t)},e.prototype.getTotalLength=function(){var t=this.attr(),e=t.x1,n=t.y1,i=t.x2,r=t.y2;return v.a.length(e,n,i,r)},e.prototype.getPoint=function(t){var e=this.attr(),n=e.x1,i=e.y1,r=e.x2,o=e.y2;return v.a.pointAt(n,i,r,o,t)},e}(c),_=n(0),M=n(60),C=n.n(M),w={circle:function(t,e,n){return[["M",t-n,e],["A",n,n,0,1,0,t+n,e],["A",n,n,0,1,0,t-n,e]]},square:function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]},diamond:function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]},triangle:function(t,e,n){var i=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+i],["L",t,e-i],["L",t+n,e+i],["Z"]]},"triangle-down":function(t,e,n){var i=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-i],["L",t+n,e-i],["L",t,e+i],["Z"]]}},O=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.initAttrs=function(t){this._resetParamsCache()},e.prototype._resetParamsCache=function(){this.set("paramsCache",{})},e.prototype.onAttrChange=function(e,n,i){t.prototype.onAttrChange.call(this,e,n,i),-1!==["symbol","x","y","r","radius"].indexOf(e)&&this._resetParamsCache()},e.prototype.isOnlyHitBox=function(){return!0},e.prototype._getR=function(t){return Object(_.isNil)(t.r)?t.radius:t.r},e.prototype._getPath=function(){var t,n,i=this.attr(),r=i.x,o=i.y,s=i.symbol||"circle",u=this._getR(i);return Object(a.h)(s)?(n=(t=s)(r,o,u),n=C()(n)):n=(t=e.Symbols[s])(r,o,u),t?n:(console.warn(s+" marker is not supported."),null)},e.prototype.createPath=function(t){var e=this._getPath(),n=this.get("paramsCache");Object(s.c)(this,t,{path:e},n)},e.Symbols=w,e}(c),S=n(35),A=n.n(S),P=n(93),I=n.n(P),T=n(91);function E(t,e,n){var i=Object(T.getOffScreenContext)();return t.createPath(i),i.isPointInPath(e,n)}function j(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function L(t,e,n){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function k(t,e,n){var i=!1,r=t.length;if(r<=2)return!1;for(var o=0;o0!=j(s[1]-n)>0&&j(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(i=!i)}return i}var B=n(92),D=n.n(B);function F(t,e,n,i,r,o,s,u){var l=(Math.atan2(u-e,s-t)+2*Math.PI)%(2*Math.PI);if(lr)return!1;var c={x:t+n*Math.cos(l),y:e+n*Math.sin(l)};return Object(a.b)(c.x,c.y,s,u)<=o/2}var R=n(42),N=n(56);var G=Object(r.__assign)({hasArc:function(t){for(var e=!1,n=t.length,i=0;i0&&i.push(r),{polygons:n,polylines:i}},isPointInStroke:function(t,e,n,i){for(var r=!1,o=e/2,s=0;sv?y:v,O=y>v?1:y/v,S=y>v?v/y:1;R.translate(C,C,[-d,-g]),R.rotate(C,C,-_),R.scale(C,C,[1/O,1/S]),N.transformMat3(M,M,C),r=F(0,0,w,x,b,e,M[0],M[1])}if(r)break}}return r}},o.PathUtil);function Y(t,e,n){for(var i=!1,r=0;r=i[0]&&t<=i[1]&&(e=(t-i[0])/(i[1]-i[0]),n=r)}));var o=r[n];if(Object(_.isNil)(o)||Object(_.isNil)(n))return null;var a=o.length,s=r[n+1];return A.a.pointAt(o[a-2],o[a-1],s[1],s[2],s[3],s[4],s[5],s[6],e)},e.prototype._calculateCurve=function(){var t=this.attr().path;this.set("curve",G.pathToCurve(t))},e.prototype._setTcache=function(){var t,e,n,i,r=0,o=0,a=[],s=this.get("curve");s&&(Object(_.each)(s,(function(t,e){n=s[e+1],i=t.length,n&&(r+=A.a.length(t[i-2],t[i-1],n[1],n[2],n[3],n[4],n[5],n[6])||0)})),this.set("totalLength",r),0!==r?(Object(_.each)(s,(function(u,l){n=s[l+1],i=u.length,n&&((t=[])[0]=o/r,e=A.a.length(u[i-2],u[i-1],n[1],n[2],n[3],n[4],n[5],n[6]),o+=e||0,t[1]=o/r,a.push(t))})),this.set("tCache",a)):this.set("tCache",[]))},e.prototype.getStartTangent=function(){var t,e=this.getSegments();if(e.length>1){var n=e[0].currentPoint,i=e[1].currentPoint,r=e[1].startTangent;t=[],r?(t.push([n[0]-r[0],n[1]-r[1]]),t.push([n[0],n[1]])):(t.push([i[0],i[1]]),t.push([n[0],n[1]]))}return t},e.prototype.getEndTangent=function(){var t,e=this.getSegments(),n=e.length;if(n>1){var i=e[n-2].currentPoint,r=e[n-1].currentPoint,o=e[n-1].endTangent;t=[],o?(t.push([r[0]-o[0],r[1]-o[1]]),t.push([r[0],r[1]])):(t.push([i[0],i[1]]),t.push([r[0],r[1]]))}return t},e}(c);function X(t,e,n,i,r){var o=t.length;if(o<2)return!1;for(var a=0;a=i[0]&&t<=i[1]&&(e=(t-i[0])/(i[1]-i[0]),n=r)})),v.a.pointAt(i[n][0],i[n][1],i[n+1][0],i[n+1][1],e)},e.prototype._setTcache=function(){var t=this.attr().points;if(t&&0!==t.length){var e=this.getTotalLength();if(!(e<=0)){var n,i,r=0,o=[];Object(_.each)(t,(function(a,s){t[s+1]&&((n=[])[0]=r/e,i=v.a.length(a[0],a[1],t[s+1][0],t[s+1][1]),r+=i,n[1]=r/e,o.push(n))})),this.set("tCache",o)}}},e.prototype.getStartTangent=function(){var t=this.attr().points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e},e.prototype.getEndTangent=function(){var t=this.attr().points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n},e}(c),U=n(57);var Z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,width:0,height:0,radius:0})},e.prototype.isInStrokeOrPath=function(t,e,n,i,r){var o=this.attr(),s=o.x,u=o.y,l=o.width,c=o.height,h=o.radius;if(h){var f=!1;return n&&(f=function(t,e,n,i,r,o,a,s){return m(t+r,e,t+n-r,e,o,a,s)||m(t+n,e+r,t+n,e+i-r,o,a,s)||m(t+n-r,e+i,t+r,e+i,o,a,s)||m(t,e+i-r,t,e+r,o,a,s)||F(t+n-r,e+r,r,1.5*Math.PI,2*Math.PI,o,a,s)||F(t+n-r,e+i-r,r,0,.5*Math.PI,o,a,s)||F(t+r,e+i-r,r,.5*Math.PI,Math.PI,o,a,s)||F(t+r,e+r,r,Math.PI,1.5*Math.PI,o,a,s)}(s,u,l,c,h,r,t,e)),!f&&i&&(f=E(this,t,e)),f}var p=r/2;return i&&n?Object(a.e)(s-p,u-p,l+p,c+p,t,e):i?Object(a.e)(s,u,l,c,t,e):n?function(t,e,n,i,r,o,s){var u=r/2;return Object(a.e)(t-u,e-u,n,r,o,s)||Object(a.e)(t+n-u,e-u,r,i,o,s)||Object(a.e)(t+u,e+i-u,n,r,o,s)||Object(a.e)(t-u,e+u,r,i,o,s)}(s,u,l,c,r,t,e):void 0},e.prototype.createPath=function(t){var e=this.attr(),n=e.x,i=e.y,r=e.width,o=e.height,a=e.radius;if(t.beginPath(),0===a)t.rect(n,i,r,o);else{var s=Object(U.a)(a),u=s[0],l=s[1],c=s[2],h=s[3];t.moveTo(n+u,i),t.lineTo(n+r-l,i),0!==l&&t.arc(n+r-l,i+l,l,-Math.PI/2,0),t.lineTo(n+r,i+o-c),0!==c&&t.arc(n+r-c,i+o-c,c,0,Math.PI/2),t.lineTo(n+h,i+o),0!==h&&t.arc(n+h,i+o-h,h,Math.PI/2,Math.PI),t.lineTo(n,i+u),0!==u&&t.arc(n+u,i+u,u,Math.PI,1.5*Math.PI),t.closePath()}},e}(c),Q=n(59),K=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,text:null,fontSize:12,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",textAlign:"start",textBaseline:"bottom"})},e.prototype.isOnlyHitBox=function(){return!0},e.prototype.initAttrs=function(t){this._assembleFont(),t.text&&this._setText(t.text)},e.prototype._assembleFont=function(){var t=this.attrs;t.font=Object(Q.assembleFont)(t)},e.prototype._setText=function(t){var e=null;Object(a.k)(t)&&-1!==t.indexOf("\n")&&(e=t.split("\n")),this.set("textArr",e)},e.prototype.onAttrChange=function(e,n,i){t.prototype.onAttrChange.call(this,e,n,i),e.startsWith("font")&&this._assembleFont(),"text"===e&&this._setText(n)},e.prototype._getSpaceingY=function(){var t=this.attrs,e=t.lineHeight,n=1*t.fontSize;return e?e-n:.14*n},e.prototype._drawTextArr=function(t,e,n){var i,r=this.attrs,o=r.textBaseline,s=r.x,u=r.y,l=1*r.fontSize,c=this._getSpaceingY(),h=Object(Q.getTextHeight)(r.text,r.fontSize,r.lineHeight);Object(a.c)(e,(function(e,r){i=u+r*(c+l)-h+l,"middle"===o&&(i+=h-l-(h-l)/2),"top"===o&&(i+=h-l),n?t.fillText(e,s,i):t.strokeText(e,s,i)}))},e.prototype._drawText=function(t,e){var n=this.attr(),i=n.x,r=n.y,o=this.get("textArr");if(o)this._drawTextArr(t,o,e);else{var a=n.text;e?t.fillText(a,i,r):t.strokeText(a,i,r)}},e.prototype.strokeAndFill=function(t){var e=this.attrs,n=e.lineWidth,i=e.opacity,r=e.strokeOpacity,o=e.fillOpacity;this.isStroke()&&n>0&&(Object(a.i)(r)||1===r||(t.globalAlpha=i),this.stroke(t)),this.isFill()&&(Object(a.i)(o)||1===o?this.fill(t):(t.globalAlpha=o,this.fill(t),t.globalAlpha=i)),this.afterDrawPath(t)},e.prototype.fill=function(t){this._drawText(t,!0)},e.prototype.stroke=function(t){this._drawText(t,!1)},e}(c)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Slider=e.HtmlTooltip=e.ContinuousLegend=e.CategoryLegend=e.CircleGrid=e.LineGrid=e.CircleAxis=e.LineAxis=e.Annotation=e.Crosshair=e.Component=e.GroupComponent=e.HtmlComponent=void 0;var i=n(9);Object.defineProperty(e,"Event",{enumerable:!0,get:function(){return i.Event}}),Object.defineProperty(e,"AbstractGroup",{enumerable:!0,get:function(){return i.AbstractGroup}}),Object.defineProperty(e,"AbstractShape",{enumerable:!0,get:function(){return i.AbstractShape}});var r=n(145);Object.defineProperty(e,"registerAdjust",{enumerable:!0,get:function(){return r.registerAdjust}}),Object.defineProperty(e,"getAdjust",{enumerable:!0,get:function(){return r.getAdjust}}),Object.defineProperty(e,"Adjust",{enumerable:!0,get:function(){return r.Adjust}});var o=n(149);Object.defineProperty(e,"getAttribute",{enumerable:!0,get:function(){return o.getAttribute}}),Object.defineProperty(e,"Attribute",{enumerable:!0,get:function(){return o.Attribute}});var a=n(125);Object.defineProperty(e,"Color",{enumerable:!0,get:function(){return a.Color}});var s=n(289);Object.defineProperty(e,"getCoordinate",{enumerable:!0,get:function(){return s.getCoordinate}}),Object.defineProperty(e,"registerCoordinate",{enumerable:!0,get:function(){return s.registerCoordinate}}),Object.defineProperty(e,"Coordinate",{enumerable:!0,get:function(){return s.Coordinate}});var u=n(33);Object.defineProperty(e,"getScale",{enumerable:!0,get:function(){return u.getScale}}),Object.defineProperty(e,"registerScale",{enumerable:!0,get:function(){return u.registerScale}}),Object.defineProperty(e,"Scale",{enumerable:!0,get:function(){return u.Scale}});var l=n(287);Object.defineProperty(e,"Annotation",{enumerable:!0,get:function(){return l.Annotation}}),Object.defineProperty(e,"Component",{enumerable:!0,get:function(){return l.Component}}),Object.defineProperty(e,"Crosshair",{enumerable:!0,get:function(){return l.Crosshair}}),Object.defineProperty(e,"GroupComponent",{enumerable:!0,get:function(){return l.GroupComponent}}),Object.defineProperty(e,"HtmlComponent",{enumerable:!0,get:function(){return l.HtmlComponent}}),Object.defineProperty(e,"Slider",{enumerable:!0,get:function(){return l.Slider}});var c=l.Axis.Line,h=l.Axis.Circle;e.LineAxis=c,e.CircleAxis=h;var f=l.Grid.Line,p=l.Grid.Circle;e.LineGrid=f,e.CircleGrid=p;var d=l.Legend.Category,g=l.Legend.Continuous;e.CategoryLegend=d,e.ContinuousLegend=g;var y=l.Tooltip.Html;e.HtmlTooltip=y},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.uniq=e.omit=e.padEnd=e.isBetween=void 0;var i=n(0);e.isBetween=function(t,e,n){var i=Math.min(e,n),r=Math.max(e,n);return t>=i&&t<=r},e.padEnd=function(t,e,n){if(i.isString(t))return t.padEnd(e,n);if(i.isArray(t)){var r=t.length;if(r=0?e:n<=0?n:0},e.prototype.createAttrOption=function(t,e,n){if(a.isNil(e)||a.isObject(e))a.isObject(e)&&a.isEqual(Object.keys(e),["values"])?a.set(this.attributeOption,t,{fields:e.values}):a.set(this.attributeOption,t,e);else{var i={};a.isNumber(e)?i.values=[e]:i.fields=y.parseFields(e),n&&(a.isFunction(n)?i.callback=n:i.values=n),a.set(this.attributeOption,t,i)}},e.prototype.initAttributes=function(){var t=this,e=this.attributes,n=this.attributeOption,r=this.theme,a=this.shapeType;this.groupScales=[];var s={},u=function(u){if(n.hasOwnProperty(u)){var c=n[u];if(!c)return{value:void 0};var h=i.__assign({},c),f=h.callback,p=h.values,d=h.fields,g=(void 0===d?[]:d).map((function(e){var n=t.scales[e];return n.isCategory&&!s[e]&&l.GROUP_ATTRS.includes(u)&&(t.groupScales.push(n),s[e]=!0),n}));h.scales=g,"position"!==u&&1===g.length&&"identity"===g[0].type?h.values=g[0].values:f||p||("size"===u?h.values=r.sizes:"shape"===u?h.values=r.shapes[a]||[]:"color"===u&&(g.length?h.values=g[0].values.length<=10?r.colors10:r.colors20:h.values=r.colors10));var y=o.getAttribute(u);e[u]=new y(h)}};for(var c in n){var h=u(c);if("object"==typeof h)return h.value}},e.prototype.processData=function(t){this.hasSorted=!1;for(var e=this.getAttribute("position").scales.filter((function(t){return t.isCategory})),n=this.groupData(t),i=[],r=0,o=n.length;ro&&(o=c)}var h=this.scaleDefs,f={};rt.max&&!a.get(h,[i,"max"])&&(f.max=o),t.change(f)},e.prototype.beforeMapping=function(t){var e=t;if(this.sortable&&this.sort(e),this.generatePoints)for(var n=0,i=e.length;n1)for(var f=0;fthis.max?NaN:this.values[i]},e.prototype.getText=function(e){for(var n=[],i=1;i1?t-1:t}},e}(u),h=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|Z|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,f="[^\\s]+",p=/\[([^]*?)\]/gm;function d(t,e){for(var n=[],i=0,r=t.length;i-1?i:null}};function y(t){for(var e=[],n=1;n3?0:(t-t%10!=10?1:0)*t%10]}},_=y({},b),M=function(t){return _=y(_,t)},C=function(t){return t.replace(/[|\\{()[^$+*?.-]/g,"\\$&")},w=function(t,e){for(void 0===e&&(e=2),t=String(t);t.length0?"-":"+")+w(100*Math.floor(Math.abs(e)/60)+Math.abs(e)%60,4)},Z:function(t){var e=t.getTimezoneOffset();return(e>0?"-":"+")+w(Math.floor(Math.abs(e)/60),2)+":"+w(Math.abs(e)%60,2)}},S=function(t){return+t-1},A=[null,"[1-9]\\d?"],P=[null,f],I=["isPm",f,function(t,e){var n=t.toLowerCase();return n===e.amPm[0]?0:n===e.amPm[1]?1:null}],T=["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var e=(t+"").match(/([+-]|\d\d)/gi);if(e){var n=60*+e[1]+parseInt(e[2],10);return"+"===e[0]?n:-n}return 0}],E={D:["day","[1-9]\\d?"],DD:["day","\\d\\d"],Do:["day","[1-9]\\d?"+f,function(t){return parseInt(t,10)}],M:["month","[1-9]\\d?",S],MM:["month","\\d\\d",S],YY:["year","\\d\\d",function(t){var e=+(""+(new Date).getFullYear()).substr(0,2);return+(""+(+t>68?e-1:e)+t)}],h:["hour","[1-9]\\d?",void 0,"isPm"],hh:["hour","\\d\\d",void 0,"isPm"],H:["hour","[1-9]\\d?"],HH:["hour","\\d\\d"],m:["minute","[1-9]\\d?"],mm:["minute","\\d\\d"],s:["second","[1-9]\\d?"],ss:["second","\\d\\d"],YYYY:["year","\\d{4}"],S:["millisecond","\\d",function(t){return 100*+t}],SS:["millisecond","\\d\\d",function(t){return 10*+t}],SSS:["millisecond","\\d{3}"],d:A,dd:A,ddd:P,dddd:P,MMM:["month",f,g("monthNamesShort")],MMMM:["month",f,g("monthNames")],a:I,A:I,ZZ:T,Z:T},j={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",isoDate:"YYYY-MM-DD",isoDateTime:"YYYY-MM-DDTHH:mm:ssZ",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},L=function(t){return y(j,t)},k=function(t,e,n){if(void 0===e&&(e=j.default),void 0===n&&(n={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var i=[];e=(e=j[e]||e).replace(p,(function(t,e){return i.push(e),"@@@"}));var r=y(y({},_),n);return(e=e.replace(h,(function(e){return O[e](t,r)}))).replace(/@@@/g,(function(){return i.shift()}))};function B(t,e,n){if(void 0===n&&(n={}),"string"!=typeof e)throw new Error("Invalid format in fecha parse");if(e=j[e]||e,t.length>1e3)return null;var i={year:(new Date).getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:null,timezoneOffset:null},r=[],o=[],a=e.replace(p,(function(t,e){return o.push(C(e)),"@@@"})),s={},u={};a=C(a).replace(h,(function(t){var e=E[t],n=e[0],i=e[1],o=e[3];if(s[n])throw new Error("Invalid format. "+n+" specified twice in format");return s[n]=!0,o&&(u[o]=!0),r.push(e),"("+i+")"})),Object.keys(u).forEach((function(t){if(!s[t])throw new Error("Invalid format. "+t+" is required in specified format")})),a=a.replace(/@@@/g,(function(){return o.shift()}));var l=t.match(new RegExp(a,"i"));if(!l)return null;for(var c=y(y({},_),n),f=1;f0?new Date(t).getTime():new Date(t.replace(/-/gi,"/")).getTime()),Object(r.isDate)(t)&&(t=t.getTime()),t}var N=36e5,G=24*N,Y=31*G,V=[["HH:mm:ss",1e3],["HH:mm:ss",1e4],["HH:mm:ss",3e4],["HH:mm",6e4],["HH:mm",6e5],["HH:mm",18e5],["HH",N],["HH",6*N],["HH",12*N],["YYYY-MM-DD",G],["YYYY-MM-DD",4*G],["YYYY-WW",7*G],["YYYY-MM",Y],["YYYY-MM",4*Y],["YYYY-MM",6*Y],["YYYY",380*G]];function X(t,e,n){var i,o=(i=function(t){return t[1]},function(t,e,n,o){for(var a=Object(r.isNil)(n)?0:n,s=Object(r.isNil)(o)?t.length:o;a>>1;i(t[u])>e?s=u:a=u+1}return a})(V,(e-t)/n)-1,a=V[o];return o<0?a=V[0]:o>=V.length&&(a=Object(r.last)(V)),a}var z=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="timeCat",e}return Object(l.__extends)(e,t),e.prototype.translate=function(t){t=R(t);var e=this.values.indexOf(t);return-1===e&&(e=Object(r.isNumber)(t)&&t-1){var i=this.values[n],r=this.formatter;return i=r?r(i,e):F(i,this.mask)}return t},e.prototype.initCfg=function(){this.tickMethod="time-cat",this.mask="YYYY-MM-DD",this.tickCount=7},e.prototype.setDomain=function(){var e=this.values;Object(r.each)(e,(function(t,n){e[n]=R(t)})),e.sort((function(t,e){return t-e})),t.prototype.setDomain.call(this)},e}(c),H=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.isContinuous=!0,e}return Object(l.__extends)(e,t),e.prototype.scale=function(t){if(Object(r.isNil)(t))return NaN;var e=this.rangeMin(),n=this.rangeMax();return this.max===this.min?e:e+this.getScalePercent(t)*(n-e)},e.prototype.init=function(){t.prototype.init.call(this);var e=this.ticks,n=Object(r.head)(e),i=Object(r.last)(e);nthis.max&&(this.max=i),Object(r.isNil)(this.minLimit)||(this.min=n),Object(r.isNil)(this.maxLimit)||(this.max=i)},e.prototype.setDomain=function(){var t=Object(r.getRange)(this.values),e=t.min,n=t.max;Object(r.isNil)(this.min)&&(this.min=e),Object(r.isNil)(this.max)&&(this.max=n),this.min>this.max&&(this.min=e,this.max=n)},e.prototype.calculateTicks=function(){var e=this,n=t.prototype.calculateTicks.call(this);return this.nice||(n=Object(r.filter)(n,(function(t){return t>=e.min&&t<=e.max}))),n},e.prototype.getScalePercent=function(t){var e=this.max,n=this.min;return(t-n)/(e-n)},e.prototype.getInvertPercent=function(t){return(t-this.rangeMin())/(this.rangeMax()-this.rangeMin())},e}(u),W=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="linear",e.isLinear=!0,e}return Object(l.__extends)(e,t),e.prototype.invert=function(t){var e=this.getInvertPercent(t);return this.min+e*(this.max-this.min)},e.prototype.initCfg=function(){this.tickMethod="wilkinson-extended",this.nice=!1},e}(H);function q(t,e){var n=Math.E;return e>=0?Math.pow(n,Math.log(e)/t):-1*Math.pow(n,Math.log(-e)/t)}function U(t,e){return 1===t?1:Math.log(e)/Math.log(t)}function Z(t,e,n){Object(r.isNil)(n)&&(n=Math.max.apply(null,t));var i=n;return Object(r.each)(t,(function(t){t>0&&t1&&(i=1),i}var Q=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="log",e}return Object(l.__extends)(e,t),e.prototype.invert=function(t){var e,n=this.base,i=U(n,this.max),r=this.rangeMin(),o=this.rangeMax()-r,a=this.positiveMin;if(a){if(0===t)return 0;var s=1/(i-(e=U(n,a/n)))*o;if(t=0?1:-1;return Math.pow(o,n)*a},e.prototype.initCfg=function(){this.tickMethod="pow",this.exponent=2,this.tickCount=5,this.nice=!0},e.prototype.getScalePercent=function(t){var e=this.max,n=this.min;if(e===n)return 0;var i=this.exponent;return(q(i,t)-q(i,n))/(q(i,e)-q(i,n))},e}(H),$=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="time",e}return Object(l.__extends)(e,t),e.prototype.getText=function(t,e){var n=this.translate(t),i=this.formatter;return i?i(n,e):F(n,this.mask)},e.prototype.scale=function(e){var n=e;return(Object(r.isString)(n)||Object(r.isDate)(n))&&(n=this.translate(n)),t.prototype.scale.call(this,n)},e.prototype.translate=function(t){return R(t)},e.prototype.initCfg=function(){this.tickMethod="time-pretty",this.mask="YYYY-MM-DD",this.tickCount=7,this.nice=!1},e.prototype.setDomain=function(){var t=this.values,e=this.getConfig("min"),n=this.getConfig("max");if(Object(r.isNil)(e)&&Object(r.isNumber)(e)||(this.min=this.translate(this.min)),Object(r.isNil)(n)&&Object(r.isNumber)(n)||(this.max=this.translate(this.max)),t&&t.length){var i=[],o=1/0,a=o,s=0;Object(r.each)(t,(function(t){var e=R(t);if(isNaN(e))throw new TypeError("Invalid Time: "+t+" in time scale!");o>e?(a=o,o=e):a>e&&(a=e),s1&&(this.minTickInterval=a-o),Object(r.isNil)(e)&&(this.min=o),Object(r.isNil)(n)&&(this.max=s)}},e}(W),J=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="quantize",e}return Object(l.__extends)(e,t),e.prototype.invert=function(t){var e=this.ticks,n=e.length,i=this.getInvertPercent(t),o=Math.floor(i*(n-1));if(o>=n-1)return Object(r.last)(e);if(o<0)return Object(r.head)(e);var a=e[o],s=o/(n-1);return a+(i-s)/((o+1)/(n-1)-s)*(e[o+1]-a)},e.prototype.initCfg=function(){this.tickMethod="r-pretty",this.tickCount=5,this.nice=!0},e.prototype.calculateTicks=function(){var e=t.prototype.calculateTicks.call(this);return this.nice||(Object(r.last)(e)!==this.max&&e.push(this.max),Object(r.head)(e)!==this.min&&e.unshift(this.min)),e},e.prototype.getScalePercent=function(t){var e=this.ticks;if(tObject(r.last)(e))return 1;var n=0;return Object(r.each)(e,(function(e,i){if(!(t>=e))return!1;n=i})),n/(e.length-1)},e}(H),tt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="quantile",e}return Object(l.__extends)(e,t),e.prototype.initCfg=function(){this.tickMethod="quantile",this.tickCount=5,this.nice=!0},e}(J),et={};function nt(t){return et[t]}function it(t,e){if(nt(t))throw new Error("type '"+t+"' existed.");et[t]=e}var rt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="identity",e.isIdentity=!0,e}return Object(l.__extends)(e,t),e.prototype.calculateTicks=function(){return this.values},e.prototype.scale=function(t){return this.values[0]!==t&&Object(r.isNumber)(t)?t:this.range[0]},e.prototype.invert=function(t){var e=this.range;return te[1]?NaN:this.values[0]},e}(u),ot=[1,5,2,2.5,4,3],at=100*Number.EPSILON;function st(t,e,n,i,o,a){var s=Object(r.size)(e),u=Object(r.indexOf)(e,t),l=0,c=function(t,e){return(t%e+e)%e}(i,a);return(c=0&&(l=1),1-u/(s-1)-n+l}function ut(t,e,n){var i=Object(r.size)(e);return 1-Object(r.indexOf)(e,t)/(i-1)-n+1}function lt(t,e,n,i,r,o){var a=(t-1)/(o-r),s=(e-1)/(Math.max(o,i)-Math.min(n,r));return 2-Math.max(a/s,s/a)}function ct(t,e){return t>=e?2-(t-1)/(e-1):1}function ht(t,e,n,i){var r=e-t;return 1-.5*(Math.pow(e-i,2)+Math.pow(t-n,2))/Math.pow(.1*r,2)}function ft(t,e,n){var i=e-t;if(n>i){var r=(n-i)/2;return 1-Math.pow(r,2)/Math.pow(.1*i,2)}return 1}function pt(t,e,n,i,o,a){if(void 0===n&&(n=5),void 0===i&&(i=!0),void 0===o&&(o=ot),void 0===a&&(a=[.25,.2,.5,.05]),"number"!=typeof t||"number"!=typeof e)return{min:0,max:0,ticks:[]};if(t===e||1===n)return{min:t,max:e,ticks:[t]};for(var s={score:-2,lmin:0,lmax:0,lstep:0},u=1;u<1/0;){for(var l=0,c=o;lb)y+=1;else{for(var _=x;_<=b;_+=1){var M=_*(v/u),C=M+v*(p-1),w=v,O=st(h,o,u,M,C,w),S=ht(t,e,M,C),A=lt(p,n,t,e,M,C),P=a[0]*O+a[1]*S+a[2]*A+1*a[3];P>s.score&&(!i||M<=t&&C>=e)&&(s.lmin=M,s.lmax=C,s.lstep=w,s.score=P)}y+=1}}p+=1}}u+=1}for(var I=Number.isInteger(s.lstep)?0:Math.ceil(Math.abs(Math.log10(s.lstep))),T=[],E=s.lmin;E<=s.lmax;E+=s.lstep)T.push(E);var j=I?Object(r.map)(T,(function(t){return Number.parseFloat(t.toFixed(I))})):T;return{min:Math.min(t,Object(r.head)(j)),max:Math.max(e,Object(r.last)(j)),ticks:j}}function dt(t){var e=t.values,n=t.tickInterval,i=t.tickCount,o=e;if(Object(r.isNumber)(n))return Object(r.filter)(o,(function(t,e){return e%n==0}));var a=t.min,s=t.max;if(Object(r.isNil)(a)&&(a=0),Object(r.isNil)(s)&&(s=e.length-1),Object(r.isNumber)(i)&&i=a&&t<=s})).map((function(t){return e[t]}))}return e.slice(a,s+1)}var gt=Math.sqrt(50),yt=Math.sqrt(10),vt=Math.sqrt(2),mt=function(){function t(){this._domain=[0,1]}return t.prototype.domain=function(t){return t?(this._domain=Array.from(t,Number),this):this._domain.slice()},t.prototype.nice=function(t){var e,n;void 0===t&&(t=5);var i,r=this._domain.slice(),o=0,a=this._domain.length-1,s=this._domain[o],u=this._domain[a];return u0?i=xt(s=Math.floor(s/i)*i,u=Math.ceil(u/i)*i,t):i<0&&(i=xt(s=Math.ceil(s*i)/i,u=Math.floor(u*i)/i,t)),i>0?(r[o]=Math.floor(s/i)*i,r[a]=Math.ceil(u/i)*i,this.domain(r)):i<0&&(r[o]=Math.ceil(s*i)/i,r[a]=Math.floor(u*i)/i,this.domain(r)),this},t.prototype.ticks=function(t){return void 0===t&&(t=5),function(t,e,n){var i,r,o,a,s=-1;if(n=+n,(t=+t)===(e=+e)&&n>0)return[t];(i=e0)for(t=Math.ceil(t/a),e=Math.floor(e/a),o=new Array(r=Math.ceil(e-t+1));++s=0?(o>=gt?10:o>=yt?5:o>=vt?2:1)*Math.pow(10,r):-Math.pow(10,-r)/(o>=gt?10:o>=yt?5:o>=vt?2:1)}function bt(t,e,n){return("ceil"===n?Math.ceil(t/e):"floor"===n?Math.floor(t/e):Math.round(t/e))*e}function _t(t,e,n){var i=bt(t,n,"floor"),o=bt(e,n,"ceil");i=Object(r.fixedBase)(i,n),o=Object(r.fixedBase)(o,n);for(var a=[],s=i;s<=o;s+=n){var u=Object(r.fixedBase)(s,n);a.push(u)}return{min:i,max:o,ticks:a}}function Mt(t,e,n){var i,o=t.minLimit,a=t.maxLimit,s=t.min,u=t.max,l=t.tickCount,c=void 0===l?5:l,h=Object(r.isNil)(o)?Object(r.isNil)(e)?s:e:o,f=Object(r.isNil)(a)?Object(r.isNil)(n)?u:n:a;if(h>f&&(f=(i=[h,f])[0],h=i[1]),c<=2)return[h,f];for(var p=(f-h)/(c-1),d=[],g=0;g1&&(r*=Math.ceil(a)),i&&r31536e6)for(var u=Ot(n),l=Math.ceil(o/31536e6),c=s;c<=u+l;c+=l)a.push(St(c));else if(o>Y){var h=Math.ceil(o/Y),f=At(e),p=function(t,e){var n=Ot(t),i=Ot(e),r=At(t);return 12*(i-n)+(At(e)-r)%12}(e,n);for(c=0;c<=p+h;c+=h)a.push(Pt(s,c+f))}else if(o>G){var d=(x=new Date(e)).getFullYear(),g=x.getMonth(),y=x.getDate(),v=Math.ceil(o/G),m=function(t,e){return Math.ceil((e-t)/G)}(e,n);for(c=0;cN){d=(x=new Date(e)).getFullYear(),g=x.getMonth(),v=x.getDate();var x,b=x.getHours(),_=Math.ceil(o/N),M=function(t,e){return Math.ceil((e-t)/N)}(e,n);for(c=0;c<=M+_;c+=_)a.push(new Date(d,g,v,b+c).getTime())}else if(o>6e4){var C=function(t,e){return Math.ceil((e-t)/6e4)}(e,n),w=Math.ceil(o/6e4);for(c=0;c<=C+w;c+=w)a.push(e+6e4*c)}else{var O=o;O<1e3&&(O=1e3);var S=1e3*Math.floor(e/1e3),A=Math.ceil((n-e)/1e3),P=Math.ceil(O/1e3);for(c=0;c=512&&console.warn("Notice: current ticks length("+a.length+') >= 512, may cause performance issues, even out of memory. Because of the configure "tickInterval"(in milliseconds, current is '+o+") is too small, increase the value to solve the problem!"),a})),s("log",(function(t){var e,n=t.base,i=t.tickCount,r=t.min,o=t.max,a=t.values,s=U(n,o);if(r>0)e=Math.floor(U(n,r));else{var u=Z(a,n,o);e=Math.floor(U(n,u))}for(var l=s-e,c=Math.ceil(l/i),h=[],f=e;f=0?1:-1;return Math.pow(t,e)*n}))})),s("quantile",(function(t){var e=t.tickCount,n=t.values;if(!n||!n.length)return[];for(var i=n.slice().sort((function(t,e){return t-e})),r=[],o=0;o=0&&o<=1&&h.push(o);else{var f=l*l-4*u*c;i.isNumberEqual(f,0)?h.push(-l/(2*u)):f>0&&(a=(-l-(s=Math.sqrt(f)))/(2*u),(o=(-l+s)/(2*u))>=0&&o<=1&&h.push(o),a>=0&&a<=1&&h.push(a))}return h}function l(t,e,n,i,o,s,u,l,c){var h=a(t,n,o,u,c),f=a(e,i,s,l,c),p=r.default.pointAt(t,e,n,i,c),d=r.default.pointAt(n,i,o,s,c),g=r.default.pointAt(o,s,u,l,c),y=r.default.pointAt(p.x,p.y,d.x,d.y,c),v=r.default.pointAt(d.x,d.y,g.x,g.y,c);return[[t,e,p.x,p.y,y.x,y.y,h,f],[h,f,v.x,v.y,g.x,g.y,u,l]]}e.default={extrema:u,box:function(t,e,n,r,o,s,l,c){for(var h=[t,l],f=[e,c],p=u(t,n,o,l),d=u(e,r,s,c),g=0;g=s[c]?1:0,p=h>Math.PI?1:0,d=n.convert(u),g=o.getDistanceToCenter(n,d);if(g>=.5)if(h===2*Math.PI){var y={x:(u.x+s.x)/2,y:(u.y+s.y)/2},v=n.convert(y);l.push(["A",g,g,0,p,f,v.x,v.y]),l.push(["A",g,g,0,p,f,d.x,d.y])}else l.push(["A",g,g,0,p,f,d.x,d.y]);return l}(n,i,t)):u.push(a(r,t));break;case"z":default:u.push(r)}})),function(t){r.each(t,(function(e,n){if("a"===e[0].toLowerCase()){var i=t[n-1],r=t[n+1];r&&"a"===r[0].toLowerCase()?i&&"l"===i[0].toLowerCase()&&(i[0]="M"):i&&"a"===i[0].toLowerCase()&&r&&"l"===r[0].toLowerCase()&&(r[0]="M")}}))}(u),u}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.toPoints=e.getRegionBBox=e.BBox=void 0;var i=n(0),r=n(6),o=function(){function t(t,e,n,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),this.x=t,this.y=e,this.height=i,this.width=n}return t.fromRange=function(e,n,i,r){return new t(e,n,i-e,r-n)},Object.defineProperty(t.prototype,"minX",{get:function(){return this.x},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxX",{get:function(){return this.x+this.width},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"minY",{get:function(){return this.y},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxY",{get:function(){return this.y+this.height},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tl",{get:function(){return{x:this.x,y:this.y}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tr",{get:function(){return{x:this.maxX,y:this.y}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bl",{get:function(){return{x:this.x,y:this.maxY}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"br",{get:function(){return{x:this.maxX,y:this.maxY}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"top",{get:function(){return{x:this.x+this.width/2,y:this.minY}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return{x:this.maxX,y:this.y+this.height/2}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bottom",{get:function(){return{x:this.x+this.width/2,y:this.maxY}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"left",{get:function(){return{x:this.minX,y:this.y+this.height/2}},enumerable:!1,configurable:!0}),t.prototype.isEqual=function(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},t.prototype.clone=function(){return new t(this.x,this.y,this.width,this.height)},t.prototype.add=function(){for(var t=[],e=0;e1?1:Number(e),i=t.length-1,r=Math.floor(i*n),o=i*n-r,a=t[r],s=r===i?a:t[r+1];return l([u(a,s,o,0),u(a,s,o,1),u(a,s,o,2)])}(n,t)}},toRGB:Object(i.memoize)(p),toCSSGradient:function(t){if(/^[r,R,L,l]{1}[\s]*\(/.test(t)){var e,n=void 0;if("l"===t[0]){var r=+(u=o.exec(t))[1]+90;n=u[2],e="linear-gradient("+r+"deg, "}else if("r"===t[0]){var u;e="radial-gradient(",n=(u=a.exec(t))[4]}var l=n.match(s);return Object(i.each)(l,(function(t,n){var i=t.split(":");e+=i[1]+" "+100*i[0]+"%",n!==l.length-1&&(e+=", ")})),e+=")"}return t}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getName=e.syncScale=e.createScaleByField=void 0;var i=n(1),r=n(0),o=n(26),a=/^(?:(?!0000)[0-9]{4}([-/.]+)(?:(?:0?[1-9]|1[0-2])\1(?:0?[1-9]|1[0-9]|2[0-8])|(?:0?[13-9]|1[0-2])\1(?:29|30)|(?:0?[13578]|1[02])\1(?:31))|(?:[0-9]{2}(?:0[48]|[2468][048]|[13579][26])|(?:0[48]|[2468][048]|[13579][26])00)([-/.]+)0?2\2(?:29))(\s+([01]|([01][0-9]|2[0-3])):([0-9]|[0-5][0-9]):([0-9]|[0-5][0-9]))?$/;e.createScaleByField=function(t,e,n){var s=e||[];if(r.isNumber(t)||r.isNil(r.firstValue(s,t))&&r.isEmpty(n))return new(o.getScale("identity"))({field:t.toString(),values:[t]});var u=r.valuesOfKey(s,t),l=r.get(n,"type",function(t){var e="linear";return a.test(t)?e="time":r.isString(t)&&(e="cat"),e}(u[0]));return new(o.getScale(l))(i.__assign({field:t,values:u},n))},e.syncScale=function(t,e){if("identity"!==t.type&&"identity"!==e.type){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=e[i]);t.change(n)}},e.getName=function(t){return t.alias||t.field}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parsePadding=e.isAutoPadding=void 0;var i=n(1),r=n(0);e.isAutoPadding=function(t){return!r.isNumber(t)&&!r.isArray(t)},e.parsePadding=function(t){void 0===t&&(t=0);var e=r.isArray(t)?t:[t];switch(e.length){case 0:e=[0,0,0,0];break;case 1:e=new Array(4).fill(e[0]);break;case 2:e=i.__spreadArrays(e,e);break;case 3:e=i.__spreadArrays(e,[e[1]]);break;default:e=e.slice(0,4)}return e}},function(t,e){},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(6),a=n(32),s=n(16),u=i.__importDefault(n(171));var l=function(){function t(t){this.geometry=t}return t.prototype.getLabelItems=function(t){var e=this,n=[],o=this.getLabelCfgs(t);return r.each(t,(function(t,a){var s=o[a];if(!s||r.isNil(t.x)||r.isNil(t.y))n.push(null);else{var u=r.isArray(s.content)?s.content:[s.content];s.content=u;var l=u.length;r.each(u,(function(o,a){if(r.isNil(o)||""===o)n.push(null);else{var u=i.__assign(i.__assign({},s),e.getLabelPoint(s,t,a));u.textAlign||(u.textAlign=e.getLabelAlign(u,a,l)),u.offset<=0&&(u.labelLine=null),n.push(u)}}))}})),n},t.prototype.render=function(t,e){void 0===e&&(e=!1);var n=this.getLabelItems(t),i=this.getLabelsRenderer(),r=this.getGeometryShapes();i.render(n,r,e)},t.prototype.clear=function(){var t=this.labelsRenderer;t&&t.clear()},t.prototype.destroy=function(){var t=this.labelsRenderer;t&&t.destroy(),this.labelsRenderer=null},t.prototype.getCoordinate=function(){return this.geometry.coordinate},t.prototype.getDefaultLabelCfg=function(){return r.get(this.geometry.theme,"labels",{})},t.prototype.setLabelPosition=function(t,e,n,i){},t.prototype.getDefaultOffset=function(t){var e=this.getCoordinate(),n=this.getOffsetVector(t);return e.isTransposed?n[0]:n[1]},t.prototype.getLabelOffset=function(t,e,n){var i=this.getDefaultOffset(t.offset),r=this.getCoordinate().isTransposed,o=r?"x":"y",a=r?1:-1,s={x:0,y:0};return s[o]=e>0||1===n?i*a:i*a*-1,s},t.prototype.getLabelPoint=function(t,e,n){var i=this.getCoordinate(),o=t.content.length;function a(e,n){var i,o,a=e;return r.isArray(a)&&(1===t.content.length?a.length<=2?a=a[e.length-1]:(i=a,o=0,r.each(i,(function(t){o+=t})),a=o/i.length):a=a[n]),a}var u={content:t.content[n],x:0,y:0,start:{x:0,y:0},color:"#fff"};if(e&&"polygon"===this.geometry.type){var l=s.getPolygonCentroid(e.x,e.y);u.x=l[0],u.y=l[1]}else u.x=a(e.x,n),u.y=a(e.y,n);var c=r.isArray(e.shape)?e.shape[0]:e.shape;if("funnel"===c||"pyramid"===c){var h=r.get(e,"nextPoints"),f=r.get(e,"points");if(h){var p=i.convert(f[1]),d=i.convert(h[1]);u.x=(p.x+d.x)/2,u.y=(p.y+d.y)/2}else if("pyramid"===c){p=i.convert(f[1]),d=i.convert(f[2]);u.x=(p.x+d.x)/2,u.y=(p.y+d.y)/2}}t.position&&this.setLabelPosition(u,e,n,t.position);var g=this.getLabelOffset(t,n,o);return u.start={x:u.x,y:u.y},u.x+=g.x,u.y+=g.y,u.color=e.color,u},t.prototype.getLabelAlign=function(t,e,n){var i="center";if(this.getCoordinate().isTransposed){var r=this.getDefaultOffset(t.offset);i=r<0?"right":0===r?"center":"left",n>1&&0===e&&("right"===i?i="left":"left"===i&&(i="right"))}return i},t.prototype.getLabelId=function(t){var e=this.geometry,n=e.type,i=e.getXScale(),r=e.getYScale(),a=t[o.FIELD_ORIGIN],s=e.getElementId(t);return"line"===n||"area"===n?s+=" "+a[i.field]:"path"===n&&(s+=" "+a[i.field]+"-"+a[r.field]),s},t.prototype.getLabelsRenderer=function(){var t=this.geometry,e=t.labelsContainer,n=t.labelOption,i=t.canvasRegion,o=t.animateOption,s=this.geometry.coordinate,l=this.labelsRenderer;return l||(l=new u.default({container:e,layout:r.get(n,["cfg","layout"],{type:this.defaultLayout})}),this.labelsRenderer=l),l.region=i,l.animate=!!o&&a.getDefaultAnimateCfg("label",s),l},t.prototype.getLabelCfgs=function(t){var e=this,n=this.geometry,a=this.getDefaultLabelCfg(),s=n.type,u=n.theme,l=n.labelOption,c=n.scales,h=n.coordinate,f=l,p=f.fields,d=f.callback,g=f.cfg,y=p.map((function(t){return c[t]})),v=[];return r.each(t,(function(t,n){var l,c=t[o.FIELD_ORIGIN],f=e.getLabelText(c,y);if(d){var m=p.map((function(t){return c[t]}));if(l=d.apply(void 0,m),r.isNil(l))return void v.push(null)}var x=i.__assign(i.__assign({id:e.getLabelId(t),data:c,mappingData:t,coordinate:h},g),l),b=x.content;r.isFunction(b)?x.content=b(c,t,n):r.isUndefined(b)&&(x.content=f[0]),r.isFunction(x.position)&&(x.position=x.position(c,t,n)),x="polygon"===s||x.offset<0&&!["line","point","path"].includes(s)?r.deepMix({},a,u.innerLabels,x):r.deepMix({},a,u.labels,x),v.push(x)})),v},t.prototype.getLabelText=function(t,e){var n=[];return r.each(e,(function(e){var i=t[e.field];i=r.isArray(i)?i.map((function(t){return e.getText(t)})):e.getText(i),r.isNil(i)||""===i?n.push(null):n.push(i)})),n},t.prototype.getOffsetVector=function(t){void 0===t&&(t=0);var e=this.getCoordinate();return e.isTransposed?e.applyMatrix(t,0):e.applyMatrix(0,t)},t.prototype.getGeometryShapes=function(){var t=this.geometry,e={};return r.each(t.elementsMap,(function(t,n){e[n]=t.shape})),r.each(t.getOffscreenGroup().getChildren(),(function(n){var i=t.getElementId(n.get("origin").mappingData);e[i]=n})),e},t}();e.default=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.default=function(t,e,n){return void 0===n&&(n=1e-5),Math.abs(t-e)0&&(c[0][0]="L")),s=s.concat(c)})),s.push(["Z"])}return s}e.getShapeAttrs=function(t,e,n,i,a){for(var u=o.getStyle(t,e,!e,"lineWidth"),l=t.connectNulls,c=t.isInCircle,h=t.points,f=t.showSinglePoint,p=r.getPathPoints(h,l,f),d=[],g=0,y=p.length;g0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function A(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function P(t,e,n){var i=e[0],r=e[1],o=e[2],a=n[0],s=n[1],u=n[2];return t[0]=r*u-o*s,t[1]=o*a-i*u,t[2]=i*s-r*a,t}function I(t,e,n,i){var r=e[0],o=e[1],a=e[2];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t[2]=a+i*(n[2]-a),t}function T(t,e,n,i,r,o){var a=o*o,s=a*(2*o-3)+1,u=a*(o-2)+o,l=a*(o-1),c=a*(3-2*o);return t[0]=e[0]*s+n[0]*u+i[0]*l+r[0]*c,t[1]=e[1]*s+n[1]*u+i[1]*l+r[1]*c,t[2]=e[2]*s+n[2]*u+i[2]*l+r[2]*c,t}function E(t,e,n,i,r,o){var a=1-o,s=a*a,u=o*o,l=s*a,c=3*o*s,h=3*u*a,f=u*o;return t[0]=e[0]*l+n[0]*c+i[0]*h+r[0]*f,t[1]=e[1]*l+n[1]*c+i[1]*h+r[1]*f,t[2]=e[2]*l+n[2]*c+i[2]*h+r[2]*f,t}function j(t,e){e=e||1;var n=2*i.c()*Math.PI,r=2*i.c()-1,o=Math.sqrt(1-r*r)*e;return t[0]=Math.cos(n)*o,t[1]=Math.sin(n)*o,t[2]=r*e,t}function L(t,e,n){var i=e[0],r=e[1],o=e[2],a=n[3]*i+n[7]*r+n[11]*o+n[15];return a=a||1,t[0]=(n[0]*i+n[4]*r+n[8]*o+n[12])/a,t[1]=(n[1]*i+n[5]*r+n[9]*o+n[13])/a,t[2]=(n[2]*i+n[6]*r+n[10]*o+n[14])/a,t}function k(t,e,n){var i=e[0],r=e[1],o=e[2];return t[0]=i*n[0]+r*n[3]+o*n[6],t[1]=i*n[1]+r*n[4]+o*n[7],t[2]=i*n[2]+r*n[5]+o*n[8],t}function B(t,e,n){var i=n[0],r=n[1],o=n[2],a=n[3],s=e[0],u=e[1],l=e[2],c=r*l-o*u,h=o*s-i*l,f=i*u-r*s,p=r*f-o*h,d=o*c-i*f,g=i*h-r*c,y=2*a;return c*=y,h*=y,f*=y,p*=2,d*=2,g*=2,t[0]=s+c+p,t[1]=u+h+d,t[2]=l+f+g,t}function D(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0],o[1]=r[1]*Math.cos(i)-r[2]*Math.sin(i),o[2]=r[1]*Math.sin(i)+r[2]*Math.cos(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function F(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[2]*Math.sin(i)+r[0]*Math.cos(i),o[1]=r[1],o[2]=r[2]*Math.cos(i)-r[0]*Math.sin(i),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function R(t,e,n,i){var r=[],o=[];return r[0]=e[0]-n[0],r[1]=e[1]-n[1],r[2]=e[2]-n[2],o[0]=r[0]*Math.cos(i)-r[1]*Math.sin(i),o[1]=r[0]*Math.sin(i)+r[1]*Math.cos(i),o[2]=r[2],t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t}function N(t,e){var n=t[0],i=t[1],r=t[2],o=e[0],a=e[1],s=e[2],u=Math.sqrt(n*n+i*i+r*r)*Math.sqrt(o*o+a*a+s*s),l=u&&A(t,e)/u;return Math.acos(Math.min(Math.max(l,-1),1))}function G(t){return t[0]=0,t[1]=0,t[2]=0,t}function Y(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"}function V(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]}function X(t,e){var n=t[0],r=t[1],o=t[2],a=e[0],s=e[1],u=e[2];return Math.abs(n-a)<=i.b*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-s)<=i.b*Math.max(1,Math.abs(r),Math.abs(s))&&Math.abs(o-u)<=i.b*Math.max(1,Math.abs(o),Math.abs(u))}var z,H=h,W=f,q=p,U=_,Z=M,Q=a,K=C,$=(z=r(),function(t,e,n,i,r,o){var a,s;for(e||(e=3),n||(n=0),s=i?Math.min(i*e+n,t.length):t.length,a=n;a=0&&s<.5*Math.PI?(i={x:c.minX,y:c.minY},o={x:c.maxX,y:c.maxY}):.5*Math.PI<=s&&s1?e*r+o(e,n)*(r-1):e},e.getLineSpaceing=o,e.getTextWidth=function(t,e){var n=r.getOffScreenContext(),o=0;if(i.isNil(t)||""===t)return o;if(n.save(),n.font=e,i.isString(t)&&t.includes("\n")){var a=t.split("\n");i.each(a,(function(t){var e=n.measureText(t).width;o=0){n=!0;break}}if(!n)return e;var u=[],l=0,c=0,h=0,f=0,p=0,d=e[0];"M"!==d[0]&&"m"!==d[0]||(h=l=+d[1],f=c=+d[2],p++,u[0]=["M",l,c]),a=p;for(var g=e.length;a0?1:-1:(i.x-n.x)*(n.y-e.y)>0?-1:1},e.getAxisThemeCfg=function(t,e){return i.get(t,["components","axis",e],{})},e.getCircleAxisCenterRadius=function(t){var e=t.x,n=t.y,i=t.circleCenter,r=n.start>n.end,o=t.isTransposed?t.convert({x:r?0:1,y:0}):t.convert({x:0,y:r?0:1}),s=[o.x-i.x,o.y-i.y],u=[1,0],l=o.y>i.y?a.vec2.angle(s,u):-1*a.vec2.angle(s,u),c=l+(e.end-e.start);return{center:i,radius:Math.sqrt(Math.pow(o.x-i.x,2)+Math.pow(o.y-i.y,2)),startAngle:l,endAngle:c}},e.getAxisOption=function(t,e){return i.isBoolean(t)?!1!==t&&{}:i.get(t,[e])},e.getAxisDirection=function(t,e){return i.get(t,"position",e)},e.getAxisTitleText=function(t,e){return i.get(e,["title","text"],o.getName(t))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i={}.toString;e.default=function(t,e){return i.call(t)==="[object "+e+"]"}},function(t,e,n){"use strict";function i(t,e){for(var n in e)e.hasOwnProperty(n)&&"constructor"!==n&&void 0!==e[n]&&(t[n]=e[n])}Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t,e,n,r){return e&&i(t,e),n&&i(t,n),r&&i(t,r),t}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(144);e.default=function(t){var e=i.default(t);return e.charAt(0).toUpperCase()+e.substring(1)}},function(t,e,n){"use strict";n.r(e),n.d(e,"create",(function(){return r})),n.d(e,"clone",(function(){return o})),n.d(e,"fromValues",(function(){return a})),n.d(e,"copy",(function(){return s})),n.d(e,"set",(function(){return u})),n.d(e,"add",(function(){return l})),n.d(e,"subtract",(function(){return c})),n.d(e,"multiply",(function(){return h})),n.d(e,"divide",(function(){return f})),n.d(e,"ceil",(function(){return p})),n.d(e,"floor",(function(){return d})),n.d(e,"min",(function(){return g})),n.d(e,"max",(function(){return y})),n.d(e,"round",(function(){return v})),n.d(e,"scale",(function(){return m})),n.d(e,"scaleAndAdd",(function(){return x})),n.d(e,"distance",(function(){return b})),n.d(e,"squaredDistance",(function(){return _})),n.d(e,"length",(function(){return M})),n.d(e,"squaredLength",(function(){return C})),n.d(e,"negate",(function(){return w})),n.d(e,"inverse",(function(){return O})),n.d(e,"normalize",(function(){return S})),n.d(e,"dot",(function(){return A})),n.d(e,"cross",(function(){return P})),n.d(e,"lerp",(function(){return I})),n.d(e,"random",(function(){return T})),n.d(e,"transformMat2",(function(){return E})),n.d(e,"transformMat2d",(function(){return j})),n.d(e,"transformMat3",(function(){return L})),n.d(e,"transformMat4",(function(){return k})),n.d(e,"rotate",(function(){return B})),n.d(e,"angle",(function(){return D})),n.d(e,"zero",(function(){return F})),n.d(e,"str",(function(){return R})),n.d(e,"exactEquals",(function(){return N})),n.d(e,"equals",(function(){return G})),n.d(e,"len",(function(){return V})),n.d(e,"sub",(function(){return X})),n.d(e,"mul",(function(){return z})),n.d(e,"div",(function(){return H})),n.d(e,"dist",(function(){return W})),n.d(e,"sqrDist",(function(){return q})),n.d(e,"sqrLen",(function(){return U})),n.d(e,"forEach",(function(){return Z}));var i=n(4);function r(){var t=new i.a(2);return i.a!=Float32Array&&(t[0]=0,t[1]=0),t}function o(t){var e=new i.a(2);return e[0]=t[0],e[1]=t[1],e}function a(t,e){var n=new i.a(2);return n[0]=t,n[1]=e,n}function s(t,e){return t[0]=e[0],t[1]=e[1],t}function u(t,e,n){return t[0]=e,t[1]=n,t}function l(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function c(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t}function h(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t}function f(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t}function p(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t}function d(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t}function g(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t}function y(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t}function v(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t}function m(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t}function x(t,e,n,i){return t[0]=e[0]+n[0]*i,t[1]=e[1]+n[1]*i,t}function b(t,e){var n=e[0]-t[0],i=e[1]-t[1];return Math.hypot(n,i)}function _(t,e){var n=e[0]-t[0],i=e[1]-t[1];return n*n+i*i}function M(t){var e=t[0],n=t[1];return Math.hypot(e,n)}function C(t){var e=t[0],n=t[1];return e*e+n*n}function w(t,e){return t[0]=-e[0],t[1]=-e[1],t}function O(t,e){return t[0]=1/e[0],t[1]=1/e[1],t}function S(t,e){var n=e[0],i=e[1],r=n*n+i*i;return r>0&&(r=1/Math.sqrt(r)),t[0]=e[0]*r,t[1]=e[1]*r,t}function A(t,e){return t[0]*e[0]+t[1]*e[1]}function P(t,e,n){var i=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=i,t}function I(t,e,n,i){var r=e[0],o=e[1];return t[0]=r+i*(n[0]-r),t[1]=o+i*(n[1]-o),t}function T(t,e){e=e||1;var n=2*i.c()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t}function E(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r,t[1]=n[1]*i+n[3]*r,t}function j(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[2]*r+n[4],t[1]=n[1]*i+n[3]*r+n[5],t}function L(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[3]*r+n[6],t[1]=n[1]*i+n[4]*r+n[7],t}function k(t,e,n){var i=e[0],r=e[1];return t[0]=n[0]*i+n[4]*r+n[12],t[1]=n[1]*i+n[5]*r+n[13],t}function B(t,e,n,i){var r=e[0]-n[0],o=e[1]-n[1],a=Math.sin(i),s=Math.cos(i);return t[0]=r*s-o*a+n[0],t[1]=r*a+o*s+n[1],t}function D(t,e){var n=t[0],i=t[1],r=e[0],o=e[1],a=Math.sqrt(n*n+i*i)*Math.sqrt(r*r+o*o),s=a&&(n*r+i*o)/a;return Math.acos(Math.min(Math.max(s,-1),1))}function F(t){return t[0]=0,t[1]=0,t}function R(t){return"vec2("+t[0]+", "+t[1]+")"}function N(t,e){return t[0]===e[0]&&t[1]===e[1]}function G(t,e){var n=t[0],r=t[1],o=e[0],a=e[1];return Math.abs(n-o)<=i.b*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=i.b*Math.max(1,Math.abs(r),Math.abs(a))}var Y,V=M,X=c,z=h,H=f,W=b,q=_,U=C,Z=(Y=r(),function(t,e,n,i,r,o){var a,s;for(e||(e=2),n||(n=0),s=i?Math.min(i*e+n,t.length):t.length,a=n;a1){for(var h=n.addGroup(),f=0,p=l;f=0?[o]:[]}function u(t,e,n,i){return 2*(1-i)*(e-t)+2*i*(n-e)}function l(t,e,n,r,o,s,u){var l=a(t,n,o,u),c=a(e,r,s,u),h=i.default.pointAt(t,e,n,r,u),f=i.default.pointAt(n,r,o,s,u);return[[t,e,h.x,h.y,l,c],[l,c,f.x,f.y,o,s]]}e.default={box:function(t,e,n,i,o,u){var l=s(t,n,o)[0],c=s(e,i,u)[0],h=[t,o],f=[e,u];return void 0!==l&&h.push(a(t,n,o,l)),void 0!==c&&f.push(a(e,i,u,c)),r.getBBoxByArray(h,f)},length:function(t,e,n,i,o,a){return function t(e,n,i,o,a,s,u){if(0===u)return(r.distance(e,n,i,o)+r.distance(i,o,a,s)+r.distance(e,n,a,s))/2;var c=l(e,n,i,o,a,s,.5),h=c[0],f=c[1];return h.push(u-1),f.push(u-1),t.apply(null,h)+t.apply(null,f)}(t,e,n,i,o,a,3)},nearestPoint:function(t,e,n,i,r,s,u,l){return o.nearestPoint([t,n,r],[e,i,s],u,l,a)},pointDistance:function(t,e,n,i,o,a,s,u){var l=this.nearestPoint(t,e,n,i,o,a,s,u);return r.distance(l.x,l.y,s,u)},interpolationAt:a,pointAt:function(t,e,n,i,r,o,s){return{x:a(t,n,r,s),y:a(e,i,o,s)}},divide:function(t,e,n,i,r,o,a){return l(t,e,n,i,r,o,a)},tangentAngle:function(t,e,n,i,o,a,s){var l=u(t,n,o,s),c=u(e,i,a,s),h=Math.atan2(c,l);return r.piMod(h)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(109),r=n(109),o=n(184);function a(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}e.default=function(t){for(var e=[],n=null,s=null,u=null,l=0,c=(t=o.default(t)).length,h=0;h1){var i=t[0].charAt(0);t.splice(1,0,t[0].substr(1)),t[0]=i}r()(t,(function(e,n){isNaN(e)||(t[n]=+e)})),e[n]=t})),e):void 0};function f(t,e){for(var n=[],i=0,r=t.length;r-2*!e>i;i+=2){var o=[{x:+t[i-2],y:+t[i-1]},{x:+t[i],y:+t[i+1]},{x:+t[i+2],y:+t[i+3]},{x:+t[i+4],y:+t[i+5]}];e?i?r-4===i?o[3]={x:+t[0],y:+t[1]}:r-2===i&&(o[2]={x:+t[0],y:+t[1]},o[3]={x:+t[2],y:+t[3]}):o[0]={x:+t[r-2],y:+t[r-1]}:r-4===i?o[3]=o[2]:i||(o[0]={x:+t[i],y:+t[i+1]}),n.push(["C",(-o[0].x+6*o[1].x+o[2].x)/6,(-o[0].y+6*o[1].y+o[2].y)/6,(o[1].x+6*o[2].x-o[3].x)/6,(o[1].y+6*o[2].y-o[3].y)/6,o[2].x,o[2].y])}return n}function p(t,e){var n=[],i=[];return t.length&&function t(e,r){if(1===e.length)n.push(e[0]),i.push(e[0]);else{for(var o=[],a=0;a=3&&(3===t.length&&e.push("Q"),e=e.concat(t[1])),2===t.length&&e.push("L"),e=e.concat(t[t.length-1])}))}(t,e,n));else{var r=[].concat(t);"M"===r[0]&&(r[0]="L");for(var o=0;o<=n-1;o++)i.push(r)}return i}function g(t,e){if(1===t.length)return t;var n=t.length-1,i=e.length-1,r=n/i,o=[];if(1===t.length&&"M"===t[0][0]){for(var a=0;a=0;u--)a=o[u].index,"add"===o[u].type?t.splice(a,0,[].concat(t[a])):t.splice(a,1)}if((i=t.length)0)){t[i]=e[i];break}n=_(n,t[i-1],1)}t[i]=["Q"].concat(n.reduce((function(t,e){return t.concat(e)}),[]));break;case"T":t[i]=["T"].concat(n[0]);break;case"C":if(n.length<3){if(!(i>0)){t[i]=e[i];break}n=_(n,t[i-1],2)}t[i]=["C"].concat(n.reduce((function(t,e){return t.concat(e)}),[]));break;case"S":if(n.length<2){if(!(i>0)){t[i]=e[i];break}n=_(n,t[i-1],1)}t[i]=["S"].concat(n.reduce((function(t,e){return t.concat(e)}),[]));break;default:t[i]=e[i]}return t}var C=n(0);function w(t,e,n,i,r){return r?[["M",+t+ +r,e],["l",n-2*r,0],["a",r,r,0,0,1,r,r],["l",0,i-2*r],["a",r,r,0,0,1,-r,r],["l",2*r-n,0],["a",r,r,0,0,1,-r,-r],["l",0,2*r-i],["a",r,r,0,0,1,r,-r],["z"]]:[["M",t,e],["l",n,0],["l",0,i],["l",-n,0],["z"]]}var O="\t\n\v\f\r   ᠎              \u2028\u2029",S=new RegExp("([a-z])["+O+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+O+"]*,?["+O+"]*)+)","ig"),A=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+O+"]*,?["+O+"]*","ig");function P(t){if(!t)return null;if(a()(t))return t;var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},n=[];return String(t).replace(S,(function(t,i,r){var o=[],a=i.toLowerCase();if(r.replace(A,(function(t,e){e&&o.push(+e)})),"m"===a&&o.length>2&&(n.push([i].concat(o.splice(0,2))),a="l",i="m"===i?"l":"L"),"o"===a&&1===o.length&&n.push([i,o[0]]),"r"===a)n.push([i].concat(o));else for(;o.length>=e[a]&&(n.push([i].concat(o.splice(0,e[a]))),e[a]););return""})),n}var I=/[a-z]/;function T(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}function E(t){var e=P(t);if(!e||!e.length)return[["M",0,0]];for(var n=!1,i=0;i=0){n=!0;break}}if(!n)return e;var o=[],a=0,s=0,u=0,l=0,c=0,h=e[0];"M"!==h[0]&&"m"!==h[0]||(u=a=+h[1],l=s=+h[2],c++,o[0]=["M",a,s]);i=c;for(var f=e.length;i1&&(n*=_=Math.sqrt(_),i*=_);var M=n*n,C=i*i,w=(o===a?-1:1)*Math.sqrt(Math.abs((M*C-M*b*b-C*x*x)/(M*b*b+C*x*x)));p=w*n*b/i+(t+s)/2,d=w*-i*x/n+(e+u)/2,h=Math.asin(Number(((e-d)/i).toFixed(9))),f=Math.asin(Number(((u-d)/i).toFixed(9))),h=tf&&(h-=2*Math.PI),!a&&f>h&&(f-=2*Math.PI)}var O=f-h;if(Math.abs(O)>g){var S=f,A=s,P=u;f=h+g*(a&&f>h?1:-1),s=p+n*Math.cos(f),u=d+i*Math.sin(f),v=j(s,u,n,i,r,0,a,A,P,[f,S,p,d])}O=f-h;var I=Math.cos(h),T=Math.sin(h),E=Math.cos(f),L=Math.sin(f),k=Math.tan(O/4),B=4/3*n*k,D=4/3*i*k,F=[t,e],R=[t+B*T,e-D*I],N=[s+B*L,u-D*E],G=[s,u];if(R[0]=2*F[0]-R[0],R[1]=2*F[1]-R[1],l)return[R,N,G].concat(v);for(var Y=[],V=0,X=(v=[R,N,G].concat(v).join().split(",")).length;V7){t[e].shift();for(var o=t[e];o.length;)s[e]="A",r&&(u[e]="A"),t.splice(e++,0,["C"].concat(o.splice(0,6)));t.splice(e,1),n=Math.max(i.length,r&&r.length||0)}},p=function(t,e,o,a,s){t&&e&&"M"===t[s][0]&&"M"!==e[s][0]&&(e.splice(s,0,["M",a.x,a.y]),o.bx=0,o.by=0,o.x=t[s][1],o.y=t[s][2],n=Math.max(i.length,r&&r.length||0))};n=Math.max(i.length,r&&r.length||0);for(var d=0;d1?1:u<0?0:u)/2,c=[-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],h=[.2491,.2491,.2335,.2335,.2032,.2032,.1601,.1601,.1069,.1069,.0472,.0472],f=0,p=0;p<12;p++){var d=l*c[p]+l,g=D(d,t,n,r,a),y=D(d,e,i,o,s),v=g*g+y*y;f+=h[p]*Math.sqrt(v)}return l*f},R=function(t,e,n,i,r,o,a,s){for(var u,l,c,h,f=[],p=[[],[]],d=0;d<2;++d)if(0===d?(l=6*t-12*n+6*r,u=-3*t+9*n-9*r+3*a,c=3*n-3*t):(l=6*e-12*i+6*o,u=-3*e+9*i-9*o+3*s,c=3*i-3*e),Math.abs(u)<1e-12){if(Math.abs(l)<1e-12)continue;(h=-c/l)>0&&h<1&&f.push(h)}else{var g=l*l-4*c*u,y=Math.sqrt(g);if(!(g<0)){var v=(-l+y)/(2*u);v>0&&v<1&&f.push(v);var m=(-l-y)/(2*u);m>0&&m<1&&f.push(m)}}for(var x,b=f.length,_=b;b--;)x=1-(h=f[b]),p[0][b]=x*x*x*t+3*x*x*h*n+3*x*h*h*r+h*h*h*a,p[1][b]=x*x*x*e+3*x*x*h*i+3*x*h*h*o+h*h*h*s;return p[0][_]=t,p[1][_]=e,p[0][_+1]=a,p[1][_+1]=s,p[0].length=p[1].length=_+2,{min:{x:Math.min.apply(0,p[0]),y:Math.min.apply(0,p[1])},max:{x:Math.max.apply(0,p[0]),y:Math.max.apply(0,p[1])}}},N=function(t,e,n,i,r,o,a,s){if(!(Math.max(t,n)Math.max(r,a)||Math.max(e,i)Math.max(o,s))){var u=(t-n)*(o-s)-(e-i)*(r-a);if(u){var l=((t*i-e*n)*(r-a)-(t-n)*(r*s-o*a))/u,c=((t*i-e*n)*(o-s)-(e-i)*(r*s-o*a))/u,h=+l.toFixed(2),f=+c.toFixed(2);if(!(h<+Math.min(t,n).toFixed(2)||h>+Math.max(t,n).toFixed(2)||h<+Math.min(r,a).toFixed(2)||h>+Math.max(r,a).toFixed(2)||f<+Math.min(e,i).toFixed(2)||f>+Math.max(e,i).toFixed(2)||f<+Math.min(o,s).toFixed(2)||f>+Math.max(o,s).toFixed(2)))return{x:l,y:c}}}},G=function(t,e,n){return e>=t.x&&e<=t.x+t.width&&n>=t.y&&n<=t.y+t.height},Y=function(t,e,n,i){return null===t&&(t=e=n=i=0),null===e&&(e=t.y,n=t.width,i=t.height,t=t.x),{x:t,y:e,width:n,w:n,height:i,h:i,x2:t+n,y2:e+i,cx:t+n/2,cy:e+i/2,r1:Math.min(n,i)/2,r2:Math.max(n,i)/2,r0:Math.sqrt(n*n+i*i)/2,path:w(t,e,n,i),vb:[t,e,n,i].join(" ")}},V=function(t,e,n,i,r,o,a,s){Object(C.isArray)(t)||(t=[t,e,n,i,r,o,a,s]);var u=R.apply(null,t);return Y(u.min.x,u.min.y,u.max.x-u.min.x,u.max.y-u.min.y)},X=function(t,e,n,i,r,o,a,s,u){var l=1-u,c=Math.pow(l,3),h=Math.pow(l,2),f=u*u,p=f*u,d=t+2*u*(n-t)+f*(r-2*n+t),g=e+2*u*(i-e)+f*(o-2*i+e),y=n+2*u*(r-n)+f*(a-2*r+n),v=i+2*u*(o-i)+f*(s-2*o+i);return{x:c*t+3*h*u*n+3*l*u*u*r+p*a,y:c*e+3*h*u*i+3*l*u*u*o+p*s,m:{x:d,y:g},n:{x:y,y:v},start:{x:l*t+u*n,y:l*e+u*i},end:{x:l*r+u*a,y:l*o+u*s},alpha:90-180*Math.atan2(d-y,g-v)/Math.PI}},z=function(t,e,n){if(!function(t,e){return t=Y(t),e=Y(e),G(e,t.x,t.y)||G(e,t.x2,t.y)||G(e,t.x,t.y2)||G(e,t.x2,t.y2)||G(t,e.x,e.y)||G(t,e.x2,e.y)||G(t,e.x,e.y2)||G(t,e.x2,e.y2)||(t.xe.x||e.xt.x)&&(t.ye.y||e.yt.y)}(V(t),V(e)))return n?0:[];for(var i=~~(F.apply(0,t)/8),r=~~(F.apply(0,e)/8),o=[],a=[],s={},u=n?0:[],l=0;l=0&&x<=1&&b>=0&&b<=1&&(n?u++:u.push({x:m.x,y:m.y,t1:x,t2:b}))}}return u};function H(t,e){return function(t,e,n){var i,r,o,a,s,u,l,c,h,f;t=B(t),e=B(e);for(var p=n?0:[],d=0,g=t.length;d1&&(n*=Math.sqrt(p),i*=Math.sqrt(p));var d=n*n*(f*f)+i*i*(h*h),g=d?Math.sqrt((n*n*(i*i)-d)/d):1;o===a&&(g*=-1),isNaN(g)&&(g=0);var y=i?g*n*f/i:0,v=n?g*-i*h/n:0,m=(s+l)/2+Math.cos(r)*y-Math.sin(r)*v,x=(u+c)/2+Math.sin(r)*y+Math.cos(r)*v,b=[(h-y)/n,(f-v)/i],_=[(-1*h-y)/n,(-1*f-v)/i],M=tt([1,0],b),C=tt(b,_);return J(b,_)<=-1&&(C=Math.PI),J(b,_)>=1&&(C=0),0===a&&C>0&&(C-=2*Math.PI),1===a&&C<0&&(C+=2*Math.PI),{cx:m,cy:x,rx:et(t,[l,c])?0:n,ry:et(t,[l,c])?0:i,startAngle:M,endAngle:M+C,xRotation:r,arcFlag:o,sweepFlag:a}}function it(t,e){return[e[0]+(e[0]-t[0]),e[1]+(e[1]-t[1])]}function rt(t){for(var e=[],n=null,i=null,r=null,o=0,a=(t=h(t)).length,s=0;s=e&&t<=n};function at(t,e,n,i){var r=n.x-t.x,o=n.y-t.y,a=e.x-t.x,s=e.y-t.y,u=i.x-n.x,l=i.y-n.y,c=a*l-s*u,h=null;if(c*c>.001*(a*a+s*s)*(u*u+l*l)){var f=(r*l-o*u)/c,p=(r*s-o*a)/c;ot(f,0,1)&&ot(p,0,1)&&(h={x:t.x+f*a,y:t.y+f*s})}return h}function st(t){return Math.abs(t)<1e-6?0:t<0?-1:1}function ut(t,e,n){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])&&Math.min(t[0],e[0])<=n[0]&&n[0]<=Math.max(t[0],e[0])&&Math.min(t[1],e[1])<=n[1]&&n[1]<=Math.max(t[1],e[1])}function lt(t,e,n){var i=!1,r=t.length;if(r<=2)return!1;for(var o=0;o0!=st(s[1]-n)>0&&st(e-(n-a[1])*(a[0]-s[0])/(a[1]-s[1])-a[0])<0&&(i=!i)}return i}function ct(t){for(var e=[],n=t.length,i=0;i1){var a=t[0],s=t[n-1];e.push({from:{x:s[0],y:s[1]},to:{x:a[0],y:a[1]}})}return e}function ht(t){var e=t.map((function(t){return t[0]})),n=t.map((function(t){return t[1]}));return{minX:Math.min.apply(null,e),maxX:Math.max.apply(null,e),minY:Math.min.apply(null,n),maxY:Math.max.apply(null,n)}}function ft(t,e){if(t.length<2||e.length<2)return!1;var n,i,r=ht(t),o=ht(e);if(n=r,(i=o).minX>n.maxX||i.maxXn.maxY||i.maxY=l}))||t[t.length-1]}var l=r.memoize((function(t){if(t.isCategory)return 1;for(var e=t.values,n=e.length,i=t.translate(e[0]),r=i,o=0;or&&(r=s)}return(r-i)/(n-1)}));function c(t){for(var e,n=0,i=function(t){var e=r.values(t.attributes);return r.filter(e,(function(t){return r.contains(o.GROUP_ATTRS,t.type)}))}(t);n(1+o)/2&&(s=a),i.translate(i.invert(s))}(t,n),O=M[o.FIELD_ORIGIN][h],S=M[o.FIELD_ORIGIN][f],A=C[o.FIELD_ORIGIN][h],P=c.isLinear&&r.isArray(S);if(r.isArray(O)){for(m=0;m=w){if(!P){p=k;break}r.isArray(p)||(p=[]),p.push(k)}}r.isArray(p)&&(p=u(p,t,n))}else{var I=void 0;if(a.isLinear||"timeCat"===a.type){if((w>a.translate(A)||wa.max||wMath.abs(a.translate(I[o.FIELD_ORIGIN][h])-w)&&(C=I)}var B=l(n.getXScale());return!p&&Math.abs(a.translate(C[o.FIELD_ORIGIN][h])-w)<=B/2&&(p=C),p},e.getTooltipItems=function(t,e,n){void 0===n&&(n="");var s,u=t[o.FIELD_ORIGIN],l=function(t,e,n){var i=n;n||(i=e.getAttribute("position").getFields()[0]);var o=e.scales;return o[i]?o[i].getText(t[i]):r.hasKey(t,i)?t[i]:i}(u,e,n),h=e.tooltipOption,f=e.theme.defaultColor,p=[];function d(e,n){if(!r.isNil(n)&&""!==n){var i={title:l,data:u,mappingData:t,name:e,value:n,color:t.color||f,marker:!0};p.push(i)}}if(r.isObject(h)){var g=h.fields,y=h.callback;if(y){var v=g.map((function(e){return t[o.FIELD_ORIGIN][e]})),m=y.apply(void 0,v),x=i.__assign({data:t[o.FIELD_ORIGIN],mappingData:t,title:l,color:t.color||f,marker:!0},m);p.push(x)}else for(var b=e.scales,_=0,M=g;_-1)return;r.push(t),"active"!==t&&"selected"!==t||s.toFront()}else{if(-1===c)return;r.splice(c,1),"active"!==t&&"selected"!==t||s.toBack()}var h=o.drawShape(l,a,this.getOffscreenGroup());r.length?r.forEach((function(t){n.syncShapeStyle(s,h,t,null)})):this.syncShapeStyle(s,h,"reset",null),h.remove(!0);var f={state:t,stateStatus:e,element:this,target:this.container};this.container.emit("statechange",f),u.propagationDelegate(this.shape,"statechange",f)},e.prototype.clearStates=function(){var t=this,e=this.states;r.each(e,(function(e){t.setState(e,!1)})),this.states=[]},e.prototype.hasState=function(t){return this.states.includes(t)},e.prototype.getStates=function(){return this.states},e.prototype.getData=function(){return this.data},e.prototype.getModel=function(){return this.model},e.prototype.getBBox=function(){var t=this.shape,e=this.labelShape,n={x:0,y:0,minX:0,minY:0,maxX:0,maxY:0,width:0,height:0};return t&&(n=t.getCanvasBBox()),e&&e.forEach((function(t){var e=t.getCanvasBBox();n.x=Math.min(e.x,n.x),n.y=Math.min(e.y,n.y),n.minX=Math.min(e.minX,n.minX),n.minY=Math.min(e.minY,n.minY),n.maxX=Math.max(e.maxX,n.maxX),n.maxY=Math.max(e.maxY,n.maxY)})),n.width=n.maxX-n.minX,n.height=n.maxY-n.minY,n},e.prototype.getStatesStyle=function(){if(!this.statesStyle){var t=this.shapeType,e=this.geometry,n=this.shapeFactory,i=e.stateOption,o=n.defaultShapeType,a=n.theme[t]||n.theme[o];this.statesStyle=r.deepMix({},a,i)}return this.statesStyle},e.prototype.getStateStyle=function(t,e){var n=this.getStatesStyle(),i=r.get(n,[t,"style"],{}),o=i[e]||i;return r.isFunction(o)?o(this):o},e.prototype.getAnimateCfg=function(t){var e=this.animate;return e?e[t]:null},e.prototype.drawShape=function(t,e){void 0===e&&(e=!1);var n=this.shapeFactory,a=this.container,s=this.shapeType;if(this.shape=n.drawShape(s,t,a),this.shape){this.setShapeInfo(this.shape,t);var u=this.shape.cfg.name;u?r.isString(u)&&(this.shape.cfg.name=["element",u]):this.shape.cfg.name=["element",this.shapeFactory.geometryType];var l=e?"enter":"appear",c=this.getAnimateCfg(l);c&&o.doAnimate(this.shape,c,{coordinate:n.coordinate,toAttrs:i.__assign({},this.shape.attr())})}},e.prototype.getOffscreenGroup=function(){if(!this.offscreenGroup){var t=this.container.getGroupBase();this.offscreenGroup=new t({})}return this.offscreenGroup},e.prototype.setShapeInfo=function(t,e){var n=this;(t.cfg.origin=e,t.cfg.element=this,t.isGroup())&&t.get("children").forEach((function(t){n.setShapeInfo(t,e)}))},e.prototype.syncShapeStyle=function(t,e,n,i,a){if(void 0===n&&(n=""),void 0===a&&(a=0),t.isGroup())for(var u=t.get("children"),l=e.get("children"),c=0;c200&&(c=a/10);for(var h=1/c,f=h/10,p=0;p<=c;p++){var d=p*h,g=[o.apply(null,t.concat([d])),o.apply(null,e.concat([d]))];(x=i.distance(l[0],l[1],g[0],g[1]))=0&&x1&&(n*=Math.sqrt(m),o*=Math.sqrt(m));var x=n*n*(v*v)+o*o*(y*y),b=x?Math.sqrt((n*n*(o*o)-x)/x):1;c===h&&(b*=-1),isNaN(b)&&(b=0);var _=o?b*n*v/o:0,M=n?b*-o*y/n:0,C=(f+d)/2+Math.cos(l)*_-Math.sin(l)*M,w=(p+g)/2+Math.sin(l)*_+Math.cos(l)*M,O=[(y-_)/n,(v-M)/o],S=[(-1*y-_)/n,(-1*v-M)/o],A=s([1,0],O),P=s(O,S);return a(O,S)<=-1&&(P=Math.PI),a(O,S)>=1&&(P=0),0===h&&P>0&&(P-=2*Math.PI),1===h&&P<0&&(P+=2*Math.PI),{cx:C,cy:w,rx:u(t,[d,g])?0:n,ry:u(t,[d,g])?0:o,startAngle:A,endAngle:A+P,xRotation:l,arcFlag:c,sweepFlag:h}}},function(t,e,n){"use strict";n.r(e);var i=n(111);for(var r in i)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(r)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";n.r(e);var i=n(113);for(var r in i)["default"].indexOf(r)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(r)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),r=n(7),o=n(78),a=n(11),s=n(43),u=n(79),l=n(115);function c(t,e,n,i,r){return 1===t.length?[["M",t[0].x,t[0].y-r.lineWidth/2],["L",t[0].x,t[0].y],["L",t[0].x,t[0].y+r.lineWidth/2]]:(n?(e&&t.length&&t.push({x:t[0].x,y:t[0].y}),o=s.getSplinePath(t,!1,i)):(o=s.getLinePath(t,!1),e&&o.push(["Z"])),o);var o}function h(t,e,n,r,o,a){if(t.length){var s=t[0];return i.isArray(s.y)?function(t,e,n,r,o,a){var s=[],l=[];i.each(t,(function(t){var e=u.splitPoints(t);s.push(e[1]),l.push(e[0])}));var h=c(s,e,r,o,a),f=c(l,e,r,o,a);return n?h:h.concat(f)}(t,e,n,r,o,a):c(t,e,r,o,a)}return[]}var f=r.registerShapeFactory("line",{defaultShapeType:"line"});i.each(["line","dot","dash","smooth"],(function(t){r.registerShape("line",t,{draw:function(e,n){var i,r="smooth"===t;if(r){var s=this.coordinate,u=s.start,l=s.end;i=[[u.x,l.y],[l.x,u.y]]}var c=function(t,e,n){for(var i=t.isStack,r=t.connectNulls,s=t.isInCircle,u=t.showSinglePoint,l=a.getStyle(t,!0,!1,"lineWidth"),c=o.getPathPoints(t.points,r,u),f=[],p=0,d=c.length;p1){a.sort();var l=function(t,e){var n=t.length,r=t;i.isString(r[0])&&(r=t.map((function(t){return e.translate(t)})));for(var o=r[1]-r[0],a=2;as&&(o=s)}return o}(a,o);u=(o.max-o.min)/l,a.length>u&&(u=a.length)}var c=o.range,h=1/u,f=1;n.isPolar?f=n.isTransposed&&u>1?e.multiplePieWidthRatio:e.roseWidthRatio:(o.isLinear&&(h*=c[1]-c[0]),f=e.columnWidthRatio),h*=f,t.getAdjust("dodge")&&(h/=function(t,e){if(e){var n=i.flatten(t);return i.valuesOfKey(n,e).length}return t.length}(s,t.getAdjust("dodge").dodgeBy));var p=e.maxColumnWidth,d=e.minColumnWidth,g=r.getXDimensionLength(t.coordinate);if(p){var y=p/g;h>y&&(h=y)}if(d){var v=d/g;h=-Math.PI/2?"left":"right";else if(n.isTransposed){var i=n.getCenter(),r=this.getDefaultOffset(t.offset);e=Math.abs(t.x-i.x)<1?"center":t.angle>Math.PI||t.angle<=0?r>0?"left":"right":r>0?"right":"left"}else e="center";return e},e.prototype.getLabelPoint=function(t,e,n){var i,r=1,o=t.content[n];this.isToMiddle(e)?i=this.getMiddlePoint(e.points):(1===t.content.length&&0===n?n=1:0===n&&(r=-1),i=this.getArcPoint(e,n));var a=this.getDefaultOffset(t.offset)*r,s=this.getPointAngle(i),u=t.labelEmit,l=this.getCirclePoint(s,a,i,u);return 0===l.r?l.content="":(l.content=o,l.angle=s,l.color=e.color),l.rotate=t.autoRotate?this.getLabelRotate(s,a,u):t.rotate,l.start={x:i.x,y:i.y},l},e.prototype.getArcPoint=function(t,e){return void 0===e&&(e=0),r.isArray(t.x)||r.isArray(t.y)?{x:r.isArray(t.x)?t.x[e]:t.x,y:r.isArray(t.y)?t.y[e]:t.y}:{x:t.x,y:t.y}},e.prototype.getPointAngle=function(t){return a.getAngleByPoint(this.getCoordinate(),t)},e.prototype.getCirclePoint=function(t,e,n,r){var a=this.getCoordinate(),s=a.getCenter(),u=o.getDistanceToCenter(a,n);if(0===u)return i.__assign(i.__assign({},s),{r:u});var l=t;a.isTransposed&&u>e&&!r?l=t+2*Math.asin(e/(2*u)):u+=e;return{x:s.x+u*Math.cos(l),y:s.y+u*Math.sin(l),r:u}},e.prototype.getLabelRotate=function(t,e,n){var i=t+u;return n&&(i-=u),i&&(i>u?i-=Math.PI:i<-u&&(i+=Math.PI)),i},e.prototype.getMiddlePoint=function(t){var e=this.getCoordinate(),n=t.length,i={x:0,y:0};return r.each(t,(function(t){i.x+=t.x,i.y+=t.y})),i.x/=n,i.y/=n,i=e.convert(i)},e.prototype.isToMiddle=function(t){return t.x.length>2},e}(s.default);e.default=l},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getTranslateDirection=e.directionToPosition=void 0;var i=n(6);function r(t){return t===i.DIRECTION.LEFT?i.DIRECTION.RIGHT:t===i.DIRECTION.RIGHT?i.DIRECTION.LEFT:t}function o(t){return t===i.DIRECTION.TOP?i.DIRECTION.BOTTOM:t===i.DIRECTION.BOTTOM?i.DIRECTION.TOP:t}e.directionToPosition=function(t,e,n){return n===i.DIRECTION.TOP?[t.minX+t.width/2-e.width/2,t.minY]:n===i.DIRECTION.BOTTOM?[t.minX+t.width/2-e.width/2,t.maxY-e.height]:n===i.DIRECTION.LEFT?[t.minX,t.minY+t.height/2-e.height/2]:n===i.DIRECTION.RIGHT?[t.maxX-e.width,t.minY+t.height/2-e.height/2]:n===i.DIRECTION.TOP_LEFT||n===i.DIRECTION.LEFT_TOP?[t.tl.x,t.tl.y]:n===i.DIRECTION.TOP_RIGHT||n===i.DIRECTION.RIGHT_TOP?[t.tr.x-e.width,t.tr.y]:n===i.DIRECTION.BOTTOM_LEFT||n===i.DIRECTION.LEFT_BOTTOM?[t.bl.x,t.bl.y-e.height]:n===i.DIRECTION.BOTTOM_RIGHT||n===i.DIRECTION.RIGHT_BOTTOM?[t.br.x-e.width,t.br.y-e.height]:[0,0]},e.getTranslateDirection=function(t,e){var n=t;return n=function(t,e){var n=t;return e.isReflect("x")&&(n=r(n)),e.isReflect("y")&&(n=o(n)),n}(n=function(t,e){var n=e.matrix[0],i=e.matrix[4],a=t;return n<0&&(a=r(a)),i<0&&(a=o(a)),a}(n=function(t,e){if(e.isTransposed)switch(t){case i.DIRECTION.BOTTOM:return i.DIRECTION.LEFT;case i.DIRECTION.LEFT:return i.DIRECTION.BOTTOM;case i.DIRECTION.RIGHT:return i.DIRECTION.TOP;case i.DIRECTION.TOP:return i.DIRECTION.RIGHT}return t}(n,e),e),e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeStamp=0,e}return i.__extends(e,t),e.prototype.show=function(){var t=this.context,e=t.event,n=t.view;if(!n.isTooltipLocked()){var i=this.timeStamp,o=+new Date;if(o-i>16){var a=this.location,s={x:e.x,y:e.y};a&&r.isEqual(a,s)||this.showTooltip(n,s),this.timeStamp=o,this.location=s}}},e.prototype.hide=function(){var t=this.context.view;t.isTooltipLocked()||(this.hideTooltip(t),this.location=null)},e.prototype.showTooltip=function(t,e){t.showTooltip(e)},e.prototype.hideTooltip=function(t){t.hideTooltip()},e}(i.__importDefault(n(12)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.shapeType="rect",e}return i.__extends(e,t),e.prototype.getRegion=function(){var t=this.points;return{start:r.head(t),end:r.last(t)}},e.prototype.getMaskAttrs=function(){var t=this.getRegion(),e=t.start,n=t.end;return{x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),width:Math.abs(n.x-e.x),height:Math.abs(n.y-e.y)}},e}(i.__importDefault(n(87)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.getMaskPath=function(){var t=this.points,e=[];return t.length&&(r.each(t,(function(t,n){0===n?e.push(["M",t.x,t.y]):e.push(["L",t.x,t.y])})),e.push(["L",t[0].x,t[0].y])),e},e.prototype.getMaskAttrs=function(){return{path:this.getMaskPath()}},e.prototype.addPoint=function(){this.resize()},e}(i.__importDefault(n(87)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=i.__importDefault(n(12)),o=n(8);function a(t,e,n,i){var r=Math.min(n[e],i[e]),o=Math.max(n[e],i[e]),a=t.range,s=a[0],u=a[1];if(ru&&(o=u),r===u&&o===u)return null;var l=t.invert(r),c=t.invert(o);if(t.isCategory){var h=t.values.indexOf(l),f=t.values.indexOf(c),p=t.values.slice(h,f+1);return function(t){return p.includes(t)}}return function(t){return t>=l&&t<=c}}var s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.dims=["x","y"],e.startPoint=null,e.isStarted=!1,e}return i.__extends(e,t),e.prototype.hasDim=function(t){return this.dims.includes(t)},e.prototype.start=function(){var t=this.context;this.isStarted=!0,this.startPoint=t.getCurrentPoint()},e.prototype.filter=function(){var t,e;if(o.isMask(this.context)){var n=this.context.event.target.getCanvasBBox();t={x:n.x,y:n.y},e={x:n.maxX,y:n.maxY}}else{if(!this.isStarted)return;t=this.startPoint,e=this.context.getCurrentPoint()}if(!(Math.abs(t.x-e.x)<5||Math.abs(t.x-e.y)<5)){var i=this.context.view,r=i.getCoordinate(),s=r.invert(e),u=r.invert(t);if(this.hasDim("x")){var l=i.getXScale(),c=a(l,"x",s,u);this.filterView(i,l.field,c)}if(this.hasDim("y")){var h=i.getYScales()[0];c=a(h,"y",s,u);this.filterView(i,h.field,c)}this.reRender(i)}},e.prototype.end=function(){this.isStarted=!1},e.prototype.reset=function(){var t=this.context.view;if(this.isStarted=!1,this.hasDim("x")){var e=t.getXScale();this.filterView(t,e.field,null)}if(this.hasDim("y")){var n=t.getYScales()[0];this.filterView(t,n.field,null)}this.reRender(t)},e.prototype.filterView=function(t,e,n){t.filter(e,n)},e.prototype.reRender=function(t){t.render(!0)},e}(r.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(71),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.dims=["x","y"],e.cfgFields=["dims"],e.cacheScaleDefs={},e}return i.__extends(e,t),e.prototype.hasDim=function(t){return this.dims.includes(t)},e.prototype.getScale=function(t){var e=this.context.view;return"x"===t?e.getXScale():e.getYScales()[0]},e.prototype.resetDim=function(t){var e=this.context.view;if(this.hasDim(t)&&this.cacheScaleDefs[t]){var n=this.getScale(t);e.scale(n.field,this.cacheScaleDefs[t]),this.cacheScaleDefs[t]=null}},e.prototype.reset=function(){this.resetDim("x"),this.resetDim("y"),this.context.view.render(!0)},e}(r.Action);e.default=o},function(t,e,n){"use strict";n.r(e),n.d(e,"registerAttribute",(function(){return y})),n.d(e,"getAttribute",(function(){return g})),n.d(e,"Attribute",(function(){return o})),n.d(e,"Color",(function(){return u})),n.d(e,"Opacity",(function(){return l})),n.d(e,"Position",(function(){return c})),n.d(e,"Shape",(function(){return h})),n.d(e,"Size",(function(){return f})),n.d(e,"Scale",(function(){return p.Scale}));var i=n(0),r=function(t,e){return Object(i.isString)(e)?e:t.invert(t.scale(e))},o=function(){function t(t){this.names=[],this.scales=[],this.linear=!1,this.values=[],this.callback=function(){return[]},this._parseCfg(t)}return t.prototype.mapping=function(){for(var t=this,e=[],n=0;n=u.minX&&e<=u.maxX&&n>=u.minY&&n<=u.maxY}var l=n(25),c=n(41),h=n(10),f=n(3),p=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(i.__extends)(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return e.renderer="canvas",e.autoDraw=!0,e.localRefresh=!0,e.refreshElements=[],e.clipView=!0,e.quickHit=!1,e},e.prototype.onCanvasChange=function(t){"attr"!==t&&"sort"!==t&&"changeSize"!==t||(this.set("refreshElements",[this]),this.draw())},e.prototype.getShapeBase=function(){return l},e.prototype.getGroupBase=function(){return c.a},e.prototype.getPixelRatio=function(){var t=this.get("pixelRatio")||Object(f.d)();return t>=1?Math.ceil(t):1},e.prototype.getViewRange=function(){return{minX:0,minY:0,maxX:this.get("width"),maxY:this.get("height")}},e.prototype.createDom=function(){var t=document.createElement("canvas"),e=t.getContext("2d");return this.set("context",e),t},e.prototype.setDOMSize=function(e,n){t.prototype.setDOMSize.call(this,e,n);var i=this.get("context"),r=this.get("el"),o=this.getPixelRatio();r.width=o*e,r.height=o*n,o>1&&i.scale(o,o)},e.prototype.clear=function(){t.prototype.clear.call(this),this._clearFrame();var e=this.get("context"),n=this.get("el");e.clearRect(0,0,n.width,n.height)},e.prototype.getShape=function(e,n){return this.get("quickHit")?function t(e,n,i){if(!u(e,n,i))return null;for(var r=null,o=e.getChildren(),a=o.length-1;a>=0;a--){var l=o[a];if(l.isGroup())r=t(l,n,i);else if(u(l,n,i)){var c=l,h=s(l,n,i),f=h[0],p=h[1];c.isInShape(f,p)&&(r=l)}if(r)break}return r}(this,e,n):t.prototype.getShape.call(this,e,n,null)},e.prototype._getRefreshRegion=function(){var t,e=this.get("refreshElements"),n=this.getViewRange();e.length&&e[0]===this?t=n:(t=Object(h.d)(e))&&(t.minX=Math.floor(t.minX),t.minY=Math.floor(t.minY),t.maxX=Math.ceil(t.maxX),t.maxY=Math.ceil(t.maxY),this.get("clipView")&&(t=Object(h.e)(t,n)));return t},e.prototype.refreshElement=function(t){this.get("refreshElements").push(t)},e.prototype._clearFrame=function(){var t=this.get("drawFrame");t&&(Object(f.a)(t),this.set("drawFrame",null),this.set("refreshElements",[]))},e.prototype.draw=function(){var t=this.get("drawFrame");this.get("autoDraw")&&t||this._startDraw()},e.prototype._drawAll=function(){var t=this.get("context"),e=this.get("el"),n=this.getChildren();t.clearRect(0,0,e.width,e.height),Object(h.a)(t,this),Object(h.b)(t,n),this.set("refreshElements",[])},e.prototype._drawRegion=function(){var t=this.get("context"),e=this.get("refreshElements"),n=this.getChildren(),i=this._getRefreshRegion();i&&(t.clearRect(i.minX,i.minY,i.maxX-i.minX,i.maxY-i.minY),t.save(),t.beginPath(),t.rect(i.minX,i.minY,i.maxX-i.minX,i.maxY-i.minY),t.clip(),Object(h.a)(t,this),Object(h.b)(t,n,i),t.restore()),Object(f.c)(e,(function(t){t.get("hasChanged")&&t.set("hasChanged",!1)})),this.set("refreshElements",[])},e.prototype._startDraw=function(){var t=this,e=this.get("drawFrame");e||(e=Object(f.n)((function(){t.get("localRefresh")?t._drawRegion():t._drawAll(),t.set("drawFrame",null)})),this.set("drawFrame",e))},e.prototype.skipDraw=function(){},e}(r.AbstractCanvas);e.a=p},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(152),r=n(153),o=n(23),a=function(t,e){if(t===e)return!0;if(!t||!e)return!1;if(o.default(t)||o.default(e))return!1;if(r.default(t)||r.default(e)){if(t.length!==e.length)return!1;for(var n=!0,s=0;s=0)i=l+this.getIntervalOnlyOffset(n,e);else if(!r.isNil(u)&&r.isNil(s)&&u>=0){i=l+this.getDodgeOnlyOffset(n,e)}else if(!r.isNil(s)&&!r.isNil(u)&&s>=0&&u>=0){i=l+this.getIntervalAndDodgeOffset(n,e)}else{var f=h*o/n,p=a*f;i=(l+c)/2+(.5*(h-n*f-(n-1)*p)+((e+1)*f+e*p)-.5*f-.5*h)}return i},e.prototype.getIntervalOnlyOffset=function(t,e){var n=this,i=n.defaultSize,o=n.intervalPadding,a=n.xDimensionLegenth,s=n.groupNum,u=n.dodgeRatio,l=n.maxColumnWidth,c=n.minColumnWidth,h=n.columnWidthRatio,f=o/a,p=(1-(s-1)*f)/s*u/(t-1),d=((1-f*(s-1))/s-p*(t-1))/t;if(d=r.isNil(h)?d:1/s/t*h,!r.isNil(l)){var g=l/a;d=Math.min(d,g)}if(!r.isNil(c)){var y=c/a;d=Math.max(d,y)}return((.5+e)*(d=i?i/a:d)+e*(p=((1-(s-1)*f)/s-t*d)/(t-1))+.5*f)*s-f/2},e.prototype.getDodgeOnlyOffset=function(t,e){var n=this,i=n.defaultSize,o=n.dodgePadding,a=n.xDimensionLegenth,s=n.groupNum,u=n.marginRatio,l=n.maxColumnWidth,c=n.minColumnWidth,h=n.columnWidthRatio,f=o/a,p=1*u/(s-1),d=((1-p*(s-1))/s-f*(t-1))/t;if(d=h?1/s/t*h:d,!r.isNil(l)){var g=l/a;d=Math.min(d,g)}if(!r.isNil(c)){var y=c/a;d=Math.max(d,y)}return((.5+e)*(d=i?i/a:d)+e*f+.5*(p=(1-(d*t+f*(t-1))*s)/(s-1)))*s-p/2},e.prototype.getIntervalAndDodgeOffset=function(t,e){var n=this.intervalPadding,i=this.dodgePadding,r=this.xDimensionLegenth,o=this.groupNum,a=n/r,s=i/r;return((.5+e)*(((1-a*(o-1))/o-s*(t-1))/t)+e*s+.5*a)*o-a/2},e.prototype.getDistribution=function(t){var e=this.adjustDataArray,n=this.cacheMap,i=n[t];return i||(i={},r.each(e,(function(e,n){var o=r.valuesOfKey(e,t);o.length||o.push(0),r.each(o,(function(t){i[t]||(i[t]=[]),i[t].push(n)}))})),n[t]=i),i},e}(n(18).a);e.a=a},function(t,e,n){"use strict";var i=n(14),r=n(0),o=n(29);var a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(i.__extends)(e,t),e.prototype.process=function(t){var e=r.clone(t),n=r.flatten(e);return this.adjustData(e,n),e},e.prototype.adjustDim=function(t,e,n){var i=this,o=this.groupData(n,t);return r.each(o,(function(n,r){return i.adjustGroup(n,t,parseFloat(r),e)}))},e.prototype.getAdjustOffset=function(t){var e,n=t.pre,i=t.next,r=(i-n)*o.c;return(i-r-(e=n+r))*Math.random()+e},e.prototype.adjustGroup=function(t,e,n,i){var o=this,a=this.getAdjustRange(e,n,i);return r.each(t,(function(t){t[e]=o.getAdjustOffset(a)})),t},e}(n(18).a);e.a=a},function(t,e,n){"use strict";var i=n(14),r=n(0),o=n(18),a=r.Cache,s=function(t){function e(e){var n=t.call(this,e)||this,i=e.adjustNames,r=void 0===i?["y"]:i,o=e.height,a=void 0===o?NaN:o,s=e.size,u=void 0===s?10:s,l=e.reverseOrder,c=void 0!==l&&l;return n.adjustNames=r,n.height=a,n.size=u,n.reverseOrder=c,n}return Object(i.__extends)(e,t),e.prototype.process=function(t){var e=this.yField,n=this.reverseOrder,i=e?this.processStack(t):this.processOneDimStack(t);return n?this.reverse(i):i},e.prototype.reverse=function(t){return t.slice(0).reverse()},e.prototype.processStack=function(t){var e=this.xField,n=this.yField,o=this.reverseOrder?this.reverse(t):t,s=new a,u=new a;return o.map((function(t){return t.map((function(t){var o,a=r.get(t,e,0),l=r.get(t,[n]),c=a.toString();if(l=r.isArray(l)?l[1]:l,!r.isNil(l)){var h=l>=0?s:u;h.has(c)||h.set(c,0);var f=h.get(c),p=l+f;return h.set(c,p),Object(i.__assign)(Object(i.__assign)({},t),((o={})[n]=[f,p],o))}return t}))}))},e.prototype.processOneDimStack=function(t){var e=this,n=this.xField,r=this.height,o=this.reverseOrder,s=o?this.reverse(t):t,u=new a;return s.map((function(t){return t.map((function(t){var o,a=e.size,s=t[n],l=2*a/r;u.has(s)||u.set(s,l/2);var c=u.get(s);return u.set(s,c+l),Object(i.__assign)(Object(i.__assign)({},t),((o={}).y=c,o))}))}))},e}(o.a);e.a=s},function(t,e,n){"use strict";var i=n(14),r=n(0),o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(i.__extends)(e,t),e.prototype.process=function(t){var e=r.flatten(t),n=this.xField,o=this.yField,a=this.getXValuesMaxMap(e),s=Math.max.apply(Math,Object.keys(a).map((function(t){return a[t]})));return r.map(t,(function(t){return r.map(t,(function(t){var e,u,l=t[o],c=t[n];if(r.isArray(l)){var h=(s-a[c])/2;return Object(i.__assign)(Object(i.__assign)({},t),((e={})[o]=r.map(l,(function(t){return h+t})),e))}var f=(s-l)/2;return Object(i.__assign)(Object(i.__assign)({},t),((u={})[o]=[f,l+f],u))}))}))},e.prototype.getXValuesMaxMap=function(t){var e=this,n=this.xField,i=this.yField,o=r.groupBy(t,(function(t){return t[n]}));return r.mapValues(o,(function(t){return e.getDimMaxValue(t,i)}))},e.prototype.getDimMaxValue=function(t,e){var n=r.map(t,(function(t){return r.get(t,e,[])})),i=r.flatten(n);return Math.max.apply(Math,i)},e}(n(18).a);e.a=o},function(t,e,n){"use strict";var i=this&&this.__spreadArrays||function(){for(var t=0,e=0,n=arguments.length;e0}Dt.registerInteraction("tooltip",{start:[{trigger:"plot:mousemove",action:"tooltip:show",throttle:{wait:50,leading:!0,trailing:!1}},{trigger:"plot:touchmove",action:"tooltip:show",throttle:{wait:50,leading:!0,trailing:!1}}],end:[{trigger:"plot:mouseleave",action:"tooltip:hide"},{trigger:"plot:leave",action:"tooltip:hide"},{trigger:"plot:touchend",action:"tooltip:hide"}]}),Dt.registerInteraction("ellipsis-text",{start:[{trigger:"legend-item-name:mousemove",action:"ellipsis-text:show",throttle:{wait:50,leading:!0,trailing:!1}},{trigger:"legend-item-name:touchstart",action:"ellipsis-text:show",throttle:{wait:50,leading:!0,trailing:!1}},{trigger:"axis-label:mousemove",action:"ellipsis-text:show",throttle:{wait:50,leading:!0,trailing:!1}},{trigger:"axis-label:touchstart",action:"ellipsis-text:show",throttle:{wait:50,leading:!0,trailing:!1}}],end:[{trigger:"legend-item-name:mouseleave",action:"ellipsis-text:hide"},{trigger:"legend-item-name:touchend",action:"ellipsis-text:hide"},{trigger:"axis-label:mouseleave",action:"ellipsis-text:hide"},{trigger:"axis-label:touchend",action:"ellipsis-text:hide"}]}),Dt.registerInteraction("element-active",{start:[{trigger:"element:mouseenter",action:"element-active:active"}],end:[{trigger:"element:mouseleave",action:"element-active:reset"}]}),Dt.registerInteraction("element-selected",{start:[{trigger:"element:click",action:"element-selected:toggle"}]}),Dt.registerInteraction("element-highlight",{start:[{trigger:"element:mouseenter",action:"element-highlight:highlight"}],end:[{trigger:"element:mouseleave",action:"element-highlight:reset"}]}),Dt.registerInteraction("element-highlight-by-x",{start:[{trigger:"element:mouseenter",action:"element-highlight-by-x:highlight"}],end:[{trigger:"element:mouseleave",action:"element-highlight-by-x:reset"}]}),Dt.registerInteraction("element-highlight-by-color",{start:[{trigger:"element:mouseenter",action:"element-highlight-by-color:highlight"}],end:[{trigger:"element:mouseleave",action:"element-highlight-by-color:reset"}]}),Dt.registerInteraction("legend-active",{start:[{trigger:"legend-item:mouseenter",action:["list-active:active","element-active:active"]}],end:[{trigger:"legend-item:mouseleave",action:["list-active:reset","element-active:reset"]}]}),Dt.registerInteraction("legend-highlight",{start:[{trigger:"legend-item:mouseenter",action:["legend-item-highlight:highlight","element-highlight:highlight"]}],end:[{trigger:"legend-item:mouseleave",action:["legend-item-highlight:reset","element-highlight:reset"]}]}),Dt.registerInteraction("axis-label-highlight",{start:[{trigger:"axis-label:mouseenter",action:["axis-label-highlight:highlight","element-highlight:highlight"]}],end:[{trigger:"axis-label:mouseleave",action:["axis-label-highlight:reset","element-highlight:reset"]}]}),Dt.registerInteraction("element-list-highlight",{start:[{trigger:"element:mouseenter",action:["list-highlight:highlight","element-highlight:highlight"]}],end:[{trigger:"element:mouseleave",action:["list-highlight:reset","element-highlight:reset"]}]}),Dt.registerInteraction("element-range-highlight",{showEnable:[{trigger:"plot:mouseenter",action:"cursor:crosshair"},{trigger:"mask:mouseenter",action:"cursor:move"},{trigger:"plot:mouseleave",action:"cursor:default"},{trigger:"mask:mouseleave",action:"cursor:crosshair"}],start:[{trigger:"plot:mousedown",isEnable:function(t){return!t.isInShape("mask")},action:["rect-mask:start","rect-mask:show"]},{trigger:"mask:dragstart",action:["rect-mask:moveStart"]}],processing:[{trigger:"plot:mousemove",action:["rect-mask:resize"]},{trigger:"mask:drag",action:["rect-mask:move"]},{trigger:"mask:change",action:["element-range-highlight:highlight"]}],end:[{trigger:"plot:mouseup",action:["rect-mask:end"]},{trigger:"mask:dragend",action:["rect-mask:moveEnd"]},{trigger:"document:mouseup",isEnable:function(t){return!t.isInPlot()},action:["element-range-highlight:clear","rect-mask:end","rect-mask:hide"]}],rollback:[{trigger:"dblclick",action:["element-range-highlight:clear","rect-mask:hide"]}]}),Dt.registerInteraction("brush",{showEnable:[{trigger:"plot:mouseenter",action:"cursor:crosshair"},{trigger:"plot:mouseleave",action:"cursor:default"}],start:[{trigger:"mousedown",isEnable:Ft,action:["brush:start","rect-mask:start","rect-mask:show"]}],processing:[{trigger:"mousemove",isEnable:Ft,action:["rect-mask:resize"]}],end:[{trigger:"mouseup",isEnable:Ft,action:["brush:filter","brush:end","rect-mask:end","rect-mask:hide","reset-button:show"]}],rollback:[{trigger:"reset-button:click",action:["brush:reset","reset-button:hide","cursor:crosshair"]}]}),Dt.registerInteraction("brush-visible",{showEnable:[{trigger:"plot:mouseenter",action:"cursor:crosshair"},{trigger:"plot:mouseleave",action:"cursor:default"}],start:[{trigger:"plot:mousedown",action:["rect-mask:start","rect-mask:show"]}],processing:[{trigger:"plot:mousemove",action:["rect-mask:resize"]},{trigger:"mask:change",action:["element-range-highlight:highlight"]}],end:[{trigger:"plot:mouseup",action:["rect-mask:end","rect-mask:hide","element-filter:filter","element-range-highlight:clear"]}],rollback:[{trigger:"dblclick",action:["element-filter:clear"]}]}),Dt.registerInteraction("brush-x",{showEnable:[{trigger:"plot:mouseenter",action:"cursor:crosshair"},{trigger:"plot:mouseleave",action:"cursor:default"}],start:[{trigger:"mousedown",isEnable:Ft,action:["brush-x:start","x-rect-mask:start","x-rect-mask:show"]}],processing:[{trigger:"mousemove",isEnable:Ft,action:["x-rect-mask:resize"]}],end:[{trigger:"mouseup",isEnable:Ft,action:["brush-x:filter","brush-x:end","x-rect-mask:end","x-rect-mask:hide"]}],rollback:[{trigger:"dblclick",action:["brush-x:reset"]}]}),Dt.registerInteraction("element-path-highlight",{showEnable:[{trigger:"plot:mouseenter",action:"cursor:crosshair"},{trigger:"plot:mouseleave",action:"cursor:default"}],start:[{trigger:"mousedown",isEnable:Ft,action:"path-mask:start"},{trigger:"mousedown",isEnable:Ft,action:"path-mask:show"}],processing:[{trigger:"mousemove",action:"path-mask:addPoint"}],end:[{trigger:"mouseup",action:"path-mask:end"}],rollback:[{trigger:"dblclick",action:"path-mask:hide"}]}),Dt.registerInteraction("element-single-selected",{start:[{trigger:"element:click",action:"element-single-selected:toggle"}]}),Dt.registerInteraction("legend-filter",{showEnable:[{trigger:"legend-item:mouseenter",action:"cursor:pointer"},{trigger:"legend-item:mouseleave",action:"cursor:default"}],start:[{trigger:"legend-item:click",action:["list-unchecked:toggle","data-filter:filter"]}]}),Dt.registerInteraction("continuous-filter",{start:[{trigger:"legend:valuechanged",action:"data-filter:filter"}]}),Dt.registerInteraction("continuous-visible-filter",{start:[{trigger:"legend:valuechanged",action:"element-filter:filter"}]}),Dt.registerInteraction("legend-visible-filter",{showEnable:[{trigger:"legend-item:mouseenter",action:"cursor:pointer"},{trigger:"legend-item:mouseleave",action:"cursor:default"}],start:[{trigger:"legend-item:click",action:["list-unchecked:toggle","element-filter:filter"]}]}),Dt.registerInteraction("active-region",{start:[{trigger:"plot:mousemove",action:"active-region:show"}],end:[{trigger:"plot:mouseleave",action:"active-region:hide"}]}),Dt.registerInteraction("view-zoom",{start:[{trigger:"plot:mousewheel",isEnable:function(t){return Rt(t.event)},action:"scale-zoom:zoomOut",throttle:{wait:100,leading:!0,trailing:!1}},{trigger:"plot:mousewheel",isEnable:function(t){return!Rt(t.event)},action:"scale-zoom:zoomIn",throttle:{wait:100,leading:!0,trailing:!1}}]}),Dt.registerInteraction("sibling-tooltip",{start:[{trigger:"plot:mousemove",action:"sibling-tooltip:show"}],end:[{trigger:"plot:mouseleave",action:"sibling-tooltip:hide"}]}),i.__exportStar(n(19),e);var Nt=n(16),Gt=n(73);e.Util={translate:Gt.translate,rotate:Gt.rotate,zoom:Gt.zoom,transform:Gt.transform,getAngle:Nt.getAngle,polarToCartesian:Nt.polarToCartesian}},,,,,,,,function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(6),a=n(96),s=n(142),u=function(t){function e(e){var n=this,u=e.container,l=e.width,c=e.height,h=e.autoFit,f=void 0!==h&&h,p=e.padding,d=e.appendPadding,g=e.renderer,y=void 0===g?"canvas":g,v=e.pixelRatio,m=e.localRefresh,x=void 0===m||m,b=e.visible,_=void 0===b||b,M=e.defaultInteractions,C=void 0===M?["tooltip","legend-filter","legend-active","continuous-filter","ellipsis-text"]:M,w=e.options,O=e.limitInPlot,S=e.theme,A=r.isString(u)?document.getElementById(u):u,P=s.createDom('
');A.appendChild(P);var I=s.getChartSize(A,f,l,c),T=new(a.getEngine(y).Canvas)(i.__assign({container:P,pixelRatio:v,localRefresh:x},I));return(n=t.call(this,{parent:null,canvas:T,backgroundGroup:T.addGroup({zIndex:o.GROUP_Z_INDEX.BG}),middleGroup:T.addGroup({zIndex:o.GROUP_Z_INDEX.MID}),foregroundGroup:T.addGroup({zIndex:o.GROUP_Z_INDEX.FORE}),padding:p,appendPadding:d,visible:_,options:w,limitInPlot:O,theme:S})||this).onResize=r.debounce((function(){n.forceFit()}),300),n.ele=A,n.canvas=T,n.width=I.width,n.height=I.height,n.autoFit=f,n.localRefresh=x,n.renderer=y,n.wrapperElement=P,n.updateCanvasStyle(),n.bindAutoFit(),n.initDefaultInteractions(C),n}return i.__extends(e,t),e.prototype.initDefaultInteractions=function(t){var e=this;r.each(t,(function(t){e.interaction(t)}))},e.prototype.changeSize=function(t,e){return this.width===t&&this.height===e||(this.width=t,this.height=e,this.canvas.changeSize(t,e),this.render(!0)),this},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.unbindAutoFit(),this.canvas.destroy(),s.removeDom(this.wrapperElement),this.wrapperElement=null},e.prototype.changeVisible=function(e){return t.prototype.changeVisible.call(this,e),this.wrapperElement.style.display=e?"":"none",this},e.prototype.forceFit=function(){if(!this.destroyed){var t=s.getChartSize(this.ele,!0,this.width,this.height),e=t.width,n=t.height;this.changeSize(e,n)}},e.prototype.updateCanvasStyle=function(){s.modifyCSS(this.canvas.get("el"),{display:"inline-block",verticalAlign:"middle"})},e.prototype.bindAutoFit=function(){this.autoFit&&window.addEventListener("resize",this.onResize)},e.prototype.unbindAutoFit=function(){this.autoFit&&window.removeEventListener("resize",this.onResize)},e}(i.__importDefault(n(97)).default);e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.removeDom=e.getChartSize=void 0;var i=n(6);function r(t){return"number"==typeof t&&!isNaN(t)}e.getChartSize=function(t,e,n,o){var a=n,s=o;if(e){var u=function(t){var e=getComputedStyle(t);return{width:(t.clientWidth||parseInt(e.width,10))-parseInt(e.paddingLeft,10)-parseInt(e.paddingRight,10),height:(t.clientHeight||parseInt(e.height,10))-parseInt(e.paddingTop,10)-parseInt(e.paddingBottom,10)}}(t);a=u.width?u.width:a,s=u.height?u.height:s}return{width:Math.max(r(a)?a:i.MIN_CHART_WIDTH,i.MIN_CHART_WIDTH),height:Math.max(r(s)?s:i.MIN_CHART_HEIGHT,i.MIN_CHART_HEIGHT)}},e.removeDom=function(t){var e=t.parentNode;e&&e.removeChild(t)};var o=n(5);Object.defineProperty(e,"createDom",{enumerable:!0,get:function(){return o.createDom}}),Object.defineProperty(e,"modifyCSS",{enumerable:!0,get:function(){return o.modifyCSS}})},function(t){t.exports=JSON.parse('{"__npminstall_done":false,"_from":"@antv/g-base@^0.4.3","_id":"@antv/g-base@0.4.7","_inBundle":false,"_integrity":"sha1-dpj8TIyzgfK3iaMPvrJrHojEgZY=","_location":"/@antv/g-base","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"@antv/g-base@^0.4.3","name":"@antv/g-base","escapedName":"@antv%2fg-base","scope":"@antv","rawSpec":"^0.4.3","saveSpec":null,"fetchSpec":"^0.4.3"},"_requiredBy":["/@antv/component","/@antv/g-canvas","/@antv/g-svg","/@antv/g2"],"_resolved":"https://registry.npm.taobao.org/@antv/g-base/download/@antv/g-base-0.4.7.tgz?cache=0&sync_timestamp=1600175593302&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40antv%2Fg-base%2Fdownload%2F%40antv%2Fg-base-0.4.7.tgz","_shasum":"7698fc4c8cb381f2b789a30fbeb26b1e88c48196","_spec":"@antv/g-base@^0.4.3","_where":"D:\\\\git\\\\building\\\\vscode-mysql\\\\node_modules\\\\@antv\\\\g2","author":{"name":"https://github.com/orgs/antvis/people"},"bugs":{"url":"https://github.com/antvis/util/issues"},"bundleDependencies":false,"dependencies":{"@antv/event-emitter":"^0.1.1","@antv/g-math":"^0.1.3","@antv/matrix-util":"^3.1.0-beta.1","@antv/path-util":"~2.0.5","@antv/util":"~2.0.0","@types/d3-timer":"^1.0.9","d3-ease":"^1.0.5","d3-interpolate":"^1.3.2","d3-timer":"^1.0.9","detect-browser":"^5.1.0"},"deprecated":false,"description":"A common util collection for antv projects","devDependencies":{"@antv/torch":"^1.0.0","gl-matrix":"^3.0.0","less":"^3.9.0","npm-run-all":"^4.1.5","tsc-watch":"^4.0.0"},"files":["package.json","esm","lib","LICENSE","README.md"],"gitHead":"eb6a2503cb7bb8154697592b10680939d954a31a","homepage":"https://github.com/antvis/util#readme","keywords":["util","antv","g"],"license":"ISC","main":"lib/index.js","module":"esm/index.js","name":"@antv/g-base","publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/antvis/util.git"},"scripts":{"build":"npm run clean && run-p build:*","build:cjs":"tsc -p tsconfig.json --target ES5 --module commonjs --outDir lib","build:esm":"tsc -p tsconfig.json --target ES5 --module ESNext --outDir esm","clean":"rm -rf esm lib","coverage":"npm run coverage-generator && npm run coverage-viewer","coverage-generator":"torch --coverage --compile --source-pattern src/*.js,src/**/*.js --opts tests/mocha.opts","coverage-viewer":"torch-coverage","test":"torch --renderer --compile --opts tests/mocha.opts","test-live":"torch --compile --interactive --opts tests/mocha.opts","tsc":"tsc --noEmit","typecheck":"tsc --noEmit","watch:cjs":"tsc-watch -p tsconfig.json --target ES5 --module commonjs --outDir lib --compiler typescript/bin/tsc"},"types":"lib/index.d.ts","version":"0.4.7"}')},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(31);e.default=function(t){return i.default(t)?"":t.toString()}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.Adjust=e.registerAdjust=e.getAdjust=void 0;var i=n(14),r=n(146);e.Adjust=r.default;var o={},a=function(t){return o[t.toLowerCase()]};e.getAdjust=a;e.registerAdjust=function(t,e){if(a(t))throw new Error("Adjust type '"+t+"' existed.");o[t.toLowerCase()]=e},i.__exportStar(n(148),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),r=n(147),o=function(){function t(t){var e=t.xField,n=t.yField,i=t.adjustNames,r=void 0===i?["x","y"]:i;this.adjustNames=r,this.xField=e,this.yField=n}return t.prototype.isAdjust=function(t){return this.adjustNames.indexOf(t)>=0},t.prototype.getAdjustRange=function(t,e,n){var i,r,o=this.yField,a=n.indexOf(e),s=n.length;return!o&&this.isAdjust("y")?(i=0,r=1):s>1?(i=n[0===a?0:a-1],r=n[a===s-1?s-1:a+1],0!==a?i+=(e-i)/2:i-=(r-e)/2,a!==s-1?r-=(r-e)/2:r+=(e-n[s-2])/2):(i=0===e?0:e-.5,r=0===e?1:e+.5),{pre:i,next:r}},t.prototype.adjustData=function(t,e){var n=this,r=this.getDimValues(e);i.each(t,(function(t,e){i.each(r,(function(i,r){n.adjustDim(r,i,t,e)}))}))},t.prototype.groupData=function(t,e){return i.each(t,(function(t){void 0===t[e]&&(t[e]=r.DEFAULT_Y)})),i.groupBy(t,e)},t.prototype.adjustDim=function(t,e,n,i){},t.prototype.getDimValues=function(t){var e=this.xField,n=this.yField,o={},a=[];if(e&&this.isAdjust("x")&&a.push(e),n&&this.isAdjust("y")&&a.push(n),a.forEach((function(e){o[e]=i.valuesOfKey(t,e).sort((function(t,e){return t-e}))})),!n&&this.isAdjust("y")){o.y=[r.DEFAULT_Y,1]}return o},t}();e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.GAP=e.DODGE_RATIO=e.MARGIN_RATIO=e.DEFAULT_Y=void 0,e.DEFAULT_Y=0,e.MARGIN_RATIO=.5,e.DODGE_RATIO=.5,e.GAP=.05},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(21),r=n(150);e.Attribute=r.default;var o={},a=function(t){return o[t.toLowerCase()]};e.getAttribute=a;e.registerAttribute=function(t,e){if(a(t))throw new Error("Attribute type '"+t+"' existed.");o[t.toLowerCase()]=e},i.__exportStar(n(151),e)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),r=function(t,e){return i.isString(e)?e:t.invert(t.scale(e))},o=function(){function t(t){this.names=[],this.scales=[],this.linear=!1,this.values=[],this.callback=function(){return[]},this._parseCfg(t)}return t.prototype.mapping=function(){for(var t=this,e=[],n=0;n=0&&e.splice(n,1)},t.prototype.getCurrentPoint=function(){var t=this.event;return t?t.target instanceof HTMLElement?this.view.getCanvas().getPointByClient(t.clientX,t.clientY):{x:t.x,y:t.y}:null},t.prototype.getCurrentShape=function(){return i.get(this.event,["gEvent","shape"])},t.prototype.isInPlot=function(){var t=this.getCurrentPoint();return!!t&&this.view.isPointInPlot(t)},t.prototype.isInShape=function(t){var e=this.getCurrentShape();return!!e&&e.get("name")===t},t.prototype.isInComponent=function(t){var e=r.getComponents(this.view),n=this.getCurrentPoint();return!!n&&!!e.find((function(e){var i=e.getBBox();return t?e.get("name")===t&&r.isInBox(i,n):r.isInBox(i,n)}))},t.prototype.destroy=function(){this.view=null,this.event=null,i.each(this.actions.slice(),(function(t){t.destroy()})),this.actions=null,this.cacheMap=null},t}();e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(158),r=n(159),o=n(0);function a(t){for(var e=[],n=t.length,i=0;i1){var a=t[0],s=t[n-1];e.push({from:{x:s[0],y:s[1]},to:{x:a[0],y:a[1]}})}return e}function s(t){var e=t.map((function(t){return t[0]})),n=t.map((function(t){return t[1]}));return{minX:Math.min.apply(null,e),maxX:Math.max.apply(null,e),minY:Math.min.apply(null,n),maxY:Math.max.apply(null,n)}}e.default=function(t,e){if(t.length<2||e.length<2)return!1;var n,u,l=s(t),c=s(e);if(n=l,(u=c).minX>n.maxX||u.maxXn.maxY||u.maxY0!=i(l[1]-n)>0&&i(e-(n-u[1])*(u[0]-l[0])/(u[1]-l[1])-u[0])<0&&(o=!o)}return o}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=function(t,e,n){return t>=e&&t<=n};e.default=function(t,e,n,r){var o=n.x-t.x,a=n.y-t.y,s=e.x-t.x,u=e.y-t.y,l=r.x-n.x,c=r.y-n.y,h=s*c-u*l,f=null;if(h*h>.001*(s*s+u*u)*(l*l+c*c)){var p=(o*c-a*l)/h,d=(o*u-a*s)/h;i(p,0,1)&&i(d,0,1)&&(f={x:t.x+p*s,y:t.y+p*u})}return f}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CROSSHAIR_Y=e.CROSSHAIR_X=e.NAME_CLASS=e.VALUE_CLASS=e.MARKER_CLASS=e.LIST_ITEM_CLASS=e.LIST_CLASS=e.TITLE_CLASS=e.CONTAINER_CLASS=void 0,e.CONTAINER_CLASS="g2-tooltip",e.TITLE_CLASS="g2-tooltip-title",e.LIST_CLASS="g2-tooltip-list",e.LIST_ITEM_CLASS="g2-tooltip-list-item",e.MARKER_CLASS="g2-tooltip-marker",e.VALUE_CLASS="g2-tooltip-value",e.NAME_CLASS="g2-tooltip-name",e.CROSSHAIR_X="g2-tooltip-crosshair-x",e.CROSSHAIR_Y="g2-tooltip-crosshair-y"},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.antvLight=void 0;var i="#000",r="#595959",o="#8C8C8C",a="#BFBFBF",s="#D9D9D9",u="#F0F0F0",l="#FFFFFF",c="#F2F2F2",h=["#5B8FF9","#5AD8A6","#5D7092","#F6BD16","#E86452","#6DC8EC","#945FB9","#FF9845","#1E9493","#FF99C3"];e.antvLight={backgroundColor:"transparent",brandColor:h[0],paletteQualitative10:h,paletteQualitative20:["#5B8FF9","#CDDDFD","#5AD8A6","#CDF3E4","#5D7092","#CED4DE","#F6BD16","#FCEBB9","#E86452","#F8D0CB","#6DC8EC","#D3EEF9","#945FB9","#DECFEA","#FF9845","#FFE0C7","#1E9493","#BBDEDE","#FF99C3","#FFE0ED"],paletteSemanticRed:"#F4664A",paletteSemanticGreen:"#30BF78",paletteSemanticYellow:"#FAAD14",fontFamily:'"-apple-system", "Segoe UI", Roboto, "Helvetica Neue", Arial,\n "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol",\n "Noto Color Emoji"',axisLineBorderColor:a,axisLineBorder:.5,axisLineDash:null,axisTitleTextFillColor:r,axisTitleTextFontSize:12,axisTitleTextLineHeight:12,axisTitleTextFontWeight:"normal",axisTickLineBorderColor:a,axisTickLineLength:4,axisTickLineBorder:.5,axisSubTickLineBorderColor:s,axisSubTickLineLength:2,axisSubTickLineBorder:.5,axisLabelFillColor:o,axisLabelFontSize:12,axisLabelLineHeight:12,axisLabelFontWeight:"normal",axisGridBorderColor:s,axisGridBorder:.5,axisGridLineDash:null,legendTitleTextFillColor:o,legendTitleTextFontSize:12,legendTitleTextLineHeight:21,legendTitleTextFontWeight:"normal",legendMarkerColor:h[0],legendMarkerSize:4,legendCircleMarkerSize:4,legendSquareMarkerSize:4,legendLineMarkerSize:5,legendItemNameFillColor:r,legendItemNameFontSize:12,legendItemNameLineHeight:12,legendItemNameFontWeight:"normal",sliderRailFillColor:s,sliderRailBorder:0,sliderRailBorderColor:null,sliderRailWidth:100,sliderRailHeight:12,sliderLabelTextFillColor:o,sliderLabelTextFontSize:12,sliderLabelTextLineHeight:12,sliderLabelTextFontWeight:"normal",sliderHandlerFillColor:u,sliderHandlerWidth:10,sliderHandlerHeight:14,sliderHandlerBorder:1,sliderHandlerBorderColor:a,annotationArcBorderColor:s,annotationArcBorder:.5,annotationLineBorderColor:a,annotationLineBorder:.5,annotationLineDash:null,annotationTextFillColor:r,annotationTextFontSize:12,annotationTextLineHeight:12,annotationTextFontWeight:"normal",annotationTextBorderColor:c,annotationTextBorder:1.5,annotationRegionFillColor:i,annotationRegionFillOpacity:.06,annotationRegionBorder:0,annotationRegionBorderColor:null,annotationDataMarkerLineLength:16,tooltipCrosshairsBorderColor:a,tooltipCrosshairsBorder:.5,tooltipCrosshairsLineDash:null,tooltipContainerFillColor:"rgb(255, 255, 255)",tooltipContainerFillOpacity:.95,tooltipContainerShadow:"0px 0px 10px #aeaeae",tooltipContainerBorderRadius:3,tooltipTextFillColor:r,tooltipTextFontSize:12,tooltipTextLineHeight:12,tooltipTextFontWeight:"bold",labelFillColor:r,labelFontSize:12,labelLineHeight:12,labelFontWeight:"normal",labelBorderColor:null,labelBorder:0,innerLabelFillColor:l,innerLabelFontSize:12,innerLabelLineHeight:12,innerLabelFontWeight:"normal",innerLabelBorderColor:null,innerLabelBorder:0,labelLineBorder:.5,labelLineBorderColor:a,pointFillColor:h[0],pointFillOpacity:.95,pointSize:4,pointBorder:1,pointBorderColor:l,pointBorderOpacity:1,pointActiveBorderColor:i,pointSelectedBorder:2,pointSelectedBorderColor:i,pointInactiveFillOpacity:.3,pointInactiveBorderOpacity:.3,hollowPointSize:4,hollowPointBorder:1,hollowPointBorderColor:h[0],hollowPointBorderOpacity:.95,hollowPointFillColor:l,hollowPointActiveBorder:1,hollowPointActiveBorderColor:i,hollowPointActiveBorderOpacity:1,hollowPointSelectedBorder:2,hollowPointSelectedBorderColor:i,hollowPointSelectedBorderOpacity:1,hollowPointInactiveBorderOpacity:.3,lineBorder:2,lineBorderColor:h[0],lineBorderOpacity:1,lineActiveBorder:3,lineSelectedBorder:3,lineInactiveBorderOpacity:.3,areaFillColor:h[0],areaFillOpacity:.25,areaActiveFillColor:h[0],areaActiveFillOpacity:.5,areaSelectedFillColor:h[0],areaSelectedFillOpacity:.5,areaInactiveFillOpacity:.3,hollowAreaBorderColor:h[0],hollowAreaBorder:2,hollowAreaBorderOpacity:1,hollowAreaActiveBorder:3,hollowAreaActiveBorderColor:i,hollowAreaSelectedBorder:3,hollowAreaSelectedBorderColor:i,hollowAreaInactiveBorderOpacity:.3,intervalFillColor:h[0],intervalFillOpacity:.95,intervalActiveBorder:1,intervalActiveBorderColor:i,intervalActiveBorderOpacity:1,intervalSelectedBorder:2,intervalSelectedBorderColor:i,intervalSelectedBorderOpacity:1,intervalInactiveBorderOpacity:.3,intervalInactiveFillOpacity:.3,hollowIntervalBorder:2,hollowIntervalBorderColor:h[0],hollowIntervalBorderOpacity:1,hollowIntervalFillColor:l,hollowIntervalActiveBorder:2,hollowIntervalActiveBorderColor:i,hollowIntervalSelectedBorder:3,hollowIntervalSelectedBorderColor:i,hollowIntervalSelectedBorderOpacity:1,hollowIntervalInactiveBorderOpacity:.3}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(26),a=function(){function t(t){this.option=this.wrapperOption(t)}return t.prototype.update=function(t){return this.option=this.wrapperOption(t),this},t.prototype.hasAction=function(t){var e=this.option.actions;return r.some(e,(function(e){return e[0]===t}))},t.prototype.create=function(t,e){var n=this.option,r=n.type,a=n.cfg,s="theta"===r,u=i.__assign({start:t,end:e},a),l=o.getCoordinate(s?"polar":r);return this.coordinate=new l(u),this.coordinate.type=r,s&&(this.hasAction("transpose")||this.transpose()),this.execActions(),this.coordinate},t.prototype.adjust=function(t,e){return this.coordinate.update({start:t,end:e}),this.coordinate.resetMatrix(),this.execActions(["scale","rotate","translate"]),this.coordinate},t.prototype.rotate=function(t){return this.option.actions.push(["rotate",t]),this},t.prototype.reflect=function(t){return this.option.actions.push(["reflect",t]),this},t.prototype.scale=function(t,e){return this.option.actions.push(["scale",t,e]),this},t.prototype.transpose=function(){return this.option.actions.push(["transpose"]),this},t.prototype.getOption=function(){return this.option},t.prototype.getCoordinate=function(){return this.coordinate},t.prototype.wrapperOption=function(t){return i.__assign({type:"rect",actions:[],cfg:{}},t)},t.prototype.execActions=function(t){var e=this,n=this.option.actions;r.each(n,(function(n){var i,o=n[0],a=n.slice(1);(!!r.isNil(t)||t.includes(o))&&(i=e.coordinate)[o].apply(i,a)}))},t}();e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(50),r=n(164);e.default=function(t){var e=t.getController("axis"),n=t.getController("legend"),o=t.getController("annotation"),a=t.getController("slider"),s=r.calculatePadding(t);t.coordinateBBox=t.viewBBox.shrink(s).shrink(i.parsePadding(t.appendPadding)),t.adjustCoordinate(),[e,a,n,o].forEach((function(t){t&&t.layout()}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.calculatePadding=void 0;var i=n(0),r=n(6),o=n(44),a=n(50),s=n(165);e.calculatePadding=function(t){var e=t.padding;if(!a.isAutoPadding(e))return a.parsePadding(e);var n=t.viewBBox,u=t.autoPadding,l=new s.PaddingCal;i.each(t.getComponents(),(function(t){var e=t.component,i=t.type;if(i!==r.COMPONENT_TYPE.GRID&&i!==r.COMPONENT_TYPE.TOOLTIP){var a=e.getLayoutBBox(),s=new o.BBox(a.x,a.y,a.width,a.height);if(i===r.COMPONENT_TYPE.AXIS){var u=s.exceed(n);l.shrink(u)}else{var c=t.direction;l.inc(s,c)}}}));var c=l.getPadding();if(u){var h=a.parsePadding(t.appendPadding);return[Math.max(u[0]-h[0],c[0]),Math.max(u[1]-h[1],c[1]),Math.max(u[2]-h[2],c[2]),Math.max(u[3]-h[3],c[3])]}return c}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.PaddingCal=void 0;var i=n(6),r=function(){function t(t,e,n,i){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===i&&(i=0),this.top=t,this.right=e,this.bottom=n,this.left=i}return t.prototype.shrink=function(t){var e=t[0],n=t[1],i=t[2],r=t[3];return this.top+=e,this.right+=n,this.bottom+=i,this.left+=r,this},t.prototype.inc=function(t,e){var n=t.width,r=t.height;switch(e){case i.DIRECTION.TOP:case i.DIRECTION.TOP_LEFT:case i.DIRECTION.TOP_RIGHT:this.top+=r;break;case i.DIRECTION.RIGHT:case i.DIRECTION.RIGHT_TOP:case i.DIRECTION.RIGHT_BOTTOM:this.right+=n;break;case i.DIRECTION.BOTTOM:case i.DIRECTION.BOTTOM_LEFT:case i.DIRECTION.BOTTOM_RIGHT:this.bottom+=r;break;case i.DIRECTION.LEFT:case i.DIRECTION.LEFT_TOP:case i.DIRECTION.LEFT_BOTTOM:this.left+=n}return this},t.prototype.getPadding=function(){return[this.top,this.right,this.bottom,this.left]},t}();e.PaddingCal=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ScalePool=void 0;var i=n(0),r=n(48),o=function(){function t(){this.scales=new Map,this.syncScales=new Map}return t.prototype.createScale=function(t,e,n,o){var a=n,s=this.getScaleMeta(o);if(0===e.length&&s){var u=s.scale,l={type:u.type};u.isCategory&&(l.values=u.values),a=i.deepMix(l,s.scaleDef,n)}var c=r.createScaleByField(t,e,a);return this.cacheScale(c,n,o),c},t.prototype.sync=function(){var t=this;this.syncScales.forEach((function(e,n){var r=Number.MAX_SAFE_INTEGER,o=Number.MIN_SAFE_INTEGER,a=[];i.each(e,(function(e){var n=t.getScale(e);o=i.isNumber(n.max)?Math.max(o,n.max):o,r=i.isNumber(n.min)?Math.min(r,n.min):r,i.each(n.values,(function(t){a.includes(t)||a.push(t)}))})),i.each(e,(function(e){var n=t.getScale(e);n.isContinuous?n.change({min:r,max:o,values:a}):n.isCategory&&n.change({values:a})}))}))},t.prototype.cacheScale=function(t,e,n){var i=this.getScaleMeta(n);i&&i.scale.type===t.type?(r.syncScale(i.scale,t),i.scaleDef=e):(i={key:n,scale:t,scaleDef:e},this.scales.set(n,i));var o=this.getSyncKey(i);if(i.syncKey=o,this.removeFromSyncScales(n),o){var a=this.syncScales.get(o);a||(a=[],this.syncScales.set(o,a)),a.push(n)}},t.prototype.getScale=function(t){var e=this.getScaleMeta(t);if(!e){var n=i.last(t.split("-")),r=this.syncScales.get(n);r&&r.length&&(e=this.getScaleMeta(r[0]))}return e&&e.scale},t.prototype.deleteScale=function(t){var e=this.getScaleMeta(t);if(e){var n=e.syncKey,i=this.syncScales.get(n);if(i&&i.length){var r=i.indexOf(t);-1!==r&&i.splice(r,1)}}this.scales.delete(t)},t.prototype.clear=function(){this.scales.clear(),this.syncScales.clear()},t.prototype.removeFromSyncScales=function(t){var e=this;this.syncScales.forEach((function(n,i){var r=n.indexOf(t);if(-1!==r)return n.splice(r,1),0===n.length&&e.syncScales.delete(i),!1}))},t.prototype.getSyncKey=function(t){var e=t.scale,n=t.scaleDef,r=e.field,o=i.get(n,["sync"]);return!0===o?r:!1===o?void 0:o},t.prototype.getScaleMeta=function(t){return this.scales.get(t)},t}();e.ScalePool=o},function(t,e,n){"use strict";n.r(e);var i=n(34);n.d(e,"getAdjust",(function(){return i.getAdjust})),n.d(e,"registerAdjust",(function(){return i.registerAdjust}));var r=n(18);n.d(e,"Adjust",(function(){return r.a}));var o=n(128),a=n(129),s=n(130),u=n(131),l=n(51);for(var c in l)["default","getAdjust","registerAdjust","Adjust"].indexOf(c)<0&&function(t){n.d(e,t,(function(){return l[t]}))}(c);Object(i.registerAdjust)("Dodge",o.a),Object(i.registerAdjust)("Jitter",a.a),Object(i.registerAdjust)("Stack",s.a),Object(i.registerAdjust)("Symmetric",u.a)},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.propagationDelegate=void 0;var i=n(89);e.propagationDelegate=function(t,e,n){var r=new i.default(e,n);r.target=t,r.propagationPath.push(t),t.emitDelegation(e,r);for(var o=t.getParent();o;)o.emitDelegation(e,r),r.propagationPath.push(o),o=o.getParent()}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.group=void 0;var i=n(0);e.group=function(t,e,n){if(void 0===n&&(n={}),!e)return[t];var r=i.groupToMap(t,e),o=[];if(1===e.length&&n[e[0]])for(var a=0,s=n[e[0]];aMath.PI/2?Math.PI-c:c,h=h>Math.PI/2?Math.PI-h:h,{xExtra:Math.cos(l/2-c)*(e/2*(1/Math.sin(l/2)))-e/2||0,yExtra:Math.cos(h-l/2)*(e/2*(1/Math.sin(l/2)))-e/2||0}}e.default=function(t){var e=t.attr(),n=e.path,s=e.stroke?e.lineWidth:0,c=function(t,e){for(var n=[],a=[],s=[],u=0;uh&&(h=g)}var y=function(t,e,n){return Math.atan(e/(t*Math.tan(n)))}(n,i,r),v=1/0,m=-1/0,x=[s,u];for(p=2*-Math.PI;p<=2*Math.PI;p+=Math.PI){var b=y+p;sm&&(m=_)}return{x:c,y:v,width:h-c,height:m-v}},length:function(t,e,n,i,r,o,a){},nearestPoint:function(t,e,n,i,o,a,l,c,h){var f=u(c-t,h-e,-o),p=f[0],d=f[1],g=r.default.nearestPoint(0,0,n,i,p,d),y=function(t,e,n,i){return(Math.atan2(i*t,n*e)+2*Math.PI)%(2*Math.PI)}(n,i,g.x,g.y);yl&&(g=s(n,i,l));var v=u(g.x,g.y,o);return{x:v[0]+t,y:v[1]+e}},pointDistance:function(t,e,n,r,o,a,s,u,l){var c=this.nearestPoint(t,e,n,r,u,l);return i.distance(c.x,c.y,u,l)},pointAt:function(t,e,n,i,r,s,u,l){var c=(u-s)*l+s;return{x:o(t,0,n,i,r,c),y:a(0,e,n,i,r,c)}},tangentAngle:function(t,e,n,r,o,a,s,u){var l=(s-a)*u+a,c=function(t,e,n,i,r,o,a,s){return-1*n*Math.cos(r)*Math.sin(s)-i*Math.sin(r)*Math.cos(s)}(0,0,n,r,o,0,0,l),h=function(t,e,n,i,r,o,a,s){return-1*n*Math.sin(r)*Math.sin(s)+i*Math.cos(r)*Math.cos(s)}(0,0,n,r,o,0,0,l);return i.piMod(Math.atan2(h,c))}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(22);function r(t,e){var n=Math.abs(t);return e>0?n:-1*n}e.default={box:function(t,e,n,i){return{x:t-n,y:e-i,width:2*n,height:2*i}},length:function(t,e,n,i){return Math.PI*(3*(n+i)-Math.sqrt((3*n+i)*(n+3*i)))},nearestPoint:function(t,e,n,i,o,a){var s=n,u=i;if(0===s||0===u)return{x:t,y:e};for(var l,c,h=o-t,f=a-e,p=Math.abs(h),d=Math.abs(f),g=s*s,y=u*u,v=Math.PI/4,m=0;m<4;m++){l=s*Math.cos(v),c=u*Math.sin(v);var x=(g-y)*Math.pow(Math.cos(v),3)/s,b=(y-g)*Math.pow(Math.sin(v),3)/u,_=l-x,M=c-b,C=p-x,w=d-b,O=Math.hypot(M,_),S=Math.hypot(w,C);v+=O*Math.asin((_*w-M*C)/(O*S))/Math.sqrt(g+y-l*l-c*c),v=Math.min(Math.PI/2,Math.max(0,v))}return{x:t+r(l,h),y:e+r(c,f)}},pointDistance:function(t,e,n,r,o,a){var s=this.nearestPoint(t,e,n,r,o,a);return i.distance(s.x,s.y,o,a)},pointAt:function(t,e,n,i,r){var o=2*Math.PI*r;return{x:t+n*Math.cos(o),y:e+i*Math.sin(o)}},tangentAngle:function(t,e,n,r,o){var a=2*Math.PI*o,s=Math.atan2(r*Math.cos(a),-n*Math.sin(a));return i.piMod(s)}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(24),r=n(17),o=n(23),a=/[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/gi,s=/[^\s\,]+/gi;e.default=function(t){var e=t||[];return r.default(e)?e:o.default(e)?(e=e.match(a),i.default(e,(function(t,n){if((t=t.match(s))[0].length>1){var r=t[0].charAt(0);t.splice(1,0,t[0].substr(1)),t[0]=r}i.default(t,(function(e,n){isNaN(e)||(t[n]=+e)})),e[n]=t})),e):void 0}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(76);e.default=function(t){var e=t.attr(),n=e.x1,r=e.y1,o=e.x2,a=e.y2,s={minX:Math.min(n,o),maxX:Math.max(n,o),minY:Math.min(r,a),maxY:Math.max(r,a)};return{x:(s=i.mergeArrowBBox(t,s)).minX,y:s.minY,width:s.maxX-s.minX,height:s.maxY-s.minY}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(t){var e=t.attr(),n=e.x,i=e.y,r=e.rx,o=e.ry;return{x:n-r,y:i-o,width:2*r,height:2*o}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(17),r="\t\n\v\f\r   ᠎              \u2028\u2029",o=new RegExp("([a-z])["+r+",]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?["+r+"]*,?["+r+"]*)+)","ig"),a=new RegExp("(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)["+r+"]*,?["+r+"]*","ig");e.default=function(t){if(!t)return null;if(i.default(t))return t;var e={a:7,c:6,o:2,h:1,l:2,m:2,r:4,q:4,s:4,t:2,v:1,u:3,z:0},n=[];return String(t).replace(o,(function(t,i,r){var o=[],s=i.toLowerCase();if(r.replace(a,(function(t,e){e&&o.push(+e)})),"m"===s&&o.length>2&&(n.push([i].concat(o.splice(0,2))),s="l",i="m"===i?"l":"L"),"o"===s&&1===o.length&&n.push([i,o[0]]),"r"===s)n.push([i].concat(o));else for(;o.length>=e[s]&&(n.push([i].concat(o.splice(0,e[s]))),e[s]););return""})),n}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.distanceAtSegment=e.angleAtSegments=e.pointAtSegments=e.lengthOfSegment=void 0;var i=n(13),r=n(22);function o(t){for(var e=0,n=[],i=0;i1||e<0||t.length<2)return null;var n=o(t),r=n.segments,a=n.totalLength;if(0===a)return{x:t[0][0],y:t[0][1]};for(var s=0,u=null,l=0;l=s&&e<=s+p){var d=(e-s)/p;u=i.default.pointAt(h[0],h[1],f[0],f[1],d);break}s+=p}return u},e.angleAtSegments=function(t,e){if(e>1||e<0||t.length<2)return 0;for(var n=o(t),i=n.segments,r=n.totalLength,a=0,s=0,u=0;u=a&&e<=a+f){s=Math.atan2(h[1]-c[1],h[0]-c[0]);break}a+=f}return s},e.distanceAtSegment=function(t,e,n){for(var r=1/0,o=0;oi&&(i=r),r=e[0]})));for(var f=this.scales[c],p=0,d=t;p0&&!r.get(n,[i,"min"])&&e.change({min:0}),a<=0&&!r.get(n,[i,"max"])&&e.change({max:0}))}},e}(a.default);e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(7),o=n(11),a=n(45),s=r.registerShapeFactory("interval",{defaultShapeType:"rect",getDefaultPoints:function(t){return a.getRectPoints(t)}});r.registerShape("interval","rect",{draw:function(t,e){var n=o.getStyle(t,!1,!0),r=this.parsePath(a.getRectPath(t.points));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:r}),name:"interval"})},getMarker:function(t){var e=t.color;return t.isInPolar?{symbol:"circle",style:{r:4.5,fill:e}}:{symbol:"square",style:{r:4,fill:e}}}}),e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=i.__importDefault(n(77));n(114);var o=function(t){function e(e){var n=t.call(this,e)||this;n.type="line";var i=e.sortable,r=void 0===i||i;return n.sortable=r,n}return i.__extends(e,t),e}(r.default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=i.__importDefault(n(28));n(200);var o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="point",e.shapeType="point",e.generatePoints=!0,e}return i.__extends(e,t),e.prototype.getDrawCfg=function(e){var n=t.prototype.getDrawCfg.call(this,e);return i.__assign(i.__assign({},n),{isStack:!!this.getAdjust("stack")})},e}(r.default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),r=n(46),o=n(7),a=n(79),s=n(80),u=o.registerShapeFactory("point",{defaultShapeType:"hollow-circle",getDefaultPoints:function(t){return a.splitPoints(t)}});i.each(s.SHAPES,(function(t){o.registerShape("point","hollow-"+t,{draw:function(e,n){return s.drawPoints(this,e,n,t,!0)},getMarker:function(e){var n=e.color;return{symbol:r.MarkerSymbols[t]||t,style:{r:4.5,stroke:n,fill:null}}}})})),e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=i.__importDefault(n(28));n(202);var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="polygon",e.shapeType="polygon",e.generatePoints=!0,e}return i.__extends(e,t),e.prototype.createShapePointsCfg=function(e){var n,i=t.prototype.createShapePointsCfg.call(this,e),o=i.x,a=i.y;if(!r.isArray(o)||!r.isArray(a)){var s=this.getXScale(),u=this.getYScale(),l=.5/s.values.length,c=.5/u.values.length;s.isCategory&&u.isCategory?(o=[o-l,o-l,o+l,o+l],a=[a-c,a+c,a+c,a-c]):r.isArray(o)?(o=[(n=o)[0],n[0],n[1],n[1]],a=[a-c/2,a+c/2,a+c/2,a-c/2]):r.isArray(a)&&(a=[(n=a)[0],n[1],n[1],n[0]],o=[o-l/2,o-l/2,o+l/2,o+l/2]),i.x=o,i.y=a}return i},e}(o.default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(7),a=n(11);var s=o.registerShapeFactory("polygon",{defaultShapeType:"polygon",getDefaultPoints:function(t){var e=[];return r.each(t.x,(function(n,i){var r=t.y[i];e.push({x:n,y:r})})),e}});o.registerShape("polygon","polygon",{draw:function(t,e){if(!r.isEmpty(t.points)){var n=a.getStyle(t,!0,!0),o=this.parsePath(function(t){for(var e=t[0],n=1,i=[["M",e.x,e.y]];n2?"weight":"normal";if(t.isInCircle){var c={x:0,y:1};return"normal"===l?n=function(t,e,n){var i=s.getQPath(e,n),r=[["M",t.x,t.y]];return r.push(i),r}(u[0],u[1],c):(o.fill=o.stroke,n=function(t,e){var n=s.getQPath(t[1],e),i=s.getQPath(t[3],e),r=[["M",t[0].x,t[0].y]];return r.push(i),r.push(["L",t[3].x,t[3].y]),r.push(["L",t[2].x,t[2].y]),r.push(n),r.push(["L",t[1].x,t[1].y]),r.push(["L",t[0].x,t[0].y]),r.push(["Z"]),r}(u,c)),n=this.parsePath(n),e.addShape("path",{attrs:i.__assign(i.__assign({},o),{path:n})})}if("normal"===l)return u=this.parsePoints(u),n=r.getArcPath((u[1].x+u[0].x)/2,u[0].y,Math.abs(u[1].x-u[0].x)/2,Math.PI,2*Math.PI),e.addShape("path",{attrs:i.__assign(i.__assign({},o),{path:n})});var h=s.getCPath(u[1],u[3]),f=s.getCPath(u[2],u[0]);return n=[["M",u[0].x,u[0].y],["L",u[1].x,u[1].y],h,["L",u[3].x,u[3].y],["L",u[2].x,u[2].y],f,["Z"]],n=this.parsePath(n),o.fill=o.stroke,e.addShape("path",{attrs:i.__assign(i.__assign({},o),{path:n})})},getMarker:function(t){return{symbol:"circle",style:{r:4.5,fill:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(7),o=n(11),a=n(117);r.registerShape("edge","smooth",{draw:function(t,e){var n=o.getStyle(t,!0,!1,"lineWidth"),r=t.points,s=this.parsePath(function(t,e){var n=a.getCPath(t,e),i=[["M",t.x,t.y]];return i.push(n),i}(r[0],r[1]));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:s})})},getMarker:function(t){return{symbol:"circle",style:{r:4.5,fill:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(7),a=n(11);o.registerShape("edge","vhv",{draw:function(t,e){var n=a.getStyle(t,!0,!1,"lineWidth"),o=t.points,s=this.parsePath(function(t,e){var n=[];n.push({x:t.x,y:t.y*(1-1/3)+e.y*(1/3)}),n.push({x:e.x,y:t.y*(1-1/3)+e.y*(1/3)}),n.push(e);var i=[["M",t.x,t.y]];return r.each(n,(function(t){i.push(["L",t.x,t.y])})),i}(o[0],o[1]));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:s})})},getMarker:function(t){return{symbol:"circle",style:{r:4.5,fill:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(7),o=n(11),a=n(45);r.registerShape("interval","funnel",{getPoints:function(t){return t.size=2*t.size,a.getRectPoints(t)},draw:function(t,e){var n=o.getStyle(t,!1,!0),r=this.parsePath(a.getFunnelPath(t.points,t.nextPoints,!1));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:r}),name:"interval"})},getMarker:function(t){return{symbol:"square",style:{r:4,fill:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(7),o=n(11),a=n(45);r.registerShape("interval","hollow-rect",{draw:function(t,e){var n=o.getStyle(t,!0,!1),r=this.parsePath(a.getRectPath(t.points));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:r}),name:"interval"})},getMarker:function(t){var e=t.color;return t.isInPolar?{symbol:"circle",style:{r:4.5,stroke:e,fill:null}}:{symbol:"square",style:{r:4,stroke:e,fill:null}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(7),a=n(11),s=n(45);o.registerShape("interval","line",{getPoints:function(t){return n=(e=t).x,i=e.y,o=e.y0,r.isArray(i)?i.map((function(t,e){return{x:r.isArray(n)?n[e]:n,y:t}})):[{x:n,y:o},{x:n,y:i}];var e,n,i,o},draw:function(t,e){var n=a.getStyle(t,!0,!1,"lineWidth"),r=this.parsePath(s.getRectPath(t.points,!1));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:r}),name:"interval"})},getMarker:function(t){return{symbol:function(t,e,n){return[["M",t,e-n],["L",t,e+n]]},style:{r:5,stroke:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(7),o=n(11),a=n(45);r.registerShape("interval","pyramid",{getPoints:function(t){return t.size=2*t.size,a.getRectPoints(t,!0)},draw:function(t,e){var n=o.getStyle(t,!1,!0),r=this.parsePath(a.getFunnelPath(t.points,t.nextPoints,!0));return e.addShape("path",{attrs:i.__assign(i.__assign({},n),{path:r}),name:"interval"})},getMarker:function(t){return{symbol:"square",style:{r:4,fill:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(7),a=n(11);o.registerShape("interval","tick",{getPoints:function(t){return function(t){var e,n,i=t.x,o=t.y,a=t.y0,s=t.size;r.isArray(o)?(e=o[0],n=o[1]):(e=a,n=o);var u=i+s/2,l=i-s/2;return[{x:i,y:e},{x:i,y:n},{x:l,y:e},{x:u,y:e},{x:l,y:n},{x:u,y:n}]}(t)},draw:function(t,e){var n,r=a.getStyle(t,!0,!1),o=this.parsePath([["M",(n=t.points)[0].x,n[0].y],["L",n[1].x,n[1].y],["M",n[2].x,n[2].y],["L",n[3].x,n[3].y],["M",n[4].x,n[4].y],["L",n[5].x,n[5].y]]);return e.addShape("path",{attrs:i.__assign(i.__assign({},r),{path:o}),name:"interval"})},getMarker:function(t){return{symbol:function(t,e,n){return[["M",t-n/2,e-n],["L",t+n/2,e-n],["M",t,e-n],["L",t,e+n],["M",t-n/2,e+n],["L",t+n/2,e+n]]},style:{r:5,stroke:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(7),a=n(78),s=n(11),u=n(115);function l(t,e){var n=a.getPathPoints(t.points,t.connectNulls,t.showSinglePoint),o=[];return r.each(n,(function(t){var n=function(t,e){var n=[];return r.each(t,(function(i,r){var o=t[r+1];if(n.push(i),o){var a=function(t,e,n){var i,r=t.x,o=t.y,a=e.x,s=e.y;switch(n){case"hv":i=[{x:a,y:o}];break;case"vh":i=[{x:r,y:s}];break;case"hvh":var u=(a+r)/2;i=[{x:u,y:o},{x:u,y:s}];break;case"vhv":var l=(o+s)/2;i=[{x:r,y:l},{x:a,y:l}]}return i}(i,o,e);n=n.concat(a)}})),n}(t,e);o=o.concat(function(t){return t.map((function(t,e){return 0===e?["M",t.x,t.y]:["L",t.x,t.y]}))}(n))})),i.__assign(i.__assign({},s.getStyle(t,!0,!1,"lineWidth")),{path:o})}r.each(["hv","vh","hvh","vhv"],(function(t){o.registerShape("line",t,{draw:function(e,n){var i=l(e,t);return n.addShape({type:"path",attrs:i,name:"line"})},getMarker:function(e){return u.getLineMarker(e,t)}})}))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(0),r=n(46),o=n(7),a=n(80);i.each(a.HOLLOW_SHAPES,(function(t){o.registerShape("point",t,{draw:function(e,n){return a.drawPoints(this,e,n,t,!0)},getMarker:function(e){var n=e.color;return{symbol:r.MarkerSymbols[t],style:{r:4.5,stroke:n,fill:null}}}})}))},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(7),r=n(11);i.registerShape("point","image",{draw:function(t,e){var n=r.getStyle(t,!1,!1,"r").r,i=this.parsePoints(t.points),o=i[0];if(t.isStack)o=i[1];else if(i.length>1){for(var a=e.addGroup(),s=0,u=i;s1?e[1]:n;return{min:n,max:i,min1:o,max1:e.length>3?e[3]:i,median:e.length>2?e[2]:o}}function u(t,e,n){var i,o=n/2;if(r.isArray(e)){var a=s(e),u=a.min,l=a.max,c=a.median,h=a.min1,f=t-o,p=t+o;i=[[f,l],[p,l],[t,l],[t,d=a.max1],[f,h],[f,d],[p,d],[p,h],[t,h],[t,u],[f,u],[p,u],[f,c],[p,c]]}else{e=r.isNil(e)?.5:e;var d,g=s(t),y=(u=g.min,l=g.max,c=g.median,e-o),v=e+o;i=[[u,y],[u,v],[u,e],[h=g.min1,e],[h,y],[h,v],[d=g.max1,v],[d,y],[d,e],[l,e],[l,y],[l,v],[c,y],[c,v]]}return i.map((function(t){return{x:t[0],y:t[1]}}))}o.registerShape("schema","box",{getPoints:function(t){return u(t.x,t.y,t.size)},draw:function(t,e){var n,r=a.getStyle(t,!0,!1),o=this.parsePath([["M",(n=t.points)[0].x,n[0].y],["L",n[1].x,n[1].y],["M",n[2].x,n[2].y],["L",n[3].x,n[3].y],["M",n[4].x,n[4].y],["L",n[5].x,n[5].y],["L",n[6].x,n[6].y],["L",n[7].x,n[7].y],["L",n[4].x,n[4].y],["Z"],["M",n[8].x,n[8].y],["L",n[9].x,n[9].y],["M",n[10].x,n[10].y],["L",n[11].x,n[11].y],["M",n[12].x,n[12].y],["L",n[13].x,n[13].y]]);return e.addShape("path",{attrs:i.__assign(i.__assign({},r),{path:o,name:"schema"})})},getMarker:function(t){return{symbol:function(t,e,n){var i=u(t,[e-6,e-3,e,e+3,e+6],n);return[["M",i[0].x+1,i[0].y],["L",i[1].x-1,i[1].y],["M",i[2].x,i[2].y],["L",i[3].x,i[3].y],["M",i[4].x,i[4].y],["L",i[5].x,i[5].y],["L",i[6].x,i[6].y],["L",i[7].x,i[7].y],["L",i[4].x,i[4].y],["Z"],["M",i[8].x,i[8].y],["L",i[9].x,i[9].y],["M",i[10].x+1,i[10].y],["L",i[11].x-1,i[11].y],["M",i[12].x,i[12].y],["L",i[13].x,i[13].y]]},style:{r:6,lineWidth:1,stroke:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(27),a=n(7),s=n(11);function u(t,e,n){var i,a,s=(i=e,a=(r.isArray(i)?i:[i]).sort((function(t,e){return e-t})),o.padEnd(a,4,a[a.length-1]));return[{x:t,y:s[0]},{x:t,y:s[1]},{x:t-n/2,y:s[2]},{x:t-n/2,y:s[1]},{x:t+n/2,y:s[1]},{x:t+n/2,y:s[2]},{x:t,y:s[2]},{x:t,y:s[3]}]}a.registerShape("schema","candle",{getPoints:function(t){return u(t.x,t.y,t.size)},draw:function(t,e){var n,r=s.getStyle(t,!0,!0),o=this.parsePath([["M",(n=t.points)[0].x,n[0].y],["L",n[1].x,n[1].y],["M",n[2].x,n[2].y],["L",n[3].x,n[3].y],["L",n[4].x,n[4].y],["L",n[5].x,n[5].y],["Z"],["M",n[6].x,n[6].y],["L",n[7].x,n[7].y]]);return e.addShape("path",{attrs:i.__assign(i.__assign({},r),{path:o,name:"schema"})})},getMarker:function(t){var e=t.color;return{symbol:function(t,e,n){var i=u(t,[e+7.5,e+3,e-3,e-7.5],n);return[["M",i[0].x,i[0].y],["L",i[1].x,i[1].y],["M",i[2].x,i[2].y],["L",i[3].x,i[3].y],["L",i[4].x,i[4].y],["L",i[5].x,i[5].y],["Z"],["M",i[6].x,i[6].y],["L",i[7].x,i[7].y]]},style:{lineWidth:1,stroke:e,fill:e,r:6}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(7),a=n(11);function s(t,e){var n=Math.abs(t[0].x-t[2].x),i=Math.abs(t[0].y-t[2].y),o=Math.min(n,i);return e&&(o=r.clamp(e,0,Math.min(n,i))),o/=2,{x:(t[0].x+t[2].x)/2-o,y:(t[0].y+t[2].y)/2-o,width:2*o,height:2*o}}o.registerShape("polygon","square",{draw:function(t,e){if(!r.isEmpty(t.points)){var n=a.getStyle(t,!0,!0),o=this.parsePoints(t.points);return e.addShape("rect",{attrs:i.__assign(i.__assign({},n),s(o,t.size)),name:"polygon"})}},getMarker:function(t){return{symbol:"square",style:{r:4,fill:t.color}}}})},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.setLabelPosition=function(t,e,n,i){var o=this.getCoordinate(),a=o.isTransposed,s=e.points,u=o.convert(s[0]),l=o.convert(s[2]),c=a?-1:1,h=(u.x-l.x)/2*c,f=(u.y-l.y)/2*c;switch(i){case"right":a||(t.x-=h,t.y+=f),t.textAlign=r.get(t,"textAlign","left");break;case"left":a?t.x-=2*h:(t.x+=h,t.y+=f),t.textAlign=r.get(t,"textAlign","right");break;case"bottom":a?(t.x-=h,t.y-=f):t.y+=2*f,t.textAlign=r.get(t,"textAlign","center"),t.textBaseline=r.get(t,"textBaseline","top");break;case"middle":a?t.x-=h:t.y+=f,t.textAlign=r.get(t,"textAlign","center");break;case"top":a&&(t.x-=h,t.y+=f),t.textAlign=r.get(t,"textAlign","center"),t.textBaseline=r.get(t,"textBaseline","bottom")}},e}(i.__importDefault(n(52)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(20),a=n(16),s=function(t){function e(e){var n=t.call(this,e)||this;return n.defaultLayout="distribute",n}return i.__extends(e,t),e.prototype.getDefaultLabelCfg=function(){return r.get(this.geometry.theme,"pieLabels",{})},e.prototype.getDefaultOffset=function(t){return t||0},e.prototype.getLabelRotate=function(t,e,n){var i;return e<0&&((i=t)>Math.PI/2&&(i-=Math.PI),i<-Math.PI/2&&(i+=Math.PI)),i},e.prototype.getLabelAlign=function(t){var e,n=this.getCoordinate().getCenter();return e=t.angle<=Math.PI/2&&t.x>=n.x?"left":"right",this.getDefaultOffset(t.offset)<=0&&(e="right"===e?"left":"right"),e},e.prototype.getArcPoint=function(t){return t},e.prototype.getPointAngle=function(t){var e,n=this.getCoordinate(),i={x:r.isArray(t.x)?t.x[0]:t.x,y:t.y[0]},a={x:r.isArray(t.x)?t.x[1]:t.x,y:t.y[1]},s=o.getAngleByPoint(n,i);if(t.points&&t.points[0].y===t.points[1].y)e=s;else{var u=o.getAngleByPoint(n,a);s>=u&&(u+=2*Math.PI),e=s+(u-s)/2}return e},e.prototype.getCirclePoint=function(t,e,n){var r=this.getCoordinate(),o=r.getCenter(),s=r.getRadius()+e;return i.__assign(i.__assign({},a.polarToCartesian(o.x,o.y,s,t)),{angle:t,r:s})},e}(i.__importDefault(n(118)).default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.distribute=void 0;var i=n(0),r=n(16);e.distribute=function(t,e,n,o){var a=t[0]?t[0].offset:0,s=e[0].get("coordinate"),u=s.getRadius(),l=s.getCenter();if(a>0){var c=2*(u+a)+28,h={start:s.start,end:s.end},f=[[],[]];t.forEach((function(t){t&&("right"===t.textAlign?f[0].push(t):f[1].push(t))})),f.forEach((function(t,n){var r=c/14;t.length>r&&(t.sort((function(t,e){return e["..percent"]-t["..percent"]})),t.splice(r,t.length-r)),t.sort((function(t,e){return t.y-e.y})),function(t,e,n,r,o,a){var s,u=!0,l=r.start,c=r.end,h=Math.min(l.y,c.y),f=Math.abs(l.y-c.y),p=0,d=Number.MIN_VALUE,g=e.map((function(t){return t.y>p&&(p=t.y),t.yf&&(f=p-h);u;)for(g.forEach((function(t){var e=(Math.min.apply(d,t.targets)+Math.max.apply(d,t.targets))/2;t.pos=Math.min(Math.max(d,e-t.size/2),f-t.size)})),u=!1,s=g.length;s--;)if(s>0){var y=g[s-1],v=g[s];y.pos+y.size>v.pos&&(y.size+=v.size,y.targets=y.targets.concat(v.targets),y.pos+y.size>f&&(y.pos=f-y.size),g.splice(s,1),u=!0)}s=0,g.forEach((function(t){var i=h+n/2;t.targets.forEach((function(){e[s].y=t.pos+i,i+=n,s++}))}));for(var m={},x=0,b=t;x0){var c=i.get(t[0],"labelHeight",14),h=u+a,f=2*h+2*c,p={start:s.start,end:s.end},d=[[],[]];t.forEach((function(t){t&&(t.xi&&(t.sort((function(t,e){return e["data.percent"]-t["data.percent"]})),t.splice(i,t.length-i+1).forEach((function(t){var n=e.findIndex((function(e){return e.get("id")===t.id}));e[n]&&(e[n].remove(!0),e.splice(n,1))})));!function(t,e,n,i,r,o,a){e.sort((function(t,e){return t.y-e.y}));var s,u=i.start,l=i.end,c=Math.min(u.y,l.y),h=Math.max(u.y,l.y),f=e.map((function(t){return{content:t.content,size:n,pos:t.y,targets:[t.y]}})),p=Math.max.apply(Math,f.map((function(t){return t.pos}))),d=Math.min.apply(Math,f.map((function(t){return t.pos})));if(a){for(var g=Math.min(d,h-(f.length-1)*n),y=Math.max(g+f.length*n,p+n),v=!0;v;)for(v=!1,s=f.length;s--;)if(s>0){var m=f[s-1],x=f[s];m.pos+m.size>x.pos&&(x.pos+s*n0){m=f[s-1],x=f[s];m.pos+m.size>x.pos&&(m.pos-g>s*n?m.pos-=m.size:(m.size+=x.size,m.targets=m.targets.concat(x.targets),f.splice(s,1)),v=!0)}s=0,f.forEach((function(t){var i=t.pos;t.targets.forEach((function(){e[s].y=i,i+=n,s++}))}));for(var b={},_=0,M=t;_0?1:-1),s=t.y+i.get(t,"offsetY",0)*(Math.sin(e)>0?1:-1),c={x:o-4*Math.cos(e),y:s-4*Math.sin(e)},h=t.labelLine.smooth,f=[],p=c.x-l.x,d=c.y-l.y,g=Math.atan(d/p);if(p<0&&(g+=Math.PI),!1===h){i.isObject(t.labelLine)||(t.labelLine={});var y=0;(e<0&&e>-Math.PI/2||e>1.5*Math.PI)&&c.y>n.y&&(y=1),e>=0&&en.y&&(y=1),e>=Math.PI/2&&ec.y&&(y=1),(e<-Math.PI/2||e>=Math.PI&&e<1.5*Math.PI)&&n.y>c.y&&(y=1);var v=a/2>4?4:Math.max(a/2-1,0),m=r.polarToCartesian(l.x,l.y,u+v,e),x=r.polarToCartesian(l.x,l.y,u+a/2,g);f.push("M "+n.x+" "+n.y),f.push("L "+m.x+" "+m.y),f.push("A "+l.x+" "+l.y+" 0 0 "+y+" "+x.x+" "+x.y),f.push("L "+c.x+" "+c.y)}else{m=r.polarToCartesian(l.x,l.y,u+(a/2>4?4:Math.max(a/2-1,0)),e);var b=n.xMath.pow(Math.E,-16)&&f.push.apply(f,["C",c.x+4*b,c.y,2*m.x-n.x,2*m.y-n.y,n.x,n.y]),f.push("L "+n.x+" "+n.y)}t.labelLine.path=f.join(" ")}}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.limitInCanvas=void 0;var i=n(0),r=n(73);e.limitInCanvas=function(t,e,n,o){i.each(e,(function(t){var e=o.minX,n=o.minY,i=o.maxX,a=o.maxY,s=t.getCanvasBBox(),u=s.minX,l=s.minY,c=s.maxX,h=s.maxY,f=s.x,p=s.y,d=s.width,g=s.height,y=f,v=p;(ui?y=i-d:c>i&&(y-=c-i),l>a?v=a-g:h>a&&(v-=h-a),y===f&&v===p||r.translate(t,y-f,v-p)}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.limitInShape=void 0;var i=n(0);e.limitInShape=function(t,e,n,r){i.each(e,(function(t,e){var i=t.getCanvasBBox(),r=n[e].getBBox();(i.minXr.maxX||i.maxY>r.maxY)&&t.remove(!0)}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.overlap=e.fixedOverlap=void 0;var i=n(0),r=function(){function t(t){void 0===t&&(t={}),this.bitmap={};var e=t.xGap,n=void 0===e?1:e,i=t.yGap,r=void 0===i?8:i;this.xGap=n,this.yGap=r}return t.prototype.hasGap=function(t){for(var e=!0,n=this.bitmap,i=Math.round(t.minX),r=Math.round(t.maxX),o=Math.round(t.minY),a=Math.round(t.maxY),s=i;s<=r;s+=1)if(n[s]){if(s===i||s===r){for(var u=o;u<=a;u++)if(n[s][u]){e=!1;break}}else if(n[s][o]||n[s][a]){e=!1;break}}else n[s]={};return e},t.prototype.fillGap=function(t){for(var e=this.bitmap,n=Math.round(t.minX),i=Math.round(t.maxX),r=Math.round(t.minY),o=Math.round(t.maxY),a=n;a<=i;a+=1)e[a]||(e[a]={});for(a=n;a<=i;a+=this.xGap){for(var s=r;s<=o;s+=this.yGap)e[a][s]=!0;e[a][o]=!0}if(1!==this.yGap)for(a=r;a<=o;a+=1)e[n][a]=!0,e[i][a]=!0;if(1!==this.xGap)for(a=n;a<=i;a+=1)e[a][r]=!0,e[a][o]=!0},t.prototype.destroy=function(){this.bitmap={}},t}();function o(t,e,n,i){var r=t.getCanvasBBox(),o=r.width,a=r.height,s={x:e,y:n,textAlign:"center"};switch(i){case 0:s.y-=a+1,s.x+=1,s.textAlign="left";break;case 1:s.y-=a+1,s.x-=1,s.textAlign="right";break;case 2:s.y+=a+1,s.x-=1,s.textAlign="right";break;case 3:s.y+=a+1,s.x+=1,s.textAlign="left";break;case 5:s.y-=2*a+2;break;case 6:s.y+=2*a+2;break;case 7:s.x+=o+1,s.textAlign="left";break;case 8:s.x-=o+1,s.textAlign="right"}return t.attr(s),t.getCanvasBBox()}e.fixedOverlap=function(t,e,n,o){var a=new r;i.each(e,(function(t){(function(t,e,n){void 0===n&&(n=100);var i,r=t.attr(),o=r.x,a=r.y,s=t.getCanvasBBox(),u=Math.sqrt(s.width*s.width+s.height*s.height),l=1,c=0,h=0;if(e.hasGap(s))return e.fillGap(s),!0;for(var f,p,d=!1,g=0,y={};Math.min(Math.abs(c),Math.abs(h))u.x?i.x:u.x,s=u.y+h/2):"xy"===o&&(n.isPolar?(a=n.getCenter().x,s=n.getCenter().y):(a=(u.x+l.x)/2,s=(u.y+l.y)/2));var f=r(t,[a,s],o);t.animate({matrix:f},e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.pathIn=void 0,e.pathIn=function(t,e,n){var i=t.getTotalLength();t.attr("lineDash",[i]),t.animate((function(t){return{lineDashOffset:(1-t)*i}}),e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.positionUpdate=void 0,e.positionUpdate=function(t,e,n){var i=n.toAttrs,r=i.x,o=i.y;delete i.x,delete i.y,t.attr(i),t.animate({x:r,y:o},e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.scaleInY=e.scaleInX=void 0;var i=n(2);e.scaleInX=function(t,e,n){var r=t.getBBox(),o=t.get("origin").mappingData.points,a=o[0].y-o[1].y>0?r.maxX:r.minX,s=(r.minY+r.maxY)/2;t.applyToMatrix([a,s,1]);var u=i.ext.transform(t.getMatrix(),[["t",-a,-s],["s",.01,1],["t",a,s]]);t.setMatrix(u),t.animate({matrix:i.ext.transform(t.getMatrix(),[["t",-a,-s],["s",100,1],["t",a,s]])},e)},e.scaleInY=function(t,e,n){var r=t.getBBox(),o=t.get("origin").mappingData,a=(r.minX+r.maxX)/2,s=o.points,u=s[0].y-s[1].y<=0?r.maxY:r.minY;t.applyToMatrix([a,u,1]);var l=i.ext.transform(t.getMatrix(),[["t",-a,-u],["s",1,.01],["t",a,u]]);t.setMatrix(l),t.animate({matrix:i.ext.transform(t.getMatrix(),[["t",-a,-u],["s",1,100],["t",a,u]])},e)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.sectorPathUpdate=void 0;var i=n(1),r=i.__importDefault(n(237)),o=n(0),a=n(16);function s(t,e){var n,i=r.default(t,e),a=i.startAngle,s=i.endAngle;return!o.isNumberEqual(a,.5*-Math.PI)&&a<.5*-Math.PI&&(a+=2*Math.PI),!o.isNumberEqual(s,.5*-Math.PI)&&s<.5*-Math.PI&&(s+=2*Math.PI),0===e[5]&&(a=(n=[s,a])[0],s=n[1]),o.isNumberEqual(a,1.5*Math.PI)&&(a=-.5*Math.PI),o.isNumberEqual(s,-.5*Math.PI)&&(s=1.5*Math.PI),{startAngle:a,endAngle:s}}function u(t){var e;return"M"===t[0]||"L"===t[0]?e=[t[1],t[2]]:"a"!==t[0]&&"A"!==t[0]||(e=[t[t.length-2],t[t.length-1]]),e}function l(t){var e,n,i,r=t.filter((function(t){return"A"===t[0]||"a"===t[0]})),a=r[0],l=r.length>1?r[1]:r[0],c=t.indexOf(a),h=t.indexOf(l),f=u(t[c-1]),p=u(t[h-1]),d=s(f,a),g=d.startAngle,y=d.endAngle,v=s(p,l),m=v.startAngle,x=v.endAngle;o.isNumberEqual(g,m)&&o.isNumberEqual(y,x)?(n=g,i=y):(n=Math.min(g,m),i=Math.max(y,x));var b=a[1],_=r[r.length-1][1];return b<_?(b=(e=[_,b])[0],_=e[1]):b===_&&(_=0),{startAngle:n,endAngle:i,radius:b,innerRadius:_}}e.sectorPathUpdate=function(t,e,n){var r=n.toAttrs,s=n.coordinate,u=r.path,c=u.map((function(t){return t[0]})),h=l(u),f=h.startAngle,p=h.endAngle,d=h.radius,g=h.innerRadius,y=l(t.attr("path")),v=y.startAngle,m=y.endAngle,x=s.getCenter(),b=f-v,_=p-m;t.animate((function(t){var e=v+t*b,n=m+t*_;return i.__assign(i.__assign({},r),{path:o.isEqual(c,["M","A","A","Z"])?a.getArcPath(x.x,x.y,d,e,n):a.getSectorPath(x.x,x.y,d,e,n,g)})}),i.__assign(i.__assign({},e),{callback:function(){t.attr("path",u)}}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(238);function r(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1])}function o(t,e){return r(t)*r(e)?(t[0]*e[0]+t[1]*e[1])/(r(t)*r(e)):1}function a(t,e){return(t[0]*e[1]1&&(n*=Math.sqrt(y),r*=Math.sqrt(y));var v=n*n*(g*g)+r*r*(d*d),m=v?Math.sqrt((n*n*(r*r)-v)/v):1;u===l&&(m*=-1),isNaN(m)&&(m=0);var x=r?m*n*g/r:0,b=n?m*-r*d/n:0,_=(c+f)/2+Math.cos(s)*x-Math.sin(s)*b,M=(h+p)/2+Math.sin(s)*x+Math.cos(s)*b,C=[(d-x)/n,(g-b)/r],w=[(-1*d-x)/n,(-1*g-b)/r],O=a([1,0],C),S=a(C,w);return o(C,w)<=-1&&(S=Math.PI),o(C,w)>=1&&(S=0),0===l&&S>0&&(S-=2*Math.PI),1===l&&S<0&&(S+=2*Math.PI),{cx:_,cy:M,rx:i.isSamePoint(t,[f,p])?0:n,ry:i.isSamePoint(t,[f,p])?0:r,startAngle:O,endAngle:O+S,xRotation:s,arcFlag:u,sweepFlag:l}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.isSamePoint=e.mergeRegion=e.intersectRect=e.inBox=e.distance=e.getPixelRatio=void 0,e.getPixelRatio=function(){return window?window.devicePixelRatio:1},e.distance=function(t,e,n,i){var r=t-n,o=e-i;return Math.sqrt(r*r+o*o)},e.inBox=function(t,e,n,i,r,o){return r>=t&&r<=t+n&&o>=e&&o<=e+i},e.intersectRect=function(t,e){return!(e.minX>t.maxX||e.maxXt.maxY||e.maxY=0;r--)for(var o=0,a=this.getFacetsByLevel(t,r);o=n){var r=i.parsePosition([t[u],t[s.field]]);r&&f.push(r)}if(t[u]===h)return!1})),f},e.prototype.getNormalizedValue=function(t,e){var n,i;switch(t){case"start":n=0;break;case"end":n=1;break;case"median":i=e.isCategory?(e.values.length-1)/2:(e.min+e.max)/2,n=e.scale(i);break;case"min":case"max":i=e.isCategory?"min"===t?0:e.values.length-1:e[t],n=e.scale(i);break;default:n=e.scale(t)}return n},e.prototype.parsePercentPosition=function(t){var e=parseFloat(t[0])/100,n=parseFloat(t[1])/100,i=this.view.getCoordinate(),r=i.start,o=i.end,a=Math.min(r.x,o.x),s=Math.min(r.y,o.y);return{x:i.getWidth()*e+a,y:i.getHeight()*n+s}},e.prototype.getCoordinateBBox=function(){var t=this.view.getCoordinate(),e=t.start,n=t.end,i=t.getWidth(),r=t.getHeight(),o={x:Math.min(e.x,n.x),y:Math.min(e.y,n.y)};return{x:o.x,y:o.y,minX:o.x,minY:o.y,maxX:o.x+i,maxY:o.y+r,width:i,height:r}},e.prototype.getAnnotationCfg=function(t,e,n){var o=this.view.getCoordinate(),s={};if(r.isNil(e))return null;if("arc"===t){var l=e,c=l.start,h=l.end,f=this.parsePosition(c),p=this.parsePosition(h),d=u.getAngleByPoint(o,f),g=u.getAngleByPoint(o,p);d>g&&(g=2*Math.PI+g),s={center:o.getCenter(),radius:u.getDistanceToCenter(o,f),startAngle:d,endAngle:g}}else if("image"===t){var y=e;c=y.start,h=y.end;s={start:this.parsePosition(c),end:this.parsePosition(h),src:e.src}}else if("line"===t){var v=e;c=v.start,h=v.end;s={start:this.parsePosition(c),end:this.parsePosition(h),text:r.get(e,"text",null)}}else if("region"===t){var m=e;c=m.start,h=m.end;s={start:this.parsePosition(c),end:this.parsePosition(h)}}else if("text"===t){var x=this.view.getData(),b=e,_=b.position,M=b.content,C=i.__rest(b,["position","content"]),w=M;r.isFunction(M)&&(w=M(x)),s=i.__assign(i.__assign(i.__assign({},this.parsePosition(_)),C),{content:w})}else if("dataMarker"===t){var O=e,S=(_=O.position,O.point),A=O.line,P=O.text,I=O.autoAdjust,T=O.direction;s=i.__assign(i.__assign({},this.parsePosition(_)),{coordinateBBox:this.getCoordinateBBox(),point:S,line:A,text:P,autoAdjust:I,direction:T})}else if("dataRegion"===t){var E=e,j=(c=E.start,h=E.end,E.region),L=(P=E.text,E.lineLength);s={points:this.getRegionPoints(c,h),region:j,text:P,lineLength:L}}else if("regionFilter"===t){var k=e,B=(c=k.start,h=k.end,k.apply),D=k.color,F=this.view.geometries,R=[],N=function(t){t&&(t.isGroup()?t.getChildren().forEach((function(t){return N(t)})):R.push(t))};r.each(F,(function(t){B?r.contains(B,t.type)&&r.each(t.elements,(function(t){N(t.shape)})):r.each(t.elements,(function(t){N(t.shape)}))})),s={color:D,shapes:R,start:this.parsePosition(c),end:this.parsePosition(h)}}var G=r.deepMix({},n,i.__assign(i.__assign({},s),{top:e.top,style:e.style,offsetX:e.offsetX,offsetY:e.offsetY}));return G.container=this.getComponentContainer(G),G.animate=this.view.getOptions().animate&&G.animate&&r.get(e,"animate",G.animate),G.animateOption=r.deepMix({},a.DEFAULT_ANIMATE_CFG,G.animateOption,e.animateOption),G},e.prototype.isTop=function(t){return r.get(t,"top",!0)},e.prototype.getComponentContainer=function(t){return this.isTop(t)?this.foregroundContainer:this.backgroundContainer},e.prototype.getAnnotationTheme=function(t){return r.get(this.view.getTheme(),["components","annotation",t],{})},e}(n(37).Controller);e.default=c},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(6),a=n(26),s=n(32),u=n(65),l=n(65),c=n(249),h=n(27),f=n(37),p=["container"],d=i.__assign(i.__assign({},s.DEFAULT_ANIMATE_CFG),{appear:null}),g=function(t){function e(e){var n=t.call(this,e)||this;return n.cache=new Map,n.gridContainer=n.view.getLayer(o.LAYER.BG).addGroup(),n.axisContainer=n.view.getLayer(o.LAYER.BG).addGroup(),n}return i.__extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"axis"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.render=function(){this.update()},e.prototype.layout=function(){var t=this,e=this.view.getCoordinate();r.each(this.getComponents(),(function(n){var i,r=n.component,a=n.direction,s=n.type,l=n.extra,h=l.dim,f=l.scale,p=l.alignTick;if(s===o.COMPONENT_TYPE.AXIS)e.isPolar?"x"===h?i=e.isTransposed?u.getAxisRegion(e,a):u.getCircleAxisCenterRadius(e):"y"===h&&(i=e.isTransposed?u.getCircleAxisCenterRadius(e):u.getAxisRegion(e,a)):i=u.getAxisRegion(e,a);else if(s===o.COMPONENT_TYPE.GRID)if(e.isPolar){i={items:e.isTransposed?"x"===h?c.getCircleGridItems(e,t.view.getYScales()[0],f,p,h):c.getLineGridItems(e,f,h,p):"x"===h?c.getLineGridItems(e,f,h,p):c.getCircleGridItems(e,t.view.getXScale(),f,p,h),center:t.view.getCoordinate().getCenter()}}else i={items:c.getLineGridItems(e,f,h,p)};r.update(i)}))},e.prototype.update=function(){this.option=this.view.getOptions().axes;var t=new Map;this.updateXAxes(t),this.updateYAxes(t);var e=new Map;this.cache.forEach((function(n,i){t.has(i)?e.set(i,n):n.component.destroy()})),this.cache=e},e.prototype.clear=function(){t.prototype.clear.call(this),this.cache.clear(),this.gridContainer.clear(),this.axisContainer.clear()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.gridContainer.remove(!0),this.axisContainer.remove(!0)},e.prototype.getComponents=function(){var t=[];return this.cache.forEach((function(e){t.push(e)})),t},e.prototype.updateXAxes=function(t){var e=this.view.getXScale();if(e&&!e.isIdentity){var n=l.getAxisOption(this.option,e.field);if(!1!==n){var i=u.getAxisDirection(n,o.DIRECTION.BOTTOM),a=o.LAYER.BG,s=this.view.getCoordinate(),c=this.getId("axis",e.field),f=this.getId("grid",e.field);if(s.isRect){if(g=this.cache.get(c)){var d=this.getLineAxisCfg(e,n,i);h.omit(d,p),g.component.update(d),t.set(c,g)}else g=this.createLineAxis(e,n,a,i,"x"),this.cache.set(c,g),t.set(c,g);if(y=this.cache.get(f)){d=this.getLineGridCfg(e,n,i,"x");h.omit(d,p),y.component.update(d),t.set(f,y)}else(y=this.createLineGrid(e,n,a,i,"x"))&&(this.cache.set(f,y),t.set(f,y))}else if(s.isPolar){var g,y;if(g=this.cache.get(c)){d=s.isTransposed?this.getLineAxisCfg(e,n,o.DIRECTION.RADIUS):this.getCircleAxisCfg(e,n,i);h.omit(d,p),g.component.update(d),t.set(c,g)}else{if(s.isTransposed){if(r.isUndefined(n))return;g=this.createLineAxis(e,n,a,o.DIRECTION.RADIUS,"x")}else g=this.createCircleAxis(e,n,a,i,"x");this.cache.set(c,g),t.set(c,g)}if(y=this.cache.get(f)){d=s.isTransposed?this.getCircleGridCfg(e,n,o.DIRECTION.RADIUS,"x"):this.getLineGridCfg(e,n,o.DIRECTION.CIRCLE,"x");h.omit(d,p),y.component.update(d),t.set(f,y)}else{if(s.isTransposed){if(r.isUndefined(n))return;y=this.createCircleGrid(e,n,a,o.DIRECTION.RADIUS,"x")}else y=this.createLineGrid(e,n,a,o.DIRECTION.CIRCLE,"x");y&&(this.cache.set(f,y),t.set(f,y))}}}}},e.prototype.updateYAxes=function(t){var e=this,n=this.view.getYScales();r.each(n,(function(n,i){if(n&&!n.isIdentity){var a=n.field,s=l.getAxisOption(e.option,a);if(!1!==s){var c=o.LAYER.BG,f=e.getId("axis",a),d=e.getId("grid",a),g=e.view.getCoordinate();if(g.isRect){var y=u.getAxisDirection(s,0===i?o.DIRECTION.LEFT:o.DIRECTION.RIGHT);if(m=e.cache.get(f)){var v=e.getLineAxisCfg(n,s,y);h.omit(v,p),m.component.update(v),t.set(f,m)}else m=e.createLineAxis(n,s,c,y,"y"),e.cache.set(f,m),t.set(f,m);if(x=e.cache.get(d)){v=e.getLineGridCfg(n,s,y,"y");h.omit(v,p),x.component.update(v),t.set(d,x)}else(x=e.createLineGrid(n,s,c,y,"y"))&&(e.cache.set(d,x),t.set(d,x))}else if(g.isPolar){var m,x;if(m=e.cache.get(f)){v=g.isTransposed?e.getCircleAxisCfg(n,s,o.DIRECTION.CIRCLE):e.getLineAxisCfg(n,s,o.DIRECTION.RADIUS);h.omit(v,p),m.component.update(v),t.set(f,m)}else{if(g.isTransposed){if(r.isUndefined(s))return;m=e.createCircleAxis(n,s,c,o.DIRECTION.CIRCLE,"y")}else m=e.createLineAxis(n,s,c,o.DIRECTION.RADIUS,"y");e.cache.set(f,m),t.set(f,m)}if(x=e.cache.get(d)){v=g.isTransposed?e.getLineGridCfg(n,s,o.DIRECTION.CIRCLE,"y"):e.getCircleGridCfg(n,s,o.DIRECTION.RADIUS,"y");h.omit(v,p),x.component.update(v),t.set(d,x)}else{if(g.isTransposed){if(r.isUndefined(s))return;x=e.createLineGrid(n,s,c,o.DIRECTION.CIRCLE,"y")}else x=e.createCircleGrid(n,s,c,o.DIRECTION.RADIUS,"y");x&&(e.cache.set(d,x),t.set(d,x))}}}}}))},e.prototype.createLineAxis=function(t,e,n,i,r){var s={component:new a.LineAxis(this.getLineAxisCfg(t,e,i)),layer:n,direction:i===o.DIRECTION.RADIUS?o.DIRECTION.NONE:i,type:o.COMPONENT_TYPE.AXIS,extra:{dim:r,scale:t}};return s.component.set("field",t.field),s.component.init(),s},e.prototype.createLineGrid=function(t,e,n,i,s){var u=this.getLineGridCfg(t,e,i,s);if(u){var l={component:new a.LineGrid(u),layer:n,direction:o.DIRECTION.NONE,type:o.COMPONENT_TYPE.GRID,extra:{dim:s,scale:t,alignTick:r.get(u,"alignTick",!0)}};return l.component.init(),l}},e.prototype.createCircleAxis=function(t,e,n,i,r){var s={component:new a.CircleAxis(this.getCircleAxisCfg(t,e,i)),layer:n,direction:i,type:o.COMPONENT_TYPE.AXIS,extra:{dim:r,scale:t}};return s.component.set("field",t.field),s.component.init(),s},e.prototype.createCircleGrid=function(t,e,n,i,s){var u=this.getCircleGridCfg(t,e,i,s);if(u){var l={component:new a.CircleGrid(u),layer:n,direction:o.DIRECTION.NONE,type:o.COMPONENT_TYPE.GRID,extra:{dim:s,scale:t,alignTick:r.get(u,"alignTick",!0)}};return l.component.init(),l}},e.prototype.getLineAxisCfg=function(t,e,n){var o=this.axisContainer,a=this.view.getCoordinate(),s=u.getAxisRegion(a,n),l=u.getAxisTitleText(t,e),c=u.getAxisThemeCfg(this.view.getTheme(),n),h=r.get(e,["title"])?r.deepMix({title:{style:{text:l}}},e):e,f=r.deepMix(i.__assign(i.__assign({container:o},s),{ticks:t.getTicks().map((function(t){return{id:""+t.tickValue,name:t.text,value:t.value}})),verticalFactor:a.isPolar?-1*u.getAxisFactorByRegion(s,a.getCenter()):u.getAxisFactorByRegion(s,a.getCenter())}),c,h),p=this.getAnimateCfg(f),d=p.animate,g=p.animateOption;f.animateOption=g,f.animate=d;var y=u.isVertical(s),v=r.get(f,"verticalLimitLength",y?1/3:.5);if(v<=1){var m=this.view.getCanvas().get("width"),x=this.view.getCanvas().get("height");f.verticalLimitLength=v*(y?m:x)}return f},e.prototype.getLineGridCfg=function(t,e,n,i){if(c.showGrid(u.getAxisThemeCfg(this.view.getTheme(),n),e)){var o=c.getGridThemeCfg(this.view.getTheme(),n),a=r.deepMix({container:this.gridContainer},o,r.get(e,"grid"),this.getAnimateCfg(e));return a.items=c.getLineGridItems(this.view.getCoordinate(),t,i,r.get(a,"alignTick",!0)),a}},e.prototype.getCircleAxisCfg=function(t,e,n){var a=this.axisContainer,s=this.view.getCoordinate(),l=t.getTicks().map((function(t){return{id:""+t.tickValue,name:t.text,value:t.value}}));t.isCategory||Math.abs(s.endAngle-s.startAngle)!==2*Math.PI||l.pop();var c=u.getAxisTitleText(t,e),h=u.getAxisThemeCfg(this.view.getTheme(),o.DIRECTION.CIRCLE),f=r.get(e,["title"])?r.deepMix({title:{style:{text:c}}},e):e,p=r.deepMix(i.__assign(i.__assign({container:a},u.getCircleAxisCenterRadius(this.view.getCoordinate())),{ticks:l,verticalFactor:1}),h,f),d=this.getAnimateCfg(p),g=d.animate,y=d.animateOption;return p.animate=g,p.animateOption=y,p},e.prototype.getCircleGridCfg=function(t,e,n,i){if(c.showGrid(u.getAxisThemeCfg(this.view.getTheme(),n),e)){var a=c.getGridThemeCfg(this.view.getTheme(),o.DIRECTION.RADIUS),s=r.deepMix({container:this.gridContainer,center:this.view.getCoordinate().getCenter()},a,r.get(e,"grid"),this.getAnimateCfg(e)),l=r.get(s,"alignTick",!0),h="x"===i?this.view.getYScales()[0]:this.view.getXScale();return s.items=c.getCircleGridItems(this.view.getCoordinate(),h,t,l,i),s}},e.prototype.getId=function(t,e){return t+"-"+e+"-"+this.view.getCoordinate().type},e.prototype.getAnimateCfg=function(t){return{animate:this.view.getOptions().animate&&r.get(t,"animate"),animateOption:t&&t.animateOption?r.deepMix({},d,t.animateOption):d}},e}(f.Controller);e.default=g},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.showGrid=e.getCircleGridItems=e.getLineGridItems=e.getGridThemeCfg=void 0;var i=n(0);e.getGridThemeCfg=function(t,e){return i.get(t,["components","axis",e,"grid"],{})},e.getLineGridItems=function(t,e,n,i){var r=[],o=e.getTicks();return t.isPolar&&o.push({value:1,text:"",tickValue:""}),o.reduce((function(e,o,a){var s=o.value;if(i)r.push({points:[t.convert("y"===n?{x:0,y:s}:{x:s,y:0}),t.convert("y"===n?{x:1,y:s}:{x:s,y:1})]});else if(a){var u=(e.value+s)/2;r.push({points:[t.convert("y"===n?{x:0,y:u}:{x:u,y:0}),t.convert("y"===n?{x:1,y:u}:{x:u,y:1})]})}return o}),o[0]),r},e.getCircleGridItems=function(t,e,n,r,o){var a=e.values.length,s=[],u=n.getTicks();return u.reduce((function(e,n){var u=e?e.value:n.value,l=n.value,c=(u+l)/2;return"x"===o?s.push({points:[t.convert({x:r?l:c,y:0}),t.convert({x:r?l:c,y:1})]}):s.push({points:i.map(Array(a+1),(function(e,n){return t.convert({x:n/a,y:r?l:c})}))}),n}),u[0]),s},e.showGrid=function(t,e){var n=i.get(e,"grid");if(null===n)return!1;var r=i.get(t,"grid");return!(void 0===n&&null===r)}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(6),a=n(26),s=n(32),u=n(44),l=n(119),c=n(27),h=n(251),f=n(48);function p(t,e){return r.isBoolean(t)?!1!==t&&{}:r.get(t,[e],t)}function d(t){return r.get(t,"position",o.DIRECTION.BOTTOM)}var g=function(t){function e(e){var n=t.call(this,e)||this;return n.container=n.view.getLayer(o.LAYER.FORE).addGroup(),n}return i.__extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"legend"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.render=function(){var t=this;this.option=this.view.getOptions().legends;if(r.get(this.option,"custom")){var e=this.createCustomLegend(void 0,void 0,void 0,this.option);if(e){e.init();var n=o.LAYER.FORE,i=d(this.option);this.components.push({id:"global-custom",component:e,layer:n,direction:i,type:o.COMPONENT_TYPE.LEGEND,extra:void 0})}}else this.loopLegends((function(e,n,i){var r=t.createFieldLegend(e,n,i);r&&(r.component.init(),t.components.push(r))}))},e.prototype.layout=function(){var t=this;this.layoutBBox=this.view.viewBBox;var e=r.get(this.view.getTheme(),["components","legend","margin"],[0,0,0,0]);r.each(this.components,(function(n){var i=n.component,r=n.direction,o=h.getLegendLayout(r),a=t.getCategoryLegendSizeCfg(o),s=i.get("maxWidth"),c=i.get("maxHeight");i.update({maxWidth:Math.min(a.maxWidth,s||0),maxHeight:Math.min(a.maxHeight,c||0)});var f=i.getLayoutBBox(),p=new u.BBox(f.x,f.y,f.width,f.height),d=l.directionToPosition(t.view.viewBBox,p,r),g=d[0],y=d[1],v=l.directionToPosition(t.layoutBBox,p,r),m=v[0],x=v[1],b=0,_=0;r.startsWith("top")||r.startsWith("bottom")?(b=g,_=x):(b=m,_=y),r.indexOf("left")>=0&&(b+=e[3]),r.indexOf("right")>=0&&(b-=e[1]),r.indexOf("top")>=0&&(_+=e[0]),r.indexOf("bottom")>=0&&(_-=e[2]),i.update({x:b,y:_}),t.layoutBBox=t.layoutBBox.cut(p,r)}))},e.prototype.update=function(){var t=this;this.option=this.view.getOptions().legends;var e={};if(r.get(this.option,"custom")){var n="global-custom",i=this.getComponentById(n);if(i){var a=this.getCategoryCfg(void 0,void 0,void 0,this.option,!0);c.omit(a,["container"]),i.component.update(a),e[n]=!0}else{var s=this.createCustomLegend(void 0,void 0,void 0,this.option);if(s){s.init();var u=o.LAYER.FORE,l=d(this.option);this.components.push({id:n,component:s,layer:u,direction:l,type:o.COMPONENT_TYPE.LEGEND,extra:void 0}),e[n]=!0}}}else this.loopLegends((function(n,i,o){var a=t.getId(o.field),s=t.getComponentById(a);if(s){var u=void 0,l=p(t.option,o.field);!1!==l&&(r.get(l,"custom")?u=t.getCategoryCfg(n,i,o,l,!0):o.isLinear?u=t.getContinuousCfg(n,i,o,l):o.isCategory&&(u=t.getCategoryCfg(n,i,o,l))),u&&(c.omit(u,["container"]),s.direction=d(l),s.component.update(u),e[a]=!0)}else{var h=t.createFieldLegend(n,i,o);h&&(h.component.init(),t.components.push(h),e[a]=!0)}}));var h=[];r.each(this.getComponents(),(function(t){e[t.id]?h.push(t):t.component.destroy()})),this.components=h},e.prototype.clear=function(){t.prototype.clear.call(this),this.container.clear()},e.prototype.destroy=function(){t.prototype.destroy.call(this),this.container.remove(!0)},e.prototype.getGeometries=function(t){var e=this,n=t.geometries;return r.each(t.views,(function(t){n=n.concat(e.getGeometries(t))})),n},e.prototype.loopLegends=function(t){if(this.view.getRootView()===this.view){var e=this.getGeometries(this.view),n={};r.each(e,(function(e){var i=e.getGroupAttributes();r.each(i,(function(i){var r=i.getScale(i.type);r&&"identity"!==r.type&&!n[r.field]&&(t(e,i,r),n[r.field]=!0)}))}))}},e.prototype.createFieldLegend=function(t,e,n){var i,a=p(this.option,n.field),s=o.LAYER.FORE,u=d(a);if(!1!==a&&(r.get(a,"custom")?i=this.createCustomLegend(t,e,n,a):n.isLinear?i=this.createContinuousLegend(t,e,n,a):n.isCategory&&(i=this.createCategoryLegend(t,e,n,a))),i)return i.set("field",n.field),{id:this.getId(n.field),component:i,layer:s,direction:u,type:o.COMPONENT_TYPE.LEGEND,extra:{scale:n}}},e.prototype.createCustomLegend=function(t,e,n,i){var r=this.getCategoryCfg(t,e,n,i,!0);return new a.CategoryLegend(r)},e.prototype.createContinuousLegend=function(t,e,n,i){var r=this.getContinuousCfg(t,e,n,i);return new a.ContinuousLegend(r)},e.prototype.createCategoryLegend=function(t,e,n,i){var r=this.getCategoryCfg(t,e,n,i);return new a.CategoryLegend(r)},e.prototype.getContinuousCfg=function(t,e,n,i){var o=n.getTicks(),a=r.find(o,(function(t){return 0===t.value})),u=r.find(o,(function(t){return 1===t.value})),l=o.map((function(t){var i=t.value,r=t.tickValue,o=e.mapping(n.invert(i)).join("");return{value:r,attrValue:o,color:o,scaleValue:i}}));a||l.push({value:n.min,attrValue:e.mapping(n.invert(0)).join(""),color:e.mapping(n.invert(0)).join(""),scaleValue:0}),u||l.push({value:n.max,attrValue:e.mapping(n.invert(1)).join(""),color:e.mapping(n.invert(1)).join(""),scaleValue:1}),l.sort((function(t,e){return t.value-e.value}));var c={min:r.head(l).value,max:r.last(l).value,colors:[],rail:{type:e.type},track:{}};"size"===e.type&&(c.track={style:{fill:"size"===e.type?this.view.getTheme().defaultColor:void 0}}),"color"===e.type&&(c.colors=l.map((function(t){return t.attrValue})));var p=this.container,g=d(i),y=h.getLegendLayout(g),v=r.get(i,"title");return v&&(v=r.deepMix({text:f.getName(n)},v)),c.container=p,c.layout=y,c.title=v,c.animateOption=s.DEFAULT_ANIMATE_CFG,this.mergeLegendCfg(c,i,"continuous")},e.prototype.getCategoryCfg=function(t,e,n,i,a){var u=this.container,l=r.get(i,"position",o.DIRECTION.BOTTOM),c=r.get(this.view.getTheme(),["components","legend",l,"marker"]),p=r.get(i,"marker"),d=h.getLegendLayout(l),g=a?h.getCustomLegendItems(c,p,i.items):h.getLegendItems(this.view,t,e,c,p),y=r.get(i,"title");y&&(y=r.deepMix({text:n?f.getName(n):""},y));var v=this.getCategoryLegendSizeCfg(d);v.container=u,v.layout=d,v.items=g,v.title=y,v.animateOption=s.DEFAULT_ANIMATE_CFG;var m=this.mergeLegendCfg(v,i,l);m.reversed&&m.items.reverse();var x=r.get(m,"maxItemWidth");return x&&x<=1&&(m.maxItemWidth=this.view.viewBBox.width*x),m},e.prototype.mergeLegendCfg=function(t,e,n){var i=n.split("-")[0],o=r.get(this.view.getTheme(),["components","legend",i],{});return r.deepMix({},o,t,e)},e.prototype.getId=function(t){return this.name+"-"+t},e.prototype.getComponentById=function(t){return r.find(this.components,(function(e){return e.id===t}))},e.prototype.getCategoryLegendSizeCfg=function(t){var e=this.view.viewBBox,n=e.width,i=e.height;return"vertical"===t?{maxWidth:n*o.COMPONENT_MAX_VIEW_PERCENTAGE,maxHeight:i}:{maxWidth:n,maxHeight:i*o.COMPONENT_MAX_VIEW_PERCENTAGE}},e}(n(37).Controller);e.default=g},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getCustomLegendItems=e.getLegendItems=e.getLegendLayout=void 0;var i=n(0),r=n(6),o=n(252),a=n(46);function s(t){var e=t.symbol;i.isString(e)&&a.MarkerSymbols[e]&&(t.symbol=a.MarkerSymbols[e])}e.getLegendLayout=function(t){return t.startsWith(r.DIRECTION.LEFT)||t.startsWith(r.DIRECTION.RIGHT)?"vertical":"horizontal"},e.getLegendItems=function(t,e,n,r,a){var u=n.getScale(n.type);if(u.isCategory){var l=u.field,c=e.getAttribute("color"),h=e.getAttribute("shape"),f=t.getTheme().defaultColor,p=e.coordinate.isPolar;return u.getTicks().map((function(n){var d,g=n.text,y=n.value,v=g,m=u.invert(y),x=0===t.filterFieldData(l,[(d={},d[l]=m,d)]).length,b=o.getMappingValue(c,m,f),_=o.getMappingValue(h,m,"point"),M=e.getShapeMarker(_,{color:b,isInPolar:p});return s(M=i.deepMix({},r,M,a)),{id:m,name:v,value:m,marker:M,unchecked:x}}))}return[]},e.getCustomLegendItems=function(t,e,n){return n.map((function(n){var r=i.deepMix({},t,e,n.marker);return s(r),n.marker=r,n}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.getMappingValue=void 0;var i=n(1);e.getMappingValue=function(t,e,n){if(!t)return n;var r;if(t.callback&&t.callback.length>1){var o=Array(t.callback.length-1).fill("");r=t.mapping.apply(t,i.__spreadArrays([e],o)).join("")}else r=t.mapping(e).join("");return r||n}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(6),a=n(26),s=n(44),u=n(119),l=n(27),c=function(t){function e(e){var n=t.call(this,e)||this;return n.onValueChanged=function(t){var e=t[0],i=t[1];n.updateMinMaxText(e,i),n.view.render(!0)},n.container=n.view.getLayer(o.LAYER.FORE).addGroup(),n}return i.__extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"slider"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.render=function(){if(this.option=this.view.getOptions().slider,this.option){this.slider?this.slider=this.updateSlider():(this.slider=this.createSlider(),this.slider.component.on("sliderchange",this.onValueChanged));var t=this.slider.component.get("start")||0,e=this.slider.component.get("end")||1;this.updateMinMaxText(t,e)}else this.slider&&(this.slider.component.destroy(),this.slider=void 0)},e.prototype.layout=function(){if(this.slider){var t=this.view.coordinateBBox.width,e=this.slider.component.getLayoutBBox(),n=new s.BBox(e.x,e.y,Math.min(e.width,t),e.height),i=u.directionToPosition(this.view.viewBBox,n,o.DIRECTION.BOTTOM),r=(i[0],i[1]),a=u.directionToPosition(this.view.coordinateBBox,n,o.DIRECTION.BOTTOM),l=a[0];a[1];this.slider.component.update({x:l,y:r,width:t})}},e.prototype.update=function(){this.render()},e.prototype.createSlider=function(){var t=this.getSliderCfg(),e=new a.Slider(i.__assign({container:this.container},t));return e.init(),{component:e,layer:o.LAYER.FORE,direction:o.DIRECTION.BOTTOM,type:o.COMPONENT_TYPE.OTHER}},e.prototype.updateSlider=function(){var t=this.getSliderCfg();return l.omit(t,["x","y","width","start","end","minText","maxText"]),this.slider.component.update(t),this.slider},e.prototype.getSliderCfg=function(){if(r.isObject(this.option)){var t=i.__assign({data:this.getData()},r.get(this.option,"trendCfg",{})),e=this.view.coordinateBBox.width,n=r.deepMix({},{x:0,y:0,width:e},this.option);return i.__assign(i.__assign({},n),{trendCfg:t})}return{}},e.prototype.getData=function(){var t=this.view.getOptions().data,e=this.view.getYScales()[0],n=this.view.getGroupScales();if(n.length){var i=n[0],r=i.field,o=i.ticks;return t.reduce((function(t,n){return n[r]===o[0]&&t.push(n[e.field]),t}),[])}return t.map((function(t){return t[e.field]||0}))},e.prototype.updateMinMaxText=function(t,e){var n=this.view.getOptions().data,i=this.view.getXScale(),o=r.size(n);if(i&&o){var a=i.field,s=n.reduce((function(t,e){return t.includes(e[a])||t.push(e[a]),t}),[]),u=r.size(s),c=Math.floor(t*(u-1)),h=Math.floor(e*(u-1)),f=r.get(s,[c]),p=r.get(s,[h]),d=this.getSliderCfg().formatter;d&&(f=d(f,n[c],c),p=d(p,n[h],h)),this.slider.component.update({minText:f,maxText:p,start:t,end:e}),this.view.filter(i.field,(function(t,e){var n=s.indexOf(t);return!(n>-1)||l.isBetween(n,c,h)}))}},e.prototype.getComponents=function(){return this.slider?[this.slider]:[]},e}(n(37).Controller);e.default=c},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(26),a=n(20),s=n(16),u=n(102);var l=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.isLocked=!1,e}return i.__extends(e,t),Object.defineProperty(e.prototype,"name",{get:function(){return"tooltip"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.isVisible=function(){return!1!==this.view.getOptions().tooltip},e.prototype.render=function(){},e.prototype.showTooltip=function(t){if(this.point=t,this.isVisible()){var e=this.view,n=this.getTooltipItems(t);if(n.length){var o=this.getTitle(n),a={x:n[0].x,y:n[0].y};e.emit("tooltip:show",i.__assign({items:n,title:o},t));var s=this.getTooltipCfg(),u=s.follow,l=s.showMarkers,c=s.showCrosshairs,h=s.showContent,f=s.marker,p=this.items,d=this.title;if(r.isEqual(d,o)&&r.isEqual(p,n)?(this.tooltip&&u&&(this.tooltip.update(t),this.tooltip.show()),this.tooltipMarkersGroup&&this.tooltipMarkersGroup.show()):(e.emit("tooltip:change",i.__assign({items:n,title:o},t)),h&&(this.tooltip||this.renderTooltip(),this.tooltip.update(r.mix({},s,{items:n,title:o},u?t:{})),this.tooltip.show()),l&&this.renderTooltipMarkers(n,f)),this.items=n,this.title=o,c){var g=r.get(s,["crosshairs","follow"],!1);this.renderCrosshairs(g?t:a,s)}}else this.hideTooltip()}},e.prototype.hideTooltip=function(){if(this.getTooltipCfg().follow){var t=this.tooltipMarkersGroup;t&&t.hide();var e=this.xCrosshair,n=this.yCrosshair;e&&e.hide(),n&&n.hide();var i=this.tooltip;i&&i.hide(),this.view.emit("tooltip:hide",{}),this.point=null}else this.point=null},e.prototype.lockTooltip=function(){this.isLocked=!0,this.tooltip&&this.tooltip.setCapture(!0)},e.prototype.unlockTooltip=function(){this.isLocked=!1;var t=this.getTooltipCfg();this.tooltip&&this.tooltip.setCapture(t.capture)},e.prototype.isTooltipLocked=function(){return this.isLocked},e.prototype.clear=function(){var t=this.tooltip,e=this.xCrosshair,n=this.yCrosshair,i=this.tooltipMarkersGroup;t&&(t.hide(),t.clear()),e&&e.clear(),n&&n.clear(),i&&i.clear()},e.prototype.destroy=function(){this.tooltip&&this.tooltip.destroy(),this.xCrosshair&&this.xCrosshair.destroy(),this.yCrosshair&&this.yCrosshair.destroy(),this.guideGroup&&this.guideGroup.remove(!0),this.items=null,this.title=null,this.tooltipMarkersGroup=null,this.tooltipCrosshairsGroup=null,this.xCrosshair=null,this.yCrosshair=null,this.tooltip=null,this.guideGroup=null,this.isLocked=!1,this.point=null},e.prototype.changeVisible=function(t){if(this.visible!==t){var e=this.tooltip,n=this.tooltipMarkersGroup,i=this.xCrosshair,r=this.yCrosshair;t?(e&&e.show(),n&&n.show(),i&&i.show(),r&&r.show()):(e&&e.hide(),n&&n.hide(),i&&i.hide(),r&&r.hide()),this.visible=t}},e.prototype.getTooltipItems=function(t){var e=this.findItemsFromView(this.view,t);if(e.length){for(var n=0,i=e=r.flatten(e);n1){for(var h=e[0],f=Math.abs(t.y-h[0].y),p=0,d=e;ph.maxY&&(h=e)):(e.minXh.maxX&&(h=e)),f.x=Math.min(e.minX,f.minX),f.y=Math.min(e.minY,f.minY),f.width=Math.max(e.maxX,f.maxX)-f.x,f.height=Math.max(e.maxY,f.maxY)-f.y}));var p=t.backgroundGroup,d=t.coordinateBBox,g=void 0;if(l.isRect){var y=t.getXScale().isLinear?0:.25,v=void 0,m=void 0,x=void 0,b=void 0;l.isTransposed?(v=d.minX,m=Math.min(h.minY,c.minY)-y*h.height,x=d.width,b=f.height+2*y*h.height):(v=Math.min(c.minX,h.minX)-y*c.width,m=Math.min(d.minY,c.minY),x=f.width+2*y*c.width,b=d.height),g=[["M",v,m],["L",v+x,m],["L",v+x,m+b],["L",v,m+b],["Z"]]}else{var _=r.head(s),M=r.last(s),C=o.getAngle(_.getModel(),l).startAngle,w=o.getAngle(M.getModel(),l).endAngle,O=l.getCenter(),S=l.getRadius(),A=l.innerRadius*S;g=o.getSectorPath(O.x,O.y,S,C,w,A)}this.regionPath?(this.regionPath.attr("path",g),this.regionPath.show()):this.regionPath=p.addShape({type:"path",name:"active-region",capture:!1,attrs:{path:g,fill:"#CCD6EC",opacity:.3}})}}},e.prototype.hide=function(){this.regionPath&&this.regionPath.hide(),this.items=null},e.prototype.destroy=function(){this.hide(),this.regionPath&&this.regionPath.remove(!0),t.prototype.destroy.call(this)},e}(i.__importDefault(n(12)).default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(8),a=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.showTooltip=function(t,e){var n=o.getSilbings(t);r.each(n,(function(n){var i=o.getSiblingPoint(t,n,e);n.showTooltip(i)}))},e.prototype.hideTooltip=function(t){var e=o.getSilbings(t);r.each(e,(function(t){t.hideTooltip()}))},e}(i.__importDefault(n(120)).default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=i.__importDefault(n(12)),a=n(26),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.timeStamp=0,e}return i.__extends(e,t),e.prototype.destroy=function(){t.prototype.destroy.call(this),this.tooltip&&this.tooltip.destroy()},e.prototype.show=function(){var t=this.context.event,e=this.timeStamp,n=+new Date;if(n-e>16){var i=this.location,o={x:t.x,y:t.y};i&&r.isEqual(i,o)||this.showTooltip(o),this.timeStamp=n,this.location=o}},e.prototype.hide=function(){this.hideTooltip(),this.location=null},e.prototype.showTooltip=function(t){var e=this.context.event.target;if(e&&e.get("tip")){this.tooltip||this.renderTooltip();var n=e.get("tip");this.tooltip.update(i.__assign({title:n},t)),this.tooltip.show()}},e.prototype.hideTooltip=function(){this.tooltip&&this.tooltip.hide()},e.prototype.renderTooltip=function(){var t=this.context.view,e=t.canvas,n={start:{x:0,y:0},end:{x:e.get("width"),y:e.get("height")}},i=t.getTheme(),o=r.get(i,["components","tooltip","domStyles"],{}),s=new a.HtmlTooltip({parent:e.get("el").parentNode,region:n,visible:!1,crosshairs:null,domStyles:o});s.init(),s.setCapture(!1),this.tooltip=s},e}(o.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="active",e}return i.__extends(e,t),e.prototype.active=function(){this.setState()},e}(i.__importDefault(n(81)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=i.__importDefault(n(12)),o=n(8),a=n(0),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.cache={},e}return i.__extends(e,t),e.prototype.getColorScale=function(t,e){var n=e.geometry.getAttribute("color");return n?t.getScaleByField(n.getFields()[0]):null},e.prototype.getLinkPath=function(t,e){var n=t.shape.getCanvasBBox(),i=e.shape.getCanvasBBox();return[["M",n.maxX,n.minY],["L",i.minX,i.minY],["L",i.minX,i.maxY],["L",n.maxX,n.maxY],["Z"]]},e.prototype.addLinkShape=function(t,e,n){t.addShape({type:"path",attrs:{opacity:.4,fill:e.shape.attr("fill"),path:this.getLinkPath(e,n)}})},e.prototype.linkByElement=function(t){var e=this,n=this.context.view,i=this.getColorScale(n,t);if(i){var r=o.getElementValue(t,i.field);if(!this.cache[r]){var s=o.getElementsByField(n,i.field,r),u=this.linkGroup.addGroup();this.cache[r]=u;var l=s.length;a.each(s,(function(t,n){if(n=0}),e)},e}(i.__importDefault(n(83)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(8),o=n(86),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="active",e}return i.__extends(e,t),e.prototype.highlight=function(){this.setState()},e.prototype.setElementState=function(t,e){var n=this.context.view,i=r.getElements(n);o.setHighlightBy(i,(function(e){return t===e}),e)},e.prototype.clear=function(){var t=this.context.view;o.clearHighlight(t)},e}(i.__importDefault(n(84)).default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="selected",e}return i.__extends(e,t),e.prototype.selected=function(){this.setState()},e}(i.__importDefault(n(83)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="selected",e}return i.__extends(e,t),e.prototype.selected=function(){this.setState()},e}(i.__importDefault(n(81)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="selected",e}return i.__extends(e,t),e.prototype.selected=function(){this.setState()},e}(i.__importDefault(n(84)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="active",e}return i.__extends(e,t),e.prototype.active=function(){this.setState()},e}(i.__importDefault(n(55)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(271),a=i.__importDefault(n(55)),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="active",e.ignoreItemStates=["unchecked"],e}return i.__extends(e,t),e.prototype.setItemsState=function(t,e,n){this.setHighlightBy(t,(function(t){return t.name===e}),n)},e.prototype.setItemState=function(t,e,n){t.getItems();this.setHighlightBy(t,(function(t){return t===e}),n)},e.prototype.setHighlightBy=function(t,e,n){var i=t.getItems();if(n)r.each(i,(function(n){e(n)?(t.hasState(n,"inactive")&&t.setItemState(n,"inactive",!1),t.setItemState(n,"active",!0)):t.hasState(n,"active")||t.setItemState(n,"inactive",!0)}));else{var o=t.getItemsByState("active"),a=!0;r.each(o,(function(t){if(!e(t))return a=!1,!1})),a?this.clear():r.each(i,(function(n){e(n)&&(t.hasState(n,"active")&&t.setItemState(n,"active",!1),t.setItemState(n,"inactive",!0))}))}},e.prototype.highlight=function(){this.setState()},e.prototype.clear=function(){var t=this.getTriggerListInfo();if(t)o.clearList(t.list);else{var e=this.getAllowComponents();r.each(e,(function(t){t.clearItemsState("active"),t.clearItemsState("inactive")}))}},e}(a.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.clearList=void 0;var i=n(0);e.clearList=function(t){var e=t.getItems();i.each(e,(function(e){t.hasState(e,"active")&&t.setItemState(e,"active",!1),t.hasState(e,"inactive")&&t.setItemState(e,"inactive",!1)}))}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="selected",e}return i.__extends(e,t),e.prototype.selected=function(){this.setState()},e}(i.__importDefault(n(55)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.stateName="unchecked",e}return i.__extends(e,t),e.prototype.unchecked=function(){this.setState()},e}(i.__importDefault(n(55)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=n(8),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.shapeType="circle",e}return i.__extends(e,t),e.prototype.getMaskAttrs=function(){var t=this.points,e=r.last(this.points),n=0,i=0,a=0;if(t.length){var s=t[0];n=o.distance(s,e)/2,i=(e.x+s.x)/2,a=(e.y+s.y)/2}return{x:i,y:a,r:n}},e}(i.__importDefault(n(87)).default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0);function o(t){t.x=r.clamp(t.x,0,1),t.y=r.clamp(t.y,0,1)}var a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.dim="x",e.inPlot=!0,e}return i.__extends(e,t),e.prototype.getRegion=function(){var t=null,e=null,n=this.points,i=this.dim,a=this.context.view.getCoordinate(),s=a.invert(r.head(n)),u=a.invert(r.last(n));return this.inPlot&&(o(s),o(u)),"x"===i?(t=a.convert({x:s.x,y:0}),e=a.convert({x:u.x,y:1})):(t=a.convert({x:0,y:s.y}),e=a.convert({x:1,y:u.y})),{start:t,end:e}},e}(i.__importDefault(n(121)).default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(8),o=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.getMaskPath=function(){var t=this.points;return r.getSpline(t,!0)},e}(i.__importDefault(n(122)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.setCursor=function(t){this.context.view.getCanvas().setCursor(t)},e.prototype.default=function(){this.setCursor("default")},e.prototype.pointer=function(){this.setCursor("pointer")},e.prototype.move=function(){this.setCursor("move")},e.prototype.crosshair=function(){this.setCursor("crosshair")},e.prototype.wait=function(){this.setCursor("wait")},e.prototype.help=function(){this.setCursor("help")},e.prototype.text=function(){this.setCursor("text")},e.prototype.eResize=function(){this.setCursor("e-resize")},e.prototype.wResize=function(){this.setCursor("w-resize")},e.prototype.nResize=function(){this.setCursor("n-resize")},e.prototype.sResize=function(){this.setCursor("s-resize")},e.prototype.neResize=function(){this.setCursor("ne-resize")},e.prototype.nwResize=function(){this.setCursor("nw-resize")},e.prototype.seResize=function(){this.setCursor("se-resize")},e.prototype.swResize=function(){this.setCursor("sw-resize")},e.prototype.nsResize=function(){this.setCursor("ns-resize")},e.prototype.ewResize=function(){this.setCursor("ew-resize")},e}(i.__importDefault(n(12)).default);e.default=r},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=i.__importDefault(n(12)),a=n(8),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.filterView=function(t,e,n){var i=this;t.getScaleByField(e)&&t.filter(e,n),t.views&&t.views.length&&r.each(t.views,(function(t){i.filterView(t,e,n)}))},e.prototype.filter=function(){var t=a.getDelegationObject(this.context);if(t){var e=this.context.view,n=t.component,i=n.get("field");if(a.isList(t)){if(i){var r=n.getItemsByState("unchecked"),o=a.getScaleByField(e,i),s=r.map((function(t){return t.name}));s.length?this.filterView(e,i,(function(t){var e=o.getText(t);return!s.includes(e)})):this.filterView(e,i,null),e.render(!0)}}else if(a.isSlider(t)){var u=n.getValue(),l=u[0],c=u[1];this.filterView(e,i,(function(t){return t>=l&&t<=c})),e.render(!0)}}},e}(o.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=i.__importDefault(n(123)),a=n(8),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.filterView=function(t,e,n){var i=a.getSilbings(t);r.each(i,(function(t){t.filter(e,n)}))},e.prototype.reRender=function(t){var e=a.getSilbings(t);r.each(e,(function(t){t.render(!0)}))},e}(o.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=i.__importDefault(n(12)),a=n(8),s=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return i.__extends(e,t),e.prototype.filter=function(){var t=a.getDelegationObject(this.context),e=this.context.view,n=a.getElements(e);if(a.isMask(this.context)){var i=a.getMaskedElements(this.context,10);i&&r.each(n,(function(t){i.includes(t)?t.show():t.hide()}))}else if(t){var o=t.component,s=o.get("field");if(a.isList(t)){if(s){var u=o.getItemsByState("unchecked"),l=a.getScaleByField(e,s),c=u.map((function(t){return t.name}));r.each(n,(function(t){var e=a.getElementValue(t,s),n=l.getText(e);c.indexOf(n)>=0?t.hide():t.show()}))}}else if(a.isSlider(t)){var h=o.getValue(),f=h[0],p=h[1];r.each(n,(function(t){var e=a.getElementValue(t,s);e>=f&&e<=p?t.show():t.hide()}))}}},e.prototype.clear=function(){var t=a.getElements(this.context.view);r.each(t,(function(t){t.show()}))},e.prototype.reset=function(){this.clear()},e}(o.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=i.__importDefault(n(12)),a=n(8),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.byRecord=!1,e}return i.__extends(e,t),e.prototype.filter=function(){a.isMask(this.context)&&(this.byRecord?this.filterByRecord():this.filterByBBox())},e.prototype.filterByRecord=function(){var t=this.context.view,e=a.getMaskedElements(this.context,10);if(e){var n=t.getXScale().field,i=t.getYScales()[0].field,o=e.map((function(t){return t.getModel().data})),s=a.getSilbings(t);r.each(s,(function(t){var e=a.getElements(t);r.each(e,(function(t){var e=t.getModel().data;a.isInRecords(o,e,n,i)?t.show():t.hide()}))}))}},e.prototype.filterByBBox=function(){var t=this,e=this.context.view,n=a.getSilbings(e);r.each(n,(function(e){var n=a.getSiblingMaskElements(t.context,e,10),i=a.getElements(e);n&&r.each(i,(function(t){n.includes(t)?t.show():t.hide()}))}))},e.prototype.reset=function(){var t=a.getSilbings(this.context.view);r.each(t,(function(t){var e=a.getElements(t);r.each(e,(function(t){t.show()}))}))},e}(o.default);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(2),o=n(0),a=n(50),s=i.__importDefault(n(12)),u=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.buttonGroup=null,e.buttonCfg={name:"button",text:"button",textStyle:{x:0,y:0,fontSize:12,fill:"#333333",cursor:"pointer"},padding:[8,10],style:{fill:"#f7f7f7",stroke:"#cccccc",cursor:"pointer"},activeStyle:{fill:"#e6e6e6"}},e}return i.__extends(e,t),e.prototype.getButtonCfg=function(){return o.deepMix(this.buttonCfg,this.cfg)},e.prototype.drawButton=function(){var t=this.getButtonCfg(),e=this.context.view.foregroundGroup.addGroup({name:t.name}),n=e.addShape({type:"text",name:"button-text",attrs:i.__assign({text:t.text},t.textStyle)}).getBBox(),r=a.parsePadding(t.padding),o=e.addShape({type:"rect",name:"button-rect",attrs:i.__assign({x:n.x-r[3],y:n.y-r[0],width:n.width+r[1]+r[3],height:n.height+r[0]+r[2]},t.style)});o.toBack(),e.on("mouseenter",(function(){o.attr(t.activeStyle)})),e.on("mouseleave",(function(){o.attr(t.style)})),this.buttonGroup=e},e.prototype.resetPosition=function(){var t=this.context.view.getCoordinate().convert({x:1,y:1}),e=this.buttonGroup,n=e.getBBox(),i=r.ext.transform(null,[["t",t.x-n.width-10,t.y+n.height+5]]);e.setMatrix(i)},e.prototype.show=function(){this.buttonGroup||this.drawButton(),this.resetPosition(),this.buttonGroup.show()},e.prototype.hide=function(){this.buttonGroup&&this.buttonGroup.hide()},e.prototype.destroy=function(){var e=this.buttonGroup;e&&e.remove(),t.prototype.destroy.call(this)},e}(s.default);e.default=u},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=i.__importDefault(n(12)),o=n(8),a=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.starting=!1,e.dragStart=!1,e}return i.__extends(e,t),e.prototype.start=function(){this.starting=!0,this.startPoint=this.context.getCurrentPoint()},e.prototype.drag=function(){if(this.startPoint){var t=this.context.getCurrentPoint(),e=this.context.view,n=this.context.event;this.dragStart?e.emit("drag",{target:n.target,x:n.x,y:n.y}):o.distance(t,this.startPoint)>4&&(e.emit("dragstart",{target:n.target,x:n.x,y:n.y}),this.dragStart=!0)}},e.prototype.end=function(){if(this.dragStart){var t=this.context.view,e=this.context.event;t.emit("dragend",{target:e.target,x:e.x,y:e.y})}this.starting=!1,this.dragStart=!1},e}(r.default);e.default=a},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(2),o=n(71),a=n(8),s=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.starting=!1,e.isMoving=!1,e.startPoint=null,e.startMatrix=null,e}return i.__extends(e,t),e.prototype.start=function(){this.starting=!0,this.startPoint=this.context.getCurrentPoint(),this.startMatrix=this.context.view.middleGroup.getMatrix()},e.prototype.move=function(){if(this.starting){var t=this.startPoint,e=this.context.getCurrentPoint();if(a.distance(t,e)>5&&!this.isMoving&&(this.isMoving=!0),this.isMoving){var n=this.context.view,i=r.ext.transform(this.startMatrix,[["t",e.x-t.x,e.y-t.y]]);n.backgroundGroup.setMatrix(i),n.foregroundGroup.setMatrix(i),n.middleGroup.setMatrix(i)}}},e.prototype.end=function(){this.isMoving&&(this.isMoving=!1),this.startMatrix=null,this.starting=!1,this.startPoint=null},e.prototype.reset=function(){this.starting=!1,this.startPoint=null,this.isMoving=!1;var t=this.context.view;t.backgroundGroup.resetMatrix(),t.foregroundGroup.resetMatrix(),t.middleGroup.resetMatrix(),this.isMoving=!1},e}(o.Action);e.default=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.startPoint=null,e.starting=!1,e.startCache={},e}return i.__extends(e,t),e.prototype.start=function(){var t=this;this.startPoint=this.context.getCurrentPoint(),this.starting=!0;var e=this.dims;r.each(e,(function(e){var n=t.getScale(e),i=n.min,r=n.max,o=n.values;t.startCache[e]={min:i,max:r,values:o}}))},e.prototype.end=function(){this.startPoint=null,this.starting=!1,this.startCache={}},e.prototype.translate=function(){var t=this;if(this.starting){var e=this.startPoint,n=this.context.view.getCoordinate(),i=this.context.getCurrentPoint(),o=n.invert(e),a=n.invert(i),s=a.x-o.x,u=a.y-o.y,l=this.context.view,c=this.dims;r.each(c,(function(e){t.translateDim(e,{x:-1*s,y:-1*u})})),l.render(!0)}},e.prototype.translateDim=function(t,e){if(this.hasDim(t)){var n=this.getScale(t);n.isLinear&&this.translateLinear(t,n,e)}},e.prototype.translateLinear=function(t,e,n){var i=this.context.view,r=this.startCache[t],o=r.min,a=r.max,s=a-o,u=n[t]*s;this.cacheScaleDefs[t]||(this.cacheScaleDefs[t]={nice:e.nice,min:o,max:a}),i.scale(e.field,{nice:!1,min:o+u,max:a+u})},e.prototype.reset=function(){t.prototype.reset.call(this),this.startPoint=null,this.starting=!1},e}(i.__importDefault(n(124)).default);e.default=o},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var i=n(1),r=n(0),o=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.zoomRatio=.05,e}return i.__extends(e,t),e.prototype.zoomIn=function(){this.zoom(this.zoomRatio)},e.prototype.zoom=function(t){var e=this,n=this.dims;r.each(n,(function(n){e.zoomDim(n,t)})),this.context.view.render(!0)},e.prototype.zoomOut=function(){this.zoom(-1*this.zoomRatio)},e.prototype.zoomDim=function(t,e){if(this.hasDim(t)){var n=this.getScale(t);n.isLinear&&this.zoomLinear(t,n,e)}},e.prototype.zoomLinear=function(t,e,n){var i=this.context.view;this.cacheScaleDefs[t]||(this.cacheScaleDefs[t]={nice:e.nice,min:e.min,max:e.max});var r=this.cacheScaleDefs[t],o=r.max-r.min,a=e.min,s=e.max,u=n*o,l=a-u,c=s+u,h=(c-l)/o;c>l&&h<100&&h>.01&&i.scale(e.field,{nice:!1,min:a-u,max:s+u})},e}(i.__importDefault(n(124)).default);e.default=o},function(t,e,n){"use strict";n.r(e),n.d(e,"Component",(function(){return N})),n.d(e,"GroupComponent",(function(){return V})),n.d(e,"HtmlComponent",(function(){return Pt})),n.d(e,"Axis",(function(){return u})),n.d(e,"Annotation",(function(){return i})),n.d(e,"Grid",(function(){return c})),n.d(e,"Legend",(function(){return h})),n.d(e,"Tooltip",(function(){return p})),n.d(e,"Crosshair",(function(){return l})),n.d(e,"Slider",(function(){return he})),n.d(e,"Scrollbar",(function(){return pe}));var i={};n.r(i),n.d(i,"Line",(function(){return U})),n.d(i,"Text",(function(){return Z})),n.d(i,"Arc",(function(){return Q})),n.d(i,"Region",(function(){return K})),n.d(i,"Image",(function(){return $})),n.d(i,"DataMarker",(function(){return J})),n.d(i,"DataRegion",(function(){return tt})),n.d(i,"RegionFilter",(function(){return et}));var r={};n.r(r),n.d(r,"getDefault",(function(){return ot})),n.d(r,"ellipsisHead",(function(){return at})),n.d(r,"ellipsisTail",(function(){return st})),n.d(r,"ellipsisMiddle",(function(){return ut}));var o={};n.r(o),n.d(o,"getDefault",(function(){return ft})),n.d(o,"reserveFirst",(function(){return pt})),n.d(o,"reserveLast",(function(){return dt})),n.d(o,"reserveBoth",(function(){return gt})),n.d(o,"equidistance",(function(){return yt}));var a={};n.r(a),n.d(a,"getDefault",(function(){return mt})),n.d(a,"fixedAngle",(function(){return xt})),n.d(a,"unfixedAngle",(function(){return bt}));var s={};n.r(s),n.d(s,"autoHide",(function(){return o})),n.d(s,"autoRotate",(function(){return a})),n.d(s,"autoEllipsis",(function(){return r}));var u={};n.r(u),n.d(u,"Line",(function(){return Mt})),n.d(u,"Circle",(function(){return Ct})),n.d(u,"Base",(function(){return it}));var l={};n.r(l),n.d(l,"Line",(function(){return Ot})),n.d(l,"Circle",(function(){return St})),n.d(l,"Base",(function(){return wt})),n.d(l,"Html",(function(){return Tt}));var c={};n.r(c),n.d(c,"Base",(function(){return Et})),n.d(c,"Circle",(function(){return Lt})),n.d(c,"Line",(function(){return kt}));var h={};n.r(h),n.d(h,"Category",(function(){return Dt})),n.d(h,"Continuous",(function(){return Ft})),n.d(h,"Base",(function(){return Bt}));var f={};n.r(f),n.d(f,"CONTAINER_CLASS",(function(){return Nt})),n.d(f,"TITLE_CLASS",(function(){return Gt})),n.d(f,"LIST_CLASS",(function(){return Yt})),n.d(f,"LIST_ITEM_CLASS",(function(){return Vt})),n.d(f,"MARKER_CLASS",(function(){return Xt})),n.d(f,"VALUE_CLASS",(function(){return zt})),n.d(f,"NAME_CLASS",(function(){return Ht})),n.d(f,"CROSSHAIR_X",(function(){return Wt})),n.d(f,"CROSSHAIR_Y",(function(){return qt}));var p={};n.r(p),n.d(p,"Html",(function(){return Zt})); -/*! ***************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ -var d=function(t,e){return(d=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function g(t,e){function n(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var y=function(){return(y=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=0;n--)t.removeChild(e[n])}function T(t){var e=t.start,n=t.end,i=Math.min(e.x,n.x),r=Math.min(e.y,n.y),o=Math.max(e.x,n.x),a=Math.max(e.y,n.y);return{x:i,y:r,minX:i,minY:r,maxX:o,maxY:a,width:o-i,height:a-r}}function E(t,e,n,i){return{x:t,y:e,width:n,height:i,minX:t,minY:e,maxX:t+n,maxY:e+i}}function j(t,e,n){return(1-n)*t+e*n}function L(t,e,n){return{x:t.x+Math.cos(n)*e,y:t.y+Math.sin(n)*e}}function k(t){var e,n,i,r,o,a=t.getClip(),s=a&&a.getBBox();if(t.isGroup()){var u=1/0,l=-1/0,c=1/0,h=-1/0,f=t.getChildren();f.length>0?Object(m.each)(f,(function(t){if(t.get("visible")){if(t.isGroup()&&0===t.get("children").length)return!0;var e=k(t),n=t.applyToMatrix([e.minX,e.minY,1]),i=t.applyToMatrix([e.minX,e.maxY,1]),r=t.applyToMatrix([e.maxX,e.minY,1]),o=t.applyToMatrix([e.maxX,e.maxY,1]),a=Math.min(n[0],i[0],r[0],o[0]),s=Math.max(n[0],i[0],r[0],o[0]),f=Math.min(n[1],i[1],r[1],o[1]),p=Math.max(n[1],i[1],r[1],o[1]);al&&(l=s),fh&&(h=p)}})):(u=0,l=0,c=0,h=0),e=E(u,c,l-u,h-c)}else e=t.getBBox();return s?(n=e,i=s,r=Math.max(n.minX,i.minX),o=Math.max(n.minY,i.minY),E(r,o,Math.min(n.maxX,i.maxX)-r,Math.min(n.maxY,i.maxY)-o)):e}function B(t){return t+"px"}function D(t,e,n,i){var r,o,a,s,u=i/(r=t,a=(o=e).x-r.x,s=o.y-r.y,Math.sqrt(a*a+s*s)),l=0;return"start"===n?l=0-u:"end"===n&&(l=1+u),{x:j(t.x,e.x,l),y:j(t.y,e.y,l)}}var F=n(9),R={none:[],point:["x","y"],region:["start","end"],points:["points"],circle:["center","radius","startAngle","endAngle"]},N=function(t){function e(e){var n=t.call(this,e)||this;return n.initCfg(),n}return g(e,t),e.prototype.getDefaultCfg=function(){return{id:"",name:"",type:"",locationType:"none",offsetX:0,offsetY:0,animate:!1,capture:!0,updateAutoRender:!1,animateOption:{appear:null,update:{duration:400,easing:"easeQuadInOut"},enter:{duration:400,easing:"easeQuadInOut"},leave:{duration:350,easing:"easeQuadIn"}},events:null,defaultCfg:{},visible:!0}},e.prototype.clear=function(){},e.prototype.update=function(t){var e=this,n=this.get("defaultCfg");Object(m.each)(t,(function(t,i){var r=t;e.get(i)!==t&&(Object(m.isObject)(t)&&n[i]&&(r=Object(m.deepMix)({},n[i],t)),e.set(i,r))})),this.updateInner(t),this.afterUpdate(t)},e.prototype.updateInner=function(t){},e.prototype.afterUpdate=function(t){Object(m.hasKey)(t,"visible")&&(t.visible?this.show():this.hide()),Object(m.hasKey)(t,"capture")&&this.setCapture(t.capture)},e.prototype.getLayoutBBox=function(){return this.getBBox()},e.prototype.getLocationType=function(){return this.get("locationType")},e.prototype.getOffset=function(){return{offsetX:this.get("offsetX"),offsetY:this.get("offsetY")}},e.prototype.setOffset=function(t,e){this.update({offsetX:t,offsetY:e})},e.prototype.setLocation=function(t){var e=y({},t);this.update(e)},e.prototype.getLocation=function(){var t=this,e={},n=this.get("locationType"),i=R[n];return Object(m.each)(i,(function(n){e[n]=t.get(n)})),e},e.prototype.isList=function(){return!1},e.prototype.isSlider=function(){return!1},e.prototype.init=function(){},e.prototype.initCfg=function(){var t=this,e=this.get("defaultCfg");Object(m.each)(e,(function(e,n){var i=t.get(n);if(Object(m.isObject)(i)){var r=Object(m.deepMix)({},e,i);t.set(n,r)}}))},e}(F.Base),G=["visible","tip","delegateObject"],Y=["container","group","shapesMap","isRegister","isUpdating","destroyed"],V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{container:null,shapesMap:{},group:null,capture:!0,isRegister:!1,isUpdating:!1,isInit:!0})},e.prototype.remove=function(){this.clear(),this.get("group").remove()},e.prototype.clear=function(){this.get("group").clear(),this.set("shapesMap",{}),this.clearOffScreenCache(),this.set("isInit",!0)},e.prototype.getChildComponentById=function(t){var e=this.getElementById(t);return e&&e.get("component")},e.prototype.getElementById=function(t){return this.get("shapesMap")[t]},e.prototype.getElementByLocalId=function(t){var e=this.getElementId(t);return this.getElementById(e)},e.prototype.getElementsByName=function(t){var e=[];return Object(m.each)(this.get("shapesMap"),(function(n){n.get("name")===t&&e.push(n)})),e},e.prototype.getContainer=function(){return this.get("container")},e.prototype.updateInner=function(t){this.offScreenRender(),this.get("updateAutoRender")&&this.render()},e.prototype.render=function(){var t=this.get("offScreenGroup");t||(t=this.offScreenRender());var e=this.get("group");this.updateElements(t,e),this.deleteElements(),this.applyOffset(),this.get("eventInitted")||(this.initEvent(),this.set("eventInitted",!0)),this.set("isInit",!1)},e.prototype.show=function(){this.get("group").show(),this.set("visible",!0)},e.prototype.hide=function(){this.get("group").hide(),this.set("visible",!1)},e.prototype.setCapture=function(t){this.get("group").set("capture",t),this.set("capture",t)},e.prototype.destroy=function(){this.removeEvent(),this.remove(),t.prototype.destroy.call(this)},e.prototype.getBBox=function(){return this.get("group").getCanvasBBox()},e.prototype.getLayoutBBox=function(){var t=this.get("group"),e=this.getInnerLayoutBBox(),n=t.getTotalMatrix();return n&&(e=function(t,e){var n=O(t,[e.minX,e.minY]),i=O(t,[e.maxX,e.minY]),r=O(t,[e.minX,e.maxY]),o=O(t,[e.maxX,e.maxY]),a=Math.min(n[0],i[0],r[0],o[0]),s=Math.max(n[0],i[0],r[0],o[0]),u=Math.min(n[1],i[1],r[1],o[1]),l=Math.max(n[1],i[1],r[1],o[1]);return{x:a,y:u,minX:a,minY:u,maxX:s,maxY:l,width:s-a,height:l-u}}(n,e)),e},e.prototype.on=function(t,e,n){return this.get("group").on(t,e,n),this},e.prototype.off=function(t,e){var n=this.get("group");return n&&n.off(t,e),this},e.prototype.emit=function(t,e){this.get("group").emit(t,e)},e.prototype.init=function(){t.prototype.init.call(this),this.get("group")||this.initGroup(),this.offScreenRender()},e.prototype.getInnerLayoutBBox=function(){return this.get("offScreenBBox")||this.get("group").getBBox()},e.prototype.delegateEmit=function(t,e){var n=this.get("group");e.target=n,n.emit(t,e),function(t,e,n){var i=new b.a(e,n);i.target=t,i.propagationPath.push(t),t.emitDelegation(e,i);for(var r=t.getParent();r;)r.emitDelegation(e,i),i.propagationPath.push(r),r=r.getParent()}(n,t,e)},e.prototype.createOffScreenGroup=function(){return new(this.get("group").getGroupBase())({delegateObject:this.getDelegateObject()})},e.prototype.applyOffset=function(){var t=this.get("offsetX"),e=this.get("offsetY");this.moveElementTo(this.get("group"),{x:t,y:e})},e.prototype.initGroup=function(){var t=this.get("container");this.set("group",t.addGroup({id:this.get("id"),name:this.get("name"),capture:this.get("capture"),visible:this.get("visible"),isComponent:!0,component:this,delegateObject:this.getDelegateObject()}))},e.prototype.offScreenRender=function(){this.clearOffScreenCache();var t=this.createOffScreenGroup();return this.renderInner(t),this.set("offScreenGroup",t),this.set("offScreenBBox",k(t)),t},e.prototype.addGroup=function(t,e){this.appendDelegateObject(t,e);var n=t.addGroup(e);return this.get("isRegister")&&this.registerElement(n),n},e.prototype.addShape=function(t,e){this.appendDelegateObject(t,e);var n=t.addShape(e);return this.get("isRegister")&&this.registerElement(n),n},e.prototype.addComponent=function(t,e){var n=e.id,i=e.component,r=v(e,["id","component"]),o=new i(y(y({},r),{id:n,container:t,updateAutoRender:this.get("updateAutoRender")}));return o.init(),o.render(),this.get("isRegister")&&this.registerElement(o.get("group")),o},e.prototype.initEvent=function(){},e.prototype.removeEvent=function(){this.get("group").off()},e.prototype.getElementId=function(t){return this.get("id")+"-"+this.get("name")+"-"+t},e.prototype.registerElement=function(t){var e=t.get("id");this.get("shapesMap")[e]=t},e.prototype.unregisterElement=function(t){var e=t.get("id");delete this.get("shapesMap")[e]},e.prototype.moveElementTo=function(t,e){var n=w(e);t.attr("matrix",n)},e.prototype.addAnimation=function(t,e,n){var i=e.attr("opacity");Object(m.isNil)(i)&&(i=1),e.attr("opacity",0),e.animate({opacity:i},n)},e.prototype.removeAnimation=function(t,e,n){e.animate({opacity:0},n)},e.prototype.updateAnimation=function(t,e,n,i){e.animate(n,i)},e.prototype.updateElements=function(t,e){var n,i=this,r=this.get("animate"),o=this.get("animateOption"),a=t.getChildren().slice(0);Object(m.each)(a,(function(t){var a=t.get("id"),s=i.getElementById(a),u=t.get("name");if(s)if(t.get("isComponent")){var l=t.get("component"),c=s.get("component"),h=Object(m.pick)(l.cfg,Object(m.difference)(Object(m.keys)(l.cfg),Y));c.update(h),s.set("update_status","update")}else{var f=i.getReplaceAttrs(s,t);r&&o.update?i.updateAnimation(u,s,f,o.update):s.attr(f),t.isGroup()&&i.updateElements(t,s),Object(m.each)(G,(function(e){s.set(e,t.get(e))})),function(t,e){if(t.getClip()||e.getClip()){var n=e.getClip();if(n){var i={type:n.get("type"),attrs:n.attr()};t.setClip(i)}else t.setClip(null)}}(s,t),n=s,s.set("update_status","update")}else{e.add(t);var p=e.getChildren();if(p.splice(p.length-1,1),n){var d=p.indexOf(n);p.splice(d+1,0,t)}else p.unshift(t);if(i.registerElement(t),t.set("update_status","add"),t.get("isComponent"))(l=t.get("component")).set("container",e);else t.isGroup()&&i.registerNewGroup(t);if(n=t,r){var g=i.get("isInit")?o.appear:o.enter;g&&i.addAnimation(u,t,g)}}}))},e.prototype.clearUpdateStatus=function(t){var e=t.getChildren();Object(m.each)(e,(function(t){t.set("update_status",null)}))},e.prototype.clearOffScreenCache=function(){var t=this.get("offScreenGroup");t&&t.destroy(),this.set("offScreenGroup",null),this.set("offScreenBBox",null)},e.prototype.getDelegateObject=function(){var t;return(t={})[this.get("name")]=this,t.component=this,t},e.prototype.appendDelegateObject=function(t,e){var n=t.get("delegateObject");e.delegateObject||(e.delegateObject={}),Object(m.mix)(e.delegateObject,n)},e.prototype.getReplaceAttrs=function(t,e){var n=t.attr(),i=e.attr();return Object(m.each)(n,(function(t,e){void 0===i[e]&&(i[e]=void 0)})),i},e.prototype.registerNewGroup=function(t){var e=this,n=t.getChildren();Object(m.each)(n,(function(t){e.registerElement(t),t.set("update_status","add"),t.isGroup()&&e.registerNewGroup(t)}))},e.prototype.deleteElements=function(){var t=this,e=this.get("shapesMap"),n=[];Object(m.each)(e,(function(t,e){!t.get("update_status")||t.destroyed?n.push([e,t]):t.set("update_status",null)}));var i=this.get("animate"),r=this.get("animateOption");Object(m.each)(n,(function(n){var o=n[0],a=n[1];if(!a.destroyed){var s=a.get("name");if(i&&r.leave){var u=Object(m.mix)({callback:function(){t.removeElement(a)}},r.leave);t.removeAnimation(s,a,u)}else t.removeElement(a)}delete e[o]}))},e.prototype.removeElement=function(t){if(t.get("isGroup")){var e=t.get("component");e&&e.destroy()}t.remove()},e}(N);function X(t,e){return t.charCodeAt(e)>0&&t.charCodeAt(e)<128?1:2}function z(t){var e=0;return Object(m.each)(t,(function(t){var n=t.getBBox().width;e=0?function(t,e,n){void 0===n&&(n="tail");var i=t.length,r="";if("tail"===n){for(var o=0,a=0;o1||i<0)&&(i=1),{x:j(t.x,e.x,i),y:j(t.y,e.y,i)}},e.prototype.renderLabel=function(t){var e=this.get("text"),n=this.get("start"),i=this.get("end"),r=e.position,o=e.content,a=e.style,s=e.offsetX,u=e.offsetY,l=e.autoRotate,c=e.maxLength,h=e.autoEllipsis,f=e.ellipsisPosition,p=e.background,d=e.isVertical,g=void 0!==d&&d,y=this.getLabelPoint(n,i,r),v=y.x+s,m=y.y+u,x={id:this.getElementId("line-text"),name:"annotation-line-text",x:v,y:m,content:o,style:a,maxLength:c,autoEllipsis:h,ellipsisPosition:f,background:p,isVertical:g};if(l){var b=[i.x-n.x,i.y-n.y];x.rotate=Math.atan2(b[1],b[0])}W(t,x)},e}(V),Z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"text",locationType:"point",x:0,y:0,content:"",rotate:null,style:{},background:null,maxLength:null,autoEllipsis:!0,isVertical:!1,ellipsisPosition:"tail",defaultCfg:{style:{fill:q.textColor,fontSize:12,textAlign:"center",textBaseline:"middle",fontFamily:q.fontFamily}}})},e.prototype.setLocation=function(t){this.set("x",t.x),this.set("y",t.y),this.resetLocation()},e.prototype.renderInner=function(t){var e=this.getLocation(),n=e.x,i=e.y,r=this.get("content"),o=this.get("style");W(t,{id:this.getElementId("text"),name:this.get("name")+"-text",x:n,y:i,content:r,style:o,maxLength:this.get("maxLength"),autoEllipsis:this.get("autoEllipsis"),isVertical:this.get("isVertical"),ellipsisPosition:this.get("ellipsisPosition"),background:this.get("background"),rotate:this.get("rotate")})},e.prototype.resetLocation=function(){var t=this.getElementByLocalId("text-group");if(t){var e=this.getLocation(),n=e.x,i=e.y,r=this.get("rotate");A(t,n,i),S(t,r,n,i)}},e}(V),Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"arc",locationType:"circle",center:null,radius:100,startAngle:-Math.PI/2,endAngle:3*Math.PI/2,style:{stroke:"#999",lineWidth:1}})},e.prototype.renderInner=function(t){this.renderArc(t)},e.prototype.getArcPath=function(){var t=this.getLocation(),e=t.center,n=t.radius,i=t.startAngle,r=t.endAngle,o=L(e,n,i),a=L(e,n,r),s=r-i>Math.PI?1:0,u=[["M",o.x,o.y]];if(r-i==2*Math.PI){var l=L(e,n,i+Math.PI);u.push(["A",n,n,0,s,1,l.x,l.y]),u.push(["A",n,n,0,s,1,a.x,a.y])}else u.push(["A",n,n,0,s,1,a.x,a.y]);return u},e.prototype.renderArc=function(t){var e=this.getArcPath(),n=this.get("style");this.addShape(t,{type:"path",id:this.getElementId("arc"),name:"annotation-arc",attrs:y({path:e},n)})},e}(V),K=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"region",locationType:"region",start:null,end:null,style:{},defaultCfg:{style:{lineWidth:0,fill:q.regionColor,opacity:.4}}})},e.prototype.renderInner=function(t){this.renderRegion(t)},e.prototype.renderRegion=function(t){var e=this.get("start"),n=this.get("end"),i=this.get("style"),r=T({start:e,end:n});this.addShape(t,{type:"rect",id:this.getElementId("region"),name:"annotation-region",attrs:y({x:r.x,y:r.y,width:r.width,height:r.height},i)})},e}(V),$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"image",locationType:"region",start:null,end:null,src:null,style:{}})},e.prototype.renderInner=function(t){this.renderImage(t)},e.prototype.getImageAttrs=function(){var t=this.get("start"),e=this.get("end"),n=this.get("style"),i=T({start:t,end:e}),r=this.get("src");return y({x:i.x,y:i.y,img:r,width:i.width,height:i.height},n)},e.prototype.renderImage=function(t){this.addShape(t,{type:"image",id:this.getElementId("image"),name:"annotation-image",attrs:this.getImageAttrs()})},e}(V),J=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"dataMarker",locationType:"point",x:0,y:0,point:{},line:{},text:{},direction:"upward",autoAdjust:!0,coordinateBBox:null,defaultCfg:{point:{display:!0,style:{r:3,fill:"#FFFFFF",stroke:"#1890FF",lineWidth:2}},line:{display:!0,length:20,style:{stroke:q.lineColor,lineWidth:1}},text:{content:"",display:!0,style:{fill:q.textColor,opacity:.65,fontSize:12,textAlign:"start",fontFamily:q.fontFamily}}}})},e.prototype.renderInner=function(t){Object(m.get)(this.get("line"),"display")&&this.renderLine(t),Object(m.get)(this.get("text"),"display")&&this.renderText(t),Object(m.get)(this.get("point"),"display")&&this.renderPoint(t),this.get("autoAdjust")&&this.autoAdjust(t)},e.prototype.applyOffset=function(){this.moveElementTo(this.get("group"),{x:this.get("x")+this.get("offsetX"),y:this.get("y")+this.get("offsetY")})},e.prototype.renderPoint=function(t){var e=this.getShapeAttrs().point;this.addShape(t,{type:"circle",id:this.getElementId("point"),name:"annotation-point",attrs:e})},e.prototype.renderLine=function(t){var e=this.getShapeAttrs().line;this.addShape(t,{type:"path",id:this.getElementId("line"),name:"annotation-line",attrs:e})},e.prototype.renderText=function(t){var e=this.getShapeAttrs().text,n=e.x,i=e.y,r=e.text,o=v(e,["x","y","text"]),a=this.get("text"),s=a.background,u=a.maxLength,l=a.autoEllipsis,c=a.isVertival,h=a.ellipsisPosition;W(t,{x:n,y:i,id:this.getElementId("text"),name:"annotation-text",content:r,style:o,background:s,maxLength:u,autoEllipsis:l,isVertival:c,ellipsisPosition:h})},e.prototype.autoAdjust=function(t){var e=this.get("direction"),n=this.get("x"),i=this.get("y"),r=Object(m.get)(this.get("line"),"length",0),o=this.get("coordinateBBox"),a=t.getBBox(),s=a.minX,u=a.maxX,l=a.minY,c=a.maxY,h=t.findById(this.getElementId("text-group")),f=t.findById(this.getElementId("text")),p=t.findById(this.getElementId("line"));if(o){if(h){if(n+s<=o.minX){var d=o.minX-(n+s);A(h,h.attr("x")+d,h.attr("y"))}if(n+u>=o.maxX){d=n+u-o.maxX;A(h,h.attr("x")-d,h.attr("y"))}}if("upward"===e&&i+l<=o.minY||"upward"!==e&&i+c>=o.maxY){var g=void 0,y=void 0;"upward"===e&&i+l<=o.minY?(g="top",y=1):(g="bottom",y=-1),f.attr("textBaseline",g),p&&p.attr("path",[["M",0,0],["L",0,r*y]]),A(h,h.attr("x"),(r+2)*y)}}},e.prototype.getShapeAttrs=function(){var t=Object(m.get)(this.get("line"),"display"),e=Object(m.get)(this.get("point"),"style",{}),n=Object(m.get)(this.get("line"),"style",{}),i=Object(m.get)(this.get("text"),"style",{}),r=this.get("direction"),o=t?Object(m.get)(this.get("line"),"length",0):0,a="upward"===r?-1:1;return{point:y({x:0,y:0},e),line:y({path:[["M",0,0],["L",0,o*a]]},n),text:y({x:0,y:(o+2)*a,text:Object(m.get)(this.get("text"),"content",""),textBaseline:"upward"===r?"bottom":"top"},i)}},e}(V),tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"dataRegion",locationType:"points",points:[],lineLength:0,region:{},text:{},defaultCfg:{region:{style:{lineWidth:0,fill:q.regionColor,opacity:.4}},text:{content:"",style:{textAlign:"center",textBaseline:"bottom",fontSize:12,fill:q.textColor,fontFamily:q.fontFamily}}}})},e.prototype.renderInner=function(t){var e=Object(m.get)(this.get("region"),"style",{}),n=(Object(m.get)(this.get("text"),"style",{}),this.get("lineLength")||0),i=this.get("points");if(i.length){var r=function(t){var e=t.map((function(t){return t.x})),n=t.map((function(t){return t.y})),i=Math.min.apply(Math,e),r=Math.min.apply(Math,n),o=Math.max.apply(Math,e),a=Math.max.apply(Math,n);return{x:i,y:r,minX:i,minY:r,maxX:o,maxY:a,width:o-i,height:a-r}}(i),o=[];o.push(["M",i[0].x,r.minY-n]),i.forEach((function(t){o.push(["L",t.x,t.y])})),o.push(["L",i[i.length-1].x,i[i.length-1].y-n]),this.addShape(t,{type:"path",id:this.getElementId("region"),name:"annotation-region",attrs:y({path:o},e)}),W(t,y({id:this.getElementId("text"),name:"annotation-text",x:(r.minX+r.maxX)/2,y:r.minY-n},this.get("text")))}},e}(V),et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"annotation",type:"regionFilter",locationType:"region",start:null,end:null,color:null,shape:[]})},e.prototype.renderInner=function(t){var e=this,n=this.get("start"),i=this.get("end"),r=this.addGroup(t,{id:this.getElementId("region-filter"),capture:!1});Object(m.each)(this.get("shapes"),(function(t,n){var i=t.get("type"),o=Object(m.clone)(t.attr());e.adjustShapeAttrs(o),e.addShape(r,{id:e.getElementId("shape-"+i+"-"+n),capture:!1,type:i,attrs:o})}));var o=T({start:n,end:i});r.setClip({type:"rect",attrs:{x:o.minX,y:o.minY,width:o.width,height:o.height}})},e.prototype.adjustShapeAttrs=function(t){var e=this.get("color");t.fill&&(t.fill=t.fillStyle=e),t.stroke=t.strokeStyle=e},e}(V);function nt(t,e,n){var i=e+"Style",r=null;return Object(m.each)(n,(function(e,n){t[n]&&e[i]&&(r||(r={}),Object(m.mix)(r,e[i]))})),r}var it=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"axis",ticks:[],line:{},tickLine:{},subTickLine:null,title:null,label:{},verticalFactor:1,verticalLimitLength:null,overlapOrder:["autoRotate","autoEllipsis","autoHide"],tickStates:{},defaultCfg:{line:{style:{lineWidth:1,stroke:q.lineColor}},tickLine:{style:{lineWidth:1,stroke:q.lineColor},alignTick:!0,length:5,displayWithLabel:!0},subTickLine:{style:{lineWidth:1,stroke:q.lineColor},count:4,length:2},label:{autoRotate:!0,autoHide:!1,autoEllipsis:!1,style:{fontSize:12,fill:q.textColor,textBaseline:"middle",fontFamily:q.fontFamily,fontWeight:"normal"},offset:10},title:{autoRotate:!0,spacing:5,position:"center",style:{fontSize:12,fill:q.textColor,textBaseline:"middle",fontFamily:q.fontFamily,textAlign:"center"}},tickStates:{active:{labelStyle:{fontWeight:500},tickLineStyle:{lineWidth:2}},inactive:{labelStyle:{fill:q.uncheckedColor}}}}})},e.prototype.renderInner=function(t){this.get("line")&&this.drawLine(t),this.drawTicks(t),this.get("title")&&this.drawTitle(t)},e.prototype.isList=function(){return!0},e.prototype.getItems=function(){return this.get("ticks")},e.prototype.setItems=function(t){this.update({ticks:t})},e.prototype.updateItem=function(t,e){Object(m.mix)(t,e),this.clear(),this.render()},e.prototype.clearItems=function(){var t=this.getElementByLocalId("label-group");t&&t.clear()},e.prototype.setItemState=function(t,e,n){t[e]=n,this.updateTickStates(t)},e.prototype.hasState=function(t,e){return!!t[e]},e.prototype.getItemStates=function(t){var e=this.get("tickStates"),n=[];return Object(m.each)(e,(function(e,i){t[i]&&n.push(i)})),n},e.prototype.clearItemsState=function(t){var e=this,n=this.getItemsByState(t);Object(m.each)(n,(function(n){e.setItemState(n,t,!1)}))},e.prototype.getItemsByState=function(t){var e=this,n=this.getItems();return Object(m.filter)(n,(function(n){return e.hasState(n,t)}))},e.prototype.getSidePoint=function(t,e){var n=this.getSideVector(e,t);return{x:t.x+n[0],y:t.y+n[1]}},e.prototype.getTextAnchor=function(t){var e;return Object(m.isNumberEqual)(t[0],0)?e="center":t[0]>0?e="start":t[0]<0&&(e="end"),e},e.prototype.processOverlap=function(t){},e.prototype.drawLine=function(t){var e=this.getLinePath(),n=this.get("line");this.addShape(t,{type:"path",id:this.getElementId("line"),name:"axis-line",attrs:Object(m.mix)({path:e},n.style)})},e.prototype.getTickLineItems=function(t){var e=this,n=[],i=this.get("tickLine"),r=i.alignTick,o=i.length,a=1;return t.length>=2&&(a=t[1].value-t[0].value),Object(m.each)(t,(function(t){var i=t.point;r||(i=e.getTickPoint(t.value-a/2));var s=e.getSidePoint(i,o);n.push({startPoint:i,tickValue:t.value,endPoint:s,tickId:t.id,id:"tickline-"+t.id})})),n},e.prototype.getSubTickLineItems=function(t){var e=[],n=this.get("subTickLine"),i=n.count,r=t.length;if(r>=2)for(var o=0;o1){l=Math.ceil(l);for(var h=0;hn:a=o>Math.abs(r[1].attr("x")-r[0].attr("x"));a&&function(t,e){Object(m.each)(t,(function(t){var n=C({x:t.attr("x"),y:t.attr("y")},e);t.attr("matrix",n)}))}(r,i(n,o));return a}function mt(){return xt}function xt(t,e,n){return vt(t,e,n,(function(){return t?q.verticalAxisRotate:q.horizontalAxisRotate}))}function bt(t,e,n){return vt(t,e,n,(function(e,n){if(!e)return t?q.verticalAxisRotate:q.horizontalAxisRotate;if(t)return-Math.acos(e/n);var i=0;return(e>n||(i=Math.asin(e/n))>Math.PI/4)&&(i=Math.PI/4),i}))}var _t,Mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"line",locationType:"region",start:null,end:null})},e.prototype.getLinePath=function(){var t=this.get("start"),e=this.get("end"),n=[];return n.push(["M",t.x,t.y]),n.push(["L",e.x,e.y]),n},e.prototype.getInnerLayoutBBox=function(){var e=this.get("start"),n=this.get("end"),i=t.prototype.getInnerLayoutBBox.call(this),r=Math.min(e.x,n.x,i.x),o=Math.min(e.y,n.y,i.y),a=Math.max(e.x,n.x,i.maxX),s=Math.max(e.y,n.y,i.maxY);return{x:r,y:o,minX:r,minY:o,maxX:a,maxY:s,width:a-r,height:s-o}},e.prototype.isVertical=function(){var t=this.get("start"),e=this.get("end");return Object(m.isNumberEqual)(t.x,e.x)},e.prototype.isHorizontal=function(){var t=this.get("start"),e=this.get("end");return Object(m.isNumberEqual)(t.y,e.y)},e.prototype.getTickPoint=function(t){var e=this.get("start"),n=this.get("end"),i=n.x-e.x,r=n.y-e.y;return{x:e.x+i*t,y:e.y+r*t}},e.prototype.getSideVector=function(t){var e=this.getAxisVector(),n=_.vec2.normalize([0,0],e),i=this.get("verticalFactor"),r=[n[1],-1*n[0]];return _.vec2.scale([0,0],r,t*i)},e.prototype.getAxisVector=function(){var t=this.get("start"),e=this.get("end");return[e.x-t.x,e.y-t.y]},e.prototype.processOverlap=function(t){var e=this,n=this.isVertical(),i=this.isHorizontal();if(n||i){var r=this.get("label"),o=this.get("title"),a=this.get("verticalLimitLength"),s=r.offset,u=a,l=0,c=0;o&&(l=o.style.fontSize,c=o.spacing),u&&(u=u-s-c-l);var h=this.get("overlapOrder");if(Object(m.each)(h,(function(n){r[n]&&e.autoProcessOverlap(n,r[n],t,u)})),o){var f=t.getBBox(),p=n?f.width:f.height;Object(m.isNil)(o.offset)&&(o.offset=s+p+c+l/2)}}},e.prototype.autoProcessOverlap=function(t,e,n,i){var r=this,o=this.isVertical(),a=!1,u=s[t];if(!0===e?a=u.getDefault()(o,n,i):Object(m.isFunction)(e)?a=e(o,n,i):u[e]&&(a=u[e](o,n,i)),"autoRotate"===t){if(a){var l=n.getChildren(),c=this.get("verticalFactor");Object(m.each)(l,(function(t){if("center"===t.attr("textAlign")){var e=c>0?"end":"start";t.attr("textAlign",e)}}))}}else if("autoHide"===t){var h=n.getChildren().slice(0);Object(m.each)(h,(function(t){t.get("visible")||(r.get("isRegister")&&r.unregisterElement(t),t.remove())}))}},e}(it),Ct=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"circle",locationType:"circle",center:null,radius:null,startAngle:-Math.PI/2,endAngle:3*Math.PI/2})},e.prototype.getLinePath=function(){var t=this.get("center"),e=t.x,n=t.y,i=this.get("radius"),r=i,o=this.get("startAngle"),a=this.get("endAngle"),s=[];if(Math.abs(a-o)===2*Math.PI)s=[["M",e,n-r],["A",i,r,0,1,1,e,n+r],["A",i,r,0,1,1,e,n-r],["Z"]];else{var u=this.getCirclePoint(o),l=this.getCirclePoint(a),c=Math.abs(a-o)>Math.PI?1:0,h=o>a?0:1;s=[["M",e,n],["L",u.x,u.y],["A",i,r,0,c,h,l.x,l.y],["L",e,n]]}return s},e.prototype.getTickPoint=function(t){var e=this.get("startAngle"),n=e+(this.get("endAngle")-e)*t;return this.getCirclePoint(n)},e.prototype.getSideVector=function(t,e){var n=this.get("center"),i=[e.x-n.x,e.y-n.y],r=this.get("verticalFactor"),o=_.vec2.length(i);return _.vec2.scale(i,i,r*t/o),i},e.prototype.getAxisVector=function(t){var e=this.get("center"),n=[t.x-e.x,t.y-e.y];return[n[1],-1*n[0]]},e.prototype.getCirclePoint=function(t,e){var n=this.get("center");return e=e||this.get("radius"),{x:n.x+Math.cos(t)*e,y:n.y+Math.sin(t)*e}},e}(it),wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"crosshair",type:"base",line:{},text:null,textBackground:{},capture:!1,defaultCfg:{line:{style:{lineWidth:1,stroke:q.lineColor}},text:{position:"start",offset:10,autoRotate:!1,content:null,style:{fill:q.textColor,textAlign:"center",textBaseline:"middle",fontFamily:q.fontFamily}},textBackground:{padding:5,style:{stroke:q.lineColor}}}})},e.prototype.renderInner=function(t){this.get("line")&&this.renderLine(t),this.get("text")&&(this.renderText(t),this.renderBackground(t))},e.prototype.renderText=function(t){var e=this.get("text"),n=e.style,i=e.autoRotate,r=e.content;if(!Object(m.isNil)(r)){var o=this.getTextPoint(),a=null;if(i)a=C(o,this.getRotateAngle());this.addShape(t,{type:"text",name:"crosshair-text",id:this.getElementId("text"),attrs:y(y(y({},o),{text:r,matrix:a}),n)})}},e.prototype.renderLine=function(t){var e=this.getLinePath(),n=this.get("line").style;this.addShape(t,{type:"path",name:"crosshair-line",id:this.getElementId("line"),attrs:y({path:e},n)})},e.prototype.renderBackground=function(t){var e=this.getElementId("text"),n=t.findById(e),i=this.get("textBackground");if(i&&n){var r=n.getBBox(),o=P(i.padding),a=i.style;this.addShape(t,{type:"rect",name:"crosshair-text-background",id:this.getElementId("text-background"),attrs:y({x:r.x-o[3],y:r.y-o[0],width:r.width+o[1]+o[3],height:r.height+o[0]+o[2],matrix:n.attr("matrix")},a)}).toBack()}},e}(V),Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"line",locationType:"region",start:null,end:null})},e.prototype.getRotateAngle=function(){var t=this.getLocation(),e=t.start,n=t.end,i=this.get("text").position,r=Math.atan2(n.y-e.y,n.x-e.x);return"start"===i?r-Math.PI/2:r+Math.PI/2},e.prototype.getTextPoint=function(){var t=this.getLocation(),e=t.start,n=t.end,i=this.get("text");return D(e,n,i.position,i.offset)},e.prototype.getLinePath=function(){var t=this.getLocation(),e=t.start,n=t.end;return[["M",e.x,e.y],["L",n.x,n.y]]},e}(wt),St=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"circle",locationType:"circle",center:null,radius:100,startAngle:-Math.PI/2,endAngle:3*Math.PI/2})},e.prototype.getRotateAngle=function(){var t=this.getLocation(),e=t.startAngle,n=t.endAngle;return"start"===this.get("text").position?e+Math.PI/2:n-Math.PI/2},e.prototype.getTextPoint=function(){var t=this.get("text"),e=t.position,n=t.offset,i=this.getLocation(),r=i.center,o=i.radius,a=i.startAngle,s=i.endAngle,u="start"===e?a:s,l=this.getRotateAngle()-Math.PI,c=L(r,o,u),h=Math.cos(l)*n,f=Math.sin(l)*n;return{x:c.x+h,y:c.y+f}},e.prototype.getLinePath=function(){var t=this.getLocation(),e=t.center,n=t.radius,i=t.startAngle,r=t.endAngle,o=null;if(r-i==2*Math.PI){var a=e.x,s=e.y;o=[["M",a,s-n],["A",n,n,0,1,1,a,s+n],["A",n,n,0,1,1,a,s-n],["Z"]]}else{var u=L(e,n,i),l=L(e,n,r),c=Math.abs(r-i)>Math.PI?1:0,h=i>r?0:1;o=[["M",u.x,u.y],["A",n,n,0,c,h,l.x,l.y]]}return o},e}(wt),At=n(5),Pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{container:null,containerTpl:"
",updateAutoRender:!0,containerClassName:"",parent:null})},e.prototype.getContainer=function(){return this.get("container")},e.prototype.show=function(){this.get("container").style.display="",this.set("visible",!0)},e.prototype.hide=function(){this.get("container").style.display="none",this.set("visible",!1)},e.prototype.setCapture=function(t){var e=t?"auto":"none";this.getContainer().style.pointerEvents=e,this.set("capture",t)},e.prototype.getBBox=function(){var t=this.getContainer();return E(parseFloat(t.style.left)||0,parseFloat(t.style.top)||0,t.clientWidth,t.clientHeight)},e.prototype.clear=function(){I(this.get("container"))},e.prototype.destroy=function(){this.removeEvent(),this.removeDom(),t.prototype.destroy.call(this)},e.prototype.init=function(){t.prototype.init.call(this),this.initContainer(),this.initDom(),this.resetStyles(),this.applyStyles(),this.initEvent(),this.initCapture(),this.initVisible()},e.prototype.initCapture=function(){this.setCapture(this.get("capture"))},e.prototype.initVisible=function(){this.get("visible")?this.show():this.hide()},e.prototype.initDom=function(){},e.prototype.initContainer=function(){var t=this.get("container");if(Object(m.isNil)(t)){t=this.createDom();var e=this.get("parent");Object(m.isString)(e)&&(e=document.getElementById(e),this.set("parent",e)),e.appendChild(t),this.set("container",t)}else Object(m.isString)(t)&&(t=document.getElementById(t),this.set("container",t));this.get("parent")||this.set("parent",t.parentNode)},e.prototype.resetStyles=function(){var t=this.get("domStyles"),e=this.get("defaultStyles");t=t?Object(m.deepMix)({},e,t):e,this.set("domStyles",t)},e.prototype.applyStyles=function(){var t=this.get("domStyles");if(t){var e=this.getContainer();this.applyChildrenStyles(e,t);var n,i=this.get("containerClassName");if(i&&(n=i,e.className.match(new RegExp("(\\s|^)"+n+"(\\s|$)")))){var r=t[i];Object(At.modifyCSS)(e,r)}}},e.prototype.applyChildrenStyles=function(t,e){Object(m.each)(e,(function(e,n){var i=t.getElementsByClassName(n);Object(m.each)(i,(function(t){Object(At.modifyCSS)(t,e)}))}))},e.prototype.applyStyle=function(t,e){var n=this.get("domStyles");Object(At.modifyCSS)(e,n[t])},e.prototype.createDom=function(){var t=this.get("containerTpl");return Object(At.createDom)(t)},e.prototype.initEvent=function(){},e.prototype.removeDom=function(){var t=this.get("container");t&&t.parentNode.removeChild(t)},e.prototype.removeEvent=function(){},e.prototype.updateInner=function(t){Object(m.hasKey)(t,"domStyles")&&(this.resetStyles(),this.applyStyles()),this.resetPosition()},e.prototype.resetPosition=function(){},e}(N),It=((_t={})["g2-crosshair"]={position:"relative"},_t["g2-crosshair-line"]={position:"absolute",backgroundColor:"rgba(0, 0, 0, 0.25)"},_t["g2-crosshair-text"]={position:"absolute",color:q.textColor,fontFamily:q.fontFamily},_t),Tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"crosshair",type:"html",locationType:"region",start:{x:0,y:0},end:{x:0,y:0},capture:!1,text:null,containerTpl:'
',crosshairTpl:'
',textTpl:'{content}',domStyles:null,containerClassName:"g2-crosshair",defaultStyles:It,defaultCfg:{text:{position:"start",content:null,align:"center",offset:10}}})},e.prototype.render=function(){this.resetText(),this.resetPosition()},e.prototype.initCrossHair=function(){var t=this.getContainer(),e=this.get("crosshairTpl"),n=Object(At.createDom)(e);t.appendChild(n),this.applyStyle("g2-crosshair-line",n),this.set("crosshairEl",n)},e.prototype.getTextPoint=function(){var t=this.getLocation(),e=t.start,n=t.end,i=this.get("text");return D(e,n,i.position,i.offset)},e.prototype.resetText=function(){var t=this.get("text"),e=this.get("textEl");if(t){var n=t.content;if(!e){var i=this.getContainer(),r=Object(m.substitute)(this.get("textTpl"),t);e=Object(At.createDom)(r),i.appendChild(e),this.applyStyle("g2-crosshair-text",e),this.set("textEl",e)}e.innerHTML=n}else e&&e.remove()},e.prototype.isVertical=function(t,e){return t.x===e.x},e.prototype.resetPosition=function(){var t=this.get("crosshairEl");t||(this.initCrossHair(),t=this.get("crosshairEl"));var e=this.get("start"),n=this.get("end"),i=Math.min(e.x,n.x),r=Math.min(e.y,n.y);this.isVertical(e,n)?Object(At.modifyCSS)(t,{width:"1px",height:B(Math.abs(n.y-e.y))}):Object(At.modifyCSS)(t,{height:"1px",width:B(Math.abs(n.x-e.x))}),Object(At.modifyCSS)(t,{top:B(r),left:B(i)}),this.alignText()},e.prototype.alignText=function(){var t=this.get("textEl");if(t){var e=this.get("text").align,n=t.clientWidth,i=this.getTextPoint();switch(e){case"center":i.x=i.x-n/2;break;case"right":i.x=i.x-n}Object(At.modifyCSS)(t,{top:B(i.y),left:B(i.x)})}},e.prototype.updateInner=function(e){Object(m.hasKey)(e,"text")&&this.resetText(),t.prototype.updateInner.call(this,e)},e}(Pt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"grid",line:{},alternateColor:null,capture:!1,items:[],closed:!1,defaultCfg:{line:{type:"line",style:{lineWidth:1,stroke:q.lineColor}}}})},e.prototype.getLineType=function(){return(this.get("line")||this.get("defaultCfg").line).type},e.prototype.renderInner=function(t){this.drawGrid(t)},e.prototype.getAlternatePath=function(t,e){var n=this.getGridPath(t),i=e.slice(0).reverse(),r=this.getGridPath(i,!0);return this.get("closed")?n=n.concat(r):(r[0][0]="L",(n=n.concat(r)).push(["Z"])),n},e.prototype.getPathStyle=function(){return this.get("line").style},e.prototype.drawGrid=function(t){var e=this,n=this.get("line"),i=this.get("items"),r=this.get("alternateColor"),o=null;Object(m.each)(i,(function(i,a){var s=i.id||a;if(n){var u=e.getPathStyle(),l=e.getElementId("line-"+s),c=e.getGridPath(i.points);e.addShape(t,{type:"path",name:"grid-line",id:l,attrs:Object(m.mix)({path:c},u)})}if(r&&a>0){var h=e.getElementId("region-"+s),f=a%2==0;if(Object(m.isString)(r))f&&e.drawAlternateRegion(h,t,o.points,i.points,r);else{var p=f?r[1]:r[0];e.drawAlternateRegion(h,t,o.points,i.points,p)}}o=i}))},e.prototype.drawAlternateRegion=function(t,e,n,i,r){var o=this.getAlternatePath(n,i);this.addShape(e,{type:"path",id:t,name:"grid-region",attrs:{path:o,fill:r}})},e}(V);var jt,Lt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"circle",center:null,closed:!0})},e.prototype.getGridPath=function(t,e){var n,i,r,o,a,s,u=this.getLineType(),l=this.get("closed"),c=[];if(t.length)if("circle"===u){var h=this.get("center"),f=t[0],p=(n=h.x,i=h.y,r=f.x,o=f.y,a=r-n,s=o-i,Math.sqrt(a*a+s*s)),d=e?0:1;l?(c.push(["M",h.x,h.y-p]),c.push(["A",p,p,0,0,d,h.x,h.y+p]),c.push(["A",p,p,0,0,d,h.x,h.y-p]),c.push(["Z"])):Object(m.each)(t,(function(t,e){0===e?c.push(["M",t.x,t.y]):c.push(["A",p,p,0,0,d,t.x,t.y])}))}else Object(m.each)(t,(function(t,e){0===e?c.push(["M",t.x,t.y]):c.push(["L",t.x,t.y])})),l&&c.push(["Z"]);return c},e}(Et),kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"line"})},e.prototype.getGridPath=function(t){var e=[];return Object(m.each)(t,(function(t,n){0===n?e.push(["M",t.x,t.y]):e.push(["L",t.x,t.y])})),e},e}(Et),Bt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"legend",layout:"horizontal",locationType:"point",x:0,y:0,offsetX:0,offsetY:0,title:null,background:null})},e.prototype.getLayoutBBox=function(){var e=t.prototype.getLayoutBBox.call(this),n=this.get("x"),i=this.get("y"),r=this.get("offsetX"),o=this.get("offsetY"),a=this.get("maxWidth"),s=this.get("maxHeight"),u=n+r,l=i+o,c=e.maxX-u,h=e.maxY-l;return a&&(c=Math.min(c,a)),s&&(h=Math.min(h,s)),E(u,l,c,h)},e.prototype.setLocation=function(t){this.set("x",t.x),this.set("y",t.y),this.resetLocation()},e.prototype.resetLocation=function(){var t=this.get("x"),e=this.get("y"),n=this.get("offsetX"),i=this.get("offsetY");this.moveElementTo(this.get("group"),{x:t+n,y:e+i})},e.prototype.applyOffset=function(){this.resetLocation()},e.prototype.getDrawPoint=function(){return this.get("currentPoint")},e.prototype.setDrawPoint=function(t){return this.set("currentPoint",t)},e.prototype.renderInner=function(t){this.resetDraw(),this.get("title")&&this.drawTitle(t),this.drawLegendContent(t),this.get("background")&&this.drawBackground(t)},e.prototype.drawBackground=function(t){var e=this.get("background"),n=t.getBBox(),i=P(e.padding),r=y({x:0,y:0,width:n.width+i[1]+i[3],height:n.height+i[0]+i[2]},e.style);this.addShape(t,{type:"rect",id:this.getElementId("background"),name:"legend-background",attrs:r}).toBack()},e.prototype.drawTitle=function(t){var e=this.get("currentPoint"),n=this.get("title"),i=n.spacing,r=n.style,o=n.text,a=this.addShape(t,{type:"text",id:this.getElementId("title"),name:"legend-title",attrs:y({text:o,x:e.x,y:e.y},r)}).getBBox();this.set("currentPoint",{x:e.x,y:a.maxY+i})},e.prototype.resetDraw=function(){var t=this.get("background"),e={x:0,y:0};if(t){var n=P(t.padding);e.x=n[3],e.y=n[0]}this.set("currentPoint",e)},e}(V),Dt=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.currentPageIndex=1,e.totalPagesCnt=1,e.pageWidth=0,e.pageHeight=0,e.startX=0,e.startY=0,e.onNavigationBack=function(){var t=e.getElementByLocalId("item-group");if(e.currentPageIndex>1){e.currentPageIndex-=1,e.updateNavigation();var n=e.getCurrentNavigationMatrix();e.get("animate")?t.animate({matrix:n},100):t.attr({matrix:n})}},e.onNavigationAfter=function(){var t=e.getElementByLocalId("item-group");if(e.currentPageIndexp&&(p=v),"horizontal"===c?(d&&dv&&(v=e.width)})),x=v,v+=c,s&&(v=Math.min(s,v),x=Math.min(s,x)),this.pageWidth=v,this.pageHeight=u-Math.max(p.height,h);var b=Math.floor(this.pageHeight/h);Object(m.each)(a,(function(t,e){0!==e&&e%b==0&&(g+=1,d.x+=v,d.y=r),n.moveElementTo(t,d),t.getParent().setClip({type:"rect",attrs:{x:d.x,y:d.y,width:v,height:h}}),d.y+=h})),this.totalPagesCnt=g,this.moveElementTo(f,{x:i+x/2-p.width/2-p.minX,y:u-p.height-p.minY})}this.pageHeight&&this.pageWidth&&e.getParent().setClip({type:"rect",attrs:{x:this.startX,y:this.startY,width:this.pageWidth,height:this.pageHeight}}),this.totalPagesCnt=g,this.currentPageIndex>this.totalPagesCnt&&(this.currentPageIndex=1),this.updateNavigation(f),e.attr("matrix",this.getCurrentNavigationMatrix())},e.prototype.drawNavigation=function(t,e,n,i){var r={x:0,y:0},o=this.addGroup(t,{id:this.getElementId("navigation-group"),name:"legend-navigation"}),a=this.drawArrow(o,r,"navigation-arrow-left","horizontal"===e?"up":"left",i);a.on("click",this.onNavigationBack);var s=a.getBBox();r.x+=s.width+2;var u=this.addShape(o,{type:"text",id:this.getElementId("navigation-text"),name:"navigation-text",attrs:{x:r.x,y:r.y+i/2,text:n,fontSize:12,fill:"#ccc",textBaseline:"middle"}}).getBBox();return r.x+=u.width+2,this.drawArrow(o,r,"navigation-arrow-right","horizontal"===e?"down":"right",i).on("click",this.onNavigationAfter),o},e.prototype.updateNavigation=function(t){var e=this.currentPageIndex+"/"+this.totalPagesCnt,n=t?t.getChildren()[1]:this.getElementByLocalId("navigation-text"),i=t?t.findById(this.getElementId("navigation-arrow-left")):this.getElementByLocalId("navigation-arrow-left"),r=t?t.findById(this.getElementId("navigation-arrow-right")):this.getElementByLocalId("navigation-arrow-right"),o=n.getBBox();n.attr("text",e);var a=n.getBBox();n.attr("x",n.attr("x")-(a.width-o.width)/2),i.attr("opacity",1===this.currentPageIndex?.45:1),i.attr("cursor",1===this.currentPageIndex?"not-allowed":"pointer"),r.attr("opacity",this.currentPageIndex===this.totalPagesCnt?.45:1),r.attr("cursor",this.currentPageIndex===this.totalPagesCnt?"not-allowed":"pointer")},e.prototype.drawArrow=function(t,e,n,i,r){var o=e.x,a=e.y,s={right:90*Math.PI/180,left:270*Math.PI/180,up:0,down:180*Math.PI/180},u=this.addShape(t,{type:"path",id:this.getElementId(n),name:n,attrs:{path:[["M",o+r/2,a],["L",o,a+r],["L",o+r,a+r],["Z"]],fill:"#000",cursor:"pointer"}});return u.attr("matrix",C({x:o+r/2,y:a+r/2},s[i])),u},e.prototype.getCurrentNavigationMatrix=function(){var t=this.currentPageIndex,e=this.pageWidth,n=this.pageHeight;return w("horizontal"===this.get("layout")?{x:0,y:n*(1-t)}:{x:e*(1-t),y:0})},e.prototype.applyItemStates=function(t,e){if(this.getItemStates(t).length>0){var n=e.getChildren(),i=this.get("itemStates");Object(m.each)(n,(function(e){var n=e.get("name").split("-")[2],r=nt(t,n,i);r&&(e.attr(r),"marker"!==n||e.get("isStroke")&&e.get("isFill")||(e.get("isStroke")&&e.attr("fill",null),e.get("isFill")&&e.attr("stroke",null)))}))}},e.prototype.getLimitItemWidth=function(){var t=this.get("itemWidth"),e=this.get("maxItemWidth");return e?t&&(e=t<=e?t:e):t&&(e=t),e},e}(Bt),Ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{type:"continue",min:0,max:100,value:null,colors:[],track:{},rail:{},label:{},handler:{},slidable:!0,tip:null,step:null,maxWidth:null,maxHeight:null,defaultCfg:{label:{align:"rail",spacing:5,formatter:null,style:{fontSize:12,fill:q.textColor,textBaseline:"middle",fontFamily:q.fontFamily}},handler:{size:10,style:{fill:"#fff",stroke:"#333"}},track:{},rail:{type:"color",size:20,defaultLength:100,style:{fill:"#DCDEE2"}},title:{spacing:5,style:{fill:q.textColor,fontSize:12,textAlign:"start",textBaseline:"top"}}}})},e.prototype.isSlider=function(){return!0},e.prototype.getValue=function(){return this.getCurrentValue()},e.prototype.getRange=function(){return{min:this.get("min"),max:this.get("max")}},e.prototype.setRange=function(t,e){this.update({min:t,max:e})},e.prototype.setValue=function(t){var e=this.getValue();this.set("value",t);var n=this.get("group");this.resetTrackClip(),this.get("slidable")&&this.resetHandlers(n),this.delegateEmit("valuechanged",{originValue:e,value:t})},e.prototype.initEvent=function(){var t=this.get("group");this.bindSliderEvent(t),this.bindRailEvent(t),this.bindTrackEvent(t)},e.prototype.drawLegendContent=function(t){this.drawRail(t),this.drawLabels(t),this.fixedElements(t),this.resetTrack(t),this.resetTrackClip(t),this.get("slidable")&&this.resetHandlers(t)},e.prototype.bindSliderEvent=function(t){this.bindHandlersEvent(t)},e.prototype.bindHandlersEvent=function(t){var e=this;t.on("legend-handler-min:drag",(function(t){var n=e.getValueByCanvasPoint(t.x,t.y),i=e.getCurrentValue()[1];in&&(i=n),e.setValue([i,n])}))},e.prototype.bindRailEvent=function(t){},e.prototype.bindTrackEvent=function(t){var e=this,n=null;t.on("legend-track:dragstart",(function(t){n={x:t.x,y:t.y}})),t.on("legend-track:drag",(function(t){if(n){var i=e.getValueByCanvasPoint(n.x,n.y),r=e.getValueByCanvasPoint(t.x,t.y),o=e.getCurrentValue(),a=o[1]-o[0],s=e.getRange(),u=r-i;u<0?o[0]+u>s.min?e.setValue([o[0]+u,o[1]+u]):e.setValue([s.min,s.min+a]):u>0&&(u>0&&o[1]+ur&&(u=r),u0&&this.changeRailLength(i,r,n[r]-l)}},e.prototype.changeRailLength=function(t,e,n){var i,r=t.getBBox();i="height"===e?this.getRailPath(r.x,r.y,r.width,n):this.getRailPath(r.x,r.y,n,r.height),t.attr("path",i)},e.prototype.changeRailPosition=function(t,e,n){var i=t.getBBox(),r=this.getRailPath(e,n,i.width,i.height);t.attr("path",r)},e.prototype.fixedHorizontal=function(t,e,n,i){var r=this.get("label"),o=r.align,a=r.spacing,s=n.getBBox(),u=t.getBBox(),l=e.getBBox(),c=s.height;this.fitRailLength(u,l,s,n),s=n.getBBox(),"rail"===o?(t.attr({x:i.x,y:i.y+c/2}),this.changeRailPosition(n,i.x+u.width+a,i.y),e.attr({x:i.x+u.width+s.width+2*a,y:i.y+c/2})):"top"===o?(t.attr({x:i.x,y:i.y}),e.attr({x:i.x+s.width,y:i.y}),this.changeRailPosition(n,i.x,i.y+u.height+a)):(this.changeRailPosition(n,i.x,i.y),t.attr({x:i.x,y:i.y+s.height+a}),e.attr({x:i.x+s.width,y:i.y+s.height+a}))},e.prototype.fixedVertail=function(t,e,n,i){var r=this.get("label"),o=r.align,a=r.spacing,s=n.getBBox(),u=t.getBBox(),l=e.getBBox();if(this.fitRailLength(u,l,s,n),s=n.getBBox(),"rail"===o)t.attr({x:i.x,y:i.y}),this.changeRailPosition(n,i.x,i.y+u.height+a),e.attr({x:i.x,y:i.y+u.height+s.height+2*a});else if("right"===o)t.attr({x:i.x+s.width+a,y:i.y}),this.changeRailPosition(n,i.x,i.y),e.attr({x:i.x+s.width+a,y:i.y+s.height});else{var c=Math.max(u.width,l.width);t.attr({x:i.x,y:i.y}),this.changeRailPosition(n,i.x+c+a,i.y),e.attr({x:i.x,y:i.y+s.height})}},e}(Bt),Rt=n(47),Nt="g2-tooltip",Gt="g2-tooltip-title",Yt="g2-tooltip-list",Vt="g2-tooltip-list-item",Xt="g2-tooltip-marker",zt="g2-tooltip-value",Ht="g2-tooltip-name",Wt="g2-tooltip-crosshair-x",qt="g2-tooltip-crosshair-y",Ut=((jt={})[""+Nt]={position:"absolute",visibility:"visible",zIndex:8,transition:"visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), left 0.4s cubic-bezier(0.23, 1, 0.32, 1), top 0.4s cubic-bezier(0.23, 1, 0.32, 1)",backgroundColor:"rgba(255, 255, 255, 0.9)",boxShadow:"0px 0px 10px #aeaeae",borderRadius:"3px",color:"rgb(87, 87, 87)",fontSize:"12px",fontFamily:q.fontFamily,lineHeight:"20px",padding:"10px 10px 6px 10px"},jt[""+Gt]={marginBottom:"4px"},jt[""+Yt]={margin:"0px",listStyleType:"none",padding:"0px"},jt[""+Vt]={listStyleType:"none",marginBottom:"4px"},jt[""+Xt]={width:"8px",height:"8px",borderRadius:"50%",display:"inline-block",marginRight:"8px"},jt[""+zt]={display:"inline-block",float:"right",marginLeft:"30px"},jt[""+Wt]={position:"absolute",width:"1px",backgroundColor:"rgba(0, 0, 0, 0.25)"},jt[""+qt]={position:"absolute",height:"1px",backgroundColor:"rgba(0, 0, 0, 0.25)"},jt);var Zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return g(e,t),e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"tooltip",type:"html",x:0,y:0,items:[],customContent:null,containerTpl:'
    ',itemTpl:'
  • \n \n {name}:\n {value}\n
  • ',xCrosshairTpl:'
    ',yCrosshairTpl:'
    ',title:null,showTitle:!0,region:null,crosshairsRegion:null,containerClassName:Nt,crosshairs:null,offset:10,position:"right",domStyles:null,defaultStyles:Ut})},e.prototype.render=function(){this.get("customContent")?this.renderCustomContent():(this.resetTitle(),this.renderItems()),this.resetPosition()},e.prototype.clear=function(){this.clearCrosshairs(),this.setTitle(""),this.clearItemDoms()},e.prototype.show=function(){var t=this.getContainer();t&&!this.destroyed&&(this.set("visible",!0),Object(At.modifyCSS)(t,{visibility:"visible"}),this.setCrossHairsVisible(!0))},e.prototype.hide=function(){var t=this.getContainer();t&&!this.destroyed&&(this.set("visible",!1),Object(At.modifyCSS)(t,{visibility:"hidden"}),this.setCrossHairsVisible(!1))},e.prototype.getLocation=function(){return{x:this.get("x"),y:this.get("y")}},e.prototype.setLocation=function(t){this.set("x",t.x),this.set("y",t.y),this.resetPosition()},e.prototype.setCrossHairsVisible=function(t){var e=t?"":"none",n=this.get("xCrosshairDom"),i=this.get("yCrosshairDom");n&&Object(At.modifyCSS)(n,{display:e}),i&&Object(At.modifyCSS)(i,{display:e})},e.prototype.initContainer=function(){if(t.prototype.initContainer.call(this),this.get("customContent")){this.get("container")&&this.get("container").remove();var e=this.getHtmlContentNode();this.get("parent").appendChild(e),this.set("container",e),this.resetStyles(),this.applyStyles()}},e.prototype.updateInner=function(e){var n,i,r;this.get("customContent")?this.renderCustomContent():(n=e,i=["title","showTitle"],r=!1,Object(m.each)(i,(function(t){if(Object(m.hasKey)(n,t))return r=!0,!1})),r&&this.resetTitle(),Object(m.hasKey)(e,"items")&&this.renderItems()),t.prototype.updateInner.call(this,e)},e.prototype.initDom=function(){this.cacheDoms()},e.prototype.removeDom=function(){t.prototype.removeDom.call(this),this.clearCrosshairs()},e.prototype.resetPosition=function(){var t,e=this.get("x"),n=this.get("y"),i=this.get("offset"),r=this.getOffset(),o=r.offsetX,a=r.offsetY,s=this.get("position"),u=this.get("region"),l=this.getContainer(),c=this.getBBox(),h=c.width,f=c.height;u&&(t=T(u));var p=function(t,e,n,i,r,o,a){var s=function(t,e,n,i,r,o){var a=t,s=e;switch(o){case"left":a=t-i-n,s=e-r/2;break;case"right":a=t+n,s=e-r/2;break;case"top":a=t-i/2,s=e-r-n;break;case"bottom":a=t-i/2,s=e+n;break;default:a=t+n,s=e-r-n}return{x:a,y:s}}(t,e,n,i,r,o);if(a){var u=function(t,e,n,i,r){return{left:tr.x+r.width,top:er.y+r.height}}(s.x,s.y,i,r,a);"auto"===o?(u.right&&(s.x=Math.max(0,t-i-n)),u.top&&(s.y=Math.max(0,e-r-n))):"top"===o||"bottom"===o?(u.left&&(s.x=a.x),u.right&&(s.x=a.x+a.width-i),"top"===o&&u.top&&(s.y=e+n),"bottom"===o&&u.bottom&&(s.y=e-r-n)):(u.top&&(s.y=a.y),u.bottom&&(s.y=a.y+a.height-r),"left"===o&&u.left&&(s.x=t+n),"right"===o&&u.right&&(s.x=t-i-n))}return s}(e,n,i,h,f,s,t);Object(At.modifyCSS)(l,{left:B(p.x+o),top:B(p.y+a)}),this.resetCrosshairs()},e.prototype.renderCustomContent=function(){var t=this.getHtmlContentNode(),e=this.get("parent"),n=this.get("container");n&&n.parentNode===e?e.replaceChild(t,n):e.appendChild(t),this.set("container",t),this.resetStyles(),this.applyStyles()},e.prototype.getHtmlContentNode=function(){var t,e=this.get("customContent");if(e){var n=e(this.get("title"),this.get("items"));t=Object(m.isElement)(n)?n:Object(At.createDom)(n)}return t},e.prototype.cacheDoms=function(){var t=this.getContainer(),e=t.getElementsByClassName(Gt)[0],n=t.getElementsByClassName(Yt)[0];this.set("titleDom",e),this.set("listDom",n)},e.prototype.resetTitle=function(){var t=this.get("title");this.get("showTitle")&&t?this.setTitle(t):this.setTitle("")},e.prototype.setTitle=function(t){var e=this.get("titleDom");e&&(e.innerText=t)},e.prototype.resetCrosshairs=function(){var t=this.get("crosshairsRegion"),e=this.get("crosshairs");if(t&&e){var n=T(t),i=this.get("xCrosshairDom"),r=this.get("yCrosshairDom");"x"===e?(this.resetCrosshair("x",n),r&&(r.remove(),this.set("yCrosshairDom",null))):"y"===e?(this.resetCrosshair("y",n),i&&(i.remove(),this.set("xCrosshairDom",null))):(this.resetCrosshair("x",n),this.resetCrosshair("y",n)),this.setCrossHairsVisible(this.get("visible"))}else this.clearCrosshairs()},e.prototype.resetCrosshair=function(t,e){var n=this.checkCrosshair(t),i=this.get(t);"x"===t?Object(At.modifyCSS)(n,{left:B(i),top:B(e.y),height:B(e.height)}):Object(At.modifyCSS)(n,{top:B(i),left:B(e.x),width:B(e.width)})},e.prototype.checkCrosshair=function(t){var e=t+"CrosshairDom",n=t+"CrosshairTpl",i="CROSSHAIR_"+t.toUpperCase(),r=f[i],o=this.get(e),a=this.get("parent");return o||(o=Object(At.createDom)(this.get(n)),this.applyStyle(r,o),a.appendChild(o),this.set(e,o)),o},e.prototype.renderItems=function(){this.clearItemDoms();var t=this.get("items"),e=this.get("itemTpl"),n=this.get("listDom");n&&(Object(m.each)(t,(function(t){var i=Rt.default.toCSSGradient(t.color),r=y(y({},t),{color:i}),o=Object(m.substitute)(e,r),a=Object(At.createDom)(o);n.appendChild(a)})),this.applyChildrenStyles(n,this.get("domStyles")))},e.prototype.clearItemDoms=function(){this.get("listDom")&&I(this.get("listDom"))},e.prototype.clearCrosshairs=function(){var t=this.get("xCrosshairDom"),e=this.get("yCrosshairDom");t&&t.remove(),e&&e.remove(),this.set("xCrosshairDom",null),this.set("yCrosshairDom",null)},e}(Pt),Qt={opacity:0},Kt={stroke:"#C5C5C5",strokeOpacity:.85},$t={fill:"#CACED4",opacity:.85},Jt=n(94),te=n(33);function ee(t){return function(t){return Object(m.map)(t,(function(t,e){return[0===e?"M":"L",t[0],t[1]]}))}(t)}function ne(t,e,n,i){void 0===i&&(i=!0);var r=new te.Linear({values:t}),o=new te.Category({values:Object(m.map)(t,(function(t,e){return e}))}),a=Object(m.map)(t,(function(t,i){return[o.scale(i)*e,n-r.scale(t)*n]}));return i?function(t){if(t.length<=2)return ee(t);var e=[];Object(m.each)(t,(function(t){Object(m.isEqual)(t,e.slice(e.length-2))||e.push(t[0],t[1])}));var n=Object(Jt.catmullRom2Bezier)(e,!1),i=Object(m.head)(t),r=i[0],o=i[1];return n.unshift(["M",r,o]),n}(a):ee(a)}function ie(t,e,n){var i=function(){for(var t=0,e=0,n=arguments.length;ec&&(l=(i=[c,l])[0],c=i[1],e=(r=[n,e])[0],n=r[1],h=!0);var f=e.getBBox(),p=n.getBBox(),d=f.width>l-2?{x:l+u/2+2,textAlign:"left"}:{x:l-u/2-2,textAlign:"right"},g=p.width>s-c-2?{x:c-u/2-2,textAlign:"right"}:{x:c+u/2+2,textAlign:"left"};return h?[g,d]:[d,g]},e.prototype.draw=function(){var t=this.get("container"),e=t&&t.get("canvas");e&&e.draw()},e.prototype.getContainerDOM=function(){var t=this.get("container"),e=t&&t.get("canvas");return e&&e.get("container")},e}(V),fe={default:{trackColor:"rgba(0,0,0,0)",thumbColor:"rgba(0,0,0,0.15)",size:8,lineCap:"round"},hover:{thumbColor:"rgba(0,0,0,0.2)"}},pe=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.clearEvents=m.noop,e.onStartEvent=function(t){return function(n){e.isMobile=t,n.originalEvent.preventDefault();var i=t?Object(m.get)(n.originalEvent,"touches.0.clientX"):n.clientX,r=t?Object(m.get)(n.originalEvent,"touches.0.clientY"):n.clientY;e.startPos=e.cfg.isHorizontal?i:r,e.bindLaterEvent()}},e.bindLaterEvent=function(){var t=e.getContainerDOM(),n=[];n=e.isMobile?[Object(At.addEventListener)(t,"touchmove",e.onMouseMove),Object(At.addEventListener)(t,"touchend",e.onMouseUp),Object(At.addEventListener)(t,"touchcancel",e.onMouseUp)]:[Object(At.addEventListener)(t,"mousemove",e.onMouseMove),Object(At.addEventListener)(t,"mouseup",e.onMouseUp),Object(At.addEventListener)(t,"mouseleave",e.onMouseUp)],e.clearEvents=function(){n.forEach((function(t){t.remove()}))}},e.onMouseMove=function(t){var n=e.cfg,i=n.isHorizontal,r=n.thumbOffset;t.preventDefault();var o=e.isMobile?Object(m.get)(t,"touches.0.clientX"):t.clientX,a=e.isMobile?Object(m.get)(t,"touches.0.clientY"):t.clientY,s=i?o:a,u=s-e.startPos;e.startPos=s,e.updateThumbOffset(r+u)},e.onMouseUp=function(t){t.preventDefault(),e.clearEvents()},e.onTrackClick=function(t){var n=e.cfg,i=n.isHorizontal,r=n.x,o=n.y,a=n.thumbLen,s=e.getContainerDOM().getBoundingClientRect(),u=t.clientX,l=t.clientY,c=i?u-s.left-r-a/2:l-s.top-o-a/2,h=e.validateRange(c);e.updateThumbOffset(h)},e.onThumbMouseOver=function(){var t=e.cfg.theme.hover.thumbColor;e.getElementByLocalId("thumb").attr("stroke",t),e.draw()},e.onThumbMouseOut=function(){var t=e.cfg.theme.default.thumbColor;e.getElementByLocalId("thumb").attr("stroke",t),e.draw()},e}return g(e,t),e.prototype.setRange=function(t,e){this.set("minLimit",t),this.set("maxLimit",e);var n=this.getValue(),i=Object(m.clamp)(n,t,e);n===i||this.get("isInit")||this.setValue(i)},e.prototype.getRange=function(){return{min:this.get("minLimit")||0,max:this.get("maxLimit")||1}},e.prototype.setValue=function(t){var e=this.getRange(),n=this.getValue();this.update({thumbOffset:(this.get("trackLen")-this.get("thumbLen"))*Object(m.clamp)(t,e.min,e.max)}),this.delegateEmit("valuechange",{originalValue:n,value:this.getValue()})},e.prototype.getValue=function(){return Object(m.clamp)(this.get("thumbOffset")/(this.get("trackLen")-this.get("thumbLen")),0,1)},e.prototype.getDefaultCfg=function(){var e=t.prototype.getDefaultCfg.call(this);return y(y({},e),{name:"scrollbar",isHorizontal:!0,minThumbLen:20,thumbOffset:0,theme:fe})},e.prototype.renderInner=function(t){this.renderTrackShape(t),this.renderThumbShape(t)},e.prototype.applyOffset=function(){this.moveElementTo(this.get("group"),{x:this.get("x"),y:this.get("y")})},e.prototype.initEvent=function(){this.bindEvents()},e.prototype.renderTrackShape=function(t){var e=this.cfg,n=e.trackLen,i=e.theme,r=(void 0===i?{default:{}}:i).default,o=r.lineCap,a=r.trackColor,s=r.size,u=this.get("isHorizontal")?{x1:0+s/2,y1:s/2,x2:n-s/2,y2:s/2,lineWidth:s,stroke:a,lineCap:o}:{x1:s/2,y1:0+s/2,x2:s/2,y2:n-s/2,lineWidth:s,stroke:a,lineCap:o};return this.addShape(t,{id:this.getElementId("track"),name:"track",type:"line",attrs:u})},e.prototype.renderThumbShape=function(t){var e=this.cfg,n=e.thumbOffset,i=e.thumbLen,r=e.theme,o=(void 0===r?{default:{}}:r).default,a=o.size,s=o.lineCap,u=o.thumbColor,l=this.get("isHorizontal")?{x1:n+a/2,y1:a/2,x2:n+i-a/2,y2:a/2,lineWidth:a,stroke:u,lineCap:s,cursor:"default"}:{x1:a/2,y1:n+a/2,x2:a/2,y2:n+i-a/2,lineWidth:a,stroke:u,lineCap:s,cursor:"default"};return this.addShape(t,{id:this.getElementId("thumb"),name:"thumb",type:"line",attrs:l})},e.prototype.bindEvents=function(){var t=this.get("group");t.on("mousedown",this.onStartEvent(!1)),t.on("mouseup",this.onMouseUp),t.on("touchstart",this.onStartEvent(!0)),t.on("touchend",this.onMouseUp),t.findById(this.getElementId("track")).on("click",this.onTrackClick);var e=t.findById(this.getElementId("thumb"));e.on("mouseover",this.onThumbMouseOver),e.on("mouseout",this.onThumbMouseOut)},e.prototype.getContainerDOM=function(){var t=this.get("container"),e=t&&t.get("canvas");return e&&e.get("container")},e.prototype.validateRange=function(t){var e=this.cfg,n=e.thumbLen,i=e.trackLen,r=t;return t+n>i?r=i-n:t+ne)n.insertBefore(t,r);else if(o0&&(e?"stroke"in n?this._setColor(t,"stroke",o):"strokeStyle"in n&&this._setColor(t,"stroke",a):this._setColor(t,"stroke",o||a),l&&h.setAttribute(u.strokeOpacity,l),c&&h.setAttribute(u.lineWidth,c))},e.prototype._setColor=function(t,e,n){var i=this.get("el");if(n)if(n=n.trim(),/^[r,R,L,l]{1}[\s]*\(/.test(n))(r=t.find("gradient",n))||(r=t.addGradient(n)),i.setAttribute(u[e],"url(#"+r+")");else if(/^[p,P]{1}[\s]*\(/.test(n)){var r;(r=t.find("pattern",n))||(r=t.addPattern(n)),i.setAttribute(u[e],"url(#"+r+")")}else i.setAttribute(u[e],n);else i.setAttribute(u[e],"none")},e.prototype.shadow=function(t,e){var n=this.attr(),i=e||n,r=i.shadowOffsetX,o=i.shadowOffsetY,a=i.shadowBlur,s=i.shadowColor;(r||o||a||s)&&function(t,e){var n=t.cfg.el,i=t.attr(),r={dx:i.shadowOffsetX,dy:i.shadowOffsetY,blur:i.shadowBlur,color:i.shadowColor};if(r.dx||r.dy||r.blur||r.color){var o=e.find("filter",r);o||(o=e.addShadow(r)),n.setAttribute("filter","url(#"+o+")")}else n.removeAttribute("filter")}(this,t)},e.prototype.transform=function(t){var e=this.attr();(t||e).matrix&&f(this)},e.prototype.isInShape=function(t,e){return this.isPointInPath(t,e)},e.prototype.isPointInPath=function(t,e){var n=this.get("el"),i=this.get("canvas").get("el").getBoundingClientRect(),r=t+i.left,o=e+i.top,a=document.elementFromPoint(r,o);return!(!a||!a.isEqualNode(n))},e.prototype.getHitLineWidth=function(){var t=this.attrs,e=t.lineWidth,n=t.lineAppendWidth;return this.isStroke()?e+n:0},e}(o.AbstractShape),x=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="circle",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,r:0})},e.prototype.createPath=function(t,e){var n=this.attr(),i=this.get("el");Object(a.each)(e||n,(function(t,e){"x"===e||"y"===e?i.setAttribute("c"+e,t):u[e]&&i.setAttribute(u[e],t)}))},e}(m),b=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="dom",e.canFill=!1,e.canStroke=!1,e}return Object(r.__extends)(e,t),e.prototype.createPath=function(t,e){var n=this.attr(),i=this.get("el");Object(a.each)(e||n,(function(t,e){u[e]&&i.setAttribute(u[e],t)})),i.innerHTML=n.html},e}(m),_=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="ellipse",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,rx:0,ry:0})},e.prototype.createPath=function(t,e){var n=this.attr(),i=this.get("el");Object(a.each)(e||n,(function(t,e){"x"===e||"y"===e?i.setAttribute("c"+e,t):u[e]&&i.setAttribute(u[e],t)}))},e}(m),M=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="image",e.canFill=!1,e.canStroke=!1,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,width:0,height:0})},e.prototype.createPath=function(t,e){var n=this,i=this.attr(),r=this.get("el");Object(a.each)(e||i,(function(t,e){"img"===e?n._setImage(i.img):u[e]&&r.setAttribute(u[e],t)}))},e.prototype.setAttr=function(t,e){this.attrs[t]=e,"img"===t&&this._setImage(e)},e.prototype._setImage=function(t){var e=this.attr(),n=this.get("el");if(Object(a.isString)(t))n.setAttribute("href",t);else if(t instanceof window.Image)e.width||(n.setAttribute("width",t.width),this.attr("width",t.width)),e.height||(n.setAttribute("height",t.height),this.attr("height",t.height)),n.setAttribute("href",t.src);else if(t instanceof HTMLElement&&Object(a.isString)(t.nodeName)&&"CANVAS"===t.nodeName.toUpperCase())n.setAttribute("href",t.toDataURL());else if(t instanceof ImageData){var i=document.createElement("canvas");i.setAttribute("width",""+t.width),i.setAttribute("height",""+t.height),i.getContext("2d").putImageData(t,0,0),e.width||(n.setAttribute("width",""+t.width),this.attr("width",t.width)),e.height||(n.setAttribute("height",""+t.height),this.attr("height",t.height)),n.setAttribute("href",i.toDataURL())}},e}(m),C=n(13),w=n.n(C),O=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="line",e.canFill=!1,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x1:0,y1:0,x2:0,y2:0,startArrow:!1,endArrow:!1})},e.prototype.createPath=function(t,e){var n=this.attr(),i=this.get("el");Object(a.each)(e||n,(function(e,r){if("startArrow"===r||"endArrow"===r)if(e){var o=Object(a.isObject)(e)?t.addArrow(n,u[r]):t.getDefaultArrow(n,u[r]);i.setAttribute(u[r],"url(#"+o+")")}else i.removeAttribute(u[r]);else u[r]&&i.setAttribute(u[r],e)}))},e.prototype.getTotalLength=function(){var t=this.attr(),e=t.x1,n=t.y1,i=t.x2,r=t.y2;return w.a.length(e,n,i,r)},e.prototype.getPoint=function(t){var e=this.attr(),n=e.x1,i=e.y1,r=e.x2,o=e.y2;return w.a.pointAt(n,i,r,o,t)},e}(m),S={circle:function(t,e,n){return[["M",t,e],["m",-n,0],["a",n,n,0,1,0,2*n,0],["a",n,n,0,1,0,2*-n,0]]},square:function(t,e,n){return[["M",t-n,e-n],["L",t+n,e-n],["L",t+n,e+n],["L",t-n,e+n],["Z"]]},diamond:function(t,e,n){return[["M",t-n,e],["L",t,e-n],["L",t+n,e],["L",t,e+n],["Z"]]},triangle:function(t,e,n){var i=n*Math.sin(1/3*Math.PI);return[["M",t-n,e+i],["L",t,e-i],["L",t+n,e+i],["z"]]},triangleDown:function(t,e,n){var i=n*Math.sin(1/3*Math.PI);return[["M",t-n,e-i],["L",t+n,e-i],["L",t,e+i],["Z"]]}},A={get:function(t){return S[t]},register:function(t,e){S[t]=e},remove:function(t){delete S[t]},getAll:function(){return S}},P=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="marker",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.createPath=function(t){this.get("el").setAttribute("d",this._assembleMarker())},e.prototype._assembleMarker=function(){var t=this._getPath();return Object(a.isArray)(t)?t.map((function(t){return t.join(" ")})).join(""):t},e.prototype._getPath=function(){var t,e=this.attr(),n=e.x,i=e.y,r=e.r||e.radius,o=e.symbol||"circle";return(t=Object(a.isFunction)(o)?o:A.get(o))?t(n,i,r):(console.warn(t+" symbol is not exist."),null)},e.symbolsFactory=A,e}(m),I=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="path",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{startArrow:!1,endArrow:!1})},e.prototype.createPath=function(t,e){var n=this,i=this.attr(),r=this.get("el");Object(a.each)(e||i,(function(e,o){if("path"===o&&Object(a.isArray)(e))r.setAttribute("d",n._formatPath(e));else if("startArrow"===o||"endArrow"===o)if(e){var s=Object(a.isObject)(e)?t.addArrow(i,u[o]):t.getDefaultArrow(i,u[o]);r.setAttribute(u[o],"url(#"+s+")")}else r.removeAttribute(u[o]);else u[o]&&r.setAttribute(u[o],e)}))},e.prototype._formatPath=function(t){var e=t.map((function(t){return t.join(" ")})).join("");return~e.indexOf("NaN")?"":e},e.prototype.getTotalLength=function(){var t=this.get("el");return t?t.getTotalLength():null},e.prototype.getPoint=function(t){var e=this.get("el"),n=this.getTotalLength(),i=e?e.getPointAtLength(t*n):null;return i?{x:i.x,y:i.y}:null},e}(m),T=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="polygon",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.createPath=function(t,e){var n=this.attr(),i=this.get("el");Object(a.each)(e||n,(function(t,e){"points"===e&&Object(a.isArray)(t)&&t.length>=2?i.setAttribute("points",t.map((function(t){return t[0]+","+t[1]})).join(" ")):u[e]&&i.setAttribute(u[e],t)}))},e}(m),E=n(61),j=n.n(E),L=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="polyline",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{startArrow:!1,endArrow:!1})},e.prototype.onAttrChange=function(e,n,i){t.prototype.onAttrChange.call(this,e,n,i),-1!==["points"].indexOf(e)&&this._resetCache()},e.prototype._resetCache=function(){this.set("totalLength",null),this.set("tCache",null)},e.prototype.createPath=function(t,e){var n=this.attr(),i=this.get("el");Object(a.each)(e||n,(function(t,e){"points"===e&&Object(a.isArray)(t)&&t.length>=2?i.setAttribute("points",t.map((function(t){return t[0]+","+t[1]})).join(" ")):u[e]&&i.setAttribute(u[e],t)}))},e.prototype.getTotalLength=function(){var t=this.attr().points,e=this.get("totalLength");return Object(a.isNil)(e)?(this.set("totalLength",j.a.length(t)),this.get("totalLength")):e},e.prototype.getPoint=function(t){var e,n,i=this.attr().points,r=this.get("tCache");return r||(this._setTcache(),r=this.get("tCache")),Object(a.each)(r,(function(i,r){t>=i[0]&&t<=i[1]&&(e=(t-i[0])/(i[1]-i[0]),n=r)})),w.a.pointAt(i[n][0],i[n][1],i[n+1][0],i[n+1][1],e)},e.prototype._setTcache=function(){var t=this.attr().points;if(t&&0!==t.length){var e=this.getTotalLength();if(!(e<=0)){var n,i,r=0,o=[];Object(a.each)(t,(function(a,s){t[s+1]&&((n=[])[0]=r/e,i=w.a.length(a[0],a[1],t[s+1][0],t[s+1][1]),r+=i,n[1]=r/e,o.push(n))})),this.set("tCache",o)}}},e.prototype.getStartTangent=function(){var t=this.attr().points,e=[];return e.push([t[1][0],t[1][1]]),e.push([t[0][0],t[0][1]]),e},e.prototype.getEndTangent=function(){var t=this.attr().points,e=t.length-1,n=[];return n.push([t[e-1][0],t[e-1][1]]),n.push([t[e][0],t[e][1]]),n},e}(m);var k=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="rect",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,width:0,height:0,radius:0})},e.prototype.createPath=function(t,e){var n=this,i=this.attr(),r=this.get("el"),o=!1,s=["x","y","width","height","radius"];Object(a.each)(e||i,(function(t,e){-1===s.indexOf(e)||o?-1===s.indexOf(e)&&u[e]&&r.setAttribute(u[e],t):(r.setAttribute("d",n._assembleRect(i)),o=!0)}))},e.prototype._assembleRect=function(t){var e=t.x,n=t.y,i=t.width,r=t.height,o=t.radius;if(!o)return"M "+e+","+n+" l "+i+",0 l 0,"+r+" l"+-i+" 0 z";var s=function(t){var e=0,n=0,i=0,r=0;return Object(a.isArray)(t)?1===t.length?e=n=i=r=t[0]:2===t.length?(e=i=t[0],n=r=t[1]):3===t.length?(e=t[0],n=r=t[1],i=t[2]):(e=t[0],n=t[1],i=t[2],r=t[3]):e=n=i=r=t,{r1:e,r2:n,r3:i,r4:r}}(o);return Object(a.isArray)(o)?1===o.length?s.r1=s.r2=s.r3=s.r4=o[0]:2===o.length?(s.r1=s.r3=o[0],s.r2=s.r4=o[1]):3===o.length?(s.r1=o[0],s.r2=s.r4=o[1],s.r3=o[2]):(s.r1=o[0],s.r2=o[1],s.r3=o[2],s.r4=o[3]):s.r1=s.r2=s.r3=s.r4=o,[["M "+(e+s.r1)+","+n],["l "+(i-s.r1-s.r2)+",0"],["a "+s.r2+","+s.r2+",0,0,1,"+s.r2+","+s.r2],["l 0,"+(r-s.r2-s.r3)],["a "+s.r3+","+s.r3+",0,0,1,"+-s.r3+","+s.r3],["l "+(s.r3+s.r4-i)+",0"],["a "+s.r4+","+s.r4+",0,0,1,"+-s.r4+","+-s.r4],["l 0,"+(s.r4+s.r1-r)],["a "+s.r1+","+s.r1+",0,0,1,"+s.r1+","+-s.r1],["z"]].join(" ")},e}(m),B=n(132),D={top:"before-edge",middle:"central",bottom:"after-edge",alphabetic:"baseline",hanging:"hanging"},F={top:"text-before-edge",middle:"central",bottom:"text-after-edge",alphabetic:"alphabetic",hanging:"hanging"},R={left:"left",start:"left",center:"middle",right:"end",end:"end"},N=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="text",e.canFill=!0,e.canStroke=!0,e}return Object(r.__extends)(e,t),e.prototype.getDefaultAttrs=function(){var e=t.prototype.getDefaultAttrs.call(this);return Object(r.__assign)(Object(r.__assign)({},e),{x:0,y:0,text:null,fontSize:12,fontFamily:"sans-serif",fontStyle:"normal",fontWeight:"normal",fontVariant:"normal",textAlign:"start",textBaseline:"bottom"})},e.prototype.createPath=function(t,e){var n=this,i=this.attr(),r=this.get("el");this._setFont(),Object(a.each)(e||i,(function(t,e){"text"===e?n._setText(""+t):"matrix"===e&&t?f(n):u[e]&&r.setAttribute(u[e],t)})),r.setAttribute("paint-order","stroke"),r.setAttribute("style","stroke-linecap:butt; stroke-linejoin:miter;")},e.prototype._setFont=function(){var t=this.get("el"),e=this.attr(),n=e.textBaseline,i=e.textAlign,r=Object(B.detect)();r&&"firefox"===r.name?t.setAttribute("dominant-baseline",F[n]||"alphabetic"):t.setAttribute("alignment-baseline",D[n]||"baseline"),t.setAttribute("text-anchor",R[i]||"left")},e.prototype._setText=function(t){var e=this.get("el"),n=this.attr(),i=n.x,r=n.textBaseline,o=void 0===r?"bottom":r;if(t)if(~t.indexOf("\n")){var s=t.split("\n"),u=s.length-1,l="";Object(a.each)(s,(function(t,e){0===e?"alphabetic"===o?l+=''+t+"":"top"===o?l+=''+t+"":"middle"===o?l+=''+t+"":"bottom"===o?l+=''+t+"":"hanging"===o&&(l+=''+t+""):l+=''+t+""})),e.innerHTML=l}else e.innerHTML=t;else e.innerHTML=""},e}(m),G=/^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i,Y=/^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i,V=/[\d.]+:(#[^\s]+|[^\)]+\))/gi;function X(t){var e=t.match(V);if(!e)return"";var n="";return e.sort((function(t,e){return t=t.split(":"),e=e.split(":"),Number(t[0])-Number(e[0])})),Object(a.each)(e,(function(t){t=t.split(":"),n+=''})),n}var z=function(){function t(t){this.cfg={};var e,n,i,r,o,s,u,c=null,h=Object(a.uniqueId)("gradient_");return"l"===t.toLowerCase()[0]?function(t,e){var n,i,r=G.exec(t),o=Object(a.mod)(Object(a.toRadian)(parseFloat(r[1])),2*Math.PI),s=r[2];o>=0&&o<.5*Math.PI?(n={x:0,y:0},i={x:1,y:1}):.5*Math.PI<=o&&o';e.innerHTML=n},t}(),U=function(){function t(t,e){this.cfg={};var n=l("marker"),i=Object(a.uniqueId)("marker_");n.setAttribute("id",i);var r=l("path");r.setAttribute("stroke",t.stroke||"none"),r.setAttribute("fill",t.fill||"none"),n.appendChild(r),n.setAttribute("overflow","visible"),n.setAttribute("orient","auto-start-reverse"),this.el=n,this.child=r,this.id=i;var o=t["marker-start"===e?"startArrow":"endArrow"];return this.stroke=t.stroke||"#000",!0===o?this._setDefaultPath(e,r):(this.cfg=o,this._setMarker(t.lineWidth,r)),this}return t.prototype.match=function(){return!1},t.prototype._setDefaultPath=function(t,e){var n=this.el;e.setAttribute("d","M0,0 L"+10*Math.cos(Math.PI/6)+",5 L0,10"),n.setAttribute("refX",""+10*Math.cos(Math.PI/6)),n.setAttribute("refY","5")},t.prototype._setMarker=function(t,e){var n=this.el,i=this.cfg.path,r=this.cfg.d;Object(a.isArray)(i)&&(i=i.map((function(t){return t.join(" ")})).join("")),e.setAttribute("d",i),n.appendChild(e),r&&n.setAttribute("refX",""+r/t)},t.prototype.update=function(t){var e=this.child;e.attr?e.attr("fill",t):e.setAttribute("fill",t)},t}(),Z=function(){function t(t){this.type="clip",this.cfg={};var e=l("clipPath");this.el=e,this.id=Object(a.uniqueId)("clip_"),e.id=this.id;var n=t.cfg.el;return e.appendChild(n),this.cfg=t,this}return t.prototype.match=function(){return!1},t.prototype.remove=function(){var t=this.el;t.parentNode.removeChild(t)},t}(),Q=/^p\s*\(\s*([axyn])\s*\)\s*(.*)/i,K=function(){function t(t){this.cfg={};var e=l("pattern");e.setAttribute("patternUnits","userSpaceOnUse");var n=l("image");e.appendChild(n);var i=Object(a.uniqueId)("pattern_");e.id=i,this.el=e,this.id=i,this.cfg=t;var r=Q.exec(t)[2];n.setAttribute("href",r);var o=new Image;function s(){e.setAttribute("width",""+o.width),e.setAttribute("height",""+o.height)}return r.match(/^data:/i)||(o.crossOrigin="Anonymous"),o.src=r,o.complete?s():(o.onload=s,o.src=o.src),this}return t.prototype.match=function(t,e){return this.cfg===e},t}(),$=function(){function t(t){var e=l("defs"),n=Object(a.uniqueId)("defs_");e.id=n,t.appendChild(e),this.children=[],this.defaultArrow={},this.el=e,this.canvas=t}return t.prototype.find=function(t,e){for(var n=this.children,i=null,r=0;r=0&&this.radius<=1&&(n*=this.radius),this.d=Math.floor(n*(1-this.innerRadius)/e),this.a=this.d/(2*Math.PI),this.x={start:this.startAngle,end:this.endAngle},this.y={start:this.innerRadius*n,end:this.innerRadius*n+.99*this.d}},e.prototype.convertPoint=function(t){var e,n=t.x,i=t.y;this.isTransposed&&(n=(e=[i,n])[0],i=e[1]);var r=this.convertDim(n,"x"),o=this.a*r,a=this.convertDim(i,"y");return{x:this.center.x+Math.cos(r)*(o+a),y:this.center.y+Math.sin(r)*(o+a)}},e.prototype.invertPoint=function(t){var e,n=this.d+this.y.start,i=a.vec2.subtract([0,0],[t.x,t.y],[this.center.x,this.center.y]),r=a.ext.angleTo(i,[1,0],!0),o=r*this.a;a.vec2.length(i)this.width/i?(e=this.width/i,this.circleCenter={x:this.center.x-(.5-o)*this.width,y:this.center.y-(.5-a)*e*r}):(e=this.height/r,this.circleCenter={x:this.center.x-(.5-o)*e*i,y:this.center.y-(.5-a)*this.height}),this.polarRadius=this.radius,this.radius?this.radius>0&&this.radius<=1?this.polarRadius=e*this.radius:(this.radius<=0||this.radius>e)&&(this.polarRadius=e):this.polarRadius=e,this.x={start:this.startAngle,end:this.endAngle},this.y={start:this.innerRadius*this.polarRadius,end:this.polarRadius}},e.prototype.getRadius=function(){return this.polarRadius},e.prototype.convertPoint=function(t){var e,n=this.getCenter(),i=t.x,r=t.y;return this.isTransposed&&(i=(e=[r,i])[0],r=e[1]),i=this.convertDim(i,"x"),r=this.convertDim(r,"y"),{x:n.x+Math.cos(i)*r,y:n.y+Math.sin(i)*r}},e.prototype.invertPoint=function(t){var e=this.getCenter(),n=[t.x-e.x,t.y-e.y],i=[1,0,0,0,1,0,0,0,1];a.ext.leftRotate(i,i,this.startAngle);var r=[1,0,0];a.vec3.transformMat3(r,r,i);var o=[r[0],r[1]],u=a.ext.angleTo(o,n,this.endAngle0?c:-c;var h=this.invertDim(l,"y"),f={x:0,y:0};return f.x=this.isTransposed?h:c,f.y=this.isTransposed?c:h,f},e.prototype.getCenter=function(){return this.circleCenter},e.prototype.getOneBox=function(){var t=this.startAngle,e=this.endAngle;if(Math.abs(e-t)>=2*Math.PI)return{minX:-1,maxX:1,minY:-1,maxY:1};for(var n=[0,Math.cos(t),Math.cos(e)],i=[0,Math.sin(t),Math.sin(e)],r=Math.min(t,e);r1)return this.getValueByKeyPath(key,options);if(templateContext&&"object"==typeof templateContext&&key in templateContext&&placeholder!==templateContext[key])return templateContext[key]=Handler.gen(templateContext[key],key,{currentContext:obj,templateCurrentContext:templateContext}),templateContext[key];if(!(key in Random||lkey in Random||okey in Random))return placeholder;for(var i=0;i1&&(a=e.context.path.slice(0),a.pop(),a=this.normalizePath(a.concat(r)));try{t=r[r.length-1];for(var o=e.context.root,u=e.context.templateRoot,i=1;i1/(t+e)*t?!n:n):Math.random()>=.5},bool:function(t,e,n){return this.boolean(t,e,n)},natural:function(t,e){return t="undefined"!=typeof t?parseInt(t,10):0,e="undefined"!=typeof e?parseInt(e,10):9007199254740992,Math.round(Math.random()*(e-t))+t},integer:function(t,e){return t="undefined"!=typeof t?parseInt(t,10):-9007199254740992,e="undefined"!=typeof e?parseInt(e,10):9007199254740992,Math.round(Math.random()*(e-t))+t},int:function(t,e){return this.integer(t,e)},float:function(t,e,n,r){n=void 0===n?0:n,n=Math.max(Math.min(n,17),0),r=void 0===r?17:r,r=Math.max(Math.min(r,17),0);for(var a=this.integer(t,e)+".",o=0,u=this.natural(n,r);o1&&r--,o=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[c]=255*o;return a},hsl2hsv:function(t){var e,n,r=t[0],a=t[1]/100,o=t[2]/100;return o*=2,a*=o<=1?o:2-o,n=(o+a)/2,e=2*a/(o+a),[r,100*e,100*n]},hsv2rgb:function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),u=255*r*(1-n),i=255*r*(1-n*o),l=255*r*(1-n*(1-o));switch(r*=255,a){case 0:return[r,l,u];case 1:return[i,r,u];case 2:return[u,r,l];case 3:return[u,i,r];case 4:return[l,u,r];case 5:return[r,u,i]}},hsv2hsl:function(t){var e,n,r=t[0],a=t[1]/100,o=t[2]/100;return n=(2-a)*o,e=a*o,e/=n<=1?n:2-n,n/=2,[r,100*e,100*n]},rgb2hex:function(t,e,n){return"#"+((256+t<<8|e)<<8|n).toString(16).slice(1)},hex2rgb:function(t){return t="0x"+t.slice(1).replace(t.length>4?t:/./g,"$&$&")|0,[t>>16,t>>8&255,255&t]}}},function(t,e){t.exports={navy:{value:"#000080",nicer:"#001F3F"},blue:{value:"#0000ff",nicer:"#0074D9"},aqua:{value:"#00ffff",nicer:"#7FDBFF"},teal:{value:"#008080",nicer:"#39CCCC"},olive:{value:"#008000",nicer:"#3D9970"},green:{value:"#008000",nicer:"#2ECC40"},lime:{value:"#00ff00",nicer:"#01FF70"},yellow:{value:"#ffff00",nicer:"#FFDC00"},orange:{value:"#ffa500",nicer:"#FF851B"},red:{value:"#ff0000",nicer:"#FF4136"},maroon:{value:"#800000",nicer:"#85144B"},fuchsia:{value:"#ff00ff",nicer:"#F012BE"},purple:{value:"#800080",nicer:"#B10DC9"},silver:{value:"#c0c0c0",nicer:"#DDDDDD"},gray:{value:"#808080",nicer:"#AAAAAA"},black:{value:"#000000",nicer:"#111111"},white:{value:"#FFFFFF",nicer:"#FFFFFF"}}},function(t,e,n){function r(t,e,n,r){return void 0===n?a.natural(t,e):void 0===r?n:a.natural(parseInt(n,10),parseInt(r,10))}var a=n(6),o=n(14);t.exports={paragraph:function(t,e){for(var n=r(3,7,t,e),a=[],o=0;o1&&(e=[].slice.call(arguments,0));var n=t.options,r=n.context.templatePath.join("."),a=t.cache[r]=t.cache[r]||{index:0,array:e};return a.array[a.index++%a.array.length]}}},function(t,e){t.exports={first:function(){var t=["James","John","Robert","Michael","William","David","Richard","Charles","Joseph","Thomas","Christopher","Daniel","Paul","Mark","Donald","George","Kenneth","Steven","Edward","Brian","Ronald","Anthony","Kevin","Jason","Matthew","Gary","Timothy","Jose","Larry","Jeffrey","Frank","Scott","Eric"].concat(["Mary","Patricia","Linda","Barbara","Elizabeth","Jennifer","Maria","Susan","Margaret","Dorothy","Lisa","Nancy","Karen","Betty","Helen","Sandra","Donna","Carol","Ruth","Sharon","Michelle","Laura","Sarah","Kimberly","Deborah","Jessica","Shirley","Cynthia","Angela","Melissa","Brenda","Amy","Anna"]);return this.pick(t)},last:function(){var t=["Smith","Johnson","Williams","Brown","Jones","Miller","Davis","Garcia","Rodriguez","Wilson","Martinez","Anderson","Taylor","Thomas","Hernandez","Moore","Martin","Jackson","Thompson","White","Lopez","Lee","Gonzalez","Harris","Clark","Lewis","Robinson","Walker","Perez","Hall","Young","Allen"];return this.pick(t)},name:function(t){return this.first()+" "+(t?this.first()+" ":"")+this.last()},cfirst:function(){var t="王 李 张 刘 陈 杨 赵 黄 周 吴 徐 孙 胡 朱 高 林 何 郭 马 罗 梁 宋 郑 谢 韩 唐 冯 于 董 萧 程 曹 袁 邓 许 傅 沈 曾 彭 吕 苏 卢 蒋 蔡 贾 丁 魏 薛 叶 阎 余 潘 杜 戴 夏 锺 汪 田 任 姜 范 方 石 姚 谭 廖 邹 熊 金 陆 郝 孔 白 崔 康 毛 邱 秦 江 史 顾 侯 邵 孟 龙 万 段 雷 钱 汤 尹 黎 易 常 武 乔 贺 赖 龚 文".split(" ");return this.pick(t)},clast:function(){var t="伟 芳 娜 秀英 敏 静 丽 强 磊 军 洋 勇 艳 杰 娟 涛 明 超 秀兰 霞 平 刚 桂英".split(" ");return this.pick(t)},cname:function(){return this.cfirst()+this.clast()}}},function(t,e){t.exports={url:function(t,e){return(t||this.protocol())+"://"+(e||this.domain())+"/"+this.word()},protocol:function(){return this.pick("http ftp gopher mailto mid cid news nntp prospero telnet rlogin tn3270 wais".split(" "))},domain:function(t){return this.word()+"."+(t||this.tld())},tld:function(){return this.pick("com net org edu gov int mil cn com.cn net.cn gov.cn org.cn 中国 中国互联.公司 中国互联.网络 tel biz cc tv info name hk mobi asia cd travel pro museum coop aero ad ae af ag ai al am an ao aq ar as at au aw az ba bb bd be bf bg bh bi bj bm bn bo br bs bt bv bw by bz ca cc cf cg ch ci ck cl cm cn co cq cr cu cv cx cy cz de dj dk dm do dz ec ee eg eh es et ev fi fj fk fm fo fr ga gb gd ge gf gh gi gl gm gn gp gr gt gu gw gy hk hm hn hr ht hu id ie il in io iq ir is it jm jo jp ke kg kh ki km kn kp kr kw ky kz la lb lc li lk lr ls lt lu lv ly ma mc md mg mh ml mm mn mo mp mq mr ms mt mv mw mx my mz na nc ne nf ng ni nl no np nr nt nu nz om qa pa pe pf pg ph pk pl pm pn pr pt pw py re ro ru rw sa sb sc sd se sg sh si sj sk sl sm sn so sr st su sy sz tc td tf tg th tj tk tm tn to tp tr tt tv tw tz ua ug uk us uy va vc ve vg vn vu wf ws ye yu za zm zr zw".split(" "))},email:function(t){return this.character("lower")+"."+this.word()+"@"+(t||this.word()+"."+this.tld())},ip:function(){return this.natural(0,255)+"."+this.natural(0,255)+"."+this.natural(0,255)+"."+this.natural(0,255)}}},function(t,e,n){var r=n(18),a=["东北","华北","华东","华中","华南","西南","西北"];t.exports={region:function(){return this.pick(a)},province:function(){return this.pick(r).name},city:function(t){var e=this.pick(r),n=this.pick(e.children);return t?[e.name,n.name].join(" "):n.name},county:function(t){var e=this.pick(r),n=this.pick(e.children),a=this.pick(n.children)||{name:"-"};return t?[e.name,n.name,a.name].join(" "):a.name},zip:function(t){for(var e="",n=0;n<(t||6);n++)e+=this.natural(0,9);return e}}},function(t,e){function n(t){for(var e,n={},r=0;ra;a++)o=t.charAt(a),"\n"===o?(e.seenCR||e.line++,e.column=1,e.seenCR=!1):"\r"===o||"\u2028"===o||"\u2029"===o?(e.line++,e.column=1,e.seenCR=!0):(e.column++,e.seenCR=!1)}return tr!==e&&(tr>e&&(tr=0,er={line:1,column:1,seenCR:!1}),n(er,tr,e),tr=e),er}function b(t){nr>Zn||(Zn>nr&&(nr=Zn,rr=[]),rr.push(t))}function w(t){var e=0;for(t.sort();eZn?(r=t.charAt(Zn),Zn++):(r=null,0===ar&&b(Hn)),null!==r?(Qn=e,n=Sn(r),null===n?(Zn=e,e=n):e=n):(Zn=e,e=kt)):(Zn=e,e=kt),e}function ft(){var e,n,r;return e=Zn,92===t.charCodeAt(Zn)?(n=Dn,Zn++):(n=null,0===ar&&b(qn)),null!==n?(Fn.test(t.charAt(Zn))?(r=t.charAt(Zn),Zn++):(r=null,0===ar&&b(Ln)),null!==r?(Qn=e,n=On(r),null===n?(Zn=e,e=n):e=n):(Zn=e,e=kt)):(Zn=e,e=kt),e}function dt(){var e,n,r,a;if(e=Zn,t.substr(Zn,2)===In?(n=In,Zn+=2):(n=null,0===ar&&b(jn)),null!==n){if(r=[],Nn.test(t.charAt(Zn))?(a=t.charAt(Zn),Zn++):(a=null,0===ar&&b(zn)),null!==a)for(;null!==a;)r.push(a),Nn.test(t.charAt(Zn))?(a=t.charAt(Zn),Zn++):(a=null,0===ar&&b(zn));else r=kt;null!==r?(Qn=e,n=Un(r),null===n?(Zn=e,e=n):e=n):(Zn=e,e=kt)}else Zn=e,e=kt;return e}function mt(){var e,n,r,a;if(e=Zn,t.substr(Zn,2)===Bn?(n=Bn,Zn+=2):(n=null,0===ar&&b(Gn)),null!==n){if(r=[],Xn.test(t.charAt(Zn))?(a=t.charAt(Zn),Zn++):(a=null,0===ar&&b(Kn)),null!==a)for(;null!==a;)r.push(a),Xn.test(t.charAt(Zn))?(a=t.charAt(Zn),Zn++):(a=null,0===ar&&b(Kn));else r=kt;null!==r?(Qn=e,n=Wn(r),null===n?(Zn=e,e=n):e=n):(Zn=e,e=kt)}else Zn=e,e=kt;return e}function vt(){var e,n,r,a;if(e=Zn,t.substr(Zn,2)===Yn?(n=Yn,Zn+=2):(n=null,0===ar&&b($n)),null!==n){if(r=[],Xn.test(t.charAt(Zn))?(a=t.charAt(Zn),Zn++):(a=null,0===ar&&b(Kn)),null!==a)for(;null!==a;)r.push(a),Xn.test(t.charAt(Zn))?(a=t.charAt(Zn),Zn++):(a=null,0===ar&&b(Kn));else r=kt;null!==r?(Qn=e,n=Jn(r),null===n?(Zn=e,e=n):e=n):(Zn=e,e=kt)}else Zn=e,e=kt;return e}function gt(){var e,n;return e=Zn,t.substr(Zn,2)===In?(n=In,Zn+=2):(n=null,0===ar&&b(jn)),null!==n&&(Qn=e,n=Vn()),null===n?(Zn=e,e=n):e=n,e}function xt(){var e,n,r;return e=Zn,92===t.charCodeAt(Zn)?(n=Dn,Zn++):(n=null,0===ar&&b(qn)),null!==n?(t.length>Zn?(r=t.charAt(Zn),Zn++):(r=null,0===ar&&b(Hn)),null!==r?(Qn=e,n=Fe(r),null===n?(Zn=e,e=n):e=n):(Zn=e,e=kt)):(Zn=e,e=kt),e}var yt,bt=arguments.length>1?arguments[1]:{},wt={regexp:C},Ct=C,kt=null,Et="",Rt="|",At='"|"',_t=function(t,e){return e?new r(t,e[1]):t},Mt=function(t,e,n){return new a([t].concat(e).concat([n]))},Pt="^",Tt='"^"',Ht=function(){return new n("start")},St="$",Dt='"$"',qt=function(){return new n("end")},Ft=function(t,e){return new i(t,e)},Lt="Quantifier",Ot=function(t,e){return e&&(t.greedy=!1),t},It="{",jt='"{"',Nt=",",zt='","',Ut="}",Bt='"}"',Gt=function(t,e){return new l(t,e)},Xt=",}",Kt='",}"',Wt=function(t){return new l(t,1/0)},Yt=function(t){return new l(t,t)},$t="+",Jt='"+"',Vt=function(){return new l(1,1/0)},Zt="*",Qt='"*"',te=function(){return new l(0,1/0)},ee="?",ne='"?"',re=function(){return new l(0,1)},ae=/^[0-9]/,oe="[0-9]",ue=function(t){return+t.join("")},ie="(",le='"("',ce=")",se='")"',he=function(t){return t},pe=function(t){return new u(t)},fe="?:",de='"?:"',me=function(t){return new o("non-capture-group",t)},ve="?=",ge='"?="',xe=function(t){return new o("positive-lookahead",t)},ye="?!",be='"?!"',we=function(t){return new o("negative-lookahead",t)},Ce="CharacterSet",ke="[",Ee='"["',Re="]",Ae='"]"',_e=function(t,e){return new c(!!t,e)},Me="CharacterRange",Pe="-",Te='"-"',He=function(t,e){return new s(t,e)},Se="Character",De=/^[^\\\]]/,qe="[^\\\\\\]]",Fe=function(t){return new h(t)},Le=".",Oe='"."',Ie=function(){return new n("any-character")},je="Literal",Ne=/^[^|\\\/.[()?+*$\^]/,ze="[^|\\\\\\/.[()?+*$\\^]",Ue="\\b",Be='"\\\\b"',Ge=function(){return new n("backspace")},Xe=function(){return new n("word-boundary")},Ke="\\B",We='"\\\\B"',Ye=function(){return new n("non-word-boundary")},$e="\\d",Je='"\\\\d"',Ve=function(){return new n("digit")},Ze="\\D",Qe='"\\\\D"',tn=function(){return new n("non-digit")},en="\\f",nn='"\\\\f"',rn=function(){return new n("form-feed")},an="\\n",on='"\\\\n"',un=function(){return new n("line-feed")},ln="\\r",cn='"\\\\r"',sn=function(){return new n("carriage-return")},hn="\\s",pn='"\\\\s"',fn=function(){return new n("white-space")},dn="\\S",mn='"\\\\S"',vn=function(){return new n("non-white-space")},gn="\\t",xn='"\\\\t"',yn=function(){return new n("tab")},bn="\\v",wn='"\\\\v"',Cn=function(){return new n("vertical-tab"); -},kn="\\w",En='"\\\\w"',Rn=function(){return new n("word")},An="\\W",_n='"\\\\W"',Mn=function(){return new n("non-word")},Pn="\\c",Tn='"\\\\c"',Hn="any character",Sn=function(t){return new v(t)},Dn="\\",qn='"\\\\"',Fn=/^[1-9]/,Ln="[1-9]",On=function(t){return new m(t)},In="\\0",jn='"\\\\0"',Nn=/^[0-7]/,zn="[0-7]",Un=function(t){return new d(t.join(""))},Bn="\\x",Gn='"\\\\x"',Xn=/^[0-9a-fA-F]/,Kn="[0-9a-fA-F]",Wn=function(t){return new f(t.join(""))},Yn="\\u",$n='"\\\\u"',Jn=function(t){return new p(t.join(""))},Vn=function(){return new n("null-character")},Zn=0,Qn=0,tr=0,er={line:1,column:1,seenCR:!1},nr=0,rr=[],ar=0;if("startRule"in bt){if(!(bt.startRule in wt))throw new Error("Can't start parsing from rule \""+bt.startRule+'".');Ct=wt[bt.startRule]}if(n.offset=x,n.text=g,yt=Ct(),null!==yt&&Zn===t.length)return yt;throw w(rr),Qn=Math.max(Zn,nr),new e(rr,Qnr)return!0;var u={path:e,type:t,actual:n,expected:r,action:"is greater than",message:o};return u.message=l.message(u),a.push(u),!1},lessThan:function(t,e,n,r,a,o){if(n=r)return!0;var u={path:e,type:t,actual:n,expected:r,action:"is greater than or equal to",message:o};return u.message=l.message(u),a.push(u),!1},lessThanOrEqualTo:function(t,e,n,r,a,o){if(n<=r)return!0;var u={path:e,type:t,actual:n,expected:r,action:"is less than or equal to",message:o};return u.message=l.message(u),a.push(u),!1}};r.Diff=i,r.Assert=l,t.exports=r},function(t,e,n){t.exports=n(28)},function(t,e,n){function r(){this.custom={events:{},requestHeaders:{},responseHeaders:{}}}function a(){function t(){try{return new window._XMLHttpRequest}catch(t){}}function e(){try{return new window._ActiveXObject("Microsoft.XMLHTTP")}catch(t){}}var n=function(){var t=/^(?:about|app|app-storage|.+-extension|file|res|widget):$/,e=/^([\w.+-]+:)(?:\/\/([^\/?#:]*)(?::(\d+)|)|)/,n=location.href,r=e.exec(n.toLowerCase())||[];return t.test(r[1])}();return window.ActiveXObject?!n&&t()||e():t()}function o(t){function e(t,e){return"string"===i.type(t)?t===e:"regexp"===i.type(t)?t.test(e):void 0}for(var n in r.Mock._mocked){var a=r.Mock._mocked[n];if((!a.rurl||e(a.rurl,t.url))&&(!a.rtype||e(a.rtype,t.type.toLowerCase())))return a}}function u(t,e){return i.isFunction(t.template)?t.template(e):r.Mock.mock(t.template)}var i=n(3);window._XMLHttpRequest=window.XMLHttpRequest,window._ActiveXObject=window.ActiveXObject;try{new window.Event("custom")}catch(t){window.Event=function(t,e,n,r){var a=document.createEvent("CustomEvent");return a.initCustomEvent(t,e,n,r),a}}var l={UNSENT:0,OPENED:1,HEADERS_RECEIVED:2,LOADING:3,DONE:4},c="readystatechange loadstart progress abort error load timeout loadend".split(" "),s="timeout withCredentials".split(" "),h="readyState responseURL status statusText responseType response responseText responseXML".split(" "),p={100:"Continue",101:"Switching Protocols",200:"OK",201:"Created",202:"Accepted",203:"Non-Authoritative Information",204:"No Content",205:"Reset Content",206:"Partial Content",300:"Multiple Choice",301:"Moved Permanently",302:"Found",303:"See Other",304:"Not Modified",305:"Use Proxy",307:"Temporary Redirect",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Request Entity Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",422:"Unprocessable Entity",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported"};r._settings={timeout:"10-100"},r.setup=function(t){return i.extend(r._settings,t),r._settings},i.extend(r,l),i.extend(r.prototype,l),r.prototype.mock=!0,r.prototype.match=!1,i.extend(r.prototype,{open:function(t,e,n,u,l){function p(t){for(var e=0;el<=6?process.emitWarning(e,"DeprecationWarning",m):process.emitWarning(e,{type:"DeprecationWarning",code:m}):e=>console.error(e);function h(e,t){return`${e} option [${t}] is deprecated and will be removed in a later version.`}const p={};try{n(85),p.ASYNC_ITERATOR=!0}catch(e){p.ASYNC_ITERATOR=!1}class f{constructor(e,t){this.db=e,this.collection=t}toString(){return this.collection?`${this.db}.${this.collection}`:this.db}withCollection(e){return new f(this.db,e)}static fromString(e){if(!e)throw new Error(`Cannot parse namespace from "${e}"`);const t=e.indexOf(".");return new f(e.substring(0,t),e.substring(t+1))}}function d(){const e=process.hrtime();return Math.floor(1e3*e[0]+e[1]/1e6)}const m="MONGODB DRIVER";function y(e){return process.emitWarning?l<=6?process.emitWarning(e,void 0,m):process.emitWarning(e,{code:m}):console.error(`[${m}] Warning:`,e)}const g=new Set;e.exports={filterOptions:function(e,t){var n={};for(var r in e)-1!==t.indexOf(r)&&(n[r]=e[r]);return n},mergeOptions:function(e,t){for(var n in t)e[n]=t[n];return e},translateOptions:function(e,t){var n={sslCA:"ca",sslCRL:"crl",sslValidate:"rejectUnauthorized",sslKey:"key",sslCert:"cert",sslPass:"passphrase",socketTimeoutMS:"socketTimeout",connectTimeoutMS:"connectionTimeout",replicaSet:"setName",rs_name:"setName",secondaryAcceptableLatencyMS:"acceptableLatency",connectWithNoPrimary:"secondaryOnlyConnectionAllowed",acceptableLatencyMS:"localThresholdMS"};for(var r in t)n[r]?e[n[r]]=t[r]:e[r]=t[r];return e},shallowClone:function(e){var t={};for(var n in e)t[n]=e[n];return t},getSingleProperty:function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:function(){return n}})},checkCollectionName:function(e){if("string"!=typeof e)throw new r("collection name must be a String");if(!e||-1!==e.indexOf(".."))throw new r("collection names cannot be empty");if(-1!==e.indexOf("$")&&null==e.match(/((^\$cmd)|(oplog\.\$main))/))throw new r("collection names must not contain '$'");if(null!=e.match(/^\.|\.$/))throw new r("collection names must not start or end with '.'");if(-1!==e.indexOf("\0"))throw new r("collection names cannot contain a null character")},toError:function(e){if(e instanceof Error)return e;for(var t=e.err||e.errmsg||e.errMessage||e,n=r.create({message:t,driver:!0}),o="object"==typeof e?Object.keys(e):[],s=0;s{if(null==e)throw new TypeError("This method requires a valid topology instance");if(!Array.isArray(n))throw new TypeError("This method requires an array of arguments to apply");o=o||{};const s=e.s.promiseLibrary;let i,a,c,l=n[n.length-1];if(!o.skipSessions&&e.hasSessionSupport())if(a=n[n.length-2],null==a||null==a.session){c=Symbol(),i=e.startSession({owner:c});const t=n.length-2;n[t]=Object.assign({},n[t],{session:i})}else if(a.session&&a.session.hasEnded)throw new r("Use of expired sessions is not permitted");const u=(e,t)=>function(n,r){if(i&&i.owner===c&&!o.returnsCursor)i.endSession(()=>{if(delete a.session,n)return t(n);e(r)});else{if(n)return t(n);e(r)}};if("function"==typeof l){l=n.pop();const e=u(e=>l(null,e),e=>l(e,null));n.push(e);try{return t.apply(null,n)}catch(t){throw e(t),t}}if(null!=n[n.length-1])throw new TypeError("final argument to `executeLegacyOperation` must be a callback");return new s((function(e,r){const o=u(e,r);n[n.length-1]=o;try{return t.apply(null,n)}catch(e){o(e)}}))},applyRetryableWrites:function(e,t){return t&&t.s.options.retryWrites&&(e.retryWrites=!0),e},applyWriteConcern:function(e,t,n){n=n||{};const r=t.db,s=t.collection;if(n.session&&n.session.inTransaction())return e.writeConcern&&delete e.writeConcern,e;const i=o.fromOptions(n);return i?Object.assign(e,{writeConcern:i}):s&&s.writeConcern?Object.assign(e,{writeConcern:Object.assign({},s.writeConcern)}):r&&r.writeConcern?Object.assign(e,{writeConcern:Object.assign({},r.writeConcern)}):e},isPromiseLike:function(e){return e&&"function"==typeof e.then},decorateWithCollation:function(e,t,n){const o=t.s&&t.s.topology||t.topology;if(!o)throw new TypeError('parameter "target" is missing a topology');const s=o.capabilities();if(n.collation&&"object"==typeof n.collation){if(!s||!s.commandsTakeCollation)throw new r("Current topology does not support collation");e.collation=n.collation}},decorateWithReadConcern:function(e,t,n){if(n&&n.session&&n.session.inTransaction())return;let r=Object.assign({},e.readConcern||{});t.s.readConcern&&Object.assign(r,t.s.readConcern),Object.keys(r).length>0&&Object.assign(e,{readConcern:r})},decorateWithExplain:function(e,t){return e.explain?e:{explain:e,verbosity:t.verbosity}},deprecateOptions:function(e,t){if(!0===process.noDeprecation)return t;const n=e.msgHandler?e.msgHandler:h,r=new Set;function o(){const o=arguments[e.optionsIndex];return a(o)&&0!==Object.keys(o).length?(e.deprecatedOptions.forEach(t=>{if(Object.prototype.hasOwnProperty.call(o,t)&&!r.has(t)){r.add(t);const o=n(e.name,t);if(u(o),this&&this.getLogger){const e=this.getLogger();e&&e.warn(o)}}}),t.apply(this,arguments)):t.apply(this,arguments)}return Object.setPrototypeOf(o,t),t.prototype&&(o.prototype=t.prototype),o},SUPPORTS:p,MongoDBNamespace:f,emitDeprecationWarning:u,makeCounter:function*(e){let t=e||0;for(;;){const e=t;t+=1,yield e}},maybePromise:function(e,t,n){const r=e&&e.s&&e.s.promiseLibrary||Promise;let o;return"function"!=typeof t&&(o=new r((e,n)=>{t=(t,r)=>{if(t)return n(t);e(r)}})),n((function(e,n){if(null==e)t(e,n);else try{t(e)}catch(e){return process.nextTick(()=>{throw e})}})),o},now:d,calculateDurationInMs:function(e){if("number"!=typeof e)throw TypeError("numeric value required to calculate duration");const t=d()-e;return t<0?0:t},makeInterruptableAsyncInterval:function(e,t){let n,r,o,s=!1;const i=(t=t||{}).interval||1e3,a=t.minInterval||500,c="boolean"==typeof t.immediate&&t.immediate,l="function"==typeof t.clock?t.clock:d;function u(e){s||(clearTimeout(n),n=setTimeout(h,e||i))}function h(){o=0,r=l(),e(e=>{if(e)throw e;u(i)})}return c?h():(r=l(),u()),{wake:function(){const e=l(),t=e-o,n=i-(e-r);o=e,ta&&u(a),n<0&&h())},stop:function(){s=!0,n&&(clearTimeout(n),n=null),r=0,o=0}}},hasAtomicOperators:function e(t){return Array.isArray(t)?t.reduce((t,n)=>t||e(n),null):Object.keys("function"!=typeof t.toBSON?t:t.toBSON()).map(e=>e[0]).indexOf("$")>=0},MONGODB_WARNING_CODE:m,emitWarning:y,emitWarningOnce:function(e){if(!g.has(e))return g.add(e),y(e)}}},function(e,t,n){"use strict";const r=n(56).Explain,o=n(3).MongoError,s={READ_OPERATION:Symbol("READ_OPERATION"),WRITE_OPERATION:Symbol("WRITE_OPERATION"),RETRYABLE:Symbol("RETRYABLE"),EXECUTE_WITH_SELECTION:Symbol("EXECUTE_WITH_SELECTION"),NO_INHERIT_OPTIONS:Symbol("NO_INHERIT_OPTIONS"),EXPLAINABLE:Symbol("EXPLAINABLE")};e.exports={Aspect:s,defineAspects:function(e,t){return Array.isArray(t)||t instanceof Set||(t=[t]),t=new Set(t),Object.defineProperty(e,"aspects",{value:t,writable:!1}),t},OperationBase:class{constructor(e){if(this.options=Object.assign({},e),this.hasAspect(s.EXPLAINABLE))this.explain=r.fromOptions(e);else if(void 0!==this.options.explain)throw new o("explain is not supported on this command")}hasAspect(e){return null!=this.constructor.aspects&&this.constructor.aspects.has(e)}set session(e){Object.assign(this.options,{session:e})}get session(){return this.options.session}clearSession(){delete this.options.session}get canRetryRead(){return!0}execute(){throw new TypeError("`execute` must be implemented for OperationBase subclasses")}}}},function(e,t,n){"use strict";let r=n(82);const o=n(66)(n(83)),s=n(4).retrieveEJSON();try{const e=o("bson-ext");e&&(r=e)}catch(e){}e.exports={MongoError:n(3).MongoError,MongoNetworkError:n(3).MongoNetworkError,MongoParseError:n(3).MongoParseError,MongoTimeoutError:n(3).MongoTimeoutError,MongoServerSelectionError:n(3).MongoServerSelectionError,MongoWriteConcernError:n(3).MongoWriteConcernError,Connection:n(84),Server:n(68),ReplSet:n(145),Mongos:n(147),Logger:n(14),Cursor:n(15).CoreCursor,ReadPreference:n(10),Sessions:n(27),BSON:r,EJSON:s,Topology:n(148).Topology,Query:n(16).Query,MongoCredentials:n(94).MongoCredentials,defaultAuthProviders:n(89).defaultAuthProviders,MongoCR:n(90),X509:n(91),Plain:n(92),GSSAPI:n(93),ScramSHA1:n(55).ScramSHA1,ScramSHA256:n(55).ScramSHA256,parseConnectionString:n(165)}},function(e,t,n){"use strict";const r=Symbol("errorLabels");class o extends Error{constructor(e){if(e instanceof Error)super(e.message),this.stack=e.stack;else{if("string"==typeof e)super(e);else for(var t in super(e.message||e.errmsg||e.$err||"n/a"),e.errorLabels&&(this[r]=new Set(e.errorLabels)),e)"errorLabels"!==t&&"errmsg"!==t&&(this[t]=e[t]);Error.captureStackTrace(this,this.constructor)}this.name="MongoError"}get errmsg(){return this.message}static create(e){return new o(e)}hasErrorLabel(e){return null!=this[r]&&this[r].has(e)}addErrorLabel(e){null==this[r]&&(this[r]=new Set),this[r].add(e)}get errorLabels(){return this[r]?Array.from(this[r]):[]}}const s=Symbol("beforeHandshake");class i extends o{constructor(e,t){super(e),this.name="MongoNetworkError",t&&!0===t.beforeHandshake&&(this[s]=!0)}}class a extends o{constructor(e){super(e),this.name="MongoParseError"}}class c extends o{constructor(e,t){t&&t.error?super(t.error.message||t.error):super(e),this.name="MongoTimeoutError",t&&(this.reason=t)}}class l extends o{constructor(e,t){super(e),this.name="MongoWriteConcernError",t&&Array.isArray(t.errorLabels)&&(this[r]=new Set(t.errorLabels)),null!=t&&(this.result=function(e){const t=Object.assign({},e);return 0===t.ok&&(t.ok=1,delete t.errmsg,delete t.code,delete t.codeName),t}(t))}}const u=new Set([6,7,89,91,189,9001,10107,11600,11602,13435,13436]),h=new Set([11600,11602,10107,13435,13436,189,91,7,6,89,9001,262]);const p=new Set([91,189,11600,11602,13436]),f=new Set([10107,13435]),d=new Set([11600,91]);function m(e){return!(!e.code||!p.has(e.code))||(e.message.match(/not master or secondary/)||e.message.match(/node is recovering/))}e.exports={MongoError:o,MongoNetworkError:i,MongoNetworkTimeoutError:class extends i{constructor(e,t){super(e,t),this.name="MongoNetworkTimeoutError"}},MongoParseError:a,MongoTimeoutError:c,MongoServerSelectionError:class extends c{constructor(e,t){super(e,t),this.name="MongoServerSelectionError"}},MongoWriteConcernError:l,isRetryableError:function(e){return u.has(e.code)||e instanceof i||e.message.match(/not master/)||e.message.match(/node is recovering/)},isSDAMUnrecoverableError:function(e){return e instanceof a||null==e||!!(m(e)||(t=e,t.code&&f.has(t.code)||!m(t)&&t.message.match(/not master/)));var t},isNodeShuttingDownError:function(e){return e.code&&d.has(e.code)},isRetryableWriteError:function(e){return e instanceof l?h.has(e.code)||h.has(e.result.code):h.has(e.code)},isNetworkErrorBeforeHandshake:function(e){return!0===e[s]}}},function(e,t,n){"use strict";const r=n(127),o=n(25),s=n(66)(n(83));const i=function(){throw new Error("The `mongodb-extjson` module was not found. Please install it and try again.")};function a(e){if(e){if(e.ismaster)return e.ismaster.maxWireVersion;if("function"==typeof e.lastIsMaster){const t=e.lastIsMaster();if(t)return t.maxWireVersion}if(e.description)return e.description.maxWireVersion}return 0}e.exports={uuidV4:()=>{const e=o.randomBytes(16);return e[6]=15&e[6]|64,e[8]=63&e[8]|128,e},relayEvents:function(e,t,n){n.forEach(n=>e.on(n,e=>t.emit(n,e)))},collationNotSupported:function(e,t){return t&&t.collation&&a(e)<5},retrieveEJSON:function(){let e=s("mongodb-extjson");return e||(e={parse:i,deserialize:i,serialize:i,stringify:i,setBSONModule:i,BSON:i}),e},retrieveKerberos:function(){let e;try{e=s("kerberos")}catch(e){if("MODULE_NOT_FOUND"===e.code)throw new Error("The `kerberos` module was not found. Please install it and try again.");throw e}return e},maxWireVersion:a,isPromiseLike:function(e){return e&&"function"==typeof e.then},eachAsync:function(e,t,n){e=e||[];let r=0,o=0;for(r=0;re===t[n]))},tagsStrictEqual:function(e,t){const n=Object.keys(e),r=Object.keys(t);return n.length===r.length&&n.every(n=>t[n]===e[n])},errorStrictEqual:function(e,t){return e===t||!(null==e&&null!=t||null!=e&&null==t)&&(e.constructor.name===t.constructor.name&&e.message===t.message)},makeStateMachine:function(e){return function(t,n){const r=e[t.s.state];if(r&&r.indexOf(n)<0)throw new TypeError(`illegal state transition from [${t.s.state}] => [${n}], allowed: [${r}]`);t.emit("stateChanged",t.s.state,n),t.s.state=n}},makeClientMetadata:function(e){e=e||{};const t={driver:{name:"nodejs",version:n(128).version},os:{type:r.type(),name:process.platform,architecture:process.arch,version:r.release()},platform:`'Node.js ${process.version}, ${r.endianness} (${e.useUnifiedTopology?"unified":"legacy"})`};if(e.driverInfo&&(e.driverInfo.name&&(t.driver.name=`${t.driver.name}|${e.driverInfo.name}`),e.driverInfo.version&&(t.version=`${t.driver.version}|${e.driverInfo.version}`),e.driverInfo.platform&&(t.platform=`${t.platform}|${e.driverInfo.platform}`)),e.appname){const n=Buffer.from(e.appname);t.application={name:n.length>128?n.slice(0,128).toString("utf8"):e.appname}}return t},noop:()=>{}}},function(e,t){e.exports=require("util")},function(e,t,n){"use strict";const r=n(10),o=n(3).MongoError,s=n(12).ServerType,i=n(86).TopologyDescription;e.exports={getReadPreference:function(e,t){var n=e.readPreference||new r("primary");if(t.readPreference&&(n=t.readPreference),"string"==typeof n&&(n=new r(n)),!(n instanceof r))throw new o("read preference must be a ReadPreference instance");return n},MESSAGE_HEADER_SIZE:16,COMPRESSION_DETAILS_SIZE:9,opcodes:{OP_REPLY:1,OP_UPDATE:2001,OP_INSERT:2002,OP_QUERY:2004,OP_GETMORE:2005,OP_DELETE:2006,OP_KILL_CURSORS:2007,OP_COMPRESSED:2012,OP_MSG:2013},parseHeader:function(e){return{length:e.readInt32LE(0),requestId:e.readInt32LE(4),responseTo:e.readInt32LE(8),opCode:e.readInt32LE(12)}},applyCommonQueryOptions:function(e,t){return Object.assign(e,{raw:"boolean"==typeof t.raw&&t.raw,promoteLongs:"boolean"!=typeof t.promoteLongs||t.promoteLongs,promoteValues:"boolean"!=typeof t.promoteValues||t.promoteValues,promoteBuffers:"boolean"==typeof t.promoteBuffers&&t.promoteBuffers,monitoring:"boolean"==typeof t.monitoring&&t.monitoring,fullResult:"boolean"==typeof t.fullResult&&t.fullResult}),"number"==typeof t.socketTimeout&&(e.socketTimeout=t.socketTimeout),t.session&&(e.session=t.session),"string"==typeof t.documentsReturnedIn&&(e.documentsReturnedIn=t.documentsReturnedIn),e},isSharded:function(e){if("mongos"===e.type)return!0;if(e.description&&e.description.type===s.Mongos)return!0;if(e.description&&e.description instanceof i){return Array.from(e.description.servers.values()).some(e=>e.type===s.Mongos)}return!1},databaseNamespace:function(e){return e.split(".")[0]},collectionNamespace:function(e){return e.split(".").slice(1).join(".")}}},function(e,t,n){"use strict";const r=n(10),o=n(12).TopologyType,s=n(3).MongoError,i=n(3).isRetryableWriteError,a=n(4).maxWireVersion,c=n(3).MongoNetworkError;function l(e,t,n){e.listeners(t).length>0&&e.emit(t,n)}var u=function(e){return e.s.serverDescription||(e.s.serverDescription={address:e.name,arbiters:[],hosts:[],passives:[],type:"Unknown"}),e.s.serverDescription},h=function(e,t){e.listeners("serverDescriptionChanged").length>0&&(e.emit("serverDescriptionChanged",{topologyId:-1!==e.s.topologyId?e.s.topologyId:e.id,address:e.name,previousDescription:u(e),newDescription:t}),e.s.serverDescription=t)},p=function(e){return e.s.topologyDescription||(e.s.topologyDescription={topologyType:"Unknown",servers:[{address:e.name,arbiters:[],hosts:[],passives:[],type:"Unknown"}]}),e.s.topologyDescription},f=function(e,t){return t||(t=e.ismaster),t?t.ismaster&&"isdbgrid"===t.msg?"Mongos":t.ismaster&&!t.hosts?"Standalone":t.ismaster?"RSPrimary":t.secondary?"RSSecondary":t.arbiterOnly?"RSArbiter":"Unknown":"Unknown"},d=function(e){return function(t){if("destroyed"!==e.s.state){var n=(new Date).getTime();l(e,"serverHeartbeatStarted",{connectionId:e.name}),e.command("admin.$cmd",{ismaster:!0},{monitoring:!0},(function(r,o){if(r)l(e,"serverHeartbeatFailed",{durationMS:s,failure:r,connectionId:e.name});else{e.emit("ismaster",o,e);var s=(new Date).getTime()-n;l(e,"serverHeartbeatSucceeded",{durationMS:s,reply:o.result,connectionId:e.name}),function(e,t,n){var r=f(e,t);return f(e,n)!==r}(e,e.s.ismaster,o.result)&&h(e,{address:e.name,arbiters:[],hosts:[],passives:[],type:e.s.inTopology?f(e):"Standalone"}),e.s.ismaster=o.result,e.s.isMasterLatencyMS=s}if("function"==typeof t)return t(r,o);e.s.inquireServerStateTimeout=setTimeout(d(e),e.s.haInterval)}))}}};const m={endSessions:function(e,t){Array.isArray(e)||(e=[e]),this.command("admin.$cmd",{endSessions:e},{readPreference:r.primaryPreferred},()=>{"function"==typeof t&&t()})}};function y(e){return e.description?e.description.type:"mongos"===e.type?o.Sharded:"replset"===e.type?o.ReplicaSetWithPrimary:o.Single}const g=function(e){return!(e.lastIsMaster().maxWireVersion<6)&&(!!e.logicalSessionTimeoutMinutes&&y(e)!==o.Single)},b="This MongoDB deployment does not support retryable writes. Please add retryWrites=false to your connection string.";e.exports={SessionMixins:m,resolveClusterTime:function(e,t){(null==e.clusterTime||t.clusterTime.greaterThan(e.clusterTime.clusterTime))&&(e.clusterTime=t)},inquireServerState:d,getTopologyType:f,emitServerDescriptionChanged:h,emitTopologyDescriptionChanged:function(e,t){e.listeners("topologyDescriptionChanged").length>0&&(e.emit("topologyDescriptionChanged",{topologyId:-1!==e.s.topologyId?e.s.topologyId:e.id,address:e.name,previousDescription:p(e),newDescription:t}),e.s.serverDescription=t)},cloneOptions:function(e){var t={};for(var n in e)t[n]=e[n];return t},createCompressionInfo:function(e){return e.compression&&e.compression.compressors?(e.compression.compressors.forEach((function(e){if("snappy"!==e&&"zlib"!==e)throw new Error("compressors must be at least one of snappy or zlib")})),e.compression.compressors):[]},clone:function(e){return JSON.parse(JSON.stringify(e))},diff:function(e,t){var n={servers:[]};e||(e={servers:[]});for(var r=0;r{n&&(clearTimeout(n),n=!1,e())};this.start=function(){return this.isRunning()||(n=setTimeout(r,t)),this},this.stop=function(){return clearTimeout(n),n=!1,this},this.isRunning=function(){return!1!==n}},isRetryableWritesSupported:g,getMMAPError:function(e){return 20===e.code&&e.errmsg.includes("Transaction numbers")?new s({message:b,errmsg:b,originalError:e}):e},topologyType:y,legacyIsRetryableWriteError:function(e,t){return e instanceof s&&(g(t)&&(e instanceof c||a(t)<9&&i(e))&&e.addErrorLabel("RetryableWriteError"),e.hasErrorLabel("RetryableWriteError"))}}},function(e,t){e.exports=require("events")},function(e,t,n){"use strict";const r=n(66)(n(129));function o(){throw new Error("Attempted to use Snappy compression, but Snappy is not installed. Install or disable Snappy compression and try again.")}e.exports={debugOptions:function(e,t){const n={};return e.forEach((function(e){n[e]=t[e]})),n},retrieveBSON:function(){const e=n(82);e.native=!1;const t=r("bson-ext");return t?(t.native=!0,t):e},retrieveSnappy:function(){let e=r("snappy");return e||(e={compress:o,uncompress:o,compressSync:o,uncompressSync:o}),e}}},function(e,t,n){"use strict";const r=n(0).emitWarningOnce,o=function(e,t,n){if(!o.isValid(e))throw new TypeError("Invalid read preference mode "+e);if(t&&!Array.isArray(t)){r("ReadPreference tags must be an array, this will change in the next major version");const e=void 0!==t.maxStalenessSeconds,o=void 0!==t.hedge;e||o?(n=t,t=void 0):t=[t]}if(this.mode=e,this.tags=t,this.hedge=n&&n.hedge,null!=(n=n||{}).maxStalenessSeconds){if(n.maxStalenessSeconds<=0)throw new TypeError("maxStalenessSeconds must be a positive integer");this.maxStalenessSeconds=n.maxStalenessSeconds,this.minWireVersion=5}if(this.mode===o.PRIMARY){if(this.tags&&Array.isArray(this.tags)&&this.tags.length>0)throw new TypeError("Primary read preference cannot be combined with tags");if(this.maxStalenessSeconds)throw new TypeError("Primary read preference cannot be combined with maxStalenessSeconds");if(this.hedge)throw new TypeError("Primary read preference cannot be combined with hedge")}};Object.defineProperty(o.prototype,"preference",{enumerable:!0,get:function(){return this.mode}}),o.PRIMARY="primary",o.PRIMARY_PREFERRED="primaryPreferred",o.SECONDARY="secondary",o.SECONDARY_PREFERRED="secondaryPreferred",o.NEAREST="nearest";const s=[o.PRIMARY,o.PRIMARY_PREFERRED,o.SECONDARY,o.SECONDARY_PREFERRED,o.NEAREST,null];o.fromOptions=function(e){if(!e)return null;const t=e.readPreference;if(!t)return null;const n=e.readPreferenceTags,r=e.maxStalenessSeconds;if("string"==typeof t)return new o(t,n);if(!(t instanceof o)&&"object"==typeof t){const e=t.mode||t.preference;if(e&&"string"==typeof e)return new o(e,t.tags,{maxStalenessSeconds:t.maxStalenessSeconds||r,hedge:t.hedge})}return t},o.resolve=function(e,t){const n=(t=t||{}).session,r=e&&e.readPreference;let s;return s=t.readPreference?o.fromOptions(t):n&&n.inTransaction()&&n.transaction.options.readPreference?n.transaction.options.readPreference:null!=r?r:o.primary,"string"==typeof s?new o(s):s},o.translate=function(e){if(null==e.readPreference)return e;const t=e.readPreference;if("string"==typeof t)e.readPreference=new o(t);else if(!t||t instanceof o||"object"!=typeof t){if(!(t instanceof o))throw new TypeError("Invalid read preference: "+t)}else{const n=t.mode||t.preference;n&&"string"==typeof n&&(e.readPreference=new o(n,t.tags,{maxStalenessSeconds:t.maxStalenessSeconds}))}return e},o.isValid=function(e){return-1!==s.indexOf(e)},o.prototype.isValid=function(e){return o.isValid("string"==typeof e?e:this.mode)};const i=["primaryPreferred","secondary","secondaryPreferred","nearest"];o.prototype.slaveOk=function(){return-1!==i.indexOf(this.mode)},o.prototype.equals=function(e){return e.mode===this.mode},o.prototype.toJSON=function(){const e={mode:this.mode};return Array.isArray(this.tags)&&(e.tags=this.tags),this.maxStalenessSeconds&&(e.maxStalenessSeconds=this.maxStalenessSeconds),this.hedge&&(e.hedge=this.hedge),e},o.primary=new o("primary"),o.primaryPreferred=new o("primaryPreferred"),o.secondary=new o("secondary"),o.secondaryPreferred=new o("secondaryPreferred"),o.nearest=new o("nearest"),e.exports=o},function(e,t,n){"use strict";const r=n(0).applyWriteConcern,o=n(2).BSON.Code,s=n(0).debugOptions,i=n(0).handleCallback,a=n(2).MongoError,c=n(0).parseIndexOptions,l=n(2).ReadPreference,u=n(0).toError,h=n(75),p=n(0).MongoDBNamespace,f=["authSource","w","wtimeout","j","native_parser","forceServerObjectId","serializeFunctions","raw","promoteLongs","promoteValues","promoteBuffers","bufferMaxEntries","numberOfRetries","retryMiliSeconds","readPreference","pkFactory","parentDb","promiseLibrary","noListener"];function d(e,t,n,o,s){let p=Object.assign({},{readPreference:l.PRIMARY},o);if(p=r(p,{db:e},o),p.writeConcern&&"function"!=typeof s)throw a.create({message:"Cannot use a writeConcern without a provided callback",driver:!0});if(e.serverConfig&&e.serverConfig.isDestroyed())return s(new a("topology was destroyed"));!function(e,t,n,o,s){const h=c(n),p="string"==typeof o.name?o.name:h.name,f=[{name:p,key:h.fieldHash}],d=Object.keys(f[0]).concat(["writeConcern","w","wtimeout","j","fsync","readPreference","session"]);for(let e in o)-1===d.indexOf(e)&&(f[0][e]=o[e]);const y=e.s.topology.capabilities();if(f[0].collation&&y&&!y.commandsTakeCollation){const e=new a("server/primary/mongos does not support collation");return e.code=67,s(e)}const g=r({createIndexes:t,indexes:f},{db:e},o);o.readPreference=l.PRIMARY,m(e,g,o,(e,t)=>e?i(s,e,null):0===t.ok?i(s,u(t),null):void i(s,null,p))}(e,t,n,p,(r,c)=>{if(null==r)return i(s,r,c);if(67===r.code||11e3===r.code||85===r.code||86===r.code||11600===r.code||197===r.code)return i(s,r,c);const l=g(e,t,n,o);p.checkKeys=!1,e.s.topology.insert(e.s.namespace.withCollection(h.SYSTEM_INDEX_COLLECTION),l,p,(e,t)=>{if(null!=s)return e?i(s,e):null==t?i(s,null,null):t.result.writeErrors?i(s,a.create(t.result.writeErrors[0]),null):void i(s,null,l.name)})})}function m(e,t,n,r){if(e.serverConfig&&e.serverConfig.isDestroyed())return r(new a("topology was destroyed"));const o=n.dbName||n.authdb||e.databaseName;n.readPreference=l.resolve(e,n),e.s.logger.isDebug()&&e.s.logger.debug(`executing command ${JSON.stringify(t)} against ${o}.$cmd with options [${JSON.stringify(s(f,n))}]`),e.s.topology.command(e.s.namespace.withCollection("$cmd"),t,n,(e,t)=>e?i(r,e):n.full?i(r,null,t):void i(r,null,t.result))}function y(e,t,n,r){const o=null!=n.full&&n.full;if(e.serverConfig&&e.serverConfig.isDestroyed())return r(new a("topology was destroyed"));e.collection(t).listIndexes(n).toArray((e,t)=>e?r(u(e)):Array.isArray(t)?o?i(r,null,t):void i(r,null,function(e){let t={};for(let n=0;n0){n.emit(t,r,e);for(let n=0;n{if(null!=r&&26!==r.code)return i(s,r,null);if(null!=a&&a[u]){if("function"==typeof s)return i(s,null,u)}else d(e,t,n,o,s)})},evaluate:function(e,t,n,r,s){let c=t,u=[];if(e.serverConfig&&e.serverConfig.isDestroyed())return s(new a("topology was destroyed"));c&&"Code"===c._bsontype||(c=new o(c)),null==n||Array.isArray(n)||"function"==typeof n?null!=n&&Array.isArray(n)&&"function"!=typeof n&&(u=n):u=[n];let h={$eval:c,args:u};r.nolock&&(h.nolock=r.nolock),r.readPreference=new l(l.PRIMARY),m(e,h,r,(e,t)=>e?i(s,e,null):t&&1===t.ok?i(s,null,t.retval):t?i(s,a.create({message:"eval failed: "+t.errmsg,driver:!0}),null):void i(s,e,t))},executeCommand:m,executeDbAdminCommand:function(e,t,n,r){const o=new p("admin","$cmd");e.s.topology.command(o,t,n,(t,n)=>e.serverConfig&&e.serverConfig.isDestroyed()?r(new a("topology was destroyed")):t?i(r,t):void i(r,null,n.result))},indexInformation:y,profilingInfo:function(e,t,n){try{e.collection("system.profile").find({},t).toArray(n)}catch(e){return n(e,null)}},validateDatabaseName:function(e){if("string"!=typeof e)throw a.create({message:"database name must be a string",driver:!0});if(0===e.length)throw a.create({message:"database name cannot be the empty string",driver:!0});if("$external"===e)return;const t=[" ",".","$","/","\\"];for(let n=0;n(!0!==r&&null==t._id&&(t._id=e.s.pkFactory.createPk()),t))}e.exports={buildCountCommand:function(e,t,n){const r=n.skip,o=n.limit;let a=n.hint;const c=n.maxTimeMS;t=t||{};const l={count:n.collectionName,query:t};return e.s.numberOfRetries?(e.options.hint?a=e.options.hint:e.cmd.hint&&(a=e.cmd.hint),s(l,e,e.cmd)):s(l,e,n),"number"==typeof r&&(l.skip=r),"number"==typeof o&&(l.limit=o),"number"==typeof c&&(l.maxTimeMS=c),a&&(l.hint=a),i(l,e),l},findAndModify:function(e,t,n,i,u,p){const f={findAndModify:e.collectionName,query:t};(n=c(n))&&(f.sort=n),f.new=!!u.new,f.remove=!!u.remove,f.upsert=!!u.upsert;const d=u.projection||u.fields;d&&(f.fields=d),u.arrayFilters&&(f.arrayFilters=u.arrayFilters,delete u.arrayFilters),i&&!u.remove&&(f.update=i),u.maxTimeMS&&(f.maxTimeMS=u.maxTimeMS),u.serializeFunctions=u.serializeFunctions||e.s.serializeFunctions,u.checkKeys=!1;let m=Object.assign({},u);m=r(m,e.s.db),m=o(m,{db:e.s.db,collection:e},u),m.writeConcern&&(f.writeConcern=m.writeConcern),!0===m.bypassDocumentValidation&&(f.bypassDocumentValidation=m.bypassDocumentValidation),m.readPreference=h.primary;try{s(f,e,m)}catch(e){return p(e,null)}a(e.s.db,f,m,(e,t)=>e?l(p,e,null):l(p,null,t))},indexInformation:function(e,t,n,r){const o=null!=n.full&&n.full;if(e.serverConfig&&e.serverConfig.isDestroyed())return r(new u("topology was destroyed"));e.collection(t).listIndexes(n).toArray((e,t)=>e?r(p(e)):Array.isArray(t)?o?l(r,null,t):void l(r,null,function(e){let t={};for(let n=0;n{if(e.s.state=f.OPEN,n)return l(t,n);l(t,null,r)})},prepareDocs:m,insertDocuments:function(e,t,n,s){"function"==typeof n&&(s=n,n={}),n=n||{},t=Array.isArray(t)?t:[t];let i=Object.assign({},n);i=r(i,e.s.db),i=o(i,{db:e.s.db,collection:e},n),!0===i.keepGoing&&(i.ordered=!1),i.serializeFunctions=n.serializeFunctions||e.s.serializeFunctions,t=m(e,t,n),e.s.topology.insert(e.s.namespace,t,i,(e,n)=>{if(null!=s){if(e)return l(s,e);if(null==n)return l(s,null,null);if(n.result.code)return l(s,p(n.result));if(n.result.writeErrors)return l(s,p(n.result.writeErrors[0]));n.ops=t,l(s,null,n)}})},removeDocuments:function(e,t,n,i){"function"==typeof n?(i=n,n={}):"function"==typeof t&&(i=t,n={},t={}),n=n||{};let a=Object.assign({},n);a=r(a,e.s.db),a=o(a,{db:e.s.db,collection:e},n),null==t&&(t={});const c={q:t,limit:0};n.single?c.limit=1:a.retryWrites&&(a.retryWrites=!1),n.hint&&(c.hint=n.hint);try{s(a,e,n)}catch(e){return i(e,null)}if(void 0!==n.explain&&d(e.s.topology)<3)return i?i(new u("server does not support explain on remove")):void 0;e.s.topology.remove(e.s.namespace,[c],a,(e,t)=>{if(null!=i)return e?l(i,e,null):null==t?l(i,null,null):t.result.code?l(i,p(t.result)):t.result.writeErrors?l(i,p(t.result.writeErrors[0])):void l(i,null,t)})},updateDocuments:function(e,t,n,i,a){if("function"==typeof i&&(a=i,i=null),null==i&&(i={}),"function"!=typeof a&&(a=null),null==t||"object"!=typeof t)return a(p("selector must be a valid JavaScript object"));if(null==n||"object"!=typeof n)return a(p("document must be a valid JavaScript object"));let c=Object.assign({},i);c=r(c,e.s.db),c=o(c,{db:e.s.db,collection:e},i),c.serializeFunctions=i.serializeFunctions||e.s.serializeFunctions;const h={q:t,u:n};h.upsert=void 0!==i.upsert&&!!i.upsert,h.multi=void 0!==i.multi&&!!i.multi,i.hint&&(h.hint=i.hint),c.arrayFilters&&(h.arrayFilters=c.arrayFilters,delete c.arrayFilters),c.retryWrites&&h.multi&&(c.retryWrites=!1);try{s(c,e,i)}catch(e){return a(e,null)}if(void 0!==i.explain&&d(e.s.topology)<3)return a?a(new u("server does not support explain on update")):void 0;e.s.topology.update(e.s.namespace,[h],c,(e,t)=>{if(null!=a)return e?l(a,e,null):null==t?l(a,null,null):t.result.code?l(a,p(t.result)):t.result.writeErrors?l(a,p(t.result.writeErrors[0])):void l(a,null,t)})}}},function(e,t,n){"use strict";var r=n(5).format,o=n(3).MongoError,s={},i={},a=null,c=process.pid,l=null,u=function(e,t){if(!(this instanceof u))return new u(e,t);t=t||{},this.className=e,t.logger?l=t.logger:null==l&&(l=console.log),t.loggerLevel&&(a=t.loggerLevel||"error"),null==i[this.className]&&(s[this.className]=!0)};u.prototype.debug=function(e,t){if(this.isDebug()&&(Object.keys(i).length>0&&i[this.className]||0===Object.keys(i).length&&s[this.className])){var n=(new Date).getTime(),o=r("[%s-%s:%s] %s %s","DEBUG",this.className,c,n,e),a={type:"debug",message:e,className:this.className,pid:c,date:n};t&&(a.meta=t),l(o,a)}},u.prototype.warn=function(e,t){if(this.isWarn()&&(Object.keys(i).length>0&&i[this.className]||0===Object.keys(i).length&&s[this.className])){var n=(new Date).getTime(),o=r("[%s-%s:%s] %s %s","WARN",this.className,c,n,e),a={type:"warn",message:e,className:this.className,pid:c,date:n};t&&(a.meta=t),l(o,a)}},u.prototype.info=function(e,t){if(this.isInfo()&&(Object.keys(i).length>0&&i[this.className]||0===Object.keys(i).length&&s[this.className])){var n=(new Date).getTime(),o=r("[%s-%s:%s] %s %s","INFO",this.className,c,n,e),a={type:"info",message:e,className:this.className,pid:c,date:n};t&&(a.meta=t),l(o,a)}},u.prototype.error=function(e,t){if(this.isError()&&(Object.keys(i).length>0&&i[this.className]||0===Object.keys(i).length&&s[this.className])){var n=(new Date).getTime(),o=r("[%s-%s:%s] %s %s","ERROR",this.className,c,n,e),a={type:"error",message:e,className:this.className,pid:c,date:n};t&&(a.meta=t),l(o,a)}},u.prototype.isInfo=function(){return"info"===a||"debug"===a},u.prototype.isError=function(){return"error"===a||"info"===a||"debug"===a},u.prototype.isWarn=function(){return"error"===a||"warn"===a||"info"===a||"debug"===a},u.prototype.isDebug=function(){return"debug"===a},u.reset=function(){a="error",i={}},u.currentLogger=function(){return l},u.setCurrentLogger=function(e){if("function"!=typeof e)throw new o("current logger must be a function");l=e},u.filter=function(e,t){"class"===e&&Array.isArray(t)&&(i={},t.forEach((function(e){i[e]=!0})))},u.setLevel=function(e){if("info"!==e&&"error"!==e&&"debug"!==e&&"warn"!==e)throw new Error(r("%s is an illegal logging level",e));a=e},e.exports=u},function(e,t,n){"use strict";const r=n(14),o=n(9).retrieveBSON,s=n(3).MongoError,i=n(3).MongoNetworkError,a=n(4).collationNotSupported,c=n(10),l=n(4).isUnifiedTopology,u=n(37),h=n(19).Readable,p=n(0).SUPPORTS,f=n(0).MongoDBNamespace,d=n(0).mergeOptions,m=n(1).OperationBase,y=o().Long,g={INIT:0,OPEN:1,CLOSED:2,GET_MORE:3};function b(e,t,n){try{e(t,n)}catch(t){process.nextTick((function(){throw t}))}}class S extends h{constructor(e,t,n,o){super({objectMode:!0}),o=o||{},t instanceof m&&(this.operation=t,t=this.operation.ns.toString(),o=this.operation.options,n=this.operation.cmd?this.operation.cmd:{}),this.pool=null,this.server=null,this.disconnectHandler=o.disconnectHandler,this.bson=e.s.bson,this.ns=t,this.namespace=f.fromString(t),this.cmd=n,this.options=o,this.topology=e,this.cursorState={cursorId:null,cmd:n,documents:o.documents||[],cursorIndex:0,dead:!1,killed:!1,init:!1,notified:!1,limit:o.limit||n.limit||0,skip:o.skip||n.skip||0,batchSize:o.batchSize||n.batchSize||1e3,currentLimit:0,transforms:o.transforms,raw:o.raw||n&&n.raw},"object"==typeof o.session&&(this.cursorState.session=o.session);const s=e.s.options;"boolean"==typeof s.promoteLongs?this.cursorState.promoteLongs=s.promoteLongs:"boolean"==typeof o.promoteLongs&&(this.cursorState.promoteLongs=o.promoteLongs),"boolean"==typeof s.promoteValues?this.cursorState.promoteValues=s.promoteValues:"boolean"==typeof o.promoteValues&&(this.cursorState.promoteValues=o.promoteValues),"boolean"==typeof s.promoteBuffers?this.cursorState.promoteBuffers=s.promoteBuffers:"boolean"==typeof o.promoteBuffers&&(this.cursorState.promoteBuffers=o.promoteBuffers),s.reconnect&&(this.cursorState.reconnect=s.reconnect),this.logger=r("Cursor",s),"number"==typeof n?(this.cursorState.cursorId=y.fromNumber(n),this.cursorState.lastCursorId=this.cursorState.cursorId):n instanceof y&&(this.cursorState.cursorId=n,this.cursorState.lastCursorId=n),this.operation&&(this.operation.cursorState=this.cursorState)}setCursorBatchSize(e){this.cursorState.batchSize=e}cursorBatchSize(){return this.cursorState.batchSize}setCursorLimit(e){this.cursorState.limit=e}cursorLimit(){return this.cursorState.limit}setCursorSkip(e){this.cursorState.skip=e}cursorSkip(){return this.cursorState.skip}_next(e){!function e(t,n){if(t.cursorState.notified)return n(new Error("cursor is exhausted"));if(function(e,t){if(e.cursorState.killed)return w(e,t),!0;return!1}(t,n))return;if(function(e,t){if(e.cursorState.dead&&!e.cursorState.killed)return e.cursorState.killed=!0,w(e,t),!0;return!1}(t,n))return;if(function(e,t){if(e.cursorState.dead&&e.cursorState.killed)return b(t,new s("cursor is dead")),!0;return!1}(t,n))return;if(!t.cursorState.init){if(!t.topology.isConnected(t.options)){if("server"===t.topology._type&&!t.topology.s.options.reconnect)return n(new s("no connection available"));if(null!=t.disconnectHandler)return t.topology.isDestroyed()?n(new s("Topology was destroyed")):void t.disconnectHandler.addObjectAndMethod("cursor",t,"next",[n],n)}return void t._initializeCursor((r,o)=>{r||null===o?n(r,o):e(t,n)})}if(t.cursorState.limit>0&&t.cursorState.currentLimit>=t.cursorState.limit)t.kill(()=>v(t,n));else if(t.cursorState.cursorIndex!==t.cursorState.documents.length||y.ZERO.equals(t.cursorState.cursorId)){if(t.cursorState.documents.length===t.cursorState.cursorIndex&&t.cmd.tailable&&y.ZERO.equals(t.cursorState.cursorId))return b(n,new s({message:"No more documents in tailed cursor",tailable:t.cmd.tailable,awaitData:t.cmd.awaitData}));if(t.cursorState.documents.length===t.cursorState.cursorIndex&&y.ZERO.equals(t.cursorState.cursorId))v(t,n);else{if(t.cursorState.limit>0&&t.cursorState.currentLimit>=t.cursorState.limit)return void t.kill(()=>v(t,n));t.cursorState.currentLimit+=1;let e=t.cursorState.documents[t.cursorState.cursorIndex++];if(!e||e.$err)return void t.kill(()=>v(t,(function(){b(n,new s(e?e.$err:void 0))})));t.cursorState.transforms&&"function"==typeof t.cursorState.transforms.doc&&(e=t.cursorState.transforms.doc(e)),b(n,null,e)}}else{if(t.cursorState.documents=[],t.cursorState.cursorIndex=0,t.topology.isDestroyed())return n(new i("connection destroyed, not possible to instantiate cursor"));if(function(e,t){if(e.pool&&e.pool.isDestroyed()){e.cursorState.killed=!0;const n=new i(`connection to host ${e.pool.host}:${e.pool.port} was destroyed`);return O(e,()=>t(n)),!0}return!1}(t,n))return;t._getMore((function(r,o,i){return r?b(n,r):(t.connection=i,0===t.cursorState.documents.length&&t.cmd.tailable&&y.ZERO.equals(t.cursorState.cursorId)?b(n,new s({message:"No more documents in tailed cursor",tailable:t.cmd.tailable,awaitData:t.cmd.awaitData})):0===t.cursorState.documents.length&&t.cmd.tailable&&!y.ZERO.equals(t.cursorState.cursorId)?e(t,n):t.cursorState.limit>0&&t.cursorState.currentLimit>=t.cursorState.limit?v(t,n):void e(t,n))}))}}(this,e)}clone(){const e=d({},this.options);return delete e.session,this.topology.cursor(this.ns,this.cmd,e)}isDead(){return!0===this.cursorState.dead}isKilled(){return!0===this.cursorState.killed}isNotified(){return!0===this.cursorState.notified}bufferedCount(){return this.cursorState.documents.length-this.cursorState.cursorIndex}readBufferedDocuments(e){const t=this.cursorState.documents.length-this.cursorState.cursorIndex,n=e0&&this.cursorState.currentLimit+r.length>this.cursorState.limit&&(r=r.slice(0,this.cursorState.limit-this.cursorState.currentLimit),this.kill()),this.cursorState.currentLimit=this.cursorState.currentLimit+r.length,this.cursorState.cursorIndex=this.cursorState.cursorIndex+r.length,r}kill(e){this.cursorState.dead=!0,this.cursorState.killed=!0,this.cursorState.documents=[],null==this.cursorState.cursorId||this.cursorState.cursorId.isZero()||!1===this.cursorState.init?e&&e(null,null):this.server.killCursors(this.ns,this.cursorState,e)}rewind(){this.cursorState.init&&(this.cursorState.dead||this.kill(),this.cursorState.currentLimit=0,this.cursorState.init=!1,this.cursorState.dead=!1,this.cursorState.killed=!1,this.cursorState.notified=!1,this.cursorState.documents=[],this.cursorState.cursorId=null,this.cursorState.cursorIndex=0)}_read(){if(this.s&&this.s.state===g.CLOSED||this.isDead())return this.push(null);this._next((e,t)=>e?(this.listeners("error")&&this.listeners("error").length>0&&this.emit("error",e),this.isDead()||this.close(),this.emit("end"),this.emit("finish")):this.cursorState.streamOptions&&"function"==typeof this.cursorState.streamOptions.transform&&null!=t?this.push(this.cursorState.streamOptions.transform(t)):(this.push(t),void(null===t&&this.isDead()&&this.once("end",()=>{this.close(),this.emit("finish")}))))}_endSession(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=this.cursorState.session;return n&&(e.force||n.owner===this)?(this.cursorState.session=void 0,this.operation&&this.operation.clearSession(),n.endSession(t),!0):(t&&t(),!1)}_getMore(e){this.logger.isDebug()&&this.logger.debug(`schedule getMore call for query [${JSON.stringify(this.query)}]`);let t=this.cursorState.batchSize;this.cursorState.limit>0&&this.cursorState.currentLimit+t>this.cursorState.limit&&(t=this.cursorState.limit-this.cursorState.currentLimit);const n=this.cursorState;this.server.getMore(this.ns,n,t,this.options,(t,r,o)=>{(t||n.cursorId&&n.cursorId.isZero())&&this._endSession(),e(t,r,o)})}_initializeCursor(e){const t=this;if(l(t.topology)&&t.topology.shouldCheckForSessionSupport())return void t.topology.selectServer(c.primaryPreferred,t=>{t?e(t):this._initializeCursor(e)});function n(n,r){const o=t.cursorState;if((n||o.cursorId&&o.cursorId.isZero())&&t._endSession(),0===o.documents.length&&o.cursorId&&o.cursorId.isZero()&&!t.cmd.tailable&&!t.cmd.awaitData)return w(t,e);e(n,r)}const r=(e,r)=>{if(e)return n(e);const o=r.message;if(Array.isArray(o.documents)&&1===o.documents.length){const e=o.documents[0];if(o.queryFailure)return n(new s(e),null);if(!t.cmd.find||t.cmd.find&&!1===t.cmd.virtual){if(e.$err||e.errmsg)return n(new s(e),null);if(null!=e.cursor&&"string"!=typeof e.cursor){const r=e.cursor.id;return e.cursor.ns&&(t.ns=e.cursor.ns),t.cursorState.cursorId="number"==typeof r?y.fromNumber(r):r,t.cursorState.lastCursorId=t.cursorState.cursorId,t.cursorState.operationTime=e.operationTime,Array.isArray(e.cursor.firstBatch)&&(t.cursorState.documents=e.cursor.firstBatch),n(null,o)}}}const i=o.cursorId||0;t.cursorState.cursorId=i instanceof y?i:y.fromNumber(i),t.cursorState.documents=o.documents,t.cursorState.lastCursorId=o.cursorId,t.cursorState.transforms&&"function"==typeof t.cursorState.transforms.query&&(t.cursorState.documents=t.cursorState.transforms.query(o)),n(null,o)};if(t.operation)return t.logger.isDebug()&&t.logger.debug(`issue initial query [${JSON.stringify(t.cmd)}] with flags [${JSON.stringify(t.query)}]`),void u(t.topology,t.operation,(e,o)=>{if(e)n(e);else{if(t.server=t.operation.server,t.cursorState.init=!0,null!=t.cursorState.cursorId)return n();r(e,o)}});const o={};return t.cursorState.session&&(o.session=t.cursorState.session),t.operation?o.readPreference=t.operation.readPreference:t.options.readPreference&&(o.readPreference=t.options.readPreference),t.topology.selectServer(o,(o,i)=>{if(o){const n=t.disconnectHandler;return null!=n?n.addObjectAndMethod("cursor",t,"next",[e],e):e(o)}if(t.server=i,t.cursorState.init=!0,a(t.server,t.cmd))return e(new s(`server ${t.server.name} does not support collation`));if(null!=t.cursorState.cursorId)return n();if(t.logger.isDebug()&&t.logger.debug(`issue initial query [${JSON.stringify(t.cmd)}] with flags [${JSON.stringify(t.query)}]`),null!=t.cmd.find)return void i.query(t.ns,t.cmd,t.cursorState,t.options,r);const c=Object.assign({session:t.cursorState.session},t.options);i.command(t.ns,t.cmd,c,r)})}}function v(e,t){e.cursorState.dead=!0,w(e,t)}function w(e,t){O(e,()=>b(t,null,null))}function O(e,t){if(e.cursorState.notified=!0,e.cursorState.documents=[],e.cursorState.cursorIndex=0,!e.cursorState.session)return t();e._endSession(t)}p.ASYNC_ITERATOR&&(S.prototype[Symbol.asyncIterator]=n(85).asyncIterator),e.exports={CursorState:g,CoreCursor:S}},function(e,t,n){"use strict";var r=(0,n(9).retrieveBSON)().Long;const o=n(17).Buffer;var s=0,i=n(6).opcodes,a=function(e,t,n,r){if(null==t)throw new Error("ns must be specified for query");if(null==n)throw new Error("query must be specified for query");if(-1!==t.indexOf("\0"))throw new Error("namespace cannot contain a null character");this.bson=e,this.ns=t,this.query=n,this.numberToSkip=r.numberToSkip||0,this.numberToReturn=r.numberToReturn||0,this.returnFieldSelector=r.returnFieldSelector||null,this.requestId=a.getRequestId(),this.pre32Limit=r.pre32Limit,this.serializeFunctions="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,this.ignoreUndefined="boolean"==typeof r.ignoreUndefined&&r.ignoreUndefined,this.maxBsonSize=r.maxBsonSize||16777216,this.checkKeys="boolean"!=typeof r.checkKeys||r.checkKeys,this.batchSize=this.numberToReturn,this.tailable=!1,this.slaveOk="boolean"==typeof r.slaveOk&&r.slaveOk,this.oplogReplay=!1,this.noCursorTimeout=!1,this.awaitData=!1,this.exhaust=!1,this.partial=!1};a.prototype.incRequestId=function(){this.requestId=s++},a.nextRequestId=function(){return s+1},a.prototype.toBin=function(){var e=[],t=null,n=0;this.tailable&&(n|=2),this.slaveOk&&(n|=4),this.oplogReplay&&(n|=8),this.noCursorTimeout&&(n|=16),this.awaitData&&(n|=32),this.exhaust&&(n|=64),this.partial&&(n|=128),this.batchSize!==this.numberToReturn&&(this.numberToReturn=this.batchSize);var r=o.alloc(20+o.byteLength(this.ns)+1+4+4);e.push(r);var s=this.bson.serialize(this.query,{checkKeys:this.checkKeys,serializeFunctions:this.serializeFunctions,ignoreUndefined:this.ignoreUndefined});e.push(s),this.returnFieldSelector&&Object.keys(this.returnFieldSelector).length>0&&(t=this.bson.serialize(this.returnFieldSelector,{checkKeys:this.checkKeys,serializeFunctions:this.serializeFunctions,ignoreUndefined:this.ignoreUndefined}),e.push(t));var a=r.length+s.length+(t?t.length:0),c=4;return r[3]=a>>24&255,r[2]=a>>16&255,r[1]=a>>8&255,r[0]=255&a,r[c+3]=this.requestId>>24&255,r[c+2]=this.requestId>>16&255,r[c+1]=this.requestId>>8&255,r[c]=255&this.requestId,r[(c+=4)+3]=0,r[c+2]=0,r[c+1]=0,r[c]=0,r[(c+=4)+3]=i.OP_QUERY>>24&255,r[c+2]=i.OP_QUERY>>16&255,r[c+1]=i.OP_QUERY>>8&255,r[c]=255&i.OP_QUERY,r[(c+=4)+3]=n>>24&255,r[c+2]=n>>16&255,r[c+1]=n>>8&255,r[c]=255&n,c=(c+=4)+r.write(this.ns,c,"utf8")+1,r[c-1]=0,r[c+3]=this.numberToSkip>>24&255,r[c+2]=this.numberToSkip>>16&255,r[c+1]=this.numberToSkip>>8&255,r[c]=255&this.numberToSkip,r[(c+=4)+3]=this.numberToReturn>>24&255,r[c+2]=this.numberToReturn>>16&255,r[c+1]=this.numberToReturn>>8&255,r[c]=255&this.numberToReturn,c+=4,e},a.getRequestId=function(){return++s};var c=function(e,t,n,r){r=r||{},this.numberToReturn=r.numberToReturn||0,this.requestId=s++,this.bson=e,this.ns=t,this.cursorId=n};c.prototype.toBin=function(){var e=4+o.byteLength(this.ns)+1+4+8+16,t=0,n=o.alloc(e);return n[t+3]=e>>24&255,n[t+2]=e>>16&255,n[t+1]=e>>8&255,n[t]=255&e,n[(t+=4)+3]=this.requestId>>24&255,n[t+2]=this.requestId>>16&255,n[t+1]=this.requestId>>8&255,n[t]=255&this.requestId,n[(t+=4)+3]=0,n[t+2]=0,n[t+1]=0,n[t]=0,n[(t+=4)+3]=i.OP_GETMORE>>24&255,n[t+2]=i.OP_GETMORE>>16&255,n[t+1]=i.OP_GETMORE>>8&255,n[t]=255&i.OP_GETMORE,n[(t+=4)+3]=0,n[t+2]=0,n[t+1]=0,n[t]=0,t=(t+=4)+n.write(this.ns,t,"utf8")+1,n[t-1]=0,n[t+3]=this.numberToReturn>>24&255,n[t+2]=this.numberToReturn>>16&255,n[t+1]=this.numberToReturn>>8&255,n[t]=255&this.numberToReturn,n[(t+=4)+3]=this.cursorId.getLowBits()>>24&255,n[t+2]=this.cursorId.getLowBits()>>16&255,n[t+1]=this.cursorId.getLowBits()>>8&255,n[t]=255&this.cursorId.getLowBits(),n[(t+=4)+3]=this.cursorId.getHighBits()>>24&255,n[t+2]=this.cursorId.getHighBits()>>16&255,n[t+1]=this.cursorId.getHighBits()>>8&255,n[t]=255&this.cursorId.getHighBits(),t+=4,n};var l=function(e,t,n){this.ns=t,this.requestId=s++,this.cursorIds=n};l.prototype.toBin=function(){var e=24+8*this.cursorIds.length,t=0,n=o.alloc(e);n[t+3]=e>>24&255,n[t+2]=e>>16&255,n[t+1]=e>>8&255,n[t]=255&e,n[(t+=4)+3]=this.requestId>>24&255,n[t+2]=this.requestId>>16&255,n[t+1]=this.requestId>>8&255,n[t]=255&this.requestId,n[(t+=4)+3]=0,n[t+2]=0,n[t+1]=0,n[t]=0,n[(t+=4)+3]=i.OP_KILL_CURSORS>>24&255,n[t+2]=i.OP_KILL_CURSORS>>16&255,n[t+1]=i.OP_KILL_CURSORS>>8&255,n[t]=255&i.OP_KILL_CURSORS,n[(t+=4)+3]=0,n[t+2]=0,n[t+1]=0,n[t]=0,n[(t+=4)+3]=this.cursorIds.length>>24&255,n[t+2]=this.cursorIds.length>>16&255,n[t+1]=this.cursorIds.length>>8&255,n[t]=255&this.cursorIds.length,t+=4;for(var r=0;r>24&255,n[t+2]=this.cursorIds[r].getLowBits()>>16&255,n[t+1]=this.cursorIds[r].getLowBits()>>8&255,n[t]=255&this.cursorIds[r].getLowBits(),n[(t+=4)+3]=this.cursorIds[r].getHighBits()>>24&255,n[t+2]=this.cursorIds[r].getHighBits()>>16&255,n[t+1]=this.cursorIds[r].getHighBits()>>8&255,n[t]=255&this.cursorIds[r].getHighBits(),t+=4;return n};var u=function(e,t,n,o,s){s=s||{promoteLongs:!0,promoteValues:!0,promoteBuffers:!1},this.parsed=!1,this.raw=t,this.data=o,this.bson=e,this.opts=s,this.length=n.length,this.requestId=n.requestId,this.responseTo=n.responseTo,this.opCode=n.opCode,this.fromCompressed=n.fromCompressed,this.responseFlags=o.readInt32LE(0),this.cursorId=new r(o.readInt32LE(4),o.readInt32LE(8)),this.startingFrom=o.readInt32LE(12),this.numberReturned=o.readInt32LE(16),this.documents=new Array(this.numberReturned),this.cursorNotFound=0!=(1&this.responseFlags),this.queryFailure=0!=(2&this.responseFlags),this.shardConfigStale=0!=(4&this.responseFlags),this.awaitCapable=0!=(8&this.responseFlags),this.promoteLongs="boolean"!=typeof s.promoteLongs||s.promoteLongs,this.promoteValues="boolean"!=typeof s.promoteValues||s.promoteValues,this.promoteBuffers="boolean"==typeof s.promoteBuffers&&s.promoteBuffers};u.prototype.isParsed=function(){return this.parsed},u.prototype.parse=function(e){if(!this.parsed){var t,n,r=(e=e||{}).raw||!1,o=e.documentsReturnedIn||null;n={promoteLongs:"boolean"==typeof e.promoteLongs?e.promoteLongs:this.opts.promoteLongs,promoteValues:"boolean"==typeof e.promoteValues?e.promoteValues:this.opts.promoteValues,promoteBuffers:"boolean"==typeof e.promoteBuffers?e.promoteBuffers:this.opts.promoteBuffers},this.index=20;for(var s=0;s */ -var r=n(53),o=r.Buffer;function s(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=i),i.prototype=Object.create(o.prototype),s(o,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).OperationBase,s=n(0).applyWriteConcern,i=n(0).debugOptions,a=n(0).handleCallback,c=n(2).MongoError,l=n(2).ReadPreference,u=n(0).MongoDBNamespace,h=["authSource","w","wtimeout","j","native_parser","forceServerObjectId","serializeFunctions","raw","promoteLongs","promoteValues","promoteBuffers","bufferMaxEntries","numberOfRetries","retryMiliSeconds","readPreference","pkFactory","parentDb","promiseLibrary","noListener"];e.exports=class extends o{constructor(e,t,n,o){super(t),this.hasAspect(r.WRITE_OPERATION)?(s(this.options,null!=n?{db:e,coll:n}:{db:e},this.options),this.options.readPreference=l.primary):this.options.readPreference=null!=n?l.resolve(n,t):l.resolve(e,t),this.db=e,null!=o&&(this.command=o),null!=n&&(this.collection=n)}_buildCommand(){if(null!=this.command)return this.command}execute(e){const t=this.db,n=Object.assign({},this.options);if(t.serverConfig&&t.serverConfig.isDestroyed())return e(new c("topology was destroyed"));let o;try{o=this._buildCommand()}catch(t){return e(t)}const s=n.dbName||n.authdb||t.databaseName;this.hasAspect(r.WRITE_OPERATION)&&(!n.writeConcern||n.session&&n.session.inTransaction()||(o.writeConcern=n.writeConcern)),t.s.logger.isDebug()&&t.s.logger.debug(`executing command ${JSON.stringify(o)} against ${s}.$cmd with options [${JSON.stringify(i(h,n))}]`);const l=null!=this.namespace?this.namespace:new u(s,"$cmd");t.s.topology.command(l,o,n,(t,r)=>t?a(e,t):n.full?a(e,null,r):void a(e,null,r.result))}}},function(e,t){e.exports=require("stream")},function(e,t,n){"use strict";const r=n(19).Transform,o=n(19).PassThrough,s=n(5).deprecate,i=n(0).handleCallback,a=n(2).ReadPreference,c=n(2).MongoError,l=n(15).CoreCursor,u=n(15).CursorState,h=n(2).BSON.Map,p=n(0).maybePromise,f=n(37),d=n(0).formattedOrderClause,m=n(56).Explain,y=n(1).Aspect,g=n(167).each,b=n(168),S=["tailable","oplogReplay","noCursorTimeout","awaitData","exhaust","partial"],v=["numberOfRetries","tailableRetryInterval"];class w extends l{constructor(e,t,n,r){super(e,t,n,r),this.operation&&(r=this.operation.options);const o=r.numberOfRetries||5,s=r.tailableRetryInterval||500,i=o,a=r.promiseLibrary||Promise;this.s={numberOfRetries:o,tailableRetryInterval:s,currentNumberOfRetries:i,state:u.INIT,promiseLibrary:a,explicitlyIgnoreSession:!!r.explicitlyIgnoreSession},!r.explicitlyIgnoreSession&&r.session&&(this.cursorState.session=r.session),!0===this.options.noCursorTimeout&&this.addCursorFlag("noCursorTimeout",!0);let c=1e3;this.cmd.cursor&&this.cmd.cursor.batchSize?c=this.cmd.cursor.batchSize:r.cursor&&r.cursor.batchSize?c=r.cursor.batchSize:"number"==typeof r.batchSize&&(c=r.batchSize),this.setCursorBatchSize(c)}get readPreference(){return this.operation?this.operation.readPreference:this.options.readPreference}get sortValue(){return this.cmd.sort}_initializeCursor(e){this.operation&&null!=this.operation.session?this.cursorState.session=this.operation.session:this.s.explicitlyIgnoreSession||this.cursorState.session||!this.topology.hasSessionSupport()||(this.cursorState.session=this.topology.startSession({owner:this}),this.operation&&(this.operation.session=this.cursorState.session)),super._initializeCursor(e)}hasNext(e){if(this.s.state===u.CLOSED||this.isDead&&this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return p(this,e,e=>{const t=this;if(t.isNotified())return e(null,!1);t._next((n,r)=>n?e(n):null==r||t.s.state===w.CLOSED||t.isDead()?e(null,!1):(t.s.state=u.OPEN,t.cursorState.cursorIndex--,t.cursorState.limit>0&&t.cursorState.currentLimit--,void e(null,!0)))})}next(e){return p(this,e,e=>{const t=this;if(t.s.state===u.CLOSED||t.isDead&&t.isDead())e(c.create({message:"Cursor is closed",driver:!0}));else{if(t.s.state===u.INIT&&t.cmd.sort)try{t.cmd.sort=d(t.cmd.sort)}catch(t){return e(t)}t._next((n,r)=>{if(n)return e(n);t.s.state=u.OPEN,e(null,r)})}})}filter(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.query=e,this}maxScan(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.maxScan=e,this}hint(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.hint=e,this}min(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.min=e,this}max(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.max=e,this}returnKey(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.returnKey=e,this}showRecordId(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.showDiskLoc=e,this}snapshot(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.snapshot=e,this}setCursorOption(e,t){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});if(-1===v.indexOf(e))throw c.create({message:`option ${e} is not a supported option ${v}`,driver:!0});return this.s[e]=t,"numberOfRetries"===e&&(this.s.currentNumberOfRetries=t),this}addCursorFlag(e,t){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});if(-1===S.indexOf(e))throw c.create({message:`flag ${e} is not a supported flag ${S}`,driver:!0});if("boolean"!=typeof t)throw c.create({message:`flag ${e} must be a boolean value`,driver:!0});return this.cmd[e]=t,this}addQueryModifier(e,t){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});if("$"!==e[0])throw c.create({message:e+" is not a valid query modifier",driver:!0});const n=e.substr(1);return this.cmd[n]=t,"orderby"===n&&(this.cmd.sort=this.cmd[n]),this}comment(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.comment=e,this}maxAwaitTimeMS(e){if("number"!=typeof e)throw c.create({message:"maxAwaitTimeMS must be a number",driver:!0});if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.maxAwaitTimeMS=e,this}maxTimeMS(e){if("number"!=typeof e)throw c.create({message:"maxTimeMS must be a number",driver:!0});if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.maxTimeMS=e,this}project(e){if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});return this.cmd.fields=e,this}sort(e,t){if(this.options.tailable)throw c.create({message:"Tailable cursor doesn't support sorting",driver:!0});if(this.s.state===u.CLOSED||this.s.state===u.OPEN||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});let n=e;return Array.isArray(n)&&Array.isArray(n[0])&&(n=new h(n.map(e=>{const t=[e[0],null];if("asc"===e[1])t[1]=1;else if("desc"===e[1])t[1]=-1;else{if(1!==e[1]&&-1!==e[1]&&!e[1].$meta)throw new c("Illegal sort clause, must be of the form [['field1', '(ascending|descending)'], ['field2', '(ascending|descending)']]");t[1]=e[1]}return t}))),null!=t&&(n=[[e,t]]),this.cmd.sort=n,this}batchSize(e){if(this.options.tailable)throw c.create({message:"Tailable cursor doesn't support batchSize",driver:!0});if(this.s.state===u.CLOSED||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});if("number"!=typeof e)throw c.create({message:"batchSize requires an integer",driver:!0});return this.cmd.batchSize=e,this.setCursorBatchSize(e),this}collation(e){return this.cmd.collation=e,this}limit(e){if(this.options.tailable)throw c.create({message:"Tailable cursor doesn't support limit",driver:!0});if(this.s.state===u.OPEN||this.s.state===u.CLOSED||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});if("number"!=typeof e)throw c.create({message:"limit requires an integer",driver:!0});return this.cmd.limit=e,this.setCursorLimit(e),this}skip(e){if(this.options.tailable)throw c.create({message:"Tailable cursor doesn't support skip",driver:!0});if(this.s.state===u.OPEN||this.s.state===u.CLOSED||this.isDead())throw c.create({message:"Cursor is closed",driver:!0});if("number"!=typeof e)throw c.create({message:"skip requires an integer",driver:!0});return this.cmd.skip=e,this.setCursorSkip(e),this}each(e){this.rewind(),this.s.state=u.INIT,g(this,e)}forEach(e,t){if(this.rewind(),this.s.state=u.INIT,"function"!=typeof t)return new this.s.promiseLibrary((t,n)=>{g(this,(r,o)=>r?(n(r),!1):null==o?(t(null),!1):(e(o),!0))});g(this,(n,r)=>{if(n)return t(n),!1;if(null!=r)return e(r),!0;if(null==r&&t){const e=t;return t=null,e(null),!1}})}setReadPreference(e){if(this.s.state!==u.INIT)throw c.create({message:"cannot change cursor readPreference after cursor has been accessed",driver:!0});if(e instanceof a)this.options.readPreference=e;else{if("string"!=typeof e)throw new TypeError("Invalid read preference: "+e);this.options.readPreference=new a(e)}return this}toArray(e){if(this.options.tailable)throw c.create({message:"Tailable cursor cannot be converted to array",driver:!0});return p(this,e,e=>{const t=this,n=[];t.rewind(),t.s.state=u.INIT;const r=()=>{t._next((o,s)=>{if(o)return i(e,o);if(null==s)return t.close({skipKillCursors:!0},()=>i(e,null,n));if(n.push(s),t.bufferedCount()>0){let e=t.readBufferedDocuments(t.bufferedCount());Array.prototype.push.apply(n,e)}r()})};r()})}count(e,t,n){if(null==this.cmd.query)throw c.create({message:"count can only be used with find command",driver:!0});"function"==typeof t&&(n=t,t={}),t=t||{},"function"==typeof e&&(n=e,e=!0),this.cursorState.session&&(t=Object.assign({},t,{session:this.cursorState.session}));const r=new b(this,e,t);return f(this.topology,r,n)}close(e,t){return"function"==typeof e&&(t=e,e={}),e=Object.assign({},{skipKillCursors:!1},e),p(this,t,t=>{this.s.state=u.CLOSED,e.skipKillCursors||this.kill(),this._endSession(()=>{this.emit("close"),t(null,this)})})}map(e){if(this.cursorState.transforms&&this.cursorState.transforms.doc){const t=this.cursorState.transforms.doc;this.cursorState.transforms.doc=n=>e(t(n))}else this.cursorState.transforms={doc:e};return this}isClosed(){return this.isDead()}destroy(e){e&&this.emit("error",e),this.pause(),this.close()}stream(e){return this.cursorState.streamOptions=e||{},this}transformStream(e){const t=e||{};if("function"==typeof t.transform){const e=new r({objectMode:!0,transform:function(e,n,r){this.push(t.transform(e)),r()}});return this.pipe(e)}return this.pipe(new o({objectMode:!0}))}explain(e,t){if("function"==typeof e&&(t=e,e=!0),void 0===e&&(e=!0),!this.operation||!this.operation.hasAspect(y.EXPLAINABLE))throw new c("This command cannot be explained");return this.operation.explain=new m(e),p(this,t,e=>{l.prototype._next.apply(this,[e])})}getLogger(){return this.logger}}w.prototype.maxTimeMs=w.prototype.maxTimeMS,s(w.prototype.each,"Cursor.each is deprecated. Use Cursor.forEach instead."),s(w.prototype.maxScan,"Cursor.maxScan is deprecated, and will be removed in a later version"),s(w.prototype.snapshot,"Cursor Snapshot is deprecated, and will be removed in a later version"),e.exports=w},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).OperationBase,s=n(2).ReadPreference,i=n(32),a=n(22),c=n(4).maxWireVersion,l=n(0).decorateWithExplain,u=n(27).commandSupportsReadConcern,h=n(3).MongoError;e.exports=class extends o{constructor(e,t,n){super(t),this.ns=e.s.namespace.withCollection("$cmd");const o=this.hasAspect(r.NO_INHERIT_OPTIONS)?void 0:e;this.readPreference=this.hasAspect(r.WRITE_OPERATION)?s.primary:s.resolve(o,this.options),this.readConcern=function(e,t){return i.fromOptions(t)||e&&e.readConcern}(o,this.options),this.writeConcern=function(e,t){return a.fromOptions(t)||e&&e.writeConcern}(o,this.options),n&&"boolean"==typeof n.fullResponse&&(this.fullResponse=!0),this.options.readPreference=this.readPreference,e.s.logger?this.logger=e.s.logger:e.s.db&&e.s.db.logger&&(this.logger=e.s.db.logger)}executeCommand(e,t,n){this.server=e;const o=this.options,s=c(e),i=this.session&&this.session.inTransaction();this.readConcern&&u(t)&&!i&&Object.assign(t,{readConcern:this.readConcern}),o.collation&&s<5?n(new h(`Server ${e.name}, which reports wire version ${s}, does not support collation`)):(s>=5&&(this.writeConcern&&this.hasAspect(r.WRITE_OPERATION)&&Object.assign(t,{writeConcern:this.writeConcern}),o.collation&&"object"==typeof o.collation&&Object.assign(t,{collation:o.collation})),"number"==typeof o.maxTimeMS&&(t.maxTimeMS=o.maxTimeMS),"string"==typeof o.comment&&(t.comment=o.comment),this.hasAspect(r.EXPLAINABLE)&&this.explain&&(s<6&&t.aggregate?t.explain=!0:t=l(t,this.explain)),this.logger&&this.logger.isDebug()&&this.logger.debug(`executing command ${JSON.stringify(t)} against ${this.ns}`),e.command(this.ns.toString(),t,this.options,(e,t)=>{e?n(e,null):this.fullResponse?n(null,t):n(null,t.result)}))}}},function(e,t,n){"use strict";const r=new Set(["w","wtimeout","j","journal","fsync"]);let o;class s{constructor(e,t,n,r){null!=e&&(this.w=e),null!=t&&(this.wtimeout=t),null!=n&&(this.j=n),null!=r&&(this.fsync=r)}static fromOptions(e){if(null!=e&&(null!=e.writeConcern||null!=e.w||null!=e.wtimeout||null!=e.j||null!=e.journal||null!=e.fsync)){if(e.writeConcern){if("string"==typeof e.writeConcern)return new s(e.writeConcern);if(!Object.keys(e.writeConcern).some(e=>r.has(e)))return;return new s(e.writeConcern.w,e.writeConcern.wtimeout,e.writeConcern.j||e.writeConcern.journal,e.writeConcern.fsync)}return o||(o=n(0)),o.emitWarningOnce("Top-level use of w, wtimeout, j, and fsync is deprecated. Use writeConcern instead."),new s(e.w,e.wtimeout,e.j||e.journal,e.fsync)}}}e.exports=s},function(e,t,n){"use strict";const r=n(9).retrieveSnappy(),o=n(130),s={snappy:1,zlib:2},i=new Set(["ismaster","saslStart","saslContinue","getnonce","authenticate","createUser","updateUser","copydbSaslStart","copydbgetnonce","copydb"]);e.exports={compressorIDs:s,uncompressibleCommands:i,compress:function(e,t,n){switch(e.options.agreedCompressor){case"snappy":r.compress(t,n);break;case"zlib":var s={};e.options.zlibCompressionLevel&&(s.level=e.options.zlibCompressionLevel),o.deflate(t,s,n);break;default:throw new Error('Attempt to compress message using unknown compressor "'+e.options.agreedCompressor+'".')}},decompress:function(e,t,n){if(e<0||e>s.length)throw new Error("Server sent message compressed using an unsupported compressor. (Received compressor ID "+e+")");switch(e){case s.snappy:r.uncompress(t,n);break;case s.zlib:o.inflate(t,n);break;default:n(null,t)}}}},function(e,t,n){"use strict";function r(e,t){return new Buffer(e,t)}e.exports={normalizedFunctionString:function(e){return e.toString().replace(/function *\(/,"function (")},allocBuffer:"function"==typeof Buffer.alloc?function(){return Buffer.alloc.apply(Buffer,arguments)}:r,toBuffer:"function"==typeof Buffer.from?function(){return Buffer.from.apply(Buffer,arguments)}:r}},function(e,t){e.exports=require("crypto")},function(e,t,n){"use strict";e.exports={AuthContext:class{constructor(e,t,n){this.connection=e,this.credentials=t,this.options=n}},AuthProvider:class{constructor(e){this.bson=e}prepare(e,t,n){n(void 0,e)}auth(e,t){t(new TypeError("`auth` method must be overridden by subclass"))}}}},function(e,t,n){"use strict";const r=n(9).retrieveBSON,o=n(8),s=r(),i=s.Binary,a=n(4).uuidV4,c=n(3).MongoError,l=n(3).isRetryableError,u=n(3).MongoNetworkError,h=n(3).MongoWriteConcernError,p=n(35).Transaction,f=n(35).TxnState,d=n(4).isPromiseLike,m=n(10),y=n(0).maybePromise,g=n(35).isTransactionCommand,b=n(7).resolveClusterTime,S=n(6).isSharded,v=n(4).maxWireVersion,w=n(0).now,O=n(0).calculateDurationInMs;function _(e,t){if(null==e.serverSession){const e=new c("Cannot use a session that has ended");if("function"==typeof t)return t(e,null),!1;throw e}return!0}const T=Symbol("serverSession");class E extends o{constructor(e,t,n,r){if(super(),null==e)throw new Error("ClientSession requires a topology");if(null==t||!(t instanceof B))throw new Error("ClientSession requires a ServerSessionPool");n=n||{},r=r||{},this.topology=e,this.sessionPool=t,this.hasEnded=!1,this.clientOptions=r,this[T]=void 0,this.supports={causalConsistency:void 0===n.causalConsistency||n.causalConsistency},this.clusterTime=n.initialClusterTime,this.operationTime=null,this.explicit=!!n.explicit,this.owner=n.owner,this.defaultTransactionOptions=Object.assign({},n.defaultTransactionOptions),this.transaction=new p}get id(){return this.serverSession.id}get serverSession(){return null==this[T]&&(this[T]=this.sessionPool.acquire()),this[T]}endSession(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=this;return y(this,t,e=>{if(n.hasEnded)return e();function t(){n.sessionPool.release(n.serverSession),n[T]=void 0,n.hasEnded=!0,n.emit("ended",n),e()}n.serverSession&&n.inTransaction()?n.abortTransaction(n=>{if(n)return e(n);t()}):t()})}advanceOperationTime(e){null!=this.operationTime?e.greaterThan(this.operationTime)&&(this.operationTime=e):this.operationTime=e}equals(e){return e instanceof E&&this.id.id.buffer.equals(e.id.id.buffer)}incrementTransactionNumber(){this.serverSession.txnNumber++}inTransaction(){return this.transaction.isActive}startTransaction(e){if(_(this),this.inTransaction())throw new c("Transaction already in progress");const t=v(this.topology);if(S(this.topology)&&null!=t&&t<8)throw new c("Transactions are not supported on sharded clusters in MongoDB < 4.2.");this.incrementTransactionNumber(),this.transaction=new p(Object.assign({},this.clientOptions,e||this.defaultTransactionOptions)),this.transaction.transition(f.STARTING_TRANSACTION)}commitTransaction(e){return y(this,e,e=>k(this,"commitTransaction",e))}abortTransaction(e){return y(this,e,e=>k(this,"abortTransaction",e))}toBSON(){throw new Error("ClientSession cannot be serialized to BSON.")}withTransaction(e,t){return A(this,w(),e,t)}}const C=new Set(["CannotSatisfyWriteConcern","UnknownReplWriteConcern","UnsatisfiableWriteConcern"]);function x(e,t){return O(e){if(!function(e){return I.has(e.transaction.state)}(e))return function e(t,n,r,o){return t.commitTransaction().catch(s=>{if(s instanceof c&&x(n,12e4)&&!N(s)){if(s.hasErrorLabel("UnknownTransactionCommitResult"))return e(t,n,r,o);if(s.hasErrorLabel("TransientTransactionError"))return A(t,n,r,o)}throw s})}(e,t,n,r)}).catch(o=>{function s(o){if(o instanceof c&&o.hasErrorLabel("TransientTransactionError")&&x(t,12e4))return A(e,t,n,r);throw N(o)&&o.addErrorLabel("UnknownTransactionCommitResult"),o}return e.transaction.isActive?e.abortTransaction().then(()=>s(o)):s(o)})}function k(e,t,n){if(!_(e,n))return;let r=e.transaction.state;if(r===f.NO_TRANSACTION)return void n(new c("No transaction started"));if("commitTransaction"===t){if(r===f.STARTING_TRANSACTION||r===f.TRANSACTION_COMMITTED_EMPTY)return e.transaction.transition(f.TRANSACTION_COMMITTED_EMPTY),void n(null,null);if(r===f.TRANSACTION_ABORTED)return void n(new c("Cannot call commitTransaction after calling abortTransaction"))}else{if(r===f.STARTING_TRANSACTION)return e.transaction.transition(f.TRANSACTION_ABORTED),void n(null,null);if(r===f.TRANSACTION_ABORTED)return void n(new c("Cannot call abortTransaction twice"));if(r===f.TRANSACTION_COMMITTED||r===f.TRANSACTION_COMMITTED_EMPTY)return void n(new c("Cannot call abortTransaction after calling commitTransaction"))}const o={[t]:1};let s;function i(r,o){var s;"commitTransaction"===t?(e.transaction.transition(f.TRANSACTION_COMMITTED),r&&(r instanceof u||r instanceof h||l(r)||N(r))&&(N(s=r)||!C.has(s.codeName)&&100!==s.code&&79!==s.code)&&(r.addErrorLabel("UnknownTransactionCommitResult"),e.transaction.unpinServer())):e.transaction.transition(f.TRANSACTION_ABORTED),n(r,o)}function a(e){return"commitTransaction"===t?e:null}e.transaction.options.writeConcern?s=Object.assign({},e.transaction.options.writeConcern):e.clientOptions&&e.clientOptions.w&&(s={w:e.clientOptions.w}),r===f.TRANSACTION_COMMITTED&&(s=Object.assign({wtimeout:1e4},s,{w:"majority"})),s&&Object.assign(o,{writeConcern:s}),"commitTransaction"===t&&e.transaction.options.maxTimeMS&&Object.assign(o,{maxTimeMS:e.transaction.options.maxTimeMS}),e.transaction.recoveryToken&&function(e){return!!e.topology.s.options.useRecoveryToken}(e)&&(o.recoveryToken=e.transaction.recoveryToken),e.topology.command("admin.$cmd",o,{session:e},(t,n)=>{if(t&&l(t))return o.commitTransaction&&(e.transaction.unpinServer(),o.writeConcern=Object.assign({wtimeout:1e4},o.writeConcern,{w:"majority"})),e.topology.command("admin.$cmd",o,{session:e},(e,t)=>i(a(e),t));i(a(t),n)})}class M{constructor(){this.id={id:new i(a(),i.SUBTYPE_UUID)},this.lastUse=w(),this.txnNumber=0,this.isDirty=!1}hasTimedOut(e){return Math.round(O(this.lastUse)%864e5%36e5/6e4)>e-1}}class B{constructor(e){if(null==e)throw new Error("ServerSessionPool requires a topology");this.topology=e,this.sessions=[]}endAllPooledSessions(e){this.sessions.length?this.topology.endSessions(this.sessions.map(e=>e.id),()=>{this.sessions=[],"function"==typeof e&&e()}):"function"==typeof e&&e()}acquire(){const e=this.topology.logicalSessionTimeoutMinutes;for(;this.sessions.length;){const t=this.sessions.shift();if(!t.hasTimedOut(e))return t}return new M}release(e){const t=this.topology.logicalSessionTimeoutMinutes;for(;this.sessions.length;){if(!this.sessions[this.sessions.length-1].hasTimedOut(t))break;this.sessions.pop()}if(!e.hasTimedOut(t)){if(e.isDirty)return;this.sessions.unshift(e)}}}function R(e,t){return!!(e.aggregate||e.count||e.distinct||e.find||e.parallelCollectionScan||e.geoNear||e.geoSearch)||!(!(e.mapReduce&&t&&t.out)||1!==t.out.inline&&"inline"!==t.out)}e.exports={ClientSession:E,ServerSession:M,ServerSessionPool:B,TxnState:f,applySession:function(e,t,n){if(e.hasEnded)return new c("Cannot use a session that has ended");if(n&&n.writeConcern&&0===n.writeConcern.w)return;const r=e.serverSession;r.lastUse=w(),t.lsid=r.id;const o=e.inTransaction()||g(t),i=n.willRetryWrite,a=R(t,n);if(r.txnNumber&&(i||o)&&(t.txnNumber=s.Long.fromNumber(r.txnNumber)),!o)return e.transaction.state!==f.NO_TRANSACTION&&e.transaction.transition(f.NO_TRANSACTION),void(e.supports.causalConsistency&&e.operationTime&&a&&(t.readConcern=t.readConcern||{},Object.assign(t.readConcern,{afterClusterTime:e.operationTime})));if(n.readPreference&&!n.readPreference.equals(m.primary))return new c("Read preference in a transaction must be primary, not: "+n.readPreference.mode);if(t.autocommit=!1,e.transaction.state===f.STARTING_TRANSACTION){e.transaction.transition(f.TRANSACTION_IN_PROGRESS),t.startTransaction=!0;const n=e.transaction.options.readConcern||e.clientOptions.readConcern;n&&(t.readConcern=n),e.supports.causalConsistency&&e.operationTime&&(t.readConcern=t.readConcern||{},Object.assign(t.readConcern,{afterClusterTime:e.operationTime}))}},updateSessionFromResponse:function(e,t){t.$clusterTime&&b(e,t.$clusterTime),t.operationTime&&e&&e.supports.causalConsistency&&e.advanceOperationTime(t.operationTime),t.recoveryToken&&e&&e.inTransaction()&&(e.transaction._recoveryToken=t.recoveryToken)},commandSupportsReadConcern:R}},function(e,t,n){"use strict";const r=n(8),o=n(2).MongoError,s=n(5).format,i=n(2).ReadPreference,a=n(2).Sessions.ClientSession;var c=function(e,t){var n=this;t=t||{force:!1,bufferMaxEntries:-1},this.s={storedOps:[],storeOptions:t,topology:e},Object.defineProperty(this,"length",{enumerable:!0,get:function(){return n.s.storedOps.length}})};c.prototype.add=function(e,t,n,r,i){if(this.s.storeOptions.force)return i(o.create({message:"db closed by application",driver:!0}));if(0===this.s.storeOptions.bufferMaxEntries)return i(o.create({message:s("no connection available for operation and number of stored operation > %s",this.s.storeOptions.bufferMaxEntries),driver:!0}));if(this.s.storeOptions.bufferMaxEntries>0&&this.s.storedOps.length>this.s.storeOptions.bufferMaxEntries)for(;this.s.storedOps.length>0;){this.s.storedOps.shift().c(o.create({message:s("no connection available for operation and number of stored operation > %s",this.s.storeOptions.bufferMaxEntries),driver:!0}))}else this.s.storedOps.push({t:e,n:t,o:n,op:r,c:i})},c.prototype.addObjectAndMethod=function(e,t,n,r,i){if(this.s.storeOptions.force)return i(o.create({message:"db closed by application",driver:!0}));if(0===this.s.storeOptions.bufferMaxEntries)return i(o.create({message:s("no connection available for operation and number of stored operation > %s",this.s.storeOptions.bufferMaxEntries),driver:!0}));if(this.s.storeOptions.bufferMaxEntries>0&&this.s.storedOps.length>this.s.storeOptions.bufferMaxEntries)for(;this.s.storedOps.length>0;){this.s.storedOps.shift().c(o.create({message:s("no connection available for operation and number of stored operation > %s",this.s.storeOptions.bufferMaxEntries),driver:!0}))}else this.s.storedOps.push({t:e,m:n,o:t,p:r,c:i})},c.prototype.flush=function(e){for(;this.s.storedOps.length>0;)this.s.storedOps.shift().c(e||o.create({message:s("no connection available for operation"),driver:!0}))};var l=["primary","primaryPreferred","nearest","secondaryPreferred"],u=["secondary","secondaryPreferred"];c.prototype.execute=function(e){e=e||{};var t=this.s.storedOps;this.s.storedOps=[];for(var n="boolean"!=typeof e.executePrimary||e.executePrimary,r="boolean"!=typeof e.executeSecondary||e.executeSecondary;t.length>0;){var o=t.shift();"cursor"===o.t?(n&&r||n&&o.o.options&&o.o.options.readPreference&&-1!==l.indexOf(o.o.options.readPreference.mode)||!n&&r&&o.o.options&&o.o.options.readPreference&&-1!==u.indexOf(o.o.options.readPreference.mode))&&o.o[o.m].apply(o.o,o.p):"auth"===o.t?this.s.topology[o.t].apply(this.s.topology,o.o):(n&&r||n&&o.op&&o.op.readPreference&&-1!==l.indexOf(o.op.readPreference.mode)||!n&&r&&o.op&&o.op.readPreference&&-1!==u.indexOf(o.op.readPreference.mode))&&this.s.topology[o.t](o.n,o.o,o.op,o.c)}},c.prototype.all=function(){return this.s.storedOps};var h=function(e){var t=function(e,t,n){Object.defineProperty(e,t,{enumerable:!0,get:function(){return n}})},n=!1,r=!1,o=!1,s=!1,i=!1,a=!1,c=e.maxWriteBatchSize||1e3,l=!1,u=!1;e.minWireVersion>=0&&(o=!0),e.maxWireVersion>=1&&(n=!0,s=!0),e.maxWireVersion>=2&&(r=!0),e.maxWireVersion>=3&&(i=!0,a=!0),e.maxWireVersion>=5&&(l=!0,u=!0),null==e.minWireVersion&&(e.minWireVersion=0),null==e.maxWireVersion&&(e.maxWireVersion=0),t(this,"hasAggregationCursor",n),t(this,"hasWriteCommands",r),t(this,"hasTextSearch",o),t(this,"hasAuthCommands",s),t(this,"hasListCollectionsCommand",i),t(this,"hasListIndexesCommand",a),t(this,"minWireVersion",e.minWireVersion),t(this,"maxWireVersion",e.maxWireVersion),t(this,"maxNumberOfDocsInBatch",c),t(this,"commandsTakeWriteConcern",l),t(this,"commandsTakeCollation",u)};class p extends r{constructor(){super(),this.setMaxListeners(1/0)}hasSessionSupport(){return null!=this.logicalSessionTimeoutMinutes}startSession(e,t){const n=new a(this,this.s.sessionPool,e,t);return n.once("ended",()=>{this.s.sessions.delete(n)}),this.s.sessions.add(n),n}endSessions(e,t){return this.s.coreTopology.endSessions(e,t)}get clientMetadata(){return this.s.coreTopology.s.options.metadata}capabilities(){return this.s.sCapabilities?this.s.sCapabilities:null==this.s.coreTopology.lastIsMaster()?null:(this.s.sCapabilities=new h(this.s.coreTopology.lastIsMaster()),this.s.sCapabilities)}command(e,t,n,r){this.s.coreTopology.command(e.toString(),t,i.translate(n),r)}insert(e,t,n,r){this.s.coreTopology.insert(e.toString(),t,n,r)}update(e,t,n,r){this.s.coreTopology.update(e.toString(),t,n,r)}remove(e,t,n,r){this.s.coreTopology.remove(e.toString(),t,n,r)}isConnected(e){return e=e||{},e=i.translate(e),this.s.coreTopology.isConnected(e)}isDestroyed(){return this.s.coreTopology.isDestroyed()}cursor(e,t,n){return n=n||{},(n=i.translate(n)).disconnectHandler=this.s.store,n.topology=this,this.s.coreTopology.cursor(e,t,n)}lastIsMaster(){return this.s.coreTopology.lastIsMaster()}selectServer(e,t,n){return this.s.coreTopology.selectServer(e,t,n)}unref(){return this.s.coreTopology.unref()}connections(){return this.s.coreTopology.connections()}close(e,t){this.s.sessions.forEach(e=>e.endSession()),this.s.sessionPool&&this.s.sessionPool.endAllPooledSessions(),!0===e&&(this.s.storeOptions.force=e,this.s.store.flush()),this.s.coreTopology.destroy({force:"boolean"==typeof e&&e},t)}}Object.defineProperty(p.prototype,"bson",{enumerable:!0,get:function(){return this.s.coreTopology.s.bson}}),Object.defineProperty(p.prototype,"parserType",{enumerable:!0,get:function(){return this.s.coreTopology.parserType}}),Object.defineProperty(p.prototype,"logicalSessionTimeoutMinutes",{enumerable:!0,get:function(){return this.s.coreTopology.logicalSessionTimeoutMinutes}}),Object.defineProperty(p.prototype,"type",{enumerable:!0,get:function(){return this.s.coreTopology.type}}),t.Store=c,t.ServerCapabilities=h,t.TopologyBase=p},function(e,t){function n(e,t){if(!(this instanceof n))return new n(e,t);this._bsontype="Long",this.low_=0|e,this.high_=0|t}n.prototype.toInt=function(){return this.low_},n.prototype.toNumber=function(){return this.high_*n.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.prototype.toBigInt=function(){return BigInt(this.toString())},n.prototype.toJSON=function(){return this.toString()},n.prototype.toString=function(e){var t=e||10;if(t<2||36=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var e=0!==this.high_?this.high_:this.low_,t=31;t>0&&0==(e&1<0},n.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},n.prototype.compare=function(e){if(this.equals(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.subtract(e).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(e){var t=this.high_>>>16,r=65535&this.high_,o=this.low_>>>16,s=65535&this.low_,i=e.high_>>>16,a=65535&e.high_,c=e.low_>>>16,l=0,u=0,h=0,p=0;return h+=(p+=s+(65535&e.low_))>>>16,p&=65535,u+=(h+=o+c)>>>16,h&=65535,l+=(u+=r+a)>>>16,u&=65535,l+=t+i,l&=65535,n.fromBits(h<<16|p,l<<16|u)},n.prototype.subtract=function(e){return this.add(e.negate())},n.prototype.multiply=function(e){if(this.isZero())return n.ZERO;if(e.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return e.isOdd()?n.MIN_VALUE:n.ZERO;if(e.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return e.isNegative()?this.negate().multiply(e.negate()):this.negate().multiply(e).negate();if(e.isNegative())return this.multiply(e.negate()).negate();if(this.lessThan(n.TWO_PWR_24_)&&e.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*e.toNumber());var t=this.high_>>>16,r=65535&this.high_,o=this.low_>>>16,s=65535&this.low_,i=e.high_>>>16,a=65535&e.high_,c=e.low_>>>16,l=65535&e.low_,u=0,h=0,p=0,f=0;return p+=(f+=s*l)>>>16,f&=65535,h+=(p+=o*l)>>>16,p&=65535,h+=(p+=s*c)>>>16,p&=65535,u+=(h+=r*l)>>>16,h&=65535,u+=(h+=o*c)>>>16,h&=65535,u+=(h+=s*a)>>>16,h&=65535,u+=t*l+r*c+o*a+s*i,u&=65535,n.fromBits(p<<16|f,u<<16|h)},n.prototype.div=function(e){if(e.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(e.equals(n.ONE)||e.equals(n.NEG_ONE))return n.MIN_VALUE;if(e.equals(n.MIN_VALUE))return n.ONE;var t=this.shiftRight(1).div(e).shiftLeft(1);if(t.equals(n.ZERO))return e.isNegative()?n.ONE:n.NEG_ONE;var r=this.subtract(e.multiply(t));return t.add(r.div(e))}if(e.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return e.isNegative()?this.negate().div(e.negate()):this.negate().div(e).negate();if(e.isNegative())return this.div(e.negate()).negate();var o=n.ZERO;for(r=this;r.greaterThanOrEqual(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),i=s<=48?1:Math.pow(2,s-48),a=n.fromNumber(t),c=a.multiply(e);c.isNegative()||c.greaterThan(r);)t-=i,c=(a=n.fromNumber(t)).multiply(e);a.isZero()&&(a=n.ONE),o=o.add(a),r=r.subtract(c)}return o},n.prototype.modulo=function(e){return this.subtract(this.div(e).multiply(e))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(e){return n.fromBits(this.low_&e.low_,this.high_&e.high_)},n.prototype.or=function(e){return n.fromBits(this.low_|e.low_,this.high_|e.high_)},n.prototype.xor=function(e){return n.fromBits(this.low_^e.low_,this.high_^e.high_)},n.prototype.shiftLeft=function(e){if(0===(e&=63))return this;var t=this.low_;if(e<32){var r=this.high_;return n.fromBits(t<>>32-e)}return n.fromBits(0,t<>>e|t<<32-e,t>>e)}return n.fromBits(t>>e-32,t>=0?0:-1)},n.prototype.shiftRightUnsigned=function(e){if(0===(e&=63))return this;var t=this.high_;if(e<32){var r=this.low_;return n.fromBits(r>>>e|t<<32-e,t>>>e)}return 32===e?n.fromBits(t,0):n.fromBits(t>>>e-32,0)},n.fromInt=function(e){if(-128<=e&&e<128){var t=n.INT_CACHE_[e];if(t)return t}var r=new n(0|e,e<0?-1:0);return-128<=e&&e<128&&(n.INT_CACHE_[e]=r),r},n.fromNumber=function(e){return isNaN(e)||!isFinite(e)?n.ZERO:e<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:e+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:e<0?n.fromNumber(-e).negate():new n(e%n.TWO_PWR_32_DBL_|0,e/n.TWO_PWR_32_DBL_|0)},n.fromBigInt=function(e){return n.fromString(e.toString(10),10)},n.fromBits=function(e,t){return new n(e,t)},n.fromString=function(e,t){if(0===e.length)throw Error("number format error: empty string");var r=t||10;if(r<2||36=0)throw Error('number format error: interior "-" character: '+e);for(var o=n.fromNumber(Math.pow(r,8)),s=n.ZERO,i=0;i{void 0!==t[e]&&(this[e]=t[e])}),this.me&&(this.me=this.me.toLowerCase()),this.hosts=this.hosts.map(e=>e.toLowerCase()),this.passives=this.passives.map(e=>e.toLowerCase()),this.arbiters=this.arbiters.map(e=>e.toLowerCase())}get allHosts(){return this.hosts.concat(this.arbiters).concat(this.passives)}get isReadable(){return this.type===i.RSSecondary||this.isWritable}get isDataBearing(){return l.has(this.type)}get isWritable(){return c.has(this.type)}get host(){const e=(":"+this.port).length;return this.address.slice(0,-e)}get port(){const e=this.address.split(":").pop();return e?Number.parseInt(e,10):e}equals(e){const t=this.topologyVersion===e.topologyVersion||0===p(this.topologyVersion,e.topologyVersion);return null!=e&&s(this.error,e.error)&&this.type===e.type&&this.minWireVersion===e.minWireVersion&&this.me===e.me&&r(this.hosts,e.hosts)&&o(this.tags,e.tags)&&this.setName===e.setName&&this.setVersion===e.setVersion&&(this.electionId?e.electionId&&this.electionId.equals(e.electionId):this.electionId===e.electionId)&&this.primary===e.primary&&this.logicalSessionTimeoutMinutes===e.logicalSessionTimeoutMinutes&&t}},parseServerType:h,compareTopologyVersion:p}},function(e,t,n){"use strict";const r=n(17).Buffer,o=n(6).opcodes,s=n(6).databaseNamespace,i=n(10),a=n(3).MongoError;let c=0;class l{constructor(e,t,n,r){if(null==n)throw new Error("query must be specified for query");this.bson=e,this.ns=t,this.command=n,this.command.$db=s(t),r.readPreference&&r.readPreference.mode!==i.PRIMARY&&(this.command.$readPreference=r.readPreference.toJSON()),this.options=r||{},this.requestId=r.requestId?r.requestId:l.getRequestId(),this.serializeFunctions="boolean"==typeof r.serializeFunctions&&r.serializeFunctions,this.ignoreUndefined="boolean"==typeof r.ignoreUndefined&&r.ignoreUndefined,this.checkKeys="boolean"==typeof r.checkKeys&&r.checkKeys,this.maxBsonSize=r.maxBsonSize||16777216,this.checksumPresent=!1,this.moreToCome=r.moreToCome||!1,this.exhaustAllowed="boolean"==typeof r.exhaustAllowed&&r.exhaustAllowed}toBin(){const e=[];let t=0;this.checksumPresent&&(t|=1),this.moreToCome&&(t|=2),this.exhaustAllowed&&(t|=65536);const n=r.alloc(20);e.push(n);let s=n.length;const i=this.command;return s+=this.makeDocumentSegment(e,i),n.writeInt32LE(s,0),n.writeInt32LE(this.requestId,4),n.writeInt32LE(0,8),n.writeInt32LE(o.OP_MSG,12),n.writeUInt32LE(t,16),e}makeDocumentSegment(e,t){const n=r.alloc(1);n[0]=0;const o=this.serializeBson(t);return e.push(n),e.push(o),n.length+o.length}serializeBson(e){return this.bson.serialize(e,{checkKeys:this.checkKeys,serializeFunctions:this.serializeFunctions,ignoreUndefined:this.ignoreUndefined})}}l.getRequestId=function(){return c=c+1&2147483647,c};e.exports={Msg:l,BinMsg:class{constructor(e,t,n,r,o){o=o||{promoteLongs:!0,promoteValues:!0,promoteBuffers:!1},this.parsed=!1,this.raw=t,this.data=r,this.bson=e,this.opts=o,this.length=n.length,this.requestId=n.requestId,this.responseTo=n.responseTo,this.opCode=n.opCode,this.fromCompressed=n.fromCompressed,this.responseFlags=r.readInt32LE(0),this.checksumPresent=0!=(1&this.responseFlags),this.moreToCome=0!=(2&this.responseFlags),this.exhaustAllowed=0!=(65536&this.responseFlags),this.promoteLongs="boolean"!=typeof o.promoteLongs||o.promoteLongs,this.promoteValues="boolean"!=typeof o.promoteValues||o.promoteValues,this.promoteBuffers="boolean"==typeof o.promoteBuffers&&o.promoteBuffers,this.documents=[]}isParsed(){return this.parsed}parse(e){if(this.parsed)return;e=e||{},this.index=4;const t=e.raw||!1,n=e.documentsReturnedIn||null,r={promoteLongs:"boolean"==typeof e.promoteLongs?e.promoteLongs:this.opts.promoteLongs,promoteValues:"boolean"==typeof e.promoteValues?e.promoteValues:this.opts.promoteValues,promoteBuffers:"boolean"==typeof e.promoteBuffers?e.promoteBuffers:this.opts.promoteBuffers};for(;this.index255)throw new Error("only accepts number in a valid unsigned byte range 0-255");var t=null;if(t="string"==typeof e?e.charCodeAt(0):null!=e.length?e[0]:e,this.buffer.length>this.position)this.buffer[this.position++]=t;else if(void 0!==r&&r.isBuffer(this.buffer)){var n=o.allocBuffer(s.BUFFER_SIZE+this.buffer.length);this.buffer.copy(n,0,0,this.buffer.length),this.buffer=n,this.buffer[this.position++]=t}else{n=null,n="[object Uint8Array]"===Object.prototype.toString.call(this.buffer)?new Uint8Array(new ArrayBuffer(s.BUFFER_SIZE+this.buffer.length)):new Array(s.BUFFER_SIZE+this.buffer.length);for(var i=0;ithis.position?t+e.length:this.position;else if(void 0!==r&&"string"==typeof e&&r.isBuffer(this.buffer))this.buffer.write(e,t,"binary"),this.position=t+e.length>this.position?t+e.length:this.position;else if("[object Uint8Array]"===Object.prototype.toString.call(e)||"[object Array]"===Object.prototype.toString.call(e)&&"string"!=typeof e){for(s=0;sthis.position?t:this.position}else if("string"==typeof e){for(s=0;sthis.position?t:this.position}},s.prototype.read=function(e,t){if(t=t&&t>0?t:this.position,this.buffer.slice)return this.buffer.slice(e,e+t);for(var n="undefined"!=typeof Uint8Array?new Uint8Array(new ArrayBuffer(t)):new Array(t),r=0;r=6&&null==t.__nodejs_mock_server__}(e),b=p.session;let S=e.clusterTime,v=Object.assign({},n);if(function(e){if(null==e)return!1;if(e.description)return e.description.maxWireVersion>=6;return null!=e.ismaster&&e.ismaster.maxWireVersion>=6}(e)&&b){b.clusterTime&&b.clusterTime.clusterTime.greaterThan(S.clusterTime)&&(S=b.clusterTime);const e=u(b,v,p);if(e)return f(e)}S&&(v.$clusterTime=S),a(e)&&!g&&y&&"primary"!==y.mode&&(v={$query:v,$readPreference:y.toJSON()});const w=Object.assign({command:!0,numberToSkip:0,numberToReturn:-1,checkKeys:!1},p);w.slaveOk=y.slaveOk();const O=c(t)+".$cmd",_=g?new o(d,O,v,w):new r(d,O,v,w),T=b&&(b.inTransaction()||l(v))?function(e){return e&&e instanceof h&&!e.hasErrorLabel("TransientTransactionError")&&e.addErrorLabel("TransientTransactionError"),!n.commitTransaction&&e&&e instanceof s&&e.hasErrorLabel("TransientTransactionError")&&b.transaction.unpinServer(),f.apply(null,arguments)}:f;try{m.write(_,w,T)}catch(e){T(e)}}e.exports=function(e,t,n,r,o){if("function"==typeof r&&(o=r,r={}),r=r||{},null==n)return o(new s(`command ${JSON.stringify(n)} does not return a cursor`));if(!function(e){return p(e)&&e.autoEncrypter}(e))return void f(e,t,n,r,o);const i=p(e);"number"!=typeof i||i<8?o(new s("Auto-encryption requires a minimum MongoDB version of 4.2")):function(e,t,n,r,o){const s=e.autoEncrypter;function i(e,t){e||null==t?o(e,t):s.decrypt(t.result,r,(e,n)=>{e?o(e,null):(t.result=n,t.message.documents=[n],o(null,t))})}s.encrypt(t,n,r,(n,s)=>{n?o(n,null):f(e,t,s,r,i)})}(e,t,n,r,o)}},function(e,t,n){"use strict";const r=n(0).maybePromise,o=n(3).MongoError,s=n(1).Aspect,i=n(1).OperationBase,a=n(10),c=n(3).isRetryableError,l=n(4).maxWireVersion,u=n(4).isUnifiedTopology;function h(e,t,n){if(null==e)throw new TypeError("This method requires a valid topology instance");if(!(t instanceof i))throw new TypeError("This method requires a valid operation instance");return r(e,n,n=>{if(u(e)&&e.shouldCheckForSessionSupport())return function(e,t,n){e.selectServer(a.primaryPreferred,r=>{if(r)return n(r);h(e,t,n)})}(e,t,n);let r,i;if(e.hasSessionSupport()){if(null==t.session)i=Symbol(),r=e.startSession({owner:i}),t.session=r;else if(t.session.hasEnded)return n(new o("Use of expired sessions is not permitted"))}else if(t.session)return n(new o("Current topology does not support sessions"));function l(e,o){r&&r.owner===i&&(r.endSession(),t.session===r&&t.clearSession()),n(e,o)}try{t.hasAspect(s.EXECUTE_WITH_SELECTION)?function(e,t,n){const r=t.readPreference||a.primary,i=t.session&&t.session.inTransaction();if(i&&!r.equals(a.primary))return void n(new o("Read preference in a transaction must be primary, not: "+r.mode));const l={readPreference:r,session:t.session};function u(r,o){return null==r?n(null,o):c(r)?void e.selectServer(l,(e,r)=>{!e&&p(r)?t.execute(r,n):n(e,null)}):n(r)}e.selectServer(l,(r,o)=>{if(r)return void n(r,null);const a=!1!==e.s.options.retryReads&&t.session&&!i&&p(o)&&t.canRetryRead;t.hasAspect(s.RETRYABLE)&&a?t.execute(o,u):t.execute(o,n)})}(e,t,l):t.execute(l)}catch(e){r&&r.owner===i&&(r.endSession(),t.session===r&&t.clearSession()),n(e)}})}function p(e){return l(e)>=6}e.exports=h},function(e,t){function n(e){return Object.prototype.toString.call(e)}t.isArray=function(e){return Array.isArray?Array.isArray(e):"[object Array]"===n(e)},t.isBoolean=function(e){return"boolean"==typeof e},t.isNull=function(e){return null===e},t.isNullOrUndefined=function(e){return null==e},t.isNumber=function(e){return"number"==typeof e},t.isString=function(e){return"string"==typeof e},t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=function(e){return void 0===e},t.isRegExp=function(e){return"[object RegExp]"===n(e)},t.isObject=function(e){return"object"==typeof e&&null!==e},t.isDate=function(e){return"[object Date]"===n(e)},t.isError=function(e){return"[object Error]"===n(e)||e instanceof Error},t.isFunction=function(e){return"function"==typeof e},t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=Buffer.isBuffer},function(e,t,n){try{var r=n(5);if("function"!=typeof r.inherits)throw"";e.exports=r.inherits}catch(t){e.exports=n(155)}},function(e,t,n){"use strict";const r=n(74),o=n(62),s=n(8).EventEmitter,i=n(5).inherits,a=n(2).MongoError,c=n(5).deprecate,l=n(22),u=n(0).MongoDBNamespace,h=n(10),p=n(0).maybePromise,f=n(115),d=n(116).connect,m=n(116).validOptions;function y(e,t){if(!(this instanceof y))return new y(e,t);s.call(this),t&&t.autoEncryption&&n(119),this.s={url:e,options:t||{},promiseLibrary:t&&t.promiseLibrary||Promise,dbCache:new Map,sessions:new Set,writeConcern:l.fromOptions(t),readPreference:h.fromOptions(t)||h.primary,namespace:new u("admin")}}i(y,s),Object.defineProperty(y.prototype,"writeConcern",{enumerable:!0,get:function(){return this.s.writeConcern}}),Object.defineProperty(y.prototype,"readPreference",{enumerable:!0,get:function(){return this.s.readPreference}}),y.prototype.connect=function(e){if("string"==typeof e)throw new TypeError("`connect` only accepts a callback");const t=this;return p(this,e,e=>{const n=m(t.s.options);if(n)return e(n);d(t,t.s.url,t.s.options,n=>{if(n)return e(n);e(null,t)})})},y.prototype.logout=c((function(e,t){"function"==typeof e&&(t=e,e={}),"function"==typeof t&&t(null,!0)}),"Multiple authentication is prohibited on a connected client, please only authenticate once per MongoClient"),y.prototype.close=function(e,t){"function"==typeof e&&(t=e,e=!1);const n=this;return p(this,t,t=>{const r=e=>{if(n.emit("close",n),!(n.topology instanceof f))for(const e of n.s.dbCache)e[1].emit("close",n);n.removeAllListeners("close"),t(e)};null!=n.topology?n.topology.close(e,t=>{const o=n.topology.s.options.encrypter;if(o)return o.close(n,e,e=>{r(t||e)});r(t)}):r()})},y.prototype.db=function(e,t){t=t||{},e||(e=this.s.options.dbName);const n=Object.assign({},this.s.options,t);if(this.s.dbCache.has(e)&&!0!==n.returnNonCachedInstance)return this.s.dbCache.get(e);if(n.promiseLibrary=this.s.promiseLibrary,!this.topology)throw new a("MongoClient must be connected before calling MongoClient.prototype.db");const r=new o(e,this.topology,n);return this.s.dbCache.set(e,r),r},y.prototype.isConnected=function(e){return e=e||{},!!this.topology&&this.topology.isConnected(e)},y.connect=function(e,t,n){const r=Array.prototype.slice.call(arguments,1);n="function"==typeof r[r.length-1]?r.pop():void 0;const o=new y(e,t=(t=r.length?r.shift():null)||{});return o.connect(n)},y.prototype.startSession=function(e){if(e=Object.assign({explicit:!0},e),!this.topology)throw new a("Must connect to a server before calling this method");return this.topology.startSession(e,this.s.options)},y.prototype.withSession=function(e,t){"function"==typeof e&&(t=e,e=void 0);const n=this.startSession(e);let r=(e,t,o)=>{if(r=()=>{throw new ReferenceError("cleanupHandler was called too many times")},o=Object.assign({throw:!0},o),n.endSession(),e){if(o.throw)throw e;return Promise.reject(e)}};try{const e=t(n);return Promise.resolve(e).then(e=>r(null,e)).catch(e=>r(e,null,{throw:!0}))}catch(e){return r(e,null,{throw:!1})}},y.prototype.watch=function(e,t){return e=e||[],t=t||{},Array.isArray(e)||(t=e,e=[]),new r(this,e,t)},y.prototype.getLogger=function(){return this.s.options.logger},e.exports=y},function(e,t,n){"use strict";const r=n(0).applyWriteConcern,o=n(2).BSON.Code,s=n(11).createIndex,i=n(0).decorateWithCollation,a=n(0).decorateWithReadConcern,c=n(11).ensureIndex,l=n(11).evaluate,u=n(11).executeCommand,h=n(0).handleCallback,p=n(11).indexInformation,f=n(2).BSON.Long,d=n(2).MongoError,m=n(2).ReadPreference,y=n(13).insertDocuments,g=n(13).updateDocuments;function b(e,t,n){p(e.s.db,e.collectionName,t,n)}e.exports={createIndex:function(e,t,n,r){s(e.s.db,e.collectionName,t,n,r)},createIndexes:function(e,t,n,r){const o=e.s.topology.capabilities();for(let e=0;e{e[t]=1}),p.group.key=e}(f=Object.assign({},f)).readPreference=m.resolve(e,f),a(p,e,f);try{i(p,e,f)}catch(e){return d(e,null)}u(e.s.db,p,f,(e,t)=>{if(e)return h(d,e,null);h(d,null,t.retval)})}else{const i=null!=s&&"Code"===s._bsontype?s.scope:{};i.ns=e.collectionName,i.keys=t,i.condition=n,i.initial=r;const a='function () {\nvar c = db[ns].find(condition);\nvar map = new Map();\nvar reduce_function = reduce;\n\nwhile (c.hasNext()) {\nvar obj = c.next();\nvar key = {};\n\nfor (var i = 0, len = keys.length; i < len; ++i) {\nvar k = keys[i];\nkey[k] = obj[k];\n}\n\nvar aggObj = map.get(key);\n\nif (aggObj == null) {\nvar newObj = Object.extend({}, key);\naggObj = Object.extend(newObj, initial);\nmap.put(key, aggObj);\n}\n\nreduce_function(obj, aggObj);\n}\n\nreturn { "result": map.values() };\n}'.replace(/ reduce;/,s.toString()+";");l(e.s.db,new o(a,i),null,f,(e,t)=>{if(e)return h(d,e,null);h(d,null,t.result||t)})}},indexes:function(e,t,n){t=Object.assign({},{full:!0},t),p(e.s.db,e.collectionName,t,n)},indexExists:function(e,t,n,r){b(e,n,(e,n)=>{if(null!=e)return h(r,e,null);if(!Array.isArray(t))return h(r,null,null!=n[t]);for(let e=0;e{if(r)return h(n,r,null);if(null==s)return h(n,new Error("no result returned for parallelCollectionScan"),null);t=Object.assign({explicitlyIgnoreSession:!0},t);const i=[];o&&(t.raw=o);for(let n=0;n{if(null!=o)return null==t?h(o,null,null):e?h(o,e,null):void h(o,null,n)})}}},function(e,t,n){"use strict";const r=n(5).deprecate,o=n(0).deprecateOptions,s=n(0).emitWarningOnce,i=n(0).checkCollectionName,a=n(2).BSON.ObjectID,c=n(2).MongoError,l=n(0).normalizeHintField,u=n(0).decorateCommand,h=n(0).decorateWithCollation,p=n(0).decorateWithReadConcern,f=n(0).formattedOrderClause,d=n(2).ReadPreference,m=n(169),y=n(170),g=n(74),b=n(0).executeLegacyOperation,S=n(22),v=n(32),w=n(0).MongoDBNamespace,O=n(77),_=n(78),T=n(41).ensureIndex,E=n(41).group,C=n(41).parallelCollectionScan,x=n(13).removeDocuments,N=n(41).save,I=n(13).updateDocuments,A=n(60),k=n(105),M=n(171),B=n(106),R=n(172),P=n(173),D=n(174),L=n(79).DropCollectionOperation,j=n(107),U=n(175),z=n(176),W=n(177),q=n(178),F=n(61),$=n(179),V=n(180),H=n(181),Y=n(182),K=n(183),G=n(184),X=n(108),J=n(185),Z=n(186),Q=n(187),ee=n(188),te=n(189),ne=n(109),re=n(113),oe=n(198),se=n(199),ie=n(200),ae=n(201),ce=n(202),le=n(37),ue=["ignoreUndefined"];function he(e,t,n,r,o,s){i(r);const c=null==s||null==s.slaveOk?e.slaveOk:s.slaveOk,l=null==s||null==s.serializeFunctions?e.s.options.serializeFunctions:s.serializeFunctions,u=null==s||null==s.raw?e.s.options.raw:s.raw,h=null==s||null==s.promoteLongs?e.s.options.promoteLongs:s.promoteLongs,p=null==s||null==s.promoteValues?e.s.options.promoteValues:s.promoteValues,f=null==s||null==s.promoteBuffers?e.s.options.promoteBuffers:s.promoteBuffers,m=new w(n,r),y=s.promiseLibrary||Promise;o=null==o?a:o,this.s={pkFactory:o,db:e,topology:t,options:s,namespace:m,readPreference:d.fromOptions(s),slaveOk:c,serializeFunctions:l,raw:u,promoteLongs:h,promoteValues:p,promoteBuffers:f,internalHint:null,collectionHint:null,promiseLibrary:y,readConcern:v.fromOptions(s),writeConcern:S.fromOptions(s)}}Object.defineProperty(he.prototype,"dbName",{enumerable:!0,get:function(){return this.s.namespace.db}}),Object.defineProperty(he.prototype,"collectionName",{enumerable:!0,get:function(){return this.s.namespace.collection}}),Object.defineProperty(he.prototype,"namespace",{enumerable:!0,get:function(){return this.s.namespace.toString()}}),Object.defineProperty(he.prototype,"readConcern",{enumerable:!0,get:function(){return null==this.s.readConcern?this.s.db.readConcern:this.s.readConcern}}),Object.defineProperty(he.prototype,"readPreference",{enumerable:!0,get:function(){return null==this.s.readPreference?this.s.db.readPreference:this.s.readPreference}}),Object.defineProperty(he.prototype,"writeConcern",{enumerable:!0,get:function(){return null==this.s.writeConcern?this.s.db.writeConcern:this.s.writeConcern}}),Object.defineProperty(he.prototype,"hint",{enumerable:!0,get:function(){return this.s.collectionHint},set:function(e){this.s.collectionHint=l(e)}});const pe=["maxScan","fields","snapshot","oplogReplay"];function fe(e,t,n,r,o){const s=Array.prototype.slice.call(arguments,1);return o="function"==typeof s[s.length-1]?s.pop():void 0,t=s.length&&s.shift()||[],n=s.length?s.shift():null,r=s.length&&s.shift()||{},(r=Object.assign({},r)).readPreference=d.PRIMARY,le(this.s.topology,new F(this,e,t,n,r),o)}he.prototype.find=o({name:"collection.find",deprecatedOptions:pe,optionsIndex:1},(function(e,t,n){"object"==typeof n&&s("Third parameter to `find()` must be a callback or undefined");let r=e;"function"!=typeof n&&("function"==typeof t?(n=t,t=void 0):null==t&&(n="function"==typeof r?r:void 0,r="object"==typeof r?r:void 0)),r=null==r?{}:r;const o=r;if(Buffer.isBuffer(o)){const e=o[0]|o[1]<<8|o[2]<<16|o[3]<<24;if(e!==o.length){const t=new Error("query selector raw message size does not match message header size ["+o.length+"] != ["+e+"]");throw t.name="MongoError",t}}null!=r&&"ObjectID"===r._bsontype&&(r={_id:r}),t||(t={});let i=t.projection||t.fields;i&&!Buffer.isBuffer(i)&&Array.isArray(i)&&(i=i.length?i.reduce((e,t)=>(e[t]=1,e),{}):{_id:1});let a=Object.assign({},t);for(let e in this.s.options)-1!==ue.indexOf(e)&&(a[e]=this.s.options[e]);if(a.skip=t.skip?t.skip:0,a.limit=t.limit?t.limit:0,a.raw="boolean"==typeof t.raw?t.raw:this.s.raw,a.hint=null!=t.hint?l(t.hint):this.s.collectionHint,a.timeout=void 0===t.timeout?void 0:t.timeout,a.slaveOk=null!=t.slaveOk?t.slaveOk:this.s.db.slaveOk,a.readPreference=d.resolve(this,a),null==a.readPreference||"primary"===a.readPreference&&"primary"===a.readPreference.mode||(a.slaveOk=!0),null!=r&&"object"!=typeof r)throw c.create({message:"query selector must be an object",driver:!0});const m={find:this.s.namespace.toString(),limit:a.limit,skip:a.skip,query:r};"boolean"==typeof t.allowDiskUse&&(m.allowDiskUse=t.allowDiskUse),"boolean"==typeof a.awaitdata&&(a.awaitData=a.awaitdata),"boolean"==typeof a.timeout&&(a.noCursorTimeout=!a.timeout),u(m,a,["session","collation"]),i&&(m.fields=i),a.db=this.s.db,a.promiseLibrary=this.s.promiseLibrary,null==a.raw&&"boolean"==typeof this.s.raw&&(a.raw=this.s.raw),null==a.promoteLongs&&"boolean"==typeof this.s.promoteLongs&&(a.promoteLongs=this.s.promoteLongs),null==a.promoteValues&&"boolean"==typeof this.s.promoteValues&&(a.promoteValues=this.s.promoteValues),null==a.promoteBuffers&&"boolean"==typeof this.s.promoteBuffers&&(a.promoteBuffers=this.s.promoteBuffers),m.sort&&(m.sort=f(m.sort)),p(m,this,t);try{h(m,this,t)}catch(e){if("function"==typeof n)return n(e,null);throw e}const y=this.s.topology.cursor(new W(this,this.s.namespace,m,a),a);if("function"!=typeof n)return y;n(null,y)})),he.prototype.insertOne=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=t||{},this.s.options.ignoreUndefined&&((t=Object.assign({},t)).ignoreUndefined=this.s.options.ignoreUndefined);const r=new Z(this,e,t);return le(this.s.topology,r,n)},he.prototype.insertMany=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=t?Object.assign({},t):{ordered:!0};const r=new J(this,e,t);return le(this.s.topology,r,n)},he.prototype.bulkWrite=function(e,t,n){if("function"==typeof t&&(n=t,t={}),t=t||{ordered:!0},!Array.isArray(e))throw c.create({message:"operations must be an array of documents",driver:!0});const r=new k(this,e,t);return le(this.s.topology,r,n)},he.prototype.insert=r((function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=t||{ordered:!1},e=Array.isArray(e)?e:[e],!0===t.keepGoing&&(t.ordered=!1),this.insertMany(e,t,n)}),"collection.insert is deprecated. Use insertOne, insertMany or bulkWrite instead."),he.prototype.updateOne=function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=Object.assign({},n),this.s.options.ignoreUndefined&&((n=Object.assign({},n)).ignoreUndefined=this.s.options.ignoreUndefined),le(this.s.topology,new ce(this,e,t,n),r)},he.prototype.replaceOne=function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=Object.assign({},n),this.s.options.ignoreUndefined&&((n=Object.assign({},n)).ignoreUndefined=this.s.options.ignoreUndefined),le(this.s.topology,new se(this,e,t,n),r)},he.prototype.updateMany=function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=Object.assign({},n),this.s.options.ignoreUndefined&&((n=Object.assign({},n)).ignoreUndefined=this.s.options.ignoreUndefined),le(this.s.topology,new ae(this,e,t,n),r)},he.prototype.update=r((function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=n||{},this.s.options.ignoreUndefined&&((n=Object.assign({},n)).ignoreUndefined=this.s.options.ignoreUndefined),b(this.s.topology,I,[this,e,t,n,r])}),"collection.update is deprecated. Use updateOne, updateMany, or bulkWrite instead."),he.prototype.deleteOne=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=Object.assign({},t),this.s.options.ignoreUndefined&&((t=Object.assign({},t)).ignoreUndefined=this.s.options.ignoreUndefined);const r=new P(this,e,t);return le(this.s.topology,r,n)},he.prototype.removeOne=he.prototype.deleteOne,he.prototype.deleteMany=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=Object.assign({},t),this.s.options.ignoreUndefined&&((t=Object.assign({},t)).ignoreUndefined=this.s.options.ignoreUndefined);const r=new R(this,e,t);return le(this.s.topology,r,n)},he.prototype.removeMany=he.prototype.deleteMany,he.prototype.remove=r((function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=t||{},this.s.options.ignoreUndefined&&((t=Object.assign({},t)).ignoreUndefined=this.s.options.ignoreUndefined),b(this.s.topology,x,[this,e,t,n])}),"collection.remove is deprecated. Use deleteOne, deleteMany, or bulkWrite instead."),he.prototype.save=r((function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=t||{},this.s.options.ignoreUndefined&&((t=Object.assign({},t)).ignoreUndefined=this.s.options.ignoreUndefined),b(this.s.topology,N,[this,e,t,n])}),"collection.save is deprecated. Use insertOne, insertMany, updateOne, or updateMany instead."),he.prototype.findOne=o({name:"collection.find",deprecatedOptions:pe,optionsIndex:1},(function(e,t,n){"object"==typeof n&&s("Third parameter to `findOne()` must be a callback or undefined"),"function"==typeof e&&(n=e,e={},t={}),"function"==typeof t&&(n=t,t={});const r=new q(this,e=e||{},t=t||{});return le(this.s.topology,r,n)})),he.prototype.rename=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=Object.assign({},t,{readPreference:d.PRIMARY});const r=new re(this,e,t);return le(this.s.topology,r,n)},he.prototype.drop=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=new L(this.s.db,this.collectionName,e);return le(this.s.topology,n,t)},he.prototype.options=function(e,t){"function"==typeof e&&(t=e,e={});const n=new ne(this,e=e||{});return le(this.s.topology,n,t)},he.prototype.isCapped=function(e,t){"function"==typeof e&&(t=e,e={});const n=new Q(this,e=e||{});return le(this.s.topology,n,t)},he.prototype.createIndex=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=t||{};const r=new B(this,this.collectionName,e,t);return le(this.s.topology,r,n)},he.prototype.createIndexes=function(e,t,n){"function"==typeof t&&(n=t,t={}),"number"!=typeof(t=t?Object.assign({},t):{}).maxTimeMS&&delete t.maxTimeMS;const r=new B(this,this.collectionName,e,t);return le(this.s.topology,r,n)},he.prototype.dropIndex=function(e,t,n){const r=Array.prototype.slice.call(arguments,1);n="function"==typeof r[r.length-1]?r.pop():void 0,(t=r.length&&r.shift()||{}).readPreference=d.PRIMARY;const o=new j(this,e,t);return le(this.s.topology,o,n)},he.prototype.dropIndexes=function(e,t){"function"==typeof e&&(t=e,e={}),"number"!=typeof(e=e?Object.assign({},e):{}).maxTimeMS&&delete e.maxTimeMS;const n=new U(this,e);return le(this.s.topology,n,t)},he.prototype.dropAllIndexes=r(he.prototype.dropIndexes,"collection.dropAllIndexes is deprecated. Use dropIndexes instead."),he.prototype.reIndex=r((function(e,t){"function"==typeof e&&(t=e,e={});const n=new oe(this,e=e||{});return le(this.s.topology,n,t)}),"collection.reIndex is deprecated. Use db.command instead."),he.prototype.listIndexes=function(e){return new _(this.s.topology,new ee(this,e),e)},he.prototype.ensureIndex=r((function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=t||{},b(this.s.topology,T,[this,e,t,n])}),"collection.ensureIndex is deprecated. Use createIndexes instead."),he.prototype.indexExists=function(e,t,n){"function"==typeof t&&(n=t,t={});const r=new G(this,e,t=t||{});return le(this.s.topology,r,n)},he.prototype.indexInformation=function(e,t){const n=Array.prototype.slice.call(arguments,0);t="function"==typeof n[n.length-1]?n.pop():void 0,e=n.length&&n.shift()||{};const r=new X(this.s.db,this.collectionName,e);return le(this.s.topology,r,t)},he.prototype.count=r((function(e,t,n){const r=Array.prototype.slice.call(arguments,0);return n="function"==typeof r[r.length-1]?r.pop():void 0,e=r.length&&r.shift()||{},"function"==typeof(t=r.length&&r.shift()||{})&&(n=t,t={}),t=t||{},le(this.s.topology,new z(this,e,t),n)}),"collection.count is deprecated, and will be removed in a future version. Use Collection.countDocuments or Collection.estimatedDocumentCount instead"),he.prototype.estimatedDocumentCount=function(e,t){"function"==typeof e&&(t=e,e={});const n=new z(this,e=e||{});return le(this.s.topology,n,t)},he.prototype.countDocuments=function(e,t,n){const r=Array.prototype.slice.call(arguments,0);n="function"==typeof r[r.length-1]?r.pop():void 0,e=r.length&&r.shift()||{},t=r.length&&r.shift()||{};const o=new M(this,e,t);return le(this.s.topology,o,n)},he.prototype.distinct=function(e,t,n,r){const o=Array.prototype.slice.call(arguments,1);r="function"==typeof o[o.length-1]?o.pop():void 0;const s=o.length&&o.shift()||{},i=o.length&&o.shift()||{},a=new D(this,e,s,i);return le(this.s.topology,a,r)},he.prototype.indexes=function(e,t){"function"==typeof e&&(t=e,e={});const n=new K(this,e=e||{});return le(this.s.topology,n,t)},he.prototype.stats=function(e,t){const n=Array.prototype.slice.call(arguments,0);t="function"==typeof n[n.length-1]?n.pop():void 0,e=n.length&&n.shift()||{};const r=new ie(this,e);return le(this.s.topology,r,t)},he.prototype.findOneAndDelete=function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=t||{},this.s.options.ignoreUndefined&&((t=Object.assign({},t)).ignoreUndefined=this.s.options.ignoreUndefined),le(this.s.topology,new $(this,e,t),n)},he.prototype.findOneAndReplace=function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=n||{},this.s.options.ignoreUndefined&&((n=Object.assign({},n)).ignoreUndefined=this.s.options.ignoreUndefined),le(this.s.topology,new V(this,e,t,n),r)},he.prototype.findOneAndUpdate=function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=n||{},this.s.options.ignoreUndefined&&((n=Object.assign({},n)).ignoreUndefined=this.s.options.ignoreUndefined),le(this.s.topology,new H(this,e,t,n),r)},he.prototype.findAndModify=r(fe,"collection.findAndModify is deprecated. Use findOneAndUpdate, findOneAndReplace or findOneAndDelete instead."),he.prototype._findAndModify=fe,he.prototype.findAndRemove=r((function(e,t,n,r){const o=Array.prototype.slice.call(arguments,1);return r="function"==typeof o[o.length-1]?o.pop():void 0,t=o.length&&o.shift()||[],(n=o.length&&o.shift()||{}).remove=!0,le(this.s.topology,new F(this,e,t,null,n),r)}),"collection.findAndRemove is deprecated. Use findOneAndDelete instead."),he.prototype.aggregate=function(e,t,n){if(Array.isArray(e))"function"==typeof t&&(n=t,t={}),null==t&&null==n&&(t={});else{const r=Array.prototype.slice.call(arguments,0);n=r.pop();const o=r[r.length-1];t=o&&(o.readPreference||o.explain||o.cursor||o.out||o.maxTimeMS||o.hint||o.allowDiskUse)?r.pop():{},e=r}const r=new O(this.s.topology,new A(this,e,t),t);if("function"!=typeof n)return r;n(null,r)},he.prototype.watch=function(e,t){return e=e||[],t=t||{},Array.isArray(e)||(t=e,e=[]),new g(this,e,t)},he.prototype.parallelCollectionScan=r((function(e,t){return"function"==typeof e&&(t=e,e={numCursors:1}),e.numCursors=e.numCursors||1,e.batchSize=e.batchSize||1e3,(e=Object.assign({},e)).readPreference=d.resolve(this,e),e.promiseLibrary=this.s.promiseLibrary,e.session&&(e.session=void 0),b(this.s.topology,C,[this,e,t],{skipSessions:!0})}),"parallelCollectionScan is deprecated in MongoDB v4.1"),he.prototype.geoHaystackSearch=r((function(e,t,n,r){const o=Array.prototype.slice.call(arguments,2);r="function"==typeof o[o.length-1]?o.pop():void 0,n=o.length&&o.shift()||{};const s=new Y(this,e,t,n);return le(this.s.topology,s,r)}),"geoHaystackSearch is deprecated, and will be removed in a future version."),he.prototype.group=r((function(e,t,n,r,o,s,i,a){const c=Array.prototype.slice.call(arguments,3);return a="function"==typeof c[c.length-1]?c.pop():void 0,r=c.length?c.shift():null,o=c.length?c.shift():null,s=c.length?c.shift():null,i=c.length&&c.shift()||{},"function"!=typeof o&&(s=o,o=null),!Array.isArray(e)&&e instanceof Object&&"function"!=typeof e&&"Code"!==e._bsontype&&(e=Object.keys(e)),"function"==typeof r&&(r=r.toString()),"function"==typeof o&&(o=o.toString()),s=null==s||s,b(this.s.topology,E,[this,e,t,n,r,o,s,i,a])}),"MongoDB 3.6 or higher no longer supports the group command. We recommend rewriting using the aggregation framework."),he.prototype.mapReduce=function(e,t,n,r){if("function"==typeof n&&(r=n,n={}),null==n.out)throw new Error("the out option parameter must be defined, see mongodb docs for possible values");"function"==typeof e&&(e=e.toString()),"function"==typeof t&&(t=t.toString()),"function"==typeof n.finalize&&(n.finalize=n.finalize.toString());const o=new te(this,e,t,n);return le(this.s.topology,o,r)},he.prototype.initializeUnorderedBulkOp=function(e){return null==(e=e||{}).ignoreUndefined&&(e.ignoreUndefined=this.s.options.ignoreUndefined),e.promiseLibrary=this.s.promiseLibrary,m(this.s.topology,this,e)},he.prototype.initializeOrderedBulkOp=function(e){return null==(e=e||{}).ignoreUndefined&&(e.ignoreUndefined=this.s.options.ignoreUndefined),e.promiseLibrary=this.s.promiseLibrary,y(this.s.topology,this,e)},he.prototype.getLogger=function(){return this.s.db.s.logger},e.exports=he},function(e,t){function n(e){if(!(this instanceof n))return new n(e);this._bsontype="Double",this.value=e}n.prototype.valueOf=function(){return this.value},n.prototype.toJSON=function(){return this.value},e.exports=n,e.exports.Double=n},function(e,t){function n(e,t){if(!(this instanceof n))return new n(e,t);this._bsontype="Timestamp",this.low_=0|e,this.high_=0|t}n.prototype.toInt=function(){return this.low_},n.prototype.toNumber=function(){return this.high_*n.TWO_PWR_32_DBL_+this.getLowBitsUnsigned()},n.prototype.toJSON=function(){return this.toString()},n.prototype.toString=function(e){var t=e||10;if(t<2||36=0?this.low_:n.TWO_PWR_32_DBL_+this.low_},n.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(n.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var e=0!==this.high_?this.high_:this.low_,t=31;t>0&&0==(e&1<0},n.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},n.prototype.compare=function(e){if(this.equals(e))return 0;var t=this.isNegative(),n=e.isNegative();return t&&!n?-1:!t&&n?1:this.subtract(e).isNegative()?-1:1},n.prototype.negate=function(){return this.equals(n.MIN_VALUE)?n.MIN_VALUE:this.not().add(n.ONE)},n.prototype.add=function(e){var t=this.high_>>>16,r=65535&this.high_,o=this.low_>>>16,s=65535&this.low_,i=e.high_>>>16,a=65535&e.high_,c=e.low_>>>16,l=0,u=0,h=0,p=0;return h+=(p+=s+(65535&e.low_))>>>16,p&=65535,u+=(h+=o+c)>>>16,h&=65535,l+=(u+=r+a)>>>16,u&=65535,l+=t+i,l&=65535,n.fromBits(h<<16|p,l<<16|u)},n.prototype.subtract=function(e){return this.add(e.negate())},n.prototype.multiply=function(e){if(this.isZero())return n.ZERO;if(e.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE))return e.isOdd()?n.MIN_VALUE:n.ZERO;if(e.equals(n.MIN_VALUE))return this.isOdd()?n.MIN_VALUE:n.ZERO;if(this.isNegative())return e.isNegative()?this.negate().multiply(e.negate()):this.negate().multiply(e).negate();if(e.isNegative())return this.multiply(e.negate()).negate();if(this.lessThan(n.TWO_PWR_24_)&&e.lessThan(n.TWO_PWR_24_))return n.fromNumber(this.toNumber()*e.toNumber());var t=this.high_>>>16,r=65535&this.high_,o=this.low_>>>16,s=65535&this.low_,i=e.high_>>>16,a=65535&e.high_,c=e.low_>>>16,l=65535&e.low_,u=0,h=0,p=0,f=0;return p+=(f+=s*l)>>>16,f&=65535,h+=(p+=o*l)>>>16,p&=65535,h+=(p+=s*c)>>>16,p&=65535,u+=(h+=r*l)>>>16,h&=65535,u+=(h+=o*c)>>>16,h&=65535,u+=(h+=s*a)>>>16,h&=65535,u+=t*l+r*c+o*a+s*i,u&=65535,n.fromBits(p<<16|f,u<<16|h)},n.prototype.div=function(e){if(e.isZero())throw Error("division by zero");if(this.isZero())return n.ZERO;if(this.equals(n.MIN_VALUE)){if(e.equals(n.ONE)||e.equals(n.NEG_ONE))return n.MIN_VALUE;if(e.equals(n.MIN_VALUE))return n.ONE;var t=this.shiftRight(1).div(e).shiftLeft(1);if(t.equals(n.ZERO))return e.isNegative()?n.ONE:n.NEG_ONE;var r=this.subtract(e.multiply(t));return t.add(r.div(e))}if(e.equals(n.MIN_VALUE))return n.ZERO;if(this.isNegative())return e.isNegative()?this.negate().div(e.negate()):this.negate().div(e).negate();if(e.isNegative())return this.div(e.negate()).negate();var o=n.ZERO;for(r=this;r.greaterThanOrEqual(e);){t=Math.max(1,Math.floor(r.toNumber()/e.toNumber()));for(var s=Math.ceil(Math.log(t)/Math.LN2),i=s<=48?1:Math.pow(2,s-48),a=n.fromNumber(t),c=a.multiply(e);c.isNegative()||c.greaterThan(r);)t-=i,c=(a=n.fromNumber(t)).multiply(e);a.isZero()&&(a=n.ONE),o=o.add(a),r=r.subtract(c)}return o},n.prototype.modulo=function(e){return this.subtract(this.div(e).multiply(e))},n.prototype.not=function(){return n.fromBits(~this.low_,~this.high_)},n.prototype.and=function(e){return n.fromBits(this.low_&e.low_,this.high_&e.high_)},n.prototype.or=function(e){return n.fromBits(this.low_|e.low_,this.high_|e.high_)},n.prototype.xor=function(e){return n.fromBits(this.low_^e.low_,this.high_^e.high_)},n.prototype.shiftLeft=function(e){if(0===(e&=63))return this;var t=this.low_;if(e<32){var r=this.high_;return n.fromBits(t<>>32-e)}return n.fromBits(0,t<>>e|t<<32-e,t>>e)}return n.fromBits(t>>e-32,t>=0?0:-1)},n.prototype.shiftRightUnsigned=function(e){if(0===(e&=63))return this;var t=this.high_;if(e<32){var r=this.low_;return n.fromBits(r>>>e|t<<32-e,t>>>e)}return 32===e?n.fromBits(t,0):n.fromBits(t>>>e-32,0)},n.fromInt=function(e){if(-128<=e&&e<128){var t=n.INT_CACHE_[e];if(t)return t}var r=new n(0|e,e<0?-1:0);return-128<=e&&e<128&&(n.INT_CACHE_[e]=r),r},n.fromNumber=function(e){return isNaN(e)||!isFinite(e)?n.ZERO:e<=-n.TWO_PWR_63_DBL_?n.MIN_VALUE:e+1>=n.TWO_PWR_63_DBL_?n.MAX_VALUE:e<0?n.fromNumber(-e).negate():new n(e%n.TWO_PWR_32_DBL_|0,e/n.TWO_PWR_32_DBL_|0)},n.fromBits=function(e,t){return new n(e,t)},n.fromString=function(e,t){if(0===e.length)throw Error("number format error: empty string");var r=t||10;if(r<2||36=0)throw Error('number format error: interior "-" character: '+e);for(var o=n.fromNumber(Math.pow(r,8)),s=n.ZERO,i=0;i>8&255,r[1]=e>>16&255,r[0]=e>>24&255,r[6]=255&s,r[5]=s>>8&255,r[4]=s>>16&255,r[8]=255&t,r[7]=t>>8&255,r[11]=255&n,r[10]=n>>8&255,r[9]=n>>16&255,r},c.prototype.toString=function(e){return this.id&&this.id.copy?this.id.toString("string"==typeof e?e:"hex"):this.toHexString()},c.prototype[r]=c.prototype.toString,c.prototype.toJSON=function(){return this.toHexString()},c.prototype.equals=function(e){return e instanceof c?this.toString()===e.toString():"string"==typeof e&&c.isValid(e)&&12===e.length&&this.id instanceof p?e===this.id.toString("binary"):"string"==typeof e&&c.isValid(e)&&24===e.length?e.toLowerCase()===this.toHexString():"string"==typeof e&&c.isValid(e)&&12===e.length?e===this.id:!(null==e||!(e instanceof c||e.toHexString))&&e.toHexString()===this.toHexString()},c.prototype.getTimestamp=function(){var e=new Date,t=this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24;return e.setTime(1e3*Math.floor(t)),e},c.index=~~(16777215*Math.random()),c.createPk=function(){return new c},c.createFromTime=function(e){var t=o.toBuffer([0,0,0,0,0,0,0,0,0,0,0,0]);return t[3]=255&e,t[2]=e>>8&255,t[1]=e>>16&255,t[0]=e>>24&255,new c(t)};var h=[];for(u=0;u<10;)h[48+u]=u++;for(;u<16;)h[55+u]=h[87+u]=u++;var p=Buffer,f=function(e){return e.toString("hex")};c.createFromHexString=function(e){if(void 0===e||null!=e&&24!==e.length)throw new Error("Argument passed in must be a single String of 12 bytes or a string of 24 hex characters");if(a)return new c(o.toBuffer(e,"hex"));for(var t=new p(12),n=0,r=0;r<24;)t[n++]=h[e.charCodeAt(r++)]<<4|h[e.charCodeAt(r++)];return new c(t)},c.isValid=function(e){return null!=e&&("number"==typeof e||("string"==typeof e?12===e.length||24===e.length&&i.test(e):e instanceof c||(e instanceof p||"function"==typeof e.toHexString&&(e.id instanceof p||"string"==typeof e.id)&&(12===e.id.length||24===e.id.length&&i.test(e.id)))))},Object.defineProperty(c.prototype,"generationTime",{enumerable:!0,get:function(){return this.id[3]|this.id[2]<<8|this.id[1]<<16|this.id[0]<<24},set:function(e){this.id[3]=255&e,this.id[2]=e>>8&255,this.id[1]=e>>16&255,this.id[0]=e>>24&255}}),e.exports=c,e.exports.ObjectID=c,e.exports.ObjectId=c},function(e,t){function n(e,t){if(!(this instanceof n))return new n;this._bsontype="BSONRegExp",this.pattern=e||"",this.options=t||"";for(var r=0;r=7e3)throw new Error(e+" not a valid Decimal128 string");var M=e.match(o),B=e.match(s),R=e.match(i);if(!M&&!B&&!R||0===e.length)throw new Error(e+" not a valid Decimal128 string");if(M&&M[4]&&void 0===M[2])throw new Error(e+" not a valid Decimal128 string");if("+"!==e[k]&&"-"!==e[k]||(n="-"===e[k++]),!f(e[k])&&"."!==e[k]){if("i"===e[k]||"I"===e[k])return new m(p.toBuffer(n?l:u));if("N"===e[k])return new m(p.toBuffer(c))}for(;f(e[k])||"."===e[k];)if("."!==e[k])_<34&&("0"!==e[k]||y)&&(y||(w=b),y=!0,O[T++]=parseInt(e[k],10),_+=1),y&&(S+=1),d&&(v+=1),b+=1,k+=1;else{if(d)return new m(p.toBuffer(c));d=!0,k+=1}if(d&&!b)throw new Error(e+" not a valid Decimal128 string");if("e"===e[k]||"E"===e[k]){var P=e.substr(++k).match(h);if(!P||!P[2])return new m(p.toBuffer(c));x=parseInt(P[0],10),k+=P[0].length}if(e[k])return new m(p.toBuffer(c));if(E=0,_){if(C=_-1,g=S,0!==x&&1!==g)for(;"0"===e[w+g-1];)g-=1}else E=0,C=0,O[0]=0,S=1,_=1,g=0;for(x<=v&&v-x>16384?x=-6176:x-=v;x>6111;){if((C+=1)-E>34){var D=O.join("");if(D.match(/^0+$/)){x=6111;break}return new m(p.toBuffer(n?l:u))}x-=1}for(;x<-6176||_=5&&(U=1,5===j))for(U=O[C]%2==1,N=w+C+2;N=0&&++O[z]>9;z--)if(O[z]=0,0===z){if(!(x<6111))return new m(p.toBuffer(n?l:u));x+=1,O[z]=1}}if(I=r.fromNumber(0),A=r.fromNumber(0),0===g)I=r.fromNumber(0),A=r.fromNumber(0);else if(C-E<17)for(z=E,A=r.fromNumber(O[z++]),I=new r(0,0);z<=C;z++)A=(A=A.multiply(r.fromNumber(10))).add(r.fromNumber(O[z]));else{for(z=E,I=r.fromNumber(O[z++]);z<=C-17;z++)I=(I=I.multiply(r.fromNumber(10))).add(r.fromNumber(O[z]));for(A=r.fromNumber(O[z++]);z<=C;z++)A=(A=A.multiply(r.fromNumber(10))).add(r.fromNumber(O[z]))}var W,q,F,$,V=function(e,t){if(!e&&!t)return{high:r.fromNumber(0),low:r.fromNumber(0)};var n=e.shiftRightUnsigned(32),o=new r(e.getLowBits(),0),s=t.shiftRightUnsigned(32),i=new r(t.getLowBits(),0),a=n.multiply(s),c=n.multiply(i),l=o.multiply(s),u=o.multiply(i);return a=a.add(c.shiftRightUnsigned(32)),c=new r(c.getLowBits(),0).add(l).add(u.shiftRightUnsigned(32)),{high:a=a.add(c.shiftRightUnsigned(32)),low:u=c.shiftLeft(32).add(new r(u.getLowBits(),0))}}(I,r.fromString("100000000000000000"));V.low=V.low.add(A),W=V.low,q=A,F=W.high_>>>0,$=q.high_>>>0,(F<$||F===$&&W.low_>>>0>>0)&&(V.high=V.high.add(r.fromNumber(1))),t=x+a;var H={low:r.fromNumber(0),high:r.fromNumber(0)};V.high.shiftRightUnsigned(49).and(r.fromNumber(1)).equals(r.fromNumber)?(H.high=H.high.or(r.fromNumber(3).shiftLeft(61)),H.high=H.high.or(r.fromNumber(t).and(r.fromNumber(16383).shiftLeft(47))),H.high=H.high.or(V.high.and(r.fromNumber(0x7fffffffffff)))):(H.high=H.high.or(r.fromNumber(16383&t).shiftLeft(49)),H.high=H.high.or(V.high.and(r.fromNumber(562949953421311)))),H.low=V.low,n&&(H.high=H.high.or(r.fromString("9223372036854775808")));var Y=p.allocBuffer(16);return k=0,Y[k++]=255&H.low.low_,Y[k++]=H.low.low_>>8&255,Y[k++]=H.low.low_>>16&255,Y[k++]=H.low.low_>>24&255,Y[k++]=255&H.low.high_,Y[k++]=H.low.high_>>8&255,Y[k++]=H.low.high_>>16&255,Y[k++]=H.low.high_>>24&255,Y[k++]=255&H.high.low_,Y[k++]=H.high.low_>>8&255,Y[k++]=H.high.low_>>16&255,Y[k++]=H.high.low_>>24&255,Y[k++]=255&H.high.high_,Y[k++]=H.high.high_>>8&255,Y[k++]=H.high.high_>>16&255,Y[k++]=H.high.high_>>24&255,new m(Y)};a=6176,m.prototype.toString=function(){for(var e,t,n,o,s,i,c=0,l=new Array(36),u=0;u>26&31)>>3==3){if(30===s)return v.join("")+"Infinity";if(31===s)return"NaN";i=e>>15&16383,f=8+(e>>14&1)}else f=e>>14&7,i=e>>17&16383;if(h=i-a,S.parts[0]=(16383&e)+((15&f)<<14),S.parts[1]=t,S.parts[2]=n,S.parts[3]=o,0===S.parts[0]&&0===S.parts[1]&&0===S.parts[2]&&0===S.parts[3])b=!0;else for(y=3;y>=0;y--){var O=0,_=d(S);if(S=_.quotient,O=_.rem.low_)for(m=8;m>=0;m--)l[9*y+m]=O%10,O=Math.floor(O/10)}if(b)c=1,l[g]=0;else for(c=36,u=0;!l[g];)u++,c-=1,g+=1;if((p=c-1+h)>=34||p<=-7||h>0){for(v.push(l[g++]),(c-=1)&&v.push("."),u=0;u0?v.push("+"+p):v.push(p)}else if(h>=0)for(u=0;u0)for(u=0;u{if(r)return n(r);Object.assign(t,{nonce:s});const i=t.credentials,a=Object.assign({},e,{speculativeAuthenticate:Object.assign(d(o,i,s),{db:i.source})});n(void 0,a)})}auth(e,t){const n=e.response;n&&n.speculativeAuthenticate?m(this.cryptoMethod,n.speculativeAuthenticate,e,t):function(e,t,n){const r=t.connection,o=t.credentials,s=t.nonce,i=o.source,a=d(e,o,s);r.command(i+".$cmd",a,(r,o)=>{const s=w(r,o);if(s)return n(s);m(e,o.result,t,n)})}(this.cryptoMethod,e,t)}}function p(e){return e.replace("=","=3D").replace(",","=2C")}function f(e,t){return o.concat([o.from("n=","utf8"),o.from(e,"utf8"),o.from(",r=","utf8"),o.from(t.toString("base64"),"utf8")])}function d(e,t,n){const r=p(t.username);return{saslStart:1,mechanism:"sha1"===e?"SCRAM-SHA-1":"SCRAM-SHA-256",payload:new l(o.concat([o.from("n,,","utf8"),f(r,n)])),autoAuthorize:1,options:{skipEmptyExchange:!0}}}function m(e,t,n,s){const a=n.connection,c=n.credentials,h=n.nonce,d=c.source,m=p(c.username),O=c.password;let _;if("sha256"===e)_=u?u(O):O;else try{_=function(e,t){if("string"!=typeof e)throw new i("username must be a string");if("string"!=typeof t)throw new i("password must be a string");if(0===t.length)throw new i("password cannot be empty");const n=r.createHash("md5");return n.update(`${e}:mongo:${t}`,"utf8"),n.digest("hex")}(m,O)}catch(e){return s(e)}const T=o.isBuffer(t.payload)?new l(t.payload):t.payload,E=y(T.value()),C=parseInt(E.i,10);if(C&&C<4096)return void s(new i("Server returned an invalid iteration count "+C),!1);const x=E.s,N=E.r;if(N.startsWith("nonce"))return void s(new i("Server returned an invalid nonce: "+N),!1);const I="c=biws,r="+N,A=function(e,t,n,o){const s=[e,t.toString("base64"),n].join("_");if(void 0!==b[s])return b[s];const i=r.pbkdf2Sync(e,t,n,v[o],o);S>=200&&(b={},S=0);return b[s]=i,S+=1,i}(_,o.from(x,"base64"),C,e),k=g(e,A,"Client Key"),M=g(e,A,"Server Key"),B=(R=e,P=k,r.createHash(R).update(P).digest());var R,P;const D=[f(m,h),T.value().toString("base64"),I].join(","),L=[I,"p="+function(e,t){o.isBuffer(e)||(e=o.from(e));o.isBuffer(t)||(t=o.from(t));const n=Math.max(e.length,t.length),r=[];for(let o=0;o{const n=w(e,t);if(n)return s(n);const c=t.result,l=y(c.payload.value());if(!function(e,t){if(e.length!==t.length)return!1;if("function"==typeof r.timingSafeEqual)return r.timingSafeEqual(e,t);let n=0;for(let r=0;r=9?43===e.code||e.hasErrorLabel("ResumableChangeStreamError"):o.has(e.code))}}},function(e,t,n){"use strict";const r=n(21),o=n(2).MongoError,s=n(4).maxWireVersion,i=n(2).ReadPreference,a=n(1).Aspect,c=n(1).defineAspects;class l extends r{constructor(e,t,n){if(super(e,n,{fullResponse:!0}),this.target=e.s.namespace&&e.s.namespace.collection?e.s.namespace.collection:1,this.pipeline=t,this.hasWriteStage=!1,"string"==typeof n.out)this.pipeline=this.pipeline.concat({$out:n.out}),this.hasWriteStage=!0;else if(t.length>0){const e=t[t.length-1];(e.$out||e.$merge)&&(this.hasWriteStage=!0)}if(this.hasWriteStage&&(this.readPreference=i.primary),this.explain&&this.writeConcern)throw new o('"explain" cannot be used on an aggregate call with writeConcern');if(null!=n.cursor&&"object"!=typeof n.cursor)throw new o("cursor options must be an object")}get canRetryRead(){return!this.hasWriteStage}addToPipeline(e){this.pipeline.push(e)}execute(e,t){const n=this.options,r=s(e),o={aggregate:this.target,pipeline:this.pipeline};this.hasWriteStage&&r<8&&(this.readConcern=null),r>=5&&this.hasWriteStage&&this.writeConcern&&Object.assign(o,{writeConcern:this.writeConcern}),!0===n.bypassDocumentValidation&&(o.bypassDocumentValidation=n.bypassDocumentValidation),"boolean"==typeof n.allowDiskUse&&(o.allowDiskUse=n.allowDiskUse),n.hint&&(o.hint=n.hint),this.explain&&(n.full=!1),o.cursor=n.cursor||{},n.batchSize&&!this.hasWriteStage&&(o.cursor.batchSize=n.batchSize),super.executeCommand(e,o,t)}}c(l,[a.READ_OPERATION,a.RETRYABLE,a.EXECUTE_WITH_SELECTION,a.EXPLAINABLE]),e.exports=l},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(0).applyRetryableWrites,s=n(0).applyWriteConcern,i=n(0).decorateWithCollation,a=n(11).executeCommand,c=n(0).formattedOrderClause,l=n(0).handleCallback,u=n(2).ReadPreference,h=n(4).maxWireVersion,p=n(59).MongoError,f=n(1).Aspect,d=n(1).defineAspects,m=n(0).decorateWithExplain;class y extends r{constructor(e,t,n,r,o){super(o),this.collection=e,this.query=t,this.sort=n,this.doc=r}execute(e){const t=this.collection,n=this.query,r=c(this.sort),f=this.doc;let d=this.options,y={findAndModify:t.collectionName,query:n};r&&(y.sort=r),y.new=!!d.new,y.remove=!!d.remove,y.upsert=!!d.upsert;const g=d.projection||d.fields;g&&(y.fields=g),d.arrayFilters&&(y.arrayFilters=d.arrayFilters),f&&!d.remove&&(y.update=f),d.maxTimeMS&&(y.maxTimeMS=d.maxTimeMS),d.serializeFunctions=d.serializeFunctions||t.s.serializeFunctions,d.checkKeys=!1,d=o(d,t.s.db),d=s(d,{db:t.s.db,collection:t},d),d.writeConcern&&(y.writeConcern=d.writeConcern),!0===d.bypassDocumentValidation&&(y.bypassDocumentValidation=d.bypassDocumentValidation),d.readPreference=u.primary;try{i(y,t,d)}catch(t){return e(t,null)}if(d.hint){if(d.writeConcern&&0===d.writeConcern.w||h(t.s.topology)<8)return void e(new p("The current topology does not support a hint on findAndModify commands"));y.hint=d.hint}if(this.explain){if(h(t.s.topology)<4)return void e(new p("server does not support explain on findAndModify"));y=m(y,this.explain)}a(t.s.db,y,d,(t,n)=>t?l(e,t,null):l(e,null,n))}}d(y,[f.EXPLAINABLE]),e.exports=y},function(e,t,n){"use strict";const r=n(8).EventEmitter,o=n(5).inherits,s=n(0).getSingleProperty,i=n(78),a=n(0).handleCallback,c=n(0).filterOptions,l=n(0).toError,u=n(2).ReadPreference,h=n(2).MongoError,p=n(2).ObjectID,f=n(2).Logger,d=n(42),m=n(0).conditionallyMergeWriteConcern,y=n(0).executeLegacyOperation,g=n(74),b=n(5).deprecate,S=n(0).deprecateOptions,v=n(0).MongoDBNamespace,w=n(75),O=n(22),_=n(32),T=n(77),E=n(11).createListener,C=n(11).ensureIndex,x=n(11).evaluate,N=n(11).profilingInfo,I=n(11).validateDatabaseName,A=n(60),k=n(110),M=n(190),B=n(18),R=n(191),P=n(192),D=n(106),L=n(79).DropCollectionOperation,j=n(79).DropDatabaseOperation,U=n(111),z=n(108),W=n(193),q=n(194),F=n(112),$=n(113),V=n(195),H=n(37),Y=["w","wtimeout","fsync","j","writeConcern","readPreference","readPreferenceTags","native_parser","forceServerObjectId","pkFactory","serializeFunctions","raw","bufferMaxEntries","authSource","ignoreUndefined","promoteLongs","promiseLibrary","readConcern","retryMiliSeconds","numberOfRetries","parentDb","noListener","loggerLevel","logger","promoteBuffers","promoteLongs","promoteValues","compression","retryWrites"];function K(e,t,n){if(n=n||{},!(this instanceof K))return new K(e,t,n);r.call(this);const o=n.promiseLibrary||Promise;(n=c(n,Y)).promiseLibrary=o,this.s={dbCache:{},children:[],topology:t,options:n,logger:f("Db",n),bson:t?t.bson:null,readPreference:u.fromOptions(n),bufferMaxEntries:"number"==typeof n.bufferMaxEntries?n.bufferMaxEntries:-1,parentDb:n.parentDb||null,pkFactory:n.pkFactory||p,nativeParser:n.nativeParser||n.native_parser,promiseLibrary:o,noListener:"boolean"==typeof n.noListener&&n.noListener,readConcern:_.fromOptions(n),writeConcern:O.fromOptions(n),namespace:new v(e)},I(e),s(this,"serverConfig",this.s.topology),s(this,"bufferMaxEntries",this.s.bufferMaxEntries),s(this,"databaseName",this.s.namespace.db),n.parentDb||this.s.noListener||(t.on("error",E(this,"error",this)),t.on("timeout",E(this,"timeout",this)),t.on("close",E(this,"close",this)),t.on("parseError",E(this,"parseError",this)),t.once("open",E(this,"open",this)),t.once("fullsetup",E(this,"fullsetup",this)),t.once("all",E(this,"all",this)),t.on("reconnect",E(this,"reconnect",this)))}o(K,r),K.prototype.on=b((function(){return K.super_.prototype.on.apply(this,arguments)}),"Listening to events on the Db class has been deprecated and will be removed in the next major version."),K.prototype.once=b((function(){return K.super_.prototype.once.apply(this,arguments)}),"Listening to events on the Db class has been deprecated and will be removed in the next major version."),Object.defineProperty(K.prototype,"topology",{enumerable:!0,get:function(){return this.s.topology}}),Object.defineProperty(K.prototype,"options",{enumerable:!0,get:function(){return this.s.options}}),Object.defineProperty(K.prototype,"slaveOk",{enumerable:!0,get:function(){return null!=this.s.options.readPreference&&("primary"!==this.s.options.readPreference||"primary"!==this.s.options.readPreference.mode)}}),Object.defineProperty(K.prototype,"readConcern",{enumerable:!0,get:function(){return this.s.readConcern}}),Object.defineProperty(K.prototype,"readPreference",{enumerable:!0,get:function(){return null==this.s.readPreference?u.primary:this.s.readPreference}}),Object.defineProperty(K.prototype,"writeConcern",{enumerable:!0,get:function(){return this.s.writeConcern}}),Object.defineProperty(K.prototype,"namespace",{enumerable:!0,get:function(){return this.s.namespace.toString()}}),K.prototype.command=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=Object.assign({},t);const r=new R(this,e,t);return H(this.s.topology,r,n)},K.prototype.aggregate=function(e,t,n){"function"==typeof t&&(n=t,t={}),null==t&&null==n&&(t={});const r=new T(this.s.topology,new A(this,e,t),t);if("function"!=typeof n)return r;n(null,r)},K.prototype.admin=function(){return new(n(114))(this,this.s.topology,this.s.promiseLibrary)};const G=["pkFactory","readPreference","serializeFunctions","strict","readConcern","ignoreUndefined","promoteValues","promoteBuffers","promoteLongs"];K.prototype.collection=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=t||{},(t=Object.assign({},t)).promiseLibrary=this.s.promiseLibrary,t.readConcern=t.readConcern?new _(t.readConcern.level):this.readConcern,this.s.options.ignoreUndefined&&(t.ignoreUndefined=this.s.options.ignoreUndefined);for(const e of G)e in t||void 0===this.s.options[e]||(t[e]=this.s.options[e]);if(null==(t=m(t,this.s.options))||!t.strict)try{const r=new d(this,this.s.topology,this.databaseName,e,this.s.pkFactory,t);return n&&n(null,r),r}catch(e){if(e instanceof h&&n)return n(e);throw e}if("function"!=typeof n)throw l("A callback is required in strict mode. While getting collection "+e);if(this.serverConfig&&this.serverConfig.isDestroyed())return n(new h("topology was destroyed"));const r=Object.assign({},t,{nameOnly:!0});this.listCollections({name:e},r).toArray((r,o)=>{if(null!=r)return a(n,r,null);if(0===o.length)return a(n,l(`Collection ${e} does not exist. Currently in strict mode.`),null);try{return a(n,null,new d(this,this.s.topology,this.databaseName,e,this.s.pkFactory,t))}catch(r){return a(n,r,null)}})},K.prototype.createCollection=S({name:"Db.createCollection",deprecatedOptions:["autoIndexId","strict","w","wtimeout","j"],optionsIndex:1},(function(e,t,n){"function"==typeof t&&(n=t,t={}),(t=t||{}).promiseLibrary=t.promiseLibrary||this.s.promiseLibrary,t.readConcern=t.readConcern?new _(t.readConcern.level):this.readConcern;const r=new P(this,e,t);return H(this.s.topology,r,n)})),K.prototype.stats=function(e,t){"function"==typeof e&&(t=e,e={});const n={dbStats:!0};null!=(e=e||{}).scale&&(n.scale=e.scale),null==e.readPreference&&this.s.readPreference&&(e.readPreference=this.s.readPreference);const r=new B(this,e,null,n);return H(this.s.topology,r,t)},K.prototype.listCollections=function(e,t){return e=e||{},t=t||{},new i(this.s.topology,new W(this,e,t),t)},K.prototype.eval=b((function(e,t,n,r){const o=Array.prototype.slice.call(arguments,1);return r="function"==typeof o[o.length-1]?o.pop():void 0,t=o.length?o.shift():t,n=o.length&&o.shift()||{},y(this.s.topology,x,[this,e,t,n,r])}),"Db.eval is deprecated as of MongoDB version 3.2"),K.prototype.renameCollection=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),(n=Object.assign({},n,{readPreference:u.PRIMARY})).new_collection=!0;const o=new $(this.collection(e),t,n);return H(this.s.topology,o,r)},K.prototype.dropCollection=function(e,t,n){"function"==typeof t&&(n=t,t={});const r=new L(this,e,t=t||{});return H(this.s.topology,r,n)},K.prototype.dropDatabase=function(e,t){"function"==typeof e&&(t=e,e={});const n=new j(this,e=e||{});return H(this.s.topology,n,t)},K.prototype.collections=function(e,t){"function"==typeof e&&(t=e,e={});const n=new M(this,e=e||{});return H(this.s.topology,n,t)},K.prototype.executeDbAdminCommand=function(e,t,n){"function"==typeof t&&(n=t,t={}),(t=t||{}).readPreference=u.resolve(this,t);const r=new U(this,e,t);return H(this.s.topology,r,n)},K.prototype.createIndex=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n=n?Object.assign({},n):{};const o=new D(this,e,t,n);return H(this.s.topology,o,r)},K.prototype.ensureIndex=b((function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=n||{},y(this.s.topology,C,[this,e,t,n,r])}),"Db.ensureIndex is deprecated as of MongoDB version 3.0 / driver version 2.0"),K.prototype.addChild=function(e){if(this.s.parentDb)return this.s.parentDb.addChild(e);this.s.children.push(e)},K.prototype.addUser=function(e,t,n,r){"function"==typeof n&&(r=n,n={}),n=n||{},"string"==typeof e&&null!=t&&"object"==typeof t&&(n=t,t=null);const o=new k(this,e,t,n);return H(this.s.topology,o,r)},K.prototype.removeUser=function(e,t,n){"function"==typeof t&&(n=t,t={});const r=new F(this,e,t=t||{});return H(this.s.topology,r,n)},K.prototype.setProfilingLevel=function(e,t,n){"function"==typeof t&&(n=t,t={});const r=new V(this,e,t=t||{});return H(this.s.topology,r,n)},K.prototype.profilingInfo=b((function(e,t){return"function"==typeof e&&(t=e,e={}),e=e||{},y(this.s.topology,N,[this,e,t])}),"Db.profilingInfo is deprecated. Query the system.profile collection directly."),K.prototype.profilingLevel=function(e,t){"function"==typeof e&&(t=e,e={});const n=new q(this,e=e||{});return H(this.s.topology,n,t)},K.prototype.indexInformation=function(e,t,n){"function"==typeof t&&(n=t,t={});const r=new z(this,e,t=t||{});return H(this.s.topology,r,n)},K.prototype.unref=function(){this.s.topology.unref()},K.prototype.watch=function(e,t){return e=e||[],t=t||{},Array.isArray(e)||(t=e,e=[]),new g(this,e,t)},K.prototype.getLogger=function(){return this.s.logger},K.SYSTEM_NAMESPACE_COLLECTION=w.SYSTEM_NAMESPACE_COLLECTION,K.SYSTEM_INDEX_COLLECTION=w.SYSTEM_INDEX_COLLECTION,K.SYSTEM_PROFILE_COLLECTION=w.SYSTEM_PROFILE_COLLECTION,K.SYSTEM_USER_COLLECTION=w.SYSTEM_USER_COLLECTION,K.SYSTEM_COMMAND_COLLECTION=w.SYSTEM_COMMAND_COLLECTION,K.SYSTEM_JS_COLLECTION=w.SYSTEM_JS_COLLECTION,e.exports=K},function(e,t,n){"use strict";const r=n(2).Server,o=n(20),s=n(28).TopologyBase,i=n(28).Store,a=n(2).MongoError,c=n(0).MAX_JS_INT,l=n(0).translateOptions,u=n(0).filterOptions,h=n(0).mergeOptions;var p=["ha","haInterval","acceptableLatencyMS","poolSize","ssl","checkServerIdentity","sslValidate","sslCA","sslCRL","sslCert","ciphers","ecdhCurve","sslKey","sslPass","socketOptions","bufferMaxEntries","store","auto_reconnect","autoReconnect","emitError","keepAlive","keepAliveInitialDelay","noDelay","connectTimeoutMS","socketTimeoutMS","family","loggerLevel","logger","reconnectTries","reconnectInterval","monitoring","appname","domainsEnabled","servername","promoteLongs","promoteValues","promoteBuffers","compression","promiseLibrary","monitorCommands"];class f extends s{constructor(e,t,n){super();const s=(n=u(n,p)).promiseLibrary;var f={force:!1,bufferMaxEntries:"number"==typeof n.bufferMaxEntries?n.bufferMaxEntries:c},d=n.store||new i(this,f);if(-1!==e.indexOf("/"))null!=t&&"object"==typeof t&&(n=t,t=null);else if(null==t)throw a.create({message:"port must be specified",driver:!0});var m="boolean"!=typeof n.auto_reconnect||n.auto_reconnect;m="boolean"==typeof n.autoReconnect?n.autoReconnect:m;var y=h({},{host:e,port:t,disconnectHandler:d,cursorFactory:o,reconnect:m,emitError:"boolean"!=typeof n.emitError||n.emitError,size:"number"==typeof n.poolSize?n.poolSize:5,monitorCommands:"boolean"==typeof n.monitorCommands&&n.monitorCommands});y=l(y,n);var g=n.socketOptions&&Object.keys(n.socketOptions).length>0?n.socketOptions:n;y=l(y,g),this.s={coreTopology:new r(y),sCapabilities:null,clonedOptions:y,reconnect:y.reconnect,emitError:y.emitError,poolSize:y.size,storeOptions:f,store:d,host:e,port:t,options:n,sessionPool:null,sessions:new Set,promiseLibrary:s||Promise}}connect(e,t){var n=this;"function"==typeof e&&(t=e,e={}),null==e&&(e=this.s.clonedOptions),"function"!=typeof t&&(t=null),e=Object.assign({},this.s.clonedOptions,e),n.s.options=e,n.s.storeOptions.bufferMaxEntries="number"==typeof e.bufferMaxEntries?e.bufferMaxEntries:-1;var r=function(){return function(e){["timeout","error","close"].forEach((function(e){n.s.coreTopology.removeListener(e,a[e])})),n.s.coreTopology.removeListener("connect",r);try{t(e)}catch(e){process.nextTick((function(){throw e}))}}},o=function(e){return function(t){"error"!==e&&n.emit(e,t)}},s=function(){n.s.store.flush()},i=function(e){return function(t,r){n.emit(e,t,r)}},a={timeout:r("timeout"),error:r("error"),close:r("close")};["timeout","error","close","serverOpening","serverDescriptionChanged","serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","serverClosed","topologyOpening","topologyClosed","topologyDescriptionChanged","commandStarted","commandSucceeded","commandFailed"].forEach((function(e){n.s.coreTopology.removeAllListeners(e)})),n.s.coreTopology.once("timeout",a.timeout),n.s.coreTopology.once("error",a.error),n.s.coreTopology.once("close",a.close),n.s.coreTopology.once("connect",(function(){["timeout","error","close","destroy"].forEach((function(e){n.s.coreTopology.removeAllListeners(e)})),n.s.coreTopology.on("timeout",o("timeout")),n.s.coreTopology.once("error",o("error")),n.s.coreTopology.on("close",o("close")),n.s.coreTopology.on("destroy",s),n.emit("open",null,n);try{t(null,n)}catch(e){process.nextTick((function(){throw e}))}})),n.s.coreTopology.on("reconnect",(function(){n.emit("reconnect",n),n.s.store.execute()})),n.s.coreTopology.on("reconnectFailed",(function(e){n.emit("reconnectFailed",e),n.s.store.flush(e)})),n.s.coreTopology.on("serverDescriptionChanged",i("serverDescriptionChanged")),n.s.coreTopology.on("serverHeartbeatStarted",i("serverHeartbeatStarted")),n.s.coreTopology.on("serverHeartbeatSucceeded",i("serverHeartbeatSucceeded")),n.s.coreTopology.on("serverHeartbeatFailed",i("serverHeartbeatFailed")),n.s.coreTopology.on("serverOpening",i("serverOpening")),n.s.coreTopology.on("serverClosed",i("serverClosed")),n.s.coreTopology.on("topologyOpening",i("topologyOpening")),n.s.coreTopology.on("topologyClosed",i("topologyClosed")),n.s.coreTopology.on("topologyDescriptionChanged",i("topologyDescriptionChanged")),n.s.coreTopology.on("commandStarted",i("commandStarted")),n.s.coreTopology.on("commandSucceeded",i("commandSucceeded")),n.s.coreTopology.on("commandFailed",i("commandFailed")),n.s.coreTopology.on("attemptReconnect",i("attemptReconnect")),n.s.coreTopology.on("monitoring",i("monitoring")),n.s.coreTopology.connect(e)}}Object.defineProperty(f.prototype,"poolSize",{enumerable:!0,get:function(){return this.s.coreTopology.connections().length}}),Object.defineProperty(f.prototype,"autoReconnect",{enumerable:!0,get:function(){return this.s.reconnect}}),Object.defineProperty(f.prototype,"host",{enumerable:!0,get:function(){return this.s.host}}),Object.defineProperty(f.prototype,"port",{enumerable:!0,get:function(){return this.s.port}}),e.exports=f},function(e,t,n){"use strict";if(void 0!==global.Map)e.exports=global.Map,e.exports.Map=global.Map;else{var r=function(e){this._keys=[],this._values={};for(var t=0;to(e,!1,t,n),i=(e,t,n)=>o(e,!0,t,n);function a(e){const t=(t,n)=>s(e,t,n);return t.resolve=(t,n)=>i(e,t,n),t}a.try=s,a.tryResolve=i,a.resolve=i,a.log=(e,t)=>console.log(`Just FYI: ${e}; Path "${t}"`),e.exports=a},function(e,t,n){"use strict";var r=function(e,t,n){this.result=e,this.connection=t,this.message=n};r.prototype.toJSON=function(){let e=Object.assign({},this,this.result);return delete e.message,e},r.prototype.toString=function(){return JSON.stringify(this.toJSON())},e.exports=r},function(e,t,n){"use strict";var r=n(5).inherits,o=n(5).format,s=n(8).EventEmitter,i=n(10),a=n(14),c=n(9).debugOptions,l=n(9).retrieveBSON,u=n(131),h=n(3).MongoError,p=n(3).MongoNetworkError,f=n(95),d=n(15).CoreCursor,m=n(7),y=n(7).createCompressionInfo,g=n(7).resolveClusterTime,b=n(7).SessionMixins,S=n(4).relayEvents;const v=n(4).collationNotSupported,w=n(4).makeClientMetadata;var O=["reconnect","reconnectTries","reconnectInterval","emitError","cursorFactory","host","port","size","keepAlive","keepAliveInitialDelay","noDelay","connectionTimeout","checkServerIdentity","socketTimeout","ssl","ca","crl","cert","key","rejectUnauthorized","promoteLongs","promoteValues","promoteBuffers","servername"],_=0,T=!1,E={},C=l();function x(e){return null==e.s.parent?e.id:e.s.parent.id}var N=function(e){e=e||{},s.call(this),this.id=_++,this.s={options:Object.assign({metadata:w(e)},e),logger:a("Server",e),Cursor:e.cursorFactory||d,bson:e.bson||new C([C.Binary,C.Code,C.DBRef,C.Decimal128,C.Double,C.Int32,C.Long,C.Map,C.MaxKey,C.MinKey,C.ObjectId,C.BSONRegExp,C.Symbol,C.Timestamp]),pool:null,disconnectHandler:e.disconnectHandler,monitoring:"boolean"!=typeof e.monitoring||e.monitoring,inTopology:!!e.parent,monitoringInterval:"number"==typeof e.monitoringInterval?e.monitoringInterval:5e3,compression:{compressors:y(e)},parent:e.parent},this.s.parent||(this.s.clusterTime=null),this.ismaster=null,this.lastIsMasterMS=-1,this.monitoringProcessId=null,this.initialConnect=!0,this._type="server",this.lastUpdateTime=0,this.lastWriteDate=0,this.staleness=0};function I(e,t,n,r,s,i){return e.s.pool.isConnected()||!e.s.options.reconnect||null==e.s.disconnectHandler||s.monitoring?e.s.pool.isConnected()?void 0:(i(new h(o("no connection available to server %s",e.name))),!0):(e.s.disconnectHandler.add(t,n,r,s,i),!0)}r(N,s),Object.assign(N.prototype,b),Object.defineProperty(N.prototype,"type",{enumerable:!0,get:function(){return this._type}}),Object.defineProperty(N.prototype,"parserType",{enumerable:!0,get:function(){return C.native?"c++":"js"}}),Object.defineProperty(N.prototype,"logicalSessionTimeoutMinutes",{enumerable:!0,get:function(){return this.ismaster&&this.ismaster.logicalSessionTimeoutMinutes||null}}),Object.defineProperty(N.prototype,"clientMetadata",{enumerable:!0,get:function(){return this.s.options.metadata}}),Object.defineProperty(N.prototype,"clusterTime",{enumerable:!0,set:function(e){const t=this.s.parent?this.s.parent:this.s;g(t,e)},get:function(){return(this.s.parent?this.s.parent:this.s).clusterTime||null}}),N.enableServerAccounting=function(){T=!0,E={}},N.disableServerAccounting=function(){T=!1},N.servers=function(){return E},Object.defineProperty(N.prototype,"name",{enumerable:!0,get:function(){return this.s.options.host+":"+this.s.options.port}});var A=function(e,t){return function(n,r){if(e.s.logger.isInfo()){var s=n instanceof h?JSON.stringify(n):{};e.s.logger.info(o("server %s fired event %s out with message %s",e.name,t,s))}if("connect"===t){if(e.initialConnect=!1,e.ismaster=r.ismaster,e.lastIsMasterMS=r.lastIsMasterMS,r.agreedCompressor&&(e.s.pool.options.agreedCompressor=r.agreedCompressor),r.zlibCompressionLevel&&(e.s.pool.options.zlibCompressionLevel=r.zlibCompressionLevel),r.ismaster.$clusterTime){const t=r.ismaster.$clusterTime;e.clusterTime=t}"isdbgrid"===e.ismaster.msg&&(e._type="mongos"),e.s.monitoring&&(e.monitoringProcessId=setTimeout(function e(t){return function(){if(!t.s.pool.isDestroyed()){t.emit("monitoring",t);var n=(new Date).getTime();t.command("admin.$cmd",{ismaster:!0},{socketTimeout:"number"!=typeof t.s.options.connectionTimeout?2e3:t.s.options.connectionTimeout,monitoring:!0},(r,o)=>{t.lastIsMasterMS=(new Date).getTime()-n,t.s.pool.isDestroyed()||(o&&(t.ismaster=o.result),t.monitoringProcessId=setTimeout(e(t),t.s.monitoringInterval))})}}}(e),e.s.monitoringInterval)),m.emitServerDescriptionChanged(e,{address:e.name,arbiters:[],hosts:[],passives:[],type:m.getTopologyType(e)}),e.s.inTopology||m.emitTopologyDescriptionChanged(e,{topologyType:"Single",servers:[{address:e.name,arbiters:[],hosts:[],passives:[],type:m.getTopologyType(e)}]}),e.s.logger.isInfo()&&e.s.logger.info(o("server %s connected with ismaster [%s]",e.name,JSON.stringify(e.ismaster))),e.emit("connect",e)}else if("error"===t||"parseError"===t||"close"===t||"timeout"===t||"reconnect"===t||"attemptReconnect"===t||"reconnectFailed"===t){if(T&&-1!==["close","timeout","error","parseError","reconnectFailed"].indexOf(t)&&(e.s.inTopology||e.emit("topologyOpening",{topologyId:e.id}),delete E[e.id]),"close"===t&&m.emitServerDescriptionChanged(e,{address:e.name,arbiters:[],hosts:[],passives:[],type:"Unknown"}),"reconnectFailed"===t)return e.emit("reconnectFailed",n),void(e.listeners("error").length>0&&e.emit("error",n));if(-1!==["disconnected","connecting"].indexOf(e.s.pool.state)&&e.initialConnect&&-1!==["close","timeout","error","parseError"].indexOf(t))return e.initialConnect=!1,e.emit("error",new p(o("failed to connect to server [%s] on first connect [%s]",e.name,n)));if("reconnect"===t)return m.emitServerDescriptionChanged(e,{address:e.name,arbiters:[],hosts:[],passives:[],type:m.getTopologyType(e)}),e.emit(t,e);e.emit(t,n)}}};function k(e){return e.s.pool?e.s.pool.isDestroyed()?new h("server instance pool was destroyed"):void 0:new h("server instance is not connected")}N.prototype.connect=function(e){if(e=e||{},T&&(E[this.id]=this),this.s.pool&&!this.s.pool.isDisconnected()&&!this.s.pool.isDestroyed())throw new h(o("server instance in invalid state %s",this.s.pool.state));this.s.pool=new u(this,Object.assign(this.s.options,e,{bson:this.s.bson})),this.s.pool.on("close",A(this,"close")),this.s.pool.on("error",A(this,"error")),this.s.pool.on("timeout",A(this,"timeout")),this.s.pool.on("parseError",A(this,"parseError")),this.s.pool.on("connect",A(this,"connect")),this.s.pool.on("reconnect",A(this,"reconnect")),this.s.pool.on("reconnectFailed",A(this,"reconnectFailed")),S(this.s.pool,this,["commandStarted","commandSucceeded","commandFailed"]),this.s.inTopology||this.emit("topologyOpening",{topologyId:x(this)}),this.emit("serverOpening",{topologyId:x(this),address:this.name}),this.s.pool.connect()},N.prototype.auth=function(e,t){"function"==typeof t&&t(null,null)},N.prototype.getDescription=function(){var e=this.ismaster||{},t={type:m.getTopologyType(this),address:this.name};return e.hosts&&(t.hosts=e.hosts),e.arbiters&&(t.arbiters=e.arbiters),e.passives&&(t.passives=e.passives),e.setName&&(t.setName=e.setName),t},N.prototype.lastIsMaster=function(){return this.ismaster},N.prototype.unref=function(){this.s.pool.unref()},N.prototype.isConnected=function(){return!!this.s.pool&&this.s.pool.isConnected()},N.prototype.isDestroyed=function(){return!!this.s.pool&&this.s.pool.isDestroyed()},N.prototype.command=function(e,t,n,r){"function"==typeof n&&(r=n,n=(n={})||{});var s=function(e,t){if(k(e),t.readPreference&&!(t.readPreference instanceof i))throw new Error("readPreference must be an instance of ReadPreference")}(this,n);return s?r(s):(n=Object.assign({},n,{wireProtocolCommand:!1}),this.s.logger.isDebug()&&this.s.logger.debug(o("executing command [%s] against %s",JSON.stringify({ns:e,cmd:t,options:c(O,n)}),this.name)),I(this,"command",e,t,n,r)?void 0:v(this,t)?r(new h(`server ${this.name} does not support collation`)):void f.command(this,e,t,n,r))},N.prototype.query=function(e,t,n,r,o){f.query(this,e,t,n,r,o)},N.prototype.getMore=function(e,t,n,r,o){f.getMore(this,e,t,n,r,o)},N.prototype.killCursors=function(e,t,n){f.killCursors(this,e,t,n)},N.prototype.insert=function(e,t,n,r){"function"==typeof n&&(r=n,n=(n={})||{});var o=k(this);return o?r(o):I(this,"insert",e,t,n,r)?void 0:(t=Array.isArray(t)?t:[t],f.insert(this,e,t,n,r))},N.prototype.update=function(e,t,n,r){"function"==typeof n&&(r=n,n=(n={})||{});var o=k(this);return o?r(o):I(this,"update",e,t,n,r)?void 0:v(this,n)?r(new h(`server ${this.name} does not support collation`)):(t=Array.isArray(t)?t:[t],f.update(this,e,t,n,r))},N.prototype.remove=function(e,t,n,r){"function"==typeof n&&(r=n,n=(n={})||{});var o=k(this);return o?r(o):I(this,"remove",e,t,n,r)?void 0:v(this,n)?r(new h(`server ${this.name} does not support collation`)):(t=Array.isArray(t)?t:[t],f.remove(this,e,t,n,r))},N.prototype.cursor=function(e,t,n){const r=(n=n||{}).topology||this;return new(n.cursorFactory||this.s.Cursor)(r,e,t,n)},N.prototype.equals=function(e){return"string"==typeof e?this.name.toLowerCase()===e.toLowerCase():!!e.name&&this.name.toLowerCase()===e.name.toLowerCase()},N.prototype.connections=function(){return this.s.pool.allConnections()},N.prototype.selectServer=function(e,t,n){"function"==typeof e&&void 0===n&&(n=e,e=void 0,t={}),"function"==typeof t&&(n=t,t=e,e=void 0),n(null,this)};var M=["close","error","timeout","parseError","connect"];N.prototype.destroy=function(e,t){if(this._destroyed)"function"==typeof t&&t(null,null);else{"function"==typeof e&&(t=e,e={}),e=e||{};var n=this;if(T&&delete E[this.id],this.monitoringProcessId&&clearTimeout(this.monitoringProcessId),!n.s.pool||this._destroyed)return this._destroyed=!0,void("function"==typeof t&&t(null,null));this._destroyed=!0,e.emitClose&&n.emit("close",n),e.emitDestroy&&n.emit("destroy",n),M.forEach((function(e){n.s.pool.removeAllListeners(e)})),n.listeners("serverClosed").length>0&&n.emit("serverClosed",{topologyId:x(n),address:n.name}),n.listeners("topologyClosed").length>0&&!n.s.inTopology&&n.emit("topologyClosed",{topologyId:x(n)}),n.s.logger.isDebug()&&n.s.logger.debug(o("destroy called on server %s",n.name)),this.s.pool.destroy(e.force,t)}},e.exports=N},function(e,t,n){"use strict";const r=n(132),o=n(133),s=n(84),i=n(3).MongoError,a=n(3).MongoNetworkError,c=n(3).MongoNetworkTimeoutError,l=n(89).defaultAuthProviders,u=n(26).AuthContext,h=n(87),p=n(4).makeClientMetadata,f=h.MAX_SUPPORTED_WIRE_VERSION,d=h.MAX_SUPPORTED_SERVER_VERSION,m=h.MIN_SUPPORTED_WIRE_VERSION,y=h.MIN_SUPPORTED_SERVER_VERSION;let g;const b=["pfx","key","passphrase","cert","ca","ciphers","NPNProtocols","ALPNProtocols","servername","ecdhCurve","secureProtocol","secureContext","session","minDHSize","crl","rejectUnauthorized"];function S(e,t){const n="string"==typeof t.host?t.host:"localhost";if(-1!==n.indexOf("/"))return{path:n};return{family:e,host:n,port:"number"==typeof t.port?t.port:27017,rejectUnauthorized:!1}}const v=new Set(["error","close","timeout","parseError"]);e.exports=function(e,t,n){"function"==typeof t&&(n=t,t=void 0);const h=e&&e.connectionType?e.connectionType:s;null==g&&(g=l(e.bson)),function(e,t,n,s){const i="boolean"==typeof t.ssl&&t.ssl,l="boolean"!=typeof t.keepAlive||t.keepAlive;let u="number"==typeof t.keepAliveInitialDelay?t.keepAliveInitialDelay:12e4;const h="boolean"!=typeof t.noDelay||t.noDelay,p="number"==typeof t.connectionTimeout?t.connectionTimeout:"number"==typeof t.connectTimeoutMS?t.connectTimeoutMS:3e4,f="number"==typeof t.socketTimeout?t.socketTimeout:0,d="boolean"!=typeof t.rejectUnauthorized||t.rejectUnauthorized;u>f&&(u=Math.round(f/2));let m;const y=function(e,t){e&&m&&m.destroy(),s(e,t)};try{i?(m=o.connect(function(e,t){const n=S(e,t);for(const e in t)null!=t[e]&&-1!==b.indexOf(e)&&(n[e]=t[e]);!1===t.checkServerIdentity?n.checkServerIdentity=function(){}:"function"==typeof t.checkServerIdentity&&(n.checkServerIdentity=t.checkServerIdentity);null!=n.servername||r.isIP(n.host)||(n.servername=n.host);return n}(e,t)),"function"==typeof m.disableRenegotiation&&m.disableRenegotiation()):m=r.createConnection(S(e,t))}catch(e){return y(e)}m.setKeepAlive(l,u),m.setTimeout(p),m.setNoDelay(h);const g=i?"secureConnect":"connect";let w;function O(e){return t=>{v.forEach(e=>m.removeAllListeners(e)),w&&n.removeListener("cancel",w),m.removeListener(g,_),y(function(e,t){switch(e){case"error":return new a(t);case"timeout":return new c("connection timed out");case"close":return new a("connection closed");case"cancel":return new a("connection establishment was cancelled");default:return new a("unknown network error")}}(e,t))}}function _(){if(v.forEach(e=>m.removeAllListeners(e)),w&&n.removeListener("cancel",w),m.authorizationError&&d)return y(m.authorizationError);m.setTimeout(f),y(null,m)}v.forEach(e=>m.once(e,O(e))),n&&(w=O("cancel"),n.once("cancel",w));m.once(g,_)}(void 0!==e.family?e.family:0,e,t,(t,r)=>{t?n(t,r):function(e,t,n){const r=function(t,r){t&&e&&e.destroy(),n(t,r)},o=t.credentials;if(o&&!o.mechanism.match(/DEFAULT/i)&&!g[o.mechanism])return void r(new i(`authMechanism '${o.mechanism}' not supported`));const a=new u(e,o,t);!function(e,t){const n=e.options,r=n.compression&&n.compression.compressors?n.compression.compressors:[],o={ismaster:!0,client:n.metadata||p(n),compression:r},s=e.credentials;if(s){if(s.mechanism.match(/DEFAULT/i)&&s.username)return Object.assign(o,{saslSupportedMechs:`${s.source}.${s.username}`}),void g["scram-sha-256"].prepare(o,e,t);return void g[s.mechanism].prepare(o,e,t)}t(void 0,o)}(a,(n,c)=>{if(n)return r(n);const l=Object.assign({},t);(t.connectTimeoutMS||t.connectionTimeout)&&(l.socketTimeout=t.connectTimeoutMS||t.connectionTimeout);const u=(new Date).getTime();e.command("admin.$cmd",c,l,(n,l)=>{if(n)return void r(n);const h=l.result;if(0===h.ok)return void r(new i(h));const p=function(e,t){const n=e&&"number"==typeof e.maxWireVersion&&e.maxWireVersion>=m,r=e&&"number"==typeof e.minWireVersion&&e.minWireVersion<=f;if(n){if(r)return null;const n=`Server at ${t.host}:${t.port} reports minimum wire version ${e.minWireVersion}, but this version of the Node.js Driver requires at most ${f} (MongoDB ${d})`;return new i(n)}const o=`Server at ${t.host}:${t.port} reports maximum wire version ${e.maxWireVersion||0}, but this version of the Node.js Driver requires at least ${m} (MongoDB ${y})`;return new i(o)}(h,t);if(p)r(p);else{if(!function(e){return!(e instanceof s)}(e)&&h.compression){const n=c.compression.filter(e=>-1!==h.compression.indexOf(e));n.length&&(e.agreedCompressor=n[0]),t.compression&&t.compression.zlibCompressionLevel&&(e.zlibCompressionLevel=t.compression.zlibCompressionLevel)}if(e.ismaster=h,e.lastIsMasterMS=(new Date).getTime()-u,h.arbiterOnly||!o)r(void 0,e);else{Object.assign(a,{response:h});const t=o.resolveAuthMechanism(h);g[t.mechanism].auth(a,t=>{if(t)return r(t);r(void 0,e)})}}})})}(new h(r,e),e,n)})}},function(e,t){e.exports=require("fs")},function(e,t){e.exports=require("url")},function(e,t,n){"use strict";function r(e,t){t=t||{};this._head=0,this._tail=0,this._capacity=t.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(e)&&this._fromArray(e)}r.prototype.peekAt=function(e){var t=e;if(t===(0|t)){var n=this.size();if(!(t>=n||t<-n))return t<0&&(t+=n),t=this._head+t&this._capacityMask,this._list[t]}},r.prototype.get=function(e){return this.peekAt(e)},r.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]},r.prototype.peekFront=function(){return this.peek()},r.prototype.peekBack=function(){return this.peekAt(-1)},Object.defineProperty(r.prototype,"length",{get:function(){return this.size()}}),r.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),t}},r.prototype.push=function(e){if(void 0===e)return this.size();var t=this._tail;return this._list[t]=e,this._tail=t+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&e<=t>>>2&&this._shrinkArray(),n}},r.prototype.removeOne=function(e){var t=e;if(t===(0|t)&&this._head!==this._tail){var n=this.size(),r=this._list.length;if(!(t>=n||t<-n)){t<0&&(t+=n),t=this._head+t&this._capacityMask;var o,s=this._list[t];if(e0;o--)this._list[t]=this._list[t=t-1+r&this._capacityMask];this._list[t]=void 0,this._head=this._head+1+r&this._capacityMask}else{for(o=n-1-e;o>0;o--)this._list[t]=this._list[t=t+1+r&this._capacityMask];this._list[t]=void 0,this._tail=this._tail-1+r&this._capacityMask}return s}}},r.prototype.remove=function(e,t){var n,r=e,o=t;if(r===(0|r)&&this._head!==this._tail){var s=this.size(),i=this._list.length;if(!(r>=s||r<-s||t<1)){if(r<0&&(r+=s),1===t||!t)return(n=new Array(1))[0]=this.removeOne(r),n;if(0===r&&r+t>=s)return n=this.toArray(),this.clear(),n;var a;for(r+t>s&&(t=s-r),n=new Array(t),a=0;a0;a--)this._list[r=r+1+i&this._capacityMask]=void 0;return n}if(0===e){for(this._head=this._head+t+i&this._capacityMask,a=t-1;a>0;a--)this._list[r=r+1+i&this._capacityMask]=void 0;return n}if(r0;a--)this.unshift(this._list[r=r-1+i&this._capacityMask]);for(r=this._head-1+i&this._capacityMask;o>0;)this._list[r=r-1+i&this._capacityMask]=void 0,o--;e<0&&(this._tail=r)}else{for(this._tail=r,r=r+t+i&this._capacityMask,a=s-(t+e);a>0;a--)this.push(this._list[r++]);for(r=this._tail;o>0;)this._list[r=r+1+i&this._capacityMask]=void 0,o--}return this._head<2&&this._tail>1e4&&this._tail<=i>>>2&&this._shrinkArray(),n}}},r.prototype.splice=function(e,t){var n=e;if(n===(0|n)){var r=this.size();if(n<0&&(n+=r),!(n>r)){if(arguments.length>2){var o,s,i,a=arguments.length,c=this._list.length,l=2;if(!r||n0&&(this._head=this._head+n+c&this._capacityMask)):(i=this.remove(n,t),this._head=this._head+n+c&this._capacityMask);a>l;)this.unshift(arguments[--a]);for(o=n;o>0;o--)this.unshift(s[o-1])}else{var u=(s=new Array(r-(n+t))).length;for(o=0;othis._tail){for(t=this._head;t>>=1,this._capacityMask>>>=1},e.exports=r},function(e,t,n){var r=n(53),o=r.Buffer;function s(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=i),s(o,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";const r=n(72),o=n(8),s=n(59).isResumableError,i=n(2).MongoError,a=n(20),c=n(4).relayEvents,l=n(4).maxWireVersion,u=n(0).maybePromise,h=n(0).now,p=n(0).calculateDurationInMs,f=n(60),d=Symbol("resumeQueue"),m=["resumeAfter","startAfter","startAtOperationTime","fullDocument"],y=["batchSize","maxAwaitTimeMS","collation","readPreference"].concat(m),g={COLLECTION:Symbol("Collection"),DATABASE:Symbol("Database"),CLUSTER:Symbol("Cluster")};class b extends a{constructor(e,t,n){super(e,t,n),n=n||{},this._resumeToken=null,this.startAtOperationTime=n.startAtOperationTime,n.startAfter?this.resumeToken=n.startAfter:n.resumeAfter&&(this.resumeToken=n.resumeAfter)}set resumeToken(e){this._resumeToken=e,this.emit("resumeTokenChanged",e)}get resumeToken(){return this._resumeToken}get resumeOptions(){const e={};for(const t of y)this.options[t]&&(e[t]=this.options[t]);if(this.resumeToken||this.startAtOperationTime)if(["resumeAfter","startAfter","startAtOperationTime"].forEach(t=>delete e[t]),this.resumeToken){const t=this.options.startAfter&&!this.hasReceived?"startAfter":"resumeAfter";e[t]=this.resumeToken}else this.startAtOperationTime&&l(this.server)>=7&&(e.startAtOperationTime=this.startAtOperationTime);return e}cacheResumeToken(e){0===this.bufferedCount()&&this.cursorState.postBatchResumeToken?this.resumeToken=this.cursorState.postBatchResumeToken:this.resumeToken=e,this.hasReceived=!0}_processBatch(e,t){const n=t.cursor;n.postBatchResumeToken&&(this.cursorState.postBatchResumeToken=n.postBatchResumeToken,0===n[e].length&&(this.resumeToken=n.postBatchResumeToken))}_initializeCursor(e){super._initializeCursor((t,n)=>{if(t||null==n)return void e(t,n);const r=n.documents[0];null==this.startAtOperationTime&&null==this.resumeAfter&&null==this.startAfter&&l(this.server)>=7&&(this.startAtOperationTime=r.operationTime),this._processBatch("firstBatch",r),this.emit("init",n),this.emit("response"),e(t,n)})}_getMore(e){super._getMore((t,n)=>{t?e(t):(this._processBatch("nextBatch",n),this.emit("more",n),this.emit("response"),e(t,n))})}}function S(e,t){const n={fullDocument:t.fullDocument||"default"};v(n,t,m),e.type===g.CLUSTER&&(n.allChangesForCluster=!0);const r=[{$changeStream:n}].concat(e.pipeline),o=v({},t,y),s=new b(e.topology,new f(e.parent,r,t),o);if(c(s,e,["resumeTokenChanged","end","close"]),e.listenerCount("change")>0&&s.on("data",(function(t){w(e,t)})),s.on("error",(function(t){O(e,t)})),e.pipeDestinations){const t=s.stream(e.streamOptions);for(let n of e.pipeDestinations)t.pipe(n)}return s}function v(e,t,n){return n.forEach(n=>{t[n]&&(e[n]=t[n])}),e}function w(e,t,n){const r=e.cursor;if(null==t&&(e.closed=!0),!e.closed){if(t&&!t._id){const t=new Error("A change stream document has been received that lacks a resume token (_id).");return n?n(t):e.emit("error",t)}return r.cacheResumeToken(t._id),e.options.startAtOperationTime=void 0,n?n(void 0,t):e.emit("change",t)}n&&n(new i("ChangeStream is closed"))}function O(e,t,n){const r=e.topology,o=e.cursor;if(!e.closed)return o&&s(t,l(o.server))?(e.cursor=void 0,["data","close","end","error"].forEach(e=>o.removeAllListeners(e)),o.close(),void function e(t,n,r){setTimeout(()=>{n&&null==n.start&&(n.start=h());const o=n.start||h(),s=n.timeout||3e4,a=n.readPreference;return t.isConnected({readPreference:a})?r():p(o)>s?r(new i("Timed out waiting for connection")):void e(t,n,r)},500)}(r,{readPreference:o.options.readPreference},t=>{if(t)return c(t);const r=S(e,o.resumeOptions);if(!n)return a(r);r.hasNext(e=>{if(e)return c(e);a(r)})})):n?n(t):e.emit("error",t);function a(t){e.cursor=t,T(e)}function c(t){n||(e.emit("error",t),e.emit("close")),T(e,t),e.closed=!0}n&&n(new i("ChangeStream is closed"))}function _(e,t){e.isClosed()?t(new i("ChangeStream is closed.")):e.cursor?t(void 0,e.cursor):e[d].push(t)}function T(e,t){for(;e[d].length;){const n=e[d].pop();if(e.isClosed()&&!t)return void n(new i("Change Stream is not open."));n(t,e.cursor)}}e.exports=class extends o{constructor(e,t,o){super();const s=n(42),i=n(62),a=n(40);if(this.pipeline=t||[],this.options=o||{},this.parent=e,this.namespace=e.s.namespace,e instanceof s)this.type=g.COLLECTION,this.topology=e.s.db.serverConfig;else if(e instanceof i)this.type=g.DATABASE,this.topology=e.serverConfig;else{if(!(e instanceof a))throw new TypeError("parent provided to ChangeStream constructor is not an instance of Collection, Db, or MongoClient");this.type=g.CLUSTER,this.topology=e.topology}this.promiseLibrary=e.s.promiseLibrary,!this.options.readPreference&&e.s.readPreference&&(this.options.readPreference=e.s.readPreference),this[d]=new r,this.cursor=S(this,o),this.closed=!1,this.on("newListener",e=>{"change"===e&&this.cursor&&0===this.listenerCount("change")&&this.cursor.on("data",e=>w(this,e))}),this.on("removeListener",e=>{"change"===e&&0===this.listenerCount("change")&&this.cursor&&this.cursor.removeAllListeners("data")})}get resumeToken(){return this.cursor.resumeToken}hasNext(e){return u(this.parent,e,e=>{_(this,(t,n)=>{if(t)return e(t);n.hasNext(e)})})}next(e){return u(this.parent,e,e=>{_(this,(t,n)=>{if(t)return e(t);n.next((t,n)=>{if(t)return this[d].push(()=>this.next(e)),void O(this,t,e);w(this,n,e)})})})}isClosed(){return this.closed||this.cursor&&this.cursor.isClosed()}close(e){return u(this.parent,e,e=>{if(this.closed)return e();if(this.closed=!0,!this.cursor)return e();const t=this.cursor;return t.close(n=>(["data","close","end","error"].forEach(e=>t.removeAllListeners(e)),this.cursor=void 0,e(n)))})}pipe(e,t){return this.pipeDestinations||(this.pipeDestinations=[]),this.pipeDestinations.push(e),this.cursor.pipe(e,t)}unpipe(e){return this.pipeDestinations&&this.pipeDestinations.indexOf(e)>-1&&this.pipeDestinations.splice(this.pipeDestinations.indexOf(e),1),this.cursor.unpipe(e)}stream(e){return this.streamOptions=e,this.cursor.stream(e)}pause(){return this.cursor.pause()}resume(){return this.cursor.resume()}}},function(e,t,n){"use strict";e.exports={SYSTEM_NAMESPACE_COLLECTION:"system.namespaces",SYSTEM_INDEX_COLLECTION:"system.indexes",SYSTEM_PROFILE_COLLECTION:"system.profile",SYSTEM_USER_COLLECTION:"system.users",SYSTEM_COMMAND_COLLECTION:"$cmd",SYSTEM_JS_COLLECTION:"system.js"}},function(e,t,n){"use strict";const r=n(2).BSON.Long,o=n(2).MongoError,s=n(2).BSON.ObjectID,i=n(2).BSON,a=n(2).MongoWriteConcernError,c=n(0).toError,l=n(0).handleCallback,u=n(0).applyRetryableWrites,h=n(0).applyWriteConcern,p=n(0).executeLegacyOperation,f=n(0).isPromiseLike,d=n(0).hasAtomicOperators,m=n(4).maxWireVersion,y=new i([i.Binary,i.Code,i.DBRef,i.Decimal128,i.Double,i.Int32,i.Long,i.Map,i.MaxKey,i.MinKey,i.ObjectId,i.BSONRegExp,i.Symbol,i.Timestamp]);class g{constructor(e){this.result=e}get ok(){return this.result.ok}get nInserted(){return this.result.nInserted}get nUpserted(){return this.result.nUpserted}get nMatched(){return this.result.nMatched}get nModified(){return this.result.nModified}get nRemoved(){return this.result.nRemoved}getInsertedIds(){return this.result.insertedIds}getUpsertedIds(){return this.result.upserted}getUpsertedIdAt(e){return this.result.upserted[e]}getRawResponse(){return this.result}hasWriteErrors(){return this.result.writeErrors.length>0}getWriteErrorCount(){return this.result.writeErrors.length}getWriteErrorAt(e){return ee.multi)),3===e.batch.batchType&&(n.retryWrites=n.retryWrites&&!e.batch.operations.some(e=>0===e.limit)));try{1===e.batch.batchType?this.s.topology.insert(this.s.namespace,e.batch.operations,n,e.resultHandler):2===e.batch.batchType?this.s.topology.update(this.s.namespace,e.batch.operations,n,e.resultHandler):3===e.batch.batchType&&this.s.topology.remove(this.s.namespace,e.batch.operations,n,e.resultHandler)}catch(n){n.ok=0,l(t,null,v(e.batch,this.s.bulkResult,n,null))}}handleWriteError(e,t){if(this.s.bulkResult.writeErrors.length>0){const n=this.s.bulkResult.writeErrors[0].errmsg?this.s.bulkResult.writeErrors[0].errmsg:"write operation failed";return l(e,new O(c({message:n,code:this.s.bulkResult.writeErrors[0].code,writeErrors:this.s.bulkResult.writeErrors}),t),null),!0}if(t.getWriteConcernError())return l(e,new O(c(t.getWriteConcernError()),t),null),!0}}Object.defineProperty(T.prototype,"length",{enumerable:!0,get:function(){return this.s.currentIndex}}),e.exports={Batch:class{constructor(e,t){this.originalZeroIndex=t,this.currentIndex=0,this.originalIndexes=[],this.batchType=e,this.operations=[],this.size=0,this.sizeBytes=0}},BulkOperationBase:T,bson:y,INSERT:1,UPDATE:2,REMOVE:3,BulkWriteError:O}},function(e,t,n){"use strict";const r=n(2).MongoError,o=n(20),s=n(15).CursorState;class i extends o{constructor(e,t,n){super(e,t,n)}batchSize(e){if(this.s.state===s.CLOSED||this.isDead())throw r.create({message:"Cursor is closed",driver:!0});if("number"!=typeof e)throw r.create({message:"batchSize requires an integer",driver:!0});return this.operation.options.batchSize=e,this.setCursorBatchSize(e),this}geoNear(e){return this.operation.addToPipeline({$geoNear:e}),this}group(e){return this.operation.addToPipeline({$group:e}),this}limit(e){return this.operation.addToPipeline({$limit:e}),this}match(e){return this.operation.addToPipeline({$match:e}),this}maxTimeMS(e){return this.operation.options.maxTimeMS=e,this}out(e){return this.operation.addToPipeline({$out:e}),this}project(e){return this.operation.addToPipeline({$project:e}),this}lookup(e){return this.operation.addToPipeline({$lookup:e}),this}redact(e){return this.operation.addToPipeline({$redact:e}),this}skip(e){return this.operation.addToPipeline({$skip:e}),this}sort(e){return this.operation.addToPipeline({$sort:e}),this}unwind(e){return this.operation.addToPipeline({$unwind:e}),this}getLogger(){return this.logger}}i.prototype.get=i.prototype.toArray,e.exports=i},function(e,t,n){"use strict";const r=n(2).ReadPreference,o=n(2).MongoError,s=n(20),i=n(15).CursorState;class a extends s{constructor(e,t,n,r){super(e,t,n,r)}setReadPreference(e){if(this.s.state===i.CLOSED||this.isDead())throw o.create({message:"Cursor is closed",driver:!0});if(this.s.state!==i.INIT)throw o.create({message:"cannot change cursor readPreference after cursor has been accessed",driver:!0});if(e instanceof r)this.options.readPreference=e;else{if("string"!=typeof e)throw new TypeError("Invalid read preference: "+e);this.options.readPreference=new r(e)}return this}batchSize(e){if(this.s.state===i.CLOSED||this.isDead())throw o.create({message:"Cursor is closed",driver:!0});if("number"!=typeof e)throw o.create({message:"batchSize requires an integer",driver:!0});return this.cmd.cursor&&(this.cmd.cursor.batchSize=e),this.setCursorBatchSize(e),this}maxTimeMS(e){return this.topology.lastIsMaster().minWireVersion>2&&(this.cmd.maxTimeMS=e),this}getLogger(){return this.logger}}a.prototype.get=a.prototype.toArray,e.exports=a},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(18),s=n(1).defineAspects,i=n(0).handleCallback;class a extends o{constructor(e,t){const n=Object.assign({},t,e.s.options);t.session&&(n.session=t.session),super(e,n)}execute(e){super.execute((t,n)=>t?i(e,t):n.ok?i(e,null,!0):void i(e,null,!1))}}s(a,r.WRITE_OPERATION);e.exports={DropOperation:a,DropCollectionOperation:class extends a{constructor(e,t,n){super(e,n),this.name=t,this.namespace=`${e.namespace}.${t}`}_buildCommand(){return{drop:this.name}}},DropDatabaseOperation:class extends a{_buildCommand(){return{dropDatabase:1}}}}},function(e,t,n){"use strict";let r,o,s;e.exports={loadCollection:function(){return r||(r=n(42)),r},loadCursor:function(){return o||(o=n(20)),o},loadDb:function(){return s||(s=n(62)),s}}},function(e,t,n){"use strict";const r=n(2),o=n(166),s=n(40).connect;s.MongoError=r.MongoError,s.MongoNetworkError=r.MongoNetworkError,s.MongoTimeoutError=r.MongoTimeoutError,s.MongoServerSelectionError=r.MongoServerSelectionError,s.MongoParseError=r.MongoParseError,s.MongoWriteConcernError=r.MongoWriteConcernError,s.MongoBulkWriteError=n(76).BulkWriteError,s.BulkWriteError=s.MongoBulkWriteError,s.Admin=n(114),s.MongoClient=n(40),s.Db=n(62),s.Collection=n(42),s.Server=n(63),s.ReplSet=n(118),s.Mongos=n(117),s.ReadPreference=r.ReadPreference,s.GridStore=n(204),s.Chunk=n(120),s.Logger=r.Logger,s.AggregationCursor=n(77),s.CommandCursor=n(78),s.Cursor=n(20),s.GridFSBucket=n(205),s.CoreServer=r.Server,s.CoreConnection=r.Connection,s.Binary=r.BSON.Binary,s.Code=r.BSON.Code,s.Map=r.BSON.Map,s.DBRef=r.BSON.DBRef,s.Double=r.BSON.Double,s.Int32=r.BSON.Int32,s.Long=r.BSON.Long,s.MinKey=r.BSON.MinKey,s.MaxKey=r.BSON.MaxKey,s.ObjectID=r.BSON.ObjectID,s.ObjectId=r.BSON.ObjectID,s.Symbol=r.BSON.Symbol,s.Timestamp=r.BSON.Timestamp,s.BSONRegExp=r.BSON.BSONRegExp,s.Decimal128=r.BSON.Decimal128,s.connect=s,s.instrument=function(e,t){"function"==typeof e&&(t=e,e={});const n=new o;return n.instrument(s.MongoClient,t),n},e.exports=s},function(e,t,n){var r=n(121),o=n(34),s=n(48),i=n(52),a=n(49),c=n(43),l=n(65),u=n(29),h=n(64),p=n(51),f=n(50),d=n(45),m=n(46),y=n(47),g=n(44);r.BSON_INT32_MAX=2147483647,r.BSON_INT32_MIN=-2147483648,r.BSON_INT64_MAX=Math.pow(2,63)-1,r.BSON_INT64_MIN=-Math.pow(2,63),r.JS_INT_MAX=9007199254740992,r.JS_INT_MIN=-9007199254740992,r.Binary=o,r.Code=s,r.DBRef=i,r.Decimal128=a,r.Double=c,r.Int32=l,r.Long=u,r.Map=h,r.MaxKey=p,r.MinKey=f,r.ObjectId=d,r.ObjectID=d,r.BSONRegExp=m,r.Symbol=y,r.Timestamp=g,e.exports=r},function(e,t){function n(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id=83},function(e,t,n){"use strict";const r=n(8).EventEmitter,o=n(25),s=n(9).debugOptions,i=n(6).parseHeader,a=n(23).decompress,c=n(16).Response,l=n(31).BinMsg,u=n(3).MongoNetworkError,h=n(3).MongoNetworkTimeoutError,p=n(3).MongoError,f=n(14),d=n(6).opcodes.OP_COMPRESSED,m=n(6).opcodes.OP_MSG,y=n(6).MESSAGE_HEADER_SIZE,g=n(17).Buffer,b=n(16).Query,S=n(67);let v=0;const w=["host","port","size","keepAlive","keepAliveInitialDelay","noDelay","connectionTimeout","socketTimeout","ssl","ca","crl","cert","rejectUnauthorized","promoteLongs","promoteValues","promoteBuffers","checkServerIdentity"];let O=void 0,_=!1,T={};const E=["error","close","timeout","parseError"];function C(e){delete T[e],O&&O.deleteConnection(e)}function x(e,t){const n=i(t);if(n.opCode!==d){const r=n.opCode===m?l:c;return void e.emit("message",new r(e.bson,t,n,t.slice(y),e.responseOptions),e)}n.fromCompressed=!0;let r=y;n.opCode=t.readInt32LE(r),r+=4,n.length=t.readInt32LE(r),r+=4;const o=t[r];r++,a(o,t.slice(r),(r,o)=>{if(r)return void e.emit("error",r);if(o.length!==n.length)return void e.emit("error",new p("Decompressing a compressed message from the server failed. The message is corrupt."));const s=n.opCode===m?l:c;e.emit("message",new s(e.bson,t,n,o,e.responseOptions),e)})}e.exports=class extends r{constructor(e,t){if(super(),!(t=t||{}).bson)throw new TypeError("must pass in valid bson parser");this.id=v++,this.options=t,this.logger=f("Connection",t),this.bson=t.bson,this.tag=t.tag,this.maxBsonMessageSize=t.maxBsonMessageSize||67108864,this.port=t.port||27017,this.host=t.host||"localhost",this.socketTimeout="number"==typeof t.socketTimeout?t.socketTimeout:0,this.keepAlive="boolean"!=typeof t.keepAlive||t.keepAlive,this.keepAliveInitialDelay="number"==typeof t.keepAliveInitialDelay?t.keepAliveInitialDelay:12e4,this.connectionTimeout="number"==typeof t.connectionTimeout?t.connectionTimeout:3e4,this.keepAliveInitialDelay>this.socketTimeout&&(this.keepAliveInitialDelay=Math.round(this.socketTimeout/2)),this.logger.isDebug()&&this.logger.debug(`creating connection ${this.id} with options [${JSON.stringify(s(w,t))}]`),this.responseOptions={promoteLongs:"boolean"!=typeof t.promoteLongs||t.promoteLongs,promoteValues:"boolean"!=typeof t.promoteValues||t.promoteValues,promoteBuffers:"boolean"==typeof t.promoteBuffers&&t.promoteBuffers},this.flushing=!1,this.queue=[],this.writeStream=null,this.destroyed=!1,this.timedOut=!1;const n=o.createHash("sha1");var r,i,a;n.update(this.address),this.hashedName=n.digest("hex"),this.workItems=[],this.socket=e,this.socket.once("error",(r=this,function(e){_&&C(r.id),r.logger.isDebug()&&r.logger.debug(`connection ${r.id} for [${r.address}] errored out with [${JSON.stringify(e)}]`),r.emit("error",new u(e),r)})),this.socket.once("timeout",function(e){return function(){_&&C(e.id),e.logger.isDebug()&&e.logger.debug(`connection ${e.id} for [${e.address}] timed out`),e.timedOut=!0,e.emit("timeout",new h(`connection ${e.id} to ${e.address} timed out`,{beforeHandshake:null==e.ismaster}),e)}}(this)),this.socket.once("close",function(e){return function(t){_&&C(e.id),e.logger.isDebug()&&e.logger.debug(`connection ${e.id} with for [${e.address}] closed`),t||e.emit("close",new u(`connection ${e.id} to ${e.address} closed`),e)}}(this)),this.socket.on("data",function(e){return function(t){for(;t.length>0;)if(e.bytesRead>0&&e.sizeOfMessage>0){const n=e.sizeOfMessage-e.bytesRead;if(n>t.length)t.copy(e.buffer,e.bytesRead),e.bytesRead=e.bytesRead+t.length,t=g.alloc(0);else{t.copy(e.buffer,e.bytesRead,0,n),t=t.slice(n);const r=e.buffer;e.buffer=null,e.sizeOfMessage=0,e.bytesRead=0,e.stubBuffer=null,x(e,r)}}else if(null!=e.stubBuffer&&e.stubBuffer.length>0)if(e.stubBuffer.length+t.length>4){const n=g.alloc(e.stubBuffer.length+t.length);e.stubBuffer.copy(n,0),t.copy(n,e.stubBuffer.length),t=n,e.buffer=null,e.sizeOfMessage=0,e.bytesRead=0,e.stubBuffer=null}else{const n=g.alloc(e.stubBuffer.length+t.length);e.stubBuffer.copy(n,0),t.copy(n,e.stubBuffer.length),t=g.alloc(0)}else if(t.length>4){const n=t[0]|t[1]<<8|t[2]<<16|t[3]<<24;if(n<0||n>e.maxBsonMessageSize){const t={err:"socketHandler",trace:"",bin:e.buffer,parseState:{sizeOfMessage:n,bytesRead:e.bytesRead,stubBuffer:e.stubBuffer}};return void e.emit("parseError",t,e)}if(n>4&&nt.length)e.buffer=g.alloc(n),t.copy(e.buffer,0),e.bytesRead=t.length,e.sizeOfMessage=n,e.stubBuffer=null,t=g.alloc(0);else if(n>4&&ne.maxBsonMessageSize){const r={err:"socketHandler",trace:null,bin:t,parseState:{sizeOfMessage:n,bytesRead:0,buffer:null,stubBuffer:null}};e.emit("parseError",r,e),e.buffer=null,e.sizeOfMessage=0,e.bytesRead=0,e.stubBuffer=null,t=g.alloc(0)}else{const r=t.slice(0,n);e.buffer=null,e.sizeOfMessage=0,e.bytesRead=0,e.stubBuffer=null,t=t.slice(n),x(e,r)}}else e.stubBuffer=g.alloc(t.length),t.copy(e.stubBuffer,0),t=g.alloc(0)}}(this)),_&&(i=this.id,a=this,T[i]=a,O&&O.addConnection(i,a))}setSocketTimeout(e){this.socket&&this.socket.setTimeout(e)}resetSocketTimeout(){this.socket&&this.socket.setTimeout(this.socketTimeout)}static enableConnectionAccounting(e){e&&(O=e),_=!0,T={}}static disableConnectionAccounting(){_=!1,O=void 0}static connections(){return T}get address(){return`${this.host}:${this.port}`}unref(){null!=this.socket?this.socket.unref():this.once("connect",()=>this.socket.unref())}flush(e){for(;this.workItems.length>0;){const t=this.workItems.shift();t.cb&&t.cb(e)}}destroy(e,t){if("function"==typeof e&&(t=e,e={}),e=Object.assign({force:!1},e),_&&C(this.id),null!=this.socket)return e.force||this.timedOut?(this.socket.destroy(),this.destroyed=!0,void("function"==typeof t&&t(null,null))):void this.socket.end(e=>{this.destroyed=!0,"function"==typeof t&&t(e,null)});this.destroyed=!0}write(e){if(this.logger.isDebug())if(Array.isArray(e))for(let t=0;t{};function l(e,t){r(e,t),r=c}function u(e){o.resetSocketTimeout(),E.forEach(e=>o.removeListener(e,u)),o.removeListener("message",h),null==e&&(e=new p(`runCommand failed for connection to '${o.address}'`)),o.on("error",c),l(e)}function h(e){if(e.responseTo!==a.requestId)return;o.resetSocketTimeout(),E.forEach(e=>o.removeListener(e,u)),o.removeListener("message",h),e.parse({promoteValues:!0});const t=e.documents[0];0===t.ok||t.$err||t.errmsg||t.code?l(new p(t)):l(void 0,new S(t,this,e))}o.setSocketTimeout(s),E.forEach(e=>o.once(e,u)),o.on("message",h),o.write(a.toBin())}}},function(e,t,n){"use strict";t.asyncIterator=function(){const e=this;return{next:function(){return Promise.resolve().then(()=>e.next()).then(t=>t?{value:t,done:!1}:e.close().then(()=>({value:t,done:!0})))}}}},function(e,t,n){"use strict";const r=n(12).ServerType,o=n(30).ServerDescription,s=n(87),i=n(12).TopologyType,a=s.MIN_SUPPORTED_SERVER_VERSION,c=s.MAX_SUPPORTED_SERVER_VERSION,l=s.MIN_SUPPORTED_WIRE_VERSION,u=s.MAX_SUPPORTED_WIRE_VERSION;class h{constructor(e,t,n,o,s,h,p){p=p||{},this.type=e||i.Unknown,this.setName=n||null,this.maxSetVersion=o||null,this.maxElectionId=s||null,this.servers=t||new Map,this.stale=!1,this.compatible=!0,this.compatibilityError=null,this.logicalSessionTimeoutMinutes=null,this.heartbeatFrequencyMS=p.heartbeatFrequencyMS||0,this.localThresholdMS=p.localThresholdMS||0,this.commonWireVersion=h||null,Object.defineProperty(this,"options",{value:p,enumberable:!1});for(const e of this.servers.values())if(e.type!==r.Unknown&&(e.minWireVersion>u&&(this.compatible=!1,this.compatibilityError=`Server at ${e.address} requires wire version ${e.minWireVersion}, but this version of the driver only supports up to ${u} (MongoDB ${c})`),e.maxWireVersion=0&&d.delete(t),u===r.RSPrimary){const t=p(d,s,e,a,c);n=t[0],s=t[1],a=t[2],c=t[3]}else if([r.RSSecondary,r.RSArbiter,r.RSOther].indexOf(u)>=0){const t=function(e,t,n){let r=i.ReplicaSetNoPrimary;if((t=t||n.setName)!==n.setName)return e.delete(n.address),[r,t];n.allHosts.forEach(t=>{e.has(t)||e.set(t,new o(t))}),n.me&&n.address!==n.me&&e.delete(n.address);return[r,t]}(d,s,e);n=t[0],s=t[1]}if(n===i.ReplicaSetWithPrimary)if([r.Standalone,r.Mongos].indexOf(u)>=0)d.delete(t),n=f(d);else if(u===r.RSPrimary){const t=p(d,s,e,a,c);n=t[0],s=t[1],a=t[2],c=t[3]}else n=[r.RSSecondary,r.RSArbiter,r.RSOther].indexOf(u)>=0?function(e,t,n){if(null==t)throw new TypeError("setName is required");(t!==n.setName||n.me&&n.address!==n.me)&&e.delete(n.address);return f(e)}(d,s,e):f(d);return new h(n,d,s,a,c,l,this.options)}get error(){const e=Array.from(this.servers.values()).filter(e=>e.error);if(e.length>0)return e[0].error}get hasKnownServers(){return Array.from(this.servers.values()).some(e=>e.type!==r.Unknown)}get hasDataBearingServers(){return Array.from(this.servers.values()).some(e=>e.isDataBearing)}hasServer(e){return this.servers.has(e)}}function p(e,t,n,s,i){if((t=t||n.setName)!==n.setName)return e.delete(n.address),[f(e),t,s,i];const a=n.electionId?n.electionId:null;if(n.setVersion&&a){if(s&&i&&(s>n.setVersion||function(e,t){if(null==e)return-1;if(null==t)return 1;if(e.id instanceof Buffer&&t.id instanceof Buffer){const n=e.id,r=t.id;return n.compare(r)}const n=e.toString(),r=t.toString();return n.localeCompare(r)}(i,a)>0))return e.set(n.address,new o(n.address)),[f(e),t,s,i];i=n.electionId}null!=n.setVersion&&(null==s||n.setVersion>s)&&(s=n.setVersion);for(const t of e.keys()){const s=e.get(t);if(s.type===r.RSPrimary&&s.address!==n.address){e.set(t,new o(s.address));break}}n.allHosts.forEach(t=>{e.has(t)||e.set(t,new o(t))});const c=Array.from(e.keys()),l=n.allHosts;return c.filter(e=>-1===l.indexOf(e)).forEach(t=>{e.delete(t)}),[f(e),t,s,i]}function f(e){for(const t of e.keys())if(e.get(t).type===r.RSPrimary)return i.ReplicaSetWithPrimary;return i.ReplicaSetNoPrimary}e.exports={TopologyDescription:h}},function(e,t,n){"use strict";e.exports={MIN_SUPPORTED_SERVER_VERSION:"2.6",MAX_SUPPORTED_SERVER_VERSION:"4.4",MIN_SUPPORTED_WIRE_VERSION:2,MAX_SUPPORTED_WIRE_VERSION:9}},function(e,t,n){"use strict";const r=n(31).Msg,o=n(16).KillCursor,s=n(16).GetMore,i=n(0).calculateDurationInMs,a=new Set(["authenticate","saslStart","saslContinue","getnonce","createUser","updateUser","copydbgetnonce","copydbsaslstart","copydb"]),c=e=>Object.keys(e)[0],l=e=>e.ns,u=e=>e.ns.split(".")[0],h=e=>e.ns.split(".")[1],p=e=>e.options?`${e.options.host}:${e.options.port}`:e.address,f=(e,t)=>a.has(e)?{}:t,d={$query:"filter",$orderby:"sort",$hint:"hint",$comment:"comment",$maxScan:"maxScan",$max:"max",$min:"min",$returnKey:"returnKey",$showDiskLoc:"showRecordId",$maxTimeMS:"maxTimeMS",$snapshot:"snapshot"},m={numberToSkip:"skip",numberToReturn:"batchSize",returnFieldsSelector:"projection"},y=["tailable","oplogReplay","noCursorTimeout","awaitData","partial","exhaust"],g=e=>{if(e instanceof s)return{getMore:e.cursorId,collection:h(e),batchSize:e.numberToReturn};if(e instanceof o)return{killCursors:h(e),cursors:e.cursorIds};if(e instanceof r)return e.command;if(e.query&&e.query.$query){let t;return"admin.$cmd"===e.ns?t=Object.assign({},e.query.$query):(t={find:h(e)},Object.keys(d).forEach(n=>{void 0!==e.query[n]&&(t[d[n]]=e.query[n])})),Object.keys(m).forEach(n=>{void 0!==e[n]&&(t[m[n]]=e[n])}),y.forEach(n=>{e[n]&&(t[n]=e[n])}),void 0!==e.pre32Limit&&(t.limit=e.pre32Limit),e.query.$explain?{explain:t}:t}return e.query?e.query:e},b=(e,t)=>e instanceof s?{ok:1,cursor:{id:t.message.cursorId,ns:l(e),nextBatch:t.message.documents}}:e instanceof o?{ok:1,cursorsUnknown:e.cursorIds}:e.query&&void 0!==e.query.$query?{ok:1,cursor:{id:t.message.cursorId,ns:l(e),firstBatch:t.message.documents}}:t&&t.result?t.result:t,S=e=>{if((e=>e.s&&e.queue)(e))return{connectionId:p(e)};const t=e;return{address:t.address,connectionId:t.id}};e.exports={CommandStartedEvent:class{constructor(e,t){const n=g(t),r=c(n),o=S(e);a.has(r)&&(this.commandObj={},this.commandObj[r]=!0),Object.assign(this,o,{requestId:t.requestId,databaseName:u(t),commandName:r,command:n})}},CommandSucceededEvent:class{constructor(e,t,n,r){const o=g(t),s=c(o),a=S(e);Object.assign(this,a,{requestId:t.requestId,commandName:s,duration:i(r),reply:f(s,b(t,n))})}},CommandFailedEvent:class{constructor(e,t,n,r){const o=g(t),s=c(o),a=S(e);Object.assign(this,a,{requestId:t.requestId,commandName:s,duration:i(r),failure:f(s,n)})}}}},function(e,t,n){"use strict";const r=n(90),o=n(91),s=n(92),i=n(93),a=n(55).ScramSHA1,c=n(55).ScramSHA256,l=n(139);e.exports={defaultAuthProviders:function(e){return{"mongodb-aws":new l(e),mongocr:new r(e),x509:new o(e),plain:new s(e),gssapi:new i(e),"scram-sha-1":new a(e),"scram-sha-256":new c(e)}}}},function(e,t,n){"use strict";const r=n(25),o=n(26).AuthProvider;e.exports=class extends o{auth(e,t){const n=e.connection,o=e.credentials,s=o.username,i=o.password,a=o.source;n.command(a+".$cmd",{getnonce:1},(e,o)=>{let c=null,l=null;if(null==e){c=o.result.nonce;let e=r.createHash("md5");e.update(s+":mongo:"+i,"utf8");const t=e.digest("hex");e=r.createHash("md5"),e.update(c+s+t,"utf8"),l=e.digest("hex")}const u={authenticate:1,user:s,nonce:c,key:l};n.command(a+".$cmd",u,t)})}}},function(e,t,n){"use strict";const r=n(26).AuthProvider;function o(e){const t={authenticate:1,mechanism:"MONGODB-X509"};return e.username&&Object.assign(t,{user:e.username}),t}e.exports=class extends r{prepare(e,t,n){const r=t.credentials;Object.assign(e,{speculativeAuthenticate:o(r)}),n(void 0,e)}auth(e,t){const n=e.connection,r=e.credentials;if(e.response.speculativeAuthenticate)return t();n.command("$external.$cmd",o(r),t)}}},function(e,t,n){"use strict";const r=n(9).retrieveBSON,o=n(26).AuthProvider,s=r().Binary;e.exports=class extends o{auth(e,t){const n=e.connection,r=e.credentials,o=r.username,i=r.password,a={saslStart:1,mechanism:"PLAIN",payload:new s(`\0${o}\0${i}`),autoAuthorize:1};n.command("$external.$cmd",a,t)}}},function(e,t,n){"use strict";const r=n(54),o=n(26).AuthProvider,s=n(4).retrieveKerberos,i=n(3).MongoError;let a;e.exports=class extends o{auth(e,t){const n=e.connection,o=e.credentials;if(null==o)return t(new i("credentials required"));const c=o.username;function l(e,t){return n.command("$external.$cmd",e,t)}!function(e,t){const n=e.options.host,o=e.options.port,c=e.credentials;if(!n||!o||!c)return t(new i(`Connection must specify: ${n?"host":""}, ${o?"port":""}, ${c?"host":"credentials"}.`));if(null==a)try{a=s()}catch(e){return t(e)}const l=c.username,u=c.password,h=c.mechanismProperties,p=h.gssapiservicename||h.gssapiServiceName||"mongodb";!function(e,t,n){if("boolean"!=typeof t.gssapiCanonicalizeHostName||!t.gssapiCanonicalizeHostName)return n(void 0,e);r.resolveCname(e,(t,r)=>t?n(t):Array.isArray(r)&&r.length>0?n(void 0,r[0]):void n(void 0,e))}(n,h,(e,n)=>{if(e)return t(e);const r={};null!=u&&Object.assign(r,{user:l,password:u}),a.initializeClient(`${p}${"win32"===process.platform?"/":"@"}${n}`,r,(e,n)=>{if(e)return t(new i(e));t(null,n)})})}(e,(e,n)=>e?t(e):null==n?t(new i("gssapi client missing")):void n.step("",(e,r)=>{if(e)return t(e);l(function(e){return{saslStart:1,mechanism:"GSSAPI",payload:e,autoAuthorize:1}}(r),(e,r)=>{if(e)return t(e);const o=r.result;!function e(t,n,r,o){t.step(r,(s,i)=>s&&0===n?o(s):s?e(t,n-1,r,o):void o(void 0,i||""))}(n,10,o.payload,(e,r)=>{if(e)return t(e);l(function(e,t){return{saslContinue:1,conversationId:t,payload:e}}(r,o.conversationId),(e,r)=>{if(e)return t(e);const o=r.result;!function(e,t,n,r){e.unwrap(n,(n,o)=>{if(n)return r(n);e.wrap(o||"",{user:t},(e,t)=>{if(e)return r(e);r(void 0,t)})})}(n,c,o.payload,(e,n)=>{if(e)return t(e);l({saslContinue:1,conversationId:o.conversationId,payload:n},(e,n)=>{if(e)return t(e);t(void 0,n)})})})})})}))}}},function(e,t,n){"use strict";function r(e){if(e){if(Array.isArray(e.saslSupportedMechs))return e.saslSupportedMechs.indexOf("SCRAM-SHA-256")>=0?"scram-sha-256":"scram-sha-1";if(e.maxWireVersion>=3)return"scram-sha-1"}return"mongocr"}class o{constructor(e){e=e||{},this.username=e.username,this.password=e.password,this.source=e.source||e.db,this.mechanism=e.mechanism||"default",this.mechanismProperties=e.mechanismProperties||{},this.mechanism.match(/MONGODB-AWS/i)&&(null==this.username&&process.env.AWS_ACCESS_KEY_ID&&(this.username=process.env.AWS_ACCESS_KEY_ID),null==this.password&&process.env.AWS_SECRET_ACCESS_KEY&&(this.password=process.env.AWS_SECRET_ACCESS_KEY),null==this.mechanismProperties.AWS_SESSION_TOKEN&&process.env.AWS_SESSION_TOKEN&&(this.mechanismProperties.AWS_SESSION_TOKEN=process.env.AWS_SESSION_TOKEN)),Object.freeze(this.mechanismProperties),Object.freeze(this)}equals(e){return this.mechanism===e.mechanism&&this.username===e.username&&this.password===e.password&&this.source===e.source}resolveAuthMechanism(e){return this.mechanism.match(/DEFAULT/i)?new o({username:this.username,password:this.password,source:this.source,mechanism:r(e),mechanismProperties:this.mechanismProperties}):this}}e.exports={MongoCredentials:o}},function(e,t,n){"use strict";const r=n(141);e.exports={insert:function(e,t,n,o,s){r(e,"insert","documents",t,n,o,s)},update:function(e,t,n,o,s){r(e,"update","updates",t,n,o,s)},remove:function(e,t,n,o,s){r(e,"delete","deletes",t,n,o,s)},killCursors:n(142),getMore:n(143),query:n(144),command:n(36)}},function(e,t,n){"use strict";e.exports={ServerDescriptionChangedEvent:class{constructor(e,t,n,r){Object.assign(this,{topologyId:e,address:t,previousDescription:n,newDescription:r})}},ServerOpeningEvent:class{constructor(e,t){Object.assign(this,{topologyId:e,address:t})}},ServerClosedEvent:class{constructor(e,t){Object.assign(this,{topologyId:e,address:t})}},TopologyDescriptionChangedEvent:class{constructor(e,t,n){Object.assign(this,{topologyId:e,previousDescription:t,newDescription:n})}},TopologyOpeningEvent:class{constructor(e){Object.assign(this,{topologyId:e})}},TopologyClosedEvent:class{constructor(e){Object.assign(this,{topologyId:e})}},ServerHeartbeatStartedEvent:class{constructor(e){Object.assign(this,{connectionId:e})}},ServerHeartbeatSucceededEvent:class{constructor(e,t,n){Object.assign(this,{connectionId:n,duration:e,reply:t})}},ServerHeartbeatFailedEvent:class{constructor(e,t,n){Object.assign(this,{connectionId:n,duration:e,failure:t})}}}},function(e,t,n){"use strict";const r=n(8),o=n(151),s=n(3).MongoError,i=n(3).MongoNetworkError,a=n(3).MongoNetworkTimeoutError,c=n(3).MongoWriteConcernError,l=n(67),u=n(160).StreamDescription,h=n(95),p=n(88),f=n(27).updateSessionFromResponse,d=n(4).uuidV4,m=n(0).now,y=n(0).calculateDurationInMs,g=Symbol("stream"),b=Symbol("queue"),S=Symbol("messageStream"),v=Symbol("generation"),w=Symbol("lastUseTime"),O=Symbol("clusterTime"),_=Symbol("description"),T=Symbol("ismaster"),E=Symbol("autoEncrypter");function C(e){const t={description:e.description,clusterTime:e[O],s:{bson:e.bson,pool:{write:x.bind(e),isConnected:()=>!0}}};return e[E]&&(t.autoEncrypter=e[E]),t}function x(e,t,n){"function"==typeof t&&(n=t),t=t||{};const r={requestId:e.requestId,cb:n,session:t.session,fullResult:"boolean"==typeof t.fullResult&&t.fullResult,noResponse:"boolean"==typeof t.noResponse&&t.noResponse,documentsReturnedIn:t.documentsReturnedIn,command:!!t.command,promoteLongs:"boolean"!=typeof t.promoteLongs||t.promoteLongs,promoteValues:"boolean"!=typeof t.promoteValues||t.promoteValues,promoteBuffers:"boolean"==typeof t.promoteBuffers&&t.promoteBuffers,raw:"boolean"==typeof t.raw&&t.raw};this[_]&&this[_].compressor&&(r.agreedCompressor=this[_].compressor,this[_].zlibCompressionLevel&&(r.zlibCompressionLevel=this[_].zlibCompressionLevel)),"number"==typeof t.socketTimeout&&(r.socketTimeoutOverride=!0,this[g].setTimeout(t.socketTimeout)),this.monitorCommands&&(this.emit("commandStarted",new p.CommandStartedEvent(this,e)),r.started=m(),r.cb=(t,o)=>{t?this.emit("commandFailed",new p.CommandFailedEvent(this,e,t,r.started)):o&&o.result&&(0===o.result.ok||o.result.$err)?this.emit("commandFailed",new p.CommandFailedEvent(this,e,o.result,r.started)):this.emit("commandSucceeded",new p.CommandSucceededEvent(this,e,o,r.started)),"function"==typeof n&&n(t,o)}),r.noResponse||this[b].set(r.requestId,r);try{this[S].writeCommand(e,r)}catch(e){if(!r.noResponse)return this[b].delete(r.requestId),void r.cb(e)}r.noResponse&&r.cb()}e.exports={Connection:class extends r{constructor(e,t){var n;super(t),this.id=t.id,this.address=function(e){if("function"==typeof e.address)return`${e.remoteAddress}:${e.remotePort}`;return d().toString("hex")}(e),this.bson=t.bson,this.socketTimeout="number"==typeof t.socketTimeout?t.socketTimeout:0,this.host=t.host||"localhost",this.port=t.port||27017,this.monitorCommands="boolean"==typeof t.monitorCommands&&t.monitorCommands,this.closed=!1,this.destroyed=!1,this[_]=new u(this.address,t),this[v]=t.generation,this[w]=m(),t.autoEncrypter&&(this[E]=t.autoEncrypter),this[b]=new Map,this[S]=new o(t),this[S].on("message",(n=this,function(e){if(n.emit("message",e),!n[b].has(e.responseTo))return;const t=n[b].get(e.responseTo),r=t.cb;n[b].delete(e.responseTo),e.moreToCome?n[b].set(e.requestId,t):t.socketTimeoutOverride&&n[g].setTimeout(n.socketTimeout);try{e.parse(t)}catch(e){return void r(new s(e))}if(e.documents[0]){const o=e.documents[0],i=t.session;if(i&&f(i,o),o.$clusterTime&&(n[O]=o.$clusterTime,n.emit("clusterTimeReceived",o.$clusterTime)),t.command){if(o.writeConcernError)return void r(new c(o.writeConcernError,o));if(0===o.ok||o.$err||o.errmsg||o.code)return void r(new s(o))}}r(void 0,new l(t.fullResult?e:e.documents[0],n,e))})),this[g]=e,e.on("error",()=>{}),e.on("close",()=>{this.closed||(this.closed=!0,this[b].forEach(e=>e.cb(new i(`connection ${this.id} to ${this.address} closed`))),this[b].clear(),this.emit("close"))}),e.on("timeout",()=>{this.closed||(e.destroy(),this.closed=!0,this[b].forEach(e=>e.cb(new a(`connection ${this.id} to ${this.address} timed out`,{beforeHandshake:null==this[T]}))),this[b].clear(),this.emit("close"))}),e.pipe(this[S]),this[S].pipe(e)}get description(){return this[_]}get ismaster(){return this[T]}set ismaster(e){this[_].receiveResponse(e),this[T]=e}get generation(){return this[v]||0}get idleTime(){return y(this[w])}get clusterTime(){return this[O]}get stream(){return this[g]}markAvailable(){this[w]=m()}destroy(e,t){return"function"==typeof e&&(t=e,e={}),e=Object.assign({force:!1},e),null==this[g]||this.destroyed?(this.destroyed=!0,void("function"==typeof t&&t())):e.force?(this[g].destroy(),this.destroyed=!0,void("function"==typeof t&&t())):void this[g].end(e=>{this.destroyed=!0,"function"==typeof t&&t(e)})}command(e,t,n,r){h.command(C(this),e,t,n,r)}query(e,t,n,r,o){h.query(C(this),e,t,n,r,o)}getMore(e,t,n,r,o){h.getMore(C(this),e,t,n,r,o)}killCursors(e,t,n){h.killCursors(C(this),e,t,n)}insert(e,t,n,r){h.insert(C(this),e,t,n,r)}update(e,t,n,r){h.update(C(this),e,t,n,r)}remove(e,t,n,r){h.remove(C(this),e,t,n,r)}}}},function(e,t,n){"use strict";var r=n(57);e.exports=b;var o,s=n(154);b.ReadableState=g;n(8).EventEmitter;var i=function(e,t){return e.listeners(t).length},a=n(99),c=n(73).Buffer,l=global.Uint8Array||function(){};var u=Object.create(n(38));u.inherits=n(39);var h=n(5),p=void 0;p=h&&h.debuglog?h.debuglog("stream"):function(){};var f,d=n(156),m=n(100);u.inherits(b,a);var y=["error","close","destroy","pause","resume"];function g(e,t){e=e||{};var r=t instanceof(o=o||n(33));this.objectMode=!!e.objectMode,r&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var s=e.highWaterMark,i=e.readableHighWaterMark,a=this.objectMode?16:16384;this.highWaterMark=s||0===s?s:r&&(i||0===i)?i:a,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new d,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.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(f||(f=n(102).StringDecoder),this.decoder=new f(e.encoding),this.encoding=e.encoding)}function b(e){if(o=o||n(33),!(this instanceof b))return new b(e);this._readableState=new g(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function S(e,t,n,r,o){var s,i=e._readableState;null===t?(i.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,O(e)}(e,i)):(o||(s=function(e,t){var n;r=t,c.isBuffer(r)||r instanceof l||"string"==typeof t||void 0===t||e.objectMode||(n=new TypeError("Invalid non-string/buffer chunk"));var r;return n}(i,t)),s?e.emit("error",s):i.objectMode||t&&t.length>0?("string"==typeof t||i.objectMode||Object.getPrototypeOf(t)===c.prototype||(t=function(e){return c.from(e)}(t)),r?i.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):v(e,i,t,!0):i.ended?e.emit("error",new Error("stream.push() after EOF")):(i.reading=!1,i.decoder&&!n?(t=i.decoder.write(t),i.objectMode||0!==t.length?v(e,i,t,!1):T(e,i)):v(e,i,t,!1))):r||(i.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function O(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(p("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?r.nextTick(_,e):_(e))}function _(e){p("emit readable"),e.emit("readable"),N(e)}function T(e,t){t.readingMore||(t.readingMore=!0,r.nextTick(E,e,t))}function E(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(n=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):n=function(e,t,n){var r;es.length?s.length:e;if(i===s.length?o+=s:o+=s.slice(0,e),0===(e-=i)){i===s.length?(++r,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=s.slice(i));break}++r}return t.length-=r,o}(e,t):function(e,t){var n=c.allocUnsafe(e),r=t.head,o=1;r.data.copy(n),e-=r.data.length;for(;r=r.next;){var s=r.data,i=e>s.length?s.length:e;if(s.copy(n,n.length-e,0,i),0===(e-=i)){i===s.length?(++o,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=s.slice(i));break}++o}return t.length-=o,n}(e,t);return r}(e,t.buffer,t.decoder),n);var n}function A(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,r.nextTick(k,t,e))}function k(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function M(e,t){for(var n=0,r=e.length;n=t.highWaterMark||t.ended))return p("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?A(this):O(this),null;if(0===(e=w(e,t))&&t.ended)return 0===t.length&&A(this),null;var r,o=t.needReadable;return p("need readable",o),(0===t.length||t.length-e0?I(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),n!==e&&t.ended&&A(this)),null!==r&&this.emit("data",r),r},b.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(e,t){var n=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,p("pipe count=%d opts=%j",o.pipesCount,t);var a=(!t||!1!==t.end)&&e!==process.stdout&&e!==process.stderr?l:b;function c(t,r){p("onunpipe"),t===n&&r&&!1===r.hasUnpiped&&(r.hasUnpiped=!0,p("cleanup"),e.removeListener("close",y),e.removeListener("finish",g),e.removeListener("drain",u),e.removeListener("error",m),e.removeListener("unpipe",c),n.removeListener("end",l),n.removeListener("end",b),n.removeListener("data",d),h=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||u())}function l(){p("onend"),e.end()}o.endEmitted?r.nextTick(a):n.once("end",a),e.on("unpipe",c);var u=function(e){return function(){var t=e._readableState;p("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&i(e,"data")&&(t.flowing=!0,N(e))}}(n);e.on("drain",u);var h=!1;var f=!1;function d(t){p("ondata"),f=!1,!1!==e.write(t)||f||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==M(o.pipes,e))&&!h&&(p("false write response, pause",n._readableState.awaitDrain),n._readableState.awaitDrain++,f=!0),n.pause())}function m(t){p("onerror",t),b(),e.removeListener("error",m),0===i(e,"error")&&e.emit("error",t)}function y(){e.removeListener("finish",g),b()}function g(){p("onfinish"),e.removeListener("close",y),b()}function b(){p("unpipe"),n.unpipe(e)}return n.on("data",d),function(e,t,n){if("function"==typeof e.prependListener)return e.prependListener(t,n);e._events&&e._events[t]?s(e._events[t])?e._events[t].unshift(n):e._events[t]=[n,e._events[t]]:e.on(t,n)}(e,"error",m),e.once("close",y),e.once("finish",g),e.emit("pipe",n),o.flowing||(p("pipe resume"),n.resume()),e},b.prototype.unpipe=function(e){var t=this._readableState,n={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,n)),this;if(!e){var r=t.pipes,o=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var s=0;s-1?setImmediate:r.nextTick;y.WritableState=m;var a=Object.create(n(38));a.inherits=n(39);var c={deprecate:n(157)},l=n(99),u=n(73).Buffer,h=global.Uint8Array||function(){};var p,f=n(100);function d(){}function m(e,t){s=s||n(33),e=e||{};var a=t instanceof s;this.objectMode=!!e.objectMode,a&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var c=e.highWaterMark,l=e.writableHighWaterMark,u=this.objectMode?16:16384;this.highWaterMark=c||0===c?c:a&&(l||0===l)?l:u,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var h=!1===e.decodeStrings;this.decodeStrings=!h,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var n=e._writableState,o=n.sync,s=n.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(n),t)!function(e,t,n,o,s){--t.pendingcb,n?(r.nextTick(s,o),r.nextTick(O,e,t),e._writableState.errorEmitted=!0,e.emit("error",o)):(s(o),e._writableState.errorEmitted=!0,e.emit("error",o),O(e,t))}(e,n,o,t,s);else{var a=v(n);a||n.corked||n.bufferProcessing||!n.bufferedRequest||S(e,n),o?i(b,e,n,a,s):b(e,n,a,s)}}(t,e)},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 o(this)}function y(e){if(s=s||n(33),!(p.call(y,this)||this instanceof s))return new y(e);this._writableState=new m(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function g(e,t,n,r,o,s,i){t.writelen=r,t.writecb=i,t.writing=!0,t.sync=!0,n?e._writev(o,t.onwrite):e._write(o,s,t.onwrite),t.sync=!1}function b(e,t,n,r){n||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,r(),O(e,t)}function S(e,t){t.bufferProcessing=!0;var n=t.bufferedRequest;if(e._writev&&n&&n.next){var r=t.bufferedRequestCount,s=new Array(r),i=t.corkedRequestsFree;i.entry=n;for(var a=0,c=!0;n;)s[a]=n,n.isBuf||(c=!1),n=n.next,a+=1;s.allBuffers=c,g(e,t,!0,t.length,s,"",i.finish),t.pendingcb++,t.lastBufferedRequest=null,i.next?(t.corkedRequestsFree=i.next,i.next=null):t.corkedRequestsFree=new o(t),t.bufferedRequestCount=0}else{for(;n;){var l=n.chunk,u=n.encoding,h=n.callback;if(g(e,t,!1,t.objectMode?1:l.length,l,u,h),n=n.next,t.bufferedRequestCount--,t.writing)break}null===n&&(t.lastBufferedRequest=null)}t.bufferedRequest=n,t.bufferProcessing=!1}function v(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function w(e,t){e._final((function(n){t.pendingcb--,n&&e.emit("error",n),t.prefinished=!0,e.emit("prefinish"),O(e,t)}))}function O(e,t){var n=v(t);return n&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,r.nextTick(w,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),n}a.inherits(y,l),m.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(m.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(p=Function.prototype[Symbol.hasInstance],Object.defineProperty(y,Symbol.hasInstance,{value:function(e){return!!p.call(this,e)||this===y&&(e&&e._writableState instanceof m)}})):p=function(e){return e instanceof this},y.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},y.prototype.write=function(e,t,n){var o,s=this._writableState,i=!1,a=!s.objectMode&&(o=e,u.isBuffer(o)||o instanceof h);return a&&!u.isBuffer(e)&&(e=function(e){return u.from(e)}(e)),"function"==typeof t&&(n=t,t=null),a?t="buffer":t||(t=s.defaultEncoding),"function"!=typeof n&&(n=d),s.ended?function(e,t){var n=new Error("write after end");e.emit("error",n),r.nextTick(t,n)}(this,n):(a||function(e,t,n,o){var s=!0,i=!1;return null===n?i=new TypeError("May not write null values to stream"):"string"==typeof n||void 0===n||t.objectMode||(i=new TypeError("Invalid non-string/buffer chunk")),i&&(e.emit("error",i),r.nextTick(o,i),s=!1),s}(this,s,e,n))&&(s.pendingcb++,i=function(e,t,n,r,o,s){if(!n){var i=function(e,t,n){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=u.from(t,n));return t}(t,r,o);r!==i&&(n=!0,o="buffer",r=i)}var a=t.objectMode?1:r.length;t.length+=a;var c=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(y.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),y.prototype._write=function(e,t,n){n(new Error("_write() is not implemented"))},y.prototype._writev=null,y.prototype.end=function(e,t,n){var o=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),null!=e&&this.write(e,t),o.corked&&(o.corked=1,this.uncork()),o.ending||o.finished||function(e,t,n){t.ending=!0,O(e,t),n&&(t.finished?r.nextTick(n):e.once("finish",n));t.ended=!0,e.writable=!1}(this,o,n)},Object.defineProperty(y.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),y.prototype.destroy=f.destroy,y.prototype._undestroy=f.undestroy,y.prototype._destroy=function(e,t){this.end(),t(e)}},function(e,t,n){"use strict";var r=n(158).Buffer,o=r.isEncoding||function(e){switch((e=""+e)&&e.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 s(e){var t;switch(this.encoding=function(e){var t=function(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}(e);if("string"!=typeof t&&(r.isEncoding===o||!o(e)))throw new Error("Unknown encoding: "+e);return t||e}(e),this.encoding){case"utf16le":this.text=c,this.end=l,t=4;break;case"utf8":this.fillLast=a,t=4;break;case"base64":this.text=u,this.end=h,t=3;break;default:return this.write=p,void(this.end=f)}this.lastNeed=0,this.lastTotal=0,this.lastChar=r.allocUnsafe(t)}function i(e){return e<=127?0:e>>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,n=function(e,t,n){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==n?n:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function c(e,t){if((e.length-t)%2==0){var n=e.toString("utf16le",t);if(n){var r=n.charCodeAt(n.length-1);if(r>=55296&&r<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],n.slice(0,-1)}return n}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function l(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var n=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,n)}return t}function u(e,t){var n=(e.length-t)%3;return 0===n?e.toString("base64",t):(this.lastNeed=3-n,this.lastTotal=3,1===n?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-n))}function h(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function p(e){return e.toString(this.encoding)}function f(e){return e&&e.length?this.write(e):""}t.StringDecoder=s,s.prototype.write=function(e){if(0===e.length)return"";var t,n;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";n=this.lastNeed,this.lastNeed=0}else n=0;return n=0)return o>0&&(e.lastNeed=o-1),o;if(--r=0)return o>0&&(e.lastNeed=o-2),o;if(--r=0)return o>0&&(2===o?o=0:e.lastNeed=o-3),o;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=n;var r=e.length-(n-this.lastNeed);return e.copy(this.lastChar,0,r),e.toString("utf8",t,r)},s.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,n){"use strict";e.exports=i;var r=n(33),o=Object.create(n(38));function s(e,t){var n=this._transformState;n.transforming=!1;var r=n.writecb;if(!r)return this.emit("error",new Error("write callback called multiple times"));n.writechunk=null,n.writecb=null,null!=t&&this.push(t),r(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length{if(!n&&t)return e(t,null);n.insertedCount=n.nInserted,n.matchedCount=n.nMatched,n.modifiedCount=n.nModified||0,n.deletedCount=n.nRemoved,n.upsertedCount=n.getUpsertedIds().length,n.upsertedIds={},n.insertedIds={},n.n=n.insertedCount;const r=n.getInsertedIds();for(let e=0;e{e?t(e):t(null,this.onlyReturnNameOfCreatedIndex?r[0].name:n)})}}o(u,[r.WRITE_OPERATION,r.EXECUTE_WITH_SELECTION]),e.exports=u},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(18),i=n(0).applyWriteConcern,a=n(0).handleCallback;class c extends s{constructor(e,t,n){super(e.s.db,n,e),this.collection=e,this.indexName=t}_buildCommand(){const e=this.collection,t=this.indexName,n=this.options;let r={dropIndexes:e.collectionName,index:t};return r=i(r,{db:e.s.db,collection:e},n),r}execute(e){super.execute((t,n)=>{if("function"==typeof e)return t?a(e,t,null):void a(e,null,n)})}}o(c,r.WRITE_OPERATION),e.exports=c},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).indexInformation;e.exports=class extends r{constructor(e,t,n){super(n),this.db=e,this.name=t}execute(e){const t=this.db,n=this.name,r=this.options;o(t,n,r,e)}}},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(0).handleCallback,s=n(2).MongoError;e.exports=class extends r{constructor(e,t){super(t),this.collection=e}execute(e){const t=this.collection,n=this.options;t.s.db.listCollections({name:t.collectionName},n).toArray((n,r)=>n?o(e,n):0===r.length?o(e,s.create({message:`collection ${t.namespace} not found`,driver:!0})):void o(e,n,r[0].options||null))}}},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(18),s=n(1).defineAspects,i=n(25),a=n(0).handleCallback,c=n(0).toError,l=n(0).emitWarning;class u extends o{constructor(e,t,n,r){super(e,r),this.username=t,this.password=n}_buildCommand(){const e=this.db,t=this.username,n=this.password,r=this.options;let o=[];Array.isArray(r.roles)&&(o=r.roles),"string"==typeof r.roles&&(o=[r.roles]),0===o.length&&l("Creating a user without roles is deprecated in MongoDB >= 2.6"),"admin"!==e.databaseName.toLowerCase()&&"admin"!==r.dbName||Array.isArray(r.roles)?Array.isArray(r.roles)||(o=["dbOwner"]):o=["root"];const s=e.s.topology.lastIsMaster().maxWireVersion>=7;let a=n;if(!s){const e=i.createHash("md5");e.update(t+":mongo:"+n),a=e.digest("hex")}const c={createUser:t,customData:r.customData||{},roles:o,digestPassword:s};return"string"==typeof n&&(c.pwd=a),c}execute(e){if(null!=this.options.digestPassword)return e(c("The digestPassword option is not supported via add_user. Please use db.command('createUser', ...) instead for this option."));super.execute((t,n)=>a(e,t,t?null:n))}}s(u,r.WRITE_OPERATION),e.exports=u},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(0).handleCallback,s=n(2).MongoError,i=n(0).MongoDBNamespace;e.exports=class extends r{constructor(e,t,n){super(n),this.db=e,this.selector=t}execute(e){const t=this.db,n=this.selector,r=this.options,a=new i("admin","$cmd");t.s.topology.command(a,n,r,(n,r)=>t.serverConfig&&t.serverConfig.isDestroyed()?e(new s("topology was destroyed")):n?o(e,n):void o(e,null,r.result))}}},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(18),s=n(1).defineAspects,i=n(0).handleCallback,a=n(22);class c extends o{constructor(e,t,n){const r={},o=a.fromOptions(n);null!=o&&(r.writeConcern=o),n.dbName&&(r.dbName=n.dbName),"number"==typeof n.maxTimeMS&&(r.maxTimeMS=n.maxTimeMS),super(e,r),this.username=t}_buildCommand(){return{dropUser:this.username}}execute(e){super.execute((t,n)=>{if(t)return i(e,t,null);i(e,t,!!n.ok)})}}s(c,r.WRITE_OPERATION),e.exports=c},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(0).applyWriteConcern,s=n(0).checkCollectionName,i=n(11).executeDbAdminCommand,a=n(0).handleCallback,c=n(80).loadCollection,l=n(0).toError;e.exports=class extends r{constructor(e,t,n){super(n),this.collection=e,this.newName=t}execute(e){const t=this.collection,n=this.newName,r=this.options;let u=c();s(n);const h={renameCollection:t.namespace,to:t.s.namespace.withCollection(n).toString(),dropTarget:"boolean"==typeof r.dropTarget&&r.dropTarget};o(h,{db:t.s.db,collection:t},r),i(t.s.db.admin().s.db,h,r,(r,o)=>{if(r)return a(e,r,null);if(o.errmsg)return a(e,l(o),null);try{return a(e,null,new u(t.s.db,t.s.topology,t.s.namespace.db,n,t.s.pkFactory,t.s.options))}catch(r){return a(e,l(r),null)}})}}},function(e,t,n){"use strict";const r=n(0).applyWriteConcern,o=n(110),s=n(111),i=n(112),a=n(196),c=n(197),l=n(37);function u(e,t,n){if(!(this instanceof u))return new u(e,t);this.s={db:e,topology:t,promiseLibrary:n}}u.prototype.command=function(e,t,n){const r=Array.prototype.slice.call(arguments,1);n="function"==typeof r[r.length-1]?r.pop():void 0,t=r.length?r.shift():{};const o=new s(this.s.db,e,t);return l(this.s.db.s.topology,o,n)},u.prototype.buildInfo=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=new s(this.s.db,{buildinfo:1},e);return l(this.s.db.s.topology,n,t)},u.prototype.serverInfo=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=new s(this.s.db,{buildinfo:1},e);return l(this.s.db.s.topology,n,t)},u.prototype.serverStatus=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=new s(this.s.db,{serverStatus:1},e);return l(this.s.db.s.topology,n,t)},u.prototype.ping=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=new s(this.s.db,{ping:1},e);return l(this.s.db.s.topology,n,t)},u.prototype.addUser=function(e,t,n,s){const i=Array.prototype.slice.call(arguments,2);s="function"==typeof i[i.length-1]?i.pop():void 0,"string"==typeof e&&null!=t&&"object"==typeof t&&(n=t,t=null),n=i.length?i.shift():{},n=Object.assign({},n),(n=r(n,{db:this.s.db})).dbName="admin";const a=new o(this.s.db,e,t,n);return l(this.s.db.s.topology,a,s)},u.prototype.removeUser=function(e,t,n){const o=Array.prototype.slice.call(arguments,1);n="function"==typeof o[o.length-1]?o.pop():void 0,t=o.length?o.shift():{},t=Object.assign({},t),(t=r(t,{db:this.s.db})).dbName="admin";const s=new i(this.s.db,e,t);return l(this.s.db.s.topology,s,n)},u.prototype.validateCollection=function(e,t,n){"function"==typeof t&&(n=t,t={});const r=new a(this,e,t=t||{});return l(this.s.db.s.topology,r,n)},u.prototype.listDatabases=function(e,t){return"function"==typeof e&&(t=e,e={}),e=e||{},l(this.s.db.s.topology,new c(this.s.db,e),t)},u.prototype.replSetGetStatus=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};const n=new s(this.s.db,{replSetGetStatus:1},e);return l(this.s.db.s.topology,n,t)},e.exports=u},function(e,t,n){"use strict";const r=n(2).Topology,o=n(28).ServerCapabilities,s=n(20),i=n(0).translateOptions;e.exports=class extends r{constructor(e,t){t=t||{};let n=Object.assign({},{cursorFactory:s,reconnect:!1,emitError:"boolean"!=typeof t.emitError||t.emitError,maxPoolSize:"number"==typeof t.maxPoolSize?t.maxPoolSize:"number"==typeof t.poolSize?t.poolSize:10,minPoolSize:"number"==typeof t.minPoolSize?t.minPoolSize:"number"==typeof t.minSize?t.minSize:0,monitorCommands:"boolean"==typeof t.monitorCommands&&t.monitorCommands});n=i(n,t);var r=t.socketOptions&&Object.keys(t.socketOptions).length>0?t.socketOptions:t;n=i(n,r),super(e,n)}capabilities(){return this.s.sCapabilities?this.s.sCapabilities:null==this.lastIsMaster()?null:(this.s.sCapabilities=new o(this.lastIsMaster()),this.s.sCapabilities)}command(e,t,n,r){super.command(e.toString(),t,n,r)}insert(e,t,n,r){super.insert(e.toString(),t,n,r)}update(e,t,n,r){super.update(e.toString(),t,n,r)}remove(e,t,n,r){super.remove(e.toString(),t,n,r)}}},function(e,t,n){"use strict";const r=n(5).deprecate,o=n(2).Logger,s=n(2).MongoCredentials,i=n(2).MongoError,a=n(117),c=n(115),l=n(2).parseConnectionString,u=n(32),h=n(2).ReadPreference,p=n(118),f=n(63),d=n(2).Sessions.ServerSessionPool,m=n(0).emitDeprecationWarning,y=n(0).emitWarningOnce,g=n(70),b=n(22),S=n(58).CMAP_EVENT_NAMES;let v;const w=r(n(203),"current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect."),O={DEFAULT:"default",PLAIN:"plain",GSSAPI:"gssapi","MONGODB-CR":"mongocr","MONGODB-X509":"x509","MONGODB-AWS":"mongodb-aws","SCRAM-SHA-1":"scram-sha-1","SCRAM-SHA-256":"scram-sha-256"},_=["timeout","close","serverOpening","serverDescriptionChanged","serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","serverClosed","topologyOpening","topologyClosed","topologyDescriptionChanged","commandStarted","commandSucceeded","commandFailed","joined","left","ping","ha","all","fullsetup","open"],T=new Set(["DEFAULT","PLAIN","GSSAPI","MONGODB-CR","MONGODB-X509","MONGODB-AWS","SCRAM-SHA-1","SCRAM-SHA-256"]),E=["poolSize","ssl","sslValidate","sslCA","sslCert","sslKey","sslPass","sslCRL","autoReconnect","noDelay","keepAlive","keepAliveInitialDelay","connectTimeoutMS","family","socketTimeoutMS","reconnectTries","reconnectInterval","ha","haInterval","replicaSet","secondaryAcceptableLatencyMS","acceptableLatencyMS","connectWithNoPrimary","authSource","w","wtimeout","j","writeConcern","forceServerObjectId","serializeFunctions","ignoreUndefined","raw","bufferMaxEntries","readPreference","pkFactory","promiseLibrary","readConcern","maxStalenessSeconds","loggerLevel","logger","promoteValues","promoteBuffers","promoteLongs","domainsEnabled","checkServerIdentity","validateOptions","appname","auth","user","password","authMechanism","compression","fsync","readPreferenceTags","numberOfRetries","auto_reconnect","minSize","monitorCommands","retryWrites","retryReads","useNewUrlParser","useUnifiedTopology","serverSelectionTimeoutMS","useRecoveryToken","autoEncryption","driverInfo","tls","tlsInsecure","tlsinsecure","tlsAllowInvalidCertificates","tlsAllowInvalidHostnames","tlsCAFile","tlsCertificateFile","tlsCertificateKeyFile","tlsCertificateKeyFilePassword","minHeartbeatFrequencyMS","heartbeatFrequencyMS","directConnection","appName","maxPoolSize","minPoolSize","maxIdleTimeMS","waitQueueTimeoutMS"],C=["native_parser"],x=["server","replset","replSet","mongos","db"];const N=E.reduce((e,t)=>(e[t.toLowerCase()]=t,e),{});function I(e,t){t.on("authenticated",M(e,"authenticated")),t.on("error",M(e,"error")),t.on("timeout",M(e,"timeout")),t.on("close",M(e,"close")),t.on("parseError",M(e,"parseError")),t.once("open",M(e,"open")),t.once("fullsetup",M(e,"fullsetup")),t.once("all",M(e,"all")),t.on("reconnect",M(e,"reconnect"))}function A(e,t){e.topology=t,t instanceof c||(t.s.sessionPool=new d(t.s.coreTopology))}function k(e,t){let r=(v||(v=n(40)),v);const o=[];return e instanceof r&&_.forEach(n=>{t.on(n,(t,r)=>{"open"===n?o.push({event:n,object1:e}):o.push({event:n,object1:t,object2:r})})}),o}function M(e,t){const n=new Set(["all","fullsetup","open","reconnect"]);return(r,o)=>{if(n.has(t))return e.emit(t,e);e.emit(t,r,o)}}const B=new Set(["reconnect","reconnectFailed","attemptReconnect","joined","left","ping","ha","all","fullsetup","open"]);function R(e,t,r,o){r.promiseLibrary=e.s.promiseLibrary;const s={};"unified"===t&&(s.createServers=!1);const i=W(r,s);if(null!=r.autoEncryption){const t=n(119).Encrypter;r.encrypter=new t(e,r),r.autoEncrypter=r.encrypter.autoEncrypter}let l;"mongos"===t?l=new a(i,r):"replicaset"===t?l=new p(i,r):"unified"===t&&(l=new c(r.servers,r),function(e){e.on("newListener",e=>{B.has(e)&&m(`The \`${e}\` event is no longer supported by the unified topology, please read more by visiting http://bit.ly/2D8WfT6`,"DeprecationWarning")})}(e)),I(e,l),U(e,l),A(e,l),r.autoEncrypter?r.autoEncrypter.init(e=>{e?o(e):l.connect(r,e=>{if(e)return l.close(!0),void o(e);r.encrypter.connectInternalClient(e=>{if(e)return o(e);o(void 0,l)})})}):l.connect(r,e=>{if(e)return l.close(!0),o(e);o(void 0,l)})}function P(e,t){const n=["mongos","server","db","replset","db_options","server_options","rs_options","mongos_options"],r=["readconcern","compression","autoencryption"],o=["w","wtimeout","j","journal","fsync","writeConcern"];for(const s in t)-1===o.indexOf(s.toLowerCase())&&(-1!==r.indexOf(s.toLowerCase())?e[s]=t[s]:-1!==n.indexOf(s.toLowerCase())?e=j(e,t[s],!1):!t[s]||"object"!=typeof t[s]||Buffer.isBuffer(t[s])||Array.isArray(t[s])?e[s]=t[s]:e=j(e,t[s],!0));const s=b.fromOptions(t);return s&&(e.writeConcern=Object.assign({},e.writeConcern,s)),e}function D(e,t,n,r){const o=(r=Object.assign({},r)).authSource||r.authdb||r.dbName,a=r.authMechanism||"DEFAULT",c=a.toUpperCase(),l=r.authMechanismProperties;if(!T.has(c))throw i.create({message:`authentication mechanism ${a} not supported', options.authMechanism`,driver:!0});return new s({mechanism:O[c],mechanismProperties:l,source:o,username:t,password:n})}function L(e){return j(P({},e),e,!1)}function j(e,t,n){for(const r in t)t[r]&&"object"==typeof t[r]&&n?e=j(e,t[r],n):e[r]=t[r];return e}function U(e,t){["commandStarted","commandSucceeded","commandFailed","serverOpening","serverClosed","serverDescriptionChanged","serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","topologyOpening","topologyClosed","topologyDescriptionChanged","joined","left","ping","ha"].concat(S).forEach(n=>{t.on(n,(t,r)=>{e.emit(n,t,r)})})}function z(e){let t=Object.assign({servers:e.hosts},e.options);for(let e in t){const n=N[e];n&&(t[n]=t[e])}const n=e.auth&&e.auth.username,r=e.options&&e.options.authMechanism;(n||r)&&(t.auth=Object.assign({},e.auth),t.auth.db&&(t.authSource=t.authSource||t.auth.db),t.auth.username&&(t.auth.user=t.auth.username)),e.defaultDatabase&&(t.dbName=e.defaultDatabase),t.maxPoolSize&&(t.poolSize=t.maxPoolSize),t.readConcernLevel&&(t.readConcern=new u(t.readConcernLevel)),t.wTimeoutMS&&(t.wtimeout=t.wTimeoutMS,t.wTimeoutMS=void 0),e.srvHost&&(t.srvHost=e.srvHost);const o=["w","wtimeout","j","journal","fsync"];for(const e of o)void 0!==t[e]&&(void 0===t.writeConcern&&(t.writeConcern={}),t.writeConcern[e]=t[e],t[e]=void 0);return t}function W(e,t){if(t=Object.assign({},{createServers:!0},t),"string"!=typeof e.readPreference&&"string"!=typeof e.read_preference||(e.readPreference=new h(e.readPreference||e.read_preference)),e.readPreference&&(e.readPreferenceTags||e.read_preference_tags)&&(e.readPreference.tags=e.readPreferenceTags||e.read_preference_tags),e.maxStalenessSeconds&&(e.readPreference.maxStalenessSeconds=e.maxStalenessSeconds),null==e.socketTimeoutMS&&(e.socketTimeoutMS=0),null==e.connectTimeoutMS&&(e.connectTimeoutMS=1e4),t.createServers)return e.servers.map(t=>t.domain_socket?new f(t.domain_socket,27017,e):new f(t.host,t.port,e))}e.exports={validOptions:function(e){const t=E.concat(x);for(const n in e)if(-1===C.indexOf(n)){if(-1===t.indexOf(n)){if(e.validateOptions)return new i(`option ${n} is not supported`);y(`the options [${n}] is not supported`)}-1!==x.indexOf(n)&&y(`the server/replset/mongos/db options are deprecated, all their options are supported at the top level of the options object [${E}]`)}},connect:function(e,t,n,r){if(n=Object.assign({},n),null==r)throw new Error("no callback function provided");let s=!1;const c=o("MongoClient",n);if(t instanceof f||t instanceof p||t instanceof a)return function(e,t,n,r){A(e,t),I(e,t),U(e,t);let o=Object.assign({},n);"string"!=typeof n.readPreference&&"string"!=typeof n.read_preference||(o.readPreference=new h(n.readPreference||n.read_preference));if((o.user||o.password||o.authMechanism)&&!o.credentials)try{o.credentials=D(e,o.user,o.password,o)}catch(e){return r(e,t)}return t.connect(o,r)}(e,t,n,m);const u=!1!==n.useNewUrlParser,d=u?z:L;function m(t,n){const o="seed list contains no mongos proxies, replicaset connections requires the parameter replicaSet to be supplied in the URI or options object, mongodb://server:port/db?replicaSet=name";if(t&&"no mongos proxies found in seed list"===t.message)return c.isWarn()&&c.warn(o),r(new i(o));s&&e.emit("authenticated",null,!0),r(t,n)}(u?l:w)(t,n,(t,o)=>{if(t)return r(t);const i=d(o),a=P(i,n);if(null==a.socketTimeoutMS&&(a.socketTimeoutMS=0),null==a.connectTimeoutMS&&(a.connectTimeoutMS=1e4),null==a.retryWrites&&(a.retryWrites=!0),null==a.useRecoveryToken&&(a.useRecoveryToken=!0),null==a.readPreference&&(a.readPreference="primary"),a.db_options&&a.db_options.auth&&delete a.db_options.auth,function(e){null!=e.tls&&["sslCA","sslKey","sslCert"].forEach(t=>{e[t]&&(e[t]=g.readFileSync(e[t]))})}(a),e.s.options=a,e.s.readPreference=h.fromOptions(a),e.s.writeConcern=b.fromOptions(a),0===i.servers.length)return r(new Error("connection string must contain at least one seed host"));if(a.auth&&!a.credentials)try{s=!0,a.credentials=D(e,a.auth.user,a.auth.password,a)}catch(t){return r(t)}return a.useUnifiedTopology?R(e,"unified",a,m):(y("Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor."),a.replicaSet||a.rs_name?R(e,"replicaset",a,m):i.servers.length>1?R(e,"mongos",a,m):function(e,t,n){t.promiseLibrary=e.s.promiseLibrary;const r=W(t)[0],o=k(e,r);r.connect(t,(s,i)=>{if(s)return r.close(!0),n(s);!function(e){_.forEach(t=>e.removeAllListeners(t))}(r),U(e,r),I(e,r);const a=i.lastIsMaster();if(A(e,i),a&&"isdbgrid"===a.msg)return i.close(),R(e,"mongos",t,n);!function(e,t){for(let n=0;n0?t.socketOptions:t;g=u(g,b),this.s={coreTopology:new s(m,g),sCapabilities:null,debug:g.debug,storeOptions:r,clonedOptions:g,store:d,options:t,sessionPool:null,sessions:new Set,promiseLibrary:t.promiseLibrary||Promise}}connect(e,t){var n=this;"function"==typeof e&&(t=e,e={}),null==e&&(e={}),"function"!=typeof t&&(t=null),e=Object.assign({},this.s.clonedOptions,e),n.s.options=e,n.s.storeOptions.bufferMaxEntries="number"==typeof e.bufferMaxEntries?e.bufferMaxEntries:-1;var r=function(){return function(e){["timeout","error","close"].forEach((function(e){n.removeListener(e,r)})),n.s.coreTopology.removeListener("connect",r),n.close(!0);try{t(e)}catch(e){process.nextTick((function(){throw e}))}}},o=function(e){return function(t){"error"!==e&&n.emit(e,t)}},s=function(e){return function(t,r){n.emit(e,t,r)}};["timeout","error","close","serverOpening","serverDescriptionChanged","serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","serverClosed","topologyOpening","topologyClosed","topologyDescriptionChanged","commandStarted","commandSucceeded","commandFailed"].forEach((function(e){n.s.coreTopology.removeAllListeners(e)})),n.s.coreTopology.on("serverDescriptionChanged",s("serverDescriptionChanged")),n.s.coreTopology.on("serverHeartbeatStarted",s("serverHeartbeatStarted")),n.s.coreTopology.on("serverHeartbeatSucceeded",s("serverHeartbeatSucceeded")),n.s.coreTopology.on("serverHeartbeatFailed",s("serverHeartbeatFailed")),n.s.coreTopology.on("serverOpening",s("serverOpening")),n.s.coreTopology.on("serverClosed",s("serverClosed")),n.s.coreTopology.on("topologyOpening",s("topologyOpening")),n.s.coreTopology.on("topologyClosed",s("topologyClosed")),n.s.coreTopology.on("topologyDescriptionChanged",s("topologyDescriptionChanged")),n.s.coreTopology.on("commandStarted",s("commandStarted")),n.s.coreTopology.on("commandSucceeded",s("commandSucceeded")),n.s.coreTopology.on("commandFailed",s("commandFailed")),n.s.coreTopology.once("timeout",r("timeout")),n.s.coreTopology.once("error",r("error")),n.s.coreTopology.once("close",r("close")),n.s.coreTopology.once("connect",(function(){["timeout","error","close","fullsetup"].forEach((function(e){n.s.coreTopology.removeAllListeners(e)})),n.s.coreTopology.on("timeout",o("timeout")),n.s.coreTopology.on("error",o("error")),n.s.coreTopology.on("close",o("close")),n.s.coreTopology.on("fullsetup",(function(){n.emit("fullsetup",n)})),n.emit("open",null,n);try{t(null,n)}catch(e){process.nextTick((function(){throw e}))}})),n.s.coreTopology.on("joined",s("joined")),n.s.coreTopology.on("left",s("left")),n.s.coreTopology.on("reconnect",(function(){n.emit("reconnect"),n.s.store.execute()})),n.s.coreTopology.connect(e)}}Object.defineProperty(d.prototype,"haInterval",{enumerable:!0,get:function(){return this.s.coreTopology.s.haInterval}}),e.exports=d},function(e,t,n){"use strict";const r=n(63),o=n(20),s=n(2).MongoError,i=n(28).TopologyBase,a=n(28).Store,c=n(2).ReplSet,l=n(0).MAX_JS_INT,u=n(0).translateOptions,h=n(0).filterOptions,p=n(0).mergeOptions;var f=["ha","haInterval","replicaSet","rs_name","secondaryAcceptableLatencyMS","connectWithNoPrimary","poolSize","ssl","checkServerIdentity","sslValidate","sslCA","sslCert","ciphers","ecdhCurve","sslCRL","sslKey","sslPass","socketOptions","bufferMaxEntries","store","auto_reconnect","autoReconnect","emitError","keepAlive","keepAliveInitialDelay","noDelay","connectTimeoutMS","socketTimeoutMS","strategy","debug","family","loggerLevel","logger","reconnectTries","appname","domainsEnabled","servername","promoteLongs","promoteValues","promoteBuffers","maxStalenessSeconds","promiseLibrary","minSize","monitorCommands"];class d extends i{constructor(e,t){super();var n=this;t=h(t=t||{},f);for(var i=0;i0?t.socketOptions:t;g=u(g,b);var S=new c(y,g);S.on("reconnect",(function(){n.emit("reconnect"),m.execute()})),this.s={coreTopology:S,sCapabilities:null,tag:t.tag,storeOptions:d,clonedOptions:g,store:m,options:t,sessionPool:null,sessions:new Set,promiseLibrary:t.promiseLibrary||Promise},g.debug&&Object.defineProperty(this,"replset",{enumerable:!0,get:function(){return S}})}connect(e,t){var n=this;"function"==typeof e&&(t=e,e={}),null==e&&(e={}),"function"!=typeof t&&(t=null),e=Object.assign({},this.s.clonedOptions,e),n.s.options=e,n.s.storeOptions.bufferMaxEntries="number"==typeof e.bufferMaxEntries?e.bufferMaxEntries:-1;var r=function(e){return function(t){"error"!==e&&n.emit(e,t)}};["timeout","error","close","serverOpening","serverDescriptionChanged","serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","serverClosed","topologyOpening","topologyClosed","topologyDescriptionChanged","commandStarted","commandSucceeded","commandFailed","joined","left","ping","ha"].forEach((function(e){n.s.coreTopology.removeAllListeners(e)}));var o,s=function(e){return function(t,r){n.emit(e,t,r)}};n.s.coreTopology.on("joined",(o="joined",function(e,t){n.emit(o,e,t.lastIsMaster(),t)})),n.s.coreTopology.on("left",s("left")),n.s.coreTopology.on("ping",s("ping")),n.s.coreTopology.on("ha",(function(e,t){n.emit("ha",e,t),"start"===e?n.emit("ha_connect",e,t):"end"===e&&n.emit("ha_ismaster",e,t)})),n.s.coreTopology.on("serverDescriptionChanged",s("serverDescriptionChanged")),n.s.coreTopology.on("serverHeartbeatStarted",s("serverHeartbeatStarted")),n.s.coreTopology.on("serverHeartbeatSucceeded",s("serverHeartbeatSucceeded")),n.s.coreTopology.on("serverHeartbeatFailed",s("serverHeartbeatFailed")),n.s.coreTopology.on("serverOpening",s("serverOpening")),n.s.coreTopology.on("serverClosed",s("serverClosed")),n.s.coreTopology.on("topologyOpening",s("topologyOpening")),n.s.coreTopology.on("topologyClosed",s("topologyClosed")),n.s.coreTopology.on("topologyDescriptionChanged",s("topologyDescriptionChanged")),n.s.coreTopology.on("commandStarted",s("commandStarted")),n.s.coreTopology.on("commandSucceeded",s("commandSucceeded")),n.s.coreTopology.on("commandFailed",s("commandFailed")),n.s.coreTopology.on("fullsetup",(function(){n.emit("fullsetup",n,n)})),n.s.coreTopology.on("all",(function(){n.emit("all",null,n)}));var i=function(){return function(e){["timeout","error","close"].forEach((function(e){n.s.coreTopology.removeListener(e,i)})),n.s.coreTopology.removeListener("connect",i),n.s.coreTopology.destroy();try{t(e)}catch(e){n.s.coreTopology.isConnected()||process.nextTick((function(){throw e}))}}};n.s.coreTopology.once("timeout",i("timeout")),n.s.coreTopology.once("error",i("error")),n.s.coreTopology.once("close",i("close")),n.s.coreTopology.once("connect",(function(){n.s.coreTopology.once("timeout",r("timeout")),n.s.coreTopology.once("error",r("error")),n.s.coreTopology.once("close",r("close")),n.emit("open",null,n);try{t(null,n)}catch(e){process.nextTick((function(){throw e}))}})),n.s.coreTopology.connect(e)}close(e,t){["timeout","error","close","joined","left"].forEach(e=>this.removeAllListeners(e)),super.close(e,t)}}Object.defineProperty(d.prototype,"haInterval",{enumerable:!0,get:function(){return this.s.coreTopology.s.haInterval}}),e.exports=d},function(e,t,n){"use strict";const r=n(40),o=n(9).retrieveBSON(),s=n(3).MongoError;try{!function(){var e=new Error("Cannot find module 'mongodb-client-encryption'");throw e.code="MODULE_NOT_FOUND",e}()}catch(e){throw new s("Auto-encryption requested, but the module is not installed. Please add `mongodb-client-encryption` as a dependency of your project")}const i=n(!function(){var e=new Error("Cannot find module 'mongodb-client-encryption'");throw e.code="MODULE_NOT_FOUND",e}());if("function"!=typeof i.extension)throw new s("loaded version of `mongodb-client-encryption` does not have property `extension`. Please make sure you are loading the correct version of `mongodb-client-encryption`");const a=i.extension(n(81)).AutoEncrypter,c=Symbol("internalClient");class l{constructor(e,t){this.bypassAutoEncryption=!!t.autoEncryption.bypassAutoEncryption,this.needsConnecting=!1,0===t.maxPoolSize&&null==t.autoEncryption.keyVaultClient?t.autoEncryption.keyVaultClient=e:null==t.autoEncryption.keyVaultClient&&(t.autoEncryption.keyVaultClient=this.getInternalClient(e)),this.bypassAutoEncryption?t.autoEncryption.metadataClient=void 0:0===t.maxPoolSize?t.autoEncryption.metadataClient=e:t.autoEncryption.metadataClient=this.getInternalClient(e),t.autoEncryption.bson=l.makeBSON(t),this.autoEncrypter=new a(e,t.autoEncryption)}getInternalClient(e){if(!this[c]){const t={};for(const n of Object.keys(e.s.options))-1===["autoEncryption","minPoolSize","servers","caseTranslate","dbName"].indexOf(n)&&(t[n]=e.s.options[n]);t.minPoolSize=0;const n=["commandStarted","commandSucceeded","commandFailed","serverOpening","serverClosed","serverDescriptionChanged","serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","topologyOpening","topologyClosed","topologyDescriptionChanged","joined","left","ping","ha","connectionPoolCreated","connectionPoolClosed","connectionCreated","connectionReady","connectionClosed","connectionCheckOutStarted","connectionCheckOutFailed","connectionCheckedOut","connectionCheckedIn","connectionPoolCleared"];this[c]=new r(e.s.url,t);for(const t of n)for(const n of e.listeners(t))this[c].on(t,n);e.on("newListener",(e,t)=>{this[c].on(e,t)}),this.needsConnecting=!0}return this[c]}connectInternalClient(e){return this.needsConnecting?(this.needsConnecting=!1,this[c].connect(e)):e()}close(e,t,n){this.autoEncrypter.teardown(r=>{if(this[c]&&e!==this[c])return this[c].close(t,n);n(r)})}static makeBSON(e){return(e||{}).bson||new o([o.Binary,o.Code,o.DBRef,o.Decimal128,o.Double,o.Int32,o.Long,o.Map,o.MaxKey,o.MinKey,o.ObjectId,o.BSONRegExp,o.Symbol,o.Timestamp])}}e.exports={Encrypter:l}},function(e,t,n){"use strict";var r=n(2).BSON.Binary,o=n(2).BSON.ObjectID,s=n(17).Buffer,i=function(e,t,n){if(!(this instanceof i))return new i(e,t);this.file=e;var a=null==t?{}:t;if(this.writeConcern=n||{w:1},this.objectId=null==a._id?new o:a._id,this.chunkNumber=null==a.n?0:a.n,this.data=new r,"string"==typeof a.data){var c=s.alloc(a.data.length);c.write(a.data,0,a.data.length,"binary"),this.data=new r(c)}else if(Array.isArray(a.data)){c=s.alloc(a.data.length);var l=a.data.join("");c.write(l,0,l.length,"binary"),this.data=new r(c)}else if(a.data&&"Binary"===a.data._bsontype)this.data=a.data;else if(!s.isBuffer(a.data)&&null!=a.data)throw Error("Illegal chunk format");this.internalPosition=0};i.prototype.write=function(e,t){return this.data.write(e,this.internalPosition,e.length,"binary"),this.internalPosition=this.data.length(),null!=t?t(null,this):this},i.prototype.read=function(e){if(e=null==e||0===e?this.length():e,this.length()-this.internalPosition+1>=e){var t=this.data.read(this.internalPosition,e);return this.internalPosition=this.internalPosition+e,t}return""},i.prototype.readSlice=function(e){if(this.length()-this.internalPosition>=e){var t=null;return null!=this.data.buffer?t=this.data.buffer.slice(this.internalPosition,this.internalPosition+e):(t=s.alloc(e),e=this.data.readInto(t,this.internalPosition)),this.internalPosition=this.internalPosition+e,t}return null},i.prototype.eof=function(){return this.internalPosition===this.length()},i.prototype.getc=function(){return this.read(1)},i.prototype.rewind=function(){this.internalPosition=0,this.data=new r},i.prototype.save=function(e,t){var n=this;"function"==typeof e&&(t=e,e={}),n.file.chunkCollection((function(r,o){if(r)return t(r);var s={upsert:!0};for(var i in e)s[i]=e[i];for(i in n.writeConcern)s[i]=n.writeConcern[i];n.data.length()>0?n.buildMongoObject((function(e){var r={forceServerObjectId:!0};for(var i in n.writeConcern)r[i]=n.writeConcern[i];o.replaceOne({_id:n.objectId},e,s,(function(e){t(e,n)}))})):t(null,n)}))},i.prototype.buildMongoObject=function(e){var t={files_id:this.file.fileId,n:this.chunkNumber,data:this.data};null!=this.objectId&&(t._id=this.objectId),e(t)},i.prototype.length=function(){return this.data.length()},Object.defineProperty(i.prototype,"position",{enumerable:!0,get:function(){return this.internalPosition},set:function(e){this.internalPosition=e}}),i.DEFAULT_CHUNK_SIZE=261120,e.exports=i},function(e,t,n){"use strict";var r=n(64),o=n(29),s=n(43),i=n(44),a=n(45),c=n(46),l=n(47),u=n(65),h=n(48),p=n(49),f=n(50),d=n(51),m=n(52),y=n(34),g=n(122),b=n(123),S=n(125),v=n(24),w=v.allocBuffer(17825792),O=function(){};O.prototype.serialize=function(e,t){var n="boolean"==typeof(t=t||{}).checkKeys&&t.checkKeys,r="boolean"==typeof t.serializeFunctions&&t.serializeFunctions,o="boolean"!=typeof t.ignoreUndefined||t.ignoreUndefined,s="number"==typeof t.minInternalBufferSize?t.minInternalBufferSize:17825792;w.lengthe.length)throw new Error("corrupt bson message");if(0!==e[r+o-1])throw new Error("One object, sized correctly, with a spot for an EOO, but the EOO isn't 0x00");return deserializeObject(e,r,t,n)},deserializeObject=function(e,t,n,r){var o=null!=n.evalFunctions&&n.evalFunctions,s=null!=n.cacheFunctions&&n.cacheFunctions,i=null!=n.cacheFunctionsCrc32&&n.cacheFunctionsCrc32;if(!i)var a=null;var c=null==n.fieldsAsRaw?null:n.fieldsAsRaw,l=null!=n.raw&&n.raw,u="boolean"==typeof n.bsonRegExp&&n.bsonRegExp,h=null!=n.promoteBuffers&&n.promoteBuffers,p=null==n.promoteLongs||n.promoteLongs,f=null==n.promoteValues||n.promoteValues,d=t;if(e.length<5)throw new Error("corrupt bson message < 5 bytes long");var m=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(m<5||m>e.length)throw new Error("corrupt bson message");for(var y=r?[]:{},g=0;;){var b=e[t++];if(0===b)break;for(var S=t;0!==e[S]&&S=e.length)throw new Error("Bad BSON Document: illegal CString");var v=r?g++:e.toString("utf8",t,S);if(t=S+1,b===BSON.BSON_DATA_STRING){var w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(w<=0||w>e.length-t||0!==e[t+w-1])throw new Error("bad string length in bson");y[v]=e.toString("utf8",t,t+w-1),t+=w}else if(b===BSON.BSON_DATA_OID){var O=utils.allocBuffer(12);e.copy(O,0,t,t+12),y[v]=new ObjectID(O),t+=12}else if(b===BSON.BSON_DATA_INT&&!1===f)y[v]=new Int32(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24);else if(b===BSON.BSON_DATA_INT)y[v]=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;else if(b===BSON.BSON_DATA_NUMBER&&!1===f)y[v]=new Double(e.readDoubleLE(t)),t+=8;else if(b===BSON.BSON_DATA_NUMBER)y[v]=e.readDoubleLE(t),t+=8;else if(b===BSON.BSON_DATA_DATE){var _=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,T=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;y[v]=new Date(new Long(_,T).toNumber())}else if(b===BSON.BSON_DATA_BOOLEAN){if(0!==e[t]&&1!==e[t])throw new Error("illegal boolean type value");y[v]=1===e[t++]}else if(b===BSON.BSON_DATA_OBJECT){var E=t,C=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;if(C<=0||C>e.length-t)throw new Error("bad embedded document length in bson");y[v]=l?e.slice(t,t+C):deserializeObject(e,E,n,!1),t+=C}else if(b===BSON.BSON_DATA_ARRAY){E=t;var x=n,N=t+(C=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24);if(c&&c[v]){for(var I in x={},n)x[I]=n[I];x.raw=!0}if(y[v]=deserializeObject(e,E,x,!0),0!==e[(t+=C)-1])throw new Error("invalid array terminator byte");if(t!==N)throw new Error("corrupted array bson")}else if(b===BSON.BSON_DATA_UNDEFINED)y[v]=void 0;else if(b===BSON.BSON_DATA_NULL)y[v]=null;else if(b===BSON.BSON_DATA_LONG){_=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,T=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;var A=new Long(_,T);y[v]=p&&!0===f&&A.lessThanOrEqual(JS_INT_MAX_LONG)&&A.greaterThanOrEqual(JS_INT_MIN_LONG)?A.toNumber():A}else if(b===BSON.BSON_DATA_DECIMAL128){var k=utils.allocBuffer(16);e.copy(k,0,t,t+16),t+=16;var M=new Decimal128(k);y[v]=M.toObject?M.toObject():M}else if(b===BSON.BSON_DATA_BINARY){var B=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,R=B,P=e[t++];if(B<0)throw new Error("Negative binary type element size found");if(B>e.length)throw new Error("Binary type size larger than document size");if(null!=e.slice){if(P===Binary.SUBTYPE_BYTE_ARRAY){if((B=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<0)throw new Error("Negative binary type element size found for subtype 0x02");if(B>R-4)throw new Error("Binary type with subtype 0x02 contains to long binary size");if(BR-4)throw new Error("Binary type with subtype 0x02 contains to long binary size");if(B=e.length)throw new Error("Bad BSON Document: illegal CString");var L=e.toString("utf8",t,S);for(S=t=S+1;0!==e[S]&&S=e.length)throw new Error("Bad BSON Document: illegal CString");var j=e.toString("utf8",t,S);t=S+1;var U=new Array(j.length);for(S=0;S=e.length)throw new Error("Bad BSON Document: illegal CString");for(L=e.toString("utf8",t,S),S=t=S+1;0!==e[S]&&S=e.length)throw new Error("Bad BSON Document: illegal CString");j=e.toString("utf8",t,S),t=S+1,y[v]=new BSONRegExp(L,j)}else if(b===BSON.BSON_DATA_SYMBOL){if((w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||w>e.length-t||0!==e[t+w-1])throw new Error("bad string length in bson");y[v]=new Symbol(e.toString("utf8",t,t+w-1)),t+=w}else if(b===BSON.BSON_DATA_TIMESTAMP)_=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,T=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24,y[v]=new Timestamp(_,T);else if(b===BSON.BSON_DATA_MIN_KEY)y[v]=new MinKey;else if(b===BSON.BSON_DATA_MAX_KEY)y[v]=new MaxKey;else if(b===BSON.BSON_DATA_CODE){if((w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||w>e.length-t||0!==e[t+w-1])throw new Error("bad string length in bson");var z=e.toString("utf8",t,t+w-1);if(o)if(s){var W=i?a(z):z;y[v]=isolateEvalWithHash(functionCache,W,z,y)}else y[v]=isolateEval(z);else y[v]=new Code(z);t+=w}else if(b===BSON.BSON_DATA_CODE_W_SCOPE){var q=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24;if(q<13)throw new Error("code_w_scope total size shorter minimum expected length");if((w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||w>e.length-t||0!==e[t+w-1])throw new Error("bad string length in bson");z=e.toString("utf8",t,t+w-1),E=t+=w,C=e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24;var F=deserializeObject(e,E,n,!1);if(t+=C,q<8+C+w)throw new Error("code_w_scope total size is to short, truncating scope");if(q>8+C+w)throw new Error("code_w_scope total size is to long, clips outer document");o?(s?(W=i?a(z):z,y[v]=isolateEvalWithHash(functionCache,W,z,y)):y[v]=isolateEval(z),y[v].scope=F):y[v]=new Code(z,F)}else{if(b!==BSON.BSON_DATA_DBPOINTER)throw new Error("Detected unknown BSON type "+b.toString(16)+' for fieldname "'+v+'", are you using the latest BSON parser');if((w=e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)<=0||w>e.length-t||0!==e[t+w-1])throw new Error("bad string length in bson");var $=e.toString("utf8",t,t+w-1);t+=w;var V=utils.allocBuffer(12);e.copy(V,0,t,t+12),O=new ObjectID(V),t+=12;var H=$.split("."),Y=H.shift(),K=H.join(".");y[v]=new DBRef(K,O,Y)}}if(m!==t-d){if(r)throw new Error("corrupt array bson");throw new Error("corrupt object bson")}return null!=y.$id&&(y=new DBRef(y.$ref,y.$id,y.$db)),y},isolateEvalWithHash=function(functionCache,hash,functionString,object){var value=null;return null==functionCache[hash]&&(eval("value = "+functionString),functionCache[hash]=value),functionCache[hash].bind(object)},isolateEval=function(functionString){var value=null;return eval("value = "+functionString),value},BSON={},functionCache=BSON.functionCache={};BSON.BSON_DATA_NUMBER=1,BSON.BSON_DATA_STRING=2,BSON.BSON_DATA_OBJECT=3,BSON.BSON_DATA_ARRAY=4,BSON.BSON_DATA_BINARY=5,BSON.BSON_DATA_UNDEFINED=6,BSON.BSON_DATA_OID=7,BSON.BSON_DATA_BOOLEAN=8,BSON.BSON_DATA_DATE=9,BSON.BSON_DATA_NULL=10,BSON.BSON_DATA_REGEXP=11,BSON.BSON_DATA_DBPOINTER=12,BSON.BSON_DATA_CODE=13,BSON.BSON_DATA_SYMBOL=14,BSON.BSON_DATA_CODE_W_SCOPE=15,BSON.BSON_DATA_INT=16,BSON.BSON_DATA_TIMESTAMP=17,BSON.BSON_DATA_LONG=18,BSON.BSON_DATA_DECIMAL128=19,BSON.BSON_DATA_MIN_KEY=255,BSON.BSON_DATA_MAX_KEY=127,BSON.BSON_BINARY_SUBTYPE_DEFAULT=0,BSON.BSON_BINARY_SUBTYPE_FUNCTION=1,BSON.BSON_BINARY_SUBTYPE_BYTE_ARRAY=2,BSON.BSON_BINARY_SUBTYPE_UUID=3,BSON.BSON_BINARY_SUBTYPE_MD5=4,BSON.BSON_BINARY_SUBTYPE_USER_DEFINED=128,BSON.BSON_INT32_MAX=2147483647,BSON.BSON_INT32_MIN=-2147483648,BSON.BSON_INT64_MAX=Math.pow(2,63)-1,BSON.BSON_INT64_MIN=-Math.pow(2,63),BSON.JS_INT_MAX=9007199254740992,BSON.JS_INT_MIN=-9007199254740992;var JS_INT_MAX_LONG=Long.fromNumber(9007199254740992),JS_INT_MIN_LONG=Long.fromNumber(-9007199254740992);module.exports=deserialize},function(e,t,n){"use strict";var r=n(124).writeIEEE754,o=n(29).Long,s=n(64),i=n(34).Binary,a=n(24).normalizedFunctionString,c=/\x00/,l=["$db","$ref","$id","$clusterTime"],u=function(e){return"object"==typeof e&&"[object Date]"===Object.prototype.toString.call(e)},h=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},p=function(e,t,n,r,o){e[r++]=B.BSON_DATA_STRING;var s=o?e.write(t,r,"ascii"):e.write(t,r,"utf8");e[(r=r+s+1)-1]=0;var i=e.write(n,r+4,"utf8");return e[r+3]=i+1>>24&255,e[r+2]=i+1>>16&255,e[r+1]=i+1>>8&255,e[r]=i+1&255,r=r+4+i,e[r++]=0,r},f=function(e,t,n,s,i){if(Math.floor(n)===n&&n>=B.JS_INT_MIN&&n<=B.JS_INT_MAX)if(n>=B.BSON_INT32_MIN&&n<=B.BSON_INT32_MAX){e[s++]=B.BSON_DATA_INT;var a=i?e.write(t,s,"ascii"):e.write(t,s,"utf8");s+=a,e[s++]=0,e[s++]=255&n,e[s++]=n>>8&255,e[s++]=n>>16&255,e[s++]=n>>24&255}else if(n>=B.JS_INT_MIN&&n<=B.JS_INT_MAX)e[s++]=B.BSON_DATA_NUMBER,s+=a=i?e.write(t,s,"ascii"):e.write(t,s,"utf8"),e[s++]=0,r(e,n,s,"little",52,8),s+=8;else{e[s++]=B.BSON_DATA_LONG,s+=a=i?e.write(t,s,"ascii"):e.write(t,s,"utf8"),e[s++]=0;var c=o.fromNumber(n),l=c.getLowBits(),u=c.getHighBits();e[s++]=255&l,e[s++]=l>>8&255,e[s++]=l>>16&255,e[s++]=l>>24&255,e[s++]=255&u,e[s++]=u>>8&255,e[s++]=u>>16&255,e[s++]=u>>24&255}else e[s++]=B.BSON_DATA_NUMBER,s+=a=i?e.write(t,s,"ascii"):e.write(t,s,"utf8"),e[s++]=0,r(e,n,s,"little",52,8),s+=8;return s},d=function(e,t,n,r,o){return e[r++]=B.BSON_DATA_NULL,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,r},m=function(e,t,n,r,o){return e[r++]=B.BSON_DATA_BOOLEAN,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=n?1:0,r},y=function(e,t,n,r,s){e[r++]=B.BSON_DATA_DATE,r+=s?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var i=o.fromNumber(n.getTime()),a=i.getLowBits(),c=i.getHighBits();return e[r++]=255&a,e[r++]=a>>8&255,e[r++]=a>>16&255,e[r++]=a>>24&255,e[r++]=255&c,e[r++]=c>>8&255,e[r++]=c>>16&255,e[r++]=c>>24&255,r},g=function(e,t,n,r,o){if(e[r++]=B.BSON_DATA_REGEXP,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,n.source&&null!=n.source.match(c))throw Error("value "+n.source+" must not contain null bytes");return r+=e.write(n.source,r,"utf8"),e[r++]=0,n.global&&(e[r++]=115),n.ignoreCase&&(e[r++]=105),n.multiline&&(e[r++]=109),e[r++]=0,r},b=function(e,t,n,r,o){if(e[r++]=B.BSON_DATA_REGEXP,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,null!=n.pattern.match(c))throw Error("pattern "+n.pattern+" must not contain null bytes");return r+=e.write(n.pattern,r,"utf8"),e[r++]=0,r+=e.write(n.options.split("").sort().join(""),r,"utf8"),e[r++]=0,r},S=function(e,t,n,r,o){return null===n?e[r++]=B.BSON_DATA_NULL:"MinKey"===n._bsontype?e[r++]=B.BSON_DATA_MIN_KEY:e[r++]=B.BSON_DATA_MAX_KEY,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,r},v=function(e,t,n,r,o){if(e[r++]=B.BSON_DATA_OID,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,"string"==typeof n.id)e.write(n.id,r,"binary");else{if(!n.id||!n.id.copy)throw new Error("object ["+JSON.stringify(n)+"] is not a valid ObjectId");n.id.copy(e,r,0,12)}return r+12},w=function(e,t,n,r,o){e[r++]=B.BSON_DATA_BINARY,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var s=n.length;return e[r++]=255&s,e[r++]=s>>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=B.BSON_BINARY_SUBTYPE_DEFAULT,n.copy(e,r,0,s),r+=s},O=function(e,t,n,r,o,s,i,a,c,l){for(var u=0;u>8&255,e[r++]=s>>16&255,e[r++]=s>>24&255,e[r++]=255&i,e[r++]=i>>8&255,e[r++]=i>>16&255,e[r++]=i>>24&255,r},E=function(e,t,n,r,o){return e[r++]=B.BSON_DATA_INT,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,e[r++]=255&n,e[r++]=n>>8&255,e[r++]=n>>16&255,e[r++]=n>>24&255,r},C=function(e,t,n,o,s){return e[o++]=B.BSON_DATA_NUMBER,o+=s?e.write(t,o,"ascii"):e.write(t,o,"utf8"),e[o++]=0,r(e,n,o,"little",52,8),o+=8},x=function(e,t,n,r,o,s,i){e[r++]=B.BSON_DATA_CODE,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var c=a(n),l=e.write(c,r+4,"utf8")+1;return e[r]=255&l,e[r+1]=l>>8&255,e[r+2]=l>>16&255,e[r+3]=l>>24&255,r=r+4+l-1,e[r++]=0,r},N=function(e,t,n,r,o,s,i,a,c){if(n.scope&&"object"==typeof n.scope){e[r++]=B.BSON_DATA_CODE_W_SCOPE;var l=c?e.write(t,r,"ascii"):e.write(t,r,"utf8");r+=l,e[r++]=0;var u=r,h="string"==typeof n.code?n.code:n.code.toString();r+=4;var p=e.write(h,r+4,"utf8")+1;e[r]=255&p,e[r+1]=p>>8&255,e[r+2]=p>>16&255,e[r+3]=p>>24&255,e[r+4+p-1]=0,r=r+p+4;var f=M(e,n.scope,o,r,s+1,i,a);r=f-1;var d=f-u;e[u++]=255&d,e[u++]=d>>8&255,e[u++]=d>>16&255,e[u++]=d>>24&255,e[r++]=0}else{e[r++]=B.BSON_DATA_CODE,r+=l=c?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0,h=n.code.toString();var m=e.write(h,r+4,"utf8")+1;e[r]=255&m,e[r+1]=m>>8&255,e[r+2]=m>>16&255,e[r+3]=m>>24&255,r=r+4+m-1,e[r++]=0}return r},I=function(e,t,n,r,o){e[r++]=B.BSON_DATA_BINARY,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var s=n.value(!0),a=n.position;return n.sub_type===i.SUBTYPE_BYTE_ARRAY&&(a+=4),e[r++]=255&a,e[r++]=a>>8&255,e[r++]=a>>16&255,e[r++]=a>>24&255,e[r++]=n.sub_type,n.sub_type===i.SUBTYPE_BYTE_ARRAY&&(a-=4,e[r++]=255&a,e[r++]=a>>8&255,e[r++]=a>>16&255,e[r++]=a>>24&255),s.copy(e,r,0,n.position),r+=n.position},A=function(e,t,n,r,o){e[r++]=B.BSON_DATA_SYMBOL,r+=o?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var s=e.write(n.value,r+4,"utf8")+1;return e[r]=255&s,e[r+1]=s>>8&255,e[r+2]=s>>16&255,e[r+3]=s>>24&255,r=r+4+s-1,e[r++]=0,r},k=function(e,t,n,r,o,s,i){e[r++]=B.BSON_DATA_OBJECT,r+=i?e.write(t,r,"ascii"):e.write(t,r,"utf8"),e[r++]=0;var a,c=r,l=(a=null!=n.db?M(e,{$ref:n.namespace,$id:n.oid,$db:n.db},!1,r,o+1,s):M(e,{$ref:n.namespace,$id:n.oid},!1,r,o+1,s))-c;return e[c++]=255&l,e[c++]=l>>8&255,e[c++]=l>>16&255,e[c++]=l>>24&255,a},M=function(e,t,n,r,o,i,a,M){r=r||0,(M=M||[]).push(t);var B=r+4;if(Array.isArray(t))for(var R=0;R>8&255,e[r++]=W>>16&255,e[r++]=W>>24&255,B},B={BSON_DATA_NUMBER:1,BSON_DATA_STRING:2,BSON_DATA_OBJECT:3,BSON_DATA_ARRAY:4,BSON_DATA_BINARY:5,BSON_DATA_UNDEFINED:6,BSON_DATA_OID:7,BSON_DATA_BOOLEAN:8,BSON_DATA_DATE:9,BSON_DATA_NULL:10,BSON_DATA_REGEXP:11,BSON_DATA_CODE:13,BSON_DATA_SYMBOL:14,BSON_DATA_CODE_W_SCOPE:15,BSON_DATA_INT:16,BSON_DATA_TIMESTAMP:17,BSON_DATA_LONG:18,BSON_DATA_DECIMAL128:19,BSON_DATA_MIN_KEY:255,BSON_DATA_MAX_KEY:127,BSON_BINARY_SUBTYPE_DEFAULT:0,BSON_BINARY_SUBTYPE_FUNCTION:1,BSON_BINARY_SUBTYPE_BYTE_ARRAY:2,BSON_BINARY_SUBTYPE_UUID:3,BSON_BINARY_SUBTYPE_MD5:4,BSON_BINARY_SUBTYPE_USER_DEFINED:128,BSON_INT32_MAX:2147483647,BSON_INT32_MIN:-2147483648};B.BSON_INT64_MAX=Math.pow(2,63)-1,B.BSON_INT64_MIN=-Math.pow(2,63),B.JS_INT_MAX=9007199254740992,B.JS_INT_MIN=-9007199254740992,e.exports=M},function(e,t){t.readIEEE754=function(e,t,n,r,o){var s,i,a="big"===n,c=8*o-r-1,l=(1<>1,h=-7,p=a?0:o-1,f=a?1:-1,d=e[t+p];for(p+=f,s=d&(1<<-h)-1,d>>=-h,h+=c;h>0;s=256*s+e[t+p],p+=f,h-=8);for(i=s&(1<<-h)-1,s>>=-h,h+=r;h>0;i=256*i+e[t+p],p+=f,h-=8);if(0===s)s=1-u;else{if(s===l)return i?NaN:1/0*(d?-1:1);i+=Math.pow(2,r),s-=u}return(d?-1:1)*i*Math.pow(2,s-r)},t.writeIEEE754=function(e,t,n,r,o,s){var i,a,c,l="big"===r,u=8*s-o-1,h=(1<>1,f=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,d=l?s-1:0,m=l?-1:1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=h):(i=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-i))<1&&(i--,c*=2),(t+=i+p>=1?f/c:f*Math.pow(2,1-p))*c>=2&&(i++,c/=2),i+p>=h?(a=0,i=h):i+p>=1?(a=(t*c-1)*Math.pow(2,o),i+=p):(a=t*Math.pow(2,p-1)*Math.pow(2,o),i=0));o>=8;e[n+d]=255&a,d+=m,a/=256,o-=8);for(i=i<0;e[n+d]=255&i,d+=m,i/=256,u-=8);e[n+d-m]|=128*y}},function(e,t,n){"use strict";var r=n(29).Long,o=n(43).Double,s=n(44).Timestamp,i=n(45).ObjectID,a=n(47).Symbol,c=n(46).BSONRegExp,l=n(48).Code,u=n(49),h=n(50).MinKey,p=n(51).MaxKey,f=n(52).DBRef,d=n(34).Binary,m=n(24).normalizedFunctionString,y=function(e,t,n){var r=5;if(Array.isArray(e))for(var o=0;o=b.JS_INT_MIN&&t<=b.JS_INT_MAX&&t>=b.BSON_INT32_MIN&&t<=b.BSON_INT32_MAX?(null!=e?Buffer.byteLength(e,"utf8")+1:0)+5:(null!=e?Buffer.byteLength(e,"utf8")+1:0)+9;case"undefined":return g||!S?(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1:0;case"boolean":return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+2;case"object":if(null==t||t instanceof h||t instanceof p||"MinKey"===t._bsontype||"MaxKey"===t._bsontype)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1;if(t instanceof i||"ObjectID"===t._bsontype||"ObjectId"===t._bsontype)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+13;if(t instanceof Date||"object"==typeof(w=t)&&"[object Date]"===Object.prototype.toString.call(w))return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+9;if("undefined"!=typeof Buffer&&Buffer.isBuffer(t))return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+6+t.length;if(t instanceof r||t instanceof o||t instanceof s||"Long"===t._bsontype||"Double"===t._bsontype||"Timestamp"===t._bsontype)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+9;if(t instanceof u||"Decimal128"===t._bsontype)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+17;if(t instanceof l||"Code"===t._bsontype)return null!=t.scope&&Object.keys(t.scope).length>0?(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+4+4+Buffer.byteLength(t.code.toString(),"utf8")+1+y(t.scope,n,S):(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+4+Buffer.byteLength(t.code.toString(),"utf8")+1;if(t instanceof d||"Binary"===t._bsontype)return t.sub_type===d.SUBTYPE_BYTE_ARRAY?(null!=e?Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1+4):(null!=e?Buffer.byteLength(e,"utf8")+1:0)+(t.position+1+4+1);if(t instanceof a||"Symbol"===t._bsontype)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+Buffer.byteLength(t.value,"utf8")+4+1+1;if(t instanceof f||"DBRef"===t._bsontype){var v={$ref:t.namespace,$id:t.oid};return null!=t.db&&(v.$db=t.db),(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+y(v,n,S)}return t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)?(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1:t instanceof c||"BSONRegExp"===t._bsontype?(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+Buffer.byteLength(t.pattern,"utf8")+1+Buffer.byteLength(t.options,"utf8")+1:(null!=e?Buffer.byteLength(e,"utf8")+1:0)+y(t,n,S)+1;case"function":if(t instanceof RegExp||"[object RegExp]"===Object.prototype.toString.call(t)||"[object RegExp]"===String.call(t))return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+Buffer.byteLength(t.source,"utf8")+1+(t.global?1:0)+(t.ignoreCase?1:0)+(t.multiline?1:0)+1;if(n&&null!=t.scope&&Object.keys(t.scope).length>0)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+4+4+Buffer.byteLength(m(t),"utf8")+1+y(t.scope,n,S);if(n)return(null!=e?Buffer.byteLength(e,"utf8")+1:0)+1+4+Buffer.byteLength(m(t),"utf8")+1}var w;return 0}var b={BSON_INT32_MAX:2147483647,BSON_INT32_MIN:-2147483648,JS_INT_MAX:9007199254740992,JS_INT_MIN:-9007199254740992};e.exports=y},function(e,t){e.exports=require("assert")},function(e,t){e.exports=require("os")},function(e){e.exports=JSON.parse('{"_from":"mongodb@^3.6.3","_id":"mongodb@3.6.6","_inBundle":false,"_integrity":"sha512-WlirMiuV1UPbej5JeCMqE93JRfZ/ZzqE7nJTwP85XzjAF4rRSeq2bGCb1cjfoHLOF06+HxADaPGqT0g3SbVT1w==","_location":"/mongodb","_phantomChildren":{},"_requested":{"type":"range","registry":true,"raw":"mongodb@^3.6.3","name":"mongodb","escapedName":"mongodb","rawSpec":"^3.6.3","saveSpec":null,"fetchSpec":"^3.6.3"},"_requiredBy":["/"],"_resolved":"https://registry.npmjs.org/mongodb/-/mongodb-3.6.6.tgz","_shasum":"92e3658f45424c34add3003e3046c1535c534449","_spec":"mongodb@^3.6.3","_where":"D:\\\\git\\\\vscode-database-client","bugs":{"url":"https://github.com/mongodb/node-mongodb-native/issues"},"bundleDependencies":false,"dependencies":{"bl":"^2.2.1","bson":"^1.1.4","denque":"^1.4.1","optional-require":"^1.0.2","safe-buffer":"^5.1.2","saslprep":"^1.0.0"},"deprecated":false,"description":"The official MongoDB driver for Node.js","devDependencies":{"chai":"^4.1.1","chai-subset":"^1.6.0","chalk":"^2.4.2","co":"4.6.0","coveralls":"^2.11.6","eslint":"^7.10.0","eslint-config-prettier":"^6.11.0","eslint-plugin-es":"^3.0.1","eslint-plugin-prettier":"^3.1.3","istanbul":"^0.4.5","jsdoc":"3.5.5","lodash.camelcase":"^4.3.0","mocha":"5.2.0","mocha-sinon":"^2.1.0","mongodb-extjson":"^2.1.1","mongodb-mock-server":"^1.0.1","prettier":"^1.19.1","semver":"^5.5.0","sinon":"^4.3.0","sinon-chai":"^3.2.0","snappy":"^6.3.4","spec-xunit-file":"0.0.1-3","standard-version":"^8.0.2","util.promisify":"^1.0.1","worker-farm":"^1.5.0","wtfnode":"^0.8.0","yargs":"^14.2.0"},"engines":{"node":">=4"},"files":["index.js","lib"],"homepage":"https://github.com/mongodb/node-mongodb-native","keywords":["mongodb","driver","official"],"license":"Apache-2.0","main":"index.js","name":"mongodb","optionalDependencies":{"saslprep":"^1.0.0"},"peerDependenciesMeta":{"kerberos":{"optional":true},"mongodb-client-encryption":{"optional":true},"mongodb-extjson":{"optional":true},"snappy":{"optional":true},"bson-ext":{"optional":true},"aws4":{"optional":true}},"repository":{"type":"git","url":"git+ssh://git@github.com/mongodb/node-mongodb-native.git"},"scripts":{"atlas":"mocha --opts \'{}\' ./test/manual/atlas_connectivity.test.js","bench":"node test/benchmarks/driverBench/","check:kerberos":"mocha --opts \'{}\' -t 60000 test/manual/kerberos.test.js","check:ldap":"mocha --opts \'{}\' test/manual/ldap.test.js","check:tls":"mocha --opts \'{}\' test/manual/tls_support.test.js","coverage":"istanbul cover mongodb-test-runner -- -t 60000 test/unit test/functional","format":"npm run lint -- --fix","generate-evergreen":"node .evergreen/generate_evergreen_tasks.js","lint":"eslint -v && eslint lib test","release":"standard-version -i HISTORY.md","test":"npm run lint && mocha --recursive test/functional test/unit","test-nolint":"mocha --recursive test/functional test/unit"},"version":"3.6.6"}')},function(e,t){function n(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}n.keys=function(){return[]},n.resolve=n,e.exports=n,n.id=129},function(e,t){e.exports=require("zlib")},function(e,t,n){"use strict";const r=n(5).inherits,o=n(8).EventEmitter,s=n(3).MongoError,i=n(3).MongoTimeoutError,a=n(3).MongoWriteConcernError,c=n(14),l=n(5).format,u=n(31).Msg,h=n(67),p=n(6).MESSAGE_HEADER_SIZE,f=n(6).COMPRESSION_DETAILS_SIZE,d=n(6).opcodes,m=n(23).compress,y=n(23).compressorIDs,g=n(23).uncompressibleCommands,b=n(88),S=n(17).Buffer,v=n(69),w=n(27).updateSessionFromResponse,O=n(4).eachAsync,_=n(4).makeStateMachine,T=n(0).now,E="destroying",C="destroyed",x=_({disconnected:["connecting","draining","disconnected"],connecting:["connecting","connected","draining","disconnected"],connected:["connected","disconnected","draining"],draining:["draining",E,C],[E]:[E,C],[C]:[C]}),N=new Set(["error","close","timeout","parseError","connect","message"]);var I=0,A=function(e,t){if(o.call(this),this.topology=e,this.s={state:"disconnected",cancellationToken:new o},this.s.cancellationToken.setMaxListeners(1/0),this.options=Object.assign({host:"localhost",port:27017,size:5,minSize:0,connectionTimeout:3e4,socketTimeout:0,keepAlive:!0,keepAliveInitialDelay:12e4,noDelay:!0,ssl:!1,checkServerIdentity:!0,ca:null,crl:null,cert:null,key:null,passphrase:null,rejectUnauthorized:!1,promoteLongs:!0,promoteValues:!0,promoteBuffers:!1,reconnect:!0,reconnectInterval:1e3,reconnectTries:30,domainsEnabled:!1,legacyCompatMode:!0},t),this.id=I++,this.retriesLeft=this.options.reconnectTries,this.reconnectId=null,this.reconnectError=null,!t.bson||t.bson&&("function"!=typeof t.bson.serialize||"function"!=typeof t.bson.deserialize))throw new Error("must pass in valid bson parser");this.logger=c("Pool",t),this.availableConnections=[],this.inUseConnections=[],this.connectingConnections=0,this.executing=!1,this.queue=[],this.numberOfConsecutiveTimeouts=0,this.connectionIndex=0;const n=this;var r;this._messageHandler=(r=this,function(e,t){for(var n=null,o=0;oe.options.reconnectTries))return e.numberOfConsecutiveTimeouts=0,e.destroy(!0),e.emit("close",e);0===e.socketCount()&&(e.state!==C&&e.state!==E&&"draining"!==e.state&&e.options.reconnect&&x(e,"disconnected"),t="error"===t?"close":t,e.emit(t,n)),!e.reconnectId&&e.options.reconnect&&(e.reconnectError=n,e.reconnectId=setTimeout(B(e),e.options.reconnectInterval));P(e){null==n&&(e.reconnectId=null,e.retriesLeft=e.options.reconnectTries,e.emit("reconnect",e)),"function"==typeof t&&t(n,r)})}else"function"==typeof t&&t(new s("Cannot create connection when pool is destroyed"))}}function R(e,t,n){var r=t.indexOf(e);-1!==r&&(t.splice(r,1),n.push(e))}function P(e){return e.availableConnections.length+e.inUseConnections.length+e.connectingConnections}function D(e,t,n,r){x(e,E),e.s.cancellationToken.emit("cancel"),O(t,(e,t)=>{for(const t of N)e.removeAllListeners(t);e.on("error",()=>{}),e.destroy(n,t)},t=>{t?"function"==typeof r&&r(t,null):(k(e),e.queue=[],x(e,C),"function"==typeof r&&r(null,null))})}function L(e,t,n){const r=t.toBin();if(!!!e.options.agreedCompressor||!function(e){const t=e instanceof u?e.command:e.query,n=Object.keys(t)[0];return!g.has(n)}(t))return n(null,r);const o=S.concat(r),s=o.slice(p),i=o.readInt32LE(12);m(e,s,(function(r,o){if(r)return n(r,null);const a=S.alloc(p);a.writeInt32LE(p+f+o.length,0),a.writeInt32LE(t.requestId,4),a.writeInt32LE(0,8),a.writeInt32LE(d.OP_COMPRESSED,12);const c=S.alloc(f);return c.writeInt32LE(i,0),c.writeInt32LE(s.length,4),c.writeUInt8(y[e.options.agreedCompressor],8),n(null,[a,c,o])}))}function j(e,t){for(var n=0;n(e.connectingConnections--,n?(e.logger.isDebug()&&e.logger.debug(`connection attempt failed with error [${JSON.stringify(n)}]`),!e.reconnectId&&e.options.reconnect?"connecting"===e.state&&e.options.legacyCompatMode?void t(n):(e.reconnectError=n,void(e.reconnectId=setTimeout(B(e,t),e.options.reconnectInterval))):void("function"==typeof t&&t(n))):e.state===C||e.state===E?("function"==typeof t&&t(new s("Pool was destroyed after connection creation")),void r.destroy()):(r.on("error",e._connectionErrorHandler),r.on("close",e._connectionCloseHandler),r.on("timeout",e._connectionTimeoutHandler),r.on("parseError",e._connectionParseErrorHandler),r.on("message",e._messageHandler),e.availableConnections.push(r),"function"==typeof t&&t(null,r),void q(e)())))):"function"==typeof t&&t(new s("Cannot create connection when pool is destroyed"))}function W(e){for(var t=0;t0)e.executing=!1;else{for(;;){const i=P(e);if(0===e.availableConnections.length){W(e.queue),i0&&z(e);break}if(0===e.queue.length)break;var t=null;const a=e.availableConnections.filter(e=>0===e.workItems.length);if(!(t=0===a.length?e.availableConnections[e.connectionIndex++%e.availableConnections.length]:a[e.connectionIndex++%a.length]).isConnected()){U(e,t),W(e.queue);break}var n=e.queue.shift();if(n.monitoring){var r=!1;for(let n=0;n0&&z(e),setTimeout(()=>q(e)(),10);break}}if(i0){e.queue.unshift(n),z(e);break}var o=n.buffer;n.monitoring&&R(t,e.availableConnections,e.inUseConnections),n.noResponse||t.workItems.push(n),n.immediateRelease||"number"!=typeof n.socketTimeout||t.setSocketTimeout(n.socketTimeout);var s=!0;if(Array.isArray(o))for(let e=0;e{if(t)return"function"==typeof e?(this.destroy(),void e(t)):("connecting"===this.state&&this.emit("error",t),void this.destroy());if(x(this,"connected"),this.minSize)for(let e=0;e0;){var o=n.queue.shift();"function"==typeof o.cb&&o.cb(new s("Pool was force destroyed"))}return D(n,r,{force:!0},t)}this.reconnectId&&clearTimeout(this.reconnectId),function e(){if(n.state!==C&&n.state!==E)if(W(n.queue),0===n.queue.length){for(var r=n.availableConnections.concat(n.inUseConnections),o=0;o0)return setTimeout(e,1);D(n,r,{force:!1},t)}else q(n)(),setTimeout(e,1);else"function"==typeof t&&t()}()}else"function"==typeof t&&t(null,null)},A.prototype.reset=function(e){if("connected"!==this.s.state)return void("function"==typeof e&&e(new s("pool is not connected, reset aborted")));this.s.cancellationToken.emit("cancel");const t=this.availableConnections.concat(this.inUseConnections);O(t,(e,t)=>{for(const t of N)e.removeAllListeners(t);e.destroy({force:!0},t)},t=>{t&&"function"==typeof e?e(t,null):(k(this),z(this,()=>{"function"==typeof e&&e(null,null)}))})},A.prototype.write=function(e,t,n){var r=this;if("function"==typeof t&&(n=t),t=t||{},"function"!=typeof n&&!t.noResponse)throw new s("write method must provide a callback");if(this.state!==C&&this.state!==E)if("draining"!==this.state){if(this.options.domainsEnabled&&process.domain&&"function"==typeof n){var o=n;n=process.domain.bind((function(){for(var e=new Array(arguments.length),t=0;t{t?r.emit("commandFailed",new b.CommandFailedEvent(this,e,t,i.started)):o&&o.result&&(0===o.result.ok||o.result.$err)?r.emit("commandFailed",new b.CommandFailedEvent(this,e,o.result,i.started)):r.emit("commandSucceeded",new b.CommandSucceededEvent(this,e,o,i.started)),"function"==typeof n&&n(t,o)}),L(r,e,(e,n)=>{if(e)throw e;i.buffer=n,t.monitoring?r.queue.unshift(i):r.queue.push(i),r.executing||process.nextTick((function(){q(r)()}))})}else n(new s("pool is draining, new operations prohibited"));else n(new s("pool destroyed"))},A._execute=q,e.exports=A},function(e,t){e.exports=require("net")},function(e,t){e.exports=require("tls")},function(e,t,n){"use strict";const{unassigned_code_points:r,commonly_mapped_to_nothing:o,non_ASCII_space_characters:s,prohibited_characters:i,bidirectional_r_al:a,bidirectional_l:c}=n(135);e.exports=function(e,t={}){if("string"!=typeof e)throw new TypeError("Expected string.");if(0===e.length)return"";const n=p(e).map(e=>l.get(e)?32:e).filter(e=>!u.get(e)),o=String.fromCodePoint.apply(null,n).normalize("NFKC"),s=p(o);if(s.some(e=>i.get(e)))throw new Error("Prohibited character, see https://tools.ietf.org/html/rfc4013#section-2.3");if(!0!==t.allowUnassigned){if(s.some(e=>r.get(e)))throw new Error("Unassigned code point, see https://tools.ietf.org/html/rfc4013#section-2.5")}const f=s.some(e=>a.get(e)),d=s.some(e=>c.get(e));if(f&&d)throw new Error("String must not contain RandALCat and LCat at the same time, see https://tools.ietf.org/html/rfc3454#section-6");const m=a.get(h((g=o,g[0]))),y=a.get(h((e=>e[e.length-1])(o)));var g;if(f&&(!m||!y))throw new Error("Bidirectional RandALCat character must be the first and the last character of the string, see https://tools.ietf.org/html/rfc3454#section-6");return o};const l=s,u=o,h=e=>e.codePointAt(0);function p(e){const t=[],n=e.length;for(let r=0;r=55296&&o<=56319&&n>r+1){const n=e.charCodeAt(r+1);if(n>=56320&&n<=57343){t.push(1024*(o-55296)+n-56320+65536),r+=1;continue}}t.push(o)}return t}},function(e,t,n){"use strict";(function(t){const r=n(70),o=n(136),s=n(137),i=r.readFileSync(o.resolve(t,"../code-points.mem"));let a=0;function c(){const e=i.readUInt32BE(a);a+=4;const t=i.slice(a,a+e);return a+=e,s({buffer:t})}const l=c(),u=c(),h=c(),p=c(),f=c(),d=c();e.exports={unassigned_code_points:l,commonly_mapped_to_nothing:u,non_ASCII_space_characters:h,prohibited_characters:p,bidirectional_r_al:f,bidirectional_l:d}}).call(this,"node_modules\\saslprep\\lib")},function(e,t){e.exports=require("path")},function(e,t,n){var r=n(138);function o(e){if(!(this instanceof o))return new o(e);if(e||(e={}),Buffer.isBuffer(e)&&(e={buffer:e}),this.pageOffset=e.pageOffset||0,this.pageSize=e.pageSize||1024,this.pages=e.pages||r(this.pageSize),this.byteLength=this.pages.length*this.pageSize,this.length=8*this.byteLength,(t=this.pageSize)&t-1)throw new Error("The page size should be a power of two");var t;if(this._trackUpdates=!!e.trackUpdates,this._pageMask=this.pageSize-1,e.buffer){for(var n=0;n>t)},o.prototype.getByte=function(e){var t=e&this._pageMask,n=(e-t)/this.pageSize,r=this.pages.get(n,!0);return r?r.buffer[t+this.pageOffset]:0},o.prototype.set=function(e,t){var n=7&e,r=(e-n)/8,o=this.getByte(r);return this.setByte(r,t?o|128>>n:o&(255^128>>n))},o.prototype.toBuffer=function(){for(var e=function(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t}(this.pages.length*this.pageSize),t=0;t=this.byteLength&&(this.byteLength=e+1,this.length=8*this.byteLength),this._trackUpdates&&this.pages.updated(o),!0)}},function(e,t){function n(e,t){if(!(this instanceof n))return new n(e,t);this.length=0,this.updates=[],this.path=new Uint16Array(4),this.pages=new Array(32768),this.maxPages=this.pages.length,this.level=0,this.pageSize=e||1024,this.deduplicate=t?t.deduplicate:null,this.zeros=this.deduplicate?r(this.deduplicate.length):null}function r(e){if(Buffer.alloc)return Buffer.alloc(e);var t=new Buffer(e);return t.fill(0),t}function o(e,t){this.offset=e*t.length,this.buffer=t,this.updated=!1,this.deduplicate=0}e.exports=n,n.prototype.updated=function(e){for(;this.deduplicate&&e.buffer[e.deduplicate]===this.deduplicate[e.deduplicate];)if(e.deduplicate++,e.deduplicate===this.deduplicate.length){e.deduplicate=0,e.buffer.equals&&e.buffer.equals(this.deduplicate)&&(e.buffer=this.deduplicate);break}!e.updated&&this.updates&&(e.updated=!0,this.updates.push(e))},n.prototype.lastUpdate=function(){if(!this.updates||!this.updates.length)return null;var e=this.updates.pop();return e.updated=!1,e},n.prototype._array=function(e,t){if(e>=this.maxPages){if(t)return;!function(e,t){for(;e.maxPages0;s--){var i=this.path[s],a=o[i];if(!a){if(t)return;a=o[i]=new Array(32768)}o=a}return o},n.prototype.get=function(e,t){var n,s,i=this._array(e,t),a=this.path[0],c=i&&i[a];return c||t||(c=i[a]=new o(e,r(this.pageSize)),e>=this.length&&(this.length=e+1)),c&&c.buffer===this.deduplicate&&this.deduplicate&&!t&&(c.buffer=(n=c.buffer,s=Buffer.allocUnsafe?Buffer.allocUnsafe(n.length):new Buffer(n.length),n.copy(s),s),c.deduplicate=0),c},n.prototype.set=function(e,t){var n=this._array(e,!1),s=this.path[0];if(e>=this.length&&(this.length=e+1),!t||this.zeros&&t.equals&&t.equals(this.zeros))n[s]=void 0;else{this.deduplicate&&t.equals&&t.equals(this.deduplicate)&&(t=this.deduplicate);var i=n[s],a=function(e,t){if(e.length===t)return e;if(e.length>t)return e.slice(0,t);var n=r(t);return e.copy(n),n}(t,this.pageSize);i?i.buffer=a:n[s]=new o(e,a)}},n.prototype.toBuffer=function(){for(var e=new Array(this.length),t=r(this.pageSize),n=0;n{e.setEncoding("utf8");let r="";e.on("data",e=>r+=e),e.on("end",()=>{if(!1!==t.json)try{const e=JSON.parse(r);n(void 0,e)}catch(e){n(new s(`Invalid JSON response: "${r}"`))}else n(void 0,r)})});r.on("error",e=>n(e)),r.end()}e.exports=class extends r{auth(e,t){const n=e.connection,r=e.credentials;if(c(n)<9)return void t(new s("MONGODB-AWS authentication requires MongoDB version 4.4 or later"));if(null==u)return void t(new s("MONGODB-AWS authentication requires the `aws4` module, please install it as a dependency of your project"));if(null==r.username)return void function(e,t){function n(n){null!=n.AccessKeyId&&null!=n.SecretAccessKey&&null!=n.Token?t(void 0,new o({username:n.AccessKeyId,password:n.SecretAccessKey,source:e.source,mechanism:"MONGODB-AWS",mechanismProperties:{AWS_SESSION_TOKEN:n.Token}})):t(new s("Could not obtain temporary MONGODB-AWS credentials"))}if(process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI)return void d("http://169.254.170.2"+process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI,(e,r)=>{if(e)return t(e);n(r)});d(h+"/latest/api/token",{method:"PUT",json:!1,headers:{"X-aws-ec2-metadata-token-ttl-seconds":30}},(e,r)=>{if(e)return t(e);d(`${h}/${p}`,{json:!1,headers:{"X-aws-ec2-metadata-token":r}},(e,o)=>{if(e)return t(e);d(`${h}/${p}/${o}`,{headers:{"X-aws-ec2-metadata-token":r}},(e,r)=>{if(e)return t(e);n(r)})})})}(r,(n,r)=>{if(n)return t(n);e.credentials=r,this.auth(e,t)});const a=r.username,l=r.password,m=r.source,y=r.mechanismProperties.AWS_SESSION_TOKEN,g=this.bson;i.randomBytes(32,(e,r)=>{if(e)return void t(e);const o={saslStart:1,mechanism:"MONGODB-AWS",payload:g.serialize({r:r,p:110})};n.command(m+".$cmd",o,(e,o)=>{if(e)return t(e);const i=o.result,c=g.deserialize(i.payload.buffer),h=c.h,p=c.s.buffer;if(64!==p.length)return void t(new s(`Invalid server nonce length ${p.length}, expected 64`));if(0!==p.compare(r,0,r.length,0,r.length))return void t(new s("Server nonce does not begin with client nonce"));if(h.length<1||h.length>255||-1!==h.indexOf(".."))return void t(new s(`Server returned an invalid host: "${h}"`));const d="Action=GetCallerIdentity&Version=2011-06-15",b=u.sign({method:"POST",host:h,region:f(c.h),service:"sts",headers:{"Content-Type":"application/x-www-form-urlencoded","Content-Length":d.length,"X-MongoDB-Server-Nonce":p.toString("base64"),"X-MongoDB-GS2-CB-Flag":"n"},path:"/",body:d},{accessKeyId:a,secretAccessKey:l,token:y}),S={a:b.headers.Authorization,d:b.headers["X-Amz-Date"]};y&&(S.t=y);const v={saslContinue:1,conversationId:1,payload:g.serialize(S)};n.command(m+".$cmd",v,e=>{if(e)return t(e);t()})})})}}},function(e,t){e.exports=require("http")},function(e,t,n){"use strict";const r=n(3).MongoError,o=n(6).collectionNamespace,s=n(36),i=n(0).decorateWithExplain,a=n(56).Explain;e.exports=function(e,t,n,c,l,u,h){if(0===l.length)throw new r(t+" must contain at least one document");"function"==typeof u&&(h=u,u={});const p="boolean"!=typeof(u=u||{}).ordered||u.ordered,f=u.writeConcern;let d={};if(d[t]=o(c),d[n]=l,d.ordered=p,f&&Object.keys(f).length>0&&(d.writeConcern=f),u.collation)for(let e=0;e{};const h=n.cursorId;if(a(e)<4){const o=e.s.bson,s=e.s.pool,i=new r(o,t,[h]),a={immediateRelease:!0,noResponse:!0};if("object"==typeof n.session&&(a.session=n.session),s&&s.isConnected())try{s.write(i,a,u)}catch(e){"function"==typeof u?u(e,null):c(e)}return}const p={killCursors:i(t),cursors:[h]},f={};"object"==typeof n.session&&(f.session=n.session),l(e,t,p,f,(e,t)=>{if(e)return u(e);const n=t.message;return n.cursorNotFound?u(new s("cursor killed or timed out"),null):Array.isArray(n.documents)&&0!==n.documents.length?void u(null,n.documents[0]):u(new o("invalid killCursors result returned for cursor id "+h))})}},function(e,t,n){"use strict";const r=n(16).GetMore,o=n(9).retrieveBSON,s=n(3).MongoError,i=n(3).MongoNetworkError,a=o().Long,c=n(6).collectionNamespace,l=n(4).maxWireVersion,u=n(6).applyCommonQueryOptions,h=n(36);e.exports=function(e,t,n,o,p,f){p=p||{};const d=l(e);function m(e,t){if(e)return f(e);const r=t.message;if(r.cursorNotFound)return f(new i("cursor killed or timed out"),null);if(d<4){const e="number"==typeof r.cursorId?a.fromNumber(r.cursorId):r.cursorId;return n.documents=r.documents,n.cursorId=e,void f(null,null,r.connection)}if(0===r.documents[0].ok)return f(new s(r.documents[0]));const o="number"==typeof r.documents[0].cursor.id?a.fromNumber(r.documents[0].cursor.id):r.documents[0].cursor.id;n.documents=r.documents[0].cursor.nextBatch,n.cursorId=o,f(null,r.documents[0],r.connection)}if(d<4){const s=e.s.bson,i=new r(s,t,n.cursorId,{numberToReturn:o}),a=u({},n);return void e.s.pool.write(i,a,m)}const y={getMore:n.cursorId instanceof a?n.cursorId:a.fromNumber(n.cursorId),collection:c(t),batchSize:Math.abs(o)};n.cmd.tailable&&"number"==typeof n.cmd.maxAwaitTimeMS&&(y.maxTimeMS=n.cmd.maxAwaitTimeMS);const g=Object.assign({returnFieldSelector:null,documentsReturnedIn:"nextBatch"},p);n.session&&(g.session=n.session),h(e,t,y,g,m)}},function(e,t,n){"use strict";const r=n(16).Query,o=n(3).MongoError,s=n(6).getReadPreference,i=n(6).collectionNamespace,a=n(6).isSharded,c=n(4).maxWireVersion,l=n(6).applyCommonQueryOptions,u=n(36),h=n(0).decorateWithExplain,p=n(56).Explain;e.exports=function(e,t,n,f,d,m){if(d=d||{},null!=f.cursorId)return m();if(null==n)return m(new o(`command ${JSON.stringify(n)} does not return a cursor`));if(c(e)<4){const i=function(e,t,n,i,c){c=c||{};const l=e.s.bson,u=s(n,c);i.batchSize=n.batchSize||i.batchSize;let h=0;h=i.limit<0||0!==i.limit&&i.limit0&&0===i.batchSize?i.limit:i.batchSize;const p=i.skip||0,f={};a(e)&&u&&(f.$readPreference=u.toJSON());n.sort&&(f.$orderby=n.sort);n.hint&&(f.$hint=n.hint);n.snapshot&&(f.$snapshot=n.snapshot);void 0!==n.returnKey&&(f.$returnKey=n.returnKey);n.maxScan&&(f.$maxScan=n.maxScan);n.min&&(f.$min=n.min);n.max&&(f.$max=n.max);void 0!==n.showDiskLoc&&(f.$showDiskLoc=n.showDiskLoc);n.comment&&(f.$comment=n.comment);n.maxTimeMS&&(f.$maxTimeMS=n.maxTimeMS);void 0!==c.explain&&(h=-Math.abs(n.limit||0),f.$explain=!0);if(f.$query=n.query,n.readConcern&&"local"!==n.readConcern.level)throw new o("server find command does not support a readConcern level of "+n.readConcern.level);n.readConcern&&delete(n=Object.assign({},n)).readConcern;const d="boolean"==typeof c.serializeFunctions&&c.serializeFunctions,m="boolean"==typeof c.ignoreUndefined&&c.ignoreUndefined,y=new r(l,t,f,{numberToSkip:p,numberToReturn:h,pre32Limit:void 0!==n.limit?n.limit:void 0,checkKeys:!1,returnFieldSelector:n.fields,serializeFunctions:d,ignoreUndefined:m});"boolean"==typeof n.tailable&&(y.tailable=n.tailable);"boolean"==typeof n.oplogReplay&&(y.oplogReplay=n.oplogReplay);"boolean"==typeof n.noCursorTimeout&&(y.noCursorTimeout=n.noCursorTimeout);"boolean"==typeof n.awaitData&&(y.awaitData=n.awaitData);"boolean"==typeof n.partial&&(y.partial=n.partial);return y.slaveOk=u.slaveOk(),y}(e,t,n,f,d),c=l({},f);return"string"==typeof i.documentsReturnedIn&&(c.documentsReturnedIn=i.documentsReturnedIn),void e.s.pool.write(i,c,m)}const y=s(n,d);let g=function(e,t,n,r){r.batchSize=n.batchSize||r.batchSize;const o={find:i(t)};n.query&&(n.query.$query?o.filter=n.query.$query:o.filter=n.query);let s=n.sort;if(Array.isArray(s)){const e={};if(s.length>0&&!Array.isArray(s[0])){let t=s[1];"asc"===t?t=1:"desc"===t&&(t=-1),e[s[0]]=t}else for(let t=0;te.name===t);if(n>=0){return e.s.connectingServers[n].destroy({force:!0}),e.s.connectingServers.splice(n,1),s()}var r=new h(Object.assign({},e.s.options,{host:t.split(":")[0],port:parseInt(t.split(":")[1],10),reconnect:!1,monitoring:!1,parent:e}));r.once("connect",i(e,"connect")),r.once("close",i(e,"close")),r.once("timeout",i(e,"timeout")),r.once("error",i(e,"error")),r.once("parseError",i(e,"parseError")),r.on("serverOpening",t=>e.emit("serverOpening",t)),r.on("serverDescriptionChanged",t=>e.emit("serverDescriptionChanged",t)),r.on("serverClosed",t=>e.emit("serverClosed",t)),g(r,e,["commandStarted","commandSucceeded","commandFailed"]),e.s.connectingServers.push(r),r.connect(e.s.connectOptions)}),n)}for(var c=0;c0&&e.emit(t,n)}N.prototype.connect=function(e){var t=this;this.s.connectOptions=e||{},E(this,"connecting");var n=this.s.seedlist.map((function(n){return new h(Object.assign({},t.s.options,n,e,{reconnect:!1,monitoring:!1,parent:t}))}));if(this.s.options.socketTimeout>0&&this.s.options.socketTimeout<=this.s.options.haInterval)return t.emit("error",new u(o("haInterval [%s] MS must be set to less than socketTimeout [%s] MS",this.s.options.haInterval,this.s.options.socketTimeout)));D(this,"topologyOpening",{topologyId:this.id}),function(e,t){e.s.connectingServers=e.s.connectingServers.concat(t);var n=0;function r(t,n){setTimeout((function(){e.s.replicaSetState.update(t)&&t.lastIsMaster()&&t.lastIsMaster().ismaster&&(e.ismaster=t.lastIsMaster()),t.once("close",P(e,"close")),t.once("timeout",P(e,"timeout")),t.once("parseError",P(e,"parseError")),t.once("error",P(e,"error")),t.once("connect",P(e,"connect")),t.on("serverOpening",t=>e.emit("serverOpening",t)),t.on("serverDescriptionChanged",t=>e.emit("serverDescriptionChanged",t)),t.on("serverClosed",t=>e.emit("serverClosed",t)),g(t,e,["commandStarted","commandSucceeded","commandFailed"]),t.connect(e.s.connectOptions)}),n)}for(;t.length>0;)r(t.shift(),n++)}(t,n)},N.prototype.auth=function(e,t){"function"==typeof t&&t(null,null)},N.prototype.destroy=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{};let n=this.s.connectingServers.length+1;const r=()=>{n--,n>0||(D(this,"topologyClosed",{topologyId:this.id}),"function"==typeof t&&t(null,null))};if(this.state!==T){E(this,T),this.haTimeoutId&&clearTimeout(this.haTimeoutId);for(var o=0;o{if(!o)return n(null,s);if(!w(o,r))return o=S(o),n(o);if(c){return L(Object.assign({},e,{retrying:!0}),t,n)}return r.s.replicaSetState.primary&&(r.s.replicaSetState.primary.destroy(),r.s.replicaSetState.remove(r.s.replicaSetState.primary,{force:!0})),n(o)};n.operationId&&(l.operationId=n.operationId),c&&(t.session.incrementTransactionNumber(),t.willRetryWrite=c),r.s.replicaSetState.primary[s](i,a,t,l)}N.prototype.selectServer=function(e,t,n){let r,o;"function"==typeof e&&void 0===n&&(n=e,e=void 0,t={}),"function"==typeof t&&(n=t,t=e),t=t||{},r=e instanceof i?e:t.readPreference||i.primary;const s=O(),a=()=>{if(_(s)>=1e4)return void(null!=o?n(o,null):n(new u("Server selection timed out")));const e=this.s.replicaSetState.pickServer(r);if(null!=e){if(!(e instanceof h))return o=e,void setTimeout(a,1e3);this.s.debug&&this.emit("pickedServer",t.readPreference,e),n(null,e)}else setTimeout(a,1e3)};a()},N.prototype.getServers=function(){return this.s.replicaSetState.allServers()},N.prototype.insert=function(e,t,n,r){L({self:this,op:"insert",ns:e,ops:t},n,r)},N.prototype.update=function(e,t,n,r){L({self:this,op:"update",ns:e,ops:t},n,r)},N.prototype.remove=function(e,t,n,r){L({self:this,op:"remove",ns:e,ops:t},n,r)};const j=["findAndModify","insert","update","delete"];N.prototype.command=function(e,t,n,r){if("function"==typeof n&&(r=n,n=(n={})||{}),this.state===T)return r(new u(o("topology was destroyed")));var s=this,a=n.readPreference?n.readPreference:i.primary;if("primary"===a.preference&&!this.s.replicaSetState.hasPrimary()&&null!=this.s.disconnectHandler)return this.s.disconnectHandler.add("command",e,t,n,r);if("secondary"===a.preference&&!this.s.replicaSetState.hasSecondary()&&null!=this.s.disconnectHandler)return this.s.disconnectHandler.add("command",e,t,n,r);if("primary"!==a.preference&&!this.s.replicaSetState.hasSecondary()&&!this.s.replicaSetState.hasPrimary()&&null!=this.s.disconnectHandler)return this.s.disconnectHandler.add("command",e,t,n,r);var c=this.s.replicaSetState.pickServer(a);if(!(c instanceof h))return r(c);if(s.s.debug&&s.emit("pickedServer",i.primary,c),null==c)return r(new u(o("no server found that matches the provided readPreference %s",a)));const l=!n.retrying&&!!n.retryWrites&&n.session&&y(s)&&!n.session.inTransaction()&&(p=t,j.some(e=>p[e]));var p;l&&(n.session.incrementTransactionNumber(),n.willRetryWrite=l),c.command(e,t,n,(o,i)=>{if(!o)return r(null,i);if(!w(o,s))return r(o);if(l){const o=Object.assign({},n,{retrying:!0});return this.command(e,t,o,r)}return this.s.replicaSetState.primary&&(this.s.replicaSetState.primary.destroy(),this.s.replicaSetState.remove(this.s.replicaSetState.primary,{force:!0})),r(o)})},N.prototype.cursor=function(e,t,n){const r=(n=n||{}).topology||this;return new(n.cursorFactory||this.s.Cursor)(r,e,t,n)},e.exports=N},function(e,t,n){"use strict";var r=n(5).inherits,o=n(5).format,s=n(7).diff,i=n(8).EventEmitter,a=n(14),c=n(10),l=n(3).MongoError,u=n(17).Buffer,h="ReplicaSetNoPrimary",p="ReplicaSetWithPrimary",f="Unknown",d="PossiblePrimary",m="RSPrimary",y="RSSecondary",g="RSArbiter",b="RSOther",S="RSGhost",v="Unknown",w=function(e){e=e||{},i.call(this),this.topologyType=h,this.setName=e.setName,this.set={},this.id=e.id,this.setName=e.setName,this.logger=e.logger||a("ReplSet",e),this.index=0,this.acceptableLatency=e.acceptableLatency||15,this.heartbeatFrequencyMS=e.heartbeatFrequencyMS||1e4,this.primary=null,this.secondaries=[],this.arbiters=[],this.passives=[],this.ghosts=[],this.unknownServers=[],this.set={},this.maxElectionId=null,this.maxSetVersion=0,this.replicasetDescription={topologyType:"Unknown",servers:[]},this.logicalSessionTimeoutMinutes=void 0};r(w,i),w.prototype.hasPrimaryAndSecondary=function(){return null!=this.primary&&this.secondaries.length>0},w.prototype.hasPrimaryOrSecondary=function(){return this.hasPrimary()||this.hasSecondary()},w.prototype.hasPrimary=function(){return null!=this.primary},w.prototype.hasSecondary=function(){return this.secondaries.length>0},w.prototype.get=function(e){for(var t=this.allServers(),n=0;n{r--,r>0||(this.secondaries=[],this.arbiters=[],this.passives=[],this.ghosts=[],this.unknownServers=[],this.set={},this.primary=null,A(this),"function"==typeof t&&t(null,null))};0!==r?n.forEach(t=>t.destroy(e,o)):o()},w.prototype.remove=function(e,t){t=t||{};var n=e.name.toLowerCase(),r=this.primary?[this.primary]:[];r=(r=(r=r.concat(this.secondaries)).concat(this.arbiters)).concat(this.passives);for(var o=0;oe.arbiterOnly&&e.setName;w.prototype.update=function(e){var t=e.lastIsMaster(),n=e.name.toLowerCase();if(t){var r=Array.isArray(t.hosts)?t.hosts:[];r=(r=(r=r.concat(Array.isArray(t.arbiters)?t.arbiters:[])).concat(Array.isArray(t.passives)?t.passives:[])).map((function(e){return e.toLowerCase()}));for(var s=0;sc)return!1}else if(!u&&i&&c&&c=5&&e.ismaster.secondary&&this.hasPrimary()?e.staleness=e.lastUpdateTime-e.lastWriteDate-(this.primary.lastUpdateTime-this.primary.lastWriteDate)+t:e.ismaster.maxWireVersion>=5&&e.ismaster.secondary&&(e.staleness=n-e.lastWriteDate+t)},w.prototype.updateSecondariesMaxStaleness=function(e){for(var t=0;t0&&null==e.maxStalenessSeconds){var o=E(this,e);if(o)return o}else if(r.length>0&&null!=e.maxStalenessSeconds&&(o=T(this,e)))return o;return e.equals(c.secondaryPreferred)?this.primary:null}if(e.equals(c.primaryPreferred)){if(o=null,this.primary)return this.primary;if(r.length>0&&null==e.maxStalenessSeconds?o=E(this,e):r.length>0&&null!=e.maxStalenessSeconds&&(o=T(this,e)),o)return o}return this.primary};var _=function(e,t){if(null==e.tags)return t;for(var n=[],r=Array.isArray(e.tags)?e.tags:[e.tags],o=0;o0?n[0].lastIsMasterMS:0;if(0===(n=n.filter((function(t){return t.lastIsMasterMS<=o+e.acceptableLatency}))).length)return null;e.index=e.index%n.length;var s=n[e.index];return e.index=e.index+1,s}function C(e,t,n){for(var r=0;r0){var t="Unknown",n=e.setName;e.hasPrimaryAndSecondary()?t="ReplicaSetWithPrimary":!e.hasPrimary()&&e.hasSecondary()&&(t="ReplicaSetNoPrimary");var r={topologyType:t,setName:n,servers:[]};if(e.hasPrimary()){var o=e.primary.getDescription();o.type="RSPrimary",r.servers.push(o)}r.servers=r.servers.concat(e.secondaries.map((function(e){var t=e.getDescription();return t.type="RSSecondary",t}))),r.servers=r.servers.concat(e.arbiters.map((function(e){var t=e.getDescription();return t.type="RSArbiter",t}))),r.servers=r.servers.concat(e.passives.map((function(e){var t=e.getDescription();return t.type="RSSecondary",t})));var i=s(e.replicasetDescription,r),a={topologyId:e.id,previousDescription:e.replicasetDescription,newDescription:r,diff:i};e.emit("topologyDescriptionChanged",a),e.replicasetDescription=r}}e.exports=w},function(e,t,n){"use strict";const r=n(5).inherits,o=n(5).format,s=n(8).EventEmitter,i=n(15).CoreCursor,a=n(14),c=n(9).retrieveBSON,l=n(3).MongoError,u=n(68),h=n(7).diff,p=n(7).cloneOptions,f=n(7).SessionMixins,d=n(7).isRetryableWritesSupported,m=n(4).relayEvents,y=c(),g=n(7).getMMAPError,b=n(4).makeClientMetadata,S=n(7).legacyIsRetryableWriteError;var v="destroying",w="destroyed";function O(e,t){var n={disconnected:["connecting",v,w,"disconnected"],connecting:["connecting",v,w,"connected","disconnected"],connected:["connected","disconnected",v,w,"unreferenced"],unreferenced:["unreferenced",v,w],destroyed:[w]}[e.state];n&&-1!==n.indexOf(t)?e.state=t:e.s.logger.error(o("Mongos with id [%s] failed attempted illegal state transition from [%s] to [%s] only following state allowed [%s]",e.id,e.state,t,n))}var _=1,T=["connect","close","error","timeout","parseError"],E=function(e,t){t=t||{},this.id=_++,Array.isArray(e)&&(e=e.reduce((e,t)=>(e.find(e=>e.host===t.host&&e.port===t.port)||e.push(t),e),[])),this.s={options:Object.assign({metadata:b(t)},t),bson:t.bson||new y([y.Binary,y.Code,y.DBRef,y.Decimal128,y.Double,y.Int32,y.Long,y.Map,y.MaxKey,y.MinKey,y.ObjectId,y.BSONRegExp,y.Symbol,y.Timestamp]),Cursor:t.cursorFactory||i,logger:a("Mongos",t),seedlist:e,haInterval:t.haInterval?t.haInterval:1e4,disconnectHandler:t.disconnectHandler,index:0,connectOptions:{},debug:"boolean"==typeof t.debug&&t.debug,localThresholdMS:t.localThresholdMS||15},this.s.logger.isWarn()&&0!==this.s.options.socketTimeout&&this.s.options.socketTimeout0&&e.emit(t,n)}r(E,s),Object.assign(E.prototype,f),Object.defineProperty(E.prototype,"type",{enumerable:!0,get:function(){return"mongos"}}),Object.defineProperty(E.prototype,"parserType",{enumerable:!0,get:function(){return y.native?"c++":"js"}}),Object.defineProperty(E.prototype,"logicalSessionTimeoutMinutes",{enumerable:!0,get:function(){return this.ismaster&&this.ismaster.logicalSessionTimeoutMinutes||null}});const x=["serverDescriptionChanged","error","close","timeout","parseError"];function N(e,t,n){t=t||{},x.forEach(t=>e.removeAllListeners(t)),e.destroy(t,n)}function I(e){return function(){e.state!==w&&e.state!==v&&(M(e.connectedProxies,e.disconnectedProxies,this),L(e),e.emit("left","mongos",this),e.emit("serverClosed",{topologyId:e.id,address:this.name}))}}function A(e,t){return function(){if(e.state===w)return L(e),M(e.connectingProxies,e.disconnectedProxies,this),this.destroy();if("connect"===t)if(e.ismaster=this.lastIsMaster(),"isdbgrid"===e.ismaster.msg){for(let t=0;t0&&"connecting"===e.state)O(e,"connected"),e.emit("connect",e),e.emit("fullsetup",e),e.emit("all",e);else if(0===e.disconnectedProxies.length)return e.s.logger.isWarn()&&e.s.logger.warn(o("no mongos proxies found in seed list, did you mean to connect to a replicaset")),e.emit("error",new l("no mongos proxies found in seed list"));!function e(t,n){if(n=n||{},t.state===w||t.state===v||"unreferenced"===t.state)return;t.haTimeoutId=setTimeout((function(){if(t.state!==w&&t.state!==v&&"unreferenced"!==t.state){t.isConnected()&&t.s.disconnectHandler&&t.s.disconnectHandler.execute();var r=t.connectedProxies.slice(0),o=r.length;if(0===r.length)return t.listeners("close").length>0&&"connecting"===t.state?t.emit("error",new l("no mongos proxy available")):t.emit("close",t),R(t,t.disconnectedProxies,(function(){t.state!==w&&t.state!==v&&"unreferenced"!==t.state&&("connecting"===t.state&&n.firstConnect?(t.emit("connect",t),t.emit("fullsetup",t),t.emit("all",t)):t.isConnected()?t.emit("reconnect",t):!t.isConnected()&&t.listeners("close").length>0&&t.emit("close",t),e(t))}));for(var s=0;s{if(!o)return n(null,s);if(!S(o,r)||!c)return o=g(o),n(o);if(a=k(r,t.session),!a)return n(o);return P(Object.assign({},e,{retrying:!0}),t,n)};n.operationId&&(u.operationId=n.operationId),c&&(t.session.incrementTransactionNumber(),t.willRetryWrite=c),a[o](s,i,t,u)}E.prototype.connect=function(e){var t=this;this.s.connectOptions=e||{},O(this,"connecting");var n=this.s.seedlist.map((function(n){const r=new u(Object.assign({},t.s.options,n,e,{reconnect:!1,monitoring:!1,parent:t}));return m(r,t,["serverDescriptionChanged"]),r}));C(this,"topologyOpening",{topologyId:this.id}),function(e,t){e.connectingProxies=e.connectingProxies.concat(t);var n=0;t.forEach(t=>function(t,n){setTimeout((function(){e.emit("serverOpening",{topologyId:e.id,address:t.name}),L(e),t.once("close",A(e,"close")),t.once("timeout",A(e,"timeout")),t.once("parseError",A(e,"parseError")),t.once("error",A(e,"error")),t.once("connect",A(e,"connect")),m(t,e,["commandStarted","commandSucceeded","commandFailed"]),t.connect(e.s.connectOptions)}),n)}(t,n++))}(t,n)},E.prototype.auth=function(e,t){"function"==typeof t&&t(null,null)},E.prototype.lastIsMaster=function(){return this.ismaster},E.prototype.unref=function(){O(this,"unreferenced"),this.connectedProxies.concat(this.connectingProxies).forEach((function(e){e.unref()})),clearTimeout(this.haTimeoutId)},E.prototype.destroy=function(e,t){"function"==typeof e&&(t=e,e={}),e=e||{},O(this,v),this.haTimeoutId&&clearTimeout(this.haTimeoutId);const n=this.connectedProxies.concat(this.connectingProxies);let r=n.length;const o=()=>{r--,r>0||(L(this),C(this,"topologyClosed",{topologyId:this.id}),O(this,w),"function"==typeof t&&t(null,null))};0!==r?n.forEach(t=>{this.emit("serverClosed",{topologyId:this.id,address:t.name}),N(t,e,o),M(this.connectedProxies,this.disconnectedProxies,t)}):o()},E.prototype.isConnected=function(){return this.connectedProxies.length>0},E.prototype.isDestroyed=function(){return this.state===w},E.prototype.insert=function(e,t,n,r){return"function"==typeof n&&(r=n,n=(n={})||{}),this.state===w?r(new l(o("topology was destroyed"))):this.isConnected()||null==this.s.disconnectHandler?this.isConnected()?void P({self:this,op:"insert",ns:e,ops:t},n,r):r(new l("no mongos proxy available")):this.s.disconnectHandler.add("insert",e,t,n,r)},E.prototype.update=function(e,t,n,r){return"function"==typeof n&&(r=n,n=(n={})||{}),this.state===w?r(new l(o("topology was destroyed"))):this.isConnected()||null==this.s.disconnectHandler?this.isConnected()?void P({self:this,op:"update",ns:e,ops:t},n,r):r(new l("no mongos proxy available")):this.s.disconnectHandler.add("update",e,t,n,r)},E.prototype.remove=function(e,t,n,r){return"function"==typeof n&&(r=n,n=(n={})||{}),this.state===w?r(new l(o("topology was destroyed"))):this.isConnected()||null==this.s.disconnectHandler?this.isConnected()?void P({self:this,op:"remove",ns:e,ops:t},n,r):r(new l("no mongos proxy available")):this.s.disconnectHandler.add("remove",e,t,n,r)};const D=["findAndModify","insert","update","delete"];function L(e){if(e.listeners("topologyDescriptionChanged").length>0){var t="Unknown";e.connectedProxies.length>0&&(t="Sharded");var n={topologyType:t,servers:[]},r=e.disconnectedProxies.concat(e.connectingProxies);n.servers=n.servers.concat(r.map((function(e){var t=e.getDescription();return t.type="Unknown",t}))),n.servers=n.servers.concat(e.connectedProxies.map((function(e){var t=e.getDescription();return t.type="Mongos",t})));var o=h(e.topologyDescription,n),s={topologyId:e.id,previousDescription:e.topologyDescription,newDescription:n,diff:o};o.servers.length>0&&e.emit("topologyDescriptionChanged",s),e.topologyDescription=n}}E.prototype.command=function(e,t,n,r){if("function"==typeof n&&(r=n,n=(n={})||{}),this.state===w)return r(new l(o("topology was destroyed")));var s=this,i=k(s,n.session);if((null==i||!i.isConnected())&&null!=this.s.disconnectHandler)return this.s.disconnectHandler.add("command",e,t,n,r);if(null==i)return r(new l("no mongos proxy available"));var a=p(n);a.topology=s;const c=!n.retrying&&n.retryWrites&&n.session&&d(s)&&!n.session.inTransaction()&&(u=t,D.some(e=>u[e]));var u;c&&(a.session.incrementTransactionNumber(),a.willRetryWrite=c),i.command(e,t,a,(n,o)=>{if(!n)return r(null,o);if(!S(n,s))return r(n);if(c){const n=Object.assign({},a,{retrying:!0});return this.command(e,t,n,r)}return r(n)})},E.prototype.cursor=function(e,t,n){const r=(n=n||{}).topology||this;return new(n.cursorFactory||this.s.Cursor)(r,e,t,n)},E.prototype.selectServer=function(e,t,n){"function"==typeof e&&void 0===n&&(n=e,e=void 0,t={}),"function"==typeof t&&(n=t,t=e,e=void 0);const r=k(this,(t=t||{}).session);null!=r?(this.s.debug&&this.emit("pickedServer",null,r),n(null,r)):n(new l("server selection failed"))},E.prototype.connections=function(){for(var e=[],t=0;t({host:e.split(":")[0],port:e.split(":")[1]||27017}))}(e)),t=Object.assign({},M.TOPOLOGY_DEFAULTS,t),t=Object.freeze(Object.assign(t,{metadata:N(t),compression:{compressors:g(t)}})),H.forEach(e=>{t[e]&&C(`The option \`${e}\` is incompatible with the unified topology, please read more by visiting http://bit.ly/2D8WfT6`,"DeprecationWarning")});const n=function(e,t){if(t.directConnection)return c.Single;if(null==(t.replicaSet||t.setName||t.rs_name))return c.Unknown;return c.ReplicaSetNoPrimary}(0,t),o=j++,i=e.reduce((e,t)=>{t.domain_socket&&(t.host=t.domain_socket);const n=t.port?`${t.host}:${t.port}`:t.host+":27017";return e.set(n,new s(n)),e},new Map);this[K]=new r,this.s={id:o,options:t,seedlist:e,state:q,description:new a(n,i,t.replicaSet,null,null,null,t),serverSelectionTimeoutMS:t.serverSelectionTimeoutMS,heartbeatFrequencyMS:t.heartbeatFrequencyMS,minHeartbeatFrequencyMS:t.minHeartbeatFrequencyMS,Cursor:t.cursorFactory||d,bson:t.bson||new y([y.Binary,y.Code,y.DBRef,y.Decimal128,y.Double,y.Int32,y.Long,y.Map,y.MaxKey,y.MinKey,y.ObjectId,y.BSONRegExp,y.Symbol,y.Timestamp]),servers:new Map,sessionPool:new x(this),sessions:new Set,promiseLibrary:t.promiseLibrary||Promise,credentials:t.credentials,clusterTime:null,connectionTimers:new Set},t.srvHost&&(this.s.srvPoller=t.srvPoller||new O({heartbeatFrequencyMS:this.s.heartbeatFrequencyMS,srvHost:t.srvHost,logger:t.logger,loggerLevel:t.loggerLevel}),this.s.detectTopologyDescriptionChange=e=>{const t=e.previousDescription.type,n=e.newDescription.type;var r;t!==c.Sharded&&n===c.Sharded&&(this.s.handleSrvPolling=(r=this,function(e){const t=r.s.description;r.s.description=r.s.description.updateFromSrvPollingEvent(e),r.s.description!==t&&(Q(r),r.emit("topologyDescriptionChanged",new l.TopologyDescriptionChangedEvent(r.s.id,t,r.s.description)))}),this.s.srvPoller.on("srvRecordDiscovery",this.s.handleSrvPolling),this.s.srvPoller.start())},this.on("topologyDescriptionChanged",this.s.detectTopologyDescriptionChange)),this.setMaxListeners(1/0)}get description(){return this.s.description}get parserType(){return y.native?"c++":"js"}connect(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},this.s.state===$)return void("function"==typeof t&&t());var n,r;V(this,F),this.emit("topologyOpening",new l.TopologyOpeningEvent(this.s.id)),this.emit("topologyDescriptionChanged",new l.TopologyDescriptionChangedEvent(this.s.id,new a(c.Unknown),this.s.description)),n=this,r=Array.from(this.s.description.servers.values()),n.s.servers=r.reduce((e,t)=>{const r=Z(n,t);return e.set(t.address,r),e},new Map),p.translate(e);const o=e.readPreference||p.primary,s=e=>{if(e)return this.close(),void("function"==typeof t?t(e):this.emit("error",e));V(this,$),this.emit("open",e,this),this.emit("connect",this),"function"==typeof t&&t(e,this)};this.s.credentials?this.command("admin.$cmd",{ping:1},{readPreference:o},s):this.selectServer(D(o),e,s)}close(e,t){"function"==typeof e&&(t=e,e={}),"boolean"==typeof e&&(e={force:e}),e=e||{},this.s.state!==q&&this.s.state!==W?(V(this,W),ne(this[K],new S("Topology closed")),B(this.s.connectionTimers),this.s.srvPoller&&(this.s.srvPoller.stop(),this.s.handleSrvPolling&&(this.s.srvPoller.removeListener("srvRecordDiscovery",this.s.handleSrvPolling),delete this.s.handleSrvPolling)),this.s.detectTopologyDescriptionChange&&(this.removeListener("topologyDescriptionChanged",this.s.detectTopologyDescriptionChange),delete this.s.detectTopologyDescriptionChange),this.s.sessions.forEach(e=>e.endSession()),this.s.sessionPool.endAllPooledSessions(()=>{E(Array.from(this.s.servers.values()),(t,n)=>J(t,this,e,n),e=>{this.s.servers.clear(),this.emit("topologyClosed",new l.TopologyClosedEvent(this.s.id)),V(this,q),this.emit("close"),"function"==typeof t&&t(e)})})):"function"==typeof t&&t()}selectServer(e,t,n){if("function"==typeof t)if(n=t,"function"!=typeof e){let n;t=e,e instanceof p?n=e:"string"==typeof e?n=new p(e):(p.translate(t),n=t.readPreference||p.primary),e=D(n)}else t={};t=Object.assign({},{serverSelectionTimeoutMS:this.s.serverSelectionTimeoutMS},t);const r=this.description.type===c.Sharded,o=t.session,s=o&&o.transaction;if(r&&s&&s.server)return void n(void 0,s.server);let i=e;if("object"==typeof e){const t=e.readPreference?e.readPreference:p.primary;i=D(t)}const a={serverSelector:i,transaction:s,callback:n},l=t.serverSelectionTimeoutMS;l&&(a.timer=setTimeout(()=>{a[Y]=!0,a.timer=void 0;const e=new v(`Server selection timed out after ${l} ms`,this.description);a.callback(e)},l)),this[K].push(a),re(this)}shouldCheckForSessionSupport(){return this.description.type===c.Single?!this.description.hasKnownServers:!this.description.hasDataBearingServers}hasSessionSupport(){return null!=this.description.logicalSessionTimeoutMinutes}startSession(e,t){const n=new b(this,this.s.sessionPool,e,t);return n.once("ended",()=>{this.s.sessions.delete(n)}),this.s.sessions.add(n),n}endSessions(e,t){Array.isArray(e)||(e=[e]),this.command("admin.$cmd",{endSessions:e},{readPreference:p.primaryPreferred,noResponse:!0},()=>{"function"==typeof t&&t()})}serverUpdateHandler(e){if(!this.s.description.hasServer(e.address))return;if(function(e,t){const n=e.servers.get(t.address).topologyVersion;return A(n,t.topologyVersion)>0}(this.s.description,e))return;const t=this.s.description,n=this.s.description.servers.get(e.address),r=e.$clusterTime;r&&w(this,r);const o=n&&n.equals(e);this.s.description=this.s.description.update(e),this.s.description.compatibilityError?this.emit("error",new S(this.s.description.compatibilityError)):(o||this.emit("serverDescriptionChanged",new l.ServerDescriptionChangedEvent(this.s.id,e.address,n,this.s.description.servers.get(e.address))),Q(this,e),this[K].length>0&&re(this),o||this.emit("topologyDescriptionChanged",new l.TopologyDescriptionChangedEvent(this.s.id,t,this.s.description)))}auth(e,t){"function"==typeof e&&(t=e,e=null),"function"==typeof t&&t(null,!0)}logout(e){"function"==typeof e&&e(null,!0)}insert(e,t,n,r){ee({topology:this,op:"insert",ns:e,ops:t},n,r)}update(e,t,n,r){ee({topology:this,op:"update",ns:e,ops:t},n,r)}remove(e,t,n,r){ee({topology:this,op:"remove",ns:e,ops:t},n,r)}command(e,t,n,r){"function"==typeof n&&(r=n,n=(n={})||{}),p.translate(n);const o=n.readPreference||p.primary;this.selectServer(D(o),n,(o,s)=>{if(o)return void r(o);const i=!n.retrying&&!!n.retryWrites&&n.session&&f(this)&&!n.session.inTransaction()&&(a=t,X.some(e=>a[e]));var a;i&&(n.session.incrementTransactionNumber(),n.willRetryWrite=i),s.command(e,t,n,(o,s)=>{if(!o)return r(null,s);if(!te(o))return r(o);if(i){const o=Object.assign({},n,{retrying:!0});return this.command(e,t,o,r)}return r(o)})})}cursor(e,t,n){const r=(n=n||{}).topology||this,o=n.cursorFactory||this.s.Cursor;return p.translate(n),new o(r,e,t,n)}get clientMetadata(){return this.s.options.metadata}isConnected(){return this.s.state===$}isDestroyed(){return this.s.state===q}unref(){k("not implemented: `unref`")}lastIsMaster(){const e=Array.from(this.description.servers.values());if(0===e.length)return{};return e.filter(e=>e.type!==i.Unknown)[0]||{maxWireVersion:this.description.commonWireVersion}}get logicalSessionTimeoutMinutes(){return this.description.logicalSessionTimeoutMinutes}get bson(){return this.s.bson}}Object.defineProperty(G.prototype,"clusterTime",{enumerable:!0,get:function(){return this.s.clusterTime},set:function(e){this.s.clusterTime=e}}),G.prototype.destroy=m(G.prototype.close,"destroy() is deprecated, please use close() instead");const X=["findAndModify","insert","update","delete"];function J(e,t,n,r){n=n||{},z.forEach(t=>e.removeAllListeners(t)),e.destroy(n,()=>{t.emit("serverClosed",new l.ServerClosedEvent(t.s.id,e.description.address)),U.forEach(t=>e.removeAllListeners(t)),"function"==typeof r&&r()})}function Z(e,t,n){e.emit("serverOpening",new l.ServerOpeningEvent(e.s.id,t.address));const r=new u(t,e.s.options,e);if(h(r,e,U),r.on("descriptionReceived",e.serverUpdateHandler.bind(e)),n){const t=setTimeout(()=>{R(t,e.s.connectionTimers),r.connect()},n);return e.s.connectionTimers.add(t),r}return r.connect(),r}function Q(e,t){if(t&&e.s.servers.has(t.address)){e.s.servers.get(t.address).s.description=t}for(const t of e.description.servers.values())if(!e.s.servers.has(t.address)){const n=Z(e,t);e.s.servers.set(t.address,n)}for(const t of e.s.servers){const n=t[0];if(e.description.hasServer(n))continue;const r=e.s.servers.get(n);e.s.servers.delete(n),J(r,e)}}function ee(e,t,n){"function"==typeof t&&(n=t,t={}),t=t||{};const r=e.topology,o=e.op,s=e.ns,i=e.ops,a=!e.retrying&&!!t.retryWrites&&t.session&&f(r)&&!t.session.inTransaction()&&void 0===t.explain;r.selectServer(L(),t,(r,c)=>{if(r)return void n(r,null);const l=(r,o)=>{if(!r)return n(null,o);if(!te(r))return r=_(r),n(r);if(a){return ee(Object.assign({},e,{retrying:!0}),t,n)}return n(r)};n.operationId&&(l.operationId=n.operationId),a&&(t.session.incrementTransactionNumber(),t.willRetryWrite=a),c[o](s,i,t,l)})}function te(e){return e instanceof S&&e.hasErrorLabel("RetryableWriteError")}function ne(e,t){for(;e.length;){const n=e.shift();clearTimeout(n.timer),n[Y]||n.callback(t)}}function re(e){if(e.s.state===q)return void ne(e[K],new S("Topology is closed, please connect"));const t=Array.from(e.description.servers.values()),n=e[K].length;for(let o=0;o0&&e.s.servers.forEach(e=>process.nextTick(()=>e.requestCheck()))}e.exports={Topology:G}},function(e,t,n){"use strict";const r=n(8),o=n(150).ConnectionPool,s=n(58).CMAP_EVENT_NAMES,i=n(3).MongoError,a=n(4).relayEvents,c=n(9).retrieveBSON(),l=n(14),u=n(30).ServerDescription,h=n(30).compareTopologyVersion,p=n(10),f=n(162).Monitor,d=n(3).MongoNetworkError,m=n(3).MongoNetworkTimeoutError,y=n(4).collationNotSupported,g=n(9).debugOptions,b=n(3).isSDAMUnrecoverableError,S=n(3).isRetryableWriteError,v=n(3).isNodeShuttingDownError,w=n(3).isNetworkErrorBeforeHandshake,O=n(4).maxWireVersion,_=n(4).makeStateMachine,T=n(12),E=T.ServerType,C=n(35).isTransactionCommand,x=["reconnect","reconnectTries","reconnectInterval","emitError","cursorFactory","host","port","size","keepAlive","keepAliveInitialDelay","noDelay","connectionTimeout","checkServerIdentity","socketTimeout","ssl","ca","crl","cert","key","rejectUnauthorized","promoteLongs","promoteValues","promoteBuffers","servername"],N=T.STATE_CLOSING,I=T.STATE_CLOSED,A=T.STATE_CONNECTING,k=T.STATE_CONNECTED,M=_({[I]:[I,A],[A]:[A,N,k,I],[k]:[k,N,I],[N]:[N,I]}),B=Symbol("monitor");class R extends r{constructor(e,t,n){super(),this.s={description:e,options:t,logger:l("Server",t),bson:t.bson||new c([c.Binary,c.Code,c.DBRef,c.Decimal128,c.Double,c.Int32,c.Long,c.Map,c.MaxKey,c.MinKey,c.ObjectId,c.BSONRegExp,c.Symbol,c.Timestamp]),state:I,credentials:t.credentials,topology:n};const r=Object.assign({host:this.description.host,port:this.description.port,bson:this.s.bson},t);this.s.pool=new o(r),a(this.s.pool,this,["commandStarted","commandSucceeded","commandFailed"].concat(s)),this.s.pool.on("clusterTimeReceived",e=>{this.clusterTime=e}),this[B]=new f(this,this.s.options),a(this[B],this,["serverHeartbeatStarted","serverHeartbeatSucceeded","serverHeartbeatFailed","monitoring"]),this[B].on("resetConnectionPool",()=>{this.s.pool.clear()}),this[B].on("resetServer",e=>L(this,e)),this[B].on("serverHeartbeatSucceeded",e=>{this.emit("descriptionReceived",new u(this.description.address,e.reply,{roundTripTime:P(this.description.roundTripTime,e.duration)})),this.s.state===A&&(M(this,k),this.emit("connect",this))})}get description(){return this.s.description}get name(){return this.s.description.address}get autoEncrypter(){return this.s.options&&this.s.options.autoEncrypter?this.s.options.autoEncrypter:null}connect(){this.s.state===I&&(M(this,A),this[B].connect())}destroy(e,t){"function"==typeof e&&(t=e,e={}),e=Object.assign({},{force:!1},e),this.s.state!==I?(M(this,N),this[B].close(),this.s.pool.close(e,e=>{M(this,I),this.emit("closed"),"function"==typeof t&&t(e)})):"function"==typeof t&&t()}requestCheck(){this[B].requestCheck()}command(e,t,n,r){if("function"==typeof n&&(r=n,n=(n={})||{}),this.s.state===N||this.s.state===I)return void r(new i("server is closed"));const o=function(e,t){if(t.readPreference&&!(t.readPreference instanceof p))return new i("readPreference must be an instance of ReadPreference")}(0,n);if(o)return r(o);n=Object.assign({},n,{wireProtocolCommand:!1}),this.s.logger.isDebug()&&this.s.logger.debug(`executing command [${JSON.stringify({ns:e,cmd:t,options:g(x,n)})}] against ${this.name}`),y(this,t)?r(new i(`server ${this.name} does not support collation`)):this.s.pool.withConnection((r,o,s)=>{if(r)return L(this,r),s(r);o.command(e,t,n,U(this,o,t,n,s))},r)}query(e,t,n,r,o){this.s.state!==N&&this.s.state!==I?this.s.pool.withConnection((o,s,i)=>{if(o)return L(this,o),i(o);s.query(e,t,n,r,U(this,s,t,r,i))},o):o(new i("server is closed"))}getMore(e,t,n,r,o){this.s.state!==N&&this.s.state!==I?this.s.pool.withConnection((o,s,i)=>{if(o)return L(this,o),i(o);s.getMore(e,t,n,r,U(this,s,null,r,i))},o):o(new i("server is closed"))}killCursors(e,t,n){this.s.state!==N&&this.s.state!==I?this.s.pool.withConnection((n,r,o)=>{if(n)return L(this,n),o(n);r.killCursors(e,t,U(this,r,null,void 0,o))},n):"function"==typeof n&&n(new i("server is closed"))}insert(e,t,n,r){D({server:this,op:"insert",ns:e,ops:t},n,r)}update(e,t,n,r){D({server:this,op:"update",ns:e,ops:t},n,r)}remove(e,t,n,r){D({server:this,op:"remove",ns:e,ops:t},n,r)}}function P(e,t){if(-1===e)return t;return.2*t+.8*e}function D(e,t,n){"function"==typeof t&&(n=t,t={}),t=t||{};const r=e.server,o=e.op,s=e.ns,a=Array.isArray(e.ops)?e.ops:[e.ops];if(r.s.state===N||r.s.state===I)return void n(new i("server is closed"));if(y(r,t))return void n(new i(`server ${r.name} does not support collation`));!(t.writeConcern&&0===t.writeConcern.w||O(r)<5)||"update"!==o&&"remove"!==o||!a.find(e=>e.hint)?r.s.pool.withConnection((e,n,i)=>{if(e)return L(r,e),i(e);n[o](s,a,t,U(r,n,a,t,i))},n):n(new i("servers < 3.4 do not support hint on "+o))}function L(e,t){t instanceof d&&!(t instanceof m)&&e[B].reset(),e.emit("descriptionReceived",new u(e.description.address,null,{error:t,topologyVersion:t&&t.topologyVersion?t.topologyVersion:e.description.topologyVersion}))}function j(e,t){return e&&e.inTransaction()&&!C(t)}function U(e,t,n,r,o){const s=r&&r.session;return function(r,i){r&&!function(e,t){return t.generation!==e.generation}(e.s.pool,t)&&(r instanceof d?(s&&!s.hasEnded&&(s.serverSession.isDirty=!0),function(e){return e.description.maxWireVersion>=6&&e.description.logicalSessionTimeoutMinutes&&e.description.type!==E.Standalone}(e)&&!j(s,n)&&r.addErrorLabel("RetryableWriteError"),r instanceof m&&!w(r)||(L(e,r),e.s.pool.clear())):(O(e)<9&&S(r)&&!j(s,n)&&r.addErrorLabel("RetryableWriteError"),b(r)&&function(e,t){const n=t.topologyVersion,r=e.description.topologyVersion;return h(r,n)<0}(e,r)&&((O(e)<=7||v(r))&&e.s.pool.clear(),L(e,r),process.nextTick(()=>e.requestCheck())))),o(r,i)}}Object.defineProperty(R.prototype,"clusterTime",{get:function(){return this.s.topology.clusterTime},set:function(e){this.s.topology.clusterTime=e}}),e.exports={Server:R}},function(e,t,n){"use strict";const r=n(72),o=n(8).EventEmitter,s=n(14),i=n(0).makeCounter,a=n(3).MongoError,c=n(97).Connection,l=n(4).eachAsync,u=n(69),h=n(4).relayEvents,p=n(161),f=p.PoolClosedError,d=p.WaitQueueTimeoutError,m=n(58),y=m.ConnectionPoolCreatedEvent,g=m.ConnectionPoolClosedEvent,b=m.ConnectionCreatedEvent,S=m.ConnectionReadyEvent,v=m.ConnectionClosedEvent,w=m.ConnectionCheckOutStartedEvent,O=m.ConnectionCheckOutFailedEvent,_=m.ConnectionCheckedOutEvent,T=m.ConnectionCheckedInEvent,E=m.ConnectionPoolClearedEvent,C=Symbol("logger"),x=Symbol("connections"),N=Symbol("permits"),I=Symbol("minPoolSizeTimer"),A=Symbol("generation"),k=Symbol("connectionCounter"),M=Symbol("cancellationToken"),B=Symbol("waitQueue"),R=Symbol("cancelled"),P=new Set(["ssl","bson","connectionType","monitorCommands","socketTimeout","credentials","compression","host","port","localAddress","localPort","family","hints","lookup","path","ca","cert","sigalgs","ciphers","clientCertEngine","crl","dhparam","ecdhCurve","honorCipherOrder","key","privateKeyEngine","privateKeyIdentifier","maxVersion","minVersion","passphrase","pfx","secureOptions","secureProtocol","sessionIdContext","allowHalfOpen","rejectUnauthorized","pskCallback","ALPNProtocols","servername","checkServerIdentity","session","minDHSize","secureContext","maxPoolSize","minPoolSize","maxIdleTimeMS","waitQueueTimeoutMS"]);function D(e,t){return t.generation!==e[A]}function L(e,t){return!!(e.options.maxIdleTimeMS&&t.idleTime>e.options.maxIdleTimeMS)}function j(e,t){const n=Object.assign({id:e[k].next().value,generation:e[A]},e.options);e[N]--,u(n,e[M],(n,r)=>{if(n)return e[N]++,e[C].debug(`connection attempt failed with error [${JSON.stringify(n)}]`),void("function"==typeof t&&t(n));e.closed?r.destroy({force:!0}):(h(r,e,["commandStarted","commandFailed","commandSucceeded","clusterTimeReceived"]),e.emit("connectionCreated",new b(e,r)),r.markAvailable(),e.emit("connectionReady",new S(e,r)),"function"!=typeof t?(e[x].push(r),process.nextTick(()=>z(e))):t(void 0,r))})}function U(e,t,n){e.emit("connectionClosed",new v(e,t,n)),e[N]++,process.nextTick(()=>t.destroy())}function z(e){if(e.closed)return;for(;e.waitQueueSize;){const t=e[B].peekFront();if(t[R]){e[B].shift();continue}if(!e.availableConnectionCount)break;const n=e[x].shift(),r=D(e,n),o=L(e,n);if(!r&&!o&&!n.closed)return e.emit("connectionCheckedOut",new _(e,n)),clearTimeout(t.timer),e[B].shift(),void t.callback(void 0,n);const s=n.closed?"error":r?"stale":"idle";U(e,n,s)}const t=e.options.maxPoolSize;e.waitQueueSize&&(t<=0||e.totalConnectionCount{const r=e[B].shift();null==r||r[R]?null==t&&e[x].push(n):(t?e.emit("connectionCheckOutFailed",new O(e,t)):e.emit("connectionCheckedOut",new _(e,n)),clearTimeout(r.timer),r.callback(t,n))})}e.exports={ConnectionPool:class extends o{constructor(e){if(super(),e=e||{},this.closed=!1,this.options=function(e,t){const n=Array.from(P).reduce((t,n)=>(Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]),t),{});return Object.freeze(Object.assign({},t,n))}(e,{connectionType:c,maxPoolSize:"number"==typeof e.maxPoolSize?e.maxPoolSize:100,minPoolSize:"number"==typeof e.minPoolSize?e.minPoolSize:0,maxIdleTimeMS:"number"==typeof e.maxIdleTimeMS?e.maxIdleTimeMS:0,waitQueueTimeoutMS:"number"==typeof e.waitQueueTimeoutMS?e.waitQueueTimeoutMS:0,autoEncrypter:e.autoEncrypter,metadata:e.metadata}),e.minSize>e.maxSize)throw new TypeError("Connection pool minimum size must not be greater than maxiumum pool size");this[C]=s("ConnectionPool",e),this[x]=new r,this[N]=this.options.maxPoolSize,this[I]=void 0,this[A]=0,this[k]=i(1),this[M]=new o,this[M].setMaxListeners(1/0),this[B]=new r,process.nextTick(()=>{this.emit("connectionPoolCreated",new y(this)),function e(t){if(t.closed||0===t.options.minPoolSize)return;const n=t.options.minPoolSize;for(let e=t.totalConnectionCount;ee(t),10)}(this)})}get address(){return`${this.options.host}:${this.options.port}`}get generation(){return this[A]}get totalConnectionCount(){return this[x].length+(this.options.maxPoolSize-this[N])}get availableConnectionCount(){return this[x].length}get waitQueueSize(){return this[B].length}checkOut(e){if(this.emit("connectionCheckOutStarted",new w(this)),this.closed)return this.emit("connectionCheckOutFailed",new O(this,"poolClosed")),void e(new f(this));const t={callback:e},n=this,r=this.options.waitQueueTimeoutMS;r&&(t.timer=setTimeout(()=>{t[R]=!0,t.timer=void 0,n.emit("connectionCheckOutFailed",new O(n,"timeout")),t.callback(new d(n))},r)),this[B].push(t),process.nextTick(()=>z(this))}checkIn(e){const t=this.closed,n=D(this,e),r=!!(t||n||e.closed);if(r||(e.markAvailable(),this[x].push(e)),this.emit("connectionCheckedIn",new T(this,e)),r){U(this,e,e.closed?"error":t?"poolClosed":"stale")}process.nextTick(()=>z(this))}clear(){this[A]+=1,this.emit("connectionPoolCleared",new E(this))}close(e,t){if("function"==typeof e&&(t=e),e=Object.assign({force:!1},e),this.closed)return t();for(this[M].emit("cancel");this.waitQueueSize;){const e=this[B].pop();clearTimeout(e.timer),e[R]||e.callback(new a("connection pool closed"))}this[I]&&clearTimeout(this[I]),"function"==typeof this[k].return&&this[k].return(),this.closed=!0,l(this[x].toArray(),(t,n)=>{this.emit("connectionClosed",new v(this,t,"poolClosed")),t.destroy(e,n)},e=>{this[x].clear(),this.emit("connectionPoolClosed",new g(this)),t(e)})}withConnection(e,t){this.checkOut((n,r)=>{e(n,r,(e,n)=>{"function"==typeof t&&(e?t(e):t(void 0,n)),r&&this.checkIn(r)})})}}}},function(e,t,n){"use strict";const r=n(19).Duplex,o=n(152),s=n(3).MongoParseError,i=n(23).decompress,a=n(16).Response,c=n(31).BinMsg,l=n(3).MongoError,u=n(6).opcodes.OP_COMPRESSED,h=n(6).opcodes.OP_MSG,p=n(6).MESSAGE_HEADER_SIZE,f=n(6).COMPRESSION_DETAILS_SIZE,d=n(6).opcodes,m=n(23).compress,y=n(23).compressorIDs,g=n(23).uncompressibleCommands,b=n(31).Msg,S=Symbol("buffer");e.exports=class extends r{constructor(e){super(e=e||{}),this.bson=e.bson,this.maxBsonMessageSize=e.maxBsonMessageSize||67108864,this[S]=new o}_write(e,t,n){this[S].append(e),function e(t,n){const r=t[S];if(r.length<4)return void n();const o=r.readInt32LE(0);if(o<0)return void n(new s("Invalid message size: "+o));if(o>t.maxBsonMessageSize)return void n(new s(`Invalid message size: ${o}, max allowed: ${t.maxBsonMessageSize}`));if(o>r.length)return void n();const f=r.slice(0,o);r.consume(o);const d={length:f.readInt32LE(0),requestId:f.readInt32LE(4),responseTo:f.readInt32LE(8),opCode:f.readInt32LE(12)};let m=d.opCode===h?c:a;const y=t.responseOptions;if(d.opCode!==u){const o=f.slice(p);return t.emit("message",new m(t.bson,f,d,o,y)),void(r.length>=4?e(t,n):n())}d.fromCompressed=!0,d.opCode=f.readInt32LE(p),d.length=f.readInt32LE(p+4);const g=f[p+8],b=f.slice(p+9);m=d.opCode===h?c:a,i(g,b,(o,s)=>{o?n(o):s.length===d.length?(t.emit("message",new m(t.bson,f,d,s,y)),r.length>=4?e(t,n):n()):n(new l("Decompressing a compressed message from the server failed. The message is corrupt."))})}(this,n)}_read(){}writeCommand(e,t){if(!(t&&!!t.agreedCompressor)||!function(e){const t=e instanceof b?e.command:e.query,n=Object.keys(t)[0];return!g.has(n)}(e)){const t=e.toBin();return void this.push(Array.isArray(t)?Buffer.concat(t):t)}const n=Buffer.concat(e.toBin()),r=n.slice(p),o=n.readInt32LE(12);m({options:t},r,(n,s)=>{if(n)return void t.cb(n,null);const i=Buffer.alloc(p);i.writeInt32LE(p+f+s.length,0),i.writeInt32LE(e.requestId,4),i.writeInt32LE(0,8),i.writeInt32LE(d.OP_COMPRESSED,12);const a=Buffer.alloc(f);a.writeInt32LE(o,0),a.writeInt32LE(r.length,4),a.writeUInt8(y[t.agreedCompressor],8),this.push(Buffer.concat([i,a,s]))})}}},function(e,t,n){"use strict";var r=n(153).Duplex,o=n(5),s=n(17).Buffer;function i(e){if(!(this instanceof i))return new i(e);if(this._bufs=[],this.length=0,"function"==typeof e){this._callback=e;var t=function(e){this._callback&&(this._callback(e),this._callback=null)}.bind(this);this.on("pipe",(function(e){e.on("error",t)})),this.on("unpipe",(function(e){e.removeListener("error",t)}))}else this.append(e);r.call(this)}o.inherits(i,r),i.prototype._offset=function(e){var t,n=0,r=0;if(0===e)return[0,0];for(;rthis.length||e<0)){var t=this._offset(e);return this._bufs[t[0]][t[1]]}},i.prototype.slice=function(e,t){return"number"==typeof e&&e<0&&(e+=this.length),"number"==typeof t&&t<0&&(t+=this.length),this.copy(null,0,e,t)},i.prototype.copy=function(e,t,n,r){if(("number"!=typeof n||n<0)&&(n=0),("number"!=typeof r||r>this.length)&&(r=this.length),n>=this.length)return e||s.alloc(0);if(r<=0)return e||s.alloc(0);var o,i,a=!!e,c=this._offset(n),l=r-n,u=l,h=a&&t||0,p=c[1];if(0===n&&r==this.length){if(!a)return 1===this._bufs.length?this._bufs[0]:s.concat(this._bufs,this.length);for(i=0;i(o=this._bufs[i].length-p))){this._bufs[i].copy(e,h,p,p+u),h+=o;break}this._bufs[i].copy(e,h,p),h+=o,u-=o,p&&(p=0)}return e.length>h?e.slice(0,h):e},i.prototype.shallowSlice=function(e,t){if(e=e||0,t="number"!=typeof t?this.length:t,e<0&&(e+=this.length),t<0&&(t+=this.length),e===t)return new i;var n=this._offset(e),r=this._offset(t),o=this._bufs.slice(n[0],r[0]+1);return 0==r[1]?o.pop():o[o.length-1]=o[o.length-1].slice(0,r[1]),0!=n[1]&&(o[0]=o[0].slice(n[1])),new i(o)},i.prototype.toString=function(e,t,n){return this.slice(t,n).toString(e)},i.prototype.consume=function(e){if(e=Math.trunc(e),Number.isNaN(e)||e<=0)return this;for(;this._bufs.length;){if(!(e>=this._bufs[0].length)){this._bufs[0]=this._bufs[0].slice(e),this.length-=e;break}e-=this._bufs[0].length,this.length-=this._bufs[0].length,this._bufs.shift()}return this},i.prototype.duplicate=function(){for(var e=0,t=new i;ethis.length?this.length:t;for(var r=this._offset(t),o=r[0],a=r[1];o=e.length){var l=c.indexOf(e,a);if(-1!==l)return this._reverseOffset([o,l]);a=c.length-e.length+1}else{var u=this._reverseOffset([o,a]);if(this._match(u,e))return u;a++}}a=0}return-1},i.prototype._match=function(e,t){if(this.length-e0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,n=""+t.data;t=t.next;)n+=e+t.data;return n},e.prototype.concat=function(e){if(0===this.length)return r.alloc(0);if(1===this.length)return this.head.data;for(var t,n,o,s=r.allocUnsafe(e>>>0),i=this.head,a=0;i;)t=i.data,n=s,o=a,t.copy(n,o),a+=i.data.length,i=i.next;return s},e}(),o&&o.inspect&&o.inspect.custom&&(e.exports.prototype[o.inspect.custom]=function(){var e=o.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t,n){e.exports=n(5).deprecate},function(e,t,n){var r=n(53),o=r.Buffer;function s(e,t){for(var n in e)t[n]=e[n]}function i(e,t,n){return o(e,t,n)}o.from&&o.alloc&&o.allocUnsafe&&o.allocUnsafeSlow?e.exports=r:(s(r,t),t.Buffer=i),s(o,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return o(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var r=o(e);return void 0!==t?"string"==typeof n?r.fill(t,n):r.fill(t):r.fill(0),r},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return o(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r.SlowBuffer(e)}},function(e,t,n){"use strict";e.exports=s;var r=n(103),o=Object.create(n(38));function s(e){if(!(this instanceof s))return new s(e);r.call(this,e)}o.inherits=n(39),o.inherits(s,r),s.prototype._transform=function(e,t,n){n(null,e)}},function(e,t,n){"use strict";const r=n(30).parseServerType,o=["minWireVersion","maxWireVersion","maxBsonObjectSize","maxMessageSizeBytes","maxWriteBatchSize","__nodejs_mock_server__"];e.exports={StreamDescription:class{constructor(e,t){this.address=e,this.type=r(null),this.minWireVersion=void 0,this.maxWireVersion=void 0,this.maxBsonObjectSize=16777216,this.maxMessageSizeBytes=48e6,this.maxWriteBatchSize=1e5,this.compressors=t&&t.compression&&Array.isArray(t.compression.compressors)?t.compression.compressors:[]}receiveResponse(e){this.type=r(e),o.forEach(t=>{void 0!==e[t]&&(this[t]=e[t])}),e.compression&&(this.compressor=this.compressors.filter(t=>-1!==e.compression.indexOf(t))[0])}}}},function(e,t,n){"use strict";const r=n(3).MongoError;e.exports={PoolClosedError:class extends r{constructor(e){super("Attempted to check out a connection from closed connection pool"),this.name="MongoPoolClosedError",this.address=e.address}},WaitQueueTimeoutError:class extends r{constructor(e){super("Timed out while checking out a connection from connection pool"),this.name="MongoWaitQueueTimeoutError",this.address=e.address}}}},function(e,t,n){"use strict";const r=n(12).ServerType,o=n(8),s=n(69),i=n(97).Connection,a=n(12),c=n(4).makeStateMachine,l=n(3).MongoNetworkError,u=n(9).retrieveBSON(),h=n(0).makeInterruptableAsyncInterval,p=n(0).calculateDurationInMs,f=n(0).now,d=n(96),m=d.ServerHeartbeatStartedEvent,y=d.ServerHeartbeatSucceededEvent,g=d.ServerHeartbeatFailedEvent,b=Symbol("server"),S=Symbol("monitorId"),v=Symbol("connection"),w=Symbol("cancellationToken"),O=Symbol("rttPinger"),_=Symbol("roundTripTime"),T=a.STATE_CLOSED,E=a.STATE_CLOSING,C=c({[E]:[E,"idle",T],[T]:[T,"monitoring"],idle:["idle","monitoring",E],monitoring:["monitoring","idle",E]}),x=new Set([E,T,"monitoring"]);function N(e){return e.s.state===T||e.s.state===E}function I(e){e[S]&&(e[S].stop(),e[S]=null),e[O]&&(e[O].close(),e[O]=void 0),e[w].emit("cancel"),e[S]&&(clearTimeout(e[S]),e[S]=void 0),e[v]&&e[v].destroy({force:!0})}function A(e,t){let n=f();function r(r){e[v]&&(e[v].destroy({force:!0}),e[v]=void 0),e.emit("serverHeartbeatFailed",new g(p(n),r,e.address)),e.emit("resetServer",r),e.emit("resetConnectionPool"),t(r)}if(e.emit("serverHeartbeatStarted",new m(e.address)),null!=e[v]&&!e[v].closed){const s=e.options.connectTimeoutMS,i=e.options.heartbeatFrequencyMS,a=e[b].description.topologyVersion,c=null!=a,l={ismaster:!0},h={socketTimeout:s};return c&&(l.maxAwaitTimeMS=i,l.topologyVersion={processId:(o=a).processId,counter:u.Long.fromNumber(o.counter)},s&&(h.socketTimeout=s+i),h.exhaustAllowed=!0,null==e[O]&&(e[O]=new M(e[w],e.connectOptions))),void e[v].command("admin.$cmd",l,h,(o,s)=>{if(o)return void r(o);const i=s.result,a=e[O],l=c&&a?a.roundTripTime:p(n);e.emit("serverHeartbeatSucceeded",new y(l,i,e.address)),c&&i.topologyVersion?(e.emit("serverHeartbeatStarted",new m(e.address)),n=f()):(e[O]&&(e[O].close(),e[O]=void 0),t(void 0,i))})}var o;s(e.connectOptions,e[w],(o,s)=>{if(s&&N(e))s.destroy({force:!0});else{if(o)return e[v]=void 0,o instanceof l||e.emit("resetConnectionPool"),void r(o);e[v]=s,e.emit("serverHeartbeatSucceeded",new y(p(n),s.ismaster,e.address)),t(void 0,s.ismaster)}})}function k(e){return t=>{function n(){N(e)||C(e,"idle"),t()}C(e,"monitoring"),process.nextTick(()=>e.emit("monitoring",e[b])),A(e,(t,o)=>{if(t&&e[b].description.type===r.Unknown)return e.emit("resetServer",t),n();o&&o.topologyVersion&&setTimeout(()=>{N(e)||e[S].wake()}),n()})}}class M{constructor(e,t){this[v]=null,this[w]=e,this[_]=0,this.closed=!1;const n=t.heartbeatFrequencyMS;this[S]=setTimeout(()=>function e(t,n){const r=f(),o=t[w],i=n.heartbeatFrequencyMS;if(t.closed)return;function a(o){t.closed?o.destroy({force:!0}):(null==t[v]&&(t[v]=o),t[_]=p(r),t[S]=setTimeout(()=>e(t,n),i))}if(null==t[v])return void s(n,o,(e,n)=>{if(e)return t[v]=void 0,void(t[_]=0);a(n)});t[v].command("admin.$cmd",{ismaster:1},e=>{if(e)return t[v]=void 0,void(t[_]=0);a()})}(this,t),n)}get roundTripTime(){return this[_]}close(){this.closed=!0,clearTimeout(this[S]),this[S]=void 0,this[v]&&this[v].destroy({force:!0})}}e.exports={Monitor:class extends o{constructor(e,t){super(t),this[b]=e,this[v]=void 0,this[w]=new o,this[w].setMaxListeners(1/0),this[S]=null,this.s={state:T},this.address=e.description.address,this.options=Object.freeze({connectTimeoutMS:"number"==typeof t.connectionTimeout?t.connectionTimeout:"number"==typeof t.connectTimeoutMS?t.connectTimeoutMS:1e4,heartbeatFrequencyMS:"number"==typeof t.heartbeatFrequencyMS?t.heartbeatFrequencyMS:1e4,minHeartbeatFrequencyMS:"number"==typeof t.minHeartbeatFrequencyMS?t.minHeartbeatFrequencyMS:500});const n=Object.assign({id:"",host:e.description.host,port:e.description.port,bson:e.s.bson,connectionType:i},e.s.options,this.options,{raw:!1,promoteLongs:!0,promoteValues:!0,promoteBuffers:!0});delete n.credentials,delete n.autoEncrypter,this.connectOptions=Object.freeze(n)}connect(){if(this.s.state!==T)return;const e=this.options.heartbeatFrequencyMS,t=this.options.minHeartbeatFrequencyMS;this[S]=h(k(this),{interval:e,minInterval:t,immediate:!0})}requestCheck(){x.has(this.s.state)||this[S].wake()}reset(){const e=this[b].description.topologyVersion;if(N(this)||null==e)return;C(this,E),I(this),C(this,"idle");const t=this.options.heartbeatFrequencyMS,n=this.options.minHeartbeatFrequencyMS;this[S]=h(k(this),{interval:t,minInterval:n})}close(){N(this)||(C(this,E),I(this),this.emit("close"),C(this,T))}}}},function(e,t,n){"use strict";const r=n(14),o=n(8).EventEmitter,s=n(54);class i{constructor(e){this.srvRecords=e}addresses(){return new Set(this.srvRecords.map(e=>`${e.name}:${e.port}`))}}e.exports.SrvPollingEvent=i,e.exports.SrvPoller=class extends o{constructor(e){if(super(),!e||!e.srvHost)throw new TypeError("options for SrvPoller must exist and include srvHost");this.srvHost=e.srvHost,this.rescanSrvIntervalMS=6e4,this.heartbeatFrequencyMS=e.heartbeatFrequencyMS||1e4,this.logger=r("srvPoller",e),this.haMode=!1,this.generation=0,this._timeout=null}get srvAddress(){return"_mongodb._tcp."+this.srvHost}get intervalMS(){return this.haMode?this.heartbeatFrequencyMS:this.rescanSrvIntervalMS}start(){this._timeout||this.schedule()}stop(){this._timeout&&(clearTimeout(this._timeout),this.generation+=1,this._timeout=null)}schedule(){clearTimeout(this._timeout),this._timeout=setTimeout(()=>this._poll(),this.intervalMS)}success(e){this.haMode=!1,this.schedule(),this.emit("srvRecordDiscovery",new i(e))}failure(e,t){this.logger.warn(e,t),this.haMode=!0,this.schedule()}parentDomainMismatch(e){this.logger.warn(`parent domain mismatch on SRV record (${e.name}:${e.port})`,e)}_poll(){const e=this.generation;s.resolveSrv(this.srvAddress,(t,n)=>{if(e!==this.generation)return;if(t)return void this.failure("DNS error",t);const r=[];n.forEach(e=>{!function(e,t){const n=/^.*?\./,r="."+e.replace(n,""),o="."+t.replace(n,"");return r.endsWith(o)}(e.name,this.srvHost)?this.parentDomainMismatch(e):r.push(e)}),r.length?this.success(r):this.failure("No valid addresses found at host")})}}},function(e,t,n){"use strict";const r=n(12).ServerType,o=n(12).TopologyType,s=n(10),i=n(3).MongoError;function a(e,t){const n=Object.keys(e),r=Object.keys(t);for(let o=0;o-1===e?t.roundTripTime:Math.min(t.roundTripTime,e),-1),r=n+e.localThresholdMS;return t.reduce((e,t)=>(t.roundTripTime<=r&&t.roundTripTime>=n&&e.push(t),e),[])}function l(e){return e.type===r.RSPrimary}function u(e){return e.type===r.RSSecondary}function h(e){return e.type===r.RSSecondary||e.type===r.RSPrimary}function p(e){return e.type!==r.Unknown}e.exports={writableServerSelector:function(){return function(e,t){return c(e,t.filter(e=>e.isWritable))}},readPreferenceServerSelector:function(e){if(!e.isValid())throw new TypeError("Invalid read preference specified");return function(t,n){const r=t.commonWireVersion;if(r&&e.minWireVersion&&e.minWireVersion>r)throw new i(`Minimum wire version '${e.minWireVersion}' required, but found '${r}'`);if(t.type===o.Unknown)return[];if(t.type===o.Single||t.type===o.Sharded)return c(t,n.filter(p));const f=e.mode;if(f===s.PRIMARY)return n.filter(l);if(f===s.PRIMARY_PREFERRED){const e=n.filter(l);if(e.length)return e}const d=f===s.NEAREST?h:u,m=c(t,function(e,t){if(null==e.tags||Array.isArray(e.tags)&&0===e.tags.length)return t;for(let n=0;n(a(r,t.tags)&&e.push(t),e),[]);if(o.length)return o}return[]}(e,function(e,t,n){if(null==e.maxStalenessSeconds||e.maxStalenessSeconds<0)return n;const r=e.maxStalenessSeconds,s=(t.heartbeatFrequencyMS+1e4)/1e3;if(r((o.lastUpdateTime-o.lastWriteDate-(r.lastUpdateTime-r.lastWriteDate)+t.heartbeatFrequencyMS)/1e3<=e.maxStalenessSeconds&&n.push(o),n),[])}if(t.type===o.ReplicaSetNoPrimary){if(0===n.length)return n;const r=n.reduce((e,t)=>t.lastWriteDate>e.lastWriteDate?t:e);return n.reduce((n,o)=>((r.lastWriteDate-o.lastWriteDate+t.heartbeatFrequencyMS)/1e3<=e.maxStalenessSeconds&&n.push(o),n),[])}return n}(e,t,n.filter(d))));return f===s.SECONDARY_PREFERRED&&0===m.length?n.filter(l):m}}}},function(e,t,n){"use strict";const r=n(71),o=n(104),s=n(54),i=n(3).MongoParseError,a=n(10),c=n(0).emitWarningOnce,l=/(mongodb(?:\+srv|)):\/\/(?: (?:[^:]*) (?: : ([^@]*) )? @ )?([^/?]*)(?:\/|)(.*)/,u=new Set(["sslCA","sslCert","sslKey","tlsCAFile","tlsCertificateKeyFile"].map(e=>e.toLowerCase()));function h(e,t){const n=/^.*?\./,r="."+e.replace(n,""),o="."+t.replace(n,"");return r.endsWith(o)}function p(e,t){if(Array.isArray(t))1===(t=t.filter((e,n)=>t.indexOf(e)===n)).length&&(t=t[0]);else if(t.indexOf(":")>0)t=t.split(",").reduce((t,n)=>{const r=n.split(":");return t[r[0]]=p(e,r[1]),t},{});else if(t.indexOf(",")>0)t=t.split(",").map(t=>p(e,t));else if("true"===t.toLowerCase()||"false"===t.toLowerCase())t="true"===t.toLowerCase();else if(!Number.isNaN(t)&&!d.has(e)){const e=parseFloat(t);Number.isNaN(e)||(t=parseFloat(t))}return t}const f=new Set(["slaveok","slave_ok","sslvalidate","fsync","safe","retrywrites","j"]),d=new Set(["authsource","replicaset"]),m=new Set(["GSSAPI","MONGODB-AWS","MONGODB-X509","MONGODB-CR","DEFAULT","SCRAM-SHA-1","SCRAM-SHA-256","PLAIN"]),y={replicaset:"replicaSet",connecttimeoutms:"connectTimeoutMS",sockettimeoutms:"socketTimeoutMS",maxpoolsize:"maxPoolSize",minpoolsize:"minPoolSize",maxidletimems:"maxIdleTimeMS",waitqueuemultiple:"waitQueueMultiple",waitqueuetimeoutms:"waitQueueTimeoutMS",wtimeoutms:"wtimeoutMS",readconcern:"readConcern",readconcernlevel:"readConcernLevel",readpreference:"readPreference",maxstalenessseconds:"maxStalenessSeconds",readpreferencetags:"readPreferenceTags",authsource:"authSource",authmechanism:"authMechanism",authmechanismproperties:"authMechanismProperties",gssapiservicename:"gssapiServiceName",localthresholdms:"localThresholdMS",serverselectiontimeoutms:"serverSelectionTimeoutMS",serverselectiontryonce:"serverSelectionTryOnce",heartbeatfrequencyms:"heartbeatFrequencyMS",retrywrites:"retryWrites",uuidrepresentation:"uuidRepresentation",zlibcompressionlevel:"zlibCompressionLevel",tlsallowinvalidcertificates:"tlsAllowInvalidCertificates",tlsallowinvalidhostnames:"tlsAllowInvalidHostnames",tlsinsecure:"tlsInsecure",tlscafile:"tlsCAFile",tlscertificatekeyfile:"tlsCertificateKeyFile",tlscertificatekeyfilepassword:"tlsCertificateKeyFilePassword",wtimeout:"wTimeoutMS",j:"journal",directconnection:"directConnection"};function g(e,t,n,r){if("journal"===t?t="j":"wtimeoutms"===t&&(t="wtimeout"),f.has(t)?n="true"===n||!0===n:"appname"===t?n=decodeURIComponent(n):"readconcernlevel"===t&&(e.readConcernLevel=n,t="readconcern",n={level:n}),"compressors"===t&&!(n=Array.isArray(n)?n:[n]).every(e=>"snappy"===e||"zlib"===e))throw new i("Value for `compressors` must be at least one of: `snappy`, `zlib`");if("authmechanism"===t&&!m.has(n))throw new i(`Value for authMechanism must be one of: ${Array.from(m).join(", ")}, found: ${n}`);if("readpreference"===t&&!a.isValid(n))throw new i("Value for `readPreference` must be one of: `primary`, `primaryPreferred`, `secondary`, `secondaryPreferred`, `nearest`");if("zlibcompressionlevel"===t&&(n<-1||n>9))throw new i("zlibCompressionLevel must be an integer between -1 and 9");"compressors"!==t&&"zlibcompressionlevel"!==t||(e.compression=e.compression||{},e=e.compression),"authmechanismproperties"===t&&("string"==typeof n.SERVICE_NAME&&(e.gssapiServiceName=n.SERVICE_NAME),"string"==typeof n.SERVICE_REALM&&(e.gssapiServiceRealm=n.SERVICE_REALM),void 0!==n.CANONICALIZE_HOST_NAME&&(e.gssapiCanonicalizeHostName=n.CANONICALIZE_HOST_NAME)),"readpreferencetags"===t&&(n=Array.isArray(n)?function(e){const t=[];for(let n=0;n{const r=e.split(":");t[n][r[0]]=r[1]});return t}(n):[n]),r.caseTranslate&&y[t]?e[y[t]]=n:e[t]=n}const b=new Set(["GSSAPI","MONGODB-CR","PLAIN","SCRAM-SHA-1","SCRAM-SHA-256"]);function S(e,t){const n={};let r=o.parse(e);!function(e){const t=Object.keys(e);if(-1!==t.indexOf("tlsInsecure")&&(-1!==t.indexOf("tlsAllowInvalidCertificates")||-1!==t.indexOf("tlsAllowInvalidHostnames")))throw new i("The `tlsInsecure` option cannot be used with `tlsAllowInvalidCertificates` or `tlsAllowInvalidHostnames`.");const n=v("tls",e,t),r=v("ssl",e,t);if(null!=n&&null!=r&&n!==r)throw new i("All values of `tls` and `ssl` must be the same.")}(r);for(const e in r){const o=r[e];if(""===o||null==o)throw new i("Incomplete key value pair for option");const s=e.toLowerCase();g(n,s,u.has(s)?o:p(s,o),t)}return n.wtimeout&&n.wtimeoutms&&(delete n.wtimeout,c("Unsupported option `wtimeout` specified")),Object.keys(n).length?n:null}function v(e,t,n){const r=-1!==n.indexOf(e);let o;if(o=Array.isArray(t[e])?t[e][0]:t[e],r&&Array.isArray(t[e])){const n=t[e][0];t[e].forEach(t=>{if(t!==n)throw new i(`All values of ${e} must be the same.`)})}return o}const w="mongodb+srv",O=["mongodb",w];function _(e,t,n){"function"==typeof t&&(n=t,t={}),t=Object.assign({},{caseTranslate:!0},t);try{r.parse(e)}catch(e){return n(new i("URI malformed, cannot be parsed"))}const a=e.match(l);if(!a)return n(new i("Invalid connection string"));const c=a[1];if(-1===O.indexOf(c))return n(new i("Invalid protocol provided"));const u=a[4].split("?"),p=u.length>0?u[0]:null,f=u.length>1?u[1]:null;let d;try{d=S(f,t)}catch(e){return n(e)}if(d=Object.assign({},d,t),c===w)return function(e,t,n){const a=r.parse(e,!0);if(t.directConnection||t.directconnection)return n(new i("directConnection not supported with SRV URI"));if(a.hostname.split(".").length<3)return n(new i("URI does not have hostname, domain name and tld"));if(a.domainLength=a.hostname.split(".").length,a.pathname&&a.pathname.match(","))return n(new i("Invalid URI, cannot contain multiple hostnames"));if(a.port)return n(new i(`Ports not accepted with '${w}' URIs`));const c=a.host;s.resolveSrv("_mongodb._tcp."+c,(e,l)=>{if(e)return n(e);if(0===l.length)return n(new i("No addresses found at host"));for(let e=0;e`${e.name}:${e.port}`).join(","),"ssl"in t||a.search&&"ssl"in a.query&&null!==a.query.ssl||(a.query.ssl=!0),s.resolveTxt(c,(e,s)=>{if(e){if("ENODATA"!==e.code&&"ENOTFOUND"!==e.code)return n(e);s=null}if(s){if(s.length>1)return n(new i("Multiple text records not allowed"));if(s=o.parse(s[0].join("")),Object.keys(s).some(e=>"authSource"!==e&&"replicaSet"!==e))return n(new i("Text record must only set `authSource` or `replicaSet`"));a.query=Object.assign({},s,a.query)}a.search=o.stringify(a.query);_(r.format(a),t,(e,t)=>{e?n(e):n(null,Object.assign({},t,{srvHost:c}))})})})}(e,d,n);const m={username:null,password:null,db:p&&""!==p?o.unescape(p):null};if(d.auth?(d.auth.username&&(m.username=d.auth.username),d.auth.user&&(m.username=d.auth.user),d.auth.password&&(m.password=d.auth.password)):(d.username&&(m.username=d.username),d.user&&(m.username=d.user),d.password&&(m.password=d.password)),-1!==a[4].split("?")[0].indexOf("@"))return n(new i("Unescaped slash in userinfo section"));const y=a[3].split("@");if(y.length>2)return n(new i("Unescaped at-sign in authority section"));if(null==y[0]||""===y[0])return n(new i("No username provided in authority section"));if(y.length>1){const e=y.shift().split(":");if(e.length>2)return n(new i("Unescaped colon in authority section"));if(""===e[0])return n(new i("Invalid empty username provided"));m.username||(m.username=o.unescape(e[0])),m.password||(m.password=e[1]?o.unescape(e[1]):null)}let g=null;const v=y.shift().split(",").map(e=>{let t=r.parse("mongodb://"+e);if("/:"===t.path)return g=new i("Double colon in host identifier"),null;if(e.match(/\.sock/)&&(t.hostname=o.unescape(e),t.port=null),Number.isNaN(t.port))return void(g=new i("Invalid port (non-numeric string)"));const n={host:t.hostname,port:t.port?parseInt(t.port):27017};if(0!==n.port)if(n.port>65535)g=new i("Invalid port (larger than 65535) with hostname");else{if(!(n.port<0))return n;g=new i("Invalid port (negative number)")}else g=new i("Invalid port (zero) with hostname")}).filter(e=>!!e);if(g)return n(g);if(0===v.length||""===v[0].host||null===v[0].host)return n(new i("No hostname or hostnames provided in connection string"));if(!!d.directConnection&&1!==v.length)return n(new i("directConnection option requires exactly one host"));null==d.directConnection&&1===v.length&&null==d.replicaSet&&(d.directConnection=!0);const T={hosts:v,auth:m.db||m.username?m:null,options:Object.keys(d).length?d:null};var E;T.auth&&T.auth.db?T.defaultDatabase=T.auth.db:T.defaultDatabase="test",T.options=((E=T.options).tls&&(E.ssl=E.tls),E.tlsInsecure?(E.checkServerIdentity=!1,E.sslValidate=!1):Object.assign(E,{checkServerIdentity:!E.tlsAllowInvalidHostnames,sslValidate:!E.tlsAllowInvalidCertificates}),E.tlsCAFile&&(E.ssl=!0,E.sslCA=E.tlsCAFile),E.tlsCertificateKeyFile&&(E.ssl=!0,E.tlsCertificateFile?(E.sslCert=E.tlsCertificateFile,E.sslKey=E.tlsCertificateKeyFile):(E.sslKey=E.tlsCertificateKeyFile,E.sslCert=E.tlsCertificateKeyFile)),E.tlsCertificateKeyFilePassword&&(E.ssl=!0,E.sslPass=E.tlsCertificateKeyFilePassword),E);try{!function(e){if(null==e.options)return;const t=e.options,n=t.authsource||t.authSource;null!=n&&(e.auth=Object.assign({},e.auth,{db:n}));const r=t.authmechanism||t.authMechanism;if(null!=r){if(b.has(r)&&(!e.auth||null==e.auth.username))throw new i(`Username required for mechanism \`${r}\``);if("GSSAPI"===r){if(null!=n&&"$external"!==n)throw new i(`Invalid source \`${n}\` for mechanism \`${r}\` specified.`);e.auth=Object.assign({},e.auth,{db:"$external"})}if("MONGODB-AWS"===r){if(null!=n&&"$external"!==n)throw new i(`Invalid source \`${n}\` for mechanism \`${r}\` specified.`);e.auth=Object.assign({},e.auth,{db:"$external"})}if("MONGODB-X509"===r){if(e.auth&&null!=e.auth.password)throw new i(`Password not allowed for mechanism \`${r}\``);if(null!=n&&"$external"!==n)throw new i(`Invalid source \`${n}\` for mechanism \`${r}\` specified.`);e.auth=Object.assign({},e.auth,{db:"$external"})}"PLAIN"===r&&e.auth&&null==e.auth.db&&(e.auth=Object.assign({},e.auth,{db:"$external"}))}e.auth&&null==e.auth.db&&(e.auth=Object.assign({},e.auth,{db:"admin"}))}(T)}catch(e){return n(e)}n(null,T)}e.exports=_},function(e,t,n){"use strict";const r=n(8).EventEmitter;e.exports=class extends r{constructor(){super()}instrument(e,t){this.$MongoClient=e;const n=this.$prototypeConnect=e.prototype.connect,r=this;e.prototype.connect=function(e){return this.s.options.monitorCommands=!0,this.on("commandStarted",e=>r.emit("started",e)),this.on("commandSucceeded",e=>r.emit("succeeded",e)),this.on("commandFailed",e=>r.emit("failed",e)),n.call(this,e)},"function"==typeof t&&t(null,this)}uninstrument(){this.$MongoClient.prototype.connect=this.$prototypeConnect}}},function(e,t,n){"use strict";const r=n(41).buildCountCommand,o=n(0).handleCallback,s=n(2).MongoError,i=Array.prototype.push,a=n(15).CursorState;function c(e,t){if(0!==e.bufferedCount())return e._next(t),c}e.exports={count:function(e,t,n,o){t&&("number"==typeof e.cursorSkip()&&(n.skip=e.cursorSkip()),"number"==typeof e.cursorLimit()&&(n.limit=e.cursorLimit())),n.readPreference&&e.setReadPreference(n.readPreference),"number"!=typeof n.maxTimeMS&&e.cmd&&"number"==typeof e.cmd.maxTimeMS&&(n.maxTimeMS=e.cmd.maxTimeMS);let s,i={};i.skip=n.skip,i.limit=n.limit,i.hint=n.hint,i.maxTimeMS=n.maxTimeMS,i.collectionName=e.namespace.collection;try{s=r(e,e.cmd.query,i)}catch(e){return o(e)}e.server=e.topology.s.coreTopology,e.topology.command(e.namespace.withCollection("$cmd"),s,e.options,(e,t)=>{o(e,t?t.result.n:null)})},each:function e(t,n){if(!n)throw s.create({message:"callback is mandatory",driver:!0});if(t.isNotified())return;if(t.s.state===a.CLOSED||t.isDead())return o(n,s.create({message:"Cursor is closed",driver:!0}));t.s.state===a.INIT&&(t.s.state=a.OPEN);let r=null;if(t.bufferedCount()>0){for(;r=c(t,n);)r(t,n);e(t,n)}else t.next((r,s)=>r?o(n,r):null==s?t.close({skipKillCursors:!0},()=>o(n,null,null)):void(!1!==o(n,null,s)&&e(t,n)))},toArray:function(e,t){const n=[];e.rewind(),e.s.state=a.INIT;const r=()=>{e._next((s,a)=>{if(s)return o(t,s);if(null==a)return e.close({skipKillCursors:!0},()=>o(t,null,n));if(n.push(a),e.bufferedCount()>0){let t=e.readBufferedDocuments(e.bufferedCount());e.s.transforms&&"function"==typeof e.s.transforms.doc&&(t=t.map(e.s.transforms.doc)),i.apply(n,t)}r()})};r()}}},function(e,t,n){"use strict";const r=n(13).buildCountCommand,o=n(1).OperationBase;e.exports=class extends o{constructor(e,t,n){super(n),this.cursor=e,this.applySkipLimit=t}execute(e){const t=this.cursor,n=this.applySkipLimit,o=this.options;n&&("number"==typeof t.cursorSkip()&&(o.skip=t.cursorSkip()),"number"==typeof t.cursorLimit()&&(o.limit=t.cursorLimit())),o.readPreference&&t.setReadPreference(o.readPreference),"number"!=typeof o.maxTimeMS&&t.cmd&&"number"==typeof t.cmd.maxTimeMS&&(o.maxTimeMS=t.cmd.maxTimeMS);let s,i={};i.skip=o.skip,i.limit=o.limit,i.hint=o.hint,i.maxTimeMS=o.maxTimeMS,i.collectionName=t.namespace.collection;try{s=r(t,t.cmd.query,i)}catch(t){return e(t)}t.server=t.topology.s.coreTopology,t.topology.command(t.namespace.withCollection("$cmd"),s,t.options,(t,n)=>{e(t,n?n.result.n:null)})}}},function(e,t,n){"use strict";const r=n(76),o=r.BulkOperationBase,s=r.Batch,i=r.bson,a=n(0).toError;function c(e,t,n){const o=i.calculateObjectSize(n,{checkKeys:!1,ignoreUndefined:!1});if(o>=e.s.maxBsonObjectSize)throw a("document is larger than the maximum size "+e.s.maxBsonObjectSize);e.s.currentBatch=null,t===r.INSERT?e.s.currentBatch=e.s.currentInsertBatch:t===r.UPDATE?e.s.currentBatch=e.s.currentUpdateBatch:t===r.REMOVE&&(e.s.currentBatch=e.s.currentRemoveBatch);const c=e.s.maxKeySize;if(null==e.s.currentBatch&&(e.s.currentBatch=new s(t,e.s.currentIndex)),(e.s.currentBatch.size+1>=e.s.maxWriteBatchSize||e.s.currentBatch.size>0&&e.s.currentBatch.sizeBytes+c+o>=e.s.maxBatchSizeBytes||e.s.currentBatch.batchType!==t)&&(e.s.batches.push(e.s.currentBatch),e.s.currentBatch=new s(t,e.s.currentIndex)),Array.isArray(n))throw a("operation passed in cannot be an Array");return e.s.currentBatch.operations.push(n),e.s.currentBatch.originalIndexes.push(e.s.currentIndex),e.s.currentIndex=e.s.currentIndex+1,t===r.INSERT?(e.s.currentInsertBatch=e.s.currentBatch,e.s.bulkResult.insertedIds.push({index:e.s.bulkResult.insertedIds.length,_id:n._id})):t===r.UPDATE?e.s.currentUpdateBatch=e.s.currentBatch:t===r.REMOVE&&(e.s.currentRemoveBatch=e.s.currentBatch),e.s.currentBatch.size+=1,e.s.currentBatch.sizeBytes+=c+o,e}class l extends o{constructor(e,t,n){n=n||{},super(e,t,n=Object.assign(n,{addToOperationsList:c}),!1)}handleWriteError(e,t){return!this.s.batches.length&&super.handleWriteError(e,t)}}function u(e,t,n){return new l(e,t,n)}u.UnorderedBulkOperation=l,e.exports=u,e.exports.Bulk=l},function(e,t,n){"use strict";const r=n(76),o=r.BulkOperationBase,s=r.Batch,i=r.bson,a=n(0).toError;function c(e,t,n){const o=i.calculateObjectSize(n,{checkKeys:!1,ignoreUndefined:!1});if(o>=e.s.maxBsonObjectSize)throw a("document is larger than the maximum size "+e.s.maxBsonObjectSize);null==e.s.currentBatch&&(e.s.currentBatch=new s(t,e.s.currentIndex));const c=e.s.maxKeySize;if((e.s.currentBatchSize+1>=e.s.maxWriteBatchSize||e.s.currentBatchSize>0&&e.s.currentBatchSizeBytes+c+o>=e.s.maxBatchSizeBytes||e.s.currentBatch.batchType!==t)&&(e.s.batches.push(e.s.currentBatch),e.s.currentBatch=new s(t,e.s.currentIndex),e.s.currentBatchSize=0,e.s.currentBatchSizeBytes=0),t===r.INSERT&&e.s.bulkResult.insertedIds.push({index:e.s.currentIndex,_id:n._id}),Array.isArray(n))throw a("operation passed in cannot be an Array");return e.s.currentBatch.originalIndexes.push(e.s.currentIndex),e.s.currentBatch.operations.push(n),e.s.currentBatchSize+=1,e.s.currentBatchSizeBytes+=c+o,e.s.currentIndex+=1,e}class l extends o{constructor(e,t,n){n=n||{},super(e,t,n=Object.assign(n,{addToOperationsList:c}),!0)}}function u(e,t,n){return new l(e,t,n)}u.OrderedBulkOperation=l,e.exports=u,e.exports.Bulk=l},function(e,t,n){"use strict";const r=n(60);e.exports=class extends r{constructor(e,t,n){const r=[{$match:t}];"number"==typeof n.skip&&r.push({$skip:n.skip}),"number"==typeof n.limit&&r.push({$limit:n.limit}),r.push({$group:{_id:1,n:{$sum:1}}}),super(e,r,n)}execute(e,t){super.execute(e,(e,n)=>{if(e)return void t(e,null);const r=n.result;if(null==r.cursor||null==r.cursor.firstBatch)return void t(null,0);const o=r.cursor.firstBatch;t(null,o.length?o[0].n:0)})}}},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).removeDocuments,s=n(1).Aspect,i=n(1).defineAspects;class a extends r{constructor(e,t,n){super(n),this.collection=e,this.filter=t}execute(e){const t=this.collection,n=this.filter,r=this.options;r.single=!1,o(t,n,r,(t,n)=>{if(null!=e){if(t&&e)return e(t);if(null==n)return e(null,{result:{ok:1}});if(this.explain)return e(void 0,n.result);n.deletedCount=n.result.n,e(null,n)}})}}i(a,[s.EXPLAINABLE]),e.exports=a},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).removeDocuments,s=n(1).Aspect,i=n(1).defineAspects;class a extends r{constructor(e,t,n){super(n),this.collection=e,this.filter=t}execute(e){const t=this.collection,n=this.filter,r=this.options;r.single=!0,o(t,n,r,(t,n)=>{if(null!=e){if(t&&e)return e(t);if(null==n)return e(null,{result:{ok:1}});if(this.explain)return e(void 0,n.result);n.deletedCount=n.result.n,e(null,n)}})}}i(a,[s.EXPLAINABLE]),e.exports=a},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(21),i=n(0).decorateWithCollation,a=n(0).decorateWithReadConcern,c=n(4).maxWireVersion,l=n(59).MongoError;class u extends s{constructor(e,t,n,r){super(e,r),this.collection=e,this.key=t,this.query=n}execute(e,t){const n=this.collection,r=this.key,o=this.query,s=this.options,u={distinct:n.collectionName,key:r,query:o};"number"==typeof s.maxTimeMS&&(u.maxTimeMS=s.maxTimeMS),a(u,n,s);try{i(u,n,s)}catch(e){return t(e,null)}this.explain&&c(e)<4?t(new l("server does not support explain on distinct")):super.executeCommand(e,u,(e,n)=>{e?t(e):t(null,this.options.full||this.explain?n:n.values)})}}o(u,[r.READ_OPERATION,r.RETRYABLE,r.EXECUTE_WITH_SELECTION,r.EXPLAINABLE]),e.exports=u},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(107),i=n(0).handleCallback;class a extends s{constructor(e,t){super(e,"*",t)}execute(e){super.execute(t=>{if(t)return i(e,t,!1);i(e,null,!0)})}}o(a,r.WRITE_OPERATION),e.exports=a},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(21);class i extends s{constructor(e,t,n){void 0===n&&(n=t,t=void 0),super(e,n),this.collectionName=e.s.namespace.collection,t&&(this.query=t)}execute(e,t){const n=this.options,r={count:this.collectionName};this.query&&(r.query=this.query),"number"==typeof n.skip&&(r.skip=n.skip),"number"==typeof n.limit&&(r.limit=n.limit),n.hint&&(r.hint=n.hint),super.executeCommand(e,r,(e,n)=>{e?t(e):t(null,n.n)})}}o(i,[r.READ_OPERATION,r.RETRYABLE,r.EXECUTE_WITH_SELECTION]),e.exports=i},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(1).Aspect,s=n(1).defineAspects,i=n(2).ReadPreference,a=n(4).maxWireVersion,c=n(3).MongoError;class l extends r{constructor(e,t,n,r){super(r),this.ns=t,this.cmd=n,this.readPreference=i.resolve(e,this.options)}execute(e,t){if(this.server=e,this.readPreference=i.resolve(this,this.options),void 0!==this.cmd.allowDiskUse&&a(e)<4)return void t(new c("The `allowDiskUse` option is not supported on MongoDB < 3.2"));this.explain&&(this.options.explain=this.explain.verbosity);const n=this.cursorState||{};e.query(this.ns.toString(),this.cmd,n,this.options,t)}}s(l,[o.READ_OPERATION,o.RETRYABLE,o.EXECUTE_WITH_SELECTION,o.EXPLAINABLE]),e.exports=l},function(e,t,n){"use strict";const r=n(0).handleCallback,o=n(1).OperationBase,s=n(0).toError,i=n(1).Aspect,a=n(1).defineAspects;class c extends o{constructor(e,t,n){super(n),this.collection=e,this.query=t}execute(e){const t=this.collection,n=this.query,o=this.options;try{t.find(n,o).limit(-1).batchSize(1).next((t,n)=>{if(null!=t)return r(e,s(t),null);r(e,null,n)})}catch(t){e(t)}}}a(c,[i.EXPLAINABLE]),e.exports=c},function(e,t,n){"use strict";const r=n(61);e.exports=class extends r{constructor(e,t,n){const r=Object.assign({},n);if(r.fields=n.projection,r.remove=!0,null==t||"object"!=typeof t)throw new TypeError("Filter parameter must be an object");super(e,t,r.sort,null,r)}}},function(e,t,n){"use strict";const r=n(61),o=n(0).hasAtomicOperators;e.exports=class extends r{constructor(e,t,n,r){const s=Object.assign({},r);if(s.fields=r.projection,s.update=!0,s.new=void 0!==r.returnOriginal&&!r.returnOriginal,s.upsert=void 0!==r.upsert&&!!r.upsert,null==t||"object"!=typeof t)throw new TypeError("Filter parameter must be an object");if(null==n||"object"!=typeof n)throw new TypeError("Replacement parameter must be an object");if(o(n))throw new TypeError("Replacement document must not contain atomic operators");super(e,t,s.sort,n,s)}}},function(e,t,n){"use strict";const r=n(61),o=n(0).hasAtomicOperators;e.exports=class extends r{constructor(e,t,n,r){const s=Object.assign({},r);if(s.fields=r.projection,s.update=!0,s.new="boolean"==typeof r.returnOriginal&&!r.returnOriginal,s.upsert="boolean"==typeof r.upsert&&r.upsert,null==t||"object"!=typeof t)throw new TypeError("Filter parameter must be an object");if(null==n||"object"!=typeof n)throw new TypeError("Update parameter must be an object");if(!o(n))throw new TypeError("Update document requires atomic operators");super(e,t,s.sort,n,s)}}},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(1).OperationBase,i=n(0).decorateCommand,a=n(0).decorateWithReadConcern,c=n(11).executeCommand,l=n(0).handleCallback,u=n(2).ReadPreference,h=n(0).toError;class p extends s{constructor(e,t,n,r){super(r),this.collection=e,this.x=t,this.y=n}execute(e){const t=this.collection,n=this.x,r=this.y;let o=this.options,s={geoSearch:t.collectionName,near:[n,r]};s=i(s,o,["readPreference","session"]),o=Object.assign({},o),o.readPreference=u.resolve(t,o),a(s,t,o),c(t.s.db,s,o,(t,n)=>{if(t)return l(e,t);(n.err||n.errmsg)&&l(e,h(n)),l(e,null,n)})}}o(p,r.READ_OPERATION),e.exports=p},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).indexInformation;e.exports=class extends r{constructor(e,t){super(t),this.collection=e}execute(e){const t=this.collection;let n=this.options;n=Object.assign({},{full:!0},n),o(t.s.db,t.collectionName,n,e)}}},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(0).handleCallback,s=n(11).indexInformation;e.exports=class extends r{constructor(e,t,n){super(n),this.collection=e,this.indexes=t}execute(e){const t=this.collection,n=this.indexes,r=this.options;s(t.s.db,t.collectionName,r,(t,r)=>{if(null!=t)return o(e,t,null);if(!Array.isArray(n))return o(e,null,null!=r[n]);for(let t=0;t{if(t)return e(t,null);e(null,function(e,t){const n={result:{ok:1,n:t.insertedCount},ops:e,insertedCount:t.insertedCount,insertedIds:t.insertedIds};t.getLastOp()&&(n.result.opTime=t.getLastOp());return n}(n,r))})}}},function(e,t,n){"use strict";const r=n(2).MongoError,o=n(1).OperationBase,s=n(13).insertDocuments;e.exports=class extends o{constructor(e,t,n){super(n),this.collection=e,this.doc=t}execute(e){const t=this.collection,n=this.doc,o=this.options;if(Array.isArray(n))return e(r.create({message:"doc parameter must be an object",driver:!0}));s(t,[n],o,(t,r)=>{if(null!=e){if(t&&e)return e(t);if(null==r)return e(null,{result:{ok:1}});r.insertedCount=r.result.n,r.insertedId=n._id,e&&e(null,r)}})}}},function(e,t,n){"use strict";const r=n(109),o=n(0).handleCallback;e.exports=class extends r{constructor(e,t){super(e,t)}execute(e){super.execute((t,n)=>{if(t)return o(e,t);o(e,null,!(!n||!n.capped))})}}},function(e,t,n){"use strict";const r=n(21),o=n(1).Aspect,s=n(1).defineAspects,i=n(4).maxWireVersion;class a extends r{constructor(e,t){super(e,t,{fullResponse:!0}),this.collectionNamespace=e.s.namespace}execute(e,t){if(i(e)<3){const n=this.collectionNamespace.withCollection("system.indexes").toString(),r=this.collectionNamespace.toString();return void e.query(n,{query:{ns:r}},{},this.options,t)}const n=this.options.batchSize?{batchSize:this.options.batchSize}:{};super.executeCommand(e,{listIndexes:this.collectionNamespace.collection,cursor:n},t)}}s(a,[o.READ_OPERATION,o.RETRYABLE,o.EXECUTE_WITH_SELECTION]),e.exports=a},function(e,t,n){"use strict";const r=n(0).applyWriteConcern,o=n(2).BSON.Code,s=n(0).decorateWithCollation,i=n(0).decorateWithReadConcern,a=n(11).executeCommand,c=n(0).handleCallback,l=n(0).isObject,u=n(80).loadDb,h=n(1).OperationBase,p=n(2).ReadPreference,f=n(0).toError,d=n(1).Aspect,m=n(1).defineAspects,y=n(0).decorateWithExplain,g=n(4).maxWireVersion,b=n(59).MongoError,S=["explain","readPreference","session","bypassDocumentValidation","w","wtimeout","j","writeConcern"];class v extends h{constructor(e,t,n,r){super(r),this.collection=e,this.map=t,this.reduce=n}execute(e){const t=this.collection,n=this.map,o=this.reduce;let l=this.options,h={mapReduce:t.collectionName,map:n,reduce:o};for(let e in l)"scope"===e?h[e]=w(l[e]):-1===S.indexOf(e)&&(h[e]=l[e]);l=Object.assign({},l),l.readPreference=p.resolve(t,l),!1!==l.readPreference&&"primary"!==l.readPreference&&l.out&&1!==l.out.inline&&"inline"!==l.out?(l.readPreference="primary",r(h,{db:t.s.db,collection:t},l)):i(h,t,l),!0===l.bypassDocumentValidation&&(h.bypassDocumentValidation=l.bypassDocumentValidation);try{s(h,t,l)}catch(t){return e(t,null)}if(this.explain){if(g(t.s.topology)<9)return void e(new b("server does not support explain on mapReduce"));h=y(h,this.explain)}a(t.s.db,h,l,(n,r)=>{if(n)return c(e,n);if(1!==r.ok||r.err||r.errmsg)return c(e,f(r));if(this.explain)return e(void 0,r);const o={};if(r.timeMillis&&(o.processtime=r.timeMillis),r.counts&&(o.counts=r.counts),r.timing&&(o.timing=r.timing),r.results)return null!=l.verbose&&l.verbose?c(e,null,{results:r.results,stats:o}):c(e,null,r.results);let s=null;if(null!=r.result&&"object"==typeof r.result){const e=r.result;s=new(u())(e.db,t.s.db.s.topology,t.s.db.s.options).collection(e.collection)}else s=t.s.db.collection(r.result);if(null==l.verbose||!l.verbose)return c(e,n,s);c(e,n,{collection:s,stats:o})})}}function w(e){if(!l(e)||"ObjectID"===e._bsontype)return e;const t=Object.keys(e);let n;const r={};for(let s=t.length-1;s>=0;s--)n=t[s],"function"==typeof e[n]?r[n]=new o(String(e[n])):r[n]=w(e[n]);return r}m(v,[d.EXPLAINABLE]),e.exports=v},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(0).handleCallback;let s;e.exports=class extends r{constructor(e,t){super(t),this.db=e}execute(e){const t=this.db;let r=this.options,i=(s||(s=n(42)),s);r=Object.assign({},r,{nameOnly:!0}),t.listCollections({},r).toArray((n,r)=>{if(null!=n)return o(e,n,null);r=r.filter(e=>-1===e.name.indexOf("$")),o(e,null,r.map(e=>new i(t,t.s.topology,t.databaseName,e.name,t.s.pkFactory,t.s.options)))})}}},function(e,t,n){"use strict";const r=n(21),o=n(1).defineAspects,s=n(1).Aspect;class i extends r{constructor(e,t,n){super(e,n),this.command=t}execute(e,t){const n=this.command;this.executeCommand(e,n,t)}}o(i,[s.EXECUTE_WITH_SELECTION,s.NO_INHERIT_OPTIONS]),e.exports=i},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(18),i=n(0).applyWriteConcern,a=n(80).loadCollection,c=n(2).MongoError,l=n(2).ReadPreference,u=new Set(["w","wtimeout","j","fsync","autoIndexId","strict","serializeFunctions","pkFactory","raw","readPreference","session","readConcern","writeConcern"]);class h extends s{constructor(e,t,n){super(e,n),this.name=t}_buildCommand(){const e=this.name,t=this.options,n={create:e};for(let e in t)null==t[e]||"function"==typeof t[e]||u.has(e)||(n[e]=t[e]);return n}execute(e){const t=this.db,n=this.name,r=this.options,o=a();let s=Object.assign({nameOnly:!0,strict:!1},r);function u(s){if(s)return e(s);try{e(null,new o(t,t.s.topology,t.databaseName,n,t.s.pkFactory,r))}catch(s){e(s)}}s=i(s,{db:t},s);s.strict?t.listCollections({name:n},s).setReadPreference(l.PRIMARY).toArray((t,r)=>t?e(t):r.length>0?e(new c(`Collection ${n} already exists. Currently in strict mode.`)):void super.execute(u)):super.execute(u)}}o(h,r.WRITE_OPERATION),e.exports=h},function(e,t,n){"use strict";const r=n(21),o=n(1).Aspect,s=n(1).defineAspects,i=n(4).maxWireVersion,a=n(75);class c extends r{constructor(e,t,n){super(e,n,{fullResponse:!0}),this.db=e,this.filter=t,this.nameOnly=!!this.options.nameOnly,"number"==typeof this.options.batchSize&&(this.batchSize=this.options.batchSize)}execute(e,t){if(i(e)<3){let n=this.filter;const r=this.db.s.namespace.db;"string"!=typeof n.name||new RegExp("^"+r+"\\.").test(n.name)||(n=Object.assign({},n),n.name=this.db.s.namespace.withCollection(n.name).toString()),null==n&&(n.name=`/${r}/`),n=n.name?{$and:[{name:n.name},{name:/^((?!\$).)*$/}]}:{name:/^((?!\$).)*$/};const o=function(e){const t=e+".";return{doc:e=>{const n=e.name.indexOf(t);return e.name&&0===n&&(e.name=e.name.substr(n+t.length)),e}}}(r);return void e.query(`${r}.${a.SYSTEM_NAMESPACE_COLLECTION}`,{query:n},{batchSize:this.batchSize||1e3},{},(e,n)=>{n&&n.message&&n.message.documents&&Array.isArray(n.message.documents)&&(n.message.documents=n.message.documents.map(o.doc)),t(e,n)})}const n={listCollections:1,filter:this.filter,cursor:this.batchSize?{batchSize:this.batchSize}:{},nameOnly:this.nameOnly};return super.executeCommand(e,n,t)}}s(c,[o.READ_OPERATION,o.RETRYABLE,o.EXECUTE_WITH_SELECTION]),e.exports=c},function(e,t,n){"use strict";const r=n(18);e.exports=class extends r{constructor(e,t,n){super(e,n)}_buildCommand(){return{profile:-1}}execute(e){super.execute((t,n)=>{if(null==t&&1===n.ok){const t=n.was;return 0===t?e(null,"off"):1===t?e(null,"slow_only"):2===t?e(null,"all"):e(new Error("Error: illegal profiling level value "+t),null)}e(null!=t?t:new Error("Error with profile command"),null)})}}},function(e,t,n){"use strict";const r=n(18),o=new Set(["off","slow_only","all"]);e.exports=class extends r{constructor(e,t,n){let r=0;"off"===t?r=0:"slow_only"===t?r=1:"all"===t&&(r=2),super(e,n),this.level=t,this.profile=r}_buildCommand(){return{profile:this.profile}}execute(e){const t=this.level;if(!o.has(t))return e(new Error("Error: illegal profiling level value "+t));super.execute((n,r)=>null==n&&1===r.ok?e(null,t):e(null!=n?n:new Error("Error with profile command"),null))}}},function(e,t,n){"use strict";const r=n(18);e.exports=class extends r{constructor(e,t,n){let r={validate:t};const o=Object.keys(n);for(let e=0;enull!=n?e(n,null):0===r.ok?e(new Error("Error with validate command"),null):null!=r.result&&r.result.constructor!==String?e(new Error("Error with validation data"),null):null!=r.result&&null!=r.result.match(/exception|corrupt/)?e(new Error("Error: invalid collection "+t),null):null==r.valid||r.valid?e(null,r):e(new Error("Error: invalid collection "+t),null))}}},function(e,t,n){"use strict";const r=n(21),o=n(1).Aspect,s=n(1).defineAspects,i=n(0).MongoDBNamespace;class a extends r{constructor(e,t){super(e,t),this.ns=new i("admin","$cmd")}execute(e,t){const n={listDatabases:1};this.options.nameOnly&&(n.nameOnly=Number(n.nameOnly)),this.options.filter&&(n.filter=this.options.filter),"boolean"==typeof this.options.authorizedDatabases&&(n.authorizedDatabases=this.options.authorizedDatabases),super.executeCommand(e,n,t)}}s(a,[o.READ_OPERATION,o.RETRYABLE,o.EXECUTE_WITH_SELECTION]),e.exports=a},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(1).defineAspects,s=n(21),i=n(12).serverType,a=n(12).ServerType,c=n(2).MongoError;class l extends s{constructor(e,t){super(e,t),this.collectionName=e.collectionName}execute(e,t){i(e)===a.Standalone?super.executeCommand(e,{reIndex:this.collectionName},(e,n)=>{e?t(e):t(null,!!n.ok)}):t(new c("reIndex can only be executed on standalone servers."))}}o(l,[r.EXECUTE_WITH_SELECTION]),e.exports=l},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).updateDocuments,s=n(0).hasAtomicOperators;e.exports=class extends r{constructor(e,t,n,r){if(super(r),s(n))throw new TypeError("Replacement document must not contain atomic operators");this.collection=e,this.filter=t,this.replacement=n}execute(e){const t=this.collection,n=this.filter,r=this.replacement,s=this.options;s.multi=!1,o(t,n,r,s,(t,n)=>function(e,t,n,r){if(null==r)return;if(e&&r)return r(e);if(null==t)return r(null,{result:{ok:1}});t.modifiedCount=null!=t.result.nModified?t.result.nModified:t.result.n,t.upsertedId=Array.isArray(t.result.upserted)&&t.result.upserted.length>0?t.result.upserted[0]:null,t.upsertedCount=Array.isArray(t.result.upserted)&&t.result.upserted.length?t.result.upserted.length:0,t.matchedCount=Array.isArray(t.result.upserted)&&t.result.upserted.length>0?0:t.result.n,t.ops=[n],r&&r(null,t)}(t,n,r,e))}}},function(e,t,n){"use strict";const r=n(1).Aspect,o=n(18),s=n(1).defineAspects;class i extends o{constructor(e,t){super(e.s.db,t,e)}_buildCommand(){const e=this.collection,t=this.options,n={collStats:e.collectionName};return null!=t.scale&&(n.scale=t.scale),n}}s(i,r.READ_OPERATION),e.exports=i},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).updateDocuments,s=n(0).hasAtomicOperators,i=n(1).Aspect,a=n(1).defineAspects;class c extends r{constructor(e,t,n,r){if(super(r),!s(n))throw new TypeError("Update document requires atomic operators");this.collection=e,this.filter=t,this.update=n}execute(e){const t=this.collection,n=this.filter,r=this.update,s=this.options;s.multi=!0,o(t,n,r,s,(t,n)=>{if(null!=e){if(t)return e(t);if(null==n)return e(null,{result:{ok:1}});if(this.explain)return e(void 0,n.result);n.modifiedCount=null!=n.result.nModified?n.result.nModified:n.result.n,n.upsertedId=Array.isArray(n.result.upserted)&&n.result.upserted.length>0?n.result.upserted[0]:null,n.upsertedCount=Array.isArray(n.result.upserted)&&n.result.upserted.length?n.result.upserted.length:0,n.matchedCount=Array.isArray(n.result.upserted)&&n.result.upserted.length>0?0:n.result.n,e(null,n)}})}}a(c,[i.EXPLAINABLE]),e.exports=c},function(e,t,n){"use strict";const r=n(1).OperationBase,o=n(13).updateDocuments,s=n(0).hasAtomicOperators,i=n(1).Aspect,a=n(1).defineAspects;class c extends r{constructor(e,t,n,r){if(super(r),!s(n))throw new TypeError("Update document requires atomic operators");this.collection=e,this.filter=t,this.update=n}execute(e){const t=this.collection,n=this.filter,r=this.update,s=this.options;s.multi=!1,o(t,n,r,s,(t,n)=>{if(null!=e){if(t)return e(t);if(null==n)return e(null,{result:{ok:1}});if(this.explain)return e(void 0,n.result);n.modifiedCount=null!=n.result.nModified?n.result.nModified:n.result.n,n.upsertedId=Array.isArray(n.result.upserted)&&n.result.upserted.length>0?n.result.upserted[0]:null,n.upsertedCount=Array.isArray(n.result.upserted)&&n.result.upserted.length?n.result.upserted.length:0,n.matchedCount=Array.isArray(n.result.upserted)&&n.result.upserted.length>0?0:n.result.n,e(null,n)}})}}a(c,[i.EXPLAINABLE]),e.exports=c},function(e,t,n){"use strict";const r=n(2).ReadPreference,o=n(71),s=n(5).format,i=n(2).Logger,a=n(54),c=n(32),l=n(104),u=n(3).MongoParseError;function h(e,t){let n=/^.*?\./,r="."+e.replace(n,""),o="."+t.replace(n,"");return!!r.endsWith(o)}function p(e,t,n){let a,l;try{a=function(e,t){let n="",a="",l="",u="admin",h=o.parse(e,!0);if((null==h.hostname||""===h.hostname)&&-1===e.indexOf(".sock"))throw new Error("No hostname or hostnames provided in connection string");if("0"===h.port)throw new Error("Invalid port (zero) with hostname");if(!isNaN(parseInt(h.port,10))&&parseInt(h.port,10)>65535)throw new Error("Invalid port (larger than 65535) with hostname");if(h.path&&h.path.length>0&&"/"!==h.path[0]&&-1===e.indexOf(".sock"))throw new Error("Missing delimiting slash between hosts and options");if(h.query)for(let e in h.query){if(-1!==e.indexOf("::"))throw new Error("Double colon in host identifier");if(""===h.query[e])throw new Error("Query parameter "+e+" is an incomplete value pair")}if(h.auth){let t=h.auth.split(":");if(-1!==e.indexOf(h.auth)&&t.length>2)throw new Error("Username with password containing an unescaped colon");if(-1!==e.indexOf(h.auth)&&-1!==h.auth.indexOf("@"))throw new Error("Username containing an unescaped at-sign")}let p=e.split("?").shift().split(","),f=[];for(let e=0;e1&&-1===t.path.indexOf("::")?new Error("Slash in host identifier"):new Error("Double colon in host identifier")}-1!==e.indexOf("?")?(l=e.substr(e.indexOf("?")+1),n=e.substring("mongodb://".length,e.indexOf("?"))):n=e.substring("mongodb://".length);-1!==n.indexOf("@")&&(a=n.split("@")[0],n=n.split("@")[1]);if(n.split("/").length>2)throw new Error("Unsupported host '"+n.split("?")[0]+"', hosts must be URL encoded and contain at most one unencoded slash");if(-1!==n.indexOf(".sock")){if(-1!==n.indexOf(".sock/")){if(u=n.split(".sock/")[1],-1!==u.indexOf("/")){if(2===u.split("/").length&&0===u.split("/")[1].length)throw new Error("Illegal trailing backslash after database name");throw new Error("More than 1 database name in URL")}n=n.split("/",n.indexOf(".sock")+".sock".length)}}else if(-1!==n.indexOf("/")){if(n.split("/").length>2){if(0===n.split("/")[2].length)throw new Error("Illegal trailing backslash after database name");throw new Error("More than 1 database name in URL")}u=n.split("/")[1],n=n.split("/")[0]}n=decodeURIComponent(n);let d,m,y,g,b={},S=a||"",v=S.split(":",2),w=decodeURIComponent(v[0]);if(v[0]!==encodeURIComponent(w))throw new Error("Username contains an illegal unescaped character");if(v[0]=w,v[1]){let e=decodeURIComponent(v[1]);if(v[1]!==encodeURIComponent(e))throw new Error("Password contains an illegal unescaped character");v[1]=e}2===v.length&&(b.auth={user:v[0],password:v[1]});t&&null!=t.auth&&(b.auth=t.auth);let O={socketOptions:{}},_={read_preference_tags:[]},T={socketOptions:{}},E={socketOptions:{}};if(b.server_options=O,b.db_options=_,b.rs_options=T,b.mongos_options=E,e.match(/\.sock/)){let t=e.substring(e.indexOf("mongodb://")+"mongodb://".length,e.lastIndexOf(".sock")+".sock".length);-1!==t.indexOf("@")&&(t=t.split("@")[1]),t=decodeURIComponent(t),y=[{domain_socket:t}]}else{d=n;let e={};y=d.split(",").map((function(t){let n,r,o;if(o=/\[([^\]]+)\](?::(.+))?/.exec(t))n=o[1],r=parseInt(o[2],10)||27017;else{let e=t.split(":",2);n=e[0]||"localhost",r=null!=e[1]?parseInt(e[1],10):27017,-1!==n.indexOf("?")&&(n=n.split(/\?/)[0])}return e[n+"_"+r]?null:(e[n+"_"+r]=1,{host:n,port:r})})).filter((function(e){return null!=e}))}b.dbName=u||"admin",m=(l||"").split(/[&;]/),m.forEach((function(e){if(e){var t=e.split("="),n=t[0],o=t[1];switch(n){case"slaveOk":case"slave_ok":O.slave_ok="true"===o,_.slaveOk="true"===o;break;case"maxPoolSize":case"poolSize":O.poolSize=parseInt(o,10),T.poolSize=parseInt(o,10);break;case"appname":b.appname=decodeURIComponent(o);break;case"autoReconnect":case"auto_reconnect":O.auto_reconnect="true"===o;break;case"ssl":if("prefer"===o){O.ssl=o,T.ssl=o,E.ssl=o;break}O.ssl="true"===o,T.ssl="true"===o,E.ssl="true"===o;break;case"sslValidate":O.sslValidate="true"===o,T.sslValidate="true"===o,E.sslValidate="true"===o;break;case"replicaSet":case"rs_name":T.rs_name=o;break;case"reconnectWait":T.reconnectWait=parseInt(o,10);break;case"retries":T.retries=parseInt(o,10);break;case"readSecondary":case"read_secondary":T.read_secondary="true"===o;break;case"fsync":_.fsync="true"===o;break;case"journal":_.j="true"===o;break;case"safe":_.safe="true"===o;break;case"nativeParser":case"native_parser":_.native_parser="true"===o;break;case"readConcernLevel":_.readConcern=new c(o);break;case"connectTimeoutMS":O.socketOptions.connectTimeoutMS=parseInt(o,10),T.socketOptions.connectTimeoutMS=parseInt(o,10),E.socketOptions.connectTimeoutMS=parseInt(o,10);break;case"socketTimeoutMS":O.socketOptions.socketTimeoutMS=parseInt(o,10),T.socketOptions.socketTimeoutMS=parseInt(o,10),E.socketOptions.socketTimeoutMS=parseInt(o,10);break;case"w":_.w=parseInt(o,10),isNaN(_.w)&&(_.w=o);break;case"authSource":_.authSource=o;break;case"gssapiServiceName":_.gssapiServiceName=o;break;case"authMechanism":if("GSSAPI"===o)if(null==b.auth){let e=decodeURIComponent(S);if(-1===e.indexOf("@"))throw new Error("GSSAPI requires a provided principal");b.auth={user:e,password:null}}else b.auth.user=decodeURIComponent(b.auth.user);else"MONGODB-X509"===o&&(b.auth={user:decodeURIComponent(S)});if("GSSAPI"!==o&&"MONGODB-X509"!==o&&"MONGODB-CR"!==o&&"DEFAULT"!==o&&"SCRAM-SHA-1"!==o&&"SCRAM-SHA-256"!==o&&"PLAIN"!==o)throw new Error("Only DEFAULT, GSSAPI, PLAIN, MONGODB-X509, or SCRAM-SHA-1 is supported by authMechanism");_.authMechanism=o;break;case"authMechanismProperties":{let e=o.split(","),t={};e.forEach((function(e){let n=e.split(":");t[n[0]]=n[1]})),_.authMechanismProperties=t,"string"==typeof t.SERVICE_NAME&&(_.gssapiServiceName=t.SERVICE_NAME),"string"==typeof t.SERVICE_REALM&&(_.gssapiServiceRealm=t.SERVICE_REALM),"string"==typeof t.CANONICALIZE_HOST_NAME&&(_.gssapiCanonicalizeHostName="true"===t.CANONICALIZE_HOST_NAME)}break;case"wtimeoutMS":_.wtimeout=parseInt(o,10);break;case"readPreference":if(!r.isValid(o))throw new Error("readPreference must be either primary/primaryPreferred/secondary/secondaryPreferred/nearest");_.readPreference=o;break;case"maxStalenessSeconds":_.maxStalenessSeconds=parseInt(o,10);break;case"readPreferenceTags":{let e={};if(null==(o=decodeURIComponent(o))||""===o){_.read_preference_tags.push(e);break}let t=o.split(/,/);for(let n=0;n9)throw new Error("zlibCompressionLevel must be an integer between -1 and 9");g.zlibCompressionLevel=e,O.compression=g}break;case"retryWrites":_.retryWrites="true"===o;break;case"minSize":_.minSize=parseInt(o,10);break;default:i("URL Parser").warn(n+" is not supported as a connection string option")}}})),0===_.read_preference_tags.length&&(_.read_preference_tags=null);if(!(-1!==_.w&&0!==_.w||!0!==_.journal&&!0!==_.fsync&&!0!==_.safe))throw new Error("w set to -1 or 0 cannot be combined with safe/w/journal/fsync");_.readPreference||(_.readPreference="primary");return _=Object.assign(_,t),b.servers=y,b}(e,t)}catch(e){l=e}return l?n(l,null):n(null,a)}e.exports=function(e,t,n){let r;"function"==typeof t&&(n=t,t={}),t=t||{};try{r=o.parse(e,!0)}catch(e){return n(new Error("URL malformed, cannot be parsed"))}if("mongodb:"!==r.protocol&&"mongodb+srv:"!==r.protocol)return n(new Error("Invalid schema, expected `mongodb` or `mongodb+srv`"));if("mongodb:"===r.protocol)return p(e,t,n);if(r.hostname.split(".").length<3)return n(new Error("URI does not have hostname, domain name and tld"));if(r.domainLength=r.hostname.split(".").length,r.pathname&&r.pathname.match(","))return n(new Error("Invalid URI, cannot contain multiple hostnames"));if(r.port)return n(new Error("Ports not accepted with `mongodb+srv` URIs"));let s="_mongodb._tcp."+r.host;a.resolveSrv(s,(function(e,o){if(e)return n(e);if(0===o.length)return n(new Error("No addresses found at host"));for(let e=0;e1)return n(new u("Multiple text records not allowed"));r=r[0].join("");const e=l.parse(r),t=Object.keys(e);if(t.some(e=>"authSource"!==e&&"replicaSet"!==e))return n(new u("Text record must only set `authSource` or `replicaSet`"));t.length>0&&c.push(r)}c.length&&(i+="?"+c.join("&")),p(i,t,n)}))}))}},function(e,t,n){"use strict";const r=n(120),o=n(2).BSON.ObjectID,s=n(2).ReadPreference,i=n(17).Buffer,a=n(70),c=n(5).format,l=n(5),u=n(2).MongoError,h=l.inherits,p=n(19).Duplex,f=n(0).shallowClone,d=n(0).executeLegacyOperation,m=n(5).deprecate;const y=m(()=>{},"GridStore is deprecated, and will be removed in a future version. Please use GridFSBucket instead");var g=function e(t,n,i,a,c){if(y(),!(this instanceof e))return new e(t,n,i,a,c);this.db=t,void 0===c&&(c={}),void 0===a?(a=i,i=void 0):"object"==typeof a&&(c=a,a=i,i=void 0),n&&"ObjectID"===n._bsontype?(this.referenceBy=1,this.fileId=n,this.filename=i):void 0===i?(this.referenceBy=0,this.filename=n,null!=a.indexOf("w")&&(this.fileId=new o)):(this.referenceBy=1,this.fileId=n,this.filename=i),this.mode=null==a?"r":a,this.options=c||{},this.isOpen=!1,this.root=null==this.options.root?e.DEFAULT_ROOT_COLLECTION:this.options.root,this.position=0,this.readPreference=this.options.readPreference||t.options.readPreference||s.primary,this.writeConcern=z(t,this.options),this.internalChunkSize=null==this.options.chunkSize?r.DEFAULT_CHUNK_SIZE:this.options.chunkSize;var l=this.options.promiseLibrary||Promise;this.promiseLibrary=l,Object.defineProperty(this,"chunkSize",{enumerable:!0,get:function(){return this.internalChunkSize},set:function(e){"w"!==this.mode[0]||0!==this.position||null!=this.uploadDate?this.internalChunkSize=this.internalChunkSize:this.internalChunkSize=e}}),Object.defineProperty(this,"md5",{enumerable:!0,get:function(){return this.internalMd5}}),Object.defineProperty(this,"chunkNumber",{enumerable:!0,get:function(){return this.currentChunk&&this.currentChunk.chunkNumber?this.currentChunk.chunkNumber:null}})};g.prototype.open=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"w"!==this.mode&&"w+"!==this.mode&&"r"!==this.mode)throw u.create({message:"Illegal mode "+this.mode,driver:!0});return d(this.db.s.topology,b,[this,e,t],{skipSessions:!0})};var b=function(e,t,n){var r=z(e.db,e.options);"w"===e.mode||"w+"===e.mode?e.collection().ensureIndex([["filename",1]],r,(function(){var t=e.chunkCollection(),o=f(r);o.unique=!0,t.ensureIndex([["files_id",1],["n",1]],o,(function(){x(e,r,(function(t,r){if(t)return n(t);e.isOpen=!0,n(t,r)}))}))})):x(e,r,(function(t,r){if(t)return n(t);e.isOpen=!0,n(t,r)}))};g.prototype.eof=function(){return this.position===this.length},g.prototype.getc=function(e,t){return"function"==typeof e&&(t=e,e={}),e=e||{},d(this.db.s.topology,S,[this,e,t],{skipSessions:!0})};var S=function(e,t,n){e.eof()?n(null,null):e.currentChunk.eof()?A(e,e.currentChunk.chunkNumber+1,(function(t,r){e.currentChunk=r,e.position=e.position+1,n(t,e.currentChunk.getc())})):(e.position=e.position+1,n(null,e.currentChunk.getc()))};g.prototype.puts=function(e,t,n){"function"==typeof t&&(n=t,t={}),t=t||{};var r=null==e.match(/\n$/)?e+"\n":e;return d(this.db.s.topology,this.write.bind(this),[r,t,n],{skipSessions:!0})},g.prototype.stream=function(){return new W(this)},g.prototype.write=function(e,t,n,r){return"function"==typeof n&&(r=n,n={}),n=n||{},d(this.db.s.topology,j,[this,e,t,n,r],{skipSessions:!0})},g.prototype.destroy=function(){this.writable&&(this.readable=!1,this.writable&&(this.writable=!1,this._q.length=0,this.emit("close")))},g.prototype.writeFile=function(e,t,n){return"function"==typeof t&&(n=t,t={}),t=t||{},d(this.db.s.topology,v,[this,e,t,n],{skipSessions:!0})};var v=function(e,t,n,o){"string"!=typeof t?e.open((function(e,n){if(e)return o(e,n);a.fstat(t,(function(e,s){if(e)return o(e,n);var c=0,l=0,u=function(){var e=i.alloc(n.chunkSize);a.read(t,e,0,e.length,c,(function(e,i,h){if(e)return o(e,n);c+=i,new r(n,{n:l++},n.writeConcern).write(h.slice(0,i),(function(e,r){if(e)return o(e,n);r.save({},(function(e){return e?o(e,n):(n.position=n.position+i,n.currentChunk=r,c>=s.size?void a.close(t,(function(e){if(e)return o(e);n.close((function(e){return o(e||null,n)}))})):process.nextTick(u))}))}))}))};process.nextTick(u)}))})):a.open(t,"r",(function(t,n){if(t)return o(t);e.writeFile(n,o)}))};g.prototype.close=function(e,t){return"function"==typeof e&&(t=e,e={}),e=e||{},d(this.db.s.topology,w,[this,e,t],{skipSessions:!0})};var w=function(e,t,n){"w"===e.mode[0]?(t=Object.assign({},e.writeConcern,t),null!=e.currentChunk&&e.currentChunk.position>0?e.currentChunk.save({},(function(r){if(r&&"function"==typeof n)return n(r);e.collection((function(r,o){if(r&&"function"==typeof n)return n(r);null!=e.uploadDate||(e.uploadDate=new Date),I(e,(function(e,r){if(e){if("function"==typeof n)return n(e);throw e}o.save(r,t,(function(e){"function"==typeof n&&n(e,r)}))}))}))})):e.collection((function(r,o){if(r&&"function"==typeof n)return n(r);e.uploadDate=new Date,I(e,(function(e,r){if(e){if("function"==typeof n)return n(e);throw e}o.save(r,t,(function(e){"function"==typeof n&&n(e,r)}))}))}))):"r"===e.mode[0]?"function"==typeof n&&n(null,null):"function"==typeof n&&n(u.create({message:c("Illegal mode %s",e.mode),driver:!0}))};g.prototype.chunkCollection=function(e){return"function"==typeof e?this.db.collection(this.root+".chunks",e):this.db.collection(this.root+".chunks")},g.prototype.unlink=function(e,t){return"function"==typeof e&&(t=e,e={}),e=e||{},d(this.db.s.topology,O,[this,e,t],{skipSessions:!0})};var O=function(e,t,n){M(e,(function(t){if(null!==t)return t.message="at deleteChunks: "+t.message,n(t);e.collection((function(t,r){if(null!==t)return t.message="at collection: "+t.message,n(t);r.remove({_id:e.fileId},e.writeConcern,(function(t){n(t,e)}))}))}))};g.prototype.collection=function(e){return"function"==typeof e&&this.db.collection(this.root+".files",e),this.db.collection(this.root+".files")},g.prototype.readlines=function(e,t,n){var r=Array.prototype.slice.call(arguments,0);return n="function"==typeof r[r.length-1]?r.pop():void 0,e=(e=r.length?r.shift():"\n")||"\n",t=r.length?r.shift():{},d(this.db.s.topology,_,[this,e,t,n],{skipSessions:!0})};var _=function(e,t,n,r){e.read((function(e,n){if(e)return r(e);var o=n.toString().split(t);o=o.length>0?o.splice(0,o.length-1):[];for(var s=0;s=s){var c=e.currentChunk.readSlice(s-a._index);return c.copy(a,a._index),e.position=e.position+a.length,0===s&&0===a.length?o(u.create({message:"File does not exist",driver:!0}),null):o(null,a)}(c=e.currentChunk.readSlice(e.currentChunk.length()-e.currentChunk.position)).copy(a,a._index),a._index+=c.length,A(e,e.currentChunk.chunkNumber+1,(function(n,r){if(n)return o(n);r.length()>0?(e.currentChunk=r,e.read(t,a,o)):a._index>0?o(null,a):o(u.create({message:"no chunks found for file, possibly corrupt",driver:!0}),null)}))};g.prototype.tell=function(e){var t=this;return"function"==typeof e?e(null,this.position):new t.promiseLibrary((function(e){e(t.position)}))},g.prototype.seek=function(e,t,n,r){var o=Array.prototype.slice.call(arguments,1);return r="function"==typeof o[o.length-1]?o.pop():void 0,t=o.length?o.shift():null,n=o.length?o.shift():{},d(this.db.s.topology,C,[this,e,t,n,r],{skipSessions:!0})};var C=function(e,t,n,r,o){if("r"!==e.mode)return o(u.create({message:"seek is only supported for mode r",driver:!0}));var s=null==n?g.IO_SEEK_SET:n,i=t,a=0;a=s===g.IO_SEEK_CUR?e.position+i:s===g.IO_SEEK_END?e.length+i:i;var c=Math.floor(a/e.chunkSize);A(e,c,(function(t,n){return t?o(t,null):null==n?o(new Error("no chunk found")):(e.currentChunk=n,e.position=a,e.currentChunk.position=e.position%e.chunkSize,void o(t,e))}))},x=function(e,t,n){var s=e.collection(),i=1===e.referenceBy?{_id:e.fileId}:{filename:e.filename};function a(e){a.err||n(a.err=e)}i=null==e.fileId&&null==e.filename?null:i,t.readPreference=e.readPreference,null!=i?s.findOne(i,t,(function(s,i){if(s)return a(s);if(null!=i)e.fileId=i._id,e.filename="r"===e.mode||void 0===e.filename?i.filename:e.filename,e.contentType=i.contentType,e.internalChunkSize=i.chunkSize,e.uploadDate=i.uploadDate,e.aliases=i.aliases,e.length=i.length,e.metadata=i.metadata,e.internalMd5=i.md5;else{if("r"===e.mode){e.length=0;var l="ObjectID"===e.fileId._bsontype?e.fileId.toHexString():e.fileId;return a(u.create({message:c("file with id %s not opened for writing",1===e.referenceBy?l:e.filename),driver:!0}))}e.fileId=null==e.fileId?new o:e.fileId,e.contentType=g.DEFAULT_CONTENT_TYPE,e.internalChunkSize=null==e.internalChunkSize?r.DEFAULT_CHUNK_SIZE:e.internalChunkSize,e.length=0}"r"===e.mode?A(e,0,t,(function(t,r){if(t)return a(t);e.currentChunk=r,e.position=0,n(null,e)})):"w"===e.mode&&i?M(e,t,(function(t){if(t)return a(t);e.currentChunk=new r(e,{n:0},e.writeConcern),e.contentType=null==e.options.content_type?e.contentType:e.options.content_type,e.internalChunkSize=null==e.options.chunk_size?e.internalChunkSize:e.options.chunk_size,e.metadata=null==e.options.metadata?e.metadata:e.options.metadata,e.aliases=null==e.options.aliases?e.aliases:e.options.aliases,e.position=0,n(null,e)})):"w"===e.mode?(e.currentChunk=new r(e,{n:0},e.writeConcern),e.contentType=null==e.options.content_type?e.contentType:e.options.content_type,e.internalChunkSize=null==e.options.chunk_size?e.internalChunkSize:e.options.chunk_size,e.metadata=null==e.options.metadata?e.metadata:e.options.metadata,e.aliases=null==e.options.aliases?e.aliases:e.options.aliases,e.position=0,n(null,e)):"w+"===e.mode&&A(e,k(e),t,(function(t,o){if(t)return a(t);e.currentChunk=null==o?new r(e,{n:0},e.writeConcern):o,e.currentChunk.position=e.currentChunk.data.length(),e.metadata=null==e.options.metadata?e.metadata:e.options.metadata,e.aliases=null==e.options.aliases?e.aliases:e.options.aliases,e.position=e.length,n(null,e)}))})):(e.fileId=null==e.fileId?new o:e.fileId,e.contentType=g.DEFAULT_CONTENT_TYPE,e.internalChunkSize=null==e.internalChunkSize?r.DEFAULT_CHUNK_SIZE:e.internalChunkSize,e.length=0,"w"===e.mode?M(e,t,(function(t){if(t)return a(t);e.currentChunk=new r(e,{n:0},e.writeConcern),e.contentType=null==e.options.content_type?e.contentType:e.options.content_type,e.internalChunkSize=null==e.options.chunk_size?e.internalChunkSize:e.options.chunk_size,e.metadata=null==e.options.metadata?e.metadata:e.options.metadata,e.aliases=null==e.options.aliases?e.aliases:e.options.aliases,e.position=0,n(null,e)})):"w+"===e.mode&&A(e,k(e),t,(function(t,o){if(t)return a(t);e.currentChunk=null==o?new r(e,{n:0},e.writeConcern):o,e.currentChunk.position=e.currentChunk.data.length(),e.metadata=null==e.options.metadata?e.metadata:e.options.metadata,e.aliases=null==e.options.aliases?e.aliases:e.options.aliases,e.position=e.length,n(null,e)})))},N=function(e,t,n,o){"function"==typeof n&&(o=n,n=null);var s="boolean"==typeof n&&n;if("w"!==e.mode)o(u.create({message:c("file with id %s not opened for writing",1===e.referenceBy?e.referenceBy:e.filename),driver:!0}),null);else{if(!(e.currentChunk.position+t.length>=e.chunkSize))return e.position=e.position+t.length,e.currentChunk.write(t),s?e.close((function(t){o(t,e)})):o(null,e);for(var i=e.currentChunk.chunkNumber,a=e.chunkSize-e.currentChunk.position,l=t.slice(0,a),h=t.slice(a),p=[e.currentChunk.write(l)];h.length>=e.chunkSize;){var f=new r(e,{n:i+1},e.writeConcern);l=h.slice(0,e.chunkSize),h=h.slice(e.chunkSize),i+=1,f.write(l),p.push(f)}e.currentChunk=new r(e,{n:i+1},e.writeConcern),h.length>0&&e.currentChunk.write(h),e.position=e.position+t.length;for(var d=p.length,m=0;m=t.length?s("offset larger than size of file",null):n&&n>t.length?s("length is larger than the size of the file",null):r&&n&&r+n>t.length?s("offset and length is larger than the size of the file",null):void(null!=r?t.seek(r,(function(e,t){if(e)return s(e);t.read(n,s)})):t.read(n,s))}))};g.readlines=function(e,t,n,r,o){var s=Array.prototype.slice.call(arguments,2);return o="function"==typeof s[s.length-1]?s.pop():void 0,n=s.length?s.shift():null,r=(r=s.length?s.shift():null)||{},d(e.s.topology,D,[e,t,n,r,o],{skipSessions:!0})};var D=function(e,t,n,r,o){var s=null==n?"\n":n;new g(e,t,"r",r).open((function(e,t){if(e)return o(e);t.readlines(s,o)}))};g.unlink=function(e,t,n,r){var o=Array.prototype.slice.call(arguments,2);return r="function"==typeof o[o.length-1]?o.pop():void 0,n=(n=o.length?o.shift():{})||{},d(e.s.topology,L,[this,e,t,n,r],{skipSessions:!0})};var L=function(e,t,n,r,o){var s=z(t,r);if(n.constructor===Array)for(var i=0,a=0;ae.totalBytesToRead&&(e.totalBytesToRead=e.totalBytesToRead-n._index,e.push(n.slice(0,n._index))),void(e.totalBytesToRead<=0&&(e.endCalled=!0)))}))},n=e.gs.length=0?(n={uploadDate:1},r=t.revision):r=-t.revision-1);var s={filename:e};return t={sort:n,skip:r,start:t&&t.start,end:t&&t.end},new o(this.s._chunksCollection,this.s._filesCollection,this.s.options.readPreference,s,t)},h.prototype.rename=function(e,t,n){return l(this.s.db.s.topology,f,[this,e,t,n],{skipSessions:!0})},h.prototype.drop=function(e){return l(this.s.db.s.topology,d,[this,e],{skipSessions:!0})},h.prototype.getLogger=function(){return this.s.db.s.logger}},function(e,t,n){"use strict";var r=n(19),o=n(5);function s(e,t,n,o,s){this.s={bytesRead:0,chunks:e,cursor:null,expected:0,files:t,filter:o,init:!1,expectedEnd:0,file:null,options:s,readPreference:n},r.Readable.call(this)}function i(e){if(e.s.init)throw new Error("You cannot change options after the stream has enteredflowing mode!")}function a(e,t){e.emit("error",t)}e.exports=s,o.inherits(s,r.Readable),s.prototype._read=function(){var e=this;this.destroyed||function(e,t){if(e.s.file)return t();e.s.init||(!function(e){var t={};e.s.readPreference&&(t.readPreference=e.s.readPreference);e.s.options&&e.s.options.sort&&(t.sort=e.s.options.sort);e.s.options&&e.s.options.skip&&(t.skip=e.s.options.skip);e.s.files.findOne(e.s.filter,t,(function(t,n){if(t)return a(e,t);if(!n){var r=e.s.filter._id?e.s.filter._id.toString():e.s.filter.filename,o=new Error("FileNotFound: file "+r+" was not found");return o.code="ENOENT",a(e,o)}if(n.length<=0)e.push(null);else if(e.destroyed)e.emit("close");else{try{e.s.bytesToSkip=function(e,t,n){if(n&&null!=n.start){if(n.start>t.length)throw new Error("Stream start ("+n.start+") must not be more than the length of the file ("+t.length+")");if(n.start<0)throw new Error("Stream start ("+n.start+") must not be negative");if(null!=n.end&&n.end0&&(s.n={$gte:i})}e.s.cursor=e.s.chunks.find(s).sort({n:1}),e.s.readPreference&&e.s.cursor.setReadPreference(e.s.readPreference),e.s.expectedEnd=Math.ceil(n.length/n.chunkSize),e.s.file=n;try{e.s.bytesToTrim=function(e,t,n,r){if(r&&null!=r.end){if(r.end>t.length)throw new Error("Stream end ("+r.end+") must not be more than the length of the file ("+t.length+")");if(r.start<0)throw new Error("Stream end ("+r.end+") must not be negative");var o=null!=r.start?Math.floor(r.start/t.chunkSize):0;return n.limit(Math.ceil(r.end/t.chunkSize)-o),e.s.expectedEnd=Math.ceil(r.end/t.chunkSize),Math.ceil(r.end/t.chunkSize)*t.chunkSize-r.end}}(e,n,e.s.cursor,e.s.options)}catch(t){return a(e,t)}e.emit("file",n)}}))}(e),e.s.init=!0);e.once("file",(function(){t()}))}(e,(function(){!function(e){if(e.destroyed)return;e.s.cursor.next((function(t,n){if(e.destroyed)return;if(t)return a(e,t);if(!n)return e.push(null),void process.nextTick(()=>{e.s.cursor.close((function(t){t?a(e,t):e.emit("close")}))});var r=e.s.file.length-e.s.bytesRead,o=e.s.expected++,s=Math.min(e.s.file.chunkSize,r);if(n.n>o){var i="ChunkIsMissing: Got unexpected n: "+n.n+", expected: "+o;return a(e,new Error(i))}if(n.n0;){var d=o.length-s;if(o.copy(e.bufToStore,e.pos,d,d+c),e.pos+=c,0===(i-=c)){e.md5&&e.md5.update(e.bufToStore);var m=u(e.id,e.n,a.from(e.bufToStore));if(++e.state.outstandingRequests,++h,y(e,r))return!1;e.chunks.insertOne(m,f(e),(function(t){if(t)return l(e,t);--e.state.outstandingRequests,--h||(e.emit("drain",m),r&&r(),p(e))})),i=e.chunkSizeBytes,e.pos=0,++e.n}s-=c,c=Math.min(i,s)}return!1}(r,e,t,n)}))},c.prototype.abort=function(e){if(this.state.streamEnd){var t=new Error("Cannot abort a stream that has already completed");return"function"==typeof e?e(t):this.state.promiseLibrary.reject(t)}if(this.state.aborted)return t=new Error("Cannot call abort() on a stream twice"),"function"==typeof e?e(t):this.state.promiseLibrary.reject(t);this.state.aborted=!0,this.chunks.deleteMany({files_id:this.id},(function(t){"function"==typeof e&&e(t)}))},c.prototype.end=function(e,t,n){var r=this;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),y(this,n)||(this.state.streamEnd=!0,n&&this.once("finish",(function(e){n(null,e)})),e?this.write(e,t,(function(){m(r)})):d(this,(function(){m(r)})))}}]); \ No newline at end of file diff --git a/src/service/connect/mongoConnection.ts b/src/service/connect/mongoConnection.ts index dc57d45..f3d353c 100644 --- a/src/service/connect/mongoConnection.ts +++ b/src/service/connect/mongoConnection.ts @@ -1,6 +1,6 @@ import * as fs from "fs"; import { Node } from "@/model/interface/node"; -import { MongoClient, MongoClientOptions, ObjectId as MObjectId } from "@/bin/mongodb"; +import { MongoClient, MongoClientOptions, ObjectId as MObjectId } from "mongodb"; import { IConnection, queryCallback } from "./connection"; export class MongoConnection extends IConnection { diff --git a/src/service/mock/mockRunner.ts b/src/service/mock/mockRunner.ts index 0a5763b..c156bd7 100644 --- a/src/service/mock/mockRunner.ts +++ b/src/service/mock/mockRunner.ts @@ -1,5 +1,5 @@ import { existsSync, readFileSync } from 'fs'; -import * as Mock from '@/bin/mockjs'; +import * as Mock from 'mockjs'; import * as vscode from "vscode"; import { MessageType } from "../../common/constants"; import { ConnectionManager } from "../connectionManager"; diff --git a/src/vue/status/index.vue b/src/vue/status/index.vue index 66c98e8..2657085 100644 --- a/src/vue/status/index.vue +++ b/src/vue/status/index.vue @@ -39,7 +39,7 @@