@fileverse-dev/formulajs 4.4.24 → 4.4.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- /* @fileverse-dev/formulajs v4.4.24 */
2
- var _excluded=["confirmations","dataDecoded"];function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,a=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */_regeneratorRuntime=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r,n){return Object.defineProperty(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function c(t,r,n,a){var i=r&&r.prototype instanceof p?r:p,o=Object.create(i.prototype);return s(o,"_invoke",function(t,r,n){var a=1;return function(i,o){if(3===a)throw Error("Generator is already running");if(4===a){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var u=n.delegate;if(u){var s=k(u,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===a)throw a=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=3;var c=f(t,r,n);if("normal"===c.type){if(a=n.done?4:2,c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(a=4,n.method="throw",n.arg=c.arg)}}}(t,n,new S(a||[])),!0),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var l={};function p(){}function d(){}function h(){}var v={};s(v,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(E([])));g&&g!==r&&n.call(g,i)&&(v=g);var y=h.prototype=p.prototype=Object.create(v);function _(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function r(a,i,o,u){var s=f(e[a],e,i);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,o,u)}),(function(e){r("throw",e,o,u)})):t.resolve(l).then((function(e){c.value=e,o(c)}),(function(e){return r("throw",e,o,u)}))}u(s.arg)}var a;s(this,"_invoke",(function(e,n){function i(){return new t((function(t,a){r(e,n,t,a)}))}return a=a?a.then(i,i):i()}),!0)}function k(t,r){var n=r.method,a=t.i[n];if(a===e)return r.delegate=null,"throw"===n&&t.i.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var i=f(a,t.i,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,l;var o=i.arg;return o?o.done?(r[t.r]=o.value,r.next=t.n,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function w(e){this.tryEntries.push(e)}function x(t){var r=t[4]||{};r.type="normal",r.arg=e,t[4]=r}function S(e){this.tryEntries=[[-1]],e.forEach(w,this),this.reset(!0)}function E(t){if(null!=t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(_typeof(t)+" is not iterable")}return d.prototype=h,s(y,"constructor",h),s(h,"constructor",d),d.displayName=s(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s(e,u,"GeneratorFunction")),e.prototype=Object.create(y),e},t.awrap=function(e){return{__await:e}},_(b.prototype),s(b.prototype,o,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new b(c(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},_(y),s(y,u,"Generator"),s(y,i,(function(){return this})),s(y,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(x),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0][4];if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e){o.type="throw",o.arg=t,r.next=e}for(var a=r.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i[4],u=this.prev,s=i[1],c=i[2];if(-1===i[0])return n("end"),!1;if(!s&&!c)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<s)return this.method="next",this.arg=e,n(s),!0;if(u<c)return n(c),!1}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var a=n;break}}a&&("break"===e||"continue"===e)&&a[0]<=t&&t<=a[2]&&(a=null);var i=a?a[4]:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a[2],l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r[2]===e)return this.complete(r[4],r[3]),x(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r[0]===e){var n=r[4];if("throw"===n.type){var a=n.arg;x(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={i:E(t),r:r,n:n},"next"===this.method&&(this.arg=e),l}},t}function asyncGeneratorStep(e,t,r,n,a,i,o){try{var u=e[i](o),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){asyncGeneratorStep(i,n,a,o,u,"next",e)}function u(e){asyncGeneratorStep(i,n,a,o,u,"throw",e)}o(void 0)}))}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,e)},_wrapNativeSuper(e)}function _construct(e,t,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var a=new(e.bind.apply(e,n));return r&&_setPrototypeOf(a,r.prototype),a}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _isNativeFunction(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){u=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw i}}}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,u=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).formulajs={})}(this,(function(e){"use strict";var t=new Error("#NULL!"),r=new Error("#DIV/0!"),n=new Error("#VALUE!"),a=new Error("#REF!"),i=new Error("#NAME?"),o=new Error("#NUM!"),u=new Error("#N/A"),s=new Error("#ERROR!"),c=new Error("#GETTING_DATA"),f=Object.freeze({__proto__:null,data:c,div0:r,error:s,na:u,name:i,nil:t,num:o,ref:a,value:n}),l=!1,p=new Date(Date.UTC(1900,0,1));function d(e){e<60&&(e+=1);var t=Math.floor(e-25569),r=new Date(1e3*(86400*t)),n=e-Math.floor(e)+1e-7,a=Math.floor(86400*n),i=a%60;a-=i;var o=Math.floor(a/3600),u=Math.floor(a/60)%60,s=r.getUTCDate(),c=r.getUTCMonth();return e>=60&&e<61&&(s=29,c=1),new Date(r.getUTCFullYear(),c,s,o,u,i)}function h(e){var t=e>-22038912e5?2:1;return Math.ceil((e-p)/864e5)+t}function v(e){var t=String(e.getDate()).padStart(2,"0"),r=String(e.getMonth()+1).padStart(2,"0"),n=e.getFullYear();return"".concat(t,"/").concat(r,"/").concat(n)}var m=Object.freeze({__proto__:null,dateToSerial:h,formatDate:v,get returnSerial(){return l},serialToDate:d,useDate:function(){l=!1},useSerial:function(){l=!0}}),g=[">",">=","<","<=","=","<>"],y="operator",_="literal",b=[y,_],k=y,w=_;function x(e,t){if(-1===b.indexOf(t))throw new Error("Unsupported token type: "+t);return{value:e,type:t}}function S(e){for(var t="",r=[],n=0;n<e.length;n++){var a=e[n];0===n&&g.indexOf(a)>=0?r.push(x(a,k)):t+=a}return t.length>0&&r.push(x(function(e){return"string"!=typeof e||/^\d+(\.\d+)?$/.test(e)&&(e=-1===e.indexOf(".")?parseInt(e,10):parseFloat(e)),e}(t),w)),r.length>0&&r[0].type!==k&&r.unshift(x("=",k)),r}function E(e){return S(function(e){for(var t=e.length,r=[],n=0,a="",i="";n<t;){var o=e.charAt(n);switch(o){case">":case"<":case"=":i+=o,a.length>0&&(r.push(a),a="");break;default:i.length>0&&(r.push(i),i=""),a+=o}n++}return a.length>0&&r.push(a),i.length>0&&r.push(i),r}(e))}var N=function(e){for(var t,r=[],n=0;n<e.length;n++){var a=e[n];switch(a.type){case k:t=a.value;break;case w:r.push(a.value)}}return function(e,t){var r=!1;switch(t){case">":r=e[0]>e[1];break;case">=":r=e[0]>=e[1];break;case"<":r=e[0]<e[1];break;case"<=":r=e[0]<=e[1];break;case"=":r=e[0]==e[1];break;case"<>":r=e[0]!=e[1]}return r}(r,t)};function A(e){var t=[];return T(e,(function(e){t.push(e)})),t}function T(e,t){for(var r=-1,n=e.length;++r<n&&!1!==t(e[r],r,e););return e}function I(e){for(var t,r=e.length;r--;)if("number"!=typeof(t=e[r]))if(!0!==t)if(!1!==t){if("string"==typeof t){var n=V(t);e[r]=n instanceof Error?0:n}}else e[r]=0;else e[r]=1;return e}function M(e,t){if(!e)return n;e.every((function(e){return Array.isArray(e)}))&&0!==e.length||(e=[_toConsumableArray(e)]),e.map((function(t,r){t.map((function(t,n){t||(e[r][n]=0)}))}));var r=e.reduce((function(t,r,n){return r.length>e[t].length?n:t}),0),a=e[r].length;return e.map((function(e){return[].concat(_toConsumableArray(e),_toConsumableArray(Array(a-e.length).fill(0)))}))}function C(){var e,t;if(1===arguments.length){var r=arguments[0];e=null!=(t=r)&&"number"==typeof t.length&&"string"!=typeof t?A.apply(null,arguments):[r]}else e=Array.from(arguments);for(;!R(e);)e=O(e);return e}function O(e){return e&&e.reduce?e.reduce((function(e,t){var r=Array.isArray(e),n=Array.isArray(t);return r&&n?e.concat(t):r?(e.push(t),e):n?[e].concat(t):[e,t]})):[e]}function R(e){if(!e)return!1;for(var t=0;t<e.length;++t)if(Array.isArray(e[t]))return!1;return!0}function j(e,t){return t=t||1,e&&"function"==typeof e.slice?e.slice(t):e}function D(e){return e?e[0].map((function(t,r){return e.map((function(e){return e[r]}))})):n}function P(e,t){var r=null;return T(e,(function(e,n){if(e[0]===t)return r=n,!1})),null==r?n:r}function L(){for(var e=0;e<arguments.length;e++)if(arguments[e]instanceof Error)return arguments[e]}function F(){for(var e=arguments.length;e--;)if(arguments[e]instanceof Error)return!0;return!1}function U(e){var t=1e14;return Math.round(e*t)/t}function q(){return C.apply(null,arguments).filter((function(e){return"number"==typeof e}))}function G(e){if("boolean"==typeof e)return e;if(e instanceof Error)return e;if("number"==typeof e)return 0!==e;if("string"==typeof e){var t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1}return e instanceof Date&&!isNaN(e)||n}function H(e){if(!isNaN(e)){if(e instanceof Date)return new Date(e);var t=parseFloat(e);return t<0||t>=2958466?o:d(t)}if("string"==typeof e){if(/^\d{4}-\d{1,2}-\d{1,2}$/.test(e))return new Date(e+"T00:00:00.000");var r=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(r){var a=_slicedToArray(r.map(Number),4),i=a[1],u=a[2],s=a[3],c=new Date(s,u-1,i);if(!isNaN(c))return c}if(/^\d{1,2}:\d{2}(:\d{2})?$/.test(e)){var f=_slicedToArray(e.split(":").map(Number),3),l=f[0],p=f[1],h=f[2],v=void 0===h?"0":h,m=new Date;return m.setHours(l,p,v,0),m}var g=/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i.exec(e);if(g){var y=_slicedToArray(g,4),_=y[1],b=y[2],k=y[3];_=parseInt(_),b=parseInt(b),"PM"===k.toUpperCase()&&12!==_&&(_+=12),"AM"===k.toUpperCase()&&12===_&&(_=0);var w=new Date;return w.setHours(_,b,0,0),w}var x=new Date(e);if(!isNaN(x))return x}return n}function Z(e){for(var t,r=e.length;r--;){if((t=H(e[r]))===n)return t;e[r]=t}return e}function V(e){return e instanceof Error?e:null==e?0:("boolean"==typeof e&&(e=+e),isNaN(e)||""===e?n:parseFloat(e))}function Y(e){var t,r;if(!e||0===(t=e.length))return n;for(;t--;){if(e[t]instanceof Error)return e[t];if((r=V(e[t]))instanceof Error)return r;e[t]=r}return e}function B(e){return e instanceof Error?e:null==e?"":e.toString()}function K(){for(var e=arguments.length;e--;)if("string"==typeof arguments[e])return!0;return!1}function z(){var e=A(arguments),t=Y(C(e.shift()));if(t instanceof Error)return t;for(var r=e,n=r.length/2,a=0;a<n;a++)r[2*a]=C(r[2*a]);for(var i=[],o=0;o<t.length;o++){for(var u=!1,s=0;s<n;s++){var c=r[2*s][o],f=r[2*s+1],l=!1;if(void 0===f||"*"===f)l=!0;else{var p=E(f+""),d=[x(c,w)].concat(p);l=N(d)}if(!l){u=!1;break}u=!0}u&&i.push(t[o])}return i}function X(e){return null!=e}var W={};function $(e){return[n,a,r,o,i,t].indexOf(e)>=0||"number"==typeof e&&(isNaN(e)||!isFinite(e))}function Q(e){return $(e)||e===u}function J(e){return!0===e||!1===e}function ee(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function te(e){return"string"==typeof e}function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}W.TYPE=function(e){switch(e){case t:return 1;case r:return 2;case n:return 3;case a:return 4;case i:return 5;case o:return 6;case u:return 7;case c:return 8}return u};var ne,ae={exports:{}};var ie=(ne||(ne=1,function(e){e.exports=function(){var e=function(e,t){var r=Array.prototype.concat,n=Array.prototype.slice,a=Object.prototype.toString;function i(t,r){var n=t>r?t:r;return e.pow(10,17-~~(e.log(n>0?n:-n)*e.LOG10E))}var o=Array.isArray||function(e){return"[object Array]"===a.call(e)};function u(e){return"[object Function]"===a.call(e)}function s(e){return"number"==typeof e&&e-e==0}function c(e){return r.apply([],e)}function f(){return new f._init(arguments)}function l(){return 0}function p(){return 1}function d(e,t){return e===t?1:0}f.fn=f.prototype,f._init=function(e){if(o(e[0]))if(o(e[0][0])){u(e[1])&&(e[0]=f.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=u(e[1])?f.map(e[0],e[1]):e[0],this.length=1;else if(s(e[0]))this[0]=f.seq.apply(null,e),this.length=1;else{if(e[0]instanceof f)return f(e[0].toArray());this[0]=[],this.length=1}return this},f._init.prototype=f.prototype,f._init.constructor=f,f.utils={calcRdx:i,isArray:o,isFunction:u,isNumber:s,toVector:c},f._random_fn=e.random,f.setRandom=function(e){if("function"!=typeof e)throw new TypeError("fn is not a function");f._random_fn=e},f.extend=function(e){var t,r;if(1===arguments.length){for(r in e)f[r]=e[r];return this}for(t=1;t<arguments.length;t++)for(r in arguments[t])e[r]=arguments[t][r];return e},f.rows=function(e){return e.length||1},f.cols=function(e){return e[0].length||1},f.dimensions=function(e){return{rows:f.rows(e),cols:f.cols(e)}},f.row=function(e,t){return o(t)?t.map((function(t){return f.row(e,t)})):e[t]},f.rowa=function(e,t){return f.row(e,t)},f.col=function(e,t){if(o(t)){var r=f.arange(e.length).map((function(){return new Array(t.length)}));return t.forEach((function(t,n){f.arange(e.length).forEach((function(a){r[a][n]=e[a][t]}))})),r}for(var n=new Array(e.length),a=0;a<e.length;a++)n[a]=[e[a][t]];return n},f.cola=function(e,t){return f.col(e,t).map((function(e){return e[0]}))},f.diag=function(e){for(var t=f.rows(e),r=new Array(t),n=0;n<t;n++)r[n]=[e[n][n]];return r},f.antidiag=function(e){for(var t=f.rows(e)-1,r=new Array(t),n=0;t>=0;t--,n++)r[n]=[e[n][t]];return r},f.transpose=function(e){var t,r,n,a,i,u=[];for(o(e[0])||(e=[e]),r=e.length,n=e[0].length,i=0;i<n;i++){for(t=new Array(r),a=0;a<r;a++)t[a]=e[a][i];u.push(t)}return 1===u.length?u[0]:u},f.map=function(e,t,r){var n,a,i,u,s;for(o(e[0])||(e=[e]),a=e.length,i=e[0].length,u=r?e:new Array(a),n=0;n<a;n++)for(u[n]||(u[n]=new Array(i)),s=0;s<i;s++)u[n][s]=t(e[n][s],n,s);return 1===u.length?u[0]:u},f.cumreduce=function(e,t,r){var n,a,i,u,s;for(o(e[0])||(e=[e]),a=e.length,i=e[0].length,u=r?e:new Array(a),n=0;n<a;n++)for(u[n]||(u[n]=new Array(i)),i>0&&(u[n][0]=e[n][0]),s=1;s<i;s++)u[n][s]=t(u[n][s-1],e[n][s]);return 1===u.length?u[0]:u},f.alter=function(e,t){return f.map(e,t,!0)},f.create=function(e,t,r){var n,a,i=new Array(e);for(u(t)&&(r=t,t=e),n=0;n<e;n++)for(i[n]=new Array(t),a=0;a<t;a++)i[n][a]=r(n,a);return i},f.zeros=function(e,t){return s(t)||(t=e),f.create(e,t,l)},f.ones=function(e,t){return s(t)||(t=e),f.create(e,t,p)},f.rand=function(e,t){return s(t)||(t=e),f.create(e,t,f._random_fn)},f.identity=function(e,t){return s(t)||(t=e),f.create(e,t,d)},f.symmetric=function(e){var t,r,n=e.length;if(e.length!==e[0].length)return!1;for(t=0;t<n;t++)for(r=0;r<n;r++)if(e[r][t]!==e[t][r])return!1;return!0},f.clear=function(e){return f.alter(e,l)},f.seq=function(e,t,r,n){u(n)||(n=!1);var a,o=[],s=i(e,t),c=(t*s-e*s)/((r-1)*s),f=e;for(a=0;f<=t&&a<r;f=(e*s+c*s*++a)/s)o.push(n?n(f,a):f);return o},f.arange=function(e,r,n){var a,i=[];if(n=n||1,r===t&&(r=e,e=0),e===r||0===n)return[];if(e<r&&n<0)return[];if(e>r&&n>0)return[];if(n>0)for(a=e;a<r;a+=n)i.push(a);else for(a=e;a>r;a+=n)i.push(a);return i},f.slice=function(){function e(e,r,n,a){var i,o=[],u=e.length;if(r===t&&n===t&&a===t)return f.copy(e);if(a=a||1,(r=(r=r||0)>=0?r:u+r)===(n=(n=n||e.length)>=0?n:u+n)||0===a)return[];if(r<n&&a<0)return[];if(r>n&&a>0)return[];if(a>0)for(i=r;i<n;i+=a)o.push(e[i]);else for(i=r;i>n;i+=a)o.push(e[i]);return o}function r(t,r){var n,a;return s((r=r||{}).row)?s(r.col)?t[r.row][r.col]:e(f.rowa(t,r.row),(n=r.col||{}).start,n.end,n.step):s(r.col)?e(f.cola(t,r.col),(a=r.row||{}).start,a.end,a.step):(a=r.row||{},n=r.col||{},e(t,a.start,a.end,a.step).map((function(t){return e(t,n.start,n.end,n.step)})))}return r}(),f.sliceAssign=function(r,n,a){var i,o;if(s(n.row)){if(s(n.col))return r[n.row][n.col]=a;n.col=n.col||{},n.col.start=n.col.start||0,n.col.end=n.col.end||r[0].length,n.col.step=n.col.step||1,i=f.arange(n.col.start,e.min(r.length,n.col.end),n.col.step);var u=n.row;return i.forEach((function(e,t){r[u][e]=a[t]})),r}if(s(n.col)){n.row=n.row||{},n.row.start=n.row.start||0,n.row.end=n.row.end||r.length,n.row.step=n.row.step||1,o=f.arange(n.row.start,e.min(r[0].length,n.row.end),n.row.step);var c=n.col;return o.forEach((function(e,t){r[e][c]=a[t]})),r}return a[0].length===t&&(a=[a]),n.row.start=n.row.start||0,n.row.end=n.row.end||r.length,n.row.step=n.row.step||1,n.col.start=n.col.start||0,n.col.end=n.col.end||r[0].length,n.col.step=n.col.step||1,o=f.arange(n.row.start,e.min(r.length,n.row.end),n.row.step),i=f.arange(n.col.start,e.min(r[0].length,n.col.end),n.col.step),o.forEach((function(e,t){i.forEach((function(n,i){r[e][n]=a[t][i]}))})),r},f.diagonal=function(e){var t=f.zeros(e.length,e.length);return e.forEach((function(e,r){t[r][r]=e})),t},f.copy=function(e){return e.map((function(e){return s(e)?e:e.map((function(e){return e}))}))};var h=f.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},h.map=function(e,t){return f(f.map(this,e,t))},h.cumreduce=function(e,t){return f(f.cumreduce(this,e,t))},h.alter=function(e){return f.alter(this,e),this},function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(t){var r,n=this;return t?(setTimeout((function(){t.call(n,h[e].call(n))})),this):(r=f[e](this),o(r)?f(r):r)}}(e[t])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(t,r){var n=this;return r?(setTimeout((function(){r.call(n,h[e].call(n,t))})),this):f(f[e](this,t))}}(e[t])}("row col".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(){return f(f[e].apply(null,arguments))}}(e[t])}("create zeros ones rand identity".split(" ")),f}(Math);return function(e,t){var r=e.utils.isFunction;function n(e,t){return e-t}function a(e,r,n){return t.max(r,t.min(e,n))}e.sum=function(e){for(var t=0,r=e.length;--r>=0;)t+=e[r];return t},e.sumsqrd=function(e){for(var t=0,r=e.length;--r>=0;)t+=e[r]*e[r];return t},e.sumsqerr=function(t){for(var r,n=e.mean(t),a=0,i=t.length;--i>=0;)a+=(r=t[i]-n)*r;return a},e.sumrow=function(e){for(var t=0,r=e.length;--r>=0;)t+=e[r];return t},e.product=function(e){for(var t=1,r=e.length;--r>=0;)t*=e[r];return t},e.min=function(e){for(var t=e[0],r=0;++r<e.length;)e[r]<t&&(t=e[r]);return t},e.max=function(e){for(var t=e[0],r=0;++r<e.length;)e[r]>t&&(t=e[r]);return t},e.unique=function(e){for(var t={},r=[],n=0;n<e.length;n++)t[e[n]]||(t[e[n]]=!0,r.push(e[n]));return r},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(r){var n=r.map(t.log),a=e.mean(n);return t.exp(a)},e.median=function(e){var t=e.length,r=e.slice().sort(n);return 1&t?r[t/2|0]:(r[t/2-1]+r[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,(function(e,t){return e+t}))},e.cumprod=function(t){return e.cumreduce(t,(function(e,t){return e*t}))},e.diff=function(e){var t,r=[],n=e.length;for(t=1;t<n;t++)r.push(e[t]-e[t-1]);return r},e.rank=function(e){var t,r=[],a={};for(t=0;t<e.length;t++)a[s=e[t]]?a[s]++:(a[s]=1,r.push(s));var i=r.sort(n),o={},u=1;for(t=0;t<i.length;t++){var s,c=a[s=i[t]],f=(u+(u+c-1))/2;o[s]=f,u+=c}return e.map((function(e){return o[e]}))},e.mode=function(e){var t,r=e.length,a=e.slice().sort(n),i=1,o=0,u=0,s=[];for(t=0;t<r;t++)a[t]===a[t+1]?i++:(i>o?(s=[a[t]],o=i,u=0):i===o&&(s.push(a[t]),u++),i=1);return 0===u?s[0]:s},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,r){return e.sumsqerr(t)/(t.length-(r?1:0))},e.pooledvariance=function(t){return t.reduce((function(t,r){return t+e.sumsqerr(r)}),0)/(t.reduce((function(e,t){return e+t.length}),0)-t.length)},e.deviation=function(t){for(var r=e.mean(t),n=t.length,a=new Array(n),i=0;i<n;i++)a[i]=t[i]-r;return a},e.stdev=function(r,n){return t.sqrt(e.variance(r,n))},e.pooledstdev=function(r){return t.sqrt(e.pooledvariance(r))},e.meandev=function(r){for(var n=e.mean(r),a=[],i=r.length-1;i>=0;i--)a.push(t.abs(r[i]-n));return e.mean(a)},e.meddev=function(r){for(var n=e.median(r),a=[],i=r.length-1;i>=0;i--)a.push(t.abs(r[i]-n));return e.median(a)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var r=e.length,a=e.slice().sort(n);return[a[t.round(r/4)-1],a[t.round(r/2)-1],a[t.round(3*r/4)-1]]},e.quantiles=function(e,r,i,o){var u,s,c,f,l,p=e.slice().sort(n),d=[r.length],h=e.length;for(void 0===i&&(i=3/8),void 0===o&&(o=3/8),u=0;u<r.length;u++)c=h*(s=r[u])+(i+s*(1-i-o)),f=t.floor(a(c,1,h-1)),l=a(c-f,0,1),d[u]=(1-l)*p[f-1]+l*p[f];return d},e.percentile=function(e,t,r){var a=e.slice().sort(n),i=t*(a.length+(r?1:-1))+(r?0:1),o=parseInt(i),u=i-o;return o+1<a.length?a[o-1]+u*(a[o]-a[o-1]):a[o-1]},e.percentileOfScore=function(e,t,r){var n,a,i=0,o=e.length,u=!1;for("strict"===r&&(u=!0),a=0;a<o;a++)n=e[a],(u&&n<t||!u&&n<=t)&&i++;return i/o},e.histogram=function(r,n){n=n||4;var a,i=e.min(r),o=(e.max(r)-i)/n,u=r.length,s=[];for(a=0;a<n;a++)s[a]=0;for(a=0;a<u;a++)s[t.min(t.floor((r[a]-i)/o),n-1)]+=1;return s},e.covariance=function(t,r){var n,a=e.mean(t),i=e.mean(r),o=t.length,u=new Array(o);for(n=0;n<o;n++)u[n]=(t[n]-a)*(r[n]-i);return e.sum(u)/(o-1)},e.corrcoeff=function(t,r){return e.covariance(t,r)/e.stdev(t,1)/e.stdev(r,1)},e.spearmancoeff=function(t,r){return t=e.rank(t),r=e.rank(r),e.corrcoeff(t,r)},e.stanMoment=function(r,n){for(var a=e.mean(r),i=e.stdev(r),o=r.length,u=0,s=0;s<o;s++)u+=t.pow((r[s]-a)/i,n);return u/r.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};var i=e.prototype;!function(t){for(var n=0;n<t.length;n++)!function(t){i[t]=function(n,a){var o=[],u=0,s=this;if(r(n)&&(a=n,n=!1),a)return setTimeout((function(){a.call(s,i[t].call(s,n))})),this;if(this.length>1){for(s=!0===n?this:this.transpose();u<s.length;u++)o[u]=e[t](s[u]);return o}return e[t](this[0],n)}}(t[n])}("cumsum cumprod".split(" ")),function(t){for(var n=0;n<t.length;n++)!function(t){i[t]=function(n,a){var o=[],u=0,s=this;if(r(n)&&(a=n,n=!1),a)return setTimeout((function(){a.call(s,i[t].call(s,n))})),this;if(this.length>1){for("sumrow"!==t&&(s=!0===n?this:this.transpose());u<s.length;u++)o[u]=e[t](s[u]);return!0===n?e[t](e.utils.toVector(o)):o}return e[t](this[0],n)}}(t[n])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(t){for(var n=0;n<t.length;n++)!function(t){i[t]=function(){var n,a=[],o=0,u=this,s=Array.prototype.slice.call(arguments);if(r(s[s.length-1])){n=s[s.length-1];var c=s.slice(0,s.length-1);return setTimeout((function(){n.call(u,i[t].apply(u,c))})),this}n=void 0;var f=function(r){return e[t].apply(u,[r].concat(s))};if(this.length>1){for(u=u.transpose();o<u.length;o++)a[o]=f(u[o]);return a}return f(this[0])}}(t[n])}("quantiles percentileOfScore".split(" "))}(e,Math),function(e,t){e.gammaln=function(e){var r,n,a,i=0,o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],u=1.000000000190015;for(a=(n=r=e)+5.5,a-=(r+.5)*t.log(a);i<6;i++)u+=o[i]/++n;return t.log(2.5066282746310007*u/r)-a},e.loggam=function(e){var r,n,a,i,o,u,s,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(r=e,s=0,1==e||2==e)return 0;for(e<=7&&(r=e+(s=t.floor(7-e))),n=1/(r*r),a=2*t.PI,o=c[9],u=8;u>=0;u--)o*=n,o+=c[u];if(i=o/r+.5*t.log(a)+(r-.5)*t.log(r)-r,e<=7)for(u=1;u<=s;u++)i-=t.log(r-1),r-=1;return i},e.gammafn=function(e){var r,n,a,i,o=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],u=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,c=0,f=0,l=0,p=e;if(e>171.6243769536076)return 1/0;if(p<=0){if(!(i=p%1+36e-17))return 1/0;s=(1&p?-1:1)*t.PI/t.sin(t.PI*i),p=1-p}for(a=p,n=p<1?p++:(p-=c=(0|p)-1)-1,r=0;r<8;++r)l=(l+o[r])*n,f=f*n+u[r];if(i=l/f+1,a<p)i/=a;else if(a>p)for(r=0;r<c;++r)i*=p,p++;return s&&(i=s/i),i},e.gammap=function(t,r){return e.lowRegGamma(t,r)*e.gammafn(t)},e.lowRegGamma=function(r,n){var a,i=e.gammaln(r),o=r,u=1/r,s=u,c=n+1-r,f=1/1e-30,l=1/c,p=l,d=1,h=-~(8.5*t.log(r>=1?r:1/r)+.4*r+17);if(n<0||r<=0)return NaN;if(n<r+1){for(;d<=h;d++)u+=s*=n/++o;return u*t.exp(-n+r*t.log(n)-i)}for(;d<=h;d++)p*=(l=1/(l=(a=-d*(d-r))*l+(c+=2)))*(f=c+a/f);return 1-p*t.exp(-n+r*t.log(n)-i)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(r,n){return r>170||n>170?t.exp(e.combinationln(r,n)):e.factorial(r)/e.factorial(n)/e.factorial(r-n)},e.combinationln=function(t,r){return e.factorialln(t)-e.factorialln(r)-e.factorialln(t-r)},e.permutation=function(t,r){return e.factorial(t)/e.factorial(t-r)},e.betafn=function(r,n){if(!(r<=0||n<=0))return r+n>170?t.exp(e.betaln(r,n)):e.gammafn(r)*e.gammafn(n)/e.gammafn(r+n)},e.betaln=function(t,r){return e.gammaln(t)+e.gammaln(r)-e.gammaln(t+r)},e.betacf=function(e,r,n){var a,i,o,u,s=1e-30,c=1,f=r+n,l=r+1,p=r-1,d=1,h=1-f*e/l;for(t.abs(h)<s&&(h=s),u=h=1/h;c<=100&&(h=1+(i=c*(n-c)*e/((p+(a=2*c))*(r+a)))*h,t.abs(h)<s&&(h=s),d=1+i/d,t.abs(d)<s&&(d=s),u*=(h=1/h)*d,h=1+(i=-(r+c)*(f+c)*e/((r+a)*(l+a)))*h,t.abs(h)<s&&(h=s),d=1+i/d,t.abs(d)<s&&(d=s),u*=o=(h=1/h)*d,!(t.abs(o-1)<3e-7));c++);return u},e.gammapinv=function(r,n){var a,i,o,u,s,c,f=0,l=n-1,p=1e-8,d=e.gammaln(n);if(r>=1)return t.max(100,n+100*t.sqrt(n));if(r<=0)return 0;for(n>1?(s=t.log(l),c=t.exp(l*(s-1)-d),u=r<.5?r:1-r,a=(2.30753+.27061*(i=t.sqrt(-2*t.log(u))))/(1+i*(.99229+.04481*i))-i,r<.5&&(a=-a),a=t.max(.001,n*t.pow(1-1/(9*n)-a/(3*t.sqrt(n)),3))):a=r<(i=1-n*(.253+.12*n))?t.pow(r/i,1/n):1-t.log(1-(r-i)/(1-i));f<12;f++){if(a<=0)return 0;if((a-=i=(o=(e.lowRegGamma(n,a)-r)/(i=n>1?c*t.exp(-(a-l)+l*(t.log(a)-s)):t.exp(-a+l*t.log(a)-d)))/(1-.5*t.min(1,o*((n-1)/a-1))))<=0&&(a=.5*(a+i)),t.abs(i)<p*a)break}return a},e.erf=function(e){var r,n,a,i,o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],u=o.length-1,s=!1,c=0,f=0;for(e<0&&(e=-e,s=!0),n=4*(r=2/(2+e))-2;u>0;u--)a=c,c=n*c-f+o[u],f=a;return i=r*t.exp(-e*e+.5*(o[0]+n*c)-f),s?i-1:1-i},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(r){var n,a,i,o,u=0;if(r>=2)return-100;if(r<=0)return 100;for(o=r<1?r:2-r,n=-.70711*((2.30753+.27061*(i=t.sqrt(-2*t.log(o/2))))/(1+i*(.99229+.04481*i))-i);u<2;u++)n+=(a=e.erfc(n)-o)/(1.1283791670955126*t.exp(-n*n)-n*a);return r<1?n:-n},e.ibetainv=function(r,n,a){var i,o,u,s,c,f,l,p,d,h,v=1e-8,m=n-1,g=a-1,y=0;if(r<=0)return 0;if(r>=1)return 1;for(n>=1&&a>=1?(u=r<.5?r:1-r,f=(2.30753+.27061*(s=t.sqrt(-2*t.log(u))))/(1+s*(.99229+.04481*s))-s,r<.5&&(f=-f),l=(f*f-3)/6,p=2/(1/(2*n-1)+1/(2*a-1)),d=f*t.sqrt(l+p)/p-(1/(2*a-1)-1/(2*n-1))*(l+5/6-2/(3*p)),f=n/(n+a*t.exp(2*d))):(i=t.log(n/(n+a)),o=t.log(a/(n+a)),f=r<(s=t.exp(n*i)/n)/(d=s+(c=t.exp(a*o)/a))?t.pow(n*d*r,1/n):1-t.pow(a*d*(1-r),1/a)),h=-e.gammaln(n)-e.gammaln(a)+e.gammaln(n+a);y<10;y++){if(0===f||1===f)return f;if((f-=s=(c=(e.ibeta(f,n,a)-r)/(s=t.exp(m*t.log(f)+g*t.log(1-f)+h)))/(1-.5*t.min(1,c*(m/f-g/(1-f)))))<=0&&(f=.5*(f+s)),f>=1&&(f=.5*(f+s+1)),t.abs(s)<v*f&&y>0)break}return f},e.ibeta=function(r,n,a){var i=0===r||1===r?0:t.exp(e.gammaln(n+a)-e.gammaln(n)-e.gammaln(a)+n*t.log(r)+a*t.log(1-r));return!(r<0||r>1)&&(r<(n+1)/(n+a+2)?i*e.betacf(r,n,a)/n:1-i*e.betacf(1-r,a,n)/a)},e.randn=function(r,n){var a,i,o,u,s;if(n||(n=r),r)return e.create(r,n,(function(){return e.randn()}));do{a=e._random_fn(),i=1.7156*(e._random_fn()-.5),s=(o=a-.449871)*o+(u=t.abs(i)+.386595)*(.196*u-.25472*o)}while(s>.27597&&(s>.27846||i*i>-4*t.log(a)*a*a));return i/a},e.randg=function(r,n,a){var i,o,u,s,c,f,l=r;if(a||(a=n),r||(r=1),n)return(f=e.zeros(n,a)).alter((function(){return e.randg(r)})),f;r<1&&(r+=1),i=r-1/3,o=1/t.sqrt(9*i);do{do{s=1+o*(c=e.randn())}while(s<=0);s*=s*s,u=e._random_fn()}while(u>1-.331*t.pow(c,4)&&t.log(u)>.5*c*c+i*(1-s+t.log(s)));if(r==l)return i*s;do{u=e._random_fn()}while(0===u);return t.pow(u,1/l)*i*s},function(t){for(var r=0;r<t.length;r++)!function(t){e.fn[t]=function(){return e(e.map(this,(function(r){return e[t](r)})))}}(t[r])}("gammaln gammafn factorial factorialln".split(" ")),function(t){for(var r=0;r<t.length;r++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(t[r])}("randn".split(" "))}(e,Math),function(e,t){function r(e,r,n,a){for(var i,o=0,u=1,s=1,c=1,f=0,l=0;t.abs((s-l)/s)>a;)l=s,u=c+(i=-(r+f)*(r+n+f)*e/(r+2*f)/(r+2*f+1))*u,s=(o=s+i*o)+(i=(f+=1)*(n-f)*e/(r+2*f-1)/(r+2*f))*s,o/=c=u+i*c,u/=c,s/=c,c=1;return s/r}function n(e){return e/t.abs(e)}function a(r,n,a){var i=12,o=6,u=-30,s=-50,c=60,f=8,l=3,p=2,d=3,h=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],v=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],m=.5*r;if(m>=f)return 1;var g,y=2*e.normal.cdf(m,0,1,1,0)-1;y=y>=t.exp(s/a)?t.pow(y,a):0;for(var _=m,b=(f-m)/(g=r>l?p:d),k=_+b,w=0,x=a-1,S=1;S<=g;S++){for(var E=0,N=.5*(k+_),A=.5*(k-_),T=1;T<=i;T++){var I,M=N+A*(o<T?h[(I=i-T+1)-1]:-h[(I=T)-1]),C=M*M;if(C>c)break;var O=2*e.normal.cdf(M,0,1,1,0)*.5-2*e.normal.cdf(M,r,1,1,0)*.5;O>=t.exp(u/x)&&(E+=O=v[I-1]*t.exp(-.5*C)*t.pow(O,x))}w+=E*=2*A*a/t.sqrt(2*t.PI),_=k,k+=b}return(y+=w)<=t.exp(u/n)?0:(y=t.pow(y,n))>=1?1:y}function i(e,r,n){var a=.322232421088,i=.099348462606,o=-1,u=.588581570495,s=-.342242088547,c=.531103462366,f=-.204231210125,l=.10353775285,p=-453642210148e-16,d=.0038560700634,h=.8832,v=.2368,m=1.208,g=1.4142,y=120,_=.5-.5*e,b=t.sqrt(t.log(1/(_*_))),k=b+((((b*p+f)*b+s)*b+o)*b+a)/((((b*d+l)*b+c)*b+u)*b+i);n<y&&(k+=(k*k*k+k)/n/4);var w=h-v*k;return n<y&&(w+=-1.214/n+m*k/n),k*(w*t.log(r-1)+g)}!function(t){for(var r=0;r<t.length;r++)!function(t){e[t]=function e(t,r,n){return this instanceof e?(this._a=t,this._b=r,this._c=n,this):new e(t,r,n)},e.fn[t]=function(r,n,a){var i=e[t](r,n,a);return i.data=this,i},e[t].prototype.sample=function(r){var n=this._a,a=this._b,i=this._c;return r?e.alter(r,(function(){return e[t].sample(n,a,i)})):e[t].sample(n,a,i)},function(r){for(var n=0;n<r.length;n++)!function(r){e[t].prototype[r]=function(n){var a=this._a,i=this._b,o=this._c;return n||0===n||(n=this.data),"number"!=typeof n?e.fn.map.call(n,(function(n){return e[t][r](n,a,i,o)})):e[t][r](n,a,i,o)}}(r[n])}("pdf cdf inv".split(" ")),function(r){for(var n=0;n<r.length;n++)!function(r){e[t].prototype[r]=function(){return e[t][r](this._a,this._b,this._c)}}(r[n])}("mean median mode variance".split(" "))}(t[r])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),e.extend(e.beta,{pdf:function(r,n,a){return r>1||r<0?0:1==n&&1==a?1:n<512&&a<512?t.pow(r,n-1)*t.pow(1-r,a-1)/e.betafn(n,a):t.exp((n-1)*t.log(r)+(a-1)*t.log(1-r)-e.betaln(n,a))},cdf:function(t,r,n){return t>1||t<0?1*(t>1):e.ibeta(t,r,n)},inv:function(t,r,n){return e.ibetainv(t,r,n)},mean:function(e,t){return e/(e+t)},median:function(t,r){return e.ibetainv(.5,t,r)},mode:function(e,t){return(e-1)/(e+t-2)},sample:function(t,r){var n=e.randg(t);return n/(n+e.randg(r))},variance:function(e,r){return e*r/(t.pow(e+r,2)*(e+r+1))}}),e.extend(e.centralF,{pdf:function(r,n,a){var i;return r<0?0:n<=2?0===r&&n<2?1/0:0===r&&2===n?1:1/e.betafn(n/2,a/2)*t.pow(n/a,n/2)*t.pow(r,n/2-1)*t.pow(1+n/a*r,-(n+a)/2):(i=n*r/(a+r*n),n*(a/(a+r*n))/2*e.binomial.pdf((n-2)/2,(n+a-2)/2,i))},cdf:function(t,r,n){return t<0?0:e.ibeta(r*t/(r*t+n),r/2,n/2)},inv:function(t,r,n){return n/(r*(1/e.ibetainv(t,r/2,n/2)-1))},mean:function(e,t){return t>2?t/(t-2):void 0},mode:function(e,t){return e>2?t*(e-2)/(e*(t+2)):void 0},sample:function(t,r){return 2*e.randg(t/2)/t/(2*e.randg(r/2)/r)},variance:function(e,t){if(!(t<=4))return 2*t*t*(e+t-2)/(e*(t-2)*(t-2)*(t-4))}}),e.extend(e.cauchy,{pdf:function(e,r,n){return n<0?0:n/(t.pow(e-r,2)+t.pow(n,2))/t.PI},cdf:function(e,r,n){return t.atan((e-r)/n)/t.PI+.5},inv:function(e,r,n){return r+n*t.tan(t.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(r,n){return e.randn()*t.sqrt(1/(2*e.randg(.5)))*n+r}}),e.extend(e.chisquare,{pdf:function(r,n){return r<0?0:0===r&&2===n?.5:t.exp((n/2-1)*t.log(r)-r/2-n/2*t.log(2)-e.gammaln(n/2))},cdf:function(t,r){return t<0?0:e.lowRegGamma(r/2,t/2)},inv:function(t,r){return 2*e.gammapinv(t,.5*r)},mean:function(e){return e},median:function(e){return e*t.pow(1-2/(9*e),3)},mode:function(e){return e-2>0?e-2:0},sample:function(t){return 2*e.randg(t/2)},variance:function(e){return 2*e}}),e.extend(e.exponential,{pdf:function(e,r){return e<0?0:r*t.exp(-r*e)},cdf:function(e,r){return e<0?0:1-t.exp(-r*e)},inv:function(e,r){return-t.log(1-e)/r},mean:function(e){return 1/e},median:function(e){return 1/e*t.log(2)},mode:function(){return 0},sample:function(r){return-1/r*t.log(e._random_fn())},variance:function(e){return t.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(r,n,a){return r<0?0:0===r&&1===n?1/a:t.exp((n-1)*t.log(r)-r/a-e.gammaln(n)-n*t.log(a))},cdf:function(t,r,n){return t<0?0:e.lowRegGamma(r,t/n)},inv:function(t,r,n){return e.gammapinv(t,r)*n},mean:function(e,t){return e*t},mode:function(e,t){if(e>1)return(e-1)*t},sample:function(t,r){return e.randg(t)*r},variance:function(e,t){return e*t*t}}),e.extend(e.invgamma,{pdf:function(r,n,a){return r<=0?0:t.exp(-(n+1)*t.log(r)-a/r-e.gammaln(n)+n*t.log(a))},cdf:function(t,r,n){return t<=0?0:1-e.lowRegGamma(r,n/t)},inv:function(t,r,n){return n/e.gammapinv(1-t,r)},mean:function(e,t){return e>1?t/(e-1):void 0},mode:function(e,t){return t/(e+1)},sample:function(t,r){return r/e.randg(t)},variance:function(e,t){if(!(e<=2))return t*t/((e-1)*(e-1)*(e-2))}}),e.extend(e.kumaraswamy,{pdf:function(e,r,n){return 0===e&&1===r?n:1===e&&1===n?r:t.exp(t.log(r)+t.log(n)+(r-1)*t.log(e)+(n-1)*t.log(1-t.pow(e,r)))},cdf:function(e,r,n){return e<0?0:e>1?1:1-t.pow(1-t.pow(e,r),n)},inv:function(e,r,n){return t.pow(1-t.pow(1-e,1/n),1/r)},mean:function(t,r){return r*e.gammafn(1+1/t)*e.gammafn(r)/e.gammafn(1+1/t+r)},median:function(e,r){return t.pow(1-t.pow(2,-1/r),1/e)},mode:function(e,r){if(e>=1&&r>=1&&1!==e&&1!==r)return t.pow((e-1)/(e*r-1),1/e)},variance:function(){throw new Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,r,n){return e<=0?0:t.exp(-t.log(e)-.5*t.log(2*t.PI)-t.log(n)-t.pow(t.log(e)-r,2)/(2*n*n))},cdf:function(r,n,a){return r<0?0:.5+.5*e.erf((t.log(r)-n)/t.sqrt(2*a*a))},inv:function(r,n,a){return t.exp(-1.4142135623730951*a*e.erfcinv(2*r)+n)},mean:function(e,r){return t.exp(e+r*r/2)},median:function(e){return t.exp(e)},mode:function(e,r){return t.exp(e-r*r)},sample:function(r,n){return t.exp(e.randn()*n+r)},variance:function(e,r){return(t.exp(r*r)-1)*t.exp(2*e+r*r)}}),e.extend(e.noncentralt,{pdf:function(r,n,a){var i=1e-14;return t.abs(a)<i?e.studentt.pdf(r,n):t.abs(r)<i?t.exp(e.gammaln((n+1)/2)-a*a/2-.5*t.log(t.PI*n)-e.gammaln(n/2)):n/r*(e.noncentralt.cdf(r*t.sqrt(1+2/n),n+2,a)-e.noncentralt.cdf(r,n,a))},cdf:function(r,n,a){var i=1e-14,o=200;if(t.abs(a)<i)return e.studentt.cdf(r,n);var u=!1;r<0&&(u=!0,a=-a);for(var s=e.normal.cdf(-a,0,1),c=i+1,f=c,l=r*r/(r*r+n),p=0,d=t.exp(-a*a/2),h=t.exp(-a*a/2-.5*t.log(2)-e.gammaln(1.5))*a;p<o||f>i||c>i;)f=c,p>0&&(d*=a*a/(2*p),h*=a*a/(2*(p+.5))),s+=.5*(c=d*e.beta.cdf(l,p+.5,n/2)+h*e.beta.cdf(l,p+1,n/2)),p++;return u?1-s:s}}),e.extend(e.normal,{pdf:function(e,r,n){return t.exp(-.5*t.log(2*t.PI)-t.log(n)-t.pow(e-r,2)/(2*n*n))},cdf:function(r,n,a){return.5*(1+e.erf((r-n)/t.sqrt(2*a*a)))},inv:function(t,r,n){return-1.4142135623730951*n*e.erfcinv(2*t)+r},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},sample:function(t,r){return e.randn()*r+t},variance:function(e,t){return t*t}}),e.extend(e.pareto,{pdf:function(e,r,n){return e<r?0:n*t.pow(r,n)/t.pow(e,n+1)},cdf:function(e,r,n){return e<r?0:1-t.pow(r/e,n)},inv:function(e,r,n){return r/t.pow(1-e,1/n)},mean:function(e,r){if(!(r<=1))return r*t.pow(e,r)/(r-1)},median:function(e,r){return e*(r*t.SQRT2)},mode:function(e){return e},variance:function(e,r){if(!(r<=2))return e*e*r/(t.pow(r-1,2)*(r-2))}}),e.extend(e.studentt,{pdf:function(r,n){return n=n>1e100?1e100:n,1/(t.sqrt(n)*e.betafn(.5,n/2))*t.pow(1+r*r/n,-(n+1)/2)},cdf:function(r,n){var a=n/2;return e.ibeta((r+t.sqrt(r*r+n))/(2*t.sqrt(r*r+n)),a,a)},inv:function(r,n){var a=e.ibetainv(2*t.min(r,1-r),.5*n,.5);return a=t.sqrt(n*(1-a)/a),r>.5?a:-a},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(r){return e.randn()*t.sqrt(r/(2*e.randg(r/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,r,n){return e<0||r<0||n<0?0:n/r*t.pow(e/r,n-1)*t.exp(-t.pow(e/r,n))},cdf:function(e,r,n){return e<0?0:1-t.exp(-t.pow(e/r,n))},inv:function(e,r,n){return r*t.pow(-t.log(1-e),1/n)},mean:function(t,r){return t*e.gammafn(1+1/r)},median:function(e,r){return e*t.pow(t.log(2),1/r)},mode:function(e,r){return r<=1?0:e*t.pow((r-1)/r,1/r)},sample:function(r,n){return r*t.pow(-t.log(e._random_fn()),1/n)},variance:function(r,n){return r*r*e.gammafn(1+2/n)-t.pow(e.weibull.mean(r,n),2)}}),e.extend(e.uniform,{pdf:function(e,t,r){return e<t||e>r?0:1/(r-t)},cdf:function(e,t,r){return e<t?0:e<r?(e-t)/(r-t):1},inv:function(e,t,r){return t+e*(r-t)},mean:function(e,t){return.5*(e+t)},median:function(t,r){return e.mean(t,r)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(t,r){return t/2+r/2+(r/2-t/2)*(2*e._random_fn()-1)},variance:function(e,r){return t.pow(r-e,2)/12}}),e.extend(e.binomial,{pdf:function(r,n,a){return 0===a||1===a?n*a===r?1:0:e.combination(n,r)*t.pow(a,r)*t.pow(1-a,n-r)},cdf:function(n,a,i){var o,u=1e-10;if(n<0)return 0;if(n>=a)return 1;if(i<0||i>1||a<=0)return NaN;var s=i,c=(n=t.floor(n))+1,f=a-n,l=c+f,p=t.exp(e.gammaln(l)-e.gammaln(f)-e.gammaln(c)+c*t.log(s)+f*t.log(1-s));return o=s<(c+1)/(l+2)?p*r(s,c,f,u):1-p*r(1-s,f,c,u),t.round(1/u*(1-o))/(1/u)}}),e.extend(e.negbin,{pdf:function(r,n,a){return r===r>>>0&&(r<0?0:e.combination(r+n-1,n-1)*t.pow(1-a,r)*t.pow(a,n))},cdf:function(t,r,n){var a=0,i=0;if(t<0)return 0;for(;i<=t;i++)a+=e.negbin.pdf(i,r,n);return a}}),e.extend(e.hypgeom,{pdf:function(r,n,a,i){if(r!=r|0)return!1;if(r<0||r<a-(n-i))return 0;if(r>i||r>a)return 0;if(2*a>n)return 2*i>n?e.hypgeom.pdf(n-a-i+r,n,n-a,n-i):e.hypgeom.pdf(i-r,n,n-a,i);if(2*i>n)return e.hypgeom.pdf(a-r,n,a,n-i);if(a<i)return e.hypgeom.pdf(r,n,i,a);for(var o=1,u=0,s=0;s<r;s++){for(;o>1&&u<i;)o*=1-a/(n-u),u++;o*=(i-s)*(a-s)/((s+1)*(n-a-i+s+1))}for(;u<i;u++)o*=1-a/(n-u);return t.min(1,t.max(0,o))},cdf:function(r,n,a,i){if(r<0||r<a-(n-i))return 0;if(r>=i||r>=a)return 1;if(2*a>n)return 2*i>n?e.hypgeom.cdf(n-a-i+r,n,n-a,n-i):1-e.hypgeom.cdf(i-r-1,n,n-a,i);if(2*i>n)return 1-e.hypgeom.cdf(a-r-1,n,a,n-i);if(a<i)return e.hypgeom.cdf(r,n,i,a);for(var o=1,u=1,s=0,c=0;c<r;c++){for(;o>1&&s<i;){var f=1-a/(n-s);u*=f,o*=f,s++}o+=u*=(i-c)*(a-c)/((c+1)*(n-a-i+c+1))}for(;s<i;s++)o*=1-a/(n-s);return t.min(1,t.max(0,o))}}),e.extend(e.poisson,{pdf:function(r,n){return n<0||r%1!=0||r<0?0:t.pow(n,r)*t.exp(-n)/e.factorial(r)},cdf:function(t,r){var n=[],a=0;if(t<0)return 0;for(;a<=t;a++)n.push(e.poisson.pdf(a,r));return e.sum(n)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(r){var n=1,a=0,i=t.exp(-r);do{a++,n*=e._random_fn()}while(n>i);return a-1},sampleLarge:function(r){var n,a,i,o,u,s,c,f,l,p,d=r;for(o=t.sqrt(d),u=t.log(d),s=.02483*(c=.931+2.53*o)-.059,f=1.1239+1.1328/(c-3.4),l=.9277-3.6224/(c-2);;){if(a=t.random()-.5,i=t.random(),p=.5-t.abs(a),n=t.floor((2*s/p+c)*a+d+.43),p>=.07&&i<=l)return n;if(!(n<0||p<.013&&i>p)&&t.log(i)+t.log(f)-t.log(s/(p*p)+c)<=n*u-d-e.loggam(n+1))return n}},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,t,r,n){return r<=t||n<t||n>r?NaN:e<t||e>r?0:e<n?2*(e-t)/((r-t)*(n-t)):e===n?2/(r-t):2*(r-e)/((r-t)*(r-n))},cdf:function(e,r,n,a){return n<=r||a<r||a>n?NaN:e<=r?0:e>=n?1:e<=a?t.pow(e-r,2)/((n-r)*(a-r)):1-t.pow(n-e,2)/((n-r)*(n-a))},inv:function(e,r,n,a){return n<=r||a<r||a>n?NaN:e<=(a-r)/(n-r)?r+(n-r)*t.sqrt(e*((a-r)/(n-r))):r+(n-r)*(1-t.sqrt((1-e)*(1-(a-r)/(n-r))))},mean:function(e,t,r){return(e+t+r)/3},median:function(e,r,n){return n<=(e+r)/2?r-t.sqrt((r-e)*(r-n))/t.sqrt(2):n>(e+r)/2?e+t.sqrt((r-e)*(n-e))/t.sqrt(2):void 0},mode:function(e,t,r){return r},sample:function(r,n,a){var i=e._random_fn();return i<(a-r)/(n-r)?r+t.sqrt(i*(n-r)*(a-r)):n-t.sqrt((1-i)*(n-r)*(n-a))},variance:function(e,t,r){return(e*e+t*t+r*r-e*t-e*r-t*r)/18}}),e.extend(e.arcsine,{pdf:function(e,r,n){return n<=r?NaN:e<=r||e>=n?0:2/t.PI*t.pow(t.pow(n-r,2)-t.pow(2*e-r-n,2),-.5)},cdf:function(e,r,n){return e<r?0:e<n?2/t.PI*t.asin(t.sqrt((e-r)/(n-r))):1},inv:function(e,r,n){return r+(.5-.5*t.cos(t.PI*e))*(n-r)},mean:function(e,t){return t<=e?NaN:(e+t)/2},median:function(e,t){return t<=e?NaN:(e+t)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(r,n){return(r+n)/2+(n-r)/2*t.sin(2*t.PI*e.uniform.sample(0,1))},variance:function(e,r){return r<=e?NaN:t.pow(r-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,r,n){return n<=0?0:t.exp(-t.abs(e-r)/n)/(2*n)},cdf:function(e,r,n){return n<=0?0:e<r?.5*t.exp((e-r)/n):1-.5*t.exp(-(e-r)/n)},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},variance:function(e,t){return 2*t*t},sample:function(r,a){var i=e._random_fn()-.5;return r-a*n(i)*t.log(1-2*t.abs(i))}}),e.extend(e.tukey,{cdf:function(r,n,i){var o=1,u=n,s=16,c=8,f=-30,l=1e-14,p=100,d=800,h=5e3,v=25e3,m=1,g=.5,y=.25,_=.125,b=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],k=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(r<=0)return 0;if(i<2||o<1||u<2)return NaN;if(!Number.isFinite(r))return 1;if(i>v)return a(r,o,u);var w,x=.5*i,S=x*t.log(i)-i*t.log(2)-e.gammaln(x),E=x-1,N=.25*i;w=i<=p?m:i<=d?g:i<=h?y:_,S+=t.log(w);for(var A=0,T=1;T<=50;T++){for(var I=0,M=(2*T-1)*w,C=1;C<=s;C++){var O,R;c<C?(O=C-c-1,R=S+E*t.log(M+b[O]*w)-(b[O]*w+M)*N):(O=C-1,R=S+E*t.log(M-b[O]*w)+(b[O]*w-M)*N),R>=f&&(I+=a(c<C?r*t.sqrt(.5*(b[O]*w+M)):r*t.sqrt(.5*(-b[O]*w+M)),o,u)*k[O]*t.exp(R))}if(T*w>=1&&I<=l)break;A+=I}if(I>l)throw new Error("tukey.cdf failed to converge");return A>1&&(A=1),A},inv:function(r,n,a){var o=1e-4,u=50;if(a<2||n<2)return NaN;if(r<0||r>1)return NaN;if(0===r)return 0;if(1===r)return 1/0;var s,c=i(r,n,a),f=e.tukey.cdf(c,n,a)-r;s=f>0?t.max(0,c-1):c+1;for(var l,p=e.tukey.cdf(s,n,a)-r,d=1;d<u;d++)if(l=s-p*(s-c)/(p-f),f=p,c=s,l<0&&(l=0,p=-r),p=e.tukey.cdf(l,n,a)-r,s=l,t.abs(s-c)<o)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(e,t){var r=Array.prototype.push,n=e.utils.isArray;function a(t){return n(t)||t instanceof e}e.extend({add:function(t,r){return a(r)?(a(r[0])||(r=[r]),e.map(t,(function(e,t,n){return e+r[t][n]}))):e.map(t,(function(e){return e+r}))},subtract:function(t,r){return a(r)?(a(r[0])||(r=[r]),e.map(t,(function(e,t,n){return e-r[t][n]||0}))):e.map(t,(function(e){return e-r}))},divide:function(t,r){return a(r)?(a(r[0])||(r=[r]),e.multiply(t,e.inv(r))):e.map(t,(function(e){return e/r}))},multiply:function(t,r){var n,i,o,u,s,c,f,l;if(void 0===t.length&&void 0===r.length)return t*r;if(s=t.length,c=t[0].length,f=e.zeros(s,o=a(r)?r[0].length:c),l=0,a(r)){for(;l<o;l++)for(n=0;n<s;n++){for(u=0,i=0;i<c;i++)u+=t[n][i]*r[i][l];f[n][l]=u}return 1===s&&1===l?f[0][0]:f}return e.map(t,(function(e){return e*r}))},outer:function(t,r){return e.multiply(t.map((function(e){return[e]})),[r])},dot:function(t,r){a(t[0])||(t=[t]),a(r[0])||(r=[r]);for(var n,i,o=1===t[0].length&&1!==t.length?e.transpose(t):t,u=1===r[0].length&&1!==r.length?e.transpose(r):r,s=[],c=0,f=o.length,l=o[0].length;c<f;c++){for(s[c]=[],n=0,i=0;i<l;i++)n+=o[c][i]*u[c][i];s[c]=n}return 1===s.length?s[0]:s},pow:function(r,n){return e.map(r,(function(e){return t.pow(e,n)}))},exp:function(r){return e.map(r,(function(e){return t.exp(e)}))},log:function(r){return e.map(r,(function(e){return t.log(e)}))},abs:function(r){return e.map(r,(function(e){return t.abs(e)}))},norm:function(e,r){var n=0,i=0;for(isNaN(r)&&(r=2),a(e[0])&&(e=e[0]);i<e.length;i++)n+=t.pow(t.abs(e[i]),r);return t.pow(n,1/r)},angle:function(r,n){return t.acos(e.dot(r,n)/(e.norm(r)*e.norm(n)))},aug:function(e,t){var n,a=[];for(n=0;n<e.length;n++)a.push(e[n].slice());for(n=0;n<a.length;n++)r.apply(a[n],t[n]);return a},inv:function(t){for(var r,n=t.length,a=t[0].length,i=e.identity(n,a),o=e.gauss_jordan(t,i),u=[],s=0;s<n;s++)for(u[s]=[],r=a;r<o[0].length;r++)u[s][r-a]=o[s][r];return u},det:function e(t){if(2===t.length)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(var r=0,n=0;n<t.length;n++){for(var a=[],i=1;i<t.length;i++){a[i-1]=[];for(var o=0;o<t.length;o++)o<n?a[i-1][o]=t[i][o]:o>n&&(a[i-1][o-1]=t[i][o])}var u=n%2?-1:1;r+=e(a)*t[0][n]*u}return r},gauss_elimination:function(r,n){var a,i,o,u,s=0,c=0,f=r.length,l=r[0].length,p=1,d=0,h=[];for(a=(r=e.aug(r,n))[0].length,s=0;s<f;s++){for(i=r[s][s],c=s,u=s+1;u<l;u++)i<t.abs(r[u][s])&&(i=r[u][s],c=u);if(c!=s)for(u=0;u<a;u++)o=r[s][u],r[s][u]=r[c][u],r[c][u]=o;for(c=s+1;c<f;c++)for(p=r[c][s]/r[s][s],u=s;u<a;u++)r[c][u]=r[c][u]-p*r[s][u]}for(s=f-1;s>=0;s--){for(d=0,c=s+1;c<=f-1;c++)d+=h[c]*r[s][c];h[s]=(r[s][a-1]-d)/r[s][s]}return h},gauss_jordan:function(r,n){var a,i,o,u=e.aug(r,n),s=u.length,c=u[0].length,f=0;for(i=0;i<s;i++){var l=i;for(o=i+1;o<s;o++)t.abs(u[o][i])>t.abs(u[l][i])&&(l=o);var p=u[i];for(u[i]=u[l],u[l]=p,o=i+1;o<s;o++)for(f=u[o][i]/u[i][i],a=i;a<c;a++)u[o][a]-=u[i][a]*f}for(i=s-1;i>=0;i--){for(f=u[i][i],o=0;o<i;o++)for(a=c-1;a>i-1;a--)u[o][a]-=u[i][a]*u[o][i]/f;for(u[i][i]/=f,a=s;a<c;a++)u[i][a]/=f}return u},triaUpSolve:function(t,r){var n,a=t[0].length,i=e.zeros(1,a)[0],o=!1;return null!=r[0].length&&(r=r.map((function(e){return e[0]})),o=!0),e.arange(a-1,-1,-1).forEach((function(o){n=e.arange(o+1,a).map((function(e){return i[e]*t[o][e]})),i[o]=(r[o]-e.sum(n))/t[o][o]})),o?i.map((function(e){return[e]})):i},triaLowSolve:function(t,r){var n,a=t[0].length,i=e.zeros(1,a)[0],o=!1;return null!=r[0].length&&(r=r.map((function(e){return e[0]})),o=!0),e.arange(a).forEach((function(a){n=e.arange(a).map((function(e){return t[a][e]*i[e]})),i[a]=(r[a]-e.sum(n))/t[a][a]})),o?i.map((function(e){return[e]})):i},lu:function(t){var r,n=t.length,a=e.identity(n),i=e.zeros(t.length,t[0].length);return e.arange(n).forEach((function(e){i[0][e]=t[0][e]})),e.arange(1,n).forEach((function(o){e.arange(o).forEach((function(n){r=e.arange(n).map((function(e){return a[o][e]*i[e][n]})),a[o][n]=(t[o][n]-e.sum(r))/i[n][n]})),e.arange(o,n).forEach((function(n){r=e.arange(o).map((function(e){return a[o][e]*i[e][n]})),i[o][n]=t[r.length][n]-e.sum(r)}))})),[a,i]},cholesky:function(r){var n,a=r.length,i=e.zeros(r.length,r[0].length);return e.arange(a).forEach((function(o){n=e.arange(o).map((function(e){return t.pow(i[o][e],2)})),i[o][o]=t.sqrt(r[o][o]-e.sum(n)),e.arange(o+1,a).forEach((function(t){n=e.arange(o).map((function(e){return i[o][e]*i[t][e]})),i[t][o]=(r[o][t]-e.sum(n))/i[o][o]}))})),i},gauss_jacobi:function(r,n,a,i){for(var o,u,s,c,f=0,l=0,p=r.length,d=[],h=[],v=[];f<p;f++)for(d[f]=[],h[f]=[],v[f]=[],l=0;l<p;l++)f>l?(d[f][l]=r[f][l],h[f][l]=v[f][l]=0):f<l?(h[f][l]=r[f][l],d[f][l]=v[f][l]=0):(v[f][l]=r[f][l],d[f][l]=h[f][l]=0);for(s=e.multiply(e.multiply(e.inv(v),e.add(d,h)),-1),u=e.multiply(e.inv(v),n),o=a,c=e.add(e.multiply(s,a),u),f=2;t.abs(e.norm(e.subtract(c,o)))>i;)o=c,c=e.add(e.multiply(s,o),u),f++;return c},gauss_seidel:function(r,n,a,i){for(var o,u,s,c,f,l=0,p=r.length,d=[],h=[],v=[];l<p;l++)for(d[l]=[],h[l]=[],v[l]=[],o=0;o<p;o++)l>o?(d[l][o]=r[l][o],h[l][o]=v[l][o]=0):l<o?(h[l][o]=r[l][o],d[l][o]=v[l][o]=0):(v[l][o]=r[l][o],d[l][o]=h[l][o]=0);for(c=e.multiply(e.multiply(e.inv(e.add(v,d)),h),-1),s=e.multiply(e.inv(e.add(v,d)),n),u=a,f=e.add(e.multiply(c,a),s),l=2;t.abs(e.norm(e.subtract(f,u)))>i;)u=f,f=e.add(e.multiply(c,u),s),l+=1;return f},SOR:function(r,n,a,i,o){for(var u,s,c,f,l,p=0,d=r.length,h=[],v=[],m=[];p<d;p++)for(h[p]=[],v[p]=[],m[p]=[],u=0;u<d;u++)p>u?(h[p][u]=r[p][u],v[p][u]=m[p][u]=0):p<u?(v[p][u]=r[p][u],h[p][u]=m[p][u]=0):(m[p][u]=r[p][u],h[p][u]=v[p][u]=0);for(f=e.multiply(e.inv(e.add(m,e.multiply(h,o))),e.subtract(e.multiply(m,1-o),e.multiply(v,o))),c=e.multiply(e.multiply(e.inv(e.add(m,e.multiply(h,o))),n),o),s=a,l=e.add(e.multiply(f,a),c),p=2;t.abs(e.norm(e.subtract(l,s)))>i;)s=l,l=e.add(e.multiply(f,s),c),p++;return l},householder:function(r){for(var n,a,i,o,u=r.length,s=r[0].length,c=0,f=[],l=[];c<u-1;c++){for(n=0,o=c+1;o<s;o++)n+=r[o][c]*r[o][c];for(n=(r[c+1][c]>0?-1:1)*t.sqrt(n),a=t.sqrt((n*n-r[c+1][c]*n)/2),(f=e.zeros(u,1))[c+1][0]=(r[c+1][c]-n)/(2*a),i=c+2;i<u;i++)f[i][0]=r[i][c]/(2*a);l=e.subtract(e.identity(u,s),e.multiply(e.multiply(f,e.transpose(f)),2)),r=e.multiply(l,e.multiply(r,l))}return r},QR:function(){var r=e.sum,n=e.arange;function a(a){var i,o,u,s=a.length,c=a[0].length,f=e.zeros(c,c);for(a=e.copy(a),o=0;o<c;o++){for(f[o][o]=t.sqrt(r(n(s).map((function(e){return a[e][o]*a[e][o]})))),i=0;i<s;i++)a[i][o]=a[i][o]/f[o][o];for(u=o+1;u<c;u++)for(f[o][u]=r(n(s).map((function(e){return a[e][o]*a[e][u]}))),i=0;i<s;i++)a[i][u]=a[i][u]-a[i][o]*f[o][u]}return[a,f]}return a}(),lstsq:function(){function t(t){var r=(t=e.copy(t)).length,n=e.identity(r);return e.arange(r-1,-1,-1).forEach((function(r){e.sliceAssign(n,{row:r},e.divide(e.slice(n,{row:r}),t[r][r])),e.sliceAssign(t,{row:r},e.divide(e.slice(t,{row:r}),t[r][r])),e.arange(r).forEach((function(a){var i=e.multiply(t[a][r],-1),o=e.slice(t,{row:a}),u=e.multiply(e.slice(t,{row:r}),i);e.sliceAssign(t,{row:a},e.add(o,u));var s=e.slice(n,{row:a}),c=e.multiply(e.slice(n,{row:r}),i);e.sliceAssign(n,{row:a},e.add(s,c))}))})),n}function r(r,n){var a=!1;void 0===n[0].length&&(n=n.map((function(e){return[e]})),a=!0);var i=e.QR(r),o=i[0],u=i[1],s=r[0].length,c=e.slice(o,{col:{end:s}}),f=t(e.slice(u,{row:{end:s}})),l=e.transpose(c);void 0===l[0].length&&(l=[l]);var p=e.multiply(e.multiply(f,l),n);return void 0===p.length&&(p=[[p]]),a?p.map((function(e){return e[0]})):p}return r}(),jacobi:function(r){for(var n,a,i,o,u,s,c,f=1,l=r.length,p=e.identity(l,l),d=[];1===f;){for(u=r[0][1],i=0,o=1,n=0;n<l;n++)for(a=0;a<l;a++)n!=a&&u<t.abs(r[n][a])&&(u=t.abs(r[n][a]),i=n,o=a);for(s=r[i][i]===r[o][o]?r[i][o]>0?t.PI/4:-t.PI/4:t.atan(2*r[i][o]/(r[i][i]-r[o][o]))/2,(c=e.identity(l,l))[i][i]=t.cos(s),c[i][o]=-t.sin(s),c[o][i]=t.sin(s),c[o][o]=t.cos(s),p=e.multiply(p,c),r=e.multiply(e.multiply(e.inv(c),r),c),f=0,n=1;n<l;n++)for(a=1;a<l;a++)n!=a&&t.abs(r[n][a])>.001&&(f=1)}for(n=0;n<l;n++)d.push(r[n][n]);return[p,d]},rungekutta:function(e,t,r,n,a,i){var o,u,s;if(2===i)for(;n<=r;)a+=((o=t*e(n,a))+(u=t*e(n+t,a+o)))/2,n+=t;if(4===i)for(;n<=r;)a+=((o=t*e(n,a))+2*(u=t*e(n+t/2,a+o/2))+2*(s=t*e(n+t/2,a+u/2))+t*e(n+t,a+s))/6,n+=t;return a},romberg:function(e,r,n,a){for(var i,o,u,s,c,f=0,l=(n-r)/2,p=[],d=[],h=[];f<a/2;){for(c=e(r),u=r,s=0;u<=n;u+=l,s++)p[s]=u;for(i=p.length,u=1;u<i-1;u++)c+=(u%2!=0?4:2)*e(p[u]);c=l/3*(c+e(n)),h[f]=c,l/=2,f++}for(o=h.length,i=1;1!==o;){for(u=0;u<o-1;u++)d[u]=(t.pow(4,i)*h[u+1]-h[u])/(t.pow(4,i)-1);o=d.length,h=d,d=[],i++}return h},richardson:function(e,r,n,a){function i(e,t){for(var r,n=0,a=e.length;n<a;n++)e[n]===t&&(r=n);return r}for(var o,u,s,c,f,l=t.abs(n-e[i(e,n)+1]),p=0,d=[],h=[];a>=l;)o=i(e,n+a),u=i(e,n),d[p]=(r[o]-2*r[u]+r[2*u-o])/(a*a),a/=2,p++;for(c=d.length,s=1;1!=c;){for(f=0;f<c-1;f++)h[f]=(t.pow(4,s)*d[f+1]-d[f])/(t.pow(4,s)-1);c=h.length,d=h,h=[],s++}return d},simpson:function(e,t,r,n){for(var a,i=(r-t)/n,o=e(t),u=[],s=t,c=0,f=1;s<=r;s+=i,c++)u[c]=s;for(a=u.length;f<a-1;f++)o+=(f%2!=0?4:2)*e(u[f]);return i/3*(o+e(r))},hermite:function(e,t,r,n){for(var a,i=e.length,o=0,u=0,s=[],c=[],f=[],l=[];u<i;u++){for(s[u]=1,a=0;a<i;a++)u!=a&&(s[u]*=(n-e[a])/(e[u]-e[a]));for(c[u]=0,a=0;a<i;a++)u!=a&&(c[u]+=1/(e[u]-e[a]));f[u]=(1-2*(n-e[u])*c[u])*(s[u]*s[u]),l[u]=(n-e[u])*(s[u]*s[u]),o+=f[u]*t[u]+l[u]*r[u]}return o},lagrange:function(e,t,r){for(var n,a,i=0,o=0,u=e.length;o<u;o++){for(a=t[o],n=0;n<u;n++)o!=n&&(a*=(r-e[n])/(e[o]-e[n]));i+=a}return i},cubic_spline:function(t,r,n){for(var a,i=t.length,o=0,u=[],s=[],c=[],f=[],l=[],p=[],d=[];o<i-1;o++)l[o]=t[o+1]-t[o];for(c[0]=0,o=1;o<i-1;o++)c[o]=3/l[o]*(r[o+1]-r[o])-3/l[o-1]*(r[o]-r[o-1]);for(o=1;o<i-1;o++)u[o]=[],s[o]=[],u[o][o-1]=l[o-1],u[o][o]=2*(l[o-1]+l[o]),u[o][o+1]=l[o],s[o][0]=c[o];for(f=e.multiply(e.inv(u),s),a=0;a<i-1;a++)p[a]=(r[a+1]-r[a])/l[a]-l[a]*(f[a+1][0]+2*f[a][0])/3,d[a]=(f[a+1][0]-f[a][0])/(3*l[a]);for(a=0;a<i&&!(t[a]>n);a++);return r[a-=1]+(n-t[a])*p[a]+e.sq(n-t[a])*f[a]+(n-t[a])*e.sq(n-t[a])*d[a]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(t){var r,n,a=t.length,i=t[0].length,o=0,u=[],s=[],c=[],f=[],l=[],p=[],d=[],h=[],v=[],m=[];for(o=0;o<a;o++)u[o]=e.sum(t[o])/i;for(o=0;o<i;o++)for(d[o]=[],r=0;r<a;r++)d[o][r]=t[r][o]-u[r];for(d=e.transpose(d),o=0;o<a;o++)for(h[o]=[],r=0;r<a;r++)h[o][r]=e.dot([d[o]],[d[r]])/(i-1);for(v=(c=e.jacobi(h))[0],s=c[1],m=e.transpose(v),o=0;o<s.length;o++)for(r=o;r<s.length;r++)s[o]<s[r]&&(n=s[o],s[o]=s[r],s[r]=n,f=m[o],m[o]=m[r],m[r]=f);for(p=e.transpose(d),o=0;o<a;o++)for(l[o]=[],r=0;r<p.length;r++)l[o][r]=e.dot([m[o]],[p[r]]);return[t,s,m,l]}}),function(t){for(var r=0;r<t.length;r++)!function(t){e.fn[t]=function(r,n){var a=this;return n?(setTimeout((function(){n.call(a,e.fn[t].call(a,r))}),15),this):"number"==typeof e[t](this,r)?e[t](this,r):e(e[t](this,r))}}(t[r])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(e,t){var r=[].slice,n=e.utils.isNumber,a=e.utils.isArray;function i(e,r,n,a){if(e>1||n>1||e<=0||n<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(e*r+n*a)/(r+a);return(e-n)/t.sqrt(i*(1-i)*(1/r+1/a))}e.extend({zscore:function(){var t=r.call(arguments);return n(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var n,i=r.call(arguments);return a(i[1])?(n=e.zscore(i[0],i[1],i[3]),1===i[2]?e.normal.cdf(-t.abs(n),0,1):2*e.normal.cdf(-t.abs(n),0,1)):i.length>2?(n=e.zscore(i[0],i[1],i[2]),1===i[3]?e.normal.cdf(-t.abs(n),0,1):2*e.normal.cdf(-t.abs(n),0,1)):(n=i[0],1===i[1]?e.normal.cdf(-t.abs(n),0,1):2*e.normal.cdf(-t.abs(n),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(r,n,a){var i=t.abs(this.zscore(r,a));return 1===n?e.normal.cdf(-i,0,1):2*e.normal.cdf(-i,0,1)}}),e.extend({tscore:function(){var n=r.call(arguments);return 4===n.length?(n[0]-n[1])/(n[2]/t.sqrt(n[3])):(n[0]-e.mean(n[1]))/(e.stdev(n[1],!0)/t.sqrt(n[1].length))},ttest:function(){var a,i=r.call(arguments);return 5===i.length?(a=t.abs(e.tscore(i[0],i[1],i[2],i[3])),1===i[4]?e.studentt.cdf(-a,i[3]-1):2*e.studentt.cdf(-a,i[3]-1)):n(i[1])?(a=t.abs(i[0]),1==i[2]?e.studentt.cdf(-a,i[1]-1):2*e.studentt.cdf(-a,i[1]-1)):(a=t.abs(e.tscore(i[0],i[1])),1==i[2]?e.studentt.cdf(-a,i[1].length-1):2*e.studentt.cdf(-a,i[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/t.sqrt(this.cols()))},ttest:function(r,n){return 1===n?1-e.studentt.cdf(t.abs(this.tscore(r)),this.cols()-1):2*e.studentt.cdf(-t.abs(this.tscore(r)),this.cols()-1)}}),e.extend({anovafscore:function(){var n,a,i,o,u,s,c,f,l=r.call(arguments);if(1===l.length){for(u=new Array(l[0].length),c=0;c<l[0].length;c++)u[c]=l[0][c];l=u}for(a=new Array,c=0;c<l.length;c++)a=a.concat(l[c]);for(i=e.mean(a),n=0,c=0;c<l.length;c++)n+=l[c].length*t.pow(e.mean(l[c])-i,2);for(n/=l.length-1,s=0,c=0;c<l.length;c++)for(o=e.mean(l[c]),f=0;f<l[c].length;f++)s+=t.pow(l[c][f]-o,2);return n/(s/=a.length-l.length)},anovaftest:function(){var t,a,i,o,u=r.call(arguments);if(n(u[0]))return 1-e.centralF.cdf(u[0],u[1],u[2]);var s=e.anovafscore(u);for(t=u.length-1,i=0,o=0;o<u.length;o++)i+=u[o].length;return a=i-t-1,1-e.centralF.cdf(s,t,a)},ftest:function(t,r,n){return 1-e.centralF.cdf(t,r,n)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){var t,r=0;for(t=0;t<this.length;t++)r+=this[t].length;return e.ftest(this.anovafscore(),this.length-1,r-this.length)}}),e.extend({qscore:function(){var a,i,o,u,s,c=r.call(arguments);return n(c[0])?(a=c[0],i=c[1],o=c[2],u=c[3],s=c[4]):(a=e.mean(c[0]),i=e.mean(c[1]),o=c[0].length,u=c[1].length,s=c[2]),t.abs(a-i)/(s*t.sqrt((1/o+1/u)/2))},qtest:function(){var t,n=r.call(arguments);3===n.length?(t=n[0],n=n.slice(1)):7===n.length?(t=e.qscore(n[0],n[1],n[2],n[3],n[4]),n=n.slice(5)):(t=e.qscore(n[0],n[1],n[2]),n=n.slice(3));var a=n[0],i=n[1];return 1-e.tukey.cdf(t,i,a-i)},tukeyhsd:function(t){for(var r=e.pooledstdev(t),n=t.map((function(t){return e.mean(t)})),a=t.reduce((function(e,t){return e+t.length}),0),i=[],o=0;o<t.length;++o)for(var u=o+1;u<t.length;++u){var s=e.qtest(n[o],n[u],t[o].length,t[u].length,r,a,t.length);i.push([[o,u],s])}return i}}),e.extend({normalci:function(){var n,a=r.call(arguments),i=new Array(2);return n=4===a.length?t.abs(e.normal.inv(a[1]/2,0,1)*a[2]/t.sqrt(a[3])):t.abs(e.normal.inv(a[1]/2,0,1)*e.stdev(a[2])/t.sqrt(a[2].length)),i[0]=a[0]-n,i[1]=a[0]+n,i},tci:function(){var n,a=r.call(arguments),i=new Array(2);return n=4===a.length?t.abs(e.studentt.inv(a[1]/2,a[3]-1)*a[2]/t.sqrt(a[3])):t.abs(e.studentt.inv(a[1]/2,a[2].length-1)*e.stdev(a[2],!0)/t.sqrt(a[2].length)),i[0]=a[0]-n,i[1]=a[0]+n,i},significant:function(e,t){return e<t}}),e.extend(e.fn,{normalci:function(t,r){return e.normalci(t,r,this.toArray())},tci:function(t,r){return e.tci(t,r,this.toArray())}}),e.extend(e.fn,{oneSidedDifferenceOfProportions:function(t,r,n,a){var o=i(t,r,n,a);return e.ztest(o,1)},twoSidedDifferenceOfProportions:function(t,r,n,a){var o=i(t,r,n,a);return e.ztest(o,2)}})}(e,Math),e.models=function(){function t(t){var n=t[0].length;return e.arange(n).map((function(a){var i=e.arange(n).filter((function(e){return e!==a}));return r(e.col(t,a).map((function(e){return e[0]})),e.col(t,i))}))}function r(t,r){var n=t.length,a=r[0].length-1,i=n-a-1,o=e.lstsq(r,t),u=e.multiply(r,o.map((function(e){return[e]}))).map((function(e){return e[0]})),s=e.subtract(t,u),c=e.mean(t),f=e.sum(u.map((function(e){return Math.pow(e-c,2)}))),l=e.sum(t.map((function(e,t){return Math.pow(e-u[t],2)}))),p=f+l;return{exog:r,endog:t,nobs:n,df_model:a,df_resid:i,coef:o,predict:u,resid:s,ybar:c,SST:p,SSE:f,SSR:l,R2:f/p}}function n(r){var n=t(r.exog),a=Math.sqrt(r.SSR/r.df_resid),i=n.map((function(e){var t=e.SST,r=e.R2;return a/Math.sqrt(t*(1-r))})),o=r.coef.map((function(e,t){return(e-0)/i[t]})),u=o.map((function(t){var n=e.studentt.cdf(t,r.df_resid);return 2*(n>.5?1-n:n)})),s=e.studentt.inv(.975,r.df_resid),c=r.coef.map((function(e,t){var r=s*i[t];return[e-r,e+r]}));return{se:i,t:o,p:u,sigmaHat:a,interval95:c}}function a(t){var r,n,a,i=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:i,pvalue:1-(r=i,n=t.df_model,a=t.df_resid,e.beta.cdf(r/(a/n+r),n/2,a/2))}}function i(e,t){var i=r(e,t),o=n(i),u=a(i),s=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=o,i.f=u,i.adjust_R2=s,i}return{ols:i}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),r=0;r<arguments.length;r++){var n=[1];t[r]=n.concat(arguments[r])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),r=0;r<arguments[0].length;r++){var n=[1];t[r]=n.concat(arguments[0][r])}return e(t)},buildjxmatrix:function(t){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=t[n];return e.builddxmatrix(r)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(t,r){var n,a,i,o,u;if(t.cols()==r.rows()){if(r.rows()>1){for(o=[],n=0;n<t.rows();n++)for(o[n]=[],a=0;a<r.cols();a++){for(u=0,i=0;i<t.cols();i++)u+=t.toArray()[n][i]*r.toArray()[i][a];o[n][a]=u}return e(o)}for(o=[],n=0;n<t.rows();n++)for(o[n]=[],a=0;a<r.cols();a++){for(u=0,i=0;i<t.cols();i++)u+=t.toArray()[n][i]*r.toArray()[a];o[n][a]=u}return e(o)}},regress:function(t,r){var n=e.xtranspxinv(t),a=t.transpose(),i=e.matrixmult(e(n),a);return e.matrixmult(i,r)},regresst:function(t,r,n){var a=e.regress(t,r),i={anova:{}},o=e.jMatYBar(t,a);i.yBar=o;var u=r.mean();i.anova.residuals=e.residuals(r,o),i.anova.ssr=e.ssr(o,u),i.anova.msr=i.anova.ssr/(t[0].length-1),i.anova.sse=e.sse(r,o),i.anova.mse=i.anova.sse/(r.length-(t[0].length-1)-1),i.anova.sst=e.sst(r,u),i.anova.mst=i.anova.sst/(r.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=e.anovaftest(i.anova.fratio,t[0].length-1,r.length-(t[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(t[0].length);for(var s,c,f,l=e.xtranspxinv(t),p=0;p<a.length;p++)s=Math.sqrt(i.anova.mse*Math.abs(l[p][p])),c=Math.abs(a[p]/s),f=e.ttest(c,r.length-t[0].length-1,n),i.stats[p]=[a[p],s,c,f];return i.regress=a,i},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var r=e.matrixmult(t.transpose(),t);return e.inv(r)},jMatYBar:function(t,r){var n=e.matrixmult(t,r);return new e(n)},residuals:function(t,r){return e.matrixsubtract(t,r)},ssr:function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},sse:function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t[n],2);return r},sst:function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},matrixsubtract:function(t,r){for(var n=new Array(t.length),a=0;a<t.length;a++){n[a]=new Array(t[a].length);for(var i=0;i<t[a].length;i++)n[a][i]=t[a][i]-r[a][i]}return e(n)}}),e.jStat=e,e}()}(ae)),ae.exports),oe=re(ie);function ue(){for(var e=[],t=0;t<arguments.length;++t){for(var r=!1,n=arguments[t],a=0;a<e.length&&!(r=e[a]===n);++a);r||e.push(n)}return e}function se(e,t,r,n){if(!t||!r)return u;n=!(0===n||!1===n);for(var i=u,o=!1,s="number"==typeof e,c="string"==typeof e?e.toLowerCase():e,f=0;f<t.length;f++){var l=t[f],p="string"==typeof l[0]?l[0].toLowerCase():l[0];if(p===c){i=r<l.length+1?l[r-1]:a;break}!o&&(s&&n&&p<=e||n&&"string"==typeof p&&p.localeCompare(e)<0)&&(i=r<l.length+1?l[r-1]:a),s&&p>e&&(o=!0)}return i}function ce(e,t){return-1===t?Array.from({length:e},(function(t,r){return e-1-r})):Array.from({length:e},(function(e,t){return t}))}function fe(e){return 0===(e=V(e))?n:e instanceof Error?e:String.fromCharCode(e)}function le(e){if(F(e))return e;var t=(e=e||"").charCodeAt(0);return isNaN(t)&&(t=n),t}function pe(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;for(var r=0;(r=e.indexOf(!0))>-1;)e[r]="TRUE";for(var n=0;(n=e.indexOf(!1))>-1;)e[n]="FALSE";return e.join("")}var de=pe;function he(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e=V(e),isNaN(e))return n;if(t=V(t),isNaN(t))return n;if(t<0){var a=Math.pow(10,-t);e=Math.round(e/a)*a}else e=e.toFixed(t);if(r)e=e.toString().replace(/,/g,"");else{var i=e.toString().split(".");i[0]=i[0].replace(/\B(?=(\d{3})+$)/g,","),e=i.join(".")}return e}function ve(e,t){var r=L(e,t);return r||(e=B(e),(t=V(t))instanceof Error?t:new Array(t+1).join(e))}function me(e){return e instanceof Error||"string"==typeof e?e:""}var ge=fe,ye=le;function _e(){var e=C(arguments).filter(X);if(0===e.length)return r;var t=L.apply(void 0,e);if(t)return t;for(var n,a=q(e),i=a.length,u=0,s=0,c=0;c<i;c++)u+=a[c],s+=1;return n=u/s,isNaN(n)&&(n=o),n}function be(){var e=C(arguments).filter(X);if(0===e.length)return r;var t=L.apply(void 0,e);if(t)return t;for(var n,a=e,i=a.length,u=0,s=0,c=0;c<i;c++){var f=a[c];"number"==typeof f&&(u+=f),!0===f&&u++,null!==f&&s++}return n=u/s,isNaN(n)&&(n=o),n}var ke={DIST:function(e,t,r,a,i,o){return arguments.length<4?n:(i=void 0===i?0:i,o=void 0===o?1:o,F(e=V(e),t=V(t),r=V(r),i=V(i),o=V(o))?n:(e=(e-i)/(o-i),a?oe.beta.cdf(e,t,r):oe.beta.pdf(e,t,r)))},INV:function(e,t,r,a,i){return a=void 0===a?0:a,i=void 0===i?1:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i))?n:oe.beta.inv(e,t,r)*(i-a)+a}},we={DIST:function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r),a=V(a))?n:a?oe.binomial.cdf(e,t,r):oe.binomial.pdf(e,t,r)}};we.DIST.RANGE=function(e,t,r,a){if(a=void 0===a?r:a,F(e=V(e),t=V(t),r=V(r),a=V(a)))return n;for(var i=0,o=r;o<=a;o++)i+=it(e,o)*Math.pow(t,o)*Math.pow(1-t,e-o);return i},we.INV=function(e,t,r){if(F(e=V(e),t=V(t),r=V(r)))return n;for(var a=0;a<=e;){if(oe.binomial.cdf(a,e,t)>=r)return a;a++}};var xe={DIST:function(e,t,r){return F(e=V(e),t=V(t))?n:r?oe.chisquare.cdf(e,t):oe.chisquare.pdf(e,t)}};xe.DIST.RT=function(e,t){return!e|!t?u:e<1||t>Math.pow(10,10)?o:"number"!=typeof e||"number"!=typeof t?n:1-oe.chisquare.cdf(e,t)},xe.INV=function(e,t){return F(e=V(e),t=V(t))?n:oe.chisquare.inv(e,t)},xe.INV.RT=function(e,t){return!e|!t?u:e<0||e>1||t<1||t>Math.pow(10,10)?o:"number"!=typeof e||"number"!=typeof t?n:oe.chisquare.inv(1-e,t)},xe.TEST=function(e,t){if(2!==arguments.length)return u;if(!(e instanceof Array&&t instanceof Array))return n;if(e.length!==t.length)return n;if(e[0]&&t[0]&&e[0].length!==t[0].length)return n;var r,a,i,o=e.length;for(a=0;a<o;a++)e[a]instanceof Array||(r=e[a],e[a]=[],e[a].push(r)),t[a]instanceof Array||(r=t[a],t[a]=[],t[a].push(r));var s=e[0].length,c=1===s?o-1:(o-1)*(s-1),f=0,l=Math.PI;for(a=0;a<o;a++)for(i=0;i<s;i++)f+=Math.pow(e[a][i]-t[a][i],2)/t[a][i];return Math.round(1e6*function(e,t){var r=Math.exp(-.5*e);t%2==1&&(r*=Math.sqrt(2*e/l));for(var n=t;n>=2;)r=r*e/n,n-=2;for(var a=r,i=t;a>1e-10*r;)r+=a=a*e/(i+=2);return 1-r}(f,c))/1e6};var Se={};function Ee(){return q(C(arguments)).length}function Ne(){var e=C(arguments);return e.length-Ae(e)}function Ae(){for(var e,t=C(arguments),r=0,n=0;n<t.length;n++)null!=(e=t[n])&&""!==e||r++;return r}Se.NORM=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.normalci(1,e,t,r)[1]-1},Se.T=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.tci(1,e,t,r)[1]-1};var Te={};Te.P=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(e),a=oe.mean(t),i=0,o=e.length,u=0;u<o;u++)i+=(e[u]-r)*(t[u]-a);return i/o},Te.S=function(e,t){return F(e=Y(C(e)),t=Y(C(t)))?n:oe.covariance(e,t)};var Ie={DIST:function(e,t,r){return F(e=V(e),t=V(t))?n:r?oe.exponential.cdf(e,t):oe.exponential.pdf(e,t)}},Me={};function Ce(e,t,r){if(F(e=V(e),t=Y(C(t)),r=Y(C(r))))return n;for(var a=oe.mean(r),i=oe.mean(t),o=r.length,u=0,s=0,c=0;c<o;c++)u+=(r[c]-a)*(t[c]-i),s+=Math.pow(r[c]-a,2);var f=u/s;return i-f*a+f*e}function Oe(e){return(e=V(e))instanceof Error?e:0===e||parseInt(e,10)===e&&e<0?o:oe.gammafn(e)}function Re(e){return(e=V(e))instanceof Error?e:oe.gammaln(e)}Me.DIST=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?oe.centralF.cdf(e,t,r):oe.centralF.pdf(e,t,r)},Me.DIST.RT=function(e,t,r){return 3!==arguments.length?u:e<0||t<1||r<1?o:"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:1-oe.centralF.cdf(e,t,r)},Me.INV=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:e<=0||e>1?o:oe.centralF.inv(e,t,r)},Me.INV.RT=function(e,t,r){return 3!==arguments.length?u:e<0||e>1||t<1||t>Math.pow(10,10)||r<1||r>Math.pow(10,10)?o:"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:oe.centralF.inv(1-e,t,r)},Me.TEST=function(e,t){if(!e||!t)return u;if(!(e instanceof Array&&t instanceof Array))return u;if(e.length<2||t.length<2)return r;var n=function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},a=dt(e)/e.length,i=dt(t)/t.length;return n(e,a)/(e.length-1)/(n(t,i)/(t.length-1))},Oe.DIST=function(e,t,r,a){return 4!==arguments.length?u:e<0||t<=0||r<=0||"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:a?oe.gamma.cdf(e,t,r,!0):oe.gamma.pdf(e,t,r,!1)},Oe.INV=function(e,t,r){return 3!==arguments.length?u:e<0||e>1||t<=0||r<=0?o:"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:oe.gamma.inv(e,t,r)},Re.PRECISE=function(e){return 1!==arguments.length?u:e<=0?o:"number"!=typeof e?n:oe.gammaln(e)};var je={};function De(e,t){var r=L.apply(void 0,e);return r||(F(t)?t:(e=q(C(e)),(t=V(t))<0||e.length<t?n:e.sort((function(e,t){return t-e}))[t-1]))}function Pe(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(e),a=oe.mean(t),i=t.length,o=0,u=0,s=0;s<i;s++)o+=(t[s]-a)*(e[s]-r),u+=Math.pow(t[s]-a,2);var c=o/u;return[c,r-c*a]}je.DIST=function(e,t,r,a,i){if(F(e=V(e),t=V(t),r=V(r),a=V(a)))return n;function o(e,t,r,n){return it(r,e)*it(n-r,t-e)/it(n,t)}return i?function(e,t,r,n){for(var a=0,i=0;i<=e;i++)a+=o(i,t,r,n);return a}(e,t,r,a):o(e,t,r,a)};var Le={};function Fe(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=q(e);return 0===r.length?0:Math.max.apply(Math,r)}function Ue(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=I(e),n=oe.median(r);return isNaN(n)&&(n=o),n}function qe(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=q(e);return 0===r.length?0:Math.min.apply(Math,r)}Le.DIST=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?oe.lognormal.cdf(e,t,r):oe.lognormal.pdf(e,t,r)},Le.INV=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.lognormal.inv(e,t,r)};var Ge={MULT:function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t,r=e.length,n={},a=[],i=0,o=0;o<r;o++)n[t=e[o]]=n[t]?n[t]+1:1,n[t]>i&&(i=n[t],a=[]),n[t]===i&&(a[a.length]=t);return a},SNGL:function(){var e=Y(C(arguments));return e instanceof Error?e:Ge.MULT(e).sort((function(e,t){return e-t}))[0]}},He={DIST:function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?oe.negbin.cdf(e,t,r):oe.negbin.pdf(e,t,r)}},Ze={};function Ve(e,t){if(F(t=Y(C(t)),e=Y(C(e))))return n;for(var r=oe.mean(e),a=oe.mean(t),i=e.length,o=0,u=0,s=0,c=0;c<i;c++)o+=(e[c]-r)*(t[c]-a),u+=Math.pow(e[c]-r,2),s+=Math.pow(t[c]-a,2);return o/Math.sqrt(u*s)}Ze.DIST=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:r<=0?o:a?oe.normal.cdf(e,t,r):oe.normal.pdf(e,t,r)},Ze.INV=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.normal.inv(e,t,r)},Ze.S={},Ze.S.DIST=function(e,t){return(e=V(e))instanceof Error?n:t?oe.normal.cdf(e,0,1):oe.normal.pdf(e,0,1)},Ze.S.INV=function(e){return(e=V(e))instanceof Error?n:oe.normal.inv(e,0,1)};var Ye={EXC:function(e,t){if(F(e=Y(C(e)),t=V(t)))return n;var r=(e=e.sort((function(e,t){return e-t}))).length;if(t<1/(r+1)||t>1-1/(r+1))return o;var a=t*(r+1)-1,i=Math.floor(a);return U(a===i?e[a]:e[i]+(a-i)*(e[i+1]-e[i]))},INC:function(e,t){if(F(e=Y(C(e)),t=V(t)))return n;var r=t*((e=e.sort((function(e,t){return e-t}))).length-1),a=Math.floor(r);return U(r===a?e[r]:e[a]+(r-a)*(e[a+1]-e[a]))}},Be={};Be.EXC=function(e,t,r){if(r=void 0===r?3:r,F(e=Y(C(e)),t=V(t),r=V(r)))return n;e=e.sort((function(e,t){return e-t}));for(var a=ue.apply(null,e),i=e.length,o=a.length,u=Math.pow(10,r),s=0,c=!1,f=0;!c&&f<o;)t===a[f]?(s=(e.indexOf(a[f])+1)/(i+1),c=!0):t>=a[f]&&(t<a[f+1]||f===o-1)&&(s=(e.indexOf(a[f])+1+(t-a[f])/(a[f+1]-a[f]))/(i+1),c=!0),f++;return Math.floor(s*u)/u},Be.INC=function(e,t,r){if(r=void 0===r?3:r,F(e=Y(C(e)),t=V(t),r=V(r)))return n;e=e.sort((function(e,t){return e-t}));for(var a=ue.apply(null,e),i=e.length,o=a.length,u=Math.pow(10,r),s=0,c=!1,f=0;!c&&f<o;)t===a[f]?(s=e.indexOf(a[f])/(i-1),c=!0):t>=a[f]&&(t<a[f+1]||f===o-1)&&(s=(e.indexOf(a[f])+(t-a[f])/(a[f+1]-a[f]))/(i-1),c=!0),f++;return Math.floor(s*u)/u};var Ke={};Ke.DIST=function(e,t,r){return F(e=V(e),t=V(t))?n:r?oe.poisson.cdf(e,t):oe.poisson.pdf(e,t)};var ze={EXC:function(e,t){if(F(e=Y(q(C(e))),t=V(t)))return n;switch(t){case 1:return Ye.EXC(e,.25);case 2:return Ye.EXC(e,.5);case 3:return Ye.EXC(e,.75);default:return o}},INC:function(e,t){if(F(e=Y(q(C(e))),t=V(t)))return n;switch(t){case 1:return Ye.INC(e,.25);case 2:return Ye.INC(e,.5);case 3:return Ye.INC(e,.75);default:return o}}},Xe={};function We(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=e.length,n=0,a=0;a<r;a++)n+=Math.pow(e[a]-t,3);return r*n/((r-1)*(r-2)*Math.pow(oe.stdev(e,!0),3))}function $e(e,t){return F(e=Y(C(e)),t=V(t))?e:e.sort((function(e,t){return e-t}))[t-1]}Xe.AVG=function(e,t,r){if(F(e=V(e),t=Y(C(t))))return n;for(var a=(r=r||!1)?function(e,t){return e-t}:function(e,t){return t-e},i=(t=(t=C(t)).sort(a)).length,o=0,u=0;u<i;u++)t[u]===e&&o++;return o>1?(2*t.indexOf(e)+o+1)/2:t.indexOf(e)+1},Xe.EQ=function(e,t,r){if(F(e=V(e),t=Y(C(t))))return n;var a=(r=r||!1)?function(e,t){return e-t}:function(e,t){return t-e};return(t=t.sort(a)).indexOf(e)+1},We.P=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=e.length,n=0,a=0,i=0;i<r;i++)a+=Math.pow(e[i]-t,3),n+=Math.pow(e[i]-t,2);return n/=r,(a/=r)/Math.pow(n,1.5)};var Qe={};Qe.P=function(){var e=Je.P.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=o),t},Qe.S=function(){var e=Je.S.apply(this,arguments);return Math.sqrt(e)},me.DIST=function(e,t,r){return 1!==r&&2!==r?o:1===r?me.DIST.RT(e,t):me.DIST["2T"](e,t)},me.DIST["2T"]=function(e,t){return 2!==arguments.length?u:e<0||t<1?o:"number"!=typeof e||"number"!=typeof t?n:2*(1-oe.studentt.cdf(e,t))},me.DIST.RT=function(e,t){return 2!==arguments.length?u:e<0||t<1?o:"number"!=typeof e||"number"!=typeof t?n:1-oe.studentt.cdf(e,t)},me.INV=function(e,t){return F(e=V(e),t=V(t))?n:oe.studentt.inv(e,t)},me.INV["2T"]=function(e,t){return e=V(e),t=V(t),e<=0||e>1||t<1?o:F(e,t)?n:Math.abs(oe.studentt.inv(e/2,t))},me.TEST=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;var r,a=oe.mean(e),i=oe.mean(t),o=0,u=0;for(r=0;r<e.length;r++)o+=Math.pow(e[r]-a,2);for(r=0;r<t.length;r++)u+=Math.pow(t[r]-i,2);o/=e.length-1,u/=t.length-1;var s=Math.abs(a-i)/Math.sqrt(o/e.length+u/t.length);return me.DIST["2T"](s,e.length+t.length-2)};var Je={};function et(){for(var e=C(arguments),t=e.length,r=0,n=0,a=be(e),i=0;i<t;i++){var o=e[i];r+="number"==typeof o?Math.pow(o-a,2):!0===o?Math.pow(1-a,2):Math.pow(0-a,2),null!==o&&n++}return r/(n-1)}function tt(){for(var e,t=C(arguments),r=t.length,n=0,a=0,i=be(t),u=0;u<r;u++){var s=t[u];n+="number"==typeof s?Math.pow(s-i,2):!0===s?Math.pow(1-i,2):Math.pow(0-i,2),null!==s&&a++}return e=n/a,isNaN(e)&&(e=o),e}Je.P=function(){for(var e,t=q(C(arguments)),r=t.length,n=0,a=_e(t),i=0;i<r;i++)n+=Math.pow(t[i]-a,2);return e=n/r,isNaN(e)&&(e=o),e},Je.S=function(){for(var e=q(C(arguments)),t=e.length,r=0,n=_e(e),a=0;a<t;a++)r+=Math.pow(e[a]-n,2);return r/(t-1)};var rt={DIST:function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?1-Math.exp(-Math.pow(e/r,t)):Math.pow(e,t-1)*Math.exp(-Math.pow(e/r,t))*t/Math.pow(r,t)}},nt={};function at(e,t){var r=L(e=V(e),t=V(t));return r||(0===t?0:e>0&&t<0?o:Math.ceil(e/t)*t)}function it(e,t){var r=L(e=V(e),t=V(t));return r||(e<t?o:ut(e)/(ut(t)*ut(e-t)))}nt.TEST=function(e,t,r){if(F(e=Y(C(e)),t=V(t)))return n;r=r||Qe.S(e);var a=e.length;return 1-Ze.S.DIST((_e(e)-t)/(r/Math.sqrt(a)),!0)},at.MATH=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;void 0===t&&(t=e>0?1:-1);var n=L(e=V(e),t=V(t),r=V(r));return n||(0===t?0:(t=Math.abs(t),0===r||e>0?Math.ceil(e/t)*t:Math.floor(e/t)*t))},at.PRECISE=function(e,t){return at.MATH(e,t)};var ot=[];function ut(e){if((e=V(e))instanceof Error)return e;var t=Math.floor(e);return 0===t||1===t?1:(ot[t]>0||(ot[t]=ut(t-1)*t),ot[t])}function st(e,t){var n=L(e=V(e),t=V(t));return n||(t?e>0&&t<0?o:Math.floor(e/t)*t:r)}st.MATH=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=L(e=V(e),t=V(t),r=V(r));return n||(0===t?0:(t=Math.abs(t),0===r||e>0?Math.floor(e/t)*t:Math.ceil(e/t)*t))},st.PRECISE=function(e,t){return st.MATH(e,t)};var ct={CEILING:at};function ft(e,t){var r=L(e=V(e),t=V(t));if(r)return r;if(0===e&&0===t)return o;var n=Math.pow(e,t);return isNaN(n)?o:n}function lt(){var e=C(arguments).filter((function(e){return null!=e}));if(0===e.length)return 0;var t=Y(e);if(t instanceof Error)return t;for(var r=1,n=0;n<t.length;n++)r*=t[n];return r}function pt(e,t){var r=L(e=V(e),t=V(t));return r||Number(Math.round(Number(e+"e"+t))+"e"+-1*t)}function dt(){var e=0;return T(A(arguments),(function(t){if(e instanceof Error)return!1;if(t instanceof Error)e=t;else if("number"==typeof t)e+=t;else if("string"==typeof t){var r=parseFloat(t);!isNaN(r)&&(e+=r)}else if(Array.isArray(t)){var n=dt.apply(null,t);n instanceof Error?e=n:e+=n}})),e}var ht=Object.freeze({__proto__:null,ADD:function(e,t){if(2!==arguments.length)return u;var r=L(e=V(e),t=V(t));return r||e+t},DIVIDE:function(e,t){if(2!==arguments.length)return u;var n=L(e=V(e),t=V(t));return n||(0===t?r:e/t)},EQ:function(e,t){return 2!==arguments.length?u:e instanceof Error?e:t instanceof Error?t:(null===e&&(e=void 0),null===t&&(t=void 0),e===t)},GT:function(e,t){if(2!==arguments.length)return u;if(e instanceof Error)return e;if(t instanceof Error)return t;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e>t},GTE:function(e,t){if(2!==arguments.length)return u;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e>=t},LT:function(e,t){if(2!==arguments.length)return u;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e<t},LTE:function(e,t){if(2!==arguments.length)return u;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e<=t},MINUS:function(e,t){if(2!==arguments.length)return u;var r=L(e=V(e),t=V(t));return r||e-t},MULTIPLY:function(e,t){if(2!==arguments.length)return u;var r=L(e=V(e),t=V(t));return r||e*t},NE:function(e,t){return 2!==arguments.length?u:e instanceof Error?e:t instanceof Error?t:(null===e&&(e=void 0),null===t&&(t=void 0),e!==t)},POW:function(e,t){return 2!==arguments.length?u:ft(e,t)}}),vt=[void 0,0,1,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,1,2,3,4,5,6,0],mt=[[],[1,2,3,4,5,6,7],[7,1,2,3,4,5,6],[6,0,1,2,3,4,5],[],[],[],[],[],[],[],[7,1,2,3,4,5,6],[6,7,1,2,3,4,5],[5,6,7,1,2,3,4],[4,5,6,7,1,2,3],[3,4,5,6,7,1,2],[2,3,4,5,6,7,1],[1,2,3,4,5,6,7]],gt=[[],[6,0],[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],void 0,void 0,void 0,[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]];function yt(e,t,r){r=r.toUpperCase(),e=H(e),t=H(t);var n,a=e.getFullYear(),i=e.getMonth(),o=e.getDate(),u=t.getFullYear(),s=t.getMonth(),c=t.getDate();switch(r){case"Y":n=Math.floor(It(e,t));break;case"D":n=bt(t,e);break;case"M":n=s-i+12*(u-a),c<o&&n--;break;case"MD":o<=c?n=c-o:(0===s?(e.setFullYear(u-1),e.setMonth(12)):(e.setFullYear(u),e.setMonth(s-1)),n=bt(t,e));break;case"YM":n=s-i+12*(u-a),c<o&&n--,n%=12;break;case"YD":s>i||s===i&&c<o?e.setFullYear(u):e.setFullYear(u-1),n=bt(t,e)}return n}function _t(e){var t=new Date(e);return t.setHours(0,0,0,0),t}function bt(e,t){return e=H(e),t=H(t),e instanceof Error?e:t instanceof Error?t:(_t(e).getTime()-_t(t).getTime())/864e5}function kt(e,t,r){if(r=G(r||"false"),e=H(e),t=H(t),e instanceof Error)return e;if(t instanceof Error)return t;if(r instanceof Error)return r;var n,a,i=e.getMonth(),o=t.getMonth();if(r)n=31===e.getDate()?30:e.getDate(),a=31===t.getDate()?30:t.getDate();else{var u=new Date(e.getFullYear(),i+1,0).getDate(),s=new Date(t.getFullYear(),o+1,0).getDate();n=e.getDate()===u?30:e.getDate(),t.getDate()===s?n<30?(o++,a=1):a=30:a=t.getDate()}return 360*(t.getFullYear()-e.getFullYear())+30*(o-i)+(a-n)}function wt(e){if((e=H(e))instanceof Error)return e;(e=_t(e)).setDate(e.getDate()+4-(e.getDay()||7));var t=new Date(e.getFullYear(),0,1);return Math.ceil(((e-t)/864e5+1)/7)}function xt(e,t,r){return xt.INTL(e,t,1,r)}xt.INTL=function(e,t,r,a){if((e=H(e))instanceof Error)return e;if((t=H(t))instanceof Error)return t;var i=!1,o=[],u=[1,2,3,4,5,6,0],s=new RegExp("^[0|1]{7}$");if(void 0===r)r=gt[1];else if("string"==typeof r&&s.test(r)){i=!0,r=r.split("");for(var c=0;c<r.length;c++)"1"===r[c]&&o.push(u[c])}else r=gt[r];if(!(r instanceof Array))return n;void 0===a?a=[]:a instanceof Array||(a=[a]);for(var f=0;f<a.length;f++){var l=H(a[f]);if(l instanceof Error)return l;a[f]=l}for(var p=Math.round((t-e)/864e5)+1,d=p,h=e,v=0;v<p;v++){for(var m=(new Date).getTimezoneOffset()>0?h.getUTCDay():h.getDay(),g=i?o.includes(m):m===r[0]||m===r[1],y=0;y<a.length;y++){var _=a[y];if(_.getDate()===h.getDate()&&_.getMonth()===h.getMonth()&&_.getFullYear()===h.getFullYear()){g=!0;break}}g&&d--,h.setDate(h.getDate()+1)}return d};var St=xt.INTL;function Et(e,t,r){return Et.INTL(e,t,1,r)}Et.INTL=function(e,t,r,a){if((e=H(e))instanceof Error)return e;if((t=V(t))instanceof Error)return t;if(!((r=void 0===r?gt[1]:gt[r])instanceof Array))return n;void 0===a?a=[]:a instanceof Array||(a=[a]);for(var i=0;i<a.length;i++){var o=H(a[i]);if(o instanceof Error)return o;a[i]=o}for(var u=0,s=Math.sign(t);u<t*s;){e.setDate(e.getDate()+s);var c=e.getDay();if(c!==r[0]&&c!==r[1]){for(var f=0;f<a.length;f++){var l=a[f];if(l.getDate()===e.getDate()&&l.getMonth()===e.getMonth()&&l.getFullYear()===e.getFullYear()){u--;break}}u++}}return e.getFullYear()<1900?n:v(e)};var Nt=Et.INTL;function At(e){return 1===new Date(e,1,29).getMonth()}function Tt(e,t){return Math.ceil((t-e)/1e3/60/60/24)}function It(e,t,r){if((e=H(e))instanceof Error)return e;if((t=H(t))instanceof Error)return t;r=r||0;var n=e.getDate(),a=e.getMonth()+1,i=e.getFullYear(),o=t.getDate(),u=t.getMonth()+1,s=t.getFullYear();switch(r){case 0:return 31===n&&31===o?(n=30,o=30):31===n?n=30:30===n&&31===o&&(o=30),(o+30*u+360*s-(n+30*a+360*i))/360;case 1:var c=365;if(i===s||i+1===s&&(a>u||a===u&&n>=o))return(i===s&&At(i)||function(e,t){var r=e.getFullYear(),n=new Date(r,2,1);if(At(r)&&e<n&&t>=n)return!0;var a=t.getFullYear(),i=new Date(a,2,1);return At(a)&&t>=i&&e<i}(e,t)||1===u&&29===o)&&(c=366),Tt(e,t)/c;var f=s-i+1,l=(new Date(s+1,0,1)-new Date(i,0,1))/1e3/60/60/24/f;return Tt(e,t)/l;case 2:return Tt(e,t)/360;case 3:return Tt(e,t)/365;case 4:return(o+30*u+360*s-(n+30*a+360*i))/360}}var Mt,Ct={};var Ot=(Mt||(Mt=1,function(e){var t;t=function(e){e.version="1.0.2";var t=Math;function r(e,t){for(var r=0,n=0;r<e.length;++r)n=t*n+e[r];return n}function n(e,t,r,n,a){if(0===t)return r;if(1===t)return n;for(var i=2/e,o=n,u=1;u<t;++u)o=n*u*i+a*r,r=n,n=o;return o}function a(e,t,r,a,i){return function(r,o){if(a){if(0===r)return 1==a?-1/0:1/0;if(r<0)return NaN}return 0===o?e(r):1===o?t(r):o<0?NaN:n(r,o|=0,e(r),t(r),i)}}var i,o,u,s,c,f,l,p,d,h,v,m,g,y=function(){var e=.636619772,a=[57568490574,-13362590354,651619640.7,-11214424.18,77392.33017,-184.9052456].reverse(),i=[57568490411,1029532985,9494680.718,59272.64853,267.8532712,1].reverse(),o=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),u=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34935152e-8].reverse();function s(n){var s=0,c=0,f=0,l=n*n;if(n<8)s=(c=r(a,l))/(f=r(i,l));else{var p=n-.785398164;c=r(o,l=64/l),f=r(u,l),s=t.sqrt(e/n)*(t.cos(p)*c-t.sin(p)*f*8/n)}return s}var c=[72362614232,-7895059235,242396853.1,-2972611.439,15704.4826,-30.16036606].reverse(),f=[144725228442,2300535178,18583304.74,99447.43394,376.9991397,1].reverse(),l=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),p=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();function d(n){var a=0,i=0,o=0,u=n*n,s=t.abs(n)-2.356194491;return Math.abs(n)<8?a=(i=n*r(c,u))/(o=r(f,u)):(i=r(l,u=64/u),o=r(p,u),a=t.sqrt(e/t.abs(n))*(t.cos(s)*i-t.sin(s)*o*8/t.abs(n)),n<0&&(a=-a)),a}return function e(r,a){if(a=Math.round(a),!isFinite(r))return isNaN(r)?r:0;if(a<0)return(a%2?-1:1)*e(r,-a);if(r<0)return(a%2?-1:1)*e(-r,a);if(0===a)return s(r);if(1===a)return d(r);if(0===r)return 0;var i=0;if(r>a)i=n(r,a,s(r),d(r),-1);else{for(var o=!1,u=0,c=0,f=1,l=0,p=2/r,h=2*t.floor((a+t.floor(t.sqrt(40*a)))/2);h>0;h--)l=h*p*f-u,u=f,f=l,t.abs(f)>1e10&&(f*=1e-10,u*=1e-10,i*=1e-10,c*=1e-10),o&&(c+=f),o=!o,h==a&&(i=u);i/=c=2*c-f}return i}}(),_=(i=.636619772,o=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),u=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),s=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),c=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse(),f=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),l=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),p=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),d=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse(),a((function(e){var n=0,a=0,f=0,l=e*e,p=e-.785398164;return e<8?n=(a=r(o,l))/(f=r(u,l))+i*y(e,0)*t.log(e):(a=r(s,l=64/l),f=r(c,l),n=t.sqrt(i/e)*(t.sin(p)*a+t.cos(p)*f*8/e)),n}),(function(e){var n=0,a=0,o=0,u=e*e,s=e-2.356194491;return e<8?n=(a=e*r(f,u))/(o=r(l,u))+i*(y(e,1)*t.log(e)-1/e):(a=r(p,u=64/u),o=r(d,u),n=t.sqrt(i/e)*(t.sin(s)*a+t.cos(s)*o*8/e)),n}),0,1,-1)),b=(h=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),v=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse(),m=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),g=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse(),function e(n,a){if(0===(a=Math.round(a)))return function(e){return e<=3.75?r(h,e*e/14.0625):t.exp(t.abs(e))/t.sqrt(t.abs(e))*r(v,3.75/t.abs(e))}(n);if(1===a)return function(e){return e<3.75?e*r(m,e*e/14.0625):(e<0?-1:1)*t.exp(t.abs(e))/t.sqrt(t.abs(e))*r(g,3.75/t.abs(e))}(n);if(a<0)return NaN;if(0===t.abs(n))return 0;if(n==1/0)return 1/0;var i,o=0,u=2/t.abs(n),s=0,c=1,f=0;for(i=2*t.round((a+t.round(t.sqrt(40*a)))/2);i>0;i--)f=i*u*c+s,s=c,c=f,t.abs(c)>1e10&&(c*=1e-10,s*=1e-10,o*=1e-10),i==a&&(o=s);return o*=e(n,0)/c,n<0&&a%2?-o:o}),k=function(){var e=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),n=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse(),i=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),o=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();return a((function(a){return a<=2?-t.log(a/2)*b(a,0)+r(e,a*a/4):t.exp(-a)/t.sqrt(a)*r(n,2/a)}),(function(e){return e<=2?t.log(e/2)*b(e,1)+1/e*r(i,e*e/4):t.exp(-e)/t.sqrt(e)*r(o,2/e)}),0,2,1)}();e.besselj=y,e.bessely=_,e.besseli=b,e.besselk=k},"undefined"==typeof DO_NOT_EXPORT_BESSEL?t(e):t({})}(Ct)),Ct),Rt=re(Ot);function jt(e){return/^[01]{1,10}$/.test(e)}function Dt(e,t,r){if(F(e=V(e),t=V(t)))return e;if("i"!==(r=void 0===r?"i":r)&&"j"!==r)return n;if(0===e&&0===t)return 0;if(0===e)return 1===t?r:t.toString()+r;if(0===t)return e.toString();var a=t>0?"+":"";return e.toString()+a+(1===t?r:t.toString()+r)}function Pt(e,t){return t=void 0===t?0:t,F(e=V(e),t=V(t))?n:oe.erf(e)}function Lt(e){return isNaN(e)?n:oe.erfc(e)}function Ft(e){var t=Vt(e),r=Ut(e);return F(t,r)?n:Math.sqrt(Math.pow(t,2)+Math.pow(r,2))}function Ut(e){if(void 0===e||!0===e||!1===e)return n;if(0===e||"0"===e)return 0;if(["i","j"].indexOf(e)>=0)return 1;var t=(e=(e+="").replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j")).indexOf("+"),r=e.indexOf("-");0===t&&(t=e.indexOf("+",1)),0===r&&(r=e.indexOf("-",1));var a=e.substring(e.length-1,e.length),i="i"===a||"j"===a;return t>=0||r>=0?i?t>=0?isNaN(e.substring(0,t))||isNaN(e.substring(t+1,e.length-1))?o:Number(e.substring(t+1,e.length-1)):isNaN(e.substring(0,r))||isNaN(e.substring(r+1,e.length-1))?o:-Number(e.substring(r+1,e.length-1)):o:i?isNaN(e.substring(0,e.length-1))?o:e.substring(0,e.length-1):isNaN(e)?o:0}function qt(e){var t=Vt(e),a=Ut(e);return F(t,a)?n:0===t&&0===a?r:0===t&&a>0?Math.PI/2:0===t&&a<0?-Math.PI/2:0===a&&t>0?0:0===a&&t<0?-Math.PI:t>0?Math.atan(a/t):t<0&&a>=0?Math.atan(a/t)+Math.PI:Math.atan(a/t)-Math.PI}function Gt(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.cos(t)*(Math.exp(r)+Math.exp(-r))/2,-Math.sin(t)*(Math.exp(r)-Math.exp(-r))/2,a)}function Ht(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.cos(r)*(Math.exp(t)+Math.exp(-t))/2,Math.sin(r)*(Math.exp(t)-Math.exp(-t))/2,a)}function Zt(e,t){var r=Vt(e),a=Ut(e),i=Vt(t),u=Ut(t);if(F(r,a,i,u))return n;var s=e.substring(e.length-1),c=t.substring(t.length-1),f="i";if(("j"===s||"j"===c)&&(f="j"),0===i&&0===u)return o;var l=i*i+u*u;return Dt((r*i+a*u)/l,(a*i-r*u)/l,f)}function Vt(e){if(void 0===e||!0===e||!1===e)return n;if(0===e||"0"===e)return 0;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(e)>=0)return 0;var t=(e+="").indexOf("+"),r=e.indexOf("-");0===t&&(t=e.indexOf("+",1)),0===r&&(r=e.indexOf("-",1));var a=e.substring(e.length-1,e.length),i="i"===a||"j"===a;return t>=0||r>=0?i?t>=0?isNaN(e.substring(0,t))||isNaN(e.substring(t+1,e.length-1))?o:Number(e.substring(0,t)):isNaN(e.substring(0,r))||isNaN(e.substring(r+1,e.length-1))?o:Number(e.substring(0,r)):o:i?isNaN(e.substring(0,e.length-1))?o:0:isNaN(e)?o:e}function Yt(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.sin(t)*(Math.exp(r)+Math.exp(-r))/2,Math.cos(t)*(Math.exp(r)-Math.exp(-r))/2,a)}function Bt(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.cos(r)*(Math.exp(t)-Math.exp(-t))/2,Math.sin(r)*(Math.exp(t)+Math.exp(-t))/2,a)}var Kt=ke.DIST,zt=ke.INV,Xt=we.DIST,Wt=at.MATH,$t=at.PRECISE,Qt=xe.DIST,Jt=xe.DIST.RT,er=xe.INV,tr=xe.INV.RT,rr=xe.TEST,nr=Te.P,ar=Te.P,ir=Te.S,or=we.INV,ur=Lt.PRECISE,sr=Pt.PRECISE,cr=Ie.DIST,fr=Me.DIST,lr=Me.DIST.RT,pr=Me.INV,dr=Me.INV.RT,hr=st.MATH,vr=st.PRECISE,mr=Me.TEST,gr=Oe.DIST,yr=Oe.INV,_r=Re.PRECISE,br=je.DIST,kr=Le.INV,wr=Le.DIST,xr=Le.INV,Sr=Ge.MULT,Er=Ge.SNGL,Nr=He.DIST,Ar=xt.INTL,Tr=Ze.DIST,Ir=Ze.INV,Mr=Ze.S.DIST,Cr=Ze.S.INV,Or=Ye.EXC,Rr=Ye.INC,jr=Be.EXC,Dr=Be.INC,Pr=Ke.DIST,Lr=ze.EXC,Fr=ze.INC,Ur=Xe.AVG,qr=Xe.EQ,Gr=We.P,Hr=Qe.P,Zr=Qe.S,Vr=me.DIST,Yr=me.DIST.RT,Br=me.INV,Kr=me.TEST,zr=Je.P,Xr=Je.S,Wr=rt.DIST,$r=Et.INTL,Qr=nt.TEST;function Jr(e){var t=[];return T(e,(function(e){e&&t.push(e)})),t}function en(e,t){for(var r={},n=1;n<e[0].length;++n)r[n]=!0;for(var a=t[0].length,i=1;i<t.length;++i)t[i].length>a&&(a=t[i].length);for(var o=1;o<e.length;++o)for(var u=1;u<e[o].length;++u){for(var s=!1,c=!1,f=0;f<t.length;++f){var l=t[f];if(!(l.length<a)){var p=l[0];if(e[o][0]===p){c=!0;for(var d=1;d<l.length;++d){if(!s)if(void 0===l[d]||"*"===l[d])s=!0;else{var h=E(l[d]+""),v=[x(e[o][u],w)].concat(h);s=N(v)}}}}}c&&(r[u]=r[u]&&s)}for(var m=[],g=0;g<e[0].length;++g)r[g]&&m.push(g-1);return m}function tn(e){return e&&e.getTime&&!isNaN(e.getTime())}function rn(e){return e instanceof Date?e:new Date(e)}function nn(e){return e=V(e),-1===[1,2,4].indexOf(e)?o:e}function an(e){return e=V(e),-1===[0,1,2,3,4].indexOf(e)?o:e}function on(e,t,r,a,i){if(a=a||0,i=i||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;var o;if(0===e)o=a+r*t;else{var u=Math.pow(1+e,t);o=1===i?a*u+r*(1+e)*(u-1)/e:a*u+r*(u-1)/e}return-o}function un(e,t,r,a,i,o){if(i=i||0,o=o||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i),o=V(o)))return n;var u=cn(e,r,a,i,o);return(1===t?1===o?0:-a:1===o?on(e,t-2,u,a,1)-u:on(e,t-1,u,a,0))*e}function sn(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=e[0],r=0,n=1;n<e.length;n++)r+=e[n]/Math.pow(1+t,n);return r}function cn(e,t,r,a,i){if(a=a||0,i=i||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;var o;if(0===e)o=(r+a)/t;else{var u=Math.pow(1+e,t);o=1===i?(a*e/(u-1)+r*e/(1-1/u))/(1+e):a*e/(u-1)+r*e/(1-1/u)}return-o}var fn,ln,pn={ethereum:1,gnosis:100,base:8453},dn={ethereum:"https://eth.blockscout.com",gnosis:"https://gnosis.blockscout.com",arbitrum:"https://arbitrum.blockscout.com",optimism:"https://optimism.blockscout.com",soneium:"https://soneium.blockscout.com",unichain:"https://unichain.blockscout.com"},hn={ethereum:"eth",gnosis:"gno"},vn="INVALID_API_KEY",mn="RATE_LIMIT",gn="DEFAULT",yn="MISSING_KEY",_n="INVALID_PARAM",bn="NETWORK_ERROR",kn="ENS",wn="ALCHEMY_API_KEY",xn=250,Sn={Etherscan:"Etherscan",Coingecko:"Coingecko",Safe:"Safe",Basescan:"Basescan",Gnosisscan:"Gnosisscan",Firefly:"Firefly",GnosisPay:"GnosisPay",Neynar:"Neynar",Defillama:"Defillama",DuneSim:"DuneSim"},En=function(){function e(t){return _classCallCheck(this,e),_callSuper(this,e,[t])}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Nn=function(){function e(t){return _classCallCheck(this,e),_callSuper(this,e,["API key for ".concat(t," is missing")])}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),An=function(){function e(t){var r;return _classCallCheck(this,e),(r=_callSuper(this,e,["You have reached the rate limit for ".concat(t)])).api=t,r}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Tn=function(){function e(t,r){var n;return _classCallCheck(this,e),(n=_callSuper(this,e,[429===r?"You have reached the rate limit for ".concat(t):"".concat(t," API failed with status code: ").concat(r)])).status=r,n.api=t,n}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),In=function(){function e(t){return _classCallCheck(this,e),_callSuper(this,e,["".concat(t," is not a supported ens name")])}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Mn=function(){function e(t){var r;return _classCallCheck(this,e),(r=_callSuper(this,e,["Api key is invalid for ".concat(t)])).api=t,r}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Cn=function(e,t){switch(!0){case e instanceof En:return{message:e.message,functionName:t,type:_n};case e instanceof Nn:return{message:e.message,functionName:t,type:yn};case e instanceof An:return{message:e.message,functionName:t,type:mn,apiKeyName:e.api};case e instanceof Tn:return 429===e.status?{message:e.message,functionName:t,type:mn,apiKeyName:e.api}:{message:e.message,functionName:t,type:bn,apiKeyName:e.api};case e instanceof In:return{message:e.message,functionName:t,type:kn};case e instanceof Mn:return{message:e.message,functionName:t,type:vn,apiKeyName:e.api};default:return{message:"An unexpected error occured",functionName:t,type:gn,reason:e.message||e}}};function On(e,t){var r=e.safeParse(t);if(!r.success){var n=r.error.issues[0];throw new En(n.message)}return r.data}!function(e){e.assertEqual=function(e){},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=function(e){var t,r={},n=_createForOfIteratorHelper(e);try{for(n.s();!(t=n.n()).done;){var a=t.value;r[a]=a}}catch(e){n.e(e)}finally{n.f()}return r},e.getValidEnumValues=function(t){var r,n=e.objectKeys(t).filter((function(e){return"number"!=typeof t[t[e]]})),a={},i=_createForOfIteratorHelper(n);try{for(i.s();!(r=i.n()).done;){var o=r.value;a[o]=t[o]}}catch(e){i.e(e)}finally{i.f()}return e.objectValues(a)},e.objectValues=function(t){return e.objectKeys(t).map((function(e){return t[e]}))},e.objectKeys="function"==typeof Object.keys?function(e){return Object.keys(e)}:function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=function(e,t){var r,n=_createForOfIteratorHelper(e);try{for(n.s();!(r=n.n()).done;){var a=r.value;if(t(a))return a}}catch(e){n.e(e)}finally{n.f()}},e.isInteger="function"==typeof Number.isInteger?function(e){return Number.isInteger(e)}:function(e){return"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e},e.joinValues=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" | ";return e.map((function(e){return"string"==typeof e?"'".concat(e,"'"):e})).join(t)},e.jsonStringifyReplacer=function(e,t){return"bigint"==typeof t?t.toString():t}}(fn||(fn={})),function(e){e.mergeShapes=function(e,t){return _objectSpread(_objectSpread({},e),t)}}(ln||(ln={}));var Rn=fn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jn=function(e){switch(_typeof(e)){case"undefined":return Rn.undefined;case"string":return Rn.string;case"number":return Number.isNaN(e)?Rn.nan:Rn.number;case"boolean":return Rn.boolean;case"function":return Rn.function;case"bigint":return Rn.bigint;case"symbol":return Rn.symbol;case"object":return Array.isArray(e)?Rn.array:null===e?Rn.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Rn.promise:"undefined"!=typeof Map&&e instanceof Map?Rn.map:"undefined"!=typeof Set&&e instanceof Set?Rn.set:"undefined"!=typeof Date&&e instanceof Date?Rn.date:Rn.object;default:return Rn.unknown}},Dn=fn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Pn=function(){function e(t){var r;_classCallCheck(this,e),(r=_callSuper(this,e)).issues=[],r.addIssue=function(e){r.issues=[].concat(_toConsumableArray(r.issues),[e])},r.addIssues=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r.issues=[].concat(_toConsumableArray(r.issues),_toConsumableArray(e))};var n=(this instanceof e?this.constructor:void 0).prototype;return Object.setPrototypeOf?Object.setPrototypeOf(r,n):r.__proto__=n,r.name="ZodError",r.issues=t,r}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e,[{key:"errors",get:function(){return this.issues}},{key:"format",value:function(e){var t=e||function(e){return e.message},r={_errors:[]},n=function(e){var a,i=_createForOfIteratorHelper(e.issues);try{for(i.s();!(a=i.n()).done;){var o=a.value;if("invalid_union"===o.code)o.unionErrors.map(n);else if("invalid_return_type"===o.code)n(o.returnTypeError);else if("invalid_arguments"===o.code)n(o.argumentsError);else if(0===o.path.length)r._errors.push(t(o));else for(var u=r,s=0;s<o.path.length;){var c=o.path[s];s===o.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(t(o))):u[c]=u[c]||{_errors:[]},u=u[c],s++}}}catch(e){i.e(e)}finally{i.f()}};return n(this),r}},{key:"toString",value:function(){return this.message}},{key:"message",get:function(){return JSON.stringify(this.issues,fn.jsonStringifyReplacer,2)}},{key:"isEmpty",get:function(){return 0===this.issues.length}},{key:"flatten",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e.message},r={},n=[],a=_createForOfIteratorHelper(this.issues);try{for(a.s();!(e=a.n()).done;){var i=e.value;if(i.path.length>0){var o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i))}}catch(e){a.e(e)}finally{a.f()}return{formErrors:n,fieldErrors:r}}},{key:"formErrors",get:function(){return this.flatten()}}],[{key:"assert",value:function(t){if(!(t instanceof e))throw new Error("Not a ZodError: ".concat(t))}}])}();Pn.create=function(e){return new Pn(e)};var Ln=function(e,t){var r;switch(e.code){case Dn.invalid_type:r=e.received===Rn.undefined?"Required":"Expected ".concat(e.expected,", received ").concat(e.received);break;case Dn.invalid_literal:r="Invalid literal value, expected ".concat(JSON.stringify(e.expected,fn.jsonStringifyReplacer));break;case Dn.unrecognized_keys:r="Unrecognized key(s) in object: ".concat(fn.joinValues(e.keys,", "));break;case Dn.invalid_union:r="Invalid input";break;case Dn.invalid_union_discriminator:r="Invalid discriminator value. Expected ".concat(fn.joinValues(e.options));break;case Dn.invalid_enum_value:r="Invalid enum value. Expected ".concat(fn.joinValues(e.options),", received '").concat(e.received,"'");break;case Dn.invalid_arguments:r="Invalid function arguments";break;case Dn.invalid_return_type:r="Invalid function return type";break;case Dn.invalid_date:r="Invalid date";break;case Dn.invalid_string:"object"===_typeof(e.validation)?"includes"in e.validation?(r='Invalid input: must include "'.concat(e.validation.includes,'"'),"number"==typeof e.validation.position&&(r="".concat(r," at one or more positions greater than or equal to ").concat(e.validation.position))):"startsWith"in e.validation?r='Invalid input: must start with "'.concat(e.validation.startsWith,'"'):"endsWith"in e.validation?r='Invalid input: must end with "'.concat(e.validation.endsWith,'"'):fn.assertNever(e.validation):r="regex"!==e.validation?"Invalid ".concat(e.validation):"Invalid";break;case Dn.too_small:r="array"===e.type?"Array must contain ".concat(e.exact?"exactly":e.inclusive?"at least":"more than"," ").concat(e.minimum," element(s)"):"string"===e.type?"String must contain ".concat(e.exact?"exactly":e.inclusive?"at least":"over"," ").concat(e.minimum," character(s)"):"number"===e.type||"bigint"===e.type?"Number must be ".concat(e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than ").concat(e.minimum):"date"===e.type?"Date must be ".concat(e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than ").concat(new Date(Number(e.minimum))):"Invalid input";break;case Dn.too_big:r="array"===e.type?"Array must contain ".concat(e.exact?"exactly":e.inclusive?"at most":"less than"," ").concat(e.maximum," element(s)"):"string"===e.type?"String must contain ".concat(e.exact?"exactly":e.inclusive?"at most":"under"," ").concat(e.maximum," character(s)"):"number"===e.type?"Number must be ".concat(e.exact?"exactly":e.inclusive?"less than or equal to":"less than"," ").concat(e.maximum):"bigint"===e.type?"BigInt must be ".concat(e.exact?"exactly":e.inclusive?"less than or equal to":"less than"," ").concat(e.maximum):"date"===e.type?"Date must be ".concat(e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"," ").concat(new Date(Number(e.maximum))):"Invalid input";break;case Dn.custom:r="Invalid input";break;case Dn.invalid_intersection_types:r="Intersection results could not be merged";break;case Dn.not_multiple_of:r="Number must be a multiple of ".concat(e.multipleOf);break;case Dn.not_finite:r="Number must be finite";break;default:r=t.defaultError,fn.assertNever(e)}return{message:r}},Fn=Ln;function Un(e,t){var r=Fn,n=function(e){var t=e.data,r=e.path,n=e.errorMaps,a=e.issueData,i=[].concat(_toConsumableArray(r),_toConsumableArray(a.path||[])),o=_objectSpread(_objectSpread({},a),{},{path:i});if(void 0!==a.message)return _objectSpread(_objectSpread({},a),{},{path:i,message:a.message});var u,s="",c=_createForOfIteratorHelper(n.filter((function(e){return!!e})).slice().reverse());try{for(c.s();!(u=c.n()).done;)s=(0,u.value)(o,{data:t,defaultError:s}).message}catch(e){c.e(e)}finally{c.f()}return _objectSpread(_objectSpread({},a),{},{path:i,message:s})}({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ln?void 0:Ln].filter((function(e){return!!e}))});e.common.issues.push(n)}var qn,Gn=function(){function e(){_classCallCheck(this,e),this.value="valid"}return _createClass(e,[{key:"dirty",value:function(){"valid"===this.value&&(this.value="dirty")}},{key:"abort",value:function(){"aborted"!==this.value&&(this.value="aborted")}}],[{key:"mergeArray",value:function(e,t){var r,n=[],a=_createForOfIteratorHelper(t);try{for(a.s();!(r=a.n()).done;){var i=r.value;if("aborted"===i.status)return Hn;"dirty"===i.status&&e.dirty(),n.push(i.value)}}catch(e){a.e(e)}finally{a.f()}return{status:e.value,value:n}}},{key:"mergeObjectAsync",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function t(r,n){var a,i,o,u,s,c;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],i=_createForOfIteratorHelper(n),t.prev=2,i.s();case 4:if((o=i.n()).done){t.next=15;break}return u=o.value,t.next=8,u.key;case 8:return s=t.sent,t.next=11,u.value;case 11:c=t.sent,a.push({key:s,value:c});case 13:t.next=4;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(2),i.e(t.t0);case 20:return t.prev=20,i.f(),t.finish(20);case 23:return t.abrupt("return",e.mergeObjectSync(r,a));case 24:case"end":return t.stop()}}),t,null,[[2,17,20,23]])}))),function(e,r){return t.apply(this,arguments)})},{key:"mergeObjectSync",value:function(e,t){var r,n={},a=_createForOfIteratorHelper(t);try{for(a.s();!(r=a.n()).done;){var i=r.value,o=i.key,u=i.value;if("aborted"===o.status)return Hn;if("aborted"===u.status)return Hn;"dirty"===o.status&&e.dirty(),"dirty"===u.status&&e.dirty(),"__proto__"===o.value||void 0===u.value&&!i.alwaysSet||(n[o.value]=u.value)}}catch(e){a.e(e)}finally{a.f()}return{status:e.value,value:n}}}]);var t}(),Hn=Object.freeze({status:"aborted"}),Zn=function(e){return{status:"dirty",value:e}},Vn=function(e){return{status:"valid",value:e}},Yn=function(e){return"aborted"===e.status},Bn=function(e){return"dirty"===e.status},Kn=function(e){return"valid"===e.status},zn=function(e){return"undefined"!=typeof Promise&&e instanceof Promise};!function(e){e.errToObj=function(e){return"string"==typeof e?{message:e}:e||{}},e.toString=function(e){return"string"==typeof e?e:null==e?void 0:e.message}}(qn||(qn={}));var Xn=function(){return _createClass((function e(t,r,n,a){_classCallCheck(this,e),this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=a}),[{key:"path",get:function(){var e,t;this._cachedPath.length||(Array.isArray(this._key)?(e=this._cachedPath).push.apply(e,_toConsumableArray(this._path).concat(_toConsumableArray(this._key))):(t=this._cachedPath).push.apply(t,_toConsumableArray(this._path).concat([this._key])));return this._cachedPath}}])}(),Wn=function(e,t){if(Kn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;var t=new Pn(e.common.issues);return this._error=t,this._error}}};function $n(e){if(!e)return{};var t=e.errorMap,r=e.invalid_type_error,n=e.required_error,a=e.description;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:a};return{errorMap:function(t,a){var i,o,u=e.message;return"invalid_enum_value"===t.code?{message:null!=u?u:a.defaultError}:void 0===a.data?{message:null!==(o=null!=u?u:n)&&void 0!==o?o:a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:null!==(i=null!=u?u:r)&&void 0!==i?i:a.defaultError}},description:a}}var Qn,Jn=function(){return _createClass((function e(t){var r=this;_classCallCheck(this,e),this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:function(e){return r["~validate"](e)}}}),[{key:"description",get:function(){return this._def.description}},{key:"_getType",value:function(e){return jn(e.data)}},{key:"_getOrReturnCtx",value:function(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}},{key:"_processInputParams",value:function(e){return{status:new Gn,ctx:{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}},{key:"_parseSync",value:function(e){var t=this._parse(e);if(zn(t))throw new Error("Synchronous parse encountered promise.");return t}},{key:"_parseAsync",value:function(e){var t=this._parse(e);return Promise.resolve(t)}},{key:"parse",value:function(e,t){var r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}},{key:"safeParse",value:function(e,t){var r,n={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Wn(n,a)}},{key:"~validate",value:function(e){var t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)};if(!this["~standard"].async)try{var r=this._parseSync({data:e,path:[],parent:t});return Kn(r)?{value:r.value}:{issues:t.common.issues}}catch(e){var n;null!=e&&null!==(n=e.message)&&void 0!==n&&null!==(n=n.toLowerCase())&&void 0!==n&&n.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((function(e){return Kn(e)?{value:e.value}:{issues:t.common.issues}}))}},{key:"parseAsync",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.safeParseAsync(t,r);case 2:if(!(n=e.sent).success){e.next=5;break}return e.abrupt("return",n.data);case 5:throw n.error;case 6:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"safeParseAsync",value:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,a,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={common:{issues:[],contextualErrorMap:null==r?void 0:r.errorMap,async:!0},path:(null==r?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jn(t)},a=this._parse({data:t,path:n.path,parent:n}),e.next=4,zn(a)?a:Promise.resolve(a);case 4:return i=e.sent,e.abrupt("return",Wn(n,i));case 6:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})},{key:"refine",value:function(e,t){return this._refinement((function(r,n){var a=e(r),i=function(){return n.addIssue(_objectSpread({code:Dn.custom},function(e){return"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t}(r)))};return"undefined"!=typeof Promise&&a instanceof Promise?a.then((function(e){return!!e||(i(),!1)})):!!a||(i(),!1)}))}},{key:"refinement",value:function(e,t){return this._refinement((function(r,n){return!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1)}))}},{key:"_refinement",value:function(e){return new Xa({schema:this,typeName:ti.ZodEffects,effect:{type:"refinement",refinement:e}})}},{key:"superRefine",value:function(e){return this._refinement(e)}},{key:"optional",value:function(){return Wa.create(this,this._def)}},{key:"nullable",value:function(){return $a.create(this,this._def)}},{key:"nullish",value:function(){return this.nullable().optional()}},{key:"array",value:function(){return Oa.create(this)}},{key:"promise",value:function(){return za.create(this,this._def)}},{key:"or",value:function(e){return Da.create([this,e],this._def)}},{key:"and",value:function(e){return Ua.create(this,e,this._def)}},{key:"transform",value:function(e){return new Xa(_objectSpread(_objectSpread({},$n(this._def)),{},{schema:this,typeName:ti.ZodEffects,effect:{type:"transform",transform:e}}))}},{key:"default",value:function(e){var t="function"==typeof e?e:function(){return e};return new Qa(_objectSpread(_objectSpread({},$n(this._def)),{},{innerType:this,defaultValue:t,typeName:ti.ZodDefault}))}},{key:"brand",value:function(){return new ri(_objectSpread({typeName:ti.ZodBranded,type:this},$n(this._def)))}},{key:"catch",value:function(e){var t="function"==typeof e?e:function(){return e};return new Ja(_objectSpread(_objectSpread({},$n(this._def)),{},{innerType:this,catchValue:t,typeName:ti.ZodCatch}))}},{key:"describe",value:function(e){return new(0,this.constructor)(_objectSpread(_objectSpread({},this._def),{},{description:e}))}},{key:"pipe",value:function(e){return ni.create(this,e)}},{key:"readonly",value:function(){return ai.create(this)}},{key:"isOptional",value:function(){return this.safeParse(void 0).success}},{key:"isNullable",value:function(){return this.safeParse(null).success}}]);var e,t}(),ea=/^c[^\s-]{8,}$/i,ta=/^[0-9a-z]+$/,ra=/^[0-9A-HJKMNP-TV-Z]{26}$/i,na=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,aa=/^[a-z0-9_-]{21}$/i,ia=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oa=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ua=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ca=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,fa=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,la=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pa=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,da=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ha="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",va=new RegExp("^".concat(ha,"$"));function ma(e){var t="[0-5]\\d";e.precision?t="".concat(t,"\\.\\d{").concat(e.precision,"}"):null==e.precision&&(t="".concat(t,"(\\.\\d+)?"));var r=e.precision?"+":"?";return"([01]\\d|2[0-3]):[0-5]\\d(:".concat(t,")").concat(r)}function ga(e){var t="".concat(ha,"T").concat(ma(e)),r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t="".concat(t,"(").concat(r.join("|"),")"),new RegExp("^".concat(t,"$"))}function ya(e,t){if(!ia.test(e))return!1;try{var r=_slicedToArray(e.split("."),1)[0];if(!r)return!1;var n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return"object"===_typeof(a)&&null!==a&&((!("typ"in a)||"JWT"===(null==a?void 0:a.typ))&&(!!a.alg&&(!t||a.alg===t)))}catch(e){return!1}}function _a(e,t){return!("v4"!==t&&t||!ca.test(e))||!("v6"!==t&&t||!la.test(e))}var ba=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Rn.string){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.string,received:t.parsedType}),Hn}var r,n,a,i=new Gn,o=void 0,u=_createForOfIteratorHelper(this._def.checks);try{for(u.s();!(r=u.n()).done;){var s=r.value;if("min"===s.kind)e.data.length<s.value&&(Un(o=this._getOrReturnCtx(e,o),{code:Dn.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if("max"===s.kind)e.data.length>s.value&&(Un(o=this._getOrReturnCtx(e,o),{code:Dn.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if("length"===s.kind){var c=e.data.length>s.value,f=e.data.length<s.value;(c||f)&&(o=this._getOrReturnCtx(e,o),c?Un(o,{code:Dn.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):f&&Un(o,{code:Dn.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),i.dirty())}else if("email"===s.kind)ua.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"email",code:Dn.invalid_string,message:s.message}),i.dirty());else if("emoji"===s.kind)Qn||(Qn=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Qn.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:Dn.invalid_string,message:s.message}),i.dirty());else if("uuid"===s.kind)na.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("nanoid"===s.kind)aa.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("cuid"===s.kind)ea.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("cuid2"===s.kind)ta.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:Dn.invalid_string,message:s.message}),i.dirty());else if("ulid"===s.kind)ra.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("url"===s.kind)try{new URL(e.data)}catch(t){Un(o=this._getOrReturnCtx(e,o),{validation:"url",code:Dn.invalid_string,message:s.message}),i.dirty()}else if("regex"===s.kind){s.regex.lastIndex=0,s.regex.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"regex",code:Dn.invalid_string,message:s.message}),i.dirty())}else if("trim"===s.kind)e.data=e.data.trim();else if("includes"===s.kind)e.data.includes(s.value,s.position)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),i.dirty());else if("toLowerCase"===s.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===s.kind)e.data=e.data.toUpperCase();else if("startsWith"===s.kind)e.data.startsWith(s.value)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:{startsWith:s.value},message:s.message}),i.dirty());else if("endsWith"===s.kind)e.data.endsWith(s.value)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:{endsWith:s.value},message:s.message}),i.dirty());else if("datetime"===s.kind){ga(s).test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:"datetime",message:s.message}),i.dirty())}else if("date"===s.kind){va.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:"date",message:s.message}),i.dirty())}else if("time"===s.kind){new RegExp("^".concat(ma(s),"$")).test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:"time",message:s.message}),i.dirty())}else"duration"===s.kind?oa.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"duration",code:Dn.invalid_string,message:s.message}),i.dirty()):"ip"===s.kind?(n=e.data,("v4"!==(a=s.version)&&a||!sa.test(n))&&("v6"!==a&&a||!fa.test(n))&&(Un(o=this._getOrReturnCtx(e,o),{validation:"ip",code:Dn.invalid_string,message:s.message}),i.dirty())):"jwt"===s.kind?ya(e.data,s.alg)||(Un(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:Dn.invalid_string,message:s.message}),i.dirty()):"cidr"===s.kind?_a(e.data,s.version)||(Un(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:Dn.invalid_string,message:s.message}),i.dirty()):"base64"===s.kind?pa.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"base64",code:Dn.invalid_string,message:s.message}),i.dirty()):"base64url"===s.kind?da.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:Dn.invalid_string,message:s.message}),i.dirty()):fn.assertNever(s)}}catch(e){u.e(e)}finally{u.f()}return{status:i.value,value:e.data}}},{key:"_regex",value:function(e,t,r){return this.refinement((function(t){return e.test(t)}),_objectSpread({validation:t,code:Dn.invalid_string},qn.errToObj(r)))}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"email",value:function(e){return this._addCheck(_objectSpread({kind:"email"},qn.errToObj(e)))}},{key:"url",value:function(e){return this._addCheck(_objectSpread({kind:"url"},qn.errToObj(e)))}},{key:"emoji",value:function(e){return this._addCheck(_objectSpread({kind:"emoji"},qn.errToObj(e)))}},{key:"uuid",value:function(e){return this._addCheck(_objectSpread({kind:"uuid"},qn.errToObj(e)))}},{key:"nanoid",value:function(e){return this._addCheck(_objectSpread({kind:"nanoid"},qn.errToObj(e)))}},{key:"cuid",value:function(e){return this._addCheck(_objectSpread({kind:"cuid"},qn.errToObj(e)))}},{key:"cuid2",value:function(e){return this._addCheck(_objectSpread({kind:"cuid2"},qn.errToObj(e)))}},{key:"ulid",value:function(e){return this._addCheck(_objectSpread({kind:"ulid"},qn.errToObj(e)))}},{key:"base64",value:function(e){return this._addCheck(_objectSpread({kind:"base64"},qn.errToObj(e)))}},{key:"base64url",value:function(e){return this._addCheck(_objectSpread({kind:"base64url"},qn.errToObj(e)))}},{key:"jwt",value:function(e){return this._addCheck(_objectSpread({kind:"jwt"},qn.errToObj(e)))}},{key:"ip",value:function(e){return this._addCheck(_objectSpread({kind:"ip"},qn.errToObj(e)))}},{key:"cidr",value:function(e){return this._addCheck(_objectSpread({kind:"cidr"},qn.errToObj(e)))}},{key:"datetime",value:function(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(_objectSpread({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r},qn.errToObj(null==e?void 0:e.message)))}},{key:"date",value:function(e){return this._addCheck({kind:"date",message:e})}},{key:"time",value:function(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(_objectSpread({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision},qn.errToObj(null==e?void 0:e.message)))}},{key:"duration",value:function(e){return this._addCheck(_objectSpread({kind:"duration"},qn.errToObj(e)))}},{key:"regex",value:function(e,t){return this._addCheck(_objectSpread({kind:"regex",regex:e},qn.errToObj(t)))}},{key:"includes",value:function(e,t){return this._addCheck(_objectSpread({kind:"includes",value:e,position:null==t?void 0:t.position},qn.errToObj(null==t?void 0:t.message)))}},{key:"startsWith",value:function(e,t){return this._addCheck(_objectSpread({kind:"startsWith",value:e},qn.errToObj(t)))}},{key:"endsWith",value:function(e,t){return this._addCheck(_objectSpread({kind:"endsWith",value:e},qn.errToObj(t)))}},{key:"min",value:function(e,t){return this._addCheck(_objectSpread({kind:"min",value:e},qn.errToObj(t)))}},{key:"max",value:function(e,t){return this._addCheck(_objectSpread({kind:"max",value:e},qn.errToObj(t)))}},{key:"length",value:function(e,t){return this._addCheck(_objectSpread({kind:"length",value:e},qn.errToObj(t)))}},{key:"nonempty",value:function(e){return this.min(1,qn.errToObj(e))}},{key:"trim",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:"trim"}])}))}},{key:"toLowerCase",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:"toLowerCase"}])}))}},{key:"toUpperCase",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:"toUpperCase"}])}))}},{key:"isDatetime",get:function(){return!!this._def.checks.find((function(e){return"datetime"===e.kind}))}},{key:"isDate",get:function(){return!!this._def.checks.find((function(e){return"date"===e.kind}))}},{key:"isTime",get:function(){return!!this._def.checks.find((function(e){return"time"===e.kind}))}},{key:"isDuration",get:function(){return!!this._def.checks.find((function(e){return"duration"===e.kind}))}},{key:"isEmail",get:function(){return!!this._def.checks.find((function(e){return"email"===e.kind}))}},{key:"isURL",get:function(){return!!this._def.checks.find((function(e){return"url"===e.kind}))}},{key:"isEmoji",get:function(){return!!this._def.checks.find((function(e){return"emoji"===e.kind}))}},{key:"isUUID",get:function(){return!!this._def.checks.find((function(e){return"uuid"===e.kind}))}},{key:"isNANOID",get:function(){return!!this._def.checks.find((function(e){return"nanoid"===e.kind}))}},{key:"isCUID",get:function(){return!!this._def.checks.find((function(e){return"cuid"===e.kind}))}},{key:"isCUID2",get:function(){return!!this._def.checks.find((function(e){return"cuid2"===e.kind}))}},{key:"isULID",get:function(){return!!this._def.checks.find((function(e){return"ulid"===e.kind}))}},{key:"isIP",get:function(){return!!this._def.checks.find((function(e){return"ip"===e.kind}))}},{key:"isCIDR",get:function(){return!!this._def.checks.find((function(e){return"cidr"===e.kind}))}},{key:"isBase64",get:function(){return!!this._def.checks.find((function(e){return"base64"===e.kind}))}},{key:"isBase64url",get:function(){return!!this._def.checks.find((function(e){return"base64url"===e.kind}))}},{key:"minLength",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"maxLength",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}}])}(Jn);ba.create=function(e){var t;return new ba(_objectSpread({checks:[],typeName:ti.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t},$n(e)))};var ka=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments)).min=e.gte,e.max=e.lte,e.step=e.multipleOf,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Rn.number){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.number,received:t.parsedType}),Hn}var r,n,a,i,o,u,s=void 0,c=new Gn,f=_createForOfIteratorHelper(this._def.checks);try{for(f.s();!(r=f.n()).done;){var l=r.value;if("int"===l.kind)fn.isInteger(e.data)||(Un(s=this._getOrReturnCtx(e,s),{code:Dn.invalid_type,expected:"integer",received:"float",message:l.message}),c.dirty());else if("min"===l.kind){(l.inclusive?e.data<l.value:e.data<=l.value)&&(Un(s=this._getOrReturnCtx(e,s),{code:Dn.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),c.dirty())}else if("max"===l.kind){(l.inclusive?e.data>l.value:e.data>=l.value)&&(Un(s=this._getOrReturnCtx(e,s),{code:Dn.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),c.dirty())}else"multipleOf"===l.kind?0!=(n=e.data,a=l.value,i=void 0,o=void 0,u=void 0,i=(n.toString().split(".")[1]||"").length,o=(a.toString().split(".")[1]||"").length,u=i>o?i:o,Number.parseInt(n.toFixed(u).replace(".",""))%Number.parseInt(a.toFixed(u).replace(".",""))/Math.pow(10,u))&&(Un(s=this._getOrReturnCtx(e,s),{code:Dn.not_multiple_of,multipleOf:l.value,message:l.message}),c.dirty()):"finite"===l.kind?Number.isFinite(e.data)||(Un(s=this._getOrReturnCtx(e,s),{code:Dn.not_finite,message:l.message}),c.dirty()):fn.assertNever(l)}}catch(e){f.e(e)}finally{f.f()}return{status:c.value,value:e.data}}},{key:"gte",value:function(e,t){return this.setLimit("min",e,!0,qn.toString(t))}},{key:"gt",value:function(e,t){return this.setLimit("min",e,!1,qn.toString(t))}},{key:"lte",value:function(e,t){return this.setLimit("max",e,!0,qn.toString(t))}},{key:"lt",value:function(e,t){return this.setLimit("max",e,!1,qn.toString(t))}},{key:"setLimit",value:function(e,r,n,a){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:e,value:r,inclusive:n,message:qn.toString(a)}])}))}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"int",value:function(e){return this._addCheck({kind:"int",message:qn.toString(e)})}},{key:"positive",value:function(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:qn.toString(e)})}},{key:"negative",value:function(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:qn.toString(e)})}},{key:"nonpositive",value:function(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:qn.toString(e)})}},{key:"nonnegative",value:function(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:qn.toString(e)})}},{key:"multipleOf",value:function(e,t){return this._addCheck({kind:"multipleOf",value:e,message:qn.toString(t)})}},{key:"finite",value:function(e){return this._addCheck({kind:"finite",message:qn.toString(e)})}},{key:"safe",value:function(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:qn.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:qn.toString(e)})}},{key:"minValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"maxValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"isInt",get:function(){return!!this._def.checks.find((function(e){return"int"===e.kind||"multipleOf"===e.kind&&fn.isInteger(e.value)}))}},{key:"isFinite",get:function(){var e,t=null,r=null,n=_createForOfIteratorHelper(this._def.checks);try{for(n.s();!(e=n.n()).done;){var a=e.value;if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===r||a.value>r)&&(r=a.value):"max"===a.kind&&(null===t||a.value<t)&&(t=a.value)}}catch(e){n.e(e)}finally{n.f()}return Number.isFinite(r)&&Number.isFinite(t)}}])}(Jn);ka.create=function(e){return new ka(_objectSpread({checks:[],typeName:ti.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1},$n(e)))};var wa=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments)).min=e.gte,e.max=e.lte,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(t){return this._getInvalidInput(e)}if(this._getType(e)!==Rn.bigint)return this._getInvalidInput(e);var t,r=void 0,n=new Gn,a=_createForOfIteratorHelper(this._def.checks);try{for(a.s();!(t=a.n()).done;){var i=t.value;if("min"===i.kind)(i.inclusive?e.data<i.value:e.data<=i.value)&&(Un(r=this._getOrReturnCtx(e,r),{code:Dn.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty());else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(Un(r=this._getOrReturnCtx(e,r),{code:Dn.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(Un(r=this._getOrReturnCtx(e,r),{code:Dn.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):fn.assertNever(i)}}catch(e){a.e(e)}finally{a.f()}return{status:n.value,value:e.data}}},{key:"_getInvalidInput",value:function(e){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.bigint,received:t.parsedType}),Hn}},{key:"gte",value:function(e,t){return this.setLimit("min",e,!0,qn.toString(t))}},{key:"gt",value:function(e,t){return this.setLimit("min",e,!1,qn.toString(t))}},{key:"lte",value:function(e,t){return this.setLimit("max",e,!0,qn.toString(t))}},{key:"lt",value:function(e,t){return this.setLimit("max",e,!1,qn.toString(t))}},{key:"setLimit",value:function(e,r,n,a){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:e,value:r,inclusive:n,message:qn.toString(a)}])}))}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"positive",value:function(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:qn.toString(e)})}},{key:"negative",value:function(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:qn.toString(e)})}},{key:"nonpositive",value:function(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:qn.toString(e)})}},{key:"nonnegative",value:function(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:qn.toString(e)})}},{key:"multipleOf",value:function(e,t){return this._addCheck({kind:"multipleOf",value:e,message:qn.toString(t)})}},{key:"minValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"maxValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}}])}(Jn);wa.create=function(e){var t;return new wa(_objectSpread({checks:[],typeName:ti.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t},$n(e)))};var xa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==Rn.boolean){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.boolean,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);xa.create=function(e){return new xa(_objectSpread({typeName:ti.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1},$n(e)))};var Sa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Rn.date){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.date,received:t.parsedType}),Hn}if(Number.isNaN(e.data.getTime()))return Un(this._getOrReturnCtx(e),{code:Dn.invalid_date}),Hn;var r,n=new Gn,a=void 0,i=_createForOfIteratorHelper(this._def.checks);try{for(i.s();!(r=i.n()).done;){var o=r.value;"min"===o.kind?e.data.getTime()<o.value&&(Un(a=this._getOrReturnCtx(e,a),{code:Dn.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):"max"===o.kind?e.data.getTime()>o.value&&(Un(a=this._getOrReturnCtx(e,a),{code:Dn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):fn.assertNever(o)}}catch(e){i.e(e)}finally{i.f()}return{status:n.value,value:new Date(e.data.getTime())}}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"min",value:function(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:qn.toString(t)})}},{key:"max",value:function(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:qn.toString(t)})}},{key:"minDate",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return null!=t?new Date(t):null}},{key:"maxDate",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return null!=t?new Date(t):null}}])}(Jn);Sa.create=function(e){return new Sa(_objectSpread({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:ti.ZodDate},$n(e)))};var Ea=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.symbol){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.symbol,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Ea.create=function(e){return new Ea(_objectSpread({typeName:ti.ZodSymbol},$n(e)))};var Na=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.undefined){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.undefined,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Na.create=function(e){return new Na(_objectSpread({typeName:ti.ZodUndefined},$n(e)))};var Aa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.null){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.null,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Aa.create=function(e){return new Aa(_objectSpread({typeName:ti.ZodNull},$n(e)))};var Ta=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments))._any=!0,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return Vn(e.data)}}])}(Jn);Ta.create=function(e){return new Ta(_objectSpread({typeName:ti.ZodAny},$n(e)))};var Ia=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments))._unknown=!0,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return Vn(e.data)}}])}(Jn);Ia.create=function(e){return new Ia(_objectSpread({typeName:ti.ZodUnknown},$n(e)))};var Ma=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.never,received:t.parsedType}),Hn}}])}(Jn);Ma.create=function(e){return new Ma(_objectSpread({typeName:ti.ZodNever},$n(e)))};var Ca=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.undefined){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.void,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Ca.create=function(e){return new Ca(_objectSpread({typeName:ti.ZodVoid},$n(e)))};var Oa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.ctx,n=t.status,a=this._def;if(r.parsedType!==Rn.array)return Un(r,{code:Dn.invalid_type,expected:Rn.array,received:r.parsedType}),Hn;if(null!==a.exactLength){var i=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(i||o)&&(Un(r,{code:i?Dn.too_big:Dn.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(null!==a.minLength&&r.data.length<a.minLength.value&&(Un(r,{code:Dn.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),null!==a.maxLength&&r.data.length>a.maxLength.value&&(Un(r,{code:Dn.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all(_toConsumableArray(r.data).map((function(e,t){return a.type._parseAsync(new Xn(r,e,r.path,t))}))).then((function(e){return Gn.mergeArray(n,e)}));var u=_toConsumableArray(r.data).map((function(e,t){return a.type._parseSync(new Xn(r,e,r.path,t))}));return Gn.mergeArray(n,u)}},{key:"element",get:function(){return this._def.type}},{key:"min",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{minLength:{value:e,message:qn.toString(r)}}))}},{key:"max",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{maxLength:{value:e,message:qn.toString(r)}}))}},{key:"length",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{exactLength:{value:e,message:qn.toString(r)}}))}},{key:"nonempty",value:function(e){return this.min(1,e)}}])}(Jn);function Ra(e){if(e instanceof ja){var t={};for(var r in e.shape){var n=e.shape[r];t[r]=Wa.create(Ra(n))}return new ja(_objectSpread(_objectSpread({},e._def),{},{shape:function(){return t}}))}return e instanceof Oa?new Oa(_objectSpread(_objectSpread({},e._def),{},{type:Ra(e.element)})):e instanceof Wa?Wa.create(Ra(e.unwrap())):e instanceof $a?$a.create(Ra(e.unwrap())):e instanceof qa?qa.create(e.items.map((function(e){return Ra(e)}))):e}Oa.create=function(e,t){return new Oa(_objectSpread({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ti.ZodArray},$n(t)))};var ja=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments))._cached=null,e.nonstrict=e.passthrough,e.augment=e.extend,e}return _inherits(t,e),_createClass(t,[{key:"_getCached",value:function(){if(null!==this._cached)return this._cached;var e=this._def.shape(),t=fn.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}},{key:"_parse",value:function(e){if(this._getType(e)!==Rn.object){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.object,received:t.parsedType}),Hn}var r=this._processInputParams(e),n=r.status,a=r.ctx,i=this._getCached(),o=i.shape,u=i.keys,s=[];if(!(this._def.catchall instanceof Ma&&"strip"===this._def.unknownKeys))for(var c in a.data)u.includes(c)||s.push(c);var f,l=[],p=_createForOfIteratorHelper(u);try{for(p.s();!(f=p.n()).done;){var d=f.value,h=o[d],v=a.data[d];l.push({key:{status:"valid",value:d},value:h._parse(new Xn(a,v,a.path,d)),alwaysSet:d in a.data})}}catch(e){p.e(e)}finally{p.f()}if(this._def.catchall instanceof Ma){var m=this._def.unknownKeys;if("passthrough"===m){var g,y=_createForOfIteratorHelper(s);try{for(y.s();!(g=y.n()).done;){var _=g.value;l.push({key:{status:"valid",value:_},value:{status:"valid",value:a.data[_]}})}}catch(e){y.e(e)}finally{y.f()}}else if("strict"===m)s.length>0&&(Un(a,{code:Dn.unrecognized_keys,keys:s}),n.dirty());else if("strip"!==m)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{var b,k=this._def.catchall,w=_createForOfIteratorHelper(s);try{for(w.s();!(b=w.n()).done;){var x=b.value,S=a.data[x];l.push({key:{status:"valid",value:x},value:k._parse(new Xn(a,S,a.path,x)),alwaysSet:x in a.data})}}catch(e){w.e(e)}finally{w.f()}}return a.common.async?Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=_createForOfIteratorHelper(l),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=15;break}return a=n.value,e.next=8,a.key;case 8:return i=e.sent,e.next=11,a.value;case 11:o=e.sent,t.push({key:i,value:o,alwaysSet:a.alwaysSet});case 13:e.next=4;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(2),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,null,[[2,17,20,23]])})))).then((function(e){return Gn.mergeObjectSync(n,e)})):Gn.mergeObjectSync(n,l)}},{key:"shape",get:function(){return this._def.shape()}},{key:"strict",value:function(e){var r=this;return qn.errToObj,new t(_objectSpread(_objectSpread({},this._def),{},{unknownKeys:"strict"},void 0!==e?{errorMap:function(t,n){var a,i,o,u,s=null!==(a=null===(i=(o=r._def).errorMap)||void 0===i?void 0:i.call(o,t,n).message)&&void 0!==a?a:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(u=qn.errToObj(e).message)&&void 0!==u?u:s}:{message:s}}}:{}))}},{key:"strip",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{unknownKeys:"strip"}))}},{key:"passthrough",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{unknownKeys:"passthrough"}))}},{key:"extend",value:function(e){var r=this;return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return _objectSpread(_objectSpread({},r._def.shape()),e)}}))}},{key:"merge",value:function(e){var r=this;return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:function(){return _objectSpread(_objectSpread({},r._def.shape()),e._def.shape())},typeName:ti.ZodObject})}},{key:"setKey",value:function(e,t){return this.augment(_defineProperty({},e,t))}},{key:"catchall",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{catchall:e}))}},{key:"pick",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(e));try{for(a.s();!(r=a.n()).done;){var i=r.value;e[i]&&this.shape[i]&&(n[i]=this.shape[i])}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"omit",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(this.shape));try{for(a.s();!(r=a.n()).done;){var i=r.value;e[i]||(n[i]=this.shape[i])}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"deepPartial",value:function(){return Ra(this)}},{key:"partial",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(this.shape));try{for(a.s();!(r=a.n()).done;){var i=r.value,o=this.shape[i];e&&!e[i]?n[i]=o:n[i]=o.optional()}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"required",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(this.shape));try{for(a.s();!(r=a.n()).done;){var i=r.value;if(e&&!e[i])n[i]=this.shape[i];else{for(var o=this.shape[i];o instanceof Wa;)o=o._def.innerType;n[i]=o}}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"keyof",value:function(){return Ya(fn.objectKeys(this.shape))}}])}(Jn);ja.create=function(e,t){return new ja(_objectSpread({shape:function(){return e},unknownKeys:"strip",catchall:Ma.create(),typeName:ti.ZodObject},$n(t)))},ja.strictCreate=function(e,t){return new ja(_objectSpread({shape:function(){return e},unknownKeys:"strict",catchall:Ma.create(),typeName:ti.ZodObject},$n(t)))},ja.lazycreate=function(e,t){return new ja(_objectSpread({shape:e,unknownKeys:"strip",catchall:Ma.create(),typeName:ti.ZodObject},$n(t)))};var Da=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,r=this._def.options;if(t.common.async)return Promise.all(r.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=_objectSpread(_objectSpread({},t),{},{common:_objectSpread(_objectSpread({},t.common),{},{issues:[]}),parent:null}),e.next=3,r._parseAsync({data:t.data,path:t.path,parent:n});case 3:return e.t0=e.sent,e.t1=n,e.abrupt("return",{result:e.t0,ctx:e.t1});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())).then((function(e){var r,n=_createForOfIteratorHelper(e);try{for(n.s();!(r=n.n()).done;){var a=r.value;if("valid"===a.result.status)return a.result}}catch(e){n.e(e)}finally{n.f()}var i,o=_createForOfIteratorHelper(e);try{for(o.s();!(i=o.n()).done;){var u,s=i.value;if("dirty"===s.result.status)return(u=t.common.issues).push.apply(u,_toConsumableArray(s.ctx.common.issues)),s.result}}catch(e){o.e(e)}finally{o.f()}var c=e.map((function(e){return new Pn(e.ctx.common.issues)}));return Un(t,{code:Dn.invalid_union,unionErrors:c}),Hn}));var n,a,i=void 0,o=[],u=_createForOfIteratorHelper(r);try{for(u.s();!(n=u.n()).done;){var s=n.value,c=_objectSpread(_objectSpread({},t),{},{common:_objectSpread(_objectSpread({},t.common),{},{issues:[]}),parent:null}),f=s._parseSync({data:t.data,path:t.path,parent:c});if("valid"===f.status)return f;"dirty"!==f.status||i||(i={result:f,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}}catch(e){u.e(e)}finally{u.f()}if(i)return(a=t.common.issues).push.apply(a,_toConsumableArray(i.ctx.common.issues)),i.result;var l=o.map((function(e){return new Pn(e)}));return Un(t,{code:Dn.invalid_union,unionErrors:l}),Hn}},{key:"options",get:function(){return this._def.options}}])}(Jn);Da.create=function(e,t){return new Da(_objectSpread({options:e,typeName:ti.ZodUnion},$n(t)))};var Pa=function(e){return e instanceof Za?Pa(e.schema):e instanceof Xa?Pa(e.innerType()):e instanceof Va?[e.value]:e instanceof Ba?e.options:e instanceof Ka?fn.objectValues(e.enum):e instanceof Qa?Pa(e._def.innerType):e instanceof Na?[void 0]:e instanceof Aa?[null]:e instanceof Wa?[void 0].concat(_toConsumableArray(Pa(e.unwrap()))):e instanceof $a?[null].concat(_toConsumableArray(Pa(e.unwrap()))):e instanceof ri||e instanceof ai?Pa(e.unwrap()):e instanceof Ja?Pa(e._def.innerType):[]},La=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;if(t.parsedType!==Rn.object)return Un(t,{code:Dn.invalid_type,expected:Rn.object,received:t.parsedType}),Hn;var r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(Un(t,{code:Dn.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Hn)}},{key:"discriminator",get:function(){return this._def.discriminator}},{key:"options",get:function(){return this._def.options}},{key:"optionsMap",get:function(){return this._def.optionsMap}}],[{key:"create",value:function(e,r,n){var a,i=new Map,o=_createForOfIteratorHelper(r);try{for(o.s();!(a=o.n()).done;){var u=a.value,s=Pa(u.shape[e]);if(!s.length)throw new Error("A discriminator value for key `".concat(e,"` could not be extracted from all schema options"));var c,f=_createForOfIteratorHelper(s);try{for(f.s();!(c=f.n()).done;){var l=c.value;if(i.has(l))throw new Error("Discriminator property ".concat(String(e)," has duplicate value ").concat(String(l)));i.set(l,u)}}catch(e){f.e(e)}finally{f.f()}}}catch(e){o.e(e)}finally{o.f()}return new t(_objectSpread({typeName:ti.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i},$n(n)))}}])}(Jn);function Fa(e,t){var r=jn(e),n=jn(t);if(e===t)return{valid:!0,data:e};if(r===Rn.object&&n===Rn.object){var a,i=fn.objectKeys(t),o=fn.objectKeys(e).filter((function(e){return-1!==i.indexOf(e)})),u=_objectSpread(_objectSpread({},e),t),s=_createForOfIteratorHelper(o);try{for(s.s();!(a=s.n()).done;){var c=a.value,f=Fa(e[c],t[c]);if(!f.valid)return{valid:!1};u[c]=f.data}}catch(e){s.e(e)}finally{s.f()}return{valid:!0,data:u}}if(r===Rn.array&&n===Rn.array){if(e.length!==t.length)return{valid:!1};for(var l=[],p=0;p<e.length;p++){var d=Fa(e[p],t[p]);if(!d.valid)return{valid:!1};l.push(d.data)}return{valid:!0,data:l}}return r===Rn.date&&n===Rn.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Ua=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.status,n=t.ctx,a=function(e,t){if(Yn(e)||Yn(t))return Hn;var a=Fa(e.value,t.value);return a.valid?((Bn(e)||Bn(t))&&r.dirty(),{status:r.value,value:a.data}):(Un(n,{code:Dn.invalid_intersection_types}),Hn)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return a(r,n)})):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}])}(Jn);Ua.create=function(e,t,r){return new Ua(_objectSpread({left:e,right:t,typeName:ti.ZodIntersection},$n(r)))};var qa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e),n=r.status,a=r.ctx;if(a.parsedType!==Rn.array)return Un(a,{code:Dn.invalid_type,expected:Rn.array,received:a.parsedType}),Hn;if(a.data.length<this._def.items.length)return Un(a,{code:Dn.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Hn;!this._def.rest&&a.data.length>this._def.items.length&&(Un(a,{code:Dn.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());var i=_toConsumableArray(a.data).map((function(e,r){var n=t._def.items[r]||t._def.rest;return n?n._parse(new Xn(a,e,a.path,r)):null})).filter((function(e){return!!e}));return a.common.async?Promise.all(i).then((function(e){return Gn.mergeArray(n,e)})):Gn.mergeArray(n,i)}},{key:"items",get:function(){return this._def.items}},{key:"rest",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{rest:e}))}}])}(Jn);qa.create=function(e,t){if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new qa(_objectSpread({items:e,typeName:ti.ZodTuple,rest:null},$n(t)))};var Ga=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"keySchema",get:function(){return this._def.keyType}},{key:"valueSchema",get:function(){return this._def.valueType}},{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.status,n=t.ctx;if(n.parsedType!==Rn.map)return Un(n,{code:Dn.invalid_type,expected:Rn.map,received:n.parsedType}),Hn;var a=this._def.keyType,i=this._def.valueType,o=_toConsumableArray(n.data.entries()).map((function(e,t){var r=_slicedToArray(e,2),o=r[0],u=r[1];return{key:a._parse(new Xn(n,o,n.path,[t,"key"])),value:i._parse(new Xn(n,u,n.path,[t,"value"]))}}));if(n.common.async){var u=new Map;return Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,a,i,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=_createForOfIteratorHelper(o),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=17;break}return a=n.value,e.next=7,a.key;case 7:return i=e.sent,e.next=10,a.value;case 10:if(s=e.sent,"aborted"!==i.status&&"aborted"!==s.status){e.next=13;break}return e.abrupt("return",Hn);case 13:"dirty"!==i.status&&"dirty"!==s.status||r.dirty(),u.set(i.value,s.value);case 15:e.next=3;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(1),t.e(e.t0);case 22:return e.prev=22,t.f(),e.finish(22);case 25:return e.abrupt("return",{status:r.value,value:u});case 26:case"end":return e.stop()}}),e,null,[[1,19,22,25]])}))))}var s,c=new Map,f=_createForOfIteratorHelper(o);try{for(f.s();!(s=f.n()).done;){var l=s.value,p=l.key,d=l.value;if("aborted"===p.status||"aborted"===d.status)return Hn;"dirty"!==p.status&&"dirty"!==d.status||r.dirty(),c.set(p.value,d.value)}}catch(e){f.e(e)}finally{f.f()}return{status:r.value,value:c}}}])}(Jn);Ga.create=function(e,t,r){return new Ga(_objectSpread({valueType:t,keyType:e,typeName:ti.ZodMap},$n(r)))};var Ha=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.status,n=t.ctx;if(n.parsedType!==Rn.set)return Un(n,{code:Dn.invalid_type,expected:Rn.set,received:n.parsedType}),Hn;var a=this._def;null!==a.minSize&&n.data.size<a.minSize.value&&(Un(n,{code:Dn.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),null!==a.maxSize&&n.data.size>a.maxSize.value&&(Un(n,{code:Dn.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());var i=this._def.valueType;function o(e){var t,n=new Set,a=_createForOfIteratorHelper(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;if("aborted"===i.status)return Hn;"dirty"===i.status&&r.dirty(),n.add(i.value)}}catch(e){a.e(e)}finally{a.f()}return{status:r.value,value:n}}var u=_toConsumableArray(n.data.values()).map((function(e,t){return i._parse(new Xn(n,e,n.path,t))}));return n.common.async?Promise.all(u).then((function(e){return o(e)})):o(u)}},{key:"min",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{minSize:{value:e,message:qn.toString(r)}}))}},{key:"max",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{maxSize:{value:e,message:qn.toString(r)}}))}},{key:"size",value:function(e,t){return this.min(e,t).max(e,t)}},{key:"nonempty",value:function(e){return this.min(1,e)}}])}(Jn);Ha.create=function(e,t){return new Ha(_objectSpread({valueType:e,minSize:null,maxSize:null,typeName:ti.ZodSet},$n(t)))};var Za=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"schema",get:function(){return this._def.getter()}},{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}])}(Jn);Za.create=function(e,t){return new Za(_objectSpread({getter:e,typeName:ti.ZodLazy},$n(t)))};var Va=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(e.data!==this._def.value){var t=this._getOrReturnCtx(e);return Un(t,{received:t.data,code:Dn.invalid_literal,expected:this._def.value}),Hn}return{status:"valid",value:e.data}}},{key:"value",get:function(){return this._def.value}}])}(Jn);function Ya(e,t){return new Ba(_objectSpread({values:e,typeName:ti.ZodEnum},$n(t)))}Va.create=function(e,t){return new Va(_objectSpread({value:e,typeName:ti.ZodLiteral},$n(t)))};var Ba=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if("string"!=typeof e.data){var t=this._getOrReturnCtx(e),r=this._def.values;return Un(t,{expected:fn.joinValues(r),received:t.parsedType,code:Dn.invalid_type}),Hn}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){var n=this._getOrReturnCtx(e),a=this._def.values;return Un(n,{received:n.data,code:Dn.invalid_enum_value,options:a}),Hn}return Vn(e.data)}},{key:"options",get:function(){return this._def.values}},{key:"enum",get:function(){var e,t={},r=_createForOfIteratorHelper(this._def.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;t[n]=n}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"Values",get:function(){var e,t={},r=_createForOfIteratorHelper(this._def.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;t[n]=n}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"Enum",get:function(){var e,t={},r=_createForOfIteratorHelper(this._def.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;t[n]=n}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"extract",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._def;return t.create(e,_objectSpread(_objectSpread({},this._def),r))}},{key:"exclude",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._def;return t.create(this.options.filter((function(t){return!e.includes(t)})),_objectSpread(_objectSpread({},this._def),r))}}])}(Jn);Ba.create=Ya;var Ka=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=fn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Rn.string&&r.parsedType!==Rn.number){var n=fn.objectValues(t);return Un(r,{expected:fn.joinValues(n),received:r.parsedType,code:Dn.invalid_type}),Hn}if(this._cache||(this._cache=new Set(fn.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){var a=fn.objectValues(t);return Un(r,{received:r.data,code:Dn.invalid_enum_value,options:a}),Hn}return Vn(e.data)}},{key:"enum",get:function(){return this._def.values}}])}(Jn);Ka.create=function(e,t){return new Ka(_objectSpread({values:e,typeName:ti.ZodNativeEnum},$n(t)))};var za=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"unwrap",value:function(){return this._def.type}},{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e).ctx;if(r.parsedType!==Rn.promise&&!1===r.common.async)return Un(r,{code:Dn.invalid_type,expected:Rn.promise,received:r.parsedType}),Hn;var n=r.parsedType===Rn.promise?r.data:Promise.resolve(r.data);return Vn(n.then((function(e){return t._def.type.parseAsync(e,{path:r.path,errorMap:r.common.contextualErrorMap})})))}}])}(Jn);za.create=function(e,t){return new za(_objectSpread({type:e,typeName:ti.ZodPromise},$n(t)))};var Xa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"innerType",value:function(){return this._def.schema}},{key:"sourceType",value:function(){return this._def.schema._def.typeName===ti.ZodEffects?this._def.schema.sourceType():this._def.schema}},{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e),n=r.status,a=r.ctx,i=this._def.effect||null,o={addIssue:function(e){Un(a,e),e.fatal?n.abort():n.dirty()},get path(){return a.path}};if(o.addIssue=o.addIssue.bind(o),"preprocess"===i.type){var u=i.transform(a.data,o);if(a.common.async)return Promise.resolve(u).then(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("aborted"!==n.value){e.next=2;break}return e.abrupt("return",Hn);case 2:return e.next=4,t._def.schema._parseAsync({data:r,path:a.path,parent:a});case 4:if("aborted"!==(i=e.sent).status){e.next=7;break}return e.abrupt("return",Hn);case 7:if("dirty"!==i.status){e.next=9;break}return e.abrupt("return",Zn(i.value));case 9:if("dirty"!==n.value){e.next=11;break}return e.abrupt("return",Zn(i.value));case 11:return e.abrupt("return",i);case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());if("aborted"===n.value)return Hn;var s=this._def.schema._parseSync({data:u,path:a.path,parent:a});return"aborted"===s.status?Hn:"dirty"===s.status||"dirty"===n.value?Zn(s.value):s}if("refinement"===i.type){var c=function(e){var t=i.refinement(e,o);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){var f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===f.status?Hn:("dirty"===f.status&&n.dirty(),c(f.value),{status:n.value,value:f.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((function(e){return"aborted"===e.status?Hn:("dirty"===e.status&&n.dirty(),c(e.value).then((function(){return{status:n.value,value:e.value}})))}))}if("transform"===i.type){if(!1===a.common.async){var l=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Kn(l))return Hn;var p=i.transform(l.value,o);if(p instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:p}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((function(e){return Kn(e)?Promise.resolve(i.transform(e.value,o)).then((function(e){return{status:n.value,value:e}})):Hn}))}fn.assertNever(i)}}])}(Jn);Xa.create=function(e,t,r){return new Xa(_objectSpread({schema:e,typeName:ti.ZodEffects,effect:t},$n(r)))},Xa.createWithPreprocess=function(e,t,r){return new Xa(_objectSpread({schema:t,effect:{type:"preprocess",transform:e},typeName:ti.ZodEffects},$n(r)))};var Wa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return this._getType(e)===Rn.undefined?Vn(void 0):this._def.innerType._parse(e)}},{key:"unwrap",value:function(){return this._def.innerType}}])}(Jn);Wa.create=function(e,t){return new Wa(_objectSpread({innerType:e,typeName:ti.ZodOptional},$n(t)))};var $a=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return this._getType(e)===Rn.null?Vn(null):this._def.innerType._parse(e)}},{key:"unwrap",value:function(){return this._def.innerType}}])}(Jn);$a.create=function(e,t){return new $a(_objectSpread({innerType:e,typeName:ti.ZodNullable},$n(t)))};var Qa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,r=t.data;return t.parsedType===Rn.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}},{key:"removeDefault",value:function(){return this._def.innerType}}])}(Jn);Qa.create=function(e,t){return new Qa(_objectSpread({innerType:e,typeName:ti.ZodDefault,defaultValue:"function"==typeof t.default?t.default:function(){return t.default}},$n(t)))};var Ja=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e).ctx,n=_objectSpread(_objectSpread({},r),{},{common:_objectSpread(_objectSpread({},r.common),{},{issues:[]})}),a=this._def.innerType._parse({data:n.data,path:n.path,parent:_objectSpread({},n)});return zn(a)?a.then((function(e){return{status:"valid",value:"valid"===e.status?e.value:t._def.catchValue({get error(){return new Pn(n.common.issues)},input:n.data})}})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new Pn(n.common.issues)},input:n.data})}}},{key:"removeCatch",value:function(){return this._def.innerType}}])}(Jn);Ja.create=function(e,t){return new Ja(_objectSpread({innerType:e,typeName:ti.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:function(){return t.catch}},$n(t)))};var ei=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.nan){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.nan,received:t.parsedType}),Hn}return{status:"valid",value:e.data}}}])}(Jn);ei.create=function(e){return new ei(_objectSpread({typeName:ti.ZodNaN},$n(e)))};var ti,ri=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}},{key:"unwrap",value:function(){return this._def.type}}])}(Jn),ni=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e),n=r.status,a=r.ctx;if(a.common.async){var i=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._def.in._parseAsync({data:a.data,path:a.path,parent:a});case 2:if("aborted"!==(r=e.sent).status){e.next=5;break}return e.abrupt("return",Hn);case 5:if("dirty"!==r.status){e.next=10;break}return n.dirty(),e.abrupt("return",Zn(r.value));case 10:return e.abrupt("return",t._def.out._parseAsync({data:r.value,path:a.path,parent:a}));case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return i()}var o=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===o.status?Hn:"dirty"===o.status?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:a.path,parent:a})}}],[{key:"create",value:function(e,r){return new t({in:e,out:r,typeName:ti.ZodPipeline})}}])}(Jn),ai=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._def.innerType._parse(e),r=function(e){return Kn(e)&&(e.value=Object.freeze(e.value)),e};return zn(t)?t.then((function(e){return r(e)})):r(t)}},{key:"unwrap",value:function(){return this._def.innerType}}])}(Jn);ai.create=function(e,t){return new ai(_objectSpread({innerType:e,typeName:ti.ZodReadonly},$n(t)))},function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(ti||(ti={}));var ii=ba.create,oi=ka.create,ui=Ta.create;Ma.create;var si=Oa.create,ci=ja.create;Da.create;var fi=La.create;Ua.create,qa.create;var li=Va.create,pi=Ba.create;za.create,Wa.create,$a.create;var di=Xa.createWithPreprocess,hi=ci({graphType:pi(["v2","v2-raw"]),category:pi(["tokens","markets"]),param1:ii().nonempty(),param2:ii().optional()});function vi(){return vi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(f),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=r[3],On(hi,{graphType:n,category:a,param1:i,param2:o}),u="".concat("https://onchain-proxy.fileverse.io/third-party")+"?service=aave"+"&graphType=".concat(encodeURIComponent(n))+"&category=".concat(encodeURIComponent(a))+"&input1=".concat(encodeURIComponent(i))+(o?"&input2=".concat(encodeURIComponent(o)):""),e.next=7,fetch(u);case 7:if((s=e.sent).ok){e.next=10;break}throw new Tn("AAVE",s.status);case 10:return e.next=12,s.json();case 12:if(c=e.sent,!Array.isArray(c)){e.next=15;break}return e.abrupt("return",c.map((function(e){var t={};return Object.entries(e).forEach((function(e){var r=_slicedToArray(e,2),n=r[0],a=r[1];null!==a&&"object"===_typeof(a)||(t[n]=a)})),t})));case 15:return e.abrupt("return",c);case 18:return e.prev=18,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"AAVE"));case 21:case"end":return e.stop()}}),e,null,[[0,18]])}))),vi.apply(this,arguments)}var mi=di((function(e){return"string"==typeof e&&/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(e)?function(e){var t=_slicedToArray(e.split("/"),3),r=t[0],n=t[1],a=t[2],i=new Date("".concat(a,"-").concat(n.padStart(2,"0"),"-").concat(r.padStart(2,"0"))).getTime();return isNaN(i)?NaN:Math.floor(i/1e3)}(e):e}),oi({invalid_type_error:"Date must be a valid DD/MM/YYYY or timestamp"}).int("Date must be an integer timestamp").nonnegative("Date must be a nonnegative timestamp").refine((function(e){return!isNaN(e)}),{message:"Invalid date format or value: expected DD/MM/YYYY"})),gi=ci({addresses:ii().nonempty(),category:pi(["balance","txns"]),chains:di((function(e){return"string"==typeof e?e.split(",").map((function(e){return e.trim()})).filter(Boolean):e}),si(pi(["ethereum","gnosis","base"])).nonempty()),startTime:mi.optional(),endTime:mi.optional(),page:oi().int().nonnegative().default(1),offset:oi().int().nonnegative().max(xn,{message:'"offset" must be less than or equal to '.concat(xn)}).default(10)}),yi=di((function(e){var t=_objectSpread({},e||{});return"balance"===t.category&&(delete t.startTime,delete t.endTime),t}),gi.refine((function(e){return"txns"!==e.category||void 0!==e.startTime&&void 0!==e.endTime}),{message:"startTime and endTime required for txns",path:["startTime"]})),_i=function(e){return/^0x[a-fA-F0-9]{40}$/.test(e)};function bi(e){return ki.apply(this,arguments)}function ki(){return ki=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof ethers){e.next=3;break}return e.next=3,new Promise((function(e,t){var r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/ethers@6.10.0/dist/ethers.umd.min.js",r.onload=e,r.onerror=t,document.head.appendChild(r)}));case 3:if(r=window.localStorage.getItem(wn)){e.next=7;break}return console.error("alchemy api key missing"),e.abrupt("return",null);case 7:return n=new ethers.AlchemyProvider("mainnet",r),e.prev=8,e.next=11,n.resolveName(t);case 11:return a=e.sent,e.abrupt("return",a||null);case 15:return e.prev=15,e.t0=e.catch(8),console.error("ENS resolution failed:",e.t0.message),e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[8,15]])}))),ki.apply(this,arguments)}var wi,xi=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!_i(t)){e.next=2;break}return e.abrupt("return",t);case 2:return e.next=4,bi(t);case 4:if(!(r=e.sent)){e.next=7;break}return e.abrupt("return",r);case 7:throw new En("Invalid address");case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Si={validateAndGetAddress:xi};function Ei(e){var t=e.url,r=e.serviceName,n=e.headers,a=void 0===n?{}:n,i=function(){if(!wi){var e="".concat(window.NEXT_PUBLIC_PROXY_BASE_URL,"/proxy");wi={DuneSim:{url:e},Etherscan:{url:e,removeParams:["apikey"]},Basescan:{url:e,removeParams:["apikey"]},Gnosisscan:{url:e,removeParams:["apikey"]},Coingecko:{url:e,removeParams:["apikey"]},Firefly:{url:e,removeParams:["apikey"]},Neynar:{url:e,removeParams:["api_key"]},Safe:{url:e,removeParams:["api_key"]},Defillama:{url:e,removeParams:["api_key"]},GnosisPay:{url:e,removeParams:["api_key"]}}}return wi}(),o=window.localStorage.getItem(Sn[r]),u="DEFAULT_PROXY_MODE"===o,s=i[r];if(!s&&Sn[r]&&(!o||""===o))throw new Nn(Sn[r]);if((u||!o||""===o)&&s){var c=function(e,t){if(!t||0===t.length)return e;var r=new URL(e);return t.forEach((function(e){r.searchParams.has(e)&&r.searchParams.delete(e)})),r.toString()}(t,s.removeParams);return{URL:s.url,HEADERS:{"target-url":c,method:"GET","Content-Type":"application/json","Cache-Control":"no-store",Pragma:"no-cache"}}}return{URL:t,HEADERS:_objectSpread({"Cache-Control":"no-store",Pragma:"no-cache"},a)}}var Ni=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var a,i,o,u,s,c,f;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&r){e.next=2;break}return e.abrupt("return");case 2:return a=pn[r],i="https://api.etherscan.io/v2/api?module=block&action=getblocknobytime&timestamp=".concat(t,"&closest=before&apikey=").concat(n,"&chainId=").concat(a),o=Ei({url:i,serviceName:"Etherscan",headers:{}}),u=o.URL,s=o.HEADERS,e.next=7,fetch(u,{method:"GET",headers:s});case 7:return c=e.sent,e.next=10,c.json();case 10:return f=e.sent,e.abrupt("return",parseInt(f.result));case 12:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),Ai={fromTimeStampToBlock:Ni};function Ti(e){var t=_slicedToArray(e.split("/").map(Number),3),r=t[0],n=t[1],a=t[2],i=new Date(a,n-1,r);return Math.floor(i.getTime()/1e3)}function Ii(){return Ii=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,T=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,t=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Ei({url:t,serviceName:"Etherscan",headers:{}}),n=r.URL,a=r.HEADERS,e.next=3,fetch(n,{method:"GET",headers:a});case 3:if((i=e.sent).ok){e.next=6;break}throw new Tn(Sn.Etherscan,i.status);case 6:return e.next=8,i.json();case 8:if("string"!=typeof(o=e.sent).result){e.next=14;break}if(!o.result.includes("Invalid API Key")){e.next=12;break}throw new Mn(Sn.Etherscan);case 12:if(!o.result.includes("Max rate limit reached")){e.next=14;break}throw new An(Sn.Etherscan);case 14:return e.abrupt("return",o.result);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),r=A(T),n=_slicedToArray(r,7),a=n[0],i=n[1],o=n[2],u=n[3],s=n[4],c=n[5],f=void 0===c?1:c,l=n[6],On(yi,{addresses:a,category:i,chains:o,startTime:u,endTime:s,page:f,offset:p=void 0===l?10:l}),d=window.localStorage.getItem(Sn.Etherscan),h=a.split(",").map((function(e){return e.trim()})).filter(Boolean),v=o.split(",").map((function(e){return e.trim()})).filter(Boolean),m={},g=_createForOfIteratorHelper(h),e.prev=9,g.s();case 11:if((y=g.n()).done){e.next=23;break}if(_=y.value,!_i(_)){e.next=17;break}m[_.toLowerCase()]=null,e.next=21;break;case 17:return e.next=19,Si.validateAndGetAddress(_);case 19:b=e.sent,m[b.toLowerCase()]=b;case 21:e.next=11;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(9),g.e(e.t0);case 28:return e.prev=28,g.f(),e.finish(28);case 31:k=Object.keys(m),w=[],x=_createForOfIteratorHelper(v),e.prev=34,E=_regeneratorRuntime().mark((function e(){var r,n,a,o,c,l,h,v,g,y,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=S.value,n=pn[r]){e.next=4;break}throw new En("Invalid chain: ".concat(r));case 4:if("balance"!==i){e.next=17;break}a=_regeneratorRuntime().mark((function e(a){var i,o,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=k.slice(a,a+20).join(","),o="https://api.etherscan.io/v2/api?chainid=".concat(n)+"&module=account&action=addresstokenbalance&address=".concat(i)+"&page=".concat(f,"&offset=").concat(p,"&apikey=").concat(d),e.next=4,t(o);case 4:if(u=e.sent,Array.isArray(u)){e.next=7;break}return e.abrupt("return",{v:{v:u}});case 7:u.forEach((function(e,t){return w.push(_objectSpread({chain:r,address:k[a+t],name:m[k[a+t]]},e))}));case 8:case"end":return e.stop()}}),e)})),c=0;case 7:if(!(c<k.length)){e.next=15;break}return e.delegateYield(a(c),"t0",9);case 9:if(!(o=e.t0)){e.next=12;break}return e.abrupt("return",o.v);case 12:c+=20,e.next=7;break;case 15:e.next=37;break;case 17:return e.next=19,Ai.fromTimeStampToBlock(Ti(u),r,d);case 19:return l=e.sent,e.next=22,Ai.fromTimeStampToBlock(Ti(s),r,d);case 22:if(h=e.sent,l){e.next=25;break}throw new En("Invalid startTime: ".concat(u));case 25:if(h){e.next=27;break}throw new En("Invalid endTime: ".concat(s));case 27:v=_regeneratorRuntime().mark((function e(){var a,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=_[y],i="https://api.etherscan.io/v2/api?chainid=".concat(n)+"&module=account&action=tokentx&address=".concat(a)+"&startblock=".concat(l,"&endblock=").concat(h)+"&page=".concat(f,"&offset=").concat(p,"&sort=asc&apikey=").concat(d),e.next=4,t(i);case 4:if(o=e.sent,Array.isArray(o)){e.next=7;break}return e.abrupt("return",{v:{v:o}});case 7:o.forEach((function(e){return w.push(_objectSpread({chain:r,address:a,name:m[a]},e))}));case 8:case"end":return e.stop()}}),e)})),y=0,_=k;case 29:if(!(y<_.length)){e.next=37;break}return e.delegateYield(v(),"t1",31);case 31:if(!(g=e.t1)){e.next=34;break}return e.abrupt("return",g.v);case 34:y++,e.next=29;break;case 37:case"end":return e.stop()}}),e)})),x.s();case 37:if((S=x.n()).done){e.next=44;break}return e.delegateYield(E(),"t1",39);case 39:if(!(N=e.t1)){e.next=42;break}return e.abrupt("return",N.v);case 42:e.next=37;break;case 44:e.next=49;break;case 46:e.prev=46,e.t2=e.catch(34),x.e(e.t2);case 49:return e.prev=49,x.f(),e.finish(49);case 52:return e.abrupt("return",w);case 55:return e.prev=55,e.t3=e.catch(0),e.abrupt("return",Cn(e.t3,"EOA"));case 58:case"end":return e.stop()}}),e,null,[[0,55],[9,25,28,31],[34,46,49,52]])}))),Ii.apply(this,arguments)}var Mi=fi("type",[ci({type:li("gas"),startDate:mi.optional(),endDate:mi.optional(),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)}),ci({type:pi(["all-txns","token-txns","nft-txns"]),address:ii().nonempty(),startDate:mi.optional(),endDate:mi.optional(),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)})]);function Ci(e){return Oi.apply(this,arguments)}function Oi(){return(Oi=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,A,T;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.type,n=t.address,a=t.startDate,i=t.endDate,o=t.page,u=void 0===o?1:o,s=t.offset,c=void 0===s?10:s,f=t.apiKey,l=t.functionName,p=t.chainId,d=t.network,h={BASE:{url:"https://api.basescan.org/api",apiKeyName:Sn.Basescan},ETHERSCAN:{url:"https://api.etherscan.io/v2/api",apiKeyName:Sn.Etherscan},GNOSIS:{url:"https://api.gnosisscan.io/api",apiKeyName:Sn.Gnosisscan}},"gas"===r){e.next=6;break}return e.next=5,Si.validateAndGetAddress(n);case 5:n=e.sent;case 6:if(v=h[l],m=null==v?void 0:v.url){e.next=10;break}throw new En("Api not found for: ".concat(l));case 10:if(g={"all-txns":"txlist","token-txns":"tokentx","nft-txns":"tokennfttx",gas:"gasoracle"}[r]){e.next=14;break}throw new En("Invalid type: ".concat(r));case 14:if(y="gasoracle"===g?"gastracker":"account",_="".concat(m,"?chainid=").concat(p,"&module=").concat(y,"&action=").concat(g,"&apikey=").concat(f),!["all-txns","token-txns","nft-txns"].includes(r)){e.next=27;break}if(_+="&address=".concat(n,"&startblock=0&endblock=99999999&sort=asc"),isNaN(a)||isNaN(i)){e.next=26;break}return e.next=21,Promise.all([Ai.fromTimeStampToBlock(Ti(a),d,f),Ai.fromTimeStampToBlock(Ti(i),d,f)]);case 21:b=e.sent,k=_slicedToArray(b,2),w=k[0],x=k[1],_+="&startblock=".concat(w||"0","&endblock=").concat(x||"99999999");case 26:_+="&page=".concat(u,"&offset=").concat(c);case 27:return S=Ei({url:_,serviceName:v.apiKeyName,headers:{}}),E=S.URL,N=S.HEADERS,e.next=30,fetch(E,{method:"GET",headers:N});case 30:if((A=e.sent).ok){e.next=33;break}throw new Tn(v.apiKeyName,A.status);case 33:return e.next=35,A.json();case 35:if("string"!=typeof(T=e.sent).result){e.next=41;break}if(!T.result.includes("Invalid API Key")){e.next=39;break}throw new Mn(v.apiKeyName);case 39:if(!T.result.includes("Max rate limit reached")){e.next=41;break}throw new An(v.apiKeyName);case 41:return e.abrupt("return","gas"!==r||Array.isArray(T.result)?T.result:[T.result]);case 42:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ri(){return Ri=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(f),r=_slicedToArray(t,6),n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],s=r[5],On(Mi,{type:n,address:a,startDate:i,endDate:o,page:u,limit:s}),c=window.localStorage.getItem(Sn.Basescan),e.next=6,Ci({type:n,address:a,startDate:i,endDate:o,page:u,offset:s,apiKey:c,functionName:"BASE",chainId:pn.base,network:"base"});case 6:return e.abrupt("return",e.sent);case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"BASE"));case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),Ri.apply(this,arguments)}var ji=ci({address:ii().nonempty(),type:pi(["stat","txns","tokens"]),chain:pi(["ethereum","gnosis","arbitrum","optimism","soneium","unichain"]).default("ethereum"),startTimestamp:mi.optional(),endTimestamp:mi.optional(),page:oi().int().nonnegative().default(1),offset:oi().int().nonnegative().max(xn,{message:'"offset" must be less than or equal to '.concat(xn)}).default(10)});function Di(){return Di=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=A(b),a=_slicedToArray(n,7),i=a[0],o=a[1],u=a[2],s=void 0===u?"ethereum":u,c=a[3],f=a[4],l=a[5],p=a[6],On(ji,{address:i,type:o,chain:s,startTimestamp:c,endTimestamp:f,page:l,offset:p}),d=null!=c?c:Math.floor((Date.now()-2592e6)/1e3),h=f,e.next=7,Si.validateAndGetAddress(i);case 7:v=e.sent,m=dn[s],e.t0=o,e.next="stat"===e.t0?12:"txns"===e.t0?14:"tokens"===e.t0?16:18;break;case 12:return g="".concat(m,"/api/v2/addresses/").concat(v,"/counters"),e.abrupt("break",18);case 14:return g="".concat(m,"/api?module=account&action=txlist")+"&address=".concat(v)+"&start_timestamp=".concat(d)+"&end_timestamp=".concat(null!=h?h:"")+"&page=".concat(l)+"&offset=".concat(p)+"&sort=asc",e.abrupt("break",18);case 16:return g="".concat(m,"/api?module=account&action=tokenlist")+"&address=".concat(v),e.abrupt("break",18);case 18:return e.next=20,fetch(g);case 20:if((y=e.sent).ok){e.next=23;break}throw new Tn("BLOCKSCOUT",y.status);case 23:return e.next=25,y.json();case 25:if(null==(_=e.sent)||null===(t=_.result)||void 0===t||!t.includes("Invalid parameter(s)")){e.next=28;break}throw new En("Invalid parameters");case 28:if(null==_||null===(r=_.result)||void 0===r||!r.includes("Not found")){e.next=30;break}throw new En("Address information not found");case 30:return e.abrupt("return","stat"===o?[_]:_.result);case 33:return e.prev=33,e.t1=e.catch(0),e.abrupt("return",Cn(e.t1,"BLOCKSCOUT"));case 36:case"end":return e.stop()}}),e,null,[[0,33]])}))),Di.apply(this,arguments)}var Pi=["1h","24h","7d","14d","30d","200d","1y"],Li=ii().refine((function(e){return e.split(",").map((function(e){return e.trim().toLowerCase()})).some((function(e){return Pi.some((function(t){return e.includes(t)}))}))}),{message:"param2 must contain at least one of: '1h', '24h', '7d', '14d', '30d', '200d', '1y'"}).optional(),Fi=fi("category",[ci({category:li("price"),param1:ii().nonempty(),param2:ii().nonempty().optional()}),ci({category:li("market"),param1:pi(["all","base","meme","aiagents","bitcoin","ethereum","hyperliquid","pump","solana"]),param2:Li}),ci({category:li("stablecoins"),param1:pi(["all","yield-bearing-stablecoins","crypto-backed-stablecoin"]),param2:Li}),ci({category:li("derivatives"),param1:ii().nonempty(),param2:ui().optional()})]);function Ui(){return Ui=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,T,I,M,C,O,R=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,r=A(R),n=_slicedToArray(r,3),a=n[0],i=n[1],o=n[2],On(Fi,{category:a,param1:i,param2:o}),u=window.localStorage.getItem(Sn.Coingecko),s={accept:"application/json","x-cg-demo-api-key":u},c="",e.t0=null==a||null===(t=a.toLowerCase)||void 0===t?void 0:t.call(a),e.next="price"===e.t0?9:"market"===e.t0?12:"stablecoins"===e.t0?17:"derivatives"===e.t0?21:23;break;case 9:return c="https://api.coingecko.com/api/v3/simple/price?vs_currencies=".concat(o||"usd","&symbols=").concat(i),e.abrupt("break",23);case 12:return f={all:"",base:"base-ecosystem",meme:"meme-token",aiagents:"ai-agents",bitcoin:"bitcoin-ecosystem",ethereum:"ethereum-ecosystem",hyperliquid:"hyperliquid-ecosystem",pump:"pump-ecosystem",solana:"solana-ecosystem"}[i]||"",l=o?"&price_change_percentage=".concat(o):"",c="https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&include_tokens=top&page=1&per_page=100".concat(f?"&category=".concat(f):"").concat(l),e.abrupt("break",23);case 17:return p="all"===i?"stablecoins":i,d=o?"&price_change_percentage=".concat(o):"",c="https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&category=".concat(p,"&order=market_cap_desc&page=1&per_page=100").concat(d),e.abrupt("break",23);case 21:return c=i&&"all"!==i?"https://api.coingecko.com/api/v3/derivatives/exchanges/".concat(i,"?include_tickers=all"):"https://api.coingecko.com/api/v3/derivatives",e.abrupt("break",23);case 23:return h=Ei({url:c,serviceName:"Coingecko",headers:s}),v=h.URL,m=h.HEADERS,e.next=26,fetch(v+"?refresh=true",{headers:m});case 26:return g=e.sent,e.next=29,g.json();case 29:if(y=e.sent,g.ok){e.next=35;break}if(!((null==y||null===(_=y.status)||void 0===_?void 0:_.error_message)||"").includes("API Key Missing")){e.next=34;break}throw new Mn(Sn.Coingecko);case 34:throw new Tn(Sn.Coingecko,g.status);case 35:if("price"!==a){e.next=39;break}for(b={},k=0,w=Object.entries(y);k<w.length;k++)for(x=_slicedToArray(w[k],2),S=x[0],E=x[1],N=0,T=Object.entries(E);N<T.length;N++)I=_slicedToArray(T[N],2),M=I[0],C=I[1],b["".concat(S.toUpperCase(),"_").concat(M.toUpperCase())]=C;return e.abrupt("return",[b]);case 39:return O=Array.isArray(y)?y:[y],e.abrupt("return",O.map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];"object"===_typeof(o)&&null!==o||(t[i]=o)}return t})));case 43:return e.prev=43,e.t1=e.catch(0),e.abrupt("return",Cn(e.t1,"COINGECKO"));case 46:case"end":return e.stop()}}),e,null,[[0,43]])}))),Ui.apply(this,arguments)}var qi=ci({category:pi(["protocols","yields","dex","fees"])}),Gi={protocols:"https://api.llama.fi/protocols",yields:"https://yields.llama.fi/pools",dex:"https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true",fees:"https://api.llama.fi/overview/fees?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true&dataType=dailyFees"};function Hi(){return Hi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t=A(u),r=_slicedToArray(t,1),n=r[0],On(qi,{category:n}),a=Gi[n]){e.next=6;break}throw new En("Invalid category: ".concat(n));case 6:return e.next=8,fetch(a);case 8:if((i=e.sent).ok){e.next=11;break}throw new Tn(Sn.Defillama,i.status);case 11:return e.next=13,i.json();case 13:o=e.sent,e.t0=n,e.next="protocols"===e.t0?17:"yields"===e.t0?19:"dex"===e.t0||"fees"===e.t0?21:23;break;case 17:return o=Array.isArray(o)?o.slice(0,500):[],e.abrupt("break",23);case 19:return o=Array.isArray(o.data)?o.data.slice(0,500):[],e.abrupt("break",23);case 21:return o=Array.isArray(o.protocols)?o.protocols.slice(0,500):[],e.abrupt("break",23);case 23:return e.abrupt("return",(Array.isArray(o)?o:[o]).map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];null!==o&&"object"===_typeof(o)||(t[i]=o)}return t})));case 26:return e.prev=26,e.t1=e.catch(0),e.abrupt("return",Cn(e.t1,"DEFILLAMA"));case 29:case"end":return e.stop()}}),e,null,[[0,26]])}))),Hi.apply(this,arguments)}var Zi=fi("type",[ci({type:li("gas"),startDate:mi.optional(),endDate:mi.optional(),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)}),ci({type:pi(["all-txns","token-txns","nft-txns"]),address:ii().nonempty(),startDate:mi.optional(),endDate:mi.optional(),chain:pi(["ethereum","base","gnosis"]),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)})]);function Vi(){return Vi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t=A(h),r=_slicedToArray(t,7),n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],s=r[5],c=void 0===s?1:s,f=r[6],On(Zi,{type:n,chain:a,address:i,startDate:o,endDate:u,page:c,limit:l=void 0===f?10:f}),p=pn[a]){e.next=6;break}throw new En("Invalid chain: ".concat(a));case 6:return d=window.localStorage.getItem(Sn.Etherscan),e.next=9,Ci({type:n,address:i,startDate:o,endDate:u,page:c,offset:l,apiKey:d,functionName:"ETHERSCAN",chainId:p,network:a});case 9:return e.abrupt("return",e.sent);case 12:return e.prev=12,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"ETHERSCAN"));case 15:case"end":return e.stop()}}),e,null,[[0,12]])}))),Vi.apply(this,arguments)}var Yi=ci({contentType:pi(["posts","replies","channels"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)});function Bi(){return Bi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(y),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=void 0===i?0:i,u=r[3],On(Yi,{contentType:n,identifier:a,start:o,end:s=void 0===u?10:u}),c=window.localStorage.getItem(Sn.Firefly),(f=new URL("https://openapi.firefly.land/v1/fileverse/fetch")).searchParams.set("query",a.split(",").map((function(e){return e.trim()})).filter(Boolean).join(",")),l={posts:"farcasterid",replies:"farcasterpostid",channels:"farcasterchannels"},f.searchParams.set("type",l[n]),f.searchParams.set("start",String(o)),f.searchParams.set("end",String(s)),p=Ei({url:f.toString(),serviceName:"Firefly",headers:{"x-api-key":c}}),d=p.URL,h=p.HEADERS,e.next=13,fetch(d,{method:"GET",headers:h});case 13:if((v=e.sent).ok){e.next=16;break}throw new Tn(Sn.Firefly,v.status);case 16:return e.next=18,v.json();case 18:if(m=e.sent,g=m.data,Array.isArray(g)){e.next=22;break}return e.abrupt("return",[]);case 22:return e.abrupt("return",g.map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];null!=o&&"object"===_typeof(o)||(t[i]=o)}return t.platform="farcaster",t})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"FARCASTER"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),Bi.apply(this,arguments)}var Ki=fi("platform",[ci({platform:li("farcaster"),contentType:pi(["posts","replies","channels"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)}),ci({platform:li("lens"),contentType:pi(["posts","replies"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)})]),zi={farcaster:{posts:"farcasterid",replies:"farcasterpostid",channels:"farcasterchannels"},lens:{posts:"lensid",replies:"lenspostid"}};function Xi(){return Xi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(y),r=_slicedToArray(t,5),n=r[0],a=r[1],i=r[2],o=r[3],u=void 0===o?0:o,s=r[4],On(Ki,{platform:n,contentType:a,identifier:i,start:u,end:c=void 0===s?10:s}),f=window.localStorage.getItem(Sn.Firefly),(l=new URL("https://openapi.firefly.land/v1/fileverse/fetch")).searchParams.set("query",i.split(",").map((function(e){return e.trim()})).filter(Boolean).join(",")),l.searchParams.set("type",zi[n][a]),l.searchParams.set("start",String(u)),l.searchParams.set("end",String(c)),p=Ei({url:l.toString(),serviceName:"Firefly",headers:{"x-api-key":f}}),d=p.URL,h=p.HEADERS,e.next=12,fetch(d,{method:"GET",headers:h});case 12:if((v=e.sent).ok){e.next=15;break}throw new Tn(Sn.Firefly,v.status);case 15:return e.next=17,v.json();case 17:if(m=e.sent,g=m.data,Array.isArray(g)){e.next=21;break}return e.abrupt("return",[]);case 21:return e.abrupt("return",g.map((function(e){for(var t={},r=0,a=Object.entries(e);r<a.length;r++){var i=_slicedToArray(a[r],2),o=i[0],u=i[1];"object"===_typeof(u)&&null!==u||(t[o]=u)}return t.platform=n,t})));case 24:return e.prev=24,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"FIREFLY"));case 27:case"end":return e.stop()}}),e,null,[[0,24]])}))),Xi.apply(this,arguments)}function Wi(){return Wi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(p),r=_slicedToArray(t,6),n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],s=void 0===u?1:u,c=r[5],On(Mi,{type:n,address:a,startDate:i,endDate:o,page:s,limit:f=void 0===c?10:c}),l=window.localStorage.getItem(Sn.Gnosisscan),e.next=6,Ci({type:n,address:a,startDate:i,endDate:o,page:s,offset:f,apiKey:l,functionName:"GNOSIS",chainId:pn.gnosis,network:"gnosis"});case 6:return e.abrupt("return",e.sent);case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"GNOSIS"));case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),Wi.apply(this,arguments)}var $i=ci({contentType:pi(["posts","replies"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)});function Qi(){return Qi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(y),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=void 0===i?0:i,u=r[3],On($i,{contentType:n,identifier:a,start:o,end:s=void 0===u?10:u}),c=window.localStorage.getItem(Sn.Firefly),(f=new URL("https://openapi.firefly.land/v1/fileverse/fetch")).searchParams.set("query",a.split(",").map((function(e){return e.trim()})).filter(Boolean).join(",")),l={posts:"lensid",replies:"lenspostid"},f.searchParams.set("type",l[n]),f.searchParams.set("start",String(o)),f.searchParams.set("end",String(s)),p=Ei({url:f.toString(),serviceName:"Firefly",headers:{"x-api-key":c}}),d=p.URL,h=p.HEADERS,e.next=13,fetch(d,{method:"GET",headers:h});case 13:if((v=e.sent).ok){e.next=16;break}throw new Tn(Sn.Firefly,v.status);case 16:return e.next=18,v.json();case 18:if(m=e.sent,g=m.data,Array.isArray(g)){e.next=22;break}return e.abrupt("return",[]);case 22:return e.abrupt("return",g.map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];null!=o&&"object"===_typeof(o)||(t[i]=o)}return t.platform="lens",t})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"LENS"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),Qi.apply(this,arguments)}var Ji=ci({username:ii().nonempty()}),eo=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,a,i,o,u,s,c,f;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",null);case 2:return n="https://api.neynar.com/v2/farcaster/user/search/?q=".concat(t,"&limit=5"),a=Ei({url:n,serviceName:"Neynar",headers:{"x-api-key":r,"x-neynar-experimental":"false"}}),i=a.URL,o=a.HEADERS,e.next=6,fetch(i,{method:"GET",headers:o});case 6:return u=e.sent,e.next=9,u.json();case 9:return s=e.sent,c=s.result?s.result.users:[],f=c.find((function(e){return e.username===t})),e.abrupt("return",f&&f.fid||null);case 13:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),to={fromUsernameToFid:eo};function ro(){return ro=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(d),r=_slicedToArray(t,1),n=r[0],On(Ji,{username:n}),a=window.localStorage.getItem(Sn.Neynar),e.next=6,to.fromUsernameToFid(n,a);case 6:if(i=e.sent){e.next=9;break}throw new En("Invalid username: ".concat(n));case 9:return o="https://api.neynar.com/v2/farcaster/followers?fid=".concat(i),u=Ei({url:o.toString(),serviceName:"Neynar",headers:{"x-api-key":a,"x-neynar-experimental":"false"}}),s=u.URL,c=u.HEADERS,e.next=13,fetch(s,{method:"GET",headers:c});case 13:if((f=e.sent).ok){e.next=16;break}throw new Tn(Sn.Neynar,f.status);case 16:return e.next=18,f.json();case 18:if(l=e.sent,(p=(null==l?void 0:l.users)||[]).length){e.next=22;break}return e.abrupt("return",[]);case 22:return e.abrupt("return",p.map((function(e){var t,r,n=e.user;return{username:n.username,custody_address:n.custody_address,follower_count:n.follower_count,country:(null===(t=n.profile)||void 0===t||null===(t=t.location)||void 0===t||null===(t=t.address)||void 0===t?void 0:t.country)||"",city:(null===(r=n.profile)||void 0===r||null===(r=r.location)||void 0===r||null===(r=r.address)||void 0===r?void 0:r.city)||""}})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"NEYNAR"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),ro.apply(this,arguments)}var no=ci({address:ii().nonempty(),utility:li("txns"),chain:pi(["ethereum","gnosis"]),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10),offset:oi().int().nonnegative().default(0)});function ao(){return ao=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t=A(_),r=_slicedToArray(t,5),n=r[0],a=r[1],i=r[2],o=r[3],u=void 0===o?10:o,s=r[4],On(no,{address:n,utility:a,chain:i,limit:u,offset:c=void 0===s?0:s}),f=window.localStorage.getItem(Sn.Safe),l=hn[i]){e.next=7;break}throw new En("Invalid chain: ".concat(i));case 7:return e.next=9,Si.validateAndGetAddress(n);case 9:return p=e.sent,d="https://api.safe.global/tx-service/".concat(l,"/api/v2/safes/").concat(p,"/multisig-transactions?limit=").concat(u,"&offset=").concat(c),h=Ei({url:d,serviceName:"Etherscan",headers:{Authorization:"Bearer ".concat(f)}}),v=h.URL,m=h.HEADERS,e.next=14,fetch(v,{headers:m});case 14:if((g=e.sent).ok){e.next=17;break}throw new Tn(Sn.Safe,g.status);case 17:return e.next=19,g.json();case 19:if(y=e.sent,Array.isArray(y.results)){e.next=22;break}throw new En("Invalid API response");case 22:return e.abrupt("return",y.results.map((function(e){e.confirmations,e.dataDecoded;return _objectWithoutProperties(e,_excluded)})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"SAFE"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),ao.apply(this,arguments)}var io=ci({graphType:pi(["v3","v3-raw"]),category:pi(["tokens","markets"]),param1:ii().nonempty(),param2:ii().optional()});function oo(){return oo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(f),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=r[3],On(io,{graphType:n,category:a,param1:i,param2:o}),u="".concat("https://onchain-proxy.fileverse.io/third-party")+"?service=uniswap"+"&graphType=".concat(n)+"&category=".concat(a)+"&input1=".concat(encodeURIComponent(i))+(o?"&input2=".concat(encodeURIComponent(o)):""),e.next=7,fetch(u);case 7:if((s=e.sent).ok){e.next=10;break}throw new Tn("UNISWAP",s.status);case 10:return e.next=12,s.json();case 12:if(c=e.sent,!Array.isArray(c)){e.next=15;break}return e.abrupt("return",c.map((function(e){var t={};return Object.entries(e).forEach((function(e){var r=_slicedToArray(e,2),n=r[0],a=r[1];null!==a&&"object"===_typeof(a)||(t[n]=a)})),t})));case 15:return e.abrupt("return",c);case 18:return e.prev=18,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"UNISWAP"));case 21:case"end":return e.stop()}}),e,null,[[0,18]])}))),oo.apply(this,arguments)}function uo(){return uo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(r),e.abrupt("return",new Promise((function(e){e({callSignature:t,responseType:"smart-contract"})})));case 5:return e.prev=5,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"SMARTCONTRACT"));case 8:case"end":return e.stop()}}),e,null,[[0,5]])}))),uo.apply(this,arguments)}var so=ci({query:pi(["organization","proposal","proposals"]),slug:ii()});function co(){return co=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=A(s),r=_slicedToArray(t,2),n=r[0],a=r[1],On(so,{query:n,slug:a}),i="".concat("https://onchain-proxy.fileverse.io/third-party")+"?service=tally"+"&input1=".concat(encodeURIComponent(n))+"&input2=".concat(encodeURIComponent(a)),e.next=7,fetch(i);case 7:if((o=e.sent).ok){e.next=10;break}throw new Tn("TALLY",o.status);case 10:return e.next=12,o.json();case 12:return u=e.sent,e.abrupt("return",u);case 16:return e.prev=16,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"TALLY"));case 19:case"end":return e.stop()}}),e,null,[[0,16]])}))),co.apply(this,arguments)}var fo=ii().regex(/^\s*(\d{1,2})(\s*,\s*\d{1,2}){0,2}\s*$/,"Up to 3 comma-separated hour offsets").refine((function(e){return e.split(",").map((function(e){return+e.trim()})).every((function(e){return e>=1&&e<=24}))}),{message:"Each offset must be between 1 and 24"}),lo=ci({type:li("activity"),input1:ii().nonempty(),input2:ii().optional(),input3:oi().int().min(1).max(100).optional()}),po=ci({type:li("token-holders"),input1:ii().nonempty(),input2:ii().nonempty(),input3:oi().int().min(1).max(500).optional()}),ho=fi("type",[lo,ci({type:li("price"),input1:ii().nonempty(),input2:fo.optional(),input3:ii().optional(),input4:oi().int().min(1).max(500).optional()}),po]);function vo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var a=t?"".concat(t,"_").concat(n):n;if("object"===_typeof(e[n])&&null!==e[n]){if(Array.isArray(e[n]))continue;vo(e[n],a,r)}else r[a]=e[n]}return r}var mo={eth:1,base:8453,polygon:137,arbitrum:42161,optimism:10,gnosis:100,bsc:56,avalanche:43114,fantom:250,scroll:534352,linea:59144,ethereum:1};function go(e,t){try{if(!t)return e;var r=BigInt(e),n=Math.pow(10,t),a=Number(r)/n;return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}).format(a)}catch(t){return console.log({error:t}),e}}var yo=null;function _o(e){return bo.apply(this,arguments)}function bo(){return(bo=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,yo){e.next=10;break}return e.next=4,fetch("https://chainid.network/chains_mini.json");case 4:if((r=e.sent).ok){e.next=7;break}throw new Error("Failed to fetch chains.json");case 7:return e.next=9,r.json();case 9:yo=e.sent;case 10:return n=yo.find((function(e){return e.chainId===t})),e.abrupt("return",n?n.name:t);case 14:return e.prev=14,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,null,[[0,14]])})))).apply(this,arguments)}function ko(){return ko=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,T,I,M,C,O,R,j,D,P=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u=A(P),s=_slicedToArray(u,5),c=s[0],f=s[1],l=s[2],p=s[3],d=s[4],On(ho,{type:c,input1:f,input2:l,input3:p,input4:d}),h="",v=function(e){var t=e.filter((function(e){var t=_slicedToArray(e,2),r=(t[0],t[1]);return void 0!==r&&""!==r})).map((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return"".concat(r,"=").concat(encodeURIComponent(n))}));return t.length?"?".concat(t.join("&")):""},"activity"!==c){e.next=11;break}return e.next=8,Si.validateAndGetAddress(f);case 8:m=e.sent,g=v([["chain_ids",mo[l]||l],["limit",p]]),h="activity/".concat(m).concat(g);case 11:return"price"===c&&(y=v([["chain_ids",mo[f]||f],["historical_prices",l],["limit",d]]),h="token-info/".concat(p||"native").concat(y)),"token-holders"===c&&(_=v([["limit",p]]),h="token-holders/".concat(mo[l]||l,"/").concat(f).concat(_)),b=window.localStorage.getItem(Sn.DuneSim),k="https://api.sim.dune.com/v1/evm/".concat(h),w=Ei({url:k,serviceName:"DuneSim",headers:{"X-Sim-Api-Key":b}}),x=w.URL,S=w.HEADERS,e.next=18,fetch(x,{method:"GET",headers:S});case 18:if((E=e.sent).ok){e.next=26;break}if(400!==E.status){e.next=25;break}return e.next=23,E.json();case 23:throw N=e.sent,new En(N.message);case 25:throw new Tn(Sn.DuneSim,E.status);case 26:return e.next=28,E.json();case 28:T=e.sent,I="activity"===c?null!==(t=null!==(r=null==T?void 0:T.activity)&&void 0!==r?r:T)&&void 0!==t?t:[]:"token-holders"===c?null!==(n=null!==(a=null==T?void 0:T.holders)&&void 0!==a?a:T)&&void 0!==n?n:[]:"price"===c?null!==(i=null!==(o=null==T?void 0:T.tokens)&&void 0!==o?o:T)&&void 0!==i?i:[]:null!=T?T:[],M=Array.isArray(I)?I:[I],C=[],R=_createForOfIteratorHelper(M),e.prev=33,D=_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,p,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(t=j.value)&&t.decimals&&(null!=t&&t.total_supply&&(t.total_supply=go(null==t?void 0:t.total_supply,t.decimals)),null!=t&&t.fully_diluted_value&&(t.fully_diluted_value=go(null==t?void 0:t.fully_diluted_value,t.decimals))),null!=t&&t.first_acquired&&(t.first_acquired=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(t.first_acquired))),t.historical_prices&&t.historical_prices.forEach((function(e){var r="price_"+e.offset_hours+"h",n=e.price_usd;t[r]=n})),"price"===c&&(delete t.chain_id,delete t.decimals,delete t.logo),"activity"!==c){e.next=9;break}return e.next=8,_o(t.chain_id);case 8:t.chain_id=e.sent;case 9:if("token-holders"!==c){e.next=30;break}if(!t.balance){e.next=30;break}if(O){e.next=29;break}return e.prev=12,n=mo[l]||l,a="https://api.sim.dune.com/v1/evm/token-info/".concat(f,"?chain_ids=").concat(n),i=Ei({url:a,serviceName:"DuneSim",headers:{"X-Sim-Api-Key":b}}),o=i.URL,u=i.HEADERS,e.next=18,fetch(o,{method:"GET",headers:u});case 18:return s=e.sent,e.next=21,s.json();case 21:p=e.sent,d=null===(r=p.tokens[0])||void 0===r?void 0:r.decimals,O=d,e.next=29;break;case 26:e.prev=26,e.t0=e.catch(12),console.log(e.t0);case 29:t.balance=go(t.balance,O);case 30:C.push(vo(t));case 31:case"end":return e.stop()}}),e,null,[[12,26]])})),R.s();case 36:if((j=R.n()).done){e.next=40;break}return e.delegateYield(D(),"t0",38);case 38:e.next=36;break;case 40:e.next=45;break;case 42:e.prev=42,e.t1=e.catch(33),R.e(e.t1);case 45:return e.prev=45,R.f(),e.finish(45);case 48:return e.abrupt("return",C);case 51:return e.prev=51,e.t2=e.catch(0),e.abrupt("return",Cn(e.t2,"DUNE"));case 54:case"end":return e.stop()}}),e,null,[[0,51],[33,42,45,48]])}))),ko.apply(this,arguments)}var wo=ci({input1:ii().nonempty(),input2:ii().optional(),input3:ii().optional()}).superRefine((function(e,t){var r,n;_i(e.input1)&&(e.input2||t.addIssue({code:Dn.custom,message:"Chain is required to query token price ",path:["input2"]}),(null===(r=e.input2)||void 0===r||null===(r=r.split(","))||void 0===r?void 0:r.length)>1&&t.addIssue({code:Dn.custom,message:"Token address can query only one chain ",path:["input2"]}),(null===(n=e.input1)||void 0===n?void 0:n.split(",").length)>1&&t.addIssue({code:Dn.custom,message:"You can query a single token address at a time.",path:["input1"]}))}));function xo(){return xo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=A(m),i=_slicedToArray(a,3),o=i[0],u=i[1],s=i[2],o=null===(t=o)||void 0===t?void 0:t.replace(/\s+/g,""),u=null===(r=u)||void 0===r?void 0:r.replace(/\s+/g,""),s=null===(n=s)||void 0===n?void 0:n.replace(/\s+/g,""),On(wo,{input1:o,input2:u,input3:s}),c=window.useLocal?"http://localhost:3000":"https://onchain-proxy.fileverse.io",f="".concat(c)+"/third-party?service=price",l=!1,_i(o)?(f+="&token=".concat(o,"&chain=").concat(u),s&&(f+="&time=".concat(s))):(f+="&coin=".concat(p=o),u?f+="&time=".concat(u):1===p.split(",").length&&(l=!0)),e.next=12,fetch(f);case 12:if(400!==(d=e.sent).status){e.next=18;break}return e.next=16,d.json();case 16:throw h=e.sent,new En(h.message);case 18:if(d.ok){e.next=20;break}throw new Tn("PRICE",d.status);case 20:return e.next=22,d.json();case 22:if(v=e.sent,!l){e.next=25;break}return e.abrupt("return",v[0].price);case 25:return e.abrupt("return",v);case 28:return e.prev=28,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"PRICE"));case 31:case"end":return e.stop()}}),e,null,[[0,28]])}))),xo.apply(this,arguments)}var So=ci({query:pi(["txns","balance"]),addresses:ii().nonempty(),chains:ii(),time:ii().optional()}).superRefine((function(e,t){e.addresses.split(",").length>20&&t.addIssue({code:Dn.custom,message:"Max number of addresses to query is 20",path:["addresses"]})})),Eo=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a,i,o,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.split(","),n=[],a=_createForOfIteratorHelper(r),e.prev=3,a.s();case 5:if((i=a.n()).done){e.next=13;break}return o=i.value,e.next=9,Si.validateAndGetAddress(o);case 9:u=e.sent,n.push(u);case 11:e.next=5;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(3),a.e(e.t0);case 18:return e.prev=18,a.f(),e.finish(18);case 21:return e.abrupt("return",n.join(","));case 22:case"end":return e.stop()}}),e,null,[[3,15,18,21]])})));return function(t){return e.apply(this,arguments)}}();function No(){return No=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=A(m),i=_slicedToArray(a,4),o=i[0],u=i[1],s=i[2],c=i[3],On(So,{addresses:o,chains:u,query:s,time:c}),o=null===(t=o)||void 0===t?void 0:t.replace(/\s+/g,""),u=null===(r=u)||void 0===r?void 0:r.replace(/\s+/g,""),c=null===(n=c)||void 0===n?void 0:n.replace(/\s+/g,""),f="https://onchain-proxy.fileverse.io",e.next=9,Eo(o);case 9:return l=e.sent,p="".concat(f,"/third-party?service=wallet&addresses=").concat(l,"&chains=").concat(u,"&query=").concat(s),c&&(p+="&time=".concat(c)),e.next=14,fetch(p);case 14:if(400!==(d=e.sent).status){e.next=20;break}return e.next=18,d.json();case 18:throw h=e.sent,new En(h.message);case 20:if(d.ok){e.next=22;break}throw new Tn("WALLET",d.status);case 22:return e.next=24,d.json();case 24:return v=e.sent,e.abrupt("return",v);case 28:return e.prev=28,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"WALLET"));case 31:case"end":return e.stop()}}),e,null,[[0,28]])}))),No.apply(this,arguments)}function Ao(){return(Ao=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){setTimeout((function(){e([{Yoo:"gotcha"}])}),1e4)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var To={errors:f,symbols:ht,date:m};e.AAVE=function(){return vi.apply(this,arguments)},e.ABS=function(e){return(e=V(e))instanceof Error?e:Math.abs(e)},e.ACCRINT=function(e,t,r,a,i,u,s){return e=rn(e),t=rn(t),r=rn(r),L(u=nn(u),s=an(s))?o:tn(e)&&tn(t)&&tn(r)?a<=0||i<=0||r<=e?o:(i=i||0)*a*It(e,r,s=s||0):n},e.ACOS=function(e){if((e=V(e))instanceof Error)return e;var t=Math.acos(e);return isNaN(t)&&(t=o),t},e.ACOSH=function(e){if((e=V(e))instanceof Error)return e;var t=Math.log(e+Math.sqrt(e*e-1));return isNaN(t)&&(t=o),t},e.ACOT=function(e){return(e=V(e))instanceof Error?e:Math.atan(1/e)},e.ACOTH=function(e){if((e=V(e))instanceof Error)return e;var t=.5*Math.log((e+1)/(e-1));return isNaN(t)&&(t=o),t},e.AGGREGATE=function(e,t,r,a){if(F(e=V(e),V(e)))return n;switch(e){case 1:return _e(r);case 2:return Ee(r);case 3:return Ne(r);case 4:return Fe(r);case 5:return qe(r);case 6:return lt(r);case 7:return Qe.S(r);case 8:return Qe.P(r);case 9:return dt(r);case 10:return Je.S(r);case 11:return Je.P(r);case 12:return Ue(r);case 13:return Ge.SNGL(r);case 14:return De(r,a);case 15:return $e(r,a);case 16:return Ye.INC(r,a);case 17:return ze.INC(r,a);case 18:return Ye.EXC(r,a);case 19:return ze.EXC(r,a)}},e.AND=function(){for(var e=C(arguments),t=n,r=0;r<e.length;r++){if(e[r]instanceof Error)return e[r];void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&(t===n&&(t=!0),e[r]||(t=!1))}return t},e.ARABIC=function(e){if(null==e)return 0;if(e instanceof Error)return e;if(!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(e))return n;var t=0;return e.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,(function(e){t+={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}[e]})),t},e.ARTEMIS=function(){return"Coming Soon"},e.ASIN=function(e){if((e=V(e))instanceof Error)return e;var t=Math.asin(e);return isNaN(t)&&(t=o),t},e.ASINH=function(e){return(e=V(e))instanceof Error?e:Math.log(e+Math.sqrt(e*e+1))},e.ATAN=function(e){return(e=V(e))instanceof Error?e:Math.atan(e)},e.ATAN2=function(e,t){var r=L(e=V(e),t=V(t));return r||Math.atan2(e,t)},e.ATANH=function(e){if((e=V(e))instanceof Error)return e;var t=Math.log((1+e)/(1-e))/2;return isNaN(t)&&(t=o),t},e.AVEDEV=function(){var e=C(arguments).filter(X);if(0===e.length)return o;var t=Y(e);return t instanceof Error?t:oe.sum(oe(t).subtract(oe.mean(t)).abs()[0])/t.length},e.AVERAGE=_e,e.AVERAGEA=be,e.AVERAGEIF=function(e,t,r){if(arguments.length<=1)return u;if(r=Y(C(r=r||e).filter(X)),e=C(e),r instanceof Error)return r;for(var n=0,a=0,i=void 0===t||"*"===t,o=i?null:E(t+""),s=0;s<e.length;s++){var c=e[s];if(i)a+=r[s],n++;else{var f=[x(c,w)].concat(o);N(f)&&(a+=r[s],n++)}}return a/n},e.AVERAGEIFS=function(){var e=z.apply(void 0,arguments),t=e.reduce((function(e,t){return e+t}),0),r=t/e.length;return isNaN(r)?0:r},e.BASE=function(){return Ri.apply(this,arguments)},e.BESSELI=function(e,t){return F(e=V(e),t=V(t))?n:Rt.besseli(e,t)},e.BESSELJ=function(e,t){return F(e=V(e),t=V(t))?n:Rt.besselj(e,t)},e.BESSELK=function(e,t){return F(e=V(e),t=V(t))?n:Rt.besselk(e,t)},e.BESSELY=function(e,t){return F(e=V(e),t=V(t))?n:Rt.bessely(e,t)},e.BETA=ke,e.BETADIST=Kt,e.BETAINV=zt,e.BIN2DEC=function(e){if(!jt(e))return o;var t=parseInt(e,2),r=e.toString();return 10===r.length&&"1"===r.substring(0,1)?parseInt(r.substring(1),2)-512:t},e.BIN2HEX=function(e,t){if(!jt(e))return o;var r=e.toString();if(10===r.length&&"1"===r.substring(0,1))return(0xfffffffe00+parseInt(r.substring(1),2)).toString(16);var a=parseInt(e,2).toString(16);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.BIN2OCT=function(e,t){if(!jt(e))return o;var r=e.toString();if(10===r.length&&"1"===r.substring(0,1))return(1073741312+parseInt(r.substring(1),2)).toString(8);var a=parseInt(e,2).toString(8);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.BINOM=we,e.BINOMDIST=Xt,e.BITAND=function(e,t){return F(e=V(e),t=V(t))?n:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?o:e&t},e.BITLSHIFT=function(e,t){return F(e=V(e),t=V(t))?n:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?o:t>=0?e<<t:e>>-t},e.BITOR=function(e,t){return F(e=V(e),t=V(t))?n:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?o:e|t},e.BITRSHIFT=function(e,t){return F(e=V(e),t=V(t))?n:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?o:t>=0?e>>t:e<<-t},e.BITXOR=function(e,t){return F(e=V(e),t=V(t))?n:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?o:e^t},e.BLOCKSCOUT=function(){return Di.apply(this,arguments)},e.CEILING=at,e.CEILINGMATH=Wt,e.CEILINGPRECISE=$t,e.CHAR=fe,e.CHIDIST=Qt,e.CHIDISTRT=Jt,e.CHIINV=er,e.CHIINVRT=tr,e.CHISQ=xe,e.CHITEST=rr,e.CHOOSE=function(){if(arguments.length<2)return u;var e=arguments[0];return e<1||e>254||arguments.length<e+1?n:arguments[e]},e.CLEAN=function(e){return F(e)?e:(e=e||"").replace(/[\0-\x1F]/g,"")},e.CODE=le,e.COINGECKO=function(){return Ui.apply(this,arguments)},e.COLUMN=function(e,t){return 2!==arguments.length?u:t<0?o:e instanceof Array&&"number"==typeof t?0!==e.length?oe.col(e,t):void 0:n},e.COLUMNS=function(e){return 1!==arguments.length?u:e instanceof Array?0===e.length?0:oe.cols(e):n},e.COMBIN=it,e.COMBINA=function(e,t){var r=L(e=V(e),t=V(t));return r||(e<t?o:0===e&&0===t?1:it(e+t-1,e-1))},e.COMPLEX=Dt,e.CONCAT=de,e.CONCATENATE=pe,e.CONFIDENCE=Se,e.CONVERT=function(e,t,r){if((e=V(e))instanceof Error)return e;for(var n,a=[["a.u. of action","?",null,"action",!1,!1,105457168181818e-48],["a.u. of charge","e",null,"electric_charge",!1,!1,160217653141414e-33],["a.u. of energy","Eh",null,"energy",!1,!1,435974417757576e-32],["a.u. of length","a?",null,"length",!1,!1,529177210818182e-25],["a.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["a.u. of time","?/Eh",null,"time",!1,!1,241888432650516e-31],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,149597870691667e-25],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["coulomb","C",null,"electric_charge",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,846786664623715e-61],["cubic metre","m3",["m^3"],"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,4168181825.44058],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,7.58660370370369e-8],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,166053886282828e-41],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["degrees Rankine","Rank",null,"temperature",!1,!0,.555555555555556],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["farad","F",null,"electric_capacitance",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519.538],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,105457168181818e-48],["n.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,128808866778687e-35],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,895054210748189e17],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988.110336],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]],i={Yi:["yobi",80,12089258196146292e8,"Yi","yotta"],Zi:["zebi",70,11805916207174113e5,"Zi","zetta"],Ei:["exbi",60,0x1000000000000000,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]},o={Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]},s=null,c=null,f=t,l=r,p=1,d=1,h=0;h<a.length;h++)n=null===a[h][2]?[]:a[h][2],(a[h][1]===f||n.indexOf(f)>=0)&&(s=a[h]),(a[h][1]===l||n.indexOf(l)>=0)&&(c=a[h]);if(null===s){var v=i[t.substring(0,2)],m=o[t.substring(0,1)];"da"===t.substring(0,2)&&(m=["dekao",10,"da"]),v?(p=v[2],f=t.substring(2)):m&&(p=m[1],f=t.substring(m[2].length));for(var g=0;g<a.length;g++)n=null===a[g][2]?[]:a[g][2],(a[g][1]===f||n.indexOf(f)>=0)&&(s=a[g])}if(null===c){var y=i[r.substring(0,2)],_=o[r.substring(0,1)];"da"===r.substring(0,2)&&(_=["dekao",10,"da"]),y?(d=y[2],l=r.substring(2)):_&&(d=_[1],l=r.substring(_[2].length));for(var b=0;b<a.length;b++)n=null===a[b][2]?[]:a[b][2],(a[b][1]===l||n.indexOf(l)>=0)&&(c=a[b])}return null===s||null===c||s[3]!==c[3]?u:e*s[6]*p/(c[6]*d)},e.CORREL=function(e,t){return F(e=Y(C(e)),t=Y(C(t)))?n:oe.corrcoeff(e,t)},e.COS=function(e){return(e=V(e))instanceof Error?e:Math.cos(e)},e.COSH=function(e){return(e=V(e))instanceof Error?e:(Math.exp(e)+Math.exp(-e))/2},e.COT=function(e){return(e=V(e))instanceof Error?e:0===e?r:1/Math.tan(e)},e.COTH=function(e){if((e=V(e))instanceof Error)return e;if(0===e)return r;var t=Math.exp(2*e);return(t+1)/(t-1)},e.COUNT=Ee,e.COUNTA=Ne,e.COUNTBLANK=Ae,e.COUNTIF=function(e,t){if(e=C(e),void 0===t||"*"===t)return e.length;for(var r=0,n=E(t+""),a=0;a<e.length;a++){var i=[x(e[a],w)].concat(n);N(i)&&r++}return r},e.COUNTIFS=function(){for(var e=A(arguments),t=new Array(C(e[0]).length),r=0;r<t.length;r++)t[r]=!0;for(var n=0;n<e.length;n+=2){var a=C(e[n]),i=e[n+1];if(!(void 0===i||"*"===i))for(var o=E(i+""),u=0;u<a.length;u++){var s=[x(a[u],w)].concat(o);t[u]=t[u]&&N(s)}}for(var c=0,f=0;f<t.length;f++)t[f]&&c++;return c},e.COUPDAYS=function(e,t,r,a){if(a=an(a),r=nn(r),L(e=H(e),t=H(t)))return n;if(L(r,a)||e>=t)return o;if(1===a){var i=function(e,t,r){var n=H(t);for(n.setFullYear(e.getFullYear()),n<e&&n.setFullYear(n.getFullYear()+1);n>e;)n.setMonth(n.getMonth()+-12/r);return n}(e,t,r),u=H(i);return u.setMonth(u.getMonth()+12/r),yt(i,u,"D")}var s;switch(a){case 0:case 2:case 4:s=360;break;case 3:s=365;break;default:return o}return s/r},e.COVAR=nr,e.COVARIANCE=Te,e.COVARIANCEP=ar,e.COVARIANCES=ir,e.CRITBINOM=or,e.CSC=function(e){return(e=V(e))instanceof Error?e:0===e?r:1/Math.sin(e)},e.CSCH=function(e){return(e=V(e))instanceof Error?e:0===e?r:2/(Math.exp(e)-Math.exp(-e))},e.CUMIPMT=function(e,t,r,a,i,u){if(F(e=V(e),t=V(t),r=V(r)))return n;if(e<=0||t<=0||r<=0)return o;if(a<1||i<1||a>i)return o;if(0!==u&&1!==u)return o;var s=cn(e,t,r,0,u),c=0;1===a&&(0===u&&(c=-r),a++);for(var f=a;f<=i;f++)c+=1===u?on(e,f-2,s,r,1)-s:on(e,f-1,s,r,0);return c*=e},e.CUMPRINC=function(e,t,r,a,i,u){if(F(e=V(e),t=V(t),r=V(r)))return n;if(e<=0||t<=0||r<=0)return o;if(a<1||i<1||a>i)return o;if(0!==u&&1!==u)return o;var s=cn(e,t,r,0,u),c=0;1===a&&(c=0===u?s+r*e:s,a++);for(var f=a;f<=i;f++)c+=u>0?s-(on(e,f-2,s,r,1)-s)*e:s-on(e,f-1,s,r,0)*e;return c},e.DATE=function(e,t,r){var a;return F(e=V(e),t=V(t),r=V(r))?a=n:(a=new Date(e,t-1,r)).getFullYear()<0&&(a=o),l?h(a):a},e.DATEDIF=yt,e.DATEVALUE=function(e){if("string"!=typeof e)return n;var t=Date.parse(e);if(isNaN(t))return n;var r=new Date(e);return l?h(r):r},e.DAVERAGE=function(e,t,a){if(isNaN(t)&&"string"!=typeof t)return n;var i=en(e,a),o=[];if("string"==typeof t){var u=P(e,t);o=j(e[u])}else o=j(e[t]);var s=0;return T(i,(function(e){s+=o[e]})),0===i.length?r:s/i.length},e.DAY=function(e){var t=H(e);return t instanceof Error?t:t.getDate()},e.DAYS=bt,e.DAYS360=kt,e.DB=function(e,t,r,a,i){if(i=void 0===i?12:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;if(e<0||t<0||r<0||a<0)return o;if(-1===[1,2,3,4,5,6,7,8,9,10,11,12].indexOf(i))return o;if(a>r)return o;if(t>=e)return 0;for(var u=(1-Math.pow(t/e,1/r)).toFixed(3),s=e*u*i/12,c=s,f=0,l=a===r?r-1:a,p=2;p<=l;p++)c+=f=(e-c)*u;return 1===a?s:a===r?(e-c)*u:f},e.DCOUNT=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),Ee(u)},e.DCOUNTA=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),Ne(u)},e.DDB=function(e,t,r,a,i){if(i=void 0===i?2:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;if(e<0||t<0||r<0||a<0||i<=0)return o;if(a>r)return o;if(t>=e)return 0;for(var u=0,s=0,c=1;c<=a;c++)u+=s=Math.min(i/r*(e-u),e-t-u);return s},e.DEC2BIN=function(e,t){if((e=V(e))instanceof Error)return e;if(!/^-?[0-9]{1,3}$/.test(e)||e<-512||e>511)return o;if(e<0)return"1"+ve("0",9-(512+e).toString(2).length)+(512+e).toString(2);var r=parseInt(e,10).toString(2);return void 0===t?r:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=r.length?ve("0",t-r.length)+r:o},e.DEC2HEX=function(e,t){if((e=V(e))instanceof Error)return e;if(!/^-?[0-9]{1,12}$/.test(e)||e<-549755813888||e>549755813887)return o;if(e<0)return(1099511627776+e).toString(16);var r=parseInt(e,10).toString(16);return void 0===t?r:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=r.length?ve("0",t-r.length)+r:o},e.DEC2OCT=function(e,t){if((e=V(e))instanceof Error)return e;if(!/^-?[0-9]{1,9}$/.test(e)||e<-536870912||e>536870911)return o;if(e<0)return(1073741824+e).toString(8);var r=parseInt(e,10).toString(8);return void 0===t?r:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=r.length?ve("0",t-r.length)+r:o},e.DECIMAL=function(e,t){if(arguments.length<2)return u;var r=L(e=e||"0",t=V(t));if(r)return r;if(0===t)return o;var n=parseInt(e,t);return isNaN(n)?o:n},e.DEFILLAMA=function(){return Hi.apply(this,arguments)},e.DEGREES=function(e){return(e=V(e))instanceof Error?e:180*e/Math.PI},e.DELTA=function(e,t){return t=void 0===t?0:t,F(e=V(e),t=V(t))?n:e===t?1:0},e.DEVSQ=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},e.DGET=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];return i=j("string"==typeof t?e[P(e,t)]:e[t]),0===a.length?n:a.length>1?o:i[a[0]]},e.DISC=function(e,t,r,a,i){if(F(e=H(e),t=H(t),r=V(r),a=V(a),i=(i=V(i))||0))return n;if(r<=0||a<=0)return o;if(e>=t)return n;var u,s;switch(i){case 0:u=360,s=kt(e,t,!1);break;case 1:case 3:u=365,s=yt(e,t,"D");break;case 2:u=360,s=yt(e,t,"D");break;case 4:u=360,s=kt(e,t,!0);break;default:return o}return(a-r)/a*u/s},e.DMAX=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=i[a[0]];return T(a,(function(e){u<i[e]&&(u=i[e])})),u},e.DMIN=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=i[a[0]];return T(a,(function(e){u>i[e]&&(u=i[e])})),u},e.DOLLAR=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(e=V(e),isNaN(e))return n;var r={style:"currency",currency:"USD",minimumFractionDigits:t>=0?t:0,maximumFractionDigits:t>=0?t:0},a=(e=pt(e,t)).toLocaleString("en-US",r);return e<0?"$("+a.slice(2)+")":a},e.DOLLARDE=function(e,t){if(F(e=V(e),t=V(t)))return n;if(t<0)return o;if(t>=0&&t<1)return r;t=parseInt(t,10);var a=parseInt(e,10);a+=e%1*Math.pow(10,Math.ceil(Math.log(t)/Math.LN10))/t;var i=Math.pow(10,Math.ceil(Math.log(t)/Math.LN2)+1);return a=Math.round(a*i)/i},e.DOLLARFR=function(e,t){if(F(e=V(e),t=V(t)))return n;if(t<0)return o;if(t>=0&&t<1)return r;t=parseInt(t,10);var a=parseInt(e,10);return a+=e%1*Math.pow(10,-Math.ceil(Math.log(t)/Math.LN10))*t},e.DPRODUCT=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];T(a,(function(e){u.push(i[e])})),u=Jr(u);var s=1;return T(u,(function(e){s*=e})),s},e.DSTDEV=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),u=Jr(u),Qe.S(u)},e.DSTDEVP=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),u=Jr(u),Qe.P(u)},e.DSUM=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),dt(u)},e.DUNE=function(){return ko.apply(this,arguments)},e.DVAR=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),Je.S(u)},e.DVARP=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return T(a,(function(e){u.push(i[e])})),Je.P(u)},e.EDATE=function(e,t){if((e=H(e))instanceof Error)return e;if(isNaN(t))return n;var r=e.getDate();e.setDate(1),t=parseInt(t,10),e.setMonth(e.getMonth()+t);var a=e.getMonth();if(r>28){var i=[31,28,31,30,31,30,31,31,30,31,30,31][a],o=e.getFullYear();1===a&&(o%4==0&&o%100!=0||o%400==0)&&(i=29),r=Math.min(r,i)}return e.setDate(r),l?h(e):e},e.EFFECT=function(e,t){return F(e=V(e),t=V(t))?n:e<=0||t<1?o:(t=parseInt(t,10),Math.pow(1+e/t,t)-1)},e.EOA=function(){return Ii.apply(this,arguments)},e.EOMONTH=function(e,t){if((e=H(e))instanceof Error)return e;if(isNaN(t))return n;t=parseInt(t,10);var r=new Date(e.getFullYear(),e.getMonth()+t+1,0);return l?h(r):r},e.ERF=Pt,e.ERFC=Lt,e.ERFCPRECISE=ur,e.ERFPRECISE=sr,e.ERROR=W,e.ETHERSCAN=function(){return Vi.apply(this,arguments)},e.EVEN=function(e){return(e=V(e))instanceof Error?e:at.MATH(e,-2,-1)},e.EXACT=function(e,t){if(2!==arguments.length)return u;var r=L(e,t);return r||(e=B(e))===(t=B(t))},e.EXP=function(e){return arguments.length<1?u:arguments.length>1?s:(e=V(e))instanceof Error?e:e=Math.exp(e)},e.EXPON=Ie,e.EXPONDIST=cr,e.F=Me,e.FACT=ut,e.FACTDOUBLE=function e(t){if((t=V(t))instanceof Error)return t;var r=Math.floor(t);return r<=0?1:r*e(r-2)},e.FALSE=function(){return!1},e.FARCASTER=function(){return Bi.apply(this,arguments)},e.FDIST=fr,e.FDISTRT=lr,e.FIND=function(e,t,r){if(arguments.length<2)return u;e=B(e),r=void 0===r?0:r;var a=(t=B(t)).indexOf(e,r-1);return-1===a?n:a+1},e.FINV=pr,e.FINVRT=dr,e.FIREFLY=function(){return Xi.apply(this,arguments)},e.FISHER=function(e){return(e=V(e))instanceof Error?e:Math.log((1+e)/(1-e))/2},e.FISHERINV=function(e){if((e=V(e))instanceof Error)return e;var t=Math.exp(2*e);return(t-1)/(t+1)},e.FIXED=he,e.FLOOR=st,e.FLOORMATH=hr,e.FLOORPRECISE=vr,e.FLVURL=function(){return Ao.apply(this,arguments)},e.FORECAST=Ce,e.FREQUENCY=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=e.length,a=t.length,i=[],o=0;o<=a;o++){i[o]=0;for(var u=0;u<r;u++)0===o?e[u]<=t[0]&&(i[0]+=1):o<a?e[u]>t[o-1]&&e[u]<=t[o]&&(i[o]+=1):o===a&&e[u]>t[a-1]&&(i[a]+=1)}return i},e.FTEST=mr,e.FV=on,e.FVSCHEDULE=function(e,t){if(F(e=V(e),t=Y(C(t))))return n;for(var r=t.length,a=e,i=0;i<r;i++)a*=1+t[i];return a},e.GAMMA=Oe,e.GAMMADIST=gr,e.GAMMAINV=yr,e.GAMMALN=Re,e.GAMMALNPRECISE=_r,e.GAUSS=function(e){return(e=V(e))instanceof Error?e:oe.normal.cdf(e,0,1)-.5},e.GCD=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=e.length,r=e[0],n=r<0?-r:r,a=1;a<t;a++){for(var i=e[a],o=i<0?-i:i;n&&o;)n>o?n%=o:o%=n;n+=o}return n},e.GEOMEAN=function(){var e=Y(C(arguments));return e instanceof Error?e:oe.geomean(e)},e.GESTEP=function(e,t){return F(t=t||0,e=V(e))?e:e>=t?1:0},e.GNOSIS=function(){return Wi.apply(this,arguments)},e.GROWTH=function(e,t,r,a){if((e=Y(C(e)))instanceof Error)return e;var i;if(void 0===t)for(t=[],i=1;i<=e.length;i++)t.push(i);if(void 0===r&&(r=t),F(t=Y(C(t)),r=Y(C(r))))return n;void 0===a&&(a=!0);var o,u,s=e.length,c=0,f=0,l=0,p=0;for(i=0;i<s;i++){var d=t[i],h=Math.log(e[i]);c+=d,f+=h,l+=d*h,p+=d*d}c/=s,f/=s,l/=s,p/=s,a?u=f-(o=(l-c*f)/(p-c*c))*c:(o=l/p,u=0);var v=[];for(i=0;i<r.length;i++)v.push(Math.exp(u+o*r[i]));return v},e.HARMEAN=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=e.length,r=0,n=0;n<t;n++)r+=1/e[n];return t/r},e.HEX2BIN=function(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return o;var r=!(10!==e.length||"f"!==e.substring(0,1).toLowerCase()),a=r?parseInt(e,16)-1099511627776:parseInt(e,16);if(a<-512||a>511)return o;if(r)return"1"+ve("0",9-(512+a).toString(2).length)+(512+a).toString(2);var i=a.toString(2);return void 0===t?i:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=i.length?ve("0",t-i.length)+i:o},e.HEX2DEC=function(e){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return o;var t=parseInt(e,16);return t>=549755813888?t-1099511627776:t},e.HEX2OCT=function(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return o;var r=parseInt(e,16);if(r>536870911&&r<0xffe0000000)return o;if(r>=0xffe0000000)return(r-0xffc0000000).toString(8);var a=r.toString(8);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.HLOOKUP=function(e,t,r,n){return se(e,D(t),r,n)},e.HOUR=function(e){return(e=H(e))instanceof Error?e:e.getHours()},e.HYPGEOM=je,e.HYPGEOMDIST=br,e.IF=function(e,t,r){return e instanceof Error?e:(null==(t=!(arguments.length>=2)||t)&&(t=0),null==(r=3===arguments.length&&r)&&(r=0),e?t:r)},e.IFERROR=function(e,t){return Q(e)?t:e},e.IFNA=function(e,t){return e===u?t:e},e.IFS=function(){for(var e=0;e<arguments.length/2;e++)if(arguments[2*e])return arguments[2*e+1];return u},e.IMABS=Ft,e.IMAGINARY=Ut,e.IMARGUMENT=qt,e.IMCONJUGATE=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",0!==r?Dt(t,-r,a):e},e.IMCOS=Gt,e.IMCOSH=Ht,e.IMCOT=function(e){return F(Vt(e),Ut(e))?n:Zt(Gt(e),Yt(e))},e.IMCSC=function(e){return!0===e||!1===e?n:F(Vt(e),Ut(e))?o:Zt("1",Yt(e))},e.IMCSCH=function(e){return!0===e||!1===e?n:F(Vt(e),Ut(e))?o:Zt("1",Bt(e))},e.IMDIV=Zt,e.IMEXP=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);a="i"===a||"j"===a?a:"i";var i=Math.exp(t);return Dt(i*Math.cos(r),i*Math.sin(r),a)},e.IMLN=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.log(Math.sqrt(t*t+r*r)),Math.atan(r/t),a)},e.IMLOG10=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.log(Math.sqrt(t*t+r*r))/Math.log(10),Math.atan(r/t)/Math.log(10),a)},e.IMLOG2=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.log(Math.sqrt(t*t+r*r))/Math.log(2),Math.atan(r/t)/Math.log(2),a)},e.IMPOWER=function(e,t){if(F(t=V(t),Vt(e),Ut(e)))return n;var r=e.substring(e.length-1);r="i"===r||"j"===r?r:"i";var a=Math.pow(Ft(e),t),i=qt(e);return Dt(a*Math.cos(t*i),a*Math.sin(t*i),r)},e.IMPRODUCT=function(){var e=arguments[0];if(!arguments.length)return n;for(var t=1;t<arguments.length;t++){var r=Vt(e),a=Ut(e),i=Vt(arguments[t]),o=Ut(arguments[t]);if(F(r,a,i,o))return n;e=Dt(r*i-a*o,r*o+a*i)}return e},e.IMREAL=Vt,e.IMSEC=function(e){return!0===e||!1===e||F(Vt(e),Ut(e))?n:Zt("1",Gt(e))},e.IMSECH=function(e){return F(Vt(e),Ut(e))?n:Zt("1",Ht(e))},e.IMSIN=Yt,e.IMSINH=Bt,e.IMSQRT=function(e){if(F(Vt(e),Ut(e)))return n;var t=e.substring(e.length-1);t="i"===t||"j"===t?t:"i";var r=Math.sqrt(Ft(e)),a=qt(e);return Dt(r*Math.cos(a/2),r*Math.sin(a/2),t)},e.IMSUB=function(e,t){var r=Vt(e),a=Ut(e),i=Vt(t),o=Ut(t);if(F(r,a,i,o))return n;var u=e.substring(e.length-1),s=t.substring(t.length-1),c="i";return("j"===u||"j"===s)&&(c="j"),Dt(r-i,a-o,c)},e.IMSUM=function(){if(!arguments.length)return n;for(var e=C(arguments),t=e[0],r=1;r<e.length;r++){var a=Vt(t),i=Ut(t),o=Vt(e[r]),u=Ut(e[r]);if(F(a,i,o,u))return n;t=Dt(a+o,i+u)}return t},e.IMTAN=function(e){return!0===e||!1===e||F(Vt(e),Ut(e))?n:Zt(Yt(e),Gt(e))},e.INDEX=function(e,t,r){var i=L(e,t,r);if(i)return i;if(!Array.isArray(e))return n;var o=e.length>0&&!Array.isArray(e[0]);return o&&!r?(r=t,t=1):(r=r||1,t=t||1),r<0||t<0?n:o&&1===t&&r<=e.length?e[r-1]:t<=e.length&&r<=e[t-1].length?e[t-1][r-1]:a},e.INT=function(e){return(e=V(e))instanceof Error?e:Math.floor(e)},e.INTERCEPT=function(e,t){return F(e=Y(e),t=Y(t))?n:e.length!==t.length?u:Ce(0,e,t)},e.IPMT=un,e.IRR=function(e,t){if(t="number"==typeof t?t:void 0===t?.1:V(t),F(e=Y(C(e)),t))return n;for(var r=new Float64Array(e.length),a=!1,i=!1,u=0;u<e.length;u++)r[u]=e[u],r[u]>0&&(a=!0),r[u]<0&&(i=!0);if(!a||!i)return o;var s=new Map,c=function(e){var t=Math.round(1e10*e)/1e10;if(s.has(t))return s.get(t);var n=function(e){e<=-1&&(e=-.999999999);for(var t=r[0],n=1+e,a=1,i=1;i<r.length;i++)a*=n,t+=r[i]/a;return t}(t);return s.set(t,n),n};return function(){for(var e=1e-10,r=t,n=r,a=0;a<1e3;){var i=c(r);if(Math.abs(i)<e)return r;if(a>0&&Math.abs(r-n)<1e-9)break;var o=Math.max(1e-4,Math.abs(1e-4*r)),u=(c(r+o)-i)/o;if(Math.abs(u)<e)break;n=r;var s=i/u,f=Math.max(.1,.5*Math.abs(r));Math.abs(s)>f?r-=Math.sign(s)*f:r-=s,r<=-1&&(r=-.99999999),r>1e3&&(r=1e3),a++}var l,p,d,h=c(r);if(Math.abs(h)<e)return r;if(h>0){for(l=r,p=r+.1;c(p)>0&&p<1e3;)p=2*p+.1;if(p>=1e3)return r}else{for(p=r,l=Math.max(-.99999999,r-.1);c(l)<0&&l>-.99999999;)l=Math.max(-.99999999,l-.1);if(l<=-.99999999)return r}for(var v=0;v<1e3;v++){var m=c(d=(l+p)/2);if(Math.abs(m)<e||Math.abs(p-l)<e)return d;m*c(l)<0?p=d:l=d}return d}()},e.ISBLANK=function(e){return null===e},e.ISDATE=function(e){return!(H(e)instanceof Error)},e.ISERR=$,e.ISERROR=Q,e.ISEVEN=function(e){return!(1&Math.floor(Math.abs(e)))},e.ISLOGICAL=J,e.ISNA=function(e){return e===u},e.ISNONTEXT=function(e){return"string"!=typeof e},e.ISNUMBER=ee,e.ISO=ct,e.ISODD=function(e){return!!(1&Math.floor(Math.abs(e)))},e.ISOWEEKNUM=wt,e.ISPMT=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r),a=V(a))?n:a*e*(t/r-1)},e.ISTEXT=te,e.KURT=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=e.length,n=0,a=0;a<r;a++)n+=Math.pow(e[a]-t,4);return r*(r+1)/((r-1)*(r-2)*(r-3))*(n/=Math.pow(oe.stdev(e,!0),4))-3*(r-1)*(r-1)/((r-2)*(r-3))},e.LARGE=De,e.LCM=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t,r,n,a,i=1;void 0!==(n=e.pop());){if(0===n)return 0;for(;n>1;){if(n%2){for(t=3,r=Math.floor(Math.sqrt(n));t<=r&&n%t;t+=2);a=t<=r?t:n}else a=2;for(n/=a,i*=a,t=e.length;t;e[--t]%a==0&&1==(e[t]/=a)&&e.splice(t,1));}}return i},e.LEFT=function(e,t){var r=L(e,t);return r||(e=B(e),(t=V(t=void 0===t?1:t))instanceof Error||"string"!=typeof e?n:e.substring(0,t))},e.LEN=function(e){return 0===arguments.length?s:e instanceof Error?e:Array.isArray(e)?n:B(e).length},e.LENS=function(){return Qi.apply(this,arguments)},e.LINEST=Pe,e.LN=function(e){return(e=V(e))instanceof Error?e:0===e?o:Math.log(e)},e.LOG=function(e,t){var r=L(e=V(e),t=t?V(t):10);return r||(0===e||0===t?o:Math.log(e)/Math.log(t))},e.LOG10=function(e){return(e=V(e))instanceof Error?e:0===e?o:Math.log(e)/Math.log(10)},e.LOGEST=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;if(e.length!==t.length)return n;for(var r=0;r<e.length;r++)e[r]=Math.log(e[r]);var a=Pe(e,t);return a[0]=Math.round(1e6*Math.exp(a[0]))/1e6,a[1]=Math.round(1e6*Math.exp(a[1]))/1e6,a},e.LOGINV=kr,e.LOGNORM=Le,e.LOGNORMDIST=wr,e.LOGNORMINV=xr,e.LOOKUP=function(e,t,r){t=C(t),r=r?C(r):t;for(var n="number"==typeof e,a=u,i=0;i<t.length;i++){if(t[i]===e)return r[i];if(n&&t[i]<=e||"string"==typeof t[i]&&t[i].localeCompare(e)<0)a=r[i];else if(n&&t[i]>e)return a}return a},e.LOWER=function(e){return 1!==arguments.length?n:F(e=B(e))?e:e.toLowerCase()},e.MATCH=function(e,t,r){if(!e&&0!==e||!t)return u;if(2===arguments.length&&(r=1),!((t=C(t))instanceof Array))return u;if(-1!==r&&0!==r&&1!==r)return u;for(var n,a,i=0;i<t.length;i++)if(1===r){if(t[i]===e)return i+1;t[i]<e&&(a?t[i]>a&&(n=i+1,a=t[i]):(n=i+1,a=t[i]))}else if(0===r){if("string"==typeof e&&"string"==typeof t[i]){var o=e.toLowerCase().replace(/\?/g,".").replace(/\*/g,".*").replace(/~/g,"\\").replace(/\+/g,"\\+").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/\[/g,"\\[").replace(/\]/g,"\\]");if(new RegExp("^"+o+"$").test(t[i].toLowerCase()))return i+1}else if(t[i]===e)return i+1}else if(-1===r){if(t[i]===e)return i+1;t[i]>e&&(a?t[i]<a&&(n=i+1,a=t[i]):(n=i+1,a=t[i]))}return n||u},e.MAX=Fe,e.MAXA=function(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=I(e);return r=r.map((function(e){return null==e?0:e})),0===r.length?0:Math.max.apply(Math,r)},e.MAXIFS=function(){var e=z.apply(void 0,arguments);return 0===e.length?0:Math.max.apply(Math,e)},e.MEDIAN=Ue,e.MEERKAT=function(){return"Coming Soon"},e.MID=function(e,t,r){if(null==t)return n;if(F(t=V(t),r=V(r))||"string"!=typeof e)return r;var a=t-1,i=a+r;return e.substring(a,i)},e.MIN=qe,e.MINA=function(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=I(e);return r=r.map((function(e){return null==e?0:e})),0===r.length?0:Math.min.apply(Math,r)},e.MINIFS=function(){var e=z.apply(void 0,arguments);return 0===e.length?0:Math.min.apply(Math,e)},e.MINUS=function(){var e=A(arguments);if(2!==e.length)return n;var t=e[0],r=e[1];return t instanceof Error||r instanceof Error?t instanceof Error?t:r:"number"!=typeof t||"number"!=typeof r?n:t-r},e.MINUTE=function(e){return(e=H(e))instanceof Error?e:e.getMinutes()},e.MIRR=function(e,t,r){if(F(e=Y(C(e)),t=V(t),r=V(r)))return n;for(var a=e.length,i=[],o=[],u=0;u<a;u++)e[u]<0?i.push(e[u]):o.push(e[u]);var s=-sn(r,o)*Math.pow(1+r,a-1),c=sn(t,i)*(1+t);return Math.pow(s/c,1/(a-1))-1},e.MMULT=function(e,t){return!Array.isArray(e)||!Array.isArray(t)||e.some((function(e){return!e.length}))||t.some((function(e){return!e.length}))||O(e).some((function(e){return"number"!=typeof e}))||O(t).some((function(e){return"number"!=typeof e}))||e[0].length!==t.length?n:Array(e.length).fill(0).map((function(){return Array(t[0].length).fill(0)})).map((function(r,n){return r.map((function(r,a){return e[n].reduce((function(e,r,n){return e+r*t[n][a]}),0)}))}))},e.MOD=function(e,t){var n=L(e=V(e),t=V(t));if(n)return n;if(0===t)return r;var a=Math.abs(e%t);return a=e<0?t-a:a,t>0?a:-a},e.MODE=Ge,e.MODEMULT=Sr,e.MODESNGL=Er,e.MONTH=function(e){return(e=H(e))instanceof Error?e:e.getMonth()+1},e.MROUND=function(e,t){var r=L(e=V(e),t=V(t));return r||(e*t==0?0:e*t<0?o:Math.round(e/t)*t)},e.MULTINOMIAL=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=0,r=1,n=0;n<e.length;n++)t+=e[n],r*=ut(e[n]);return ut(t)/r},e.MUNIT=function(e){return arguments.length>1?u:!(e=parseInt(e))||e<=0?n:Array(e).fill(0).map((function(){return Array(e).fill(0)})).map((function(e,t){return e[t]=1,e}))},e.MYANIMELIST=function(){return"Coming Soon"},e.N=function(e){return ee(e)?e:e instanceof Date?e.getTime():!0===e?1:!1===e?0:Q(e)?e:0},e.NA=function(){return u},e.NEGBINOM=He,e.NEGBINOMDIST=Nr,e.NETWORKDAYS=xt,e.NETWORKDAYSINTL=Ar,e.NETWORKDAYS_INTL=St,e.NEYNAR=function(){return ro.apply(this,arguments)},e.NOMINAL=function(e,t){return F(e=V(e),t=V(t))?n:e<=0||t<1?o:(t=parseInt(t,10),(Math.pow(e+1,1/t)-1)*t)},e.NORM=Ze,e.NORMDIST=Tr,e.NORMINV=Ir,e.NORMSDIST=Mr,e.NORMSINV=Cr,e.NOT=function(e){return"string"==typeof e?n:e instanceof Error?e:!e},e.NOW=function(){return l?h(new Date):new Date},e.NPER=function(e,t,r,a,i){if(i=void 0===i?0:i,a=void 0===a?0:a,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;if(0===e)return-(r+a)/t;var o=t*(1+e*i)-a*e,u=r*e+t*(1+e*i);return Math.log(o/u)/Math.log(1+e)},e.NPV=sn,e.NUMBERVALUE=function(e,t,r){return"number"==typeof(e=X(e)?e:"")?e:"string"!=typeof e?u:(t=void 0===t?".":t,r=void 0===r?",":r,Number(e.replace(t,".").replace(r,"")))},e.OCT2BIN=function(e,t){if(!/^[0-7]{1,10}$/.test(e))return o;var r=!(10!==e.length||"7"!==e.substring(0,1)),a=r?parseInt(e,8)-1073741824:parseInt(e,8);if(a<-512||a>511)return o;if(r)return"1"+ve("0",9-(512+a).toString(2).length)+(512+a).toString(2);var i=a.toString(2);return void 0===t?i:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=i.length?ve("0",t-i.length)+i:o},e.OCT2DEC=function(e){if(!/^[0-7]{1,10}$/.test(e))return o;var t=parseInt(e,8);return t>=536870912?t-1073741824:t},e.OCT2HEX=function(e,t){if(!/^[0-7]{1,10}$/.test(e))return o;var r=parseInt(e,8);if(r>=536870912)return"ff"+(r+3221225472).toString(16);var a=r.toString(16);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.ODD=function(e){if((e=V(e))instanceof Error)return e;var t=Math.ceil(Math.abs(e));return t=1&t?t:t+1,e>=0?t:-t},e.OR=function(){for(var e=C(arguments),t=n,r=0;r<e.length;r++){if(e[r]instanceof Error)return e[r];void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&(t===n&&(t=!1),e[r]&&(t=!0))}return t},e.PDURATION=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:e<=0?o:(Math.log(r)-Math.log(t))/Math.log(1+e)},e.PEARSON=Ve,e.PERCENTILE=Ye,e.PERCENTILEEXC=Or,e.PERCENTILEINC=Rr,e.PERCENTRANK=Be,e.PERCENTRANKEXC=jr,e.PERCENTRANKINC=Dr,e.PERMUT=function(e,t){return F(e=V(e),t=V(t))?n:ut(e)/ut(e-t)},e.PERMUTATIONA=function(e,t){return F(e=V(e),t=V(t))?n:Math.pow(e,t)},e.PHI=function(e){return(e=V(e))instanceof Error?n:Math.exp(-.5*e*e)/2.5066282746310002},e.PI=function(){return Math.PI},e.PMT=cn,e.PNL=function(){var e=_slicedToArray(A(arguments),2),t=e[0],r=e[1],n=function(e){var t=Number(e);if(isNaN(t))throw new Error("Invalid number value: ".concat(e));return t};if("number"==typeof t&&"number"==typeof r)return t-r;if(Array.isArray(t)&&Array.isArray(r)&&"object"!==_typeof(t[0])){for(var a=Math.max(t.length,r.length),i=0,o=0;o<a;o++){i+=(o<t.length?n(t[o]):0)-(o<r.length?n(r[o]):0)}return i}if(Array.isArray(t[0])&&"object"!==_typeof(t[0][0])){for(var u=0,s=Math.max(t.length,r.length),c=0;c<s;c++)for(var f=t[c]||[],l=r[c]||[],p=Math.max(f.length,l.length),d=0;d<p;d++){u+=(d<f.length?n(f[d]):0)-(d<l.length?n(l[d]):0)}return u}if(Array.isArray(t[0][0])){for(var h=0,v=Math.max(t.length,r.length),m=0;m<v;m++)for(var g=t[m]||[],y=r[m]||[],_=Math.max(g.length,y.length),b=0;b<_;b++)for(var k=g[b]||[],w=y[b]||[],x=Math.max(k.length,w.length),S=0;S<x;S++){h+=(S<k.length?n(k[S]):0)-(S<w.length?n(w[S]):0)}return h}throw new Error("Unsupported or mismatched structure")},e.POISSON=Ke,e.POISSONDIST=Pr,e.POLYMARKET=function(){return"Coming Soon"},e.POWER=ft,e.PPMT=function(e,t,r,a,i,o){return i=i||0,o=o||0,F(e=V(e),r=V(r),a=V(a),i=V(i),o=V(o))?n:cn(e,r,a,i,o)-un(e,t,r,a,i,o)},e.PRICE=function(){return xo.apply(this,arguments)},e.PRICEDISC=function(e,t,r,a,i){if(F(e=H(e),t=H(t),r=V(r),a=V(a),i=(i=V(i))||0))return n;if(r<=0||a<=0)return o;if(e>=t)return n;var u,s;switch(i){case 0:u=360,s=kt(e,t,!1);break;case 1:case 3:u=365,s=yt(e,t,"D");break;case 2:u=360,s=yt(e,t,"D");break;case 4:u=360,s=kt(e,t,!0);break;default:return o}return a-r*a*s/u},e.PRIVACYPOOL=function(){return"Coming Soon"},e.PROB=function(e,t,r,a){if(void 0===r)return 0;if(a=void 0===a?r:a,F(e=Y(C(e)),t=Y(C(t)),r=V(r),a=V(a)))return n;if(r===a)return e.indexOf(r)>=0?t[e.indexOf(r)]:0;for(var i=e.sort((function(e,t){return e-t})),o=i.length,u=0,s=0;s<o;s++)i[s]>=r&&i[s]<=a&&(u+=t[e.indexOf(i[s])]);return u},e.PRODUCT=lt,e.PROPER=function(e){return F(e)?e:isNaN(e)&&"number"==typeof e?n:(e=B(e)).replace(/\w\S*/g,(function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}))},e.PV=function(e,t,r,a,i){return a=a||0,i=i||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i))?n:0===e?-r*t-a:((1-Math.pow(1+e,t))/e*r*(1+e*i)-a)/Math.pow(1+e,t)},e.QUARTILE=ze,e.QUARTILEEXC=Lr,e.QUARTILEINC=Fr,e.QUOTIENT=function(e,t){var r=L(e=V(e),t=V(t));return r||parseInt(e/t,10)},e.RADIANS=function(e){return(e=V(e))instanceof Error?e:e*Math.PI/180},e.RAND=function(){return Math.random()},e.RANDBETWEEN=function(e,t){var r=L(e=V(e),t=V(t));return r||e+Math.ceil((t-e+1)*Math.random())-1},e.RANK=Xe,e.RANKAVG=Ur,e.RANKEQ=qr,e.RATE=function(e,t,r,a,i,u){if(u=void 0===u?.1:u,a=void 0===a?0:a,i=void 0===i?0:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i),u=V(u)))return n;var s=1e-10,c=u;i=i?1:0;for(var f=0;f<100;f++){if(c<=-1)return o;var l=void 0,p=void 0;if(l=Math.abs(c)<s?r*(1+e*c)+t*(1+c*i)*e+a:r*(p=Math.pow(1+c,e))+t*(1/c+i)*(p-1)+a,Math.abs(l)<s)return c;var d=void 0;if(Math.abs(c)<s)d=r*e+t*i*e;else{p=Math.pow(1+c,e);var h=e*Math.pow(1+c,e-1);d=r*h+t*(1/c+i)*h+t*(-1/(c*c))*(p-1)}c-=l/d}return c},e.REPLACE=function(e,t,r,a){return F(t=V(t),r=V(r))||"string"!=typeof e||"string"!=typeof a?n:e.substr(0,t-1)+a+e.substr(t-1+r)},e.REPT=ve,e.RIGHT=function(e,t){var r=L(e,t);return r||(e=B(e),(t=V(t=void 0===t?1:t))instanceof Error?t:e.substring(e.length-t))},e.ROMAN=function(e){if((e=V(e))instanceof Error)return e;for(var t=String(e).split(""),r=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],n="",a=3;a--;)n=(r[+t.pop()+10*a]||"")+n;return new Array(+t.join("")+1).join("M")+n},e.ROTKI=function(){return"Coming Soon"},e.ROUND=pt,e.ROUNDDOWN=function(e,t){var r=L(e=V(e),t=V(t));return r||(e>0?1:-1)*Math.floor(Math.abs(e)*Math.pow(10,t))/Math.pow(10,t)},e.ROUNDUP=function(e,t){var r=L(e=V(e),t=V(t));return r||(e>0?1:-1)*Math.ceil(Math.abs(e)*Math.pow(10,t))/Math.pow(10,t)},e.ROW=function(e,t){return 2!==arguments.length?u:t<0?o:e instanceof Array&&"number"==typeof t?0!==e.length?oe.row(e,t):void 0:n},e.ROWS=function(e){return 1!==arguments.length?u:e instanceof Array?0===e.length?0:oe.rows(e):n},e.RRI=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:0===e||0===t?o:Math.pow(r/t,1/e)-1},e.RSQ=function(e,t){return F(e=Y(C(e)),t=Y(C(t)))?n:Math.pow(Ve(e,t),2)},e.SAFE=function(){return ao.apply(this,arguments)},e.SEARCH=function(e,t,r){var a;return"string"!=typeof e||"string"!=typeof t?n:(r=void 0===r?0:r,0===(a=t.toLowerCase().indexOf(e.toLowerCase(),r-1)+1)?n:a)},e.SEC=function(e){return(e=V(e))instanceof Error?e:1/Math.cos(e)},e.SECH=function(e){return(e=V(e))instanceof Error?e:2/(Math.exp(e)+Math.exp(-e))},e.SECOND=function(e){return(e=H(e))instanceof Error?e:e.getSeconds()},e.SERIESSUM=function(e,t,r,a){if(F(e=V(e),t=V(t),r=V(r),a=Y(a)))return n;for(var i=a[0]*Math.pow(e,t),o=1;o<a.length;o++)i+=a[o]*Math.pow(e,t+o*r);return i},e.SIGN=function(e){return(e=V(e))instanceof Error?e:e<0?-1:0===e?0:1},e.SIN=function(e){return(e=V(e))instanceof Error?e:Math.sin(e)},e.SINH=function(e){return(e=V(e))instanceof Error?e:(Math.exp(e)-Math.exp(-e))/2},e.SKEW=We,e.SKEWP=Gr,e.SLN=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:0===r?o:(e-t)/r},e.SLOPE=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(t),a=oe.mean(e),i=t.length,o=0,u=0,s=0;s<i;s++)o+=(t[s]-r)*(e[s]-a),u+=Math.pow(t[s]-r,2);return o/u},e.SMALL=$e,e.SMARTCONTRACT=function(){return uo.apply(this,arguments)},e.SORT=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!e||!Array.isArray(e))return u;if(0===e.length)return 0;var o=V(t);if(!o||o<1)return n;o-=1;var s=V("false"===(null==r?void 0:r.toLowerCase())?-1:1);if(1!==s&&-1!==s)return n;var c=G(a);if("boolean"!=typeof c)return i;var f=M(e),l=c?D(f):f;if(!l.length||!l[0]||o>=l[0].length)return n;var p=function(e){return""===e||null==e},d=l.map((function(e,t){return{row:e,rowIndex:t}}));d.sort((function(e,t){var r=function(e,t){var r,n,a=p(e),i=p(t);if(a&&i)return 0;if(a)return 1;if(i)return-1;var o=V(e),u=V(t),s=Number.isFinite(o),c=Number.isFinite(u);if(s&&c)return o<u?-1:o>u?1:0;var f=(null!==(r=B(e))&&void 0!==r?r:"").toString().toLowerCase(),l=(null!==(n=B(t))&&void 0!==n?n:"").toString().toLowerCase();return f<l?-1:f>l?1:0}(e.row[o],t.row[o]);return 0!==r?r*s:e.rowIndex-t.rowIndex}));var h=d.map((function(e){return e.row}));return c?D(h):h},e.SQRT=function(e){return(e=V(e))instanceof Error?e:e<0?o:Math.sqrt(e)},e.SQRTPI=function(e){return(e=V(e))instanceof Error?e:Math.sqrt(e*Math.PI)},e.STANDARDIZE=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:(e-t)/r},e.STDEV=Qe,e.STDEVA=function(){var e=et.apply(this,arguments);return Math.sqrt(e)},e.STDEVP=Hr,e.STDEVPA=function(){var e=tt.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=o),t},e.STDEVS=Zr,e.STEYX=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(t),a=oe.mean(e),i=t.length,o=0,u=0,s=0,c=0;c<i;c++)o+=Math.pow(e[c]-a,2),u+=(t[c]-r)*(e[c]-a),s+=Math.pow(t[c]-r,2);return Math.sqrt((o-u*u/s)/(i-2))},e.SUBSTITUTE=function(e,t,r,a){if(arguments.length<3)return u;if(e&&t){if(void 0===a)return e.split(t).join(r);if(a=Math.floor(Number(a)),Number.isNaN(a)||a<=0)return n;for(var i=0,o=0;i>-1&&e.indexOf(t,i)>-1;)if(o++,(i=e.indexOf(t,i+1))>-1&&o===a)return e.substring(0,i)+r+e.substring(i+t.length);return e}return e},e.SUBTOTAL=function(e,t){if((e=V(e))instanceof Error)return e;switch(e){case 1:case 101:return _e(t);case 2:case 102:return Ee(t);case 3:case 103:return Ne(t);case 4:case 104:return Fe(t);case 5:case 105:return qe(t);case 6:case 106:return lt(t);case 7:case 107:return Qe.S(t);case 8:case 108:return Qe.P(t);case 9:case 109:return dt(t);case 10:case 110:return Je.S(t);case 11:case 111:return Je.P(t)}},e.SUM=dt,e.SUMIF=function(e,t,r){if(e=C(e),r=r?C(r):e,e instanceof Error)return e;if(null==t||t instanceof Error)return 0;for(var n=0,a="*"===t,i=a?null:E(t+""),o=0;o<e.length;o++){var u=e[o],s=r[o];if(a)n+=u;else{var c=[x(u,w)].concat(i);n+=N(c)?s:0}}return n},e.SUMIFS=function(){return dt(z.apply(void 0,arguments))},e.SUMPRODUCT=function(){if(!arguments||0===arguments.length)return n;for(var e,t,r,a,i=arguments.length+1,o=0,u=0;u<arguments[0].length;u++)if(arguments[0][u]instanceof Array)for(var s=0;s<arguments[0][u].length;s++){for(e=1,t=1;t<i;t++){var c=arguments[t-1][u][s];if(c instanceof Error)return c;if((a=V(c))instanceof Error)return a;e*=a}o+=e}else{for(e=1,t=1;t<i;t++){var f=arguments[t-1][u];if(f instanceof Error)return f;if((r=V(f))instanceof Error)return r;e*=r}o+=e}return o},e.SUMSQ=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=0,r=e.length,n=0;n<r;n++)t+=ee(e[n])?e[n]*e[n]:0;return t},e.SUMX2MY2=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=0,a=0;a<e.length;a++)r+=e[a]*e[a]-t[a]*t[a];return r},e.SUMX2PY2=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;var r=0;e=Y(C(e)),t=Y(C(t));for(var a=0;a<e.length;a++)r+=e[a]*e[a]+t[a]*t[a];return r},e.SUMXMY2=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;var r=0;e=C(e),t=C(t);for(var a=0;a<e.length;a++)r+=Math.pow(e[a]-t[a],2);return r},e.SWITCH=function(){var e;if(arguments.length>0){var t=arguments[0],r=arguments.length-1,a=Math.floor(r/2),i=!1,o=r%2!=0,s=r%2==0?null:arguments[arguments.length-1];if(a)for(var c=0;c<a;c++)if(t===arguments[2*c+1]){e=arguments[2*c+2],i=!0;break}i||(e=o?s:u)}else e=n;return e},e.SYD=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r),a=V(a))?n:0===r||a<1||a>r?o:(e-t)*(r-(a=parseInt(a,10))+1)*2/(r*(r+1))},e.T=me,e.TALLY=function(){return co.apply(this,arguments)},e.TAN=function(e){return(e=V(e))instanceof Error?e:Math.tan(e)},e.TANH=function(e){if((e=V(e))instanceof Error)return e;var t=Math.exp(2*e);return(t-1)/(t+1)},e.TBILLEQ=function(e,t,r){return F(e=H(e),t=H(t),r=V(r))?n:r<=0||e>t||t-e>31536e6?o:365*r/(360-r*kt(e,t,!1))},e.TBILLPRICE=function(e,t,r){return F(e=H(e),t=H(t),r=V(r))?n:r<=0||e>t||t-e>31536e6?o:100*(1-r*kt(e,t,!1)/360)},e.TBILLYIELD=function(e,t,r){return F(e=H(e),t=H(t),r=V(r))?n:r<=0||e>t||t-e>31536e6?o:360*(100-r)/(r*kt(e,t,!1))},e.TDIST=Vr,e.TDISTRT=Yr,e.TEXT=function(e,t){if(void 0===e||e instanceof Error||t instanceof Error)return u;if(e instanceof Date)return e.toISOString().slice(0,10);if(null==t)return"";if("number"==typeof t)return String(t);if("string"!=typeof t)return n;var r=t.startsWith("$")?"$":"",a=t.endsWith("%");return a&&(e*=100),e=(e=he(e,(t=t.replace(/%/g,"").replace(/\$/g,"")).includes(".")?t.split(".")[1].match(/0/g).length:0,!t.includes(","))).startsWith("-")?"-"+r+(e=e.replace("-","")):r+e,a&&(e+="%"),e},e.TEXTJOIN=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),a=2;a<r;a++)n[a-2]=arguments[a];if("boolean"!=typeof t&&(t=G(t)),arguments.length<3)return u;e=null!=e?e:"";var i=C(n),o=t?i.filter((function(e){return e})):i;if(Array.isArray(e)){e=C(e);for(var s=o.map((function(e){return[e]})),c=0,f=0;f<s.length-1;f++)s[f].push(e[c]),++c===e.length&&(c=0);return(o=C(s)).join("")}return o.join(e)},e.TIME=function(e,t,r){if(F(e=V(e),t=V(t),r=V(r)))return n;if(e<0||t<0||r<0)return o;var a=String(e).padStart(2,"0"),i=String(t).padStart(2,"0"),u=String(r).padStart(2,"0");return"".concat(a,":").concat(i,":").concat(u)},e.TIMEVALUE=function(e){return(e=H(e))instanceof Error?e:(3600*e.getHours()+60*e.getMinutes()+e.getSeconds())/86400},e.TINV=Br,e.TODAY=function(){return v(_t(new Date))},e.TRANSPOSE=function(e){return e?D(M(e)):u},e.TREND=function(e,t,r){if(F(e=Y(C(e)),t=Y(C(t)),r=Y(C(r))))return n;var a=Pe(e,t),i=a[0],o=a[1],u=[];return r.forEach((function(e){u.push(i*e+o)})),u},e.TRIM=function(e){return(e=B(e))instanceof Error?e:e.replace(/\s+/g," ").trim()},e.TRIMMEAN=function(e,t){if(F(e=Y(C(e)),t=V(t)))return n;var r,a,i=st(e.length*t,2)/2;return oe.mean((r=j(e.sort((function(e,t){return e-t})),i),a=(a=i)||1,r&&"function"==typeof r.slice?r.slice(0,r.length-a):r))},e.TRUE=function(){return!0},e.TRUNC=function(e,t){var r=L(e=V(e),t=V(t));return r||(e>0?1:-1)*Math.floor(Math.abs(e)*Math.pow(10,t))/Math.pow(10,t)},e.TTEST=Kr,e.TYPE=function(e){return ee(e)?1:te(e)?2:J(e)?4:Q(e)?16:Array.isArray(e)?64:void 0},e.UNICHAR=ge,e.UNICODE=ye,e.UNIQUE=ue,e.UNISWAP=function(){return oo.apply(this,arguments)},e.UPPER=function(e){return(e=B(e))instanceof Error?e:e.toUpperCase()},e.VALUE=function(e){var t=L(e);if(t)return t;if("number"==typeof e)return e;if(X(e)||(e=""),"string"!=typeof e)return n;var r=/(%)$/.test(e)||/^(%)/.test(e);if(""===(e=(e=(e=e.replace(/^[^0-9-]{0,3}/,"")).replace(/[^0-9]{0,3}$/,"")).replace(/[ ,]/g,"")))return 0;var a=Number(e);return isNaN(a)?n:(a=a||0,r&&(a*=.01),a)},e.VAR=Je,e.VARA=et,e.VARP=zr,e.VARPA=tt,e.VARS=Xr,e.VLOOKUP=se,e.WALLET=function(){return No.apply(this,arguments)},e.WEEKDAY=function(e,t){if((e=H(e))instanceof Error)return e;void 0===t&&(t=1);var r=e.getDay();return mt[t][r]},e.WEEKNUM=function(e,t){if((e=H(e))instanceof Error)return e;if(void 0===t&&(t=1),21===t)return wt(e);var r=vt[t],n=new Date(e.getFullYear(),0,1),a=n.getDay()<r?1:0;return n-=24*Math.abs(n.getDay()-r)*60*60*1e3,Math.floor((e-n)/864e5/7+1)+a},e.WEIBULL=rt,e.WEIBULLDIST=Wr,e.WORKDAY=Et,e.WORKDAYINTL=$r,e.WORKDAY_INTL=Nt,e.XIRR=function(e,t,r){if(F(e=Y(C(e)),t=Z(C(t)),r=V(r)))return n;for(var a=function(e,t,r){for(var n=r+1,a=e[0],i=1;i<e.length;i++)a+=e[i]/Math.pow(n,bt(t[i],t[0])/365);return a},i=function(e,t,r){for(var n=r+1,a=0,i=1;i<e.length;i++){var o=bt(t[i],t[0])/365;a-=o*e[i]/Math.pow(n,o+1)}return a},u=!1,s=!1,c=0;c<e.length;c++)e[c]>0&&(u=!0),e[c]<0&&(s=!0);if(!u||!s)return o;var f,l,p,d=r=r||.1,h=!0;do{f=d-(p=a(e,t,d))/i(e,t,d),l=Math.abs(f-d),d=f,h=l>1e-10&&Math.abs(p)>1e-10}while(h);return d},e.XLOOKUP=function(e,t,r,n,a,i,o){var u="true"===n;if(null==e)return new Error("search_key");if(!t)return new Error("lookup_range");if(!r)return new Error("result_range");var s=function(e){if(!Array.isArray(e))return null;if(!Array.isArray(e[0]))return e;var t=e.length,r=e[0].length;return 1===t?e[0]:1===r?e.map((function(e){return e[0]})):null}(t);if(!s)return new Error("lookup_range_single");var c=function(e){if(!Array.isArray(e))return null;if(!Array.isArray(e[0]))return e.map((function(e){return[e]}));return e}(r);if(!c)return new Error("result_range_invalid");if(c.map((function(e){if(e.length!==s.length)return new Error("lookup_range_and_result_range")})),a=void 0!==a?a:new Error("not_found"),o=void 0!==o?o:1,u=void 0!==u&&u,![0,1,-1,2].includes(i=void 0!==i?i:0))return new Error("match_mode_must");if(![1,-1,2,-2].includes(o))return new Error("search_mode_must");if(2===Math.abs(o)&&2===i)return new Error("binary_search_and_wildcard");var f=function(e,t,r,n,a,i,o){var u=-1;switch(a){case 0:u=function(e,t,r){var n="string"==typeof e?e.toLowerCase().trim():e;if(2===Math.abs(r))return function(e,t,r){var n=0,a=t.length-1;for(;n<=a;){var i=Math.floor((n+a)/2),o=t[i],u="string"==typeof o?o.toLowerCase().trim():o;if(u===e)return i;(r?u<e:u>e)?n=i+1:a=i-1}return-1}(n,t,r>0);var a,i=_createForOfIteratorHelper(ce(t.length,r));try{for(i.s();!(a=i.n()).done;){var o=a.value,u=t[o];if(("string"==typeof u?u.toLowerCase().trim():u)===n)return o}}catch(e){i.e(e)}finally{i.f()}return-1}(e,t,i);break;case 1:u=function(e,t,r){var n="number"==typeof e,a="string"==typeof e?e.toLowerCase().trim():e;if(2===Math.abs(r))return function(e,t,r){var n=0,a=t.length-1,i=-1;for(;n<=a;){var o=Math.floor((n+a)/2),u=t[o],s="string"==typeof u?u.toLowerCase().trim():u;if(s===e)return o;r?s>e?(i=o,a=o-1):n=o+1:s<e?(i=o,n=o+1):a=o-1}return i}(a,t,r>0);var i,o=ce(t.length,r),u=-1,s=_createForOfIteratorHelper(o);try{for(s.s();!(i=s.n()).done;){var c=i.value,f=t[c],l="string"==typeof f?f.toLowerCase().trim():f;if(l===a)return c;n&&"number"==typeof f&&f>e?(-1===u||f<t[u])&&(u=c):!n&&"string"==typeof f&&l>a&&(-1===u||l<("string"==typeof t[u]?t[u].toLowerCase().trim():t[u]))&&(u=c)}}catch(e){s.e(e)}finally{s.f()}return u}(e,t,i);break;case-1:u=function(e,t,r){var n="number"==typeof e,a="string"==typeof e?e.toLowerCase().trim():e;if(2===Math.abs(r))return function(e,t,r){var n=0,a=t.length-1,i=-1;for(;n<=a;){var o=Math.floor((n+a)/2),u=t[o],s="string"==typeof u?u.toLowerCase().trim():u;if(s===e)return o;r?s<e?(i=o,n=o+1):a=o-1:s>e?(i=o,a=o-1):n=o+1}return i}(a,t,r>0);var i,o=ce(t.length,r),u=-1,s=_createForOfIteratorHelper(o);try{for(s.s();!(i=s.n()).done;){var c=i.value,f=t[c],l="string"==typeof f?f.toLowerCase().trim():f;if(l===a)return c;n&&"number"==typeof f&&f<e?(-1===u||f>t[u])&&(u=c):!n&&"string"==typeof f&&l<a&&(-1===u||l>("string"==typeof t[u]?t[u].toLowerCase().trim():t[u]))&&(u=c)}}catch(e){s.e(e)}finally{s.f()}return u}(e,t,i);break;case 2:u=function(e,t,r){if("string"!=typeof e)return-1;var n,a=e.toLowerCase().replace(/\*/g,".*").replace(/\?/g,".").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\.\*/g,".*").replace(/\\\./g,"."),i=new RegExp("^".concat(a,"$"),"i"),o=ce(t.length,r),u=_createForOfIteratorHelper(o);try{for(u.s();!(n=u.n()).done;){var s=n.value,c=t[s];if("string"==typeof c&&i.test(c))return s}}catch(e){u.e(e)}finally{u.f()}return-1}(e,t,i)}if(-1===u)return n;return o?r.map((function(e){return e[u]})):r[u]}(e,s,c,a,i,o,u);return f=u?Array.isArray(f)?f.map((function(e){return[e.toString()]})):f:[f]},e.XNPV=function(e,t,r){if(F(e=V(e),t=Y(C(t)),r=Z(C(r))))return n;for(var a=0,i=0;i<t.length;i++)a+=t[i]/Math.pow(1+e,bt(r[i],r[0])/365);return a},e.XOR=function(){for(var e=C(arguments),t=n,r=0;r<e.length;r++){if(e[r]instanceof Error)return e[r];void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&(t===n&&(t=0),e[r]&&t++)}return t===n?t:!!(1&Math.floor(Math.abs(t)))},e.YEAR=function(e){return(e=H(e))instanceof Error?e:e.getFullYear()},e.YEARFRAC=It,e.Z=nt,e.ZTEST=Qr,e.utils=To}));
1
+ /* @fileverse-dev/formulajs v4.4.26 */
2
+ var _excluded=["confirmations","dataDecoded"];function _objectWithoutProperties(e,t){if(null==e)return{};var r,n,a=_objectWithoutPropertiesLoose(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],-1===t.indexOf(r)&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(-1!==t.indexOf(n))continue;r[n]=e[n]}return r}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */_regeneratorRuntime=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",o=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r,n){return Object.defineProperty(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n})}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function c(t,r,n,a){var i=r&&r.prototype instanceof p?r:p,o=Object.create(i.prototype);return s(o,"_invoke",function(t,r,n){var a=1;return function(i,o){if(3===a)throw Error("Generator is already running");if(4===a){if("throw"===i)throw o;return{value:e,done:!0}}for(n.method=i,n.arg=o;;){var u=n.delegate;if(u){var s=k(u,n);if(s){if(s===l)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(1===a)throw a=4,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=3;var c=f(t,r,n);if("normal"===c.type){if(a=n.done?4:2,c.arg===l)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(a=4,n.method="throw",n.arg=c.arg)}}}(t,n,new S(a||[])),!0),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=c;var l={};function p(){}function d(){}function h(){}var v={};s(v,i,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(E([])));g&&g!==r&&n.call(g,i)&&(v=g);var y=h.prototype=p.prototype=Object.create(v);function _(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function r(a,i,o,u){var s=f(e[a],e,i);if("throw"!==s.type){var c=s.arg,l=c.value;return l&&"object"==_typeof(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,o,u)}),(function(e){r("throw",e,o,u)})):t.resolve(l).then((function(e){c.value=e,o(c)}),(function(e){return r("throw",e,o,u)}))}u(s.arg)}var a;s(this,"_invoke",(function(e,n){function i(){return new t((function(t,a){r(e,n,t,a)}))}return a=a?a.then(i,i):i()}),!0)}function k(t,r){var n=r.method,a=t.i[n];if(a===e)return r.delegate=null,"throw"===n&&t.i.return&&(r.method="return",r.arg=e,k(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),l;var i=f(a,t.i,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,l;var o=i.arg;return o?o.done?(r[t.r]=o.value,r.next=t.n,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,l):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,l)}function w(e){this.tryEntries.push(e)}function x(t){var r=t[4]||{};r.type="normal",r.arg=e,t[4]=r}function S(e){this.tryEntries=[[-1]],e.forEach(w,this),this.reset(!0)}function E(t){if(null!=t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(_typeof(t)+" is not iterable")}return d.prototype=h,s(y,"constructor",h),s(h,"constructor",d),d.displayName=s(h,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,s(e,u,"GeneratorFunction")),e.prototype=Object.create(y),e},t.awrap=function(e){return{__await:e}},_(b.prototype),s(b.prototype,o,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,a,i){void 0===i&&(i=Promise);var o=new b(c(e,r,n,a),i);return t.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},_(y),s(y,u,"Generator"),s(y,i,(function(){return this})),s(y,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.unshift(n);return function e(){for(;r.length;)if((n=r.pop())in t)return e.value=n,e.done=!1,e;return e.done=!0,e}},t.values=E,S.prototype={constructor:S,reset:function(t){if(this.prev=this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(x),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0][4];if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e){o.type="throw",o.arg=t,r.next=e}for(var a=r.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],o=i[4],u=this.prev,s=i[1],c=i[2];if(-1===i[0])return n("end"),!1;if(!s&&!c)throw Error("try statement without catch or finally");if(null!=i[0]&&i[0]<=u){if(u<s)return this.method="next",this.arg=e,n(s),!0;if(u<c)return n(c),!1}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n[0]>-1&&n[0]<=this.prev&&this.prev<n[2]){var a=n;break}}a&&("break"===e||"continue"===e)&&a[0]<=t&&t<=a[2]&&(a=null);var i=a?a[4]:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a[2],l):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r[2]===e)return this.complete(r[4],r[3]),x(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r[0]===e){var n=r[4];if("throw"===n.type){var a=n.arg;x(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={i:E(t),r:r,n:n},"next"===this.method&&(this.arg=e),l}},t}function asyncGeneratorStep(e,t,r,n,a,i,o){try{var u=e[i](o),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,a)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var i=e.apply(t,r);function o(e){asyncGeneratorStep(i,n,a,o,u,"next",e)}function u(e){asyncGeneratorStep(i,n,a,o,u,"throw",e)}o(void 0)}))}}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _defineProperty(e,t,r){return(t=_toPropertyKey(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _defineProperties(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_toPropertyKey(n.key),n)}}function _createClass(e,t,r){return t&&_defineProperties(e.prototype,t),r&&_defineProperties(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==_typeof(t)?t:t+""}function _toPrimitive(e,t){if("object"!=_typeof(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=_typeof(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _callSuper(e,t,r){return t=_getPrototypeOf(t),_possibleConstructorReturn(e,_isNativeReflectConstruct()?Reflect.construct(t,r||[],_getPrototypeOf(e).constructor):t.apply(e,r))}function _possibleConstructorReturn(e,t){if(t&&("object"==_typeof(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(e)}function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&_setPrototypeOf(e,t)}function _wrapNativeSuper(e){var t="function"==typeof Map?new Map:void 0;return _wrapNativeSuper=function(e){if(null===e||!_isNativeFunction(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return _construct(e,arguments,_getPrototypeOf(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),_setPrototypeOf(r,e)},_wrapNativeSuper(e)}function _construct(e,t,r){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var n=[null];n.push.apply(n,t);var a=new(e.bind.apply(e,n));return r&&_setPrototypeOf(a,r.prototype),a}function _isNativeReflectConstruct(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(_isNativeReflectConstruct=function(){return!!e})()}function _isNativeFunction(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}function _setPrototypeOf(e,t){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},_setPrototypeOf(e,t)}function _getPrototypeOf(e){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},_getPrototypeOf(e)}function _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,a=function(){};return{s:a,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,o=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){u=!0,i=e},f:function(){try{o||null==r.return||r.return()}finally{if(u)throw i}}}}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,a,i,o,u=[],s=!0,c=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==t);s=!0);}catch(e){c=!0,a=e}finally{try{if(!s&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(c)throw a}}return u}}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).formulajs={})}(this,(function(e){"use strict";var t=new Error("#NULL!"),r=new Error("#DIV/0!"),n=new Error("#VALUE!"),a=new Error("#REF!"),i=new Error("#NAME?"),o=new Error("#NUM!"),u=new Error("#N/A"),s=new Error("#ERROR!"),c=new Error("#GETTING_DATA"),f=Object.freeze({__proto__:null,data:c,div0:r,error:s,na:u,name:i,nil:t,num:o,ref:a,value:n}),l=!1,p=new Date(Date.UTC(1900,0,1));function d(e){e<60&&(e+=1);var t=Math.floor(e-25569),r=new Date(1e3*(86400*t)),n=e-Math.floor(e)+1e-7,a=Math.floor(86400*n),i=a%60;a-=i;var o=Math.floor(a/3600),u=Math.floor(a/60)%60,s=r.getUTCDate(),c=r.getUTCMonth();return e>=60&&e<61&&(s=29,c=1),new Date(r.getUTCFullYear(),c,s,o,u,i)}function h(e){var t=e>-22038912e5?2:1;return Math.ceil((e-p)/864e5)+t}function v(e){var t=String(e.getDate()).padStart(2,"0"),r=String(e.getMonth()+1).padStart(2,"0"),n=e.getFullYear();return"".concat(t,"/").concat(r,"/").concat(n)}var m=Object.freeze({__proto__:null,dateToSerial:h,formatDate:v,get returnSerial(){return l},serialToDate:d,useDate:function(){l=!1},useSerial:function(){l=!0}}),g=[">",">=","<","<=","=","<>"],y="operator",_="literal",b=[y,_],k=y,w=_;function x(e,t){if(-1===b.indexOf(t))throw new Error("Unsupported token type: "+t);return{value:e,type:t}}function S(e){for(var t="",r=[],n=0;n<e.length;n++){var a=e[n];0===n&&g.indexOf(a)>=0?r.push(x(a,k)):t+=a}return t.length>0&&r.push(x(function(e){return"string"!=typeof e||/^\d+(\.\d+)?$/.test(e)&&(e=-1===e.indexOf(".")?parseInt(e,10):parseFloat(e)),e}(t),w)),r.length>0&&r[0].type!==k&&r.unshift(x("=",k)),r}function E(e){return S(function(e){for(var t=e.length,r=[],n=0,a="",i="";n<t;){var o=e.charAt(n);switch(o){case">":case"<":case"=":i+=o,a.length>0&&(r.push(a),a="");break;default:i.length>0&&(r.push(i),i=""),a+=o}n++}return a.length>0&&r.push(a),i.length>0&&r.push(i),r}(e))}var N=function(e){for(var t,r=[],n=0;n<e.length;n++){var a=e[n];switch(a.type){case k:t=a.value;break;case w:r.push(a.value)}}return function(e,t){var r=!1;switch(t){case">":r=e[0]>e[1];break;case">=":r=e[0]>=e[1];break;case"<":r=e[0]<e[1];break;case"<=":r=e[0]<=e[1];break;case"=":r=e[0]==e[1];break;case"<>":r=e[0]!=e[1]}return r}(r,t)};function T(e){var t=[];return A(e,(function(e){t.push(e)})),t}function A(e,t){for(var r=-1,n=e.length;++r<n&&!1!==t(e[r],r,e););return e}function I(e){for(var t,r=e.length;r--;)if("number"!=typeof(t=e[r]))if(!0!==t)if(!1!==t){if("string"==typeof t){var n=V(t);e[r]=n instanceof Error?0:n}}else e[r]=0;else e[r]=1;return e}function M(e,t){if(!e)return n;e.every((function(e){return Array.isArray(e)}))&&0!==e.length||(e=[_toConsumableArray(e)]),e.map((function(t,r){t.map((function(t,n){t||(e[r][n]=0)}))}));var r=e.reduce((function(t,r,n){return r.length>e[t].length?n:t}),0),a=e[r].length;return e.map((function(e){return[].concat(_toConsumableArray(e),_toConsumableArray(Array(a-e.length).fill(0)))}))}function C(){var e,t;if(1===arguments.length){var r=arguments[0];e=null!=(t=r)&&"number"==typeof t.length&&"string"!=typeof t?T.apply(null,arguments):[r]}else e=Array.from(arguments);for(;!R(e);)e=O(e);return e}function O(e){return e&&e.reduce?e.reduce((function(e,t){var r=Array.isArray(e),n=Array.isArray(t);return r&&n?e.concat(t):r?(e.push(t),e):n?[e].concat(t):[e,t]})):[e]}function R(e){if(!e)return!1;for(var t=0;t<e.length;++t)if(Array.isArray(e[t]))return!1;return!0}function j(e,t){return t=t||1,e&&"function"==typeof e.slice?e.slice(t):e}function D(e){return e?e[0].map((function(t,r){return e.map((function(e){return e[r]}))})):n}function P(e,t){var r=null;return A(e,(function(e,n){if(e[0]===t)return r=n,!1})),null==r?n:r}function L(){for(var e=0;e<arguments.length;e++)if(arguments[e]instanceof Error)return arguments[e]}function F(){for(var e=arguments.length;e--;)if(arguments[e]instanceof Error)return!0;return!1}function U(e){var t=1e14;return Math.round(e*t)/t}function q(){return C.apply(null,arguments).filter((function(e){return"number"==typeof e}))}function G(e){if("boolean"==typeof e)return e;if(e instanceof Error)return e;if("number"==typeof e)return 0!==e;if("string"==typeof e){var t=e.toUpperCase();if("TRUE"===t)return!0;if("FALSE"===t)return!1}return e instanceof Date&&!isNaN(e)||n}function H(e){if(!isNaN(e)){if(e instanceof Date)return new Date(e);var t=parseFloat(e);return t<0||t>=2958466?o:d(t)}if("string"==typeof e){if(/^\d{4}-\d{1,2}-\d{1,2}$/.test(e))return new Date(e+"T00:00:00.000");var r=/^(\d{1,2})\/(\d{1,2})\/(\d{4})$/.exec(e);if(r){var a=_slicedToArray(r.map(Number),4),i=a[1],u=a[2],s=a[3],c=new Date(s,u-1,i);if(!isNaN(c))return c}if(/^\d{1,2}:\d{2}(:\d{2})?$/.test(e)){var f=_slicedToArray(e.split(":").map(Number),3),l=f[0],p=f[1],h=f[2],v=void 0===h?"0":h,m=new Date;return m.setHours(l,p,v,0),m}var g=/^(\d{1,2}):(\d{2})\s*(AM|PM)$/i.exec(e);if(g){var y=_slicedToArray(g,4),_=y[1],b=y[2],k=y[3];_=parseInt(_),b=parseInt(b),"PM"===k.toUpperCase()&&12!==_&&(_+=12),"AM"===k.toUpperCase()&&12===_&&(_=0);var w=new Date;return w.setHours(_,b,0,0),w}var x=new Date(e);if(!isNaN(x))return x}return n}function Z(e){for(var t,r=e.length;r--;){if((t=H(e[r]))===n)return t;e[r]=t}return e}function V(e){return e instanceof Error?e:null==e?0:("boolean"==typeof e&&(e=+e),isNaN(e)||""===e?n:parseFloat(e))}function Y(e){var t,r;if(!e||0===(t=e.length))return n;for(;t--;){if(e[t]instanceof Error)return e[t];if((r=V(e[t]))instanceof Error)return r;e[t]=r}return e}function B(e){return e instanceof Error?e:null==e?"":e.toString()}function K(){for(var e=arguments.length;e--;)if("string"==typeof arguments[e])return!0;return!1}function z(){var e=T(arguments),t=Y(C(e.shift()));if(t instanceof Error)return t;for(var r=e,n=r.length/2,a=0;a<n;a++)r[2*a]=C(r[2*a]);for(var i=[],o=0;o<t.length;o++){for(var u=!1,s=0;s<n;s++){var c=r[2*s][o],f=r[2*s+1],l=!1;if(void 0===f||"*"===f)l=!0;else{var p=E(f+""),d=[x(c,w)].concat(p);l=N(d)}if(!l){u=!1;break}u=!0}u&&i.push(t[o])}return i}function X(e){return null!=e}var W={};function $(e){return[n,a,r,o,i,t].indexOf(e)>=0||"number"==typeof e&&(isNaN(e)||!isFinite(e))}function Q(e){return $(e)||e===u}function J(e){return!0===e||!1===e}function ee(e){return"number"==typeof e&&!isNaN(e)&&isFinite(e)}function te(e){return"string"==typeof e}function re(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}W.TYPE=function(e){switch(e){case t:return 1;case r:return 2;case n:return 3;case a:return 4;case i:return 5;case o:return 6;case u:return 7;case c:return 8}return u};var ne,ae={exports:{}};var ie=(ne||(ne=1,function(e){e.exports=function(){var e=function(e,t){var r=Array.prototype.concat,n=Array.prototype.slice,a=Object.prototype.toString;function i(t,r){var n=t>r?t:r;return e.pow(10,17-~~(e.log(n>0?n:-n)*e.LOG10E))}var o=Array.isArray||function(e){return"[object Array]"===a.call(e)};function u(e){return"[object Function]"===a.call(e)}function s(e){return"number"==typeof e&&e-e==0}function c(e){return r.apply([],e)}function f(){return new f._init(arguments)}function l(){return 0}function p(){return 1}function d(e,t){return e===t?1:0}f.fn=f.prototype,f._init=function(e){if(o(e[0]))if(o(e[0][0])){u(e[1])&&(e[0]=f.map(e[0],e[1]));for(var t=0;t<e[0].length;t++)this[t]=e[0][t];this.length=e[0].length}else this[0]=u(e[1])?f.map(e[0],e[1]):e[0],this.length=1;else if(s(e[0]))this[0]=f.seq.apply(null,e),this.length=1;else{if(e[0]instanceof f)return f(e[0].toArray());this[0]=[],this.length=1}return this},f._init.prototype=f.prototype,f._init.constructor=f,f.utils={calcRdx:i,isArray:o,isFunction:u,isNumber:s,toVector:c},f._random_fn=e.random,f.setRandom=function(e){if("function"!=typeof e)throw new TypeError("fn is not a function");f._random_fn=e},f.extend=function(e){var t,r;if(1===arguments.length){for(r in e)f[r]=e[r];return this}for(t=1;t<arguments.length;t++)for(r in arguments[t])e[r]=arguments[t][r];return e},f.rows=function(e){return e.length||1},f.cols=function(e){return e[0].length||1},f.dimensions=function(e){return{rows:f.rows(e),cols:f.cols(e)}},f.row=function(e,t){return o(t)?t.map((function(t){return f.row(e,t)})):e[t]},f.rowa=function(e,t){return f.row(e,t)},f.col=function(e,t){if(o(t)){var r=f.arange(e.length).map((function(){return new Array(t.length)}));return t.forEach((function(t,n){f.arange(e.length).forEach((function(a){r[a][n]=e[a][t]}))})),r}for(var n=new Array(e.length),a=0;a<e.length;a++)n[a]=[e[a][t]];return n},f.cola=function(e,t){return f.col(e,t).map((function(e){return e[0]}))},f.diag=function(e){for(var t=f.rows(e),r=new Array(t),n=0;n<t;n++)r[n]=[e[n][n]];return r},f.antidiag=function(e){for(var t=f.rows(e)-1,r=new Array(t),n=0;t>=0;t--,n++)r[n]=[e[n][t]];return r},f.transpose=function(e){var t,r,n,a,i,u=[];for(o(e[0])||(e=[e]),r=e.length,n=e[0].length,i=0;i<n;i++){for(t=new Array(r),a=0;a<r;a++)t[a]=e[a][i];u.push(t)}return 1===u.length?u[0]:u},f.map=function(e,t,r){var n,a,i,u,s;for(o(e[0])||(e=[e]),a=e.length,i=e[0].length,u=r?e:new Array(a),n=0;n<a;n++)for(u[n]||(u[n]=new Array(i)),s=0;s<i;s++)u[n][s]=t(e[n][s],n,s);return 1===u.length?u[0]:u},f.cumreduce=function(e,t,r){var n,a,i,u,s;for(o(e[0])||(e=[e]),a=e.length,i=e[0].length,u=r?e:new Array(a),n=0;n<a;n++)for(u[n]||(u[n]=new Array(i)),i>0&&(u[n][0]=e[n][0]),s=1;s<i;s++)u[n][s]=t(u[n][s-1],e[n][s]);return 1===u.length?u[0]:u},f.alter=function(e,t){return f.map(e,t,!0)},f.create=function(e,t,r){var n,a,i=new Array(e);for(u(t)&&(r=t,t=e),n=0;n<e;n++)for(i[n]=new Array(t),a=0;a<t;a++)i[n][a]=r(n,a);return i},f.zeros=function(e,t){return s(t)||(t=e),f.create(e,t,l)},f.ones=function(e,t){return s(t)||(t=e),f.create(e,t,p)},f.rand=function(e,t){return s(t)||(t=e),f.create(e,t,f._random_fn)},f.identity=function(e,t){return s(t)||(t=e),f.create(e,t,d)},f.symmetric=function(e){var t,r,n=e.length;if(e.length!==e[0].length)return!1;for(t=0;t<n;t++)for(r=0;r<n;r++)if(e[r][t]!==e[t][r])return!1;return!0},f.clear=function(e){return f.alter(e,l)},f.seq=function(e,t,r,n){u(n)||(n=!1);var a,o=[],s=i(e,t),c=(t*s-e*s)/((r-1)*s),f=e;for(a=0;f<=t&&a<r;f=(e*s+c*s*++a)/s)o.push(n?n(f,a):f);return o},f.arange=function(e,r,n){var a,i=[];if(n=n||1,r===t&&(r=e,e=0),e===r||0===n)return[];if(e<r&&n<0)return[];if(e>r&&n>0)return[];if(n>0)for(a=e;a<r;a+=n)i.push(a);else for(a=e;a>r;a+=n)i.push(a);return i},f.slice=function(){function e(e,r,n,a){var i,o=[],u=e.length;if(r===t&&n===t&&a===t)return f.copy(e);if(a=a||1,(r=(r=r||0)>=0?r:u+r)===(n=(n=n||e.length)>=0?n:u+n)||0===a)return[];if(r<n&&a<0)return[];if(r>n&&a>0)return[];if(a>0)for(i=r;i<n;i+=a)o.push(e[i]);else for(i=r;i>n;i+=a)o.push(e[i]);return o}function r(t,r){var n,a;return s((r=r||{}).row)?s(r.col)?t[r.row][r.col]:e(f.rowa(t,r.row),(n=r.col||{}).start,n.end,n.step):s(r.col)?e(f.cola(t,r.col),(a=r.row||{}).start,a.end,a.step):(a=r.row||{},n=r.col||{},e(t,a.start,a.end,a.step).map((function(t){return e(t,n.start,n.end,n.step)})))}return r}(),f.sliceAssign=function(r,n,a){var i,o;if(s(n.row)){if(s(n.col))return r[n.row][n.col]=a;n.col=n.col||{},n.col.start=n.col.start||0,n.col.end=n.col.end||r[0].length,n.col.step=n.col.step||1,i=f.arange(n.col.start,e.min(r.length,n.col.end),n.col.step);var u=n.row;return i.forEach((function(e,t){r[u][e]=a[t]})),r}if(s(n.col)){n.row=n.row||{},n.row.start=n.row.start||0,n.row.end=n.row.end||r.length,n.row.step=n.row.step||1,o=f.arange(n.row.start,e.min(r[0].length,n.row.end),n.row.step);var c=n.col;return o.forEach((function(e,t){r[e][c]=a[t]})),r}return a[0].length===t&&(a=[a]),n.row.start=n.row.start||0,n.row.end=n.row.end||r.length,n.row.step=n.row.step||1,n.col.start=n.col.start||0,n.col.end=n.col.end||r[0].length,n.col.step=n.col.step||1,o=f.arange(n.row.start,e.min(r.length,n.row.end),n.row.step),i=f.arange(n.col.start,e.min(r[0].length,n.col.end),n.col.step),o.forEach((function(e,t){i.forEach((function(n,i){r[e][n]=a[t][i]}))})),r},f.diagonal=function(e){var t=f.zeros(e.length,e.length);return e.forEach((function(e,r){t[r][r]=e})),t},f.copy=function(e){return e.map((function(e){return s(e)?e:e.map((function(e){return e}))}))};var h=f.prototype;return h.length=0,h.push=Array.prototype.push,h.sort=Array.prototype.sort,h.splice=Array.prototype.splice,h.slice=Array.prototype.slice,h.toArray=function(){return this.length>1?n.call(this):n.call(this)[0]},h.map=function(e,t){return f(f.map(this,e,t))},h.cumreduce=function(e,t){return f(f.cumreduce(this,e,t))},h.alter=function(e){return f.alter(this,e),this},function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(t){var r,n=this;return t?(setTimeout((function(){t.call(n,h[e].call(n))})),this):(r=f[e](this),o(r)?f(r):r)}}(e[t])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(t,r){var n=this;return r?(setTimeout((function(){r.call(n,h[e].call(n,t))})),this):f(f[e](this,t))}}(e[t])}("row col".split(" ")),function(e){for(var t=0;t<e.length;t++)!function(e){h[e]=function(){return f(f[e].apply(null,arguments))}}(e[t])}("create zeros ones rand identity".split(" ")),f}(Math);return function(e,t){var r=e.utils.isFunction;function n(e,t){return e-t}function a(e,r,n){return t.max(r,t.min(e,n))}e.sum=function(e){for(var t=0,r=e.length;--r>=0;)t+=e[r];return t},e.sumsqrd=function(e){for(var t=0,r=e.length;--r>=0;)t+=e[r]*e[r];return t},e.sumsqerr=function(t){for(var r,n=e.mean(t),a=0,i=t.length;--i>=0;)a+=(r=t[i]-n)*r;return a},e.sumrow=function(e){for(var t=0,r=e.length;--r>=0;)t+=e[r];return t},e.product=function(e){for(var t=1,r=e.length;--r>=0;)t*=e[r];return t},e.min=function(e){for(var t=e[0],r=0;++r<e.length;)e[r]<t&&(t=e[r]);return t},e.max=function(e){for(var t=e[0],r=0;++r<e.length;)e[r]>t&&(t=e[r]);return t},e.unique=function(e){for(var t={},r=[],n=0;n<e.length;n++)t[e[n]]||(t[e[n]]=!0,r.push(e[n]));return r},e.mean=function(t){return e.sum(t)/t.length},e.meansqerr=function(t){return e.sumsqerr(t)/t.length},e.geomean=function(r){var n=r.map(t.log),a=e.mean(n);return t.exp(a)},e.median=function(e){var t=e.length,r=e.slice().sort(n);return 1&t?r[t/2|0]:(r[t/2-1]+r[t/2])/2},e.cumsum=function(t){return e.cumreduce(t,(function(e,t){return e+t}))},e.cumprod=function(t){return e.cumreduce(t,(function(e,t){return e*t}))},e.diff=function(e){var t,r=[],n=e.length;for(t=1;t<n;t++)r.push(e[t]-e[t-1]);return r},e.rank=function(e){var t,r=[],a={};for(t=0;t<e.length;t++)a[s=e[t]]?a[s]++:(a[s]=1,r.push(s));var i=r.sort(n),o={},u=1;for(t=0;t<i.length;t++){var s,c=a[s=i[t]],f=(u+(u+c-1))/2;o[s]=f,u+=c}return e.map((function(e){return o[e]}))},e.mode=function(e){var t,r=e.length,a=e.slice().sort(n),i=1,o=0,u=0,s=[];for(t=0;t<r;t++)a[t]===a[t+1]?i++:(i>o?(s=[a[t]],o=i,u=0):i===o&&(s.push(a[t]),u++),i=1);return 0===u?s[0]:s},e.range=function(t){return e.max(t)-e.min(t)},e.variance=function(t,r){return e.sumsqerr(t)/(t.length-(r?1:0))},e.pooledvariance=function(t){return t.reduce((function(t,r){return t+e.sumsqerr(r)}),0)/(t.reduce((function(e,t){return e+t.length}),0)-t.length)},e.deviation=function(t){for(var r=e.mean(t),n=t.length,a=new Array(n),i=0;i<n;i++)a[i]=t[i]-r;return a},e.stdev=function(r,n){return t.sqrt(e.variance(r,n))},e.pooledstdev=function(r){return t.sqrt(e.pooledvariance(r))},e.meandev=function(r){for(var n=e.mean(r),a=[],i=r.length-1;i>=0;i--)a.push(t.abs(r[i]-n));return e.mean(a)},e.meddev=function(r){for(var n=e.median(r),a=[],i=r.length-1;i>=0;i--)a.push(t.abs(r[i]-n));return e.median(a)},e.coeffvar=function(t){return e.stdev(t)/e.mean(t)},e.quartiles=function(e){var r=e.length,a=e.slice().sort(n);return[a[t.round(r/4)-1],a[t.round(r/2)-1],a[t.round(3*r/4)-1]]},e.quantiles=function(e,r,i,o){var u,s,c,f,l,p=e.slice().sort(n),d=[r.length],h=e.length;for(void 0===i&&(i=3/8),void 0===o&&(o=3/8),u=0;u<r.length;u++)c=h*(s=r[u])+(i+s*(1-i-o)),f=t.floor(a(c,1,h-1)),l=a(c-f,0,1),d[u]=(1-l)*p[f-1]+l*p[f];return d},e.percentile=function(e,t,r){var a=e.slice().sort(n),i=t*(a.length+(r?1:-1))+(r?0:1),o=parseInt(i),u=i-o;return o+1<a.length?a[o-1]+u*(a[o]-a[o-1]):a[o-1]},e.percentileOfScore=function(e,t,r){var n,a,i=0,o=e.length,u=!1;for("strict"===r&&(u=!0),a=0;a<o;a++)n=e[a],(u&&n<t||!u&&n<=t)&&i++;return i/o},e.histogram=function(r,n){n=n||4;var a,i=e.min(r),o=(e.max(r)-i)/n,u=r.length,s=[];for(a=0;a<n;a++)s[a]=0;for(a=0;a<u;a++)s[t.min(t.floor((r[a]-i)/o),n-1)]+=1;return s},e.covariance=function(t,r){var n,a=e.mean(t),i=e.mean(r),o=t.length,u=new Array(o);for(n=0;n<o;n++)u[n]=(t[n]-a)*(r[n]-i);return e.sum(u)/(o-1)},e.corrcoeff=function(t,r){return e.covariance(t,r)/e.stdev(t,1)/e.stdev(r,1)},e.spearmancoeff=function(t,r){return t=e.rank(t),r=e.rank(r),e.corrcoeff(t,r)},e.stanMoment=function(r,n){for(var a=e.mean(r),i=e.stdev(r),o=r.length,u=0,s=0;s<o;s++)u+=t.pow((r[s]-a)/i,n);return u/r.length},e.skewness=function(t){return e.stanMoment(t,3)},e.kurtosis=function(t){return e.stanMoment(t,4)-3};var i=e.prototype;!function(t){for(var n=0;n<t.length;n++)!function(t){i[t]=function(n,a){var o=[],u=0,s=this;if(r(n)&&(a=n,n=!1),a)return setTimeout((function(){a.call(s,i[t].call(s,n))})),this;if(this.length>1){for(s=!0===n?this:this.transpose();u<s.length;u++)o[u]=e[t](s[u]);return o}return e[t](this[0],n)}}(t[n])}("cumsum cumprod".split(" ")),function(t){for(var n=0;n<t.length;n++)!function(t){i[t]=function(n,a){var o=[],u=0,s=this;if(r(n)&&(a=n,n=!1),a)return setTimeout((function(){a.call(s,i[t].call(s,n))})),this;if(this.length>1){for("sumrow"!==t&&(s=!0===n?this:this.transpose());u<s.length;u++)o[u]=e[t](s[u]);return!0===n?e[t](e.utils.toVector(o)):o}return e[t](this[0],n)}}(t[n])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(t){for(var n=0;n<t.length;n++)!function(t){i[t]=function(){var n,a=[],o=0,u=this,s=Array.prototype.slice.call(arguments);if(r(s[s.length-1])){n=s[s.length-1];var c=s.slice(0,s.length-1);return setTimeout((function(){n.call(u,i[t].apply(u,c))})),this}n=void 0;var f=function(r){return e[t].apply(u,[r].concat(s))};if(this.length>1){for(u=u.transpose();o<u.length;o++)a[o]=f(u[o]);return a}return f(this[0])}}(t[n])}("quantiles percentileOfScore".split(" "))}(e,Math),function(e,t){e.gammaln=function(e){var r,n,a,i=0,o=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],u=1.000000000190015;for(a=(n=r=e)+5.5,a-=(r+.5)*t.log(a);i<6;i++)u+=o[i]/++n;return t.log(2.5066282746310007*u/r)-a},e.loggam=function(e){var r,n,a,i,o,u,s,c=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(r=e,s=0,1==e||2==e)return 0;for(e<=7&&(r=e+(s=t.floor(7-e))),n=1/(r*r),a=2*t.PI,o=c[9],u=8;u>=0;u--)o*=n,o+=c[u];if(i=o/r+.5*t.log(a)+(r-.5)*t.log(r)-r,e<=7)for(u=1;u<=s;u++)i-=t.log(r-1),r-=1;return i},e.gammafn=function(e){var r,n,a,i,o=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],u=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],s=!1,c=0,f=0,l=0,p=e;if(e>171.6243769536076)return 1/0;if(p<=0){if(!(i=p%1+36e-17))return 1/0;s=(1&p?-1:1)*t.PI/t.sin(t.PI*i),p=1-p}for(a=p,n=p<1?p++:(p-=c=(0|p)-1)-1,r=0;r<8;++r)l=(l+o[r])*n,f=f*n+u[r];if(i=l/f+1,a<p)i/=a;else if(a>p)for(r=0;r<c;++r)i*=p,p++;return s&&(i=s/i),i},e.gammap=function(t,r){return e.lowRegGamma(t,r)*e.gammafn(t)},e.lowRegGamma=function(r,n){var a,i=e.gammaln(r),o=r,u=1/r,s=u,c=n+1-r,f=1/1e-30,l=1/c,p=l,d=1,h=-~(8.5*t.log(r>=1?r:1/r)+.4*r+17);if(n<0||r<=0)return NaN;if(n<r+1){for(;d<=h;d++)u+=s*=n/++o;return u*t.exp(-n+r*t.log(n)-i)}for(;d<=h;d++)p*=(l=1/(l=(a=-d*(d-r))*l+(c+=2)))*(f=c+a/f);return 1-p*t.exp(-n+r*t.log(n)-i)},e.factorialln=function(t){return t<0?NaN:e.gammaln(t+1)},e.factorial=function(t){return t<0?NaN:e.gammafn(t+1)},e.combination=function(r,n){return r>170||n>170?t.exp(e.combinationln(r,n)):e.factorial(r)/e.factorial(n)/e.factorial(r-n)},e.combinationln=function(t,r){return e.factorialln(t)-e.factorialln(r)-e.factorialln(t-r)},e.permutation=function(t,r){return e.factorial(t)/e.factorial(t-r)},e.betafn=function(r,n){if(!(r<=0||n<=0))return r+n>170?t.exp(e.betaln(r,n)):e.gammafn(r)*e.gammafn(n)/e.gammafn(r+n)},e.betaln=function(t,r){return e.gammaln(t)+e.gammaln(r)-e.gammaln(t+r)},e.betacf=function(e,r,n){var a,i,o,u,s=1e-30,c=1,f=r+n,l=r+1,p=r-1,d=1,h=1-f*e/l;for(t.abs(h)<s&&(h=s),u=h=1/h;c<=100&&(h=1+(i=c*(n-c)*e/((p+(a=2*c))*(r+a)))*h,t.abs(h)<s&&(h=s),d=1+i/d,t.abs(d)<s&&(d=s),u*=(h=1/h)*d,h=1+(i=-(r+c)*(f+c)*e/((r+a)*(l+a)))*h,t.abs(h)<s&&(h=s),d=1+i/d,t.abs(d)<s&&(d=s),u*=o=(h=1/h)*d,!(t.abs(o-1)<3e-7));c++);return u},e.gammapinv=function(r,n){var a,i,o,u,s,c,f=0,l=n-1,p=1e-8,d=e.gammaln(n);if(r>=1)return t.max(100,n+100*t.sqrt(n));if(r<=0)return 0;for(n>1?(s=t.log(l),c=t.exp(l*(s-1)-d),u=r<.5?r:1-r,a=(2.30753+.27061*(i=t.sqrt(-2*t.log(u))))/(1+i*(.99229+.04481*i))-i,r<.5&&(a=-a),a=t.max(.001,n*t.pow(1-1/(9*n)-a/(3*t.sqrt(n)),3))):a=r<(i=1-n*(.253+.12*n))?t.pow(r/i,1/n):1-t.log(1-(r-i)/(1-i));f<12;f++){if(a<=0)return 0;if((a-=i=(o=(e.lowRegGamma(n,a)-r)/(i=n>1?c*t.exp(-(a-l)+l*(t.log(a)-s)):t.exp(-a+l*t.log(a)-d)))/(1-.5*t.min(1,o*((n-1)/a-1))))<=0&&(a=.5*(a+i)),t.abs(i)<p*a)break}return a},e.erf=function(e){var r,n,a,i,o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],u=o.length-1,s=!1,c=0,f=0;for(e<0&&(e=-e,s=!0),n=4*(r=2/(2+e))-2;u>0;u--)a=c,c=n*c-f+o[u],f=a;return i=r*t.exp(-e*e+.5*(o[0]+n*c)-f),s?i-1:1-i},e.erfc=function(t){return 1-e.erf(t)},e.erfcinv=function(r){var n,a,i,o,u=0;if(r>=2)return-100;if(r<=0)return 100;for(o=r<1?r:2-r,n=-.70711*((2.30753+.27061*(i=t.sqrt(-2*t.log(o/2))))/(1+i*(.99229+.04481*i))-i);u<2;u++)n+=(a=e.erfc(n)-o)/(1.1283791670955126*t.exp(-n*n)-n*a);return r<1?n:-n},e.ibetainv=function(r,n,a){var i,o,u,s,c,f,l,p,d,h,v=1e-8,m=n-1,g=a-1,y=0;if(r<=0)return 0;if(r>=1)return 1;for(n>=1&&a>=1?(u=r<.5?r:1-r,f=(2.30753+.27061*(s=t.sqrt(-2*t.log(u))))/(1+s*(.99229+.04481*s))-s,r<.5&&(f=-f),l=(f*f-3)/6,p=2/(1/(2*n-1)+1/(2*a-1)),d=f*t.sqrt(l+p)/p-(1/(2*a-1)-1/(2*n-1))*(l+5/6-2/(3*p)),f=n/(n+a*t.exp(2*d))):(i=t.log(n/(n+a)),o=t.log(a/(n+a)),f=r<(s=t.exp(n*i)/n)/(d=s+(c=t.exp(a*o)/a))?t.pow(n*d*r,1/n):1-t.pow(a*d*(1-r),1/a)),h=-e.gammaln(n)-e.gammaln(a)+e.gammaln(n+a);y<10;y++){if(0===f||1===f)return f;if((f-=s=(c=(e.ibeta(f,n,a)-r)/(s=t.exp(m*t.log(f)+g*t.log(1-f)+h)))/(1-.5*t.min(1,c*(m/f-g/(1-f)))))<=0&&(f=.5*(f+s)),f>=1&&(f=.5*(f+s+1)),t.abs(s)<v*f&&y>0)break}return f},e.ibeta=function(r,n,a){var i=0===r||1===r?0:t.exp(e.gammaln(n+a)-e.gammaln(n)-e.gammaln(a)+n*t.log(r)+a*t.log(1-r));return!(r<0||r>1)&&(r<(n+1)/(n+a+2)?i*e.betacf(r,n,a)/n:1-i*e.betacf(1-r,a,n)/a)},e.randn=function(r,n){var a,i,o,u,s;if(n||(n=r),r)return e.create(r,n,(function(){return e.randn()}));do{a=e._random_fn(),i=1.7156*(e._random_fn()-.5),s=(o=a-.449871)*o+(u=t.abs(i)+.386595)*(.196*u-.25472*o)}while(s>.27597&&(s>.27846||i*i>-4*t.log(a)*a*a));return i/a},e.randg=function(r,n,a){var i,o,u,s,c,f,l=r;if(a||(a=n),r||(r=1),n)return(f=e.zeros(n,a)).alter((function(){return e.randg(r)})),f;r<1&&(r+=1),i=r-1/3,o=1/t.sqrt(9*i);do{do{s=1+o*(c=e.randn())}while(s<=0);s*=s*s,u=e._random_fn()}while(u>1-.331*t.pow(c,4)&&t.log(u)>.5*c*c+i*(1-s+t.log(s)));if(r==l)return i*s;do{u=e._random_fn()}while(0===u);return t.pow(u,1/l)*i*s},function(t){for(var r=0;r<t.length;r++)!function(t){e.fn[t]=function(){return e(e.map(this,(function(r){return e[t](r)})))}}(t[r])}("gammaln gammafn factorial factorialln".split(" ")),function(t){for(var r=0;r<t.length;r++)!function(t){e.fn[t]=function(){return e(e[t].apply(null,arguments))}}(t[r])}("randn".split(" "))}(e,Math),function(e,t){function r(e,r,n,a){for(var i,o=0,u=1,s=1,c=1,f=0,l=0;t.abs((s-l)/s)>a;)l=s,u=c+(i=-(r+f)*(r+n+f)*e/(r+2*f)/(r+2*f+1))*u,s=(o=s+i*o)+(i=(f+=1)*(n-f)*e/(r+2*f-1)/(r+2*f))*s,o/=c=u+i*c,u/=c,s/=c,c=1;return s/r}function n(e){return e/t.abs(e)}function a(r,n,a){var i=12,o=6,u=-30,s=-50,c=60,f=8,l=3,p=2,d=3,h=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],v=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],m=.5*r;if(m>=f)return 1;var g,y=2*e.normal.cdf(m,0,1,1,0)-1;y=y>=t.exp(s/a)?t.pow(y,a):0;for(var _=m,b=(f-m)/(g=r>l?p:d),k=_+b,w=0,x=a-1,S=1;S<=g;S++){for(var E=0,N=.5*(k+_),T=.5*(k-_),A=1;A<=i;A++){var I,M=N+T*(o<A?h[(I=i-A+1)-1]:-h[(I=A)-1]),C=M*M;if(C>c)break;var O=2*e.normal.cdf(M,0,1,1,0)*.5-2*e.normal.cdf(M,r,1,1,0)*.5;O>=t.exp(u/x)&&(E+=O=v[I-1]*t.exp(-.5*C)*t.pow(O,x))}w+=E*=2*T*a/t.sqrt(2*t.PI),_=k,k+=b}return(y+=w)<=t.exp(u/n)?0:(y=t.pow(y,n))>=1?1:y}function i(e,r,n){var a=.322232421088,i=.099348462606,o=-1,u=.588581570495,s=-.342242088547,c=.531103462366,f=-.204231210125,l=.10353775285,p=-453642210148e-16,d=.0038560700634,h=.8832,v=.2368,m=1.208,g=1.4142,y=120,_=.5-.5*e,b=t.sqrt(t.log(1/(_*_))),k=b+((((b*p+f)*b+s)*b+o)*b+a)/((((b*d+l)*b+c)*b+u)*b+i);n<y&&(k+=(k*k*k+k)/n/4);var w=h-v*k;return n<y&&(w+=-1.214/n+m*k/n),k*(w*t.log(r-1)+g)}!function(t){for(var r=0;r<t.length;r++)!function(t){e[t]=function e(t,r,n){return this instanceof e?(this._a=t,this._b=r,this._c=n,this):new e(t,r,n)},e.fn[t]=function(r,n,a){var i=e[t](r,n,a);return i.data=this,i},e[t].prototype.sample=function(r){var n=this._a,a=this._b,i=this._c;return r?e.alter(r,(function(){return e[t].sample(n,a,i)})):e[t].sample(n,a,i)},function(r){for(var n=0;n<r.length;n++)!function(r){e[t].prototype[r]=function(n){var a=this._a,i=this._b,o=this._c;return n||0===n||(n=this.data),"number"!=typeof n?e.fn.map.call(n,(function(n){return e[t][r](n,a,i,o)})):e[t][r](n,a,i,o)}}(r[n])}("pdf cdf inv".split(" ")),function(r){for(var n=0;n<r.length;n++)!function(r){e[t].prototype[r]=function(){return e[t][r](this._a,this._b,this._c)}}(r[n])}("mean median mode variance".split(" "))}(t[r])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),e.extend(e.beta,{pdf:function(r,n,a){return r>1||r<0?0:1==n&&1==a?1:n<512&&a<512?t.pow(r,n-1)*t.pow(1-r,a-1)/e.betafn(n,a):t.exp((n-1)*t.log(r)+(a-1)*t.log(1-r)-e.betaln(n,a))},cdf:function(t,r,n){return t>1||t<0?1*(t>1):e.ibeta(t,r,n)},inv:function(t,r,n){return e.ibetainv(t,r,n)},mean:function(e,t){return e/(e+t)},median:function(t,r){return e.ibetainv(.5,t,r)},mode:function(e,t){return(e-1)/(e+t-2)},sample:function(t,r){var n=e.randg(t);return n/(n+e.randg(r))},variance:function(e,r){return e*r/(t.pow(e+r,2)*(e+r+1))}}),e.extend(e.centralF,{pdf:function(r,n,a){var i;return r<0?0:n<=2?0===r&&n<2?1/0:0===r&&2===n?1:1/e.betafn(n/2,a/2)*t.pow(n/a,n/2)*t.pow(r,n/2-1)*t.pow(1+n/a*r,-(n+a)/2):(i=n*r/(a+r*n),n*(a/(a+r*n))/2*e.binomial.pdf((n-2)/2,(n+a-2)/2,i))},cdf:function(t,r,n){return t<0?0:e.ibeta(r*t/(r*t+n),r/2,n/2)},inv:function(t,r,n){return n/(r*(1/e.ibetainv(t,r/2,n/2)-1))},mean:function(e,t){return t>2?t/(t-2):void 0},mode:function(e,t){return e>2?t*(e-2)/(e*(t+2)):void 0},sample:function(t,r){return 2*e.randg(t/2)/t/(2*e.randg(r/2)/r)},variance:function(e,t){if(!(t<=4))return 2*t*t*(e+t-2)/(e*(t-2)*(t-2)*(t-4))}}),e.extend(e.cauchy,{pdf:function(e,r,n){return n<0?0:n/(t.pow(e-r,2)+t.pow(n,2))/t.PI},cdf:function(e,r,n){return t.atan((e-r)/n)/t.PI+.5},inv:function(e,r,n){return r+n*t.tan(t.PI*(e-.5))},median:function(e){return e},mode:function(e){return e},sample:function(r,n){return e.randn()*t.sqrt(1/(2*e.randg(.5)))*n+r}}),e.extend(e.chisquare,{pdf:function(r,n){return r<0?0:0===r&&2===n?.5:t.exp((n/2-1)*t.log(r)-r/2-n/2*t.log(2)-e.gammaln(n/2))},cdf:function(t,r){return t<0?0:e.lowRegGamma(r/2,t/2)},inv:function(t,r){return 2*e.gammapinv(t,.5*r)},mean:function(e){return e},median:function(e){return e*t.pow(1-2/(9*e),3)},mode:function(e){return e-2>0?e-2:0},sample:function(t){return 2*e.randg(t/2)},variance:function(e){return 2*e}}),e.extend(e.exponential,{pdf:function(e,r){return e<0?0:r*t.exp(-r*e)},cdf:function(e,r){return e<0?0:1-t.exp(-r*e)},inv:function(e,r){return-t.log(1-e)/r},mean:function(e){return 1/e},median:function(e){return 1/e*t.log(2)},mode:function(){return 0},sample:function(r){return-1/r*t.log(e._random_fn())},variance:function(e){return t.pow(e,-2)}}),e.extend(e.gamma,{pdf:function(r,n,a){return r<0?0:0===r&&1===n?1/a:t.exp((n-1)*t.log(r)-r/a-e.gammaln(n)-n*t.log(a))},cdf:function(t,r,n){return t<0?0:e.lowRegGamma(r,t/n)},inv:function(t,r,n){return e.gammapinv(t,r)*n},mean:function(e,t){return e*t},mode:function(e,t){if(e>1)return(e-1)*t},sample:function(t,r){return e.randg(t)*r},variance:function(e,t){return e*t*t}}),e.extend(e.invgamma,{pdf:function(r,n,a){return r<=0?0:t.exp(-(n+1)*t.log(r)-a/r-e.gammaln(n)+n*t.log(a))},cdf:function(t,r,n){return t<=0?0:1-e.lowRegGamma(r,n/t)},inv:function(t,r,n){return n/e.gammapinv(1-t,r)},mean:function(e,t){return e>1?t/(e-1):void 0},mode:function(e,t){return t/(e+1)},sample:function(t,r){return r/e.randg(t)},variance:function(e,t){if(!(e<=2))return t*t/((e-1)*(e-1)*(e-2))}}),e.extend(e.kumaraswamy,{pdf:function(e,r,n){return 0===e&&1===r?n:1===e&&1===n?r:t.exp(t.log(r)+t.log(n)+(r-1)*t.log(e)+(n-1)*t.log(1-t.pow(e,r)))},cdf:function(e,r,n){return e<0?0:e>1?1:1-t.pow(1-t.pow(e,r),n)},inv:function(e,r,n){return t.pow(1-t.pow(1-e,1/n),1/r)},mean:function(t,r){return r*e.gammafn(1+1/t)*e.gammafn(r)/e.gammafn(1+1/t+r)},median:function(e,r){return t.pow(1-t.pow(2,-1/r),1/e)},mode:function(e,r){if(e>=1&&r>=1&&1!==e&&1!==r)return t.pow((e-1)/(e*r-1),1/e)},variance:function(){throw new Error("variance not yet implemented")}}),e.extend(e.lognormal,{pdf:function(e,r,n){return e<=0?0:t.exp(-t.log(e)-.5*t.log(2*t.PI)-t.log(n)-t.pow(t.log(e)-r,2)/(2*n*n))},cdf:function(r,n,a){return r<0?0:.5+.5*e.erf((t.log(r)-n)/t.sqrt(2*a*a))},inv:function(r,n,a){return t.exp(-1.4142135623730951*a*e.erfcinv(2*r)+n)},mean:function(e,r){return t.exp(e+r*r/2)},median:function(e){return t.exp(e)},mode:function(e,r){return t.exp(e-r*r)},sample:function(r,n){return t.exp(e.randn()*n+r)},variance:function(e,r){return(t.exp(r*r)-1)*t.exp(2*e+r*r)}}),e.extend(e.noncentralt,{pdf:function(r,n,a){var i=1e-14;return t.abs(a)<i?e.studentt.pdf(r,n):t.abs(r)<i?t.exp(e.gammaln((n+1)/2)-a*a/2-.5*t.log(t.PI*n)-e.gammaln(n/2)):n/r*(e.noncentralt.cdf(r*t.sqrt(1+2/n),n+2,a)-e.noncentralt.cdf(r,n,a))},cdf:function(r,n,a){var i=1e-14,o=200;if(t.abs(a)<i)return e.studentt.cdf(r,n);var u=!1;r<0&&(u=!0,a=-a);for(var s=e.normal.cdf(-a,0,1),c=i+1,f=c,l=r*r/(r*r+n),p=0,d=t.exp(-a*a/2),h=t.exp(-a*a/2-.5*t.log(2)-e.gammaln(1.5))*a;p<o||f>i||c>i;)f=c,p>0&&(d*=a*a/(2*p),h*=a*a/(2*(p+.5))),s+=.5*(c=d*e.beta.cdf(l,p+.5,n/2)+h*e.beta.cdf(l,p+1,n/2)),p++;return u?1-s:s}}),e.extend(e.normal,{pdf:function(e,r,n){return t.exp(-.5*t.log(2*t.PI)-t.log(n)-t.pow(e-r,2)/(2*n*n))},cdf:function(r,n,a){return.5*(1+e.erf((r-n)/t.sqrt(2*a*a)))},inv:function(t,r,n){return-1.4142135623730951*n*e.erfcinv(2*t)+r},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},sample:function(t,r){return e.randn()*r+t},variance:function(e,t){return t*t}}),e.extend(e.pareto,{pdf:function(e,r,n){return e<r?0:n*t.pow(r,n)/t.pow(e,n+1)},cdf:function(e,r,n){return e<r?0:1-t.pow(r/e,n)},inv:function(e,r,n){return r/t.pow(1-e,1/n)},mean:function(e,r){if(!(r<=1))return r*t.pow(e,r)/(r-1)},median:function(e,r){return e*(r*t.SQRT2)},mode:function(e){return e},variance:function(e,r){if(!(r<=2))return e*e*r/(t.pow(r-1,2)*(r-2))}}),e.extend(e.studentt,{pdf:function(r,n){return n=n>1e100?1e100:n,1/(t.sqrt(n)*e.betafn(.5,n/2))*t.pow(1+r*r/n,-(n+1)/2)},cdf:function(r,n){var a=n/2;return e.ibeta((r+t.sqrt(r*r+n))/(2*t.sqrt(r*r+n)),a,a)},inv:function(r,n){var a=e.ibetainv(2*t.min(r,1-r),.5*n,.5);return a=t.sqrt(n*(1-a)/a),r>.5?a:-a},mean:function(e){return e>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(r){return e.randn()*t.sqrt(r/(2*e.randg(r/2)))},variance:function(e){return e>2?e/(e-2):e>1?1/0:void 0}}),e.extend(e.weibull,{pdf:function(e,r,n){return e<0||r<0||n<0?0:n/r*t.pow(e/r,n-1)*t.exp(-t.pow(e/r,n))},cdf:function(e,r,n){return e<0?0:1-t.exp(-t.pow(e/r,n))},inv:function(e,r,n){return r*t.pow(-t.log(1-e),1/n)},mean:function(t,r){return t*e.gammafn(1+1/r)},median:function(e,r){return e*t.pow(t.log(2),1/r)},mode:function(e,r){return r<=1?0:e*t.pow((r-1)/r,1/r)},sample:function(r,n){return r*t.pow(-t.log(e._random_fn()),1/n)},variance:function(r,n){return r*r*e.gammafn(1+2/n)-t.pow(e.weibull.mean(r,n),2)}}),e.extend(e.uniform,{pdf:function(e,t,r){return e<t||e>r?0:1/(r-t)},cdf:function(e,t,r){return e<t?0:e<r?(e-t)/(r-t):1},inv:function(e,t,r){return t+e*(r-t)},mean:function(e,t){return.5*(e+t)},median:function(t,r){return e.mean(t,r)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(t,r){return t/2+r/2+(r/2-t/2)*(2*e._random_fn()-1)},variance:function(e,r){return t.pow(r-e,2)/12}}),e.extend(e.binomial,{pdf:function(r,n,a){return 0===a||1===a?n*a===r?1:0:e.combination(n,r)*t.pow(a,r)*t.pow(1-a,n-r)},cdf:function(n,a,i){var o,u=1e-10;if(n<0)return 0;if(n>=a)return 1;if(i<0||i>1||a<=0)return NaN;var s=i,c=(n=t.floor(n))+1,f=a-n,l=c+f,p=t.exp(e.gammaln(l)-e.gammaln(f)-e.gammaln(c)+c*t.log(s)+f*t.log(1-s));return o=s<(c+1)/(l+2)?p*r(s,c,f,u):1-p*r(1-s,f,c,u),t.round(1/u*(1-o))/(1/u)}}),e.extend(e.negbin,{pdf:function(r,n,a){return r===r>>>0&&(r<0?0:e.combination(r+n-1,n-1)*t.pow(1-a,r)*t.pow(a,n))},cdf:function(t,r,n){var a=0,i=0;if(t<0)return 0;for(;i<=t;i++)a+=e.negbin.pdf(i,r,n);return a}}),e.extend(e.hypgeom,{pdf:function(r,n,a,i){if(r!=r|0)return!1;if(r<0||r<a-(n-i))return 0;if(r>i||r>a)return 0;if(2*a>n)return 2*i>n?e.hypgeom.pdf(n-a-i+r,n,n-a,n-i):e.hypgeom.pdf(i-r,n,n-a,i);if(2*i>n)return e.hypgeom.pdf(a-r,n,a,n-i);if(a<i)return e.hypgeom.pdf(r,n,i,a);for(var o=1,u=0,s=0;s<r;s++){for(;o>1&&u<i;)o*=1-a/(n-u),u++;o*=(i-s)*(a-s)/((s+1)*(n-a-i+s+1))}for(;u<i;u++)o*=1-a/(n-u);return t.min(1,t.max(0,o))},cdf:function(r,n,a,i){if(r<0||r<a-(n-i))return 0;if(r>=i||r>=a)return 1;if(2*a>n)return 2*i>n?e.hypgeom.cdf(n-a-i+r,n,n-a,n-i):1-e.hypgeom.cdf(i-r-1,n,n-a,i);if(2*i>n)return 1-e.hypgeom.cdf(a-r-1,n,a,n-i);if(a<i)return e.hypgeom.cdf(r,n,i,a);for(var o=1,u=1,s=0,c=0;c<r;c++){for(;o>1&&s<i;){var f=1-a/(n-s);u*=f,o*=f,s++}o+=u*=(i-c)*(a-c)/((c+1)*(n-a-i+c+1))}for(;s<i;s++)o*=1-a/(n-s);return t.min(1,t.max(0,o))}}),e.extend(e.poisson,{pdf:function(r,n){return n<0||r%1!=0||r<0?0:t.pow(n,r)*t.exp(-n)/e.factorial(r)},cdf:function(t,r){var n=[],a=0;if(t<0)return 0;for(;a<=t;a++)n.push(e.poisson.pdf(a,r));return e.sum(n)},mean:function(e){return e},variance:function(e){return e},sampleSmall:function(r){var n=1,a=0,i=t.exp(-r);do{a++,n*=e._random_fn()}while(n>i);return a-1},sampleLarge:function(r){var n,a,i,o,u,s,c,f,l,p,d=r;for(o=t.sqrt(d),u=t.log(d),s=.02483*(c=.931+2.53*o)-.059,f=1.1239+1.1328/(c-3.4),l=.9277-3.6224/(c-2);;){if(a=t.random()-.5,i=t.random(),p=.5-t.abs(a),n=t.floor((2*s/p+c)*a+d+.43),p>=.07&&i<=l)return n;if(!(n<0||p<.013&&i>p)&&t.log(i)+t.log(f)-t.log(s/(p*p)+c)<=n*u-d-e.loggam(n+1))return n}},sample:function(e){return e<10?this.sampleSmall(e):this.sampleLarge(e)}}),e.extend(e.triangular,{pdf:function(e,t,r,n){return r<=t||n<t||n>r?NaN:e<t||e>r?0:e<n?2*(e-t)/((r-t)*(n-t)):e===n?2/(r-t):2*(r-e)/((r-t)*(r-n))},cdf:function(e,r,n,a){return n<=r||a<r||a>n?NaN:e<=r?0:e>=n?1:e<=a?t.pow(e-r,2)/((n-r)*(a-r)):1-t.pow(n-e,2)/((n-r)*(n-a))},inv:function(e,r,n,a){return n<=r||a<r||a>n?NaN:e<=(a-r)/(n-r)?r+(n-r)*t.sqrt(e*((a-r)/(n-r))):r+(n-r)*(1-t.sqrt((1-e)*(1-(a-r)/(n-r))))},mean:function(e,t,r){return(e+t+r)/3},median:function(e,r,n){return n<=(e+r)/2?r-t.sqrt((r-e)*(r-n))/t.sqrt(2):n>(e+r)/2?e+t.sqrt((r-e)*(n-e))/t.sqrt(2):void 0},mode:function(e,t,r){return r},sample:function(r,n,a){var i=e._random_fn();return i<(a-r)/(n-r)?r+t.sqrt(i*(n-r)*(a-r)):n-t.sqrt((1-i)*(n-r)*(n-a))},variance:function(e,t,r){return(e*e+t*t+r*r-e*t-e*r-t*r)/18}}),e.extend(e.arcsine,{pdf:function(e,r,n){return n<=r?NaN:e<=r||e>=n?0:2/t.PI*t.pow(t.pow(n-r,2)-t.pow(2*e-r-n,2),-.5)},cdf:function(e,r,n){return e<r?0:e<n?2/t.PI*t.asin(t.sqrt((e-r)/(n-r))):1},inv:function(e,r,n){return r+(.5-.5*t.cos(t.PI*e))*(n-r)},mean:function(e,t){return t<=e?NaN:(e+t)/2},median:function(e,t){return t<=e?NaN:(e+t)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(r,n){return(r+n)/2+(n-r)/2*t.sin(2*t.PI*e.uniform.sample(0,1))},variance:function(e,r){return r<=e?NaN:t.pow(r-e,2)/8}}),e.extend(e.laplace,{pdf:function(e,r,n){return n<=0?0:t.exp(-t.abs(e-r)/n)/(2*n)},cdf:function(e,r,n){return n<=0?0:e<r?.5*t.exp((e-r)/n):1-.5*t.exp(-(e-r)/n)},mean:function(e){return e},median:function(e){return e},mode:function(e){return e},variance:function(e,t){return 2*t*t},sample:function(r,a){var i=e._random_fn()-.5;return r-a*n(i)*t.log(1-2*t.abs(i))}}),e.extend(e.tukey,{cdf:function(r,n,i){var o=1,u=n,s=16,c=8,f=-30,l=1e-14,p=100,d=800,h=5e3,v=25e3,m=1,g=.5,y=.25,_=.125,b=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],k=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(r<=0)return 0;if(i<2||o<1||u<2)return NaN;if(!Number.isFinite(r))return 1;if(i>v)return a(r,o,u);var w,x=.5*i,S=x*t.log(i)-i*t.log(2)-e.gammaln(x),E=x-1,N=.25*i;w=i<=p?m:i<=d?g:i<=h?y:_,S+=t.log(w);for(var T=0,A=1;A<=50;A++){for(var I=0,M=(2*A-1)*w,C=1;C<=s;C++){var O,R;c<C?(O=C-c-1,R=S+E*t.log(M+b[O]*w)-(b[O]*w+M)*N):(O=C-1,R=S+E*t.log(M-b[O]*w)+(b[O]*w-M)*N),R>=f&&(I+=a(c<C?r*t.sqrt(.5*(b[O]*w+M)):r*t.sqrt(.5*(-b[O]*w+M)),o,u)*k[O]*t.exp(R))}if(A*w>=1&&I<=l)break;T+=I}if(I>l)throw new Error("tukey.cdf failed to converge");return T>1&&(T=1),T},inv:function(r,n,a){var o=1e-4,u=50;if(a<2||n<2)return NaN;if(r<0||r>1)return NaN;if(0===r)return 0;if(1===r)return 1/0;var s,c=i(r,n,a),f=e.tukey.cdf(c,n,a)-r;s=f>0?t.max(0,c-1):c+1;for(var l,p=e.tukey.cdf(s,n,a)-r,d=1;d<u;d++)if(l=s-p*(s-c)/(p-f),f=p,c=s,l<0&&(l=0,p=-r),p=e.tukey.cdf(l,n,a)-r,s=l,t.abs(s-c)<o)return l;throw new Error("tukey.inv failed to converge")}})}(e,Math),function(e,t){var r=Array.prototype.push,n=e.utils.isArray;function a(t){return n(t)||t instanceof e}e.extend({add:function(t,r){return a(r)?(a(r[0])||(r=[r]),e.map(t,(function(e,t,n){return e+r[t][n]}))):e.map(t,(function(e){return e+r}))},subtract:function(t,r){return a(r)?(a(r[0])||(r=[r]),e.map(t,(function(e,t,n){return e-r[t][n]||0}))):e.map(t,(function(e){return e-r}))},divide:function(t,r){return a(r)?(a(r[0])||(r=[r]),e.multiply(t,e.inv(r))):e.map(t,(function(e){return e/r}))},multiply:function(t,r){var n,i,o,u,s,c,f,l;if(void 0===t.length&&void 0===r.length)return t*r;if(s=t.length,c=t[0].length,f=e.zeros(s,o=a(r)?r[0].length:c),l=0,a(r)){for(;l<o;l++)for(n=0;n<s;n++){for(u=0,i=0;i<c;i++)u+=t[n][i]*r[i][l];f[n][l]=u}return 1===s&&1===l?f[0][0]:f}return e.map(t,(function(e){return e*r}))},outer:function(t,r){return e.multiply(t.map((function(e){return[e]})),[r])},dot:function(t,r){a(t[0])||(t=[t]),a(r[0])||(r=[r]);for(var n,i,o=1===t[0].length&&1!==t.length?e.transpose(t):t,u=1===r[0].length&&1!==r.length?e.transpose(r):r,s=[],c=0,f=o.length,l=o[0].length;c<f;c++){for(s[c]=[],n=0,i=0;i<l;i++)n+=o[c][i]*u[c][i];s[c]=n}return 1===s.length?s[0]:s},pow:function(r,n){return e.map(r,(function(e){return t.pow(e,n)}))},exp:function(r){return e.map(r,(function(e){return t.exp(e)}))},log:function(r){return e.map(r,(function(e){return t.log(e)}))},abs:function(r){return e.map(r,(function(e){return t.abs(e)}))},norm:function(e,r){var n=0,i=0;for(isNaN(r)&&(r=2),a(e[0])&&(e=e[0]);i<e.length;i++)n+=t.pow(t.abs(e[i]),r);return t.pow(n,1/r)},angle:function(r,n){return t.acos(e.dot(r,n)/(e.norm(r)*e.norm(n)))},aug:function(e,t){var n,a=[];for(n=0;n<e.length;n++)a.push(e[n].slice());for(n=0;n<a.length;n++)r.apply(a[n],t[n]);return a},inv:function(t){for(var r,n=t.length,a=t[0].length,i=e.identity(n,a),o=e.gauss_jordan(t,i),u=[],s=0;s<n;s++)for(u[s]=[],r=a;r<o[0].length;r++)u[s][r-a]=o[s][r];return u},det:function e(t){if(2===t.length)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(var r=0,n=0;n<t.length;n++){for(var a=[],i=1;i<t.length;i++){a[i-1]=[];for(var o=0;o<t.length;o++)o<n?a[i-1][o]=t[i][o]:o>n&&(a[i-1][o-1]=t[i][o])}var u=n%2?-1:1;r+=e(a)*t[0][n]*u}return r},gauss_elimination:function(r,n){var a,i,o,u,s=0,c=0,f=r.length,l=r[0].length,p=1,d=0,h=[];for(a=(r=e.aug(r,n))[0].length,s=0;s<f;s++){for(i=r[s][s],c=s,u=s+1;u<l;u++)i<t.abs(r[u][s])&&(i=r[u][s],c=u);if(c!=s)for(u=0;u<a;u++)o=r[s][u],r[s][u]=r[c][u],r[c][u]=o;for(c=s+1;c<f;c++)for(p=r[c][s]/r[s][s],u=s;u<a;u++)r[c][u]=r[c][u]-p*r[s][u]}for(s=f-1;s>=0;s--){for(d=0,c=s+1;c<=f-1;c++)d+=h[c]*r[s][c];h[s]=(r[s][a-1]-d)/r[s][s]}return h},gauss_jordan:function(r,n){var a,i,o,u=e.aug(r,n),s=u.length,c=u[0].length,f=0;for(i=0;i<s;i++){var l=i;for(o=i+1;o<s;o++)t.abs(u[o][i])>t.abs(u[l][i])&&(l=o);var p=u[i];for(u[i]=u[l],u[l]=p,o=i+1;o<s;o++)for(f=u[o][i]/u[i][i],a=i;a<c;a++)u[o][a]-=u[i][a]*f}for(i=s-1;i>=0;i--){for(f=u[i][i],o=0;o<i;o++)for(a=c-1;a>i-1;a--)u[o][a]-=u[i][a]*u[o][i]/f;for(u[i][i]/=f,a=s;a<c;a++)u[i][a]/=f}return u},triaUpSolve:function(t,r){var n,a=t[0].length,i=e.zeros(1,a)[0],o=!1;return null!=r[0].length&&(r=r.map((function(e){return e[0]})),o=!0),e.arange(a-1,-1,-1).forEach((function(o){n=e.arange(o+1,a).map((function(e){return i[e]*t[o][e]})),i[o]=(r[o]-e.sum(n))/t[o][o]})),o?i.map((function(e){return[e]})):i},triaLowSolve:function(t,r){var n,a=t[0].length,i=e.zeros(1,a)[0],o=!1;return null!=r[0].length&&(r=r.map((function(e){return e[0]})),o=!0),e.arange(a).forEach((function(a){n=e.arange(a).map((function(e){return t[a][e]*i[e]})),i[a]=(r[a]-e.sum(n))/t[a][a]})),o?i.map((function(e){return[e]})):i},lu:function(t){var r,n=t.length,a=e.identity(n),i=e.zeros(t.length,t[0].length);return e.arange(n).forEach((function(e){i[0][e]=t[0][e]})),e.arange(1,n).forEach((function(o){e.arange(o).forEach((function(n){r=e.arange(n).map((function(e){return a[o][e]*i[e][n]})),a[o][n]=(t[o][n]-e.sum(r))/i[n][n]})),e.arange(o,n).forEach((function(n){r=e.arange(o).map((function(e){return a[o][e]*i[e][n]})),i[o][n]=t[r.length][n]-e.sum(r)}))})),[a,i]},cholesky:function(r){var n,a=r.length,i=e.zeros(r.length,r[0].length);return e.arange(a).forEach((function(o){n=e.arange(o).map((function(e){return t.pow(i[o][e],2)})),i[o][o]=t.sqrt(r[o][o]-e.sum(n)),e.arange(o+1,a).forEach((function(t){n=e.arange(o).map((function(e){return i[o][e]*i[t][e]})),i[t][o]=(r[o][t]-e.sum(n))/i[o][o]}))})),i},gauss_jacobi:function(r,n,a,i){for(var o,u,s,c,f=0,l=0,p=r.length,d=[],h=[],v=[];f<p;f++)for(d[f]=[],h[f]=[],v[f]=[],l=0;l<p;l++)f>l?(d[f][l]=r[f][l],h[f][l]=v[f][l]=0):f<l?(h[f][l]=r[f][l],d[f][l]=v[f][l]=0):(v[f][l]=r[f][l],d[f][l]=h[f][l]=0);for(s=e.multiply(e.multiply(e.inv(v),e.add(d,h)),-1),u=e.multiply(e.inv(v),n),o=a,c=e.add(e.multiply(s,a),u),f=2;t.abs(e.norm(e.subtract(c,o)))>i;)o=c,c=e.add(e.multiply(s,o),u),f++;return c},gauss_seidel:function(r,n,a,i){for(var o,u,s,c,f,l=0,p=r.length,d=[],h=[],v=[];l<p;l++)for(d[l]=[],h[l]=[],v[l]=[],o=0;o<p;o++)l>o?(d[l][o]=r[l][o],h[l][o]=v[l][o]=0):l<o?(h[l][o]=r[l][o],d[l][o]=v[l][o]=0):(v[l][o]=r[l][o],d[l][o]=h[l][o]=0);for(c=e.multiply(e.multiply(e.inv(e.add(v,d)),h),-1),s=e.multiply(e.inv(e.add(v,d)),n),u=a,f=e.add(e.multiply(c,a),s),l=2;t.abs(e.norm(e.subtract(f,u)))>i;)u=f,f=e.add(e.multiply(c,u),s),l+=1;return f},SOR:function(r,n,a,i,o){for(var u,s,c,f,l,p=0,d=r.length,h=[],v=[],m=[];p<d;p++)for(h[p]=[],v[p]=[],m[p]=[],u=0;u<d;u++)p>u?(h[p][u]=r[p][u],v[p][u]=m[p][u]=0):p<u?(v[p][u]=r[p][u],h[p][u]=m[p][u]=0):(m[p][u]=r[p][u],h[p][u]=v[p][u]=0);for(f=e.multiply(e.inv(e.add(m,e.multiply(h,o))),e.subtract(e.multiply(m,1-o),e.multiply(v,o))),c=e.multiply(e.multiply(e.inv(e.add(m,e.multiply(h,o))),n),o),s=a,l=e.add(e.multiply(f,a),c),p=2;t.abs(e.norm(e.subtract(l,s)))>i;)s=l,l=e.add(e.multiply(f,s),c),p++;return l},householder:function(r){for(var n,a,i,o,u=r.length,s=r[0].length,c=0,f=[],l=[];c<u-1;c++){for(n=0,o=c+1;o<s;o++)n+=r[o][c]*r[o][c];for(n=(r[c+1][c]>0?-1:1)*t.sqrt(n),a=t.sqrt((n*n-r[c+1][c]*n)/2),(f=e.zeros(u,1))[c+1][0]=(r[c+1][c]-n)/(2*a),i=c+2;i<u;i++)f[i][0]=r[i][c]/(2*a);l=e.subtract(e.identity(u,s),e.multiply(e.multiply(f,e.transpose(f)),2)),r=e.multiply(l,e.multiply(r,l))}return r},QR:function(){var r=e.sum,n=e.arange;function a(a){var i,o,u,s=a.length,c=a[0].length,f=e.zeros(c,c);for(a=e.copy(a),o=0;o<c;o++){for(f[o][o]=t.sqrt(r(n(s).map((function(e){return a[e][o]*a[e][o]})))),i=0;i<s;i++)a[i][o]=a[i][o]/f[o][o];for(u=o+1;u<c;u++)for(f[o][u]=r(n(s).map((function(e){return a[e][o]*a[e][u]}))),i=0;i<s;i++)a[i][u]=a[i][u]-a[i][o]*f[o][u]}return[a,f]}return a}(),lstsq:function(){function t(t){var r=(t=e.copy(t)).length,n=e.identity(r);return e.arange(r-1,-1,-1).forEach((function(r){e.sliceAssign(n,{row:r},e.divide(e.slice(n,{row:r}),t[r][r])),e.sliceAssign(t,{row:r},e.divide(e.slice(t,{row:r}),t[r][r])),e.arange(r).forEach((function(a){var i=e.multiply(t[a][r],-1),o=e.slice(t,{row:a}),u=e.multiply(e.slice(t,{row:r}),i);e.sliceAssign(t,{row:a},e.add(o,u));var s=e.slice(n,{row:a}),c=e.multiply(e.slice(n,{row:r}),i);e.sliceAssign(n,{row:a},e.add(s,c))}))})),n}function r(r,n){var a=!1;void 0===n[0].length&&(n=n.map((function(e){return[e]})),a=!0);var i=e.QR(r),o=i[0],u=i[1],s=r[0].length,c=e.slice(o,{col:{end:s}}),f=t(e.slice(u,{row:{end:s}})),l=e.transpose(c);void 0===l[0].length&&(l=[l]);var p=e.multiply(e.multiply(f,l),n);return void 0===p.length&&(p=[[p]]),a?p.map((function(e){return e[0]})):p}return r}(),jacobi:function(r){for(var n,a,i,o,u,s,c,f=1,l=r.length,p=e.identity(l,l),d=[];1===f;){for(u=r[0][1],i=0,o=1,n=0;n<l;n++)for(a=0;a<l;a++)n!=a&&u<t.abs(r[n][a])&&(u=t.abs(r[n][a]),i=n,o=a);for(s=r[i][i]===r[o][o]?r[i][o]>0?t.PI/4:-t.PI/4:t.atan(2*r[i][o]/(r[i][i]-r[o][o]))/2,(c=e.identity(l,l))[i][i]=t.cos(s),c[i][o]=-t.sin(s),c[o][i]=t.sin(s),c[o][o]=t.cos(s),p=e.multiply(p,c),r=e.multiply(e.multiply(e.inv(c),r),c),f=0,n=1;n<l;n++)for(a=1;a<l;a++)n!=a&&t.abs(r[n][a])>.001&&(f=1)}for(n=0;n<l;n++)d.push(r[n][n]);return[p,d]},rungekutta:function(e,t,r,n,a,i){var o,u,s;if(2===i)for(;n<=r;)a+=((o=t*e(n,a))+(u=t*e(n+t,a+o)))/2,n+=t;if(4===i)for(;n<=r;)a+=((o=t*e(n,a))+2*(u=t*e(n+t/2,a+o/2))+2*(s=t*e(n+t/2,a+u/2))+t*e(n+t,a+s))/6,n+=t;return a},romberg:function(e,r,n,a){for(var i,o,u,s,c,f=0,l=(n-r)/2,p=[],d=[],h=[];f<a/2;){for(c=e(r),u=r,s=0;u<=n;u+=l,s++)p[s]=u;for(i=p.length,u=1;u<i-1;u++)c+=(u%2!=0?4:2)*e(p[u]);c=l/3*(c+e(n)),h[f]=c,l/=2,f++}for(o=h.length,i=1;1!==o;){for(u=0;u<o-1;u++)d[u]=(t.pow(4,i)*h[u+1]-h[u])/(t.pow(4,i)-1);o=d.length,h=d,d=[],i++}return h},richardson:function(e,r,n,a){function i(e,t){for(var r,n=0,a=e.length;n<a;n++)e[n]===t&&(r=n);return r}for(var o,u,s,c,f,l=t.abs(n-e[i(e,n)+1]),p=0,d=[],h=[];a>=l;)o=i(e,n+a),u=i(e,n),d[p]=(r[o]-2*r[u]+r[2*u-o])/(a*a),a/=2,p++;for(c=d.length,s=1;1!=c;){for(f=0;f<c-1;f++)h[f]=(t.pow(4,s)*d[f+1]-d[f])/(t.pow(4,s)-1);c=h.length,d=h,h=[],s++}return d},simpson:function(e,t,r,n){for(var a,i=(r-t)/n,o=e(t),u=[],s=t,c=0,f=1;s<=r;s+=i,c++)u[c]=s;for(a=u.length;f<a-1;f++)o+=(f%2!=0?4:2)*e(u[f]);return i/3*(o+e(r))},hermite:function(e,t,r,n){for(var a,i=e.length,o=0,u=0,s=[],c=[],f=[],l=[];u<i;u++){for(s[u]=1,a=0;a<i;a++)u!=a&&(s[u]*=(n-e[a])/(e[u]-e[a]));for(c[u]=0,a=0;a<i;a++)u!=a&&(c[u]+=1/(e[u]-e[a]));f[u]=(1-2*(n-e[u])*c[u])*(s[u]*s[u]),l[u]=(n-e[u])*(s[u]*s[u]),o+=f[u]*t[u]+l[u]*r[u]}return o},lagrange:function(e,t,r){for(var n,a,i=0,o=0,u=e.length;o<u;o++){for(a=t[o],n=0;n<u;n++)o!=n&&(a*=(r-e[n])/(e[o]-e[n]));i+=a}return i},cubic_spline:function(t,r,n){for(var a,i=t.length,o=0,u=[],s=[],c=[],f=[],l=[],p=[],d=[];o<i-1;o++)l[o]=t[o+1]-t[o];for(c[0]=0,o=1;o<i-1;o++)c[o]=3/l[o]*(r[o+1]-r[o])-3/l[o-1]*(r[o]-r[o-1]);for(o=1;o<i-1;o++)u[o]=[],s[o]=[],u[o][o-1]=l[o-1],u[o][o]=2*(l[o-1]+l[o]),u[o][o+1]=l[o],s[o][0]=c[o];for(f=e.multiply(e.inv(u),s),a=0;a<i-1;a++)p[a]=(r[a+1]-r[a])/l[a]-l[a]*(f[a+1][0]+2*f[a][0])/3,d[a]=(f[a+1][0]-f[a][0])/(3*l[a]);for(a=0;a<i&&!(t[a]>n);a++);return r[a-=1]+(n-t[a])*p[a]+e.sq(n-t[a])*f[a]+(n-t[a])*e.sq(n-t[a])*d[a]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(t){var r,n,a=t.length,i=t[0].length,o=0,u=[],s=[],c=[],f=[],l=[],p=[],d=[],h=[],v=[],m=[];for(o=0;o<a;o++)u[o]=e.sum(t[o])/i;for(o=0;o<i;o++)for(d[o]=[],r=0;r<a;r++)d[o][r]=t[r][o]-u[r];for(d=e.transpose(d),o=0;o<a;o++)for(h[o]=[],r=0;r<a;r++)h[o][r]=e.dot([d[o]],[d[r]])/(i-1);for(v=(c=e.jacobi(h))[0],s=c[1],m=e.transpose(v),o=0;o<s.length;o++)for(r=o;r<s.length;r++)s[o]<s[r]&&(n=s[o],s[o]=s[r],s[r]=n,f=m[o],m[o]=m[r],m[r]=f);for(p=e.transpose(d),o=0;o<a;o++)for(l[o]=[],r=0;r<p.length;r++)l[o][r]=e.dot([m[o]],[p[r]]);return[t,s,m,l]}}),function(t){for(var r=0;r<t.length;r++)!function(t){e.fn[t]=function(r,n){var a=this;return n?(setTimeout((function(){n.call(a,e.fn[t].call(a,r))}),15),this):"number"==typeof e[t](this,r)?e[t](this,r):e(e[t](this,r))}}(t[r])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(e,Math),function(e,t){var r=[].slice,n=e.utils.isNumber,a=e.utils.isArray;function i(e,r,n,a){if(e>1||n>1||e<=0||n<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(e*r+n*a)/(r+a);return(e-n)/t.sqrt(i*(1-i)*(1/r+1/a))}e.extend({zscore:function(){var t=r.call(arguments);return n(t[1])?(t[0]-t[1])/t[2]:(t[0]-e.mean(t[1]))/e.stdev(t[1],t[2])},ztest:function(){var n,i=r.call(arguments);return a(i[1])?(n=e.zscore(i[0],i[1],i[3]),1===i[2]?e.normal.cdf(-t.abs(n),0,1):2*e.normal.cdf(-t.abs(n),0,1)):i.length>2?(n=e.zscore(i[0],i[1],i[2]),1===i[3]?e.normal.cdf(-t.abs(n),0,1):2*e.normal.cdf(-t.abs(n),0,1)):(n=i[0],1===i[1]?e.normal.cdf(-t.abs(n),0,1):2*e.normal.cdf(-t.abs(n),0,1))}}),e.extend(e.fn,{zscore:function(e,t){return(e-this.mean())/this.stdev(t)},ztest:function(r,n,a){var i=t.abs(this.zscore(r,a));return 1===n?e.normal.cdf(-i,0,1):2*e.normal.cdf(-i,0,1)}}),e.extend({tscore:function(){var n=r.call(arguments);return 4===n.length?(n[0]-n[1])/(n[2]/t.sqrt(n[3])):(n[0]-e.mean(n[1]))/(e.stdev(n[1],!0)/t.sqrt(n[1].length))},ttest:function(){var a,i=r.call(arguments);return 5===i.length?(a=t.abs(e.tscore(i[0],i[1],i[2],i[3])),1===i[4]?e.studentt.cdf(-a,i[3]-1):2*e.studentt.cdf(-a,i[3]-1)):n(i[1])?(a=t.abs(i[0]),1==i[2]?e.studentt.cdf(-a,i[1]-1):2*e.studentt.cdf(-a,i[1]-1)):(a=t.abs(e.tscore(i[0],i[1])),1==i[2]?e.studentt.cdf(-a,i[1].length-1):2*e.studentt.cdf(-a,i[1].length-1))}}),e.extend(e.fn,{tscore:function(e){return(e-this.mean())/(this.stdev(!0)/t.sqrt(this.cols()))},ttest:function(r,n){return 1===n?1-e.studentt.cdf(t.abs(this.tscore(r)),this.cols()-1):2*e.studentt.cdf(-t.abs(this.tscore(r)),this.cols()-1)}}),e.extend({anovafscore:function(){var n,a,i,o,u,s,c,f,l=r.call(arguments);if(1===l.length){for(u=new Array(l[0].length),c=0;c<l[0].length;c++)u[c]=l[0][c];l=u}for(a=new Array,c=0;c<l.length;c++)a=a.concat(l[c]);for(i=e.mean(a),n=0,c=0;c<l.length;c++)n+=l[c].length*t.pow(e.mean(l[c])-i,2);for(n/=l.length-1,s=0,c=0;c<l.length;c++)for(o=e.mean(l[c]),f=0;f<l[c].length;f++)s+=t.pow(l[c][f]-o,2);return n/(s/=a.length-l.length)},anovaftest:function(){var t,a,i,o,u=r.call(arguments);if(n(u[0]))return 1-e.centralF.cdf(u[0],u[1],u[2]);var s=e.anovafscore(u);for(t=u.length-1,i=0,o=0;o<u.length;o++)i+=u[o].length;return a=i-t-1,1-e.centralF.cdf(s,t,a)},ftest:function(t,r,n){return 1-e.centralF.cdf(t,r,n)}}),e.extend(e.fn,{anovafscore:function(){return e.anovafscore(this.toArray())},anovaftes:function(){var t,r=0;for(t=0;t<this.length;t++)r+=this[t].length;return e.ftest(this.anovafscore(),this.length-1,r-this.length)}}),e.extend({qscore:function(){var a,i,o,u,s,c=r.call(arguments);return n(c[0])?(a=c[0],i=c[1],o=c[2],u=c[3],s=c[4]):(a=e.mean(c[0]),i=e.mean(c[1]),o=c[0].length,u=c[1].length,s=c[2]),t.abs(a-i)/(s*t.sqrt((1/o+1/u)/2))},qtest:function(){var t,n=r.call(arguments);3===n.length?(t=n[0],n=n.slice(1)):7===n.length?(t=e.qscore(n[0],n[1],n[2],n[3],n[4]),n=n.slice(5)):(t=e.qscore(n[0],n[1],n[2]),n=n.slice(3));var a=n[0],i=n[1];return 1-e.tukey.cdf(t,i,a-i)},tukeyhsd:function(t){for(var r=e.pooledstdev(t),n=t.map((function(t){return e.mean(t)})),a=t.reduce((function(e,t){return e+t.length}),0),i=[],o=0;o<t.length;++o)for(var u=o+1;u<t.length;++u){var s=e.qtest(n[o],n[u],t[o].length,t[u].length,r,a,t.length);i.push([[o,u],s])}return i}}),e.extend({normalci:function(){var n,a=r.call(arguments),i=new Array(2);return n=4===a.length?t.abs(e.normal.inv(a[1]/2,0,1)*a[2]/t.sqrt(a[3])):t.abs(e.normal.inv(a[1]/2,0,1)*e.stdev(a[2])/t.sqrt(a[2].length)),i[0]=a[0]-n,i[1]=a[0]+n,i},tci:function(){var n,a=r.call(arguments),i=new Array(2);return n=4===a.length?t.abs(e.studentt.inv(a[1]/2,a[3]-1)*a[2]/t.sqrt(a[3])):t.abs(e.studentt.inv(a[1]/2,a[2].length-1)*e.stdev(a[2],!0)/t.sqrt(a[2].length)),i[0]=a[0]-n,i[1]=a[0]+n,i},significant:function(e,t){return e<t}}),e.extend(e.fn,{normalci:function(t,r){return e.normalci(t,r,this.toArray())},tci:function(t,r){return e.tci(t,r,this.toArray())}}),e.extend(e.fn,{oneSidedDifferenceOfProportions:function(t,r,n,a){var o=i(t,r,n,a);return e.ztest(o,1)},twoSidedDifferenceOfProportions:function(t,r,n,a){var o=i(t,r,n,a);return e.ztest(o,2)}})}(e,Math),e.models=function(){function t(t){var n=t[0].length;return e.arange(n).map((function(a){var i=e.arange(n).filter((function(e){return e!==a}));return r(e.col(t,a).map((function(e){return e[0]})),e.col(t,i))}))}function r(t,r){var n=t.length,a=r[0].length-1,i=n-a-1,o=e.lstsq(r,t),u=e.multiply(r,o.map((function(e){return[e]}))).map((function(e){return e[0]})),s=e.subtract(t,u),c=e.mean(t),f=e.sum(u.map((function(e){return Math.pow(e-c,2)}))),l=e.sum(t.map((function(e,t){return Math.pow(e-u[t],2)}))),p=f+l;return{exog:r,endog:t,nobs:n,df_model:a,df_resid:i,coef:o,predict:u,resid:s,ybar:c,SST:p,SSE:f,SSR:l,R2:f/p}}function n(r){var n=t(r.exog),a=Math.sqrt(r.SSR/r.df_resid),i=n.map((function(e){var t=e.SST,r=e.R2;return a/Math.sqrt(t*(1-r))})),o=r.coef.map((function(e,t){return(e-0)/i[t]})),u=o.map((function(t){var n=e.studentt.cdf(t,r.df_resid);return 2*(n>.5?1-n:n)})),s=e.studentt.inv(.975,r.df_resid),c=r.coef.map((function(e,t){var r=s*i[t];return[e-r,e+r]}));return{se:i,t:o,p:u,sigmaHat:a,interval95:c}}function a(t){var r,n,a,i=t.R2/t.df_model/((1-t.R2)/t.df_resid);return{F_statistic:i,pvalue:1-(r=i,n=t.df_model,a=t.df_resid,e.beta.cdf(r/(a/n+r),n/2,a/2))}}function i(e,t){var i=r(e,t),o=n(i),u=a(i),s=1-(1-i.R2)*((i.nobs-1)/i.df_resid);return i.t=o,i.f=u,i.adjust_R2=s,i}return{ols:i}}(),e.extend({buildxmatrix:function(){for(var t=new Array(arguments.length),r=0;r<arguments.length;r++){var n=[1];t[r]=n.concat(arguments[r])}return e(t)},builddxmatrix:function(){for(var t=new Array(arguments[0].length),r=0;r<arguments[0].length;r++){var n=[1];t[r]=n.concat(arguments[0][r])}return e(t)},buildjxmatrix:function(t){for(var r=new Array(t.length),n=0;n<t.length;n++)r[n]=t[n];return e.builddxmatrix(r)},buildymatrix:function(t){return e(t).transpose()},buildjymatrix:function(e){return e.transpose()},matrixmult:function(t,r){var n,a,i,o,u;if(t.cols()==r.rows()){if(r.rows()>1){for(o=[],n=0;n<t.rows();n++)for(o[n]=[],a=0;a<r.cols();a++){for(u=0,i=0;i<t.cols();i++)u+=t.toArray()[n][i]*r.toArray()[i][a];o[n][a]=u}return e(o)}for(o=[],n=0;n<t.rows();n++)for(o[n]=[],a=0;a<r.cols();a++){for(u=0,i=0;i<t.cols();i++)u+=t.toArray()[n][i]*r.toArray()[a];o[n][a]=u}return e(o)}},regress:function(t,r){var n=e.xtranspxinv(t),a=t.transpose(),i=e.matrixmult(e(n),a);return e.matrixmult(i,r)},regresst:function(t,r,n){var a=e.regress(t,r),i={anova:{}},o=e.jMatYBar(t,a);i.yBar=o;var u=r.mean();i.anova.residuals=e.residuals(r,o),i.anova.ssr=e.ssr(o,u),i.anova.msr=i.anova.ssr/(t[0].length-1),i.anova.sse=e.sse(r,o),i.anova.mse=i.anova.sse/(r.length-(t[0].length-1)-1),i.anova.sst=e.sst(r,u),i.anova.mst=i.anova.sst/(r.length-1),i.anova.r2=1-i.anova.sse/i.anova.sst,i.anova.r2<0&&(i.anova.r2=0),i.anova.fratio=i.anova.msr/i.anova.mse,i.anova.pvalue=e.anovaftest(i.anova.fratio,t[0].length-1,r.length-(t[0].length-1)-1),i.anova.rmse=Math.sqrt(i.anova.mse),i.anova.r2adj=1-i.anova.mse/i.anova.mst,i.anova.r2adj<0&&(i.anova.r2adj=0),i.stats=new Array(t[0].length);for(var s,c,f,l=e.xtranspxinv(t),p=0;p<a.length;p++)s=Math.sqrt(i.anova.mse*Math.abs(l[p][p])),c=Math.abs(a[p]/s),f=e.ttest(c,r.length-t[0].length-1,n),i.stats[p]=[a[p],s,c,f];return i.regress=a,i},xtranspx:function(t){return e.matrixmult(t.transpose(),t)},xtranspxinv:function(t){var r=e.matrixmult(t.transpose(),t);return e.inv(r)},jMatYBar:function(t,r){var n=e.matrixmult(t,r);return new e(n)},residuals:function(t,r){return e.matrixsubtract(t,r)},ssr:function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},sse:function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t[n],2);return r},sst:function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},matrixsubtract:function(t,r){for(var n=new Array(t.length),a=0;a<t.length;a++){n[a]=new Array(t[a].length);for(var i=0;i<t[a].length;i++)n[a][i]=t[a][i]-r[a][i]}return e(n)}}),e.jStat=e,e}()}(ae)),ae.exports),oe=re(ie);function ue(){for(var e=[],t=0;t<arguments.length;++t){for(var r=!1,n=arguments[t],a=0;a<e.length&&!(r=e[a]===n);++a);r||e.push(n)}return e}function se(e,t,r,n){if(!t||!r)return u;n=!(0===n||!1===n);for(var i=u,o=!1,s="number"==typeof e,c="string"==typeof e?e.toLowerCase():e,f=0;f<t.length;f++){var l=t[f],p="string"==typeof l[0]?l[0].toLowerCase():l[0];if(p===c){i=r<l.length+1?l[r-1]:a;break}!o&&(s&&n&&p<=e||n&&"string"==typeof p&&p.localeCompare(e)<0)&&(i=r<l.length+1?l[r-1]:a),s&&p>e&&(o=!0)}return i}function ce(e,t){return-1===t?Array.from({length:e},(function(t,r){return e-1-r})):Array.from({length:e},(function(e,t){return t}))}function fe(e){return 0===(e=V(e))?n:e instanceof Error?e:String.fromCharCode(e)}function le(e){if(F(e))return e;var t=(e=e||"").charCodeAt(0);return isNaN(t)&&(t=n),t}function pe(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;for(var r=0;(r=e.indexOf(!0))>-1;)e[r]="TRUE";for(var n=0;(n=e.indexOf(!1))>-1;)e[n]="FALSE";return e.join("")}var de=pe;function he(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2,r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(e=V(e),isNaN(e))return n;if(t=V(t),isNaN(t))return n;if(t<0){var a=Math.pow(10,-t);e=Math.round(e/a)*a}else e=e.toFixed(t);if(r)e=e.toString().replace(/,/g,"");else{var i=e.toString().split(".");i[0]=i[0].replace(/\B(?=(\d{3})+$)/g,","),e=i.join(".")}return e}function ve(e,t){var r=L(e,t);return r||(e=B(e),(t=V(t))instanceof Error?t:new Array(t+1).join(e))}function me(e){return e instanceof Error||"string"==typeof e?e:""}var ge=fe,ye=le;function _e(){var e=C(arguments).filter(X);if(0===e.length)return r;var t=L.apply(void 0,e);if(t)return t;for(var n,a=q(e),i=a.length,u=0,s=0,c=0;c<i;c++)u+=a[c],s+=1;return n=u/s,isNaN(n)&&(n=o),n}function be(){var e=C(arguments).filter(X);if(0===e.length)return r;var t=L.apply(void 0,e);if(t)return t;for(var n,a=e,i=a.length,u=0,s=0,c=0;c<i;c++){var f=a[c];"number"==typeof f&&(u+=f),!0===f&&u++,null!==f&&s++}return n=u/s,isNaN(n)&&(n=o),n}var ke={DIST:function(e,t,r,a,i,o){return arguments.length<4?n:(i=void 0===i?0:i,o=void 0===o?1:o,F(e=V(e),t=V(t),r=V(r),i=V(i),o=V(o))?n:(e=(e-i)/(o-i),a?oe.beta.cdf(e,t,r):oe.beta.pdf(e,t,r)))},INV:function(e,t,r,a,i){return a=void 0===a?0:a,i=void 0===i?1:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i))?n:oe.beta.inv(e,t,r)*(i-a)+a}},we={DIST:function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r),a=V(a))?n:a?oe.binomial.cdf(e,t,r):oe.binomial.pdf(e,t,r)}};we.DIST.RANGE=function(e,t,r,a){if(a=void 0===a?r:a,F(e=V(e),t=V(t),r=V(r),a=V(a)))return n;for(var i=0,o=r;o<=a;o++)i+=it(e,o)*Math.pow(t,o)*Math.pow(1-t,e-o);return i},we.INV=function(e,t,r){if(F(e=V(e),t=V(t),r=V(r)))return n;for(var a=0;a<=e;){if(oe.binomial.cdf(a,e,t)>=r)return a;a++}};var xe={DIST:function(e,t,r){return F(e=V(e),t=V(t))?n:r?oe.chisquare.cdf(e,t):oe.chisquare.pdf(e,t)}};xe.DIST.RT=function(e,t){return!e|!t?u:e<1||t>Math.pow(10,10)?o:"number"!=typeof e||"number"!=typeof t?n:1-oe.chisquare.cdf(e,t)},xe.INV=function(e,t){return F(e=V(e),t=V(t))?n:oe.chisquare.inv(e,t)},xe.INV.RT=function(e,t){return!e|!t?u:e<0||e>1||t<1||t>Math.pow(10,10)?o:"number"!=typeof e||"number"!=typeof t?n:oe.chisquare.inv(1-e,t)},xe.TEST=function(e,t){if(2!==arguments.length)return u;if(!(e instanceof Array&&t instanceof Array))return n;if(e.length!==t.length)return n;if(e[0]&&t[0]&&e[0].length!==t[0].length)return n;var r,a,i,o=e.length;for(a=0;a<o;a++)e[a]instanceof Array||(r=e[a],e[a]=[],e[a].push(r)),t[a]instanceof Array||(r=t[a],t[a]=[],t[a].push(r));var s=e[0].length,c=1===s?o-1:(o-1)*(s-1),f=0,l=Math.PI;for(a=0;a<o;a++)for(i=0;i<s;i++)f+=Math.pow(e[a][i]-t[a][i],2)/t[a][i];return Math.round(1e6*function(e,t){var r=Math.exp(-.5*e);t%2==1&&(r*=Math.sqrt(2*e/l));for(var n=t;n>=2;)r=r*e/n,n-=2;for(var a=r,i=t;a>1e-10*r;)r+=a=a*e/(i+=2);return 1-r}(f,c))/1e6};var Se={};function Ee(){return q(C(arguments)).length}function Ne(){var e=C(arguments);return e.length-Te(e)}function Te(){for(var e,t=C(arguments),r=0,n=0;n<t.length;n++)null!=(e=t[n])&&""!==e||r++;return r}Se.NORM=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.normalci(1,e,t,r)[1]-1},Se.T=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.tci(1,e,t,r)[1]-1};var Ae={};Ae.P=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(e),a=oe.mean(t),i=0,o=e.length,u=0;u<o;u++)i+=(e[u]-r)*(t[u]-a);return i/o},Ae.S=function(e,t){return F(e=Y(C(e)),t=Y(C(t)))?n:oe.covariance(e,t)};var Ie={DIST:function(e,t,r){return F(e=V(e),t=V(t))?n:r?oe.exponential.cdf(e,t):oe.exponential.pdf(e,t)}},Me={};function Ce(e,t,r){if(F(e=V(e),t=Y(C(t)),r=Y(C(r))))return n;for(var a=oe.mean(r),i=oe.mean(t),o=r.length,u=0,s=0,c=0;c<o;c++)u+=(r[c]-a)*(t[c]-i),s+=Math.pow(r[c]-a,2);var f=u/s;return i-f*a+f*e}function Oe(e){return(e=V(e))instanceof Error?e:0===e||parseInt(e,10)===e&&e<0?o:oe.gammafn(e)}function Re(e){return(e=V(e))instanceof Error?e:oe.gammaln(e)}Me.DIST=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?oe.centralF.cdf(e,t,r):oe.centralF.pdf(e,t,r)},Me.DIST.RT=function(e,t,r){return 3!==arguments.length?u:e<0||t<1||r<1?o:"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:1-oe.centralF.cdf(e,t,r)},Me.INV=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:e<=0||e>1?o:oe.centralF.inv(e,t,r)},Me.INV.RT=function(e,t,r){return 3!==arguments.length?u:e<0||e>1||t<1||t>Math.pow(10,10)||r<1||r>Math.pow(10,10)?o:"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:oe.centralF.inv(1-e,t,r)},Me.TEST=function(e,t){if(!e||!t)return u;if(!(e instanceof Array&&t instanceof Array))return u;if(e.length<2||t.length<2)return r;var n=function(e,t){for(var r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},a=dt(e)/e.length,i=dt(t)/t.length;return n(e,a)/(e.length-1)/(n(t,i)/(t.length-1))},Oe.DIST=function(e,t,r,a){return 4!==arguments.length?u:e<0||t<=0||r<=0||"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:a?oe.gamma.cdf(e,t,r,!0):oe.gamma.pdf(e,t,r,!1)},Oe.INV=function(e,t,r){return 3!==arguments.length?u:e<0||e>1||t<=0||r<=0?o:"number"!=typeof e||"number"!=typeof t||"number"!=typeof r?n:oe.gamma.inv(e,t,r)},Re.PRECISE=function(e){return 1!==arguments.length?u:e<=0?o:"number"!=typeof e?n:oe.gammaln(e)};var je={};function De(e,t){var r=L.apply(void 0,e);return r||(F(t)?t:(e=q(C(e)),(t=V(t))<0||e.length<t?n:e.sort((function(e,t){return t-e}))[t-1]))}function Pe(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(e),a=oe.mean(t),i=t.length,o=0,u=0,s=0;s<i;s++)o+=(t[s]-a)*(e[s]-r),u+=Math.pow(t[s]-a,2);var c=o/u;return[c,r-c*a]}je.DIST=function(e,t,r,a,i){if(F(e=V(e),t=V(t),r=V(r),a=V(a)))return n;function o(e,t,r,n){return it(r,e)*it(n-r,t-e)/it(n,t)}return i?function(e,t,r,n){for(var a=0,i=0;i<=e;i++)a+=o(i,t,r,n);return a}(e,t,r,a):o(e,t,r,a)};var Le={};function Fe(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=q(e);return 0===r.length?0:Math.max.apply(Math,r)}function Ue(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=I(e),n=oe.median(r);return isNaN(n)&&(n=o),n}function qe(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=q(e);return 0===r.length?0:Math.min.apply(Math,r)}Le.DIST=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?oe.lognormal.cdf(e,t,r):oe.lognormal.pdf(e,t,r)},Le.INV=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.lognormal.inv(e,t,r)};var Ge={MULT:function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t,r=e.length,n={},a=[],i=0,o=0;o<r;o++)n[t=e[o]]=n[t]?n[t]+1:1,n[t]>i&&(i=n[t],a=[]),n[t]===i&&(a[a.length]=t);return a},SNGL:function(){var e=Y(C(arguments));return e instanceof Error?e:Ge.MULT(e).sort((function(e,t){return e-t}))[0]}},He={DIST:function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?oe.negbin.cdf(e,t,r):oe.negbin.pdf(e,t,r)}},Ze={};function Ve(e,t){if(F(t=Y(C(t)),e=Y(C(e))))return n;for(var r=oe.mean(e),a=oe.mean(t),i=e.length,o=0,u=0,s=0,c=0;c<i;c++)o+=(e[c]-r)*(t[c]-a),u+=Math.pow(e[c]-r,2),s+=Math.pow(t[c]-a,2);return o/Math.sqrt(u*s)}Ze.DIST=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:r<=0?o:a?oe.normal.cdf(e,t,r):oe.normal.pdf(e,t,r)},Ze.INV=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:oe.normal.inv(e,t,r)},Ze.S={},Ze.S.DIST=function(e,t){return(e=V(e))instanceof Error?n:t?oe.normal.cdf(e,0,1):oe.normal.pdf(e,0,1)},Ze.S.INV=function(e){return(e=V(e))instanceof Error?n:oe.normal.inv(e,0,1)};var Ye={EXC:function(e,t){if(F(e=Y(C(e)),t=V(t)))return n;var r=(e=e.sort((function(e,t){return e-t}))).length;if(t<1/(r+1)||t>1-1/(r+1))return o;var a=t*(r+1)-1,i=Math.floor(a);return U(a===i?e[a]:e[i]+(a-i)*(e[i+1]-e[i]))},INC:function(e,t){if(F(e=Y(C(e)),t=V(t)))return n;var r=t*((e=e.sort((function(e,t){return e-t}))).length-1),a=Math.floor(r);return U(r===a?e[r]:e[a]+(r-a)*(e[a+1]-e[a]))}},Be={};Be.EXC=function(e,t,r){if(r=void 0===r?3:r,F(e=Y(C(e)),t=V(t),r=V(r)))return n;e=e.sort((function(e,t){return e-t}));for(var a=ue.apply(null,e),i=e.length,o=a.length,u=Math.pow(10,r),s=0,c=!1,f=0;!c&&f<o;)t===a[f]?(s=(e.indexOf(a[f])+1)/(i+1),c=!0):t>=a[f]&&(t<a[f+1]||f===o-1)&&(s=(e.indexOf(a[f])+1+(t-a[f])/(a[f+1]-a[f]))/(i+1),c=!0),f++;return Math.floor(s*u)/u},Be.INC=function(e,t,r){if(r=void 0===r?3:r,F(e=Y(C(e)),t=V(t),r=V(r)))return n;e=e.sort((function(e,t){return e-t}));for(var a=ue.apply(null,e),i=e.length,o=a.length,u=Math.pow(10,r),s=0,c=!1,f=0;!c&&f<o;)t===a[f]?(s=e.indexOf(a[f])/(i-1),c=!0):t>=a[f]&&(t<a[f+1]||f===o-1)&&(s=(e.indexOf(a[f])+(t-a[f])/(a[f+1]-a[f]))/(i-1),c=!0),f++;return Math.floor(s*u)/u};var Ke={};Ke.DIST=function(e,t,r){return F(e=V(e),t=V(t))?n:r?oe.poisson.cdf(e,t):oe.poisson.pdf(e,t)};var ze={EXC:function(e,t){if(F(e=Y(q(C(e))),t=V(t)))return n;switch(t){case 1:return Ye.EXC(e,.25);case 2:return Ye.EXC(e,.5);case 3:return Ye.EXC(e,.75);default:return o}},INC:function(e,t){if(F(e=Y(q(C(e))),t=V(t)))return n;switch(t){case 1:return Ye.INC(e,.25);case 2:return Ye.INC(e,.5);case 3:return Ye.INC(e,.75);default:return o}}},Xe={};function We(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=e.length,n=0,a=0;a<r;a++)n+=Math.pow(e[a]-t,3);return r*n/((r-1)*(r-2)*Math.pow(oe.stdev(e,!0),3))}function $e(e,t){return F(e=Y(C(e)),t=V(t))?e:e.sort((function(e,t){return e-t}))[t-1]}Xe.AVG=function(e,t,r){if(F(e=V(e),t=Y(C(t))))return n;for(var a=(r=r||!1)?function(e,t){return e-t}:function(e,t){return t-e},i=(t=(t=C(t)).sort(a)).length,o=0,u=0;u<i;u++)t[u]===e&&o++;return o>1?(2*t.indexOf(e)+o+1)/2:t.indexOf(e)+1},Xe.EQ=function(e,t,r){if(F(e=V(e),t=Y(C(t))))return n;var a=(r=r||!1)?function(e,t){return e-t}:function(e,t){return t-e};return(t=t.sort(a)).indexOf(e)+1},We.P=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=e.length,n=0,a=0,i=0;i<r;i++)a+=Math.pow(e[i]-t,3),n+=Math.pow(e[i]-t,2);return n/=r,(a/=r)/Math.pow(n,1.5)};var Qe={};Qe.P=function(){var e=Je.P.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=o),t},Qe.S=function(){var e=Je.S.apply(this,arguments);return Math.sqrt(e)},me.DIST=function(e,t,r){return 1!==r&&2!==r?o:1===r?me.DIST.RT(e,t):me.DIST["2T"](e,t)},me.DIST["2T"]=function(e,t){return 2!==arguments.length?u:e<0||t<1?o:"number"!=typeof e||"number"!=typeof t?n:2*(1-oe.studentt.cdf(e,t))},me.DIST.RT=function(e,t){return 2!==arguments.length?u:e<0||t<1?o:"number"!=typeof e||"number"!=typeof t?n:1-oe.studentt.cdf(e,t)},me.INV=function(e,t){return F(e=V(e),t=V(t))?n:oe.studentt.inv(e,t)},me.INV["2T"]=function(e,t){return e=V(e),t=V(t),e<=0||e>1||t<1?o:F(e,t)?n:Math.abs(oe.studentt.inv(e/2,t))},me.TEST=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;var r,a=oe.mean(e),i=oe.mean(t),o=0,u=0;for(r=0;r<e.length;r++)o+=Math.pow(e[r]-a,2);for(r=0;r<t.length;r++)u+=Math.pow(t[r]-i,2);o/=e.length-1,u/=t.length-1;var s=Math.abs(a-i)/Math.sqrt(o/e.length+u/t.length);return me.DIST["2T"](s,e.length+t.length-2)};var Je={};function et(){for(var e=C(arguments),t=e.length,r=0,n=0,a=be(e),i=0;i<t;i++){var o=e[i];r+="number"==typeof o?Math.pow(o-a,2):!0===o?Math.pow(1-a,2):Math.pow(0-a,2),null!==o&&n++}return r/(n-1)}function tt(){for(var e,t=C(arguments),r=t.length,n=0,a=0,i=be(t),u=0;u<r;u++){var s=t[u];n+="number"==typeof s?Math.pow(s-i,2):!0===s?Math.pow(1-i,2):Math.pow(0-i,2),null!==s&&a++}return e=n/a,isNaN(e)&&(e=o),e}Je.P=function(){for(var e,t=q(C(arguments)),r=t.length,n=0,a=_e(t),i=0;i<r;i++)n+=Math.pow(t[i]-a,2);return e=n/r,isNaN(e)&&(e=o),e},Je.S=function(){for(var e=q(C(arguments)),t=e.length,r=0,n=_e(e),a=0;a<t;a++)r+=Math.pow(e[a]-n,2);return r/(t-1)};var rt={DIST:function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r))?n:a?1-Math.exp(-Math.pow(e/r,t)):Math.pow(e,t-1)*Math.exp(-Math.pow(e/r,t))*t/Math.pow(r,t)}},nt={};function at(e,t){var r=L(e=V(e),t=V(t));return r||(0===t?0:e>0&&t<0?o:Math.ceil(e/t)*t)}function it(e,t){var r=L(e=V(e),t=V(t));return r||(e<t?o:ut(e)/(ut(t)*ut(e-t)))}nt.TEST=function(e,t,r){if(F(e=Y(C(e)),t=V(t)))return n;r=r||Qe.S(e);var a=e.length;return 1-Ze.S.DIST((_e(e)-t)/(r/Math.sqrt(a)),!0)},at.MATH=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;void 0===t&&(t=e>0?1:-1);var n=L(e=V(e),t=V(t),r=V(r));return n||(0===t?0:(t=Math.abs(t),0===r||e>0?Math.ceil(e/t)*t:Math.floor(e/t)*t))},at.PRECISE=function(e,t){return at.MATH(e,t)};var ot=[];function ut(e){if((e=V(e))instanceof Error)return e;var t=Math.floor(e);return 0===t||1===t?1:(ot[t]>0||(ot[t]=ut(t-1)*t),ot[t])}function st(e,t){var n=L(e=V(e),t=V(t));return n||(t?e>0&&t<0?o:Math.floor(e/t)*t:r)}st.MATH=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,n=L(e=V(e),t=V(t),r=V(r));return n||(0===t?0:(t=Math.abs(t),0===r||e>0?Math.floor(e/t)*t:Math.ceil(e/t)*t))},st.PRECISE=function(e,t){return st.MATH(e,t)};var ct={CEILING:at};function ft(e,t){var r=L(e=V(e),t=V(t));if(r)return r;if(0===e&&0===t)return o;var n=Math.pow(e,t);return isNaN(n)?o:n}function lt(){var e=C(arguments).filter((function(e){return null!=e}));if(0===e.length)return 0;var t=Y(e);if(t instanceof Error)return t;for(var r=1,n=0;n<t.length;n++)r*=t[n];return r}function pt(e,t){var r=L(e=V(e),t=V(t));return r||Number(Math.round(Number(e+"e"+t))+"e"+-1*t)}function dt(){var e=0;return A(T(arguments),(function(t){if(e instanceof Error)return!1;if(t instanceof Error)e=t;else if("number"==typeof t)e+=t;else if("string"==typeof t){var r=parseFloat(t);!isNaN(r)&&(e+=r)}else if(Array.isArray(t)){var n=dt.apply(null,t);n instanceof Error?e=n:e+=n}})),e}var ht=Object.freeze({__proto__:null,ADD:function(e,t){if(2!==arguments.length)return u;var r=L(e=V(e),t=V(t));return r||e+t},DIVIDE:function(e,t){if(2!==arguments.length)return u;var n=L(e=V(e),t=V(t));return n||(0===t?r:e/t)},EQ:function(e,t){return 2!==arguments.length?u:e instanceof Error?e:t instanceof Error?t:(null===e&&(e=void 0),null===t&&(t=void 0),e===t)},GT:function(e,t){if(2!==arguments.length)return u;if(e instanceof Error)return e;if(t instanceof Error)return t;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e>t},GTE:function(e,t){if(2!==arguments.length)return u;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e>=t},LT:function(e,t){if(2!==arguments.length)return u;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e<t},LTE:function(e,t){if(2!==arguments.length)return u;K(e,t)?(e=B(e),t=B(t)):(e=V(e),t=V(t));var r=L(e,t);return r||e<=t},MINUS:function(e,t){if(2!==arguments.length)return u;var r=L(e=V(e),t=V(t));return r||e-t},MULTIPLY:function(e,t){if(2!==arguments.length)return u;var r=L(e=V(e),t=V(t));return r||e*t},NE:function(e,t){return 2!==arguments.length?u:e instanceof Error?e:t instanceof Error?t:(null===e&&(e=void 0),null===t&&(t=void 0),e!==t)},POW:function(e,t){return 2!==arguments.length?u:ft(e,t)}}),vt=[void 0,0,1,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,1,2,3,4,5,6,0],mt=[[],[1,2,3,4,5,6,7],[7,1,2,3,4,5,6],[6,0,1,2,3,4,5],[],[],[],[],[],[],[],[7,1,2,3,4,5,6],[6,7,1,2,3,4,5],[5,6,7,1,2,3,4],[4,5,6,7,1,2,3],[3,4,5,6,7,1,2],[2,3,4,5,6,7,1],[1,2,3,4,5,6,7]],gt=[[],[6,0],[0,1],[1,2],[2,3],[3,4],[4,5],[5,6],void 0,void 0,void 0,[0,0],[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]];function yt(e,t,r){r=r.toUpperCase(),e=H(e),t=H(t);var n,a=e.getFullYear(),i=e.getMonth(),o=e.getDate(),u=t.getFullYear(),s=t.getMonth(),c=t.getDate();switch(r){case"Y":n=Math.floor(It(e,t));break;case"D":n=bt(t,e);break;case"M":n=s-i+12*(u-a),c<o&&n--;break;case"MD":o<=c?n=c-o:(0===s?(e.setFullYear(u-1),e.setMonth(12)):(e.setFullYear(u),e.setMonth(s-1)),n=bt(t,e));break;case"YM":n=s-i+12*(u-a),c<o&&n--,n%=12;break;case"YD":s>i||s===i&&c<o?e.setFullYear(u):e.setFullYear(u-1),n=bt(t,e)}return n}function _t(e){var t=new Date(e);return t.setHours(0,0,0,0),t}function bt(e,t){return e=H(e),t=H(t),e instanceof Error?e:t instanceof Error?t:(_t(e).getTime()-_t(t).getTime())/864e5}function kt(e,t,r){if(r=G(r||"false"),e=H(e),t=H(t),e instanceof Error)return e;if(t instanceof Error)return t;if(r instanceof Error)return r;var n,a,i=e.getMonth(),o=t.getMonth();if(r)n=31===e.getDate()?30:e.getDate(),a=31===t.getDate()?30:t.getDate();else{var u=new Date(e.getFullYear(),i+1,0).getDate(),s=new Date(t.getFullYear(),o+1,0).getDate();n=e.getDate()===u?30:e.getDate(),t.getDate()===s?n<30?(o++,a=1):a=30:a=t.getDate()}return 360*(t.getFullYear()-e.getFullYear())+30*(o-i)+(a-n)}function wt(e){if((e=H(e))instanceof Error)return e;(e=_t(e)).setDate(e.getDate()+4-(e.getDay()||7));var t=new Date(e.getFullYear(),0,1);return Math.ceil(((e-t)/864e5+1)/7)}function xt(e,t,r){return xt.INTL(e,t,1,r)}xt.INTL=function(e,t,r,a){if((e=H(e))instanceof Error)return e;if((t=H(t))instanceof Error)return t;var i=!1,o=[],u=[1,2,3,4,5,6,0],s=new RegExp("^[0|1]{7}$");if(void 0===r)r=gt[1];else if("string"==typeof r&&s.test(r)){i=!0,r=r.split("");for(var c=0;c<r.length;c++)"1"===r[c]&&o.push(u[c])}else r=gt[r];if(!(r instanceof Array))return n;void 0===a?a=[]:a instanceof Array||(a=[a]);for(var f=0;f<a.length;f++){var l=H(a[f]);if(l instanceof Error)return l;a[f]=l}for(var p=Math.round((t-e)/864e5)+1,d=p,h=e,v=0;v<p;v++){for(var m=(new Date).getTimezoneOffset()>0?h.getUTCDay():h.getDay(),g=i?o.includes(m):m===r[0]||m===r[1],y=0;y<a.length;y++){var _=a[y];if(_.getDate()===h.getDate()&&_.getMonth()===h.getMonth()&&_.getFullYear()===h.getFullYear()){g=!0;break}}g&&d--,h.setDate(h.getDate()+1)}return d};var St=xt.INTL;function Et(e,t,r){return Et.INTL(e,t,1,r)}Et.INTL=function(e,t,r,a){if((e=H(e))instanceof Error)return e;if((t=V(t))instanceof Error)return t;if(!((r=void 0===r?gt[1]:gt[r])instanceof Array))return n;void 0===a?a=[]:a instanceof Array||(a=[a]);for(var i=0;i<a.length;i++){var o=H(a[i]);if(o instanceof Error)return o;a[i]=o}for(var u=0,s=Math.sign(t);u<t*s;){e.setDate(e.getDate()+s);var c=e.getDay();if(c!==r[0]&&c!==r[1]){for(var f=0;f<a.length;f++){var l=a[f];if(l.getDate()===e.getDate()&&l.getMonth()===e.getMonth()&&l.getFullYear()===e.getFullYear()){u--;break}}u++}}return e.getFullYear()<1900?n:v(e)};var Nt=Et.INTL;function Tt(e){return 1===new Date(e,1,29).getMonth()}function At(e,t){return Math.ceil((t-e)/1e3/60/60/24)}function It(e,t,r){if((e=H(e))instanceof Error)return e;if((t=H(t))instanceof Error)return t;r=r||0;var n=e.getDate(),a=e.getMonth()+1,i=e.getFullYear(),o=t.getDate(),u=t.getMonth()+1,s=t.getFullYear();switch(r){case 0:return 31===n&&31===o?(n=30,o=30):31===n?n=30:30===n&&31===o&&(o=30),(o+30*u+360*s-(n+30*a+360*i))/360;case 1:var c=365;if(i===s||i+1===s&&(a>u||a===u&&n>=o))return(i===s&&Tt(i)||function(e,t){var r=e.getFullYear(),n=new Date(r,2,1);if(Tt(r)&&e<n&&t>=n)return!0;var a=t.getFullYear(),i=new Date(a,2,1);return Tt(a)&&t>=i&&e<i}(e,t)||1===u&&29===o)&&(c=366),At(e,t)/c;var f=s-i+1,l=(new Date(s+1,0,1)-new Date(i,0,1))/1e3/60/60/24/f;return At(e,t)/l;case 2:return At(e,t)/360;case 3:return At(e,t)/365;case 4:return(o+30*u+360*s-(n+30*a+360*i))/360}}var Mt,Ct={};var Ot=(Mt||(Mt=1,function(e){var t;t=function(e){e.version="1.0.2";var t=Math;function r(e,t){for(var r=0,n=0;r<e.length;++r)n=t*n+e[r];return n}function n(e,t,r,n,a){if(0===t)return r;if(1===t)return n;for(var i=2/e,o=n,u=1;u<t;++u)o=n*u*i+a*r,r=n,n=o;return o}function a(e,t,r,a,i){return function(r,o){if(a){if(0===r)return 1==a?-1/0:1/0;if(r<0)return NaN}return 0===o?e(r):1===o?t(r):o<0?NaN:n(r,o|=0,e(r),t(r),i)}}var i,o,u,s,c,f,l,p,d,h,v,m,g,y=function(){var e=.636619772,a=[57568490574,-13362590354,651619640.7,-11214424.18,77392.33017,-184.9052456].reverse(),i=[57568490411,1029532985,9494680.718,59272.64853,267.8532712,1].reverse(),o=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),u=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34935152e-8].reverse();function s(n){var s=0,c=0,f=0,l=n*n;if(n<8)s=(c=r(a,l))/(f=r(i,l));else{var p=n-.785398164;c=r(o,l=64/l),f=r(u,l),s=t.sqrt(e/n)*(t.cos(p)*c-t.sin(p)*f*8/n)}return s}var c=[72362614232,-7895059235,242396853.1,-2972611.439,15704.4826,-30.16036606].reverse(),f=[144725228442,2300535178,18583304.74,99447.43394,376.9991397,1].reverse(),l=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),p=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();function d(n){var a=0,i=0,o=0,u=n*n,s=t.abs(n)-2.356194491;return Math.abs(n)<8?a=(i=n*r(c,u))/(o=r(f,u)):(i=r(l,u=64/u),o=r(p,u),a=t.sqrt(e/t.abs(n))*(t.cos(s)*i-t.sin(s)*o*8/t.abs(n)),n<0&&(a=-a)),a}return function e(r,a){if(a=Math.round(a),!isFinite(r))return isNaN(r)?r:0;if(a<0)return(a%2?-1:1)*e(r,-a);if(r<0)return(a%2?-1:1)*e(-r,a);if(0===a)return s(r);if(1===a)return d(r);if(0===r)return 0;var i=0;if(r>a)i=n(r,a,s(r),d(r),-1);else{for(var o=!1,u=0,c=0,f=1,l=0,p=2/r,h=2*t.floor((a+t.floor(t.sqrt(40*a)))/2);h>0;h--)l=h*p*f-u,u=f,f=l,t.abs(f)>1e10&&(f*=1e-10,u*=1e-10,i*=1e-10,c*=1e-10),o&&(c+=f),o=!o,h==a&&(i=u);i/=c=2*c-f}return i}}(),_=(i=.636619772,o=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),u=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),s=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),c=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse(),f=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),l=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),p=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),d=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse(),a((function(e){var n=0,a=0,f=0,l=e*e,p=e-.785398164;return e<8?n=(a=r(o,l))/(f=r(u,l))+i*y(e,0)*t.log(e):(a=r(s,l=64/l),f=r(c,l),n=t.sqrt(i/e)*(t.sin(p)*a+t.cos(p)*f*8/e)),n}),(function(e){var n=0,a=0,o=0,u=e*e,s=e-2.356194491;return e<8?n=(a=e*r(f,u))/(o=r(l,u))+i*(y(e,1)*t.log(e)-1/e):(a=r(p,u=64/u),o=r(d,u),n=t.sqrt(i/e)*(t.sin(s)*a+t.cos(s)*o*8/e)),n}),0,1,-1)),b=(h=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),v=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse(),m=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),g=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse(),function e(n,a){if(0===(a=Math.round(a)))return function(e){return e<=3.75?r(h,e*e/14.0625):t.exp(t.abs(e))/t.sqrt(t.abs(e))*r(v,3.75/t.abs(e))}(n);if(1===a)return function(e){return e<3.75?e*r(m,e*e/14.0625):(e<0?-1:1)*t.exp(t.abs(e))/t.sqrt(t.abs(e))*r(g,3.75/t.abs(e))}(n);if(a<0)return NaN;if(0===t.abs(n))return 0;if(n==1/0)return 1/0;var i,o=0,u=2/t.abs(n),s=0,c=1,f=0;for(i=2*t.round((a+t.round(t.sqrt(40*a)))/2);i>0;i--)f=i*u*c+s,s=c,c=f,t.abs(c)>1e10&&(c*=1e-10,s*=1e-10,o*=1e-10),i==a&&(o=s);return o*=e(n,0)/c,n<0&&a%2?-o:o}),k=function(){var e=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),n=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse(),i=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),o=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();return a((function(a){return a<=2?-t.log(a/2)*b(a,0)+r(e,a*a/4):t.exp(-a)/t.sqrt(a)*r(n,2/a)}),(function(e){return e<=2?t.log(e/2)*b(e,1)+1/e*r(i,e*e/4):t.exp(-e)/t.sqrt(e)*r(o,2/e)}),0,2,1)}();e.besselj=y,e.bessely=_,e.besseli=b,e.besselk=k},"undefined"==typeof DO_NOT_EXPORT_BESSEL?t(e):t({})}(Ct)),Ct),Rt=re(Ot);function jt(e){return/^[01]{1,10}$/.test(e)}function Dt(e,t,r){if(F(e=V(e),t=V(t)))return e;if("i"!==(r=void 0===r?"i":r)&&"j"!==r)return n;if(0===e&&0===t)return 0;if(0===e)return 1===t?r:t.toString()+r;if(0===t)return e.toString();var a=t>0?"+":"";return e.toString()+a+(1===t?r:t.toString()+r)}function Pt(e,t){return t=void 0===t?0:t,F(e=V(e),t=V(t))?n:oe.erf(e)}function Lt(e){return isNaN(e)?n:oe.erfc(e)}function Ft(e){var t=Vt(e),r=Ut(e);return F(t,r)?n:Math.sqrt(Math.pow(t,2)+Math.pow(r,2))}function Ut(e){if(void 0===e||!0===e||!1===e)return n;if(0===e||"0"===e)return 0;if(["i","j"].indexOf(e)>=0)return 1;var t=(e=(e+="").replace("+i","+1i").replace("-i","-1i").replace("+j","+1j").replace("-j","-1j")).indexOf("+"),r=e.indexOf("-");0===t&&(t=e.indexOf("+",1)),0===r&&(r=e.indexOf("-",1));var a=e.substring(e.length-1,e.length),i="i"===a||"j"===a;return t>=0||r>=0?i?t>=0?isNaN(e.substring(0,t))||isNaN(e.substring(t+1,e.length-1))?o:Number(e.substring(t+1,e.length-1)):isNaN(e.substring(0,r))||isNaN(e.substring(r+1,e.length-1))?o:-Number(e.substring(r+1,e.length-1)):o:i?isNaN(e.substring(0,e.length-1))?o:e.substring(0,e.length-1):isNaN(e)?o:0}function qt(e){var t=Vt(e),a=Ut(e);return F(t,a)?n:0===t&&0===a?r:0===t&&a>0?Math.PI/2:0===t&&a<0?-Math.PI/2:0===a&&t>0?0:0===a&&t<0?-Math.PI:t>0?Math.atan(a/t):t<0&&a>=0?Math.atan(a/t)+Math.PI:Math.atan(a/t)-Math.PI}function Gt(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.cos(t)*(Math.exp(r)+Math.exp(-r))/2,-Math.sin(t)*(Math.exp(r)-Math.exp(-r))/2,a)}function Ht(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.cos(r)*(Math.exp(t)+Math.exp(-t))/2,Math.sin(r)*(Math.exp(t)-Math.exp(-t))/2,a)}function Zt(e,t){var r=Vt(e),a=Ut(e),i=Vt(t),u=Ut(t);if(F(r,a,i,u))return n;var s=e.substring(e.length-1),c=t.substring(t.length-1),f="i";if(("j"===s||"j"===c)&&(f="j"),0===i&&0===u)return o;var l=i*i+u*u;return Dt((r*i+a*u)/l,(a*i-r*u)/l,f)}function Vt(e){if(void 0===e||!0===e||!1===e)return n;if(0===e||"0"===e)return 0;if(["i","+i","1i","+1i","-i","-1i","j","+j","1j","+1j","-j","-1j"].indexOf(e)>=0)return 0;var t=(e+="").indexOf("+"),r=e.indexOf("-");0===t&&(t=e.indexOf("+",1)),0===r&&(r=e.indexOf("-",1));var a=e.substring(e.length-1,e.length),i="i"===a||"j"===a;return t>=0||r>=0?i?t>=0?isNaN(e.substring(0,t))||isNaN(e.substring(t+1,e.length-1))?o:Number(e.substring(0,t)):isNaN(e.substring(0,r))||isNaN(e.substring(r+1,e.length-1))?o:Number(e.substring(0,r)):o:i?isNaN(e.substring(0,e.length-1))?o:0:isNaN(e)?o:e}function Yt(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.sin(t)*(Math.exp(r)+Math.exp(-r))/2,Math.cos(t)*(Math.exp(r)-Math.exp(-r))/2,a)}function Bt(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.cos(r)*(Math.exp(t)-Math.exp(-t))/2,Math.sin(r)*(Math.exp(t)+Math.exp(-t))/2,a)}var Kt=ke.DIST,zt=ke.INV,Xt=we.DIST,Wt=at.MATH,$t=at.PRECISE,Qt=xe.DIST,Jt=xe.DIST.RT,er=xe.INV,tr=xe.INV.RT,rr=xe.TEST,nr=Ae.P,ar=Ae.P,ir=Ae.S,or=we.INV,ur=Lt.PRECISE,sr=Pt.PRECISE,cr=Ie.DIST,fr=Me.DIST,lr=Me.DIST.RT,pr=Me.INV,dr=Me.INV.RT,hr=st.MATH,vr=st.PRECISE,mr=Me.TEST,gr=Oe.DIST,yr=Oe.INV,_r=Re.PRECISE,br=je.DIST,kr=Le.INV,wr=Le.DIST,xr=Le.INV,Sr=Ge.MULT,Er=Ge.SNGL,Nr=He.DIST,Tr=xt.INTL,Ar=Ze.DIST,Ir=Ze.INV,Mr=Ze.S.DIST,Cr=Ze.S.INV,Or=Ye.EXC,Rr=Ye.INC,jr=Be.EXC,Dr=Be.INC,Pr=Ke.DIST,Lr=ze.EXC,Fr=ze.INC,Ur=Xe.AVG,qr=Xe.EQ,Gr=We.P,Hr=Qe.P,Zr=Qe.S,Vr=me.DIST,Yr=me.DIST.RT,Br=me.INV,Kr=me.TEST,zr=Je.P,Xr=Je.S,Wr=rt.DIST,$r=Et.INTL,Qr=nt.TEST;function Jr(e){var t=[];return A(e,(function(e){e&&t.push(e)})),t}function en(e,t){for(var r={},n=1;n<e[0].length;++n)r[n]=!0;for(var a=t[0].length,i=1;i<t.length;++i)t[i].length>a&&(a=t[i].length);for(var o=1;o<e.length;++o)for(var u=1;u<e[o].length;++u){for(var s=!1,c=!1,f=0;f<t.length;++f){var l=t[f];if(!(l.length<a)){var p=l[0];if(e[o][0]===p){c=!0;for(var d=1;d<l.length;++d){if(!s)if(void 0===l[d]||"*"===l[d])s=!0;else{var h=E(l[d]+""),v=[x(e[o][u],w)].concat(h);s=N(v)}}}}}c&&(r[u]=r[u]&&s)}for(var m=[],g=0;g<e[0].length;++g)r[g]&&m.push(g-1);return m}function tn(e){return e&&e.getTime&&!isNaN(e.getTime())}function rn(e){return e instanceof Date?e:new Date(e)}function nn(e){return e=V(e),-1===[1,2,4].indexOf(e)?o:e}function an(e){return e=V(e),-1===[0,1,2,3,4].indexOf(e)?o:e}function on(e,t,r,a,i){if(a=a||0,i=i||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;var o;if(0===e)o=a+r*t;else{var u=Math.pow(1+e,t);o=1===i?a*u+r*(1+e)*(u-1)/e:a*u+r*(u-1)/e}return-o}function un(e,t,r,a,i,o){if(i=i||0,o=o||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i),o=V(o)))return n;var u=cn(e,r,a,i,o);return(1===t?1===o?0:-a:1===o?on(e,t-2,u,a,1)-u:on(e,t-1,u,a,0))*e}function sn(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=e[0],r=0,n=1;n<e.length;n++)r+=e[n]/Math.pow(1+t,n);return r}function cn(e,t,r,a,i){if(a=a||0,i=i||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;var o;if(0===e)o=(r+a)/t;else{var u=Math.pow(1+e,t);o=1===i?(a*e/(u-1)+r*e/(1-1/u))/(1+e):a*e/(u-1)+r*e/(1-1/u)}return-o}var fn,ln,pn={ethereum:1,gnosis:100,base:8453},dn={ethereum:"https://eth.blockscout.com",gnosis:"https://gnosis.blockscout.com",arbitrum:"https://arbitrum.blockscout.com",optimism:"https://optimism.blockscout.com",soneium:"https://soneium.blockscout.com",unichain:"https://unichain.blockscout.com"},hn={ethereum:"eth",gnosis:"gno"},vn="INVALID_API_KEY",mn="RATE_LIMIT",gn="DEFAULT",yn="MISSING_KEY",_n="INVALID_PARAM",bn="NETWORK_ERROR",kn="ENS",wn="ALCHEMY_API_KEY",xn=250,Sn={Etherscan:"Etherscan",Coingecko:"Coingecko",Safe:"Safe",Basescan:"Basescan",Gnosisscan:"Gnosisscan",Firefly:"Firefly",GnosisPay:"GnosisPay",Neynar:"Neynar",Defillama:"Defillama",DuneSim:"DuneSim"},En=function(){function e(t){return _classCallCheck(this,e),_callSuper(this,e,[t])}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Nn=function(){function e(t){return _classCallCheck(this,e),_callSuper(this,e,["API key for ".concat(t," is missing")])}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Tn=function(){function e(t){var r;return _classCallCheck(this,e),(r=_callSuper(this,e,["You have reached the rate limit for ".concat(t)])).api=t,r}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),An=function(){function e(t,r){var n;return _classCallCheck(this,e),(n=_callSuper(this,e,[429===r?"You have reached the rate limit for ".concat(t):"".concat(t," API failed with status code: ").concat(r)])).status=r,n.api=t,n}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),In=function(){function e(t){return _classCallCheck(this,e),_callSuper(this,e,["".concat(t," is not a supported ens name")])}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Mn=function(){function e(t){var r;return _classCallCheck(this,e),(r=_callSuper(this,e,["Api key is invalid for ".concat(t)])).api=t,r}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e)}(),Cn=function(e,t){switch(!0){case e instanceof En:return{message:e.message,functionName:t,type:_n};case e instanceof Nn:return{message:e.message,functionName:t,type:yn};case e instanceof Tn:return{message:e.message,functionName:t,type:mn,apiKeyName:e.api};case e instanceof An:return 429===e.status?{message:e.message,functionName:t,type:mn,apiKeyName:e.api}:{message:e.message,functionName:t,type:bn,apiKeyName:e.api};case e instanceof In:return{message:e.message,functionName:t,type:kn};case e instanceof Mn:return{message:e.message,functionName:t,type:vn,apiKeyName:e.api};default:return{message:"An unexpected error occured",functionName:t,type:gn,reason:e.message||e}}};function On(e,t){var r=e.safeParse(t);if(!r.success){var n=r.error.issues[0];throw new En(n.message)}return r.data}!function(e){e.assertEqual=function(e){},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=function(e){var t,r={},n=_createForOfIteratorHelper(e);try{for(n.s();!(t=n.n()).done;){var a=t.value;r[a]=a}}catch(e){n.e(e)}finally{n.f()}return r},e.getValidEnumValues=function(t){var r,n=e.objectKeys(t).filter((function(e){return"number"!=typeof t[t[e]]})),a={},i=_createForOfIteratorHelper(n);try{for(i.s();!(r=i.n()).done;){var o=r.value;a[o]=t[o]}}catch(e){i.e(e)}finally{i.f()}return e.objectValues(a)},e.objectValues=function(t){return e.objectKeys(t).map((function(e){return t[e]}))},e.objectKeys="function"==typeof Object.keys?function(e){return Object.keys(e)}:function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.push(r);return t},e.find=function(e,t){var r,n=_createForOfIteratorHelper(e);try{for(n.s();!(r=n.n()).done;){var a=r.value;if(t(a))return a}}catch(e){n.e(e)}finally{n.f()}},e.isInteger="function"==typeof Number.isInteger?function(e){return Number.isInteger(e)}:function(e){return"number"==typeof e&&Number.isFinite(e)&&Math.floor(e)===e},e.joinValues=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:" | ";return e.map((function(e){return"string"==typeof e?"'".concat(e,"'"):e})).join(t)},e.jsonStringifyReplacer=function(e,t){return"bigint"==typeof t?t.toString():t}}(fn||(fn={})),function(e){e.mergeShapes=function(e,t){return _objectSpread(_objectSpread({},e),t)}}(ln||(ln={}));var Rn=fn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jn=function(e){switch(_typeof(e)){case"undefined":return Rn.undefined;case"string":return Rn.string;case"number":return Number.isNaN(e)?Rn.nan:Rn.number;case"boolean":return Rn.boolean;case"function":return Rn.function;case"bigint":return Rn.bigint;case"symbol":return Rn.symbol;case"object":return Array.isArray(e)?Rn.array:null===e?Rn.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Rn.promise:"undefined"!=typeof Map&&e instanceof Map?Rn.map:"undefined"!=typeof Set&&e instanceof Set?Rn.set:"undefined"!=typeof Date&&e instanceof Date?Rn.date:Rn.object;default:return Rn.unknown}},Dn=fn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Pn=function(){function e(t){var r;_classCallCheck(this,e),(r=_callSuper(this,e)).issues=[],r.addIssue=function(e){r.issues=[].concat(_toConsumableArray(r.issues),[e])},r.addIssues=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];r.issues=[].concat(_toConsumableArray(r.issues),_toConsumableArray(e))};var n=(this instanceof e?this.constructor:void 0).prototype;return Object.setPrototypeOf?Object.setPrototypeOf(r,n):r.__proto__=n,r.name="ZodError",r.issues=t,r}return _inherits(e,_wrapNativeSuper(Error)),_createClass(e,[{key:"errors",get:function(){return this.issues}},{key:"format",value:function(e){var t=e||function(e){return e.message},r={_errors:[]},n=function(e){var a,i=_createForOfIteratorHelper(e.issues);try{for(i.s();!(a=i.n()).done;){var o=a.value;if("invalid_union"===o.code)o.unionErrors.map(n);else if("invalid_return_type"===o.code)n(o.returnTypeError);else if("invalid_arguments"===o.code)n(o.argumentsError);else if(0===o.path.length)r._errors.push(t(o));else for(var u=r,s=0;s<o.path.length;){var c=o.path[s];s===o.path.length-1?(u[c]=u[c]||{_errors:[]},u[c]._errors.push(t(o))):u[c]=u[c]||{_errors:[]},u=u[c],s++}}}catch(e){i.e(e)}finally{i.f()}};return n(this),r}},{key:"toString",value:function(){return this.message}},{key:"message",get:function(){return JSON.stringify(this.issues,fn.jsonStringifyReplacer,2)}},{key:"isEmpty",get:function(){return 0===this.issues.length}},{key:"flatten",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:function(e){return e.message},r={},n=[],a=_createForOfIteratorHelper(this.issues);try{for(a.s();!(e=a.n()).done;){var i=e.value;if(i.path.length>0){var o=i.path[0];r[o]=r[o]||[],r[o].push(t(i))}else n.push(t(i))}}catch(e){a.e(e)}finally{a.f()}return{formErrors:n,fieldErrors:r}}},{key:"formErrors",get:function(){return this.flatten()}}],[{key:"assert",value:function(t){if(!(t instanceof e))throw new Error("Not a ZodError: ".concat(t))}}])}();Pn.create=function(e){return new Pn(e)};var Ln=function(e,t){var r;switch(e.code){case Dn.invalid_type:r=e.received===Rn.undefined?"Required":"Expected ".concat(e.expected,", received ").concat(e.received);break;case Dn.invalid_literal:r="Invalid literal value, expected ".concat(JSON.stringify(e.expected,fn.jsonStringifyReplacer));break;case Dn.unrecognized_keys:r="Unrecognized key(s) in object: ".concat(fn.joinValues(e.keys,", "));break;case Dn.invalid_union:r="Invalid input";break;case Dn.invalid_union_discriminator:r="Invalid discriminator value. Expected ".concat(fn.joinValues(e.options));break;case Dn.invalid_enum_value:r="Invalid enum value. Expected ".concat(fn.joinValues(e.options),", received '").concat(e.received,"'");break;case Dn.invalid_arguments:r="Invalid function arguments";break;case Dn.invalid_return_type:r="Invalid function return type";break;case Dn.invalid_date:r="Invalid date";break;case Dn.invalid_string:"object"===_typeof(e.validation)?"includes"in e.validation?(r='Invalid input: must include "'.concat(e.validation.includes,'"'),"number"==typeof e.validation.position&&(r="".concat(r," at one or more positions greater than or equal to ").concat(e.validation.position))):"startsWith"in e.validation?r='Invalid input: must start with "'.concat(e.validation.startsWith,'"'):"endsWith"in e.validation?r='Invalid input: must end with "'.concat(e.validation.endsWith,'"'):fn.assertNever(e.validation):r="regex"!==e.validation?"Invalid ".concat(e.validation):"Invalid";break;case Dn.too_small:r="array"===e.type?"Array must contain ".concat(e.exact?"exactly":e.inclusive?"at least":"more than"," ").concat(e.minimum," element(s)"):"string"===e.type?"String must contain ".concat(e.exact?"exactly":e.inclusive?"at least":"over"," ").concat(e.minimum," character(s)"):"number"===e.type||"bigint"===e.type?"Number must be ".concat(e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than ").concat(e.minimum):"date"===e.type?"Date must be ".concat(e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than ").concat(new Date(Number(e.minimum))):"Invalid input";break;case Dn.too_big:r="array"===e.type?"Array must contain ".concat(e.exact?"exactly":e.inclusive?"at most":"less than"," ").concat(e.maximum," element(s)"):"string"===e.type?"String must contain ".concat(e.exact?"exactly":e.inclusive?"at most":"under"," ").concat(e.maximum," character(s)"):"number"===e.type?"Number must be ".concat(e.exact?"exactly":e.inclusive?"less than or equal to":"less than"," ").concat(e.maximum):"bigint"===e.type?"BigInt must be ".concat(e.exact?"exactly":e.inclusive?"less than or equal to":"less than"," ").concat(e.maximum):"date"===e.type?"Date must be ".concat(e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"," ").concat(new Date(Number(e.maximum))):"Invalid input";break;case Dn.custom:r="Invalid input";break;case Dn.invalid_intersection_types:r="Intersection results could not be merged";break;case Dn.not_multiple_of:r="Number must be a multiple of ".concat(e.multipleOf);break;case Dn.not_finite:r="Number must be finite";break;default:r=t.defaultError,fn.assertNever(e)}return{message:r}},Fn=Ln;function Un(e,t){var r=Fn,n=function(e){var t=e.data,r=e.path,n=e.errorMaps,a=e.issueData,i=[].concat(_toConsumableArray(r),_toConsumableArray(a.path||[])),o=_objectSpread(_objectSpread({},a),{},{path:i});if(void 0!==a.message)return _objectSpread(_objectSpread({},a),{},{path:i,message:a.message});var u,s="",c=_createForOfIteratorHelper(n.filter((function(e){return!!e})).slice().reverse());try{for(c.s();!(u=c.n()).done;)s=(0,u.value)(o,{data:t,defaultError:s}).message}catch(e){c.e(e)}finally{c.f()}return _objectSpread(_objectSpread({},a),{},{path:i,message:s})}({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,r,r===Ln?void 0:Ln].filter((function(e){return!!e}))});e.common.issues.push(n)}var qn,Gn=function(){function e(){_classCallCheck(this,e),this.value="valid"}return _createClass(e,[{key:"dirty",value:function(){"valid"===this.value&&(this.value="dirty")}},{key:"abort",value:function(){"aborted"!==this.value&&(this.value="aborted")}}],[{key:"mergeArray",value:function(e,t){var r,n=[],a=_createForOfIteratorHelper(t);try{for(a.s();!(r=a.n()).done;){var i=r.value;if("aborted"===i.status)return Hn;"dirty"===i.status&&e.dirty(),n.push(i.value)}}catch(e){a.e(e)}finally{a.f()}return{status:e.value,value:n}}},{key:"mergeObjectAsync",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function t(r,n){var a,i,o,u,s,c;return _regeneratorRuntime().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:a=[],i=_createForOfIteratorHelper(n),t.prev=2,i.s();case 4:if((o=i.n()).done){t.next=15;break}return u=o.value,t.next=8,u.key;case 8:return s=t.sent,t.next=11,u.value;case 11:c=t.sent,a.push({key:s,value:c});case 13:t.next=4;break;case 15:t.next=20;break;case 17:t.prev=17,t.t0=t.catch(2),i.e(t.t0);case 20:return t.prev=20,i.f(),t.finish(20);case 23:return t.abrupt("return",e.mergeObjectSync(r,a));case 24:case"end":return t.stop()}}),t,null,[[2,17,20,23]])}))),function(e,r){return t.apply(this,arguments)})},{key:"mergeObjectSync",value:function(e,t){var r,n={},a=_createForOfIteratorHelper(t);try{for(a.s();!(r=a.n()).done;){var i=r.value,o=i.key,u=i.value;if("aborted"===o.status)return Hn;if("aborted"===u.status)return Hn;"dirty"===o.status&&e.dirty(),"dirty"===u.status&&e.dirty(),"__proto__"===o.value||void 0===u.value&&!i.alwaysSet||(n[o.value]=u.value)}}catch(e){a.e(e)}finally{a.f()}return{status:e.value,value:n}}}]);var t}(),Hn=Object.freeze({status:"aborted"}),Zn=function(e){return{status:"dirty",value:e}},Vn=function(e){return{status:"valid",value:e}},Yn=function(e){return"aborted"===e.status},Bn=function(e){return"dirty"===e.status},Kn=function(e){return"valid"===e.status},zn=function(e){return"undefined"!=typeof Promise&&e instanceof Promise};!function(e){e.errToObj=function(e){return"string"==typeof e?{message:e}:e||{}},e.toString=function(e){return"string"==typeof e?e:null==e?void 0:e.message}}(qn||(qn={}));var Xn=function(){return _createClass((function e(t,r,n,a){_classCallCheck(this,e),this._cachedPath=[],this.parent=t,this.data=r,this._path=n,this._key=a}),[{key:"path",get:function(){var e,t;this._cachedPath.length||(Array.isArray(this._key)?(e=this._cachedPath).push.apply(e,_toConsumableArray(this._path).concat(_toConsumableArray(this._key))):(t=this._cachedPath).push.apply(t,_toConsumableArray(this._path).concat([this._key])));return this._cachedPath}}])}(),Wn=function(e,t){if(Kn(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;var t=new Pn(e.common.issues);return this._error=t,this._error}}};function $n(e){if(!e)return{};var t=e.errorMap,r=e.invalid_type_error,n=e.required_error,a=e.description;if(t&&(r||n))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:a};return{errorMap:function(t,a){var i,o,u=e.message;return"invalid_enum_value"===t.code?{message:null!=u?u:a.defaultError}:void 0===a.data?{message:null!==(o=null!=u?u:n)&&void 0!==o?o:a.defaultError}:"invalid_type"!==t.code?{message:a.defaultError}:{message:null!==(i=null!=u?u:r)&&void 0!==i?i:a.defaultError}},description:a}}var Qn,Jn=function(){return _createClass((function e(t){var r=this;_classCallCheck(this,e),this.spa=this.safeParseAsync,this._def=t,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:function(e){return r["~validate"](e)}}}),[{key:"description",get:function(){return this._def.description}},{key:"_getType",value:function(e){return jn(e.data)}},{key:"_getOrReturnCtx",value:function(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}},{key:"_processInputParams",value:function(e){return{status:new Gn,ctx:{common:e.parent.common,data:e.data,parsedType:jn(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}},{key:"_parseSync",value:function(e){var t=this._parse(e);if(zn(t))throw new Error("Synchronous parse encountered promise.");return t}},{key:"_parseAsync",value:function(e){var t=this._parse(e);return Promise.resolve(t)}},{key:"parse",value:function(e,t){var r=this.safeParse(e,t);if(r.success)return r.data;throw r.error}},{key:"safeParse",value:function(e,t){var r,n={common:{issues:[],async:null!==(r=null==t?void 0:t.async)&&void 0!==r&&r,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Wn(n,a)}},{key:"~validate",value:function(e){var t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jn(e)};if(!this["~standard"].async)try{var r=this._parseSync({data:e,path:[],parent:t});return Kn(r)?{value:r.value}:{issues:t.common.issues}}catch(e){var n;null!=e&&null!==(n=e.message)&&void 0!==n&&null!==(n=n.toLowerCase())&&void 0!==n&&n.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((function(e){return Kn(e)?{value:e.value}:{issues:t.common.issues}}))}},{key:"parseAsync",value:(t=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.safeParseAsync(t,r);case 2:if(!(n=e.sent).success){e.next=5;break}return e.abrupt("return",n.data);case 5:throw n.error;case 6:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"safeParseAsync",value:(e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,a,i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n={common:{issues:[],contextualErrorMap:null==r?void 0:r.errorMap,async:!0},path:(null==r?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:t,parsedType:jn(t)},a=this._parse({data:t,path:n.path,parent:n}),e.next=4,zn(a)?a:Promise.resolve(a);case 4:return i=e.sent,e.abrupt("return",Wn(n,i));case 6:case"end":return e.stop()}}),e,this)}))),function(t,r){return e.apply(this,arguments)})},{key:"refine",value:function(e,t){return this._refinement((function(r,n){var a=e(r),i=function(){return n.addIssue(_objectSpread({code:Dn.custom},function(e){return"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t}(r)))};return"undefined"!=typeof Promise&&a instanceof Promise?a.then((function(e){return!!e||(i(),!1)})):!!a||(i(),!1)}))}},{key:"refinement",value:function(e,t){return this._refinement((function(r,n){return!!e(r)||(n.addIssue("function"==typeof t?t(r,n):t),!1)}))}},{key:"_refinement",value:function(e){return new Xa({schema:this,typeName:ti.ZodEffects,effect:{type:"refinement",refinement:e}})}},{key:"superRefine",value:function(e){return this._refinement(e)}},{key:"optional",value:function(){return Wa.create(this,this._def)}},{key:"nullable",value:function(){return $a.create(this,this._def)}},{key:"nullish",value:function(){return this.nullable().optional()}},{key:"array",value:function(){return Oa.create(this)}},{key:"promise",value:function(){return za.create(this,this._def)}},{key:"or",value:function(e){return Da.create([this,e],this._def)}},{key:"and",value:function(e){return Ua.create(this,e,this._def)}},{key:"transform",value:function(e){return new Xa(_objectSpread(_objectSpread({},$n(this._def)),{},{schema:this,typeName:ti.ZodEffects,effect:{type:"transform",transform:e}}))}},{key:"default",value:function(e){var t="function"==typeof e?e:function(){return e};return new Qa(_objectSpread(_objectSpread({},$n(this._def)),{},{innerType:this,defaultValue:t,typeName:ti.ZodDefault}))}},{key:"brand",value:function(){return new ri(_objectSpread({typeName:ti.ZodBranded,type:this},$n(this._def)))}},{key:"catch",value:function(e){var t="function"==typeof e?e:function(){return e};return new Ja(_objectSpread(_objectSpread({},$n(this._def)),{},{innerType:this,catchValue:t,typeName:ti.ZodCatch}))}},{key:"describe",value:function(e){return new(0,this.constructor)(_objectSpread(_objectSpread({},this._def),{},{description:e}))}},{key:"pipe",value:function(e){return ni.create(this,e)}},{key:"readonly",value:function(){return ai.create(this)}},{key:"isOptional",value:function(){return this.safeParse(void 0).success}},{key:"isNullable",value:function(){return this.safeParse(null).success}}]);var e,t}(),ea=/^c[^\s-]{8,}$/i,ta=/^[0-9a-z]+$/,ra=/^[0-9A-HJKMNP-TV-Z]{26}$/i,na=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,aa=/^[a-z0-9_-]{21}$/i,ia=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oa=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ua=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,sa=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ca=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,fa=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,la=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,pa=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,da=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,ha="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",va=new RegExp("^".concat(ha,"$"));function ma(e){var t="[0-5]\\d";e.precision?t="".concat(t,"\\.\\d{").concat(e.precision,"}"):null==e.precision&&(t="".concat(t,"(\\.\\d+)?"));var r=e.precision?"+":"?";return"([01]\\d|2[0-3]):[0-5]\\d(:".concat(t,")").concat(r)}function ga(e){var t="".concat(ha,"T").concat(ma(e)),r=[];return r.push(e.local?"Z?":"Z"),e.offset&&r.push("([+-]\\d{2}:?\\d{2})"),t="".concat(t,"(").concat(r.join("|"),")"),new RegExp("^".concat(t,"$"))}function ya(e,t){if(!ia.test(e))return!1;try{var r=_slicedToArray(e.split("."),1)[0];if(!r)return!1;var n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return"object"===_typeof(a)&&null!==a&&((!("typ"in a)||"JWT"===(null==a?void 0:a.typ))&&(!!a.alg&&(!t||a.alg===t)))}catch(e){return!1}}function _a(e,t){return!("v4"!==t&&t||!ca.test(e))||!("v6"!==t&&t||!la.test(e))}var ba=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==Rn.string){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.string,received:t.parsedType}),Hn}var r,n,a,i=new Gn,o=void 0,u=_createForOfIteratorHelper(this._def.checks);try{for(u.s();!(r=u.n()).done;){var s=r.value;if("min"===s.kind)e.data.length<s.value&&(Un(o=this._getOrReturnCtx(e,o),{code:Dn.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if("max"===s.kind)e.data.length>s.value&&(Un(o=this._getOrReturnCtx(e,o),{code:Dn.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),i.dirty());else if("length"===s.kind){var c=e.data.length>s.value,f=e.data.length<s.value;(c||f)&&(o=this._getOrReturnCtx(e,o),c?Un(o,{code:Dn.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):f&&Un(o,{code:Dn.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),i.dirty())}else if("email"===s.kind)ua.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"email",code:Dn.invalid_string,message:s.message}),i.dirty());else if("emoji"===s.kind)Qn||(Qn=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Qn.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"emoji",code:Dn.invalid_string,message:s.message}),i.dirty());else if("uuid"===s.kind)na.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"uuid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("nanoid"===s.kind)aa.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"nanoid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("cuid"===s.kind)ea.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"cuid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("cuid2"===s.kind)ta.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"cuid2",code:Dn.invalid_string,message:s.message}),i.dirty());else if("ulid"===s.kind)ra.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"ulid",code:Dn.invalid_string,message:s.message}),i.dirty());else if("url"===s.kind)try{new URL(e.data)}catch(t){Un(o=this._getOrReturnCtx(e,o),{validation:"url",code:Dn.invalid_string,message:s.message}),i.dirty()}else if("regex"===s.kind){s.regex.lastIndex=0,s.regex.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"regex",code:Dn.invalid_string,message:s.message}),i.dirty())}else if("trim"===s.kind)e.data=e.data.trim();else if("includes"===s.kind)e.data.includes(s.value,s.position)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),i.dirty());else if("toLowerCase"===s.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===s.kind)e.data=e.data.toUpperCase();else if("startsWith"===s.kind)e.data.startsWith(s.value)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:{startsWith:s.value},message:s.message}),i.dirty());else if("endsWith"===s.kind)e.data.endsWith(s.value)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:{endsWith:s.value},message:s.message}),i.dirty());else if("datetime"===s.kind){ga(s).test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:"datetime",message:s.message}),i.dirty())}else if("date"===s.kind){va.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:"date",message:s.message}),i.dirty())}else if("time"===s.kind){new RegExp("^".concat(ma(s),"$")).test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{code:Dn.invalid_string,validation:"time",message:s.message}),i.dirty())}else"duration"===s.kind?oa.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"duration",code:Dn.invalid_string,message:s.message}),i.dirty()):"ip"===s.kind?(n=e.data,("v4"!==(a=s.version)&&a||!sa.test(n))&&("v6"!==a&&a||!fa.test(n))&&(Un(o=this._getOrReturnCtx(e,o),{validation:"ip",code:Dn.invalid_string,message:s.message}),i.dirty())):"jwt"===s.kind?ya(e.data,s.alg)||(Un(o=this._getOrReturnCtx(e,o),{validation:"jwt",code:Dn.invalid_string,message:s.message}),i.dirty()):"cidr"===s.kind?_a(e.data,s.version)||(Un(o=this._getOrReturnCtx(e,o),{validation:"cidr",code:Dn.invalid_string,message:s.message}),i.dirty()):"base64"===s.kind?pa.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"base64",code:Dn.invalid_string,message:s.message}),i.dirty()):"base64url"===s.kind?da.test(e.data)||(Un(o=this._getOrReturnCtx(e,o),{validation:"base64url",code:Dn.invalid_string,message:s.message}),i.dirty()):fn.assertNever(s)}}catch(e){u.e(e)}finally{u.f()}return{status:i.value,value:e.data}}},{key:"_regex",value:function(e,t,r){return this.refinement((function(t){return e.test(t)}),_objectSpread({validation:t,code:Dn.invalid_string},qn.errToObj(r)))}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"email",value:function(e){return this._addCheck(_objectSpread({kind:"email"},qn.errToObj(e)))}},{key:"url",value:function(e){return this._addCheck(_objectSpread({kind:"url"},qn.errToObj(e)))}},{key:"emoji",value:function(e){return this._addCheck(_objectSpread({kind:"emoji"},qn.errToObj(e)))}},{key:"uuid",value:function(e){return this._addCheck(_objectSpread({kind:"uuid"},qn.errToObj(e)))}},{key:"nanoid",value:function(e){return this._addCheck(_objectSpread({kind:"nanoid"},qn.errToObj(e)))}},{key:"cuid",value:function(e){return this._addCheck(_objectSpread({kind:"cuid"},qn.errToObj(e)))}},{key:"cuid2",value:function(e){return this._addCheck(_objectSpread({kind:"cuid2"},qn.errToObj(e)))}},{key:"ulid",value:function(e){return this._addCheck(_objectSpread({kind:"ulid"},qn.errToObj(e)))}},{key:"base64",value:function(e){return this._addCheck(_objectSpread({kind:"base64"},qn.errToObj(e)))}},{key:"base64url",value:function(e){return this._addCheck(_objectSpread({kind:"base64url"},qn.errToObj(e)))}},{key:"jwt",value:function(e){return this._addCheck(_objectSpread({kind:"jwt"},qn.errToObj(e)))}},{key:"ip",value:function(e){return this._addCheck(_objectSpread({kind:"ip"},qn.errToObj(e)))}},{key:"cidr",value:function(e){return this._addCheck(_objectSpread({kind:"cidr"},qn.errToObj(e)))}},{key:"datetime",value:function(e){var t,r;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck(_objectSpread({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(r=null==e?void 0:e.local)&&void 0!==r&&r},qn.errToObj(null==e?void 0:e.message)))}},{key:"date",value:function(e){return this._addCheck({kind:"date",message:e})}},{key:"time",value:function(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck(_objectSpread({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision},qn.errToObj(null==e?void 0:e.message)))}},{key:"duration",value:function(e){return this._addCheck(_objectSpread({kind:"duration"},qn.errToObj(e)))}},{key:"regex",value:function(e,t){return this._addCheck(_objectSpread({kind:"regex",regex:e},qn.errToObj(t)))}},{key:"includes",value:function(e,t){return this._addCheck(_objectSpread({kind:"includes",value:e,position:null==t?void 0:t.position},qn.errToObj(null==t?void 0:t.message)))}},{key:"startsWith",value:function(e,t){return this._addCheck(_objectSpread({kind:"startsWith",value:e},qn.errToObj(t)))}},{key:"endsWith",value:function(e,t){return this._addCheck(_objectSpread({kind:"endsWith",value:e},qn.errToObj(t)))}},{key:"min",value:function(e,t){return this._addCheck(_objectSpread({kind:"min",value:e},qn.errToObj(t)))}},{key:"max",value:function(e,t){return this._addCheck(_objectSpread({kind:"max",value:e},qn.errToObj(t)))}},{key:"length",value:function(e,t){return this._addCheck(_objectSpread({kind:"length",value:e},qn.errToObj(t)))}},{key:"nonempty",value:function(e){return this.min(1,qn.errToObj(e))}},{key:"trim",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:"trim"}])}))}},{key:"toLowerCase",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:"toLowerCase"}])}))}},{key:"toUpperCase",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:"toUpperCase"}])}))}},{key:"isDatetime",get:function(){return!!this._def.checks.find((function(e){return"datetime"===e.kind}))}},{key:"isDate",get:function(){return!!this._def.checks.find((function(e){return"date"===e.kind}))}},{key:"isTime",get:function(){return!!this._def.checks.find((function(e){return"time"===e.kind}))}},{key:"isDuration",get:function(){return!!this._def.checks.find((function(e){return"duration"===e.kind}))}},{key:"isEmail",get:function(){return!!this._def.checks.find((function(e){return"email"===e.kind}))}},{key:"isURL",get:function(){return!!this._def.checks.find((function(e){return"url"===e.kind}))}},{key:"isEmoji",get:function(){return!!this._def.checks.find((function(e){return"emoji"===e.kind}))}},{key:"isUUID",get:function(){return!!this._def.checks.find((function(e){return"uuid"===e.kind}))}},{key:"isNANOID",get:function(){return!!this._def.checks.find((function(e){return"nanoid"===e.kind}))}},{key:"isCUID",get:function(){return!!this._def.checks.find((function(e){return"cuid"===e.kind}))}},{key:"isCUID2",get:function(){return!!this._def.checks.find((function(e){return"cuid2"===e.kind}))}},{key:"isULID",get:function(){return!!this._def.checks.find((function(e){return"ulid"===e.kind}))}},{key:"isIP",get:function(){return!!this._def.checks.find((function(e){return"ip"===e.kind}))}},{key:"isCIDR",get:function(){return!!this._def.checks.find((function(e){return"cidr"===e.kind}))}},{key:"isBase64",get:function(){return!!this._def.checks.find((function(e){return"base64"===e.kind}))}},{key:"isBase64url",get:function(){return!!this._def.checks.find((function(e){return"base64url"===e.kind}))}},{key:"minLength",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"maxLength",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}}])}(Jn);ba.create=function(e){var t;return new ba(_objectSpread({checks:[],typeName:ti.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t},$n(e)))};var ka=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments)).min=e.gte,e.max=e.lte,e.step=e.multipleOf,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==Rn.number){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.number,received:t.parsedType}),Hn}var r,n,a,i,o,u,s=void 0,c=new Gn,f=_createForOfIteratorHelper(this._def.checks);try{for(f.s();!(r=f.n()).done;){var l=r.value;if("int"===l.kind)fn.isInteger(e.data)||(Un(s=this._getOrReturnCtx(e,s),{code:Dn.invalid_type,expected:"integer",received:"float",message:l.message}),c.dirty());else if("min"===l.kind){(l.inclusive?e.data<l.value:e.data<=l.value)&&(Un(s=this._getOrReturnCtx(e,s),{code:Dn.too_small,minimum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),c.dirty())}else if("max"===l.kind){(l.inclusive?e.data>l.value:e.data>=l.value)&&(Un(s=this._getOrReturnCtx(e,s),{code:Dn.too_big,maximum:l.value,type:"number",inclusive:l.inclusive,exact:!1,message:l.message}),c.dirty())}else"multipleOf"===l.kind?0!=(n=e.data,a=l.value,i=void 0,o=void 0,u=void 0,i=(n.toString().split(".")[1]||"").length,o=(a.toString().split(".")[1]||"").length,u=i>o?i:o,Number.parseInt(n.toFixed(u).replace(".",""))%Number.parseInt(a.toFixed(u).replace(".",""))/Math.pow(10,u))&&(Un(s=this._getOrReturnCtx(e,s),{code:Dn.not_multiple_of,multipleOf:l.value,message:l.message}),c.dirty()):"finite"===l.kind?Number.isFinite(e.data)||(Un(s=this._getOrReturnCtx(e,s),{code:Dn.not_finite,message:l.message}),c.dirty()):fn.assertNever(l)}}catch(e){f.e(e)}finally{f.f()}return{status:c.value,value:e.data}}},{key:"gte",value:function(e,t){return this.setLimit("min",e,!0,qn.toString(t))}},{key:"gt",value:function(e,t){return this.setLimit("min",e,!1,qn.toString(t))}},{key:"lte",value:function(e,t){return this.setLimit("max",e,!0,qn.toString(t))}},{key:"lt",value:function(e,t){return this.setLimit("max",e,!1,qn.toString(t))}},{key:"setLimit",value:function(e,r,n,a){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:e,value:r,inclusive:n,message:qn.toString(a)}])}))}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"int",value:function(e){return this._addCheck({kind:"int",message:qn.toString(e)})}},{key:"positive",value:function(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:qn.toString(e)})}},{key:"negative",value:function(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:qn.toString(e)})}},{key:"nonpositive",value:function(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:qn.toString(e)})}},{key:"nonnegative",value:function(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:qn.toString(e)})}},{key:"multipleOf",value:function(e,t){return this._addCheck({kind:"multipleOf",value:e,message:qn.toString(t)})}},{key:"finite",value:function(e){return this._addCheck({kind:"finite",message:qn.toString(e)})}},{key:"safe",value:function(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:qn.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:qn.toString(e)})}},{key:"minValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"maxValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"isInt",get:function(){return!!this._def.checks.find((function(e){return"int"===e.kind||"multipleOf"===e.kind&&fn.isInteger(e.value)}))}},{key:"isFinite",get:function(){var e,t=null,r=null,n=_createForOfIteratorHelper(this._def.checks);try{for(n.s();!(e=n.n()).done;){var a=e.value;if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===r||a.value>r)&&(r=a.value):"max"===a.kind&&(null===t||a.value<t)&&(t=a.value)}}catch(e){n.e(e)}finally{n.f()}return Number.isFinite(r)&&Number.isFinite(t)}}])}(Jn);ka.create=function(e){return new ka(_objectSpread({checks:[],typeName:ti.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1},$n(e)))};var wa=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments)).min=e.gte,e.max=e.lte,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch(t){return this._getInvalidInput(e)}if(this._getType(e)!==Rn.bigint)return this._getInvalidInput(e);var t,r=void 0,n=new Gn,a=_createForOfIteratorHelper(this._def.checks);try{for(a.s();!(t=a.n()).done;){var i=t.value;if("min"===i.kind)(i.inclusive?e.data<i.value:e.data<=i.value)&&(Un(r=this._getOrReturnCtx(e,r),{code:Dn.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty());else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(Un(r=this._getOrReturnCtx(e,r),{code:Dn.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),n.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(Un(r=this._getOrReturnCtx(e,r),{code:Dn.not_multiple_of,multipleOf:i.value,message:i.message}),n.dirty()):fn.assertNever(i)}}catch(e){a.e(e)}finally{a.f()}return{status:n.value,value:e.data}}},{key:"_getInvalidInput",value:function(e){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.bigint,received:t.parsedType}),Hn}},{key:"gte",value:function(e,t){return this.setLimit("min",e,!0,qn.toString(t))}},{key:"gt",value:function(e,t){return this.setLimit("min",e,!1,qn.toString(t))}},{key:"lte",value:function(e,t){return this.setLimit("max",e,!0,qn.toString(t))}},{key:"lt",value:function(e,t){return this.setLimit("max",e,!1,qn.toString(t))}},{key:"setLimit",value:function(e,r,n,a){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[{kind:e,value:r,inclusive:n,message:qn.toString(a)}])}))}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"positive",value:function(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:qn.toString(e)})}},{key:"negative",value:function(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:qn.toString(e)})}},{key:"nonpositive",value:function(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:qn.toString(e)})}},{key:"nonnegative",value:function(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:qn.toString(e)})}},{key:"multipleOf",value:function(e,t){return this._addCheck({kind:"multipleOf",value:e,message:qn.toString(t)})}},{key:"minValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"maxValue",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return t}}])}(Jn);wa.create=function(e){var t;return new wa(_objectSpread({checks:[],typeName:ti.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t},$n(e)))};var xa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=Boolean(e.data)),this._getType(e)!==Rn.boolean){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.boolean,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);xa.create=function(e){return new xa(_objectSpread({typeName:ti.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1},$n(e)))};var Sa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==Rn.date){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.date,received:t.parsedType}),Hn}if(Number.isNaN(e.data.getTime()))return Un(this._getOrReturnCtx(e),{code:Dn.invalid_date}),Hn;var r,n=new Gn,a=void 0,i=_createForOfIteratorHelper(this._def.checks);try{for(i.s();!(r=i.n()).done;){var o=r.value;"min"===o.kind?e.data.getTime()<o.value&&(Un(a=this._getOrReturnCtx(e,a),{code:Dn.too_small,message:o.message,inclusive:!0,exact:!1,minimum:o.value,type:"date"}),n.dirty()):"max"===o.kind?e.data.getTime()>o.value&&(Un(a=this._getOrReturnCtx(e,a),{code:Dn.too_big,message:o.message,inclusive:!0,exact:!1,maximum:o.value,type:"date"}),n.dirty()):fn.assertNever(o)}}catch(e){i.e(e)}finally{i.f()}return{status:n.value,value:new Date(e.data.getTime())}}},{key:"_addCheck",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{checks:[].concat(_toConsumableArray(this._def.checks),[e])}))}},{key:"min",value:function(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:qn.toString(t)})}},{key:"max",value:function(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:qn.toString(t)})}},{key:"minDate",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"min"===n.kind&&(null===t||n.value>t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return null!=t?new Date(t):null}},{key:"maxDate",get:function(){var e,t=null,r=_createForOfIteratorHelper(this._def.checks);try{for(r.s();!(e=r.n()).done;){var n=e.value;"max"===n.kind&&(null===t||n.value<t)&&(t=n.value)}}catch(e){r.e(e)}finally{r.f()}return null!=t?new Date(t):null}}])}(Jn);Sa.create=function(e){return new Sa(_objectSpread({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:ti.ZodDate},$n(e)))};var Ea=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.symbol){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.symbol,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Ea.create=function(e){return new Ea(_objectSpread({typeName:ti.ZodSymbol},$n(e)))};var Na=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.undefined){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.undefined,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Na.create=function(e){return new Na(_objectSpread({typeName:ti.ZodUndefined},$n(e)))};var Ta=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.null){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.null,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Ta.create=function(e){return new Ta(_objectSpread({typeName:ti.ZodNull},$n(e)))};var Aa=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments))._any=!0,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return Vn(e.data)}}])}(Jn);Aa.create=function(e){return new Aa(_objectSpread({typeName:ti.ZodAny},$n(e)))};var Ia=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments))._unknown=!0,e}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return Vn(e.data)}}])}(Jn);Ia.create=function(e){return new Ia(_objectSpread({typeName:ti.ZodUnknown},$n(e)))};var Ma=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.never,received:t.parsedType}),Hn}}])}(Jn);Ma.create=function(e){return new Ma(_objectSpread({typeName:ti.ZodNever},$n(e)))};var Ca=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.undefined){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.void,received:t.parsedType}),Hn}return Vn(e.data)}}])}(Jn);Ca.create=function(e){return new Ca(_objectSpread({typeName:ti.ZodVoid},$n(e)))};var Oa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.ctx,n=t.status,a=this._def;if(r.parsedType!==Rn.array)return Un(r,{code:Dn.invalid_type,expected:Rn.array,received:r.parsedType}),Hn;if(null!==a.exactLength){var i=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(i||o)&&(Un(r,{code:i?Dn.too_big:Dn.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(null!==a.minLength&&r.data.length<a.minLength.value&&(Un(r,{code:Dn.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),null!==a.maxLength&&r.data.length>a.maxLength.value&&(Un(r,{code:Dn.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all(_toConsumableArray(r.data).map((function(e,t){return a.type._parseAsync(new Xn(r,e,r.path,t))}))).then((function(e){return Gn.mergeArray(n,e)}));var u=_toConsumableArray(r.data).map((function(e,t){return a.type._parseSync(new Xn(r,e,r.path,t))}));return Gn.mergeArray(n,u)}},{key:"element",get:function(){return this._def.type}},{key:"min",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{minLength:{value:e,message:qn.toString(r)}}))}},{key:"max",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{maxLength:{value:e,message:qn.toString(r)}}))}},{key:"length",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{exactLength:{value:e,message:qn.toString(r)}}))}},{key:"nonempty",value:function(e){return this.min(1,e)}}])}(Jn);function Ra(e){if(e instanceof ja){var t={};for(var r in e.shape){var n=e.shape[r];t[r]=Wa.create(Ra(n))}return new ja(_objectSpread(_objectSpread({},e._def),{},{shape:function(){return t}}))}return e instanceof Oa?new Oa(_objectSpread(_objectSpread({},e._def),{},{type:Ra(e.element)})):e instanceof Wa?Wa.create(Ra(e.unwrap())):e instanceof $a?$a.create(Ra(e.unwrap())):e instanceof qa?qa.create(e.items.map((function(e){return Ra(e)}))):e}Oa.create=function(e,t){return new Oa(_objectSpread({type:e,minLength:null,maxLength:null,exactLength:null,typeName:ti.ZodArray},$n(t)))};var ja=function(e){function t(){var e;return _classCallCheck(this,t),(e=_callSuper(this,t,arguments))._cached=null,e.nonstrict=e.passthrough,e.augment=e.extend,e}return _inherits(t,e),_createClass(t,[{key:"_getCached",value:function(){if(null!==this._cached)return this._cached;var e=this._def.shape(),t=fn.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}},{key:"_parse",value:function(e){if(this._getType(e)!==Rn.object){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.object,received:t.parsedType}),Hn}var r=this._processInputParams(e),n=r.status,a=r.ctx,i=this._getCached(),o=i.shape,u=i.keys,s=[];if(!(this._def.catchall instanceof Ma&&"strip"===this._def.unknownKeys))for(var c in a.data)u.includes(c)||s.push(c);var f,l=[],p=_createForOfIteratorHelper(u);try{for(p.s();!(f=p.n()).done;){var d=f.value,h=o[d],v=a.data[d];l.push({key:{status:"valid",value:d},value:h._parse(new Xn(a,v,a.path,d)),alwaysSet:d in a.data})}}catch(e){p.e(e)}finally{p.f()}if(this._def.catchall instanceof Ma){var m=this._def.unknownKeys;if("passthrough"===m){var g,y=_createForOfIteratorHelper(s);try{for(y.s();!(g=y.n()).done;){var _=g.value;l.push({key:{status:"valid",value:_},value:{status:"valid",value:a.data[_]}})}}catch(e){y.e(e)}finally{y.f()}}else if("strict"===m)s.length>0&&(Un(a,{code:Dn.unrecognized_keys,keys:s}),n.dirty());else if("strip"!==m)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{var b,k=this._def.catchall,w=_createForOfIteratorHelper(s);try{for(w.s();!(b=w.n()).done;){var x=b.value,S=a.data[x];l.push({key:{status:"valid",value:x},value:k._parse(new Xn(a,S,a.path,x)),alwaysSet:x in a.data})}}catch(e){w.e(e)}finally{w.f()}}return a.common.async?Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=_createForOfIteratorHelper(l),e.prev=2,r.s();case 4:if((n=r.n()).done){e.next=15;break}return a=n.value,e.next=8,a.key;case 8:return i=e.sent,e.next=11,a.value;case 11:o=e.sent,t.push({key:i,value:o,alwaysSet:a.alwaysSet});case 13:e.next=4;break;case 15:e.next=20;break;case 17:e.prev=17,e.t0=e.catch(2),r.e(e.t0);case 20:return e.prev=20,r.f(),e.finish(20);case 23:return e.abrupt("return",t);case 24:case"end":return e.stop()}}),e,null,[[2,17,20,23]])})))).then((function(e){return Gn.mergeObjectSync(n,e)})):Gn.mergeObjectSync(n,l)}},{key:"shape",get:function(){return this._def.shape()}},{key:"strict",value:function(e){var r=this;return qn.errToObj,new t(_objectSpread(_objectSpread({},this._def),{},{unknownKeys:"strict"},void 0!==e?{errorMap:function(t,n){var a,i,o,u,s=null!==(a=null===(i=(o=r._def).errorMap)||void 0===i?void 0:i.call(o,t,n).message)&&void 0!==a?a:n.defaultError;return"unrecognized_keys"===t.code?{message:null!==(u=qn.errToObj(e).message)&&void 0!==u?u:s}:{message:s}}}:{}))}},{key:"strip",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{unknownKeys:"strip"}))}},{key:"passthrough",value:function(){return new t(_objectSpread(_objectSpread({},this._def),{},{unknownKeys:"passthrough"}))}},{key:"extend",value:function(e){var r=this;return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return _objectSpread(_objectSpread({},r._def.shape()),e)}}))}},{key:"merge",value:function(e){var r=this;return new t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:function(){return _objectSpread(_objectSpread({},r._def.shape()),e._def.shape())},typeName:ti.ZodObject})}},{key:"setKey",value:function(e,t){return this.augment(_defineProperty({},e,t))}},{key:"catchall",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{catchall:e}))}},{key:"pick",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(e));try{for(a.s();!(r=a.n()).done;){var i=r.value;e[i]&&this.shape[i]&&(n[i]=this.shape[i])}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"omit",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(this.shape));try{for(a.s();!(r=a.n()).done;){var i=r.value;e[i]||(n[i]=this.shape[i])}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"deepPartial",value:function(){return Ra(this)}},{key:"partial",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(this.shape));try{for(a.s();!(r=a.n()).done;){var i=r.value,o=this.shape[i];e&&!e[i]?n[i]=o:n[i]=o.optional()}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"required",value:function(e){var r,n={},a=_createForOfIteratorHelper(fn.objectKeys(this.shape));try{for(a.s();!(r=a.n()).done;){var i=r.value;if(e&&!e[i])n[i]=this.shape[i];else{for(var o=this.shape[i];o instanceof Wa;)o=o._def.innerType;n[i]=o}}}catch(e){a.e(e)}finally{a.f()}return new t(_objectSpread(_objectSpread({},this._def),{},{shape:function(){return n}}))}},{key:"keyof",value:function(){return Ya(fn.objectKeys(this.shape))}}])}(Jn);ja.create=function(e,t){return new ja(_objectSpread({shape:function(){return e},unknownKeys:"strip",catchall:Ma.create(),typeName:ti.ZodObject},$n(t)))},ja.strictCreate=function(e,t){return new ja(_objectSpread({shape:function(){return e},unknownKeys:"strict",catchall:Ma.create(),typeName:ti.ZodObject},$n(t)))},ja.lazycreate=function(e,t){return new ja(_objectSpread({shape:e,unknownKeys:"strip",catchall:Ma.create(),typeName:ti.ZodObject},$n(t)))};var Da=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,r=this._def.options;if(t.common.async)return Promise.all(r.map(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=_objectSpread(_objectSpread({},t),{},{common:_objectSpread(_objectSpread({},t.common),{},{issues:[]}),parent:null}),e.next=3,r._parseAsync({data:t.data,path:t.path,parent:n});case 3:return e.t0=e.sent,e.t1=n,e.abrupt("return",{result:e.t0,ctx:e.t1});case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())).then((function(e){var r,n=_createForOfIteratorHelper(e);try{for(n.s();!(r=n.n()).done;){var a=r.value;if("valid"===a.result.status)return a.result}}catch(e){n.e(e)}finally{n.f()}var i,o=_createForOfIteratorHelper(e);try{for(o.s();!(i=o.n()).done;){var u,s=i.value;if("dirty"===s.result.status)return(u=t.common.issues).push.apply(u,_toConsumableArray(s.ctx.common.issues)),s.result}}catch(e){o.e(e)}finally{o.f()}var c=e.map((function(e){return new Pn(e.ctx.common.issues)}));return Un(t,{code:Dn.invalid_union,unionErrors:c}),Hn}));var n,a,i=void 0,o=[],u=_createForOfIteratorHelper(r);try{for(u.s();!(n=u.n()).done;){var s=n.value,c=_objectSpread(_objectSpread({},t),{},{common:_objectSpread(_objectSpread({},t.common),{},{issues:[]}),parent:null}),f=s._parseSync({data:t.data,path:t.path,parent:c});if("valid"===f.status)return f;"dirty"!==f.status||i||(i={result:f,ctx:c}),c.common.issues.length&&o.push(c.common.issues)}}catch(e){u.e(e)}finally{u.f()}if(i)return(a=t.common.issues).push.apply(a,_toConsumableArray(i.ctx.common.issues)),i.result;var l=o.map((function(e){return new Pn(e)}));return Un(t,{code:Dn.invalid_union,unionErrors:l}),Hn}},{key:"options",get:function(){return this._def.options}}])}(Jn);Da.create=function(e,t){return new Da(_objectSpread({options:e,typeName:ti.ZodUnion},$n(t)))};var Pa=function(e){return e instanceof Za?Pa(e.schema):e instanceof Xa?Pa(e.innerType()):e instanceof Va?[e.value]:e instanceof Ba?e.options:e instanceof Ka?fn.objectValues(e.enum):e instanceof Qa?Pa(e._def.innerType):e instanceof Na?[void 0]:e instanceof Ta?[null]:e instanceof Wa?[void 0].concat(_toConsumableArray(Pa(e.unwrap()))):e instanceof $a?[null].concat(_toConsumableArray(Pa(e.unwrap()))):e instanceof ri||e instanceof ai?Pa(e.unwrap()):e instanceof Ja?Pa(e._def.innerType):[]},La=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;if(t.parsedType!==Rn.object)return Un(t,{code:Dn.invalid_type,expected:Rn.object,received:t.parsedType}),Hn;var r=this.discriminator,n=t.data[r],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(Un(t,{code:Dn.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[r]}),Hn)}},{key:"discriminator",get:function(){return this._def.discriminator}},{key:"options",get:function(){return this._def.options}},{key:"optionsMap",get:function(){return this._def.optionsMap}}],[{key:"create",value:function(e,r,n){var a,i=new Map,o=_createForOfIteratorHelper(r);try{for(o.s();!(a=o.n()).done;){var u=a.value,s=Pa(u.shape[e]);if(!s.length)throw new Error("A discriminator value for key `".concat(e,"` could not be extracted from all schema options"));var c,f=_createForOfIteratorHelper(s);try{for(f.s();!(c=f.n()).done;){var l=c.value;if(i.has(l))throw new Error("Discriminator property ".concat(String(e)," has duplicate value ").concat(String(l)));i.set(l,u)}}catch(e){f.e(e)}finally{f.f()}}}catch(e){o.e(e)}finally{o.f()}return new t(_objectSpread({typeName:ti.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:i},$n(n)))}}])}(Jn);function Fa(e,t){var r=jn(e),n=jn(t);if(e===t)return{valid:!0,data:e};if(r===Rn.object&&n===Rn.object){var a,i=fn.objectKeys(t),o=fn.objectKeys(e).filter((function(e){return-1!==i.indexOf(e)})),u=_objectSpread(_objectSpread({},e),t),s=_createForOfIteratorHelper(o);try{for(s.s();!(a=s.n()).done;){var c=a.value,f=Fa(e[c],t[c]);if(!f.valid)return{valid:!1};u[c]=f.data}}catch(e){s.e(e)}finally{s.f()}return{valid:!0,data:u}}if(r===Rn.array&&n===Rn.array){if(e.length!==t.length)return{valid:!1};for(var l=[],p=0;p<e.length;p++){var d=Fa(e[p],t[p]);if(!d.valid)return{valid:!1};l.push(d.data)}return{valid:!0,data:l}}return r===Rn.date&&n===Rn.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}var Ua=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.status,n=t.ctx,a=function(e,t){if(Yn(e)||Yn(t))return Hn;var a=Fa(e.value,t.value);return a.valid?((Bn(e)||Bn(t))&&r.dirty(),{status:r.value,value:a.data}):(Un(n,{code:Dn.invalid_intersection_types}),Hn)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return a(r,n)})):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}])}(Jn);Ua.create=function(e,t,r){return new Ua(_objectSpread({left:e,right:t,typeName:ti.ZodIntersection},$n(r)))};var qa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e),n=r.status,a=r.ctx;if(a.parsedType!==Rn.array)return Un(a,{code:Dn.invalid_type,expected:Rn.array,received:a.parsedType}),Hn;if(a.data.length<this._def.items.length)return Un(a,{code:Dn.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Hn;!this._def.rest&&a.data.length>this._def.items.length&&(Un(a,{code:Dn.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),n.dirty());var i=_toConsumableArray(a.data).map((function(e,r){var n=t._def.items[r]||t._def.rest;return n?n._parse(new Xn(a,e,a.path,r)):null})).filter((function(e){return!!e}));return a.common.async?Promise.all(i).then((function(e){return Gn.mergeArray(n,e)})):Gn.mergeArray(n,i)}},{key:"items",get:function(){return this._def.items}},{key:"rest",value:function(e){return new t(_objectSpread(_objectSpread({},this._def),{},{rest:e}))}}])}(Jn);qa.create=function(e,t){if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new qa(_objectSpread({items:e,typeName:ti.ZodTuple,rest:null},$n(t)))};var Ga=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"keySchema",get:function(){return this._def.keyType}},{key:"valueSchema",get:function(){return this._def.valueType}},{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.status,n=t.ctx;if(n.parsedType!==Rn.map)return Un(n,{code:Dn.invalid_type,expected:Rn.map,received:n.parsedType}),Hn;var a=this._def.keyType,i=this._def.valueType,o=_toConsumableArray(n.data.entries()).map((function(e,t){var r=_slicedToArray(e,2),o=r[0],u=r[1];return{key:a._parse(new Xn(n,o,n.path,[t,"key"])),value:i._parse(new Xn(n,u,n.path,[t,"value"]))}}));if(n.common.async){var u=new Map;return Promise.resolve().then(_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,n,a,i,s;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=_createForOfIteratorHelper(o),e.prev=1,t.s();case 3:if((n=t.n()).done){e.next=17;break}return a=n.value,e.next=7,a.key;case 7:return i=e.sent,e.next=10,a.value;case 10:if(s=e.sent,"aborted"!==i.status&&"aborted"!==s.status){e.next=13;break}return e.abrupt("return",Hn);case 13:"dirty"!==i.status&&"dirty"!==s.status||r.dirty(),u.set(i.value,s.value);case 15:e.next=3;break;case 17:e.next=22;break;case 19:e.prev=19,e.t0=e.catch(1),t.e(e.t0);case 22:return e.prev=22,t.f(),e.finish(22);case 25:return e.abrupt("return",{status:r.value,value:u});case 26:case"end":return e.stop()}}),e,null,[[1,19,22,25]])}))))}var s,c=new Map,f=_createForOfIteratorHelper(o);try{for(f.s();!(s=f.n()).done;){var l=s.value,p=l.key,d=l.value;if("aborted"===p.status||"aborted"===d.status)return Hn;"dirty"!==p.status&&"dirty"!==d.status||r.dirty(),c.set(p.value,d.value)}}catch(e){f.e(e)}finally{f.f()}return{status:r.value,value:c}}}])}(Jn);Ga.create=function(e,t,r){return new Ga(_objectSpread({valueType:t,keyType:e,typeName:ti.ZodMap},$n(r)))};var Ha=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e),r=t.status,n=t.ctx;if(n.parsedType!==Rn.set)return Un(n,{code:Dn.invalid_type,expected:Rn.set,received:n.parsedType}),Hn;var a=this._def;null!==a.minSize&&n.data.size<a.minSize.value&&(Un(n,{code:Dn.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),null!==a.maxSize&&n.data.size>a.maxSize.value&&(Un(n,{code:Dn.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());var i=this._def.valueType;function o(e){var t,n=new Set,a=_createForOfIteratorHelper(e);try{for(a.s();!(t=a.n()).done;){var i=t.value;if("aborted"===i.status)return Hn;"dirty"===i.status&&r.dirty(),n.add(i.value)}}catch(e){a.e(e)}finally{a.f()}return{status:r.value,value:n}}var u=_toConsumableArray(n.data.values()).map((function(e,t){return i._parse(new Xn(n,e,n.path,t))}));return n.common.async?Promise.all(u).then((function(e){return o(e)})):o(u)}},{key:"min",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{minSize:{value:e,message:qn.toString(r)}}))}},{key:"max",value:function(e,r){return new t(_objectSpread(_objectSpread({},this._def),{},{maxSize:{value:e,message:qn.toString(r)}}))}},{key:"size",value:function(e,t){return this.min(e,t).max(e,t)}},{key:"nonempty",value:function(e){return this.min(1,e)}}])}(Jn);Ha.create=function(e,t){return new Ha(_objectSpread({valueType:e,minSize:null,maxSize:null,typeName:ti.ZodSet},$n(t)))};var Za=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"schema",get:function(){return this._def.getter()}},{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx;return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}])}(Jn);Za.create=function(e,t){return new Za(_objectSpread({getter:e,typeName:ti.ZodLazy},$n(t)))};var Va=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(e.data!==this._def.value){var t=this._getOrReturnCtx(e);return Un(t,{received:t.data,code:Dn.invalid_literal,expected:this._def.value}),Hn}return{status:"valid",value:e.data}}},{key:"value",get:function(){return this._def.value}}])}(Jn);function Ya(e,t){return new Ba(_objectSpread({values:e,typeName:ti.ZodEnum},$n(t)))}Va.create=function(e,t){return new Va(_objectSpread({value:e,typeName:ti.ZodLiteral},$n(t)))};var Ba=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if("string"!=typeof e.data){var t=this._getOrReturnCtx(e),r=this._def.values;return Un(t,{expected:fn.joinValues(r),received:t.parsedType,code:Dn.invalid_type}),Hn}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){var n=this._getOrReturnCtx(e),a=this._def.values;return Un(n,{received:n.data,code:Dn.invalid_enum_value,options:a}),Hn}return Vn(e.data)}},{key:"options",get:function(){return this._def.values}},{key:"enum",get:function(){var e,t={},r=_createForOfIteratorHelper(this._def.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;t[n]=n}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"Values",get:function(){var e,t={},r=_createForOfIteratorHelper(this._def.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;t[n]=n}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"Enum",get:function(){var e,t={},r=_createForOfIteratorHelper(this._def.values);try{for(r.s();!(e=r.n()).done;){var n=e.value;t[n]=n}}catch(e){r.e(e)}finally{r.f()}return t}},{key:"extract",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._def;return t.create(e,_objectSpread(_objectSpread({},this._def),r))}},{key:"exclude",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._def;return t.create(this.options.filter((function(t){return!e.includes(t)})),_objectSpread(_objectSpread({},this._def),r))}}])}(Jn);Ba.create=Ya;var Ka=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=fn.getValidEnumValues(this._def.values),r=this._getOrReturnCtx(e);if(r.parsedType!==Rn.string&&r.parsedType!==Rn.number){var n=fn.objectValues(t);return Un(r,{expected:fn.joinValues(n),received:r.parsedType,code:Dn.invalid_type}),Hn}if(this._cache||(this._cache=new Set(fn.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){var a=fn.objectValues(t);return Un(r,{received:r.data,code:Dn.invalid_enum_value,options:a}),Hn}return Vn(e.data)}},{key:"enum",get:function(){return this._def.values}}])}(Jn);Ka.create=function(e,t){return new Ka(_objectSpread({values:e,typeName:ti.ZodNativeEnum},$n(t)))};var za=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"unwrap",value:function(){return this._def.type}},{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e).ctx;if(r.parsedType!==Rn.promise&&!1===r.common.async)return Un(r,{code:Dn.invalid_type,expected:Rn.promise,received:r.parsedType}),Hn;var n=r.parsedType===Rn.promise?r.data:Promise.resolve(r.data);return Vn(n.then((function(e){return t._def.type.parseAsync(e,{path:r.path,errorMap:r.common.contextualErrorMap})})))}}])}(Jn);za.create=function(e,t){return new za(_objectSpread({type:e,typeName:ti.ZodPromise},$n(t)))};var Xa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"innerType",value:function(){return this._def.schema}},{key:"sourceType",value:function(){return this._def.schema._def.typeName===ti.ZodEffects?this._def.schema.sourceType():this._def.schema}},{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e),n=r.status,a=r.ctx,i=this._def.effect||null,o={addIssue:function(e){Un(a,e),e.fatal?n.abort():n.dirty()},get path(){return a.path}};if(o.addIssue=o.addIssue.bind(o),"preprocess"===i.type){var u=i.transform(a.data,o);if(a.common.async)return Promise.resolve(u).then(function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(r){var i;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("aborted"!==n.value){e.next=2;break}return e.abrupt("return",Hn);case 2:return e.next=4,t._def.schema._parseAsync({data:r,path:a.path,parent:a});case 4:if("aborted"!==(i=e.sent).status){e.next=7;break}return e.abrupt("return",Hn);case 7:if("dirty"!==i.status){e.next=9;break}return e.abrupt("return",Zn(i.value));case 9:if("dirty"!==n.value){e.next=11;break}return e.abrupt("return",Zn(i.value));case 11:return e.abrupt("return",i);case 12:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}());if("aborted"===n.value)return Hn;var s=this._def.schema._parseSync({data:u,path:a.path,parent:a});return"aborted"===s.status?Hn:"dirty"===s.status||"dirty"===n.value?Zn(s.value):s}if("refinement"===i.type){var c=function(e){var t=i.refinement(e,o);if(a.common.async)return Promise.resolve(t);if(t instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return e};if(!1===a.common.async){var f=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===f.status?Hn:("dirty"===f.status&&n.dirty(),c(f.value),{status:n.value,value:f.value})}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((function(e){return"aborted"===e.status?Hn:("dirty"===e.status&&n.dirty(),c(e.value).then((function(){return{status:n.value,value:e.value}})))}))}if("transform"===i.type){if(!1===a.common.async){var l=this._def.schema._parseSync({data:a.data,path:a.path,parent:a});if(!Kn(l))return Hn;var p=i.transform(l.value,o);if(p instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:n.value,value:p}}return this._def.schema._parseAsync({data:a.data,path:a.path,parent:a}).then((function(e){return Kn(e)?Promise.resolve(i.transform(e.value,o)).then((function(e){return{status:n.value,value:e}})):Hn}))}fn.assertNever(i)}}])}(Jn);Xa.create=function(e,t,r){return new Xa(_objectSpread({schema:e,typeName:ti.ZodEffects,effect:t},$n(r)))},Xa.createWithPreprocess=function(e,t,r){return new Xa(_objectSpread({schema:t,effect:{type:"preprocess",transform:e},typeName:ti.ZodEffects},$n(r)))};var Wa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return this._getType(e)===Rn.undefined?Vn(void 0):this._def.innerType._parse(e)}},{key:"unwrap",value:function(){return this._def.innerType}}])}(Jn);Wa.create=function(e,t){return new Wa(_objectSpread({innerType:e,typeName:ti.ZodOptional},$n(t)))};var $a=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){return this._getType(e)===Rn.null?Vn(null):this._def.innerType._parse(e)}},{key:"unwrap",value:function(){return this._def.innerType}}])}(Jn);$a.create=function(e,t){return new $a(_objectSpread({innerType:e,typeName:ti.ZodNullable},$n(t)))};var Qa=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,r=t.data;return t.parsedType===Rn.undefined&&(r=this._def.defaultValue()),this._def.innerType._parse({data:r,path:t.path,parent:t})}},{key:"removeDefault",value:function(){return this._def.innerType}}])}(Jn);Qa.create=function(e,t){return new Qa(_objectSpread({innerType:e,typeName:ti.ZodDefault,defaultValue:"function"==typeof t.default?t.default:function(){return t.default}},$n(t)))};var Ja=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e).ctx,n=_objectSpread(_objectSpread({},r),{},{common:_objectSpread(_objectSpread({},r.common),{},{issues:[]})}),a=this._def.innerType._parse({data:n.data,path:n.path,parent:_objectSpread({},n)});return zn(a)?a.then((function(e){return{status:"valid",value:"valid"===e.status?e.value:t._def.catchValue({get error(){return new Pn(n.common.issues)},input:n.data})}})):{status:"valid",value:"valid"===a.status?a.value:this._def.catchValue({get error(){return new Pn(n.common.issues)},input:n.data})}}},{key:"removeCatch",value:function(){return this._def.innerType}}])}(Jn);Ja.create=function(e,t){return new Ja(_objectSpread({innerType:e,typeName:ti.ZodCatch,catchValue:"function"==typeof t.catch?t.catch:function(){return t.catch}},$n(t)))};var ei=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){if(this._getType(e)!==Rn.nan){var t=this._getOrReturnCtx(e);return Un(t,{code:Dn.invalid_type,expected:Rn.nan,received:t.parsedType}),Hn}return{status:"valid",value:e.data}}}])}(Jn);ei.create=function(e){return new ei(_objectSpread({typeName:ti.ZodNaN},$n(e)))};var ti,ri=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._processInputParams(e).ctx,r=t.data;return this._def.type._parse({data:r,path:t.path,parent:t})}},{key:"unwrap",value:function(){return this._def.type}}])}(Jn),ni=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this,r=this._processInputParams(e),n=r.status,a=r.ctx;if(a.common.async){var i=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t._def.in._parseAsync({data:a.data,path:a.path,parent:a});case 2:if("aborted"!==(r=e.sent).status){e.next=5;break}return e.abrupt("return",Hn);case 5:if("dirty"!==r.status){e.next=10;break}return n.dirty(),e.abrupt("return",Zn(r.value));case 10:return e.abrupt("return",t._def.out._parseAsync({data:r.value,path:a.path,parent:a}));case 11:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return i()}var o=this._def.in._parseSync({data:a.data,path:a.path,parent:a});return"aborted"===o.status?Hn:"dirty"===o.status?(n.dirty(),{status:"dirty",value:o.value}):this._def.out._parseSync({data:o.value,path:a.path,parent:a})}}],[{key:"create",value:function(e,r){return new t({in:e,out:r,typeName:ti.ZodPipeline})}}])}(Jn),ai=function(e){function t(){return _classCallCheck(this,t),_callSuper(this,t,arguments)}return _inherits(t,e),_createClass(t,[{key:"_parse",value:function(e){var t=this._def.innerType._parse(e),r=function(e){return Kn(e)&&(e.value=Object.freeze(e.value)),e};return zn(t)?t.then((function(e){return r(e)})):r(t)}},{key:"unwrap",value:function(){return this._def.innerType}}])}(Jn);ai.create=function(e,t){return new ai(_objectSpread({innerType:e,typeName:ti.ZodReadonly},$n(t)))},function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"}(ti||(ti={}));var ii=ba.create,oi=ka.create,ui=Aa.create;Ma.create;var si=Oa.create,ci=ja.create;Da.create;var fi=La.create;Ua.create,qa.create;var li=Va.create,pi=Ba.create;za.create,Wa.create,$a.create;var di=Xa.createWithPreprocess,hi=ci({graphType:pi(["v2","v2-raw"]),category:pi(["tokens","markets"]),param1:ii().nonempty(),param2:ii().optional()});function vi(){return vi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(f),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=r[3],On(hi,{graphType:n,category:a,param1:i,param2:o}),u="".concat("https://onchain-proxy.fileverse.io/third-party")+"?service=aave"+"&graphType=".concat(encodeURIComponent(n))+"&category=".concat(encodeURIComponent(a))+"&input1=".concat(encodeURIComponent(i))+(o?"&input2=".concat(encodeURIComponent(o)):""),e.next=7,fetch(u);case 7:if((s=e.sent).ok){e.next=10;break}throw new An("AAVE",s.status);case 10:return e.next=12,s.json();case 12:if(c=e.sent,!Array.isArray(c)){e.next=15;break}return e.abrupt("return",c.map((function(e){var t={};return Object.entries(e).forEach((function(e){var r=_slicedToArray(e,2),n=r[0],a=r[1];null!==a&&"object"===_typeof(a)||(t[n]=a)})),t})));case 15:return e.abrupt("return",c);case 18:return e.prev=18,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"AAVE"));case 21:case"end":return e.stop()}}),e,null,[[0,18]])}))),vi.apply(this,arguments)}var mi=di((function(e){return"string"==typeof e&&/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(e)?function(e){var t=_slicedToArray(e.split("/"),3),r=t[0],n=t[1],a=t[2],i=new Date("".concat(a,"-").concat(n.padStart(2,"0"),"-").concat(r.padStart(2,"0"))).getTime();return isNaN(i)?NaN:Math.floor(i/1e3)}(e):e}),oi({invalid_type_error:"Date must be a valid DD/MM/YYYY or timestamp"}).int("Date must be an integer timestamp").nonnegative("Date must be a nonnegative timestamp").refine((function(e){return!isNaN(e)}),{message:"Invalid date format or value: expected DD/MM/YYYY"})),gi=ci({addresses:ii().nonempty(),category:pi(["balance","txns"]),chains:di((function(e){return"string"==typeof e?e.split(",").map((function(e){return e.trim()})).filter(Boolean):e}),si(pi(["ethereum","gnosis","base"])).nonempty()),startTime:mi.optional(),endTime:mi.optional(),page:oi().int().nonnegative().default(1),offset:oi().int().nonnegative().max(xn,{message:'"offset" must be less than or equal to '.concat(xn)}).default(10)}),yi=di((function(e){var t=_objectSpread({},e||{});return"balance"===t.category&&(delete t.startTime,delete t.endTime),t}),gi.refine((function(e){return"txns"!==e.category||void 0!==e.startTime&&void 0!==e.endTime}),{message:"startTime and endTime required for txns",path:["startTime"]})),_i=function(e){return/^0x[a-fA-F0-9]{40}$/.test(e)};function bi(e){return ki.apply(this,arguments)}function ki(){return ki=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("undefined"!=typeof ethers){e.next=3;break}return e.next=3,new Promise((function(e,t){var r=document.createElement("script");r.src="https://cdn.jsdelivr.net/npm/ethers@6.10.0/dist/ethers.umd.min.js",r.onload=e,r.onerror=t,document.head.appendChild(r)}));case 3:if(r=window.localStorage.getItem(wn)){e.next=7;break}return console.error("alchemy api key missing"),e.abrupt("return",null);case 7:return n=new ethers.AlchemyProvider("mainnet",r),e.prev=8,e.next=11,n.resolveName(t);case 11:return a=e.sent,e.abrupt("return",a||null);case 15:return e.prev=15,e.t0=e.catch(8),console.error("ENS resolution failed:",e.t0.message),e.abrupt("return",null);case 19:case"end":return e.stop()}}),e,null,[[8,15]])}))),ki.apply(this,arguments)}var wi,xi=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!_i(t)){e.next=2;break}return e.abrupt("return",t);case 2:return e.next=4,bi(t);case 4:if(!(r=e.sent)){e.next=7;break}return e.abrupt("return",r);case 7:throw new En("Invalid address");case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Si={validateAndGetAddress:xi};function Ei(e){var t=e.url,r=e.serviceName,n=e.headers,a=void 0===n?{}:n,i=function(){if(!wi){var e="".concat(window.NEXT_PUBLIC_PROXY_BASE_URL,"/proxy");wi={DuneSim:{url:e},Etherscan:{url:e,removeParams:["apikey"]},Basescan:{url:e,removeParams:["apikey"]},Gnosisscan:{url:e,removeParams:["apikey"]},Coingecko:{url:e,removeParams:["apikey"]},Firefly:{url:e,removeParams:["apikey"]},Neynar:{url:e,removeParams:["api_key"]},Safe:{url:e,removeParams:["api_key"]},Defillama:{url:e,removeParams:["api_key"]},GnosisPay:{url:e,removeParams:["api_key"]}}}return wi}(),o=window.localStorage.getItem(Sn[r]),u="DEFAULT_PROXY_MODE"===o,s=i[r];if(!s&&Sn[r]&&(!o||""===o))throw new Nn(Sn[r]);if((u||!o||""===o)&&s){var c=function(e,t){if(!t||0===t.length)return e;var r=new URL(e);return t.forEach((function(e){r.searchParams.has(e)&&r.searchParams.delete(e)})),r.toString()}(t,s.removeParams);return{URL:s.url,HEADERS:{"target-url":c,method:"GET","Content-Type":"application/json","Cache-Control":"no-store",Pragma:"no-cache"}}}return{URL:t,HEADERS:_objectSpread({"Cache-Control":"no-store",Pragma:"no-cache"},a)}}var Ni=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r,n){var a,i,o,u,s,c,f;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t&&r){e.next=2;break}return e.abrupt("return");case 2:return a=pn[r],i="https://api.etherscan.io/v2/api?module=block&action=getblocknobytime&timestamp=".concat(t,"&closest=before&apikey=").concat(n,"&chainId=").concat(a),o=Ei({url:i,serviceName:"Etherscan",headers:{}}),u=o.URL,s=o.HEADERS,e.next=7,fetch(u,{method:"GET",headers:s});case 7:return c=e.sent,e.next=10,c.json();case 10:return f=e.sent,e.abrupt("return",parseInt(f.result));case 12:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),Ti={fromTimeStampToBlock:Ni};function Ai(e){var t=_slicedToArray(e.split("/").map(Number),3),r=t[0],n=t[1],a=t[2],i=new Date(a,n-1,r);return Math.floor(i.getTime()/1e3)}function Ii(){return Ii=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,A=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,t=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Ei({url:t,serviceName:"Etherscan",headers:{}}),n=r.URL,a=r.HEADERS,e.next=3,fetch(n,{method:"GET",headers:a});case 3:if((i=e.sent).ok){e.next=6;break}throw new An(Sn.Etherscan,i.status);case 6:return e.next=8,i.json();case 8:if("string"!=typeof(o=e.sent).result){e.next=14;break}if(!o.result.includes("Invalid API Key")){e.next=12;break}throw new Mn(Sn.Etherscan);case 12:if(!o.result.includes("Max rate limit reached")){e.next=14;break}throw new Tn(Sn.Etherscan);case 14:return e.abrupt("return",o.result);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),r=T(A),n=_slicedToArray(r,7),a=n[0],i=n[1],o=n[2],u=n[3],s=n[4],c=n[5],f=void 0===c?1:c,l=n[6],On(yi,{addresses:a,category:i,chains:o,startTime:u,endTime:s,page:f,offset:p=void 0===l?10:l}),d=window.localStorage.getItem(Sn.Etherscan),h=a.split(",").map((function(e){return e.trim()})).filter(Boolean),v=o.split(",").map((function(e){return e.trim()})).filter(Boolean),m={},g=_createForOfIteratorHelper(h),e.prev=9,g.s();case 11:if((y=g.n()).done){e.next=23;break}if(_=y.value,!_i(_)){e.next=17;break}m[_.toLowerCase()]=null,e.next=21;break;case 17:return e.next=19,Si.validateAndGetAddress(_);case 19:b=e.sent,m[b.toLowerCase()]=b;case 21:e.next=11;break;case 23:e.next=28;break;case 25:e.prev=25,e.t0=e.catch(9),g.e(e.t0);case 28:return e.prev=28,g.f(),e.finish(28);case 31:k=Object.keys(m),w=[],x=_createForOfIteratorHelper(v),e.prev=34,E=_regeneratorRuntime().mark((function e(){var r,n,a,o,c,l,h,v,g,y,_;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=S.value,n=pn[r]){e.next=4;break}throw new En("Invalid chain: ".concat(r));case 4:if("balance"!==i){e.next=17;break}a=_regeneratorRuntime().mark((function e(a){var i,o,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=k.slice(a,a+20).join(","),o="https://api.etherscan.io/v2/api?chainid=".concat(n)+"&module=account&action=addresstokenbalance&address=".concat(i)+"&page=".concat(f,"&offset=").concat(p,"&apikey=").concat(d),e.next=4,t(o);case 4:if(u=e.sent,Array.isArray(u)){e.next=7;break}return e.abrupt("return",{v:{v:u}});case 7:u.forEach((function(e,t){return w.push(_objectSpread({chain:r,address:k[a+t],name:m[k[a+t]]},e))}));case 8:case"end":return e.stop()}}),e)})),c=0;case 7:if(!(c<k.length)){e.next=15;break}return e.delegateYield(a(c),"t0",9);case 9:if(!(o=e.t0)){e.next=12;break}return e.abrupt("return",o.v);case 12:c+=20,e.next=7;break;case 15:e.next=37;break;case 17:return e.next=19,Ti.fromTimeStampToBlock(Ai(u),r,d);case 19:return l=e.sent,e.next=22,Ti.fromTimeStampToBlock(Ai(s),r,d);case 22:if(h=e.sent,l){e.next=25;break}throw new En("Invalid startTime: ".concat(u));case 25:if(h){e.next=27;break}throw new En("Invalid endTime: ".concat(s));case 27:v=_regeneratorRuntime().mark((function e(){var a,i,o;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=_[y],i="https://api.etherscan.io/v2/api?chainid=".concat(n)+"&module=account&action=tokentx&address=".concat(a)+"&startblock=".concat(l,"&endblock=").concat(h)+"&page=".concat(f,"&offset=").concat(p,"&sort=asc&apikey=").concat(d),e.next=4,t(i);case 4:if(o=e.sent,Array.isArray(o)){e.next=7;break}return e.abrupt("return",{v:{v:o}});case 7:o.forEach((function(e){return w.push(_objectSpread({chain:r,address:a,name:m[a]},e))}));case 8:case"end":return e.stop()}}),e)})),y=0,_=k;case 29:if(!(y<_.length)){e.next=37;break}return e.delegateYield(v(),"t1",31);case 31:if(!(g=e.t1)){e.next=34;break}return e.abrupt("return",g.v);case 34:y++,e.next=29;break;case 37:case"end":return e.stop()}}),e)})),x.s();case 37:if((S=x.n()).done){e.next=44;break}return e.delegateYield(E(),"t1",39);case 39:if(!(N=e.t1)){e.next=42;break}return e.abrupt("return",N.v);case 42:e.next=37;break;case 44:e.next=49;break;case 46:e.prev=46,e.t2=e.catch(34),x.e(e.t2);case 49:return e.prev=49,x.f(),e.finish(49);case 52:return e.abrupt("return",w);case 55:return e.prev=55,e.t3=e.catch(0),e.abrupt("return",Cn(e.t3,"EOA"));case 58:case"end":return e.stop()}}),e,null,[[0,55],[9,25,28,31],[34,46,49,52]])}))),Ii.apply(this,arguments)}var Mi=fi("type",[ci({type:li("gas"),startDate:mi.optional(),endDate:mi.optional(),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)}),ci({type:pi(["all-txns","token-txns","nft-txns"]),address:ii().nonempty(),startDate:mi.optional(),endDate:mi.optional(),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)})]);function Ci(e){return Oi.apply(this,arguments)}function Oi(){return(Oi=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,T,A;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.type,n=t.address,a=t.startDate,i=t.endDate,o=t.page,u=void 0===o?1:o,s=t.offset,c=void 0===s?10:s,f=t.apiKey,l=t.functionName,p=t.chainId,d=t.network,h={BASE:{url:"https://api.basescan.org/api",apiKeyName:Sn.Basescan},ETHERSCAN:{url:"https://api.etherscan.io/v2/api",apiKeyName:Sn.Etherscan},GNOSIS:{url:"https://api.gnosisscan.io/api",apiKeyName:Sn.Gnosisscan}},"gas"===r){e.next=6;break}return e.next=5,Si.validateAndGetAddress(n);case 5:n=e.sent;case 6:if(v=h[l],m=null==v?void 0:v.url){e.next=10;break}throw new En("Api not found for: ".concat(l));case 10:if(g={"all-txns":"txlist","token-txns":"tokentx","nft-txns":"tokennfttx",gas:"gasoracle"}[r]){e.next=14;break}throw new En("Invalid type: ".concat(r));case 14:if(y="gasoracle"===g?"gastracker":"account",_="".concat(m,"?chainid=").concat(p,"&module=").concat(y,"&action=").concat(g,"&apikey=").concat(f),!["all-txns","token-txns","nft-txns"].includes(r)){e.next=27;break}if(_+="&address=".concat(n,"&startblock=0&endblock=99999999&sort=asc"),isNaN(a)||isNaN(i)){e.next=26;break}return e.next=21,Promise.all([Ti.fromTimeStampToBlock(Ai(a),d,f),Ti.fromTimeStampToBlock(Ai(i),d,f)]);case 21:b=e.sent,k=_slicedToArray(b,2),w=k[0],x=k[1],_+="&startblock=".concat(w||"0","&endblock=").concat(x||"99999999");case 26:_+="&page=".concat(u,"&offset=").concat(c);case 27:return S=Ei({url:_,serviceName:v.apiKeyName,headers:{}}),E=S.URL,N=S.HEADERS,e.next=30,fetch(E,{method:"GET",headers:N});case 30:if((T=e.sent).ok){e.next=33;break}throw new An(v.apiKeyName,T.status);case 33:return e.next=35,T.json();case 35:if("string"!=typeof(A=e.sent).result){e.next=41;break}if(!A.result.includes("Invalid API Key")){e.next=39;break}throw new Mn(v.apiKeyName);case 39:if(!A.result.includes("Max rate limit reached")){e.next=41;break}throw new Tn(v.apiKeyName);case 41:return e.abrupt("return","gas"!==r||Array.isArray(A.result)?A.result:[A.result]);case 42:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ri(){return Ri=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(f),r=_slicedToArray(t,6),n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],s=r[5],On(Mi,{type:n,address:a,startDate:i,endDate:o,page:u,limit:s}),c=window.localStorage.getItem(Sn.Basescan),e.next=6,Ci({type:n,address:a,startDate:i,endDate:o,page:u,offset:s,apiKey:c,functionName:"BASE",chainId:pn.base,network:"base"});case 6:return e.abrupt("return",e.sent);case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"BASE"));case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),Ri.apply(this,arguments)}var ji=ci({address:ii().nonempty(),type:pi(["stat","txns","tokens"]),chain:pi(["ethereum","gnosis","arbitrum","optimism","soneium","unichain"]).default("ethereum"),startTimestamp:mi.optional(),endTimestamp:mi.optional(),page:oi().int().nonnegative().default(1),offset:oi().int().nonnegative().max(xn,{message:'"offset" must be less than or equal to '.concat(xn)}).default(10)});function Di(){return Di=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,n=T(b),a=_slicedToArray(n,7),i=a[0],o=a[1],u=a[2],s=void 0===u?"ethereum":u,c=a[3],f=a[4],l=a[5],p=a[6],On(ji,{address:i,type:o,chain:s,startTimestamp:c,endTimestamp:f,page:l,offset:p}),d=null!=c?c:Math.floor((Date.now()-2592e6)/1e3),h=f,e.next=7,Si.validateAndGetAddress(i);case 7:v=e.sent,m=dn[s],e.t0=o,e.next="stat"===e.t0?12:"txns"===e.t0?14:"tokens"===e.t0?16:18;break;case 12:return g="".concat(m,"/api/v2/addresses/").concat(v,"/counters"),e.abrupt("break",18);case 14:return g="".concat(m,"/api?module=account&action=txlist")+"&address=".concat(v)+"&start_timestamp=".concat(d)+"&end_timestamp=".concat(null!=h?h:"")+"&page=".concat(l)+"&offset=".concat(p)+"&sort=asc",e.abrupt("break",18);case 16:return g="".concat(m,"/api?module=account&action=tokenlist")+"&address=".concat(v),e.abrupt("break",18);case 18:return e.next=20,fetch(g);case 20:if((y=e.sent).ok){e.next=23;break}throw new An("BLOCKSCOUT",y.status);case 23:return e.next=25,y.json();case 25:if(null==(_=e.sent)||null===(t=_.result)||void 0===t||!t.includes("Invalid parameter(s)")){e.next=28;break}throw new En("Invalid parameters");case 28:if(null==_||null===(r=_.result)||void 0===r||!r.includes("Not found")){e.next=30;break}throw new En("Address information not found");case 30:return e.abrupt("return","stat"===o?[_]:_.result);case 33:return e.prev=33,e.t1=e.catch(0),e.abrupt("return",Cn(e.t1,"BLOCKSCOUT"));case 36:case"end":return e.stop()}}),e,null,[[0,33]])}))),Di.apply(this,arguments)}var Pi=["1h","24h","7d","14d","30d","200d","1y"],Li=ii().refine((function(e){return e.split(",").map((function(e){return e.trim().toLowerCase()})).some((function(e){return Pi.some((function(t){return e.includes(t)}))}))}),{message:"param2 must contain at least one of: '1h', '24h', '7d', '14d', '30d', '200d', '1y'"}).optional(),Fi=fi("category",[ci({category:li("price"),param1:ii().nonempty(),param2:ii().nonempty().optional()}),ci({category:li("market"),param1:pi(["all","base","meme","aiagents","bitcoin","ethereum","hyperliquid","pump","solana"]),param2:Li}),ci({category:li("stablecoins"),param1:pi(["all","yield-bearing-stablecoins","crypto-backed-stablecoin"]),param2:Li}),ci({category:li("derivatives"),param1:ii().nonempty(),param2:ui().optional()})]);function Ui(){return Ui=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,A,I,M,C,O,R=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.prev=0,r=T(R),n=_slicedToArray(r,3),a=n[0],i=n[1],o=n[2],On(Fi,{category:a,param1:i,param2:o}),u=window.localStorage.getItem(Sn.Coingecko),s={accept:"application/json","x-cg-demo-api-key":u},c="",e.t0=null==a||null===(t=a.toLowerCase)||void 0===t?void 0:t.call(a),e.next="price"===e.t0?9:"market"===e.t0?12:"stablecoins"===e.t0?17:"derivatives"===e.t0?21:23;break;case 9:return c="https://api.coingecko.com/api/v3/simple/price?vs_currencies=".concat(o||"usd","&symbols=").concat(i),e.abrupt("break",23);case 12:return f={all:"",base:"base-ecosystem",meme:"meme-token",aiagents:"ai-agents",bitcoin:"bitcoin-ecosystem",ethereum:"ethereum-ecosystem",hyperliquid:"hyperliquid-ecosystem",pump:"pump-ecosystem",solana:"solana-ecosystem"}[i]||"",l=o?"&price_change_percentage=".concat(o):"",c="https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&include_tokens=top&page=1&per_page=100".concat(f?"&category=".concat(f):"").concat(l),e.abrupt("break",23);case 17:return p="all"===i?"stablecoins":i,d=o?"&price_change_percentage=".concat(o):"",c="https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&category=".concat(p,"&order=market_cap_desc&page=1&per_page=100").concat(d),e.abrupt("break",23);case 21:return c=i&&"all"!==i?"https://api.coingecko.com/api/v3/derivatives/exchanges/".concat(i,"?include_tickers=all"):"https://api.coingecko.com/api/v3/derivatives",e.abrupt("break",23);case 23:return h=Ei({url:c,serviceName:"Coingecko",headers:s}),v=h.URL,m=h.HEADERS,e.next=26,fetch(v+"?refresh=true",{headers:m});case 26:return g=e.sent,e.next=29,g.json();case 29:if(y=e.sent,g.ok){e.next=35;break}if(!((null==y||null===(_=y.status)||void 0===_?void 0:_.error_message)||"").includes("API Key Missing")){e.next=34;break}throw new Mn(Sn.Coingecko);case 34:throw new An(Sn.Coingecko,g.status);case 35:if("price"!==a){e.next=39;break}for(b={},k=0,w=Object.entries(y);k<w.length;k++)for(x=_slicedToArray(w[k],2),S=x[0],E=x[1],N=0,A=Object.entries(E);N<A.length;N++)I=_slicedToArray(A[N],2),M=I[0],C=I[1],b["".concat(S.toUpperCase(),"_").concat(M.toUpperCase())]=C;return e.abrupt("return",[b]);case 39:return O=Array.isArray(y)?y:[y],e.abrupt("return",O.map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];"object"===_typeof(o)&&null!==o||(t[i]=o)}return t})));case 43:return e.prev=43,e.t1=e.catch(0),e.abrupt("return",Cn(e.t1,"COINGECKO"));case 46:case"end":return e.stop()}}),e,null,[[0,43]])}))),Ui.apply(this,arguments)}var qi=ci({category:pi(["protocols","yields","dex","fees"])}),Gi={protocols:"https://api.llama.fi/protocols",yields:"https://yields.llama.fi/pools",dex:"https://api.llama.fi/overview/dexs?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true",fees:"https://api.llama.fi/overview/fees?excludeTotalDataChart=true&excludeTotalDataChartBreakdown=true&dataType=dailyFees"};function Hi(){return Zi.apply(this,arguments)}function Zi(){return Zi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t=T(u),r=_slicedToArray(t,1),n=r[0],On(qi,{category:n}),a=Gi[n]){e.next=6;break}throw new En("Invalid category: ".concat(n));case 6:return e.next=8,fetch(a);case 8:if((i=e.sent).ok){e.next=11;break}throw new An(Sn.Defillama,i.status);case 11:return e.next=13,i.json();case 13:o=e.sent,e.t0=n,e.next="protocols"===e.t0?17:"yields"===e.t0?19:"dex"===e.t0||"fees"===e.t0?21:23;break;case 17:return o=Array.isArray(o)?o.slice(0,500):[],e.abrupt("break",23);case 19:return o=Array.isArray(o.data)?o.data.slice(0,500):[],e.abrupt("break",23);case 21:return o=Array.isArray(o.protocols)?o.protocols.slice(0,500):[],e.abrupt("break",23);case 23:return e.abrupt("return",(Array.isArray(o)?o:[o]).map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];null!==o&&"object"===_typeof(o)||(t[i]=o)}return t})));case 26:return e.prev=26,e.t1=e.catch(0),e.abrupt("return",Cn(e.t1,"DEFILLAMA"));case 29:case"end":return e.stop()}}),e,null,[[0,26]])}))),Zi.apply(this,arguments)}var Vi=fi("type",[ci({type:li("gas"),startDate:mi.optional(),endDate:mi.optional(),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)}),ci({type:pi(["all-txns","token-txns","nft-txns"]),address:ii().nonempty(),startDate:mi.optional(),endDate:mi.optional(),chain:pi(["ethereum","base","gnosis"]),page:oi().int().nonnegative().default(1),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10)})]);function Yi(){return Yi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t=T(h),r=_slicedToArray(t,7),n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],s=r[5],c=void 0===s?1:s,f=r[6],On(Vi,{type:n,chain:a,address:i,startDate:o,endDate:u,page:c,limit:l=void 0===f?10:f}),p=pn[a]){e.next=6;break}throw new En("Invalid chain: ".concat(a));case 6:return d=window.localStorage.getItem(Sn.Etherscan),e.next=9,Ci({type:n,address:i,startDate:o,endDate:u,page:c,offset:l,apiKey:d,functionName:"ETHERSCAN",chainId:p,network:a});case 9:return e.abrupt("return",e.sent);case 12:return e.prev=12,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"ETHERSCAN"));case 15:case"end":return e.stop()}}),e,null,[[0,12]])}))),Yi.apply(this,arguments)}var Bi=ci({contentType:pi(["posts","replies","channels"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)});function Ki(){return Ki=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(y),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=void 0===i?0:i,u=r[3],On(Bi,{contentType:n,identifier:a,start:o,end:s=void 0===u?10:u}),c=window.localStorage.getItem(Sn.Firefly),(f=new URL("https://openapi.firefly.land/v1/fileverse/fetch")).searchParams.set("query",a.split(",").map((function(e){return e.trim()})).filter(Boolean).join(",")),l={posts:"farcasterid",replies:"farcasterpostid",channels:"farcasterchannels"},f.searchParams.set("type",l[n]),f.searchParams.set("start",String(o)),f.searchParams.set("end",String(s)),p=Ei({url:f.toString(),serviceName:"Firefly",headers:{"x-api-key":c}}),d=p.URL,h=p.HEADERS,e.next=13,fetch(d,{method:"GET",headers:h});case 13:if((v=e.sent).ok){e.next=16;break}throw new An(Sn.Firefly,v.status);case 16:return e.next=18,v.json();case 18:if(m=e.sent,g=m.data,Array.isArray(g)){e.next=22;break}return e.abrupt("return",[]);case 22:return e.abrupt("return",g.map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];null!=o&&"object"===_typeof(o)||(t[i]=o)}return t.platform="farcaster",t})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"FARCASTER"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),Ki.apply(this,arguments)}var zi=fi("platform",[ci({platform:li("farcaster"),contentType:pi(["posts","replies","channels"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)}),ci({platform:li("lens"),contentType:pi(["posts","replies"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)})]),Xi={farcaster:{posts:"farcasterid",replies:"farcasterpostid",channels:"farcasterchannels"},lens:{posts:"lensid",replies:"lenspostid"}};function Wi(){return Wi=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(y),r=_slicedToArray(t,5),n=r[0],a=r[1],i=r[2],o=r[3],u=void 0===o?0:o,s=r[4],On(zi,{platform:n,contentType:a,identifier:i,start:u,end:c=void 0===s?10:s}),f=window.localStorage.getItem(Sn.Firefly),(l=new URL("https://openapi.firefly.land/v1/fileverse/fetch")).searchParams.set("query",i.split(",").map((function(e){return e.trim()})).filter(Boolean).join(",")),l.searchParams.set("type",Xi[n][a]),l.searchParams.set("start",String(u)),l.searchParams.set("end",String(c)),p=Ei({url:l.toString(),serviceName:"Firefly",headers:{"x-api-key":f}}),d=p.URL,h=p.HEADERS,e.next=12,fetch(d,{method:"GET",headers:h});case 12:if((v=e.sent).ok){e.next=15;break}throw new An(Sn.Firefly,v.status);case 15:return e.next=17,v.json();case 17:if(m=e.sent,g=m.data,Array.isArray(g)){e.next=21;break}return e.abrupt("return",[]);case 21:return e.abrupt("return",g.map((function(e){for(var t={},r=0,a=Object.entries(e);r<a.length;r++){var i=_slicedToArray(a[r],2),o=i[0],u=i[1];"object"===_typeof(u)&&null!==u||(t[o]=u)}return t.platform=n,t})));case 24:return e.prev=24,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"FIREFLY"));case 27:case"end":return e.stop()}}),e,null,[[0,24]])}))),Wi.apply(this,arguments)}function $i(){return $i=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(p),r=_slicedToArray(t,6),n=r[0],a=r[1],i=r[2],o=r[3],u=r[4],s=void 0===u?1:u,c=r[5],On(Mi,{type:n,address:a,startDate:i,endDate:o,page:s,limit:f=void 0===c?10:c}),l=window.localStorage.getItem(Sn.Gnosisscan),e.next=6,Ci({type:n,address:a,startDate:i,endDate:o,page:s,offset:f,apiKey:l,functionName:"GNOSIS",chainId:pn.gnosis,network:"gnosis"});case 6:return e.abrupt("return",e.sent);case 9:return e.prev=9,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"GNOSIS"));case 12:case"end":return e.stop()}}),e,null,[[0,9]])}))),$i.apply(this,arguments)}var Qi=ci({contentType:pi(["posts","replies"]),identifier:ii().nonempty(),start:oi().int().nonnegative().default(0),end:oi().int().nonnegative().max(xn,{message:'"end" must be less than or equal to '.concat(xn)}).default(10)});function Ji(){return Ji=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(y),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=void 0===i?0:i,u=r[3],On(Qi,{contentType:n,identifier:a,start:o,end:s=void 0===u?10:u}),c=window.localStorage.getItem(Sn.Firefly),(f=new URL("https://openapi.firefly.land/v1/fileverse/fetch")).searchParams.set("query",a.split(",").map((function(e){return e.trim()})).filter(Boolean).join(",")),l={posts:"lensid",replies:"lenspostid"},f.searchParams.set("type",l[n]),f.searchParams.set("start",String(o)),f.searchParams.set("end",String(s)),p=Ei({url:f.toString(),serviceName:"Firefly",headers:{"x-api-key":c}}),d=p.URL,h=p.HEADERS,e.next=13,fetch(d,{method:"GET",headers:h});case 13:if((v=e.sent).ok){e.next=16;break}throw new An(Sn.Firefly,v.status);case 16:return e.next=18,v.json();case 18:if(m=e.sent,g=m.data,Array.isArray(g)){e.next=22;break}return e.abrupt("return",[]);case 22:return e.abrupt("return",g.map((function(e){for(var t={},r=0,n=Object.entries(e);r<n.length;r++){var a=_slicedToArray(n[r],2),i=a[0],o=a[1];null!=o&&"object"===_typeof(o)||(t[i]=o)}return t.platform="lens",t})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"LENS"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),Ji.apply(this,arguments)}var eo=ci({username:ii().nonempty()}),to=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t,r){var n,a,i,o,u,s,c,f;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=2;break}return e.abrupt("return",null);case 2:return n="https://api.neynar.com/v2/farcaster/user/search/?q=".concat(t,"&limit=5"),a=Ei({url:n,serviceName:"Neynar",headers:{"x-api-key":r,"x-neynar-experimental":"false"}}),i=a.URL,o=a.HEADERS,e.next=6,fetch(i,{method:"GET",headers:o});case 6:return u=e.sent,e.next=9,u.json();case 9:return s=e.sent,c=s.result?s.result.users:[],f=c.find((function(e){return e.username===t})),e.abrupt("return",f&&f.fid||null);case 13:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),ro={fromUsernameToFid:to};function no(){return no=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(d),r=_slicedToArray(t,1),n=r[0],On(eo,{username:n}),a=window.localStorage.getItem(Sn.Neynar),e.next=6,ro.fromUsernameToFid(n,a);case 6:if(i=e.sent){e.next=9;break}throw new En("Invalid username: ".concat(n));case 9:return o="https://api.neynar.com/v2/farcaster/followers?fid=".concat(i),u=Ei({url:o.toString(),serviceName:"Neynar",headers:{"x-api-key":a,"x-neynar-experimental":"false"}}),s=u.URL,c=u.HEADERS,e.next=13,fetch(s,{method:"GET",headers:c});case 13:if((f=e.sent).ok){e.next=16;break}throw new An(Sn.Neynar,f.status);case 16:return e.next=18,f.json();case 18:if(l=e.sent,(p=(null==l?void 0:l.users)||[]).length){e.next=22;break}return e.abrupt("return",[]);case 22:return e.abrupt("return",p.map((function(e){var t,r,n=e.user;return{username:n.username,custody_address:n.custody_address,follower_count:n.follower_count,country:(null===(t=n.profile)||void 0===t||null===(t=t.location)||void 0===t||null===(t=t.address)||void 0===t?void 0:t.country)||"",city:(null===(r=n.profile)||void 0===r||null===(r=r.location)||void 0===r||null===(r=r.address)||void 0===r?void 0:r.city)||""}})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"NEYNAR"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),no.apply(this,arguments)}var ao=ci({address:ii().nonempty(),utility:li("txns"),chain:pi(["ethereum","gnosis"]),limit:oi().int().nonnegative().max(xn,{message:'"limit" must be less than or equal to '.concat(xn)}).default(10),offset:oi().int().nonnegative().default(0)});function io(){return io=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t=T(_),r=_slicedToArray(t,5),n=r[0],a=r[1],i=r[2],o=r[3],u=void 0===o?10:o,s=r[4],On(ao,{address:n,utility:a,chain:i,limit:u,offset:c=void 0===s?0:s}),f=window.localStorage.getItem(Sn.Safe),l=hn[i]){e.next=7;break}throw new En("Invalid chain: ".concat(i));case 7:return e.next=9,Si.validateAndGetAddress(n);case 9:return p=e.sent,d="https://api.safe.global/tx-service/".concat(l,"/api/v2/safes/").concat(p,"/multisig-transactions?limit=").concat(u,"&offset=").concat(c),h=Ei({url:d,serviceName:"Etherscan",headers:{Authorization:"Bearer ".concat(f)}}),v=h.URL,m=h.HEADERS,e.next=14,fetch(v,{headers:m});case 14:if((g=e.sent).ok){e.next=17;break}throw new An(Sn.Safe,g.status);case 17:return e.next=19,g.json();case 19:if(y=e.sent,Array.isArray(y.results)){e.next=22;break}throw new En("Invalid API response");case 22:return e.abrupt("return",y.results.map((function(e){e.confirmations,e.dataDecoded;return _objectWithoutProperties(e,_excluded)})));case 25:return e.prev=25,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"SAFE"));case 28:case"end":return e.stop()}}),e,null,[[0,25]])}))),io.apply(this,arguments)}var oo=ci({graphType:pi(["v3","v3-raw"]),category:pi(["tokens","markets"]),param1:ii().nonempty(),param2:ii().optional()});function uo(){return uo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(f),r=_slicedToArray(t,4),n=r[0],a=r[1],i=r[2],o=r[3],On(oo,{graphType:n,category:a,param1:i,param2:o}),u="".concat("https://onchain-proxy.fileverse.io/third-party")+"?service=uniswap"+"&graphType=".concat(n)+"&category=".concat(a)+"&input1=".concat(encodeURIComponent(i))+(o?"&input2=".concat(encodeURIComponent(o)):""),e.next=7,fetch(u);case 7:if((s=e.sent).ok){e.next=10;break}throw new An("UNISWAP",s.status);case 10:return e.next=12,s.json();case 12:if(c=e.sent,!Array.isArray(c)){e.next=15;break}return e.abrupt("return",c.map((function(e){var t={};return Object.entries(e).forEach((function(e){var r=_slicedToArray(e,2),n=r[0],a=r[1];null!==a&&"object"===_typeof(a)||(t[n]=a)})),t})));case 15:return e.abrupt("return",c);case 18:return e.prev=18,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"UNISWAP"));case 21:case"end":return e.stop()}}),e,null,[[0,18]])}))),uo.apply(this,arguments)}function so(){return so=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(r),e.abrupt("return",new Promise((function(e){e({callSignature:t,responseType:"smart-contract"})})));case 5:return e.prev=5,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"SMARTCONTRACT"));case 8:case"end":return e.stop()}}),e,null,[[0,5]])}))),so.apply(this,arguments)}var co=ci({query:pi(["organization","proposal","proposals"]),slug:ii()});function fo(){return fo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(s),r=_slicedToArray(t,2),n=r[0],a=r[1],On(co,{query:n,slug:a}),i="".concat("https://onchain-proxy.fileverse.io/third-party")+"?service=tally"+"&input1=".concat(encodeURIComponent(n))+"&input2=".concat(encodeURIComponent(a)),e.next=7,fetch(i);case 7:if((o=e.sent).ok){e.next=10;break}throw new An("TALLY",o.status);case 10:return e.next=12,o.json();case 12:return u=e.sent,e.abrupt("return",u);case 16:return e.prev=16,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"TALLY"));case 19:case"end":return e.stop()}}),e,null,[[0,16]])}))),fo.apply(this,arguments)}var lo=ii().regex(/^\s*(\d{1,2})(\s*,\s*\d{1,2}){0,2}\s*$/,"Up to 3 comma-separated hour offsets").refine((function(e){return e.split(",").map((function(e){return+e.trim()})).every((function(e){return e>=1&&e<=24}))}),{message:"Each offset must be between 1 and 24"}),po=ci({type:li("activity"),input1:ii().nonempty(),input2:ii().optional(),input3:oi().int().min(1).max(100).optional()}),ho=ci({type:li("token-holders"),input1:ii().nonempty(),input2:ii().nonempty(),input3:oi().int().min(1).max(500).optional()}),vo=fi("type",[po,ci({type:li("price"),input1:ii().nonempty(),input2:lo.optional(),input3:ii().optional(),input4:oi().int().min(1).max(500).optional()}),ho]);function mo(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var a=t?"".concat(t,"_").concat(n):n;if("object"===_typeof(e[n])&&null!==e[n]){if(Array.isArray(e[n]))continue;mo(e[n],a,r)}else r[a]=e[n]}return r}var go={eth:1,base:8453,polygon:137,arbitrum:42161,optimism:10,gnosis:100,bsc:56,avalanche:43114,fantom:250,scroll:534352,linea:59144,ethereum:1};function yo(e,t){try{if(!t)return e;var r=BigInt(e),n=Math.pow(10,t),a=Number(r)/n;return new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}).format(a)}catch(t){return console.log({error:t}),e}}var _o=null;function bo(e){return ko.apply(this,arguments)}function ko(){return(ko=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,_o){e.next=10;break}return e.next=4,fetch("https://chainid.network/chains_mini.json");case 4:if((r=e.sent).ok){e.next=7;break}throw new Error("Failed to fetch chains.json");case 7:return e.next=9,r.json();case 9:_o=e.sent;case 10:return n=_o.find((function(e){return e.chainId===t})),e.abrupt("return",n?n.name:t);case 14:return e.prev=14,e.t0=e.catch(0),console.log(e.t0),e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,null,[[0,14]])})))).apply(this,arguments)}function wo(){return wo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m,g,y,_,b,k,w,x,S,E,N,A,I,M,C,O,R,j,D,P=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,u=T(P),s=_slicedToArray(u,5),c=s[0],f=s[1],l=s[2],p=s[3],d=s[4],On(vo,{type:c,input1:f,input2:l,input3:p,input4:d}),h="",v=function(e){var t=e.filter((function(e){var t=_slicedToArray(e,2),r=(t[0],t[1]);return void 0!==r&&""!==r})).map((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return"".concat(r,"=").concat(encodeURIComponent(n))}));return t.length?"?".concat(t.join("&")):""},"activity"!==c){e.next=11;break}return e.next=8,Si.validateAndGetAddress(f);case 8:m=e.sent,g=v([["chain_ids",go[l]||l],["limit",p]]),h="activity/".concat(m).concat(g);case 11:return"price"===c&&(y=v([["chain_ids",go[f]||f],["historical_prices",l],["limit",d]]),h="token-info/".concat(p||"native").concat(y)),"token-holders"===c&&(_=v([["limit",p]]),h="token-holders/".concat(go[l]||l,"/").concat(f).concat(_)),b=window.localStorage.getItem(Sn.DuneSim),k="https://api.sim.dune.com/v1/evm/".concat(h),w=Ei({url:k,serviceName:"DuneSim",headers:{"X-Sim-Api-Key":b}}),x=w.URL,S=w.HEADERS,e.next=18,fetch(x,{method:"GET",headers:S});case 18:if((E=e.sent).ok){e.next=26;break}if(400!==E.status){e.next=25;break}return e.next=23,E.json();case 23:throw N=e.sent,new En(N.message);case 25:throw new An(Sn.DuneSim,E.status);case 26:return e.next=28,E.json();case 28:A=e.sent,I="activity"===c?null!==(t=null!==(r=null==A?void 0:A.activity)&&void 0!==r?r:A)&&void 0!==t?t:[]:"token-holders"===c?null!==(n=null!==(a=null==A?void 0:A.holders)&&void 0!==a?a:A)&&void 0!==n?n:[]:"price"===c?null!==(i=null!==(o=null==A?void 0:A.tokens)&&void 0!==o?o:A)&&void 0!==i?i:[]:null!=A?A:[],M=Array.isArray(I)?I:[I],C=[],R=_createForOfIteratorHelper(M),e.prev=33,D=_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,p,d;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(t=j.value)&&t.decimals&&(null!=t&&t.total_supply&&(t.total_supply=yo(null==t?void 0:t.total_supply,t.decimals)),null!=t&&t.fully_diluted_value&&(t.fully_diluted_value=yo(null==t?void 0:t.fully_diluted_value,t.decimals))),null!=t&&t.first_acquired&&(t.first_acquired=new Intl.DateTimeFormat("en-US",{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"}).format(new Date(t.first_acquired))),t.historical_prices&&t.historical_prices.forEach((function(e){var r="price_"+e.offset_hours+"h",n=e.price_usd;t[r]=n})),"price"===c&&(delete t.chain_id,delete t.decimals,delete t.logo),"activity"!==c){e.next=9;break}return e.next=8,bo(t.chain_id);case 8:t.chain_id=e.sent;case 9:if("token-holders"!==c){e.next=30;break}if(!t.balance){e.next=30;break}if(O){e.next=29;break}return e.prev=12,n=go[l]||l,a="https://api.sim.dune.com/v1/evm/token-info/".concat(f,"?chain_ids=").concat(n),i=Ei({url:a,serviceName:"DuneSim",headers:{"X-Sim-Api-Key":b}}),o=i.URL,u=i.HEADERS,e.next=18,fetch(o,{method:"GET",headers:u});case 18:return s=e.sent,e.next=21,s.json();case 21:p=e.sent,d=null===(r=p.tokens[0])||void 0===r?void 0:r.decimals,O=d,e.next=29;break;case 26:e.prev=26,e.t0=e.catch(12),console.log(e.t0);case 29:t.balance=yo(t.balance,O);case 30:C.push(mo(t));case 31:case"end":return e.stop()}}),e,null,[[12,26]])})),R.s();case 36:if((j=R.n()).done){e.next=40;break}return e.delegateYield(D(),"t0",38);case 38:e.next=36;break;case 40:e.next=45;break;case 42:e.prev=42,e.t1=e.catch(33),R.e(e.t1);case 45:return e.prev=45,R.f(),e.finish(45);case 48:return e.abrupt("return",C);case 51:return e.prev=51,e.t2=e.catch(0),e.abrupt("return",Cn(e.t2,"DUNE"));case 54:case"end":return e.stop()}}),e,null,[[0,51],[33,42,45,48]])}))),wo.apply(this,arguments)}var xo=ci({input1:ii().nonempty(),input2:ii().optional(),input3:ii().optional()}).superRefine((function(e,t){var r,n;_i(e.input1)&&(e.input2||t.addIssue({code:Dn.custom,message:"Chain is required to query token price ",path:["input2"]}),(null===(r=e.input2)||void 0===r||null===(r=r.split(","))||void 0===r?void 0:r.length)>1&&t.addIssue({code:Dn.custom,message:"Token address can query only one chain ",path:["input2"]}),(null===(n=e.input1)||void 0===n?void 0:n.split(",").length)>1&&t.addIssue({code:Dn.custom,message:"You can query a single token address at a time.",path:["input1"]}))}));function So(){return So=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=T(m),i=_slicedToArray(a,3),o=i[0],u=i[1],s=i[2],o=null===(t=o)||void 0===t?void 0:t.replace(/\s+/g,""),u=null===(r=u)||void 0===r?void 0:r.replace(/\s+/g,""),s=null===(n=s)||void 0===n?void 0:n.replace(/\s+/g,""),On(xo,{input1:o,input2:u,input3:s}),c=window.useLocal?"http://localhost:3000":"https://onchain-proxy.fileverse.io",f="".concat(c)+"/third-party?service=price",l=!1,_i(o)?(f+="&token=".concat(o,"&chain=").concat(u),s&&(f+="&time=".concat(s))):(f+="&coin=".concat(p=o),u?f+="&time=".concat(u):1===p.split(",").length&&(l=!0)),e.next=12,fetch(f);case 12:if(400!==(d=e.sent).status){e.next=18;break}return e.next=16,d.json();case 16:throw h=e.sent,new En(h.message);case 18:if(d.ok){e.next=20;break}throw new An("PRICE",d.status);case 20:return e.next=22,d.json();case 22:if(v=e.sent,!l){e.next=25;break}return e.abrupt("return",v[0].price);case 25:return e.abrupt("return",v);case 28:return e.prev=28,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"PRICE"));case 31:case"end":return e.stop()}}),e,null,[[0,28]])}))),So.apply(this,arguments)}var Eo=ci({query:pi(["txns","balance"]),addresses:ii().nonempty(),chains:ii(),time:ii().optional()}).superRefine((function(e,t){e.addresses.split(",").length>20&&t.addIssue({code:Dn.custom,message:"Max number of addresses to query is 20",path:["addresses"]})})),No=function(){var e=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,a,i,o,u;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=t.split(","),n=[],a=_createForOfIteratorHelper(r),e.prev=3,a.s();case 5:if((i=a.n()).done){e.next=13;break}return o=i.value,e.next=9,Si.validateAndGetAddress(o);case 9:u=e.sent,n.push(u);case 11:e.next=5;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(3),a.e(e.t0);case 18:return e.prev=18,a.f(),e.finish(18);case 21:return e.abrupt("return",n.join(","));case 22:case"end":return e.stop()}}),e,null,[[3,15,18,21]])})));return function(t){return e.apply(this,arguments)}}();function To(){return To=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o,u,s,c,f,l,p,d,h,v,m=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,a=T(m),i=_slicedToArray(a,4),o=i[0],u=i[1],s=i[2],c=i[3],On(Eo,{addresses:o,chains:u,query:s,time:c}),o=null===(t=o)||void 0===t?void 0:t.replace(/\s+/g,""),u=null===(r=u)||void 0===r?void 0:r.replace(/\s+/g,""),c=null===(n=c)||void 0===n?void 0:n.replace(/\s+/g,""),f="https://onchain-proxy.fileverse.io",e.next=9,No(o);case 9:return l=e.sent,p="".concat(f,"/third-party?service=wallet&addresses=").concat(l,"&chains=").concat(u,"&query=").concat(s),c&&(p+="&time=".concat(c)),e.next=14,fetch(p);case 14:if(400!==(d=e.sent).status){e.next=20;break}return e.next=18,d.json();case 18:throw h=e.sent,new En(h.message);case 20:if(d.ok){e.next=22;break}throw new An("WALLET",d.status);case 22:return e.next=24,d.json();case 24:return v=e.sent,e.abrupt("return",v);case 28:return e.prev=28,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"WALLET"));case 31:case"end":return e.stop()}}),e,null,[[0,28]])}))),To.apply(this,arguments)}var Ao=ci({category:pi(["all","stablecoins"])});function Io(){return Io=_asyncToGenerator(_regeneratorRuntime().mark((function e(){var t,r,n,a,i,o=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,t=T(o),r=_slicedToArray(t,1),n=r[0],On(Ao,{category:n}),e.next=5,Hi("yields");case 5:if(!(a=e.sent).functionName){e.next=9;break}return a.functionName="YIELD",e.abrupt("return",a);case 9:if("all"!==n){e.next=11;break}return e.abrupt("return",a);case 11:return i=a.filter((function(e){return e.stablecoin})),e.abrupt("return",i);case 15:return e.prev=15,e.t0=e.catch(0),e.abrupt("return",Cn(e.t0,"YIELD"));case 18:case"end":return e.stop()}}),e,null,[[0,15]])}))),Io.apply(this,arguments)}function Mo(){return(Mo=_asyncToGenerator(_regeneratorRuntime().mark((function e(){return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){setTimeout((function(){e([{Yoo:"gotcha"}])}),1e4)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Co={errors:f,symbols:ht,date:m};e.AAVE=function(){return vi.apply(this,arguments)},e.ABS=function(e){return(e=V(e))instanceof Error?e:Math.abs(e)},e.ACCRINT=function(e,t,r,a,i,u,s){return e=rn(e),t=rn(t),r=rn(r),L(u=nn(u),s=an(s))?o:tn(e)&&tn(t)&&tn(r)?a<=0||i<=0||r<=e?o:(i=i||0)*a*It(e,r,s=s||0):n},e.ACOS=function(e){if((e=V(e))instanceof Error)return e;var t=Math.acos(e);return isNaN(t)&&(t=o),t},e.ACOSH=function(e){if((e=V(e))instanceof Error)return e;var t=Math.log(e+Math.sqrt(e*e-1));return isNaN(t)&&(t=o),t},e.ACOT=function(e){return(e=V(e))instanceof Error?e:Math.atan(1/e)},e.ACOTH=function(e){if((e=V(e))instanceof Error)return e;var t=.5*Math.log((e+1)/(e-1));return isNaN(t)&&(t=o),t},e.AGGREGATE=function(e,t,r,a){if(F(e=V(e),V(e)))return n;switch(e){case 1:return _e(r);case 2:return Ee(r);case 3:return Ne(r);case 4:return Fe(r);case 5:return qe(r);case 6:return lt(r);case 7:return Qe.S(r);case 8:return Qe.P(r);case 9:return dt(r);case 10:return Je.S(r);case 11:return Je.P(r);case 12:return Ue(r);case 13:return Ge.SNGL(r);case 14:return De(r,a);case 15:return $e(r,a);case 16:return Ye.INC(r,a);case 17:return ze.INC(r,a);case 18:return Ye.EXC(r,a);case 19:return ze.EXC(r,a)}},e.AND=function(){for(var e=C(arguments),t=n,r=0;r<e.length;r++){if(e[r]instanceof Error)return e[r];void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&(t===n&&(t=!0),e[r]||(t=!1))}return t},e.ARABIC=function(e){if(null==e)return 0;if(e instanceof Error)return e;if(!/^M*(?:D?C{0,3}|C[MD])(?:L?X{0,3}|X[CL])(?:V?I{0,3}|I[XV])$/.test(e))return n;var t=0;return e.replace(/[MDLV]|C[MD]?|X[CL]?|I[XV]?/g,(function(e){t+={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1}[e]})),t},e.ARTEMIS=function(){return"Coming Soon"},e.ASIN=function(e){if((e=V(e))instanceof Error)return e;var t=Math.asin(e);return isNaN(t)&&(t=o),t},e.ASINH=function(e){return(e=V(e))instanceof Error?e:Math.log(e+Math.sqrt(e*e+1))},e.ATAN=function(e){return(e=V(e))instanceof Error?e:Math.atan(e)},e.ATAN2=function(e,t){var r=L(e=V(e),t=V(t));return r||Math.atan2(e,t)},e.ATANH=function(e){if((e=V(e))instanceof Error)return e;var t=Math.log((1+e)/(1-e))/2;return isNaN(t)&&(t=o),t},e.AVEDEV=function(){var e=C(arguments).filter(X);if(0===e.length)return o;var t=Y(e);return t instanceof Error?t:oe.sum(oe(t).subtract(oe.mean(t)).abs()[0])/t.length},e.AVERAGE=_e,e.AVERAGEA=be,e.AVERAGEIF=function(e,t,r){if(arguments.length<=1)return u;if(r=Y(C(r=r||e).filter(X)),e=C(e),r instanceof Error)return r;for(var n=0,a=0,i=void 0===t||"*"===t,o=i?null:E(t+""),s=0;s<e.length;s++){var c=e[s];if(i)a+=r[s],n++;else{var f=[x(c,w)].concat(o);N(f)&&(a+=r[s],n++)}}return a/n},e.AVERAGEIFS=function(){var e=z.apply(void 0,arguments),t=e.reduce((function(e,t){return e+t}),0),r=t/e.length;return isNaN(r)?0:r},e.BASE=function(){return Ri.apply(this,arguments)},e.BESSELI=function(e,t){return F(e=V(e),t=V(t))?n:Rt.besseli(e,t)},e.BESSELJ=function(e,t){return F(e=V(e),t=V(t))?n:Rt.besselj(e,t)},e.BESSELK=function(e,t){return F(e=V(e),t=V(t))?n:Rt.besselk(e,t)},e.BESSELY=function(e,t){return F(e=V(e),t=V(t))?n:Rt.bessely(e,t)},e.BETA=ke,e.BETADIST=Kt,e.BETAINV=zt,e.BIN2DEC=function(e){if(!jt(e))return o;var t=parseInt(e,2),r=e.toString();return 10===r.length&&"1"===r.substring(0,1)?parseInt(r.substring(1),2)-512:t},e.BIN2HEX=function(e,t){if(!jt(e))return o;var r=e.toString();if(10===r.length&&"1"===r.substring(0,1))return(0xfffffffe00+parseInt(r.substring(1),2)).toString(16);var a=parseInt(e,2).toString(16);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.BIN2OCT=function(e,t){if(!jt(e))return o;var r=e.toString();if(10===r.length&&"1"===r.substring(0,1))return(1073741312+parseInt(r.substring(1),2)).toString(8);var a=parseInt(e,2).toString(8);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.BINOM=we,e.BINOMDIST=Xt,e.BITAND=function(e,t){return F(e=V(e),t=V(t))?n:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?o:e&t},e.BITLSHIFT=function(e,t){return F(e=V(e),t=V(t))?n:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?o:t>=0?e<<t:e>>-t},e.BITOR=function(e,t){return F(e=V(e),t=V(t))?n:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?o:e|t},e.BITRSHIFT=function(e,t){return F(e=V(e),t=V(t))?n:e<0||Math.floor(e)!==e||e>0xffffffffffff||Math.abs(t)>53?o:t>=0?e>>t:e<<-t},e.BITXOR=function(e,t){return F(e=V(e),t=V(t))?n:e<0||t<0||Math.floor(e)!==e||Math.floor(t)!==t||e>0xffffffffffff||t>0xffffffffffff?o:e^t},e.BLOCKSCOUT=function(){return Di.apply(this,arguments)},e.CEILING=at,e.CEILINGMATH=Wt,e.CEILINGPRECISE=$t,e.CHAR=fe,e.CHIDIST=Qt,e.CHIDISTRT=Jt,e.CHIINV=er,e.CHIINVRT=tr,e.CHISQ=xe,e.CHITEST=rr,e.CHOOSE=function(){if(arguments.length<2)return u;var e=arguments[0];return e<1||e>254||arguments.length<e+1?n:arguments[e]},e.CLEAN=function(e){return F(e)?e:(e=e||"").replace(/[\0-\x1F]/g,"")},e.CODE=le,e.COINGECKO=function(){return Ui.apply(this,arguments)},e.COLUMN=function(e,t){return 2!==arguments.length?u:t<0?o:e instanceof Array&&"number"==typeof t?0!==e.length?oe.col(e,t):void 0:n},e.COLUMNS=function(e){return 1!==arguments.length?u:e instanceof Array?0===e.length?0:oe.cols(e):n},e.COMBIN=it,e.COMBINA=function(e,t){var r=L(e=V(e),t=V(t));return r||(e<t?o:0===e&&0===t?1:it(e+t-1,e-1))},e.COMPLEX=Dt,e.CONCAT=de,e.CONCATENATE=pe,e.CONFIDENCE=Se,e.CONVERT=function(e,t,r){if((e=V(e))instanceof Error)return e;for(var n,a=[["a.u. of action","?",null,"action",!1,!1,105457168181818e-48],["a.u. of charge","e",null,"electric_charge",!1,!1,160217653141414e-33],["a.u. of energy","Eh",null,"energy",!1,!1,435974417757576e-32],["a.u. of length","a?",null,"length",!1,!1,529177210818182e-25],["a.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["a.u. of time","?/Eh",null,"time",!1,!1,241888432650516e-31],["admiralty knot","admkn",null,"speed",!1,!0,.514773333],["ampere","A",null,"electric_current",!0,!1,1],["ampere per meter","A/m",null,"magnetic_field_intensity",!0,!1,1],["ångström","Å",["ang"],"length",!1,!0,1e-10],["are","ar",null,"area",!1,!0,100],["astronomical unit","ua",null,"length",!1,!1,149597870691667e-25],["bar","bar",null,"pressure",!1,!1,1e5],["barn","b",null,"area",!1,!1,1e-28],["becquerel","Bq",null,"radioactivity",!0,!1,1],["bit","bit",["b"],"information",!1,!0,1],["btu","BTU",["btu"],"energy",!1,!0,1055.05585262],["byte","byte",null,"information",!1,!0,8],["candela","cd",null,"luminous_intensity",!0,!1,1],["candela per square metre","cd/m?",null,"luminance",!0,!1,1],["coulomb","C",null,"electric_charge",!0,!1,1],["cubic ångström","ang3",["ang^3"],"volume",!1,!0,1e-30],["cubic foot","ft3",["ft^3"],"volume",!1,!0,.028316846592],["cubic inch","in3",["in^3"],"volume",!1,!0,16387064e-12],["cubic light-year","ly3",["ly^3"],"volume",!1,!0,846786664623715e-61],["cubic metre","m3",["m^3"],"volume",!0,!0,1],["cubic mile","mi3",["mi^3"],"volume",!1,!0,4168181825.44058],["cubic nautical mile","Nmi3",["Nmi^3"],"volume",!1,!0,6352182208],["cubic Pica","Pica3",["Picapt3","Pica^3","Picapt^3"],"volume",!1,!0,7.58660370370369e-8],["cubic yard","yd3",["yd^3"],"volume",!1,!0,.764554857984],["cup","cup",null,"volume",!1,!0,.0002365882365],["dalton","Da",["u"],"mass",!1,!1,166053886282828e-41],["day","d",["day"],"time",!1,!0,86400],["degree","°",null,"angle",!1,!1,.0174532925199433],["degrees Rankine","Rank",null,"temperature",!1,!0,.555555555555556],["dyne","dyn",["dy"],"force",!1,!0,1e-5],["electronvolt","eV",["ev"],"energy",!1,!0,1.60217656514141],["ell","ell",null,"length",!1,!0,1.143],["erg","erg",["e"],"energy",!1,!0,1e-7],["farad","F",null,"electric_capacitance",!0,!1,1],["fluid ounce","oz",null,"volume",!1,!0,295735295625e-16],["foot","ft",null,"length",!1,!0,.3048],["foot-pound","flb",null,"energy",!1,!0,1.3558179483314],["gal","Gal",null,"acceleration",!1,!1,.01],["gallon","gal",null,"volume",!1,!0,.003785411784],["gauss","G",["ga"],"magnetic_flux_density",!1,!0,1],["grain","grain",null,"mass",!1,!0,647989e-10],["gram","g",null,"mass",!1,!0,.001],["gray","Gy",null,"absorbed_dose",!0,!1,1],["gross registered ton","GRT",["regton"],"volume",!1,!0,2.8316846592],["hectare","ha",null,"area",!1,!0,1e4],["henry","H",null,"inductance",!0,!1,1],["hertz","Hz",null,"frequency",!0,!1,1],["horsepower","HP",["h"],"power",!1,!0,745.69987158227],["horsepower-hour","HPh",["hh","hph"],"energy",!1,!0,2684519.538],["hour","h",["hr"],"time",!1,!0,3600],["imperial gallon (U.K.)","uk_gal",null,"volume",!1,!0,.00454609],["imperial hundredweight","lcwt",["uk_cwt","hweight"],"mass",!1,!0,50.802345],["imperial quart (U.K)","uk_qt",null,"volume",!1,!0,.0011365225],["imperial ton","brton",["uk_ton","LTON"],"mass",!1,!0,1016.046909],["inch","in",null,"length",!1,!0,.0254],["international acre","uk_acre",null,"area",!1,!0,4046.8564224],["IT calorie","cal",null,"energy",!1,!0,4.1868],["joule","J",null,"energy",!0,!0,1],["katal","kat",null,"catalytic_activity",!0,!1,1],["kelvin","K",["kel"],"temperature",!0,!0,1],["kilogram","kg",null,"mass",!0,!0,1],["knot","kn",null,"speed",!1,!0,.514444444444444],["light-year","ly",null,"length",!1,!0,9460730472580800],["litre","L",["l","lt"],"volume",!1,!0,.001],["lumen","lm",null,"luminous_flux",!0,!1,1],["lux","lx",null,"illuminance",!0,!1,1],["maxwell","Mx",null,"magnetic_flux",!1,!1,1e-18],["measurement ton","MTON",null,"volume",!1,!0,1.13267386368],["meter per hour","m/h",["m/hr"],"speed",!1,!0,.00027777777777778],["meter per second","m/s",["m/sec"],"speed",!0,!0,1],["meter per second squared","m?s??",null,"acceleration",!0,!1,1],["parsec","pc",["parsec"],"length",!1,!0,0x6da012f958ee1c],["meter squared per second","m?/s",null,"kinematic_viscosity",!0,!1,1],["metre","m",null,"length",!0,!0,1],["miles per hour","mph",null,"speed",!1,!0,.44704],["millimetre of mercury","mmHg",null,"pressure",!1,!1,133.322],["minute","?",null,"angle",!1,!1,.000290888208665722],["minute","min",["mn"],"time",!1,!0,60],["modern teaspoon","tspm",null,"volume",!1,!0,5e-6],["mole","mol",null,"amount_of_substance",!0,!1,1],["morgen","Morgen",null,"area",!1,!0,2500],["n.u. of action","?",null,"action",!1,!1,105457168181818e-48],["n.u. of mass","m?",null,"mass",!1,!1,910938261616162e-45],["n.u. of speed","c?",null,"speed",!1,!1,299792458],["n.u. of time","?/(me?c??)",null,"time",!1,!1,128808866778687e-35],["nautical mile","M",["Nmi"],"length",!1,!0,1852],["newton","N",null,"force",!0,!0,1],["œrsted","Oe ",null,"magnetic_field_intensity",!1,!1,79.5774715459477],["ohm","Ω",null,"electric_resistance",!0,!1,1],["ounce mass","ozm",null,"mass",!1,!0,.028349523125],["pascal","Pa",null,"pressure",!0,!1,1],["pascal second","Pa?s",null,"dynamic_viscosity",!0,!1,1],["pferdestärke","PS",null,"power",!1,!0,735.49875],["phot","ph",null,"illuminance",!1,!1,1e-4],["pica (1/6 inch)","pica",null,"length",!1,!0,.00035277777777778],["pica (1/72 inch)","Pica",["Picapt"],"length",!1,!0,.00423333333333333],["poise","P",null,"dynamic_viscosity",!1,!1,.1],["pond","pond",null,"force",!1,!0,.00980665],["pound force","lbf",null,"force",!1,!0,4.4482216152605],["pound mass","lbm",null,"mass",!1,!0,.45359237],["quart","qt",null,"volume",!1,!0,.000946352946],["radian","rad",null,"angle",!0,!1,1],["second","?",null,"angle",!1,!1,484813681109536e-20],["second","s",["sec"],"time",!0,!0,1],["short hundredweight","cwt",["shweight"],"mass",!1,!0,45.359237],["siemens","S",null,"electrical_conductance",!0,!1,1],["sievert","Sv",null,"equivalent_dose",!0,!1,1],["slug","sg",null,"mass",!1,!0,14.59390294],["square ångström","ang2",["ang^2"],"area",!1,!0,1e-20],["square foot","ft2",["ft^2"],"area",!1,!0,.09290304],["square inch","in2",["in^2"],"area",!1,!0,64516e-8],["square light-year","ly2",["ly^2"],"area",!1,!0,895054210748189e17],["square meter","m?",null,"area",!0,!0,1],["square mile","mi2",["mi^2"],"area",!1,!0,2589988.110336],["square nautical mile","Nmi2",["Nmi^2"],"area",!1,!0,3429904],["square Pica","Pica2",["Picapt2","Pica^2","Picapt^2"],"area",!1,!0,1792111111111e-17],["square yard","yd2",["yd^2"],"area",!1,!0,.83612736],["statute mile","mi",null,"length",!1,!0,1609.344],["steradian","sr",null,"solid_angle",!0,!1,1],["stilb","sb",null,"luminance",!1,!1,1e-4],["stokes","St",null,"kinematic_viscosity",!1,!1,1e-4],["stone","stone",null,"mass",!1,!0,6.35029318],["tablespoon","tbs",null,"volume",!1,!0,147868e-10],["teaspoon","tsp",null,"volume",!1,!0,492892e-11],["tesla","T",null,"magnetic_flux_density",!0,!0,1],["thermodynamic calorie","c",null,"energy",!1,!0,4.184],["ton","ton",null,"mass",!1,!0,907.18474],["tonne","t",null,"mass",!1,!1,1e3],["U.K. pint","uk_pt",null,"volume",!1,!0,.00056826125],["U.S. bushel","bushel",null,"volume",!1,!0,.03523907],["U.S. oil barrel","barrel",null,"volume",!1,!0,.158987295],["U.S. pint","pt",["us_pt"],"volume",!1,!0,.000473176473],["U.S. survey mile","survey_mi",null,"length",!1,!0,1609.347219],["U.S. survey/statute acre","us_acre",null,"area",!1,!0,4046.87261],["volt","V",null,"voltage",!0,!1,1],["watt","W",null,"power",!0,!0,1],["watt-hour","Wh",["wh"],"energy",!1,!0,3600],["weber","Wb",null,"magnetic_flux",!0,!1,1],["yard","yd",null,"length",!1,!0,.9144],["year","yr",null,"time",!1,!0,31557600]],i={Yi:["yobi",80,12089258196146292e8,"Yi","yotta"],Zi:["zebi",70,11805916207174113e5,"Zi","zetta"],Ei:["exbi",60,0x1000000000000000,"Ei","exa"],Pi:["pebi",50,0x4000000000000,"Pi","peta"],Ti:["tebi",40,1099511627776,"Ti","tera"],Gi:["gibi",30,1073741824,"Gi","giga"],Mi:["mebi",20,1048576,"Mi","mega"],ki:["kibi",10,1024,"ki","kilo"]},o={Y:["yotta",1e24,"Y"],Z:["zetta",1e21,"Z"],E:["exa",1e18,"E"],P:["peta",1e15,"P"],T:["tera",1e12,"T"],G:["giga",1e9,"G"],M:["mega",1e6,"M"],k:["kilo",1e3,"k"],h:["hecto",100,"h"],e:["dekao",10,"e"],d:["deci",.1,"d"],c:["centi",.01,"c"],m:["milli",.001,"m"],u:["micro",1e-6,"u"],n:["nano",1e-9,"n"],p:["pico",1e-12,"p"],f:["femto",1e-15,"f"],a:["atto",1e-18,"a"],z:["zepto",1e-21,"z"],y:["yocto",1e-24,"y"]},s=null,c=null,f=t,l=r,p=1,d=1,h=0;h<a.length;h++)n=null===a[h][2]?[]:a[h][2],(a[h][1]===f||n.indexOf(f)>=0)&&(s=a[h]),(a[h][1]===l||n.indexOf(l)>=0)&&(c=a[h]);if(null===s){var v=i[t.substring(0,2)],m=o[t.substring(0,1)];"da"===t.substring(0,2)&&(m=["dekao",10,"da"]),v?(p=v[2],f=t.substring(2)):m&&(p=m[1],f=t.substring(m[2].length));for(var g=0;g<a.length;g++)n=null===a[g][2]?[]:a[g][2],(a[g][1]===f||n.indexOf(f)>=0)&&(s=a[g])}if(null===c){var y=i[r.substring(0,2)],_=o[r.substring(0,1)];"da"===r.substring(0,2)&&(_=["dekao",10,"da"]),y?(d=y[2],l=r.substring(2)):_&&(d=_[1],l=r.substring(_[2].length));for(var b=0;b<a.length;b++)n=null===a[b][2]?[]:a[b][2],(a[b][1]===l||n.indexOf(l)>=0)&&(c=a[b])}return null===s||null===c||s[3]!==c[3]?u:e*s[6]*p/(c[6]*d)},e.CORREL=function(e,t){return F(e=Y(C(e)),t=Y(C(t)))?n:oe.corrcoeff(e,t)},e.COS=function(e){return(e=V(e))instanceof Error?e:Math.cos(e)},e.COSH=function(e){return(e=V(e))instanceof Error?e:(Math.exp(e)+Math.exp(-e))/2},e.COT=function(e){return(e=V(e))instanceof Error?e:0===e?r:1/Math.tan(e)},e.COTH=function(e){if((e=V(e))instanceof Error)return e;if(0===e)return r;var t=Math.exp(2*e);return(t+1)/(t-1)},e.COUNT=Ee,e.COUNTA=Ne,e.COUNTBLANK=Te,e.COUNTIF=function(e,t){if(e=C(e),void 0===t||"*"===t)return e.length;for(var r=0,n=E(t+""),a=0;a<e.length;a++){var i=[x(e[a],w)].concat(n);N(i)&&r++}return r},e.COUNTIFS=function(){for(var e=T(arguments),t=new Array(C(e[0]).length),r=0;r<t.length;r++)t[r]=!0;for(var n=0;n<e.length;n+=2){var a=C(e[n]),i=e[n+1];if(!(void 0===i||"*"===i))for(var o=E(i+""),u=0;u<a.length;u++){var s=[x(a[u],w)].concat(o);t[u]=t[u]&&N(s)}}for(var c=0,f=0;f<t.length;f++)t[f]&&c++;return c},e.COUPDAYS=function(e,t,r,a){if(a=an(a),r=nn(r),L(e=H(e),t=H(t)))return n;if(L(r,a)||e>=t)return o;if(1===a){var i=function(e,t,r){var n=H(t);for(n.setFullYear(e.getFullYear()),n<e&&n.setFullYear(n.getFullYear()+1);n>e;)n.setMonth(n.getMonth()+-12/r);return n}(e,t,r),u=H(i);return u.setMonth(u.getMonth()+12/r),yt(i,u,"D")}var s;switch(a){case 0:case 2:case 4:s=360;break;case 3:s=365;break;default:return o}return s/r},e.COVAR=nr,e.COVARIANCE=Ae,e.COVARIANCEP=ar,e.COVARIANCES=ir,e.CRITBINOM=or,e.CSC=function(e){return(e=V(e))instanceof Error?e:0===e?r:1/Math.sin(e)},e.CSCH=function(e){return(e=V(e))instanceof Error?e:0===e?r:2/(Math.exp(e)-Math.exp(-e))},e.CUMIPMT=function(e,t,r,a,i,u){if(F(e=V(e),t=V(t),r=V(r)))return n;if(e<=0||t<=0||r<=0)return o;if(a<1||i<1||a>i)return o;if(0!==u&&1!==u)return o;var s=cn(e,t,r,0,u),c=0;1===a&&(0===u&&(c=-r),a++);for(var f=a;f<=i;f++)c+=1===u?on(e,f-2,s,r,1)-s:on(e,f-1,s,r,0);return c*=e},e.CUMPRINC=function(e,t,r,a,i,u){if(F(e=V(e),t=V(t),r=V(r)))return n;if(e<=0||t<=0||r<=0)return o;if(a<1||i<1||a>i)return o;if(0!==u&&1!==u)return o;var s=cn(e,t,r,0,u),c=0;1===a&&(c=0===u?s+r*e:s,a++);for(var f=a;f<=i;f++)c+=u>0?s-(on(e,f-2,s,r,1)-s)*e:s-on(e,f-1,s,r,0)*e;return c},e.DATE=function(e,t,r){var a;return F(e=V(e),t=V(t),r=V(r))?a=n:(a=new Date(e,t-1,r)).getFullYear()<0&&(a=o),l?h(a):a},e.DATEDIF=yt,e.DATEVALUE=function(e){if("string"!=typeof e)return n;var t=Date.parse(e);if(isNaN(t))return n;var r=new Date(e);return l?h(r):r},e.DAVERAGE=function(e,t,a){if(isNaN(t)&&"string"!=typeof t)return n;var i=en(e,a),o=[];if("string"==typeof t){var u=P(e,t);o=j(e[u])}else o=j(e[t]);var s=0;return A(i,(function(e){s+=o[e]})),0===i.length?r:s/i.length},e.DAY=function(e){var t=H(e);return t instanceof Error?t:t.getDate()},e.DAYS=bt,e.DAYS360=kt,e.DB=function(e,t,r,a,i){if(i=void 0===i?12:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;if(e<0||t<0||r<0||a<0)return o;if(-1===[1,2,3,4,5,6,7,8,9,10,11,12].indexOf(i))return o;if(a>r)return o;if(t>=e)return 0;for(var u=(1-Math.pow(t/e,1/r)).toFixed(3),s=e*u*i/12,c=s,f=0,l=a===r?r-1:a,p=2;p<=l;p++)c+=f=(e-c)*u;return 1===a?s:a===r?(e-c)*u:f},e.DCOUNT=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),Ee(u)},e.DCOUNTA=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),Ne(u)},e.DDB=function(e,t,r,a,i){if(i=void 0===i?2:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;if(e<0||t<0||r<0||a<0||i<=0)return o;if(a>r)return o;if(t>=e)return 0;for(var u=0,s=0,c=1;c<=a;c++)u+=s=Math.min(i/r*(e-u),e-t-u);return s},e.DEC2BIN=function(e,t){if((e=V(e))instanceof Error)return e;if(!/^-?[0-9]{1,3}$/.test(e)||e<-512||e>511)return o;if(e<0)return"1"+ve("0",9-(512+e).toString(2).length)+(512+e).toString(2);var r=parseInt(e,10).toString(2);return void 0===t?r:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=r.length?ve("0",t-r.length)+r:o},e.DEC2HEX=function(e,t){if((e=V(e))instanceof Error)return e;if(!/^-?[0-9]{1,12}$/.test(e)||e<-549755813888||e>549755813887)return o;if(e<0)return(1099511627776+e).toString(16);var r=parseInt(e,10).toString(16);return void 0===t?r:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=r.length?ve("0",t-r.length)+r:o},e.DEC2OCT=function(e,t){if((e=V(e))instanceof Error)return e;if(!/^-?[0-9]{1,9}$/.test(e)||e<-536870912||e>536870911)return o;if(e<0)return(1073741824+e).toString(8);var r=parseInt(e,10).toString(8);return void 0===t?r:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=r.length?ve("0",t-r.length)+r:o},e.DECIMAL=function(e,t){if(arguments.length<2)return u;var r=L(e=e||"0",t=V(t));if(r)return r;if(0===t)return o;var n=parseInt(e,t);return isNaN(n)?o:n},e.DEFILLAMA=Hi,e.DEGREES=function(e){return(e=V(e))instanceof Error?e:180*e/Math.PI},e.DELTA=function(e,t){return t=void 0===t?0:t,F(e=V(e),t=V(t))?n:e===t?1:0},e.DEVSQ=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=0,n=0;n<e.length;n++)r+=Math.pow(e[n]-t,2);return r},e.DGET=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];return i=j("string"==typeof t?e[P(e,t)]:e[t]),0===a.length?n:a.length>1?o:i[a[0]]},e.DISC=function(e,t,r,a,i){if(F(e=H(e),t=H(t),r=V(r),a=V(a),i=(i=V(i))||0))return n;if(r<=0||a<=0)return o;if(e>=t)return n;var u,s;switch(i){case 0:u=360,s=kt(e,t,!1);break;case 1:case 3:u=365,s=yt(e,t,"D");break;case 2:u=360,s=yt(e,t,"D");break;case 4:u=360,s=kt(e,t,!0);break;default:return o}return(a-r)/a*u/s},e.DMAX=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=i[a[0]];return A(a,(function(e){u<i[e]&&(u=i[e])})),u},e.DMIN=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=i[a[0]];return A(a,(function(e){u>i[e]&&(u=i[e])})),u},e.DOLLAR=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(e=V(e),isNaN(e))return n;var r={style:"currency",currency:"USD",minimumFractionDigits:t>=0?t:0,maximumFractionDigits:t>=0?t:0},a=(e=pt(e,t)).toLocaleString("en-US",r);return e<0?"$("+a.slice(2)+")":a},e.DOLLARDE=function(e,t){if(F(e=V(e),t=V(t)))return n;if(t<0)return o;if(t>=0&&t<1)return r;t=parseInt(t,10);var a=parseInt(e,10);a+=e%1*Math.pow(10,Math.ceil(Math.log(t)/Math.LN10))/t;var i=Math.pow(10,Math.ceil(Math.log(t)/Math.LN2)+1);return a=Math.round(a*i)/i},e.DOLLARFR=function(e,t){if(F(e=V(e),t=V(t)))return n;if(t<0)return o;if(t>=0&&t<1)return r;t=parseInt(t,10);var a=parseInt(e,10);return a+=e%1*Math.pow(10,-Math.ceil(Math.log(t)/Math.LN10))*t},e.DPRODUCT=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];A(a,(function(e){u.push(i[e])})),u=Jr(u);var s=1;return A(u,(function(e){s*=e})),s},e.DSTDEV=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),u=Jr(u),Qe.S(u)},e.DSTDEVP=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),u=Jr(u),Qe.P(u)},e.DSUM=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),dt(u)},e.DUNE=function(){return wo.apply(this,arguments)},e.DVAR=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),Je.S(u)},e.DVARP=function(e,t,r){if(isNaN(t)&&"string"!=typeof t)return n;var a=en(e,r),i=[];if("string"==typeof t){var o=P(e,t);i=j(e[o])}else i=j(e[t]);var u=[];return A(a,(function(e){u.push(i[e])})),Je.P(u)},e.EDATE=function(e,t){if((e=H(e))instanceof Error)return e;if(isNaN(t))return n;var r=e.getDate();e.setDate(1),t=parseInt(t,10),e.setMonth(e.getMonth()+t);var a=e.getMonth();if(r>28){var i=[31,28,31,30,31,30,31,31,30,31,30,31][a],o=e.getFullYear();1===a&&(o%4==0&&o%100!=0||o%400==0)&&(i=29),r=Math.min(r,i)}return e.setDate(r),l?h(e):e},e.EFFECT=function(e,t){return F(e=V(e),t=V(t))?n:e<=0||t<1?o:(t=parseInt(t,10),Math.pow(1+e/t,t)-1)},e.EOA=function(){return Ii.apply(this,arguments)},e.EOMONTH=function(e,t){if((e=H(e))instanceof Error)return e;if(isNaN(t))return n;t=parseInt(t,10);var r=new Date(e.getFullYear(),e.getMonth()+t+1,0);return l?h(r):r},e.ERF=Pt,e.ERFC=Lt,e.ERFCPRECISE=ur,e.ERFPRECISE=sr,e.ERROR=W,e.ETHERSCAN=function(){return Yi.apply(this,arguments)},e.EVEN=function(e){return(e=V(e))instanceof Error?e:at.MATH(e,-2,-1)},e.EXACT=function(e,t){if(2!==arguments.length)return u;var r=L(e,t);return r||(e=B(e))===(t=B(t))},e.EXP=function(e){return arguments.length<1?u:arguments.length>1?s:(e=V(e))instanceof Error?e:e=Math.exp(e)},e.EXPON=Ie,e.EXPONDIST=cr,e.F=Me,e.FACT=ut,e.FACTDOUBLE=function e(t){if((t=V(t))instanceof Error)return t;var r=Math.floor(t);return r<=0?1:r*e(r-2)},e.FALSE=function(){return!1},e.FARCASTER=function(){return Ki.apply(this,arguments)},e.FDIST=fr,e.FDISTRT=lr,e.FIND=function(e,t,r){if(arguments.length<2)return u;e=B(e),r=void 0===r?0:r;var a=(t=B(t)).indexOf(e,r-1);return-1===a?n:a+1},e.FINV=pr,e.FINVRT=dr,e.FIREFLY=function(){return Wi.apply(this,arguments)},e.FISHER=function(e){return(e=V(e))instanceof Error?e:Math.log((1+e)/(1-e))/2},e.FISHERINV=function(e){if((e=V(e))instanceof Error)return e;var t=Math.exp(2*e);return(t-1)/(t+1)},e.FIXED=he,e.FLOOR=st,e.FLOORMATH=hr,e.FLOORPRECISE=vr,e.FLVURL=function(){return Mo.apply(this,arguments)},e.FORECAST=Ce,e.FREQUENCY=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=e.length,a=t.length,i=[],o=0;o<=a;o++){i[o]=0;for(var u=0;u<r;u++)0===o?e[u]<=t[0]&&(i[0]+=1):o<a?e[u]>t[o-1]&&e[u]<=t[o]&&(i[o]+=1):o===a&&e[u]>t[a-1]&&(i[a]+=1)}return i},e.FTEST=mr,e.FV=on,e.FVSCHEDULE=function(e,t){if(F(e=V(e),t=Y(C(t))))return n;for(var r=t.length,a=e,i=0;i<r;i++)a*=1+t[i];return a},e.GAMMA=Oe,e.GAMMADIST=gr,e.GAMMAINV=yr,e.GAMMALN=Re,e.GAMMALNPRECISE=_r,e.GAUSS=function(e){return(e=V(e))instanceof Error?e:oe.normal.cdf(e,0,1)-.5},e.GCD=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=e.length,r=e[0],n=r<0?-r:r,a=1;a<t;a++){for(var i=e[a],o=i<0?-i:i;n&&o;)n>o?n%=o:o%=n;n+=o}return n},e.GEOMEAN=function(){var e=Y(C(arguments));return e instanceof Error?e:oe.geomean(e)},e.GESTEP=function(e,t){return F(t=t||0,e=V(e))?e:e>=t?1:0},e.GNOSIS=function(){return $i.apply(this,arguments)},e.GROWTH=function(e,t,r,a){if((e=Y(C(e)))instanceof Error)return e;var i;if(void 0===t)for(t=[],i=1;i<=e.length;i++)t.push(i);if(void 0===r&&(r=t),F(t=Y(C(t)),r=Y(C(r))))return n;void 0===a&&(a=!0);var o,u,s=e.length,c=0,f=0,l=0,p=0;for(i=0;i<s;i++){var d=t[i],h=Math.log(e[i]);c+=d,f+=h,l+=d*h,p+=d*d}c/=s,f/=s,l/=s,p/=s,a?u=f-(o=(l-c*f)/(p-c*c))*c:(o=l/p,u=0);var v=[];for(i=0;i<r.length;i++)v.push(Math.exp(u+o*r[i]));return v},e.HARMEAN=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=e.length,r=0,n=0;n<t;n++)r+=1/e[n];return t/r},e.HEX2BIN=function(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return o;var r=!(10!==e.length||"f"!==e.substring(0,1).toLowerCase()),a=r?parseInt(e,16)-1099511627776:parseInt(e,16);if(a<-512||a>511)return o;if(r)return"1"+ve("0",9-(512+a).toString(2).length)+(512+a).toString(2);var i=a.toString(2);return void 0===t?i:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=i.length?ve("0",t-i.length)+i:o},e.HEX2DEC=function(e){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return o;var t=parseInt(e,16);return t>=549755813888?t-1099511627776:t},e.HEX2OCT=function(e,t){if(!/^[0-9A-Fa-f]{1,10}$/.test(e))return o;var r=parseInt(e,16);if(r>536870911&&r<0xffe0000000)return o;if(r>=0xffe0000000)return(r-0xffc0000000).toString(8);var a=r.toString(8);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.HLOOKUP=function(e,t,r,n){return se(e,D(t),r,n)},e.HOUR=function(e){return(e=H(e))instanceof Error?e:e.getHours()},e.HYPGEOM=je,e.HYPGEOMDIST=br,e.IF=function(e,t,r){return e instanceof Error?e:(null==(t=!(arguments.length>=2)||t)&&(t=0),null==(r=3===arguments.length&&r)&&(r=0),e?t:r)},e.IFERROR=function(e,t){return Q(e)?t:e},e.IFNA=function(e,t){return e===u?t:e},e.IFS=function(){for(var e=0;e<arguments.length/2;e++)if(arguments[2*e])return arguments[2*e+1];return u},e.IMABS=Ft,e.IMAGINARY=Ut,e.IMARGUMENT=qt,e.IMCONJUGATE=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",0!==r?Dt(t,-r,a):e},e.IMCOS=Gt,e.IMCOSH=Ht,e.IMCOT=function(e){return F(Vt(e),Ut(e))?n:Zt(Gt(e),Yt(e))},e.IMCSC=function(e){return!0===e||!1===e?n:F(Vt(e),Ut(e))?o:Zt("1",Yt(e))},e.IMCSCH=function(e){return!0===e||!1===e?n:F(Vt(e),Ut(e))?o:Zt("1",Bt(e))},e.IMDIV=Zt,e.IMEXP=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);a="i"===a||"j"===a?a:"i";var i=Math.exp(t);return Dt(i*Math.cos(r),i*Math.sin(r),a)},e.IMLN=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.log(Math.sqrt(t*t+r*r)),Math.atan(r/t),a)},e.IMLOG10=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.log(Math.sqrt(t*t+r*r))/Math.log(10),Math.atan(r/t)/Math.log(10),a)},e.IMLOG2=function(e){var t=Vt(e),r=Ut(e);if(F(t,r))return n;var a=e.substring(e.length-1);return a="i"===a||"j"===a?a:"i",Dt(Math.log(Math.sqrt(t*t+r*r))/Math.log(2),Math.atan(r/t)/Math.log(2),a)},e.IMPOWER=function(e,t){if(F(t=V(t),Vt(e),Ut(e)))return n;var r=e.substring(e.length-1);r="i"===r||"j"===r?r:"i";var a=Math.pow(Ft(e),t),i=qt(e);return Dt(a*Math.cos(t*i),a*Math.sin(t*i),r)},e.IMPRODUCT=function(){var e=arguments[0];if(!arguments.length)return n;for(var t=1;t<arguments.length;t++){var r=Vt(e),a=Ut(e),i=Vt(arguments[t]),o=Ut(arguments[t]);if(F(r,a,i,o))return n;e=Dt(r*i-a*o,r*o+a*i)}return e},e.IMREAL=Vt,e.IMSEC=function(e){return!0===e||!1===e||F(Vt(e),Ut(e))?n:Zt("1",Gt(e))},e.IMSECH=function(e){return F(Vt(e),Ut(e))?n:Zt("1",Ht(e))},e.IMSIN=Yt,e.IMSINH=Bt,e.IMSQRT=function(e){if(F(Vt(e),Ut(e)))return n;var t=e.substring(e.length-1);t="i"===t||"j"===t?t:"i";var r=Math.sqrt(Ft(e)),a=qt(e);return Dt(r*Math.cos(a/2),r*Math.sin(a/2),t)},e.IMSUB=function(e,t){var r=Vt(e),a=Ut(e),i=Vt(t),o=Ut(t);if(F(r,a,i,o))return n;var u=e.substring(e.length-1),s=t.substring(t.length-1),c="i";return("j"===u||"j"===s)&&(c="j"),Dt(r-i,a-o,c)},e.IMSUM=function(){if(!arguments.length)return n;for(var e=C(arguments),t=e[0],r=1;r<e.length;r++){var a=Vt(t),i=Ut(t),o=Vt(e[r]),u=Ut(e[r]);if(F(a,i,o,u))return n;t=Dt(a+o,i+u)}return t},e.IMTAN=function(e){return!0===e||!1===e||F(Vt(e),Ut(e))?n:Zt(Yt(e),Gt(e))},e.INDEX=function(e,t,r){var i=L(e,t,r);if(i)return i;if(!Array.isArray(e))return n;var o=e.length>0&&!Array.isArray(e[0]);return o&&!r?(r=t,t=1):(r=r||1,t=t||1),r<0||t<0?n:o&&1===t&&r<=e.length?e[r-1]:t<=e.length&&r<=e[t-1].length?e[t-1][r-1]:a},e.INT=function(e){return(e=V(e))instanceof Error?e:Math.floor(e)},e.INTERCEPT=function(e,t){return F(e=Y(e),t=Y(t))?n:e.length!==t.length?u:Ce(0,e,t)},e.IPMT=un,e.IRR=function(e,t){if(t="number"==typeof t?t:void 0===t?.1:V(t),F(e=Y(C(e)),t))return n;for(var r=new Float64Array(e.length),a=!1,i=!1,u=0;u<e.length;u++)r[u]=e[u],r[u]>0&&(a=!0),r[u]<0&&(i=!0);if(!a||!i)return o;var s=new Map,c=function(e){var t=Math.round(1e10*e)/1e10;if(s.has(t))return s.get(t);var n=function(e){e<=-1&&(e=-.999999999);for(var t=r[0],n=1+e,a=1,i=1;i<r.length;i++)a*=n,t+=r[i]/a;return t}(t);return s.set(t,n),n};return function(){for(var e=1e-10,r=t,n=r,a=0;a<1e3;){var i=c(r);if(Math.abs(i)<e)return r;if(a>0&&Math.abs(r-n)<1e-9)break;var o=Math.max(1e-4,Math.abs(1e-4*r)),u=(c(r+o)-i)/o;if(Math.abs(u)<e)break;n=r;var s=i/u,f=Math.max(.1,.5*Math.abs(r));Math.abs(s)>f?r-=Math.sign(s)*f:r-=s,r<=-1&&(r=-.99999999),r>1e3&&(r=1e3),a++}var l,p,d,h=c(r);if(Math.abs(h)<e)return r;if(h>0){for(l=r,p=r+.1;c(p)>0&&p<1e3;)p=2*p+.1;if(p>=1e3)return r}else{for(p=r,l=Math.max(-.99999999,r-.1);c(l)<0&&l>-.99999999;)l=Math.max(-.99999999,l-.1);if(l<=-.99999999)return r}for(var v=0;v<1e3;v++){var m=c(d=(l+p)/2);if(Math.abs(m)<e||Math.abs(p-l)<e)return d;m*c(l)<0?p=d:l=d}return d}()},e.ISBLANK=function(e){return null===e},e.ISDATE=function(e){return!(H(e)instanceof Error)},e.ISERR=$,e.ISERROR=Q,e.ISEVEN=function(e){return!(1&Math.floor(Math.abs(e)))},e.ISLOGICAL=J,e.ISNA=function(e){return e===u},e.ISNONTEXT=function(e){return"string"!=typeof e},e.ISNUMBER=ee,e.ISO=ct,e.ISODD=function(e){return!!(1&Math.floor(Math.abs(e)))},e.ISOWEEKNUM=wt,e.ISPMT=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r),a=V(a))?n:a*e*(t/r-1)},e.ISTEXT=te,e.KURT=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=oe.mean(e),r=e.length,n=0,a=0;a<r;a++)n+=Math.pow(e[a]-t,4);return r*(r+1)/((r-1)*(r-2)*(r-3))*(n/=Math.pow(oe.stdev(e,!0),4))-3*(r-1)*(r-1)/((r-2)*(r-3))},e.LARGE=De,e.LCM=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t,r,n,a,i=1;void 0!==(n=e.pop());){if(0===n)return 0;for(;n>1;){if(n%2){for(t=3,r=Math.floor(Math.sqrt(n));t<=r&&n%t;t+=2);a=t<=r?t:n}else a=2;for(n/=a,i*=a,t=e.length;t;e[--t]%a==0&&1==(e[t]/=a)&&e.splice(t,1));}}return i},e.LEFT=function(e,t){var r=L(e,t);return r||(e=B(e),(t=V(t=void 0===t?1:t))instanceof Error||"string"!=typeof e?n:e.substring(0,t))},e.LEN=function(e){return 0===arguments.length?s:e instanceof Error?e:Array.isArray(e)?n:B(e).length},e.LENS=function(){return Ji.apply(this,arguments)},e.LINEST=Pe,e.LN=function(e){return(e=V(e))instanceof Error?e:0===e?o:Math.log(e)},e.LOG=function(e,t){var r=L(e=V(e),t=t?V(t):10);return r||(0===e||0===t?o:Math.log(e)/Math.log(t))},e.LOG10=function(e){return(e=V(e))instanceof Error?e:0===e?o:Math.log(e)/Math.log(10)},e.LOGEST=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;if(e.length!==t.length)return n;for(var r=0;r<e.length;r++)e[r]=Math.log(e[r]);var a=Pe(e,t);return a[0]=Math.round(1e6*Math.exp(a[0]))/1e6,a[1]=Math.round(1e6*Math.exp(a[1]))/1e6,a},e.LOGINV=kr,e.LOGNORM=Le,e.LOGNORMDIST=wr,e.LOGNORMINV=xr,e.LOOKUP=function(e,t,r){t=C(t),r=r?C(r):t;for(var n="number"==typeof e,a=u,i=0;i<t.length;i++){if(t[i]===e)return r[i];if(n&&t[i]<=e||"string"==typeof t[i]&&t[i].localeCompare(e)<0)a=r[i];else if(n&&t[i]>e)return a}return a},e.LOWER=function(e){return 1!==arguments.length?n:F(e=B(e))?e:e.toLowerCase()},e.MATCH=function(e,t,r){if(!e&&0!==e||!t)return u;if(2===arguments.length&&(r=1),!((t=C(t))instanceof Array))return u;if(-1!==r&&0!==r&&1!==r)return u;for(var n,a,i=0;i<t.length;i++)if(1===r){if(t[i]===e)return i+1;t[i]<e&&(a?t[i]>a&&(n=i+1,a=t[i]):(n=i+1,a=t[i]))}else if(0===r){if("string"==typeof e&&"string"==typeof t[i]){var o=e.toLowerCase().replace(/\?/g,".").replace(/\*/g,".*").replace(/~/g,"\\").replace(/\+/g,"\\+").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/\[/g,"\\[").replace(/\]/g,"\\]");if(new RegExp("^"+o+"$").test(t[i].toLowerCase()))return i+1}else if(t[i]===e)return i+1}else if(-1===r){if(t[i]===e)return i+1;t[i]>e&&(a?t[i]<a&&(n=i+1,a=t[i]):(n=i+1,a=t[i]))}return n||u},e.MAX=Fe,e.MAXA=function(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=I(e);return r=r.map((function(e){return null==e?0:e})),0===r.length?0:Math.max.apply(Math,r)},e.MAXIFS=function(){var e=z.apply(void 0,arguments);return 0===e.length?0:Math.max.apply(Math,e)},e.MEDIAN=Ue,e.MEERKAT=function(){return"Coming Soon"},e.MID=function(e,t,r){if(null==t)return n;if(F(t=V(t),r=V(r))||"string"!=typeof e)return r;var a=t-1,i=a+r;return e.substring(a,i)},e.MIN=qe,e.MINA=function(){var e=C(arguments),t=L.apply(void 0,e);if(t)return t;var r=I(e);return r=r.map((function(e){return null==e?0:e})),0===r.length?0:Math.min.apply(Math,r)},e.MINIFS=function(){var e=z.apply(void 0,arguments);return 0===e.length?0:Math.min.apply(Math,e)},e.MINUS=function(){var e=T(arguments);if(2!==e.length)return n;var t=e[0],r=e[1];return t instanceof Error||r instanceof Error?t instanceof Error?t:r:"number"!=typeof t||"number"!=typeof r?n:t-r},e.MINUTE=function(e){return(e=H(e))instanceof Error?e:e.getMinutes()},e.MIRR=function(e,t,r){if(F(e=Y(C(e)),t=V(t),r=V(r)))return n;for(var a=e.length,i=[],o=[],u=0;u<a;u++)e[u]<0?i.push(e[u]):o.push(e[u]);var s=-sn(r,o)*Math.pow(1+r,a-1),c=sn(t,i)*(1+t);return Math.pow(s/c,1/(a-1))-1},e.MMULT=function(e,t){return!Array.isArray(e)||!Array.isArray(t)||e.some((function(e){return!e.length}))||t.some((function(e){return!e.length}))||O(e).some((function(e){return"number"!=typeof e}))||O(t).some((function(e){return"number"!=typeof e}))||e[0].length!==t.length?n:Array(e.length).fill(0).map((function(){return Array(t[0].length).fill(0)})).map((function(r,n){return r.map((function(r,a){return e[n].reduce((function(e,r,n){return e+r*t[n][a]}),0)}))}))},e.MOD=function(e,t){var n=L(e=V(e),t=V(t));if(n)return n;if(0===t)return r;var a=Math.abs(e%t);return a=e<0?t-a:a,t>0?a:-a},e.MODE=Ge,e.MODEMULT=Sr,e.MODESNGL=Er,e.MONTH=function(e){return(e=H(e))instanceof Error?e:e.getMonth()+1},e.MROUND=function(e,t){var r=L(e=V(e),t=V(t));return r||(e*t==0?0:e*t<0?o:Math.round(e/t)*t)},e.MULTINOMIAL=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=0,r=1,n=0;n<e.length;n++)t+=e[n],r*=ut(e[n]);return ut(t)/r},e.MUNIT=function(e){return arguments.length>1?u:!(e=parseInt(e))||e<=0?n:Array(e).fill(0).map((function(){return Array(e).fill(0)})).map((function(e,t){return e[t]=1,e}))},e.MYANIMELIST=function(){return"Coming Soon"},e.N=function(e){return ee(e)?e:e instanceof Date?e.getTime():!0===e?1:!1===e?0:Q(e)?e:0},e.NA=function(){return u},e.NEGBINOM=He,e.NEGBINOMDIST=Nr,e.NETWORKDAYS=xt,e.NETWORKDAYSINTL=Tr,e.NETWORKDAYS_INTL=St,e.NEYNAR=function(){return no.apply(this,arguments)},e.NOMINAL=function(e,t){return F(e=V(e),t=V(t))?n:e<=0||t<1?o:(t=parseInt(t,10),(Math.pow(e+1,1/t)-1)*t)},e.NORM=Ze,e.NORMDIST=Ar,e.NORMINV=Ir,e.NORMSDIST=Mr,e.NORMSINV=Cr,e.NOT=function(e){return"string"==typeof e?n:e instanceof Error?e:!e},e.NOW=function(){return l?h(new Date):new Date},e.NPER=function(e,t,r,a,i){if(i=void 0===i?0:i,a=void 0===a?0:a,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i)))return n;if(0===e)return-(r+a)/t;var o=t*(1+e*i)-a*e,u=r*e+t*(1+e*i);return Math.log(o/u)/Math.log(1+e)},e.NPV=sn,e.NUMBERVALUE=function(e,t,r){return"number"==typeof(e=X(e)?e:"")?e:"string"!=typeof e?u:(t=void 0===t?".":t,r=void 0===r?",":r,Number(e.replace(t,".").replace(r,"")))},e.OCT2BIN=function(e,t){if(!/^[0-7]{1,10}$/.test(e))return o;var r=!(10!==e.length||"7"!==e.substring(0,1)),a=r?parseInt(e,8)-1073741824:parseInt(e,8);if(a<-512||a>511)return o;if(r)return"1"+ve("0",9-(512+a).toString(2).length)+(512+a).toString(2);var i=a.toString(2);return void 0===t?i:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=i.length?ve("0",t-i.length)+i:o},e.OCT2DEC=function(e){if(!/^[0-7]{1,10}$/.test(e))return o;var t=parseInt(e,8);return t>=536870912?t-1073741824:t},e.OCT2HEX=function(e,t){if(!/^[0-7]{1,10}$/.test(e))return o;var r=parseInt(e,8);if(r>=536870912)return"ff"+(r+3221225472).toString(16);var a=r.toString(16);return void 0===t?a:isNaN(t)?n:t<0?o:(t=Math.floor(t))>=a.length?ve("0",t-a.length)+a:o},e.ODD=function(e){if((e=V(e))instanceof Error)return e;var t=Math.ceil(Math.abs(e));return t=1&t?t:t+1,e>=0?t:-t},e.OR=function(){for(var e=C(arguments),t=n,r=0;r<e.length;r++){if(e[r]instanceof Error)return e[r];void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&(t===n&&(t=!1),e[r]&&(t=!0))}return t},e.PDURATION=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:e<=0?o:(Math.log(r)-Math.log(t))/Math.log(1+e)},e.PEARSON=Ve,e.PERCENTILE=Ye,e.PERCENTILEEXC=Or,e.PERCENTILEINC=Rr,e.PERCENTRANK=Be,e.PERCENTRANKEXC=jr,e.PERCENTRANKINC=Dr,e.PERMUT=function(e,t){return F(e=V(e),t=V(t))?n:ut(e)/ut(e-t)},e.PERMUTATIONA=function(e,t){return F(e=V(e),t=V(t))?n:Math.pow(e,t)},e.PHI=function(e){return(e=V(e))instanceof Error?n:Math.exp(-.5*e*e)/2.5066282746310002},e.PI=function(){return Math.PI},e.PMT=cn,e.PNL=function(){var e=_slicedToArray(T(arguments),2),t=e[0],r=e[1],n=function(e){var t=Number(e);if(isNaN(t))throw new Error("Invalid number value: ".concat(e));return t};if("number"==typeof t&&"number"==typeof r)return t-r;if(Array.isArray(t)&&Array.isArray(r)&&"object"!==_typeof(t[0])){for(var a=Math.max(t.length,r.length),i=0,o=0;o<a;o++){i+=(o<t.length?n(t[o]):0)-(o<r.length?n(r[o]):0)}return i}if(Array.isArray(t[0])&&"object"!==_typeof(t[0][0])){for(var u=0,s=Math.max(t.length,r.length),c=0;c<s;c++)for(var f=t[c]||[],l=r[c]||[],p=Math.max(f.length,l.length),d=0;d<p;d++){u+=(d<f.length?n(f[d]):0)-(d<l.length?n(l[d]):0)}return u}if(Array.isArray(t[0][0])){for(var h=0,v=Math.max(t.length,r.length),m=0;m<v;m++)for(var g=t[m]||[],y=r[m]||[],_=Math.max(g.length,y.length),b=0;b<_;b++)for(var k=g[b]||[],w=y[b]||[],x=Math.max(k.length,w.length),S=0;S<x;S++){h+=(S<k.length?n(k[S]):0)-(S<w.length?n(w[S]):0)}return h}throw new Error("Unsupported or mismatched structure")},e.POISSON=Ke,e.POISSONDIST=Pr,e.POLYMARKET=function(){return"Coming Soon"},e.POWER=ft,e.PPMT=function(e,t,r,a,i,o){return i=i||0,o=o||0,F(e=V(e),r=V(r),a=V(a),i=V(i),o=V(o))?n:cn(e,r,a,i,o)-un(e,t,r,a,i,o)},e.PRICE=function(){return So.apply(this,arguments)},e.PRICEDISC=function(e,t,r,a,i){if(F(e=H(e),t=H(t),r=V(r),a=V(a),i=(i=V(i))||0))return n;if(r<=0||a<=0)return o;if(e>=t)return n;var u,s;switch(i){case 0:u=360,s=kt(e,t,!1);break;case 1:case 3:u=365,s=yt(e,t,"D");break;case 2:u=360,s=yt(e,t,"D");break;case 4:u=360,s=kt(e,t,!0);break;default:return o}return a-r*a*s/u},e.PRIVACYPOOL=function(){return"Coming Soon"},e.PROB=function(e,t,r,a){if(void 0===r)return 0;if(a=void 0===a?r:a,F(e=Y(C(e)),t=Y(C(t)),r=V(r),a=V(a)))return n;if(r===a)return e.indexOf(r)>=0?t[e.indexOf(r)]:0;for(var i=e.sort((function(e,t){return e-t})),o=i.length,u=0,s=0;s<o;s++)i[s]>=r&&i[s]<=a&&(u+=t[e.indexOf(i[s])]);return u},e.PRODUCT=lt,e.PROPER=function(e){return F(e)?e:isNaN(e)&&"number"==typeof e?n:(e=B(e)).replace(/\w\S*/g,(function(e){return e.charAt(0).toUpperCase()+e.substr(1).toLowerCase()}))},e.PV=function(e,t,r,a,i){return a=a||0,i=i||0,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i))?n:0===e?-r*t-a:((1-Math.pow(1+e,t))/e*r*(1+e*i)-a)/Math.pow(1+e,t)},e.QUARTILE=ze,e.QUARTILEEXC=Lr,e.QUARTILEINC=Fr,e.QUOTIENT=function(e,t){var r=L(e=V(e),t=V(t));return r||parseInt(e/t,10)},e.RADIANS=function(e){return(e=V(e))instanceof Error?e:e*Math.PI/180},e.RAND=function(){return Math.random()},e.RANDBETWEEN=function(e,t){var r=L(e=V(e),t=V(t));return r||e+Math.ceil((t-e+1)*Math.random())-1},e.RANK=Xe,e.RANKAVG=Ur,e.RANKEQ=qr,e.RATE=function(e,t,r,a,i,u){if(u=void 0===u?.1:u,a=void 0===a?0:a,i=void 0===i?0:i,F(e=V(e),t=V(t),r=V(r),a=V(a),i=V(i),u=V(u)))return n;var s=1e-10,c=u;i=i?1:0;for(var f=0;f<100;f++){if(c<=-1)return o;var l=void 0,p=void 0;if(l=Math.abs(c)<s?r*(1+e*c)+t*(1+c*i)*e+a:r*(p=Math.pow(1+c,e))+t*(1/c+i)*(p-1)+a,Math.abs(l)<s)return c;var d=void 0;if(Math.abs(c)<s)d=r*e+t*i*e;else{p=Math.pow(1+c,e);var h=e*Math.pow(1+c,e-1);d=r*h+t*(1/c+i)*h+t*(-1/(c*c))*(p-1)}c-=l/d}return c},e.REPLACE=function(e,t,r,a){return F(t=V(t),r=V(r))||"string"!=typeof e||"string"!=typeof a?n:e.substr(0,t-1)+a+e.substr(t-1+r)},e.REPT=ve,e.RIGHT=function(e,t){var r=L(e,t);return r||(e=B(e),(t=V(t=void 0===t?1:t))instanceof Error?t:e.substring(e.length-t))},e.ROMAN=function(e){if((e=V(e))instanceof Error)return e;for(var t=String(e).split(""),r=["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM","","X","XX","XXX","XL","L","LX","LXX","LXXX","XC","","I","II","III","IV","V","VI","VII","VIII","IX"],n="",a=3;a--;)n=(r[+t.pop()+10*a]||"")+n;return new Array(+t.join("")+1).join("M")+n},e.ROTKI=function(){return"Coming Soon"},e.ROUND=pt,e.ROUNDDOWN=function(e,t){var r=L(e=V(e),t=V(t));return r||(e>0?1:-1)*Math.floor(Math.abs(e)*Math.pow(10,t))/Math.pow(10,t)},e.ROUNDUP=function(e,t){var r=L(e=V(e),t=V(t));return r||(e>0?1:-1)*Math.ceil(Math.abs(e)*Math.pow(10,t))/Math.pow(10,t)},e.ROW=function(e,t){return 2!==arguments.length?u:t<0?o:e instanceof Array&&"number"==typeof t?0!==e.length?oe.row(e,t):void 0:n},e.ROWS=function(e){return 1!==arguments.length?u:e instanceof Array?0===e.length?0:oe.rows(e):n},e.RRI=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:0===e||0===t?o:Math.pow(r/t,1/e)-1},e.RSQ=function(e,t){return F(e=Y(C(e)),t=Y(C(t)))?n:Math.pow(Ve(e,t),2)},e.SAFE=function(){return io.apply(this,arguments)},e.SEARCH=function(e,t,r){var a;return"string"!=typeof e||"string"!=typeof t?n:(r=void 0===r?0:r,0===(a=t.toLowerCase().indexOf(e.toLowerCase(),r-1)+1)?n:a)},e.SEC=function(e){return(e=V(e))instanceof Error?e:1/Math.cos(e)},e.SECH=function(e){return(e=V(e))instanceof Error?e:2/(Math.exp(e)+Math.exp(-e))},e.SECOND=function(e){return(e=H(e))instanceof Error?e:e.getSeconds()},e.SERIESSUM=function(e,t,r,a){if(F(e=V(e),t=V(t),r=V(r),a=Y(a)))return n;for(var i=a[0]*Math.pow(e,t),o=1;o<a.length;o++)i+=a[o]*Math.pow(e,t+o*r);return i},e.SIGN=function(e){return(e=V(e))instanceof Error?e:e<0?-1:0===e?0:1},e.SIN=function(e){return(e=V(e))instanceof Error?e:Math.sin(e)},e.SINH=function(e){return(e=V(e))instanceof Error?e:(Math.exp(e)-Math.exp(-e))/2},e.SKEW=We,e.SKEWP=Gr,e.SLN=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:0===r?o:(e-t)/r},e.SLOPE=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(t),a=oe.mean(e),i=t.length,o=0,u=0,s=0;s<i;s++)o+=(t[s]-r)*(e[s]-a),u+=Math.pow(t[s]-r,2);return o/u},e.SMALL=$e,e.SMARTCONTRACT=function(){return so.apply(this,arguments)},e.SORT=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if(!e||!Array.isArray(e))return u;if(0===e.length)return 0;var o=V(t);if(!o||o<1)return n;o-=1;var s=V("false"===(null==r?void 0:r.toLowerCase())?-1:1);if(1!==s&&-1!==s)return n;var c=G(a);if("boolean"!=typeof c)return i;var f=M(e),l=c?D(f):f;if(!l.length||!l[0]||o>=l[0].length)return n;var p=function(e){return""===e||null==e},d=l.map((function(e,t){return{row:e,rowIndex:t}}));d.sort((function(e,t){var r=function(e,t){var r,n,a=p(e),i=p(t);if(a&&i)return 0;if(a)return 1;if(i)return-1;var o=V(e),u=V(t),s=Number.isFinite(o),c=Number.isFinite(u);if(s&&c)return o<u?-1:o>u?1:0;var f=(null!==(r=B(e))&&void 0!==r?r:"").toString().toLowerCase(),l=(null!==(n=B(t))&&void 0!==n?n:"").toString().toLowerCase();return f<l?-1:f>l?1:0}(e.row[o],t.row[o]);return 0!==r?r*s:e.rowIndex-t.rowIndex}));var h=d.map((function(e){return e.row}));return c?D(h):h},e.SQRT=function(e){return(e=V(e))instanceof Error?e:e<0?o:Math.sqrt(e)},e.SQRTPI=function(e){return(e=V(e))instanceof Error?e:Math.sqrt(e*Math.PI)},e.STANDARDIZE=function(e,t,r){return F(e=V(e),t=V(t),r=V(r))?n:(e-t)/r},e.STDEV=Qe,e.STDEVA=function(){var e=et.apply(this,arguments);return Math.sqrt(e)},e.STDEVP=Hr,e.STDEVPA=function(){var e=tt.apply(this,arguments),t=Math.sqrt(e);return isNaN(t)&&(t=o),t},e.STDEVS=Zr,e.STEYX=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=oe.mean(t),a=oe.mean(e),i=t.length,o=0,u=0,s=0,c=0;c<i;c++)o+=Math.pow(e[c]-a,2),u+=(t[c]-r)*(e[c]-a),s+=Math.pow(t[c]-r,2);return Math.sqrt((o-u*u/s)/(i-2))},e.SUBSTITUTE=function(e,t,r,a){if(arguments.length<3)return u;if(e&&t){if(void 0===a)return e.split(t).join(r);if(a=Math.floor(Number(a)),Number.isNaN(a)||a<=0)return n;for(var i=0,o=0;i>-1&&e.indexOf(t,i)>-1;)if(o++,(i=e.indexOf(t,i+1))>-1&&o===a)return e.substring(0,i)+r+e.substring(i+t.length);return e}return e},e.SUBTOTAL=function(e,t){if((e=V(e))instanceof Error)return e;switch(e){case 1:case 101:return _e(t);case 2:case 102:return Ee(t);case 3:case 103:return Ne(t);case 4:case 104:return Fe(t);case 5:case 105:return qe(t);case 6:case 106:return lt(t);case 7:case 107:return Qe.S(t);case 8:case 108:return Qe.P(t);case 9:case 109:return dt(t);case 10:case 110:return Je.S(t);case 11:case 111:return Je.P(t)}},e.SUM=dt,e.SUMIF=function(e,t,r){if(e=C(e),r=r?C(r):e,e instanceof Error)return e;if(null==t||t instanceof Error)return 0;for(var n=0,a="*"===t,i=a?null:E(t+""),o=0;o<e.length;o++){var u=e[o],s=r[o];if(a)n+=u;else{var c=[x(u,w)].concat(i);n+=N(c)?s:0}}return n},e.SUMIFS=function(){return dt(z.apply(void 0,arguments))},e.SUMPRODUCT=function(){if(!arguments||0===arguments.length)return n;for(var e,t,r,a,i=arguments.length+1,o=0,u=0;u<arguments[0].length;u++)if(arguments[0][u]instanceof Array)for(var s=0;s<arguments[0][u].length;s++){for(e=1,t=1;t<i;t++){var c=arguments[t-1][u][s];if(c instanceof Error)return c;if((a=V(c))instanceof Error)return a;e*=a}o+=e}else{for(e=1,t=1;t<i;t++){var f=arguments[t-1][u];if(f instanceof Error)return f;if((r=V(f))instanceof Error)return r;e*=r}o+=e}return o},e.SUMSQ=function(){var e=Y(C(arguments));if(e instanceof Error)return e;for(var t=0,r=e.length,n=0;n<r;n++)t+=ee(e[n])?e[n]*e[n]:0;return t},e.SUMX2MY2=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;for(var r=0,a=0;a<e.length;a++)r+=e[a]*e[a]-t[a]*t[a];return r},e.SUMX2PY2=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;var r=0;e=Y(C(e)),t=Y(C(t));for(var a=0;a<e.length;a++)r+=e[a]*e[a]+t[a]*t[a];return r},e.SUMXMY2=function(e,t){if(F(e=Y(C(e)),t=Y(C(t))))return n;var r=0;e=C(e),t=C(t);for(var a=0;a<e.length;a++)r+=Math.pow(e[a]-t[a],2);return r},e.SWITCH=function(){var e;if(arguments.length>0){var t=arguments[0],r=arguments.length-1,a=Math.floor(r/2),i=!1,o=r%2!=0,s=r%2==0?null:arguments[arguments.length-1];if(a)for(var c=0;c<a;c++)if(t===arguments[2*c+1]){e=arguments[2*c+2],i=!0;break}i||(e=o?s:u)}else e=n;return e},e.SYD=function(e,t,r,a){return F(e=V(e),t=V(t),r=V(r),a=V(a))?n:0===r||a<1||a>r?o:(e-t)*(r-(a=parseInt(a,10))+1)*2/(r*(r+1))},e.T=me,e.TALLY=function(){return fo.apply(this,arguments)},e.TAN=function(e){return(e=V(e))instanceof Error?e:Math.tan(e)},e.TANH=function(e){if((e=V(e))instanceof Error)return e;var t=Math.exp(2*e);return(t-1)/(t+1)},e.TBILLEQ=function(e,t,r){return F(e=H(e),t=H(t),r=V(r))?n:r<=0||e>t||t-e>31536e6?o:365*r/(360-r*kt(e,t,!1))},e.TBILLPRICE=function(e,t,r){return F(e=H(e),t=H(t),r=V(r))?n:r<=0||e>t||t-e>31536e6?o:100*(1-r*kt(e,t,!1)/360)},e.TBILLYIELD=function(e,t,r){return F(e=H(e),t=H(t),r=V(r))?n:r<=0||e>t||t-e>31536e6?o:360*(100-r)/(r*kt(e,t,!1))},e.TDIST=Vr,e.TDISTRT=Yr,e.TEXT=function(e,t){if(void 0===e||e instanceof Error||t instanceof Error)return u;if(e instanceof Date)return e.toISOString().slice(0,10);if(null==t)return"";if("number"==typeof t)return String(t);if("string"!=typeof t)return n;var r=t.startsWith("$")?"$":"",a=t.endsWith("%");return a&&(e*=100),e=(e=he(e,(t=t.replace(/%/g,"").replace(/\$/g,"")).includes(".")?t.split(".")[1].match(/0/g).length:0,!t.includes(","))).startsWith("-")?"-"+r+(e=e.replace("-","")):r+e,a&&(e+="%"),e},e.TEXTJOIN=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),a=2;a<r;a++)n[a-2]=arguments[a];if("boolean"!=typeof t&&(t=G(t)),arguments.length<3)return u;e=null!=e?e:"";var i=C(n),o=t?i.filter((function(e){return e})):i;if(Array.isArray(e)){e=C(e);for(var s=o.map((function(e){return[e]})),c=0,f=0;f<s.length-1;f++)s[f].push(e[c]),++c===e.length&&(c=0);return(o=C(s)).join("")}return o.join(e)},e.TIME=function(e,t,r){if(F(e=V(e),t=V(t),r=V(r)))return n;if(e<0||t<0||r<0)return o;var a=String(e).padStart(2,"0"),i=String(t).padStart(2,"0"),u=String(r).padStart(2,"0");return"".concat(a,":").concat(i,":").concat(u)},e.TIMEVALUE=function(e){return(e=H(e))instanceof Error?e:(3600*e.getHours()+60*e.getMinutes()+e.getSeconds())/86400},e.TINV=Br,e.TODAY=function(){return v(_t(new Date))},e.TRANSPOSE=function(e){return e?D(M(e)):u},e.TREND=function(e,t,r){if(F(e=Y(C(e)),t=Y(C(t)),r=Y(C(r))))return n;var a=Pe(e,t),i=a[0],o=a[1],u=[];return r.forEach((function(e){u.push(i*e+o)})),u},e.TRIM=function(e){return(e=B(e))instanceof Error?e:e.replace(/\s+/g," ").trim()},e.TRIMMEAN=function(e,t){if(F(e=Y(C(e)),t=V(t)))return n;var r,a,i=st(e.length*t,2)/2;return oe.mean((r=j(e.sort((function(e,t){return e-t})),i),a=(a=i)||1,r&&"function"==typeof r.slice?r.slice(0,r.length-a):r))},e.TRUE=function(){return!0},e.TRUNC=function(e,t){var r=L(e=V(e),t=V(t));return r||(e>0?1:-1)*Math.floor(Math.abs(e)*Math.pow(10,t))/Math.pow(10,t)},e.TTEST=Kr,e.TYPE=function(e){return ee(e)?1:te(e)?2:J(e)?4:Q(e)?16:Array.isArray(e)?64:void 0},e.UNICHAR=ge,e.UNICODE=ye,e.UNIQUE=ue,e.UNISWAP=function(){return uo.apply(this,arguments)},e.UPPER=function(e){return(e=B(e))instanceof Error?e:e.toUpperCase()},e.VALUE=function(e){var t=L(e);if(t)return t;if("number"==typeof e)return e;if(X(e)||(e=""),"string"!=typeof e)return n;var r=/(%)$/.test(e)||/^(%)/.test(e);if(""===(e=(e=(e=e.replace(/^[^0-9-]{0,3}/,"")).replace(/[^0-9]{0,3}$/,"")).replace(/[ ,]/g,"")))return 0;var a=Number(e);return isNaN(a)?n:(a=a||0,r&&(a*=.01),a)},e.VAR=Je,e.VARA=et,e.VARP=zr,e.VARPA=tt,e.VARS=Xr,e.VLOOKUP=se,e.WALLET=function(){return To.apply(this,arguments)},e.WEEKDAY=function(e,t){if((e=H(e))instanceof Error)return e;void 0===t&&(t=1);var r=e.getDay();return mt[t][r]},e.WEEKNUM=function(e,t){if((e=H(e))instanceof Error)return e;if(void 0===t&&(t=1),21===t)return wt(e);var r=vt[t],n=new Date(e.getFullYear(),0,1),a=n.getDay()<r?1:0;return n-=24*Math.abs(n.getDay()-r)*60*60*1e3,Math.floor((e-n)/864e5/7+1)+a},e.WEIBULL=rt,e.WEIBULLDIST=Wr,e.WORKDAY=Et,e.WORKDAYINTL=$r,e.WORKDAY_INTL=Nt,e.XIRR=function(e,t,r){if(F(e=Y(C(e)),t=Z(C(t)),r=V(r)))return n;for(var a=function(e,t,r){for(var n=r+1,a=e[0],i=1;i<e.length;i++)a+=e[i]/Math.pow(n,bt(t[i],t[0])/365);return a},i=function(e,t,r){for(var n=r+1,a=0,i=1;i<e.length;i++){var o=bt(t[i],t[0])/365;a-=o*e[i]/Math.pow(n,o+1)}return a},u=!1,s=!1,c=0;c<e.length;c++)e[c]>0&&(u=!0),e[c]<0&&(s=!0);if(!u||!s)return o;var f,l,p,d=r=r||.1,h=!0;do{f=d-(p=a(e,t,d))/i(e,t,d),l=Math.abs(f-d),d=f,h=l>1e-10&&Math.abs(p)>1e-10}while(h);return d},e.XLOOKUP=function(e,t,r,n,a,i,o){var u="true"===n;if(null==e)return new Error("search_key");if(!t)return new Error("lookup_range");if(!r)return new Error("result_range");var s=function(e){if(!Array.isArray(e))return null;if(!Array.isArray(e[0]))return e;var t=e.length,r=e[0].length;return 1===t?e[0]:1===r?e.map((function(e){return e[0]})):null}(t);if(!s)return new Error("lookup_range_single");var c=function(e){if(!Array.isArray(e))return null;if(!Array.isArray(e[0]))return e.map((function(e){return[e]}));return e}(r);if(!c)return new Error("result_range_invalid");if(c.map((function(e){if(e.length!==s.length)return new Error("lookup_range_and_result_range")})),a=void 0!==a?a:new Error("not_found"),o=void 0!==o?o:1,u=void 0!==u&&u,![0,1,-1,2].includes(i=void 0!==i?i:0))return new Error("match_mode_must");if(![1,-1,2,-2].includes(o))return new Error("search_mode_must");if(2===Math.abs(o)&&2===i)return new Error("binary_search_and_wildcard");var f=function(e,t,r,n,a,i,o){var u=-1;switch(a){case 0:u=function(e,t,r){var n="string"==typeof e?e.toLowerCase().trim():e;if(2===Math.abs(r))return function(e,t,r){var n=0,a=t.length-1;for(;n<=a;){var i=Math.floor((n+a)/2),o=t[i],u="string"==typeof o?o.toLowerCase().trim():o;if(u===e)return i;(r?u<e:u>e)?n=i+1:a=i-1}return-1}(n,t,r>0);var a,i=_createForOfIteratorHelper(ce(t.length,r));try{for(i.s();!(a=i.n()).done;){var o=a.value,u=t[o];if(("string"==typeof u?u.toLowerCase().trim():u)===n)return o}}catch(e){i.e(e)}finally{i.f()}return-1}(e,t,i);break;case 1:u=function(e,t,r){var n="number"==typeof e,a="string"==typeof e?e.toLowerCase().trim():e;if(2===Math.abs(r))return function(e,t,r){var n=0,a=t.length-1,i=-1;for(;n<=a;){var o=Math.floor((n+a)/2),u=t[o],s="string"==typeof u?u.toLowerCase().trim():u;if(s===e)return o;r?s>e?(i=o,a=o-1):n=o+1:s<e?(i=o,n=o+1):a=o-1}return i}(a,t,r>0);var i,o=ce(t.length,r),u=-1,s=_createForOfIteratorHelper(o);try{for(s.s();!(i=s.n()).done;){var c=i.value,f=t[c],l="string"==typeof f?f.toLowerCase().trim():f;if(l===a)return c;n&&"number"==typeof f&&f>e?(-1===u||f<t[u])&&(u=c):!n&&"string"==typeof f&&l>a&&(-1===u||l<("string"==typeof t[u]?t[u].toLowerCase().trim():t[u]))&&(u=c)}}catch(e){s.e(e)}finally{s.f()}return u}(e,t,i);break;case-1:u=function(e,t,r){var n="number"==typeof e,a="string"==typeof e?e.toLowerCase().trim():e;if(2===Math.abs(r))return function(e,t,r){var n=0,a=t.length-1,i=-1;for(;n<=a;){var o=Math.floor((n+a)/2),u=t[o],s="string"==typeof u?u.toLowerCase().trim():u;if(s===e)return o;r?s<e?(i=o,n=o+1):a=o-1:s>e?(i=o,a=o-1):n=o+1}return i}(a,t,r>0);var i,o=ce(t.length,r),u=-1,s=_createForOfIteratorHelper(o);try{for(s.s();!(i=s.n()).done;){var c=i.value,f=t[c],l="string"==typeof f?f.toLowerCase().trim():f;if(l===a)return c;n&&"number"==typeof f&&f<e?(-1===u||f>t[u])&&(u=c):!n&&"string"==typeof f&&l<a&&(-1===u||l>("string"==typeof t[u]?t[u].toLowerCase().trim():t[u]))&&(u=c)}}catch(e){s.e(e)}finally{s.f()}return u}(e,t,i);break;case 2:u=function(e,t,r){if("string"!=typeof e)return-1;var n,a=e.toLowerCase().replace(/\*/g,".*").replace(/\?/g,".").replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\.\*/g,".*").replace(/\\\./g,"."),i=new RegExp("^".concat(a,"$"),"i"),o=ce(t.length,r),u=_createForOfIteratorHelper(o);try{for(u.s();!(n=u.n()).done;){var s=n.value,c=t[s];if("string"==typeof c&&i.test(c))return s}}catch(e){u.e(e)}finally{u.f()}return-1}(e,t,i)}if(-1===u)return n;return o?r.map((function(e){return e[u]})):r[u]}(e,s,c,a,i,o,u);return f=u?Array.isArray(f)?f.map((function(e){return[e.toString()]})):f:[f]},e.XNPV=function(e,t,r){if(F(e=V(e),t=Y(C(t)),r=Z(C(r))))return n;for(var a=0,i=0;i<t.length;i++)a+=t[i]/Math.pow(1+e,bt(r[i],r[0])/365);return a},e.XOR=function(){for(var e=C(arguments),t=n,r=0;r<e.length;r++){if(e[r]instanceof Error)return e[r];void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&(t===n&&(t=0),e[r]&&t++)}return t===n?t:!!(1&Math.floor(Math.abs(t)))},e.YEAR=function(e){return(e=H(e))instanceof Error?e:e.getFullYear()},e.YEARFRAC=It,e.YIELD=function(){return Io.apply(this,arguments)},e.Z=nt,e.ZTEST=Qr,e.utils=Co}));
3
3
  //# sourceMappingURL=formula.min.js.map