@cortex-js/compute-engine 0.30.1 → 0.30.2

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 (143) hide show
  1. package/dist/compute-engine.esm.js +3 -3
  2. package/dist/compute-engine.min.esm.js +2 -2
  3. package/dist/compute-engine.min.umd.js +2 -2
  4. package/dist/compute-engine.umd.js +3 -3
  5. package/dist/math-json.esm.js +2 -2
  6. package/dist/math-json.min.esm.js +2 -2
  7. package/dist/math-json.min.umd.js +2 -2
  8. package/dist/math-json.umd.js +2 -2
  9. package/dist/types/common/ansi-codes.d.ts +1 -1
  10. package/dist/types/common/configuration-change.d.ts +1 -1
  11. package/dist/types/common/fuzzy-string-match.d.ts +1 -1
  12. package/dist/types/common/grapheme-splitter.d.ts +1 -1
  13. package/dist/types/common/interruptible.d.ts +1 -1
  14. package/dist/types/common/one-of.d.ts +1 -1
  15. package/dist/types/common/signals.d.ts +1 -1
  16. package/dist/types/common/type/boxed-type.d.ts +1 -1
  17. package/dist/types/common/type/parse.d.ts +1 -1
  18. package/dist/types/common/type/primitive.d.ts +1 -1
  19. package/dist/types/common/type/serialize.d.ts +1 -1
  20. package/dist/types/common/type/subtype.d.ts +1 -1
  21. package/dist/types/common/type/types.d.ts +1 -1
  22. package/dist/types/common/type/utils.d.ts +1 -1
  23. package/dist/types/common/utils.d.ts +1 -1
  24. package/dist/types/compute-engine/assume.d.ts +1 -1
  25. package/dist/types/compute-engine/boxed-expression/abstract-boxed-expression.d.ts +1 -1
  26. package/dist/types/compute-engine/boxed-expression/apply.d.ts +1 -1
  27. package/dist/types/compute-engine/boxed-expression/arithmetic-add.d.ts +1 -1
  28. package/dist/types/compute-engine/boxed-expression/arithmetic-mul-div.d.ts +1 -1
  29. package/dist/types/compute-engine/boxed-expression/arithmetic-power.d.ts +1 -1
  30. package/dist/types/compute-engine/boxed-expression/ascii-math.d.ts +1 -1
  31. package/dist/types/compute-engine/boxed-expression/box.d.ts +1 -1
  32. package/dist/types/compute-engine/boxed-expression/boxed-dictionary.d.ts +1 -1
  33. package/dist/types/compute-engine/boxed-expression/boxed-function.d.ts +1 -1
  34. package/dist/types/compute-engine/boxed-expression/boxed-number.d.ts +1 -1
  35. package/dist/types/compute-engine/boxed-expression/boxed-operator-definition.d.ts +1 -1
  36. package/dist/types/compute-engine/boxed-expression/boxed-patterns.d.ts +1 -1
  37. package/dist/types/compute-engine/boxed-expression/boxed-string.d.ts +1 -1
  38. package/dist/types/compute-engine/boxed-expression/boxed-symbol.d.ts +1 -1
  39. package/dist/types/compute-engine/boxed-expression/boxed-tensor.d.ts +1 -1
  40. package/dist/types/compute-engine/boxed-expression/boxed-value-definition.d.ts +1 -1
  41. package/dist/types/compute-engine/boxed-expression/cache.d.ts +1 -1
  42. package/dist/types/compute-engine/boxed-expression/canonical-utils.d.ts +1 -1
  43. package/dist/types/compute-engine/boxed-expression/canonical.d.ts +1 -1
  44. package/dist/types/compute-engine/boxed-expression/compare.d.ts +1 -1
  45. package/dist/types/compute-engine/boxed-expression/expand.d.ts +1 -1
  46. package/dist/types/compute-engine/boxed-expression/expression-map.d.ts +1 -1
  47. package/dist/types/compute-engine/boxed-expression/factor.d.ts +1 -1
  48. package/dist/types/compute-engine/boxed-expression/flatten.d.ts +1 -1
  49. package/dist/types/compute-engine/boxed-expression/hold.d.ts +1 -1
  50. package/dist/types/compute-engine/boxed-expression/match.d.ts +1 -1
  51. package/dist/types/compute-engine/boxed-expression/negate.d.ts +1 -1
  52. package/dist/types/compute-engine/boxed-expression/numerics.d.ts +1 -1
  53. package/dist/types/compute-engine/boxed-expression/order.d.ts +1 -1
  54. package/dist/types/compute-engine/boxed-expression/polynomials.d.ts +1 -1
  55. package/dist/types/compute-engine/boxed-expression/product.d.ts +1 -1
  56. package/dist/types/compute-engine/boxed-expression/rules.d.ts +1 -1
  57. package/dist/types/compute-engine/boxed-expression/serialize.d.ts +1 -1
  58. package/dist/types/compute-engine/boxed-expression/sgn.d.ts +1 -1
  59. package/dist/types/compute-engine/boxed-expression/simplify.d.ts +1 -1
  60. package/dist/types/compute-engine/boxed-expression/solve.d.ts +1 -1
  61. package/dist/types/compute-engine/boxed-expression/terms.d.ts +1 -1
  62. package/dist/types/compute-engine/boxed-expression/trigonometry.d.ts +1 -1
  63. package/dist/types/compute-engine/boxed-expression/utils.d.ts +1 -1
  64. package/dist/types/compute-engine/boxed-expression/validate.d.ts +1 -1
  65. package/dist/types/compute-engine/collection-utils.d.ts +1 -1
  66. package/dist/types/compute-engine/compile.d.ts +1 -1
  67. package/dist/types/compute-engine/cost-function.d.ts +1 -1
  68. package/dist/types/compute-engine/function-utils.d.ts +1 -1
  69. package/dist/types/compute-engine/global-types.d.ts +1 -1
  70. package/dist/types/compute-engine/index.d.ts +1 -1
  71. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-algebra.d.ts +1 -1
  72. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-arithmetic.d.ts +1 -1
  73. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-calculus.d.ts +1 -1
  74. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-complex.d.ts +1 -1
  75. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-core.d.ts +1 -1
  76. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-linear-algebra.d.ts +1 -1
  77. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-logic.d.ts +1 -1
  78. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-other.d.ts +1 -1
  79. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-relational-operators.d.ts +1 -1
  80. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-sets.d.ts +1 -1
  81. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-statistics.d.ts +1 -1
  82. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-symbols.d.ts +1 -1
  83. package/dist/types/compute-engine/latex-syntax/dictionary/definitions-trigonometry.d.ts +1 -1
  84. package/dist/types/compute-engine/latex-syntax/dictionary/definitions.d.ts +1 -1
  85. package/dist/types/compute-engine/latex-syntax/parse-symbol.d.ts +1 -1
  86. package/dist/types/compute-engine/latex-syntax/parse.d.ts +1 -1
  87. package/dist/types/compute-engine/latex-syntax/serialize-number.d.ts +1 -1
  88. package/dist/types/compute-engine/latex-syntax/serializer-style.d.ts +1 -1
  89. package/dist/types/compute-engine/latex-syntax/serializer.d.ts +1 -1
  90. package/dist/types/compute-engine/latex-syntax/tokenizer.d.ts +1 -1
  91. package/dist/types/compute-engine/latex-syntax/types.d.ts +1 -1
  92. package/dist/types/compute-engine/latex-syntax/utils.d.ts +1 -1
  93. package/dist/types/compute-engine/library/arithmetic.d.ts +1 -1
  94. package/dist/types/compute-engine/library/calculus.d.ts +1 -1
  95. package/dist/types/compute-engine/library/collections.d.ts +1 -1
  96. package/dist/types/compute-engine/library/combinatorics.d.ts +1 -1
  97. package/dist/types/compute-engine/library/complex.d.ts +1 -1
  98. package/dist/types/compute-engine/library/control-structures.d.ts +1 -1
  99. package/dist/types/compute-engine/library/core.d.ts +1 -1
  100. package/dist/types/compute-engine/library/invisible-operator.d.ts +1 -1
  101. package/dist/types/compute-engine/library/library.d.ts +1 -1
  102. package/dist/types/compute-engine/library/linear-algebra.d.ts +1 -1
  103. package/dist/types/compute-engine/library/logic.d.ts +1 -1
  104. package/dist/types/compute-engine/library/number-theory.d.ts +1 -1
  105. package/dist/types/compute-engine/library/polynomials.d.ts +1 -1
  106. package/dist/types/compute-engine/library/random-expression.d.ts +1 -1
  107. package/dist/types/compute-engine/library/relational-operator.d.ts +1 -1
  108. package/dist/types/compute-engine/library/sets.d.ts +1 -1
  109. package/dist/types/compute-engine/library/statistics.d.ts +1 -1
  110. package/dist/types/compute-engine/library/trigonometry.d.ts +1 -1
  111. package/dist/types/compute-engine/library/utils.d.ts +1 -1
  112. package/dist/types/compute-engine/numeric-value/big-numeric-value.d.ts +1 -1
  113. package/dist/types/compute-engine/numeric-value/exact-numeric-value.d.ts +1 -1
  114. package/dist/types/compute-engine/numeric-value/machine-numeric-value.d.ts +1 -1
  115. package/dist/types/compute-engine/numeric-value/types.d.ts +1 -1
  116. package/dist/types/compute-engine/numerics/bigint.d.ts +1 -1
  117. package/dist/types/compute-engine/numerics/expression.d.ts +1 -1
  118. package/dist/types/compute-engine/numerics/interval.d.ts +1 -1
  119. package/dist/types/compute-engine/numerics/monte-carlo.d.ts +1 -1
  120. package/dist/types/compute-engine/numerics/numeric-bigint.d.ts +1 -1
  121. package/dist/types/compute-engine/numerics/numeric-bignum.d.ts +1 -1
  122. package/dist/types/compute-engine/numerics/numeric-complex.d.ts +1 -1
  123. package/dist/types/compute-engine/numerics/numeric.d.ts +1 -1
  124. package/dist/types/compute-engine/numerics/primes.d.ts +1 -1
  125. package/dist/types/compute-engine/numerics/rationals.d.ts +1 -1
  126. package/dist/types/compute-engine/numerics/richardson.d.ts +1 -1
  127. package/dist/types/compute-engine/numerics/special-functions.d.ts +1 -1
  128. package/dist/types/compute-engine/numerics/statistics.d.ts +1 -1
  129. package/dist/types/compute-engine/numerics/strings.d.ts +1 -1
  130. package/dist/types/compute-engine/numerics/types.d.ts +1 -1
  131. package/dist/types/compute-engine/symbolic/antiderivative.d.ts +1 -1
  132. package/dist/types/compute-engine/symbolic/derivative.d.ts +1 -1
  133. package/dist/types/compute-engine/symbolic/distribute.d.ts +1 -1
  134. package/dist/types/compute-engine/symbolic/simplify-rules.d.ts +1 -1
  135. package/dist/types/compute-engine/tensor/tensor-fields.d.ts +1 -1
  136. package/dist/types/compute-engine/tensor/tensors.d.ts +1 -1
  137. package/dist/types/compute-engine/types.d.ts +1 -1
  138. package/dist/types/compute-engine.d.ts +1 -1
  139. package/dist/types/math-json/symbols.d.ts +1 -1
  140. package/dist/types/math-json/types.d.ts +1 -1
  141. package/dist/types/math-json/utils.d.ts +1 -1
  142. package/dist/types/math-json.d.ts +2 -2
  143. package/package.json +2 -1
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.30.1 */
1
+ /** Compute Engine 0.30.2 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngine=(()=>{var Lo=Object.defineProperty;var kf=Object.getOwnPropertyDescriptor;var Cf=Object.getOwnPropertyNames;var Af=Object.prototype.hasOwnProperty;var Df=(n,e)=>{for(var t in e)Lo(n,t,{get:e[t],enumerable:!0})},Mf=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Cf(e))!Af.call(n,r)&&r!==t&&Lo(n,r,{get:()=>e[r],enumerable:!(i=kf(e,r))||i.enumerable});return n};var Rf=n=>Mf(Lo({},"__esModule",{value:!0}),n);var wg={};Df(wg,{BoxedType:()=>S,ComputeEngine:()=>Ii,NumericValue:()=>j,version:()=>Ig});var Me=Math.cosh||function(n){return Math.abs(n)<1e-9?1-n:(Math.exp(n)+Math.exp(-n))*.5},en=Math.sinh||function(n){return Math.abs(n)<1e-9?n:(Math.exp(n)-Math.exp(-n))*.5},Pf=function(n){var e=Math.PI/4;if(-e>n||n>e)return Math.cos(n)-1;var t=n*n;return t*(t*(t*(t*(t*(t*(t*(t/20922789888e3-1/87178291200)+1/479001600)-1/3628800)+1/40320)-1/720)+1/24)-1/2)},Lf=function(n,e){var t=Math.abs(n),i=Math.abs(e);return t<3e3&&i<3e3?Math.sqrt(t*t+i*i):(t<i?(t=i,i=n/e):i=e/n,t*Math.sqrt(1+i*i))},Ut=function(){throw SyntaxError("Invalid Param")};function Oo(n,e){var t=Math.abs(n),i=Math.abs(e);return n===0?Math.log(i):e===0?Math.log(t):t<3e3&&i<3e3?Math.log(n*n+e*e)*.5:(n=n/2,e=e/2,.5*Math.log(n*n+e*e)+Math.LN2)}var Of=function(n,e){var t={re:0,im:0};if(n==null)t.re=t.im=0;else if(e!==void 0)t.re=n,t.im=e;else switch(typeof n){case"object":if("im"in n&&"re"in n)t.re=n.re,t.im=n.im;else if("abs"in n&&"arg"in n){if(!Number.isFinite(n.abs)&&Number.isFinite(n.arg))return q.INFINITY;t.re=n.abs*Math.cos(n.arg),t.im=n.abs*Math.sin(n.arg)}else if("r"in n&&"phi"in n){if(!Number.isFinite(n.r)&&Number.isFinite(n.phi))return q.INFINITY;t.re=n.r*Math.cos(n.phi),t.im=n.r*Math.sin(n.phi)}else n.length===2?(t.re=n[0],t.im=n[1]):Ut();break;case"string":t.im=t.re=0;var i=n.match(/\d+\.?\d*e[+-]?\d+|\d+\.?\d*|\.\d+|./g),r=1,o=0;i===null&&Ut();for(var s=0;s<i.length;s++){var a=i[s];a===" "||a===" "||a===`
4
4
  `||(a==="+"?r++:a==="-"?o++:a==="i"||a==="I"?(r+o===0&&Ut(),i[s+1]!==" "&&!isNaN(Number(i[s+1]))?(t.im+=parseFloat((o%2?"-":"")+i[s+1]),s++):t.im+=parseFloat((o%2?"-":"")+"1"),r=o=0):((r+o===0||isNaN(Number(a)))&&Ut(),i[s+1]==="i"||i[s+1]==="I"?(t.im+=parseFloat((o%2?"-":"")+a),s++):t.re+=parseFloat((o%2?"-":"")+a),r=o=0))}r+o>0&&Ut();break;case"number":t.im=0,t.re=n;break;default:Ut()}return isNaN(t.re)||isNaN(t.im),t},q=class n{constructor(e,t){this.re=0,this.im=0;var i=Of(e,t);this.re=i.re,this.im=i.im}sign(){var e=this.abs();return new n(this.re/e,this.im/e)}add(e,t){var i=new n(e,t);return this.isInfinite()&&i.isInfinite()?n.NAN:this.isInfinite()||i.isInfinite()?n.INFINITY:new n(this.re+i.re,this.im+i.im)}sub(e,t){var i=new n(e,t);return this.isInfinite()&&i.isInfinite()?n.NAN:this.isInfinite()||i.isInfinite()?n.INFINITY:new n(this.re-i.re,this.im-i.im)}mul(e,t){var i=new n(e,t);return this.isInfinite()&&i.isZero()||this.isZero()&&i.isInfinite()?n.NAN:this.isInfinite()||i.isInfinite()?n.INFINITY:i.im===0&&this.im===0?new n(this.re*i.re,0):new n(this.re*i.re-this.im*i.im,this.re*i.im+this.im*i.re)}div(e,t){var i=new n(e,t);if(this.isZero()&&i.isZero()||this.isInfinite()&&i.isInfinite())return n.NAN;if(this.isInfinite()||i.isZero())return n.INFINITY;if(this.isZero()||i.isInfinite())return n.ZERO;e=this.re,t=this.im;var r=i.re,o=i.im,s,a;return o===0?new n(e/r,t/r):Math.abs(r)<Math.abs(o)?(a=r/o,s=r*a+o,new n((e*a+t)/s,(t*a-e)/s)):(a=o/r,s=o*a+r,new n((e+t*a)/s,(t-e*a)/s))}pow(e,t){var i=new n(e,t);if(e=this.re,t=this.im,i.isZero())return n.ONE;if(i.im===0){if(t===0&&e>0)return new n(Math.pow(e,i.re),0);if(e===0)switch((i.re%4+4)%4){case 0:return new n(Math.pow(t,i.re),0);case 1:return new n(0,Math.pow(t,i.re));case 2:return new n(-Math.pow(t,i.re),0);case 3:return new n(0,-Math.pow(t,i.re))}}if(e===0&&t===0&&i.re>0&&i.im>=0)return n.ZERO;var r=Math.atan2(t,e),o=Oo(e,t);return e=Math.exp(i.re*o-i.im*r),t=i.im*o+i.re*r,new n(e*Math.cos(t),e*Math.sin(t))}sqrt(){var e=this.re,t=this.im,i=this.abs(),r,o;if(e>=0){if(t===0)return new n(Math.sqrt(e),0);r=.5*Math.sqrt(2*(i+e))}else r=Math.abs(t)/Math.sqrt(2*(i-e));return e<=0?o=.5*Math.sqrt(2*(i-e)):o=Math.abs(t)/Math.sqrt(2*(i+e)),new n(r,t<0?-o:o)}exp(){var e=Math.exp(this.re);return this.im,new n(e*Math.cos(this.im),e*Math.sin(this.im))}expm1(){var e=this.re,t=this.im;return new n(Math.expm1(e)*Math.cos(t)+Pf(t),Math.exp(e)*Math.sin(t))}log(){var e=this.re,t=this.im;return t===0&&e>0,new n(Oo(e,t),Math.atan2(t,e))}abs(){return Lf(this.re,this.im)}arg(){return Math.atan2(this.im,this.re)}sin(){var e=this.re,t=this.im;return new n(Math.sin(e)*Me(t),Math.cos(e)*en(t))}cos(){var e=this.re,t=this.im;return new n(Math.cos(e)*Me(t),-Math.sin(e)*en(t))}tan(){var e=2*this.re,t=2*this.im,i=Math.cos(e)+Me(t);return new n(Math.sin(e)/i,en(t)/i)}cot(){var e=2*this.re,t=2*this.im,i=Math.cos(e)-Me(t);return new n(-Math.sin(e)/i,en(t)/i)}sec(){var e=this.re,t=this.im,i=.5*Me(2*t)+.5*Math.cos(2*e);return new n(Math.cos(e)*Me(t)/i,Math.sin(e)*en(t)/i)}csc(){var e=this.re,t=this.im,i=.5*Me(2*t)-.5*Math.cos(2*e);return new n(Math.sin(e)*Me(t)/i,-Math.cos(e)*en(t)/i)}asin(){var e=this.re,t=this.im,i=new n(t*t-e*e+1,-2*e*t).sqrt(),r=new n(i.re-t,i.im+e).log();return new n(r.im,-r.re)}acos(){var e=this.re,t=this.im,i=new n(t*t-e*e+1,-2*e*t).sqrt(),r=new n(i.re-t,i.im+e).log();return new n(Math.PI/2-r.im,r.re)}atan(){var e=this.re,t=this.im;if(e===0){if(t===1)return new n(0,1/0);if(t===-1)return new n(0,-1/0)}var i=e*e+(1-t)*(1-t),r=new n((1-t*t-e*e)/i,-2*e/i).log();return new n(-.5*r.im,.5*r.re)}acot(){var e=this.re,t=this.im;if(t===0)return new n(Math.atan2(1,e),0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).atan():new n(e!==0?e/0:0,t!==0?-t/0:0).atan()}asec(){var e=this.re,t=this.im;if(e===0&&t===0)return new n(0,1/0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).acos():new n(e!==0?e/0:0,t!==0?-t/0:0).acos()}acsc(){var e=this.re,t=this.im;if(e===0&&t===0)return new n(Math.PI/2,1/0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).asin():new n(e!==0?e/0:0,t!==0?-t/0:0).asin()}sinh(){var e=this.re,t=this.im;return new n(en(e)*Math.cos(t),Me(e)*Math.sin(t))}cosh(){var e=this.re,t=this.im;return new n(Me(e)*Math.cos(t),en(e)*Math.sin(t))}tanh(){var e=2*this.re,t=2*this.im,i=Me(e)+Math.cos(t);return new n(en(e)/i,Math.sin(t)/i)}coth(){var e=2*this.re,t=2*this.im,i=Me(e)-Math.cos(t);return new n(en(e)/i,-Math.sin(t)/i)}csch(){var e=this.re,t=this.im,i=Math.cos(2*t)-Me(2*e);return new n(-2*en(e)*Math.cos(t)/i,2*Me(e)*Math.sin(t)/i)}sech(){var e=this.re,t=this.im,i=Math.cos(2*t)+Me(2*e);return new n(2*Me(e)*Math.cos(t)/i,-2*en(e)*Math.sin(t)/i)}asinh(){var e=this.im;this.im=-this.re,this.re=e;var t=this.asin();return this.re=-this.im,this.im=e,e=t.re,t.re=-t.im,t.im=e,t}acosh(){var e=this.acos();if(e.im<=0){var t=e.re;e.re=-e.im,e.im=t}else{var t=e.im;e.im=-e.re,e.re=t}return e}atanh(){var e=this.re,t=this.im,i=e>1&&t===0,r=1-e,o=1+e,s=r*r+t*t,a=s!==0?new n((o*r-t*t)/s,(t*r+o*t)/s):new n(e!==-1?e/0:0,t!==0?t/0:0),u=a.re;return a.re=Oo(a.re,a.im)/2,a.im=Math.atan2(a.im,u)/2,i&&(a.im=-a.im),a}acoth(){var e=this.re,t=this.im;if(e===0&&t===0)return new n(0,Math.PI/2);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).atanh():new n(e!==0?e/0:0,t!==0?-t/0:0).atanh()}acsch(){var e=this.re,t=this.im;if(t===0)return new n(e!==0?Math.log(e+Math.sqrt(e*e+1)):1/0,0);var i=e*e+t*t;return i!==0?new n(e/i,-t/i).asinh():new n(e!==0?e/0:0,t!==0?-t/0:0).asinh()}asech(){var e=this.re,t=this.im;if(this.isZero())return n.INFINITY;var i=e*e+t*t;return i!==0?new n(e/i,-t/i).acosh():new n(e!==0?e/0:0,t!==0?-t/0:0).acosh()}inverse(){if(this.isZero())return n.INFINITY;if(this.isInfinite())return n.ZERO;var e=this.re,t=this.im,i=e*e+t*t;return new n(e/i,-t/i)}conjugate(){return new n(this.re,-this.im)}neg(){return new n(-this.re,-this.im)}ceil(e){return e=Math.pow(10,e||0),new n(Math.ceil(this.re*e)/e,Math.ceil(this.im*e)/e)}floor(e){return e=Math.pow(10,e||0),new n(Math.floor(this.re*e)/e,Math.floor(this.im*e)/e)}round(e){return e=Math.pow(10,e||0),new n(Math.round(this.re*e)/e,Math.round(this.im*e)/e)}equals(e,t){var i=new n(e,t);return Math.abs(i.re-this.re)<=n.EPSILON&&Math.abs(i.im-this.im)<=n.EPSILON}clone(){return new n(this.re,this.im)}toString(){var e=this.re,t=this.im,i="";return this.isNaN()?"NaN":this.isInfinite()?"Infinity":(Math.abs(e)<n.EPSILON&&(e=0),Math.abs(t)<n.EPSILON&&(t=0),t===0?i+e:(e!==0?(i+=e,i+=" ",t<0?(t=-t,i+="-"):i+="+",i+=" "):t<0&&(t=-t,i+="-"),t!==1&&(i+=t),i+"i"))}toVector(){return[this.re,this.im]}valueOf(){return this.im===0?this.re:null}isNaN(){return isNaN(this.re)||isNaN(this.im)}isZero(){return this.im===0&&this.re===0}isFinite(){return isFinite(this.re)&&isFinite(this.im)}isInfinite(){return!(this.isNaN()||this.isFinite())}};q.ZERO=new q(0,0);q.ONE=new q(1,0);q.I=new q(0,1);q.PI=new q(Math.PI,0);q.E=new q(Math.E,0);q.INFINITY=new q(1/0,1/0);q.NAN=new q(NaN,NaN);q.EPSILON=1e-15;var jt=9e15,ot=1e9,$o="0123456789abcdef",Ar="2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058",Dr="3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789",Fo={precision:20,rounding:4,modulo:1,toExpNeg:-7,toExpPos:21,minE:-jt,maxE:jt,crypto:!1},Oa,Vn,D=!0,Rr="[DecimalError] ",rt=Rr+"Invalid argument: ",$a=Rr+"Precision limit exceeded",Fa=Rr+"crypto unavailable",Va="[object Decimal]",Re=Math.floor,Se=Math.pow,$f=/^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,Ff=/^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,Vf=/^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,qa=/^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,xn=1e7,C=7,qf=9007199254740991,zf=Ar.length-1,Vo=Dr.length-1,y={toStringTag:Va};y.absoluteValue=y.abs=function(){var n=new this.constructor(this);return n.s<0&&(n.s=1),I(n)};y.ceil=function(){return I(new this.constructor(this),this.e+1,2)};y.clampedTo=y.clamp=function(n,e){var t,i=this,r=i.constructor;if(n=new r(n),e=new r(e),!n.s||!e.s)return new r(NaN);if(n.gt(e))throw Error(rt+e);return t=i.cmp(n),t<0?n:i.cmp(e)>0?e:new r(i)};y.comparedTo=y.cmp=function(n){var e,t,i,r,o=this,s=o.d,a=(n=new o.constructor(n)).d,u=o.s,l=n.s;if(!s||!a)return!u||!l?NaN:u!==l?u:s===a?0:!s^u<0?1:-1;if(!s[0]||!a[0])return s[0]?u:a[0]?-l:0;if(u!==l)return u;if(o.e!==n.e)return o.e>n.e^u<0?1:-1;for(i=s.length,r=a.length,e=0,t=i<r?i:r;e<t;++e)if(s[e]!==a[e])return s[e]>a[e]^u<0?1:-1;return i===r?0:i>r^u<0?1:-1};y.cosine=y.cos=function(){var n,e,t=this,i=t.constructor;return t.d?t.d[0]?(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+C,i.rounding=1,t=Gf(i,Za(i,t)),i.precision=n,i.rounding=e,I(Vn==2||Vn==3?t.neg():t,n,e,!0)):new i(1):new i(NaN)};y.cubeRoot=y.cbrt=function(){var n,e,t,i,r,o,s,a,u,l,c=this,f=c.constructor;if(!c.isFinite()||c.isZero())return new f(c);for(D=!1,o=c.s*Se(c.s*c,1/3),!o||Math.abs(o)==1/0?(t=Ce(c.d),n=c.e,(o=(n-t.length+1)%3)&&(t+=o==1||o==-2?"0":"00"),o=Se(t,1/3),n=Re((n+1)/3)-(n%3==(n<0?-1:2)),o==1/0?t="5e"+n:(t=o.toExponential(),t=t.slice(0,t.indexOf("e")+1)+n),i=new f(t),i.s=c.s):i=new f(o.toString()),s=(n=f.precision)+3;;)if(a=i,u=a.times(a).times(a),l=u.plus(c),i=X(l.plus(c).times(a),l.plus(u),s+2,1),Ce(a.d).slice(0,s)===(t=Ce(i.d)).slice(0,s))if(t=t.slice(s-3,s+1),t=="9999"||!r&&t=="4999"){if(!r&&(I(a,n+1,0),a.times(a).times(a).eq(c))){i=a;break}s+=4,r=1}else{(!+t||!+t.slice(1)&&t.charAt(0)=="5")&&(I(i,n+1,1),e=!i.times(i).times(i).eq(c));break}return D=!0,I(i,n,f.rounding,e)};y.decimalPlaces=y.dp=function(){var n,e=this.d,t=NaN;if(e){if(n=e.length-1,t=(n-Re(this.e/C))*C,n=e[n],n)for(;n%10==0;n/=10)t--;t<0&&(t=0)}return t};y.dividedBy=y.div=function(n){return X(this,new this.constructor(n))};y.dividedToIntegerBy=y.divToInt=function(n){var e=this,t=e.constructor;return I(X(e,new t(n),0,1,1),t.precision,t.rounding)};y.equals=y.eq=function(n){return this.cmp(n)===0};y.floor=function(){return I(new this.constructor(this),this.e+1,3)};y.greaterThan=y.gt=function(n){return this.cmp(n)>0};y.greaterThanOrEqualTo=y.gte=function(n){var e=this.cmp(n);return e==1||e===0};y.hyperbolicCosine=y.cosh=function(){var n,e,t,i,r,o=this,s=o.constructor,a=new s(1);if(!o.isFinite())return new s(o.s?1/0:NaN);if(o.isZero())return a;t=s.precision,i=s.rounding,s.precision=t+Math.max(o.e,o.sd())+4,s.rounding=1,r=o.d.length,r<32?(n=Math.ceil(r/3),e=(1/Lr(4,n)).toString()):(n=16,e="2.3283064365386962890625e-10"),o=Zt(s,1,o.times(e),new s(1),!0);for(var u,l=n,c=new s(8);l--;)u=o.times(o),o=a.minus(u.times(c.minus(u.times(c))));return I(o,s.precision=t,s.rounding=i,!0)};y.hyperbolicSine=y.sinh=function(){var n,e,t,i,r=this,o=r.constructor;if(!r.isFinite()||r.isZero())return new o(r);if(e=o.precision,t=o.rounding,o.precision=e+Math.max(r.e,r.sd())+4,o.rounding=1,i=r.d.length,i<3)r=Zt(o,2,r,r,!0);else{n=1.4*Math.sqrt(i),n=n>16?16:n|0,r=r.times(1/Lr(5,n)),r=Zt(o,2,r,r,!0);for(var s,a=new o(5),u=new o(16),l=new o(20);n--;)s=r.times(r),r=r.times(a.plus(s.times(u.times(s).plus(l))))}return o.precision=e,o.rounding=t,I(r,e,t,!0)};y.hyperbolicTangent=y.tanh=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+7,i.rounding=1,X(t.sinh(),t.cosh(),i.precision=n,i.rounding=e)):new i(t.s)};y.inverseCosine=y.acos=function(){var n=this,e=n.constructor,t=n.abs().cmp(1),i=e.precision,r=e.rounding;return t!==-1?t===0?n.isNeg()?In(e,i,r):new e(0):new e(NaN):n.isZero()?In(e,i+4,r).times(.5):(e.precision=i+6,e.rounding=1,n=new e(1).minus(n).div(n.plus(1)).sqrt().atan(),e.precision=i,e.rounding=r,n.times(2))};y.inverseHyperbolicCosine=y.acosh=function(){var n,e,t=this,i=t.constructor;return t.lte(1)?new i(t.eq(1)?0:NaN):t.isFinite()?(n=i.precision,e=i.rounding,i.precision=n+Math.max(Math.abs(t.e),t.sd())+4,i.rounding=1,D=!1,t=t.times(t).minus(1).sqrt().plus(t),D=!0,i.precision=n,i.rounding=e,t.ln()):new i(t)};y.inverseHyperbolicSine=y.asinh=function(){var n,e,t=this,i=t.constructor;return!t.isFinite()||t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+2*Math.max(Math.abs(t.e),t.sd())+6,i.rounding=1,D=!1,t=t.times(t).plus(1).sqrt().plus(t),D=!0,i.precision=n,i.rounding=e,t.ln())};y.inverseHyperbolicTangent=y.atanh=function(){var n,e,t,i,r=this,o=r.constructor;return r.isFinite()?r.e>=0?new o(r.abs().eq(1)?r.s/0:r.isZero()?r:NaN):(n=o.precision,e=o.rounding,i=r.sd(),Math.max(i,n)<2*-r.e-1?I(new o(r),n,e,!0):(o.precision=t=i-r.e,r=X(r.plus(1),new o(1).minus(r),t+n,1),o.precision=n+4,o.rounding=1,r=r.ln(),o.precision=n,o.rounding=e,r.times(.5))):new o(NaN)};y.inverseSine=y.asin=function(){var n,e,t,i,r=this,o=r.constructor;return r.isZero()?new o(r):(e=r.abs().cmp(1),t=o.precision,i=o.rounding,e!==-1?e===0?(n=In(o,t+4,i).times(.5),n.s=r.s,n):new o(NaN):(o.precision=t+6,o.rounding=1,r=r.div(new o(1).minus(r.times(r)).sqrt().plus(1)).atan(),o.precision=t,o.rounding=i,r.times(2)))};y.inverseTangent=y.atan=function(){var n,e,t,i,r,o,s,a,u,l=this,c=l.constructor,f=c.precision,d=c.rounding;if(l.isFinite()){if(l.isZero())return new c(l);if(l.abs().eq(1)&&f+4<=Vo)return s=In(c,f+4,d).times(.25),s.s=l.s,s}else{if(!l.s)return new c(NaN);if(f+4<=Vo)return s=In(c,f+4,d).times(.5),s.s=l.s,s}for(c.precision=a=f+10,c.rounding=1,t=Math.min(28,a/C+2|0),n=t;n;--n)l=l.div(l.times(l).plus(1).sqrt().plus(1));for(D=!1,e=Math.ceil(a/C),i=1,u=l.times(l),s=new c(l),r=l;n!==-1;)if(r=r.times(u),o=s.minus(r.div(i+=2)),r=r.times(u),s=o.plus(r.div(i+=2)),s.d[e]!==void 0)for(n=e;s.d[n]===o.d[n]&&n--;);return t&&(s=s.times(2<<t-1)),D=!0,I(s,c.precision=f,c.rounding=d,!0)};y.isFinite=function(){return!!this.d};y.isInteger=y.isInt=function(){return!!this.d&&Re(this.e/C)>this.d.length-2};y.isNaN=function(){return!this.s};y.isNegative=y.isNeg=function(){return this.s<0};y.isPositive=y.isPos=function(){return this.s>0};y.isZero=function(){return!!this.d&&this.d[0]===0};y.lessThan=y.lt=function(n){return this.cmp(n)<0};y.lessThanOrEqualTo=y.lte=function(n){return this.cmp(n)<1};y.logarithm=y.log=function(n){var e,t,i,r,o,s,a,u,l=this,c=l.constructor,f=c.precision,d=c.rounding,p=5;if(n==null)n=new c(10),e=!0;else{if(n=new c(n),t=n.d,n.s<0||!t||!t[0]||n.eq(1))return new c(NaN);e=n.eq(10)}if(t=l.d,l.s<0||!t||!t[0]||l.eq(1))return new c(t&&!t[0]?-1/0:l.s!=1?NaN:t?0:1/0);if(e)if(t.length>1)o=!0;else{for(r=t[0];r%10===0;)r/=10;o=r!==1}if(D=!1,a=f+p,s=it(l,a),i=e?Mr(c,a+10):it(n,a),u=X(s,i,a,1),ki(u.d,r=f,d))do if(a+=10,s=it(l,a),i=e?Mr(c,a+10):it(n,a),u=X(s,i,a,1),!o){+Ce(u.d).slice(r+1,r+15)+1==1e14&&(u=I(u,f+1,0));break}while(ki(u.d,r+=10,d));return D=!0,I(u,f,d)};y.minus=y.sub=function(n){var e,t,i,r,o,s,a,u,l,c,f,d,p=this,x=p.constructor;if(n=new x(n),!p.d||!n.d)return!p.s||!n.s?n=new x(NaN):p.d?n.s=-n.s:n=new x(n.d||p.s!==n.s?p:NaN),n;if(p.s!=n.s)return n.s=-n.s,p.plus(n);if(l=p.d,d=n.d,a=x.precision,u=x.rounding,!l[0]||!d[0]){if(d[0])n.s=-n.s;else if(l[0])n=new x(p);else return new x(u===3?-0:0);return D?I(n,a,u):n}if(t=Re(n.e/C),c=Re(p.e/C),l=l.slice(),o=c-t,o){for(f=o<0,f?(e=l,o=-o,s=d.length):(e=d,t=c,s=l.length),i=Math.max(Math.ceil(a/C),s)+2,o>i&&(o=i,e.length=1),e.reverse(),i=o;i--;)e.push(0);e.reverse()}else{for(i=l.length,s=d.length,f=i<s,f&&(s=i),i=0;i<s;i++)if(l[i]!=d[i]){f=l[i]<d[i];break}o=0}for(f&&(e=l,l=d,d=e,n.s=-n.s),s=l.length,i=d.length-s;i>0;--i)l[s++]=0;for(i=d.length;i>o;){if(l[--i]<d[i]){for(r=i;r&&l[--r]===0;)l[r]=xn-1;--l[r],l[i]+=xn}l[i]-=d[i]}for(;l[--s]===0;)l.pop();for(;l[0]===0;l.shift())--t;return l[0]?(n.d=l,n.e=Pr(l,t),D?I(n,a,u):n):new x(u===3?-0:0)};y.modulo=y.mod=function(n){var e,t=this,i=t.constructor;return n=new i(n),!t.d||!n.s||n.d&&!n.d[0]?new i(NaN):!n.d||t.d&&!t.d[0]?I(new i(t),i.precision,i.rounding):(D=!1,i.modulo==9?(e=X(t,n.abs(),0,3,1),e.s*=n.s):e=X(t,n,0,i.modulo,1),e=e.times(n),D=!0,t.minus(e))};y.naturalExponential=y.exp=function(){return qo(this)};y.naturalLogarithm=y.ln=function(){return it(this)};y.negated=y.neg=function(){var n=new this.constructor(this);return n.s=-n.s,I(n)};y.plus=y.add=function(n){var e,t,i,r,o,s,a,u,l,c,f=this,d=f.constructor;if(n=new d(n),!f.d||!n.d)return!f.s||!n.s?n=new d(NaN):f.d||(n=new d(n.d||f.s===n.s?f:NaN)),n;if(f.s!=n.s)return n.s=-n.s,f.minus(n);if(l=f.d,c=n.d,a=d.precision,u=d.rounding,!l[0]||!c[0])return c[0]||(n=new d(f)),D?I(n,a,u):n;if(o=Re(f.e/C),i=Re(n.e/C),l=l.slice(),r=o-i,r){for(r<0?(t=l,r=-r,s=c.length):(t=c,i=o,s=l.length),o=Math.ceil(a/C),s=o>s?o+1:s+1,r>s&&(r=s,t.length=1),t.reverse();r--;)t.push(0);t.reverse()}for(s=l.length,r=c.length,s-r<0&&(r=s,t=c,c=l,l=t),e=0;r;)e=(l[--r]=l[r]+c[r]+e)/xn|0,l[r]%=xn;for(e&&(l.unshift(e),++i),s=l.length;l[--s]==0;)l.pop();return n.d=l,n.e=Pr(l,i),D?I(n,a,u):n};y.precision=y.sd=function(n){var e,t=this;if(n!==void 0&&n!==!!n&&n!==1&&n!==0)throw Error(rt+n);return t.d?(e=za(t.d),n&&t.e+1>e&&(e=t.e+1)):e=NaN,e};y.round=function(){var n=this,e=n.constructor;return I(new e(n),n.e+1,e.rounding)};y.sine=y.sin=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+Math.max(t.e,t.sd())+C,i.rounding=1,t=jf(i,Za(i,t)),i.precision=n,i.rounding=e,I(Vn>2?t.neg():t,n,e,!0)):new i(NaN)};y.squareRoot=y.sqrt=function(){var n,e,t,i,r,o,s=this,a=s.d,u=s.e,l=s.s,c=s.constructor;if(l!==1||!a||!a[0])return new c(!l||l<0&&(!a||a[0])?NaN:a?s:1/0);for(D=!1,l=Math.sqrt(+s),l==0||l==1/0?(e=Ce(a),(e.length+u)%2==0&&(e+="0"),l=Math.sqrt(e),u=Re((u+1)/2)-(u<0||u%2),l==1/0?e="5e"+u:(e=l.toExponential(),e=e.slice(0,e.indexOf("e")+1)+u),i=new c(e)):i=new c(l.toString()),t=(u=c.precision)+3;;)if(o=i,i=o.plus(X(s,o,t+2,1)).times(.5),Ce(o.d).slice(0,t)===(e=Ce(i.d)).slice(0,t))if(e=e.slice(t-3,t+1),e=="9999"||!r&&e=="4999"){if(!r&&(I(o,u+1,0),o.times(o).eq(s))){i=o;break}t+=4,r=1}else{(!+e||!+e.slice(1)&&e.charAt(0)=="5")&&(I(i,u+1,1),n=!i.times(i).eq(s));break}return D=!0,I(i,u,c.rounding,n)};y.tangent=y.tan=function(){var n,e,t=this,i=t.constructor;return t.isFinite()?t.isZero()?new i(t):(n=i.precision,e=i.rounding,i.precision=n+10,i.rounding=1,t=t.sin(),t.s=1,t=X(t,new i(1).minus(t.times(t)).sqrt(),n+10,0),i.precision=n,i.rounding=e,I(Vn==2||Vn==4?t.neg():t,n,e,!0)):new i(NaN)};y.times=y.mul=function(n){var e,t,i,r,o,s,a,u,l,c=this,f=c.constructor,d=c.d,p=(n=new f(n)).d;if(n.s*=c.s,!d||!d[0]||!p||!p[0])return new f(!n.s||d&&!d[0]&&!p||p&&!p[0]&&!d?NaN:!d||!p?n.s/0:n.s*0);for(t=Re(c.e/C)+Re(n.e/C),u=d.length,l=p.length,u<l&&(o=d,d=p,p=o,s=u,u=l,l=s),o=[],s=u+l,i=s;i--;)o.push(0);for(i=l;--i>=0;){for(e=0,r=u+i;r>i;)a=o[r]+p[i]*d[r-i-1]+e,o[r--]=a%xn|0,e=a/xn|0;o[r]=(o[r]+e)%xn|0}for(;!o[--s];)o.pop();return e?++t:o.shift(),n.d=o,n.e=Pr(o,t),D?I(n,f.precision,f.rounding):n};y.toBinary=function(n,e){return zo(this,2,n,e)};y.toDecimalPlaces=y.toDP=function(n,e){var t=this,i=t.constructor;return t=new i(t),n===void 0?t:(ze(n,0,ot),e===void 0?e=i.rounding:ze(e,0,8),I(t,n+t.e+1,e))};y.toExponential=function(n,e){var t,i=this,r=i.constructor;return n===void 0?t=wn(i,!0):(ze(n,0,ot),e===void 0?e=r.rounding:ze(e,0,8),i=I(new r(i),n+1,e),t=wn(i,!0,n+1)),i.isNeg()&&!i.isZero()?"-"+t:t};y.toFixed=function(n,e){var t,i,r=this,o=r.constructor;return n===void 0?t=wn(r):(ze(n,0,ot),e===void 0?e=o.rounding:ze(e,0,8),i=I(new o(r),n+r.e+1,e),t=wn(i,!1,n+i.e+1)),r.isNeg()&&!r.isZero()?"-"+t:t};y.toFraction=function(n){var e,t,i,r,o,s,a,u,l,c,f,d,p=this,x=p.d,g=p.constructor;if(!x)return new g(p);if(l=t=new g(1),i=u=new g(0),e=new g(i),o=e.e=za(x)-p.e-1,s=o%C,e.d[0]=Se(10,s<0?C+s:s),n==null)n=o>0?e:l;else{if(a=new g(n),!a.isInt()||a.lt(l))throw Error(rt+a);n=a.gt(e)?o>0?e:l:a}for(D=!1,a=new g(Ce(x)),c=g.precision,g.precision=o=x.length*C*2;f=X(a,e,0,1,1),r=t.plus(f.times(i)),r.cmp(n)!=1;)t=i,i=r,r=l,l=u.plus(f.times(r)),u=r,r=e,e=a.minus(f.times(r)),a=r;return r=X(n.minus(t),i,0,1,1),u=u.plus(r.times(l)),t=t.plus(r.times(i)),u.s=l.s=p.s,d=X(l,i,o,1).minus(p).abs().cmp(X(u,t,o,1).minus(p).abs())<1?[l,i]:[u,t],g.precision=c,D=!0,d};y.toHexadecimal=y.toHex=function(n,e){return zo(this,16,n,e)};y.toNearest=function(n,e){var t=this,i=t.constructor;if(t=new i(t),n==null){if(!t.d)return t;n=new i(1),e=i.rounding}else{if(n=new i(n),e===void 0?e=i.rounding:ze(e,0,8),!t.d)return n.s?t:n;if(!n.d)return n.s&&(n.s=t.s),n}return n.d[0]?(D=!1,t=X(t,n,0,e,1).times(n),D=!0,I(t)):(n.s=t.s,t=n),t};y.toNumber=function(){return+this};y.toOctal=function(n,e){return zo(this,8,n,e)};y.toPower=y.pow=function(n){var e,t,i,r,o,s,a=this,u=a.constructor,l=+(n=new u(n));if(!a.d||!n.d||!a.d[0]||!n.d[0])return new u(Se(+a,l));if(a=new u(a),a.eq(1))return a;if(i=u.precision,o=u.rounding,n.eq(1))return I(a,i,o);if(e=Re(n.e/C),e>=n.d.length-1&&(t=l<0?-l:l)<=qf)return r=Ga(u,a,t,i),n.s<0?new u(1).div(r):I(r,i,o);if(s=a.s,s<0){if(e<n.d.length-1)return new u(NaN);if((n.d[e]&1)==0&&(s=1),a.e==0&&a.d[0]==1&&a.d.length==1)return a.s=s,a}return t=Se(+a,l),e=t==0||!isFinite(t)?Re(l*(Math.log("0."+Ce(a.d))/Math.LN10+a.e+1)):new u(t+"").e,e>u.maxE+1||e<u.minE-1?new u(e>0?s/0:0):(D=!1,u.rounding=a.s=1,t=Math.min(12,(e+"").length),r=qo(n.times(it(a,i+t)),i),r.d&&(r=I(r,i+5,1),ki(r.d,i,o)&&(e=i+10,r=I(qo(n.times(it(a,e+t)),e),e+5,1),+Ce(r.d).slice(i+1,i+15)+1==1e14&&(r=I(r,i+1,0)))),r.s=s,D=!0,u.rounding=o,I(r,i,o))};y.toPrecision=function(n,e){var t,i=this,r=i.constructor;return n===void 0?t=wn(i,i.e<=r.toExpNeg||i.e>=r.toExpPos):(ze(n,1,ot),e===void 0?e=r.rounding:ze(e,0,8),i=I(new r(i),n,e),t=wn(i,n<=i.e||i.e<=r.toExpNeg,n)),i.isNeg()&&!i.isZero()?"-"+t:t};y.toSignificantDigits=y.toSD=function(n,e){var t=this,i=t.constructor;return n===void 0?(n=i.precision,e=i.rounding):(ze(n,1,ot),e===void 0?e=i.rounding:ze(e,0,8)),I(new i(t),n,e)};y.toString=function(){var n=this,e=n.constructor,t=wn(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()&&!n.isZero()?"-"+t:t};y.truncated=y.trunc=function(){return I(new this.constructor(this),this.e+1,1)};y.valueOf=y.toJSON=function(){var n=this,e=n.constructor,t=wn(n,n.e<=e.toExpNeg||n.e>=e.toExpPos);return n.isNeg()?"-"+t:t};function Ce(n){var e,t,i,r=n.length-1,o="",s=n[0];if(r>0){for(o+=s,e=1;e<r;e++)i=n[e]+"",t=C-i.length,t&&(o+=tt(t)),o+=i;s=n[e],i=s+"",t=C-i.length,t&&(o+=tt(t))}else if(s===0)return"0";for(;s%10===0;)s/=10;return o+s}function ze(n,e,t){if(n!==~~n||n<e||n>t)throw Error(rt+n)}function ki(n,e,t,i){var r,o,s,a;for(o=n[0];o>=10;o/=10)--e;return--e<0?(e+=C,r=0):(r=Math.ceil((e+1)/C),e%=C),o=Se(10,C-e),a=n[r]%o|0,i==null?e<3?(e==0?a=a/100|0:e==1&&(a=a/10|0),s=t<4&&a==99999||t>3&&a==49999||a==5e4||a==0):s=(t<4&&a+1==o||t>3&&a+1==o/2)&&(n[r+1]/o/100|0)==Se(10,e-2)-1||(a==o/2||a==0)&&(n[r+1]/o/100|0)==0:e<4?(e==0?a=a/1e3|0:e==1?a=a/100|0:e==2&&(a=a/10|0),s=(i||t<4)&&a==9999||!i&&t>3&&a==4999):s=((i||t<4)&&a+1==o||!i&&t>3&&a+1==o/2)&&(n[r+1]/o/1e3|0)==Se(10,e-3)-1,s}function kr(n,e,t){for(var i,r=[0],o,s=0,a=n.length;s<a;){for(o=r.length;o--;)r[o]*=e;for(r[0]+=$o.indexOf(n.charAt(s++)),i=0;i<r.length;i++)r[i]>t-1&&(r[i+1]===void 0&&(r[i+1]=0),r[i+1]+=r[i]/t|0,r[i]%=t)}return r.reverse()}function Gf(n,e){var t,i,r;if(e.isZero())return e;i=e.d.length,i<32?(t=Math.ceil(i/3),r=(1/Lr(4,t)).toString()):(t=16,r="2.3283064365386962890625e-10"),n.precision+=t,e=Zt(n,1,e.times(r),new n(1));for(var o=t;o--;){var s=e.times(e);e=s.times(s).minus(s).times(8).plus(1)}return n.precision-=t,e}var X=function(){function n(i,r,o){var s,a=0,u=i.length;for(i=i.slice();u--;)s=i[u]*r+a,i[u]=s%o|0,a=s/o|0;return a&&i.unshift(a),i}function e(i,r,o,s){var a,u;if(o!=s)u=o>s?1:-1;else for(a=u=0;a<o;a++)if(i[a]!=r[a]){u=i[a]>r[a]?1:-1;break}return u}function t(i,r,o,s){for(var a=0;o--;)i[o]-=a,a=i[o]<r[o]?1:0,i[o]=a*s+i[o]-r[o];for(;!i[0]&&i.length>1;)i.shift()}return function(i,r,o,s,a,u){var l,c,f,d,p,x,g,b,_,k,w,z,be,ke,hn,Br,wi,Ro,yn,Ir,wr=i.constructor,Po=i.s==r.s?1:-1,De=i.d,te=r.d;if(!De||!De[0]||!te||!te[0])return new wr(!i.s||!r.s||(De?te&&De[0]==te[0]:!te)?NaN:De&&De[0]==0||!te?Po*0:Po/0);for(u?(p=1,c=i.e-r.e):(u=xn,p=C,c=Re(i.e/p)-Re(r.e/p)),yn=te.length,wi=De.length,_=new wr(Po),k=_.d=[],f=0;te[f]==(De[f]||0);f++);if(te[f]>(De[f]||0)&&c--,o==null?(ke=o=wr.precision,s=wr.rounding):a?ke=o+(i.e-r.e)+1:ke=o,ke<0)k.push(1),x=!0;else{if(ke=ke/p+2|0,f=0,yn==1){for(d=0,te=te[0],ke++;(f<wi||d)&&ke--;f++)hn=d*u+(De[f]||0),k[f]=hn/te|0,d=hn%te|0;x=d||f<wi}else{for(d=u/(te[0]+1)|0,d>1&&(te=n(te,d,u),De=n(De,d,u),yn=te.length,wi=De.length),Br=yn,w=De.slice(0,yn),z=w.length;z<yn;)w[z++]=0;Ir=te.slice(),Ir.unshift(0),Ro=te[0],te[1]>=u/2&&++Ro;do d=0,l=e(te,w,yn,z),l<0?(be=w[0],yn!=z&&(be=be*u+(w[1]||0)),d=be/Ro|0,d>1?(d>=u&&(d=u-1),g=n(te,d,u),b=g.length,z=w.length,l=e(g,w,b,z),l==1&&(d--,t(g,yn<b?Ir:te,b,u))):(d==0&&(l=d=1),g=te.slice()),b=g.length,b<z&&g.unshift(0),t(w,g,z,u),l==-1&&(z=w.length,l=e(te,w,yn,z),l<1&&(d++,t(w,yn<z?Ir:te,z,u))),z=w.length):l===0&&(d++,w=[0]),k[f++]=d,l&&w[0]?w[z++]=De[Br]||0:(w=[De[Br]],z=1);while((Br++<wi||w[0]!==void 0)&&ke--);x=w[0]!==void 0}k[0]||k.shift()}if(p==1)_.e=c,Oa=x;else{for(f=1,d=k[0];d>=10;d/=10)f++;_.e=f+c*p-1,I(_,a?o+_.e+1:o,s,x)}return _}}();function I(n,e,t,i){var r,o,s,a,u,l,c,f,d,p=n.constructor;e:if(e!=null){if(f=n.d,!f)return n;for(r=1,a=f[0];a>=10;a/=10)r++;if(o=e-r,o<0)o+=C,s=e,c=f[d=0],u=c/Se(10,r-s-1)%10|0;else if(d=Math.ceil((o+1)/C),a=f.length,d>=a)if(i){for(;a++<=d;)f.push(0);c=u=0,r=1,o%=C,s=o-C+1}else break e;else{for(c=a=f[d],r=1;a>=10;a/=10)r++;o%=C,s=o-C+r,u=s<0?0:c/Se(10,r-s-1)%10|0}if(i=i||e<0||f[d+1]!==void 0||(s<0?c:c%Se(10,r-s-1)),l=t<4?(u||i)&&(t==0||t==(n.s<0?3:2)):u>5||u==5&&(t==4||i||t==6&&(o>0?s>0?c/Se(10,r-s):0:f[d-1])%10&1||t==(n.s<0?8:7)),e<1||!f[0])return f.length=0,l?(e-=n.e+1,f[0]=Se(10,(C-e%C)%C),n.e=-e||0):f[0]=n.e=0,n;if(o==0?(f.length=d,a=1,d--):(f.length=d+1,a=Se(10,C-o),f[d]=s>0?(c/Se(10,r-s)%Se(10,s)|0)*a:0),l)for(;;)if(d==0){for(o=1,s=f[0];s>=10;s/=10)o++;for(s=f[0]+=a,a=1;s>=10;s/=10)a++;o!=a&&(n.e++,f[0]==xn&&(f[0]=1));break}else{if(f[d]+=a,f[d]!=xn)break;f[d--]=0,a=1}for(o=f.length;f[--o]===0;)f.pop()}return D&&(n.e>p.maxE?(n.d=null,n.e=NaN):n.e<p.minE&&(n.e=0,n.d=[0])),n}function wn(n,e,t){if(!n.isFinite())return ja(n);var i,r=n.e,o=Ce(n.d),s=o.length;return e?(t&&(i=t-s)>0?o=o.charAt(0)+"."+o.slice(1)+tt(i):s>1&&(o=o.charAt(0)+"."+o.slice(1)),o=o+(n.e<0?"e":"e+")+n.e):r<0?(o="0."+tt(-r-1)+o,t&&(i=t-s)>0&&(o+=tt(i))):r>=s?(o+=tt(r+1-s),t&&(i=t-r-1)>0&&(o=o+"."+tt(i))):((i=r+1)<s&&(o=o.slice(0,i)+"."+o.slice(i)),t&&(i=t-s)>0&&(r+1===s&&(o+="."),o+=tt(i))),o}function Pr(n,e){var t=n[0];for(e*=C;t>=10;t/=10)e++;return e}function Mr(n,e,t){if(e>zf)throw D=!0,t&&(n.precision=t),Error($a);return I(new n(Ar),e,1,!0)}function In(n,e,t){if(e>Vo)throw Error($a);return I(new n(Dr),e,t,!0)}function za(n){var e=n.length-1,t=e*C+1;if(e=n[e],e){for(;e%10==0;e/=10)t--;for(e=n[0];e>=10;e/=10)t++}return t}function tt(n){for(var e="";n--;)e+="0";return e}function Ga(n,e,t,i){var r,o=new n(1),s=Math.ceil(i/C+4);for(D=!1;;){if(t%2&&(o=o.times(e),Pa(o.d,s)&&(r=!0)),t=Re(t/2),t===0){t=o.d.length-1,r&&o.d[t]===0&&++o.d[t];break}e=e.times(e),Pa(e.d,s)}return D=!0,o}function Ra(n){return n.d[n.d.length-1]&1}function Ua(n,e,t){for(var i,r,o=new n(e[0]),s=0;++s<e.length;){if(r=new n(e[s]),!r.s){o=r;break}i=o.cmp(r),(i===t||i===0&&o.s===t)&&(o=r)}return o}function qo(n,e){var t,i,r,o,s,a,u,l=0,c=0,f=0,d=n.constructor,p=d.rounding,x=d.precision;if(!n.d||!n.d[0]||n.e>17)return new d(n.d?n.d[0]?n.s<0?0:1/0:1:n.s?n.s<0?0:n:NaN);for(e==null?(D=!1,u=x):u=e,a=new d(.03125);n.e>-2;)n=n.times(a),f+=5;for(i=Math.log(Se(2,f))/Math.LN10*2+5|0,u+=i,t=o=s=new d(1),d.precision=u;;){if(o=I(o.times(n),u,1),t=t.times(++c),a=s.plus(X(o,t,u,1)),Ce(a.d).slice(0,u)===Ce(s.d).slice(0,u)){for(r=f;r--;)s=I(s.times(s),u,1);if(e==null)if(l<3&&ki(s.d,u-i,p,l))d.precision=u+=10,t=o=a=new d(1),c=0,l++;else return I(s,d.precision=x,p,D=!0);else return d.precision=x,s}s=a}}function it(n,e){var t,i,r,o,s,a,u,l,c,f,d,p=1,x=10,g=n,b=g.d,_=g.constructor,k=_.rounding,w=_.precision;if(g.s<0||!b||!b[0]||!g.e&&b[0]==1&&b.length==1)return new _(b&&!b[0]?-1/0:g.s!=1?NaN:b?0:g);if(e==null?(D=!1,c=w):c=e,_.precision=c+=x,t=Ce(b),i=t.charAt(0),Math.abs(o=g.e)<15e14){for(;i<7&&i!=1||i==1&&t.charAt(1)>3;)g=g.times(n),t=Ce(g.d),i=t.charAt(0),p++;o=g.e,i>1?(g=new _("0."+t),o++):g=new _(i+"."+t.slice(1))}else return l=Mr(_,c+2,w).times(o+""),g=it(new _(i+"."+t.slice(1)),c-x).plus(l),_.precision=w,e==null?I(g,w,k,D=!0):g;for(f=g,u=s=g=X(g.minus(1),g.plus(1),c,1),d=I(g.times(g),c,1),r=3;;){if(s=I(s.times(d),c,1),l=u.plus(X(s,new _(r),c,1)),Ce(l.d).slice(0,c)===Ce(u.d).slice(0,c))if(u=u.times(2),o!==0&&(u=u.plus(Mr(_,c+2,w).times(o+""))),u=X(u,new _(p),c,1),e==null)if(ki(u.d,c-x,k,a))_.precision=c+=x,l=s=g=X(f.minus(1),f.plus(1),c,1),d=I(g.times(g),c,1),r=a=1;else return I(u,_.precision=w,k,D=!0);else return _.precision=w,u;u=l,r+=2}}function ja(n){return String(n.s*n.s/0)}function Cr(n,e){var t,i,r;for((t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),i=0;e.charCodeAt(i)===48;i++);for(r=e.length;e.charCodeAt(r-1)===48;--r);if(e=e.slice(i,r),e){if(r-=i,n.e=t=t-i-1,n.d=[],i=(t+1)%C,t<0&&(i+=C),i<r){for(i&&n.d.push(+e.slice(0,i)),r-=C;i<r;)n.d.push(+e.slice(i,i+=C));e=e.slice(i),i=C-e.length}else i-=r;for(;i--;)e+="0";n.d.push(+e),D&&(n.e>n.constructor.maxE?(n.d=null,n.e=NaN):n.e<n.constructor.minE&&(n.e=0,n.d=[0]))}else n.e=0,n.d=[0];return n}function Uf(n,e){var t,i,r,o,s,a,u,l,c;if(e.indexOf("_")>-1){if(e=e.replace(/(\d)_(?=\d)/g,"$1"),qa.test(e))return Cr(n,e)}else if(e==="Infinity"||e==="NaN")return+e||(n.s=NaN),n.e=NaN,n.d=null,n;if(Ff.test(e))t=16,e=e.toLowerCase();else if($f.test(e))t=2;else if(Vf.test(e))t=8;else throw Error(rt+e);for(o=e.search(/p/i),o>0?(u=+e.slice(o+1),e=e.substring(2,o)):e=e.slice(2),o=e.indexOf("."),s=o>=0,i=n.constructor,s&&(e=e.replace(".",""),a=e.length,o=a-o,r=Ga(i,new i(t),o,o*2)),l=kr(e,t,xn),c=l.length-1,o=c;l[o]===0;--o)l.pop();return o<0?new i(n.s*0):(n.e=Pr(l,c),n.d=l,D=!1,s&&(n=X(n,r,a*4)),u&&(n=n.times(Math.abs(u)<54?Se(2,u):M.pow(2,u))),D=!0,n)}function jf(n,e){var t,i=e.d.length;if(i<3)return e.isZero()?e:Zt(n,2,e,e);t=1.4*Math.sqrt(i),t=t>16?16:t|0,e=e.times(1/Lr(5,t)),e=Zt(n,2,e,e);for(var r,o=new n(5),s=new n(16),a=new n(20);t--;)r=e.times(e),e=e.times(o.plus(r.times(s.times(r).minus(a))));return e}function Zt(n,e,t,i,r){var o,s,a,u,l=1,c=n.precision,f=Math.ceil(c/C);for(D=!1,u=t.times(t),a=new n(i);;){if(s=X(a.times(u),new n(e++*e++),c,1),a=r?i.plus(s):i.minus(s),i=X(s.times(u),new n(e++*e++),c,1),s=a.plus(i),s.d[f]!==void 0){for(o=f;s.d[o]===a.d[o]&&o--;);if(o==-1)break}o=a,a=i,i=s,s=o,l++}return D=!0,s.d.length=f+1,s}function Lr(n,e){for(var t=n;--e;)t*=n;return t}function Za(n,e){var t,i=e.s<0,r=In(n,n.precision,1),o=r.times(.5);if(e=e.abs(),e.lte(o))return Vn=i?4:1,e;if(t=e.divToInt(r),t.isZero())Vn=i?3:2;else{if(e=e.minus(t.times(r)),e.lte(o))return Vn=Ra(t)?i?2:3:i?4:1,e;Vn=Ra(t)?i?1:4:i?3:2}return e.minus(r).abs()}function zo(n,e,t,i){var r,o,s,a,u,l,c,f,d,p=n.constructor,x=t!==void 0;if(x?(ze(t,1,ot),i===void 0?i=p.rounding:ze(i,0,8)):(t=p.precision,i=p.rounding),!n.isFinite())c=ja(n);else{for(c=wn(n),s=c.indexOf("."),x?(r=2,e==16?t=t*4-3:e==8&&(t=t*3-2)):r=e,s>=0&&(c=c.replace(".",""),d=new p(1),d.e=c.length-s,d.d=kr(wn(d),10,r),d.e=d.d.length),f=kr(c,10,r),o=u=f.length;f[--u]==0;)f.pop();if(!f[0])c=x?"0p+0":"0";else{if(s<0?o--:(n=new p(n),n.d=f,n.e=o,n=X(n,d,t,i,0,r),f=n.d,o=n.e,l=Oa),s=f[t],a=r/2,l=l||f[t+1]!==void 0,l=i<4?(s!==void 0||l)&&(i===0||i===(n.s<0?3:2)):s>a||s===a&&(i===4||l||i===6&&f[t-1]&1||i===(n.s<0?8:7)),f.length=t,l)for(;++f[--t]>r-1;)f[t]=0,t||(++o,f.unshift(1));for(u=f.length;!f[u-1];--u);for(s=0,c="";s<u;s++)c+=$o.charAt(f[s]);if(x){if(u>1)if(e==16||e==8){for(s=e==16?4:3,--u;u%s;u++)c+="0";for(f=kr(c,r,e),u=f.length;!f[u-1];--u);for(s=1,c="1.";s<u;s++)c+=$o.charAt(f[s])}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>u)for(o-=u;o--;)c+="0";else o<u&&(c=c.slice(0,o)+"."+c.slice(o))}c=(e==16?"0x":e==2?"0b":e==8?"0o":"")+c}return n.s<0?"-"+c:c}function Pa(n,e){if(n.length>e)return n.length=e,!0}function Zf(n){return new this(n).abs()}function Hf(n){return new this(n).acos()}function Wf(n){return new this(n).acosh()}function Jf(n,e){return new this(n).plus(e)}function Yf(n){return new this(n).asin()}function Qf(n){return new this(n).asinh()}function Xf(n){return new this(n).atan()}function Kf(n){return new this(n).atanh()}function ed(n,e){n=new this(n),e=new this(e);var t,i=this.precision,r=this.rounding,o=i+4;return!n.s||!e.s?t=new this(NaN):!n.d&&!e.d?(t=In(this,o,1).times(e.s>0?.25:.75),t.s=n.s):!e.d||n.isZero()?(t=e.s<0?In(this,i,r):new this(0),t.s=n.s):!n.d||e.isZero()?(t=In(this,o,1).times(.5),t.s=n.s):e.s<0?(this.precision=o,this.rounding=1,t=this.atan(X(n,e,o,1)),e=In(this,o,1),this.precision=i,this.rounding=r,t=n.s<0?t.minus(e):t.plus(e)):t=this.atan(X(n,e,o,1)),t}function nd(n){return new this(n).cbrt()}function td(n){return I(n=new this(n),n.e+1,2)}function id(n,e,t){return new this(n).clamp(e,t)}function rd(n){if(!n||typeof n!="object")throw Error(Rr+"Object expected");var e,t,i,r=n.defaults===!0,o=["precision",1,ot,"rounding",0,8,"toExpNeg",-jt,0,"toExpPos",0,jt,"maxE",0,jt,"minE",-jt,0,"modulo",0,9];for(e=0;e<o.length;e+=3)if(t=o[e],r&&(this[t]=Fo[t]),(i=n[t])!==void 0)if(Re(i)===i&&i>=o[e+1]&&i<=o[e+2])this[t]=i;else throw Error(rt+t+": "+i);if(t="crypto",r&&(this[t]=Fo[t]),(i=n[t])!==void 0)if(i===!0||i===!1||i===0||i===1)if(i)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))this[t]=!0;else throw Error(Fa);else this[t]=!1;else throw Error(rt+t+": "+i);return this}function od(n){return new this(n).cos()}function sd(n){return new this(n).cosh()}function Ha(n){var e,t,i;function r(o){var s,a,u,l=this;if(!(l instanceof r))return new r(o);if(l.constructor=r,La(o)){l.s=o.s,D?!o.d||o.e>r.maxE?(l.e=NaN,l.d=null):o.e<r.minE?(l.e=0,l.d=[0]):(l.e=o.e,l.d=o.d.slice()):(l.e=o.e,l.d=o.d?o.d.slice():o.d);return}if(u=typeof o,u==="number"){if(o===0){l.s=1/o<0?-1:1,l.e=0,l.d=[0];return}if(o<0?(o=-o,l.s=-1):l.s=1,o===~~o&&o<1e7){for(s=0,a=o;a>=10;a/=10)s++;D?s>r.maxE?(l.e=NaN,l.d=null):s<r.minE?(l.e=0,l.d=[0]):(l.e=s,l.d=[o]):(l.e=s,l.d=[o]);return}if(o*0!==0){o||(l.s=NaN),l.e=NaN,l.d=null;return}return Cr(l,o.toString())}if(u==="string")return(a=o.charCodeAt(0))===45?(o=o.slice(1),l.s=-1):(a===43&&(o=o.slice(1)),l.s=1),qa.test(o)?Cr(l,o):Uf(l,o);if(u==="bigint")return o<0?(o=-o,l.s=-1):l.s=1,Cr(l,o.toString());throw Error(rt+o)}if(r.prototype=y,r.ROUND_UP=0,r.ROUND_DOWN=1,r.ROUND_CEIL=2,r.ROUND_FLOOR=3,r.ROUND_HALF_UP=4,r.ROUND_HALF_DOWN=5,r.ROUND_HALF_EVEN=6,r.ROUND_HALF_CEIL=7,r.ROUND_HALF_FLOOR=8,r.EUCLID=9,r.config=r.set=rd,r.clone=Ha,r.isDecimal=La,r.abs=Zf,r.acos=Hf,r.acosh=Wf,r.add=Jf,r.asin=Yf,r.asinh=Qf,r.atan=Xf,r.atanh=Kf,r.atan2=ed,r.cbrt=nd,r.ceil=td,r.clamp=id,r.cos=od,r.cosh=sd,r.div=ad,r.exp=ud,r.floor=ld,r.hypot=cd,r.ln=fd,r.log=dd,r.log10=md,r.log2=pd,r.max=gd,r.min=hd,r.mod=yd,r.mul=xd,r.pow=bd,r.random=Ed,r.round=vd,r.sign=Nd,r.sin=_d,r.sinh=Sd,r.sqrt=Td,r.sub=Bd,r.sum=Id,r.tan=wd,r.tanh=kd,r.trunc=Cd,n===void 0&&(n={}),n&&n.defaults!==!0)for(i=["precision","rounding","toExpNeg","toExpPos","maxE","minE","modulo","crypto"],e=0;e<i.length;)n.hasOwnProperty(t=i[e++])||(n[t]=this[t]);return r.config(n),r}function ad(n,e){return new this(n).div(e)}function ud(n){return new this(n).exp()}function ld(n){return I(n=new this(n),n.e+1,3)}function cd(){var n,e,t=new this(0);for(D=!1,n=0;n<arguments.length;)if(e=new this(arguments[n++]),e.d)t.d&&(t=t.plus(e.times(e)));else{if(e.s)return D=!0,new this(1/0);t=e}return D=!0,t.sqrt()}function La(n){return n instanceof M||n&&n.toStringTag===Va||!1}function fd(n){return new this(n).ln()}function dd(n,e){return new this(n).log(e)}function pd(n){return new this(n).log(2)}function md(n){return new this(n).log(10)}function gd(){return Ua(this,arguments,-1)}function hd(){return Ua(this,arguments,1)}function yd(n,e){return new this(n).mod(e)}function xd(n,e){return new this(n).mul(e)}function bd(n,e){return new this(n).pow(e)}function Ed(n){var e,t,i,r,o=0,s=new this(1),a=[];if(n===void 0?n=this.precision:ze(n,1,ot),i=Math.ceil(n/C),this.crypto)if(crypto.getRandomValues)for(e=crypto.getRandomValues(new Uint32Array(i));o<i;)r=e[o],r>=429e7?e[o]=crypto.getRandomValues(new Uint32Array(1))[0]:a[o++]=r%1e7;else if(crypto.randomBytes){for(e=crypto.randomBytes(i*=4);o<i;)r=e[o]+(e[o+1]<<8)+(e[o+2]<<16)+((e[o+3]&127)<<24),r>=214e7?crypto.randomBytes(4).copy(e,o):(a.push(r%1e7),o+=4);o=i/4}else throw Error(Fa);else for(;o<i;)a[o++]=Math.random()*1e7|0;for(i=a[--o],n%=C,i&&n&&(r=Se(10,C-n),a[o]=(i/r|0)*r);a[o]===0;o--)a.pop();if(o<0)t=0,a=[0];else{for(t=-1;a[0]===0;t-=C)a.shift();for(i=1,r=a[0];r>=10;r/=10)i++;i<C&&(t-=C-i)}return s.e=t,s.d=a,s}function vd(n){return I(n=new this(n),n.e+1,this.rounding)}function Nd(n){return n=new this(n),n.d?n.d[0]?n.s:0*n.s:n.s||NaN}function _d(n){return new this(n).sin()}function Sd(n){return new this(n).sinh()}function Td(n){return new this(n).sqrt()}function Bd(n,e){return new this(n).sub(e)}function Id(){var n=0,e=arguments,t=new this(e[n]);for(D=!1;t.s&&++n<e.length;)t=t.plus(e[n]);return D=!0,I(t,this.precision,this.rounding)}function wd(n){return new this(n).tan()}function kd(n){return new this(n).tanh()}function Cd(n){return I(n=new this(n),n.e+1,1)}y[Symbol.for("nodejs.util.inspect.custom")]=y.toString;y[Symbol.toStringTag]="Decimal";var M=y.constructor=Ha(Fo);Ar=new M(Ar);Dr=new M(Dr);var Ci=M;var $e="\x1B[0m";var Ht="\x1B[30;1m";var Wa="\x1B[33m",Go="\x1B[34;1m";var Ai="\x1B[36;1m",Ja="\x1B[101;97m";var Or="\x1B[1m";var Uo;function Xa(n){if(!Uo){let t=`^[${["Zyyy","Zinh","Arab","Armn","Beng","Bopo","Cyrl","Deva","Ethi","Geor","Grek","Gujr","Guru","Hang","Hani","Hebr","Hira","Kana","Knda","Khmr","Laoo","Latn","Mlym","Mymr","Orya","Sinh","Taml","Telu","Thaa","Thai","Tibt"].map(i=>`\\p{Script=${i}}`).join("")}]*$`;Uo=new RegExp(t,"u")}return Uo.test(n)}function Te(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||Wt.test(n)?!0:Xa(n)?/^[\p{XIDS}_]\p{XIDC}*$/u.test(n):!1}var Ad="\\u{FE0F}",Dd="\\u{20E3}",Md="\\u{200D}",Rd="\\p{RI}\\p{RI}",Pd="(?:[\\u{E0020}-\\u{E007E}]+\\u{E007F})",Ya=`(?:\\p{EMod}|${Ad}${Dd}?|${Pd})`,Ld="(?:(?=\\P{XIDC})\\p{Emoji})",Qa=`(?:${Ld}${Ya}*|\\p{Emoji}${Ya}+|${Rd})`,Ka=`(?:${Qa})(${Md}${Qa})*`,Od=new RegExp(`(?:${Ka})+`,"u"),Wt=new RegExp(`^(?:${Ka})+$`,"u");function nn(n){return typeof n!="string"?"not-a-string":n===""?"empty-string":n.normalize()!==n?"expected-nfc":/[\u200E\u200F\u2066-\u2069\u202A-\u202E]/.test(n)?"unexpected-bidi-marker":Wt.test(n)?"valid":/\p{XIDC}/u.test(n)&&Od.test(n)?"unexpected-mixed-emoji":Xa(n)?Te(n)?"valid":Te(n[0])?"invalid-char":"invalid-first-char":"unexpected-script"}var $r=["number","finite_number","complex","finite_complex","imaginary","real","finite_real","rational","finite_rational","integer","finite_integer","non_finite_number"],jo=["indexed_collection","list","tuple"],Fr=[...jo,"collection","set","record","dictionary"],Vr=["scalar",...$r,"boolean","string"],Zo=["value",...Fr,...Vr],Ho=["expression","symbol","function",...Zo],Et=["any","unknown","nothing","never","error",...Ho];var $d={number:$r,non_finite_number:[],finite_number:["finite_complex","finite_real","finite_integer","finite_rational"],complex:["finite_complex","imaginary","finite_real","finite_rational","finite_integer","non_finite_number"],finite_complex:["imaginary","finite_real","finite_rational","finite_integer"],imaginary:[],real:["rational","integer","finite_real","finite_rational","finite_integer","non_finite_number"],finite_real:["finite_rational","finite_integer"],rational:["finite_rational","finite_integer","integer","non_finite_number"],finite_rational:["finite_integer"],integer:["finite_integer","non_finite_number"],finite_integer:[],any:Et,unknown:[],nothing:[],never:[],error:[],value:Zo,scalar:Vr,collection:Fr,indexed_collection:jo,list:[],set:[],tuple:[],record:[],dictionary:[],function:[],symbol:[],boolean:[],string:[],expression:Ho};function Di(n,e){return e==="any"||n==="never"?!0:n==="unknown"||e==="unknown"?!1:n===e?!0:$d[e].includes(n)}function E(n,e){if(typeof n=="string"&&(n=A(n)),typeof e=="string"&&(e=A(e)),e==="any")return!0;if(e==="never")return!1;if(e==="error")return n==="error";if(e==="nothing")return n==="nothing";if(n==="nothing")return!1;if(e==="unknown")return!0;if(n==="unknown")return!1;if(typeof e=="string")return typeof n=="string"?Di(n,e):n.kind==="value"?typeof n.value=="boolean"?e==="boolean":typeof n.value=="number"?Number.isInteger(n.value)?Di("integer",e):Di("number",e):typeof n.value=="boolean"?Di("boolean",e):typeof n.value=="string"?Di("string",e):!1:n.kind==="union"?n.types.every(t=>E(t,e)):n.kind==="intersection"?n.types.some(t=>E(t,e)):n.kind==="negation"?!E(n.type,e):n.kind==="numeric"?!!E(n.type,e):e==="number"?eu(n):e==="symbol"?Wo(n):e==="expression"?Fd(n):e==="function"?ou(n):e==="scalar"?nu(n):e==="value"?ru(n):e==="indexed_collection"?iu(n):e==="collection"?tu(n):e==="tuple"?n.kind==="tuple":e==="list"?n.kind==="list":e==="set"?n.kind==="set":e==="record"?n.kind==="record":e==="dictionary"?n.kind==="dictionary":!1;if(e.kind==="union")return typeof n!="string"&&n.kind==="union"?n.types.every(t=>e.types.some(i=>E(t,i))):e.types.some(t=>E(n,t));if(e.kind==="expression"){if(n==="symbol")return!0;if(typeof n=="string")return!1;if(n.kind==="expression")return e.operator==="Symbol"?Wo(n):n.operator===e.operator;if(n.kind==="symbol")return!0}if(typeof n=="string")return!1;if(e.kind==="reference"){if(n.kind==="reference")return n.name===e.name;if(e.alias===!0&&e.def)return E(n,e.def)}if(n.kind==="union")return n.types.some(t=>E(t,e));if(n.kind==="intersection"&&e.kind==="intersection")return e.types.every(t=>n.types.some(i=>E(i,t)));if(n.kind==="intersection")return n.types.every(t=>E(t,e));if(e.kind==="intersection")return e.types.every(t=>E(n,t));if(n.kind==="signature"&&e.kind==="signature"){if(!E(n.result,e.result))return!1;if(n.optArgs||n.variadicArg){if(e.args){if(!n.args||n.args.length!==e.args.length)return!1;for(let t=0;t<e.args.length;t++)if(!E(e.args[t].type,n.args[t].type))return!1}else if(n.args)return!1;if(e.optArgs){if(!n.optArgs||n.optArgs.length!==e.optArgs.length)return!1;for(let t=0;t<n.optArgs.length;t++)if(!E(e.optArgs[t].type,n.optArgs[t].type))return!1}else if(n.optArgs)return!1;if(e.variadicArg){if(!n.variadicArg||n.variadicMin!=e.variadicMin||!E(e.variadicArg.type,n.variadicArg.type))return!1}else if(n.variadicArg)return!1}else{if(e.args&&!n.args)return!1;let t=0;if(e.args){if(n.args.length<e.args.length)return!1;for(;t<e.args.length;){if(!E(e.args[t].type,n.args[t].type))return!1;t+=1}}if(e.optArgs){if(t>=n.args.length)return!0;for(let i=0;i<e.optArgs.length;i++){if(!E(e.optArgs[i].type,n.args[t].type))return!1;if(t+=1,t>=n.args.length)return!0}}if(e.variadicArg){if(t>=n.args.length&&e.variadicMin===0)return!0;if(e.variadicMin>0&&t+e.variadicMin>n.args.length)return!1;for(;t<n.args.length;){if(!E(e.variadicArg.type,n.args[t].type))return!1;t+=1}}}return!0}if(n.kind==="record"&&e.kind==="record"){for(let t of Object.keys(e.elements))if(!(t in n.elements)||!E(n.elements[t],e.elements[t]))return!1;return!0}if(n.kind==="dictionary"&&e.kind==="dictionary")return E(n.values,e.values);if(e.kind==="indexed_collection")return n.kind==="indexed_collection"||n.kind==="list"?E(n.elements,e.elements):n.kind==="tuple"?n.elements.every(t=>E(t.type,e.elements)):!1;if(e.kind==="collection"){if(n.kind==="collection"||n.kind==="indexed_collection"||n.kind==="list")return E(n.elements,e.elements);if(n.kind==="tuple")return n.elements.every(t=>E(t.type,e.elements));if(n.kind==="set")return E(n.elements,e.elements);if(n.kind==="dictionary")return E(A(`tuple<string, ${U(n.values)}>`),e.elements);if(n.kind==="record")return E(A(`tuple<$string, ${U(oe(...Object.values(n.elements)))}>`),e.elements)}if(n.kind==="tuple"&&e.kind==="tuple"){if(n.elements.length!==e.elements.length)return!1;for(let t=0;t<n.elements.length;t++){let i=n.elements[t],r=e.elements[t];if(!E(i.type,r.type)||i.name!==r.name)return!1}return!0}if(e.kind==="list"&&n.kind==="list"){if(!E(n.elements,e.elements))return!1;if(e.dimensions){if(!n.dimensions||n.dimensions.length!==e.dimensions.length)return!1;for(let t=0;t<n.dimensions.length;t++)if(e.dimensions[t]!==-1&&n.dimensions[t]!==e.dimensions[t])return!1}return!0}if(n.kind==="symbol"&&e.kind==="symbol")return n.name===e.name;if(n.kind==="numeric"&&e.kind==="numeric")return!(!E(n.type,e.type)||(n.lower??-1/0)<(e.lower??-1/0)||(n.upper??1/0)>(e.upper??1/0));if(e.kind==="set"&&n.kind==="set")return!!E(n.elements,e.elements);if(n.kind==="negation"&&e.kind==="negation")return E(n.type,e.type);if(e.kind==="negation")return!E(n,e.type);if(e.kind==="value"&&n.kind==="value")return e.value===n.value;if(n.kind==="value"){if(typeof n.value=="boolean")return E("boolean",e);if(typeof n.value=="number")return Number.isInteger(n.value)?E("integer",e):E("real",e);if(typeof n.value=="string")return E("string",e)}return!1}function eu(n){return typeof n=="string"?$r.includes(n):n.kind==="value"?typeof n.value=="number":n.kind==="numeric"}function nu(n){return eu(n)?!0:typeof n=="string"?Vr.includes(n):n.kind==="value"?["string","boolean","number"].includes(typeof n.value):!1}function tu(n){return iu(n)?!0:typeof n=="string"?Fr.includes(n):["collection","set","record","dictionary"].includes(n.kind)}function iu(n){return typeof n=="string"?!1:["indexed_collection","list","tuple"].includes(n.kind)}function ru(n){return nu(n)||tu(n)}function ou(n){return n==="function"||typeof n!="string"&&n.kind==="signature"}function Fd(n){return typeof n=="string"&&["expression","symbol","function"].includes(n)||ru(n)||ou(n)||Wo(n)?!0:typeof n=="string"?!1:n.kind==="expression"}function Wo(n){return n==="symbol"?!0:typeof n=="string"?!1:n.kind==="symbol"?!0:n.kind==="expression"?n.operator==="Symbol":!1}var au=3,uu=1,lu=2,Vd=4,qd=5,zd=6,Gd=7,Ud=8,jd=9,Zd=10,Hd=11;function U(n,e=0){if(typeof n=="string")return n;let t="";switch(n.kind){case"value":typeof n.value=="string"?t=`"${n.value}"`:typeof n.value=="boolean"?t=n.value?"true":"false":t=n.value.toString();break;case"reference":t=n.name;break;case"negation":t=`!${U(n.type,au)}`;break;case"union":t=n.types.map(u=>U(u,uu)).join(" | ");break;case"intersection":t=n.types.map(u=>U(u,lu)).join(" & ");break;case"expression":t=`expression<${su(n.operator)}>`;break;case"symbol":t=`symbol<${su(n.name)}>`;break;case"numeric":Number.isFinite(n.lower)&&Number.isFinite(n.upper)?t=`${n.type}<${n.lower}..${n.upper}>`:Number.isFinite(n.lower)?t=`${n.type}<${n.lower}..>`:Number.isFinite(n.upper)?t=`${n.type}<..${n.upper}>`:t=`${n.type}`;break;case"list":if(n.dimensions&&E(n.elements,"number")){if(n.dimensions===void 0)n.elements==="number"&&(t="tensor");else if(n.dimensions.length===1)n.elements==="number"?n.dimensions[0]<0?t="vector":t=`vector<${n.dimensions[0]}>`:n.dimensions[0]<0?t=`vector<${U(n.elements)}>`:t=`vector<${U(n.elements)}^${n.dimensions[0]}>`;else if(n.dimensions.length===2){let u=n.dimensions;n.elements==="number"?u[0]<0&&u[1]<0?t="matrix":t=`matrix<${u[0]}x${u[1]}>`:u[0]<0&&u[1]<0?t=`matrix<${U(n.elements)}>`:t=`matrix<${U(n.elements)}^(${u[0]}x${u[1]})>`}}if(!t){let u=n.dimensions?n.dimensions.length===1?`^${n.dimensions[0].toString()}`:`^(${n.dimensions.join("x")})`:"";t=`list<${U(n.elements)}${u}>`}break;case"record":t=`record<${Object.entries(n.elements).map(([u,l])=>`${u}: ${U(l)}`).join(", ")}>`;break;case"dictionary":t=`dictionary<${U(n.values)}>`;break;case"set":t=`set<${U(n.elements)}>`;break;case"collection":t=`collection<${U(n.elements)}>`;break;case"indexed_collection":t=`indexed_collection<${U(n.elements)}>`;break;case"tuple":if(n.elements.length===0)t="tuple";else if(n.elements.length===1){let[u]=n.elements;t=`tuple<${Jt(u)}>`}else t="tuple<"+n.elements.map(u=>Jt(u)).join(", ")+">";break;case"signature":let r=n.args?n.args.map(u=>Jt(u)).join(", "):"",o=n.optArgs?n.optArgs.map(u=>Jt(u)+"?").join(", "):"",s=n.variadicArg?n.variadicMin===0?`${Jt(n.variadicArg)}*`:`${Jt(n.variadicArg)}+`:"";t=`(${[r,o,s].filter(u=>u).join(", ")}) -> ${U(n.result)}`;break;default:t="error"}return e>0&&e>Wd(n.kind)?`(${t})`:t}function Jt(n){return n.name?`${n.name}: ${U(n.type)}`:U(n.type)}function su(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)?n:`\`${n}\``}function Wd(n){switch(n){case"negation":return au;case"union":return uu;case"intersection":return lu;case"list":return Vd;case"record":return qd;case"dictionary":return zd;case"set":return Gd;case"collection":case"indexed_collection":return Ud;case"tuple":return jd;case"signature":return Zd;case"value":return Hd;default:return 0}}function Jd(n,e){if(n===e)return 0;if(n.length===0)return e.length;if(e.length===0)return n.length;let t=Array.from({length:n.length+1},(r,o)=>o),i=new Array(n.length+1);for(let r=1;r<=e.length;r++){i[0]=r;for(let o=1;o<=n.length;o++){let s=n[o-1]===e[r-1]?0:1;i[o]=Math.min(t[o]+1,i[o-1]+1,t[o-1]+s)}[t,i]=[i,t]}return t[n.length]}function Mi(n,e){let i=null,r=1/0,o=n.length;for(let s of e){if(Math.abs(o-s.length)>7)continue;let a=Jd(n,s);if(a===0)return s;a<=7&&a<r&&(r=a,i=s)}return i}var Jo=class{buffer;pos;_valueParser;_typeResolver;constructor(e,t){this.buffer=e,this.pos=0,this._valueParser=t?.valueParser??(()=>null),this._typeResolver=t?.typeResolver??{forward:()=>{},resolve:()=>{},get names(){return[]}}}error(...e){throw new Error(`
@@ -108,7 +108,7 @@ Error in definition of "${i}"`,"",JSON.stringify(r,void 0,4),"",o.message].join(
108
108
  `)}}function wo(n){return typeof n=="number"?n===0?1:Number.isInteger(n)?Math.floor(Math.log2(Math.abs(n))/Math.log2(10))+(n>0?1:2):2:n.isZero?1:n.im!==0?wo(n.re)+wo(n.im)+1:wo(n.re)}function Ia(n){if(n.symbol)return 1;if(n.isNumberLiteral)return wo(n.numericValue);let e=n.operator,t=2;if(["Add"].includes(e))t=3;else if(["Subtract","Negate"].includes(e))t=4;else if(["Square","Sqrt"].includes(e))t=5;else{if(["Power","Root"].includes(e))return Ia(n.ops[1]);["Multiply"].includes(e)?t=7:["Divide"].includes(e)?t=8:["Ln","Exp","Log","Lb"].includes(e)?t=9:["Cos","Sin","Tan"].includes(e)?t=10:t=11}return t+(n.ops?.reduce((i,r)=>i+Ia(r),0)??0)}var wa=Ia;function we(n){for(let[e,t]of Object.entries(n))if(e!=="x"&&e!=="_x"&&t.has("_x"))return!1;return!0}var gf=[{match:["Multiply","_x","__a"],replace:0,id:"ax",condition:we},{match:["Add",["Divide","_a","_x"],"__b"],replace:1/0,useVariations:!0,condition:we},{match:["Add",["Multiply","_x","__a"],"__b"],replace:["Divide",["Negate","__b"],"__a"],useVariations:!0,condition:we},{match:["Add",["Multiply","_a",["Power","_x","_n"]],"__b"],replace:["Power",["Divide",["Negate","__b"],"_a"],["Divide",1,"_n"]],useVariations:!0,condition:n=>we(n)&&!n._n.is(0)},{match:["Add",["Multiply","_a",["Power","_x","_n"]],"__b"],replace:["Negate",["Power",["Divide",["Negate","__b"],"_a"],["Divide",1,"_n"]]],useVariations:!0,condition:n=>we(n)&&!n._n.is(0)&&(n._n.isEven??!1)},{match:["Add",["Multiply","__a",["Power","_x",2]],["Multiply","__b","_x"],"__c"],replace:["Divide",["Add",["Negate","__b"],["Sqrt",["Subtract",["Square","__b"],["Multiply",4,"__a","__c"]]]],["Multiply",2,"__a"]],useVariations:!0,condition:we},{match:["Add",["Multiply","__a",["Power","_x",2]],["Multiply","__b","_x"],"__c"],replace:["Divide",["Subtract",["Negate","__b"],["Sqrt",["Subtract",["Square","__b"],["Multiply",4,"__a","__c"]]]],["Multiply",2,"__a"]],useVariations:!0,condition:we},{id:"a^x + b = 0",match:["Add",["Power","_a","_x"],"__b"],replace:["Ln",["Negate","__b"],"_a"],useVariations:!0,onBeforeMatch:()=>{},condition:n=>we(n)&&(n._a.isPositive??!1)&&(n.__b.isNegative??!1)},{match:["Add",["Multiply","__a",["Exp",["Multiply","__b","_x"]]],"__c"],replace:["Divide",["Ln",["Negate",["Divide","__c","__a"]]],"__b"],useVariations:!0,condition:n=>we(n)&&((!n.__a.is(0)&&n.__c.div(n.__a).isNegative)??!1)},{match:["Add",["Multiply","__a",["Exp","_x"]],"__c"],replace:["Ln",["Negate",["Divide","__c","__a"]]],useVariations:!0,condition:n=>we(n)&&((!n.__a.is(0)&&n.__c.div(n.__a).isNegative)??!1)&&!n.__a.has("_x")&&!n.__c.has("_x")},{match:["Add",["Exp","_x"],"__c"],replace:["Ln",["Negate","__c"]],useVariations:!0,condition:n=>we(n)&&(n.__c.isNegative??!1)},{match:["Add",["Exp",["Multiply","__b","_x"]],"__c"],replace:["Divide",["Ln",["Negate","__c"]],"__b"],useVariations:!0,condition:n=>we(n)&&(n.__c.isNegative??!1)},{match:["Add",["Multiply","__a",["Log","_x","__b"]],"__c"],replace:["Power","__b",["Negate",["Divide","__c","__a"]]],useVariations:!0,condition:n=>(we(n)&&!n.__a.is(0)&&n.__b.isPositive)??!1},{match:["Multiply","__a",["Log","_x","__b"]],replace:["Power","__b",["Negate",["Divide","__c","__a"]]],useVariations:!0,condition:n=>(we(n)&&!n.__a.is(0)&&n.__b.isPositive)??!1},{match:["Add",["Abs",["Add",["Multiply","__a","_x"],"__b"]],"__c"],replace:["Divide",["Subtract","__b","__c"],"__a"],condition:we},{match:["Add",["Abs",["Add",["Multiply","__a","_x"],"__b"]],"__c"],replace:["Divide",["Negate",["Add","__b","__c"],"__a"]],condition:we},{match:"ax + \\mathrm{__b} \\sqrt{cx + \\mathrm{__d}} + \\mathrm{__g}",replace:"\\frac{-(2 a g - \\mathrm{__b}^2 c) + \\sqrt{(2 a \\mathrm{__g} - \\mathrm{__b}^2 c)^2 - 4 a^2(g^2 - b^2 \\mathrm{__d})}}{2 a^2}",useVariations:!0,condition:we},{match:"ax + \\mathrm{__b} \\sqrt{cx + \\mathrm{__d}} + \\mathrm{__g}",replace:"\\frac{-(2 a g - \\mathrm{__b}^2 c) - \\sqrt{(2 a \\mathrm{__g} - \\mathrm{__b}^2 c)^2 - 4 a^2(g^2 - b^2 \\mathrm{__d})}}{2 a^2}",useVariations:!0,condition:we}];function ko(n,e){let t=n.engine;n.operator==="Equal"?n=n.op1.expand().sub(n.op2.expand()).simplify():n=n.expand().simplify();let i=t.getRuleSet("solve-univariate"),r=[n.subs({[e]:"_x"},{canonical:!1})];t.pushScope(),t.declare("_x","number");let o=r.flatMap(s=>$t(s,i,{_x:t.symbol("_x")},{useVariations:!0,canonical:!0}));return o.length===0&&(r=r.flatMap(s=>mf(s)),o=r.flatMap(s=>$t(s,i,{_x:t.symbol(e)},{useVariations:!0,canonical:!0}))),o.length===0&&(r=r.flatMap(s=>Ze(s.canonical)).filter(s=>s!==null),r=r.flatMap(s=>mf(s)),o=r.flatMap(s=>$t(s,i,{_x:t.symbol(e)},{useVariations:!0,canonical:!0}))),t.popScope(),og(n,e,o.map(s=>s.evaluate().simplify()))}var hf=[{match:["Add",["Abs",["Add",["Multiply","__a","_x"],"__b"]],"__c"],replace:["Add",["Multiply","__a","_x"],"__b","__c"]},{match:["Add",["Abs",["Add",["Multiply","__a","_x"],"__b"]],"__c"],replace:["Add",["Negate",["Multiply","__a","_x"]],["Negate","__b"],"__c"]},{match:["Multiply","__a",["Power","_b","_n"]],replace:"_b",condition:({__a:n,_b:e,_n:t})=>!n.has("_x")&&e.has("_x")&&!t.is(0)&&!t.has("_x")},{match:["Multiply","__a",["Sqrt","_b"]],replace:["Multiply",["Square","_a"],"__b"],condition:({_b:n})=>n.has("_x")},{match:["Divide","_a","_b"],replace:"_a",condition:({_a:n,_b:e})=>n.has("_x")&&!e.is(0)},{match:["Multiply","__a","_b"],replace:"_b",condition:({__a:n,_b:e})=>!n.has("_x")&&e.has("_x")},{match:["Add",["Ln","_a"],["Ln","_b"],"__c"],replace:["Add",["Ln",["Multiply","_a","_b"]],"__c"]},{match:["Multiply",["Exp","__a"],["Exp","__b"],"__c"],replace:["Multiply",["Exp",["Add","_a","_b"]],"__c"]},{match:["Ln","_a"],replace:["Subtract","_a",1],condition:({_a:n})=>n.has("_x")},{match:["Sin","_a"],replace:"_a",condition:({_a:n})=>n.has("_x")},{match:["Cos","_a"],replace:["Subtract","_a",["Divide","Pi",2]],condition:({_a:n})=>n.has("_x")},{match:["Tan","_a"],replace:"_a",condition:({_a:n})=>n.has("_x")},{match:["Add",["Sin","_a"],["Cos","_a"]],replace:1,condition:({_a:n})=>n.has("_x")},{match:["Subtract",["Square",["Sin","_a"]],["Square",["Cos","_a"]]],replace:["PlusMinus",["Sin","_a"],["Divide",["Sqrt",2],2]],condition:({_a:n})=>n.has("_x")}];function mf(n){let e=n.engine,t=e.getRuleSet("harmonization");return $t(n,t,{_x:e.symbol("_x")})}function og(n,e,t){return t.filter(i=>{let r=n.subs({[e]:i}).canonical.evaluate();return r===null||!r.isValid||r.isNaN||r.has(e)?!1:r.isEqual(0)})}function Co(n,e){if(!n.ops)return[];let t=n.ops,i=n.operatorDefinition;if(!i||t.length===0)return t;let r=i?.associative?n.operator:"";if(t=lt(t,r),i.lazy)return t;let o=[];for(let s of t){let a=s.operator;if(a==="Hold")o.push(s);else{let u=a==="ReleaseHold"?s.op1:s;if(u){let l=e(u);l!==null&&o.push(l)}}}return lt(o,r)}async function yf(n,e){if(!n.ops)return[];let t=n.ops,i=n.operatorDefinition;if(!i||t.length===0)return t;let r=i?.associative?n.operator:"";if(t=lt(t,r),i.lazy)return t;let o=[];for(let s of t){let a=s.operator;if(a==="Hold")o.push(s);else{let u=a==="ReleaseHold"?s.op1:s;if(u){let l=await e(u);l!==null&&o.push(l)}}}return lt(o,r)}function xt(n,e,t){if((s=>t&&t.some(a=>a.value.isSame(s)))(n)||(t||(t=[{value:n,because:"initial"}]),!n.isValid))return t;if(!(n.isCanonical||n.isStructural)){let s=n.canonical;return s.isCanonical||s.isStructural?xt(s,e,t):t}let r=n.engine,o=e?.rules?r.rules(e.rules,{canonical:!0}):r.getRuleSet("standard-simplification");e={...e,rules:o};do{let s=ag(n,o,e,t);if(s.length<=t.length)break;n=s.at(-1).value,t=s}while(!t.slice(0,-1).some(s=>s.value.isSame(n)));return t}function sg(n,e,t){if(e==null||n===e||n.isSame(e))return!1;let i=n.engine;return t??=r=>i.costFunction(r),t(e)<=1.2*t(n)}function xf(n,e){return n.ops?n.engine.function(n.operator,Co(n,t=>xt(t,e).at(-1).value)):n}function ag(n,e,t,i){if(n.isNumberLiteral||n.string)return i;if(n.symbol){let s=et(n,e,{recursive:!1,canonical:!0,useVariations:!1});return s.length>0?[...i,...s]:i}let r=xf(n,t);r.isSame(n)||(i=[...i,{value:r,because:"simplified operands"}],n=r);let o=ug(n,e,t,i);return o.length>i.length?o:i}function ug(n,e,t,i){let r=et(n,e,{recursive:!1,canonical:!0,useVariations:t.useVariations??!1});if(r.length===0)return i;let o=r.at(-1).value;return o.isSame(n)||(o=xf(o),!sg(n,o,t?.costFunction))?i:(r.at(-1).value=o,[...i,...r])}function Ca(n){return typeof n=="string"?n.startsWith("_"):$n(n)?!0:n.ops?Ca(n.operator)||n.ops.some(Ca):!1}function Ao(n,e,t){return n.startsWith("_"),n==="_"||n==="__"||n==="___"?t:n in t?e.isSame(t[n])?t:null:Ca(e)?null:{...t,[n]:e}}function qt(n,e,t,i){if($n(e))return Ao(Fn(e),n,t);let r=i.acceptVariants??!0;if(i={...i,acceptVariants:!0},e.numericValue!==null)return n.numericValue===null?null:e.isEqual(n)?t:r?ka(n,e,t,i):null;let o=e.string;if(o!==null)return n.string===o?t:null;let s=e.symbol;if(s!==null)return s===n.symbol?t:r?ka(n,e,t,i):null;if(e.ops){let a=i.useVariations??!1,u=n.engine,l=null,c=e.operator;if(c.startsWith("_")?(l=Ao(c,u.box(n.operator),t),l!==null&&(l=Aa(n,e.ops,l,i))):c===n.operator&&(l=e.operatorDefinition.commutative?cg(n,e,t,i):Aa(n,e.ops,t,i)),l===null&&a){if(!r)return null;l=ka(n,e,t,i)}return l!==null&&(t=l),i.recursive&&n.ops&&(l=lg(n,e,t,{...i,acceptVariants:r})??l),l}return null}function lg(n,e,t,i){n.ops;let r=null;for(let o of n.ops){let s=qt(o,e,t,i);s!==null&&(r=s,t=s)}return r}function ka(n,e,t,i){if(!i.useVariations)return null;let r=n.engine,o={...i,acceptVariants:!1},s=(u,l)=>qt(r.function(u,l,{canonical:!1}),e,t,o),a=e.operator;if(a==="Negate"&&n.is(0))return qt(r.Zero,e.op1,t,o);if(a==="Add"){let u=s("Add",[0,n]);if(u!==null||(n.operator==="Subtract"&&(u=s("Add",[n.op1,["Negate",n.op2]])),u!==null))return u}if(a==="Subtract"){let u=s("Subtract",[n,0]);if(u!==null||(n.operator==="Negate"&&(u=s("Subtract",[0,n.op1])),u!==null))return u}if(a==="Multiply"){let u=s("Multiply",[1,n]);if(u!==null||n.operator==="Negate"&&(u=s("Multiply",[-1,n.op1]),u!==null)||n.operator==="Divide"&&(u=s("Multiply",[n.op1,["Divide",1,n.op2]]),u!==null))return u}if(a==="Divide"){let u=s("Divide",[n,1]);if(u!==null)return u}if(a==="Square"){let u=s("Power",[n,2]);if(u!==null)return u}if(a==="Exp"){let u=s("Power",[r.E,n]);if(u!==null)return u}if(a==="Power"){if(e.op2.re===2&&e.op2.im===0){let u=s("Square",[n]);if(u!==null)return u}if(e.op1.symbol==="ExponentialE"){let u=s("Exp",[n]);if(u!==null)return u}{let u=s("Power",[n,1]);if(u!==null)return u}}return null}function cg(n,e,t,i){n.operator,e.operator;let r=Yo(e.ops);for(let o of r){let s=Aa(n,o,t,i);if(s!==null)return s}return null}function Aa(n,e,t,i){if(e.length===0)return n.ops&&n.ops.length===0?t:null;let r=e[0].engine,o={...t},s=[...n.ops],a=0;for(;a<e.length;){let u=e[a],l=Fn(u);if(l!==null)if(l.startsWith("__")){let c=0;if(e[a+1]===void 0)c=s.length+1;else{let d=!1;for(;!d&&c<s.length;)d=qt(s[c],e[a+1],o,i)!==null,c+=1;if(!d&&l.startsWith("___"))return null}if(!l.startsWith("___")&&c<=1)return null;let f;if(c<=1)n.operator==="Add"?f=r.Zero:n.operator==="Multiply"?f=r.One:f=r.Nothing;else if(c===2){if(s.length===0)return null;f=s.shift()}else{let d=r.lookupDefinition(n.operator),p=s.splice(0,c-1);d&&Z(d)&&d.operator.associative?f=r.function(n.operator,p,{canonical:!1}):f=r.function("Sequence",p,{canonical:!1})}o=Ao(l,f,o)}else if(l.startsWith("_")){if(s.length===0)return null;o=Ao(l,s.shift(),o)}else o=qt(s.shift(),u,o,i);else{let c=s.shift();if(!c)return null;o=qt(c,u,o,i)}if(o===null)return null;a+=1}return s.length>0?null:o}function Ni(n,e,t){e=e.structural;let i=t?.useVariations??!1,r={recursive:t?.recursive??!1,useVariations:i,acceptVariants:i},o=t?.substitution??{};return qt(n.structural,e.structural,o,r)}function bf(n){let e=n.engine;if(n.operator==="Hold")return;let t;if(n.ops){let i=n.operatorDefinition;return i?.sgn&&(t=i.sgn(n.ops,{engine:e})),t}return n.symbol||n.isNumberLiteral?n.sgn:"unsigned"}function _i(n){if(n!==void 0){if(n==="positive")return!0;if(["non-positive","zero","negative"].includes(n))return!1}}function Si(n){if(n!==void 0){if(["positive","positive-infinity","non-negative","zero"].includes(n))return!0;if(n==="negative")return!1}}function Ti(n){if(n!==void 0){if(n==="negative")return!0;if(["non-negative","zero","positive"].includes(n))return!1}}function Bi(n){if(n!==void 0){if(["negative","non-positive","zero"].includes(n))return!0;if(["positive","positive-infinity"].includes(n))return!1}}function Da(n,e,t){return n.generation=e,n.value=t(),n.value}var fg=[5,5],he=class extends W{_operator;_ops;_def;_capturedContext;_localScope;_isPure;_isStructural;_hash;_value={value:null,generation:-1};_valueN={value:null,generation:-1};_sgn={value:null,generation:-1};_type={value:null,generation:-1};constructor(e,t,i,r){super(e,r?.metadata),this._operator=t,this._ops=i,this._localScope=r?.scope,this._isStructural=r?.structural??!1,(r?.canonical||this._isStructural)&&this.bind()}get hash(){if(this._hash!==void 0)return this._hash;let e=0;for(let t of this._ops)e=e<<1^t.hash|0;return e=e^cn(this._operator)|0,this._hash=e,e}infer(e,t){let i=this.operatorDefinition;return!i||!i.inferredSignature?!1:(i.signature.is("function")?i.signature=new S({kind:"signature",result:e},this.engine._typeResolver):Gr(i.signature.type)&&(i.signature=new S({kind:"signature",result:t==="narrow"?vt(i.signature.type.result,e):oe(i.signature.type.result,e)},this.engine._typeResolver)),this.engine._generation+=1,!0)}bind(){this._def=to(this._operator,this._localScope??this.engine.context.lexicalScope)}reset(){}get value(){}get isCanonical(){return this._def!==void 0&&this._def!==null}get isPure(){if(this._isPure!==void 0)return this._isPure;let e=this.operatorDefinition?.pure??!1;return e&&(e=this._ops.every(t=>t.isPure)),this._isPure=e,e}get isConstant(){return this.isPure&&this._ops.every(e=>e.isConstant)}get constantValue(){return this.isConstant?this.value:void 0}get json(){return[this._operator,...this.structural.ops.map(e=>e.json)]}get operator(){return this._operator}get ops(){return this._ops}get nops(){return this._ops.length}get op1(){return this._ops[0]??this.engine.Nothing}get op2(){return this._ops[1]??this.engine.Nothing}get op3(){return this._ops[2]??this.engine.Nothing}get isScoped(){return this._localScope!==void 0}get localScope(){return this._localScope}get isValid(){return this._operator==="Error"?!1:this._ops.every(e=>e?.isValid)}get canonical(){return this.isCanonical||!this.isValid?this:this.engine.function(this._operator,this._ops)}get structural(){if(this.isStructural)return this;let e=this.operatorDefinition;if(e?.associative||e?.commutative){let t=this.ops.map(r=>r.structural),i=[];if(!e.associative)i=t;else for(let r of t)r.operator===this.operator?i.push(...r.ops):i.push(r);return this.engine.function(this._operator,this.isValid?Ji(this._operator,i):i,{canonical:!1,structural:!0})}return this.engine.function(this._operator,this.ops.map(t=>t.structural),{canonical:!1,structural:!0})}get isStructural(){return this._isStructural}toNumericValue(){this.isCanonical||this.isStructural;let e=this.engine;if(this.operator==="Complex")return[e._numericValue({re:this.op1.re,im:this.op2.re}),e.One];let t=this;if(t.operator==="Add"&&(t=gt(this),t.numericValue!==null)){if(typeof t.numericValue=="number"){if(Number.isInteger(t.numericValue))return[e._numericValue(t.numericValue),e.One]}else if(t.numericValue.isExact)return[t.numericValue,e.One]}if(t.operator==="Negate"){let[i,r]=t.op1.toNumericValue();return[i.neg(),r]}if(t.operator==="Multiply"){let i=[],r=e._numericValue(1);for(let o of t.ops){let[s,a]=o.toNumericValue();r=r.mul(s),a.is(1)||i.push(a)}return i.length===0?[r,e.One]:i.length===1?[r,i[0]]:[r,_e(this.engine,i)]}if(t.operator==="Divide"){let[i,r]=t.op1.toNumericValue(),[o,s]=t.op2.toNumericValue(),a=i.div(o);return s.is(1)?[a,r]:[a,e.function("Divide",[r,s])]}if(t.operator==="Power"){if(t.op2.numericValue===null)return[e._numericValue(1),this];let[i,r]=t.op1.toNumericValue();if(i.isOne)return[i,this];let o=ee(t.op2);return o!==null?[i.pow(o),e.function("Power",[r,t.op2])]:t.op2.is(.5)?[i.sqrt(),e.function("Sqrt",[r])]:[e._numericValue(1),this]}if(t.operator==="Sqrt"){let[i,r]=t.op1.toNumericValue();return r.is(1)||r.is(0)?i.isOne||i.isZero?[i,r]:[i.sqrt(),r]:[i.sqrt(),e.function("Sqrt",[r])]}if(t.operator==="Root"){let i=t.op2.re;if(isNaN(i)||t.op2.im!==0)return[e._numericValue(1),this];let[r,o]=t.op1.toNumericValue();return i===2?[r.sqrt(),e.function("Sqrt",[o])]:[r.root(i),e.function("Root",[o,t.op2])]}if(t.operator==="Abs"){let[i,r]=t.op1.toNumericValue();return[i.abs(),e.function("Abs",[r])]}if(t.operator,t.operator,t.operator==="Log"||t.operator==="Ln"){let i=t.op2.re;isNaN(i)&&t.operator==="Log"&&(i=10);let[r,o]=t.op1.toNumericValue();return r.isOne?[r,this]:e.box(r.ln(i)).add(e.function(t.operator,[o,t.op2])).toNumericValue()}return[e._numericValue(1),t]}subs(e,t){t??={canonical:void 0},t.canonical===void 0&&(t={canonical:this.isCanonical});let i=this._ops.map(r=>r.subs(e,t));return i.every(r=>r.isValid)?this.engine.function(this._operator,i,t):this.engine.function(this._operator,i,{canonical:!1})}replace(e,t){return et(this,e,t).at(-1)?.value??null}match(e,t){return Ni(this,e,t)}has(e){if(typeof e=="string"){if(this._operator===e)return!0}else if(e.includes(this._operator))return!0;return this._ops.some(t=>t.has(e))}get sgn(){let e=this.isPure&&this._ops.every(t=>t.isConstant)?void 0:this.engine._generation;return Da(this._sgn,e,()=>{if(!(!this.isValid||this.isNumber!==!0))return bf(this)})}get isNaN(){if(!this.isNumber)return!1}get isInfinity(){if(!this.isNumber)return!1}get isFinite(){if(this.isNumber!==!0||this.isNaN||this.isInfinity)return!1;if(!(this.isNaN===void 0||this.isInfinity===void 0))return!0}get isOne(){if(this.isNonPositive===!0||this.isReal===!1)return!1}get isNegativeOne(){if(this.isNonNegative===!0||this.isReal===!1)return!1}get isPositive(){return _i(this.sgn)}get isNonNegative(){return Si(this.sgn)}get isNegative(){return Ti(this.sgn)}get isNonPositive(){return Bi(this.sgn)}get numerator(){return this.numeratorDenominator[0]}get denominator(){return this.numeratorDenominator[1]}get numeratorDenominator(){if(!this.isCanonical)return[this,this.engine.One];if(this.isNumber!==!0)return[this.engine.Nothing,this.engine.Nothing];let e=this.operator;if(e==="Divide")return[this.op1,this.op2];if(e==="Negate"){let[t,i]=this.op1.numeratorDenominator;return[t.neg(),i]}if(e==="Power"){let[t,i]=this.op1.numeratorDenominator;return[t.pow(this.op2),i.pow(this.op2)]}if(e==="Root"){let[t,i]=this.op1.numeratorDenominator;return[t.root(this.op2),i.root(this.op2)]}if(e==="Sqrt"){let[t,i]=this.op1.numeratorDenominator;return[t.sqrt(),i.sqrt()]}if(e==="Abs"){let[t,i]=this.op1.numeratorDenominator;return[t.abs(),i.abs()]}return e==="Multiply"?new Oe(this.engine,this.ops).asNumeratorDenominator():[this,this.engine.One]}neg(){if(!this.isCanonical)throw new Error("Not canonical");return Lt(this)}inv(){if(!this.isCanonical)throw new Error("Not canonical");if(this.isOne)return this;if(this.isNegativeOne)return this;if(this.operator==="Sqrt")return this.op1.inv().sqrt();if(this.operator==="Divide")return this.op2.div(this.op1);if(this.operator==="Power"){let e=this.op2.neg();return e.operator!=="Negate"?this.op1.pow(e):this.engine.function("Power",[this.op1,e])}if(this.operator==="Root"){let e=this.op2.neg();return e.operator!=="Negate"?this.op1.root(e):this.engine.function("Root",[this.op1,e])}return this.operator==="Exp"?this.engine.E.pow(this.op1.neg()):this.operator==="Rational"?this.op2.div(this.op1):this.operator==="Negate"?this.op1.inv().neg():this.engine._fn("Divide",[this.engine.One,this])}abs(){if(!this.isCanonical)throw new Error("Not canonical");return this.operator==="Abs"||this.operator==="Negate"?this:this.isNonNegative?this:this.isNonPositive?this.neg():this.engine._fn("Abs",[this])}add(e){if(e===0)return this;if(!this.isCanonical)throw new Error("Not canonical");return H(this,this.engine.box(e))}mul(e){if(!this.isCanonical)throw new Error("Not canonical");if(e===0)return this.engine.Zero;if(e===1)return this;if(e===-1)return this.neg();if(e instanceof j){if(e.isZero)return this.engine.Zero;if(e.isOne)return this;if(e.isNegativeOne)return this.neg()}return ae(this,this.engine.box(e))}div(e){if(!this.isCanonical)throw new Error("Not canonical");return hi(this,e)}pow(e){return Ie(this,e,{numericApproximation:!1})}root(e){if(!this.isCanonical||typeof e!="number"&&!e.isCanonical)throw new Error("Not canonical");let t=typeof e=="number"?e:e.im===0?e.re:void 0;if(t===0)return this.engine.NaN;if(t===1)return this;if(t===-1)return this.inv();if(t===2)return this.engine.function("Sqrt",[this]);if(this.operator==="Power"&&t!==void 0){let[i,r]=this.ops;return i.pow(r.div(t))}if(this.operator==="Divide"){let[i,r]=this.ops;return i.root(e).div(r.root(e))}if(this.operator==="Negate"&&t!==void 0)return t%2===0?this.op1.root(e):this.op1.root(e).neg();if(this.operator==="Sqrt"){if(t!==void 0)return this.op1.root(t*2);if(typeof e!="number")return this.op1.root(e.mul(2))}if(this.operator==="Root"){let[i,r]=this.ops;return i.root(r.mul(e))}if(this.operator==="Multiply"){let i=this.ops.map(r=>r.root(e));return ae(...i)}if(this.isNumberLiteral){let i=this.numericValue;if(typeof i=="number"){if(i<0)return this.engine.NaN;if(i===0)return this.engine.Zero;if(i===1)return this.engine.One;if(t!==void 0){let r=this.engine.number(Math.pow(i,1/t));if(!r.isFinite||r.isInteger)return r}}else{if(i.isOne)return this.engine.One;if(i.isZero)return this.engine.Zero;if(t!==void 0){let r=i.root(t);if(r.isExact)return this.engine.number(r)}}}return this.engine._fn("Root",[this,this.engine.box(e)])}sqrt(){return this.root(2)}ln(e){let t=e?this.engine.box(e):void 0;if(!this.isCanonical)throw new Error("Not canonical");if(this.is(0))return this.engine.NegativeInfinity;if(this.operator==="Exp")return this.op1;if(t&&this.isSame(t))return this.engine.One;if(!t&&this.isSame(this.engine.E))return this.engine.One;if(this.operator==="Power"){let[i,r]=this.ops;return i.isSame(this.engine.E)?r:r.mul(i.ln(t))}if(this.operator==="Root"){let[i,r]=this.ops;return r.div(i.ln(t))}return this.operator==="Sqrt"?this.op1.ln(t).div(2):this.operator==="Divide"?this.op1.ln(t).sub(this.op2.ln(t)):t&&t.type.matches("finite_integer")?t.re===10?this.engine._fn("Log",[this]):this.engine._fn("Log",[this,t]):this.engine._fn("Ln",[this])}get complexity(){if(this.isCanonical)return this.operatorDefinition?.complexity??ct}get baseDefinition(){if(this._def)return Z(this._def)?this._def.operator:this._def.value}get operatorDefinition(){if(this._def)return Z(this._def)?this._def.operator:void 0}get valueDefinition(){if(this._def)return ne(this._def)?this._def.value:void 0}get isNumber(){if(!this.type.isUnknown)return E(this.type.type,"number")}get isInteger(){if(!this.type.isUnknown)return E(this.type.type,"integer")}get isRational(){if(!this.type.isUnknown)return E(this.type.type,"rational")}get isReal(){if(!this.type.isUnknown)return E(this.type.type,"real")}get isFunctionExpression(){return!0}get type(){let e=this.isPure&&this._ops.every(t=>t.isConstant)?void 0:this.engine._generation;return Da(this._type,e,()=>new S(dg(this),this.engine._typeResolver))??S.unknown}simplify(e){return xt(this,e).at(-1)?.value??this}evaluate(e){return pg(this.engine,this._computeValue(e))()}evaluateAsync(e){return mg(this.engine,this._computeValueAsync(e))()}N(){return this.evaluate({numericApproximation:!0})}solve(e){let t=fr(e??this.unknowns);return t.length!==1?null:ko(this,t[0])}get isCollection(){if(!this.isValid)return!1;let e=this.baseDefinition?.collection;return!e||e.count!==void 0&&e.iterator,e!==void 0}get isIndexedCollection(){return!this.isValid||!this.baseDefinition?.collection?.at?!1:this.type.matches("indexed_collection")}get isLazyCollection(){if(!this.isValid)return!1;let e=this.baseDefinition?.collection;return e?e?.isLazy?.(this)??!1:!1}xcontains(e){return this.baseDefinition?.collection?.contains?.(this,e)}get xsize(){return this.operatorDefinition?.collection?.count?.(this)}get isEmptyCollection(){if(this.isCollection)return this.operatorDefinition?.collection?.isEmpty?.(this)}get isFiniteCollection(){if(this.isCollection)return this.operatorDefinition?.collection?.isFinite?.(this)}each(){let e=this.operatorDefinition?.collection?.iterator?.(this);return e?function*(){let t=e.next(),i=0;for(;!t.done;)i+=1,yield t.value,t=e.next()}():function*(){}()}at(e){return this.operatorDefinition?.collection?.at?.(this,e)}get(e){if(typeof e=="string")return this.operatorDefinition?.collection?.at?.(this,e);if(e.string)return this.operatorDefinition?.collection?.at?.(this,e.string)}indexWhere(e){if(this.operatorDefinition?.collection?.indexWhere)return this.operatorDefinition.collection.indexWhere(this,e);if(!this.isIndexedCollection||!this.isFiniteCollection)return;let t=0;for(let i of this.each()){if(e(i))return t;t+=1}}subsetOf(e,t){return this.operatorDefinition?.collection?.subsetOf?.(this,e,t)??!1}_computeValue(e){return()=>{if(!this.isValid||!this._def)return this;let t=e?.numericApproximation??!1,i=e?.materialization??!1;if(ne(this._def))return Ef(this,this._def.value,e);let r=this._def.operator;if(r.broadcastable&&this.ops.some(u=>pe(u))){let u=Is(this._ops);if(!u)return this.engine.Nothing;let l=[];for(;;){let{done:c,value:f}=u.next();if(c)break;l.push(this.engine._fn(this.operator,f).evaluate(e))}return l.length===0?this.engine.Nothing:l.length===1?l[0]:this.engine._fn("List",l)}if(i!==!1&&!r.evaluate&&this.isLazyCollection)return gg(this,r,e);let o=Co(this,u=>u.evaluate(e)),s=this._localScope!==void 0||e?.withArguments;if(s&&(this.engine._pushEvalContext(this._localScope??{parent:this.engine.context?.lexicalScope,bindings:new Map}),e?.withArguments))for(let[u,l]of Object.entries(e.withArguments))this.engine.context.values[u]=l;let a=r.evaluate?.(o,{numericApproximation:t,engine:this.engine,materialization:i});return s&&this.engine._popEvalContext(),a??this.engine.function(this._operator,o)}}_computeValueAsync(e){return async()=>{if(!this.isValid||!this._def)return this;let t=e?.numericApproximation??!1;if(ne(this._def))return Ef(this,this._def.value,e);let i=this._def.operator;if(i?.broadcastable&&this.ops.some(l=>pe(l))){let l=Is(this._ops);if(!l)return this.engine.Nothing;let c=[];for(;;){let{done:f,value:d}=l.next();if(f)break;c.push(this.engine._fn(this.operator,d).evaluateAsync(e))}return c.length===0?this.engine.Nothing:c.length===1?c[0]:Promise.all(c).then(f=>this.engine._fn("List",f))}let r=await yf(this,async l=>await l.evaluateAsync(e)),o=this._localScope!==void 0||e?.withArguments;if(o&&(this.engine._pushEvalContext(this._localScope??{parent:this.engine.context?.lexicalScope,bindings:new Map}),e?.withArguments))for(let[l,c]of Object.entries(e.withArguments))this.engine.context.values[l]=c;let s=this.engine,a={numericApproximation:t,engine:s,signal:e?.signal,eager:e?.materialization},u=i.evaluateAsync?.(r,a)??i.evaluate?.(r,a);return o&&this.engine._popEvalContext(),Promise.resolve(u).then(l=>l??s.function(this._operator,r))}}};function dg(n){if(!n.isValid)return"error";if(n.operator==="Function"){let i=n.ops[0].type,r=n.ops.slice(1);return A(`(${r.map(o=>"unknown").join(", ")}) -> ${i}`,n.engine._typeResolver)}let e=n.operatorDefinition;if(e){let t=e.signature instanceof S?e.signature.type:typeof e.signature=="string"?A(e.signature,n.engine._typeResolver):e.signature,i=We(t)??"unknown";if(typeof e.type=="function"){let r=e.type(n.ops,{engine:n.engine});r&&(r instanceof S?i=r.type:i=A(r,n.engine._typeResolver)??i)}return i}return n.valueDefinition?We(n.valueDefinition.type.type)??"unknown":"unknown"}function pg(n,e){return()=>{if(n._deadline===void 0){n._deadline=Date.now()+n.timeLimit;let t=e();return n._deadline=void 0,t}return e()}}function mg(n,e){return async()=>{if(n._deadline===void 0){n._deadline=Date.now()+n.timeLimit;let t=await e();return n._deadline=void 0,t}return e()}}function Ef(n,e,t){let i=e.isConstant?e.value:n.engine._getSymbolValue(n.operator);if(i&&!i.type.matches("function"))return i.isValid?n.engine.typeError("function",i.type,i.toString()):n;let r=n.ops.map(o=>o.evaluate(t));return!i||i.type.isUnknown?n.engine.function(n.operator,r):An(i,r)}function gg(n,e,t){if(!n.isValid||t?.materialization===!1)return n;let i=t?.materialization??!1;typeof i=="boolean"&&(i=fg);let r=n.isIndexedCollection,o=n.isFiniteCollection,s=[];if(!n.isEmptyCollection)if(!r||!o){let u=typeof i=="number"?i:i[0],l=n.each();for(let c of l){if(s.length===u){l.next().done||s.push(n.engine.symbol("ContinuationPlaceholder"));break}s.push(c.evaluate(t))}}else{let[u,l]=typeof i=="number"?[Math.ceil(i/2),i-Math.ceil(i/2)]:i,c=1,f=n.each();for(let p of f)if(s.push(p.evaluate(t)),c+=1,c>u)break;let d=n.xsize;if(d===void 0||d<=u)(d===void 0||s.length<d)&&s.push(n.engine.symbol("ContinuationPlaceholder"));else{let p=Math.max(u+1,d-l+1);for(d>u+l&&s.push(n.engine.symbol("ContinuationPlaceholder")),c=p;c<=d;){let x=n.at(c);if(!x)break;s.push(x.evaluate(t)),c+=1}}}let a=e.collection?.elttype?.(n);return a&&E(a,"tuple<string, any>")?n.engine.function("Dictionary",s):r?n.engine._fn("List",s):n.engine.function("Set",[...s])}var bt=class n extends W{[Symbol.toStringTag]="[BoxedString]";_string;_utf8Buffer;_unicodeScalarValues;constructor(e,t,i){super(e,i),this._string=t.normalize()}get json(){return Ge(this._string)&&!tn(this._string)?this._string:`'${this._string}'`}get hash(){return cn("String"+this._string)}get operator(){return"String"}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(e){}get value(){return this}get type(){return S.string}get complexity(){return 19}get string(){return this._string}get buffer(){if(this._utf8Buffer===void 0){let e=new TextEncoder;this._utf8Buffer=e.encode(this._string)}return this._utf8Buffer}get unicodeScalars(){return this._unicodeScalarValues===void 0&&(this._unicodeScalarValues=hg(this._string)),this._unicodeScalarValues}match(e,t){return Xn(e)||(e=this.engine.box(e,{canonical:!1})),$n(e)?{[Fn(e)]:this}:e instanceof n&&this._string===e._string?{}:null}};function hg(n){let e=[];for(let t=0;t<n.length;t++){let i=n.codePointAt(t);e.push(i),i>65535&&t++}return e}var Sr=class n extends W{[Symbol.toStringTag]="[BoxedDictionary]";_keyValues={};_type;constructor(e,t,i){super(e,i?.metadata),t instanceof W?this._initFromExpression(t,i):this._initFromRecord(t,i)}_initFromRecord(e,t){for(let i in e){if(typeof i!="string")throw new Error(`Dictionary keys must be strings, but got ${typeof i}`);if(i.length===0)throw new Error("Dictionary keys must not be empty strings");e[i]instanceof W?this._keyValues[i]=e[i]:this._keyValues[i]=this.engine.box(e[i],t)}}_initFromExpression(e,t){if(e instanceof n){Object.assign(this._keyValues,e._keyValues);return}if(e.operator==="Tuple"||e.operator==="Pair"||e.operator==="KeyValuePair"){if(e.nops!==2)throw new Error(`Expected a key/value pair, got ${e.nops} elements`);let[i,r]=e.ops,o;if(i.string)o=i.string;else if(i.symbol)o=i.symbol;else throw new Error(`Expected a string key, got ${i.type}`);this._keyValues[o]=r.canonical;return}if(e.operator==="Dictionary"){for(let i of e.ops)if(i.operator==="KeyValuePair"||i.operator==="Pair"||i.operator==="Tuple"){let[r,o]=i.ops,s;if(r.string)s=r.string;else if(r.symbol)s=r.symbol;else return;this._keyValues[s]=o.canonical}else throw new Error(`Expected a key/value pair, got ${i.type}`);return}}get json(){return["Dictionary",{dict:Object.fromEntries(Object.entries(this._keyValues).map(([e,t])=>[e,t.json]))}]}get hash(){return cn("Dictionary"+JSON.stringify(this._keyValues))}get operator(){return"Dictionary"}get type(){if(this._type)return this._type;let e=oe(...Object.values(this._keyValues).map(t=>t.type.type));return this._type=this.engine.type(`dictionary<${e}>`),this._type}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(e){}get value(){}get complexity(){return 1e3}get isCollection(){return!0}get isIndexedCollection(){return!1}get isLazyCollection(){return!1}xcontains(e){}get xsize(){return Object.keys(this._keyValues).length}get isEmptyCollection(){return Object.keys(this._keyValues).length===0}get isFiniteCollection(){return!0}each(){let e=this.engine;return function*(t){for(let[i,r]of Object.entries(t._keyValues))yield e.tuple(e.string(i),r)}(this)}get(e){return this._keyValues[e]}has(e){return this._keyValues.hasOwnProperty(e)}get keys(){return Object.keys(this._keyValues)}get entries(){return Object.entries(this._keyValues)}get values(){return Object.values(this._keyValues)}match(e,t){if($n(e))return{[Fn(e)]:this};if(!(e instanceof n))return null;let i=null,r=Object.keys(e._keyValues);for(let o of r){if(!this._keyValues.hasOwnProperty(o))return null;let s=this._keyValues[o],a=e._keyValues[o];if(!s.match(a))return null;if($n(e._keyValues[o])){let u=Fn(e._keyValues[o]);u&&(i={...i??{},[u]:s})}}return i}};function Ma(n,e,t){if(e instanceof W)return e;if(e=V(e),typeof e=="string")return Bn(n,e,t);if(Array.isArray(e)){let[i,...r]=e;return new he(n,i,r.map(o=>Ma(n,o,t)),{canonical:!1})}if(typeof e=="object"){if("fn"in e)return Ma(n,e.fn,t);if("str"in e)return new bt(n,e.str);if("sym"in e)return Bn(n,e.sym,t);if("num"in e)return Bn(n,e.num,t)}return Bn(n,e,t)}function Do(n,e,t,i){if(i=i?{...i}:{},"canonical"in i||(i.canonical=!0),!Te(e))throw new Error(`Unexpected operator: "${e}" is not a valid symbol: ${nn(e)}`);let r=i.structural??!1;if(e==="Hold")return new he(n,"Hold",[Ma(n,t[0],i)],{...i,canonical:!0,structural:r});if(e==="Error"||e==="ErrorCode")return new he(n,e,t.map(s=>n.box(s,{canonical:!1})),{metadata:i?.metadata,canonical:!0});if(e==="Number"&&t.length===1)return Bn(n,t[0],i);if(r===!1&&i.canonical===!0){if((e==="Divide"||e==="Rational")&&t.length===2){let s=Qn(t[0]);if(s!==null){let a=Qn(t[1]);if(a!==null)return n.number([s,a],i)}e="Divide"}if(e==="Complex"){if(t.length===1){let s=t[0];if(s instanceof W&&s.isNumberLiteral)return n.number(n.complex(0,s.re),i);let a=R(t[0]);return a!==null&&a!==0?n.number(n.complex(0,a),i):n.box(s).mul(n.I)}if(t.length===2){let s=t[0]instanceof W?t[0].re:R(t[0]),a=t[1]instanceof W?t[1].re:R(t[1]);return a!==null&&s!==null&&!isNaN(a)&&!isNaN(s)?a===0&&s===0?n.Zero:a!==0?n.number(n._numericValue({re:s,im:a}),i):Bn(n,t[0],i):Bn(n,t[0],i).add(Bn(n,t[1],i).mul(n.I))}throw new Error("Expected one or two arguments with Complex expression")}if(e==="Negate"&&t.length===1){let s=t[0];if(typeof s=="number")return n.number(-s,i);if(s instanceof M)return n.number(s.neg(),i);let a=n.box(s,i),u=a.numericValue;if(u!==null)return n.number(typeof u=="number"?-u:u.neg(),i);t=[a]}}return i.canonical===!0?yg(n,e,t,i.metadata,i.scope):Ft(new he(n,e,t.map(s=>Bn(n,s,{canonical:i.canonical,structural:r,scope:i.scope})),{metadata:i.metadata,canonical:!1,structural:r,scope:i.scope}),i.canonical??!1,i.scope)}function Bn(n,e,t){if(e==null)return n.error("missing");if(e instanceof j)return bg(n,e);if(e instanceof W)return Ft(e,t?.canonical??!0,t?.scope);t=t?{...t}:{},"canonical"in t||(t.canonical=!0);let i=t.canonical===!0,r=t.structural??!1;if(Array.isArray(e)){if(typeof e[0]!="string")throw new Error(`The first element of an array should be a string (the function name): ${JSON.stringify(e,void 0,4)}`);return Ft(Do(n,e[0],e.slice(1),{canonical:i,structural:r,scope:t?.scope}),t?.canonical??!0,t?.scope)}if(typeof e=="number"||e instanceof M||e instanceof q)return n.number(e);if(typeof e=="string"){if(Ge(e)){let o=T(e);if(!o||!Te(o))return n.error("invalid-symbol",e);let s=i||t.canonical!==!1;return n.symbol(o,{canonical:s})}return tn(e)?n.number(e):(Hr(e),new bt(n,F(e)))}if(typeof e=="object"){if("fn"in e){let[o,...s]=e.fn;return Ft(Do(n,o,s,{canonical:i,structural:r}),t.canonical,t.scope)}if("str"in e)return new bt(n,e.str);if("sym"in e)return n.symbol(e.sym,{canonical:i});if("num"in e)return n.number(e,{canonical:i});if("dict"in e)return new Sr(n,e.dict,{canonical:i});throw new Error(`Unexpected MathJSON object: ${JSON.stringify(e,void 0,4)}`)}return n.symbol("Undefined")}function yg(n,e,t,i,r){let o=xg(n,e,t,i,r);if(o)return o;if(e==="List"){let f=t.map(p=>n.box(p,{canonical:!1})),d=Hc("List",f);return d&&d.dtype?new br(n,{ops:Qe(n,f,r),shape:d.shape,dtype:d.dtype},{metadata:i}):new he(n,"List",Qe(n,f,r),{canonical:!0})}if(e==="Dictionary"){let f=t.map(d=>n.box(d,{canonical:!1}));return new Sr(n,n._fn("Dictionary",f),{canonical:!0})}let s=n.lookupDefinition(e);if(!s)return n.declare(e,{type:"function",inferred:!0}),new he(n,e,Q(zt(n,t)),{metadata:i,canonical:!0});if(ne(s))return new he(n,e,Q(zt(n,t)),{metadata:i,canonical:!0});let a=s.operator;if(r??=a.scoped?{parent:n.context.lexicalScope,bindings:new Map}:void 0,a.lazy){let f=t.map(d=>n.box(d,{canonical:!1}));if(a.canonical){try{if(o=a.canonical(f,{engine:n,scope:r}),o)return o}catch(d){console.error(d.message)}return o=new he(n,e,f,{metadata:i,canonical:!1}),o}return o=new he(n,e,yi(n,f,a.signature.type,a.lazy,a.broadcastable)??f,{metadata:i,canonical:!0,scope:r}),o}let u=t.map(f=>n.box(f));if(a.canonical){try{let d=a.canonical(u,{engine:n,scope:r});if(d)return d}catch(d){console.error(d.message)}return new he(n,e,u,{metadata:i,canonical:!1})}let l=Q(u,a.associative?e:void 0),c=yi(n,l,a.signature.type,a.lazy,a.broadcastable);if(c)return new he(n,e,c,{metadata:i,canonical:!0,scope:r});if(l.length===1&&l[0].operator===e){if(a.involution)return l[0].op1;if(a.idempotent)return new he(n,e,u[0].ops,{metadata:i,canonical:!0,scope:r})}return new he(n,e,Ji(e,l),{metadata:i,canonical:!0,scope:r})}function xg(n,e,t,i,r){let o=[];if(e==="Add"||e==="Multiply")o=He(n,zt(n,t,r),{flatten:e});else if(e==="Negate"||e==="Square"||e==="Sqrt"||e==="Exp")o=He(n,zt(n,t,r),1);else if(e==="Ln"||e==="Log")o=He(n,zt(n,t,r)),o.length===0&&(o=[n.error("missing")]);else if(e==="Power"||e==="Root")o=He(n,zt(n,t,r),2);else if(e==="Divide")o=He(n,zt(n,t,r)),o.length===0&&(o=[n.error("missing"),n.error("missing")]),o.length===1&&(o=[o[0],n.error("missing")]);else return null;if(!o.every(s=>s.isValid))return new he(n,e,o,{metadata:i,canonical:!0});if(e==="Add")return Ke(n,o);if(e==="Negate")return cc(o[0]);if(e==="Multiply")return _e(n,o);if(e==="Divide")return o.length===2?un(...o):o.slice(1).reduce((s,a)=>un(s,a),o[0]);if(e==="Exp")return Kn(n.E,o[0]);if(e==="Square")return Kn(o[0],n.number(2));if(e==="Power")return Kn(o[0],o[1]);if(e==="Root")return wt(o[0],o[1]);if(e==="Sqrt")return wt(o[0],2);if(e==="Ln"||e==="Log"){if(o.length>0){if(o[0].is(1))return n.Zero;if(o.length===1)return new he(n,e,o,{metadata:i,canonical:!0})}return new he(n,"Log",o,{metadata:i,canonical:!0})}return null}function bg(n,e){if(e.isZero)return n.Zero;if(e.isOne)return n.One;if(e.isNegativeOne)return n.NegativeOne;if(e.isNaN)return n.NaN;if(e.isNegativeInfinity)return n.NegativeInfinity;if(e.isPositiveInfinity)return n.PositiveInfinity;if(e=e.asExact??e,!e.isExact){let o=e.im;return o===0?n.number(e.bignumRe??e.re):e.re===0?n.number(n.complex(0,o)):e.bignumRe!==void 0&&!Mt(e.bignumRe)?Ke(n,[n.number(e.bignumRe),n.number(n.complex(0,o))]):n.number(n.complex(e.re,e.im))}let t=[],i=e;if(i.sign!==0)if(i.radical===1)t.push(n.number(i.rational));else{let o=i.rational,s=n.function("Sqrt",[n.number(i.radical)]);if(Ae(o))t.push(s);else{let[a,u]=o;u===1?a===1?t.push(s):t.push(n.function("Multiply",[n.number(a),s])):a===1?t.push(n.function("Divide",[s,n.number(u)])):t.push(n.function("Divide",[n.function("Multiply",[n.number(a),s]),n.number(u)]))}}let r;return e.im===0?t.length===0?n.Zero:(r=t.length===1?t[0]:_e(n,t),r):t.length===0?n.number(n.complex(0,e.im)):(r=t.length===1?t[0]:_e(n,t),Ke(n,[r,n.number(n.complex(0,e.im))]))}function zt(n,e,t){return e.every(i=>i instanceof W&&i.isCanonical)?e:e.map(i=>n.box(i,{scope:t}))}var Tr=class n{_items;constructor(e){e?e instanceof n?this._items=new Map(e._items):this._items=new Map(e):this._items=new Map}has(e){for(let t of this._items.keys())if(t.isSame(e))return!0;return!1}get(e){for(let[t,i]of this._items)if(t.isSame(e))return i}clear(){this._items.clear()}set(e,t){for(let i of this._items.keys())if(i.isSame(e)){this._items.set(i,t);return}this._items.set(e,t)}delete(e){this._items.delete(e)}[Symbol.iterator](){return this._items.entries()}entries(){return this._items.entries()}};var qe=class extends W{_value;_hash;constructor(e,t,i){super(e,i?.metadata),t instanceof j||typeof t=="number"?this._value=t:this._value=e._numericValue(t)}get hash(){return this._hash??=cn(this._value.toString()),this._hash}get json(){let e=this._value;return typeof e=="number"?Number.isNaN(e)?"NaN":Number.isFinite(e)?e:e>0?"PositiveInfinity":"NegativeInfinity":e.toJSON()}get operator(){return"Number"}get isPure(){return!0}get isCanonical(){return!0}set isCanonical(e){}get complexity(){return 1}valueOf(){return typeof this._value=="number"?this._value:this._value.N().valueOf()}get numericValue(){return this._value}get isNumberLiteral(){return!0}get re(){return typeof this._value=="number"?this._value:this._value.re}get im(){return typeof this._value=="number"?0:this._value.im}get bignumRe(){if(typeof this._value!="number")return this._value.bignumRe}get bignumIm(){return typeof this._value=="number"?this.engine._BIGNUM_ZERO:this.engine.bignum(this._value.im)}neg(){let e=this._value;return e===0?this:typeof e=="number"?this.engine.number(-e):this.engine.number(e.neg())}inv(){return typeof this._value=="number"?Math.abs(this._value)===1?this:Number.isInteger(this._value)?this.engine.number(this.engine._numericValue({rational:[1,this._value]})):this.engine.number(1/this._value):Math.abs(this.re)===1&&this.im===0?this:this.engine.number(this._value.inv())}abs(){return this.isPositive?this:typeof this._value=="number"?this.engine.number(-this._value):this.engine.number(this._value.abs())}add(e){let t=this.engine;return this.is(0)?t.box(e):typeof e=="number"?e===0?this:typeof this._value=="number"?t.number(this._value+e):t.number(this._value.add(e)):e.numericValue!==null?typeof this._value=="number"?typeof e.numericValue=="number"?t.number(this._value+e.numericValue):t.number(e.numericValue.add(this._value)):t.number(this._value.add(e.numericValue)):H(this,e.canonical)}mul(e){if(this.is(1))return this.engine.box(e);if(this.is(-1))return this.engine.box(e).neg();let t=this.engine;return typeof e=="number"?e===1?this:e===0||this.is(0)?this.engine.Zero:e===-1?this.neg():t.number(typeof this._value=="number"?this._value*e:this._value.mul(e)):typeof this._value=="number"&&typeof e=="number"?t.number(this._value*e):e instanceof j?this.is(1)?t.number(e):this.is(-1)?t.number(e.neg()):t.number(e.mul(this._value)):e.numericValue!==null?t.number(t._numericValue(this._value).mul(e.numericValue)):ae(this,e)}div(e){return hi(this,e)}pow(e){return Ie(this,e,{numericApproximation:!1})}root(e){if(typeof e=="number"){if(e===0)return this.engine.NaN;if(e===1)return this;if(e===-1)return this.inv();if(e===2)return this.sqrt();if(this.isNegative){if(e%2===1)return this.neg().root(e).neg();if(e%2===0)return this.neg().root(e)}}else{if(e=e.canonical,e.is(0))return this.engine.NaN;if(e.is(1))return this;if(e.is(-1))return this.inv();if(e.is(2))return this.sqrt();if(this.isNegative){if(e.isOdd)return this.neg().root(e).neg();if(e.isEven)return this.neg().root(e)}}let t=typeof e=="number"?e:e.re;if(Number.isInteger(t))if(typeof this._value=="number"){let i=this._value**(1/t);if(Number.isInteger(i))return this.engine.number(i)}else{let i=this._value.root(t);if(E(i.type,"integer"))return this.engine.number(i)}return this.engine._fn("Root",[this,this.engine.box(e)])}sqrt(){return typeof this._value=="number"?this._value===0||this._value===1?this:this._value===-1?this.engine.I:this._value>0&&Number.isInteger(this._value)&&this._value<$?this.engine.number(this.engine._numericValue({radical:this._value})):this.engine.number(this.engine._numericValue(this._value).sqrt()):this.is(0)||this.is(1)?this:this.engine.number(this._value.sqrt())}ln(e){let t=e?this.engine.box(e):void 0;if(this.is(0))return this.engine.NegativeInfinity;if(t&&this.isSame(t))return this.engine.One;if((!t||t.symbol==="ExponentialE")&&this.symbol==="ExponentialE")return this.engine.One;let i=this.re;if(Number.isInteger(i)&&i>0){let r=this.engine,[o,s]=Yt(i,3);if(o!==1)return r.number(o).ln(t).mul(3).add(r.number(s).ln(t));if([o,s]=Yt(i,2),o!==1)return r.number(o).ln(t).mul(2).add(r.number(s).ln(t))}return t&&t.isInteger?typeof this._value=="number"?this.engine.number(Math.log(this._value)/Math.log(t.re)):this.engine.number(this._value.ln(t.re)):t===void 0?typeof this._value=="number"?this.engine.number(Math.log(this._value)):this.engine.number(this._value.ln()):this.engine._fn("Ln",[this])}get value(){return this}get type(){return typeof this._value=="number"?Number.isNaN(this._value)?S.number:Number.isFinite(this._value)?Number.isInteger(this._value)?S.finite_integer:S.finite_real:S.non_finite_number:new S(this._value.type,this.engine._typeResolver)}get sgn(){if(this._value===0)return"zero";let e;return typeof this._value=="number"?e=Math.sign(this._value):e=this._value.sgn(),e===void 0||Number.isNaN(e)?"unsigned":e===0?"zero":e>0?"positive":"negative"}get numerator(){return typeof this._value=="number"?this:this.engine.number(this._value.numerator)}get denominator(){return typeof this._value=="number"?this.engine.One:this.engine.number(this._value.denominator)}get numeratorDenominator(){if(typeof this._value=="number")return[this,this.engine.One];let e=this.engine;return[e.number(this._value.numerator),e.number(this._value.denominator)]}subs(e,t){return this.isStructural?this:this.structural.subs(e,t)}replace(e,t){return et(this.structural,e,t).at(-1)?.value??null}match(e,t){return Ni(this.structural,e,t)}get isPositive(){return typeof this._value=="number"?!Number.isNaN(this._value)&&this._value>0:_i(this.sgn)}get isNonNegative(){return typeof this._value=="number"?!Number.isNaN(this._value)&&this._value>=0:Si(this.sgn)}get isNegative(){return typeof this._value=="number"?!Number.isNaN(this._value)&&this._value<0:Ti(this.sgn)}get isNonPositive(){return typeof this._value=="number"?!Number.isNaN(this._value)&&this._value<=0:Bi(this.sgn)}get isOdd(){if(this.is(1)||this.is(-1))return!0;if(this.is(0))return!1;if(!this.isFinite||!this.isInteger)return;if(typeof this._value=="number")return this._value%2!==0;let[e,t]=[this._value.numerator,this._value.denominator];return t.isOne?e.re%2!==0:e.re%2!==0&&t.re%2===0}get isEven(){let e=this.isOdd;return e!==void 0?!e:void 0}get isInfinity(){return typeof this._value=="number"?!Number.isFinite(this._value)&&!Number.isNaN(this._value):Number.isFinite(this._value.im)?this._value.isPositiveInfinity||this._value.isNegativeInfinity:!0}get isNaN(){return typeof this._value=="number"?Number.isNaN(this._value):this._value.isNaN}get isFinite(){return this.isInfinity===!1&&this.isNaN===!1}get isNumber(){return!0}get isInteger(){return typeof this._value=="number"?Number.isInteger(this._value):E(this._value.type,"integer")}get isRational(){return typeof this._value=="number"?Number.isInteger(this._value):E(this._value.type,"rational")}get isReal(){return typeof this._value=="number"?!0:E(this._value.type,"real")}is(e){return typeof e=="number"?typeof this._value=="number"?Object.is(this._value,e):this._value.isNaN?Object.is(e,NaN):this._value.eq(e):typeof e=="bigint"?typeof this._value=="number"?ie(this._value)===e:this._value.eq(this.engine._numericValue(e)):typeof e=="boolean"?!1:this.isSame(e)}get canonical(){return this}get isStructural(){return typeof this._value=="number"||this.type.matches("rational")?!0:!(this._value instanceof K)}get structural(){return this.isStructural?this:this.engine.box(this.json,{canonical:!1,structural:!0})}toNumericValue(){let e=this._value;return typeof e=="number"?[this.engine._numericValue(e),this.engine.One]:[e,this.engine.One]}simplify(e){return xt(this.structural,e).at(-1).value??this}evaluate(e){return e?.numericApproximation?this.N():this}N(){let e=this._value;if(typeof e=="number")return this;let t=e.N();return e===t?this:this.engine.number(t)}};function Mo(n,e){if(e==null)return NaN;if(e instanceof j)return e;if(typeof e=="number")return Number.isInteger(e)&&e>=-$&&e<=$||!Number.isFinite(e)?e:n._numericValue(e);if(e instanceof M){let t=e.toNumber();return e.isInteger()&&Math.abs(t)<=$?t:e.isNaN()?NaN:e.isFinite()?n._numericValue(e):t>0?1/0:-1/0}if(typeof e=="bigint")return e>=-$&&e<=$?Number(e):n._numericValue(e);if(e instanceof q)return e.im===0?Mo(n,e.re):e.isNaN()?NaN:!e.isFinite()&&e.im===0?e.re>0?1/0:-1/0:n._numericValue({re:e.re,im:e.im});if(typeof e=="object"&&"num"in e){if(typeof e.num=="number")return Mo(n,e.num);if(typeof e.num!="string")throw new Error("MathJSON `num` property should be a string of digits");return vf(n,e.num)}if(typeof e=="string")return vf(n,e);if(e[1]==0)return NaN;if(typeof e[1]=="number"&&!Number.isFinite(e[1]))return Number.isFinite(e[0])?0:NaN;if(typeof e[0]=="number"&&!Number.isFinite(e[0])){let t=e[0]>0?1:-1;return e[0]>0?t>0?1/0:-1/0:e[0]<0?t>0?-1/0:1/0:NaN}return n._numericValue(e)}function vf(n,e){if(e=e.toLowerCase(),/[0-9][nd]$/.test(e)&&(e=e.slice(0,-1)),e=e.replace(/[\u0009-\u000d\u0020\u00a0]/g,""),e==="nan")return NaN;if(e==="infinity"||e==="+infinity"||e==="oo"||e==="+oo")return Number.POSITIVE_INFINITY;if(e==="-infinity"||e==="-oo")return Number.NEGATIVE_INFINITY;if(e==="0")return 0;if(e==="1")return 1;if(e==="-1")return-1;if(/\([0-9]+\)/.test(e)){let[i,r,o,s]=e.match(/(.+)\(([0-9]+)\)(.+)?$/)??[];e=r+o.repeat(Math.ceil(n.precision/o.length))+(s??"")}let t=ie(e);return t!==null?t>=-$&&t<=$?Number(t):n._numericValue(t):n._numericValue(n.bignum(e))}var Gt=class extends W{_hash;_id;_def;constructor(e,t,i){super(e,i?.metadata),Te(t),`${t}${nn(t)}`,this._id=t,this._def=i?.def}get json(){return Ge(this._id)?this._id:{sym:this._id}}get hash(){return this._hash??=cn(this._id),this._hash}get isPure(){return!0}get isConstant(){let e=this._def;return(ne(e)&&e?.value.isConstant)??!1}bind(){}reset(){}get isCanonical(){return this._def!==void 0}set isCanonical(e){throw new Error("Setting the isCanonical property is not allowed. Use the canonical() method instead.")}get canonical(){return this._def?this:this.engine.symbol(this._id)}is(e){return e===!0?this.symbol==="True"||this.value?.symbol==="True":e===!1?this.symbol==="False"||this.value?.symbol==="False":e instanceof W&&e.symbol?this.symbol===e.symbol:this.value?.is(e instanceof W?e.value:e)??!1}toNumericValue(){this.isCanonical;let e=this.engine;return this.symbol==="ImaginaryUnit"?[e._numericValue({re:0,im:1}),e.One]:this.symbol==="PositiveInfinity"||this.isInfinity&&this.isPositive?[e._numericValue(1/0),e.One]:this.symbol==="NegativeInfinity"||this.isInfinity&&this.isNegative?[e._numericValue(-1/0),e.One]:this.symbol==="NaN"?[e._numericValue(NaN),e.One]:[e._numericValue(1),this]}neg(){return Lt(this)}inv(){return this.engine._fn("Divide",[this.engine.One,this])}abs(){return this.isNonNegative?this:this.isNonPositive?this.neg():this.engine._fn("Abs",[this])}add(e){return e===0?this:H(this,this.engine.box(e))}mul(e){if(e===1)return this;if(e===-1)return this.neg();if(e===0&&!this.isNaN)return this.engine.Zero;if(e instanceof j){if(e.isOne)return this;if(e.isNegativeOne)return this.neg();if(e.isZero&&!this.isNaN)return this.engine.Zero}return ae(this,this.engine.box(e))}div(e){return hi(this,e)}pow(e){return Ie(this,e,{numericApproximation:!1})}root(e){let t=typeof e=="number"?e:e.im===0?e.re:void 0,i=this.engine;return this.symbol==="ComplexInfinity"||t===0?i.NaN:t===1?this:t===2?this.sqrt():t===-1?this.inv():i._fn("Root",[this,i.box(e)])}sqrt(){let e=this.engine;return this.symbol==="ComplexInfinity"?e.NaN:this.is(0)?this:this.is(1)?this.engine.One:this.is(-1)?e.I:e._fn("Sqrt",[this])}ln(e){let t=e?this.engine.box(e):void 0;return this.is(0)?this.engine.NegativeInfinity:(!t||t.symbol==="ExponentialE")&&this.symbol==="ExponentialE"?this.engine.One:t?t.re===10?this.engine._fn("Log",[this]):this.engine._fn("Log",[this,t]):this.engine._fn("Ln",[this])}solve(e){let t=fr(e);return t.length!==1?null:t.includes(this.symbol)?[this.engine.Zero]:null}get complexity(){return 7}get operator(){return"Symbol"}get symbol(){return this._id}get baseDefinition(){return this.valueDefinition??this.operatorDefinition}get valueDefinition(){if(ne(this._def))return this._def.value}get operatorDefinition(){if(Z(this._def))return this._def.operator}infer(e,t="narrow"){if(!this._def)return!1;let i=this._def;if(ne(i))return i.value.inferredType||i.value.type.isUnknown?(i.value.isConstant,i.value.type=this.engine.type(t==="widen"?oe(i.value.type.type,e):vt(i.value.type.type,e)),!0):!1;if(Z(i)){let r=this.engine.type(t==="widen"?oe(i.operator.signature.type,e):vt(i.operator.signature.type,e));return r.matches("function")?(i.operator.signature=r,!0):(delete i.operator,i.value={value:{type:r}},!0)}return!1}get _value(){if(!(!this._def||Z(this._def)))return this._def.value.isConstant?this._def.value.value:this.engine._getSymbolValue(this._id)}get value(){return Z(this._def)?this.engine._fn("Operator",[this.engine.string(this._id)]):this._value}set value(e){if(!this._def)throw new Error(`Cannot set value of non-canonical ${this._id}`);let t=this.engine;t.forget(this._id);let i;if(typeof e=="boolean"&&(e=e?t.True:t.False),typeof e=="string"&&(e=t.string(e)),typeof e=="object")if("re"in e&&"im"in e)e=t.complex(e.re??0,e.im);else if("num"in e&&"denom"in e)e=t.number([e.num,e.denom]);else if(Array.isArray(e))e=t._fn("List",e.map(r=>t.box(r)));else throw new Error(`Invalid value for symbol ${this._id}: ${e}`);if(e!==void 0&&(i=t.box(e).evaluate()),i?.type.matches("function")){delete this._def.value,this._def.operator={signature:i.type,evaluate:i};return}if(ne(this._def)&&this._def.value.isConstant)throw new Error(`The value of the constant "${this._id}" cannot be changed`);t._setSymbolValue(this._id,i)}get type(){let e=this._def;return ne(e)?e.value.type:Z(e)?e.operator.signature:S.unknown}set type(e){if(!this._def)throw new Error(`Cannot set type of non-canonical symbol "${this._id}"`);if(this._id[0]==="_")throw new Error(`The type of the wildcard "${this._id}" cannot be changed`);this.engine.forget(this._id),typeof e=="string"?e=A(e):e instanceof S&&(e=e.type),e==="function"||Gr(e)?Z(this._def)?this._def.operator.signature=e:(delete this._def.value,this._def.operator={signature:e}):Z(this._def)?(delete this._def.operator,this._def.value={type:e}):this._def.value.type=e}has(e){return typeof e=="string"?this._id===e:e.includes(this._id)}match(e,t){return Ni(this,e,t)}get sgn(){return this.value?.sgn}get isOdd(){return this.value?.isOdd}get isEven(){return this.value?.isEven}get isFinite(){return this.value?.isFinite}get isInfinity(){return this.value?.isInfinity}get isNaN(){return this.value?.isNaN}get isPositive(){return _i(this.sgn)}get isNonPositive(){return Bi(this.sgn)}get isNegative(){return Ti(this.sgn)}get isNonNegative(){return Si(this.sgn)}get isFunction(){if(!this.type.isUnknown)return this.type.matches("function")}get isNumber(){let e=this.type;if(!e.isUnknown)return e.matches("number")}get isInteger(){let e=this.type;if(!e.isUnknown)return e.matches("integer")}get isRational(){let e=this.type;if(!e.isUnknown)return e.matches("rational")}get isReal(){let e=this.type;if(!e.isUnknown)return e.matches("real")}get re(){return this.value?.re??NaN}get im(){return this.value?.im??NaN}get bignumRe(){return this.value?.bignumRe}get bignumIm(){return this.value?.bignumIm}simplify(e){return xt(this,e).at(-1)?.value??this}evaluate(e){let t=this.valueDefinition;if(!t)return this;let i=t.holdUntil;if(t.isConstant){if(e?.numericApproximation){if(i==="never"||i==="evaluate"||i==="N")return t.value?.N()??this}else if(i==="never"||i==="evaluate")return t.value?.evaluate(e)??this}else if(i==="never"||i==="evaluate"||i==="N"&&e?.numericApproximation){let r=this.engine._getSymbolValue(this._id)??this;return r.operator==="Unevaluated"&&(r=r.evaluate(e)??this),r}return this}N(){let e=this.valueDefinition;return e&&e.holdUntil==="never"?this:e?.value?.N()??this}replace(e,t){return et(this,e,t).at(-1)?.value??null}subs(e,t){let i=t?.canonical??this.isCanonical;return e[this._id]===void 0?i?this.canonical:this:this.engine.box(e[this._id],{canonical:i})}get _asCollection(){if(ne(this._def))return this._def.value.collection}get isCollection(){return this._asCollection?.iterator!==void 0||(this._value?.isCollection??!1)}get isIndexedCollection(){return this._asCollection?.at!==void 0||(this._value?.isIndexedCollection??!1)}get isLazyCollection(){return this._asCollection?.isLazy?.(this._value??this)??this._value?.isLazyCollection??!1}xcontains(e){return this._asCollection?.contains?.(this._value??this,e)??this._value?.xcontains?.(e)}get xsize(){return this._asCollection?.count(this._value??this)??this._value?.xsize??0}get isEmptyCollection(){return this._asCollection?.isEmpty?.(this._value??this)??this._value?.isEmptyCollection??this.xsize===0}get isFiniteCollection(){return this._asCollection?.isFinite?.(this._value??this)??this._value?.isFiniteCollection??isFinite(this.xsize)}each(){let e=this._asCollection?.iterator?.(this._value??this);return e?function*(){let t=e.next();for(;!t.done;)yield t.value,t=e.next()}():this._value?.each()??function*(){}()}at(e){return this._asCollection?.at?.(this._value??this,e)??this._value?.at?.(e)}get(e){return this._value?.get?.(e)}indexWhere(e){return this._asCollection?.indexWhere?this._asCollection.indexWhere(this._value??this,e):this._value?.indexWhere(e)}subsetOf(e,t){return this._asCollection?.subsetOf?.(this._value??this,e,t)??this._value?.subsetOf?.(e,t)??!1}};var _f=["\\varphi -> \\frac{1+\\sqrt{5}}{2}",Eg,vg,n=>{let e=Ze(n);return e?{value:e,because:"expand"}:void 0},n=>{if(n.operator==="Add")return{value:H(...n.ops.map(e=>e.canonical.simplify())),because:"addition"}},n=>{if(n.operator==="Negate")return{value:n.op1.neg(),because:"negation"}},n=>{if(n.operator==="Multiply")return{value:ae(...n.ops.map(e=>e.canonical.simplify())),because:"multiplication"}},n=>{if(n.operator==="Divide")return{value:n.op1.div(n.op2),because:"division"};if(n.operator==="Rational"&&n.nops===2)return{value:n.op1.div(n.op2),because:"rational"}},n=>{if(!n.op1.isNumberLiteral)return;if(n.operator==="Sqrt"){if(n.op1.isNegative)return{value:n.engine.box(["Multiply",["Sqrt",n.op1.neg()],"ImaginaryUnit"]).simplify(),because:"sqrt"};let i=n.op1.sqrt();return Nf(i.numericValue)?{value:i,because:"sqrt"}:void 0}let e=n.op1,t=n.op2;if(t.isNumberLiteral&&e.isInteger&&t.isInteger&&e.re<$&&t.re<$){if(n.operator==="Power")return{value:n.op1.pow(n.op2),because:"power"};if(n.operator==="Root"){let i=n.op1.root(n.op2);if(Nf(i.numericValue))return{value:n.op1.root(n.op2),because:"root"}}}},n=>{if(n.operator!=="Abs")return;let e=n.op1;if(e.isNonNegative)return{value:e,because:"|x| -> x"};if(e.isNegative)return{value:e.neg(),because:"|x| -> -x"}},n=>{if(n.operator!=="Sign")return;let e=n.sgn,t=n.engine;if(e!==void 0){if(e==="positive")return{value:t.One,because:"sign positive"};if(e==="negative")return{value:t.One,because:"sign negative"};if(e==="zero")return{value:t.Zero,because:"sign zero"};if(e==="unsigned")return{value:t.NaN,because:"sign unsinged"}}},n=>{if(n.operator==="Ln")return{value:n.op1.ln(n.ops[1]),because:"ln"};if(n.operator==="Log")return{value:n.op1.ln(n.ops[1]??10),because:"log"}},n=>{if(n.operator==="Max"){if(n.nops===0)return{value:n.engine.NegativeInfinity,because:"max"};if(n.nops===1)return{value:n.op1,because:"max"}}else if(n.operator==="Min"){if(n.nops===0)return{value:n.engine.PositiveInfinity,because:"min"};if(n.nops===1)return{value:n.op1,because:"min"}}else if(n.operator==="Supremum"){if(n.nops===0)return{value:n.engine.NegativeInfinity,because:"sup"};if(n.nops===1)return{value:n.op1,because:"sup"}}else if(n.operator==="Infimum"){if(n.nops===0)return{value:n.engine.PositiveInfinity,because:"inf"};if(n.nops===1)return{value:n.op1,because:"inf"}}},n=>{if(n.operator!=="Derivative")return;let e=n.engine,[t,i]=n.ops;if(n.nops===2)return{value:e.function("Derivative",[t.simplify(),i]),because:"derivative"};if(n.nops===1)return{value:e.function("Derivative",[t.simplify()]),because:"derivative"}},n=>n.operator!=="Hypot"?void 0:{value:n.engine.box(["Sqrt",["Add",["Square",n.op1],["Square",n.op2]]]).simplify(),because:"hypot(x,y) -> sqrt(x^2+y^2)"},n=>{if(n.operator!=="Congruent"||n.nops<3)return;let e=n.engine;return{value:e._fn("Equal",[e.function("Mod",[n.ops[0],n.ops[2]]).simplify(),e.function("Mod",[n.ops[1],n.ops[2]]).simplify()]).simplify(),because:"congruent"}},n=>{n.operator},n=>{if(!Sa(n))return;let e=_r(n.operator,n.op1);if(e)return{value:e,because:"constructible value"}},n=>{if(n.operator!=="InverseFunction")return;let e=Nr(n.engine,n.ops);if(e)return{value:e,because:"inverse function"}},n=>{if(n.operator!=="Arctan2")return;let[e,t]=n.ops,i=n.engine;return e.isFinite===!1&&t.isFinite===!1?{value:i.NaN,because:"arctan2"}:e.is(0)&&t.is(0)?{value:i.Zero,because:"arctan2"}:t.isFinite===!1?{value:t.isPositive?i.Zero:i.Pi,because:"arctan2"}:e.isFinite===!1?{value:e.isPositive?i.Pi.div(2):i.Pi.div(-2),because:"arctan2"}:e.is(0)?{value:t.isPositive?i.Zero:i.Pi,because:"arctan2"}:{value:i.function("Arctan",[e.div(t)]).simplify(),because:"arctan2"}},"\\arcsinh(x) -> \\ln(x+\\sqrt{x^2+1})","\\arccosh(x) -> \\ln(x+\\sqrt{x^2-1})","\\arctanh(x) -> \\frac{1}{2}\\ln(\\frac{1+x}{1-x})","\\arccoth(x) -> \\frac{1}{2}\\ln(\\frac{x+1}{x-1})","\\arcsech(x) -> \\ln(\\frac{1+\\sqrt{1-x^2}}{x})","\\arccsch(x) -> \\ln(\\frac{1}{x} + \\sqrt{\\frac{1}{x^2}+1})",nf];function Eg(n){let e=n.operator;if(!vn(e)&&!ti(e))return;let t=n,i=n.engine,r=n.op1.simplify(),o=n.op2.simplify();if(n=i.function(n.operator,[r,o]),n=gt(n)??n,Je(n.operator),n.nops===2&&!n.op2.is(0)){let s=gt(i.function(n.operator,[n.op1.sub(n.op2),i.Zero]));i.costFunction(s)<i.costFunction(n)&&(n=s)}if(!n.isSame(t))return{value:n,because:"simplify-relational-operator"}}function vg(n){return n.operator!=="List"||!n.ops.every(t=>ti(t.operator)||vn(t.operator))?void 0:{value:n.engine.function("List",n.ops.map(t=>t.simplify())),because:"simplify-system-of-equations"}}function Nf(n){return n===null?!1:typeof n=="number"?Number.isInteger(n):n.isExact}function Sf(n){if(n.operator==="Element")return Sg(n);if(n.operator==="Equal")return Ng(n);if(vn(n.operator))return _g(n);throw new Error("Unsupported assumption. Use `Element`, `Equal` or an inequality")}function Ng(n){n.operator;let e=n.unknowns;if(e.length===0){let r=n.evaluate();return r.symbol==="True"?"tautology":r.symbol==="False"?"contradiction":(n.canonical.evaluate(),"not-a-predicate")}let t=n.engine,i=n.op1.symbol;if(i&&!Bg(t,i)&&!n.op2.has(i)){let r=n.op2.evaluate();if(!r.isValid)return"not-a-predicate";let o=t.lookupDefinition(i);return!o||!ne(o)?(t.declare(i,{value:r}),"ok"):o.value.type&&!r.type.matches(o.value.type)&&!o.value.inferredType?"contradiction":"ok"}if(e.length===1){let r=e[0],o=ko(n,r);o.length===0&&t.context.assumptions.set(t.function("Equal",[n.op1.sub(n.op2),0]),!0);let s=o.length===1?o[0]:t.function("List",o),a=t.lookupDefinition(r);return!a||!ne(a)?(t.declare(r,{value:s}),"ok"):a.value.type&&!o.every(u=>!u.type||s.type.matches(u.type))?"contradiction":"ok"}return t.context.assumptions.set(n,!0),"ok"}function _g(n){let e=n.engine,t="",i,r;if(n.operator==="Less"?(i=n.op1,r=n.op2,t="<"):n.operator==="LessEqual"?(i=n.op1,r=n.op2,t="<="):n.operator==="Greater"?(i=n.op2,r=n.op1,t="<"):n.operator==="GreaterEqual"&&(i=n.op2,r=n.op1,t="<="),!t)return"internal-error";let o=i.sub(r),s=e.box([t==="<"?"Less":"LessEqual",o,0]).evaluate();if(s.symbol==="True")return"tautology";if(s.symbol==="False")return"contradiction";let a=s.unknowns;return a.length===0?"not-a-predicate":(a.length===1&&(e.lookupDefinition(a[0])||e.declare(a[0],{type:"real"})),s.operator==="Less"||s.operator,e.context.assumptions.set(s,!0),"ok")}function Sg(n){n.operator;let e=n.engine,t=Tg(n.op1);if(t.length===1){let r=n.op2.evaluate();if(!r.isValid)return"not-a-predicate";let o=ho(r);if(o==="unknown")throw new Error(`Invalid domain "${r.toString()}"`);return e.declare(t[0],o),"ok"}if(n.op1.symbol&&Tf(e,n.op1.symbol)){let r=n.op2.evaluate();if(!r.isValid)return"not-a-predicate";let o=ho(r);e.context?.lexicalScope?.bindings.has(n.op1.symbol)||e.declare(n.op1.symbol,ho(r));let s=e.lookupDefinition(n.op1.symbol);return ne(s)?s.value.type&&!E(o,s.value.type.type)?"contradiction":(s.value.type=new S(o,e._typeResolver),"ok"):Z(s)?E(o,We(s.operator.signature.type))?"ok":"contradiction":"not-a-predicate"}if(t.length>0)return e.context.assumptions.set(n,!0),"ok";let i=n.evaluate();return i.symbol==="True"?"tautology":i.symbol==="False"?"contradiction":"not-a-predicate"}function Tf(n,e){return n.lookupDefinition(e)!==void 0}function Tg(n){return n.symbols.filter(e=>!Tf(n.engine,e))}function Bg(n,e){let t=n.lookupDefinition(e);return t?!!(ne(t)&&t.value.isConstant||n._getSymbolValue(e)!==void 0):!1}var Ii=class n{True;False;Pi;E;Nothing;Zero;One;Half;NegativeOne;Two;I;NaN;PositiveInfinity;NegativeInfinity;ComplexInfinity;decimalSeparator=".";_BIGNUM_NAN;_BIGNUM_ZERO;_BIGNUM_ONE;_BIGNUM_TWO;_BIGNUM_HALF;_BIGNUM_PI;_BIGNUM_NEGATIVE_ONE;_precision;_angularUnit;_tolerance;_bignumTolerance;_negBignumTolerance;__cache={};_configurationChangeTracker=new Ur;_cost;_commonSymbols={Pi:null,True:null,False:null,All:null,Nothing:null,None:null,Undefined:null,ImaginaryUnit:null,ExponentialE:null};_commonNumbers={"-5":null,"-4":null,"-3":null,"-2":null,2:null,3:null,4:null,5:null,6:null,7:null,8:null,9:null,10:null,11:null,12:null,36:null};_evalContextStack=[];get context(){return this._evalContextStack[this._evalContextStack.length-1]}get contextStack(){return[...this._evalContextStack]}set contextStack(e){this._evalContextStack=[...e]}get _typeResolver(){let e=this;return{get names(){let t=[],i=e.context.lexicalScope;for(;i;)i.types&&t.push(...Object.keys(i.types)),i=i.parent;return t},resolve:t=>{let i=e.context.lexicalScope;for(;i;){if(i.types?.[t])return i.types[t];i=i.parent}},forward:t=>{let i={kind:"reference",name:t,alias:!1,def:void 0};return e.context.lexicalScope.types??={},e.context.lexicalScope.types[t]=i,i}}}declareType(e,t,{alias:i}={}){if(!cu(e))throw Error(`The type name "${e}" is invalid`);let r=this.context.lexicalScope;if(r.types?.[e])throw Error(`The type "${e}" is already defined in the current scope`);r.types??={},i??=!1,r.types[e]={kind:"reference",name:e,alias:i,def:void 0};let o=t instanceof S?t.type:typeof t=="string"?A(t,this._typeResolver):t;r.types[e].def=o}get trace(){return this._evalContextStack.map(e=>e.name).filter(e=>e!==void 0).reverse()}_generation=0;strict;deadline;_latexDictionaryInput;__indexedLatexDictionary;_bignum;static getStandardLibrary(e="all"){return Ta(e)}static getLatexDictionary(e="all"){return ul(e)}constructor(e){if(e!==void 0&&typeof e!="object")throw Error("Unexpected argument");this.strict=!0;let t=e?.precision??es;t==="machine"&&(t=Math.floor(kn)),this._bignum=M.clone({precision:t}),this._precision=t,this.tolerance=e?.tolerance??"auto",this._angularUnit="rad",this.Zero=new qe(this,0),this.One=new qe(this,1),this.Half=new qe(this,{rational:[1,2]}),this.NegativeOne=new qe(this,-1),this.Two=new qe(this,2),this.NaN=new qe(this,Number.NaN),this.PositiveInfinity=new qe(this,Number.POSITIVE_INFINITY),this.NegativeInfinity=new qe(this,Number.NEGATIVE_INFINITY),this.I=new qe(this,{im:1}),this.ComplexInfinity=new qe(this,{re:1/0,im:1/0}),this._reset(),this.pushScope(void 0,"system"),this.declareType("limits","expression<Limits>");for(let r of n.getStandardLibrary("domains"))Ba(this,r);let i=e?.ids??n.getStandardLibrary();for(let r of i)Ba(this,r);for(let r of Object.keys(this._commonSymbols))this._commonSymbols[r]=new Gt(this,r,{def:this.lookupDefinition(r)});this.True=this._commonSymbols.True,this.False=this._commonSymbols.False,this.Pi=this._commonSymbols.Pi,this.E=this._commonSymbols.ExponentialE,this.Nothing=this._commonSymbols.Nothing,this.pushScope(void 0,"global"),du(this)}toJSON(){return"[ComputeEngine]"}[Symbol.toStringTag]="ComputeEngine";get latexDictionary(){return this._latexDictionaryInput??n.getLatexDictionary()}set latexDictionary(e){this._latexDictionaryInput=e,this.__indexedLatexDictionary=Es(e,t=>{throw Error(typeof t.message=="string"?t.message:t.message.join(","))})}get _indexedLatexDictionary(){return this.__indexedLatexDictionary??=Es(this.latexDictionary,e=>console.error(e)),this.__indexedLatexDictionary}_reset(){this._bignum,this._generation+=1,this._BIGNUM_NEGATIVE_ONE=this.bignum(-1),this._BIGNUM_NAN=this.bignum(NaN),this._BIGNUM_ZERO=this.bignum(0),this._BIGNUM_ONE=this.bignum(1),this._BIGNUM_TWO=this.bignum(2),this._BIGNUM_HALF=this._BIGNUM_ONE.div(this._BIGNUM_TWO),this._BIGNUM_PI=this._BIGNUM_NEGATIVE_ONE.acos();for(let e of Object.values(this._commonSymbols))e?.reset();for(let e of Object.keys(this.__cache))this.__cache[e].value&&(this.__cache[e].purge?this.__cache[e].value=this.__cache[e].purge(this.__cache[e].value):delete this.__cache[e]);this._configurationChangeTracker.notifyNow()}listenToConfigurationChange(e){return this._configurationChangeTracker.listen(e)}get precision(){return this._precision}set precision(e){e==="machine"&&(e=kn),e==="auto"&&(e=es);let t=this._precision;if(e!==t){if(typeof e!="number"||e<=0)throw Error('Expected "machine" or a positive number');this._precision=Math.max(e,kn),this._bignum=this._bignum.config({precision:this._precision}),this.tolerance="auto",this._reset()}}get angularUnit(){return this._angularUnit}set angularUnit(e){if(e!==this._angularUnit){if(typeof e!="string")throw Error("Expected a string");this._angularUnit=e,this._reset()}}get timeLimit(){return this._timeLimit}set timeLimit(e){e<=0&&(e=Number.POSITIVE_INFINITY),this._timeLimit=e}_timeLimit=2e3;_deadline=void 0;get _timeRemaining(){return this.deadline===void 0?Number.POSITIVE_INFINITY:this.deadline-Date.now()}get iterationLimit(){return this._iterationLimit}set iterationLimit(e){e<=0&&(e=Number.POSITIVE_INFINITY),this._iterationLimit=e}_iterationLimit=1024;get recursionLimit(){return this._recursionLimit}set recursionLimit(e){e<=0&&(e=Number.POSITIVE_INFINITY),this._recursionLimit=e}_recursionLimit=1024;get tolerance(){return this._tolerance}set tolerance(e){e==="auto"&&(e=ns),(!Number.isFinite(e)||e<0)&&(e=Math.pow(10,-this._precision+2)),this._tolerance=e,this._bignumTolerance=this.bignum(e),this._negBignumTolerance=this.bignum(-e)}chop(e){return typeof e=="number"?Math.abs(e)<=this._tolerance?0:e:e instanceof M?e.isPositive()&&e.lte(this._bignumTolerance)||e.isNegative()&&e.gte(this._negBignumTolerance)||e.isZero()?0:e:e instanceof q&&Math.abs(e.re)<=this._tolerance&&Math.abs(e.im)<=this._tolerance?0:e}bignum(e){if(typeof e=="bigint")return new this._bignum(e.toString());try{return new this._bignum(e)}catch(t){console.error(t.message)}return this._BIGNUM_NAN}complex(e,t){return e instanceof M&&(e=e.toNumber()),t instanceof M&&(t=t.toNumber()),new q(e,t)}_numericValue(e){if(e instanceof j)return e.asExact??e;let t=r=>this.bignum(r),i=this._precision>kn?r=>new Rt(r,t):r=>new Pt(r,t);if(typeof e=="number")return Number.isInteger(e)?new K(e,i,t):i(e);if(typeof e=="bigint")return new K(e,i,t);if(Yn(e))return new K({rational:e},i,t);if(e instanceof M)return e.isInteger()&&e.e<=yu?new K(ie(e.toString()),i,t):i(e);if(e instanceof q)return e.im===0?this._numericValue(e.re):i({re:e.re,im:e.im});if("im"in e||"re"in e)return e.im!==void 0&&e.im!==0?i(e):e.re instanceof M&&e.re.isInteger()?new K({rational:[ie(e.re.toString()),BigInt(1)]},i,t):typeof e.re=="number"&&Number.isInteger(e.re)?new K({rational:[e.re,1]},i,t):i(e);if("radical"in e||"rational"in e){if(e.radical!==void 0&&(!Number.isInteger(e.radical)||e.radical>=$))throw Error("Unexpected value for radical part:"+e.radical);return e.rational&&se(e.rational)&&(!Number.isInteger(e.rational[0])||!Number.isInteger(e.rational[1]))?i(e):new K(e,i,t)}throw Error("Unexpected value")}get costFunction(){return this._cost??wa}set costFunction(e){typeof e!="function"&&(this._cost=wa),this._cost=e}lookupDefinition(e){return to(e,this.context.lexicalScope)}_declareSymbolValue(e,t,i){i??=this.context.lexicalScope,i.bindings.set(e,{value:new _n(this,e,{type:"unknown",inferred:!0})});let r=i.bindings.get(e);return gr(this,e,r,t),i===this.context.lexicalScope&&ne(r)&&r.value.value&&!r.value.isConstant&&(this.context.values[e]=r.value.value),this._generation+=1,r}_declareSymbolOperator(e,t,i){i??=this.context.lexicalScope,i.bindings.set(e,{value:new _n(this,e,{type:"function"})});let r=i.bindings.get(e);return gr(this,e,r,t),this._generation+=1,r}pushScope(e,t){this._pushEvalContext(e??{parent:this.context?.lexicalScope,bindings:new Map},t)}popScope(){this._popEvalContext()}_pushEvalContext(e,t){if(!t){let r=this._evalContextStack.length;r===0&&(t="system"),r===1&&(t="global"),t??=`anonymous_${r-1}`}let i={};for(let[r,o]of e.bindings.entries())ne(o)&&!o.value.isConstant&&(i[r]=o.value.value);this._evalContextStack.push({lexicalScope:e,name:t,assumptions:new Tr(this.context?.assumptions??[]),values:i})}_popEvalContext(){this._evalContextStack.pop()}_inScope(e,t){if(!e)return t();this._evalContextStack.push({lexicalScope:e,name:"",assumptions:new Tr([]),values:{}});try{return t()}finally{this._evalContextStack.pop()}}_printStack(e){e?(e={...e},e.maxDepth??=1,e.details??=!1):e={details:!1,maxDepth:-2},e.maxDepth!==void 0&&e.maxDepth<0&&(e.maxDepth=this._evalContextStack.length+e.maxDepth),e.maxDepth=Math.min(this._evalContextStack.length-1,e.maxDepth);let t=0;for(;t<=e.maxDepth;){let i=this._evalContextStack[this._evalContextStack.length-1-t];t===0?console.group(`${Or}${Go}${i.name}${$e}`):console.groupCollapsed(`${Or}${Go}${i.name}${$e} ${Ht}(${t})${$e}`);let r=[...i.assumptions.entries()].map(([s,a])=>`${s}: ${a}`);if(r.length>0){console.groupCollapsed(`${Or}${r.length} assumptions${$e}`);for(let s of r)console.info(s);console.groupEnd()}let o=Object.entries(i.values);if(o.length+i.lexicalScope.bindings.size===0){console.groupEnd(),t+=1;continue}for(let[s,a]of o)i.lexicalScope.bindings.has(s)?console.info(wf(s,i.lexicalScope.bindings.get(s),a)):console.info(a===void 0?`${Ai}${s}${$e}: ${Ht}undefined${$e}`:`${Ai}${s}${$e}: ${Ht}${a.toString()}${$e}`);for(let[s,a]of i.lexicalScope.bindings)s in i.values||console.info(wf(s,a));console.groupEnd(),t+=1}}_getSymbolValue(e){let t=this._evalContextStack.length-1;if(!(t<0))for(let i=t;i>=0;i--){let r=this._evalContextStack[i].values;if(e in r)return r[e]}}_setSymbolValue(e,t){let i=this._evalContextStack.length-1;if(i<0)throw new Error(`Unknown symbol "${e}"`);typeof t=="number"?t=this.number(t):typeof t=="boolean"&&(t=t?this.True:this.False);for(let o=i;o>=0;o--){let s=this._evalContextStack[o].values;if(e in s){s[e]=t,this._generation+=1;return}}let r=this.lookupContext(e);if(!r)throw new Error(`Unknown symbol "${e}"`);r.values[e]=t}declare(e,t,i){if(typeof e!="string"){for(let[a,u]of Object.entries(e))this.declare(a,u);return this}let r=e;if(r==="Nothing")return this;if(t==null)throw Error(`Expected a definition or type for "${r}"`);if(typeof r!="string"||r.length===0||!Te(r))throw new Error(`Invalid symbol "${r}": ${nn(r)}`);if(i??=this.context.lexicalScope,i.bindings.has(r))throw new Error(`The symbol "${r}" is already declared in this scope`);let s=t;if(mr(s))return this._declareSymbolValue(r,s,i),this;if(pr(s))return this._declareSymbolOperator(r,s,i),this;{let a=A(s,this._typeResolver);if(!st(a))throw Error([`Invalid argument for "${r}"`,JSON.stringify(s,void 0,4),"Use a type, a `OperatorDefinition` or a `ValueDefinition`"].join(`
109
109
  | `));this._declareSymbolValue(r,{type:a},i)}return this}lookupContext(e){if(e.length===0||!Te(e))throw Error(`Invalid symbol "${e}": ${nn(e)}}`);let t=this._evalContextStack.length-1;if(!(t<0))for(let i=t;i>=0;i--){let r=this._evalContextStack[i];if(r.lexicalScope.bindings.has(e))return r}}_swapContext(e){for(;this._evalContextStack.length>0&&this._evalContextStack[this._evalContextStack.length-1]!==e;)this._evalContextStack.pop();this._evalContextStack.length===0&&(this._evalContextStack=[e])}assign(e,t){if(typeof e=="object"){for(let[a,u]of Object.entries(e))this.assign(a,u);return this}let i=e;if(i==="Nothing")return this;let r=this.lookupDefinition(i);if(Z(r)){if(Bf(this,t))throw Error(`Cannot change the operator "${i}" to a value`);let u=If(this,t);if(!u)throw Error(`Cannot change the operator "${i}" to a value`);return gr(this,i,r,u),this}let o=Bf(this,t);if(o!==void 0){if(!r)return this._declareSymbolValue(i,{value:o}),this;if(r.value.isConstant)throw Error(`Cannot assign a value to the constant "${i}"`);return r.value.inferredType&&(r.value.type=this.type(oe(r.value.type.type,o.type.type))),this._setSymbolValue(i,o),this}let s=If(this,t);if(s===void 0)throw Error(`Invalid definition for symbol "${i}"`);return r?(ne(r),gr(this,i,r,s),this._setSymbolValue(i,void 0)):this.declare(i,s),this}_shouldContinueExecution(){return this.deadline===void 0||this.deadline>=Date.now()}_checkContinueExecution(){if(!this._shouldContinueExecution())throw new Error("timeout")}_cache(e,t,i){if(this.__cache[e]===void 0)try{this.__cache[e]={build:t,purge:i,value:t()}}catch(r){console.error(`Fatal error building cache "${e}":
110
110
  ${r.toString()}`)}return this.__cache[e]?.value}box(e,t){return Bn(this,e,t)}function(e,t,i){return Do(this,e,t,i)}error(e,t){let i;typeof e=="string"?i=this.string(e):i=this.function("ErrorCode",e.map(s=>this.string(s)));let r;t&&zi(t)?r=this.function("LatexString",[this.string(ut(t))]):typeof t=="string"&&t.length>0&&(r=this.string(t));let o=[this.box(i)];return r&&o.push(r),this.function("Error",o)}typeError(e,t,i){return t?this.error(["incompatible-type",U(e),t.toString()],i):this.error(["incompatible-type",U(e)],i)}hold(e){return this._fn("Hold",[this.box(e,{canonical:!1})])}tuple(...e){return new he(this,"Tuple",e.map(t=>typeof t=="number"?this.number(t):t.canonical),{canonical:!0})}type(e){return e instanceof S?e:new S(e,this._typeResolver)}string(e,t){return new bt(this,e,t)}symbol(e,t){let i=t?.canonical??!0;e=e.normalize();let r=e.toLowerCase();if(r==="infinity"||r==="+infinity")return this.PositiveInfinity;if(r==="-infinity")return this.NegativeInfinity;if(this.strict&&!Te(e))return this.error(["invalid-symbol",nn(e)],e);if(!i)return new Gt(this,e);let o=this._commonSymbols[e];if(o)return o;let s=this.lookupDefinition(e);return ne(s)&&s.value.holdUntil==="never"?s.value.value??this.Nothing:s?new Gt(this,e,{def:s}):(s=this._declareSymbolValue(e,{type:"unknown",inferred:!0}),new Gt(this,e,{def:s}))}number(e,t){let i=t?.metadata,r=!1;if((!t||t.canonical===void 0||t.canonical==="Number"||t.canonical===!0||Array.isArray(t.canonical)&&t.canonical.includes("Number"))&&(r=!0),!r&&Yn(e))return this._fn("Rational",[this.number(e[0]),this.number(e[1])],{...i,canonical:!1});if(e=Mo(this,e),i===void 0){if(typeof e=="number"){let o=e;if(o===1)return this.One;if(o===0)return this.Zero;if(o===-1)return this.NegativeOne;if(o===2)return this.Two;if(Number.isInteger(o)&&this._commonNumbers[o]!==void 0)return this._commonNumbers[o]??=new qe(this,e),this._commonNumbers[o];if(Number.isNaN(o))return this.NaN;if(!Number.isFinite(o))return o<0?this.NegativeInfinity:this.PositiveInfinity}else if(e instanceof j){if(e.isZero)return this.Zero;if(e.isOne)return this.One;if(e.isNegativeOne)return this.NegativeOne;if(e.isNaN)return this.NaN;if(e.isNegativeInfinity)return this.NegativeInfinity;if(e.isPositiveInfinity)return this.PositiveInfinity}}return new qe(this,e,{metadata:i})}rules(e,t){return yr(this,e,t)}getRuleSet(e){if(e??="standard-simplification",e==="standard-simplification")return this._cache("standard-simplification-rules",()=>yr(this,_f,{canonical:!0}));if(e==="solve-univariate")return this._cache("univariate-roots-rules",()=>yr(this,gf));if(e==="harmonization")return this._cache("harmonization-rules",()=>yr(this,hf))}_fn(e,t,i){let r=i?.canonical??!0;return new he(this,e,t,{...i,canonical:r})}parse(e,t){if(e==null)return null;if(typeof e!="string")throw Error("ce.parse(): expected a LaTeX string");let i={imaginaryUnit:"\\imaginaryI",positiveInfinity:"\\infty",negativeInfinity:"-\\infty",notANumber:"\\operatorname{NaN}",decimalSeparator:this.decimalSeparator,digitGroup:3,digitGroupSeparator:"\\,",exponentProduct:"\\cdot",beginExponentMarker:"10^{",endExponentMarker:"}",truncationMarker:"\\ldots",repeatingDecimal:"auto",skipSpace:!0,parseNumbers:"auto",getSymbolType:o=>{let s=this.lookupDefinition(o);return s?Z(s)?s.operator.signature:ne(s)?s.value.type:S.unknown:S.unknown},parseUnexpectedToken:(o,s)=>null,preserveLatex:!1},r=fl(ut(e)??e,this._indexedLatexDictionary,{...i,...t});if(r===null)throw Error("Failed to parse LaTeX string");return this.box(r,{canonical:t?.canonical??!0})}ask(e){let t=this.box(e,{canonical:!1}),i=[],r=this.context.assumptions;for(let[o,s]of r){let a=t.match(o);a!==null&&s===!0&&i.push(a)}return i}verify(e){return!1}assume(e){try{let t=zi(e)?this.parse(e,{canonical:!1}):this.box(e,{canonical:!1});return this._generation+=1,Sf(t)}catch(t){throw console.error(t.message.toString()),t}}forget(e){if(e===void 0){this.context.assumptions?.clear(),this._generation+=1;return}if(Array.isArray(e)){for(let t of e)this.forget(t);return}if(typeof e=="string")for(let[t,i]of this.context.assumptions)t.has(e)&&this.context.assumptions.delete(t);this._generation+=1}};function Bf(n,e){if(e==null||typeof e=="function")return;if(typeof e=="boolean")return e?n.True:n.False;if(typeof e=="number"||typeof e=="bigint")return n.number(e);let t=n.box(e);if(!(t.unknowns.length>0))return t}function If(n,e){if(typeof e=="function")return{evaluate:e,signature:"function"};if(e==null||typeof e=="boolean")return;let t=ve(n.box(e));if(t!==void 0)return{evaluate:t,signature:"function"}}function wf(n,e,t){let i="";if(ne(e)){let r=[];e.value.holdUntil==="never"&&r.push("(hold never)"),e.value.holdUntil==="N"&&r.push("(hold until N)"),e.value.inferredType&&r.push("inferred");let o=r.length>0?` ${r.join(" ")}`:"";i=`${Ai}${n}${$e}:${o}`,e.value.isConstant?(i+=` const ${e.value.type.toString()}`,e.value.value!==void 0&&(i+=` = ${e.value.value?.toString()}`)):i+=` ${e.value.type.toString()}`}else if(Z(e)){let r=[];e.operator.inferredSignature&&r.push("(inferred)");let o=r.length>0?` (${r.join(" ")})`:"";i=`${Ai}${n}${$e}:${o} ${e.operator.signature.toString()}`;let s=[];e.operator.lazy&&s.push("lazy"),e.operator.scoped&&s.push("scoped"),e.operator.broadcastable&&s.push("broadcastable"),e.operator.associative&&s.push("associative"),e.operator.commutative&&s.push("commutative"),e.operator.idempotent&&s.push("idempotent"),e.operator.involution&&s.push("involution"),e.operator.pure||s.push("not pure");let a=s.map(u=>`${Ht}${u}${$e}`).join(" ");a.length>0&&(i+=`
111
- \u2514 ${a}`)}else i="unknown";return t&&(t.isValid?t.isCanonical?i+=` = ${Ht}${t.toString()}${$e}`:i+=` = ${Wa}${t.toString()}${$e} (not canonical)`:i+=` = ${Ja}${t.toString()}${$e} (not valid)`),i}var Ig="0.30.1";globalThis[Symbol.for("io.cortexjs.compute-engine")]={ComputeEngine:Ii.prototype.constructor,version:"0.30.1"};return Rf(wg);})();
111
+ \u2514 ${a}`)}else i="unknown";return t&&(t.isValid?t.isCanonical?i+=` = ${Ht}${t.toString()}${$e}`:i+=` = ${Wa}${t.toString()}${$e} (not canonical)`:i+=` = ${Ja}${t.toString()}${$e} (not valid)`),i}var Ig="0.30.2";globalThis[Symbol.for("io.cortexjs.compute-engine")]={ComputeEngine:Ii.prototype.constructor,version:"0.30.2"};return Rf(wg);})();
112
112
  /*! Bundled license information:
113
113
 
114
114
  complex-esm/dist/src/complex.js:
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.30.1 */
1
+ /** Compute Engine 0.30.2 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComputeEngine = {}));})(this, (function (exports) { 'use strict';
3
3
  var ComputeEngine = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -38974,10 +38974,10 @@ Error in definition of "${name}"`,
38974
38974
  }
38975
38975
 
38976
38976
  // src/compute-engine.ts
38977
- var version = "0.30.1";
38977
+ var version = "0.30.2";
38978
38978
  globalThis[Symbol.for("io.cortexjs.compute-engine")] = {
38979
38979
  ComputeEngine: ComputeEngine.prototype.constructor,
38980
- version: "0.30.1"
38980
+ version: "0.30.2"
38981
38981
  };
38982
38982
  return __toCommonJS(compute_engine_exports);
38983
38983
  })();
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.30.1 */
1
+ /** Compute Engine 0.30.2 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  function isSymbolObject(expr) {
@@ -101,7 +101,7 @@ function matchesSymbol(s) {
101
101
  }
102
102
 
103
103
  // src/math-json.ts
104
- var version = "0.30.1";
104
+ var version = "0.30.2";
105
105
  export {
106
106
  dictionaryFromExpression,
107
107
  isFunctionObject,
@@ -1,4 +1,4 @@
1
- /** Compute Engine 0.30.1 */
1
+ /** Compute Engine 0.30.2 */
2
2
 
3
3
  // src/math-json/utils.ts
4
4
  function isSymbolObject(expr) {
@@ -101,7 +101,7 @@ function matchesSymbol(s) {
101
101
  }
102
102
 
103
103
  // src/math-json.ts
104
- var version = "0.30.1";
104
+ var version = "0.30.2";
105
105
  export {
106
106
  dictionaryFromExpression,
107
107
  isFunctionObject,
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.30.1 */
1
+ /** MathJSON 0.30.2 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
3
- var MathJson=(()=>{var s=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var i in t)s(n,i,{get:t[i],enumerable:!0})},J=(n,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of O(t))!M.call(n,e)&&e!==i&&s(n,e,{get:()=>t[e],enumerable:!(r=j(t,e))||r.enumerable});return n};var A=n=>J(s({},"__esModule",{value:!0}),n);var F={};S(F,{dictionaryFromExpression:()=>E,isFunctionObject:()=>u,isStringObject:()=>y,isSymbolObject:()=>f,mapArgs:()=>h,operand:()=>d,operator:()=>o,stringValue:()=>c,symbol:()=>m,version:()=>k});function f(n){return n!==null&&typeof n=="object"&&"sym"in n}function y(n){return n!==null&&typeof n=="object"&&"str"in n}function N(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):p(n)||g(n)?null:n}function o(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function b(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function d(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function D(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function m(n){return typeof n=="string"&&g(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:f(n)?n.sym:null}function a(n){let t=o(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=b(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function E(n){if(n===null)return null;if(N(n))return n;let t=a(n);if(t)return{[t[0]]:t[1]};if(o(n)==="Dictionary"){let i={},r=b(n);for(let e=1;e<D(n);e++){let l=a(r[e]);l&&(i[l[0]]=l[1])}return i}return null}function h(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function p(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function g(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}var k="0.30.1";return A(F);})();
3
+ var MathJson=(()=>{var s=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var M=Object.prototype.hasOwnProperty;var S=(n,t)=>{for(var i in t)s(n,i,{get:t[i],enumerable:!0})},J=(n,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of O(t))!M.call(n,e)&&e!==i&&s(n,e,{get:()=>t[e],enumerable:!(r=j(t,e))||r.enumerable});return n};var A=n=>J(s({},"__esModule",{value:!0}),n);var F={};S(F,{dictionaryFromExpression:()=>E,isFunctionObject:()=>u,isStringObject:()=>y,isSymbolObject:()=>f,mapArgs:()=>h,operand:()=>d,operator:()=>o,stringValue:()=>c,symbol:()=>m,version:()=>k});function f(n){return n!==null&&typeof n=="object"&&"sym"in n}function y(n){return n!==null&&typeof n=="object"&&"str"in n}function N(n){return n!==null&&typeof n=="object"&&"dict"in n&&typeof n.dict=="object"&&!Array.isArray(n.dict)&&n.dict!==null}function u(n){return n!==null&&typeof n=="object"&&"fn"in n&&Array.isArray(n.fn)&&n.fn.length>0&&typeof n.fn[0]=="string"}function c(n){return n==null?null:typeof n=="object"&&"str"in n?n.str:typeof n!="string"?null:n.length>=2&&n.at(0)==="'"&&n.at(-1)==="'"?n.substring(1,n.length-1):p(n)||g(n)?null:n}function o(n){return Array.isArray(n)?n[0]:n==null?"":u(n)?n.fn[0]:""}function b(n){return Array.isArray(n)?n.slice(1):n!==void 0&&u(n)?n.fn.slice(1):[]}function d(n,t){return Array.isArray(n)?n[t]??null:n===null||!u(n)?null:n.fn[t]??null}function D(n){return n==null?0:Array.isArray(n)?Math.max(0,n.length-1):u(n)?Math.max(0,n.fn.length-1):0}function m(n){return typeof n=="string"&&g(n)?n.length>=2&&n.at(0)==="`"&&n.at(-1)==="`"?n.slice(1,-1):n:n==null?null:f(n)?n.sym:null}function a(n){let t=o(n);if(t==="KeyValuePair"||t==="Tuple"||t==="Pair"){let[i,r]=b(n),e=c(i);return e?[e,r??"Nothing"]:null}return null}function E(n){if(n===null)return null;if(N(n))return n;let t=a(n);if(t)return{[t[0]]:t[1]};if(o(n)==="Dictionary"){let i={},r=b(n);for(let e=1;e<D(n);e++){let l=a(r[e]);l&&(i[l[0]]=l[1])}return i}return null}function h(n,t){let i=null;if(Array.isArray(n)&&(i=n),u(n)&&(i=n.fn),i===null)return[];let r=1,e=[];for(;r<i.length;)e.push(t(i[r])),r+=1;return e}function p(n){return/^(nan|oo|\+oo|-oo|infinity|\+infinity|-infinity)$/i.test(n)||/^[+-]?(0|[1-9][0-9]*)(\.[0-9]+)?(\([0-9]+\))?([eE][+-]?[0-9]+)?$/.test(n)}function g(n){return/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(n)||n.length>=2&&n[0]==="`"&&n[n.length-1]==="`"}var k="0.30.2";return A(F);})();
4
4
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /** MathJSON 0.30.1 */
1
+ /** MathJSON 0.30.2 */
2
2
  (function(global,factory){typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'],factory):(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MathJson = {}));})(this, (function (exports) { 'use strict';
3
3
  var MathJson = (() => {
4
4
  var __defProp = Object.defineProperty;
@@ -135,7 +135,7 @@ var MathJson = (() => {
135
135
  }
136
136
 
137
137
  // src/math-json.ts
138
- var version = "0.30.1";
138
+ var version = "0.30.2";
139
139
  return __toCommonJS(math_json_exports);
140
140
  })();
141
141
  Object.assign(exports, MathJson); Object.defineProperty(exports, '__esModule', { value: true });}));
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  export declare const DEFAULT_COLOR = "\u001B[39m";
3
3
  export declare const DEFAULT_BG = "\u001B[49m";
4
4
  export declare const WHITE_BG = "\u001B[47m";
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  private _listeners;
3
3
  private _pending;
4
4
  private _version;
@@ -1,2 +1,2 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  export declare function fuzzyStringMatch(invalidWord: string, validWords: string[]): string | null;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /**
3
3
  * Return a string or an array of graphemes.
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  cause: unknown;
3
3
  value: T;
4
4
  constructor({ message, value, cause, }?: {
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  infer Head,
3
3
  ...infer Rem
4
4
  ] ? MergeTypes<Rem, Res & Head> : Res;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  export type RuntimeSignalCode = 'timeout' | 'out-of-memory' | 'recursion-depth-exceeded' | 'iteration-limit-exceeded';
3
3
  /** @category Error Handling */
4
4
  export type SignalCode = RuntimeSignalCode | ('invalid-name' | 'expected-predicate' | 'expected-symbol' | 'operator-requires-one-operand' | 'postfix-operator-requires-one-operand' | 'prefix-operator-requires-one-operand' | 'unbalanced-symbols' | 'expected-argument' | 'unexpected-command' | 'cyclic-definition' | 'invalid-supersets' | 'expected-supersets' | 'unknown-domain' | 'duplicate-wikidata' | 'invalid-dictionary-entry' | 'syntax-error');
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /** @category Type */
3
3
  export declare class BoxedType {
4
4
  static unknown: BoxedType;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  export declare function parseType(s: undefined, typeResolver?: TypeResolver): undefined;
3
3
  export declare function parseType(s: TypeString | Type, typeResolver?: TypeResolver): Type;
4
4
  export declare function parseType(s: TypeString | Type | undefined, typeResolver?: TypeResolver): Type | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /** All the types representing numeric values */
3
3
  export declare const NUMERIC_TYPES: NumericPrimitiveType[];
4
4
  export declare const INDEXED_COLLECTION_TYPES: PrimitiveType[];
@@ -1,2 +1,2 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  export declare function typeToString(type: Type, precedence?: number): string;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /** Return true if lhs is a subtype of rhs */
3
3
  export declare function isPrimitiveSubtype(lhs: PrimitiveType, rhs: PrimitiveType): boolean;
4
4
  /** Return true if lhs is a subtype of rhs */
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  * A primitive type is a simple type that represents a concrete value.
3
3
  *
4
4
  * - `any`: the top type
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /** Convert two or more types into a more specific type that is a subtype of
3
3
  * all the input types. The resulting type is usually more constrained and
4
4
  * only encompasses values that belong to both input types.
@@ -1,2 +1,2 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  export declare function hidePrivateProperties(obj: any): void;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /**
3
3
  * Add an assumption, in the form of a predicate, for example:
4
4
  *
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  import type { Expression, MathJsonSymbol } from '../../math-json/types';
3
3
  import type { Type, TypeString } from '../../common/type/types';
4
4
  import { BoxedType } from '../../common/type/boxed-type';
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  import { Decimal } from 'decimal.js';
3
3
  import type { BoxedExpression } from '../global-types';
4
4
  export declare function apply(expr: BoxedExpression, fn: (x: number) => number | Complex, bigFn?: (x: Decimal) => Decimal | Complex | number, complexFn?: (x: Complex) => number | Complex): BoxedExpression | undefined;
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  import { BoxedType } from '../../common/type/boxed-type';
3
3
  import type { BoxedExpression, ComputeEngine } from '../global-types';
4
4
  /**
@@ -1,4 +1,4 @@
1
- /* 0.30.1 */
1
+ /* 0.30.2 */
2
2
  /**
3
3
  * Canonical form of 'Divide' (and 'Rational')
4
4
  * - remove denominator of 1