@arcgis/core 4.32.0-next.20250107 → 4.32.0-next.20250108

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 (99) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{07304287ed5244fa4e12.js → 12b2c8251ec2d0e2ca46.js} +1 -1
  4. package/assets/esri/core/workers/chunks/24a597ae32a2083a50a5.js +1 -0
  5. package/assets/esri/core/workers/chunks/510cb8647841fec436c8.js +1 -0
  6. package/assets/esri/core/workers/chunks/{f6d6bc43ac1c13892d44.js → 58485909e1cfeb52c01e.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{c49707b577f3805f0142.js → 5b61a1e7ac60a02a906d.js} +1 -1
  8. package/assets/esri/core/workers/chunks/76a7114a69264f5c07b0.js +2 -0
  9. package/assets/esri/core/workers/chunks/{ca1e186f136abb23ae4b.js → 7d0fc25ce1f74adcfeb6.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{dca0eb66116e4b5403fc.js → 7df076d15b7b7a66dcee.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{955421ee2247965244f0.js → 7fe92f072d3641ec4662.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{4423aac6e44c3dbf184e.js → 89286d8f59844724cd16.js} +1 -1
  13. package/assets/esri/core/workers/chunks/a8ec4189ec3b37d5ff74.js +1 -0
  14. package/assets/esri/core/workers/chunks/cd92b80de7e9f982f9a9.js +1 -0
  15. package/chunks/CrackAndCluster-CfzXpEle.js +1 -1
  16. package/chunks/LineSeries.js +1 -1
  17. package/chunks/OperatorProject.js +1 -1
  18. package/chunks/Pattern.glsl.js +1 -1
  19. package/chunks/QuadraticBezier.js +1 -1
  20. package/chunks/Transformation2D.js +1 -1
  21. package/chunks/chartUtilsAm5.js +1 -1
  22. package/chunks/lyr3DWorker.js +1 -1
  23. package/chunks/vxlLayer.js +1 -1
  24. package/geometry/support/meshUtils/primitives.js +1 -1
  25. package/geometry/support/triangle.js +1 -1
  26. package/interfaces.d.ts +175 -91
  27. package/layers/LinkChartLayer.js +1 -1
  28. package/layers/MapNotesLayer.js +1 -1
  29. package/layers/MediaLayer.js +1 -1
  30. package/layers/support/ImageElement.js +1 -1
  31. package/layers/support/VideoElement.js +1 -1
  32. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  33. package/layers/video/VideoController.js +1 -1
  34. package/linkChart/OrganicLayoutSettings.js +1 -1
  35. package/package.json +3 -3
  36. package/smartMapping/renderers/color.js +1 -1
  37. package/smartMapping/renderers/size.js +1 -1
  38. package/smartMapping/renderers/univariateColorSize.js +1 -1
  39. package/support/mediaLayerUtils.js +5 -0
  40. package/support/revision.js +1 -1
  41. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  42. package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
  43. package/views/2d/AnimationManager.js +1 -1
  44. package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
  45. package/views/2d/engine/webgl/Overlay.js +1 -1
  46. package/views/2d/engine/webgl/SDFConverter.js +1 -1
  47. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  48. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
  49. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  50. package/views/2d/layers/features/support/GraphicsReader.js +1 -1
  51. package/views/2d/navigation/MapViewNavigation.js +1 -1
  52. package/views/2d/support/HighlightGroup.js +1 -1
  53. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  54. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  55. package/views/3d/analysis/support/measurementUtils.js +1 -1
  56. package/views/3d/environment/CloudsParameters.js +1 -1
  57. package/views/3d/environment/MarsAtmosphere.js +1 -1
  58. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  59. package/views/3d/layers/MediaLayerView3D.js +1 -1
  60. package/views/3d/layers/graphics/placementUtils.js +1 -1
  61. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  62. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  63. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  64. package/views/3d/support/HighlightGroup.js +1 -1
  65. package/views/3d/terrain/SphericalPatch.js +1 -1
  66. package/views/3d/terrain/TilePerLayerInfo.js +1 -1
  67. package/views/3d/terrain/TileRenderer.js +1 -1
  68. package/views/3d/terrain/TileTexture.js +1 -1
  69. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  70. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  71. package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
  72. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  73. package/views/SceneView.js +1 -1
  74. package/views/View.js +1 -1
  75. package/views/input/BrowserEventSource.js +1 -1
  76. package/views/layers/MediaLayerView.js +1 -1
  77. package/views/support/HighlightGroup.d.ts +4 -0
  78. package/views/support/HighlightGroup.js +5 -0
  79. package/views/webgl/Texture.js +1 -1
  80. package/views/webgl/textureUtils.js +1 -1
  81. package/webscene/Slide.js +1 -1
  82. package/widgets/BasemapLayerList.js +1 -1
  83. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  84. package/widgets/CatalogLayerList.js +1 -1
  85. package/widgets/FeatureTable/support/exportUtils.js +1 -1
  86. package/widgets/LayerList/support/layerListUtils.js +1 -1
  87. package/widgets/LayerList.js +1 -1
  88. package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
  89. package/widgets/PanoramicViewer/utils.js +1 -1
  90. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  91. package/widgets/Sketch/SketchViewModel.js +1 -1
  92. package/widgets/TableList.js +1 -1
  93. package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +0 -1
  94. package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +0 -1
  95. package/assets/esri/core/workers/chunks/8cd2c9ec1e541836b81c.js +0 -1
  96. package/assets/esri/core/workers/chunks/b07710e01494a6cda097.js +0 -1
  97. package/assets/esri/core/workers/chunks/c05e0bd145a1c27d6857.js +0 -2
  98. package/views/2d/support/HighlightGroup.d.ts +0 -4
  99. /package/assets/esri/core/workers/chunks/{c05e0bd145a1c27d6857.js.LICENSE.txt → 76a7114a69264f5c07b0.js.LICENSE.txt} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{a as t,g as s,w as i,t as e,x as n}from"./Geometry.js";class r{constructor(t){this.sum=t,this.compensation=0}assign(t){return this.compensation=t.compensation,this.sum=t.sum,this}reset(){this.sum=this.compensation=0}resetToStart(t){this.sum=t,this.compensation=0}normalize(){const t=[Number.NaN];this.sum=ct(this.sum,this.compensation,t),this.compensation=t[0]}add(t){const s=this.sum+t;let i;if(Math.abs(this.sum)>=Math.abs(t)){const e=this.sum-s+t;i=this.compensation+e}else{const e=t-s+this.sum;i=this.compensation+e}this.sum=s,this.compensation=i}sub(t){this.add(-t)}addProduct(t,s){const i=[0],e=ot(t,s,i);this.add(e),this.add(i[0])}mul(t){const s=new r(0);s.addProduct(this.sum,t),s.addProduct(this.compensation,t),this.assign(s)}getResult(){return this.sum+this.compensation}pe(t){return this.add(t),this}me(t){return this.add(-t),this}}const h=0x00000000ffffffffn,o=0x0000ffffn,a=0x000000ffn,u=0x0fn,l=0xffff0000n,m=0xff00n,c=0xf0n,y=[5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1],x=[-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3];function f(t){let s=0;return t&o||(s+=16,t>>=16n),t&a||(s+=8,t>>=8n),t&u||(s+=4,t>>=4n),s+y[Number(BigInt.asUintN(4,t))]}function d(t){let s=0;return t&l&&(s+=16,t>>=16n),t&m&&(s+=8,t>>=8n),t&c&&(s+=4,t>>=4n),s+x[Number(BigInt.asUintN(4,t))]+1}function b(t){let s=0;return t&h||(s=32,t>>=32n),s+f(BigInt.asUintN(32,t))}function v(t){let s=0;return 0xffffffff00000000n&t&&(s=32,t>>=32n),s+d(t)}class _{constructor(t,s){if(this.m_EnvelopeType=1,void 0!==t){if(t instanceof _)return this.vmin=t.vmin,void(this.vmax=t.vmax);this.vmin=t,this.vmax=s,this.normalize()}else this.setEmpty()}static construct(t,s){return new _(t,s)}static constructEmpty(){return new _}setCoords(t,s){this.vmin=t,this.vmax=s,this.normalize()}setCoordsFromEnvelope(t){this.vmin=t.vmin,this.vmax=t.vmax}setEmpty(){this.vmin=Number.NaN,this.vmax=Number.NaN}getCenter(){return.5*(this.vmin+this.vmax)}equalsRange(t,s){return ns(this.vmin,t)&&ns(this.vmax,s)}equals(t,s){return!(!this.isEmpty()||!t.isEmpty())||(void 0!==s?Math.abs(this.vmin-t.vmin)<=s&&Math.abs(this.vmax-t.vmax)<=s:this.vmin===t.vmin&&this.vmax===t.vmax)}width(){return this.vmax-this.vmin}isEmpty(){return Number.isNaN(this.vmin)||Number.isNaN(this.vmax)}isZero(){return this.vmin===this.vmax}setInfinite(){this.vmin=Number.NEGATIVE_INFINITY,this.vmax=Number.POSITIVE_INFINITY}move(t){this.isEmpty()||(this.vmin+=t,this.vmax+=t)}contains(t){return t.vmin>=this.vmin&&t.vmax<=this.vmax}containsCoordinate(t){return t>=this.vmin&&t<=this.vmax}containsRightExclusive(t){return t>=this.vmin&&t<this.vmax}containsExclusiveCoordinate(t){return t>this.vmin&&t<this.vmax}containsExclusive(t){return t.vmin>this.vmin&&t.vmax<this.vmax}isIntersecting(t){return this.vmin<=t.vmin?this.vmax>=t.vmin:t.vmax>=this.vmin}mergeCoordinate(t){if(this.isEmpty())return this.vmin=t,void(this.vmax=t);this.mergeNeCoordinate(t)}merge(t){if(t.isEmpty())return;const s=t.vmin,i=t.vmax;this.mergeCoordinate(s),this.mergeCoordinate(i)}mergeNe(t){const s=t.vmin,i=t.vmax;this.mergeNeCoordinate(s),this.mergeNeCoordinate(i)}mergeNeCoordinate(t){t<this.vmin?this.vmin=t:t>this.vmax&&(this.vmax=t)}intersect(t){this.isEmpty()||t.isEmpty()?this.setEmpty():(this.vmin<t.vmin&&(this.vmin=t.vmin),this.vmax>t.vmax&&(this.vmax=t.vmax),this.vmin>this.vmax&&this.setEmpty())}inflate(t){this.isEmpty()||(this.vmin-=t,this.vmax+=t,this.vmax<this.vmin&&this.setEmpty())}normalize(){this.vmin<=this.vmax||(this.vmin>this.vmax?this.vmax=Tt(this.vmin,this.vmin=this.vmax):this.setEmpty())}isValid(){return this.isEmpty()||this.vmin<=this.vmax}snapClip(t){return Fs(t,this.vmin,this.vmax)}calculateToleranceFromEnvelope(){if(this.isEmpty())return As();return(Math.abs(this.vmin)+Math.abs(this.vmax)+1)*As()}static unit(){return N}normalizeNoNAN(){this.vmin>this.vmax&&(this.vmax=Tt(this.vmin,this.vmin=this.vmax))}setCoordsNoNAN(t,s){this.vmin=t,this.vmax=s,this.normalizeNoNAN()}clone(){return new _(this.vmin,this.vmax)}}const N=new _(0,1);class w{static getNAN(){return new w(Number.NaN)}constructor(t,s){this.m_value=t??0,this.m_eps=s??0}[Symbol.toPrimitive](t){return this}clone(){return new w(this.m_value,this.m_eps)}assign(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}scaleError(t){this.m_eps*=t}setError(t){this.m_eps=t}set(t,s){return this.m_value=t,this.m_eps=s??0,this}setWithEps(t,s){return void 0===s&&(s=1),this.m_value=t,this.m_eps=w.ulp(t)*s,this}setE(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}precise(){return new w(this.m_value)}value(){return this.m_value}toDouble(){return this.m_value}eps(){return this.m_eps}resetError(){return this.m_eps=0,this}absThis(){return this.m_value=Math.abs(this.m_value),this}add(t){return this.clone().addThis(t)}addE(t){return this.clone().addThisE(t)}addThisE(t){const s=this.m_value+t.m_value,i=this.m_eps+t.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}addThis(t){const s=this.m_value+t,i=this.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}subE(t){return this.clone().subThisE(t)}sub(t){return this.clone().subThis(t)}subThisE(t){const s=this.m_value-t.m_value,i=this.m_eps+t.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}subThis(t){const s=this.m_value-t,i=this.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}setAddE(t,s){return this.m_value=t.m_value+s.m_value,this.m_eps=t.m_eps+s.m_eps+w.ulp(this.m_value),this}setAdd(t,s){return this.m_value=t+s,this.m_eps=w.ulp(this.m_value),this}setAddEN(t,s){return this.m_value=t.m_value+s,this.m_eps=t.m_eps+w.ulp(this.m_value),this}setAddNE(t,s){return this.m_value=t+s.m_value,this.m_eps=s.m_eps+w.ulp(this.m_value),this}setSubE(t,s){return this.m_value=t.m_value-s.m_value,this.m_eps=t.m_eps+s.m_eps+w.ulp(this.m_value),this}setSub(t,s){return this.m_value=t-s,this.m_eps=w.ulp(this.m_value),this}setSubEN(t,s){return this.m_value=t.m_value-s,this.m_eps=t.m_eps+w.ulp(this.m_value),this}setSubNE(t,s){return this.m_value=t-s.m_value,this.m_eps=s.m_eps+w.ulp(this.m_value),this}mulThisE(t){const s=this.m_value*t.m_value;return this.m_eps=this.m_eps*Math.abs(t.m_value)+t.m_eps*Math.abs(this.m_value)+this.m_eps*t.m_eps+w.ulp(s),this.m_value=s,this}mulThis(t){const s=this.m_value*t;return this.m_eps=this.m_eps*Math.abs(t)+w.ulp(s),this.m_value=s,this}mul(t){return this.clone().mulThis(t)}mulE(t){return this.clone().mulThisE(t)}setMulE(t,s){const i=t.m_value*s.m_value;return this.m_eps=t.m_eps*Math.abs(s.m_value)+s.m_eps*Math.abs(t.m_value)+t.m_eps*s.m_eps+w.ulp(i),this.m_value=i,this}setMul(t,s){return this.m_value=t*s,this.m_eps=w.ulp(this.m_value),this}setMulEN(t,s){return this.setE(t),this.mulThis(s)}setMulNE(t,s){return this.setE(s),this.mulThis(t)}mulThisByPower2(t){return this.m_value*=t,this.m_eps*=Math.abs(t),this}static st_mulByPower2(t,s){return new w(t.m_value,t.m_eps).mulThisByPower2(s)}divE(t){return this.clone().divThisE(t)}divThisE(t){const s=Math.abs(t.m_value),i=this.m_value/t.m_value;let e=(this.m_eps+Math.abs(i)*t.m_eps)/s;if(t.m_eps>.01*s){const i=t.m_eps/s;e*=1+(1+i)*i}return this.m_value=i,this.m_eps=e+w.ulp(i),this}divThis(t){const s=Math.abs(t);return this.m_value/=t,this.m_eps=this.m_eps/s+w.ulp(this.m_value),this}setDivE(t,s){return this.setE(t),this.divThisE(s)}setDiv(t,s){return this.m_value=t/s,this.m_eps=w.ulp(this.m_value),this}setDivEN(t,s){return this.setE(t),this.divThis(s)}setDivNE(t,s){return this.set(t),this.divThisE(s)}divThisByPower2(t){return this.m_value/=t,this.m_eps/=Math.abs(t),this}invThis(){return this.setE(E.clone().divThisE(this)),this}sqrt(){return this.clone().sqrtThis()}sqrtThis(){let t,s;return this.m_value>=0?(t=Math.sqrt(this.m_value),s=this.m_value>10*this.m_eps?.5*this.m_eps/t:this.m_value>this.m_eps?t-Math.sqrt(this.m_value-this.m_eps):Math.max(t,Math.sqrt(this.m_value+this.m_eps)-t),s+=w.ulp(t)):this.m_value<-this.m_eps?(t=Number.NaN,s=Number.NaN):(t=0,s=Math.sqrt(this.m_eps)),this.m_value=t,this.m_eps=s,this}sqr(){return this.clone().sqrThis()}sqrThis(){const t=this.m_value*this.m_value;return this.m_eps=2*this.m_eps*Math.abs(this.m_value)+this.m_eps*this.m_eps+w.ulp(t),this.m_value=t,this}setSin(t){const s=Math.sin(t.m_value),i=Math.cos(t.m_value);this.m_value=s;const e=Math.abs(s),n=Math.abs(t.value());return this.m_eps=(Math.abs(i)+.5*e*t.m_eps)*t.m_eps+w.ulp(e+n),this}static ulp(t){let s=Kt(t);const i=((0x7ff0000000000000n&s)>>52n)-1075n;return i>-1023n?(s=i+0x3ffn<<52n,ts(s)):0===t?0:Number.MIN_VALUE}setCos(t){const s=Math.sin(t.m_value),i=Math.cos(t.m_value);this.m_value=i;const e=Math.abs(i),n=Math.abs(t.value());return this.m_eps=(Math.abs(s)+.5*e*t.m_eps)*t.m_eps+w.ulp(e+n),this}static st_cosAndSin(t,s,i){const e=Math.sin(t.m_value),n=Math.cos(t.m_value);i.m_value=e,s.m_value=n;const r=Math.abs(e),h=Math.abs(n),o=Math.abs(t.value());i.m_eps=(Math.abs(n)+.5*r*t.m_eps)*t.m_eps+w.ulp(r+o),s.m_eps=(Math.abs(e)+.5*h*t.m_eps)*t.m_eps+w.ulp(h+o)}negate(){return this.clone().negateThis()}negateThis(){return this.m_value=-this.m_value,this}setAbs(){return this.m_value=Math.abs(this.m_value),this}isInInterval(t){return _.construct(this.m_value-this.m_eps,this.m_value+this.m_eps).isIntersecting(t)}eq(t){return Math.abs(this.m_value-t.m_value)<=this.m_eps+t.m_eps}ne(t){return!this.eq(t)}gt(t){return this.m_value-t.m_value>this.m_eps+t.m_eps}lt(t){return t.m_value-this.m_value>this.m_eps+t.m_eps}ge(t){return!this.lt(t)}le(t){return!this.gt(t)}tolEQ(t,s){return Math.abs(this.m_value-t.m_value)<=s||this.eq(t)}tolNE(t,s){return!this.tolEQ(t,s)}tolGT(t,s){return this.m_value-t.m_value>s&&this.gt(t)}tolLT(t,s){return t.m_value-this.m_value>s&&this.lt(t)}tolGE(t,s){return!this.tolLT(t,s)}tolLE(t,s){return!this.tolGT(t,s)}isZero(){return Math.abs(this.m_value)<=this.m_eps}isFuzzyZero(){return this.isZero()&&0!==this.m_eps}tolIsZero(t){return Math.abs(this.m_value)<=Math.max(this.m_eps,t)}setPi(){this.setE(R)}setEuler(){this.set(2.718281828459045,T())}static size(){return 1}}function M(t,s){const i=ss(t),e=ss(s),n=53-b(i),r=53-b(e);return(n>=0?n:0)+(r>=0?r:0)<=52}function p(t,s){const i=t+s;return i-t===s&&i-s===t}function C(t,s){const i=t-s;return t-i===s&&s+i===t}function T(){return zs()}w.dimensions=1;const R=new w(Math.PI,.5*T()),g=new w(0,0),E=new w(1,0),I=new w(4,0);function D(t,s,i){return t.addE(s.subE(t).mulE(i))}function A(t,s,i){return s.subE(s.subE(t).mulE(E.subE(i)))}function P(t){return Math.atanh(t)}function q(t){let s;if(0===t)s=1;else if(Math.abs(t)>.01)s=P(t)/t;else{let i;const e=-36.841361487904734;s=0;const n=t*t;for(let t=2*Math.trunc(e/Math.log(n)+2.5)-1;t>1;t-=2)i=1/t,s=(s+i)*n;s+=1}return s}function z(t){const s=Math.PI*Math.PI/6;let i;if(1===t)i=s;else if(t>1)i=s;else if(0===t)i=t;else if(t<0){const s=1+(t=Math.abs(t)),e=Math.log(s);i=e*e/-2-z(t/s)}else if(t>.5){const e=1-t,n=Math.log(t)*Math.log(e);i=s-z(e)-n}else{i=0;const s=1+Math.trunc(-16*Math.log(10)/Math.log(t)+1.5);let e=s;for(let n=s;n>0;n--,e-=1)i*=t,i+=1/(e*e);i*=t}return i}function Z(t,s){const i=s*t;if(Math.abs(s)<.1){let s=0;for(let t=60;t>=1;t--)s*=i,s+=1/t/t;return s*=t,s}return z(i)/s}function F(t,s){return t<s?Gt(t,s):Gt(s,t)}function S(t,s){const i=Math.abs(t);return s>=0?i:-i}function k(t){return Math.round(t)}function L(t,s,i,e,n){n[0]=s[0]+(i[0]-s[0])*e,n[1]=s[1]+(i[1]-s[1])*e,3===t&&(n[2]=s[2]+(i[2]-s[2])*e)}function B(t,s,i,e,n){n[0]=i[0]-(i[0]-s[0])*(1-e),n[1]=i[1]-(i[1]-s[1])*(1-e),3===t&&(n[2]=i[2]-(i[2]-s[2])*(1-e))}function O(t,s,i,e,n){e<=.5?L(t,s,i,e,n):B(t,s,i,e,n)}function G(t,s,i,e,n){n[0]=s[0].addE(i[0].subE(s[0]).mulE(e)),n[1]=s[1].addE(i[1].subE(s[1]).mulE(e))}function Q(t,s,i,e,n){n[0]=i[0].subE(i[0].subE(s[0]).mulE(E.subE(e))),n[1]=i[1].subE(i[1].subE(s[1]).mulE(E.subE(e)))}function V(t,s,i){let e;return e=i<=.5?t+(s-t)*i:s-(s-t)*(1-i),e}function U(t,s,i){return t+(s-t)*i}function W(t,s,i){return s-(s-t)*(1-i)}function Y(t,s,i,e){i<=.5?(e.x=t.x+(s.x-t.x)*i,e.y=t.y+(s.y-t.y)*i):(e.x=s.x-(s.x-t.x)*(1-i),e.y=s.y-(s.y-t.y)*(1-i))}function j(t,s,i,e){i<=.5?(e.x=t.x+(s.x-t.x)*i,e.y=t.y+(s.y-t.y)*i,e.z=t.z+(s.z-t.z)*i):(e.x=s.x-(s.x-t.x)*(1-i),e.y=s.y-(s.y-t.y)*(1-i),e.z=s.z-(s.z-t.z)*(1-i))}function X(t){return t*t}function $(t){return t*t*t}function H(t){return 1/Math.sqrt(t)}function J(t){return t<0?-1:t>0?1:0}function K(t,s,i,e){const n=[0],r=[0],h=[0];return ct(ot(t,i,n),ot(s,e,r),h)+(n[0]+r[0]+h[0])}const tt=[0],st=[0];function it(t,s,i){return mt(ot(t,s,tt),i,tt[0],st)}const et=[0],nt=[0],rt=[0],ht=[0];function ot(t,s,i){const e=t*s;return at(t,et,nt),at(s,rt,ht),i[0]=nt[0]*ht[0]-(e-et[0]*rt[0]-nt[0]*rt[0]-et[0]*ht[0]),e}function at(t,s,i){const e=134217729*t;s[0]=e-(e-t),i[0]=t-s[0]}const ut=[0],lt=[0];function mt(t,s,i,e){const n=ct(t,s,ut),r=ct(n,i,lt);return ct(r,ut[0]+lt[0],e)}function ct(t,s,i){const e=t+s;return Math.abs(t)>Math.abs(s)?i[0]=t-e+s:i[0]=s-e+t,e}function yt(t,s){return t%s}function xt(t){const s=1-t;if(0===s)return 1;let i;if(s<=.01){const t=s,e=Math.log(t);i=1+t*(.4431471805599453-.25*e+t*(.05680519270997949-.09375*e+t*(.02183137044373718-.05859375*e+t*(.011544521417308362-.042724609375*e+t*(.00714200031339596-.0336456298828125*e+t*(.004854743337164948-.027757644653320312*e+t*(.003514687963781376-.023627042770385742*e)))))))}else{if(t<.016){const s=t,i=.25,e=.046875,n=.01953125,r=.01068115234375,h=.0067291259765625,o=.004626274108886719,a=.0033752918243408203,u=.0025710230693221092;return Os()*(1-s*(i+s*(e+s*(n+s*(r+s*(h+s*(o+s*(a+s*u))))))))}i=bt(0,s,1)-t*vt(0,s,1)/3}return Fs(i,1,Os())}function ft(t,i,e=Number.NaN){if(s(i>=0&&i<=1),0===i)return t;let n=1,r=t;if(r<0&&(r=-r,n=-1),1===i){const t=Math.round(r/Ls()),s=r-t*Ls();return n*(2*t+Math.sin(s))}const h=Os(),o=Math.floor(r/h);1&o?r=(o+1)*h-r:r-=o*h;const a=Math.sin(r),u=Number.isNaN(e)?xt(i):e;let l;if(1===a)l=u+Math.sqrt(1-i)*(r-h);else{const t=r*r;if(.01424*Math.pow(t,4)<=2*zs()){l=r*(1+t*i*(-1/6+t*((4-3*i)/120-(16+(45*i-60)*i)/5040*t)))}else if(i<=.01){const t=Math.sin(2*r),s=Math.sin(4*r),e=Math.sin(6*r),n=Math.sin(8*r),h=Math.sin(10*r);l=r+i*((2*-r+t)/8+i*((-3*r+2*t-.25*s)/64+i*((-20*r+15*t-3*s+e/3)/1024+i*(5*(-140*r+112*t-28*s+16/3*e-.5*n)/65536+7*i*((-63*r+52.5*t-15*s+3.75*e-.625*n+.05*h)/65536+i*(-693*r+594*t-185.625*s+1.375*e-12.375*n+1.8*h-.125*Math.sin(12*r))/1048576)))))}else{const t=a*a,s=Math.cos(r),e=s*s,n=_t(a,s,i);l=a*(bt(e,n,1)-i*t*vt(e,n,1)/3)}}if(1&o){l=u*(o+1)-l}else l+=u*o;return n*l}function dt(t,s,i=Number.NaN){if(0===t)return 0;let e=1,n=t;t<0&&(n=-n,e=-1);const r=Number.isNaN(i)?xt(s):i,h=Math.floor(n/r);1&h?n=(h+1)*r-n:n-=h*r;let o=n<=0?0:n>=r?Os():Nt(n,s,r);return 1&h?o=Os()*(h+1)-o:o+=Os()*h,e*o}function bt(t,i,e){s((0!==t?1:0)+(0!==i?1:0)+1>1);let n=t,r=i,h=e;for(;;){const t=Math.sqrt(n*r)+Math.sqrt(r*h)+Math.sqrt(h*n);n=.25*(n+t),r=.25*(r+t),h=.25*(h+t);const s=(n+r+h)/3,i=(s-n)/s,e=(s-r)/s,o=(s-h)/s;if(Math.abs(i)<=.0024&&Math.abs(e)<=.0024&&Math.abs(o)<=.0024){const t=i*e-o*o,n=i*e*o;return(1+(1/24*t-.1-3/44*n-5*t*t/208+t*n/16)*t+(1/14+3*n/104)*n)/Math.sqrt(s)}}}function vt(t,i,e){s(0!==t||0!==i);let n=t,h=i,o=e;const a=new r(0);let u=1;for(;;){const t=.2*(n+h+3*o),s=(t-n)/t,i=(t-h)/t,e=(t-o)/t;if(Math.abs(s)<=.0015&&Math.abs(i)<=.0015&&Math.abs(e)<=.0015){const n=s*i,r=e*e,h=n-r,o=n-6*r,l=o+h+h,m=9/22,c=3/26,y=o*(.25*m*o-3/14-1.5*c*e*l),x=e*(1/6*l+e*(-m*h+e*c*n));return 3*a.getResult()+u*(1+y+x)/(t*Math.sqrt(t))}const r=Math.sqrt(n),l=Math.sqrt(h),m=Math.sqrt(o),c=r*(l+m)+l*m;a.add(u/(m*(o+c))),u*=.25,n=.25*(n+c),h=.25*(h+c),o=.25*(o+c)}}function _t(t,s,i){return t<.999?1-i*X(t):1-i+i*X(s)}function Nt(t,s,i){if(0===s)return t;if(1===s)return Math.asin(t);let e=0,n=!0;if(t<.2){const i=t*t,r=t*(1+i*s*(1/6+i*((13*s-4)/120+(16-284*s+493*s*s)/5040*i))),h=Math.abs(s*(4944*s-64-31224*s*s+37369*s*s*s)/362880*Math.pow(t,9));if(h<Math.abs(r)*zs())return r;e=r,n=h>.1*r}if(n){const n=1-s,r=1-t/i,h=Math.sqrt(r*r+n*n),o=Math.atan2(n,t+zs());e=Os()+Math.sqrt(h)*(o-Os())}let r=0;for(let h=0;h<7;h++){r=ft(e,s,i);const n=_t(Math.sin(e),Math.cos(e),s);if(e-=(r-t)/Math.sqrt(n),h>0&&Math.abs(r-t)<=4*zs()*t)break}return e}function wt(s,i,e,n,r){return 0===s?0===n?i:1===n?e:r:1===s?0===n?i:1===n?e:V(i,e,n):(2===s&&t("angular interpolation"),void t(""))}function Mt(s,i,e,n,r,h,o,a){if(0===s)for(let t=0;t<h;++t)n[t+r]=0===o?i[t]:1===o?e[t]:a;else if(1===s)if(0===o)pt(n,i,r,0,h);else if(1===o)pt(n,e,r,0,h);else for(let t=0;t<h;++t)n[t+r]=V(i[t],e[t],o);else if(2===s)if(0===o)pt(n,i,r,0,h);else if(1===o)pt(n,e,r,0,h);else{let t=0;for(let s=0,a=r;s<h;++s,++a)n[a]=V(i[s],e[s],o),t+=n[a]*n[a];if(t>0){t=Math.sqrt(t);for(let s=r;s<r+h;++s)n[s]/=t}else{for(let t=r;t<r+h;++t)n[t]=0;n[r]=1}}else t("")}function pt(t,s,i,e,n){if(0===n)return;let r=0,h=i,o=e;for(;r++<n;)t[h++]=s[o++]}function Ct(t,s,i){let e=0;for(let n=0;!e&&n<i;++n)e=t[n]-s[n];return e}function Tt(t,s){return t}function Rt(t){t.sort(((t,s)=>t<s?-1:t>s?1:0))}function gt(t,s){const i=t.slice(0,s);Rt(i),pt(t,i,0,0,s)}function Et(t,s,i,e){const n=t.slice(s,s+i);n.sort(e),pt(t,n,s,0,i)}function It(t,s){return t<s?-1:t>s?1:0}function Dt(t,s,i,e){return t<i?-1:t>i?1:s<e?-1:s>e?1:0}function At(t,s){if(t.length<2)return t.length;let i=0;for(let e=1;e<t.length;++e)s(t[e],t[i])||(i++,t[e]=Tt(t[i],t[i]=t[e]));return 1+i}function Pt(t,s){t[s]=t.at(-1),t.pop()}function qt(t,s=!1){return{[Symbol.dispose](){this.bForget||t()},bForget:s}}function zt(t,s){return Array.from({length:s},(()=>new t))}function Zt(t,s,i){for(let e=0;e<i;++e)t[e].assign(s[e]);return i}function Ft(t,s){const i=t.slice(0,s);for(let e=0;e<s;++e)i[e]=i[e].clone();return i}function St(t){return Array.from({length:t},(()=>null))}function kt(t,s){return Array.from({length:s},(()=>t()))}function Lt(t,s){return Array.from({length:t},(()=>s))}function Bt(t,s){return s in t&&1===Object.getOwnPropertyNames(t).length}class Ot{constructor(...t){this.m_elts=t}get length(){return this.m_elts.length}at(t){return this.m_elts[t]}[Symbol.dispose](){for(const t of this.m_elts)t[Symbol.dispose]()}}function Gt(t,s){return{first:t,second:s}}const Qt=Math.PI,Vt=2*Math.PI,Ut=.5*Math.PI;class Wt{constructor(t,s){this.m_cr=t,this.m_cc=s,this.m_v=Lt(t*s,0)}get(t,s){return this.m_v[t*this.m_cc+s]}set(t,s,i){this.m_v[t*this.m_cc+s]=i}inc(t,s){return++this.m_v[t*this.m_cc+s]}}const Yt=new ArrayBuffer(8),jt=new Float64Array(Yt),Xt=new BigUint64Array(Yt),$t=0x0fffffffffffffn,Ht=0x7ff0000000000000n;function Jt(){return Number.EPSILON*Ds}function Kt(t){return jt[0]=t,Xt[0]}function ts(t){return Xt[0]=t,jt[0]}function ss(t){return Kt(t)&$t}function is(t){return Number((Kt(t)&Ht)>>52n)}function es(t){if(0n===t)return-1n;if(1n===t||-1n===t)return 0n;t<0n&&(t=-t);let s=0n,i=512n,e=1n<<s+i;for(;t>=e;)s+=i,i<<=1n,e<<=i;let n=s;i>>=1n;let r=n+i;for(;i>0n;)t<1n<<r||(n=r),i>>=1n,r=n+i;return n}function ns(t,s){return t===s||Number.isNaN(t)&&Number.isNaN(s)}function rs(t,s,i){return t===s||Math.abs(t-s)<=i||Number.isNaN(t)&&Number.isNaN(s)}function hs(t,s){return t<s?-1:t>s?1:0}function os(t,s){if(t<s)return-1;if(t>s)return 1;if(t===s)return 0;{const i=Number.isNaN(t),e=Number.isNaN(s);return i<e?-1:i>e?1:0}}function as(){return 2147483647}function us(){return 32767}function ls(){return 2147483647}function ms(){return-2147483648}const cs=ls(),ys=BigInt(cs),xs=2166136261,fs=16777619;function ds(t){let s=xs,i=t;return s=(s^255&i)*fs,i>>=8,s=(s^255&i)*fs,i>>=8,s=(s^255&i)*fs,i>>=8,s=(s^255&i)*fs,s&cs}const bs=14695981039346656037n,vs=1099511628211n;function _s(t){let s=bs,i=t;return s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,s&ys}function Ns(t){return 1103515245*t+12345&2147483647}function ws(t){let s=xs;for(let i=0,e=t.length;i<e;++i)s=(s^t.charCodeAt(i))*fs;return s&cs}function Ms(t,s){return s+2654435769+(t<<6)+(t>>2)&cs}function ps(t,s){return Ms(t,gs(s))}function Cs(t){return Ms(3735928559,t)}function Ts(t,s){return Ms(t,Cs(s))}function Rs(t){return ds(t)}function gs(t){return Number(_s(t))}function Es(t){return Ns(t)}const Is=100,Ds=100;function As(){return Number.EPSILON*Is}function Ps(){return.38196601125010515}function qs(){return 1.4142135623730951}function zs(){return Number.EPSILON}function Zs(t,s,i){return t===s||t===i}function Fs(t,s,i){return t>=s?t<=i?t:i:s}function Ss(t,s,i){const e=t[0];if(e>=s){if(e<=i)return!1;t[0]=i}else t[0]=s;return!0}function ks(t,s){return t>=s?s:t<-s?-s:t}function Ls(){return Qt}function Bs(){return Vt}function Os(){return Ut}const Gs=3*Os();function Qs(){return Gs}function Vs(t){return t+0}function Us(t){return{v:t}}class Ws{constructor(){this.m_rn=Us(0n),this.m_rd=Us(1n),this.m_bNaN=!1,this.m_bNormalized=!1,this.m_power=0,this.m_sign=0}static constructAssign(t,s){const i=t.clone();return void 0!==s&&i.limitPrecisionThis(s),i}static constructDouble(t){return(new Ws).setDouble(t)}static constructInt64(t){return(new Ws).setInt64(t)}static constructRational(t,s){return(new Ws).setRational(t,s)}static constructInt32(t){return this.constructInt64(BigInt(Math.trunc(t)))}[Symbol.toPrimitive](t){return this}compare(t){return this.lt(t)?-1:this.gt(t)?1:0}assignCopy(t){return this.setThis(t)}abs(){return this.clone().absThis()}absThis(){return this.isNAN()||(this.m_sign*=this.m_sign),this}clone(){return(new Ws).setThis(this)}setThis(t){return this.m_bNaN=t.m_bNaN,this.m_bNormalized=t.m_bNormalized,this.m_rn.v=t.m_rn.v,this.m_rd.v=t.m_rd.v,this.m_power=t.m_power,this.m_sign=t.m_sign,this}setZero(){return this.m_rn.v=0n,this.m_rd.v=1n,this.m_bNaN=!1,this.m_power=0,this.m_bNormalized=!0,this.m_sign=0,this}setDouble(s){if(this.setZero(),0===s)return this;if(Number.isInteger(s)&&Math.abs(s)<ls())return this.setInt32(s);const i=Kt(s),e=(i&Ws.s_em)>>52n,n=!!(i&Ws.s_sm),r=i&Ws.s_fm;if(e===Ws.s_emax)return r?(this.m_rn.v=this.m_rd.v=0n,this.m_bNaN=!0,this):(this.m_rn.v=n?-1n:1n,this.m_rd.v=0n,this);0n===e&&t("denormalized numbers not yet implemented");const h=e-1023n,o=h>=0n?h:0n,a=h<0n?-h:0n;return this.m_rn.v=(1n<<52n|r)<<o,this.m_rd.v=1n<<52n+a,this.m_sign=n?-1:1,this.m_bNormalized=!1,this.normalizeThis()}setInt64(t){return 0n===t?this.setZero():(this.m_bNaN=!1,this.m_sign=t>0n?1:-1,this.m_rn.v=t>0n?t:-t,this.m_rd.v=1n,this.m_power=0,this.m_bNormalized=!1,this.normalizeThis())}setRational(t,s){return 0n===t?0n===s?this.setNAN():this.setZero():0n===s?t>0n?this.setPositiveInf():this.setNegativeInf():(this.m_sign=(t>0n?1:-1)*(s>0n?1:-1),this.m_rn.v=t>0n?t:-t,this.m_rd.v=s>0n?s:-s,this.m_power=0,this.m_bNormalized=!1,this.normalizeThis())}setInt32(t){return this.setInt64(BigInt(Math.trunc(t)))}getDouble(){return this.convertToDouble()}toDouble(){return this.convertToDouble()}value(){return this.convertToDouble()}isNAN(){return this.m_bNaN}isPositiveInf(){return!this.isNAN()&&(0n===this.m_rd.v&&1===this.m_sign)}isNegativeInf(){return!this.isNAN()&&(0n===this.m_rd.v&&-1===this.m_sign)}isFinite(){return!this.isNAN()&&0n!==this.m_rd.v}setNAN(){return this.m_bNaN=!0,this.m_rn.v=0n,this.m_rd.v=0n,this.m_power=0,this.m_bNormalized=!0,this}setPositiveInf(){return this.m_rn.v=1n,this.m_rd.v=0n,this.m_bNaN=!1,this.m_bNormalized=!0,this.m_sign=1,this.m_power=0,this}setNegativeInf(){return this.m_rn.v=1n,this.m_rd.v=0n,this.m_bNaN=!1,this.m_bNormalized=!0,this.m_sign=-1,this.m_power=0,this}subThis(t){if(t.isNAN()&&this.setNAN(),this.isPositiveInf()&&t.isPositiveInf())this.setNAN();else{if(this.isPositiveInf()&&t.isNegativeInf())return this.setPositiveInf(),this;if(this.isNegativeInf()&&t.isNegativeInf())this.setNAN();else if(this.isNegativeInf()&&t.isPositiveInf())return this.setNegativeInf(),this}return this.isNAN()?this:this.opPlusMinus(t,!1)}thisSubAbs(t){return s(0),this}mulThis(t){return t.isNAN()&&this.setNAN(),this.isNAN()?this:(this.m_sign*=t.m_sign,0===this.m_sign?this.setZero():(this.m_rn.v*=t.m_rn.v,this.m_rd.v*=t.m_rd.v,this.m_power+=t.m_power,this.m_bNormalized=!1,this.normalizeThis(),this))}mulDoubleThis(t){return this.mulThis(Ws.constructDouble(t))}thisMulInt64(t){return s(0),this}thisMulInt32(t){return s(0),this}divThis(t){return this.mulThis(t.clone().invertThis())}divDoubleThis(t){return this.divThis(Ws.constructDouble(t))}addDoubleThis(t){return this.addThis(Ws.constructDouble(t))}subDoubleThis(t){return this.subThis(Ws.constructDouble(t))}mul(t){return this.clone().mulThis(t)}mulBigIntThis(t){return this.mulThis(Ws.constructInt64(t))}mulDouble(t){return this.clone().mulThis(Ws.constructDouble(t))}div(t){return this.clone().divThis(t)}divDouble(t){return this.clone().divDoubleThis(t)}add(t){return this.clone().addThis(t)}fmSubThis(t,s){return this.subThis(t.clone().mulThis(s))}fmAddThis(t,s){return this.addThis(t.clone().mulThis(s))}addThis(t){if(t.isNAN()&&this.setNAN(),this.isPositiveInf()&&t.isPositiveInf())return this.setPositiveInf(),this;if(this.isPositiveInf()&&t.isNegativeInf())this.setNAN();else{if(this.isNegativeInf()&&t.isNegativeInf())return this.setNegativeInf(),this;this.isNegativeInf()&&t.isPositiveInf()&&this.setNAN()}return this.isNAN()?this:this.opPlusMinus(t,!0)}addDouble(t){return this.clone().addThis(Ws.constructDouble(t))}sub(t){return this.clone().subThis(t)}subDouble(t){return this.clone().subThis(Ws.constructDouble(t))}isZero(){return 0===this.m_sign}equals(t){return this.clone().subThis(t).isZero()}lt(t){return!this.isNAN()&&!t.isNAN()&&(!(this.isPositiveInf()&&t.isPositiveInf()||this.isNegativeInf()&&t.isNegativeInf())&&(!this.isPositiveInf()&&(!!t.isPositiveInf()||this.clone().sub(t).LZ())))}absLessAbs(t){return this.abs().lt(t.abs())}gt(t){return this.clone().sub(t).GZ()}lte(t){return this.sub(t).LEZ()}gte(t){return this.sub(t).GEZ()}normalizeThis(){if(this.m_bNormalized)return this;if(0n===this.m_rn.v)return this.setZero();let t=0,s=0xffffffffn;for(;0n===(this.m_rn.v&s)&&s<=this.m_rn.v;)s<<=32n,t+=32;s&=this.m_rn.v,s>>=BigInt(t),t+=f(BigInt.asUintN(32,s))-1;let i=0;for(s=0xffffffffn;0n===(this.m_rd.v&s)&&s<=this.m_rd.v;)s<<=32n,i+=32;return s&=this.m_rd.v,s>>=BigInt(i),i+=f(BigInt.asUintN(32,s))-1,this.m_rn.v>>=BigInt(t),this.m_rd.v>>=BigInt(i),this.m_power+=t-i,this.m_rn.v>1n&&this.m_rd.v>1n&&(this.m_rn.v%this.m_rd.v===0n?(this.m_rn.v/=this.m_rd.v,this.m_rd.v=1n):this.m_rd.v%this.m_rn.v===0n&&(this.m_rd.v/=this.m_rn.v,this.m_rn.v=1n)),this.m_bNormalized=!0,this}negateThis(){return this.isNAN()||(this.m_sign*=-1),this}negate(){return this.clone().negateThis()}invertThis(){return this.isNAN()?this:this.isPositiveInf()||this.isNegativeInf()?(this.setZero(),this):0n===this.m_rn.v?(this.setPositiveInf(),this):(this.m_rd=Tt(this.m_rn,this.m_rn=this.m_rd),this.m_power=-this.m_power,this)}limitPrecisionThis(t){if(0===t)return this;if(this.isZero())return this.setZero();if(!this.isFinite())return this;this.normalizeThis();let s=Number(es(this.m_rn.v));if(s>t){const i=s-t;this.m_rn.v>>=BigInt(s-t),this.m_power+=i}if(s=Number(es(this.m_rd.v)),s>t){const i=s-t;this.m_rd.v>>=BigInt(s-t),this.m_power-=i}return this}hiBitIndex(){return Math.max(Number(es(this.m_rn.v)),Number(es(this.m_rd.v)))}ldexp(t){return this.clone().ldexpThis(t)}ldexpThis(t){return t&&(this.m_bNormalized=!1,this.m_power+=t,this.normalizeThis()),this}LZ(){return!this.isNAN()&&-1===this.m_sign}GZ(){return!this.isNAN()&&1===this.m_sign}LEZ(){return!this.isNAN()&&this.m_sign<=0}GEZ(){return!this.isNAN()&&this.m_sign>=0}toString(){return this.toDouble().toString()}sqr(){return this.clone().sqrThis()}sqrThis(){return this.mulThis(this.clone())}static sqrt(t,e){if(t.m_sign<0n&&i("MP_value: sqrt(-1)"),t.isZero())return t.clone();let n=52,r=2220446049250313e-31;for(;n<e;)2*n<=e?(r*=r,n*=2):(r*=2220446049250313e-31,n+=52);n+=52;const h=es(t.m_rn.v),o=es(t.m_rd.v);let a,u=t.m_power+Number(h-o);const l=new Ws;Math.abs(u)>200?(1&Math.abs(u)&&(u+=1),a=Ws.constructAssign(t,53).ldexpThis(-u).value(),l.setThis(t).ldexpThis(-u),s(Number.isFinite(a))):(l.setThis(t),a=l.value(),s(Number.isFinite(a)),u=0),a=Math.sqrt(a);const m=Ws.constructDouble(a),c=Ws.constructDouble(r);c.mulThis(m).ldexpThis(1);const y=r*a*2,x=m.clone(),f=new Ws;let d;for(let s=0;s<10;++s){x.mulThis(m),f.setThis(l).subThis(x).absThis();let t=f.value();if(d=1,t<.9)for(;t>y;)t*=t,++d;else d=4;if(f.lte(c))break;for(let s=0;s<d;s++)x.setThis(m).divThis(l).invertThis().addThis(m).ldexpThis(-1).limitPrecisionThis(n),m.setThis(x)}return m.ldexpThis(u/2)}static cubicRoot(t,s){if(t.isZero())return t.clone();let i=52,e=2220446049250313e-31;for(;i<s;)2*i<=s?(e*=e,i*=2):(e*=2220446049250313e-31,i+=52);i+=52;const n=Math.pow(Math.abs(t.value()),1/3),r=Ws.constructDouble(n),h=r.clone();h.sqrThis().mulDoubleThis(3).mulDoubleThis(e),h.limitPrecisionThis(32),t.LZ()&&r.negateThis();for(let o=0;o<10;++o){const s=r.clone();s.sqrThis().mulThis(r);const e=s.clone();if(e.subThis(t),e.absThis().limitPrecisionThis(32),e.lte(h))break;e.setThis(t),e.ldexpThis(1),e.addThis(s);const n=s.clone();n.ldexpThis(1),n.addThis(t),e.divThis(n),r.mulThis(e),r.limitPrecisionThis(i)}return r}isInTheRangeOfDouble(){return s(0),!1}sign(){return this.m_sign}cosAndSin(t,i){s(0)}static nan(){return s(0),new Ws}convertToDouble(){if(this.m_bNaN)return Number.NaN;if(this.isZero())return 0;if(0n===this.m_rd.v)return 1===this.m_sign?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;const t=-1===this.m_sign,s=this.m_rn.v<<(this.m_power>=0?BigInt(this.m_power):0n);let i=this.m_rd.v<<(this.m_power<0?BigInt(-this.m_power):0n);const e=s/i;let n=Number(e);if(BigInt(n)!==e)return t?-n:n;let r=s-e*i;if(r){let t=es(i)-1023n;t>0n&&(i>>=t,r<<=52n,r>>=t);let s=Number(r);Number.isFinite(s)||(r>>=52n,s=Number(r),t=0n),t>0n&&(s/=Math.pow(2,52));n+=s/Number(i)}return t?-n:n}signVal(){return 1===this.m_sign?1n:-1===this.m_sign?-1n:0n}opPlusMinus(t,s){const i=Math.min(this.m_power,t.m_power);let e,n;this.m_power>i?(e=BigInt(this.m_power-i),n=0n):(e=0n,n=BigInt(t.m_power-i));const r=this.signVal()*this.m_rn.v*t.m_rd.v<<e,h=t.signVal()*t.m_rn.v*this.m_rd.v<<n;return this.m_rn.v=s?r+h:r-h,this.m_rd.v*=t.m_rd.v,this.m_power=i,this.m_sign=1,this.m_rn.v<0n&&(this.m_sign=-1,this.m_rn.v=-this.m_rn.v),this.m_bNormalized=!1,this.normalizeThis(),this}}Ws.s_sm=0x8000000000000000n,Ws.s_em=0x7ff0000000000000n,Ws.s_fm=0x000fffffffffffffn,Ws.s_emax=0x7ffn;const Ys=Ws.constructInt32(1),js=Ws.constructInt32(0);function Xs(t,s){return v(t^s)}function $s(t,s){let i=is(t);const e=is(s);if(i===e){return i-=53-Xs(ss(t),ss(s)),i}return i>e?i:e}function Hs(t){const s=zt(Js,t.length);for(let i=0,e=t.length;i<e;++i)s[i].setCoords(t[i][0],t[i][1]);return s}class Js{static construct(t,s){return new Js(t,s)}constructor(t,s){void 0!==t?(this.x=t,this.y=s):this.x=this.y=Number.NaN}clone(){return new Js(this.x,this.y)}assign(t){this.setCoordsPoint2D(t)}setCoords(t,s){return this.x=t,this.y=s,this}setCoordsPoint2D(t){this.x=t.x,this.y=t.y}isEqualPoint2D(t,s){return void 0!==s?Math.abs(this.x-t.x)<=s&&Math.abs(this.y-t.y)<=s:this.x===t.x&&this.y===t.y}isEqual(t,s,i){return void 0!==i?Math.abs(this.x-t)<=i&&Math.abs(this.y-s)<=i:this.x===t&&this.y===s}equalsPoint2D(t,s){return this.isEqualPoint2D(t,s)}setSub(t,s){this.x=t.x-s.x,this.y=t.y-s.y}addThis(t){return this.x+=t.x,this.y+=t.y,this}setAdd(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this}absoluteOther(t){}absolute(){return s(0),this}setNegate(){this.x=-this.x,this.y=-this.y}setNegateOther(t){this.x=-t.x,this.y=-t.y}interpolateThis(t,s){}interpolate(t,i,e){s(0)}scaleAddThis(t,s){this.x=this.x*t+s.x,this.y=this.y*t+s.y}setScaleAdd(t,s,i){this.x=s.x*t+i.x,this.y=s.y*t+i.y}scaleOther(t,i){s(0)}scale(t){this.x*=t,this.y*=t}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:0}compareX(t){return this.x<t.x?-1:this.x>t.x?1:this.y<t.y?-1:this.y>t.y?1:0}normalizeOther(t){s(0)}normalize(){const t=this.length();return t?(this.x/=t,this.y/=t):(this.x=1,this.y=0),this}getUnitVector(){return this.clone().normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}sqrLength(){return this.x*this.x+this.y*this.y}static averageFast(t,i){return s(0),{}}static average(t,s){const i=new Js;if(0===s)return i.setNAN(),i;if(1===s)return i.assign(t[0]),i;const e=new r(t[0].x),n=new r(t[0].y);for(let r=1;r<s;r++)e.add(t[r].x),n.add(t[r].y),255&r||(e.normalize(),n.normalize());return i.x=e.getResult()/s,i.y=n.getResult()/s,i}offset(t,s){const i=Js.distance(t,s),e=Js.construct(this.x,this.y);if(0===i)return Js.distance(e,t);const n=s.clone();n.subThis(t),e.subThis(t);return e.crossProduct(n)/i}side(t,s){return t.equals(s)?this.equals(t)?0:1:Js.orientationRobust(s,t,this)}static sqrDistance(t,s){const i=t.x-s.x,e=t.y-s.y;return i*i+e*e}static sqrDistanceCoords(t,s,i,e){const n=i-t,r=e-s;return n*n+r*r}static distance(t,s){return Math.sqrt(Js.sqrDistance(t,s))}dotProduct(t){return this.x*t.x+this.y*t.y}dotProductAbs(t){return Math.abs(this.x*t.x)+Math.abs(this.y*t.y)}crossProduct(t){return this.x*t.y-this.y*t.x}crossProductAbs(t){return s(0),0}rotateDirect(t,s){const i=this.x*t-this.y*s,e=this.x*s+this.y*t;this.x=i,this.y=e}rotateReverse(t,s){const i=this.x*t+this.y*s,e=-this.x*s+this.y*t;this.x=i,this.y=e}leftPerpendicularThis(){const t=this.x;this.x=-this.y,this.y=t}leftPerpendicularOther(t){const s=t.x;this.x=-t.y,this.y=s}rightPerpendicularThis(){const t=this.x;this.x=this.y,this.y=-t}rightPerpendicularOther(t){const s=t.x;this.x=t.y,this.y=-s}equals(t){return this.x===t.x&&this.y===t.y}notequals(t){return this.x!==t.x||this.y!==t.y}not(){return!this.x&&!this.y}gt(t){return this.y>t.y||this.y===t.y&&this.x>t.x}gte(t){return!this.lt(t)}lt(t){return this.y<t.y||this.y===t.y&&this.x<t.x}lte(t){return!this.gt(t)}subThis(t){return this.x-=t.x,this.y-=t.y,this}divThis(t){return this.x/=t,this.y/=t,this}add(t){return new Js(this.x+t.x,this.y+t.y)}sub(t){return new Js(this.x-t.x,this.y-t.y)}negateThis(){return this.x=-this.x,this.y=-this.y,this}negate(){return new Js(-this.x,-this.y)}mul(t){return new Js(this.x*t,this.y*t)}mulThis(t){return this.x*=t,this.y*=t,this}divide(t){return new Js(this.x/t,this.y/t)}setNAN(){this.x=this.y=Number.NaN}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)}static getNAN(){return new Js(Number.NaN,Number.NaN)}isFinite(){return Number.isFinite(this.x)&&Number.isFinite(this.y)}isZero(){return 0===this.x&&0===this.y}norm(t){switch(t){case 0:{const t=Math.abs(this.x),s=Math.abs(this.y),i=t-s;return i>=0?t:i<=0?s:Number.NaN}case 1:return Math.abs(this.x)+Math.abs(this.y);case 2:return Math.sqrt(this.x*this.x+this.y*this.y);default:e("norm")}}getQuarter(){return Js.getQuarterCoords(this.x,this.y)}static getQuarterCoords(t,s){return t>0?s>=0?1:4:s>0?2:0===t?4:3}static compareVectors(t,s){const i=t.getQuarter(),e=s.getQuarter();return e===i?Js.orientationRobustImpl(Js.construct(0,0),s,t,!0):i<e?-1:1}static compareVectorsOrigin(t,s,i){const e=s.sub(t),n=i.sub(t),r=e.getQuarter(),h=n.getQuarter();return h===r?Js.orientationRobustImpl(t,i,s,!0):r<h?-1:1}static orientationRobust(t,s,i){return Js.orientationRobustImpl(t,s,i,!1)}static orientationRobustEx(t,s,i,e){if(t.equals(s)||i.equals(e))return 0;const n=s.x-t.x,r=s.y-t.y,h=e.x-i.x,o=e.y-i.y;{const t=Js.getQuarterCoords(n,r)-1,s=Js.getQuarterCoords(h,o)-1,i=Js.d[t][s];if(0!==i)return i}const a=n*o,u=r*h,l=4*zs()*(Math.abs(a)+Math.abs(u)),m=a-u;if(Math.abs(m)>=l){return m<0?-1:m>0?1:0}return Js.orientationRobustExMp(t,s,i,e)}static orientationRobustExMp(t,s,i,e){const n=Ws.constructDouble(s.x),r=Ws.constructDouble(e.x);n.subThis(Ws.constructDouble(t.x)),r.subThis(Ws.constructDouble(i.x));const h=Ws.constructDouble(s.y),o=Ws.constructDouble(e.y);return h.subThis(Ws.constructDouble(t.y)),o.subThis(Ws.constructDouble(i.y)),n.mulThis(o),h.mulThis(r),n.subThis(h),n.LZ()?-1:n.GZ()?1:0}static orientationNonRobust(t,s,i){const e=s.sub(t).crossProduct(i.sub(t));return e<0?-1:e>0?1:0}static orientationRobustImpl(t,s,i,e){if(s.isEqualPoint2D(t)||i.isEqualPoint2D(t)||s.isEqualPoint2D(i))return 0;const n=s.x-t.x,r=s.y-t.y,h=i.x-t.x,o=i.y-t.y;if(!e){const t=Js.getQuarterCoords(n,r)-1,s=Js.getQuarterCoords(h,o)-1,i=Js.d[t][s];if(0!==i)return i}const a=(Math.abs(n)+Math.abs(r)+Math.abs(h)+Math.abs(o))*(Math.abs(s.x)+Math.abs(s.y)+Math.abs(i.x)+Math.abs(i.y))*8*T(),u=n*o-r*h;if(Math.abs(u)>a){return u<0?-1:1}if(C(s.x,t.x)&&C(i.y,t.y)&&C(s.y,t.y)&&C(i.x,t.x)&&M(n,o)&&M(r,h)){const t=n*o,s=r*h;if(C(t,s)){const i=t-s;return i<0?-1:i>0?1:0}}return Js.orientationRobustMp(t,s,i)}static orientationRobustMp(t,s,i){const e=Ws.constructDouble(s.x),n=Ws.constructDouble(i.x);{const s=Ws.constructDouble(t.x);e.subThis(s),n.subThis(s)}const r=Ws.constructDouble(i.y),h=Ws.constructDouble(s.y);{const s=Ws.constructDouble(t.y);r.subThis(s),h.subThis(s)}return e.mulThis(r),h.mulThis(n),e.subThis(h),e.LZ()?-1:e.GZ()?1:0}static inCircleRobust(t,s,i,e){const n=new w,r=new w;n.set(t.x),n.subThis(e.x),r.set(t.y),r.subThis(e.y);const h=new w,o=new w;h.set(s.x),h.subThis(e.x),o.set(s.y),o.subThis(e.y);const a=new w,u=new w;a.set(i.x),a.subThis(e.x),u.set(i.y),u.subThis(e.y);const l=n.mulE(o).subE(r.mulE(h)),m=h.mulE(u).subE(o.mulE(a)),c=n.mulE(u).subE(r.mulE(a)),y=n.mulE(n).addE(r.mulE(r)),x=h.mulE(h).addE(o.mulE(o)),f=a.mulE(a).addE(u.mulE(u)),d=y.mulE(m).subE(x.mulE(c)).addE(f.mulE(l));if(!d.isFuzzyZero()){const t=d.value();return t<0?-1:t>0?1:0}return Js.inCircleRobustMp(t,s,i,e)}static inCircleRobustMp(t,s,i,e){do{if(!C(t.x,e.x)||!C(t.y,e.y))break;if(!C(s.x,e.x)||!C(s.y,e.y))break;if(!C(i.x,e.x)||!C(i.y,e.y))break;const n=t.x-e.x,r=t.y-e.y,h=s.x-e.x,o=s.y-e.y,a=i.x-e.x,u=i.y-e.y;if(!M(n,o)||!M(r,h))break;if(!M(h,u)||!M(o,a))break;if(!M(n,u)||!M(r,a))break;if(!M(n,n)||!M(r,r))break;if(!M(h,h)||!M(o,o))break;if(!M(a,a)||!M(u,u))break;const l=n*o,m=r*h,c=h*u,y=o*a,x=n*u,f=r*a,d=n*n,b=r*r,v=h*h,_=o*o,N=a*a,w=u*u;if(!C(l,m))break;if(!C(c,y))break;if(!C(x,f))break;if(!p(d,b))break;if(!p(v,_))break;if(!p(N,w))break;const T=l-m,R=c-y,g=x-f,E=d+b,I=v+_,D=N+w;if(!M(E,R))break;if(!M(I,g))break;if(!M(D,T))break;const A=E*R,P=I*g,q=D*T;if(!C(A,P))break;const z=A-P;if(!p(z,q))break;const Z=z+q;return Z<0?-1:Z>0?1:0}while(0);const n=Ws.constructDouble(e.x),r=Ws.constructDouble(e.y),h=Ws.constructDouble(t.x),o=Ws.constructDouble(t.y);h.subThis(n),o.subThis(r);const a=Ws.constructDouble(s.x),u=Ws.constructDouble(s.y);a.subThis(n),u.subThis(r);const l=Ws.constructDouble(i.x),m=Ws.constructDouble(i.y);l.subThis(n),m.subThis(r);const c=h.mul(u).sub(o.mul(a)),y=a.mul(m).sub(u.mul(l)),x=h.mul(m).sub(o.mul(l)),f=h.mul(h).add(o.mul(o)),d=a.mul(a).add(u.mul(u)),b=l.mul(l).add(m.mul(m)),v=f.mul(y).sub(d.mul(x)).add(b.mul(c));return v.LZ()?-1:v.GZ()?1:0}static inCircleRobustMp3Point(t,s,i){const e=Ws.constructDouble(t.x),n=Ws.constructDouble(t.y),r=Ws.constructDouble(s.x),h=Ws.constructDouble(s.y),o=Ws.constructDouble(i.x),a=Ws.constructDouble(i.y),u=o.mul(o).add(a.mul(a)).sub(o.mul(e).add(a.mul(n)).add(o.mul(r)).add(a.mul(h))).add(e.mul(r).add(n.mul(h)));return u.LZ()?-1:u.GZ()?1:0}static inCircleRobust3Point(t,s,i){const e=new w(t.x),n=new w(t.y),r=new w(s.x),h=new w(s.y),o=new w(i.x),a=new w(i.y),u=o.mulE(o).addE(a.mulE(a)).subE(o.mulE(e).addE(a.mulE(n)).addE(o.mulE(r)).addE(a.mulE(h))).addE(e.mulE(r).addE(n.mulE(h)));if(!u.isFuzzyZero()){const t=u.value();return t<0?-1:t>0?1:0}return Js.inCircleRobustMp3Point(t,s,i)}static calculateCircleCenterFromThreePoints(t,s,i){if(t.equals(i)||t.equals(s)||i.equals(s))return Js.getNAN();const e=Ks(t,s,i);return e.isNAN()?ti(t,s,i):e}static calculateAngle(t,s){return Math.atan2(t.crossProduct(s),t.dotProduct(s))}static isBisectorRobust(t,i,e){return s(0),!1}static size(){return 2}get 0(){return this.x}get 1(){return this.y}set 0(t){this.x=t}set 1(t){this.y=t}static compareZorder(t,s){const i=Js.c_compare_zorder_xx[t.x<0?1:0]|Js.c_compare_zorder_yy[t.y<0?1:0],e=Js.c_compare_zorder_xx[s.x<0?1:0]|Js.c_compare_zorder_yy[s.y<0?1:0];if(i===e){let i=0,e=0;for(let n=0;n<2;++n){const r=$s(t[n],s[n]);r>i&&(i=r,e=n)}return t[e]<s[e]}return i<e}static lerp(t,s,i){const e=new Js;return Y(t,s,i,e),e}static getClosestCoordinate(t,s,i,e=!1){const n=Js.getNAN();n.setSub(s,t);const r=n.sqrLength();if(0===r)return.5;if(s.isEqualPoint2D(i))return 1;const h=Js.getNAN();h.setSub(i,t);let o=h.dotProduct(n)/r;return e||(o<0?o=0:o>1&&(o=1)),o}static intersectLinesAtOnePoint(t,s,i,e){if(t.equals(s)||i.equals(e))return Js.getNAN();const n=s.x-t.x,r=i.x-e.x,h=s.y-t.y,o=i.y-e.y,a=n*o-r*h;if(!a)return Js.getNAN();const u=a;if(0===u)return Js.getNAN();let l=(i.x-t.x)*o-(i.y-t.y)*r;l/=u;const m=new Js;return Y(t,s,l,m),m.isFinite()?m:Js.getNAN()}toString(){return`[${this.x},${this.y}]`}}function Ks(t,s,i){const e=new w(s.x);e.subThis(t.x);const n=new w(s.y);n.subThis(t.y);const r=new w(i.x);r.subThis(t.x);const h=new w(i.y);h.subThis(t.y);const o=e.clone();o.mulThisE(h);let a=n.clone();if(a.mulThisE(r),o.subThisE(a),0===o.value())return Js.getNAN();o.mulThis(2);const u=e.clone();u.mulThisE(e);const l=n.clone();l.mulThisE(n);const m=u.clone();m.addThisE(l);const c=r.clone();c.mulThisE(r);const y=h.clone();y.mulThisE(h);const x=c.clone();x.addThisE(y);const f=n.clone();f.mulThisE(x),a=h.clone(),a.mulThisE(m),f.subThisE(a),f.divThisE(o);const d=e.clone();d.mulThisE(x),a=r.clone(),a.mulThisE(m),d.subThisE(a),d.divThisE(o);const b=Js.construct(t.x-f.value(),t.y+d.value()),v=t.sub(b).length(),_=s.sub(b).length(),N=i.sub(b).length(),M=1e-15*(v+Math.abs(t.x)+Math.abs(s.x)+Math.abs(i.x)+Math.abs(t.y)+Math.abs(s.y)+Math.abs(i.y));return Math.abs(v-_)<=M&&Math.abs(v-N)<=M&&f.eps()<M&&d.eps()<M?b:Js.getNAN()}function ti(t,s,i){const e=Ws.constructDouble(s.x);e.subDoubleThis(t.x);const n=Ws.constructDouble(s.y);n.subDoubleThis(t.y);const r=Ws.constructDouble(i.x);r.subDoubleThis(t.x);const h=Ws.constructDouble(i.y);h.subDoubleThis(t.y);const o=e.clone();o.mulThis(h);let a=n.clone();if(a.mulThis(r),o.subThis(a),o.isZero())return Js.getNAN();o.mulDoubleThis(2);const u=e.clone();u.mulThis(e);const l=n.clone();l.mulThis(n);const m=u.clone();m.addThis(l);const c=r.clone();c.mulThis(r);const y=h.clone();y.mulThis(h);const x=c.clone();x.addThis(y);const f=n.clone();f.mulThis(x),a=h.clone(),a.mulThis(m),f.subThis(a),f.divThis(o);const d=e.clone();d.mulThis(x),a=r.clone(),a.mulThis(m),d.subThis(a),d.divThis(o);return Js.construct(t.x-f.value(),t.y+d.value())}Js.dimensions=2,Js.d=[[0,1,0,-1],[-1,0,1,0],[0,-1,0,1],[1,0,-1,0]],Js.c_compare_zorder_xx=[2,0],Js.c_compare_zorder_yy=[1,0];class si{constructor(t,s,i){if(t instanceof si)return this.data=t.data,this.N=t.N,this.M=t.M,t.data=null,t.N=0,void(t.M=0);this.data=t,this.N=s,this.M=i}assignCopy(t){return this===t||(s(this.N*this.M==t.N*t.M),this.data.set(t.data),this.N=t.N,this.M=t.M),this}setZero(){return this.data?.fill(0),this}setIdentity(){const t=0,s=1;for(let i=0;i<this.N;i++)for(let e=0;e<this.M;e++)this.setRowCol(i,e,i===e?s:t);return this}rows(){return this.N}cols(){return this.M}row(t){return s(0),{}}set(t,s){return this.data[t]=s,this}setRowCol(t,s,i){return this.data[t*this.M+s]=i,this}at(t){return this.data[t]}atRowCol(t,s){return this.data[t*this.M+s]}mulScalar(t,i){s(0)}mul(t,i){if(s(this.M===t.rows()),s(this.N===i.rows()),s(t.cols()===i.cols()),i===this){const s=new Float64Array(this.N*this.M),e=new si(s,this.N,this.M);return this.mul(t,e),void i.assignCopy(e)}if(i===t){const s=new Float64Array(t.N*t.M),e=new si(s,t.N,t.M);return this.mul(t,e),void i.assignCopy(e)}const e=t.cols();for(let s=0;s<this.N;s++)for(let n=0;n<e;n++){let e=0;for(let i=0;i<this.M;i++)e+=this.atRowCol(s,i)*t.atRowCol(i,n);i.setRowCol(s,n,e)}}mulTranspose(t,i){if(s(this.M===t.cols()),s(this.N===i.rows()),s(t.rows()===i.cols()),i===this){const s=new Float64Array(this.N*this.M),e=new si(s,this.N,this.M);return this.mulTranspose(t,e),void i.assignCopy(e)}if(i===t){const s=new Float64Array(t.N*t.M),e=new si(s,t.N,t.M);return this.mulTranspose(t,e),void i.assignCopy(e)}const e=t.rows();for(let s=0;s<this.N;s++)for(let n=0;n<e;n++){let e=0;for(let i=0;i<this.M;i++)e+=this.atRowCol(s,i)*t.atRowCol(n,i);i.setRowCol(s,n,e)}}mulLeft(t,i){s(0)}mulLeftTranspose(t,i){s(0)}mulDiag(t,i){if(s(this.M===t.N*t.M),s(this.N===i.rows()),s(this.M===i.cols()),i===this){const s=new Float64Array(this.N*this.M),e=new si(s,this.N,this.M);return this.mulDiag(t,e),void i.assignCopy(e)}const e=this.M;for(let s=0;s<this.N;s++)for(let n=0;n<e;n++)i.setRowCol(s,n,this.atRowCol(s,n)*t.at(n))}transposeInPlace(){if(this.N===this.M){for(let t=0;t<this.N;t++)for(let s=t+1;s<this.M;s++){const i=this.atRowCol(t,s);this.setRowCol(t,s,this.atRowCol(s,t)),this.setRowCol(s,t,i)}return this}const t=new Float64Array(this.N*this.M),s=new si(t,this.N,this.M);return s.assignCopy(this),this.M=Tt(this.N,this.N=this.M),s.transpose(this),this}transpose(t){if(this!==t){si.checkDims(t,this.M,this.N);for(let s=0;s<this.N;s++)for(let i=0;i<this.M;i++)t.setRowCol(i,s,this.atRowCol(s,i))}else t.transposeInPlace()}add(t,s){}svd(t,i,e,n=!1){if(si.checkDims(t,this.N,this.M),si.checkDims(i,this.M,1),si.checkDims(e,this.M,this.M),n){if(s(this.N===this.M),!this.symmetricEigen(i,e))return!1;for(let t=0;t<this.M;++t)i.at(t)<0&&i.set(t,0);return t.assignCopy(e),!0}let r,h,o,a,u,l,m,c=0,y=0,x=0,f=0,d=0;const b=this.M,v=this.N;t.assignCopy(this);const _=new Float64Array(b),N=new si(_,b,1),w=(t,s)=>s>=0?Math.abs(t):-Math.abs(t),M=(t,s)=>{if((t=Math.abs(t))>(s=Math.abs(s))){const i=s/t;return t*Math.sqrt(i*i+1)}if(s>0){const i=t/s;return s*Math.sqrt(i*i+1)}return 0};for(let s=0;s<b;s++){if(c=s+1,N.set(s,f*x),x=a=f=0,s<v){for(let i=s;i<v;i++)f+=Math.abs(t.atRowCol(i,s));if(f){for(let i=s;i<v;i++)t.setRowCol(i,s,t.atRowCol(i,s)/f),a+=t.atRowCol(i,s)*t.atRowCol(i,s);h=t.atRowCol(s,s),x=-w(Math.sqrt(a),h),o=h*x-a,t.setRowCol(s,s,h-x);for(let i=c;i<b;i++){a=0;for(let e=s;e<v;e++)a+=t.atRowCol(e,s)*t.atRowCol(e,i);h=a/o;for(let e=s;e<v;e++)t.setRowCol(e,i,t.atRowCol(e,i)+h*t.atRowCol(e,s))}for(let i=s;i<v;i++)t.setRowCol(i,s,t.atRowCol(i,s)*f)}}if(i.set(s,f*x),x=a=f=0,s<v&&s!==b-1){for(let i=c;i<b;i++)f+=Math.abs(t.atRowCol(s,i));if(f){for(let i=c;i<b;i++)t.setRowCol(s,i,t.atRowCol(s,i)/f),a+=t.atRowCol(s,i)*t.atRowCol(s,i);h=t.atRowCol(s,c),x=-w(Math.sqrt(a),h),o=h*x-a,t.setRowCol(s,c,h-x);for(let i=c;i<b;i++)N.set(i,t.atRowCol(s,i)/o);for(let i=c;i<v;i++){a=0;for(let e=c;e<b;e++)a+=t.atRowCol(i,e)*t.atRowCol(s,e);for(let s=c;s<b;s++)t.setRowCol(i,s,t.atRowCol(i,s)+a*N.at(s))}for(let i=c;i<b;i++)t.setRowCol(s,i,t.atRowCol(s,i)*f)}}const e=Math.abs(i.at(s))+Math.abs(N.at(s));d=e>d?e:d}for(let s=b-1;s>=0;s--){if(s<b-1){if(x){for(let i=c;i<b;i++)e.setRowCol(i,s,t.atRowCol(s,i)/t.atRowCol(s,c)/x);for(let i=c;i<b;i++){a=0;for(let n=c;n<b;n++)a+=t.atRowCol(s,n)*e.atRowCol(n,i);for(let t=c;t<b;t++)e.setRowCol(t,i,e.atRowCol(t,i)+a*e.atRowCol(t,s))}}for(let t=c;t<b;t++)e.setRowCol(s,t,0),e.setRowCol(t,s,0)}e.setRowCol(s,s,1),x=N.at(s),c=s}for(let s=(v<b?v:b)-1;s>=0;s--){c=s+1,x=i.at(s);for(let i=c;i<b;i++)t.setRowCol(s,i,0);if(x){x=1/x;for(let i=c;i<b;i++){a=0;for(let e=c;e<v;e++)a+=t.atRowCol(e,s)*t.atRowCol(e,i);h=a/t.atRowCol(s,s)*x;for(let e=s;e<v;e++)t.setRowCol(e,i,t.atRowCol(e,i)+h*t.atRowCol(e,s))}for(let i=s;i<v;i++)t.setRowCol(i,s,t.atRowCol(i,s)*x)}else for(let i=s;i<v;i++)t.setRowCol(i,s,0);t.setRowCol(s,s,t.atRowCol(s,s)+1)}for(let s=b-1;s>=0;s--)for(let n=1;;n++){let f=1;for(c=s;c>=0;c--){if(y=c-1,Math.abs(N.at(c))+d===d){f=0;break}if(Math.abs(i.at(y))+d===d)break}if(f){r=0,a=1;for(let e=c;e<=s&&(h=a*N.at(e),N.set(e,N.at(e)*r),Math.abs(h)+d!==d);e++){x=i.at(e),o=M(h,x),i.set(e,o),o=1/o,r=x*o,a=-h*o;for(let s=0;s<v;s++)l=t.atRowCol(s,y),m=t.atRowCol(s,e),t.setRowCol(s,y,l*r+m*a),t.setRowCol(s,e,m*r-l*a)}}if(m=i.at(s),c===s){if(m<0){i.set(s,-m);for(let t=0;t<b;t++)e.setRowCol(t,s,-e.atRowCol(t,s))}break}if(100===n)return!1;u=i.at(c),y=s-1,l=i.at(y),x=N.at(y),o=N.at(s),h=((l-m)*(l+m)+(x-o)*(x+o))/(2*o*l),x=M(h,1),h=((u-m)*(u+m)+o*(l/(h+w(x,h))-o))/u,r=a=1;for(let s=c;s<=y;s++){const n=s+1;x=N.at(n),l=i.at(n),o=a*x,x*=r,m=M(h,o),N.set(s,m),r=h/m,a=o/m,h=u*r+x*a,x=x*r-u*a,o=l*a,l*=r;for(let t=0;t<b;t++)u=e.atRowCol(t,s),m=e.atRowCol(t,n),e.setRowCol(t,s,u*r+m*a),e.setRowCol(t,n,m*r-u*a);m=M(h,o),i.set(s,m),m&&(m=1/m,r=h*m,a=o*m),h=r*x+a*l,u=r*l-a*x;for(let i=0;i<v;i++)l=t.atRowCol(i,s),m=t.atRowCol(i,n),t.setRowCol(i,s,l*r+m*a),t.setRowCol(i,n,m*r-l*a)}N.set(c,0),N.set(s,h),i.set(s,u)}const p=new Float64Array(this.N),C=new Float64Array(this.M),T=new si(p,this.N,1),R=new si(C,this.M,1);let g=1;do{g*=3,g++}while(g<=this.M);do{g/=3,g=Math.trunc(g);for(let s=g;s<this.M;s++){const n=i.at(s);for(let i=0;i<this.N;i++)T.set(i,t.atRowCol(i,s));for(let t=0;t<this.M;t++)R.set(t,e.atRowCol(t,s));let r=s;for(;i.at(r-g)<n;){i.set(r,i.at(r-g));for(let s=0;s<this.N;s++)t.setRowCol(s,r,t.atRowCol(s,r-g));for(let t=0;t<this.M;t++)e.setRowCol(t,r,e.atRowCol(t,r-g));if(r-=g,r<g)break}i.set(r,n);for(let s=0;s<this.N;s++)t.setRowCol(s,r,T.at(s));for(let t=0;t<this.M;t++)e.setRowCol(t,r,R.at(t))}}while(g>1);for(let s=0;s<this.M;s++){let i=0;for(let e=0;e<this.N;e++)t.atRowCol(e,s)<0&&i++;for(let t=0;t<this.M;t++)e.atRowCol(t,s)<0&&i++;if(i>Math.trunc((this.N+this.M)/2)){for(let i=0;i<this.N;i++)t.setRowCol(i,s,-t.atRowCol(i,s));for(let t=0;t<this.M;t++)e.setRowCol(t,s,-e.atRowCol(t,s))}}return!0}isSymmetric(){if(this.N!==this.M)return!1;for(let t=0;t<this.N;t++)for(let s=t+1;s<this.M;s++)if(this.atRowCol(t,s)!==this.atRowCol(s,t))return!1;return!0}isZero(){return s(0),!1}isIdentity(){return s(0),!1}equals(t,i){if(void 0!==i&&s(0),this.N!==t.N||this.M!==t.M)return!1;for(let s=0;s<this.N*this.M;s++)if(this.data[s]!==t.data[s])return!1;return!0}maxElement(){return s(0),0}minElement(){return s(0),0}determinant(){if(s(this.N===this.M),1===this.N)return this.data[0];if(2===this.N)return this.data[0]*this.data[3]-this.data[1]*this.data[2];if(3===this.N){const t=this;return t.atRowCol(0,0)*(t.atRowCol(1,1)*t.atRowCol(2,2)-t.atRowCol(1,2)*t.atRowCol(2,1))-t.atRowCol(0,1)*(t.atRowCol(1,0)*t.atRowCol(2,2)-t.atRowCol(2,0)*t.atRowCol(1,2))+t.atRowCol(0,2)*(t.atRowCol(1,0)*t.atRowCol(2,1)-t.atRowCol(1,1)*t.atRowCol(2,0))}const t=new Float64Array(this.N*this.N),i=new si(t,this.N,this.N),e=new Float64Array(this.N);if(!this.luDecomposition(i,e))return 0;let n=1;for(let s=0;s<this.N;s++)n*=i.atRowCol(s,s),e[s]!==s&&(n=-n);return n}submatrix(t,i,e){s(0)}inverse(t){s(0)}pseudoInverse(t,s=!1,i=2220446049250313e-31){if(t.setZero(),1===this.N&&1===this.M)return 0!==this.atRowCol(0,0)?t.setRowCol(0,0,1/this.atRowCol(0,0)):t.setRowCol(0,0,0),!0;if(2===this.N&&2===this.M){const s=this.atRowCol(0,0)*this.atRowCol(1,1)-this.atRowCol(0,1)*this.atRowCol(1,0),i=1e-5*(Math.abs(this.atRowCol(0,0)*this.atRowCol(1,1))+Math.abs(this.atRowCol(0,1)*this.atRowCol(1,0)));if(Math.abs(s)>i)return t.setRowCol(0,0,this.atRowCol(1,1)/s),t.setRowCol(0,1,-this.atRowCol(0,1)/s),t.setRowCol(1,0,-this.atRowCol(1,0)/s),t.setRowCol(1,1,this.atRowCol(0,0)/s),!0}const e=new Float64Array(this.N*this.M),n=new si(e,this.N,this.M),r=new Float64Array(this.M),h=new si(r,this.M,1),o=new Float64Array(this.M*this.M),a=new si(o,this.M,this.M);if(!this.svd(n,h,a,s))return!1;const u=Math.max(this.N,this.M),l=i*Math.abs(h.at(0))*u;for(let m=0;m<this.M;m++)h.at(m)>l?h.set(m,1/h.at(m)):h.set(m,0);return a.mulDiag(h,t),t.mulTranspose(n,t),!0}luDecomposition(t,i){return s(0),!1}symmetricEigen(t,i){s(this.rows()===this.cols()),s(this.rows()===t.rows()),s(i.rows()===i.cols()&&i.rows()===this.rows()),s(this.isSymmetric());const e=new Float64Array(this.N*this.M),n=new si(e,this.N,this.M);n.assignCopy(this);const r=100/Number.EPSILON,h=this.rows(),o=new Float64Array(h),a=new Float64Array(h),u=new si(o,h,1),l=new si(a,h,1);for(let s=0;s<h;s++)u.set(s,n.atRowCol(s,s)),t.set(s,n.atRowCol(s,s)),l.set(s,0);i.setIdentity();const m=()=>{const s=u;i.transposeInPlace();let e=1;do{e*=3,e++}while(e<=h);do{e/=3,e=Math.trunc(e);for(let n=e;n<h;n++){const r=t.at(n),h=Math.abs(r);for(let t=0;t<this.M;t++)s.set(t,i.atRowCol(t,n));let o=n;for(;Math.abs(t.at(o-e))<h;){t.set(o,t.at(o-e));for(let t=0;t<this.M;t++)i.setRowCol(t,o,i.atRowCol(t,o-e));if(o-=e,o<e)break}if(o!==n){t.set(o,r);for(let t=0;t<this.M;t++)i.setRowCol(t,o,s.at(t))}}}while(e>1)};for(let s=1;;s++){let e=0;for(let t=1;t<h;t++)for(let s=0;s<t;s++)e+=Math.abs(n.atRowCol(t,s));if(0===e)return m(),!0;const o=s<4?.2*e/(h*h):0;for(let a=0;a<h;a++)for(let e=a+1;e<h;e++){let u=r*Math.abs(n.atRowCol(e,a));if(s>4&&u<=Math.abs(t.at(a))&&u<=Math.abs(t.at(e)))n.setRowCol(e,a,0);else if(Math.abs(n.atRowCol(e,a))>o){let s,r=t.at(e)-t.at(a);if(u<Math.abs(r))s=n.atRowCol(e,a)/r;else{const t=.5*r/n.atRowCol(e,a);s=1/(Math.abs(t)+Math.sqrt(1+t*t)),t<0&&(s=-s)}const o=1/Math.sqrt(1+s*s),m=s*o,c=m/(1+o);r=s*n.atRowCol(e,a),l.set(a,l.at(a)-r),l.set(e,l.at(e)+r),t.set(a,t.at(a)-r),t.set(e,t.at(e)+r),n.setRowCol(e,a,0);let y=0;for(;y<a;y++)u=n.atRowCol(a,y),r=n.atRowCol(e,y),n.setRowCol(a,y,u-m*(r+u*c)),n.setRowCol(e,y,r+m*(u-r*c));for(y++;y<e;y++)u=n.atRowCol(y,a),r=n.atRowCol(e,y),n.setRowCol(y,a,u-m*(r+u*c)),n.setRowCol(e,y,r+m*(u-r*c));for(y++;y<h;y++)u=n.atRowCol(y,a),r=n.atRowCol(y,e),n.setRowCol(y,a,u-m*(r+u*c)),n.setRowCol(y,e,r+m*(u-r*c));for(y=0;y<h;y++)u=i.atRowCol(a,y),r=i.atRowCol(e,y),i.setRowCol(a,y,u-m*(r+u*c)),i.setRowCol(e,y,r+m*(u-r*c))}}for(let s=0;s<h;s++)u.set(s,u.at(s)+l.at(s)),t.set(s,u.at(s)),l.set(s,0)}}static checkDims(t,i,e){s(t.rows()===i&&t.cols()===e)}}class ii extends si{constructor(t){if(t.copy){const s=new Float64Array(t.copy.N*t.copy.M);return super(s,t.copy.N,t.copy.M),this.buffer=s,void this.assignCopy(t.copy)}const s=new Float64Array(t.NN*t.MM);super(s,t.NN,t.MM),this.buffer=s,t.initializerList&&pt(this.buffer,t.initializerList,0,0,t.initializerList.length)}assignCopy(t){return this===t||super.assignCopy(t),this}}class ei{constructor(t){this.m_TransformationType=1,void 0===t?this.setIdentity():t instanceof ei?this.set(t):this.setScale(t)}set(t){return this.xx=t.xx,this.xy=t.xy,this.xd=t.xd,this.yx=t.yx,this.yy=t.yy,this.yd=t.yd,this}clone(){return(new ei).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(t){return this===t||this.xx===t.xx&&this.xy===t.xy&&this.xd===t.xd&&this.yx===t.yx&&this.yy===t.yy&&this.yd===t.yd}transformInPlace(t){const s=this.xx*t.x+this.xy*t.y+this.xd,i=this.yx*t.x+this.yy*t.y+this.yd;t.x=s,t.y=i}transform(t){const s=t.clone();return this.transformInPlace(s),s}queryTransform(t,s){const i=this.xx*t.x+this.xy*t.y+this.xd,e=this.yx*t.x+this.yy*t.y+this.yd;s.setCoords(i,e)}transformEnvInPlace(t){if(t.isEmpty())return;const s=zt(Js,4);t.queryCorners(s),this.transformPoints2D(s,4,s),t.setFromPoints(s,4)}queryTransformEnv(t,i){s(0)}transformPoints2D(t,s,i){for(let e=0;e<s;++e)this.queryTransform(t[e],i[e])}transformInterleavedPoints(t,s,i){s*=2;const e=Js.getNAN();for(let n=0;n<s;n+=2)e.x=t[n],e.y=t[n+1],this.transformInPlace(e),i[n]=e.x,i[n+1]=e.y}multiply(t){return ei.st_multiply(this,t,this),this}mulLeft(t){return s(0),this}static st_multiply(t,s,i){const e=t.xx*s.xx+t.yx*s.xy,n=t.xy*s.xx+t.yy*s.xy,r=t.xd*s.xx+t.yd*s.xy+s.xd,h=t.xx*s.yx+t.yx*s.yy,o=t.xy*s.yx+t.yy*s.yy,a=t.xd*s.yx+t.yd*s.yy+s.yd;i.xx=e,i.xy=n,i.xd=r,i.yx=h,i.yy=o,i.yd=a}getCoefficients(t){s(t.length>=6),t[0]=this.xx,t[1]=this.xy,t[2]=this.xd,t[3]=this.yx,t[4]=this.yy,t[5]=this.yd}setCoefficients(t){s(t.length>=6),this.xx=t[0],this.xy=t[1],this.xd=t[2],this.yx=t[3],this.yy=t[4],this.yd=t[5]}copyTo(t){s(0)}initializeFromRect(t,s){t.isEmpty()||s.isEmpty()||!t.width()||!t.height()?this.setZero():(this.xy=this.yx=0,this.xx=s.width()/t.width(),this.yy=s.height()/t.height(),this.xd=s.xmin-t.xmin*this.xx,this.yd=s.ymin-t.ymin*this.yy)}initializeFromRectIsotropic(t,s){if(t.isEmpty()||!t.width()||!t.height()||s.isEmpty())this.setZero();else{this.yx=0,this.xy=0,this.xx=s.width()/t.width(),this.yy=s.height()/t.height(),this.xx>this.yy?this.xx=this.yy:this.yy=this.xx;const i=s.getCenter(),e=t.getCenter();this.xd=i.x-e.x*this.xx,this.yd=i.y-e.y*this.yy}}initializeFromTwoPointsArray(t,s){if(t[0].equals(s[0])&&t[1].equals(s[1]))return void this.setIdentity();if(t[0].equals(t[1])){if(s[0].equals(s[1]))return void this.setShift(s[0].sub(t[0]));e("")}if(!t[0].equals(t[1])&&s[0].equals(s[1]))return this.setZero(),void this.shift(s[0]);this.setShiftCoords(-t[0].x,-t[0].y);const i=Js.distance(t[0],t[1]),n=Js.distance(s[0],s[1]),r=n/i;this.scale(r,r);const h=t[1].sub(t[0]);h.divThis(i);const o=s[1].sub(s[0]);o.divThis(n);const a=h.crossProduct(o),u=h.dotProduct(o);this.rotate(u,a),this.shiftCoords(s[0].x,s[0].y)}initializeFromTwoPoints(t,s,i,e){const n=[t,s],r=[i,e];this.initializeFromTwoPointsArray(n,r)}transformSizeInPlace(t){s(0)}transformSize(t,i){s(0)}transformTol(t){return s(0),0}transformWithoutTranslateArray(t,s,i){for(let e=0;e<s;++e)this.transformWithoutTranslate(t[e],i[e])}transformWithoutTranslateInPlace(t){const s=this.xx*t.x+this.xy*t.y,i=this.yx*t.x+this.yy*t.y;t.setCoords(s,i)}transformWithoutTranslate(t,s){const i=this.xx*t.x+this.xy*t.y,e=this.yx*t.x+this.yy*t.y;s.setCoords(i,e)}setIdentity(){this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=1,this.yd=0}isIdentity(){return!(1!==this.xx||1!==this.yy||this.xy||this.xd||this.yx||this.yd)}isIdentityTol(t){const s=t*t;return!(X(this.xd)+X(this.yd)>s)&&(!(X(this.xy+this.xd)+X(this.yy+this.yd-1)>s)&&!(X(this.xx+this.xd-1)+X(this.yx+this.yd)>s))}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(t){const s=this.xx*this.xx+this.yx*this.yx,i=this.xy*this.xy+this.yy*this.yy,e=(s+i)*t;return Math.abs(s-i)<=e&&Math.abs(this.xx*this.xy+this.yx*this.yy)<=e}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return 1===this.xx&&1===this.yy&&!this.xy&&!this.yx}isTranslateTol(t){const s=new Js;return s.setCoords(0,1),this.transformWithoutTranslateInPlace(s),s.y-=1,!(s.sqrLength()>t*t)&&(s.setCoords(1,0),this.transformWithoutTranslateInPlace(s),s.x-=1,s.sqrLength()<=t*t)}isOrthonormal(t){const s=new ei;return s.xx=this.xx*this.xx+this.xy*this.xy,s.xy=this.xx*this.yx+this.xy*this.yy,s.yx=this.yx*this.xx+this.yy*this.xy,s.yy=this.yx*this.yx+this.yy*this.yy,s.xd=0,s.yd=0,s.isIdentityTol(t)}isDegenerate(t){return Math.abs(this.xx*this.yy-this.yx*this.xy)<=2*t*(Math.abs(this.xx*this.yy)+Math.abs(this.yx*this.xy))}isZero(){return 0===this.xx&&0===this.yy&&0===this.xy&&0===this.yx&&0===this.xd&&0===this.yd}isScaleAndTranslateTol(t){return this.xy*this.xy+this.yx*this.yx<=(this.xx*this.xx+this.yy*this.yy)*t}setTranslate(t,s){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=s,this}setShiftCoords(t,s){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=s,this}setShift(t){return this.xx=1,this.xy=0,this.xd=t.x,this.yx=0,this.yy=1,this.yd=t.y,this}setScaleCoords(t,s){return this.xx=t,this.xy=0,this.xd=0,this.yx=0,this.yy=s,this.yd=0,this}setScale(t){return this.setScaleCoords(t,t),this}setFlipX(t,s){return this.xx=-1,this.xy=0,this.xd=t+s,this.yx=0,this.yy=1,this.yd=0,this}setFlipY(t,s){return this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=-1,this.yd=t+s,this}setShear(t,s){return this.xx=1,this.xy=t,this.xd=0,this.yx=s,this.yy=1,this.yd=0,this}scale(t,s){return this.xx*=t,this.xy*=t,this.xd*=t,this.yx*=s,this.yy*=s,this.yd*=s,this}setRotateAngle(t){return this.setRotate(Math.cos(t),Math.sin(t))}setRotate(t,s){return this.xx=t,this.xy=-s,this.xd=0,this.yx=s,this.yy=t,this.yd=0,this}setRotateAngleAbout(t,s){return this.setRotateAbout(Math.cos(t),Math.sin(t),s)}setRotateAbout(t,s,i){return this.setTranslate(-i.x,-i.y),this.rotate(t,s),this.translate(i.x,i.y)}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return this.xx=0,this.xy=1,this.xd=0,this.yx=-1,this.yy=0,this.yd=0,this}setRotateCcw90(){return this.xx=0,this.xy=-1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}shiftCoords(t,s){return this.xd+=t,this.yd+=s,this}shift(t){return this.xd+=t.x,this.yd+=t.y,this}translate(t,s){return this.xd+=t,this.yd+=s,this}flipX(t,s){return this.xx=-this.xx,this.xy=-this.xy,this.xd=t+s-this.xd,this}flipY(t,s){return this.yx=-this.yx,this.yy=-this.yy,this.yd=t+s-this.yd,this}shear(t,s){const i=new ei;return i.setShear(t,s),this.multiply(i)}rotateAngle(t){const s=new ei;return s.setRotateAngle(t),this.multiply(s)}rotate(t,s){const i=new ei;return i.setRotate(t,s),this.multiply(i)}rotateAbout(t,s,i){return this.translate(-i.x,-i.y),this.rotate(t,s),this.translate(i.x,i.y)}rotateAngleAbout(t,s){return this.rotateAbout(Math.cos(t),Math.sin(t),s)}setInvert(t){return this.set(t),this.invertThis()}invertThis(){let t=this.xx*this.yy-this.xy*this.yx;if(0===t)return this.setZero(),this;t=1/t;const s=(this.xy*this.yd-this.xd*this.yy)*t,i=(this.xd*this.yx-this.xx*this.yd)*t,e=this.yy*t,n=-this.xy*t,r=-this.yx*t,h=this.xx*t;return this.xd=s,this.yd=i,this.xx=e,this.yy=h,this.xy=n,this.yx=r,this}invertPrecise(t){return this.set(t),this.invertPreciseThis()}invertPreciseThis(){const t=Ws.constructDouble(this.xy),s=Ws.constructDouble(this.xx),i=s.mulDouble(this.yy).sub(t.mulDouble(this.yx));if(i.isZero())return this.setZero(),this;const e=i.clone();e.invertThis();const n=Ws.constructDouble(this.xd),r=t.mulDouble(this.yd).sub(n.mulDouble(this.yy)).mul(e).toDouble(),h=n.mulDouble(this.yx).sub(s.mulDouble(this.yd)).mul(e).toDouble(),o=e.mulDouble(this.yy).toDouble(),a=e.mulDouble(-this.xy).toDouble(),u=e.mulDouble(-this.yx).toDouble(),l=e.mulDouble(this.xx).toDouble();return this.xd=r,this.yd=h,this.xx=o,this.yy=l,this.xy=a,this.yx=u,this}extractScaleTransform(t,s){const i=Math.sqrt(this.xx*this.xx+this.xy*this.xy),e=Math.sqrt(this.yx*this.yx+this.yy*this.yy);s.setScaleCoords(1/i,1/e),s.multiply(this),t.setScaleCoords(i,e)}setFromTwoTriangles(t,s){let i=!0;for(let u=0;u<3;++u)i=i&&t[u].equals(s[u]);if(i)return this.setIdentity(),!0;const e=new Js;e.setSub(t[0],t[1]);const n=new Js;n.setSub(t[0],t[2]);const r=new Js;r.setSub(s[0],s[1]);const h=new Js;h.setSub(s[0],s[2]);const o=4*Number.EPSILON*(Math.abs(e.x*n.y)+Math.abs(n.x*e.y));let a=e.x*n.y-e.y*n.x;return Math.abs(a)>o?(a=1/a,this.xx=(r.x*n.y-e.y*h.x)*a,this.xy=(e.x*h.x-r.x*n.x)*a,this.yx=(r.y*n.y-e.y*h.y)*a,this.yy=(e.x*h.y-r.y*n.x)*a,this.xd=s[0].x-(this.xx*t[0].x+this.xy*t[0].y),this.yd=s[0].y-(this.yx*t[0].x+this.yy*t[0].y),!0):(this.setZero(),!1)}initializeFromControlPoints(t,s,i,e,n=null){return 0===s?(this.setIdentity(),void(n&&n.setIdentity())):1===s?(this.setShift(e[0].sub(i[0])),void(n&&n.setShift(i[0].sub(e[0])))):(s<3&&(t=1),void(4===t&&s>2?hi(this,s,i,e,n):oi(t,this,s,i,e,n)))}calculateErrors(t,i,e,n){s(t>0&&null!==i&&null!==e);let r=0;for(let s=0;s<t;++s){const t=this.transform(i[s]),h=Js.sqrDistance(e[s],t);r+=h,n&&(n[s]=Math.sqrt(h))}return Math.sqrt(r/t)}}const ni=[43,11,41,9,61];function ri(t,i){s(!(2!==i.rows()&&3!==i.rows()||2!==i.cols()&&3!==i.rows())),t.xx=i.atRowCol(0,0),t.xy=i.atRowCol(0,1),t.yx=i.atRowCol(1,0),t.yy=i.atRowCol(1,1),3===i.cols()?(t.xd=i.atRowCol(0,2),t.yd=i.atRowCol(1,2)):(t.xd=0,t.yd=0)}function hi(t,s,i,e,r){const h=Js.average(i,s),o=Js.average(e,s),a=new ii({NN:2,MM:2});a.setZero();const u=new ii({NN:2,MM:2});u.setZero();for(let n=0;n<s;++n)a.setRowCol(0,0,a.atRowCol(0,0)+(i[n].x-h.x)*(i[n].x-h.x)),a.setRowCol(0,1,a.atRowCol(0,1)+(i[n].x-h.x)*(i[n].y-h.y)),a.setRowCol(1,1,a.atRowCol(1,1)+(i[n].y-h.y)*(i[n].y-h.y)),u.setRowCol(0,0,u.atRowCol(0,0)+(e[n].x-o.x)*(i[n].x-h.x)),u.setRowCol(0,1,u.atRowCol(0,1)+(e[n].x-o.x)*(i[n].y-h.y)),u.setRowCol(1,0,u.atRowCol(1,0)+(e[n].y-o.y)*(i[n].x-h.x)),u.setRowCol(1,1,u.atRowCol(1,1)+(e[n].y-o.y)*(i[n].y-h.y));a.setRowCol(1,0,a.atRowCol(0,1));const l=new ii({NN:2,MM:2});a.pseudoInverse(l,!0)||n("Failed to compute pseudo inverse"),u.mul(l,u),ri(t,u);const m=h.clone();t.transformInPlace(m),t.xd=o.x-m.x,t.yd=o.y-m.y,r&&(u.pseudoInverse(l,!1)||n("Failed to compute pseudo inverse"),ri(r,l),r.transformInPlace(o),r.xd=h.x-o.x,r.yd=h.y-o.y)}function oi(t,i,e,r,h,o){s(1===t||0===t||2===t||3===t),i.setIdentity();const a=Js.average(r,e),u=Js.average(h,e);if(s(t<ni.length&&t>0),8&ni[t]){const s=new ii({NN:2,MM:2});s.setZero();for(let t=0;t<e;++t)s.setRowCol(0,0,s.atRowCol(0,0)+(h[t].x-u.x)*(r[t].x-a.x)),s.setRowCol(1,0,s.atRowCol(1,0)+(h[t].x-u.x)*(r[t].y-a.y)),s.setRowCol(0,1,s.atRowCol(0,1)+(h[t].y-u.y)*(r[t].x-a.x)),s.setRowCol(1,1,s.atRowCol(1,1)+(h[t].y-u.y)*(r[t].y-a.y));const o=new ii({NN:2,MM:2}),l=new ii({NN:2,MM:1}),m=new ii({NN:2,MM:2});s.svd(o,l,m)||n("Failed to compute svd");const c=new ii({NN:2,MM:2});o.transpose(c);const y=new ii({NN:2,MM:2});if(m.mul(c,y),!(32&ni[t])){y.determinant()<0&&(c.setRowCol(1,0,-c.atRowCol(1,0)),c.setRowCol(1,1,-c.atRowCol(1,1)),m.mul(c,y))}const x=new ei;ri(x,y),i.set(x)}if(2&ni[t]){let t=0,s=0;for(let n=0;n<e;++n){const e=r[n].sub(a);t+=e.sqrLength(),i.transformInPlace(e),s+=e.dotProduct(h[n].sub(u))}if(0===t)0===s?i.setIdentity():i.setZero();else{const e=s/t;i.scale(e,e)}}else s(!(4&ni[t]));const l=a.clone();i.transformInPlace(l),i.xd=u.x-l.x,i.yd=u.y-l.y,o&&(o.set(i),o.invertThis(),o.isZero()&&(o.xd=a.x,o.yd=a.y))}export{wt as $,Pt as A,Y as B,g as C,pt as D,_ as E,It as F,us as G,w as H,Ts as I,Cs as J,r as K,ms as L,Ws as M,Ct as N,As as O,Js as P,ns as Q,rs as R,Ot as S,ei as T,Mt as U,Es as V,Et as W,qs as X,Bt as Y,U as Z,W as _,Lt as a,gt as a0,Zs as a1,L as a2,B as a3,hs as a4,D as a5,A as a6,O as a7,G as a8,Q as a9,ws as aA,Hs as aB,F as aC,Jt as aD,zs as aa,Qt as ab,Ls as ac,Qs as ad,Os as ae,Bs as af,ft as ag,dt as ah,E as ai,I as aj,js as ak,Ys as al,$ as am,ks as an,xt as ao,Wt as ap,Ft as aq,it as ar,H as as,Vs as at,Dt as au,Ps as av,Ms as aw,Zt as ax,k as ay,Ss as az,Tt as b,S as c,Gt as d,X as e,qt as f,os as g,ps as h,Rs as i,as as j,St as k,Fs as l,zt as m,Rt as n,ls as o,Vt as p,Ut as q,yt as r,J as s,kt as t,K as u,At as v,V as w,j as x,q as y,Z as z};
5
+ import{a as t,g as s,w as i,t as e,x as n}from"./Geometry.js";class r{constructor(t){this.sum=t,this.compensation=0}assign(t){return this.compensation=t.compensation,this.sum=t.sum,this}reset(){this.sum=this.compensation=0}resetToStart(t){this.sum=t,this.compensation=0}normalize(){const t=[Number.NaN];this.sum=ct(this.sum,this.compensation,t),this.compensation=t[0]}add(t){const s=this.sum+t;let i;if(Math.abs(this.sum)>=Math.abs(t)){const e=this.sum-s+t;i=this.compensation+e}else{const e=t-s+this.sum;i=this.compensation+e}this.sum=s,this.compensation=i}sub(t){this.add(-t)}addProduct(t,s){const i=[0],e=ot(t,s,i);this.add(e),this.add(i[0])}mul(t){const s=new r(0);s.addProduct(this.sum,t),s.addProduct(this.compensation,t),this.assign(s)}getResult(){return this.sum+this.compensation}pe(t){return this.add(t),this}me(t){return this.add(-t),this}}const h=0x00000000ffffffffn,o=0x0000ffffn,a=0x000000ffn,u=0x0fn,l=0xffff0000n,m=0xff00n,c=0xf0n,y=[5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1],x=[-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3];function f(t){let s=0;return t&o||(s+=16,t>>=16n),t&a||(s+=8,t>>=8n),t&u||(s+=4,t>>=4n),s+y[Number(BigInt.asUintN(4,t))]}function d(t){let s=0;return t&l&&(s+=16,t>>=16n),t&m&&(s+=8,t>>=8n),t&c&&(s+=4,t>>=4n),s+x[Number(BigInt.asUintN(4,t))]+1}function b(t){let s=0;return t&h||(s=32,t>>=32n),s+f(BigInt.asUintN(32,t))}function v(t){let s=0;return 0xffffffff00000000n&t&&(s=32,t>>=32n),s+d(t)}class _{constructor(t,s){if(this.m_EnvelopeType=1,void 0!==t){if(t instanceof _)return this.vmin=t.vmin,void(this.vmax=t.vmax);this.vmin=t,this.vmax=s,this.normalize()}else this.setEmpty()}static construct(t,s){return new _(t,s)}static constructEmpty(){return new _}setCoords(t,s){this.vmin=t,this.vmax=s,this.normalize()}setCoordsFromEnvelope(t){this.vmin=t.vmin,this.vmax=t.vmax}setEmpty(){this.vmin=Number.NaN,this.vmax=Number.NaN}getCenter(){return.5*(this.vmin+this.vmax)}equalsRange(t,s){return ns(this.vmin,t)&&ns(this.vmax,s)}equals(t,s){return!(!this.isEmpty()||!t.isEmpty())||(void 0!==s?Math.abs(this.vmin-t.vmin)<=s&&Math.abs(this.vmax-t.vmax)<=s:this.vmin===t.vmin&&this.vmax===t.vmax)}width(){return this.vmax-this.vmin}isEmpty(){return Number.isNaN(this.vmin)||Number.isNaN(this.vmax)}isZero(){return this.vmin===this.vmax}setInfinite(){this.vmin=Number.NEGATIVE_INFINITY,this.vmax=Number.POSITIVE_INFINITY}move(t){this.isEmpty()||(this.vmin+=t,this.vmax+=t)}contains(t){return t.vmin>=this.vmin&&t.vmax<=this.vmax}containsCoordinate(t){return t>=this.vmin&&t<=this.vmax}containsRightExclusive(t){return t>=this.vmin&&t<this.vmax}containsExclusiveCoordinate(t){return t>this.vmin&&t<this.vmax}containsExclusive(t){return t.vmin>this.vmin&&t.vmax<this.vmax}isIntersecting(t){return this.vmin<=t.vmin?this.vmax>=t.vmin:t.vmax>=this.vmin}mergeCoordinate(t){if(this.isEmpty())return this.vmin=t,void(this.vmax=t);this.mergeNeCoordinate(t)}merge(t){if(t.isEmpty())return;const s=t.vmin,i=t.vmax;this.mergeCoordinate(s),this.mergeCoordinate(i)}mergeNe(t){const s=t.vmin,i=t.vmax;this.mergeNeCoordinate(s),this.mergeNeCoordinate(i)}mergeNeCoordinate(t){t<this.vmin?this.vmin=t:t>this.vmax&&(this.vmax=t)}intersect(t){this.isEmpty()||t.isEmpty()?this.setEmpty():(this.vmin<t.vmin&&(this.vmin=t.vmin),this.vmax>t.vmax&&(this.vmax=t.vmax),this.vmin>this.vmax&&this.setEmpty())}inflate(t){this.isEmpty()||(this.vmin-=t,this.vmax+=t,this.vmax<this.vmin&&this.setEmpty())}normalize(){this.vmin<=this.vmax||(this.vmin>this.vmax?this.vmax=Tt(this.vmin,this.vmin=this.vmax):this.setEmpty())}isValid(){return this.isEmpty()||this.vmin<=this.vmax}snapClip(t){return Fs(t,this.vmin,this.vmax)}calculateToleranceFromEnvelope(){if(this.isEmpty())return As();return(Math.abs(this.vmin)+Math.abs(this.vmax)+1)*As()}static unit(){return N}normalizeNoNAN(){this.vmin>this.vmax&&(this.vmax=Tt(this.vmin,this.vmin=this.vmax))}setCoordsNoNAN(t,s){this.vmin=t,this.vmax=s,this.normalizeNoNAN()}clone(){return new _(this.vmin,this.vmax)}}const N=new _(0,1);class w{static getNAN(){return new w(Number.NaN)}constructor(t,s){this.m_value=t??0,this.m_eps=s??0}[Symbol.toPrimitive](t){return this}clone(){return new w(this.m_value,this.m_eps)}assign(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}scaleError(t){this.m_eps*=t}setError(t){this.m_eps=t}set(t,s){return this.m_value=t,this.m_eps=s??0,this}setWithEps(t,s){return void 0===s&&(s=1),this.m_value=t,this.m_eps=w.ulp(t)*s,this}setE(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}precise(){return new w(this.m_value)}value(){return this.m_value}toDouble(){return this.m_value}eps(){return this.m_eps}resetError(){return this.m_eps=0,this}absThis(){return this.m_value=Math.abs(this.m_value),this}add(t){return this.clone().addThis(t)}addE(t){return this.clone().addThisE(t)}addThisE(t){const s=this.m_value+t.m_value,i=this.m_eps+t.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}addThis(t){const s=this.m_value+t,i=this.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}subE(t){return this.clone().subThisE(t)}sub(t){return this.clone().subThis(t)}subThisE(t){const s=this.m_value-t.m_value,i=this.m_eps+t.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}subThis(t){const s=this.m_value-t,i=this.m_eps+w.ulp(s);return this.m_value=s,this.m_eps=i,this}setAddE(t,s){return this.m_value=t.m_value+s.m_value,this.m_eps=t.m_eps+s.m_eps+w.ulp(this.m_value),this}setAdd(t,s){return this.m_value=t+s,this.m_eps=w.ulp(this.m_value),this}setAddEN(t,s){return this.m_value=t.m_value+s,this.m_eps=t.m_eps+w.ulp(this.m_value),this}setAddNE(t,s){return this.m_value=t+s.m_value,this.m_eps=s.m_eps+w.ulp(this.m_value),this}setSubE(t,s){return this.m_value=t.m_value-s.m_value,this.m_eps=t.m_eps+s.m_eps+w.ulp(this.m_value),this}setSub(t,s){return this.m_value=t-s,this.m_eps=w.ulp(this.m_value),this}setSubEN(t,s){return this.m_value=t.m_value-s,this.m_eps=t.m_eps+w.ulp(this.m_value),this}setSubNE(t,s){return this.m_value=t-s.m_value,this.m_eps=s.m_eps+w.ulp(this.m_value),this}mulThisE(t){const s=this.m_value*t.m_value;return this.m_eps=this.m_eps*Math.abs(t.m_value)+t.m_eps*Math.abs(this.m_value)+this.m_eps*t.m_eps+w.ulp(s),this.m_value=s,this}mulThis(t){const s=this.m_value*t;return this.m_eps=this.m_eps*Math.abs(t)+w.ulp(s),this.m_value=s,this}mul(t){return this.clone().mulThis(t)}mulE(t){return this.clone().mulThisE(t)}setMulE(t,s){const i=t.m_value*s.m_value;return this.m_eps=t.m_eps*Math.abs(s.m_value)+s.m_eps*Math.abs(t.m_value)+t.m_eps*s.m_eps+w.ulp(i),this.m_value=i,this}setMul(t,s){return this.m_value=t*s,this.m_eps=w.ulp(this.m_value),this}setMulEN(t,s){return this.setE(t),this.mulThis(s)}setMulNE(t,s){return this.setE(s),this.mulThis(t)}mulThisByPower2(t){return this.m_value*=t,this.m_eps*=Math.abs(t),this}static st_mulByPower2(t,s){return new w(t.m_value,t.m_eps).mulThisByPower2(s)}divE(t){return this.clone().divThisE(t)}divThisE(t){const s=Math.abs(t.m_value),i=this.m_value/t.m_value;let e=(this.m_eps+Math.abs(i)*t.m_eps)/s;if(t.m_eps>.01*s){const i=t.m_eps/s;e*=1+(1+i)*i}return this.m_value=i,this.m_eps=e+w.ulp(i),this}divThis(t){const s=Math.abs(t);return this.m_value/=t,this.m_eps=this.m_eps/s+w.ulp(this.m_value),this}setDivE(t,s){return this.setE(t),this.divThisE(s)}setDiv(t,s){return this.m_value=t/s,this.m_eps=w.ulp(this.m_value),this}setDivEN(t,s){return this.setE(t),this.divThis(s)}setDivNE(t,s){return this.set(t),this.divThisE(s)}divThisByPower2(t){return this.m_value/=t,this.m_eps/=Math.abs(t),this}invThis(){return this.setE(E.clone().divThisE(this)),this}sqrt(){return this.clone().sqrtThis()}sqrtThis(){let t,s;return this.m_value>=0?(t=Math.sqrt(this.m_value),s=this.m_value>10*this.m_eps?.5*this.m_eps/t:this.m_value>this.m_eps?t-Math.sqrt(this.m_value-this.m_eps):Math.max(t,Math.sqrt(this.m_value+this.m_eps)-t),s+=w.ulp(t)):this.m_value<-this.m_eps?(t=Number.NaN,s=Number.NaN):(t=0,s=Math.sqrt(this.m_eps)),this.m_value=t,this.m_eps=s,this}sqr(){return this.clone().sqrThis()}sqrThis(){const t=this.m_value*this.m_value;return this.m_eps=2*this.m_eps*Math.abs(this.m_value)+this.m_eps*this.m_eps+w.ulp(t),this.m_value=t,this}setSin(t){const s=Math.sin(t.m_value),i=Math.cos(t.m_value);this.m_value=s;const e=Math.abs(s),n=Math.abs(t.value());return this.m_eps=(Math.abs(i)+.5*e*t.m_eps)*t.m_eps+w.ulp(e+n),this}static ulp(t){let s=Kt(t);const i=((0x7ff0000000000000n&s)>>52n)-1075n;return i>-1023n?(s=i+0x3ffn<<52n,ts(s)):0===t?0:Number.MIN_VALUE}setCos(t){const s=Math.sin(t.m_value),i=Math.cos(t.m_value);this.m_value=i;const e=Math.abs(i),n=Math.abs(t.value());return this.m_eps=(Math.abs(s)+.5*e*t.m_eps)*t.m_eps+w.ulp(e+n),this}static st_cosAndSin(t,s,i){const e=Math.sin(t.m_value),n=Math.cos(t.m_value);i.m_value=e,s.m_value=n;const r=Math.abs(e),h=Math.abs(n),o=Math.abs(t.value());i.m_eps=(Math.abs(n)+.5*r*t.m_eps)*t.m_eps+w.ulp(r+o),s.m_eps=(Math.abs(e)+.5*h*t.m_eps)*t.m_eps+w.ulp(h+o)}negate(){return this.clone().negateThis()}negateThis(){return this.m_value=-this.m_value,this}setAbs(){return this.m_value=Math.abs(this.m_value),this}isInInterval(t){return _.construct(this.m_value-this.m_eps,this.m_value+this.m_eps).isIntersecting(t)}eq(t){return Math.abs(this.m_value-t.m_value)<=this.m_eps+t.m_eps}ne(t){return!this.eq(t)}gt(t){return this.m_value-t.m_value>this.m_eps+t.m_eps}lt(t){return t.m_value-this.m_value>this.m_eps+t.m_eps}ge(t){return!this.lt(t)}le(t){return!this.gt(t)}tolEQ(t,s){return Math.abs(this.m_value-t.m_value)<=s||this.eq(t)}tolNE(t,s){return!this.tolEQ(t,s)}tolGT(t,s){return this.m_value-t.m_value>s&&this.gt(t)}tolLT(t,s){return t.m_value-this.m_value>s&&this.lt(t)}tolGE(t,s){return!this.tolLT(t,s)}tolLE(t,s){return!this.tolGT(t,s)}isZero(){return Math.abs(this.m_value)<=this.m_eps}isFuzzyZero(){return this.isZero()&&0!==this.m_eps}tolIsZero(t){return Math.abs(this.m_value)<=Math.max(this.m_eps,t)}setPi(){this.setE(R)}setEuler(){this.set(2.718281828459045,T())}static size(){return 1}}function M(t,s){const i=ss(t),e=ss(s),n=53-b(i),r=53-b(e);return(n>=0?n:0)+(r>=0?r:0)<=52}function p(t,s){const i=t+s;return i-t===s&&i-s===t}function C(t,s){const i=t-s;return t-i===s&&s+i===t}function T(){return zs()}w.dimensions=1;const R=new w(Math.PI,.5*T()),g=new w(0,0),E=new w(1,0),I=new w(4,0);function D(t,s,i){return t.addE(s.subE(t).mulE(i))}function A(t,s,i){return s.subE(s.subE(t).mulE(E.subE(i)))}function P(t){return Math.atanh(t)}function q(t){let s;if(0===t)s=1;else if(Math.abs(t)>.01)s=P(t)/t;else{let i;const e=-36.841361487904734;s=0;const n=t*t;for(let t=2*Math.trunc(e/Math.log(n)+2.5)-1;t>1;t-=2)i=1/t,s=(s+i)*n;s+=1}return s}function z(t){const s=Math.PI*Math.PI/6;let i;if(1===t)i=s;else if(t>1)i=s;else if(0===t)i=t;else if(t<0){const s=1+(t=Math.abs(t)),e=Math.log(s);i=e*e/-2-z(t/s)}else if(t>.5){const e=1-t,n=Math.log(t)*Math.log(e);i=s-z(e)-n}else{i=0;const s=1+Math.trunc(-16*Math.log(10)/Math.log(t)+1.5);let e=s;for(let n=s;n>0;n--,e-=1)i*=t,i+=1/(e*e);i*=t}return i}function Z(t,s){const i=s*t;if(Math.abs(s)<.1){let s=0;for(let t=60;t>=1;t--)s*=i,s+=1/t/t;return s*=t,s}return z(i)/s}function F(t,s){return t<s?Gt(t,s):Gt(s,t)}function S(t,s){const i=Math.abs(t);return s>=0?i:-i}function k(t){return Math.round(t)}function L(t,s,i,e,n){n[0]=s[0]+(i[0]-s[0])*e,n[1]=s[1]+(i[1]-s[1])*e,3===t&&(n[2]=s[2]+(i[2]-s[2])*e)}function B(t,s,i,e,n){n[0]=i[0]-(i[0]-s[0])*(1-e),n[1]=i[1]-(i[1]-s[1])*(1-e),3===t&&(n[2]=i[2]-(i[2]-s[2])*(1-e))}function O(t,s,i,e,n){e<=.5?L(t,s,i,e,n):B(t,s,i,e,n)}function G(t,s,i,e,n){n[0]=s[0].addE(i[0].subE(s[0]).mulE(e)),n[1]=s[1].addE(i[1].subE(s[1]).mulE(e))}function Q(t,s,i,e,n){n[0]=i[0].subE(i[0].subE(s[0]).mulE(E.subE(e))),n[1]=i[1].subE(i[1].subE(s[1]).mulE(E.subE(e)))}function V(t,s,i){let e;return e=i<=.5?t+(s-t)*i:s-(s-t)*(1-i),e}function U(t,s,i){return t+(s-t)*i}function W(t,s,i){return s-(s-t)*(1-i)}function Y(t,s,i,e){i<=.5?(e.x=t.x+(s.x-t.x)*i,e.y=t.y+(s.y-t.y)*i):(e.x=s.x-(s.x-t.x)*(1-i),e.y=s.y-(s.y-t.y)*(1-i))}function j(t,s,i,e){i<=.5?(e.x=t.x+(s.x-t.x)*i,e.y=t.y+(s.y-t.y)*i,e.z=t.z+(s.z-t.z)*i):(e.x=s.x-(s.x-t.x)*(1-i),e.y=s.y-(s.y-t.y)*(1-i),e.z=s.z-(s.z-t.z)*(1-i))}function X(t){return t*t}function $(t){return t*t*t}function H(t){return 1/Math.sqrt(t)}function J(t){return t<0?-1:t>0?1:0}function K(t,s,i,e){const n=[0],r=[0],h=[0];return ct(ot(t,i,n),ot(s,e,r),h)+(n[0]+r[0]+h[0])}const tt=[0],st=[0];function it(t,s,i){return mt(ot(t,s,tt),i,tt[0],st)}const et=[0],nt=[0],rt=[0],ht=[0];function ot(t,s,i){const e=t*s;return at(t,et,nt),at(s,rt,ht),i[0]=nt[0]*ht[0]-(e-et[0]*rt[0]-nt[0]*rt[0]-et[0]*ht[0]),e}function at(t,s,i){const e=134217729*t;s[0]=e-(e-t),i[0]=t-s[0]}const ut=[0],lt=[0];function mt(t,s,i,e){const n=ct(t,s,ut),r=ct(n,i,lt);return ct(r,ut[0]+lt[0],e)}function ct(t,s,i){const e=t+s;return Math.abs(t)>Math.abs(s)?i[0]=t-e+s:i[0]=s-e+t,e}function yt(t,s){return t%s}function xt(t){const s=1-t;if(0===s)return 1;let i;if(s<=.01){const t=s,e=Math.log(t);i=1+t*(.4431471805599453-.25*e+t*(.05680519270997949-.09375*e+t*(.02183137044373718-.05859375*e+t*(.011544521417308362-.042724609375*e+t*(.00714200031339596-.0336456298828125*e+t*(.004854743337164948-.027757644653320312*e+t*(.003514687963781376-.023627042770385742*e)))))))}else{if(t<.016){const s=t,i=.25,e=.046875,n=.01953125,r=.01068115234375,h=.0067291259765625,o=.004626274108886719,a=.0033752918243408203,u=.0025710230693221092;return Os()*(1-s*(i+s*(e+s*(n+s*(r+s*(h+s*(o+s*(a+s*u))))))))}i=bt(0,s,1)-t*vt(0,s,1)/3}return Fs(i,1,Os())}function ft(t,i,e=Number.NaN){if(s(i>=0&&i<=1),0===i)return t;let n=1,r=t;if(r<0&&(r=-r,n=-1),1===i){const t=Math.round(r/Ls()),s=r-t*Ls();return n*(2*t+Math.sin(s))}const h=Os(),o=Math.floor(r/h);1&o?r=(o+1)*h-r:r-=o*h;const a=Math.sin(r),u=Number.isNaN(e)?xt(i):e;let l;if(1===a)l=u+Math.sqrt(1-i)*(r-h);else{const t=r*r;if(.01424*Math.pow(t,4)<=2*zs()){l=r*(1+t*i*(-1/6+t*((4-3*i)/120-(16+(45*i-60)*i)/5040*t)))}else if(i<=.01){const t=Math.sin(2*r),s=Math.sin(4*r),e=Math.sin(6*r),n=Math.sin(8*r),h=Math.sin(10*r);l=r+i*((2*-r+t)/8+i*((-3*r+2*t-.25*s)/64+i*((-20*r+15*t-3*s+e/3)/1024+i*(5*(-140*r+112*t-28*s+16/3*e-.5*n)/65536+7*i*((-63*r+52.5*t-15*s+3.75*e-.625*n+.05*h)/65536+i*(-693*r+594*t-185.625*s+1.375*e-12.375*n+1.8*h-.125*Math.sin(12*r))/1048576)))))}else{const t=a*a,s=Math.cos(r),e=s*s,n=_t(a,s,i);l=a*(bt(e,n,1)-i*t*vt(e,n,1)/3)}}if(1&o){l=u*(o+1)-l}else l+=u*o;return n*l}function dt(t,s,i=Number.NaN){if(0===t)return 0;let e=1,n=t;t<0&&(n=-n,e=-1);const r=Number.isNaN(i)?xt(s):i,h=Math.floor(n/r);1&h?n=(h+1)*r-n:n-=h*r;let o=n<=0?0:n>=r?Os():Nt(n,s,r);return 1&h?o=Os()*(h+1)-o:o+=Os()*h,e*o}function bt(t,i,e){s((0!==t?1:0)+(0!==i?1:0)+1>1);let n=t,r=i,h=e;for(;;){const t=Math.sqrt(n*r)+Math.sqrt(r*h)+Math.sqrt(h*n);n=.25*(n+t),r=.25*(r+t),h=.25*(h+t);const s=(n+r+h)/3,i=(s-n)/s,e=(s-r)/s,o=(s-h)/s;if(Math.abs(i)<=.0024&&Math.abs(e)<=.0024&&Math.abs(o)<=.0024){const t=i*e-o*o,n=i*e*o;return(1+(1/24*t-.1-3/44*n-5*t*t/208+t*n/16)*t+(1/14+3*n/104)*n)/Math.sqrt(s)}}}function vt(t,i,e){s(0!==t||0!==i);let n=t,h=i,o=e;const a=new r(0);let u=1;for(;;){const t=.2*(n+h+3*o),s=(t-n)/t,i=(t-h)/t,e=(t-o)/t;if(Math.abs(s)<=.0015&&Math.abs(i)<=.0015&&Math.abs(e)<=.0015){const n=s*i,r=e*e,h=n-r,o=n-6*r,l=o+h+h,m=3/26,c=o*(.25*(9/22)*o-.21428571428571427-1.5*m*e*l),y=e*(1/6*l+e*(-.4090909090909091*h+e*m*n));return 3*a.getResult()+u*(1+c+y)/(t*Math.sqrt(t))}const r=Math.sqrt(n),l=Math.sqrt(h),m=Math.sqrt(o),c=r*(l+m)+l*m;a.add(u/(m*(o+c))),u*=.25,n=.25*(n+c),h=.25*(h+c),o=.25*(o+c)}}function _t(t,s,i){return t<.999?1-i*X(t):1-i+i*X(s)}function Nt(t,s,i){if(0===s)return t;if(1===s)return Math.asin(t);let e=0,n=!0;if(t<.2){const i=t*t,r=t*(1+i*s*(1/6+i*((13*s-4)/120+(16-284*s+493*s*s)/5040*i))),h=Math.abs(s*(4944*s-64-31224*s*s+37369*s*s*s)/362880*Math.pow(t,9));if(h<Math.abs(r)*zs())return r;e=r,n=h>.1*r}if(n){const n=1-s,r=1-t/i,h=Math.sqrt(r*r+n*n),o=Math.atan2(n,t+zs());e=Os()+Math.sqrt(h)*(o-Os())}let r=0;for(let h=0;h<7;h++){r=ft(e,s,i);const n=_t(Math.sin(e),Math.cos(e),s);if(e-=(r-t)/Math.sqrt(n),h>0&&Math.abs(r-t)<=4*zs()*t)break}return e}function wt(s,i,e,n,r){return 0===s?0===n?i:1===n?e:r:1===s?0===n?i:1===n?e:V(i,e,n):(2===s&&t("angular interpolation"),void t(""))}function Mt(s,i,e,n,r,h,o,a){if(0===s)for(let t=0;t<h;++t)n[t+r]=0===o?i[t]:1===o?e[t]:a;else if(1===s)if(0===o)pt(n,i,r,0,h);else if(1===o)pt(n,e,r,0,h);else for(let t=0;t<h;++t)n[t+r]=V(i[t],e[t],o);else if(2===s)if(0===o)pt(n,i,r,0,h);else if(1===o)pt(n,e,r,0,h);else{let t=0;for(let s=0,a=r;s<h;++s,++a)n[a]=V(i[s],e[s],o),t+=n[a]*n[a];if(t>0){t=Math.sqrt(t);for(let s=r;s<r+h;++s)n[s]/=t}else{for(let t=r;t<r+h;++t)n[t]=0;n[r]=1}}else t("")}function pt(t,s,i,e,n){if(0===n)return;let r=0,h=i,o=e;for(;r++<n;)t[h++]=s[o++]}function Ct(t,s,i){let e=0;for(let n=0;!e&&n<i;++n)e=t[n]-s[n];return e}function Tt(t,s){return t}function Rt(t){t.sort(((t,s)=>t<s?-1:t>s?1:0))}function gt(t,s){const i=t.slice(0,s);Rt(i),pt(t,i,0,0,s)}function Et(t,s,i,e){const n=t.slice(s,s+i);n.sort(e),pt(t,n,s,0,i)}function It(t,s){return t<s?-1:t>s?1:0}function Dt(t,s,i,e){return t<i?-1:t>i?1:s<e?-1:s>e?1:0}function At(t,s){if(t.length<2)return t.length;let i=0;for(let e=1;e<t.length;++e)s(t[e],t[i])||(i++,t[e]=Tt(t[i],t[i]=t[e]));return 1+i}function Pt(t,s){t[s]=t.at(-1),t.pop()}function qt(t,s=!1){return{[Symbol.dispose](){this.bForget||t()},bForget:s}}function zt(t,s){return Array.from({length:s},(()=>new t))}function Zt(t,s,i){for(let e=0;e<i;++e)t[e].assign(s[e]);return i}function Ft(t,s){const i=t.slice(0,s);for(let e=0;e<s;++e)i[e]=i[e].clone();return i}function St(t){return Array.from({length:t},(()=>null))}function kt(t,s){return Array.from({length:s},(()=>t()))}function Lt(t,s){return Array.from({length:t},(()=>s))}function Bt(t,s){return s in t&&1===Object.getOwnPropertyNames(t).length}class Ot{constructor(...t){this.m_elts=t}get length(){return this.m_elts.length}at(t){return this.m_elts[t]}[Symbol.dispose](){for(const t of this.m_elts)t[Symbol.dispose]()}}function Gt(t,s){return{first:t,second:s}}const Qt=Math.PI,Vt=2*Math.PI,Ut=.5*Math.PI;class Wt{constructor(t,s){this.m_cr=t,this.m_cc=s,this.m_v=Lt(t*s,0)}get(t,s){return this.m_v[t*this.m_cc+s]}set(t,s,i){this.m_v[t*this.m_cc+s]=i}inc(t,s){return++this.m_v[t*this.m_cc+s]}}const Yt=new ArrayBuffer(8),jt=new Float64Array(Yt),Xt=new BigUint64Array(Yt),$t=0x0fffffffffffffn,Ht=0x7ff0000000000000n;function Jt(){return Number.EPSILON*Ds}function Kt(t){return jt[0]=t,Xt[0]}function ts(t){return Xt[0]=t,jt[0]}function ss(t){return Kt(t)&$t}function is(t){return Number((Kt(t)&Ht)>>52n)}function es(t){if(0n===t)return-1n;if(1n===t||-1n===t)return 0n;t<0n&&(t=-t);let s=0n,i=512n,e=1n<<s+i;for(;t>=e;)s+=i,i<<=1n,e<<=i;let n=s;i>>=1n;let r=n+i;for(;i>0n;)t<1n<<r||(n=r),i>>=1n,r=n+i;return n}function ns(t,s){return t===s||Number.isNaN(t)&&Number.isNaN(s)}function rs(t,s,i){return t===s||Math.abs(t-s)<=i||Number.isNaN(t)&&Number.isNaN(s)}function hs(t,s){return t<s?-1:t>s?1:0}function os(t,s){if(t<s)return-1;if(t>s)return 1;if(t===s)return 0;{const i=Number.isNaN(t),e=Number.isNaN(s);return i<e?-1:i>e?1:0}}function as(){return 2147483647}function us(){return 32767}function ls(){return 2147483647}function ms(){return-2147483648}const cs=ls(),ys=BigInt(cs),xs=2166136261,fs=16777619;function ds(t){let s=xs,i=t;return s=(s^255&i)*fs,i>>=8,s=(s^255&i)*fs,i>>=8,s=(s^255&i)*fs,i>>=8,s=(s^255&i)*fs,s&cs}const bs=14695981039346656037n,vs=1099511628211n;function _s(t){let s=bs,i=t;return s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,i>>=8n,s=(s^0xffn&i)*vs,s&ys}function Ns(t){return 1103515245*t+12345&2147483647}function ws(t){let s=xs;for(let i=0,e=t.length;i<e;++i)s=(s^t.charCodeAt(i))*fs;return s&cs}function Ms(t,s){return s+2654435769+(t<<6)+(t>>2)&cs}function ps(t,s){return Ms(t,gs(s))}function Cs(t){return Ms(3735928559,t)}function Ts(t,s){return Ms(t,Cs(s))}function Rs(t){return ds(t)}function gs(t){return Number(_s(t))}function Es(t){return Ns(t)}const Is=100,Ds=100;function As(){return Number.EPSILON*Is}function Ps(){return.38196601125010515}function qs(){return 1.4142135623730951}function zs(){return Number.EPSILON}function Zs(t,s,i){return t===s||t===i}function Fs(t,s,i){return t>=s?t<=i?t:i:s}function Ss(t,s,i){const e=t[0];if(e>=s){if(e<=i)return!1;t[0]=i}else t[0]=s;return!0}function ks(t,s){return t>=s?s:t<-s?-s:t}function Ls(){return Qt}function Bs(){return Vt}function Os(){return Ut}const Gs=3*Os();function Qs(){return Gs}function Vs(t){return t+0}function Us(t){return{v:t}}class Ws{constructor(){this.m_rn=Us(0n),this.m_rd=Us(1n),this.m_bNaN=!1,this.m_bNormalized=!1,this.m_power=0,this.m_sign=0}static constructAssign(t,s){const i=t.clone();return void 0!==s&&i.limitPrecisionThis(s),i}static constructDouble(t){return(new Ws).setDouble(t)}static constructInt64(t){return(new Ws).setInt64(t)}static constructRational(t,s){return(new Ws).setRational(t,s)}static constructInt32(t){return this.constructInt64(BigInt(Math.trunc(t)))}[Symbol.toPrimitive](t){return this}compare(t){return this.lt(t)?-1:this.gt(t)?1:0}assignCopy(t){return this.setThis(t)}abs(){return this.clone().absThis()}absThis(){return this.isNAN()||(this.m_sign*=this.m_sign),this}clone(){return(new Ws).setThis(this)}setThis(t){return this.m_bNaN=t.m_bNaN,this.m_bNormalized=t.m_bNormalized,this.m_rn.v=t.m_rn.v,this.m_rd.v=t.m_rd.v,this.m_power=t.m_power,this.m_sign=t.m_sign,this}setZero(){return this.m_rn.v=0n,this.m_rd.v=1n,this.m_bNaN=!1,this.m_power=0,this.m_bNormalized=!0,this.m_sign=0,this}setDouble(s){if(this.setZero(),0===s)return this;if(Number.isInteger(s)&&Math.abs(s)<ls())return this.setInt32(s);const i=Kt(s),e=(i&Ws.s_em)>>52n,n=!!(i&Ws.s_sm),r=i&Ws.s_fm;if(e===Ws.s_emax)return r?(this.m_rn.v=this.m_rd.v=0n,this.m_bNaN=!0,this):(this.m_rn.v=n?-1n:1n,this.m_rd.v=0n,this);0n===e&&t("denormalized numbers not yet implemented");const h=e-1023n,o=h>=0n?h:0n,a=h<0n?-h:0n;return this.m_rn.v=(1n<<52n|r)<<o,this.m_rd.v=1n<<52n+a,this.m_sign=n?-1:1,this.m_bNormalized=!1,this.normalizeThis()}setInt64(t){return 0n===t?this.setZero():(this.m_bNaN=!1,this.m_sign=t>0n?1:-1,this.m_rn.v=t>0n?t:-t,this.m_rd.v=1n,this.m_power=0,this.m_bNormalized=!1,this.normalizeThis())}setRational(t,s){return 0n===t?0n===s?this.setNAN():this.setZero():0n===s?t>0n?this.setPositiveInf():this.setNegativeInf():(this.m_sign=(t>0n?1:-1)*(s>0n?1:-1),this.m_rn.v=t>0n?t:-t,this.m_rd.v=s>0n?s:-s,this.m_power=0,this.m_bNormalized=!1,this.normalizeThis())}setInt32(t){return this.setInt64(BigInt(Math.trunc(t)))}getDouble(){return this.convertToDouble()}toDouble(){return this.convertToDouble()}value(){return this.convertToDouble()}isNAN(){return this.m_bNaN}isPositiveInf(){return!this.isNAN()&&(0n===this.m_rd.v&&1===this.m_sign)}isNegativeInf(){return!this.isNAN()&&(0n===this.m_rd.v&&-1===this.m_sign)}isFinite(){return!this.isNAN()&&0n!==this.m_rd.v}setNAN(){return this.m_bNaN=!0,this.m_rn.v=0n,this.m_rd.v=0n,this.m_power=0,this.m_bNormalized=!0,this}setPositiveInf(){return this.m_rn.v=1n,this.m_rd.v=0n,this.m_bNaN=!1,this.m_bNormalized=!0,this.m_sign=1,this.m_power=0,this}setNegativeInf(){return this.m_rn.v=1n,this.m_rd.v=0n,this.m_bNaN=!1,this.m_bNormalized=!0,this.m_sign=-1,this.m_power=0,this}subThis(t){if(t.isNAN()&&this.setNAN(),this.isPositiveInf()&&t.isPositiveInf())this.setNAN();else{if(this.isPositiveInf()&&t.isNegativeInf())return this.setPositiveInf(),this;if(this.isNegativeInf()&&t.isNegativeInf())this.setNAN();else if(this.isNegativeInf()&&t.isPositiveInf())return this.setNegativeInf(),this}return this.isNAN()?this:this.opPlusMinus(t,!1)}thisSubAbs(t){return s(0),this}mulThis(t){return t.isNAN()&&this.setNAN(),this.isNAN()?this:(this.m_sign*=t.m_sign,0===this.m_sign?this.setZero():(this.m_rn.v*=t.m_rn.v,this.m_rd.v*=t.m_rd.v,this.m_power+=t.m_power,this.m_bNormalized=!1,this.normalizeThis(),this))}mulDoubleThis(t){return this.mulThis(Ws.constructDouble(t))}thisMulInt64(t){return s(0),this}thisMulInt32(t){return s(0),this}divThis(t){return this.mulThis(t.clone().invertThis())}divDoubleThis(t){return this.divThis(Ws.constructDouble(t))}addDoubleThis(t){return this.addThis(Ws.constructDouble(t))}subDoubleThis(t){return this.subThis(Ws.constructDouble(t))}mul(t){return this.clone().mulThis(t)}mulBigIntThis(t){return this.mulThis(Ws.constructInt64(t))}mulDouble(t){return this.clone().mulThis(Ws.constructDouble(t))}div(t){return this.clone().divThis(t)}divDouble(t){return this.clone().divDoubleThis(t)}add(t){return this.clone().addThis(t)}fmSubThis(t,s){return this.subThis(t.clone().mulThis(s))}fmAddThis(t,s){return this.addThis(t.clone().mulThis(s))}addThis(t){if(t.isNAN()&&this.setNAN(),this.isPositiveInf()&&t.isPositiveInf())return this.setPositiveInf(),this;if(this.isPositiveInf()&&t.isNegativeInf())this.setNAN();else{if(this.isNegativeInf()&&t.isNegativeInf())return this.setNegativeInf(),this;this.isNegativeInf()&&t.isPositiveInf()&&this.setNAN()}return this.isNAN()?this:this.opPlusMinus(t,!0)}addDouble(t){return this.clone().addThis(Ws.constructDouble(t))}sub(t){return this.clone().subThis(t)}subDouble(t){return this.clone().subThis(Ws.constructDouble(t))}isZero(){return 0===this.m_sign}equals(t){return this.clone().subThis(t).isZero()}lt(t){return!this.isNAN()&&!t.isNAN()&&(!(this.isPositiveInf()&&t.isPositiveInf()||this.isNegativeInf()&&t.isNegativeInf())&&(!this.isPositiveInf()&&(!!t.isPositiveInf()||this.clone().sub(t).LZ())))}absLessAbs(t){return this.abs().lt(t.abs())}gt(t){return this.clone().sub(t).GZ()}lte(t){return this.sub(t).LEZ()}gte(t){return this.sub(t).GEZ()}normalizeThis(){if(this.m_bNormalized)return this;if(0n===this.m_rn.v)return this.setZero();let t=0,s=0xffffffffn;for(;0n===(this.m_rn.v&s)&&s<=this.m_rn.v;)s<<=32n,t+=32;s&=this.m_rn.v,s>>=BigInt(t),t+=f(BigInt.asUintN(32,s))-1;let i=0;for(s=0xffffffffn;0n===(this.m_rd.v&s)&&s<=this.m_rd.v;)s<<=32n,i+=32;return s&=this.m_rd.v,s>>=BigInt(i),i+=f(BigInt.asUintN(32,s))-1,this.m_rn.v>>=BigInt(t),this.m_rd.v>>=BigInt(i),this.m_power+=t-i,this.m_rn.v>1n&&this.m_rd.v>1n&&(this.m_rn.v%this.m_rd.v===0n?(this.m_rn.v/=this.m_rd.v,this.m_rd.v=1n):this.m_rd.v%this.m_rn.v===0n&&(this.m_rd.v/=this.m_rn.v,this.m_rn.v=1n)),this.m_bNormalized=!0,this}negateThis(){return this.isNAN()||(this.m_sign*=-1),this}negate(){return this.clone().negateThis()}invertThis(){return this.isNAN()?this:this.isPositiveInf()||this.isNegativeInf()?(this.setZero(),this):0n===this.m_rn.v?(this.setPositiveInf(),this):(this.m_rd=Tt(this.m_rn,this.m_rn=this.m_rd),this.m_power=-this.m_power,this)}limitPrecisionThis(t){if(0===t)return this;if(this.isZero())return this.setZero();if(!this.isFinite())return this;this.normalizeThis();let s=Number(es(this.m_rn.v));if(s>t){const i=s-t;this.m_rn.v>>=BigInt(s-t),this.m_power+=i}if(s=Number(es(this.m_rd.v)),s>t){const i=s-t;this.m_rd.v>>=BigInt(s-t),this.m_power-=i}return this}hiBitIndex(){return Math.max(Number(es(this.m_rn.v)),Number(es(this.m_rd.v)))}ldexp(t){return this.clone().ldexpThis(t)}ldexpThis(t){return t&&(this.m_bNormalized=!1,this.m_power+=t,this.normalizeThis()),this}LZ(){return!this.isNAN()&&-1===this.m_sign}GZ(){return!this.isNAN()&&1===this.m_sign}LEZ(){return!this.isNAN()&&this.m_sign<=0}GEZ(){return!this.isNAN()&&this.m_sign>=0}toString(){return this.toDouble().toString()}sqr(){return this.clone().sqrThis()}sqrThis(){return this.mulThis(this.clone())}static sqrt(t,e){if(t.m_sign<0n&&i("MP_value: sqrt(-1)"),t.isZero())return t.clone();let n=52,r=2220446049250313e-31;for(;n<e;)2*n<=e?(r*=r,n*=2):(r*=2220446049250313e-31,n+=52);n+=52;const h=es(t.m_rn.v),o=es(t.m_rd.v);let a,u=t.m_power+Number(h-o);const l=new Ws;Math.abs(u)>200?(1&Math.abs(u)&&(u+=1),a=Ws.constructAssign(t,53).ldexpThis(-u).value(),l.setThis(t).ldexpThis(-u),s(Number.isFinite(a))):(l.setThis(t),a=l.value(),s(Number.isFinite(a)),u=0),a=Math.sqrt(a);const m=Ws.constructDouble(a),c=Ws.constructDouble(r);c.mulThis(m).ldexpThis(1);const y=r*a*2,x=m.clone(),f=new Ws;let d;for(let s=0;s<10;++s){x.mulThis(m),f.setThis(l).subThis(x).absThis();let t=f.value();if(d=1,t<.9)for(;t>y;)t*=t,++d;else d=4;if(f.lte(c))break;for(let s=0;s<d;s++)x.setThis(m).divThis(l).invertThis().addThis(m).ldexpThis(-1).limitPrecisionThis(n),m.setThis(x)}return m.ldexpThis(u/2)}static cubicRoot(t,s){if(t.isZero())return t.clone();let i=52,e=2220446049250313e-31;for(;i<s;)2*i<=s?(e*=e,i*=2):(e*=2220446049250313e-31,i+=52);i+=52;const n=Math.pow(Math.abs(t.value()),1/3),r=Ws.constructDouble(n),h=r.clone();h.sqrThis().mulDoubleThis(3).mulDoubleThis(e),h.limitPrecisionThis(32),t.LZ()&&r.negateThis();for(let o=0;o<10;++o){const s=r.clone();s.sqrThis().mulThis(r);const e=s.clone();if(e.subThis(t),e.absThis().limitPrecisionThis(32),e.lte(h))break;e.setThis(t),e.ldexpThis(1),e.addThis(s);const n=s.clone();n.ldexpThis(1),n.addThis(t),e.divThis(n),r.mulThis(e),r.limitPrecisionThis(i)}return r}isInTheRangeOfDouble(){return s(0),!1}sign(){return this.m_sign}cosAndSin(t,i){s(0)}static nan(){return s(0),new Ws}convertToDouble(){if(this.m_bNaN)return Number.NaN;if(this.isZero())return 0;if(0n===this.m_rd.v)return 1===this.m_sign?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY;const t=-1===this.m_sign,s=this.m_rn.v<<(this.m_power>=0?BigInt(this.m_power):0n);let i=this.m_rd.v<<(this.m_power<0?BigInt(-this.m_power):0n);const e=s/i;let n=Number(e);if(BigInt(n)!==e)return t?-n:n;let r=s-e*i;if(r){let t=es(i)-1023n;t>0n&&(i>>=t,r<<=52n,r>>=t);let s=Number(r);Number.isFinite(s)||(r>>=52n,s=Number(r),t=0n),t>0n&&(s/=Math.pow(2,52));n+=s/Number(i)}return t?-n:n}signVal(){return 1===this.m_sign?1n:-1===this.m_sign?-1n:0n}opPlusMinus(t,s){const i=Math.min(this.m_power,t.m_power);let e,n;this.m_power>i?(e=BigInt(this.m_power-i),n=0n):(e=0n,n=BigInt(t.m_power-i));const r=this.signVal()*this.m_rn.v*t.m_rd.v<<e,h=t.signVal()*t.m_rn.v*this.m_rd.v<<n;return this.m_rn.v=s?r+h:r-h,this.m_rd.v*=t.m_rd.v,this.m_power=i,this.m_sign=1,this.m_rn.v<0n&&(this.m_sign=-1,this.m_rn.v=-this.m_rn.v),this.m_bNormalized=!1,this.normalizeThis(),this}}Ws.s_sm=0x8000000000000000n,Ws.s_em=0x7ff0000000000000n,Ws.s_fm=0x000fffffffffffffn,Ws.s_emax=0x7ffn;const Ys=Ws.constructInt32(1),js=Ws.constructInt32(0);function Xs(t,s){return v(t^s)}function $s(t,s){let i=is(t);const e=is(s);if(i===e){return i-=53-Xs(ss(t),ss(s)),i}return i>e?i:e}function Hs(t){const s=zt(Js,t.length);for(let i=0,e=t.length;i<e;++i)s[i].setCoords(t[i][0],t[i][1]);return s}class Js{static construct(t,s){return new Js(t,s)}constructor(t,s){void 0!==t?(this.x=t,this.y=s):this.x=this.y=Number.NaN}clone(){return new Js(this.x,this.y)}assign(t){this.setCoordsPoint2D(t)}setCoords(t,s){return this.x=t,this.y=s,this}setCoordsPoint2D(t){this.x=t.x,this.y=t.y}isEqualPoint2D(t,s){return void 0!==s?Math.abs(this.x-t.x)<=s&&Math.abs(this.y-t.y)<=s:this.x===t.x&&this.y===t.y}isEqual(t,s,i){return void 0!==i?Math.abs(this.x-t)<=i&&Math.abs(this.y-s)<=i:this.x===t&&this.y===s}equalsPoint2D(t,s){return this.isEqualPoint2D(t,s)}setSub(t,s){this.x=t.x-s.x,this.y=t.y-s.y}addThis(t){return this.x+=t.x,this.y+=t.y,this}setAdd(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this}absoluteOther(t){}absolute(){return s(0),this}setNegate(){this.x=-this.x,this.y=-this.y}setNegateOther(t){this.x=-t.x,this.y=-t.y}interpolateThis(t,s){}interpolate(t,i,e){s(0)}scaleAddThis(t,s){this.x=this.x*t+s.x,this.y=this.y*t+s.y}setScaleAdd(t,s,i){this.x=s.x*t+i.x,this.y=s.y*t+i.y}scaleOther(t,i){s(0)}scale(t){this.x*=t,this.y*=t}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:0}compareX(t){return this.x<t.x?-1:this.x>t.x?1:this.y<t.y?-1:this.y>t.y?1:0}normalizeOther(t){s(0)}normalize(){const t=this.length();return t?(this.x/=t,this.y/=t):(this.x=1,this.y=0),this}getUnitVector(){return this.clone().normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}sqrLength(){return this.x*this.x+this.y*this.y}static averageFast(t,i){return s(0),{}}static average(t,s){const i=new Js;if(0===s)return i.setNAN(),i;if(1===s)return i.assign(t[0]),i;const e=new r(t[0].x),n=new r(t[0].y);for(let r=1;r<s;r++)e.add(t[r].x),n.add(t[r].y),255&r||(e.normalize(),n.normalize());return i.x=e.getResult()/s,i.y=n.getResult()/s,i}offset(t,s){const i=Js.distance(t,s),e=Js.construct(this.x,this.y);if(0===i)return Js.distance(e,t);const n=s.clone();n.subThis(t),e.subThis(t);return e.crossProduct(n)/i}side(t,s){return t.equals(s)?this.equals(t)?0:1:Js.orientationRobust(s,t,this)}static sqrDistance(t,s){const i=t.x-s.x,e=t.y-s.y;return i*i+e*e}static sqrDistanceCoords(t,s,i,e){const n=i-t,r=e-s;return n*n+r*r}static distance(t,s){return Math.sqrt(Js.sqrDistance(t,s))}dotProduct(t){return this.x*t.x+this.y*t.y}dotProductAbs(t){return Math.abs(this.x*t.x)+Math.abs(this.y*t.y)}crossProduct(t){return this.x*t.y-this.y*t.x}crossProductAbs(t){return s(0),0}rotateDirect(t,s){const i=this.x*t-this.y*s,e=this.x*s+this.y*t;this.x=i,this.y=e}rotateReverse(t,s){const i=this.x*t+this.y*s,e=-this.x*s+this.y*t;this.x=i,this.y=e}leftPerpendicularThis(){const t=this.x;this.x=-this.y,this.y=t}leftPerpendicularOther(t){const s=t.x;this.x=-t.y,this.y=s}rightPerpendicularThis(){const t=this.x;this.x=this.y,this.y=-t}rightPerpendicularOther(t){const s=t.x;this.x=t.y,this.y=-s}equals(t){return this.x===t.x&&this.y===t.y}notequals(t){return this.x!==t.x||this.y!==t.y}not(){return!this.x&&!this.y}gt(t){return this.y>t.y||this.y===t.y&&this.x>t.x}gte(t){return!this.lt(t)}lt(t){return this.y<t.y||this.y===t.y&&this.x<t.x}lte(t){return!this.gt(t)}subThis(t){return this.x-=t.x,this.y-=t.y,this}divThis(t){return this.x/=t,this.y/=t,this}add(t){return new Js(this.x+t.x,this.y+t.y)}sub(t){return new Js(this.x-t.x,this.y-t.y)}negateThis(){return this.x=-this.x,this.y=-this.y,this}negate(){return new Js(-this.x,-this.y)}mul(t){return new Js(this.x*t,this.y*t)}mulThis(t){return this.x*=t,this.y*=t,this}divide(t){return new Js(this.x/t,this.y/t)}setNAN(){this.x=this.y=Number.NaN}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)}static getNAN(){return new Js(Number.NaN,Number.NaN)}isFinite(){return Number.isFinite(this.x)&&Number.isFinite(this.y)}isZero(){return 0===this.x&&0===this.y}norm(t){switch(t){case 0:{const t=Math.abs(this.x),s=Math.abs(this.y),i=t-s;return i>=0?t:i<=0?s:Number.NaN}case 1:return Math.abs(this.x)+Math.abs(this.y);case 2:return Math.sqrt(this.x*this.x+this.y*this.y);default:e("norm")}}getQuarter(){return Js.getQuarterCoords(this.x,this.y)}static getQuarterCoords(t,s){return t>0?s>=0?1:4:s>0?2:0===t?4:3}static compareVectors(t,s){const i=t.getQuarter(),e=s.getQuarter();return e===i?Js.orientationRobustImpl(Js.construct(0,0),s,t,!0):i<e?-1:1}static compareVectorsOrigin(t,s,i){const e=s.sub(t),n=i.sub(t),r=e.getQuarter(),h=n.getQuarter();return h===r?Js.orientationRobustImpl(t,i,s,!0):r<h?-1:1}static orientationRobust(t,s,i){return Js.orientationRobustImpl(t,s,i,!1)}static orientationRobustEx(t,s,i,e){if(t.equals(s)||i.equals(e))return 0;const n=s.x-t.x,r=s.y-t.y,h=e.x-i.x,o=e.y-i.y;{const t=Js.getQuarterCoords(n,r)-1,s=Js.getQuarterCoords(h,o)-1,i=Js.d[t][s];if(0!==i)return i}const a=n*o,u=r*h,l=4*zs()*(Math.abs(a)+Math.abs(u)),m=a-u;if(Math.abs(m)>=l){return m<0?-1:m>0?1:0}return Js.orientationRobustExMp(t,s,i,e)}static orientationRobustExMp(t,s,i,e){const n=Ws.constructDouble(s.x),r=Ws.constructDouble(e.x);n.subThis(Ws.constructDouble(t.x)),r.subThis(Ws.constructDouble(i.x));const h=Ws.constructDouble(s.y),o=Ws.constructDouble(e.y);return h.subThis(Ws.constructDouble(t.y)),o.subThis(Ws.constructDouble(i.y)),n.mulThis(o),h.mulThis(r),n.subThis(h),n.LZ()?-1:n.GZ()?1:0}static orientationNonRobust(t,s,i){const e=s.sub(t).crossProduct(i.sub(t));return e<0?-1:e>0?1:0}static orientationRobustImpl(t,s,i,e){if(s.isEqualPoint2D(t)||i.isEqualPoint2D(t)||s.isEqualPoint2D(i))return 0;const n=s.x-t.x,r=s.y-t.y,h=i.x-t.x,o=i.y-t.y;if(!e){const t=Js.getQuarterCoords(n,r)-1,s=Js.getQuarterCoords(h,o)-1,i=Js.d[t][s];if(0!==i)return i}const a=(Math.abs(n)+Math.abs(r)+Math.abs(h)+Math.abs(o))*(Math.abs(s.x)+Math.abs(s.y)+Math.abs(i.x)+Math.abs(i.y))*8*T(),u=n*o-r*h;if(Math.abs(u)>a){return u<0?-1:1}if(C(s.x,t.x)&&C(i.y,t.y)&&C(s.y,t.y)&&C(i.x,t.x)&&M(n,o)&&M(r,h)){const t=n*o,s=r*h;if(C(t,s)){const i=t-s;return i<0?-1:i>0?1:0}}return Js.orientationRobustMp(t,s,i)}static orientationRobustMp(t,s,i){const e=Ws.constructDouble(s.x),n=Ws.constructDouble(i.x);{const s=Ws.constructDouble(t.x);e.subThis(s),n.subThis(s)}const r=Ws.constructDouble(i.y),h=Ws.constructDouble(s.y);{const s=Ws.constructDouble(t.y);r.subThis(s),h.subThis(s)}return e.mulThis(r),h.mulThis(n),e.subThis(h),e.LZ()?-1:e.GZ()?1:0}static inCircleRobust(t,s,i,e){const n=new w,r=new w;n.set(t.x),n.subThis(e.x),r.set(t.y),r.subThis(e.y);const h=new w,o=new w;h.set(s.x),h.subThis(e.x),o.set(s.y),o.subThis(e.y);const a=new w,u=new w;a.set(i.x),a.subThis(e.x),u.set(i.y),u.subThis(e.y);const l=n.mulE(o).subE(r.mulE(h)),m=h.mulE(u).subE(o.mulE(a)),c=n.mulE(u).subE(r.mulE(a)),y=n.mulE(n).addE(r.mulE(r)),x=h.mulE(h).addE(o.mulE(o)),f=a.mulE(a).addE(u.mulE(u)),d=y.mulE(m).subE(x.mulE(c)).addE(f.mulE(l));if(!d.isFuzzyZero()){const t=d.value();return t<0?-1:t>0?1:0}return Js.inCircleRobustMp(t,s,i,e)}static inCircleRobustMp(t,s,i,e){do{if(!C(t.x,e.x)||!C(t.y,e.y))break;if(!C(s.x,e.x)||!C(s.y,e.y))break;if(!C(i.x,e.x)||!C(i.y,e.y))break;const n=t.x-e.x,r=t.y-e.y,h=s.x-e.x,o=s.y-e.y,a=i.x-e.x,u=i.y-e.y;if(!M(n,o)||!M(r,h))break;if(!M(h,u)||!M(o,a))break;if(!M(n,u)||!M(r,a))break;if(!M(n,n)||!M(r,r))break;if(!M(h,h)||!M(o,o))break;if(!M(a,a)||!M(u,u))break;const l=n*o,m=r*h,c=h*u,y=o*a,x=n*u,f=r*a,d=n*n,b=r*r,v=h*h,_=o*o,N=a*a,w=u*u;if(!C(l,m))break;if(!C(c,y))break;if(!C(x,f))break;if(!p(d,b))break;if(!p(v,_))break;if(!p(N,w))break;const T=l-m,R=c-y,g=x-f,E=d+b,I=v+_,D=N+w;if(!M(E,R))break;if(!M(I,g))break;if(!M(D,T))break;const A=E*R,P=I*g,q=D*T;if(!C(A,P))break;const z=A-P;if(!p(z,q))break;const Z=z+q;return Z<0?-1:Z>0?1:0}while(0);const n=Ws.constructDouble(e.x),r=Ws.constructDouble(e.y),h=Ws.constructDouble(t.x),o=Ws.constructDouble(t.y);h.subThis(n),o.subThis(r);const a=Ws.constructDouble(s.x),u=Ws.constructDouble(s.y);a.subThis(n),u.subThis(r);const l=Ws.constructDouble(i.x),m=Ws.constructDouble(i.y);l.subThis(n),m.subThis(r);const c=h.mul(u).sub(o.mul(a)),y=a.mul(m).sub(u.mul(l)),x=h.mul(m).sub(o.mul(l)),f=h.mul(h).add(o.mul(o)),d=a.mul(a).add(u.mul(u)),b=l.mul(l).add(m.mul(m)),v=f.mul(y).sub(d.mul(x)).add(b.mul(c));return v.LZ()?-1:v.GZ()?1:0}static inCircleRobustMp3Point(t,s,i){const e=Ws.constructDouble(t.x),n=Ws.constructDouble(t.y),r=Ws.constructDouble(s.x),h=Ws.constructDouble(s.y),o=Ws.constructDouble(i.x),a=Ws.constructDouble(i.y),u=o.mul(o).add(a.mul(a)).sub(o.mul(e).add(a.mul(n)).add(o.mul(r)).add(a.mul(h))).add(e.mul(r).add(n.mul(h)));return u.LZ()?-1:u.GZ()?1:0}static inCircleRobust3Point(t,s,i){const e=new w(t.x),n=new w(t.y),r=new w(s.x),h=new w(s.y),o=new w(i.x),a=new w(i.y),u=o.mulE(o).addE(a.mulE(a)).subE(o.mulE(e).addE(a.mulE(n)).addE(o.mulE(r)).addE(a.mulE(h))).addE(e.mulE(r).addE(n.mulE(h)));if(!u.isFuzzyZero()){const t=u.value();return t<0?-1:t>0?1:0}return Js.inCircleRobustMp3Point(t,s,i)}static calculateCircleCenterFromThreePoints(t,s,i){if(t.equals(i)||t.equals(s)||i.equals(s))return Js.getNAN();const e=Ks(t,s,i);return e.isNAN()?ti(t,s,i):e}static calculateAngle(t,s){return Math.atan2(t.crossProduct(s),t.dotProduct(s))}static isBisectorRobust(t,i,e){return s(0),!1}static size(){return 2}get 0(){return this.x}get 1(){return this.y}set 0(t){this.x=t}set 1(t){this.y=t}static compareZorder(t,s){const i=Js.c_compare_zorder_xx[t.x<0?1:0]|Js.c_compare_zorder_yy[t.y<0?1:0],e=Js.c_compare_zorder_xx[s.x<0?1:0]|Js.c_compare_zorder_yy[s.y<0?1:0];if(i===e){let i=0,e=0;for(let n=0;n<2;++n){const r=$s(t[n],s[n]);r>i&&(i=r,e=n)}return t[e]<s[e]}return i<e}static lerp(t,s,i){const e=new Js;return Y(t,s,i,e),e}static getClosestCoordinate(t,s,i,e=!1){const n=Js.getNAN();n.setSub(s,t);const r=n.sqrLength();if(0===r)return.5;if(s.isEqualPoint2D(i))return 1;const h=Js.getNAN();h.setSub(i,t);let o=h.dotProduct(n)/r;return e||(o<0?o=0:o>1&&(o=1)),o}static intersectLinesAtOnePoint(t,s,i,e){if(t.equals(s)||i.equals(e))return Js.getNAN();const n=s.x-t.x,r=i.x-e.x,h=s.y-t.y,o=i.y-e.y,a=n*o-r*h;if(!a)return Js.getNAN();const u=a;if(0===u)return Js.getNAN();let l=(i.x-t.x)*o-(i.y-t.y)*r;l/=u;const m=new Js;return Y(t,s,l,m),m.isFinite()?m:Js.getNAN()}toString(){return`[${this.x},${this.y}]`}}function Ks(t,s,i){const e=new w(s.x);e.subThis(t.x);const n=new w(s.y);n.subThis(t.y);const r=new w(i.x);r.subThis(t.x);const h=new w(i.y);h.subThis(t.y);const o=e.clone();o.mulThisE(h);let a=n.clone();if(a.mulThisE(r),o.subThisE(a),0===o.value())return Js.getNAN();o.mulThis(2);const u=e.clone();u.mulThisE(e);const l=n.clone();l.mulThisE(n);const m=u.clone();m.addThisE(l);const c=r.clone();c.mulThisE(r);const y=h.clone();y.mulThisE(h);const x=c.clone();x.addThisE(y);const f=n.clone();f.mulThisE(x),a=h.clone(),a.mulThisE(m),f.subThisE(a),f.divThisE(o);const d=e.clone();d.mulThisE(x),a=r.clone(),a.mulThisE(m),d.subThisE(a),d.divThisE(o);const b=Js.construct(t.x-f.value(),t.y+d.value()),v=t.sub(b).length(),_=s.sub(b).length(),N=i.sub(b).length(),M=1e-15*(v+Math.abs(t.x)+Math.abs(s.x)+Math.abs(i.x)+Math.abs(t.y)+Math.abs(s.y)+Math.abs(i.y));return Math.abs(v-_)<=M&&Math.abs(v-N)<=M&&f.eps()<M&&d.eps()<M?b:Js.getNAN()}function ti(t,s,i){const e=Ws.constructDouble(s.x);e.subDoubleThis(t.x);const n=Ws.constructDouble(s.y);n.subDoubleThis(t.y);const r=Ws.constructDouble(i.x);r.subDoubleThis(t.x);const h=Ws.constructDouble(i.y);h.subDoubleThis(t.y);const o=e.clone();o.mulThis(h);let a=n.clone();if(a.mulThis(r),o.subThis(a),o.isZero())return Js.getNAN();o.mulDoubleThis(2);const u=e.clone();u.mulThis(e);const l=n.clone();l.mulThis(n);const m=u.clone();m.addThis(l);const c=r.clone();c.mulThis(r);const y=h.clone();y.mulThis(h);const x=c.clone();x.addThis(y);const f=n.clone();f.mulThis(x),a=h.clone(),a.mulThis(m),f.subThis(a),f.divThis(o);const d=e.clone();d.mulThis(x),a=r.clone(),a.mulThis(m),d.subThis(a),d.divThis(o);return Js.construct(t.x-f.value(),t.y+d.value())}Js.dimensions=2,Js.d=[[0,1,0,-1],[-1,0,1,0],[0,-1,0,1],[1,0,-1,0]],Js.c_compare_zorder_xx=[2,0],Js.c_compare_zorder_yy=[1,0];class si{constructor(t,s,i){if(t instanceof si)return this.data=t.data,this.N=t.N,this.M=t.M,t.data=null,t.N=0,void(t.M=0);this.data=t,this.N=s,this.M=i}assignCopy(t){return this===t||(s(this.N*this.M==t.N*t.M),this.data.set(t.data),this.N=t.N,this.M=t.M),this}setZero(){return this.data?.fill(0),this}setIdentity(){const t=0,s=1;for(let i=0;i<this.N;i++)for(let e=0;e<this.M;e++)this.setRowCol(i,e,i===e?s:t);return this}rows(){return this.N}cols(){return this.M}row(t){return s(0),{}}set(t,s){return this.data[t]=s,this}setRowCol(t,s,i){return this.data[t*this.M+s]=i,this}at(t){return this.data[t]}atRowCol(t,s){return this.data[t*this.M+s]}mulScalar(t,i){s(0)}mul(t,i){if(s(this.M===t.rows()),s(this.N===i.rows()),s(t.cols()===i.cols()),i===this){const s=new Float64Array(this.N*this.M),e=new si(s,this.N,this.M);return this.mul(t,e),void i.assignCopy(e)}if(i===t){const s=new Float64Array(t.N*t.M),e=new si(s,t.N,t.M);return this.mul(t,e),void i.assignCopy(e)}const e=t.cols();for(let s=0;s<this.N;s++)for(let n=0;n<e;n++){let e=0;for(let i=0;i<this.M;i++)e+=this.atRowCol(s,i)*t.atRowCol(i,n);i.setRowCol(s,n,e)}}mulTranspose(t,i){if(s(this.M===t.cols()),s(this.N===i.rows()),s(t.rows()===i.cols()),i===this){const s=new Float64Array(this.N*this.M),e=new si(s,this.N,this.M);return this.mulTranspose(t,e),void i.assignCopy(e)}if(i===t){const s=new Float64Array(t.N*t.M),e=new si(s,t.N,t.M);return this.mulTranspose(t,e),void i.assignCopy(e)}const e=t.rows();for(let s=0;s<this.N;s++)for(let n=0;n<e;n++){let e=0;for(let i=0;i<this.M;i++)e+=this.atRowCol(s,i)*t.atRowCol(n,i);i.setRowCol(s,n,e)}}mulLeft(t,i){s(0)}mulLeftTranspose(t,i){s(0)}mulDiag(t,i){if(s(this.M===t.N*t.M),s(this.N===i.rows()),s(this.M===i.cols()),i===this){const s=new Float64Array(this.N*this.M),e=new si(s,this.N,this.M);return this.mulDiag(t,e),void i.assignCopy(e)}const e=this.M;for(let s=0;s<this.N;s++)for(let n=0;n<e;n++)i.setRowCol(s,n,this.atRowCol(s,n)*t.at(n))}transposeInPlace(){if(this.N===this.M){for(let t=0;t<this.N;t++)for(let s=t+1;s<this.M;s++){const i=this.atRowCol(t,s);this.setRowCol(t,s,this.atRowCol(s,t)),this.setRowCol(s,t,i)}return this}const t=new Float64Array(this.N*this.M),s=new si(t,this.N,this.M);return s.assignCopy(this),this.M=Tt(this.N,this.N=this.M),s.transpose(this),this}transpose(t){if(this!==t){si.checkDims(t,this.M,this.N);for(let s=0;s<this.N;s++)for(let i=0;i<this.M;i++)t.setRowCol(i,s,this.atRowCol(s,i))}else t.transposeInPlace()}add(t,s){}svd(t,i,e,n=!1){if(si.checkDims(t,this.N,this.M),si.checkDims(i,this.M,1),si.checkDims(e,this.M,this.M),n){if(s(this.N===this.M),!this.symmetricEigen(i,e))return!1;for(let t=0;t<this.M;++t)i.at(t)<0&&i.set(t,0);return t.assignCopy(e),!0}let r,h,o,a,u,l,m,c=0,y=0,x=0,f=0,d=0;const b=this.M,v=this.N;t.assignCopy(this);const _=new Float64Array(b),N=new si(_,b,1),w=(t,s)=>s>=0?Math.abs(t):-Math.abs(t),M=(t,s)=>{if((t=Math.abs(t))>(s=Math.abs(s))){const i=s/t;return t*Math.sqrt(i*i+1)}if(s>0){const i=t/s;return s*Math.sqrt(i*i+1)}return 0};for(let s=0;s<b;s++){if(c=s+1,N.set(s,f*x),x=a=f=0,s<v){for(let i=s;i<v;i++)f+=Math.abs(t.atRowCol(i,s));if(f){for(let i=s;i<v;i++)t.setRowCol(i,s,t.atRowCol(i,s)/f),a+=t.atRowCol(i,s)*t.atRowCol(i,s);h=t.atRowCol(s,s),x=-w(Math.sqrt(a),h),o=h*x-a,t.setRowCol(s,s,h-x);for(let i=c;i<b;i++){a=0;for(let e=s;e<v;e++)a+=t.atRowCol(e,s)*t.atRowCol(e,i);h=a/o;for(let e=s;e<v;e++)t.setRowCol(e,i,t.atRowCol(e,i)+h*t.atRowCol(e,s))}for(let i=s;i<v;i++)t.setRowCol(i,s,t.atRowCol(i,s)*f)}}if(i.set(s,f*x),x=a=f=0,s<v&&s!==b-1){for(let i=c;i<b;i++)f+=Math.abs(t.atRowCol(s,i));if(f){for(let i=c;i<b;i++)t.setRowCol(s,i,t.atRowCol(s,i)/f),a+=t.atRowCol(s,i)*t.atRowCol(s,i);h=t.atRowCol(s,c),x=-w(Math.sqrt(a),h),o=h*x-a,t.setRowCol(s,c,h-x);for(let i=c;i<b;i++)N.set(i,t.atRowCol(s,i)/o);for(let i=c;i<v;i++){a=0;for(let e=c;e<b;e++)a+=t.atRowCol(i,e)*t.atRowCol(s,e);for(let s=c;s<b;s++)t.setRowCol(i,s,t.atRowCol(i,s)+a*N.at(s))}for(let i=c;i<b;i++)t.setRowCol(s,i,t.atRowCol(s,i)*f)}}const e=Math.abs(i.at(s))+Math.abs(N.at(s));d=e>d?e:d}for(let s=b-1;s>=0;s--){if(s<b-1){if(x){for(let i=c;i<b;i++)e.setRowCol(i,s,t.atRowCol(s,i)/t.atRowCol(s,c)/x);for(let i=c;i<b;i++){a=0;for(let n=c;n<b;n++)a+=t.atRowCol(s,n)*e.atRowCol(n,i);for(let t=c;t<b;t++)e.setRowCol(t,i,e.atRowCol(t,i)+a*e.atRowCol(t,s))}}for(let t=c;t<b;t++)e.setRowCol(s,t,0),e.setRowCol(t,s,0)}e.setRowCol(s,s,1),x=N.at(s),c=s}for(let s=(v<b?v:b)-1;s>=0;s--){c=s+1,x=i.at(s);for(let i=c;i<b;i++)t.setRowCol(s,i,0);if(x){x=1/x;for(let i=c;i<b;i++){a=0;for(let e=c;e<v;e++)a+=t.atRowCol(e,s)*t.atRowCol(e,i);h=a/t.atRowCol(s,s)*x;for(let e=s;e<v;e++)t.setRowCol(e,i,t.atRowCol(e,i)+h*t.atRowCol(e,s))}for(let i=s;i<v;i++)t.setRowCol(i,s,t.atRowCol(i,s)*x)}else for(let i=s;i<v;i++)t.setRowCol(i,s,0);t.setRowCol(s,s,t.atRowCol(s,s)+1)}for(let s=b-1;s>=0;s--)for(let n=1;;n++){let f=1;for(c=s;c>=0;c--){if(y=c-1,Math.abs(N.at(c))+d===d){f=0;break}if(Math.abs(i.at(y))+d===d)break}if(f){r=0,a=1;for(let e=c;e<=s&&(h=a*N.at(e),N.set(e,N.at(e)*r),Math.abs(h)+d!==d);e++){x=i.at(e),o=M(h,x),i.set(e,o),o=1/o,r=x*o,a=-h*o;for(let s=0;s<v;s++)l=t.atRowCol(s,y),m=t.atRowCol(s,e),t.setRowCol(s,y,l*r+m*a),t.setRowCol(s,e,m*r-l*a)}}if(m=i.at(s),c===s){if(m<0){i.set(s,-m);for(let t=0;t<b;t++)e.setRowCol(t,s,-e.atRowCol(t,s))}break}if(100===n)return!1;u=i.at(c),y=s-1,l=i.at(y),x=N.at(y),o=N.at(s),h=((l-m)*(l+m)+(x-o)*(x+o))/(2*o*l),x=M(h,1),h=((u-m)*(u+m)+o*(l/(h+w(x,h))-o))/u,r=a=1;for(let s=c;s<=y;s++){const n=s+1;x=N.at(n),l=i.at(n),o=a*x,x*=r,m=M(h,o),N.set(s,m),r=h/m,a=o/m,h=u*r+x*a,x=x*r-u*a,o=l*a,l*=r;for(let t=0;t<b;t++)u=e.atRowCol(t,s),m=e.atRowCol(t,n),e.setRowCol(t,s,u*r+m*a),e.setRowCol(t,n,m*r-u*a);m=M(h,o),i.set(s,m),m&&(m=1/m,r=h*m,a=o*m),h=r*x+a*l,u=r*l-a*x;for(let i=0;i<v;i++)l=t.atRowCol(i,s),m=t.atRowCol(i,n),t.setRowCol(i,s,l*r+m*a),t.setRowCol(i,n,m*r-l*a)}N.set(c,0),N.set(s,h),i.set(s,u)}const p=new Float64Array(this.N),C=new Float64Array(this.M),T=new si(p,this.N,1),R=new si(C,this.M,1);let g=1;do{g*=3,g++}while(g<=this.M);do{g/=3,g=Math.trunc(g);for(let s=g;s<this.M;s++){const n=i.at(s);for(let i=0;i<this.N;i++)T.set(i,t.atRowCol(i,s));for(let t=0;t<this.M;t++)R.set(t,e.atRowCol(t,s));let r=s;for(;i.at(r-g)<n;){i.set(r,i.at(r-g));for(let s=0;s<this.N;s++)t.setRowCol(s,r,t.atRowCol(s,r-g));for(let t=0;t<this.M;t++)e.setRowCol(t,r,e.atRowCol(t,r-g));if(r-=g,r<g)break}i.set(r,n);for(let s=0;s<this.N;s++)t.setRowCol(s,r,T.at(s));for(let t=0;t<this.M;t++)e.setRowCol(t,r,R.at(t))}}while(g>1);for(let s=0;s<this.M;s++){let i=0;for(let e=0;e<this.N;e++)t.atRowCol(e,s)<0&&i++;for(let t=0;t<this.M;t++)e.atRowCol(t,s)<0&&i++;if(i>Math.trunc((this.N+this.M)/2)){for(let i=0;i<this.N;i++)t.setRowCol(i,s,-t.atRowCol(i,s));for(let t=0;t<this.M;t++)e.setRowCol(t,s,-e.atRowCol(t,s))}}return!0}isSymmetric(){if(this.N!==this.M)return!1;for(let t=0;t<this.N;t++)for(let s=t+1;s<this.M;s++)if(this.atRowCol(t,s)!==this.atRowCol(s,t))return!1;return!0}isZero(){return s(0),!1}isIdentity(){return s(0),!1}equals(t,i){if(void 0!==i&&s(0),this.N!==t.N||this.M!==t.M)return!1;for(let s=0;s<this.N*this.M;s++)if(this.data[s]!==t.data[s])return!1;return!0}maxElement(){return s(0),0}minElement(){return s(0),0}determinant(){if(s(this.N===this.M),1===this.N)return this.data[0];if(2===this.N)return this.data[0]*this.data[3]-this.data[1]*this.data[2];if(3===this.N){const t=this;return t.atRowCol(0,0)*(t.atRowCol(1,1)*t.atRowCol(2,2)-t.atRowCol(1,2)*t.atRowCol(2,1))-t.atRowCol(0,1)*(t.atRowCol(1,0)*t.atRowCol(2,2)-t.atRowCol(2,0)*t.atRowCol(1,2))+t.atRowCol(0,2)*(t.atRowCol(1,0)*t.atRowCol(2,1)-t.atRowCol(1,1)*t.atRowCol(2,0))}const t=new Float64Array(this.N*this.N),i=new si(t,this.N,this.N),e=new Float64Array(this.N);if(!this.luDecomposition(i,e))return 0;let n=1;for(let s=0;s<this.N;s++)n*=i.atRowCol(s,s),e[s]!==s&&(n=-n);return n}submatrix(t,i,e){s(0)}inverse(t){s(0)}pseudoInverse(t,s=!1,i=2220446049250313e-31){if(t.setZero(),1===this.N&&1===this.M)return 0!==this.atRowCol(0,0)?t.setRowCol(0,0,1/this.atRowCol(0,0)):t.setRowCol(0,0,0),!0;if(2===this.N&&2===this.M){const s=this.atRowCol(0,0)*this.atRowCol(1,1)-this.atRowCol(0,1)*this.atRowCol(1,0),i=1e-5*(Math.abs(this.atRowCol(0,0)*this.atRowCol(1,1))+Math.abs(this.atRowCol(0,1)*this.atRowCol(1,0)));if(Math.abs(s)>i)return t.setRowCol(0,0,this.atRowCol(1,1)/s),t.setRowCol(0,1,-this.atRowCol(0,1)/s),t.setRowCol(1,0,-this.atRowCol(1,0)/s),t.setRowCol(1,1,this.atRowCol(0,0)/s),!0}const e=new Float64Array(this.N*this.M),n=new si(e,this.N,this.M),r=new Float64Array(this.M),h=new si(r,this.M,1),o=new Float64Array(this.M*this.M),a=new si(o,this.M,this.M);if(!this.svd(n,h,a,s))return!1;const u=Math.max(this.N,this.M),l=i*Math.abs(h.at(0))*u;for(let m=0;m<this.M;m++)h.at(m)>l?h.set(m,1/h.at(m)):h.set(m,0);return a.mulDiag(h,t),t.mulTranspose(n,t),!0}luDecomposition(t,i){return s(0),!1}symmetricEigen(t,i){s(this.rows()===this.cols()),s(this.rows()===t.rows()),s(i.rows()===i.cols()&&i.rows()===this.rows()),s(this.isSymmetric());const e=new Float64Array(this.N*this.M),n=new si(e,this.N,this.M);n.assignCopy(this);const r=100/Number.EPSILON,h=this.rows(),o=new Float64Array(h),a=new Float64Array(h),u=new si(o,h,1),l=new si(a,h,1);for(let s=0;s<h;s++)u.set(s,n.atRowCol(s,s)),t.set(s,n.atRowCol(s,s)),l.set(s,0);i.setIdentity();const m=()=>{const s=u;i.transposeInPlace();let e=1;do{e*=3,e++}while(e<=h);do{e/=3,e=Math.trunc(e);for(let n=e;n<h;n++){const r=t.at(n),h=Math.abs(r);for(let t=0;t<this.M;t++)s.set(t,i.atRowCol(t,n));let o=n;for(;Math.abs(t.at(o-e))<h;){t.set(o,t.at(o-e));for(let t=0;t<this.M;t++)i.setRowCol(t,o,i.atRowCol(t,o-e));if(o-=e,o<e)break}if(o!==n){t.set(o,r);for(let t=0;t<this.M;t++)i.setRowCol(t,o,s.at(t))}}}while(e>1)};for(let s=1;;s++){let e=0;for(let t=1;t<h;t++)for(let s=0;s<t;s++)e+=Math.abs(n.atRowCol(t,s));if(0===e)return m(),!0;const o=s<4?.2*e/(h*h):0;for(let a=0;a<h;a++)for(let e=a+1;e<h;e++){let u=r*Math.abs(n.atRowCol(e,a));if(s>4&&u<=Math.abs(t.at(a))&&u<=Math.abs(t.at(e)))n.setRowCol(e,a,0);else if(Math.abs(n.atRowCol(e,a))>o){let s,r=t.at(e)-t.at(a);if(u<Math.abs(r))s=n.atRowCol(e,a)/r;else{const t=.5*r/n.atRowCol(e,a);s=1/(Math.abs(t)+Math.sqrt(1+t*t)),t<0&&(s=-s)}const o=1/Math.sqrt(1+s*s),m=s*o,c=m/(1+o);r=s*n.atRowCol(e,a),l.set(a,l.at(a)-r),l.set(e,l.at(e)+r),t.set(a,t.at(a)-r),t.set(e,t.at(e)+r),n.setRowCol(e,a,0);let y=0;for(;y<a;y++)u=n.atRowCol(a,y),r=n.atRowCol(e,y),n.setRowCol(a,y,u-m*(r+u*c)),n.setRowCol(e,y,r+m*(u-r*c));for(y++;y<e;y++)u=n.atRowCol(y,a),r=n.atRowCol(e,y),n.setRowCol(y,a,u-m*(r+u*c)),n.setRowCol(e,y,r+m*(u-r*c));for(y++;y<h;y++)u=n.atRowCol(y,a),r=n.atRowCol(y,e),n.setRowCol(y,a,u-m*(r+u*c)),n.setRowCol(y,e,r+m*(u-r*c));for(y=0;y<h;y++)u=i.atRowCol(a,y),r=i.atRowCol(e,y),i.setRowCol(a,y,u-m*(r+u*c)),i.setRowCol(e,y,r+m*(u-r*c))}}for(let s=0;s<h;s++)u.set(s,u.at(s)+l.at(s)),t.set(s,u.at(s)),l.set(s,0)}}static checkDims(t,i,e){s(t.rows()===i&&t.cols()===e)}}class ii extends si{constructor(t){if(t.copy){const s=new Float64Array(t.copy.N*t.copy.M);return super(s,t.copy.N,t.copy.M),this.buffer=s,void this.assignCopy(t.copy)}const s=new Float64Array(t.NN*t.MM);super(s,t.NN,t.MM),this.buffer=s,t.initializerList&&pt(this.buffer,t.initializerList,0,0,t.initializerList.length)}assignCopy(t){return this===t||super.assignCopy(t),this}}class ei{constructor(t){this.m_TransformationType=1,void 0===t?this.setIdentity():t instanceof ei?this.set(t):this.setScale(t)}set(t){return this.xx=t.xx,this.xy=t.xy,this.xd=t.xd,this.yx=t.yx,this.yy=t.yy,this.yd=t.yd,this}clone(){return(new ei).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(t){return this===t||this.xx===t.xx&&this.xy===t.xy&&this.xd===t.xd&&this.yx===t.yx&&this.yy===t.yy&&this.yd===t.yd}transformInPlace(t){const s=this.xx*t.x+this.xy*t.y+this.xd,i=this.yx*t.x+this.yy*t.y+this.yd;t.x=s,t.y=i}transform(t){const s=t.clone();return this.transformInPlace(s),s}queryTransform(t,s){const i=this.xx*t.x+this.xy*t.y+this.xd,e=this.yx*t.x+this.yy*t.y+this.yd;s.setCoords(i,e)}transformEnvInPlace(t){if(t.isEmpty())return;const s=zt(Js,4);t.queryCorners(s),this.transformPoints2D(s,4,s),t.setFromPoints(s,4)}queryTransformEnv(t,i){s(0)}transformPoints2D(t,s,i){for(let e=0;e<s;++e)this.queryTransform(t[e],i[e])}transformInterleavedPoints(t,s,i){s*=2;const e=Js.getNAN();for(let n=0;n<s;n+=2)e.x=t[n],e.y=t[n+1],this.transformInPlace(e),i[n]=e.x,i[n+1]=e.y}multiply(t){return ei.st_multiply(this,t,this),this}mulLeft(t){return s(0),this}static st_multiply(t,s,i){const e=t.xx*s.xx+t.yx*s.xy,n=t.xy*s.xx+t.yy*s.xy,r=t.xd*s.xx+t.yd*s.xy+s.xd,h=t.xx*s.yx+t.yx*s.yy,o=t.xy*s.yx+t.yy*s.yy,a=t.xd*s.yx+t.yd*s.yy+s.yd;i.xx=e,i.xy=n,i.xd=r,i.yx=h,i.yy=o,i.yd=a}getCoefficients(t){s(t.length>=6),t[0]=this.xx,t[1]=this.xy,t[2]=this.xd,t[3]=this.yx,t[4]=this.yy,t[5]=this.yd}setCoefficients(t){s(t.length>=6),this.xx=t[0],this.xy=t[1],this.xd=t[2],this.yx=t[3],this.yy=t[4],this.yd=t[5]}copyTo(t){s(0)}initializeFromRect(t,s){t.isEmpty()||s.isEmpty()||!t.width()||!t.height()?this.setZero():(this.xy=this.yx=0,this.xx=s.width()/t.width(),this.yy=s.height()/t.height(),this.xd=s.xmin-t.xmin*this.xx,this.yd=s.ymin-t.ymin*this.yy)}initializeFromRectIsotropic(t,s){if(t.isEmpty()||!t.width()||!t.height()||s.isEmpty())this.setZero();else{this.yx=0,this.xy=0,this.xx=s.width()/t.width(),this.yy=s.height()/t.height(),this.xx>this.yy?this.xx=this.yy:this.yy=this.xx;const i=s.getCenter(),e=t.getCenter();this.xd=i.x-e.x*this.xx,this.yd=i.y-e.y*this.yy}}initializeFromTwoPointsArray(t,s){if(t[0].equals(s[0])&&t[1].equals(s[1]))return void this.setIdentity();if(t[0].equals(t[1])){if(s[0].equals(s[1]))return void this.setShift(s[0].sub(t[0]));e("")}if(!t[0].equals(t[1])&&s[0].equals(s[1]))return this.setZero(),void this.shift(s[0]);this.setShiftCoords(-t[0].x,-t[0].y);const i=Js.distance(t[0],t[1]),n=Js.distance(s[0],s[1]),r=n/i;this.scale(r,r);const h=t[1].sub(t[0]);h.divThis(i);const o=s[1].sub(s[0]);o.divThis(n);const a=h.crossProduct(o),u=h.dotProduct(o);this.rotate(u,a),this.shiftCoords(s[0].x,s[0].y)}initializeFromTwoPoints(t,s,i,e){const n=[t,s],r=[i,e];this.initializeFromTwoPointsArray(n,r)}transformSizeInPlace(t){s(0)}transformSize(t,i){s(0)}transformTol(t){return s(0),0}transformWithoutTranslateArray(t,s,i){for(let e=0;e<s;++e)this.transformWithoutTranslate(t[e],i[e])}transformWithoutTranslateInPlace(t){const s=this.xx*t.x+this.xy*t.y,i=this.yx*t.x+this.yy*t.y;t.setCoords(s,i)}transformWithoutTranslate(t,s){const i=this.xx*t.x+this.xy*t.y,e=this.yx*t.x+this.yy*t.y;s.setCoords(i,e)}setIdentity(){this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=1,this.yd=0}isIdentity(){return!(1!==this.xx||1!==this.yy||this.xy||this.xd||this.yx||this.yd)}isIdentityTol(t){const s=t*t;return!(X(this.xd)+X(this.yd)>s)&&(!(X(this.xy+this.xd)+X(this.yy+this.yd-1)>s)&&!(X(this.xx+this.xd-1)+X(this.yx+this.yd)>s))}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(t){const s=this.xx*this.xx+this.yx*this.yx,i=this.xy*this.xy+this.yy*this.yy,e=(s+i)*t;return Math.abs(s-i)<=e&&Math.abs(this.xx*this.xy+this.yx*this.yy)<=e}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return 1===this.xx&&1===this.yy&&!this.xy&&!this.yx}isTranslateTol(t){const s=new Js;return s.setCoords(0,1),this.transformWithoutTranslateInPlace(s),s.y-=1,!(s.sqrLength()>t*t)&&(s.setCoords(1,0),this.transformWithoutTranslateInPlace(s),s.x-=1,s.sqrLength()<=t*t)}isOrthonormal(t){const s=new ei;return s.xx=this.xx*this.xx+this.xy*this.xy,s.xy=this.xx*this.yx+this.xy*this.yy,s.yx=this.yx*this.xx+this.yy*this.xy,s.yy=this.yx*this.yx+this.yy*this.yy,s.xd=0,s.yd=0,s.isIdentityTol(t)}isDegenerate(t){return Math.abs(this.xx*this.yy-this.yx*this.xy)<=2*t*(Math.abs(this.xx*this.yy)+Math.abs(this.yx*this.xy))}isZero(){return 0===this.xx&&0===this.yy&&0===this.xy&&0===this.yx&&0===this.xd&&0===this.yd}isScaleAndTranslateTol(t){return this.xy*this.xy+this.yx*this.yx<=(this.xx*this.xx+this.yy*this.yy)*t}setTranslate(t,s){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=s,this}setShiftCoords(t,s){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=s,this}setShift(t){return this.xx=1,this.xy=0,this.xd=t.x,this.yx=0,this.yy=1,this.yd=t.y,this}setScaleCoords(t,s){return this.xx=t,this.xy=0,this.xd=0,this.yx=0,this.yy=s,this.yd=0,this}setScale(t){return this.setScaleCoords(t,t),this}setFlipX(t,s){return this.xx=-1,this.xy=0,this.xd=t+s,this.yx=0,this.yy=1,this.yd=0,this}setFlipY(t,s){return this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=-1,this.yd=t+s,this}setShear(t,s){return this.xx=1,this.xy=t,this.xd=0,this.yx=s,this.yy=1,this.yd=0,this}scale(t,s){return this.xx*=t,this.xy*=t,this.xd*=t,this.yx*=s,this.yy*=s,this.yd*=s,this}setRotateAngle(t){return this.setRotate(Math.cos(t),Math.sin(t))}setRotate(t,s){return this.xx=t,this.xy=-s,this.xd=0,this.yx=s,this.yy=t,this.yd=0,this}setRotateAngleAbout(t,s){return this.setRotateAbout(Math.cos(t),Math.sin(t),s)}setRotateAbout(t,s,i){return this.setTranslate(-i.x,-i.y),this.rotate(t,s),this.translate(i.x,i.y)}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return this.xx=0,this.xy=1,this.xd=0,this.yx=-1,this.yy=0,this.yd=0,this}setRotateCcw90(){return this.xx=0,this.xy=-1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}shiftCoords(t,s){return this.xd+=t,this.yd+=s,this}shift(t){return this.xd+=t.x,this.yd+=t.y,this}translate(t,s){return this.xd+=t,this.yd+=s,this}flipX(t,s){return this.xx=-this.xx,this.xy=-this.xy,this.xd=t+s-this.xd,this}flipY(t,s){return this.yx=-this.yx,this.yy=-this.yy,this.yd=t+s-this.yd,this}shear(t,s){const i=new ei;return i.setShear(t,s),this.multiply(i)}rotateAngle(t){const s=new ei;return s.setRotateAngle(t),this.multiply(s)}rotate(t,s){const i=new ei;return i.setRotate(t,s),this.multiply(i)}rotateAbout(t,s,i){return this.translate(-i.x,-i.y),this.rotate(t,s),this.translate(i.x,i.y)}rotateAngleAbout(t,s){return this.rotateAbout(Math.cos(t),Math.sin(t),s)}setInvert(t){return this.set(t),this.invertThis()}invertThis(){let t=this.xx*this.yy-this.xy*this.yx;if(0===t)return this.setZero(),this;t=1/t;const s=(this.xy*this.yd-this.xd*this.yy)*t,i=(this.xd*this.yx-this.xx*this.yd)*t,e=this.yy*t,n=-this.xy*t,r=-this.yx*t,h=this.xx*t;return this.xd=s,this.yd=i,this.xx=e,this.yy=h,this.xy=n,this.yx=r,this}invertPrecise(t){return this.set(t),this.invertPreciseThis()}invertPreciseThis(){const t=Ws.constructDouble(this.xy),s=Ws.constructDouble(this.xx),i=s.mulDouble(this.yy).sub(t.mulDouble(this.yx));if(i.isZero())return this.setZero(),this;const e=i.clone();e.invertThis();const n=Ws.constructDouble(this.xd),r=t.mulDouble(this.yd).sub(n.mulDouble(this.yy)).mul(e).toDouble(),h=n.mulDouble(this.yx).sub(s.mulDouble(this.yd)).mul(e).toDouble(),o=e.mulDouble(this.yy).toDouble(),a=e.mulDouble(-this.xy).toDouble(),u=e.mulDouble(-this.yx).toDouble(),l=e.mulDouble(this.xx).toDouble();return this.xd=r,this.yd=h,this.xx=o,this.yy=l,this.xy=a,this.yx=u,this}extractScaleTransform(t,s){const i=Math.sqrt(this.xx*this.xx+this.xy*this.xy),e=Math.sqrt(this.yx*this.yx+this.yy*this.yy);s.setScaleCoords(1/i,1/e),s.multiply(this),t.setScaleCoords(i,e)}setFromTwoTriangles(t,s){let i=!0;for(let u=0;u<3;++u)i=i&&t[u].equals(s[u]);if(i)return this.setIdentity(),!0;const e=new Js;e.setSub(t[0],t[1]);const n=new Js;n.setSub(t[0],t[2]);const r=new Js;r.setSub(s[0],s[1]);const h=new Js;h.setSub(s[0],s[2]);const o=4*Number.EPSILON*(Math.abs(e.x*n.y)+Math.abs(n.x*e.y));let a=e.x*n.y-e.y*n.x;return Math.abs(a)>o?(a=1/a,this.xx=(r.x*n.y-e.y*h.x)*a,this.xy=(e.x*h.x-r.x*n.x)*a,this.yx=(r.y*n.y-e.y*h.y)*a,this.yy=(e.x*h.y-r.y*n.x)*a,this.xd=s[0].x-(this.xx*t[0].x+this.xy*t[0].y),this.yd=s[0].y-(this.yx*t[0].x+this.yy*t[0].y),!0):(this.setZero(),!1)}initializeFromControlPoints(t,s,i,e,n=null){return 0===s?(this.setIdentity(),void(n&&n.setIdentity())):1===s?(this.setShift(e[0].sub(i[0])),void(n&&n.setShift(i[0].sub(e[0])))):(s<3&&(t=1),void(4===t&&s>2?hi(this,s,i,e,n):oi(t,this,s,i,e,n)))}calculateErrors(t,i,e,n){s(t>0&&null!==i&&null!==e);let r=0;for(let s=0;s<t;++s){const t=this.transform(i[s]),h=Js.sqrDistance(e[s],t);r+=h,n&&(n[s]=Math.sqrt(h))}return Math.sqrt(r/t)}}const ni=[43,11,41,9,61];function ri(t,i){s(!(2!==i.rows()&&3!==i.rows()||2!==i.cols()&&3!==i.rows())),t.xx=i.atRowCol(0,0),t.xy=i.atRowCol(0,1),t.yx=i.atRowCol(1,0),t.yy=i.atRowCol(1,1),3===i.cols()?(t.xd=i.atRowCol(0,2),t.yd=i.atRowCol(1,2)):(t.xd=0,t.yd=0)}function hi(t,s,i,e,r){const h=Js.average(i,s),o=Js.average(e,s),a=new ii({NN:2,MM:2});a.setZero();const u=new ii({NN:2,MM:2});u.setZero();for(let n=0;n<s;++n)a.setRowCol(0,0,a.atRowCol(0,0)+(i[n].x-h.x)*(i[n].x-h.x)),a.setRowCol(0,1,a.atRowCol(0,1)+(i[n].x-h.x)*(i[n].y-h.y)),a.setRowCol(1,1,a.atRowCol(1,1)+(i[n].y-h.y)*(i[n].y-h.y)),u.setRowCol(0,0,u.atRowCol(0,0)+(e[n].x-o.x)*(i[n].x-h.x)),u.setRowCol(0,1,u.atRowCol(0,1)+(e[n].x-o.x)*(i[n].y-h.y)),u.setRowCol(1,0,u.atRowCol(1,0)+(e[n].y-o.y)*(i[n].x-h.x)),u.setRowCol(1,1,u.atRowCol(1,1)+(e[n].y-o.y)*(i[n].y-h.y));a.setRowCol(1,0,a.atRowCol(0,1));const l=new ii({NN:2,MM:2});a.pseudoInverse(l,!0)||n("Failed to compute pseudo inverse"),u.mul(l,u),ri(t,u);const m=h.clone();t.transformInPlace(m),t.xd=o.x-m.x,t.yd=o.y-m.y,r&&(u.pseudoInverse(l,!1)||n("Failed to compute pseudo inverse"),ri(r,l),r.transformInPlace(o),r.xd=h.x-o.x,r.yd=h.y-o.y)}function oi(t,i,e,r,h,o){s(1===t||0===t||2===t||3===t),i.setIdentity();const a=Js.average(r,e),u=Js.average(h,e);if(s(t<ni.length&&t>0),8&ni[t]){const s=new ii({NN:2,MM:2});s.setZero();for(let t=0;t<e;++t)s.setRowCol(0,0,s.atRowCol(0,0)+(h[t].x-u.x)*(r[t].x-a.x)),s.setRowCol(1,0,s.atRowCol(1,0)+(h[t].x-u.x)*(r[t].y-a.y)),s.setRowCol(0,1,s.atRowCol(0,1)+(h[t].y-u.y)*(r[t].x-a.x)),s.setRowCol(1,1,s.atRowCol(1,1)+(h[t].y-u.y)*(r[t].y-a.y));const o=new ii({NN:2,MM:2}),l=new ii({NN:2,MM:1}),m=new ii({NN:2,MM:2});s.svd(o,l,m)||n("Failed to compute svd");const c=new ii({NN:2,MM:2});o.transpose(c);const y=new ii({NN:2,MM:2});if(m.mul(c,y),!(32&ni[t])){y.determinant()<0&&(c.setRowCol(1,0,-c.atRowCol(1,0)),c.setRowCol(1,1,-c.atRowCol(1,1)),m.mul(c,y))}const x=new ei;ri(x,y),i.set(x)}if(2&ni[t]){let t=0,s=0;for(let n=0;n<e;++n){const e=r[n].sub(a);t+=e.sqrLength(),i.transformInPlace(e),s+=e.dotProduct(h[n].sub(u))}if(0===t)0===s?i.setIdentity():i.setZero();else{const e=s/t;i.scale(e,e)}}else s(!(4&ni[t]));const l=a.clone();i.transformInPlace(l),i.xd=u.x-l.x,i.yd=u.y-l.y,o&&(o.set(i),o.invertThis(),o.isZero()&&(o.xd=a.x,o.yd=a.y))}export{wt as $,Pt as A,Y as B,g as C,pt as D,_ as E,It as F,us as G,w as H,Ts as I,Cs as J,r as K,ms as L,Ws as M,Ct as N,As as O,Js as P,ns as Q,rs as R,Ot as S,ei as T,Mt as U,Es as V,Et as W,qs as X,Bt as Y,U as Z,W as _,Lt as a,gt as a0,Zs as a1,L as a2,B as a3,hs as a4,D as a5,A as a6,O as a7,G as a8,Q as a9,ws as aA,Hs as aB,F as aC,Jt as aD,zs as aa,Qt as ab,Ls as ac,Qs as ad,Os as ae,Bs as af,ft as ag,dt as ah,E as ai,I as aj,js as ak,Ys as al,$ as am,ks as an,xt as ao,Wt as ap,Ft as aq,it as ar,H as as,Vs as at,Dt as au,Ps as av,Ms as aw,Zt as ax,k as ay,Ss as az,Tt as b,S as c,Gt as d,X as e,qt as f,os as g,ps as h,Rs as i,as as j,St as k,Fs as l,zt as m,Rt as n,ls as o,Vt as p,Ut as q,yt as r,J as s,kt as t,K as u,At as v,V as w,j as x,q as y,Z as z};