@arcgis/core 4.31.0-next.20240713 → 4.31.0-next.20240716

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 (43) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/956cfaab50468b1de65a.js +1 -0
  3. package/assets/esri/core/workers/chunks/{d60b9ab97c56b1a3f0c2.js → dfee89697ffa6921fbee.js} +9 -9
  4. package/assets/esri/themes/base/widgets/_Tooltip.scss +9 -3
  5. package/assets/esri/themes/dark/main.css +1 -1
  6. package/assets/esri/themes/light/main.css +1 -1
  7. package/assets/esri/themes/light/view.css +1 -1
  8. package/chunks/Clipper-D_zmIu84.js +1 -1
  9. package/chunks/Densificator-DB2izaQs.js +1 -1
  10. package/chunks/OperatorDifference.js +5 -0
  11. package/chunks/OperatorRelationsBase-C_y-7Mq7.js +5 -0
  12. package/chunks/OperatorSimplify.js +1 -1
  13. package/chunks/Polyline.js +1 -1
  14. package/chunks/RelationalOperations-wfnLPxD3.js +5 -0
  15. package/geometry/operators/gx/operatorCut.js +1 -1
  16. package/geometry/operators/gx/operatorDensify.js +1 -1
  17. package/geometry/operators/gx/operatorIntersection.js +1 -1
  18. package/geometry/operators/gx/operatorUnion.js +1 -1
  19. package/geometry/operators/operatorContains.js +5 -0
  20. package/geometry/operators/operatorCrosses.js +5 -0
  21. package/geometry/operators/operatorDifference.js +5 -0
  22. package/geometry/operators/operatorDisjoint.js +1 -1
  23. package/geometry/operators/operatorEquals.js +5 -0
  24. package/geometry/operators/operatorIntersects.js +5 -0
  25. package/geometry/operators/operatorOverlaps.js +5 -0
  26. package/geometry/operators/operatorRelate.js +5 -0
  27. package/geometry/operators/operatorTouches.js +5 -0
  28. package/geometry/operators/operatorUnion.js +1 -1
  29. package/geometry/operators/operatorWithin.js +5 -0
  30. package/interfaces.d.ts +14 -1
  31. package/layers/support/SubtypeSublayer.js +1 -1
  32. package/package.json +2 -2
  33. package/support/revision.js +1 -1
  34. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  35. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexTextureCoordinates.glsl.js +5 -5
  36. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +1 -1
  37. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +1 -1
  38. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +5 -5
  39. package/views/3d/webgl-engine/materials/DefaultTechniqueConfiguration.js +1 -1
  40. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  41. package/views/interactive/tooltip/Tooltip.js +1 -1
  42. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  43. package/assets/esri/core/workers/chunks/543f9db420c99d429637.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- function t(t,e){try{if(!t)throw new Error(e)}catch(s){throw s}}class e extends Error{constructor(t,e){super(),this.m_AdditionalMessage=e,this.m_ErrorType=t}what(){return t(0),""}additionalMessage(){return t(0),""}code(){return t(0),1}}class s extends e{constructor(t){super(2,t),this.name="corrupted geometry exception"}}class i extends e{constructor(t){super(3,t),this.name="empty gemetry exception"}}class n extends e{constructor(t){super(8,t),this.name="non simple geometry exception"}}var r;!function(t){t[t.enumUnknown=0]="enumUnknown",t[t.enumPoint=513]="enumPoint",t[t.enumLine=5122]="enumLine",t[t.enumBezier=5123]="enumBezier",t[t.enumEllipticArc=5124]="enumEllipticArc",t[t.enumEnvelope=3077]="enumEnvelope",t[t.enumMultiPoint=8710]="enumMultiPoint",t[t.enumPolyline=25607]="enumPolyline",t[t.enumPolygon=27656]="enumPolygon",t[t.enumMultipatch=40969]="enumMultipatch",t[t.enumGeometryCollection=3594]="enumGeometryCollection",t[t.enumRationalBezier2=5134]="enumRationalBezier2",t[t.enumBezier2=5135]="enumBezier2"}(r||(r={}));const o=[0,0,1,1,1,2,0,1,2,3,-1,-1,-1,-1,1,1];function a(t){return o[15&t]}function h(t){return!!(512&t)}function m(t){return!!(1024&t)}function u(t){return!!(4096&t)}function l(t){return!!(8192&t)}function c(t){return!!(16384&t)}function d(t){return!!(32768&t)}function _(t){const e=t.getGeometryType();return l(e)?t.getPointCount():t.isEmpty()?0:e===r.enumEnvelope?4:e===r.enumPoint?1:u(e)?2:void E("missing type")}function g(t){const e=t.getGeometryType();if(c(e))return t.hasNonLinearSegments();if(e===r.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)if(g(e.getGeometry(t)))return!0;return!1}return!!u(e)&&e!==r.enumLine}function p(t){throw new s(t)}function f(t){const e=new Error(t);throw e.name="invalid argument exception",e}function x(){f("Geometry type is not supported for 3D topological operations.")}function y(t){throw new e(12,t)}function v(t){throw new i(t)}function P(t){const s=new e(14,t);throw s.name="not implemented",s}function b(t){const e=new Error(t);throw e.name="out of range exception",e}function E(t){const s=new e(13,t);throw s.name="internal error",s}function C(t){const e=new Error(t);throw e.name="logic error exception",e}function D(t){throw new n(t)}function S(){P("operation does not support curves yet")}function w(t){g(t)&&S()}function A(t){d(t.getGeometryType())&&P("Unsupported geometry type.")}function T(t){t===r.enumGeometryCollection&&f("Geometry_collection instances are not supported in this operation")}function I(t){f(`bad wkid: ${t}`)}function N(t,e){t||f(e)}class M{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new M(this.tolerance+t,this.resolution)}scale(t){return new M(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function q(t,e){return{first:t,second:e}}const R=Math.PI,F=2*Math.PI,Y=.5*Math.PI,X=new ArrayBuffer(8),L=new Float64Array(X),z=new BigUint64Array(X),V=0x0fffffffffffffn,B=0x7ff0000000000000n;function k(t){return L[0]=t,z[0]}function G(t){return k(t)&V}function W(t){return Number((k(t)&B)>>52n)}function Z(t){if(0n===t)return-1n;if(1n===t||-1n===t)return 0n;t<0n&&(t=-t);let e=0n,s=512n,i=1n<<e+s;for(;t>=i;)e+=s,s<<=1n,i<<=s;let n=e;s>>=1n;let r=n+s;for(;s>0n;)t<1n<<r||(n=r),s>>=1n,r=n+s;return n}function H(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function O(t,e,s){return t===e||Math.abs(t-e)<=s||Number.isNaN(t)&&Number.isNaN(e)}function j(t,e){return t<e?-1:t>e?1:0}function U(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;{const s=Number.isNaN(t),i=Number.isNaN(e);return s<i?-1:s>i?1:0}}function Q(){return 2147483647}function K(){return 32767}function $(){return 2147483647}const J=$(),tt=BigInt(J),et=2166136261,st=16777619;function it(t){let e=et,s=t;return e=(e^255&s)*st,s>>=8,e=(e^255&s)*st,s>>=8,e=(e^255&s)*st,s>>=8,e=(e^255&s)*st,e&J}const nt=14695981039346656037n,rt=1099511628211n;function ot(t){let e=nt,s=t;return e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,e&tt}function at(t){return 1103515245*t+12345&2147483647}function ht(t,e){return e+2654435769+(t<<6)+(t>>2)&J}function mt(t,e){return ht(t,dt(e))}function ut(t){return ht(3735928559,t)}function lt(t,e){return ht(t,ut(e))}function ct(t){return it(t)}function dt(t){return Number(ot(t))}function _t(t){return at(t)}const gt=100;function pt(){return Number.EPSILON*gt}function ft(){return.38196601125010515}function xt(){return 1.4142135623730951}function yt(){return Number.EPSILON}function vt(t,e,s){return t===e||t===s}function Pt(t,e,s){return t>=e?t<=s?t:s:e}function bt(t,e){return t>=e?e:t<-e?-e:t}function Et(){return R}function Ct(){return F}function Dt(){return Y}const St=3*Dt();function wt(){return St}const At=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0],Tt=[2,1,1,1,3,1,2,3,2,4,1,1,2],It=[1,1,1,0,2,1,1,1,0,0,0,0,0],Nt=[1,1,1,2,0,0,0,0,2,2,4,2,2],Mt=[4,8,4,8,1],qt=24;function Rt(){return new Array(24)}let Ft=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return It[t]}static getPersistence(t){return Nt[t]}static getPersistenceSize(t){return Mt[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return Tt[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return At[t]}static isDefaultValue(t,e){return H(At[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(13),this.m_indexToSemantics=new Int32Array(13),this.m_pointAttributeOffsets=new Int32Array(13),this.m_defaultPointAttributes=new Array(qt),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,n=13;for(;s<n;s++)e&i&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),i<<=1;let r=0;for(s=0,n=this.getAttributeCount();s<n;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=r;for(let t=0;t<i;t++)this.m_defaultPointAttributes[r]=n,r++}}};class Yt{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(){t(0)}add(t){const e=this.sum+t;let s;if(Math.abs(this.sum)>=Math.abs(t)){const i=this.sum-e+t;s=this.compensation+i}else{const i=t-e+this.sum;s=this.compensation+i}this.sum=e,this.compensation=s}sub(t){this.add(-t)}addProduct(t,e){const s=[0],i=Ne(t,e,s);this.add(i),this.add(s[0])}addKahan(e){t(0)}subKahan(e){t(0)}mulKahan(e){t(0)}mul(t){const e=new Yt(0);e.addProduct(this.sum,t),e.addProduct(this.compensation,t),this.assign(e)}getResult(){return this.sum+this.compensation}pe(t){return this.add(t),this}me(t){return this.add(-t),this}meKahan(t){return this.subKahan(t),this}peKahan(t){return this.addKahan(t),this}}const Xt=0x00000000ffffffffn,Lt=0x0000ffffn,zt=0x000000ffn,Vt=0x0fn,Bt=0xffff0000n,kt=0xff00n,Gt=0xf0n,Wt=[5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1],Zt=[-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3];function Ht(t){let e=0;return t&Lt||(e+=16,t>>=16n),t&zt||(e+=8,t>>=8n),t&Vt||(e+=4,t>>=4n),e+Wt[Number(BigInt.asUintN(4,t))]}function Ot(t){let e=0;return t&Bt&&(e+=16,t>>=16n),t&kt&&(e+=8,t>>=8n),t&Gt&&(e+=4,t>>=4n),e+Zt[Number(BigInt.asUintN(4,t))]+1}function jt(t){let e=0;return t&Xt||(e=32,t>>=32n),e+Ht(BigInt.asUintN(32,t))}function Ut(t){let e=0;return 0xffffffff00000000n&t&&(e=32,t>>=32n),e+Ot(t)}class Qt{constructor(t,e){if(void 0!==t){if(t instanceof Qt)return this.vmin=t.vmin,void(this.vmax=t.vmax);this.vmin=t,this.vmax=e,this.normalize()}else this.setEmpty()}static construct(t,e){return new Qt(t,e)}static constructEmpty(){return new Qt}setCoords(t,e){this.vmin=t,this.vmax=e,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,e){return H(this.vmin,t)&&H(this.vmax,e)}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(void 0!==e?Math.abs(this.vmin-t.vmin)<=e&&Math.abs(this.vmax-t.vmax)<=e: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 t(0),!0}setInfinite(){this.vmin=Number.NEGATIVE_INFINITY,this.vmax=Number.POSITIVE_INFINITY}move(e){t(0)}contains(t){return t.vmin>=this.vmin&&t.vmax<=this.vmax}containsCoordinate(t){return t>=this.vmin&&t<=this.vmax}containsRightExclusive(e){return t(0),!0}containsExclusiveCoordinate(t){return t>this.vmin&&t<this.vmax}containsExclusive(e){return t(0),!0}isIntersecting(e){return t(0),!0}mergeCoordinate(t){if(this.isEmpty())return this.vmin=t,void(this.vmax=t);this.mergeNeCoordinate(t)}merge(t){if(t.isEmpty())return;const e=t.vmin,s=t.vmax;this.mergeCoordinate(e),this.mergeCoordinate(s)}mergeNe(t){const e=t.vmin,s=t.vmax;this.mergeNeCoordinate(e),this.mergeNeCoordinate(s)}mergeNeCoordinate(t){t<this.vmin?this.vmin=t:t>this.vmax&&(this.vmax=t)}intersect(e){t(0)}inflate(e){t(0)}normalize(){this.vmin<=this.vmax||(this.vmin>this.vmax?this.vmax=je(this.vmin,this.vmin=this.vmax):this.setEmpty())}isValid(){return t(0),!0}snapClip(t){return Pt(t,this.vmin,this.vmax)}calculateToleranceFromEnvelope(){return t(0),0}static unit(){return Kt}normalizeNoNAN(){this.vmin>this.vmax&&(this.vmax=je(this.vmin,this.vmin=this.vmax))}setCoordsNoNAN(t,e){this.vmin=t,this.vmax=e,this.normalizeNoNAN()}clone(){return new Qt(this.vmin,this.vmax)}}const Kt=new Qt(0,1);class $t{static ulp(t){return Math.abs(t)*ee()}static getNAN(){return new $t(Number.NaN)}constructor(t,e){this.m_value=t??0,this.m_eps=e??0}[Symbol.toPrimitive](t){return this}clone(){return new $t(this.m_value,this.m_eps)}scaleError(t){this.m_eps*=t}setError(t){this.m_eps=t}set(t,e){return this.m_value=t,this.m_eps=e??0,this}setWithEps(t,e){return void 0===e&&(e=1),this.m_value=t,this.m_eps=$t.ulp(t)*e,this}setE(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}precise(){return new $t(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 e=this.m_value+t.m_value,s=this.m_eps+t.m_eps+$t.ulp(e);return this.m_value=e,this.m_eps=s,this}addThis(t){const e=this.m_value+t,s=this.m_eps+$t.ulp(e);return this.m_value=e,this.m_eps=s,this}subE(t){return this.clone().subThisE(t)}sub(t){return this.clone().subThis(t)}subThisE(t){const e=this.m_value-t.m_value,s=this.m_eps+t.m_eps+$t.ulp(e);return this.m_value=e,this.m_eps=s,this}subThis(t){const e=this.m_value-t,s=this.m_eps+$t.ulp(e);return this.m_value=e,this.m_eps=s,this}setAddE(t,e){return this.m_value=t.m_value+e.m_value,this.m_eps=t.m_eps+e.m_eps+$t.ulp(this.m_value),this}setAdd(t,e){return this.m_value=t+e,this.m_eps=$t.ulp(this.m_value),this}setAddEN(t,e){return this.m_value=t.m_value+e,this.m_eps=t.m_eps+$t.ulp(this.m_value),this}setAddNE(t,e){return this.m_value=t+e.m_value,this.m_eps=e.m_eps+$t.ulp(this.m_value),this}setSubE(t,e){return this.m_value=t.m_value-e.m_value,this.m_eps=t.m_eps+e.m_eps+$t.ulp(this.m_value),this}setSub(t,e){return this.m_value=t-e,this.m_eps=$t.ulp(this.m_value),this}setSubEN(t,e){return this.m_value=t.m_value-e,this.m_eps=t.m_eps+$t.ulp(this.m_value),this}setSubNE(t,e){return this.m_value=t-e.m_value,this.m_eps=e.m_eps+$t.ulp(this.m_value),this}mulThisE(t){const e=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+$t.ulp(e),this.m_value=e,this}mulThis(t){const e=this.m_value*t;return this.m_eps=this.m_eps*Math.abs(t)+$t.ulp(e),this.m_value=e,this}mul(t){return this.clone().mulThis(t)}mulE(t){return this.clone().mulThisE(t)}setMulE(t,e){const s=t.m_value*e.m_value;return this.m_eps=t.m_eps*Math.abs(e.m_value)+e.m_eps*Math.abs(t.m_value)+t.m_eps*e.m_eps+$t.ulp(s),this.m_value=s,this}setMul(t,e){return this.m_value=t*e,this.m_eps=$t.ulp(this.m_value),this}setMulEN(t,e){return this.setE(t),this.mulThis(e)}setMulNE(t,e){return this.setE(e),this.mulThis(t)}mulThisByPower2(t){return this.m_value*=t,this.m_eps*=Math.abs(t),this}static st_mulByPower2(t,e){return new $t(t.m_value,t.m_eps).mulThisByPower2(e)}divE(t){return this.clone().divThisE(t)}divThisE(t){const e=Math.abs(t.m_value),s=this.m_value/t.m_value;let i=(this.m_eps+Math.abs(s)*t.m_eps)/e;if(t.m_eps>.01*e){const s=t.m_eps/e;i*=1+(1+s)*s}return this.m_value=s,this.m_eps=i+$t.ulp(s),this}divThis(t){const e=Math.abs(t);return this.m_value/=t,this.m_eps=this.m_eps/e+$t.ulp(this.m_value),this}setDivE(t,e){return this.setE(t),this.divThisE(e)}setDiv(t,e){return this.m_value=t/e,this.m_eps=$t.ulp(this.m_value),this}setDivEN(t,e){return this.setE(t),this.divThis(e)}setDivNE(t,e){return this.set(t),this.divThisE(e)}divThisByPower2(t){return this.m_value/=t,this.m_eps/=Math.abs(t),this}invThis(){return this.setE(ne.clone().divThisE(this)),this}sqrt(){return this.clone().sqrtThis()}sqrtThis(){let t,e;return this.m_value>=0?(t=Math.sqrt(this.m_value),e=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),e+=$t.ulp(t)):this.m_value<-this.m_eps?(t=Number.NaN,e=Number.NaN):(t=0,e=Math.sqrt(this.m_eps)),this.m_value=t,this.m_eps=e,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+$t.ulp(t),this.m_value=t,this}cubeThis(){return t(0),this}setSin(e){return t(0),this}setCos(e){return t(0),this}static st_cosAndSin(t,e,s){const i=Math.sin(t.m_value),n=Math.cos(t.m_value);s.m_value=i,e.m_value=n;const r=Math.abs(i),o=Math.abs(n),a=Math.abs(t.value());s.m_eps=(Math.abs(n)+.5*r*t.m_eps)*t.m_eps+$t.ulp(r+a),e.m_eps=(Math.abs(i)+.5*o*t.m_eps)*t.m_eps+$t.ulp(o+a)}setLog(e){return t(0),this}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}static atan2(e,s){return t(0),new $t}acosThis(){return t(0),this}asinThis(){return t(0),this}isInInterval(t){return Qt.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,e){return Math.abs(this.m_value-t.m_value)<=e||this.eq(t)}tolNE(t,e){return!this.tolEQ(t,e)}tolGT(t,e){return this.m_value-t.m_value>e&&this.gt(t)}tolLT(t,e){return t.m_value-this.m_value>e&&this.lt(t)}tolGE(t,e){return!this.tolLT(t,e)}tolLE(t,e){return!this.tolGT(t,e)}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(se)}setEuler(){this.set(2.718281828459045,ee())}cubicRootThis(){return t(0),this}powerThis(e){return t(0),this}setPower(t,e){return this.setE(t),this.powerThis(e)}static size(){return 1}}function Jt(t,e){const s=G(t),i=G(e),n=53-jt(s),r=53-jt(i);return(n>=0?n:0)+(r>=0?r:0)<=52}function te(t,e){const s=t-e;return t-s===e&&e+s===t}function ee(){return yt()}$t.dimensions=1;const se=new $t(R,.5*ee()),ie=new $t(0,0),ne=new $t(1,0),re=new $t(4,0);function oe(t,e,s){return t.addE(e.subE(t).mulE(s))}function ae(t,e,s){return e.subE(e.subE(t).mulE(ne.subE(s)))}function he(t){return Math.round(t)}function me(t,e,s,i,n){n[0]=e[0]+(s[0]-e[0])*i,n[1]=e[1]+(s[1]-e[1])*i,3===t&&(n[2]=e[2]+(s[2]-e[2])*i)}function ue(t,e,s,i,n){n[0]=s[0]-(s[0]-e[0])*(1-i),n[1]=s[1]-(s[1]-e[1])*(1-i),3===t&&(n[2]=s[2]-(s[2]-e[2])*(1-i))}function le(t,e,s,i,n){i<=.5?me(t,e,s,i,n):ue(t,e,s,i,n)}function ce(t,e,s,i){i.setE(t.addE(e.subE(t).mulE(s)))}function de(t,e,s,i){i.setE(e.subE(e.mulE(t)).mulE(ne.subE(s)))}function _e(t,e,s,i,n){n[0]=e[0].addE(s[0].subE(e[0]).mulE(i)),n[1]=e[1].addE(s[1].subE(e[1]).mulE(i))}function ge(t,e,s,i,n){n[0]=s[0].subE(s[0].subE(e[0]).mulE(ne.subE(i))),n[1]=s[1].subE(s[1].subE(e[1]).mulE(ne.subE(i)))}function pe(t,e,s){let i;return i=s<=.5?t+(e-t)*s:e-(e-t)*(1-s),i}function fe(t,e,s){return t+(e-t)*s}function xe(t,e,s){return e-(e-t)*(1-s)}function ye(t,e,s,i){s<=.5?(i.x=t.x+(e.x-t.x)*s,i.y=t.y+(e.y-t.y)*s):(i.x=e.x-(e.x-t.x)*(1-s),i.y=e.y-(e.y-t.y)*(1-s))}function ve(t){return t*t}function Pe(t){return t*t*t}function be(t){return 1/Math.sqrt(t)}function Ee(t){return t<0?-1:t>0?1:0}const Ce=[0],De=[0];function Se(t,e,s){return Fe(Ne(t,e,Ce),s,Ce[0],De)}const we=[0],Ae=[0],Te=[0],Ie=[0];function Ne(t,e,s){const i=t*e;return Me(t,we,Ae),Me(e,Te,Ie),s[0]=Ae[0]*Ie[0]-(i-we[0]*Te[0]-Ae[0]*Te[0]-we[0]*Ie[0]),i}function Me(t,e,s){const i=134217729*t;e[0]=i-(i-t),s[0]=t-e[0]}const qe=[0],Re=[0];function Fe(t,e,s,i){const n=Ye(t,e,qe),r=Ye(n,s,Re);return Ye(r,qe[0]+Re[0],i)}function Ye(t,e,s){const i=t+e;return Math.abs(t)>Math.abs(e)?s[0]=t-i+e:s[0]=e-i+t,i}function Xe(t,e){return t%e}function Le(t){const e=1-t;if(0===e)return 1;let s;if(e<=.01){const t=e,i=Math.log(t);s=1+t*(.4431471805599453-.25*i+t*(.05680519270997949-.09375*i+t*(.02183137044373718-.05859375*i+t*(.011544521417308362-.042724609375*i+t*(.00714200031339596-.0336456298828125*i+t*(.004854743337164948-.027757644653320312*i+t*(.003514687963781376-.023627042770385742*i)))))))}else{if(t<.016){const e=t,s=.25,i=.046875,n=.01953125,r=.01068115234375,o=.0067291259765625,a=.004626274108886719,h=.0033752918243408203,m=.0025710230693221092;return Dt()*(1-e*(s+e*(i+e*(n+e*(r+e*(o+e*(a+e*(h+e*m))))))))}s=Be(0,e,1)-t*ke(0,e,1)/3}return Pt(s,1,Dt())}function ze(e,s,i){if(t(s>=0&&s<=1),0===s)return e;let n=1,r=e;if(r<0&&(r=-r,n=-1),1===s){const t=Math.round(r/Et()),e=r-t*Et();return n*(2*t+Math.sin(e))}const o=Dt(),a=Math.floor(r/o);1&a?r=(a+1)*o-r:r-=a*o;const h=Math.sin(r),m=Number.isNaN(i)?Le(s):i;let u;if(1===h)u=m+Math.sqrt(1-s)*(r-o);else{const t=r*r;if(.01424*Math.pow(t,4)<=2*yt()){u=r*(1+t*s*(-1/6+t*((4-3*s)/120-(16+(45*s-60)*s)/5040*t)))}else if(s<=.01){const t=Math.sin(2*r),e=Math.sin(4*r),i=Math.sin(6*r),n=Math.sin(8*r),o=Math.sin(10*r);u=r+s*((2*-r+t)/8+s*((-3*r+2*t-.25*e)/64+s*((-20*r+15*t-3*e+i/3)/1024+s*(5*(-140*r+112*t-28*e+16/3*i-.5*n)/65536+7*s*((-63*r+52.5*t-15*e+3.75*i-.625*n+.05*o)/65536+s*(-693*r+594*t-185.625*e+1.375*i-12.375*n+1.8*o-.125*Math.sin(12*r))/1048576)))))}else{const t=h*h,e=Math.cos(r),i=e*e,n=Ge(h,e,s);u=h*(Be(i,n,1)-s*t*ke(i,n,1)/3)}}if(1&a){u=m*(a+1)-u}else u+=m*a;return n*u}function Ve(t,e,s){if(0===t)return 0;let i=1,n=t;t<0&&(n=-n,i=-1);const r=Number.isNaN(s)?Le(e):s,o=Math.floor(n/r);1&o?n=(o+1)*r-n:n-=o*r;let a=n<=0?0:n>=r?Dt():We(n,e,r);return 1&o?a=Dt()*(o+1)-a:a+=Dt()*o,i*a}function Be(e,s,i){t((0!==e?1:0)+(0!==s?1:0)+1>1);let n=e,r=s,o=i;for(;;){const t=Math.sqrt(n*r)+Math.sqrt(r*o)+Math.sqrt(o*n);n=.25*(n+t),r=.25*(r+t),o=.25*(o+t);const e=(n+r+o)/3,s=(e-n)/e,i=(e-r)/e,a=(e-o)/e;if(Math.abs(s)<=.0024&&Math.abs(i)<=.0024&&Math.abs(a)<=.0024){const t=s*i-a*a,n=s*i*a;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(e)}}}function ke(e,s,i){t(0!==e||0!==s);let n=e,r=s,o=i;const a=new Yt(0);let h=1;for(;;){const t=.2*(n+r+3*o),e=(t-n)/t,s=(t-r)/t,i=(t-o)/t;if(Math.abs(e)<=.0015&&Math.abs(s)<=.0015&&Math.abs(i)<=.0015){const n=e*s,r=i*i,o=n-r,m=n-6*r,u=m+o+o,l=9/22,c=3/26,d=m*(.25*l*m-3/14-1.5*c*i*u),_=i*(1/6*u+i*(-l*o+i*c*n));return 3*a.getResult()+h*(1+d+_)/(t*Math.sqrt(t))}const m=Math.sqrt(n),u=Math.sqrt(r),l=Math.sqrt(o),c=m*(u+l)+u*l;a.add(h/(l*(o+c))),h*=.25,n=.25*(n+c),r=.25*(r+c),o=.25*(o+c)}}function Ge(t,e,s){return t<.999?1-s*ve(t):1-s+s*ve(e)}function We(t,e,s){if(0===e)return t;if(1===e)return Math.asin(t);let i=0,n=!0;if(t<.2){const s=t*t,r=t*(1+s*e*(1/6+s*((13*e-4)/120+(16-284*e+493*e*e)/5040*s))),o=Math.abs(e*(4944*e-64-31224*e*e+37369*e*e*e)/362880*Math.pow(t,9));if(o<Math.abs(r)*yt())return r;i=r,n=o>.1*r}if(n){const n=1-e,r=1-t/s,o=Math.sqrt(r*r+n*n),a=Math.atan2(n,t+yt());i=Dt()+Math.sqrt(o)*(a-Dt())}let r=0;for(let o=0;o<7;o++){r=ze(i,e,s);const n=Ge(Math.sin(i),Math.cos(i),e);if(i-=(r-t)/Math.sqrt(n),o>0&&Math.abs(r-t)<=4*yt()*t)break}return i}function Ze(t,e,s,i,n){return 0===t?0===i?e:1===i?s:n:1===t?0===i?e:1===i?s:pe(e,s,i):(2===t&&P("angular interpolation"),void P(""))}function He(t,e,s,i,n,r,o,a){if(0===t)for(let h=0;h<r;++h)i[h]=0===o?e[h]:1===o?s[h]:a;else if(1===t)if(0===o)Oe(i,e,n,0,r);else if(1===o)Oe(i,s,n,0,r);else for(let h=0;h<r;++h)i[h+n]=pe(e[h],s[h],o);else if(2===t)if(0===o)Oe(i,e,n,0,r);else if(1===o)Oe(i,s,n,0,r);else{let t=0;for(let a=0,h=n;a<r;++a,++h)i[h]=pe(e[a],s[a],o),t+=i[h]*i[h];if(t>0){t=Math.sqrt(t);for(let e=n;e<n+r;++e)i[e]/=t}else{for(let t=n;t<n+r;++t)i[t]=0;i[n]=1}}else P("")}function Oe(t,e,s,i,n){if(0===n)return;let r=0,o=s,a=i;for(;r++<n;)t[o++]=e[a++]}function je(t,e){return t}function Ue(t){t.sort(((t,e)=>t<e?-1:t>e?1:0))}function Qe(t,e){const s=t.slice(0,e);Ue(s),Oe(t,s,0,0,e)}function Ke(t,e,s){const i=t.slice(0,e);i.sort(s),Oe(t,i,0,0,e)}function $e(t,e){return t<e?-1:t>e?1:0}function Je(t,e,s,i){return t<s?-1:t>s?1:e<i?-1:e>i?1:0}function ts(t,e){if(t.length<2)return t.length;let s=0;for(let i=1;i<t.length;++i)e(t[i],t[s])||(s++,t[i]=je(t[s],t[s]=t[i]));return 1+s}function es(t,e){t[e]=t.at(-1),t.pop()}function ss(t){return{[Symbol.dispose](){this.bForget||t()},bForget:!1}}function is(t,e){return Array.from({length:e},(()=>new t))}function ns(t,e){const s=t.slice(0,e);for(let i=0;i<e;++i)s[i]=s[i].clone();return s}function rs(t){return Array.from({length:t},(()=>null))}function os(t,e){return Array.from({length:e},(()=>t()))}function as(t,e){return Array.from({length:t},(()=>e))}function hs(t){return{v:t}}class ms{constructor(){this.m_rn=hs(0n),this.m_rd=hs(1n),this.m_bNaN=!1,this.m_bNormalized=!1,this.m_power=0,this.m_sign=0}static constructAssign(t,e){const s=t.clone();return void 0!==e&&s.limitPrecisionThis(e),s}static constructDouble(t){return(new ms).setDouble(t)}static constructInt64(t){return(new ms).setInt64(t)}static constructRational(t,e){return(new ms).setRational(t,e)}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 ms).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(t){if(this.setZero(),0===t)return this;if(Number.isInteger(t)&&Math.abs(t)<$())return this.setInt32(t);const e=k(t),s=(e&ms.s_em)>>52n,i=!!(e&ms.s_sm),n=e&ms.s_fm;if(s===ms.s_emax)return n?(this.m_rn.v=this.m_rd.v=0n,this.m_bNaN=!0,this):(this.m_rn.v=i?-1n:1n,this.m_rd.v=0n,this);0n===s&&P("denormalized numbers not yet implemented");const r=s-1023n,o=r>=0n?r:0n,a=r<0n?-r:0n;return this.m_rn.v=(1n<<52n|n)<<o,this.m_rd.v=1n<<52n+a,this.m_sign=i?-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,e){return 0n===t?0n===e?this.setNAN():this.setZero():0n===e?t>0n?this.setPositiveInf():this.setNegativeInf():(this.m_sign=(t>0n?1:-1)*(e>0n?1:-1),this.m_rn.v=t>0n?t:-t,this.m_rd.v=e>0n?e:-e,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(e){return t(0),this}fmsThis(t,e){return this.subThis(t.mul(e))}fmaThis(e,s){return t(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(ms.constructDouble(t))}thisMulInt64(e){return t(0),this}thisMulInt32(e){return t(0),this}divThis(t){return this.mulThis(t.clone().invertThis())}divDoubleThis(t){return this.divThis(ms.constructDouble(t))}addDoubleThis(t){return this.addThis(ms.constructDouble(t))}subDoubleThis(t){return this.subThis(ms.constructDouble(t))}mul(t){return this.clone().mulThis(t)}mulBigIntThis(t){return this.mulThis(ms.constructInt64(t))}mulDouble(t){return this.clone().mulThis(ms.constructDouble(t))}div(t){return this.clone().divThis(t)}divDouble(t){return this.clone().divDoubleThis(t)}add(t){return this.clone().addThis(t)}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(ms.constructDouble(t))}sub(t){return this.clone().subThis(t)}subDouble(t){return this.clone().subThis(ms.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,e=0xffffffffn;for(;0n===(this.m_rn.v&e)&&e<=this.m_rn.v;)e<<=32n,t+=32;e&=this.m_rn.v,e>>=BigInt(t),t+=Ht(BigInt.asUintN(32,e))-1;let s=0;for(e=0xffffffffn;0n===(this.m_rd.v&e)&&e<=this.m_rd.v;)e<<=32n,s+=32;return e&=this.m_rd.v,e>>=BigInt(s),s+=Ht(BigInt.asUintN(32,e))-1,this.m_rn.v>>=BigInt(t),this.m_rd.v>>=BigInt(s),this.m_power+=t-s,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=je(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 e=Number(Z(this.m_rn.v));if(e>t){const s=e-t;this.m_rn.v>>=BigInt(e-t),this.m_power+=s}if(e=Number(Z(this.m_rd.v)),e>t){const s=e-t;this.m_rd.v>>=BigInt(e-t),this.m_power-=s}return this}hiBitIndex(){return Math.max(Number(Z(this.m_rn.v)),Number(Z(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(e,s){if(e.m_sign<0n&&b("MP_value: sqrt(-1)"),e.isZero())return e.clone();let i=52,n=2220446049250313e-31;for(;i<s;)2*i<=s?(n*=n,i*=2):(n*=2220446049250313e-31,i+=52);i+=52;const r=Z(e.m_rn.v),o=Z(e.m_rd.v);let a,h=e.m_power+Number(r-o);const m=new ms;Math.abs(h)>200?(1&Math.abs(h)&&(h+=1),a=ms.constructAssign(e,53).ldexpThis(-h).value(),m.setThis(e).ldexpThis(-h),t(Number.isFinite(a))):(m.setThis(e),a=m.value(),t(Number.isFinite(a)),h=0),a=Math.sqrt(a);const u=ms.constructDouble(a),l=ms.constructDouble(n);l.mulThis(u).ldexpThis(1);const c=n*a*2,d=u.clone(),_=new ms;let g;for(let t=0;t<10;++t){d.mulThis(u),_.setThis(m).subThis(d).absThis();let t=_.value();if(g=1,t<.9)for(;t>c;)t*=t,++g;else g=4;if(_.lte(l))break;for(let e=0;e<g;e++)d.setThis(u).divThis(m).invertThis().addThis(u).ldexpThis(-1).limitPrecisionThis(i),u.setThis(d)}return u.ldexpThis(h/2)}static cubicRoot(t,e){if(t.isZero())return t.clone();let s=52,i=2220446049250313e-31;for(;s<e;)2*s<=e?(i*=i,s*=2):(i*=2220446049250313e-31,s+=52);s+=52;const n=Math.pow(Math.abs(t.value()),1/3),r=ms.constructDouble(n),o=r.clone();o.sqrThis().mulDoubleThis(3).mulDoubleThis(i),o.limitPrecisionThis(32),t.LZ()&&r.negateThis();for(let a=0;a<10;++a){const e=r.clone();e.sqrThis().mulThis(r);const i=e.clone();if(i.subThis(t),i.absThis().limitPrecisionThis(32),i.lte(o))break;i.setThis(t),i.ldexpThis(1),i.addThis(e);const n=e.clone();n.ldexpThis(1),n.addThis(t),i.divThis(n),r.mulThis(i),r.limitPrecisionThis(s)}return r}isInTheRangeOfDouble(){return t(0),!1}sign(){return this.m_sign}cosAndSin(e,s){t(0)}static nan(){return t(0),new ms}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,e=this.m_rn.v<<(this.m_power>=0?BigInt(this.m_power):0n);let s=this.m_rd.v<<(this.m_power<0?BigInt(-this.m_power):0n);const i=e/s;let n=Number(i);if(BigInt(n)!==i)return t?-n:n;let r=e-i*s;if(r){let t=Z(s)-1023n;t>0n&&(s>>=t,r<<=52n,r>>=t);let e=Number(r);Number.isFinite(e)||(r>>=52n,e=Number(r),t=0n),t>0n&&(e/=Math.pow(2,52));n+=e/Number(s)}return t?-n:n}signVal(){return 1===this.m_sign?1n:-1===this.m_sign?-1n:0n}opPlusMinus(t,e){const s=Math.min(this.m_power,t.m_power);let i,n;this.m_power>s?(i=BigInt(this.m_power-s),n=0n):(i=0n,n=BigInt(t.m_power-s));const r=this.signVal()*this.m_rn.v*t.m_rd.v<<i,o=t.signVal()*t.m_rn.v*this.m_rd.v<<n;return this.m_rn.v=e?r+o:r-o,this.m_rd.v*=t.m_rd.v,this.m_power=s,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}}ms.s_sm=0x8000000000000000n,ms.s_em=0x7ff0000000000000n,ms.s_fm=0x000fffffffffffffn,ms.s_emax=0x7ffn;const us=ms.constructInt32(1),ls=ms.constructInt32(0);function cs(t,e){return Ut(t^e)}function ds(t,e){let s=W(t);const i=W(e);if(s===i){return s-=53-cs(G(t),G(e)),s}return s>i?s:i}class _s{static construct(t,e){return new _s(t,e)}constructor(t,e){void 0!==t?(this.x=t,this.y=e):this.x=this.y=Number.NaN}clone(){return new _s(this.x,this.y)}assign(t){this.setCoordsPoint2D(t)}setCoords(t,e){return this.x=t,this.y=e,this}setCoordsPoint2D(t){this.x=t.x,this.y=t.y}isEqualPoint2D(t,e){return void 0!==e?Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e:this.x===t.x&&this.y===t.y}isEqual(t,e,s){return void 0!==s?Math.abs(this.x-t)<=s&&Math.abs(this.y-e)<=s:this.x===t&&this.y===e}equalsPoint2D(t,e){return this.isEqualPoint2D(t,e)}setSub(t,e){this.x=t.x-e.x,this.y=t.y-e.y}addThis(t){return this.x+=t.x,this.y+=t.y,this}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}absoluteOther(t){}absolute(){return t(0),this}setNegate(){this.x=-this.x,this.y=-this.y}setNegateOther(t){this.x=-t.x,this.y=-t.y}interpolateThis(t,e){}interpolate(e,s,i){t(0)}scaleAddThis(t,e){this.x=this.x*t+e.x,this.y=this.y*t+e.y}scaleAddOther(e,s,i){t(0)}scaleOther(e,s){t(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(e){t(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}offset(e,s){return t(0),0}side(e,s){return t(0),0}static sqrDistance(t,e){const s=t.x-e.x,i=t.y-e.y;return s*s+i*i}static sqrDistanceCoords(e,s,i,n){return t(0),0}static distance(t,e){return Math.sqrt(_s.sqrDistance(t,e))}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(e){return t(0),0}rotateDirect(t,e){const s=this.x*t-this.y*e,i=this.x*e+this.y*t;this.x=s,this.y=i}rotateReverse(t,e){const s=this.x*t+this.y*e,i=-this.x*e+this.y*t;this.x=s,this.y=i}leftPerpendicularThis(){const t=this.x;this.x=-this.y,this.y=t}leftPerpendicularOther(t){const e=t.x;this.x=-t.y,this.y=e}rightPerpendicularThis(){const t=this.x;this.x=this.y,this.y=-t}rightPerpendicularOther(t){const e=t.x;this.x=t.y,this.y=-e}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 _s(this.x+t.x,this.y+t.y)}sub(t){return new _s(this.x-t.x,this.y-t.y)}negateThis(){return this.x=-this.x,this.y=-this.y,this}negate(){return new _s(-this.x,-this.y)}mul(t){return new _s(this.x*t,this.y*t)}mulThis(t){return this.x*=t,this.y*=t,this}divide(t){return new _s(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 _s(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),e=Math.abs(this.y),s=t-e;return s>=0?t:s<=0?e: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:f("norm")}}getQuarter(){return _s.getQuarterCoords(this.x,this.y)}static getQuarterCoords(t,e){return t>0?e>=0?1:4:e>0?2:0===t?4:3}static compareVectors(t,e){const s=t.getQuarter(),i=e.getQuarter();return i===s?_s.orientationRobustImpl(_s.construct(0,0),e,t,!0):s<i?-1:1}static compareVectorsOrigin(t,e,s){const i=e.sub(t),n=s.sub(t),r=i.getQuarter(),o=n.getQuarter();return o===r?_s.orientationRobustImpl(t,s,e,!0):r<o?-1:1}static orientationRobust(t,e,s){return _s.orientationRobustImpl(t,e,s,!1)}static orientationNonRobust(t,e,s){const i=e.sub(t).crossProduct(s.sub(t));return i<0?-1:i>0?1:0}static orientationRobustImpl(t,e,s,i){if(e.isEqualPoint2D(t)||s.isEqualPoint2D(t)||e.isEqualPoint2D(s))return 0;const n=e.x-t.x,r=e.y-t.y,o=s.x-t.x,a=s.y-t.y;if(!i){const t=_s.getQuarterCoords(n,r)-1,e=_s.getQuarterCoords(o,a)-1,s=_s.d[t][e];if(0!==s)return s}const h=(Math.abs(n)+Math.abs(r)+Math.abs(o)+Math.abs(a))*(Math.abs(e.x)+Math.abs(e.y)+Math.abs(s.x)+Math.abs(s.y))*8*ee(),m=n*a-r*o;if(Math.abs(m)>h){return m<0?-1:1}if(te(e.x,t.x)&&te(s.y,t.y)&&te(e.y,t.y)&&te(s.x,t.x)&&Jt(n,a)&&Jt(r,o)){const t=n*a,e=r*o;if(te(t,e)){const s=t-e;return s<0?-1:s>0?1:0}}return _s.orientationRobustMp(t,e,s)}static orientationRobustMp(t,e,s){const i=ms.constructDouble(e.x),n=ms.constructDouble(s.x);{const e=ms.constructDouble(t.x);i.subThis(e),n.subThis(e)}const r=ms.constructDouble(s.y),o=ms.constructDouble(e.y);{const e=ms.constructDouble(t.y);r.subThis(e),o.subThis(e)}return i.mulThis(r),o.mulThis(n),i.subThis(o),i.LZ()?-1:i.GZ()?1:0}static inCircleRobust(e,s,i,n){return t(0),0}static calculateCircleCenterFromThreePoints(e,s,i){return t(0),new _s(0,0)}static calculateAngle(t,e){return Math.atan2(t.crossProduct(e),t.dotProduct(e))}static isBisectorRobust(e,s,i){return t(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,e){const s=_s.c_compare_zorder_xx[t.x<0?1:0]|_s.c_compare_zorder_yy[t.y<0?1:0],i=_s.c_compare_zorder_xx[e.x<0?1:0]|_s.c_compare_zorder_yy[e.y<0?1:0];if(s===i){let s=0,i=0;for(let n=0;n<2;++n){const r=ds(t[n],e[n]);r>s&&(s=r,i=n)}return t[i]<e[i]}return s<i}static lerp(e,s,i){return t(0),new _s(0,0)}static getClosestCoordinate(t,e,s,i=!1){const n=_s.getNAN();n.setSub(e,t);const r=n.sqrLength();if(0===r)return.5;if(e.isEqualPoint2D(s))return 1;const o=_s.getNAN();o.setSub(s,t);let a=o.dotProduct(n)/r;return i||(a<0?a=0:a>1&&(a=1)),a}static intersectLinesAtOnePoint(e,s,i,n){return t(0),new _s(0,0)}toString(){return`[${this.x},${this.y}]`}}_s.dimensions=2,_s.d=[[0,1,0,-1],[-1,0,1,0],[0,-1,0,1],[1,0,-1,0]],_s.c_compare_zorder_xx=[2,0],_s.c_compare_zorder_yy=[1,0];class gs{static construct(t,e,s){return new gs(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new gs(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}normalize(e){t(0)}normalizeThis(){t(0)}getUnitVector(){return t(0),new gs(0,0,0)}sqrLength(){return t(0),0}length(){return t(0),0}static sqrDistance(e,s){return t(0),0}static sqrDistanceCoords(e,s,i,n,r,o){return t(0),0}static distance(e,s){return t(0),0}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&O(this.z,t.z,e)}static compareByLength(e,s,i,n){return t(0),0}isEqualCoords(e,s,i,n){return t(0),this.x===e&&this.y===s&&this.z===i}isEqualsTols(e,s,i){return t(0),!1}isEqualCoordsTols(e,s,i,n,r){return t(0),!1}static st_isEqual(e,s,i,n){return t(0),!1}equals(e,s){return t(0),!1}equalsTols(e,s,i){return t(0),!1}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVectorThis(e,s){return t(0),this}crossProductVector(e){return t(0),new gs(0,0,0)}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}setNAN(){return t(0),this}isNAN(){return t(0),!1}static getNAN(){return gs.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return t(0),!1}isZero(){return t(0),!1}sqrDistanceFromCenterToSpheroidSurface(e,s){return t(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(e,s,i,n=!1){return t(0),0}compare(e){return t(0),0}compareXYZ(e){return t(0),0}static size(){return gs.dimensions}static lerp(e,s,i){return t(0),{}}static slerp(e,s,i){return t(0),{}}static compareVectors(e,s){return t(0),0}static selectRightHandedBasisFromNormal(e,s,i){t(0)}createAPerpendicular(){return t(0),{}}calculateAngle(e){return t(0),0}}gs.dimensions=3;class ps{static construct(t,e,s,i){return new ps(t,e,s,i)}constructor(t,e,s,i){"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax)}static constructEmpty(){return new ps(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new ps(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return t(0),0}sqrDiagonal(){return t(0),0}diagonal(){return t(0),0}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return _s.construct(this.getCenterX(),this.getCenterY())}queryCenter(e){t(0)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){t(0)}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return t(0),!1}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(e,s){return t(0),new ps(0,0,0,0)}inflate(e){t(0)}getInflated(e){return t(0),new ps(0,0,0,0)}zoom(e,s){t(0)}scale(e){t(0)}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(e){void 0!==e.xmin?(this.xmin=e.xmin,this.xmax=e.xmax,this.ymin=e.ymin,this.ymax=e.ymax):void 0!==e.x?(this.xmin=e.x,this.xmax=e.x,this.ymin=e.y,this.ymax=e.y):void 0!==e.pt1?(this.xmin=e.pt1.x,this.ymin=e.pt1.y,this.xmax=e.pt2.x,this.ymax=e.pt2.y,this.normalize()):void 0!==e.env2D?(this.xmin=e.env2D.xmin,this.xmax=e.env2D.xmax,this.ymin=e.env2D.ymin,this.ymax=e.env2D.ymax,this.normalize()):void 0!==e.pt?(this.xmin=e.pt.x,this.xmax=e.pt.x,this.ymin=e.pt.y,this.ymax=e.pt.y):void 0!==e.center?(this.xmin=e.center.x-.5*e.width,this.xmax=this.xmin+e.width,this.ymin=e.center.y-.5*e.height,this.ymax=this.ymin+e.height,this.normalize()):t(0),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0!==e){this.setCoords(t[0]);for(let s=1;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);return}this.setCoords(t[s]),s++}}else this.setEmpty()}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return t(0),!1}getLowerLeft(){return new _s(this.xmin,this.ymin)}getLowerRight(){return new _s(this.xmax,this.ymin)}getUpperLeft(){return new _s(this.xmin,this.ymax)}getUpperRight(){return new _s(this.xmax,this.ymax)}move(e,s){t(0)}centerAtCoords(e,s){t(0)}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new _s(this.xmin,this.ymin);case 1:return new _s(this.xmin,this.ymax);case 2:return new _s(this.xmax,this.ymax);default:return new _s(this.xmax,this.ymin)}}queryCorners(e){t(0)}queryCornersReversed(e){t(0)}reaspect(e,s){t(0)}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return t(0),0}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,r=e.y-t.y;if(Math.abs(n)>Math.abs(r)?s&ps.XMASK?(s&ps.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&ps.XMASK?(i&ps.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&ps.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):(i&ps.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s&ps.YMASK?(s&ps.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):i&ps.YMASK?(i&ps.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s?(s&ps.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&ps.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(e){return t(0),0}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(e,s,i){return t(0),0}sqrDistance(e,s){if(void 0!==s)return t(0),0;if(this.isEmpty()||e.isNAN())return Number.NaN;let i,n=0,r=0;return i=this.xmin-e.x,i>n&&(n=i),i=this.ymin-e.y,i>r&&(r=i),i=e.x-this.xmax,i>n&&(n=i),i=e.y-this.ymax,i>r&&(r=i),n*n+r*r}sqrMaxMinDistanceEnvelope(e){return t(0),0}sqrMaxDistanceEnvelope(e){return t(0),0}sqrMaxMinDistance(e){return t(0),0}sqrMinDistance(e){return t(0),0}sqrMaxDistance(e){return t(0),0}snapToBoundary(e){return t(0),!1}snapClip(t){const e=Pt(t.x,this.xmin,this.xmax),s=Pt(t.y,this.ymin,this.ymax);return _s.construct(e,s)}boundaryDistance(e){return t(0),0}envelopeSide(e){return t(0),0}querySide(t,e){switch(t){case 0:e.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:e.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:e.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:e.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:f("query_side")}return e}isPointOnBoundary(e,s){return t(0),!1}calculateToleranceFromEnvelope(){if(this.isEmpty())return pt();return(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*pt()}notEquals(e){return t(0),!1}toString(){return t(0),""}}ps.XLESSXMIN=1,ps.YLESSYMIN=4,ps.XMASK=3,ps.YMASK=12;var fs=Ft;function xs(){return new Array(13)}class ys{static getInstance(){return ys.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new fs(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new fs(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new fs(t);return this.m_map.set(t,s),s}}ys.s_thisInstance=new ys;let vs=class e{static getVertexDescription(t){return ys.getInstance().FindOrAdd(t)}static getVertexDescriptionFromArray(t,s){let i=1;for(let e=0;e<s;++e)i|=1<<t[e];return e.getVertexDescription(i)}static getVertexDescriptionFromAttributes(t,s,i){let n=1;return t&&(n|=2),s&&(n|=4),i&&(n|=8),e.getVertexDescription(n)}static getMergedVertexDescription(t,s){if(!t||!s)return s||t;const i=t.getSemanticsBitArray()|s.getSemanticsBitArray();return(i&t.getSemanticsBitArray())===i?t:(i&s.getSemanticsBitArray())===i?s:e.getVertexDescription(i)}static getMergedVertexDescriptionSemantics(t,s){const i=t.getSemanticsBitArray()|1<<s;return(i&t.getSemanticsBitArray())===i?t:e.getVertexDescription(i)}static removeSemanticsFromVertexDescription(s,i){const n=(s.getSemanticsBitArray()|1<<i)-(1<<i);return n===s.getSemanticsBitArray()?(t(0),s):e.getVertexDescription(n)}static getDefaultDescription2D(){return ys.getInstance().GetVD2D()}static getDefaultDescription3D(){return ys.getInstance().GetVD3D()}static getDescriptionHash(t){return t.getSemanticsBitArray()}static mapAttributes(t,e,s){s.fill(-1);for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}};var Ps=Ft;function bs(t,e){return e*(t.getTotalComponentCount()-2)}class Es{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new ps(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new ps(t.env2D);else if(t.move)this.m_envelope2D=new ps(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new ps(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=ps.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}copyTo(e,s){const i=s,n=e.getTotalComponentCount()-2;if(i.m_description!==e&&(i.releaseAttributes_(),i.m_description=e,n&&(i.m_data.m_attributes=new Array(2*n))),n){t(this.m_attributes&&i.m_data.m_attributes);const e=2*n;Oe(i.m_data.m_attributes,this.m_attributes,0,0,e)}i.m_data.m_envelope2D=new ps(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new ps(this.m_envelope2D),e.releaseAttributes();t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}queryInterval(t,e,s,i){if(this.isEmpty())return void i.setEmpty();0===e&&(0===s?this.m_envelope2D.queryIntervalX(i):1===s?this.m_envelope2D.queryIntervalY(i):b(""));const n=Ps.getComponentCount(e);(s<0||s>=n)&&b("");const r=t.getAttributeIndex(e);if(r>=0)return i.vmin=this.m_attributes[bs(t,0)+t.getPointAttributeOffset(r)-2+s],void(i.vmax=this.m_attributes[bs(t,1)+t.getPointAttributeOffset(r)-2+s]);{const t=Ps.getDefaultValue(e);return void i.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new Qt;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}class Cs{constructor(t){if(this.m_description=vs.getDefaultDescription2D(),void 0===t)this.m_data=new Es;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Es,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Es({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Es({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_description=t.copy.getDescription(),this.m_data=new Es,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=t.move.m_data;else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this}assignCopy(t){return this}transformAttribute(e,s,i,n,r){t(0)}vertexCount(){return t(0),0}setAttributeBasic(e,s,i){t(0)}hasNonLinearSegments(){return t(0),!0}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=vs.getMergedVertexDescription(e,t);this.assignVertexDescription(s)}asEnvelope2D(){return new ps(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterX(){return t(0),0}getCenterY(){return t(0),0}getCenterXX(){return t(0),new _s(0,0)}getCenter(e){t(0)}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof ps)this.m_data.m_envelope2D=new ps(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=Qt.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){t(0)}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const e=this.m_description.getSemantics(s),i=Ps.getComponentCount(e);for(let s=0;s<i;s++){const i=t.queryInterval(e,s),n=this.queryInterval(e,s);n.intersect(i),this.setIntervalEnvelope(e,s,n)}}return!0}intersectCommonAttributes(e){return t(0),!1}move(e,s){t(0)}centerAt(e,s){t(0)}centerAtPoint(t){}reaspect(e,s){t(0)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(e,s){return t(0),!1}contains(e){return t(0),!1}containsPoint(e){return t(0),!1}containsEnvelope(e){return t(0),!1}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=new Qt(s);if(i.normalize(),0===t){if(i.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=i.vmin,this.m_data.m_envelope2D.xmax=i.vmax):1===e?(this.m_data.m_envelope2D.ymin=i.vmin,this.m_data.m_envelope2D.ymax=i.vmax):b("")}else this.setAttributeAsDblImpl(0,t,e,i.vmin),this.setAttributeAsDblImpl(1,t,e,i.vmax)}setInterval(t,e,s,i){this.setIntervalEnvelope(t,e,new Qt(s,i))}queryInterval(t,e){const s=new Qt;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(e){e instanceof ps?e.setCoords({env2D:this.m_data.m_envelope2D}):t(0)}applyTransformation(e){t(0)}createInstance(){return t(0),this}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){t(0)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return t(0),0}calculateLength3D(e){return t(0),0}equals(e){return t(0),!1}getBoundary(){return t(0),this}clone(){return new Cs({copy:this})}swap(e){t(0)}queryCoordinates(e){t(0)}queryCornerByVal(t,e){(t<0||t>3)&&b(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=Ps.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(e,s){t(0)}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=vs.removeSemanticsFromVertexDescription(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){t(0)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(e,s){t(0)}getImpl(){return this}setFromPoint(e,s,i){t(0)}assignVertexDescriptionImpl(t){const e=xs();vs.mapAttributes(t,this.m_description,e);let s=null;const i=t.getTotalComponentCount()-2,n=this.m_description?this.m_description.getTotalComponentCount()-2:0;i>0&&(s=new Array(2*i),s.fill(Number.NaN));for(let r=1;r<t.getAttributeCount();r++){const o=e[r];if(-1!==o){const e=t.getPointAttributeOffset(r)-2,a=Ps.getComponentCount(t.getSemantics(r)),h=this.m_description.getPointAttributeOffset(o)-2;Oe(s,this.m_data.m_attributes,e,h,a),Oe(s,this.m_data.m_attributes,i+e,n+h,a)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(e,s,i){return t(0),0}setAttributeAsDblImpl(t,e,s,i){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=i:0===s?this.m_data.m_envelope2D.xmax=i:b(""):1===s?this.m_data.m_envelope2D.ymin=i:0===s?this.m_data.m_envelope2D.xmin=i:b(""));const n=Ps.getComponentCount(e);(s<0||s>=n)&&b(""),this.addAttribute(e);const r=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[bs(this.m_description,t)+this.m_description.getPointAttributeOffset(r)-2+s]=i}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}}Cs.type=r.enumEnvelope;const Ds=-559038737;var Ss=Ft;function ws(t,e,s){switch(t){case 0:return new Ys(e,s);case 1:return new Xs(e,s);case 2:return new Fs(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new Rs(e,s);default:f("")}}function As(t,e){const s=Ss.getComponentCount(t);return ws(Ss.getPersistence(t),e*s,Ss.getDefaultValue(t))}function Ts(t,e){const s=Ss.getComponentCount(t);return ws(Ss.getPersistence(t),e*s)}function Is(t,e){return new Fs(t,e)}function Ns(t,e){return new Rs(t,e)}function Ms(t,e){return new Xs(t,e)}class qs{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>qs.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(e){return t(e>=0&&e<this.m_size),this.m_a[e]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,s){(e<0||s<0||s+e>this.size())&&f(),this.m_a.fill(t,e,e+s)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}equals(t,e,s,i){if(this.getPersistence()!==t.getPersistence())return!1;return Ls(this,t,e,s,i)}insertRange(t,e,s,i){s&&this.checkResize(i+s),this.m_a.copyWithin(t+s,t,i||this.m_size),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.subarray(t,t+e)}insertRangeFromStream(e,s,i,n,r,o,a){t(this.getPersistence()===s.getPersistence());const h=s;n&&this.checkResize(a+n),this.m_a.copyWithin(e+n,e,a||this.m_size),this.m_a.set(h.readRange(i,n),e)}writeRange(e,s,i,n,r,o){t(this.getPersistence()===i.getPersistence());const a=i;if((e<0||s<0||n<0)&&f(),a.size()<n+s&&f(),0===s)return;this.size()<s+e&&this.resize(s+e);const h=a.m_a.subarray(n,n+s);zs(this.m_a,e,s,h)}insertAttributes(t,e,s,i){const n=Ss.getComponentCount(s);this.m_a.copyWithin(t+n,t,i||this.m_size);for(let r=0;r<n;r++)this.m_a[t+r]=e.getAttributeAsDbl(s,r)}insertAttributesFromPoints(e,s,i,n,r){t(0)}eraseRange(t,e,s){this.m_size<t+e&&f(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!=0)&&f(),this.m_a.subarray(t,t+e).reverse(),s>1)for(let i=t,n=t+e;i<n;i+=s){let t=i,e=i+s-1;for(;t<e;){const s=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=s,t++,e--}}}rotate(e,s,i){t(0)}adjacentDifference(e,s,i){return t(0),0}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,qs.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}qs.s_constructMin=2,qs.s_resizeMin=30;class Rs extends qs{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new Rs({ctor:Int8Array,copy:this})}restrictedClone(t){return new Rs({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class Fs extends qs{getPersistence(){return 2}clone(){return new Fs({ctor:Int32Array,copy:this})}restrictedClone(t){return new Fs({ctor:Int32Array,copy:this,maxSize:t})}write(e,s){t(s<=$()),super.write(e,s)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class Ys extends qs{getPersistence(){return 0}clone(){return new Ys({ctor:Float32Array,copy:this})}restrictedClone(t){return new Ys({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class Xs extends qs{getPersistence(){return 1}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&f();const i=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(i,s,i)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new _s(e,s)}queryPoint2D(t,e){e.x=this.m_a[t],e.y=this.m_a[t+1]}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){if(s+2>=this.m_a.length)throw RangeError("AttributeStreamOfDbl::insert");this.m_a.copyWithin(t+2,t,s||this.m_size),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){if(this.m_a.copyWithin(t+2*i,t,r||this.m_size),n)for(let o=s,a=t,h=0;h<i;++h,++o){const t=e[o];this.m_a[a++]=t.x,this.m_a[a++]=t.y}else for(let o=s+i-1,a=t,h=0;h<i;++h,--o){const t=e[o];this.m_a[a++]=t.x,this.m_a[a++]=t.y}}queryRange(t,e,s,i,n){if((t<0||e<0)&&f(),!i&&(n<=0||e%n!=0)&&f(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const r=this.m_a.subarray(t,t+e);s.set(r)}writeRangeFromArray(t,e,s,i,n){if((t<0||e<0)&&f(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let r=s;e<s.length&&(r=s.subarray(0,e)),this.m_a.set(r,t)}clone(){return new Xs({ctor:Float64Array,copy:this})}restrictedClone(t){return new Xs({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}function Ls(t,e,s,i,n){if(t.getPersistence()!==e.getPersistence())return!1;const r=t.getPersistence()<=1,o=t.size(),a=e.size();if(i>o||i>a)return!1;if(n)for(let h=s;h<i;h++){let s=t.read(h)-e.read(h);if(s<0&&(s=-s),s>n)return!1}else for(let h=s;h<i;h++){const s=t.read(h),i=e.read(h);if(s!==i){if(r&&Number.isNaN(s)&&Number.isNaN(i))continue;return!1}}return!0}function zs(t,e,s,i,n,r){if((e<0||s<0)&&f(),0===s)return;if(1===s)return void(t[e]=i[0]);let o=i;s<i.length&&(o=i.subarray(0,s)),t.set(o,e)}class Vs{static constructEmpty(){return new Vs(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}getEnvelope2D(){return new ps(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new Qt(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=je(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=je(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=je(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}}class Bs{constructor(){this.xyStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.xyStream}set(t,e){t>0?this.streams[t-1]=e:this.xyStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.xyStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.xyStream,t.xyStream]=[t.xyStream,this.xyStream]}empty(){return null===this.xyStream&&null===this.streams}}class ks{constructor(t){this.m_buffer=null,this.m_firstFree=-1,this.m_last=0,this.m_size=0,this.m_capacity=0,this.m_bufferSize=0,this.m_stride=0,this.m_stride=t,this.m_realStride=t,this.m_blockSize=Math.trunc(ks.st_realBlockSize/this.m_realStride)}dbgdelete_(t){return this.m_buffer[t>>ks.st_blockPower][1+(t&ks.st_blockMask)]=ks.st_deadVertex,!0}deleteElement(t){(t>>ks.st_blockPower)*this.m_blockSize*this.m_realStride+(t&ks.st_blockMask)<this.m_last*this.m_realStride?(this.m_buffer[t>>ks.st_blockPower][t&ks.st_blockMask]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.m_size--}getField(t,e){return this.m_buffer[t>>ks.st_blockPower][(t&ks.st_blockMask)+e]}setField(t,e,s){this.m_buffer[t>>ks.st_blockPower][(t&ks.st_blockMask)+e]=s}getStride(){return this.m_stride}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.m_capacity){const t=0!==this.m_capacity?Math.trunc(1.5*(this.m_capacity+1)):1;this.grow(t)}t=(this.m_last/this.m_blockSize<<ks.st_blockPower)+this.m_last%this.m_blockSize*this.m_realStride,this.m_last++}else this.m_firstFree=this.m_buffer[t>>ks.st_blockPower][t&ks.st_blockMask];this.m_size++;const e=this.m_buffer[t>>ks.st_blockPower],s=t&ks.st_blockMask;for(let i=0;i<this.m_stride;i++)e[s+i]=-1;return t}elementToIndex(t){return(t>>ks.st_blockPower)*this.m_blockSize+(t&ks.st_blockMask)/this.m_realStride}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.m_size=0,t&&(this.m_buffer=null,this.m_capacity=0)}size(){return this.m_size}setCapacity(t){t>this.m_capacity&&this.grow(t)}capacity(){return this.m_capacity}swap(t,e){const s=this.m_buffer[t>>ks.st_blockPower],i=this.m_buffer[e>>ks.st_blockPower],n=t&ks.st_blockMask,r=e&ks.st_blockMask;for(let o=0;o<this.m_stride;o++){const t=s[n+o];s[n+o]=i[r+o],i[r+o]=t}}swapField(t,e,s){const i=this.m_buffer[t>>ks.st_blockPower],n=this.m_buffer[e>>ks.st_blockPower],r=(t&ks.st_blockMask)+s,o=(e&ks.st_blockMask)+s,a=i[r];i[r]=n[o],n[o]=a}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}ensureBufferBlocksCapacity(t){if(this.m_buffer.length<t){const e=new Array(t);for(let t=0;t<this.m_buffer.length;t++)e[t]=this.m_buffer[t];this.m_buffer=e}}grow(t){null===this.m_buffer&&(this.m_bufferSize=0,this.m_buffer=new Array(8));const e=Math.trunc((t+this.m_blockSize-1)/this.m_blockSize);if(this.ensureBufferBlocksCapacity(e),1===e){this.m_capacity>0&&this.m_capacity;let e=0;const s=t*this.m_realStride;for(;s>ks.st_sizes[e];)e++;const i=new Int32Array(ks.st_sizes[e]);1===this.m_bufferSize?(i.set(this.m_buffer[0]),this.m_buffer[0]=i):(this.m_buffer[this.m_bufferSize]=i,this.m_bufferSize++),this.m_capacity=Math.trunc(i.length/this.m_realStride)}else{if(1===this.m_bufferSize&&this.m_buffer[0].length<ks.st_realBlockSize){const t=new Int32Array(ks.st_realBlockSize);t.set(this.m_buffer[0]),this.m_buffer[0]=t,this.m_capacity=this.m_blockSize}for(;this.m_bufferSize<e;)this.m_buffer[this.m_bufferSize++]=new Int32Array(ks.st_realBlockSize),this.m_capacity+=this.m_blockSize}}}ks.st_realBlockSize=16384,ks.st_blockMask=16383,ks.st_blockPower=14,ks.st_sizes=[16,32,64,128,256,512,1024,2048,4096,8192,16384],ks.st_deadVertex=-2125315821;class Gs{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class Ws{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new ks(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||(t(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,i,n,r=-1){if(-1===r&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),r=this.m_defaultTreap),this.getRoot_(r)===Ws.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,r),this.addToList_(-1,t,r),t}let o,a,h,m,u;if(n?(o=e!==Ws.st_nullNode()?this.m_comparator.compare(this,s,e):-1,a=t!==Ws.st_nullNode()?this.m_comparator.compare(this,s,t):1):(o=-1,a=1),i&&(0===o||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===o?e:t;return this.setDuplicateElement_(i,r),-1}u=e!==Ws.st_nullNode()&&t!==Ws.st_nullNode()?this.m_random>_t(this.m_random)>>1:e!==Ws.st_nullNode(),u?(m=o,h=e):(m=a,h=t);let l=-1,c=-1,d=!0;for(;;){if(m<0){const t=this.getLeft(h);if(t===Ws.st_nullNode()){c=h,l=this.newNode_(s),this.setLeft_(h,l),this.setParent_(l,h);break}h=t}else{const t=this.getRight(h);if(t===Ws.st_nullNode()){c=this.getNext(h),l=this.newNode_(s),this.setRight_(h,l),this.setParent_(l,h);break}h=t}d&&(m*=-1,d=!1)}return this.bubbleUp_(l),this.getParent(l)===Ws.st_nullNode()&&this.setRoot_(l,r),this.addToList_(c,l,r),l}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==Ws.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==Ws.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===Ws.st_nullNode()&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==Ws.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),Ws.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==Ws.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==Ws.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=Ws.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return ks.isValidElement(t)}dbgCheck_(e){t(0)}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const i=this.getPriority_(t);for(;e!==Ws.st_nullNode()||s!==Ws.st_nullNode();){const n=e!==Ws.st_nullNode()?this.getPriority_(e):Q(),r=s!==Ws.st_nullNode()?this.getPriority_(s):Q();if(i<=Math.min(n,r))return;n<=r?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==Ws.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==Ws.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==Ws.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==Ws.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==Ws.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==Ws.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=_t(this.m_random),this.m_random&Q()>>1}maxPriority(){return t(0),0}getMaxDepthHelper_(t){return t===Ws.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===Ws.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===Ws.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===Ws.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===Ws.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),i=this.getRight(t),n=this.getParent(t),r=t;if(-1!==s&&-1!==i){let o;this.m_random=_t(this.m_random),o=this.m_random>Q()>>1?this.getNext(t):this.getPrev(t);const a=this.getParent(o)===t;this.m_treapData.swapField(t,o,0),this.m_treapData.swapField(t,o,1),this.m_treapData.swapField(t,o,2),-1!==n?this.getLeft(n)===t?this.setLeft_(n,o):this.setRight_(n,o):this.setRoot_(o,e),a?(s===o?(this.setLeft_(o,t),this.setParent_(i,o)):i===o&&(this.setRight_(o,t),this.setParent_(s,o)),this.setParent_(t,o),n=o):(this.setParent_(s,o),this.setParent_(i,o),n=this.getParent(t),r=o),s=this.getLeft(t),i=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==i&&this.setParent_(i,t)}const o=-1!==s?s:i;-1===n?this.setRoot_(o,e):this.getLeft(n)===r?this.setLeft_(n,o):this.setRight_(n,o),-1!==o&&this.setParent_(o,n),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,Q());let s=Ws.st_nullNode(),i=Ws.st_nullNode();const n=this.getRoot_(e),r=n===t;if(r&&(s=this.getLeft(n),i=this.getRight(n),s===Ws.st_nullNode()&&i===Ws.st_nullNode()))return this.removeFromList_(n,e),this.freeNode_(n,e),void this.setRoot_(Ws.st_nullNode(),e);this.bubbleDown_(t);const o=this.getParent(t);o!==Ws.st_nullNode()&&(this.getLeft(o)===t?this.setLeft_(o,Ws.st_nullNode()):this.setRight_(o,Ws.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),r&&this.setRoot_(s===Ws.st_nullNode()||this.getParent(s)!==Ws.st_nullNode()?i:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===Ws.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===Ws.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class Zs{constructor(t){this.m_lists=new ks(6),this.m_listOfLists=Zs.st_nullNode(),void 0===t?(this.m_listNodes=new ks(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new ks(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){t(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(e,s){t(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(e,s){t(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==Zs.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==Zs.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==Zs.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(e){t(0)}getListData(e){return t(0),0}getList(e){return t(0),0}setListData(e,s){t(0)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;e!==Zs.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==Zs.st_nullNode()&&this.setNext_(n,i);if(e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===Zs.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==Zs.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==Zs.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==Zs.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let e=this.getFirstList();-1!==e;)e=this.deleteList(e)}isEmpty(e){return t(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class Hs{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new Fs(0),this.m_bucketedIndices=new Fs(0)}static sortEx(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);(new Hs).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let m=e;m<s;m++){const e=i.getValue(t.read(m));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let r=e;r<s;r++){const s=t.read(r),n=i.getValue(s),o=this.getBucket(n);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(r-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let r=e;r<s;r++){const s=this.m_bucketedIndices.read(r-e),n=i.getValue(s),o=this.getBucket(n),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let m=0,u=this.m_buckets.size();m<u;m++){const s=h;h=this.m_buckets.read(m),h>s&&i.userSort(e+s,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(Hs.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}Hs.c_maxBuckets=65536;class Os extends Gs{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?js.isLeft_(e)&&js.isRight_(i)?-1:js.isLeft_(i)&&js.isRight_(e)?1:0:1}}class js{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new ks(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new ks(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new Ws,this.m_secondaryTreaps.setComparator(new Os(this)),this.m_secondaryLists=new Zs}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){t(0)}addInterval(e){t(0)}addIntervalCoords(e,s){t(0)}endConstruction(){t(0)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||y(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new Fs(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||y("");const e=this.m_intervalHandles[t];let s;-1===e&&f("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(i),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),i),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),i),s=this.m_secondaryTreaps.size(i),0===s&&(this.m_secondaryTreaps.deleteTreap(i),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let r=this.getPptr_(n),o=this.getLptr_(n),a=this.getRptr_(n);for(;!(s>0||n===this.m_root||-1!==o&&-1!==a);)n===this.getLptr_(r)?-1!==o?(this.setLptr_(r,o),this.setPptr_(o,r),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==a?(this.setLptr_(r,a),this.setPptr_(a,r),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(r,-1),this.setPptr_(n,-1)):-1!==o?(this.setRptr_(r,o),this.setPptr_(o,r),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==a?(this.setRptr_(r,a),this.setPptr_(a,r),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(r,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=r,i=this.getSecondaryFromTertiary_(n),s=-1!==i?this.m_secondaryTreaps.size(i):0,o=this.getLptr_(n),a=this.getRptr_(n),r=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(e,s){return t(0),{}}getIterator(){return new Us(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){t(0)}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let u=Number.NaN,l=Number.NaN,c=!0;const d=this.getMin_(m),_=this.getMax_(m);let g=-1;for(;c;){h=o+(a-o>>1),g=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(g);if(_<e){if(-1!==i)if(g===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getLptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l>e){const t=this.createTertiaryNode_(g);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}a=h;continue}if(d>e){if(-1!==i)if(g===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getRptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l<e){const t=this.createTertiaryNode_(g);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||g!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(g):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&g===this.getDiscriminantIndex1_(i)||(e<u?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(l<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||y(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;if(t<e){s=t+(e-t>>1)+2}else s=-(t+2);return s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new Hs).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,((t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&js.isLeft_(t)&&js.isRight_(e)?-1:1}))}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return js.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return js.isLeft_(t)?e.xmin:e.xmax}checkValidation_(){return t(0),!1}checkValidationHelper_(e){return t(0),0}}class Us{constructor(t,e,s){this.m_query=Qt.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return t(0),!1}resetIterator(t,e){if("number"==typeof t){const s=new Qt;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||y(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&js.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&js.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&js.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class Qs{constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new Fs(0),this.m_sortedEndIndicesBlue=new Fs(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new Zs,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||y(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new ps(e))}endConstruction(){this.m_bAddRedRed||y(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||y(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||y(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||y(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||y(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getEnvelope(e){return t(0),{}}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new js(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){return t(0),!1}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new js(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new js(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new js(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=Qt.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=Qt.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&(this.m_queuedIndicesRed.length=this.m_envelopesRed.length,this.m_queuedIndicesRed.fill(-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=Qt.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&(this.m_queuedIndicesBlue.length=this.m_envelopesBlue.length,this.m_queuedIndicesBlue.fill(-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return t(0),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new Hs).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,((t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1}))}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}function Ks(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function $s(t,e){const s=ps.constructEmpty();t.queryLooseEnvelope(s);const i=ps.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function Js(t,e,s){const i=ps.constructEmpty();i.setFromPoints(t,e);return ri(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function ti(t,e,s){return ri(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function ei(t,e,s){return ri(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function si(t,e,s){return ei(t,e.queryInterval(1,0),s)}function ii(t,e,s){const i=ps.constructEmpty();return e.queryEnvelope(i),ti(t,i,s)}function ni(t,e,s){return ri(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ri(t,e,s,i,n){const r=new M(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01);return r.total()<s?new M(s,0):r}function oi(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function ai(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function hi(t){return t>=3}function mi(t,e){const s=[0];return t.getImpl().getIsSimple(e,s)>=3}function ui(t){return t>=4}function li(t,e){return t===r.enumPolygon?hi(e):e>=1}function ci(t,e,s){const i=ps.constructEmpty(),n=ps.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=ps.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=e.querySegmentIterator(),h=ps.constructEmpty(),m=ps.constructEmpty(),u=new Qs;u.setTolerance(s);let l=!1;for(u.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(h),h.isIntersecting(r)&&(l=!0,u.addRedEnvelope(o.getStartPointIndex(),h))}if(u.endRedConstruction(),!l)return null;let c=!1;for(u.startBlueConstruction();a.nextPath();)for(;a.hasNextSegment();){a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(r)&&(c=!0,u.addBlueEnvelope(a.getStartPointIndex(),m))}return u.endBlueConstruction(),c?u:null}function di(t,e,s,i,n){t.getGeometryType(),e.getGeometryType();const r=ps.constructEmpty(),o=ps.constructEmpty();t.queryLooseEnvelope(r),e.queryLooseEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=ps.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new Qs;h.setTolerance(s);let m=!1;h.startRedConstruction();for(let l=0,c=t.getPathCount();l<c;l++)t.queryLoosePathEnvelope(l,r),r.isIntersecting(a)&&(m=!0,h.addRedEnvelope(l,r));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let l=0,c=e.getPathCount();l<c;l++)e.queryLoosePathEnvelope(l,o),o.isIntersecting(a)&&(u=!0,h.addBlueEnvelope(l,o));return h.endBlueConstruction(),u?h:null}function _i(t,e,s){const i=ps.constructEmpty(),n=ps.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=ps.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=new Qs;a.setTolerance(s);let h=!1;for(a.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(i),i.isIntersecting(r)&&(h=!0,a.addRedEnvelope(o.getStartPointIndex(),i))}if(a.endRedConstruction(),!h)return null;let m=!1;a.startBlueConstruction();for(let u=0,l=e.getPointCount();u<l;u++){const t=e.getXY(u);r.contains(t)&&(m=!0,a.addBlueEnvelope(u,ps.construct(t.x,t.y,t.x,t.y)))}return a.endBlueConstruction(),m?a:null}function gi(t,e,s){const i=ps.constructEmpty(),n=ps.constructEmpty();t.queryEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=ps.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=new Qs;o.setTolerance(s);let a=!1;o.startRedConstruction();const h=new _s;for(let l=0,c=t.getPointCount();l<c;l++)t.queryXY(l,h),r.contains(h)&&(a=!0,o.addRedEnvelope(l,ps.construct(h.x,h.y,h.x,h.y)));if(o.endRedConstruction(),!a)return null;let m=!1;o.startBlueConstruction();const u=new _s;for(let l=0,c=e.getPointCount();l<c;l++)e.queryXY(l,u),r.contains(u)&&(m=!0,o.addBlueEnvelope(l,ps.construct(u.x,u.y,u.x,u.y)));return o.endBlueConstruction(),m?o:null}function pi(t,e){return null}function fi(t,e){return null}function xi(t,e,s,i,n){(e<0||s<0||i<1||e+i*(s-1)+1>t.size())&&f("Index out of bound");for(let r=e,o=e+i*(s-1)+1;r<o;r+=i)t.writeAsDbl(r,n(t.readAsDbl(r)))}function yi(e,s,i){const n=e.getDescription().getTotalComponentCount();t(n<=i),e.setX(s[0]),e.setY(s[1]),Oe(e.getAttributeArray(),s,0,2,n-2)}var vi=Ft;const Pi="can not assign an empty point to a vertex";class bi{constructor(t){if(void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=vs.getDefaultDescription2D(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new Bs,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new Es,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:vs.getDefaultDescription2D();this.m_description=e,this.m_vertexAttributes=new Bs,this.m_envelopeData=new Es,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!l(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==s.getPointCount())return!1;for(let n=0;n<this.m_description.getAttributeCount();n++){const t=this.m_description.getSemantics(n),r=this.getAttributeStreamRef(t),o=s.getAttributeStreamRef(t),a=vi.getComponentCount(t);if(!r.equals(o,0,i*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}vertexCount(){return t(0),0}transformAttribute(t,e,s,i,n){this.addAttribute(t),this.isEmpty()||0===s&&1===i||(xi(this.getAttributeStreamRef(t),e,this.getPointCount(),vi.getComponentCount(t),Ks(s,i,n)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=vs.getMergedVertexDescription(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=vs.removeSemanticsFromVertexDescription(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=vs.getDefaultDescription2D();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||f("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||f("stream"),e&&vi.getPersistence(t)!==e.getPersistence()&&f(""),this.addAttribute(t);const s=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(s,e),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let i=0;i<this.m_description.getAttributeCount();i++){const e=this.m_description.getSemantics(i);for(let n=0,r=vi.getComponentCount(e);n<r;n++){const o=this.m_vertexAttributes.get(i).readAsDbl(r*t+n);s.setAttributeBasic(e,n,o)}}}setPointByVal(t,e){const s=e;s.isEmpty()&&f(Pi);const i=s.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const n=this.m_vertexAttributes.get(0);n.write(2*t,s.getX()),n.write(2*t+1,s.getY());for(let r=1,o=this.m_description.getAttributeCount();r<o;r++){const e=this.m_description.getSemantics(r),i=vi.getComponentCount(e);for(let n=0;n<i;n++){const o=s.getAttributeAsDbl(e,n);this.m_vertexAttributes.get(r).writeAsDbl(t*i+n,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(e,s,i,n){t(0)}getPointByValAsArray(e,s,i,n){t(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const i=vi.getComponentCount(t);s>=i&&b("");const n=this.m_description.getAttributeIndex(t);return n>=0?this.m_vertexAttributes.get(n).readAsDbl(e*i+s):vi.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const n=vi.getComponentCount(t);i<n&&b("");const r=this.m_description.getAttributeIndex(t);if(r>=0){const t=e*n,i=this.m_vertexAttributes.get(r);for(let e=0;e<n;e++)s[e]=i.readAsDbl(t+e)}else{const e=vi.getDefaultValue(t);for(let t=0;t<n;t++)s[t]=e}}getAttributeAsInt(e,s,i){return t(0),0}queryAttributeAsInt(e,s,i,n){t(0)}setAttribute(t,e,s,i){const n=vi.getComponentCount(t);s>=n&&b(""),this.addAttribute(t);const r=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(r).writeAsDbl(e*n+s,i)}setAttributeFromArray(t,e,s,i){(e<0||e>=this.m_pointCount)&&b("");const n=vi.getComponentCount(t);i!==n&&b(""),this.addAttribute(t);const r=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const o=this.m_vertexAttributes.get(r);for(let a=0;a<n;++a)o.writeAsDbl(e*n+a,s[a])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXY(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoords(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=gs.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=vi.getDefaultValue(1),s}setXYZ(e,s){t(0)}queryEnvelope(t){t instanceof ps||t instanceof Vs?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(e,s){return t(0),new Qt(0,0)}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(e,s,i){t(0)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=vi.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let r=0;r<i;r++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,o=this.m_pointCount*i;t<o;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(e){return t(0),0}setEnvelopeForImport(e){t(0)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&f(""),this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,i){let n=i<0?this.m_pointCount:i;if(n=Math.min(n,s+e),(s<0||n<s||this.m_pointCount>0&&s>=this.m_pointCount)&&f(""),0===this.m_pointCount)return n;const r=this.getAttributeStreamRef(0);for(let o=2*s,a=2*(n-s),h=0;o<a;o+=2,h++)t[h]=r.readPoint2D(o);return n}queryCoordinates3D(t,e,s,i){let n=i<0?this.m_pointCount:i;if(n=Math.min(n,s+e),(s<0||n<s||this.m_pointCount>0&&s>=this.m_pointCount)&&f(""),0===this.m_pointCount)return n;const r=this.getAttributeStreamRef(0);let o=null;const a=vi.getDefaultValue(1),h=this.m_description.hasAttribute(1);h&&(o=this.getAttributeStreamRef(1));let m=0;for(let u=s;u<n;u++,m++)t[m].x=r.read(2*u),t[m].y=r.read(2*u+1),t[m].z=h?o.read(u):a;return n}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;if(!(1&i)){s=(14&i)>>1,e[0]=n,n<t&&(s=-1)}return s}setIsSimple(e,s,i=!1){if(2===e?t(this.getGeometryType()===r.enumPolyline):1===e?t(this.getGeometryType()===r.enumMultiPoint||this.getGeometryType()===r.enumPolyline):3===e&&t(this.getGeometryType()===r.enumPolygon),-1===e)this.setDirtyFlagProtected(17,!0);else{let t=e<<1;i||(t|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,t),this.m_simpleTolerance!==s&&(this.m_simpleTolerance=s)}}attributeStreamIsAllocated(e){return t(0),!1}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(e,s=!1){s&&this.hasDirtyFlag(32)&&C("Cannot do shallow clone on unprepared geometry");const i=e,n=this.getGeometryType(),o=i.getGeometryType();t(n===o||n===r.enumPolygon&&o===r.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();const a=this.m_description.getAttributeCount(),h=new Bs;if(!this.m_vertexAttributes.empty()){h.destroyAndSetSize(a);for(let t=0;t<a;t++)if(this.m_vertexAttributes.get(t))if(s)h.set(t,this.m_vertexAttributes.get(t));else{const e=vi.getComponentCount(this.m_description.getSemantics(t));h.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,n!==o){const t=[0];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(h),h.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)?(t(!s),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,s)}catch(m){throw i.setEmpty(),m}i.verifyAllStreamsAfterSizeChange()}getAccelerators(){return null}clearAccelerators(){}ensureUniqueAccelerators(){t(0)}interpolateTwoVertices(e,s,i,n){(e<0||e>=this.m_pointCount)&&b(""),(s<0||s>=this.m_pointCount)&&b(""),n.assignVertexDescription(this.m_description);const r=new Array(vi.maxComponentCount()),o=new Array(vi.maxComponentCount()),a=Rt();let h=0;for(let m=0;m<this.m_description.getAttributeCount();m++){const n=this.m_description.getSemantics(m),u=vi.getInterpolation(n),l=vi.getComponentCount(n),c=vi.getDefaultValue(n);this.queryAttributeAsDbl(n,e,r,l),this.queryAttributeAsDbl(n,s,o,l),t(h+l<=qt),He(u,r,o,a,h,l,i,c),h+=l}yi(n,a,h)}getShortestDistance(t,e){return _s.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return _s.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&f(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}verifyPointIndex(e){t(0)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=xs();vs.mapAttributes(t,this.m_description,e);const s=new Bs;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return!!(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=Number.MAX_SAFE_INTEGER;let t=0;t=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:(4*this.m_pointCount+2)/3;for(let e=0;e<this.m_description.getAttributeCount();e++){const s=this.m_description.getSemantics(e);let i=0;if(null!==this.m_vertexAttributes.get(e)){const n=vi.getComponentCount(s);i=this.m_vertexAttributes.get(e).size()/n,i<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*n,vi.getDefaultValue(s)),i=t)}else this.m_vertexAttributes.set(e,As(s,t)),i=t;i<this.m_reservedPointCount&&(this.m_reservedPointCount=i)}}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new Cs({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=vi.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const r=new Qt;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new Es({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=ps.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(e){t(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof ps?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,e){if(t<0&&f(""),0===t)return;let s=t=Math.ceil(t);if(this.m_reservedPointCount<s){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,Ts(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*s),s=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,Ts(0,s)):this.m_vertexAttributes.get(0).resize(2*s);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=vi.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*i):this.m_vertexAttributes.set(t,Ts(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&f(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&v("")}}var Ei=Ft;class Ci{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=vs.getDefaultDescription2D(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=vs.getDefaultDescription3D(),this.ensureAttributes(),this.setXYZ(new gs(t.x,t.y,t.z))):(this.m_description=vs.getDefaultDescription2D(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=vs.getDefaultDescription2D()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(e){return t(0),this}vertexCount(){return t(0),1}getXY(){return new _s(this.x,this.y)}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new gs;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Ei.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return t(0),0}setID(e){t(0)}isEqualXY(e,s){return t(0),!1}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;b("")}const s=Ei.getComponentCount(t);(e<0||e>=s)&&b("");const i=this.m_description.getAttributeIndex(t);return i>=0?this.m_attribs[this.m_description.getPointAttributeOffset(i)-2+e]:Ei.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:b(""));const i=Ei.getComponentCount(t);(e<0||e>=i)&&b("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=s}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(e){t(0)}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(e){t(0)}dropAllAttributes(){const t=vs.getDefaultDescription2D();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.enumPoint}getDimension(){return 0}queryEnvelope(e){if(e instanceof Cs&&t(0,"not impl for wrapper type"),e instanceof Vs){if(this.isEmpty())return void e.setEmpty();const t=this.getXYZ();return e.xmin=t.x,e.ymin=t.y,e.zmin=t.z,e.xmax=t.x,e.ymax=t.y,void(e.zmax=t.z)}this.isEmpty()?e.setEmpty():(e.xmin=this.x,e.ymin=this.y,e.xmax=this.x,e.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(e,s){return t(0),new Qt(0,0)}applyTransformation(e){t(0)}transformAttribute(e,s,i,n,r){t(0)}createInstance(){return this}copyTo(t){if(this===t)return;t.getGeometryType()!==r.enumPoint&&f();const e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=vs.getDefaultDescription2D(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&Oe(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let i=0,n=this.m_description.getTotalComponentCount()-2;i<n;i++)if(!O(this.m_attribs[i],s.m_attribs[i],e))return!1;return!0}getBoundary(){return null}clone(){return t(0),this}swap(e){t(0)}replaceNaNs(e,s){t(0)}lerp(e,s,i){return t(0),new Ci({x:0,y:0})}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?Oe(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(e,s){return t(0),0}getImpl(){return this}hasNonLinearSegments(){return t(0),!1}mergeVertexDescriptionImpl(e){t(0)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=vs.getDefaultDescription2D());const e=xs();vs.mapAttributes(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=Ei.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&Oe(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=Ei.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=Ei.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){}dbgDefaultAttribs(){}}Ci.type=r.enumPoint;class Di{constructor(){this.envAabb=ps.constructEmpty(),this.envRot=ps.constructEmpty()}static constructEmpty(){return new Di}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}isEmpty(){return t(0),!1}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:Si(t),y:wi(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergePoint2D(e){t(0)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Si(t),wi(t))}mergeCoords(e,s){t(0)}mergeW(e){t(0)}mergeE2D(e){t(0)}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=Si(t[i]),s=wi(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=Si(t[s]),i=wi(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Si(t),wi(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*xt();this.envRot.inflateCoords(e,e),e<0&&Di.st_reduceEmpty(this)}sqrMaxMinDistance(e){return t(0),0}sqrMinDistance(e){return t(0),0}sqrMaxDistance(e){return t(0),0}getEnvelope2D(){return t(0),new ps(this.envAabb)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}}function Si(t){return t.x-t.y}function wi(t){return t.x+t.y}class Ai{constructor(){this.x=$t.getNAN(),this.y=$t.getNAN()}static getNAN(){return new Ai}static constructPoint2D(t){const e=new Ai;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ai;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ai;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new Ai).setE(this)}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new Ai;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ai;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=ne.clone(),this.y=ie.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return _s.construct(this.x.value(),this.y.value())}}class Ti{constructor(){this.a11=new $t(1),this.a12=new $t(0),this.a21=new $t(0),this.a22=new $t(1)}clone(){const t=new Ti;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=je(this.a12,this.a12=this.a21),this}transformPoint(e){return t(0),new Ai}eigenValues(e){return t(0),0}eigenVectors(e,s){return t(0),0}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new $t(1),n=new $t(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new $t(1);if(this.a11.ne(this.a22)){const r=this.a11.subE(this.a22).divE(s);r.mulThisByPower2(.5);const o=r.sqr();e.setE(r),e.absThis(),e.subThisE(o.add(1).sqrtThis()),r.gt(ie)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(a),i.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else i=new $t(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=je(t[0],t[0]=t[1]),e[1]=je(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var Ii=Ft,Ni=vs;function Mi(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function qi(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Ri(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),i=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,i}function Fi(e,s,i,n,r,o,a,h){let m=e.calculateUpperLength2D(),u=s.calculateUpperLength2D(),l=e,c=s,d=!1;m>u&&(c=je(l,l=c),n=je(i,i=n),u=je(m,m=u),d=!0);const _=0===i;{a[0]=_?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(_s.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(l.getCoord2D(e[i])),!c.isCloserThanDistance(t,new Qt(0,1),r)){s=!1;break}if(s)return d&&(h[0]=je(a[0],a[0]=h[0])),1}}if(m<=3*r)return 0;let g=Pt(Math.max(r/m,.1),0,.5),p=.01*r,f=0,x=0,y=g,v=-1,P=0,b=1/32;for(let E=0;;E++){t(E<4095);const e=_?g:1-g,s=l.getCoord2D(e),i=c.getClosestCoordinate(s,!1);if(i===n)return P;const m=c.getCoord2D(i),u=_s.distance(s,m);if(0===E&&(v=u),u<=p?(b=.5,x=u,f=g):(y=g,v=u),Math.abs(x-v)>.1*p&&y-f>1e-16)g=pe(f,y,b);else{if(a[P]=e,h[P]=i,d&&(h[P]=je(a[P],a[P]=h[P])),1===o||1===P)return 1===P&&a[0]>a[1]&&(a[1]=je(a[0],a[0]=a[1]),h[1]=je(h[0],h[0]=h[1])),P+1;P++,f=y,x=v,y=.8,v=-1,g=.8,b=1/32,p=10*r,E=0}}}function Yi(t,e,s,i,n,r,o,a,h){if(vt(s,0,1)&&vt(i,0,1)){if(0===_s.distance(t.getCoord2D(s),e.getCoord2D(i))){const h=1e-12,m=new Ai,u=yt();if(t.queryDerivative(new $t(s,u),m),m.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new $t(s,u).add(e),m)}1===s&&m.negateThis();const l=new Ai;if(e.queryDerivative(new $t(i,u),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new $t(i,u).add(t),l)}1===i&&l.negateThis(),m.isZero()||m.normalize(),l.isZero()||l.normalize();const c=m.dotProduct(l),d=m.crossProduct(l);d.scaleError(3);const _=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(c.ge(ie)&&(d.isZero()||Math.abs(d.value())<_())){return Fi(t,e,s,i,n,r,o,a)}}}return 0}function Xi(e,s,i){if(t(e.isCurve()||s.isCurve()),e.getStartXY().equals(s.getStartXY())){if(Yi(e,s,0,0,i,2,[0,0],[0,0]))return!0}if(e.getEndXY().equals(s.getEndXY())){if(Yi(e,s,1,1,i,2,[0,0],[0,0]))return!0}if(e.getStartXY().equals(s.getEndXY())){if(Yi(e,s,0,1,i,2,[0,0],[0,0]))return!0}if(e.getEndXY().equals(s.getStartXY())){if(Yi(e,s,1,0,i,2,[0,0],[0,0]))return!0}return!1}function Li(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function zi(t,e,s){t.m_XStart=e,t.m_YStart=s}function Vi(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Bi(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function ki(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}function Gi(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function Wi(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let r=1;r<t.m_description.getAttributeCount();r++){const i=t.m_description.getSemantics(r);for(let n=0,r=Ii.getComponentCount(i);n<r;n++){const r=Hi(t,e,i,n);s.setAttributeBasic(i,n,r)}}}function Zi(t,e,s){s.isEmpty()&&v(""),ki(t,e,s.getXY());const i=s.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let n=1,r=i.getAttributeCount();n<r;n++){const r=i.getSemantics(n),o=Ii.getComponentCount(r);for(let i=0;i<o;i++){Oi(t,e,r,i,s.getAttributeAsDbl(r,i))}}}function Hi(t,e,s,i){if((e<0||e>1)&&b(""),0===s)return(i<0||i>=2)&&b(""),0===e?0===i?t.m_XStart:t.m_YStart:0===i?t.m_XEnd:t.m_YEnd;const n=Ii.getComponentCount(s);(i<0||i>=n)&&b("");const r=t.m_description.getAttributeIndex(s);return r>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(r)-2+i]:Ii.getDefaultValue(s)}function Oi(t,e,s,i,n){if((e<0||e>1)&&b(""),0===s)return 0===e?0===i?t.m_XStart=n:1===i?t.m_YStart=n:b(""):1===e?0===i?t.m_XEnd=n:1===i?t.m_YEnd=n:b(""):b(""),void t.endPointModified();const r=Ii.getComponentCount(s);(i<0||i>=r)&&b("");let o=t.m_description.getAttributeIndex(s);o<0&&(t.addAttribute(s),o=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+i]=n}function ji(t,e){if(t===e)return;e.isEmpty()&&v("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=Ii.getComponentCount(n);for(let s=0;s<r;s++){let i=Hi(e,0,n,s);Oi(t,0,n,s,i),i=Hi(e,1,n,s),Oi(t,1,n,s,i)}}}function Ui(t,e){const s=xs();Ni.mapAttributes(e,t.m_description,s);let i=null;const n=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(n>0){i=new Array(2*n);const o=e.getDefaultPointAttributes();for(let t=2;t<o.length;++t)i[t-2]=i[t-2+n]=o[t];if(null!==t.m_description)for(let a=1;a<e.getAttributeCount();a++){const o=s[a];if(-1!==o){const s=t.m_description.getPointAttributeOffset(o)-2,h=e.getPointAttributeOffset(a)-2,m=Ii.getComponentCount(e.getSemantics(a));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[n+h]=t.m_attributes[r+s]}}}t.m_attributes=i,t.m_description=e}function Qi(t){return t.absNorm()*pt()}function Ki(t,e){return Math.max(t.absNorm(),e.absNorm())*pt()}function $i(t,e,s){const i=new Di;t.queryEnvelopeW(Qt.unit(),i);const n=new Di;return e.queryEnvelopeW(Qt.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function Ji(t,e,s){const i=ns(t,s),n=ns(e,s);i.sort(((t,e)=>t.compare(e))),n.sort(((t,e)=>t.compare(e)));for(let r=0;r<3;r++){if(i[r].compare(n[r])<0)return-1;if(0!==i[r].compare(n[r]))return 1}return 0}class tn{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&b("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&b("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&b(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}clone(){return t(0),this}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&b(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return t(0),!1}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){t(0)}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&y(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&b("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&b(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!==(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&b(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&b(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){return t(0),!1}isPathClosed(){return t(0),!1}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}function en(t){const e=t.getGeometryType();return e===r.enumEllipticArc?10:e===r.enumBezier?4:e===r.enumRationalBezier2?5:e===r.enumBezier2?2:void E("")}function sn(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function nn(t,e,s){return s.writeInBufferStream(t,e)}function rn(t,e,s){s.readFromBufferStream(t,e)}function on(t,e,s,i){const n=t.getPathStart(e),r=t.getPathEnd(e);if(r-n<3)return;const o=2*n,a=_s.getNAN();s.queryPoint2D(o,a);const h=a.x,m=a.y,u=_s.getNAN();s.queryPoint2D(o+2,u);const l=_s.getNAN();for(let c=o+4,d=2*r;c<d;c+=2)s.queryPoint2D(c,l),i.pe((l.x-a.x)*(u.y-m)),a.setCoordsPoint2D(u),u.setCoordsPoint2D(l);i.pe((h-a.x)*(u.y-m))}function an(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var hn=Ft;class mn{static toSegType(t){let e=0;switch(t){case r.enumLine:e=1;break;case r.enumBezier:e=2;break;case r.enumEllipticArc:e=4;break;case r.enumRationalBezier2:e=8;break;case r.enumBezier2:e=16;break;default:E("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class un extends bi{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?r.enumPolygon:r.enumPolyline}getDimension(){return this.m_bPolygon?2:1}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(e){return t(0),!1}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new Xs(t),s=new Yt(0),i=new Yt(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new tn({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();on(this,r,n,i),an(this,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),on(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){return t(0),0}getHashCodeImpl(){return t(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!un.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),r=sn(s);for(let t=0;t<r;t++){if(!H(this.m_curveData.m_segmentParams.read(i+t),e.m_curveData.m_segmentParams.read(n+t)))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=Is(1,0),this.m_pathFlags=Ns(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new mn),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new Yt(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(e){return t(0),0}calculateLength3D(e){return t(0),0}calculatePathLength3D(e,s){return t(0),0}copyTo(t){c(t.getGeometryType())||f(""),super.copyTo(t)}swap(e){t(0)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&f("Multi_path_impl::add");for(let s=0,i=t.getPathCount();s<i;s++)this.addPath(t,s,!e)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addSegmentsFromPath(t,e,s,i,n){if(this===t&&f("Multi_path_impl.add_segments_from_path"),n||0!==this.getPathCount()||(n=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||i<0||s+i>t.getSegmentCountPath(e))&&b("add_segments_from_path"),0===i)return;const r=t.getPathStart(e),o=t.isClosedPath(e)&&s+i===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let a=i;const h=r+s;let m=h+1;n&&(a++,m--),!n&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(h)&&(t.getXY(h).equals(this.getXY(this.m_pointCount-1))||f("add_segments_from_path: start point mismatch"));const u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange(),n){if(0===a)return;this.m_paths.add(this.m_pointCount);let s=t.m_pathFlags.read(e);this.m_bPolygon&&(s|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,s),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const l=o?a-1:a;for(let c=0,d=this.m_description.getAttributeCount();c<d;c++){const e=this.m_description.getSemantics(c),s=hn.getComponentCount(e),i=t.m_description.getAttributeIndex(e);if(l>0){if(i<0||!t.m_vertexAttributes.get(i)){const t=hn.getDefaultValue(e);this.m_vertexAttributes.get(c).insertRange(s*u,t,l*s,s*u),o&&this.m_vertexAttributes.get(c).insertRange(s*u+l*s,t,s,s*u);continue}this.m_vertexAttributes.get(c).insertRangeFromStream(s*u,t.m_vertexAttributes.get(i),s*m,l*s,!0,s,s*u)}o&&this.m_vertexAttributes.get(c).insertRangeFromStream(s*(u+l),t.m_vertexAttributes.get(i),s*r,s,!0,s,s*(u+l))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,n=h;s<i;s++){e+=sn(t.m_curveData.m_segmentFlags.read(n)),n++}if(e>0){this.initSegmentData(e);let s=h,r=u-(n?0:1),o=0;for(let e=0;e<i;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(r,e),un.isNonLinearSegmentFlag(e)){o++;let i=t.m_curveData.m_segmentParamIndex.read(s);const n=sn(e);this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<n;e++){const e=t.m_curveData.m_segmentParams.read(i);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,i++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(r,-1);r++,s++}this.modifyCurveCounter(o)}}if(o){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&f("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),i=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const n=new this.m_segmentBufferCTor;let r=!1;for(let s=0;s<e;s++,t++){const e=this.m_curveData.m_segmentFlags.read(t);if(!un.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,n,!0),n.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);nn(this.m_curveData.m_segmentParams,s,n.get())}if(r){const t=i?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const n=i?1:0;for(let o=0,a=this.m_description.getAttributeCount();o<a;o++)if(this.m_vertexAttributes.get(o)){const t=this.m_description.getSemantics(o),i=hn.getComponentCount(t);this.m_vertexAttributes.get(o).reverseRange(i*(s+n),i*(e-n),i)}const r=6&this.m_pathFlags.read(t);if(r){let e=0;4&r&&(e|=2),2&r&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(e){t(0)}insertPath(t,e,s,i){this===e&&f("Multi_path_impl::insert_path");const n=this.getPathCount();if(!i&&e.hasNonLinearSegmentsPath(s))return t=this.insertPath(t,e,s,!0),this.reversePath(t),t;s>=e.getPathCount()&&f(""),t>n&&f(""),t<0&&(t=n),s<0&&(s=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());const r=e.getPathStart(s),o=e.getPathSize(s);if(0===o)return this.insertPath2D(t,null,0,0,!0);const a=this.m_pointCount,h=e.isClosedPath(s)&&!i?1:0;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=t<n?this.getPathStart(t):a;for(let c=0,d=this.m_description.getAttributeCount();c<d;c++){const t=this.m_description.getSemantics(c),s=e.getDescription().getAttributeIndex(t),n=hn.getComponentCount(t);if(s>=0&&e.m_vertexAttributes.get(s))0!==h&&this.m_vertexAttributes.get(c).insertRangeFromStream(m*n,e.m_vertexAttributes.get(s),n*r,n,!0,n,n*a),this.m_vertexAttributes.get(c).insertRangeFromStream((m+h)*n,e.m_vertexAttributes.get(s),n*(r+h),n*(o-h),i,n,n*(a+h));else{const e=hn.getDefaultValue(t);this.m_vertexAttributes.get(c).insertRange(m*n,e,n*o,n*a)}}const u=a+o;this.m_paths.add(u);for(let c=n;c>=t+1;c--){const t=this.m_paths.read(c-1);this.m_paths.write(c,t+o)}this.m_pathFlags.add(0);for(let c=n-1;c>=t+1;c--){let t=this.m_pathFlags.read(c);t&=-9,this.m_pathFlags.write(c+1,t)}let l=e.getPathFlagsStreamRef().read(s);if(l&=-9,this.m_bPolygon&&(l|=1),this.m_pathFlags.write(t,l),e.hasNonLinearSegments()){this.initSegmentData(0);let t=r,s=0;for(let i=0;i<o;i++){s+=sn(e.m_curveData.m_segmentFlags.read(t)),t++}if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=Ns(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=Is(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(m,1,o,a),this.m_curveData.m_segmentParamIndex.insertRange(m,-1,o,a)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+s):this.m_curveData.m_segmentParams=Ms(s),t=r;let i=m,n=0;for(let s=0;s<o;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(un.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(i,s),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const r=sn(s);let o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){const t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(s,1)}t++,i++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,s,i,n){const r=this.getPathCount();(t>r||s<0)&&f(""),t<0&&(t=r),this.m_bPathStarted=!1;const o=this.m_pointCount;this.resizeImpl(this.m_pointCount+i),0===i&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const a=t<r?this.getPathStart(t):o;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*a,e,s,i,n,2*o);else{const t=hn.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*a,t,2*i,2*o)}for(let h=1,m=this.m_description.getAttributeCount();h<m;h++){const t=this.m_description.getSemantics(h),e=hn.getComponentCount(t),s=hn.getDefaultValue(t);this.m_vertexAttributes.get(h).insertRange(a*e,s,e*i,e*o)}this.m_paths.add(this.m_pointCount);for(let h=r;h>=t+1;h--){const t=this.m_paths.read(h-1);this.m_paths.write(h,t+i)}this.m_pathFlags.add(0);for(let h=r-1;h>=t+1;h--){let t=this.m_pathFlags.read(h);t&=-9,this.m_pathFlags.write(h+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(a,1,i,o),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,i,o)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(e,s,i,n,r){t(0)}insertPoints(e,s,i,n,r,o,a){t(0)}insertPointsFromPoints(e,s,i,n,r,o){t(0)}insertPointsFromMultipoint(e,s,i,n,r,o){t(0)}insertPoint2D(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&b(""),t===i&&this.addPathPoint2D(null,0,!0);const n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const r=this.getPathStart(t),o=e<0?this.getPathSize(t)+r:e+r,a=this.m_vertexAttributes.get(0);if(o===n)this.m_paths.write(t+1,n+1),a.writePoint2D(2*o,s);else{a.insert(2*o,s,2*n);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=hn.getComponentCount(e),i=hn.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*o,i,s,s*n)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(o,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(o,-1,1,n));for(let e=t+1,s=i;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&o>r&&this.isNonLinearSegment(o-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&b(""),t===i&&this.addPathPoint2D(null,0,!0);const n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const r=this.getPathStart(t),o=e<0?this.getPathSize(t)+r:e+r;if(o===n)this.m_paths.write(t+1,n+1),this.setPointByVal(o,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),r=hn.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(r*o,s,i,r*n);else{const e=hn.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(r*o,e,r,r*n)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(o,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(o,-1,1,n));for(let s=t+1,n=i;s<=n;s++)this.m_paths.write(s,this.m_paths.read(s)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&o>r&&this.isNonLinearSegment(o-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&b("Multi_path.remove_point");const i=this.getPathStart(t),n=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&b("Multi_path.remove_point");const r=i+e;for(let o=0,a=this.m_description.getAttributeCount();o<a;o++)if(this.m_vertexAttributes.get(o)){const t=this.m_description.getSemantics(o),e=hn.getComponentCount(t);this.m_vertexAttributes.get(o).eraseRange(e*r,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(r>i&&this.isNonLinearSegment(r-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(r-1),-1),this.m_curveData.m_segmentFlags.write(r-1,1),this.m_curveData.m_segmentParamIndex.write(r-1,-1);else{const s=this.getPathEnd(t);n&&i+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(r)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(r),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(r,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(r,1,this.m_pointCount)}for(let o=s;o>=t+1;o--){const t=this.m_paths.read(o);this.m_paths.write(o,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)un.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=un.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new Ci({x:t,y:e}))}startPath(t){this.startPathPoint(new Ci({pt:t}))}startPath3D(t){this.startPathPoint(new Ci({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new Ci({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&f("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const i=new Ci({vd:this.m_description});t.copyCommonAttributesTo(i),s=i}else s=t;this.m_bPathStarted?this.setPointByVal(this.m_pointCount-1,s):(this.insertPoint(-1,-1,s),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=Is(2),this.m_paths.write(0,0),this.m_pathFlags=Ns(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoords(this.m_pointCount-1,t,e);else{const s=Rt(),i=new Ci({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByVal(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=vs.getMergedVertexDescription(this.m_description,vs.getDefaultDescription3D()),s=Rt(),i=new Ci({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByVal(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new gs(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByVal(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=Rt(),s=new Ci({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByVal(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&E("");const e=this.getPathCount();if(t>e&&f(""),!this.isClosedPath(t))return;this.m_pathFlags||E("");const s=this.m_pointCount,i=this.getPathStart(t),n=this.getPathEnd(t);if(n-i!=0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),r=hn.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(r*n,this.m_vertexAttributes.get(t),r*i,r,!0,1,r*s)}for(let s=e;s>t;s--){const t=this.m_paths.read(s);this.m_paths.write(s,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(n,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(n,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(e){t(0)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&E(""),this.isEmpty())return;this.m_pathFlags||E("");let t=0;const e=this.getPathCount();for(let m=0;m<e;m++)this.isClosedPath(m)&&(this.getPathSize(m)>0?t++:this.m_pathFlags.clearBits(m,1));if(0===t)return;const s=this.hasNonLinearSegments();let i=0;const n=this.getPathCount(),r=this.m_description.getAttributeCount(),o=new Array(r);let a=null,h=null;for(let m=0;m<n;++m){const e=this.getPathStart(m),n=this.getPathSize(m),u=this.isClosedPath(m);if(n>0){const m=e+i;for(let s=0;s<r;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=hn.getComponentCount(i);if(!o[s]){const e=Ts(i,r*(this.m_pointCount+t));o[s]=e}o[s].writeRange(m*r,n*r,this.m_vertexAttributes.get(s),e*r,!0,1),u&&o[s].writeRange((m+n)*r,r,this.m_vertexAttributes.get(s),e*r,!0,1)}if(s){if(null===a){const e=this.m_pointCount+t;a=Ns(e),h=Is(e)}a.writeRange(m,n,this.m_curveData.m_segmentFlags,e,!0,1),h.writeRange(m,n,this.m_curveData.m_segmentParamIndex,e,!0,1),u&&(a.write(m+n,1),h.write(m+n,-1))}}this.m_paths.write(m,e+i),u&&(this.m_pathFlags.clearBits(m,1),++i)}this.m_paths.write(n,this.m_pointCount+t),this.m_pathFlags.clearBits(n,1);for(let m=0;m<r;m++)this.m_vertexAttributes.get(m)&&this.m_vertexAttributes.set(m,o[m]);s&&(this.m_curveData.m_segmentFlags=a,this.m_curveData.m_segmentParamIndex=h),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&f("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const e=this.m_pathFlags.read(t);if(this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),1!==s&&(this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&f("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||f("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());const s=e.getStartXY(),i=this.getPathEnd(t)-1;s.equals(this.getXY(i))||f("close_path_with_segment: start point mismatch");const n=e.getGeometryType();if(n===r.enumLine)return void this.closePathWithLine(t);{const t=en(e);this.initSegmentData(t);const s=mn.toSegType(n),r=this.m_curveData.m_segmentFlags.read(i);if(r!==s)this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint),nn(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==r?this.incCurveType(r,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(i);nn(this.m_curveData.m_segmentParams,t,e)}this.m_curveData.m_segmentFlags.write(i,s)}}const s=this.m_pathFlags.read(t);this.m_pathFlags.write(t,1|s),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(e){return t(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(un.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof ps)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=Rt(),n=new Ci({vd:s,attribBuffer:i,initDefaultValues:!1});for(let r=0,o=4;r<o;r++){const s=e?o-r-1:r;t.queryCornerByVal(s,n),0===r?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||f("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new Ci;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new Ci;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const i=Rt(),n=new Ci({vd:s,attribBuffer:i,initDefaultValues:!1}),o=t.getGeometryType();if(o===r.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(n),this.startPathPoint(n)),t.queryEnd(n),this.lineToPoint(n);else{let s=!1;if((e||this.isEmptyImpl())&&(s=!0),!s){t.getStartXY().equals(this.getXY(this.m_pointCount-1))||f("add_segment: start point mismatch")}if(s&&(t.queryStart(n),this.startPathPoint(n)),this.beforeNewSegment(1),t.queryEnd(n),n.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,n);else{const t=Rt(),e=new Ci({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});n.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const i=en(t);this.initSegmentData(i),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),nn(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint+=i;const r=mn.toSegType(o);this.incCurveType(r,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,r)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributes(t,e,s,i){for(let o=t;o<s-1;o++)this.isClosedPath(o)&&f("cannot interpolate across closed paths");const n=this.m_description.getAttributeCount();if(1===n)return;const r=this.calculateSubLength2D(t,e,s,i);if(0!==r)for(let o=1;o<n;o++){const n=this.m_description.getSemantics(o);this.interpolateAttributesSemanticsImpl(n,t,e,s,i,r)}}interpolateAttributesSemantics(e,s,i,n,r){t(0)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(e,s,i,n){t(0)}interpolateAttributesSemanticsImpl(t,e,s,i,n,r){const o=this.querySegmentIterator(),a=this.getPathStart(e)+s,h=this.getPathStart(i)+n,m=hn.getComponentCount(t),u=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new Array(hn.maxComponentCount());Oe(c,u,0,0,m);let d=0;const _=hn.getDefaultValue(t),g=hn.getInterpolation(t);o.resetToVertex(a,e);do{if(o.hasNextSegment()){if(o.nextSegment(),o.getStartPointIndex()===h)return;this.setAttributeFromArray(t,o.getStartPointIndex(),c,m),o.previousSegment();do{const e=o.nextSegment();if(o.getEndPointIndex()===h)return;d+=e.calculateLength2D();He(g,u,l,c,0,m,d/r,_),o.isClosingSegment()||this.setAttributeFromArray(t,o.getEndPointIndex(),c,m)}while(o.hasNextSegment())}}while(o.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,n){const r=this.querySegmentIterator(),o=hn.getInterpolation(t),a=this.getPathStart(e)+s,h=this.getPathStart(e)+i;if(h===a)return;const m=hn.getComponentCount(t),u=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new Yt(0);r.resetToVertex(a,e),r.setCirculator(this.isClosedPath(e));const d=hn.getDefaultValue(t),_=new Array(hn.maxComponentCount());Oe(_,u,0,0,m);const g=0===n;let p=.5;do{const e=r.nextSegment();if(this.setAttributeFromArray(t,r.getStartPointIndex(),_,m),!g){const t=e.calculateLength2D();c.pe(t),p=c.getResult()/n}He(o,u,l,_,0,m,p,d)}while(r.getEndPointIndex()!==h)}querySegment(t,e,s){const i=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(i);n>=this.getSegmentCountPath(i)&&f("get_segment"),this.getSegmentFromPath(i,n,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(e){return t(0),r.enumUnknown}getSegmentFromPath(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef();let o=1;switch(r&&(o=31&r.read(n)),o){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:E("")}const a=s.get();let h,m=null;i?(m=vs.getDefaultDescription2D(),a.assignVertexDescription(m)):a.assignVertexDescription(this.m_description),h=n===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):n+1;Li(a,this.getXY(n));if(Vi(a,this.getXY(h)),!i)for(let u=1,l=this.m_description.getAttributeCount();u<l;u++){const t=this.m_description.getSemantics(u),e=hn.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,n,s);a.setStartAttribute(t,s,e);const i=this.getAttributeAsDbl(t,h,s);a.setEndAttribute(t,s,i)}}if(un.isNonLinearSegmentFlag(o)){const t=this.m_curveData.m_segmentParamIndex.read(n);rn(this.m_curveData.m_segmentParams,t,a)}}queryPointAlongPath(t,e,s,i=!1){const n={iSegment:-1},r=i?n:{iSegment:-1,tSegment:0};if(s.setEmpty(),this.isEmpty())return n;if((t<0||t>=this.getPathCount())&&f("query_point_along_path"),e<0)return n;const o=this.getPathSize(t);if(0===o)return n;if(1===o)return this.getPointByVal(this.getPathStart(t),s),r.tSegment=0,n.iSegment=this.getPathStart(t),n;const a=this.querySegmentIteratorAtVertex(this.getPathStart(t)),h=new Yt(0);for(;a.hasNextSegment();){const t=a.nextSegment(),i=t.calculateLength2D(),o=h.getResult();if(h.add(i),h.getResult()>=e){let h=e-o;h>i&&(h=i);const m=t.lengthToT(h);return t.queryCoord(m,s),r.tSegment=m,n.iSegment=a.getStartPointIndex(),n}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),r.tSegment=1,n.iSegment=this.getPathEnd(t)-1,n}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(r.tSegment=1,n.iSegment=this.getPathEnd(t)-2,n):(r.tSegment=0,n.iSegment=this.getPathStart(t),n)}}queryPointsAlongPath(t,e,s,i,n,r){{let t=0;for(let o=0;o<e;++o)i&&i[o].setEmpty(),n&&(n[o]=-1),r&&(r[o]=0),t>s[o]&&f("query_points_along"),t=s[o]}const o=this.getPathSize(t);if(0===e||0===o)return 0;if(1===o){const e=this.getPathStart(t);return i&&this.getPointByVal(e,i[0]),r&&(r[0]=0),n&&(n[0]=e),1}const a=this.getPathStart(t),h=new Yt(0),m=this.querySegmentIteratorAtVertex(a);let u=0,l=0,c=s[u];for(;m.hasNextSegment();){const t=m.nextSegment(),o=t.calculateLength2D(),a=h.getResult();for(h.add(o);h.getResult()>=c;){let h=c-a;h>o&&(h=o);const d=t.lengthToT(h);if(i&&t.queryCoord(d,i[l]),r&&(r[l]=d),n&&(n[l]=m.getStartPointIndex()),l++,u++,c=s[u],u===e)return l}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;i&&this.getPointByVal(e,i[l]),r&&(r[l]=s),n&&(n[l]=e),l++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;i&&this.getPointByVal(e+1,i[l]),r&&(r[l]=s),n&&(n[l]=e),l++}return l}queryPointsAlong(t,e,s,i,n){{let r=0;for(let o=0;o<t;++o)s&&s[o].setEmpty(),i&&(i[o]=-1),n&&(n[o]=0),r>e[o]&&f("query_points_along"),r=e[o]}if(0===t)return 0;const r=new Yt(0),o=this.querySegmentIterator();let a=-1,h=0,m=0,u=e[h];for(;o.nextPath();)for(;o.hasNextSegment();){a=o.getPathIndex();const l=o.nextSegment(),c=l.calculateLength2D(),d=r.getResult();for(r.add(c);r.getResult()>=u;){let r=u-d;r>c&&(r=c);const a=l.lengthToT(r);if(s&&l.queryCoord(a,s[m]),n&&(n[m]=a),i&&(i[m]=o.getStartPointIndex()),m++,h++,u=e[h],h===t)return m}}if(a<0)return 0;if(this.isClosedPath(a)){const t=this.getPathStart(a),e=0;s&&this.getPointByVal(t,s[m]),n&&(n[m]=e),i&&(i[m]=t),m++}else if(this.getPathSize(a)>1){const t=this.getPathEnd(a)-2,e=1;s&&this.getPointByVal(t+1,s[m]),n&&(n[m]=e),i&&(i[m]=t),m++}return m}querySegmentIterator(){return new tn({parent:this})}querySegmentIteratorAtVertex(t){return new tn({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(e,s,i){if(s instanceof Cs&&t(0,"not implemented for Envelope"),(e>=this.getPathCount()||e<0)&&f(""),this.isEmpty())return void s.setEmpty();const n=this.getAttributeStreamRef(0),r=ps.constructEmpty();r.setEmpty();for(let o=2*this.getPathStart(e),a=2*this.getPathEnd(e);o<a;){const e=a-o;t(!(1&e)),r.mergePointsInterleaved(n,o/2,e/2),o+=e}if(s.setCoords({env2D:r}),this.hasNonLinearSegmentsPath(e)){const n=this.querySegmentIterator();if(n.resetToPath(e),n.nextPath())for(;n.hasNextSegment();){const t=n.nextCurve();if(!t)break;{const e=ps.constructEmpty();i?t.queryEnvelope(e):t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}else t(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=10,e=sn(4)*this.m_curveData.m_arcCount+sn(2)*this.m_curveData.m_bezierCount+sn(8)*this.m_curveData.m_rbezier2Count+sn(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*e>>1,t)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let i=0,n=this.getPointCount();i<n;i++){const e=this.m_curveData.m_segmentFlags.read(i);if(un.isNonLinearSegmentFlag(e)){t+=sn(e)}}const e=Ms(t);let s=0;for(let i=0,n=this.getPointCount();i<n;i++){const t=this.m_curveData.m_segmentFlags.read(i);if(un.isNonLinearSegmentFlag(t)){let n=this.m_curveData.m_segmentParamIndex.read(i);this.m_curveData.m_segmentParamIndex.write(i,s);const r=sn(t);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setPathsFromJsonArrays(e,s,i){t(!1===s),t(!1===e),this.setEmpty();const n=i.length;if(0===n)return;let o=0;for(const t of i)o+=t.length;const a=new Xs(2*o),h=new Fs(n);let m=0,u=0;for(let t=0;t<n;++t){h.write(t,m),m+=i[t].length;const e=i[t],s=e.length;for(let t=0;t<s;++t)a.write(u++,e[t][0]),a.write(u++,e[t][1])}const l=new Rs(h.size());l.setRange(this.getGeometryType()===r.enumPolygon?1:0,0,h.size()),this.setAttributeStreamRef(0,a),this.setPathFlagsStreamRef(l),this.setPathStreamRef(h),this.notifyModifiedFlags(65535)}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(e){t(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=Is(0),this.m_pathFlags=Ns(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0))}reserveParts(e,s){t(0)}clone(){const t=this.createInstance();return this.copyTo(t),t}createShallowClone(){return t(0),this}queryLimitedSegmentIterator(t){return new ln(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new mn),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,i){if(i>=0&&i<e){if(s>=t.read(i)){if(s<t.read(i+1))return i;i++}else i--;if(i>=0&&i<e&&s>=t.read(i)&&s<t.read(i+1))return i}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;p("")}let n=0,r=e-1;for(;r>n;){const e=n+(r-n>>1);if(s<t.read(e))r=e-1;else{if(!(s>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(e){return t(0),0}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&f("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const s=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let i,n;return e<0?(i=0,n=this.m_pointCount):(i=this.getPathStart(e),n=this.getPathEnd(e)),s.applyTransformation(t,2*i,n-i),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,n=this.getPathCount();let r=e<0?0:e;do{const n=this.getPathStart(r),o=this.getPathEnd(r),a=this.isClosedPath(r),h=s.readPoint2D(2*n);if(!this.hasNonLinearSegmentsPath(r)){s.applyTransformation(t,2*n,o-n);continue}const m=_s.getNAN();for(let e=n;e<o;++e){if(1!==(31&this.m_curveData.m_segmentFlags.read(e))){const r=a&&e+1===o;r&&s.writePoint2D(2*n,h),this.getSegmentBuffer(e,i,!0),i.get().applyTransformation(t);const m=this.m_curveData.m_segmentParamIndex.read(e);nn(this.m_curveData.m_segmentParams,m,i.get()),s.writePoint2D(2*e,i.get().getStartXY()),r&&s.writePoint2D(2*n,i.get().getEndXY());continue}const r=2*e;s.queryPoint2D(r,m),t.transformInPlace(m),s.writePoint2D(r,m)}if(r===e)break}while(++r<n);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getPathStart(s)+i;(r<n||n<0||r>this.getPointCount()-1)&&y("");const o=this.querySegmentIterator();let a=0;o.resetToVertex(n,t);do{for(;o.hasNextSegment();){const t=o.nextSegment();if(o.getStartPointIndex()===r)break;a+=t.calculateLength2D()}if(o.getStartPointIndex()===r)break}while(o.nextPath());return a}calculatePathSubLength2D(t,e,s){const i=this.getPathStart(t)+e,n=this.getPathStart(t)+s;(i<0||n>this.getPointCount()-1)&&y("");const r=this.querySegmentIterator();if(i>n&&(this.isClosedPath(t)||f("cannot iterate across an open path"),r.setCirculator(!0)),i===n)return 0;let o=0,a=0;r.resetToVertex(i,t);do{a+=o;o=r.nextSegment().calculateLength2D()}while(r.getStartPointIndex()!==n);return a}calculateEnvelope2D(e){return t(0),new ps(0,0,0,0)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=ps.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&f("Multi_path_impl::add");let s=this.getPathCount();for(let i=0,n=t.getPathCount();i<n;i++)this.addPath(t,i,!e),this.openPathAndDuplicateStartVertex(s),s++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,s){const i=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(i);n>=this.getSegmentCountPath(i)&&f("getSegmentBuffer"),this.getSegmentFromPath(i,n,e,s)}getSegmentTypeFromPath(e,s){return t(0),r.enumBezier}ensureXYMonotoneSegments(){return t(0),!1}buildRasterizedGeometryAccelerator(e,s){return t(0),!1}buildQuadTreeAccelerator(e){return t(0),!1}buildQuadTreeForPathsAccelerator(e){return t(0),!1}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(un.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new mn),un.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new mn),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return t(0),0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new mn);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=Ns(e,1),this.m_curveData.m_segmentParamIndex=Is(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=Ms(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(e){t(0)}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=Ee(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(e,s,i){(e<0||e>=this.getPointCount())&&f("Multi_path_impl.replace_segment"),t(s.isCurve());const n=this.getPathIndexFromPointIndex(e),r=this.getPathStart(n),o=(e-r+1)%this.getPathSize(n)+r;{const i=this.getXY(e),n=this.getXY(o);t(!(!i.isEqualPoint2D(s.getStartXY())||!n.isEqualPoint2D(s.getEndXY())))}const a=s.getDescription();this.mergeVertexDescription(a);const h=new Array(32),m=new Ci({vd:a,attribBuffer:h,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(e),l=sn(u),c=en(s);let d,_=!1;l>=c?(t(null!==this.m_curveData),_=!0,d=this.m_curveData.m_segmentParamIndex.read(e)):(this.initSegmentData(c),_=!1,d=this.m_curveData.m_curveParamWritePoint);const g=s.getGeometryType(),p=mn.toSegType(g);i||(s.queryStart(m),this.setPointByVal(e,m),s.queryEnd(m),this.setPointByVal(o,m)),this.m_curveData.m_segmentParamIndex.write(e,1!==p?d:-1),this.m_curveData.m_segmentFlags.write(e,p),1!==p&&nn(this.m_curveData.m_segmentParams,d,s),_||(this.m_curveData.m_curveParamWritePoint+=c),u!==p&&(this.incCurveType(u,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===u?1:-1))}verifyPathIndex(e){t(0)}setAttributeImpl(e,s,i){t(0)}}un.st_totalCurveCount=0;class ln{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_extentOfInterest=new ps(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){this.m_parent.getAccelerators(),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){return t(0),"not implemented"}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=ps.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class cn{constructor(t){void 0===t?this.setIdentity():t instanceof cn?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 cn).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(e){return t(0),!1}transformInPlace(t){const e=this.xx*t.x+this.xy*t.y+this.xd,s=this.yx*t.x+this.yy*t.y+this.yd;t.x=e,t.y=s}transform(e){return t(0),_s.getNAN()}queryTransform(t,e){const s=this.xx*t.x+this.xy*t.y+this.xd,i=this.yx*t.x+this.yy*t.y+this.yd;e.setCoords(s,i)}transformEnvInPlace(e){t(0)}queryTransformEnv(e,s){t(0)}transformInterleaved(e,s,i){t(0)}transformPoints(t,e,s){for(let i=0;i<e;++i)this.queryTransform(t[i],s[i])}transformInterleavedPoints(t,e,s){e*=2;const i=_s.getNAN();for(let n=0;n<e;n+=2)i.x=t[n],i.y=t[n+1],this.transformInPlace(i),s[n]=i.x,s[n+1]=i.y}multiply(t){return cn.st_multiply(this,t,this),this}mulLeft(e){return t(0),this}static st_multiply(t,e,s){const i=t.xx*e.xx+t.yx*e.xy,n=t.xy*e.xx+t.yy*e.xy,r=t.xd*e.xx+t.yd*e.xy+e.xd,o=t.xx*e.yx+t.yx*e.yy,a=t.xy*e.yx+t.yy*e.yy,h=t.xd*e.yx+t.yd*e.yy+e.yd;s.xx=i,s.xy=n,s.xd=r,s.yx=o,s.yy=a,s.yd=h}getCoefficients(e){t(0)}setCoefficients(t){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(e){t(0)}initializeFromRect(e,s){t(0)}initializeFromRectIsotropic(e,s){t(0)}initializeFromCurveParameters(e,s,i){t(0)}initializeFromTwoPointsArray(t,e){if(t[0].equals(e[0])&&t[1].equals(e[1]))return void this.setIdentity();if(t[0].equals(t[1])){if(e[0].equals(e[1]))return void this.setShift(e[0].sub(t[0]));f("")}if(!t[0].equals(t[1])&&e[0].equals(e[1]))return this.setZero(),void this.shift(e[0]);this.setShiftCoords(-t[0].x,-t[0].y);const s=_s.distance(t[0],t[1]),i=_s.distance(e[0],e[1]),n=i/s;this.scale(n,n);const r=t[1].sub(t[0]);r.divThis(s);const o=e[1].sub(e[0]);o.divThis(i);const a=r.crossProduct(o),h=r.dotProduct(o);this.rotate(h,a),this.shiftCoords(e[0].x,e[0].y)}initializeFromTwoPoints(t,e,s,i){const n=[t,e],r=[s,i];this.initializeFromTwoPointsArray(n,r)}transformSizeInPlace(e){t(0)}transformSize(e,s){t(0)}transformTol(e){return t(0),0}transformWithoutTranslateArray(e,s,i){t(0)}transformWithoutTranslateInPlace(t){const e=this.xx*t.x+this.xy*t.y,s=this.yx*t.x+this.yy*t.y;t.setCoords(e,s)}transformWithoutTranslate(e,s){t(0)}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(e){return t(0),!1}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(e){return t(0),!1}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return t(0),!1}isTranslateTol(e){return t(0),!1}isOrthonormal(e){return t(0),!1}isDegenerate(e){return t(0),!1}isZero(){return t(0),!1}isScaleAndTranslate(e){return t(0),!1}setTranslate(e,s){return t(0),this}setShiftCoords(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,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,e){return this.xx=t,this.xy=0,this.xd=0,this.yx=0,this.yy=e,this.yd=0,this}setScale(t){return this.setScaleCoords(t,t),this}setFlipX(e,s){return t(0),this}setFlipY(e,s){return t(0),this}setShear(e,s){return t(0),this}scale(t,e){return this.xx*=t,this.xy*=t,this.xd*=t,this.yx*=e,this.yy*=e,this.yd*=e,this}setRotateAngle(t){return this.setRotate(Math.cos(t),Math.sin(t))}setRotate(t,e){return this.xx=t,this.xy=-e,this.xd=0,this.yx=e,this.yy=t,this.yd=0,this}setRotateAngleAbout(e,s){return t(0),this}setRotateAbout(e,s,i){return t(0),this}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return t(0),this}setRotateCcw90(){return t(0),this}shiftCoords(t,e){return this.xd+=t,this.yd+=e,this}shift(t){return this.xd+=t.x,this.yd+=t.y,this}translate(t,e){return this.xd+=t,this.yd+=e,this}flip_x(e,s){return t(0),this}flip_y(e,s){return t(0),this}shear(e,s){return t(0),this}rotateAngle(t){const e=new cn;return e.setRotateAngle(t),this.multiply(e)}rotate(t,e){const s=new cn;return s.setRotate(t,e),this.multiply(s)}rotateAbout(e,s,i){return t(0),this}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 e=(this.xy*this.yd-this.xd*this.yy)*t,s=(this.xd*this.yx-this.xx*this.yd)*t,i=this.yy*t,n=-this.xy*t,r=-this.yx*t,o=this.xx*t;return this.xd=e,this.yd=s,this.xx=i,this.yy=o,this.xy=n,this.yx=r,this}invertPrecise(t){return this.set(t),this.invertPreciseThis()}invertPreciseThis(){return t(0),this}extractScaleTransform(e,s){t(0)}setFromTwoTriangles(t,e){let s=!0;for(let m=0;m<3;++m)s=s&&t[m].equals(e[m]);if(s)return this.setIdentity(),!0;const i=new _s;i.setSub(t[0],t[1]);const n=new _s;n.setSub(t[0],t[2]);const r=new _s;r.setSub(e[0],e[1]);const o=new _s;o.setSub(e[0],e[2]);const a=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(n.x*i.y));let h=i.x*n.y-i.y*n.x;return Math.abs(h)>a?(h=1/h,this.xx=(r.x*n.y-i.y*o.x)*h,this.xy=(i.x*o.x-r.x*n.x)*h,this.yx=(r.y*n.y-i.y*o.y)*h,this.yy=(i.x*o.y-r.y*n.x)*h,this.xd=e[0].x-(this.xx*t[0].x+this.xy*t[0].y),this.yd=e[0].y-(this.yx*t[0].x+this.yy*t[0].y),!0):(this.setZero(),!1)}}class dn extends bi{constructor(t){super(t)}assignCopy(e){return t(0),this}assignMove(e){return t(0),this}insertPoint2D(e,s){t(0)}insertPoint(e,s){t(0)}insertPoints(e,s,i){t(0)}insertPoints2D(e,s,i){t(0)}removePoints(e,s){t(0)}removePoint(e){t(0)}calculateEnvelope2D(){return t(0),new ps(0,0,0,0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s),i=Ft.getDefaultValue(t),n=Ft.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(n*e,i,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(e,s,i,n){return t(0),0}getAttributeAsDbl(e,s,i){return t(0),0}getAttributeAsInt(e,s,i){return t(0),0}queryAttributeAsInt(e,s,i,n){t(0)}setAttribute(e,s,i,n){t(0)}add(t){t.isEmpty()&&f(Pi),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByVal(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new _s(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(e,s,i){t(0)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){}addPoints(t,e,s){this===t&&f("Multi_point_impl.add");const i=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||i<e)&&f(""),e===i)return;const n=t.getDescription();this.mergeVertexDescription(n);const r=i-e,o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+r);for(let a=0,h=this.m_description.getAttributeCount();a<h;a++){const s=this.m_description.getSemantics(a),i=Ft.getComponentCount(s),h=this.getAttributeStreamRef(s);if(n.hasAttribute(s)){const n=t.getAttributeStreamRef(s);h.insertRangeFromStream(o*i,n,e*i,r*i,!0,1,o*i)}else{const t=Ft.getDefaultValue(s);h.insertRange(o*i,t,r*i,o*i)}}}addPoints2D(t,e,s,i){let n=e;const r=i<0?n:i;if((n<0||s<0||s>n||r<s)&&f(""),s===r)return;n=r-s;const o=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+n);const a=this.getAttributeStreamRef(0);for(let h=0;h<n;++h)a.writePoint2D(2*(o+h),t[s+h]);this.notifyModifiedFlags(2001)}addPoints3D(e,s,i,n){t(0)}getGeometryType(){return r.enumMultiPoint}getDimension(){return 0}createInstance(){return new dn({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(e){if(this.isEmpty())return;if(e.isIdentity())return;const s=this.m_vertexAttributes.get(0);e instanceof cn?s.applyTransformation(e,0,this.m_pointCount):t(0),this.notifyModifiedFlags(2001)}calculateArea2D(){return t(0),0}calculateLength2D(){return t(0),0}calculateLength3D(e){return t(0),0}equals(t,e){return t.getGeometryType()===r.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(e){e instanceof Cs?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,e)):e instanceof ps?this.updateEnvelope(e):t(0)}queryInterval(e,s){return t(0),new Qt(0,0)}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}capacity(){return t(0),0}clone(){return t(0),this}swap(e){t(0)}setAttributeBasic(e,s,i){t(0)}buildRasterizedGeometryAccelerator(e,s){return t(0),!1}buildQuadTreeAccelerator(e){return t(0),!1}getHashCodeImpl(){return t(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}dn.type=r.enumMultiPoint;class _n{isIdentity(){return t(0),!0}}class gn{constructor(){this.m_factor=1,this.m_wkid=9001}getUnitType(){return 0}convertFromMeters(t){return t/this.getUnitToBaseFactor()}convertToMeters(t){return t*this.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getName(){return""}getDisplayName(){return""}getPluralDisplayName(){return""}getID(){return 0}getConversionFactor(t){return 1}getAbbreviation(){return""}equals(t){return!1}}class pn{constructor(t,e=!0){this.m_csType=0,this.m_PCSHorizon=null,this.m_GCSHorizon=null,this.m_GCSSplitLines=null,this.m_GCSHorisonIsInclusive=!1,this.m_oneMeterPCS=1,this.m_oneDegreeGCS=1,this.m_gcsUnitFactor=0,this.m_northPole=_s.getNAN(),this.m_southPole=_s.getNAN(),this.m_polesUpdated=0,this.m_domain=ps.constructEmpty(),this.m_primeMeridian=Number.NaN,this.m_geogToProjFactor=1,this.m_geogToProjOffset=0,this.m_geogToProjFactorsUpdated=0,this.m_oneMillimeter=0,this.m_centralMeridian=0,this.m_pPCSInfoNoDomain=null,this.m_WKID=-1,this.m_oldWKID=-1973,this.m_vcsWKID=-1,this.m_bIsPannable=!1,this.m_cached=!1,this.m_pannableExtent=ps.constructEmpty(),this.m_pannableExtentGCS=ps.constructEmpty(),this.m_unit=new gn,this.m_areaOfUse=null,this.m_canonicalWkt="not yet implemented",this.m_PECoordSys=t}getPCSHorizonPannable(){return{}}getGCSHorizonPannable(){return{}}updateGCSHorizon(){}updateAreaOfUse(){return{}}updatePCSHorizon(){}updatePannableExtent(){}updatePannableExtentGCS(){}updateDomain(){}updatePoles(){}updateGeogToProjFactors(){}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return 0}getUnitsPerMillimeter(){return this.m_oneMillimeter}getCentralMeridian(){return 0}get_GCS_split_lines(){return{}}getGCSHorizon(){return{}}getGCSHorisonIsInclusive(){return!1}getPCSHorizon(){return{}}getPole(t){return new _s}getGeogToProjFactors(){return{}}getDomainXY(){if(this.m_bIsPannable)return this.m_domain;let t=!1;return t=this.m_domain.isEmpty(),t&&this.updateDomain(),this.m_domain}getPCSInfo(){return{}}getPrimeMeridian(){return 0}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;return t<0&&(t=0,this.m_WKID>0&&(t=this.m_WKID),this.m_oldWKID=t),t}isCustomWkid(){return!1}isPannable(){return!1}getPannableExtent(){return{}}getPannableExtentGCS(){return{}}getAreaOfUse(){return{}}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_cached=!0}getCached(){return this.m_cached}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}class fn{constructor(t,e=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new gn,this.m_cached=!1}setCached(t=!0){this.m_cached=t}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;return t<0&&(t=0,this.m_WKID>0&&(t=this.m_WKID),this.m_oldWKID=t),t}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}const xn=new Map;function yn(t){t<=0&&I(t);{const e=bn(t);if(e)return e}const e=new pn({},!0);return e.m_WKID=t,e.m_csType=t===qn.GCS_WGS_1984?1:2,xn.set(t,new WeakRef(e)),e}function vn(t){const e=new fn({},!0);return e.m_WKID=t,e}function Pn(t){return t>0}function bn(t){const e=xn.get(t);if(e)return e.deref()}function En(t){const e=vn(t),s=new Dn;return s.setVertProj_(e),s}function Cn(t){return Pn(t)}class Dn{constructor(){this.m_hashCode=0,this.m_PEVertSysVal=null,this.m_verticalUnit=new gn,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return 0}getID(){return 0}getLatestID(){return this.m_PEVertSysVal?this.m_PEVertSysVal.getLatestID():0}getOldID(){return this.m_PEVertSysVal?this.m_PEVertSysVal.getOldID():0}getText(){return""}getTextExtended(t){return""}getText2(t){return""}getUnit(){return t(0),{}}equals(t){return!1}getPeVertcsCopy(){return{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return 0}isDepth(){return!1}getVerticalShift(){return 0}isCustomWkid(){return!!this.m_PEVertSysVal&&this.m_PEVertSysVal.isCustomWkid()}setVertProj_(t){this.m_PEVertSysVal=t}}const Sn=2147483645n,wn=9007199254740990n,An=1,Tn=2;var In;function Nn(t,e,s){return Wn(t,0,null,!1)}function Mn(t,e){return{}}!function(t){t[t.utmDefault=0]="utmDefault",t[t.utmNorthSouth=1]="utmNorthSouth"}(In||(In={}));class qn{constructor(){this.m_vertcs=null,this.m_PECoordSysVal=null,this.m_unit=null,this.m_userWKID=-1,this.m_geogSpatialReferenceInitialized=0,this.m_geogSpatialReference=null,this.m_srToGcs=null,this.m_gcsToSr=null,this.m_defaultPrecisionSr=null,this.m_localZToXYFactor=Number.NaN,this.m_precisionDescriptor=new Rn,this.m_hashCode=0,this.m_defaultDescriptor=!1,this.m_precisionDescriptor=new Rn,this.m_localZToXYFactor=-1,this.m_userWKID=0,Bn(this.m_precisionDescriptor),this.m_hashCode=0,this.m_defaultDescriptor=!1,this.m_geogSpatialReferenceInitialized=0}calculateHashCode(){}initDbgName(){}setHorzProj_(t){this.m_PECoordSysVal=t,this.m_unit=this.m_PECoordSysVal.getUnit()}getTolerance(t=0){return this.m_precisionDescriptor.getTolerance(t)}getResolution(t){return this.m_precisionDescriptor.getResolution(t)}getCoordinateSystemType(){return 4326===this.m_PECoordSysVal?.m_WKID?1:2}getID(){return 0}getLatestID(){return this.m_PECoordSysVal?this.m_PECoordSysVal.getLatestID():0}getOldID(){return this.m_PECoordSysVal?this.m_PECoordSysVal.getOldID():0}getVerticalID(){return 0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return 0}getText(){return""}getTextExtended(t){return""}getText2(t=-1){return""}getUnit(){return{}}getAuthorityName(){return""}getVerticalUnit(){return{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCS(){return{}}toMilitaryGrid(t,e,s,i,n){return[]}fromMilitaryGrid(t,e){return[]}toUnitedStatesNationalGrid(t,e,s,i){return[]}fromUnitedStatesNationalGrid(t){return[]}toUniversalTransverseMercator(t,e,s){return[]}fromUniversalTransverseMercator(t,e){return[]}toWorldGeographicReference(t,e,s){return[]}fromWorldGeographicReference(t){return[]}toGlobalArea(t){return[]}fromGlobalArea(t,e){return[]}toDegreeMinuteSecond(t,e){return[]}fromDegreeMinuteSecond(t){return[]}toDegreeDecimalMinute(t,e){return[]}fromDegreeDecimalMinute(t){return[]}toDecimalDegree(t,e){return[]}fromDecimalDegree(t){return[]}fromGeohashToGCSEnvelope(t){return{}}toGeohash(t,e){return""}calculateContainingGeohash(t){return"1;"}calculateCoveringGeohashes(t,e){return[]}calculateGeohashNeighbours(t){return[]}calculateGeohashNeighbour(t,e,s){return""}isPannable(){return!1}getPannableExtent(){return{}}getFullWorldExtent(){return{}}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX))if(t(null!==this.m_PECoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_PECoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(t){}equals(t){return!1}equalHorizontal(t){return!1}equalVertical(t){return!1}equalVerticalVCS(t){return!1}convergenceAngle(t){return 0}getPeCoordsysCopy(){return 0}getPeVertcsCopy(){return 0}getSRToGCSTransform(){return{}}getGCSToSRTransform(){return{}}getOneMeter(){return 0}querySpheroidData(t){}getAreaOfUse(){return{}}getZToXyFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return 1}getGcsUnitFactor(){return 1}snapGeometry(t){if(t.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const e=t.getGeometryType();if(l(e))return this.snapMultiVertex_(t);if(e===r.enumPoint)return this.snapPoint_(t);if(e===r.enumEnvelope)return this.snapEnvelope_(t);if(u(e))return this.snapSegment_(t);if(e===r.enumGeometryCollection){const e=t;let s=!1;for(let t=0,i=e.getGeometryCount();t<i;++t)s=this.snapGeometry(e.getGeometry(t))||s;return s}E("what else?")}snapMultiVertex_(e){if(t(!e.isEmpty()),t(2!==this.m_precisionDescriptor.getPrecision()),c(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const s=e.getImpl(),i=s.getDescription();let n=!1;for(let t=0,r=i.getAttributeCount();t<r;t++){const e=i.getSemantics(t),r=s.getAttributeStreamRef(e);n=this.snapAttributes(e,r,0,s.getPointCount())||n}return n&&s.notifyModifiedFlags(2001),n}snapPoint_(t){return!1}snapEnvelope_(t){return!1}snapSegment_(t){return!1}snapGeometryWithCurves_(t){return!1}snapAttributes(t,e,s,i){let n=!1;const r=new Rn;if(this.queryPrecisionDescriptor(r),0===t){const t=e;for(let e=s;e<i;e++){const s=t.read(2*e),i=qn.s_SnapValue(s,r.getFalseX(),r.getGridUnitsXy()),o=t.read(2*e+1),a=qn.s_SnapValue(o,r.getFalseY(),r.getGridUnitsXy());n=n||i!==s||a!==o,n&&(t.write(2*e,i),t.write(2*e+1,a))}}else if(1===t){const t=e;for(let e=s;e<i;e++){const s=t.read(e),i=qn.s_SnapValue(s,r.getFalseZ(),r.getGridUnitsZ());n=n||!H(i,s),n&&t.write(e,i)}}else if(2===t){const t=e;for(let e=s;e<i;e++){const s=t.read(e),i=qn.s_SnapValue(s,r.getFalseM(),r.getGridUnitsM());n=n||!H(i,s),n&&t.write(e,i)}}return n}static s_SnapValue(t,e,s){return he((t-e)*s)/s+e}}qn.GCS_WGS_1984=4326,qn.PCS_WGS_1984_WEB_MERCATOR_AUXSPHERE=3857,qn.c_suLimit32=2147483645n,qn.c_suLimit64=9007199254740990n;class Rn{constructor(){const t=wn,e=1e-4,s=.001,i=e*Number(t)*.5;this.m_precision=1,this.m_falseX=-i,this.m_falseY=-i,this.m_unitsXY=Number(t)/(2*i),this.m_falseM=-1e5,this.m_unitsM=1/e,this.m_falseZ=-1e5,this.m_unitsZ=1/e,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}clone(){const t=new Rn;return t.m_falseX=this.m_falseX,t.m_falseY=this.m_falseY,t.m_unitsXY=this.m_unitsXY,t.m_falseZ=this.m_falseZ,t.m_unitsZ=this.m_unitsZ,t.m_falseM=this.m_falseM,t.m_unitsM=this.m_unitsM,t.m_toleranceXY=this.m_toleranceXY,t.m_toleranceZ=this.m_toleranceZ,t.m_toleranceM=this.m_toleranceM,t.m_precision=this.m_precision,t}assign(t){return this.m_falseX=t.m_falseX,this.m_falseY=t.m_falseY,this.m_unitsXY=t.m_unitsXY,this.m_falseZ=t.m_falseZ,this.m_unitsZ=t.m_unitsZ,this.m_falseM=t.m_falseM,this.m_unitsM=t.m_unitsM,this.m_toleranceXY=t.m_toleranceXY,this.m_toleranceZ=t.m_toleranceZ,this.m_toleranceM=t.m_toleranceM,this.m_precision=t.m_precision,this}initialize2D(t,e){}getTolerance(t){switch(t){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(t){if(2===this.m_precision)return 0;switch(t){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXy(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){return{}}getZGridRange(){return{}}getMGridRange(){return{}}setTolerance(t,e){}setGridParams(t,e,s){}setZParams(t,e){}setMParams(t,e){}setPrecision(t){}equals(t){return!1}snapPrecision(){if(2===this.m_precision)return;const t=(t,e,s,i)=>{if(!Number.isFinite(e)||!Number.isFinite(s))return s;if(s<1)return 1;if(!i)return s;const n=Number(t)/s;return Math.trunc((e+n-e)*s)>t&&(s=t/(e+n-e)),Math.max(1,s)},e=Number(0===this.m_precision?qn.c_suLimit32:qn.c_suLimit64);this.m_unitsXY=t(e,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=t(e,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=t(e,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=t(e,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const t=(t,e,s,i)=>{if(s<1)return!1;if(!Number.isFinite(e)||!Number.isFinite(s))return!1;if(!i)return!0;const n=Number(t)/s;return!(BigInt((e+n-e)*s)>t)},e=0===this.m_precision?Sn:wn;return!!t(e,this.m_falseX,this.m_unitsXY,!0)&&(!!t(e,this.m_falseY,this.m_unitsXY,!0)&&(!!t(e,this.m_falseZ,this.m_unitsZ,!1)&&!!t(e,this.m_falseM,this.m_unitsM,!1)))}fixTolerance(){}equalsWithoutFalseXY(t){return!1}setBestXyDomainFromEnvelope(t,e){}setBestZDomainFromZRange(t,e,s){}setBestMDomainFromMRange(t,e,s){}}let Fn=null;function Yn(){return Fn=Wn(3857,0,null,!0),Fn}let Xn=null;function Ln(){return Xn=Wn(102100,0,null,!0),Xn}let zn=null;function Vn(){return zn=Wn(4326,0,null,!0),zn}function Bn(t){t.m_falseX=0,t.m_falseY=0,t.m_unitsXY=1,t.m_falseZ=0,t.m_unitsZ=1,t.m_falseM=0,t.m_unitsM=1,t.m_toleranceXY=100*yt(),t.m_toleranceZ=100*yt(),t.m_toleranceM=100*yt(),t.m_precision=2}function kn(t,e,s,i){Bn(t),t.m_precision=i,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const n=1e-4,r=.001,o=1===e.m_csType?An:Tn;if(o===An){const s=1e-9*e.getOneDegreeGCSUnit();t.m_unitsXY=1/s}else if(o===Tn){const s=n*e.getOneMeterPCSUnit();t.m_unitsXY=1/s}t.m_falseM=-1e5,t.m_unitsM=1/n,t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let a=0,h=0;a=2/t.m_unitsXY,h=2/t.m_unitsM,t.m_toleranceXY=Math.max(a,e.getUnitsPerMillimeter()),t.m_toleranceM=Math.max(r,h),Gn(t,s)}function Gn(t,e){const s=1e-4,i=.001;if(t.m_falseZ=-1e5,e){const n=(0===t.m_precision?i:s)*e.getOneMeter();t.m_unitsZ=1/n}else t.m_unitsZ=1/(0===t.m_precision?i:s);t.m_unitsZ=Math.max(1,t.m_unitsZ);let n=0;0!==t.m_precision&&1!==t.m_precision||(n=2/t.m_unitsZ),t.m_toleranceZ=Math.max(e?e.getOneMeter()*i:i,n)}function Wn(t,e,s,i){if(!i&&0===e&&!s){if(3857===t)return Yn();if(102100===t)return Ln();if(4326===t)return Vn()}const n=yn(t);e<=0&&Cn(t)&&(e=t);let r=null;e>0?r=En(e):e=0;const o=new qn;return o.setHorzProj_(n),o.m_vertcs=r,kn(o.m_precisionDescriptor,n,r,1),o.m_defaultDescriptor=!0,o.m_userWKID=t,o.calculateHashCode(),o.initDbgName(),o}var Zn=Ft;class Hn{constructor(e){this.m_attributes=null,this.m_description=void 0!==e.vd?e.vd:vs.getDefaultDescription2D();const s=this.m_description.getTotalComponentCount()-2;s&&(this.m_attributes=new Array(2*s)),void 0!==e.XStart?(this.m_XStart=e.XStart,this.m_YStart=e.YStart,this.m_XEnd=e.XEnd,this.m_YEnd=e.YEnd):void 0!==e.start?(this.m_XStart=e.start.x,this.m_YStart=e.start.y,this.m_XEnd=e.end.x,this.m_YEnd=e.end.y):void 0!==e.move?(this.m_description=e.move.m_description,this.m_attributes=e.move.m_attributes,e.move.m_attributes=null,this.m_XStart=e.move.m_XStart,this.m_YStart=e.move.m_YStart,this.m_XEnd=e.move.m_XEnd,this.m_YEnd=e.move.m_YEnd):void 0!==e.copy?(this.m_description=e.copy.m_description,e.copy.m_attributes&&(this.m_attributes=e.copy.m_attributes.slice()),this.m_XStart=e.copy.m_XStart,this.m_YStart=e.copy.m_YStart,this.m_XEnd=e.copy.m_XEnd,this.m_YEnd=e.copy.m_YEnd):(t(0),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN)}transformAttribute(e,s,i,n,r){t(0)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=vs.getMergedVertexDescription(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let r=1,o=n.getAttributeCount();r<o;r++){const s=n.getSemantics(r),i=Zn.getComponentCount(s);for(let n=0;n<i;n++){Oi(this,0,s,n,t.getAttributeAsDbl(s,n));Oi(this,1,s,n,e.getAttributeAsDbl(s,n))}}}getStartXY(){return new _s(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return t(0),new gs(0,0,0)}setStartXYZ(e){t(0)}setStartXYZCoords(t,e,s){Gi(this,0,gs.construct(t,e,s))}queryStart(t){Wi(this,0,t)}setStart(t){Zi(this,0,t)}setStart2D(e){t(0)}getStartAttributeAsDbl(t,e){return Hi(this,0,t,e)}getStartAttributeAsInt(e,s){return t(0),0}setStartAttribute(t,e,s){Oi(this,0,t,e,s)}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndXY(){return new _s(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return t(0),new gs(0,0,0)}setEndXYZ(e){t(0)}setEndXYZCoords(t,e,s){Gi(this,1,gs.construct(t,e,s))}queryEnd(t){Wi(this,1,t)}setEnd(t){Zi(this,1,t)}setEnd2D(e){t(0)}getEndAttributeAsDbl(t,e){return Hi(this,1,t,e)}getEndAttributeAsInt(e,s){return t(0),Math.trunc(0)}setEndAttribute(t,e,s){Oi(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&f("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&Oe(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=Qt.constructEmpty();return s.vmin=Hi(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(Hi(this,1,t,e)),s}calculateLength3D(e){return t(0),0}getCoord2D(t){const e=_s.getNAN();return this.queryCoord2D(t,e),e}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=Zn.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=ps.constructEmpty();this.queryLooseEnvelopeOnInterval(e,i);if(i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&_s.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=je(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=je(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=Zn.getComponentCount(e);t<s;t++){const s=Hi(this,0,e,t);Oi(this,0,e,t,Hi(this,1,e,t)),Oi(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(e,s,i){return t(0),0}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return pe(t,e,s)}moveTo(e){t(0)}moveTo3D(e){t(0)}getDescription(){return this.m_description}assignVertexDescription(t){Ui(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=vs.removeSemanticsFromVertexDescription(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=vs.getDefaultDescription2D();t!==this.m_description&&this.assignVertexDescription(t)}swap(e){t(0)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let n=0,r=2*(this.m_description.getTotalComponentCount()-2);n<r;n++)if(!O(this.m_attributes[n],i.m_attributes[n],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(e,s,i){t(0)}replaceNaNs(e,s){t(0)}}function On(t,e,s){jn(e,t.getStartXY(),t.getEndXY(),s)}function jn(t,e,s,i){ye(e,s,t,i)}function Un(t,e){return pe(t.m_XStart,t.m_XEnd,e)}function Qn(t,e){return pe(t.m_YStart,t.m_YEnd,e)}function Kn(t,e,s){const i=Ai.constructPoint2D(t.getStartXY()),n=Ai.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}function $n(t,e,s){e.value()<=.5?_e(2,Ai.constructPoint2D(t.getStartXY()),Ai.constructPoint2D(t.getEndXY()),e,s):ge(2,Ai.constructPoint2D(t.getStartXY()),Ai.constructPoint2D(t.getEndXY()),e,s)}function Jn(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function tr(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=je(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=je(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=je(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function er(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:rr(t,e)?4:0}function sr(t,e,s,i,n,r,o,a){null!==i&&(i.length=2),null!==n&&(n.length=2),null!==s&&(s.length=2);const h=ir(t,e,2,s,i,n,r,o,a);return i&&(i.length=h),n&&(n.length=h),s&&(s.length=h),h}function ir(t,e,s,i,n,r,o,a,h){const m=or(t,e.getStartXY(),o,!1),u=or(t,e.getEndXY(),o,!1),l=or(e,t.getStartXY(),o,!1),c=or(e,t.getEndXY(),o,!1);let d=0,_=0;if(!Number.isNaN(m)){let s=!1;a&&vt(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(n&&(n[_]=m),r&&(r[_]=0),i&&(i[_]=_s.construct(e.m_XStart,e.m_YStart)),_++)}if(!Number.isNaN(u)){let o=!1;a&&vt(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(d++,o=!0),o||(s>_&&(n&&(n[_]=u),r&&(r[_]=1),i&&(i[_]=_s.construct(e.m_XEnd,e.m_YEnd))),_++)}if(2!==_&&!Number.isNaN(l)&&!(0===m&&0===l||0===u&&1===l)){let o=!1;a&&vt(l,0,1)&&e.getCoord2D(l).isEqualPoint2D(t.getStartXY())&&(d++,o=!0),o||(s>_&&(n&&(n[_]=0),r&&(r[_]=l),i&&(i[_]=_s.construct(t.m_XStart,t.m_YStart))),_++)}if(2!==_&&!Number.isNaN(c)&&!(1===m&&0===c||1===u&&1===c)){let o=!1;a&&vt(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(d++,o=!0),o||(s>_&&(n&&(n[_]=1),r&&(r[_]=c),i&&(i[_]=_s.construct(e.m_XEnd,e.m_YEnd))),_++)}if(_>0)return h&&(r=je(n,n=r)),2===_&&s>=2&&n&&n[0]>n[1]&&(n[1]=je(n[0],n[0]=n[1]),r&&(r[1]=je(r[0],r[0]=r[1])),i&&(i[1]=je(i[0],i[0]=i[1]))),_;if(d>0)return 0;const g=lr(t,e,o);return Number.isNaN(g.x)?0:(i&&(i[0]=t.getCoord2D(g.x)),n&&(n[0]=g.x),r&&(r[0]=g.y),1)}function nr(t,e,s){const i=lr(t,e,0);return Number.isNaN(i.x)?0:(s[0]=t.getCoord2D(i.x),1)}function rr(t,e){const s=ar(t,e.m_XStart,e.m_YStart),i=ar(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=ar(e,t.m_XStart,t.m_YStart),r=ar(e,t.m_XEnd,t.m_YEnd);if(n<0&&r<0||n>0&&r>0)return!1;return ur(t)>ur(e)?mr(t,e):mr(e,t)}function or(t,e,s,i){const n=_s.getNAN(),r=_s.getNAN();let o=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(n.setCoords(t.m_XEnd,t.m_YEnd),r.setCoords(t.m_XStart,t.m_YStart),o=!0):(n.setCoords(t.m_XStart,t.m_YStart),r.setCoords(t.m_XEnd,t.m_YEnd));const a=o?1:0,h=o?0:1,m=_s.getNAN();m.setSub(e,n);let u=m.length(),l=3*u*yt();if(u<=Math.max(s,l))return i&&0===u?Number.NaN:a;if(m.setSub(e,r),u=m.length(),l=3*u*yt(),u<=Math.max(s,l))return i&&0===u?Number.NaN:h;m.setCoords(r.x-n.x,r.y-n.y);const c=m.length();if(c>0){const t=1/c;m.scale(t);const i=_s.getNAN();i.setSub(e,n);const u=i.dotProduct(m),l=8*i.dotProductAbs(m)*yt();m.leftPerpendicularThis();const d=i.dotProduct(m),_=8*i.dotProductAbs(m)*yt(),g=Math.max(s,l);if(u<-g||u>c+g)return Number.NaN;const p=Math.max(s,_);if(Math.abs(d)<=p){let i=u*t;i=Pt(i,0,1);const m=_s.getNAN();if(jn(i,n,r,m),_s.distance(m,e)<=s){if(i<.5){if(_s.distance(m,n)<=s&&_s.distance(e,n)<=s)return a}else if(_s.distance(m,r)<=s&&_s.distance(e,r)<=s)return h;return o?1-i:i}}}return Number.NaN}function ar(t,e,s){const i=_s.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=_s.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const r=n.crossProduct(i),o=4*yt()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?-1:r<-o?1:0}function hr(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,r=i?t.m_YStart:t.m_YEnd,o=_s.getNAN();o.x=e.getEndX()-n,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*yt()*s.dotProductAbs(o)){o.x=e.getStartX()-n,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*yt()*s.dotProductAbs(o)}return!0}function mr(t,e){const s=_s.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!hr(t,e,s,!1)&&(s.negateThis(),!!hr(t,e,s,!0))}function ur(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function lr(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*n-i*o;if(0===a)return _s.getNAN();const h=4*yt()*(Math.abs(r*n)+Math.abs(i*o)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,l=r*u-m*o,c=4*yt()*(Math.abs(r*u)+Math.abs(m*o)),d=l/a,_=Math.abs(a),g=(c*_+h*Math.abs(l))/(a*a)+yt()*Math.abs(d);if(d<-g||d>1+g)return _s.getNAN();const p=i*u-m*n,f=p/a,x=(4*yt()*(Math.abs(i*u)+Math.abs(m*n))*_+h*Math.abs(p))/(a*a)+yt()*Math.abs(f);if(f<-x||f>1+x)return _s.getNAN();let y=Pt(d,0,1),v=Pt(f,0,1);const P=_s.getNAN();On(t,y,P);const b=_s.getNAN();if(On(e,v,b),!s||_s.distance(P,b)>s){const i=_s.getNAN();ye(P,b,.5,i),y=t.getClosestCoordinate(i,!1),v=e.getClosestCoordinate(i,!1);const n=_s.getNAN();On(t,y,n);const r=_s.getNAN();On(e,v,r),n.subThis(r);const o=n.length(),a=(t.absNorm()+e.absNorm())*pt();if(o>Math.max(s,a))return _s.getNAN()}return new _s(y,v)}Hn.s_maxMonotonicPartParams=8;class cr extends un{constructor(e){e?e.vd?(super({vd:e.vd,bPolygon:!1}),this.m_segmentBufferCTor=xl):e.copy?(super({vd:e.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=xl,e.copy.copyTo(this)):e.move?(super({move:e.move}),this.m_segmentBufferCTor=xl):e.start?(super({vd:e.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=xl,this.startPathPoint(e.start),this.lineToPoint(e.end)):e.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=xl,this.addPathPoint2D(e.path,e.pointCount,e.bForward)):t(0):(super({bPolygon:!1}),this.m_segmentBufferCTor=xl)}getBoundary(){return gr(this)}buildRasterizedGeometryAccelerator(e,s){return t(0),!1}buildQuadTreeAccelerator(e){return t(0),!1}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(e){return t(0),this}getGeometryType(){return cr.type}getDimension(){return 1}createInstance(){return new cr({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}cr.type=r.enumPolyline;var dr=r;function _r(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===dr.enumPolygon)return 0!==t.calculateArea2D();if(s===dr.enumPolyline)return pr(t.getImpl(),e,!0).bNotEmpty;if(s===dr.enumEnvelope)return!0;if(u(s))return!!t.isClosed();if(h(s))return!1;if(s===dr.enumGeometryCollection){const s=t;for(let t=0,i=s.getGeometryCount();t<i;t++)if(_r(s.getGeometry(t),e))return!0;return!1}P("")}function gr(t,e){const s=t.getGeometryType();if(s===dr.enumPolygon){const e=new cr({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===dr.enumPolyline)return pr(t.getImpl(),e,!1).boundary;if(s===dr.enumEnvelope){const e=new cr({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(u(s)){const e=new dn({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new Ci;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===dr.enumGeometryCollection){const s=t;let i=null;for(let n=0,r=s.getGeometryCount();n<r;n++){const r=gr(s.getGeometry(n),e);if(null!==r){null===i&&(i=t.createInstance());const e=r;i.addGeometry(e)}}return i}if(h(s))return new Ci({vd:t.getDescription()});P("")}function pr(t,e,s){const i=!1,n=t;let r=null;if(s||(r=new dn({vd:n.getDescription()})),!n.isEmpty()){const t=new Fs(0);for(let e=0,s=n.getPathCount();e<s;e++){if(n.getPathSize(e)>0&&!n.isClosedPathInXYPlane(e)){const s=n.getPathStart(e);t.add(s);const i=n.getPathEnd(e)-1;t.add(i)}}if(t.size()>0){const e=new Hs,i=n.getAttributeStreamRef(0),o={userSort(t,e,s){const n=_s.getNAN(),r=_s.getNAN();s.sort(t,e,((t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,r),n.compare(r))))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),o);let a=i.readPoint2D(2*t.read(0)),h=0,m=1;const u=new Ci;for(let n=1,r=t.size();n<r;n++){const e=i.readPoint2D(2*t.read(n));if(e.isEqualPoint2D(a))t.read(h)>t.read(n)?(t.write(h,Q()),h=n):t.write(n,Q()),m++;else{if(1&m){if(s)return{bNotEmpty:!0,boundary:new dn({})}}else t.write(h,Q());a=e,h=n,m=1}}if(1&m){if(s)return{bNotEmpty:!0,boundary:new dn({})}}else t.write(h,Q());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==Q();e++)n.getPointByVal(t.read(e),u),r.add(u)}}}return s?{bNotEmpty:i,boundary:new dn({})}:{bNotEmpty:i,boundary:r}}const fr=R/180,xr=180/R;function yr(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=Xe(e,360),e<0&&(e+=360),e)}function vr(t){let e=t;return e=yr(e),e>180&&(e-=360),e}function Pr(t){return t*fr}function br(t){return t*xr}function Er(t){const e=Ct();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=Xe(s,e),s<0&&(s+=e),s)}function Cr(t){const e=Et();let s=t;return s>-e&&s<=e||(s=Er(s),s>e&&(s-=Ct())),s}function Dr(e,s,i,n){const r=4*yt()*(Math.abs(s.vmin)+Math.abs(s.vmax)),o=yt();if(1===e.getMaxDerivative()){t(i>0);const o=Nr(e,0,s,yt(),r);return n[0]=o.root,o.cRoots}let a,h=[];const m=new Qt(s.vmin-r,s.vmax+r);h.push(new _s(m.vmin,m.vmax));let u=0;for(let t=e.getMaxDerivative()-1;t>=0;t--){a=h,h=[];for(let m=0,l=a.length;m<l;m++){if(a[m][0]<a[m][1]){let l,c,d;if(t===e.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:d}=Nr(e,t,Qt.construct(a[m][0],a[m][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:d}=Mr(e,t,Qt.construct(a[m][0],a[m][1]),o,.5*r)),1===d){if(0===t){if(u<i){if(a[m][0]<=s.vmin&&a[m][1]>=s.vmin&&l!==s.vmin){0===e.getValue(0,s.vmin)&&(l=s.vmin)}if(a[m][0]<=s.vmax&&a[m][1]>=s.vmax&&l!==s.vmax){0===e.getValue(0,s.vmax)&&(l=s.vmax)}n[u]=s.snapClip(l),u>0?n[u]-n[u-1]>r&&u++:u++}}else{const t=_s.getNAN();t[0]=a[m][0],t[1]=l,h.push(t);const e=_s.getNAN();e[0]=l,e[1]=a[m][1],h.push(e)}continue}}h.push(a[m])}}return u}function Sr(t,e,s,i,n,r){const o=is($t,2),a=Yr(new $t(t),new $t(e),new $t(s),i,n,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function wr(t,e,s,i,n,r,o){const a=is($t,3),h=Xr(new $t(t),new $t(e),new $t(s),new $t(i),n,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function Ar(t,e,s,i,n,r,o,a){return Ir(t,e,s,i,n,r,o,a)}function Tr(t,e,s,i,n,r){return Rr(t,e,s,i,n,r)}function Ir(t,e,s,i,n,r,o,a){const h=new Array(s*s);h.fill(0),Oe(a,i,0,0,s);const m=new Array(s),u=new Array(s),l=new Array(s);let c=t(a,s,e);const d=100;let _=0;for(_=0;_<d;_++){const i=c;for(let t=0;t<s;++t)u[t]=a[t];if(_%s==0){h.fill(0);for(let t=0;t<s;t++)h[t*s+t]=1}let o=0,d=0;for(let u=0;u<s;++u){for(let t=0;t<s;++t)m[t]=h[u*s+t];const i=c;c=qr(t,e,a,m,n,r,s);const l=i-c;l>o&&(d=u,o=l)}for(let t=0;t<s;t++)m[t]=a[t]-u[t],l[t]=a[t]+(a[t]-u[t]);const g=t(l,s,e);if(g<i){if(2*(i-2*c+g)*ve(i-c-o)<ve(i-g)*o){c=qr(t,e,a,m,n,r,s);for(let t=0;t<s;++t)h[d*s+t]=h[(s-1)*s+t],h[(s-1)*s+t]=m[t]}}if(i<=c)return t(a,s,e)}return c}function Nr(e,s,i,n,r){const o={root:0,funcAtRoot:0,cRoots:0};let a=i.vmin,h=i.vmax,m=0,u=Number.MAX_VALUE,l=e.getValue(s,a),c=e.getValue(s,h),d=0,_=0,g=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(o.funcAtRoot=l,o.root=a,o.cRoots=0===l?1:0,o):(o.funcAtRoot=c,o.root=h,o.cRoots=0===c?1:0,o);Math.abs(l)<Math.abs(c)&&(h=je(a,a=h),c=je(l,l=c)),m=a,d=l;let p=!0,f=0;for(;0!==c&&Math.abs(a-h)>n*Math.abs(h)+r;f++){_=l!==d&&c!==d?a*c*d/((l-c)*(l-d))+h*l*d/((c-l)*(c-d))+m*l*c/((d-l)*(d-c)):h-c*(h-a)/(c-l);const i=(3*a+h)/4;let x=!(_>i&&_<h||_>h&&_<i);if(!x){const t=n*Math.abs(h)+r;if(p){const e=Math.abs(h-m);x=Math.abs(_-h)>=.5*e||e<t}else{const e=Math.abs(m-u);x=Math.abs(_-h)>=.5*e||e<t}}if(x?(_=(a+h)/2,p=!0):p=!1,g=e.getValue(s,_),0===g)return o.root=_,o.funcAtRoot=g,o.cRoots=1,o;const y=a-_,v=_-h;if(Math.abs(y)>10*Math.abs(v)){const t=h+3*v,i=e.getValue(s,t);Ee(l)*Ee(i)>0&&(a=t,l=i)}else if(Math.abs(v)>10*Math.abs(y)){const t=a-3*y,i=e.getValue(s,t);Ee(c)*Ee(i)>0&&(h=t,c=i)}u=m,m=h,d=c,Ee(l)*Ee(g)<0?(h=_,c=g):(a=_,l=g),Math.abs(l)<Math.abs(c)&&(h=je(a,a=h),c=je(l,l=c)),f>64&&(t(0),E(""))}return f>64&&E("Root_finder iterations exceeded"),o.root=h,o.funcAtRoot=c,o.cRoots=1,o}function Mr(t,e,s,i,n){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,a=t.getValue(e,o),h=s.vmax,m=t.getValue(e,h);if(a>=0&&m>=0||a<=0&&m<=0)return Math.abs(a)<Math.abs(m)?(r.funcAtRoot=a,r.root=o,r.cRoots=0===a?1:0,r):(r.funcAtRoot=m,r.root=h,r.cRoots=0===m?1:0,r);m<0&&(m=je(a,a=m),h=je(o,o=h));let u=.5*(o+h),l=Math.abs(h-o),c=l,d=t.getValue(e,u),_=t.getValue(e+1,u);const g=1,p=4;let f=p;const x=2;let y=1,v=0,P=0,b=g;const C=32;let D=0;for(;++D<100;){let s;D>C||0===_||b===x&&v>1||b===g&&f<p?(b=g,y>1&&y--):(b=x,P>1&&Math.abs(2*d)>Math.abs(l*_)&&y++),l=c;let i=!1;if(b===g)do{if(P>2){const t=16*Math.abs(l);if(.5*Math.abs(o-h)>t){const e=Math.min(o,h),i=Math.max(o,h);if(u===e){s=u,u=e+t,c=u-s;break}if(u===i){s=u,u=i-t,c=u-s;break}}}c=.5*(h-o),s=u,u=o+c,i=o===u||h===u}while(0);else for(;;){c=y*d/_,s=u,u-=c,i=u===s;const t=Math.min(o,h),e=Math.max(o,h);if(u<t){if(y>1){u=s,y--;continue}c=s-t,u=t}else if(u>e){if(y>1){u=s,y--;continue}c=s-e,u=e}break}if(i||Math.abs(c)<n){s!==u&&(d=t.getValue(e,u));break}d=t.getValue(e,u),_=t.getValue(e+1,u);const r=o,E=h;d<0?(a=d,o=u):(m=d,h=u),b===x&&(o===r&&h===E||P>1&&Math.abs(c)>=.5001*Math.abs(l))?v++:v=0,b===g?(f++,P=0):(f=0,P++)}return 100===D&&E("Root_finder iterations exceeded"),r.root=u,r.funcAtRoot=d,r.cRoots=1,r}function qr(t,e,s,i,n,r,o){const a=i.slice(0,o);let h=0;for(let f=0;f<o;f++)h+=i[f]*i[f];if(h=Math.sqrt(h),h>0)for(let f=0;f<o;f++)a[f]/=h;let m=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=new Array(o);for(let e=0;e<o;e++)t[e]=e;t.sort(((t,e)=>{const s=Math.abs(a[t]),i=Math.abs(a[e]);return s<i?-1:s>i?1:0}));for(let e=0;e<o;e++){const i=t[e];if(0===a[i])continue;let o=(n[i]-s[i])/a[i],h=(r[i]-s[i])/a[i];h<o&&(h=je(o,o=h)),o>m&&(m=o),h<u&&(u=h)}}let l=0;const c=(Math.abs(m)+Math.abs(u))*yt()*100,d=new Array(o),_=a.slice();function g(i,n){for(let t=0,e=o;t<e;t++)d[t]=s[t]+i*_[t];return t(d,o,e)}c>0&&(l=Tr(g,null,m,0,u,c));const p=g(l);for(let f=0,x=o;f<x;f++)s[f]=Pt(d[f],n[f],r[f]);return p}function Rr(t,e,s,i,n,r){const o=ft();let a=i,h=t(a,e),m=s,u=n,l=t(m,e),c=t(u,e);h>l&&(h=l,a=m),h>c&&(h=c,a=u);let d=m,_=u,g=l,p=c;g>p&&(g=je(p,p=g),_=je(d,d=_));let f=a-d,x=d-_;const y=.5*Math.min(r,u-m),v=2*y,P=100;let b,E=0;for(b=0;b<P&&!(u-m<=v);++b){const s=m+.5*(u-m);let i=E>0;if(!i&&Math.abs(x)<=y&&(i=!0,E=3),!i){const t=a-d,e=a-_,s=t*(h-p);let n=e*(h-g),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*x/2)||r<=n*(m-a)||r>=n*(u-a)?(i=!0,E=3):(x=f,f=r/n)}i&&(x=a>=s?m-a:u-a,f=o*x,E--);let n=a+f;n<m+y?n=m+y:n>u-y&&(n=u-y);const r=t(n,e);r<h?(n>=a?(m=a,l=h):(u=a,c=h),_=d,d=a,a=n,p=g,g=h,h=r):(n<a?(m=n,l=r):(u=n,c=r),r<=g||d===a?(_=d,d=n,p=g,g=r):(r<=p||_===a||_===d)&&(_=n,p=r))}return a}function Fr(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function Yr(t,e,s,i,n,r){if(0===t.value()){if(n)return r[0].set(1),i.containsCoordinate(r[0].value())?1:0;return Fr(e,s,i,r[0])}if(n){let e=2;return r[0].set(1),r[1].setE(s).divThisE(t),r[1].eq(r[0])&&(r[1].set(1),e=1),i.containsCoordinate(r[1].value())||(e=1),i.containsCoordinate(r[0].value())||(e--,r[0].setE(r[1])),2===e&&r[0].value()>r[1].value()&&(r[1]=je(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(re));if(o.lt(ie))return 0;const a=new $t(e.value()>=0?1:-1),h=o.clone().sqrtThis(),m=new $t(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let u=0;r[0].setE(m).divThisE(t);const l=new $t(r[0].value()),c=t.clone().resetError(),d=e.clone().resetError(),_=s.clone().resetError();let g=c.clone().mulThisE(l).addThisE(d).mulThisE(l).addThisE(_);if(!g.isZero()){const i=new $t;Wr(r[0],t,e,s,i),r[0].setE(i)}if(i.containsCoordinate(r[0].value())&&u++,0!==h.value()&&0!==m.value()){if(r[u].setE(s).divThisE(m),l.set(r[u].value()),g=c.clone().mulThisE(l).addThisE(d).mulThisE(l).addThisE(_),!g.isZero()){const i=new $t;Wr(r[u],t,e,s,i),r[u].setE(i)}return i.containsCoordinate(r[u].value())&&u++,2===u&&r[0].value()>r[1].value()&&(r[1]=je(r[0],r[0]=r[1])),u}return u}function Xr(t,e,s,i,n,r,o){if(0===t.value()){return Yr(e,s,i,n,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=Yr(t,e.addE(t),i.negate(),n,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(ne)&&(o[s-1]=je(o[t],o[t]=o[s-1]),s--)}const h=o.slice(0,s);h.sort(((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));for(let t=0;t<s;++t)o[t]=h[t];return s}return Zr(t,e,s,i,n,o)}function Lr(t,e,s,i,n,r){return(r<e||e<0)&&f("nth_degree_real_roots"),Hr(t,e,s,i,n)}function zr(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class Vr{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=this.truePower-t+1;for(let s=0,i=this.truePower-t;s<=i;++s){e[s]=this.coefs[s+t].clone();let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let n=e;n>=1;n--)if(0!==this.coefs[n].value()){this.truePower=n;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new Yt(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new Yt(0),i=new $t(1),n=new $t(0);for(let o=0,a=this.power;o<=a;++o)n.addThisE(this.coefs[o].mulE(i)),s.pe(i.value()*this.coefs[o].eps()),i.mulThis(e);s.pe(n.eps());let r=1;for(let o=1;o<=this.truePower;++o){r*=o,this.updateCoefs(o);const e=new $t(1),i=new $t(0);for(let s=0,n=this.truePower-o;s<=n;++s)i.addThisE(this.curCoefs[s].mulE(e)),e.mulThis(t);if(!i.isZero())return Math.pow(r*s.getResult()/Math.abs(i.value()),1/o)}return 0}}function Br(t,e,s,i,n,r){let o=t,a=e,h=a-o;if(!r){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(a=je(o,o=a),n=je(s,s=n)),s>=0||n<=0)return!1}let m,u=!1,l=s,c=0;for(;c<100;c++){const t=i.calcF(l);if(m=i.calcDF(l),m.isZero())return!1;if(!t.value()||c>3&&t.isZero()){u=!0;break}r||(t.value()<0?o=l:a=l);const e=t.value()/m.value(),s=l-e;r||(s>=o&&s<=a||s>=a&&s<=o)&&Math.abs(e)<=.5*h?(l=s,h=Math.abs(e)):(h=Math.abs(.5*(a-o)),l=.5*(o+a))}return!!u&&(n.set(l,i.estimateError(l)),!0)}function kr(t,e,s,i,n,r,o,a){return Br(t,e,s.value(),zr(i,n,r,o),a,!1)}class Gr{constructor(t,e,s){this.coefs=is($t,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new $t(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new $t(t);return $t.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new $t(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function Wr(t,e,s,i,n){return Br(0,0,t.value(),new Gr(e,s,i),n,!0)}function Zr(t,e,s,i,n,r){const o=is($t,3);let a=0;const h=e.negate().divThisE(t.clone().mulThis(3));n.containsCoordinate(h.value())&&(o[0].setE(h),a=1);const m=is($t,2),u=Yr(t.mul(3),e.mul(2),s,n,!1,m);if(u<0)return i.isZero()?-1:0;for(let g=0;g<u;g++)n.containsCoordinate(m[g].value())&&o[a++].setE(m[g]);Ke(o,a,((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));const l=is($t,5);l[0].set(n.vmin);for(let g=0;g<a;g++)l[1+g].setE(o[g]);l[1+a].set(n.vmax);const c=a+2;let d=1,_=0;{const n=l[0].clone();if(t.clone().mulThisE(n).addThisE(e).mulThisE(n).addThisE(s).mulThisE(n).addThisE(i).isZero()){const o=zr(t,e,s,i);n.setError(o.estimateError(n.value())),r[_]=n,_++,d++}}for(let g=d;g<c;g++){const o=l[g].clone(),a=t.clone().mulThisE(o).addThisE(e).mulThisE(o).addThisE(s).mulThisE(o).addThisE(i).isZero();if(a||!l[g].eq(l[g-1])){if(a||kr(l[g-1].value(),l[g].value(),l[g-1].clone().addThisE(l[g]).divThisByPower2(2),t,e,s,i,o)){if(_>0&&o.eq(r[_-1]))continue;if(_>=3&&E("cubic_polynomial_solver_too_many_roots"),a){const n=zr(t,e,s,i);o.setError(n.estimateError(o.value()))}r[_]=o,_++}if(l[g].value()===n.vmax)break;a&&g++}}return _}function Hr(t,e,s,i,n,r){const o=new Vr(t,e,s,yt());let a=0;if(2===o.truePower)a=Yr(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=Fr(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=Dr(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let h=0;h<a;h++)n[h].setError(o.getError(n[h].value()));return a}var Or=Ft;class jr extends Hn{constructor(e){if(e&&void 0!==e.copy)return super({copy:e.copy}),this.m_cachedValues=null,this.m_interior=new _s(0,0),this.m_center=new _s(0,0),void e.copy.copyToImpl(this);e?t(0):(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_bits=0,this.m_startAngle=0,this.m_sweepAngle=0,this.m_sinr=0,this.m_cosr=1,this.m_rotation=0,this.m_minorMajorRatio=1,this.m_semiMajorAxis=0,this.m_interior=new _s(0,0),this.m_center=new _s(0,0),this.m_cachedValues=null)}getBoundary(){return gr(this)}assignMove(e){return t(0),this}assignCopy(t){return t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=_s.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructLineEllipticArc(t,e){return tm(this,t,e,1),this}constructLineCircularArc(e,s){return t(0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const r=new _s(0,this.m_minorMajorRatio*this.m_semiMajorAxis),o=Math.cos(i),a=Math.sin(i);return r.rotateDirect(o,a),r.addThis(s),this.constructEllipticArcEndPointsCenter(r,r,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,s),this}constructCircularArcThreePoint(t,e,s){const i=new $t(t.x),n=new $t(e.x),r=new $t(s.x),o=new $t(t.y),a=new $t(e.y),h=new $t(s.y),m=new $t(.5),u=n.subE(i),l=a.subE(o),c=r.subE(i),d=h.subE(o),_=u.mulE(d).subThisE(l.mulE(c));if(_.scaleError(10),_.isZero()){if(!u.isZero()||!l.isZero())return tm(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const g=u.sqr().addThisE(l.sqr()).mulThisE(m),p=c.sqr().addThisE(d.sqr()).mulThisE(m),f=g.mulE(d).subThisE(p.mulE(l)),x=u.mulE(p).subThisE(c.mulE(g));f.divThisE(_),x.divThisE(_);const y=f.sqr().addThisE(x.sqr());y.sqrtThis();const v=f.addE(i),P=x.addE(o);let b=t.x-v.value(),E=t.y-P.value();const C=Math.atan2(E,b);b=e.x-v.value(),E=e.y-P.value();const D=Math.atan2(E,b);b=s.x-v.value(),E=s.y-P.value();const S=Math.atan2(E,b);let w=S-2*Et();for(;w<C;)w+=2*Et();let A=D-2*Et();for(;A<w;)A+=2*Et();let T=S+2*Et();for(;T>C;)T-=2*Et();let I,N=D+2*Et();for(;N>T;)N-=2*Et();I=A-C<C-N?A-C:N-C;const M=new _s(v.value(),P.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(I)>Et(),I>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return Jh(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return Jh(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,r){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=Cr(r),a=Math.cos(o),h=Math.sin(o),m=new _s(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=_s.getNAN(),l=Cr(i);u.x=m.x*Math.cos(l),u.y=m.y*Math.sin(l),u.rotateDirect(a,h),u.addThis(s);const c=bt(n,Ct());let d=c;Math.abs(d)===Ct()&&(d=0);const _=_s.getNAN();return _.x=m.x*Math.cos(l+d),_.y=m.y*Math.sin(l+d),_.rotateDirect(a,h),_.addThis(s),this.constructEllipticArcEndPointsCenter(u,_,this.m_semiMajorAxis,this.m_minorMajorRatio,o,Math.abs(c)>Et(),c>0,s)}constructEllipticArcAsNURB(e,s,i,n){return t(0),this}constructCanonic(e){return t(0),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!Ri(this,[t])&&em(this)}isDegenerateToLine(){return em(this)}getCenter(){return this.m_center}setCenter(e){t(0)}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return _s.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!mm(this)}isMajor(){return lm(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return r.enumEllipticArc}queryEnvelope(e){if(e instanceof Cs){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=ps.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=Or.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else if(e instanceof ps){if(em(this))return e.setCoords(this.getStartXY()),void e.mergeNe(this.getEndXY());const t=this.getSemiAxes(),s=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),i=s+Et(),n=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),r=n+Et(),o=new Array(4);o[0]=kh(this,s),o[1]=kh(this,i),o[2]=kh(this,n),o[3]=kh(this,r),e.setCoords(this.getStartXY()),e.mergeNe(this.getEndXY());const a=_s.getNAN();for(let h=0;h<4;h++){const t=o[h];t>0&&t<1&&(this.queryCoord2D(t,a),e.mergeNe(a))}}else t(0)}applyTransformation(t){rm(this,t,!1)}createInstance(){return new jr}calculateLength2D(){return Oh(this,0,1)}queryCoord2D(t,e){if(em(this))jn(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(_s.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(_s.construct(this.m_XEnd,this.m_YEnd));else{const s=Gh(this,t),i=new _s(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){Fh(this,t,e)}getCoordX(t){const e=new _s;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new _s;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();let r=0===t&&1===e;if(r&&!i)return void this.copyTo(n);const o=_s.getNAN();this.queryCoord2D(t,o);const a=_s.getNAN();if(this.queryCoord2D(e,a),!r)if(o.equals(a))e-t>.5&&this.isMajor()&&this.isClosed()?(r=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&o.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&a.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),r=0===t&&1===e,r&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,zi(n,o.x,o.y),Bi(n,a.x,a.y),r)return void om(n,jh(this));n.m_startAngle=Gh(this,t),n.m_sweepAngle=Gh(this,e)-n.m_startAngle,n.m_startAngle=Lh(n.m_startAngle),um(n,Math.abs(n.m_sweepAngle)>Et()),n.assignVertexDescription(this.m_description),vm(n),Bh(n);const h=this.m_description.getAttributeCount();if(h>1){for(let e=1;e<h;e++){const s=this.m_description.getSemantics(e),i=Or.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<h;t++){const s=this.m_description.getSemantics(t),i=Or.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){Am()}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new _s;this.queryCoord2D(t,n);const r=new _s;this.queryCoord2D(e,r),i||(n.equals(r)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&r.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,zi(s,n.x,n.y),Bi(s,r.x,r.y),i?om(s,jh(this)):(s.m_startAngle=Gh(this,t),s.m_sweepAngle=Gh(this,e)-s.m_startAngle,s.m_startAngle=Lh(s.m_startAngle),um(s,Math.abs(s.m_sweepAngle)>Math.PI),vm(s),s.afterCompletedModification())}changeEndPoints2D(e,s){t(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0;return Ze(Or.getInterpolation(e),this.getStartAttributeAsDbl(e,s),this.getEndAttributeAsDbl(e,s),n,Or.getDefaultValue(e))}getClosestCoordinate(t,e){return Dm(this,t,Qt.unit(),e)}getClosestCoordinateOnInterval(t,e,s){return Dm(this,t,e,!1)}getYMonotonicParts(e,s=!1){e.length<2&&f("");const i=this.getSemiAxes(),n=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r=n+Et(),o=new Array(3);let a=0;if(o[0]=kh(this,n),o[0]>0&&o[0]<1&&a++,o[1]=kh(this,r),o[1]>0&&o[1]<1&&(o[a]=o[1],a++),0===a)return 0;o[a]=1,a++,t(e.length>=a);let h=0;for(let t=0;t<a;t++){const i=o[t];this.queryCut(h,i,e[t],s),h=i}return a}getMonotonicParts(e,s){if(e.length<4&&f(""),this.isDegenerateToLine())return e[0].createEllipticArc().assignCopy(this),s&&e[0].get().dropAllAttributes(),1;const i=this.getSemiAxes(),n=new Array(4);n[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),n[1]=n[0]+Et(),n[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),n[3]=n[2]+Et();const r=new Array(5);let o=0;for(let t=0;t<4;t++)r[o]=kh(this,n[t]),r[o]>0&&r[o]<1&&o++;if(0===o)return 0;Qe(r,o),r[o-1]<1&&(r[o]=1,o++),t(e.length>=o);let a=0;for(let t=0;t<o;t++){const i=r[t];this.queryCut(a,i,e[t],s),a=i}return o}intersectionWithAxis2D(t,e,s,i){if(em(this)){return new fl({pt1:this.getStartXY(),pt2:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i)}let n,r;const o=new $t(e),a=this.getSemiAxes();if(t){if(e>this.m_center.y+a.x||e<this.m_center.y-a.x)return 0;n=new $t(a.x).mulThis(this.m_sinr),r=new $t(a.y).mulThis(this.m_cosr),o.subThis(this.m_center.y)}else{if(e>this.m_center.x+a.x||e<this.m_center.x-a.x)return 0;n=new $t(a.x).mulThis(this.m_cosr),r=new $t(a.y).mulThis(-this.m_sinr),o.subThis(this.m_center.x)}const h=n.sqr(),m=r.sqr(),u=h.addE(m),l=r.mulE(o).mulThis(-2),c=o.sqr().subThisE(h),d=l.sqr().subThisE(u.mulE(c).mulThis(4)),_=n.mulE(o).mulThis(-2),g=o.sqr().subThisE(m),p=_.sqr().subThisE(u.mulE(g).mulThis(4));let f=d.eps()*Math.abs(p.value())<=p.eps()*Math.abs(d.value());f?n.isZero()&&(f=!1):r.isZero()&&(f=!0),f||(l.setE(_),c.setE(g));const x=is($t,2);let y=Yr(u,l,c,Qt.construct(-1,1),!1,x);if(0===y)return 0;const v=[0,0];let P=0;for(let b=0;b<y;b++){const t=new $t,e=new $t;f?(t.setE(x[b]),e.setE(o.subE(r.mulE(x[b])).divThisE(n))):(e.setE(x[b]),t.setE(o.subE(n.mulE(x[b])).divThisE(r)));const s=kh(this,Math.atan2(t.value(),e.value()));s>=0&&s<=1&&(v[P]=s,P++)}return y=P,0===y?0:(2===y&&v[0]>v[1]&&(v[1]=je(v[0],v[0]=v[1])),i&&Oe(i,v,0,0,y),s&&(s[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),y>1&&(s[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!i&&s[0]>s[1]&&(s[1]=je(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return qi(this,t)}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(e){if(e instanceof Vs)return void t(0);if(em(this))return e.setCoords(this.getStartXY()),void e.mergeNe(this.getEndXY());const s=this.getSemiAxes();e.setCoords({xmin:this.m_center.x-s.x,ymin:this.m_center.y-s.x,xmax:this.m_center.x+s.x,ymax:this.m_center.y+s.x})}clone(t){const e=new jr;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(em(this))return 0===e?Qt.construct(this.getStartX(),this.getEndX()):Qt.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const i=t+Math.PI,n=[0,0];n[0]=kh(this,t),n[1]=kh(this,i);const r=0===e?Qt.construct(this.getStartX(),this.getEndX()):Qt.construct(this.getStartY(),this.getEndY()),o=new _s;for(let a=0;a<2;a++){const t=n[a];t>0&&t<1&&(this.queryCoord2D(t,o),r.mergeNeCoordinate(0===e?o.x:o.y))}return r}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){if(em(this))return e.setCoords(this.getStartXY()),void e.mergeNe(this.getEndXY());const s=this.getSemiAxes();e.setCoords({xmin:this.m_center.x-s.x,ymin:this.m_center.y-s.x,xmax:this.m_center.x+s.x,ymax:this.m_center.y+s.x})}tToLength(t){return em(this)?t*_s.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:sm(this,t)}lengthToT(t){if(em(this)){const e=_s.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return im(this,t)}calculateWeightedAreaCentroid2D(e){return t(0),_s.getNAN()}calculateWeightedCentroid2D(){return t(0),_s.getNAN()}isIntersectingPoint(e,s,i){return t(0),!1}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}getTangent(t){if(em(this))return this.getEndXY().sub(this.getStartXY());{const e=Gh(this,t),s=new _s;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(e){return t(0),_s.getNAN()}normalizeAfterEndpointChange(){return!!dm(this)&&(em(this)?(_m(this),!1):gm(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new _s(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new _s(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}queryAttributeAsDbl(e,s,i,n){t(0)}getCurvature(e){return t(0),0}getMonotonicPartParams(t,e){const s=new Array(6);s[0]=0;let i=1;if(this.isDegenerateToLine())s[1]=1,i=2;else{const t=this.getSemiAxes(),e=new Array(4);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=wt());for(let n=0;n<4;n++){const t=kh(this,e[n]);t>0&&t<1&&(s[i]=t,i++)}i>2&&Qe(s,i),s[i]=1,i++}if(e){t<i&&f("");for(let t=0;t<i;t++)e[t]=s[t]}return i}calculateLowerLength2D(){const t=_s.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=_s.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){t(0)}isLine(){return em(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,am(t)}calculateArea2DHelper(){if(this.isLine())return 0;if(this.isDegenerate(0))return 0;const t=this.m_semiMajorAxis,e=this.getSemiMinorAxis(),s=t*t+e*e,i=this.getStartAngle(),n=this.getEndAngle(),r=this.m_center.y-this.m_YStart,o=this.m_cosr,a=this.m_sinr;let h=1,m=0;this.m_rotation&&(h=(o-a)*(o+a),m=2*o*a);const u=((-.5*(n-i)+.25*h*(2*Math.cos(n+i)*Math.sin(n-i)))*e+-2*Math.sin(.5*(n+i))*Math.sin(.5*(n-i))*o*r)*t/s;let l=0;if(this.m_rotation){l=.125*(-2*Math.sin(n+i)*Math.sin(n-i))*m-e*r/s*(2*Math.cos(.5*(n+i))*Math.sin(.5*(n-i)))*a}return s*(u+l)+-.5*(this.m_XEnd-this.m_XStart)*(this.m_YEnd-this.m_YStart)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),em(this))return;const s=this.getSemiAxes(),i=new Array(8);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=kh(this,t),i[1]=kh(this,e),i[2]=kh(this,n),i[3]=kh(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=kh(this,n),i[5]=kh(this,r),i[6]=kh(this,o),i[7]=kh(this,a)}const n=_s.getNAN();for(let r=0;r<8;r++){const s=i[r];t.containsExclusiveCoordinate(s)&&(this.queryCoord2D(s,n),e.mergeNe(n))}}setSegmentFromCoords(t,e){Kh(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(e){return t(0),!1}calculateSpecialPointsForCracking(e,s){return t(0),0}ensureXYMonotone(){return t(0),!1}setCoordsForIntersector(t,e,s){Qh(this,t,e,s)}getInteriorPoint(){return t(0),this.m_interior}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,om(e,jh(this))}reverseImpl(){hm(this,!mm(this)),Bh(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&vm(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(Pr(vr(br(this.m_rotation-s.m_rotation)))),n=Math.abs(Et()-i),r=Math.min(i,n);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;const o=this.getCoord2D(.5),a=s.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){_m(this),am(this)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&b(""),em(this)){return new fl({pt1:this.getStartXY(),pt2:this.getEndXY()}).intersectPoint(t,e,s)}{const e=_s.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const i=this.getClosestCoordinate(t,!1),n=_s.getNAN();return this.queryCoord2D(i,n),_s.distance(n,t)<=s?vt(i,0,1)&&(this.queryCoord2D(0===i?1:0,n),_s.distance(n,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==ol(!1,this,t,e,s)}intersect_(e,s,i,n){return t(0),0}endPointModified(){this.m_bits|=8,am(this)}clearEndPointModified(){_m(this)}}jr.type=r.enumEllipticArc;class Ur extends un{constructor(e){e?e.vd?(super({vd:e.vd,bPolygon:!0}),this.m_segmentBufferCTor=xl):e.copy?(super({vd:e.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=xl,e.copy.copyTo(this)):e.move?(super({move:e.move}),this.m_segmentBufferCTor=xl):(e.envelope,t(0)):(super({bPolygon:!0}),this.m_segmentBufferCTor=xl)}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}getBoundary(){return gr(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return Ur.type}getDimension(){return 2}createInstance(){return new Ur({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function Qr(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x);Kr(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function Kr(t,e,s,i){let n=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;n>Et();)n-=2*Et();for(;n<=-Et();)n+=2*Et();if(!Number.isNaN(e)){for(;e>Et();)e-=2*Et();for(;e<=-Et();)e+=2*Et();!s&&e>n&&(e-=2*Et()),s&&e<n&&(e+=2*Et()),r=e-n,Math.abs(r)<o&&!i&&(r=s?2*Et():-2*Et()),Math.abs(r)>2*Et()-o&&i&&(r=0)}Math.abs(r)>2*Et()-o&&(r=r>=0?2*Et():-2*Et(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),i=Math.abs(r)<=Et(),r&&(s=r>0),t.m_startAngle=Lh(n),t.m_sweepAngle=r,um(t,!i),hm(t,s)}function $r(t,e,s,i,n,r,o,a,h,m=null){const u=Math.max(Ki(t,e),s),l=Math.max(i,4*u);if($i(t,e,l))return 0;return new ho(t,e,u,l,a,!1,m).intersectNonMonotone(n,r,o,h)}function Jr(t,e,s,i,n,r=null){const o=Math.max(Ki(t,e),s),a=Math.max(i,4*o);if($i(t,e,a))return!1;return new ho(t,e,o,a,n,!0,r).intersectNonMonotone(null,null,null,!1)>0}function to(t,e,s,i,n=null){const r=Qi(e),o=Math.max(4*r,s);return new ho(e,null,o,Number.NaN,!1,!1,n).approximateWithCirclesImpl(t,i)}function eo(t,e,s,i,n,r,o){return{ptStart:t.clone(),ptEnd:e.clone(),ptStartIntervalLeft:new Qt(s),ptStartIntervalRight:new Qt(i),ptEndIntervalLeft:new Qt(s),ptEndIntervalRight:new Qt(i),intervalLeft:new Qt(s),intervalRight:new Qt(i),distance:n,kind:r,mask:o}}function so(t){return Number.isNaN(t.radius.value())}function io(){return{ptStart:new _s,ptEnd:new _s,center:new Ai,radius:new $t,fcenter:new _s,fradius2:Number.NaN,maxError:0}}function no(t,e,s,i){return{pt:t.clone(),t:e,err:s,checkCount:i}}function ro(){return{pt:new _s,leftParam:Number.NaN,rightParam:Number.NaN}}Ur.type=r.enumPolygon;const oo=5,ao=1/8;class ho{constructor(t,e,s,i,n,r,o=null){this.m_currentIntersections=[],this.m_circleCheckCounter=0,this.m_circleIntersectCounter=0,this.m_leftRecursionCounter=0,this.m_rightRecursionCounter=0,this.m_maxRecursionDepth=0,this.m_bReversedLeft=!1,this.m_bReversedRight=!1,this.m_leftArc=io(),this.m_rightArc=io(),this.m_line1=new fl,this.m_line2=new fl,this.m_tracker=null,this.m_trackerCounter=0,this.m_left=t,this.m_right=e,this.m_eps=s,this.m_tolerance=i,this.m_sqrTolerance=ve(this.m_tolerance),this.m_bExcludeExactEndpoints=n,this.m_bBreakEarly=r,this.m_tracker=o}intersectNonMonotone(e,s,i,n){null!==e&&(e.length=0),null!==s&&(s.length=0),null!==i&&(i.length=0);const r=[],o=new Array(9),a=this.m_left.getMonotonicPartParams(o.length,o),h=new Array(9),m=this.m_right.getMonotonicPartParams(h.length,h);let u=0;for(let t=1;t<a;t++){const e=new Qt(o[t-1],o[t]);for(let t=1;t<m;t++){const s=new Qt(h[t-1],h[t]);u|=this.intersectMonotone(e,s)?1:0;for(const t of this.m_currentIntersections)if(1024&t.kind){let e=ro();if(e.pt.assign(t.ptStart),e.leftParam=ho.pointToT(this.m_left,t.ptStartIntervalLeft,t.ptStart),e.rightParam=ho.pointToT(this.m_right,t.ptStartIntervalRight,t.ptStart),r.push(e),e=ro(),e.pt.assign(t.ptEnd),e.leftParam=ho.pointToT(this.m_left,t.ptEndIntervalLeft,t.ptEnd),e.rightParam=ho.pointToT(this.m_right,t.ptEndIntervalRight,t.ptEnd),r.push(e),this.m_bBreakEarly)return 1}else{const e=ro();if(e.pt.assign(t.ptStart),e.leftParam=ho.pointToT(this.m_left,t.ptStartIntervalLeft,t.ptStart),e.rightParam=ho.pointToT(this.m_right,t.ptStartIntervalRight,t.ptStart),this.m_bBreakEarly){if(!vt(e.leftParam,0,1)&&!vt(e.rightParam,0,1))return 1;if(!this.m_left.getCoord2D(e.leftParam).equals(this.m_right.getCoord2D(e.rightParam)))return 1}r.push(e)}this.m_currentIntersections.length=0}}if(u){const o=(t,e)=>n?Je(t.rightParam,t.leftParam,e.rightParam,e.leftParam):Je(t.leftParam,t.rightParam,e.leftParam,e.rightParam);r.sort(o);let a=0;for(let t=0,n=r.length;t<n;++t){const n=r[t];if(this.m_bExcludeExactEndpoints&&vt(n.leftParam,0,1)&&vt(n.rightParam,0,1)){const t=_s.getNAN();this.m_left.queryCoord2D(n.leftParam,t);const e=_s.getNAN();if(this.m_right.queryCoord2D(n.rightParam,e),t.equals(e))continue}if(a>0){const t=Math.abs(n.leftParam-r[a-1].leftParam),e=Math.abs(n.rightParam-r[a-1].rightParam);if(0===t&&0===e)continue}t!==a&&(r[a]=n),null!==e&&e.push(n.pt),null!==s&&s.push(n.leftParam),null!==i&&i.push(n.rightParam),a++}return t(a<=Number.MAX_SAFE_INTEGER),a}return 0}intersectMonotone(e,s){if(this.m_bReversedLeft=!ho.goodOrientation(this.m_left,e),this.m_bReversedRight=!ho.goodOrientation(this.m_right,s),this.checkAndProcessOverlap(this.m_tolerance,e,s))return!0;const i=[],n=[];{const t=new _s;this.m_bReversedLeft?(i.push(no(t,e.vmin,0,0)),i.push(no(t,e.vmax,0,0))):(i.push(no(t,e.vmax,0,0)),i.push(no(t,e.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t),this.m_bReversedRight?(n.push(no(t,s.vmin,0,0)),n.push(no(t,s.vmax,0,0))):(n.push(no(t,s.vmax,0,0)),n.push(no(t,s.vmin,0,0))),n[0].pt=this.m_right.getCoord2D(n[0].t),n[1].pt=this.m_right.getCoord2D(n[1].t)}const r=i[i.length-1].pt.clone(),o=n[n.length-1].pt.clone(),a=new _s,h=new _s,m=ps.constructEmpty(),u=ps.constructEmpty(),l=Qt.constructEmpty(),c=Qt.constructEmpty();let d=!0,_=!0,g=-1,p=-1;this.m_leftArc=io(),this.m_rightArc=io();let f=0,x=0,y=0,v=0,P=!1;for(;i.length>1&&n.length>1;){const e=Math.max(i.length,n.length);if(e>this.m_maxRecursionDepth&&(this.m_maxRecursionDepth=e,t(this.m_maxRecursionDepth<32)),d){a.assign(i[i.length-2].pt),m.setCoords({pt1:r,pt2:a});const t=i.at(-1);l.setCoords(t.t,i[i.length-2].t),f=t.err,y=t.checkCount,g=-1,d=!1}if(_){h.assign(n[n.length-2].pt),u.setCoords({pt1:o,pt2:h});const t=n.at(-1);c.setCoords(t.t,n[n.length-2].t),x=t.err,v=t.checkCount,p=-1,_=!1}const s=(a.compare(h)<0?a:h).clone();let b=!1;const E=new ps(m);if(E.inflateCoords(this.m_tolerance,this.m_tolerance),E.isIntersectingNe(u)){if(b=m.maxDimension()>=u.maxDimension(),b&&-1===g||1===p){const t=l.getCenter(),e=this.m_left.getCoord2D(t);if(f<=this.m_eps||y>=oo?(g=this.closeToCircularArc(this.m_left,l,r,e,a,this.m_leftArc)?1:0,f=this.m_leftArc.maxError,y=0):y++,1!==g){const s=i[i.length-1].t,n=i[i.length-1].pt.clone(),r=i.at(-1);r.t=t,r.pt.assign(e),f*=ao,r.err=f,r.checkCount=y,i.push(no(n,s,f,y)),d=!0;continue}}if(-1===p){const t=c.getCenter(),e=this.m_right.getCoord2D(t).clone();if(x<=this.m_eps||v>=oo?(p=this.closeToCircularArc(this.m_right,c,o,e,h,this.m_rightArc)?1:0,x=this.m_rightArc.maxError,v=0):v++,1!==p){const s=n[n.length-1].t,i=n[n.length-1].pt.clone(),r=n.at(-1);r.t=t,r.pt.assign(e),x*=ao,r.err=x,r.checkCount=v,n.push(no(i,s,x,v)),_=!0;continue}}if(1!==g||1!==p)continue;{const t=this.intersectCircular(l,c);P||=t}}s.equals(a)&&(i.pop(),r.assign(a),d=!0),s.equals(h)&&(n.pop(),o.assign(h),_=!0)}return P}adaptiveDensify(e,s){t(0)}adaptiveDensifyMonotone(e,s,i,n){t(0)}intersecting(e,s){return t(0),!1}closeToCircularArc(t,e,s,i,n,r){if(this.m_circleCheckCounter++,r.maxError=0,!ho.checkSweepAngle(t,e))return!1;if(r.ptStart.assign(s),r.ptEnd.assign(n),t.isCircular()){const e=t;return r.radius.set(e.getSemiMajorAxis()),r.center.set(e.getCenter()),!0}const o=r.ptEnd.sub(r.ptStart).clone();o.leftPerpendicularThis(),o.normalize();if(Math.abs(o.dotProduct(i.sub(r.ptStart)))<=this.m_eps)return!!this.confirmIsLine(r,o)&&(r.radius.set(Number.NaN),r.center.setCoords(0,0),!0);{const s=r.ptEnd.sub(r.ptStart),n=i.sub(r.ptStart),o=s.crossProduct(n);if(0===o)return!1;const a=.5*s.sqrLength(),h=.5*n.sqrLength();let m=a*n.y-h*s.y;m/=o;let u=s.x*h-n.x*a;u/=o;const l=Math.sqrt(m*m+u*u);if(4*yt()*l>this.m_eps)return!1;const c=m+r.ptStart.x,d=u+r.ptStart.y;r.radius.setWithEps(l),r.center.setWithEps(new _s(c,d));const _=this.maxCircleApproximationError(t,e,r);return!(_>this.m_eps)||(r.maxError=_,!1)}}intersectLineLine(t,e){const s=new _s;this.m_left.queryCoord2D(t.vmin,s);const i=new _s;this.m_left.queryCoord2D(t.vmax,i),this.m_line1.construct(s,i),this.m_right.queryCoord2D(e.vmin,s),this.m_right.queryCoord2D(e.vmax,i),this.m_line2.construct(s,i);const n=is(_s,2);if(1===nr(this.m_line1,this.m_line2,n))return this.addIntersectionPoint(n[0],0,t,e,266,0);{let s=new _s,i=Number.MAX_VALUE,n=0;const r=or(this.m_line1,this.m_line2.getStartXY(),this.m_tolerance,!1);if(!Number.isNaN(r)){n++;const t=_s.distance(this.m_line1.getCoord2D(r),this.m_line2.getStartXY());t<i&&(i=t,s=this.m_line2.getStartXY())}const o=or(this.m_line1,this.m_line2.getEndXY(),this.m_tolerance,!1);if(!Number.isNaN(o)){n++;const t=_s.distance(this.m_line1.getCoord2D(o),this.m_line2.getEndXY());t<i&&(i=t,s=this.m_line2.getEndXY())}const a=or(this.m_line2,this.m_line1.getStartXY(),this.m_tolerance,!1);if(!Number.isNaN(a)){n++;const t=_s.distance(this.m_line2.getCoord2D(a),this.m_line1.getStartXY());t<i&&(i=t,s=this.m_line1.getStartXY())}const h=or(this.m_line2,this.m_line1.getEndXY(),this.m_tolerance,!1);if(!Number.isNaN(h)){n++;const t=_s.distance(this.m_line2.getCoord2D(h),this.m_line1.getEndXY());t<i&&(i=t,s=this.m_line1.getEndXY())}if(n>0)return this.addIntersectionPoint(s,i,t,e,i>0?513:266,0)}return!1}intersectLineCircular(e,s){return t(0),!1}intersectCircularLine(t,e,s){if(so(this.m_leftArc))return this.intersectLineLine(t,e);const i=_s.getClosestCoordinate(this.m_rightArc.ptStart,this.m_rightArc.ptEnd,this.m_leftArc.center.value(),!0),n=new _s;ye(this.m_rightArc.ptStart,this.m_rightArc.ptEnd,i,n);const r=new Ai;r.setWithEps(n);const o=r.subE(this.m_leftArc.center).sqrLength(),a=this.m_leftArc.radius.sqr().subE(o);if(a.value()>0){const i=a.clone();i.sqrtThis();const n=Ai.constructPoint2D(this.m_rightArc.ptEnd.sub(this.m_rightArc.ptStart)).getUnitVector(),o=r.addE(n.mulE(i)),h=r.subE(n.mulE(i));let m=!1;return(this.m_leftArc.ptStart.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptStart.equals(this.m_rightArc.ptEnd))&&(o.eq(Ai.constructPoint2D(this.m_leftArc.ptStart))&&o.set(this.m_leftArc.ptStart),h.eq(Ai.constructPoint2D(this.m_leftArc.ptStart))&&h.set(this.m_leftArc.ptStart)),(this.m_leftArc.ptEnd.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptEnd.equals(this.m_rightArc.ptEnd))&&(o.eq(Ai.constructPoint2D(this.m_leftArc.ptEnd))&&o.set(this.m_leftArc.ptEnd),h.eq(Ai.constructPoint2D(this.m_leftArc.ptEnd))&&h.set(this.m_leftArc.ptEnd)),this.isOnArc(this.m_leftArc,o)&&this.isOnArc(this.m_rightArc,o)&&(m=s?this.addIntersectionPoint(o.value(),0,e,t,268,18)||m:this.addIntersectionPoint(o.value(),0,t,e,268,18)||m),this.isOnArc(this.m_leftArc,h)&&this.isOnArc(this.m_rightArc,h)&&(m=s?this.addIntersectionPoint(h.value(),0,e,t,268,18)||m:this.addIntersectionPoint(h.value(),0,t,e,268,18)||m),m}{const i=Math.sqrt(o.value())-this.m_leftArc.radius.value();if(i<=this.m_tolerance&&((this.m_leftArc.ptStart.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptStart.equals(this.m_rightArc.ptEnd))&&r.eq(Ai.constructPoint2D(this.m_leftArc.ptStart))&&r.set(this.m_leftArc.ptStart),(this.m_leftArc.ptEnd.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptEnd.equals(this.m_rightArc.ptEnd))&&r.eq(Ai.constructPoint2D(this.m_leftArc.ptEnd))&&r.set(this.m_leftArc.ptEnd),this.isOnArc(this.m_leftArc,r)&&this.isOnArc(this.m_rightArc,r))){if(s){return this.addIntersectionPoint(n,i,t,e,260,18)}return this.addIntersectionPoint(n,i,e,t,260,18)}}return!1}intersectCircular(t,e){if(so(this.m_rightArc))return this.intersectCircularLine(t,e,!1);if(so(this.m_leftArc))return this.intersectLineCircular(t,e);const s=Ai.distance(this.m_leftArc.center,this.m_rightArc.center),i=s.subE(this.m_leftArc.radius.addE(this.m_rightArc.radius));if(i.ge(ie)){if(i.value()<=this.m_tolerance){i.value()<0&&i.set(0);const s=this.m_rightArc.center.subE(this.m_leftArc.center).getUnitVector(),n=.5*i.value(),r=this.m_leftArc.radius.value()<this.m_rightArc.radius.value()?s.mulE(this.m_leftArc.radius.add(n)).addE(this.m_leftArc.center):this.m_rightArc.center.subE(s.mulE(this.m_rightArc.radius.add(n)));if(this.isOnArc(this.m_leftArc,r)&&this.isOnArc(this.m_rightArc,r)){return this.addIntersectionPoint(r.value(),i.value(),t,e,i.value()>0?515:259,18)}return!1}return!1}{const i=Math.min(this.m_leftArc.radius.value(),this.m_rightArc.radius.value()),n=Math.max(this.m_leftArc.radius.value(),this.m_rightArc.radius.value());if(s.value()+i<=n){const r=n-(s.value()+i);if(r<=this.m_tolerance){if(i<n&&s.value()>0){const s=.5*r,i=this.m_leftArc.center.subE(this.m_rightArc.center).getUnitVector();this.m_leftArc.radius.value()>this.m_rightArc.radius.value()&&i.negateThis();const n=this.m_leftArc.radius.value()<this.m_rightArc.radius.value()?this.m_leftArc.center.addE(i.mulE(this.m_leftArc.radius.add(s))):this.m_rightArc.center.addE(i.mulE(this.m_rightArc.radius.add(s)));if(this.isOnArc(this.m_leftArc,n)&&this.isOnArc(this.m_rightArc,n)){return this.addIntersectionPoint(n.value(),r,t,e,r>0?514:258,18)}return!1}{const i=(s.isZero(),1285);return this.addOverlap(r,t,e,i)}}return!1}return this.intersectCircles(t,e)}}isOnArc(t,e){if(so(t)){const s=e.subE(Ai.constructPoint2D(t.ptStart)),i=e.subE(Ai.constructPoint2D(t.ptEnd)),n=Ai.constructPoint2D(t.ptEnd).subE(Ai.constructPoint2D(t.ptStart)),r=s.dotProduct(n),o=i.dotProduct(n).negate();return!r.lt(ie)&&!o.lt(ie)}{const s=e.subE(t.center),i=Ai.constructPoint2D(t.ptStart).subE(t.center),n=Ai.constructPoint2D(t.ptEnd).subE(t.center);if(s.dotProduct(i).le(ie))return!1;if(s.dotProduct(n).le(ie))return!1;const r=s.crossProduct(i),o=s.crossProduct(n);return r.le(ie)&&o.ge(ie)||r.ge(ie)&&o.le(ie)}}intersectCircles(t,e){let s=this.m_leftArc,i=this.m_rightArc;this.m_leftArc.radius.value()>this.m_rightArc.radius.value()&&(i=je(s,s=i));const n=s.center.value(),r=i.center.value(),o=s.radius.value(),a=i.radius.value(),h=r.sub(n),m=h.sqrLength(),u=Math.sqrt(m);let l,c=.5*((o*o-a*a)/u+u);if(o<=Math.abs(c))c=c>0?o:-o,l=0;else{const t=o*o-c*c;l=Math.sqrt(t)}const d=h.clone();d.divThis(u);const _=d.mul(c);d.leftPerpendicularThis();const g=_.add(d.mul(l));g.addThis(n);const p=_.sub(d.mul(l));p.addThis(n),(this.m_leftArc.ptStart.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptStart.equals(this.m_rightArc.ptEnd))&&(g.equals(this.m_leftArc.ptStart)&&g.assign(this.m_leftArc.ptStart),p.equals(this.m_leftArc.ptStart)&&p.assign(this.m_leftArc.ptStart)),(this.m_leftArc.ptEnd.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptEnd.equals(this.m_rightArc.ptEnd))&&(g.equals(this.m_leftArc.ptEnd)&&g.assign(this.m_leftArc.ptEnd),p.equals(this.m_leftArc.ptEnd)&&p.assign(this.m_leftArc.ptEnd));let f=!1;return this.isOnArc(this.m_leftArc,Ai.constructPoint2D(g))&&this.isOnArc(this.m_rightArc,Ai.constructPoint2D(g))&&(this.addIntersectionPoint(g,0,t,e,267,18),f=!0),this.isOnArc(this.m_leftArc,Ai.constructPoint2D(p))&&this.isOnArc(this.m_rightArc,Ai.constructPoint2D(p))&&(this.addIntersectionPoint(p,0,t,e,267,18),f=!0),f}static checkSweepAngle(t,e){if(t.getGeometryType()===r.enumEllipticArc){const s=t,i=Gh(s,e.vmin),n=Gh(s,e.vmax);return!(Math.abs(n-i)>.5*Dt())}return!0}static calcCircleDir(e,s,i,n){return t(0),new _s}confirmIsLine(t,e){const s=t.ptEnd.sub(t.ptStart);return!(Math.abs(e.dotProduct(s.mul(.25)))>this.m_eps)&&!(Math.abs(e.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(t,e,s){const i=[.25,.75],n=[.1,.25,.75,.9];let o;o=t.getGeometryType()===r.enumEllipticArc?i:n;const a=o.length;let h=0;for(let r=0;r<a;++r){const i=new _s;t.queryCoord2D(pe(e.vmin,e.vmax,o[r]),i);const n=i.sub(s.center.value()).length(),a=Math.abs(n-s.radius.value());a>h&&(h=a)}return h}addIntersectionPoint(t,e,s,i,n,r){e<0&&(e=0);const o=eo(t,t,s,i,e,n,r);if(this.m_currentIntersections.length>0){const t=this.m_currentIntersections.at(-1);if(this.tryMergeResults(t,o))return!0}return this.m_currentIntersections.push(o),!0}addOverlap(e,s,i,n){let r=0,o=0;if(this.isOnArc(this.m_leftArc,Ai.constructPoint2D(this.m_rightArc.ptStart))&&(o|=16,o|=1,r++),this.isOnArc(this.m_leftArc,Ai.constructPoint2D(this.m_rightArc.ptEnd))&&(o|=16,o|=4,r++),this.isOnArc(this.m_rightArc,Ai.constructPoint2D(this.m_leftArc.ptStart))&&(o|=8,o|=2,r++),this.isOnArc(this.m_rightArc,Ai.constructPoint2D(this.m_leftArc.ptEnd))&&(o|=32,o|=2,r++),!r)return!1;r<2&&t(r>1);const a=new _s;8&o?a.assign(this.m_leftArc.ptStart):a.assign(this.m_bReversedLeft===this.m_bReversedRight?this.m_rightArc.ptStart:this.m_rightArc.ptEnd);const h=new _s;32&o?h.assign(this.m_leftArc.ptEnd):h.assign(this.m_bReversedLeft===this.m_bReversedRight?this.m_rightArc.ptEnd:this.m_rightArc.ptStart);const m=eo(a,h,s,i,e,n,o);if(this.m_currentIntersections.length>0){const t=this.m_currentIntersections.at(-1);if(this.tryMergeResults(t,m))return!0}return this.m_currentIntersections.push(m),!0}static pointToT(t,e,s){return t.getClosestCoordinateOnInterval(s,e,-1)}approximateWithCirclesImpl(t,e){let s=1;e&&e.push(0);const i=new Array(9);let n;t?n=this.m_left.getMonotonicPartParams(i.length,i):(i[0]=0,i[1]=1,n=2);const r=[],o=[],a=new _s(0,0);for(let h=1;h<n;h++){const t=new Qt(i[h-1],i[h]);for(this.m_bReversedLeft=!ho.goodOrientation(this.m_left,t),this.m_bReversedLeft?(r.push(no(a,t.vmin,0,0)),r.push(no(a,t.vmax,0,0))):(r.push(no(a,t.vmax,0,0)),r.push(no(a,t.vmin,0,0))),r[0].pt.assign(this.m_left.getCoord2D(r[0].t)),r[1].pt.assign(this.m_left.getCoord2D(r[1].t));r.length>1;){this.progress_();const t=r.at(-1);let i=t.checkCount,n=t.err;const a=t.pt.clone(),h=t.t,m=r[r.length-2].t,u=.5*(h+m),l=this.m_left.getCoord2D(u);if(n<=this.m_eps||i>=oo){const t=new Qt;if(t.setCoords(h,m),this.closeToCircularArc(this.m_left,t,a,l,r[r.length-2].pt,this.m_leftArc)){e&&(this.m_bReversedLeft?o.push(h):e.push(m)),s++,r.pop();continue}i=0,n=this.m_leftArc.maxError}t.t=u,t.pt.setCoordsPoint2D(l),n*=ao,i++,t.err=n,t.checkCount=i,r.push(no(a,h,n,i))}if(this.m_bReversedLeft&&e){const t=e.length;e.length=t+o.length,Oe(e,o.reverse(),t,0,o.length),o.length=0}r.length=0}return s}approximateWithCirclesImplPolyline(e){return t(0),{}}tryMergeResults(t,e){const s=t;let i=!1;if(s.intervalLeft.vmax===e.intervalLeft.vmin&&32&s.mask&&8&e.mask?s.intervalRight.vmax===e.intervalRight.vmin&&4&s.mask&&1&e.mask?(s.mask=-33&s.mask|32&e.mask,s.mask=-5&s.mask|4&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.vmin===e.intervalRight.vmax&&1&s.mask&&4&e.mask?(s.mask=-33&s.mask|32&e.mask,s.mask=-2&s.mask|1&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.equals(e.intervalRight)&&(s.mask=-33&s.mask|32&e.mask,s.mask|=7&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),i=!0):s.intervalLeft.vmin===e.intervalLeft.vmax&&8&s.mask&&4&e.mask?s.intervalRight.vmax===e.intervalRight.vmin&&4&s.mask&&1&e.mask?(s.mask=-9&s.mask|8&e.mask,s.mask=-5&s.mask|4&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.vmin===e.intervalRight.vmax&&1&s.mask&&4&e.mask?(s.mask=-9&s.mask|8&e.mask,s.mask=-2&s.mask|1&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.equals(e.intervalRight)&&(s.mask=-9&s.mask|8&e.mask,s.mask|=7&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),i=!0):s.intervalLeft.equals(e.intervalLeft)&&(s.intervalRight.vmax===e.intervalRight.vmin&&4&s.mask&&1&e.mask?(s.mask|=56&e.mask,s.mask=-5&s.mask|4&e.mask,s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.vmin===e.intervalRight.vmax&&1&s.mask&&4&e.mask&&(s.mask|=56&e.mask,s.mask=-2&s.mask|1&e.mask,s.intervalRight.mergeNe(e.intervalRight),i=!0)),!i){if((513===t.kind||513===e.kind)&&this.connectedIntervals(t,e)){if(513===t.kind){if(t.distance>=e.distance)return t=e,!0;if(513!==e.kind)return!1}return!0}return!1}return t.kind&e.kind&1024?this.m_bReversedLeft?(s.ptStart=e.ptStart,s.ptStartIntervalLeft=e.ptStartIntervalLeft,s.ptStartIntervalRight=e.ptStartIntervalRight):(s.ptEnd=e.ptEnd,s.ptEndIntervalLeft=e.ptEndIntervalLeft,s.ptEndIntervalRight=e.ptEndIntervalRight):1024&e.kind&&(s.ptStart=e.ptStart,s.ptEnd=e.ptEnd,s.ptStartIntervalLeft=e.ptStartIntervalLeft,s.ptStartIntervalRight=e.ptStartIntervalRight,s.ptEndIntervalLeft=e.ptEndIntervalLeft,s.ptEndIntervalRight=e.ptEndIntervalRight),1024&(t.kind|e.kind)?s.kind=1024:256&(t.kind|e.kind)?s.kind=256:s.kind=512,t=s,!0}connectedIntervals(e,s){return t(0),!1}checkAndProcessOverlap(t,e,s){const i=new Array(4),n=new Array(4),r=is(_s,4);let o=0;{const a=this.m_right.getCoord2D(s.vmin),h=this.m_right.getCoord2D(s.vmax);if(!this.m_left.isCloserThanDistance(a,e,t)||!this.m_left.isCloserThanDistance(h,e,t))return!1;const m=this.m_left.getClosestCoordinateOnInterval(a,e,-1),u=this.m_left.getCoord2D(m);_s.distance(u,a)<=t&&(r[o].assign(a),i[o]=s.vmin,n[o]=m,o++);const l=this.m_left.getClosestCoordinateOnInterval(h,e,-1),c=this.m_left.getCoord2D(l);if(_s.distance(c,h)<=t&&(r[o].assign(h),i[o]=s.vmax,n[o]=l,o++),2===o)return!!this.confirmDetectedOverlap(n[0],n[1],i[0],i[1],t)&&(this.addIntersectionPoint(a,0,e,s,266,0),this.addIntersectionPoint(h,0,e,s,266,0),!0)}{const a=this.m_left.getCoord2D(e.vmin),h=this.m_left.getCoord2D(e.vmax);if(!this.m_right.isCloserThanDistance(a,s,t)||!this.m_right.isCloserThanDistance(h,s,t))return!1;const m=this.m_right.getClosestCoordinateOnInterval(a,s,-1),u=this.m_right.getCoord2D(m);_s.distance(u,a)<=t&&(i[o]=m,r[o].assign(a),n[o]=e.vmin,o++);const l=this.m_right.getClosestCoordinateOnInterval(h,s,-1),c=this.m_right.getCoord2D(l);if(_s.distance(c,h)<=t&&(i[o]=l,n[o]=e.vmax,r[o].assign(h),o++),o>=2&&n[o-2]!==n[o-1]&&i[o-2]!==i[o-1]&&this.confirmDetectedOverlap(n[o-2],n[o-1],i[o-2],i[o-1],t))return this.addIntersectionPoint(r[o-2],0,e,s,266,0),this.addIntersectionPoint(r[o-1],0,e,s,266,0),!0}return!1}confirmDetectedOverlap(t,e,s,i,n){return ho.confirmDetectedOverlapHelper(this.m_left,t,e,this.m_right,s,i,n)&&ho.confirmDetectedOverlapHelper(this.m_right,s,i,this.m_left,t,e,n)}static confirmDetectedOverlapHelper(t,e,s,i,n,r,o){const a=[.1,.25,.75,.9],h=Qt.constructEmpty();h.setCoords(n,r);for(let m=0,u=a.length;m<u;++m){const n=pe(e,s,a[m]),r=new _s;if(t.queryCoord2D(n,r),!i.isCloserThanDistance(r,h,o))return!1}return!0}static goodOrientation(t,e){const s=t.getCoord2D(e.vmin),i=t.getCoord2D(e.vmax);return s.compare(i)<0}progress_(t=!1){}}var mo=Ft;function uo(t){return t.length>=3}class lo extends Hn{constructor(t){if(!t||t&&t.vd)return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new _s(0,0),this.m_weights=[1,0,1],void(this.m_cachedValues=null);const e={...t};e.points&&(e.f=e.points[0],e.cp=e.points[1],e.t=e.points[2],e.weights&&(e.w0=e.weights[0],e.w1=e.weights[1],e.w2=e.weights[2])),e.f?(super({start:e.f,end:e.t}),e.w0&&(e.w0<=0||e.w1<=0||e.w2<=0)&&f("weights"),this.m_cp=e.cp.clone(),this.m_weights=e.w?[1,e.w,1]:[e.w0,e.w1,e.w2],this.m_cachedValues=null):(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new _s,this.m_weights=[Number.NaN,Number.NaN,Number.NaN])}getBoundary(){return gr(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),Sa(this)}constructWeights(t,e,s,i,n,r){}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Sa(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return r.enumRationalBezier2}queryEnvelope(t){if(t instanceof ps){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Oa(this);if(null!==e){const s=new _s;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=is(_s,3);this.queryControlPoints(s),Aa(s,this.m_weights,e);const i=new _s;for(const n of e)this.queryCoord2D(n,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof cn){const e=is(_s,3);return this.queryControlPoints(e),t.transformPoints(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new lo({vd:this.m_description})}calculateLength2D(){return Ta(this,1,!1)}calculateLowerLength2D(){return _s.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return _s.distance(this.getStartXY(),this.m_cp)+_s.distance(this.getEndXY(),this.m_cp)}return _s.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){vh(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void On(new fl({pt1:this.getStartXY(),pt2:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void On(new fl({pt1:this.getEndXY(),pt2:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const i=is(_s,3);this.queryControlPoints(i),Eh(i,this.m_weights,t,e)}getCoordX(t){const e=new _s;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new _s;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=mo.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=mo.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){La(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&f("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=is(_s,3);this.queryControlPoints(i);const n=[0,0,0];rh(i,this.m_weights,t,e,i,n),s.setControlPointsAndWeights(i,n)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0;return Ze(mo.getInterpolation(e),this.getStartAttributeAsDbl(e,s),this.getEndAttributeAsDbl(e,s),n,mo.getDefaultValue(e))}getClosestCoordinate(t,e){return Ua(this,t,Qt.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s){return Ua(this,t,e,!1,s)}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),r=is($t,2),o=new Qt(0,1);let a=0;const h=is(_s,3);if(this.queryControlPoints(h),t){if(n[0]=new $t(h[0].y).sub(e).mul(this.m_weights[0]),n[1]=new $t(h[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new $t(h[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Yr(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordX(r[m].value())}else if(n[0]=new $t(h[0].x).sub(e).mul(this.m_weights[0]),n[1]=new $t(h[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new $t(h[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Yr(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordY(r[m].value());if(i)for(let m=0;m<a;m++)i[m]=r[m].value();else s&&Ke(s,a,$e);return a}intersectionOfYMonotonicWithAxisX(e,s){if(this.m_YStart===this.m_YEnd)return e===this.m_YStart?s:Number.NaN;if(e===this.m_YStart)return this.m_XStart;if(e===this.m_YEnd)return this.m_XEnd;const i=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,e,i,null);return t(2!==n),-1===n?s:i[0]}isCurve(){return!0}isDegenerate(t){return qi(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof ps)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=ps.constructEmpty();this.queryEnvelope(t);const s=Qt.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=is(_s,3);this.queryControlPoints(s);const i=[0,0,0];rh(s,this.m_weights,t.vmin,t.vmax,s,i),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Ta(this,t,!0)}lengthToT(t){return ka(this,t)}calculateWeightedAreaCentroid2D(t){return _s.getNAN()}calculateWeightedCentroid2D(){return _s.getNAN()}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=is(_s,3);return this.queryControlPoints(e),Va(e,this.m_weights,t)}getDerivative(t){return _s.getNAN()}getCurvature(t){return 0}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}queryAttributeAsDbl(t,e,s,i){}isMonotoneQuickAndDirty(){const t=is(_s,3);return this.queryControlPoints(t),eh(t)}getMonotonicPartParams(t,e){const s=wa(this),i=s.specialPointsCount();if(!e)return s.specialPointsCount();t<i&&f("");for(let n=0;n<i;n++)e[n]=s.specialPoints[n];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=je(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=je(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=je(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)je(this.m_attributes[t],this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=[t];return!!Ri(this,e)&&mh(this,e[0])}copyIgnoreAttributes(t){Ah(this,t)}calculateArea2DHelper(){return Ga(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}queryEnvelopeW(t,e){Ja(this,t,e)}setSegmentFromCoords(t,e){}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=is(_s,3);this.queryControlPoints(e);const s=_s.sqrDistance(e[1],e[0]),i=_s.sqrDistance(e[1],e[2]);let n=e[0].clone(),r=s;s>i&&(n=e[2].clone(),r=i);let o=!1;return r<=t&&0!==r&&(o=!0,this.setControlPoint1(n)),o}needsSnapControlPoints(t){if(!t)return!1;const e=is(_s,3);this.queryControlPoints(e);const s=_s.sqrDistance(e[1],e[0]),i=_s.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return sh(this)}setCoordsForIntersector(t,e,s){oh(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],ja(e,Oa(this))}reverseImpl(){this.m_weights[2]=je(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let s=0;s<3;s++)if(this.m_weights[s]!==e.m_weights[s])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=is(_s,3);this.queryControlPoints(i);const n=is(_s,3);s.queryControlPoints(n);const r=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let o=0;o<3;o++){const t=new gs;t.setCoordsPoint2DZ(i[o].mul(this.m_weights[o]),this.m_weights[o]);const s=new gs;if(s.setCoordsPoint2DZ(n[o].mul(r[o]),r[o]),!t.isEqual(s,e))return!1}return!0}getHashCodeImpl(){return 0}swapImpl(t){}afterCompletedModification(){Sa(this)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return $a(this,t,e,s)}intersect_(t,e,s,i){return 0}endPointModified(){Sa(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,i,n,r){(i<=0||r<=0||n<0)&&f("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&f("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=i,this.m_weights[1]=n,this.m_weights[2]=r,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}lo.type=r.enumRationalBezier2;class co{static constructPoint2D(t){return new co(ms.constructDouble(t.x),ms.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new ms).setNAN(),void(this.y=(new ms).setNAN());this.x=t.clone(),this.y=e.clone()}clone(){return new co(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new co(this.x.add(t.x),this.y.add(t.y))}sub(t){return new co(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}}var _o=Ft;class go extends Hn{constructor(e){void 0===e?(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new _s(0,0)):e.from?(super({XStart:e.from.x,YStart:e.from.y,XEnd:e.to.x,YEnd:e.to.y,...e.vd}),this.m_cp=e.cp.clone()):e.points?(super({XStart:e.points[0].x,YStart:e.points[0].y,XEnd:e.points[2].x,YEnd:e.points[2].y,...e.vd}),this.m_cp=e.points[1].clone()):e.copy?(super(e),this.m_cp=e.copy.m_cp.clone()):(t(0),super({XStart:0,YStart:0,XEnd:0,YEnd:0,...e.vd}),this.m_cp=new _s(0,0))}getBoundary(){return gr(this)}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),zo(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),zo(this)}getGeometryType(){return r.enumBezier2}queryEnvelope(e){t(0)}applyTransformation(e){t(0)}createInstance(){return new go({vd:this.m_description})}calculateLength2D(){return t(0),0}calculateLowerLength2D(){return t(0),0}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return _s.distance(this.getStartXY(),this.m_cp)+_s.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=is(_s,3);this.queryControlPoints(i),ma(i,t,e,s)}queryCoord2DE(t,e){ua()}getCoordX(e){return t(0),0}getCoordY(e){return t(0),0}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=_o.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=_o.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){la()}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&f("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return s.setStartXY(this.getStartXY()),s.m_cp.assign(this.m_cp),void s.setEndXY(this.getEndXY());const i=is(_s,3);this.queryControlPoints(i),Jo(i,t,e,i),s.constructPoints(i)}splitBezierIgnoreAttributes(e,s,i){t(0)}getAttributeAsDbl(e,s,i){return t(0),0}getClosestCoordinate(e,s){return t(0),0}getClosestCoordinateOnInterval(t,e,s){return Oo(this,t,e)}getYMonotonicParts(e,s){return t(0),0}getMonotonicParts(e,s){return t(0),0}intersectionWithAxis2D(e,s,i,n){return t(0),0}intersectionOfYMonotonicWithAxisX(e,s){return t(0),0}isCurve(){return!0}isLine(){return!1}isDegenerate(e){return t(0),!1}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(e){t(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(e,s){return t(0),new Qt(0,0)}queryLooseEnvelopeOnInterval(t,e){const s=is(_s,4);this.queryControlPoints(s),Jo(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(e,s){t(0)}tToLength(t){return Vo(this,t,!0)}lengthToT(e){return t(0),0}calculateWeightedAreaCentroid2D(e){return t(0),_s.getNAN()}calculateWeightedCentroid2D(){return t(0),_s.getNAN()}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPoints(e){t(0)}getTangent(e){return t(0),_s.getNAN()}getDerivative(e){return t(0),_s.getNAN()}getCurvature(e){return t(0),0}isIntersecting(e,s,i){return t(0),!1}isIntersectingPoint(e,s,i){return t(0),!1}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}queryAttributeAsDbl(e,s,i,n){t(0)}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(e,s){return t(0),0}normalizeAfterEndpointChange(){return t(0),!0}orientBottomUp(){t(0)}isDegenerateToLineHelper(e){return t(0),!1}copyIgnoreAttributes(e){t(0)}calculateArea2DHelper(){return t(0),0}absNorm(){return ta(this)}queryEnvelopeW(t,e){const s=is(_s,3);this.queryControlPoints(s),Uo(s,t,e)}setSegmentFromCoords(e,s){t(0)}snapControlPoints(e){return t(0),!1}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(e){return t(0),!1}calculateSpecialPointsForCracking(e,s){return t(0),0}ensureXYMonotone(){return t(0),!1}setCoordsForIntersector(e,s,i){t(0)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ho(e,Zo(this))}reverseImpl(){}equalsImplTol(e,s){return t(0),!1}equalsImpl(e){return t(0),!1}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){zo(this)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(e,s,i){return t(0),0}intersect_(e,s,i,n){return t(0),0}endPointModified(){zo(this)}clearEndPointModified(){t(0)}}go.type=r.enumBezier2;class po{constructor(e){return e.coefsT?(this.m_zeroCtor=e.zeroCtor,this.m_elements=e.coefsT.map((t=>t.clone())),t(this.m_elements.length===e.power+1),void this.updatePower()):e.coef0?(this.m_zeroCtor=e.zeroCtor,void(this.m_elements=[e.coef0.clone()])):e.copy?(this.m_zeroCtor=e.copy.m_zeroCtor,void(this.m_elements=e.copy.m_elements.map((t=>t.clone())))):(this.m_zeroCtor=e.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map((t=>t.clone())),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map((t=>t.clone())),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}fmsThis(e,s){return t(0),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}addThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(e){return t(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(e){return t(0),this}subNumber0(e){return t(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let o=e;o<=n;++o)this.m_elements[o].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let o=n+1;o<=i;++o)this.m_elements[o].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let a=s;a<=r;++a)this.m_elements[a].fmsThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let a=i;a<this.m_elements.length;++a)this.m_elements[a]=new this.m_zeroCtor;for(let a=r+1;a<=n;++a)this.m_elements[a].subThis(t.m_elements[o++]);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let n=0,r=e.power();n<=r;n++){const i=this.m_elements[t].clone();i.mulThis(e.m_elements[n]),t+n<s.length?s[t+n].addThis(i):s.push(i)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulNumber0(e){return t(0),this}mulBigint0(e){return t(0),this}mulBigIntThis(e){return t(0),this}mulInt320(e){return t(0),this}div0(e){return t(0),this}absThis(){return t(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let r=n.power();const o=n.power()-t.power();let a=o;for(e.m_elements=is(e.m_zeroCtor,o+1);;){if(r<t.power()){s.assignMove(n);break}if(r===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[a]=s.clone()}a--,r--}s.updatePower(),e.updatePower()}divThis(e){return t(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(e,s){t(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(ms.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce(((t,e)=>{const s=e.hiBitIndex();return t<s?s:t}),0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class fo extends po{constructor(t){super(void 0===t?{zeroCtor:ms}:{...t,zeroCtor:ms})}clone(){return new fo({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let n=e-1;n>=0;--n)s.mulThis(i),s.addThis(this.m_elements[n].abs());return s}}class xo extends po{constructor(t){super(void 0===t?{zeroCtor:fo}:{...t,zeroCtor:fo})}clone(){return new xo({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new fo({coef0:t[s]}));return this.updatePower(),this}}function yo(){return{polypoly1:new xo,polypoly2:new xo,polyX2:new fo,polyY2:new fo,polyX2Deriv:new fo,polyY2Deriv:new fo,polypolyX1:new xo,polypolyY1:new xo,polypolyX1Deriv:new xo,polypolyY1Deriv:new xo,lazyPolypolyD1:new xo,lazyPolypolyD1Deriv:new xo,lazyPolyD2:new fo,lazyPolyD2Deriv:null,polypoly11:new xo,polypoly12:new xo,tempPp:new xo,tempPp1:new xo,tempPp2:new xo,tempP:new fo,tempP1:new fo,tempP2:new fo}}function vo(e,s,i,n,r,o,a,h,m,u,l,c,d,_,g,p,f,x=!1){const y=yo();y.polyX2.construct(a,h),y.polyY2.construct(m,u),y.polypolyX1.constructFromMPValues(e,s),y.polypolyY1.constructFromMPValues(i,n),y.polypoly11.assignCopy(y.polypolyX1),y.polypoly12.assignCopy(y.polypolyY1),l&&(y.lazyPolyD2.construct(l,c),y.polypoly11.mulElementThis(y.lazyPolyD2),y.polypoly12.mulElementThis(y.lazyPolyD2)),r?(y.lazyPolypolyD1.constructFromMPValues(r,o),y.lazyPolypolyD1Deriv=new xo({copy:y.lazyPolypolyD1}),y.lazyPolypolyD1Deriv.derivative1This(),y.tempPp.assignCopy(y.lazyPolypolyD1),y.tempPp.mulElementThis(y.polyX2),y.polypoly11.subThis(y.tempPp),y.tempPp.assignCopy(y.lazyPolypolyD1),y.tempPp.mulElementThis(y.polyY2),y.polypoly12.subThis(y.tempPp)):(y.polypoly11.sub0This(y.polyX2),y.polypoly12.sub0This(y.polyY2)),y.polypolyX1Deriv.assignCopy(y.polypolyX1),y.polypolyX1Deriv.derivative1This(),y.polypolyY1Deriv.assignCopy(y.polypolyY1),y.polypolyY1Deriv.derivative1This(),r&&(y.polypolyX1Deriv.mulThis(y.lazyPolypolyD1),y.tempPp2.assignCopy(y.lazyPolypolyD1Deriv),y.tempPp2.mulThis(y.polypolyX1),y.polypolyX1Deriv.subThis(y.tempPp2),y.polypolyY1Deriv.mulThis(y.lazyPolypolyD1),y.tempPp2.assignCopy(y.lazyPolypolyD1Deriv),y.tempPp2.mulThis(y.polypolyY1),y.polypolyY1Deriv.subThis(y.tempPp2)),y.polyX2Deriv.assignCopy(y.polyX2),y.polyX2Deriv.derivative1This(),y.polyY2Deriv.assignCopy(y.polyY2),y.polyY2Deriv.derivative1This(),l&&(t(null===y.lazyPolyD2Deriv),y.lazyPolyD2Deriv=new fo({copy:y.lazyPolyD2}),y.lazyPolyD2Deriv.derivative1This(),y.polyX2Deriv.mulThis(y.lazyPolyD2),y.tempP1.assignCopy(y.lazyPolyD2Deriv),y.tempP1.mulThis(y.polyX2),y.polyX2Deriv.subThis(y.tempP1),y.polyY2Deriv.mulThis(y.lazyPolyD2),y.tempP1.assignCopy(y.lazyPolyD2Deriv),y.tempP1.mulThis(y.polyY2),y.polyY2Deriv.subThis(y.tempP1)),y.polypoly1.assignCopy(y.polypoly11),y.polypoly1.mulElementThis(y.polyX2Deriv),y.tempPp.assignCopy(y.polypoly12),y.tempPp.mulElementThis(y.polyY2Deriv),y.polypoly1.addThis(y.tempPp),y.polypoly2.assignCopy(y.polypolyX1Deriv),y.polypoly2.mulElementThis(y.polyY2Deriv),y.tempPp.assignCopy(y.polypolyY1Deriv),y.tempPp.mulElementThis(y.polyX2Deriv),y.polypoly2.subThis(y.tempPp);let v=[];const P=[];f||(f=[]),p||(p=[]),Io(y.polypoly11,y.polypoly12,y.tempP);let b=57,C=.25*Number.EPSILON;const D=[];let S=No(y.tempP,d,g,C,b,D);if(S<0)return-1;for(let t=0;t<S;t++){fo.evaluateCoefs(y.polypoly11,ms.constructDouble(D[t]),y.tempP1);const e=[];let s=No(y.tempP1,d,_,C,b,e);if(0!==s)if(fo.evaluateCoefs(y.polypoly12,ms.constructDouble(D[t]),y.tempP2),s<0){s=No(y.tempP2,d,_,C,b,e),s<0&&E("mp_curve_proximity");for(let i=0;i<s;i++)P.push(q(e[i],D[t]))}else{const i=y.tempP2.absEvaluate(us);i.mulThis(ms.constructDouble(1e-12));for(let n=0;n<s;n++){const s=y.tempP2.evaluate(ms.constructDouble(e[n]));s.absThis(),s.lt(i)&&P.push(q(e[n],D[t]))}}}S=P.length,Io(y.polypoly1,y.polypoly2,y.tempP),b=57,C=.25*Number.EPSILON;const w=[];let A=No(y.tempP,d,g,C,b,w);A<0&&(A=0);for(let t=0;t<A;t++){fo.evaluateCoefs(y.polypoly1,ms.constructDouble(w[t]),y.tempP1);const e=[];let s=No(y.tempP1,d,_,C,b,e);if(0!==s)if(fo.evaluateCoefs(y.polypoly2,ms.constructDouble(w[t]),y.tempP2),s<0){if(s=No(y.tempP2,d,_,C,b,e),s<0)continue;for(let i=0;i<s;i++)v.push(q(e[i],w[t]))}else{const i=y.tempP2.absEvaluate(us);i.mulThis(ms.constructDouble(1e-12));for(let n=0;n<s;n++){const s=y.tempP2.evaluate(ms.constructDouble(e[n]));s.absThis(),s.lt(i)&&v.push(q(e[n],w[t]))}}}if(A=v.length,0===S&&0===A)return 0;v=v.concat(P),v.sort(((t,e)=>x?$e(t.second,e.second):$e(t.first,e.first)));const T=ts(v,((t,e)=>t.first===e.first&&t.second===e.second));v=v.slice(0,T),p.length=0,f.length=0;for(const t of v)p.push(t.first),f.push(t.second);return t(p.length===f.length),f.length}function Po(t,e,s,i,n,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(ms.constructInt32(1)).isZero();if(1===t.power()){const s=Co(t.getElement(1),t.getElement(0),e,r.at(0));return r[0].limitPrecisionThis(i),1!==s?0:(r[0].limitPrecisionThis(i),1)}if(2===t.power()){return Do(t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(3===t.power()){return So(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(4===t.power()){return wo(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}return Yo(t,e,s,i,a,n,r,o)}function bo(){return{polyIntersect:new fo,polyX1:new fo,polyY1:new fo,polyX1Deriv:new fo,polyY1Deriv:new fo,lazyPolyD1:new fo,lazyPolyD1Deriv:new fo,tempP:new fo,tempP1:new fo,tempP2:new fo,polypoly1Proximity:new xo,polypoly2Proximity:new xo}}function Eo(t,e,s,i,n,r,o,a,h,m,u){const l=bo();l.polyX1.construct(t,e),l.polyY1.construct(s,i),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.polyIntersect.assignCopy(l.polyX1),l.polyIntersect.mulThis(l.polyX1),l.polyIntersect.mulElementThis(o[0]),l.tempP.assignCopy(l.polyY1),l.tempP.mulThis(l.polyY1),l.tempP.mulElementThis(o[1]),l.polyIntersect.addThis(l.tempP),l.polyIntersect.add0(o[2]);{const n=o[0].clone(),r=n.clone();r.sqrThis();const a=o[1].clone(),h=a.clone();h.sqrThis();const m=o[2].clone(),u=n.clone();u.subThis(a),l.polyX1.construct(t,e),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1.construct(s,i),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(h),l.tempP.mulElementThis(m),l.polypoly1Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(a.mul(u).mul(m).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(n.mul(h)),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1),l.tempP1.mulElementThis(r.mul(a)),l.tempP.addThis(l.tempP1),l.tempP.add0(u.mul(u).mul(m)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulElementThis(u.mul(n).mul(a).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.construct0(n.mul(u).mul(u)),l.polypoly1Proximity.addElement(l.tempP),l.polypoly1Proximity.updatePower(),l.tempP.construct0(ls),l.polypoly2Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1Deriv),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1Deriv),l.tempP.addThis(l.tempP1),l.tempP.mulElementThis(n.mul(a)),l.polypoly2Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1Deriv),l.tempP.mulElementThis(u.mul(n)),l.polypoly2Proximity.addElement(l.tempP),l.polypoly2Proximity.updatePower()}const c=[],d=[];u||(u=[]);let _=2*l.polyIntersect.power()+58;const g=.5*Number.EPSILON,p=No(l.polyIntersect,a,h,g,_,d);if(p<0)return-1;Io(l.polypoly1Proximity,l.polypoly2Proximity,l.tempP),_=2*l.tempP.power()+58;let f=No(l.tempP,a,h,g,_,c);if(f<0&&(f=0),0===p&&0===f)return 0;const x=c.concat(d);u.length=x.length,Oe(u,x,0,0,x.length),Ue(u);const y=ts(u,((t,e)=>0===$e(t,e)));return u.length=y,u.length}function Co(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function Do(t,e,s,i,n,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),n.containsCoordinate(1)?1:0;return Co(e,s,n,o[0])}if(r){let e=2;return o[0].setInt32(1),s.equals(t)?(o[1].setInt32(1),e=1):o[1].setThis(s.div(t)),n.containsCoordinate(o[1].value())||(e=1),n.containsCoordinate(o[0].value())||(e--,o[0].setThis(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=je(o[0],o[0]=o[1])),e}const a=e.clone();a.sqrThis();const h=t.clone();if(h.mulThis(s).ldexpThis(2).negateThis().addThis(a),h.LZ())return 0;const m=i+2,u=ms.sqrt(h,m),l=u.clone();e.LZ()&&l.negateThis(),l.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let c=0;return o[0].setThis(l).divThis(ms.constructAssign(t,m)).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[0].value()))&&c++,u.isZero()||l.isZero()||(o[c].setThis(s).divThis(l).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[c].value()))&&c++,2===c&&o[0].gt(o[1])&&(o[1]=je(o[0],o[0]=o[1]))),c}function So(e,s,i,n,r,o,a,h){if(e.isZero()){return Do(s,i,n,r,o,a,h)}const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=je(h[t],h[t]=h[s-1]),s--);e=s}return Ke(h,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let t=0;o.containsCoordinate(0)&&(h[0].setInt32(0),t=1);return m(Do(e,s,i,r,o,a,h.slice(1)),t)}if(a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const i=s.add(e),a=n.negate(),u=e.add(i).add(a).isZero();return m(Do(e,i,a,r,o,u,h.slice(t)),t)}const u=new ms,l=new ms,c=new ms,d=s.clone();if(d.isZero())l.setThis(i),l.divThis(e),c.setThis(n),l.divThis(e);else{d.divThis(e).divDoubleThis(3).negateThis();const t=s.clone();t.sqrThis();const r=e.clone();r.sqrThis(),l.setThis(e),l.mulThis(i).mulDoubleThis(3).subThis(t).divThis(r).divDoubleThis(3),c.setThis(t),c.mulThis(s),c.ldexpThis(1),u.setThis(e),u.mulThis(s).mulThis(i).mulDoubleThis(9),c.subThis(u),u.setThis(r),u.mulThis(n).mulDoubleThis(27),c.addThis(u),c.divThis(r).divThis(e).divDoubleThis(27)}if(l.isZero()){const t=c.clone();return t.negateThis(),t.isZero()?(h[0].setThis(d),Lo(o,r,h,1)):(h[0].setThis(ms.cubicRoot(c,r).add(d)),Lo(o,r,h,1))}const _=c.clone();if(_.sqrThis().ldexpThis(-2),u.setThis(l.clone()),u.sqrThis().mulThis(l).divDoubleThis(27),_.addThis(u),_.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(l),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(d),h[1].addThis(d),Lo(o,r,h,2);if(_.GZ())return _.setThis(ms.sqrt(_,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.addThis(_),h[0].setThis(ms.cubicRoot(u,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.subThis(_),h[0].addThis(ms.cubicRoot(u,r+8)),h[0].addThis(d),Lo(o,r,h,1);u.setThis(l),u.divDoubleThis(3).negateThis(),t(u.GEZ());const g=ms.sqrt(u,r+8),p=g.clone();p.negateThis(),p.addThis(d),g.addThis(d);const f=ms.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),x=ms.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),y=new fo({zeroCtor:ms});y.construct0(n),y.addElement(i),y.addElement(s),y.addElement(e);const v=new fo({copy:y});v.derivative1This();let P=0;const b=is(ms,4);b[P++].setThis(f),p.gt(f)&&p.lt(x)&&b[P++].setThis(p),g.gt(f)&&g.lt(x)&&b[P++].setThis(g),b[P++].setThis(x);const E=3*r;let C=52,D=Number.EPSILON;for(;C<E;)2*C<=E?(D*=D,C*=2):(D*=Number.EPSILON,C+=52);C+=2;let S=0,w=!1;for(let t=1;t<P;t++){if(Ro(y,v,b[t-1],b[t],D,C,h[0])){S=1,w=t+1<P;break}}if(!S)return 0;if(w){const e=new fo({zeroCtor:ms,coef0:h[0]});e.negateThis(),e.addElement(us);const s=new fo({zeroCtor:ms}),i=new fo({zeroCtor:ms});y.div(e,s,i),t(2===s.power()),t(0===i.power());const n=Do(s.getElement(2),s.getElement(1),s.getElement(0),r,o,!1,h.slice(1));t(n>=0&&n<=2),S+=n}return Lo(o,r,h,S)}function wo(t,e,s,i,n,r,o,a,h){if(t.isZero())return So(e,s,i,n,r,o,a,h);const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=je(h[t],h[t]=h[s-1]),s--);e=s}return Ke(h,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let n=0;o.containsCoordinate(0)&&(h[0].setInt32(0),n=1);return m(So(t,e,s,i,r,o,a,h.slice(n)),n)}const u=new fo({zeroCtor:ms,coef0:n});if(u.addElement(i),u.addElement(s),u.addElement(e),u.addElement(t),a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const e=new fo({zeroCtor:ms,coef0:ms.constructInt32(-1)});e.addElement(ms.constructInt32(1));const s=new fo({zeroCtor:ms}),i=new fo({zeroCtor:ms});u.div(e,s,i);return m(So(3===s.power()?s.getElement(3):ls.clone(),s.power()>=2?s.getElement(2):ls.clone(),s.power()>=1?s.getElement(1):ls.clone(),s.getElement(0),r,o,s.evaluate(us).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(o.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);const e=So(3===u.power()?u.getElement(3):ls.clone(),u.power()>=2?u.getElement(2):ls.clone(),u.power()>=1?u.getElement(1):ls.clone(),u.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),Ke(h,t,((t,e)=>t.compare(e))),t}let l=52,c=Number.EPSILON;for(;l<r;)2*l<=r?(c*=c,l*=2):(c*=Number.EPSILON,l+=52);l+=2;const d=Xo(u),_=ms.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(d.lt(_)?d:_).mul(ms.constructDouble(c)).toDouble(),Yo(u,o,c,l,a,!1,h,4)}function Ao(t,e){let s=t,i=e;i.power()>s.power()&&(i=je(s,s=i));const n=s.power()-i.power(),r=new fo({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let o=0,a=s.power();o<a;o++)if(o>=n){const t=new fo({copy:i.getElement(o-n)});t.mulThis(r);const e=s.getElement(o).sub(t);s.setElement(o,e)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),To(s)}function To(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Io(t,e,s){const i=t.clone(),n=e.clone();for(To(i),To(n);0!==i.power()||0!==n.power();)Ao(i,n);s.assignMove(i.getElement(0))}function No(t,e,s,i,n,r){r.length=0;const o=t.power(),a=is(ms,2*o+4),h=Po(t,s||Qt.unit(),i,n,!1,a,a.length);if(h>0){r.length=0;for(let t=0;t<h;t++){const e=a[t].value();t>0&&e<=r.at(-1)||r.push(e)}return r.length}return h}function Mo(e,s,i){if(t(i>=1),0===e.power())return e.isZero()?-1:0;const n=e.getElement(0);return n.negateThis(),n.divThis(e.getElement(1)),s[0].setThis(n),1}function qo(e,s,i,n){if(e.power()<2)return Mo(e,i,n);t(n>=1);let r=e.getElement(1);r.mulThis(e.getElement(1));const o=e.getElement(0);if(o.mulThis(e.getElement(2)),o.ldexpThis(2),r.subThis(o),r.LZ())return 0;if(r.isZero()){const t=e.getElement(1);return t.negateThis(),t.divThis(e.getElement(2)),t.ldexpThis(-1),t.limitPrecisionThis(s),i[0].setThis(t),1}t(n>=2),r=ms.sqrt(r,s+8);const a=e.getElement(1);a.negateThis();const h=a.clone();h.subThis(r),h.divThis(e.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(s);const m=a.clone();return m.addThis(r),m.divThis(e.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(s),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}function Ro(t,e,s,i,n,r,o){let a=s.clone(),h=i.clone();a.limitPrecisionThis(r),h.limitPrecisionThis(r);let m=t.evaluate(a);m.limitPrecisionThis(r+2);let u=t.evaluate(h);if(u.limitPrecisionThis(r+2),m.GEZ()&&u.GEZ()||m.LEZ()&&u.LEZ())return m.absLessAbs(u)?(o=a,m.isZero()):(o=h,u.isZero());const l=u.LZ();l&&(u=je(m,m=u),h=je(a,a=h));const c=l?h:a,d=l?a:h,_=a.add(h).ldexpThis(-1);_.limitPrecisionThis(r);const g=h.sub(a);g.limitPrecisionThis(r),g.absThis();const p=g.clone();let f=t.evaluate(_),x=e.evaluate(_);const y=new fo({copy:t}),v=new fo({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=us.clone();i.ldexpThis(-(r+2));for(let n=64;n<s;){y.limitPrecisionThis(n),v.limitPrecisionThis(n);const r=y.evaluate(_),o=v.evaluate(_),a=r.sub(f),h=o.sub(x);if(a.divThis(f).absThis().lt(i)&&(x.isZero()||h.divThis(x).absThis().lt(i)))break;y.assignCopy(t),v.assignCopy(e),n=Math.min(n+64,s)}f.limitPrecisionThis(r+2),x.limitPrecisionThis(r+2)}const P=1,b=4;let C=b;const D=2;let S=1,w=0,A=0,T=P;const I=32,N=ms.constructDouble(.25*n),M=ms.constructDouble(.5001);let q=0;const R=300;for(;++q<R;){if(q>I&&w>0||x.isZero()||T===D&&w>1||T===P&&C<b)T=P,S>1&&S--;else if(T=D,A>1){const t=g.mul(x);t.absThis(),t.ldexpThis(-3),t.absLessAbs(f)&&S++}g.setThis(p);const t=new ms;let e=!1;if(T===P)do{if(A>2){const e=g.clone();if(e.absThis(),e.ldexpThis(4),d.sub(c).ldexpThis(-1).gt(e)){if(_.equals(c)){t.setThis(_),_.setThis(c.add(e)),_.limitPrecisionThis(r),p.setThis(_.sub(t));break}if(_.equals(d)){t.setThis(_),_.setThis(d.sub(e)),_.limitPrecisionThis(r),p.setThis(_.sub(t));break}}}p.setThis(h.sub(a)),p.ldexpThis(-1),p.limitPrecisionThis(r),t.setThis(_),_.setThis(a.add(p)),_.limitPrecisionThis(r),_.lt(c)?_.setThis(c):_.gt(d)&&_.setThis(d),e=a.equals(_)||h.equals(_)}while(0);else for(;;){if(p.setThis(f.div(x)),p.limitPrecisionThis(r),1!==S&&p.mulDoubleThis(S),t.setThis(_),_.subThis(p),_.limitPrecisionThis(r),e=_.equals(t),_.lt(c)){if(S>1){_.setThis(t),S--;continue}p.setThis(t.sub(c)),_.setThis(c)}else if(_.gt(d)){if(S>1){_.setThis(t),S--;continue}p.setThis(t.sub(d)),_.setThis(d)}break}if(e||p.absLessAbs(N)){t.equals(_)||(f=y.evaluate(_),f.limitPrecisionThis(r+2));break}f=y.evaluate(_),f.limitPrecisionThis(r+2),x=v.evaluate(_),x.limitPrecisionThis(r+2);const s=a.clone(),i=h.clone();f.LZ()?(m.setThis(f),a.setThis(_)):(u.setThis(f),h.setThis(_)),T===D&&(a.equals(s)&&h.equals(i)||A>1&&!p.absLessAbs(M.mul(g)))?w++:w=0,T===P?(C++,A=0):(C=0,A++)}return q>=R&&E("Root_finder iterations exceeded"),o.setThis(_),!0}function Fo(t,e,s,i,n){const r=t.evaluate(s);if(r.isZero())return!0;const o=ms.constructDouble(.5*i),a=s.clone();a.subThis(o);const h=t.evaluate(a),m=s.clone();m.addThis(o);const u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ())return!0;if(r.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ())return!0;const l=h.LEZ()&&u.LEZ(),c=h.GEZ()&&u.GEZ();let d=!1;return l?r.gt(h)&&r.gt(u)&&(d=!0):c&&r.lt(h)&&r.lt(u)&&(d=!0),!!d&&r.absThis().lt(ms.constructDouble(1e-17))}function Yo(e,s,i,n,r,o,a,h){t(i>0),t(h>=e.power());const m=a,u=[];let l=[];const c=new fo({zeroCtor:e.m_zeroCtor}),d=new fo({zeroCtor:e.m_zeroCtor}),_=new fo({zeroCtor:e.m_zeroCtor}),g=ms.constructDouble(i),p=ms.constructDouble(s.vmin),f=ms.constructDouble(s.vmax),x=p.sub(g),y=f.add(g),v=Xo(e),P=v.clone();if(P.negateThis(),x.lt(P))x.setThis(P.sub(g));else if(x.gt(v))return 0;if(y.gt(v))y.setThis(v.add(g));else if(y.lt(P))return 0;let b=e,E=null;if(r){const t=new fo({coef0:ms.constructInt32(-1)});t.addElement(us),E=new fo,b=E;const s=new fo,i=new fo;for(e.div(t,s,i),E.assignCopy(s);b.evaluate(us).isZero();)b.div(t,s,i),E.assignCopy(s)}let C=!1;if(b.power()>0&&b.getElement(0).isZero())for(C=!0,E||(E=new fo({copy:b}),b=E);b.getElement(0).isZero();)E.shiftRight(1);let D=n+2*b.power()+2,S=i/Math.pow(2,b.power()+2),w=D;if(ls.gt(x)&&ls.lt(y))for(let t=0,M=b.power();t<M;t++)if(b.getElement(t).isZero()){u.push(ls.clone());break}for(let M=b.power()-1;M>0;M--)if(S*=2,D-=2,w-=2,b.power()-M!=1)if(b.power()-M!=2){d.assignMove(_),_.assignMove(b.derivative(M-1));let t=[];for(let e=0,s=l.length;e<s;++e)if(l[e].first.lte(l[e].second)){const s=new ms;if(Ro(d,c,l[e].first,l[e].second,S,D,s)){u.push(s);let i=s.sub(g);i.limitPrecisionThis(w),t.push(q(l[e].first,i)),i=s.add(g),i.limitPrecisionThis(w),t.push(q(i,l[e].second))}else t.push(l[e])}l=t,t=[],c.assignMove(d)}else{d.assignMove(b.derivative(M));const e=qo(d,D,m,h);t(e>=0&&e<=2);for(let t=0;t<e;t++)m[t].gt(x)&&m[t].lt(y)&&!m[t].isZero()&&u.push(m[t].clone());if(u.length>1&&u.sort(((t,e)=>t.compare(e))),u.length>0){let t=u[0].sub(g);t.limitPrecisionThis(w),l.push(q(x.clone(),t));let e=1===u.length?y.clone():u[1].sub(g);t=u[0].add(g),t.limitPrecisionThis(w),e.limitPrecisionThis(w),l.push(q(t,e)),u.length>1&&(e=2===u.length?y.clone():u[2].sub(g),e.limitPrecisionThis(w),t=u[1].add(g),t.limitPrecisionThis(w),l.push(q(t,e)),u.length>2&&(t=u[2].add(g),t.limitPrecisionThis(w),l.push(q(t,y.clone()))))}else l.push(q(x.clone(),y.clone()));c.assignCopy(d),_.assignMove(b.derivative(M-1))}else{d.assignMove(b.derivative(M));1===Mo(d,m,h)&&(m[0].gt(x)&&m[0].lt(y)&&!m[0].isZero()&&u.push(m[0].clone()),c.assignMove(d),_.assignMove(b.derivative(M-1)))}u.sort(((t,e)=>t.compare(e))),0===l.length&&(c.assignMove(b.derivative(b.power())),c.isZero()||l.push(q(x.clone(),y.clone())));let A=0,T=0,I=0;const N=new ms;for(;;){if(T<l.length){if(l[T].first.gt(l[T].second)){T++;continue}let t=!1;if(I<u.length&&u[I].lt(l[T].first)&&(t=!0),!t){Ro(b,c,l[T].first,l[T].second,i,n,N)&&(N.lt(p)?m[A++].setThis(p):N.gt(f)?m[A++].setThis(f):m[A++].setThis(N)),T++;continue}}if(!(I<u.length))break;0!==I&&u[I-1].equals(u[I])||Fo(b,c,u[I],i)&&(N.setThis(u[I]),N.lt(p)?N.setThis(p):N.gt(f)&&N.setThis(f),0!==A&&m[A].equals(N)||m[A++].setThis(N)),I++}return C&&ls.gt(x)&&ls.lt(y)&&(m[A++].setThis(ls),Ke(m,A,((t,e)=>t.compare(e)))),r&&us.gt(x)&&us.lt(y)&&(m[A++].setThis(us),Ke(m,A,((t,e)=>t.compare(e)))),A}function Xo(t){const e=t.getElement(t.power());e.limitPrecisionThis(53);const s=ls.clone();for(let i=0,n=t.power();i<n;i++){const n=t.getElement(i);n.limitPrecisionThis(53),n.divThis(e).absThis(),n.gt(s)&&s.setThis(n)}return s.addThis(us),s.mulThis(ms.constructDouble(1+100*Number.EPSILON)),s}function Lo(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=je(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=je(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=je(s[1],s[1]=s[2]))));for(let r=0;r<n;++r)s[r].limitPrecisionThis(e);return n}function zo(t){t.m_cachedValues=null}function Vo(t,e,s){const i=is(_s,3);return t.queryControlPoints(i),Bo(i,e,s)}function Bo(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Bo(t,1,!1)}if(1===e)return ko(t);const i=is(_s,3);return $o(t,e,i,null),ko(i)}function ko(e){if(e[0].equals(e[1]))return _s.distance(e[2],e[0]);if(e[1].equals(e[2]))return _s.distance(e[0],e[2]);const s=_s.distance(e[0],e[1])+_s.distance(e[2],e[1]),i=_s.distance(e[0],e[2]);if(s-i<=s*Number.EPSILON)return i;const n=1,r=is(_s,3);aa(e,r,!0);const o=4*(ve(r[2].x)+ve(r[2].y)),a=2*(r[2].x*r[1].x+r[2].y*r[1].y),h=ve(r[1].x)+ve(r[1].y);if(1e-14*(Math.abs(a)+Math.abs(h))>=Math.abs(o)){if(1e-14*Math.abs(h)>=Math.abs(a)){return Math.sqrt(h)*n}t(0);return 2/(3*a)*(Math.pow(a*n+h,1.5)-Math.pow(h,1.5))}const m=a/o,u=h/o,l=u-m*m,c=n+m;if(0===l){if(m>=0&&c>=0||m<=0&&c<=0){return Math.abs(.5*Math.sqrt(o)*(c*c-m*m))}return.5*Math.sqrt(o)*(c*c+m*m)}const d=Math.sqrt(l+c*c),_=Math.sqrt(u);return.5*Math.sqrt(o)*(c*d-m*_+l*Math.log(Math.abs((c+d)/(m+_))))}function Go(e,s){return t(0),_s.getNAN()}function Wo(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Zo(t){return t.m_cachedValues}function Ho(t,e){t.m_cachedValues=e}function Oo(t,e,s,i,n){N(Qt.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=is(_s,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=jo(r,e,a);if(s.containsCoordinate(a[0]))o=_s.distance(e,h);else{a[0]=s.vmin,ma(r,a[0],h),o=_s.distance(h,e);const t=new _s;ma(r,s.vmax,t);const i=_s.distance(t,e);o>i&&(h.setCoordsPoint2D(t),a[0]=s.vmax,o=i)}return a[0]}function jo(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),r=t[0].sub(e),o=r.dotProduct(n),a=r.dotProduct(i)+2*n.dotProduct(n),h=3*n.dotProduct(i),m=i.dotProduct(i),u=new Array(3),l=wr(m,h,a,o,Qt.unit(),!1,u),c=t[0].clone();let d=0,_=_s.sqrDistance(t[0],e),g=_s.sqrDistance(t[2],e);g<_&&(d=1,c.assign(t[2]),_=g);for(let p=0;p<l;p++){const s=new _s;ma(t,u[p],s),g=_s.sqrDistance(s,e),g<_&&(_=g,c.assign(s),d=u[p])}return s&&(s[0]=d),c}function Uo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=is(_s,3);Jo(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function Qo(e,s,i){t(0)}function Ko(t){let e=!1;for(let s=0;s<2;s++){const i=j(t[0][s],t[2][s]);i>0?(j(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(j(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function $o(t,e,s,i){(new _s).setCoordsPoint2D(t[0]);(new _s).setCoordsPoint2D(t[1]);(new _s).setCoordsPoint2D(t[2]);const n=new _s,r=new _s,o=new _s;if(ye(t[0],t[1],e,n),ye(t[1],t[2],e,r),ye(n,r,e,o),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(o)),i){const e=t[2];i[0].assign(o),i[1].assign(r),i[2].assign(e)}}function Jo(t,e,s,i){if(e===s){const s=new _s;return ma(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=is(_s,3);$o(t,s,n,null),$o(n,e/s,null,n),ma(t,e,n[0]),ma(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function ta(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function ea(e,s,i,n,r){return t(0),0}function sa(e,s,i,n,r){return t(0),0}function ia(e,s,i,n,r){return t(0),0}function na(e,s,i,n,r,o,a,h,m,u){return t(0),0}function ra(t,e,s,i,n,r,o,a,h,m){if(em(s))return new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),na();const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=is(_s,3);{e.queryControlPoints(d);const t=is(_s,3),i=new cn;s.canonicToWorldTransformation(i);const n=new cn;n.setInvert(i),n.transformPoints(d,3,t);const r=is(ms,3),a=is(ms,3);ha(t,r,a);const h=is(ms,3);h[0].setDouble(s.getSemiMinorAxis()),h[0].sqrThis(),h[1].setDouble(s.getSemiMajorAxis()),h[1].sqrThis(),h[2]=h[0],h[2].mul(h[1]),h[2].negate();const m=Eo(r,2,a,2,null,0,h,!0,Qt.unit(),Qt.unit(),l);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new _s;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new _s;s.queryCoord2D(r,a),_s.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const _=[0,1];for(let g=0;g<2;g++){const t=0===g?s.getStartXY():s.getEndXY(),e=[0];jo(d,t,e);const i=new _s;ma(d,e[0],i),_s.distance(t,i)<=o&&(l.push(e[0]),c.push(_[g]))}for(let g=0;g<2;g++){const t=[0,2];{const e=s.getClosestCoordinate(d[t[g]],!1),i=new _s;s.queryCoord2D(e,i),_s.distance(d[t[g]],i)<=o&&(l.push(_[g]),c.push(e))}}return dl(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function oa(t,e,s,i,n,r,o,a,h,m){const u=is(_s,3);e.queryControlPoints(u);const l=is(_s,3);if(s.queryControlPoints(l),Ji(u,l,3)<0)return oa(t,s,e,i,r,n,o,a,h,!m);const c=Ki(e,s);if($i(e,s,o=Math.max(o,c)))return 0;if(da(e,s,i,n,r,o,a,h,m))return 2;const d=new Qt(0,1),_=new Qt(0,1);{const t=new Di;Uo(u,Qt.unit(),t);const e=new Di;Uo(l,Qt.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Qo(),Qo(),d.isEmpty()||_.isEmpty())return 0;Jo(u,d.vmin,d.vmax,u),Jo(l,_.vmin,_.vmax,l)}}const g=gl(u,2,l,2,o);if(0===g)return 0;const p=[],f=[];if(-1===g){const t=is(ms,3),e=is(ms,3);ha(u,t,e);const s=is(ms,3),i=is(ms,3);ha(l,s,i);const n=vo(t,2,e,2,null,0,s,2,i,2,null,0,!0,Qt.unit(),Qt.unit(),p,f,m);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new _s,i=new _s;ma(l,f[e],i),ma(u,p[e],s),_s.distance(s,i)<=o&&(p[t]=p[e],f[t]=f[e],t++)}p.length=t,f.length=t}}for(let x=0;x<2;x++){const t=0===x?u:l,e=0===x?l:u;for(let s=0;s<2;s++){const i=0===s?0:2,n=[0];jo(e,t[i],n);const r=new _s;ma(e,n[0],r),_s.distance(t[i],r)<=o&&(0===x?(p.push(0===i?0:1),f.push(n[0])):(f.push(0===i?0:1),p.push(n[0])))}}if(0===p.length)return 0;if(!d.equalsRange(0,1))for(let x=0;x<p.length;++x)p[x]=go.recalculateParentT(d.vmin,d.vmax,p[x]);if(!_.equalsRange(0,1))for(let x=0;x<f.length;++x)f[x]=go.recalculateParentT(_.vmin,_.vmax,f[x]);return dl(t,e,s,p,f,p.length,i,n,r,o,a,h,m)}function aa(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function ha(t,e,s){e[0].setDouble(t[0].x),e[1].setDouble(t[1].x),e[1].subThis(e[0]),e[1].ldexpThis(1),e[2].setThis(e[0]),e[2].addDoubleThis(t[2].x),e[2].subThis(ms.constructDouble(t[1].x).ldexpThis(1)),s[0].setDouble(t[0].y),s[1].setDouble(t[1].y),s[1].subThis(s[0]),s[1].ldexpThis(1),s[2].setThis(s[0]),s[2].addDoubleThis(t[2].y),s[2].subThis(ms.constructDouble(t[1].y).ldexpThis(1))}function ma(t,e,s,i){if(i){if(e<0){return void On(new fl({pt1:t[0],pt2:t[0].add(Go().getUnitVector())}),e,s)}if(e>1){return void On(new fl({pt1:t[2],pt2:t[2].add(Go().getUnitVector())}),e-1,s)}}if(e<=.5){const i=t[1].clone(),n=new _s;me(2,t[0],i,e,n);const r=new _s;me(2,i,t[2],e,r);const o=new _s;me(2,n,r,e,o),s.assign(o)}else{const i=t[1].clone(),n=new _s;ue(2,t[0],i,e,n);const r=new _s;ue(2,i,t[2],e,r);const o=new _s;ue(2,n,r,e,o),s.assign(o)}}function ua(e,s,i){t(0)}function la(e,s,i){t(0)}function ca(t,e){e[0].assign(t[0]),e[3].assign(t[2]),ye(t[0],t[1],2/3,e[1]),ye(t[1],t[2],1/3,e[2])}function da(t,e,s,i,n,r,o,a,h){const m=is(_s,3);t.queryControlPoints(m);const u=is(_s,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return s&&(s.length=0,s.push(m[0]),s.push(m[2])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=je(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=je(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[2]),h&&(s[1]=je(s[0],s[0]=s[1]))),!0)}const _a=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],ga=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],pa=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],fa=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],xa=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],ya=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function va(t,e,s,i){const n=.5*(i-s),r=s+n,o=new Yt(0);for(let a=0,h=t/2;a<h;++a){let s,i;switch(t){case 4:s=_a[a][0],i=_a[a][1];break;case 8:s=ga[a][0],i=ga[a][1];break;case 16:s=pa[a][0],i=pa[a][1];break;case 32:s=fa[a][0],i=fa[a][1];break;case 64:s=xa[a][0],i=xa[a][1];break;case 128:s=ya[a][0],i=ya[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=Se(-n,s,r),m=Se(n,s,r);o.pe(e(h)*i),o.pe(e(m)*i)}return o.getResult()*n}class Pa{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function ba(e,s,i,n,r,o,a,h){for(;;){const m=_s.distance(s[0],s[2]),u=_s.distance(s[0],s[1])+_s.distance(s[1],s[2]);if(u-m<=r+n*u)return e+pe(m,u,.5);const l=is(_s,4),c=t=>{Ia(s,i,1,t,l);return l[1].length()};if(0===a&&h<8){t(h<8);let m=c(0),l=c(1);o[0]+=2,m>l&&(l=je(m,m=l),s[2]=je(s[0],s[0]=s[2]),i[2]=je(i[0],i[0]=i[2]));let d=m/(m+l),_=1,g=u;for(;d<1/32&&g>=r+n*g;){_/=4;const t=c(_);o[0]++,d=m/(t+m);const e=new _s;if(Eh(s,i,.5*_,e),g=_s.distance(e,s[0]),g<=r){const t=new _s;Eh(s,i,_,t),g+=_s.distance(t,e)}}if(1!==_){const t=is(_s,3),m=[0,0,0];nh(s,i,_,s,i,t,m),e=ba(e,t,m,n,r,o,0,h+1),a++,h++;continue}}let d=!1;const _=8;o[0]+=_;const g=va(_,c,0,1),p=16;o[0]+=p;const f=va(p,c,0,1);if(d=Math.abs(g-f)>r+n*u,!d)return e+f;if(a<8&&h<9){const t=is(_s,3),m=[0,0,0];nh(s,i,.5,s,i,t,m),e=ba(e,t,m,n,r,o,a+1,h+1),a++,h++;continue}const x=32;o[0]+=x;const y=va(x,c,0,1);if(d=Math.abs(f-y)>r+n*u,!d)return e+y;const v=64;o[0]+=v;const P=va(v,c,0,1);if(d=Math.abs(y-P)>r+n*u,!d)return e+P;const b=128;o[0]+=b;const E=va(b,c,0,1);return d=Math.abs(P-E)>r+n*u,e+E}}function Ea(t,e,s,i,n){if(s===e)return 0;const r=is(_s,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=is(_s,3);rh(r,o,e,s,h,a);return ba(0,h,a,i,n,[0],0,0)}let Ca=class{constructor(t,e,s){this.controlPoints=ns(t,3),this.weights=[0,0,0],Oe(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new _s;Eh(this.controlPoints,this.weights,e,t);const s=is(_s,4);Ia(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new _s;Eh(this.controlPoints,this.weights,e,t);const s=is(_s,4);Ia(this.controlPoints,this.weights,2,e,s);return 2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new _s;Eh(this.controlPoints,this.weights,e,t);const s=is(_s,4);Ia(this.controlPoints,this.weights,3,e,s);return 2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(e){return t(0),0}};function Da(t,e,s,i){const n=Ka(0,0,0,0,_s.getNAN()),r=new Array(18),o=is(_s,3);t.queryControlPoints(o),o[2].subThis(e),o[1].subThis(e),o[0].subThis(e);const a=[0,0,0];t.queryWeights(a);const h=[1,Dh(a),1],m=wh(a,s),u=wh(a,i),l=Dr(new Ca(o,h,new _s(0,0)),Qt.construct(m,u),18,r);Eh(o,h,m,n.pt),n.t=m,n.d=_s.distance(n.pt,new _s(0,0));const c=new _s;Eh(o,h,u,c);const d=_s.distance(c,new _s(0,0));d<n.d&&(n.d=d,n.t=u,n.pt.assign(c));for(let _=0;_<l;_++){Eh(o,h,r[_],c);const t=_s.distance(c,new _s(0,0));t<n.d&&(n.d=t,n.t=Sh(a,r[_]),n.pt.assign(c))}return n}function Sa(t){t.m_cachedValues=null}function wa(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Pa,s=is(_s,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),Aa(s,i,e.specialPoints),ja(t,e),e}function Aa(t,e,s){if(0===e[1])return s.length=2,s[0]=0,void(s[1]=1);const i=is($t,8);i[0].set(0);let n=1;{const s=new $t(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new $t(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new $t(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=is($t,2);let h=Yr(o,r,s,new Qt(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)vt(a[t].value(),0,1)||(i[n]=a[t],n++)}{const s=new $t(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new $t(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new $t(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=is($t,2);let h=Yr(o,r,s,new Qt(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)vt(a[t].value(),0,1)||(i[n]=a[t],n++)}if(i[n].set(1),n++,n>2){Ke(i,n,((t,e)=>$e(t.value(),e.value())));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let r=0;r<n;r++)s[r]=i[r].value()}function Ta(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ta(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=wa(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Za(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=Ea(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function Ia(t,e,s,i,n){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=is(_s,4);Na(r,o,s,i,a);for(let h=0;h<=s;h++)n[h].setCoords(a[h].x,a[h].y)}function Na(e,s,i,n,r){t(i>0);const o=[e[0].clone(),e[1].clone(),e[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const a=Ma(o,s,0,n),h=Ra(s,0,n),m=a.divide(h);if(r[0].assign(m),0===i)return;const u=[s[1]*s[0],s[2]*s[0]*.5,s[1]*s[2]],l=[e[1].sub(e[0]),e[2].sub(e[0]),e[2].sub(e[1])],c=h*h,d=Ma(l,u,0,n).mul(2).divide(c);if(r[1].assign(d),1===i)return;const _=Ra(s,1,n),g=2*h*_,p=Ma(l,u,1,n).mul(2).sub(d.mul(g)).divide(c);if(r[2].assign(p),2===i)return;const f=Ma(l,u,2,n).mul(2),x=2*(_*_+h*Ra(s,2,n)),y=f.sub(p.mul(g).mul(2)).sub(d.mul(x)).divide(c);r[3].assign(y),3!==i&&E("")}function Ma(t,e,s,i){if(0===s){if(i<=.5){const s=new _s;me(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new _s;me(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new _s;return me(2,s,n,i,r),r}{const s=new _s;ue(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new _s;ue(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new _s;return ue(2,s,n,i,r),r}}if(1===s){const s=t[1].mul(e[1]),n=s.sub(t[0].mul(e[0])).mul(1-i).add(t[2].mul(e[2]).sub(s).mul(i));return n.mulThis(2),n}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}E("")}function qa(t,e,s,i){if(i.toDouble()<=.5){const s=new Ai;_e(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ai;_e(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ai;return _e(2,s,n,i,r),r}{const s=new Ai;ge(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ai;ge(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ai;return ge(2,s,n,i,r),r}}function Ra(t,e,s){if(0===e){const e=pe(t[0],t[1],s),i=pe(t[1],t[2],s);return pe(e,i,s)}if(1===e){return 2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s)}if(2===e){return 2*(t[2]-t[1]-(t[1]-t[0]))}E("")}function Fa(t,e,s){if(s.toDouble()<=.5){const e=oe(t[0],t[1],s),i=oe(t[1],t[2],s);return oe(e,i,s)}{const e=ae(t[0],t[1],s),i=ae(t[1],t[2],s);return ae(e,i,s)}}function Ya(t,e,s,i,n){const r=[Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);Xa(r,[new $t(e[0]),new $t(e[1]),new $t(e[2])],s,i,n)}function Xa(e,s,i,n,r){t(i>0);const o=[e[0].clone(),e[1].clone(),e[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThisE(o[0]);o[0]=Ai.constructCoords(0,0)}const a=qa(o,s,0,n),h=Fa(s,0,n),m=a.divE(h);r[0].setE(m);const u=[s[1].mulE(s[0]),s[2].mulE(s[0]).mul(.5),s[1].mulE(s[2])],l=qa([e[1].subE(e[0]),e[2].subE(e[0]),e[2].subE(e[1])],u,0,n).mul(2),c=h.sqr(),d=l.divE(c);r[1].setE(d)}function La(t,e,s){const i=is(_s,3);t.queryControlPoints(i);const n=new Array(3);t.queryWeights(n),za(i,n,e,s)}function za(t,e,s,i){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const n=is(Ai,4);Ya(t,e,1,s,n),i.setE(n[1])}function Va(t,e,s){const i=Pt(s,0,1),n=is(_s,4);if(Ia(t,e,3,i,n),!n[1]){if(n[2]){const t=n[2].clone();return 1===i&&t.negateThis(),t}return n[3]}return n[1]}class Ba{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ta(this.b,e,!1):0}getError(e){return t(0),0}}function ka(t,e,s){const i=Ta(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Dr(new Ba(t,e),Qt.unit(),1,n)&&E(""),n[0]}function Ga(t){const e=is(_s,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Wa(e,s)}function Wa(e,s){const i=Dh(s);if(1===i){return Wo(e)}if(0===i)return 0;const n=[new _s(0,0),e[1].sub(e[0]),e[2].sub(e[0])],r=n[1].crossProduct(n[2]);if(i<1){t(i>0);const e=1-i;let s;if(e<.01)s=-1/3+e*(2/15+e*(3/35+e*(16/315+e*(20/693+e*(16/1001+e*(56/6435))))));else{const t=e*(1+i),n=Math.atan2(Math.sqrt(e),Math.sqrt(1+i));s=i*(.5*i-be(t)*n)/t}return r*s}{const t=(i-1)*(i+1);return.25*i/Math.pow(t,1.5)*(-2*i*Math.sqrt(t)*r-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-n[1].x*n[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}function Za(t){return Ha(t.calculateUpperLength2D())}function Ha(t){return 256*yt()*t}function Oa(t){return t.m_cachedValues}function ja(t,e){t.m_cachedValues=e}function Ua(t,e,s,i,n){const r=is(_s,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===Qa(r,o,e,Qt.unit(),i,n,1,a)?a[0]:Number.NaN}function Qa(e,s,i,n,r,o,a,h){N(Qt.unit().contains(n)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const m=new Array(3);for(let t=0;t<3;++t)m[t]=e[t].sub(i);const u=Dh(s),l=co.constructPoint2D(m[0]),c=co.constructPoint2D(m[1]),d=co.constructPoint2D(m[2]),_=ms.constructDouble(u),g=_.clone();g.ldexpThis(1);const p=l.dotProduct(c.sub(l)).mul(_),f=_.mul(_.addDouble(2)),x=d.sub(c.mul(f.ldexp(1))),y=c.sqrLength().mul(_.mul(_).ldexp(1)).add(l.sqrLength().mul(_.ldexp(2).subDouble(1))).add(l.dotProduct(x)),v=d.sub(c.mul(g)).add(l.mul(g.subDouble(1))),P=c.mul(_).sub(l).dotProduct(v).mulDouble(3),b=c.dotProduct(d).mul(_.subDouble(3).mul(_)).ldexp(1),E=c.sqrLength().mul(_.mul(_).ldexp(2)),C=l.sqrLength().mul(_.ldexp(2).subDouble(3)),D=l.dotProduct(d.sub(c.mul(_.mulDouble(3).subDouble(1)).mul(_))).ldexp(1),S=d.sqrLength().addThis(b).addThis(E).addThis(C).addThis(D),w=l.add(d).sub(c.mul(g)),A=_.subDouble(1),T=d.sub(l).dotProduct(w).mul(A),I=new _s(0,0),M=[];let q=new _s;Eh(m,s,n.vmin,q);let R=_s.distance(q,I);if(R<=o&&M.push(new _s(n.vmin,R)),n.vmin!==n.vmax&&(Eh(m,s,n.vmax,q),R=_s.distance(q,I),R<=o&&M.push(new _s(n.vmax,R))),n.width()>0){const t=m[2].isZero(),e=is(ms,4),i=wo(T,S,P,y,p,58,n,t,e);for(let r=0;r<i;r++){if(!n.containsExclusiveCoordinate(e[r].toDouble()))continue;let t=e[r].toDouble();t=Sh(s,t);const i=new _s;Eh(m,s,t,i),R=_s.distance(i,I),R<=o&&M.push(new _s(t,R))}}if(r){t(n.equals(Qt.unit()));{Eh(m,s,-1,q,!0);const t=new _s;Eh(m,s,0,t);const e=new fl({pt1:q,pt2:t}),i=e.getClosestCoordinate(I,!0);i<1&&(q=e.getCoord2D(i),R=_s.distance(q,I),R<=o&&M.push(new _s(i-1,R)))}{Eh(m,s,2,q,!0);const t=new _s;Eh(m,s,n.vmax,t);const e=new fl({pt1:t,pt2:q}),i=e.getClosestCoordinate(I,!0);i>0&&(q=e.getCoord2D(i),R=_s.distance(q,I),R<=o&&M.push(new _s(1+i,R)))}}if(!M.length)return 0;M.sort(((t,e)=>t.compare(e)));let F=0;const Y=M[0].x;if(h[F++]=Y,F<a){const t=Js(m,4,!1).total(),e=M[0].y;for(let s=1,i=M.length;s<i;s++)if(M[s].y>e+t){M.length=s;break}M.sort(((t,e)=>$e(t.x,e.x))),F=0,h[F++]=M[0].x;for(let s=1,i=M.length;s<i;s++)M[s].x!==h[F-1]&&F<a&&(h[F++]=M[s].x)}return F}function Ka(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function $a(e,s,i,n,r){const o=new Di;if(Ja(e,Qt.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(s))return 0;const a=wa(e);let h=0;const m=[];let u=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const i=a.specialPoints[l],n=Da(e,s,u,i);if(0===m.length)m.push(n);else if(n.t===n.tmin)t(m.at(-1).d<=n.d),m.at(-1).tmax=n.tmax;else if(m.at(-1).t===m.at(-1).tmax){t(m.at(-1).d>=n.d);const e=m.at(-1).tmin;m[m.length-1]=n,m.at(-1).tmin=e}else m.push(n);u=i}for(const t of m)if(t.d<=n){const e=t.t;i?(i[h]=e,h++):h++}return h}function Ja(t,e,s){const i=is(_s,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),th(i,n,e,s)}function th(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=is(_s,3),r=[0,0,0];rh(t,e,s.vmin,s.vmax,n,r),i.setFromPoints(n,3)}function eh(t){const e=j(t[0].y,t[1].y),s=j(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=j(t[0].x,t[1].x),s=j(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function sh(t){const e=is(_s,3);t.queryControlPoints(e);const s=ih(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function ih(t){let e=!1;for(let s=0;s<2;s++){const i=j(t[0][s],t[2][s]);i>0?(j(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(j(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function nh(e,s,i,n,r,o,a){t(i>=0&&i<=1&&n!==o&&r!==a),t(s[0]>0&&s[2]>0&&s[1]>=0);const h=[1,Dh(s),1],m=wh(s,i),u=ns(e,3),l=is(gs,3);xh(u,h,l);const c=is(gs,3),d=is(gs,3);Th(l,m,n?c:null,o?d:null),Ih(s,i,r,a);const _=eh(u);if(n){for(let t=0;t<3;++t)bh(c[t],n[t]);Mh(u,n),_&&ih(n)}if(o){for(let t=0;t<3;++t)bh(d[t],o[t]);Mh(u,o),_&&ih(o)}}function rh(e,s,i,n,r,o){if(t(i>=0&&n<=1&&i<=n),i===n){const t=new _s,n=yh(e,s,i,t);return Nh(e,t),r[0].assign(t),r[1].assign(t),r[2].assign(t),o[0]=n,o[1]=n,void(o[2]=n)}if(0===i&&1===n)return r[0].assign(e[0]),r[1].assign(e[1]),r[2].assign(e[2]),o[0]=s[0],o[1]=s[1],void(o[2]=s[2]);const a=is(gs,3);{const t=[1,Dh(s),1],r=wh(s,i),o=wh(s,n);xh(e,t,a),Th(a,o,a,null);Th(a,r>=o?1:r/o,null,a)}const h=[0,0,0];Ih(s,n,h,null),Ih(h,i/n,null,h);const m=eh(e),u=is(_s,3);bh(a[1],u[1]),Eh(e,s,i,u[0]),Eh(e,s,n,u[2]),Mh(e,u);for(let t=0;t<3;++t)r[t].assign(u[t]),o[t]=h[t];m&&ih(r)}function oh(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new cn,o=is(_s,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new _s;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=is(_s,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):ye(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&sh(t)}function ah(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==ch(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function hh(e,s,i,n,r){return t(0),0}function mh(t,e){const s=t.getEndXY().sub(t.getStartXY()),i=s.length(),n=t.getControlPoint1();n.subThis(t.getStartXY());return!(Math.abs(n.crossProduct(s))/i>e)}function uh(t,e,s,i,n){if(n){const i=hl(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(Mi(e,s))return 1;return 0!==_h(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function lh(e,s,i,n,r){return t(0),0}function ch(e,s,i,n,r,o,a,h,m,u){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0),i.isDegenerate(0)){const t=[0,0],e=s.intersectPoint(i.getStartXY(),t,a);if(e>0){if(null!==r)for(let s=0;s<e;s++)r.push(t[s]);if(null!=o)for(let t=0;t<e;t++)o.push(0);if(null!=n)for(let i=0;i<e;i++){const e=new _s;s.queryCoord2D(t[i],e),n.push(e)}}return e}const l=Ki(s,i);if(a=Math.max(a,l),s.isDegenerateToLineHelper(l)){const t=new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),e=sr(t,i,n,r,o,a,h,u);if(r)for(let i=0;i<e;++i){const e=t.getCoord2D(r[i]);r[i]=s.getClosestCoordinate(e,!1)}return e}if($i(s,i,a))return 0;const c=is(_s,3);s.queryControlPoints(c);const d=[0,0,0];s.queryWeights(d);const _=[1,Dh(d),1],g=i.getEndXY().sub(i.getStartXY()),p=g.clone();p.leftPerpendicularThis();const f=c[0].clone(),x=c[1].clone(),y=c[2].clone(),v=x.sub(f),P=y.sub(f),b=y.sub(x),E=_[0],C=_[1],D=_[2],S=E*C,w=E*D,A=C*D,T=v.dotProduct(p)*S,I=P.dotProduct(p)*w;let N=T,M=I-2*T,q=b.dotProduct(p)*A+I-I;const R=new Array(13),F=new Array(13);let Y=Sr(q,M,N,Qt.unit(),!1,R);Y<0&&(R[0]=0,R[1]=1,Y=2);let X=0;for(let t=0,k=X;t<Y;++t){const e=new _s;Eh(c,_,R[t+k],e),F[X]=i.getClosestCoordinate(e,!1);_s.distance(e,i.getCoord2D(F[X]))<=a&&(R[X]=R[t+k],X++)}const L=is(_s,3),z=is(_s,3);if(s.queryControlPoints(z),z[0].subThis(i.getStartXY()),z[1].subThis(i.getStartXY()),z[2].subThis(i.getStartXY()),ph(z,_,L,!1),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;q=L[2].y-L[2].x*t,M=L[1].y-L[1].x*t,N=L[0].y-L[0].x*t}else{const t=g.x/g.y;q=L[2].x-L[2].y*t,M=L[1].x-L[1].y*t,N=L[0].x-L[0].y*t}const V=s.getEndXY().equals(i.getStartXY())||s.getEndXY().equals(i.getEndXY()),B=[0,0];Y=Sr(q,M,N,Qt.unit(),V,B);for(let t=0,k=X;t<Y;++t){R[t+k]=B[t];const e=new _s;Eh(c,_,R[t+k],e),F[X]=i.getClosestCoordinate(e,!1);_s.distance(e,i.getCoord2D(F[X]))<=a&&(R[X]=R[t+k],X++)}t(X<R.length+4);for(let t=0;t<X;t++)R[t]=Sh(d,R[t]);Y=s.intersectPoint(i.getStartXY(),B,a);for(let t=0;t<Y;t++)R[X]=B[t],F[X++]=0;Y=s.intersectPoint(i.getEndXY(),B,a);for(let t=0;t<Y;t++)R[X]=B[t],F[X++]=1;Y=i.intersectPoint(s.getStartXY(),B,a);for(let t=0;t<Y;t++)F[X]=B[t],R[X++]=0;Y=i.intersectPoint(s.getEndXY(),B,a);for(let t=0;t<Y;t++)F[X]=B[t],R[X++]=1;return 0===X?0:dl(e,s,i,R,F,X,n,r,o,a,h,m,u)}function dh(e,s,i,n,r,o,a,h,m,u){return t(0),0}function _h(e,s,i,n,r,o,a,h,m,u){const l=is(_s,3);s.queryControlPoints(l);const c=is(_s,3);if(i.queryControlPoints(c),Ji(l,c,3)<0)return _h(e,i,s,n,o,r,a,h,m,!u);const d=Ki(s,i);if(s.isDegenerateToLineHelper(d)){const t=new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),l=ch(e,i,t,n,o,r,a,h,m,!u);if(r)for(let e=0;e<l;++e){const i=t.getCoord2D(r[e]);r[e]=s.getClosestCoordinate(i,!1)}return l}if(i.isDegenerateToLineHelper(d)){const t=new fl({pt1:i.getStartXY(),pt2:i.getEndXY()}),l=ch(e,s,t,n,r,o,a,h,m,u);if(o)for(let e=0;e<l;++e){const s=t.getCoord2D(o[e]);o[e]=i.getClosestCoordinate(s,!1)}return l}if($i(s,i,a=Math.max(a,d)))return 0;const _=new Array(3);s.queryWeights(_);const g=new Array(3);i.queryWeights(g);const p=[1,Dh(_),1],f=[1,Dh(g),1],x=new Qt(0,1),y=new Qt(0,1);{const t=Di.constructEmpty();th(l,p,new Qt(0,1),t);const e=Di.constructEmpty();th(c,f,new Qt(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Ch(l,p,t,x),Ch(c,f,t,y),x.isEmpty()||y.isEmpty())return 0;rh(l,p,x.vmin,x.vmax,l,p),rh(c,f,y.vmin,y.vmax,c,f)}}const v=gl(l,2,c,2,a);if(0===v)return 0;const P=[],b=[];if(-1===v){const t=is(ms,3),e=is(ms,3),s=is(ms,3);fh(l,p,t,e,s);const i=is(ms,3),n=is(ms,3),r=is(ms,3);fh(c,f,i,n,r);const o=[],h=[],m=vo(t,2,e,2,s,2,i,2,n,2,r,2,!0,Qt.unit(),Qt.unit(),o,h);if(m>0)for(let u=0;u<m;u++){const t=new _s;Eh(c,f,h[u],t);const e=new _s;Eh(l,p,o[u],e);_s.distance(e,t)<=a&&(P.push(o[u]),b.push(h[u]))}}for(let E=0;E<2;E++){let e,s,i;0===E?(e=l,s=c,i=f):(e=c,s=l,i=p);for(let n=0;n<2;n++){const r=0===n?0:e.length-1,o=new _s,h=[0];t(1===Qa(s,i,e[r],Qt.unit(),!1,-1,1,h)),Eh(s,i,h[0],o),_s.distance(e[r],o)<=a&&(0===E?(P.push(0===r?0:1),b.push(h[0])):(b.push(0===r?0:1),P.push(h[0])))}}if(0===P.length)return 0;if(!x.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=lo.recalculateParentT(x.vmin,x.vmax,P[t]);if(!y.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=lo.recalculateParentT(y.vmin,y.vmax,b[t]);for(let t=0;t<P.length;++t)P[t]=Sh(_,P[t]);for(let t=0;t<b.length;++t)b[t]=Sh(g,b[t]);return dl(e,s,i,P,b,P.length,n,r,o,a,h,m,u)}function gh(t,e,s,i,n,r,o,a,h,m){if(e.isLine())return new fl({pt1:e.getStartXY(),pt2:e.getEndXY()}),na();if(s.isLine()){return ch(t,e,new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,m)}const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=is(_s,3);e.queryControlPoints(l);const c=is(_s,3);s.queryControlPoints(c);const d=gl(l,2,c,2,o);if(0===d)return 0;const _=[],g=[];if(-1===d){const t=is(ms,3),i=is(ms,3),n=is(ms,3),r=[0,0,0];e.queryWeights(r),fh(l,r,t,i,n);const a=is(ms,3),h=is(ms,3);ha(c,a,h);const m=vo(t,2,i,2,n,2,a,2,h,2,null,0,!0,Qt.unit(),Qt.unit(),_,g);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new _s;s.queryCoord2D(g[i],n);const r=new _s;e.queryCoord2D(_[i],r),_s.distance(r,n)<=o&&(_[t]=_[i],g[t]=g[i],t++)}_.length=t,g.length=t}}for(let p=0;p<2;p++){let t;t=0===p?l:c;for(let i=0;i<2;i++){const n=0===i?0:t.length-1;let r;const a=new _s;0===p?(r=Oo(s,t[n],Qt.unit()),s.queryCoord2D(r,a)):(r=Ua(e,t[n],Qt.unit(),!1,-1),e.queryCoord2D(r,a)),_s.distance(t[n],a)<=o&&(0===p?(_.push(0===n?0:1),g.push(r)):(g.push(0===n?0:1),_.push(r)))}}return dl(t,e,s,_,g,_.length,i,n,r,o,a,h,m)}function ph(t,e,s,i=!1){const n=is(_s,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}function fh(t,e,s,i,n){const r=ms.constructDouble(e[0]),o=ms.constructDouble(e[1]),a=ms.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(r),s[1].setDouble(t[1].x),s[1].mulThis(o),s[2].setDouble(t[2].x),s[2].mulThis(a),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),i[0].setDouble(t[0].y),i[0].mulThis(r),i[1].setDouble(t[1].y),i[1].mulThis(o),i[2].setDouble(t[2].y),i[2].mulThis(a),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function xh(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function yh(t,e,s,i){const n=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],r=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],o=[e[0],e[1],e[2]],a=s;let h,m,u;if(s<=.5){h=pe(fe(n[0],n[1],a),fe(n[1],n[2],a),a);m=pe(fe(r[0],r[1],a),fe(r[1],r[2],a),a);const l=fe(o[0],o[1],a),c=fe(o[1],o[2],a);if(u=fe(l,c,a),0===s)return i.assign(t[0]),e[0]}else{const l=xe(n[0],n[1],a),c=xe(n[1],n[2],a);h=xe(l,c,a);const d=xe(r[0],r[1],a),_=xe(r[1],r[2],a);m=xe(d,_,a);const g=xe(o[0],o[1],a),p=xe(o[1],o[2],a);if(u=xe(g,p,a),1===s)return i.assign(t[2]),e[2]}return h/=u,m/=u,i.setCoords(h,m),Nh(t,i),u}function vh(t,e,s){const i=is(_s,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n);Ph([Ai.constructPoint2D(i[0]),Ai.constructPoint2D(i[1]),Ai.constructPoint2D(i[2])],[new $t(n[0]),new $t(n[1]),new $t(n[2])],e,s)}function Ph(t,e,s,i){let n=e[0].mulE(e[2]);n.sqrtThis(),n=e[1].divE(n);const r=e[0].divE(e[2]);r.sqrt();const o=s.divE(r.mulE(new $t(1).subE(s)).addE(s)),a=new Ai,h=new $t,m=t[1].mulE(n);if(o.value()<=.5){const e=new Ai;_e(2,t[0],m,o,e);const s=new Ai;_e(2,m,t[2],o,s),_e(2,e,s,o,a);const i=new $t;ce(new $t(1),n,o,i);const r=new $t;ce(n,new $t(1),o,r),ce(i,r,o,h)}else{const e=new Ai;ge(2,t[0],m,o,e);const s=new Ai;ge(2,m,t[2],o,s),ge(2,e,s,o,a);const i=new $t;de(new $t(1),n,o,i);const r=new $t;de(n,new $t(1),o,r),de(i,r,o,h)}a.divThisE(h);const u=new _s(a.x.value(),a.y.value());Nh([t[0].value(),t[1].value(),t[2].value()],u),i.x.set(u.x,a.x.eps()),i.y.set(u.y,a.y.eps())}function bh(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function Eh(t,e,s,i,n){if(n){if(s<0){return void On(new fl({pt1:t[0],pt2:t[0].add(Va(t,e,0).getUnitVector())}),s,i)}if(s>1){return void On(new fl({pt1:t[2],pt2:t[2].add(Va(t,e,1).getUnitVector())}),s-1,i)}}yh(t,e,s,i)}function Ch(t,e,s,i){i.setEmpty();const n=[];n.push(new Qt(0,1));const r=.5*Math.max(s.width(),s.height());for(;n.length;){const o=n.at(-1);n.pop();const a=new Di;if(th(t,e,o,a),a.isIntersectingW(s)){const t=Math.max(a.width(),a.height());if(s.containsW(a)||t<=r||o.width()<1e-12)i.merge(o);else{const t=o.getCenter();n.push(Qt.construct(o.vmin,t)),n.push(Qt.construct(t,o.vmax))}}}}function Dh(t){return t[1]/Math.sqrt(t[0]*t[2])}function Sh(t,e){return e/pe(Math.sqrt(t[2]/t[0]),1,e)}function wh(t,e){return e/pe(Math.sqrt(t[0]/t[2]),1,e)}function Ah(t,e){const s=is(_s,3);t.queryControlPoints(s);const i=[0,0,0];t.queryWeights(i),e.setControlPointsAndWeights(s,i)}function Th(e,s,i,n){t(s>=0&&s<=1);(new gs).setCoordsPoint3D(e[0]);(new gs).setCoordsPoint3D(e[1]);(new gs).setCoordsPoint3D(e[2]);const r=new gs,o=new gs,a=new gs;le(3,e[0],e[1],s,r),le(3,e[1],e[2],s,o),le(3,r,o,s,a);const h=e[2].clone();i&&(i[0].assign(e[0]),i[1].assign(r),i[2].assign(a)),n&&(n[0].assign(a),n[1].assign(o),n[2].assign(h))}function Ih(e,s,i,n){const r=[e[0],e[1],e[2]];t(s>=0&&s<=1&&i!==n);const o=pe(r[0],r[1],s),a=pe(r[1],r[2],s),h=pe(o,a,s);i&&(i[0]=r[0],i[1]=o,i[2]=h),n&&(n[0]=h,n[1]=a,n[2]=r[2])}function Nh(t,e){const s=Qt.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=Pt(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=Pt(e.y,s.vmin,s.vmax)}function Mh(t,e){const s=new Qt;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=Pt(e[0].x,s.vmin,s.vmax),e[1].x=Pt(e[1].x,s.vmin,s.vmax),e[2].x=Pt(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=Pt(e[0].y,s.vmin,s.vmax),e[1].y=Pt(e[1].y,s.vmin,s.vmax),e[2].y=Pt(e[2].y,s.vmin,s.vmax)}function qh(){return{e2:0,completeE:0}}class Rh{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?_s.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(e){return t(0),0}}function Fh(t,e,s){if(em(t)){$n(new fl({pt1:t.getStartXY(),pt2:t.getEndXY()}),e,s)}else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const e=new $t;Wh();const i=new $t,n=new $t;$t.st_cosAndSin(e,i,n);const r=Ai.constructCoordsE(new $t(t.m_semiMajorAxis).mulThisE(i),new $t(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(n)),o=new $t(t.m_rotation);$t.st_cosAndSin(o,i,n),r.rotateDirect(i,n),r.addThisE(Ai.constructPoint2D(t.m_center)),s.setE(r)}}function Yh(t,e){return t.convertToCanonic(e)}function Xh(t,e){const s=new Qt(t.getStartAngle(),t.getEndAngle());s.normalize();const i=Ct(),n=Xe(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}function Lh(t){let e=t,s=!1;return e<=-Et()?(e+=Ct(),s=!0):e>Et()&&(e-=Ct(),s=!0),e<=-Et()?(e=Xe(e,Ct()),e<=-Et()&&(e+=Ct()),s=!0):e>Et()&&(e=Xe(e,Ct()),e>Et()&&(e-=Ct()),s=!0),s&&(e>Et()||e<=-Et())&&(e=Et()),e}function zh(t,e,s){const i=s,n=i.getSemiAxes();let r=new _s(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return r=i.convertFromCanonic(r),_s.sqrDistance(r,i.getStartXY())}function Vh(t,e,s){const i=s,n=i.getSemiAxes(),r=t[0]+i.getStartAngle();let o=new _s(n.x*Math.cos(r),n.y*Math.sin(r));return o=i.convertFromCanonic(o),_s.sqrDistance(o,i.getEndXY())}function Bh(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=lm(t),r=mm(t),o=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new _s(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Lh(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?r?Ct():-Ct():0}else{const i=t.convertToCanonic(e),a=new _s(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=a.x,i.y/=a.y;const h=t.convertToCanonic(s);h.x/=a.x,h.y/=a.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=_s.calculateAngle(i,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=Ct()):t.m_sweepAngle>0&&(t.m_sweepAngle-=Ct()),t.m_startAngle=Lh(t.m_startAngle);let m=zh([t.m_startAngle],1,t);if(m=Math.sqrt(m),m>.25*Qi(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Ar(zh,t,1,[t.m_startAngle],[e],[s],1e-14,i),t.m_startAngle=Lh(i[0])}if(m=Vh([t.m_sweepAngle],1,t),m=Math.sqrt(m),m>.25*Qi(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Ar(Vh,t,1,[t.m_sweepAngle],[e],[s],1e-14,i),t.m_sweepAngle=i[0]}const u=Math.abs(t.m_sweepAngle)>Et();if(um(t,u),n!==u&&!n&&Math.abs(t.m_sweepAngle)>1.5*Et())return void tm(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void tm(t,e,s,o)}}function kh(t,e){return(Xh(t,e)-t.getStartAngle())/t.getSweepAngle()}function Gh(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Wh(e,s,i){t(0)}function Zh(t,e){const s=new $t(t.m_cosr).sqrThis(),i=new $t(t.m_sinr).sqrThis(),n=new $t(t.m_minorMajorRatio),r=new $t(1/t.m_minorMajorRatio),o=n.mulE(s).addThisE(r.mulE(i)),a=n.subE(r).mulThis(2*t.m_cosr*t.m_sinr),h=n.mulE(i).addThisE(r.mulE(s));e[0]=o,e[1]=a,e[2]=h,e[3]=new $t(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function Hh(t,e){const s=new Ti;s.a11.setE(t[0]),s.a12=$t.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[_s.getNAN(),_s.getNAN()],n=[new $t,new $t];s.eigenSymmetric(n,i);const r=t[3].clone();r.negateThis(),r.invThis(),n[0].mulThisE(r),n[1].mulThisE(r),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble();return Math.atan2(i[0].y,i[0].x)}function Oh(t,e,s){if(em(t))return(s-e)*_s.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const i=sm(t,e);return sm(t,s)-i}function jh(t){return t.m_cachedValues}function Uh(t){if(t.m_cachedValues)return t.m_cachedValues;const e=qh();return e.e2=$h(t),e.completeE=Le(e.e2),t.m_cachedValues=e,e}function Qh(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(em(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,vm(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*Dt()){const i=is(_s,3),n=pm(t,i);if(eh(i)){i[0].assign(e),i[2].assign(s),ih(i);if(0===t.projectionBehavior()){let e=0,s=2;_s.sqrDistance(i[1],i[0])<_s.sqrDistance(i[1],i[2])&&(s=je(e,e=s));const n=i[s].sub(i[e]),r=n.length();n.divThis(r);const o=i[1].sub(i[e]),a=o.length(),h=o.dotProduct(n)/a,m=o.crossProduct(n)/a,u=new _s;ye(i[e],i[s],.5,u);const l=.5*r/m*Pt(1-h,0,1),c=i[1].side(i[e],i[s]),d=n.clone();c?d.leftPerpendicularThis():d.rightPerpendicularThis();const _=u.sub(d.mul(l));t.constructCircularArcThreePoint(i[0],i[2],_)}else fm(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?Tm(t,e,s):Im(t,e,s)}}function Kh(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void tm(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new _s;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=t.getSemiMajorAxis(),r=t.getMinorMajorRatio(),o=t.getAxisXRotation(),a=t.getCenter(),h=new Array(4);h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];const m=new Array(4);m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];const u=Math.trunc(s<5?1:(s+4)/5),l=is(jr,4),c=new Array(4);let d=0;for(let _=0;_<4;_++){l[_].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,r,o,h[_],m[_],a),c[_]=0;let t=0;for(let i=u;i<s-1;i+=u){const s=l[_].getClosestCoordinate(e[i],!1);c[_]+=_s.sqrDistance(l[_].getCoord2D(s),e[i]),t++}c[_]/=t,c[_]<c[d]&&(d=_)}t.assignCopy(l[d])}function $h(t){return 1-ve(t.m_minorMajorRatio)}function Jh(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,Li(t,e),Vi(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),um(t,o),hm(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,gm(t,void 0===h)}function tm(t,e,s,i){t.m_bits=0,t.m_rotation=0,Li(t,e),Vi(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,um(t,!1),hm(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function em(t){return t.m_center.isNAN()}function sm(t,e){if(0===e)return 0;const s=Uh(t),i=Gh(t,e),n=Dt(),r=nm(t),o=ze(i+n,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function im(t,e){if(em(t)){const s=_s.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const i=Uh(t),n=Dt(),r=nm(t);s<0&&(e=-e);let o=Ve(e/t.m_semiMajorAxis+r,i.e2,i.completeE);o-=n,o-=t.getStartAngle();return o/s}function nm(t){const e=Uh(t);return ze(t.getStartAngle()+Dt(),e.e2,e.completeE)}function rm(e,s,i){if(s instanceof _n)return void t(0);if(t(!dm(e)),s.isIdentity())return;am(e);const n=_s.getNAN();n.x=e.m_XStart,n.y=e.m_YStart,s.transformInPlace(n);const r=_s.getNAN();if(r.x=e.m_XEnd,r.y=e.m_YEnd,s.transformInPlace(r),em(e))return e.m_XStart=n.x,e.m_YStart=n.y,e.m_XEnd=r.x,void(e.m_YEnd=r.y);const o=e.m_center.clone();if(s.transformInPlace(o),i||s.isUniformNoRotation()){let t=mm(e);s.isReflective()&&(t=!t);if(0===e.projectionBehavior()){if(!n.equals(r)){const t=e.m_interior.clone();return s.transformInPlace(t),void e.constructCircularArcThreePoint(n,r,t)}return void Qr(e,n,r,o,t,!1)}const i=new _s(e.m_cosr,e.m_sinr);s.transformWithoutTranslateInPlace(i);const a=Math.atan2(i.y,i.x),h=e.getSemiAxes();s.transformWithoutTranslateInPlace(h);const m=e.m_center.clone();return s.transformInPlace(m),void e.constructEllipticArcEndPointsCenter(n,r,h.x,h.y/h.x,a,e.isMajor(),t,m)}{{const t=new Array(4);Zh(e,t);const i=new Ti;i.a11.setE(t[0]),i.a12.setE(t[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(t[2]);if(!i.det().isZero()){const a=new Ti;if(a.a11.set(s.xx),a.a12.set(s.xy),a.a21.set(s.yx),a.a22.set(s.yy),a.invertThis()){const h=a.clone();h.transposeThis();const m=i.clone();m.mulThis(a),m.mulLeftThis(h);if(!m.det().isZero()){const i=is($t,4);i[0].setE(m.a11),i[1].setE(m.a12),i[1].mulThisByPower2(2),i[2].setE(m.a22),i[3].setE(t[3]);const a=_s.getNAN(),h=Hh(i,a);let u=mm(e);return s.isReflective()&&(u=!u),void e.constructEllipticArcEndPointsCenter(n,r,a.x,a.y/a.x,h,e.isMajor(),u,o)}}}}const t=[_s.getNAN(),_s.getNAN(),_s.getNAN()];t[0].setCoords(e.getSemiMajorAxis(),0),t[0].rotateDirect(e.m_cosr,e.m_sinr),t[1].setCoords(e.getSemiMajorAxis(),e.getSemiMinorAxis()),t[1].rotateDirect(e.m_cosr,e.m_sinr),t[2].setCoords(0,e.getSemiMinorAxis()),t[2].rotateDirect(e.m_cosr,e.m_sinr);let i=e.isClockwise();i&&(t[2]=je(t[0],t[0]=t[2]));const a=.5;s.transformWithoutTranslateArray(t,3,t),s.isReflective()&&(i=!i);const h=new _s(0,0),m=e.createInstance();fm(t,a,h,!1,m),e.constructEllipticArcEndPointsCenter(n,r,m.getSemiMajorAxis(),m.getMinorMajorRatio(),m.getAxisXRotation(),e.isMajor(),!i,o)}}function om(t,e){t.m_cachedValues=e}function am(t){t.m_cachedValues=null}function hm(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function mm(t){return!!(1&t.m_bits)}function um(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function lm(t){return!!(2&t.m_bits)}function cm(t){if(t.m_center.isNAN())return!1;const e=8,s=new Ai;s.setWithEps(t.getStartXY(),e),s.subThisE((new Ai).setWithEps(t.m_center,e));const i=new $t;i.setWithEps(t.m_rotation,e);const n=new $t,r=new $t;$t.st_cosAndSin(i,n,r),s.rotateReverse(n,r);const o=new Ai;o.setWithEps(t.getEndXY()),o.subThisE(Ai.constructPoint2D(t.m_center)),o.rotateReverse(n,r);const a=new $t;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),m=new $t;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),s.x.divThisE(a),s.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const u=s.x.sqr().addThisE(s.y.sqr()).subThisE(ne),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(ne);return!u.isZero()||!l.isZero()}function dm(t){return!!(8&t.m_bits)}function _m(t){t.m_bits&=-9}function gm(t,e){_m(t);const s=t.getStartXY(),i=t.getEndXY();let n=!1;const r=lm(t),o=mm(t),a=t.projectionBehavior(),h=s.equals(i);let m=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:p("NAN minor major ratio and non-zero major axis")),m||=e?h:t.m_center.isNAN(),m)return tm(t,s,i,a),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const u=new _s(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(h){const e=t.convertToCanonic(s);e.x/=u.x,e.y/=u.y;const i=Math.sqrt(ve(e.x)+ve(e.y));if(n=1!==i,t.m_semiMajorAxis*=i,u.mulThis(i),t.m_startAngle=Lh(Math.atan2(e.y,e.x)),!r)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),n;t.m_sweepAngle=o?Ct():-Ct()}else{let e=t.m_center.isNAN()||cm(t);if(!e){const n=t.convertToCanonic(s);n.x/=u.x,n.y/=u.y;const r=new _s(1,0);t.m_startAngle=_s.calculateAngle(r,n);const o=t.convertToCanonic(i);o.x/=u.x,o.y/=u.y,t.m_sweepAngle=_s.calculateAngle(n,o),e=!ym(t)}if(e){n=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let a=ve(e.x/u.x)+ve(e.y/u.y);a>1&&(a=Math.sqrt(a),t.m_semiMajorAxis*=a,u.mulThis(a));const h=new _s(0,0);{const t=u.x*u.x,s=u.y*u.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);h.setCoords(u.x*e.y/u.y,-u.y*e.x/u.x),h.mulThis(t),r===o&&h.negateThis()}}{const e=new _s(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(Bh(t),!ym(t))return tm(t,s,i,a),!0}return vm(t),t.afterCompletedModification(),n}function pm(e,s){t(Math.abs(e.getSweepAngle())<15*Math.PI/16);const i=e.getSemiMajorAxis(),n=e.getSemiMinorAxis();let r;if(0===i)return s[0].setCoordsPoint2D(e.getStartXY()),s[1].setCoordsPoint2D(e.getStartXY()),s[2].setCoordsPoint2D(e.getStartXY()),r=1,r;if(0===n)return s[0].setCoordsPoint2D(e.getStartXY()),s[2].setCoordsPoint2D(e.getEndXY()),s[1]=_s.lerp(s[0],s[2],.5),r=1,r;const o=e.getSweepAngle(),a=e.getStartAngle(),h=a+o,m=Math.cos(.5*o),u=new _s(-i*Math.sin(a),n*Math.cos(a)),l=new _s(-i*Math.sin(h),n*Math.cos(h));u.normalize(),l.normalize(),u.rotateDirect(e.m_cosr,e.m_sinr),l.rotateDirect(e.m_cosr,e.m_sinr),s[0].setCoordsPoint2D(e.getStartXY()),s[2].setCoordsPoint2D(e.getEndXY()),s[1].setSub(s[2],s[0]);const c=u.crossProduct(l);return s[1]=u.mul(s[1].crossProduct(l)/c),s[1].addThis(s[0]),r=m,r}function fm(e,s,i,n,r){const o=e[0].sub(e[1]),a=e[2].sub(e[1]),h=o.crossProduct(a),m=o.dotProduct(a),u=s;t(u<=1),t(u>0);const l=.5/(1-u),c=o.sqrLength(),d=m,_=a.sqrLength(),g=ve(h),p=o.sub(a).sqrLength();if(0===g)return tm(r,e[0],e[2],1),!1;if(m<=-Math.sqrt(c)*Math.sqrt(_))return tm(r,e[0],e[2],1),!1;const f=[0,0],x=new Qt;x.setInfinite();const y=Sr(2*g,-(p/u+4*d),2*(1-u)/u,x,!1,f);if(0===y)return tm(r,e[0],e[2],1),!1;1===y&&(f[1]=f[0]);const v=Math.sqrt(l/f[0]),P=Math.sqrt(l/f[1]),b=.5/u;let E=b-_*f[0],C=b-c*f[0];Math.abs(E)>Math.abs(C)?C=d*f[0]-b+1:E=d*f[0]-b+1;const D=o.mul(E).add(a.mul(C)),S=D.norm(1)<1e-15*v?0:Math.atan2(D.y,D.x)+Math.PI,w=o.add(a),A=i?i.clone():e[1].add(w.mul(l)),T=e[0].sub(A),I=e[2].sub(A),N=T.crossProduct(I)<0,M=!1;new jr;return r.constructEllipticArcEndPointsCenter(e[0],e[2],v,P/v,S,M,!N,A)}function xm(t,e,s,i,n){return fm(t,e,s,i,n)}function ym(t){let e=!1;{const s=new _s(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center);e=_s.distance(t.getStartXY(),s)>Qi(t)}let s=!1;if(!e){const e=new _s(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(t.m_center);s=_s.distance(t.getEndXY(),e)>Qi(t)}return!e&&!s}function vm(t){t.queryCoord2D(.5,t.m_interior)}function Pm(t,e,s,i,n){if(n){if(0!==hl(e,s))return 2}else if(Mi(e,s))return 1;return 0!==Em(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function bm(t,e,s,i,n){if(n){if(0!==hl(e,s))return 2}else if(Mi(e,s))return 1;return 0!==Cm(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Em(e,s,i,n,r,o,a,h,m,u){if(em(s)){return sr(new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,u)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0);const l=Ki(s,i);if($i(s,i,a=Math.max(l,a)))return 0;const c=i.getStartXY();c.subThis(s.m_center);const d=i.getEndXY();d.subThis(s.m_center),c.rotateReverse(s.m_cosr,s.m_sinr),d.rotateReverse(s.m_cosr,s.m_sinr);const _=d.clone();_.subThis(c);const g=s.m_semiMajorAxis,p=1/g,f=s.getSemiMinorAxis(),x=1/f,y=_.clone();y.leftPerpendicularThis();const v=Math.atan2(f*y.y,g*y.x),P=new Array(16),b=new Array(16);let E=0;const C=[v,v+Math.PI];for(let t=0;t<2;++t){const e=kh(s,C[t]);if(e>=0&&e<=1){P[E]=e;const t=s.getCoord2D(P[E]);b[E]=i.getClosestCoordinate(t,!1),_s.distance(t,i.getCoord2D(b[E]))<=a&&E++}}const D=c.x*p,S=c.y*x,w=_.x*p,A=_.y*x;let T=Sr(w*w+A*A,2*(D*w+S*A),D*D+S*S-1,Qt.unit(),!1,b);t(T>=0);for(let t=0;t<T;t++){const e=_.mul(b[t]).add(c);e.x*=p,e.y*=x;const n=kh(s,Math.atan2(e.y,e.x));if(n>=0&&n<=1){P[E]=n;const t=s.getCoord2D(n);b[E]=i.getClosestCoordinate(t,!1),_s.distance(t,i.getCoord2D(b[E]))<=a&&E++}}t(E<P.length+4);const I=new Array(16);T=s.intersectPoint(i.getStartXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=I[t],b[E]=0;T=s.intersectPoint(i.getEndXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=I[t],b[E]=1;T=i.intersectPoint(s.getStartXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=0,b[E]=I[t];T=i.intersectPoint(s.getEndXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=1,b[E]=I[t];return 0===E?0:dl(e,s,i,P,b,E,n,r,o,a,h,m,u)}function Cm(t,e,s,i,n,r,o,a,h,m){if(em(e)){return Em(t,s,new fl({pt1:e.getStartXY(),pt2:e.getEndXY()}),i,r,n,o,a,h,!m)}if(em(s)){return Em(t,e,new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,m)}return h?Jr(e,s,0,o,a)?1:0:$r(e,s,0,o,i,n,r,a,m)}function Dm(e,s,i,n,r){if(0===e.m_semiMajorAxis)return i.vmin;let o=_s.getNAN();e.queryCoord2D(i.vmin,o);let a=_s.getNAN();if(e.queryCoord2D(i.vmax,a),em(e)){return new fl({pt1:o,pt2:a}).getClosestCoordinate(s,n)}const h=Yh(e,s);if(o=Yh(e,o),a=Yh(e,a),1===e.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;const t=kh(e,Math.atan2(h.y,h.x));if(n||i.containsCoordinate(t))return t;return _s.distance(h,o)<=_s.distance(h,a)?i.vmin:i.vmax}const m=e.getSemiMajorAxis(),u=e.getSemiMinorAxis(),l=(m-u)*(m+u),c=ve(l),d=h.x,_=h.y,g=ve(u*_),p=u*l*_*2,f=[new $t(g),new $t(p),new $t(c-ve(m*d)-g),new $t(-p),new $t(-c)],x=is($t,4),y=Lr(f,4,new Qt(-1,1),!1,x,4);let v=i.vmin,P=_s.sqrDistance(h,o);{const t=_s.sqrDistance(h,a);t<P&&(v=i.vmax,P=t)}t(!n);let b=new Array(8);for(let t=0;t<y;++t){const s=x[t].value(),i=Math.sqrt(1-s*s),n=Math.atan2(s,i),r=Math.atan2(s,-i);b[2*t]=kh(e,n),b[2*t+1]=kh(e,r)}b=b.slice(0,2*y),Ue(b);for(let t=0,E=2*y;t<E;++t)if(b[t]>i.vmin&&b[t]<i.vmax){const i=_s.sqrDistance(s,e.getCoord2D(b[t]));P>i&&(P=i,v=b[t])}return v}function Sm(e,s,i){return t(0),!1}function wm(e,s,i){t(!em(e));const n=new cn;n.setRotateAngle(-e.getAxisXRotation());const r=new _s;n.queryTransform(s,r);const o=Math.atan2(-r.x*e.getMinorMajorRatio(),r.y),a=o+Et();let h=kh(e,o),m=kh(e,a);m<h&&(m=je(h,h=m));let u=0;return h>=0&&h<=1&&(i[u++]=h),m>=0&&m<=1&&(i[u++]=m),u}function Am(e,s,i){t(0)}function Tm(t,e,s,i){const n=t.getStartXY(),r=t.getEndXY(),o=n.equals(r),a=e.equals(s);if(!o&&!a){const i=new cn;i.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=_s.distance(e,s),a=_s.distance(n,r),h=o/a;i.scale(h,h);const m=r.sub(n);m.divThis(a);const u=s.sub(e);u.divThis(o);const l=m.crossProduct(u),c=u.dotProduct(m);return i.rotate(c,l),i.shiftCoords(e.x,e.y),rm(t,i,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,void(t.m_YEnd=s.y)}const h=new _s;if(t.queryCoord2D(.5,h),a){if(o){const i=t.m_center.add(e.sub(n));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),i),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}else t.constructCircularArcThreePoint(e,s,e);return}const m=e.add(s).mul(.5),u=s.sub(e);u.rightPerpendicularThis();const l=m.add(u),c=_s.getClosestCoordinate(m,l,t.getCenter(),!0),d=new _s;ye(m,l,c,d);const _=_s.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,_,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}function Im(e,s,i,n){const r=e.getStartXY(),o=e.getEndXY(),a=r.equals(o),h=s.equals(i);if(!a&&!h){const t=new cn;return t.initializeFromTwoPoints(r,o,s,i),rm(e,t,!0),e.m_XStart=s.x,e.m_YStart=s.y,e.m_XEnd=i.x,e.m_YEnd=i.y,e.endPointModified(),void e.normalizeAfterEndpointChange()}if(!e.isMajor())return void tm(e,s,i,1);if(a&&h){const t=e.m_center.add(s.sub(r));return void e.constructEllipticArcEndPointsCenter(s,i,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),t)}if(!a){const t=.5*(Ct()-Math.abs(e.getSweepAngle())),n=(e.getSweepAngle()+t*Ee(e.getSweepAngle()))/e.getSweepAngle(),r=new _s;e.queryCoord2D(n,r),e.constructEllipticArcEndPointsCenter(r,r,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),e.getCenter());const o=e.getCenter().add(s.sub(r));return void e.constructEllipticArcEndPointsCenter(s,i,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),o)}const m=_s.sqrDistance(s,i);let u=.25,l=.75;if(m<_s.sqrDistance(e.getCoord2D(.25),e.getCoord2D(.75))){const s=[0],i=Dr(new Rh(e,m),Qt.construct(0,.25),1,s);i>0&&(t(1===i),u=s[0],l=1-s[0])}const c=e.getCoord2D(u),d=e.getCoord2D(l);t(!c.equals(d)),e.constructEllipticArcEndPointsCenter(c,d,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),e.m_center),Im(e,s,i)}class Nm{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Mm(t){return qm(t.calculateUpperLength2D())}function qm(t){return 256*yt()*t}function Rm(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Fm(t,e,s){const i=is(_s,4);t.queryControlPoints(i),Xm(i,e,s)}function Ym(t,e,s){const i=is(_s,4);t.queryControlPoints(i),Lm(i,e,s)}function Xm(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function Lm(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function zm(t,e,s){const i=t[0],n=t[1],r=t[2],o=t[3];e[1].setDouble(n.x),e[1].subDoubleThis(i.x),e[1].mulDoubleThis(3),e[2].setDouble(r.x),e[2].subDoubleThis(n.x),e[2].mulDoubleThis(3),e[3].setDouble(o.x),e[3].subDoubleThis(i.x),e[3].subThis(e[2]),e[2].subThis(e[1]),e[0].setDouble(i.x),s[1].setDouble(n.y),s[1].subDoubleThis(i.y),s[1].mulDoubleThis(3),s[2].setDouble(r.y),s[2].subDoubleThis(n.y),s[2].mulDoubleThis(3),s[3].setDouble(o.y),s[3].subDoubleThis(i.y),s[3].subThis(s[2]),s[2].subThis(s[1]),s[0].setDouble(i.y)}function Vm(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Vm(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=km(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=Mm(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=Vu(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function Bm(t,e,s){const i=Vm(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Dr(new Lu(t,e),Qt.unit(),1,n)&&E(""),n[0]}function km(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Nm,s=is($t,8),i=is(_s,4);t.queryControlPoints(i);const n=Ru(i,s);e.specialPoints=[];for(let r=0;r<n;r++)e.specialPoints.push(s[r].value());return Wm(t,e),e}function Gm(t){let e=null;return e=t.m_cachedValues,e}function Wm(t,e){t.m_cachedValues=e}function Zm(t){t.m_cachedValues=null}function Hm(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new cn,o=is(_s,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new _s;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=is(_s,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformPoints(t.m_cp,2,t.m_cp):(ye(e,s,1/3,t.m_cp[0]),ye(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&su(t)}function Om(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function jm(t,e,s,i){const n=new Array(18),r=is(_s,4);t.queryControlPoints(r);const o=Dr(new wu(r,e),Qt.construct(s,i),18,n),a=new _s;t.queryCoord2D(s,a);let h=s,m=_s.distance(a,e);const u=new _s;t.queryCoord2D(i,u);const l=_s.distance(u,e);l<m&&(m=l,h=i,a.assign(u));for(let c=0;c<o;c++){t.queryCoord2D(n[c],u);const s=_s.distance(u,e);s<m&&(m=s,h=n[c],a.assign(u))}return Om(s,i,h,m,a)}function Um(e,s){const i=is($t,4);Fm(e,i,!0);const n=is($t,4);Ym(e,n,!0);const r=i[3].clone(),o=i[2].clone(),a=i[1].clone(),h=n[3].clone(),m=n[2].clone(),u=n[1].clone(),l=o.mulE(a).addE(m.mulE(u)).mul(4),c=o.mulE(o).mul(8).addE(r.mulE(a).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),d=r.mulE(o).addE(h.mulE(m)).mul(36),_=r.mulE(r).addE(h.mulE(h)).mul(36),g=is($t,3),p=Xr(_,d,c,l,new Qt(0,1),!1,g);if(t(p<=3),p>0){const t=tu(e,1,0).sqrLength(),i=tu(e,1,1).sqrLength();let n=t;s.set(0),n<i&&(n=i,s.set(1));for(let r=0;r<p;r++){const t=tu(e,1,g[r].value()).sqrLength();t<n&&(n=t,s=g[r])}}}function Qm(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}function Km(t,e,s,i){{const e=ne.subE(s),n=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new $t(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));i.setE(o.mulE(new $t(3)))}}function $m(t,e,s){const i=new _s;return Qm(t,e,s,i),i}function Jm(t,e,s){const i=[Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2]),Ai.constructPoint2D(t[3])],n=new Ai;return Km(i,e,s,n),n}function tu(t,e,s){const i=is(_s,4);return t.queryControlPoints(i),$m(i,e,s)}function eu(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e);return(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function su(t){const e=is(_s,4);t.queryControlPoints(e);const s=iu(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function iu(t){let e=!1;for(let s=0;s<2;s++){const i=j(t[0][s],t[3][s]);i>0?(j(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),j(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),j(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),j(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?(j(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),j(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),j(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),j(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function nu(t){const e=j(t[0].y,t[1].y),s=j(t[1].y,t[2].y),i=j(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=j(t[0].x,t[1].x),s=j(t[1].x,t[2].x),i=j(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}function ru(t,e,s){const i=new _s,n=new _s,r=new _s,o=new _s,a=new _s;e<=.5?(me(2,t[0],t[1],e,i),me(2,t[1],t[2],e,n),me(2,t[2],t[3],e,r),me(2,i,n,e,o),me(2,n,r,e,a),me(2,o,a,e,s)):(ue(2,t[0],t[1],e,i),ue(2,t[1],t[2],e,n),ue(2,t[2],t[3],e,r),ue(2,i,n,e,o),ue(2,n,r,e,a),ue(2,o,a,e,s))}function ou(e,s,i,n){t(s>=0&&s<=1);const r=new _s,o=new _s,a=new _s,h=new _s,m=new _s,u=new _s;s<=.5?(me(2,e[0],e[1],s,r),me(2,e[1],e[2],s,o),me(2,e[2],e[3],s,a),me(2,r,o,s,h),me(2,o,a,s,m),me(2,h,m,s,u)):(ue(2,e[0],e[1],s,r),ue(2,e[1],e[2],s,o),ue(2,e[2],e[3],s,a),ue(2,r,o,s,h),ue(2,o,a,s,m),ue(2,h,m,s,u)),nu(e);const l=e[3].clone();i&&(i[0].assign(e[0]),i[1].assign(r),i[2].assign(h),i[3].assign(u)),n&&(n[0].assign(u),n[1].assign(m),n[2].assign(a),n[3].assign(l))}function au(e,s,i,n){if(t(s>=0&&i<=1&&s<=i),s===i){const t=new _s;return hu(e,s,t),n[0].assign(t),n[1].assign(t),n[2].assign(t),void n[3].assign(t)}if(0===s&&1===i){for(let t=0;t<4;++t)n[t].assign(e[t]);return}const r=is(_s,4);ou(e,i,r,null),ou(r,i>0?s/i:0,null,r),hu(e,s,r[0]),hu(e,i,r[3]),n[0].setCoordsPoint2D(r[0]),n[1].setCoordsPoint2D(r[1]),n[2].setCoordsPoint2D(r[2]),n[3].setCoordsPoint2D(r[3])}function hu(t,e,s,i){if(i){if(e<0){return void On(new fl({pt1:t[0],pt2:t[0].add(lu(t,0).getUnitVector())}),e,s)}if(e>1){return void On(new fl({pt1:t[3],pt2:t[3].add(lu(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const i=new _s;me(2,t[0],t[1],e,i);const n=new _s;me(2,t[1],t[2],e,n);const r=new _s;me(2,t[2],t[3],e,r);const o=new _s;me(2,i,n,e,o);const a=new _s;me(2,n,r,e,a),me(2,o,a,e,s)}else{const i=new _s;ue(2,t[0],t[1],e,i);const n=new _s;ue(2,t[1],t[2],e,n);const r=new _s;ue(2,t[2],t[3],e,r);const o=new _s;ue(2,i,n,e,o);const a=new _s;ue(2,n,r,e,a),ue(2,o,a,e,s)}}function mu(t,e,s){if(e.value()<=.5){const i=new Ai;_e(2,Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),e,i);const n=new Ai;_e(2,Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2]),e,n);const r=new Ai;_e(2,Ai.constructPoint2D(t[2]),Ai.constructPoint2D(t[3]),e,r);const o=new Ai;_e(2,i,n,e,o);const a=new Ai;_e(2,n,r,e,a),_e(2,o,a,e,s)}else{const i=new Ai;ge(2,Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),e,i);const n=new Ai;ge(2,Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2]),e,n);const r=new Ai;ge(2,Ai.constructPoint2D(t[2]),Ai.constructPoint2D(t[3]),e,r);const o=new Ai;ge(2,i,n,e,o);const a=new Ai;ge(2,n,r,e,a),ge(2,o,a,e,s)}}function uu(t,e,s){const i=is(_s,4);t.queryControlPoints(i),mu(i,e,s)}function lu(t,e){const s=Pt(e,0,1);let i=$m(t,1,s);return i||(i=$m(t,2,s),i?1===s&&i.negateThis():i=$m(t,3,s)),i}function cu(t,e,s){const i=is(_s,4);t.queryControlPoints(i),du(i,e,s)}function du(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(Jm(t,1,e))}function _u(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==yu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function gu(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==vu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function pu(t,e,s,i,n){if(n){if(0!==hl(e,s))return 2}else if(Mi(e,s))return 1;return 0!==Pu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function fu(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==bu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function xu(e,s,i,n,r){return t(0),0}function yu(t,e,s,i,n,r,o,a,h,m){if(null!==n&&(n.length=0),null!=r&&(r.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],a=e.intersectPoint(s.getStartXY(),t,o);if(a>0){if(null!==n)for(let e=0;e<a;e++)n.push(t[e]);if(null!==r)for(let t=0;t<a;t++)r.push(0);if(null!=i)for(let s=0;s<a;s++){const n=new _s;e.queryCoord2D(t[s],n),i.push(n)}}return a}const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=is(_s,4);Rm(e,l);const c=s.getEndXY();c.subThis(s.getStartXY());const d=c.clone();d.leftPerpendicularThis();let _=3*l[3].dotProduct(d),g=2*l[2].dotProduct(d),p=l[1].dotProduct(d);const f=new Array(15),x=new Array(15);let y=Sr(_,g,p,Qt.unit(),!1,f);y<0&&(f[0]=0,f[1]=1,y=2);let v,P=0;for(let C=0,D=P;C<y;++C){const t=e.getCoord2D(f[C+D]);x[P]=s.getClosestCoordinate(t,!1),_s.distance(t,s.getCoord2D(x[P]))<=o&&(f[P]=f[C+D],P++)}if(l[0].subThis(s.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){const t=c.y/c.x;_=l[3].y-l[3].x*t,g=l[2].y-l[2].x*t,p=l[1].y-l[1].x*t,v=l[0].y-l[0].x*t}else{const t=c.x/c.y;_=l[3].x-l[3].y*t,g=l[2].x-l[2].y*t,p=l[1].x-l[1].y*t,v=l[0].x-l[0].y*t}const b=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),E=[0,0,0];y=wr(_,g,p,v,Qt.unit(),b,E);for(let C=0,D=P;C<y;++C){f[C+D]=E[C];const t=e.getCoord2D(f[C+D]);x[P]=s.getClosestCoordinate(t,!1);_s.distance(t,s.getCoord2D(x[P]))<=o&&(f[P]=f[C+D],P++)}y=e.intersectPoint(s.getStartXY(),E,o);for(let C=0;C<y;C++)f[P]=E[C],x[P++]=0;y=e.intersectPoint(s.getEndXY(),E,o);for(let C=0;C<y;C++)f[P]=E[C],x[P++]=1;return 0!==s.intersectPoint(e.getStartXY(),E,o)&&(x[P]=E[0],f[P++]=0),0!==s.intersectPoint(e.getEndXY(),E,o)&&(x[P]=E[0],f[P++]=1),0===P?0:dl(t,e,s,f,x,P,i,n,r,o,a,h,m)}function vu(t,e,s,i,n,r,o,a,h,m){if(em(s)){return yu(t,e,new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,m)}const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=is(_s,4);{e.queryControlPoints(d);const t=is(_s,4),i=new cn;s.canonicToWorldTransformation(i);const n=new cn;n.setInvert(i),n.transformPoints(d,4,t);const r=is(ms,4),a=is(ms,4);zm(t,r,a);const h=is(ms,3);h[0].setDouble(s.getSemiMinorAxis()),h[0].sqrThis(),h[1].setDouble(s.getSemiMajorAxis()),h[1].sqrThis(),h[2].setThis(h[0]),h[2].mulThis(h[1]),h[2].negateThis();const m=Eo(r,3,a,3,null,0,h,!0,Qt.unit(),Qt.unit(),l);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new _s;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new _s;s.queryCoord2D(r,a);_s.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const _=[0,1];for(let g=0;g<2;g++){const t=0===g?s.getStartXY():s.getEndXY(),e=[0];Au(d,t,Qt.unit(),!1,-1,1,e);const i=new _s;hu(d,e[0],i);_s.distance(t,i)<=o&&(l.push(e[0]),c.push(_[g]))}for(let g=0;g<2;g++){const t=[0,3];{const e=s.getClosestCoordinate(d[t[g]],!1),i=new _s;s.queryCoord2D(e,i);_s.distance(d[t[g]],i)<=o&&(l.push(_[g]),c.push(e))}}return dl(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function Pu(t,e,s,i,n,r,o,a,h,m){const u=is(_s,4);e.queryControlPoints(u);const l=is(_s,4);if(s.queryControlPoints(l),Ji(u,l,4)<0)return Pu(t,s,e,i,r,n,o,a,h,!m);const c=Ki(e,s);if($i(e,s,o=Math.max(o,c)))return 0;if(Bu(e,s,i,n,r,o,a,h,m))return 2;const d=new Qt(0,1),_=new Qt(0,1);{const t=new Di;Su(u,new Qt(0,1),t);const e=new Di;Su(l,new Qt(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Yu(u,t,d),Yu(l,t,_),d.isEmpty()||_.isEmpty())return 0;au(u,d.vmin,d.vmax,u),au(l,_.vmin,_.vmax,l)}}const g=gl(u,3,l,3,o);if(0===g)return 0;const p=[],f=[];if(-1===g){const t=is(ms,4),e=is(ms,4);zm(u,t,e);const s=is(ms,4),i=is(ms,4);zm(l,s,i);const n=[],r=[],a=vo(t,3,e,3,null,0,s,3,i,3,null,0,!0,Qt.unit(),Qt.unit(),n,r);if(a>0)for(let h=0;h<a;h++){const t=new _s;hu(l,r[h],t);const e=new _s;hu(u,n[h],e);_s.distance(e,t)<=o&&(f.push(r[h]),p.push(n[h]))}}for(let x=0;x<2;x++){const t=0===x?u:l,e=0===x?l:u;for(let s=0;s<2;s++){const i=0===s?0:3,n=[0];Au(e,t[i],Qt.unit(),!1,-1,1,n);const r=new _s;hu(e,n[0],r);_s.distance(t[i],r)<=o&&(0===x?(p.push(0===i?0:1),f.push(n[0])):(f.push(0===i?0:1),p.push(n[0])))}}if(0===p.length)return 0;if(!d.equalsRange(0,1))for(let x=0;x<p.length;++x)p[x]=vl.recalculateParentT(d.vmin,d.vmax,p[x]);if(!_.equalsRange(0,1))for(let x=0;x<f.length;++x)f[x]=vl.recalculateParentT(_.vmin,_.vmax,f[x]);return dl(t,e,s,p,f,p.length,i,n,r,o,a,h,m)}function bu(e,s,i,n,r,o,a,h,m,u){const l=Ki(s,i);if(i.isDegenerateToLineHelper(l)){const t=new fl({pt1:i.getStartXY(),pt2:i.getEndXY()}),l=yu(e,s,t,n,r,o,a,h,m,u);if(o)for(let e=0;e<l;++e){const s=t.getCoord2D(o[e]);o[e]=i.getClosestCoordinate(s,!1)}return l}if($i(s,i,a=Math.max(a,l)))return 0;const c=is(_s,4);s.queryControlPoints(c);const d=is(_s,3);i.queryControlPoints(d);const _=new Qt(0,1),g=new Qt(0,1),p=[0,0,0];i.queryWeights(p);const f=[1,Dh(p),1];{const t=new Di;Su(c,new Qt(0,1),t);const e=new Di;th(d,f,new Qt(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Yu(c,t,_),Ch(d,f,t,g),_.isEmpty()||g.isEmpty())return 0;au(c,_.vmin,_.vmax,c),rh(d,f,g.vmin,g.vmax,d,f)}}const x=gl(c,3,d,2,a);if(0===x)return 0;const y=[],v=[];if(-1===x){const t=is(ms,4),e=is(ms,4);zm(c,t,e);const s=is(ms,3),i=is(ms,3),n=is(ms,3);fh(d,f,s,i,n);const r=[],o=[],h=vo(s,2,i,2,n,2,t,3,e,3,null,0,!0,Qt.unit(),Qt.unit(),o,r);if(h>0)for(let m=0;m<h;m++){const t=new _s;hu(c,r[m],t);const e=new _s;Eh(d,f,o[m],e);_s.distance(t,e)<=a&&(y.push(r[m]),v.push(o[m]))}}for(let P=0;P<2;P++){let e,s;0===P?(e=c,s=d):(s=c,e=d);for(let i=0;i<2;i++){const n=0===i?0:e.length-1,r=[0],o=new _s;if(0===P){t(1===Qa(s,f,e[n],Qt.unit(),!1,-1,1,r)),Eh(s,f,r[0],o)}else{t(1===Au(s,e[n],Qt.unit(),!1,-1,1,r)),hu(s,r[0],o)}_s.distance(e[n],o)<=a&&(0===P?(y.push(0===n?0:1),v.push(r[0])):(v.push(0===n?0:1),y.push(r[0])))}}if(0===y.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=vl.recalculateParentT(_.vmin,_.vmax,y[t]);if(!g.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=lo.recalculateParentT(g.vmin,g.vmax,v[t]);for(let t=0;t<v.length;++t)v[t]=Sh(p,v[t]);return dl(e,s,i,y,v,y.length,n,r,o,a,h,m,u)}function Eu(e,s,i,n,r,o,a,h,m,u){const l=Ki(s,i);if($i(s,i,a=Math.max(a,l)))return 0;const c=is(_s,4);s.queryControlPoints(c);const d=is(_s,3);i.queryControlPoints(d);const _=gl(c,3,d,2,a);if(0===_)return 0;const g=[],p=[];if(-1===_){const t=is(ms,4),e=is(ms,4);zm(c,t,e);const n=is(ms,3),r=is(ms,3);ha(d,n,r);const o=vo(n,2,r,2,null,0,t,3,e,3,null,0,!0,Qt.unit(),Qt.unit(),p,g);if(o>0){let t=0;for(let e=0;e<o;e++){const n=new _s;s.queryCoord2D(g[e],n);const r=new _s;i.queryCoord2D(p[e],r);_s.distance(n,r)<=a&&(g[t]=g[e],p[t]=p[e],t++)}g.length=t}}for(let f=0;f<2;f++){let e,s;0===f?(e=c,s=d):(s=c,e=d);for(let i=0;i<2;i++){const n=0===i?0:e.length-1,r=[0],o=new _s;if(0===f)jo(s,e[n],r),ma(s,r[0],o);else{t(1===Au(s,e[n],Qt.unit(),!1,-1,1,r)),hu(s,r[0],o)}_s.distance(e[n],o)<=a&&(0===f?(g.push(0===n?0:1),p.push(r[0])):(p.push(0===n?0:1),g.push(r[0])))}}return dl(e,s,i,g,p,g.length,n,r,o,a,h,m,u)}function Cu(e,s,i,n,r){const o=new Di;if(Du(e,Qt.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(s))return 0;const a=km(e);let h=0,m=a.specialPoints[0];const u=[];for(let l=1,c=a.specialPoints.length;l<c;++l){const i=a.specialPoints[l],n=jm(e,s,m,i);if(0===u.length)u.push(n);else if(n.t===n.tmin)t(u.at(-1).d<=n.d),u.at(-1).tmax=n.tmax;else if(u.at(-1).t===u.at(-1).tmax){t(u.at(-1).d>=n.d);const e=u.at(-1).tmin;u[u.length-1]=n,u.at(-1).tmin=e}else u.push(n);m=i}for(const t of u)if(t.d<=n){const e=t.t;i?(h>=i.length&&b(""),i[h]=e,h++):h++}return h}function Du(t,e,s){const i=is(_s,4);t.queryControlPoints(i),Su(i,e,s)}function Su(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=is(_s,4);au(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}class wu{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new _s;hu(this.controlPoints,e,t);const s=$m(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new _s;hu(this.controlPoints,e,t);const s=$m(this.controlPoints,1,e),i=$m(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new _s;hu(this.controlPoints,e,t);const s=$m(this.controlPoints,1,e),i=$m(this.controlPoints,2,e),n=$m(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=$m(this.controlPoints,1,e),s=$m(this.controlPoints,2,e),i=$m(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=$m(this.controlPoints,2,e),s=$m(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=$m(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(e){return t(0),0}}function Au(e,s,i,n,r,o,a){N(Qt.unit().contains(i)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],m=new _s;hu(e,i.vmin,m);let u=_s.distance(m,s);if(u<=r&&h.push(new _s(i.vmin,u)),i.vmin!==i.vmax&&(hu(e,i.vmax,m),u=_s.distance(m,s),u<=r&&h.push(new _s(i.vmax,u))),i.width()>0){const t=new Array(18),n=Dr(new wu(e,s),i,18,t);for(let i=0;i<n;i++)hu(e,t[i],m),u=_s.distance(m,s),u>r||h.push(new _s(t[i],u))}if(n){t(i.equals(Qt.unit()));{hu(e,-1,m,!0);const t=new _s;hu(e,0,t);const i=new fl({pt1:m,pt2:t}),n=i.getClosestCoordinate(s,!0);n<1&&(m.assign(i.getCoord2D(n)),u=_s.distance(m,s),u<=r&&h.push(new _s(n-1,u)))}{hu(e,2,m,!0);const t=new _s;hu(e,i.vmax,t);const n=new fl({pt1:t,pt2:m}),o=n.getClosestCoordinate(s,!0);o>0&&(m.assign(n.getCoord2D(o)),u=_s.distance(m,s),u<=r&&h.push(new _s(1+o,u)))}}if(!h.length)return 0;h.sort(((t,e)=>t.compare(e)));let l=0;const c=h[0].x;if(a[l++]=c,l<o){const t=Js(e,4,!1).total(),s=h[0].y;for(let e=1,i=h.length;e<i;e++)if(h[e].y>s+t){h.length=e;break}h.sort(((t,e)=>$e(t.x,e.x))),l=0,a[l++]=h[0].x;for(let e=1,i=h.length;e<i;e++)h[e].x!==a[l-1]&&l<o&&(a[l++]=h[e].x)}return l}function Tu(t,e,s,i,n,r,o){const a=is(_s,4);return t.queryControlPoints(a),Au(a,e,s,i,n,r,o)}function Iu(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function Nu(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function Mu(e,s,i){if(t(i>=2),2===i){const t=new _s;ye(s[0],s[i-1],1/3,t);const n=new _s;return ye(s[0],s[i-1],2/3,n),void e.construct(s[0],t,n,s[i-1])}const n=s[0],r=s[i-1],o=[0,0],a=Tu(e,n,Qt.unit(),!1,Number.NaN,2,o),h=[0,0],m=Tu(e,r,Qt.unit(),!1,Number.NaN,2,h),u=[];for(let t=0;t<a;t++)for(let a=0;a<m;a++){const m=o[t],l=h[a],c=(t,o)=>{const a=[];a.length=i-2;const h=()=>{let t=0;for(let e=1,n=i-1;e<n;e++){t+=_s.distance(s[e-1],s[e]);const i=t;a[e-1]=i}t+=_s.distance(s[i-2],s[i-1]);for(let e=1,s=i-1;e<s;e++)a[e-1]/=t};let u=!1,c=!1;{const s=new xl;m<=l?(e.queryCut(m,l,s,!0),t.assign(s.get().getControlPoint1()),o.assign(s.get().getControlPoint2())):(e.queryCut(l,m,s,!0),t.assign(s.get().getControlPoint2()),o.assign(s.get().getControlPoint1())),n.equals(t)&&(u=!0),r.equals(o)&&(c=!0)}h();let d=Number.MAX_VALUE;const _=t.clone(),g=o.clone();for(let e=0;e<5;e++){d=ku(!0,!1,n,_,g,r,u,c,a,i-2,s,i)}for(let e=0;e<30;e++){const t=_.clone();g.clone();const e=ku(!0,!0,n,_,g,r,u,c,a,i-2,s,i);if(d<=e&&t.equals(_)&&t.equals(g))break;d=e}h();let p=!1,f=Number.EPSILON;const x=t.clone(),y=o.clone();for(let e=0;e<30;e++){const t=x.clone();y.clone();const e=ku(p,!0,n,x,y,r,u,c,a,i-2,s,i);if(f<=e&&t.equals(x)&&t.equals(y))break;p=!0,f=e}return f<d?(t.assign(x),o.assign(y)):(t.assign(_),o.assign(g),f=d),f},d=new _s,_=new _s,g=[c(d,_),_s.distance(n,d)+_s.distance(d,_)+_s.distance(_,r),d.x,d.y,_.x,_.y];u.splice(u.length,0,...g)}let l=u[0],c=u[1],d=0;for(let t=6;t<u.length;t+=6)u[t]<l&&(l=u[t],c=u[t+1],d=t);let _=d;for(let t=0;t<u.length;t+=6)t!==d&&u[t+1]<c&&Math.abs(l-u[t])<10*l&&(c=u[t+1],_=t);e.construct(n,new _s(u[_+2],u[_+3]),new _s(u[_+4],u[_+5]),r)}function qu(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),r=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),o=is($t,2);let a=Yr(r,n,i,new Qt(0,1),!1,o);a<0&&(a=0);let h=0;for(let m=0;m<a;m++)vt(o[m].value(),0,1)||(s[h].setE(o[m]),h++);return h}function Ru(e,s){s[0].set(0);let i=1;const n=is($t,4);Xm(e,n,!0);const r=is($t,4);Lm(e,r,!0);{const t=n[3].mul(3),e=n[2].mul(2),r=n[1].clone(),o=is($t,2);let a=Yr(t,e,r,new Qt(0,1),!1,o);a<0&&(a=0);for(let n=0;n<a;n++)vt(o[n].value(),0,1)||(s[i]=o[n],i++)}{const t=r[3].mul(3),e=r[2].mul(2),n=r[1].clone(),o=is($t,2);let a=Yr(t,e,n,new Qt(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)vt(o[r].value(),0,1)||(s[i]=o[r],i++)}if(i+=qu(n,r,s.slice(i)),s[i].set(1),i++,i>2){Ke(s,i,((t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0}));let t=0;const n=s[0].clone();let r=0;const o=Nu(e)*yt(),a=new _s;ru(e,s[0].value(),a);for(let h=1;h<i;h++){const i=new _s;if(ru(e,s[h].value(),i),s[h].eq(n)||i.isEqualPoint2D(a,o)){if(0!==t){if(0===s[h].eps())n.setE(s[h]),r=0;else if(0!==r){const t=ve(1/s[h].eps()),e=1/r,i=t+e;n.set((s[h].value()*t+n.value()*e)/i),r=1/i,n.setError(Math.sqrt(r))}s[t].setE(n),ru(e,n.value(),a)}}else t++,s[t].setE(s[h]),n.setE(s[h]),ru(e,n.value(),a),r=ve(s[h].eps())}t++,i=t}return 1===i&&(i=2,s[1].set(1)),t(0===s[0].value()),t(1===s[i-1].value()),i}function Fu(t,e,s,i,n){const r=is($t,4),o=is($t,3),a=new Qt(0,1);let h=0;if(e){if(Lm(t,r,!1),h=Xr(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new _s;hu(t,o[m].value(),e),i[m]=e.x}}else if(Xm(t,r,!1),h=Xr(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new _s;hu(t,o[m].value(),e),i[m]=e.y}if(n)for(let m=0;m<h;m++)n[m]=o[m].value();else i&&Ke(i,h,$e);return h}function Yu(t,e,s){s.setEmpty();const i=[];i.push(new Qt(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const r=i.at(-1);i.pop();const o=new Di;if(Su(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=n||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();i.push(Qt.construct(r.vmin,t)),i.push(Qt.construct(t,r.vmax))}}}}function Xu(t,e,s){s.length=0;{const e=new $t;Um(t,e);const i=new Ai;if(cu(t,e,i),i.isZero())return e.isZero()||e.eq(new $t(1))?0:(s.push(e.value()),1)}const i=is($t,4);Fm(t,i,!0);const n=is($t,4);Ym(t,n,!0);const r=is($t,6),o=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),a=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));r[0]=n[1].mulE(n[1]).mulE(o).addE(i[1].mulE(i[1]).mulE(a)).addE(i[1].mulE(n[1]).mulE(h).mul(2)).mul(6),r[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const m=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),u=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(m).mul(156),l=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),d=i[1].mulE(i[3]).mulE(c).addE(n[1].mulE(n[3]).mulE(l)).mul(72),_=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),g=i[2].mulE(n[2]).mulE(_).mul(120),p=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),f=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(p).mul(36);r[2]=u.addE(d).addE(g).addE(f);const x=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),y=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),v=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),P=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);r[3]=x.addE(y).addE(v).addE(P),r[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),r[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const b=is($t,5),E=Lr(r,5,new Qt(0,1),!1,b,5);if(E>0){let i=Math.abs(t.getCurvature(0)),n=0;const r=Math.abs(t.getCurvature(1));(r>i||!Number.isFinite(r))&&(n=1);for(let e=0;e<E;e++){const s=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=b[e].value())}if((!Number.isFinite(i)||1/i<e)&&!vt(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}return 0}class Lu{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Vm(this.b,e,!1):0}getError(e){return t(0),0}}function zu(e,s,i,n,r,o,a){for(;;){const h=_s.distance(s[0],s[3]),m=_s.distance(s[0],s[1])+_s.distance(s[1],s[2])+_s.distance(s[2],s[3]);if(m-h<=n+i*m)return e+pe(h,m,.5);const u=t=>$m(s,1,t).length();if(0===o){t(a<8);let h=u(0),l=u(1);r[0]+=2,h>l&&(l=je(h,h=l),s[3]=je(s[0],s[0]=s[3]),s[2]=je(s[1],s[1]=s[2]));let c=h/(h+l),d=1,_=m;for(;c<1/32&&_>=32*(n+i*_);){d/=4;const t=u(d);r[0]++,c=h/(t+h);const e=new _s;if(hu(s,.5*d,e),_=_s.distance(e,s[0]),_<=n){const t=new _s;hu(s,d,t),_+=_s.distance(t,e)}}if(1!==d){const t=is(_s,4);ou(s,d,s,t),e=zu(e,t,i,n,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=va(l,u,0,1),d=16;r[0]+=d;const _=va(d,u,0,1);let g=Math.abs(c-_)>n+i*m;if(!g)return e+_;if(o<3){const t=is(_s,4);ou(s,.5,s,t),e=zu(e,t,i,n,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const f=va(p,u,0,1);if(g=Math.abs(_-f)>n+i*m,!g)return e+f;const x=64;r[0]+=x;const y=va(x,u,0,1);if(g=Math.abs(f-y)>n+i*m,!g)return e+y;const v=128;r[0]+=v;const P=va(v,u,0,1);return g=Math.abs(y-P)>n+i*m,e+P}}function Vu(t,e,s,i,n){if(s===e)return 0;const r=is(_s,4);t.queryControlPoints(r);const o=is(_s,4);au(r,e,s,o);return zu(0,o,i,n,[0],0,0)}function Bu(t,e,s,i,n,r,o,a,h){const m=is(_s,4);t.queryControlPoints(m);const u=is(_s,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return s&&(s.length=0,s.push(m[0]),s.push(m[3])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=je(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=je(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[3]),h&&(s[1]=je(s[0],s[0]=s[1]))),!0)}function ku(t,e,s,i,n,r,o,a,h,m,u,l){let c=0,d=0,_=0,g=0,p=0,f=0,x=0;for(let v=1,P=l-1;v<P;v++){let e,o,a,m,l,y,P=-1,b=h[v-1];t&&(v>2?(b=Pt(2*h[v-2]-h[v-3],0,1),h[v-1]=b):2===v&&b<=h[0]&&(b=h[0]));for(let c=0;c<11&&(e=h[v-1],o=e*e,a=o*e,m=1-e,l=m*m,y=l*m,t)&&!(Math.abs(e-P)<1e-12)&&10!==c;c++){const t=s.x-2*i.x+n.x,a=s.x-3*i.x+3*n.x-r.x,m=s.y-2*i.y+n.y,c=s.y-3*i.y+3*n.y-r.y,d=s.x-i.x-2*t*e+a*o,_=-u[v].x+s.x*y+e*(3*i.x*l+e*(3*n.x-3*n.x*e+r.x*e)),g=s.y-i.y-2*m*e+c*o,p=-u[v].y+s.y*y+e*(3*i.y*l+e*(3*n.y-3*n.y*e+r.y*e));P=e;const f=e- -6*(d*_+g*p)/(6*(3*ve(d)-(-2*t+2*a*e)*_)+6*(3*ve(g)-(-2*m+2*c*e)*p));h[v-1]=Pt(f,v>1?h[v-2]:0,1)}c+=3*o*l*l,d+=3*a*y,_+=3*o*o*l;const E=-(y*s.x+a*r.x-u[v].x);g+=E*e*l,p+=E*o*m;const C=-(y*s.y+a*r.y-u[v].y);f+=C*e*l,x+=C*o*m}if(e){const t=c*_-d*d;Math.abs(t)>=1e-12*(Math.abs(c*_)+Math.abs(d*d))+1e-10?(o||(i.x=(g*_-p*d)/t,i.y=(f*_-x*d)/t),a||(n.x=(c*p-d*g)/t,n.y=(c*x-d*f)/t)):(ye(s,r,.3,i),ye(s,r,.6,n))}let y=0;for(let v=1,P=l-1;v<P;v++){const t=h[v-1],e=1-t,o=s.mul(Pe(e)),a=i.mul(3*t*e*e),m=n.mul(3*t*t*e),l=r.mul(Pe(t));y+=o.add(a).add(m).add(l).sub(u[v]).sqrLength()}return y}class Gu{constructor(t,e){this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class Wu{constructor(e){t(0)}assignCopy(e){return t(0),this}assignMove(e){return t(0),this}getGeometryCount(){return t(0),0}reserve(e){t(0)}addGeometry(e){t(0)}addGeometryMove(e){t(0)}addCursor(e){t(0)}getGeometry(e){return t(0),new Ci}static generateGeometryCursor(t,e=-1){return new Gu(t,e)}modifiedElementIndex(e){t(0)}modifiedElement(e){t(0)}getGeometryType(){return r.enumGeometryCollection}getDimension(){return t(0),0}getDescription(){return t(0),new Ft(1)}assignVertexDescription(e){t(0)}mergeVertexDescription(e){t(0)}hasAttribute(e){return t(0),!1}addAttribute(e){t(0)}dropAttribute(e){t(0)}dropAllAttributes(){t(0)}queryInterval(e,s){return t(0),new Qt(0,0)}queryEnvelope(e){t(0)}queryLooseEnvelope(e){t(0)}isEmpty(){return t(0),!1}setEmpty(){t(0)}applyTransformation(e){t(0)}transformAttribute(e,s,i,n,r){t(0)}createInstance(){return t(0),this}copyTo(e){t(0)}calculateArea2D(){return t(0),0}calculateLength2D(){return t(0),0}calculateLength3D(e){return t(0),0}getBoundary(){return t(0),this}clone(){return t(0),this}equals(e,s){return t(0),!1}swap(e){t(0)}setAttributeBasic(e,s,i){t(0)}replaceNaNs(e,s){t(0)}getImpl(){return this}vertexCount(){return t(0),0}hasNonLinearSegments(){return t(0),!1}mergeVertexDescriptionImpl(e){t(0)}}function Zu(e,s){let i=s,n=null;i||(n=d(e)?vs.getDefaultDescription3D():vs.getDefaultDescription2D(),i=n);let o=null;switch(e){case r.enumPoint:o=new Ci({vd:i});break;case r.enumLine:o=new fl({vd:i});break;case r.enumBezier:o=new vl({vd:i});break;case r.enumEllipticArc:o=new jr({vd:i});break;case r.enumRationalBezier2:o=new lo({vd:i});break;case r.enumBezier2:o=new go({vd:i});break;case r.enumEnvelope:o=new Cs({vd:i});break;case r.enumMultiPoint:o=new dn({vd:i});break;case r.enumPolyline:o=new cr({vd:i});break;case r.enumPolygon:o=new Ur({vd:i});break;case r.enumMultipatch:t(0);break;case r.enumGeometryCollection:o=new Wu({vd:i});break;default:f("Geometry.create")}return o}Wu.type=r.enumGeometryCollection;var Hu=Ft;const Ou=-1,ju=1;class Uu{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}function Qu(t){return void 0!==t.parent}class Ku{constructor(t){Qu(t)?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==Ou;){for(;this.m_path!==Ou;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==Ou)return this.m_vertex;if(this.m_bOneGeom)return Ou;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===Ou)break;this.m_bSkipMultiPoints&&!c(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return Ou}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==Ou&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return Ou}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==Ou?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==Ou&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):Ou}currentGeometry(){return this.m_geometry}currentPath(){return t(0),0}static create_(t,e,s,i,n,r,o,a,h){return new Ku({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class $u{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class Ju{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let s=0,i=this.m_indices.length;s<i;s++){if(s===this.m_selectionIndex)continue;const t=this.m_indices[s];null!==t&&t.size()>e&&t.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,ju),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,ju),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=!1;const n=e!==Ou?this.getPrevVertex(e):this.getLastVertex(t),r=n!==Ou?this.getNextVertex(n):Ou,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByVal(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==Ou&&this.setPrevVertex(r,o),n!==Ou&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===Ou&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==Ou||this.setFirstVertex(t,o)),h&&r===Ou&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const u=this.getGeometryFromPath(t);return this.setGeometryVertexCount(u,this.getPointCount(u)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new Ci({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPath_(e){return t(0),0}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(e,s){return t(0),0}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let n=0,r=s.getPathCount();n<r;n++){if(0===s.getPathSize(n))continue;const e=this.insertPath(t,Ou);this.setClosedPath(e,s.isClosedPath(n));for(let t=s.getPathStart(n),r=s.getPathEnd(n);t<r;t++){const n=this.insertVertex_(e,Ou,null,!1);if(i){const e=this.getVertexIndex(n);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const i=new xl;s.querySegment(t,i,!0),this.setSegmentToIndex(e,i.releaseSegment())}}}s.isStrongPathStart(n)&&this.setStrongPathStart(e,!0),s.isStrongPathEnd(n)&&this.setStrongPathEnd(e,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===r.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(e,s,i){t(0)}appendMultiPathPolygon(e,s,i){const n=s.getImpl(),r=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),o=ps.constructEmpty();s.queryEnvelope(o),t(i.isIntersecting(o)&&!i.containsEnvelope(o));let a=ps.construct(Number.NEGATIVE_INFINITY,i.ymin,Number.POSITIVE_INFINITY,i.ymax),h=ps.construct(i.xmin,Number.NEGATIVE_INFINITY,i.xmax,Number.POSITIVE_INFINITY);a.height()>h.width()&&(h=je(a,a=h));const m=[],u=n.queryLimitedSegmentIterator(a);let l=-1,c=-100,d=-1,_=0,g=-1,p=-1,f=Ou,x=!0,y=u.nextSegment();if(null!==y)for(;;y=u.nextSegment()){let i=null===y;const o=null!==y?u.getPathIndex():l,a=null!==y?u.getStartPointIndex():c;if(i||(o===l?c+1===a?_++:i=!0:(i=l>=0,l<0&&(l=o,d=n.getSegmentCountPath(l),g=a,f=Ou,_=1))),i){if(!(0===m.length&&d===_)){0!==m.length&&m[0].first===g||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(s,g,g+1),-1===p&&(p=g),f===Ou&&(f=this.insertPath(e,Ou),this.setClosedPath(f,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(f,Ou,null,!1));for(const{first:i,second:o}of m){-1===p&&(p=i);let a=-1,h=-1;const u=i+o-1;if(o===d){const e=u+1;h=e-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(s,i,e),a=u,t(1===m.length)}else if(u+1<n.getPathEnd(l)){const t=u+2;h=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(s,i,t),a=u}else{const t=n.getPathStart(l),e=t!==p?1:0,r=u+1;h=r-i+e,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-i)+e),this.m_verticesMp.addPoints(s,i,r),a=u,e>0&&this.m_verticesMp?.addPoints(s,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),f===Ou&&(f=this.insertPath(e,Ou),this.setClosedPath(f,!0));for(let t=0,e=i;t<h;t++,e++){const t=this.insertVertex_(f,Ou,null,!1);if(r){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new xl;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===m.length||m.at(-1).first+m.at(-1).second!==g+_){let t=g+_;t===s.getPathEnd(l)&&(t=s.getPathStart(l)),p!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(s,t,t+1),this.insertVertex_(f,Ou,null,!1))}}m.length=0,x=!0,o!==l&&(l=o,d=n.getSegmentCountPath(l),f=Ou,p=-1),g=a,_=1}if(!y)break;{const t=ps.constructEmpty();y.queryLooseEnvelope(t),h.isIntersecting(t)?(x?m.push(q(a,1)):m.at(-1).second++,x=!1):x=!0}c=a}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const i=e.getGeometryType()===r.enumPolygon,n=ps.constructEmpty();e.queryEnvelope(n),s.isIntersecting(n)&&(!s.containsEnvelope(n)&&e.getPointCount()>10?i?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(e,s,i){t(0)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,Ou);for(let i=0,n=e.getPointCount();i<n;i++)this.insertVertex_(s,Ou,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)?(-1===r&&(r=m,o=m),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,Ou);for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&this.insertVertex_(h,Ou,null,!1)}}splitSegmentForward(t,e,s,i,n){const o=this.getNextVertex(t);o===Ou&&f("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let l=0,c=e.getResultSegmentCount(s);l<c;l++){const t=this.getVertexIndex(m),i=this.getNextVertex(m),d=e.getResultSegment(s,l);let _=null;if(d.getGeometryType()!==r.enumLine&&(_=d.clone(),_.dropAllAttributes()),0===l&&(d.queryStart(a),this.setSegmentToIndex(t,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,l),e.getResultSegmentStartPointWeight(s,l),n)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,l)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,l)),u){const t=e.getResultSegmentSegmentParentage(s,l),i=e.getResultSegmentStartPointIsBreak(s,l);this.setSegmentParentageAndBreak(m,t,i)}if(d.queryEnd(a),l<c-1){this.setSegmentToIndex(t,_);const n=this.insertVertex(h,i,a);this.setWeight(n,e.getResultSegmentEndPointWeight(s,l)),this.setRank(n,e.getResultSegmentEndPointRank(s,l)),this.select(n),m=n}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,l),e.getResultSegmentEndPointWeight(s,l),n);const i=e.getResultSegmentEndPointIsBreak(s,l);this.setSegmentParentageBreakVertex(o,i),this.setSegmentToIndex(t,_)}}}splitSegmentBackward(t,e,s,i,n){const o=this.getNextVertex(t);o===Ou&&f("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let l=0,c=e.getResultSegmentCount(s);l<c;l++){const t=c-l-1,i=this.getVertexIndex(m),d=this.getNextVertex(m),_=e.getResultSegment(s,t);let g=null;if(_.getGeometryType()!==r.enumLine&&(g=_.clone(),g.reverse(),g.dropAllAttributes()),0===l&&(_.queryEnd(a),this.setSegmentToIndex(i,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),n),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,t),e.getResultSegmentEndPointIsBreak(s,t))),_.getGeometryType()===r.enumLine?this.setSegmentToIndex(i,null):this.setSegmentToIndex(i,g),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),_.queryStart(a),l<c-1){const i=this.insertVertex(h,d,a);this.setWeight(i,e.getResultSegmentStartPointWeight(s,t)),this.setRank(i,e.getResultSegmentStartPointRank(s,t)),this.select(i),m=i,u&&this.setSegmentParentageAndBreak(i,e.getResultSegmentSegmentParentage(s,t),e.getResultSegmentEndPointIsBreak(s,t))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),n)}}splitSegmentForward3D(e,s,i){t(0)}splitSegmentBackward3D(e,s,i){t(0)}selected_(e){return t(0),!1}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?Is(0,-1):Is(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return Is(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),r=this.getVertexIndex(t),o=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(r),e=this.getSegmentFromIndex(o);this.setSegmentToIndex(o,null),this.setSegmentToIndex(r,e),this.setSegmentToIndex(o,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=je(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,Ou,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return Ou}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,((t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s}))}sortVerticesSimpleByYHelper3D(e,s,i){t(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_hasForceSetEnvelope=!1,this.m_workPoint2D=_s.getNAN(),this.m_workPoint2_2D=_s.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=Ou,this.m_lastGeometry=Ou,this.m_vertexIndexList=new ks(5),this.m_pathIndexList=new ks(8),this.m_geometryIndexList=new ks(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new Hs,this.m_forceSetEnvelope=ps.constructEmpty(),this.m_hasForceSetEnvelope=!1,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(this.m_hasForceSetEnvelope)return this.m_forceSetEnvelope;const e=this.hasCurves(),s=ps.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let r=i.next();r!==Ou;r=i.next()){if(n?s.merge(this.getXY(r)):s.mergeNe(this.getXY(r)),e){const t=this.getSegment(r);if(null!==t){const e=ps.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}n=!1}return s}getEnvelope3D(e){return t(0),Vs.constructEmpty()}forceSetEnvelope2D(e){t(0)}forgetForceSetEnvelope2D(){t(0)}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if(c(s))return this.addMultiPath(t,e);if(s===r.enumMultiPoint)return this.addMultiPoint(t,e);if(s===r.enumPoint)return this.addPoint_(t,e);if(s===r.enumEnvelope){const s=new Ur;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}f("")}appendGeometry(t,e){this.m_verticesMp.mergeVertexDescription(e.getDescription()),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1;const s=e.getGeometryType();c(s)?this.appendMultiPath(t,e):s!==r.enumMultiPoint?f(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(e,s){t(0)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(r.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=Ou,s=-1,i=-1;for(let n=this.getFirstGeometry();n!==Ou;)if(t!==r.enumUnknown&&this.getGeometryType(n)!==t)n=this.getNextGeometry(n);else{if(e===Ou){e=n,s=this.getPathCount(e),i=this.getPointCount(e),n=this.getNextGeometry(n);continue}for(let s=this.getFirstPath(n);s!==Ou;s=this.getNextPath(s))this.setPathGeometry(s,e);s+=this.getPathCount(n),i+=this.getPointCount(n);const t=this.getLastPath(e),r=this.getFirstPath(n);t!==Ou?this.setNextPath(t,r):this.setFirstPath(e,r),r!==Ou&&(this.setPrevPath(r,t),this.setLastPath(e,this.getLastPath(n))),this.setFirstPath(n,Ou),this.setLastPath(n,Ou);const o=n;n=this.getNextGeometry(n),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==Ou&&(this.setGeometryVertexCount(e,i),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(e){return t(0),!0}swapGeometry(e,s){t(0)}addPathFromMultiPath(e,s,i){return t(0),0}getGeometry(e){const s=this.getGeometryType(e),i=Zu(s,this.m_verticesMp.getDescription()),n=this.getPointCount(e);if(0===n)return i;if(c(s)){const t=i.getImpl(),s=this.getPathCount(e),r=Is(s+1),o=Ns(s+1,0),a=i.getDescription(),h=this.hasCurves();for(let i=0,m=a.getAttributeCount();i<m;i++){const h=a.getSemantics(i),m=Hu.getComponentCount(h),u=As(h,n),l=this.m_vertices.getAttributeStreamRef(h);let c=0,d=0,_=0;for(let t=this.getFirstPath(e);t!==Ou;t=this.getNextPath(t)){let e=0;this.isClosedPath(t)&&(e|=1),this.isExterior(t)&&(e|=8),this.isStrongPathStart(t)&&(e|=2),this.isStrongPathEnd(t)&&(e|=4),e&&o.setBits(d,e);const s=this.getPathSize(t);if(r.write(d++,_),_+=s,0===h){const e=l,s=u;let i;for(let n=this.getFirstVertex(t);c<_;n=this.getNextVertex(n),c++){const t=this.getVertexIndex(n);i=e.readPoint2D(2*t),s.writePoint2D(2*c,i)}}else for(let i=this.getFirstVertex(t);c<_;i=this.getNextVertex(i),c++){const t=this.getVertexIndex(i);for(let e=0;e<m;e++){const s=l.readAsDbl(t*m+e);u.writeAsDbl(c*m+e,s)}}}t.setAttributeStreamRef(h,u),r.write(s,n)}if(t.setPathFlagsStreamRef(o),t.setPathStreamRef(r),t.notifyModifiedFlags(65535),h){let s=0,i=0;for(let n=this.getFirstPath(e);n!==Ou;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let e=this.getFirstVertex(n);i<s;e=this.getNextVertex(e)){const s=this.getSegment(e);null!==s&&s.isCurve()&&t.replaceSegment(i,s,!0),i++}}}}else if(s===r.enumMultiPoint){const t=i.getImpl(),s=i.getDescription();t.reserve(n),t.resizeNoInit(n);for(let i=0,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=Hu.getComponentCount(n),o=t.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);let h=0;const m=this.getFirstPath(e),u=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<u;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}t.setAttributeStreamRef(n,o)}t.notifyModifiedFlags(65535)}else t(0);return i}queryPointGeometryOnly(e,s){t(0)}removeGeometry(t){for(let i=this.getFirstPath(t);i!==Ou;i=this.removePath(i));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==Ou?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==Ou?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=vs.getDefaultDescription2D());const s=this.newGeometry(t);return this.m_vertices?this.m_verticesMp.mergeVertexDescription(e):(this.m_verticesMp=new dn({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1,this.m_firstGeometry===Ou?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=Is(0),t;this.m_geometryIndices.push(Is(0));const e=this.m_geometryIndices.length-1;return t(e>=0&&e<=Number.MAX_SAFE_INTEGER),e}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==Ou;t=this.getNextGeometry(t))if(!c(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(e,s,i,n,o){const a=e*e;let h=0;const m=this.hasCurves(),u=this.hasSegmentParentage();for(let l=o===Ou?this.getFirstGeometry():o;l!==Ou;l=o===Ou?this.getNextGeometry(l):Ou){const e=this.getGeometryType(l);if(!c(e))continue;if(i&&e!==r.enumPolygon)continue;const o=this.getGeometryType(l)===r.enumPolygon;let d=this.getGeometryModified(l);for(let i=this.getFirstPath(l);i!==Ou;){let e=0;for(let s=this.getFirstVertex(i);e<this.getPathSize(i)/2;){const r=this.getNextVertex(s);if(r===Ou)break;const o=this.getXY(s),c=this.getXY(r);let _=_s.sqrDistance(o,c),g=!0;do{if(_<=a){if(m){const t=this.getSegment(s);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===h&&(h=-1):h=1,r!==this.getLastVertex(i)){const e=u&&(this.getSegmentParentageBreakVertex(s)||this.getSegmentParentageBreakVertex(r));if(this.transferAllDataToTheVertex(r,s),this.removeVertex(r,!1),n&&!d&&(this.setGeometryModified(l,!0),d=!0),u&&s!==r){this.setSegmentParentageBreakVertex(s,e);const i=this.getNextVertex(s);t(i!==Ou),this.isDiscontinuousSegmentParentage(i)&&this.setSegmentParentageBreakVertex(i,!0)}}g=!1}}while(0);g&&(s=this.getNextVertex(s)),e++}let r=this.getFirstVertex(i);for(let t=this.isClosedPath(i)?r:this.getLastVertex(i);this.getPathSize(i)>0;){const e=this.getPrevVertex(t);if(e===Ou)break;{const s=this.getXY(e),o=this.getXY(t);let c=_s.sqrDistance(s,o),_=!0;do{if(c<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(c=e*e,c>a)break}}0===c?0===h&&(h=-1):h=1;const s=u&&(this.getSegmentParentageBreakVertex(t)||this.getSegmentParentageBreakVertex(e));this.removeVertex(e,!0),n&&!d&&(this.setGeometryModified(l,!0),d=!0),u&&e!==t&&(s||this.isDiscontinuousSegmentParentage(t))&&this.setSegmentParentageBreakVertex(t,!0),r===e&&(r=this.getFirstVertex(i)),_=!1}}while(0);if(_&&(t=this.getPrevVertex(t),t===r))break}}const c=this.getPathSize(i);let _=s&&c<(o?3:2);_&&o&&2===c&&m&&(_=!this.pathHasCurves(i)),_?(i=this.removePath(i),0===h&&(h=-1),n&&!d&&(this.setGeometryModified(l,!0),d=!0)):i=this.getNextPath(i)}}return h}filterClosePoints3D(e,s,i,n,r,o){return t(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==Ou;e=this.getNextGeometry(e))if(c(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==Ou;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===Ou)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(e,s){return t(0),!1}transferAllDataToTheVertex(t,e){const s=this.getVertexIndex(t),i=this.getVertexIndex(e);if(this.m_weights){const t=this.getWeightWithIndex(s);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(s);this.setRankWithIndex(i,t)}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(i,t)}this.m_bHasAttributes;for(let r=0,o=this.m_indices.length;r<o;r++)if(r!==this.m_selectionIndex&&null!==this.m_indices[r]){const s=this.getUserIndex(t,r);-1!==s&&this.setUserIndex(e,r,s)}const n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,i,n){let r=0;const o=this.getNextVertex(t);o===Ou&&f("");const a=this.getVertexIndex(t),h=this.getVertexIndex(o),m=this.getSegmentFromIndex(a);let u=this.m_vertices.getShortestDistance(a,h);const l=this.getPathFromVertex(t),c=this.m_bHasAttributes;c&&m&&(u=m.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,n=0,g=Ou;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=m.cut(t,s);if(null!==i&&(p>0&&e.setStartXY(i[p-1]),e.setEndXY(i[p]),e.normalizeAfterEndpointChange(),n=p),c){const t=u>0?m.calculateSubLengthFromStart(s)/u:0;this.m_vertices.interpolateTwoVertices(a,h,t,_)}_.setXY(e.getEndXY()),g=this.insertVertex(l,o,_),r++;const f=this.getPrevVertex(g),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==d&&this.setSegmentParentageAndBreak(g,d,!1),t=s}}if(g!==Ou){const e=m.cut(t,1);null!==i&&(e.setStartXY(i[n]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(g);this.setSegmentToIndex(s,e)}}else{let t=0;for(let i=0;i<s;i++){const s=e[i];if(t<s&&s<1){this.m_vertices.interpolateTwoVertices(a,h,s,_);const t=this.insertVertex(l,o,_);r++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=s}}return r}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(e,s,i){return t(0),!1}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==Ou;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(e,s,i){return t(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==Ou){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByVal(s,e)}setPointOnlyEx(e,s,i,n){t(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==Ou){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new _s(e,s),t,!1),n.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==Ou){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new _s(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}setXYZ(e,s){t(0)}setXYZCoords(e,s,i,n){t(0)}queryXYZ(e,s){t(0)}getXYZ(e){return t(0),gs.getNAN()}getXYZWithIndex(e){return t(0),gs.getNAN()}getAttributeAsDbl(e,s,i){return t(0),0}queryAttributeAsDbl(e,s,i,n){t(0)}setAttribute(e,s,i,n){t(0)}setAttributeInt(e,s,i,n){t(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(e){return t(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){return this.getXY(t).y}getX(e){return t(0),0}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(e,s){return t(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=Ms(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=Ms(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return ju;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?ju:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?ju:this.m_ranks.read(t)}setRank(t,e){e<ju&&(e=ju);const s=e===ju;if(null===this.m_ranks){if(s)return;this.m_ranks=Is(this.m_vertices.getPointCount(),ju)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,ju)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<ju&&(e=ju);const s=e===ju;if(null===this.m_ranks){if(s)return;this.m_ranks=Is(this.m_vertices.getPointCount(),ju)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,ju)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=Ms(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=Ms(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return Ju.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?Ju.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?ju:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<ju&&(e=ju);const s=e===ju;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=Is(this.m_vertices.getPointCount(),ju)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,ju)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(e,s){t(0)}removeWeights(){t(0),this.m_weights=new Xs(0),this.m_segmentWeights=new Xs(0)}removeRanks(){t(0),this.m_ranks=new Fs(0),this.m_segmentRanks=new Fs(0)}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];if(s<i.size()){return i.read(s)}return-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());const e=this.m_indices.length-1;return t(e>=0&&e<=$()),e}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));const e=this.m_indices.length-1;return t(e>=0&&e<=Number.MAX_SAFE_INTEGER),e}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let r=this.getFirstPath(t);r!==Ou;r=this.getNextPath(r)){let t=this.getFirstVertex(r);for(let e=0,o=this.getPathSize(r);e<o;e++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(e,s){t(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===Ou)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new Ci({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(e,s,i=!1){return t(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(e){return t(0),!1}pathHasCurves(e){return t(0),!1}insertPath(t,e){let s=Ou;e!==Ou?(t!==this.getGeometryFromPath(e)&&f(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const i=this.newPath(t);return e!==Ou&&this.setPrevPath(e,i),this.setNextPath(i,e),this.setPrevPath(i,s),s!==Ou?this.setNextPath(s,i):this.setFirstPath(t,i),e===Ou&&this.setLastPath(t,i),this.setGeometryPathCount(t,this.getPathCount(t)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==Ou?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Ou?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==Ou){let s=e;for(let e=0,n=this.getPathSize(t);e<n;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,Ou),this.setPrevVertex(s,Ou);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(e){t(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===Ou)return 0;const s=this.getXY(e),i=new Yt(0),n=this.getPathSize(t);if(n>2){const t=s.clone(),r=t.x,o=t.y;let a=this.getNextVertex(e);const h=this.getXY(a);a=this.getNextVertex(a);const m=_s.getNAN();for(let e=2;e<n;e++,a=this.getNextVertex(a))this.queryXY(a,m),i.pe((m.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);i.pe((r-t.x)*(h.y-o))}if(this.hasCurves()){let t=e;for(let e=0;e<n;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===r.enumLine)continue;const s=2*e.calculateArea2DHelper();i.pe(s)}}this.setRingAreaValid(t,!0);const o=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=o,o}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());const e=this.m_pathindices.length-1;return t(e>=0&&e<=Number.MAX_SAFE_INTEGER),e}fillPathUserIndexForGeometry(e,s,i){t(0)}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,s){if(s===Ou&&f(""),e===s)return;const i=this.getNextPath(s);let n=this.getPrevPath(s);const r=this.getGeometryFromPath(s);n===Ou?this.setFirstPath(r,i):this.setNextPath(n,i),i===Ou?this.setLastPath(r,n):this.setPrevPath(i,n),this.setGeometryVertexCount(r,this.getPointCount(r)-this.getPathSize(s)),this.setGeometryPathCount(r,this.getPathCount(r)-1),n=e===Ou?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,n),this.setNextPath(s,e),e===Ou?this.setLastPath(t,s):this.setPrevPath(e,s),n===Ou?this.setFirstPath(t,s):this.setNextPath(n,s),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(s)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(s,t)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,Ou,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==Ou&&this.setNextVertex(i,n);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:Ou),n!==Ou&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:Ou);if(this.hasCurves()&&i!==Ou&&n!==Ou){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(e,s){t(e!==s);const i=this.getPathFromVertex(e),n=this.getPrevVertex(e),r=this.getPrevVertex(s);n!==Ou&&this.setNextVertex(n,s);let o=this.getPathSize(i);const a=this.getVertexIndex(e);this.setSegmentToIndex(a,null),this.setPrevVertex(s,n),this.setPrevVertex(e,Ou),this.setNextVertex(r,Ou);let h=0,m=e;const u=this.getFirstVertex(i);let l=!1;for(;;){const t=this.getNextVertex(m);if(l||=u===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,l&&this.setFirstVertex(i,o>0?s:Ou),this.setPathSize(i,o);const c=this.getGeometryFromPath(i);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(e,s){return t(0),0}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||E(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==Ou;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==Ou;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=Ou){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=Ou){let s=Ou,i=Ou,n=Ou,r=Ou,o=0,a=!1;for(s=e!==Ou?e:this.getFirstGeometry();s!==Ou;s=this.getNextGeometry(s))if(!t||c(this.getGeometryType(s))){for(i=this.getFirstPath(s);i!==Ou;i=this.getNextPath(i))if(n=this.getFirstVertex(i),r=n,o=0,n!==Ou){a=!0;break}if(a||e!==Ou)break}return a||(s=Ou),Ku.create_(this,s,i,n,r,o,t,!1,e!==Ou)}queryVertexIteratorOnSelection(t=Ou){return this.m_selection?Ku.create_(this,t,Ou,Ou,Ou,-1,!1,!0,t!==Ou):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){t(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=Ou,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(e,s){return t(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}splitSegmentWithIntersector3D(e,s,i,n){t(0)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(e){return t(0),!1}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===Ou)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}getAndClearSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=!1,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(e,s){return t(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==Ou?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Ou?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,Ou),this.setLastVertex(t,Ou),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,Ou);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(e,s){return t(0),0}findVertex3D(e,s,i){return t(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(e,s){t(0)}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);s!==Ou&&this.setNextVertex(s,i),i!==Ou&&this.setPrevVertex(i,s);if(this.hasCurves()&&s!==Ou&&i!==Ou){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.getXY(t).compare(this.getXY(e))}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(e,s){t(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new Uu(this))}sortVerticesSimpleByX(e,s,i){t(0)}sortVerticesSimpleByY3D(e,s,i){t(0)}snapVertexForPoleClipping(e,s){t(0)}setSegmentParentageAndBreak(e,s,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===s)return;this.m_segmentParentageIndex=this.createUserIndex()}s>=0&&(t(s<=Q()>>1),s<<=1,s|=i?1:0),this.setUserIndex(e,this.m_segmentParentageIndex,s)}setSegmentParentagePreserveBreak(e,s){if(-1===this.m_segmentParentageIndex){if(-1===s)return;this.m_segmentParentageIndex=this.createUserIndex()}if(s>=0){t(s<=Q()>>1),s<<=1;s|=this.getSegmentParentageBreakVertex(e)?1:0}this.setUserIndex(e,this.m_segmentParentageIndex,s)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new $u(e)}return new $u(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=Q()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);if(e===Ou)return!1;return this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function tl(e,s,i){if(s<=262144)return rl(e,s,i);t(0);const n=new sl({points:e,n:s}),r=0;let o=1;const a=e[r].clone();for(;o<s&&e[o].equals(a);)o++;if(n.m_treeHull.addElement(r),o<s){n.m_treeHull.addBiggestElement(o);for(let t=o+1;t<s;t++){const s=e[t],i=n.treeHull(s);-1!==i&&n.m_treeHull.setElement(i,t)}}let h=0;for(let t=n.m_treeHull.getFirst();-1!==t;t=n.m_treeHull.getNext(t))i[h++]=n.m_treeHull.getElement(t);return h}Ju.st_defaultRank=1;class el{constructor(e){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,t(0),this.m_convexHull=e,this.m_function=this.done_}next(){return t(0),!1}get_vertex_handle_p(){return t(0),0}get_vertex_handle_q(){return t(0),0}get_current_support(){return t(0),0}getNext(e){return t(0),0}getPrev(e){return t(0),0}intialize_(){return t(0),!1}increment_(){return t(0),!1}increment_q_(){return t(0),!1}increment_p_(){return t(0),!1}parallel_edge_with_q_support_(){return t(0),!1}parallel_edge_with_p_support_(){return t(0),!1}done_(){return t(0),!1}}class sl{constructor(t){this.m_treeHull=new Ws,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,t||(this.m_treeHull.setCapacity(20),this.m_shape=new Ju,this.m_geometryHandle=this.m_shape.createGeometry(r.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,Ou),this.m_stream=null,this.m_points=null),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape}getXYShape(e){return t(0),new _s}getXYStream(e){return t(0),new _s}getXYPoints(e){return t(0),new _s}deleteNodeShape(e){t(0)}deleteNodeStream(e){t(0)}deleteNodePoints(e){t(0)}add_geometry(e){t(0)}get_bounding_geometry(){return t(0),null}get_antipodal_pairs_iterator(){return t(0),new el(this)}getXY(e){return t(0),new _s}getXYWithIndex(e){return t(0),new _s}getFirst(){return t(0),0}getLast(){return t(0),0}getNext(e){return t(0),0}getPrev(e){return t(0),0}getVertexIndex(e){return t(0),0}getPointCount(){return t(0),0}addMultiVertexGeometry(e){t(0)}addEnvelope(e){t(0)}addSegment(e){t(0)}addPoint(e){t(0)}addPoint2D(e){return t(0),0}treeHull(e){return t(0),0}treeHullWalkForward(e,s,i){return t(0),0}treeHullWalkBackward(e,s,i){return t(0),0}static isClockwise(e){return t(0),!1}static isCounterClockwise(e){return t(0),!1}static isDegenerate(e){return t(0),!1}static isBetween(e,s,i){return t(0),0}}function il(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:_s.orientationRobust(t,e,s)}function nl(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:_s.orientationRobust(t,e,s)}function rl(t,e,s){const i=new Fs(0);for(let a=0;a<e;a++)i.add(a);const n={userSort(e,s,i){i.sort(e,s,((e,s)=>t[e].compareX(t[s])))},getValue:e=>t[e].x};Hs.sortEx(i,0,e,n);let r=0;t:for(let a=0;a<e;++a){const e=i.read(a);for(;r>=2;){const n=s[r-2],o=s[r-1];if(t[o].equals(t[e])){i.write(a,-1);continue t}if(!(il(t[n],t[o],t[e])>=0)){o===i.read(a-1)&&i.write(a-1,-1);break}r--}s[r++]=e,2===r&&t[e].equals(t[s[0]])&&(i.write(1,-1),r--)}const o=r+1;t:for(let a=e-2;a>=0;--a){const e=i.read(a);if(!(e<0)){for(;r>=o;){const i=s[r-2],n=s[r-1];if(t[n].equals(t[e]))continue t;if(!(nl(t[i],t[n],t[e])>=0))break;r--}if(0!==a){const i=s[r-1];s[r++]=e,t[e].equals(t[i])&&r--}}}return r>1&&t[s[0]].equals(t[s[r-1]])&&r--,r}function ol(t,e,s,i,n){return al(t,!1,e,s,i,n)}function al(t,e,s,i,n,o){const a=s.getGeometryType(),h=i.getGeometryType(),m=Math.max(n,Ki(s,i));if(a===r.enumLine&&h===r.enumLine)return er(s,i,m,o);let u=s,l=i,c=s.getStartXY(),d=s.getEndXY();if(c.compare(d)>0&&(u=s.clone().reverse()),c=i.getStartXY(),d=i.getEndXY(),c.compare(d)>0&&(l=i.clone().reverse()),e){if(s.equals(i))return 2;if(Xi(s,i,m))return 4}switch(a){case r.enumLine:switch(h){case r.enumEllipticArc:return Pm(t,l,u,m,o);case r.enumBezier:return _u(t,l,u,m,o);case r.enumRationalBezier2:return ah(t,l,u,m,o);case r.enumBezier2:return ea();default:E("")}break;case r.enumEllipticArc:switch(h){case r.enumLine:return Pm(t,u,l,m,o);case r.enumEllipticArc:return bm(t,u,l,m,o);case r.enumBezier:return gu(t,l,u,m,o);case r.enumRationalBezier2:return hh();case r.enumBezier2:return sa();default:E("")}break;case r.enumBezier:switch(h){case r.enumLine:return _u(t,u,l,m,o);case r.enumEllipticArc:return gu(t,u,l,m,o);case r.enumBezier:return pu(t,u,l,m,o);case r.enumRationalBezier2:return fu(t,u,l,m,o);case r.enumBezier2:return xu();default:E("")}break;case r.enumRationalBezier2:switch(h){case r.enumLine:return ah(t,u,l,m,o);case r.enumEllipticArc:return hh();case r.enumBezier:return fu(t,l,u,m,o);case r.enumRationalBezier2:return uh(t,u,l,m,o);case r.enumBezier2:return lh();default:E("")}break;case r.enumBezier2:switch(h){case r.enumLine:return ea();case r.enumEllipticArc:return sa();case r.enumBezier:return xu();case r.enumRationalBezier2:return lh();case r.enumBezier2:return ia();default:E("")}break;default:E("")}}function hl(t,e,s=!0){if(!s&&!ml(t,e))return 0;const i=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(i)return s;const n=t.getGeometryType();if(n!==e.getGeometryType())return 0;if(n===r.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(n===r.enumEllipticArc)return Sm()?s:0;if(n===r.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(n===r.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(i)return s;const n=t.getGeometryType();if(n!==e.getGeometryType())return 0;if(n===r.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(n===r.enumEllipticArc)return Sm()?s:-1;if(n===r.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(n===r.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function ml(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==r.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function ul(t,e,s,i,n,o,a){!n&&o&&f("");const h=e.getGeometryType(),m=s.getGeometryType(),u=Math.max(a,Ki(e,s));if(i&&(i.length=0),n&&(n.length=0),o&&(o.length=0),h===r.enumLine&&m===r.enumLine)return sr(e,s,i,n,o,u,!1,!1);let l=e,c=s,d=e.getStartXY(),_=e.getEndXY(),g=!1,p=!1;d.compare(_)>0&&(l=e.clone(!0).reverse(),g=!0),d=s.getStartXY(),_=s.getEndXY(),d.compare(_)>0&&(c=s.clone(!0).reverse(),p=!0);let x=0;switch(h){case r.enumLine:switch(m){case r.enumEllipticArc:x=Em(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumBezier:x=yu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=ch(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumBezier2:x=na();break;default:E("")}break;case r.enumEllipticArc:switch(m){case r.enumLine:x=Em(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumEllipticArc:x=Cm(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier:x=vu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=dh();break;case r.enumBezier2:x=ra(t,c,l,i,o,n,u,!1,!1,!0);break;default:E("")}break;case r.enumRationalBezier2:switch(m){case r.enumLine:x=ch(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumEllipticArc:x=dh();break;case r.enumBezier:x=bu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=_h(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier2:x=gh(t,l,c,i,n,o,u,!1,!1,!1);break;default:E("")}break;case r.enumBezier2:switch(m){case r.enumLine:x=na();break;case r.enumEllipticArc:x=ra(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier:x=Eu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=gh(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumBezier2:x=oa(t,l,c,i,n,o,u,!1,!1,!1);break;default:E("")}break;case r.enumBezier:switch(m){case r.enumLine:x=yu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumEllipticArc:x=vu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier:x=Pu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumRationalBezier2:x=bu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier2:x=Eu(t,l,c,i,n,o,u,!1,!1,!1);break;default:E("")}break;default:E("")}if(g){if(n){for(let t=0;t<x;t++)n[t]=1-n[t];n.reverse()}i&&i.reverse(),o&&o.reverse()}if(p&&o)for(let r=0;r<x;r++)o[r]=1-o[r];return x}function ll(t,e,s){if(e===s)return 0;e>s&&(s=je(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function cl(t,e,s,i,n){const r=[],o=[],a=[];for(let m=0,u=n;m<u;m++)r.push(t.calculateSubLengthFromStart(s[m])),o.push(e.calculateSubLengthFromStart(i[m])),vt(s[m],0,1)&&vt(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&a.push(m);if(0===a.length||a.length===n)return;a.sort(((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0));let h=-1;for(const m of a){if(h>=0&&s[m]===s[h]&&s[m]===s[h]){h=m;continue}h=m;const a=[];a.length=n;for(let t=0;t<a.length;++t)a[t]=t;a.sort(((t,e)=>{const s=r[m],i=o[m],n=r[t]-s,a=o[t]-i,h=n*n+a*a,u=r[e]-s,l=o[e]-i,c=u*u+l*l;return h<c?-1:h>c?1:0}));for(let r=0;r<n;r++){const n=a[r];if(n===m||s[n]===s[m]&&i[n]===i[m]||vt(s[n],0,1)&&vt(i[n],0,1))continue;const o=(s,i,n,r)=>{const o=new Ai,a=new $t;a.setWithEps(1);const h=new $t;h.set(i,a.eps()),t.queryCoord2DE(h,o);const m=new Ai;t.queryCoord2DE(new $t(s),m);let u=!1;return o.eq(m)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new $t(n),m),u=o.eq(m)),!u},h=_s.getNAN();t.queryCoord2D(s[n],h);const u=_s.getNAN();e.queryCoord2D(i[n],u);if(0===_s.distance(h,u)&&o(s[m],s[n],i[m],i[n]))break;const l=new Qt(i[n],i[m]);l.normalizeNoNAN();const c=new Qt(s[n],s[m]);c.normalizeNoNAN();let d=-1,_=Number.POSITIVE_INFINITY,g=s[n];for(let r=0;r<5;r++){h.assign(t.getCoord2D(g));const r=e.getClosestCoordinateOnInterval(h,l,-1);if(u.assign(e.getCoord2D(r)),g=t.getClosestCoordinateOnInterval(u,c,-1),g===s[m]&&r===i[m]){d=1;break}const a=_s.distance(u,t.getCoord2D(g));if(!(a<_)){d=0;break}if(0===a){o(s[m],s[n],i[m],i[n])?(s[n]=g,i[n]=r,d=0):d=1;break}_=a}if(-1===d&&(d=vt(s[n],0,1)||vt(i[n],0,1)?0:1),1!==d)break;s[n]=s[m],i[n]=i[m]}}}function dl(t,e,s,i,n,r,o,a,h,m,u,l,c){if(!r)return 0;const d=(t,e)=>{for(let s=0;s<r;++s){const i=e[s];if(vt(i,0,1))continue;const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&ll(t,0,i)<=Qi(t)&&(e[s]=0):n.equals(t.getEndXY())&&ll(t,i,1)<=Qi(t)&&(e[s]=1)}};d(e,i),d(s,n),cl(e,s,i,n,r);const _=[];for(let f=0,x=r;f<x;f++)_.push(f);const g=(t,e)=>c?Je(n[t],i[t],n[e],i[e]):Je(i[t],n[t],i[e],n[e]);if(_.length>1){_.sort(g);const t=Math.max(Qi(e),Qi(s));let r=0;for(let o=1,a=_.length;o<a;o++){const a=i[_[r]],h=i[_[o]],m=n[_[r]],u=n[_[o]];if(a!==h||m!==u)if(!(ll(e,a,h)<=t&&ll(s,m,u)<=t)||vt(a,0,1)&&vt(m,0,1)||vt(h,0,1)&&vt(u,0,1))r++,_[r]=_[o];else{const t=_s.distance(e.getCoord2D(a),s.getCoord2D(m)),i=_s.distance(e.getCoord2D(h),s.getCoord2D(u));if(t<=i)continue;if(i<t){_[r]=_[o];continue}}}if(_.length=r+1,1===_.length&&0!==_[0]&&(i[0]=i[_[0]],n[0]=n[_[0]],_[0]=0),_.length>2){const t=Qt.constructEmpty(),r=Qt.constructEmpty();t.setCoords(i[_[0]],i[_.at(-1)]),r.setCoords(n[_[0]],n[_.at(-1)]);let o=!0;for(let e=1,s=_.length-1;e<s;e++)if(!t.containsCoordinate(i[_[e]])||!r.containsCoordinate(n[_[e]])){o=!1;break}if(o){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let a=pe(t.vmin,t.vmax,i[n]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,m)){o=!1;break}a=pe(r.vmin,r.vmax,i[n]);const u=s.getCoord2D(a);if(!e.isCloserThanDistance(u,t,m)){o=!1;break}}}o&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t){const t=0,r=0;Yi(e,s,i[0],n[0],m,1,[t],[r])&&(_.push(1),i[1]=t,n[1]=r,_.sort(g))}if(u&&1===_.length){let t=!0;for(let r=0,o=_.length;r<o;r++){if(vt(i[_[r]],0,1)&&vt(n[_[r]],0,1)){if(0===_s.distance(e.getCoord2D(i[_[r]]),s.getCoord2D(n[_[r]])))continue}t=!1;break}if(t)return 0}let p=0;for(let f=0,x=_.length;f<x;f++){if(a&&a.push(i[_[f]]),h&&h.push(n[_[f]]),o){const t=_s.getNAN();e.queryCoord2D(i[_[f]],t),o.push(t)}p++}return p}function _l(t,e,s,i,n,r,o,a,h){if(vt(s,0,1)&&vt(i,0,1)){if(0===_s.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,u=new Ai,l=Number.EPSILON;if(t.queryDerivative(new $t(s,l),u),u.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new $t(s,l).add(e),u)}1===s&&u.negateThis();const c=new Ai;if(e.queryDerivative(new $t(i,l),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new $t(i,l).add(t),c)}1===i&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();const d=u.dotProduct(c),_=u.crossProduct(c);_.scaleError(3);const g=()=>{if(h)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(d.ge(ie)&&(_.isZero()||Math.abs(_.value())<g())){return Fi(t,e,s,i,n,r,o,a)}}}return 0}function gl(e,s,i,n,r){let o=-1,a=-1,h=-1,m=-1;{const t=[0,s],r=[s,0],u=[0,n],l=[n,0];for(let s=0;s<2&&-1===o;++s)for(let n=0;n<2;++n)if(e[t[s]].equals(i[u[n]])){o=t[s],a=r[s],h=u[n],m=l[n];break}}if(-1===o){const t=new Di;t.setFromPoints(e,s+1);const o=new Di;return o.setFromPoints(i,n+1),o.inflate(r),t.isIntersectingW(o)?-1:0}{const u=new Array(s+1),l=tl(e,s+1,u);t(l>1);let c=0,d=0;for(let t=0;t<l;++t)o===u[t]&&(d=t,c++),a===u[t]&&c++;if(2!==c)return-1;const _=new Array(n+1),g=tl(i,n+1,_);t(g>1),c=0;let p=0;for(let t=0;t<g;++t)h===_[t]&&(p=t,c++),m===_[t]&&c++;if(2!==c)return-1;const f=e[u[(d+l-1)%l]],x=e[u[(d+1)%l]],y=i[_[(p+g-1)%g]],v=i[_[(p+1)%g]],P=e[o],b=[f,x,y,v],E=[0,1,2,3];E.sort(((t,e)=>_s.compareVectorsOrigin(P,b[t],b[e])));let C=E[0];for(let t=1;t<4;t++){if(E[t]!==(C+1)%4)return-1;C=E[t]}{const t=f.sub(P),e=v.sub(P),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}{const t=x.sub(P),e=y.sub(P),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}return 1}}var pl=Ft;class fl extends Hn{constructor(t){void 0===t?super({XStart:0,YStart:0,XEnd:0,YEnd:0}):void 0!==t.x1?super({XStart:t.x1,YStart:t.y1,XEnd:t.x2,YEnd:t.y2,vd:t.vd}):void 0!==t.pt1?super({start:t.pt1,end:t.pt2,vd:t.vd}):void 0!==t.move?super({move:t.move}):void 0!==t.copy&&super({copy:t.copy})}assignMove(t){return this!==t&&(this.m_description=t.m_description,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}getBoundary(){return gr(this)}transformAttribute(e,s,i,n,r){t(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?Un(this,t):Qn(this,t);return Ze(pl.getInterpolation(e),this.getStartAttributeAsDbl(e,s),this.getEndAttributeAsDbl(e,s),t,pl.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}constructFromPoints(e,s){t(0)}getGeometryType(){return fl.type}queryEnvelope(e){if(e instanceof Cs){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=ps.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=pl.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else e instanceof ps?e.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):e instanceof Vs?(e.setEmpty(),e.mergeCoords(this.m_XStart,this.m_YStart,Hi(this,0,1,0)),e.mergeCoords(this.m_XEnd,this.m_YEnd,Hi(this,1,1,0))):t(0)}applyTransformation(e){t(0)}createInstance(){return t(0),this}calculateLength2D(){return Math.sqrt(ur(this))}calculateLength3D(e){return t(0),0}changeEndPoints2D(e,s){t(0)}queryCoord2D(t,e){return On(this,t,e)}queryCoord2DE(t,e){$n(this,t,e)}getCoordX(e){return t(0),0}getCoordY(e){return t(0),0}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const r=_s.getNAN();if(On(this,t,r),n.setStartXYCoords(r.x,r.y),On(this,e,r),n.setEndXYCoords(r.x,r.y),!i)for(let o=1,a=this.m_description.getAttributeCount();o<a;o++){const s=this.m_description.getSemantics(o),i=pl.getComponentCount(s);for(let r=0;r<i;r++){const i=this.getAttributeAsDbl(t,s,r);n.setStartAttribute(s,r,i);const o=this.getAttributeAsDbl(e,s,r);n.setEndAttribute(s,r,o)}}}queryDerivative(t,e){Kn(this,t,e)}getClosestCoordinate(t,e){return _s.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s){const i=new _s;this.queryCoord2D(e.vmin,i);const n=new _s;this.queryCoord2D(e.vmax,n);const r=_s.getClosestCoordinate(i,n,t,!1);return Hn.recalculateParentT(e.vmin,e.vmax,r)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=Un(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new fl;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(e){return t(0),new _s(0,0)}calculateWeightedCentroid2D(){return t(0),new _s(0,0)}queryAttributeAsDbl(e,s,i,n){t(0)}getTangent(t){const e=_s.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(e){return t(0),new _s(0,0)}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return or(this,t,e,s)>=0}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}getYMonotonicParts(e,s){return t(0),0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(e,s){return t(0),0}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=Un(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=Qn(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){let s=Pt(t.vmin,0,1);const i=new _s;this.queryCoord2D(s,i),e.setCoords({pt:i}),s=Pt(t.vmax,0,1),this.queryCoord2D(s,i),e.mergeNe(i)}orientBottomUp(){tr(this)}isLine(){return!0}isDegenerateToLineHelper(e){return t(0),!1}copyIgnoreAttributes(e){t(0)}calculateArea2DHelper(){return t(0),0}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoords(e,s){t(0)}writeInBufferStream(e,s){return t(0),0}readFromBufferStream(e,s){t(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(e,s){return t(0),0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){Jn(this,t,e)}static isIntersectingLineLine(e,s,i,n){return t(0),0}static isIntersectingLineLine_(e,s,i,n){return t(0),0}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&b("");const i=or(this,t,s,!1);return i>=0?(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==ol(!1,this,t,e,s)}intersect_(e,s,i,n){return t(0),0}}fl.type=r.enumLine;class xl{constructor(e){this.m_mask=0,this.m_line=null,this.m_arc=null,this.m_cubicBezier=null,this.m_quadraticRationalBezier=null,this.m_quadraticBezier=null,this.m_seg=null,void 0!==e&&(e.segment?this.copyFrom(e.segment,e.bIgnoreAttributes):e.copy?e.copy.copyTo(this,!1):t(0))}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}assignMoveFromSegment(e){return t(0),this}assignCopyFromSegment(e){return t(0),this}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}empty(){return null===this.m_seg}create(t){t===r.enumLine?this.createLine():t===r.enumEllipticArc?this.createEllipticArc():t===r.enumBezier?this.createCubicBezier():t===r.enumRationalBezier2?this.createQuadraticRationalBezier():t===r.enumBezier2?this.createQuadraticBezier():f("Segment_buffer.create")}createLine(){return 1&this.m_mask||(this.m_line=new fl,this.m_mask|=1),this.m_seg=this.m_line,this.m_line}createEllipticArc(){return 2&this.m_mask?this.m_arc.clearEndPointModified():(this.m_arc=new jr,this.m_mask|=2),this.m_seg=this.m_arc,this.m_arc}createCubicBezier(){return 4&this.m_mask||(this.m_cubicBezier=new vl,this.m_mask|=4),this.m_seg=this.m_cubicBezier,this.m_cubicBezier}createQuadraticRationalBezier(){return 8&this.m_mask||(this.m_quadraticRationalBezier=new lo,this.m_mask|=8),this.m_seg=this.m_quadraticRationalBezier,this.m_quadraticRationalBezier}createQuadraticBezier(){return 16&this.m_mask||(this.m_quadraticBezier=new go,this.m_mask|=16),this.m_seg=this.m_quadraticBezier,this.m_quadraticBezier}get(){return this.m_seg}releaseSegment(){const t=this.m_seg;if(this.m_seg=null,t===this.m_line){const e=t;return this.m_line=null,this.m_mask&=-2,e}if(t===this.m_arc){const e=t;return this.m_arc=null,this.m_mask&=-3,e}if(t===this.m_cubicBezier){const e=t;return this.m_cubicBezier=null,this.m_mask&=-5,e}if(t===this.m_quadraticRationalBezier){const e=t;return this.m_quadraticRationalBezier=null,this.m_mask&=-9,e}if(t===this.m_quadraticBezier){const e=t;return this.m_quadraticBezier=null,this.m_mask&=-17,e}E("Segment_buffer::release_segment")}}var yl=Ft;class vl extends Hn{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=is(_s,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t?(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=is(_s,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=is(_s,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),this.m_cp=is(_s,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return gr(this)}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=is(_s,4);ca(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),le(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),le(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),ji(this,t)}getGeometryType(){return r.enumBezier}queryEnvelope(e){if(!(e instanceof ps))return void t(0);if(e.setCoords(this.getStartXY()),e.mergeNe(this.getEndXY()),e.contains(this.m_cp[0])&&e.contains(this.m_cp[1]))return;const s=Gm(this);if(null!==s){const t=new _s;for(const i of s.specialPoints)this.queryCoord2D(i,t),e.mergeNe(t);return}const i=is($t,8),n=is(_s,4);this.queryControlPoints(n);const r=Ru(n,i),o=new _s;for(let t=1;t<r-1;t++)this.queryCoord2D(i[t].value(),o),e.mergeNe(o)}applyTransformation(e){if(e instanceof cn){const t=is(_s,4);return this.queryControlPoints(t),e.transformPoints(t,4,t),this.setStartXY(t[0]),this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.setEndXY(t[3]),void Zm(this)}t(0)}createInstance(){return new vl({vd:this.m_description})}calculateLength2D(){return Vm(this,1,!1)}calculateLowerLength2D(){return _s.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return _s.distance(this.getStartXY(),this.m_cp[0])+_s.distance(this.m_cp[0],this.m_cp[1])+_s.distance(this.getEndXY(),this.m_cp[1])}calculateUpperLength2D_(){return t(0),0}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DExtends(t,e,s){const i=is(_s,4);this.queryControlPoints(i),hu(i,t,e,s)}queryCoord2DE(t,e){uu(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new _s;return this.queryCoord2DExtends(t,e,!0),e.x}const e=pe(this.getStartX(),this.m_cp[0].x,t),s=pe(this.m_cp[0].x,this.m_cp[1].x,t),i=pe(this.m_cp[1].x,this.getEndX(),t),n=pe(e,s,t),r=pe(s,i,t);return pe(n,r,t)}getCoordY(t){if(t<0||t>1){const e=new _s;return this.queryCoord2DExtends(t,e,!0),e.y}const e=pe(this.getStartY(),this.m_cp[0].y,t),s=pe(this.m_cp[0].y,this.m_cp[1].y,t),i=pe(this.m_cp[1].y,this.getEndY(),t),n=pe(e,s,t),r=pe(s,i,t);return pe(n,r,t)}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=yl.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=yl.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){cu(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&f("Cubic_bezier.cut_bezier_ignore_attributes");const i=is(_s,4);this.queryControlPoints(i);const n=is(_s,4);au(i,t,e,n),s.setControlPoints(n)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&f("Cubic_bezier.split_bezier_ignore_attributes");const i=is(_s,4);this.queryControlPoints(i);const n=is(_s,4),r=is(_s,4);ou(i,t,n,r),e&&e.setControlPoints(n),s&&s.setControlPoints(r)}getAttributeAsDbl(e,s,i){return t(0),0}getClosestCoordinate(t,e){const s=[Number.NaN];return Tu(this,t,Qt.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s){const i=[Number.NaN];return 0===Tu(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(e,s=!1){return t(0),0}getMonotonicParts(e,s){e.length<2&&f("");const i=km(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let n=0;t(e.length>=i.specialPointsCount()-1);for(let t=1,r=i.specialPointsCount();t<r;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[n],s),n++;for(let t=0;t<n;++t){su(e[t].get())}return n}intersectionWithAxis2D(t,e,s,i){const n=is(_s,4);return this.queryControlPoints(n),Fu(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(e,s){if(this.m_YStart===this.m_YEnd)return e===this.m_YStart?s:Number.NaN;if(e===this.m_YStart)return this.m_XStart;if(e===this.m_YEnd)return this.m_XEnd;const i=[0,0],n=this.intersectionWithAxis2D(!0,e,i,null);return t(2!==n),-1===n?s:i[0]}isCurve(){return!0}isDegenerate(t){return qi(this,t)}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(e){if(e instanceof ps)return e.setCoords({pt:this.getStartXY()}),e.mergeNe(this.m_cp[0]),e.mergeNe(this.m_cp[1]),void e.mergeNe(this.getEndXY());t(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=ps.constructEmpty();this.queryEnvelope(t);const s=Qt.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=is(_s,4);this.queryControlPoints(s),au(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Vm(this,t,!0)}lengthToT(t){return Bm(this,t)}calculateWeightedAreaCentroid2D(e){return t(0),_s.getNAN()}calculateWeightedCentroid2D(){return t(0),_s.getNAN()}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&f("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=is(_s,4);return this.queryControlPoints(e),lu(e,t)}getDerivative(e){return t(0),_s.getNAN()}getCurvature(t){const e=tu(this,1,t),s=tu(this,2,t),i=e.sqrLength();if(0===i)return Number.NaN;e.divThis(Math.sqrt(i));return e.crossProduct(s)/i}isIntersectingPoint(e,s,i){return t(0),!1}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}queryAttributeAsDbl(e,s,i,n){t(0)}isMonotoneQuickAndDirty(){const t=is(_s,4);return this.queryControlPoints(t),nu(t)}getMonotonicPartParams(e,s){const i=km(this),n=i.specialPointsCount();if(t(Hn.s_maxMonotonicPartParams>=n),!s)return i.specialPointsCount();e<n&&f("");for(let t=0;t<n;t++)s[t]=i.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=je(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=je(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=je(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=je(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new $t;return Um(this,t),t.value()}queryConvexHull2D(e){return t(0),0}isLine(){return!1}isDegenerateToLineHelper(e){return t(0),!1}copyIgnoreAttributes(t){const e=is(_s,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return eu(this)}absNorm(){return Iu(this)}queryEnvelopeW(t,e){Du(this,t,e)}setSegmentFromCoords(t,e){Mu(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=is(_s,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=is(_s,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(_s.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);_s.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=is(_s,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(_s.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);_s.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return Xu(this,t,e)}ensureXYMonotone(){return su(this)}setCoordsForIntersector(t,e,s){Hm(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Wm(e,Gm(this))}reverseImpl(){this.m_cp[1]=je(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t,s=0,i=1;return!!this.m_cp[0].equals(e.m_cp[s])&&!!this.m_cp[1].equals(e.m_cp[i])}equalsImplTol(t,e){const s=t,i=0,n=1;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[i],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[n],e)}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){Zm(this)}isIntersecting(t,e,s){return 0!==ol(!1,this,t,e,s)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return Cu(this,t,e,s)}intersect_(e,s,i,n){return t(0),0}endPointModified(){Zm(this)}clearEndPointModified(){t(0)}}vl.type=r.enumBezier;export{ol as $,Er as A,ti as B,vl as C,l as D,Cs as E,f as F,r as G,Ju as H,Ou as I,$s as J,li as K,fl as L,dn as M,ii as N,T as O,Ci as P,lo as Q,ui as R,xl as S,cn as T,Zs as U,Ws as V,oi as W,ai as X,Fs as Y,Hs as Z,si as _,Ur as a,_i as a$,Rs as a0,Ft as a1,hi as a2,Ee as a3,U as a4,Wu as a5,Vs as a6,ei as a7,a as a8,mi as a9,ul as aA,D as aB,Ds as aC,y as aD,$u as aE,os as aF,$e as aG,rs as aH,hl as aI,ml as aJ,K as aK,_l as aL,ss as aM,lt as aN,ct as aO,Pt as aP,ut as aQ,A as aR,x as aS,qn as aT,ni as aU,w as aV,pi as aW,gr as aX,_r as aY,fi as aZ,ci as a_,Qs as aa,as as ab,_ as ac,je as ad,q as ae,ks as af,Xs as ag,h as ah,ve as ai,es as aj,Ku as ak,al,Ue as am,uo as an,to as ao,pe as ap,Dh as aq,xm as ar,Hn as as,m as at,Gs as au,M as av,mt as aw,Yt as ax,Q as ay,tr as az,cr as b,gi as b0,di as b1,Nn as c,Mn as d,N as e,c as f,u as g,Dt as h,$ as i,ps as j,_s as k,t as l,is as m,Qt as n,go as o,jr as p,P as q,hu as r,wm as s,E as t,ye as u,su as v,iu as w,Ko as x,pm as y,ih as z};
5
+ function t(t,e){try{if(!t)throw new Error(e)}catch(s){throw s}}class e extends Error{constructor(t,e){super(),this.m_AdditionalMessage=e,this.m_ErrorType=t}what(){return t(0),""}additionalMessage(){return t(0),""}code(){return t(0),1}}class s extends e{constructor(t){super(2,t),this.name="corrupted geometry exception"}}class i extends e{constructor(t){super(3,t),this.name="empty gemetry exception"}}class n extends e{constructor(t){super(8,t),this.name="non simple geometry exception"}}var r;!function(t){t[t.enumUnknown=0]="enumUnknown",t[t.enumPoint=513]="enumPoint",t[t.enumLine=5122]="enumLine",t[t.enumBezier=5123]="enumBezier",t[t.enumEllipticArc=5124]="enumEllipticArc",t[t.enumEnvelope=3077]="enumEnvelope",t[t.enumMultiPoint=8710]="enumMultiPoint",t[t.enumPolyline=25607]="enumPolyline",t[t.enumPolygon=27656]="enumPolygon",t[t.enumMultipatch=40969]="enumMultipatch",t[t.enumGeometryCollection=3594]="enumGeometryCollection",t[t.enumRationalBezier2=5134]="enumRationalBezier2",t[t.enumBezier2=5135]="enumBezier2"}(r||(r={}));const o=[0,0,1,1,1,2,0,1,2,3,-1,-1,-1,-1,1,1];function a(t){return o[15&t]}function h(t){return!!(512&t)}function m(t){return!!(1024&t)}function u(t){return!!(4096&t)}function l(t){return!!(8192&t)}function c(t){return!!(16384&t)}function d(t){return!!(32768&t)}function _(t){const e=t.getGeometryType();return l(e)?t.getPointCount():t.isEmpty()?0:e===r.enumEnvelope?4:e===r.enumPoint?1:u(e)?2:void E("missing type")}function g(t){const e=t.getGeometryType();if(c(e))return t.hasNonLinearSegments();if(e===r.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)if(g(e.getGeometry(t)))return!0;return!1}return!!u(e)&&e!==r.enumLine}function p(t){throw new s(t)}function f(t){const e=new Error(t);throw e.name="invalid argument exception",e}function x(){f("Geometry type is not supported for 3D topological operations.")}function y(t){throw new e(12,t)}function v(t){throw new i(t)}function P(t){const s=new e(14,t);throw s.name="not implemented",s}function b(t){const e=new Error(t);throw e.name="out of range exception",e}function E(t){const s=new e(13,t);throw s.name="internal error",s}function C(t){const e=new Error(t);throw e.name="logic error exception",e}function D(t){throw new n(t)}function S(){P("operation does not support curves yet")}function w(t){g(t)&&S()}function A(t){d(t.getGeometryType())&&P("Unsupported geometry type.")}function T(t){t===r.enumGeometryCollection&&f("Geometry_collection instances are not supported in this operation")}function I(t){f(`bad wkid: ${t}`)}function N(t,e){t||f(e)}class M{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new M(this.tolerance+t,this.resolution)}scale(t){return new M(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function q(t,e){return{first:t,second:e}}const R=Math.PI,F=2*Math.PI,Y=.5*Math.PI,X=new ArrayBuffer(8),L=new Float64Array(X),z=new BigUint64Array(X),V=0x0fffffffffffffn,B=0x7ff0000000000000n;function k(t){return L[0]=t,z[0]}function G(t){return k(t)&V}function W(t){return Number((k(t)&B)>>52n)}function Z(t){if(0n===t)return-1n;if(1n===t||-1n===t)return 0n;t<0n&&(t=-t);let e=0n,s=512n,i=1n<<e+s;for(;t>=i;)e+=s,s<<=1n,i<<=s;let n=e;s>>=1n;let r=n+s;for(;s>0n;)t<1n<<r||(n=r),s>>=1n,r=n+s;return n}function H(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function O(t,e,s){return t===e||Math.abs(t-e)<=s||Number.isNaN(t)&&Number.isNaN(e)}function j(t,e){return t<e?-1:t>e?1:0}function U(t,e){if(t<e)return-1;if(t>e)return 1;if(t===e)return 0;{const s=Number.isNaN(t),i=Number.isNaN(e);return s<i?-1:s>i?1:0}}function Q(){return 2147483647}function K(){return 32767}function $(){return 2147483647}const J=$(),tt=BigInt(J),et=2166136261,st=16777619;function it(t){let e=et,s=t;return e=(e^255&s)*st,s>>=8,e=(e^255&s)*st,s>>=8,e=(e^255&s)*st,s>>=8,e=(e^255&s)*st,e&J}const nt=14695981039346656037n,rt=1099511628211n;function ot(t){let e=nt,s=t;return e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,s>>=8n,e=(e^0xffn&s)*rt,e&tt}function at(t){return 1103515245*t+12345&2147483647}function ht(t,e){return e+2654435769+(t<<6)+(t>>2)&J}function mt(t,e){return ht(t,dt(e))}function ut(t){return ht(3735928559,t)}function lt(t,e){return ht(t,ut(e))}function ct(t){return it(t)}function dt(t){return Number(ot(t))}function _t(t){return at(t)}const gt=100;function pt(){return Number.EPSILON*gt}function ft(){return.38196601125010515}function xt(){return 1.4142135623730951}function yt(){return Number.EPSILON}function vt(t,e,s){return t===e||t===s}function Pt(t,e,s){return t>=e?t<=s?t:s:e}function bt(t,e){return t>=e?e:t<-e?-e:t}function Et(){return R}function Ct(){return F}function Dt(){return Y}const St=3*Dt();function wt(){return St}class At{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(){t(0)}add(t){const e=this.sum+t;let s;if(Math.abs(this.sum)>=Math.abs(t)){const i=this.sum-e+t;s=this.compensation+i}else{const i=t-e+this.sum;s=this.compensation+i}this.sum=e,this.compensation=s}sub(t){this.add(-t)}addProduct(t,e){const s=[0],i=Ee(t,e,s);this.add(i),this.add(s[0])}addKahan(e){t(0)}subKahan(e){t(0)}mulKahan(e){t(0)}mul(t){const e=new At(0);e.addProduct(this.sum,t),e.addProduct(this.compensation,t),this.assign(e)}getResult(){return this.sum+this.compensation}pe(t){return this.add(t),this}me(t){return this.add(-t),this}meKahan(t){return this.subKahan(t),this}peKahan(t){return this.addKahan(t),this}}const Tt=0x00000000ffffffffn,It=0x0000ffffn,Nt=0x000000ffn,Mt=0x0fn,qt=0xffff0000n,Rt=0xff00n,Ft=0xf0n,Yt=[5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1],Xt=[-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3];function Lt(t){let e=0;return t&It||(e+=16,t>>=16n),t&Nt||(e+=8,t>>=8n),t&Mt||(e+=4,t>>=4n),e+Yt[Number(BigInt.asUintN(4,t))]}function zt(t){let e=0;return t&qt&&(e+=16,t>>=16n),t&Rt&&(e+=8,t>>=8n),t&Ft&&(e+=4,t>>=4n),e+Xt[Number(BigInt.asUintN(4,t))]+1}function Vt(t){let e=0;return t&Tt||(e=32,t>>=32n),e+Lt(BigInt.asUintN(32,t))}function Bt(t){let e=0;return 0xffffffff00000000n&t&&(e=32,t>>=32n),e+zt(t)}class kt{constructor(t,e){if(void 0!==t){if(t instanceof kt)return this.vmin=t.vmin,void(this.vmax=t.vmax);this.vmin=t,this.vmax=e,this.normalize()}else this.setEmpty()}static construct(t,e){return new kt(t,e)}static constructEmpty(){return new kt}setCoords(t,e){this.vmin=t,this.vmax=e,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,e){return H(this.vmin,t)&&H(this.vmax,e)}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(void 0!==e?Math.abs(this.vmin-t.vmin)<=e&&Math.abs(this.vmax-t.vmax)<=e: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 t(0),!0}setInfinite(){this.vmin=Number.NEGATIVE_INFINITY,this.vmax=Number.POSITIVE_INFINITY}move(e){t(0)}contains(t){return t.vmin>=this.vmin&&t.vmax<=this.vmax}containsCoordinate(t){return t>=this.vmin&&t<=this.vmax}containsRightExclusive(e){return t(0),!0}containsExclusiveCoordinate(t){return t>this.vmin&&t<this.vmax}containsExclusive(e){return t(0),!0}isIntersecting(e){return t(0),!0}mergeCoordinate(t){if(this.isEmpty())return this.vmin=t,void(this.vmax=t);this.mergeNeCoordinate(t)}merge(t){if(t.isEmpty())return;const e=t.vmin,s=t.vmax;this.mergeCoordinate(e),this.mergeCoordinate(s)}mergeNe(t){const e=t.vmin,s=t.vmax;this.mergeNeCoordinate(e),this.mergeNeCoordinate(s)}mergeNeCoordinate(t){t<this.vmin?this.vmin=t:t>this.vmax&&(this.vmax=t)}intersect(e){t(0)}inflate(e){t(0)}normalize(){this.vmin<=this.vmax||(this.vmin>this.vmax?this.vmax=Ve(this.vmin,this.vmin=this.vmax):this.setEmpty())}isValid(){return t(0),!0}snapClip(t){return Pt(t,this.vmin,this.vmax)}calculateToleranceFromEnvelope(){return t(0),0}static unit(){return Gt}normalizeNoNAN(){this.vmin>this.vmax&&(this.vmax=Ve(this.vmin,this.vmin=this.vmax))}setCoordsNoNAN(t,e){this.vmin=t,this.vmax=e,this.normalizeNoNAN()}clone(){return new kt(this.vmin,this.vmax)}}const Gt=new kt(0,1);class Wt{static ulp(t){return Math.abs(t)*Ot()}static getNAN(){return new Wt(Number.NaN)}constructor(t,e){this.m_value=t??0,this.m_eps=e??0}[Symbol.toPrimitive](t){return this}clone(){return new Wt(this.m_value,this.m_eps)}scaleError(t){this.m_eps*=t}setError(t){this.m_eps=t}set(t,e){return this.m_value=t,this.m_eps=e??0,this}setWithEps(t,e){return void 0===e&&(e=1),this.m_value=t,this.m_eps=Wt.ulp(t)*e,this}setE(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}precise(){return new Wt(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 e=this.m_value+t.m_value,s=this.m_eps+t.m_eps+Wt.ulp(e);return this.m_value=e,this.m_eps=s,this}addThis(t){const e=this.m_value+t,s=this.m_eps+Wt.ulp(e);return this.m_value=e,this.m_eps=s,this}subE(t){return this.clone().subThisE(t)}sub(t){return this.clone().subThis(t)}subThisE(t){const e=this.m_value-t.m_value,s=this.m_eps+t.m_eps+Wt.ulp(e);return this.m_value=e,this.m_eps=s,this}subThis(t){const e=this.m_value-t,s=this.m_eps+Wt.ulp(e);return this.m_value=e,this.m_eps=s,this}setAddE(t,e){return this.m_value=t.m_value+e.m_value,this.m_eps=t.m_eps+e.m_eps+Wt.ulp(this.m_value),this}setAdd(t,e){return this.m_value=t+e,this.m_eps=Wt.ulp(this.m_value),this}setAddEN(t,e){return this.m_value=t.m_value+e,this.m_eps=t.m_eps+Wt.ulp(this.m_value),this}setAddNE(t,e){return this.m_value=t+e.m_value,this.m_eps=e.m_eps+Wt.ulp(this.m_value),this}setSubE(t,e){return this.m_value=t.m_value-e.m_value,this.m_eps=t.m_eps+e.m_eps+Wt.ulp(this.m_value),this}setSub(t,e){return this.m_value=t-e,this.m_eps=Wt.ulp(this.m_value),this}setSubEN(t,e){return this.m_value=t.m_value-e,this.m_eps=t.m_eps+Wt.ulp(this.m_value),this}setSubNE(t,e){return this.m_value=t-e.m_value,this.m_eps=e.m_eps+Wt.ulp(this.m_value),this}mulThisE(t){const e=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+Wt.ulp(e),this.m_value=e,this}mulThis(t){const e=this.m_value*t;return this.m_eps=this.m_eps*Math.abs(t)+Wt.ulp(e),this.m_value=e,this}mul(t){return this.clone().mulThis(t)}mulE(t){return this.clone().mulThisE(t)}setMulE(t,e){const s=t.m_value*e.m_value;return this.m_eps=t.m_eps*Math.abs(e.m_value)+e.m_eps*Math.abs(t.m_value)+t.m_eps*e.m_eps+Wt.ulp(s),this.m_value=s,this}setMul(t,e){return this.m_value=t*e,this.m_eps=Wt.ulp(this.m_value),this}setMulEN(t,e){return this.setE(t),this.mulThis(e)}setMulNE(t,e){return this.setE(e),this.mulThis(t)}mulThisByPower2(t){return this.m_value*=t,this.m_eps*=Math.abs(t),this}static st_mulByPower2(t,e){return new Wt(t.m_value,t.m_eps).mulThisByPower2(e)}divE(t){return this.clone().divThisE(t)}divThisE(t){const e=Math.abs(t.m_value),s=this.m_value/t.m_value;let i=(this.m_eps+Math.abs(s)*t.m_eps)/e;if(t.m_eps>.01*e){const s=t.m_eps/e;i*=1+(1+s)*s}return this.m_value=s,this.m_eps=i+Wt.ulp(s),this}divThis(t){const e=Math.abs(t);return this.m_value/=t,this.m_eps=this.m_eps/e+Wt.ulp(this.m_value),this}setDivE(t,e){return this.setE(t),this.divThisE(e)}setDiv(t,e){return this.m_value=t/e,this.m_eps=Wt.ulp(this.m_value),this}setDivEN(t,e){return this.setE(t),this.divThis(e)}setDivNE(t,e){return this.set(t),this.divThisE(e)}divThisByPower2(t){return this.m_value/=t,this.m_eps/=Math.abs(t),this}invThis(){return this.setE(Qt.clone().divThisE(this)),this}sqrt(){return this.clone().sqrtThis()}sqrtThis(){let t,e;return this.m_value>=0?(t=Math.sqrt(this.m_value),e=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),e+=Wt.ulp(t)):this.m_value<-this.m_eps?(t=Number.NaN,e=Number.NaN):(t=0,e=Math.sqrt(this.m_eps)),this.m_value=t,this.m_eps=e,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+Wt.ulp(t),this.m_value=t,this}cubeThis(){return t(0),this}setSin(e){return t(0),this}setCos(e){return t(0),this}static st_cosAndSin(t,e,s){const i=Math.sin(t.m_value),n=Math.cos(t.m_value);s.m_value=i,e.m_value=n;const r=Math.abs(i),o=Math.abs(n),a=Math.abs(t.value());s.m_eps=(Math.abs(n)+.5*r*t.m_eps)*t.m_eps+Wt.ulp(r+a),e.m_eps=(Math.abs(i)+.5*o*t.m_eps)*t.m_eps+Wt.ulp(o+a)}setLog(e){return t(0),this}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}static atan2(e,s){return t(0),new Wt}acosThis(){return t(0),this}asinThis(){return t(0),this}isInInterval(t){return kt.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,e){return Math.abs(this.m_value-t.m_value)<=e||this.eq(t)}tolNE(t,e){return!this.tolEQ(t,e)}tolGT(t,e){return this.m_value-t.m_value>e&&this.gt(t)}tolLT(t,e){return t.m_value-this.m_value>e&&this.lt(t)}tolGE(t,e){return!this.tolLT(t,e)}tolLE(t,e){return!this.tolGT(t,e)}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(jt)}setEuler(){this.set(2.718281828459045,Ot())}cubicRootThis(){return t(0),this}powerThis(e){return t(0),this}setPower(t,e){return this.setE(t),this.powerThis(e)}static size(){return 1}}function Zt(t,e){const s=G(t),i=G(e),n=53-Vt(s),r=53-Vt(i);return(n>=0?n:0)+(r>=0?r:0)<=52}function Ht(t,e){const s=t-e;return t-s===e&&e+s===t}function Ot(){return yt()}Wt.dimensions=1;const jt=new Wt(R,.5*Ot()),Ut=new Wt(0,0),Qt=new Wt(1,0),Kt=new Wt(4,0);function $t(t,e,s){return t.addE(e.subE(t).mulE(s))}function Jt(t,e,s){return e.subE(e.subE(t).mulE(Qt.subE(s)))}function te(t){return Math.round(t)}function ee(t,e,s,i,n){n[0]=e[0]+(s[0]-e[0])*i,n[1]=e[1]+(s[1]-e[1])*i,3===t&&(n[2]=e[2]+(s[2]-e[2])*i)}function se(t,e,s,i,n){n[0]=s[0]-(s[0]-e[0])*(1-i),n[1]=s[1]-(s[1]-e[1])*(1-i),3===t&&(n[2]=s[2]-(s[2]-e[2])*(1-i))}function ie(t,e,s,i,n){i<=.5?ee(t,e,s,i,n):se(t,e,s,i,n)}function ne(t,e,s,i){i.setE(t.addE(e.subE(t).mulE(s)))}function re(t,e,s,i){i.setE(e.subE(e.mulE(t)).mulE(Qt.subE(s)))}function oe(t,e,s,i,n){n[0]=e[0].addE(s[0].subE(e[0]).mulE(i)),n[1]=e[1].addE(s[1].subE(e[1]).mulE(i))}function ae(t,e,s,i,n){n[0]=s[0].subE(s[0].subE(e[0]).mulE(Qt.subE(i))),n[1]=s[1].subE(s[1].subE(e[1]).mulE(Qt.subE(i)))}function he(t,e,s){let i;return i=s<=.5?t+(e-t)*s:e-(e-t)*(1-s),i}function me(t,e,s){return t+(e-t)*s}function ue(t,e,s){return e-(e-t)*(1-s)}function le(t,e,s,i){s<=.5?(i.x=t.x+(e.x-t.x)*s,i.y=t.y+(e.y-t.y)*s):(i.x=e.x-(e.x-t.x)*(1-s),i.y=e.y-(e.y-t.y)*(1-s))}function ce(t){return t*t}function de(t){return t*t*t}function _e(t){return 1/Math.sqrt(t)}function ge(t){return t<0?-1:t>0?1:0}const pe=[0],fe=[0];function xe(t,e,s){return we(Ee(t,e,pe),s,pe[0],fe)}const ye=[0],ve=[0],Pe=[0],be=[0];function Ee(t,e,s){const i=t*e;return Ce(t,ye,ve),Ce(e,Pe,be),s[0]=ve[0]*be[0]-(i-ye[0]*Pe[0]-ve[0]*Pe[0]-ye[0]*be[0]),i}function Ce(t,e,s){const i=134217729*t;e[0]=i-(i-t),s[0]=t-e[0]}const De=[0],Se=[0];function we(t,e,s,i){const n=Ae(t,e,De),r=Ae(n,s,Se);return Ae(r,De[0]+Se[0],i)}function Ae(t,e,s){const i=t+e;return Math.abs(t)>Math.abs(e)?s[0]=t-i+e:s[0]=e-i+t,i}function Te(t,e){return t%e}function Ie(t){const e=1-t;if(0===e)return 1;let s;if(e<=.01){const t=e,i=Math.log(t);s=1+t*(.4431471805599453-.25*i+t*(.05680519270997949-.09375*i+t*(.02183137044373718-.05859375*i+t*(.011544521417308362-.042724609375*i+t*(.00714200031339596-.0336456298828125*i+t*(.004854743337164948-.027757644653320312*i+t*(.003514687963781376-.023627042770385742*i)))))))}else{if(t<.016){const e=t,s=.25,i=.046875,n=.01953125,r=.01068115234375,o=.0067291259765625,a=.004626274108886719,h=.0033752918243408203,m=.0025710230693221092;return Dt()*(1-e*(s+e*(i+e*(n+e*(r+e*(o+e*(a+e*(h+e*m))))))))}s=qe(0,e,1)-t*Re(0,e,1)/3}return Pt(s,1,Dt())}function Ne(e,s,i){if(t(s>=0&&s<=1),0===s)return e;let n=1,r=e;if(r<0&&(r=-r,n=-1),1===s){const t=Math.round(r/Et()),e=r-t*Et();return n*(2*t+Math.sin(e))}const o=Dt(),a=Math.floor(r/o);1&a?r=(a+1)*o-r:r-=a*o;const h=Math.sin(r),m=Number.isNaN(i)?Ie(s):i;let u;if(1===h)u=m+Math.sqrt(1-s)*(r-o);else{const t=r*r;if(.01424*Math.pow(t,4)<=2*yt()){u=r*(1+t*s*(-1/6+t*((4-3*s)/120-(16+(45*s-60)*s)/5040*t)))}else if(s<=.01){const t=Math.sin(2*r),e=Math.sin(4*r),i=Math.sin(6*r),n=Math.sin(8*r),o=Math.sin(10*r);u=r+s*((2*-r+t)/8+s*((-3*r+2*t-.25*e)/64+s*((-20*r+15*t-3*e+i/3)/1024+s*(5*(-140*r+112*t-28*e+16/3*i-.5*n)/65536+7*s*((-63*r+52.5*t-15*e+3.75*i-.625*n+.05*o)/65536+s*(-693*r+594*t-185.625*e+1.375*i-12.375*n+1.8*o-.125*Math.sin(12*r))/1048576)))))}else{const t=h*h,e=Math.cos(r),i=e*e,n=Fe(h,e,s);u=h*(qe(i,n,1)-s*t*Re(i,n,1)/3)}}if(1&a){u=m*(a+1)-u}else u+=m*a;return n*u}function Me(t,e,s){if(0===t)return 0;let i=1,n=t;t<0&&(n=-n,i=-1);const r=Number.isNaN(s)?Ie(e):s,o=Math.floor(n/r);1&o?n=(o+1)*r-n:n-=o*r;let a=n<=0?0:n>=r?Dt():Ye(n,e,r);return 1&o?a=Dt()*(o+1)-a:a+=Dt()*o,i*a}function qe(e,s,i){t((0!==e?1:0)+(0!==s?1:0)+1>1);let n=e,r=s,o=i;for(;;){const t=Math.sqrt(n*r)+Math.sqrt(r*o)+Math.sqrt(o*n);n=.25*(n+t),r=.25*(r+t),o=.25*(o+t);const e=(n+r+o)/3,s=(e-n)/e,i=(e-r)/e,a=(e-o)/e;if(Math.abs(s)<=.0024&&Math.abs(i)<=.0024&&Math.abs(a)<=.0024){const t=s*i-a*a,n=s*i*a;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(e)}}}function Re(e,s,i){t(0!==e||0!==s);let n=e,r=s,o=i;const a=new At(0);let h=1;for(;;){const t=.2*(n+r+3*o),e=(t-n)/t,s=(t-r)/t,i=(t-o)/t;if(Math.abs(e)<=.0015&&Math.abs(s)<=.0015&&Math.abs(i)<=.0015){const n=e*s,r=i*i,o=n-r,m=n-6*r,u=m+o+o,l=9/22,c=3/26,d=m*(.25*l*m-3/14-1.5*c*i*u),_=i*(1/6*u+i*(-l*o+i*c*n));return 3*a.getResult()+h*(1+d+_)/(t*Math.sqrt(t))}const m=Math.sqrt(n),u=Math.sqrt(r),l=Math.sqrt(o),c=m*(u+l)+u*l;a.add(h/(l*(o+c))),h*=.25,n=.25*(n+c),r=.25*(r+c),o=.25*(o+c)}}function Fe(t,e,s){return t<.999?1-s*ce(t):1-s+s*ce(e)}function Ye(t,e,s){if(0===e)return t;if(1===e)return Math.asin(t);let i=0,n=!0;if(t<.2){const s=t*t,r=t*(1+s*e*(1/6+s*((13*e-4)/120+(16-284*e+493*e*e)/5040*s))),o=Math.abs(e*(4944*e-64-31224*e*e+37369*e*e*e)/362880*Math.pow(t,9));if(o<Math.abs(r)*yt())return r;i=r,n=o>.1*r}if(n){const n=1-e,r=1-t/s,o=Math.sqrt(r*r+n*n),a=Math.atan2(n,t+yt());i=Dt()+Math.sqrt(o)*(a-Dt())}let r=0;for(let o=0;o<7;o++){r=Ne(i,e,s);const n=Fe(Math.sin(i),Math.cos(i),e);if(i-=(r-t)/Math.sqrt(n),o>0&&Math.abs(r-t)<=4*yt()*t)break}return i}function Xe(t,e,s,i,n){return 0===t?0===i?e:1===i?s:n:1===t?0===i?e:1===i?s:he(e,s,i):(2===t&&P("angular interpolation"),void P(""))}function Le(t,e,s,i,n,r,o,a){if(0===t)for(let h=0;h<r;++h)i[h]=0===o?e[h]:1===o?s[h]:a;else if(1===t)if(0===o)ze(i,e,n,0,r);else if(1===o)ze(i,s,n,0,r);else for(let h=0;h<r;++h)i[h+n]=he(e[h],s[h],o);else if(2===t)if(0===o)ze(i,e,n,0,r);else if(1===o)ze(i,s,n,0,r);else{let t=0;for(let a=0,h=n;a<r;++a,++h)i[h]=he(e[a],s[a],o),t+=i[h]*i[h];if(t>0){t=Math.sqrt(t);for(let e=n;e<n+r;++e)i[e]/=t}else{for(let t=n;t<n+r;++t)i[t]=0;i[n]=1}}else P("")}function ze(t,e,s,i,n){if(0===n)return;let r=0,o=s,a=i;for(;r++<n;)t[o++]=e[a++]}function Ve(t,e){return t}function Be(t){t.sort(((t,e)=>t<e?-1:t>e?1:0))}function ke(t,e){const s=t.slice(0,e);Be(s),ze(t,s,0,0,e)}function Ge(t,e,s){const i=t.slice(0,e);i.sort(s),ze(t,i,0,0,e)}function We(t,e){return t<e?-1:t>e?1:0}function Ze(t,e,s,i){return t<s?-1:t>s?1:e<i?-1:e>i?1:0}function He(t,e){if(t.length<2)return t.length;let s=0;for(let i=1;i<t.length;++i)e(t[i],t[s])||(s++,t[i]=Ve(t[s],t[s]=t[i]));return 1+s}function Oe(t,e){t[e]=t.at(-1),t.pop()}function je(t){return{[Symbol.dispose](){this.bForget||t()},bForget:!1}}function Ue(t,e){return Array.from({length:e},(()=>new t))}function Qe(t,e){const s=t.slice(0,e);for(let i=0;i<e;++i)s[i]=s[i].clone();return s}function Ke(t){return Array.from({length:t},(()=>null))}function $e(t,e){return Array.from({length:e},(()=>t()))}function Je(t,e){return Array.from({length:t},(()=>e))}function ts(t){return{v:t}}class es{constructor(){this.m_rn=ts(0n),this.m_rd=ts(1n),this.m_bNaN=!1,this.m_bNormalized=!1,this.m_power=0,this.m_sign=0}static constructAssign(t,e){const s=t.clone();return void 0!==e&&s.limitPrecisionThis(e),s}static constructDouble(t){return(new es).setDouble(t)}static constructInt64(t){return(new es).setInt64(t)}static constructRational(t,e){return(new es).setRational(t,e)}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 es).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(t){if(this.setZero(),0===t)return this;if(Number.isInteger(t)&&Math.abs(t)<$())return this.setInt32(t);const e=k(t),s=(e&es.s_em)>>52n,i=!!(e&es.s_sm),n=e&es.s_fm;if(s===es.s_emax)return n?(this.m_rn.v=this.m_rd.v=0n,this.m_bNaN=!0,this):(this.m_rn.v=i?-1n:1n,this.m_rd.v=0n,this);0n===s&&P("denormalized numbers not yet implemented");const r=s-1023n,o=r>=0n?r:0n,a=r<0n?-r:0n;return this.m_rn.v=(1n<<52n|n)<<o,this.m_rd.v=1n<<52n+a,this.m_sign=i?-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,e){return 0n===t?0n===e?this.setNAN():this.setZero():0n===e?t>0n?this.setPositiveInf():this.setNegativeInf():(this.m_sign=(t>0n?1:-1)*(e>0n?1:-1),this.m_rn.v=t>0n?t:-t,this.m_rd.v=e>0n?e:-e,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(e){return t(0),this}fmsThis(t,e){return this.subThis(t.mul(e))}fmaThis(e,s){return t(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(es.constructDouble(t))}thisMulInt64(e){return t(0),this}thisMulInt32(e){return t(0),this}divThis(t){return this.mulThis(t.clone().invertThis())}divDoubleThis(t){return this.divThis(es.constructDouble(t))}addDoubleThis(t){return this.addThis(es.constructDouble(t))}subDoubleThis(t){return this.subThis(es.constructDouble(t))}mul(t){return this.clone().mulThis(t)}mulBigIntThis(t){return this.mulThis(es.constructInt64(t))}mulDouble(t){return this.clone().mulThis(es.constructDouble(t))}div(t){return this.clone().divThis(t)}divDouble(t){return this.clone().divDoubleThis(t)}add(t){return this.clone().addThis(t)}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(es.constructDouble(t))}sub(t){return this.clone().subThis(t)}subDouble(t){return this.clone().subThis(es.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,e=0xffffffffn;for(;0n===(this.m_rn.v&e)&&e<=this.m_rn.v;)e<<=32n,t+=32;e&=this.m_rn.v,e>>=BigInt(t),t+=Lt(BigInt.asUintN(32,e))-1;let s=0;for(e=0xffffffffn;0n===(this.m_rd.v&e)&&e<=this.m_rd.v;)e<<=32n,s+=32;return e&=this.m_rd.v,e>>=BigInt(s),s+=Lt(BigInt.asUintN(32,e))-1,this.m_rn.v>>=BigInt(t),this.m_rd.v>>=BigInt(s),this.m_power+=t-s,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=Ve(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 e=Number(Z(this.m_rn.v));if(e>t){const s=e-t;this.m_rn.v>>=BigInt(e-t),this.m_power+=s}if(e=Number(Z(this.m_rd.v)),e>t){const s=e-t;this.m_rd.v>>=BigInt(e-t),this.m_power-=s}return this}hiBitIndex(){return Math.max(Number(Z(this.m_rn.v)),Number(Z(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(e,s){if(e.m_sign<0n&&b("MP_value: sqrt(-1)"),e.isZero())return e.clone();let i=52,n=2220446049250313e-31;for(;i<s;)2*i<=s?(n*=n,i*=2):(n*=2220446049250313e-31,i+=52);i+=52;const r=Z(e.m_rn.v),o=Z(e.m_rd.v);let a,h=e.m_power+Number(r-o);const m=new es;Math.abs(h)>200?(1&Math.abs(h)&&(h+=1),a=es.constructAssign(e,53).ldexpThis(-h).value(),m.setThis(e).ldexpThis(-h),t(Number.isFinite(a))):(m.setThis(e),a=m.value(),t(Number.isFinite(a)),h=0),a=Math.sqrt(a);const u=es.constructDouble(a),l=es.constructDouble(n);l.mulThis(u).ldexpThis(1);const c=n*a*2,d=u.clone(),_=new es;let g;for(let t=0;t<10;++t){d.mulThis(u),_.setThis(m).subThis(d).absThis();let t=_.value();if(g=1,t<.9)for(;t>c;)t*=t,++g;else g=4;if(_.lte(l))break;for(let e=0;e<g;e++)d.setThis(u).divThis(m).invertThis().addThis(u).ldexpThis(-1).limitPrecisionThis(i),u.setThis(d)}return u.ldexpThis(h/2)}static cubicRoot(t,e){if(t.isZero())return t.clone();let s=52,i=2220446049250313e-31;for(;s<e;)2*s<=e?(i*=i,s*=2):(i*=2220446049250313e-31,s+=52);s+=52;const n=Math.pow(Math.abs(t.value()),1/3),r=es.constructDouble(n),o=r.clone();o.sqrThis().mulDoubleThis(3).mulDoubleThis(i),o.limitPrecisionThis(32),t.LZ()&&r.negateThis();for(let a=0;a<10;++a){const e=r.clone();e.sqrThis().mulThis(r);const i=e.clone();if(i.subThis(t),i.absThis().limitPrecisionThis(32),i.lte(o))break;i.setThis(t),i.ldexpThis(1),i.addThis(e);const n=e.clone();n.ldexpThis(1),n.addThis(t),i.divThis(n),r.mulThis(i),r.limitPrecisionThis(s)}return r}isInTheRangeOfDouble(){return t(0),!1}sign(){return this.m_sign}cosAndSin(e,s){t(0)}static nan(){return t(0),new es}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,e=this.m_rn.v<<(this.m_power>=0?BigInt(this.m_power):0n);let s=this.m_rd.v<<(this.m_power<0?BigInt(-this.m_power):0n);const i=e/s;let n=Number(i);if(BigInt(n)!==i)return t?-n:n;let r=e-i*s;if(r){let t=Z(s)-1023n;t>0n&&(s>>=t,r<<=52n,r>>=t);let e=Number(r);Number.isFinite(e)||(r>>=52n,e=Number(r),t=0n),t>0n&&(e/=Math.pow(2,52));n+=e/Number(s)}return t?-n:n}signVal(){return 1===this.m_sign?1n:-1===this.m_sign?-1n:0n}opPlusMinus(t,e){const s=Math.min(this.m_power,t.m_power);let i,n;this.m_power>s?(i=BigInt(this.m_power-s),n=0n):(i=0n,n=BigInt(t.m_power-s));const r=this.signVal()*this.m_rn.v*t.m_rd.v<<i,o=t.signVal()*t.m_rn.v*this.m_rd.v<<n;return this.m_rn.v=e?r+o:r-o,this.m_rd.v*=t.m_rd.v,this.m_power=s,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}}es.s_sm=0x8000000000000000n,es.s_em=0x7ff0000000000000n,es.s_fm=0x000fffffffffffffn,es.s_emax=0x7ffn;const ss=es.constructInt32(1),is=es.constructInt32(0);function ns(t,e){return Bt(t^e)}function rs(t,e){let s=W(t);const i=W(e);if(s===i){return s-=53-ns(G(t),G(e)),s}return s>i?s:i}class os{static construct(t,e){return new os(t,e)}constructor(t,e){void 0!==t?(this.x=t,this.y=e):this.x=this.y=Number.NaN}clone(){return new os(this.x,this.y)}assign(t){this.setCoordsPoint2D(t)}setCoords(t,e){return this.x=t,this.y=e,this}setCoordsPoint2D(t){this.x=t.x,this.y=t.y}isEqualPoint2D(t,e){return void 0!==e?Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e:this.x===t.x&&this.y===t.y}isEqual(t,e,s){return void 0!==s?Math.abs(this.x-t)<=s&&Math.abs(this.y-e)<=s:this.x===t&&this.y===e}equalsPoint2D(t,e){return this.isEqualPoint2D(t,e)}setSub(t,e){this.x=t.x-e.x,this.y=t.y-e.y}addThis(t){return this.x+=t.x,this.y+=t.y,this}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this}absoluteOther(t){}absolute(){return t(0),this}setNegate(){this.x=-this.x,this.y=-this.y}setNegateOther(t){this.x=-t.x,this.y=-t.y}interpolateThis(t,e){}interpolate(e,s,i){t(0)}scaleAddThis(t,e){this.x=this.x*t+e.x,this.y=this.y*t+e.y}scaleAddOther(e,s,i){t(0)}scaleOther(e,s){t(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(e){t(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}offset(e,s){return t(0),0}side(e,s){return t(0),0}static sqrDistance(t,e){const s=t.x-e.x,i=t.y-e.y;return s*s+i*i}static sqrDistanceCoords(e,s,i,n){return t(0),0}static distance(t,e){return Math.sqrt(os.sqrDistance(t,e))}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(e){return t(0),0}rotateDirect(t,e){const s=this.x*t-this.y*e,i=this.x*e+this.y*t;this.x=s,this.y=i}rotateReverse(t,e){const s=this.x*t+this.y*e,i=-this.x*e+this.y*t;this.x=s,this.y=i}leftPerpendicularThis(){const t=this.x;this.x=-this.y,this.y=t}leftPerpendicularOther(t){const e=t.x;this.x=-t.y,this.y=e}rightPerpendicularThis(){const t=this.x;this.x=this.y,this.y=-t}rightPerpendicularOther(t){const e=t.x;this.x=t.y,this.y=-e}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 os(this.x+t.x,this.y+t.y)}sub(t){return new os(this.x-t.x,this.y-t.y)}negateThis(){return this.x=-this.x,this.y=-this.y,this}negate(){return new os(-this.x,-this.y)}mul(t){return new os(this.x*t,this.y*t)}mulThis(t){return this.x*=t,this.y*=t,this}divide(t){return new os(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 os(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),e=Math.abs(this.y),s=t-e;return s>=0?t:s<=0?e: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:f("norm")}}getQuarter(){return os.getQuarterCoords(this.x,this.y)}static getQuarterCoords(t,e){return t>0?e>=0?1:4:e>0?2:0===t?4:3}static compareVectors(t,e){const s=t.getQuarter(),i=e.getQuarter();return i===s?os.orientationRobustImpl(os.construct(0,0),e,t,!0):s<i?-1:1}static compareVectorsOrigin(t,e,s){const i=e.sub(t),n=s.sub(t),r=i.getQuarter(),o=n.getQuarter();return o===r?os.orientationRobustImpl(t,s,e,!0):r<o?-1:1}static orientationRobust(t,e,s){return os.orientationRobustImpl(t,e,s,!1)}static orientationNonRobust(t,e,s){const i=e.sub(t).crossProduct(s.sub(t));return i<0?-1:i>0?1:0}static orientationRobustImpl(t,e,s,i){if(e.isEqualPoint2D(t)||s.isEqualPoint2D(t)||e.isEqualPoint2D(s))return 0;const n=e.x-t.x,r=e.y-t.y,o=s.x-t.x,a=s.y-t.y;if(!i){const t=os.getQuarterCoords(n,r)-1,e=os.getQuarterCoords(o,a)-1,s=os.d[t][e];if(0!==s)return s}const h=(Math.abs(n)+Math.abs(r)+Math.abs(o)+Math.abs(a))*(Math.abs(e.x)+Math.abs(e.y)+Math.abs(s.x)+Math.abs(s.y))*8*Ot(),m=n*a-r*o;if(Math.abs(m)>h){return m<0?-1:1}if(Ht(e.x,t.x)&&Ht(s.y,t.y)&&Ht(e.y,t.y)&&Ht(s.x,t.x)&&Zt(n,a)&&Zt(r,o)){const t=n*a,e=r*o;if(Ht(t,e)){const s=t-e;return s<0?-1:s>0?1:0}}return os.orientationRobustMp(t,e,s)}static orientationRobustMp(t,e,s){const i=es.constructDouble(e.x),n=es.constructDouble(s.x);{const e=es.constructDouble(t.x);i.subThis(e),n.subThis(e)}const r=es.constructDouble(s.y),o=es.constructDouble(e.y);{const e=es.constructDouble(t.y);r.subThis(e),o.subThis(e)}return i.mulThis(r),o.mulThis(n),i.subThis(o),i.LZ()?-1:i.GZ()?1:0}static inCircleRobust(e,s,i,n){return t(0),0}static calculateCircleCenterFromThreePoints(e,s,i){return t(0),new os(0,0)}static calculateAngle(t,e){return Math.atan2(t.crossProduct(e),t.dotProduct(e))}static isBisectorRobust(e,s,i){return t(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,e){const s=os.c_compare_zorder_xx[t.x<0?1:0]|os.c_compare_zorder_yy[t.y<0?1:0],i=os.c_compare_zorder_xx[e.x<0?1:0]|os.c_compare_zorder_yy[e.y<0?1:0];if(s===i){let s=0,i=0;for(let n=0;n<2;++n){const r=rs(t[n],e[n]);r>s&&(s=r,i=n)}return t[i]<e[i]}return s<i}static lerp(e,s,i){return t(0),new os(0,0)}static getClosestCoordinate(t,e,s,i=!1){const n=os.getNAN();n.setSub(e,t);const r=n.sqrLength();if(0===r)return.5;if(e.isEqualPoint2D(s))return 1;const o=os.getNAN();o.setSub(s,t);let a=o.dotProduct(n)/r;return i||(a<0?a=0:a>1&&(a=1)),a}static intersectLinesAtOnePoint(e,s,i,n){return t(0),new os(0,0)}toString(){return`[${this.x},${this.y}]`}}os.dimensions=2,os.d=[[0,1,0,-1],[-1,0,1,0],[0,-1,0,1],[1,0,-1,0]],os.c_compare_zorder_xx=[2,0],os.c_compare_zorder_yy=[1,0];class as{static construct(t,e,s,i){return new as(t,e,s,i)}constructor(t,e,s,i){"number"==typeof t?(this.xmin=t,this.ymin=e,this.xmax=s,this.ymax=i):(this.xmin=t.xmin,this.ymin=t.ymin,this.xmax=t.xmax,this.ymax=t.ymax)}static constructEmpty(){return new as(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new as(this)}assign(t){return this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax,this}width(){return this.xmax-this.xmin}height(){return this.ymax-this.ymin}maxDimension(){return Math.max(this.width(),this.height())}minDimension(){return t(0),0}sqrDiagonal(){return t(0),0}diagonal(){return t(0),0}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return os.construct(this.getCenterX(),this.getCenterY())}queryCenter(e){t(0)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){t(0)}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return t(0),!1}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}mergeNeCoords(t,e){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e)}mergeNe(t){this.mergeNeCoords(t.x,t.y)}mergeCoords(t,e){this.isEmpty()?(this.xmin=t,this.ymin=e,this.xmax=t,this.ymax=e):(this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e))}merge(t){this.mergeCoords(t.x,t.y)}mergeEnvelope2D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin),this.mergeNeCoords(t.xmax,t.ymax))}mergePoints(t,e){for(let s=0;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);break}this.setCoords(t[s]),s++}}mergePointsInterleaved(t,e,s){for(let i=2*e,n=i+2*s;i<n;i+=2)this.mergeCoords(t.read(i),t.read(i+1))}inflateCoords(t,e){this.isEmpty()||(this.xmin-=t,this.xmax+=t,this.ymin-=e,this.ymax+=e,(this.xmin>this.xmax||this.ymin>this.ymax)&&this.setEmpty())}getInflatedCoords(e,s){return t(0),new as(0,0,0,0)}inflate(e){t(0)}getInflated(e){return t(0),new as(0,0,0,0)}zoom(e,s){t(0)}scale(e){t(0)}equals(t,e){return!(!this.isEmpty()||!t.isEmpty())||(e?Math.abs(this.xmin-t.xmin)<=e&&Math.abs(this.ymin-t.ymin)<=e&&Math.abs(this.xmax-t.xmax)<=e&&Math.abs(this.ymax-t.ymax)<=e:this.xmin===t.xmin&&this.ymin===t.ymin&&this.xmax===t.xmax&&this.ymax===t.ymax)}setCoords(e){void 0!==e.xmin?(this.xmin=e.xmin,this.xmax=e.xmax,this.ymin=e.ymin,this.ymax=e.ymax):void 0!==e.x?(this.xmin=e.x,this.xmax=e.x,this.ymin=e.y,this.ymax=e.y):void 0!==e.pt1?(this.xmin=e.pt1.x,this.ymin=e.pt1.y,this.xmax=e.pt2.x,this.ymax=e.pt2.y,this.normalize()):void 0!==e.env2D?(this.xmin=e.env2D.xmin,this.xmax=e.env2D.xmax,this.ymin=e.env2D.ymin,this.ymax=e.env2D.ymax,this.normalize()):void 0!==e.pt?(this.xmin=e.pt.x,this.xmax=e.pt.x,this.ymin=e.pt.y,this.ymax=e.pt.y):void 0!==e.center?(this.xmin=e.center.x-.5*e.width,this.xmax=this.xmin+e.width,this.ymin=e.center.y-.5*e.height,this.ymax=this.ymin+e.height,this.normalize()):t(0),this.normalize()}queryIntervalX(t){this.isEmpty()?t.setEmpty():t.setCoords(this.xmin,this.xmax)}queryIntervalY(t){this.isEmpty()?t.setEmpty():t.setCoords(this.ymin,this.ymax)}setFromPoints(t,e){if(0!==e){this.setCoords(t[0]);for(let s=1;s<e;){if(!this.isEmpty()){for(let i=s;i<e;i++)this.mergeNe(t[i]);return}this.setCoords(t[s]),s++}}else this.setEmpty()}normalize(){let t=!1;this.xmin<=this.xmax||([this.xmin,this.xmax]=[this.xmax,this.xmin],t=!0),this.ymin<=this.ymax||([this.ymin,this.ymax]=[this.ymax,this.ymin],t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax||this.setEmpty()}isValid(){return t(0),!1}getLowerLeft(){return new os(this.xmin,this.ymin)}getLowerRight(){return new os(this.xmax,this.ymin)}getUpperLeft(){return new os(this.xmin,this.ymax)}getUpperRight(){return new os(this.xmax,this.ymax)}move(e,s){t(0)}centerAtCoords(e,s){t(0)}centerAt(t){this.centerAtCoords(t.x,t.y)}containsCoords(t,e){return t>=this.xmin&&t<=this.xmax&&e>=this.ymin&&e<=this.ymax}contains(t){return this.containsCoords(t.x,t.y)}containsEnvelope(t){return t.xmin>=this.xmin&&t.xmax<=this.xmax&&t.ymin>=this.ymin&&t.ymax<=this.ymax}containsExclusiveCoords(t,e){return t>this.xmin&&t<this.xmax&&e>this.ymin&&e<this.ymax}containsExclusive(t){return this.containsExclusiveCoords(t.x,t.y)}containsExclusiveEnvelope(t){return t.xmin>this.xmin&&t.xmax<this.xmax&&t.ymin>this.ymin&&t.ymax<this.ymax}isIntersecting(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}isIntersectingNe(t){return(this.xmin<=t.xmin?this.xmax>=t.xmin:t.xmax>=this.xmin)&&(this.ymin<=t.ymin?this.ymax>=t.ymin:t.ymax>=this.ymin)}intersect(t){if(this.isEmpty())return!1;if(t.isEmpty())return this.setEmpty(),!1;t.xmin>this.xmin&&(this.xmin=t.xmin),t.xmax<this.xmax&&(this.xmax=t.xmax),t.ymin>this.ymin&&(this.ymin=t.ymin),t.ymax<this.ymax&&(this.ymax=t.ymax);const e=this.xmin<=this.xmax&&this.ymin<=this.ymax;return e||this.setEmpty(),e}queryCorner(t){switch(3&t){case 0:return new os(this.xmin,this.ymin);case 1:return new os(this.xmin,this.ymax);case 2:return new os(this.xmax,this.ymax);default:return new os(this.xmax,this.ymin)}}queryCorners(e){t(0)}queryCornersReversed(e){t(0)}reaspect(e,s){t(0)}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return t(0),0}clipCode(t){return(t.x<this.xmin?1:0)|(t.x>this.xmax?1:0)<<1|(t.y<this.ymin?1:0)<<2|(t.y>this.ymax?1:0)<<3}clipLine(t,e){let s=this.clipCode(t),i=this.clipCode(e);if(s&i)return 0;if(!(s|i))return 4;const n=(s?1:0)|(i?2:0);do{const n=e.x-t.x,r=e.y-t.y;if(Math.abs(n)>Math.abs(r)?s&as.XMASK?(s&as.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):i&as.XMASK?(i&as.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)):s?(s&as.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):(i&as.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s&as.YMASK?(s&as.YLESSYMIN?(t.x+=n*(this.ymin-t.y)/r,t.y=this.ymin):(t.x+=n*(this.ymax-t.y)/r,t.y=this.ymax),s=this.clipCode(t)):i&as.YMASK?(i&as.YLESSYMIN?(e.x+=n*(this.ymin-e.y)/r,e.y=this.ymin):(e.x+=n*(this.ymax-e.y)/r,e.y=this.ymax),i=this.clipCode(e)):s?(s&as.XLESSXMIN?(t.y+=r*(this.xmin-t.x)/n,t.x=this.xmin):(t.y+=r*(this.xmax-t.x)/n,t.x=this.xmax),s=this.clipCode(t)):(i&as.XLESSXMIN?(e.y+=r*(this.xmin-e.x)/n,e.x=this.xmin):(e.y+=r*(this.xmax-e.x)/n,e.x=this.xmax),i=this.clipCode(e)),s&i)return 0}while(s|i);return n}distanceFromEnvelope(e){return t(0),0}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(e,s,i){return t(0),0}sqrDistance(e,s){if(void 0!==s)return t(0),0;if(this.isEmpty()||e.isNAN())return Number.NaN;let i,n=0,r=0;return i=this.xmin-e.x,i>n&&(n=i),i=this.ymin-e.y,i>r&&(r=i),i=e.x-this.xmax,i>n&&(n=i),i=e.y-this.ymax,i>r&&(r=i),n*n+r*r}sqrMaxMinDistanceEnvelope(e){return t(0),0}sqrMaxDistanceEnvelope(e){return t(0),0}sqrMaxMinDistance(e){return t(0),0}sqrMinDistance(e){return t(0),0}sqrMaxDistance(e){return t(0),0}snapToBoundary(e){return t(0),!1}snapClip(t){const e=Pt(t.x,this.xmin,this.xmax),s=Pt(t.y,this.ymin,this.ymax);return os.construct(e,s)}boundaryDistance(e){return t(0),0}envelopeSide(e){return t(0),0}querySide(t,e){switch(t){case 0:e.constructFromCoords(this.xmin,this.ymin,this.xmin,this.ymax);break;case 1:e.constructFromCoords(this.xmin,this.ymax,this.xmax,this.ymax);break;case 2:e.constructFromCoords(this.xmax,this.ymax,this.xmax,this.ymin);break;case 3:e.constructFromCoords(this.xmax,this.ymin,this.xmin,this.ymin);break;default:f("query_side")}return e}isPointOnBoundary(e,s){return t(0),!1}calculateToleranceFromEnvelope(){if(this.isEmpty())return pt();return(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*pt()}notEquals(e){return t(0),!1}toString(){return t(0),""}}as.XLESSXMIN=1,as.YLESSYMIN=4,as.XMASK=3,as.YMASK=12;const hs=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0],ms=[2,1,1,1,3,1,2,3,2,4,1,1,2],us=[1,1,1,0,2,1,1,1,0,0,0,0,0],ls=[1,1,1,2,0,0,0,0,2,2,4,2,2],cs=[4,8,4,8,1],ds=24;function _s(){return new Array(24)}let gs=class t{getAttributeCount(){return this.m_attributeCount}getSemantics(t){return this.m_indexToSemantics[t]}getSemanticsBitArray(){return this.m_semanticsBitArray}getAttributeIndex(t){return this.m_semanticsToIndexMap[t]}static getInterpolation(t){return us[t]}static getPersistence(t){return ls[t]}static getPersistenceSize(t){return cs[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return ms[t]}static maxComponentCount(){return 4}static isInteger(t){return 2===t||3===t||4===t}static isIntegerSemantics(e){return t.isInteger(t.getPersistence(e))}static isTexture(t){return 5===t||6===t||7===t}hasAttribute(t){return!!(this.m_semanticsBitArray&1<<t)}hasAttributesFrom(t){return(this.m_semanticsBitArray&t.m_semanticsBitArray)===t.m_semanticsBitArray}hasZ(){return this.hasAttribute(1)}hasM(){return this.hasAttribute(2)}hasID(){return this.hasAttribute(3)}getTotalComponentCount(){return this.m_totalComponentCount}static getDefaultValue(t){return hs[t]}static isDefaultValue(t,e){return H(hs[t],e)}equals(t){return this===t}getDefaultPointAttributes(){return this.m_defaultPointAttributes}getPointAttributeOffset(t){return this.m_pointAttributeOffsets[t]}constructor(e){this.m_semanticsBitArray=e,this.m_attributeCount=0,this.m_totalComponentCount=0,this.m_semanticsToIndexMap=new Int32Array(13),this.m_indexToSemantics=new Int32Array(13),this.m_pointAttributeOffsets=new Int32Array(13),this.m_defaultPointAttributes=new Array(ds),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,n=13;for(;s<n;s++)e&i&&(this.m_semanticsToIndexMap[s]=this.m_attributeCount,this.m_indexToSemantics[this.m_attributeCount]=s,this.m_attributeCount++,this.m_totalComponentCount+=t.getComponentCount(s)),i<<=1;let r=0;for(s=0,n=this.getAttributeCount();s<n;s++){const e=this.getSemantics(s),i=t.getComponentCount(e),n=t.getDefaultValue(e);this.m_pointAttributeOffsets[s]=r;for(let t=0;t<i;t++)this.m_defaultPointAttributes[r]=n,r++}}};class ps{static construct(t,e,s){return new ps(t,e,s)}constructor(t,e,s){void 0!==t?(this.x=t,this.y=e,this.z=s):this.x=this.y=this.z=Number.NaN}get 0(){return this.x}get 1(){return this.y}get 2(){return this.z}set 0(t){this.x=t}set 1(t){this.y=t}set 2(t){this.z=t}clone(){return new ps(this.x,this.y,this.z)}assign(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}setCoords(t,e,s){return this.x=t,this.y=e,this.z=s,this}setCoordsPoint2DZ(t,e){return this.setCoords(t.x,t.y,e)}setCoordsPoint3D(t){this.x=t.x,this.y=t.y,this.z=t.z}setZero(){this.x=0,this.y=0,this.z=0}normalize(e){t(0)}normalizeThis(){t(0)}getUnitVector(){return t(0),new ps(0,0,0)}sqrLength(){return t(0),0}length(){return t(0),0}static sqrDistance(e,s){return t(0),0}static sqrDistanceCoords(e,s,i,n,r,o){return t(0),0}static distance(e,s){return t(0),0}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&O(this.z,t.z,e)}static compareByLength(e,s,i,n){return t(0),0}isEqualCoords(e,s,i,n){return t(0),this.x===e&&this.y===s&&this.z===i}isEqualsTols(e,s,i){return t(0),!1}isEqualCoordsTols(e,s,i,n,r){return t(0),!1}static st_isEqual(e,s,i,n){return t(0),!1}equals(e,s){return t(0),!1}equalsTols(e,s,i){return t(0),!1}subThis(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}setSub(t,e){return this.x=t.x-e.x,this.y=t.y-e.y,this.z=t.z-e.z,this}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVectorThis(e,s){return t(0),this}crossProductVector(e){return t(0),new ps(0,0,0)}setScaled(t,e){return this.x=t*e.x,this.y=t*e.y,this.z=t*e.z,this}scaleThis(t){return this.x*=t,this.y*=t,this.z*=t,this}setNAN(){return t(0),this}isNAN(){return t(0),!1}static getNAN(){return ps.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return t(0),!1}isZero(){return t(0),!1}sqrDistanceFromCenterToSpheroidSurface(e,s){return t(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(e,s,i,n=!1){return t(0),0}compare(e){return t(0),0}compareXYZ(e){return t(0),0}static size(){return ps.dimensions}static lerp(e,s,i){return t(0),{}}static slerp(e,s,i){return t(0),{}}static compareVectors(e,s){return t(0),0}static selectRightHandedBasisFromNormal(e,s,i){t(0)}createAPerpendicular(){return t(0),{}}calculateAngle(e){return t(0),0}}ps.dimensions=3;var fs=gs;function xs(){return new Array(13)}class ys{static getInstance(){return ys.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new fs(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new fs(3),this.m_map.set(3,this.m_vd2D)}GetVD2D(){return this.m_vd2D}GetVD3D(){return this.m_vd3D}FindOrAdd(t){if(1===t)return this.GetVD2D();if(3===t)return this.GetVD3D();const e=this.m_map.get(t);if(e)return e;const s=new fs(t);return this.m_map.set(t,s),s}}ys.s_thisInstance=new ys;let vs=class e{static getVertexDescription(t){return ys.getInstance().FindOrAdd(t)}static getVertexDescriptionFromArray(t,s){let i=1;for(let e=0;e<s;++e)i|=1<<t[e];return e.getVertexDescription(i)}static getVertexDescriptionFromAttributes(t,s,i){let n=1;return t&&(n|=2),s&&(n|=4),i&&(n|=8),e.getVertexDescription(n)}static getMergedVertexDescription(t,s){if(!t||!s)return s||t;const i=t.getSemanticsBitArray()|s.getSemanticsBitArray();return(i&t.getSemanticsBitArray())===i?t:(i&s.getSemanticsBitArray())===i?s:e.getVertexDescription(i)}static getMergedVertexDescriptionSemantics(t,s){const i=t.getSemanticsBitArray()|1<<s;return(i&t.getSemanticsBitArray())===i?t:e.getVertexDescription(i)}static removeSemanticsFromVertexDescription(s,i){const n=(s.getSemanticsBitArray()|1<<i)-(1<<i);return n===s.getSemanticsBitArray()?(t(0),s):e.getVertexDescription(n)}static getDefaultDescription2D(){return ys.getInstance().GetVD2D()}static getDefaultDescription3D(){return ys.getInstance().GetVD3D()}static getDescriptionHash(t){return t.getSemanticsBitArray()}static mapAttributes(t,e,s){s.fill(-1);for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}};var Ps=gs;function bs(t,e){return e*(t.getTotalComponentCount()-2)}class Es{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new as(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new as(t.env2D);else if(t.move)this.m_envelope2D=new as(t.move.m_envelope2D),this.m_attributes=t.move.m_attributes,t.move.m_attributes=null;else{if(!t.moveEnv)throw new Error("unrecognized EnvelopeData constructor options");{const e=t.moveEnv.accessEnvelopeData();this.m_envelope2D=new as(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=as.constructEmpty()}ensureAttributes(t){const e=t.getTotalComponentCount()-2;!this.m_attributes&&e&&(this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}copyTo(e,s){const i=s,n=e.getTotalComponentCount()-2;if(i.m_description!==e&&(i.releaseAttributes_(),i.m_description=e,n&&(i.m_data.m_attributes=new Array(2*n))),n){t(this.m_attributes&&i.m_data.m_attributes);const e=2*n;ze(i.m_data.m_attributes,this.m_attributes,0,0,e)}i.m_data.m_envelope2D=new as(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new as(this.m_envelope2D),e.releaseAttributes();t.getTotalComponentCount()-2&&this.m_attributes&&(e.m_attributes=this.m_attributes.slice())}releaseAttributes(){this.m_attributes=null}isEmpty(){return this.m_envelope2D.isEmpty()}queryInterval(t,e,s,i){if(this.isEmpty())return void i.setEmpty();0===e&&(0===s?this.m_envelope2D.queryIntervalX(i):1===s?this.m_envelope2D.queryIntervalY(i):b(""));const n=Ps.getComponentCount(e);(s<0||s>=n)&&b("");const r=t.getAttributeIndex(e);if(r>=0)return i.vmin=this.m_attributes[bs(t,0)+t.getPointAttributeOffset(r)-2+s],void(i.vmax=this.m_attributes[bs(t,1)+t.getPointAttributeOffset(r)-2+s]);{const t=Ps.getDefaultValue(e);return void i.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new kt;this.queryInterval(t,1,0,s),e.setCoords(this.m_envelope2D.xmin,this.m_envelope2D.ymin,s.vmin,this.m_envelope2D.xmax,this.m_envelope2D.ymax,s.vmax)}setEmpty(t){this.m_envelope2D.setEmpty();const e=t.getTotalComponentCount()-2;e&&(this.m_attributes?this.dbgAssertSize(e):this.m_attributes=new Array(2*e),this.m_attributes.fill(Number.NaN))}dbgAssertSize(t){}}class Cs{constructor(t){if(this.m_description=vs.getDefaultDescription2D(),void 0===t)this.m_data=new Es;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Es,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Es({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Es({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_description=t.copy.getDescription(),this.m_data=new Es,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=t.move.m_data;else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this}assignCopy(t){return this}transformAttribute(e,s,i,n,r){t(0)}vertexCount(){return t(0),0}setAttributeBasic(e,s,i){t(0)}hasNonLinearSegments(){return t(0),!0}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=vs.getMergedVertexDescription(e,t);this.assignVertexDescription(s)}asEnvelope2D(){return new as(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return r.enumEnvelope}getDimension(){return 2}getXMin(){return this.m_data.m_envelope2D.xmin}getYMin(){return this.m_data.m_envelope2D.ymin}getXMax(){return this.m_data.m_envelope2D.xmax}getYMax(){return this.m_data.m_envelope2D.ymax}width(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.width()}height(){return this.m_data.isEmpty()?Number.NaN:this.m_data.m_envelope2D.height()}getCenterX(){return t(0),0}getCenterY(){return t(0),0}getCenterXX(){return t(0),new os(0,0)}getCenter(e){t(0)}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof as)this.m_data.m_envelope2D=new as(t),this.m_data.m_envelope2D.normalize();else{this.addAttribute(1),this.m_data.m_envelope2D=t.getEnvelope2D(),this.m_data.m_envelope2D.normalize();const e=kt.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(e){t(0)}intersect(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();this.mergeVertexDescription(e);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const e=this.m_description.getSemantics(s),i=Ps.getComponentCount(e);for(let s=0;s<i;s++){const i=t.queryInterval(e,s),n=this.queryInterval(e,s);n.intersect(i),this.setIntervalEnvelope(e,s,n)}}return!0}intersectCommonAttributes(e){return t(0),!1}move(e,s){t(0)}centerAt(e,s){t(0)}centerAtPoint(t){}reaspect(e,s){t(0)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(e,s){return t(0),!1}contains(e){return t(0),!1}containsPoint(e){return t(0),!1}containsEnvelope(e){return t(0),!1}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=new kt(s);if(i.normalize(),0===t){if(i.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=i.vmin,this.m_data.m_envelope2D.xmax=i.vmax):1===e?(this.m_data.m_envelope2D.ymin=i.vmin,this.m_data.m_envelope2D.ymax=i.vmax):b("")}else this.setAttributeAsDblImpl(0,t,e,i.vmin),this.setAttributeAsDblImpl(1,t,e,i.vmax)}setInterval(t,e,s,i){this.setIntervalEnvelope(t,e,new kt(s,i))}queryInterval(t,e){const s=new kt;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(e){e instanceof as?e.setCoords({env2D:this.m_data.m_envelope2D}):t(0)}applyTransformation(e){t(0)}createInstance(){return t(0),this}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){t(0)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return t(0),0}calculateLength3D(e){return t(0),0}equals(e){return t(0),!1}getBoundary(){return t(0),this}clone(){return new Cs({copy:this})}swap(e){t(0)}queryCoordinates(e){t(0)}queryCornerByVal(t,e){(t<0||t>3)&&b(""),e.assignVertexDescription(this.m_description);const s=this.getDescription().getAttributeCount();for(let i=1;i<s;i++){const s=this.m_description.getSemantics(i),n=Ps.getComponentCount(s);for(let i=0;i<n;i++)e.setAttributeBasic(s,i,this.getAttributeAsDblImpl(t%2,s,i))}e.setXY(this.m_data.m_envelope2D.queryCorner(t))}queryCorner(e,s){t(0)}getDescription(){return this.m_description}mergeVertexDescription(t){this.m_description!==t&&(this.m_description&&this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=vs.removeSemanticsFromVertexDescription(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){t(0)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(e,s){t(0)}getImpl(){return this}setFromPoint(e,s,i){t(0)}assignVertexDescriptionImpl(t){const e=xs();vs.mapAttributes(t,this.m_description,e);let s=null;const i=t.getTotalComponentCount()-2,n=this.m_description?this.m_description.getTotalComponentCount()-2:0;i>0&&(s=new Array(2*i),s.fill(Number.NaN));for(let r=1;r<t.getAttributeCount();r++){const o=e[r];if(-1!==o){const e=t.getPointAttributeOffset(r)-2,a=Ps.getComponentCount(t.getSemantics(r)),h=this.m_description.getPointAttributeOffset(o)-2;ze(s,this.m_data.m_attributes,e,h,a),ze(s,this.m_data.m_attributes,i+e,n+h,a)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(e,s,i){return t(0),0}setAttributeAsDblImpl(t,e,s,i){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=i:0===s?this.m_data.m_envelope2D.xmax=i:b(""):1===s?this.m_data.m_envelope2D.ymin=i:0===s?this.m_data.m_envelope2D.xmin=i:b(""));const n=Ps.getComponentCount(e);(s<0||s>=n)&&b(""),this.addAttribute(e);const r=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[bs(this.m_description,t)+this.m_description.getPointAttributeOffset(r)-2+s]=i}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}}Cs.type=r.enumEnvelope;const Ds=-559038737;var Ss=gs;function ws(t,e,s){switch(t){case 0:return new Ys(e,s);case 1:return new Xs(e,s);case 2:return new Fs(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new Rs(e,s);default:f("")}}function As(t,e){const s=Ss.getComponentCount(t);return ws(Ss.getPersistence(t),e*s,Ss.getDefaultValue(t))}function Ts(t,e){const s=Ss.getComponentCount(t);return ws(Ss.getPersistence(t),e*s)}function Is(t,e){return new Fs(t,e)}function Ns(t,e){return new Rs(t,e)}function Ms(t,e){return new Xs(t,e)}class qs{size(){return this.m_size}checkResize(t,e){t>this.m_size&&this.resize(t,e)}resize(t,e){if((t=Math.trunc(t))===this.m_size)return;const s=!!e||Number.isNaN(e);if(t<this.m_a.length)this.m_a.length>qs.s_resizeMin&&1.25*t<this.m_a.length&&(this.m_a=this.m_a.slice(0,t)),s&&t>this.m_size&&this.m_a.fill(e,this.m_size,t);else if(t>=this.m_a.length){const i=1.25*t,n=new this.m_a.constructor(i);n.set(this.m_a),this.m_a=n,s&&this.m_a.fill(e,this.m_size,t)}this.m_size=t}resizeRounded(t,e){return this.resize(t,e)}reserve(t){}read(e){return t(e>=0&&e<this.m_size),this.m_a[e]}readAsDbl(t){return this.read(t)}write(t,e){this.m_a[t]=e}writeAsDbl(t,e){this.write(t,e)}setRange(t,e,s){(e<0||s<0||s+e>this.size())&&f(),this.m_a.fill(t,e,e+s)}add(t){this.resize(this.m_size+1),this.m_a[this.m_size-1]=t}addArray(t,e){const s=this.m_size;void 0===e?(this.resize(this.m_size+t.length),this.m_a.set(t,s)):(this.resize(this.m_size+e),this.m_a.set(t.slice(0,e),s))}equals(t,e,s,i){if(this.getPersistence()!==t.getPersistence())return!1;return Ls(this,t,e,s,i)}insertRange(t,e,s,i){s&&this.checkResize(i+s),this.m_a.copyWithin(t+s,t,i||this.m_size),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.subarray(t,t+e)}insertRangeFromStream(e,s,i,n,r,o,a){t(this.getPersistence()===s.getPersistence());const h=s;n&&this.checkResize(a+n),this.m_a.copyWithin(e+n,e,a||this.m_size),this.m_a.set(h.readRange(i,n),e)}writeRange(e,s,i,n,r,o){t(this.getPersistence()===i.getPersistence());const a=i;if((e<0||s<0||n<0)&&f(),a.size()<n+s&&f(),0===s)return;this.size()<s+e&&this.resize(s+e);const h=a.m_a.subarray(n,n+s);zs(this.m_a,e,s,h)}insertAttributes(t,e,s,i){const n=Ss.getComponentCount(s);this.m_a.copyWithin(t+n,t,i||this.m_size);for(let r=0;r<n;r++)this.m_a[t+r]=e.getAttributeAsDbl(s,r)}insertAttributesFromPoints(e,s,i,n,r){t(0)}eraseRange(t,e,s){this.m_size<t+e&&f(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!=0)&&f(),this.m_a.subarray(t,t+e).reverse(),s>1)for(let i=t,n=t+e;i<n;i+=s){let t=i,e=i+s-1;for(;t<e;){const s=this.m_a[t];this.m_a[t]=this.m_a[e],this.m_a[e]=s,t++,e--}}}rotate(e,s,i){t(0)}adjacentDifference(e,s,i){return t(0),0}sort(t,e,s){this.m_a.subarray(t,e).sort(s)}constructor(t){if(t.move)this.m_a=t.move.m_a,this.m_size=t.move.m_size,t.move.m_a=t.move.m_a.slice(0,0),t.move.m_size=0;else if(t.copy)this.m_size=t.copy.m_size,t.maxSize&&(this.m_size=Math.min(t.maxSize,this.m_size)),this.m_a=t.copy.m_a.slice(0,this.m_size);else{const e=Math.max(t.size,qs.s_constructMin);this.m_a=new t.ctor(e),(t.defaultValue||Number.isNaN(t.defaultValue))&&this.m_a.fill(t.defaultValue),this.m_size=t.size}}}qs.s_constructMin=2,qs.s_resizeMin=30;class Rs extends qs{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new Rs({ctor:Int8Array,copy:this})}restrictedClone(t){return new Rs({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class Fs extends qs{getPersistence(){return 2}clone(){return new Fs({ctor:Int32Array,copy:this})}restrictedClone(t){return new Fs({ctor:Int32Array,copy:this,maxSize:t})}write(e,s){t(s<=$()),super.write(e,s)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class Ys extends qs{getPersistence(){return 0}clone(){return new Ys({ctor:Float32Array,copy:this})}restrictedClone(t){return new Ys({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class Xs extends qs{getPersistence(){return 1}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&f();const i=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(i,s,i)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new os(e,s)}queryPoint2D(t,e){e.x=this.m_a[t],e.y=this.m_a[t+1]}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){if(s+2>=this.m_a.length)throw RangeError("AttributeStreamOfDbl::insert");this.m_a.copyWithin(t+2,t,s||this.m_size),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){if(this.m_a.copyWithin(t+2*i,t,r||this.m_size),n)for(let o=s,a=t,h=0;h<i;++h,++o){const t=e[o];this.m_a[a++]=t.x,this.m_a[a++]=t.y}else for(let o=s+i-1,a=t,h=0;h<i;++h,--o){const t=e[o];this.m_a[a++]=t.x,this.m_a[a++]=t.y}}queryRange(t,e,s,i,n){if((t<0||e<0)&&f(),!i&&(n<=0||e%n!=0)&&f(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const r=this.m_a.subarray(t,t+e);s.set(r)}writeRangeFromArray(t,e,s,i,n){if((t<0||e<0)&&f(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let r=s;e<s.length&&(r=s.subarray(0,e)),this.m_a.set(r,t)}clone(){return new Xs({ctor:Float64Array,copy:this})}restrictedClone(t){return new Xs({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}function Ls(t,e,s,i,n){if(t.getPersistence()!==e.getPersistence())return!1;const r=t.getPersistence()<=1,o=t.size(),a=e.size();if(i>o||i>a)return!1;if(n)for(let h=s;h<i;h++){let s=t.read(h)-e.read(h);if(s<0&&(s=-s),s>n)return!1}else for(let h=s;h<i;h++){const s=t.read(h),i=e.read(h);if(s!==i){if(r&&Number.isNaN(s)&&Number.isNaN(i))continue;return!1}}return!0}function zs(t,e,s,i,n,r){if((e<0||s<0)&&f(),0===s)return;if(1===s)return void(t[e]=i[0]);let o=i;s<i.length&&(o=i.subarray(0,s)),t.set(o,e)}class Vs{static constructEmpty(){return new Vs(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}getEnvelope2D(){return new as(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new kt(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=Ve(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=Ve(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=Ve(this.zmin,this.zmin=this.zmax),this.zmin<=this.zmax||this.setEmptyZ()):this.setEmpty()}isEmpty(){return Number.isNaN(this.xmin)||Number.isNaN(this.ymin)||Number.isNaN(this.xmax)||Number.isNaN(this.ymax)}isEmptyZ(){return Number.isNaN(this.zmin)||Number.isNaN(this.zmax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.zmin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN,this.zmax=Number.NaN}mergeEnv3D(t){t.isEmpty()||(this.mergeCoords(t.xmin,t.ymin,t.zmin),this.mergeCoords(t.xmax,t.ymax,t.zmax))}mergeNe(t){this.mergeNeCoords(t.x,t.y,t.z)}mergeNeCoords(t,e,s){this.xmin>t?this.xmin=t:this.xmax<t&&(this.xmax=t),this.ymin>e?this.ymin=e:this.ymax<e&&(this.ymax=e),this.zmin>s?this.zmin=s:this.zmax<s&&(this.zmax=s)}mergeCoords(t,e,s){this.isEmpty()?(this.xmin=t,this.xmax=t,this.ymin=e,this.ymax=e,this.zmin=s,this.zmax=s):(this.isEmptyZ()&&(this.zmin=s,this.zmax=s),this.mergeNeCoords(t,e,s))}setCoords(t,e,s,i,n,r){this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}}class Bs{constructor(){this.xyStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.xyStream}set(t,e){t>0?this.streams[t-1]=e:this.xyStream=e}destroyAndSetSize(t){if(this.streams=null,t>1){this.streams=new Array(t-1);for(let e=0;e<t-1;++e)this.streams[e]=null}this.xyStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.xyStream,t.xyStream]=[t.xyStream,this.xyStream]}empty(){return null===this.xyStream&&null===this.streams}}class ks{constructor(t){this.m_buffer=null,this.m_firstFree=-1,this.m_last=0,this.m_size=0,this.m_capacity=0,this.m_bufferSize=0,this.m_stride=0,this.m_stride=t,this.m_realStride=t,this.m_blockSize=Math.trunc(ks.st_realBlockSize/this.m_realStride)}dbgdelete_(t){return this.m_buffer[t>>ks.st_blockPower][1+(t&ks.st_blockMask)]=ks.st_deadVertex,!0}deleteElement(t){(t>>ks.st_blockPower)*this.m_blockSize*this.m_realStride+(t&ks.st_blockMask)<this.m_last*this.m_realStride?(this.m_buffer[t>>ks.st_blockPower][t&ks.st_blockMask]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.m_size--}getField(t,e){return this.m_buffer[t>>ks.st_blockPower][(t&ks.st_blockMask)+e]}setField(t,e,s){this.m_buffer[t>>ks.st_blockPower][(t&ks.st_blockMask)+e]=s}getStride(){return this.m_stride}newElement(){let t=this.m_firstFree;if(-1===t){if(this.m_last===this.m_capacity){const t=0!==this.m_capacity?Math.trunc(1.5*(this.m_capacity+1)):1;this.grow(t)}t=(this.m_last/this.m_blockSize<<ks.st_blockPower)+this.m_last%this.m_blockSize*this.m_realStride,this.m_last++}else this.m_firstFree=this.m_buffer[t>>ks.st_blockPower][t&ks.st_blockMask];this.m_size++;const e=this.m_buffer[t>>ks.st_blockPower],s=t&ks.st_blockMask;for(let i=0;i<this.m_stride;i++)e[s+i]=-1;return t}elementToIndex(t){return(t>>ks.st_blockPower)*this.m_blockSize+(t&ks.st_blockMask)/this.m_realStride}deleteAll(t){this.m_firstFree=-1,this.m_last=0,this.m_size=0,t&&(this.m_buffer=null,this.m_capacity=0)}size(){return this.m_size}setCapacity(t){t>this.m_capacity&&this.grow(t)}capacity(){return this.m_capacity}swap(t,e){const s=this.m_buffer[t>>ks.st_blockPower],i=this.m_buffer[e>>ks.st_blockPower],n=t&ks.st_blockMask,r=e&ks.st_blockMask;for(let o=0;o<this.m_stride;o++){const t=s[n+o];s[n+o]=i[r+o],i[r+o]=t}}swapField(t,e,s){const i=this.m_buffer[t>>ks.st_blockPower],n=this.m_buffer[e>>ks.st_blockPower],r=(t&ks.st_blockMask)+s,o=(e&ks.st_blockMask)+s,a=i[r];i[r]=n[o],n[o]=a}static impossibleIndex2(){return-2}static impossibleIndex3(){return-3}static isValidElement(t){return t>=0}ensureBufferBlocksCapacity(t){if(this.m_buffer.length<t){const e=new Array(t);for(let t=0;t<this.m_buffer.length;t++)e[t]=this.m_buffer[t];this.m_buffer=e}}grow(t){null===this.m_buffer&&(this.m_bufferSize=0,this.m_buffer=new Array(8));const e=Math.trunc((t+this.m_blockSize-1)/this.m_blockSize);if(this.ensureBufferBlocksCapacity(e),1===e){this.m_capacity>0&&this.m_capacity;let e=0;const s=t*this.m_realStride;for(;s>ks.st_sizes[e];)e++;const i=new Int32Array(ks.st_sizes[e]);1===this.m_bufferSize?(i.set(this.m_buffer[0]),this.m_buffer[0]=i):(this.m_buffer[this.m_bufferSize]=i,this.m_bufferSize++),this.m_capacity=Math.trunc(i.length/this.m_realStride)}else{if(1===this.m_bufferSize&&this.m_buffer[0].length<ks.st_realBlockSize){const t=new Int32Array(ks.st_realBlockSize);t.set(this.m_buffer[0]),this.m_buffer[0]=t,this.m_capacity=this.m_blockSize}for(;this.m_bufferSize<e;)this.m_buffer[this.m_bufferSize++]=new Int32Array(ks.st_realBlockSize),this.m_capacity+=this.m_blockSize}}}ks.st_realBlockSize=16384,ks.st_blockMask=16383,ks.st_blockPower=14,ks.st_sizes=[16,32,64,128,256,512,1024,2048,4096,8192,16384],ks.st_deadVertex=-2125315821;class Gs{constructor(t=!1){this.m_bNotifyOnActions=t}onDelete(t){}onSet(t){}onEndSearch(t){}onAddUniqueElementFailed(t){}onDeleteImpl(t,e){this.m_bNotifyOnActions&&this.onDelete(t.getElement(e))}onSetImpl(t,e){this.m_bNotifyOnActions&&this.onSet(t.getElement(e))}onAddUniqueElementFailedImpl(t){this.m_bNotifyOnActions&&this.onAddUniqueElementFailed(t)}onEndSearchImpl(t){this.m_bNotifyOnActions&&this.onEndSearch(t)}}class Ws{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new ks(7),this.m_treapCount=0,this.m_maxDepthEver=0,this.m_bBalancing=!0}setComparator(t){this.m_comparator=t}getComparator(){return this.m_comparator}disableBalancing(){this.m_bBalancing=!1}enableBalancing(){this.m_bBalancing||(t(this.m_treapCount<=1),this.rebalance(-1),this.m_bBalancing=!0)}isAutoBalancing(){return this.m_bBalancing}rebalance(t){if(this.m_bBalancing)return;if(-1===t&&(t=this.m_defaultTreap),0===this.size(t))return;const e=[];for(let s=this.getFirst(t);-1!==s;s=this.getNext(s))e.push(s),this.setParent_(s,-1),this.setRight_(s,-1),this.setLeft_(s,-1);this.setRoot_(-1,t),this.setFirst_(-1,t),this.setLast_(-1,t),this.setSize_(0,t),this.m_bBalancing=!0;for(const s of e)this.addBiggestElement_(s,t);this.m_bBalancing=!1}setCapacity(t){this.m_treapData.setCapacity(t)}createTreap(t){const e=this.m_treapData.newElement();return this.setSize_(0,e),this.setTreapData_(t,e),this.m_treapCount++,e}deleteTreap(t){this.m_treapData.deleteElement(t),this.m_treapCount--}addElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,0,e)}addUniqueElement(t,e=-1){return-1===e&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap),this.addElement_(t,1,e)}addBiggestElement(t,e=-1){-1===e&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),e=this.m_defaultTreap);const s=this.newNode_(t);return this.addBiggestElement_(s,e),s}addElementAtPosition(t,e,s,i,n,r=-1){if(-1===r&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),r=this.m_defaultTreap),this.getRoot_(r)===Ws.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,r),this.addToList_(-1,t,r),t}let o,a,h,m,u;if(n?(o=e!==Ws.st_nullNode()?this.m_comparator.compare(this,s,e):-1,a=t!==Ws.st_nullNode()?this.m_comparator.compare(this,s,t):1):(o=-1,a=1),i&&(0===o||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===o?e:t;return this.setDuplicateElement_(i,r),-1}u=e!==Ws.st_nullNode()&&t!==Ws.st_nullNode()?this.m_random>_t(this.m_random)>>1:e!==Ws.st_nullNode(),u?(m=o,h=e):(m=a,h=t);let l=-1,c=-1,d=!0;for(;;){if(m<0){const t=this.getLeft(h);if(t===Ws.st_nullNode()){c=h,l=this.newNode_(s),this.setLeft_(h,l),this.setParent_(l,h);break}h=t}else{const t=this.getRight(h);if(t===Ws.st_nullNode()){c=this.getNext(h),l=this.newNode_(s),this.setRight_(h,l),this.setParent_(l,h);break}h=t}d&&(m*=-1,d=!1)}return this.bubbleUp_(l),this.getParent(l)===Ws.st_nullNode()&&this.setRoot_(l,r),this.addToList_(c,l,r),l}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==Ws.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==Ws.st_nullNode()&&(a=this.m_comparator.compare(this,e,o)),s&&(0===r||0===a)){this.m_comparator.onAddUniqueElementFailedImpl(e);const t=0===r?i:o;return n===Ws.st_nullNode()&&(this.m_defaultTreap===Ws.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),n=this.m_defaultTreap),this.setDuplicateElement_(t,n),-1}}return this.setElement_(t,e),t}getDuplicateElement(t=-1){return-1===t?this.getDuplicateElement_(this.m_defaultTreap):this.getDuplicateElement_(t)}deleteNode(t,e=-1){this.m_comparator&&this.m_comparator.onDeleteImpl(this,t),-1===e&&(e=this.m_defaultTreap),this.m_bBalancing?this.deleteNode_(t,e):this.unbalancedDelete_(t,e)}search(t,e=-1){let s=this.getRoot(e);for(;s!==Ws.st_nullNode();){const e=this.m_comparator.compare(this,t,s);if(!e)return s;s=e<0?this.getLeft(s):this.getRight(s)}return this.m_comparator.onEndSearchImpl(t),Ws.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==Ws.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?s=this.getLeft(s):(i=s,s=this.getRight(s))}return i}searchUpperBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==Ws.st_nullNode();){const e=t.compare(this,s);if(!e)return s;e<0?(i=s,s=this.getLeft(s)):s=this.getRight(s)}return i}getElement(t){return this.m_treapData.getField(t,3)}getLeft(t){return this.m_treapData.getField(t,0)}getRight(t){return this.m_treapData.getField(t,1)}getParent(t){return this.m_treapData.getField(t,2)}getNext(t){return this.m_treapData.getField(t,6)}getPrev(t){return this.m_treapData.getField(t,5)}getFirst(t=-1){return-1===t?this.getFirst_(this.m_defaultTreap):this.getFirst_(t)}getLast(t=-1){return-1===t?this.getLast_(this.m_defaultTreap):this.getLast_(t)}getTreapData(t=-1){return-1===t?this.getTreapData_(this.m_defaultTreap):this.getTreapData_(t)}setElement(t,e){null!==this.m_comparator&&this.m_comparator.onSetImpl(this,t),this.setElement_(t,e)}getRoot(t=-1){return-1===t?this.getRoot_(this.m_defaultTreap):this.getRoot_(t)}clear(){this.m_treapData.deleteAll(!1),this.m_defaultTreap=Ws.st_nullNode(),this.m_treapCount=0,this.m_maxDepthEver=0}addToList_(t,e,s){let i;-1!==t?(i=this.getPrev(t),this.setPrev_(t,e)):i=this.getLast_(s),this.setPrev_(e,i),-1!==i&&this.setNext_(i,e),this.setNext_(e,t),t===this.getFirst_(s)&&this.setFirst_(e,s),-1===t&&this.setLast_(e,s),this.setSize_(this.getSize_(s)+1,s)}size(t=-1){return-1===t?this.getSize_(this.m_defaultTreap):this.getSize_(t)}getMaxDepth(t=-1){return this.getMaxDepthHelper_(this.getRoot(t))}getMaxDepthEver(){return this.m_maxDepthEver}static st_isValidNode(t){return ks.isValidElement(t)}dbgCheck_(e){t(0)}getPriority_(t){return this.m_treapData.getField(t,4)}bubbleDown_(t){let e=this.getLeft(t),s=this.getRight(t);const i=this.getPriority_(t);for(;e!==Ws.st_nullNode()||s!==Ws.st_nullNode();){const n=e!==Ws.st_nullNode()?this.getPriority_(e):Q(),r=s!==Ws.st_nullNode()?this.getPriority_(s):Q();if(i<=Math.min(n,r))return;n<=r?this.rotateRight_(e):this.rotateLeft_(t),e=this.getLeft(t),s=this.getRight(t)}}bubbleUp_(t){if(!this.m_bBalancing)return;const e=this.getPriority_(t);let s=this.getParent(t);for(;s!==Ws.st_nullNode()&&this.getPriority_(s)>e;)this.getLeft(s)===t?this.rotateRight_(t):this.rotateLeft_(s),s=this.getParent(t)}rotateLeft_(t){const e=t,s=this.getRight(t);let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getLeft(s),this.setRight_(e,i),i!==Ws.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==Ws.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}rotateRight_(t){const e=this.getParent(t),s=t;let i;this.setParent_(s,this.getParent(e)),this.setParent_(e,s),i=this.getRight(s),this.setLeft_(e,i),i!==Ws.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==Ws.st_nullNode()&&(this.getLeft(i)===e?this.setLeft_(i,s):this.setRight_(i,s))}setParent_(t,e){this.m_treapData.setField(t,2,e)}setLeft_(t,e){this.m_treapData.setField(t,0,e)}setRight_(t,e){this.m_treapData.setField(t,1,e)}setPriority_(t,e){this.m_treapData.setField(t,4,e)}setPrev_(t,e){this.m_treapData.setField(t,5,e)}setNext_(t,e){this.m_treapData.setField(t,6,e)}setRoot_(t,e){this.m_treapData.setField(e,0,t)}setFirst_(t,e){this.m_treapData.setField(e,1,t)}setLast_(t,e){this.m_treapData.setField(e,2,t)}setDuplicateElement_(t,e){this.m_treapData.setField(e,3,t)}setSize_(t,e){this.m_treapData.setField(e,4,t)}setTreapData_(t,e){this.m_treapData.setField(e,5,t)}getRoot_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?Ws.st_nullNode():this.m_treapData.getField(t,3)}getSize_(t){return-1===t?0:this.m_treapData.getField(t,4)}getTreapData_(t){return this.m_treapData.getField(t,5)}newNode_(t){const e=this.m_treapData.newElement();return this.setPriority_(e,this.generatePriority_()),this.setElement_(e,t),e}freeNode_(t,e){t!==Ws.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=_t(this.m_random),this.m_random&Q()>>1}maxPriority(){return t(0),0}getMaxDepthHelper_(t){return t===Ws.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===Ws.st_nullNode()){const e=this.newNode_(t);return this.setRoot_(e,s),this.addToList_(-1,e,s),this.m_maxDepthEver=Math.max(this.m_maxDepthEver,1),e}let i=this.getRoot_(s),n=-1,r=-1,o=1;for(;;){const a=-1===e?1:this.m_comparator.compare(this,t,i);if(a<0){const e=this.getLeft(i);if(e===Ws.st_nullNode()){r=i,n=this.newNode_(t),this.setLeft_(i,n),this.setParent_(n,i);break}i=e}else{if(1===e&&0===a)return this.m_comparator.onAddUniqueElementFailedImpl(t),this.setDuplicateElement_(i,s),-1;const o=this.getRight(i);if(o===Ws.st_nullNode()){r=this.getNext(i),n=this.newNode_(t),this.setRight_(i,n),this.setParent_(n,i);break}i=o}o++}return this.bubbleUp_(n),this.getParent(n)===Ws.st_nullNode()&&this.setRoot_(n,s),this.addToList_(r,n,s),this.m_maxDepthEver=Math.max(o,this.m_maxDepthEver),n}removeFromList_(t,e){const s=this.getPrev(t),i=this.getNext(t);-1!==s?this.setNext_(s,i):this.setFirst_(i,e),-1!==i?this.setPrev_(i,s):this.setLast_(s,e),this.setSize_(this.getSize_(e)-1,e)}unbalancedDelete_(t,e){this.removeFromList_(t,e);let s=this.getLeft(t),i=this.getRight(t),n=this.getParent(t),r=t;if(-1!==s&&-1!==i){let o;this.m_random=_t(this.m_random),o=this.m_random>Q()>>1?this.getNext(t):this.getPrev(t);const a=this.getParent(o)===t;this.m_treapData.swapField(t,o,0),this.m_treapData.swapField(t,o,1),this.m_treapData.swapField(t,o,2),-1!==n?this.getLeft(n)===t?this.setLeft_(n,o):this.setRight_(n,o):this.setRoot_(o,e),a?(s===o?(this.setLeft_(o,t),this.setParent_(i,o)):i===o&&(this.setRight_(o,t),this.setParent_(s,o)),this.setParent_(t,o),n=o):(this.setParent_(s,o),this.setParent_(i,o),n=this.getParent(t),r=o),s=this.getLeft(t),i=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==i&&this.setParent_(i,t)}const o=-1!==s?s:i;-1===n?this.setRoot_(o,e):this.getLeft(n)===r?this.setLeft_(n,o):this.setRight_(n,o),-1!==o&&this.setParent_(o,n),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,Q());let s=Ws.st_nullNode(),i=Ws.st_nullNode();const n=this.getRoot_(e),r=n===t;if(r&&(s=this.getLeft(n),i=this.getRight(n),s===Ws.st_nullNode()&&i===Ws.st_nullNode()))return this.removeFromList_(n,e),this.freeNode_(n,e),void this.setRoot_(Ws.st_nullNode(),e);this.bubbleDown_(t);const o=this.getParent(t);o!==Ws.st_nullNode()&&(this.getLeft(o)===t?this.setLeft_(o,Ws.st_nullNode()):this.setRight_(o,Ws.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),r&&this.setRoot_(s===Ws.st_nullNode()||this.getParent(s)!==Ws.st_nullNode()?i:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===Ws.st_nullNode())return this.setRoot_(t,e),void this.addToList_(-1,t,e);const s=this.getLast_(e);this.setRight_(s,t),this.setParent_(t,s),this.bubbleUp_(t),this.getParent(t)===Ws.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class Zs{constructor(t){this.m_lists=new ks(6),this.m_listOfLists=Zs.st_nullNode(),void 0===t?(this.m_listNodes=new ks(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new ks(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(e){t(0)}newList_(){return this.m_lists.newElement()}setPrev_(t,e){this.m_listNodes.setField(t,1,e)}setNext_(t,e){this.m_listNodes.setField(t,2,e)}setData_(e,s){t(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(e,s){t(0)}setPrevList_(t,e){this.m_lists.setField(t,2,e)}createList(t){const e=this.newList_();return this.m_lists.setField(e,3,this.m_listOfLists),this.m_lists.setField(e,4,0),this.m_lists.setField(e,5,t),this.m_listOfLists!==Zs.st_nullNode()&&this.setPrevList_(this.m_listOfLists,e),this.m_listOfLists=e,e}deleteList(t){this.clear(t);const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);return e!==Zs.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==Zs.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(e){t(0)}getListData(e){return t(0),0}getList(e){return t(0),0}setListData(e,s){t(0)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;e!==Zs.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==Zs.st_nullNode()&&this.setNext_(n,i);if(e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===Zs.st_nullNode()){const e=this.m_lists.getField(t,1);this.setPrev_(i,e),-1!==e&&this.setNext_(e,i),this.m_lists.setField(t,1,i)}return this.setData(i,s),this.setListSize_(t,this.getListSize(t)+1),this.m_bStoreListIndexWithNode&&this.setList_(i,t),i}deleteElement(t,e){const s=this.getPrev(e),i=this.getNext(e);return s!==Zs.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==Zs.st_nullNode()?this.setPrev_(i,s):this.m_lists.setField(t,1,s),this.freeNode_(e),this.setListSize_(t,this.getListSize(t)-1),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}getData(t){return this.m_listNodes.getField(t,0)}getElement(t){return this.getData(t)}setData(t,e){this.m_listNodes.setField(t,0,e)}getNext(t){return this.m_listNodes.getField(t,2)}getPrev(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getLast(t){return this.m_lists.getField(t,1)}static st_nullNode(){return-1}clear(t){if(void 0!==t){let e=this.getLast(t);for(;e!==Zs.st_nullNode();){const t=e;e=this.getPrev(t),this.freeNode_(t)}return this.m_lists.setField(t,0,-1),this.m_lists.setField(t,1,-1),void this.setListSize_(t,0)}for(let e=this.getFirstList();-1!==e;)e=this.deleteList(e)}isEmpty(e){return t(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getListSize(t){return this.m_lists.getField(t,4)}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}class Hs{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new Fs(0),this.m_bucketedIndices=new Fs(0)}static sortEx(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);(new Hs).sort(t,e,s,i,n)}sort(t,e,s,i,n=32){if(s-e<=n)return void i.userSort(e,s,t);let r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY;for(let m=e;m<s;m++){const e=i.getValue(t.read(m));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let r=e;r<s;r++){const s=t.read(r),n=i.getValue(s),o=this.getBucket(n);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(r-e,s)}let n=this.m_buckets.read(0);this.m_buckets.write(0,0);for(let t=1,e=this.m_buckets.size();t<e;t++){const e=this.m_buckets.read(t);this.m_buckets.write(t,n),n+=e}for(let r=e;r<s;r++){const s=this.m_bucketedIndices.read(r-e),n=i.getValue(s),o=this.getBucket(n),a=this.m_buckets.read(o);t.write(a+e,s),this.m_buckets.write(o,a+1)}r=!1}if(r)return void i.userSort(e,s,t);let h=0;for(let m=0,u=this.m_buckets.size();m<u;m++){const s=h;h=this.m_buckets.read(m),h>s&&i.userSort(e+s,e+h,t)}this.m_buckets.size()>100&&(this.m_buckets.resize(0),this.m_bucketedIndices.resize(0))}reset(t,e,s,i){if(t<2||s===e)return!1;const n=Math.min(Hs.c_maxBuckets,t);return this.m_buckets.resize(n),this.m_buckets.setRange(0,0,this.m_buckets.size()),this.m_minValue=e,this.m_maxValue=s,this.m_bucketedIndices.resize(i),this.m_dy=(s-e)/(n-1),!0}getBucket(t){return Math.trunc((t-this.m_minValue)/this.m_dy)}getBucketCount(){return this.m_buckets.size()}}Hs.c_maxBuckets=65536;class Os extends Gs{constructor(t){super(),this.m_intervalTree=t}compare(t,e,s){const i=t.getElement(s),n=this.m_intervalTree.getValue_(e),r=this.m_intervalTree.getValue_(i);return n<r?-1:n===r?js.isLeft_(e)&&js.isRight_(i)?-1:js.isLeft_(i)&&js.isRight_(e)?1:0:1}}class js{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new ks(3),this.m_intervalHandles=[],this.m_endIndicesUnique=[],this.m_cCount=-1,this.m_root=-1,this.m_bSortIntervals=!1,this.m_bConstructing=!1,this.m_bConstructionEnded=!1,this.m_bOfflineDynamic=t,this.m_tertiaryNodes=new ks(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new Ws,this.m_secondaryTreaps.setComparator(new Os(this)),this.m_secondaryLists=new Zs}addEnvelopesRef(t){this.reset_(!0,!0),this.m_bEnvelopesRef=!0,this.m_envelopesRef=t,this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_envelopesRef.length)}startConstruction(){t(0)}addInterval(e){t(0)}addIntervalCoords(e,s){t(0)}endConstruction(){t(0)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||y(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new Fs(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalHandles.length=t,this.m_intervalHandles.fill(-1),this.m_bSortIntervals=!1}else this.m_intervalHandles.fill(-1,0,t);this.m_root=this.createRoot_()}const e=this.insertIntervalEnd_(t<<1,this.m_root),s=this.getSecondaryFromInterval_(e),i=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,i),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||y("");const e=this.m_intervalHandles[t];let s;-1===e&&f("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let i=this.getSecondaryFromInterval_(e),n=-1;n=this.m_secondaryTreaps.getTreapData(i),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),i),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),i),s=this.m_secondaryTreaps.size(i),0===s&&(this.m_secondaryTreaps.deleteTreap(i),this.setSecondaryToTertiary_(n,-1)),this.m_intervalNodes.deleteElement(e);let r=this.getPptr_(n),o=this.getLptr_(n),a=this.getRptr_(n);for(;!(s>0||n===this.m_root||-1!==o&&-1!==a);)n===this.getLptr_(r)?-1!==o?(this.setLptr_(r,o),this.setPptr_(o,r),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==a?(this.setLptr_(r,a),this.setPptr_(a,r),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setLptr_(r,-1),this.setPptr_(n,-1)):-1!==o?(this.setRptr_(r,o),this.setPptr_(o,r),this.setLptr_(n,-1),this.setPptr_(n,-1)):-1!==a?(this.setRptr_(r,a),this.setPptr_(a,r),this.setRptr_(n,-1),this.setPptr_(n,-1)):(this.setRptr_(r,-1),this.setPptr_(n,-1)),this.m_tertiaryNodes.deleteElement(n),n=r,i=this.getSecondaryFromTertiary_(n),s=-1!==i?this.m_secondaryTreaps.size(i):0,o=this.getLptr_(n),a=this.getRptr_(n),r=this.getPptr_(n)}size(){return this.m_cCount}getIteratorQuery(e,s){return t(0),{}}getIterator(){return new Us(this)}querySortedEndPointIndices_(t){const e=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;for(let s=0;s<2*e;s++)t.add(s);this.sortEndIndices_(t,0,2*e)}querySortedDuplicatesRemoved_(t){let e=Number.NaN;for(let s=0;s<t.size();s++){const i=t.read(s),n=this.getValue_(i);n!==e&&(this.m_endIndicesUnique.push(i),e=n)}}insertIntervalsStatic_(){t(0)}createRoot_(){const t=this.calculateDiscriminantIndex1_(0,this.m_endIndicesUnique.length-1);return this.createTertiaryNode_(t)}insertIntervalEnd_(t,e){let s=-1,i=e,n=-1,r=-1,o=0,a=this.m_endIndicesUnique.length-1,h=0;const m=t>>1;let u=Number.NaN,l=Number.NaN,c=!0;const d=this.getMin_(m),_=this.getMax_(m);let g=-1;for(;c;){h=o+(a-o>>1),g=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(g);if(_<e){if(-1!==i)if(g===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getLptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l>e){const t=this.createTertiaryNode_(g);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setRptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}a=h;continue}if(d>e){if(-1!==i)if(g===this.getDiscriminantIndex1_(i))s=i,u=e,i=this.getRptr_(i),l=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(l<e){const t=this.createTertiaryNode_(g);e<u?this.setLptr_(s,t):this.setRptr_(s,t),this.setLptr_(t,i),this.m_bOfflineDynamic&&(this.setPptr_(t,s),this.setPptr_(i,t)),s=t,u=e,i=-1,l=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||g!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(g):i,n=this.getSecondaryFromTertiary_(m),-1===n&&(n=this.createSecondary_(m),this.setSecondaryToTertiary_(m,n));const p=this.addEndIndex_(n,t);r=this.createIntervalNode_(),this.setSecondaryToInterval_(r,n),this.setLeftEnd_(r,p),-1!==i&&g===this.getDiscriminantIndex1_(i)||(e<u?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(l<e?this.setLptr_(m,i):this.setRptr_(m,i),this.m_bOfflineDynamic&&this.setPptr_(i,m))),c=!1;break}return r}createTertiaryNode_(t){const e=this.m_tertiaryNodes.newElement();return this.setDiscriminantIndex1_(e,t),e}createSecondary_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.createTreap(t):this.m_secondaryLists.createList(t)}createIntervalNode_(){return this.m_intervalNodes.newElement()}reset(){this.m_bOfflineDynamic&&this.m_bConstructionEnded||y(""),this.reset_(!1,this.m_bEnvelopesRef)}reset_(t,e){t?(this.m_bEnvelopesRef=!1,this.m_envelopesRef=null,this.m_bSortIntervals=!0,this.m_bConstructing=!0,this.m_bConstructionEnded=!1,this.m_endIndicesUnique.length=0,e?(this.m_intervals.length=0,this.m_bEnvelopesRef=!0):this.m_intervals.length=0):this.m_bSortIntervals=!1,this.m_bOfflineDynamic?this.m_secondaryTreaps.clear():this.m_secondaryLists.clear(),this.m_intervalNodes.deleteAll(!1),this.m_tertiaryNodes.deleteAll(!1),this.m_root=-1,this.m_cCount=0}getDiscriminant_(t){const e=this.getDiscriminantIndex1_(t);return this.getDiscriminantFromIndex1_(e)}getDiscriminantFromIndex1_(t){if(-1===t)return Number.NaN;if(t>0){const e=t-2,s=this.m_endIndicesUnique[e],i=this.m_endIndicesUnique[e+1];return.5*(this.getValue_(s)+this.getValue_(i))}const e=-t-2,s=this.m_endIndicesUnique[e];return this.getValue_(s)}calculateDiscriminantIndex1_(t,e){let s;if(t<e){s=t+(e-t>>1)+2}else s=-(t+2);return s}setDiscriminantIndex1_(t,e){this.m_tertiaryNodes.setField(t,0,e)}setSecondaryToTertiary_(t,e){this.m_tertiaryNodes.setField(t,1,e)}setLptr_(t,e){this.m_tertiaryNodes.setField(t,2,e)}setRptr_(t,e){this.m_tertiaryNodes.setField(t,3,e)}setPptr_(t,e){this.m_tertiaryNodes.setField(t,4,e)}setSecondaryToInterval_(t,e){this.m_intervalNodes.setField(t,0,e)}addEndIndex_(t,e){let s=-1;return s=this.m_bOfflineDynamic?this.m_secondaryTreaps.addElement(e,t):this.m_secondaryLists.addElement(t,e),s}setLeftEnd_(t,e){this.m_intervalNodes.setField(t,1,e)}setRightEnd_(t,e){this.m_intervalNodes.setField(t,2,e)}getFirst_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getFirst(t):this.m_secondaryLists.getFirst(t)}getLast_(t){return this.m_bOfflineDynamic?this.m_secondaryTreaps.getLast(t):this.m_secondaryLists.getLast(t)}static isLeft_(t){return!(1&t)}static isRight_(t){return!(1&~t)}getDiscriminantIndex1_(t){return this.m_tertiaryNodes.getField(t,0)}getSecondaryFromTertiary_(t){return this.m_tertiaryNodes.getField(t,1)}getLptr_(t){return this.m_tertiaryNodes.getField(t,2)}getRptr_(t){return this.m_tertiaryNodes.getField(t,3)}getPptr_(t){return this.m_tertiaryNodes.getField(t,4)}getSecondaryFromInterval_(t){return this.m_intervalNodes.getField(t,0)}getLeftEnd_(t){return this.m_intervalNodes.getField(t,1)}getRightEnd_(t){return this.m_intervalNodes.getField(t,2)}getMin_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmin:this.m_intervals[t].vmin}getMax_(t){return this.m_bEnvelopesRef?this.m_envelopesRef[t].xmax:this.m_intervals[t].vmax}sortEndIndices_(t,e,s){const i=this,n={userSort(t,e,s){i.sortEndIndicesHelper_(s,t,e)},getValue:t=>i.getValue_(t)};(new Hs).sort(t,e,s,n)}sortEndIndicesHelper_(t,e,s){t.sort(e,s,((t,e)=>{const s=this.getValue_(t),i=this.getValue_(e);return s<i||s===i&&js.isLeft_(t)&&js.isRight_(e)?-1:1}))}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return js.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return js.isLeft_(t)?e.xmin:e.xmax}checkValidation_(){return t(0),!1}checkValidationHelper_(e){return t(0),0}}class Us{constructor(t,e,s){this.m_query=kt.constructEmpty(),this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_nextEndHandle=-1,this.m_tertiaryStack=[],this.m_functionIndex=0,this.m_intervalTree=t,this.m_functionStack=new Array(2),this.m_functionStack[0]=this.nullFunc_,this.m_functionStack[1]=this.nullFunc_,void 0!==e&&this.resetIterator(e,s)}nullFunc_(){return t(0),!1}resetIterator(t,e){if("number"==typeof t){const s=new kt;s.setCoords(t,t),this.resetIterator(s,e)}else void 0===e&&(e=0),this.m_query.vmin=t.vmin-e,this.m_query.vmax=t.vmax+e,this.m_tertiaryStack.length=0,this.m_functionIndex=0,this.m_functionStack[0]=this.initialize_}next(){if(this.m_intervalTree.m_bConstructionEnded||y(""),this.m_functionIndex<0)return-1;for(;this.m_fi=this.m_functionStack[this.m_functionIndex],this.m_fi(););return-1!==this.m_currentEndHandle?this.getCurrentEndIndex_()>>1:-1}initialize_(){return this.m_tertiaryHandle=-1,this.m_nextTertiaryHandle=-1,this.m_forkedHandle=-1,this.m_currentEndHandle=-1,this.m_intervalTree.m_tertiaryNodes.size()>0?(this.m_functionStack[0]=this.pIn_,this.m_nextTertiaryHandle=this.m_intervalTree.m_root,!0):(this.m_functionIndex=-1,!1)}pIn_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}if(t<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}this.m_functionStack[this.m_functionIndex]=this.pL_,this.m_forkedHandle=this.m_tertiaryHandle;const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_),!0}pL_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pR_,this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_forkedHandle),!0;if(this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle)<this.m_query.vmin){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getLast_(t),this.m_functionStack[++this.m_functionIndex]=this.right_),!0}const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_);const e=this.m_intervalTree.getRptr_(this.m_tertiaryHandle);return-1!==e&&this.m_tertiaryStack.push(e),!0}pR_(){if(this.m_tertiaryHandle=this.m_nextTertiaryHandle,-1===this.m_tertiaryHandle)return this.m_functionStack[this.m_functionIndex]=this.pT_,!0;const t=this.m_intervalTree.getDiscriminant_(this.m_tertiaryHandle);if(this.m_query.vmax<t){const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return this.m_nextTertiaryHandle=this.m_intervalTree.getLptr_(this.m_tertiaryHandle),-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.left_),!0}const e=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);this.m_nextTertiaryHandle=this.m_intervalTree.getRptr_(this.m_tertiaryHandle),-1!==e&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(e),this.m_functionStack[++this.m_functionIndex]=this.all_);const s=this.m_intervalTree.getLptr_(this.m_tertiaryHandle);return-1!==s&&this.m_tertiaryStack.push(s),!0}pT_(){if(0===this.m_tertiaryStack.length)return this.m_functionIndex=-1,this.m_currentEndHandle=-1,!1;this.m_tertiaryHandle=this.m_tertiaryStack.at(-1),this.m_tertiaryStack.pop();const t=this.m_intervalTree.getSecondaryFromTertiary_(this.m_tertiaryHandle);return-1!==t&&(this.m_nextEndHandle=this.m_intervalTree.getFirst_(t),this.m_functionStack[++this.m_functionIndex]=this.all_),-1!==this.m_intervalTree.getLptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getLptr_(this.m_tertiaryHandle)),-1!==this.m_intervalTree.getRptr_(this.m_tertiaryHandle)&&this.m_tertiaryStack.push(this.m_intervalTree.getRptr_(this.m_tertiaryHandle)),!0}left_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&js.isLeft_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())<=this.m_query.vmax?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}right_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&js.isRight_(this.getCurrentEndIndex_())&&this.m_intervalTree.getValue_(this.getCurrentEndIndex_())>=this.m_query.vmin?(this.m_nextEndHandle=this.getPrev_(),!1):(this.m_functionIndex--,!0)}all_(){return this.m_currentEndHandle=this.m_nextEndHandle,-1!==this.m_currentEndHandle&&js.isLeft_(this.getCurrentEndIndex_())?(this.m_nextEndHandle=this.getNext_(),!1):(this.m_functionIndex--,!0)}getNext_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getNext(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getNext(this.m_currentEndHandle)}getPrev_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getPrev(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getPrev(this.m_currentEndHandle)}getCurrentEndIndex_(){return this.m_intervalTree.m_bOfflineDynamic?this.m_intervalTree.m_secondaryTreaps.getElement(this.m_currentEndHandle):this.m_intervalTree.m_secondaryLists.getData(this.m_currentEndHandle)}}class Qs{constructor(){this.m_tolerance=0,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_intervalTreeRed=null,this.m_intervalTreeBlue=null,this.m_iteratorRed=null,this.m_iteratorBlue=null,this.m_envelopesRed=[],this.m_envelopesBlue=[],this.m_elementsRed=[],this.m_elementsBlue=[],this.m_sortedEndIndicesRed=new Fs(0),this.m_sortedEndIndicesBlue=new Fs(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new Zs,this.m_queuedIndicesRed=[],this.m_queuedIndicesBlue=[],this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_bDone=!0,this.m_function=this.nullFunc_,this.reset_()}startConstruction(){this.reset_(),this.m_bAddRedRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addEnvelope(t,e){this.m_bAddRedRed||y(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new as(e))}endConstruction(){this.m_bAddRedRed||y(""),this.m_bAddRedRed=!1,this.m_envelopesRed.length>0&&(this.m_function=this.initialize_,this.m_bDone=!1)}startRedConstruction(){this.reset_(),this.m_bAddRed=!0,this.m_elementsRed.length=0,this.m_envelopesRed.length=0}addRedEnvelope(t,e){this.m_bAddRed||y(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||y(""),this.m_bAddRed=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeBlue_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeRed_),this.m_bDone=!1)}startBlueConstruction(){this.reset_(),this.m_bAddBlue=!0,this.m_elementsBlue.length=0,this.m_envelopesBlue.length=0}addBlueEnvelope(t,e){this.m_bAddBlue||y(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||y(""),this.m_bAddBlue=!1,this.m_envelopesRed.length>0&&this.m_envelopesBlue.length>0&&(this.m_function===this.nullFunc_||this.m_function===this.initializeRed_?this.m_function=this.initializeRedBlue_:this.m_function!==this.initializeRedBlue_&&(this.m_function=this.initializeBlue_),this.m_bDone=!1)}next(){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}getHandleA(){return this.m_envelopeHandleA}getHandleB(){return this.m_envelopeHandleB}setTolerance(t){this.m_tolerance=t}getEnvelope(e){return t(0),{}}getElement(t){return this.m_elementsRed[t]}getRedEnvelope(t){return this.m_envelopesRed[t]}getBlueEnvelope(t){return this.m_envelopesBlue[t]}getRedElement(t){return this.m_elementsRed[t]}getBlueElement(t){return this.m_elementsBlue[t]}isTop_(t){return!(1&~t)}isBottom_(t){return!(1&t)}reset_(){this.m_bAddRed=!1,this.m_bAddBlue=!1,this.m_bAddRedRed=!1,this.m_sweepIndexRed=-1,this.m_sweepIndexBlue=-1,this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_bDone=!0}initialize_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new js(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),this.m_sortedEndIndicesRed.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,2*this.m_envelopesRed.length,!0),this.m_sweepIndexRed=2*this.m_envelopesRed.length,this.m_function=this.sweep_,!0}initializeRed_(){return t(0),!1}initializeBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new js(!0)),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null==this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,this.resetRed_()}initializeRedBlue_(){if(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_envelopesRed.length<10||this.m_envelopesBlue.length<10)return this.m_sweepIndexRed=this.m_envelopesRed.length,this.m_function=this.sweepRedBlueBruteForce_,!0;this.m_intervalTreeRed||(this.m_intervalTreeRed=new js(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new js(!0)),this.m_intervalTreeRed.addEnvelopesRef(this.m_envelopesRed),this.m_intervalTreeBlue.addEnvelopesRef(this.m_envelopesBlue),null===this.m_iteratorRed&&(this.m_iteratorRed=this.m_intervalTreeRed.getIterator()),null===this.m_iteratorBlue&&(this.m_iteratorBlue=this.m_intervalTreeBlue.getIterator()),this.m_sortedEndIndicesRed.resize(0),this.m_sortedEndIndicesBlue.resize(0);for(let t=0;t<2*this.m_envelopesRed.length;t++)this.m_sortedEndIndicesRed.add(t);for(let t=0;t<2*this.m_envelopesBlue.length;t++)this.m_sortedEndIndicesBlue.add(t);return this.sortYEndIndices_(this.m_sortedEndIndicesRed,0,this.m_sortedEndIndicesRed.size(),!0),this.sortYEndIndices_(this.m_sortedEndIndicesBlue,0,this.m_sortedEndIndicesBlue.size(),!1),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_function=this.sweepRedBlue_,!0}sweep_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);const s=kt.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);return this.m_iteratorRed.resetIterator(s,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterate_,!0}sweepBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_sweepIndexRed,this.m_function=this.iterateBruteForce_,!0)}sweepRedBlueBruteForce_(){return-1==--this.m_sweepIndexRed?(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1):(this.m_envelopeHandleA=this.m_sweepIndexRed,this.m_sweepIndexBlue=this.m_envelopesBlue.length,this.m_function=this.iterateRedBlueBruteForce_,!0)}sweepRedBlue_(){const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed-1),e=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue-1),s=this.getAdjustedValue_(t,!0),i=this.getAdjustedValue_(e,!1);return s>i?this.sweepRed_():s<i?this.sweepBlue_():this.isTop_(t)?this.sweepRed_():this.isTop_(e)?this.sweepBlue_():this.sweepRed_()}sweepRed_(){const t=this.m_sortedEndIndicesRed.read(--this.m_sweepIndexRed),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListRed&&-1!==this.m_queuedIndicesRed[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,this.m_queuedIndicesRed[e]),this.m_queuedIndicesRed[e]=-1):this.m_intervalTreeRed.remove(e),0!==this.m_sweepIndexRed||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListBlue&&this.m_queuedEnvelopes.getListSize(this.m_queuedListBlue)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListBlue);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeBlue.insert(e),this.m_queuedIndicesBlue[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,t),t=s}}if(this.m_intervalTreeBlue.size()>0){const t=kt.construct(this.m_envelopesRed[e].xmin,this.m_envelopesRed[e].xmax);this.m_iteratorBlue.resetIterator(t,this.m_tolerance),this.m_envelopeHandleA=e,this.m_function=this.iterateBlue_}else-1===this.m_queuedListRed&&(this.m_queuedIndicesRed.length=this.m_envelopesRed.length,this.m_queuedIndicesRed.fill(-1),this.m_queuedListRed=this.m_queuedEnvelopes.createList(1)),this.m_queuedIndicesRed[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListRed,e),this.m_function=this.sweepRedBlue_;return!0}sweepBlue_(){const t=this.m_sortedEndIndicesBlue.read(--this.m_sweepIndexBlue),e=t>>1;if(this.isBottom_(t))return-1!==this.m_queuedListBlue&&-1!==this.m_queuedIndicesBlue[e]?(this.m_queuedEnvelopes.deleteElement(this.m_queuedListBlue,this.m_queuedIndicesBlue[e]),this.m_queuedIndicesBlue[e]=-1):this.m_intervalTreeBlue.remove(e),0!==this.m_sweepIndexBlue||(this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1,this.m_bDone=!0,!1);if(-1!==this.m_queuedListRed&&this.m_queuedEnvelopes.getListSize(this.m_queuedListRed)>0){let t=this.m_queuedEnvelopes.getFirst(this.m_queuedListRed);for(;-1!==t;){const e=this.m_queuedEnvelopes.getData(t);this.m_intervalTreeRed.insert(e),this.m_queuedIndicesRed[e]=-1;const s=this.m_queuedEnvelopes.getNext(t);this.m_queuedEnvelopes.deleteElement(this.m_queuedListRed,t),t=s}}if(this.m_intervalTreeRed.size()>0){const t=kt.construct(this.m_envelopesBlue[e].xmin,this.m_envelopesBlue[e].xmax);this.m_iteratorRed.resetIterator(t,this.m_tolerance),this.m_envelopeHandleB=e,this.m_function=this.iterateRed_}else-1===this.m_queuedListBlue&&(this.m_queuedIndicesBlue.length=this.m_envelopesBlue.length,this.m_queuedIndicesBlue.fill(-1),this.m_queuedListBlue=this.m_queuedEnvelopes.createList(0)),this.m_queuedIndicesBlue[e]=this.m_queuedEnvelopes.addElement(this.m_queuedListBlue,e),this.m_function=this.sweepRedBlue_;return!0}iterate_(){if(this.m_envelopeHandleB=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweep_,!0}iterateRed_(){if(this.m_envelopeHandleA=this.m_iteratorRed.next(),-1!==this.m_envelopeHandleA)return!1;this.m_envelopeHandleA=-1,this.m_envelopeHandleB=-1;const t=this.m_sortedEndIndicesBlue.read(this.m_sweepIndexBlue)>>1;return this.m_intervalTreeBlue.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBlue_(){if(this.m_envelopeHandleB=this.m_iteratorBlue.next(),-1!==this.m_envelopeHandleB)return!1;const t=this.m_sortedEndIndicesRed.read(this.m_sweepIndexRed)>>1;return this.m_intervalTreeRed.insert(t),this.m_function=this.sweepRedBlue_,!0}iterateBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesRed[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}iterateRedBlueBruteForce_(){if(-1==--this.m_sweepIndexBlue)return this.m_function=this.sweepRedBlueBruteForce_,!0;const t=this.m_envelopesRed[this.m_sweepIndexRed].clone(),e=this.m_envelopesBlue[this.m_sweepIndexBlue];return t.inflateCoords(this.m_tolerance,this.m_tolerance),!t.isIntersecting(e)||(this.m_envelopeHandleB=this.m_sweepIndexBlue,!1)}resetRed_(){return this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),this.m_intervalTreeRed.size()>0&&this.m_intervalTreeRed.reset(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_bDone=!1,!0}resetBlue_(){return this.m_sweepIndexBlue=this.m_sortedEndIndicesBlue.size(),this.m_intervalTreeBlue.size()>0&&this.m_intervalTreeBlue.reset(),-1!==this.m_queuedListBlue&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListBlue),this.m_queuedIndicesBlue.length=0,this.m_queuedListBlue=-1),this.m_bDone=!1,!0}nullFunc_(){return t(0),!1}sortYEndIndices_(t,e,s,i){const n=this,r={userSort(t,e,s){n.sortYEndIndicesHelper_(s,t,e,i)},getValue:t=>n.getAdjustedValue_(t,i)};(new Hs).sort(t,e,s,r)}sortYEndIndicesHelper_(t,e,s,i){t.sort(e,s,((t,e)=>{const s=this.getAdjustedValue_(t,i),n=this.getAdjustedValue_(e,i);return s<n||s===n&&this.isBottom_(t)&&this.isTop_(e)?-1:1}))}getAdjustedValue_(t,e){const s=.5*this.m_tolerance;if(e){const e=this.m_envelopesRed[t>>1];return this.isBottom_(t)?e.ymin-s:e.ymax+s}const i=this.m_envelopesBlue[t>>1];return this.isBottom_(t)?i.ymin-s:i.ymax+s}}function Ks(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function $s(t,e){const s=as.constructEmpty();t.queryLooseEnvelope(s);const i=as.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function Js(t,e,s){const i=as.constructEmpty();i.setFromPoints(t,e);return ri(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function ti(t,e,s){return ri(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function ei(t,e,s){return ri(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function si(t,e,s){return ei(t,e.queryInterval(1,0),s)}function ii(t,e,s){const i=as.constructEmpty();return e.queryEnvelope(i),ti(t,i,s)}function ni(t,e,s){return ri(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ri(t,e,s,i,n){const r=new M(0,0);if(null!==e&&(r.tolerance=e.getTolerance(t),(!n||i)&&null!==e)){const s=e.getResolution(t);r.resolution=s,i&&(r.resolution*=2)}i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01);return r.total()<s?new M(s,0):r}function oi(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function ai(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function hi(t){return t>=3}function mi(t,e){const s=[0];return t.getImpl().getIsSimple(e,s)>=3}function ui(t){return t>=4}function li(t,e){return t===r.enumPolygon?hi(e):e>=1}function ci(t,e,s){const i=as.constructEmpty(),n=as.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=as.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=e.querySegmentIterator(),h=as.constructEmpty(),m=as.constructEmpty(),u=new Qs;u.setTolerance(s);let l=!1;for(u.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(h),h.isIntersecting(r)&&(l=!0,u.addRedEnvelope(o.getStartPointIndex(),h))}if(u.endRedConstruction(),!l)return null;let c=!1;for(u.startBlueConstruction();a.nextPath();)for(;a.hasNextSegment();){a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(r)&&(c=!0,u.addBlueEnvelope(a.getStartPointIndex(),m))}return u.endBlueConstruction(),c?u:null}function di(t,e,s,i,n){t.getGeometryType(),e.getGeometryType();const r=as.constructEmpty(),o=as.constructEmpty();t.queryLooseEnvelope(r),e.queryLooseEnvelope(o),r.inflateCoords(s,s),o.inflateCoords(s,s);const a=as.constructEmpty();a.setCoords({env2D:r}),a.intersect(o);const h=new Qs;h.setTolerance(s);let m=!1;h.startRedConstruction();for(let l=0,c=t.getPathCount();l<c;l++)t.queryLoosePathEnvelope(l,r),r.isIntersecting(a)&&(m=!0,h.addRedEnvelope(l,r));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();for(let l=0,c=e.getPathCount();l<c;l++)e.queryLoosePathEnvelope(l,o),o.isIntersecting(a)&&(u=!0,h.addBlueEnvelope(l,o));return h.endBlueConstruction(),u?h:null}function _i(t,e,s){const i=as.constructEmpty(),n=as.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=as.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=t.querySegmentIterator(),a=new Qs;a.setTolerance(s);let h=!1;for(a.startRedConstruction();o.nextPath();)for(;o.hasNextSegment();){o.nextSegment().queryLooseEnvelope(i),i.isIntersecting(r)&&(h=!0,a.addRedEnvelope(o.getStartPointIndex(),i))}if(a.endRedConstruction(),!h)return null;let m=!1;a.startBlueConstruction();for(let u=0,l=e.getPointCount();u<l;u++){const t=e.getXY(u);r.contains(t)&&(m=!0,a.addBlueEnvelope(u,as.construct(t.x,t.y,t.x,t.y)))}return a.endBlueConstruction(),m?a:null}function gi(t,e,s){const i=as.constructEmpty(),n=as.constructEmpty();t.queryEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=as.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const o=new Qs;o.setTolerance(s);let a=!1;o.startRedConstruction();const h=new os;for(let l=0,c=t.getPointCount();l<c;l++)t.queryXY(l,h),r.contains(h)&&(a=!0,o.addRedEnvelope(l,as.construct(h.x,h.y,h.x,h.y)));if(o.endRedConstruction(),!a)return null;let m=!1;o.startBlueConstruction();const u=new os;for(let l=0,c=e.getPointCount();l<c;l++)e.queryXY(l,u),r.contains(u)&&(m=!0,o.addBlueEnvelope(l,as.construct(u.x,u.y,u.x,u.y)));return o.endBlueConstruction(),m?o:null}function pi(t,e){return null}function fi(t,e){return null}function xi(t,e,s,i,n){(e<0||s<0||i<1||e+i*(s-1)+1>t.size())&&f("Index out of bound");for(let r=e,o=e+i*(s-1)+1;r<o;r+=i)t.writeAsDbl(r,n(t.readAsDbl(r)))}function yi(e,s,i){const n=e.getDescription().getTotalComponentCount();t(n<=i),e.setX(s[0]),e.setY(s[1]),ze(e.getAttributeArray(),s,0,2,n-2)}var vi=gs;const Pi="can not assign an empty point to a vertex";class bi{constructor(t){if(void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=vs.getDefaultDescription2D(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new Bs,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new Es,this.m_pointCount=t.move.m_pointCount,this.m_reservedPointCount=t.move.m_reservedPointCount,this.m_flags=t.move.m_flags,this.m_bFillRule=t.move.m_bFillRule,this.m_bPathStarted=t.move.m_bPathStarted,this.m_bPolygon=t.move.m_bPolygon,this.m_simpleTolerance=t.move.m_simpleTolerance;else{const e=void 0!==t&&t.vd?t.vd:vs.getDefaultDescription2D();this.m_description=e,this.m_vertexAttributes=new Bs,this.m_envelopeData=new Es,this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_flags=4063,this.m_bFillRule=this.m_bPathStarted=this.m_bPolygon=!1,this.m_simpleTolerance=0,void 0!==t&&t.copy&&t.copy.copyTo(this)}}equalsBase(t,e){if(!l(t.getGeometryType()))return!1;const s=t;if(this===s)return!0;if(!this.m_description.equals(s.getDescription()))return!1;if(this.isEmptyImpl()!==s.isEmptyImpl())return!1;if(this.isEmptyImpl())return!0;const i=this.getPointCount();if(i!==s.getPointCount())return!1;for(let n=0;n<this.m_description.getAttributeCount();n++){const t=this.m_description.getSemantics(n),r=this.getAttributeStreamRef(t),o=s.getAttributeStreamRef(t),a=vi.getComponentCount(t);if(!r.equals(o,0,i*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}vertexCount(){return t(0),0}transformAttribute(t,e,s,i,n){this.addAttribute(t),this.isEmpty()||0===s&&1===i||(xi(this.getAttributeStreamRef(t),e,this.getPointCount(),vi.getComponentCount(t),Ks(s,i,n)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=vs.getMergedVertexDescription(e,t);this.assignVertexDescription(s)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=vs.removeSemanticsFromVertexDescription(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=vs.getDefaultDescription2D();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||f("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||f("stream"),e&&vi.getPersistence(t)!==e.getPersistence()&&f(""),this.addAttribute(t);const s=this.m_description.getAttributeIndex(t);this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_vertexAttributes.set(s,e),this.notifyModifiedFlags(2001)}notifyModifiedFlags(t){65535===t&&(this.m_reservedPointCount=-1,this.notifyModifiedAllImpl()),this.setDirtyFlagProtected(t,!0),this.clearAccelerators(),32&t&&this.verifyAllStreamsAfterSizeChange()}notifyModified(){this.notifyModifiedFlags(2001)}getPointCount(){return this.m_pointCount}getPointByVal(t,e){const s=e;s.assignVertexDescription(this.m_description);for(let i=0;i<this.m_description.getAttributeCount();i++){const e=this.m_description.getSemantics(i);for(let n=0,r=vi.getComponentCount(e);n<r;n++){const o=this.m_vertexAttributes.get(i).readAsDbl(r*t+n);s.setAttributeBasic(e,n,o)}}}setPointByVal(t,e){const s=e;s.isEmpty()&&f(Pi);const i=s.getDescription();i!==this.m_description&&this.mergeVertexDescription(i);const n=this.m_vertexAttributes.get(0);n.write(2*t,s.getX()),n.write(2*t+1,s.getY());for(let r=1,o=this.m_description.getAttributeCount();r<o;r++){const e=this.m_description.getSemantics(r),i=vi.getComponentCount(e);for(let n=0;n<i;n++){const o=s.getAttributeAsDbl(e,n);this.m_vertexAttributes.get(r).writeAsDbl(t*i+n,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(e,s,i,n){t(0)}getPointByValAsArray(e,s,i,n){t(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const i=vi.getComponentCount(t);s>=i&&b("");const n=this.m_description.getAttributeIndex(t);return n>=0?this.m_vertexAttributes.get(n).readAsDbl(e*i+s):vi.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,i){const n=vi.getComponentCount(t);i<n&&b("");const r=this.m_description.getAttributeIndex(t);if(r>=0){const t=e*n,i=this.m_vertexAttributes.get(r);for(let e=0;e<n;e++)s[e]=i.readAsDbl(t+e)}else{const e=vi.getDefaultValue(t);for(let t=0;t<n;t++)s[t]=e}}getAttributeAsInt(e,s,i){return t(0),0}queryAttributeAsInt(e,s,i,n){t(0)}setAttribute(t,e,s,i){const n=vi.getComponentCount(t);s>=n&&b(""),this.addAttribute(t);const r=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(r).writeAsDbl(e*n+s,i)}setAttributeFromArray(t,e,s,i){(e<0||e>=this.m_pointCount)&&b("");const n=vi.getComponentCount(t);i!==n&&b(""),this.addAttribute(t);const r=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const o=this.m_vertexAttributes.get(r);for(let a=0;a<n;++a)o.writeAsDbl(e*n+a,s[a])}getXY(t){return this.m_vertexAttributes.get(0).readPoint2D(2*t)}queryXY(t,e){return this.m_vertexAttributes.get(0).queryPoint2D(2*t,e)}setXY(t,e){this.m_vertexAttributes.get(0).writePoint2D(2*t,e),this.notifyModifiedFlags(2001)}setXYCoords(t,e,s){const i=this.m_vertexAttributes.get(0);i.write(2*t,e),i.write(2*t+1,s),this.notifyModifiedFlags(2001)}getXYZ(t){const e=this.m_vertexAttributes.get(0),s=ps.getNAN();return s.x=e.read(2*t),s.y=e.read(2*t+1),this.m_description.hasAttribute(1)?s.z=this.m_vertexAttributes.get(1).read(t):s.z=vi.getDefaultValue(1),s}setXYZ(e,s){t(0)}queryEnvelope(t){t instanceof as||t instanceof Vs?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(e,s){return t(0),new kt(0,0)}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(e,s,i){t(0)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=vi.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let r=0;r<i;r++)if(1===n.getPersistence()){const t=n;for(let n=0,r=this.m_pointCount*i;n<r;n++){const i=t.read(n);Number.isNaN(i)&&(t.write(n,e),s=!0)}}else for(let t=0,o=this.m_pointCount*i;t<o;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(e){return t(0),0}setEnvelopeForImport(e){t(0)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&f(""),this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,i){let n=i<0?this.m_pointCount:i;if(n=Math.min(n,s+e),(s<0||n<s||this.m_pointCount>0&&s>=this.m_pointCount)&&f(""),0===this.m_pointCount)return n;const r=this.getAttributeStreamRef(0);for(let o=2*s,a=2*(n-s),h=0;o<a;o+=2,h++)t[h]=r.readPoint2D(o);return n}queryCoordinates3D(t,e,s,i){let n=i<0?this.m_pointCount:i;if(n=Math.min(n,s+e),(s<0||n<s||this.m_pointCount>0&&s>=this.m_pointCount)&&f(""),0===this.m_pointCount)return n;const r=this.getAttributeStreamRef(0);let o=null;const a=vi.getDefaultValue(1),h=this.m_description.hasAttribute(1);h&&(o=this.getAttributeStreamRef(1));let m=0;for(let u=s;u<n;u++,m++)t[m].x=r.read(2*u),t[m].y=r.read(2*u+1),t[m].z=h?o.read(u):a;return n}clearAndSetDirtyFlagProtected(t,e){let s=0;const i=t&~e,n=e|i;s=this.m_flags,(s&n)!==e&&(this.m_flags=s&~i|e)}getIsSimple(t,e){e[0]=0;let s=-1;const i=this.m_flags,n=this.m_simpleTolerance;if(!(1&i)){s=(14&i)>>1,e[0]=n,n<t&&(s=-1)}return s}setIsSimple(e,s,i=!1){if(2===e?t(this.getGeometryType()===r.enumPolyline):1===e?t(this.getGeometryType()===r.enumMultiPoint||this.getGeometryType()===r.enumPolyline):3===e&&t(this.getGeometryType()===r.enumPolygon),-1===e)this.setDirtyFlagProtected(17,!0);else{let t=e<<1;i||(t|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,t),this.m_simpleTolerance!==s&&(this.m_simpleTolerance=s)}}attributeStreamIsAllocated(e){return t(0),!1}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(e,s=!1){s&&this.hasDirtyFlag(32)&&C("Cannot do shallow clone on unprepared geometry");const i=e,n=this.getGeometryType(),o=i.getGeometryType();t(n===o||n===r.enumPolygon&&o===r.enumPolyline,"failure in copyToUnchcked"),i.clearAccelerators(),i.m_description=this.m_description,i.m_vertexAttributes.destroyAndSetSize(0),i.m_envelopeData.releaseAttributes();const a=this.m_description.getAttributeCount(),h=new Bs;if(!this.m_vertexAttributes.empty()){h.destroyAndSetSize(a);for(let t=0;t<a;t++)if(this.m_vertexAttributes.get(t))if(s)h.set(t,this.m_vertexAttributes.get(t));else{const e=vi.getComponentCount(this.m_description.getSemantics(t));h.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,i.m_envelopeData),i.m_flags=this.m_flags,i.m_simpleTolerance=this.m_simpleTolerance,n!==o){const t=[0];i.getIsSimple(0,t)>=3?i.setIsSimple(1,t[0]):i.setIsSimple(-1,0)}i.m_vertexAttributes.swap(h),h.destroyAndSetSize(0),i.m_pointCount=this.m_pointCount,i.hasDirtyFlag(32)?(t(!s),i.m_reservedPointCount=-1):i.m_reservedPointCount=i.m_pointCount;try{this.copyToImpl(i,s)}catch(m){throw i.setEmpty(),m}i.verifyAllStreamsAfterSizeChange()}getAccelerators(){return null}clearAccelerators(){}ensureUniqueAccelerators(){t(0)}interpolateTwoVertices(e,s,i,n){(e<0||e>=this.m_pointCount)&&b(""),(s<0||s>=this.m_pointCount)&&b(""),n.assignVertexDescription(this.m_description);const r=new Array(vi.maxComponentCount()),o=new Array(vi.maxComponentCount()),a=_s();let h=0;for(let m=0;m<this.m_description.getAttributeCount();m++){const n=this.m_description.getSemantics(m),u=vi.getInterpolation(n),l=vi.getComponentCount(n),c=vi.getDefaultValue(n);this.queryAttributeAsDbl(n,e,r,l),this.queryAttributeAsDbl(n,s,o,l),t(h+l<=ds),Le(u,r,o,a,h,l,i,c),h+=l}yi(n,a,h)}getShortestDistance(t,e){return os.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return os.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&f(),(t=Math.ceil(t))===this.m_pointCount)return;this.m_pointCount=t;const e=this.m_pointCount<=this.m_reservedPointCount?2001:4095;this.notifyModifiedFlags(e)}verifyPointIndex(e){t(0)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=xs();vs.mapAttributes(t,this.m_description,e);const s=new Bs;s.destroyAndSetSize(t.getAttributeCount());for(let i=0;i<t.getAttributeCount();i++){const t=e[i];-1!==t?s.set(i,this.m_vertexAttributes.get(t)):this.m_reservedPointCount=-1}s.swap(this.m_vertexAttributes)}this.m_description=t,this.m_envelopeData.releaseAttributes(),this.notifyModifiedFlags(4095)}hasDirtyFlag(t){return!!(this.m_flags&t)}setDirtyFlagProtected(t,e){e?this.m_flags|=t:this.m_flags&=~t}notifyModifiedAllImpl(){}verifyAllStreamsAfterSizeChange(){this.hasDirtyFlag(32)&&this.verifyAllStreamsAfterSizeChangeImpl()}verifyAllStreamsAfterSizeChangeImpl(){if(this.hasDirtyFlag(32)){if(this.m_reservedPointCount<this.m_pointCount){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),this.m_reservedPointCount=Number.MAX_SAFE_INTEGER;let t=0;t=this.m_pointCount<4?3:this.m_pointCount<=128?2*this.m_pointCount:(4*this.m_pointCount+2)/3;for(let e=0;e<this.m_description.getAttributeCount();e++){const s=this.m_description.getSemantics(e);let i=0;if(null!==this.m_vertexAttributes.get(e)){const n=vi.getComponentCount(s);i=this.m_vertexAttributes.get(e).size()/n,i<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*n,vi.getDefaultValue(s)),i=t)}else this.m_vertexAttributes.set(e,As(s,t)),i=t;i<this.m_reservedPointCount&&(this.m_reservedPointCount=i)}}this.verifyStreamsAfterSizeChangeExtraImpl(),this.setDirtyFlagProtected(32,!1)}}verifyStreamsAfterSizeChangeExtraImpl(){}updateAllDirtyIntervals(t){if(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128)){if(this.isEmpty())return this.hasDirtyFlag(192)&&this.m_envelopeData.setEmpty(this.m_description),void this.setDirtyFlagProtected(192,!1);const e=this.updateXYImpl(t),s=new Cs({vd:this.m_description});s.setEnvelope(e);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=vi.getComponentCount(e),n=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const r=new kt;r.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=n.readAsDbl(e*i+t);r.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,r)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new Es({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=as.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(e){t(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof as?t.assign(this.m_envelopeData.m_envelope2D):this.m_envelopeData.queryEnvelope3D(this.m_description,t)}updateEnvelope(t){this.updateAllDirtyIntervals(!0),t.assign(this.m_envelopeData.m_envelope2D)}setEmptyImpl(){this.m_pointCount=0,this.m_reservedPointCount=-1,this.m_vertexAttributes.destroyAndSetSize(0),this.notifyModifiedFlags(4095)}clearDirtyIntervalsFlag(t){this.setDirtyFlagProtected(192,!1)}reserveImpl(t,e){if(t<0&&f(""),0===t)return;let s=t=Math.ceil(t);if(this.m_reservedPointCount<s){this.m_vertexAttributes.empty()&&this.m_vertexAttributes.destroyAndSetSize(this.m_description.getAttributeCount()),e?(null===this.m_vertexAttributes.get(0)&&this.m_vertexAttributes.set(0,Ts(0,0)),this.m_vertexAttributes.get(0).resizeRounded(2*s),s=this.m_vertexAttributes.get(0).size()>>1):null===this.m_vertexAttributes.get(0)?this.m_vertexAttributes.set(0,Ts(0,s)):this.m_vertexAttributes.get(0).resize(2*s);for(let t=1;t<this.m_description.getAttributeCount();t++){const e=this.m_description.getSemantics(t),i=vi.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*i):this.m_vertexAttributes.set(t,Ts(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&f(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&v("")}}var Ei=gs;class Ci{constructor(t){if(this.m_description=null,this.x=Number.NaN,this.y=Number.NaN,this.m_attribs=null,t){if(!t.copy)return t.move?(this.m_description=t.move.m_description,t.move.m_description=null,this.m_attribs=t.move.m_attribs,t.move.m_attribs=null,this.x=t.move.x,void(this.y=t.move.y)):t.vd?(this.m_description=t.vd,void(t.attribBuffer?(this.m_attribs=t.attribBuffer,t.initDefaultValues&&this.setDefaultAttributeValues()):this.ensureAttributes())):t.pt?(this.m_description=vs.getDefaultDescription2D(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=vs.getDefaultDescription3D(),this.ensureAttributes(),this.setXYZ(new ps(t.x,t.y,t.z))):(this.m_description=vs.getDefaultDescription2D(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=vs.getDefaultDescription2D()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(e){return t(0),this}vertexCount(){return t(0),1}getXY(){return new os(this.x,this.y)}setXY(t){this.x=t.x,this.y=t.y}setXYCoords(t,e){this.x=t,this.y=e}getXYZ(){const t=new ps;return t.x=this.x,t.y=this.y,t.z=this.getZ(),t}setXYZ(t){this.addAttribute(1),this.x=t.x,this.y=t.y,this.m_attribs[0]=t.z}getX(){return this.x}setX(t){this.x=t}getY(){return this.y}setY(t){this.y=t}getZ(){return this.m_description.hasZ()?this.m_attribs[0]:Ei.getDefaultValue(1)}setZ(t){this.addAttribute(1),this.m_attribs[0]=t}getM(){return this.getAttributeAsDbl(2,0)}setM(t){this.addAttribute(2),this.m_description.hasZ()?this.m_attribs[1]=t:this.m_attribs[0]=t}getID(){return t(0),0}setID(e){t(0)}isEqualXY(e,s){return t(0),!1}isEqualXYCoords(t,e,s){return void 0===s&&(s=0),Math.abs(t-this.x)<=s&&Math.abs(e-this.y)<=s}getAttributeAsDbl(t,e){if(0===t){if(0===e)return this.x;if(1===e)return this.y;b("")}const s=Ei.getComponentCount(t);(e<0||e>=s)&&b("");const i=this.m_description.getAttributeIndex(t);return i>=0?this.m_attribs[this.m_description.getPointAttributeOffset(i)-2+e]:Ei.getDefaultValue(t)}getAttributeAsInt(t,e){return Math.trunc(this.getAttributeAsDbl(t,e))}setAttributeBasic(t,e,s){if(0===t)return void(0===e?this.x=s:1===e?this.y=s:b(""));const i=Ei.getComponentCount(t);(e<0||e>=i)&&b("");let n=this.m_description.getAttributeIndex(t);n<0&&(this.addAttribute(t),n=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]=s}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescription(e){t(0)}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(e){t(0)}dropAllAttributes(){const t=vs.getDefaultDescription2D();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return r.enumPoint}getDimension(){return 0}queryEnvelope(e){if(e instanceof Cs&&t(0,"not impl for wrapper type"),e instanceof Vs){if(this.isEmpty())return void e.setEmpty();const t=this.getXYZ();return e.xmin=t.x,e.ymin=t.y,e.zmin=t.z,e.xmax=t.x,e.ymax=t.y,void(e.zmax=t.z)}this.isEmpty()?e.setEmpty():(e.xmin=this.x,e.ymin=this.y,e.xmax=this.x,e.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(e,s){return t(0),new kt(0,0)}applyTransformation(e){t(0)}transformAttribute(e,s,i,n,r){t(0)}createInstance(){return this}copyTo(t){if(this===t)return;t.getGeometryType()!==r.enumPoint&&f();const e=t;e.x=this.x,e.y=this.y,this.m_attribs?(e.assignVertexDescription(this.m_description),e.m_attribs=this.m_attribs.slice()):(e.releaseAttributes(),e.assignVertexDescription(this.m_description))}isEmpty(){return Number.isNaN(this.x)||Number.isNaN(this.y)}setEmpty(){this.m_description||(this.m_description=vs.getDefaultDescription2D(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&ze(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,this.m_description.getTotalComponentCount()-2)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==r.enumPoint)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.isEmpty()!==s.isEmpty())return!1;if(this.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.x-s.x)>e)return!1;if(Math.abs(this.y-s.y)>e)return!1;for(let i=0,n=this.m_description.getTotalComponentCount()-2;i<n;i++)if(!O(this.m_attribs[i],s.m_attribs[i],e))return!1;return!0}getBoundary(){return null}clone(){return t(0),this}swap(e){t(0)}replaceNaNs(e,s){t(0)}lerp(e,s,i){return t(0),new Ci({x:0,y:0})}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?ze(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(e,s){return t(0),0}getImpl(){return this}hasNonLinearSegments(){return t(0),!1}mergeVertexDescriptionImpl(e){t(0)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=vs.getDefaultDescription2D());const e=xs();vs.mapAttributes(t,this.m_description,e);let s=null;t.getTotalComponentCount()-2>0&&(s=t.getDefaultPointAttributes().slice(2));for(let i=1,n=t.getAttributeCount();i<n;i++){const n=e[i];if(-1!==n){const e=this.m_description.getPointAttributeOffset(n)-2,r=t.getPointAttributeOffset(i)-2,o=Ei.getComponentCount(t.getSemantics(i));for(let t=0;t<o;t++)s[r+t]=this.m_attribs[e+t]}}this.m_attribs=s,this.m_description=t}ensureAttributes(){this.m_description.getTotalComponentCount()-2>0&&null===this.m_attribs&&(this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}queryValues(t,e){}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&ze(t.m_attribs,this.m_attribs,0,0,this.m_description.getTotalComponentCount()-2);else{let s=0;for(let i=1,n=e.getAttributeCount();i<n;i++){const n=e.getSemantics(i);let r=Ei.getComponentCount(n);if(this.m_description.hasAttribute(n)){let e=this.m_description.getPointAttributeOffset(this.m_description.getAttributeIndex(n))-2;for(;0!==r;)t.m_attribs[s++]=this.m_attribs[e++],r--}else{const e=Ei.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){}dbgDefaultAttribs(){}}Ci.type=r.enumPoint;class Di{constructor(){this.envAabb=as.constructEmpty(),this.envRot=as.constructEmpty()}static constructEmpty(){return new Di}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}isEmpty(){return t(0),!1}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:Si(t),y:wi(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergePoint2D(e){t(0)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Si(t),wi(t))}mergeCoords(e,s){t(0)}mergeW(e){t(0)}mergeE2D(e){t(0)}mergePoints(t,e){this.envAabb.mergePoints(t,e);for(let s=0;s<e;){if(!this.envRot.isEmpty()){for(let i=s;i<e;i++){const e=Si(t[i]),s=wi(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=Si(t[s]),i=wi(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Si(t),wi(t)))}isIntersectingW(t){return this.envAabb.isIntersecting(t.envAabb)&&this.envRot.isIntersecting(t.envRot)}containsW(t){return!(!this.envAabb.containsEnvelope(t.envAabb)||!this.envRot.containsEnvelope(t.envRot))}containsPoint2D(t){return this.isIntersectingPoint2D(t)}intersectW(t){const e=this.envAabb.intersect(t.envAabb),s=this.envRot.intersect(t.envRot);return e&&!s&&this.envAabb.setEmpty(),s&&!e&&this.envRot.setEmpty(),e&&s}inflate(t){this.envAabb.inflateCoords(t,t);const e=t*xt();this.envRot.inflateCoords(e,e),e<0&&Di.st_reduceEmpty(this)}sqrMaxMinDistance(e){return t(0),0}sqrMinDistance(e){return t(0),0}sqrMaxDistance(e){return t(0),0}getEnvelope2D(){return t(0),new as(this.envAabb)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}}function Si(t){return t.x-t.y}function wi(t){return t.x+t.y}class Ai{constructor(){this.x=Wt.getNAN(),this.y=Wt.getNAN()}static getNAN(){return new Ai}static constructPoint2D(t){const e=new Ai;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Ai;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Ai;return s.setCoordsE(t,e),s}get 0(){return this.x.clone()}set 0(t){this.x.setE(t)}get 1(){return this.y.clone()}set 1(t){this.y.setE(t)}clone(){return(new Ai).setE(this)}setCoords(t,e){return this.x.set(t),this.y.set(e),this}setCoordsE(t,e){return this.x.setE(t),this.y.setE(e),this}set(t){return this.x.set(t.x),this.y.set(t.y),this}setE(t){return this.x.setE(t.x),this.y.setE(t.y),this}setWithEps(t,e){return this.x.setWithEps(t.x,e),this.y.setWithEps(t.y,e),this}getUnitVector(){const t=this.clone();return t.normalize(),t}sqrLength(){return this.x.sqr().addE(this.y.sqr())}length(){return this.sqrLength().sqrt()}mulE(t){const e=new Ai;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Ai;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}divE(t){return this.clone().divThisE(t)}divThisE(t){return this.x.divThisE(t),this.y.divThisE(t),this}normalize(){const t=this.length();0===t.value()?(this.x=Qt.clone(),this.y=Ut.clone()):(this.x.divThisE(t),this.y.divThisE(t))}addE(t){return this.clone().addThisE(t)}addThisE(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this}subE(t){return this.clone().subThisE(t)}subThisE(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this}static distance(t,e){return t.subE(e).length()}negateThis(){return this.x.negateThis(),this.y.negateThis(),this}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)}isZero(){return this.x.isZero()&&this.y.isZero()}isTrueZero(){return!this.x.value()&&!this.y.value()}rotateDirect(t,e){const s=this.x.mulE(t).subThisE(this.y.mulE(e)),i=this.x.mulE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}rotateReverse(t,e){const s=this.x.mulE(t).addThisE(this.y.mulE(e)),i=this.x.negate().mulThisE(e).addThisE(this.y.mulE(t));return this.x.setE(s),this.y.setE(i),this}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y))}crossProduct(t){return this.x.mulE(t.y).subE(this.y.mulE(t.x))}value(){return os.construct(this.x.value(),this.y.value())}}class Ti{constructor(){this.a11=new Wt(1),this.a12=new Wt(0),this.a21=new Wt(0),this.a22=new Wt(1)}clone(){const t=new Ti;return t.a11.setE(this.a11),t.a12.setE(this.a12),t.a21.setE(this.a21),t.a22.setE(this.a22),t}assign(t){return this.a11.setE(t.a11),this.a12.setE(t.a12),this.a21.setE(t.a21),this.a22.setE(t.a22),this}mulThis(t){const e=this.a11.mulE(t.a11).addThisE(this.a12.mulE(t.a21)),s=this.a11.mulE(t.a12).addThisE(this.a12.mulE(t.a22)),i=this.a21.mulE(t.a11).addThisE(this.a22.mulE(t.a21)),n=this.a21.mulE(t.a12).addThisE(this.a22.mulE(t.a22));return this.a11=e,this.a12=s,this.a21=i,this.a22=n,this}mulLeftThis(t){const e=t.clone();return this.assign(e.mulThis(this)),this}det(){return this.a11.mulE(this.a22).subThisE(this.a12.mulE(this.a21))}invertThis(){const t=this.det();if(0!==t.value()){const e=this.a22.divE(t),s=this.a12.negate().divThisE(t),i=this.a21.negate().divThisE(t),n=this.a11.divE(t);this.a11=e,this.a12=s,this.a21=i,this.a22=n}else this.setZero();return!t.isZero()}transposeThis(){return this.a21=Ve(this.a12,this.a12=this.a21),this}transformPoint(e){return t(0),new Ai}eigenValues(e){return t(0),0}eigenVectors(e,s){return t(0),0}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new Wt(1),n=new Wt(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new Wt(1);if(this.a11.ne(this.a22)){const r=this.a11.subE(this.a22).divE(s);r.mulThisByPower2(.5);const o=r.sqr();e.setE(r),e.absThis(),e.subThisE(o.add(1).sqrtThis()),r.gt(Ut)&&e.negateThis();const a=e.sqr().addThis(1).sqrtThis().invThis();n=e.mulE(a),i.setE(a);const h=e.mulE(s);t[0]=this.a11.addE(h),t[1]=this.a22.subE(h)}else i=new Wt(1/Math.sqrt(2)),n=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=n.toDouble(),e[1].x=n.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=Ve(t[0],t[0]=t[1]),e[1]=Ve(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var Ii=gs,Ni=vs;function Mi(t,e){const s=t.getStartXY();if(s.equals(e.getStartXY()))return!0;if(s.equals(e.getEndXY()))return!0;const i=t.getEndXY();return!!i.equals(e.getStartXY())||!!i.equals(e.getEndXY())}function qi(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Ri(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),i=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,i}function Fi(e,s,i,n,r,o,a,h){let m=e.calculateUpperLength2D(),u=s.calculateUpperLength2D(),l=e,c=s,d=!1;m>u&&(c=Ve(l,l=c),n=Ve(i,i=n),u=Ve(m,m=u),d=!0);const _=0===i;{a[0]=_?1:0;const t=l.getCoord2D(a[0]);h[0]=c.getClosestCoordinate(t,!1);const e=c.getCoord2D(h[0]);if(os.distance(t,e)<=r){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(l.getCoord2D(e[i])),!c.isCloserThanDistance(t,new kt(0,1),r)){s=!1;break}if(s)return d&&(h[0]=Ve(a[0],a[0]=h[0])),1}}if(m<=3*r)return 0;let g=Pt(Math.max(r/m,.1),0,.5),p=.01*r,f=0,x=0,y=g,v=-1,P=0,b=1/32;for(let E=0;;E++){t(E<4095);const e=_?g:1-g,s=l.getCoord2D(e),i=c.getClosestCoordinate(s,!1);if(i===n)return P;const m=c.getCoord2D(i),u=os.distance(s,m);if(0===E&&(v=u),u<=p?(b=.5,x=u,f=g):(y=g,v=u),Math.abs(x-v)>.1*p&&y-f>1e-16)g=he(f,y,b);else{if(a[P]=e,h[P]=i,d&&(h[P]=Ve(a[P],a[P]=h[P])),1===o||1===P)return 1===P&&a[0]>a[1]&&(a[1]=Ve(a[0],a[0]=a[1]),h[1]=Ve(h[0],h[0]=h[1])),P+1;P++,f=y,x=v,y=.8,v=-1,g=.8,b=1/32,p=10*r,E=0}}}function Yi(t,e,s,i,n,r,o,a,h){if(vt(s,0,1)&&vt(i,0,1)){if(0===os.distance(t.getCoord2D(s),e.getCoord2D(i))){const h=1e-12,m=new Ai,u=yt();if(t.queryDerivative(new Wt(s,u),m),m.isTrueZero()){const e=1===s?-h:h;t.queryDerivative(new Wt(s,u).add(e),m)}1===s&&m.negateThis();const l=new Ai;if(e.queryDerivative(new Wt(i,u),l),l.isTrueZero()){const t=1===s?-h:h;e.queryDerivative(new Wt(i,u).add(t),l)}1===i&&l.negateThis(),m.isZero()||m.normalize(),l.isZero()||l.normalize();const c=m.dotProduct(l),d=m.crossProduct(l);d.scaleError(3);const _=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(c.ge(Ut)&&(d.isZero()||Math.abs(d.value())<_())){return Fi(t,e,s,i,n,r,o,a)}}}return 0}function Xi(e,s,i){if(t(e.isCurve()||s.isCurve()),e.getStartXY().equals(s.getStartXY())){if(Yi(e,s,0,0,i,2,[0,0],[0,0]))return!0}if(e.getEndXY().equals(s.getEndXY())){if(Yi(e,s,1,1,i,2,[0,0],[0,0]))return!0}if(e.getStartXY().equals(s.getEndXY())){if(Yi(e,s,0,1,i,2,[0,0],[0,0]))return!0}if(e.getEndXY().equals(s.getStartXY())){if(Yi(e,s,1,0,i,2,[0,0],[0,0]))return!0}return!1}function Li(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function zi(t,e,s){t.m_XStart=e,t.m_YStart=s}function Vi(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function Bi(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function ki(t,e,s){e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified())}function Gi(t,e,s){t.m_description.hasZ()||t.addAttribute(1),e?t.m_XEnd===s.x&&t.m_YEnd===s.y||(t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified()):t.m_XStart===s.x&&t.m_YStart===s.y||(t.m_XStart=s.x,t.m_YStart=s.y,t.endPointModified()),t.m_attributes[(t.m_description.getTotalComponentCount()-2)*e]=s.z}function Wi(t,e,s){s.assignVertexDescription(t.m_description);const i=0===e?t.m_XStart:t.m_XEnd,n=0===e?t.m_YStart:t.m_YEnd;s.setXYCoords(i,n);for(let r=1;r<t.m_description.getAttributeCount();r++){const i=t.m_description.getSemantics(r);for(let n=0,r=Ii.getComponentCount(i);n<r;n++){const r=Hi(t,e,i,n);s.setAttributeBasic(i,n,r)}}}function Zi(t,e,s){s.isEmpty()&&v(""),ki(t,e,s.getXY());const i=s.getDescription();i!==t.m_description&&t.mergeVertexDescription(i);for(let n=1,r=i.getAttributeCount();n<r;n++){const r=i.getSemantics(n),o=Ii.getComponentCount(r);for(let i=0;i<o;i++){Oi(t,e,r,i,s.getAttributeAsDbl(r,i))}}}function Hi(t,e,s,i){if((e<0||e>1)&&b(""),0===s)return(i<0||i>=2)&&b(""),0===e?0===i?t.m_XStart:t.m_YStart:0===i?t.m_XEnd:t.m_YEnd;const n=Ii.getComponentCount(s);(i<0||i>=n)&&b("");const r=t.m_description.getAttributeIndex(s);return r>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(r)-2+i]:Ii.getDefaultValue(s)}function Oi(t,e,s,i,n){if((e<0||e>1)&&b(""),0===s)return 0===e?0===i?t.m_XStart=n:1===i?t.m_YStart=n:b(""):1===e?0===i?t.m_XEnd=n:1===i?t.m_YEnd=n:b(""):b(""),void t.endPointModified();const r=Ii.getComponentCount(s);(i<0||i>=r)&&b("");let o=t.m_description.getAttributeIndex(s);o<0&&(t.addAttribute(s),o=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+i]=n}function ji(t,e){if(t===e)return;e.isEmpty()&&v("");const s=e.getDescription();s!==t.m_description&&t.mergeVertexDescription(s);for(let i=1,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=Ii.getComponentCount(n);for(let s=0;s<r;s++){let i=Hi(e,0,n,s);Oi(t,0,n,s,i),i=Hi(e,1,n,s),Oi(t,1,n,s,i)}}}function Ui(t,e){const s=xs();Ni.mapAttributes(e,t.m_description,s);let i=null;const n=e.getTotalComponentCount()-2,r=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(n>0){i=new Array(2*n);const o=e.getDefaultPointAttributes();for(let t=2;t<o.length;++t)i[t-2]=i[t-2+n]=o[t];if(null!==t.m_description)for(let a=1;a<e.getAttributeCount();a++){const o=s[a];if(-1!==o){const s=t.m_description.getPointAttributeOffset(o)-2,h=e.getPointAttributeOffset(a)-2,m=Ii.getComponentCount(e.getSemantics(a));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[n+h]=t.m_attributes[r+s]}}}t.m_attributes=i,t.m_description=e}function Qi(t){return t.absNorm()*pt()}function Ki(t,e){return Math.max(t.absNorm(),e.absNorm())*pt()}function $i(t,e,s){const i=new Di;t.queryEnvelopeW(kt.unit(),i);const n=new Di;return e.queryEnvelopeW(kt.unit(),n),n.inflate(s),!i.isIntersectingW(n)}function Ji(t,e,s){const i=Qe(t,s),n=Qe(e,s);i.sort(((t,e)=>t.compare(e))),n.sort(((t,e)=>t.compare(e)));for(let r=0;r<3;r++){if(i[r].compare(n[r])<0)return-1;if(0!==i[r].compare(n[r]))return 1}return 0}class tn{constructor(t){if(this.m_segFlagStream=null,this.m_xyStream=null,this.m_bCirculator=!1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_parent=t.parent,this.m_buffer=new this.m_parent.m_segmentBufferCTor,this.m_description=t.parent.getDescription(),this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),void 0!==t.pointIndex){(t.pointIndex<0||t.pointIndex>=t.parent.getPointCount())&&b("");const e=t.parent.getPathIndexFromPointIndex(t.pointIndex);this.m_currentPathIndex=e,this.m_nextPathIndex=e+1,this.m_nextSegmentIndex=t.pointIndex-t.parent.getPathStart(e),this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex)}else if(void 0!==t.pathIndex){(t.pathIndex<0||t.pathIndex>=t.parent.getPathCount()||t.segmentIndex<0)&&b("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&b(""),this.m_nextSegmentIndex=t.segmentIndex,this.m_currentPathIndex=t.pathIndex,this.m_nextPathIndex=this.m_nextSegmentIndex+1,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex)}this.prepare(),this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1,this.m_bStripAttributes=!1,this.m_prevPathIndex=-1,this.m_prevSegmentIndex=-1,this.m_bNeedsUpdate=!1,this.m_currentPathIndex>-1&&(this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex))}stripAttributes(){this.m_bStripAttributes=!0}clone(){return t(0),this}prepare(){this.m_bCirculator=!1,this.m_parent.isEmptyImpl()?(this.m_segFlagStream=null,this.m_xyStream=null):(this.m_segFlagStream=this.m_parent.getSegmentFlagsStreamRef(),this.m_xyStream=this.m_parent.getAttributeStreamRef(0))}nextPath(){return this.m_currentPathIndex=this.m_nextPathIndex,!(this.m_currentPathIndex>=this.m_parent.getPathCount())&&(this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_currentPathIndex),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.m_nextPathIndex++,!0)}previousPath(){return 0!==this.m_nextPathIndex&&(this.m_nextPathIndex--,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0,this.m_segmentCount=this.getSegmentCount(this.m_nextPathIndex),this.m_currentPathIndex=this.m_nextPathIndex,this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex),this.resetToLastSegment(),!0)}getSegmentCount(t){return this.m_parent.isEmptyImpl()?0:this.m_parent.getSegmentCountPath(t)}resetToFirstPath(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_nextPathIndex=0,this.m_currentPathIndex=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}resetToLastPath(){this.m_nextPathIndex=this.m_parent.getPathCount(),this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1}resetToPath(t){(t<0||t>this.m_parent.getPathCount())&&b(""),this.m_nextPathIndex=t,this.m_currentPathIndex=-1,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=-1,this.m_segmentCount=-1,this.m_pathBegin=-1,this.m_bCurrentPathClosed=!1}isLastPath(){return this.m_currentPathIndex===this.m_parent.getPathCount()-1}isFirstSegmentInPath(){return t(0),!1}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){t(0)}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&y(""),this.m_currentSegmentIndex=t.m_currentSegmentIndex,this.m_nextSegmentIndex=t.m_nextSegmentIndex,this.m_currentPathIndex=t.m_currentPathIndex,this.m_nextPathIndex=t.m_nextPathIndex,this.m_segmentCount=t.m_segmentCount,this.m_bCirculator=t.m_bCirculator,this.m_pathBegin=t.m_pathBegin,this.m_bCurrentPathClosed=t.m_bCurrentPathClosed,this.m_bStripAttributes=t.m_bStripAttributes,this.m_description=t.m_description}resetToVertex(t,e){if(this.m_currentPathIndex>=0&&this.m_currentPathIndex<this.m_parent.getPathCount()){const e=this.getPathBegin();if(t>=e&&t<this.m_parent.getPathEnd(this.m_currentPathIndex))return this.m_currentSegmentIndex=-1,void(this.m_nextSegmentIndex=t-e)}let s;s=e>=0&&e<this.m_parent.getPathCount()&&t>=this.m_parent.getPathStart(e)&&t<this.m_parent.getPathEnd(e)?e:this.m_parent.getPathIndexFromPointIndex(t),this.m_nextPathIndex=s+1,this.m_currentPathIndex=s,this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=t-this.m_parent.getPathStart(s),this.m_segmentCount=this.getSegmentCount(s),this.m_pathBegin=this.m_parent.getPathStart(this.m_currentPathIndex),this.m_bCurrentPathClosed=this.m_parent.isClosedPath(this.m_currentPathIndex)}hasNextSegment(){return this.m_nextSegmentIndex<this.m_segmentCount}hasPreviousSegment(){return this.m_nextSegmentIndex>0}nextSegment(){return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&b("Segment_iterator_impl::next_segment"),this.m_nextSegmentIndex++),this.m_buffer.get()}previousSegment(){return this.m_bCirculator?this.m_nextSegmentIndex=(this.m_segmentCount+this.m_nextSegmentIndex-1)%this.m_segmentCount:(0===this.m_nextSegmentIndex&&b(""),this.m_nextSegmentIndex--),this.m_nextSegmentIndex!==this.m_currentSegmentIndex&&this.updateSegment(),this.m_buffer.get()}nextCurve(){if(!this.m_parent.hasNonLinearSegments())return this.resetToLastSegment(),null;let t=0;for(;;){if(this.m_nextSegmentIndex===this.m_segmentCount||t===this.m_segmentCount)return null;const e=this.getPathBegin()+this.m_nextSegmentIndex;if(1!==(31&this.m_segFlagStream.read(e))){this.updateSegment();break}this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:this.m_nextSegmentIndex++,t++}return this.m_currentSegmentIndex!==this.m_nextSegmentIndex&&this.updateSegment(),this.m_bCirculator?this.m_nextSegmentIndex=(this.m_nextSegmentIndex+1)%this.m_segmentCount:(this.m_nextSegmentIndex===this.m_segmentCount&&b(""),this.m_nextSegmentIndex++),this.m_buffer.get()}getPathBegin(){return this.m_pathBegin}getPathIndex(){return this.m_currentPathIndex}getStartPointIndex(){return this.getPathBegin()+this.m_currentSegmentIndex}getEndPointIndex(){return this.isClosingSegment()?this.getPathBegin():this.getStartPointIndex()+1}updateSegment(){(this.m_nextSegmentIndex<0||this.m_nextSegmentIndex>=this.m_segmentCount||this.m_currentPathIndex<0)&&b(""),this.m_currentSegmentIndex=this.m_nextSegmentIndex,this.m_parent.getSegmentFromPath(this.m_currentPathIndex,this.m_currentSegmentIndex,this.m_buffer,this.m_bStripAttributes)}isClosingSegment(){return this.m_bCurrentPathClosed&&this.m_currentSegmentIndex===this.m_segmentCount-1}isCurve(){return t(0),!1}isPathClosed(){return t(0),!1}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}function en(t){const e=t.getGeometryType();return e===r.enumEllipticArc?10:e===r.enumBezier?4:e===r.enumRationalBezier2?5:e===r.enumBezier2?2:void E("")}function sn(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function nn(t,e,s){return s.writeInBufferStream(t,e)}function rn(t,e,s){s.readFromBufferStream(t,e)}function on(t,e,s,i){const n=t.getPathStart(e),r=t.getPathEnd(e);if(r-n<3)return;const o=2*n,a=os.getNAN();s.queryPoint2D(o,a);const h=a.x,m=a.y,u=os.getNAN();s.queryPoint2D(o+2,u);const l=os.getNAN();for(let c=o+4,d=2*r;c<d;c+=2)s.queryPoint2D(c,l),i.pe((l.x-a.x)*(u.y-m)),a.setCoordsPoint2D(u),u.setCoordsPoint2D(l);i.pe((h-a.x)*(u.y-m))}function an(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var hn=gs;class mn{static toSegType(t){let e=0;switch(t){case r.enumLine:e=1;break;case r.enumBezier:e=2;break;case r.enumEllipticArc:e=4;break;case r.enumRationalBezier2:e=8;break;case r.enumBezier2:e=16;break;default:E("")}return e}constructor(){this.m_segmentFlags=null,this.m_segmentParamIndex=null,this.m_segmentParams=null,this.m_curveCount=0,this.m_bezierCount=0,this.m_arcCount=0,this.m_rbezier2Count=0,this.m_bezier2Count=0,this.m_curveParamWritePoint=0}assignCopy(t){return this.m_segmentFlags=t.m_segmentFlags,this.m_segmentParamIndex=t.m_segmentParamIndex,this.m_segmentParams=t.m_segmentParams,this.m_curveCount=t.m_curveCount,this.m_bezierCount=t.m_bezierCount,this.m_arcCount=t.m_arcCount,this.m_rbezier2Count=t.m_rbezier2Count,this.m_bezier2Count=t.m_bezier2Count,this.m_curveParamWritePoint=t.m_curveParamWritePoint,this}}class un extends bi{constructor(t){super(t),this.m_cachedRingAreas2D=null,this.m_paths=null,this.m_pathFlags=null,this.m_curveData=null,t.move?(this.m_bPolygon=t.move.m_bPolygon,this.m_cachedLength2D=t.move.m_cachedLength2D,this.m_cachedArea2D=t.move.m_cachedArea2D,this.m_currentPathIndex=t.move.m_currentPathIndex,this.m_cachedRingAreas2D=t.move.m_cachedRingAreas2D,this.m_paths=t.move.m_paths,this.m_pathFlags=t.move.m_pathFlags,this.m_curveData=t.move.m_curveData,t.move.setEmpty()):(this.m_bPolygon=t.bPolygon,this.m_cachedLength2D=0,this.m_cachedArea2D=0,this.m_currentPathIndex=0)}getGeometryType(){return this.m_bPolygon?r.enumPolygon:r.enumPolyline}getDimension(){return this.m_bPolygon?2:1}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(e){return t(0),!1}isExteriorRing(t){return this.calculateRingArea2D(t)>0}calculateRingArea2D(t){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedRingAreas2D.read(t)):0}updateRingAreas2DProtected(){if(!this.hasDirtyFlag(1024))return;const t=this.getPathCount();if(0===t)return this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=0),void this.setDirtyFlagProtected(1024,!1);const e=new Xs(t),s=new At(0),i=new At(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new tn({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();on(this,r,n,i),an(this,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),on(this,r,n,i);const t=.5*i.getResult();s.add(t),e.write(r,t)}}this.hasDirtyFlag(1024)&&(this.m_cachedArea2D=s.getResult(),this.m_cachedRingAreas2D=e,this.setDirtyFlagProtected(1024,!1))}getOGCPolygonCount(){return t(0),0}getHashCodeImpl(){return t(0),0}equalsImpl(t){const e=t,s=this.getPathCount();if(s!==e.getPathCount())return!1;const i=this.hasNonLinearSegments();if(i!==e.hasNonLinearSegments())return!1;if(i){if(this.m_curveData.m_curveCount!==e.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==e.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(e.m_paths,0,s+1))return!1;if(this.m_bFillRule!==e.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(e.m_pathFlags,0,s))return!1;if(this.hasNonLinearSegments()){if(!this.m_curveData.m_segmentFlags.equals(e.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;for(let t=0,s=this.getPointCount();t<s;t++){const s=this.m_curveData.m_segmentFlags.read(t);if(!un.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),n=e.m_curveData.m_segmentParamIndex.read(t),r=sn(s);for(let t=0;t<r;t++){if(!H(this.m_curveData.m_segmentParams.read(i+t),e.m_curveData.m_segmentParams.read(n+t)))return!1}}}return!0}equalsImplTol(t,e){const s=t,i=this.getPathCount();if(i!==s.getPathCount())return!1;const n=this.hasNonLinearSegments();if(n!==s.hasNonLinearSegments())return!1;if(n){if(this.m_curveData.m_curveCount!==s.m_curveData.m_curveCount)return!1;if(this.m_curveData.m_bezierCount!==s.m_curveData.m_bezierCount)return!1}if(this.m_paths&&!this.m_paths.equals(s.m_paths,0,i+1))return!1;if(this.m_bFillRule!==s.m_bFillRule)return!1;if(!this.m_bPolygon&&this.m_pathFlags&&!this.m_pathFlags.equals(s.m_pathFlags,0,i))return!1;if(!n)return!0;if(!this.m_curveData.m_segmentFlags.equals(s.m_curveData.m_segmentFlags,0,this.getPointCount()))return!1;const r=this.querySegmentIterator(),o=s.querySegmentIterator();for(;r.nextPath();){if(!o.nextPath())return!1;for(;r.hasNextSegment();){const t=r.nextCurve(),s=o.nextCurve();if(!(t&&s&&t.equals(s,e))){if(!t&&!s)break;return!1}}}return!0}reserveImplImpl(t,e){this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(t,1),this.m_curveData.m_segmentParamIndex.resize(t,-1),this.checkCompactSegmentParams())}verifyStreamsAfterSizeChangeExtraImpl(){this.m_paths||(this.m_paths=Is(1,0),this.m_pathFlags=Ns(1,0)),this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.resize(this.m_reservedPointCount,1),this.m_curveData.m_segmentParamIndex.resize(this.m_reservedPointCount,-1),this.checkCompactSegmentParams())}copyToImpl(t,e){const s=t;s.m_bPathStarted=!1,s.m_bFillRule=this.m_bFillRule,this.m_paths?s.m_paths=e?this.m_paths:this.m_paths.clone():s.m_paths=null,this.m_pathFlags?s.m_pathFlags=e?this.m_pathFlags:this.m_pathFlags.clone():s.m_pathFlags=null,this.m_curveData&&(s.m_curveData||(s.m_curveData=new mn),s.m_curveData.assignCopy(this.m_curveData),s.m_curveData.m_curveCount=0,s.updateCurveCounter(this.m_curveData.m_curveCount),e||(this.m_curveData.m_segmentParamIndex?s.m_curveData.m_segmentParamIndex=this.m_curveData.m_segmentParamIndex.clone():s.m_curveData.m_segmentParamIndex=null,this.m_curveData.m_segmentFlags?s.m_curveData.m_segmentFlags=this.m_curveData.m_segmentFlags.clone():s.m_curveData.m_segmentFlags=null,this.m_curveData.m_segmentParams?s.m_curveData.m_segmentParams=this.m_curveData.m_segmentParams.clone():s.m_curveData.m_segmentParams=null)),s.hasDirtyFlag(512)||(s.m_cachedLength2D=this.m_cachedLength2D),s.m_cachedRingAreas2D=null,s.hasDirtyFlag(1024)||(s.m_cachedArea2D=this.m_cachedArea2D,null!==this.m_cachedRingAreas2D&&(s.m_cachedRingAreas2D=e?this.m_cachedRingAreas2D:this.m_cachedRingAreas2D.clone()))}calculateArea2D(){return this.m_bPolygon?(this.updateRingAreas2DProtected(),this.m_cachedArea2D):0}calculateLength2D(){if(!this.hasDirtyFlag(512))return this.m_cachedLength2D;const t=this.querySegmentIterator(),e=new At(0);for(;t.nextPath();)for(;t.hasNextSegment();)e.add(t.nextSegment().calculateLength2D());return this.hasDirtyFlag(512)&&(this.m_cachedLength2D=e.getResult()),this.setDirtyFlagProtected(512,!1),e.getResult()}calculatePathLength2D(e){return t(0),0}calculateLength3D(e){return t(0),0}calculatePathLength3D(e,s){return t(0),0}copyTo(t){c(t.getGeometryType())||f(""),super.copyTo(t)}swap(e){t(0)}hasNonLinearSegments(){return 0!==this.getCurveCount()}getSegmentCount(){let t=this.getPointCount();if(!this.m_bPolygon){t-=this.getPathCount();for(let e=0,s=this.getPathCount();e<s;e++)this.isClosedPath(e)&&t++}return t}getSegmentCountPath(t){let e=this.getPathSize(t);return!this.isClosedPath(t)&&e>0&&e--,e}add(t,e){this===t&&f("Multi_path_impl::add");for(let s=0,i=t.getPathCount();s<i;s++)this.addPath(t,s,!e)}addPath(t,e,s){this.insertPath(-1,t,e,s)}addPathPoint2D(t,e,s){this.insertPath2D(-1,t,0,e,s)}addSegmentsFromPath(t,e,s,i,n){if(this===t&&f("Multi_path_impl.add_segments_from_path"),n||0!==this.getPathCount()||(n=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||i<0||s+i>t.getSegmentCountPath(e))&&b("add_segments_from_path"),0===i)return;const r=t.getPathStart(e),o=t.isClosedPath(e)&&s+i===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let a=i;const h=r+s;let m=h+1;n&&(a++,m--),!n&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(h)&&(t.getXY(h).equals(this.getXY(this.m_pointCount-1))||f("add_segments_from_path: start point mismatch"));const u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange(),n){if(0===a)return;this.m_paths.add(this.m_pointCount);let s=t.m_pathFlags.read(e);this.m_bPolygon&&(s|=1),this.m_pathFlags.write(this.m_pathFlags.size()-1,s),this.m_pathFlags.add(0)}else this.m_paths.write(this.m_pathFlags.size()-1,this.m_pointCount);const l=o?a-1:a;for(let c=0,d=this.m_description.getAttributeCount();c<d;c++){const e=this.m_description.getSemantics(c),s=hn.getComponentCount(e),i=t.m_description.getAttributeIndex(e);if(l>0){if(i<0||!t.m_vertexAttributes.get(i)){const t=hn.getDefaultValue(e);this.m_vertexAttributes.get(c).insertRange(s*u,t,l*s,s*u),o&&this.m_vertexAttributes.get(c).insertRange(s*u+l*s,t,s,s*u);continue}this.m_vertexAttributes.get(c).insertRangeFromStream(s*u,t.m_vertexAttributes.get(i),s*m,l*s,!0,s,s*u)}o&&this.m_vertexAttributes.get(c).insertRangeFromStream(s*(u+l),t.m_vertexAttributes.get(i),s*r,s,!0,s,s*(u+l))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,n=h;s<i;s++){e+=sn(t.m_curveData.m_segmentFlags.read(n)),n++}if(e>0){this.initSegmentData(e);let s=h,r=u-(n?0:1),o=0;for(let e=0;e<i;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(r,e),un.isNonLinearSegmentFlag(e)){o++;let i=t.m_curveData.m_segmentParamIndex.read(s);const n=sn(e);this.m_curveData.m_segmentParamIndex.write(r,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<n;e++){const e=t.m_curveData.m_segmentParams.read(i);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,i++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(r,-1);r++,s++}this.modifyCurveCounter(o)}}if(o){const t=this.getPathCount()-1,e=this.getPathStart(t),s=this.getPathEnd(t)-1,i=this.getXY(e),n=this.getXY(s);i.isEqualPoint2D(n)&&(--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount))}this.notifyModifiedFlags(2001)}reverseAllPaths(){for(let t=0,e=this.getPathCount();t<e;t++)this.reversePath(t)}reversePath(t){t>=this.getPathCount()&&f("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),i=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const n=new this.m_segmentBufferCTor;let r=!1;for(let s=0;s<e;s++,t++){const e=this.m_curveData.m_segmentFlags.read(t);if(!un.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,n,!0),n.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);nn(this.m_curveData.m_segmentParams,s,n.get())}if(r){const t=i?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const n=i?1:0;for(let o=0,a=this.m_description.getAttributeCount();o<a;o++)if(this.m_vertexAttributes.get(o)){const t=this.m_description.getSemantics(o),i=hn.getComponentCount(t);this.m_vertexAttributes.get(o).reverseRange(i*(s+n),i*(e-n),i)}const r=6&this.m_pathFlags.read(t);if(r){let e=0;4&r&&(e|=2),2&r&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(e){t(0)}insertPath(t,e,s,i){this===e&&f("Multi_path_impl::insert_path");const n=this.getPathCount();if(!i&&e.hasNonLinearSegmentsPath(s))return t=this.insertPath(t,e,s,!0),this.reversePath(t),t;s>=e.getPathCount()&&f(""),t>n&&f(""),t<0&&(t=n),s<0&&(s=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());const r=e.getPathStart(s),o=e.getPathSize(s);if(0===o)return this.insertPath2D(t,null,0,0,!0);const a=this.m_pointCount,h=e.isClosedPath(s)&&!i?1:0;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=t<n?this.getPathStart(t):a;for(let c=0,d=this.m_description.getAttributeCount();c<d;c++){const t=this.m_description.getSemantics(c),s=e.getDescription().getAttributeIndex(t),n=hn.getComponentCount(t);if(s>=0&&e.m_vertexAttributes.get(s))0!==h&&this.m_vertexAttributes.get(c).insertRangeFromStream(m*n,e.m_vertexAttributes.get(s),n*r,n,!0,n,n*a),this.m_vertexAttributes.get(c).insertRangeFromStream((m+h)*n,e.m_vertexAttributes.get(s),n*(r+h),n*(o-h),i,n,n*(a+h));else{const e=hn.getDefaultValue(t);this.m_vertexAttributes.get(c).insertRange(m*n,e,n*o,n*a)}}const u=a+o;this.m_paths.add(u);for(let c=n;c>=t+1;c--){const t=this.m_paths.read(c-1);this.m_paths.write(c,t+o)}this.m_pathFlags.add(0);for(let c=n-1;c>=t+1;c--){let t=this.m_pathFlags.read(c);t&=-9,this.m_pathFlags.write(c+1,t)}let l=e.getPathFlagsStreamRef().read(s);if(l&=-9,this.m_bPolygon&&(l|=1),this.m_pathFlags.write(t,l),e.hasNonLinearSegments()){this.initSegmentData(0);let t=r,s=0;for(let i=0;i<o;i++){s+=sn(e.m_curveData.m_segmentFlags.read(t)),t++}if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=Ns(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=Is(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(m,1,o,a),this.m_curveData.m_segmentParamIndex.insertRange(m,-1,o,a)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+s):this.m_curveData.m_segmentParams=Ms(s),t=r;let i=m,n=0;for(let s=0;s<o;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(un.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(i,s),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const r=sn(s);let o=e.m_curveData.m_segmentParamIndex.read(t);for(let t=0;t<r;t++){const t=e.m_curveData.m_segmentParams.read(o);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint++,o++}n++,this.incCurveType(s,1)}t++,i++}this.modifyCurveCounter(n)}}return this.notifyModifiedFlags(2001),t}insertPath2D(t,e,s,i,n){const r=this.getPathCount();(t>r||s<0)&&f(""),t<0&&(t=r),this.m_bPathStarted=!1;const o=this.m_pointCount;this.resizeImpl(this.m_pointCount+i),0===i&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const a=t<r?this.getPathStart(t):o;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*a,e,s,i,n,2*o);else{const t=hn.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*a,t,2*i,2*o)}for(let h=1,m=this.m_description.getAttributeCount();h<m;h++){const t=this.m_description.getSemantics(h),e=hn.getComponentCount(t),s=hn.getDefaultValue(t);this.m_vertexAttributes.get(h).insertRange(a*e,s,e*i,e*o)}this.m_paths.add(this.m_pointCount);for(let h=r;h>=t+1;h--){const t=this.m_paths.read(h-1);this.m_paths.write(h,t+i)}this.m_pathFlags.add(0);for(let h=r-1;h>=t+1;h--){let t=this.m_pathFlags.read(h);t&=-9,this.m_pathFlags.write(h+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(a,1,i,o),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,i,o)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(e,s,i,n,r){t(0)}insertPoints(e,s,i,n,r,o,a){t(0)}insertPointsFromPoints(e,s,i,n,r,o){t(0)}insertPointsFromMultipoint(e,s,i,n,r,o){t(0)}insertPoint2D(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&b(""),t===i&&this.addPathPoint2D(null,0,!0);const n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const r=this.getPathStart(t),o=e<0?this.getPathSize(t)+r:e+r,a=this.m_vertexAttributes.get(0);if(o===n)this.m_paths.write(t+1,n+1),a.writePoint2D(2*o,s);else{a.insert(2*o,s,2*n);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=hn.getComponentCount(e),i=hn.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*o,i,s,s*n)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(o,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(o,-1,1,n));for(let e=t+1,s=i;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&o>r&&this.isNonLinearSegment(o-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const i=this.getPathCount();t<0&&(t=i),(t>i||t<i&&e>this.getPathSize(t))&&b(""),t===i&&this.addPathPoint2D(null,0,!0);const n=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const r=this.getPathStart(t),o=e<0?this.getPathSize(t)+r:e+r;if(o===n)this.m_paths.write(t+1,n+1),this.setPointByVal(o,s);else{const e=s.getDescription();this.m_description!==e&&this.mergeVertexDescription(e);for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),r=hn.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(r*o,s,i,r*n);else{const e=hn.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(r*o,e,r,r*n)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(o,1,1,n),this.m_curveData.m_segmentParamIndex.insertRange(o,-1,1,n));for(let s=t+1,n=i;s<=n;s++)this.m_paths.write(s,this.m_paths.read(s)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&o>r&&this.isNonLinearSegment(o-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&b("Multi_path.remove_point");const i=this.getPathStart(t),n=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&b("Multi_path.remove_point");const r=i+e;for(let o=0,a=this.m_description.getAttributeCount();o<a;o++)if(this.m_vertexAttributes.get(o)){const t=this.m_description.getSemantics(o),e=hn.getComponentCount(t);this.m_vertexAttributes.get(o).eraseRange(e*r,e,e*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(r>i&&this.isNonLinearSegment(r-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(r-1),-1),this.m_curveData.m_segmentFlags.write(r-1,1),this.m_curveData.m_segmentParamIndex.write(r-1,-1);else{const s=this.getPathEnd(t);n&&i+1<s&&this.isNonLinearSegment(s-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(s-1),-1),this.m_curveData.m_segmentFlags.write(s-1,1),this.m_curveData.m_segmentParamIndex.write(s-1,-1),e+=1)}this.isNonLinearSegment(r)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(r),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(r,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(r,1,this.m_pointCount)}for(let o=s;o>=t+1;o--){const t=this.m_paths.read(o);this.m_paths.write(o,t-1)}this.m_pointCount--,this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}removePoint(t){let e;e=t<0?this.getPathCount()-1:this.getPathIndexFromPointIndex(t),this.removePointFromPath(e,t-this.getPathStart(e))}getNumberOfCurves(t){if(!this.hasNonLinearSegments())return 0;let e=0;for(let s=this.getPathStart(t),i=this.getPathEnd(t);s<i;s++)un.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(s))&&++e;return e}getPathCount(){return this.m_paths?this.m_paths.size()-1:0}getPathSize(t){return this.m_paths.read(t+1)-this.m_paths.read(t)}getPathStart(t){return this.m_paths.read(t)}getPathEnd(t){return this.m_paths.read(t+1)}getPathIndexFromPointIndex(t,e=-1){-1===e&&(e=this.m_currentPathIndex);const s=this.getPathCount(),i=un.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new Ci({x:t,y:e}))}startPath(t){this.startPathPoint(new Ci({pt:t}))}startPath3D(t){this.startPathPoint(new Ci({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new Ci({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&f("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const i=new Ci({vd:this.m_description});t.copyCommonAttributesTo(i),s=i}else s=t;this.m_bPathStarted?this.setPointByVal(this.m_pointCount-1,s):(this.insertPoint(-1,-1,s),this.m_bPathStarted=!0)}beforeNewSegmentHelper2(){this.m_paths=Is(2),this.m_paths.write(0,0),this.m_pathFlags=Ns(2,0),this.m_bPolygon&&this.m_pathFlags.write(0,1)}beforeNewSegmentHelper1(){null!==this.m_paths?(this.m_paths.add(0),this.m_pathFlags.add(0),this.m_bPolygon&&this.m_pathFlags.write(this.m_pathFlags.size()-2,1)):this.beforeNewSegmentHelper2()}beforeNewSegment(t){0!==this.m_pointCount||this.m_bPathStarted||this.startPathCoords(0,0);const e=this.m_pointCount,s=this.m_paths.size()-1,i=e+t;this.m_paths.write(s,i),this.resizeImpl(i),this.m_bPathStarted&&(this.m_bPathStarted=!1)}finishLineTo(){if(this.hasNonLinearSegments()){const t=this.m_curveData.m_segmentFlags.read(this.m_pointCount-1);1!==t&&(this.m_curveData.m_segmentFlags.write(this.m_pointCount-1,1),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-1,-1),this.modifyCurveCounter(-1),this.incCurveType(t,-1))}}lineToCoords(t,e){if(this.beforeNewSegment(1),1===this.m_description.getAttributeCount())this.setXYCoords(this.m_pointCount-1,t,e);else{const s=_s(),i=new Ci({vd:this.m_description,attribBuffer:s,initDefaultValues:!0});i.setXYCoords(t,e),this.setPointByVal(this.m_pointCount-1,i)}this.finishLineTo()}lineTo(t){this.lineToCoords(t.x,t.y)}lineTo3D(t){this.beforeNewSegment(1);const e=vs.getMergedVertexDescription(this.m_description,vs.getDefaultDescription3D()),s=_s(),i=new Ci({vd:e,attribBuffer:s,initDefaultValues:!0});i.setXYZ(t),this.setPointByVal(this.m_pointCount-1,i),this.finishLineTo()}lineTo3DCoords(t,e,s){this.lineTo3D(new ps(t,e,s))}lineToPoint(t){if(this.beforeNewSegment(1),this.m_description===t.getDescription())this.setPointByVal(this.m_pointCount-1,t);else{this.mergeVertexDescription(t.getDescription());const e=_s(),s=new Ci({vd:this.m_description,attribBuffer:e,initDefaultValues:!1});t.copyCommonAttributesTo(s),this.setPointByVal(this.m_pointCount-1,s)}this.finishLineTo()}openPathAndDuplicateStartVertex(t){this.m_bPolygon&&E("");const e=this.getPathCount();if(t>e&&f(""),!this.isClosedPath(t))return;this.m_pathFlags||E("");const s=this.m_pointCount,i=this.getPathStart(t),n=this.getPathEnd(t);if(n-i!=0){this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();for(let t=0,e=this.m_description.getAttributeCount();t<e;t++)if(this.m_vertexAttributes.get(t)){const e=this.m_description.getSemantics(t),r=hn.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(r*n,this.m_vertexAttributes.get(t),r*i,r,!0,1,r*s)}for(let s=e;s>t;s--){const t=this.m_paths.read(s);this.m_paths.write(s,t+1)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(n,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(n,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(e){t(0)}isStrongPathStart(t){return!!(2&this.m_pathFlags.read(t))}setStrongPathStart(t,e){e?this.m_pathFlags.setBits(t,2):this.m_pathFlags.clearBits(t,2)}isStrongPathEnd(t){return!!(4&this.m_pathFlags.read(t))}setStrongPathEnd(t,e){e?this.m_pathFlags.setBits(t,4):this.m_pathFlags.clearBits(t,4)}clearStrongPathEnds(){for(let t=0,e=this.getPathCount();t<e;++t)this.m_pathFlags.clearBits(t,6)}openAllPathsAndDuplicateStartVertex(){if(this.m_bPolygon&&E(""),this.isEmpty())return;this.m_pathFlags||E("");let t=0;const e=this.getPathCount();for(let m=0;m<e;m++)this.isClosedPath(m)&&(this.getPathSize(m)>0?t++:this.m_pathFlags.clearBits(m,1));if(0===t)return;const s=this.hasNonLinearSegments();let i=0;const n=this.getPathCount(),r=this.m_description.getAttributeCount(),o=new Array(r);let a=null,h=null;for(let m=0;m<n;++m){const e=this.getPathStart(m),n=this.getPathSize(m),u=this.isClosedPath(m);if(n>0){const m=e+i;for(let s=0;s<r;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),r=hn.getComponentCount(i);if(!o[s]){const e=Ts(i,r*(this.m_pointCount+t));o[s]=e}o[s].writeRange(m*r,n*r,this.m_vertexAttributes.get(s),e*r,!0,1),u&&o[s].writeRange((m+n)*r,r,this.m_vertexAttributes.get(s),e*r,!0,1)}if(s){if(null===a){const e=this.m_pointCount+t;a=Ns(e),h=Is(e)}a.writeRange(m,n,this.m_curveData.m_segmentFlags,e,!0,1),h.writeRange(m,n,this.m_curveData.m_segmentParamIndex,e,!0,1),u&&(a.write(m+n,1),h.write(m+n,-1))}}this.m_paths.write(m,e+i),u&&(this.m_pathFlags.clearBits(m,1),++i)}this.m_paths.write(n,this.m_pointCount+t),this.m_pathFlags.clearBits(n,1);for(let m=0;m<r;m++)this.m_vertexAttributes.get(m)&&this.m_vertexAttributes.set(m,o[m]);s&&(this.m_curveData.m_segmentFlags=a,this.m_curveData.m_segmentParamIndex=h),this.m_pointCount+=t,this.m_reservedPointCount>0&&(this.m_reservedPointCount=this.m_pointCount)}closePathWithLine(t){void 0===t&&(t=this.getPathCount()-1),this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&f("close_path_with_line"),t===this.getPathCount()-1&&(this.m_bPathStarted=!1);const e=this.m_pathFlags.read(t);if(this.m_pathFlags.write(t,1|e),this.m_curveData&&this.m_curveData.m_segmentFlags){const e=this.getPathEnd(t)-1,s=this.m_curveData.m_segmentFlags.read(e);this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),1!==s&&(this.incCurveType(s,-1),this.modifyCurveCounter(-1))}this.notifyModifiedFlags(2001)}closeLastPathWithSegment(t){this.closePathWithSegment(this.getPathCount()-1,t)}closePathWithSegment(t,e){if(this.throwIfEmpty(),(t<0||t>=this.getPathCount())&&f("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||f("close_path_with_segment: end point mismatch"),t===this.getPathCount()-1)this.m_bPathStarted=!1,this.addSegment(e,!1),--this.m_pointCount,this.m_paths.write(t+1,this.m_pointCount);else{this.mergeVertexDescription(e.getDescription());const s=e.getStartXY(),i=this.getPathEnd(t)-1;s.equals(this.getXY(i))||f("close_path_with_segment: start point mismatch");const n=e.getGeometryType();if(n===r.enumLine)return void this.closePathWithLine(t);{const t=en(e);this.initSegmentData(t);const s=mn.toSegType(n),r=this.m_curveData.m_segmentFlags.read(i);if(r!==s)this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint),nn(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==r?this.incCurveType(r,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(i);nn(this.m_curveData.m_segmentParams,t,e)}this.m_curveData.m_segmentFlags.write(i,s)}}const s=this.m_pathFlags.read(t);this.m_pathFlags.write(t,1|s),this.notifyModifiedFlags(2001)}closeAllPaths(){if(this.m_bPolygon||this.isEmptyImpl())return;this.m_bPathStarted=!1;let t=!1;for(let e=0,s=this.m_paths.size()-1;e<s;e++){if(this.isClosedPath(e))continue;const s=this.m_pathFlags.read(e);this.m_pathFlags.write(e,1|s),t=!0}t&&this.notifyModifiedFlags(512)}isClosedPath(t){return!!(1&this.m_pathFlags.read(t))}isClosedPathInXYPlane(t){if(this.isClosedPath(t))return!0;const e=this.getPathStart(t),s=this.getPathEnd(t)-1;if(e>s)return!1;const i=this.getXY(e),n=this.getXY(s);return i.isEqualPoint2D(n)}isClosedPathIn3D(e){return t(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(un.isNonLinearSegmentFlag(this.m_curveData.m_segmentFlags.read(e)))return!0;return!1}isNonLinearSegment(t){return!(1&this.getSegmentFlags(t))}addEnvelope(t,e){if(t.isEmpty())return;const s=0===this.m_pointCount;if(t instanceof as)this.startPathCoords(t.xmin,t.ymin),e?(this.lineToCoords(t.xmax,t.ymin),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmin,t.ymax)):(this.lineToCoords(t.xmin,t.ymax),this.lineToCoords(t.xmax,t.ymax),this.lineToCoords(t.xmax,t.ymin));else{const s=t.getDescription(),i=_s(),n=new Ci({vd:s,attribBuffer:i,initDefaultValues:!1});for(let r=0,o=4;r<o;r++){const s=e?o-r-1:r;t.queryCornerByVal(s,n),0===r?this.startPathPoint(n):this.lineToPoint(n)}}this.closePathWithLine(),this.m_bPathStarted=!1,s&&!e&&(this.setDirtyFlagProtected(256,!1),this.m_bPolygon&&Math.min(t.width(),t.height())>0&&this.setIsSimple(3,0))}addPathFromClosedSegment(t,e){if(t.isClosed()||f("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new Ci;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new Ci;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const i=_s(),n=new Ci({vd:s,attribBuffer:i,initDefaultValues:!1}),o=t.getGeometryType();if(o===r.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(n),this.startPathPoint(n)),t.queryEnd(n),this.lineToPoint(n);else{let s=!1;if((e||this.isEmptyImpl())&&(s=!0),!s){t.getStartXY().equals(this.getXY(this.m_pointCount-1))||f("add_segment: start point mismatch")}if(s&&(t.queryStart(n),this.startPathPoint(n)),this.beforeNewSegment(1),t.queryEnd(n),n.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,n);else{const t=_s(),e=new Ci({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});n.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const i=en(t);this.initSegmentData(i),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),nn(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint,t),this.m_curveData.m_curveParamWritePoint+=i;const r=mn.toSegType(o);this.incCurveType(r,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,r)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributes(t,e,s,i){for(let o=t;o<s-1;o++)this.isClosedPath(o)&&f("cannot interpolate across closed paths");const n=this.m_description.getAttributeCount();if(1===n)return;const r=this.calculateSubLength2D(t,e,s,i);if(0!==r)for(let o=1;o<n;o++){const n=this.m_description.getSemantics(o);this.interpolateAttributesSemanticsImpl(n,t,e,s,i,r)}}interpolateAttributesSemantics(e,s,i,n,r){t(0)}interpolateAttributesPath(t,e,s){const i=this.m_description.getAttributeCount();if(1===i)return;if(e===s)return;const n=this.calculatePathSubLength2D(t,e,s);for(let r=1;r<i;r++){const i=this.m_description.getSemantics(r);this.interpolateAttributesSemanticsPathImpl(i,t,e,s,n)}}interpolateAttributesSemanticsPath(e,s,i,n){t(0)}interpolateAttributesSemanticsImpl(t,e,s,i,n,r){const o=this.querySegmentIterator(),a=this.getPathStart(e)+s,h=this.getPathStart(i)+n,m=hn.getComponentCount(t),u=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new Array(hn.maxComponentCount());ze(c,u,0,0,m);let d=0;const _=hn.getDefaultValue(t),g=hn.getInterpolation(t);o.resetToVertex(a,e);do{if(o.hasNextSegment()){if(o.nextSegment(),o.getStartPointIndex()===h)return;this.setAttributeFromArray(t,o.getStartPointIndex(),c,m),o.previousSegment();do{const e=o.nextSegment();if(o.getEndPointIndex()===h)return;d+=e.calculateLength2D();Le(g,u,l,c,0,m,d/r,_),o.isClosingSegment()||this.setAttributeFromArray(t,o.getEndPointIndex(),c,m)}while(o.hasNextSegment())}}while(o.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,n){const r=this.querySegmentIterator(),o=hn.getInterpolation(t),a=this.getPathStart(e)+s,h=this.getPathStart(e)+i;if(h===a)return;const m=hn.getComponentCount(t),u=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,a,u,m);const l=new Array(hn.maxComponentCount());this.queryAttributeAsDbl(t,h,l,m);const c=new At(0);r.resetToVertex(a,e),r.setCirculator(this.isClosedPath(e));const d=hn.getDefaultValue(t),_=new Array(hn.maxComponentCount());ze(_,u,0,0,m);const g=0===n;let p=.5;do{const e=r.nextSegment();if(this.setAttributeFromArray(t,r.getStartPointIndex(),_,m),!g){const t=e.calculateLength2D();c.pe(t),p=c.getResult()/n}Le(o,u,l,_,0,m,p,d)}while(r.getEndPointIndex()!==h)}querySegment(t,e,s){const i=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(i);n>=this.getSegmentCountPath(i)&&f("get_segment"),this.getSegmentFromPath(i,n,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(e){return t(0),r.enumUnknown}getSegmentFromPath(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getSegmentFlagsStreamRef();let o=1;switch(r&&(o=31&r.read(n)),o){case 1:s.createLine();break;case 2:s.createCubicBezier();break;case 4:s.createEllipticArc();break;case 8:s.createQuadraticRationalBezier();break;case 16:s.createQuadraticBezier();break;default:E("")}const a=s.get();let h,m=null;i?(m=vs.getDefaultDescription2D(),a.assignVertexDescription(m)):a.assignVertexDescription(this.m_description),h=n===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):n+1;Li(a,this.getXY(n));if(Vi(a,this.getXY(h)),!i)for(let u=1,l=this.m_description.getAttributeCount();u<l;u++){const t=this.m_description.getSemantics(u),e=hn.getComponentCount(t);for(let s=0;s<e;s++){const e=this.getAttributeAsDbl(t,n,s);a.setStartAttribute(t,s,e);const i=this.getAttributeAsDbl(t,h,s);a.setEndAttribute(t,s,i)}}if(un.isNonLinearSegmentFlag(o)){const t=this.m_curveData.m_segmentParamIndex.read(n);rn(this.m_curveData.m_segmentParams,t,a)}}queryPointAlongPath(t,e,s,i=!1){const n={iSegment:-1},r=i?n:{iSegment:-1,tSegment:0};if(s.setEmpty(),this.isEmpty())return n;if((t<0||t>=this.getPathCount())&&f("query_point_along_path"),e<0)return n;const o=this.getPathSize(t);if(0===o)return n;if(1===o)return this.getPointByVal(this.getPathStart(t),s),r.tSegment=0,n.iSegment=this.getPathStart(t),n;const a=this.querySegmentIteratorAtVertex(this.getPathStart(t)),h=new At(0);for(;a.hasNextSegment();){const t=a.nextSegment(),i=t.calculateLength2D(),o=h.getResult();if(h.add(i),h.getResult()>=e){let h=e-o;h>i&&(h=i);const m=t.lengthToT(h);return t.queryCoord(m,s),r.tSegment=m,n.iSegment=a.getStartPointIndex(),n}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),r.tSegment=1,n.iSegment=this.getPathEnd(t)-1,n}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(r.tSegment=1,n.iSegment=this.getPathEnd(t)-2,n):(r.tSegment=0,n.iSegment=this.getPathStart(t),n)}}queryPointsAlongPath(t,e,s,i,n,r){{let t=0;for(let o=0;o<e;++o)i&&i[o].setEmpty(),n&&(n[o]=-1),r&&(r[o]=0),t>s[o]&&f("query_points_along"),t=s[o]}const o=this.getPathSize(t);if(0===e||0===o)return 0;if(1===o){const e=this.getPathStart(t);return i&&this.getPointByVal(e,i[0]),r&&(r[0]=0),n&&(n[0]=e),1}const a=this.getPathStart(t),h=new At(0),m=this.querySegmentIteratorAtVertex(a);let u=0,l=0,c=s[u];for(;m.hasNextSegment();){const t=m.nextSegment(),o=t.calculateLength2D(),a=h.getResult();for(h.add(o);h.getResult()>=c;){let h=c-a;h>o&&(h=o);const d=t.lengthToT(h);if(i&&t.queryCoord(d,i[l]),r&&(r[l]=d),n&&(n[l]=m.getStartPointIndex()),l++,u++,c=s[u],u===e)return l}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;i&&this.getPointByVal(e,i[l]),r&&(r[l]=s),n&&(n[l]=e),l++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;i&&this.getPointByVal(e+1,i[l]),r&&(r[l]=s),n&&(n[l]=e),l++}return l}queryPointsAlong(t,e,s,i,n){{let r=0;for(let o=0;o<t;++o)s&&s[o].setEmpty(),i&&(i[o]=-1),n&&(n[o]=0),r>e[o]&&f("query_points_along"),r=e[o]}if(0===t)return 0;const r=new At(0),o=this.querySegmentIterator();let a=-1,h=0,m=0,u=e[h];for(;o.nextPath();)for(;o.hasNextSegment();){a=o.getPathIndex();const l=o.nextSegment(),c=l.calculateLength2D(),d=r.getResult();for(r.add(c);r.getResult()>=u;){let r=u-d;r>c&&(r=c);const a=l.lengthToT(r);if(s&&l.queryCoord(a,s[m]),n&&(n[m]=a),i&&(i[m]=o.getStartPointIndex()),m++,h++,u=e[h],h===t)return m}}if(a<0)return 0;if(this.isClosedPath(a)){const t=this.getPathStart(a),e=0;s&&this.getPointByVal(t,s[m]),n&&(n[m]=e),i&&(i[m]=t),m++}else if(this.getPathSize(a)>1){const t=this.getPathEnd(a)-2,e=1;s&&this.getPointByVal(t+1,s[m]),n&&(n[m]=e),i&&(i[m]=t),m++}return m}querySegmentIterator(){return new tn({parent:this})}querySegmentIteratorAtVertex(t){return new tn({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(e,s,i){if(s instanceof Cs&&t(0,"not implemented for Envelope"),(e>=this.getPathCount()||e<0)&&f(""),this.isEmpty())return void s.setEmpty();const n=this.getAttributeStreamRef(0),r=as.constructEmpty();r.setEmpty();for(let o=2*this.getPathStart(e),a=2*this.getPathEnd(e);o<a;){const e=a-o;t(!(1&e)),r.mergePointsInterleaved(n,o/2,e/2),o+=e}if(s.setCoords({env2D:r}),this.hasNonLinearSegmentsPath(e)){const n=this.querySegmentIterator();if(n.resetToPath(e),n.nextPath())for(;n.hasNextSegment();){const t=n.nextCurve();if(!t)break;{const e=as.constructEmpty();i?t.queryEnvelope(e):t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}else t(0)}}checkCompactSegmentParams(){if(!this.m_curveData||null===this.m_curveData.m_segmentParams)return!1;if(this.m_curveData.m_segmentParams.size()<=this.m_vertexAttributes.get(0).size())return!1;const t=10,e=sn(4)*this.m_curveData.m_arcCount+sn(2)*this.m_curveData.m_bezierCount+sn(8)*this.m_curveData.m_rbezier2Count+sn(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*e>>1,t)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let i=0,n=this.getPointCount();i<n;i++){const e=this.m_curveData.m_segmentFlags.read(i);if(un.isNonLinearSegmentFlag(e)){t+=sn(e)}}const e=Ms(t);let s=0;for(let i=0,n=this.getPointCount();i<n;i++){const t=this.m_curveData.m_segmentFlags.read(i);if(un.isNonLinearSegmentFlag(t)){let n=this.m_curveData.m_segmentParamIndex.read(i);this.m_curveData.m_segmentParamIndex.write(i,s);const r=sn(t);for(let t=0;t<r;t++)e.write(s,this.m_curveData.m_segmentParams.read(n)),s++,n++}}this.m_curveData.m_segmentParams=e,this.m_curveData.m_curveParamWritePoint=s}setPathsFromJsonArrays(e,s,i){t(!1===s),t(!1===e),this.setEmpty();const n=i.length;if(0===n)return;let o=0;for(const t of i)o+=t.length;const a=new Xs(2*o),h=new Fs(n);let m=0,u=0;for(let t=0;t<n;++t){h.write(t,m),m+=i[t].length;const e=i[t],s=e.length;for(let t=0;t<s;++t)a.write(u++,e[t][0]),a.write(u++,e[t][1])}const l=new Rs(h.size());l.setRange(this.getGeometryType()===r.enumPolygon?1:0,0,h.size()),this.setAttributeStreamRef(0,a),this.setPathFlagsStreamRef(l),this.setPathStreamRef(h),this.notifyModifiedFlags(65535)}setEmpty(){this.m_curveData&&(this.removeAllCurvesFromGlobalCounter(),this.m_curveData=null),this.m_bPathStarted=!1,this.m_paths=null,this.m_pathFlags=null,this.setEmptyImpl()}applyTransformation(t){this.applyTransformationToPath(t,-1)}applyTransformation3D(e){t(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=Is(0),this.m_pathFlags=Ns(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0))}reserveParts(e,s){t(0)}clone(){const t=this.createInstance();return this.copyTo(t),t}createShallowClone(){return t(0),this}queryLimitedSegmentIterator(t){return new ln(this,t)}getPathStreamRef(){return this.throwIfEmpty(),this.m_paths}setPathStreamRef(t){this.m_paths=t}getSegmentFlagsStreamRef(){return this.throwIfEmpty(),null!=this.m_curveData?this.m_curveData.m_segmentFlags:null}getPathFlagsStreamRef(){return this.throwIfEmpty(),this.m_pathFlags}setPathFlagsStreamRef(t){this.m_pathFlags=t}getSegmentIndexStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParamIndex:null}getSegmentDataStreamRef(){return this.throwIfEmpty(),null!==this.m_curveData?this.m_curveData.m_segmentParams:null}setSegmentData(t,e,s,i){this.m_curveData||(this.m_curveData=new mn),this.m_curveData.m_segmentFlags=s,this.m_curveData.m_segmentParams=e,this.m_curveData.m_segmentParamIndex=t,this.m_curveData.m_curveParamWritePoint=i}static getPathIndexFromPointIndexImpl(t,e,s,i){if(i>=0&&i<e){if(s>=t.read(i)){if(s<t.read(i+1))return i;i++}else i--;if(i>=0&&i<e&&s>=t.read(i)&&s<t.read(i+1))return i}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;p("")}let n=0,r=e-1;for(;r>n;){const e=n+(r-n>>1);if(s<t.read(e))r=e-1;else{if(!(s>=t.read(e+1)))return e;n=e+1}}return n}getHighestPointIndex(e){return t(0),0}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&f("apply_transformation"),this.isEmpty())return;if(t.isIdentity())return;const s=this.m_vertexAttributes.get(0);if(!(e<0?this.hasNonLinearSegments():this.hasNonLinearSegmentsPath(e))){let i,n;return e<0?(i=0,n=this.m_pointCount):(i=this.getPathStart(e),n=this.getPathEnd(e)),s.applyTransformation(t,2*i,n-i),void this.notifyModifiedFlags(2001)}const i=new this.m_segmentBufferCTor,n=this.getPathCount();let r=e<0?0:e;do{const n=this.getPathStart(r),o=this.getPathEnd(r),a=this.isClosedPath(r),h=s.readPoint2D(2*n);if(!this.hasNonLinearSegmentsPath(r)){s.applyTransformation(t,2*n,o-n);continue}const m=os.getNAN();for(let e=n;e<o;++e){if(1!==(31&this.m_curveData.m_segmentFlags.read(e))){const r=a&&e+1===o;r&&s.writePoint2D(2*n,h),this.getSegmentBuffer(e,i,!0),i.get().applyTransformation(t);const m=this.m_curveData.m_segmentParamIndex.read(e);nn(this.m_curveData.m_segmentParams,m,i.get()),s.writePoint2D(2*e,i.get().getStartXY()),r&&s.writePoint2D(2*n,i.get().getEndXY());continue}const r=2*e;s.queryPoint2D(r,m),t.transformInPlace(m),s.writePoint2D(r,m)}if(r===e)break}while(++r<n);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,i){const n=this.getPathStart(t)+e,r=this.getPathStart(s)+i;(r<n||n<0||r>this.getPointCount()-1)&&y("");const o=this.querySegmentIterator();let a=0;o.resetToVertex(n,t);do{for(;o.hasNextSegment();){const t=o.nextSegment();if(o.getStartPointIndex()===r)break;a+=t.calculateLength2D()}if(o.getStartPointIndex()===r)break}while(o.nextPath());return a}calculatePathSubLength2D(t,e,s){const i=this.getPathStart(t)+e,n=this.getPathStart(t)+s;(i<0||n>this.getPointCount()-1)&&y("");const r=this.querySegmentIterator();if(i>n&&(this.isClosedPath(t)||f("cannot iterate across an open path"),r.setCirculator(!0)),i===n)return 0;let o=0,a=0;r.resetToVertex(i,t);do{a+=o;o=r.nextSegment().calculateLength2D()}while(r.getStartPointIndex()!==n);return a}calculateEnvelope2D(e){return t(0),new as(0,0,0,0)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=as.constructEmpty(),i=this.querySegmentIterator();for(;i.nextPath();)for(;i.hasNextSegment();){const n=i.nextCurve();if(!n)break;t?n.queryEnvelope(s):n.queryLooseEnvelope(s),e.mergeEnvelope2D(s)}}return e}notifyModifiedAllImpl(){null!==this.m_paths&&this.m_paths.size()?this.m_pointCount=this.m_paths.read(this.m_paths.size()-1):this.m_pointCount=0}setDirtyOGCFlags(t){this.setDirtyFlagProtected(16,t)}hasDirtyOGCStartFlags(){return this.hasDirtyFlag(16)}setDirtyRingAreas2D(t){this.setDirtyFlagProtected(1024,t)}hasDirtyRingAreas2D(){return this.hasDirtyFlag(1024)}static isNonLinearSegmentFlag(t){return!(1&t)}addAndExplicitlyOpenAllPaths(t,e){this===t&&f("Multi_path_impl::add");let s=this.getPathCount();for(let i=0,n=t.getPathCount();i<n;i++)this.addPath(t,i,!e),this.openPathAndDuplicateStartVertex(s),s++}getSegmentFlags(t){return null!==this.m_curveData&&null!==this.m_curveData.m_segmentFlags?this.m_curveData.m_segmentFlags.read(t):1}getSegmentBuffer(t,e,s){const i=this.getPathIndexFromPointIndex(t),n=t-this.getPathStart(i);n>=this.getSegmentCountPath(i)&&f("getSegmentBuffer"),this.getSegmentFromPath(i,n,e,s)}getSegmentTypeFromPath(e,s){return t(0),r.enumBezier}ensureXYMonotoneSegments(){return t(0),!1}buildRasterizedGeometryAccelerator(e,s){return t(0),!1}buildQuadTreeAccelerator(e){return t(0),!1}buildQuadTreeForPathsAccelerator(e){return t(0),!1}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(un.st_totalCurveCount-=this.m_curveData.m_curveCount,this.m_curveData.m_curveCount=0,this.m_curveData.m_bezierCount=0,this.m_curveData.m_arcCount=0,this.m_curveData.m_bezier2Count=0,this.m_curveData.m_rbezier2Count=0,this.m_curveData.m_curveParamWritePoint=0)}modifyCurveCounter(t){t&&(this.m_curveData||(this.m_curveData=new mn),un.st_totalCurveCount+=t,this.m_curveData.m_curveCount+=t)}getCurveCount(){return this.m_curveData?this.m_curveData.m_curveCount:0}incCurveType(t,e){this.m_curveData||(this.m_curveData=new mn),2&t?this.m_curveData.m_bezierCount+=e:4&t?this.m_curveData.m_arcCount+=e:8&t?this.m_curveData.m_rbezier2Count+=e:16&t&&(this.m_curveData.m_bezier2Count+=e)}getCurveWritePoint(){return t(0),0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new mn);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=Ns(e,1),this.m_curveData.m_segmentParamIndex=Is(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=Ms(s):s!==this.m_curveData.m_segmentParams.size()&&this.m_curveData.m_segmentParams.resize(s,0),this.m_curveData.m_segmentFlags.size()<e&&(this.m_curveData.m_segmentFlags.resize(e,1),this.m_curveData.m_segmentParamIndex.resize(e,-1))}updateCurveWritePoint(e){t(0)}updateOGCFlagsHelper(){const t=this.getPathCount();if(0===t)return;const e=this.m_pathFlags;let s=0;for(let i=0;i<t;i++){const t=this.m_cachedRingAreas2D.read(i);0===s&&(s=ge(t)),t*s>0||0===s?e.setBits(i,8):e.clearBits(i,8)}}updateOGCFlagsProtected(){this.hasDirtyFlag(16)&&(this.updateRingAreas2DProtected(),this.updateOGCFlagsHelper(),this.setDirtyFlagProtected(16,!1))}replaceSegment(e,s,i){(e<0||e>=this.getPointCount())&&f("Multi_path_impl.replace_segment"),t(s.isCurve());const n=this.getPathIndexFromPointIndex(e),r=this.getPathStart(n),o=(e-r+1)%this.getPathSize(n)+r;{const i=this.getXY(e),n=this.getXY(o);t(!(!i.isEqualPoint2D(s.getStartXY())||!n.isEqualPoint2D(s.getEndXY())))}const a=s.getDescription();this.mergeVertexDescription(a);const h=new Array(32),m=new Ci({vd:a,attribBuffer:h,initDefaultValues:!1}),u=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(e),l=sn(u),c=en(s);let d,_=!1;l>=c?(t(null!==this.m_curveData),_=!0,d=this.m_curveData.m_segmentParamIndex.read(e)):(this.initSegmentData(c),_=!1,d=this.m_curveData.m_curveParamWritePoint);const g=s.getGeometryType(),p=mn.toSegType(g);i||(s.queryStart(m),this.setPointByVal(e,m),s.queryEnd(m),this.setPointByVal(o,m)),this.m_curveData.m_segmentParamIndex.write(e,1!==p?d:-1),this.m_curveData.m_segmentFlags.write(e,p),1!==p&&nn(this.m_curveData.m_segmentParams,d,s),_||(this.m_curveData.m_curveParamWritePoint+=c),u!==p&&(this.incCurveType(u,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===u?1:-1))}verifyPathIndex(e){t(0)}setAttributeImpl(e,s,i){t(0)}}un.st_totalCurveCount=0;class ln{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_extentOfInterest=new as(e),this.m_bfirst=!0,this.m_prevIndex=-100,this.m_parent=t}nextSegment(){return this.m_bfirst&&this.prepare_(),this.m_quadTree?this.nextSegmentQt():this.nextSegmentNoQt()}getPathIndex(){return this.m_segIter.getPathIndex()}getStartPointIndex(){return this.m_segIter.getStartPointIndex()}getEndPointIndex(){return this.m_segIter.getEndPointIndex()}isClosingSegment(){return this.m_segIter.isClosingSegment()}isPathClosed(){return this.m_segIter.isPathClosed()}prepare_(){this.m_parent.getAccelerators(),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){return t(0),"not implemented"}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=as.constructEmpty();if(t.queryLooseEnvelope(e),!e.isIntersecting(this.m_extentOfInterest))continue;return t}if(this.m_bfirst=!1,!this.m_segIter.nextPath())return null}}}class cn{constructor(t){void 0===t?this.setIdentity():t instanceof cn?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 cn).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(e){return t(0),!1}transformInPlace(t){const e=this.xx*t.x+this.xy*t.y+this.xd,s=this.yx*t.x+this.yy*t.y+this.yd;t.x=e,t.y=s}transform(e){return t(0),os.getNAN()}queryTransform(t,e){const s=this.xx*t.x+this.xy*t.y+this.xd,i=this.yx*t.x+this.yy*t.y+this.yd;e.setCoords(s,i)}transformEnvInPlace(e){t(0)}queryTransformEnv(e,s){t(0)}transformInterleaved(e,s,i){t(0)}transformPoints(t,e,s){for(let i=0;i<e;++i)this.queryTransform(t[i],s[i])}transformInterleavedPoints(t,e,s){e*=2;const i=os.getNAN();for(let n=0;n<e;n+=2)i.x=t[n],i.y=t[n+1],this.transformInPlace(i),s[n]=i.x,s[n+1]=i.y}multiply(t){return cn.st_multiply(this,t,this),this}mulLeft(e){return t(0),this}static st_multiply(t,e,s){const i=t.xx*e.xx+t.yx*e.xy,n=t.xy*e.xx+t.yy*e.xy,r=t.xd*e.xx+t.yd*e.xy+e.xd,o=t.xx*e.yx+t.yx*e.yy,a=t.xy*e.yx+t.yy*e.yy,h=t.xd*e.yx+t.yd*e.yy+e.yd;s.xx=i,s.xy=n,s.xd=r,s.yx=o,s.yy=a,s.yd=h}getCoefficients(e){t(0)}setCoefficients(t){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(e){t(0)}initializeFromRect(e,s){t(0)}initializeFromRectIsotropic(e,s){t(0)}initializeFromCurveParameters(e,s,i){t(0)}initializeFromTwoPointsArray(t,e){if(t[0].equals(e[0])&&t[1].equals(e[1]))return void this.setIdentity();if(t[0].equals(t[1])){if(e[0].equals(e[1]))return void this.setShift(e[0].sub(t[0]));f("")}if(!t[0].equals(t[1])&&e[0].equals(e[1]))return this.setZero(),void this.shift(e[0]);this.setShiftCoords(-t[0].x,-t[0].y);const s=os.distance(t[0],t[1]),i=os.distance(e[0],e[1]),n=i/s;this.scale(n,n);const r=t[1].sub(t[0]);r.divThis(s);const o=e[1].sub(e[0]);o.divThis(i);const a=r.crossProduct(o),h=r.dotProduct(o);this.rotate(h,a),this.shiftCoords(e[0].x,e[0].y)}initializeFromTwoPoints(t,e,s,i){const n=[t,e],r=[s,i];this.initializeFromTwoPointsArray(n,r)}transformSizeInPlace(e){t(0)}transformSize(e,s){t(0)}transformTol(e){return t(0),0}transformWithoutTranslateArray(e,s,i){t(0)}transformWithoutTranslateInPlace(t){const e=this.xx*t.x+this.xy*t.y,s=this.yx*t.x+this.yy*t.y;t.setCoords(e,s)}transformWithoutTranslate(e,s){t(0)}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(e){return t(0),!1}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(e){return t(0),!1}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return t(0),!1}isTranslateTol(e){return t(0),!1}isOrthonormal(e){return t(0),!1}isDegenerate(e){return t(0),!1}isZero(){return t(0),!1}isScaleAndTranslate(e){return t(0),!1}setTranslate(e,s){return t(0),this}setShiftCoords(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,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,e){return this.xx=t,this.xy=0,this.xd=0,this.yx=0,this.yy=e,this.yd=0,this}setScale(t){return this.setScaleCoords(t,t),this}setFlipX(e,s){return t(0),this}setFlipY(e,s){return t(0),this}setShear(e,s){return t(0),this}scale(t,e){return this.xx*=t,this.xy*=t,this.xd*=t,this.yx*=e,this.yy*=e,this.yd*=e,this}setRotateAngle(t){return this.setRotate(Math.cos(t),Math.sin(t))}setRotate(t,e){return this.xx=t,this.xy=-e,this.xd=0,this.yx=e,this.yy=t,this.yd=0,this}setRotateAngleAbout(e,s){return t(0),this}setRotateAbout(e,s,i){return t(0),this}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return t(0),this}setRotateCcw90(){return t(0),this}shiftCoords(t,e){return this.xd+=t,this.yd+=e,this}shift(t){return this.xd+=t.x,this.yd+=t.y,this}translate(t,e){return this.xd+=t,this.yd+=e,this}flip_x(e,s){return t(0),this}flip_y(e,s){return t(0),this}shear(e,s){return t(0),this}rotateAngle(t){const e=new cn;return e.setRotateAngle(t),this.multiply(e)}rotate(t,e){const s=new cn;return s.setRotate(t,e),this.multiply(s)}rotateAbout(e,s,i){return t(0),this}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 e=(this.xy*this.yd-this.xd*this.yy)*t,s=(this.xd*this.yx-this.xx*this.yd)*t,i=this.yy*t,n=-this.xy*t,r=-this.yx*t,o=this.xx*t;return this.xd=e,this.yd=s,this.xx=i,this.yy=o,this.xy=n,this.yx=r,this}invertPrecise(t){return this.set(t),this.invertPreciseThis()}invertPreciseThis(){return t(0),this}extractScaleTransform(e,s){t(0)}setFromTwoTriangles(t,e){let s=!0;for(let m=0;m<3;++m)s=s&&t[m].equals(e[m]);if(s)return this.setIdentity(),!0;const i=new os;i.setSub(t[0],t[1]);const n=new os;n.setSub(t[0],t[2]);const r=new os;r.setSub(e[0],e[1]);const o=new os;o.setSub(e[0],e[2]);const a=4*Number.EPSILON*(Math.abs(i.x*n.y)+Math.abs(n.x*i.y));let h=i.x*n.y-i.y*n.x;return Math.abs(h)>a?(h=1/h,this.xx=(r.x*n.y-i.y*o.x)*h,this.xy=(i.x*o.x-r.x*n.x)*h,this.yx=(r.y*n.y-i.y*o.y)*h,this.yy=(i.x*o.y-r.y*n.x)*h,this.xd=e[0].x-(this.xx*t[0].x+this.xy*t[0].y),this.yd=e[0].y-(this.yx*t[0].x+this.yy*t[0].y),!0):(this.setZero(),!1)}}class dn extends bi{constructor(t){super(t)}assignCopy(e){return t(0),this}assignMove(e){return t(0),this}insertPoint2D(e,s){t(0)}insertPoint(e,s){t(0)}insertPoints(e,s,i){t(0)}insertPoints2D(e,s,i){t(0)}removePoints(e,s){t(0)}removePoint(e){t(0)}calculateEnvelope2D(){return t(0),new as(0,0,0,0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s),i=gs.getDefaultValue(t),n=gs.getComponentCount(t);this.m_vertexAttributes.get(s).insertRange(n*e,i,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(e,s,i,n){return t(0),0}getAttributeAsDbl(e,s,i){return t(0),0}getAttributeAsInt(e,s,i){return t(0),0}queryAttributeAsInt(e,s,i,n){t(0)}setAttribute(e,s,i,n){t(0)}add(t){t.isEmpty()&&f(Pi),this.resizeAndInitNonPositionAttributes(this.m_pointCount+1),this.setPointByVal(this.m_pointCount-1,t)}addXY(t,e){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const s=new os(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(e,s,i){t(0)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){}addPoints(t,e,s){this===t&&f("Multi_point_impl.add");const i=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||i<e)&&f(""),e===i)return;const n=t.getDescription();this.mergeVertexDescription(n);const r=i-e,o=this.m_pointCount;this.resizeNoInit(this.m_pointCount+r);for(let a=0,h=this.m_description.getAttributeCount();a<h;a++){const s=this.m_description.getSemantics(a),i=gs.getComponentCount(s),h=this.getAttributeStreamRef(s);if(n.hasAttribute(s)){const n=t.getAttributeStreamRef(s);h.insertRangeFromStream(o*i,n,e*i,r*i,!0,1,o*i)}else{const t=gs.getDefaultValue(s);h.insertRange(o*i,t,r*i,o*i)}}}addPoints2D(t,e,s,i){let n=e;const r=i<0?n:i;if((n<0||s<0||s>n||r<s)&&f(""),s===r)return;n=r-s;const o=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+n);const a=this.getAttributeStreamRef(0);for(let h=0;h<n;++h)a.writePoint2D(2*(o+h),t[s+h]);this.notifyModifiedFlags(2001)}addPoints3D(e,s,i,n){t(0)}getGeometryType(){return r.enumMultiPoint}getDimension(){return 0}createInstance(){return new dn({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(e){if(this.isEmpty())return;if(e.isIdentity())return;const s=this.m_vertexAttributes.get(0);e instanceof cn?s.applyTransformation(e,0,this.m_pointCount):t(0),this.notifyModifiedFlags(2001)}calculateArea2D(){return t(0),0}calculateLength2D(){return t(0),0}calculateLength3D(e){return t(0),0}equals(t,e){return t.getGeometryType()===r.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(e){e instanceof Cs?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,e)):e instanceof as?this.updateEnvelope(e):t(0)}queryInterval(e,s){return t(0),new kt(0,0)}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}capacity(){return t(0),0}clone(){return t(0),this}swap(e){t(0)}setAttributeBasic(e,s,i){t(0)}buildRasterizedGeometryAccelerator(e,s){return t(0),!1}buildQuadTreeAccelerator(e){return t(0),!1}getHashCodeImpl(){return t(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}dn.type=r.enumMultiPoint;class _n{isIdentity(){return t(0),!0}}class gn{constructor(){this.m_factor=1,this.m_wkid=9001}getUnitType(){return 0}convertFromMeters(t){return t/this.getUnitToBaseFactor()}convertToMeters(t){return t*this.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getName(){return""}getDisplayName(){return""}getPluralDisplayName(){return""}getID(){return 0}getConversionFactor(t){return 1}getAbbreviation(){return""}equals(t){return!1}}class pn{constructor(t,e=!0){this.m_csType=0,this.m_PCSHorizon=null,this.m_GCSHorizon=null,this.m_GCSSplitLines=null,this.m_GCSHorisonIsInclusive=!1,this.m_oneMeterPCS=1,this.m_oneDegreeGCS=1,this.m_gcsUnitFactor=0,this.m_northPole=os.getNAN(),this.m_southPole=os.getNAN(),this.m_polesUpdated=0,this.m_domain=as.constructEmpty(),this.m_primeMeridian=Number.NaN,this.m_geogToProjFactor=1,this.m_geogToProjOffset=0,this.m_geogToProjFactorsUpdated=0,this.m_oneMillimeter=0,this.m_centralMeridian=0,this.m_pPCSInfoNoDomain=null,this.m_WKID=-1,this.m_oldWKID=-1973,this.m_vcsWKID=-1,this.m_bIsPannable=!1,this.m_cached=!1,this.m_pannableExtent=as.constructEmpty(),this.m_pannableExtentGCS=as.constructEmpty(),this.m_unit=new gn,this.m_areaOfUse=null,this.m_canonicalWkt="not yet implemented",this.m_PECoordSys=t}getPCSHorizonPannable(){return{}}getGCSHorizonPannable(){return{}}updateGCSHorizon(){}updateAreaOfUse(){return{}}updatePCSHorizon(){}updatePannableExtent(){}updatePannableExtentGCS(){}updateDomain(){}updatePoles(){}updateGeogToProjFactors(){}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return 0}getUnitsPerMillimeter(){return this.m_oneMillimeter}getCentralMeridian(){return 0}get_GCS_split_lines(){return{}}getGCSHorizon(){return{}}getGCSHorisonIsInclusive(){return!1}getPCSHorizon(){return{}}getPole(t){return new os}getGeogToProjFactors(){return{}}getDomainXY(){if(this.m_bIsPannable)return this.m_domain;let t=!1;return t=this.m_domain.isEmpty(),t&&this.updateDomain(),this.m_domain}getPCSInfo(){return{}}getPrimeMeridian(){return 0}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;return t<0&&(t=0,this.m_WKID>0&&(t=this.m_WKID),this.m_oldWKID=t),t}isCustomWkid(){return!1}isPannable(){return!1}getPannableExtent(){return{}}getPannableExtentGCS(){return{}}getAreaOfUse(){return{}}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_cached=!0}getCached(){return this.m_cached}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}class fn{constructor(t,e=!0){this.m_oneMeter=0,this.m_WKID=-1,this.m_oldWKID=-1,this.m_canonicalWkt="not yet implemented",this.m_model=0,this.m_unit=new gn,this.m_cached=!1}setCached(t=!0){this.m_cached=t}getCached(){return this.m_cached}getOneMeterUnit(){return 0}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;return t<0&&(t=0,this.m_WKID>0&&(t=this.m_WKID),this.m_oldWKID=t),t}getModel(){return 0}isCustomWkid(){return!1}getVerticalUnit(){return this.m_unit}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}const xn=new Map;function yn(t){t<=0&&I(t);{const e=bn(t);if(e)return e}const e=new pn({},!0);return e.m_WKID=t,e.m_csType=t===qn.GCS_WGS_1984?1:2,xn.set(t,new WeakRef(e)),e}function vn(t){const e=new fn({},!0);return e.m_WKID=t,e}function Pn(t){return t>0}function bn(t){const e=xn.get(t);if(e)return e.deref()}function En(t){const e=vn(t),s=new Dn;return s.setVertProj_(e),s}function Cn(t){return Pn(t)}class Dn{constructor(){this.m_hashCode=0,this.m_PEVertSysVal=null,this.m_verticalUnit=new gn,this.m_verticalShift=0,this.m_userVerticalWKID=0,this.m_bIsDepth=!1}getType(){return 0}getID(){return 0}getLatestID(){return this.m_PEVertSysVal?this.m_PEVertSysVal.getLatestID():0}getOldID(){return this.m_PEVertSysVal?this.m_PEVertSysVal.getOldID():0}getText(){return""}getTextExtended(t){return""}getText2(t){return""}getUnit(){return t(0),{}}equals(t){return!1}getPeVertcsCopy(){return{}}getOneMeter(){return 1/this.m_verticalUnit.getUnitToBaseFactor()}getUnitToBaseFactor(){return 0}isDepth(){return!1}getVerticalShift(){return 0}isCustomWkid(){return!!this.m_PEVertSysVal&&this.m_PEVertSysVal.isCustomWkid()}setVertProj_(t){this.m_PEVertSysVal=t}}const Sn=2147483645n,wn=9007199254740990n,An=1,Tn=2;var In;function Nn(t,e,s){return Wn(t,0,null,!1)}function Mn(t,e){return{}}!function(t){t[t.utmDefault=0]="utmDefault",t[t.utmNorthSouth=1]="utmNorthSouth"}(In||(In={}));class qn{constructor(){this.m_vertcs=null,this.m_PECoordSysVal=null,this.m_unit=null,this.m_userWKID=-1,this.m_geogSpatialReferenceInitialized=0,this.m_geogSpatialReference=null,this.m_srToGcs=null,this.m_gcsToSr=null,this.m_defaultPrecisionSr=null,this.m_localZToXYFactor=Number.NaN,this.m_precisionDescriptor=new Rn,this.m_hashCode=0,this.m_defaultDescriptor=!1,this.m_precisionDescriptor=new Rn,this.m_localZToXYFactor=-1,this.m_userWKID=0,Bn(this.m_precisionDescriptor),this.m_hashCode=0,this.m_defaultDescriptor=!1,this.m_geogSpatialReferenceInitialized=0}calculateHashCode(){}initDbgName(){}setHorzProj_(t){this.m_PECoordSysVal=t,this.m_unit=this.m_PECoordSysVal.getUnit()}getTolerance(t=0){return this.m_precisionDescriptor.getTolerance(t)}getResolution(t){return this.m_precisionDescriptor.getResolution(t)}getCoordinateSystemType(){return 4326===this.m_PECoordSysVal?.m_WKID?1:2}getID(){return 0}getLatestID(){return this.m_PECoordSysVal?this.m_PECoordSysVal.getLatestID():0}getOldID(){return this.m_PECoordSysVal?this.m_PECoordSysVal.getOldID():0}getVerticalID(){return 0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return 0}getText(){return""}getTextExtended(t){return""}getText2(t=-1){return""}getUnit(){return{}}getAuthorityName(){return""}getVerticalUnit(){return{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCS(){return{}}toMilitaryGrid(t,e,s,i,n){return[]}fromMilitaryGrid(t,e){return[]}toUnitedStatesNationalGrid(t,e,s,i){return[]}fromUnitedStatesNationalGrid(t){return[]}toUniversalTransverseMercator(t,e,s){return[]}fromUniversalTransverseMercator(t,e){return[]}toWorldGeographicReference(t,e,s){return[]}fromWorldGeographicReference(t){return[]}toGlobalArea(t){return[]}fromGlobalArea(t,e){return[]}toDegreeMinuteSecond(t,e){return[]}fromDegreeMinuteSecond(t){return[]}toDegreeDecimalMinute(t,e){return[]}fromDegreeDecimalMinute(t){return[]}toDecimalDegree(t,e){return[]}fromDecimalDegree(t){return[]}fromGeohashToGCSEnvelope(t){return{}}toGeohash(t,e){return""}calculateContainingGeohash(t){return"1;"}calculateCoveringGeohashes(t,e){return[]}calculateGeohashNeighbours(t){return[]}calculateGeohashNeighbour(t,e,s){return""}isPannable(){return!1}getPannableExtent(){return{}}getFullWorldExtent(){return{}}queryPrecisionDescriptor(e){if(e.assign(this.m_precisionDescriptor),Number.isNaN(e.m_falseX))if(t(null!==this.m_PECoordSysVal),2!==this.m_precisionDescriptor.m_precision){const t=this.m_PECoordSysVal.getDomainXY();e.m_falseX=t.xmin,e.m_falseY=t.ymin}else e.m_falseX=-Number.MAX_VALUE,e.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(t){}equals(t){return!1}equalHorizontal(t){return!1}equalVertical(t){return!1}equalVerticalVCS(t){return!1}convergenceAngle(t){return 0}getPeCoordsysCopy(){return 0}getPeVertcsCopy(){return 0}getSRToGCSTransform(){return{}}getGCSToSRTransform(){return{}}getOneMeter(){return 0}querySpheroidData(t){}getAreaOfUse(){return{}}getZToXyFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return 1}getGcsUnitFactor(){return 1}snapGeometry(t){if(t.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const e=t.getGeometryType();if(l(e))return this.snapMultiVertex_(t);if(e===r.enumPoint)return this.snapPoint_(t);if(e===r.enumEnvelope)return this.snapEnvelope_(t);if(u(e))return this.snapSegment_(t);if(e===r.enumGeometryCollection){const e=t;let s=!1;for(let t=0,i=e.getGeometryCount();t<i;++t)s=this.snapGeometry(e.getGeometry(t))||s;return s}E("what else?")}snapMultiVertex_(e){if(t(!e.isEmpty()),t(2!==this.m_precisionDescriptor.getPrecision()),c(e.getGeometryType())){const t=e;if(t.hasNonLinearSegments())return this.snapGeometryWithCurves_(t)}const s=e.getImpl(),i=s.getDescription();let n=!1;for(let t=0,r=i.getAttributeCount();t<r;t++){const e=i.getSemantics(t),r=s.getAttributeStreamRef(e);n=this.snapAttributes(e,r,0,s.getPointCount())||n}return n&&s.notifyModifiedFlags(2001),n}snapPoint_(t){return!1}snapEnvelope_(t){return!1}snapSegment_(t){return!1}snapGeometryWithCurves_(t){return!1}snapAttributes(t,e,s,i){let n=!1;const r=new Rn;if(this.queryPrecisionDescriptor(r),0===t){const t=e;for(let e=s;e<i;e++){const s=t.read(2*e),i=qn.s_SnapValue(s,r.getFalseX(),r.getGridUnitsXy()),o=t.read(2*e+1),a=qn.s_SnapValue(o,r.getFalseY(),r.getGridUnitsXy());n=n||i!==s||a!==o,n&&(t.write(2*e,i),t.write(2*e+1,a))}}else if(1===t){const t=e;for(let e=s;e<i;e++){const s=t.read(e),i=qn.s_SnapValue(s,r.getFalseZ(),r.getGridUnitsZ());n=n||!H(i,s),n&&t.write(e,i)}}else if(2===t){const t=e;for(let e=s;e<i;e++){const s=t.read(e),i=qn.s_SnapValue(s,r.getFalseM(),r.getGridUnitsM());n=n||!H(i,s),n&&t.write(e,i)}}return n}static s_SnapValue(t,e,s){return te((t-e)*s)/s+e}}qn.GCS_WGS_1984=4326,qn.PCS_WGS_1984_WEB_MERCATOR_AUXSPHERE=3857,qn.c_suLimit32=2147483645n,qn.c_suLimit64=9007199254740990n;class Rn{constructor(){const t=wn,e=1e-4,s=.001,i=e*Number(t)*.5;this.m_precision=1,this.m_falseX=-i,this.m_falseY=-i,this.m_unitsXY=Number(t)/(2*i),this.m_falseM=-1e5,this.m_unitsM=1/e,this.m_falseZ=-1e5,this.m_unitsZ=1/e,this.m_toleranceXY=s,this.m_toleranceM=s,this.m_toleranceZ=s}clone(){const t=new Rn;return t.m_falseX=this.m_falseX,t.m_falseY=this.m_falseY,t.m_unitsXY=this.m_unitsXY,t.m_falseZ=this.m_falseZ,t.m_unitsZ=this.m_unitsZ,t.m_falseM=this.m_falseM,t.m_unitsM=this.m_unitsM,t.m_toleranceXY=this.m_toleranceXY,t.m_toleranceZ=this.m_toleranceZ,t.m_toleranceM=this.m_toleranceM,t.m_precision=this.m_precision,t}assign(t){return this.m_falseX=t.m_falseX,this.m_falseY=t.m_falseY,this.m_unitsXY=t.m_unitsXY,this.m_falseZ=t.m_falseZ,this.m_unitsZ=t.m_unitsZ,this.m_falseM=t.m_falseM,this.m_unitsM=t.m_unitsM,this.m_toleranceXY=t.m_toleranceXY,this.m_toleranceZ=t.m_toleranceZ,this.m_toleranceM=t.m_toleranceM,this.m_precision=t.m_precision,this}initialize2D(t,e){}getTolerance(t){switch(t){case 0:return this.m_toleranceXY;case 1:return this.m_toleranceZ;case 2:return this.m_toleranceM;default:return 0}}getResolution(t){if(2===this.m_precision)return 0;switch(t){case 0:return 1/this.m_unitsXY;case 1:return 1/this.m_unitsZ;case 2:return 1/this.m_unitsM;default:return 0}}getFalseX(){return this.m_falseX}getFalseY(){return this.m_falseY}getFalseZ(){return this.m_falseZ}getFalseM(){return this.m_falseM}getGridUnitsXy(){return this.m_unitsXY}getGridUnitsZ(){return this.m_unitsZ}getGridUnitsM(){return this.m_unitsM}getPrecision(){return this.m_precision}static getLimit32(){return 2147483645}static getLimit64(){return 9007199254740990n}static getLimitFloat(){return 0}getXYGridRange(){return{}}getZGridRange(){return{}}getMGridRange(){return{}}setTolerance(t,e){}setGridParams(t,e,s){}setZParams(t,e){}setMParams(t,e){}setPrecision(t){}equals(t){return!1}snapPrecision(){if(2===this.m_precision)return;const t=(t,e,s,i)=>{if(!Number.isFinite(e)||!Number.isFinite(s))return s;if(s<1)return 1;if(!i)return s;const n=Number(t)/s;return Math.trunc((e+n-e)*s)>t&&(s=t/(e+n-e)),Math.max(1,s)},e=Number(0===this.m_precision?qn.c_suLimit32:qn.c_suLimit64);this.m_unitsXY=t(e,this.m_falseX,this.m_unitsXY,!0),this.m_unitsXY=t(e,this.m_falseY,this.m_unitsXY,!0),this.m_unitsZ=t(e,this.m_falseZ,this.m_unitsZ,!1),this.m_unitsM=t(e,this.m_falseM,this.m_unitsM,!1)}verifyPrecision(){if(2===this.m_precision)return!0;const t=(t,e,s,i)=>{if(s<1)return!1;if(!Number.isFinite(e)||!Number.isFinite(s))return!1;if(!i)return!0;const n=Number(t)/s;return!(BigInt((e+n-e)*s)>t)},e=0===this.m_precision?Sn:wn;return!!t(e,this.m_falseX,this.m_unitsXY,!0)&&(!!t(e,this.m_falseY,this.m_unitsXY,!0)&&(!!t(e,this.m_falseZ,this.m_unitsZ,!1)&&!!t(e,this.m_falseM,this.m_unitsM,!1)))}fixTolerance(){}equalsWithoutFalseXY(t){return!1}setBestXyDomainFromEnvelope(t,e){}setBestZDomainFromZRange(t,e,s){}setBestMDomainFromMRange(t,e,s){}}let Fn=null;function Yn(){return Fn=Wn(3857,0,null,!0),Fn}let Xn=null;function Ln(){return Xn=Wn(102100,0,null,!0),Xn}let zn=null;function Vn(){return zn=Wn(4326,0,null,!0),zn}function Bn(t){t.m_falseX=0,t.m_falseY=0,t.m_unitsXY=1,t.m_falseZ=0,t.m_unitsZ=1,t.m_falseM=0,t.m_unitsM=1,t.m_toleranceXY=100*yt(),t.m_toleranceZ=100*yt(),t.m_toleranceM=100*yt(),t.m_precision=2}function kn(t,e,s,i){Bn(t),t.m_precision=i,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const n=1e-4,r=.001,o=1===e.m_csType?An:Tn;if(o===An){const s=1e-9*e.getOneDegreeGCSUnit();t.m_unitsXY=1/s}else if(o===Tn){const s=n*e.getOneMeterPCSUnit();t.m_unitsXY=1/s}t.m_falseM=-1e5,t.m_unitsM=1/n,t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let a=0,h=0;a=2/t.m_unitsXY,h=2/t.m_unitsM,t.m_toleranceXY=Math.max(a,e.getUnitsPerMillimeter()),t.m_toleranceM=Math.max(r,h),Gn(t,s)}function Gn(t,e){const s=1e-4,i=.001;if(t.m_falseZ=-1e5,e){const n=(0===t.m_precision?i:s)*e.getOneMeter();t.m_unitsZ=1/n}else t.m_unitsZ=1/(0===t.m_precision?i:s);t.m_unitsZ=Math.max(1,t.m_unitsZ);let n=0;0!==t.m_precision&&1!==t.m_precision||(n=2/t.m_unitsZ),t.m_toleranceZ=Math.max(e?e.getOneMeter()*i:i,n)}function Wn(t,e,s,i){if(!i&&0===e&&!s){if(3857===t)return Yn();if(102100===t)return Ln();if(4326===t)return Vn()}const n=yn(t);e<=0&&Cn(t)&&(e=t);let r=null;e>0?r=En(e):e=0;const o=new qn;return o.setHorzProj_(n),o.m_vertcs=r,kn(o.m_precisionDescriptor,n,r,1),o.m_defaultDescriptor=!0,o.m_userWKID=t,o.calculateHashCode(),o.initDbgName(),o}var Zn=gs;class Hn{constructor(e){this.m_attributes=null,this.m_description=void 0!==e.vd?e.vd:vs.getDefaultDescription2D();const s=this.m_description.getTotalComponentCount()-2;s&&(this.m_attributes=new Array(2*s)),void 0!==e.XStart?(this.m_XStart=e.XStart,this.m_YStart=e.YStart,this.m_XEnd=e.XEnd,this.m_YEnd=e.YEnd):void 0!==e.start?(this.m_XStart=e.start.x,this.m_YStart=e.start.y,this.m_XEnd=e.end.x,this.m_YEnd=e.end.y):void 0!==e.move?(this.m_description=e.move.m_description,this.m_attributes=e.move.m_attributes,e.move.m_attributes=null,this.m_XStart=e.move.m_XStart,this.m_YStart=e.move.m_YStart,this.m_XEnd=e.move.m_XEnd,this.m_YEnd=e.move.m_YEnd):void 0!==e.copy?(this.m_description=e.copy.m_description,e.copy.m_attributes&&(this.m_attributes=e.copy.m_attributes.slice()),this.m_XStart=e.copy.m_XStart,this.m_YStart=e.copy.m_YStart,this.m_XEnd=e.copy.m_XEnd,this.m_YEnd=e.copy.m_YEnd):(t(0),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN)}transformAttribute(e,s,i,n,r){t(0)}mergeVertexDescriptionImpl(t){const e=this.getDescription(),s=vs.getMergedVertexDescription(e,t);this.assignVertexDescription(s)}changeEndPoints(t,e){const s=t.getXY(),i=e.getXY();this.changeEndPoints2D(s,i);let n=t.getDescription();n!==this.getDescription()&&this.mergeVertexDescription(n),n=e.getDescription(),n!==this.getDescription()&&this.mergeVertexDescription(n);for(let r=1,o=n.getAttributeCount();r<o;r++){const s=n.getSemantics(r),i=Zn.getComponentCount(s);for(let n=0;n<i;n++){Oi(this,0,s,n,t.getAttributeAsDbl(s,n));Oi(this,1,s,n,e.getAttributeAsDbl(s,n))}}}getStartXY(){return new os(this.m_XStart,this.m_YStart)}setStartXY(t){this.m_XStart=t.x,this.m_YStart=t.y,this.endPointModified()}setStartXYCoords(t,e){this.m_XStart=t,this.m_YStart=e,this.endPointModified()}getStartXYZ(){return t(0),new ps(0,0,0)}setStartXYZ(e){t(0)}setStartXYZCoords(t,e,s){Gi(this,0,ps.construct(t,e,s))}queryStart(t){Wi(this,0,t)}setStart(t){Zi(this,0,t)}setStart2D(e){t(0)}getStartAttributeAsDbl(t,e){return Hi(this,0,t,e)}getStartAttributeAsInt(e,s){return t(0),0}setStartAttribute(t,e,s){Oi(this,0,t,e,s)}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndXY(){return new os(this.m_XEnd,this.m_YEnd)}setEndXY(t){this.m_XEnd=t.x,this.m_YEnd=t.y,this.endPointModified()}setEndXYCoords(t,e){this.m_XEnd=t,this.m_YEnd=e,this.endPointModified()}getEndXYZ(){return t(0),new ps(0,0,0)}setEndXYZ(e){t(0)}setEndXYZCoords(t,e,s){Gi(this,1,ps.construct(t,e,s))}queryEnd(t){Wi(this,1,t)}setEnd(t){Zi(this,1,t)}setEnd2D(e){t(0)}getEndAttributeAsDbl(t,e){return Hi(this,1,t,e)}getEndAttributeAsInt(e,s){return t(0),Math.trunc(0)}setEndAttribute(t,e,s){Oi(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&f("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&ze(e.m_attributes,this.m_attributes,0,0,2*(this.m_description.getTotalComponentCount()-2)),e.m_XStart=this.m_XStart,e.m_YStart=this.m_YStart,e.m_XEnd=this.m_XEnd,e.m_YEnd=this.m_YEnd,this.copyToImpl(e)}isEmpty(){return this.isEmptyImpl()}isClosed(){return this.m_XStart===this.m_XEnd&&this.m_YStart===this.m_YEnd}setEmpty(){}calculateArea2D(){return 0}queryInterval(t,e){const s=kt.constructEmpty();return s.vmin=Hi(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(Hi(this,1,t,e)),s}calculateLength3D(e){return t(0),0}getCoord2D(t){const e=os.getNAN();return this.queryCoord2D(t,e),e}queryCoord(t,e){e.assignVertexDescription(this.m_description),e.setXY(this.getCoord2D(t));for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=Zn.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);e.setAttributeBasic(i,s,n)}}}isCloserThanDistance(t,e,s){const i=as.constructEmpty();this.queryLooseEnvelopeOnInterval(e,i);if(i.distance(t)>s)return!1;const n=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(n)&&os.distance(t,this.getCoord2D(n))<=s}isMonotoneQuickAndDirty(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=Ve(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Ve(this.m_YStart,this.m_YStart=this.m_YEnd),this.reverseImpl();for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t);for(let t=0,s=Zn.getComponentCount(e);t<s;t++){const s=Hi(this,0,e,t);Oi(this,0,e,t,Hi(this,1,e,t)),Oi(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(e,s,i){return t(0),0}calculateSubLengthFromStart(t){return this.tToLength(t)}calculateSubLength(t,e){return e===t?0:this.tToLength(e)-this.tToLength(t)}static recalculateParentT(t,e,s){return he(t,e,s)}moveTo(e){t(0)}moveTo3D(e){t(0)}getDescription(){return this.m_description}assignVertexDescription(t){Ui(this,t)}mergeVertexDescription(t){this.m_description!==t&&(this.m_description.hasAttributesFrom(t)||this.mergeVertexDescriptionImpl(t))}hasAttribute(t){return this.m_description.hasAttribute(t)}addAttribute(t){if(this.m_description.hasAttribute(t))return;const e=vs.getMergedVertexDescriptionSemantics(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=vs.removeSemanticsFromVertexDescription(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=vs.getDefaultDescription2D();t!==this.m_description&&this.assignVertexDescription(t)}swap(e){t(0)}equals(t,e){if(this.getGeometryType()!==t.getGeometryType())return!1;const s=void 0===e;s&&(e=0);const i=t;if(this===i)return!0;if(this.m_description!==i.m_description)return!1;if(Math.abs(this.m_XStart-i.m_XStart)>e||Math.abs(this.m_XEnd-i.m_XEnd)>e||Math.abs(this.m_YStart-i.m_YStart)>e||Math.abs(this.m_YEnd-i.m_YEnd)>e)return!1;for(let n=0,r=2*(this.m_description.getTotalComponentCount()-2);n<r;n++)if(!O(this.m_attributes[n],i.m_attributes[n],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(e,s,i){t(0)}replaceNaNs(e,s){t(0)}}function On(t,e,s){jn(e,t.getStartXY(),t.getEndXY(),s)}function jn(t,e,s,i){le(e,s,t,i)}function Un(t,e){return he(t.m_XStart,t.m_XEnd,e)}function Qn(t,e){return he(t.m_YStart,t.m_YEnd,e)}function Kn(t,e,s){const i=Ai.constructPoint2D(t.getStartXY()),n=Ai.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}function $n(t,e,s){e.value()<=.5?oe(2,Ai.constructPoint2D(t.getStartXY()),Ai.constructPoint2D(t.getEndXY()),e,s):ae(2,Ai.constructPoint2D(t.getStartXY()),Ai.constructPoint2D(t.getEndXY()),e,s)}function Jn(t,e,s){t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.afterCompletedModification()}function tr(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=Ve(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=Ve(t.m_YStart,t.m_YStart=t.m_YEnd);for(let e=0,s=t.m_description.getTotalComponentCount()-2;e<s;e++)t.m_attributes[e+s]=Ve(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function er(t,e,s,i){let n=0;if((t.m_XStart===e.m_XStart&&t.m_YStart===e.m_YStart||t.m_XStart===e.m_XEnd&&t.m_YStart===e.m_YEnd)&&(n++,!i))return 1;if(t.m_XEnd===e.m_XStart&&t.m_YEnd===e.m_YStart||t.m_XEnd===e.m_XEnd&&t.m_YEnd===e.m_YEnd){if(n++,2===n)return 2;if(!i)return 1}return e.isIntersectingPoint(t.getStartXY(),s,!0)||e.isIntersectingPoint(t.getEndXY(),s,!0)||t.isIntersectingPoint(e.getStartXY(),s,!0)||t.isIntersectingPoint(e.getEndXY(),s,!0)?4:i&&n?0:rr(t,e)?4:0}function sr(t,e,s,i,n,r,o,a){null!==i&&(i.length=2),null!==n&&(n.length=2),null!==s&&(s.length=2);const h=ir(t,e,2,s,i,n,r,o,a);return i&&(i.length=h),n&&(n.length=h),s&&(s.length=h),h}function ir(t,e,s,i,n,r,o,a,h){const m=or(t,e.getStartXY(),o,!1),u=or(t,e.getEndXY(),o,!1),l=or(e,t.getStartXY(),o,!1),c=or(e,t.getEndXY(),o,!1);let d=0,_=0;if(!Number.isNaN(m)){let s=!1;a&&vt(m,0,1)&&t.getCoord2D(m).isEqualPoint2D(e.getStartXY())&&(d++,s=!0),s||(n&&(n[_]=m),r&&(r[_]=0),i&&(i[_]=os.construct(e.m_XStart,e.m_YStart)),_++)}if(!Number.isNaN(u)){let o=!1;a&&vt(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(d++,o=!0),o||(s>_&&(n&&(n[_]=u),r&&(r[_]=1),i&&(i[_]=os.construct(e.m_XEnd,e.m_YEnd))),_++)}if(2!==_&&!Number.isNaN(l)&&!(0===m&&0===l||0===u&&1===l)){let o=!1;a&&vt(l,0,1)&&e.getCoord2D(l).isEqualPoint2D(t.getStartXY())&&(d++,o=!0),o||(s>_&&(n&&(n[_]=0),r&&(r[_]=l),i&&(i[_]=os.construct(t.m_XStart,t.m_YStart))),_++)}if(2!==_&&!Number.isNaN(c)&&!(1===m&&0===c||1===u&&1===c)){let o=!1;a&&vt(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getEndXY())&&(d++,o=!0),o||(s>_&&(n&&(n[_]=1),r&&(r[_]=c),i&&(i[_]=os.construct(e.m_XEnd,e.m_YEnd))),_++)}if(_>0)return h&&(r=Ve(n,n=r)),2===_&&s>=2&&n&&n[0]>n[1]&&(n[1]=Ve(n[0],n[0]=n[1]),r&&(r[1]=Ve(r[0],r[0]=r[1])),i&&(i[1]=Ve(i[0],i[0]=i[1]))),_;if(d>0)return 0;const g=lr(t,e,o);return Number.isNaN(g.x)?0:(i&&(i[0]=t.getCoord2D(g.x)),n&&(n[0]=g.x),r&&(r[0]=g.y),1)}function nr(t,e,s){const i=lr(t,e,0);return Number.isNaN(i.x)?0:(s[0]=t.getCoord2D(i.x),1)}function rr(t,e){const s=ar(t,e.m_XStart,e.m_YStart),i=ar(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=ar(e,t.m_XStart,t.m_YStart),r=ar(e,t.m_XEnd,t.m_YEnd);if(n<0&&r<0||n>0&&r>0)return!1;return ur(t)>ur(e)?mr(t,e):mr(e,t)}function or(t,e,s,i){const n=os.getNAN(),r=os.getNAN();let o=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(n.setCoords(t.m_XEnd,t.m_YEnd),r.setCoords(t.m_XStart,t.m_YStart),o=!0):(n.setCoords(t.m_XStart,t.m_YStart),r.setCoords(t.m_XEnd,t.m_YEnd));const a=o?1:0,h=o?0:1,m=os.getNAN();m.setSub(e,n);let u=m.length(),l=3*u*yt();if(u<=Math.max(s,l))return i&&0===u?Number.NaN:a;if(m.setSub(e,r),u=m.length(),l=3*u*yt(),u<=Math.max(s,l))return i&&0===u?Number.NaN:h;m.setCoords(r.x-n.x,r.y-n.y);const c=m.length();if(c>0){const t=1/c;m.scale(t);const i=os.getNAN();i.setSub(e,n);const u=i.dotProduct(m),l=8*i.dotProductAbs(m)*yt();m.leftPerpendicularThis();const d=i.dotProduct(m),_=8*i.dotProductAbs(m)*yt(),g=Math.max(s,l);if(u<-g||u>c+g)return Number.NaN;const p=Math.max(s,_);if(Math.abs(d)<=p){let i=u*t;i=Pt(i,0,1);const m=os.getNAN();if(jn(i,n,r,m),os.distance(m,e)<=s){if(i<.5){if(os.distance(m,n)<=s&&os.distance(e,n)<=s)return a}else if(os.distance(m,r)<=s&&os.distance(e,r)<=s)return h;return o?1-i:i}}}return Number.NaN}function ar(t,e,s){const i=os.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const n=os.getNAN();n.setSub(t.getEndXY(),t.getStartXY());const r=n.crossProduct(i),o=4*yt()*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?-1:r<-o?1:0}function hr(t,e,s,i){const n=i?t.m_XStart:t.m_XEnd,r=i?t.m_YStart:t.m_YEnd,o=os.getNAN();o.x=e.getEndX()-n,o.y=e.getEndY()-r;if(s.dotProduct(o)>3*yt()*s.dotProductAbs(o)){o.x=e.getStartX()-n,o.y=e.getStartY()-r;return s.dotProduct(o)<=3*yt()*s.dotProductAbs(o)}return!0}function mr(t,e){const s=os.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!hr(t,e,s,!1)&&(s.negateThis(),!!hr(t,e,s,!0))}function ur(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}function lr(t,e,s){const i=t.m_XEnd-t.m_XStart,n=t.m_YEnd-t.m_YStart,r=e.m_XEnd-e.m_XStart,o=e.m_YEnd-e.m_YStart,a=r*n-i*o;if(0===a)return os.getNAN();const h=4*yt()*(Math.abs(r*n)+Math.abs(i*o)),m=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,l=r*u-m*o,c=4*yt()*(Math.abs(r*u)+Math.abs(m*o)),d=l/a,_=Math.abs(a),g=(c*_+h*Math.abs(l))/(a*a)+yt()*Math.abs(d);if(d<-g||d>1+g)return os.getNAN();const p=i*u-m*n,f=p/a,x=(4*yt()*(Math.abs(i*u)+Math.abs(m*n))*_+h*Math.abs(p))/(a*a)+yt()*Math.abs(f);if(f<-x||f>1+x)return os.getNAN();let y=Pt(d,0,1),v=Pt(f,0,1);const P=os.getNAN();On(t,y,P);const b=os.getNAN();if(On(e,v,b),!s||os.distance(P,b)>s){const i=os.getNAN();le(P,b,.5,i),y=t.getClosestCoordinate(i,!1),v=e.getClosestCoordinate(i,!1);const n=os.getNAN();On(t,y,n);const r=os.getNAN();On(e,v,r),n.subThis(r);const o=n.length(),a=(t.absNorm()+e.absNorm())*pt();if(o>Math.max(s,a))return os.getNAN()}return new os(y,v)}Hn.s_maxMonotonicPartParams=8;class cr extends un{constructor(e){e?e.vd?(super({vd:e.vd,bPolygon:!1}),this.m_segmentBufferCTor=xl):e.copy?(super({vd:e.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=xl,e.copy.copyTo(this)):e.move?(super({move:e.move}),this.m_segmentBufferCTor=xl):e.start?(super({vd:e.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=xl,this.startPathPoint(e.start),this.lineToPoint(e.end)):e.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=xl,this.addPathPoint2D(e.path,e.pointCount,e.bForward)):t(0):(super({bPolygon:!1}),this.m_segmentBufferCTor=xl)}getBoundary(){return gr(this)}buildRasterizedGeometryAccelerator(e,s){return t(0),!1}buildQuadTreeAccelerator(e){return t(0),!1}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(e){return t(0),this}getGeometryType(){return cr.type}getDimension(){return 1}createInstance(){return new cr({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}cr.type=r.enumPolyline;var dr=r;function _r(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===dr.enumPolygon)return 0!==t.calculateArea2D();if(s===dr.enumPolyline)return pr(t.getImpl(),e,!0).bNotEmpty;if(s===dr.enumEnvelope)return!0;if(u(s))return!!t.isClosed();if(h(s))return!1;if(s===dr.enumGeometryCollection){const s=t;for(let t=0,i=s.getGeometryCount();t<i;t++)if(_r(s.getGeometry(t),e))return!0;return!1}P("")}function gr(t,e){const s=t.getGeometryType();if(s===dr.enumPolygon){const e=new cr({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===dr.enumPolyline)return pr(t.getImpl(),e,!1).boundary;if(s===dr.enumEnvelope){const e=new cr({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(u(s)){const e=new dn({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new Ci;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===dr.enumGeometryCollection){const s=t;let i=null;for(let n=0,r=s.getGeometryCount();n<r;n++){const r=gr(s.getGeometry(n),e);if(null!==r){null===i&&(i=t.createInstance());const e=r;i.addGeometry(e)}}return i}if(h(s))return new Ci({vd:t.getDescription()});P("")}function pr(t,e,s){const i=!1,n=t;let r=null;if(s||(r=new dn({vd:n.getDescription()})),!n.isEmpty()){const t=new Fs(0);for(let e=0,s=n.getPathCount();e<s;e++){if(n.getPathSize(e)>0&&!n.isClosedPathInXYPlane(e)){const s=n.getPathStart(e);t.add(s);const i=n.getPathEnd(e)-1;t.add(i)}}if(t.size()>0){const e=new Hs,i=n.getAttributeStreamRef(0),o={userSort(t,e,s){const n=os.getNAN(),r=os.getNAN();s.sort(t,e,((t,e)=>(i.queryPoint2D(2*t,n),i.queryPoint2D(2*e,r),n.compare(r))))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),o);let a=i.readPoint2D(2*t.read(0)),h=0,m=1;const u=new Ci;for(let n=1,r=t.size();n<r;n++){const e=i.readPoint2D(2*t.read(n));if(e.isEqualPoint2D(a))t.read(h)>t.read(n)?(t.write(h,Q()),h=n):t.write(n,Q()),m++;else{if(1&m){if(s)return{bNotEmpty:!0,boundary:new dn({})}}else t.write(h,Q());a=e,h=n,m=1}}if(1&m){if(s)return{bNotEmpty:!0,boundary:new dn({})}}else t.write(h,Q());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==Q();e++)n.getPointByVal(t.read(e),u),r.add(u)}}}return s?{bNotEmpty:i,boundary:new dn({})}:{bNotEmpty:i,boundary:r}}const fr=R/180,xr=180/R;function yr(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=Te(e,360),e<0&&(e+=360),e)}function vr(t){let e=t;return e=yr(e),e>180&&(e-=360),e}function Pr(t){return t*fr}function br(t){return t*xr}function Er(t){const e=Ct();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=Te(s,e),s<0&&(s+=e),s)}function Cr(t){const e=Et();let s=t;return s>-e&&s<=e||(s=Er(s),s>e&&(s-=Ct())),s}function Dr(e,s,i,n){const r=4*yt()*(Math.abs(s.vmin)+Math.abs(s.vmax)),o=yt();if(1===e.getMaxDerivative()){t(i>0);const o=Nr(e,0,s,yt(),r);return n[0]=o.root,o.cRoots}let a,h=[];const m=new kt(s.vmin-r,s.vmax+r);h.push(new os(m.vmin,m.vmax));let u=0;for(let t=e.getMaxDerivative()-1;t>=0;t--){a=h,h=[];for(let m=0,l=a.length;m<l;m++){if(a[m][0]<a[m][1]){let l,c,d;if(t===e.getMaxDerivative()-1?({root:l,funcAtRoot:c,cRoots:d}=Nr(e,t,kt.construct(a[m][0],a[m][1]),o,.5*r)):({root:l,funcAtRoot:c,cRoots:d}=Mr(e,t,kt.construct(a[m][0],a[m][1]),o,.5*r)),1===d){if(0===t){if(u<i){if(a[m][0]<=s.vmin&&a[m][1]>=s.vmin&&l!==s.vmin){0===e.getValue(0,s.vmin)&&(l=s.vmin)}if(a[m][0]<=s.vmax&&a[m][1]>=s.vmax&&l!==s.vmax){0===e.getValue(0,s.vmax)&&(l=s.vmax)}n[u]=s.snapClip(l),u>0?n[u]-n[u-1]>r&&u++:u++}}else{const t=os.getNAN();t[0]=a[m][0],t[1]=l,h.push(t);const e=os.getNAN();e[0]=l,e[1]=a[m][1],h.push(e)}continue}}h.push(a[m])}}return u}function Sr(t,e,s,i,n,r){const o=Ue(Wt,2),a=Yr(new Wt(t),new Wt(e),new Wt(s),i,n,o);return r[0]=o[0].value(),r[1]=o[1].value(),a}function wr(t,e,s,i,n,r,o){const a=Ue(Wt,3),h=Xr(new Wt(t),new Wt(e),new Wt(s),new Wt(i),n,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),o[2]=a[2].value(),h}function Ar(t,e,s,i,n,r,o,a){return Ir(t,e,s,i,n,r,o,a)}function Tr(t,e,s,i,n,r){return Rr(t,e,s,i,n,r)}function Ir(t,e,s,i,n,r,o,a){const h=new Array(s*s);h.fill(0),ze(a,i,0,0,s);const m=new Array(s),u=new Array(s),l=new Array(s);let c=t(a,s,e);const d=100;let _=0;for(_=0;_<d;_++){const i=c;for(let t=0;t<s;++t)u[t]=a[t];if(_%s==0){h.fill(0);for(let t=0;t<s;t++)h[t*s+t]=1}let o=0,d=0;for(let u=0;u<s;++u){for(let t=0;t<s;++t)m[t]=h[u*s+t];const i=c;c=qr(t,e,a,m,n,r,s);const l=i-c;l>o&&(d=u,o=l)}for(let t=0;t<s;t++)m[t]=a[t]-u[t],l[t]=a[t]+(a[t]-u[t]);const g=t(l,s,e);if(g<i){if(2*(i-2*c+g)*ce(i-c-o)<ce(i-g)*o){c=qr(t,e,a,m,n,r,s);for(let t=0;t<s;++t)h[d*s+t]=h[(s-1)*s+t],h[(s-1)*s+t]=m[t]}}if(i<=c)return t(a,s,e)}return c}function Nr(e,s,i,n,r){const o={root:0,funcAtRoot:0,cRoots:0};let a=i.vmin,h=i.vmax,m=0,u=Number.MAX_VALUE,l=e.getValue(s,a),c=e.getValue(s,h),d=0,_=0,g=0;if(l>=0&&c>=0||l<=0&&c<=0)return Math.abs(l)<Math.abs(c)?(o.funcAtRoot=l,o.root=a,o.cRoots=0===l?1:0,o):(o.funcAtRoot=c,o.root=h,o.cRoots=0===c?1:0,o);Math.abs(l)<Math.abs(c)&&(h=Ve(a,a=h),c=Ve(l,l=c)),m=a,d=l;let p=!0,f=0;for(;0!==c&&Math.abs(a-h)>n*Math.abs(h)+r;f++){_=l!==d&&c!==d?a*c*d/((l-c)*(l-d))+h*l*d/((c-l)*(c-d))+m*l*c/((d-l)*(d-c)):h-c*(h-a)/(c-l);const i=(3*a+h)/4;let x=!(_>i&&_<h||_>h&&_<i);if(!x){const t=n*Math.abs(h)+r;if(p){const e=Math.abs(h-m);x=Math.abs(_-h)>=.5*e||e<t}else{const e=Math.abs(m-u);x=Math.abs(_-h)>=.5*e||e<t}}if(x?(_=(a+h)/2,p=!0):p=!1,g=e.getValue(s,_),0===g)return o.root=_,o.funcAtRoot=g,o.cRoots=1,o;const y=a-_,v=_-h;if(Math.abs(y)>10*Math.abs(v)){const t=h+3*v,i=e.getValue(s,t);ge(l)*ge(i)>0&&(a=t,l=i)}else if(Math.abs(v)>10*Math.abs(y)){const t=a-3*y,i=e.getValue(s,t);ge(c)*ge(i)>0&&(h=t,c=i)}u=m,m=h,d=c,ge(l)*ge(g)<0?(h=_,c=g):(a=_,l=g),Math.abs(l)<Math.abs(c)&&(h=Ve(a,a=h),c=Ve(l,l=c)),f>64&&(t(0),E(""))}return f>64&&E("Root_finder iterations exceeded"),o.root=h,o.funcAtRoot=c,o.cRoots=1,o}function Mr(t,e,s,i,n){const r={root:0,funcAtRoot:0,cRoots:0};let o=s.vmin,a=t.getValue(e,o),h=s.vmax,m=t.getValue(e,h);if(a>=0&&m>=0||a<=0&&m<=0)return Math.abs(a)<Math.abs(m)?(r.funcAtRoot=a,r.root=o,r.cRoots=0===a?1:0,r):(r.funcAtRoot=m,r.root=h,r.cRoots=0===m?1:0,r);m<0&&(m=Ve(a,a=m),h=Ve(o,o=h));let u=.5*(o+h),l=Math.abs(h-o),c=l,d=t.getValue(e,u),_=t.getValue(e+1,u);const g=1,p=4;let f=p;const x=2;let y=1,v=0,P=0,b=g;const C=32;let D=0;for(;++D<100;){let s;D>C||0===_||b===x&&v>1||b===g&&f<p?(b=g,y>1&&y--):(b=x,P>1&&Math.abs(2*d)>Math.abs(l*_)&&y++),l=c;let i=!1;if(b===g)do{if(P>2){const t=16*Math.abs(l);if(.5*Math.abs(o-h)>t){const e=Math.min(o,h),i=Math.max(o,h);if(u===e){s=u,u=e+t,c=u-s;break}if(u===i){s=u,u=i-t,c=u-s;break}}}c=.5*(h-o),s=u,u=o+c,i=o===u||h===u}while(0);else for(;;){c=y*d/_,s=u,u-=c,i=u===s;const t=Math.min(o,h),e=Math.max(o,h);if(u<t){if(y>1){u=s,y--;continue}c=s-t,u=t}else if(u>e){if(y>1){u=s,y--;continue}c=s-e,u=e}break}if(i||Math.abs(c)<n){s!==u&&(d=t.getValue(e,u));break}d=t.getValue(e,u),_=t.getValue(e+1,u);const r=o,E=h;d<0?(a=d,o=u):(m=d,h=u),b===x&&(o===r&&h===E||P>1&&Math.abs(c)>=.5001*Math.abs(l))?v++:v=0,b===g?(f++,P=0):(f=0,P++)}return 100===D&&E("Root_finder iterations exceeded"),r.root=u,r.funcAtRoot=d,r.cRoots=1,r}function qr(t,e,s,i,n,r,o){const a=i.slice(0,o);let h=0;for(let f=0;f<o;f++)h+=i[f]*i[f];if(h=Math.sqrt(h),h>0)for(let f=0;f<o;f++)a[f]/=h;let m=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=new Array(o);for(let e=0;e<o;e++)t[e]=e;t.sort(((t,e)=>{const s=Math.abs(a[t]),i=Math.abs(a[e]);return s<i?-1:s>i?1:0}));for(let e=0;e<o;e++){const i=t[e];if(0===a[i])continue;let o=(n[i]-s[i])/a[i],h=(r[i]-s[i])/a[i];h<o&&(h=Ve(o,o=h)),o>m&&(m=o),h<u&&(u=h)}}let l=0;const c=(Math.abs(m)+Math.abs(u))*yt()*100,d=new Array(o),_=a.slice();function g(i,n){for(let t=0,e=o;t<e;t++)d[t]=s[t]+i*_[t];return t(d,o,e)}c>0&&(l=Tr(g,null,m,0,u,c));const p=g(l);for(let f=0,x=o;f<x;f++)s[f]=Pt(d[f],n[f],r[f]);return p}function Rr(t,e,s,i,n,r){const o=ft();let a=i,h=t(a,e),m=s,u=n,l=t(m,e),c=t(u,e);h>l&&(h=l,a=m),h>c&&(h=c,a=u);let d=m,_=u,g=l,p=c;g>p&&(g=Ve(p,p=g),_=Ve(d,d=_));let f=a-d,x=d-_;const y=.5*Math.min(r,u-m),v=2*y,P=100;let b,E=0;for(b=0;b<P&&!(u-m<=v);++b){const s=m+.5*(u-m);let i=E>0;if(!i&&Math.abs(x)<=y&&(i=!0,E=3),!i){const t=a-d,e=a-_,s=t*(h-p);let n=e*(h-g),r=e*n-t*s;n=2*(n-s),n>0&&(r=-r),n=Math.abs(n),0===n||Math.abs(r)>=Math.abs(n*x/2)||r<=n*(m-a)||r>=n*(u-a)?(i=!0,E=3):(x=f,f=r/n)}i&&(x=a>=s?m-a:u-a,f=o*x,E--);let n=a+f;n<m+y?n=m+y:n>u-y&&(n=u-y);const r=t(n,e);r<h?(n>=a?(m=a,l=h):(u=a,c=h),_=d,d=a,a=n,p=g,g=h,h=r):(n<a?(m=n,l=r):(u=n,c=r),r<=g||d===a?(_=d,d=n,p=g,g=r):(r<=p||_===a||_===d)&&(_=n,p=r))}return a}function Fr(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setE(e.clone().negateThis().divThisE(t)),s.containsCoordinate(i.value())?1:0)}function Yr(t,e,s,i,n,r){if(0===t.value()){if(n)return r[0].set(1),i.containsCoordinate(r[0].value())?1:0;return Fr(e,s,i,r[0])}if(n){let e=2;return r[0].set(1),r[1].setE(s).divThisE(t),r[1].eq(r[0])&&(r[1].set(1),e=1),i.containsCoordinate(r[1].value())||(e=1),i.containsCoordinate(r[0].value())||(e--,r[0].setE(r[1])),2===e&&r[0].value()>r[1].value()&&(r[1]=Ve(r[0],r[0]=r[1])),e}const o=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(Kt));if(o.lt(Ut))return 0;const a=new Wt(e.value()>=0?1:-1),h=o.clone().sqrtThis(),m=new Wt(-.5).mulThisE(e.clone().addThisE(a.clone().mulThisE(h)));let u=0;r[0].setE(m).divThisE(t);const l=new Wt(r[0].value()),c=t.clone().resetError(),d=e.clone().resetError(),_=s.clone().resetError();let g=c.clone().mulThisE(l).addThisE(d).mulThisE(l).addThisE(_);if(!g.isZero()){const i=new Wt;Wr(r[0],t,e,s,i),r[0].setE(i)}if(i.containsCoordinate(r[0].value())&&u++,0!==h.value()&&0!==m.value()){if(r[u].setE(s).divThisE(m),l.set(r[u].value()),g=c.clone().mulThisE(l).addThisE(d).mulThisE(l).addThisE(_),!g.isZero()){const i=new Wt;Wr(r[u],t,e,s,i),r[u].setE(i)}return i.containsCoordinate(r[u].value())&&u++,2===u&&r[0].value()>r[1].value()&&(r[1]=Ve(r[0],r[0]=r[1])),u}return u}function Xr(t,e,s,i,n,r,o){if(0===t.value()){return Yr(e,s,i,n,r,o)}if(r){let s=1;o[0].set(1);const r=o.slice(s),a=Yr(t,e.addE(t),i.negate(),n,!1,r);if(a>0){s+=a;for(let t=1;t<s;t++)o[t].eq(Qt)&&(o[s-1]=Ve(o[t],o[t]=o[s-1]),s--)}const h=o.slice(0,s);h.sort(((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));for(let t=0;t<s;++t)o[t]=h[t];return s}return Zr(t,e,s,i,n,o)}function Lr(t,e,s,i,n,r){return(r<e||e<0)&&f("nth_degree_real_roots"),Hr(t,e,s,i,n)}function zr(t,e,s,i){return{coef0:t.clone(),coef1:e.clone(),coef2:s.clone(),coef3:i.clone(),calcF(t){return this.coef0.clone().mulThis(t).addThisE(this.coef1).mulThis(t).addThisE(this.coef2).mulThis(t).addThisE(this.coef3)},calcDF(t){return this.coef0.clone().mulThis(3).mulThis(t).addThisE(this.coef1.clone().mulThisByPower2(2)).mulThis(t).addThisE(this.coef2)},estimateError(t){const e=Math.abs(t),s=((this.coef0.eps()*e+this.coef1.eps())*e+this.coef2.eps())*e+this.coef3.eps()+this.calcF(t).eps(),i=this.coef0.clone().mulThis(t).mulThis(3).addThisE(this.coef1.clone().mulThis(2)).mulThis(t).addThisE(this.coef2);if(i.isZero()){const e=this.coef0.clone().mulThis(t).mulThis(6).addThisE(this.coef1.clone().mulThis(2));if(e.isZero()){const t=this.coef0.clone().mulThis(6);return Math.pow(6*s/Math.abs(t.value()),1/3)}return Math.sqrt(2*s/Math.abs(e.value()))}return s/Math.abs(i.value())}}}class Vr{updateCoefs(t){if(this.lastDeriv1===t)return this.curCoefs=this.derivCoefs1,void(this.lastUsed=1);if(this.lastDeriv2===t)return this.curCoefs=this.derivCoefs2,void(this.lastUsed=2);let e;1===this.lastUsed?(e=this.derivCoefs2,this.lastDeriv2=t,this.lastUsed=2):(e=this.derivCoefs1,this.lastDeriv1=t,this.lastUsed=1),e.length=this.truePower-t+1;for(let s=0,i=this.truePower-t;s<=i;++s){e[s]=this.coefs[s+t].clone();let i=s+t,n=i--;for(let e=1;e<t;e++)n*=i--;e[s].mulThis(n)}this.curCoefs=e}constructor(t,e,s,i){this.derivCoefs1=[],this.derivCoefs2=[],this.lastDeriv1=-1,this.lastDeriv2=-1,this.lastUsed=-1,this.curCoefs=null,this.coefs=t,this.power=e,this.truePower=0;for(let n=e;n>=1;n--)if(0!==this.coefs[n].value()){this.truePower=n;break}}getMaxDerivative(){return this.truePower+1}getValue(t,e){let s=this.coefs;0===t?s=this.coefs:(this.updateCoefs(t),s=this.curCoefs);const i=new At(0);let n=1;for(let r=0,o=this.truePower-t;r<=o;++r)i.pe(n*s[r].value()),n*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new At(0),i=new Wt(1),n=new Wt(0);for(let o=0,a=this.power;o<=a;++o)n.addThisE(this.coefs[o].mulE(i)),s.pe(i.value()*this.coefs[o].eps()),i.mulThis(e);s.pe(n.eps());let r=1;for(let o=1;o<=this.truePower;++o){r*=o,this.updateCoefs(o);const e=new Wt(1),i=new Wt(0);for(let s=0,n=this.truePower-o;s<=n;++s)i.addThisE(this.curCoefs[s].mulE(e)),e.mulThis(t);if(!i.isZero())return Math.pow(r*s.getResult()/Math.abs(i.value()),1/o)}return 0}}function Br(t,e,s,i,n,r){let o=t,a=e,h=a-o;if(!r){let s=i.calcF(t).value(),n=i.calcF(e).value();if((s>0||s>n)&&(a=Ve(o,o=a),n=Ve(s,s=n)),s>=0||n<=0)return!1}let m,u=!1,l=s,c=0;for(;c<100;c++){const t=i.calcF(l);if(m=i.calcDF(l),m.isZero())return!1;if(!t.value()||c>3&&t.isZero()){u=!0;break}r||(t.value()<0?o=l:a=l);const e=t.value()/m.value(),s=l-e;r||(s>=o&&s<=a||s>=a&&s<=o)&&Math.abs(e)<=.5*h?(l=s,h=Math.abs(e)):(h=Math.abs(.5*(a-o)),l=.5*(o+a))}return!!u&&(n.set(l,i.estimateError(l)),!0)}function kr(t,e,s,i,n,r,o,a){return Br(t,e,s.value(),zr(i,n,r,o),a,!1)}class Gr{constructor(t,e,s){this.coefs=Ue(Wt,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new Wt(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new Wt(t);return Wt.st_mulByPower2(this.coefs[0],2).mulE(e).addE(this.coefs[1])}estimateError(t){const e=Math.abs(t),s=(this.coefs[0].eps()*e+this.coefs[1].eps())*e+this.coefs[2].eps()+this.calcF(t).eps(),i=new Wt(2).mulE(this.coefs[0]).mul(t).addE(this.coefs[1]);if(i.isZero()){const t=this.coefs[0].value();return Math.sqrt(s/Math.abs(t))}return s/Math.abs(i.value())}}function Wr(t,e,s,i,n){return Br(0,0,t.value(),new Gr(e,s,i),n,!0)}function Zr(t,e,s,i,n,r){const o=Ue(Wt,3);let a=0;const h=e.negate().divThisE(t.clone().mulThis(3));n.containsCoordinate(h.value())&&(o[0].setE(h),a=1);const m=Ue(Wt,2),u=Yr(t.mul(3),e.mul(2),s,n,!1,m);if(u<0)return i.isZero()?-1:0;for(let g=0;g<u;g++)n.containsCoordinate(m[g].value())&&o[a++].setE(m[g]);Ge(o,a,((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));const l=Ue(Wt,5);l[0].set(n.vmin);for(let g=0;g<a;g++)l[1+g].setE(o[g]);l[1+a].set(n.vmax);const c=a+2;let d=1,_=0;{const n=l[0].clone();if(t.clone().mulThisE(n).addThisE(e).mulThisE(n).addThisE(s).mulThisE(n).addThisE(i).isZero()){const o=zr(t,e,s,i);n.setError(o.estimateError(n.value())),r[_]=n,_++,d++}}for(let g=d;g<c;g++){const o=l[g].clone(),a=t.clone().mulThisE(o).addThisE(e).mulThisE(o).addThisE(s).mulThisE(o).addThisE(i).isZero();if(a||!l[g].eq(l[g-1])){if(a||kr(l[g-1].value(),l[g].value(),l[g-1].clone().addThisE(l[g]).divThisByPower2(2),t,e,s,i,o)){if(_>0&&o.eq(r[_-1]))continue;if(_>=3&&E("cubic_polynomial_solver_too_many_roots"),a){const n=zr(t,e,s,i);o.setError(n.estimateError(o.value()))}r[_]=o,_++}if(l[g].value()===n.vmax)break;a&&g++}}return _}function Hr(t,e,s,i,n,r){const o=new Vr(t,e,s,yt());let a=0;if(2===o.truePower)a=Yr(t[2],t[1],t[0],s,i,n);else if(1===o.truePower)a=Fr(t[1],t[0],s,n[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=Dr(o,s,e,t);for(let e=0;e<a;e++)n[e].set(t[e])}}for(let h=0;h<a;h++)n[h].setError(o.getError(n[h].value()));return a}var Or=gs;class jr extends Hn{constructor(e){if(e&&void 0!==e.copy)return super({copy:e.copy}),this.m_cachedValues=null,this.m_interior=new os(0,0),this.m_center=new os(0,0),void e.copy.copyToImpl(this);e?t(0):(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_bits=0,this.m_startAngle=0,this.m_sweepAngle=0,this.m_sinr=0,this.m_cosr=1,this.m_rotation=0,this.m_minorMajorRatio=1,this.m_semiMajorAxis=0,this.m_interior=new os(0,0),this.m_center=new os(0,0),this.m_cachedValues=null)}getBoundary(){return gr(this)}assignMove(e){return t(0),this}assignCopy(t){return t.copyTo(this),this}constructCircleRadius(t,e,s=!1){return this.constructEllipse(t,1,e,0,s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircleCenterAndPoint(t,e,s=!1){const i=os.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructLineEllipticArc(t,e){return tm(this,t,e,1),this}constructLineCircularArc(e,s){return t(0),this}constructEllipse(t,e,s,i,n=!1){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const r=new os(0,this.m_minorMajorRatio*this.m_semiMajorAxis),o=Math.cos(i),a=Math.sin(i);return r.rotateDirect(o,a),r.addThis(s),this.constructEllipticArcEndPointsCenter(r,r,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,n,s),this}constructCircularArcThreePoint(t,e,s){const i=new Wt(t.x),n=new Wt(e.x),r=new Wt(s.x),o=new Wt(t.y),a=new Wt(e.y),h=new Wt(s.y),m=new Wt(.5),u=n.subE(i),l=a.subE(o),c=r.subE(i),d=h.subE(o),_=u.mulE(d).subThisE(l.mulE(c));if(_.scaleError(10),_.isZero()){if(!u.isZero()||!l.isZero())return tm(this,t,e,0),this;{const i=t.clone().addThis(e).mulThis(.5).addThis(s).mulThis(.5),n=s.sub(i).length();this.constructEllipticArcEndPointsCenter(t,e,n,1,0,!0,!1,i),this.m_interior.assign(s)}return this.setProjectionBehavior(0),this}const g=u.sqr().addThisE(l.sqr()).mulThisE(m),p=c.sqr().addThisE(d.sqr()).mulThisE(m),f=g.mulE(d).subThisE(p.mulE(l)),x=u.mulE(p).subThisE(c.mulE(g));f.divThisE(_),x.divThisE(_);const y=f.sqr().addThisE(x.sqr());y.sqrtThis();const v=f.addE(i),P=x.addE(o);let b=t.x-v.value(),E=t.y-P.value();const C=Math.atan2(E,b);b=e.x-v.value(),E=e.y-P.value();const D=Math.atan2(E,b);b=s.x-v.value(),E=s.y-P.value();const S=Math.atan2(E,b);let w=S-2*Et();for(;w<C;)w+=2*Et();let A=D-2*Et();for(;A<w;)A+=2*Et();let T=S+2*Et();for(;T>C;)T-=2*Et();let I,N=D+2*Et();for(;N>T;)N-=2*Et();I=A-C<C-N?A-C:N-C;const M=new os(v.value(),P.value());return this.constructEllipticArcEndPointsCenter(t,e,y.value(),1,0,Math.abs(I)>Et(),I>0,M),this.m_interior.assign(s),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructCircularArc(t,e,s,i){return this.constructEllipticArcGeneral(t,1,e,s,i,0),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructEllipticArcEndPoints(t,e,s,i,n,r,o){return Jh(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return Jh(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,n,r){this.m_semiMajorAxis=Math.abs(t),this.m_minorMajorRatio=Math.abs(e),this.m_minorMajorRatio>1&&(this.m_semiMajorAxis*=this.m_minorMajorRatio,this.m_minorMajorRatio=1/this.m_minorMajorRatio);const o=Cr(r),a=Math.cos(o),h=Math.sin(o),m=new os(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=os.getNAN(),l=Cr(i);u.x=m.x*Math.cos(l),u.y=m.y*Math.sin(l),u.rotateDirect(a,h),u.addThis(s);const c=bt(n,Ct());let d=c;Math.abs(d)===Ct()&&(d=0);const _=os.getNAN();return _.x=m.x*Math.cos(l+d),_.y=m.y*Math.sin(l+d),_.rotateDirect(a,h),_.addThis(s),this.constructEllipticArcEndPointsCenter(u,_,this.m_semiMajorAxis,this.m_minorMajorRatio,o,Math.abs(c)>Et(),c>0,s)}constructEllipticArcAsNURB(e,s,i,n){return t(0),this}constructCanonic(e){return t(0),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!Ri(this,[t])&&em(this)}isDegenerateToLine(){return em(this)}getCenter(){return this.m_center}setCenter(e){t(0)}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return os.construct(this.m_semiMajorAxis,this.m_semiMajorAxis*this.m_minorMajorRatio)}getSemiMajorAxis(){return this.m_semiMajorAxis}getSemiMinorAxis(){return this.m_semiMajorAxis*this.m_minorMajorRatio}getMinorMajorRatio(){return this.m_minorMajorRatio}isClockwise(){return!mm(this)}isMajor(){return lm(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return r.enumEllipticArc}queryEnvelope(e){if(e instanceof Cs){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=as.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=Or.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else if(e instanceof as){if(em(this))return e.setCoords(this.getStartXY()),void e.mergeNe(this.getEndXY());const t=this.getSemiAxes(),s=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),i=s+Et(),n=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),r=n+Et(),o=new Array(4);o[0]=kh(this,s),o[1]=kh(this,i),o[2]=kh(this,n),o[3]=kh(this,r),e.setCoords(this.getStartXY()),e.mergeNe(this.getEndXY());const a=os.getNAN();for(let h=0;h<4;h++){const t=o[h];t>0&&t<1&&(this.queryCoord2D(t,a),e.mergeNe(a))}}else t(0)}applyTransformation(t){rm(this,t,!1)}createInstance(){return new jr}calculateLength2D(){return Oh(this,0,1)}queryCoord2D(t,e){if(em(this))jn(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(os.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(os.construct(this.m_XEnd,this.m_YEnd));else{const s=Gh(this,t),i=new os(this.m_semiMajorAxis*Math.cos(s),this.getSemiMinorAxis()*Math.sin(s));i.rotateDirect(this.m_cosr,this.m_sinr),i.addThis(this.m_center),e.assign(i)}}queryCoord2DE(t,e){Fh(this,t,e)}getCoordX(t){const e=new os;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new os;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createEllipticArc();let r=0===t&&1===e;if(r&&!i)return void this.copyTo(n);const o=os.getNAN();this.queryCoord2D(t,o);const a=os.getNAN();if(this.queryCoord2D(e,a),!r)if(o.equals(a))e-t>.5&&this.isMajor()&&this.isClosed()?(r=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&o.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&a.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),r=0===t&&1===e,r&&!i)return void this.copyTo(n);if(n.m_center.assign(this.m_center),n.m_semiMajorAxis=this.m_semiMajorAxis,n.m_minorMajorRatio=this.m_minorMajorRatio,n.m_interior.assign(this.m_interior),n.m_rotation=this.m_rotation,n.m_cosr=this.m_cosr,n.m_sinr=this.m_sinr,n.m_sweepAngle=this.m_sweepAngle,n.m_startAngle=this.m_startAngle,n.m_bits=this.m_bits,zi(n,o.x,o.y),Bi(n,a.x,a.y),r)return void om(n,jh(this));n.m_startAngle=Gh(this,t),n.m_sweepAngle=Gh(this,e)-n.m_startAngle,n.m_startAngle=Lh(n.m_startAngle),um(n,Math.abs(n.m_sweepAngle)>Et()),n.assignVertexDescription(this.m_description),vm(n),Bh(n);const h=this.m_description.getAttributeCount();if(h>1){for(let e=1;e<h;e++){const s=this.m_description.getSemantics(e),i=Or.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<h;t++){const s=this.m_description.getSemantics(t),i=Or.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}n.afterCompletedModification()}queryDerivative(t,e){Am()}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const n=new os;this.queryCoord2D(t,n);const r=new os;this.queryCoord2D(e,r),i||(n.equals(r)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&n.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&r.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),i=0===t&&1===e)),s.m_center.assign(this.m_center),s.m_semiMajorAxis=this.m_semiMajorAxis,s.m_minorMajorRatio=this.m_minorMajorRatio,s.m_interior.assign(this.m_interior),s.m_rotation=this.m_rotation,s.m_cosr=this.m_cosr,s.m_sinr=this.m_sinr,s.m_sweepAngle=this.m_sweepAngle,s.m_startAngle=this.m_startAngle,s.m_bits=this.m_bits,zi(s,n.x,n.y),Bi(s,r.x,r.y),i?om(s,jh(this)):(s.m_startAngle=Gh(this,t),s.m_sweepAngle=Gh(this,e)-s.m_startAngle,s.m_startAngle=Lh(s.m_startAngle),um(s,Math.abs(s.m_sweepAngle)>Math.PI),vm(s),s.afterCompletedModification())}changeEndPoints2D(e,s){t(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);if(0===t)return this.getStartAttributeAsDbl(e,s);if(1===t)return this.getEndAttributeAsDbl(e,s);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0;return Xe(Or.getInterpolation(e),this.getStartAttributeAsDbl(e,s),this.getEndAttributeAsDbl(e,s),n,Or.getDefaultValue(e))}getClosestCoordinate(t,e){return Dm(this,t,kt.unit(),e)}getClosestCoordinateOnInterval(t,e,s){return Dm(this,t,e,!1)}getYMonotonicParts(e,s=!1){e.length<2&&f("");const i=this.getSemiAxes(),n=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),r=n+Et(),o=new Array(3);let a=0;if(o[0]=kh(this,n),o[0]>0&&o[0]<1&&a++,o[1]=kh(this,r),o[1]>0&&o[1]<1&&(o[a]=o[1],a++),0===a)return 0;o[a]=1,a++,t(e.length>=a);let h=0;for(let t=0;t<a;t++){const i=o[t];this.queryCut(h,i,e[t],s),h=i}return a}getMonotonicParts(e,s){if(e.length<4&&f(""),this.isDegenerateToLine())return e[0].createEllipticArc().assignCopy(this),s&&e[0].get().dropAllAttributes(),1;const i=this.getSemiAxes(),n=new Array(4);n[0]=Math.atan2(i.y*this.m_cosr,i.x*this.m_sinr),n[1]=n[0]+Et(),n[2]=Math.atan2(-i.y*this.m_sinr,i.x*this.m_cosr),n[3]=n[2]+Et();const r=new Array(5);let o=0;for(let t=0;t<4;t++)r[o]=kh(this,n[t]),r[o]>0&&r[o]<1&&o++;if(0===o)return 0;ke(r,o),r[o-1]<1&&(r[o]=1,o++),t(e.length>=o);let a=0;for(let t=0;t<o;t++){const i=r[t];this.queryCut(a,i,e[t],s),a=i}return o}intersectionWithAxis2D(t,e,s,i){if(em(this)){return new fl({pt1:this.getStartXY(),pt2:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i)}let n,r;const o=new Wt(e),a=this.getSemiAxes();if(t){if(e>this.m_center.y+a.x||e<this.m_center.y-a.x)return 0;n=new Wt(a.x).mulThis(this.m_sinr),r=new Wt(a.y).mulThis(this.m_cosr),o.subThis(this.m_center.y)}else{if(e>this.m_center.x+a.x||e<this.m_center.x-a.x)return 0;n=new Wt(a.x).mulThis(this.m_cosr),r=new Wt(a.y).mulThis(-this.m_sinr),o.subThis(this.m_center.x)}const h=n.sqr(),m=r.sqr(),u=h.addE(m),l=r.mulE(o).mulThis(-2),c=o.sqr().subThisE(h),d=l.sqr().subThisE(u.mulE(c).mulThis(4)),_=n.mulE(o).mulThis(-2),g=o.sqr().subThisE(m),p=_.sqr().subThisE(u.mulE(g).mulThis(4));let f=d.eps()*Math.abs(p.value())<=p.eps()*Math.abs(d.value());f?n.isZero()&&(f=!1):r.isZero()&&(f=!0),f||(l.setE(_),c.setE(g));const x=Ue(Wt,2);let y=Yr(u,l,c,kt.construct(-1,1),!1,x);if(0===y)return 0;const v=[0,0];let P=0;for(let b=0;b<y;b++){const t=new Wt,e=new Wt;f?(t.setE(x[b]),e.setE(o.subE(r.mulE(x[b])).divThisE(n))):(e.setE(x[b]),t.setE(o.subE(n.mulE(x[b])).divThisE(r)));const s=kh(this,Math.atan2(t.value(),e.value()));s>=0&&s<=1&&(v[P]=s,P++)}return y=P,0===y?0:(2===y&&v[0]>v[1]&&(v[1]=Ve(v[0],v[0]=v[1])),i&&ze(i,v,0,0,y),s&&(s[0]=t?this.getCoordX(v[0]):this.getCoordY(v[0]),y>1&&(s[1]=t?this.getCoordX(v[1]):this.getCoordY(v[1]),!i&&s[0]>s[1]&&(s[1]=Ve(s[0],s[0]=s[1])))),y)}intersectionOfYMonotonicWithAxisX(t,e){if(this.m_YStart===this.m_YEnd)return t===this.m_YStart?e:Number.NaN;if(t===this.m_YStart)return this.m_XStart;if(t===this.m_YEnd)return this.m_XEnd;const s=[0,0];return-1===this.intersectionWithAxis2D(!0,t,s,null)?e:s[0]}isCurve(){return!0}isDegenerate(t){return qi(this,t)}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(e){if(e instanceof Vs)return void t(0);if(em(this))return e.setCoords(this.getStartXY()),void e.mergeNe(this.getEndXY());const s=this.getSemiAxes();e.setCoords({xmin:this.m_center.x-s.x,ymin:this.m_center.y-s.x,xmax:this.m_center.x+s.x,ymax:this.m_center.y+s.x})}clone(t){const e=new jr;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(em(this))return 0===e?kt.construct(this.getStartX(),this.getEndX()):kt.construct(this.getStartY(),this.getEndY());let t;const s=this.getSemiAxes();t=0===e?Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr):Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr);const i=t+Math.PI,n=[0,0];n[0]=kh(this,t),n[1]=kh(this,i);const r=0===e?kt.construct(this.getStartX(),this.getEndX()):kt.construct(this.getStartY(),this.getEndY()),o=new os;for(let a=0;a<2;a++){const t=n[a];t>0&&t<1&&(this.queryCoord2D(t,o),r.mergeNeCoordinate(0===e?o.x:o.y))}return r}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){if(em(this))return e.setCoords(this.getStartXY()),void e.mergeNe(this.getEndXY());const s=this.getSemiAxes();e.setCoords({xmin:this.m_center.x-s.x,ymin:this.m_center.y-s.x,xmax:this.m_center.x+s.x,ymax:this.m_center.y+s.x})}tToLength(t){return em(this)?t*os.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:sm(this,t)}lengthToT(t){if(em(this)){const e=os.distance(this.getStartXY(),this.getEndXY());return 0===e?0:t/e}if(1===this.m_minorMajorRatio){const e=Math.abs(this.getSweepAngle())*this.m_semiMajorAxis;return 0===e?0:t/e}return im(this,t)}calculateWeightedAreaCentroid2D(e){return t(0),os.getNAN()}calculateWeightedCentroid2D(){return t(0),os.getNAN()}isIntersectingPoint(e,s,i){return t(0),!1}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}getTangent(t){if(em(this))return this.getEndXY().sub(this.getStartXY());{const e=Gh(this,t),s=new os;return s.setCoords(-this.m_semiMajorAxis*Math.sin(e),this.getSemiMinorAxis()*Math.cos(e)),this.m_rotation&&s.rotateDirect(this.m_cosr,this.m_sinr),s.scale(this.getSweepAngle()),s}}getDerivative(e){return t(0),os.getNAN()}normalizeAfterEndpointChange(){return!!dm(this)&&(em(this)?(_m(this),!1):gm(this,!1))}projectionBehavior(){return(4&this.m_bits)>>2}setProjectionBehavior(t){this.m_bits=-5&this.m_bits|t<<2}convertToCanonic(t){const e=new os(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new os(t.x,t.y);return e.rotateDirect(this.m_cosr,this.m_sinr),e.addThis(this.m_center),e}canonicToWorldTransformation(t){t.setRotate(this.m_cosr,this.m_sinr),t.shiftCoords(this.m_center.x,this.m_center.y)}queryAttributeAsDbl(e,s,i,n){t(0)}getCurvature(e){return t(0),0}getMonotonicPartParams(t,e){const s=new Array(6);s[0]=0;let i=1;if(this.isDegenerateToLine())s[1]=1,i=2;else{const t=this.getSemiAxes(),e=new Array(4);this.m_rotation?(e[0]=Math.atan2(t.y*this.m_cosr,t.x*this.m_sinr),e[1]=e[0]+Math.PI,e[2]=Math.atan2(-t.y*this.m_sinr,t.x*this.m_cosr),e[3]=e[2]+Math.PI):(e[0]=0,e[1]=Math.PI,e[2]=.5*Math.PI,e[3]=wt());for(let n=0;n<4;n++){const t=kh(this,e[n]);t>0&&t<1&&(s[i]=t,i++)}i>2&&ke(s,i),s[i]=1,i++}if(e){t<i&&f("");for(let t=0;t<i;t++)e[t]=s[t]}return i}calculateLowerLength2D(){const t=os.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMinorAxis();return Math.max(e,t)}calculateUpperLength2D(){const t=os.distance(this.getStartXY(),this.getEndXY());if(this.isDegenerateToLine())return t;const e=Math.abs(this.m_sweepAngle)*this.getSemiMajorAxis();return Math.max(e,t)}orientBottomUp(){t(0)}isLine(){return em(this)}copyIgnoreAttributes(t){t.m_XStart=this.m_XStart,t.m_YStart=this.m_YStart,t.m_XEnd=this.m_XEnd,t.m_YEnd=this.m_YEnd,t.m_center.assign(this.m_center),t.m_semiMajorAxis=this.m_semiMajorAxis,t.m_minorMajorRatio=this.m_minorMajorRatio,t.m_interior.assign(this.m_interior),t.m_rotation=this.m_rotation,t.m_cosr=this.m_cosr,t.m_sinr=this.m_sinr,t.m_sweepAngle=this.m_sweepAngle,t.m_startAngle=this.m_startAngle,t.m_bits=this.m_bits,am(t)}calculateArea2DHelper(){if(this.isLine())return 0;if(this.isDegenerate(0))return 0;const t=this.m_semiMajorAxis,e=this.getSemiMinorAxis(),s=t*t+e*e,i=this.getStartAngle(),n=this.getEndAngle(),r=this.m_center.y-this.m_YStart,o=this.m_cosr,a=this.m_sinr;let h=1,m=0;this.m_rotation&&(h=(o-a)*(o+a),m=2*o*a);const u=((-.5*(n-i)+.25*h*(2*Math.cos(n+i)*Math.sin(n-i)))*e+-2*Math.sin(.5*(n+i))*Math.sin(.5*(n-i))*o*r)*t/s;let l=0;if(this.m_rotation){l=.125*(-2*Math.sin(n+i)*Math.sin(n-i))*m-e*r/s*(2*Math.cos(.5*(n+i))*Math.sin(.5*(n-i)))*a}return s*(u+l)+-.5*(this.m_XEnd-this.m_XStart)*(this.m_YEnd-this.m_YStart)}absNorm(){let t=this.getStartXY().norm(1)+this.getEndXY().norm(1);return this.isDegenerateToLine()||(t+=this.m_center.norm(1),t+=this.m_semiMajorAxis),t}queryEnvelopeW(t,e){if(e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax)),em(this))return;const s=this.getSemiAxes(),i=new Array(8);{const t=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),e=t+Math.PI,n=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r=n+Math.PI;i[0]=kh(this,t),i[1]=kh(this,e),i[2]=kh(this,n),i[3]=kh(this,r)}{const t=this.m_cosr+this.m_sinr,e=this.m_cosr-this.m_sinr,n=Math.atan2(-s.y*t,s.x*e),r=n+Math.PI,o=Math.atan2(s.y*e,s.x*t),a=o+Math.PI;i[4]=kh(this,n),i[5]=kh(this,r),i[6]=kh(this,o),i[7]=kh(this,a)}const n=os.getNAN();for(let r=0;r<8;r++){const s=i[r];t.containsExclusiveCoordinate(s)&&(this.queryCoord2D(s,n),e.mergeNe(n))}}setSegmentFromCoords(t,e){Kh(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(10);return s[0]=this.m_bits,s[1]=this.m_semiMajorAxis,s[2]=this.m_minorMajorRatio,s[3]=this.m_rotation,s[4]=this.m_center.x,s[5]=this.m_center.y,s[6]=this.m_sweepAngle,s[7]=this.m_startAngle,s[8]=this.m_interior.x,s[9]=this.m_interior.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(10);t.queryRange(e,s.length,s,!0,1),this.m_bits=s[0],this.m_semiMajorAxis=s[1],this.m_minorMajorRatio=s[2],this.m_rotation=s[3],this.m_center.x=s[4],this.m_center.y=s[5],this.m_sweepAngle=s[6],this.m_startAngle=s[7],this.m_interior.x=s[8],this.m_interior.y=s[9],this.m_cosr=Math.cos(this.m_rotation),this.m_sinr=Math.sin(this.m_rotation),this.m_cachedValues=null}snapControlPoints(t){return!1}needsSnapControlPoints(e){return t(0),!1}calculateSpecialPointsForCracking(e,s){return t(0),0}ensureXYMonotone(){return t(0),!1}setCoordsForIntersector(t,e,s){Qh(this,t,e,s)}getInteriorPoint(){return t(0),this.m_interior}copyToImpl(t){const e=t;e.m_center.assign(this.m_center),e.m_semiMajorAxis=this.m_semiMajorAxis,e.m_minorMajorRatio=this.m_minorMajorRatio,e.m_interior.assign(this.m_interior),e.m_rotation=this.m_rotation,e.m_cosr=this.m_cosr,e.m_sinr=this.m_sinr,e.m_sweepAngle=this.m_sweepAngle,e.m_startAngle=this.m_startAngle,e.m_bits=this.m_bits,om(e,jh(this))}reverseImpl(){hm(this,!mm(this)),Bh(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&vm(this)}equalsImpl(t){const e=t;if(this.m_bits!==e.m_bits)return!1;if(this.m_semiMajorAxis!==e.m_semiMajorAxis)return!1;if(this.m_minorMajorRatio!==e.m_minorMajorRatio)return!1;if(!(this.m_center.isEqualPoint2D(e.m_center)||this.m_center.isNAN()&&e.m_center.isNAN()))return!1;if(this.m_rotation!==e.m_rotation)return!1;if(!this.m_interior.equals(e.m_interior))return!1;const s=e.m_sweepAngle;if(this.m_sweepAngle!==s)return!1;const i=e.m_startAngle;return this.m_startAngle===i}equalsImplTol(t,e){const s=t;if(this.m_bits!==s.m_bits)return!1;if(this.m_center.isNAN()&&s.m_center.isNAN())return!0;if(this.m_center.isNAN()!==s.m_center.isNAN())return!1;if(!this.getSemiAxes().isEqualPoint2D(s.getSemiAxes(),e))return!1;if(!this.m_center.isEqualPoint2D(s.m_center,e))return!1;const i=Math.abs(Pr(vr(br(this.m_rotation-s.m_rotation)))),n=Math.abs(Et()-i),r=Math.min(i,n);if(this.m_semiMajorAxis*Math.abs(r)>e)return!1;const o=this.getCoord2D(.5),a=s.getCoord2D(.5);return!!o.isEqualPoint2D(a,e)}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){_m(this),am(this)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&b(""),em(this)){return new fl({pt1:this.getStartXY(),pt2:this.getEndXY()}).intersectPoint(t,e,s)}{const e=os.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const i=this.getClosestCoordinate(t,!1),n=os.getNAN();return this.queryCoord2D(i,n),os.distance(n,t)<=s?vt(i,0,1)&&(this.queryCoord2D(0===i?1:0,n),os.distance(n,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==ol(!1,this,t,e,s)}intersect_(e,s,i,n){return t(0),0}endPointModified(){this.m_bits|=8,am(this)}clearEndPointModified(){_m(this)}}jr.type=r.enumEllipticArc;class Ur extends un{constructor(e){e?e.vd?(super({vd:e.vd,bPolygon:!0}),this.m_segmentBufferCTor=xl):e.copy?(super({vd:e.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=xl,e.copy.copyTo(this)):e.move?(super({move:e.move}),this.m_segmentBufferCTor=xl):(e.envelope,t(0)):(super({bPolygon:!0}),this.m_segmentBufferCTor=xl)}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}getBoundary(){return gr(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return Ur.type}getDimension(){return 2}createInstance(){return new Ur({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function Qr(t,e,s,i,n,r){const o=.5*(i.sub(e).length()+i.sub(s).length());t.m_center.assign(i),t.m_startAngle=Math.atan2(e.y-t.m_center.y,e.x-t.m_center.x);Kr(t,Math.atan2(s.y-t.m_center.y,s.x-t.m_center.x),n,r);const a=t.constructEllipticArcEndPointsCenter(e,s,o,1,0,Math.abs(t.m_sweepAngle)>Math.PI,t.m_sweepAngle>0,i);return t.setProjectionBehavior(0),a}function Kr(t,e,s,i){let n=t.m_startAngle,r=t.m_sweepAngle;const o=1e-12;for(;n>Et();)n-=2*Et();for(;n<=-Et();)n+=2*Et();if(!Number.isNaN(e)){for(;e>Et();)e-=2*Et();for(;e<=-Et();)e+=2*Et();!s&&e>n&&(e-=2*Et()),s&&e<n&&(e+=2*Et()),r=e-n,Math.abs(r)<o&&!i&&(r=s?2*Et():-2*Et()),Math.abs(r)>2*Et()-o&&i&&(r=0)}Math.abs(r)>2*Et()-o&&(r=r>=0?2*Et():-2*Et(),t.setEndXY(t.getStartXY())),Math.abs(r)<o&&(r=0,t.setEndXY(t.getStartXY())),i=Math.abs(r)<=Et(),r&&(s=r>0),t.m_startAngle=Lh(n),t.m_sweepAngle=r,um(t,!i),hm(t,s)}function $r(t,e,s,i,n,r,o,a,h,m=null){const u=Math.max(Ki(t,e),s),l=Math.max(i,4*u);if($i(t,e,l))return 0;return new ho(t,e,u,l,a,!1,m).intersectNonMonotone(n,r,o,h)}function Jr(t,e,s,i,n,r=null){const o=Math.max(Ki(t,e),s),a=Math.max(i,4*o);if($i(t,e,a))return!1;return new ho(t,e,o,a,n,!0,r).intersectNonMonotone(null,null,null,!1)>0}function to(t,e,s,i,n=null){const r=Qi(e),o=Math.max(4*r,s);return new ho(e,null,o,Number.NaN,!1,!1,n).approximateWithCirclesImpl(t,i)}function eo(t,e,s,i,n,r,o){return{ptStart:t.clone(),ptEnd:e.clone(),ptStartIntervalLeft:new kt(s),ptStartIntervalRight:new kt(i),ptEndIntervalLeft:new kt(s),ptEndIntervalRight:new kt(i),intervalLeft:new kt(s),intervalRight:new kt(i),distance:n,kind:r,mask:o}}function so(t){return Number.isNaN(t.radius.value())}function io(){return{ptStart:new os,ptEnd:new os,center:new Ai,radius:new Wt,fcenter:new os,fradius2:Number.NaN,maxError:0}}function no(t,e,s,i){return{pt:t.clone(),t:e,err:s,checkCount:i}}function ro(){return{pt:new os,leftParam:Number.NaN,rightParam:Number.NaN}}Ur.type=r.enumPolygon;const oo=5,ao=1/8;class ho{constructor(t,e,s,i,n,r,o=null){this.m_currentIntersections=[],this.m_circleCheckCounter=0,this.m_circleIntersectCounter=0,this.m_leftRecursionCounter=0,this.m_rightRecursionCounter=0,this.m_maxRecursionDepth=0,this.m_bReversedLeft=!1,this.m_bReversedRight=!1,this.m_leftArc=io(),this.m_rightArc=io(),this.m_line1=new fl,this.m_line2=new fl,this.m_tracker=null,this.m_trackerCounter=0,this.m_left=t,this.m_right=e,this.m_eps=s,this.m_tolerance=i,this.m_sqrTolerance=ce(this.m_tolerance),this.m_bExcludeExactEndpoints=n,this.m_bBreakEarly=r,this.m_tracker=o}intersectNonMonotone(e,s,i,n){null!==e&&(e.length=0),null!==s&&(s.length=0),null!==i&&(i.length=0);const r=[],o=new Array(9),a=this.m_left.getMonotonicPartParams(o.length,o),h=new Array(9),m=this.m_right.getMonotonicPartParams(h.length,h);let u=0;for(let t=1;t<a;t++){const e=new kt(o[t-1],o[t]);for(let t=1;t<m;t++){const s=new kt(h[t-1],h[t]);u|=this.intersectMonotone(e,s)?1:0;for(const t of this.m_currentIntersections)if(1024&t.kind){let e=ro();if(e.pt.assign(t.ptStart),e.leftParam=ho.pointToT(this.m_left,t.ptStartIntervalLeft,t.ptStart),e.rightParam=ho.pointToT(this.m_right,t.ptStartIntervalRight,t.ptStart),r.push(e),e=ro(),e.pt.assign(t.ptEnd),e.leftParam=ho.pointToT(this.m_left,t.ptEndIntervalLeft,t.ptEnd),e.rightParam=ho.pointToT(this.m_right,t.ptEndIntervalRight,t.ptEnd),r.push(e),this.m_bBreakEarly)return 1}else{const e=ro();if(e.pt.assign(t.ptStart),e.leftParam=ho.pointToT(this.m_left,t.ptStartIntervalLeft,t.ptStart),e.rightParam=ho.pointToT(this.m_right,t.ptStartIntervalRight,t.ptStart),this.m_bBreakEarly){if(!vt(e.leftParam,0,1)&&!vt(e.rightParam,0,1))return 1;if(!this.m_left.getCoord2D(e.leftParam).equals(this.m_right.getCoord2D(e.rightParam)))return 1}r.push(e)}this.m_currentIntersections.length=0}}if(u){const o=(t,e)=>n?Ze(t.rightParam,t.leftParam,e.rightParam,e.leftParam):Ze(t.leftParam,t.rightParam,e.leftParam,e.rightParam);r.sort(o);let a=0;for(let t=0,n=r.length;t<n;++t){const n=r[t];if(this.m_bExcludeExactEndpoints&&vt(n.leftParam,0,1)&&vt(n.rightParam,0,1)){const t=os.getNAN();this.m_left.queryCoord2D(n.leftParam,t);const e=os.getNAN();if(this.m_right.queryCoord2D(n.rightParam,e),t.equals(e))continue}if(a>0){const t=Math.abs(n.leftParam-r[a-1].leftParam),e=Math.abs(n.rightParam-r[a-1].rightParam);if(0===t&&0===e)continue}t!==a&&(r[a]=n),null!==e&&e.push(n.pt),null!==s&&s.push(n.leftParam),null!==i&&i.push(n.rightParam),a++}return t(a<=Number.MAX_SAFE_INTEGER),a}return 0}intersectMonotone(e,s){if(this.m_bReversedLeft=!ho.goodOrientation(this.m_left,e),this.m_bReversedRight=!ho.goodOrientation(this.m_right,s),this.checkAndProcessOverlap(this.m_tolerance,e,s))return!0;const i=[],n=[];{const t=new os;this.m_bReversedLeft?(i.push(no(t,e.vmin,0,0)),i.push(no(t,e.vmax,0,0))):(i.push(no(t,e.vmax,0,0)),i.push(no(t,e.vmin,0,0))),i[0].pt=this.m_left.getCoord2D(i[0].t),i[1].pt=this.m_left.getCoord2D(i[1].t),this.m_bReversedRight?(n.push(no(t,s.vmin,0,0)),n.push(no(t,s.vmax,0,0))):(n.push(no(t,s.vmax,0,0)),n.push(no(t,s.vmin,0,0))),n[0].pt=this.m_right.getCoord2D(n[0].t),n[1].pt=this.m_right.getCoord2D(n[1].t)}const r=i[i.length-1].pt.clone(),o=n[n.length-1].pt.clone(),a=new os,h=new os,m=as.constructEmpty(),u=as.constructEmpty(),l=kt.constructEmpty(),c=kt.constructEmpty();let d=!0,_=!0,g=-1,p=-1;this.m_leftArc=io(),this.m_rightArc=io();let f=0,x=0,y=0,v=0,P=!1;for(;i.length>1&&n.length>1;){const e=Math.max(i.length,n.length);if(e>this.m_maxRecursionDepth&&(this.m_maxRecursionDepth=e,t(this.m_maxRecursionDepth<32)),d){a.assign(i[i.length-2].pt),m.setCoords({pt1:r,pt2:a});const t=i.at(-1);l.setCoords(t.t,i[i.length-2].t),f=t.err,y=t.checkCount,g=-1,d=!1}if(_){h.assign(n[n.length-2].pt),u.setCoords({pt1:o,pt2:h});const t=n.at(-1);c.setCoords(t.t,n[n.length-2].t),x=t.err,v=t.checkCount,p=-1,_=!1}const s=(a.compare(h)<0?a:h).clone();let b=!1;const E=new as(m);if(E.inflateCoords(this.m_tolerance,this.m_tolerance),E.isIntersectingNe(u)){if(b=m.maxDimension()>=u.maxDimension(),b&&-1===g||1===p){const t=l.getCenter(),e=this.m_left.getCoord2D(t);if(f<=this.m_eps||y>=oo?(g=this.closeToCircularArc(this.m_left,l,r,e,a,this.m_leftArc)?1:0,f=this.m_leftArc.maxError,y=0):y++,1!==g){const s=i[i.length-1].t,n=i[i.length-1].pt.clone(),r=i.at(-1);r.t=t,r.pt.assign(e),f*=ao,r.err=f,r.checkCount=y,i.push(no(n,s,f,y)),d=!0;continue}}if(-1===p){const t=c.getCenter(),e=this.m_right.getCoord2D(t).clone();if(x<=this.m_eps||v>=oo?(p=this.closeToCircularArc(this.m_right,c,o,e,h,this.m_rightArc)?1:0,x=this.m_rightArc.maxError,v=0):v++,1!==p){const s=n[n.length-1].t,i=n[n.length-1].pt.clone(),r=n.at(-1);r.t=t,r.pt.assign(e),x*=ao,r.err=x,r.checkCount=v,n.push(no(i,s,x,v)),_=!0;continue}}if(1!==g||1!==p)continue;{const t=this.intersectCircular(l,c);P||=t}}s.equals(a)&&(i.pop(),r.assign(a),d=!0),s.equals(h)&&(n.pop(),o.assign(h),_=!0)}return P}adaptiveDensify(e,s){t(0)}adaptiveDensifyMonotone(e,s,i,n){t(0)}intersecting(e,s){return t(0),!1}closeToCircularArc(t,e,s,i,n,r){if(this.m_circleCheckCounter++,r.maxError=0,!ho.checkSweepAngle(t,e))return!1;if(r.ptStart.assign(s),r.ptEnd.assign(n),t.isCircular()){const e=t;return r.radius.set(e.getSemiMajorAxis()),r.center.set(e.getCenter()),!0}const o=r.ptEnd.sub(r.ptStart).clone();o.leftPerpendicularThis(),o.normalize();if(Math.abs(o.dotProduct(i.sub(r.ptStart)))<=this.m_eps)return!!this.confirmIsLine(r,o)&&(r.radius.set(Number.NaN),r.center.setCoords(0,0),!0);{const s=r.ptEnd.sub(r.ptStart),n=i.sub(r.ptStart),o=s.crossProduct(n);if(0===o)return!1;const a=.5*s.sqrLength(),h=.5*n.sqrLength();let m=a*n.y-h*s.y;m/=o;let u=s.x*h-n.x*a;u/=o;const l=Math.sqrt(m*m+u*u);if(4*yt()*l>this.m_eps)return!1;const c=m+r.ptStart.x,d=u+r.ptStart.y;r.radius.setWithEps(l),r.center.setWithEps(new os(c,d));const _=this.maxCircleApproximationError(t,e,r);return!(_>this.m_eps)||(r.maxError=_,!1)}}intersectLineLine(t,e){const s=new os;this.m_left.queryCoord2D(t.vmin,s);const i=new os;this.m_left.queryCoord2D(t.vmax,i),this.m_line1.construct(s,i),this.m_right.queryCoord2D(e.vmin,s),this.m_right.queryCoord2D(e.vmax,i),this.m_line2.construct(s,i);const n=Ue(os,2);if(1===nr(this.m_line1,this.m_line2,n))return this.addIntersectionPoint(n[0],0,t,e,266,0);{let s=new os,i=Number.MAX_VALUE,n=0;const r=or(this.m_line1,this.m_line2.getStartXY(),this.m_tolerance,!1);if(!Number.isNaN(r)){n++;const t=os.distance(this.m_line1.getCoord2D(r),this.m_line2.getStartXY());t<i&&(i=t,s=this.m_line2.getStartXY())}const o=or(this.m_line1,this.m_line2.getEndXY(),this.m_tolerance,!1);if(!Number.isNaN(o)){n++;const t=os.distance(this.m_line1.getCoord2D(o),this.m_line2.getEndXY());t<i&&(i=t,s=this.m_line2.getEndXY())}const a=or(this.m_line2,this.m_line1.getStartXY(),this.m_tolerance,!1);if(!Number.isNaN(a)){n++;const t=os.distance(this.m_line2.getCoord2D(a),this.m_line1.getStartXY());t<i&&(i=t,s=this.m_line1.getStartXY())}const h=or(this.m_line2,this.m_line1.getEndXY(),this.m_tolerance,!1);if(!Number.isNaN(h)){n++;const t=os.distance(this.m_line2.getCoord2D(h),this.m_line1.getEndXY());t<i&&(i=t,s=this.m_line1.getEndXY())}if(n>0)return this.addIntersectionPoint(s,i,t,e,i>0?513:266,0)}return!1}intersectLineCircular(e,s){return t(0),!1}intersectCircularLine(t,e,s){if(so(this.m_leftArc))return this.intersectLineLine(t,e);const i=os.getClosestCoordinate(this.m_rightArc.ptStart,this.m_rightArc.ptEnd,this.m_leftArc.center.value(),!0),n=new os;le(this.m_rightArc.ptStart,this.m_rightArc.ptEnd,i,n);const r=new Ai;r.setWithEps(n);const o=r.subE(this.m_leftArc.center).sqrLength(),a=this.m_leftArc.radius.sqr().subE(o);if(a.value()>0){const i=a.clone();i.sqrtThis();const n=Ai.constructPoint2D(this.m_rightArc.ptEnd.sub(this.m_rightArc.ptStart)).getUnitVector(),o=r.addE(n.mulE(i)),h=r.subE(n.mulE(i));let m=!1;return(this.m_leftArc.ptStart.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptStart.equals(this.m_rightArc.ptEnd))&&(o.eq(Ai.constructPoint2D(this.m_leftArc.ptStart))&&o.set(this.m_leftArc.ptStart),h.eq(Ai.constructPoint2D(this.m_leftArc.ptStart))&&h.set(this.m_leftArc.ptStart)),(this.m_leftArc.ptEnd.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptEnd.equals(this.m_rightArc.ptEnd))&&(o.eq(Ai.constructPoint2D(this.m_leftArc.ptEnd))&&o.set(this.m_leftArc.ptEnd),h.eq(Ai.constructPoint2D(this.m_leftArc.ptEnd))&&h.set(this.m_leftArc.ptEnd)),this.isOnArc(this.m_leftArc,o)&&this.isOnArc(this.m_rightArc,o)&&(m=s?this.addIntersectionPoint(o.value(),0,e,t,268,18)||m:this.addIntersectionPoint(o.value(),0,t,e,268,18)||m),this.isOnArc(this.m_leftArc,h)&&this.isOnArc(this.m_rightArc,h)&&(m=s?this.addIntersectionPoint(h.value(),0,e,t,268,18)||m:this.addIntersectionPoint(h.value(),0,t,e,268,18)||m),m}{const i=Math.sqrt(o.value())-this.m_leftArc.radius.value();if(i<=this.m_tolerance&&((this.m_leftArc.ptStart.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptStart.equals(this.m_rightArc.ptEnd))&&r.eq(Ai.constructPoint2D(this.m_leftArc.ptStart))&&r.set(this.m_leftArc.ptStart),(this.m_leftArc.ptEnd.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptEnd.equals(this.m_rightArc.ptEnd))&&r.eq(Ai.constructPoint2D(this.m_leftArc.ptEnd))&&r.set(this.m_leftArc.ptEnd),this.isOnArc(this.m_leftArc,r)&&this.isOnArc(this.m_rightArc,r))){if(s){return this.addIntersectionPoint(n,i,t,e,260,18)}return this.addIntersectionPoint(n,i,e,t,260,18)}}return!1}intersectCircular(t,e){if(so(this.m_rightArc))return this.intersectCircularLine(t,e,!1);if(so(this.m_leftArc))return this.intersectLineCircular(t,e);const s=Ai.distance(this.m_leftArc.center,this.m_rightArc.center),i=s.subE(this.m_leftArc.radius.addE(this.m_rightArc.radius));if(i.ge(Ut)){if(i.value()<=this.m_tolerance){i.value()<0&&i.set(0);const s=this.m_rightArc.center.subE(this.m_leftArc.center).getUnitVector(),n=.5*i.value(),r=this.m_leftArc.radius.value()<this.m_rightArc.radius.value()?s.mulE(this.m_leftArc.radius.add(n)).addE(this.m_leftArc.center):this.m_rightArc.center.subE(s.mulE(this.m_rightArc.radius.add(n)));if(this.isOnArc(this.m_leftArc,r)&&this.isOnArc(this.m_rightArc,r)){return this.addIntersectionPoint(r.value(),i.value(),t,e,i.value()>0?515:259,18)}return!1}return!1}{const i=Math.min(this.m_leftArc.radius.value(),this.m_rightArc.radius.value()),n=Math.max(this.m_leftArc.radius.value(),this.m_rightArc.radius.value());if(s.value()+i<=n){const r=n-(s.value()+i);if(r<=this.m_tolerance){if(i<n&&s.value()>0){const s=.5*r,i=this.m_leftArc.center.subE(this.m_rightArc.center).getUnitVector();this.m_leftArc.radius.value()>this.m_rightArc.radius.value()&&i.negateThis();const n=this.m_leftArc.radius.value()<this.m_rightArc.radius.value()?this.m_leftArc.center.addE(i.mulE(this.m_leftArc.radius.add(s))):this.m_rightArc.center.addE(i.mulE(this.m_rightArc.radius.add(s)));if(this.isOnArc(this.m_leftArc,n)&&this.isOnArc(this.m_rightArc,n)){return this.addIntersectionPoint(n.value(),r,t,e,r>0?514:258,18)}return!1}{const i=(s.isZero(),1285);return this.addOverlap(r,t,e,i)}}return!1}return this.intersectCircles(t,e)}}isOnArc(t,e){if(so(t)){const s=e.subE(Ai.constructPoint2D(t.ptStart)),i=e.subE(Ai.constructPoint2D(t.ptEnd)),n=Ai.constructPoint2D(t.ptEnd).subE(Ai.constructPoint2D(t.ptStart)),r=s.dotProduct(n),o=i.dotProduct(n).negate();return!r.lt(Ut)&&!o.lt(Ut)}{const s=e.subE(t.center),i=Ai.constructPoint2D(t.ptStart).subE(t.center),n=Ai.constructPoint2D(t.ptEnd).subE(t.center);if(s.dotProduct(i).le(Ut))return!1;if(s.dotProduct(n).le(Ut))return!1;const r=s.crossProduct(i),o=s.crossProduct(n);return r.le(Ut)&&o.ge(Ut)||r.ge(Ut)&&o.le(Ut)}}intersectCircles(t,e){let s=this.m_leftArc,i=this.m_rightArc;this.m_leftArc.radius.value()>this.m_rightArc.radius.value()&&(i=Ve(s,s=i));const n=s.center.value(),r=i.center.value(),o=s.radius.value(),a=i.radius.value(),h=r.sub(n),m=h.sqrLength(),u=Math.sqrt(m);let l,c=.5*((o*o-a*a)/u+u);if(o<=Math.abs(c))c=c>0?o:-o,l=0;else{const t=o*o-c*c;l=Math.sqrt(t)}const d=h.clone();d.divThis(u);const _=d.mul(c);d.leftPerpendicularThis();const g=_.add(d.mul(l));g.addThis(n);const p=_.sub(d.mul(l));p.addThis(n),(this.m_leftArc.ptStart.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptStart.equals(this.m_rightArc.ptEnd))&&(g.equals(this.m_leftArc.ptStart)&&g.assign(this.m_leftArc.ptStart),p.equals(this.m_leftArc.ptStart)&&p.assign(this.m_leftArc.ptStart)),(this.m_leftArc.ptEnd.equals(this.m_rightArc.ptStart)||this.m_leftArc.ptEnd.equals(this.m_rightArc.ptEnd))&&(g.equals(this.m_leftArc.ptEnd)&&g.assign(this.m_leftArc.ptEnd),p.equals(this.m_leftArc.ptEnd)&&p.assign(this.m_leftArc.ptEnd));let f=!1;return this.isOnArc(this.m_leftArc,Ai.constructPoint2D(g))&&this.isOnArc(this.m_rightArc,Ai.constructPoint2D(g))&&(this.addIntersectionPoint(g,0,t,e,267,18),f=!0),this.isOnArc(this.m_leftArc,Ai.constructPoint2D(p))&&this.isOnArc(this.m_rightArc,Ai.constructPoint2D(p))&&(this.addIntersectionPoint(p,0,t,e,267,18),f=!0),f}static checkSweepAngle(t,e){if(t.getGeometryType()===r.enumEllipticArc){const s=t,i=Gh(s,e.vmin),n=Gh(s,e.vmax);return!(Math.abs(n-i)>.5*Dt())}return!0}static calcCircleDir(e,s,i,n){return t(0),new os}confirmIsLine(t,e){const s=t.ptEnd.sub(t.ptStart);return!(Math.abs(e.dotProduct(s.mul(.25)))>this.m_eps)&&!(Math.abs(e.dotProduct(s.mul(.75)))>this.m_eps)}maxCircleApproximationError(t,e,s){const i=[.25,.75],n=[.1,.25,.75,.9];let o;o=t.getGeometryType()===r.enumEllipticArc?i:n;const a=o.length;let h=0;for(let r=0;r<a;++r){const i=new os;t.queryCoord2D(he(e.vmin,e.vmax,o[r]),i);const n=i.sub(s.center.value()).length(),a=Math.abs(n-s.radius.value());a>h&&(h=a)}return h}addIntersectionPoint(t,e,s,i,n,r){e<0&&(e=0);const o=eo(t,t,s,i,e,n,r);if(this.m_currentIntersections.length>0){const t=this.m_currentIntersections.at(-1);if(this.tryMergeResults(t,o))return!0}return this.m_currentIntersections.push(o),!0}addOverlap(e,s,i,n){let r=0,o=0;if(this.isOnArc(this.m_leftArc,Ai.constructPoint2D(this.m_rightArc.ptStart))&&(o|=16,o|=1,r++),this.isOnArc(this.m_leftArc,Ai.constructPoint2D(this.m_rightArc.ptEnd))&&(o|=16,o|=4,r++),this.isOnArc(this.m_rightArc,Ai.constructPoint2D(this.m_leftArc.ptStart))&&(o|=8,o|=2,r++),this.isOnArc(this.m_rightArc,Ai.constructPoint2D(this.m_leftArc.ptEnd))&&(o|=32,o|=2,r++),!r)return!1;r<2&&t(r>1);const a=new os;8&o?a.assign(this.m_leftArc.ptStart):a.assign(this.m_bReversedLeft===this.m_bReversedRight?this.m_rightArc.ptStart:this.m_rightArc.ptEnd);const h=new os;32&o?h.assign(this.m_leftArc.ptEnd):h.assign(this.m_bReversedLeft===this.m_bReversedRight?this.m_rightArc.ptEnd:this.m_rightArc.ptStart);const m=eo(a,h,s,i,e,n,o);if(this.m_currentIntersections.length>0){const t=this.m_currentIntersections.at(-1);if(this.tryMergeResults(t,m))return!0}return this.m_currentIntersections.push(m),!0}static pointToT(t,e,s){return t.getClosestCoordinateOnInterval(s,e,-1)}approximateWithCirclesImpl(t,e){let s=1;e&&e.push(0);const i=new Array(9);let n;t?n=this.m_left.getMonotonicPartParams(i.length,i):(i[0]=0,i[1]=1,n=2);const r=[],o=[],a=new os(0,0);for(let h=1;h<n;h++){const t=new kt(i[h-1],i[h]);for(this.m_bReversedLeft=!ho.goodOrientation(this.m_left,t),this.m_bReversedLeft?(r.push(no(a,t.vmin,0,0)),r.push(no(a,t.vmax,0,0))):(r.push(no(a,t.vmax,0,0)),r.push(no(a,t.vmin,0,0))),r[0].pt.assign(this.m_left.getCoord2D(r[0].t)),r[1].pt.assign(this.m_left.getCoord2D(r[1].t));r.length>1;){this.progress_();const t=r.at(-1);let i=t.checkCount,n=t.err;const a=t.pt.clone(),h=t.t,m=r[r.length-2].t,u=.5*(h+m),l=this.m_left.getCoord2D(u);if(n<=this.m_eps||i>=oo){const t=new kt;if(t.setCoords(h,m),this.closeToCircularArc(this.m_left,t,a,l,r[r.length-2].pt,this.m_leftArc)){e&&(this.m_bReversedLeft?o.push(h):e.push(m)),s++,r.pop();continue}i=0,n=this.m_leftArc.maxError}t.t=u,t.pt.setCoordsPoint2D(l),n*=ao,i++,t.err=n,t.checkCount=i,r.push(no(a,h,n,i))}if(this.m_bReversedLeft&&e){const t=e.length;e.length=t+o.length,ze(e,o.reverse(),t,0,o.length),o.length=0}r.length=0}return s}approximateWithCirclesImplPolyline(e){return t(0),{}}tryMergeResults(t,e){const s=t;let i=!1;if(s.intervalLeft.vmax===e.intervalLeft.vmin&&32&s.mask&&8&e.mask?s.intervalRight.vmax===e.intervalRight.vmin&&4&s.mask&&1&e.mask?(s.mask=-33&s.mask|32&e.mask,s.mask=-5&s.mask|4&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.vmin===e.intervalRight.vmax&&1&s.mask&&4&e.mask?(s.mask=-33&s.mask|32&e.mask,s.mask=-2&s.mask|1&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.equals(e.intervalRight)&&(s.mask=-33&s.mask|32&e.mask,s.mask|=7&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),i=!0):s.intervalLeft.vmin===e.intervalLeft.vmax&&8&s.mask&&4&e.mask?s.intervalRight.vmax===e.intervalRight.vmin&&4&s.mask&&1&e.mask?(s.mask=-9&s.mask|8&e.mask,s.mask=-5&s.mask|4&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.vmin===e.intervalRight.vmax&&1&s.mask&&4&e.mask?(s.mask=-9&s.mask|8&e.mask,s.mask=-2&s.mask|1&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.equals(e.intervalRight)&&(s.mask=-9&s.mask|8&e.mask,s.mask|=7&e.mask,s.intervalLeft.mergeNe(e.intervalLeft),i=!0):s.intervalLeft.equals(e.intervalLeft)&&(s.intervalRight.vmax===e.intervalRight.vmin&&4&s.mask&&1&e.mask?(s.mask|=56&e.mask,s.mask=-5&s.mask|4&e.mask,s.intervalRight.mergeNe(e.intervalRight),i=!0):s.intervalRight.vmin===e.intervalRight.vmax&&1&s.mask&&4&e.mask&&(s.mask|=56&e.mask,s.mask=-2&s.mask|1&e.mask,s.intervalRight.mergeNe(e.intervalRight),i=!0)),!i){if((513===t.kind||513===e.kind)&&this.connectedIntervals(t,e)){if(513===t.kind){if(t.distance>=e.distance)return t=e,!0;if(513!==e.kind)return!1}return!0}return!1}return t.kind&e.kind&1024?this.m_bReversedLeft?(s.ptStart=e.ptStart,s.ptStartIntervalLeft=e.ptStartIntervalLeft,s.ptStartIntervalRight=e.ptStartIntervalRight):(s.ptEnd=e.ptEnd,s.ptEndIntervalLeft=e.ptEndIntervalLeft,s.ptEndIntervalRight=e.ptEndIntervalRight):1024&e.kind&&(s.ptStart=e.ptStart,s.ptEnd=e.ptEnd,s.ptStartIntervalLeft=e.ptStartIntervalLeft,s.ptStartIntervalRight=e.ptStartIntervalRight,s.ptEndIntervalLeft=e.ptEndIntervalLeft,s.ptEndIntervalRight=e.ptEndIntervalRight),1024&(t.kind|e.kind)?s.kind=1024:256&(t.kind|e.kind)?s.kind=256:s.kind=512,t=s,!0}connectedIntervals(e,s){return t(0),!1}checkAndProcessOverlap(t,e,s){const i=new Array(4),n=new Array(4),r=Ue(os,4);let o=0;{const a=this.m_right.getCoord2D(s.vmin),h=this.m_right.getCoord2D(s.vmax);if(!this.m_left.isCloserThanDistance(a,e,t)||!this.m_left.isCloserThanDistance(h,e,t))return!1;const m=this.m_left.getClosestCoordinateOnInterval(a,e,-1),u=this.m_left.getCoord2D(m);os.distance(u,a)<=t&&(r[o].assign(a),i[o]=s.vmin,n[o]=m,o++);const l=this.m_left.getClosestCoordinateOnInterval(h,e,-1),c=this.m_left.getCoord2D(l);if(os.distance(c,h)<=t&&(r[o].assign(h),i[o]=s.vmax,n[o]=l,o++),2===o)return!!this.confirmDetectedOverlap(n[0],n[1],i[0],i[1],t)&&(this.addIntersectionPoint(a,0,e,s,266,0),this.addIntersectionPoint(h,0,e,s,266,0),!0)}{const a=this.m_left.getCoord2D(e.vmin),h=this.m_left.getCoord2D(e.vmax);if(!this.m_right.isCloserThanDistance(a,s,t)||!this.m_right.isCloserThanDistance(h,s,t))return!1;const m=this.m_right.getClosestCoordinateOnInterval(a,s,-1),u=this.m_right.getCoord2D(m);os.distance(u,a)<=t&&(i[o]=m,r[o].assign(a),n[o]=e.vmin,o++);const l=this.m_right.getClosestCoordinateOnInterval(h,s,-1),c=this.m_right.getCoord2D(l);if(os.distance(c,h)<=t&&(i[o]=l,n[o]=e.vmax,r[o].assign(h),o++),o>=2&&n[o-2]!==n[o-1]&&i[o-2]!==i[o-1]&&this.confirmDetectedOverlap(n[o-2],n[o-1],i[o-2],i[o-1],t))return this.addIntersectionPoint(r[o-2],0,e,s,266,0),this.addIntersectionPoint(r[o-1],0,e,s,266,0),!0}return!1}confirmDetectedOverlap(t,e,s,i,n){return ho.confirmDetectedOverlapHelper(this.m_left,t,e,this.m_right,s,i,n)&&ho.confirmDetectedOverlapHelper(this.m_right,s,i,this.m_left,t,e,n)}static confirmDetectedOverlapHelper(t,e,s,i,n,r,o){const a=[.1,.25,.75,.9],h=kt.constructEmpty();h.setCoords(n,r);for(let m=0,u=a.length;m<u;++m){const n=he(e,s,a[m]),r=new os;if(t.queryCoord2D(n,r),!i.isCloserThanDistance(r,h,o))return!1}return!0}static goodOrientation(t,e){const s=t.getCoord2D(e.vmin),i=t.getCoord2D(e.vmax);return s.compare(i)<0}progress_(t=!1){}}var mo=gs;function uo(t){return t.length>=3}class lo extends Hn{constructor(t){if(!t||t&&t.vd)return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new os(0,0),this.m_weights=[1,0,1],void(this.m_cachedValues=null);const e={...t};e.points&&(e.f=e.points[0],e.cp=e.points[1],e.t=e.points[2],e.weights&&(e.w0=e.weights[0],e.w1=e.weights[1],e.w2=e.weights[2])),e.f?(super({start:e.f,end:e.t}),e.w0&&(e.w0<=0||e.w1<=0||e.w2<=0)&&f("weights"),this.m_cp=e.cp.clone(),this.m_weights=e.w?[1,e.w,1]:[e.w0,e.w1,e.w2],this.m_cachedValues=null):(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new os,this.m_weights=[Number.NaN,Number.NaN,Number.NaN])}getBoundary(){return gr(this)}assignMove(t){return this}assignCopy(t){return t.copyTo(this),this}construct(t,e,s,i){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,1,i,1),Sa(this)}constructWeights(t,e,s,i,n,r){}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Sa(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return r.enumRationalBezier2}queryEnvelope(t){if(t instanceof as){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Oa(this);if(null!==e){const s=new os;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=Ue(os,3);this.queryControlPoints(s),Aa(s,this.m_weights,e);const i=new os;for(const n of e)this.queryCoord2D(n,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof cn){const e=Ue(os,3);return this.queryControlPoints(e),t.transformPoints(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new lo({vd:this.m_description})}calculateLength2D(){return Ta(this,1,!1)}calculateLowerLength2D(){return os.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){if(this.m_weights[1]>0){return os.distance(this.getStartXY(),this.m_cp)+os.distance(this.getEndXY(),this.m_cp)}return os.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){vh(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0){return void On(new fl({pt1:this.getStartXY(),pt2:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e)}if(t>1){return void On(new fl({pt1:this.getEndXY(),pt2:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}}const i=Ue(os,3);this.queryControlPoints(i),Eh(i,this.m_weights,t,e)}getCoordX(t){const e=new os;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new os;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticRationalBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=mo.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=mo.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){La(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&f("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const i=Ue(os,3);this.queryControlPoints(i);const n=[0,0,0];rh(i,this.m_weights,t,e,i,n),s.setControlPointsAndWeights(i,n)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),n=i>0?this.tToLength(t)/i:0;return Xe(mo.getInterpolation(e),this.getStartAttributeAsDbl(e,s),this.getEndAttributeAsDbl(e,s),n,mo.getDefaultValue(e))}getClosestCoordinate(t,e){return Ua(this,t,kt.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s){return Ua(this,t,e,!1,s)}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const n=new Array(3),r=Ue(Wt,2),o=new kt(0,1);let a=0;const h=Ue(os,3);if(this.queryControlPoints(h),t){if(n[0]=new Wt(h[0].y).sub(e).mul(this.m_weights[0]),n[1]=new Wt(h[1].y).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new Wt(h[2].y).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Yr(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordX(r[m].value())}else if(n[0]=new Wt(h[0].x).sub(e).mul(this.m_weights[0]),n[1]=new Wt(h[1].x).sub(e).mul(this.m_weights[1]),n[2]=n[0].subE(n[1].mul(2)).addE(new Wt(h[2].x).sub(e).mul(this.m_weights[2])),n[1]=n[1].subE(n[0]).mulThisByPower2(2),a=Yr(n[2],n[1],n[0],o,!1,r),s)for(let m=0;m<a;m++)s[m]=this.getCoordY(r[m].value());if(i)for(let m=0;m<a;m++)i[m]=r[m].value();else s&&Ge(s,a,We);return a}intersectionOfYMonotonicWithAxisX(e,s){if(this.m_YStart===this.m_YEnd)return e===this.m_YStart?s:Number.NaN;if(e===this.m_YStart)return this.m_XStart;if(e===this.m_YEnd)return this.m_XEnd;const i=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,e,i,null);return t(2!==n),-1===n?s:i[0]}isCurve(){return!0}isDegenerate(t){return qi(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof as)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY())}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=as.constructEmpty();this.queryEnvelope(t);const s=kt.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=Ue(os,3);this.queryControlPoints(s);const i=[0,0,0];rh(s,this.m_weights,t.vmin,t.vmax,s,i),e.setFromPoints(s,3)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp.isEqual(this.m_XStart,this.m_YStart),i=this.m_cp.isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp.setCoordsPoint2D(t):i&&this.m_cp.setCoordsPoint2D(e),this.normalizeAfterEndpointChange()}tToLength(t){return Ta(this,t,!0)}lengthToT(t){return ka(this,t)}calculateWeightedAreaCentroid2D(t){return os.getNAN()}calculateWeightedCentroid2D(){return os.getNAN()}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryWeights(t){for(let e=0;e<3;++e)t[e]=this.m_weights[e]}setWeights(t){}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPointsAndWeights(t,e){this.setCpsAndWeightsArray(t,e),this.afterCompletedModification()}getTangent(t){const e=Ue(os,3);return this.queryControlPoints(e),Va(e,this.m_weights,t)}getDerivative(t){return os.getNAN()}getCurvature(t){return 0}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}queryAttributeAsDbl(t,e,s,i){}isMonotoneQuickAndDirty(){const t=Ue(os,3);return this.queryControlPoints(t),eh(t)}getMonotonicPartParams(t,e){const s=wa(this),i=s.specialPointsCount();if(!e)return s.specialPointsCount();t<i&&f("");for(let n=0;n<i;n++)e[n]=s.specialPoints[n];return i}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Ve(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Ve(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=Ve(this.m_weights[0],this.m_weights[0]=this.m_weights[2]);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)Ve(this.m_attributes[t],this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=[t];return!!Ri(this,e)&&mh(this,e[0])}copyIgnoreAttributes(t){Ah(this,t)}calculateArea2DHelper(){return Ga(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}queryEnvelopeW(t,e){Ja(this,t,e)}setSegmentFromCoords(t,e){}writeInBufferStream(t,e){const s=new Float64Array(5);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,s[2]=this.m_weights[0],s[3]=this.m_weights[1],s[4]=this.m_weights[2],t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(5);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_weights[0]=s[2],this.m_weights[1]=s[3],this.m_weights[2]=s[4],this.m_cachedValues=null}snapControlPoints(t){const e=Ue(os,3);this.queryControlPoints(e);const s=os.sqrDistance(e[1],e[0]),i=os.sqrDistance(e[1],e[2]);let n=e[0].clone(),r=s;s>i&&(n=e[2].clone(),r=i);let o=!1;return r<=t&&0!==r&&(o=!0,this.setControlPoint1(n)),o}needsSnapControlPoints(t){if(!t)return!1;const e=Ue(os,3);this.queryControlPoints(e);const s=os.sqrDistance(e[1],e[0]),i=os.sqrDistance(e[1],e[2]);e[0].clone();let n=s;return s>i&&(e[2].clone(),n=i),n<=t&&0!==n}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return sh(this)}setCoordsForIntersector(t,e,s){oh(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),e.m_weights[0]=this.m_weights[0],e.m_weights[1]=this.m_weights[1],e.m_weights[2]=this.m_weights[2],ja(e,Oa(this))}reverseImpl(){this.m_weights[2]=Ve(this.m_weights[0],this.m_weights[0]=this.m_weights[2])}equalsImpl(t){const e=t;if(!this.m_cp.equals(e.m_cp))return!1;for(let s=0;s<3;s++)if(this.m_weights[s]!==e.m_weights[s])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=Ue(os,3);this.queryControlPoints(i);const n=Ue(os,3);s.queryControlPoints(n);const r=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let o=0;o<3;o++){const t=new ps;t.setCoordsPoint2DZ(i[o].mul(this.m_weights[o]),this.m_weights[o]);const s=new ps;if(s.setCoordsPoint2DZ(n[o].mul(r[o]),r[o]),!t.isEqual(s,e))return!1}return!0}getHashCodeImpl(){return 0}swapImpl(t){}afterCompletedModification(){Sa(this)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return $a(this,t,e,s)}intersect_(t,e,s,i){return 0}endPointModified(){Sa(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,i,n,r){(i<=0||r<=0||n<0)&&f("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&f("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=i,this.m_weights[1]=n,this.m_weights[2]=r,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}lo.type=r.enumRationalBezier2;class co{static constructPoint2D(t){return new co(es.constructDouble(t.x),es.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new es).setNAN(),void(this.y=(new es).setNAN());this.x=t.clone(),this.y=e.clone()}clone(){return new co(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new co(this.x.add(t.x),this.y.add(t.y))}sub(t){return new co(this.x.sub(t.x),this.y.sub(t.y))}sqrLength(){return this.x.sqr().addThis(this.y.sqr())}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mul(t){return this.clone().mulThis(t)}}var _o=gs;class go extends Hn{constructor(e){void 0===e?(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new os(0,0)):e.from?(super({XStart:e.from.x,YStart:e.from.y,XEnd:e.to.x,YEnd:e.to.y,...e.vd}),this.m_cp=e.cp.clone()):e.points?(super({XStart:e.points[0].x,YStart:e.points[0].y,XEnd:e.points[2].x,YEnd:e.points[2].y,...e.vd}),this.m_cp=e.points[1].clone()):e.copy?(super(e),this.m_cp=e.copy.m_cp.clone()):(t(0),super({XStart:0,YStart:0,XEnd:0,YEnd:0,...e.vd}),this.m_cp=new os(0,0))}getBoundary(){return gr(this)}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),zo(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),zo(this)}getGeometryType(){return r.enumBezier2}queryEnvelope(e){t(0)}applyTransformation(e){t(0)}createInstance(){return new go({vd:this.m_description})}calculateLength2D(){return t(0),0}calculateLowerLength2D(){return t(0),0}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return os.distance(this.getStartXY(),this.m_cp)+os.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=Ue(os,3);this.queryControlPoints(i),ma(i,t,e,s)}queryCoord2DE(t,e){ua()}getCoordX(e){return t(0),0}getCoordY(e){return t(0),0}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createQuadraticBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=_o.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=_o.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){la()}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&f("Quadratic_bezier.cut_bezier_ignore_attributes"),0===t&&1===e)return s.setStartXY(this.getStartXY()),s.m_cp.assign(this.m_cp),void s.setEndXY(this.getEndXY());const i=Ue(os,3);this.queryControlPoints(i),Jo(i,t,e,i),s.constructPoints(i)}splitBezierIgnoreAttributes(e,s,i){t(0)}getAttributeAsDbl(e,s,i){return t(0),0}getClosestCoordinate(e,s){return t(0),0}getClosestCoordinateOnInterval(t,e,s){return Oo(this,t,e)}getYMonotonicParts(e,s){return t(0),0}getMonotonicParts(e,s){return t(0),0}intersectionWithAxis2D(e,s,i,n){return t(0),0}intersectionOfYMonotonicWithAxisX(e,s){return t(0),0}isCurve(){return!0}isLine(){return!1}isDegenerate(e){return t(0),!1}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(e){t(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(e,s){return t(0),new kt(0,0)}queryLooseEnvelopeOnInterval(t,e){const s=Ue(os,4);this.queryControlPoints(s),Jo(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(e,s){t(0)}tToLength(t){return Vo(this,t,!0)}lengthToT(e){return t(0),0}calculateWeightedAreaCentroid2D(e){return t(0),os.getNAN()}calculateWeightedCentroid2D(){return t(0),os.getNAN()}getControlPoint1(){return this.m_cp.clone()}setControlPoint1(t){this.m_cp.setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp),t[2].assign(this.getEndXY())}setControlPoints(e){t(0)}getTangent(e){return t(0),os.getNAN()}getDerivative(e){return t(0),os.getNAN()}getCurvature(e){return t(0),0}isIntersecting(e,s,i){return t(0),!1}isIntersectingPoint(e,s,i){return t(0),!1}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}queryAttributeAsDbl(e,s,i,n){t(0)}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(e,s){return t(0),0}normalizeAfterEndpointChange(){return t(0),!0}orientBottomUp(){t(0)}isDegenerateToLineHelper(e){return t(0),!1}copyIgnoreAttributes(e){t(0)}calculateArea2DHelper(){return t(0),0}absNorm(){return ta(this)}queryEnvelopeW(t,e){const s=Ue(os,3);this.queryControlPoints(s),Uo(s,t,e)}setSegmentFromCoords(e,s){t(0)}snapControlPoints(e){return t(0),!1}writeInBufferStream(t,e){const s=new Float64Array(2);return s[0]=this.m_cp.x,s[1]=this.m_cp.y,t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}readFromBufferStream(t,e){const s=new Float64Array(2);t.queryRange(e,s.length,s,!0,1),this.m_cp.x=s[0],this.m_cp.y=s[1],this.m_cachedValues=null}needsSnapControlPoints(e){return t(0),!1}calculateSpecialPointsForCracking(e,s){return t(0),0}ensureXYMonotone(){return t(0),!1}setCoordsForIntersector(e,s,i){t(0)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ho(e,Zo(this))}reverseImpl(){}equalsImplTol(e,s){return t(0),!1}equalsImpl(e){return t(0),!1}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){zo(this)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(e,s,i){return t(0),0}intersect_(e,s,i,n){return t(0),0}endPointModified(){zo(this)}clearEndPointModified(){t(0)}}go.type=r.enumBezier2;class po{constructor(e){return e.coefsT?(this.m_zeroCtor=e.zeroCtor,this.m_elements=e.coefsT.map((t=>t.clone())),t(this.m_elements.length===e.power+1),void this.updatePower()):e.coef0?(this.m_zeroCtor=e.zeroCtor,void(this.m_elements=[e.coef0.clone()])):e.copy?(this.m_zeroCtor=e.copy.m_zeroCtor,void(this.m_elements=e.copy.m_elements.map((t=>t.clone())))):(this.m_zeroCtor=e.zeroCtor,void(this.m_elements=[new this.m_zeroCtor]))}construct(t,e){return this.m_elements=t.map((t=>t.clone())),this.updatePower(),this}construct0(t){return this.m_elements.length=0,this.m_elements.push(t.clone()),this.updatePower(),this}assignCopy(t){return this.m_elements=t.m_elements.map((t=>t.clone())),this.updatePower(),this}assignMove(t){return this.m_elements=t.m_elements,t.m_elements=[],this.updatePower(),this}fmsThis(e,s){return t(0),this}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}addThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].addThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i];return this.updatePower(),this}add0(t){return this.m_elements[0].addThis(t),this.updatePower(),this}addNumber0(e){return t(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0(e){return t(0),this}subNumber0(e){return t(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let o=e;o<=n;++o)this.m_elements[o].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let o=n+1;o<=i;++o)this.m_elements[o].subThis(t.m_elements[r++]);return this.updatePower(),this}subShiftedWithCoef(t,e,s){const i=this.power(),n=t.power()+s,r=Math.min(this.power(),n);let o=0;for(let a=s;a<=r;++a)this.m_elements[a].fmsThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let a=i;a<this.m_elements.length;++a)this.m_elements[a]=new this.m_zeroCtor;for(let a=r+1;a<=n;++a)this.m_elements[a].subThis(t.m_elements[o++]);return this.updatePower(),this}mulThis(t){if(this.constructor===t.constructor){const e=t,s=[];for(let t=0,i=this.power();t<=i;t++)for(let n=0,r=e.power();n<=r;n++){const i=this.m_elements[t].clone();i.mulThis(e.m_elements[n]),t+n<s.length?s[t+n].addThis(i):s.push(i)}this.m_elements=s}else for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulElementThis(t){for(let e=0,s=this.power();e<=s;e++)this.m_elements[e].mulThis(t);return this.updatePower(),this}mulNumber0(e){return t(0),this}mulBigint0(e){return t(0),this}mulBigIntThis(e){return t(0),this}mulInt320(e){return t(0),this}div0(e){return t(0),this}absThis(){return t(0),this}div(t,e,s){if(this.power()<t.power())return s.assignCopy(this),void e.setZero();s.setZero(),e.setZero();const i=t.getElement(t.power()),n=this.clone();let r=n.power();const o=n.power()-t.power();let a=o;for(e.m_elements=Ue(e.m_zeroCtor,o+1);;){if(r<t.power()){s.assignMove(n);break}if(r===n.power()){const s=n.getElement(n.power());s.divThis(i),n.subShiftedWithCoef(t,s,n.power()-t.power()),e.m_elements[a]=s.clone()}a--,r--}s.updatePower(),e.updatePower()}divThis(e){return t(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let i=0;i<=e;++i)this.m_elements[i].subThis(t.m_elements[i]);const s=t.power();this.m_elements.length=Math.max(this.power(),t.power())+1;for(let i=e+1;i<=s;++i)this.m_elements[i]=t.m_elements[i].clone(),this.m_elements[i].negateThis();return this.updatePower(),this}sub0This(t){return this.m_elements[0].subThis(t),this.updatePower(),this}subFrom(e,s){t(0)}isZero(){return 0===this.power()&&this.m_elements[0].isZero()}negateThis(){for(let t=this.m_elements.length-1;t>=0;t--)this.m_elements[t].negateThis();return this}getElement(t){return this.m_elements[t].clone()}setElement(t,e){return this.m_elements[t]=e.clone(),this}evaluate(t){const e=this.power(),s=this.m_elements[e].clone();for(let i=e-1;i>=0;--i)s.mulThis(t),s.addThis(this.m_elements[i]);return s}equals(t){if(this===t)return!0;if(this.power()!==t.power())return!1;for(let e=this.m_elements.length-1;e>=0;e--)if(!this.m_elements[e].equals(t.m_elements[e]))return!1;return!0}updatePower(){for(let t=this.m_elements.length-1;t>0&&this.m_elements[t].isZero();t--)this.m_elements.pop();return this}setZero(){return this.m_elements.length=1,this.m_elements[0]=new this.m_zeroCtor,this.updatePower(),this}derivative(t){if(this.power()<t)return this.clone().setZero();if(0===t)return this.clone();const e=new this.constructor({coefsT:this.m_elements.slice(t),power:this.power()-t});for(let s=t,i=this.power();s<=i;s++){let i=BigInt(s);for(let e=s-1,n=s-t;e>n;--e)i*=BigInt(e);e.m_elements[s-t].mulBigIntThis(i)}return e.updatePower(),e}derivative1This(){if(this.m_elements.length>1){this.m_elements=this.m_elements.slice(1);for(let t=1,e=this.power();t<=e;t++)this.m_elements[t].mulThis(es.constructInt32(t+1))}else this.m_elements.length=0,this.m_elements.push(new this.m_zeroCtor);return this}limitPrecisionThis(t){for(let e=this.power();e>=0;--e)this.m_elements[e].limitPrecisionThis(t);return this.updatePower(),this}hiBitIndex(){return this.m_elements.reduce(((t,e)=>{const s=e.hiBitIndex();return t<s?s:t}),0)}shiftRight(t){return this.m_elements.splice(0,t),this.updatePower(),this}static evaluateCoefs(t,e,s){const i=t.power();s.construct0(t.getElement(0).evaluate(e));for(let n=1;n<=i;++n)s.addElement(t.getElement(n).evaluate(e));s.updatePower()}}class fo extends po{constructor(t){super(void 0===t?{zeroCtor:es}:{...t,zeroCtor:es})}clone(){return new fo({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let n=e-1;n>=0;--n)s.mulThis(i),s.addThis(this.m_elements[n].abs());return s}}class xo extends po{constructor(t){super(void 0===t?{zeroCtor:fo}:{...t,zeroCtor:fo})}clone(){return new xo({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new fo({coef0:t[s]}));return this.updatePower(),this}}function yo(){return{polypoly1:new xo,polypoly2:new xo,polyX2:new fo,polyY2:new fo,polyX2Deriv:new fo,polyY2Deriv:new fo,polypolyX1:new xo,polypolyY1:new xo,polypolyX1Deriv:new xo,polypolyY1Deriv:new xo,lazyPolypolyD1:new xo,lazyPolypolyD1Deriv:new xo,lazyPolyD2:new fo,lazyPolyD2Deriv:null,polypoly11:new xo,polypoly12:new xo,tempPp:new xo,tempPp1:new xo,tempPp2:new xo,tempP:new fo,tempP1:new fo,tempP2:new fo}}function vo(e,s,i,n,r,o,a,h,m,u,l,c,d,_,g,p,f,x=!1){const y=yo();y.polyX2.construct(a,h),y.polyY2.construct(m,u),y.polypolyX1.constructFromMPValues(e,s),y.polypolyY1.constructFromMPValues(i,n),y.polypoly11.assignCopy(y.polypolyX1),y.polypoly12.assignCopy(y.polypolyY1),l&&(y.lazyPolyD2.construct(l,c),y.polypoly11.mulElementThis(y.lazyPolyD2),y.polypoly12.mulElementThis(y.lazyPolyD2)),r?(y.lazyPolypolyD1.constructFromMPValues(r,o),y.lazyPolypolyD1Deriv=new xo({copy:y.lazyPolypolyD1}),y.lazyPolypolyD1Deriv.derivative1This(),y.tempPp.assignCopy(y.lazyPolypolyD1),y.tempPp.mulElementThis(y.polyX2),y.polypoly11.subThis(y.tempPp),y.tempPp.assignCopy(y.lazyPolypolyD1),y.tempPp.mulElementThis(y.polyY2),y.polypoly12.subThis(y.tempPp)):(y.polypoly11.sub0This(y.polyX2),y.polypoly12.sub0This(y.polyY2)),y.polypolyX1Deriv.assignCopy(y.polypolyX1),y.polypolyX1Deriv.derivative1This(),y.polypolyY1Deriv.assignCopy(y.polypolyY1),y.polypolyY1Deriv.derivative1This(),r&&(y.polypolyX1Deriv.mulThis(y.lazyPolypolyD1),y.tempPp2.assignCopy(y.lazyPolypolyD1Deriv),y.tempPp2.mulThis(y.polypolyX1),y.polypolyX1Deriv.subThis(y.tempPp2),y.polypolyY1Deriv.mulThis(y.lazyPolypolyD1),y.tempPp2.assignCopy(y.lazyPolypolyD1Deriv),y.tempPp2.mulThis(y.polypolyY1),y.polypolyY1Deriv.subThis(y.tempPp2)),y.polyX2Deriv.assignCopy(y.polyX2),y.polyX2Deriv.derivative1This(),y.polyY2Deriv.assignCopy(y.polyY2),y.polyY2Deriv.derivative1This(),l&&(t(null===y.lazyPolyD2Deriv),y.lazyPolyD2Deriv=new fo({copy:y.lazyPolyD2}),y.lazyPolyD2Deriv.derivative1This(),y.polyX2Deriv.mulThis(y.lazyPolyD2),y.tempP1.assignCopy(y.lazyPolyD2Deriv),y.tempP1.mulThis(y.polyX2),y.polyX2Deriv.subThis(y.tempP1),y.polyY2Deriv.mulThis(y.lazyPolyD2),y.tempP1.assignCopy(y.lazyPolyD2Deriv),y.tempP1.mulThis(y.polyY2),y.polyY2Deriv.subThis(y.tempP1)),y.polypoly1.assignCopy(y.polypoly11),y.polypoly1.mulElementThis(y.polyX2Deriv),y.tempPp.assignCopy(y.polypoly12),y.tempPp.mulElementThis(y.polyY2Deriv),y.polypoly1.addThis(y.tempPp),y.polypoly2.assignCopy(y.polypolyX1Deriv),y.polypoly2.mulElementThis(y.polyY2Deriv),y.tempPp.assignCopy(y.polypolyY1Deriv),y.tempPp.mulElementThis(y.polyX2Deriv),y.polypoly2.subThis(y.tempPp);let v=[];const P=[];f||(f=[]),p||(p=[]),Io(y.polypoly11,y.polypoly12,y.tempP);let b=57,C=.25*Number.EPSILON;const D=[];let S=No(y.tempP,d,g,C,b,D);if(S<0)return-1;for(let t=0;t<S;t++){fo.evaluateCoefs(y.polypoly11,es.constructDouble(D[t]),y.tempP1);const e=[];let s=No(y.tempP1,d,_,C,b,e);if(0!==s)if(fo.evaluateCoefs(y.polypoly12,es.constructDouble(D[t]),y.tempP2),s<0){s=No(y.tempP2,d,_,C,b,e),s<0&&E("mp_curve_proximity");for(let i=0;i<s;i++)P.push(q(e[i],D[t]))}else{const i=y.tempP2.absEvaluate(ss);i.mulThis(es.constructDouble(1e-12));for(let n=0;n<s;n++){const s=y.tempP2.evaluate(es.constructDouble(e[n]));s.absThis(),s.lt(i)&&P.push(q(e[n],D[t]))}}}S=P.length,Io(y.polypoly1,y.polypoly2,y.tempP),b=57,C=.25*Number.EPSILON;const w=[];let A=No(y.tempP,d,g,C,b,w);A<0&&(A=0);for(let t=0;t<A;t++){fo.evaluateCoefs(y.polypoly1,es.constructDouble(w[t]),y.tempP1);const e=[];let s=No(y.tempP1,d,_,C,b,e);if(0!==s)if(fo.evaluateCoefs(y.polypoly2,es.constructDouble(w[t]),y.tempP2),s<0){if(s=No(y.tempP2,d,_,C,b,e),s<0)continue;for(let i=0;i<s;i++)v.push(q(e[i],w[t]))}else{const i=y.tempP2.absEvaluate(ss);i.mulThis(es.constructDouble(1e-12));for(let n=0;n<s;n++){const s=y.tempP2.evaluate(es.constructDouble(e[n]));s.absThis(),s.lt(i)&&v.push(q(e[n],w[t]))}}}if(A=v.length,0===S&&0===A)return 0;v=v.concat(P),v.sort(((t,e)=>x?We(t.second,e.second):We(t.first,e.first)));const T=He(v,((t,e)=>t.first===e.first&&t.second===e.second));v=v.slice(0,T),p.length=0,f.length=0;for(const t of v)p.push(t.first),f.push(t.second);return t(p.length===f.length),f.length}function Po(t,e,s,i,n,r,o){if(0===t.power())return t.isZero()?-1:0;const a=t.evaluate(es.constructInt32(1)).isZero();if(1===t.power()){const s=Co(t.getElement(1),t.getElement(0),e,r.at(0));return r[0].limitPrecisionThis(i),1!==s?0:(r[0].limitPrecisionThis(i),1)}if(2===t.power()){return Do(t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(3===t.power()){return So(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}if(4===t.power()){return wo(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,a,r)}return Yo(t,e,s,i,a,n,r,o)}function bo(){return{polyIntersect:new fo,polyX1:new fo,polyY1:new fo,polyX1Deriv:new fo,polyY1Deriv:new fo,lazyPolyD1:new fo,lazyPolyD1Deriv:new fo,tempP:new fo,tempP1:new fo,tempP2:new fo,polypoly1Proximity:new xo,polypoly2Proximity:new xo}}function Eo(t,e,s,i,n,r,o,a,h,m,u){const l=bo();l.polyX1.construct(t,e),l.polyY1.construct(s,i),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.polyIntersect.assignCopy(l.polyX1),l.polyIntersect.mulThis(l.polyX1),l.polyIntersect.mulElementThis(o[0]),l.tempP.assignCopy(l.polyY1),l.tempP.mulThis(l.polyY1),l.tempP.mulElementThis(o[1]),l.polyIntersect.addThis(l.tempP),l.polyIntersect.add0(o[2]);{const n=o[0].clone(),r=n.clone();r.sqrThis();const a=o[1].clone(),h=a.clone();h.sqrThis();const m=o[2].clone(),u=n.clone();u.subThis(a),l.polyX1.construct(t,e),l.polyX1Deriv.assignCopy(l.polyX1),l.polyX1Deriv.derivative1This(),l.polyY1.construct(s,i),l.polyY1Deriv.assignCopy(l.polyY1),l.polyY1Deriv.derivative1This(),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(h),l.tempP.mulElementThis(m),l.polypoly1Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(a.mul(u).mul(m).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1),l.tempP.mulElementThis(n.mul(h)),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1),l.tempP1.mulElementThis(r.mul(a)),l.tempP.addThis(l.tempP1),l.tempP.add0(u.mul(u).mul(m)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulElementThis(u.mul(n).mul(a).ldexpThis(1)),l.polypoly1Proximity.addElement(l.tempP),l.tempP.construct0(n.mul(u).mul(u)),l.polypoly1Proximity.addElement(l.tempP),l.polypoly1Proximity.updatePower(),l.tempP.construct0(is),l.polypoly2Proximity.construct0(l.tempP),l.tempP.assignCopy(l.polyX1),l.tempP.mulThis(l.polyX1Deriv),l.tempP1.assignCopy(l.polyY1),l.tempP1.mulThis(l.polyY1Deriv),l.tempP.addThis(l.tempP1),l.tempP.mulElementThis(n.mul(a)),l.polypoly2Proximity.addElement(l.tempP),l.tempP.assignCopy(l.polyX1Deriv),l.tempP.mulElementThis(u.mul(n)),l.polypoly2Proximity.addElement(l.tempP),l.polypoly2Proximity.updatePower()}const c=[],d=[];u||(u=[]);let _=2*l.polyIntersect.power()+58;const g=.5*Number.EPSILON,p=No(l.polyIntersect,a,h,g,_,d);if(p<0)return-1;Io(l.polypoly1Proximity,l.polypoly2Proximity,l.tempP),_=2*l.tempP.power()+58;let f=No(l.tempP,a,h,g,_,c);if(f<0&&(f=0),0===p&&0===f)return 0;const x=c.concat(d);u.length=x.length,ze(u,x,0,0,x.length),Be(u);const y=He(u,((t,e)=>0===We(t,e)));return u.length=y,u.length}function Co(t,e,s,i){return t.isZero()?e.isZero()?-1:0:(i.setThis(e),i.negateThis(),i.divThis(t),s.isEmpty()||s.containsCoordinate(i.value())?1:0)}function Do(t,e,s,i,n,r,o){if(t.isZero()){if(r)return o[0].setInt32(1),n.containsCoordinate(1)?1:0;return Co(e,s,n,o[0])}if(r){let e=2;return o[0].setInt32(1),s.equals(t)?(o[1].setInt32(1),e=1):o[1].setThis(s.div(t)),n.containsCoordinate(o[1].value())||(e=1),n.containsCoordinate(o[0].value())||(e--,o[0].setThis(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=Ve(o[0],o[0]=o[1])),e}const a=e.clone();a.sqrThis();const h=t.clone();if(h.mulThis(s).ldexpThis(2).negateThis().addThis(a),h.LZ())return 0;const m=i+2,u=es.sqrt(h,m),l=u.clone();e.LZ()&&l.negateThis(),l.addThis(e).limitPrecisionThis(m).ldexpThis(-1).negateThis();let c=0;return o[0].setThis(l).divThis(es.constructAssign(t,m)).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[0].value()))&&c++,u.isZero()||l.isZero()||(o[c].setThis(s).divThis(l).limitPrecisionThis(i),(n.isEmpty()||n.containsCoordinate(o[c].value()))&&c++,2===c&&o[0].gt(o[1])&&(o[1]=Ve(o[0],o[0]=o[1]))),c}function So(e,s,i,n,r,o,a,h){if(e.isZero()){return Do(s,i,n,r,o,a,h)}const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=Ve(h[t],h[t]=h[s-1]),s--);e=s}return Ge(h,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let t=0;o.containsCoordinate(0)&&(h[0].setInt32(0),t=1);return m(Do(e,s,i,r,o,a,h.slice(1)),t)}if(a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const i=s.add(e),a=n.negate(),u=e.add(i).add(a).isZero();return m(Do(e,i,a,r,o,u,h.slice(t)),t)}const u=new es,l=new es,c=new es,d=s.clone();if(d.isZero())l.setThis(i),l.divThis(e),c.setThis(n),l.divThis(e);else{d.divThis(e).divDoubleThis(3).negateThis();const t=s.clone();t.sqrThis();const r=e.clone();r.sqrThis(),l.setThis(e),l.mulThis(i).mulDoubleThis(3).subThis(t).divThis(r).divDoubleThis(3),c.setThis(t),c.mulThis(s),c.ldexpThis(1),u.setThis(e),u.mulThis(s).mulThis(i).mulDoubleThis(9),c.subThis(u),u.setThis(r),u.mulThis(n).mulDoubleThis(27),c.addThis(u),c.divThis(r).divThis(e).divDoubleThis(27)}if(l.isZero()){const t=c.clone();return t.negateThis(),t.isZero()?(h[0].setThis(d),Lo(o,r,h,1)):(h[0].setThis(es.cubicRoot(c,r).add(d)),Lo(o,r,h,1))}const _=c.clone();if(_.sqrThis().ldexpThis(-2),u.setThis(l.clone()),u.sqrThis().mulThis(l).divDoubleThis(27),_.addThis(u),_.isZero())return h[0].setThis(c),h[0].mulDoubleThis(3).divThis(l),h[1].setThis(h[0]),h[1].negateThis(),h[1].ldexpThis(-1),h[0].addThis(d),h[1].addThis(d),Lo(o,r,h,2);if(_.GZ())return _.setThis(es.sqrt(_,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.addThis(_),h[0].setThis(es.cubicRoot(u,r+8)),u.setThis(c),u.ldexpThis(-1).negateThis(),u.subThis(_),h[0].addThis(es.cubicRoot(u,r+8)),h[0].addThis(d),Lo(o,r,h,1);u.setThis(l),u.divDoubleThis(3).negateThis(),t(u.GEZ());const g=es.sqrt(u,r+8),p=g.clone();p.negateThis(),p.addThis(d),g.addThis(d);const f=es.constructDouble(o.isEmpty()?-Number.MAX_VALUE:o.vmin),x=es.constructDouble(o.isEmpty()?Number.MAX_VALUE:o.vmax),y=new fo({zeroCtor:es});y.construct0(n),y.addElement(i),y.addElement(s),y.addElement(e);const v=new fo({copy:y});v.derivative1This();let P=0;const b=Ue(es,4);b[P++].setThis(f),p.gt(f)&&p.lt(x)&&b[P++].setThis(p),g.gt(f)&&g.lt(x)&&b[P++].setThis(g),b[P++].setThis(x);const E=3*r;let C=52,D=Number.EPSILON;for(;C<E;)2*C<=E?(D*=D,C*=2):(D*=Number.EPSILON,C+=52);C+=2;let S=0,w=!1;for(let t=1;t<P;t++){if(Ro(y,v,b[t-1],b[t],D,C,h[0])){S=1,w=t+1<P;break}}if(!S)return 0;if(w){const e=new fo({zeroCtor:es,coef0:h[0]});e.negateThis(),e.addElement(ss);const s=new fo({zeroCtor:es}),i=new fo({zeroCtor:es});y.div(e,s,i),t(2===s.power()),t(0===i.power());const n=Do(s.getElement(2),s.getElement(1),s.getElement(0),r,o,!1,h.slice(1));t(n>=0&&n<=2),S+=n}return Lo(o,r,h,S)}function wo(t,e,s,i,n,r,o,a,h){if(t.isZero())return So(e,s,i,n,r,o,a,h);const m=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)h[t].equals(h[0])&&(h[s-1]=Ve(h[t],h[t]=h[s-1]),s--);e=s}return Ge(h,e,((t,e)=>t.compare(e))),e};if(n.isZero()){let n=0;o.containsCoordinate(0)&&(h[0].setInt32(0),n=1);return m(So(t,e,s,i,r,o,a,h.slice(n)),n)}const u=new fo({zeroCtor:es,coef0:n});if(u.addElement(i),u.addElement(s),u.addElement(e),u.addElement(t),a){let t=0;o.containsCoordinate(1)&&(h[0].setInt32(1),t=1);const e=new fo({zeroCtor:es,coef0:es.constructInt32(-1)});e.addElement(es.constructInt32(1));const s=new fo({zeroCtor:es}),i=new fo({zeroCtor:es});u.div(e,s,i);return m(So(3===s.power()?s.getElement(3):is.clone(),s.power()>=2?s.getElement(2):is.clone(),s.power()>=1?s.getElement(1):is.clone(),s.getElement(0),r,o,s.evaluate(ss).isZero(),h.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(o.containsCoordinate(0)&&(t=1,h[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);const e=So(3===u.power()?u.getElement(3):is.clone(),u.power()>=2?u.getElement(2):is.clone(),u.power()>=1?u.getElement(1):is.clone(),u.getElement(0),r,o,!1,h.slice(t));return e>0&&(t+=e),Ge(h,t,((t,e)=>t.compare(e))),t}let l=52,c=Number.EPSILON;for(;l<r;)2*l<=r?(c*=c,l*=2):(c*=Number.EPSILON,l+=52);l+=2;const d=Xo(u),_=es.constructDouble(Math.max(Math.abs(o.vmax),Math.abs(o.vmin)));return c=(d.lt(_)?d:_).mul(es.constructDouble(c)).toDouble(),Yo(u,o,c,l,a,!1,h,4)}function Ao(t,e){let s=t,i=e;i.power()>s.power()&&(i=Ve(s,s=i));const n=s.power()-i.power(),r=new fo({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let o=0,a=s.power();o<a;o++)if(o>=n){const t=new fo({copy:i.getElement(o-n)});t.mulThis(r);const e=s.getElement(o).sub(t);s.setElement(o,e)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),To(s)}function To(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Io(t,e,s){const i=t.clone(),n=e.clone();for(To(i),To(n);0!==i.power()||0!==n.power();)Ao(i,n);s.assignMove(i.getElement(0))}function No(t,e,s,i,n,r){r.length=0;const o=t.power(),a=Ue(es,2*o+4),h=Po(t,s||kt.unit(),i,n,!1,a,a.length);if(h>0){r.length=0;for(let t=0;t<h;t++){const e=a[t].value();t>0&&e<=r.at(-1)||r.push(e)}return r.length}return h}function Mo(e,s,i){if(t(i>=1),0===e.power())return e.isZero()?-1:0;const n=e.getElement(0);return n.negateThis(),n.divThis(e.getElement(1)),s[0].setThis(n),1}function qo(e,s,i,n){if(e.power()<2)return Mo(e,i,n);t(n>=1);let r=e.getElement(1);r.mulThis(e.getElement(1));const o=e.getElement(0);if(o.mulThis(e.getElement(2)),o.ldexpThis(2),r.subThis(o),r.LZ())return 0;if(r.isZero()){const t=e.getElement(1);return t.negateThis(),t.divThis(e.getElement(2)),t.ldexpThis(-1),t.limitPrecisionThis(s),i[0].setThis(t),1}t(n>=2),r=es.sqrt(r,s+8);const a=e.getElement(1);a.negateThis();const h=a.clone();h.subThis(r),h.divThis(e.getElement(2)),h.ldexpThis(-1),h.limitPrecisionThis(s);const m=a.clone();return m.addThis(r),m.divThis(e.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(s),h.lt(m)?(i[0].setThis(h),i[1].setThis(m)):(i[1].setThis(h),i[0].setThis(m)),2}function Ro(t,e,s,i,n,r,o){let a=s.clone(),h=i.clone();a.limitPrecisionThis(r),h.limitPrecisionThis(r);let m=t.evaluate(a);m.limitPrecisionThis(r+2);let u=t.evaluate(h);if(u.limitPrecisionThis(r+2),m.GEZ()&&u.GEZ()||m.LEZ()&&u.LEZ())return m.absLessAbs(u)?(o=a,m.isZero()):(o=h,u.isZero());const l=u.LZ();l&&(u=Ve(m,m=u),h=Ve(a,a=h));const c=l?h:a,d=l?a:h,_=a.add(h).ldexpThis(-1);_.limitPrecisionThis(r);const g=h.sub(a);g.limitPrecisionThis(r),g.absThis();const p=g.clone();let f=t.evaluate(_),x=e.evaluate(_);const y=new fo({copy:t}),v=new fo({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=ss.clone();i.ldexpThis(-(r+2));for(let n=64;n<s;){y.limitPrecisionThis(n),v.limitPrecisionThis(n);const r=y.evaluate(_),o=v.evaluate(_),a=r.sub(f),h=o.sub(x);if(a.divThis(f).absThis().lt(i)&&(x.isZero()||h.divThis(x).absThis().lt(i)))break;y.assignCopy(t),v.assignCopy(e),n=Math.min(n+64,s)}f.limitPrecisionThis(r+2),x.limitPrecisionThis(r+2)}const P=1,b=4;let C=b;const D=2;let S=1,w=0,A=0,T=P;const I=32,N=es.constructDouble(.25*n),M=es.constructDouble(.5001);let q=0;const R=300;for(;++q<R;){if(q>I&&w>0||x.isZero()||T===D&&w>1||T===P&&C<b)T=P,S>1&&S--;else if(T=D,A>1){const t=g.mul(x);t.absThis(),t.ldexpThis(-3),t.absLessAbs(f)&&S++}g.setThis(p);const t=new es;let e=!1;if(T===P)do{if(A>2){const e=g.clone();if(e.absThis(),e.ldexpThis(4),d.sub(c).ldexpThis(-1).gt(e)){if(_.equals(c)){t.setThis(_),_.setThis(c.add(e)),_.limitPrecisionThis(r),p.setThis(_.sub(t));break}if(_.equals(d)){t.setThis(_),_.setThis(d.sub(e)),_.limitPrecisionThis(r),p.setThis(_.sub(t));break}}}p.setThis(h.sub(a)),p.ldexpThis(-1),p.limitPrecisionThis(r),t.setThis(_),_.setThis(a.add(p)),_.limitPrecisionThis(r),_.lt(c)?_.setThis(c):_.gt(d)&&_.setThis(d),e=a.equals(_)||h.equals(_)}while(0);else for(;;){if(p.setThis(f.div(x)),p.limitPrecisionThis(r),1!==S&&p.mulDoubleThis(S),t.setThis(_),_.subThis(p),_.limitPrecisionThis(r),e=_.equals(t),_.lt(c)){if(S>1){_.setThis(t),S--;continue}p.setThis(t.sub(c)),_.setThis(c)}else if(_.gt(d)){if(S>1){_.setThis(t),S--;continue}p.setThis(t.sub(d)),_.setThis(d)}break}if(e||p.absLessAbs(N)){t.equals(_)||(f=y.evaluate(_),f.limitPrecisionThis(r+2));break}f=y.evaluate(_),f.limitPrecisionThis(r+2),x=v.evaluate(_),x.limitPrecisionThis(r+2);const s=a.clone(),i=h.clone();f.LZ()?(m.setThis(f),a.setThis(_)):(u.setThis(f),h.setThis(_)),T===D&&(a.equals(s)&&h.equals(i)||A>1&&!p.absLessAbs(M.mul(g)))?w++:w=0,T===P?(C++,A=0):(C=0,A++)}return q>=R&&E("Root_finder iterations exceeded"),o.setThis(_),!0}function Fo(t,e,s,i,n){const r=t.evaluate(s);if(r.isZero())return!0;const o=es.constructDouble(.5*i),a=s.clone();a.subThis(o);const h=t.evaluate(a),m=s.clone();m.addThis(o);const u=t.evaluate(m);if(h.LZ()&&u.GZ()||h.GZ()&&u.LZ())return!0;if(r.GZ()?h.LEZ()||u.LEZ():h.GEZ()||u.GEZ())return!0;const l=h.LEZ()&&u.LEZ(),c=h.GEZ()&&u.GEZ();let d=!1;return l?r.gt(h)&&r.gt(u)&&(d=!0):c&&r.lt(h)&&r.lt(u)&&(d=!0),!!d&&r.absThis().lt(es.constructDouble(1e-17))}function Yo(e,s,i,n,r,o,a,h){t(i>0),t(h>=e.power());const m=a,u=[];let l=[];const c=new fo({zeroCtor:e.m_zeroCtor}),d=new fo({zeroCtor:e.m_zeroCtor}),_=new fo({zeroCtor:e.m_zeroCtor}),g=es.constructDouble(i),p=es.constructDouble(s.vmin),f=es.constructDouble(s.vmax),x=p.sub(g),y=f.add(g),v=Xo(e),P=v.clone();if(P.negateThis(),x.lt(P))x.setThis(P.sub(g));else if(x.gt(v))return 0;if(y.gt(v))y.setThis(v.add(g));else if(y.lt(P))return 0;let b=e,E=null;if(r){const t=new fo({coef0:es.constructInt32(-1)});t.addElement(ss),E=new fo,b=E;const s=new fo,i=new fo;for(e.div(t,s,i),E.assignCopy(s);b.evaluate(ss).isZero();)b.div(t,s,i),E.assignCopy(s)}let C=!1;if(b.power()>0&&b.getElement(0).isZero())for(C=!0,E||(E=new fo({copy:b}),b=E);b.getElement(0).isZero();)E.shiftRight(1);let D=n+2*b.power()+2,S=i/Math.pow(2,b.power()+2),w=D;if(is.gt(x)&&is.lt(y))for(let t=0,M=b.power();t<M;t++)if(b.getElement(t).isZero()){u.push(is.clone());break}for(let M=b.power()-1;M>0;M--)if(S*=2,D-=2,w-=2,b.power()-M!=1)if(b.power()-M!=2){d.assignMove(_),_.assignMove(b.derivative(M-1));let t=[];for(let e=0,s=l.length;e<s;++e)if(l[e].first.lte(l[e].second)){const s=new es;if(Ro(d,c,l[e].first,l[e].second,S,D,s)){u.push(s);let i=s.sub(g);i.limitPrecisionThis(w),t.push(q(l[e].first,i)),i=s.add(g),i.limitPrecisionThis(w),t.push(q(i,l[e].second))}else t.push(l[e])}l=t,t=[],c.assignMove(d)}else{d.assignMove(b.derivative(M));const e=qo(d,D,m,h);t(e>=0&&e<=2);for(let t=0;t<e;t++)m[t].gt(x)&&m[t].lt(y)&&!m[t].isZero()&&u.push(m[t].clone());if(u.length>1&&u.sort(((t,e)=>t.compare(e))),u.length>0){let t=u[0].sub(g);t.limitPrecisionThis(w),l.push(q(x.clone(),t));let e=1===u.length?y.clone():u[1].sub(g);t=u[0].add(g),t.limitPrecisionThis(w),e.limitPrecisionThis(w),l.push(q(t,e)),u.length>1&&(e=2===u.length?y.clone():u[2].sub(g),e.limitPrecisionThis(w),t=u[1].add(g),t.limitPrecisionThis(w),l.push(q(t,e)),u.length>2&&(t=u[2].add(g),t.limitPrecisionThis(w),l.push(q(t,y.clone()))))}else l.push(q(x.clone(),y.clone()));c.assignCopy(d),_.assignMove(b.derivative(M-1))}else{d.assignMove(b.derivative(M));1===Mo(d,m,h)&&(m[0].gt(x)&&m[0].lt(y)&&!m[0].isZero()&&u.push(m[0].clone()),c.assignMove(d),_.assignMove(b.derivative(M-1)))}u.sort(((t,e)=>t.compare(e))),0===l.length&&(c.assignMove(b.derivative(b.power())),c.isZero()||l.push(q(x.clone(),y.clone())));let A=0,T=0,I=0;const N=new es;for(;;){if(T<l.length){if(l[T].first.gt(l[T].second)){T++;continue}let t=!1;if(I<u.length&&u[I].lt(l[T].first)&&(t=!0),!t){Ro(b,c,l[T].first,l[T].second,i,n,N)&&(N.lt(p)?m[A++].setThis(p):N.gt(f)?m[A++].setThis(f):m[A++].setThis(N)),T++;continue}}if(!(I<u.length))break;0!==I&&u[I-1].equals(u[I])||Fo(b,c,u[I],i)&&(N.setThis(u[I]),N.lt(p)?N.setThis(p):N.gt(f)&&N.setThis(f),0!==A&&m[A].equals(N)||m[A++].setThis(N)),I++}return C&&is.gt(x)&&is.lt(y)&&(m[A++].setThis(is),Ge(m,A,((t,e)=>t.compare(e)))),r&&ss.gt(x)&&ss.lt(y)&&(m[A++].setThis(ss),Ge(m,A,((t,e)=>t.compare(e)))),A}function Xo(t){const e=t.getElement(t.power());e.limitPrecisionThis(53);const s=is.clone();for(let i=0,n=t.power();i<n;i++){const n=t.getElement(i);n.limitPrecisionThis(53),n.divThis(e).absThis(),n.gt(s)&&s.setThis(n)}return s.addThis(ss),s.mulThis(es.constructDouble(1+100*Number.EPSILON)),s}function Lo(t,e,s,i){let n=i;if(!t.isEmpty()){n=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(n!==e&&s[n].setThis(s[e]),n++)}n>1&&(s[0].gt(s[1])&&(s[1]=Ve(s[0],s[0]=s[1])),n>2&&(s[0].gt(s[2])&&(s[2]=Ve(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=Ve(s[1],s[1]=s[2]))));for(let r=0;r<n;++r)s[r].limitPrecisionThis(e);return n}function zo(t){t.m_cachedValues=null}function Vo(t,e,s){const i=Ue(os,3);return t.queryControlPoints(i),Bo(i,e,s)}function Bo(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Bo(t,1,!1)}if(1===e)return ko(t);const i=Ue(os,3);return $o(t,e,i,null),ko(i)}function ko(e){if(e[0].equals(e[1]))return os.distance(e[2],e[0]);if(e[1].equals(e[2]))return os.distance(e[0],e[2]);const s=os.distance(e[0],e[1])+os.distance(e[2],e[1]),i=os.distance(e[0],e[2]);if(s-i<=s*Number.EPSILON)return i;const n=1,r=Ue(os,3);aa(e,r,!0);const o=4*(ce(r[2].x)+ce(r[2].y)),a=2*(r[2].x*r[1].x+r[2].y*r[1].y),h=ce(r[1].x)+ce(r[1].y);if(1e-14*(Math.abs(a)+Math.abs(h))>=Math.abs(o)){if(1e-14*Math.abs(h)>=Math.abs(a)){return Math.sqrt(h)*n}t(0);return 2/(3*a)*(Math.pow(a*n+h,1.5)-Math.pow(h,1.5))}const m=a/o,u=h/o,l=u-m*m,c=n+m;if(0===l){if(m>=0&&c>=0||m<=0&&c<=0){return Math.abs(.5*Math.sqrt(o)*(c*c-m*m))}return.5*Math.sqrt(o)*(c*c+m*m)}const d=Math.sqrt(l+c*c),_=Math.sqrt(u);return.5*Math.sqrt(o)*(c*d-m*_+l*Math.log(Math.abs((c+d)/(m+_))))}function Go(e,s){return t(0),os.getNAN()}function Wo(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Zo(t){return t.m_cachedValues}function Ho(t,e){t.m_cachedValues=e}function Oo(t,e,s,i,n){N(kt.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const r=Ue(os,3);t.queryControlPoints(r);let o=Number.MAX_VALUE;const a=[0],h=jo(r,e,a);if(s.containsCoordinate(a[0]))o=os.distance(e,h);else{a[0]=s.vmin,ma(r,a[0],h),o=os.distance(h,e);const t=new os;ma(r,s.vmax,t);const i=os.distance(t,e);o>i&&(h.setCoordsPoint2D(t),a[0]=s.vmax,o=i)}return a[0]}function jo(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),n=t[1].sub(t[0]),r=t[0].sub(e),o=r.dotProduct(n),a=r.dotProduct(i)+2*n.dotProduct(n),h=3*n.dotProduct(i),m=i.dotProduct(i),u=new Array(3),l=wr(m,h,a,o,kt.unit(),!1,u),c=t[0].clone();let d=0,_=os.sqrDistance(t[0],e),g=os.sqrDistance(t[2],e);g<_&&(d=1,c.assign(t[2]),_=g);for(let p=0;p<l;p++){const s=new os;ma(t,u[p],s),g=os.sqrDistance(s,e),g<_&&(_=g,c.assign(s),d=u[p])}return s&&(s[0]=d),c}function Uo(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=Ue(os,3);Jo(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function Qo(e,s,i){t(0)}function Ko(t){let e=!1;for(let s=0;s<2;s++){const i=j(t[0][s],t[2][s]);i>0?(j(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(j(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function $o(t,e,s,i){(new os).setCoordsPoint2D(t[0]);(new os).setCoordsPoint2D(t[1]);(new os).setCoordsPoint2D(t[2]);const n=new os,r=new os,o=new os;if(le(t[0],t[1],e,n),le(t[1],t[2],e,r),le(n,r,e,o),s&&(s[0].assign(t[0]),s[1].assign(n),s[2].assign(o)),i){const e=t[2];i[0].assign(o),i[1].assign(r),i[2].assign(e)}}function Jo(t,e,s,i){if(e===s){const s=new os;return ma(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const n=Ue(os,3);$o(t,s,n,null),$o(n,e/s,null,n),ma(t,e,n[0]),ma(t,s,n[2]),i[0].setCoordsPoint2D(n[0]),i[1].setCoordsPoint2D(n[1]),i[2].setCoordsPoint2D(n[2])}function ta(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1)}function ea(e,s,i,n,r){return t(0),0}function sa(e,s,i,n,r){return t(0),0}function ia(e,s,i,n,r){return t(0),0}function na(e,s,i,n,r,o,a,h,m,u){return t(0),0}function ra(t,e,s,i,n,r,o,a,h,m){if(em(s))return new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),na();const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=Ue(os,3);{e.queryControlPoints(d);const t=Ue(os,3),i=new cn;s.canonicToWorldTransformation(i);const n=new cn;n.setInvert(i),n.transformPoints(d,3,t);const r=Ue(es,3),a=Ue(es,3);ha(t,r,a);const h=Ue(es,3);h[0].setDouble(s.getSemiMinorAxis()),h[0].sqrThis(),h[1].setDouble(s.getSemiMajorAxis()),h[1].sqrThis(),h[2]=h[0],h[2].mul(h[1]),h[2].negate();const m=Eo(r,2,a,2,null,0,h,!0,kt.unit(),kt.unit(),l);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new os;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new os;s.queryCoord2D(r,a),os.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const _=[0,1];for(let g=0;g<2;g++){const t=0===g?s.getStartXY():s.getEndXY(),e=[0];jo(d,t,e);const i=new os;ma(d,e[0],i),os.distance(t,i)<=o&&(l.push(e[0]),c.push(_[g]))}for(let g=0;g<2;g++){const t=[0,2];{const e=s.getClosestCoordinate(d[t[g]],!1),i=new os;s.queryCoord2D(e,i),os.distance(d[t[g]],i)<=o&&(l.push(_[g]),c.push(e))}}return dl(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function oa(t,e,s,i,n,r,o,a,h,m){const u=Ue(os,3);e.queryControlPoints(u);const l=Ue(os,3);if(s.queryControlPoints(l),Ji(u,l,3)<0)return oa(t,s,e,i,r,n,o,a,h,!m);const c=Ki(e,s);if($i(e,s,o=Math.max(o,c)))return 0;if(da(e,s,i,n,r,o,a,h,m))return 2;const d=new kt(0,1),_=new kt(0,1);{const t=new Di;Uo(u,kt.unit(),t);const e=new Di;Uo(l,kt.unit(),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Qo(),Qo(),d.isEmpty()||_.isEmpty())return 0;Jo(u,d.vmin,d.vmax,u),Jo(l,_.vmin,_.vmax,l)}}const g=gl(u,2,l,2,o);if(0===g)return 0;const p=[],f=[];if(-1===g){const t=Ue(es,3),e=Ue(es,3);ha(u,t,e);const s=Ue(es,3),i=Ue(es,3);ha(l,s,i);const n=vo(t,2,e,2,null,0,s,2,i,2,null,0,!0,kt.unit(),kt.unit(),p,f,m);if(n>0){let t=0;for(let e=0;e<n;e++){const s=new os,i=new os;ma(l,f[e],i),ma(u,p[e],s),os.distance(s,i)<=o&&(p[t]=p[e],f[t]=f[e],t++)}p.length=t,f.length=t}}for(let x=0;x<2;x++){const t=0===x?u:l,e=0===x?l:u;for(let s=0;s<2;s++){const i=0===s?0:2,n=[0];jo(e,t[i],n);const r=new os;ma(e,n[0],r),os.distance(t[i],r)<=o&&(0===x?(p.push(0===i?0:1),f.push(n[0])):(f.push(0===i?0:1),p.push(n[0])))}}if(0===p.length)return 0;if(!d.equalsRange(0,1))for(let x=0;x<p.length;++x)p[x]=go.recalculateParentT(d.vmin,d.vmax,p[x]);if(!_.equalsRange(0,1))for(let x=0;x<f.length;++x)f[x]=go.recalculateParentT(_.vmin,_.vmax,f[x]);return dl(t,e,s,p,f,p.length,i,n,r,o,a,h,m)}function aa(t,e,s=!1){const i=t[1].sub(t[0]);e[1].assign(i.mul(2)),e[2].assign(t[2].sub(t[1]).sub(i)),s?e[0].setCoords(0,0):e[0].assign(t[0])}function ha(t,e,s){e[0].setDouble(t[0].x),e[1].setDouble(t[1].x),e[1].subThis(e[0]),e[1].ldexpThis(1),e[2].setThis(e[0]),e[2].addDoubleThis(t[2].x),e[2].subThis(es.constructDouble(t[1].x).ldexpThis(1)),s[0].setDouble(t[0].y),s[1].setDouble(t[1].y),s[1].subThis(s[0]),s[1].ldexpThis(1),s[2].setThis(s[0]),s[2].addDoubleThis(t[2].y),s[2].subThis(es.constructDouble(t[1].y).ldexpThis(1))}function ma(t,e,s,i){if(i){if(e<0){return void On(new fl({pt1:t[0],pt2:t[0].add(Go().getUnitVector())}),e,s)}if(e>1){return void On(new fl({pt1:t[2],pt2:t[2].add(Go().getUnitVector())}),e-1,s)}}if(e<=.5){const i=t[1].clone(),n=new os;ee(2,t[0],i,e,n);const r=new os;ee(2,i,t[2],e,r);const o=new os;ee(2,n,r,e,o),s.assign(o)}else{const i=t[1].clone(),n=new os;se(2,t[0],i,e,n);const r=new os;se(2,i,t[2],e,r);const o=new os;se(2,n,r,e,o),s.assign(o)}}function ua(e,s,i){t(0)}function la(e,s,i){t(0)}function ca(t,e){e[0].assign(t[0]),e[3].assign(t[2]),le(t[0],t[1],2/3,e[1]),le(t[1],t[2],1/3,e[2])}function da(t,e,s,i,n,r,o,a,h){const m=Ue(os,3);t.queryControlPoints(m);const u=Ue(os,3);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2]))return s&&(s.length=0,s.push(m[0]),s.push(m[2])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[2]))return!1}return!!(m[0].equals(u[2])&&m[1].equals(u[1])&&m[2].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=Ve(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=Ve(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[2]),h&&(s[1]=Ve(s[0],s[0]=s[1]))),!0)}const _a=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],ga=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],pa=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],fa=[[.04830766568773832,.0965400885147278],[.1444719615827965,.09563872007927486],[.23928736225213706,.09384439908080457],[.33186860228212767,.09117387869576389],[.42135127613063533,.08765209300440381],[.5068999089322294,.08331192422694675],[.5877157572407623,.07819389578707031],[.6630442669302152,.0723457941088485],[.7321821187402897,.06582222277636185],[.7944837959679424,.058684093478535544],[.84936761373257,.050998059262376175],[.8963211557660521,.04283589802222668],[.9349060759377397,.03427386291302143],[.9647622555875064,.02539206530926206],[.9856115115452684,.01627439473090567],[.9972638618494816,.007018610009470096]],xa=[[.024350292663424433,.048690957009139724],[.07299312178779904,.04857546744150343],[.12146281929612056,.048344762234802954],[.16964442042399283,.04799938859645831],[.21742364374000708,.04754016571483031],[.2646871622087674,.04696818281621002],[.31132287199021097,.046284796581314416],[.3572201583376681,.04549162792741814],[.4022701579639916,.044590558163756566],[.4463660172534641,.04358372452932345],[.48940314570705296,.04247351512365359],[.5312794640198946,.04126256324262353],[.571895646202634,.03995374113272034],[.6111553551723933,.038550153178615626],[.6489654712546573,.03705512854024005],[.6852363130542333,.035472213256882386],[.7198818501716109,.033805161837141606],[.7528199072605319,.03205792835485155],[.7839723589433414,.030234657072402478],[.8132653151227975,.028339672614259483],[.8406292962525803,.02637746971505466],[.8659993981540928,.024352702568710874],[.8893154459951141,.022270173808383253],[.9105221370785028,.02013482315353021],[.9295691721319396,.017951715775697343],[.9464113748584028,.015726030476024718],[.9610087996520538,.013463047896718643],[.973326827789911,.011168139460131128],[.983336253884626,.008846759826363947],[.9910133714767443,.006504457968978363],[.9963401167719553,.004147033260562468],[.9993050417357722,.001783280721696433]],ya=[[.012223698960615764,.024446180196262518],[.03666379096873349,.024431569097850044],[.06108196960413957,.02440235563384958],[.08546364050451549,.024358557264690626],[.10979423112764375,.024300200167971867],[.13405919946118777,.02422731922281525],[.15824404271422493,.024139957989019287],[.18233430598533718,.024038168681024052],[.2063155909020792,.023922012136703457],[.23017356422666,.023791557781003402],[.2538939664226943,.023646883584447616],[.2774626201779044,.02348807601653591],[.3008654388776772,.02331522999406276],[.32408843502441337,.023128448824387027],[.3471177285976355,.022927844143686846],[.369939555349859,.02271353585023646],[.39254027503326744,.022485652032744968],[.414906379552275,.022244328893799764],[.43702450103710416,.02198971066846049],[.4588814198335522,.021721949538052076],[.48046407240417205,.02144120553920846],[.5017595591361445,.02114764646822135],[.5227551520511755,.02084144778075115],[.5434383024128103,.02052279248696007],[.5637966482266181,.020191871042130043],[.5838180216287631,.01984888123283086],[.6034904561585486,.019494028058706602],[.6228021939105849,.019127523609950944],[.6417416925623075,.01874958694054471],[.660297632272646,.01836044393733134],[.6784589224477192,.017960327185008687],[.6962147083695144,.017549475827117706],[.7135543776835874,.01712813542311138],[.7304675667419088,.016696557801589205],[.746944166797062,.016255000909785187],[.7629743300440948,.015803728659399347],[.7785484755064119,.015343010768865144],[.7936572947621933,.014873122602147314],[.8082917575079137,.014394345004166847],[.8224431169556439,.013906964132951985],[.8361029150609068,.013411271288616333],[.8492629875779689,.012907562739267348],[.8619154689395485,.012396139543950923],[.8740527969580318,.01187730737274028],[.8856677173453972,.011351376324080417],[.8967532880491582,.010818660739503076],[.9073028834017568,.010279479015832158],[.9173101980809605,.009734153415006806],[.9267692508789478,.009183009871660874],[.9356743882779164,.00862637779861675],[.9440202878302202,.008064589890486059],[.9518019613412644,.0074979819256347285],[.9590147578536999,.006926892566898814],[.9656543664319652,.006351663161707189],[.9717168187471366,.005772637542865698],[.9771984914639074,.00519016183267633],[.9820961084357185,.004604584256702955],[.9864067427245862,.004016254983738642],[.9901278184917344,.0034255260409102157],[.9932571129002129,.0028327514714579912],[.9957927585349812,.0022382884309626186],[.997733248625514,.0016425030186690294],[.9990774599773758,.0010458126793403489],[.9998248879471319,.00044938096029209035]];function va(t,e,s,i){const n=.5*(i-s),r=s+n,o=new At(0);for(let a=0,h=t/2;a<h;++a){let s,i;switch(t){case 4:s=_a[a][0],i=_a[a][1];break;case 8:s=ga[a][0],i=ga[a][1];break;case 16:s=pa[a][0],i=pa[a][1];break;case 32:s=fa[a][0],i=fa[a][1];break;case 64:s=xa[a][0],i=xa[a][1];break;case 128:s=ya[a][0],i=ya[a][1];break;default:throw new Error("Quadrature_integral: invalid n")}const h=xe(-n,s,r),m=xe(n,s,r);o.pe(e(h)*i),o.pe(e(m)*i)}return o.getResult()*n}class Pa{constructor(){this.length=Number.NaN,this.area=Number.NaN,this.centroidX=Number.NaN,this.centroidY=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}function ba(e,s,i,n,r,o,a,h){for(;;){const m=os.distance(s[0],s[2]),u=os.distance(s[0],s[1])+os.distance(s[1],s[2]);if(u-m<=r+n*u)return e+he(m,u,.5);const l=Ue(os,4),c=t=>{Ia(s,i,1,t,l);return l[1].length()};if(0===a&&h<8){t(h<8);let m=c(0),l=c(1);o[0]+=2,m>l&&(l=Ve(m,m=l),s[2]=Ve(s[0],s[0]=s[2]),i[2]=Ve(i[0],i[0]=i[2]));let d=m/(m+l),_=1,g=u;for(;d<1/32&&g>=r+n*g;){_/=4;const t=c(_);o[0]++,d=m/(t+m);const e=new os;if(Eh(s,i,.5*_,e),g=os.distance(e,s[0]),g<=r){const t=new os;Eh(s,i,_,t),g+=os.distance(t,e)}}if(1!==_){const t=Ue(os,3),m=[0,0,0];nh(s,i,_,s,i,t,m),e=ba(e,t,m,n,r,o,0,h+1),a++,h++;continue}}let d=!1;const _=8;o[0]+=_;const g=va(_,c,0,1),p=16;o[0]+=p;const f=va(p,c,0,1);if(d=Math.abs(g-f)>r+n*u,!d)return e+f;if(a<8&&h<9){const t=Ue(os,3),m=[0,0,0];nh(s,i,.5,s,i,t,m),e=ba(e,t,m,n,r,o,a+1,h+1),a++,h++;continue}const x=32;o[0]+=x;const y=va(x,c,0,1);if(d=Math.abs(f-y)>r+n*u,!d)return e+y;const v=64;o[0]+=v;const P=va(v,c,0,1);if(d=Math.abs(y-P)>r+n*u,!d)return e+P;const b=128;o[0]+=b;const E=va(b,c,0,1);return d=Math.abs(P-E)>r+n*u,e+E}}function Ea(t,e,s,i,n){if(s===e)return 0;const r=Ue(os,3),o=[0,0,0];t.queryControlPoints(r),t.queryWeights(o);const a=[0,0,0],h=Ue(os,3);rh(r,o,e,s,h,a);return ba(0,h,a,i,n,[0],0,0)}let Ca=class{constructor(t,e,s){this.controlPoints=Qe(t,3),this.weights=[0,0,0],ze(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new os;Eh(this.controlPoints,this.weights,e,t);const s=Ue(os,4);Ia(this.controlPoints,this.weights,1,e,s);return 2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new os;Eh(this.controlPoints,this.weights,e,t);const s=Ue(os,4);Ia(this.controlPoints,this.weights,2,e,s);return 2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new os;Eh(this.controlPoints,this.weights,e,t);const s=Ue(os,4);Ia(this.controlPoints,this.weights,3,e,s);return 2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(e){return t(0),0}};function Da(t,e,s,i){const n=Ka(0,0,0,0,os.getNAN()),r=new Array(18),o=Ue(os,3);t.queryControlPoints(o),o[2].subThis(e),o[1].subThis(e),o[0].subThis(e);const a=[0,0,0];t.queryWeights(a);const h=[1,Dh(a),1],m=wh(a,s),u=wh(a,i),l=Dr(new Ca(o,h,new os(0,0)),kt.construct(m,u),18,r);Eh(o,h,m,n.pt),n.t=m,n.d=os.distance(n.pt,new os(0,0));const c=new os;Eh(o,h,u,c);const d=os.distance(c,new os(0,0));d<n.d&&(n.d=d,n.t=u,n.pt.assign(c));for(let _=0;_<l;_++){Eh(o,h,r[_],c);const t=os.distance(c,new os(0,0));t<n.d&&(n.d=t,n.t=Sh(a,r[_]),n.pt.assign(c))}return n}function Sa(t){t.m_cachedValues=null}function wa(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Pa,s=Ue(os,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),Aa(s,i,e.specialPoints),ja(t,e),e}function Aa(t,e,s){if(0===e[1])return s.length=2,s[0]=0,void(s[1]=1);const i=Ue(Wt,8);i[0].set(0);let n=1;{const s=new Wt(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),r=new Wt(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new Wt(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=Ue(Wt,2);let h=Yr(o,r,s,new kt(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)vt(a[t].value(),0,1)||(i[n]=a[t],n++)}{const s=new Wt(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),r=new Wt(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),o=s.subE(r).addThisE(new Wt(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));r.subThisE(s.mul(2));const a=Ue(Wt,2);let h=Yr(o,r,s,new kt(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)vt(a[t].value(),0,1)||(i[n]=a[t],n++)}if(i[n].set(1),n++,n>2){Ge(i,n,((t,e)=>We(t.value(),e.value())));let t=0,e=i[0].value(),s=1;for(let r=1;r<n;r++)i[r].eq(i[r-1])?(e+=i[r].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[r],e=i[r].value(),s=1);t++,n=t}i[0].set(0),i[n-1].set(1),s.length=n;for(let r=0;r<n;r++)s[r]=i[r].value()}function Ta(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Ta(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=wa(t);if(i&&!Number.isNaN(n.length))return n.length;const r=Za(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=Ea(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function Ia(t,e,s,i,n){const r=[t[0],t[1],t[2]],o=[e[0],e[1],e[2]],a=Ue(os,4);Na(r,o,s,i,a);for(let h=0;h<=s;h++)n[h].setCoords(a[h].x,a[h].y)}function Na(e,s,i,n,r){t(i>0);const o=[e[0].clone(),e[1].clone(),e[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThis(o[0]);o[0].setCoords(0,0)}const a=Ma(o,s,0,n),h=Ra(s,0,n),m=a.divide(h);if(r[0].assign(m),0===i)return;const u=[s[1]*s[0],s[2]*s[0]*.5,s[1]*s[2]],l=[e[1].sub(e[0]),e[2].sub(e[0]),e[2].sub(e[1])],c=h*h,d=Ma(l,u,0,n).mul(2).divide(c);if(r[1].assign(d),1===i)return;const _=Ra(s,1,n),g=2*h*_,p=Ma(l,u,1,n).mul(2).sub(d.mul(g)).divide(c);if(r[2].assign(p),2===i)return;const f=Ma(l,u,2,n).mul(2),x=2*(_*_+h*Ra(s,2,n)),y=f.sub(p.mul(g).mul(2)).sub(d.mul(x)).divide(c);r[3].assign(y),3!==i&&E("")}function Ma(t,e,s,i){if(0===s){if(i<=.5){const s=new os;ee(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new os;ee(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new os;return ee(2,s,n,i,r),r}{const s=new os;se(2,t[0].mul(e[0]),t[1].mul(e[1]),i,s);const n=new os;se(2,t[1].mul(e[1]),t[2].mul(e[2]),i,n);const r=new os;return se(2,s,n,i,r),r}}if(1===s){const s=t[1].mul(e[1]),n=s.sub(t[0].mul(e[0])).mul(1-i).add(t[2].mul(e[2]).sub(s).mul(i));return n.mulThis(2),n}if(2===s){const s=t[1].mul(e[1]),i=t[2].mul(e[2]).sub(s).sub(s.sub(t[0].mul(e[0])));return i.mulThis(2),i}E("")}function qa(t,e,s,i){if(i.toDouble()<=.5){const s=new Ai;oe(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ai;oe(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ai;return oe(2,s,n,i,r),r}{const s=new Ai;ae(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const n=new Ai;ae(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,n);const r=new Ai;return ae(2,s,n,i,r),r}}function Ra(t,e,s){if(0===e){const e=he(t[0],t[1],s),i=he(t[1],t[2],s);return he(e,i,s)}if(1===e){return 2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s)}if(2===e){return 2*(t[2]-t[1]-(t[1]-t[0]))}E("")}function Fa(t,e,s){if(s.toDouble()<=.5){const e=$t(t[0],t[1],s),i=$t(t[1],t[2],s);return $t(e,i,s)}{const e=Jt(t[0],t[1],s),i=Jt(t[1],t[2],s);return Jt(e,i,s)}}function Ya(t,e,s,i,n){const r=[Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2])];r[2].subThisE(r[0]),r[1].subThisE(r[0]),r[0].setCoords(0,0);Xa(r,[new Wt(e[0]),new Wt(e[1]),new Wt(e[2])],s,i,n)}function Xa(e,s,i,n,r){t(i>0);const o=[e[0].clone(),e[1].clone(),e[2].clone()];if(!o[0].isZero()){for(let t=1;t<3;++t)o[t].subThisE(o[0]);o[0]=Ai.constructCoords(0,0)}const a=qa(o,s,0,n),h=Fa(s,0,n),m=a.divE(h);r[0].setE(m);const u=[s[1].mulE(s[0]),s[2].mulE(s[0]).mul(.5),s[1].mulE(s[2])],l=qa([e[1].subE(e[0]),e[2].subE(e[0]),e[2].subE(e[1])],u,0,n).mul(2),c=h.sqr(),d=l.divE(c);r[1].setE(d)}function La(t,e,s){const i=Ue(os,3);t.queryControlPoints(i);const n=new Array(3);t.queryWeights(n),za(i,n,e,s)}function za(t,e,s,i){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const n=Ue(Ai,4);Ya(t,e,1,s,n),i.setE(n[1])}function Va(t,e,s){const i=Pt(s,0,1),n=Ue(os,4);if(Ia(t,e,3,i,n),!n[1]){if(n[2]){const t=n[2].clone();return 1===i&&t.negateThis(),t}return n[3]}return n[1]}class Ba{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Ta(this.b,e,!1):0}getError(e){return t(0),0}}function ka(t,e,s){const i=Ta(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Dr(new Ba(t,e),kt.unit(),1,n)&&E(""),n[0]}function Ga(t){const e=Ue(os,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),Wa(e,s)}function Wa(e,s){const i=Dh(s);if(1===i){return Wo(e)}if(0===i)return 0;const n=[new os(0,0),e[1].sub(e[0]),e[2].sub(e[0])],r=n[1].crossProduct(n[2]);if(i<1){t(i>0);const e=1-i;let s;if(e<.01)s=-1/3+e*(2/15+e*(3/35+e*(16/315+e*(20/693+e*(16/1001+e*(56/6435))))));else{const t=e*(1+i),n=Math.atan2(Math.sqrt(e),Math.sqrt(1+i));s=i*(.5*i-_e(t)*n)/t}return r*s}{const t=(i-1)*(i+1);return.25*i/Math.pow(t,1.5)*(-2*i*Math.sqrt(t)*r-4*n[1].y*n[2].x*Math.atanh(Math.sqrt((i-1)/(i+1)))-n[1].x*n[2].y*Math.log(2*i*(i-Math.sqrt(t))-1))}}function Za(t){return Ha(t.calculateUpperLength2D())}function Ha(t){return 256*yt()*t}function Oa(t){return t.m_cachedValues}function ja(t,e){t.m_cachedValues=e}function Ua(t,e,s,i,n){const r=Ue(os,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o);const a=[0];return 1===Qa(r,o,e,kt.unit(),i,n,1,a)?a[0]:Number.NaN}function Qa(e,s,i,n,r,o,a,h){N(kt.unit().contains(n)&&a>0,""),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const m=new Array(3);for(let t=0;t<3;++t)m[t]=e[t].sub(i);const u=Dh(s),l=co.constructPoint2D(m[0]),c=co.constructPoint2D(m[1]),d=co.constructPoint2D(m[2]),_=es.constructDouble(u),g=_.clone();g.ldexpThis(1);const p=l.dotProduct(c.sub(l)).mul(_),f=_.mul(_.addDouble(2)),x=d.sub(c.mul(f.ldexp(1))),y=c.sqrLength().mul(_.mul(_).ldexp(1)).add(l.sqrLength().mul(_.ldexp(2).subDouble(1))).add(l.dotProduct(x)),v=d.sub(c.mul(g)).add(l.mul(g.subDouble(1))),P=c.mul(_).sub(l).dotProduct(v).mulDouble(3),b=c.dotProduct(d).mul(_.subDouble(3).mul(_)).ldexp(1),E=c.sqrLength().mul(_.mul(_).ldexp(2)),C=l.sqrLength().mul(_.ldexp(2).subDouble(3)),D=l.dotProduct(d.sub(c.mul(_.mulDouble(3).subDouble(1)).mul(_))).ldexp(1),S=d.sqrLength().addThis(b).addThis(E).addThis(C).addThis(D),w=l.add(d).sub(c.mul(g)),A=_.subDouble(1),T=d.sub(l).dotProduct(w).mul(A),I=new os(0,0),M=[];let q=new os;Eh(m,s,n.vmin,q);let R=os.distance(q,I);if(R<=o&&M.push(new os(n.vmin,R)),n.vmin!==n.vmax&&(Eh(m,s,n.vmax,q),R=os.distance(q,I),R<=o&&M.push(new os(n.vmax,R))),n.width()>0){const t=m[2].isZero(),e=Ue(es,4),i=wo(T,S,P,y,p,58,n,t,e);for(let r=0;r<i;r++){if(!n.containsExclusiveCoordinate(e[r].toDouble()))continue;let t=e[r].toDouble();t=Sh(s,t);const i=new os;Eh(m,s,t,i),R=os.distance(i,I),R<=o&&M.push(new os(t,R))}}if(r){t(n.equals(kt.unit()));{Eh(m,s,-1,q,!0);const t=new os;Eh(m,s,0,t);const e=new fl({pt1:q,pt2:t}),i=e.getClosestCoordinate(I,!0);i<1&&(q=e.getCoord2D(i),R=os.distance(q,I),R<=o&&M.push(new os(i-1,R)))}{Eh(m,s,2,q,!0);const t=new os;Eh(m,s,n.vmax,t);const e=new fl({pt1:t,pt2:q}),i=e.getClosestCoordinate(I,!0);i>0&&(q=e.getCoord2D(i),R=os.distance(q,I),R<=o&&M.push(new os(1+i,R)))}}if(!M.length)return 0;M.sort(((t,e)=>t.compare(e)));let F=0;const Y=M[0].x;if(h[F++]=Y,F<a){const t=Js(m,4,!1).total(),e=M[0].y;for(let s=1,i=M.length;s<i;s++)if(M[s].y>e+t){M.length=s;break}M.sort(((t,e)=>We(t.x,e.x))),F=0,h[F++]=M[0].x;for(let s=1,i=M.length;s<i;s++)M[s].x!==h[F-1]&&F<a&&(h[F++]=M[s].x)}return F}function Ka(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function $a(e,s,i,n,r){const o=new Di;if(Ja(e,kt.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(s))return 0;const a=wa(e);let h=0;const m=[];let u=a.specialPoints[0];for(let l=1,c=a.specialPoints.length;l<c;++l){const i=a.specialPoints[l],n=Da(e,s,u,i);if(0===m.length)m.push(n);else if(n.t===n.tmin)t(m.at(-1).d<=n.d),m.at(-1).tmax=n.tmax;else if(m.at(-1).t===m.at(-1).tmax){t(m.at(-1).d>=n.d);const e=m.at(-1).tmin;m[m.length-1]=n,m.at(-1).tmin=e}else m.push(n);u=i}for(const t of m)if(t.d<=n){const e=t.t;i?(i[h]=e,h++):h++}return h}function Ja(t,e,s){const i=Ue(os,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n),th(i,n,e,s)}function th(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const n=Ue(os,3),r=[0,0,0];rh(t,e,s.vmin,s.vmax,n,r),i.setFromPoints(n,3)}function eh(t){const e=j(t[0].y,t[1].y),s=j(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=j(t[0].x,t[1].x),s=j(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function sh(t){const e=Ue(os,3);t.queryControlPoints(e);const s=ih(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function ih(t){let e=!1;for(let s=0;s<2;s++){const i=j(t[0][s],t[2][s]);i>0?(j(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?(j(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[2][s])>0&&(t[1][s]=t[2][s],e=!0)):t[1][s]!==t[0][s]&&(t[1][s]=t[0][s],e=!0)}return e}function nh(e,s,i,n,r,o,a){t(i>=0&&i<=1&&n!==o&&r!==a),t(s[0]>0&&s[2]>0&&s[1]>=0);const h=[1,Dh(s),1],m=wh(s,i),u=Qe(e,3),l=Ue(ps,3);xh(u,h,l);const c=Ue(ps,3),d=Ue(ps,3);Th(l,m,n?c:null,o?d:null),Ih(s,i,r,a);const _=eh(u);if(n){for(let t=0;t<3;++t)bh(c[t],n[t]);Mh(u,n),_&&ih(n)}if(o){for(let t=0;t<3;++t)bh(d[t],o[t]);Mh(u,o),_&&ih(o)}}function rh(e,s,i,n,r,o){if(t(i>=0&&n<=1&&i<=n),i===n){const t=new os,n=yh(e,s,i,t);return Nh(e,t),r[0].assign(t),r[1].assign(t),r[2].assign(t),o[0]=n,o[1]=n,void(o[2]=n)}if(0===i&&1===n)return r[0].assign(e[0]),r[1].assign(e[1]),r[2].assign(e[2]),o[0]=s[0],o[1]=s[1],void(o[2]=s[2]);const a=Ue(ps,3);{const t=[1,Dh(s),1],r=wh(s,i),o=wh(s,n);xh(e,t,a),Th(a,o,a,null);Th(a,r>=o?1:r/o,null,a)}const h=[0,0,0];Ih(s,n,h,null),Ih(h,i/n,null,h);const m=eh(e),u=Ue(os,3);bh(a[1],u[1]),Eh(e,s,i,u[0]),Eh(e,s,n,u[2]),Mh(e,u);for(let t=0;t<3;++t)r[t].assign(u[t]),o[t]=h[t];m&&ih(r)}function oh(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new cn,o=Ue(os,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new os;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=Ue(os,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformInPlace(t.m_cp):le(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),n&&sh(t)}function ah(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==ch(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function hh(e,s,i,n,r){return t(0),0}function mh(t,e){const s=t.getEndXY().sub(t.getStartXY()),i=s.length(),n=t.getControlPoint1();n.subThis(t.getStartXY());return!(Math.abs(n.crossProduct(s))/i>e)}function uh(t,e,s,i,n){if(n){const i=hl(e,s);if(0!==i){if(t){if(1===i){if(e.m_weights[0]===s.m_weights[0]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[2])return 2}else if(e.m_weights[0]===s.m_weights[2]&&e.m_weights[1]===s.m_weights[1]&&e.m_weights[2]===s.m_weights[0])return 2;return 4}return 2}}else if(Mi(e,s))return 1;return 0!==_h(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function lh(e,s,i,n,r){return t(0),0}function ch(e,s,i,n,r,o,a,h,m,u){if(null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0),i.isDegenerate(0)){const t=[0,0],e=s.intersectPoint(i.getStartXY(),t,a);if(e>0){if(null!==r)for(let s=0;s<e;s++)r.push(t[s]);if(null!=o)for(let t=0;t<e;t++)o.push(0);if(null!=n)for(let i=0;i<e;i++){const e=new os;s.queryCoord2D(t[i],e),n.push(e)}}return e}const l=Ki(s,i);if(a=Math.max(a,l),s.isDegenerateToLineHelper(l)){const t=new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),e=sr(t,i,n,r,o,a,h,u);if(r)for(let i=0;i<e;++i){const e=t.getCoord2D(r[i]);r[i]=s.getClosestCoordinate(e,!1)}return e}if($i(s,i,a))return 0;const c=Ue(os,3);s.queryControlPoints(c);const d=[0,0,0];s.queryWeights(d);const _=[1,Dh(d),1],g=i.getEndXY().sub(i.getStartXY()),p=g.clone();p.leftPerpendicularThis();const f=c[0].clone(),x=c[1].clone(),y=c[2].clone(),v=x.sub(f),P=y.sub(f),b=y.sub(x),E=_[0],C=_[1],D=_[2],S=E*C,w=E*D,A=C*D,T=v.dotProduct(p)*S,I=P.dotProduct(p)*w;let N=T,M=I-2*T,q=b.dotProduct(p)*A+I-I;const R=new Array(13),F=new Array(13);let Y=Sr(q,M,N,kt.unit(),!1,R);Y<0&&(R[0]=0,R[1]=1,Y=2);let X=0;for(let t=0,k=X;t<Y;++t){const e=new os;Eh(c,_,R[t+k],e),F[X]=i.getClosestCoordinate(e,!1);os.distance(e,i.getCoord2D(F[X]))<=a&&(R[X]=R[t+k],X++)}const L=Ue(os,3),z=Ue(os,3);if(s.queryControlPoints(z),z[0].subThis(i.getStartXY()),z[1].subThis(i.getStartXY()),z[2].subThis(i.getStartXY()),ph(z,_,L,!1),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;q=L[2].y-L[2].x*t,M=L[1].y-L[1].x*t,N=L[0].y-L[0].x*t}else{const t=g.x/g.y;q=L[2].x-L[2].y*t,M=L[1].x-L[1].y*t,N=L[0].x-L[0].y*t}const V=s.getEndXY().equals(i.getStartXY())||s.getEndXY().equals(i.getEndXY()),B=[0,0];Y=Sr(q,M,N,kt.unit(),V,B);for(let t=0,k=X;t<Y;++t){R[t+k]=B[t];const e=new os;Eh(c,_,R[t+k],e),F[X]=i.getClosestCoordinate(e,!1);os.distance(e,i.getCoord2D(F[X]))<=a&&(R[X]=R[t+k],X++)}t(X<R.length+4);for(let t=0;t<X;t++)R[t]=Sh(d,R[t]);Y=s.intersectPoint(i.getStartXY(),B,a);for(let t=0;t<Y;t++)R[X]=B[t],F[X++]=0;Y=s.intersectPoint(i.getEndXY(),B,a);for(let t=0;t<Y;t++)R[X]=B[t],F[X++]=1;Y=i.intersectPoint(s.getStartXY(),B,a);for(let t=0;t<Y;t++)F[X]=B[t],R[X++]=0;Y=i.intersectPoint(s.getEndXY(),B,a);for(let t=0;t<Y;t++)F[X]=B[t],R[X++]=1;return 0===X?0:dl(e,s,i,R,F,X,n,r,o,a,h,m,u)}function dh(e,s,i,n,r,o,a,h,m,u){return t(0),0}function _h(e,s,i,n,r,o,a,h,m,u){const l=Ue(os,3);s.queryControlPoints(l);const c=Ue(os,3);if(i.queryControlPoints(c),Ji(l,c,3)<0)return _h(e,i,s,n,o,r,a,h,m,!u);const d=Ki(s,i);if(s.isDegenerateToLineHelper(d)){const t=new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),l=ch(e,i,t,n,o,r,a,h,m,!u);if(r)for(let e=0;e<l;++e){const i=t.getCoord2D(r[e]);r[e]=s.getClosestCoordinate(i,!1)}return l}if(i.isDegenerateToLineHelper(d)){const t=new fl({pt1:i.getStartXY(),pt2:i.getEndXY()}),l=ch(e,s,t,n,r,o,a,h,m,u);if(o)for(let e=0;e<l;++e){const s=t.getCoord2D(o[e]);o[e]=i.getClosestCoordinate(s,!1)}return l}if($i(s,i,a=Math.max(a,d)))return 0;const _=new Array(3);s.queryWeights(_);const g=new Array(3);i.queryWeights(g);const p=[1,Dh(_),1],f=[1,Dh(g),1],x=new kt(0,1),y=new kt(0,1);{const t=Di.constructEmpty();th(l,p,new kt(0,1),t);const e=Di.constructEmpty();th(c,f,new kt(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Ch(l,p,t,x),Ch(c,f,t,y),x.isEmpty()||y.isEmpty())return 0;rh(l,p,x.vmin,x.vmax,l,p),rh(c,f,y.vmin,y.vmax,c,f)}}const v=gl(l,2,c,2,a);if(0===v)return 0;const P=[],b=[];if(-1===v){const t=Ue(es,3),e=Ue(es,3),s=Ue(es,3);fh(l,p,t,e,s);const i=Ue(es,3),n=Ue(es,3),r=Ue(es,3);fh(c,f,i,n,r);const o=[],h=[],m=vo(t,2,e,2,s,2,i,2,n,2,r,2,!0,kt.unit(),kt.unit(),o,h);if(m>0)for(let u=0;u<m;u++){const t=new os;Eh(c,f,h[u],t);const e=new os;Eh(l,p,o[u],e);os.distance(e,t)<=a&&(P.push(o[u]),b.push(h[u]))}}for(let E=0;E<2;E++){let e,s,i;0===E?(e=l,s=c,i=f):(e=c,s=l,i=p);for(let n=0;n<2;n++){const r=0===n?0:e.length-1,o=new os,h=[0];t(1===Qa(s,i,e[r],kt.unit(),!1,-1,1,h)),Eh(s,i,h[0],o),os.distance(e[r],o)<=a&&(0===E?(P.push(0===r?0:1),b.push(h[0])):(b.push(0===r?0:1),P.push(h[0])))}}if(0===P.length)return 0;if(!x.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=lo.recalculateParentT(x.vmin,x.vmax,P[t]);if(!y.equalsRange(0,1))for(let t=0;t<b.length;++t)b[t]=lo.recalculateParentT(y.vmin,y.vmax,b[t]);for(let t=0;t<P.length;++t)P[t]=Sh(_,P[t]);for(let t=0;t<b.length;++t)b[t]=Sh(g,b[t]);return dl(e,s,i,P,b,P.length,n,r,o,a,h,m,u)}function gh(t,e,s,i,n,r,o,a,h,m){if(e.isLine())return new fl({pt1:e.getStartXY(),pt2:e.getEndXY()}),na();if(s.isLine()){return ch(t,e,new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,m)}const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=Ue(os,3);e.queryControlPoints(l);const c=Ue(os,3);s.queryControlPoints(c);const d=gl(l,2,c,2,o);if(0===d)return 0;const _=[],g=[];if(-1===d){const t=Ue(es,3),i=Ue(es,3),n=Ue(es,3),r=[0,0,0];e.queryWeights(r),fh(l,r,t,i,n);const a=Ue(es,3),h=Ue(es,3);ha(c,a,h);const m=vo(t,2,i,2,n,2,a,2,h,2,null,0,!0,kt.unit(),kt.unit(),_,g);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new os;s.queryCoord2D(g[i],n);const r=new os;e.queryCoord2D(_[i],r),os.distance(r,n)<=o&&(_[t]=_[i],g[t]=g[i],t++)}_.length=t,g.length=t}}for(let p=0;p<2;p++){let t;t=0===p?l:c;for(let i=0;i<2;i++){const n=0===i?0:t.length-1;let r;const a=new os;0===p?(r=Oo(s,t[n],kt.unit()),s.queryCoord2D(r,a)):(r=Ua(e,t[n],kt.unit(),!1,-1),e.queryCoord2D(r,a)),os.distance(t[n],a)<=o&&(0===p?(_.push(0===n?0:1),g.push(r)):(g.push(0===n?0:1),_.push(r)))}}return dl(t,e,s,_,g,_.length,i,n,r,o,a,h,m)}function ph(t,e,s,i=!1){const n=Ue(os,3);i?(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[1].subThis(n[0]),n[2].setCoordsPoint2D(t[2]),n[2].subThis(n[0]),n[0].setCoords(0,0)):(n[0].setCoordsPoint2D(t[0]),n[1].setCoordsPoint2D(t[1]),n[2].setCoordsPoint2D(t[2])),n[0].mulThis(e[0]),n[1].mulThis(e[1]),n[2].mulThis(e[2]),s[1].setCoords(n[1].x-n[0].x,n[1].y-n[0].y),s[2].setCoordsPoint2D(n[2].sub(n[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(n[0])}function fh(t,e,s,i,n){const r=es.constructDouble(e[0]),o=es.constructDouble(e[1]),a=es.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(r),s[1].setDouble(t[1].x),s[1].mulThis(o),s[2].setDouble(t[2].x),s[2].mulThis(a),s[2].subThis(s[1]),s[1].subThis(s[0]),s[2].subThis(s[1]),s[1].ldexpThis(1),i[0].setDouble(t[0].y),i[0].mulThis(r),i[1].setDouble(t[1].y),i[1].mulThis(o),i[2].setDouble(t[2].y),i[2].mulThis(a),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),n[0].setDouble(e[0]),n[1].setDouble(e[1]),n[2].setThis(n[1]),n[2].ldexpThis(1),n[2].negateThis(),n[2].addThis(n[0]),n[2].addDoubleThis(e[2]),n[1].subThis(n[0]),n[1].ldexpThis(1)}function xh(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function yh(t,e,s,i){const n=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],r=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],o=[e[0],e[1],e[2]],a=s;let h,m,u;if(s<=.5){h=he(me(n[0],n[1],a),me(n[1],n[2],a),a);m=he(me(r[0],r[1],a),me(r[1],r[2],a),a);const l=me(o[0],o[1],a),c=me(o[1],o[2],a);if(u=me(l,c,a),0===s)return i.assign(t[0]),e[0]}else{const l=ue(n[0],n[1],a),c=ue(n[1],n[2],a);h=ue(l,c,a);const d=ue(r[0],r[1],a),_=ue(r[1],r[2],a);m=ue(d,_,a);const g=ue(o[0],o[1],a),p=ue(o[1],o[2],a);if(u=ue(g,p,a),1===s)return i.assign(t[2]),e[2]}return h/=u,m/=u,i.setCoords(h,m),Nh(t,i),u}function vh(t,e,s){const i=Ue(os,3);t.queryControlPoints(i);const n=[0,0,0];t.queryWeights(n);Ph([Ai.constructPoint2D(i[0]),Ai.constructPoint2D(i[1]),Ai.constructPoint2D(i[2])],[new Wt(n[0]),new Wt(n[1]),new Wt(n[2])],e,s)}function Ph(t,e,s,i){let n=e[0].mulE(e[2]);n.sqrtThis(),n=e[1].divE(n);const r=e[0].divE(e[2]);r.sqrt();const o=s.divE(r.mulE(new Wt(1).subE(s)).addE(s)),a=new Ai,h=new Wt,m=t[1].mulE(n);if(o.value()<=.5){const e=new Ai;oe(2,t[0],m,o,e);const s=new Ai;oe(2,m,t[2],o,s),oe(2,e,s,o,a);const i=new Wt;ne(new Wt(1),n,o,i);const r=new Wt;ne(n,new Wt(1),o,r),ne(i,r,o,h)}else{const e=new Ai;ae(2,t[0],m,o,e);const s=new Ai;ae(2,m,t[2],o,s),ae(2,e,s,o,a);const i=new Wt;re(new Wt(1),n,o,i);const r=new Wt;re(n,new Wt(1),o,r),re(i,r,o,h)}a.divThisE(h);const u=new os(a.x.value(),a.y.value());Nh([t[0].value(),t[1].value(),t[2].value()],u),i.x.set(u.x,a.x.eps()),i.y.set(u.y,a.y.eps())}function bh(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function Eh(t,e,s,i,n){if(n){if(s<0){return void On(new fl({pt1:t[0],pt2:t[0].add(Va(t,e,0).getUnitVector())}),s,i)}if(s>1){return void On(new fl({pt1:t[2],pt2:t[2].add(Va(t,e,1).getUnitVector())}),s-1,i)}}yh(t,e,s,i)}function Ch(t,e,s,i){i.setEmpty();const n=[];n.push(new kt(0,1));const r=.5*Math.max(s.width(),s.height());for(;n.length;){const o=n.at(-1);n.pop();const a=new Di;if(th(t,e,o,a),a.isIntersectingW(s)){const t=Math.max(a.width(),a.height());if(s.containsW(a)||t<=r||o.width()<1e-12)i.merge(o);else{const t=o.getCenter();n.push(kt.construct(o.vmin,t)),n.push(kt.construct(t,o.vmax))}}}}function Dh(t){return t[1]/Math.sqrt(t[0]*t[2])}function Sh(t,e){return e/he(Math.sqrt(t[2]/t[0]),1,e)}function wh(t,e){return e/he(Math.sqrt(t[0]/t[2]),1,e)}function Ah(t,e){const s=Ue(os,3);t.queryControlPoints(s);const i=[0,0,0];t.queryWeights(i),e.setControlPointsAndWeights(s,i)}function Th(e,s,i,n){t(s>=0&&s<=1);(new ps).setCoordsPoint3D(e[0]);(new ps).setCoordsPoint3D(e[1]);(new ps).setCoordsPoint3D(e[2]);const r=new ps,o=new ps,a=new ps;ie(3,e[0],e[1],s,r),ie(3,e[1],e[2],s,o),ie(3,r,o,s,a);const h=e[2].clone();i&&(i[0].assign(e[0]),i[1].assign(r),i[2].assign(a)),n&&(n[0].assign(a),n[1].assign(o),n[2].assign(h))}function Ih(e,s,i,n){const r=[e[0],e[1],e[2]];t(s>=0&&s<=1&&i!==n);const o=he(r[0],r[1],s),a=he(r[1],r[2],s),h=he(o,a,s);i&&(i[0]=r[0],i[1]=o,i[2]=h),n&&(n[0]=h,n[1]=a,n[2]=r[2])}function Nh(t,e){const s=kt.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=Pt(e.x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e.y=Pt(e.y,s.vmin,s.vmax)}function Mh(t,e){const s=new kt;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=Pt(e[0].x,s.vmin,s.vmax),e[1].x=Pt(e[1].x,s.vmin,s.vmax),e[2].x=Pt(e[2].x,s.vmin,s.vmax),s.vmin=s.vmax=t[0].y,s.mergeNeCoordinate(t[1].y),s.mergeNeCoordinate(t[2].y),e[0].y=Pt(e[0].y,s.vmin,s.vmax),e[1].y=Pt(e[1].y,s.vmin,s.vmax),e[2].y=Pt(e[2].y,s.vmin,s.vmax)}function qh(){return{e2:0,completeE:0}}class Rh{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?os.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(e){return t(0),0}}function Fh(t,e,s){if(em(t)){$n(new fl({pt1:t.getStartXY(),pt2:t.getEndXY()}),e,s)}else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const e=new Wt;Wh();const i=new Wt,n=new Wt;Wt.st_cosAndSin(e,i,n);const r=Ai.constructCoordsE(new Wt(t.m_semiMajorAxis).mulThisE(i),new Wt(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(n)),o=new Wt(t.m_rotation);Wt.st_cosAndSin(o,i,n),r.rotateDirect(i,n),r.addThisE(Ai.constructPoint2D(t.m_center)),s.setE(r)}}function Yh(t,e){return t.convertToCanonic(e)}function Xh(t,e){const s=new kt(t.getStartAngle(),t.getEndAngle());s.normalize();const i=Ct(),n=Te(e,i);if(n<s.vmin){let t=n+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-n<t-s.vmax?n:t}if(n>s.vmax){let t=n-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<n-s.vmax?t:n}return n}function Lh(t){let e=t,s=!1;return e<=-Et()?(e+=Ct(),s=!0):e>Et()&&(e-=Ct(),s=!0),e<=-Et()?(e=Te(e,Ct()),e<=-Et()&&(e+=Ct()),s=!0):e>Et()&&(e=Te(e,Ct()),e>Et()&&(e-=Ct()),s=!0),s&&(e>Et()||e<=-Et())&&(e=Et()),e}function zh(t,e,s){const i=s,n=i.getSemiAxes();let r=new os(n.x*Math.cos(t[0]),n.y*Math.sin(t[0]));return r=i.convertFromCanonic(r),os.sqrDistance(r,i.getStartXY())}function Vh(t,e,s){const i=s,n=i.getSemiAxes(),r=t[0]+i.getStartAngle();let o=new os(n.x*Math.cos(r),n.y*Math.sin(r));return o=i.convertFromCanonic(o),os.sqrDistance(o,i.getEndXY())}function Bh(t){if(t.m_center.isNAN())return t.m_startAngle=0,void(t.m_sweepAngle=0);const e=t.getStartXY(),s=t.getEndXY(),i=e.equals(s),n=lm(t),r=mm(t),o=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new os(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Lh(Math.atan2(s.y,s.x)),t.m_sweepAngle=n?r?Ct():-Ct():0}else{const i=t.convertToCanonic(e),a=new os(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=a.x,i.y/=a.y;const h=t.convertToCanonic(s);h.x/=a.x,h.y/=a.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=os.calculateAngle(i,h),r?t.m_sweepAngle<0&&(t.m_sweepAngle+=Ct()):t.m_sweepAngle>0&&(t.m_sweepAngle-=Ct()),t.m_startAngle=Lh(t.m_startAngle);let m=zh([t.m_startAngle],1,t);if(m=Math.sqrt(m),m>.25*Qi(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];Ar(zh,t,1,[t.m_startAngle],[e],[s],1e-14,i),t.m_startAngle=Lh(i[0])}if(m=Vh([t.m_sweepAngle],1,t),m=Math.sqrt(m),m>.25*Qi(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];Ar(Vh,t,1,[t.m_sweepAngle],[e],[s],1e-14,i),t.m_sweepAngle=i[0]}const u=Math.abs(t.m_sweepAngle)>Et();if(um(t,u),n!==u&&!n&&Math.abs(t.m_sweepAngle)>1.5*Et())return void tm(t,e,s,o);if(0===t.m_sweepAngle||r!==t.m_sweepAngle>0)return void tm(t,e,s,o)}}function kh(t,e){return(Xh(t,e)-t.getStartAngle())/t.getSweepAngle()}function Gh(t,e){return t.m_startAngle+e*t.m_sweepAngle}function Wh(e,s,i){t(0)}function Zh(t,e){const s=new Wt(t.m_cosr).sqrThis(),i=new Wt(t.m_sinr).sqrThis(),n=new Wt(t.m_minorMajorRatio),r=new Wt(1/t.m_minorMajorRatio),o=n.mulE(s).addThisE(r.mulE(i)),a=n.subE(r).mulThis(2*t.m_cosr*t.m_sinr),h=n.mulE(i).addThisE(r.mulE(s));e[0]=o,e[1]=a,e[2]=h,e[3]=new Wt(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}function Hh(t,e){const s=new Ti;s.a11.setE(t[0]),s.a12=Wt.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[os.getNAN(),os.getNAN()],n=[new Wt,new Wt];s.eigenSymmetric(n,i);const r=t[3].clone();r.negateThis(),r.invThis(),n[0].mulThisE(r),n[1].mulThisE(r),n[0].sqrtThis().invThis(),n[1].sqrtThis().invThis(),e.x=n[0].toDouble(),e.y=n[1].toDouble();return Math.atan2(i[0].y,i[0].x)}function Oh(t,e,s){if(em(t))return(s-e)*os.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(t.getSweepAngle()*(e-s))*t.m_semiMajorAxis;const i=sm(t,e);return sm(t,s)-i}function jh(t){return t.m_cachedValues}function Uh(t){if(t.m_cachedValues)return t.m_cachedValues;const e=qh();return e.e2=$h(t),e.completeE=Ie(e.e2),t.m_cachedValues=e,e}function Qh(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(em(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,vm(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*Dt()){const i=Ue(os,3),n=pm(t,i);if(eh(i)){i[0].assign(e),i[2].assign(s),ih(i);if(0===t.projectionBehavior()){let e=0,s=2;os.sqrDistance(i[1],i[0])<os.sqrDistance(i[1],i[2])&&(s=Ve(e,e=s));const n=i[s].sub(i[e]),r=n.length();n.divThis(r);const o=i[1].sub(i[e]),a=o.length(),h=o.dotProduct(n)/a,m=o.crossProduct(n)/a,u=new os;le(i[e],i[s],.5,u);const l=.5*r/m*Pt(1-h,0,1),c=i[1].side(i[e],i[s]),d=n.clone();c?d.leftPerpendicularThis():d.rightPerpendicularThis();const _=u.sub(d.mul(l));t.constructCircularArcThreePoint(i[0],i[2],_)}else fm(i,n*n,null,!1,t);return}}0===t.projectionBehavior()?Tm(t,e,s):Im(t,e,s)}}function Kh(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void tm(t,e[0],e[s-1],i?0:1);if(i){t.constructCircularArcThreePoint(e[0],e[s-1],e[Math.trunc(s/2)]);const i=new os;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const n=t.getSemiMajorAxis(),r=t.getMinorMajorRatio(),o=t.getAxisXRotation(),a=t.getCenter(),h=new Array(4);h[0]=t.isMajor(),h[1]=!h[0],h[2]=h[0],h[3]=!h[0];const m=new Array(4);m[0]=t.isClockwise(),m[1]=m[0],m[2]=!m[0],m[3]=!m[0];const u=Math.trunc(s<5?1:(s+4)/5),l=Ue(jr,4),c=new Array(4);let d=0;for(let _=0;_<4;_++){l[_].constructEllipticArcEndPointsCenter(e[0],e[s-1],n,r,o,h[_],m[_],a),c[_]=0;let t=0;for(let i=u;i<s-1;i+=u){const s=l[_].getClosestCoordinate(e[i],!1);c[_]+=os.sqrDistance(l[_].getCoord2D(s),e[i]),t++}c[_]/=t,c[_]<c[d]&&(d=_)}t.assignCopy(l[d])}function $h(t){return 1-ce(t.m_minorMajorRatio)}function Jh(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,Li(t,e),Vi(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),um(t,o),hm(t,a),void 0!==h?t.m_center.assign(h):t.m_center.setNAN(),t.setProjectionBehavior(1),t.m_semiMajorAxis=i,t.m_minorMajorRatio=n,gm(t,void 0===h)}function tm(t,e,s,i){t.m_bits=0,t.m_rotation=0,Li(t,e),Vi(t,s),t.m_interior.assign(e.add(s).mul(.5)),t.m_startAngle=0,t.m_sweepAngle=0,t.m_cosr=1,t.m_sinr=0,um(t,!1),hm(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function em(t){return t.m_center.isNAN()}function sm(t,e){if(0===e)return 0;const s=Uh(t),i=Gh(t,e),n=Dt(),r=nm(t),o=Ne(i+n,s.e2,s.completeE),a=t.m_semiMajorAxis*(o-r);return Math.abs(a)}function im(t,e){if(em(t)){const s=os.distance(t.getStartXY(),t.getEndXY());return 0===s?0:e/s}if(1===t.m_minorMajorRatio){const s=Math.abs(t.getSweepAngle()*t.m_semiMajorAxis);return 0===s?0:e/s}if(0===e)return 0;const s=t.getSweepAngle();if(0===s)return.5;const i=Uh(t),n=Dt(),r=nm(t);s<0&&(e=-e);let o=Me(e/t.m_semiMajorAxis+r,i.e2,i.completeE);o-=n,o-=t.getStartAngle();return o/s}function nm(t){const e=Uh(t);return Ne(t.getStartAngle()+Dt(),e.e2,e.completeE)}function rm(e,s,i){if(s instanceof _n)return void t(0);if(t(!dm(e)),s.isIdentity())return;am(e);const n=os.getNAN();n.x=e.m_XStart,n.y=e.m_YStart,s.transformInPlace(n);const r=os.getNAN();if(r.x=e.m_XEnd,r.y=e.m_YEnd,s.transformInPlace(r),em(e))return e.m_XStart=n.x,e.m_YStart=n.y,e.m_XEnd=r.x,void(e.m_YEnd=r.y);const o=e.m_center.clone();if(s.transformInPlace(o),i||s.isUniformNoRotation()){let t=mm(e);s.isReflective()&&(t=!t);if(0===e.projectionBehavior()){if(!n.equals(r)){const t=e.m_interior.clone();return s.transformInPlace(t),void e.constructCircularArcThreePoint(n,r,t)}return void Qr(e,n,r,o,t,!1)}const i=new os(e.m_cosr,e.m_sinr);s.transformWithoutTranslateInPlace(i);const a=Math.atan2(i.y,i.x),h=e.getSemiAxes();s.transformWithoutTranslateInPlace(h);const m=e.m_center.clone();return s.transformInPlace(m),void e.constructEllipticArcEndPointsCenter(n,r,h.x,h.y/h.x,a,e.isMajor(),t,m)}{{const t=new Array(4);Zh(e,t);const i=new Ti;i.a11.setE(t[0]),i.a12.setE(t[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(t[2]);if(!i.det().isZero()){const a=new Ti;if(a.a11.set(s.xx),a.a12.set(s.xy),a.a21.set(s.yx),a.a22.set(s.yy),a.invertThis()){const h=a.clone();h.transposeThis();const m=i.clone();m.mulThis(a),m.mulLeftThis(h);if(!m.det().isZero()){const i=Ue(Wt,4);i[0].setE(m.a11),i[1].setE(m.a12),i[1].mulThisByPower2(2),i[2].setE(m.a22),i[3].setE(t[3]);const a=os.getNAN(),h=Hh(i,a);let u=mm(e);return s.isReflective()&&(u=!u),void e.constructEllipticArcEndPointsCenter(n,r,a.x,a.y/a.x,h,e.isMajor(),u,o)}}}}const t=[os.getNAN(),os.getNAN(),os.getNAN()];t[0].setCoords(e.getSemiMajorAxis(),0),t[0].rotateDirect(e.m_cosr,e.m_sinr),t[1].setCoords(e.getSemiMajorAxis(),e.getSemiMinorAxis()),t[1].rotateDirect(e.m_cosr,e.m_sinr),t[2].setCoords(0,e.getSemiMinorAxis()),t[2].rotateDirect(e.m_cosr,e.m_sinr);let i=e.isClockwise();i&&(t[2]=Ve(t[0],t[0]=t[2]));const a=.5;s.transformWithoutTranslateArray(t,3,t),s.isReflective()&&(i=!i);const h=new os(0,0),m=e.createInstance();fm(t,a,h,!1,m),e.constructEllipticArcEndPointsCenter(n,r,m.getSemiMajorAxis(),m.getMinorMajorRatio(),m.getAxisXRotation(),e.isMajor(),!i,o)}}function om(t,e){t.m_cachedValues=e}function am(t){t.m_cachedValues=null}function hm(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function mm(t){return!!(1&t.m_bits)}function um(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function lm(t){return!!(2&t.m_bits)}function cm(t){if(t.m_center.isNAN())return!1;const e=8,s=new Ai;s.setWithEps(t.getStartXY(),e),s.subThisE((new Ai).setWithEps(t.m_center,e));const i=new Wt;i.setWithEps(t.m_rotation,e);const n=new Wt,r=new Wt;Wt.st_cosAndSin(i,n,r),s.rotateReverse(n,r);const o=new Ai;o.setWithEps(t.getEndXY()),o.subThisE(Ai.constructPoint2D(t.m_center)),o.rotateReverse(n,r);const a=new Wt;a.setWithEps(t.m_semiMajorAxis,e);const h=a.clone(),m=new Wt;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),s.x.divThisE(a),s.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const u=s.x.sqr().addThisE(s.y.sqr()).subThisE(Qt),l=o.x.sqr().addThisE(o.y.sqr()).subThisE(Qt);return!u.isZero()||!l.isZero()}function dm(t){return!!(8&t.m_bits)}function _m(t){t.m_bits&=-9}function gm(t,e){_m(t);const s=t.getStartXY(),i=t.getEndXY();let n=!1;const r=lm(t),o=mm(t),a=t.projectionBehavior(),h=s.equals(i);let m=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:p("NAN minor major ratio and non-zero major axis")),m||=e?h:t.m_center.isNAN(),m)return tm(t,s,i,a),!0;t.m_semiMajorAxis=Math.abs(t.m_semiMajorAxis),t.m_minorMajorRatio=Math.abs(t.m_minorMajorRatio),t.m_minorMajorRatio>1&&(t.m_semiMajorAxis*=t.m_minorMajorRatio,t.m_minorMajorRatio=1/t.m_minorMajorRatio);const u=new os(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(h){const e=t.convertToCanonic(s);e.x/=u.x,e.y/=u.y;const i=Math.sqrt(ce(e.x)+ce(e.y));if(n=1!==i,t.m_semiMajorAxis*=i,u.mulThis(i),t.m_startAngle=Lh(Math.atan2(e.y,e.x)),!r)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),n;t.m_sweepAngle=o?Ct():-Ct()}else{let e=t.m_center.isNAN()||cm(t);if(!e){const n=t.convertToCanonic(s);n.x/=u.x,n.y/=u.y;const r=new os(1,0);t.m_startAngle=os.calculateAngle(r,n);const o=t.convertToCanonic(i);o.x/=u.x,o.y/=u.y,t.m_sweepAngle=os.calculateAngle(n,o),e=!ym(t)}if(e){n=!0;const e=s.sub(i).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let a=ce(e.x/u.x)+ce(e.y/u.y);a>1&&(a=Math.sqrt(a),t.m_semiMajorAxis*=a,u.mulThis(a));const h=new os(0,0);{const t=u.x*u.x,s=u.y*u.y,i=t*e.y*e.y+s*e.x*e.x,n=t*s-i;if(n>0){const t=Math.sqrt(n/i);h.setCoords(u.x*e.y/u.y,-u.y*e.x/u.x),h.mulThis(t),r===o&&h.negateThis()}}{const e=new os(h.x,h.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(i).mulThis(.5)),t.m_center.assign(e)}}if(Bh(t),!ym(t))return tm(t,s,i,a),!0}return vm(t),t.afterCompletedModification(),n}function pm(e,s){t(Math.abs(e.getSweepAngle())<15*Math.PI/16);const i=e.getSemiMajorAxis(),n=e.getSemiMinorAxis();let r;if(0===i)return s[0].setCoordsPoint2D(e.getStartXY()),s[1].setCoordsPoint2D(e.getStartXY()),s[2].setCoordsPoint2D(e.getStartXY()),r=1,r;if(0===n)return s[0].setCoordsPoint2D(e.getStartXY()),s[2].setCoordsPoint2D(e.getEndXY()),s[1]=os.lerp(s[0],s[2],.5),r=1,r;const o=e.getSweepAngle(),a=e.getStartAngle(),h=a+o,m=Math.cos(.5*o),u=new os(-i*Math.sin(a),n*Math.cos(a)),l=new os(-i*Math.sin(h),n*Math.cos(h));u.normalize(),l.normalize(),u.rotateDirect(e.m_cosr,e.m_sinr),l.rotateDirect(e.m_cosr,e.m_sinr),s[0].setCoordsPoint2D(e.getStartXY()),s[2].setCoordsPoint2D(e.getEndXY()),s[1].setSub(s[2],s[0]);const c=u.crossProduct(l);return s[1]=u.mul(s[1].crossProduct(l)/c),s[1].addThis(s[0]),r=m,r}function fm(e,s,i,n,r){const o=e[0].sub(e[1]),a=e[2].sub(e[1]),h=o.crossProduct(a),m=o.dotProduct(a),u=s;t(u<=1),t(u>0);const l=.5/(1-u),c=o.sqrLength(),d=m,_=a.sqrLength(),g=ce(h),p=o.sub(a).sqrLength();if(0===g)return tm(r,e[0],e[2],1),!1;if(m<=-Math.sqrt(c)*Math.sqrt(_))return tm(r,e[0],e[2],1),!1;const f=[0,0],x=new kt;x.setInfinite();const y=Sr(2*g,-(p/u+4*d),2*(1-u)/u,x,!1,f);if(0===y)return tm(r,e[0],e[2],1),!1;1===y&&(f[1]=f[0]);const v=Math.sqrt(l/f[0]),P=Math.sqrt(l/f[1]),b=.5/u;let E=b-_*f[0],C=b-c*f[0];Math.abs(E)>Math.abs(C)?C=d*f[0]-b+1:E=d*f[0]-b+1;const D=o.mul(E).add(a.mul(C)),S=D.norm(1)<1e-15*v?0:Math.atan2(D.y,D.x)+Math.PI,w=o.add(a),A=i?i.clone():e[1].add(w.mul(l)),T=e[0].sub(A),I=e[2].sub(A),N=T.crossProduct(I)<0,M=!1;new jr;return r.constructEllipticArcEndPointsCenter(e[0],e[2],v,P/v,S,M,!N,A)}function xm(t,e,s,i,n){return fm(t,e,s,i,n)}function ym(t){let e=!1;{const s=new os(t.m_semiMajorAxis*Math.cos(t.m_startAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle));s.rotateDirect(t.m_cosr,t.m_sinr),s.addThis(t.m_center);e=os.distance(t.getStartXY(),s)>Qi(t)}let s=!1;if(!e){const e=new os(t.m_semiMajorAxis*Math.cos(t.m_startAngle+t.m_sweepAngle),t.getSemiMinorAxis()*Math.sin(t.m_startAngle+t.m_sweepAngle));e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(t.m_center);s=os.distance(t.getEndXY(),e)>Qi(t)}return!e&&!s}function vm(t){t.queryCoord2D(.5,t.m_interior)}function Pm(t,e,s,i,n){if(n){if(0!==hl(e,s))return 2}else if(Mi(e,s))return 1;return 0!==Em(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function bm(t,e,s,i,n){if(n){if(0!==hl(e,s))return 2}else if(Mi(e,s))return 1;return 0!==Cm(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Em(e,s,i,n,r,o,a,h,m,u){if(em(s)){return sr(new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,u)}null!==r&&(r.length=0),null!==o&&(o.length=0),null!==n&&(n.length=0);const l=Ki(s,i);if($i(s,i,a=Math.max(l,a)))return 0;const c=i.getStartXY();c.subThis(s.m_center);const d=i.getEndXY();d.subThis(s.m_center),c.rotateReverse(s.m_cosr,s.m_sinr),d.rotateReverse(s.m_cosr,s.m_sinr);const _=d.clone();_.subThis(c);const g=s.m_semiMajorAxis,p=1/g,f=s.getSemiMinorAxis(),x=1/f,y=_.clone();y.leftPerpendicularThis();const v=Math.atan2(f*y.y,g*y.x),P=new Array(16),b=new Array(16);let E=0;const C=[v,v+Math.PI];for(let t=0;t<2;++t){const e=kh(s,C[t]);if(e>=0&&e<=1){P[E]=e;const t=s.getCoord2D(P[E]);b[E]=i.getClosestCoordinate(t,!1),os.distance(t,i.getCoord2D(b[E]))<=a&&E++}}const D=c.x*p,S=c.y*x,w=_.x*p,A=_.y*x;let T=Sr(w*w+A*A,2*(D*w+S*A),D*D+S*S-1,kt.unit(),!1,b);t(T>=0);for(let t=0;t<T;t++){const e=_.mul(b[t]).add(c);e.x*=p,e.y*=x;const n=kh(s,Math.atan2(e.y,e.x));if(n>=0&&n<=1){P[E]=n;const t=s.getCoord2D(n);b[E]=i.getClosestCoordinate(t,!1),os.distance(t,i.getCoord2D(b[E]))<=a&&E++}}t(E<P.length+4);const I=new Array(16);T=s.intersectPoint(i.getStartXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=I[t],b[E]=0;T=s.intersectPoint(i.getEndXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=I[t],b[E]=1;T=i.intersectPoint(s.getStartXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=0,b[E]=I[t];T=i.intersectPoint(s.getEndXY(),I,a);for(let t=0;t<T;t++,E++)P[E]=1,b[E]=I[t];return 0===E?0:dl(e,s,i,P,b,E,n,r,o,a,h,m,u)}function Cm(t,e,s,i,n,r,o,a,h,m){if(em(e)){return Em(t,s,new fl({pt1:e.getStartXY(),pt2:e.getEndXY()}),i,r,n,o,a,h,!m)}if(em(s)){return Em(t,e,new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,m)}return h?Jr(e,s,0,o,a)?1:0:$r(e,s,0,o,i,n,r,a,m)}function Dm(e,s,i,n,r){if(0===e.m_semiMajorAxis)return i.vmin;let o=os.getNAN();e.queryCoord2D(i.vmin,o);let a=os.getNAN();if(e.queryCoord2D(i.vmax,a),em(e)){return new fl({pt1:o,pt2:a}).getClosestCoordinate(s,n)}const h=Yh(e,s);if(o=Yh(e,o),a=Yh(e,a),1===e.m_minorMajorRatio){if(h.isEqual(0,0))return i.vmin;const t=kh(e,Math.atan2(h.y,h.x));if(n||i.containsCoordinate(t))return t;return os.distance(h,o)<=os.distance(h,a)?i.vmin:i.vmax}const m=e.getSemiMajorAxis(),u=e.getSemiMinorAxis(),l=(m-u)*(m+u),c=ce(l),d=h.x,_=h.y,g=ce(u*_),p=u*l*_*2,f=[new Wt(g),new Wt(p),new Wt(c-ce(m*d)-g),new Wt(-p),new Wt(-c)],x=Ue(Wt,4),y=Lr(f,4,new kt(-1,1),!1,x,4);let v=i.vmin,P=os.sqrDistance(h,o);{const t=os.sqrDistance(h,a);t<P&&(v=i.vmax,P=t)}t(!n);let b=new Array(8);for(let t=0;t<y;++t){const s=x[t].value(),i=Math.sqrt(1-s*s),n=Math.atan2(s,i),r=Math.atan2(s,-i);b[2*t]=kh(e,n),b[2*t+1]=kh(e,r)}b=b.slice(0,2*y),Be(b);for(let t=0,E=2*y;t<E;++t)if(b[t]>i.vmin&&b[t]<i.vmax){const i=os.sqrDistance(s,e.getCoord2D(b[t]));P>i&&(P=i,v=b[t])}return v}function Sm(e,s,i){return t(0),!1}function wm(e,s,i){t(!em(e));const n=new cn;n.setRotateAngle(-e.getAxisXRotation());const r=new os;n.queryTransform(s,r);const o=Math.atan2(-r.x*e.getMinorMajorRatio(),r.y),a=o+Et();let h=kh(e,o),m=kh(e,a);m<h&&(m=Ve(h,h=m));let u=0;return h>=0&&h<=1&&(i[u++]=h),m>=0&&m<=1&&(i[u++]=m),u}function Am(e,s,i){t(0)}function Tm(t,e,s,i){const n=t.getStartXY(),r=t.getEndXY(),o=n.equals(r),a=e.equals(s);if(!o&&!a){const i=new cn;i.setShiftCoords(-t.m_XStart,-t.m_YStart);const o=os.distance(e,s),a=os.distance(n,r),h=o/a;i.scale(h,h);const m=r.sub(n);m.divThis(a);const u=s.sub(e);u.divThis(o);const l=m.crossProduct(u),c=u.dotProduct(m);return i.rotate(c,l),i.shiftCoords(e.x,e.y),rm(t,i,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,void(t.m_YEnd=s.y)}const h=new os;if(t.queryCoord2D(.5,h),a){if(o){const i=t.m_center.add(e.sub(n));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),i),t.setProjectionBehavior(0)}else if(t.isMajor()){const i=h.sub(e).getUnitVector().mul(2*t.getSemiMajorAxis()).add(e);t.constructCircularArcThreePoint(e,s,i)}else t.constructCircularArcThreePoint(e,s,e);return}const m=e.add(s).mul(.5),u=s.sub(e);u.rightPerpendicularThis();const l=m.add(u),c=os.getClosestCoordinate(m,l,t.getCenter(),!0),d=new os;le(m,l,c,d);const _=os.distance(e,d);t.constructEllipticArcEndPointsCenter(e,s,_,1,0,!0,!t.isClockwise(),d),t.setProjectionBehavior(0)}function Im(e,s,i,n){const r=e.getStartXY(),o=e.getEndXY(),a=r.equals(o),h=s.equals(i);if(!a&&!h){const t=new cn;return t.initializeFromTwoPoints(r,o,s,i),rm(e,t,!0),e.m_XStart=s.x,e.m_YStart=s.y,e.m_XEnd=i.x,e.m_YEnd=i.y,e.endPointModified(),void e.normalizeAfterEndpointChange()}if(!e.isMajor())return void tm(e,s,i,1);if(a&&h){const t=e.m_center.add(s.sub(r));return void e.constructEllipticArcEndPointsCenter(s,i,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),t)}if(!a){const t=.5*(Ct()-Math.abs(e.getSweepAngle())),n=(e.getSweepAngle()+t*ge(e.getSweepAngle()))/e.getSweepAngle(),r=new os;e.queryCoord2D(n,r),e.constructEllipticArcEndPointsCenter(r,r,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),e.getCenter());const o=e.getCenter().add(s.sub(r));return void e.constructEllipticArcEndPointsCenter(s,i,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),o)}const m=os.sqrDistance(s,i);let u=.25,l=.75;if(m<os.sqrDistance(e.getCoord2D(.25),e.getCoord2D(.75))){const s=[0],i=Dr(new Rh(e,m),kt.construct(0,.25),1,s);i>0&&(t(1===i),u=s[0],l=1-s[0])}const c=e.getCoord2D(u),d=e.getCoord2D(l);t(!c.equals(d)),e.constructEllipticArcEndPointsCenter(c,d,e.getSemiMajorAxis(),e.getMinorMajorRatio(),e.getAxisXRotation(),!0,!e.isClockwise(),e.m_center),Im(e,s,i)}class Nm{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function Mm(t){return qm(t.calculateUpperLength2D())}function qm(t){return 256*yt()*t}function Rm(t,e,s=!1){e[1].setCoords(t.m_cp[0].x-t.getStartX(),t.m_cp[0].y-t.getStartY()),e[1].mulThis(3),e[2].setCoords(t.m_cp[1].x-t.m_cp[0].x,t.m_cp[1].y-t.m_cp[0].y),e[2].mulThis(3),e[3]=t.getEndXY().sub(t.getStartXY()),e[3].subThis(e[2]),e[2].subThis(e[1]),s?e[0].setCoords(0,0):e[0]=t.getStartXY()}function Fm(t,e,s){const i=Ue(os,4);t.queryControlPoints(i),Xm(i,e,s)}function Ym(t,e,s){const i=Ue(os,4);t.queryControlPoints(i),Lm(i,e,s)}function Xm(t,e,s){let i=t[1].x;i-=t[0].x,i*=3;let n=t[2].x;n-=t[1].x,n*=3;let r=t[3].x;r-=t[0].x,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].x)}function Lm(t,e,s){let i=t[1].y;i-=t[0].y,i*=3;let n=t[2].y;n-=t[1].y,n*=3;let r=t[3].y;r-=t[0].y,r-=n,n-=i,e[3].setWithEps(r),e[2].setWithEps(n),e[1].setWithEps(i),s?e[0].set(0):e[0].set(t[0].y)}function zm(t,e,s){const i=t[0],n=t[1],r=t[2],o=t[3];e[1].setDouble(n.x),e[1].subDoubleThis(i.x),e[1].mulDoubleThis(3),e[2].setDouble(r.x),e[2].subDoubleThis(n.x),e[2].mulDoubleThis(3),e[3].setDouble(o.x),e[3].subDoubleThis(i.x),e[3].subThis(e[2]),e[2].subThis(e[1]),e[0].setDouble(i.x),s[1].setDouble(n.y),s[1].subDoubleThis(i.y),s[1].mulDoubleThis(3),s[2].setDouble(r.y),s[2].subDoubleThis(n.y),s[2].mulDoubleThis(3),s[3].setDouble(o.y),s[3].subDoubleThis(i.y),s[3].subThis(s[2]),s[2].subThis(s[1]),s[0].setDouble(i.y)}function Vm(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Vm(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=km(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=Mm(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let m=1,u=n.specialPointsCount();m<u;m++){const s=n.specialPoints[m];if(a+=Vu(t,h,Math.min(e,s),o,r),e<=s)break;h=s}return i&&(n.length=a),a}function Bm(t,e,s){const i=Vm(t,1,!1);if(e<=0)return e;if(e>=i)return e-i+1;const n=[0];return 1!==Dr(new Lu(t,e),kt.unit(),1,n)&&E(""),n[0]}function km(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Nm,s=Ue(Wt,8),i=Ue(os,4);t.queryControlPoints(i);const n=Ru(i,s);e.specialPoints=[];for(let r=0;r<n;r++)e.specialPoints.push(s[r].value());return Wm(t,e),e}function Gm(t){let e=null;return e=t.m_cachedValues,e}function Wm(t,e){t.m_cachedValues=e}function Zm(t){t.m_cachedValues=null}function Hm(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const n=!!i&&t.isMonotoneQuickAndDirty(),r=new cn,o=Ue(os,3);o[0].setCoords(t.m_XStart,t.m_YStart),o[2].setCoords(t.m_XEnd,t.m_YEnd);const a=new os;a.setSub(o[2],o[0]),a.leftPerpendicularThis(),o[1].setAdd(o[0],a);const h=Ue(os,3);h[0].setCoordsPoint2D(e),h[2].setCoordsPoint2D(s),a.setSub(h[2],h[0]),a.leftPerpendicularThis(),h[1].setAdd(h[0],a),r.setFromTwoTriangles(o,h)?r.transformPoints(t.m_cp,2,t.m_cp):(le(e,s,1/3,t.m_cp[0]),le(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),n&&su(t)}function Om(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}function jm(t,e,s,i){const n=new Array(18),r=Ue(os,4);t.queryControlPoints(r);const o=Dr(new wu(r,e),kt.construct(s,i),18,n),a=new os;t.queryCoord2D(s,a);let h=s,m=os.distance(a,e);const u=new os;t.queryCoord2D(i,u);const l=os.distance(u,e);l<m&&(m=l,h=i,a.assign(u));for(let c=0;c<o;c++){t.queryCoord2D(n[c],u);const s=os.distance(u,e);s<m&&(m=s,h=n[c],a.assign(u))}return Om(s,i,h,m,a)}function Um(e,s){const i=Ue(Wt,4);Fm(e,i,!0);const n=Ue(Wt,4);Ym(e,n,!0);const r=i[3].clone(),o=i[2].clone(),a=i[1].clone(),h=n[3].clone(),m=n[2].clone(),u=n[1].clone(),l=o.mulE(a).addE(m.mulE(u)).mul(4),c=o.mulE(o).mul(8).addE(r.mulE(a).mul(12)).addE(m.mulE(m).mul(8).addE(h.mulE(u).mul(12))),d=r.mulE(o).addE(h.mulE(m)).mul(36),_=r.mulE(r).addE(h.mulE(h)).mul(36),g=Ue(Wt,3),p=Xr(_,d,c,l,new kt(0,1),!1,g);if(t(p<=3),p>0){const t=tu(e,1,0).sqrLength(),i=tu(e,1,1).sqrLength();let n=t;s.set(0),n<i&&(n=i,s.set(1));for(let r=0;r<p;r++){const t=tu(e,1,g[r].value()).sqrLength();t<n&&(n=t,s=g[r])}}}function Qm(t,e,s,i){if(1===e){const e=1-s,n=e*e,r=s*s,o=t[1].sub(t[0]),a=t[2].sub(t[1]),h=t[3].sub(t[2]),m=o.mul(n).add(a.mul(2*e*s)).add(h.mul(r));i.assign(m.mul(3))}else if(2===e){const e=1-s,n=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[3].sub(t[2]).sub(t[2].sub(t[1])),o=n.mul(e).add(r.mul(s));i.assign(o.mul(6))}else if(3===e){const e=t[2].sub(t[1]),s=t[3].sub(e.mul(3)).sub(t[0]);i.assign(s.mul(6))}else i.setCoords(0,0)}function Km(t,e,s,i){{const e=Qt.subE(s),n=e.sqr(),r=s.sqr(),o=t[1].subE(t[0]).mulE(n).addE(t[2].subE(t[1]).mulE(new Wt(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(r));i.setE(o.mulE(new Wt(3)))}}function $m(t,e,s){const i=new os;return Qm(t,e,s,i),i}function Jm(t,e,s){const i=[Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2]),Ai.constructPoint2D(t[3])],n=new Ai;return Km(i,e,s,n),n}function tu(t,e,s){const i=Ue(os,4);return t.queryControlPoints(i),$m(i,e,s)}function eu(t){const e=t.m_cp[0].sub(t.getStartXY()),s=t.m_cp[1].sub(t.m_cp[0]),i=t.getEndXY().sub(t.getStartXY());e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e);return(3*i.x*(2*s.y+5*e.y)-3*i.y*(2*s.x+5*e.x)+10*(s.x*e.y-s.y*e.x))/60}function su(t){const e=Ue(os,4);t.queryControlPoints(e);const s=iu(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function iu(t){let e=!1;for(let s=0;s<2;s++){const i=j(t[0][s],t[3][s]);i>0?(j(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),j(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),j(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),j(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?(j(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),j(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),j(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),j(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),j(t[1][s],t[2][s])>0&&(t[2][s]=t[1][s],e=!0)):t[1][s]===t[0][s]&&t[2][s]===t[0][s]||(t[1][s]=t[0][s],t[2][s]=t[0][s],e=!0)}return e}function nu(t){const e=j(t[0].y,t[1].y),s=j(t[1].y,t[2].y),i=j(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=j(t[0].x,t[1].x),s=j(t[1].x,t[2].x),i=j(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}function ru(t,e,s){const i=new os,n=new os,r=new os,o=new os,a=new os;e<=.5?(ee(2,t[0],t[1],e,i),ee(2,t[1],t[2],e,n),ee(2,t[2],t[3],e,r),ee(2,i,n,e,o),ee(2,n,r,e,a),ee(2,o,a,e,s)):(se(2,t[0],t[1],e,i),se(2,t[1],t[2],e,n),se(2,t[2],t[3],e,r),se(2,i,n,e,o),se(2,n,r,e,a),se(2,o,a,e,s))}function ou(e,s,i,n){t(s>=0&&s<=1);const r=new os,o=new os,a=new os,h=new os,m=new os,u=new os;s<=.5?(ee(2,e[0],e[1],s,r),ee(2,e[1],e[2],s,o),ee(2,e[2],e[3],s,a),ee(2,r,o,s,h),ee(2,o,a,s,m),ee(2,h,m,s,u)):(se(2,e[0],e[1],s,r),se(2,e[1],e[2],s,o),se(2,e[2],e[3],s,a),se(2,r,o,s,h),se(2,o,a,s,m),se(2,h,m,s,u)),nu(e);const l=e[3].clone();i&&(i[0].assign(e[0]),i[1].assign(r),i[2].assign(h),i[3].assign(u)),n&&(n[0].assign(u),n[1].assign(m),n[2].assign(a),n[3].assign(l))}function au(e,s,i,n){if(t(s>=0&&i<=1&&s<=i),s===i){const t=new os;return hu(e,s,t),n[0].assign(t),n[1].assign(t),n[2].assign(t),void n[3].assign(t)}if(0===s&&1===i){for(let t=0;t<4;++t)n[t].assign(e[t]);return}const r=Ue(os,4);ou(e,i,r,null),ou(r,i>0?s/i:0,null,r),hu(e,s,r[0]),hu(e,i,r[3]),n[0].setCoordsPoint2D(r[0]),n[1].setCoordsPoint2D(r[1]),n[2].setCoordsPoint2D(r[2]),n[3].setCoordsPoint2D(r[3])}function hu(t,e,s,i){if(i){if(e<0){return void On(new fl({pt1:t[0],pt2:t[0].add(lu(t,0).getUnitVector())}),e,s)}if(e>1){return void On(new fl({pt1:t[3],pt2:t[3].add(lu(t,1).getUnitVector())}),e-1,s)}}if(e<=.5){const i=new os;ee(2,t[0],t[1],e,i);const n=new os;ee(2,t[1],t[2],e,n);const r=new os;ee(2,t[2],t[3],e,r);const o=new os;ee(2,i,n,e,o);const a=new os;ee(2,n,r,e,a),ee(2,o,a,e,s)}else{const i=new os;se(2,t[0],t[1],e,i);const n=new os;se(2,t[1],t[2],e,n);const r=new os;se(2,t[2],t[3],e,r);const o=new os;se(2,i,n,e,o);const a=new os;se(2,n,r,e,a),se(2,o,a,e,s)}}function mu(t,e,s){if(e.value()<=.5){const i=new Ai;oe(2,Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),e,i);const n=new Ai;oe(2,Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2]),e,n);const r=new Ai;oe(2,Ai.constructPoint2D(t[2]),Ai.constructPoint2D(t[3]),e,r);const o=new Ai;oe(2,i,n,e,o);const a=new Ai;oe(2,n,r,e,a),oe(2,o,a,e,s)}else{const i=new Ai;ae(2,Ai.constructPoint2D(t[0]),Ai.constructPoint2D(t[1]),e,i);const n=new Ai;ae(2,Ai.constructPoint2D(t[1]),Ai.constructPoint2D(t[2]),e,n);const r=new Ai;ae(2,Ai.constructPoint2D(t[2]),Ai.constructPoint2D(t[3]),e,r);const o=new Ai;ae(2,i,n,e,o);const a=new Ai;ae(2,n,r,e,a),ae(2,o,a,e,s)}}function uu(t,e,s){const i=Ue(os,4);t.queryControlPoints(i),mu(i,e,s)}function lu(t,e){const s=Pt(e,0,1);let i=$m(t,1,s);return i||(i=$m(t,2,s),i?1===s&&i.negateThis():i=$m(t,3,s)),i}function cu(t,e,s){const i=Ue(os,4);t.queryControlPoints(i),du(i,e,s)}function du(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(Jm(t,1,e))}function _u(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==yu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function gu(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==vu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function pu(t,e,s,i,n){if(n){if(0!==hl(e,s))return 2}else if(Mi(e,s))return 1;return 0!==Pu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function fu(t,e,s,i,n){if(n){if(0!==hl(e,s))return t?4:2}else if(Mi(e,s))return 1;return 0!==bu(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function xu(e,s,i,n,r){return t(0),0}function yu(t,e,s,i,n,r,o,a,h,m){if(null!==n&&(n.length=0),null!=r&&(r.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],a=e.intersectPoint(s.getStartXY(),t,o);if(a>0){if(null!==n)for(let e=0;e<a;e++)n.push(t[e]);if(null!==r)for(let t=0;t<a;t++)r.push(0);if(null!=i)for(let s=0;s<a;s++){const n=new os;e.queryCoord2D(t[s],n),i.push(n)}}return a}const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=Ue(os,4);Rm(e,l);const c=s.getEndXY();c.subThis(s.getStartXY());const d=c.clone();d.leftPerpendicularThis();let _=3*l[3].dotProduct(d),g=2*l[2].dotProduct(d),p=l[1].dotProduct(d);const f=new Array(15),x=new Array(15);let y=Sr(_,g,p,kt.unit(),!1,f);y<0&&(f[0]=0,f[1]=1,y=2);let v,P=0;for(let C=0,D=P;C<y;++C){const t=e.getCoord2D(f[C+D]);x[P]=s.getClosestCoordinate(t,!1),os.distance(t,s.getCoord2D(x[P]))<=o&&(f[P]=f[C+D],P++)}if(l[0].subThis(s.getStartXY()),Math.abs(c.x)>=Math.abs(c.y)){const t=c.y/c.x;_=l[3].y-l[3].x*t,g=l[2].y-l[2].x*t,p=l[1].y-l[1].x*t,v=l[0].y-l[0].x*t}else{const t=c.x/c.y;_=l[3].x-l[3].y*t,g=l[2].x-l[2].y*t,p=l[1].x-l[1].y*t,v=l[0].x-l[0].y*t}const b=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),E=[0,0,0];y=wr(_,g,p,v,kt.unit(),b,E);for(let C=0,D=P;C<y;++C){f[C+D]=E[C];const t=e.getCoord2D(f[C+D]);x[P]=s.getClosestCoordinate(t,!1);os.distance(t,s.getCoord2D(x[P]))<=o&&(f[P]=f[C+D],P++)}y=e.intersectPoint(s.getStartXY(),E,o);for(let C=0;C<y;C++)f[P]=E[C],x[P++]=0;y=e.intersectPoint(s.getEndXY(),E,o);for(let C=0;C<y;C++)f[P]=E[C],x[P++]=1;return 0!==s.intersectPoint(e.getStartXY(),E,o)&&(x[P]=E[0],f[P++]=0),0!==s.intersectPoint(e.getEndXY(),E,o)&&(x[P]=E[0],f[P++]=1),0===P?0:dl(t,e,s,f,x,P,i,n,r,o,a,h,m)}function vu(t,e,s,i,n,r,o,a,h,m){if(em(s)){return yu(t,e,new fl({pt1:s.getStartXY(),pt2:s.getEndXY()}),i,n,r,o,a,h,m)}const u=Ki(e,s);if($i(e,s,o=Math.max(o,u)))return 0;const l=[],c=[],d=Ue(os,4);{e.queryControlPoints(d);const t=Ue(os,4),i=new cn;s.canonicToWorldTransformation(i);const n=new cn;n.setInvert(i),n.transformPoints(d,4,t);const r=Ue(es,4),a=Ue(es,4);zm(t,r,a);const h=Ue(es,3);h[0].setDouble(s.getSemiMinorAxis()),h[0].sqrThis(),h[1].setDouble(s.getSemiMajorAxis()),h[1].sqrThis(),h[2].setThis(h[0]),h[2].mulThis(h[1]),h[2].negateThis();const m=Eo(r,3,a,3,null,0,h,!0,kt.unit(),kt.unit(),l);if(m>0){let t=0;for(let i=0;i<m;i++){const n=new os;e.queryCoord2D(l[i],n);const r=s.getClosestCoordinate(n,!1),a=new os;s.queryCoord2D(r,a);os.distance(n,a)<=o&&(l[t]=l[i],c.push(r),t++)}l.length=t}}const _=[0,1];for(let g=0;g<2;g++){const t=0===g?s.getStartXY():s.getEndXY(),e=[0];Au(d,t,kt.unit(),!1,-1,1,e);const i=new os;hu(d,e[0],i);os.distance(t,i)<=o&&(l.push(e[0]),c.push(_[g]))}for(let g=0;g<2;g++){const t=[0,3];{const e=s.getClosestCoordinate(d[t[g]],!1),i=new os;s.queryCoord2D(e,i);os.distance(d[t[g]],i)<=o&&(l.push(_[g]),c.push(e))}}return dl(t,e,s,l,c,l.length,i,n,r,o,a,h,m)}function Pu(t,e,s,i,n,r,o,a,h,m){const u=Ue(os,4);e.queryControlPoints(u);const l=Ue(os,4);if(s.queryControlPoints(l),Ji(u,l,4)<0)return Pu(t,s,e,i,r,n,o,a,h,!m);const c=Ki(e,s);if($i(e,s,o=Math.max(o,c)))return 0;if(Bu(e,s,i,n,r,o,a,h,m))return 2;const d=new kt(0,1),_=new kt(0,1);{const t=new Di;Su(u,new kt(0,1),t);const e=new Di;Su(l,new kt(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*o),e.inflate(3*o),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Yu(u,t,d),Yu(l,t,_),d.isEmpty()||_.isEmpty())return 0;au(u,d.vmin,d.vmax,u),au(l,_.vmin,_.vmax,l)}}const g=gl(u,3,l,3,o);if(0===g)return 0;const p=[],f=[];if(-1===g){const t=Ue(es,4),e=Ue(es,4);zm(u,t,e);const s=Ue(es,4),i=Ue(es,4);zm(l,s,i);const n=[],r=[],a=vo(t,3,e,3,null,0,s,3,i,3,null,0,!0,kt.unit(),kt.unit(),n,r);if(a>0)for(let h=0;h<a;h++){const t=new os;hu(l,r[h],t);const e=new os;hu(u,n[h],e);os.distance(e,t)<=o&&(f.push(r[h]),p.push(n[h]))}}for(let x=0;x<2;x++){const t=0===x?u:l,e=0===x?l:u;for(let s=0;s<2;s++){const i=0===s?0:3,n=[0];Au(e,t[i],kt.unit(),!1,-1,1,n);const r=new os;hu(e,n[0],r);os.distance(t[i],r)<=o&&(0===x?(p.push(0===i?0:1),f.push(n[0])):(f.push(0===i?0:1),p.push(n[0])))}}if(0===p.length)return 0;if(!d.equalsRange(0,1))for(let x=0;x<p.length;++x)p[x]=vl.recalculateParentT(d.vmin,d.vmax,p[x]);if(!_.equalsRange(0,1))for(let x=0;x<f.length;++x)f[x]=vl.recalculateParentT(_.vmin,_.vmax,f[x]);return dl(t,e,s,p,f,p.length,i,n,r,o,a,h,m)}function bu(e,s,i,n,r,o,a,h,m,u){const l=Ki(s,i);if(i.isDegenerateToLineHelper(l)){const t=new fl({pt1:i.getStartXY(),pt2:i.getEndXY()}),l=yu(e,s,t,n,r,o,a,h,m,u);if(o)for(let e=0;e<l;++e){const s=t.getCoord2D(o[e]);o[e]=i.getClosestCoordinate(s,!1)}return l}if($i(s,i,a=Math.max(a,l)))return 0;const c=Ue(os,4);s.queryControlPoints(c);const d=Ue(os,3);i.queryControlPoints(d);const _=new kt(0,1),g=new kt(0,1),p=[0,0,0];i.queryWeights(p);const f=[1,Dh(p),1];{const t=new Di;Su(c,new kt(0,1),t);const e=new Di;th(d,f,new kt(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*a),e.inflate(3*a),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Yu(c,t,_),Ch(d,f,t,g),_.isEmpty()||g.isEmpty())return 0;au(c,_.vmin,_.vmax,c),rh(d,f,g.vmin,g.vmax,d,f)}}const x=gl(c,3,d,2,a);if(0===x)return 0;const y=[],v=[];if(-1===x){const t=Ue(es,4),e=Ue(es,4);zm(c,t,e);const s=Ue(es,3),i=Ue(es,3),n=Ue(es,3);fh(d,f,s,i,n);const r=[],o=[],h=vo(s,2,i,2,n,2,t,3,e,3,null,0,!0,kt.unit(),kt.unit(),o,r);if(h>0)for(let m=0;m<h;m++){const t=new os;hu(c,r[m],t);const e=new os;Eh(d,f,o[m],e);os.distance(t,e)<=a&&(y.push(r[m]),v.push(o[m]))}}for(let P=0;P<2;P++){let e,s;0===P?(e=c,s=d):(s=c,e=d);for(let i=0;i<2;i++){const n=0===i?0:e.length-1,r=[0],o=new os;if(0===P){t(1===Qa(s,f,e[n],kt.unit(),!1,-1,1,r)),Eh(s,f,r[0],o)}else{t(1===Au(s,e[n],kt.unit(),!1,-1,1,r)),hu(s,r[0],o)}os.distance(e[n],o)<=a&&(0===P?(y.push(0===n?0:1),v.push(r[0])):(v.push(0===n?0:1),y.push(r[0])))}}if(0===y.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=vl.recalculateParentT(_.vmin,_.vmax,y[t]);if(!g.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=lo.recalculateParentT(g.vmin,g.vmax,v[t]);for(let t=0;t<v.length;++t)v[t]=Sh(p,v[t]);return dl(e,s,i,y,v,y.length,n,r,o,a,h,m,u)}function Eu(e,s,i,n,r,o,a,h,m,u){const l=Ki(s,i);if($i(s,i,a=Math.max(a,l)))return 0;const c=Ue(os,4);s.queryControlPoints(c);const d=Ue(os,3);i.queryControlPoints(d);const _=gl(c,3,d,2,a);if(0===_)return 0;const g=[],p=[];if(-1===_){const t=Ue(es,4),e=Ue(es,4);zm(c,t,e);const n=Ue(es,3),r=Ue(es,3);ha(d,n,r);const o=vo(n,2,r,2,null,0,t,3,e,3,null,0,!0,kt.unit(),kt.unit(),p,g);if(o>0){let t=0;for(let e=0;e<o;e++){const n=new os;s.queryCoord2D(g[e],n);const r=new os;i.queryCoord2D(p[e],r);os.distance(n,r)<=a&&(g[t]=g[e],p[t]=p[e],t++)}g.length=t}}for(let f=0;f<2;f++){let e,s;0===f?(e=c,s=d):(s=c,e=d);for(let i=0;i<2;i++){const n=0===i?0:e.length-1,r=[0],o=new os;if(0===f)jo(s,e[n],r),ma(s,r[0],o);else{t(1===Au(s,e[n],kt.unit(),!1,-1,1,r)),hu(s,r[0],o)}os.distance(e[n],o)<=a&&(0===f?(g.push(0===n?0:1),p.push(r[0])):(p.push(0===n?0:1),g.push(r[0])))}}return dl(e,s,i,g,p,g.length,n,r,o,a,h,m,u)}function Cu(e,s,i,n,r){const o=new Di;if(Du(e,kt.unit(),o),o.inflate(n),!o.isIntersectingPoint2D(s))return 0;const a=km(e);let h=0,m=a.specialPoints[0];const u=[];for(let l=1,c=a.specialPoints.length;l<c;++l){const i=a.specialPoints[l],n=jm(e,s,m,i);if(0===u.length)u.push(n);else if(n.t===n.tmin)t(u.at(-1).d<=n.d),u.at(-1).tmax=n.tmax;else if(u.at(-1).t===u.at(-1).tmax){t(u.at(-1).d>=n.d);const e=u.at(-1).tmin;u[u.length-1]=n,u.at(-1).tmin=e}else u.push(n);m=i}for(const t of u)if(t.d<=n){const e=t.t;i?(h>=i.length&&b(""),i[h]=e,h++):h++}return h}function Du(t,e,s){const i=Ue(os,4);t.queryControlPoints(i),Su(i,e,s)}function Su(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=Ue(os,4);au(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}class wu{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new os;hu(this.controlPoints,e,t);const s=$m(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new os;hu(this.controlPoints,e,t);const s=$m(this.controlPoints,1,e),i=$m(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new os;hu(this.controlPoints,e,t);const s=$m(this.controlPoints,1,e),i=$m(this.controlPoints,2,e),n=$m(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(n)+3*s.dotProduct(i))}case 3:{const t=$m(this.controlPoints,1,e),s=$m(this.controlPoints,2,e),i=$m(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=$m(this.controlPoints,2,e),s=$m(this.controlPoints,3,e);return 2*(10*t.dotProduct(s))}case 5:{const t=$m(this.controlPoints,3,e);return 2*(10*t.dotProduct(t))}default:return 0}}getError(e){return t(0),0}}function Au(e,s,i,n,r,o,a){N(kt.unit().contains(i)&&o>0,"getClosestCoordinate"),(r<0||Number.isNaN(r))&&(r=Number.MAX_VALUE);const h=[],m=new os;hu(e,i.vmin,m);let u=os.distance(m,s);if(u<=r&&h.push(new os(i.vmin,u)),i.vmin!==i.vmax&&(hu(e,i.vmax,m),u=os.distance(m,s),u<=r&&h.push(new os(i.vmax,u))),i.width()>0){const t=new Array(18),n=Dr(new wu(e,s),i,18,t);for(let i=0;i<n;i++)hu(e,t[i],m),u=os.distance(m,s),u>r||h.push(new os(t[i],u))}if(n){t(i.equals(kt.unit()));{hu(e,-1,m,!0);const t=new os;hu(e,0,t);const i=new fl({pt1:m,pt2:t}),n=i.getClosestCoordinate(s,!0);n<1&&(m.assign(i.getCoord2D(n)),u=os.distance(m,s),u<=r&&h.push(new os(n-1,u)))}{hu(e,2,m,!0);const t=new os;hu(e,i.vmax,t);const n=new fl({pt1:t,pt2:m}),o=n.getClosestCoordinate(s,!0);o>0&&(m.assign(n.getCoord2D(o)),u=os.distance(m,s),u<=r&&h.push(new os(1+o,u)))}}if(!h.length)return 0;h.sort(((t,e)=>t.compare(e)));let l=0;const c=h[0].x;if(a[l++]=c,l<o){const t=Js(e,4,!1).total(),s=h[0].y;for(let e=1,i=h.length;e<i;e++)if(h[e].y>s+t){h.length=e;break}h.sort(((t,e)=>We(t.x,e.x))),l=0,a[l++]=h[0].x;for(let e=1,i=h.length;e<i;e++)h[e].x!==a[l-1]&&l<o&&(a[l++]=h[e].x)}return l}function Tu(t,e,s,i,n,r,o){const a=Ue(os,4);return t.queryControlPoints(a),Au(a,e,s,i,n,r,o)}function Iu(t){return t.getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1)}function Nu(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}function Mu(e,s,i){if(t(i>=2),2===i){const t=new os;le(s[0],s[i-1],1/3,t);const n=new os;return le(s[0],s[i-1],2/3,n),void e.construct(s[0],t,n,s[i-1])}const n=s[0],r=s[i-1],o=[0,0],a=Tu(e,n,kt.unit(),!1,Number.NaN,2,o),h=[0,0],m=Tu(e,r,kt.unit(),!1,Number.NaN,2,h),u=[];for(let t=0;t<a;t++)for(let a=0;a<m;a++){const m=o[t],l=h[a],c=(t,o)=>{const a=[];a.length=i-2;const h=()=>{let t=0;for(let e=1,n=i-1;e<n;e++){t+=os.distance(s[e-1],s[e]);const i=t;a[e-1]=i}t+=os.distance(s[i-2],s[i-1]);for(let e=1,s=i-1;e<s;e++)a[e-1]/=t};let u=!1,c=!1;{const s=new xl;m<=l?(e.queryCut(m,l,s,!0),t.assign(s.get().getControlPoint1()),o.assign(s.get().getControlPoint2())):(e.queryCut(l,m,s,!0),t.assign(s.get().getControlPoint2()),o.assign(s.get().getControlPoint1())),n.equals(t)&&(u=!0),r.equals(o)&&(c=!0)}h();let d=Number.MAX_VALUE;const _=t.clone(),g=o.clone();for(let e=0;e<5;e++){d=ku(!0,!1,n,_,g,r,u,c,a,i-2,s,i)}for(let e=0;e<30;e++){const t=_.clone();g.clone();const e=ku(!0,!0,n,_,g,r,u,c,a,i-2,s,i);if(d<=e&&t.equals(_)&&t.equals(g))break;d=e}h();let p=!1,f=Number.EPSILON;const x=t.clone(),y=o.clone();for(let e=0;e<30;e++){const t=x.clone();y.clone();const e=ku(p,!0,n,x,y,r,u,c,a,i-2,s,i);if(f<=e&&t.equals(x)&&t.equals(y))break;p=!0,f=e}return f<d?(t.assign(x),o.assign(y)):(t.assign(_),o.assign(g),f=d),f},d=new os,_=new os,g=[c(d,_),os.distance(n,d)+os.distance(d,_)+os.distance(_,r),d.x,d.y,_.x,_.y];u.splice(u.length,0,...g)}let l=u[0],c=u[1],d=0;for(let t=6;t<u.length;t+=6)u[t]<l&&(l=u[t],c=u[t+1],d=t);let _=d;for(let t=0;t<u.length;t+=6)t!==d&&u[t+1]<c&&Math.abs(l-u[t])<10*l&&(c=u[t+1],_=t);e.construct(n,new os(u[_+2],u[_+3]),new os(u[_+4],u[_+5]),r)}function qu(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),n=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),r=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),o=Ue(Wt,2);let a=Yr(r,n,i,new kt(0,1),!1,o);a<0&&(a=0);let h=0;for(let m=0;m<a;m++)vt(o[m].value(),0,1)||(s[h].setE(o[m]),h++);return h}function Ru(e,s){s[0].set(0);let i=1;const n=Ue(Wt,4);Xm(e,n,!0);const r=Ue(Wt,4);Lm(e,r,!0);{const t=n[3].mul(3),e=n[2].mul(2),r=n[1].clone(),o=Ue(Wt,2);let a=Yr(t,e,r,new kt(0,1),!1,o);a<0&&(a=0);for(let n=0;n<a;n++)vt(o[n].value(),0,1)||(s[i]=o[n],i++)}{const t=r[3].mul(3),e=r[2].mul(2),n=r[1].clone(),o=Ue(Wt,2);let a=Yr(t,e,n,new kt(0,1),!1,o);a<0&&(a=0);for(let r=0;r<a;r++)vt(o[r].value(),0,1)||(s[i]=o[r],i++)}if(i+=qu(n,r,s.slice(i)),s[i].set(1),i++,i>2){Ge(s,i,((t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0}));let t=0;const n=s[0].clone();let r=0;const o=Nu(e)*yt(),a=new os;ru(e,s[0].value(),a);for(let h=1;h<i;h++){const i=new os;if(ru(e,s[h].value(),i),s[h].eq(n)||i.isEqualPoint2D(a,o)){if(0!==t){if(0===s[h].eps())n.setE(s[h]),r=0;else if(0!==r){const t=ce(1/s[h].eps()),e=1/r,i=t+e;n.set((s[h].value()*t+n.value()*e)/i),r=1/i,n.setError(Math.sqrt(r))}s[t].setE(n),ru(e,n.value(),a)}}else t++,s[t].setE(s[h]),n.setE(s[h]),ru(e,n.value(),a),r=ce(s[h].eps())}t++,i=t}return 1===i&&(i=2,s[1].set(1)),t(0===s[0].value()),t(1===s[i-1].value()),i}function Fu(t,e,s,i,n){const r=Ue(Wt,4),o=Ue(Wt,3),a=new kt(0,1);let h=0;if(e){if(Lm(t,r,!1),h=Xr(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new os;hu(t,o[m].value(),e),i[m]=e.x}}else if(Xm(t,r,!1),h=Xr(r[3],r[2],r[1],r[0].sub(s),a,!1,o),i)for(let m=0;m<h;m++){const e=new os;hu(t,o[m].value(),e),i[m]=e.y}if(n)for(let m=0;m<h;m++)n[m]=o[m].value();else i&&Ge(i,h,We);return h}function Yu(t,e,s){s.setEmpty();const i=[];i.push(new kt(0,1));const n=.5*Math.max(e.width(),e.height());for(;i.length;){const r=i.at(-1);i.pop();const o=new Di;if(Su(t,r,o),o.isIntersectingW(e)){const t=Math.max(o.width(),o.height());if(e.containsW(o)||t<=n||r.width()<1e-12)s.merge(r);else{const t=r.getCenter();i.push(kt.construct(r.vmin,t)),i.push(kt.construct(t,r.vmax))}}}}function Xu(t,e,s){s.length=0;{const e=new Wt;Um(t,e);const i=new Ai;if(cu(t,e,i),i.isZero())return e.isZero()||e.eq(new Wt(1))?0:(s.push(e.value()),1)}const i=Ue(Wt,4);Fm(t,i,!0);const n=Ue(Wt,4);Ym(t,n,!0);const r=Ue(Wt,6),o=i[3].negate().mulE(n[1]).addE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),a=i[3].negate().mulE(n[1]).subE(i[2].mulE(n[2]).mul(2)).addE(i[1].mulE(n[3])),h=i[2].mulE(i[2]).subE(n[2].mulE(n[2]));r[0]=n[1].mulE(n[1]).mulE(o).addE(i[1].mulE(i[1]).mulE(a)).addE(i[1].mulE(n[1]).mulE(h).mul(2)).mul(6),r[1]=i[2].mulE(n[1]).subE(i[1].mulE(n[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(n[2].mulE(n[2])).addE(n[1].mulE(n[3]).mul(2))).mul(24);const m=i[1].mulE(n[2]).mulE(n[2]).mulE(n[3]),u=i[2].mulE(i[2]).mulE(i[3]).mulE(n[1]).subE(m).mul(156),l=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),c=i[3].mulE(n[1]).subE(i[1].mulE(n[3])),d=i[1].mulE(i[3]).mulE(c).addE(n[1].mulE(n[3]).mulE(l)).mul(72),_=n[1].mulE(n[3]).subE(i[1].mulE(i[3])),g=i[2].mulE(n[2]).mulE(_).mul(120),p=i[1].mulE(i[2]).mulE(i[2]).mulE(n[3]),f=i[3].mulE(n[1]).mulE(n[2]).mulE(n[2]).subE(p).mul(36);r[2]=u.addE(d).addE(g).addE(f);const x=i[2].mulE(i[3]).mulE(i[3]).mulE(n[1]).subE(i[1].mulE(n[2]).mulE(n[3]).mulE(n[3])).mul(360),y=i[2].mulE(n[2]).mulE(i[2].mulE(i[3]).subE(n[2].mulE(n[3]))).addE(i[3].mulE(n[2]).mulE(n[2]).mulE(n[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(n[3])).mul(24),v=i[2].mulE(n[1]).mulE(n[3]).mulE(n[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(n[2])).mul(72),P=i[3].mulE(n[3]).mulE(n[1].mulE(n[2]).subE(i[1].mulE(i[2]))).mul(288);r[3]=x.addE(y).addE(v).addE(P),r[4]=n[3].mulE(n[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(n[1]).subE(i[1].mulE(n[3]))).mul(270).addE(i[3].mulE(n[2]).subE(i[2].mulE(n[3]))).mulE(i[2].mulE(i[3]).addE(n[2].mulE(n[3]))).mul(180),r[5]=i[3].mulE(n[2]).subE(i[2].mulE(n[3])).mulE(i[3].mulE(i[3]).addE(n[3].mulE(n[3]))).mul(216);const b=Ue(Wt,5),E=Lr(r,5,new kt(0,1),!1,b,5);if(E>0){let i=Math.abs(t.getCurvature(0)),n=0;const r=Math.abs(t.getCurvature(1));(r>i||!Number.isFinite(r))&&(n=1);for(let e=0;e<E;e++){const s=Math.abs(t.getCurvature(b[e].value()));t.getCoord2D(b[e].value()),(s>i||!Number.isFinite(s))&&(i=s,n=b[e].value())}if((!Number.isFinite(i)||1/i<e)&&!vt(n,0,1)){const e=t.getCoord2D(n);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(n),1}}return 0}class Lu{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Vm(this.b,e,!1):0}getError(e){return t(0),0}}function zu(e,s,i,n,r,o,a){for(;;){const h=os.distance(s[0],s[3]),m=os.distance(s[0],s[1])+os.distance(s[1],s[2])+os.distance(s[2],s[3]);if(m-h<=n+i*m)return e+he(h,m,.5);const u=t=>$m(s,1,t).length();if(0===o){t(a<8);let h=u(0),l=u(1);r[0]+=2,h>l&&(l=Ve(h,h=l),s[3]=Ve(s[0],s[0]=s[3]),s[2]=Ve(s[1],s[1]=s[2]));let c=h/(h+l),d=1,_=m;for(;c<1/32&&_>=32*(n+i*_);){d/=4;const t=u(d);r[0]++,c=h/(t+h);const e=new os;if(hu(s,.5*d,e),_=os.distance(e,s[0]),_<=n){const t=new os;hu(s,d,t),_+=os.distance(t,e)}}if(1!==d){const t=Ue(os,4);ou(s,d,s,t),e=zu(e,t,i,n,r,0,a+1),o++,a++;continue}}const l=8;r[0]+=l;const c=va(l,u,0,1),d=16;r[0]+=d;const _=va(d,u,0,1);let g=Math.abs(c-_)>n+i*m;if(!g)return e+_;if(o<3){const t=Ue(os,4);ou(s,.5,s,t),e=zu(e,t,i,n,r,o+1,a+1),o++,a++;continue}const p=32;r[0]+=p;const f=va(p,u,0,1);if(g=Math.abs(_-f)>n+i*m,!g)return e+f;const x=64;r[0]+=x;const y=va(x,u,0,1);if(g=Math.abs(f-y)>n+i*m,!g)return e+y;const v=128;r[0]+=v;const P=va(v,u,0,1);return g=Math.abs(y-P)>n+i*m,e+P}}function Vu(t,e,s,i,n){if(s===e)return 0;const r=Ue(os,4);t.queryControlPoints(r);const o=Ue(os,4);au(r,e,s,o);return zu(0,o,i,n,[0],0,0)}function Bu(t,e,s,i,n,r,o,a,h){const m=Ue(os,4);t.queryControlPoints(m);const u=Ue(os,4);if(e.queryControlPoints(u),m[0].equals(u[0])){if(m[1].equals(u[1])&&m[2].equals(u[2])&&m[3].equals(u[3]))return s&&(s.length=0,s.push(m[0]),s.push(m[3])),i&&(i.length=0,i.push(0),i.push(1)),n&&(n.length=0,n.push(0),n.push(1)),!0;if(!m[0].equals(u[3]))return!1}return!!(m[0].equals(u[3])&&m[1].equals(u[2])&&m[2].equals(u[1])&&m[3].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),h&&(i[1]=Ve(i[0],i[0]=i[1]))),n&&(n.length=0,n.push(1),n.push(0),h&&(n[1]=Ve(n[0],n[0]=n[1]))),s&&(s.length=0,s.push(m[0]),s.push(m[3]),h&&(s[1]=Ve(s[0],s[0]=s[1]))),!0)}function ku(t,e,s,i,n,r,o,a,h,m,u,l){let c=0,d=0,_=0,g=0,p=0,f=0,x=0;for(let v=1,P=l-1;v<P;v++){let e,o,a,m,l,y,P=-1,b=h[v-1];t&&(v>2?(b=Pt(2*h[v-2]-h[v-3],0,1),h[v-1]=b):2===v&&b<=h[0]&&(b=h[0]));for(let c=0;c<11&&(e=h[v-1],o=e*e,a=o*e,m=1-e,l=m*m,y=l*m,t)&&!(Math.abs(e-P)<1e-12)&&10!==c;c++){const t=s.x-2*i.x+n.x,a=s.x-3*i.x+3*n.x-r.x,m=s.y-2*i.y+n.y,c=s.y-3*i.y+3*n.y-r.y,d=s.x-i.x-2*t*e+a*o,_=-u[v].x+s.x*y+e*(3*i.x*l+e*(3*n.x-3*n.x*e+r.x*e)),g=s.y-i.y-2*m*e+c*o,p=-u[v].y+s.y*y+e*(3*i.y*l+e*(3*n.y-3*n.y*e+r.y*e));P=e;const f=e- -6*(d*_+g*p)/(6*(3*ce(d)-(-2*t+2*a*e)*_)+6*(3*ce(g)-(-2*m+2*c*e)*p));h[v-1]=Pt(f,v>1?h[v-2]:0,1)}c+=3*o*l*l,d+=3*a*y,_+=3*o*o*l;const E=-(y*s.x+a*r.x-u[v].x);g+=E*e*l,p+=E*o*m;const C=-(y*s.y+a*r.y-u[v].y);f+=C*e*l,x+=C*o*m}if(e){const t=c*_-d*d;Math.abs(t)>=1e-12*(Math.abs(c*_)+Math.abs(d*d))+1e-10?(o||(i.x=(g*_-p*d)/t,i.y=(f*_-x*d)/t),a||(n.x=(c*p-d*g)/t,n.y=(c*x-d*f)/t)):(le(s,r,.3,i),le(s,r,.6,n))}let y=0;for(let v=1,P=l-1;v<P;v++){const t=h[v-1],e=1-t,o=s.mul(de(e)),a=i.mul(3*t*e*e),m=n.mul(3*t*t*e),l=r.mul(de(t));y+=o.add(a).add(m).add(l).sub(u[v]).sqrLength()}return y}class Gu{constructor(t,e){this.m_index=-1,this.gc=t,this.dim=e}next(){for(;;){if(this.m_index>=this.gc.getGeometryCount())return null;if(this.m_index++,this.m_index===this.gc.getGeometryCount())return null;const t=this.gc.getGeometry(this.m_index);if(-1===this.dim||1<<t.getDimension()&this.dim)return t}return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class Wu{constructor(e){t(0)}assignCopy(e){return t(0),this}assignMove(e){return t(0),this}getGeometryCount(){return t(0),0}reserve(e){t(0)}addGeometry(e){t(0)}addGeometryMove(e){t(0)}addCursor(e){t(0)}getGeometry(e){return t(0),new Ci}static generateGeometryCursor(t,e=-1){return new Gu(t,e)}modifiedElementIndex(e){t(0)}modifiedElement(e){t(0)}getGeometryType(){return r.enumGeometryCollection}getDimension(){return t(0),0}getDescription(){return t(0),new gs(1)}assignVertexDescription(e){t(0)}mergeVertexDescription(e){t(0)}hasAttribute(e){return t(0),!1}addAttribute(e){t(0)}dropAttribute(e){t(0)}dropAllAttributes(){t(0)}queryInterval(e,s){return t(0),new kt(0,0)}queryEnvelope(e){t(0)}queryLooseEnvelope(e){t(0)}isEmpty(){return t(0),!1}setEmpty(){t(0)}applyTransformation(e){t(0)}transformAttribute(e,s,i,n,r){t(0)}createInstance(){return t(0),this}copyTo(e){t(0)}calculateArea2D(){return t(0),0}calculateLength2D(){return t(0),0}calculateLength3D(e){return t(0),0}getBoundary(){return t(0),this}clone(){return t(0),this}equals(e,s){return t(0),!1}swap(e){t(0)}setAttributeBasic(e,s,i){t(0)}replaceNaNs(e,s){t(0)}getImpl(){return this}vertexCount(){return t(0),0}hasNonLinearSegments(){return t(0),!1}mergeVertexDescriptionImpl(e){t(0)}}function Zu(e,s){let i=s,n=null;i||(n=d(e)?vs.getDefaultDescription3D():vs.getDefaultDescription2D(),i=n);let o=null;switch(e){case r.enumPoint:o=new Ci({vd:i});break;case r.enumLine:o=new fl({vd:i});break;case r.enumBezier:o=new vl({vd:i});break;case r.enumEllipticArc:o=new jr({vd:i});break;case r.enumRationalBezier2:o=new lo({vd:i});break;case r.enumBezier2:o=new go({vd:i});break;case r.enumEnvelope:o=new Cs({vd:i});break;case r.enumMultiPoint:o=new dn({vd:i});break;case r.enumPolyline:o=new cr({vd:i});break;case r.enumPolygon:o=new Ur({vd:i});break;case r.enumMultipatch:t(0);break;case r.enumGeometryCollection:o=new Wu({vd:i});break;default:f("Geometry.create")}return o}Wu.type=r.enumGeometryCollection;var Hu=gs;const Ou=-1,ju=1;class Uu{constructor(t){this.m_shape=t}userSort(t,e,s){this.m_shape.sortVerticesSimpleByYHelper(s,t,e)}getValue(t){return this.m_shape.getY(t)}}function Qu(t){return void 0!==t.parent}class Ku{constructor(t){Qu(t)?(this.m_parent=t.parent,this.m_geometry=t.geometry,this.m_path=t.path,this.m_vertex=t.vertex,this.m_firstVertex=t.firstVertex,this.m_index=t.selection?0:t.index,this.m_bSkipMultiPoints=t.bSkipMultiPoints,this.m_selection=t.selection,this.m_bOneGeom=t.bOneGeom,this.m_bFirst=!0):(this.m_parent=t.copy.m_parent,this.m_geometry=t.copy.m_geometry,this.m_path=t.copy.m_path,this.m_vertex=t.copy.m_vertex,this.m_index=t.copy.m_index,this.m_bSkipMultiPoints=t.copy.m_bSkipMultiPoints,this.m_firstVertex=t.copy.m_firstVertex,this.m_bFirst=!0,this.m_selection=t.copy.m_selection,this.m_bOneGeom=t.copy.m_bOneGeom)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==Ou;){for(;this.m_path!==Ou;this.m_path=this.m_parent.getNextPath(this.m_path))if(this.m_vertex=this.m_parent.getFirstVertex(this.m_path),this.m_firstVertex=this.m_vertex,this.m_vertex!==Ou)return this.m_vertex;if(this.m_bOneGeom)return Ou;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===Ou)break;this.m_bSkipMultiPoints&&!c(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return Ou}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==Ou&&(this.m_path=this.m_parent.getPathFromVertex(t),!this.m_bOneGeom||this.m_geometry===this.m_parent.getGeometryFromPath(this.m_path)))return this.m_geometry=this.m_parent.getGeometryFromPath(this.m_path),t}return Ou}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==Ou?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==Ou&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):Ou}currentGeometry(){return this.m_geometry}currentPath(){return t(0),0}static create_(t,e,s,i,n,r,o,a,h){return new Ku({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class $u{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class Ju{setPrevPath(t,e){this.m_pathIndexList.setField(t,1,e)}setNextPath(t,e){this.m_pathIndexList.setField(t,2,e)}setPathFlags(t,e){this.m_pathIndexList.setField(t,6,e)}getPathFlags(t){return this.m_pathIndexList.getField(t,6)}setPathGeometry(t,e){this.m_pathIndexList.setField(t,7,e)}getPathIndex(t){return this.m_pathIndexList.getField(t,0)}setNextGeometry(t,e){this.m_geometryIndexList.setField(t,1,e)}setPrevGeometry(t,e){this.m_geometryIndexList.setField(t,0,e)}getGeometryIndex(t){return this.m_geometryIndexList.getField(t,7)}setFirstPath(t,e){this.m_geometryIndexList.setField(t,3,e)}setLastPath(t,e){this.m_geometryIndexList.setField(t,4,e)}newGeometry(t){const e=this.m_geometryIndexList.newElement();return this.m_geometryIndexList.setField(e,2,t),this.m_geometryIndexList.setField(e,5,0),this.m_geometryIndexList.setField(e,6,0),this.m_geometryIndexList.setField(e,7,this.m_geometryIndexList.elementToIndex(e)),e}freeGeometry(t){this.m_geometryIndexList.deleteElement(t)}newPath(t){const e=this.m_pathIndexList.newElement(),s=this.m_pathIndexList.elementToIndex(e);if(this.m_pathIndexList.setField(e,0,s),this.m_pathIndexList.setField(e,3,0),this.m_pathIndexList.setField(e,6,0),this.setPathGeometry(e,t),s>=this.m_pathAreas.length){const t=Math.trunc(s<16?16:3*s/2);this.m_pathAreas.length=t,this.m_pathLengths.length=t}return this.m_pathAreas[s]=0,this.m_pathLengths[s]=0,this.m_pathCount++,e}freePath(t){this.m_pathIndexList.deleteElement(t),this.m_pathCount--}newVertex(t){const e=this.m_vertexIndexList.newElement(),s=t>=0?t:this.m_vertexIndexList.elementToIndex(e);if(this.m_vertexIndexList.setField(e,0,s),t<0){if(s>=this.m_vertices.getPointCount()){const t=Math.trunc(s<16?16:3*s/2);this.m_vertices.reserveRounded(t),this.m_vertices.resizeNoInit(t),null!==this.m_segments&&(this.m_segments.length=t),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0)}this.m_segments&&(this.m_segments[s]=null)}return this.m_pointCount++,e}freeVertex(t){this.unselect(t);const e=this.getVertexIndex(t);this.m_vertexIndexList.deleteElement(t),this.m_pointCount--;for(let s=0,i=this.m_indices.length;s<i;s++){if(s===this.m_selectionIndex)continue;const t=this.m_indices[s];null!==t&&t.size()>e&&t.write(e,-1)}this.m_weights&&this.m_weights.size()>e&&this.m_weights.write(e,1),this.m_ranks&&this.m_ranks.size()>e&&this.m_ranks.write(e,ju),this.m_segmentWeights&&this.m_segmentWeights.size()>e&&this.m_segmentWeights.write(e,1),this.m_segmentRanks&&this.m_segmentRanks.size()>e&&this.m_segmentRanks.write(e,ju),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=!1;const n=e!==Ou?this.getPrevVertex(e):this.getLastVertex(t),r=n!==Ou?this.getNextVertex(n):Ou,o=this.newVertex(null===s?this.m_pointCount:-1),a=this.getVertexIndex(o);null!==s&&this.m_vertices.setPointByVal(a,s),this.setPathToVertex(o,t),this.setNextVertex(o,r),this.setPrevVertex(o,n),r!==Ou&&this.setPrevVertex(r,o),n!==Ou&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===Ou&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==Ou||this.setFirstVertex(t,o)),h&&r===Ou&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const u=this.getGeometryFromPath(t);return this.setGeometryVertexCount(u,this.getPointCount(u)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new Ci({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPath_(e){return t(0),0}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(e,s){return t(0),0}appendMultiPath_(t,e){if(e.isEmpty())return;const s=e.getImpl();this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+s.getPointCount()),this.m_verticesMp.addPoints(e,0,s.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const i=null!==this.m_segments||null!==s.getSegmentFlagsStreamRef();this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+s.getPointCount()),this.m_pathIndexList.setCapacity(this.m_pathIndexList.size()+s.getPathCount());for(let n=0,r=s.getPathCount();n<r;n++){if(0===s.getPathSize(n))continue;const e=this.insertPath(t,Ou);this.setClosedPath(e,s.isClosedPath(n));for(let t=s.getPathStart(n),r=s.getPathEnd(n);t<r;t++){const n=this.insertVertex_(e,Ou,null,!1);if(i){const e=this.getVertexIndex(n);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(e,null);else{const i=new xl;s.querySegment(t,i,!0),this.setSegmentToIndex(e,i.releaseSegment())}}}s.isStrongPathStart(n)&&this.setStrongPathStart(e,!0),s.isStrongPathEnd(n)&&this.setStrongPathEnd(e,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===r.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(e,s,i){t(0)}appendMultiPathPolygon(e,s,i){const n=s.getImpl(),r=null!==this.m_segments||null!==n.getSegmentFlagsStreamRef(),o=as.constructEmpty();s.queryEnvelope(o),t(i.isIntersecting(o)&&!i.containsEnvelope(o));let a=as.construct(Number.NEGATIVE_INFINITY,i.ymin,Number.POSITIVE_INFINITY,i.ymax),h=as.construct(i.xmin,Number.NEGATIVE_INFINITY,i.xmax,Number.POSITIVE_INFINITY);a.height()>h.width()&&(h=Ve(a,a=h));const m=[],u=n.queryLimitedSegmentIterator(a);let l=-1,c=-100,d=-1,_=0,g=-1,p=-1,f=Ou,x=!0,y=u.nextSegment();if(null!==y)for(;;y=u.nextSegment()){let i=null===y;const o=null!==y?u.getPathIndex():l,a=null!==y?u.getStartPointIndex():c;if(i||(o===l?c+1===a?_++:i=!0:(i=l>=0,l<0&&(l=o,d=n.getSegmentCountPath(l),g=a,f=Ou,_=1))),i){if(!(0===m.length&&d===_)){0!==m.length&&m[0].first===g||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(s,g,g+1),-1===p&&(p=g),f===Ou&&(f=this.insertPath(e,Ou),this.setClosedPath(f,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(f,Ou,null,!1));for(const{first:i,second:o}of m){-1===p&&(p=i);let a=-1,h=-1;const u=i+o-1;if(o===d){const e=u+1;h=e-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(s,i,e),a=u,t(1===m.length)}else if(u+1<n.getPathEnd(l)){const t=u+2;h=t-i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(s,i,t),a=u}else{const t=n.getPathStart(l),e=t!==p?1:0,r=u+1;h=r-i+e,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(r-i)+e),this.m_verticesMp.addPoints(s,i,r),a=u,e>0&&this.m_verticesMp?.addPoints(s,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),f===Ou&&(f=this.insertPath(e,Ou),this.setClosedPath(f,!0));for(let t=0,e=i;t<h;t++,e++){const t=this.insertVertex_(f,Ou,null,!1);if(r){const s=this.getVertexIndex(t);if(1&n.getSegmentFlags(e)||e>a)this.setSegmentToIndex(s,null);else{const t=new xl;n.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===m.length||m.at(-1).first+m.at(-1).second!==g+_){let t=g+_;t===s.getPathEnd(l)&&(t=s.getPathStart(l)),p!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(s,t,t+1),this.insertVertex_(f,Ou,null,!1))}}m.length=0,x=!0,o!==l&&(l=o,d=n.getSegmentCountPath(l),f=Ou,p=-1),g=a,_=1}if(!y)break;{const t=as.constructEmpty();y.queryLooseEnvelope(t),h.isIntersecting(t)?(x?m.push(q(a,1)):m.at(-1).second++,x=!1):x=!0}c=a}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const i=e.getGeometryType()===r.enumPolygon,n=as.constructEmpty();e.queryEnvelope(n),s.isIntersecting(n)&&(!s.containsEnvelope(n)&&e.getPointCount()>10?i?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(e,s,i){t(0)}appendMultiPoint_(t,e){this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+e.getPointCount()),this.m_verticesMp.addPoints(e,0,e.getPointCount()),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+e.getPointCount());const s=this.insertPath(t,Ou);for(let i=0,n=e.getPointCount();i<n;i++)this.insertVertex_(s,Ou,null,!1)}appendMultiPoint(t,e,s){if(void 0===s)return void this.appendMultiPoint_(t,e);const i=e.getAttributeStreamRef(0);let n=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)?(-1===r&&(r=m,o=m),o++):r>=0&&(this.m_verticesMp.addPoints(e,r,o-r),r=-1,a++)}if(r>0&&(this.m_verticesMp.addPoints(e,r,o-r),a++),!a)return;this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+n);const h=this.insertPath(t,Ou);for(let m=0,u=e.getPointCount();m<u;m++){const t=i.readPoint2D(2*m);s.contains(t)&&this.insertVertex_(h,Ou,null,!1)}}splitSegmentForward(t,e,s,i,n){const o=this.getNextVertex(t);o===Ou&&f("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let l=0,c=e.getResultSegmentCount(s);l<c;l++){const t=this.getVertexIndex(m),i=this.getNextVertex(m),d=e.getResultSegment(s,l);let _=null;if(d.getGeometryType()!==r.enumLine&&(_=d.clone(),_.dropAllAttributes()),0===l&&(d.queryStart(a),this.setSegmentToIndex(t,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,l),e.getResultSegmentStartPointWeight(s,l),n)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,l)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,l)),u){const t=e.getResultSegmentSegmentParentage(s,l),i=e.getResultSegmentStartPointIsBreak(s,l);this.setSegmentParentageAndBreak(m,t,i)}if(d.queryEnd(a),l<c-1){this.setSegmentToIndex(t,_);const n=this.insertVertex(h,i,a);this.setWeight(n,e.getResultSegmentEndPointWeight(s,l)),this.setRank(n,e.getResultSegmentEndPointRank(s,l)),this.select(n),m=n}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,l),e.getResultSegmentEndPointWeight(s,l),n);const i=e.getResultSegmentEndPointIsBreak(s,l);this.setSegmentParentageBreakVertex(o,i),this.setSegmentToIndex(t,_)}}}splitSegmentBackward(t,e,s,i,n){const o=this.getNextVertex(t);o===Ou&&f("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const u=this.hasSegmentParentage();for(let l=0,c=e.getResultSegmentCount(s);l<c;l++){const t=c-l-1,i=this.getVertexIndex(m),d=this.getNextVertex(m),_=e.getResultSegment(s,t);let g=null;if(_.getGeometryType()!==r.enumLine&&(g=_.clone(),g.reverse(),g.dropAllAttributes()),0===l&&(_.queryEnd(a),this.setSegmentToIndex(i,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),n),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,t),e.getResultSegmentEndPointIsBreak(s,t))),_.getGeometryType()===r.enumLine?this.setSegmentToIndex(i,null):this.setSegmentToIndex(i,g),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),_.queryStart(a),l<c-1){const i=this.insertVertex(h,d,a);this.setWeight(i,e.getResultSegmentStartPointWeight(s,t)),this.setRank(i,e.getResultSegmentStartPointRank(s,t)),this.select(i),m=i,u&&this.setSegmentParentageAndBreak(i,e.getResultSegmentSegmentParentage(s,t),e.getResultSegmentEndPointIsBreak(s,t))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),n)}}splitSegmentForward3D(e,s,i){t(0)}splitSegmentBackward3D(e,s,i){t(0)}selected_(e){return t(0),!1}allocateIndex(t=!0){if(this.m_deletedIndices.length){const e=this.m_deletedIndices.pop();return t&&e.setRange(-1,0,e.size()),e}return t?Is(0,-1):Is(0)}recycleUserIndex(t){this.m_deletedIndices.push(t)}allocatePathIndex(){if(this.m_deletedPathIndices.length){const t=this.m_deletedPathIndices.at(-1);return this.m_deletedPathIndices.pop(),t}return Is(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),n=this.getNextVertex(e),r=this.getVertexIndex(t),o=this.getVertexIndex(e);if(this.setNextVertex(t,n),this.setPrevVertex(n,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(r),e=this.getSegmentFromIndex(o);this.setSegmentToIndex(o,null),this.setSegmentToIndex(r,e),this.setSegmentToIndex(o,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=Ve(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),r=[!1],o=this.insertClosedPath(s,Ou,i,this.getFirstVertex(e),r);r[0]&&this.setFirstVertex(e,n);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return Ou}sortVerticesSimpleByYHelper(t,e,s){t.sort(e,s,((t,e)=>{let s=this.compareVerticesSimpleY(t,e);if(0===s){const i=this.getPathInternalIndexFromVertex(t),n=this.getPathInternalIndexFromVertex(e);s=i<n?-1:i>n?1:0}return s}))}sortVerticesSimpleByYHelper3D(e,s,i){t(0)}constructor(){this.m_verticesMp=null,this.m_vertices=null,this.m_xyStream=null,this.m_vertexDescription=null,this.m_segments=null,this.m_weights=null,this.m_ranks=null,this.m_segmentWeights=null,this.m_segmentRanks=null,this.m_indices=[],this.m_deletedIndices=[],this.m_pathAreas=[],this.m_pathLengths=[],this.m_pathindices=[],this.m_deletedPathIndices=[],this.m_geometryIndices=[],this.m_selectedVertices=[],this.m_helperPoint=null,this.m_hasForceSetEnvelope=!1,this.m_workPoint2D=os.getNAN(),this.m_workPoint2_2D=os.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=Ou,this.m_lastGeometry=Ou,this.m_vertexIndexList=new ks(5),this.m_pathIndexList=new ks(8),this.m_geometryIndexList=new ks(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new Hs,this.m_forceSetEnvelope=as.constructEmpty(),this.m_hasForceSetEnvelope=!1,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(this.m_hasForceSetEnvelope)return this.m_forceSetEnvelope;const e=this.hasCurves(),s=as.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let r=i.next();r!==Ou;r=i.next()){if(n?s.merge(this.getXY(r)):s.mergeNe(this.getXY(r)),e){const t=this.getSegment(r);if(null!==t){const e=as.constructEmpty();t.queryLooseEnvelope(e),s.mergeEnvelope2D(e)}}n=!1}return s}getEnvelope3D(e){return t(0),Vs.constructEmpty()}forceSetEnvelope2D(e){t(0)}forgetForceSetEnvelope2D(){t(0)}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if(c(s))return this.addMultiPath(t,e);if(s===r.enumMultiPoint)return this.addMultiPoint(t,e);if(s===r.enumPoint)return this.addPoint_(t,e);if(s===r.enumEnvelope){const s=new Ur;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}f("")}appendGeometry(t,e){this.m_verticesMp.mergeVertexDescription(e.getDescription()),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1;const s=e.getGeometryType();c(s)?this.appendMultiPath(t,e):s!==r.enumMultiPoint?f(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(e,s){t(0)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(r.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=Ou,s=-1,i=-1;for(let n=this.getFirstGeometry();n!==Ou;)if(t!==r.enumUnknown&&this.getGeometryType(n)!==t)n=this.getNextGeometry(n);else{if(e===Ou){e=n,s=this.getPathCount(e),i=this.getPointCount(e),n=this.getNextGeometry(n);continue}for(let s=this.getFirstPath(n);s!==Ou;s=this.getNextPath(s))this.setPathGeometry(s,e);s+=this.getPathCount(n),i+=this.getPointCount(n);const t=this.getLastPath(e),r=this.getFirstPath(n);t!==Ou?this.setNextPath(t,r):this.setFirstPath(e,r),r!==Ou&&(this.setPrevPath(r,t),this.setLastPath(e,this.getLastPath(n))),this.setFirstPath(n,Ou),this.setLastPath(n,Ou);const o=n;n=this.getNextGeometry(n),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==Ou&&(this.setGeometryVertexCount(e,i),this.setGeometryPathCount(e,s),this.dbgVerifyVertexCounts()),e}setFillRule(t,e){let s=this.m_geometryIndexList.getField(t,2);s&=-134217729,s|=1===e?134217728:0,this.m_geometryIndexList.setField(t,2,s)}getFillRule(t){return 134217728&this.m_geometryIndexList.getField(t,2)?1:0}setGeometryModified(t,e){let s=this.m_geometryIndexList.getField(t,2);!!(67108864&s)!==e&&(s&=-67108865,s|=e?67108864:0,this.m_geometryIndexList.setField(t,2,s))}getGeometryModified(t){return!!(67108864&this.m_geometryIndexList.getField(t,2))}setGeometryModifiedWithVertex(t,e){const s=this.getPathFromVertex(t),i=this.getGeometryFromPath(s);this.setGeometryModified(i,e)}getGeometryModifiedWithVertex(e){return t(0),!0}swapGeometry(e,s){t(0)}addPathFromMultiPath(e,s,i){return t(0),0}getGeometry(e){const s=this.getGeometryType(e),i=Zu(s,this.m_verticesMp.getDescription()),n=this.getPointCount(e);if(0===n)return i;if(c(s)){const t=i.getImpl(),s=this.getPathCount(e),r=Is(s+1),o=Ns(s+1,0),a=i.getDescription(),h=this.hasCurves();for(let i=0,m=a.getAttributeCount();i<m;i++){const h=a.getSemantics(i),m=Hu.getComponentCount(h),u=As(h,n),l=this.m_vertices.getAttributeStreamRef(h);let c=0,d=0,_=0;for(let t=this.getFirstPath(e);t!==Ou;t=this.getNextPath(t)){let e=0;this.isClosedPath(t)&&(e|=1),this.isExterior(t)&&(e|=8),this.isStrongPathStart(t)&&(e|=2),this.isStrongPathEnd(t)&&(e|=4),e&&o.setBits(d,e);const s=this.getPathSize(t);if(r.write(d++,_),_+=s,0===h){const e=l,s=u;let i;for(let n=this.getFirstVertex(t);c<_;n=this.getNextVertex(n),c++){const t=this.getVertexIndex(n);i=e.readPoint2D(2*t),s.writePoint2D(2*c,i)}}else for(let i=this.getFirstVertex(t);c<_;i=this.getNextVertex(i),c++){const t=this.getVertexIndex(i);for(let e=0;e<m;e++){const s=l.readAsDbl(t*m+e);u.writeAsDbl(c*m+e,s)}}}t.setAttributeStreamRef(h,u),r.write(s,n)}if(t.setPathFlagsStreamRef(o),t.setPathStreamRef(r),t.notifyModifiedFlags(65535),h){let s=0,i=0;for(let n=this.getFirstPath(e);n!==Ou;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let e=this.getFirstVertex(n);i<s;e=this.getNextVertex(e)){const s=this.getSegment(e);null!==s&&s.isCurve()&&t.replaceSegment(i,s,!0),i++}}}}else if(s===r.enumMultiPoint){const t=i.getImpl(),s=i.getDescription();t.reserve(n),t.resizeNoInit(n);for(let i=0,n=s.getAttributeCount();i<n;i++){const n=s.getSemantics(i),r=Hu.getComponentCount(n),o=t.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);let h=0;const m=this.getFirstPath(e),u=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<u;t=this.getNextVertex(t),h++){const e=this.getVertexIndex(t);for(let t=0;t<r;t++){const s=a.readAsDbl(e*r+t);o.writeAsDbl(h*r+t,s)}}t.setAttributeStreamRef(n,o)}t.notifyModifiedFlags(65535)}else t(0);return i}queryPointGeometryOnly(e,s){t(0)}removeGeometry(t){for(let i=this.getFirstPath(t);i!==Ou;i=this.removePath(i));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==Ou?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==Ou?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=vs.getDefaultDescription2D());const s=this.newGeometry(t);return this.m_vertices?this.m_verticesMp.mergeVertexDescription(e):(this.m_verticesMp=new dn({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1,this.m_firstGeometry===Ou?(this.m_firstGeometry=s,this.m_lastGeometry=s):(this.setPrevGeometry(s,this.m_lastGeometry),this.setNextGeometry(this.m_lastGeometry,s),this.m_lastGeometry=s),s}getFirstGeometry(){return this.m_firstGeometry}getLastGeometry(){return this.m_lastGeometry}getNextGeometry(t){return this.m_geometryIndexList.getField(t,1)}getPrevGeometry(t){return this.m_geometryIndexList.getField(t,0)}getGeometryType(t){return 16777215&this.m_geometryIndexList.getField(t,2)}setGeometryUserIndex(t,e,s){const i=this.m_geometryIndices[e],n=this.getGeometryIndex(t);n>=i.size()&&i.resize(Math.max(1.25*n,16),-1),i.write(n,s)}getGeometryUserIndex(t,e){const s=this.getGeometryIndex(t),i=this.m_geometryIndices[e];return s<i.size()?i.read(s):-1}createGeometryUserIndex(){for(let t=0;t<this.m_geometryIndices.length;t++)if(null===this.m_geometryIndices[t])return this.m_geometryIndices[t]=Is(0),t;this.m_geometryIndices.push(Is(0));const e=this.m_geometryIndices.length-1;return t(e>=0&&e<=Number.MAX_SAFE_INTEGER),e}removeGeometryUserIndex(t){for(this.m_geometryIndices[t]=null;this.m_geometryIndices.length>0&&null===this.m_geometryIndices.at(-1);)this.m_geometryIndices.pop()}getFirstPath(t){return this.m_geometryIndexList.getField(t,3)}getLastPath(t){return this.m_geometryIndexList.getField(t,4)}hasPointFeatures(){for(let t=this.getFirstGeometry();t!==Ou;t=this.getNextGeometry(t))if(!c(this.getGeometryType(t)))return!0;return!1}getPointCount(t){return this.m_geometryIndexList.getField(t,5)}getPathCount(t){return this.m_geometryIndexList.getField(t,6)}filterClosePoints(e,s,i,n,o){const a=e*e;let h=0;const m=this.hasCurves(),u=this.hasSegmentParentage();for(let l=o===Ou?this.getFirstGeometry():o;l!==Ou;l=o===Ou?this.getNextGeometry(l):Ou){const e=this.getGeometryType(l);if(!c(e))continue;if(i&&e!==r.enumPolygon)continue;const o=this.getGeometryType(l)===r.enumPolygon;let d=this.getGeometryModified(l);for(let i=this.getFirstPath(l);i!==Ou;){let e=0;for(let s=this.getFirstVertex(i);e<this.getPathSize(i)/2;){const r=this.getNextVertex(s);if(r===Ou)break;const o=this.getXY(s),c=this.getXY(r);let _=os.sqrDistance(o,c),g=!0;do{if(_<=a){if(m){const t=this.getSegment(s);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}if(0===_?0===h&&(h=-1):h=1,r!==this.getLastVertex(i)){const e=u&&(this.getSegmentParentageBreakVertex(s)||this.getSegmentParentageBreakVertex(r));if(this.transferAllDataToTheVertex(r,s),this.removeVertex(r,!1),n&&!d&&(this.setGeometryModified(l,!0),d=!0),u&&s!==r){this.setSegmentParentageBreakVertex(s,e);const i=this.getNextVertex(s);t(i!==Ou),this.isDiscontinuousSegmentParentage(i)&&this.setSegmentParentageBreakVertex(i,!0)}}g=!1}}while(0);g&&(s=this.getNextVertex(s)),e++}let r=this.getFirstVertex(i);for(let t=this.isClosedPath(i)?r:this.getLastVertex(i);this.getPathSize(i)>0;){const e=this.getPrevVertex(t);if(e===Ou)break;{const s=this.getXY(e),o=this.getXY(t);let c=os.sqrDistance(s,o),_=!0;do{if(c<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(c=e*e,c>a)break}}0===c?0===h&&(h=-1):h=1;const s=u&&(this.getSegmentParentageBreakVertex(t)||this.getSegmentParentageBreakVertex(e));this.removeVertex(e,!0),n&&!d&&(this.setGeometryModified(l,!0),d=!0),u&&e!==t&&(s||this.isDiscontinuousSegmentParentage(t))&&this.setSegmentParentageBreakVertex(t,!0),r===e&&(r=this.getFirstVertex(i)),_=!1}}while(0);if(_&&(t=this.getPrevVertex(t),t===r))break}}const c=this.getPathSize(i);let _=s&&c<(o?3:2);_&&o&&2===c&&m&&(_=!this.pathHasCurves(i)),_?(i=this.removePath(i),0===h&&(h=-1),n&&!d&&(this.setGeometryModified(l,!0),d=!0)):i=this.getNextPath(i)}}return h}filterClosePoints3D(e,s,i,n,r,o){return t(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==Ou;e=this.getNextGeometry(e))if(c(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==Ou;){const e=this.getPathSize(s);if(0===e)return!0;let i=this.getFirstVertex(s);for(let s=0;s<e;s++){const e=this.getNextVertex(i);if(e===Ou)break;const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);let r=0;if(null!==n){if(r=n.calculateLowerLength2D(),r<=t){if(r=n.calculateUpperLength2D(),r<=t)return!0;if(r=n.calculateLength2D(),r<=t)return!0}}else{const i=this.getVertexIndex(e);if(r=this.m_vertices.getShortestDistance(s,i),r<=t)return!0}i=e}s=this.getNextPath(s)}return!1}hasDegenerateSegments3D(e,s){return t(0),!1}transferAllDataToTheVertex(t,e){const s=this.getVertexIndex(t),i=this.getVertexIndex(e);if(this.m_weights){const t=this.getWeightWithIndex(s);this.setWeightWithIndex(i,t)}if(this.m_ranks){const t=this.getRankWithIndex(s);this.setRankWithIndex(i,t)}if(this.m_segmentWeights){const t=this.getSegmentWeightWithIndex(s);this.setSegmentWeightWithIndex(i,t)}if(this.m_segmentRanks){const t=this.getSegmentRankWithIndex(s);this.setSegmentRankWithIndex(i,t)}this.m_bHasAttributes;for(let r=0,o=this.m_indices.length;r<o;r++)if(r!==this.m_selectionIndex&&null!==this.m_indices[r]){const s=this.getUserIndex(t,r);-1!==s&&this.setUserIndex(e,r,s)}const n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,i,n){let r=0;const o=this.getNextVertex(t);o===Ou&&f("");const a=this.getVertexIndex(t),h=this.getVertexIndex(o),m=this.getSegmentFromIndex(a);let u=this.m_vertices.getShortestDistance(a,h);const l=this.getPathFromVertex(t),c=this.m_bHasAttributes;c&&m&&(u=m.calculateLength2D());const d=this.getSegmentParentage(t),_=this.getHelperPoint();if(m){let t=0,n=0,g=Ou;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=m.cut(t,s);if(null!==i&&(p>0&&e.setStartXY(i[p-1]),e.setEndXY(i[p]),e.normalizeAfterEndpointChange(),n=p),c){const t=u>0?m.calculateSubLengthFromStart(s)/u:0;this.m_vertices.interpolateTwoVertices(a,h,t,_)}_.setXY(e.getEndXY()),g=this.insertVertex(l,o,_),r++;const f=this.getPrevVertex(g),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==d&&this.setSegmentParentageAndBreak(g,d,!1),t=s}}if(g!==Ou){const e=m.cut(t,1);null!==i&&(e.setStartXY(i[n]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(g);this.setSegmentToIndex(s,e)}}else{let t=0;for(let i=0;i<s;i++){const s=e[i];if(t<s&&s<1){this.m_vertices.interpolateTwoVertices(a,h,s,_);const t=this.insertVertex(l,o,_);r++,-1!==d&&this.setSegmentParentageAndBreak(t,d,!1)}t=s}}return r}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(e,s,i){return t(0),!1}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==Ou;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(e,s,i){return t(0),0}setPoint(t,e,s){if(this.setPointOnly(t,e),null!==this.m_segments){const i=this.getVertexIndex(t),n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXY(e.getXY()),n.normalizeAfterEndpointChange(),s&&n.ensureXYMonotone());const r=this.getPrevVertex(t);if(r!==Ou){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!==i&&(i.setEndXY(e.getXY()),i.normalizeAfterEndpointChange(),s&&i.ensureXYMonotone())}}}setPointEx(t,e,s,i,n){this.setPoint(t,e,n);const r=this.getVertexIndex(t);this.setWeightWithIndex(r,i),this.setRankWithIndex(r,s)}setPointOnly(t,e){const s=this.getVertexIndex(t);this.m_vertices.setPointByVal(s,e)}setPointOnlyEx(e,s,i,n){t(0)}queryPoint(t,e){const s=this.getVertexIndex(t);this.m_vertices.getPointByVal(s,e)}setXY(t,e){this.setXYCoords(t,e.x,e.y)}setXYCoords(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices?.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);null!==n&&(n.setStartXYCoords(e,s),n.normalizeAfterEndpointChange());const r=this.getPrevVertex(t);if(r!==Ou){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);null!=i&&(i.setEndXYCoords(e,s),i.normalizeAfterEndpointChange())}}}setXYMonotonic(t,e,s){const i=this.getVertexIndex(t);if(this.m_vertices.setXYCoords(i,e,s),null!==this.m_segments){const n=this.getSegmentFromIndex(i);if(null!==n){const t=n.getEndXY();n.setCoordsForIntersector(new os(e,s),t,!1),n.ensureXYMonotone()}const r=this.getPrevVertex(t);if(r!==Ou){const t=this.getVertexIndex(r),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new os(e,s),!1),i.ensureXYMonotone()}}}}setXYMonotonicPoint2D(t,e){this.setXYMonotonic(t,e.x,e.y)}queryXY(t,e){const s=this.getVertexIndex(t);return this.m_vertices.queryXY(s,e)}getXY(t){const e=this.getVertexIndex(t);return this.m_vertices.getXY(e)}getXYWithIndex(t){return this.m_xyStream.readPoint2D(2*t)}setXYZ(e,s){t(0)}setXYZCoords(e,s,i,n){t(0)}queryXYZ(e,s){t(0)}getXYZ(e){return t(0),ps.getNAN()}getXYZWithIndex(e){return t(0),ps.getNAN()}getAttributeAsDbl(e,s,i){return t(0),0}queryAttributeAsDbl(e,s,i,n){t(0)}setAttribute(e,s,i,n){t(0)}setAttributeInt(e,s,i,n){t(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(e){return t(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){return this.getXY(t).y}getX(e){return t(0),0}isEqualXY(t,e){return this.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.isEqualPoint2D(this.m_workPoint2_2D)}isEqualXYPoint2D(t,e){return this.queryXY(t,this.m_workPoint2D),this.m_workPoint2D.isEqualPoint2D(e)}isEqualXYZPoint3D(e,s){return t(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=Ms(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_weights.size()){if(s)return;this.m_weights.resize(i+1,1)}this.m_weights.write(i,e)}setWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_weights){if(s)return;this.m_weights=Ms(this.m_vertices.getPointCount(),1)}if(t>=this.m_weights.size()){if(s)return;this.m_weights.resize(t+1,1)}this.m_weights.write(t,e)}getWeight(t){if(null===this.m_weights)return 1;const e=this.getVertexIndex(t);return e>=this.m_weights.size()?1:this.m_weights.read(e)}getWeightWithIndex(t){return null===this.m_weights||t>=this.m_weights.size()?1:this.m_weights.read(t)}getRank(t){if(null===this.m_ranks)return ju;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?ju:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?ju:this.m_ranks.read(t)}setRank(t,e){e<ju&&(e=ju);const s=e===ju;if(null===this.m_ranks){if(s)return;this.m_ranks=Is(this.m_vertices.getPointCount(),ju)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,ju)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<ju&&(e=ju);const s=e===ju;if(null===this.m_ranks){if(s)return;this.m_ranks=Is(this.m_vertices.getPointCount(),ju)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,ju)}this.m_ranks.write(t,e)}setSegmentWeight(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentWeights){if(s)return;this.m_segmentWeights=Ms(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(i+1,1)}this.m_segmentWeights.write(i,e)}setSegmentWeightWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_segmentWeights){if(s)return;this.m_segmentWeights=Ms(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentWeights.size()){if(s)return;this.m_segmentWeights.resize(t+1,1)}this.m_segmentWeights.write(t,e)}getSegmentWeight(t){if(null===this.m_segmentWeights)return 1;const e=this.getVertexIndex(t);return e>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(e)}getSegmentWeightWithIndex(t){return null==this.m_segmentWeights||t>=this.m_segmentWeights.size()?1:this.m_segmentWeights.read(t)}getSegmentRank(t){if(null===this.m_segmentRanks)return Ju.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?Ju.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?ju:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<ju&&(e=ju);const s=e===ju;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=Is(this.m_vertices.getPointCount(),ju)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,ju)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(e,s){t(0)}removeWeights(){t(0),this.m_weights=new Xs(0),this.m_segmentWeights=new Xs(0)}removeRanks(){t(0),this.m_ranks=new Fs(0),this.m_segmentRanks=new Fs(0)}setUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);if(i.size()<=n){if(-1===s)return;i.resize(this.m_vertices.getPointCount(),-1)}i.write(n,s)}getUserIndex(t,e){const s=this.getVertexIndex(t),i=this.m_indices[e];if(s<i.size()){return i.read(s)}return-1}addToUserIndex(t,e,s){const i=this.m_indices[e],n=this.getVertexIndex(t);i.size()<=n&&i.resize(this.m_vertices.getPointCount(),-1);const r=i.read(n);i.write(n,r+s)}createUserIndex(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(),t;this.m_indices.push(this.allocateIndex());const e=this.m_indices.length-1;return t(e>=0&&e<=$()),e}createUserIndexUninitialized(){for(let t=0;t<this.m_indices.length;t++)if(null===this.m_indices[t])return this.m_indices[t]=this.allocateIndex(!1),t;this.m_indices.push(this.allocateIndex(!1));const e=this.m_indices.length-1;return t(e>=0&&e<=Number.MAX_SAFE_INTEGER),e}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let r=this.getFirstPath(t);r!==Ou;r=this.getNextPath(r)){let t=this.getFirstVertex(r);for(let e=0,o=this.getPathSize(r);e<o;e++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(e,s){t(0)}removeUserIndex(t){for(this.recycleUserIndex(this.m_indices[t]),this.m_indices[t]=null;this.m_indices.length>0&&null===this.m_indices[this.m_indices.length-1];)this.m_indices.pop()}replaceCurveWithLine(t){if(null!==this.m_segments){const e=this.getVertexIndex(t);this.setSegmentToIndex(e,null)}}queryLineConnector(t,e,s=!1){const i=this.getNextVertex(t);if(i===Ou)return!1;if(!this.m_bHasAttributes||s){const s=this.getXY(t);e.setStartXY(s);const n=this.getXY(i);e.setEndXY(n)}else{const s=new Ci({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(e,s,i=!1){return t(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(e){return t(0),!1}pathHasCurves(e){return t(0),!1}insertPath(t,e){let s=Ou;e!==Ou?(t!==this.getGeometryFromPath(e)&&f(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const i=this.newPath(t);return e!==Ou&&this.setPrevPath(e,i),this.setNextPath(i,e),this.setPrevPath(i,s),s!==Ou?this.setNextPath(s,i):this.setFirstPath(t,i),e===Ou&&this.setLastPath(t,i),this.setGeometryPathCount(t,this.getPathCount(t)+1),i}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==Ou?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Ou?this.setPrevPath(s,e):this.setLastPath(i,e),this.clearPath(t),this.setGeometryPathCount(i,this.getPathCount(i)-1),this.freePath(t),s}clearPath(t){const e=this.getFirstVertex(t);if(e!==Ou){let s=e;for(let e=0,n=this.getPathSize(t);e<n;e++){const t=s;s=this.getNextVertex(s),this.freeVertex(t)}const i=this.getGeometryFromPath(t);this.setGeometryVertexCount(i,this.getPointCount(i)-this.getPathSize(t))}this.setPathSize(t,0)}getNextPath(t){return this.m_pathIndexList.getField(t,2)}getPrevPath(t){return this.m_pathIndexList.getField(t,1)}getPathSize(t){return this.m_pathIndexList.getField(t,3)}isClosedPath(t){return!!(1&this.getPathFlags(t))}setClosedPath(t,e){if(this.isClosedPath(t)===e)return;if(this.getPathSize(t)>0){const s=this.getFirstVertex(t),i=this.getLastVertex(t);if(e){this.setNextVertex(i,s),this.setPrevVertex(s,i);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}else{this.setNextVertex(i,Ou),this.setPrevVertex(s,Ou);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(e){t(0)}isStrongPathStart(t){return!!(8&this.getPathFlags(t))}isStrongPathEnd(t){return!!(16&this.getPathFlags(t))}setStrongPathStart(t,e){const s=(8|this.getPathFlags(t))-8;this.setPathFlags(t,s|(e?8:0))}setStrongPathEnd(t,e){const s=(16|this.getPathFlags(t))-16;this.setPathFlags(t,s|(e?16:0))}getGeometryFromPath(t){return this.m_pathIndexList.getField(t,7)}isExterior(t){return!!(2&this.getPathFlags(t))}setExterior(t,e){const s=(2|this.getPathFlags(t))-2;this.setPathFlags(t,s|(e?2:0))}getRingArea(t){if(this.isRingAreaValid(t))return this.m_pathAreas[this.getPathIndex(t)];const e=this.getFirstVertex(t);if(e===Ou)return 0;const s=this.getXY(e),i=new At(0),n=this.getPathSize(t);if(n>2){const t=s.clone(),r=t.x,o=t.y;let a=this.getNextVertex(e);const h=this.getXY(a);a=this.getNextVertex(a);const m=os.getNAN();for(let e=2;e<n;e++,a=this.getNextVertex(a))this.queryXY(a,m),i.pe((m.x-t.x)*(h.y-o)),t.setCoordsPoint2D(h),h.setCoordsPoint2D(m);i.pe((r-t.x)*(h.y-o))}if(this.hasCurves()){let t=e;for(let e=0;e<n;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===r.enumLine)continue;const s=2*e.calculateArea2DHelper();i.pe(s)}}this.setRingAreaValid(t,!0);const o=.5*i.getResult();return this.m_pathAreas[this.getPathIndex(t)]=o,o}getPathIndexInternal(t){return this.getPathIndex(t)}getPathInternalIndexFromVertex(t){return this.getPathIndex(this.getPathFromVertex(t))}setPathUserIndex(t,e,s){const i=this.m_pathindices[e],n=this.getPathIndex(t);i.size()<this.m_pathAreas.length&&i.resize(this.m_pathAreas.length,-1),i.write(n,s)}getPathUserIndex(t,e){const s=this.getPathIndex(t),i=this.m_pathindices[e];return s<i.size()?i.read(s):-1}createPathUserIndex(){for(let t=0;t<this.m_pathindices.length;t++)if(null===this.m_pathindices[t])return this.m_pathindices[t]=this.allocatePathIndex(),t;this.m_pathindices.push(this.allocatePathIndex());const e=this.m_pathindices.length-1;return t(e>=0&&e<=Number.MAX_SAFE_INTEGER),e}fillPathUserIndexForGeometry(e,s,i){t(0)}removePathUserIndex(t){for(this.recyclePathUserIndex(this.m_pathindices[t]),this.m_pathindices[t]=null;this.m_pathindices.length>0&&null===this.m_pathindices.at(-1);)this.m_pathindices.pop()}movePath(t,e,s){if(s===Ou&&f(""),e===s)return;const i=this.getNextPath(s);let n=this.getPrevPath(s);const r=this.getGeometryFromPath(s);n===Ou?this.setFirstPath(r,i):this.setNextPath(n,i),i===Ou?this.setLastPath(r,n):this.setPrevPath(i,n),this.setGeometryVertexCount(r,this.getPointCount(r)-this.getPathSize(s)),this.setGeometryPathCount(r,this.getPathCount(r)-1),n=e===Ou?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,n),this.setNextPath(s,e),e===Ou?this.setLastPath(t,s):this.setPrevPath(e,s),n===Ou?this.setFirstPath(t,s):this.setNextPath(n,s),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(s)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(s,t)}addVertex(t,e){this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint());return this.insertVertex_(t,Ou,this.getHelperPoint(),!1)}insertVertex(t,e,s){return this.insertVertex_(t,e,s,!0)}removeVertex(t,e){const s=this.getPathFromVertex(t),i=this.getPrevVertex(t),n=this.getNextVertex(t);i!==Ou&&this.setNextVertex(i,n);const r=this.getPathSize(s);t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:Ou),n!==Ou&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:Ou);if(this.hasCurves()&&i!==Ou&&n!==Ou){const s=this.getVertexIndex(t),r=this.getVertexIndex(i),o=this.getVertexIndex(n);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(s,null)}else{const t=this.getSegmentFromIndex(s);if(this.setSegmentToIndex(s,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}this.setPathSize(s,r-1);const o=this.getGeometryFromPath(s);return this.setGeometryVertexCount(o,this.getPointCount(o)-1),this.freeVertex(t),n}removeVertices(e,s){t(e!==s);const i=this.getPathFromVertex(e),n=this.getPrevVertex(e),r=this.getPrevVertex(s);n!==Ou&&this.setNextVertex(n,s);let o=this.getPathSize(i);const a=this.getVertexIndex(e);this.setSegmentToIndex(a,null),this.setPrevVertex(s,n),this.setPrevVertex(e,Ou),this.setNextVertex(r,Ou);let h=0,m=e;const u=this.getFirstVertex(i);let l=!1;for(;;){const t=this.getNextVertex(m);if(l||=u===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,l&&this.setFirstVertex(i,o>0?s:Ou),this.setPathSize(i,o);const c=this.getGeometryFromPath(i);this.setGeometryVertexCount(c,this.getPointCount(c)-h)}getFirstVertex(t){return this.m_pathIndexList.getField(t,4)}getLastVertex(t){return this.m_pathIndexList.getField(t,5)}getNextVertex(t){return this.m_vertexIndexList.getField(t,2)}getPrevVertex(t){return this.m_vertexIndexList.getField(t,1)}getNextVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,2):this.m_vertexIndexList.getField(t,1)}getPrevVertexEx(t,e){return e>0?this.m_vertexIndexList.getField(t,1):this.m_vertexIndexList.getField(t,2)}getPathFromVertex(t){return this.m_vertexIndexList.getField(t,3)}addPoint(e,s){return t(0),0}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||E(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==Ou;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==Ou;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let s=0,i=this.getPathSize(e);s<i;s++)t=this.getXY(t).isFinite()?this.getNextVertex(t):this.removeVertex(t,!0)}}queryVertexIterator(t=Ou){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=Ou){let s=Ou,i=Ou,n=Ou,r=Ou,o=0,a=!1;for(s=e!==Ou?e:this.getFirstGeometry();s!==Ou;s=this.getNextGeometry(s))if(!t||c(this.getGeometryType(s))){for(i=this.getFirstPath(s);i!==Ou;i=this.getNextPath(i))if(n=this.getFirstVertex(i),r=n,o=0,n!==Ou){a=!0;break}if(a||e!==Ou)break}return a||(s=Ou),Ku.create_(this,s,i,n,r,o,t,!1,e!==Ou)}queryVertexIteratorOnSelection(t=Ou){return this.m_selection?Ku.create_(this,t,Ou,Ou,Ou,-1,!1,!0,t!==Ou):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){t(0)}removeSelection(){this.m_selection&&(this.m_selectedVertices.length=0,this.removeUserIndex(this.m_selectionIndex),this.m_selectionIndex=-1,this.m_selection=!1,this.m_selectedCount=0)}select(t){return!!this.selected(t)||(this.setUserIndex(t,this.m_selectionIndex,this.m_selectedVertices.length),this.m_selectedVertices.push(t),this.m_selectedCount++,!1)}unselect(t){if(!this.m_selection)return;const e=this.getUserIndex(t,this.m_selectionIndex);e>=0&&(this.m_selectedVertices[e]=Ou,this.setUserIndex(t,this.m_selectionIndex,-1),this.m_selectedCount--)}selected(t){return!this.m_selection||this.selected_(t)}getSelectedCount(){return this.m_selection?this.m_selectedCount:this.getTotalPointCount()}createSelectionForCrackingAndClustering(e,s){return t(0),!1}peelALoop(t,e){this.peelALoop_(t,e,!1)}peelALoopIntoAPath(t,e){return this.peelALoop_(t,e,!0)}applyTransformation(t){if(this.m_verticesMp.applyTransformation(t),null!==this.m_segments)for(let e=0,s=this.m_segments.length;e<s;e++)this.m_segments[e]&&this.m_segments[e].applyTransformation(t)}setGeometryType(t,e){this.m_geometryIndexList.setField(t,2,e)}splitSegmentWithIntersector(t,e,s,i,n){i?this.splitSegmentForward(t,e,s,!0,n):this.splitSegmentBackward(t,e,s,!0,n)}splitSegmentWithIntersector3D(e,s,i,n){t(0)}setPrevVertex(t,e){this.m_vertexIndexList.setField(t,1,e)}setNextVertex(t,e){this.m_vertexIndexList.setField(t,2,e)}setPathToVertex(t,e){this.m_vertexIndexList.setField(t,3,e)}setPathSize(t,e){this.m_pathIndexList.setField(t,3,e)}setFirstVertex(t,e){this.m_pathIndexList.setField(t,4,e)}setLastVertex(t,e){this.m_pathIndexList.setField(t,5,e)}getSegment(t){if(null!=this.m_segments){const e=this.getVertexIndex(t);return this.getSegmentFromIndex(e)}return null}isCurve(e){return t(0),!1}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===Ou)return!1;const r=this.getSegment(t);if(!r)return!s&&(this.queryLineConnector(t,e.createLine(),i),!0);if(e.copyFrom(r,!0),i)return!0;if(this.m_vertexDescription.getAttributeCount()>1){const s=this.getHelperPoint();this.queryPoint(t,s),e.get().setStart(s),this.queryPoint(n,s),e.get().setEnd(s)}return!0}getSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}getAndClearSegmentFromIndex(t){const e=null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null;return e||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=!1,null===this.m_segments){if(!e)return;this.m_segments=[],this.m_segments.length=this.m_vertices.getPointCount()}t>=this.m_segments.length&&(this.m_segments.length=t+1),this.m_segments[t]=e}setGeometryPathCount(t,e){this.m_geometryIndexList.setField(t,6,e)}setGeometryVertexCount(t,e){this.m_geometryIndexList.setField(t,5,e)}ringParentageCheckInternal(e,s){return t(0),!1}reverseRingInternal(t){const e=this.hasCurves(),s=this.hasSegmentParentage();let i=null,n=-1,r=t;if(e){const t=this.getVertexIndex(r);i=this.getAndClearSegmentFromIndex(t)}s&&(n=this.getSegmentParentage(r));do{const t=this.getPrevVertex(r),o=this.getNextVertex(r);if(this.setNextVertex(r,t),this.setPrevVertex(r,o),e){const t=this.getVertexIndex(o),e=this.getSegmentFromIndex(t);i&&i.reverse(),this.setSegmentToIndex(t,i),i=e}if(s){const t=this.getSegmentParentage(o);this.setSegmentParentagePreserveBreak(o,n),n=t}r=o}while(r!==t);this.dbgVerifyIntegrity(t)}setTotalPointCount(t){this.m_pointCount=t}removePathOnly(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);e!==Ou?this.setNextPath(e,s):this.setFirstPath(i,s),s!==Ou?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,Ou),this.setLastVertex(t,Ou),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,Ou);let o=0,a=s;for(n[0]=!1;;){a===i&&(n[0]=!0),this.setPathToVertex(a,r),o++;const t=this.getNextVertex(a);if(t===s)break;a=t}return this.setClosedPath(r,!0),this.setPathSize(r,o),n[0]&&(s=i),this.setFirstVertex(r,s),this.setLastVertex(r,this.getPrevVertex(s)),this.setRingAreaValid(r,!1),r}findVertex2D(e,s){return t(0),0}findVertex3D(e,s,i){return t(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(e,s){t(0)}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);s!==Ou&&this.setNextVertex(s,i),i!==Ou&&this.setPrevVertex(i,s);if(this.hasCurves()&&s!==Ou&&i!==Ou){const n=this.getVertexIndex(t),r=this.getVertexIndex(s),o=this.getVertexIndex(i);if(e){const t=this.getSegmentFromIndex(r);if(null!==t){const e=this.m_vertices.getXY(o);t.setEndXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(n,null)}else{const t=this.getSegmentFromIndex(n);if(this.setSegmentToIndex(n,null),null!==t){const e=this.m_vertices.getXY(r);t.setStartXY(e),t.normalizeAfterEndpointChange()}this.setSegmentToIndex(r,t)}}return this.freeVertex(t),i}isRingAreaValid(t){return!!(4&this.getPathFlags(t))}setRingAreaValid(t,e){const s=(4|this.getPathFlags(t))-4;this.setPathFlags(t,s|(e?4:0))}compareVerticesSimpleY(t,e){return this.getXY(t).compare(this.getXY(e))}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(e,s){t(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new Uu(this))}sortVerticesSimpleByX(e,s,i){t(0)}sortVerticesSimpleByY3D(e,s,i){t(0)}snapVertexForPoleClipping(e,s){t(0)}setSegmentParentageAndBreak(e,s,i=!0){if(-1===this.m_segmentParentageIndex){if(-1===s)return;this.m_segmentParentageIndex=this.createUserIndex()}s>=0&&(t(s<=Q()>>1),s<<=1,s|=i?1:0),this.setUserIndex(e,this.m_segmentParentageIndex,s)}setSegmentParentagePreserveBreak(e,s){if(-1===this.m_segmentParentageIndex){if(-1===s)return;this.m_segmentParentageIndex=this.createUserIndex()}if(s>=0){t(s<=Q()>>1),s<<=1;s|=this.getSegmentParentageBreakVertex(e)?1:0}this.setUserIndex(e,this.m_segmentParentageIndex,s)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0?e:e>>1}getOriginalSegmentInfo(t){if(-1!==this.m_segmentParentageIndex){const e=this.getSegmentParentage(t);return new $u(e)}return new $u(-1)}setSegmentParentageBreakVertex(t,e){if(-1===this.m_segmentParentageIndex)return;let s=this.getUserIndex(t,this.m_segmentParentageIndex);s<0||!!(1&s)!==e&&(e?s|=1:s&=Q()>>1<<1,this.setUserIndex(t,this.m_segmentParentageIndex,s))}getSegmentParentageBreakVertex(t){if(-1===this.m_segmentParentageIndex)return!0;const e=this.getUserIndex(t,this.m_segmentParentageIndex);return e<0||!!(1&e)}isDiscontinuousSegmentParentage(t){const e=this.getPrevVertex(t);if(e===Ou)return!1;return this.getSegmentParentage(e)!==this.getSegmentParentage(t)}setCurveStitcherPointer(t){this.m_curveStitcher=t}hasSegmentParentage(){return-1!==this.m_segmentParentageIndex}deleteSegmentParentage(){-1!==this.m_segmentParentageIndex&&(this.removeUserIndex(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),this.m_curveStitcher=null}clearSegments(){this.m_segments=null}}function tl(e,s,i){if(s<=262144)return rl(e,s,i);t(0);const n=new sl({points:e,n:s}),r=0;let o=1;const a=e[r].clone();for(;o<s&&e[o].equals(a);)o++;if(n.m_treeHull.addElement(r),o<s){n.m_treeHull.addBiggestElement(o);for(let t=o+1;t<s;t++){const s=e[t],i=n.treeHull(s);-1!==i&&n.m_treeHull.setElement(i,t)}}let h=0;for(let t=n.m_treeHull.getFirst();-1!==t;t=n.m_treeHull.getNext(t))i[h++]=n.m_treeHull.getElement(t);return h}Ju.st_defaultRank=1;class el{constructor(e){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,t(0),this.m_convexHull=e,this.m_function=this.done_}next(){return t(0),!1}get_vertex_handle_p(){return t(0),0}get_vertex_handle_q(){return t(0),0}get_current_support(){return t(0),0}getNext(e){return t(0),0}getPrev(e){return t(0),0}intialize_(){return t(0),!1}increment_(){return t(0),!1}increment_q_(){return t(0),!1}increment_p_(){return t(0),!1}parallel_edge_with_q_support_(){return t(0),!1}parallel_edge_with_p_support_(){return t(0),!1}done_(){return t(0),!1}}class sl{constructor(t){this.m_treeHull=new Ws,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,t||(this.m_treeHull.setCapacity(20),this.m_shape=new Ju,this.m_geometryHandle=this.m_shape.createGeometry(r.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,Ou),this.m_stream=null,this.m_points=null),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape}getXYShape(e){return t(0),new os}getXYStream(e){return t(0),new os}getXYPoints(e){return t(0),new os}deleteNodeShape(e){t(0)}deleteNodeStream(e){t(0)}deleteNodePoints(e){t(0)}add_geometry(e){t(0)}get_bounding_geometry(){return t(0),null}get_antipodal_pairs_iterator(){return t(0),new el(this)}getXY(e){return t(0),new os}getXYWithIndex(e){return t(0),new os}getFirst(){return t(0),0}getLast(){return t(0),0}getNext(e){return t(0),0}getPrev(e){return t(0),0}getVertexIndex(e){return t(0),0}getPointCount(){return t(0),0}addMultiVertexGeometry(e){t(0)}addEnvelope(e){t(0)}addSegment(e){t(0)}addPoint(e){t(0)}addPoint2D(e){return t(0),0}treeHull(e){return t(0),0}treeHullWalkForward(e,s,i){return t(0),0}treeHullWalkBackward(e,s,i){return t(0),0}static isClockwise(e){return t(0),!1}static isCounterClockwise(e){return t(0),!1}static isDegenerate(e){return t(0),!1}static isBetween(e,s,i){return t(0),0}}function il(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x>0?-1:0;if(0===i.y)return n.y>0?1:n.y<0?-1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:os.orientationRobust(t,e,s)}function nl(t,e,s){const i=e.sub(t),n=s.sub(e);if(0===i.x)return n.x<0?-1:0;if(0===i.y)return n.y>0?-1:n.y<0?1:0;const r=i.crossProduct(n),o=4*Number.EPSILON*(Math.abs(n.x*i.y)+Math.abs(n.y*i.x));return r>o?1:r<-o?-1:os.orientationRobust(t,e,s)}function rl(t,e,s){const i=new Fs(0);for(let a=0;a<e;a++)i.add(a);const n={userSort(e,s,i){i.sort(e,s,((e,s)=>t[e].compareX(t[s])))},getValue:e=>t[e].x};Hs.sortEx(i,0,e,n);let r=0;t:for(let a=0;a<e;++a){const e=i.read(a);for(;r>=2;){const n=s[r-2],o=s[r-1];if(t[o].equals(t[e])){i.write(a,-1);continue t}if(!(il(t[n],t[o],t[e])>=0)){o===i.read(a-1)&&i.write(a-1,-1);break}r--}s[r++]=e,2===r&&t[e].equals(t[s[0]])&&(i.write(1,-1),r--)}const o=r+1;t:for(let a=e-2;a>=0;--a){const e=i.read(a);if(!(e<0)){for(;r>=o;){const i=s[r-2],n=s[r-1];if(t[n].equals(t[e]))continue t;if(!(nl(t[i],t[n],t[e])>=0))break;r--}if(0!==a){const i=s[r-1];s[r++]=e,t[e].equals(t[i])&&r--}}}return r>1&&t[s[0]].equals(t[s[r-1]])&&r--,r}function ol(t,e,s,i,n){return al(t,!1,e,s,i,n)}function al(t,e,s,i,n,o){const a=s.getGeometryType(),h=i.getGeometryType(),m=Math.max(n,Ki(s,i));if(a===r.enumLine&&h===r.enumLine)return er(s,i,m,o);let u=s,l=i,c=s.getStartXY(),d=s.getEndXY();if(c.compare(d)>0&&(u=s.clone().reverse()),c=i.getStartXY(),d=i.getEndXY(),c.compare(d)>0&&(l=i.clone().reverse()),e){if(s.equals(i))return 2;if(Xi(s,i,m))return 4}switch(a){case r.enumLine:switch(h){case r.enumEllipticArc:return Pm(t,l,u,m,o);case r.enumBezier:return _u(t,l,u,m,o);case r.enumRationalBezier2:return ah(t,l,u,m,o);case r.enumBezier2:return ea();default:E("")}break;case r.enumEllipticArc:switch(h){case r.enumLine:return Pm(t,u,l,m,o);case r.enumEllipticArc:return bm(t,u,l,m,o);case r.enumBezier:return gu(t,l,u,m,o);case r.enumRationalBezier2:return hh();case r.enumBezier2:return sa();default:E("")}break;case r.enumBezier:switch(h){case r.enumLine:return _u(t,u,l,m,o);case r.enumEllipticArc:return gu(t,u,l,m,o);case r.enumBezier:return pu(t,u,l,m,o);case r.enumRationalBezier2:return fu(t,u,l,m,o);case r.enumBezier2:return xu();default:E("")}break;case r.enumRationalBezier2:switch(h){case r.enumLine:return ah(t,u,l,m,o);case r.enumEllipticArc:return hh();case r.enumBezier:return fu(t,l,u,m,o);case r.enumRationalBezier2:return uh(t,u,l,m,o);case r.enumBezier2:return lh();default:E("")}break;case r.enumBezier2:switch(h){case r.enumLine:return ea();case r.enumEllipticArc:return sa();case r.enumBezier:return xu();case r.enumRationalBezier2:return lh();case r.enumBezier2:return ia();default:E("")}break;default:E("")}}function hl(t,e,s=!0){if(!s&&!ml(t,e))return 0;const i=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(i)return s;const n=t.getGeometryType();if(n!==e.getGeometryType())return 0;if(n===r.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(n===r.enumEllipticArc)return Sm()?s:0;if(n===r.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(n===r.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}if(t.getStartXY().equals(e.getEndXY())&&t.getEndXY().equals(e.getStartXY())){const s=-1;if(i)return s;const n=t.getGeometryType();if(n!==e.getGeometryType())return 0;if(n===r.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(n===r.enumEllipticArc)return Sm()?s:-1;if(n===r.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(n===r.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function ml(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==r.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function ul(t,e,s,i,n,o,a){!n&&o&&f("");const h=e.getGeometryType(),m=s.getGeometryType(),u=Math.max(a,Ki(e,s));if(i&&(i.length=0),n&&(n.length=0),o&&(o.length=0),h===r.enumLine&&m===r.enumLine)return sr(e,s,i,n,o,u,!1,!1);let l=e,c=s,d=e.getStartXY(),_=e.getEndXY(),g=!1,p=!1;d.compare(_)>0&&(l=e.clone(!0).reverse(),g=!0),d=s.getStartXY(),_=s.getEndXY(),d.compare(_)>0&&(c=s.clone(!0).reverse(),p=!0);let x=0;switch(h){case r.enumLine:switch(m){case r.enumEllipticArc:x=Em(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumBezier:x=yu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=ch(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumBezier2:x=na();break;default:E("")}break;case r.enumEllipticArc:switch(m){case r.enumLine:x=Em(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumEllipticArc:x=Cm(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier:x=vu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=dh();break;case r.enumBezier2:x=ra(t,c,l,i,o,n,u,!1,!1,!0);break;default:E("")}break;case r.enumRationalBezier2:switch(m){case r.enumLine:x=ch(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumEllipticArc:x=dh();break;case r.enumBezier:x=bu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=_h(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier2:x=gh(t,l,c,i,n,o,u,!1,!1,!1);break;default:E("")}break;case r.enumBezier2:switch(m){case r.enumLine:x=na();break;case r.enumEllipticArc:x=ra(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier:x=Eu(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumRationalBezier2:x=gh(t,c,l,i,o,n,u,!1,!1,!0);break;case r.enumBezier2:x=oa(t,l,c,i,n,o,u,!1,!1,!1);break;default:E("")}break;case r.enumBezier:switch(m){case r.enumLine:x=yu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumEllipticArc:x=vu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier:x=Pu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumRationalBezier2:x=bu(t,l,c,i,n,o,u,!1,!1,!1);break;case r.enumBezier2:x=Eu(t,l,c,i,n,o,u,!1,!1,!1);break;default:E("")}break;default:E("")}if(g){if(n){for(let t=0;t<x;t++)n[t]=1-n[t];n.reverse()}i&&i.reverse(),o&&o.reverse()}if(p&&o)for(let r=0;r<x;r++)o[r]=1-o[r];return x}function ll(t,e,s){if(e===s)return 0;e>s&&(s=Ve(e,e=s));return t.cut(e,s,!0).calculateUpperLength2D()}function cl(t,e,s,i,n){const r=[],o=[],a=[];for(let m=0,u=n;m<u;m++)r.push(t.calculateSubLengthFromStart(s[m])),o.push(e.calculateSubLengthFromStart(i[m])),vt(s[m],0,1)&&vt(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&a.push(m);if(0===a.length||a.length===n)return;a.sort(((t,e)=>s[t]<s[e]?-1:s[t]>s[e]?1:i[t]<i[e]?-1:i[t]>i[e]?1:0));let h=-1;for(const m of a){if(h>=0&&s[m]===s[h]&&s[m]===s[h]){h=m;continue}h=m;const a=[];a.length=n;for(let t=0;t<a.length;++t)a[t]=t;a.sort(((t,e)=>{const s=r[m],i=o[m],n=r[t]-s,a=o[t]-i,h=n*n+a*a,u=r[e]-s,l=o[e]-i,c=u*u+l*l;return h<c?-1:h>c?1:0}));for(let r=0;r<n;r++){const n=a[r];if(n===m||s[n]===s[m]&&i[n]===i[m]||vt(s[n],0,1)&&vt(i[n],0,1))continue;const o=(s,i,n,r)=>{const o=new Ai,a=new Wt;a.setWithEps(1);const h=new Wt;h.set(i,a.eps()),t.queryCoord2DE(h,o);const m=new Ai;t.queryCoord2DE(new Wt(s),m);let u=!1;return o.eq(m)&&(h.set(r,a.eps()),e.queryCoord2DE(h,o),e.queryCoord2DE(new Wt(n),m),u=o.eq(m)),!u},h=os.getNAN();t.queryCoord2D(s[n],h);const u=os.getNAN();e.queryCoord2D(i[n],u);if(0===os.distance(h,u)&&o(s[m],s[n],i[m],i[n]))break;const l=new kt(i[n],i[m]);l.normalizeNoNAN();const c=new kt(s[n],s[m]);c.normalizeNoNAN();let d=-1,_=Number.POSITIVE_INFINITY,g=s[n];for(let r=0;r<5;r++){h.assign(t.getCoord2D(g));const r=e.getClosestCoordinateOnInterval(h,l,-1);if(u.assign(e.getCoord2D(r)),g=t.getClosestCoordinateOnInterval(u,c,-1),g===s[m]&&r===i[m]){d=1;break}const a=os.distance(u,t.getCoord2D(g));if(!(a<_)){d=0;break}if(0===a){o(s[m],s[n],i[m],i[n])?(s[n]=g,i[n]=r,d=0):d=1;break}_=a}if(-1===d&&(d=vt(s[n],0,1)||vt(i[n],0,1)?0:1),1!==d)break;s[n]=s[m],i[n]=i[m]}}}function dl(t,e,s,i,n,r,o,a,h,m,u,l,c){if(!r)return 0;const d=(t,e)=>{for(let s=0;s<r;++s){const i=e[s];if(vt(i,0,1))continue;const n=t.getCoord2D(i);i<.5?n.equals(t.getStartXY())&&ll(t,0,i)<=Qi(t)&&(e[s]=0):n.equals(t.getEndXY())&&ll(t,i,1)<=Qi(t)&&(e[s]=1)}};d(e,i),d(s,n),cl(e,s,i,n,r);const _=[];for(let f=0,x=r;f<x;f++)_.push(f);const g=(t,e)=>c?Ze(n[t],i[t],n[e],i[e]):Ze(i[t],n[t],i[e],n[e]);if(_.length>1){_.sort(g);const t=Math.max(Qi(e),Qi(s));let r=0;for(let o=1,a=_.length;o<a;o++){const a=i[_[r]],h=i[_[o]],m=n[_[r]],u=n[_[o]];if(a!==h||m!==u)if(!(ll(e,a,h)<=t&&ll(s,m,u)<=t)||vt(a,0,1)&&vt(m,0,1)||vt(h,0,1)&&vt(u,0,1))r++,_[r]=_[o];else{const t=os.distance(e.getCoord2D(a),s.getCoord2D(m)),i=os.distance(e.getCoord2D(h),s.getCoord2D(u));if(t<=i)continue;if(i<t){_[r]=_[o];continue}}}if(_.length=r+1,1===_.length&&0!==_[0]&&(i[0]=i[_[0]],n[0]=n[_[0]],_[0]=0),_.length>2){const t=kt.constructEmpty(),r=kt.constructEmpty();t.setCoords(i[_[0]],i[_.at(-1)]),r.setCoords(n[_[0]],n[_.at(-1)]);let o=!0;for(let e=1,s=_.length-1;e<s;e++)if(!t.containsCoordinate(i[_[e]])||!r.containsCoordinate(n[_[e]])){o=!1;break}if(o){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let n=0;n<i.length;n++){let a=he(t.vmin,t.vmax,i[n]);const h=e.getCoord2D(a);if(!s.isCloserThanDistance(h,r,m)){o=!1;break}a=he(r.vmin,r.vmax,i[n]);const u=s.getCoord2D(a);if(!e.isCloserThanDistance(u,t,m)){o=!1;break}}}o&&(_[1]=_.at(-1),_.length=2)}}if(1===_.length&&t){const t=0,r=0;Yi(e,s,i[0],n[0],m,1,[t],[r])&&(_.push(1),i[1]=t,n[1]=r,_.sort(g))}if(u&&1===_.length){let t=!0;for(let r=0,o=_.length;r<o;r++){if(vt(i[_[r]],0,1)&&vt(n[_[r]],0,1)){if(0===os.distance(e.getCoord2D(i[_[r]]),s.getCoord2D(n[_[r]])))continue}t=!1;break}if(t)return 0}let p=0;for(let f=0,x=_.length;f<x;f++){if(a&&a.push(i[_[f]]),h&&h.push(n[_[f]]),o){const t=os.getNAN();e.queryCoord2D(i[_[f]],t),o.push(t)}p++}return p}function _l(t,e,s,i,n,r,o,a,h){if(vt(s,0,1)&&vt(i,0,1)){if(0===os.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,u=new Ai,l=Number.EPSILON;if(t.queryDerivative(new Wt(s,l),u),u.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new Wt(s,l).add(e),u)}1===s&&u.negateThis();const c=new Ai;if(e.queryDerivative(new Wt(i,l),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new Wt(i,l).add(t),c)}1===i&&c.negateThis(),u.isZero()||u.normalize(),c.isZero()||c.normalize();const d=u.dotProduct(c),_=u.crossProduct(c);_.scaleError(3);const g=()=>{if(h)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*n/Math.min(s,i),1e-10)}};if(d.ge(Ut)&&(_.isZero()||Math.abs(_.value())<g())){return Fi(t,e,s,i,n,r,o,a)}}}return 0}function gl(e,s,i,n,r){let o=-1,a=-1,h=-1,m=-1;{const t=[0,s],r=[s,0],u=[0,n],l=[n,0];for(let s=0;s<2&&-1===o;++s)for(let n=0;n<2;++n)if(e[t[s]].equals(i[u[n]])){o=t[s],a=r[s],h=u[n],m=l[n];break}}if(-1===o){const t=new Di;t.setFromPoints(e,s+1);const o=new Di;return o.setFromPoints(i,n+1),o.inflate(r),t.isIntersectingW(o)?-1:0}{const u=new Array(s+1),l=tl(e,s+1,u);t(l>1);let c=0,d=0;for(let t=0;t<l;++t)o===u[t]&&(d=t,c++),a===u[t]&&c++;if(2!==c)return-1;const _=new Array(n+1),g=tl(i,n+1,_);t(g>1),c=0;let p=0;for(let t=0;t<g;++t)h===_[t]&&(p=t,c++),m===_[t]&&c++;if(2!==c)return-1;const f=e[u[(d+l-1)%l]],x=e[u[(d+1)%l]],y=i[_[(p+g-1)%g]],v=i[_[(p+1)%g]],P=e[o],b=[f,x,y,v],E=[0,1,2,3];E.sort(((t,e)=>os.compareVectorsOrigin(P,b[t],b[e])));let C=E[0];for(let t=1;t<4;t++){if(E[t]!==(C+1)%4)return-1;C=E[t]}{const t=f.sub(P),e=v.sub(P),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}{const t=x.sub(P),e=y.sub(P),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),o=n*t.length(),a=n*e.length();if(o<=r||a<=r)return-1}}return 1}}var pl=gs;class fl extends Hn{constructor(t){void 0===t?super({XStart:0,YStart:0,XEnd:0,YEnd:0}):void 0!==t.x1?super({XStart:t.x1,YStart:t.y1,XEnd:t.x2,YEnd:t.y2,vd:t.vd}):void 0!==t.pt1?super({start:t.pt1,end:t.pt2,vd:t.vd}):void 0!==t.move?super({move:t.move}):void 0!==t.copy&&super({copy:t.copy})}assignMove(t){return this!==t&&(this.m_description=t.m_description,this.m_attributes=t.m_attributes,t.m_attributes=null,this.m_XStart=t.m_XStart,t.m_XStart=Number.NaN,this.m_YStart=t.m_YStart,this.m_XEnd=t.m_XEnd,t.m_XEnd=Number.NaN,this.m_YEnd=t.m_YEnd),this}assignCopy(t){return this!==t&&t.copyTo(this),this}getBoundary(){return gr(this)}transformAttribute(e,s,i,n,r){t(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?Un(this,t):Qn(this,t);return Xe(pl.getInterpolation(e),this.getStartAttributeAsDbl(e,s),this.getEndAttributeAsDbl(e,s),t,pl.getDefaultValue(e))}constructFromCoords(t,e,s,i){this.dropAllAttributes(),this.setStartXYCoords(t,e),this.setEndXYCoords(s,i)}construct(t,e){this.dropAllAttributes(),this.setStartXY(t),this.setEndXY(e)}constructFromPoints(e,s){t(0)}getGeometryType(){return fl.type}queryEnvelope(e){if(e instanceof Cs){e.setEmpty(),e.assignVertexDescription(this.m_description);const t=as.constructEmpty();this.queryEnvelope(t),e.setEnvelope(t);for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const t=this.m_description.getSemantics(s);for(let i=0,n=pl.getComponentCount(t);s<n;s++){const s=this.queryInterval(t,i);e.setIntervalEnvelope(t,i,s)}}}else e instanceof as?e.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):e instanceof Vs?(e.setEmpty(),e.mergeCoords(this.m_XStart,this.m_YStart,Hi(this,0,1,0)),e.mergeCoords(this.m_XEnd,this.m_YEnd,Hi(this,1,1,0))):t(0)}applyTransformation(e){t(0)}createInstance(){return t(0),this}calculateLength2D(){return Math.sqrt(ur(this))}calculateLength3D(e){return t(0),0}changeEndPoints2D(e,s){t(0)}queryCoord2D(t,e){return On(this,t,e)}queryCoord2DE(t,e){$n(this,t,e)}getCoordX(e){return t(0),0}getCoordY(e){return t(0),0}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createLine();i&&n.assignVertexDescription(this.m_description);const r=os.getNAN();if(On(this,t,r),n.setStartXYCoords(r.x,r.y),On(this,e,r),n.setEndXYCoords(r.x,r.y),!i)for(let o=1,a=this.m_description.getAttributeCount();o<a;o++){const s=this.m_description.getSemantics(o),i=pl.getComponentCount(s);for(let r=0;r<i;r++){const i=this.getAttributeAsDbl(t,s,r);n.setStartAttribute(s,r,i);const o=this.getAttributeAsDbl(e,s,r);n.setEndAttribute(s,r,o)}}}queryDerivative(t,e){Kn(this,t,e)}getClosestCoordinate(t,e){return os.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s){const i=new os;this.queryCoord2D(e.vmin,i);const n=new os;this.queryCoord2D(e.vmax,n);const r=os.getClosestCoordinate(i,n,t,!1);return Hn.recalculateParentT(e.vmin,e.vmax,r)}intersectionOfYMonotonicWithAxisX(t,e){const s=this.m_YEnd-this.m_YStart;if(!s)return t===this.m_YEnd?e:Number.NaN;const i=(t-this.m_YStart)/s;let n=Un(this,i);return 1===i&&(n=this.m_XEnd),n}isCurve(){return!1}isMonotoneQuickAndDirty(){return!0}isDegenerate(t){const e=this.m_XStart-this.m_XEnd,s=this.m_YStart-this.m_YEnd;return Math.sqrt(e*e+s*s)<=t}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new fl;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(e){return t(0),new os(0,0)}calculateWeightedCentroid2D(){return t(0),new os(0,0)}queryAttributeAsDbl(e,s,i,n){t(0)}getTangent(t){const e=os.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(e){return t(0),new os(0,0)}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return or(this,t,e,s)>=0}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}getYMonotonicParts(e,s){return t(0),0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(e,s){return t(0),0}intersectionWithAxis2D(t,e,s,i){if(t){const t=this.m_YEnd-this.m_YStart;if(!t)return e===this.m_YEnd?-1:0;const n=(e-this.m_YStart)/t;return n<0||n>1?0:(s&&(s[0]=Un(this,n)),i&&(i[0]=n),1)}{const t=this.m_XEnd-this.m_XStart;if(!t)return e===this.m_XEnd?-1:0;const n=(e-this.m_XStart)/t;return n<0||n>1?0:(s&&(s[0]=Qn(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){let s=Pt(t.vmin,0,1);const i=new os;this.queryCoord2D(s,i),e.setCoords({pt:i}),s=Pt(t.vmax,0,1),this.queryCoord2D(s,i),e.mergeNe(i)}orientBottomUp(){tr(this)}isLine(){return!0}isDegenerateToLineHelper(e){return t(0),!1}copyIgnoreAttributes(e){t(0)}calculateArea2DHelper(){return t(0),0}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)}queryEnvelopeW(t,e){e.setCoords(this.getCoord2D(t.vmin)),e.mergeNe(this.getCoord2D(t.vmax))}setSegmentFromCoords(e,s){t(0)}writeInBufferStream(e,s){return t(0),0}readFromBufferStream(e,s){t(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(e,s){return t(0),0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){Jn(this,t,e)}static isIntersectingLineLine(e,s,i,n){return t(0),0}static isIntersectingLineLine_(e,s,i,n){return t(0),0}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&b("");const i=or(this,t,s,!1);return i>=0?(e&&(e[0]=i),1):0}isIntersecting(t,e,s){return 0!==ol(!1,this,t,e,s)}intersect_(e,s,i,n){return t(0),0}}fl.type=r.enumLine;class xl{constructor(e){this.m_mask=0,this.m_line=null,this.m_arc=null,this.m_cubicBezier=null,this.m_quadraticRationalBezier=null,this.m_quadraticBezier=null,this.m_seg=null,void 0!==e&&(e.segment?this.copyFrom(e.segment,e.bIgnoreAttributes):e.copy?e.copy.copyTo(this,!1):t(0))}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}assignMoveFromSegment(e){return t(0),this}assignCopyFromSegment(e){return t(0),this}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}empty(){return null===this.m_seg}create(t){t===r.enumLine?this.createLine():t===r.enumEllipticArc?this.createEllipticArc():t===r.enumBezier?this.createCubicBezier():t===r.enumRationalBezier2?this.createQuadraticRationalBezier():t===r.enumBezier2?this.createQuadraticBezier():f("Segment_buffer.create")}createLine(){return 1&this.m_mask||(this.m_line=new fl,this.m_mask|=1),this.m_seg=this.m_line,this.m_line}createEllipticArc(){return 2&this.m_mask?this.m_arc.clearEndPointModified():(this.m_arc=new jr,this.m_mask|=2),this.m_seg=this.m_arc,this.m_arc}createCubicBezier(){return 4&this.m_mask||(this.m_cubicBezier=new vl,this.m_mask|=4),this.m_seg=this.m_cubicBezier,this.m_cubicBezier}createQuadraticRationalBezier(){return 8&this.m_mask||(this.m_quadraticRationalBezier=new lo,this.m_mask|=8),this.m_seg=this.m_quadraticRationalBezier,this.m_quadraticRationalBezier}createQuadraticBezier(){return 16&this.m_mask||(this.m_quadraticBezier=new go,this.m_mask|=16),this.m_seg=this.m_quadraticBezier,this.m_quadraticBezier}get(){return this.m_seg}releaseSegment(){const t=this.m_seg;if(this.m_seg=null,t===this.m_line){const e=t;return this.m_line=null,this.m_mask&=-2,e}if(t===this.m_arc){const e=t;return this.m_arc=null,this.m_mask&=-3,e}if(t===this.m_cubicBezier){const e=t;return this.m_cubicBezier=null,this.m_mask&=-5,e}if(t===this.m_quadraticRationalBezier){const e=t;return this.m_quadraticRationalBezier=null,this.m_mask&=-9,e}if(t===this.m_quadraticBezier){const e=t;return this.m_quadraticBezier=null,this.m_mask&=-17,e}E("Segment_buffer::release_segment")}}var yl=gs;class vl extends Hn{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=Ue(os,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t?(super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=Ue(os,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)):t.from?(super({start:t.from,end:t.to,vd:t.vd}),this.m_cp=Ue(os,2),this.m_cp[0].assign(t.cp1),this.m_cp[1].assign(t.cp2)):(super({XStart:0,YStart:0,XEnd:0,YEnd:0,vd:t.vd}),this.m_cp=Ue(os,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return gr(this)}assignMove(e){return t(0),this}assignCopy(e){return t(0),this}construct(t,e,s,i){this.m_XStart=t.x,this.m_YStart=t.y,this.m_XEnd=i.x,this.m_YEnd=i.y,this.m_cp[0].assign(e),this.m_cp[1].assign(s),this.afterCompletedModification()}constructPoints(t){this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.afterCompletedModification()}constructFromQuadratic(t){const e=Ue(os,4);ca(t,e),this.constructPoints(e)}constructFromQuadraticSegment(t){this.dropAllAttributes(),this.assignVertexDescription(t.getDescription()),this.m_XStart=t.getStartX(),this.m_YStart=t.getStartY(),this.m_XEnd=t.getEndX(),this.m_YEnd=t.getEndY(),ie(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),ie(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),ji(this,t)}getGeometryType(){return r.enumBezier}queryEnvelope(e){if(!(e instanceof as))return void t(0);if(e.setCoords(this.getStartXY()),e.mergeNe(this.getEndXY()),e.contains(this.m_cp[0])&&e.contains(this.m_cp[1]))return;const s=Gm(this);if(null!==s){const t=new os;for(const i of s.specialPoints)this.queryCoord2D(i,t),e.mergeNe(t);return}const i=Ue(Wt,8),n=Ue(os,4);this.queryControlPoints(n);const r=Ru(n,i),o=new os;for(let t=1;t<r-1;t++)this.queryCoord2D(i[t].value(),o),e.mergeNe(o)}applyTransformation(e){if(e instanceof cn){const t=Ue(os,4);return this.queryControlPoints(t),e.transformPoints(t,4,t),this.setStartXY(t[0]),this.m_cp[0].assign(t[1]),this.m_cp[1].assign(t[2]),this.setEndXY(t[3]),void Zm(this)}t(0)}createInstance(){return new vl({vd:this.m_description})}calculateLength2D(){return Vm(this,1,!1)}calculateLowerLength2D(){return os.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return os.distance(this.getStartXY(),this.m_cp[0])+os.distance(this.m_cp[0],this.m_cp[1])+os.distance(this.getEndXY(),this.m_cp[1])}calculateUpperLength2D_(){return t(0),0}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DExtends(t,e,s){const i=Ue(os,4);this.queryControlPoints(i),hu(i,t,e,s)}queryCoord2DE(t,e){uu(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new os;return this.queryCoord2DExtends(t,e,!0),e.x}const e=he(this.getStartX(),this.m_cp[0].x,t),s=he(this.m_cp[0].x,this.m_cp[1].x,t),i=he(this.m_cp[1].x,this.getEndX(),t),n=he(e,s,t),r=he(s,i,t);return he(n,r,t)}getCoordY(t){if(t<0||t>1){const e=new os;return this.queryCoord2DExtends(t,e,!0),e.y}const e=he(this.getStartY(),this.m_cp[0].y,t),s=he(this.m_cp[0].y,this.m_cp[1].y,t),i=he(this.m_cp[1].y,this.getEndY(),t),n=he(e,s,t),r=he(s,i,t);return he(n,r,t)}cut(t,e,s){const i=new xl;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const n=s.createCubicBezier();if(this.cutBezierIgnoreAttributes(t,e,n),i)return;n.assignVertexDescription(this.m_description);const r=this.m_description.getAttributeCount();if(r>1){for(let e=1;e<r;e++){const s=this.m_description.getSemantics(e),i=yl.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);n.setStartAttribute(s,e,i)}}for(let t=1;t<r;t++){const s=this.m_description.getSemantics(t),i=yl.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){cu(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&f("Cubic_bezier.cut_bezier_ignore_attributes");const i=Ue(os,4);this.queryControlPoints(i);const n=Ue(os,4);au(i,t,e,n),s.setControlPoints(n)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&f("Cubic_bezier.split_bezier_ignore_attributes");const i=Ue(os,4);this.queryControlPoints(i);const n=Ue(os,4),r=Ue(os,4);ou(i,t,n,r),e&&e.setControlPoints(n),s&&s.setControlPoints(r)}getAttributeAsDbl(e,s,i){return t(0),0}getClosestCoordinate(t,e){const s=[Number.NaN];return Tu(this,t,kt.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s){const i=[Number.NaN];return 0===Tu(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(e,s=!1){return t(0),0}getMonotonicParts(e,s){e.length<2&&f("");const i=km(this);if(2===i.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let n=0;t(e.length>=i.specialPointsCount()-1);for(let t=1,r=i.specialPointsCount();t<r;++t)this.queryCut(i.specialPoints[t-1],i.specialPoints[t],e[n],s),n++;for(let t=0;t<n;++t){su(e[t].get())}return n}intersectionWithAxis2D(t,e,s,i){const n=Ue(os,4);return this.queryControlPoints(n),Fu(n,t,e,s,i)}intersectionOfYMonotonicWithAxisX(e,s){if(this.m_YStart===this.m_YEnd)return e===this.m_YStart?s:Number.NaN;if(e===this.m_YStart)return this.m_XStart;if(e===this.m_YEnd)return this.m_XEnd;const i=[0,0],n=this.intersectionWithAxis2D(!0,e,i,null);return t(2!==n),-1===n?s:i[0]}isCurve(){return!0}isDegenerate(t){return qi(this,t)}isDegenerate3D(e,s){return t(0),!1}queryLooseEnvelope(e){if(e instanceof as)return e.setCoords({pt:this.getStartXY()}),e.mergeNe(this.m_cp[0]),e.mergeNe(this.m_cp[1]),void e.mergeNe(this.getEndXY());t(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=as.constructEmpty();this.queryEnvelope(t);const s=kt.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=Ue(os,4);this.queryControlPoints(s),au(s,t.vmin,t.vmax,s),e.setFromPoints(s,4)}changeEndPoints2D(t,e){if(t.isEqual(this.m_XStart,this.m_YStart)&&e.isEqual(this.m_XEnd,this.m_YEnd))return;const s=this.m_cp[0].isEqual(this.m_XStart,this.m_YStart),i=this.m_cp[0].isEqual(this.m_XEnd,this.m_YEnd),n=this.m_cp[1].isEqual(this.m_XStart,this.m_YStart),r=this.m_cp[1].isEqual(this.m_XEnd,this.m_YEnd);this.setStartXY(t),this.setEndXY(e),s?this.m_cp[0].setCoordsPoint2D(t):i&&this.m_cp[0].setCoordsPoint2D(e),r?this.m_cp[1].setCoordsPoint2D(e):n&&this.m_cp[1].setCoordsPoint2D(t),this.normalizeAfterEndpointChange()}tToLength(t){return Vm(this,t,!0)}lengthToT(t){return Bm(this,t)}calculateWeightedAreaCentroid2D(e){return t(0),os.getNAN()}calculateWeightedCentroid2D(){return t(0),os.getNAN()}getControlPoint1(){return this.m_cp[0].clone()}setControlPoint1(t){this.m_cp[0].setCoordsPoint2D(t),this.afterCompletedModification()}getControlPoint2(){return this.m_cp[1].clone()}setControlPoint2(t){this.m_cp[1].setCoordsPoint2D(t),this.afterCompletedModification()}queryControlPoints(t){t[0].assign(this.getStartXY()),t[1].assign(this.m_cp[0]),t[2].assign(this.m_cp[1]),t[3].assign(this.getEndXY())}setControlPoints(t){for(let e=0;e<4;e++)t[e].isNAN()&&f("NAN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp[0].setCoordsPoint2D(t[1]),this.m_cp[1].setCoordsPoint2D(t[2]),this.m_XEnd=t[3].x,this.m_YEnd=t[3].y,this.afterCompletedModification()}getTangent(t){const e=Ue(os,4);return this.queryControlPoints(e),lu(e,t)}getDerivative(e){return t(0),os.getNAN()}getCurvature(t){const e=tu(this,1,t),s=tu(this,2,t),i=e.sqrLength();if(0===i)return Number.NaN;e.divThis(Math.sqrt(i));return e.crossProduct(s)/i}isIntersectingPoint(e,s,i){return t(0),!1}isIntersectingPoint3D(e,s,i,n,r=1){return t(0),!1}queryAttributeAsDbl(e,s,i,n){t(0)}isMonotoneQuickAndDirty(){const t=Ue(os,4);return this.queryControlPoints(t),nu(t)}getMonotonicPartParams(e,s){const i=km(this),n=i.specialPointsCount();if(t(Hn.s_maxMonotonicPartParams>=n),!s)return i.specialPointsCount();e<n&&f("");for(let t=0;t<n;t++)s[t]=i.specialPoints[t];return n}normalizeAfterEndpointChange(){return!1}orientBottomUp(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=Ve(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=Ve(this.m_YStart,this.m_YStart=this.m_YEnd);for(let t=0,e=this.m_description.getTotalComponentCount()-2;t<e;t++)this.m_attributes[t+e]=Ve(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=Ve(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new Wt;return Um(this,t),t.value()}queryConvexHull2D(e){return t(0),0}isLine(){return!1}isDegenerateToLineHelper(e){return t(0),!1}copyIgnoreAttributes(t){const e=Ue(os,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return eu(this)}absNorm(){return Iu(this)}queryEnvelopeW(t,e){Du(this,t,e)}setSegmentFromCoords(t,e){Mu(this,t,e)}writeInBufferStream(t,e){const s=new Float64Array(4);return this.writeInBuffer_(s),t.writeRangeFromArray(e,s.length,s,!0,1),e+s.length}writeInBuffer_(t){return t[0]=this.m_cp[0].x,t[1]=this.m_cp[0].y,t[2]=this.m_cp[1].x,t[3]=this.m_cp[1].y,4}readFromBufferStream(t,e){const s=new Float64Array(4);t.queryRange(e,s.length,s,!0,1),this.readFromBuffer_(s)}readFromBuffer_(t){this.m_cp=Ue(os,2),this.m_cp[0].x=t[0],this.m_cp[0].y=t[1],this.m_cp[1].x=t[2],this.m_cp[1].y=t[3],this.m_cachedValues=null}snapControlPoints(t){const e=Ue(os,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(os.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);os.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return(i||n)&&this.setControlPoints(e),i||n}needsSnapControlPoints(t){if(!t)return!1;const e=Ue(os,4);this.queryControlPoints(e);const s=(e,s,i)=>{let n=!1;if(os.sqrDistance(e,i)<=t){n=!e.equals(i),e.setCoordsPoint2D(i);os.sqrDistance(s,i)<=t&&(n||=!s.equals(i),s.setCoordsPoint2D(i))}return n},i=s(e[1],e[2],e[0]),n=s(e[2],e[1],e[3]);return i||n}calculateSpecialPointsForCracking(t,e){return Xu(this,t,e)}ensureXYMonotone(){return su(this)}setCoordsForIntersector(t,e,s){Hm(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp[0].assign(this.m_cp[0]),e.m_cp[1].assign(this.m_cp[1]),Wm(e,Gm(this))}reverseImpl(){this.m_cp[1]=Ve(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t,s=0,i=1;return!!this.m_cp[0].equals(e.m_cp[s])&&!!this.m_cp[1].equals(e.m_cp[i])}equalsImplTol(t,e){const s=t,i=0,n=1;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[i],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[n],e)}getHashCodeImpl(){return t(0),0}swapImpl(e){t(0)}afterCompletedModification(){Zm(this)}isIntersecting(t,e,s){return 0!==ol(!1,this,t,e,s)}intersect(t,e,s,i,n){return ul(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return Cu(this,t,e,s)}intersect_(e,s,i,n){return t(0),0}endPointModified(){Zm(this)}clearEndPointModified(){t(0)}}vl.type=r.enumBezier;export{pm as $,gi as A,di as B,M as C,ti as D,Cs as E,Ue as F,r as G,xl as H,$ as I,Dt as J,N as K,fl as L,dn as M,vl as N,kt as O,Ci as P,lo as Q,go as R,qn as S,jr as T,P as U,hu as V,wm as W,le as X,su as Y,iu as Z,Ko as _,Ur as a,ut as a$,ih as a0,cn as a1,Er as a2,li as a3,ii as a4,T as a5,ui as a6,Zs as a7,Ws as a8,oi as a9,uo as aA,to as aB,he as aC,Dh as aD,xm as aE,Hn as aF,m as aG,Gs as aH,mt as aI,At as aJ,Q as aK,tr as aL,ul as aM,D as aN,Ds as aO,$u as aP,$e as aQ,We as aR,Ke as aS,hl as aT,ml as aU,K as aV,_l as aW,je as aX,lt as aY,ct as aZ,Pt as a_,ai as aa,Fs as ab,Hs as ac,si as ad,ol as ae,Rs as af,gs as ag,ge as ah,U as ai,Wu as aj,Vs as ak,ei as al,a as am,mi as an,Qs as ao,_ as ap,Ve as aq,q as ar,ks as as,Xs as at,h as au,ce as av,Oe as aw,Ku as ax,al as ay,Be as az,cr as b,$s as b0,x as b1,Nn as c,Mn as d,as as e,ni as f,Ju as g,t as h,gr as i,os as j,c as k,_r as l,Je as m,Ou as n,u as o,A as p,l as q,E as r,w as s,f as t,pi as u,hi as v,fi as w,y as x,ci as y,_i as z};