w-trade-solve 1.0.1

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.
Files changed (88) hide show
  1. package/.editorconfig +9 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.js +55 -0
  4. package/.jsdoc +25 -0
  5. package/README.md +132 -0
  6. package/SECURITY.md +5 -0
  7. package/babel.config.js +16 -0
  8. package/dist/w-trade-solve.umd.js +19 -0
  9. package/dist/w-trade-solve.umd.js.map +1 -0
  10. package/docs/calcFitness.mjs.html +205 -0
  11. package/docs/calcLevelNumTrade.mjs.html +164 -0
  12. package/docs/cont.mjs.html +94 -0
  13. package/docs/estimComps.mjs.html +190 -0
  14. package/docs/estimFinder.mjs.html +197 -0
  15. package/docs/estimKeys.mjs.html +571 -0
  16. package/docs/estimPicks.mjs.html +200 -0
  17. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  18. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  19. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  20. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  21. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  22. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  23. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  24. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  25. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  26. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  27. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  28. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  29. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  30. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  31. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  32. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  33. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  34. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  35. package/docs/genSid.mjs.html +125 -0
  36. package/docs/genStrategyFileName.mjs.html +131 -0
  37. package/docs/genTid.mjs.html +113 -0
  38. package/docs/global.html +4932 -0
  39. package/docs/index.html +84 -0
  40. package/docs/ott.mjs.html +137 -0
  41. package/docs/p2r.mjs.html +111 -0
  42. package/docs/readStrategies.mjs.html +203 -0
  43. package/docs/scripts/collapse.js +39 -0
  44. package/docs/scripts/commonNav.js +28 -0
  45. package/docs/scripts/linenumber.js +25 -0
  46. package/docs/scripts/nav.js +12 -0
  47. package/docs/scripts/polyfill.js +4 -0
  48. package/docs/scripts/prettify/Apache-License-2.0.txt +202 -0
  49. package/docs/scripts/prettify/lang-css.js +2 -0
  50. package/docs/scripts/prettify/prettify.js +28 -0
  51. package/docs/scripts/search.js +99 -0
  52. package/docs/styles/jsdoc.css +776 -0
  53. package/docs/styles/prettify.css +80 -0
  54. package/g.mjs +110 -0
  55. package/package.json +31 -0
  56. package/script.txt +19 -0
  57. package/src/WTradeSolve.mjs +29 -0
  58. package/src/calcFitness.mjs +133 -0
  59. package/src/calcLevelNumTrade.mjs +92 -0
  60. package/src/cont.mjs +22 -0
  61. package/src/estimComps.mjs +118 -0
  62. package/src/estimFinder.mjs +125 -0
  63. package/src/estimKeys.mjs +499 -0
  64. package/src/estimPicks.mjs +128 -0
  65. package/src/genSid.mjs +53 -0
  66. package/src/genStrategyFileName.mjs +59 -0
  67. package/src/genTid.mjs +41 -0
  68. package/src/ott.mjs +65 -0
  69. package/src/p2r.mjs +39 -0
  70. package/src/readStrategies.mjs +131 -0
  71. package/test/unit-WTradeSolve.test.mjs +83 -0
  72. package/test/unit-calcFitness.test.mjs +121 -0
  73. package/test/unit-calcLevelNumTrade.test.mjs +80 -0
  74. package/test/unit-estimComps.test.mjs +193 -0
  75. package/test/unit-estimFinder.test.mjs +184 -0
  76. package/test/unit-estimKeys.test.mjs +260 -0
  77. package/test/unit-estimPicks.test.mjs +241 -0
  78. package/test/unit-genSid.test.mjs +75 -0
  79. package/test/unit-genStrategyFileName.test.mjs +85 -0
  80. package/test/unit-genTid.test.mjs +72 -0
  81. package/test/unit-p2r.test.mjs +51 -0
  82. package/test/unit-readStrategies.test.mjs +258 -0
  83. package/test/unit-setup.mjs +119 -0
  84. package/toolg/addVersion.mjs +4 -0
  85. package/toolg/cleanFolder.mjs +5 -0
  86. package/toolg/gDistRollup.mjs +37 -0
  87. package/toolg/gDocsExams.mjs +48 -0
  88. package/toolg/modifyReadme.mjs +4 -0
package/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 4
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
package/.eslintignore ADDED
@@ -0,0 +1,3 @@
1
+ /build/
2
+ /config/
3
+ /dist/
package/.eslintrc.js ADDED
@@ -0,0 +1,55 @@
1
+ module.exports = {
2
+ 'env': {
3
+ 'browser': true,
4
+ 'es6': true,
5
+ 'mocha': true
6
+ },
7
+ 'extends': ['plugin:vue/base', 'plugin:vue/essential', 'standard'],
8
+ 'plugins': [
9
+ 'vue'
10
+ ],
11
+ 'globals': {
12
+ 'Atomics': 'readonly',
13
+ 'SharedArrayBuffer': 'readonly'
14
+ },
15
+ 'parser': 'vue-eslint-parser',
16
+ 'parserOptions': {
17
+ 'parser': '@babel/eslint-parser',
18
+ 'ecmaVersion': 2019,
19
+ 'sourceType': 'module',
20
+ },
21
+ 'rules': {
22
+ 'generator-star-spacing': 'off',
23
+ 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
24
+ 'indent': ['error', 4],
25
+ 'no-console': 'off',
26
+ 'comma-dangle': ['error', {
27
+ 'arrays': 'ignore',
28
+ 'objects': 'ignore',
29
+ 'imports': 'never',
30
+ 'exports': 'never',
31
+ 'functions': 'ignore'
32
+ }],
33
+ 'no-multiple-empty-lines': ['error', { 'max': 2, 'maxEOF': 2 }],
34
+ //'space-before-function-paren': ['error', { 'anonymous': 'always', 'named': 'never' }],
35
+ 'space-before-function-paren': 'off',
36
+ 'spaced-comment': 'off',
37
+ 'brace-style': ['error', 'stroustrup'],
38
+ 'padded-blocks': 'off',
39
+ 'no-constant-condition': 'off',
40
+ 'camelcase': 'off',
41
+ 'no-new': 'off',
42
+ 'prefer-const': 'off',
43
+ 'quote-props': ['error', 'consistent'],
44
+ 'dot-notation': 'off',
45
+ 'standard/no-callback-literal': 'off',
46
+ 'quotes': ['error', 'single', { 'allowTemplateLiterals': true }],
47
+ 'prefer-promise-reject-errors': 'off',
48
+ 'no-unused-vars': ['error', { 'args': 'none', 'ignoreRestSiblings': true, 'argsIgnorePattern': '^_' }],
49
+ 'node/no-callback-literal': 'off',
50
+ 'prefer-regex-literals': 'off',
51
+ 'array-callback-return': 'off',
52
+ 'no-unreachable-loop': 'off',
53
+ 'vue/multi-word-component-names': 'off',
54
+ }
55
+ }
package/.jsdoc ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "tags": {
3
+ "allowUnknownTags": false
4
+ },
5
+ "source": {
6
+ "include": ["src/", "server/"],
7
+ "includePattern": ".+\\.(js(doc|x)?|mjs|vue)$",
8
+ "excludePattern": "(node_modules/|docs)"
9
+ },
10
+ "plugins": [
11
+ "plugins/markdown",
12
+ "node_modules/jsdoc-vuejs"
13
+ ],
14
+ "opts": {
15
+ "template": "node_modules/docdash",
16
+ "encoding": "utf8",
17
+ "destination": "docs/",
18
+ "recurse": true,
19
+ "verbose": true
20
+ },
21
+ "templates": {
22
+ "cleverLinks": false,
23
+ "monospaceLinks": false
24
+ }
25
+ }
package/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # w-trade-solve
2
+ A tool for solve trade params.
3
+
4
+ ![language](https://img.shields.io/badge/language-JavaScript-orange.svg)
5
+ [![npm version](http://img.shields.io/npm/v/w-trade-solve.svg?style=flat)](https://npmjs.org/package/w-trade-solve)
6
+ [![license](https://img.shields.io/npm/l/w-trade-solve.svg?style=flat)](https://npmjs.org/package/w-trade-solve)
7
+ [![npm download](https://img.shields.io/npm/dt/w-trade-solve.svg)](https://npmjs.org/package/w-trade-solve)
8
+ [![npm download](https://img.shields.io/npm/dm/w-trade-solve.svg)](https://npmjs.org/package/w-trade-solve)
9
+ [![jsdelivr download](https://img.shields.io/jsdelivr/npm/hm/w-trade-solve.svg)](https://www.jsdelivr.com/package/npm/w-trade-solve)
10
+
11
+ ## Documentation
12
+ To view documentation or get support, visit [docs](https://yuda-lyu.github.io/w-trade-solve/global.html).
13
+
14
+ ## Installation
15
+
16
+ ### Using npm(ES6 module):
17
+ ```alias
18
+ npm i w-trade-solve
19
+ ```
20
+
21
+ #### Example:
22
+ > **Link:** [[dev source code](https://github.com/yuda-lyu/w-trade-solve/blob/master/g.mjs)]
23
+ ```alias
24
+ import fs from 'fs'
25
+ import path from 'path'
26
+ import ott from 'w-trade-solve/src/ott.mjs' //時區時間函數由外部傳入, 可用src/ott.mjs或自行以dayjs包裝
27
+ import wts from 'w-trade-solve'
28
+
29
+
30
+ async function test() {
31
+
32
+ //示範用資料夾, fdOhlc 放 K 線序列, fdParam 放指標參數序列, 各以 `${key}.json` 儲存
33
+ // fdData 為求得策略之儲存資料夾, 不存在時由 estimKeys 自動建立
34
+ let fdOhlc = './tmp/data-ohlc'
35
+ let fdParam = './tmp/data-param'
36
+ let fdData = './tmp/data-strategy'
37
+ fs.rmSync(fdData, { recursive: true, force: true })
38
+ fs.mkdirSync(fdOhlc, { recursive: true })
39
+ fs.mkdirSync(fdParam, { recursive: true })
40
+
41
+ //st, 設定物件, 由 opt.keySettings 指定取用之鍵
42
+ // name 與 interval 用於組出 K 線序列 key(`${name}_price_${interval}`)與縮寫 tid
43
+ let st = {
44
+ btc4hr: {
45
+ name: 'btc',
46
+ symbol: 'BTCUSDT',
47
+ interval: '4hr',
48
+ },
49
+ }
50
+
51
+ //arrOhlc 與 arrParam, 20 根 4hr K 線與對應之指標序列(以 sin/cos 合成之示範資料)
52
+ let arrOhlc = []
53
+ let arrParam = []
54
+ let c = 100
55
+ for (let i = 0; i < 20; i++) {
56
+ let time = new Date(Date.UTC(2020, 0, 1) + i * 4 * 3600 * 1000).toISOString().slice(0, 19)
57
+ let o = c
58
+ c = c + Math.sin(i * 0.31) * 2 + Math.cos(i * 0.11) * 1.5
59
+ arrOhlc.push({ time, Open: o, High: Math.max(o, c) + 1, Low: Math.min(o, c) - 1, Close: c })
60
+ arrParam.push({ time, param: Math.sin(i * 0.17) })
61
+ }
62
+ fs.writeFileSync(path.resolve(fdOhlc, 'btc_price_4hr.json'), JSON.stringify(arrOhlc), 'utf8')
63
+ fs.writeFileSync(path.resolve(fdParam, 'btc_4hr_ma_1day.json'), JSON.stringify(arrParam), 'utf8')
64
+
65
+ //keys, 待率定門檻之指標 key, 各 key 於 fdParam 內須有對應之 `${key}.json`
66
+ let keys = ['btc_4hr_ma_1day']
67
+
68
+ //estimKeys, 以 omlPSO 率定[止損, 止盈, 各 key 門檻], 逐次以 runStrategy 回測並取 fitness 最小者
69
+ // 滿足 thNumTrade / thRWin / thREquivalentCumuProfitOrLossFinalNormYear 三門檻之參數組會存入 fdData
70
+ let m = await wts.estimKeys(ott, st, fdOhlc, fdParam, arrOhlc[0].time, arrOhlc[19].time, 'long', keys, fdData, {
71
+ keySettings: 'btc4hr',
72
+ thsTp: [3], //止盈候選(%), 僅給 1 點使示範較快收斂
73
+ thsSl: [2], //止損候選(%)
74
+ thNumTrade: 5, //至少 5 筆交易才存檔
75
+ thRWin: 0.5, //勝率至少 50% 才存檔
76
+ thREquivalentCumuProfitOrLossFinalNormYear: 0, //等效年化盈虧至少 0 才存檔
77
+ })
78
+
79
+ //設計變數為[止損, 止盈, 各 key 門檻], 故個數為 2 + keys 個數
80
+ // 各 key 門檻之解值帶有平移量 10, 大於 0 代表'>'條件、小於 0 代表'<'條件, 還原時扣除平移量
81
+ // estimKeys 為隨機求解, 故以下各數值每次執行皆不同, 僅結構固定
82
+ console.log(m.bestSolution.ps.length, m.bestSolution.ps)
83
+ // => 3 [
84
+ // { ind: 0, value: 0.02 },
85
+ // { ind: 0, value: 0.03 },
86
+ // { ind: 63, value: -9.799999999999999 }
87
+ // ]
88
+
89
+ //readStrategies, 讀回 fdData 內之策略, tkid 為`${tid}:${交易次數級距}`, 同 tkid 僅保留等效年化盈虧最佳者
90
+ let ss = wts.readStrategies(fdData, { readContent: true })
91
+ console.log(ss.map((s) => {
92
+ return `${s.tkid} → ${s.rEquivalentCumuProfitOrLossFinalNormYear}`
93
+ }))
94
+ // => [
95
+ // 'long ║ ma_1day:1 → 194.67%',
96
+ // 'long ║ ma_1day:11 → 839.50%',
97
+ // 'long ║ ma_1day:2 → 644.83%'
98
+ // ]
99
+
100
+ //策略內容含還原後之 conds(門檻已扣除平移量)與回測所用之 settings
101
+ console.log(ss[0].data.conds, ss[0].data.settings)
102
+ // => [ { key: 'btc_4hr_ma_1day', sym: '<', th: 0.3 } ] {
103
+ // uIni: 1000,
104
+ // uTrade: 1,
105
+ // rTakeProfit: 0.03,
106
+ // rStopLoss: 0.02,
107
+ // rFee: 0.0005
108
+ // }
109
+
110
+ //genTid, 策略種類識別碼, 僅由 mode 與 keys 決定, 並將 `${name}_`、`${interval}_` 等樣式縮寫
111
+ console.log(wts.genTid('btc', '4hr', 'long', keys))
112
+ // => 'long ║ ma_1day'
113
+
114
+ //calcLevelNumTrade, 交易次數之級距代碼, 使不同交易次數規模之策略各自保留最佳者
115
+ console.log(wts.calcLevelNumTrade(3), wts.calcLevelNumTrade(30), wts.calcLevelNumTrade(300))
116
+ // => 1 12 102
117
+
118
+ //genStrategyFileName, 策略儲存檔名, 為`${tid} ⊙ ${級距} ⊙ ${等效年化盈虧}.json`
119
+ console.log(wts.genStrategyFileName('btc', '4hr', 'long', keys, {}, { numTrade: 30, rEquivalentCumuProfitOrLossFinalNormYear: '31.25%' }))
120
+ // => 'long ║ ma_1day ⊙ 12 ⊙ 31.25%.json'
121
+
122
+ //calcFitness, 求解所用之目標函數值, 越小越佳, 由勝率(權重 2)與等效年化盈虧(權重 1)組成
123
+ console.log(wts.calcFitness({ uIni: 1000 }, { numTrade: 30, uEquityFinal: 1200, rWin: '60%', rEquivalentCumuProfitOrLossFinalNormYear: '25%' }))
124
+ // => 1.3
125
+
126
+ }
127
+ test()
128
+ .catch((err) => {
129
+ console.log('catch', err)
130
+ })
131
+
132
+ ```
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security Policy
2
+
3
+ ## Reporting a Vulnerability
4
+
5
+ Please report security issues to `firsemisphere@gmail.com`
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ 'presets': [
3
+ ['@babel/preset-env', {
4
+ 'useBuiltIns': 'entry',
5
+ 'corejs': 3
6
+ }]
7
+ ],
8
+ 'plugins': [
9
+ '@babel/plugin-transform-runtime',
10
+ '@babel/plugin-proposal-export-default-from',
11
+ // '@babel/plugin-syntax-import-assertions', //已被棄用
12
+ // '@babel/plugin-proposal-nullish-coalescing-operator', //browser與nodejs已支援
13
+ // '@babel/plugin-proposal-object-rest-spread', //browser與nodejs已支援
14
+ // '@babel/plugin-proposal-optional-chaining', //browser與nodejs已支援
15
+ ]
16
+ }
@@ -0,0 +1,19 @@
1
+ /*!
2
+ * w-trade-solve v1.0.1
3
+ * (c) 2018-2021 yuda-lyu(semisphere)
4
+ * Released under the MIT License.
5
+ */
6
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("path"),require("fs")):"function"==typeof define&&define.amd?define(["path","fs"],e):(t="undefined"!=typeof globalThis?globalThis:t||self)["w-trade-solve"]=e(t.path,t.fs)}(this,function(t,e){"use strict";var r=Array.isArray,n="object"==typeof global&&global&&global.Object===Object&&global,i="object"==typeof self&&self&&self.Object===Object&&self,o=n||i||Function("return this")(),u=o.Symbol,s=Object.prototype,a=s.hasOwnProperty,f=s.toString,c=u?u.toStringTag:void 0;var l=Object.prototype.toString;var d=u?u.toStringTag:void 0;function h(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":d&&d in Object(t)?function(t){var e=a.call(t,c),r=t[c];try{t[c]=void 0;var n=!0}catch(t){}var i=f.call(t);return n&&(e?t[c]=r:delete t[c]),i}(t):function(t){return l.call(t)}(t)}function p(t){return null!=t&&"object"==typeof t}function v(t){return"symbol"==typeof t||p(t)&&"[object Symbol]"==h(t)}var y=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,m=/^\w*$/;function g(t,e){if(r(t))return!1;var n=typeof t;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=t&&!v(t))||(m.test(t)||!y.test(t)||null!=e&&t in Object(e))}function b(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function w(t){if(!b(t))return!1;var e=h(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}var _,j=o["__core-js_shared__"],O=(_=/[^.]+$/.exec(j&&j.keys&&j.keys.IE_PROTO||""))?"Symbol(src)_1."+_:"";var S=Function.prototype.toString;function $(t){if(null!=t){try{return S.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var E=/^\[object .+?Constructor\]$/,M=Function.prototype,N=Object.prototype,A=M.toString,x=N.hasOwnProperty,T=RegExp("^"+A.call(x).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function P(t){return!(!b(t)||(e=t,O&&O in e))&&(w(t)?T:E).test($(t));var e}function L(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return P(r)?r:void 0}var k=L(Object,"create");var F=Object.prototype.hasOwnProperty;var D=Object.prototype.hasOwnProperty;function C(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function R(t,e){return t===e||t!=t&&e!=e}function I(t,e){for(var r=t.length;r--;)if(R(t[r][0],e))return r;return-1}C.prototype.clear=function(){this.__data__=k?k(null):{},this.size=0},C.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},C.prototype.get=function(t){var e=this.__data__;if(k){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return F.call(e,t)?e[t]:void 0},C.prototype.has=function(t){var e=this.__data__;return k?void 0!==e[t]:D.call(e,t)},C.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=k&&void 0===e?"__lodash_hash_undefined__":e,this};var q=Array.prototype.splice;function z(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}z.prototype.clear=function(){this.__data__=[],this.size=0},z.prototype.delete=function(t){var e=this.__data__,r=I(e,t);return!(r<0)&&(r==e.length-1?e.pop():q.call(e,r,1),--this.size,!0)},z.prototype.get=function(t){var e=this.__data__,r=I(e,t);return r<0?void 0:e[r][1]},z.prototype.has=function(t){return I(this.__data__,t)>-1},z.prototype.set=function(t,e){var r=this.__data__,n=I(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var U=L(o,"Map");function Y(t,e){var r,n,i=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof e?"string":"hash"]:i.map}function B(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}B.prototype.clear=function(){this.size=0,this.__data__={hash:new C,map:new(U||z),string:new C}},B.prototype.delete=function(t){var e=Y(this,t).delete(t);return this.size-=e?1:0,e},B.prototype.get=function(t){return Y(this,t).get(t)},B.prototype.has=function(t){return Y(this,t).has(t)},B.prototype.set=function(t,e){var r=Y(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this};function H(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var u=t.apply(this,n);return r.cache=o.set(i,u)||o,u};return r.cache=new(H.Cache||B),r}H.Cache=B;var G,Z,V,W=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,J=/\\(\\)?/g,K=(G=function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(W,function(t,r,n,i){e.push(n?i.replace(J,"$1"):r||t)}),e},Z=H(G,function(t){return 500===V.size&&V.clear(),t}),V=Z.cache,Z),Q=K;function X(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var tt=u?u.prototype:void 0,et=tt?tt.toString:void 0;function rt(t){if("string"==typeof t)return t;if(r(t))return X(t,rt)+"";if(v(t))return et?et.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function nt(t){return null==t?"":rt(t)}function it(t,e){return r(t)?t:g(t,e)?[t]:Q(nt(t))}function ot(t){if("string"==typeof t||v(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function ut(t,e){for(var r=0,n=(e=it(e,t)).length;null!=t&&r<n;)t=t[ot(e[r++])];return r&&r==n?t:void 0}function st(t,e,r){var n=null==t?void 0:ut(t,e);return void 0===n?r:n}var at=Math.floor,ft=Math.random;function ct(t,e){return t+at(ft()*(e-t+1))}function lt(t){var e=t.length;return e?t[ct(0,e-1)]:void 0}function dt(t){return p(t)&&"[object Arguments]"==h(t)}var ht=Object.prototype,pt=ht.hasOwnProperty,vt=ht.propertyIsEnumerable,yt=dt(function(){return arguments}())?dt:function(t){return p(t)&&pt.call(t,"callee")&&!vt.call(t,"callee")},mt=yt;var gt="object"==typeof exports&&exports&&!exports.nodeType&&exports,bt=gt&&"object"==typeof module&&module&&!module.nodeType&&module,wt=bt&&bt.exports===gt?o.Buffer:void 0,_t=(wt?wt.isBuffer:void 0)||function(){return!1},jt=/^(?:0|[1-9]\d*)$/;function Ot(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&jt.test(t))&&t>-1&&t%1==0&&t<e}function St(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var $t={};function Et(t){return function(e){return t(e)}}$t["[object Float32Array]"]=$t["[object Float64Array]"]=$t["[object Int8Array]"]=$t["[object Int16Array]"]=$t["[object Int32Array]"]=$t["[object Uint8Array]"]=$t["[object Uint8ClampedArray]"]=$t["[object Uint16Array]"]=$t["[object Uint32Array]"]=!0,$t["[object Arguments]"]=$t["[object Array]"]=$t["[object ArrayBuffer]"]=$t["[object Boolean]"]=$t["[object DataView]"]=$t["[object Date]"]=$t["[object Error]"]=$t["[object Function]"]=$t["[object Map]"]=$t["[object Number]"]=$t["[object Object]"]=$t["[object RegExp]"]=$t["[object Set]"]=$t["[object String]"]=$t["[object WeakMap]"]=!1;var Mt="object"==typeof exports&&exports&&!exports.nodeType&&exports,Nt=Mt&&"object"==typeof module&&module&&!module.nodeType&&module,At=Nt&&Nt.exports===Mt&&n.process,xt=function(){try{var t=Nt&&Nt.require&&Nt.require("util").types;return t||At&&At.binding&&At.binding("util")}catch(t){}}(),Tt=xt&&xt.isTypedArray,Pt=Tt?Et(Tt):function(t){return p(t)&&St(t.length)&&!!$t[h(t)]},Lt=Object.prototype.hasOwnProperty;function kt(t,e){var n=r(t),i=!n&&mt(t),o=!n&&!i&&_t(t),u=!n&&!i&&!o&&Pt(t),s=n||i||o||u,a=s?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],f=a.length;for(var c in t)!e&&!Lt.call(t,c)||s&&("length"==c||o&&("offset"==c||"parent"==c)||u&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Ot(c,f))||a.push(c);return a}var Ft=Object.prototype;function Dt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||Ft)}function Ct(t,e){return function(r){return t(e(r))}}var Rt=Ct(Object.keys,Object),It=Object.prototype.hasOwnProperty;function qt(t){if(!Dt(t))return Rt(t);var e=[];for(var r in Object(t))It.call(t,r)&&"constructor"!=r&&e.push(r);return e}function zt(t){return null!=t&&St(t.length)&&!w(t)}function Ut(t){return zt(t)?kt(t):qt(t)}function Yt(t){return null==t?[]:function(t,e){return X(e,function(e){return t[e]})}(t,Ut(t))}function Bt(t){return lt(Yt(t))}function Ht(t){return"[object String]"===Object.prototype.toString.call(t)}function Gt(t){return!(!Ht(t)||""===t)}function Zt(t){var e=this.__data__=new z(t);this.size=e.size}Zt.prototype.clear=function(){this.__data__=new z,this.size=0},Zt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Zt.prototype.get=function(t){return this.__data__.get(t)},Zt.prototype.has=function(t){return this.__data__.has(t)},Zt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof z){var n=r.__data__;if(!U||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new B(n)}return r.set(t,e),this.size=r.size,this};function Vt(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new B;++e<r;)this.add(t[e])}function Wt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Jt(t,e){return t.has(e)}Vt.prototype.add=Vt.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},Vt.prototype.has=function(t){return this.__data__.has(t)};function Kt(t,e,r,n,i,o){var u=1&r,s=t.length,a=e.length;if(s!=a&&!(u&&a>s))return!1;var f=o.get(t),c=o.get(e);if(f&&c)return f==e&&c==t;var l=-1,d=!0,h=2&r?new Vt:void 0;for(o.set(t,e),o.set(e,t);++l<s;){var p=t[l],v=e[l];if(n)var y=u?n(v,p,l,e,t,o):n(p,v,l,t,e,o);if(void 0!==y){if(y)continue;d=!1;break}if(h){if(!Wt(e,function(t,e){if(!Jt(h,e)&&(p===t||i(p,t,r,n,o)))return h.push(e)})){d=!1;break}}else if(p!==v&&!i(p,v,r,n,o)){d=!1;break}}return o.delete(t),o.delete(e),d}var Qt=o.Uint8Array;function Xt(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function te(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var ee=u?u.prototype:void 0,re=ee?ee.valueOf:void 0;function ne(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}function ie(t,e,n){var i=e(t);return r(t)?i:ne(i,n(t))}function oe(t,e){for(var r=-1,n=null==t?0:t.length,i=0,o=[];++r<n;){var u=t[r];e(u,r,t)&&(o[i++]=u)}return o}function ue(){return[]}var se=Object.prototype.propertyIsEnumerable,ae=Object.getOwnPropertySymbols,fe=ae?function(t){return null==t?[]:(t=Object(t),oe(ae(t),function(e){return se.call(t,e)}))}:ue;function ce(t){return ie(t,Ut,fe)}var le=Object.prototype.hasOwnProperty;var de=L(o,"DataView"),he=L(o,"Promise"),pe=L(o,"Set"),ve=L(o,"WeakMap"),ye="[object Map]",me="[object Promise]",ge="[object Set]",be="[object WeakMap]",we="[object DataView]",_e=$(de),je=$(U),Oe=$(he),Se=$(pe),$e=$(ve),Ee=h;(de&&Ee(new de(new ArrayBuffer(1)))!=we||U&&Ee(new U)!=ye||he&&Ee(he.resolve())!=me||pe&&Ee(new pe)!=ge||ve&&Ee(new ve)!=be)&&(Ee=function(t){var e=h(t),r="[object Object]"==e?t.constructor:void 0,n=r?$(r):"";if(n)switch(n){case _e:return we;case je:return ye;case Oe:return me;case Se:return ge;case $e:return be}return e});var Me=Ee,Ne="[object Arguments]",Ae="[object Array]",xe="[object Object]",Te=Object.prototype.hasOwnProperty;function Pe(t,e,n,i,o,u){var s=r(t),a=r(e),f=s?Ae:Me(t),c=a?Ae:Me(e),l=(f=f==Ne?xe:f)==xe,d=(c=c==Ne?xe:c)==xe,h=f==c;if(h&&_t(t)){if(!_t(e))return!1;s=!0,l=!1}if(h&&!l)return u||(u=new Zt),s||Pt(t)?Kt(t,e,n,i,o,u):function(t,e,r,n,i,o,u){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Qt(t),new Qt(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return R(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var s=Xt;case"[object Set]":var a=1&n;if(s||(s=te),t.size!=e.size&&!a)return!1;var f=u.get(t);if(f)return f==e;n|=2,u.set(t,e);var c=Kt(s(t),s(e),n,i,o,u);return u.delete(t),c;case"[object Symbol]":if(re)return re.call(t)==re.call(e)}return!1}(t,e,f,n,i,o,u);if(!(1&n)){var p=l&&Te.call(t,"__wrapped__"),v=d&&Te.call(e,"__wrapped__");if(p||v){var y=p?t.value():t,m=v?e.value():e;return u||(u=new Zt),o(y,m,n,i,u)}}return!!h&&(u||(u=new Zt),function(t,e,r,n,i,o){var u=1&r,s=ce(t),a=s.length;if(a!=ce(e).length&&!u)return!1;for(var f=a;f--;){var c=s[f];if(!(u?c in e:le.call(e,c)))return!1}var l=o.get(t),d=o.get(e);if(l&&d)return l==e&&d==t;var h=!0;o.set(t,e),o.set(e,t);for(var p=u;++f<a;){var v=t[c=s[f]],y=e[c];if(n)var m=u?n(y,v,c,e,t,o):n(v,y,c,t,e,o);if(!(void 0===m?v===y||i(v,y,r,n,o):m)){h=!1;break}p||(p="constructor"==c)}if(h&&!p){var g=t.constructor,b=e.constructor;g==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(h=!1)}return o.delete(t),o.delete(e),h}(t,e,n,i,o,u))}function Le(t,e,r,n,i){return t===e||(null==t||null==e||!p(t)&&!p(e)?t!=t&&e!=e:Pe(t,e,r,n,Le,i))}function ke(t){return t==t&&!b(t)}function Fe(t,e){return function(r){return null!=r&&(r[t]===e&&(void 0!==e||t in Object(r)))}}function De(t){var e=function(t){for(var e=Ut(t),r=e.length;r--;){var n=e[r],i=t[n];e[r]=[n,i,ke(i)]}return e}(t);return 1==e.length&&e[0][2]?Fe(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var i=r.length,o=i,u=!n;if(null==t)return!o;for(t=Object(t);i--;){var s=r[i];if(u&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++i<o;){var a=(s=r[i])[0],f=t[a],c=s[1];if(u&&s[2]){if(void 0===f&&!(a in t))return!1}else{var l=new Zt;if(n)var d=n(f,c,a,t,e,l);if(!(void 0===d?Le(c,f,3,n,l):d))return!1}}return!0}(r,t,e)}}function Ce(t,e){return null!=t&&e in Object(t)}function Re(t,e){return null!=t&&function(t,e,n){for(var i=-1,o=(e=it(e,t)).length,u=!1;++i<o;){var s=ot(e[i]);if(!(u=null!=t&&n(t,s)))break;t=t[s]}return u||++i!=o?u:!!(o=null==t?0:t.length)&&St(o)&&Ot(s,o)&&(r(t)||mt(t))}(t,e,Ce)}function Ie(t){return t}function qe(t){return function(e){return null==e?void 0:e[t]}}function ze(t){return g(t)?qe(ot(t)):function(t){return function(e){return ut(e,t)}}(t)}function Ue(t){return"function"==typeof t?t:null==t?Ie:"object"==typeof t?r(t)?function(t,e){return g(t)&&ke(e)?Fe(ot(t),e):function(r){var n=st(r,t);return void 0===n&&n===e?Re(r,t):Le(e,n,3)}}(t[0],t[1]):De(t):ze(t)}var Ye,Be=function(t,e,r){for(var n=-1,i=Object(t),o=r(t),u=o.length;u--;){var s=o[Ye?u:++n];if(!1===e(i[s],s,i))break}return t};var He=function(t,e){return function(r,n){if(null==r)return r;if(!zt(r))return t(r,n);for(var i=r.length,o=e?i:-1,u=Object(r);(e?o--:++o<i)&&!1!==n(u[o],o,u););return r}}(function(t,e){return t&&Be(t,e,Ut)}),Ge=He;function Ze(t,e){var r=-1,n=zt(t)?Array(t.length):[];return Ge(t,function(t,i,o){n[++r]=e(t,i,o)}),n}function Ve(t,e){return(r(t)?X:Ze)(t,Ue(e))}var We=qe("length"),Je=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function Ke(t){return Je.test(t)}var Qe="\\ud800-\\udfff",Xe="["+Qe+"]",tr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",er="\\ud83c[\\udffb-\\udfff]",rr="[^"+Qe+"]",nr="(?:\\ud83c[\\udde6-\\uddff]){2}",ir="[\\ud800-\\udbff][\\udc00-\\udfff]",or="(?:"+tr+"|"+er+")"+"?",ur="[\\ufe0e\\ufe0f]?",sr=ur+or+("(?:\\u200d(?:"+[rr,nr,ir].join("|")+")"+ur+or+")*"),ar="(?:"+[rr+tr+"?",tr,nr,ir,Xe].join("|")+")",fr=RegExp(er+"(?="+er+")|"+ar+sr,"g");function cr(t){return Ke(t)?function(t){for(var e=fr.lastIndex=0;fr.test(t);)++e;return e}(t):We(t)}function lr(t){if(null==t)return 0;if(zt(t))return"string"==typeof(e=t)||!r(e)&&p(e)&&"[object String]"==h(e)?cr(t):t.length;var e,n=Me(t);return"[object Map]"==n||"[object Set]"==n?t.size:qt(t).length}var dr=/\s/;var hr=/^\s+/;function pr(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&dr.test(t.charAt(e)););return e}(t)+1).replace(hr,""):t}var vr=/^[-+]0x[0-9a-f]+$/i,yr=/^0b[01]+$/i,mr=/^0o[0-7]+$/i,gr=parseInt;function br(t){if("number"==typeof t)return t;if(v(t))return NaN;if(b(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=b(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=pr(t);var r=yr.test(t);return r||mr.test(t)?gr(t.slice(2),r?2:8):vr.test(t)?NaN:+t}var wr=1/0;function _r(t){return t?(t=br(t))===wr||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function jr(t){var e=_r(t),r=e%1;return e==e?r?e-r:e:0}var Or=o.isFinite,Sr=Math.min;var $r=function(t){var e=Math[t];return function(t,r){if(t=br(t),(r=null==r?0:Sr(jr(r),292))&&Or(t)){var n=(nt(t)+"e").split("e");return+((n=(nt(e(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return e(t)}}("round"),Er=$r;function Mr(t){return t!=t}function Nr(t){let e=!1;if(Gt(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(Mr(t))return!1;e=!0}return e}function Ar(t){if(!Nr(t))return 0;return _r(t)}function xr(t){if(!Nr(t))return 0;t=Ar(t);let e=Er(t);return"0"===String(e)?0:e}var Tr=Math.ceil,Pr=Math.max;function Lr(t,e,r){if(!b(r))return!1;var n=typeof e;return!!("number"==n?zt(r)&&Ot(e,r.length):"string"==n&&e in r)&&R(r[e],t)}var kr=function(t){return function(e,r,n){return n&&"number"!=typeof n&&Lr(e,r,n)&&(r=n=void 0),e=_r(e),void 0===r?(r=e,e=0):r=_r(r),function(t,e,r,n){for(var i=-1,o=Pr(Tr((e-t)/(r||1)),0),u=Array(o);o--;)u[n?o:++i]=t,t+=r;return u}(e,r,n=void 0===n?e<r?1:-1:_r(n),t)}}(),Fr=kr;function Dr(t,e,r){return t==t&&(void 0!==r&&(t=t<=r?t:r),void 0!==e&&(t=t>=e?t:e)),t}function Cr(t,e){var r=-1,n=t.length;for(e||(e=Array(n));++r<n;)e[r]=t[r];return e}function Rr(t,e){var r=-1,n=t.length,i=n-1;for(e=void 0===e?n:e;++r<e;){var o=ct(r,i),u=t[o];t[o]=t[r],t[r]=u}return t.length=e,t}function Ir(t,e){return Rr(Cr(t),Dr(e,0,t.length))}function qr(t,e){var r=Yt(t);return Rr(r,Dr(e,0,r.length))}function zr(t){return!!Nr(t)&&(t=Ar(t),"number"==typeof(e=t)&&e==jr(e));var e}function Ur(t){if(!zr(t))return!1;return xr(t)>0}function Yr(t=0,e=100,n){if(zr(t)||(t=0),t=xr(t),zr(e)||(e=100),e=xr(e),Ur(n)||(n=1),n=xr(n),t>e)throw new Error(`vstart[${t}] > vend[${e}]`);let i=function(t,e,n){return e=(n?Lr(t,e,n):void 0===e)?1:jr(e),(r(t)?Ir:qr)(t,e)}(Fr(t,e+1),n);return i}function Br(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}function Hr(t,e){var n;return(r(t)?Br:Ge)(t,"function"==typeof(n=e)?n:Ie)}function Gr(t,e,r){var n=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++n<i;)o[n]=t[n+e];return o}function Zr(t){return t!=t}function Vr(t,e,r){return e==e?function(t,e,r){for(var n=r-1,i=t.length;++n<i;)if(t[n]===e)return n;return-1}(t,e,r):function(t,e,r,n){for(var i=t.length,o=r+(n?1:-1);n?o--:++o<i;)if(e(t[o],o,t))return o;return-1}(t,Zr,r)}var Wr="\\ud800-\\udfff",Jr="["+Wr+"]",Kr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Qr="\\ud83c[\\udffb-\\udfff]",Xr="[^"+Wr+"]",tn="(?:\\ud83c[\\udde6-\\uddff]){2}",en="[\\ud800-\\udbff][\\udc00-\\udfff]",rn="(?:"+Kr+"|"+Qr+")"+"?",nn="[\\ufe0e\\ufe0f]?",on=nn+rn+("(?:\\u200d(?:"+[Xr,tn,en].join("|")+")"+nn+rn+")*"),un="(?:"+[Xr+Kr+"?",Kr,tn,en,Jr].join("|")+")",sn=RegExp(Qr+"(?="+Qr+")|"+un+on,"g");function an(t){return Ke(t)?function(t){return t.match(sn)||[]}(t):function(t){return t.split("")}(t)}function fn(t,e,r){if((t=nt(t))&&(r||void 0===e))return pr(t);if(!t||!(e=rt(e)))return t;var n=an(t),i=an(e),o=function(t,e){for(var r=-1,n=t.length;++r<n&&Vr(e,t[r],0)>-1;);return r}(n,i),u=function(t,e){for(var r=t.length;r--&&Vr(e,t[r],0)>-1;);return r}(n,i)+1;return function(t,e,r){var n=t.length;return r=void 0===r?n:r,!e&&r>=n?t:Gr(t,e,r)}(n,o,u).join("")}function cn(t,e){if(!Gt(t))return[];if(!Gt(e))return[];let r=function(t,e){return Gt(t)&&Gt(e)?t.split(e):[]}(t,e);r=Ve(r,fn);let n=[];return Hr(r,function(t){Gt(t)&&n.push(t)}),n}function ln(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}var dn="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function hn(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var pn={exports:{}};
7
+ /*!
8
+ * w-data-tdprovide v1.0.4
9
+ * (c) 2018-2021 yuda-lyu(semisphere)
10
+ * Released under the MIT License.
11
+ */!function(r,n){r.exports=function(t,e){function i(t,e){for(var r=-1,n=null==t?0:t.length;++r<n&&!1!==e(t[r],r,t););return t}var o=function(t,e,r){for(var n=-1,i=Object(t),o=r(t),u=o.length;u--;){var s=o[++n];if(!1===e(i[s],s,i))break}return t},u="object"==typeof dn&&dn&&dn.Object===Object&&dn,s="object"==typeof self&&self&&self.Object===Object&&self,a=u||s||Function("return this")(),f=a.Symbol,c=Object.prototype,l=c.hasOwnProperty,d=c.toString,h=f?f.toStringTag:void 0,p=Object.prototype.toString,v=f?f.toStringTag:void 0;function y(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":v&&v in Object(t)?function(t){var e=l.call(t,h),r=t[h];try{t[h]=void 0;var n=!0}catch(t){}var i=d.call(t);return n&&(e?t[h]=r:delete t[h]),i}(t):function(t){return p.call(t)}(t)}function m(t){return null!=t&&"object"==typeof t}function g(t){return m(t)&&"[object Arguments]"==y(t)}var b=Object.prototype,w=b.hasOwnProperty,_=b.propertyIsEnumerable,j=g(function(){return arguments}())?g:function(t){return m(t)&&w.call(t,"callee")&&!_.call(t,"callee")},O=j,S=Array.isArray,$=n&&!n.nodeType&&n,E=$&&r&&!r.nodeType&&r,M=E&&E.exports===$?a.Buffer:void 0,N=(M?M.isBuffer:void 0)||function(){return!1},A=/^(?:0|[1-9]\d*)$/;function x(t,e){var r=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==r||"symbol"!=r&&A.test(t))&&t>-1&&t%1==0&&t<e}function T(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}var P={};function L(t){return function(e){return t(e)}}P["[object Float32Array]"]=P["[object Float64Array]"]=P["[object Int8Array]"]=P["[object Int16Array]"]=P["[object Int32Array]"]=P["[object Uint8Array]"]=P["[object Uint8ClampedArray]"]=P["[object Uint16Array]"]=P["[object Uint32Array]"]=!0,P["[object Arguments]"]=P["[object Array]"]=P["[object ArrayBuffer]"]=P["[object Boolean]"]=P["[object DataView]"]=P["[object Date]"]=P["[object Error]"]=P["[object Function]"]=P["[object Map]"]=P["[object Number]"]=P["[object Object]"]=P["[object RegExp]"]=P["[object Set]"]=P["[object String]"]=P["[object WeakMap]"]=!1;var k=n&&!n.nodeType&&n,F=k&&r&&!r.nodeType&&r,D=F&&F.exports===k&&u.process,C=function(){try{return F&&F.require&&F.require("util").types||D&&D.binding&&D.binding("util")}catch(t){}}(),R=C&&C.isTypedArray,I=R?L(R):function(t){return m(t)&&T(t.length)&&!!P[y(t)]},q=Object.prototype.hasOwnProperty;function z(t,e){var r=S(t),n=!r&&O(t),i=!r&&!n&&N(t),o=!r&&!n&&!i&&I(t),u=r||n||i||o,s=u?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],a=s.length;for(var f in t)!e&&!q.call(t,f)||u&&("length"==f||i&&("offset"==f||"parent"==f)||o&&("buffer"==f||"byteLength"==f||"byteOffset"==f)||x(f,a))||s.push(f);return s}var U,Y,B=Object.prototype,H=(U=Object.keys,Y=Object,function(t){return U(Y(t))}),G=Object.prototype.hasOwnProperty;function Z(t){if(r=(e=t)&&e.constructor,e!==("function"==typeof r&&r.prototype||B))return H(t);var e,r,n=[];for(var i in Object(t))G.call(t,i)&&"constructor"!=i&&n.push(i);return n}function V(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function W(t){if(!V(t))return!1;var e=y(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e}function J(t){return null!=t&&T(t.length)&&!W(t)}function K(t){return J(t)?z(t):Z(t)}var Q=function(t,e){return function(r,n){if(null==r)return r;if(!J(r))return t(r,n);for(var i=r.length,o=e?i:-1,u=Object(r);(e?o--:++o<i)&&!1!==n(u[o],o,u););return r}}(function(t,e){return t&&o(t,e,K)}),X=Q;function tt(t){return t}function et(t,e){var r;return(S(t)?i:X)(t,"function"==typeof(r=e)?r:tt)}function rt(t,e){for(var r=-1,n=null==t?0:t.length,i=0,o=[];++r<n;){var u=t[r];e(u,r,t)&&(o[i++]=u)}return o}function nt(t,e){var r=[];return X(t,function(t,n,i){e(t,n,i)&&r.push(t)}),r}function it(t,e){return t===e||t!=t&&e!=e}function ot(t,e){for(var r=t.length;r--;)if(it(t[r][0],e))return r;return-1}var ut=Array.prototype.splice;function st(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}st.prototype.clear=function(){this.__data__=[],this.size=0},st.prototype.delete=function(t){var e=this.__data__,r=ot(e,t);return!(r<0||(r==e.length-1?e.pop():ut.call(e,r,1),--this.size,0))},st.prototype.get=function(t){var e=this.__data__,r=ot(e,t);return r<0?void 0:e[r][1]},st.prototype.has=function(t){return ot(this.__data__,t)>-1},st.prototype.set=function(t,e){var r=this.__data__,n=ot(r,t);return n<0?(++this.size,r.push([t,e])):r[n][1]=e,this};var at,ft=a["__core-js_shared__"],ct=(at=/[^.]+$/.exec(ft&&ft.keys&&ft.keys.IE_PROTO||""))?"Symbol(src)_1."+at:"",lt=Function.prototype.toString;function dt(t){if(null!=t){try{return lt.call(t)}catch(t){}try{return t+""}catch(t){}}return""}var ht=/^\[object .+?Constructor\]$/,pt=Function.prototype,vt=Object.prototype,yt=pt.toString,mt=vt.hasOwnProperty,gt=RegExp("^"+yt.call(mt).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function bt(t){return!(!V(t)||function(t){return!!ct&&ct in t}(t))&&(W(t)?gt:ht).test(dt(t))}function wt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return bt(r)?r:void 0}var _t=wt(a,"Map"),jt=wt(Object,"create"),Ot=Object.prototype.hasOwnProperty,St=Object.prototype.hasOwnProperty;function $t(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Et(t,e){var r,n,i=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?i["string"==typeof e?"string":"hash"]:i.map}function Mt(t){var e=-1,r=null==t?0:t.length;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Nt(t){var e=this.__data__=new st(t);this.size=e.size}function At(t){var e=-1,r=null==t?0:t.length;for(this.__data__=new Mt;++e<r;)this.add(t[e])}function xt(t,e){for(var r=-1,n=null==t?0:t.length;++r<n;)if(e(t[r],r,t))return!0;return!1}function Tt(t,e,r,n,i,o){var u=1&r,s=t.length,a=e.length;if(s!=a&&!(u&&a>s))return!1;var f=o.get(t),c=o.get(e);if(f&&c)return f==e&&c==t;var l=-1,d=!0,h=2&r?new At:void 0;for(o.set(t,e),o.set(e,t);++l<s;){var p=t[l],v=e[l];if(n)var y=u?n(v,p,l,e,t,o):n(p,v,l,t,e,o);if(void 0!==y){if(y)continue;d=!1;break}if(h){if(!xt(e,function(t,e){if(u=e,!h.has(u)&&(p===t||i(p,t,r,n,o)))return h.push(e);var u})){d=!1;break}}else if(p!==v&&!i(p,v,r,n,o)){d=!1;break}}return o.delete(t),o.delete(e),d}$t.prototype.clear=function(){this.__data__=jt?jt(null):{},this.size=0},$t.prototype.delete=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},$t.prototype.get=function(t){var e=this.__data__;if(jt){var r=e[t];return"__lodash_hash_undefined__"===r?void 0:r}return Ot.call(e,t)?e[t]:void 0},$t.prototype.has=function(t){var e=this.__data__;return jt?void 0!==e[t]:St.call(e,t)},$t.prototype.set=function(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=jt&&void 0===e?"__lodash_hash_undefined__":e,this},Mt.prototype.clear=function(){this.size=0,this.__data__={hash:new $t,map:new(_t||st),string:new $t}},Mt.prototype.delete=function(t){var e=Et(this,t).delete(t);return this.size-=e?1:0,e},Mt.prototype.get=function(t){return Et(this,t).get(t)},Mt.prototype.has=function(t){return Et(this,t).has(t)},Mt.prototype.set=function(t,e){var r=Et(this,t),n=r.size;return r.set(t,e),this.size+=r.size==n?0:1,this},Nt.prototype.clear=function(){this.__data__=new st,this.size=0},Nt.prototype.delete=function(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r},Nt.prototype.get=function(t){return this.__data__.get(t)},Nt.prototype.has=function(t){return this.__data__.has(t)},Nt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof st){var n=r.__data__;if(!_t||n.length<199)return n.push([t,e]),this.size=++r.size,this;r=this.__data__=new Mt(n)}return r.set(t,e),this.size=r.size,this},At.prototype.add=At.prototype.push=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},At.prototype.has=function(t){return this.__data__.has(t)};var Pt=a.Uint8Array;function Lt(t){var e=-1,r=Array(t.size);return t.forEach(function(t,n){r[++e]=[n,t]}),r}function kt(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var Ft=f?f.prototype:void 0,Dt=Ft?Ft.valueOf:void 0,Ct=Object.prototype.propertyIsEnumerable,Rt=Object.getOwnPropertySymbols,It=Rt?function(t){return null==t?[]:(t=Object(t),rt(Rt(t),function(e){return Ct.call(t,e)}))}:function(){return[]};function qt(t){return function(t,e,r){var n=e(t);return S(t)?n:function(t,e){for(var r=-1,n=e.length,i=t.length;++r<n;)t[i+r]=e[r];return t}(n,r(t))}(t,K,It)}var zt=Object.prototype.hasOwnProperty,Ut=wt(a,"DataView"),Yt=wt(a,"Promise"),Bt=wt(a,"Set"),Ht=wt(a,"WeakMap"),Gt="[object Map]",Zt="[object Promise]",Vt="[object Set]",Wt="[object WeakMap]",Jt="[object DataView]",Kt=dt(Ut),Qt=dt(_t),Xt=dt(Yt),te=dt(Bt),ee=dt(Ht),re=y;(Ut&&re(new Ut(new ArrayBuffer(1)))!=Jt||_t&&re(new _t)!=Gt||Yt&&re(Yt.resolve())!=Zt||Bt&&re(new Bt)!=Vt||Ht&&re(new Ht)!=Wt)&&(re=function(t){var e=y(t),r="[object Object]"==e?t.constructor:void 0,n=r?dt(r):"";if(n)switch(n){case Kt:return Jt;case Qt:return Gt;case Xt:return Zt;case te:return Vt;case ee:return Wt}return e});var ne=re,ie="[object Arguments]",oe="[object Array]",ue="[object Object]",se=Object.prototype.hasOwnProperty;function ae(t,e,r,n,i,o){var u=S(t),s=S(e),a=u?oe:ne(t),f=s?oe:ne(e),c=(a=a==ie?ue:a)==ue,l=(f=f==ie?ue:f)==ue,d=a==f;if(d&&N(t)){if(!N(e))return!1;u=!0,c=!1}if(d&&!c)return o||(o=new Nt),u||I(t)?Tt(t,e,r,n,i,o):function(t,e,r,n,i,o,u){switch(r){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new Pt(t),new Pt(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return it(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var s=Lt;case"[object Set]":var a=1&n;if(s||(s=kt),t.size!=e.size&&!a)return!1;var f=u.get(t);if(f)return f==e;n|=2,u.set(t,e);var c=Tt(s(t),s(e),n,i,o,u);return u.delete(t),c;case"[object Symbol]":if(Dt)return Dt.call(t)==Dt.call(e)}return!1}(t,e,a,r,n,i,o);if(!(1&r)){var h=c&&se.call(t,"__wrapped__"),p=l&&se.call(e,"__wrapped__");if(h||p){var v=h?t.value():t,y=p?e.value():e;return o||(o=new Nt),i(v,y,r,n,o)}}return!!d&&(o||(o=new Nt),function(t,e,r,n,i,o){var u=1&r,s=qt(t),a=s.length;if(a!=qt(e).length&&!u)return!1;for(var f=a;f--;){var c=s[f];if(!(u?c in e:zt.call(e,c)))return!1}var l=o.get(t),d=o.get(e);if(l&&d)return l==e&&d==t;var h=!0;o.set(t,e),o.set(e,t);for(var p=u;++f<a;){var v=t[c=s[f]],y=e[c];if(n)var m=u?n(y,v,c,e,t,o):n(v,y,c,t,e,o);if(!(void 0===m?v===y||i(v,y,r,n,o):m)){h=!1;break}p||(p="constructor"==c)}if(h&&!p){var g=t.constructor,b=e.constructor;g==b||!("constructor"in t)||!("constructor"in e)||"function"==typeof g&&g instanceof g&&"function"==typeof b&&b instanceof b||(h=!1)}return o.delete(t),o.delete(e),h}(t,e,r,n,i,o))}function fe(t,e,r,n,i){return t===e||(null==t||null==e||!m(t)&&!m(e)?t!=t&&e!=e:ae(t,e,r,n,fe,i))}function ce(t){return t==t&&!V(t)}function le(t,e){return function(r){return null!=r&&r[t]===e&&(void 0!==e||t in Object(r))}}function de(t){var e=function(t){for(var e=K(t),r=e.length;r--;){var n=e[r],i=t[n];e[r]=[n,i,ce(i)]}return e}(t);return 1==e.length&&e[0][2]?le(e[0][0],e[0][1]):function(r){return r===t||function(t,e,r,n){var i=r.length,o=i,u=!n;if(null==t)return!o;for(t=Object(t);i--;){var s=r[i];if(u&&s[2]?s[1]!==t[s[0]]:!(s[0]in t))return!1}for(;++i<o;){var a=(s=r[i])[0],f=t[a],c=s[1];if(u&&s[2]){if(void 0===f&&!(a in t))return!1}else{var l=new Nt;if(n)var d=n(f,c,a,t,e,l);if(!(void 0===d?fe(c,f,3,n,l):d))return!1}}return!0}(r,t,e)}}function he(t){return"symbol"==typeof t||m(t)&&"[object Symbol]"==y(t)}var pe=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ve=/^\w*$/;function ye(t,e){if(S(t))return!1;var r=typeof t;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=t&&!he(t))||ve.test(t)||!pe.test(t)||null!=e&&t in Object(e)}function me(t,e){if("function"!=typeof t||null!=e&&"function"!=typeof e)throw new TypeError("Expected a function");var r=function(){var n=arguments,i=e?e.apply(this,n):n[0],o=r.cache;if(o.has(i))return o.get(i);var u=t.apply(this,n);return r.cache=o.set(i,u)||o,u};return r.cache=new(me.Cache||Mt),r}me.Cache=Mt;var ge=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,be=/\\(\\)?/g,we=function(t){var e=me(t,function(t){return 500===r.size&&r.clear(),t}),r=e.cache;return e}(function(t){var e=[];return 46===t.charCodeAt(0)&&e.push(""),t.replace(ge,function(t,r,n,i){e.push(n?i.replace(be,"$1"):r||t)}),e}),_e=we;function je(t,e){for(var r=-1,n=null==t?0:t.length,i=Array(n);++r<n;)i[r]=e(t[r],r,t);return i}var Oe=f?f.prototype:void 0,Se=Oe?Oe.toString:void 0;function $e(t){if("string"==typeof t)return t;if(S(t))return je(t,$e)+"";if(he(t))return Se?Se.call(t):"";var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Ee(t){return null==t?"":$e(t)}function Me(t,e){return S(t)?t:ye(t,e)?[t]:_e(Ee(t))}function Ne(t){if("string"==typeof t||he(t))return t;var e=t+"";return"0"==e&&1/t==-1/0?"-0":e}function Ae(t,e){for(var r=0,n=(e=Me(e,t)).length;null!=t&&r<n;)t=t[Ne(e[r++])];return r&&r==n?t:void 0}function xe(t,e,r){var n=null==t?void 0:Ae(t,e);return void 0===n?r:n}function Te(t,e){return null!=t&&e in Object(t)}function Pe(t,e){return null!=t&&function(t,e,r){for(var n=-1,i=(e=Me(e,t)).length,o=!1;++n<i;){var u=Ne(e[n]);if(!(o=null!=t&&r(t,u)))break;t=t[u]}return o||++n!=i?o:!!(i=null==t?0:t.length)&&T(i)&&x(u,i)&&(S(t)||O(t))}(t,e,Te)}function Le(t){return function(e){return null==e?void 0:e[t]}}function ke(t){return ye(t)?Le(Ne(t)):function(t){return function(e){return Ae(e,t)}}(t)}function Fe(t){return"function"==typeof t?t:null==t?tt:"object"==typeof t?S(t)?function(t,e){return ye(t)&&ce(e)?le(Ne(t),e):function(r){var n=xe(r,t);return void 0===n&&n===e?Pe(r,t):fe(e,n,3)}}(t[0],t[1]):de(t):ke(t)}function De(t,e){return(S(t)?rt:nt)(t,Fe(e))}function Ce(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}function Re(t,e){var r=-1,n=J(t)?Array(t.length):[];return X(t,function(t,i,o){n[++r]=e(t,i,o)}),n}var Ie=Le("length"),qe=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");function ze(t){return qe.test(t)}var Ue="\\ud800-\\udfff",Ye="["+Ue+"]",Be="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",He="\\ud83c[\\udffb-\\udfff]",Ge="[^"+Ue+"]",Ze="(?:\\ud83c[\\udde6-\\uddff]){2}",Ve="[\\ud800-\\udbff][\\udc00-\\udfff]",We="(?:"+Be+"|"+He+")?",Je="[\\ufe0e\\ufe0f]?",Ke=Je+We+"(?:\\u200d(?:"+[Ge,Ze,Ve].join("|")+")"+Je+We+")*",Qe="(?:"+[Ge+Be+"?",Be,Ze,Ve,Ye].join("|")+")",Xe=RegExp(He+"(?="+He+")|"+Qe+Ke,"g");function tr(t){return ze(t)?function(t){for(var e=Xe.lastIndex=0;Xe.test(t);)++e;return e}(t):Ie(t)}function er(t){if(null==t)return 0;if(J(t))return"string"==typeof(e=t)||!S(e)&&m(e)&&"[object String]"==y(e)?tr(t):t.length;var e,r=ne(t);return"[object Map]"==r||"[object Set]"==r?t.size:Z(t).length}function rr(t,e={}){let r=xe(e,"fs"),n=!1;try{r.statSync(t),n=!0}catch{n=!1}return n}function nr(t){return function(t,e={}){let r=xe(e,"fs");return!!rr(t,{fs:r})&&!r.lstatSync(t).isDirectory()&&!r.lstatSync(t).isSymbolicLink()}(t,{fs:e})}function ir(t){let r=null,n=function(t,e={}){let r=null,n=xe(e,"fs"),i="";try{i=n.readFileSync(t,"utf8")}catch(t){r=t}return null!==r?{error:r}:{success:i}}(t,{fs:e});if(n.error)return n;let i=n.success,o=null;try{o=JSON.parse(i)}catch(t){r=t}return null!==r?{error:r}:{success:o}}var or=/\s/,ur=/^\s+/;function sr(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&or.test(t.charAt(e)););return e}(t)+1).replace(ur,""):t}var ar=/^[-+]0x[0-9a-f]+$/i,fr=/^0b[01]+$/i,cr=/^0o[0-7]+$/i,lr=parseInt;function dr(t){if("number"==typeof t)return t;if(he(t))return NaN;if(V(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=V(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=sr(t);var r=fr.test(t);return r||cr.test(t)?lr(t.slice(2),r?2:8):ar.test(t)?NaN:+t}var hr=1/0;function pr(t){return t?(t=dr(t))===hr||t===-1/0?17976931348623157e292*(t<0?-1:1):t==t?t:0:0===t?t:0}function vr(t){var e=pr(t),r=e%1;return e==e?r?e-r:e:0}function yr(t){return"[object String]"===Object.prototype.toString.call(t)}function mr(t){return!(!yr(t)||""===t)}function gr(t){return t!=t}function br(t){let e=!1;if(mr(t))e=!isNaN(Number(t));else if(function(t){return"[object Number]"===Object.prototype.toString.call(t)}(t)){if(gr(t))return!1;e=!0}return e}function wr(t){return br(t)?pr(t):0}function _r(t){return!!br(t)&&"number"==typeof(e=t=wr(t))&&e==vr(e);var e}var jr=a.isFinite,Or=Math.min,Sr=function(){var t=Math.round;return function(e,r){if(e=dr(e),(r=null==r?0:Or(vr(r),292))&&jr(e)){var n=(Ee(e)+"e").split("e");return+((n=(Ee(t(n[0]+"e"+(+n[1]+r)))+"e").split("e"))[0]+"e"+(+n[1]-r))}return t(e)}}(),$r=Sr;function Er(t){if(!br(t))return 0;t=wr(t);let e=$r(t);return"0"===String(e)?0:e}function Mr(t,e={}){let r=xe(e,"fs");if(!rr(t,{fs:r}))return!1;let n=r.lstatSync(t);return!n.isFile()&&!n.isSymbolicLink()}function Nr(t,e=1,r={}){let n=1,i=xe(r,"path"),o=xe(r,"fs");if(!Mr(t,{fs:o}))throw new Error(`fd[${t}] is not a folder`);var u;return null!==e&&_r(u=e)&&Er(u)>0&&(e=Er(e))<1&&(e=1),function t(r){let u=[];return Mr(r,{fs:o})?(et(o.readdirSync(r),function(s){let a=i.resolve(r,s),f=null;try{f=o.statSync(a)}catch(t){}f&&f.isDirectory()?(u.push({isFolder:!0,level:n,path:a,name:i.basename(a)}),n+=1,(n<=e||null===e)&&(u=u.concat(t(a))),n-=1):u.push({isFolder:!1,level:n,path:a,name:i.basename(a)})}),u):u}(t)}function Ar(r,n=1){return Nr(r,n,{path:t,fs:e})}function xr(t,e,r){var n=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(r=r>i?i:r)<0&&(r+=i),i=e>r?0:r-e>>>0,e>>>=0;for(var o=Array(i);++n<i;)o[n]=t[n+e];return o}var Tr=C&&C.isRegExp,Pr=Tr?L(Tr):function(t){return m(t)&&"[object RegExp]"==y(t)},Lr="\\ud800-\\udfff",kr="["+Lr+"]",Fr="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",Dr="\\ud83c[\\udffb-\\udfff]",Cr="[^"+Lr+"]",Rr="(?:\\ud83c[\\udde6-\\uddff]){2}",Ir="[\\ud800-\\udbff][\\udc00-\\udfff]",qr="(?:"+Fr+"|"+Dr+")?",zr="[\\ufe0e\\ufe0f]?",Ur=zr+qr+"(?:\\u200d(?:"+[Cr,Rr,Ir].join("|")+")"+zr+qr+")*",Yr="(?:"+[Cr+Fr+"?",Fr,Rr,Ir,kr].join("|")+")",Br=RegExp(Dr+"(?="+Dr+")|"+Yr+Ur,"g");function Hr(t){return ze(t)?function(t){return t.match(Br)||[]}(t):function(t){return t.split("")}(t)}function Gr(t,e,r){return r&&"number"!=typeof r&&function(t,e,r){if(!V(r))return!1;var n=typeof e;return!!("number"==n?J(r)&&x(e,r.length):"string"==n&&e in r)&&it(r[e],t)}(t,e,r)&&(e=r=void 0),(r=void 0===r?4294967295:r>>>0)?(t=Ee(t))&&("string"==typeof e||null!=e&&!Pr(e))&&!(e=$e(e))&&ze(t)?(i=0,o=r,u=(n=Hr(t)).length,o=void 0===o?u:o,!i&&o>=u?n:xr(n,i,o)):t.split(e,r):[];var n,i,o,u}function Zr(t){return!!_r(t)&&Er(t)>=0}function Vr(t,e){if(!mr(t))return"";if(!Zr(e))return"";if(0===(e=Er(e)))return"";let r=t.length-e;return r<0&&(r=0),t.substring(r,r+e)}function Wr(t,e){return mr(t)&&Zr(e)?0===(e=Er(e))?t:function(t,e){return mr(t)&&Zr(e)?0===(e=Er(e))?"":t.substring(0,e):""}(t,t.length-e):""}function Jr(t){if(!mr(t))return"";let e=function(t){if(!mr(t))return{path:"",isRoot:!1};for(;t.indexOf("\\\\")>=0;)t=t.replace("\\\\","\\");for(;t.indexOf("//")>=0;)t=t.replace("//","/");if(":"===Vr(t,1))return{path:`${t}\\`,isRoot:!0};if("\\"===Vr(t,1)){let e=Wr(t,1);return":"===Vr(e,1)?{path:t,isRoot:!0}:{path:e,isRoot:!1}}if("/"===Vr(t,1)){let e=Wr(t,1);return 0===e.length?{path:t,isRoot:!0}:{path:e,isRoot:!1}}return{path:t,isRoot:!1}}(t);if(e.isRoot)return e.path;let r=e.path;try{r=r.split("\\").pop().split("/").pop()}catch(t){}return r}var Kr=Array.prototype.join;function Qr(t){if(!mr(t))return"";let e=Jr(t),r=Gr(e,".");if(er(r)<=1)return e;let n="";try{r=(s=null==(i=r)?0:i.length)?xr(i,0,(o=s-(o=u||void 0===o?1:vr(o)))<0?0:o):[],n=function(t,e){return null==t?"":Kr.call(t,e)}(r,".")}catch(t){}var i,o,u,s;return n}function Xr(t){return"[object Object]"===Object.prototype.toString.call(t)}function tn(t,e){return!!Xr(t)&&!(!mr(e)&&!br(e))&&e in t}function en(t){return"[object Array]"===Object.prototype.toString.call(t)}function rn(t){return!!(function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||function(t){if(Xr(t)){for(let e in t)return!1;return!0}return!1}(t)||function(t){return!(!yr(t)||""!==t)}(t)||function(t){return!!en(t)&&0===t.length}(t)||gr(t))}function nn(t){return!(!en(t)||0===t.length||1===t.length&&rn(t[0]))}function on(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var un={exports:{}};!function(t){t.exports=function(){var t=1e3,e=6e4,r=36e5,n="millisecond",i="second",o="minute",u="hour",s="day",a="week",f="month",c="quarter",l="year",d="date",h="Invalid Date",p=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,v=/\[([^\]]+)]|YYYY|YY|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,y={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],r=t%100;return"["+t+(e[(r-20)%10]||e[r]||e[0])+"]"}},m=function(t,e,r){var n=String(t);return!n||n.length>=e?t:""+Array(e+1-n.length).join(r)+t},g={s:m,z:function(t){var e=-t.utcOffset(),r=Math.abs(e),n=Math.floor(r/60),i=r%60;return(e<=0?"+":"-")+m(n,2,"0")+":"+m(i,2,"0")},m:function t(e,r){if(e.date()<r.date())return-t(r,e);var n=12*(r.year()-e.year())+(r.month()-e.month()),i=e.clone().add(n,f),o=r-i<0,u=e.clone().add(n+(o?-1:1),f);return+(-(n+(r-i)/(o?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return{M:f,y:l,w:a,d:s,D:d,h:u,m:o,s:i,ms:n,Q:c}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},b="en",w={};w[b]=y;var _="$isDayjsObject",j=function(t){return t instanceof E||!(!t||!t[_])},O=function t(e,r,n){var i;if(!e)return b;if("string"==typeof e){var o=e.toLowerCase();w[o]&&(i=o),r&&(w[o]=r,i=o);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else{var s=e.name;w[s]=e,i=s}return!n&&i&&(b=i),i||!n&&b},S=function(t,e){if(j(t))return t.clone();var r="object"==typeof e?e:{};return r.date=t,r.args=arguments,new E(r)},$=g;$.l=O,$.i=j,$.w=function(t,e){return S(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var E=function(){function y(t){this.$L=O(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[_]=!0}var m=y.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,r=t.utc;if(null===e)return new Date(NaN);if($.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var n=e.match(p);if(n){var i=n[2]-1||0,o=(n[7]||"0").substring(0,3);return r?new Date(Date.UTC(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,o)):new Date(n[1],i,n[3]||1,n[4]||0,n[5]||0,n[6]||0,o)}}return new Date(e)}(t),this.init()},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds()},m.$utils=function(){return $},m.isValid=function(){return!(this.$d.toString()===h)},m.isSame=function(t,e){var r=S(t);return this.startOf(e)<=r&&r<=this.endOf(e)},m.isAfter=function(t,e){return S(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<S(t)},m.$g=function(t,e,r){return $.u(t)?this[e]:this.set(r,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var r=this,n=!!$.u(e)||e,c=$.p(t),h=function(t,e){var i=$.w(r.$u?Date.UTC(r.$y,e,t):new Date(r.$y,e,t),r);return n?i:i.endOf(s)},p=function(t,e){return $.w(r.toDate()[t].apply(r.toDate("s"),(n?[0,0,0,0]:[23,59,59,999]).slice(e)),r)},v=this.$W,y=this.$M,m=this.$D,g="set"+(this.$u?"UTC":"");switch(c){case l:return n?h(1,0):h(31,11);case f:return n?h(1,y):h(0,y+1);case a:var b=this.$locale().weekStart||0,w=(v<b?v+7:v)-b;return h(n?m-w:m+(6-w),y);case s:case d:return p(g+"Hours",0);case u:return p(g+"Minutes",1);case o:return p(g+"Seconds",2);case i:return p(g+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var r,a=$.p(t),c="set"+(this.$u?"UTC":""),h=(r={},r[s]=c+"Date",r[d]=c+"Date",r[f]=c+"Month",r[l]=c+"FullYear",r[u]=c+"Hours",r[o]=c+"Minutes",r[i]=c+"Seconds",r[n]=c+"Milliseconds",r)[a],p=a===s?this.$D+(e-this.$W):e;if(a===f||a===l){var v=this.clone().set(d,1);v.$d[h](p),v.init(),this.$d=v.set(d,Math.min(this.$D,v.daysInMonth())).$d}else h&&this.$d[h](p);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[$.p(t)]()},m.add=function(n,c){var d,h=this;n=Number(n);var p=$.p(c),v=function(t){var e=S(h);return $.w(e.date(e.date()+Math.round(t*n)),h)};if(p===f)return this.set(f,this.$M+n);if(p===l)return this.set(l,this.$y+n);if(p===s)return v(1);if(p===a)return v(7);var y=(d={},d[o]=e,d[u]=r,d[i]=t,d)[p]||1,m=this.$d.getTime()+n*y;return $.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,r=this.$locale();if(!this.isValid())return r.invalidDate||h;var n=t||"YYYY-MM-DDTHH:mm:ssZ",i=$.z(this),o=this.$H,u=this.$m,s=this.$M,a=r.weekdays,f=r.months,c=r.meridiem,l=function(t,r,i,o){return t&&(t[r]||t(e,n))||i[r].slice(0,o)},d=function(t){return $.s(o%12||12,t,"0")},p=c||function(t,e,r){var n=t<12?"AM":"PM";return r?n.toLowerCase():n};return n.replace(v,function(t,n){return n||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return $.s(e.$y,4,"0");case"M":return s+1;case"MM":return $.s(s+1,2,"0");case"MMM":return l(r.monthsShort,s,f,3);case"MMMM":return l(f,s);case"D":return e.$D;case"DD":return $.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return l(r.weekdaysMin,e.$W,a,2);case"ddd":return l(r.weekdaysShort,e.$W,a,3);case"dddd":return a[e.$W];case"H":return String(o);case"HH":return $.s(o,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return p(o,u,!0);case"A":return p(o,u,!1);case"m":return String(u);case"mm":return $.s(u,2,"0");case"s":return String(e.$s);case"ss":return $.s(e.$s,2,"0");case"SSS":return $.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")})},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(n,d,h){var p,v=this,y=$.p(d),m=S(n),g=(m.utcOffset()-this.utcOffset())*e,b=this-m,w=function(){return $.m(v,m)};switch(y){case l:p=w()/12;break;case f:p=w();break;case c:p=w()/3;break;case a:p=(b-g)/6048e5;break;case s:p=(b-g)/864e5;break;case u:p=b/r;break;case o:p=b/e;break;case i:p=b/t;break;default:p=b}return h?p:$.a(p)},m.daysInMonth=function(){return this.endOf(f).$D},m.$locale=function(){return w[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var r=this.clone(),n=O(t,e,!0);return n&&(r.$L=n),r},m.clone=function(){return $.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},y}(),M=E.prototype;return S.prototype=M,[["$ms",n],["$s",i],["$m",o],["$H",u],["$W",s],["$M",f],["$y",l],["$D",d]].forEach(function(t){M[t[1]]=function(e){return this.$g(e,t[0],t[1])}}),S.extend=function(t,e){return t.$i||(t(e,E,S),t.$i=!0),S},S.locale=O,S.isDayjs=j,S.unix=function(t){return S(1e3*t)},S.en=w[b],S.Ls=w,S.p={},S}()}(un);var sn=on(un.exports);function an(t){if(!mr(t))return!1;let e="YYYY-MM-DDTHH:mm:ss";return t===sn(t,e).format(e)}function fn(t){let e=Object.prototype.toString.call(t);return"[object Function]"===e||"[object AsyncFunction]"===e}function cn(t,e){let r=function(){let t,e,r=new Promise(function(){t=arguments[0],e=arguments[1]});return r.resolve=t,r.reject=e,r}();if(!en(t)&&!Xr(t))return r.reject("rs is not an array or object"),r;let n=!1;if(Xr(t)){n=!0;let e=[];et(t,(t,r)=>{e.push({k:r,v:t})}),t=e}fn(e)||(e=function(t){return t});let i=-1,o=[];return t.reduce(function(t,r){return t.then(function(t){o.push(t),i+=1;let u=i,s=r;return n&&(u=r.k,s=r.v),fn(e)?e(s,u):s})},Promise.resolve()).then(function(t){var e,n,i;o.push(t),i=null==(e=o)?0:e.length,o=i?xr(e,(n=void 0===n?1:vr(n))<0?0:n,i):[],r.resolve(o)}).catch(function(t){r.reject(t)}),r}return(e,r)=>{let n={},i=async i=>{if(tn(n,i))return n[i];let o=await(async n=>{let i=t.resolve(r,`${n}.json`),o=t.resolve(e,`${n}.json`),u="";if(nr(i))u=i;else{if(!nr(o))throw console.log(`fpParam[${i}] or fpOhlc[${o}] do not exist`),new Error(`invalid key[${n}]`);u=o}let s=xe(ir(u),"success",null);if(!nn(s))throw new Error(`fp[${u}] no data`);return s})(i);return n[i]=o,o},o=[],u=async()=>{if(er(o)>0)return o;let t=t=>{let e=Ar(t);return e=De(e,t=>"json"===function(t){if(!mr(t))return"";let e=Gr(Jr(t),".");if(er(e)<=1)return"";let r="";try{r=Ce(e)}catch(t){}return r}(t.name)),e},n=[],u=t(e);await cn(u,async t=>{let e=Qr(t.name),r=await i(e);n.push({type:"ohlc",key:e,arr:r})});let s=t(r);return await cn(s,async t=>{let e=Qr(t.name),r=await i(e);n.push({type:"param",key:e,arr:r})}),o=n,n},s={},a=async(t,e)=>{if(!an(t))throw new Error("invalid timeStart");if(!an(e))throw new Error("invalid timeEnd");let r=`${t}:${e}`;if(tn(s,r))return s[r];let n=await u(),i="1000-01-01T00:00:00",o="9999-01-01T00:00:00";if(et(n,t=>{let e=(r=t.arr)&&r.length?r[0]:void 0;var r;let n=Ce(t.arr),u=xe(e,"time",""),s=xe(n,"time","");"ohlc"===t.type&&i<u&&(i=u),o>s&&(o=s)}),t<i)throw new Error(`timeStart[${t}] < timeStartData[${i}]`);if(e>o)throw new Error(`timeEnd[${e}] > timeEndData[${o}]`);let a=[];return et(n,r=>{let n=De(r.arr,r=>r.time>=t&&r.time<=e);a.push({key:r.key,arr:n})}),s[r]=a,a},f={getKeysParam:()=>{let t=Ar(r);var e,n;return n=t=>Qr(t.name),(S(e=t)?je:Re)(e,Fe(n))},getTimeSeries:i,getTimeSeriesByTimeRange:async(t,e,r)=>{let n=await i(t);return n=De(n,t=>t.time>=e&&t.time<=r),n},getTimeSeriesFull:u,getTimeSeriesFullByTimeRange:a,buildGetTimeSeriesByTimeRange:async(t,e)=>{let r=await a(t,e),n={};return et(r,t=>{n[t.key]=t.arr}),async r=>{let i=xe(n,r,[]);if(!nn(i))throw new Error(`can not get series by key[${r}] bewteen timeStart[${t}] and timeEnd[${e}]`);return i}},buildGetTimeValueByTimeRange:async(t,e)=>{let r=await a(t,e),n={};return et(r,t=>{et(t.arr,e=>{let r=`${t.key}_${e.time}`;n[r]=e})}),async(r,i)=>{let o=xe(n,`${r}_${i}`,{});if(!function(t){if(Xr(t)){for(let e in t)return!0;return!1}return!1}(o))throw new Error(`can not get value by key[${r}] and time[${i}] bewteen timeStart[${t}] and timeEnd[${e}]`);return o}}};return f}}(t,e)}(pn,pn.exports);var vn=hn(pn.exports);function yn(t){if(!zr(t))return!1;return xr(t)>=0}function mn(t,e=0){if(!Nr(t))return"";if(!yn(e))return"";return t=Ar(t),Er(t,e).toFixed(e)}function gn(t,e={}){let r=st(e,"fs"),n=!1;try{r.statSync(t),n=!0}catch{n=!1}return n}function bn(t,e={}){let r=st(e,"fs");if(!gn(t,{fs:r}))return!1;let n=r.lstatSync(t);return!n.isFile()&&!n.isSymbolicLink()}function wn(t,e={}){let r=st(e,"fs");if(bn(t,{fs:r}))return{success:"input folder is already exists: "+t};if(gn(t,{fs:r}))return{error:"input path already exists: "+t};try{r.mkdirSync(t,{recursive:!0})}catch(t){return{error:t}}return{success:"done: "+t}}function _n(t,e={}){let r=st(e,"fs");if(!gn(t,{fs:r}))return{success:"file does not exist: "+t};if(!function(t,e={}){let r=st(e,"fs");return!!gn(t,{fs:r})&&!r.lstatSync(t).isDirectory()&&!r.lstatSync(t).isSymbolicLink()}(t,{fs:r}))return{error:"input path is not a file: "+t};try{r.unlinkSync(t)}catch(t){return{error:t}}return{success:"done: "+t}}function jn(t){return bn(t,{fs:e})}function On(t){return"[object Object]"===Object.prototype.toString.call(t)}function Sn(t){return"[object Array]"===Object.prototype.toString.call(t)}function $n(t){return!0===(e=t)||!1===e||p(e)&&"[object Boolean]"==h(e);var e}function En(t,e){if(!Gt(t))return"";if(!yn(e))return"";if(0===(e=xr(e)))return"";let r=t.length-e;return r<0&&(r=0),t.substring(r,r+e)}function Mn(t,e){return Gt(t)&&yn(e)?0===(e=xr(e))?t:function(t,e){return Gt(t)&&yn(e)?0===(e=xr(e))?"":t.substring(0,e):""}(t,t.length-e):""}function Nn(t){if(!Gt(t))return{path:"",isRoot:!1};for(;t.indexOf("\\\\")>=0;)t=t.replace("\\\\","\\");for(;t.indexOf("//")>=0;)t=t.replace("//","/");if(":"===En(t,1))return{path:`${t}\\`,isRoot:!0};if("\\"===En(t,1)){let e=Mn(t,1);return":"===En(e,1)?{path:t,isRoot:!0}:{path:e,isRoot:!1}}if("/"===En(t,1)){let e=Mn(t,1);return 0===e.length?{path:t,isRoot:!0}:{path:e,isRoot:!1}}return{path:t,isRoot:!1}}function An(t){if(!Gt(t))return"";let e=Nn(t);if(e.isRoot)return e.path;let r=function(t){if(!Gt(t))return"";let e=Nn(t);if(e.isRoot)return e.path;let r=e.path;try{r=r.split("\\").pop().split("/").pop()}catch(t){}return r}(t=e.path);if(!Gt(r))return t;let n=Nn(t=Mn(t,r.length));return n.isRoot,n.path}function xn(t,r,n={}){let i=null;if(!On(r)&&!Sn(r))return{error:"inp is not an object or array"};let o=st(n,"useFormat",null);$n(o)||(o=!1);let u="";try{u=o?JSON.stringify(r,null,2):JSON.stringify(r)}catch(t){i=t}if(null!==i)return{error:i};let s=function(t,e,r={}){let n=null,i=st(r,"fs"),o=An(t);bn(o,{fs:i})||wn(o,{fs:i});try{i.writeFileSync(t,e,"utf8")}catch(t){n=t}return null!==n?{error:n}:{success:t}}(t,u,{fs:e});return s}function Tn(t,e){return!!On(t)&&(!(!Gt(e)&&!Nr(e))&&e in t)}function Pn(t){return!!function(t){return"[object Undefined]"===Object.prototype.toString.call(t)}(t)||(!!function(t){return"[object Null]"===Object.prototype.toString.call(t)}(t)||(!!function(t){if(On(t)){for(let e in t)return!1;return!0}return!1}(t)||(!!function(t){return!(!Ht(t)||""!==t)}(t)||(!!function(t){return!!Sn(t)&&0===t.length}(t)||!!Mr(t)))))}function Ln(t){return!!Sn(t)&&(0!==t.length&&(1!==t.length||!Pn(t[0])))}function kn(t,e,r=2){if(!Nr(t))return[];if(t=Ar(t),!Nr(e))return[];if(e=Ar(e),Ur(r)||(r=2),(r=xr(r))<=0)throw new Error(`num[${r}] <= 0`);let n=(e-t)/r,i=t,o=[];for(let t=0;t<=r;t++)o.push(i),i+=n;return o}
12
+ /*!
13
+ * decimal.js v10.6.0
14
+ * An arbitrary-precision Decimal type for JavaScript.
15
+ * https://github.com/MikeMcl/decimal.js
16
+ * Copyright (c) 2025 Michael Mclaughlin <M8ch88l@gmail.com>
17
+ * MIT Licence
18
+ */var Fn,Dn,Cn=9e15,Rn=1e9,In="0123456789abcdef",qn="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",zn="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Un={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-Cn,maxE:Cn,crypto:!1},Yn=!0,Bn="[DecimalError] ",Hn=Bn+"Invalid argument: ",Gn=Bn+"Precision limit exceeded",Zn=Bn+"crypto unavailable",Vn="[object Decimal]",Wn=Math.floor,Jn=Math.pow,Kn=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Qn=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Xn=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,ti=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,ei=1e7,ri=qn.length-1,ni=zn.length-1,ii={toStringTag:Vn};function oi(t){var e,r,n,i=t.length-1,o="",u=t[0];if(i>0){for(o+=u,e=1;e<i;e++)(r=7-(n=t[e]+"").length)&&(o+=yi(r)),o+=n;(r=7-(n=(u=t[e])+"").length)&&(o+=yi(r))}else if(0===u)return"0";for(;u%10==0;)u/=10;return o+u}function ui(t,e,r){if(t!==~~t||t<e||t>r)throw Error(Hn+t)}function si(t,e,r,n){var i,o,u,s;for(o=t[0];o>=10;o/=10)--e;return--e<0?(e+=7,i=0):(i=Math.ceil((e+1)/7),e%=7),o=Jn(10,7-e),s=t[i]%o|0,null==n?e<3?(0==e?s=s/100|0:1==e&&(s=s/10|0),u=r<4&&99999==s||r>3&&49999==s||5e4==s||0==s):u=(r<4&&s+1==o||r>3&&s+1==o/2)&&(t[i+1]/o/100|0)==Jn(10,e-2)-1||(s==o/2||0==s)&&!(t[i+1]/o/100|0):e<4?(0==e?s=s/1e3|0:1==e?s=s/100|0:2==e&&(s=s/10|0),u=(n||r<4)&&9999==s||!n&&r>3&&4999==s):u=((n||r<4)&&s+1==o||!n&&r>3&&s+1==o/2)&&(t[i+1]/o/1e3|0)==Jn(10,e-3)-1,u}function ai(t,e,r){for(var n,i,o=[0],u=0,s=t.length;u<s;){for(i=o.length;i--;)o[i]*=e;for(o[0]+=In.indexOf(t.charAt(u++)),n=0;n<o.length;n++)o[n]>r-1&&(void 0===o[n+1]&&(o[n+1]=0),o[n+1]+=o[n]/r|0,o[n]%=r)}return o.reverse()}ii.absoluteValue=ii.abs=function(){var t=new this.constructor(this);return t.s<0&&(t.s=1),ci(t)},ii.ceil=function(){return ci(new this.constructor(this),this.e+1,2)},ii.clampedTo=ii.clamp=function(t,e){var r=this,n=r.constructor;if(t=new n(t),e=new n(e),!t.s||!e.s)return new n(NaN);if(t.gt(e))throw Error(Hn+e);return r.cmp(t)<0?t:r.cmp(e)>0?e:new n(r)},ii.comparedTo=ii.cmp=function(t){var e,r,n,i,o=this,u=o.d,s=(t=new o.constructor(t)).d,a=o.s,f=t.s;if(!u||!s)return a&&f?a!==f?a:u===s?0:!u^a<0?1:-1:NaN;if(!u[0]||!s[0])return u[0]?a:s[0]?-f:0;if(a!==f)return a;if(o.e!==t.e)return o.e>t.e^a<0?1:-1;for(e=0,r=(n=u.length)<(i=s.length)?n:i;e<r;++e)if(u[e]!==s[e])return u[e]>s[e]^a<0?1:-1;return n===i?0:n>i^a<0?1:-1},ii.cosine=ii.cos=function(){var t,e,r=this,n=r.constructor;return r.d?r.d[0]?(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(t,e){var r,n,i;if(e.isZero())return e;n=e.d.length,n<32?i=(1/Ei(4,r=Math.ceil(n/3))).toString():(r=16,i="2.3283064365386962890625e-10");t.precision+=r,e=$i(t,1,e.times(i),new t(1));for(var o=r;o--;){var u=e.times(e);e=u.times(u).minus(u).times(8).plus(1)}return t.precision-=r,e}(n,Mi(n,r)),n.precision=t,n.rounding=e,ci(2==Dn||3==Dn?r.neg():r,t,e,!0)):new n(1):new n(NaN)},ii.cubeRoot=ii.cbrt=function(){var t,e,r,n,i,o,u,s,a,f,c=this,l=c.constructor;if(!c.isFinite()||c.isZero())return new l(c);for(Yn=!1,(o=c.s*Jn(c.s*c,1/3))&&Math.abs(o)!=1/0?n=new l(o.toString()):(r=oi(c.d),(o=((t=c.e)-r.length+1)%3)&&(r+=1==o||-2==o?"0":"00"),o=Jn(r,1/3),t=Wn((t+1)/3)-(t%3==(t<0?-1:2)),(n=new l(r=o==1/0?"5e"+t:(r=o.toExponential()).slice(0,r.indexOf("e")+1)+t)).s=c.s),u=(t=l.precision)+3;;)if(f=(a=(s=n).times(s).times(s)).plus(c),n=fi(f.plus(c).times(s),f.plus(a),u+2,1),oi(s.d).slice(0,u)===(r=oi(n.d)).slice(0,u)){if("9999"!=(r=r.slice(u-3,u+1))&&(i||"4999"!=r)){+r&&(+r.slice(1)||"5"!=r.charAt(0))||(ci(n,t+1,1),e=!n.times(n).times(n).eq(c));break}if(!i&&(ci(s,t+1,0),s.times(s).times(s).eq(c))){n=s;break}u+=4,i=1}return Yn=!0,ci(n,t,l.rounding,e)},ii.decimalPlaces=ii.dp=function(){var t,e=this.d,r=NaN;if(e){if(r=7*((t=e.length-1)-Wn(this.e/7)),t=e[t])for(;t%10==0;t/=10)r--;r<0&&(r=0)}return r},ii.dividedBy=ii.div=function(t){return fi(this,new this.constructor(t))},ii.dividedToIntegerBy=ii.divToInt=function(t){var e=this.constructor;return ci(fi(this,new e(t),0,1,1),e.precision,e.rounding)},ii.equals=ii.eq=function(t){return 0===this.cmp(t)},ii.floor=function(){return ci(new this.constructor(this),this.e+1,3)},ii.greaterThan=ii.gt=function(t){return this.cmp(t)>0},ii.greaterThanOrEqualTo=ii.gte=function(t){var e=this.cmp(t);return 1==e||0===e},ii.hyperbolicCosine=ii.cosh=function(){var t,e,r,n,i,o=this,u=o.constructor,s=new u(1);if(!o.isFinite())return new u(o.s?1/0:NaN);if(o.isZero())return s;r=u.precision,n=u.rounding,u.precision=r+Math.max(o.e,o.sd())+4,u.rounding=1,(i=o.d.length)<32?e=(1/Ei(4,t=Math.ceil(i/3))).toString():(t=16,e="2.3283064365386962890625e-10"),o=$i(u,1,o.times(e),new u(1),!0);for(var a,f=t,c=new u(8);f--;)a=o.times(o),o=s.minus(a.times(c.minus(a.times(c))));return ci(o,u.precision=r,u.rounding=n,!0)},ii.hyperbolicSine=ii.sinh=function(){var t,e,r,n,i=this,o=i.constructor;if(!i.isFinite()||i.isZero())return new o(i);if(e=o.precision,r=o.rounding,o.precision=e+Math.max(i.e,i.sd())+4,o.rounding=1,(n=i.d.length)<3)i=$i(o,2,i,i,!0);else{t=(t=1.4*Math.sqrt(n))>16?16:0|t,i=$i(o,2,i=i.times(1/Ei(5,t)),i,!0);for(var u,s=new o(5),a=new o(16),f=new o(20);t--;)u=i.times(i),i=i.times(s.plus(u.times(a.times(u).plus(f))))}return o.precision=e,o.rounding=r,ci(i,e,r,!0)},ii.hyperbolicTangent=ii.tanh=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+7,n.rounding=1,fi(r.sinh(),r.cosh(),n.precision=t,n.rounding=e)):new n(r.s)},ii.inverseCosine=ii.acos=function(){var t=this,e=t.constructor,r=t.abs().cmp(1),n=e.precision,i=e.rounding;return-1!==r?0===r?t.isNeg()?pi(e,n,i):new e(0):new e(NaN):t.isZero()?pi(e,n+4,i).times(.5):(e.precision=n+6,e.rounding=1,t=new e(1).minus(t).div(t.plus(1)).sqrt().atan(),e.precision=n,e.rounding=i,t.times(2))},ii.inverseHyperbolicCosine=ii.acosh=function(){var t,e,r=this,n=r.constructor;return r.lte(1)?new n(r.eq(1)?0:NaN):r.isFinite()?(t=n.precision,e=n.rounding,n.precision=t+Math.max(Math.abs(r.e),r.sd())+4,n.rounding=1,Yn=!1,r=r.times(r).minus(1).sqrt().plus(r),Yn=!0,n.precision=t,n.rounding=e,r.ln()):new n(r)},ii.inverseHyperbolicSine=ii.asinh=function(){var t,e,r=this,n=r.constructor;return!r.isFinite()||r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+2*Math.max(Math.abs(r.e),r.sd())+6,n.rounding=1,Yn=!1,r=r.times(r).plus(1).sqrt().plus(r),Yn=!0,n.precision=t,n.rounding=e,r.ln())},ii.inverseHyperbolicTangent=ii.atanh=function(){var t,e,r,n,i=this,o=i.constructor;return i.isFinite()?i.e>=0?new o(i.abs().eq(1)?i.s/0:i.isZero()?i:NaN):(t=o.precision,e=o.rounding,n=i.sd(),Math.max(n,t)<2*-i.e-1?ci(new o(i),t,e,!0):(o.precision=r=n-i.e,i=fi(i.plus(1),new o(1).minus(i),r+t,1),o.precision=t+4,o.rounding=1,i=i.ln(),o.precision=t,o.rounding=e,i.times(.5))):new o(NaN)},ii.inverseSine=ii.asin=function(){var t,e,r,n,i=this,o=i.constructor;return i.isZero()?new o(i):(e=i.abs().cmp(1),r=o.precision,n=o.rounding,-1!==e?0===e?((t=pi(o,r+4,n).times(.5)).s=i.s,t):new o(NaN):(o.precision=r+6,o.rounding=1,i=i.div(new o(1).minus(i.times(i)).sqrt().plus(1)).atan(),o.precision=r,o.rounding=n,i.times(2)))},ii.inverseTangent=ii.atan=function(){var t,e,r,n,i,o,u,s,a,f=this,c=f.constructor,l=c.precision,d=c.rounding;if(f.isFinite()){if(f.isZero())return new c(f);if(f.abs().eq(1)&&l+4<=ni)return(u=pi(c,l+4,d).times(.25)).s=f.s,u}else{if(!f.s)return new c(NaN);if(l+4<=ni)return(u=pi(c,l+4,d).times(.5)).s=f.s,u}for(c.precision=s=l+10,c.rounding=1,t=r=Math.min(28,s/7+2|0);t;--t)f=f.div(f.times(f).plus(1).sqrt().plus(1));for(Yn=!1,e=Math.ceil(s/7),n=1,a=f.times(f),u=new c(f),i=f;-1!==t;)if(i=i.times(a),o=u.minus(i.div(n+=2)),i=i.times(a),void 0!==(u=o.plus(i.div(n+=2))).d[e])for(t=e;u.d[t]===o.d[t]&&t--;);return r&&(u=u.times(2<<r-1)),Yn=!0,ci(u,c.precision=l,c.rounding=d,!0)},ii.isFinite=function(){return!!this.d},ii.isInteger=ii.isInt=function(){return!!this.d&&Wn(this.e/7)>this.d.length-2},ii.isNaN=function(){return!this.s},ii.isNegative=ii.isNeg=function(){return this.s<0},ii.isPositive=ii.isPos=function(){return this.s>0},ii.isZero=function(){return!!this.d&&0===this.d[0]},ii.lessThan=ii.lt=function(t){return this.cmp(t)<0},ii.lessThanOrEqualTo=ii.lte=function(t){return this.cmp(t)<1},ii.logarithm=ii.log=function(t){var e,r,n,i,o,u,s,a,f=this,c=f.constructor,l=c.precision,d=c.rounding;if(null==t)t=new c(10),e=!0;else{if(r=(t=new c(t)).d,t.s<0||!r||!r[0]||t.eq(1))return new c(NaN);e=t.eq(10)}if(r=f.d,f.s<0||!r||!r[0]||f.eq(1))return new c(r&&!r[0]?-1/0:1!=f.s?NaN:r?0:1/0);if(e)if(r.length>1)o=!0;else{for(i=r[0];i%10==0;)i/=10;o=1!==i}if(Yn=!1,u=_i(f,s=l+5),n=e?hi(c,s+10):_i(t,s),si((a=fi(u,n,s,1)).d,i=l,d))do{if(u=_i(f,s+=10),n=e?hi(c,s+10):_i(t,s),a=fi(u,n,s,1),!o){+oi(a.d).slice(i+1,i+15)+1==1e14&&(a=ci(a,l+1,0));break}}while(si(a.d,i+=10,d));return Yn=!0,ci(a,l,d)},ii.minus=ii.sub=function(t){var e,r,n,i,o,u,s,a,f,c,l,d,h=this,p=h.constructor;if(t=new p(t),!h.d||!t.d)return h.s&&t.s?h.d?t.s=-t.s:t=new p(t.d||h.s!==t.s?h:NaN):t=new p(NaN),t;if(h.s!=t.s)return t.s=-t.s,h.plus(t);if(f=h.d,d=t.d,s=p.precision,a=p.rounding,!f[0]||!d[0]){if(d[0])t.s=-t.s;else{if(!f[0])return new p(3===a?-0:0);t=new p(h)}return Yn?ci(t,s,a):t}if(r=Wn(t.e/7),c=Wn(h.e/7),f=f.slice(),o=c-r){for((l=o<0)?(e=f,o=-o,u=d.length):(e=d,r=c,u=f.length),o>(n=Math.max(Math.ceil(s/7),u)+2)&&(o=n,e.length=1),e.reverse(),n=o;n--;)e.push(0);e.reverse()}else{for((l=(n=f.length)<(u=d.length))&&(u=n),n=0;n<u;n++)if(f[n]!=d[n]){l=f[n]<d[n];break}o=0}for(l&&(e=f,f=d,d=e,t.s=-t.s),u=f.length,n=d.length-u;n>0;--n)f[u++]=0;for(n=d.length;n>o;){if(f[--n]<d[n]){for(i=n;i&&0===f[--i];)f[i]=ei-1;--f[i],f[n]+=ei}f[n]-=d[n]}for(;0===f[--u];)f.pop();for(;0===f[0];f.shift())--r;return f[0]?(t.d=f,t.e=di(f,r),Yn?ci(t,s,a):t):new p(3===a?-0:0)},ii.modulo=ii.mod=function(t){var e,r=this,n=r.constructor;return t=new n(t),!r.d||!t.s||t.d&&!t.d[0]?new n(NaN):!t.d||r.d&&!r.d[0]?ci(new n(r),n.precision,n.rounding):(Yn=!1,9==n.modulo?(e=fi(r,t.abs(),0,3,1)).s*=t.s:e=fi(r,t,0,n.modulo,1),e=e.times(t),Yn=!0,r.minus(e))},ii.naturalExponential=ii.exp=function(){return wi(this)},ii.naturalLogarithm=ii.ln=function(){return _i(this)},ii.negated=ii.neg=function(){var t=new this.constructor(this);return t.s=-t.s,ci(t)},ii.plus=ii.add=function(t){var e,r,n,i,o,u,s,a,f,c,l=this,d=l.constructor;if(t=new d(t),!l.d||!t.d)return l.s&&t.s?l.d||(t=new d(t.d||l.s===t.s?l:NaN)):t=new d(NaN),t;if(l.s!=t.s)return t.s=-t.s,l.minus(t);if(f=l.d,c=t.d,s=d.precision,a=d.rounding,!f[0]||!c[0])return c[0]||(t=new d(l)),Yn?ci(t,s,a):t;if(o=Wn(l.e/7),n=Wn(t.e/7),f=f.slice(),i=o-n){for(i<0?(r=f,i=-i,u=c.length):(r=c,n=o,u=f.length),i>(u=(o=Math.ceil(s/7))>u?o+1:u+1)&&(i=u,r.length=1),r.reverse();i--;)r.push(0);r.reverse()}for((u=f.length)-(i=c.length)<0&&(i=u,r=c,c=f,f=r),e=0;i;)e=(f[--i]=f[i]+c[i]+e)/ei|0,f[i]%=ei;for(e&&(f.unshift(e),++n),u=f.length;0==f[--u];)f.pop();return t.d=f,t.e=di(f,n),Yn?ci(t,s,a):t},ii.precision=ii.sd=function(t){var e,r=this;if(void 0!==t&&t!==!!t&&1!==t&&0!==t)throw Error(Hn+t);return r.d?(e=vi(r.d),t&&r.e+1>e&&(e=r.e+1)):e=NaN,e},ii.round=function(){var t=this,e=t.constructor;return ci(new e(t),t.e+1,e.rounding)},ii.sine=ii.sin=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+Math.max(r.e,r.sd())+7,n.rounding=1,r=function(t,e){var r,n=e.d.length;if(n<3)return e.isZero()?e:$i(t,2,e,e);r=(r=1.4*Math.sqrt(n))>16?16:0|r,e=e.times(1/Ei(5,r)),e=$i(t,2,e,e);for(var i,o=new t(5),u=new t(16),s=new t(20);r--;)i=e.times(e),e=e.times(o.plus(i.times(u.times(i).minus(s))));return e}(n,Mi(n,r)),n.precision=t,n.rounding=e,ci(Dn>2?r.neg():r,t,e,!0)):new n(NaN)},ii.squareRoot=ii.sqrt=function(){var t,e,r,n,i,o,u=this,s=u.d,a=u.e,f=u.s,c=u.constructor;if(1!==f||!s||!s[0])return new c(!f||f<0&&(!s||s[0])?NaN:s?u:1/0);for(Yn=!1,0==(f=Math.sqrt(+u))||f==1/0?(((e=oi(s)).length+a)%2==0&&(e+="0"),f=Math.sqrt(e),a=Wn((a+1)/2)-(a<0||a%2),n=new c(e=f==1/0?"5e"+a:(e=f.toExponential()).slice(0,e.indexOf("e")+1)+a)):n=new c(f.toString()),r=(a=c.precision)+3;;)if(n=(o=n).plus(fi(u,o,r+2,1)).times(.5),oi(o.d).slice(0,r)===(e=oi(n.d)).slice(0,r)){if("9999"!=(e=e.slice(r-3,r+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(ci(n,a+1,1),t=!n.times(n).eq(u));break}if(!i&&(ci(o,a+1,0),o.times(o).eq(u))){n=o;break}r+=4,i=1}return Yn=!0,ci(n,a,c.rounding,t)},ii.tangent=ii.tan=function(){var t,e,r=this,n=r.constructor;return r.isFinite()?r.isZero()?new n(r):(t=n.precision,e=n.rounding,n.precision=t+10,n.rounding=1,(r=r.sin()).s=1,r=fi(r,new n(1).minus(r.times(r)).sqrt(),t+10,0),n.precision=t,n.rounding=e,ci(2==Dn||4==Dn?r.neg():r,t,e,!0)):new n(NaN)},ii.times=ii.mul=function(t){var e,r,n,i,o,u,s,a,f,c=this,l=c.constructor,d=c.d,h=(t=new l(t)).d;if(t.s*=c.s,!(d&&d[0]&&h&&h[0]))return new l(!t.s||d&&!d[0]&&!h||h&&!h[0]&&!d?NaN:d&&h?0*t.s:t.s/0);for(r=Wn(c.e/7)+Wn(t.e/7),(a=d.length)<(f=h.length)&&(o=d,d=h,h=o,u=a,a=f,f=u),o=[],n=u=a+f;n--;)o.push(0);for(n=f;--n>=0;){for(e=0,i=a+n;i>n;)s=o[i]+h[n]*d[i-n-1]+e,o[i--]=s%ei|0,e=s/ei|0;o[i]=(o[i]+e)%ei|0}for(;!o[--u];)o.pop();return e?++r:o.shift(),t.d=o,t.e=di(o,r),Yn?ci(t,l.precision,l.rounding):t},ii.toBinary=function(t,e){return Ni(this,2,t,e)},ii.toDecimalPlaces=ii.toDP=function(t,e){var r=this,n=r.constructor;return r=new n(r),void 0===t?r:(ui(t,0,Rn),void 0===e?e=n.rounding:ui(e,0,8),ci(r,t+r.e+1,e))},ii.toExponential=function(t,e){var r,n=this,i=n.constructor;return void 0===t?r=li(n,!0):(ui(t,0,Rn),void 0===e?e=i.rounding:ui(e,0,8),r=li(n=ci(new i(n),t+1,e),!0,t+1)),n.isNeg()&&!n.isZero()?"-"+r:r},ii.toFixed=function(t,e){var r,n,i=this,o=i.constructor;return void 0===t?r=li(i):(ui(t,0,Rn),void 0===e?e=o.rounding:ui(e,0,8),r=li(n=ci(new o(i),t+i.e+1,e),!1,t+n.e+1)),i.isNeg()&&!i.isZero()?"-"+r:r},ii.toFraction=function(t){var e,r,n,i,o,u,s,a,f,c,l,d,h=this,p=h.d,v=h.constructor;if(!p)return new v(h);if(f=r=new v(1),n=a=new v(0),u=(o=(e=new v(n)).e=vi(p)-h.e-1)%7,e.d[0]=Jn(10,u<0?7+u:u),null==t)t=o>0?e:f;else{if(!(s=new v(t)).isInt()||s.lt(f))throw Error(Hn+s);t=s.gt(e)?o>0?e:f:s}for(Yn=!1,s=new v(oi(p)),c=v.precision,v.precision=o=7*p.length*2;l=fi(s,e,0,1,1),1!=(i=r.plus(l.times(n))).cmp(t);)r=n,n=i,i=f,f=a.plus(l.times(i)),a=i,i=e,e=s.minus(l.times(i)),s=i;return i=fi(t.minus(r),n,0,1,1),a=a.plus(i.times(f)),r=r.plus(i.times(n)),a.s=f.s=h.s,d=fi(f,n,o,1).minus(h).abs().cmp(fi(a,r,o,1).minus(h).abs())<1?[f,n]:[a,r],v.precision=c,Yn=!0,d},ii.toHexadecimal=ii.toHex=function(t,e){return Ni(this,16,t,e)},ii.toNearest=function(t,e){var r=this,n=r.constructor;if(r=new n(r),null==t){if(!r.d)return r;t=new n(1),e=n.rounding}else{if(t=new n(t),void 0===e?e=n.rounding:ui(e,0,8),!r.d)return t.s?r:t;if(!t.d)return t.s&&(t.s=r.s),t}return t.d[0]?(Yn=!1,r=fi(r,t,0,e,1).times(t),Yn=!0,ci(r)):(t.s=r.s,r=t),r},ii.toNumber=function(){return+this},ii.toOctal=function(t,e){return Ni(this,8,t,e)},ii.toPower=ii.pow=function(t){var e,r,n,i,o,u,s=this,a=s.constructor,f=+(t=new a(t));if(!(s.d&&t.d&&s.d[0]&&t.d[0]))return new a(Jn(+s,f));if((s=new a(s)).eq(1))return s;if(n=a.precision,o=a.rounding,t.eq(1))return ci(s,n,o);if((e=Wn(t.e/7))>=t.d.length-1&&(r=f<0?-f:f)<=9007199254740991)return i=mi(a,s,r,n),t.s<0?new a(1).div(i):ci(i,n,o);if((u=s.s)<0){if(e<t.d.length-1)return new a(NaN);if(1&t.d[e]||(u=1),0==s.e&&1==s.d[0]&&1==s.d.length)return s.s=u,s}return(e=0!=(r=Jn(+s,f))&&isFinite(r)?new a(r+"").e:Wn(f*(Math.log("0."+oi(s.d))/Math.LN10+s.e+1)))>a.maxE+1||e<a.minE-1?new a(e>0?u/0:0):(Yn=!1,a.rounding=s.s=1,r=Math.min(12,(e+"").length),(i=wi(t.times(_i(s,n+r)),n)).d&&si((i=ci(i,n+5,1)).d,n,o)&&(e=n+10,+oi((i=ci(wi(t.times(_i(s,e+r)),e),e+5,1)).d).slice(n+1,n+15)+1==1e14&&(i=ci(i,n+1,0))),i.s=u,Yn=!0,a.rounding=o,ci(i,n,o))},ii.toPrecision=function(t,e){var r,n=this,i=n.constructor;return void 0===t?r=li(n,n.e<=i.toExpNeg||n.e>=i.toExpPos):(ui(t,1,Rn),void 0===e?e=i.rounding:ui(e,0,8),r=li(n=ci(new i(n),t,e),t<=n.e||n.e<=i.toExpNeg,t)),n.isNeg()&&!n.isZero()?"-"+r:r},ii.toSignificantDigits=ii.toSD=function(t,e){var r=this.constructor;return void 0===t?(t=r.precision,e=r.rounding):(ui(t,1,Rn),void 0===e?e=r.rounding:ui(e,0,8)),ci(new r(this),t,e)},ii.toString=function(){var t=this,e=t.constructor,r=li(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()&&!t.isZero()?"-"+r:r},ii.truncated=ii.trunc=function(){return ci(new this.constructor(this),this.e+1,1)},ii.valueOf=ii.toJSON=function(){var t=this,e=t.constructor,r=li(t,t.e<=e.toExpNeg||t.e>=e.toExpPos);return t.isNeg()?"-"+r:r};var fi=function(){function t(t,e,r){var n,i=0,o=t.length;for(t=t.slice();o--;)n=t[o]*e+i,t[o]=n%r|0,i=n/r|0;return i&&t.unshift(i),t}function e(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;)t.shift()}return function(n,i,o,u,s,a){var f,c,l,d,h,p,v,y,m,g,b,w,_,j,O,S,$,E,M,N,A=n.constructor,x=n.s==i.s?1:-1,T=n.d,P=i.d;if(!(T&&T[0]&&P&&P[0]))return new A(n.s&&i.s&&(T?!P||T[0]!=P[0]:P)?T&&0==T[0]||!P?0*x:x/0:NaN);for(a?(h=1,c=n.e-i.e):(a=ei,h=7,c=Wn(n.e/h)-Wn(i.e/h)),M=P.length,$=T.length,g=(m=new A(x)).d=[],l=0;P[l]==(T[l]||0);l++);if(P[l]>(T[l]||0)&&c--,null==o?(j=o=A.precision,u=A.rounding):j=s?o+(n.e-i.e)+1:o,j<0)g.push(1),p=!0;else{if(j=j/h+2|0,l=0,1==M){for(d=0,P=P[0],j++;(l<$||d)&&j--;l++)O=d*a+(T[l]||0),g[l]=O/P|0,d=O%P|0;p=d||l<$}else{for((d=a/(P[0]+1)|0)>1&&(P=t(P,d,a),T=t(T,d,a),M=P.length,$=T.length),S=M,w=(b=T.slice(0,M)).length;w<M;)b[w++]=0;(N=P.slice()).unshift(0),E=P[0],P[1]>=a/2&&++E;do{d=0,(f=e(P,b,M,w))<0?(_=b[0],M!=w&&(_=_*a+(b[1]||0)),(d=_/E|0)>1?(d>=a&&(d=a-1),1==(f=e(v=t(P,d,a),b,y=v.length,w=b.length))&&(d--,r(v,M<y?N:P,y,a))):(0==d&&(f=d=1),v=P.slice()),(y=v.length)<w&&v.unshift(0),r(b,v,w,a),-1==f&&(f=e(P,b,M,w=b.length))<1&&(d++,r(b,M<w?N:P,w,a)),w=b.length):0===f&&(d++,b=[0]),g[l++]=d,f&&b[0]?b[w++]=T[S]||0:(b=[T[S]],w=1)}while((S++<$||void 0!==b[0])&&j--);p=void 0!==b[0]}g[0]||g.shift()}if(1==h)m.e=c,Fn=p;else{for(l=1,d=g[0];d>=10;d/=10)l++;m.e=l+c*h-1,ci(m,s?o+m.e+1:o,u,p)}return m}}();function ci(t,e,r,n){var i,o,u,s,a,f,c,l,d,h=t.constructor;t:if(null!=e){if(!(l=t.d))return t;for(i=1,s=l[0];s>=10;s/=10)i++;if((o=e-i)<0)o+=7,u=e,a=(c=l[d=0])/Jn(10,i-u-1)%10|0;else if((d=Math.ceil((o+1)/7))>=(s=l.length)){if(!n)break t;for(;s++<=d;)l.push(0);c=a=0,i=1,u=(o%=7)-7+1}else{for(c=s=l[d],i=1;s>=10;s/=10)i++;a=(u=(o%=7)-7+i)<0?0:c/Jn(10,i-u-1)%10|0}if(n=n||e<0||void 0!==l[d+1]||(u<0?c:c%Jn(10,i-u-1)),f=r<4?(a||n)&&(0==r||r==(t.s<0?3:2)):a>5||5==a&&(4==r||n||6==r&&(o>0?u>0?c/Jn(10,i-u):0:l[d-1])%10&1||r==(t.s<0?8:7)),e<1||!l[0])return l.length=0,f?(e-=t.e+1,l[0]=Jn(10,(7-e%7)%7),t.e=-e||0):l[0]=t.e=0,t;if(0==o?(l.length=d,s=1,d--):(l.length=d+1,s=Jn(10,7-o),l[d]=u>0?(c/Jn(10,i-u)%Jn(10,u)|0)*s:0),f)for(;;){if(0==d){for(o=1,u=l[0];u>=10;u/=10)o++;for(u=l[0]+=s,s=1;u>=10;u/=10)s++;o!=s&&(t.e++,l[0]==ei&&(l[0]=1));break}if(l[d]+=s,l[d]!=ei)break;l[d--]=0,s=1}for(o=l.length;0===l[--o];)l.pop()}return Yn&&(t.e>h.maxE?(t.d=null,t.e=NaN):t.e<h.minE&&(t.e=0,t.d=[0])),t}function li(t,e,r){if(!t.isFinite())return ji(t);var n,i=t.e,o=oi(t.d),u=o.length;return e?(r&&(n=r-u)>0?o=o.charAt(0)+"."+o.slice(1)+yi(n):u>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(t.e<0?"e":"e+")+t.e):i<0?(o="0."+yi(-i-1)+o,r&&(n=r-u)>0&&(o+=yi(n))):i>=u?(o+=yi(i+1-u),r&&(n=r-i-1)>0&&(o=o+"."+yi(n))):((n=i+1)<u&&(o=o.slice(0,n)+"."+o.slice(n)),r&&(n=r-u)>0&&(i+1===u&&(o+="."),o+=yi(n))),o}function di(t,e){var r=t[0];for(e*=7;r>=10;r/=10)e++;return e}function hi(t,e,r){if(e>ri)throw Yn=!0,r&&(t.precision=r),Error(Gn);return ci(new t(qn),e,1,!0)}function pi(t,e,r){if(e>ni)throw Error(Gn);return ci(new t(zn),e,r,!0)}function vi(t){var e=t.length-1,r=7*e+1;if(e=t[e]){for(;e%10==0;e/=10)r--;for(e=t[0];e>=10;e/=10)r++}return r}function yi(t){for(var e="";t--;)e+="0";return e}function mi(t,e,r,n){var i,o=new t(1),u=Math.ceil(n/7+4);for(Yn=!1;;){if(r%2&&Ai((o=o.times(e)).d,u)&&(i=!0),0===(r=Wn(r/2))){r=o.d.length-1,i&&0===o.d[r]&&++o.d[r];break}Ai((e=e.times(e)).d,u)}return Yn=!0,o}function gi(t){return 1&t.d[t.d.length-1]}function bi(t,e,r){for(var n,i,o=new t(e[0]),u=0;++u<e.length;){if(!(i=new t(e[u])).s){o=i;break}((n=o.cmp(i))===r||0===n&&o.s===r)&&(o=i)}return o}function wi(t,e){var r,n,i,o,u,s,a,f=0,c=0,l=0,d=t.constructor,h=d.rounding,p=d.precision;if(!t.d||!t.d[0]||t.e>17)return new d(t.d?t.d[0]?t.s<0?0:1/0:1:t.s?t.s<0?0:t:NaN);for(null==e?(Yn=!1,a=p):a=e,s=new d(.03125);t.e>-2;)t=t.times(s),l+=5;for(a+=n=Math.log(Jn(2,l))/Math.LN10*2+5|0,r=o=u=new d(1),d.precision=a;;){if(o=ci(o.times(t),a,1),r=r.times(++c),oi((s=u.plus(fi(o,r,a,1))).d).slice(0,a)===oi(u.d).slice(0,a)){for(i=l;i--;)u=ci(u.times(u),a,1);if(null!=e)return d.precision=p,u;if(!(f<3&&si(u.d,a-n,h,f)))return ci(u,d.precision=p,h,Yn=!0);d.precision=a+=10,r=o=s=new d(1),c=0,f++}u=s}}function _i(t,e){var r,n,i,o,u,s,a,f,c,l,d,h=1,p=t,v=p.d,y=p.constructor,m=y.rounding,g=y.precision;if(p.s<0||!v||!v[0]||!p.e&&1==v[0]&&1==v.length)return new y(v&&!v[0]?-1/0:1!=p.s?NaN:v?0:p);if(null==e?(Yn=!1,c=g):c=e,y.precision=c+=10,n=(r=oi(v)).charAt(0),!(Math.abs(o=p.e)<15e14))return f=hi(y,c+2,g).times(o+""),p=_i(new y(n+"."+r.slice(1)),c-10).plus(f),y.precision=g,null==e?ci(p,g,m,Yn=!0):p;for(;n<7&&1!=n||1==n&&r.charAt(1)>3;)n=(r=oi((p=p.times(t)).d)).charAt(0),h++;for(o=p.e,n>1?(p=new y("0."+r),o++):p=new y(n+"."+r.slice(1)),l=p,a=u=p=fi(p.minus(1),p.plus(1),c,1),d=ci(p.times(p),c,1),i=3;;){if(u=ci(u.times(d),c,1),oi((f=a.plus(fi(u,new y(i),c,1))).d).slice(0,c)===oi(a.d).slice(0,c)){if(a=a.times(2),0!==o&&(a=a.plus(hi(y,c+2,g).times(o+""))),a=fi(a,new y(h),c,1),null!=e)return y.precision=g,a;if(!si(a.d,c-10,m,s))return ci(a,y.precision=g,m,Yn=!0);y.precision=c+=10,f=u=p=fi(l.minus(1),l.plus(1),c,1),d=ci(p.times(p),c,1),i=s=1}a=f,i+=2}}function ji(t){return String(t.s*t.s/0)}function Oi(t,e){var r,n,i;for((r=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(r<0&&(r=n),r+=+e.slice(n+1),e=e.substring(0,n)):r<0&&(r=e.length),n=0;48===e.charCodeAt(n);n++);for(i=e.length;48===e.charCodeAt(i-1);--i);if(e=e.slice(n,i)){if(i-=n,t.e=r=r-n-1,t.d=[],n=(r+1)%7,r<0&&(n+=7),n<i){for(n&&t.d.push(+e.slice(0,n)),i-=7;n<i;)t.d.push(+e.slice(n,n+=7));n=7-(e=e.slice(n)).length}else n-=i;for(;n--;)e+="0";t.d.push(+e),Yn&&(t.e>t.constructor.maxE?(t.d=null,t.e=NaN):t.e<t.constructor.minE&&(t.e=0,t.d=[0]))}else t.e=0,t.d=[0];return t}function Si(t,e){var r,n,i,o,u,s,a,f,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),ti.test(e))return Oi(t,e)}else if("Infinity"===e||"NaN"===e)return+e||(t.s=NaN),t.e=NaN,t.d=null,t;if(Qn.test(e))r=16,e=e.toLowerCase();else if(Kn.test(e))r=2;else{if(!Xn.test(e))throw Error(Hn+e);r=8}for((o=e.search(/p/i))>0?(a=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),u=(o=e.indexOf("."))>=0,n=t.constructor,u&&(o=(s=(e=e.replace(".","")).length)-o,i=mi(n,new n(r),o,2*o)),o=c=(f=ai(e,r,ei)).length-1;0===f[o];--o)f.pop();return o<0?new n(0*t.s):(t.e=di(f,c),t.d=f,Yn=!1,u&&(t=fi(t,i,4*s)),a&&(t=t.times(Math.abs(a)<54?Jn(2,a):mo.pow(2,a))),Yn=!0,t)}function $i(t,e,r,n,i){var o,u,s,a,f=t.precision,c=Math.ceil(f/7);for(Yn=!1,a=r.times(r),s=new t(n);;){if(u=fi(s.times(a),new t(e++*e++),f,1),s=i?n.plus(u):n.minus(u),n=fi(u.times(a),new t(e++*e++),f,1),void 0!==(u=s.plus(n)).d[c]){for(o=c;u.d[o]===s.d[o]&&o--;);if(-1==o)break}o=s,s=n,n=u,u=o}return Yn=!0,u.d.length=c+1,u}function Ei(t,e){for(var r=t;--e;)r*=t;return r}function Mi(t,e){var r,n=e.s<0,i=pi(t,t.precision,1),o=i.times(.5);if((e=e.abs()).lte(o))return Dn=n?4:1,e;if((r=e.divToInt(i)).isZero())Dn=n?3:2;else{if((e=e.minus(r.times(i))).lte(o))return Dn=gi(r)?n?2:3:n?4:1,e;Dn=gi(r)?n?1:4:n?3:2}return e.minus(i).abs()}function Ni(t,e,r,n){var i,o,u,s,a,f,c,l,d,h=t.constructor,p=void 0!==r;if(p?(ui(r,1,Rn),void 0===n?n=h.rounding:ui(n,0,8)):(r=h.precision,n=h.rounding),t.isFinite()){for(p?(i=2,16==e?r=4*r-3:8==e&&(r=3*r-2)):i=e,(u=(c=li(t)).indexOf("."))>=0&&(c=c.replace(".",""),(d=new h(1)).e=c.length-u,d.d=ai(li(d),10,i),d.e=d.d.length),o=a=(l=ai(c,10,i)).length;0==l[--a];)l.pop();if(l[0]){if(u<0?o--:((t=new h(t)).d=l,t.e=o,l=(t=fi(t,d,r,n,0,i)).d,o=t.e,f=Fn),u=l[r],s=i/2,f=f||void 0!==l[r+1],f=n<4?(void 0!==u||f)&&(0===n||n===(t.s<0?3:2)):u>s||u===s&&(4===n||f||6===n&&1&l[r-1]||n===(t.s<0?8:7)),l.length=r,f)for(;++l[--r]>i-1;)l[r]=0,r||(++o,l.unshift(1));for(a=l.length;!l[a-1];--a);for(u=0,c="";u<a;u++)c+=In.charAt(l[u]);if(p){if(a>1)if(16==e||8==e){for(u=16==e?4:3,--a;a%u;a++)c+="0";for(a=(l=ai(c,i,e)).length;!l[a-1];--a);for(u=1,c="1.";u<a;u++)c+=In.charAt(l[u])}else c=c.charAt(0)+"."+c.slice(1);c=c+(o<0?"p":"p+")+o}else if(o<0){for(;++o;)c="0"+c;c="0."+c}else if(++o>a)for(o-=a;o--;)c+="0";else o<a&&(c=c.slice(0,o)+"."+c.slice(o))}else c=p?"0p+0":"0";c=(16==e?"0x":2==e?"0b":8==e?"0o":"")+c}else c=ji(t);return t.s<0?"-"+c:c}function Ai(t,e){if(t.length>e)return t.length=e,!0}function xi(t){return new this(t).abs()}function Ti(t){return new this(t).acos()}function Pi(t){return new this(t).acosh()}function Li(t,e){return new this(t).plus(e)}function ki(t){return new this(t).asin()}function Fi(t){return new this(t).asinh()}function Di(t){return new this(t).atan()}function Ci(t){return new this(t).atanh()}function Ri(t,e){t=new this(t),e=new this(e);var r,n=this.precision,i=this.rounding,o=n+4;return t.s&&e.s?t.d||e.d?!e.d||t.isZero()?(r=e.s<0?pi(this,n,i):new this(0)).s=t.s:!t.d||e.isZero()?(r=pi(this,o,1).times(.5)).s=t.s:e.s<0?(this.precision=o,this.rounding=1,r=this.atan(fi(t,e,o,1)),e=pi(this,o,1),this.precision=n,this.rounding=i,r=t.s<0?r.minus(e):r.plus(e)):r=this.atan(fi(t,e,o,1)):(r=pi(this,o,1).times(e.s>0?.25:.75)).s=t.s:r=new this(NaN),r}function Ii(t){return new this(t).cbrt()}function qi(t){return ci(t=new this(t),t.e+1,2)}function zi(t,e,r){return new this(t).clamp(e,r)}function Ui(t){if(!t||"object"!=typeof t)throw Error(Bn+"Object expected");var e,r,n,i=!0===t.defaults,o=["precision",1,Rn,"rounding",0,8,"toExpNeg",-Cn,0,"toExpPos",0,Cn,"maxE",0,Cn,"minE",-Cn,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(r=o[e],i&&(this[r]=Un[r]),void 0!==(n=t[r])){if(!(Wn(n)===n&&n>=o[e+1]&&n<=o[e+2]))throw Error(Hn+r+": "+n);this[r]=n}if(r="crypto",i&&(this[r]=Un[r]),void 0!==(n=t[r])){if(!0!==n&&!1!==n&&0!==n&&1!==n)throw Error(Hn+r+": "+n);if(n){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw Error(Zn);this[r]=!0}else this[r]=!1}return this}function Yi(t){return new this(t).cos()}function Bi(t){return new this(t).cosh()}function Hi(t,e){return new this(t).div(e)}function Gi(t){return new this(t).exp()}function Zi(t){return ci(t=new this(t),t.e+1,3)}function Vi(){var t,e,r=new this(0);for(Yn=!1,t=0;t<arguments.length;)if((e=new this(arguments[t++])).d)r.d&&(r=r.plus(e.times(e)));else{if(e.s)return Yn=!0,new this(1/0);r=e}return Yn=!0,r.sqrt()}function Wi(t){return t instanceof mo||t&&t.toStringTag===Vn||!1}function Ji(t){return new this(t).ln()}function Ki(t,e){return new this(t).log(e)}function Qi(t){return new this(t).log(2)}function Xi(t){return new this(t).log(10)}function to(){return bi(this,arguments,-1)}function eo(){return bi(this,arguments,1)}function ro(t,e){return new this(t).mod(e)}function no(t,e){return new this(t).mul(e)}function io(t,e){return new this(t).pow(e)}function oo(t){var e,r,n,i,o=0,u=new this(1),s=[];if(void 0===t?t=this.precision:ui(t,1,Rn),n=Math.ceil(t/7),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(n));o<n;)(i=e[o])>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:s[o++]=i%1e7;else{if(!crypto.randomBytes)throw Error(Zn);for(e=crypto.randomBytes(n*=4);o<n;)(i=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((127&e[o+3])<<24))>=214e7?crypto.randomBytes(4).copy(e,o):(s.push(i%1e7),o+=4);o=n/4}else for(;o<n;)s[o++]=1e7*Math.random()|0;for(t%=7,(n=s[--o])&&t&&(i=Jn(10,7-t),s[o]=(n/i|0)*i);0===s[o];o--)s.pop();if(o<0)r=0,s=[0];else{for(r=-1;0===s[0];r-=7)s.shift();for(n=1,i=s[0];i>=10;i/=10)n++;n<7&&(r-=7-n)}return u.e=r,u.d=s,u}function uo(t){return ci(t=new this(t),t.e+1,this.rounding)}function so(t){return(t=new this(t)).d?t.d[0]?t.s:0*t.s:t.s||NaN}function ao(t){return new this(t).sin()}function fo(t){return new this(t).sinh()}function co(t){return new this(t).sqrt()}function lo(t,e){return new this(t).sub(e)}function ho(){var t=0,e=arguments,r=new this(e[t]);for(Yn=!1;r.s&&++t<e.length;)r=r.plus(e[t]);return Yn=!0,ci(r,this.precision,this.rounding)}function po(t){return new this(t).tan()}function vo(t){return new this(t).tanh()}function yo(t){return ci(t=new this(t),t.e+1,1)}ii[Symbol.for("nodejs.util.inspect.custom")]=ii.toString,ii[Symbol.toStringTag]="Decimal";var mo=ii.constructor=function t(e){var r,n,i;function o(t){var e,r,n,i=this;if(!(i instanceof o))return new o(t);if(i.constructor=o,Wi(t))return i.s=t.s,void(Yn?!t.d||t.e>o.maxE?(i.e=NaN,i.d=null):t.e<o.minE?(i.e=0,i.d=[0]):(i.e=t.e,i.d=t.d.slice()):(i.e=t.e,i.d=t.d?t.d.slice():t.d));if("number"===(n=typeof t)){if(0===t)return i.s=1/t<0?-1:1,i.e=0,void(i.d=[0]);if(t<0?(t=-t,i.s=-1):i.s=1,t===~~t&&t<1e7){for(e=0,r=t;r>=10;r/=10)e++;return void(Yn?e>o.maxE?(i.e=NaN,i.d=null):e<o.minE?(i.e=0,i.d=[0]):(i.e=e,i.d=[t]):(i.e=e,i.d=[t]))}return 0*t!=0?(t||(i.s=NaN),i.e=NaN,void(i.d=null)):Oi(i,t.toString())}if("string"===n)return 45===(r=t.charCodeAt(0))?(t=t.slice(1),i.s=-1):(43===r&&(t=t.slice(1)),i.s=1),ti.test(t)?Oi(i,t):Si(i,t);if("bigint"===n)return t<0?(t=-t,i.s=-1):i.s=1,Oi(i,t.toString());throw Error(Hn+t)}if(o.prototype=ii,o.ROUND_UP=0,o.ROUND_DOWN=1,o.ROUND_CEIL=2,o.ROUND_FLOOR=3,o.ROUND_HALF_UP=4,o.ROUND_HALF_DOWN=5,o.ROUND_HALF_EVEN=6,o.ROUND_HALF_CEIL=7,o.ROUND_HALF_FLOOR=8,o.EUCLID=9,o.config=o.set=Ui,o.clone=t,o.isDecimal=Wi,o.abs=xi,o.acos=Ti,o.acosh=Pi,o.add=Li,o.asin=ki,o.asinh=Fi,o.atan=Di,o.atanh=Ci,o.atan2=Ri,o.cbrt=Ii,o.ceil=qi,o.clamp=zi,o.cos=Yi,o.cosh=Bi,o.div=Hi,o.exp=Gi,o.floor=Zi,o.hypot=Vi,o.ln=Ji,o.log=Ki,o.log10=Xi,o.log2=Qi,o.max=to,o.min=eo,o.mod=ro,o.mul=no,o.pow=io,o.random=oo,o.round=uo,o.sign=so,o.sin=ao,o.sinh=fo,o.sqrt=co,o.sub=lo,o.sum=ho,o.tan=po,o.tanh=vo,o.trunc=yo,void 0===e&&(e={}),e&&!0!==e.defaults)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],r=0;r<i.length;)e.hasOwnProperty(n=i[r++])||(e[n]=this[n]);return o.config(e),o}(Un);function go(t,e=0,r={}){yn(e)||(e=0),e=xr(e);let n=st(r,"rounding","");return"ROUND_HALF_UP"!==n&&"ROUND_HALF_EVEN"!==n&&(n="ROUND_HALF_UP"),Nr(t)?new mo(t).toDecimalPlaces(e,mo[n]).toNumber():""}qn=new mo(qn),zn=new mo(zn);var bo=u?u.isConcatSpreadable:void 0;function wo(t){return r(t)||mt(t)||!!(bo&&t&&t[bo])}function _o(t,e,r,n,i){var o=-1,u=t.length;for(r||(r=wo),i||(i=[]);++o<u;){var s=t[o];e>0&&r(s)?e>1?_o(s,e-1,r,n,i):ne(i,s):n||(i[i.length]=s)}return i}function jo(t,e){if(t!==e){var r=void 0!==t,n=null===t,i=t==t,o=v(t),u=void 0!==e,s=null===e,a=e==e,f=v(e);if(!s&&!f&&!o&&t>e||o&&u&&a&&!s&&!f||n&&u&&a||!r&&a||!i)return 1;if(!n&&!o&&!f&&t<e||f&&r&&i&&!n&&!o||s&&r&&i||!u&&i||!a)return-1}return 0}function Oo(t,e,n){e=e.length?X(e,function(t){return r(t)?function(e){return ut(e,1===t.length?t[0]:t)}:t}):[Ie];var i=-1;return e=X(e,Et(Ue)),function(t,e){var r=t.length;for(t.sort(e);r--;)t[r]=t[r].value;return t}(Ze(t,function(t,r,n){return{criteria:X(e,function(e){return e(t)}),index:++i,value:t}}),function(t,e){return function(t,e,r){for(var n=-1,i=t.criteria,o=e.criteria,u=i.length,s=r.length;++n<u;){var a=jo(i[n],o[n]);if(a)return n>=s?a:a*("desc"==r[n]?-1:1)}return t.index-e.index}(t,e,n)})}var So=Math.max;var $o=function(){try{var t=L(Object,"defineProperty");return t({},"",{}),t}catch(t){}}(),Eo=$o,Mo=Eo?function(t,e){return Eo(t,"toString",{configurable:!0,enumerable:!1,value:(r=e,function(){return r}),writable:!0});var r}:Ie,No=Mo,Ao=Date.now;var xo=function(t){var e=0,r=0;return function(){var n=Ao(),i=16-(n-r);if(r=n,i>0){if(++e>=800)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}(No),To=xo;var Po=function(t,e){return To(function(t,e,r){return e=So(void 0===e?t.length-1:e,0),function(){for(var n=arguments,i=-1,o=So(n.length-e,0),u=Array(o);++i<o;)u[i]=n[e+i];i=-1;for(var s=Array(e+1);++i<e;)s[i]=n[i];return s[e]=r(u),function(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}(t,this,s)}}(t,e,Ie),t+"")}(function(t,e){if(null==t)return[];var r=e.length;return r>1&&Lr(t,e[0],e[1])?e=[]:r>2&&Lr(e[0],e[1],e[2])&&(e=[e[0]]),Oo(t,_o(e,1),[])}),Lo=Po;function ko(t,e,r){"__proto__"==e&&Eo?Eo(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Fo=Object.prototype.hasOwnProperty;function Do(t,e,r){var n=t[e];Fo.call(t,e)&&R(n,r)&&(void 0!==r||e in t)||ko(t,e,r)}function Co(t,e,r,n){var i=!r;r||(r={});for(var o=-1,u=e.length;++o<u;){var s=e[o],a=n?n(r[s],t[s],s,r,t):void 0;void 0===a&&(a=t[s]),i?ko(r,s,a):Do(r,s,a)}return r}var Ro=Object.prototype.hasOwnProperty;function Io(t){if(!b(t))return function(t){var e=[];if(null!=t)for(var r in Object(t))e.push(r);return e}(t);var e=Dt(t),r=[];for(var n in t)("constructor"!=n||!e&&Ro.call(t,n))&&r.push(n);return r}function qo(t){return zt(t)?kt(t,!0):Io(t)}var zo="object"==typeof exports&&exports&&!exports.nodeType&&exports,Uo=zo&&"object"==typeof module&&module&&!module.nodeType&&module,Yo=Uo&&Uo.exports===zo?o.Buffer:void 0,Bo=Yo?Yo.allocUnsafe:void 0;var Ho=Ct(Object.getPrototypeOf,Object),Go=Object.getOwnPropertySymbols?function(t){for(var e=[];t;)ne(e,fe(t)),t=Ho(t);return e}:ue,Zo=Go;function Vo(t){return ie(t,qo,Zo)}var Wo=Object.prototype.hasOwnProperty;function Jo(t){var e=new t.constructor(t.byteLength);return new Qt(e).set(new Qt(t)),e}var Ko=/\w*$/;var Qo=u?u.prototype:void 0,Xo=Qo?Qo.valueOf:void 0;function tu(t,e,r){var n,i=t.constructor;switch(e){case"[object ArrayBuffer]":return Jo(t);case"[object Boolean]":case"[object Date]":return new i(+t);case"[object DataView]":return function(t,e){var r=e?Jo(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,r);case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return function(t,e){var r=e?Jo(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,r);case"[object Map]":case"[object Set]":return new i;case"[object Number]":case"[object String]":return new i(t);case"[object RegExp]":return function(t){var e=new t.constructor(t.source,Ko.exec(t));return e.lastIndex=t.lastIndex,e}(t);case"[object Symbol]":return n=t,Xo?Object(Xo.call(n)):{}}}var eu=Object.create,ru=function(){function t(){}return function(e){if(!b(e))return{};if(eu)return eu(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),nu=ru;var iu=xt&&xt.isMap,ou=iu?Et(iu):function(t){return p(t)&&"[object Map]"==Me(t)};var uu=xt&&xt.isSet,su=uu?Et(uu):function(t){return p(t)&&"[object Set]"==Me(t)},au="[object Arguments]",fu="[object Function]",cu="[object Object]",lu={};function du(t,e,n,i,o,u){var s,a=1&e,f=2&e,c=4&e;if(n&&(s=o?n(t,i,o,u):n(t)),void 0!==s)return s;if(!b(t))return t;var l=r(t);if(l){if(s=function(t){var e=t.length,r=new t.constructor(e);return e&&"string"==typeof t[0]&&Wo.call(t,"index")&&(r.index=t.index,r.input=t.input),r}(t),!a)return Cr(t,s)}else{var d=Me(t),h=d==fu||"[object GeneratorFunction]"==d;if(_t(t))return function(t,e){if(e)return t.slice();var r=t.length,n=Bo?Bo(r):new t.constructor(r);return t.copy(n),n}(t,a);if(d==cu||d==au||h&&!o){if(s=f||h?{}:function(t){return"function"!=typeof t.constructor||Dt(t)?{}:nu(Ho(t))}(t),!a)return f?function(t,e){return Co(t,Zo(t),e)}(t,function(t,e){return t&&Co(e,qo(e),t)}(s,t)):function(t,e){return Co(t,fe(t),e)}(t,function(t,e){return t&&Co(e,Ut(e),t)}(s,t))}else{if(!lu[d])return o?t:{};s=tu(t,d,a)}}u||(u=new Zt);var p=u.get(t);if(p)return p;u.set(t,s),su(t)?t.forEach(function(r){s.add(du(r,e,n,r,t,u))}):ou(t)&&t.forEach(function(r,i){s.set(i,du(r,e,n,i,t,u))});var v=l?void 0:(c?f?Vo:ce:f?qo:Ut)(t);return Br(v||t,function(r,i){v&&(r=t[i=r]),Do(s,i,du(r,e,n,i,t,u))}),s}lu[au]=lu["[object Array]"]=lu["[object ArrayBuffer]"]=lu["[object DataView]"]=lu["[object Boolean]"]=lu["[object Date]"]=lu["[object Float32Array]"]=lu["[object Float64Array]"]=lu["[object Int8Array]"]=lu["[object Int16Array]"]=lu["[object Int32Array]"]=lu["[object Map]"]=lu["[object Number]"]=lu[cu]=lu["[object RegExp]"]=lu["[object Set]"]=lu["[object String]"]=lu["[object Symbol]"]=lu["[object Uint8Array]"]=lu["[object Uint8ClampedArray]"]=lu["[object Uint16Array]"]=lu["[object Uint32Array]"]=!0,lu["[object Error]"]=lu[fu]=lu["[object WeakMap]"]=!1;function hu(t){return du(t,5)}function pu(t){let e,r=Object.prototype.toString.call(t);if(e="[object Promise]"===r,e)return!0;if("[object Function]"!==r)return!1;try{e="function"!=typeof t.subscribe&&"function"==typeof t.then}catch(t){}return e}function vu(t,e){return Le(t,e)}function yu(t,e){function r(t){return Sn(t)?t:[t]}if(Pn(t))return!1;if(0===(t=r(t)).length)return!1;if(Pn(t))return!1;if(0===(e=r(e)).length)return!1;for(let r=0;r<t.length;r++)for(let n=0;n<e.length;n++)if(vu(t[r],e[n]))return!0;return!1}function mu(t){return"number"==typeof t||p(t)&&"[object Number]"==h(t)}function gu(t){if(!(Gt(t)||Nr(t)||v(t)||function(t){return"[object BigInt]"===Object.prototype.toString.call(t)}(t)))return"";let e="";try{e=String(t)}catch(t){}try{e=t.toString()}catch(t){}return e}let bu=0;let wu=function(t="start1",e=!1){void 0===t?t=(new Date).getTime():"start1"===t&&(bu++,t=bu);let r=624,n=397,i=2147483648,o=2147483647,u=new Array(r),s=625,a=t=>{var e;for(mu(t)?u[0]=t>>>0:(t=gu(t),u[0]=Ht(e=t)?""===e?0:e.split("").reduce((t,e)=>e.charCodeAt(0)+(t<<6)+(t<<16)-t,0):null),s=1;s<r;s++){let t=u[s-1]^u[s-1]>>>30;u[s]=(1812433253*((4294901760&t)>>>16)<<16)+1812433253*(65535&t)+s,u[s]>>>=0}},f=()=>(()=>{let t,e=new Array(2567483615);if(s>=r){let f;for(625===s&&a(5489),f=0;f<227;f++)t=u[f]&i|u[f+1]&o,u[f]=u[f+n]^t>>>1^e[1&t];for(;f<623;f++)t=u[f]&i|u[f+1]&o,u[f]=u[f+(n-r)]^t>>>1^e[1&t];t=u[623]&i|u[0]&o,u[623]=u[396]^t>>>1^e[1&t],s=0}return t=u[s++],t^=t>>>11,t^=t<<7&2636928640,t^=t<<15&4022730752,t^=t>>>18,t>>>0})()*(1/4294967296);a(t);let c=null;return c=e?f:f(),c}((new Date).getTime(),!0);function _u(t=0,e=100){if(zr(t)||(t=0),t=xr(t),zr(e)||(e=100),t>(e=xr(e)))throw new Error(`vstart[${t}] > vend[${e}]`);let r=wu()*(e-t+1)+t;return r=Math.floor(r),r}function ju(t){if(0===lr(t))throw new Error("dps is not an effective array");let e=Ve(t,t=>{let e=st(t,"values",[]);if(0===lr(e))throw new Error("dp.values is not an effective array");let r=st(t,"n",0);if(r<=0)throw new Error("n<=0");let n=_u(0,r-1);return{ind:n,value:e[n]}});return{ps:e,fitness:null}}function Ou(t,e,r="Mapping"){if(!zr(t))throw new Error(`ind[${t}] in not an integer`);if(t=xr(t),!yn(e))throw new Error(`iUp[${e}]<0`);if(0===(e=xr(e)))return 0;if("Limit"===r)t=Math.min(t,e),t=Math.max(t,0);else if("Mapping"===r){let r=e+1;t=(t%r+r)%r}else{if("Random"!==r)throw new Error(`invalid mode[${r}]`);(t<0||t>e)&&(t=_u(0,e))}return t}function Su(t,e){let r=t.ps,n=e.ps;if(lr(r)!==lr(n))return!1;for(let t=0;t<r.length;t++)if(r[t].ind!==n[t].ind)return!1;return!0}function $u(t,e,r,n,i){if(t===e)return t;if(r<-4)return e;if(r>4)return t;if(i<=1)return t;let o;return o=r>=0?Math.pow(n/(i-1),Math.exp(r)):1-Math.pow((i-1-n)/(i-1),Math.exp(-r)),o*(e-t)+t}function Eu(t,e,r,n,i){for(let o=0;o<t.length;++o)t[o]=e*r[o]+n*i[o]}function Mu(t,e){return t.y-e.y}function Nu(t,e,r){if(0===lr(r))throw new Error("dps is not an effective array");let n=st(r,e),i=st(n,"values",[]),o=null,u=null,s=1e20;return Hr(i,(e,r)=>{let n=t-e;n=Math.abs(n),s>n&&(s=n,o=r,u=e)}),{ind:o,value:u}}function Au(t,e,r){let n=hu(t.ps),i=_u(0,e.length-1),o=Math.random()<.5?-1:1,u=n[i].ind,s=u+o;return s=Ou(s,e[i].n-1,r),n[i].ind=s,n[i].value=e[i].values[s],{ps:n,changed:s!==u}}function xu(t){if(On(t)){for(let e in t)return!0;return!1}return!1}function Tu(t){if(!Ln(t))throw new Error("dps is not an effective array");Hr(t,(t,e)=>{if(!xu(t))throw new Error(`dps[${e}] is not an effective object`);let r=st(t,"values");if(!Ln(r))throw new Error(`dps[${e}].values is not an effective array`);let n=r.length,i=st(t,"n");if(!Ur(i))throw new Error(`dps[${e}].n is not a positive integer, got ${i}`);if(i!==n)throw new Error(`dps[${e}] invariant violated: n[${i}] !== values.length[${n}]`)})}async function Pu(t,e,r={}){Tu(t);let n=st(r,"Nl","");Ur(n)||(n=1e4),n=xr(n);let i=st(r,"NContiguous","");Ur(i)||(i=200),i=xr(i);let o=st(r,"NCore","");Ur(o)||(o=1e6),o=xr(o);let u=st(r,"ModeOutLimit","");yu(u,["Mapping","Limit","Random"])||(u="Mapping");let s=st(r,"taThresholdType","");yu(s,["Arithmetic Series","Geometric Series","Trapezoid Series"])||(s="Geometric Series");let a=st(r,"taThresholdInitial","");Nr(a)||(a=1),a=Ar(a);let f=st(r,"UseHists","");$n(f)||(f=!0);let c=st(r,"funGetBetter"),l=st(r,"funEndLoop"),d=0,h=st(r,"calcFitness");ln(h)||(h=async(t,r)=>{d++;let n=Ve(t.ps,"value"),i=e(n);return pu(i)&&(i=await i),{ps:t.ps,fitness:i}});let p,v=st(r,"initSolution");if(v&&Ln(v.ps)&&Nr(v.fitness))p=hu(v);else{let e=ju(t);p=await h(e,"init")}let y=function(t,e,r){let n=new Array(r).fill(0);if("Arithmetic Series"===t)for(let t=0;t<r;t++)n[t]=e*(r-1-t)/Math.max(r-1,1);else if("Geometric Series"===t){let t=.6,i=e;for(let e=0;e<r;e++)n[e]=i,i*=t}else{if("Trapezoid Series"!==t)throw new Error(`invalid thresholdType[${t}]`);{let t=Math.floor(r/3),i=Math.floor(r/2),o=r-t-i,u=Math.max(t+o-1,1);for(let r=0;r<t;r++)n[r]=e*(t+o-1-r)/u;let s=n[t-1]||0;for(let e=t;e<t+i;e++)n[e]=s;for(let r=t+i;r<t+i+o;r++)n[r]=e*(t+o-1-(r-i))/u}}return n}(s,a,n),m=hu(p),g=[],b="",w=0,_=0,j=0;f&&g.push(hu(p));let O=-1;for(;;){if(O++,O>=n){b=`stop by Nl[${n}]`,w=O,_=d;break}let e,r=Au(p,t,u);if(e=r.changed?await h({ps:r.ps},"neighbor"):{ps:r.ps,fitness:p.fitness},e.fitness-p.fitness<y[O]&&(p=e),m.fitness>p.fitness?(m=hu(p),ln(c)&&c(hu(m),O),j=0):j+=1,f&&g.push(hu(p)),j>=i?b=`stop by iContinue[${j}] >= NContiguous[${i}]`:d>=o&&(b=`stop by iExecute[${d}] >= NCore[${o}]`),Gt(b)){w=O,_=d;break}ln(l)&&l(hu(p),hu(m),O)}return{bestSolution:m,hists:g,stopMode:b,stopNl:w,stopExecutions:_}}async function Lu(t,e,r,n,i,o){let u=e.length,s=hu(t),a=0,f=-1,c=0;for(let l=0;l<u;l++)for(let u=-1;u<=1;u+=2){if(i===l&&o===-u)continue;let d=t.ps[l].ind,h=d+u;if(h=Ou(h,e[l].n-1,r),h!==d){let r=hu(t.ps);r[l].ind=h,r[l].value=e[l].values[h];let i=await n({ps:r},"sdmNeighbor"),o=t.fitness-i.fitness;a<o&&(a=o,s=i,f=l,c=u)}}return{sMove:s,level:f,dir:c}}async function ku(t,e,r){let n=e.length,i=[],o=new Array(n).fill(0),u=hu(t);for(let o=0;o<n;o++){i.push([0,0]);for(let n=0;n<=1;n++){let s=0===n?-1:1,a=t.ps[o].ind,f=a+s;if(f=Ou(f,e[o].n-1,"Limit"),f!==a){let s=hu(t.ps);s[o].ind=f,s[o].value=e[o].values[f];let a=await r({ps:s},"sdmGold");u.fitness>a.fitness&&(u=a),i[o][n]=t.fitness-a.fitness}else i[o][n]=0}}let s=0;for(let t=0;t<n;t++)i[t][0]<=0&&i[t][1]<=0&&s++;if(s===n)return t.fitness<u.fitness?t:u;let a=0;for(let t=0;t<n;t++){let e=i[t][0],r=i[t][1];o[t]=e>=0&&r>=0?e>r?-e:r:e>=0&&r<0?-e:e<0&&r>=0?r:0,a+=o[t]*o[t]}if(a=Math.sqrt(a),0===a)return t.fitness<u.fitness?t:u;for(let t=0;t<n;t++)o[t]=o[t]/a;let f=0;for(let t=0;t<n;t++)f+=e[t].n*e[t].n;f=Math.sqrt(f),f>32768&&(f=32768);let c=hu(t),l=hu(t),d=hu(t),h=1/1.618,p="",v=0;for(;;){let i="none",s=null;for(;;){if(h*=1.618,h>f){i="over";break}let r=hu(t.ps),u=0;for(let i=0;i<n;i++){let n=t.ps[i].ind+Math.round(o[i]*h);n=Ou(n,e[i].n-1,"Limit"),r[i].ind=n,r[i].value=e[i].values[n],n===t.ps[i].ind&&u++}if(u!==n){i="move",s={ps:r,fitness:null};break}}if("over"===i){p="over";break}if(s=await r(s,"sdmGold"),u.fitness>s.fitness&&(u=s),v++,1===v){if(!(d.fitness>s.fitness))return c.fitness<u.fitness?c:u;d=s}else{if(!(d.fitness>s.fitness)){l=s,p="concave";break}d=s}}if("over"===p)return d.fitness<u.fitness?d:u;let y=0;for(;y++,!(y>50);){let t=hu(d.ps);for(let r=0;r<n;r++){let n=Math.round(.5*c.ps[r].ind+.5*l.ps[r].ind);t[r].ind=n,t[r].value=e[r].values[n]}let i=await r({ps:t},"sdmGold");u.fitness>i.fitness&&(u=i);let o=i.ps.every((t,e)=>t.ind===c.ps[e].ind),s=i.ps.every((t,e)=>t.ind===l.ps[e].ind);if(o||s)return[c,l,u].reduce((t,e)=>t.fitness<e.fitness?t:e);if(i.fitness<=c.fitness&&i.fitness<=l.fitness)c.fitness<=l.fitness?l=i:c=i,d=i;else if(i.fitness>=c.fitness&&i.fitness<=l.fitness)l=i;else{if(!(i.fitness<=c.fitness&&i.fitness>=l.fitness))return[c,l,u].reduce((t,e)=>t.fitness<e.fitness?t:e);c=i}}return[c,l,u].reduce((t,e)=>t.fitness<e.fitness?t:e)}async function Fu(t,e,r,n,i,o,u={}){if("None"===t)return e;if("NelderMead"===t){let t=async t=>{let e={ps:Ve(t,(t,e)=>Nu(t,e,r)),fitness:null};return(await i(e,"localSearchNelderMead")).fitness},n=Ve(e.ps,"value"),o=await async function(t,e,r={}){if(!ln(t))return Promise.reject("invalid fun");if(!Ln(e))return Promise.reject("params is not an effective array");let n=lr(e),i=st(r,"maxIterations");Nr(i)||(i=200*n),i=Ar(i);let o=st(r,"nonZeroDelta");Nr(o)||(o=1.05),o=Ar(o);let u=st(r,"delta");Nr(u)||(u=.001),u=Ar(u);let s=st(r,"minErrorDelta");Nr(s)||(s=1e-6),s=Ar(s);let a=st(r,"minTolerance");Nr(a)||(a=1e-5),a=Ar(a);let f=st(r,"rho");Nr(f)||(f=1),f=Ar(f);let c=st(r,"chi");Nr(c)||(c=2),c=Ar(c);let l=st(r,"psi");Nr(l)||(l=-.5),l=Ar(l);let d=st(r,"sigma");Nr(d)||(d=.5),d=Ar(d);let h=0;async function p(){let e=t(...arguments);return pu(e)&&(e=await e),h++,e}let v=new Array(n+1);v[0]=e,v[0].y=await p(e),v[0].id=0;for(let t=0;t<n;++t){let r=e.slice();r[t]=r[t]?r[t]*o:u,v[t+1]=r,v[t+1].y=await p(r),v[t+1].id=t+1}let y,m=t=>{for(let e=0;e<t.length;e++)v[n][e]=t[e];v[n].y=t.y},g=e.slice(),b=e.slice(),w=e.slice(),_=e.slice();for(let t=0;t<i;++t){v.sort(Mu),y=0;for(let t=0;t<n;++t)y=Math.max(y,Math.abs(v[0][t]-v[1][t]));if(Math.abs(v[0].y-v[n].y)<s&&y<a)break;for(let t=0;t<n;++t){g[t]=0;for(let e=0;e<n;++e)g[t]+=v[e][t];g[t]/=n}let t=v[n];if(Eu(b,1+f,g,-f,t),b.y=await p(b),b.y<v[0].y)Eu(_,1+c,g,-c,t),_.y=await p(_),_.y<b.y?m(_):m(b);else if(b.y>=v[n-1].y){let e=!1;if(b.y>t.y?(Eu(w,1+l,g,-l,t),w.y=await p(w),w.y<t.y?m(w):e=!0):(Eu(w,1-l*f,g,l*f,t),w.y=await p(w),w.y<b.y?m(w):e=!0),e){if(d>=1)break;for(let t=1;t<v.length;++t)Eu(v[t],1-d,v[0],d,v[t]),v[t].y=await p(v[t])}}else m(b)}v.sort(Mu);let j=[],O=v[0];for(let t=0;t<n;t++)j.push(O[t]);return{count:h,y:v[0].y,x:j}}(t,n);return o.y>=e.fitness?e:{ps:Ve(o.x,(t,e)=>Nu(t,e,r)),fitness:o.y}}if("Neighbor"===t||"OneGold"===t||"Gold"===t){let u=await async function(t,e,r={}){Tu(t);let n=st(r,"sdmMode","");yu(n,["Neighbor","OneGold","Gold"])||(n="Neighbor");let i=st(r,"ModeOutLimit","");yu(i,["Mapping","Limit","Random"])||(i="Mapping");let o=0,u=st(r,"calcFitness");ln(u)||(u=async(t,r)=>{o++;let n=Ve(t.ps,"value"),i=e(n);return pu(i)&&(i=await i),{ps:t.ps,fitness:i}});let s,a=st(r,"initSolution");if(a&&Ln(a.ps)&&Nr(a.fitness))s=hu(a);else{let e=ju(t);s=await u(e,"init")}let f=hu(s);if("Neighbor"===n){let e=-1,r=0;for(;;){let n=await Lu(s,t,i,u,e,r);if(s.fitness===n.sMove.fitness)break;s=n.sMove,e=n.level,r=n.dir,f.fitness>s.fitness&&(f=hu(s))}}else if("OneGold"===n){let e=await ku(s,t,u);f.fitness>e.fitness&&(f=e)}else if("Gold"===n){let e=50,r=0;for(;r++,!(r>e);){let e=await ku(s,t,u);if(s.fitness===e.fitness)break;s=e,f.fitness>s.fitness&&(f=hu(s))}}return{bestSolution:f,stopExecutions:o}}(r,n,{sdmMode:t,ModeOutLimit:o,initSolution:e,calcFitness:i});return u.bestSolution}if("SA"===t){let t=await async function(t,e,r={}){Tu(t);let n=st(r,"Nl","");Ur(n)||(n=1e4),n=xr(n);let i=st(r,"NContiguous","");Ur(i)||(i=200),i=xr(i);let o=st(r,"NCore","");Ur(o)||(o=1e6),o=xr(o);let u=st(r,"ModeOutLimit","");yu(u,["Mapping","Limit","Random"])||(u="Mapping");let s=st(r,"saInitialTemperature","");Nr(s)||(s=100),s=Ar(s);let a=st(r,"saAlpha","");Nr(a)||(a=.9),a=Ar(a);let f=st(r,"UseHists","");$n(f)||(f=!0);let c=st(r,"funGetBetter"),l=st(r,"funEndLoop"),d=0,h=st(r,"calcFitness");ln(h)||(h=async(t,r)=>{d++;let n=Ve(t.ps,"value"),i=e(n);return pu(i)&&(i=await i),{ps:t.ps,fitness:i}});let p,v=st(r,"initSolution");if(v&&Ln(v.ps)&&Nr(v.fitness))p=hu(v);else{let e=ju(t);p=await h(e,"init")}let y=hu(p),m=[],g="",b=0,w=0,_=0,j=s;f&&m.push(hu(p));let O=-1;for(;;){O++;let e,r=Au(p,t,u);e=r.changed?await h({ps:r.ps},"neighbor"):{ps:r.ps,fitness:p.fitness};let s=e.fitness-p.fitness;if(s<0?(p=e,j*=a):Math.random()<Math.exp(-s/j)&&(p=e),y.fitness>p.fitness?(y=hu(p),ln(c)&&c(hu(y),O),_=0):_+=1,f&&m.push(hu(p)),O>=n?g=`stop by Nl[${n}]`:_>=i?g=`stop by iContinue[${_}] >= NContiguous[${i}]`:d>=o&&(g=`stop by iExecute[${d}] >= NCore[${o}]`),Gt(g)){b=O,w=d;break}ln(l)&&l(hu(p),hu(y),O)}return{bestSolution:y,hists:m,stopMode:g,stopNl:b,stopExecutions:w}}(r,n,{initSolution:e,calcFitness:i,ModeOutLimit:o,Nl:1e3,NContiguous:5,saInitialTemperature:Math.max(.05*e.fitness,1),saAlpha:.9,UseHists:!1});return t.bestSolution}if("TA"===t){return(await Pu(r,n,{initSolution:e,calcFitness:i,ModeOutLimit:o,Nl:1e3,NContiguous:5,taThresholdType:"Geometric Series",taThresholdInitial:Math.max(.05*e.fitness,1),UseHists:!1})).bestSolution}throw new Error(`invalid LocalSearchMethod[${t}]`)}function Du(t,e,r){var n=null==t?0:t.length;return n?Gr(t,(e=r||void 0===e?1:jr(e))<0?0:e,n):[]}var Cu=Array.prototype.reverse;function Ru(t,e){return Gt(t)&&yn(e)?0===(e=xr(e))?t:En(t,t.length-e):""}function Iu(t,e={}){let r=st(e,"excludeString");if($n(r)||(r=!1),!Gt(t))return"";let n=t=>t>="0"&&t<="9"||"."===t||"-"===t||"+"===t,i=fn(t);if(r){let t=i.split("");for(let e=0;e<t.length;e++)if(n(t[e])){i=Ru(i,e),t=Du(t,e);break}t=null==(o=t)?o:Cu.call(o);for(let e=0;e<t.length;e++)if(n(t[e])){i=Mn(i,e);break}}var o;return i}function qu(t){let e=0,r=0,n=0,i=lr(t);Hr(t,t=>{Nr(t)?e+=1:Ht(t)?r+=1:On(t)&&(n+=1)});let o="";return e===i?o="num":r===i?o="str":n===i?o="obj":e+r===i?o="str":console.log("eles in array are non-homogeneous",t),o}function zu(t,e,r={}){let n=[];if("num"!==e&&"str"!==e&&"files"!==e)throw new Error(`invalid type[${e}]`);if("num"===e)n=Ve(t,(t,e)=>({key:e,payload:t,value:Ar(t)}));else if("files"===e)n=Ve(t,(t,e)=>({key:e,payload:t,value:gu(t)}));else if("str"===e){let e=Ve(t,t=>Iu(t,{excludeString:!0})),r=0;Hr(e,t=>{Nr(t)&&r++});let i=r===lr(e);n=Ve(t,(t,r)=>{let n=t;return i?(n=e[r],n=Ar(n)):n=gu(n),{key:r,payload:t,value:n}})}return n}function Uu(t,e){let r=Lo(t,"value");return Ve(r,e?"key":"payload")}function Yu(t,e){let r=function(t,e){let r=hu(t);return r.sort((t,r)=>t[e].localeCompare(r[e],"standard",{numeric:!0})),r}(t,"value");return Ve(r,e?"key":"payload")}function Bu(t,e){let r=function(){let t,e,r=new Promise(function(){t=arguments[0],e=arguments[1]});return r.resolve=t,r.reject=e,r}();if(!Sn(t)&&!On(t))return r.reject("rs is not an array or object"),r;let n=!1;if(On(t)){n=!0;let e=[];Hr(t,(t,r)=>{e.push({k:r,v:t})}),t=e}ln(e)||(e=function(t){return t});let i=-1,o=[];return t.reduce(function(t,r){return t.then(function(t){o.push(t),i+=1;let u=i,s=r;return n&&(u=r.k,s=r.v),ln(e)?e(s,u):s})},Promise.resolve()).then(function(t){o.push(t),o=Du(o),r.resolve(o)}).catch(function(t){r.reject(t)}),r}function Hu(t,e){var r=[];return Ge(t,function(t,n,i){e(t,n,i)&&r.push(t)}),r}function Gu(t,e){return(r(t)?oe:Hu)(t,Ue(e))}let Zu=(t,e,r,n,i)=>{if(!(Nr(o=e)&&Ar(o)>0))throw new Error(`uIni[${e}] is not a positive number`);var o;if(!Gt(n))throw new Error(`invalid timeOhlcStart[${n}]`);if(!Gt(i))throw new Error(`invalid timeOhlcEnd[${i}]`);r=Lo(r,"timeStart");let u=[],s=[];Hr(r,t=>{Gt(t.modeResult)?u.push(t):s.push(t)});let a=lr(r),f=lr(u),c=lr(s),l=mn(lr(Gu(r,{modeResult:"profit"}))/f*100,2)+"%",d=0,h="",p="",v=0,y="",m="",g="",b=0,w="",_=0,j=0,O=e,S=e,$={},E={};Hr(r,t=>{if(Gt(t.modeResult)){O=Math.max(O,t.uEquity);let e=O-t.uEquity,r=mn(e/O*100,2)+"%";e>d&&(d=e,S=O,h=r)}{let e=null;e=1,Gt(t.timeStart)&&(Tn($,t.timeStart)||($[t.timeStart]=0),$[t.timeStart]+=e*t.uTrade,Tn(E,t.timeStart)||(E[t.timeStart]=0),E[t.timeStart]+=1),Gt(t.timeEnd)&&(Tn($,t.timeEnd)||($[t.timeEnd]=0),$[t.timeEnd]-=e*t.uTrade,Tn(E,t.timeEnd)||(E[t.timeEnd]=0),E[t.timeEnd]-=1)}});{let t=[];Hr($,(e,r)=>{if(!mu(e))throw console.log("time",r),new Error(`invalid uTradeAll[${e}]`);t.push({time:r,uTradeAll:e})}),t=Lo(t,"time");let e=0,r=Ve(t,t=>(e+=t.uTradeAll,{...t,uAccm:e})),n={};Hr(r,t=>{n[t.time]=t.uAccm}),$=n}{let t=[];Hr(E,(e,r)=>{if(!mu(e))throw console.log("time",r),new Error(`invalid numTradeAll[${e}]`);t.push({time:r,numTradeAll:e})}),t=Lo(t,"time");let e=0,r=Ve(t,t=>(e+=t.numTradeAll,{...t,nAccm:e})),n={};Hr(r,t=>{n[t.time]=t.nAccm}),E=n}r=Ve(r,t=>{let r=st($,t.timeStart,null);if(!mu(r))throw new Error("invalid uTradeAll");r=Math.abs(r),t.uTradeAll=r;let n=mn(t.uTradeAll/e*100,2)+"%";t.rTradeAll=n,b<t.uTradeAll&&(b=t.uTradeAll,w=t.rTradeAll);let i=st(E,t.timeStart,null);if(!mu(i))throw new Error("invalid numTradeAll");return t.numTradeAll=i,_<t.numTradeAll&&(_=t.numTradeAll),t});{let t=lr(u)-1;v=st(u,`${t}.uEquity`,""),y=st(u,`${t}.uCumuProfitOrLoss`,""),m=st(u,`${t}.rCumuProfitOrLoss`,"")}{let t;t=S-e+b>0?d/(S-e+b):0,p=mn(100*t,2)+"%"}g=b>0&&mu(y)?y/b:0,g=mn(100*g,2)+"%";{let t=0,e=0,r=0,n=0;Hr(u,t=>{let e=t.rProfitOrLossDay*t.dayHold;r+=e;let i=t.dayHold;n+=i}),n>0&&(t=r/n);let i=0;Hr(u,e=>{let r=e.rProfitOrLossDay-t,n=e.dayHold*(r*r);i+=n}),n>1&&(e=Math.sqrt(i/(n-1))),e>0&&(j=t/e*Math.sqrt(252)),j<-10&&(j=-10),j>10&&(j=10)}let M=t(n),N=t(i).diff(M,"day"),A=N/365,x="";{let t;t=0===e||0===A?0:(v-e)/e/A,x=`${mn(100*t,2)}%`}let T="";{let t;t=0===b||0===A?0:(v-e)/b/A,T=`${mn(100*t,2)}%`}return{btDays:N,btYears:mn(A,1),numTrade:a,numTradeFin:f,numTradeUnsettled:c,uTradeAllMax:b,rTradeAllMax:w,numTradeAllMax:_,uDrawdownMax:d,rDrawdownMax:h,rEquivalentDrawdownMax:p,rSharpe:j,rWin:l,uEquityFinal:v,uCumuProfitOrLossFinal:y,rCumuProfitOrLossFinal:m,rCumuProfitOrLossFinalNormYear:x,rEquivalentCumuProfitOrLossFinal:g,rEquivalentCumuProfitOrLossFinalNormYear:T}},Vu=async(t,e,r,n={})=>{let i=st(e,"mode","");if("long"!==i&&"short"!==i)throw new Error(`invalid strategy.mode[${i}] not 'long' or 'short'`);let o=st(e,"keyOhlc","");if(!Gt(o))throw new Error("invalid strategy.keyOhlc");let u=st(e,"conds",[]);if(!Ln(u))throw new Error("invalid strategy.conds");let s=lr(u),a=st(e,"settings",{});if(xu(a)||(a={uIni:1e3,uTrade:1,rTakeProfit:.05,rStopLoss:.03,rFee:5e-4}),!ln(r))throw new Error("funGetSeries is not a function");let f=st(n,"withCalcOrderProfitOrLoss",!0),c=st(n,"withSummary",!0),l=await r(o),d={},h={};await Bu(u,async t=>{let e=await r(t.key);Tn(h,t.key)||(h[t.key]={}),Hr(e,e=>{h[t.key][e.time]=e.param,Tn(d,e.time)||(d[e.time]=0),d[e.time]+=1})});let p=[];Hr(d,(t,e)=>{t===s&&p.push(e)}),p=function(t,e={}){if(!Ln(t))return[];if(1===lr(t))return t;let r=st(e,"localeCompare");$n(r)||(r=!1);let n=st(e,"returnIndex");$n(n)||(n=!1);let i=st(e,"compareKey",null),o=null;o=r?Yu:Uu;let u,s=qu(t);if(""===s)return[];if("obj"===s){if(!Gt(i))return[];let s=Ve(t,(t,e)=>st(t,i,"")),a=qu(s);if("num"!==a&&"str"!==a)return[];{r&&(a="files");let i=o(zu(s,a,e),!0);u=n?i:Ve(i,e=>t[e])}}else"num"!==s&&"str"!==s||(r&&(s="files"),u=o(zu(t,s,e),n));return u}(p);let v={};Hr(p,t=>{v[t]=!0});let y={};Hr(p,t=>{y[t]={},Hr(u,e=>{y[t][e.key]=h[e.key][t]})});let m=st((g=l)&&g.length?g[0]:void 0,"time","");var g;let b=st(function(t){var e=null==t?0:t.length;return e?t[e-1]:void 0}(l),"time",""),w=[];await Bu(l,async t=>{let e=st(t,"time");if(!Tn(v,e))return!0;let r=!0;{let t=[];Hr(u,(r,n)=>{let i=y[e][r.key],o=st(r,"sym",">"),u=st(r,"th",0),s=st(r,"opr",null);"and"!==s&&"or"!==s&&(s="and");let a=!1;a=">"===o?i>u:i<u,t.push({opr:s,b:a})});let n=t.filter(t=>"and"===t.opr).every(t=>t.b),i=t.filter(t=>"or"===t.opr),o=0===i.length||i.some(t=>t.b);r=n&&o}let n=!1,o=!1;if(r&&("long"===i?n=!0:o=!0),n){let r={mode:"long",timeStart:e,priceStart:t.Close,uTrade:a.uTrade,rTakeProfit:a.rTakeProfit,priceTakeProfit:(1+a.rTakeProfit)*t.Close,rStopLoss:a.rStopLoss,priceStopLoss:(1-a.rStopLoss)*t.Close,timeEnd:"",priceEnd:"",modeResult:"",rFee:a.rFee,uFee:a.rFee*a.uTrade,uProfitOrLoss:"",rProfitOrLoss:"",uCumuProfitOrLoss:"",rCumuProfitOrLoss:"",uEquity:"",uTradeAll:"",rTradeAll:""};w.push(r)}else if(o){let r={mode:"short",timeStart:e,priceStart:t.Close,uTrade:a.uTrade,rTakeProfit:a.rTakeProfit,priceTakeProfit:(1-a.rTakeProfit)*t.Close,rStopLoss:a.rStopLoss,priceStopLoss:(1+a.rStopLoss)*t.Close,timeEnd:"",priceEnd:"",modeResult:"",rFee:a.rFee,uFee:a.rFee*a.uTrade,uProfitOrLoss:"",rProfitOrLoss:"",uCumuProfitOrLoss:"",rCumuProfitOrLoss:"",uEquity:"",uTradeAll:"",rTradeAll:""};w.push(r)}}),f&&(w=await(async(t,e,r={})=>{e=Lo(e,"timeStart");let n=st(r,"uIni",1e3),i={};Hr(t,t=>{i[t.time]=t});let o={},u=n,s=0;Hr(e,(t,e)=>{Hr(i,r=>{if(r.time<=t.timeStart)return delete i[r.time],!0;if("long"===t.mode){if(r.Low<=t.priceStopLoss)return t.timeEnd=r.time,t.priceEnd=t.priceStopLoss,t.uProfitOrLoss=t.uTrade*(t.priceEnd/t.priceStart)-t.uTrade-2*t.uFee,t.rProfitOrLoss=t.uProfitOrLoss/t.uTrade,s+=t.uProfitOrLoss,t.uCumuProfitOrLoss=s,t.rCumuProfitOrLoss=mn(t.uCumuProfitOrLoss/n*100,2)+"%",u+=t.uProfitOrLoss,t.uEquity=u,t.modeResult=t.uProfitOrLoss<0?"loss":"profit",o[e]=t,!1;if(r.High>=t.priceTakeProfit)return t.timeEnd=r.time,t.priceEnd=t.priceTakeProfit,t.uProfitOrLoss=t.uTrade*(t.priceEnd/t.priceStart)-t.uTrade-2*t.uFee,t.rProfitOrLoss=t.uProfitOrLoss/t.uTrade,s+=t.uProfitOrLoss,t.uCumuProfitOrLoss=s,t.rCumuProfitOrLoss=mn(t.uCumuProfitOrLoss/n*100,2)+"%",u+=t.uProfitOrLoss,t.uEquity=u,t.modeResult=t.uProfitOrLoss<0?"loss":"profit",o[e]=t,!1}else{if(r.High>=t.priceStopLoss)return t.timeEnd=r.time,t.priceEnd=t.priceStopLoss,t.uProfitOrLoss=(t.priceStart-t.priceEnd)*(t.uTrade/t.priceStart)-2*t.uFee,t.rProfitOrLoss=t.uProfitOrLoss/t.uTrade,s+=t.uProfitOrLoss,t.uCumuProfitOrLoss=s,t.rCumuProfitOrLoss=mn(t.uCumuProfitOrLoss/n*100,2)+"%",u+=t.uProfitOrLoss,t.uEquity=u,t.modeResult=t.uProfitOrLoss<0?"loss":"profit",o[e]=t,!1;if(r.Low<=t.priceTakeProfit)return t.timeEnd=r.time,t.priceEnd=t.priceTakeProfit,t.uProfitOrLoss=(t.priceStart-t.priceEnd)*(t.uTrade/t.priceStart)-2*t.uFee,t.rProfitOrLoss=t.uProfitOrLoss/t.uTrade,s+=t.uProfitOrLoss,t.uCumuProfitOrLoss=s,t.rCumuProfitOrLoss=mn(t.uCumuProfitOrLoss/n*100,2)+"%",u+=t.uProfitOrLoss,t.uEquity=u,t.modeResult=t.uProfitOrLoss<0?"loss":"profit",o[e]=t,!1}})});{let t=[];Hr(e,(e,r)=>{let n=null;n=Tn(o,r)?o[r]:e,t.push(n)}),e=t}return e})(l,w,{uIni:a.uIni}));let _={timeTest:t().format("YYYY-MM-DDTHH:mm:ssZ"),timeOhlcStart:m,timeOhlcEnd:b,uIni:st(a,"uIni","")};if(c){w=((t,e)=>Ve(e,e=>{if(!Gt(e.modeResult))return e;let r=t(e.timeStart),n=t(e.timeEnd),i=r.format("YYYY-MM-DD"),o=n.format("YYYY-MM-DD"),u=t(i,"YYYY-MM-DD"),s=t(o,"YYYY-MM-DD").diff(u,"day")+1;e.dayHold=s;let a=0;return 1+e.rProfitOrLoss>=0&&(a=Math.pow(1+e.rProfitOrLoss,1/e.dayHold)-1),e.rProfitOrLossDay=a,e}))(t,w);let e=Zu(t,a.uIni,w,m,b);_={..._,...e}}return{orders:w,summary:_}};function Wu(t){let r=null,n=function(t,e={}){let r=null,n=st(e,"fs"),i="";try{i=n.readFileSync(t,"utf8")}catch(t){r=t}return null!==r?{error:r}:{success:i}}(t,{fs:e});if(n.error)return n;let i=n.success,o=null;try{o=JSON.parse(i)}catch(t){r=t}return null!==r?{error:r}:{success:o}}function Ju(r,n=1){return function(t,e=1,r={}){let n=1,i=st(r,"path"),o=st(r,"fs");if(!bn(t,{fs:o}))throw new Error(`fd[${t}] is not a folder`);return null!==e&&Ur(e)&&(e=xr(e))<1&&(e=1),function t(r){let u=[];return bn(r,{fs:o})?(Hr(o.readdirSync(r),function(s){let a=i.resolve(r,s),f=null;try{f=o.statSync(a)}catch(t){}f&&f.isDirectory()?(u.push({isFolder:!0,level:n,path:a,name:i.basename(a)}),n+=1,(n<=e||null===e)&&(u=u.concat(t(a))),n-=1):u.push({isFolder:!1,level:n,path:a,name:i.basename(a)})}),u):u}(t)}(r,n,{path:t,fs:e})}let Ku={dlmSeps:" ║ ",dlmPkgs:" ⊙ "},Qu=(t,e={})=>{let r=st(e,"readContent",!1);if(!jn(t))return console.log(`invalid fd[${t}]`),[];let n=Ju(t);if(n=Gu(n,{isFolder:!1}),0===lr(n))return console.log(`fd[${t}] no files`),[];let i=[];return Hr(n,t=>{let e=function(t,e,r){return Gt(t)&&Gt(e)&&Ht(r)?String(t).replaceAll(e,r):""}(t.name,".json",""),n=cn(e,Ku.dlmPkgs),o=st(n,0,"");if(!Gt(o))return!0;let u=st(n,1,""),s=st(n,2,""),a=cn(o,Ku.dlmSeps),f=st(a,0,"");a=Du(a);let c=`${o}:${u}`,l={path:t.path,name:t.name,tkid:c,tid:o,levelNumTrade:u,rEquivalentCumuProfitOrLossFinalNormYear:s,mode:f,ps:a};if(r){let e=Wu(t.path);l.data=st(e,"success",null)}i.push(l)}),i};var Xu=Array.prototype.join;function ts(t,e){return null==t?"":Xu.call(t,e)}let es=(t,e,r,n)=>{let i=ts([r,...n],Ku.dlmSeps);return i=i.replaceAll(`${t}_`,""),i=i.replaceAll(`${e}_`,""),i=i.replaceAll("price_","p_"),i=i.replaceAll("index_","i_"),i=i.replaceAll("Ohlc_","o_"),i=i.replaceAll("Close_","c_"),i=i.replaceAll("Volumn_","v_"),i},rs=(t,e,r,n)=>{let i=ts([r,...Ve(n,t=>`${t.key}${t.sym}${t.th}`)],Ku.dlmSeps);return i=i.replaceAll(`${t}_`,""),i=i.replaceAll(`${e}_`,""),i=i.replaceAll("price_","p_"),i=i.replaceAll("index_","i_"),i=i.replaceAll("Ohlc_","o_"),i=i.replaceAll("Close_","c_"),i=i.replaceAll("Volumn_","v_"),i},ns=t=>(t=gu(t)).indexOf("%")<0?0:(t=Ar(t=t.replace("%","")),t/=100),is=t=>{if(!Nr(t))throw new Error(`numTrade[${t}] is not a number`);let e=0;return e=(t=xr(t))<=0?0:t<=5?1:t<=9?2:t<=24?11:t<=49?12:t<=74?13:t<=99?14:t<=249?101:t<=499?102:t<=749?103:t<=999?104:t<=1999?1001:t<=2999?1002:t<=3999?1003:t<=4999?1004:100,e},os=(t,e)=>{let r=xr(e.numTrade),n=t.uIni,i=e.uEquityFinal-n,o=ns(e.rEquivalentCumuProfitOrLossFinalNormYear);o=Math.min(Math.max(o,0),.5),o/=.5;let u=1-o,s=ns(e.rWin);s=Math.min(Math.max(s,0),1);let a=0;return a+=2*(1-s),a+=1*u,0===r&&(a+=1e6),i<=0&&(a+=1e6),a},us=(t,e,r,n,i,o)=>{let u=es(t,e,r,n),s=xr(o.numTrade),a=is(s),f=o.rEquivalentCumuProfitOrLossFinalNormYear;return`${u}${Ku.dlmPkgs}${a}${Ku.dlmPkgs}${f}.json`},ss=async(r,n,i,o,u,s,a,f,c,l={})=>{if(!Gt(i))throw new Error(`invalid fdOhlc[${i}]`);if(!Gt(o))throw new Error(`invalid fdParam[${o}]`);if(!Gt(u))throw new Error(`invalid timeStart[${u}]`);if(!Gt(s))throw new Error(`invalid timeEnd[${s}]`);if("long"!==a&&"short"!==a)throw new Error(`invalid mode[${a}]`);if(!Ln(f))throw new Error(`invalid keys[${f}]`);if(!Gt(c))throw new Error(`invalid fdData[${c}]`);let d=st(l,"keySettings","");if(!Gt(d))throw new Error(`invalid opt.keySettings[${d}]`);let h=st(l,"thsTp",null);Ln(h)||(h=[1,2,3,4,5,6,7,8,9,10]);let p=st(l,"thsSl",null);Ln(p)||(p=[1,2,3,4,5,6,7,8,9,10]);let v=st(l,"thNumTrade",null);Nr(v)||(v=1);let y=st(l,"thRWin",null);Nr(y)||(y=.5);let m=st(l,"thREquivalentCumuProfitOrLossFinalNormYear",null);Nr(m)||(m=.15);let g=st(l,"useShowLog",null),b=vn(i,o),w=st(n,`${d}.name`,""),_=st(n,`${d}.symbol`,""),j=st(n,`${d}.interval`,"");jn(c)||wn(c,{fs:e});let O=await b.buildGetTimeSeriesByTimeRange(u,s),S=es(w,j,a,f),$=[];{let t;t=p,t=Ve(t,t=>t/100),$.push({values:t,n:lr(t)}),t=h,t=Ve(t,t=>t/100),$.push({values:t,n:lr(t)})}Hr(f,()=>{let t=kn(-2,2,40);t=Ve(t,t=>t+10);let e=kn(-2,2,40);e=Ve(e,t=>t-10);let r=[...t,...e];$.push({values:r,n:lr(r)})});let E=0,M=1e20,N=await async function(t,e,r={}){Tu(t);let n=st(r,"Nl","");Ur(n)||(n=1e4),n=xr(n);let i=st(r,"Np","");Ur(i)||(i=40),i=xr(i);let o=lr(t),u=st(r,"NContiguous","");Ur(u)||(u=100),u=xr(u);let s=st(r,"NRepeat","");Ur(s)||(s=1),s=xr(s);let a=st(r,"NCore","");Ur(a)||(a=1e6),a=xr(a);let f=st(r,"ModeOutLimit","");yu(f,["Mapping","Limit","Random"])||(f="Mapping");let c=st(r,"UseRepeat","");$n(c)||(c=!0);let l=st(r,"UseImmigration","");$n(l)||(l=!0);let d=st(r,"LocalSearchMethod","");yu(d,["None","Neighbor","TA","SA","OneGold","Gold","NelderMead"])||(d="NelderMead");let h=st(r,"funGetBetter"),p=st(r,"funEndLoop"),v=st(r,"funGenerationBefore"),y=st(r,"funGenerationAfter"),m=st(r,"psoC1Start","");Nr(m)||(m=2),m=Ar(m);let g=st(r,"psoC1End","");Nr(g)||(g=2),g=Ar(g);let b=st(r,"psoC1Dynamic","");Nr(b)||(b=0),b=Ar(b);let w=st(r,"psoC2Start","");Nr(w)||(w=2),w=Ar(w);let _=st(r,"psoC2End","");Nr(_)||(_=2),_=Ar(_);let j=st(r,"psoC2Dynamic","");Nr(j)||(j=0),j=Ar(j);let O=st(r,"psoBeta","");Nr(O)||(O=.9),O=Ar(O);let S=st(r,"psoGamma","");Nr(S)||(S=.5),S=Ar(S);let $=st(r,"psoInertiaMin","");Nr($)||($=.4),$=Ar($);let E=0,M=0,N=0,A=async(t,r)=>{N++;let n=Ve(t.ps,"value"),i=e(n);return pu(i)&&(i=await i),{ps:t.ps,fitness:i}},x=async e=>{let r=ju(t),n=await A(r),i=[];for(let e=0;e<o;e++){let r=t[e].n;i.push(_u(-(r-1),r-1))}let u=(1+Math.random())*$;return{ps:n.ps,fitness:n.fitness,bs:hu(n),velocity:i,inertia:u}},T=null,P=[],L="",k=0,F=0,D=[],C=null;for(let t=0;t<i;t++){let t=await x();D.push(t)}D=Lo(D,"fitness"),C={ps:hu(D[0].ps),fitness:D[0].fitness},P.push(hu(D[0])),T={ps:hu(D[0].ps),fitness:D[0].fitness};let R=async(e,r)=>{let n,u=e+r;n=u>4?2/Math.abs(2-u-Math.sqrt(u*u-4*u)):1;for(let u=0;u<i;u++){let i=D[u],s=Math.random(),a=Math.random();for(let u=0;u<o;u++){let o=0;o+=i.inertia*i.velocity[u],o+=e*s*(i.bs.ps[u].ind-i.ps[u].ind),o+=r*a*(C.ps[u].ind-i.ps[u].ind),o*=n;let f=S*(t[u].n-1),c=-f;i.velocity[u]=Math.max(Math.min(o,f),c)}let c=O*i.inertia;i.inertia=Math.max(Math.min(c,1e4),$);for(let e=0;e<o;e++){let r=Math.round(i.ps[e].ind+i.velocity[e]);r=Ou(r,t[e].n-1,f),i.ps[e].ind=r,i.ps[e].value=t[e].values[r]}let l=await A(i);i.fitness=l.fitness,i.bs.fitness>i.fitness&&(i.bs={ps:hu(i.ps),fitness:i.fitness}),C.fitness>i.fitness&&(C={ps:hu(i.ps),fitness:i.fitness})}},I=-1;for(;;){I++;let r={psoC1:$u(m,g,b,M,u),psoC2:$u(w,_,j,M,u),psoBeta:O,psoGamma:S,psoInertiaMin:$,ModeOutLimit:f,LocalSearchMethod:d};if(ln(v)){let t=await v({params:hu(r)});t&&t.params&&(r={...r,...t.params})}O=r.psoBeta,S=r.psoGamma,$=r.psoInertiaMin,f=r.ModeOutLimit,d=r.LocalSearchMethod;let o=r.psoC1,q=r.psoC2;await R(o,q),D=Lo(D,"fitness");let z=async()=>{for(let t=i-1;t>=1;t--)if(Su(D[t-1],D[t])){let e=await x();D[t]=e}D=Lo(D,"fitness"),C.fitness>D[0].fitness&&(C={ps:hu(D[0].ps),fitness:D[0].fitness})};l&&await z();let U=async()=>{let r={ps:hu(D[0].ps),fitness:D[0].fitness},n=await Fu(d,r,t,e,A,f);n.fitness>=D[0].fitness||(D[0].ps=n.ps,D[0].fitness=n.fitness,C.fitness>n.fitness&&(C={ps:hu(n.ps),fitness:n.fitness}))};await U(),P.push(hu(D[0])),T.fitness>D[0].fitness?(T={ps:hu(D[0].ps),fitness:D[0].fitness},ln(h)&&h(hu(T),I),M=0):M+=1;let Y=async()=>{for(let t=1;t<=i-1;t++){let e=await x();D[t]=e}D=Lo(D,"fitness"),M=0,E+=1};if(c&&M>=u&&E<s&&await Y(),I>=n?L=`stop by Nl[${n}]`:M>=u?L=`stop by iContinue[${M}] >= NContiguous[${u}]`:N>=a&&(L=`stop by iExecute[${N}] >= NCore[${a}]`),ln(y)&&await y({params:hu(r),childrenBestFitness:D[0].fitness}),Gt(L)){k=I,F=N;break}ln(p)&&p(hu(D),hu(T),I)}return{bestSolution:T,hists:P,stopMode:L,stopNl:k,stopIteration:k,stopExecutions:F}}($,async n=>{E++;let i=n[0];i=Er(i,3);let o=n[1];o=Er(o,3);let u=Ve(f,(t,e)=>{let r=e+2,i=st(n,r,null);if(null===i)throw console.log("xs",n),console.log("ix",r),console.log("key",t),console.log("i",e),new Error("invalid x");let o="",u=null;return i<0?(o="<",u=i+10,u=go(u,3)):(o=">",u=i-10,u=go(u,3)),{key:t,sym:o,th:u}}),s=rs(w,j,a,u),l={tid:S,sid:s,name:w,symbol:_,interval:j,keyOhlc:`${w}_price_${j}`,mode:a,conds:u,settings:{uIni:1e3,uTrade:1,rTakeProfit:o,rStopLoss:i,rFee:5e-4}},d=await Vu(r,l,O),h=xr(d.summary.numTrade),p=ns(d.summary.rWin),b=ns(d.summary.rEquivalentCumuProfitOrLossFinalNormYear),$=os(l.settings,d.summary),N={...l,summary:d.summary,fitness:$},A={"方向":N.mode,"每次下單金額":N.settings.uTrade,"止盈":mn(100*N.settings.rTakeProfit,1)+"%","止損":mn(100*N.settings.rStopLoss,1)+"%","最大持倉比例":N.summary.rTradeAllMax,"交易次數":N.summary.numTrade,"最大回撤率":N.summary.rDrawdownMax,"勝率":N.summary.rWin,"夏普值":mn(N.summary.rSharpe,4),"最終盈虧":N.summary.rCumuProfitOrLossFinal,"最終等效盈虧":N.summary.rEquivalentCumuProfitOrLossFinal,"最終等效年化盈虧":N.summary.rEquivalentCumuProfitOrLossFinalNormYear,fitness:N.fitness};if(M>$&&(g&&console.log(E,"更新最佳解",A),M=$),h>=v&&p>=y&&b>=m){g&&console.log(E,"可用參數組",A);let r={};Hr(Qu(c,{readContent:!1}),t=>{r[t.tkid]=t});let n=is(h),i=`${S}:${n}`,o=!1,u=b;if(Tn(r,i)){let t=ns(r[i].rEquivalentCumuProfitOrLossFinalNormYear);u>t&&(o=!0,g&&console.log("刪除較差策略...",`${u} > ${t}`,r[i].path),function(t){_n(t,{fs:e})}(r[i].path))}else o=!0;if(o){let e=us(w,j,a,f,0,d.summary);xn(t.resolve(c,e),N,{useFormat:!0})}}return $},{});return g&&(console.log("bestSolution",N.bestSolution),console.log("stopMode",N.stopMode),console.log("stopIteration",N.stopIteration),console.log("stopExecutions",N.stopExecutions)),N},as=async(t,e,r,n,i,o,u,s,a,f={})=>{if(!Gt(r))throw new Error(`invalid fdOhlc[${r}]`);if(!Gt(n))throw new Error(`invalid fdParam[${n}]`);if(!Gt(i))throw new Error(`invalid timeStart[${i}]`);if(!Gt(o))throw new Error(`invalid timeEnd[${o}]`);if("long"!==u&&"short"!==u)throw new Error(`invalid mode[${u}]`);if(!ln(s))throw new Error("funPickKeys is not a function");if(!Gt(a))throw new Error(`invalid fdData[${a}]`);let c=st(f,"funFilterKeysNorm",null),l=st(f,"funFilterKeysIndex",null),d=st(f,"funFilterKeysVolumn",null),h=vn(r,n).getKeysParam(),p=[],v=[],y=[];Hr(h,t=>{let e=0===t.indexOf("index_"),r=t.indexOf("_vbs_")>=0,n=!(e||r);e?p.push(t):r?v.push(t):n&&y.push(t)}),ln(c)&&(y=await c(y)),ln(l)&&(p=await l(p)),ln(d)&&(v=await d(v));let m=s({keysNorm:y,keysIndex:p,keysVolumn:v});await ss(t,e,r,n,i,o,u,m,a,f)},fs=async(t,e,r,n,i,o,u,s,a,f={})=>{if(!Gt(r))throw new Error(`invalid fdOhlc[${r}]`);if(!Gt(n))throw new Error(`invalid fdParam[${n}]`);if(!Gt(i))throw new Error(`invalid timeStart[${i}]`);if(!Gt(o))throw new Error(`invalid timeEnd[${o}]`);if("long"!==u&&"short"!==u)throw new Error(`invalid mode[${u}]`);if(!Gt(s))throw new Error(`invalid comps[${s}]`);if(!Gt(a))throw new Error(`invalid fdData[${a}]`);let c=cn(s,",");if(3!==lr(c))throw new Error(`comps[${s}]非預期`);c=Ve(c,xr);let l=(t,e)=>Ve(Yr(0,lr(t)-1,e),e=>st(t,e));await as(t,e,r,n,i,o,u,({keysNorm:t,keysIndex:e,keysVolumn:r})=>{let n=[];return c[0]>=1&&(n=[...n,...l(t,c[0])]),c[1]>=1&&(n=[...n,...l(e,c[1])]),c[2]>=1&&(n=[...n,...l(r,c[2])]),n},a,f)};return{estimFinder:async(t,e,n,i,o,u={})=>{if(!Gt(n))throw new Error(`invalid fdOhlc[${n}]`);if(!Gt(i))throw new Error(`invalid fdParam[${i}]`);if(!Gt(o))throw new Error(`invalid fdData[${o}]`);let s=st(u,"mode",null),a=st(u,"timeStart",null),f=st(u,"timeEnd",null),c=st(u,"comps",null),l="";l=Gt(s)?s:Math.random()<.5?"long":"short";let d="2022-07-01T00:00:00";Gt(a)&&(d=a);let h="";h=Gt(f)?f:"long"===l?"2025-04-08T00:00:00":"2025-10-06T00:00:00";let p=["2,0,0","3,0,0","4,0,0","2,1,0","3,1,0","4,1,0","2,2,0","3,2,0","4,2,0","2,0,1","3,0,1","4,0,1","2,1,1","3,1,1","4,1,1","2,2,1","3,2,1","4,2,1"],v="";var y;v=Gt(c)?c:(r(y=p)?lt:Bt)(y),await fs(t,e,n,i,d,h,l,v,o,u)},estimComps:fs,estimPicks:as,estimKeys:ss,readStrategies:Qu,genTid:es,genSid:rs,genStrategyFileName:us,calcLevelNumTrade:is,calcFitness:os,cont:Ku}});
19
+ //# sourceMappingURL=w-trade-solve.umd.js.map