UNPKG

a-calc

Version:

A very powerful and easy-to-use number precision calculation and formatting library.

1 lines 188 kB
var a_calc=function(exports){"use strict";var _documentCurrentScript="undefined"!=typeof document?document.currentScript:null;function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a,o,s=[],_=!0,u=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;_=!1}else for(;!(_=(n=a.call(r)).done)&&(s.push(n.value),s.length!==t);_=!0);}catch(e){u=!0,i=e}finally{try{if(!_&&null!=r.return&&(o=r.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}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 _objectSpread2(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 _regeneratorRuntime(){_regeneratorRuntime=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n=Object.defineProperty||function(e,t,r){e[t]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function _(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{_({},"")}catch(e){_=function(e,t,r){return e[t]=r}}function u(e,t,r,i){var a=t&&t.prototype instanceof p?t:p,o=Object.create(a.prototype),s=new A(i||[]);return n(o,"_invoke",{value:y(e,r,s)}),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function p(){}function d(){}function f(){}var g={};_(g,a,(function(){return this}));var m=Object.getPrototypeOf,v=m&&m(m(T([])));v&&v!==t&&r.call(v,a)&&(g=v);var h=f.prototype=p.prototype=Object.create(g);function w(e){["next","throw","return"].forEach((function(t){_(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){function i(n,a,o,s){var _=c(e[n],e,a);if("throw"!==_.type){var u=_.arg,l=u.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){i("next",e,o,s)}),(function(e){i("throw",e,o,s)})):t.resolve(l).then((function(e){u.value=e,o(u)}),(function(e){return i("throw",e,o,s)}))}s(_.arg)}var a;n(this,"_invoke",{value:function(e,r){function n(){return new t((function(t,n){i(e,r,t,n)}))}return a=a?a.then(n,n):n()}})}function y(e,t,r){var n="suspendedStart";return function(i,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw a;return N()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=x(o,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var _=c(e,t,r);if("normal"===_.type){if(n=r.done?"completed":"suspendedYield",_.arg===l)continue;return{value:_.arg,done:r.done}}"throw"===_.type&&(n="completed",r.method="throw",r.arg=_.arg)}}}function x(e,t){var r=t.method,n=e.iterator[r];if(void 0===n)return t.delegate=null,"throw"===r&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==r&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+r+"' method")),l;var i=c(n,e.iterator,t.arg);if("throw"===i.type)return t.method="throw",t.arg=i.arg,t.delegate=null,l;var a=i.arg;return a?a.done?(t[e.resultName]=a.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):a:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function A(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function T(e){if(e){var t=e[a];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=f,n(h,"constructor",{value:f,configurable:!0}),n(f,"constructor",{value:d,configurable:!0}),d.displayName=_(f,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,f):(e.__proto__=f,_(e,s,"GeneratorFunction")),e.prototype=Object.create(h),e},e.awrap=function(e){return{__await:e}},w(b.prototype),_(b.prototype,o,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new b(u(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},w(h),_(h,s,"Generator"),_(h,a,(function(){return this})),_(h,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},e.values=T,A.prototype={constructor:A,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(E),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],o=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),_=r.call(a,"finallyLoc");if(s&&_){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!_)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,l):this.complete(o)},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.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}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 asyncGeneratorStep(e,t,r,n,i,a,o){try{var s=e[a](o),_=s.value}catch(e){return void r(e)}s.done?t(_):Promise.resolve(_).then(n,i)}function _asyncToGenerator(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){asyncGeneratorStep(a,n,i,o,s,"next",e)}function s(e){asyncGeneratorStep(a,n,i,o,s,"throw",e)}o(void 0)}))}}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 _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _toConsumableArray(e){return _arrayWithoutHoles(e)||_iterableToArray(e)||_unsupportedIterableToArray(e)||_nonIterableSpread()}function _arrayWithoutHoles(e){if(Array.isArray(e))return _arrayLikeToArray(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArray(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.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 _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}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 _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 _createForOfIteratorHelper(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=_unsupportedIterableToArray(e))||t){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}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 a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function _toPrimitive(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function _toPropertyKey(e){var t=_toPrimitive(e,"string");return"symbol"==typeof t?t:String(t)}var version="3.0.0";function decimal_round(e,t,r,n,i){var a=e.startsWith("-"),o=a?e.slice(1):e,s=o,_=t,u=t.length;function c(){s=(+s+1).toString()}var l={"~-":function(){var e="<"===r?n-1:n;_=t.slice(0,e)},"~+":function(){var e="<"===r?n-1:n;if(!(u<=e||0===u)){var i=t.slice(0,e);0==+t.slice(e,u)?_=i:(i=(+"9".concat(i)+1).toString().slice(1)).length>e?(_=i.slice(1,i.length),c()):_=i}},"~5":function(){if(0!==u){var e="<"===r?n-1:n;_=t.slice(0,e);var i=+t[e];Number.isNaN(i)||i>=5&&(_=(+"9".concat(_)+1).toString().slice(1)).length>e&&(_=_.slice(1,_.length),c())}},"~6":function(){if(0!==u){var e,i="<"===r?n-1:n,a=+t[i],s=t.slice(+i+1,t.length);s=""===s?0:parseInt(s),e=0===i?+o[o.length-1]:+t[i-1],_=t.slice(0,i),(a>=6||5===a&&s>0||5===a&&e%2!=0)&&(_=(+"9".concat(_)+1).toString().slice(1)).length>i&&(_=_.slice(1,_.length),c())}}};return"<="===r?u<=n?_=t.replace(/0*$/,""):(l[i]&&l[i](),_=_.replace(/0+$/,"")):"<"===r?u<n?_=t.replace(/0*$/,""):(l[i]&&l[i](),_=_.replace(/0+$/,"")):"="===r?u<n?_=t+"0".repeat(n-u):u>n&&l[i]&&l[i]():">="===r?u<n&&(_=t+"0".repeat(n-u)):">"===r&&u<=n&&(_=t+"0".repeat(n-u+1)),{int_part:a?"-".concat(s):s,dec_part:_}}var number_char="0123456789",var_char="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$",number_first_char="0123456789-+",var_members_char="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$[].'\"",var_first_char="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$",pure_number_var_first_char="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$",empty_char=" \n\r\t",number_char_set=new Set(number_char),var_char_set=new Set(var_char),var_members_char_set=new Set(var_members_char),var_first_char_set=new Set(var_first_char);new Set(number_first_char);var pure_number_var_first_char_set=new Set(pure_number_var_first_char),empty_char_set=new Set(empty_char),state_initial="initial",state_number="number",state_scientific="scientific",state_operator="operator",state_bracket="bracket",state_var="var",state_symbol="symbol",state_percent="percent",state_round="round",state_plus="plus",state_comma="comma",state_fraction="fraction",state_to_number="to-number",state_to_number_string="to-number-string",state_fallback_var="fallback_var",state_integer_padding="integer_padding",state_compact="compact",state_unit_after="unit_after",state_unit_before="unit_before",state_unit_middle="unit_middle",state_unit_hide="unit_hide",state_unit_default="unit_default",state_thousands="thousands",state_fmt_group="fmt_group",state_shortcut="shortcut",state_comparison="comparison",state_logical="logical",state_logical_not="logical_not",state_ternary_question="ternary_question",state_ternary_colon="ternary_colon",state_function="function",state_range_start="range_start",state_range_end="range_end",state_range_clamp="range_clamp",comparison_operators=new Set([">","<",">=","<=","==","!="]),logical_operators=new Set(["&&","||"]),operator_precedence={"|":0,"?":1,":":1,"||":2,"&&":3,"==":4,"!=":4,">":5,"<":5,">=":5,"<=":5,"+":6,"-":6,"*":7,"/":7,"%":7,"//":7,"**":8,"!":9,"unary-":9,"unary+":9},isArray=Array.isArray,freeGlobal="object"==("undefined"==typeof global?"undefined":_typeof(global))&&global&&global.Object===Object&&global,freeSelf="object"==("undefined"==typeof self?"undefined":_typeof(self))&&self&&self.Object===Object&&self,root=freeGlobal||freeSelf||Function("return this")(),_Symbol=root.Symbol,objectProto$4=Object.prototype,hasOwnProperty$3=objectProto$4.hasOwnProperty,nativeObjectToString$1=objectProto$4.toString,symToStringTag$1=_Symbol?_Symbol.toStringTag:void 0;function getRawTag(e){var t=hasOwnProperty$3.call(e,symToStringTag$1),r=e[symToStringTag$1];try{e[symToStringTag$1]=void 0;var n=!0}catch(e){}var i=nativeObjectToString$1.call(e);return n&&(t?e[symToStringTag$1]=r:delete e[symToStringTag$1]),i}var objectProto$3=Object.prototype,nativeObjectToString=objectProto$3.toString;function objectToString(e){return nativeObjectToString.call(e)}var nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=_Symbol?_Symbol.toStringTag:void 0;function baseGetTag(e){return null==e?void 0===e?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(e)?getRawTag(e):objectToString(e)}function isObjectLike(e){return null!=e&&"object"==_typeof(e)}var symbolTag="[object Symbol]";function isSymbol(e){return"symbol"==_typeof(e)||isObjectLike(e)&&baseGetTag(e)==symbolTag}var reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey(e,t){if(isArray(e))return!1;var r=_typeof(e);return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!isSymbol(e))||(reIsPlainProp.test(e)||!reIsDeepProp.test(e)||null!=t&&e in Object(t))}function isObject(e){var t=_typeof(e);return null!=e&&("object"==t||"function"==t)}var asyncTag="[object AsyncFunction]",funcTag="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction(e){if(!isObject(e))return!1;var t=baseGetTag(e);return t==funcTag||t==genTag||t==asyncTag||t==proxyTag}var coreJsData=root["__core-js_shared__"],maskSrcKey=(uid=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||""),uid?"Symbol(src)_1."+uid:""),uid;function isMasked(e){return!!maskSrcKey&&maskSrcKey in e}var funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource(e){if(null!=e){try{return funcToString$1.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$2=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$2=objectProto$2.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$2).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative(e){return!(!isObject(e)||isMasked(e))&&(isFunction(e)?reIsNative:reIsHostCtor).test(toSource(e))}function getValue(e,t){return null==e?void 0:e[t]}function getNative(e,t){var r=getValue(e,t);return baseIsNative(r)?r:void 0}var nativeCreate=getNative(Object,"create");function hashClear(){this.__data__=nativeCreate?nativeCreate(null):{},this.size=0}function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var HASH_UNDEFINED$1="__lodash_hash_undefined__",objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty;function hashGet(e){var t=this.__data__;if(nativeCreate){var r=t[e];return r===HASH_UNDEFINED$1?void 0:r}return hasOwnProperty$1.call(t,e)?t[e]:void 0}var objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty;function hashHas(e){var t=this.__data__;return nativeCreate?void 0!==t[e]:hasOwnProperty.call(t,e)}var HASH_UNDEFINED="__lodash_hash_undefined__";function hashSet(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=nativeCreate&&void 0===t?HASH_UNDEFINED:t,this}function Hash(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}function listCacheClear(){this.__data__=[],this.size=0}function eq(e,t){return e===t||e!=e&&t!=t}function assocIndexOf(e,t){for(var r=e.length;r--;)if(eq(e[r][0],t))return r;return-1}Hash.prototype.clear=hashClear,Hash.prototype.delete=hashDelete,Hash.prototype.get=hashGet,Hash.prototype.has=hashHas,Hash.prototype.set=hashSet;var arrayProto=Array.prototype,splice=arrayProto.splice;function listCacheDelete(e){var t=this.__data__,r=assocIndexOf(t,e);return!(r<0)&&(r==t.length-1?t.pop():splice.call(t,r,1),--this.size,!0)}function listCacheGet(e){var t=this.__data__,r=assocIndexOf(t,e);return r<0?void 0:t[r][1]}function listCacheHas(e){return assocIndexOf(this.__data__,e)>-1}function listCacheSet(e,t){var r=this.__data__,n=assocIndexOf(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}ListCache.prototype.clear=listCacheClear,ListCache.prototype.delete=listCacheDelete,ListCache.prototype.get=listCacheGet,ListCache.prototype.has=listCacheHas,ListCache.prototype.set=listCacheSet;var Map$1=getNative(root,"Map");function mapCacheClear(){this.size=0,this.__data__={hash:new Hash,map:new(Map$1||ListCache),string:new Hash}}function isKeyable(e){var t=_typeof(e);return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}function getMapData(e,t){var r=e.__data__;return isKeyable(t)?r["string"==typeof t?"string":"hash"]:r.map}function mapCacheDelete(e){var t=getMapData(this,e).delete(e);return this.size-=t?1:0,t}function mapCacheGet(e){return getMapData(this,e).get(e)}function mapCacheHas(e){return getMapData(this,e).has(e)}function mapCacheSet(e,t){var r=getMapData(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}function MapCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}MapCache.prototype.clear=mapCacheClear,MapCache.prototype.delete=mapCacheDelete,MapCache.prototype.get=mapCacheGet,MapCache.prototype.has=mapCacheHas,MapCache.prototype.set=mapCacheSet;var FUNC_ERROR_TEXT="Expected a function";function memoize(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError(FUNC_ERROR_TEXT);var r=function r(){var n=arguments,i=t?t.apply(this,n):n[0],a=r.cache;if(a.has(i))return a.get(i);var o=e.apply(this,n);return r.cache=a.set(i,o)||a,o};return r.cache=new(memoize.Cache||MapCache),r}memoize.Cache=MapCache;var MAX_MEMOIZE_SIZE=500;function memoizeCapped(e){var t=memoize(e,(function(e){return r.size===MAX_MEMOIZE_SIZE&&r.clear(),e})),r=t.cache;return t}var rePropName=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,reEscapeChar=/\\(\\)?/g,stringToPath=memoizeCapped((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(rePropName,(function(e,r,n,i){t.push(n?i.replace(reEscapeChar,"$1"):r||e)})),t}));function arrayMap(e,t){for(var r=-1,n=null==e?0:e.length,i=Array(n);++r<n;)i[r]=t(e[r],r,e);return i}var symbolProto=_Symbol?_Symbol.prototype:void 0,symbolToString=symbolProto?symbolProto.toString:void 0;function baseToString(e){if("string"==typeof e)return e;if(isArray(e))return arrayMap(e,baseToString)+"";if(isSymbol(e))return symbolToString?symbolToString.call(e):"";var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function toString(e){return null==e?"":baseToString(e)}function castPath(e,t){return isArray(e)?e:isKey(e,t)?[e]:stringToPath(toString(e))}function toKey(e){if("string"==typeof e||isSymbol(e))return e;var t=e+"";return"0"==t&&1/e==-1/0?"-0":t}function baseGet(e,t){for(var r=0,n=(t=castPath(t,e)).length;null!=e&&r<n;)e=e[toKey(t[r++])];return r&&r==n?e:void 0}function get(e,t,r){var n=null==e?void 0:baseGet(e,t);return void 0===n?r:n}var REG_UNIT_NUM_SCIENTIFIC=/^([+-]?[\d.]+(?:e|E)(?:\+|-)?\d+)(.*)$/,REG_UNIT_NUM_NORMAL=/^([+-]?[\d.]+)(.*)$/;function split_unit_num(e){var t,r,n=(e="string"!=typeof e?e.toString():e).match(REG_UNIT_NUM_SCIENTIFIC)||e.match(REG_UNIT_NUM_NORMAL);if(n){r=n[1];var i=n[2];""!==i.trim()&&(t=i)}return{num:r,unit:t}}function find_value(e,t,r){var n,i,a,o;return Array.isArray(e)?e.length>1?null!==(n=null!==(i=get(e[0],t))&&void 0!==i?i:get(e.at(-1),t))&&void 0!==n?n:r:1===e.length&&null!==(a=get(e[0],t))&&void 0!==a?a:r:null!==(o=get(e,t,r))&&void 0!==o?o:r}function parse_mantissa(e,t,r,n){var i=e.split("."),a=i[0],o=1===i.length?"":i[1],s=decimal_round(a,o,t,+r,n);return a=s.int_part,""===(o=s.dec_part)?a:"".concat(a,".").concat(o)}function integer_thousands(e){for(var t=e.length,r="";t>0;)r=e.substring(t-3,t)+(""!==r?",":"")+r,t-=3;return r}function parse_thousands(e){var t=e.split("."),r=t[0];return"-"===r[0]?t[0]="-"+integer_thousands(r.slice(1)):t[0]=integer_thousands(r),t.join(".")}function promise_queue(e){return _promise_queue.apply(this,arguments)}function _promise_queue(){return _promise_queue=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r,n,i,a=arguments;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=a.length>1&&void 0!==a[1]?a[1]:5e3,n=0;case 2:if(!(n<t.length)){e.next=16;break}return e.prev=3,e.next=6,Promise.race([t[n],new Promise((function(e,t){setTimeout((function(){return t(new Error("promise queue timeout err"))}),r)}))]);case 6:i=e.sent,e.next=12;break;case 9:return e.prev=9,e.t0=e.catch(3),e.abrupt("continue",13);case 12:return e.abrupt("return",i);case 13:n++,e.next=2;break;case 16:return e.abrupt("return",Promise.reject("错误的 promise queue 调用"));case 17:case"end":return e.stop()}}),e,null,[[3,9]])}))),_promise_queue.apply(this,arguments)}function test_urls(e){return _test_urls.apply(this,arguments)}function _test_urls(){return(_test_urls=_asyncToGenerator(_regeneratorRuntime().mark((function e(t){var r;return _regeneratorRuntime().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=0;case 1:if(!(r<t.length)){e.next=16;break}return e.prev=2,e.next=5,fetch(t[r]);case 5:if(!e.sent.ok){e.next=8;break}return e.abrupt("return",t[r]);case 8:e.next=13;break;case 10:return e.prev=10,e.t0=e.catch(2),e.abrupt("continue",13);case 13:r++,e.next=1;break;case 16:return e.abrupt("return",null);case 17:case"end":return e.stop()}}),e,null,[[2,10]])})))).apply(this,arguments)}function get_real_value(e,t){if(Array.isArray(e)){for(var r,n=0,i=e.length;n<i;n++){var a;if(void 0!==(r=null!==(a=get(e[n],t))&&void 0!==a?a:void 0))break}if(void 0===r)throw new Error("填充变量".concat(t,"失败"));return r}var o;return null!==(o=get(e,t))&&void 0!==o?o:void 0}function is_empty_for_fallback(e,t,r){return r&&"function"==typeof r._empty_check?r._empty_check(e,t):r&&Array.isArray(r._empty_values)?r._empty_values.some((function(t){return!(!Number.isNaN(t)||!Number.isNaN(e))||e===t})):null==e}function get_fallback_value(e,t,r){for(var n=0;n<t.length;n++){var i=t[n].trim(),a=void 0;try{if(Array.isArray(e))for(var o=0;o<e.length;o++){var s=get(e[o],i);if(void 0!==s){a=s;break}}else a=get(e,i)}catch(e){continue}if(!is_empty_for_fallback(a,i,r))return{value:a,path:i}}throw new Error("多路取值失败,所有路径均为空值: ".concat(t.join(" | ")))}function get_next_nonempty_char(e,t,r){var n;for(t++;t<r;){if(n=e[t],!empty_char_set.has(n))return n;t++}}function resolve_unit_value$1(e,t){return e&&e.startsWith("@")?get_real_value(t,e.slice(1)):e}function push_token$3(e,t,r,n,i){t===state_var||t===state_integer_padding&&var_char.includes(r[0])?(i.has_var=!0,e.push({type:t,value:r,real_value:get_real_value(i.fill_data,r)})):e.push({type:t,value:r}),n.prev=n.curr,i.state=state_initial}function fmt_tokenizer(e,t){for(var r,n={prev:0,curr:0},i=e.length,a={state:state_initial,fill_data:t,has_var:!1},o=[];n.curr<i;)switch(r=e[n.curr],a.state){case state_initial:if(" "===r)n.curr++,n.prev=n.curr;else if("<>=".includes(r))a.state=state_symbol,n.curr++;else if(","===r)n.curr++,push_token$3(o,state_comma,",",n,a);else if(var_char.includes(r))a.state=state_var,n.curr++;else if(number_char.includes(r))a.state=state_number,n.curr++;else if("+"===r)n.curr++,push_token$3(o,state_plus,"+",n,a);else if("~"===r)n.curr++,a.state=state_round;else if("%"===r)n.curr++,push_token$3(o,state_percent,"%",n,a);else if("/"===r)n.curr++,push_token$3(o,state_fraction,"/",n,a);else if("!"===r)if(a.state=state_initial,n.curr++,"n"===e[n.curr])n.curr++,push_token$3(o,state_to_number,"!n",n,a);else if("u"===e[n.curr]){n.curr++;var s=e[n.curr];if("a"===s||"b"===s||"m"===s){if(n.curr++,":"===e[n.curr]){n.curr++;for(var _=n.curr;n.curr<i&&" "!==e[n.curr];)n.curr++;var u=e.slice(_,n.curr).split(":"),c=resolve_unit_value$1(u[0],a.fill_data),l=u[1]?resolve_unit_value$1(u[1],a.fill_data):null;(u[0].startsWith("@")||u[1]&&u[1].startsWith("@"))&&(a.has_var=!0);var p={a:state_unit_after,b:state_unit_before,m:state_unit_middle};o.push({type:p[s],value:"!u".concat(s),unit:c,input_unit:l})}else{var d={a:state_unit_after,b:state_unit_before,m:state_unit_middle};o.push({type:d[s],value:"!u".concat(s),unit:null,input_unit:null,use_default:!0})}n.prev=n.curr,a.state=state_initial}else if("h"===s){if(n.curr++,":"===e[n.curr]){n.curr++;for(var f=n.curr;n.curr<i&&" "!==e[n.curr];)n.curr++;var g=e.slice(f,n.curr).split(":"),m=resolve_unit_value$1(g[0],a.fill_data),v=g[1]?resolve_unit_value$1(g[1],a.fill_data):null;(g[0].startsWith("@")||g[1]&&g[1].startsWith("@"))&&(a.has_var=!0),o.push({type:state_unit_hide,value:"!uh",unit:m,input_unit:v})}else{var h=get_config("_unit_default_out");if(h){var w=Array.isArray(h)?h[0]:h;o.push({type:state_unit_hide,value:"!uh",unit:w,input_unit:null})}else o.push({type:state_to_number_string,value:"!uh"})}n.prev=n.curr,a.state=state_initial}else if(":"===e[n.curr]){n.curr++;for(var b=n.curr;n.curr<i&&" "!==e[n.curr];)n.curr++;var y=e.slice(b,n.curr).split(":"),x=resolve_unit_value$1(y[0],a.fill_data),S=y[1]?resolve_unit_value$1(y[1],a.fill_data):null;(y[0].startsWith("@")||y[1]&&y[1].startsWith("@"))&&(a.has_var=!0),o.push({type:state_unit_default,value:"!u",unit:x,input_unit:S}),n.prev=n.curr,a.state=state_initial}else{var E=get_config("_unit_default_out");if(E){var A=Array.isArray(E)?E[0]:E;o.push({type:state_unit_default,value:"!u",unit:A,input_unit:null}),n.prev=n.curr,a.state=state_initial}else push_token$3(o,state_to_number_string,"!u",n,a)}}else if("e"===e[n.curr])n.curr++,push_token$3(o,state_scientific,"!e",n,a);else if("c"===e[n.curr]){n.curr++;var T=null;if(":"===e[n.curr]){n.curr++;for(var N=n.curr;n.curr<i&&/[a-zA-Z0-9_]/.test(e[n.curr]);)n.curr++;T=e.slice(N,n.curr)}o.push({type:state_compact,value:"!c",preset:T}),n.prev=n.curr,a.state=state_initial}else if("i"===e[n.curr]){if(n.curr++,":"!==e[n.curr])throw new Error("!i 语法需要指定位数,格式: !i:n");n.curr++;var D=n.curr;if("@"===e[n.curr]){for(n.curr++;n.curr<i&&var_members_char.includes(e[n.curr]);)n.curr++;var k=e.slice(D+1,n.curr),O=get_real_value(a.fill_data,k);a.has_var=!0,o.push({type:state_integer_padding,value:k,real_value:O})}else{for(;n.curr<i&&number_char.includes(e[n.curr]);)n.curr++;var P=e.slice(D,n.curr);o.push({type:state_integer_padding,value:P})}n.prev=n.curr,a.state=state_initial}else if("t"===e[n.curr])if(n.curr++,":"!==e[n.curr])o.push({type:state_thousands,value:"!t",preset:"default"}),n.prev=n.curr,a.state=state_initial;else{n.curr++;var M=n.curr;if("@"===e[n.curr]){for(n.curr++;n.curr<i&&var_members_char.includes(e[n.curr]);)n.curr++;var L=e.slice(M+1,n.curr),I=get_real_value(a.fill_data,L);a.has_var=!0,o.push({type:state_thousands,value:"!t",preset:I,preset_var:L})}else{for(;n.curr<i&&/[a-zA-Z0-9_]/.test(e[n.curr]);)n.curr++;var W=e.slice(M,n.curr);o.push({type:state_thousands,value:"!t",preset:W})}n.prev=n.curr,a.state=state_initial}else{if("g"!==e[n.curr])throw new Error("无法识别的!模式字符:".concat(e[n.curr]));if(n.curr++,":"!==e[n.curr])throw new Error("!g 语法需要指定分组名称,格式: !g:name");if(n.curr++,"@"===e[n.curr]){n.curr++;for(var j=n.curr;n.curr<i&&var_members_char.includes(e[n.curr]);)n.curr++;var C=e.slice(j,n.curr),F=get_real_value(a.fill_data,C);a.has_var=!0,o.push({type:state_fmt_group,value:"!g",group_name:F,var_path:C})}else{for(var R=n.curr;n.curr<i&&/[a-zA-Z0-9_]/.test(e[n.curr]);)n.curr++;var q=e.slice(R,n.curr);o.push({type:state_fmt_group,value:"!g",group_name:q})}n.prev=n.curr,a.state=state_initial}else if("#"===r)if(n.curr++,"@"===e[n.curr]){n.curr++;for(var V=n.curr;n.curr<i&&var_members_char.includes(e[n.curr]);)n.curr++;var $=e.slice(V,n.curr),B=get_real_value(a.fill_data,$);a.has_var=!0,o.push({type:state_fmt_group,value:"#",group_name:B,var_path:$}),n.prev=n.curr,a.state=state_initial}else{for(var G=n.curr;n.curr<i&&/[a-zA-Z0-9_]/.test(e[n.curr]);)n.curr++;var U=e.slice(G,n.curr);U?(o.push({type:state_fmt_group,value:"#",group_name:U}),n.prev=n.curr,a.state=state_initial):(n.prev=n.curr,a.state=state_initial)}else if("["===r){for(n.curr++;n.curr<i&&" "===e[n.curr];)n.curr++;var z=n.curr,H=void 0;if("@"===e[n.curr]){for(n.curr++;n.curr<i&&/[a-zA-Z0-9_$.]/.test(e[n.curr]);)n.curr++;var Z=e.slice(z+1,n.curr);H=get_real_value(a.fill_data,Z),a.has_var=!0}else{for("-"!==e[n.curr]&&"+"!==e[n.curr]||n.curr++;n.curr<i&&(number_char.includes(e[n.curr])||"."===e[n.curr]);)n.curr++;H=e.slice(z,n.curr)}for(;n.curr<i&&" "===e[n.curr];)n.curr++;for(","===e[n.curr]&&n.curr++;n.curr<i&&" "===e[n.curr];)n.curr++;var X=n.curr,K=void 0;if("@"===e[n.curr]){for(n.curr++;n.curr<i&&/[a-zA-Z0-9_$.]/.test(e[n.curr]);)n.curr++;var Y=e.slice(X+1,n.curr);K=get_real_value(a.fill_data,Y),a.has_var=!0}else{for("-"!==e[n.curr]&&"+"!==e[n.curr]||n.curr++;n.curr<i&&(number_char.includes(e[n.curr])||"."===e[n.curr]);)n.curr++;K=e.slice(X,n.curr)}for(;n.curr<i&&" "===e[n.curr];)n.curr++;"]"===e[n.curr]&&n.curr++,o.push({type:state_range_clamp,min:""===H?null:H,max:""===K?null:K}),n.prev=n.curr,a.state=state_initial}else":"===r?(a.state=state_shortcut,n.curr++):(n.curr++,n.prev=n.curr);break;case state_symbol:"="===r&&n.curr++,push_token$3(o,state_symbol,e.slice(n.prev,n.curr),n,a);break;case state_number:number_char.includes(r)?n.curr++:push_token$3(o,state_number,e.slice(n.prev,n.curr),n,a);break;case state_var:var_members_char.includes(r)?n.curr++:push_token$3(o,state_var,e.slice(n.prev,n.curr),n,a);break;case state_round:if(!("56+-".includes(r)&&n.curr-n.prev<2))throw new Error("错误的舍入语法:".concat(e.slice(n.prev,n.curr+1)));n.curr++,push_token$3(o,state_round,e.slice(n.prev,n.curr),n,a);break;case state_integer_padding:if(number_char.includes(r))n.curr++;else if(var_members_char.includes(r))n.curr++;else{var J=e.slice(n.prev,n.curr);var_char.includes(J[0])?(a.has_var=!0,o.push({type:state_integer_padding,value:J,real_value:get_real_value(a.fill_data,J)})):push_token$3(o,state_integer_padding,J,n,a),n.prev=n.curr,a.state=state_initial}break;case state_shortcut:for(var Q=n.curr,ee=new Set([",","=","+","<",">","~","!","[","/","%","-"]);n.curr<i&&" "!==e[n.curr]&&!ee.has(e[n.curr]);)n.curr++;var te=e.slice(Q,n.curr);if(!te){n.prev=n.curr,a.state=state_initial;break}var re,ne=get_config("_shortcut_prefix")||"!u",ie=fmt_tokenizer("".concat(ne,":").concat(te),a.fill_data),ae=_createForOfIteratorHelper(ie);try{for(ae.s();!(re=ae.n()).done;){var oe=re.value;o.push(oe)}}catch(e){ae.e(e)}finally{ae.f()}ie.has_var&&(a.has_var=!0),n.prev=n.curr,a.state=state_initial;break;default:throw new Error("错误的fmt分词器状态")}return n.prev<n.curr&&push_token$3(o,a.state,e.slice(n.prev,n.curr),n,a),o.has_var=a.has_var,o}var symbol_set=new Set(["<",">","=",">=","<="]),round_set=new Set(["~+","~-","~5","~6"]);function resolve_unit_value(e,t){return e&&e.startsWith("@")?get_real_value(t,e.slice(1)):e}function create_token_from_string(e,t){var r=t.scope;if(","===e)return{type:state_comma,value:","};if(symbol_set.has(e))return{type:state_symbol,value:e};if(!Number.isNaN(Number(e)))return{type:state_number,value:e};if(var_first_char.includes(e[0]))return r.has_var=!0,{type:state_var,value:e,real_value:get_real_value(r.fill_data,e)};if("%"===e)return{type:state_percent,value:e};if("/"===e)return{type:state_fraction,value:e};if("+"===e)return{type:state_plus,value:e};if(round_set.has(e))return{type:state_round,value:e};if("!n"===e)return{type:state_to_number,value:e};if("!u"===e)return{type:state_to_number_string,value:e};if("!uh"===e)return{type:state_to_number_string,value:e};if(e.startsWith("!uh:")){var n=e.slice(4).split(":"),i=resolve_unit_value(n[0],r.fill_data),a=n[1]?resolve_unit_value(n[1],r.fill_data):null;return(n[0].startsWith("@")||n[1]&&n[1].startsWith("@"))&&(r.has_var=!0),{type:state_unit_hide,value:"!uh",unit:i,input_unit:a}}if(e.startsWith("!u:")){var o=e.slice(3).split(":"),s=resolve_unit_value(o[0],r.fill_data),_=o[1]?resolve_unit_value(o[1],r.fill_data):null;return(o[0].startsWith("@")||o[1]&&o[1].startsWith("@"))&&(r.has_var=!0),{type:state_unit_default,value:"!u",unit:s,input_unit:_}}if(e.startsWith("!ua:")||e.startsWith("!ub:")||e.startsWith("!um:")){var u=e[2],c=e.slice(4).split(":"),l=resolve_unit_value(c[0],r.fill_data),p=c[1]?resolve_unit_value(c[1],r.fill_data):null;return(c[0].startsWith("@")||c[1]&&c[1].startsWith("@"))&&(r.has_var=!0),{type:{a:state_unit_after,b:state_unit_before,m:state_unit_middle}[u],value:"!u".concat(u),unit:l,input_unit:p}}if("!ua"===e||"!ub"===e||"!um"===e){var d=e[2];return"b"===d?null:{type:{a:state_unit_after,m:state_unit_middle}[d],value:"!u".concat(d),unit:null,input_unit:null,use_default:!0}}if("!e"===e)return{type:state_scientific,value:e};if("!c"===e||e.startsWith("!c:")){var f=e.startsWith("!c:")?e.slice(3):null;return{type:state_compact,value:"!c",preset:f}}if(e.startsWith("!i:")){var g=e.slice(3);if(g.startsWith("@")){var m=g.slice(1),v=get_real_value(r.fill_data,m);return r.has_var=!0,{type:state_integer_padding,value:m,real_value:v}}return{type:state_integer_padding,value:g}}if("!t"===e||e.startsWith("!t:")){if("!t"===e)return{type:state_thousands,value:"!t",preset:"default"};var h=e.slice(3);if(h.startsWith("@")){var w=h.slice(1),b=get_real_value(r.fill_data,w);return r.has_var=!0,{type:state_thousands,value:"!t",preset:b,preset_var:w}}return{type:state_thousands,value:"!t",preset:h}}if(e.startsWith("!g:")){var y=e.slice(3);if(y.startsWith("@")){var x=y.slice(1),S=get_real_value(r.fill_data,x);return r.has_var=!0,{type:state_fmt_group,value:"!g",group_name:S,var_path:x}}return{type:state_fmt_group,value:"!g",group_name:y}}if(e.startsWith("#")){var E=e.slice(1);if(E.startsWith("@")){var A=E.slice(1),T=get_real_value(r.fill_data,A);return r.has_var=!0,"number"==typeof T||/^\d+$/.test(String(T))?{type:state_integer_padding,value:A,real_value:T}:{type:state_fmt_group,value:"#",group_name:T,var_path:A}}E.startsWith("=")&&(E=E.slice(1));var N=/^\d+$/.test(E),D=var_first_char.includes(E[0]);return N||D?D?(r.has_var=!0,{type:state_integer_padding,value:E,real_value:get_real_value(r.fill_data,E)}):{type:state_integer_padding,value:E}:{type:state_fmt_group,value:"#",group_name:E}}if(e.startsWith("[")&&e.endsWith("]")){var k=e.slice(1,-1).split(","),O=null,P=null;if(k[0]){var M=k[0].trim();if(M.startsWith("@")){var L=M.slice(1);O=get_real_value(r.fill_data,L),r.has_var=!0}else O=M}if(k[1]){var I=k[1].trim();if(I.startsWith("@")){var W=I.slice(1);P=get_real_value(r.fill_data,W),r.has_var=!0}else P=I}return{type:state_range_clamp,min:O,max:P}}throw new Error("无法识别的格式化字符: ".concat(e))}function push_token$2(e,t,r){var n=create_token_from_string(t,{scope:r});n&&e.push(n)}function fmt_tokenizer_space(e,t){for(var r,n=0,i=e.length,a={fill_data:t,has_var:!1},o=0,s=[];n<i;)" "===(r=e[n])?(n>o&&push_token$2(s,e.slice(o,n),a),o=n+1):"<>=".includes(r)&&("="===e[n+1]?(s.push({type:state_symbol,value:r+"="}),o=1+ ++n):(s.push({type:state_symbol,value:r}),o=n+1)),n++;return o<n&&push_token$2(s,e.slice(o,n),a),s.has_var=a.has_var,s}var _default_config={_debug_console:!0,_error:"-",_angle_unit:"deg",_builtin_functions:{},_compute_mode:"decimal",_div_precision:20,_default_round:void 0,_fmt:void 0,_fmt_parsed:void 0,_compact:{},_compact_default:void 0,_fmt_groups:{},_fmt_groups_parsed:{},_thousands:{},_thousands_default:void 0,_unit_convert_out:void 0,_unit_convert_in:void 0,_unit_default_out:void 0,_unit_default_in:void 0,_unit_position_map:void 0,_unit_default_position:void 0,_unit_thousands_map:void 0,_unit_compact_map:void 0,_shortcut_prefix:"!u",_empty_values:void 0,_empty_check:void 0},_global_config=_objectSpread2({},_default_config),VALID_COMPUTE_MODES=new Set(["decimal","bigint","wasm"]),config_listeners={};function on_config_change(e,t){config_listeners[e]||(config_listeners[e]=[]),config_listeners[e].push(t)}function extract_display_properties(e){var t={},r={},n={};if(!e)return{thousands:t,positions:r,compacts:n};for(var i in e){var a=e[i];if("object"===_typeof(a)&&null!==a)for(var o in a._thousands&&!t[i]&&(t[i]=a._thousands),a._position&&!r[i]&&(r[i]=a._position),a._compact&&!n[i]&&(n[i]=a._compact),a)if(!o.startsWith("_")){var s=a[o];"object"===_typeof(s)&&null!==s&&(s._thousands&&!t[i]&&(t[i]=s._thousands),s._position&&!r[i]&&(r[i]=s._position),s._compact&&!n[i]&&(n[i]=s._compact))}}return{thousands:t,positions:r,compacts:n}}function convert_unit_in_to_out(e){if(!e)return null;var t={};for(var r in e){var n=e[r];for(var i in n){var a=n[i];if(t[i]||(t[i]={}),"object"===_typeof(a)&&null!==a){if(a._thousands&&!t[i]._thousands&&(t[i]._thousands=a._thousands),a._position&&!t[i]._position&&(t[i]._position=a._position),a._compact&&!t[i]._compact&&(t[i]._compact=a._compact),a.fn)t[i][r]={fn:a.fn};else if(void 0!==a.mul)t[i][r]={mul:a.mul};else if(void 0!==a.div)t[i][r]={div:a.div};else if(void 0!==a.add||void 0!==a.sub||void 0!==a.minus){var o={};void 0!==a.add&&(o.add=a.add),void 0!==a.sub&&(o.sub=a.sub),void 0!==a.minus&&(o.minus=a.minus),t[i][r]=o}}else t[i][r]=a}}return t}function validate_shortcut_prefix(e){if("string"!=typeof e)return console.warn("_shortcut_prefix must be a string, got: ".concat(_typeof(e))),null;if(!e.startsWith("!"))return console.warn("_shortcut_prefix must start with '!', got: ".concat(e)),null;var t=e;e.endsWith(":")&&(t=e.slice(0,-1));var r=["!u","!t","!c","!n","!e","!i","!g","!ua","!ub","!um","!uh"];return r.includes(t)?t:(console.warn("_shortcut_prefix must be one of: ".concat(r.join(", "),", got: ").concat(e)),null)}function set_config(e){if(e&&"object"===_typeof(e))for(var t=function(){var t=n[r],i=e[t];if("_unit_convert_out"===t&&"object"===_typeof(i)){var a=extract_display_properties(i);return _global_config._unit_thousands_map||(_global_config._unit_thousands_map={}),_global_config._unit_position_map||(_global_config._unit_position_map={}),_global_config._unit_compact_map||(_global_config._unit_compact_map={}),_global_config._unit_thousands_map=_objectSpread2(_objectSpread2({},a.thousands),_global_config._unit_thousands_map),_global_config._unit_position_map=_objectSpread2(_objectSpread2({},a.positions),_global_config._unit_position_map),_global_config._unit_compact_map=_objectSpread2(_objectSpread2({},a.compacts),_global_config._unit_compact_map),_global_config._unit_convert_out=i,"continue"}if("_unit_convert_in"===t&&"object"===_typeof(i)&&null!==i){var o=convert_unit_in_to_out(i),s=extract_display_properties(o);if(_global_config._unit_thousands_map||(_global_config._unit_thousands_map={}),_global_config._unit_position_map||(_global_config._unit_position_map={}),_global_config._unit_compact_map||(_global_config._unit_compact_map={}),_global_config._unit_thousands_map=_objectSpread2(_objectSpread2({},s.thousands),_global_config._unit_thousands_map),_global_config._unit_position_map=_objectSpread2(_objectSpread2({},s.positions),_global_config._unit_position_map),_global_config._unit_compact_map=_objectSpread2(_objectSpread2({},s.compacts),_global_config._unit_compact_map),_global_config._unit_convert_out)for(var _ in o)_global_config._unit_convert_out[_]?_global_config._unit_convert_out[_]=_objectSpread2(_objectSpread2({},_global_config._unit_convert_out[_]),o[_]):_global_config._unit_convert_out[_]=o[_];else _global_config._unit_convert_out=o;return _global_config._unit_convert_in=void 0,"continue"}if("_builtin_functions"===t&&"object"===_typeof(i))Object.assign(_global_config._builtin_functions,i);else if("_compact"===t&&"object"===_typeof(i))Object.assign(_global_config._compact,i);else if("_thousands"===t&&"object"===_typeof(i))Object.assign(_global_config._thousands,i);else if("_unit_compact_map"===t&&"object"===_typeof(i))_global_config._unit_compact_map||(_global_config._unit_compact_map={}),Object.assign(_global_config._unit_compact_map,i);else if("_unit_thousands_map"===t&&"object"===_typeof(i))_global_config._unit_thousands_map||(_global_config._unit_thousands_map={}),Object.assign(_global_config._unit_thousands_map,i);else if("_unit_position_map"===t&&"object"===_typeof(i))_global_config._unit_position_map||(_global_config._unit_position_map={}),Object.assign(_global_config._unit_position_map,i);else if("_fmt_groups"===t&&"object"===_typeof(i)){Object.assign(_global_config._fmt_groups,i);var u=_global_config._fmt_groups;config_listeners._fmt_groups&&config_listeners._fmt_groups.forEach((function(e){return e(_global_config._fmt_groups,u)}))}else if("_fmt"===t){var c=_global_config._fmt,l=i;c!==l&&(_global_config._fmt=l,config_listeners._fmt&&config_listeners._fmt.forEach((function(e){return e(l,c)})))}else if("_compute_mode"===t){var p=i;if(!VALID_COMPUTE_MODES.has(p))return console.warn("Unknown compute mode: ".concat(p,", available modes: ").concat(_toConsumableArray(VALID_COMPUTE_MODES).join(", "))),"continue";var d=_global_config[t];d!==p&&(_global_config[t]=p,config_listeners[t]&&config_listeners[t].forEach((function(e){return e(p,d)})))}else if("_shortcut_prefix"===t){var f=validate_shortcut_prefix(i);if(!f)return"continue";var g=_global_config[t],m=f;g!==m&&(_global_config[t]=m,config_listeners[t]&&config_listeners[t].forEach((function(e){return e(m,g)})))}else if(t in _global_config){var v=_global_config[t],h=i;v!==h&&(_global_config[t]=h,config_listeners[t]&&config_listeners[t].forEach((function(e){return e(h,v)})))}},r=0,n=Object.keys(e);r<n.length;r++)t()}function get_config(e){return void 0===e?_objectSpread2({},_global_config):_global_config[e]}function reset_config(e){if(void 0===e)for(var t=Object.keys(_global_config),r=function(){var e=i[n],t=_global_config[e],r=_default_config[e];"object"===_typeof(r)&&null!==r?_global_config[e]=Array.isArray(r)?_toConsumableArray(r):_objectSpread2({},r):_global_config[e]=r,t!==_global_config[e]&&config_listeners[e]&&config_listeners[e].forEach((function(r){return r(_global_config[e],t)}))},n=0,i=t;n<i.length;n++)r();else{var a,o=_createForOfIteratorHelper(Array.isArray(e)?e:[e]);try{var s=function(){var e=a.value;if(e in _default_config){var t=_global_config[e],r=_default_config[e];if("object"===_typeof(r)&&null!==r?_global_config[e]=Array.isArray(r)?_toConsumableArray(r):_objectSpread2({},r):_global_config[e]=r,("_unit_compact_map"===e||"_unit_thousands_map"===e||"_unit_position_map"===e)&&_global_config._unit_convert_out){var n=extract_display_properties(_global_config._unit_convert_out);"_unit_compact_map"===e&&Object.keys(n.compacts).length>0&&(_global_config._unit_compact_map=n.compacts),"_unit_thousands_map"===e&&Object.keys(n.thousands).length>0&&(_global_config._unit_thousands_map=n.thousands),"_unit_position_map"===e&&Object.keys(n.positions).length>0&&(_global_config._unit_position_map=n.positions)}t!==_global_config[e]&&config_listeners[e]&&config_listeners[e].forEach((function(r){return r(_global_config[e],t)}))}};for(o.s();!(a=o.n()).done;)s()}catch(e){o.e(e)}finally{o.f()}}}function close_important_push(){}function open_important_push(){}if(on_config_change("_fmt",(function(e,t){if(null!=e&&""!==e){if("string"!=typeof e)return console.warn("_fmt must be a string, got: ".concat(_typeof(e))),void(_global_config._fmt_parsed=void 0);try{var r=fmt_tokenizer(e,null);_global_config._fmt_parsed=r}catch(t){console.warn('Failed to parse _fmt: "'.concat(e,'":'),t),_global_config._fmt_parsed=void 0}}else _global_config._fmt_parsed=void 0})),_global_config._fmt)try{var tokens_standard=fmt_tokenizer(_global_config._fmt,null);_global_config._fmt_parsed=tokens_standard}catch(e){console.warn('Failed to parse initial _fmt: "'.concat(_global_config._fmt,'":'),e),_global_config._fmt_parsed=void 0}function split_expr_and_fmt(e){for(var t=0,r=0;r<e.length;r++){var n=e[r];if("("===n)t++;else if(")"===n)t--;else if("|"===n&&0===t){if(r+1<e.length&&"|"===e[r+1]){r++;continue}return{expr:e.slice(0,r),fmt:e.slice(r+1).trim()}}}return{expr:e,fmt:""}}function parse_args(e,t){var r,n,i="",a={origin_expr:e,origin_fill_data:t,expr:"",fmt_expr:"",options:void 0,fill_data:void 0,_unit:void 0,_empty_values:void 0,_empty_check:void 0,_compact_symbols:void 0,_compact_step:void 0,_thousands:void 0};if(null!=t&&(a.options=t,Array.isArray(t)?a.fill_data=t:a.fill_data=[t]),a._unit=find_value(t,"_unit",!1),a._empty_values=null!==(r=find_value(t,"_empty_values"))&&void 0!==r?r:get_config("_empty_values"),a._empty_check=null!==(n=find_value(t,"_empty_check"))&&void 0!==n?n:get_config("_empty_check"),a._compact_symbols=find_value(t,"_compact_symbols"),a._compact_step=find_value(t,"_compact_step"),a._thousands=find_value(t,"_thousands"),"string"==typeof e){if(i=e,""===e.trim()||e.includes("NaN"))throw new Error("非法的表达式:".concat(e))}else{if("number"!=typeof e)throw new Error("错误的第一个参数类型: ".concat(e," 类型为:").concat(_typeof(e)));if(isNaN(e))throw new Error("传入了一个非法数字NaN");i=e.toString()}var o=split_expr_and_fmt(i),s=o.expr,_=o.fmt;return a.expr=s,a.fmt_expr=_,a}function detect_fallback_var$1(e,t){if("("!==e[t])return null;for(var r=0,n=!1,i=[],a="",o=t;o<e.length;){var s=e[o];if("("===s){if(0===r){r++,o++;continue}r++,a+=s}else if(")"===s){if(0===--r)return n?(i.push(a.trim()),{paths:i,end_index:o}):null;a+=s}else"|"===s&&1===r?(n=!0,i.push(a.trim()),a=""):a+=s;o++}return null}function detect_function_call(e,t,r){for(var n=t;n<e.length&&" "===e[n];)n++;return n<e.length&&"("===e[n]}function parse_function_args(e,t){if("("!==e[t])return null;for(var r=1,n=[],i="",a=t+1;a<e.length&&r>0;){var o=e[a];if("("===o)r++,i+=o;else if(")"===o){if(0===--r)return i.trim()&&n.push(i.trim()),{args:n,end_index:a};i+=o}else","===o&&1===r?(n.push(i.trim()),i=""):i+=o;a++}return null}function push_token$1(e,t){if(t.curr_state===state_number||t.curr_state===state_scientific){var r=t.expr.slice(t.prev_index,t.cur_index);if("+"===r||"-"===r)return e.push({type:state_operator,value:r}),t.curr_state=state_initial,void(t.prev_index=t.cur_index);if(t._unit){var n,i=split_unit_num(r),a=i.num,o=i.unit;if(void 0===o)e.push({type:state_number,value:a,real_value:a,has_unit:!1});else t.has_unit=!0,null!==(n=t.unit_str)&&void 0!==n||(t.unit_str=o),e.push({type:state_number,value:a,real_value:a,has_unit:!0,unit:o})}else e.push({type:state_number,value:r,real_value:r,has_unit:!1})}else if(t.curr_state===state_var){t.has_var=!0;var s=t.expr.slice(t.prev_index,t.cur_index);if("true"===s)e.push({type:"boolean",value:!0});else if("false"===s)e.push({type:"boolean",value:!1});else if(detect_function_call(t.expr,t.cur_index)){for(var _=t.cur_index;_<t.expr.length&&" "===t.expr[_];)_++;var u=parse_function_args(t.expr,_);if(u)return e.push({type:state_function,value:s,args:u.args}),t.cur_index=u.end_index+1,t.prev_index=t.cur_index,void(t.curr_state=state_initial)}else{var c=get_real_value(t.fill_data,s);if("function"==typeof c){for(var l=t.cur_index;l<t.expr.length&&" "===t.expr[l];)l++;if(l<t.expr.length&&"("===t.expr[l]){var p=parse_function_args(t.expr,l);if(p)return e.push({type:state_function,value:s,args:p.args,fn:c}),t.cur_index=p.end_index+1,t.prev_index=t.cur_index,void(t.curr_state=state_initial)}}if(t._unit){var d,f=split_unit_num(c),g=f.num,m=f.unit;if(void 0===m)e.push({type:"var",value:s,real_value:g,has_unit:!1});else t.has_unit=!0,null!==(d=t.unit_str)&&void 0!==d||(t.unit_str=m),e.push({type:"var",value:s,real_value:g,has_unit:!0,unit:m})}else e.push({type:"var",value:s,real_value:c,has_unit:!1})}}else e.push({type:t.curr_state,value:t.expr.slice(t.prev_index,t.cur_index)});t.curr_state=state_initial,t.prev_index=t.cur_in