@arcgis/core 4.32.0-next.20250107 → 4.32.0-next.20250108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/WebLinkChart.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{07304287ed5244fa4e12.js → 12b2c8251ec2d0e2ca46.js} +1 -1
- package/assets/esri/core/workers/chunks/24a597ae32a2083a50a5.js +1 -0
- package/assets/esri/core/workers/chunks/510cb8647841fec436c8.js +1 -0
- package/assets/esri/core/workers/chunks/{f6d6bc43ac1c13892d44.js → 58485909e1cfeb52c01e.js} +1 -1
- package/assets/esri/core/workers/chunks/{c49707b577f3805f0142.js → 5b61a1e7ac60a02a906d.js} +1 -1
- package/assets/esri/core/workers/chunks/76a7114a69264f5c07b0.js +2 -0
- package/assets/esri/core/workers/chunks/{ca1e186f136abb23ae4b.js → 7d0fc25ce1f74adcfeb6.js} +1 -1
- package/assets/esri/core/workers/chunks/{dca0eb66116e4b5403fc.js → 7df076d15b7b7a66dcee.js} +1 -1
- package/assets/esri/core/workers/chunks/{955421ee2247965244f0.js → 7fe92f072d3641ec4662.js} +1 -1
- package/assets/esri/core/workers/chunks/{4423aac6e44c3dbf184e.js → 89286d8f59844724cd16.js} +1 -1
- package/assets/esri/core/workers/chunks/a8ec4189ec3b37d5ff74.js +1 -0
- package/assets/esri/core/workers/chunks/cd92b80de7e9f982f9a9.js +1 -0
- package/chunks/CrackAndCluster-CfzXpEle.js +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/OperatorProject.js +1 -1
- package/chunks/Pattern.glsl.js +1 -1
- package/chunks/QuadraticBezier.js +1 -1
- package/chunks/Transformation2D.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/chunks/vxlLayer.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/interfaces.d.ts +175 -91
- package/layers/LinkChartLayer.js +1 -1
- package/layers/MapNotesLayer.js +1 -1
- package/layers/MediaLayer.js +1 -1
- package/layers/support/ImageElement.js +1 -1
- package/layers/support/VideoElement.js +1 -1
- package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/linkChart/OrganicLayoutSettings.js +1 -1
- package/package.json +3 -3
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/size.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/support/mediaLayerUtils.js +5 -0
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/views/2d/AnimationManager.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/SDFConverter.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/hittestUtils.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/navigation/MapViewNavigation.js +1 -1
- package/views/2d/support/HighlightGroup.js +1 -1
- package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
- package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
- package/views/3d/analysis/support/measurementUtils.js +1 -1
- package/views/3d/environment/CloudsParameters.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/graphics/placementUtils.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/HighlightGroup.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TilePerLayerInfo.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/TileTexture.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/View.js +1 -1
- package/views/input/BrowserEventSource.js +1 -1
- package/views/layers/MediaLayerView.js +1 -1
- package/views/support/HighlightGroup.d.ts +4 -0
- package/views/support/HighlightGroup.js +5 -0
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/textureUtils.js +1 -1
- package/webscene/Slide.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
- package/widgets/CatalogLayerList.js +1 -1
- package/widgets/FeatureTable/support/exportUtils.js +1 -1
- package/widgets/LayerList/support/layerListUtils.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Legend/styles/support/relationshipUtils.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/TableList.js +1 -1
- package/assets/esri/core/workers/chunks/127c82cdb229434883b6.js +0 -1
- package/assets/esri/core/workers/chunks/66b411119b8ffb99b9dc.js +0 -1
- package/assets/esri/core/workers/chunks/8cd2c9ec1e541836b81c.js +0 -1
- package/assets/esri/core/workers/chunks/b07710e01494a6cda097.js +0 -1
- package/assets/esri/core/workers/chunks/c05e0bd145a1c27d6857.js +0 -2
- package/views/2d/support/HighlightGroup.d.ts +0 -4
- /package/assets/esri/core/workers/chunks/{c05e0bd145a1c27d6857.js.LICENSE.txt → 76a7114a69264f5c07b0.js.LICENSE.txt} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[9192],{54573:(t,e,s)=>{s.d(e,{a:()=>a,b:()=>h,c:()=>o});var i=s(35368),n=s(55537),r=s(11878);function o(t,e,s,i,n){return a(t,e,null,s,i,n)}function a(t,e,s,r,a,h){const l=t.getGeometryType();if(l===n.G.enumPoint){const s=t.getXY();return e.contains(s)?t:t.createInstance()}if(l===n.G.enumEnvelope){const s=i.a.constructEmpty();if(t.queryEnvelope(s),s.intersect(e)){const e=t.clone();return e.setEnvelope(s),e}return t.createInstance()}if(t.isEmpty())return t;if(e.isEmpty())return t.createInstance();const u=e.clone();{const e=new i.a;if(t.queryLooseEnvelope(e),u.containsEnvelope(e))return t;if(!u.isIntersecting(e))return t.createInstance();0===a&&(e.intersect(u),e.inflate(Math.max(.1*e.maxDimension(),1)),e.intersect(u),u.assign(e))}let c=r;if((null!==s||Number.isNaN(c))&&(c=(0,i.b)(s,u,!1).total()),l===n.G.enumGeometryCollection){const e=t,s=t.createInstance();for(let t=0,i=e.getGeometryCount();t<i;t++){const i=e.getGeometry(t);if(i.isEmpty())continue;const n=o(i,u,c,a,h);n.isEmpty()||(n===i?s.addGeometry(n.clone()):s.addGeometry(n))}return s}(0,n.i)(l)||(0,n.t)("Clip: geometry not supported");const g=t.getImpl().getAccelerators();if(null!==g){const t=g.getRasterizedGeometry();(0,n.g)(null===t)}switch(l){case n.G.enumMultiPoint:{const e=t;let s;const i=e.getPointCount(),r=e.getImpl().getAttributeStreamRef(0);let o=0;for(let t=0;t<i;t++){const i=r.readPoint2D(2*t);u.contains(i)||(0===o&&(s=e.createInstance()),o<t&&s.addPoints(e,o,t),o=t+1)}return o>0&&s.addPoints(e,o,i),0===o?e:((0,n.g)(null!==s),s)}case n.G.enumPolygon:case n.G.enumPolyline:return function(t,e,s,i,n){return new m(e,n).clipMultiPath2(t,s,i)}(t,u,c,a,h);default:(0,n.b)("")}}function h(t,e,s,n,r,o){const a=new m(e,o),h=new i.a;return t.queryLooseEnvelope(h),e.containsEnvelope(h)?t:e.isIntersecting(h)?a.clipPolesOut(t,r):t.createInstance()}class m{constructor(t,e){this.m_shape=new i.d,this.m_geometry=i.n,this.m_verticesOnExtentIndex=-1,this.m_verticesOnExtent=[],this.m_progressCounter=0,this.m_extent=new i.a(t),this.m_progressTracker=e}progress_(){}clipMultiPath2(t,e,s){return t.getGeometryType()===n.G.enumPolygon?this.clipPolygonOrProjectedPolyline2(t,s):this.clipPolyline(t,e)}clipPolygonOrProjectedPolyline2(t,e){const s=t.getGeometryType()===n.G.enumPolyline;if(0===this.m_extent.width()||0===this.m_extent.height())return t.createInstance();const o=i.a.constructEmpty();t.queryLooseEnvelope(o),this.m_geometry=s?this.m_shape.addGeometry(t):this.m_shape.addGeometry(t,this.m_extent);const a=i.a.constructEmpty(),h=i.a.constructEmpty(),l=new r.P,u=new r.P,c=new Array(9),g=new Array(9),_=(0,r.m)(r.P,9);let d=null;const p=new i.L,f=[];let x=!1;for(let t=0;!x&&t<4;t++){let e=!1;const r=!!(1&t);let y=0;switch(t){case 0:y=this.m_extent.xmin,e=o.xmin<=y&&o.xmax>=y;break;case 1:y=this.m_extent.ymin,e=o.ymin<=y&&o.ymax>=y;break;case 2:y=this.m_extent.xmax,e=o.xmin<=y&&o.xmax>=y;break;case 3:y=this.m_extent.ymax,e=o.ymin<=y&&o.ymax>=y}if(e){x=!0;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==i.n;){let o=!0,P=-1,E=-1;const C=this.m_shape.getFirstVertex(e);let v=C;do{this.progress_(),d=this.m_shape.getSegment(v);let e=d;if(null===e){const t=this.m_shape.getNextVertex(v);if(t===i.n){(0,n.g)(s),0===P&&f.push(v);break}this.m_shape.queryXY(v,l),p.setStartXY(l),this.m_shape.queryXY(t,u),p.setEndXY(u),e=p}e.queryLooseEnvelope(a);let C=m.checkSegmentIntersection(a,t,y);e.isCurve()&&0===C&&e.isCurve()&&(p.setStartXY(e.getStartXY()),p.setEndXY(e.getEndXY()),this.m_shape.replaceCurveWithLine(v),e=p,p.queryEnvelope(a),C=m.checkSegmentIntersection(a,t,y));let b=0,S=i.n;if(-1===C){const s=e.intersectionWithAxis2D(r,y,c,g);if(s>0){let t=null;if(e.isCurve()){t=_,(0,n.g)(s<=9);for(let t=0;t<s;t++)r?_[t].setCoords(c[t],y):_[t].setCoords(y,c[t]);b=this.m_shape.splitSegmentAxisAware(v,g,s,t,r?1:0)}else b=this.m_shape.splitSegmentAxisAware(v,g,s,null,-1)}else b=0;b+=1;let i=v,a=this.m_shape.getNextVertex(i);e=null;for(let e=0;e<b;e++){this.m_shape.queryXY(i,l),this.m_shape.queryXY(a,u),d=this.m_shape.getSegment(i);let e=d;null===e&&(p.setStartXY(l),p.setEndXY(u),e=p),e.queryEnvelope(h);let s=m.checkSegmentIntersection(h,t,y);e.isCurve()&&0===s&&(this.m_shape.replaceCurveWithLine(i),p.setStartXY(l),p.setEndXY(u),e=p,e.queryEnvelope(h),s=m.checkSegmentIntersection(h,t,y)),-1===s&&(r?Math.abs(l.y-y)<Math.abs(u.y-y)?(l.y=y,this.m_shape.setXY(i,l)):(u.y=y,this.m_shape.setXY(a,u)):Math.abs(l.x-y)<Math.abs(u.x-y)?(l.x=y,this.m_shape.setXY(i,l)):(u.x=y,this.m_shape.setXY(a,u)),d=this.m_shape.getSegment(i),e=d,null===e&&(p.setStartXY(l),p.setEndXY(u),e=p),e.queryEnvelope(h),s=m.checkSegmentIntersection(h,t,y),-1===s&&(s=m.checkSegmentIntersectionLoose(h,t,y)));const n=P;P=s,-1===E&&(E=P),0===n&&1===P||1===n&&0===P||0===n&&0===P&&f.push(i),1===P&&(x=!1,o=!1),i=a,S=i,a=this.m_shape.getNextVertex(a)}}if(0===b){const t=P;P=C,-1===E&&(E=P),0===t&&P>=1||t>=1&&0===P||0===t&&0===P&&f.push(v),1===P&&(x=!1,o=!1),S=this.m_shape.getNextVertex(v)}if(v=S,f.length>=256){for(let t=1,e=f.length-1;t<e;t++){const e=f[t];s?this.m_shape.snapVertexForPoleClipping(e,y):this.m_shape.removeVertex(e,!1)}f[1]=f.at(-1),f.length=2}}while(v!==C);if(!o){0!==E||!s&&0!==P&&2!==P||f.push(C);for(let t=0,e=f.length;t<e;t++){const e=f[t];s?this.m_shape.snapVertexForPoleClipping(e,y):this.m_shape.removeVertex(e,!1)}}f.length=0,e=o||0===this.m_shape.getPathSize(e)?this.m_shape.removePath(e):this.m_shape.getNextPath(e)}}}if(x)return t.createInstance();d=null,s?this.removeSpikesAlongPoles():this.resolveBoundaryOverlaps(),e>0&&this.densifyAlongClipExtent(e);const y=this.m_shape.getGeometry(this.m_geometry);return y.getGeometryType()===n.G.enumPolygon&&y.setFillRule(t.getFillRule()),y}clipPolyline(t,e){const s=i.a.constructEmpty(),n=i.a.constructEmpty(),o=new Array(9),a=new Array(9),h=new i.S;let l=t;const u=i.a.constructEmpty();t.queryLooseEnvelope(u);for(let e=0;e<4;e++){let i=!1;const c=!!(1&e);let g=0;switch(e){case 0:g=this.m_extent.xmin,i=u.xmin<=g&&u.xmax>=g;break;case 1:g=this.m_extent.ymin,i=u.ymin<=g&&u.ymax>=g;break;case 2:g=this.m_extent.xmax,i=u.xmin<=g&&u.xmax>=g;break;case 3:g=this.m_extent.ymax,i=u.ymin<=g&&u.ymax>=g}if(!i)continue;const _=l;l=t.createInstance();const d=_.getImpl().querySegmentIterator();d.resetToFirstPath();const p=new r.P,f=new r.P;for(;d.nextPath();){let t=-1,i=!0;for(;d.hasNextSegment();){this.progress_();const r=d.nextSegment(),u=r.isDegenerate(0);r.queryLooseEnvelope(s);const _=m.checkSegmentIntersection(s,e,g);if(-1===_){const s=r.intersectionWithAxis2D(c,g,o,a);let _=0;p.assign(r.getStartXY());for(let d=0;d<=s;d++){const x=d<s?a[d]:1;if(_===x)continue;r.queryCut(_,x,h,!1);const y=h.get();let P=!1;if(y.getStartXY().equals(p)||(y.setStartXY(p),P=!0),d<s&&(c?(f.x=o[d],f.y=g):(f.x=g,f.y=o[d]),y.getEndXY().equals(f)||(y.setEndXY(f),P=!0)),P&&y.normalizeAfterEndpointChange(),!u&&y.isDegenerate(0))continue;y.queryEnvelope(n);let E=m.checkSegmentIntersection(n,e,g);if(-1===E){const t=y.getStartXY(),s=y.getEndXY();P=!1,c?Math.abs(t.y-g)<Math.abs(s.y-g)?(t.y=g,y.setStartXY(t),t.equals(y.getStartXY())||(y.setStartXY(t),P=!0)):(s.y=g,s.equals(y.getEndXY())||(y.setEndXY(s),P=!0)):Math.abs(t.x-g)<Math.abs(s.x-g)?(t.x=g,t.equals(y.getStartXY())||(y.setStartXY(t),P=!0)):(s.x=g,s.equals(y.getEndXY())||(y.setEndXY(s),P=!0)),P&&y.normalizeAfterEndpointChange(),y.queryEnvelope(n),E=m.checkSegmentIntersection(n,e,g),-1===E&&(E=m.checkSegmentIntersectionLoose(n,e,g))}p.assign(y.getEndXY()),_=x,t=E,t>=1?(l.addSegment(y,i),i=!1):i=!0}}else t=_,t>=1?(l.addSegment(r,i),i=!1):i=!0}}}return l}static checkSegmentIntersection(t,e,s){switch(e){case 0:return t.xmin<s&&t.xmax<=s?0:t.xmin>=s?t.xmax===s?2:1:-1;case 1:return t.ymin<s&&t.ymax<=s?0:t.ymin>=s?t.ymax===s?2:1:-1;case 2:return t.xmin>=s&&t.xmax>s?0:t.xmax<=s?t.xmin===s?2:1:-1;case 3:return t.ymin>=s&&t.ymax>s?0:t.ymax<=s?t.ymin===s?2:1:-1}return(0,n.b)(""),0}static checkSegmentIntersectionLoose(t,e,s){switch(e){case 0:{const e=Math.abs(t.xmin-s),i=Math.abs(t.xmax-s);return t.xmin<s?e>i?0:1:((0,n.b)(""),1)}case 1:{const e=Math.abs(t.ymin-s),i=Math.abs(t.ymax-s);return t.ymin<s?e>i?0:1:((0,n.b)(""),1)}case 2:{const e=Math.abs(t.xmin-s),i=Math.abs(t.xmax-s);return t.xmax>s?e<i?0:1:((0,n.b)(""),1)}case 3:{const e=Math.abs(t.ymin-s),i=Math.abs(t.ymax-s);return t.ymax>s?e<i?0:1:((0,n.b)(""),1)}}return(0,n.b)(""),0}resolveBoundaryOverlaps(){this.m_verticesOnExtentIndex=-1,this.splitSegments(!1,this.m_extent.xmin),this.splitSegments(!1,this.m_extent.xmax),this.splitSegments(!0,this.m_extent.ymin),this.splitSegments(!0,this.m_extent.ymax),this.m_verticesOnExtent.length=0,this.m_verticesOnExtentIndex=this.m_shape.createUserIndex();const t=new r.P;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==i.n;e=this.m_shape.getNextPath(e)){let s=this.m_shape.getFirstVertex(e);for(let i=0,n=this.m_shape.getPathSize(e);i<n;i++,s=this.m_shape.getNextVertex(s))this.progress_(),this.m_shape.queryXY(s,t),this.m_extent.xmin!==t.x&&this.m_extent.xmax!==t.x&&this.m_extent.ymin!==t.y&&this.m_extent.ymax!==t.y||(this.m_shape.setUserIndex(s,this.m_verticesOnExtentIndex,this.m_verticesOnExtent.length),this.m_verticesOnExtent.push(s))}this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmin),this.dbgCheckPathFirst(),this.resolveOverlaps(!1,this.m_extent.xmax),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymin),this.dbgCheckPathFirst(),this.resolveOverlaps(!0,this.m_extent.ymax),this.fixPaths()}densifyAlongClipExtent(t){const e=new r.P(0,0),s=new r.P(0,0),o=new Array(2048);for(let a=this.m_shape.getFirstPath(this.m_geometry);a!==i.n;a=this.m_shape.getNextPath(a)){const i=this.m_shape.getFirstVertex(a);let h=i;do{const i=this.m_shape.getNextVertex(h);this.m_shape.queryXY(h,e);let a=-1;if(e.x===this.m_extent.xmin?(this.m_shape.queryXY(i,s),s.x===this.m_extent.xmin&&(a=1)):e.x===this.m_extent.xmax&&(this.m_shape.queryXY(i,s),s.x===this.m_extent.xmax&&(a=1)),e.y===this.m_extent.ymin?(this.m_shape.queryXY(i,s),s.y===this.m_extent.ymin&&(a=0)):e.y===this.m_extent.ymax&&(this.m_shape.queryXY(i,s),s.y===this.m_extent.ymax&&(a=0)),-1===a){h=i;continue}if(this.isCurve(h)){h=i;continue}const m=e.clone(),l=new r.P(0,0);if(a){const i=e.y-this.m_extent.ymin;l.y=(0,r.s)(s.y-e.y),m.y=t*(0,r.c)(Math.floor(Math.abs(i)/t),i)+this.m_extent.ymin,l.y<0&&(m.y+=t)}else{const i=e.x-this.m_extent.xmin;l.x=(0,r.s)(s.x-e.x),m.x=t*(0,r.c)(Math.floor(Math.abs(i)/t),i)+this.m_extent.xmin,l.x<0&&(m.x+=t)}const u=a?s.y-e.y:s.x-e.x,c=Math.abs(u);if(c/t>65536&&(0,n.b)(""),c>0){const s=Math.trunc(c/t)+2;o.length<s&&(o.length=s);let i=0;for(let s=0;;s++){const r=m.add(l.mul(s*t)),h=(a?r.y-e.y:r.x-e.x)/u;if(h>=1)break;h<=0||((0,n.g)(i<=o.length),o[i]=h,i++)}0!==i&&this.m_shape.splitSegment(h,o,i)}h=i}while(h!==i)}}splitSegments(t,e){let s=-1;const n=new r.P,o=[];for(let r=this.m_shape.getFirstPath(this.m_geometry);r!==i.n;r=this.m_shape.getNextPath(r)){let a=this.m_shape.getFirstVertex(r),h=i.n;for(let i=0,m=this.m_shape.getPathSize(r);i<m;i++,a=h)if(this.progress_(),h=this.m_shape.getNextVertex(a),this.m_shape.queryXY(a,n),(t?n.y===e:n.x===e)&&(this.m_shape.queryXY(h,n),t?n.y===e:n.x===e)){if(this.isCurve(a))continue;-1===s&&(s=this.m_shape.createUserIndex()),1!==this.m_shape.getUserIndex(a,s)&&(o.push(a),this.m_shape.setUserIndex(a,s,1)),1!==this.m_shape.getUserIndex(h,s)&&(o.push(h),this.m_shape.setUserIndex(h,s,1))}}if(-1!==s&&this.m_shape.removeUserIndex(s),o.length<3)return;o.sort(((t,e)=>this.compareVertices(t,e)));const a=new r.P,h=new r.P,m=new r.P;h.setNAN();let l=-1,u=[],c=[];const g=this.m_shape.createUserIndex(),_=this.m_shape.createUserIndex();for(let s=0,i=o.length;s<i;s++){const i=o[s];if(this.m_shape.queryXY(i,n),!n.isEqualPoint2D(h)){if(-1===l){l=s,h.setCoordsPoint2D(n);continue}for(let i=l;i<s;i++){const s=o[i],n=this.m_shape.getNextVertex(s),r=this.m_shape.getPrevVertex(s);let m=!1;this.m_shape.queryXY(n,a),h.compare(a)<0&&(t?a.y===e:a.x===e)&&(this.isCurve(s)||(u.push(s),m=!0,this.m_shape.setUserIndex(s,_,1))),this.m_shape.queryXY(r,a),h.compare(a)<0&&(t?a.y===e:a.x===e)&&(this.isCurve(r)||(m||u.push(s),this.m_shape.setUserIndex(s,g,1)))}for(let t=0,e=u.length;t<e;t++){const e=u[t],s=this.m_shape.getUserIndex(e,g),i=this.m_shape.getUserIndex(e,_);if(1===s){const t=this.m_shape.getPrevVertex(e);this.m_shape.queryXY(t,m);let s=0;if(!m.isEqualPoint2D(n)){const i=r.P.distance(h,m);s=r.P.distance(m,n)/i,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(t,[s],1);const o=this.m_shape.getPrevVertex(e);this.m_shape.setXY(o,n),c.push(o),this.m_shape.setUserIndex(o,g,1),this.m_shape.setUserIndex(o,_,-1)}}if(1===i){const t=this.m_shape.getNextVertex(e);this.m_shape.queryXY(t,m);let s=0;if(!m.isEqualPoint2D(n)){const t=r.P.distance(h,m);s=r.P.distance(h,n)/t,0===s?s=Number.EPSILON:1===s&&(s=1-Number.EPSILON),this.m_shape.splitSegment(e,[s],1);const i=this.m_shape.getNextVertex(e);this.m_shape.setXY(i,n),c.push(i),this.m_shape.setUserIndex(i,g,-1),this.m_shape.setUserIndex(i,_,1)}}}const i=u;u=c,c=i,c.length=0,l=s,h.setCoordsPoint2D(n)}}this.m_shape.removeUserIndex(g),this.m_shape.removeUserIndex(_)}resolveOverlaps(t,e){const s=new r.P,o=[];let a=-1;for(let n=0,r=this.m_verticesOnExtent.length;n<r;n++){this.progress_();const r=this.m_verticesOnExtent[n];if(r===i.n)continue;const h=this.m_shape.getNextVertex(r);if(this.m_shape.queryXY(r,s),(t?s.y===e:s.x===e)&&(this.m_shape.queryXY(h,s),t?s.y===e:s.x===e)){if(this.isCurve(r))continue;-1===a&&(a=this.m_shape.createUserIndex()),-2!==this.m_shape.getUserIndex(r,a)&&(o.push(r),this.m_shape.setUserIndex(r,a,-2)),-2!==this.m_shape.getUserIndex(h,a)&&(o.push(h),this.m_shape.setUserIndex(h,a,-2))}}if(0===o.length)return void(-1!==a&&this.m_shape.removeUserIndex(a));(0,n.g)(-1!==a),o.sort(((t,e)=>this.compareVertices(t,e)));for(let t=0,e=o.length;t<e;t++){const e=o[t];this.m_shape.setUserIndex(e,a,t)}const h=new r.P,m=new r.P;m.setNAN();let l=-1;for(let n=0,r=o.length;n<r;n++){this.progress_();const r=o[n];if(r!==i.n&&(this.m_shape.queryXY(r,s),!s.isEqualPoint2D(m))){if(-1!==l)for(;;){let s=!1;const r=n;for(let u=l;u<r;u++){const r=o[u];if(r===i.n)continue;let l=i.n;const c=this.m_shape.getNextVertex(r);this.m_shape.queryXY(c,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(r)||(l=c));let g=i.n;const _=this.m_shape.getPrevVertex(r);if(this.m_shape.queryXY(_,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(_)||(g=_)),l===i.n||g===i.n){if(l!==i.n||g!==i.n){for(let c=u+1;c<n;c++){const n=o[c];if(n===i.n)continue;const u=this.m_shape.getNextVertex(n);let _=i.n;this.m_shape.queryXY(u,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(n)||(_=u));const d=this.m_shape.getPrevVertex(n);let p=i.n;if(this.m_shape.queryXY(d,h),m.compare(h)<0&&(t?h.y===e:h.x===e)&&(this.isCurve(d)||(p=d)),_!==i.n&&p!==i.n){this.beforeRemoveVertex(n,o,a),this.m_shape.removeVertex(n,!1),this.beforeRemoveVertex(_,o,a),this.m_shape.removeVertex(_,!1),s=!0;break}if(l!==i.n&&p!==i.n){this.removeOverlap(o,r,l,n,p,a),s=!0;break}if(g!==i.n&&_!==i.n){this.removeOverlap(o,n,_,r,g,a),s=!0;break}}if(s)break}}else this.beforeRemoveVertex(r,o,a),this.m_shape.removeVertex(r,!1),this.beforeRemoveVertex(l,o,a),this.m_shape.removeVertex(l,!1),s=!0}if(!s)break}l=n,m.setCoordsPoint2D(s)}}this.m_shape.removeUserIndex(a)}beforeRemoveVertex(t,e,s){let r=this.m_shape.getUserIndex(t,s);(0,n.g)(r>=0),e[r]=i.n,r=this.m_shape.getUserIndex(t,this.m_verticesOnExtentIndex),(0,n.g)(r>=0),this.m_verticesOnExtent[r]=i.n;const o=this.m_shape.getPathFromVertex(t);o!==i.n&&this.m_shape.getFirstVertex(o)===t&&(this.m_shape.setFirstVertex(o,i.n),this.m_shape.setLastVertex(o,i.n))}removeOverlap(t,e,s,i,n,r){this.m_shape.setNextVertex(e,i),this.m_shape.setPrevVertex(i,e),this.m_shape.setPrevVertex(s,n),this.m_shape.setNextVertex(n,s),this.beforeRemoveVertex(i,t,r),this.m_shape.removeVertexInternal(i,!1),this.beforeRemoveVertex(n,t,r),this.m_shape.removeVertexInternal(n,!0)}removeSpikesAlongPoles(){this.removeSpikesOnPole(this.m_extent.ymin),this.removeSpikesOnPole(this.m_extent.ymax)}removeSpikesOnPole(t){for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==i.n;e=this.m_shape.getNextPath(e)){const s=this.m_shape.getPathSize(e);if(s<3)continue;let i=this.m_shape.getFirstVertex(e);const n=new r.P;this.m_shape.queryXY(i,n);let o=n.y===t&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const a=new r.P;this.m_shape.queryXY(i,a);let h=a.y===t&&!this.isCurve(i);i=this.m_shape.getNextVertex(i);const m=new r.P;for(let e=0,r=s-2;e<r;e++,i=this.m_shape.getNextVertex(i)){this.progress_(),this.m_shape.queryXY(i,m);const e=m.y===t;h&&o&&e&&(a.x-n.x)*(m.x-a.x)<=0?(this.m_shape.removeVertex(this.m_shape.getPrevVertex(i),!1),a.setCoordsPoint2D(m),h=e&&!this.isCurve(i)):(n.setCoordsPoint2D(a),o=h,a.setCoordsPoint2D(m),h=e&&!this.isCurve(i))}}}fixPaths(){for(let t=0,e=this.m_verticesOnExtent.length;t<e;t++){const e=this.m_verticesOnExtent[t];e!==i.n&&this.m_shape.setPathToVertex(e,i.n)}const t=this.m_shape.hasCurves();let e=0,s=0;for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==i.n;){const n=this.m_shape.getFirstVertex(t);if(n===i.n||t!==this.m_shape.getPathFromVertex(n)){const e=t;t=this.m_shape.getNextPath(t),this.m_shape.setFirstVertex(e,i.n),this.m_shape.removePathOnly(e);continue}let r=n,o=0;do{this.m_shape.setPathToVertex(r,t),o++,r=this.m_shape.getNextVertex(r)}while(r!==n);this.m_shape.setRingAreaValid(t,!1),this.m_shape.setLastVertex(t,this.m_shape.getPrevVertex(n)),this.m_shape.setPathSize(t,o),s+=o,e++,t=this.m_shape.getNextPath(t)}for(let r=0,o=this.m_verticesOnExtent.length;r<o;r++){let o=this.m_verticesOnExtent[r];if(o===i.n)continue;let a=this.m_shape.getPathFromVertex(o);if(a!==i.n)continue;a=this.m_shape.insertPath(this.m_geometry,i.n);let h=!1,m=0;const l=o;do{this.m_shape.setPathToVertex(o,a),m++,t&&m<=2&&(h||=this.isCurve(o)),o=this.m_shape.getNextVertex(o)}while(o!==l);if(h?0===m:m<=2){let t=this.m_shape.getUserIndex(l,this.m_verticesOnExtentIndex);(0,n.g)(t>=0),this.m_verticesOnExtent[t]=i.n;const e=this.m_shape.removeVertex(l,!1);2===m&&(t=this.m_shape.getUserIndex(e,this.m_verticesOnExtentIndex),t>=0&&(this.m_verticesOnExtent[t]=i.n),this.m_shape.removeVertex(e,!1));const s=a;a=this.m_shape.getNextPath(a),this.m_shape.setFirstVertex(s,i.n),this.m_shape.removePathOnly(s)}else this.m_shape.setClosedPath(a,!0),this.m_shape.setPathSize(a,m),this.m_shape.setFirstVertex(a,l),this.m_shape.setLastVertex(a,this.m_shape.getPrevVertex(l)),this.m_shape.setRingAreaValid(a,!1),s+=m,e++}this.m_shape.setGeometryPathCount(this.m_geometry,e),this.m_shape.setGeometryVertexCount(this.m_geometry,s);let r=0;for(let t=this.m_shape.getFirstGeometry();t!==i.n;t=this.m_shape.getNextGeometry(t))r+=this.m_shape.getPointCount(t);this.m_shape.setTotalPointCount(r)}dbgCheckPathFirst(){}isCurve(t){return null!==this.m_shape.getSegment(t)}compareVertices(t,e){const s=new r.P;this.m_shape.queryXY(t,s);const i=new r.P;return this.m_shape.queryXY(e,i),s.compare(i)}clipPolesOut(t,e){return this.clipPolygonOrProjectedPolyline2(t,e)}}},77592:(t,e,s)=>{s.d(e,{C:()=>J,N:()=>a,P:()=>Y,a:()=>P,b:()=>W,c:()=>it,d:()=>Z,e:()=>tt,f:()=>K,g:()=>E,h:()=>j,i:()=>c,j:()=>et,k:()=>st,l:()=>_,m:()=>u,n:()=>k,r:()=>l,s:()=>Q,t:()=>g,u:()=>m,v:()=>H});var i=s(35368),n=s(55537),r=s(11878),o=s(90237);class a{assign(t){this.m_reason=t.m_reason,this.m_vertexIndex1=t.m_vertexIndex1,this.m_vertexIndex2=t.m_vertexIndex2}constructor(t,e,s){void 0!==t?(this.m_reason=t,this.m_vertexIndex1=e,this.m_vertexIndex2=s):(this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-2)}clear(){this.m_reason=0,this.m_vertexIndex1=-1,this.m_vertexIndex2=-1}}class h{constructor(t,e){this.m_monotoneParts=(0,r.m)(i.S,16),this.m_xOrds=(0,r.a)(16,Number.NaN),this.m_inputPoint=r.P.getNAN(),this.m_miny=0,this.m_maxy=0,this.m_windnum=0,this.m_bAlternate=t,this.m_tolerance=e,this.m_toleranceSqr=e*e,this.m_bTestBorder=!!e,this.m_bBreak=!1}_DoOne(t){if(!this.m_bTestBorder&&(this.m_bAlternate&&this.m_inputPoint.equals(t.getStartXY())||this.m_inputPoint.equals(t.getEndXY())))return void(this.m_bBreak=!0);if(t.getStartY()===this.m_inputPoint.y&&t.getStartY()===t.getEndY()){if(this.m_bAlternate&&!this.m_bTestBorder){const e=Math.min(t.getStartX(),t.getEndX()),s=Math.max(t.getStartX(),t.getEndX());this.m_inputPoint.x>e&&this.m_inputPoint.x<s&&(this.m_bBreak=!0)}return}let e=!1;const s=Math.max(t.getStartX(),t.getEndX());if(this.m_inputPoint.x>s)e=!0;else if(this.m_inputPoint.x>=Math.min(t.getStartX(),t.getEndX())){const i=t.intersectionOfYMonotonicWithAxisX(this.m_inputPoint.y,s);e=!Number.isNaN(i)&&i<=this.m_inputPoint.x}if(e){if(this.m_inputPoint.y===t.getStartY()){if(this.m_inputPoint.y<t.getEndY())return}else if(this.m_inputPoint.y===t.getEndY()&&this.m_inputPoint.y<t.getStartY())return;this.m_bAlternate?this.m_windnum^=1:this.m_windnum+=t.getStartY()>t.getEndY()?1:-1}}_Result(){return!!this.m_windnum}testBorder(t){const e=t.getClosestCoordinate(this.m_inputPoint,!1),s=t.getCoord2D(e);return r.P.sqrDistance(s,this.m_inputPoint)<=this.m_toleranceSqr}setInputPoint(t){this.m_inputPoint.setCoordsPoint2D(t),this.m_miny=t.y-this.m_tolerance,this.m_maxy=t.y+this.m_tolerance}processSegment(t){const e=t.queryInterval(0,1);if(e.vmin>this.m_maxy||e.vmax<this.m_miny)return!1;if(this.m_bTestBorder&&this.testBorder(t))return!0;if(e.vmin>this.m_inputPoint.y||e.vmax<this.m_inputPoint.y)return!1;let s=0;if(t.isCurve()&&(0===this.m_monotoneParts.length&&(this.m_monotoneParts.length=128),s=t.getMonotonicParts(this.m_monotoneParts,!0),(0,n.g)(this.m_monotoneParts.length>=s)),s>0)for(let t=0;t<s;t++){const e=this.m_monotoneParts[t].get(),s=r.E.construct(e.getStartY(),e.getEndY());if(!(s.vmin>this.m_inputPoint.y||s.vmax<this.m_inputPoint.y)&&(this._DoOne(e),this.m_bBreak))return!0}else if(this._DoOne(t),this.m_bBreak)return!0;return!1}result(){return(0,n.g)(0),2}}function m(t,e,s){if(t.isEmpty())return 0;const r=i.a.constructEmpty();if(t.queryLooseEnvelope(r),r.inflateCoords(s,s),!r.contains(e))return 0;const o=t.getImpl().getAccelerators();if(o){o.getRasterizedGeometry()&&(0,n.g)(0);const r=o.getQuadTree();if(r)return function(t,e,s,n){const r=new i.a;t.queryLooseEnvelope(r),r.inflateCoords(n,n);const o=0===t.getFillRule(),a=new h(o,n);a.setInputPoint(s);const m=r.clone();m.xmax=s.x+n,m.ymin=s.y-n,m.ymax=s.y+n;const l=t.getImpl().querySegmentIterator(),u=e.getIterator(m,n);for(let t=u.next();-1!==t;t=u.next())if(l.resetToVertex(e.getElement(t),-1),l.hasNextSegment()){const t=l.nextSegment();if(a.processSegment(t))return-1}return a._Result()?1:0}(t,r,e,s)}return function(t,e,s){const i=0===t.getFillRule(),n=new h(i,s);n.setInputPoint(e);const r=t.getImpl().querySegmentIterator();for(;r.nextPath();)for(;r.hasNextSegment();){const t=r.nextSegment();if(n.processSegment(t))return-1}return n._Result()?1:0}(t,e,s)}function l(t,e){const s=t.getPointCount();return!(s<16)&&2*s+Math.log(s)/Math.log(2)*1*e<1*s*e}function u(t,e,s){const i=function(t,e,s){return e.isEmpty()?0:m(t,e.getXY(),s)}(t,e,s);return i?1===i?1:2:0}function c(t,e,s){const i=m(t,e,s);return i?1===i?1:2:0}function g(t,e,s,r,o){if(t.getGeometryType()===n.G.enumPolygon)!function(t,e,s,i,n){for(let r=0;r<s;r++)n[r]=c(t,e[r],i)}(t,e,s,r,o);else if(t.getGeometryType()===n.G.enumEnvelope){const n=i.a.constructEmpty();t.queryEnvelope(n),function(t,e,s,i,n){if(t.isEmpty()){for(let t=0;t<s;t++)n[t]=0;return}const r=t.clone();r.inflateCoords(.5*-i,.5*-i);const o=t.clone();o.inflateCoords(.5*i,.5*i);for(let t=0;t<s;t++)r.contains(e[t])?n[t]=1:o.contains(e[t])?n[t]=2:n[t]=0}(n,e,s,r,o)}else(0,n.u)("")}function _(t,e,s,r,o){const a=t.getGeometryType();a===n.G.enumPolyline?function(t,e,s,r,o){const a=t.getImpl(),h=a.getAccelerators();let m=null;h&&(m=h.getRasterizedGeometry());let l=s;for(let t=0;t<s;t++)o[t]=1,m&&(0,n.g)(0);if(l){if(h){let t=null;null!==h&&null!==h.getQuadTree()&&(t=h.getQuadTree());const n=a.getPointCount();if(null===t&&n>20&&n*s>4*n+Math.log(n)*s&&(t=(0,i.ac)(a)),t){let n=null;const h=a.querySegmentIterator(),m=new i.a;for(let i=0;i<s&&l;i++)if(1===o[i]){m.setCoords(e[i]),null===n?n=t.getIterator(m,r):n.resetIterator(m,r);let s=-1;for(let a=n.next();-1!==a;a=n.next()){if(h.resetToVertex(t.getElement(a),s),s=h.getPathIndex(),h.nextSegment().isIntersectingPoint(e[i],r)){o[i]=2,l--;break}o[i]=0}}return}}const t=a.querySegmentIterator();for(;t.nextPath()&&l;)for(;t.hasNextSegment()&&l;){const i=t.nextSegment();for(let t=0;t<s&&l;t++)1===o[t]&&i.isIntersectingPoint(e[t],r)&&(o[t]=2,l--)}}for(let t=0;t<s;t++)1===o[t]&&(o[t]=0)}(t,e,s,r,o):(0,n.e)(a)?(0,n.g)(0):(0,n.u)("")}class d{freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){this.m_lists.deleteElement(t)}newList_(){return this.m_lists.newElement()}Init_(t){(0,n.g)(0)}constructor(t){this.m_listNodes=new i.r(2),this.m_listOfLists=d.st_nullNode(),this.m_bAllowNavigationBetweenLists=!0,void 0===t&&(t=!0),this.m_bAllowNavigationBetweenLists=t,this.m_lists=new i.r(this.m_bAllowNavigationBetweenLists?4:2)}createList(){const t=this.newList_();return this.m_bAllowNavigationBetweenLists&&(this.m_lists.setField(t,3,this.m_listOfLists),this.m_listOfLists!==d.st_nullNode()&&this.m_lists.setField(this.m_listOfLists,2,t),this.m_listOfLists=t),t}deleteList(t){let e=this.getFirst(t);for(;e!==d.st_nullNode();){const t=e;e=this.getNext(e),this.freeNode_(t)}if(this.m_bAllowNavigationBetweenLists){const e=this.m_lists.getField(t,2),s=this.m_lists.getField(t,3);e!==d.st_nullNode()?this.m_lists.setField(e,3,s):this.m_listOfLists=s,s!==d.st_nullNode()&&this.m_lists.setField(s,2,e)}this.freeList_(t)}reserveLists(t){this.m_lists.setCapacity(t)}addElement(t,e){this.m_lists.getField(t,0);const s=this.m_lists.getField(t,1),i=this.newNode_();return s!==d.st_nullNode()?(this.m_listNodes.setField(s,1,i),this.m_lists.setField(t,1,i)):(this.m_lists.setField(t,0,i),this.m_lists.setField(t,1,i)),this.m_listNodes.setField(i,0,e),i}reserveNodes(t){this.m_listNodes.setCapacity(t)}deleteElementDirect(t,e,s){e!==d.st_nullNode()?(this.m_listNodes.setField(e,1,this.m_listNodes.getField(s,1)),this.m_lists.getField(t,1)===s&&this.m_lists.setField(t,1,e)):(this.m_lists.setField(t,0,this.m_listNodes.getField(s,1)),this.m_lists.getField(t,1)===s&&this.m_lists.setField(t,1,d.st_nullNode())),this.freeNode_(s)}deleteElementSearch(t,e){let s=-1,i=this.getFirst(t);for(;i!==e;)s=i,i=this.getNext(i);this.deleteElementDirect(t,s,e)}concatenateLists(t,e){const s=this.m_lists.getField(t,1),i=this.m_lists.getField(e,0);if(i!==d.st_nullNode()&&(s!==d.st_nullNode()?(this.m_listNodes.setField(s,1,i),this.m_lists.setField(t,1,this.m_lists.getField(e,1))):(this.m_lists.setField(t,0,i),this.m_lists.setField(t,1,this.m_lists.getField(e,1)))),this.m_bAllowNavigationBetweenLists){const t=this.m_lists.getField(e,2),s=this.m_lists.getField(e,3);t!==d.st_nullNode()?this.m_lists.setField(t,3,s):this.m_listOfLists=s,s!==d.st_nullNode()&&this.m_lists.setField(s,2,t)}return this.freeList_(e),t}getElement(t){return this.m_listNodes.getField(t,0)}getData(t){return this.getElement(t)}setElement(t,e){(0,n.g)(0)}getNext(t){return this.m_listNodes.getField(t,1)}getFirst(t){return this.m_lists.getField(t,0)}getFirstElement(t){const e=this.getFirst(t);return this.getElement(e)}static st_nullNode(){return-1}clear(){this.m_listNodes.deleteAll(!0),this.m_lists.deleteAll(!0),this.m_listOfLists=d.st_nullNode()}isEmpty(t){return(0,n.g)(0),!1}getNodeCount(){return this.m_listNodes.size()}getListCount(){return this.m_lists.size()}getFirstList(){return this.m_listOfLists}getNextList(t){return this.m_lists.getField(t,3)}}function p(t=-1){return{m_value:t,m_line:new i.L,m_segment:null,m_segmentInfo:new i.av(-1),m_env:new r.E(0,0),m_dxdy:55555555,m_bHorizontal:!1,m_bCurve:!1}}class f extends i.F{constructor(t,e,s){super(!0),this.m_bIntersectionDetected=!1,this.m_nonSimpleResult=new a,this.m_tempSimpleEdge1=p(),this.m_tempSimpleEdge2=p(),this.m_prev1=i.n,this.m_prev2=i.n,this.m_vertex1=i.n,this.m_vertex2=i.n,this.m_currentNode=-1,this.m_prevX1=Number.NaN,this.m_prevX2=Number.NaN,this.m_prevY=Number.NaN,this.m_prevX=0,this.m_sweepY=Number.NaN,this.m_sweepX=0,this.m_ptSweep=new r.P,this.m_simpleEdgesCache=[],this.m_simpleEdgesRecycle=[],this.m_cOutstandingConstructedEdges=0,this.m_shape=t,this.m_bShapeHasSegments=this.m_shape.hasCurves(),this.m_tolerance=e,this.m_tolerance10=10*e,this.m_bIsSimple=s;const n=Math.trunc(Math.min(3*t.getTotalPointCount()/2,67)),o=Math.min(7,n);this.m_simpleEdgesCache.length=o}tryGetCachedEdge_(t){const e=this.m_simpleEdgesCache[(t&(0,r.j)())%this.m_simpleEdgesCache.length];return e&&e.m_value===t?e:null}tryDeleteCachedEdge_(t){const e=(t&(0,r.j)())%this.m_simpleEdgesCache.length,s=this.m_simpleEdgesCache[e];s&&s.m_value===t&&(this.m_simpleEdgesRecycle.push(s),this.m_simpleEdgesCache[e]=null)}tryCreateCachedEdge_(t){const e=(t&(0,r.j)())%this.m_simpleEdgesCache.length;let s=this.m_simpleEdgesCache[e];return s?null:(0===this.m_simpleEdgesRecycle.length?(s=p(),this.m_cOutstandingConstructedEdges++):s=this.m_simpleEdgesRecycle.pop(),s.m_value=t,this.m_simpleEdgesCache[e]=s,s)}initSimpleEdge_(t,e){this.m_bShapeHasSegments&&this.initSimpleEdgeHelper_(t,e)||t.m_bCurve||(this.m_shape.queryLineConnector(e,t.m_line,!0),t.m_segment=t.m_line,t.m_env.setCoordsNoNAN(t.m_line.getStartX(),t.m_line.getEndX()),t.m_env.vmax+=this.m_tolerance,t.m_line.orientBottomUp(),t.m_bHorizontal=t.m_line.getEndY()===t.m_line.getStartY(),t.m_bHorizontal||(t.m_dxdy=(t.m_line.getEndX()-t.m_line.getStartX())/(t.m_line.getEndY()-t.m_line.getStartY())))}initSimpleEdgeHelper_(t,e){if(t.m_segment=this.m_shape.getSegment(e),t.m_segmentInfo=this.m_shape.getOriginalSegmentInfo(e),t.m_bCurve=null!==t.m_segment,t.m_bCurve){const e=t.m_segment.clone();return e.orientBottomUp(),t.m_segment=e,t.m_env=t.m_segment.queryInterval(0,0),t.m_env.vmax+=this.m_tolerance,!0}return!1}compareTwoSegments_(t,e){const s=t.getStartXY(),i=t.getEndXY(),n=e.getStartXY(),o=e.getEndXY();if(this.m_ptSweep.setCoords(this.m_sweepX,this.m_sweepY),s.isEqualPoint2D(n)&&this.m_sweepY===s.y){this.m_ptSweep.assign(i.compare(o)<0?i:o);const s=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x);if(Math.abs(s-n)>this.m_tolerance)return s<n?-1:1}const a=s.compare(n)<0?n:s,h=i.compare(o)<0?i:o;let m=0,l=0;for(let s=1;s<5;s++){(0,r.B)(a,h,s/5,this.m_ptSweep);const i=t.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),n=e.intersectionOfYMonotonicWithAxisX(this.m_ptSweep.y,this.m_ptSweep.x),o=Math.abs(i-n);o>m&&(m=o,l=i<n?-1:1)}return 0===l?this.errorCracking():l}compareNonHorizontal_(t,e){if(t.m_line.getStartY()===e.m_line.getStartY()&&t.m_line.getStartX()===e.m_line.getStartX())return t.m_line.getEndY()===e.m_line.getEndY()&&t.m_line.getEndX()===e.m_line.getEndX()?this.m_bIsSimple?this.errorCoincident():0:this.compareNonHorizontalUpperEnd_(t,e);if(t.m_line.getEndY()===e.m_line.getEndY()&&t.m_line.getEndX()===e.m_line.getEndX())return this.compareNonHorizontalLowerEnd_(t,e);const s=this.compareNonHorizontalLowerEnd_(t,e),i=this.compareNonHorizontalUpperEnd_(t,e);return s<0&&i<0?-1:s>0&&i>0?1:this.errorCracking()}compareHorizontal1Case1_(t,e){if(t.getEndX()>e.getEndX()){if(e.getEndX()>e.getStartX()&&e.getEndY()-e.getStartY()<2*this.m_tolerance&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((e.getEndY()-e.getStartY())/(e.getEndX()-e.getStartX())*(t.getEndX()-t.getStartX())<this.m_tolerance10&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return 1}compareHorizontal1Case2_(t,e){if(t.getStartX()<e.getStartX()){if(e.getEndX()>e.getStartX()&&e.getEndY()-e.getStartY()<2*this.m_tolerance&&t.isIntersectingPoint(e.getEndXY(),this.m_tolerance,!0))return this.errorCracking()}else if((e.getEndY()-e.getStartY())/(e.getEndX()-e.getStartX())*(t.getStartX()-t.getEndX())<this.m_tolerance10&&e.isIntersectingPoint(t.getStartXY(),this.m_tolerance,!0))return this.errorCracking();return-1}compareHorizontal1Case3_(t,e){const s=r.P.getNAN();s.setSub(e.getEndXY(),e.getStartXY()),s.rightPerpendicularThis(),s.normalize();const i=r.P.getNAN();i.setSub(t.getStartXY(),e.getStartXY());const n=r.P.getNAN();n.setSub(t.getEndXY(),e.getStartXY());const o=i.dotProduct(s),a=n.dotProduct(s),h=Math.abs(o),m=Math.abs(a);if(h<m){if(h<this.m_tolerance10&&e.isIntersectingPoint(t.getStartXY(),this.m_tolerance,!0))return this.errorCracking()}else if(m<this.m_tolerance10&&e.isIntersectingPoint(t.getEndXY(),this.m_tolerance,!0))return this.errorCracking();return o<0&&a<0?-1:o>0&&a>0?1:this.errorCracking()}compareHorizontal1_(t,e){return t.getStartY()===e.getStartY()&&t.getStartX()===e.getStartX()?this.compareHorizontal1Case1_(t,e):t.getEndY()===e.getEndY()&&t.getEndX()===e.getEndX()?this.compareHorizontal1Case2_(t,e):this.compareHorizontal1Case3_(t,e)}compareHorizontal2_(t,e){return t.getEndY()===e.getEndY()&&t.getEndX()===e.getEndX()&&t.getStartY()===e.getStartY()&&t.getStartX()===e.getStartX()?this.m_bIsSimple?this.errorCoincident():0:this.errorCracking()}compareNonHorizontalLowerEnd_(t,e){let s=1;if(t.m_line.getStartY()<e.m_line.getStartY()){s=-1;const i=t;t=e,e=i}const i=t.m_line,n=e.m_line,r=i.getStartX()-n.getStartX(),o=e.m_dxdy*(i.getStartY()-n.getStartY()),a=this.m_tolerance10;return r<o-a?-s:r>o+a?s:n.isIntersectingPoint(i.getStartXY(),this.m_tolerance,!0)?this.errorCracking():r<o?-s:s}compareNonHorizontalUpperEnd_(t,e){let s=1;if(e.m_line.getEndY()<t.m_line.getEndY()){s=-1;const i=t;t=e,e=i}const i=t.m_line,n=e.m_line,r=i.getEndX()-n.getStartX(),o=e.m_dxdy*(i.getEndY()-n.getStartY()),a=this.m_tolerance10;return r<o-a?-s:r>o+a?s:n.isIntersectingPoint(i.getEndXY(),this.m_tolerance,!0)?this.errorCracking():r<o?-s:s}errorCoincident(){return this.m_bIntersectionDetected=!0,this.m_nonSimpleResult=new a(7,this.m_vertex1,this.m_vertex2),-1}errorCracking(){if(this.m_bIntersectionDetected=!0,this.m_bIsSimple){const t=6;this.m_nonSimpleResult=new a(t,this.m_vertex1,this.m_vertex2)}else this.m_prev1=i.n,this.m_prev2=i.n,this.m_vertex1=i.n,this.m_vertex2=i.n;return-1}compareSegments_(t,e,s,n){if(s.m_env.vmax<n.m_env.vmin)return-1;if(n.m_env.vmax<s.m_env.vmin)return 1;if(!s.m_bCurve&&!n.m_bCurve){let t=s.m_bHorizontal?1:0;return t|=n.m_bHorizontal?2:0,0===t?this.compareNonHorizontal_(s,n):1===t?this.compareHorizontal1_(s.m_line,n.m_line):2===t?-1*this.compareHorizontal1_(n.m_line,s.m_line):this.compareHorizontal2_(s.m_line,n.m_line)}if(this.m_bIntersectionDetected)return-1;const r=this.m_prevY===this.m_sweepY&&this.m_prevX===this.m_sweepX;let o,a;if(r&&t===this.m_prev1?o=this.m_prevX1:(o=Number.NaN,this.m_prev1=i.n),r&&e===this.m_prev2?a=this.m_prevX2:(a=Number.NaN,this.m_prev2=i.n),this.m_prevY=this.m_sweepY,this.m_prevX=this.m_sweepX,Number.isNaN(o)){this.m_prev1=t;const e=s.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);o=e,this.m_prevX1=e}if(Number.isNaN(a)){this.m_prev2=e;const t=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_sweepY,this.m_sweepX);a=t,this.m_prevX2=t}const h=(0,i.am)(!0,!0,s.m_segment,n.m_segment,this.m_tolerance,!0);return 0!==h?2===h?this.m_bIsSimple?this.errorCoincident():s.m_segmentInfo.equals(n.m_segmentInfo)?0:this.errorCracking():this.errorCracking():Math.abs(o-a)<=this.m_tolerance?this.compareTwoSegments_(s.m_segment,n.m_segment):o<a?-1:o>a?1:0}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1}intersectionDetected(){return this.m_bIntersectionDetected}getLastComparedNode(){return this.m_currentNode}getResult(){return this.m_nonSimpleResult}setSweepY(t,e){this.m_sweepY=t,this.m_sweepX=e,this.m_prev1=i.n,this.m_prev2=i.n,this.m_vertex1=i.n,this.m_vertex2=i.n}compare(t,e,s){if(this.m_bIntersectionDetected)return-1;const i=t.getElement(s),n=e;return this.m_currentNode=s,this.compareSegments(n,n,i,i)}compareSegments(t,e,s,i){let n=this.tryGetCachedEdge_(t);null===n?this.m_vertex1===e?n=this.m_tempSimpleEdge1:(this.m_vertex1=e,n=this.tryCreateCachedEdge_(t),null===n&&(n=this.m_tempSimpleEdge1,this.m_tempSimpleEdge1.m_value=t),this.initSimpleEdge_(n,e)):this.m_vertex1=e;let r=this.tryGetCachedEdge_(s);return null===r?this.m_vertex2===i?r=this.m_tempSimpleEdge2:(this.m_vertex2=i,r=this.tryCreateCachedEdge_(s),null===r&&(r=this.m_tempSimpleEdge2,this.m_tempSimpleEdge2.m_value=s),this.initSimpleEdge_(r,i)):this.m_vertex2=i,this.compareSegments_(e,i,n,r)}onDelete(t){this.tryDeleteCachedEdge_(t)}onSet(t){this.tryDeleteCachedEdge_(t)}onEndSearch(t){this.tryDeleteCachedEdge_(t)}onAddUniqueElementFailed(t){this.tryDeleteCachedEdge_(t)}}class x{constructor(t,e){this.m_bIntersectionDetected=!1,this.m_pointOfInterest=r.P.getNAN(),this.m_line1=new i.L,this.m_seg1=null,this.m_env=r.E.constructEmpty(),this.m_vertex1=-1,this.m_currentNode=-1,this.m_minDist=Number.MAX_VALUE,this.m_shape=t,this.m_tolerance=e}getCurrentNode(){return this.m_currentNode}clearIntersectionDetectedFlag(){this.m_bIntersectionDetected=!1,this.m_minDist=Number.MAX_VALUE}intersectionDetected(){return this.m_bIntersectionDetected}setPoint(t){this.m_pointOfInterest.assign(t)}compare(t,e){const s=t.getElement(e);return this.compareVertex(t,e,s)}compareVertex(t,e,s){let n,o=this.m_shape.getSegment(s),a=!0;if(null==o)this.m_shape.queryLineConnector(s,this.m_line1,!0),this.m_env.setCoordsNoNAN(this.m_line1.getStartX(),this.m_line1.getEndX()),o=this.m_line1,n=this.m_line1.getStartY()===this.m_line1.getEndY();else{const t=i.a.constructEmpty();o.queryLooseEnvelope(t),t.queryIntervalX(this.m_env),n=0===t.height(),a=!1}if(this.m_pointOfInterest.x+this.m_tolerance<this.m_env.vmin)return-1;if(this.m_pointOfInterest.x-this.m_tolerance>this.m_env.vmax)return 1;if(n)return this.m_currentNode=e,this.m_bIntersectionDetected=!0,0;let h=0;if(a){(0,i.ar)(this.m_line1);const t=this.m_line1.getStartXY(),e=new r.P;e.setSub(this.m_line1.getEndXY(),t),e.rightPerpendicularThis();const s=new r.P;s.setSub(this.m_pointOfInterest,t),h=e.dotProduct(s),h/=e.length()}else h=o.intersectionOfYMonotonicWithAxisX(this.m_pointOfInterest.y,this.m_pointOfInterest.x)-this.m_pointOfInterest.x;return h<10*-this.m_tolerance?-1:h>10*this.m_tolerance?1:(o.isIntersectingPoint(this.m_pointOfInterest,this.m_tolerance)&&(Math.abs(h)<this.m_minDist&&(this.m_currentNode=e,this.m_minDist=h),this.m_bIntersectionDetected=!0),h<0?-1:h>0?1:0)}}class y{constructor(t,e){this.m_lists=new d(!1),this.m_hash=e,this.m_hashBuckets=new Int32Array(t),this.m_hashBuckets.fill(y.st_nullNode()),this.m_bitFilter=new Int32Array(10*t+31>>5)}reserveElements(t){this.m_lists.reserveLists(Math.min(this.m_hashBuckets.length,t)),this.m_lists.reserveNodes(t)}addElement(t,e){void 0===e&&(e=this.m_hash.getHash(t));const s=e%(this.m_bitFilter.length<<5);this.m_bitFilter[s>>5]|=1<<(31&s);const i=e%this.m_hashBuckets.length;let n=this.m_hashBuckets[i];return n===d.st_nullNode()&&(n=this.m_lists.createList(),this.m_hashBuckets[i]=n),this.m_lists.addElement(n,t)}deleteElement(t,e){void 0===e&&(e=this.m_hash.getHash(t));const s=e%this.m_hashBuckets.length,i=this.m_hashBuckets[s];i===d.st_nullNode()&&(0,n.t)("");let r=this.m_lists.getFirst(i),o=d.st_nullNode();for(;r!==d.st_nullNode();){const e=this.m_lists.getData(r),n=this.m_lists.getNext(r);e===t?(this.m_lists.deleteElementDirect(i,o,r),this.m_lists.getFirst(i)===d.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[s]=d.st_nullNode())):o=r,r=n}}getFirstInBucket(t){const e=t%(this.m_bitFilter.length<<5);if(!(this.m_bitFilter[e>>5]&1<<(31&e)))return d.st_nullNode();const s=t%this.m_hashBuckets.length,i=this.m_hashBuckets[s];return i===d.st_nullNode()?d.st_nullNode():this.m_lists.getFirst(i)}getNextInBucket(t){return this.m_lists.getNext(t)}findNode(t){const e=this.m_hash.getHash(t);let s=this.getFirstInBucket(e);for(;s!==d.st_nullNode();){const e=this.m_lists.getData(s);if(this.m_hash.equal(e,t))return s;s=this.m_lists.getNext(s)}return d.st_nullNode()}deleteNode(t){const e=this.getElement(t),s=this.m_hash.getHash(e)%this.m_hashBuckets.length,i=this.m_hashBuckets[s];i===d.st_nullNode()&&(0,n.t)(""),this.m_lists.deleteElementSearch(i,t),this.m_lists.getFirst(i)===d.st_nullNode()&&(this.m_lists.deleteList(i),this.m_hashBuckets[s]=d.st_nullNode())}getElement(t){return this.m_lists.getData(t)}static st_nullNode(){return d.st_nullNode()}clear(){(0,n.g)(0)}size(){return this.m_lists.getNodeCount()}dbgPrintBucketHistogram(){}}function P(t,e,s,i,n){const r=new S(n);return r.m_shape=t,r.m_sqrTolerance=e*e,r.m_cellSize=2*e,r.m_invCellSize=1/r.m_cellSize,r.m_geometry=s,r.m_bTrackChanges=i,r.m_bHasSegmentParentage=t.hasSegmentParentage(),r.clusterNonReciprocal()}function E(t,e,s,i,n){const r=t-s,o=e-i;return r*r+o*o<=n}function C(t,e,s,i,n,o){const a={pt:new r.P,weight:0,rank:0,bMerged:!1},h=s+n;let m=!1,l=t.x;t.x!==e.x&&(i===o&&(l=(t.x*s+e.x*n)/h),m=!0);let u=t.y;return t.y!==e.y&&(i===o&&(u=(t.y*s+e.y*n)/h),m=!0),i!==o?i>o?(a.rank=i,a.weight=s,a.pt=t):(a.rank=o,a.weight=n,a.pt=e):(a.pt.setCoords(l,u),a.weight=h,a.rank=i),a.bMerged=m,a}function v(t,e){const s=(0,r.J)(t);return(0,r.I)(s,e)}class b{constructor(t,e,s,i,n){this.m_workPt=new r.P,this.m_shape=t,this.m_sqrTolerance=s,this.m_invCellSize=i,this.m_origin=e.clone(),this.m_hashValues=n}getHash(t){return this.m_shape.getUserIndex(t,this.m_hashValues)}calculateHashFromVertex(t){this.m_shape.queryXY(t,this.m_workPt);const e=this.m_workPt.x-this.m_origin.x,s=Math.trunc(e*this.m_invCellSize+.5),i=this.m_workPt.y-this.m_origin.y;return v(s,Math.trunc(i*this.m_invCellSize+.5))}equal(t,e){return(0,n.g)(0),!1}}class S{constructor(t){this.m_origin=r.P.getNAN(),this.m_sqrTolerance=0,this.m_cellSize=0,this.m_invCellSize=0,this.m_geometry=i.n,this.m_bucketArray=new Array(4),this.m_bucketHash=new Array(4),this.m_dbgCandidateCheckCount=0,this.m_nsr=new a,this.m_hashValues=-1,this.m_newClusters=-1,this.m_bTrackChanges=!1,this.m_bHasSegmentParentage=!1,this.m_shape=null,this.m_clusters=new d,this.m_hashFunction=null,this.m_hashTable=null,this.m_progressCounter=0,this.m_progressTracker=t}progress_(){}collectClusterCandidates(t,e){const s=r.P.getNAN();this.m_shape.queryXY(t,s);const i=(s.x-this.m_origin.x)*this.m_invCellSize,n=(s.y-this.m_origin.y)*this.m_invCellSize,o=Math.trunc(i),a=Math.trunc(n);let h=0;for(let t=0;t<=1;t+=1)for(let e=0;e<=1;e+=1){const s=v(o+t,a+e),i=this.m_hashTable.getFirstInBucket(s);i!==y.st_nullNode()&&(this.m_bucketArray[h]=i,this.m_bucketHash[h]=s,h++)}for(let t=h-1;t>=1;t--){const e=this.m_bucketArray[t];for(let s=t-1;s>=0;s--)if(e===this.m_bucketArray[s]){this.m_bucketHash[s]=-1,h--,t!==h&&(this.m_bucketHash[t]=this.m_bucketHash[h],this.m_bucketArray[t]=this.m_bucketArray[h]);break}}for(let i=0;i<h;i++)this.collectNearestNeighbourCandidates(t,this.m_bucketHash[i],s,this.m_bucketArray[i],e)}collectNearestNeighbourCandidates(t,e,s,i,n){const o=r.P.getNAN();for(let r=i;r!==y.st_nullNode();r=this.m_hashTable.getNextInBucket(r)){const i=this.m_hashTable.getElement(r);t===i||-1!==e&&this.m_shape.getUserIndex(i,this.m_hashValues)!==e||(this.m_shape.queryXY(i,o),E(s.x,s.y,o.x,o.y,this.m_sqrTolerance)&&n.push(r))}}mergeClusters(t,e,s){let n=this.m_shape.getUserIndex(t,this.m_newClusters);const r=this.m_shape.getUserIndex(e,this.m_newClusters);-1===n&&(n=this.m_clusters.createList(),this.m_clusters.addElement(n,t),this.m_shape.setUserIndex(t,this.m_newClusters,n)),-1===r?this.m_clusters.addElement(n,e):this.m_clusters.concatenateLists(n,r),this.m_shape.setUserIndex(e,this.m_newClusters,i.r.impossibleIndex2());const o=this.mergeVertices(t,e);if(s){const e=this.m_hashFunction.calculateHashFromVertex(t);this.m_shape.setUserIndex(t,this.m_hashValues,e)}return o}mergeVertices(t,e){const s=r.P.getNAN();this.m_shape.queryXY(t,s);const i=r.P.getNAN();this.m_shape.queryXY(e,i);const n=this.m_shape.getRank(t),o=this.m_shape.getRank(e),a=this.m_shape.getWeight(t),h=this.m_shape.getWeight(e);let m,l,u,c,g=!1;if(n===o?(m=n,l=a+h,u=s.x,s.x!==i.x&&(u=(s.x*a+i.x*h)/l,g=!0),c=s.y,s.y!==i.y&&(c=(s.y*a+i.y*h)/l,g=!0)):(n>o?(u=s.x,c=s.y,l=a,m=n):(u=i.x,c=i.y,l=h,m=o),g=!s.equals(i)),g&&(this.m_shape.setXYMonotonic(t,u,c),this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(t,!0),this.m_bHasSegmentParentage)){const s=this.m_shape.getSegmentParentageBreakVertex(t)||this.m_shape.getSegmentParentageBreakVertex(e);this.m_shape.setSegmentParentageBreakVertex(t,s),this.m_shape.setSegmentParentageBreakVertex(e,s)}return this.m_shape.setWeight(t,l),this.m_shape.setRank(t,m),g}needsClustering(){const t={stack:[],error:void 0,hasError:!1};try{(0,o.b)(t,(0,r.f)((()=>{this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters)})),!1);const e=this.m_shape.getSelectedCount(),s=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin.assign(s.getLowerLeft());const n=Math.max(s.height(),s.width())/((0,r.o)()-1);this.m_cellSize<n&&(this.m_cellSize=n,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(this.m_shape.getSelectedCount()/3+1),this.m_clusters.reserveNodes(this.m_shape.getSelectedCount()/3+1),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new b(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new y(4*e/3,this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let h=!1;for(let t=0;t<2;t++){const e=[],s=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let n=s.next();n!==i.n;n=s.next()){if(this.progress_(),t>0&&this.m_shape.getUserIndex(n,this.m_newClusters)===i.r.impossibleIndex2())continue;let s;if(0===t?(s=this.m_hashFunction.calculateHashFromVertex(n),this.m_shape.setUserIndex(n,this.m_hashValues,s)):s=this.m_shape.getUserIndex(n,this.m_hashValues),this.collectClusterCandidates(n,e),0!==e.length){for(let t=0,s=e.length;t<s;t++){this.progress_();const s=e[t],i=this.m_hashTable.getElement(s);if(this.m_hashTable.deleteNode(s),!this.m_shape.isEqualXY(n,i))return this.m_nsr=new a(5,this.m_shape.getVertexIndex(n),this.m_shape.getVertexIndex(i)),h=!0,h;this.mergeClusters(n,i,!1)}e.length=0}0===t&&this.m_hashTable.addElement(n,s)}}return h}catch(e){t.error=e,t.hasError=!0}finally{(0,o.c)(t)}}clusterNonReciprocal(){const t=this.m_shape.getSelectedCount(),e=this.m_shape.getEnvelope2D(this.m_progressTracker);this.m_origin=e.getLowerLeft();const s=Math.max(e.height(),e.width())/((0,r.o)()-1);this.m_cellSize<s&&(this.m_cellSize=s,this.m_invCellSize=1/this.m_cellSize),this.m_clusters.clear(),this.m_clusters.reserveLists(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_clusters.reserveNodes(Math.trunc(this.m_shape.getSelectedCount()/3+1)),this.m_hashValues=this.m_shape.createUserIndex(),this.m_newClusters=this.m_shape.createUserIndex(),this.m_hashFunction=new b(this.m_shape,this.m_origin,this.m_sqrTolerance,this.m_invCellSize,this.m_hashValues),this.m_hashTable=new y(Math.trunc(4*t/3),this.m_hashFunction),this.m_hashTable.reserveElements(this.m_shape.getSelectedCount());let n=!1;{const t=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let e=t.next();e!==i.n;e=t.next()){this.progress_();const t=this.m_hashFunction.calculateHashFromVertex(e);this.m_shape.setUserIndex(e,this.m_hashValues,t),this.m_hashTable.addElement(e,t)}}{const t=[],e=this.m_shape.queryVertexIteratorOnSelection(this.m_geometry);for(let s=e.next();s!==i.n;s=e.next()){if(this.m_shape.getUserIndex(s,this.m_newClusters)===i.r.impossibleIndex2())continue;let e=this.m_shape.getUserIndex(s,this.m_hashValues);this.m_hashTable.deleteElement(s,e);let r=!1;for(;this.collectClusterCandidates(s,t),0!==t.length;){let e=0;for(let i=0,n=t.length;i<n;i++){this.progress_();const r=t[i],o=this.m_hashTable.getElement(r);this.m_hashTable.deleteNode(r);const a=i+1===n;e|=this.mergeClusters(s,o,a)?1:0}if(r||=0!==e,n||=0!==e,t.length=0,!e)break}r&&(e=this.m_shape.getUserIndex(s,this.m_hashValues)),this.m_hashTable.addElement(s,e)}t.length=0}return n&&this.applyClusterPositions_(),this.m_hashTable=null,this.m_hashFunction=null,this.m_shape.removeUserIndex(this.m_hashValues),this.m_shape.removeUserIndex(this.m_newClusters),n}applyClusterPositions_(){const t=r.P.getNAN();for(let e=this.m_clusters.getFirstList();e!==d.st_nullNode();e=this.m_clusters.getNextList(e)){let s=this.m_clusters.getFirst(e);const i=this.m_clusters.getElement(s);this.m_shape.queryXY(i,t);const n=this.m_shape.getRank(i),r=this.m_shape.getWeight(i);for(s=this.m_clusters.getNext(s);s!==d.st_nullNode();s=this.m_clusters.getNext(s)){const e=this.m_clusters.getElement(s);if(this.m_bTrackChanges?this.m_shape.isEqualXYPoint2D(e,t)||(this.m_shape.setXYMonotonicPoint2D(e,t),this.m_shape.setGeometryModifiedWithVertex(e,!0)):this.m_shape.setXYMonotonicPoint2D(e,t),this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentageBreakVertex(i)||this.m_shape.getSegmentParentageBreakVertex(e);this.m_shape.setSegmentParentageBreakVertex(i,t),this.m_shape.setSegmentParentageBreakVertex(e,t)}this.m_shape.setWeight(e,r),this.m_shape.setRank(e,n)}}}}class I{constructor(){this.m_inputParts=[],this.m_resultParts1=[],this.m_resultParts2=[],this.m_resultSegments=[],this.m_freeSegments=[],this.m_inputSegments=[],this.m_param1=[],this.m_param2=[],this.m_tolerance=0,this.m_toleranceZ=0,this.m_point=new i.P,this.m_pointWeight=1,this.m_maxDensifyLimit=0,this.m_pointRank=0,this.m_changed1=!1,this.m_changed2=!1,this.m_adaptiveDensify=!1}clear(){this.freeAllResultSegments(),this.m_inputSegments.length=0,this.m_inputParts.length=0,this.m_resultParts1.length=0,this.m_resultParts2.length=0,this.m_param1.length=0,this.m_param2.length=0,this.m_adaptiveDensify=!1,this.m_changed1=!1,this.m_changed2=!1}newIntersectionPart_(t,e,s,i,n,r,o,a,h,m){return function(t,e,s,i,n,r,o,a,h,m){return{segmentIndex:t,weightStart:e,rankStart:s,weightEnd:i,rankEnd:n,weightInterior:r,rankInterior:o,segmentParentage:m,u:w(a,h)}}(t,e,s,i,n,r,o,a,h,m)}pushSegment(t,e,s,i,n,r,o,a,h,m){return this.m_inputParts.push(this.newIntersectionPart_(this.m_inputSegments.length,e,s,i,n,r,o,a,h,m)),this.m_inputSegments.push(t),this.m_inputParts.length-1}getResultSegmentCount(t){return this.m_adaptiveDensify?0===t?this.m_param1.length-1:this.m_param2.length-1:0===t?this.m_resultParts1.length:this.m_resultParts2.length}getResultPart_(t,e){return 0===t?this.m_resultParts1[e]:this.m_resultParts2[e]}getResultSegment(t,e){return this.m_resultSegments[this.getResultPart_(t,e).segmentIndex].get()}getSegmentChanged(t){return 0===t?this.m_changed1:this.m_changed2}getResultSegmentStartPointWeight(t,e){return this.getResultPart_(t,e).weightStart}getResultSegmentStartPointRank(t,e){return this.getResultPart_(t,e).rankStart}getResultSegmentSegmentParentage(t,e){return this.getResultPart_(t,e).segmentParentage}getResultSegmentStartPointIsBreak(t,e){return this.getResultPart_(t,e).u.bBreakStart}getResultSegmentEndPointWeight(t,e){return this.getResultPart_(t,e).weightEnd}getResultSegmentEndPointRank(t,e){return this.getResultPart_(t,e).rankEnd}getResultSegmentEndPointIsBreak(t,e){return this.getResultPart_(t,e).u.bBreakEnd}getResultSegmentInteriorRank(t,e){return this.getResultPart_(t,e).rankInterior}getResultSegmentInteriorWeight(t,e){return this.getResultPart_(t,e).weightInterior}getResultPoint(){return this.m_point}getResultPointWeight(){return this.m_pointWeight}getResultPointRank(){return this.m_pointRank}getResultPointChanged(){return this.m_changed2}intersectLines(t,e){2!==this.m_inputSegments.length&&(0,n.b)(""),this.m_changed1=!1,this.m_changed2=!1,this.m_tolerance=t;const s=(0,r.e)(t*I.c_smallToleranceFactor);let o=!1;const a=this.m_inputParts[0],h=this.m_inputParts[1],m=this.m_inputSegments[a.segmentIndex],l=this.m_inputSegments[h.segmentIndex];if(e||5&(0,i.x)(!0,m,l,t,!0)){const e=(0,i.ak)(!0,m,l,null,this.m_param1,this.m_param2,t);0===e&&(0,n.b)("");const u=new Array(e);for(let t=0;t<e;++t)u[t]=r.P.getNAN();const c=new Float64Array(e),g=new Int32Array(e),_=new Array(e),d=new Array(e);for(let t=0;t<e;++t)_[t]={bBigMove:!1,bIsBreak:!1},d[t]={bBigMove:!1,bIsBreak:!1};for(let t=0;t<e;t++){const e=this.m_param1[t],i=this.m_param2[t];let n,p=a.rankInterior,f=a.weightInterior;0===e?(p=a.rankStart,f=a.weightStart,n=a.u.bBreakStart):1===e?(p=a.rankEnd,f=a.weightEnd,n=a.u.bBreakEnd):(this.m_changed1=!0,n=!1);let x,y=h.rankInterior,P=h.weightInterior;0===i?(y=h.rankStart,P=h.weightStart,x=h.u.bBreakStart):1===i?(y=h.rankEnd,P=h.weightEnd,x=h.u.bBreakEnd):(this.m_changed2=!0,x=!1);const E=p,C=y;let v=1,b=0,S=r.P.getNAN();if(E===C){const n=m.getCoord2D(e),o=l.getCoord2D(i);v=f+P,b=p,(0,r.B)(n,o,P/v,S);const a=r.P.sqrDistance(S,n),h=r.P.sqrDistance(S,o);_[t].bBigMove=a>s,d[t].bBigMove=h>s,this.m_changed1||n.equals(S)||(this.m_changed1=!0),this.m_changed2||o.equals(S)||(this.m_changed2=!0)}else if(E>C){S=m.getCoord2D(e);const n=l.getCoord2D(i);v=f,b=p;const o=r.P.sqrDistance(S,n);_[t].bBigMove=!1,d[t].bBigMove=o>s,this.m_changed2||n.equals(S)||(this.m_changed2=!0)}else{S=l.getCoord2D(i),v=P,b=y;const n=m.getCoord2D(e),o=r.P.sqrDistance(S,n);_[t].bBigMove=o>s,d[t].bBigMove=!1,this.m_changed1||n.equals(S)||(this.m_changed1=!0)}u[t].assign(S),c[t]=v,g[t]=b,_[t].bIsBreak=n||x,d[t].bIsBreak=n||x,o||=_[t].bBigMove||d[t].bBigMove}const p=a.rankInterior,f=a.weightInterior;let x=0,y=-1;for(let s=0;s<=e;s++){const i=s<e?this.m_param1[s]:1;if(i!==x){const n=this.allocResultSegment(),o=this.m_resultSegments[n];let h,l,d,P;m.queryCut(x,i,o,!1),o.get().snapControlPoints(t*t);let E=!1,C=!1,v=!1,b=!1,S=!1,I=r.P.getNAN(),w=r.P.getNAN();-1!==y?(l=g[y],h=c[y],E=_[y].bBigMove,I.assign(u[y]),v=_[y].bIsBreak,S=!0):(h=a.weightStart,l=a.rankStart,I=o.get().getStartXY(),v=a.u.bBreakStart),s<e?(P=g[s],d=c[s],C=_[s].bBigMove,w.assign(u[s]),b=_[s].bIsBreak,S=!0):(d=a.weightEnd,P=a.rankEnd,w=o.get().getEndXY(),b=a.u.bBreakEnd),S&&o.get().setCoordsForIntersector(I,w,!0),this.m_resultParts1.push(this.newIntersectionPart_(n,h,l,d,P,f,p,v,b,a.segmentParentage));const D=this.m_resultParts1.at(-1);D.u.bBigMoveStart=E,D.u.bBigMoveEnd=C,x=i,y=s}else-1===y&&(y=s)}const P=new Array(e);for(let t=0;t<e;t++)P[t]=t;e>2?(P.sort(((t,e)=>this.m_param2[t]<this.m_param2[e]?-1:this.m_param2[t]>this.m_param2[e]?1:0)),(0,r.n)(this.m_param2)):2===e&&this.m_param2[0]>this.m_param2[1]&&(this.m_param2[1]=(0,r.b)(this.m_param2[0],this.m_param2[0]=this.m_param2[1]),P[1]=(0,r.b)(P[0],P[0]=P[1]));const E=h.rankInterior,C=h.weightInterior;x=0,y=-1;for(let s=0;s<=e;s++){const i=s<e?this.m_param2[s]:1;if(i!==x){const n=this.allocResultSegment(),o=this.m_resultSegments[n];let a,m,_,p;l.queryCut(x,i,o,!1),o.get().snapControlPoints(t*t);let f=r.P.getNAN(),v=r.P.getNAN(),b=!1,S=!1,I=!1,w=!1,D=!1;if(-1!==y){const t=P[y];a=c[t],m=g[t],f.assign(u[t]),I=d[t].bBigMove,b=d[t].bIsBreak,D=!0}else a=h.weightStart,m=h.rankStart,f=o.get().getStartXY(),b=h.u.bBreakStart;if(s!==e){const t=P[s];_=c[t],p=g[t],v.assign(u[t]),w=d[t].bBigMove,S=d[t].bIsBreak,D=!0}else _=h.weightEnd,p=h.rankEnd,v=o.get().getEndXY(),S=h.u.bBreakEnd;D&&o.get().setCoordsForIntersector(f,v,!0),this.m_resultParts2.push(this.newIntersectionPart_(n,a,m,_,p,C,E,b,S,h.segmentParentage));const T=this.m_resultParts2.at(-1);T.u.bBigMoveStart=I,T.u.bBigMoveEnd=w,x=i,y=s}else-1===y&&(y=s)}return o?3:2}return 0}intersectLines3D(t,e,s,i){return(0,n.g)(0),1}intersect2D(t,e){const s=this.m_inputParts[0],i=this.m_inputParts[1],r=this.m_inputSegments[s.segmentIndex].getGeometryType(),o=this.m_inputSegments[i.segmentIndex].getGeometryType();return r!==n.G.enumLine||o!==n.G.enumLine?new M(this).intersectCurves(t,e):this.intersectLines(t,e)}intersect2DEx(t,e,s,i,o){this.m_point.assignCopy(e),1!==this.m_inputSegments.length&&(0,n.b)(""),this.m_tolerance=t,this.m_changed1=!1,this.m_changed2=!1;const a=(0,r.e)(t*I.c_smallToleranceFactor);let h=!1;const m=this.m_inputParts[0],l=this.m_inputSegments[m.segmentIndex];if(o||l.isIntersectingPoint(e.getXY(),t,!0)){this.m_param1=(0,r.a)(16,Number.NaN);const n=l.getClosestCoordinate(e.getXY(),!1);this.m_param1[0]=n;let o=m.rankInterior,u=m.weightInterior;0===n?(o=m.rankStart,u=m.weightStart):1===n?(o=m.rankEnd,u=m.weightEnd):this.m_changed1=!0;let c=o;const g=s,_=i;c===g&&l.isCurve()&&(c=g+1);let d=1,p=0;const f=new r.P;if(c===g){const t=l.getCoord2D(n),s=e.getXY();d=u+_,p=o,(0,r.B)(t,s,_/d,f),this.m_changed1||t.equals(f)||(this.m_changed1=!0),this.m_changed2||s.equals(f)||(this.m_changed2=!0),h=r.P.sqrDistance(f,t)>a}else c>g?(f.assign(l.getCoord2D(n)),d=u,p=o,this.m_changed2||f.equals(e.getXY())||(this.m_changed2=!0)):(f.assign(l.getCoord2D(n)),d=_,p=g,this.m_changed1||f.equals(e.getXY())||(this.m_changed1=!0),h=r.P.sqrDistance(f,e.getXY())>a);let x=0,y=-1;const P=1;for(let e=0;e<=P;e++){const s=e<P?this.m_param1[0]:1;if(s!==x){const i=this.allocResultSegment(),n=this.m_resultSegments[i];l.queryCut(x,s,n),n.get().snapControlPoints(t*t);let r=m.weightStart,o=m.weightEnd,a=m.rankStart,h=m.rankEnd;const u=m.rankInterior,c=m.weightInterior;let g=m.u.bBreakStart,_=m.u.bBreakEnd;-1!==y&&(r=d,a=p,g=!0,n.get().setCoordsForIntersector(f,n.get().getEndXY(),!0)),e!==P&&(o=d,h=p,_=!0,n.get().setCoordsForIntersector(n.get().getStartXY(),f,!0)),x=s,this.m_resultParts1.push(this.newIntersectionPart_(i,r,a,o,h,c,u,g,_,m.segmentParentage))}y=e}return this.m_point.setXY(f),this.m_pointWeight=d,this.m_pointRank=p,h?3:2}return 0}intersect3D(t,e,s,i){return(0,n.g)(0),1}intersect3DEx(t,e,s,i,r,o,a){return(0,n.g)(0),1}getTolerance(){return this.m_tolerance}freeAllResultSegments(){this.m_resultSegments.length=0,this.m_freeSegments.length=0}freeResultSegment(t){this.m_freeSegments.push(t)}allocResultSegment(){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const t=new i.S,e=this.m_resultSegments.length;return this.m_resultSegments.push(t),e}allocResultSegmentFromBuffer(t){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const e=new i.S({copy:t}),s=this.m_resultSegments.length;return this.m_resultSegments.push(e),s}allocResultSegmentFromSegment(t){if(this.m_freeSegments.length)return this.m_freeSegments.pop();const e=new i.S({segment:t}),s=this.m_resultSegments.length;return this.m_resultSegments.push(e),s}}function w(t,e){return{bBigMoveStart:!1,bBigMoveEnd:!1,bBreakStart:t,bBreakEnd:e}}function D(){return{bBigMove:!1,bIsBreak:!1}}I.maxWeight=.1*Number.MAX_VALUE,I.c_smallToleranceFactor=.01,I.c_maxGeometryTypeToRankDelta=8;class T{constructor(){this.start=null,this.end=null,this.equalEdge=null,this.segmentIndex=-1,this.segmentParentage=-1,this.weight=0,this.rank=0}hasSegment(){return this.segmentIndex>=0}transferAttributes(t,e,s){if(1===e.getDescription().getAttributeCount())return;const n=t.parent.m_resultSegments[this.segmentIndex].get().getStartXY(),r=t.parent.m_resultSegments[this.segmentIndex].get().getEndXY(),o=new i.P;e.queryStart(o),s?(o.setXY(n),t.parent.m_resultSegments[this.segmentIndex].get().setStart(o)):(o.setXY(r),t.parent.m_resultSegments[this.segmentIndex].get().setEnd(o)),e.queryEnd(o),s?(o.setXY(r),t.parent.m_resultSegments[this.segmentIndex].get().setEnd(o)):(o.setXY(n),t.parent.m_resultSegments[this.segmentIndex].get().setStart(o))}copyFromWhenOverlap(t,e,s){this.equalEdge=e,e.equalEdge=this,this.segmentIndex=t.parent.allocResultSegmentFromBuffer(t.parent.m_resultSegments[e.segmentIndex]),this.segmentParentage=e.segmentParentage,this.weight=e.weight,this.rank=e.rank,s?(this.start.copyFrom(e.start),this.end.copyFrom(e.end)):(this.start.copyFrom(e.end),this.end.copyFrom(e.start),t.parent.m_resultSegments[this.segmentIndex].get().reverse())}getEnd(){return this.end}getNextInChain(){return this.end.nextInChain}getPrevInChain(){return this.start.prevInChain}}class N{constructor(){this.hash=0,this.pt=new r.P,this.prevInChain=null,this.nextInChain=null,this.prevInHash=null,this.nextInHash=null,this.prevEqual=null,this.nextEqual=null,this.weight=0,this.rank=0,this.bBigMove=!1,this.bIsBreak=!1}copyFrom(t){this.pt.assign(t.pt),this.weight=t.weight,this.rank=t.rank,this.bBigMove=t.bBigMove,this.bIsBreak=t.bIsBreak}nextNode(){return this.nextInChain?this.nextInChain.end:null}prevNode(){return this.prevInChain?this.prevInChain.start:null}equalListHead(){let t=this;for(;null!==t.prevEqual;t=t.prevEqual);return t}}function A(t,e,s,i){return{edge1:t,edge2:e,recursion:s,bIsIntersecting:i}}class M{constructor(t){this.m_pairs=[],this.m_chainOrigin1=null,this.m_chainOrigin2=null,this.m_newNodes=[],this.m_hashTableOfEquals=[],this.m_hashTableOfEqualsSize=0,this.m_origin=new r.P,this.m_cell=new r.P,this.parent=t}addSegment(t,e,s,i,r,o,a,h,m,l,u){const c=this.newNode(this.parent.m_resultSegments[t].get().getStartXY(),s,i,m),g=this.newNode(this.parent.m_resultSegments[t].get().getEndXY(),r,o,l);this.newEdge(c,g,t,a,h,u),null===this.m_chainOrigin1?this.m_chainOrigin1=c:null===this.m_chainOrigin2?this.m_chainOrigin2=c:(0,n.g)(0)}intersectCurvesHelper(t,e,s,o,a){const h=this.getSegment(t).get(),m=this.getSegment(e).get();if(h.isDegenerate(0)||m.isDegenerate(0))return 0;const l=this.tryOverlapIntersectCurves(t,e,s,o);if(0!==l)return l;const u=(0,r.e)(.01*s);let c=!1,g=this.processSharpCorners(h,m,s,a>4);const _=g>0;if(!_){if(!(o||5&(0,i.am)(!0,!1,h,m,s,!0)))return 0;g=(0,i.ak)(!0,h,m,null,this.parent.m_param1,this.parent.m_param2,s)}0===g&&(0,n.b)("");const d=h.getGeometryType(),p=m.getGeometryType(),f=(0,r.m)(r.P,g),x=(0,r.m)(r.P,g),y=new Array(g),P=new Array(g),E=new Array(g),C=new Array(g),v=(0,r.t)(D,g),b=(0,r.t)(D,g);let S=!1,w=!1;for(let i=0;i<g;i++){const n=this.parent.m_param1[i],o=this.parent.m_param2[i];let a=t.rank,l=t.weight,g=!0,D=!1;0===n?(a=t.start.rank,l=t.start.weight,D=t.start.bIsBreak):1===n?(a=t.end.rank,l=t.end.weight,D=t.end.bIsBreak):(S=!0,g=!1);let T=e.rank,N=e.weight,A=!1,M=!0;0===o?(T=e.start.rank,N=e.start.weight,A=e.start.bIsBreak):1===o?(T=e.end.rank,N=e.end.weight,A=e.end.bIsBreak):(w=!0,M=!1);let q=a,F=T;if(q===F&&(q*=I.c_maxGeometryTypeToRankDelta,F*=I.c_maxGeometryTypeToRankDelta,q+=G(d,h,!1),F+=G(p,m,!1)),g&&M&&F===q){const t=h.getCoord2D(n),e=m.getCoord2D(o);t.equals(e)&&(F=q-1)}let V=1,R=0,Y=1,X=0;const k=new r.P,H=new r.P,B=h.getCoord2D(n),L=m.getCoord2D(o);if(_&&r.P.distance(B,L)>s)k.setCoordsPoint2D(B),H.setCoordsPoint2D(L),V=l,Y=N,R=a,X=T,v[i].bBigMove=!1,b[i].bBigMove=!1,D=!0,A=!0;else if(q===F){Y=V=l+N,X=R=a,(0,r.B)(B,L,N/V,k),H.setCoordsPoint2D(k);const t=r.P.sqrDistance(k,B),e=r.P.sqrDistance(k,L);v[i].bBigMove=t>u,b[i].bBigMove=e>u,S||B.equals(k)||(S=!0),w||L.equals(H)||(w=!0)}else if(q>F){k.setCoordsPoint2D(B),H.setCoordsPoint2D(k),Y=V=l,X=R=a;const t=r.P.sqrDistance(k,L);v[i].bBigMove=!1,b[i].bBigMove=t>u,w||L.equals(H)||(w=!0)}else{H.setCoordsPoint2D(L),k.setCoordsPoint2D(H),Y=V=N,X=R=T;const t=r.P.sqrDistance(k,B);v[i].bBigMove=t>u,b[i].bBigMove=!1,S||B.equals(k)||(S=!0)}f[i].assign(k),x[i].assign(H),y[i]=V,P[i]=Y,E[i]=R,C[i]=X,v[i].bIsBreak=D||A,b[i].bIsBreak=D||A,c||=v[i].bBigMove||b[i].bBigMove,i>0&&(n!==this.parent.m_param1[i-1]&&o!==this.parent.m_param2[i-1]||(E[i]<=E[i-1]?(f[i].assign(x[i-1]),y[i]=P[i-1],E[i]=C[i-1],x[i].assign(x[i-1]),P[i]=P[i-1],C[i]=C[i-1],v[i].bBigMove||=v[i-1].bBigMove,b[i].bBigMove||=b[i-1].bBigMove,v[i].bIsBreak||=v[i-1].bIsBreak,b[i].bIsBreak||=b[i-1].bIsBreak):(f[i-1].assign(f[i]),y[i-1]=y[i],E[i-1]=E[i],x[i-1].assign(x[i]),P[i-1]=P[i],C[i-1]=C[i],v[i-1].bBigMove||=v[i].bBigMove,b[i-1].bBigMove||=b[i].bBigMove,v[i-1].bIsBreak||=v[i].bIsBreak,b[i-1].bIsBreak||=b[i].bIsBreak)))}if(!(S||w||2!==g||d===n.G.enumLine&&p===n.G.enumLine)){if(this.processDoublyConnectedEdges(t,e,a+1,s))return this.parent.m_changed1=!0,this.parent.m_changed2=!0,2;(0,n.g)(0)}this.parent.m_changed1||=S,this.parent.m_changed2||=w;let T=t,N=t.end.weight,A=t.end.rank,M=t.end.bBigMove,q=t.end.bIsBreak,F=0,V=-1;for(let e=0;e<=g;e++){const i=e<g?this.parent.m_param1[e]:1;if(i!==F){const n=this.parent.allocResultSegment(),o=this.parent.m_resultSegments[n];let a,m,l,u;h.queryCut(F,i,o,!1),o.get().snapControlPoints(s*s);let c=!1,_=!1,d=!1,p=!1;const x=new r.P,P=new r.P;-1!==V?(m=E[V],a=y[V],d=v[V].bBigMove,c=v[V].bIsBreak,x.assign(f[V])):(a=t.start.weight,m=t.start.rank,d=t.start.bBigMove,c=t.start.bIsBreak,x.assign(o.get().getStartXY())),e<g?(u=E[e],l=y[e],p=v[e].bBigMove,_=v[e].bIsBreak,P.assign(f[e])):(l=N,u=A,p=M,_=q,P.assign(o.get().getEndXY()));let C=T;i<1&&(this.splitEdgeInPlace(T),C=T.getNextInChain()),this.updateSegmentOnly(T,n),0===T.start.hash||T.start.pt.equals(x)||(this.m_newNodes.push(T.start),this.removeNodeFromHash(T.start),T.start.hash=0),0===T.end.hash||T.end.pt.equals(P)||(this.m_newNodes.push(T.end),this.removeNodeFromHash(T.end),T.end.hash=0),T.start.pt.assign(x),T.end.pt.assign(P),T.start.bBigMove||=d,T.end.bBigMove||=p,T.start.bIsBreak||=c,T.end.bIsBreak||=_,T.start.weight=a,T.start.rank=m,T.end.weight=l,T.end.rank=u,T=C,F=i,V=e}else-1===V&&(V=e)}const R=T.getNextInChain(),Y=[];Y.length=g;for(let t=0;t<g;t++)Y[t]=t;g>2?(Y.sort(((t,e)=>(0,r.F)(this.parent.m_param2[t],this.parent.m_param2[e]))),this.parent.m_param2.sort(r.F)):2===g&&this.parent.m_param2[0]>this.parent.m_param2[1]&&(this.parent.m_param2[1]=(0,r.b)(this.parent.m_param2[0],this.parent.m_param2[0]=this.parent.m_param2[1]),Y[1]=(0,r.b)(Y[0],Y[0]=Y[1])),T=e,N=e.end.weight,A=e.end.rank,M=e.end.bBigMove,q=e.end.bIsBreak,F=0,V=-1;for(let t=0;t<=g;t++){const i=t<g?this.parent.m_param2[t]:1;if(i!==F){const n=this.parent.allocResultSegment(),o=this.parent.m_resultSegments[n];let a,h,l,u;m.queryCut(F,i,o,!1),o.get().snapControlPoints(s*s);const c=new r.P,_=new r.P;let d=!1,p=!1,f=!1,y=!1;if(-1!==V){const t=Y[V];a=P[t],h=C[t],c.assign(x[t]),f=b[t].bBigMove,d=b[t].bIsBreak}else a=e.start.weight,h=e.start.rank,f=e.start.bBigMove,d=e.start.bIsBreak,c.assign(o.get().getStartXY());if(t!==g){const e=Y[t];l=P[e],u=C[e],_.assign(x[e]),y=b[e].bBigMove,p=b[e].bIsBreak}else l=N,u=A,y=M,p=q,_.assign(o.get().getEndXY());let E=T;i<1&&(this.splitEdgeInPlace(T),E=T.getNextInChain()),this.updateSegmentOnly(T,n),0===T.start.hash||T.start.pt.equals(c)||(this.m_newNodes.push(T.start),this.removeNodeFromHash(T.start),T.start.hash=0),0===T.end.hash||T.end.pt.equals(_)||(this.m_newNodes.push(T.end),this.removeNodeFromHash(T.end),T.end.hash=0),T.start.pt.assign(c),T.end.pt.assign(_),T.start.bBigMove||=f,T.end.bBigMove||=y,T.start.bIsBreak||=d,T.end.bIsBreak||=p,T.start.weight=a,T.start.rank=h,T.end.weight=l,T.end.rank=u,T=E,F=i,V=t}else-1===V&&(V=t)}const X=T.getNextInChain();return this.postProcessResultPartsForCurves(t,R,e,X,a+1),c?3:2}intersectCurves(t,e){2!==this.parent.m_inputSegments.length&&(0,n.b)(""),this.parent.m_changed1=!1,this.parent.m_changed2=!1,this.parent.m_tolerance=t,this.m_hashTableOfEqualsSize=0,this.m_hashTableOfEquals=(0,r.k)(16);const s=i.a.constructEmpty();for(let t=0;t<2;t++){const e=this.parent.allocResultSegmentFromSegment(this.parent.m_inputSegments[this.parent.m_inputParts[t].segmentIndex]),n=i.a.constructEmpty();this.parent.m_inputSegments[this.parent.m_inputParts[t].segmentIndex].queryLooseEnvelope(n),s.mergeEnvelope2D(n);const r=this.parent.m_inputParts[t];this.addSegment(e,0,r.weightStart,r.rankStart,r.weightEnd,r.rankEnd,r.weightInterior,r.rankInterior,r.u.bBreakStart,r.u.bBreakEnd,r.segmentParentage)}s.inflateCoords(100*t,100*t),this.m_origin.assign(s.getLowerLeft()),this.m_cell.setCoords(2*t,2*t),this.m_pairs.push(A(this.m_chainOrigin1.nextInChain,this.m_chainOrigin2.nextInChain,0,e));let o=0,a=!0;for(;this.m_pairs.length;){const e=this.m_pairs.at(-1);this.m_pairs.pop(),(0,n.g)(e.recursion>=0),(0,n.g)(e.recursion<=256),this.clusterNodes(t);const s=this.intersectCurvesHelper(e.edge1,e.edge2,t,e.bIsIntersecting,e.recursion);a&&(a=!1,o=s)}for(let t=0;t<2;t++){const e=0===t?this.parent.m_resultParts1:this.parent.m_resultParts2;for(let s=(0===t?this.m_chainOrigin1:this.m_chainOrigin2).nextInChain;null!=s;s=s.getNextInChain())e.push(this.parent.newIntersectionPart_(s.segmentIndex,s.start.weight,s.start.rank,s.end.weight,s.end.rank,s.weight,s.rank,s.start.bIsBreak,s.end.bIsBreak,s.segmentParentage)),e.at(-1).u.bBigMoveStart=s.start.bBigMove,e.at(-1).u.bBigMoveEnd=s.end.bBigMove}return o}tryOverlapIntersectCurves(t,e,s,o){const a=this.parent.m_resultSegments[t.segmentIndex].get(),h=this.parent.m_resultSegments[e.segmentIndex].get(),m=a.getStartXY().equals(h.getStartXY())&&a.getEndXY().equals(h.getEndXY()),l=a.getStartXY().equals(h.getEndXY())&&a.getEndXY().equals(h.getStartXY());if(!m&&!l)return 0;const u=(0,i.as)(a,h,!0);if(0!==u&&(0,i.at)(a,h)&&t.segmentParentage===e.segmentParentage){let t=!1;if(u>0)t=a.equals(h);else{(0,n.g)(-1===u);const e=new i.S({segment:h});e.get().reverse(),t=a.equals(e.get())}if(t)return 1}const c=s*I.c_smallToleranceFactor;let g=!1;if(0===u){const t=[.5,.25,.75,.125,.375,.625,.875,.5625,.3125];for(let e=0,i=t.length;e<i;++e){const i=t[e],n=new r.P;a.queryCoord2D(i,n);const o=h.getClosestCoordinate(n,!1),m=new r.P;h.queryCoord2D(o,m);const l=r.P.distance(n,m);if(l>s)return 0;g||=l>c}for(let e=0,i=t.length;e<i;++e){const i=t[e],n=new r.P;h.queryCoord2D(i,n);const o=a.getClosestCoordinate(n,!1),m=new r.P;a.queryCoord2D(o,m);const l=r.P.distance(n,m);if(l>s)return 0;g||=l>c}}let _=t.rank,d=e.rank;return _===d&&(_*=I.c_maxGeometryTypeToRankDelta,d*=I.c_maxGeometryTypeToRankDelta,_+=G(a.getGeometryType(),a,!0),d+=G(h.getGeometryType(),h,!0)),_>d?(e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)):d>_?(t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,h,m)):t.segmentParentage<=e.segmentParentage?(t.weight=t.weight+e.weight,e.copyFromWhenOverlap(this,t,m),e.transferAttributes(this,a,m)):(e.weight=t.weight+e.weight,t.copyFromWhenOverlap(this,e,m),t.transferAttributes(this,h,m)),g?3:2}postProcessResultPartsForCurves(t,e,s,i,o){o===(0,r.G)()&&(0,n.b)("curve_helper");for(let s=t;s!==e;s=s.getNextInChain())this.updateSegmentToNodes(s);for(let t=s;t!==i;t=t.getNextInChain())this.updateSegmentToNodes(t);for(let a=t;a!==e;a=a.getNextInChain()){const t=a.end.pt.sub(a.start.pt);for(let e=s;e!==i;e=e.getNextInChain()){let s=0;if(a.start.pt.equals(e.start.pt)&&a.end.pt.equals(e.end.pt)?s=1:a.start.pt.equals(e.end.pt)&&a.end.pt.equals(e.start.pt)&&(s=-1),!s){let s=a.start.pt.equals(e.start.pt)?1:0;if(s||(s=a.end.pt.equals(e.end.pt)?2:0,s||(s=a.end.pt.equals(e.start.pt)?3:0,s||(s=a.start.pt.equals(e.end.pt)?4:0))),s){const i=e.end.pt.sub(e.start.pt),r=t.dotProduct(i);let h;switch(s){case 1:case 2:h=r>0;break;case 3:case 4:h=r<0;break;default:(0,n.b)("post_process_result_parts_for_curves_")}h&&this.m_pairs.push(A(a,e,o,!1))}continue}const i=this.parent.m_resultSegments[a.segmentIndex],h=this.parent.m_resultSegments[e.segmentIndex],m=[.5,.25,.75];for(let t=0,e=m.length;t<e;++t){const e=m[t],n=new r.P;i.get().queryCoord2D(e,n);const o=h.get().getClosestCoordinate(n,!1),a=new r.P;if(h.get().queryCoord2D(o,a),r.P.distance(n,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(A(a,e,o,!1));continue}for(let t=0,e=m.length;t<e;++t){const e=m[t],n=new r.P;h.get().queryCoord2D(e,n);const o=i.get().getClosestCoordinate(n,!1),a=new r.P;if(i.get().queryCoord2D(o,a),r.P.distance(n,a)>this.parent.m_tolerance){s=0;break}}if(!s){this.m_pairs.push(A(a,e,o,!1));continue}a.equalEdge=e,e.equalEdge=a;let l=a.rank,u=e.rank;l===u&&(l*=I.c_maxGeometryTypeToRankDelta,u*=I.c_maxGeometryTypeToRankDelta,l+=G(i.get().getGeometryType(),i.get(),!0),u+=G(h.get().getGeometryType(),h.get(),!0)),l>u||l===u&&a.segmentParentage<=e.segmentParentage?(i.copyTo(h,!1),e.segmentParentage=a.segmentParentage,-1===s&&h.get().reverse()):(h.copyTo(i,!1),a.segmentParentage=e.segmentParentage,-1===s&&i.get().reverse());break}}this.updateAttachedEdgesAfterNodeChange(t.start),e&&this.updateAttachedEdgesAfterNodeChange(e.start),this.updateAttachedEdgesAfterNodeChange(s.start),i&&this.updateAttachedEdgesAfterNodeChange(i.start)}processDoublyConnectedEdges(t,e,s,o){s===(0,r.G)()&&(0,n.b)("curve_helper");const a=this.getSegment(t).get(),h=this.getSegment(e).get(),m=a.getStartXY().equals(h.getStartXY())&&a.getEndXY().equals(h.getEndXY())?1:a.getEndXY().equals(h.getStartXY())&&a.getStartXY().equals(h.getEndXY())?-1:0;if(0!==m){const n=new i.S;a.queryCut(0,.5,n),n.get().snapControlPoints(o*o);const r=new i.S;a.queryCut(.5,1,r),r.get().snapControlPoints(o*o),this.splitEdgeInPlace(t),t.end.pt=n.get().getEndXY(),t.segmentIndex=this.parent.allocResultSegmentFromBuffer(n),t.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(r);let l=h.getClosestCoordinate(t.end.pt,!1);return Math.abs(l-.5)>.2&&(l=.5),h.queryCut(0,l,n),n.get().snapControlPoints(o*o),h.queryCut(l,1,r),r.get().snapControlPoints(o*o),this.splitEdgeInPlace(e),e.end.pt=n.get().getEndXY(),e.segmentIndex=this.parent.allocResultSegmentFromBuffer(n),e.getNextInChain().segmentIndex=this.parent.allocResultSegmentFromBuffer(r),m>0?(this.m_pairs.push(A(t,e,s,!1)),this.m_pairs.push(A(t.getNextInChain(),e.getNextInChain(),s,!1))):(this.m_pairs.push(A(t,e.getNextInChain(),s,!1)),this.m_pairs.push(A(t.getNextInChain(),e,s,!1))),!0}return!1}newNode(t,e,s,i){const n=new N;return this.m_newNodes.push(n),n.pt=t,n.rank=s,n.weight=e,n.bIsBreak=i,n}newEdge(t,e,s,i,n,r){const o=new T;return o.start=t,o.end=e,t.nextInChain=o,e.prevInChain=o,o.segmentIndex=s,o.segmentParentage=r,o.rank=n,o.weight=i,o}splitEdgeInPlace(t){t.segmentIndex=-1;const e=new T,s=new N;this.m_newNodes.push(s),s.pt.setNAN(),s.nextInChain=e,s.prevInChain=t,s.prevInHash=null,s.nextInHash=null,s.prevEqual=null,s.nextEqual=null,s.weight=t.weight,s.rank=t.rank,s.bIsBreak=!1,s.bBigMove=!1,e.start=s,e.segmentIndex=-1,e.end=t.end,e.end.prevInChain=e,e.rank=t.rank,e.weight=t.weight,e.segmentParentage=t.segmentParentage,t.end=s,t.equalEdge&&(t.equalEdge.equalEdge=null),t.equalEdge=null}updateSegmentOnly(t,e){t.segmentIndex=e}updateAttachedEdgesAfterNodeChange(t){for(let e=t.equalListHead();null!==e;e=e.nextEqual)this.updateAttachedEdgesAfterNodeChangeImpl(e)}updateAttachedEdgesAfterNodeChangeImpl(t){const e=t.prevInChain;if(e&&e.hasSegment()){const s=this.getSegment(e).get();t.pt.equals(s.getEndXY())||(s.setCoordsForIntersector(e.start.pt,e.end.pt,!1),s.ensureXYMonotone())}const s=t.nextInChain;if(s&&s.hasSegment()){const e=this.getSegment(s).get();t.pt.equals(e.getStartXY())||(e.setCoordsForIntersector(s.start.pt,s.end.pt,!1),e.ensureXYMonotone())}}updateSegmentToNodes(t){const e=this.getSegment(t).get();t.start.pt.equals(e.getStartXY())&&t.end.pt.equals(e.getEndXY())||(e.setCoordsForIntersector(t.start.pt,t.end.pt,!1),e.ensureXYMonotone()),this.updateAttachedEdgesAfterNodeChange(t.start),this.updateAttachedEdgesAfterNodeChange(t.end)}getSegment(t){return this.parent.m_resultSegments[t.segmentIndex]}clusterNodes(t){let e=!1;const s=[],i=[],n=[];for(let t=0,e=this.m_newNodes.length;t<e;t++){const s=this.m_newNodes[t];if(null===s)continue;let i=s;for(let n=t+1;n<e;n++){const t=this.m_newNodes[n];null!==t&&s.pt.equals(t.pt)&&(i.nextInHash=t,t.prevInHash=i,i=t,this.m_newNodes[n]=null)}}for(let o=0,a=this.m_newNodes.length;o<a;o++){const a=this.m_newNodes[o];if(null==a)continue;for(a.hash=this.calculateHash(a.pt);;){const o=(0,r.k)(4),h=this.hashTableBinsToCheck(a,o);for(let e=0;e<h;e++)if(null!==o[e])for(let h=o[e];null!==h;){const e=h.nextInHash;r.P.distance(a.pt,h.pt)<=t&&(s.push(h),this.removeNodeFromHash(h),h.hash=0,n.push(h),i.push(h)),h=e}let m=!1;for(const t of s)if(!a.pt.equals(t.pt)){const s=C(a.pt,t.pt,a.weight,a.rank,t.weight,t.rank);a.pt.assign(s.pt),a.weight=s.weight,a.rank=s.rank,m=!0,e=!0}if(s.length=0,!m)break;a.hash=this.calculateHash(a.pt)}n.push(a),i.push(a);for(let t=a.nextInHash;null!==t;){t.prevInHash=null;const e=t.nextInHash;t.nextInHash=null,n.push(t),i.push(t),t=e}const h=a.hash;let m=null,l=null;for(const t of i)a!==t&&(t.hash=h,t.pt.assign(a.pt),t.rank=a.rank,t.weight=a.weight),t.prevInHash=m,m&&(m.nextInHash=t),t.prevEqual=l,t.nextEqual=null,l&&(l.nextEqual=t),l=t,m=t;const u=h%this.m_hashTableOfEquals.length;m.nextInHash=this.m_hashTableOfEquals[u],null!==this.m_hashTableOfEquals[u]&&(this.m_hashTableOfEquals[u].prevInHash=m),this.m_hashTableOfEquals[u]=i[0],this.m_hashTableOfEqualsSize+=i.length,i.length=0,this.rehashIfNeeded()}if(this.m_newNodes.length=0,e)for(const t of n)this.updateAttachedEdgesAfterNodeChange(t)}rehashIfNeeded(){if(2*this.m_hashTableOfEqualsSize>this.m_hashTableOfEquals.length){const t=this.m_hashTableOfEquals;this.m_hashTableOfEquals=(0,r.k)(2*t.length),this.m_hashTableOfEqualsSize=0;for(const e of t){let t=e;for(;t;){const e=t.nextInHash;t.nextInHash=null,t.prevInHash=null,this.addNodeToHashImpl(t),t=e}}}}addNodeToHashImpl(t){const e=t.hash%this.m_hashTableOfEquals.length,s=this.m_hashTableOfEquals[e];t.nextInHash=s,null!==s&&(s.prevInHash=t),this.m_hashTableOfEquals[e]=t,this.m_hashTableOfEqualsSize++}removeNodeFromHash(t){const e=t.hash%this.m_hashTableOfEquals.length,s=t.prevInHash,i=t.nextInHash;s?s.nextInHash=i:this.m_hashTableOfEquals[e]=i,i&&(i.prevInHash=s),this.m_hashTableOfEqualsSize--,t.prevInHash=null,t.nextInHash=null}hashTableBinsToCheck(t,e){const s=(t.pt.x-this.m_origin.x)/this.m_cell.x,i=(t.pt.y-this.m_origin.y)/this.m_cell.y,n=(0,r.o)()-1,o=Math.round((0,r.l)(s,-n,n)),a=Math.round((0,r.l)(i,-n,n));let h=o|a<<32;h=(0,r.i)(h),e[0]=this.m_hashTableOfEquals[h%this.m_hashTableOfEquals.length];let m=o+1|a<<32;m=(0,r.i)(m);let l=1;e[1]=this.m_hashTableOfEquals[m%this.m_hashTableOfEquals.length],e[1]!==e[0]&&(l=2);let u=o+1|a+1<<32;u=(0,r.i)(u),e[l]=this.m_hashTableOfEquals[u%this.m_hashTableOfEquals.length];for(let t=0;t<l;t++)if(e[l]===e[t]){l--;break}l++;let c=o|a+1<<32;c=(0,r.i)(c),e[l]=this.m_hashTableOfEquals[c%this.m_hashTableOfEquals.length];for(let t=0;t<l;t++)if(e[l]===e[t]){l--;break}return l++,l}calculateHash(t){const e=(t.x-this.m_origin.x)/this.m_cell.x,s=(t.y-this.m_origin.y)/this.m_cell.y,i=(0,r.o)()-1;let n=Math.round((0,r.l)(e,-i,i))|Math.round((0,r.l)(s,-i,i))<<32;return n=(0,r.i)(n),0===n&&(n=1),n}processSharpCorners(t,e,s,n){if(this.parent.m_param1.length=0,this.parent.m_param2.length=0,t.getStartXY().equals(e.getStartXY())){const r=[0,0],o=[0,0],a=(0,i.au)(t,e,0,0,s,2,r,o,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(0);for(let t=0;t<a;t++)this.parent.m_param1.push(r[t]),this.parent.m_param2.push(o[t]);return a+1}}if(t.getEndXY().equals(e.getEndXY())){const r=[0,0],o=[0,0],a=(0,i.au)(t,e,1,1,s,2,r,o,n);if(a){for(let t=0;t<a;t++)this.parent.m_param1.push(r[t]),this.parent.m_param2.push(o[t]);return this.parent.m_param1.push(1),this.parent.m_param2.push(1),a+1}}if(t.getStartXY().equals(e.getEndXY())){const r=[0,0],o=[0,0],a=(0,i.au)(t,e,0,1,s,2,r,o,n);if(a){this.parent.m_param1.push(0),this.parent.m_param2.push(1);for(let t=0;t<a;t++)this.parent.m_param1.push(r[t]),this.parent.m_param2.push(o[t]);return a+1}}if(t.getEndXY().equals(e.getStartXY())){const r=[0,0],o=[0,0],a=(0,i.au)(t,e,1,0,s,2,r,o,n);if(a){for(let t=0;t<a;t++)this.parent.m_param1.push(r[t]),this.parent.m_param2.push(o[t]);return this.parent.m_param1.push(1),this.parent.m_param2.push(0),a+1}}return 0}}function G(t,e,s){let i=0;switch(t){case n.G.enumLine:i=0;break;case n.G.enumBezier:i=2;break;case n.G.enumRationalBezier2:i=3;break;case n.G.enumBezier2:i=1;break;case n.G.enumEllipticArc:i=0===e.projectionBehavior()?5:4;break;default:(0,n.b)("")}return s?5-i:i}class q extends f{constructor(t){super(t.m_shape,t.m_tolerance,!1),this.m_parent=t}compare(t,e,s){if(this.m_bIntersectionDetected)return-1;const i=t.getElement(s),n=this.m_parent.getEdgeOriginVertices(e),r=this.m_parent.m_edgeVertices.getFirstElement(n),o=this.m_parent.getEdgeOriginVertices(i),a=this.m_parent.m_edgeVertices.getFirstElement(o);return this.m_currentNode=s,this.compareSegments(e,r,i,a)}}class F extends x{constructor(t){super(t.m_shape,t.m_tolerance),this.m_parent=t}compare(t,e){if(this.m_bIntersectionDetected)return-1;const s=t.getElement(e),i=this.m_parent.getEdgeOriginVertices(s),n=this.m_parent.m_edgeVertices.getFirstElement(i);return this.m_currentNode=e,this.compareVertex(t,e,n)}}class V extends i.F{constructor(t){super(),this.pt1=r.P.getNAN(),this.pt2=r.P.getNAN(),this.m_shape=t}compare(t,e,s){this.m_shape.queryXY(e,this.pt1);const i=t.getElement(s);return this.m_shape.queryXY(i,this.pt2),this.pt1.compare(this.pt2)}}class R{constructor(t){this.m_point=r.P.getNAN(),this.m_pt=r.P.getNAN(),this.m_shape=t}setPoint(t){this.m_point.setCoordsPoint2D(t)}compare(t,e){const s=t.getElement(e);return this.m_shape.queryXY(s,this.m_pt),this.m_point.compare(this.m_pt)}}class Y{constructor(t,e){this.m_shape=null,this.m_progressTracker=null,this.m_edges=new i.r(8),this.m_clusters=new i.r(5),this.m_clusterVertices=new d(!1),this.m_edgeVertices=new d(!1),this.m_helperPoint=new i.P,this.m_eventQ=new i.T,this.m_sweepStructure=new i.T,this.m_bComplications=!1,this.m_sweepComparator=null,this.m_tempEdgeBuffer=[],this.m_modifiedClusters=[],this.m_edgesToInsertInSweepStructure=[],this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1,this.m_progressCounter=0,this.m_segmentIntersector=new I,this.m_segBuf1=new i.S,this.m_segBuf2=new i.S,this.m_sweepPoint=new r.P(0,0),this.m_tolerance=0,this.m_toleranceSqr=0,this.m_sweepPointCluster=-1,this.m_vertexClusterIndex=-1,this.m_bCracked=!1,this.m_bSweepPointClusterWasModified=!1,this.m_progressTracker=t,this.m_bTrackChanges=e}hadComplications(){return this.m_bComplications}sweep(t,e){const s=new r.T;s.setSwapCoordinates(),t.applyTransformation(s),this.setEditShape_(t),this.m_bCracked=!1,this.m_tolerance=e,this.m_toleranceSqr=e*e;let i=this.sweepImpl_();return t.applyTransformation(s),i||(this.fillEventQueuePass2(),i=this.sweepImpl_()||i),this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_shape=null,this.m_bCracked}sweepVertical(t,e){this.setEditShape_(t),this.m_bCracked=!1,this.m_tolerance=e,this.m_toleranceSqr=e*e,this.m_bComplications=!1;let s=this.sweepImpl_();if(!this.m_bComplications){const n=t.filterClosePoints(e,!0,!1,this.m_bTrackChanges,i.n);this.m_bComplications=1===n,s||=1===n}return-1!==this.m_vertexClusterIndex&&(this.m_shape.removeUserIndex(this.m_vertexClusterIndex),this.m_vertexClusterIndex=-1),this.m_shape=null,s}getEdgeCluster(t,e){return this.m_edges.getField(t,0+e)}setEdgeCluster_(t,e,s){this.m_edges.setField(t,0+e,s)}getEdgeOriginVertices(t){return this.m_edges.getField(t,2)}setEdgeOriginVertices_(t,e){this.m_edges.setField(t,2,e)}getNextEdgeEx(t,e){return this.m_edges.getField(t,3+e)}setNextEdgeEx_(t,e,s){this.m_edges.setField(t,3+e,s)}getEdgeSweepNode(t){return this.m_edges.getField(t,7)}setEdgeSweepNode_(t,e){this.m_edges.setField(t,7,e)}getNextEdge(t,e){const s=this.getEdgeEnd(t,e);return this.m_edges.getField(t,3+s)}setNextEdge_(t,e,s){const i=this.getEdgeEnd(t,e);this.m_edges.setField(t,3+i,s)}getPrevEdge(t,e){const s=this.getEdgeEnd(t,e);return this.m_edges.getField(t,5+s)}setPrevEdge_(t,e,s){const i=this.getEdgeEnd(t,e);this.m_edges.setField(t,5+i,s)}getClusterVertices(t){return this.m_clusters.getField(t,0)}setClusterVertices_(t,e){this.m_clusters.setField(t,0,e)}getClusterSweepEdgeList(t){return this.m_clusters.getField(t,2)}setClusterSweepEdgeList_(t,e){this.m_clusters.setField(t,2,e)}getClusterFirstEdge(t){return this.m_clusters.getField(t,1)}setClusterFirstEdge_(t,e){this.m_clusters.setField(t,1,e)}getClusterEventQNode(t){return this.m_clusters.getField(t,3)}setClusterEventQNode_(t,e){this.m_clusters.setField(t,3,e)}newCluster_(t){const e=this.m_clusters.newElement(),s=this.m_clusterVertices.createList();return this.setClusterVertices_(e,s),t!==i.n&&(this.m_clusterVertices.addElement(s,t),this.m_shape.setUserIndex(t,this.m_vertexClusterIndex,e)),e}deleteCluster_(t){this.m_clusters.deleteElement(t)}addVertexToCluster_(t,e){const s=this.getClusterVertices(t);this.m_clusterVertices.addElement(s,e),this.m_shape.setUserIndex(e,this.m_vertexClusterIndex,t)}newEdge_(t){const e=this.m_edges.newElement(),s=this.m_edgeVertices.createList();return this.setEdgeOriginVertices_(e,s),-1!==t&&this.m_edgeVertices.addElement(s,t),e}addVertexToEdge_(t,e){const s=this.getEdgeOriginVertices(t);this.m_edgeVertices.addElement(s,e)}deleteEdge_(t){this.m_edges.deleteElement(t);const e=this.m_edgesToInsertInSweepStructure.findIndex((e=>e===t));e>=0&&(0,r.A)(this.m_edgesToInsertInSweepStructure,e)}addEdgeToCluster(t,e){-1===this.getEdgeCluster(t,0)?this.setEdgeCluster_(t,0,e):-1===this.getEdgeCluster(t,1)?this.setEdgeCluster_(t,1,e):(0,n.b)(""),this.addEdgeToClusterImpl_(t,e)}addEdgeToClusterImpl_(t,e){const s=this.getClusterFirstEdge(e);if(-1!==s){const i=this.getNextEdge(s,e);this.setPrevEdge_(i,e,t),this.setNextEdge_(t,e,i),this.setNextEdge_(s,e,t),this.setPrevEdge_(t,e,s)}else this.setPrevEdge_(t,e,t),this.setNextEdge_(t,e,t),this.setClusterFirstEdge_(e,t)}getEdgeEnd(t,e){return this.getEdgeCluster(t,0)===e?0:1}mergeClusters_(t,e){this.dbgCheckCluster_(t),this.dbgCheckCluster_(e);const s=this.getClusterEventQNode(e);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(e,-1));let i=this.getClusterFirstEdge(t),n=this.getClusterFirstEdge(e);if(-1!==n){let s=n,r=n,o=!1;do{this.dbgCheckEdge_(s),o=!1;const i=this.getEdgeEnd(s,e),a=this.getNextEdgeEx(s,i);if(this.getEdgeCluster(s,i+1&1)===t){this.disconnectEdge_(s);const t=this.getEdgeOriginVertices(s);if(this.m_edgeVertices.deleteList(t),this.deleteEdge_(s),s===a){n=-1;break}n===s&&(n=this.getClusterFirstEdge(e),r=a,o=!0)}s=a}while(s!==r||o);if(-1!==n){do{const i=this.getEdgeEnd(s,e),n=this.getNextEdgeEx(s,i);this.setEdgeCluster_(s,i,t),s=n}while(s!==r);if(i=this.getClusterFirstEdge(t),-1!==i){const e=this.getNextEdge(i,t),s=this.getNextEdge(n,t);e===i?(this.setClusterFirstEdge_(t,n),this.addEdgeToClusterImpl_(i,t),this.setClusterFirstEdge_(t,i)):s===n&&this.addEdgeToClusterImpl_(n,t),this.setNextEdge_(n,t,e),this.setPrevEdge_(e,t,n),this.setNextEdge_(i,t,s),this.setPrevEdge_(s,t,i)}else this.setClusterFirstEdge_(t,n)}}const r=this.getClusterVertices(t),o=this.getClusterVertices(e);for(let e=this.m_clusterVertices.getFirst(o);-1!==e;e=this.m_clusterVertices.getNext(e)){const s=this.m_clusterVertices.getElement(e);this.m_shape.setUserIndex(s,this.m_vertexClusterIndex,t)}this.m_clusterVertices.concatenateLists(r,o),this.deleteCluster_(e),this.dbgCheckCluster_(t)}mergeEdges_(t,e){this.dbgCheckEdge_(t),this.dbgCheckEdge_(e);const s=this.getEdgeCluster(t,0),i=this.getEdgeCluster(t,1),n=this.getEdgeCluster(e,0),r=this.getEdgeCluster(e,1),o=this.getEdgeOriginVertices(t),a=this.getEdgeOriginVertices(e);if(this.m_edgeVertices.concatenateLists(o,a),e===this.getClusterFirstEdge(s)&&this.setClusterFirstEdge_(s,t),e===this.getClusterFirstEdge(i)&&this.setClusterFirstEdge_(i,t),this.disconnectEdge_(e),this.deleteEdge_(e),!(s===n&&i===r||i===n&&s===r)){const t=this.getClusterXY(s),e=this.getClusterXY(n);t.isEqualPoint2D(e)?(s!==n&&this.mergeClusters_(s,n),i!==r&&this.mergeClusters_(i,r)):(i!==n&&this.mergeClusters_(i,n),s!==r&&this.mergeClusters_(s,r))}this.dbgCheckEdge_(t)}disconnectEdge_(t){const e=this.getEdgeCluster(t,0),s=this.getEdgeCluster(t,1);this.disconnectEdgeFromCluster_(t,e),this.disconnectEdgeFromCluster_(t,s)}disconnectEdgeFromCluster_(t,e){const s=this.getNextEdge(t,e),i=this.getPrevEdge(t,e),n=this.getClusterFirstEdge(e);s!==t?(this.setNextEdge_(i,e,s),this.setPrevEdge_(s,e,i),n===t&&this.setClusterFirstEdge_(e,s)):this.setClusterFirstEdge_(e,-1)}applyIntersectorToEditShape_(t,e,s){let i=this.m_edgeVertices.getFirst(t);const n=this.m_edgeVertices.getElement(i),r=this.getClusterFromVertex(n),o=this.m_shape.getNextVertex(n),a=this.getClusterFromVertex(o),h=this.m_shape.getXY(n),m=this.m_shape.getXY(o);let l=!1,u=!1;const c=e.getResultSegment(s,0).getStartXY(),g=e.getResultSegment(s,e.getResultSegmentCount(s)-1).getEndXY();h.equals(c)||(l=!0),m.equals(g)||(u=!0),this.m_shape.splitSegmentWithIntersector(n,e,s,!0,!0);const _=this.m_bTrackChanges&&e.getSegmentChanged(s);for(_&&this.m_shape.setGeometryModifiedWithVertex(n,!0),i=this.m_edgeVertices.getNext(i);-1!==i;i=this.m_edgeVertices.getNext(i)){const t=this.m_edgeVertices.getElement(i),n=this.getClusterFromVertex(t)===r;this.m_shape.splitSegmentWithIntersector(t,e,s,n,!0),_&&this.m_shape.setGeometryModifiedWithVertex(t,!0)}if(l&&this.updateClusterXY(!0,r,c,e.getResultSegmentStartPointWeight(s,0),e.getResultSegmentStartPointRank(s,0)),u){const t=e.getResultSegmentCount(s)-1;this.updateClusterXY(!0,a,g,e.getResultSegmentEndPointWeight(s,t),e.getResultSegmentEndPointRank(s,t))}}createEdgesAndClustersFromSplitEdge_(t,e,s){this.dbgCheckNewEdgesArray_();const n=this.getEdgeOriginVertices(t),r=this.getEdgeCluster(t,0),o=this.getEdgeCluster(t,1);let a=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(a);const h=i.r.impossibleIndex3();this.setEdgeSweepNode_(a,h),this.m_tempEdgeBuffer.push(a),this.addEdgeToCluster(a,r);const m=e.getResultSegmentCount(s);for(let t=1;t<m;t++){const t=this.newCluster_(-1);this.m_modifiedClusters.push(t),this.m_tempEdgeBuffer.push(t),this.addEdgeToCluster(a,t);const e=this.newEdge_(-1);this.m_edgesToInsertInSweepStructure.push(e),this.setEdgeSweepNode_(e,h),this.m_tempEdgeBuffer.push(e),this.addEdgeToCluster(e,t),a=e}this.addEdgeToCluster(a,o);for(let t=this.m_edgeVertices.getFirst(n);-1!==t;t=this.m_edgeVertices.getNext(t)){let e=this.m_edgeVertices.getElement(t);if(this.getClusterFromVertex(e)===r){let t=0;const s=this.m_tempEdgeBuffer.length;do{if(t>0){const s=this.m_tempEdgeBuffer[t-1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t+=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t<s)}else{let t=this.m_tempEdgeBuffer.length-1;do{if(t<this.m_tempEdgeBuffer.length-2){const s=this.m_tempEdgeBuffer[t+1];this.addVertexToCluster_(s,e)}const s=this.m_tempEdgeBuffer[t];t-=2,this.addVertexToEdge_(s,e),e=this.m_shape.getNextVertex(e)}while(t>=0)}}this.m_tempEdgeBuffer.length=0,this.dbgCheckNewEdgesArray_()}getVertexFromClusterIndex(t){const e=this.getClusterVertices(t);return this.m_clusterVertices.getFirstElement(e)}getClusterFromVertex(t){return this.m_shape.getUserIndex(t,this.m_vertexClusterIndex)}processSplitHelper1_(t,e,s){const n=this.getEdgeCluster(e,0),r=this.getClusterXY(n),o=this.getEdgeCluster(e,1),a=this.getClusterXY(o),h=s.getResultSegmentCount(t);let m=s.getResultSegment(t,0);const l=m.getStartXY();if(r.isEqualPoint2D(l)||(this.m_bComplications||r.compare(this.m_sweepPoint)*l.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(n,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(n)),!this.m_bComplications&&h>1){const t=r.compare(a),e=m.getEndXY();(r.compare(e)!==t||e.compare(a)!==t||e.compare(this.m_sweepPoint)<0)&&(this.m_bComplications=!0)}m=s.getResultSegment(t,h-1);const u=m.getEndXY();a.isEqualPoint2D(u)||(this.m_bComplications||a.compare(this.m_sweepPoint)*u.compare(this.m_sweepPoint)<0&&(this.m_bComplications=!0),this.getAffectedEdges(o,this.m_tempEdgeBuffer),this.m_modifiedClusters.push(o)),this.m_tempEdgeBuffer.push(e);for(let t=0,s=this.m_tempEdgeBuffer.length;t<s;t++){const s=this.m_tempEdgeBuffer[t],n=this.getEdgeSweepNode(s);i.r.isValidElement(n)&&(this.m_sweepStructure.deleteNode(n),this.setEdgeSweepNode_(s,-1));const r=i.r.impossibleIndex3();s!==e&&this.getEdgeSweepNode(s)!==r&&(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r))}this.m_tempEdgeBuffer.length=0}checkAndFixIntersection_(t,e){const s=this.m_sweepStructure.getElement(t);return this.m_sweepComparator.compare(this.m_sweepStructure,s,e),!!this.m_sweepComparator.intersectionDetected()&&(this.m_sweepComparator.clearIntersectionDetectedFlag(),this.fixIntersection_(t,e),!0)}fixIntersection_(t,e){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(t),i=this.m_sweepStructure.getElement(e);let r=null,o=null;const a=this.getEdgeOriginVertices(s),h=this.m_edgeVertices.getFirstElement(a),m=this.getEdgeOriginVertices(i),l=this.m_edgeVertices.getFirstElement(m),u=this.m_shape.querySegment(h,this.m_segBuf1,!1,!1);(0,n.g)(u),r=this.m_segBuf1.get();const c=this.m_shape.getNextVertex(h),g=this.m_shape.getWeight(h),_=this.m_shape.getSegmentParentageBreakVertex(h),d=this.m_shape.getWeight(c),p=this.m_shape.getSegmentParentageBreakVertex(c),f=this.m_shape.getSegmentWeight(h),x=this.m_shape.getRank(h),y=this.m_shape.getRank(c),P=this.m_shape.getSegmentRank(h),E=this.m_shape.getSegmentParentage(h),C=this.m_shape.querySegment(l,this.m_segBuf2,!1,!1);(0,n.g)(C),o=this.m_segBuf2.get();const v=this.m_shape.getNextVertex(l),b=this.m_shape.getWeight(l),S=this.m_shape.getSegmentParentageBreakVertex(l),I=this.m_shape.getWeight(v),w=this.m_shape.getSegmentParentageBreakVertex(v),D=this.m_shape.getSegmentWeight(l),T=this.m_shape.getRank(l),N=this.m_shape.getRank(v),A=this.m_shape.getSegmentRank(l),M=this.m_shape.getSegmentParentage(l);this.m_segmentIntersector.pushSegment(r,g,x,d,y,f,P,_,p,E),this.m_segmentIntersector.pushSegment(o,b,T,I,N,D,A,S,w,M),3===this.m_segmentIntersector.intersect2D(this.m_tolerance,!0)&&(this.m_bComplications=!0),this.splitEdge_(s,i,-1,this.m_segmentIntersector),this.m_segmentIntersector.clear()}fixIntersectionPointSegment_(t,e){this.m_bCracked=!0;const s=this.m_sweepStructure.getElement(e);let i=null;const r=this.getEdgeOriginVertices(s),o=this.m_edgeVertices.getFirstElement(r),a=this.m_shape.querySegment(o,this.m_segBuf1,!1,!1);(0,n.g)(a),i=this.m_segBuf1.get();const h=this.m_shape.getNextVertex(o),m=this.m_shape.getWeight(o),l=this.m_shape.getSegmentParentageBreakVertex(o),u=this.m_shape.getWeight(h),c=this.m_shape.getSegmentParentageBreakVertex(h),g=this.m_shape.getSegmentWeight(o),_=this.m_shape.getRank(o),d=this.m_shape.getRank(h),p=this.m_shape.getSegmentRank(o),f=this.m_shape.getSegmentParentage(o),x=this.getClusterFirstVertex(t);this.m_segmentIntersector.pushSegment(i,m,_,u,d,g,p,l,c,f),this.m_shape.queryPoint(x,this.m_helperPoint);const y=this.m_shape.getWeight(x),P=this.m_shape.getRank(x);this.m_segmentIntersector.intersect2DEx(this.m_tolerance,this.m_helperPoint,P,y,!0),this.splitEdge_(s,-1,t,this.m_segmentIntersector),this.m_segmentIntersector.clear()}insertNewEdges_(){if(0===this.m_edgesToInsertInSweepStructure.length)return!0;this.dbgCheckNewEdgesArray_();let t=!0,e=0;const s=this.m_edgesToInsertInSweepStructure.length,n=Math.max(2*s+200,this.m_sweepStructure.size()+200);for(;this.m_edgesToInsertInSweepStructure.length;){if(this.m_edgesToInsertInSweepStructure.length>Math.max(100,this.m_shape.getTotalPointCount())||e>n){this.m_edgesToInsertInSweepStructure.length=0,this.m_bComplications=!0,t=!1;break}const s=this.m_edgesToInsertInSweepStructure.at(-1);this.m_edgesToInsertInSweepStructure.pop(),this.setEdgeSweepNode_(s,-1);const r=this.isEdgeOnSweepLine_(s);i.r.isValidElement(r)?(this.insertNewEdgeToSweepStructure_(s,r),e++):r!==i.r.impossibleIndex2()&&(t=!1),this.m_bContinuingSegmentChainOptimization=!1}return t}insertNewEdgeToSweepStructure_(t,e){let s;if(this.m_bContinuingSegmentChainOptimization?(s=this.m_sweepStructure.addElementAtPosition(this.m_prevNeighbour,this.m_nextNeighbour,t,!0,!0),this.m_bContinuingSegmentChainOptimization=!1):s=this.m_sweepStructure.addUniqueElement(t),-1===s){const e=this.m_sweepStructure.getDuplicateElement(),s=this.m_sweepStructure.getElement(e);return this.mergeEdges_(s,t),!1}if(this.setEdgeSweepNode_(t,s),this.m_sweepComparator.intersectionDetected()){this.m_sweepComparator.clearIntersectionDetectedFlag();const t=this.m_sweepComparator.getLastComparedNode();return this.m_prevNeighbour===t&&(this.m_prevNeighbour=-1),this.m_nextNeighbour===t&&(this.m_nextNeighbour=-1),this.fixIntersection_(t,s),!0}return!1}isEdgeOnSweepLine_(t){const e=this.getEdgeCluster(t,0),s=this.getEdgeCluster(t,1),n=this.getClusterXY(e),o=this.getClusterXY(s);if(r.P.sqrDistance(n,o)<=this.m_toleranceSqr)return this.m_bComplications=!0,-1;const a=n.compare(this.m_sweepPoint),h=o.compare(this.m_sweepPoint);return a<=0&&h>0?s:h<=0&&a>0?e:a>0&&h>0?i.r.impossibleIndex2():-1}fillEventQueue(){const t=new i.A(0),e=this.m_shape.queryVertexIteratorOnSelection();for(let s=e.next();s!==i.n;s=e.next())-1!==this.m_shape.getUserIndex(s,this.m_vertexClusterIndex)&&t.add(s);this.m_shape.sortVerticesSimpleByY(t,0,t.size()),this.progress_(!0),this.m_eventQ.clear(),this.m_eventQ.setCapacity(t.size()),this.m_eventQ.setComparator(new V(this.m_shape));const s=r.P.getNAN();s.setNAN();let n=-1;for(let e=0,i=t.size();e<i;e++){const i=t.read(e);if(this.m_shape.getXY(i).isEqualPoint2D(s)){const t=this.m_shape.getUserIndex(i,this.m_vertexClusterIndex);this.mergeClusters_(n,t);continue}n=this.getClusterFromVertex(i),this.m_shape.queryXY(i,s);const r=this.m_eventQ.addBiggestElement(i);this.setClusterEventQNode_(n,r)}}fillEventQueuePass2(){const t=new i.A(0);for(let e=this.m_eventQ.getFirst();-1!==e;e=this.m_eventQ.getNext(e)){const s=this.m_eventQ.getElement(e);t.add(s)}this.m_eventQ.clear(),this.m_shape.sortVerticesSimpleByY(t,0,t.size()),this.progress_(!0);for(let e=0,s=t.size();e<s;e++){const s=t.read(e),i=this.getClusterFromVertex(s),n=this.m_eventQ.addBiggestElement(s);this.setClusterEventQNode_(i,n)}}getAffectedEdges(t,e){const s=this.getClusterFirstEdge(t);if(-1===s)return;let n=s;do{const s=this.getEdgeSweepNode(n);i.r.isValidElement(s)&&e.push(n),n=this.getNextEdge(n,t)}while(n!==s)}updateClusterXY(t,e,s,i,n){const r=this.getClusterVertices(e);for(let e=this.m_clusterVertices.getFirst(r);-1!==e;e=this.m_clusterVertices.getNext(e)){const r=this.m_clusterVertices.getElement(e);this.m_shape.setXYMonotonicPoint2D(r,s),this.m_shape.setWeight(r,i),this.m_shape.setRank(r,n),t&&this.m_bTrackChanges&&this.m_shape.setGeometryModifiedWithVertex(r,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)}}splitEdge_(t,e,s,i){this.dbgCheckEdge_(t),-1!==e&&this.dbgCheckEdge_(e),this.disconnectEdge_(t),-1!==e&&this.disconnectEdge_(e),this.processSplitHelper1_(0,t,i),-1!==e&&this.processSplitHelper1_(1,e,i),-1!==s&&i.getResultPointChanged()&&this.m_modifiedClusters.push(s);for(let t=0,e=this.m_modifiedClusters.length;t<e;t++){const e=this.m_modifiedClusters[t],s=this.getClusterEventQNode(e);-1!==s&&(this.m_eventQ.deleteNode(s),this.setClusterEventQNode_(e,-1))}const n=this.getEdgeOriginVertices(t),r=-1!==e?this.getEdgeOriginVertices(e):-1;if(this.applyIntersectorToEditShape_(n,i,0),-1!==r)this.applyIntersectorToEditShape_(r,i,1);else{const t=i.getResultPoint().getXY();this.updateClusterXY(i.getResultPointChanged(),s,t,i.getResultPointWeight(),i.getResultPointRank())}this.createEdgesAndClustersFromSplitEdge_(t,i,0),-1!==e&&this.createEdgesAndClustersFromSplitEdge_(e,i,1),this.m_edgeVertices.deleteList(n),this.deleteEdge_(t),-1!==e&&(this.m_edgeVertices.deleteList(r),this.deleteEdge_(e));for(let t=0,e=this.m_modifiedClusters.length;t<e;t++){const e=this.m_modifiedClusters[t];e===this.m_sweepPointCluster&&(this.m_bSweepPointClusterWasModified=!0);let s=this.getClusterEventQNode(e);if(-1===s){const t=this.getClusterFirstVertex(e);if(s=this.m_eventQ.addUniqueElement(t),-1===s){const t=this.m_eventQ.getDuplicateElement(),s=this.m_eventQ.getElement(t),i=this.getClusterFromVertex(s);this.mergeClusters_(i,e)}else this.setClusterEventQNode_(e,s)}}this.m_modifiedClusters.length=0}getClusterXY(t){const e=this.getClusterFirstVertex(t);return this.m_shape.getXY(e)}getClusterFirstVertex(t){const e=this.getClusterVertices(t);return this.m_clusterVertices.getFirstElement(e)}dbgCheckEdge_(t){}dbgCheckCluster_(t){}dbgCheckNewEdgesArray_(){}dbgSaveSweepStructure_(t){}sweepImpl_(){this.progress_(!0),this.m_bSweepPointClusterWasModified=!1,this.m_sweepPointCluster=-1,null===this.m_sweepComparator&&(this.m_sweepStructure.disableBalancing(),this.m_sweepComparator=new q(this),this.m_sweepStructure.setComparator(this.m_sweepComparator));const t=[];let e=null,s=null;this.m_prevNeighbour=-1,this.m_nextNeighbour=-1,this.m_bContinuingSegmentChainOptimization=!1;const n=i.r.impossibleIndex2(),r=i.r.impossibleIndex3();for(let i=this.m_eventQ.getFirst();-1!==i;){this.progress_(),this.dbgCheckSweepStructure_(),this.m_bContinuingSegmentChainOptimization=!1,this.m_prevNeighbour=-1,this.m_nextNeighbour=-1;const o=this.m_eventQ.getElement(i);this.m_sweepPointCluster=this.getClusterFromVertex(o),this.m_shape.queryXY(o,this.m_sweepPoint),this.m_sweepComparator.setSweepY(this.m_sweepPoint.y,this.m_sweepPoint.x);let a=!1;{const e=this.getClusterFirstEdge(this.m_sweepPointCluster);if(a=-1===e,!a){let s=e;do{const e=this.getEdgeSweepNode(s);-1===e?(this.m_edgesToInsertInSweepStructure.push(s),this.setEdgeSweepNode_(s,r)):e!==r&&t.push(e),s=this.getNextEdge(s,this.m_sweepPointCluster)}while(s!==e)}}if(!this.m_sweepStructure.isAutoBalancing()&&(this.m_sweepStructure.getMaxDepthEver()>4||this.m_edgesToInsertInSweepStructure.length>10)&&this.m_sweepStructure.enableBalancing(),t.length>0){this.m_bContinuingSegmentChainOptimization=1===t.length&&1===this.m_edgesToInsertInSweepStructure.length;for(let e=0,s=t.length;e<s;e++){const s=this.m_sweepStructure.getElement(t[e]);this.setEdgeSweepNode_(s,n)}let e=n,s=n;for(let i=0,r=t.length;i<r;i++){const r=t[i];if(e===n){const t=this.m_sweepStructure.getPrev(r);if(-1!==t){const s=this.m_sweepStructure.getElement(t);this.getEdgeSweepNode(s)!==n&&(e=t)}else e=-1}if(s===n){const t=this.m_sweepStructure.getNext(r);if(-1!==t){const e=this.m_sweepStructure.getElement(t);this.getEdgeSweepNode(e)!==n&&(s=t)}else s=-1}if(e!==n&&s!==n)break}for(let e=0,s=t.length;e<s;e++){const s=t[e],i=this.m_sweepStructure.getElement(s);this.m_sweepStructure.deleteNode(s),this.setEdgeSweepNode_(i,-1)}t.length=0,this.m_prevNeighbour=e,this.m_nextNeighbour=s,-1!==e&&-1!==s?this.m_bContinuingSegmentChainOptimization||this.checkAndFixIntersection_(e,s):-1===e&&-1===s&&(this.m_bContinuingSegmentChainOptimization=!1)}else a&&(null===e&&(e=new F(this)),e.setPoint(this.m_sweepPoint),this.m_sweepStructure.searchUpperBound(e),e.intersectionDetected()&&(e.clearIntersectionDetectedFlag(),this.fixIntersectionPointSegment_(this.m_sweepPointCluster,e.getCurrentNode())));const h=this.m_bContinuingSegmentChainOptimization;!this.insertNewEdges_()&&h&&-1!==this.m_prevNeighbour&&-1!==this.m_nextNeighbour&&this.checkAndFixIntersection_(this.m_prevNeighbour,this.m_nextNeighbour),this.m_bSweepPointClusterWasModified?(this.m_bSweepPointClusterWasModified=!1,null===s&&(s=new R(this.m_shape)),s.setPoint(this.m_sweepPoint),i=this.m_eventQ.searchUpperBound(s)):i=this.m_eventQ.getNext(i)}return this.m_bCracked}setEditShape_(t){this.m_shape=t,this.m_vertexClusterIndex=this.m_shape.createUserIndex(),this.m_edges.setCapacity(t.getSelectedCount()+32),this.m_clusters.setCapacity(t.getSelectedCount()),this.m_clusterVertices.reserveLists(t.getSelectedCount()),this.m_clusterVertices.reserveNodes(t.getSelectedCount()),this.m_edgeVertices.reserveLists(t.getSelectedCount()+32),this.m_edgeVertices.reserveNodes(t.getSelectedCount()+32);for(let e=this.m_shape.getFirstGeometry();e!==i.n;e=this.m_shape.getNextGeometry(e))if((0,n.f)(this.m_shape.getGeometryType(e)))for(let s=this.m_shape.getFirstPath(e);s!==i.n;s=this.m_shape.getNextPath(s)){const e=this.m_shape.getPathSize(s),n=this.m_shape.getFirstVertex(s);if(n===i.n)continue;let r=this.m_shape.getNextVertex(n);if(r===i.n||r===n)continue;let o=-1;t.selected(n)&&(o=this.newCluster_(n));let a=-1;-1!==o&&t.selected(r)&&(a=this.newEdge_(n),this.addEdgeToCluster(a,o));let h=a;for(let t=0,s=e-2;t<s;t++){const t=this.m_shape.getNextVertex(r);let e=-1;if(this.m_shape.selected(r)){const s=this.newCluster_(r);-1!==h&&this.addEdgeToCluster(h,s),this.m_shape.selected(t)&&(e=this.newEdge_(r),this.addEdgeToCluster(e,s))}h=e,r=t}if(this.m_shape.isClosedPath(s)){const t=this.m_shape.getNextVertex(r);if(this.m_shape.selected(r)){const e=this.newCluster_(r);if(-1!==h&&this.addEdgeToCluster(h,e),this.m_shape.selected(t)){const t=this.newEdge_(r);this.addEdgeToCluster(t,e),this.addEdgeToCluster(t,o)}}}else{let t=-1;this.m_shape.selected(r)&&(t=this.newCluster_(r),-1!==h&&this.addEdgeToCluster(h,t))}}else for(let t=this.m_shape.getFirstPath(e);t!==i.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let s=0,i=this.m_shape.getPathSize(t);s<i;s++)this.m_shape.selected(e)&&this.newCluster_(e),e=this.m_shape.getNextVertex(e)}this.fillEventQueue()}progress_(t=!1){}dbgCheckSweepStructure_(){}}function X(t){for(let e=t.getFirstGeometry();e!==i.n;e=t.getNextGeometry(e))if((0,n.f)(t.getGeometryType(e)))return!0;return!1}function k(t,e,s,i,n){if(!X(e))return!1;let o=new L(n);if(o.m_shape=e,o.m_tolerance=s,o.m_bAllowCoincident=t,o.m_bNeedsNonSimpleResult=null!==i,o.needsCrackingImpl_())return i&&i.assign(o.m_nonSimpleResult),!0;const a=new r.T;a.setSwapCoordinates(),e.applyTransformation(a),o=new L(n),o.m_shape=e,o.m_tolerance=s,o.m_bAllowCoincident=t,o.m_bNeedsNonSimpleResult=null!==i;const h=o.needsCrackingImpl_();return e.applyTransformation(a),!!h&&(i&&i.assign(o.m_nonSimpleResult),!0)}function H(t,e,s,i){const r=e.getGeometryType();if((0,n.f)(r))return new L(i).crackAWithBMultiPath_(t,e,s);(0,n.a)("crack_A_with_B")}function B(t,e){return{t,index:e}}class L{crackBruteForce_(){let t=this.crackBruteForceImpl_();if(!t&&this.m_shape.hasCurves()){const e=new r.T;e.setSwapCoordinates(),this.m_shape.applyTransformation(e),t=this.crackBruteForceImpl_(),this.m_shape.applyTransformation(e)}return t}crackBruteForceImpl_(){let t=!1;const e=new i.S,s=new i.S,r=i.a.constructEmpty(),o=i.a.constructEmpty(),a=!1,h=new i.P,m=new I,l=this.m_shape.getTotalPointCount(),u=l*l*2,c=this.m_shape.queryVertexIteratorOnSelection();for(let l=c.next();l!==i.n;l=c.next()){const g=this.m_shape.getGeometryType(c.currentGeometry());let _=1,d=1,p=1,f=0,x=0,y=0;const P=this.m_shape.getSegmentParentage(l);let E=!1,C=!1,v=null,b=!1;if((0,n.h)(g))_=this.m_shape.getWeight(l),f=this.m_shape.getRank(l);else{if(v=this.getSegment_(l,e),null===v)continue;const t=this.m_shape.getVertexIndex(l);_=this.m_shape.getWeightWithIndex(t),f=this.m_shape.getRankWithIndex(t),p=this.m_shape.getSegmentWeightWithIndex(t),y=this.m_shape.getSegmentRankWithIndex(t),E=this.m_shape.getSegmentParentageBreakVertex(l);{const t=this.m_shape.getNextVertex(l);d=this.m_shape.getWeight(t),x=this.m_shape.getRank(t),C=this.m_shape.getSegmentParentageBreakVertex(t)}if(v.queryLooseEnvelope(r),r.inflateCoords(this.m_tolerance,this.m_tolerance),v.isDegenerate(this.m_tolerance)){if(!v.isDegenerate(0))continue;b=!0,v=null}}const S=new i.al({copy:c});let I=S.next();I!==i.n&&(I=S.next());let w=0;for(;I!==i.n;I=S.next()){if(0!==w){w--;continue}if(this.m_shape.getTotalPointCount()>u)return t;this.progress_();const g=this.m_shape.getGeometryType(S.currentGeometry());let D=null,T=!1,N=0,A=0,M=0,G=0,q=0,F=0,V=!1,R=!1;const Y=this.m_shape.getSegmentParentage(I);if((0,n.h)(g))N=this.m_shape.getWeight(I),G=this.m_shape.getRank(I);else{if(D=this.getSegment_(I,s),null===D)continue;const t=this.m_shape.getVertexIndex(I);N=this.m_shape.getWeightWithIndex(t),G=this.m_shape.getRankWithIndex(t),M=this.m_shape.getSegmentWeightWithIndex(t),F=this.m_shape.getSegmentRankWithIndex(t),V=this.m_shape.getSegmentParentageBreakVertex(I);{const t=this.m_shape.getNextVertex(I);A=this.m_shape.getWeight(t),q=this.m_shape.getRank(t),R=this.m_shape.getSegmentParentageBreakVertex(t)}if(D.queryLooseEnvelope(o),D.isDegenerate(this.m_tolerance)){if(!D.isDegenerate(0))continue;T=!0,D=null}}let X=0,k=0;if(null!==v&&null!==D)r.isIntersectingNe(o)&&0!==(0,i.am)(!0,!0,v,D,this.m_tolerance,!0)&&(m.pushSegment(v,_,f,d,x,p,y,E,C,P),m.pushSegment(D,N,G,A,q,M,F,V,R,Y),m.intersect2D(this.m_tolerance,!0),t||=m.getSegmentChanged(0)||m.getSegmentChanged(1),X=m.getResultSegmentCount(0),k=m.getResultSegmentCount(1),X+k>0&&(this.m_shape.splitSegmentWithIntersector(l,m,0,!0,!0),this.m_shape.splitSegmentWithIntersector(I,m,1,!0,!0),this.m_bTrackChanges&&(m.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(l,!0),m.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(I,!0))),k>1&&(w+=k-1),m.clear());else if(null!==v){const e=this.m_shape.getXY(I);if(r.contains(e)){if(m.pushSegment(v,_,f,d,x,p,y,E,C,P),this.m_shape.queryPoint(I,h),m.intersect2DEx(this.m_tolerance,h,G,N,a),t||=m.getSegmentChanged(0)||m.getResultPointChanged(),X=m.getResultSegmentCount(0),X>0)if(this.m_bTrackChanges&&(m.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(l,!0),m.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(I,!0)),this.m_shape.splitSegmentWithIntersector(l,m,0,!0,!0),T){let t=i.n;for(let e=this.m_shape.getNextVertex(I);e!==i.n&&e!==I&&(D=this.getSegment_(e,s),t=e,null!=D&&D.isDegenerate(0));e=this.m_shape.getNextVertex(e));for(let e=I;e!==i.n&&(this.m_shape.setPoint(e,m.getResultPoint(),!0),e!==t);e=this.m_shape.getNextVertex(e));}else this.m_shape.setPoint(I,m.getResultPoint(),!0);m.clear()}}else{if(null===D)continue;{const e=this.m_shape.getXY(l);if(o.inflateCoords(this.m_tolerance,this.m_tolerance),o.contains(e)){if(m.pushSegment(D,N,G,A,q,M,F,V,R,Y),this.m_shape.queryPoint(l,h),m.intersect2DEx(this.m_tolerance,h,f,_,a),t||=m.getSegmentChanged(0)||m.getResultPointChanged(),k=m.getResultSegmentCount(0),k>0)if(this.m_bTrackChanges&&(m.getSegmentChanged(0)&&this.m_shape.setGeometryModifiedWithVertex(I,!0),m.getSegmentChanged(1)&&this.m_shape.setGeometryModifiedWithVertex(l,!0)),this.m_shape.splitSegmentWithIntersector(I,m,0,!0,!0),w+=k-1,b){let t=i.n;for(let e=this.m_shape.getNextVertex(l);e!==i.n&&e!==l&&(D=this.getSegment_(e,s),t=e,null!=D&&D.isDegenerate(0));e=this.m_shape.getNextVertex(e));for(let e=l;e!==i.n&&(this.m_shape.setPoint(e,m.getResultPoint(),!0),e!==t);e=this.m_shape.getNextVertex(e));}else this.m_shape.setPoint(l,m.getResultPoint(),!0);m.clear()}}}if(X+k!==0&&0!==X){let t=!1;for(;v=this.getSegment_(l,e),null!=v&&(v.queryEnvelope(r),v.isDegenerate(this.m_tolerance));){if(!(X>1)){t=!0;break}l=c.next(),X--,(0,n.g)(l!==i.n)}if(t)break}}}return t}crackerPlaneSweep_(){return this.planesweep_()}planesweep_(){return new Y(this.m_progressTracker,this.m_bTrackChanges).sweep(this.m_shape,this.m_tolerance)}needsCrackingImpl_(){let t=!1;const e=new i.A(0);e.resize(this.m_shape.getSelectedCount());const s=this.m_shape.queryVertexIteratorOnSelection();for(let t=0,n=s.next();n!==i.n;++t,n=s.next())e.write(t,n);this.m_shape.sortVerticesSimpleByY(e,0,e.size()),e.add(i.n);const o=this.m_shape.createUserIndex(),h=this.m_shape.createUserIndex();this.m_sweepComparator=new f(this.m_shape,this.m_tolerance,!this.m_bAllowCoincident),this.m_sweepStructure.setComparator(this.m_sweepComparator);let m=null;const l=[],u=[];let c=0;const g=new r.P;for(let s=e.read(c++);s!==i.n;){this.m_shape.queryXY(s,g);let _=!1;do{let t=this.m_shape.getNextVertex(s),n=this.m_shape.getPrevVertex(s);_||=t!==i.n||n!==i.n,t===i.n||this.m_shape.selected(t)||(t=i.n),n===i.n||this.m_shape.selected(n)||(n=i.n),t!==i.n&&this.m_shape.compareVerticesSimpleY(s,t)<0&&(u.push(s),u.push(t)),n!==i.n&&this.m_shape.compareVerticesSimpleY(s,n)<0&&(u.push(n),u.push(n));const r=this.m_shape.getUserIndex(s,o);-1!==r&&(l.push(r),this.m_shape.setUserIndex(s,o,-1));const a=this.m_shape.getUserIndex(s,h);-1!==a&&(l.push(a),this.m_shape.setUserIndex(s,h,-1)),s=e.read(c++)}while(s!==i.n&&this.m_shape.isEqualXYPoint2D(s,g));if(!_&&(null===m&&(m=new x(this.m_shape,this.m_tolerance)),m.setPoint(g),this.m_sweepStructure.searchUpperBound(m),m.intersectionDetected())){t=!0,this.m_bNeedsNonSimpleResult&&((0,n.b)("needsCrackingIMpl_"),this.m_nonSimpleResult=new a(6,-1,-1));break}let d=1===l.length&&2===u.length;const p=32;l.length>p&&(0,r.n)(l);let f=-1,y=-1;if(!d)for(let e=0,s=l.length;e<s;e++){const s=l[e],i=this.m_sweepStructure.getPrev(s);if(-1!==i&&-1===l.indexOf(i))if(-1===f)f=i;else{if(t=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new a(6,-1,-1)}const n=this.m_sweepStructure.getNext(s);if(-1!==n&&-1===l.indexOf(n))if(-1===y)y=n;else{if(t=!0,!this.m_bNeedsNonSimpleResult)break;this.m_nonSimpleResult=new a(6,-1,-1)}if(-1!==f&&-1!==y)break}if(t&&!this.m_bNeedsNonSimpleResult)break;if(this.m_sweepComparator.setSweepY(g.y,g.x),!d){for(let t=0,e=l.length;t<e;t++){const e=l[t];this.m_sweepStructure.deleteNode(e)}l.length=0}if(!d&&-1!==f&&-1!==y&&this.checkForIntersections_(f,y)){t=!0,this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult());break}for(let e=0,s=u.length;e<s;e+=2){const s=u[e],i=u[e+1];let n;if(d?(n=this.m_sweepStructure.replaceElementAtPosition(l[0],s,!0,!0),l.length=0,d=!1):n=this.m_sweepStructure.addElement(s),this.m_sweepComparator.intersectionDetected()){this.m_bNeedsNonSimpleResult&&(this.m_nonSimpleResult=this.m_sweepComparator.getResult()),t=!0;break}-1===this.m_shape.getUserIndex(i,o)?this.m_shape.setUserIndex(i,o,n):this.m_shape.setUserIndex(i,h,n)}if(t)break;u.length=0}return this.m_shape.removeUserIndex(o),this.m_shape.removeUserIndex(h),t}checkForIntersections_(t,e){const s=this.m_sweepStructure.getElement(t);this.m_sweepComparator.compare(this.m_sweepStructure,s,e);const i=this.m_sweepComparator.intersectionDetected();return this.m_sweepComparator.clearIntersectionDetectedFlag(),i}getSegment_(t,e){return L.st_getSegment(this.m_shape,t,e)}static st_getSegment(t,e,s){return t.querySegment(e,s,!1,!1)?s.get():null}dbgPrintSweepEdge(t){}dbgPrintSweepStructure(){}dbgSaveSweepStructure(t=null){}dbgCheckSweepStructure(){}progress_(t=!1){this.m_progressCounter++}crackAWithBMultiPath_(t,e,s){const r=i.a.constructEmpty();t.queryLooseEnvelope(r);const o=i.a.constructEmpty();if(e.queryLooseEnvelope(o),o.inflateCoords(s,s),!o.isIntersecting(r))return t;const a=t.getImpl(),h=a.getAccelerators();let m=null,l=null;h&&(l=h.getQuadTree()),function(t,e){const s=t.getPointCount();if(s<16)return!1;return 2*s+Math.log(s)/Math.log(2)*1*e<1*s*e}(t,(0,n.v)(e))&&(m=(0,i.ac)(a,o),l=m);const u=l?l.getIteratorForQT():null,c=e.querySegmentIterator(),g=t.querySegmentIterator(),_=new Array(15),d=[];for(;c.nextPath();)for(;c.hasNextSegment();){const t=c.nextSegment();if(l){u.resetIterator(t,s);for(let e=u.next();-1!==e;e=u.next()){this.progress_();const i=l.getElement(e);if(g.resetToVertex(i,-1),g.hasNextSegment()){const e=g.nextSegment().intersect(t,null,_,null,s);for(let t=0;t<e;t++){const e=_[t];if(0===e||1===e)continue;const s=B(e,g.getStartPointIndex());d.push(s)}}}}else{const e=i.a.constructEmpty();if(t.queryLooseEnvelope(e),e.inflateCoords(s,s),!r.isIntersecting(e))continue;for(g.resetToFirstPath();g.nextPath();)for(;g.hasNextSegment();){const n=g.nextSegment(),r=i.a.constructEmpty();if(n.queryLooseEnvelope(r),!r.isIntersecting(e))continue;const o=n.intersect(t,null,_,null,s);for(let t=0;t<o;t++){const e=_[t];if(0===e||1===e)continue;const s=B(e,g.getStartPointIndex());d.push(s)}}}}if(0===d.length)return t;d.sort(((t,e)=>t.index<e.index?-1:t.index>e.index?1:t.t<e.t?-1:t.t>e.t?1:0));const p=t.createInstance();for(p.getGeometryType()===n.G.enumPolygon&&p.setFillRule(t.getFillRule()),g.resetToFirstPath();g.nextPath()&&!g.hasNextSegment(););(0,n.g)(g.hasNextSegment());let f=g.nextSegment();const x=new i.S;let y=-1;for(let t=0,e=d.length;t<e;){const s=d[t].index;let i=t+1;for(;i<e&&d[i].index===s;)++i;for(;g.getStartPointIndex()<s;){this.progress_();const t=g.hasNextSegment(),e=g.getPathIndex();if((t||!g.isClosingSegment()||g.isCurve())&&((0,n.g)(null!==f),p.addSegment(f,y!==e)),y=e,!t){for(g.isPathClosed();g.nextPath()&&!g.hasNextSegment(););(0,n.g)(g.hasNextSegment())}f=g.nextSegment()}let r=0;for(let e=t;e<i;e++){const t=d[e].t;if(t===r)continue;(0,n.g)(null!==f),f.queryCut(r,t,x),r=t;const s=g.getPathIndex();p.addSegment(x.get(),y!==s),y=s}const o=g.hasNextSegment();if((o||!g.isClosingSegment()||g.isCurve())&&((0,n.g)(null!=f),f.queryCut(r,1,x),p.addSegment(x.get(),!1)),o)f=g.nextSegment();else{for(;g.nextPath()&&!g.hasNextSegment(););f=g.hasNextSegment()?g.nextSegment():null}t=i}if(null!==f){const t=g.getPathIndex();(g.hasNextSegment()||!g.isClosingSegment()||g.isCurve())&&p.addSegment(f,y!==t),y=t}let P=g.hasNextSegment();for(;;){if(!P){for(;g.nextPath()&&(P=g.hasNextSegment(),!P););if(!P)break}f=g.nextSegment();const t=g.getPathIndex();P=g.hasNextSegment(),(P||!g.isClosingSegment()||g.isCurve())&&p.addSegment(f,y!==t),y=t}return p}constructor(t){this.m_shape=null,this.m_progressTracker=null,this.m_nonSimpleResult=new a,this.m_tolerance=0,this.m_sweepComparator=null,this.m_progressCounter=0,this.m_bTrackChanges=!1,this.m_bNeedsNonSimpleResult=!1,this.m_bAllowCoincident=!0,this.m_sweepStructure=new i.T,this.m_progressTracker=t}}function z(){return Number.isNaN(this.radius.value())}function U(t,e,s,i){return{pt:t.clone(),t:e,err:s,checkCount:i}}L.s_bForceBruteForce=!0;class O{constructor(t,e,s,n,o){this.m_left=t,this.m_tracker=o,this.m_eps=s,this.m_trackerCounter=0,this.m_tolerance=n,this.m_circleCheckCounter=0,this.m_bReversedLeft=!1,this.m_leftArc={ptStart:new r.P,ptEnd:new r.P,center:new i.ap,radius:new r.H,fcenter:new i.ao,fradius2:new r.M,maxError:Number.NaN,isLine:z}}closeToCircularArc(t,e,s,n,o,a){if(this.m_circleCheckCounter++,a.maxError=0,!O.checkSweepAngle(t,e))return!1;if(a.ptStart.setCoordsPoint2D(s),a.ptEnd.setCoordsPoint2D(o),t.isCircular()){const e=t;return a.fradius2=r.M.constructDouble(e.getSemiMajorAxis()).mulDouble(e.getSemiMajorAxis()),a.radius.set(e.getSemiMajorAxis()),a.fcenter.assignPoint2D(e.getCenter()),a.center.set(e.getCenter()),!0}const h=a.ptEnd.sub(a.ptStart).clone();if(h.leftPerpendicularThis(),h.normalize(),Math.abs(h.dotProduct(n.sub(a.ptStart)))<=this.m_eps)return!!this.confirmIsLine(a,h)&&(a.radius.set(Number.NaN),a.center.setCoords(0,0),!0);{const s=a.ptEnd.sub(a.ptStart),i=n.sub(a.ptStart),r=s.crossProduct(i);if(0===r)return!1;const o=.5*s.sqrLength(),h=.5*i.sqrLength();let m=o*i.y-h*s.y;m/=r;let l=s.x*h-i.x*o;l/=r;const u=Math.sqrt(m*m+l*l);if(4*Number.EPSILON*u>this.m_eps)return!1;const c=m+a.ptStart.x,g=l+a.ptStart.y;a.radius.set(u),a.center.setCoords(c,g);const _=this.maxCircleApproximationError(t,e,a);if(_>this.m_eps)return a.maxError=_,!1}const m=(new i.ao).assignPoint2D(a.ptStart),l=(new i.ao).assignPoint2D(a.ptEnd).sub(m),u=(new i.ao).assignPoint2D(n).sub(m),c=l.crossProduct(u);if(c.isZero())return!1;const g=l.sqrLength().mulDouble(.5),_=u.sqrLength().mulDouble(.5),d=g.mul(u.y).sub(_.mul(l.y)),p=l.x.mul(_).sub(u.x.mul(g)),f=d.mul(d).add(p.mul(p)),x=c.clone();x.invertThis(),a.fradius2=f.mul(x).mul(x),a.fcenter.setCoords(d.mul(x).add(m.x),p.mul(x).add(m.y)),a.center.setWithEps(a.fcenter.asPoint2D()),a.radius.setWithEps(Math.sqrt(a.fradius2.toDouble()));const y=i.ap.constructPoint2D(a.ptStart).subE(a.center),P=i.ap.constructPoint2D(a.ptEnd).subE(a.center);if(!y.dotProduct(P).gt(r.C))return!1;const E=this.maxCircleApproximationError(t,e,a);return a.maxError=E,E<=this.m_eps}static checkSweepAngle(t,e){if(t.getGeometryType()===n.G.enumEllipticArc){const s=t,n=(0,i.aq)(s,e.vmin),o=(0,i.aq)(s,e.vmax);return!(Math.abs(o-n)>.5*r.q)}return!0}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],o=[.1,.25,.75,.9];let a,h;t.getGeometryType()===n.G.enumEllipticArc?(a=i,h=i.length):(a=o,h=o.length);let m=0;for(let i=0;i<h;++i){const n=new r.P;t.queryCoord2D((0,r.w)(e.vmin,e.vmax,a[i]),n);const o=n.sub(s.center.value()).length(),h=Math.abs(o-s.radius.value());h>m&&(m=h)}return m}approximateWithCirclesImpl(t,e){let s=1;e&&e.push(0);const i=(0,r.a)(9,Number.NaN);let n;t?n=this.m_left.getMonotonicPartParams(i.length,i):(i[0]=0,i[1]=1,n=2);const o=[],a=[],h=new r.P(0,0);for(let t=1;t<n;t++){const n=new r.E(i[t-1],i[t]);for(this.m_bReversedLeft=!O.goodOrientation(this.m_left,n),this.m_bReversedLeft?(o.push(U(h,n.vmin,0,0)),o.push(U(h,n.vmax,0,0))):(o.push(U(h,n.vmax,0,0)),o.push(U(h,n.vmin,0,0))),o[0].pt=this.m_left.getCoord2D(o[0].t),o[1].pt=this.m_left.getCoord2D(o[1].t);o.length>1;){this.progress_();const t=o.at(-1);let i=t.checkCount,n=t.err;const h=t.pt.clone(),m=t.t,l=o[o.length-2].t,u=.5*(m+l),c=this.m_left.getCoord2D(u);if(n<=this.m_eps||i>=5){const t=new r.E;if(t.setCoords(m,l),this.closeToCircularArc(this.m_left,t,h,c,o[o.length-2].pt,this.m_leftArc)){e&&(this.m_bReversedLeft?a.push(m):e.push(l)),s++,o.pop();continue}i=0,n=this.m_leftArc.maxError}t.t=u,t.pt.setCoordsPoint2D(c),n*=.125,i++,t.err=n,t.checkCount=i,o.push(U(h,m,n,i))}this.m_bReversedLeft&&e&&(e.length=e.length+a.length,(0,r.D)(e,a.reverse(),e.length-a.length,0,a.length),a.length=0),o.length=0}return s}approximateWithCirclesImplPolyline(t){const e=new i.i,s=[];if(!this.approximateWithCirclesImpl(!0,s))return e;let n=0;const o=this.m_left.getStartXY();e.startPath(o);for(let a=1;a<s.length;++a)if(t)e.lineTo(this.m_left.getCoord2D(s[a]));else{const t=new r.P;this.m_left.queryCoord2D(s[a],t);const h=new r.P;this.m_left.queryCoord2D(.5*(s[a]+n),h);const m=new i.a3;m.constructCircularArcThreePoint(o,t,h),e.addSegment(m,!1),o.assign(t),n=s[a]}return e}static goodOrientation(t,e){const s=t.getCoord2D(e.vmin),i=t.getCoord2D(e.vmax);return s.compare(i)<0}progress_(t=!1){}}function W(t,e,s,i,n,r,o){!function(t,e,s,i,n,r){t.hasCurves()?(t.setCurveStitcherPointer(i),i.m_impl=new $(r,!1,null),i.m_impl.buildMonotonicCurveParentage(t,e,s,n)):i.m_impl=null}(t,e,s,n,r,o)}function j(t,e,s,i,n,r,o,a){t.hasCurves()?(t.setCurveStitcherPointer(r),r.m_impl=new $(a,!0,n),r.m_impl.buildMonotonicCurveParentage(t,e,s,o),function(t,e,s){nt.fixCurveTwoPointLoops(t,e,s)}(t,s,a)):r.m_impl=null}function Z(t,e){return e||(e=i.a.constructEmpty()),function(t,e){let s=e.isEmpty()?t:(0,i.b)(null,e,!0).total();return s>t&&(s=t),.125*s}(t,e)}function Q(t,e){return.125*t}function K(t,e){return 3*t+3*e}class J{constructor(){this.m_impl=null}stitchCurves(t,e,s,i){this.m_impl&&(this.m_impl.stitchCurves(t,e,s),i&&this.clearStitcher(t))}clearStitcher(t){this.m_impl&&(this.m_impl.clearStitcher(t),this.m_impl=null)}getOriginalVertexIndex(t,e){return this.m_impl.getOriginalVertexIndex(t,e)}getOriginalSegmentTypeInfo(t){return this.m_impl.getOriginalSegmentTypeInfo(t)}}class ${constructor(t,e,s){this.m_originalPlanarSegments=[],this.m_progressTracker=null,this.m_nsr=null,this.m_progressTracker=t,this.m_nsr=s,this.m_tolerance=0,this.m_originalVertexIndex=-1,this.m_type=0,this.m_progressCounter=0,this.m_bIsSimple=e}buildMonotonicCurveParentage(t,e,s,r){const o=!1;if(!t.hasCurves())return;(0,n.g)(!t.hasSegmentParentage()),this.m_type=1,this.m_originalPlanarSegments.length=0,this.m_bIsSimple&&(this.m_originalVertexIndex=t.createUserIndex()),this.m_tolerance=s;const h=new i.P,m=new i.S,l=[],u=[],c=[];for(let r=t.getFirstGeometry();r!==i.n;r=t.getNextGeometry(r))for(let g=t.getFirstPath(r);g!==i.n;g=t.getNextPath(g)){let r=t.getPathSize(g),_=t.getFirstVertex(g),d=0,p=-1;for(let f=0;f<r;f++){let x=t.getNextVertex(_);if(!t.querySegment(_,m,!0,!1)){_=x;continue}if(0===d){p=t.getVertexIndex(_);const e=$.regularizeCurve(t,m.get(),_,s);if(e>=0){this.m_nsr&&0===this.m_nsr.m_reason&&this.m_nsr.assign(new a(13,p,-1)),d=e,r=t.getPathSize(g),x=t.getNextVertex(_);const s=t.querySegment(_,m,!0,!1);(0,n.g)(s)}}else d--;const y=t.getVertexIndex(_);let P;-1!==this.m_originalVertexIndex&&t.setUserIndex(_,this.m_originalVertexIndex,p),t.setSegmentToIndex(y,null);let E=!1;switch(m.get().getGeometryType()){case n.G.enumEllipticArc:case n.G.enumRationalBezier2:P=(0,i.ae)(m.get(),e,s,o,!0,u,c,l),E=!0;break;default:{const t=!this.m_bIsSimple||!m.get().isMonotoneQuickAndDirty();P=(0,i.ad)(m.get(),e,s,t,o,u,l)}}const C=this.m_originalPlanarSegments.length;if(t.setSegmentParentageAndBreak(_,C,!0),!u[1].isNAN()){let e=null;e=E?new i.ag({points:u,weights:c}):new i.af({cp:u}),e.snapControlPoints(s*s),t.setSegmentToIndex(y,e)}const v=E?2:3;for(let e=1,n=P,r=v;e<n;++e,r+=v){m.get().queryCoord(l[e],h);const n=t.insertVertex(g,x,h);if(-1!==this.m_originalVertexIndex&&t.setUserIndex(n,this.m_originalVertexIndex,p),!u[r+1].isNAN())if(E){const e=new i.ag({points:u.slice(r),weights:c.slice(r)});e.snapControlPoints(s*s),t.setSegmentToIndex(t.getVertexIndex(n),e)}else{const e=new i.af({cp:u.slice(r)});e.snapControlPoints(s*s),t.setSegmentToIndex(t.getVertexIndex(n),e)}t.setSegmentParentageAndBreak(n,C,!1)}P>1&&(f+=P-1,r=t.getPathSize(g)),this.m_originalPlanarSegments.push(m.releaseSegment()),_=x}}}stitchCurves(t,e,s){$.st_stitchCurvesImpl(this,t,e,s,!1)}clearStitcher(t){this.m_originalPlanarSegments.length=0,-1!==this.m_originalVertexIndex&&(t.removeUserIndex(this.m_originalVertexIndex),this.m_originalVertexIndex=-1),t.deleteSegmentParentage()}static st_verifyParentage(t){$.st_stitchCurvesImpl(null,t,i.n,0,!0)}getOriginalVertexIndex(t,e){return-1!==this.m_originalVertexIndex&&e!==i.n?t.getUserIndex(e,this.m_originalVertexIndex):-1}getOriginalSegmentTypeInfo(t){if(-1!==t){const e=this.m_originalPlanarSegments[t];switch(e.getGeometryType()){case n.G.enumEllipticArc:return 0===e.projectionBehavior()?0:1;case n.G.enumBezier:return 2;case n.G.enumBezier2:return 3;case n.G.enumLine:return-1;case n.G.enumRationalBezier2:return 4;default:(0,n.a)("")}}return-1}progress_(t=!1){this.m_progressCounter++}processSpan_(t,e,s,r,o,a,h){if(e===s&&0===r)return(0,n.g)(t.getNextVertex(e)===i.n),t.setSegmentToIndex(t.getVertexIndex(e),null),void t.setSegmentParentageAndBreak(e,-1);const m=t.getNextVertex(e);{let e=2;for(let i=m;i!==s;i=t.getNextVertex(i))e++;(0,n.g)(e===r)}if(null===o){t.setSegmentToIndex(t.getVertexIndex(e),null);for(let e=m;e!==s;)e=t.removeVertex(e,!0);return}const l=t.getXY(e),u=t.getXY(s);if(o.isClosed()){if(l.isEqualPoint2D(u)&&l.isEqualPoint2D(o.getStartXY())){let i;if(i=this.verifySegmentFitness(t,e,s,r,o,a,h)){const n=o.clone();return n.dropAllAttributes(),i<0&&n.reverse(),this.removeSpan(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),n)}}}else if(l.isEqualPoint2D(o.getStartXY())){if(u.isEqualPoint2D(o.getEndXY())){const i=o.clone();if(i.dropAllAttributes(),this.verifySegmentFitness(t,e,s,r,i,a,h))return this.removeSpan(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),i)}}else if(u.isEqualPoint2D(o.getStartXY())&&l.isEqualPoint2D(o.getEndXY())){const i=o.getReversed();if(i.dropAllAttributes(),this.verifySegmentFitness(t,e,s,r,i,a,h))return this.removeSpan(t,e,s),void t.setSegmentToIndex(t.getVertexIndex(e),i)}this.processSpanSplitSegment(t,e,s,r,o,a,h)}processSpanSplitSegment(t,e,s,i,n,o,a){if(n.isLine())return;if(this.fitSegmentToSpan(t,e,s,i,n,o,a))return;const h=a*a;let m=i,l=e;const u=t.getXY(e);let c=n.getClosestCoordinate(u,!1);const g=n.getCoord2D(c);let _=!1;const d=r.P.sqrDistance(u,g);if(d>h){const i=t.getNextVertex(e);if(this.approximateSpanSection(t,e,n,o,a),i===s)return;l=i,_=!0,m-=1}let p=s;const f=t.getXY(s);c=n.getClosestCoordinate(f,!1);const x=n.getCoord2D(c);let y=!1;const P=r.P.sqrDistance(f,x);if(P>h){const e=t.getPrevVertex(s);if(this.approximateSpanSection(t,e,n,o,a),e===l)return;p=e,y=!0,m-=1}if((_||y)&&this.fitSegmentToSpan(t,l,p,m,n,o,a))return;let E=!1;if(!_&&d>0){const s=t.getNextVertex(e);if(this.approximateSpanSection(t,e,n,o,a),s===p)return;l=s,_=!0,E=!0,m-=1}if(!y&&P>0){const e=t.getPrevVertex(s);if(this.approximateSpanSection(t,e,n,o,a),e===l)return;p=e,y=!0,E=!0,m-=1}if(E&&this.fitSegmentToSpan(t,l,p,m,n,o,a))return;let C=l;for(;;){const e=t.getNextVertex(C);if(this.approximateSpanSection(t,C,n,o,a),C=e,C===p)return}}fitSegmentToSpan(t,e,s,o,a,h,m){const l=0===this.m_type,u=[];if(u.push(t.getXY(e)),l){let i=e;const r=32;if(o>r){const e=BigInt(o-1),a=BigInt(r-1);let h=a,m=0n;for(let s=1;s<o;s++,h+=a)if(i=t.getNextVertex(i),h>=m+e){m+=e;const s=t.getXY(i);u.push(s)}(0,n.g)(i===s)}else{for(let e=1;e<o;e++){i=t.getNextVertex(i);const e=t.getXY(i);u.push(e)}(0,n.g)(i===s)}}else{let n=e;const r=new i.S;for(;;){t.querySegment(n,r,!1,!0);const e=[.1,.25,.4,.5,.6,.75,.9,1];let i=0;for(const t of e)(2===o||1&i)&&u.push(r.get().getCoord2D(t)),i++;if(n=t.getNextVertex(n),n===s)break}}const c=(()=>{let t=u[0].compare(u.at(-1));if(0===t){const e=new r.K(0);(function(t,e,s){if(s.reset(),e<3)return;const i=t[0].clone(),n=i.x,o=i.y,a=t[1].clone(),h=new r.P;for(let n=2;n<e;n++)h.assign(t[n]),s.pe((h.x-i.x)*(a.y-o)),i.assign(a),a.assign(h);s.pe((n-i.x)*(a.y-o))})(u,u.length,e),t=e.getResult()>=0?-1:1}return t>0})();c&&u.reverse();const g=a.clone();if(g.dropAllAttributes(),g.setSegmentFromCoords(u,u.length),c&&g.reverse(),g.snapControlPoints(this.m_tolerance*this.m_tolerance),this.verifySegmentFitness(t,e,s,o,g,h,m)){this.removeSpan(t,e,s);const i=t.getVertexIndex(e);return t.setSegmentToIndex(i,g),!0}return!1}approximateSpanSection(t,e,s,o,a){const h=new i.S;if(!t.querySegment(e,h,!0,!1))return;const m=s.getGeometryType();if(m!==h.get().getGeometryType()){if(m===n.G.enumEllipticArc){if(h.get().getGeometryType()!==n.G.enumRationalBezier2)return;if(0===s.projectionBehavior()){const s=[];!function(t,e,s,n,r){const o=(0,i.an)(e),a=Math.max(4*o,s);new O(e,null,a,Number.NaN,r).approximateWithCirclesImpl(!1,n)}(0,h.get(),a,s,this.m_progressTracker);const n=t.getNextVertex(e),o=t.getPathFromVertex(e),m=new i.P;let l=e;for(let e=1,a=s.length;e<a;e++){const a=s[e],u=h.get().getCoord2D(s[e-1]),c=h.get().getCoord2D((0,r.w)(s[e-1],a,.5));h.get().queryCoord(a,m);const g=m.getXY(),_=new i.a3;_.constructCircularArcThreePoint(u,g,c);let d=i.n;a<1&&(d=t.insertVertex(o,n,m)),t.setSegmentToIndex(t.getVertexIndex(l),_),l=d}return}{const s=(0,r.m)(r.P,3);h.get().queryControlPoints(s);const n=[0,0,0];h.get().queryWeights(n);const o=(0,i.ah)(n),a=new i.a3;return(0,i.ai)(s,o*o,null,!1,a),void t.setSegmentToIndex(t.getVertexIndex(e),a)}}(0,n.b)("approximate_span_section_")}}verifySegmentFitness(t,e,s,i,n,r,o){return 0===this.m_type?this.verifySegmentFitnessLines(t,e,s,i,n,r,o):this.verifySegmentFitnessCurves(t,e,s,i,n,r,o)}verifySegmentFitnessCurves(t,e,s,n,o,a,h){const m=t.getXY(e),l=t.getXY(s);if(!m.isEqualPoint2D(o.getStartXY())||!l.isEqualPoint2D(o.getEndXY()))return 0;let u=0;if(o.isClosed()){const t=o.getCoord2D(.1).sub(m);u=o.getCoord2D(.7).sub(m).crossProduct(t)>=0?1:-1}const c=new Array(i.aj.s_maxMonotonicPartParams);let g=o.getMonotonicPartParams(c.length,c);g--;const _=new i.L,d=[1,.5,.75,.25];let p=0,f=e;const x=m.clone();for(;;){const e=t.getNextVertex(f);let i=t.getSegment(f);null===i&&(t.queryLineConnector(f,_,!0),i=_);for(let t=e===s?1:0;t<d.length;t++){const e=i.getCoord2D(d[t]);if(!o.isCloserThanDistance(e,r.E.unit(),h))return 0}if(g>1)for(let t=1;t<g;){const e=o.getCoord2D(c[t]);i.isCloserThanDistance(e,r.E.unit(),h)?(c[g-1]=(0,r.b)(c[t],c[t]=c[g-1]),g--):t++}if(u){const t=i.getCoord2D(.25);p+=t.sub(m).crossProduct(x.sub(m)),x.assign(t),t.assign(i.getCoord2D(.75)),p+=t.sub(m).crossProduct(x.sub(m)),x.assign(t)}if(f=e,f===s)return g>1?0:u?p<0?-u:u:1}}verifySegmentFitnessLines(t,e,s,i,r,o,a){return(0,n.g)(0),0}removeSpan(t,e,s){t.setSegmentToIndex(t.getVertexIndex(e),null);const i=t.getNextVertex(e);i!==s&&t.removeVertices(i,s)}static st_stitchCurvesImpl(t,e,s,i,n){if(e.hasSegmentParentage())return e.hasCurves()?$.st_stitchCurvesFromCurvesImpl(t,e,s,i,n):$.st_stitchCurvesFromLinesImpl(t,e,s,i,n)}static st_stitchCurvesFromLinesImpl(t,e,s,r,o){let a=s===i.n?e.getFirstGeometry():s;for(;a!==i.n;){for(let s=e.getFirstPath(a);s!==i.n;s=e.getNextPath(s)){let a=e.getPathSize(s);e.isClosedPath(s)&&(a+=1);let h=!0,m=!1;const l=e.getFirstVertex(s);let u=l;for(let s=0;s<a&&u!==i.n;){let c=e.getSegmentParentage(u);if(-1===c||h){h=!1,s++,u=e.getNextVertex(u),m=!0;continue}let g,_,d=0;if(m?(g=e.getPrevVertex(u),_=u,(0,n.g)(g!==i.n),(0,n.g)(_!==g),(0,n.g)(-1===e.getSegmentParentage(g)||l===g)):(g=u,_=e.getNextVertex(g),s++,(0,n.g)(_!==i.n),(0,n.g)(_!==g),c=e.getSegmentParentage(_)),d=2,m=!1,-1===c||e.getSegmentParentageBreakVertex(_)){u=_;continue}let p=e.getNextVertex(_);for(s++;s<a&&p!==i.n;){_=p,d++;const t=e.getSegmentParentage(p);if(-1===t||e.getSegmentParentageBreakVertex(p))break;(0,n.g)(t===c),s++,p=e.getNextVertex(p)}if(!o){const s=t.m_originalPlanarSegments[c];t.processSpan_(e,g,_,d,s,c,r)}u=_}}if(s!==i.n)break;a=e.getNextGeometry(a)}}static st_stitchCurvesFromCurvesImpl(t,e,s,r,o){let a=s===i.n?e.getFirstGeometry():s;for(;a!==i.n;)if((0,n.s)(e.getGeometryType(a))){for(let s=e.getFirstPath(a);s!==i.n;s=e.getNextPath(s)){let a=e.getPathSize(s);const h=e.isClosedPath(s);h&&(a+=1);let m=e.getFirstVertex(s);if(h){if(-1!==e.getSegmentParentage(m)){let t=m;for(let i=0;!e.getSegmentParentageBreakVertex(t);i++){if(i===a){m=e.getFirstVertex(s),e.setSegmentParentageBreakVertex(t,!0);break}t=e.getPrevVertex(t)}}}else(0,n.g)(-1===e.getSegmentParentage(m)||e.getSegmentParentageBreakVertex(m));let l=m;for(let s=0;s<a&&l!==i.n;){const h=e.getSegmentParentage(l);if(-1===h){s++,l=e.getNextVertex(l);continue}let m=0,u=i.n;const c=l;m=1;let g=e.getNextVertex(c);for(;s<a&&g!==i.n;){s++,u=g,m++;const t=e.getSegmentParentage(g);if(-1===t||e.getSegmentParentageBreakVertex(g))break;(0,n.g)(t===h),g=e.getNextVertex(g)}if(u===i.n)break;if(!o){const s=t.m_originalPlanarSegments[h];t.processSpan_(e,c,u,m,s,h,r)}l=u}}if(s!==i.n)break;a=e.getNextGeometry(a)}else a=s===i.n?e.getNextGeometry(a):i.n}static regularizeCurve(t,e,s,n){let r=e.snapControlPoints(n*n);if(r){const i=t.getVertexIndex(s),n=e.clone();t.setSegmentToIndex(i,n)}if(e.getGeometryType()===i.af.type){const i=[],o=e.calculateSpecialPointsForCracking(n,i);if(o>0){t.splitSegment(s,i,o),r=t.snapControlPoints(s,o+1,n*n)||r;for(let e=0;e<o;e++)s=t.getNextVertex(s),t.setSegmentParentageBreakVertex(s,!0);return o}}return r?0:-1}}function tt(t,e,s,i,n){return new nt(t,s,e,i,n).do_()}function et(t,e,s){const n=(0,i.l)(t);return E(e.getX(),e.getY(),s.getX(),s.getY(),(0,r.e)(n))}function st(t,e,s=1,n=1,r=1,o=1){if(n>o)return t;if(o>n)return e;const a=new i.P;return function(t,e,s,i,n,r,o,a,h){const m=t.equals(e);if(i>r)return o.assignCopy(t),h[0]=i,a[0]=s,m;if(r>i)return o=e,h[0]=r,a[0]=n,m;o.assignCopy(t);const l=C(t.getXY(),e.getXY(),s,i,n,r);o.setXY(l.pt),a[0]=l.weight,h[0]=l.rank}(t,e,s,n,r,o,a,[0],[0]),a}function it(t){return(0,i.l)(t)}class nt{constructor(t,e,s,i,n){this.m_shape=t,this.m_progressTracker=e,this.m_tolerance=s,this.m_bFilterDegenerateSegments=i,this.m_bTrackChanges=n,this.m_progressCounter=0}do_(){const t=new i.C(this.m_tolerance.tolerance,this.m_tolerance.resolution),e=it(t);let s=(0,i.v)(t);const o=1.00001*s;s*=1.000001;let a=!1;const h=this.m_shape.getTotalPointCount()+10>30?1e3:(this.m_shape.getTotalPointCount()+10)*(this.m_shape.getTotalPointCount()+10),m=this.m_shape.hasPointFeatures();for(let t=0;;t++){this.m_shape.dbgCheckSelection(),t>h&&(0,n.b)("crack_and_cluster_iteration_exceeded"),this.m_shape.dbgVerifyMonotone();let r=-1;0===t&&(r=this.firstCrack_(),a||=r>0);const l=this.cluster_(e);if(this.m_shape.dbgVerifyMonotone(),a||=l,this.m_bFilterDegenerateSegments){const t=0!==this.m_shape.filterClosePoints(e,!0,!1,this.m_bTrackChanges,i.n);a||=t,this.m_shape.dbgVerifyMonotone()}const u=this.m_shape.snapControlPointsOnSelection(o*o);a||=u,this.m_shape.dbgCheckSelection();let c=!1;if((0===t&&-1===r||m||k(!0,this.m_shape,s,null,this.m_progressTracker))&&(c=this.crack_(o),a||=c,this.m_shape.dbgVerifyMonotone()),!c&&!nt.fixCurveTwoPointLoops(this.m_shape,e,this.m_progressTracker)){this.m_shape.dbgVerifyMonotone();break}}return a&&function(t){if(!t.hasSegmentParentage())return;const e=new i.A(0),s=t.queryVertexIteratorOnSelection();for(let t=s.next();t!==i.n;t=s.next())e.add(t);if(0===e.size())return;t.sortVerticesSimpleByY(e,0,e.size()),e.add(i.n);const n=r.P.getNAN();t.queryXY(e.read(0),n);let o=0;const a=r.P.getNAN();for(let s=1,r=e.size();s<r;s++){{const n=e.read(s);n!==i.n?t.queryXY(n,a):a.setNAN()}if(!a.isEqualPoint2D(n)){let r=!1,h=-2;for(let n=o;n<s;++n){const s=e.read(n);if(t.getSegmentParentageBreakVertex(s)){r=!0;break}let o=t.getSegmentParentage(s);const a=t.getPrevVertex(s);if(a!==i.n){let e=t.getSegmentParentage(a);if(-1===o&&(o=e),-1===e&&(e=o),o!==e){r=!0;break}}if(-2!==h&&o!==h){r=!0;break}h=o}if(r)for(let i=o;i<s;++i)t.setSegmentParentageBreakVertex(e.read(i),!0);n.setCoordsPoint2D(a),o=s}}}(this.m_shape),a}cluster_(t){return P(this.m_shape,t,i.n,this.m_bTrackChanges,this.m_progressTracker)}crack_(t){return function(t,e,s,i){if(!X(t))return!1;const n=new L(i);n.m_shape=t,n.m_tolerance=e,n.m_bTrackChanges=s;let r=!1;const o=t.hasCurves()?5:15;return r=t.getTotalPointCount()<o?n.crackBruteForce_():n.crackerPlaneSweep_(),r}(this.m_shape,t,this.m_bTrackChanges,this.m_progressTracker)}static fixCurveTwoPointLoops(t,e,s){if(!t.hasCurves())return!1;t.dbgVerifyCurves();const o=t.createUserIndexUninitialized(),a=new i.A(0),h=t.queryVertexIteratorOnSelection();for(let e=h.next();e!==i.n;e=h.next())a.add(e),t.setUserIndex(e,o,-1);if(0===a.size())return!1;a.add(i.n),t.sortVerticesSimpleByY(a,0,a.size()-1);let m=0;const l=t.getXY(a.read(m)),u=new r.P(Number.NaN,Number.NaN),c=[];for(let e=1,s=a.size();e<s;++e){const s=a.read(e),n=s!==i.n?t.getXY(s):u;if(n.equals(l))continue;const h=[];for(let s=m;s<e;s++){const e=a.read(s),n=t.getPrevVertex(e);if(n!==i.n&&-1===t.getUserIndex(n,o)){const e=rt(t.getXY(n),t.getSegment(n));0!==r.P.sqrDistance(l,e.otherPt)&&(e.vert=n,e.dir=-1,h.push(e)),t.setUserIndex(n,o,1)}const m=t.getNextVertex(e);if(m!==i.n&&-1===t.getUserIndex(e,o)){const s=rt(t.getXY(m),t.getSegment(e));0!==r.P.sqrDistance(l,s.otherPt)&&(s.vert=e,s.dir=1,h.push(s)),t.setUserIndex(e,o,1)}}if(h.length>1){h.sort(((t,e)=>at(t,e)));const t=rt(u.clone(),null);h.push(t);let e=0;for(let t=1,s=h.length;t<s;t++)if(!h[t].otherPt.equals(h[t-1].otherPt)){if(t-e>1&&null!==h[e].seg){let s=!1;const i=e;for(let n=e+1;n<t;n++)if(!ot(h[i],h[n])){s=!0;break}if(s)for(let s=e;s<t&&null!==h[s].seg;s++)c.push(h[s].vert)}e=t}}m=e,l.setCoordsPoint2D(n)}for(const s of c){const i=t.getSegment(s);(0,n.g)(null!==i);const o=t.getXY(s),a=t.getXY(t.getNextVertex(s));if(r.P.distance(o,a)<3*e)t.setSegmentToIndex(t.getVertexIndex(s),null);else{const e=i.lengthToT(.5*i.calculateLength2D());t.splitSegment(s,[e],1)}}return t.removeUserIndex(o),c.length>0}firstCrack_(){const t=this.m_shape.getEnvelope2D(this.m_progressTracker),e=(0,i.b)(null,t,!0).total();if(4*e<this.m_tolerance.total()){let t=!1;const s=1.1*e,n=e,r=this.cluster_(s);t||=r;let o=0;this.m_bFilterDegenerateSegments&&(o=this.m_shape.filterClosePoints(0,!0,!1,this.m_bTrackChanges,i.n));const a=this.crack_(n);return t||=a,t?1:o?2:0}return-1}progress_(t=!1){this.m_progressCounter++,!t&&4095&this.m_progressCounter||(this.m_progressCounter=0)}}function rt(t,e){return{otherPt:t,seg:e,vert:-1,dir:0}}function ot(t,e){if((0,n.g)(t.otherPt.equals(e.otherPt)),null===t.seg)return null===e.seg;if(null===e.seg)return!1;const s=t.seg.getGeometryType();if(s!==e.seg.getGeometryType())return!1;if(s===n.G.enumBezier){const s=t.seg,i=e.seg;let n=s.getControlPoint1(),o=s.getControlPoint2();-1===t.dir&&(o=(0,r.b)(n,n=o));let a=i.getControlPoint1(),h=i.getControlPoint2();return-1===e.dir&&(h=(0,r.b)(a,a=h)),n.equals(a)&&o.equals(h)}if(s===n.G.enumRationalBezier2){const s=t.seg,i=e.seg,n=s.getControlPoint1(),o=i.getControlPoint1();if(!n.equals(o))return!1;const a=[0,0,0];s.queryWeights(a),-1===t.dir&&(a[2]=(0,r.b)(a[0],a[0]=a[2]));const h=[0,0,0];return i.queryWeights(h),-1===e.dir&&(h[2]=(0,r.b)(h[0],h[0]=h[2])),a[0]===h[0]&&a[1]===h[1]&&a[2]===h[2]}(0,n.b)("")}function at(t,e){const s=t.otherPt.compare(e.otherPt);return 0!==s?s:function(t,e){if(null===t.seg||null===e.seg)return null!==t.seg?-1:null!==e.seg?1:0;const s=t.seg.getGeometryType(),i=e.seg.getGeometryType();return s<i?-1:s>i?1:0}(t,e)}},55537:(t,e,s)=>{function i(t,e){try{if(!t)throw new Error(e)}catch(t){throw t}}s.d(e,{A:()=>X,B:()=>R,C:()=>Y,G:()=>m,a:()=>D,b:()=>N,c:()=>q,d:()=>c,e:()=>p,f:()=>x,g:()=>i,h:()=>g,i:()=>f,j:()=>F,k:()=>M,l:()=>S,m:()=>V,n:()=>E,o:()=>C,p:()=>G,q:()=>y,r:()=>d,s:()=>_,t:()=>v,u:()=>I,v:()=>P,w:()=>T,x:()=>b,y:()=>w,z:()=>A});class n extends Error{constructor(t,e){super(),this.m_AdditionalMessage=e,this.m_ErrorType=t}what(){return function(t){switch(t){case 1:return"Unknown error";case 2:return"Corrupted geometry";case 3:return"Empty geometry";case 4:return"Math singularity";case 5:return"Buffer is too small";case 6:return"Invalid shape type";case 7:return"Projection out of supported range";case 8:return"Non simple geometry";case 9:return"Cannot calculate geodesic";case 10:return"Notation conversion";case 11:return"Missing grid file";case 12:return"Invalid call";case 13:return"Internal error";case 14:return"Not implemented";case 15:return"IO error";case 16:return"Invalid 3D";case 17:return"An ambiguous geography edge with antipodal points";case 18:return"Geocentric coordinates require ellipsoidal height";case 19:return"Geography cannot be projected into a gnomonic plane or a result of an operation cannot fit into a gnomonic plane";case 20:return"Geometry is too large to be exported in to a given format";case 21:return"Operation is canceled by the user";default:return"unknown error"}}(this.m_ErrorType)}additionalMessage(){return this.m_AdditionalMessage?this.m_AdditionalMessage:""}code(){return this.m_ErrorType}}class r extends n{constructor(t){super(2,t),this.name="corrupted geometry exception"}}class o extends n{constructor(t){super(3,t),this.name="empty gemetry exception"}}class a extends n{constructor(t){super(4,t),this.name="match singularity exception"}}class h extends n{constructor(t){super(8,t),this.name="non simple geometry exception"}}var m,l;(l=m||(m={}))[l.enumUnknown=0]="enumUnknown",l[l.enumPoint=513]="enumPoint",l[l.enumLine=5122]="enumLine",l[l.enumBezier=5123]="enumBezier",l[l.enumEllipticArc=5124]="enumEllipticArc",l[l.enumEnvelope=3077]="enumEnvelope",l[l.enumMultiPoint=8710]="enumMultiPoint",l[l.enumPolyline=25607]="enumPolyline",l[l.enumPolygon=27656]="enumPolygon",l[l.enumMultipatch=40969]="enumMultipatch",l[l.enumGeometryCollection=3594]="enumGeometryCollection",l[l.enumRationalBezier2=5134]="enumRationalBezier2",l[l.enumBezier2=5135]="enumBezier2",l[l.enumRationalBezier23d=5392]="enumRationalBezier23d",l[l.enumGreatArc3d=5393]="enumGreatArc3d";const u=[0,0,1,1,1,2,0,1,2,3,-1,-1,-1,-1,1,1];function c(t){return u[15&t]}function g(t){return!!(512&t)}function _(t){return!!(1024&t)}function d(t){return!!(2048&t)}function p(t){return!!(4096&t)}function f(t){return!!(8192&t)}function x(t){return!!(16384&t)}function y(t){return!!(32768&t)}function P(t){const e=t.getGeometryType();return f(e)?t.getPointCount():t.isEmpty()?0:e===m.enumEnvelope?4:e===m.enumPoint?1:p(e)?2:void N("missing type")}function E(t){const e=t.getGeometryType();if(x(e))return t.hasNonLinearSegments();if(e===m.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)if(E(e.getGeometry(t)))return!0;return!1}return!!p(e)&&e!==m.enumLine}function C(t){throw new r(t)}function v(t){const e=new Error(t);throw e.name="invalid argument exception",e}function b(t){const e=new a(t);throw e.name="invalid argument exception",e}function S(){v("Geometry type is not supported for 3D operations.")}function I(t){throw new n(12,t)}function w(t){throw new o(t)}function D(t){const e=new n(14,t);throw e.name="not implemented",e}function T(t){const e=new Error(t);throw e.name="out of range exception",e}function N(t){const e=new n(13,t);throw e.name="internal error",e}function A(t){const e=new Error(t);throw e.name="logic error exception",e}function M(t){throw new h(t)}function G(t){t&&E(t)&&D("operation does not support curves yet")}function q(t){t&&y(t.getGeometryType())&&D("Unsupported geometry type.")}function F(t){t===m.enumGeometryCollection&&v("Geometry_collection instances are not supported in this operation")}function V(t){F(t.getGeometryType())}function R(t){v(`bad wkid: ${t}`)}function Y(t){let e="bad wkt: ";e+=t,e+="...",v(e)}function X(t,e){t||v(e)}},89473:(t,e,s)=>{s.d(e,{I:()=>m});var i=s(55537),n=s(76061),r=s(35368),o=s(54573),a=s(11878),h=s(32406);class m{constructor(t,e,s,n){this.m_intersectorGeom=null,this.m_sr=null,this.m_dimensionMask=-1,this.m_progressTracker=null,this.m_intersectorGeomType=i.G.enumUnknown,this.m_geomIntersectorEmptyGeom=null,this.m_intersectorGeom=t,this.m_sr=e,this.m_dimensionMask=s,this.m_progressTracker=n,this.m_intersectorGeomType=t.getGeometryType()}intersect(t){const e=this.tryFastImplementation(t);if(null!==e)return e;const s=(0,r.H)(this.m_intersectorGeom,t),i=(0,r.b)(this.m_sr,s,!0).total(),n=r.a.constructEmpty();this.m_intersectorGeom.queryEnvelope(n);const m=r.a.constructEmpty();t.queryEnvelope(m),n.inflateCoords(2*i,2*i),n.intersect(m),n.inflateCoords(100*i,100*i);let l=(0,o.c)(this.m_intersectorGeom,n,0,0,this.m_progressTracker),u=(0,o.c)(t,n,0,0,this.m_progressTracker);return t.getDimension()>this.m_intersectorGeom.getDimension()&&(l=(0,a.b)(u,u=l)),(0,h.i)(u,l,this.m_sr,this.m_progressTracker)}intersectEx(t){const e=this.tryFastImplementation(t);if(null!==e){const s=[];return s.length=3,s[e.getDimension()]=e,this.prepareVector(t.getDescription(),this.m_dimensionMask,s)}const s=(0,r.H)(this.m_intersectorGeom,t),i=(0,r.b)(this.m_sr,s,!0).total(),n=r.a.constructEmpty();this.m_intersectorGeom.queryEnvelope(n);const m=r.a.constructEmpty();t.queryEnvelope(m),n.inflateCoords(2*i,2*i),n.intersect(m),n.inflateCoords(100*i,100*i);let l=(0,o.c)(this.m_intersectorGeom,n,0,0,this.m_progressTracker),u=(0,o.c)(t,n,0,0,this.m_progressTracker);t.getDimension()>this.m_intersectorGeom.getDimension()&&(l=(0,a.b)(u,u=l));const c=(0,h.c)(u,l,this.m_sr,this.m_progressTracker);return this.prepareVector(t.getDescription(),this.m_dimensionMask,c)}init(t,e,s,n=null){(0,i.g)(0)}static intersectPoints(t,e,s){const i=(0,r.H)(t,e),n=(0,r.b)(s,i,!0);return(0,h.e)(t,e,n)}tryFastImplementation(t){const e=t.getGeometryType();if(this.m_intersectorGeomType===i.G.enumPoint&&e===i.G.enumPoint){const e=m.intersectPoints(t,this.m_intersectorGeom,this.m_sr);if(-1!==this.m_dimensionMask){const t=new r.M({vd:e.getDescription()});return e.isEmpty()||t.add(e),t}return e}if(e===i.G.enumEnvelope&&this.m_intersectorGeomType===i.G.enumEnvelope&&(-1===this.m_dimensionMask||4===this.m_dimensionMask)){const e=t,s=this.m_intersectorGeom,i=new r.E({copy:e});return i.intersect(s),i}const s=(0,r.H)(t,this.m_intersectorGeom),n=(0,r.b)(this.m_sr,s,!0),a=t.isEmpty(),l=this.m_intersectorGeom.isEmpty();let u=a||l;if(!u){const e=function(t,e,s){const n=new r.a;t.queryEnvelope(n);const o=new r.a;e.queryEnvelope(o);const a=new r.a(o);if(a.inflate(2*s),!a.isIntersecting(n))return 4;const h=t.getGeometryType(),m=e.getGeometryType();if(h===i.G.enumEnvelope&&n.containsEnvelope(a))return 1;if(m===i.G.enumEnvelope){const t=new r.a(n);if(t.inflate(2*s),o.containsEnvelope(t))return 2}return 0}(this.m_intersectorGeom,t,n.total());if(4===e)u=!0;else{if(2&e)return this.m_intersectorGeom;if(1&e)return t}}if(u){const s=(0,i.d)(e),n=(0,i.d)(this.m_intersectorGeomType);return s<n?m.ReturnEmpty(t,a):s>n||0===s&&e===i.G.enumMultiPoint&&this.m_intersectorGeomType===i.G.enumPoint?this.ReturnEmptyIntersector():m.ReturnEmpty(t,a)}if(e===i.G.enumEnvelope&&0===(0,i.d)(this.m_intersectorGeomType)||this.m_intersectorGeomType===i.G.enumEnvelope&&0===(0,i.d)(e)){const s=e===i.G.enumEnvelope?t:this.m_intersectorGeom,a=e===i.G.enumEnvelope?this.m_intersectorGeom:t,h=r.a.constructEmpty();return s.queryEnvelope(h),(0,o.c)(a,h,n.total(),0,this.m_progressTracker)}if(0===(0,i.d)(e)&&(0,i.d)(this.m_intersectorGeomType)>0||(0,i.d)(e)>0&&0===(0,i.d)(this.m_intersectorGeomType)){if(e===i.G.enumMultiPoint)return(0,h.f)(t,this.m_intersectorGeom,n);if(e===i.G.enumPoint)return(0,h.g)(t,this.m_intersectorGeom,n);if(this.m_intersectorGeomType===i.G.enumMultiPoint)return(0,h.f)(this.m_intersectorGeom,t,n);if(this.m_intersectorGeomType===i.G.enumPoint)return(0,h.g)(this.m_intersectorGeom,t,n);(0,i.b)("")}return null}ReturnEmptyIntersector(){return null===this.m_geomIntersectorEmptyGeom&&(this.m_geomIntersectorEmptyGeom=this.m_intersectorGeom.createInstance()),this.m_geomIntersectorEmptyGeom}static ReturnEmpty(t,e){return e?t:t.createInstance()}prepareVector(t,e,s){let i=0;return 1&e?(s[0]||(s[0]=new r.M({vd:t})),i++):s.shift(),2&e?(s[i]||(s[i]=new r.i({vd:t})),i++):s.splice(i,1),4&e?s[i]||(s[i]=new r.h({vd:t})):s.splice(i,1),new n.S(s)}}},31139:(t,e,s)=>{s.d(e,{O:()=>a});var i=s(76061),n=s(55537),r=s(35368),o=s(54573);class a{getOperatorType(){return 10004}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i){return new h(t,e,s,i)}execute(t,e,s,i){return function(t,e,s,i){return(0,o.a)(t,e,s,Number.NaN,0,i)}(t,e,s,i)}}class h extends i.G{constructor(t,e,s,i){super(),this.m_progressTracker=i,this.m_index=-1,t||(0,n.t)(""),this.m_envelope=e,this.m_inputGeometryCursor=t,this.m_spatialRefImpl=s,this.m_tolerance=(0,r.b)(s,e,!1).total()}next(){let t;return(t=this.m_inputGeometryCursor.next())?((0,n.c)(t),this.m_index=this.m_inputGeometryCursor.getGeometryID(),(0,o.c)(t,this.m_envelope,this.m_tolerance,0,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},5247:(t,e,s)=>{s.d(e,{O:()=>h});var i=s(76061),n=s(55537),r=s(35368),o=r.D;class a extends i.G{constructor(t,e,s,i,n,r){super(),this.m_densificator=new o(e,s,i,r,!1,n),this.m_index=-1,this.m_inputGeoms=t}tock(){return!0}getRank(){return 1}next(){let t=null;for(;t=this.m_inputGeoms.next();)return(0,n.c)(t),this.m_index=this.m_inputGeoms.getGeometryID(),this.densify(t);return null}getGeometryID(){return this.m_index}densify(t){return this.m_densificator.densify(t)}}class h{getOperatorType(){return 10202}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}executeMany(t,e,s,i,n,r=12e3){return new a(t,e,s,i,r,n)}execute(t,e,s,i,n,o=12e3){return(0,r.e)(t,e,s,i,n,o)}}},31085:(t,e,s)=>{s.d(e,{O:()=>u});var i=s(76061),n=s(55537),r=s(89473),o=s(11878),a=s(35368),h=s(54573),m=s(32406),l=s(77592);class u{getOperatorType(){return 10002}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i){return new c(t,e,s,i)}execute(t,e,s,n){return this.executeMany(new i.S([t]),new i.S([e]),s,n).next()}}class c extends i.G{constructor(t,e,s,i){super(),this.m_progressTracker=i,this.m_index=-1,this.m_inputGeoms=t,this.m_spatialReference=s;const n=e.next();this.m_geomSubtractor=n||new a.h}next(){const t=this.m_inputGeoms.next();return t?((0,n.c)(t),(0,n.m)(t),this.m_index=this.m_inputGeoms.getGeometryID(),function(t,e,s,i){if(t.isEmpty()||e.isEmpty())return t;const u=t.getDimension(),c=e.getDimension();if(u>c)return t;const g=t.getGeometryType(),_=e.getGeometryType(),d=new a.a,p=new a.a,f=new a.a;t.queryEnvelope(d),e.queryEnvelope(p),f.setCoords({env2D:d}),f.mergeEnvelope2D(p);const x=(0,a.b)(s,f,!0),y=(0,a.l)(x),P=new a.a;if(P.setCoords({env2D:d}),P.inflateCoords(y,y),!P.isIntersecting(p))return t;if(1===u&&2===c){const o=function(t,e,s,i,o){const h=new a.E;t.queryEnvelope(h);const m=new a.a;e.queryEnvelope(m),h.merge(m);const l=.1*h.width(),u=.1*h.height();h.inflateCoords(l,u);const c=new a.h;c.addEnvelope(h,!1);const g=c.getImpl();if(s===n.G.enumPolygon){const t=e.getImpl();g.add(t,!0)}else g.addEnvelope(e,!0);return new r.I(c,i,-1,o).tryFastImplementation(t)}(t,e,_,s,i);if(o)return o}if(g===n.G.enumPoint){let s;switch((0,n.e)(_)?(s=new a.i({vd:e.getDescription()}),s.addSegment(e,!0)):s=e,_){case n.G.enumPolygon:return function(t,e,s){return 0===(0,l.m)(e,t,s.total())?t:t.createInstance()}(t,s,x);case n.G.enumPolyline:return function(t,e,s){const i=t.getXY(),n=e.querySegmentIterator(),r=(0,a.l)(s),h=r*r;for(;n.nextPath();)for(;n.hasNextSegment();){const e=n.nextSegment(),m=new a.a;if(e.queryEnvelope(m),m.inflateCoords(r,r),!m.contains(i))continue;if(e.isIntersectingPoint(i,s.total()))return t.createInstance();let l=e.getStartXY();if(o.P.sqrDistance(i,l)<=h)return t.createInstance();if(l=e.getEndXY(),o.P.sqrDistance(i,l)<=h)return t.createInstance()}return t}(t,s,x);case n.G.enumMultiPoint:return function(t,e,s){const i=e.getImpl().getAttributeStreamRef(0),n=e.getPointCount(),r=t.getXY(),h=(0,a.l)(s),m=h*h,l=new o.P;for(let e=0;e<n;e++)if(i.queryPoint2D(2*e,l),o.P.sqrDistance(l,r)<=m)return t.createInstance();return t}(t,s,x);case n.G.enumEnvelope:return function(t,e,s){const i=new a.a;e.queryEnvelope(i),i.inflate(s.total());const n=t.getXY();return i.contains(n)?t.createInstance():t}(t,s,x);case n.G.enumPoint:return function(t,e,s){const i=(0,a.l)(s),n=i*i,r=t.getXY(),h=e.getXY();return o.P.sqrDistance(r,h)<=n?t.createInstance():t}(t,s,x);default:(0,n.t)("invalid shape type")}}else if(g===n.G.enumMultiPoint)switch(_){case n.G.enumPolygon:return function(t,e,s){const i=new a.a;e.queryEnvelope(i),i.inflate(s.total());const n=t.getPointCount();let r=!1;const h=(0,o.a)(n,!1),m=new o.P;for(let o=0;o<n;o++)t.queryXY(o,m),i.contains(m)&&0!==(0,l.i)(e,m,s.total())&&(r=!0,h[o]=!0);if(!r)return t;const u=t.createInstance();for(let e=0;e<n;e++)h[e]||u.addPoints(t,e,e+1);return u}(t,e,x);case n.G.enumEnvelope:return function(t,e,s){const i=new a.a;e.queryEnvelope(i),i.inflate(s.total());const n=t.getPointCount();let r=!1;const h=(0,o.a)(n,!1),m=new o.P;for(let e=0;e<n;e++)t.queryXY(e,m),i.contains(m)&&(r=!0,h[e]=!0);if(!r)return t;const l=t.createInstance();for(let e=0;e<n;e++)h[e]||l.addPoints(t,e,e+1);return l}(t,e,x);case n.G.enumPoint:return function(t,e,s){const i=t.getImpl().getAttributeStreamRef(0),n=t.getPointCount(),r=e.getXY();let h=!1;const m=(0,o.a)(n,!1),l=(0,a.l)(s),u=l*l,c=new o.P;for(let t=0;t<n;t++)i.queryPoint2D(2*t,c),o.P.sqrDistance(c,r)<=u&&(h=!0,m[t]=!0);if(!h)return t;const g=t.createInstance();for(let e=0;e<n;e++)m[e]||g.addPoints(t,e,e+1);return g}(t,e,x)}const E=new a.a(d);E.inflate(100*x.total());const C=(0,h.c)(e,E,0,0,i);return(0,m.b)(t,C,s,i)}(t,this.m_geomSubtractor,this.m_spatialReference,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}},32932:(t,e,s)=>{s.d(e,{O:()=>h});var i=s(76061),n=s(55537),r=s(89473),o=s(35368);class a extends i.G{constructor(t,e,s,i,o){super(),this.m_smallCursor=null,this.m_progressTracker=i,this.m_geomIntersector=e.next(),this.m_intersector=new r.I(this.m_geomIntersector,s,o,i),this.m_index=-1,this.m_inputGeoms=t,this.m_dimensionMask=o,-1!==this.m_dimensionMask&&(this.m_dimensionMask<=0||this.m_dimensionMask>7)&&(0,n.t)("bad dimension mask")}next(){if(!this.m_geomIntersector)return null;let t;if(null!==this.m_smallCursor){if(t=this.m_smallCursor.next(),t)return t;this.m_smallCursor=null}for(;t=this.m_inputGeoms.next();)return(0,n.c)(t),this.m_index=this.m_inputGeoms.getGeometryID(),-1===this.m_dimensionMask?this.m_intersector.intersect(t):(this.m_smallCursor=this.m_intersector.intersectEx(t),this.m_smallCursor.next());return null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}class h{getOperatorType(){return 1e4}accelerateGeometry(t,e,s){if(!this.canAccelerateGeometry(t))return!1;(0,o.u)(e,t,!0);let i=0;return t.getGeometryType()!==n.G.enumPolygon&&t.getGeometryType()!==n.G.enumPolyline||!(0,o.G)(t)||0===s||(i|=t.getImpl().buildQuadTreeAccelerator(s)?1:0),!!i}canAccelerateGeometry(t){return(0,o.G)(t)}supportsCurves(){return!0}executeMany(t,e,s,i,n=-1){return new a(t,e,s,i,n)}execute(t,e,s,o){if(t.getGeometryType()===n.G.enumPoint&&e.getGeometryType()===n.G.enumPoint)return r.I.intersectPoints(t,e,s);const a=new i.S([t]),h=new i.S([e]),m=this.executeMany(a,h,s,o,-1).next();return m||(0,n.b)("null output"),m}}},9192:(t,e,s)=>{s.r(e),s.d(e,{$:()=>Ai,A:()=>Ms,B:()=>b,C:()=>Ps,D:()=>ps,E:()=>T,F:()=>$i,G:()=>ke,H:()=>ms,I:()=>bs,J:()=>k,K:()=>G,L:()=>Us,M:()=>q,N:()=>vs,O:()=>Je,P:()=>Zi,Q:()=>Ji,R:()=>ae,S:()=>Ri,T:()=>X,U:()=>M,V:()=>L,W:()=>z,X:()=>Qe,Y:()=>Ke,Z:()=>di,_:()=>vi,a:()=>$e,a0:()=>Ki,a1:()=>Es,a2:()=>R,a3:()=>Ii,a4:()=>Si,a5:()=>We,a6:()=>Ei,a7:()=>p,a8:()=>gn,a9:()=>_n,b:()=>yi,c:()=>xi,d:()=>Ze,e:()=>Ws,f:()=>pe,g:()=>_e,h:()=>_s,i:()=>_i,j:()=>Ci,k:()=>P,l:()=>Xe,m:()=>gs,n:()=>fe,o:()=>Qi,p:()=>on,q:()=>rn,r:()=>ot,s:()=>gi,t:()=>Ye,u:()=>Pe,v:()=>Ee,w:()=>xe,x:()=>ye,y:()=>I,z:()=>Cs});var i=s(35368),n=s(55537),r=s(11878),o=s(90237),a=s(54573),h=s(5247),m=s(32406),l=s(31139),u=s(32932),c=s(76061),g=s(77592),_=s(96546),d=s(31085);class p{constructor(t){if(this.m_geom=this.m_sr=null,t){if(t.move)return this.m_geom=t.move.m_geom,t.move.m_geom=null,this.m_sr=t.move.m_sr,void(t.move.m_sr=null);if(t.copy)return this.m_geom=t.copy.m_geom?t.copy.m_geom.clone():null,void(this.m_sr=t.copy.m_sr);t.geom&&(this.m_geom=t.geom),t.sr&&(this.m_sr=t.sr)}}getGeometry(){return this.m_geom}getSpatialReference(){return this.m_sr}setGeometry(t){this.m_geom=t}setSpatialReference(t){this.m_sr=t}equals(t,e){const s=t;return!(!this.m_sr&&s.m_sr||this.m_sr&&!s.m_sr||!this.m_geom&&s.m_geom||this.m_geom&&!s.m_geom||this.m_sr&&s.m_sr&&!this.m_sr.equals(s.m_sr)||this.m_geom&&s.m_geom&&!this.m_geom.equals(s.m_geom,e))}clone(){let t=null;return this.m_geom&&(t=this.m_geom.clone()),new p({geom:t,sr:this.m_sr})}hasGeom(){return!!this.m_geom}}class f{constructor(t){this.m_factor=1,this.m_wkid=0,this.m_peUnit=null,t&&(this.m_peUnit=t,this.m_factor=t.getUnitFactor(),this.m_wkid=t.getCode(),this.m_wkid<0&&(this.m_wkid=0))}getName(){return this.m_peUnit.getName()}getID(){return this.m_wkid}getConversionFactor(t){return this.getUnitType()!==t.getUnitType()&&(0,n.t)("unit type mismatch"),this.getUnitToBaseFactor()/t.getUnitToBaseFactor()}getUnitToBaseFactor(){return this.m_factor}getHashCode(){return(0,r.aw)((0,r.i)(this.getUnitType()),(0,r.i)(this.getUnitToBaseFactor()))}equals(t){return!!t&&this.getUnitType()===t.getUnitType()&&this.getUnitToBaseFactor()===t.getUnitToBaseFactor()&&this.getID()===t.getID()&&this.getName()===t.getName()}static isValidWkid(t){return!1}}const x={330:104878,500:104879,1300:104899,1450:104986,2230:104988,3800:104978,5e3:104919,6200:104906,8200:104909,9500:104927,9600:104977,1e4:[104911,104936],11e3:104941,11080:104872,11100:104907,12e3:104920,12400:104995,13e3:104948,14e3:[104923,104989],15e3:[104913,104954],15100:104976,16e3:[104926,104931],18e3:[104922,104982],21e3:104947,21500:104877,27e3:[104950,104957],29e3:104964,3e4:104921,31e3:104949,33e3:104946,4e4:[104914,104967],40600:104897,41900:104937,42e3:104951,43100:104993,49300:104924,50100:104939,54e3:104955,58200:104981,59500:104930,74e3:104961,77e3:104956,79e3:104962,83500:104910,85e3:104917,88800:104934,89200:104985,96e3:104997,104e3:104963,106500:104898,11e4:104938,133e3:104932,135e3:104983,17e4:104965,198200:104987,198630:104935,208e3:104966,235800:104952,249400:104929,252100:104980,255e3:104973,47e4:104972,529800:104942,531e3:104996,56e4:104928,561400:104979,578900:104945,584700:104959,593e3:104970,606e3:104999,718e3:104933,745700:104984,761400:104953,763500:104994,764e3:104940,788900:104958,1188300:104998,1195e3:104969,1352600:104968,1560800:104874,1562090:104915,1737400:104903,1821460:104918,1821490:104876,2409300:104912,2410300:104873,2439400:104974,2439700:104900,2575e3:104943,2631200:104875,2632345:104916,3393400:104904,3396190:[104905,104971],6051e3:104901,6051800:104902,637e4:104128,6370997:[4052,37008],6371e3:4035,6371007:4047,6371228:[4053,10346],6376045:[8042,8043],6376523:[4027,4901,4902],6376896:37007,6378135:[4122,4322,4324,4720,4985,4987],6378136:[4740,4923,7678,7680,9474,9475,104017,104018],6378137:[3823,3824,3888,3889,4017,4019,4023,4031,4040,4046,4055,4074,4075,4080,4081,4121,4126,4130,4133,4140,4141,4148,4151,4152,4163,4166,4167,4170,4171,4172,4173,4176,4180,4189,4190,4258,4269,4283,4318,4319,4326,4463,4466,4469,4470,4480,4482,4483,4490,4557,4558,4612,4617,4619,4624,4627,4659,4661,4667,4669,4670,4674,4686,4687,4693,4694,4702,4737,4742,4747,4749,4750,4755,4756,4757,4758,4759,4761,4762,4763,4764,4765,4883,4885,4887,4889,4893,4895,4898,4907,4909,4921,4925,4927,4929,4931,4933,4935,4937,4939,4941,4943,4945,4947,4949,4951,4953,4955,4957,4959,4961,4963,4965,4967,4971,4975,4977,4979,4981,4983,4989,4997,4999,5012,5013,5245,5246,5251,5252,5263,5264,5323,5324,5340,5342,5353,5354,5359,5360,5364,5365,5370,5371,5372,5373,5380,5381,5392,5393,5488,5489,5545,5546,5592,5593,5885,5886,6134,6135,6310,6311,6318,6319,6321,6322,6324,6325,6364,6365,6667,6668,6705,6706,6782,6783,6980,6982,6983,6987,6989,6990,7034,7035,7036,7037,7038,7039,7040,7041,7042,7072,7073,7084,7085,7086,7087,7133,7135,7136,7138,7139,7372,7373,7657,7659,7661,7663,7665,7685,7686,7797,7798,7816,7843,7844,7880,7881,7885,7886,7900,7901,7902,7903,7904,7905,7906,7907,7908,7909,7910,7911,7912,7915,7917,7919,7921,7923,7925,7927,7929,7931,8085,8086,8231,8232,8235,8237,8239,8240,8244,8246,8248,8249,8251,8252,8254,8255,8399,8403,8426,8427,8449,8542,8544,8545,8684,8685,8698,8699,8817,8818,8860,8888,8899,8900,8901,8902,8906,8907,8916,8918,8920,8922,8924,8926,8928,8930,8932,8934,8936,8938,8940,8942,8944,8946,8948,8949,8972,8973,8974,8975,8976,8977,8978,8979,8980,8981,8982,8983,8984,8985,8986,8987,8988,8989,8990,8991,8992,8993,8994,8995,8996,8997,8998,8999,9e3,9002,9003,9005,9006,9008,9009,9011,9012,9013,9014,9016,9017,9018,9019,9053,9054,9055,9056,9057,9059,9060,9061,9062,9063,9064,9065,9066,9067,9068,9069,9071,9072,9074,9075,9139,9140,9147,9148,9152,9153,9183,9184,9293,9294,9299,9308,9309,9332,9333,9364,9372,9379,9380,9384,9453,9469,9470,9546,9547,9695,9696,9701,9702,9739,9754,9755,9758,9763,9776,9777,9778,9779,9781,9782,9783,9784,9866,9871,9939,9964,9969,9974,9989,9990,10175,10177,10178,10185,10191,10196,10204,10209,10214,10219,10224,10229,10237,10272,10277,10283,10284,10298,10299,10300,10304,10305,10307,10309,10310,10311,10312,10327,10328,10413,10414,10468,10474,10475,10570,10571,10605,10606,10623,10628,20033,20040,20041,20045,20046,104009,104010,104011,104012,104013,104014,104015,104016,104019,104020,104021,104022,104024,104027,104028,104050,104100,104107,104108,104110,104111,104114,104115,104116,104117,104118,104119,104120,104121,104122,104123,104124,104129,104133,104134,104137,104141,104142,104143,104144,104145,104179,104180,104181,104182,104183,104184,104185,104186,104199,104223,104257,104258,104259,104260,104286,104287,104602,104613,104644,104645,104646,104647,104653,104804,104896,104991],6378140:4610,6378145:[4025,4276,4760,4891,37001],6378150:37003,6378155:[37004,37207],6378160:[3821,4003,4021,4036,4202,4203,4237,4238,4291,4618,4708,5527,37231,104023,104136],6378166:37002,6378200:[4020,4229,4286,4303,4706],6378245:[4024,4147,4164,4178,4179,4191,4200,4205,4214,4284,4317,4555,4676,4677,4678,4991,4993,5560,5561,37257,104135],6378270:[4732,37005,37229],6378273:[4054,10345],6378300:[4029,4168,4174],6378388:[4022,4123,4153,4154,4158,4159,4160,4161,4165,4181,4182,4183,4184,4185,4192,4194,4195,4196,4199,4204,4207,4208,4215,4218,4221,4224,4225,4230,4231,4233,4235,4236,4247,4248,4249,4254,4255,4259,4264,4265,4271,4272,4274,4285,4287,4288,4292,4297,4309,4311,4313,4316,4472,4475,4611,4614,4615,4616,4621,4622,4623,4625,4626,4628,4629,4630,4631,4632,4633,4636,4637,4639,4641,4642,4643,4644,4645,4646,4658,4660,4662,4663,4664,4665,4668,4672,4673,4684,4688,4689,4690,4691,4692,4698,4704,4705,4707,4709,4710,4711,4712,4714,4715,4716,4718,4719,4721,4722,4724,4725,4727,4728,4729,4730,4733,4734,4735,4739,4741,4753,4754,4802,4803,4806,4809,4810,4823,4824,4900,5524,6883,8428,8430,8431,9248,9251,9253,9403,9893,10158,10249,10252,37201,37204,37205,37212,37213,37214,37215,37216,37217,37218,37219,37221,37222,37224,37226,37227,37230,37232,37233,37234,37235,37237,37238,37241,37242,37245,37246,37247,37249,37250,37251,37253,37259,104104,104106,104125,104126,104127,104130,104138,104248],6378523:104786,24764e3:104960,25559e3:104944,60268e3:104925,71492e3:104908,6957e5:104975,6377397.155:[3819,3906,4004,4120,4124,4125,4149,4150,4156,4162,4211,4219,4257,4262,4280,4289,4294,4295,4301,4306,4308,4312,4314,4613,4666,4745,4746,4801,4804,4805,4808,4813,4814,4815,4818,4820,4904,5132,5228,5229,5681,5830,8351,9267,10268,37255,104101,104102,104105,104131,104648,104696,104697,104990,104992],6377563.396:[4001,4188,4277,4278,4279],6377340.189:[4002,4299,4300],6377492.018:[4005,4273,4817],6377483.865280418:[4006,4293],6378293.645208759:[4007,4157,4302,4738,5464],6378206.4:[4008,4127,4128,4129,4135,4136,4137,4138,4139,4169,4216,4242,4253,4267,4608,4609,4638,4675,4683,4695,4717,4723,4726,4995,5451,5467,37220,37239,37243,37252,37260,104e3,104109,104112,104113,104132],6378450.047:[4009,4268],6378300.789:[4010,4281],6378249.2:[4011,4014,4155,4193,4206,4213,4223,4226,4227,4228,4252,4261,4266,4275,4282,4296,4304,4310,4315,4671,4807,4811,4816,4821,37223,37225,104139,104140,104261,104304],6378249.145:[4012,4013,4132,4134,4142,4143,4175,4197,4198,4201,4209,4210,4212,4220,4222,4232,4234,4246,4250,4251,4256,4260,4263,4270,4305,4307,4600,4601,4602,4603,4604,4605,4606,4607,4620,4679,4680,4696,4697,4699,4700,4701,4703,4713,4731,4736,4743,4744,4812,4819,6881,6882,6892,6894,8694,37206,37208,37211,37228,37240,37254,104025,104026,104103,104305],6377276.345:[4015,4131,4144,4239,4240,4244,4682,5233,6207,37202,104256,104664,104693],6377298.556:[4016,4298],6377304.063:[4018,4245],6378298.3:[4028,4903],6378136.2:4032,6378136.3:4033,6378249.144808011:[4034,4241],20922931.8:[4042,4243],6377301.243:[4044,4145,37203],6377299.151:[4045,4146],6377019.27:[4657,10256,10260,10265],6378306.3696:[4748,4752],6377295.664:[4751,37006],6378136.5:[7682,7683],6371008.7714:104047,6378418.941:[104700,104726,104760],6378586.581:[104701,104743],6378505.809:104702,6378544.823:104703,6378490.569:104704,6378470.757:[104705,104776],6378403.701:[104706,104750],6378434.181:[104707,104724,104739,104764],6378454.907:104708,6378400.653:104709,6378567.378:104710,6378546.957:[104711,104717,104780],6378476.853:[104712,104736],6378411.321:[104713,104728],6378647.541:[104714,104715],6378514.953:[104716,104782],6378421.989:[104718,104770],6378481.425:[104719,104753,104774,104781],6378518.001:[104720,104725],6378521.049:[104721,104723,104731,104745,104748],6378464.661:104722,6378436.619:104727,6378574.389:[104729,104730],6378472.281:[104732,104756],6378498.189:[104733,104746],6378449.421:[104734,104766],6378525.621:[104735,104754],6378466.185:104737,6378496.665:104738,6378643.579:104740,6378559.758:104741,6378414.369:[104742,104763,104772],6378441.801:104744,6378502.761:[104747,104759,104773,104775],6378617.061:104749,6378624.681:[104751,104765],6378468.623:104752,6378445.763:[104755,104758,104761],6378670.401:104757,6378438.753:104762,6378543.909:104767,6378605.783:104768,6378540.861:104769,6378443.325:[104771,104784],6378548.481:104777,6378463.746:104778,6378426.561:104779,6378453.688:104783,6378530.193:104785,6378376.271:[104800,104828],6378471.92:104801,6378472.931:104802,6378411.351:104803,6378380.991:104805,6378414.96:104806,6378345.09:[104807,104819,104844,104870],6378412.542:104808,6378470.401:104809,6378376.331:104810,6378379.031:104811,6378407.621:104812,6378376.811:[104813,104827],6378313.92:104814,6378414.93:104815,6378413.021:104816,6378380.381:104817,6378530.851:104818,6378591.521:104820,6378378.881:104821,6378408.481:[104822,104832],6378375.601:[104823,104838],6378408.041:104824,6378655.071:104825,6378409.151:104826,6378315.7:[104829,104840,104845,104851],6378285.86:[104830,104835,104859],6378379.301:104831,6378560.121:104833,6378531.821:104834,6378500.6:104836,6378376.041:104837,6378406.601:104839,6378438.991:104841,6378345.42:104842,6378593.86:104843,6378381.271:[104846,104847],6378413.671:104848,6378344.377:104849,6378563.891:104850,6378408.091:104852,6378377.671:104853,6378472.751:104854,6378412.511:104855,6378407.281:104856,6378534.451:104857,6378406.051:104858,6378532.921:104860,6378380.091:104861,6378408.941:104862,6378624.171:104863,6378377.411:104864,6378474.591:104865,6378407.141:104866,6378376.871:104867,6378375.251:104868,6378405.971:104869,6378437.651:104871};class y extends f{constructor(t){if("number"==typeof t)return super(),this.m_factor=t,void(this.m_wkid=0);super(t)}getUnitType(){return 1}convertFromRadians(t){return t/this.getUnitToBaseFactor()}convertToRadians(t){return t*this.getUnitToBaseFactor()}}function P(t){return new ri}class E{constructor(t,e,s){void 0===t?(this.x=new r.H,this.y=new r.H,this.z=new r.H):t instanceof i.O?(this.x=new r.H(t.x),this.y=new r.H(t.y),this.z=new r.H(t.z)):t instanceof r.H?(this.x=t.clone(),this.y=e.clone(),this.z=s.clone()):(0,n.t)("EPoint3D constructor")}dotProduct(t){return this.x.mulE(t.x).addE(this.y.mulE(t.y)).addE(this.z.mulE(t.z))}crossProduct(t){return new E(this.y.mulE(t.z).subE(this.z.mulE(t.y)),this.z.mulE(t.x).subE(this.x.mulE(t.z)),this.x.mulE(t.y).subE(this.y.mulE(t.x)))}crossProductVector(t){const e=this.y.mulE(t.z).subE(t.y.mulE(this.z)),s=t.x.mulE(this.z).subE(this.x.mulE(t.z)),i=this.x.mulE(t.y).subE(t.x.mulE(this.y));return new E(e,s,i)}sqrLength(){return this.x.mulE(this.x).addE(this.y.mulE(this.y)).addE(this.z.mulE(this.z))}length(){return this.sqrLength().sqrt()}static distance(t,e){return t.sub(e).length()}negate(){return new E(this.x.negate(),this.y.negate(),this.z.negate())}add(t){return new E(this.x.addE(t.x),this.y.addE(t.y),this.z.addE(t.z))}sub(t){return new E(this.x.subE(t.x),this.y.subE(t.y),this.z.subE(t.z))}subThis(t){return this.x.subThisE(t.x),this.y.subThisE(t.y),this.z.subThisE(t.z),this}addThis(t){return this.x.addThisE(t.x),this.y.addThisE(t.y),this.z.addThisE(t.z),this}mul(t){return new E(this.x.mulE(t),this.y.mulE(t),this.z.mulE(t))}div(t){return new E(this.x.divE(t),this.y.divE(t),this.z.divE(t))}eq(t){return this.x.eq(t.x)&&this.y.eq(t.y)&&this.z.eq(t.z)}isZero(){return this.x.isZero()&&this.y.isZero()&&this.z.isZero()}value(){return i.O.construct(this.x.value(),this.y.value(),this.z.value())}}class C{constructor(t){this.m_origin=new i.O,this.m_normal=new i.O,this.m_axisX=new i.O,this.m_axisY=new i.O,(0,n.g)(0)}assign(t){return(0,n.g)(0),this}set(t,e,s,i){(0,n.g)(0)}setFromPoints(t,e,s){return(0,n.g)(0),!1}getCoord(t,e){return(0,n.g)(0),{}}getCoord2D(t){return(0,n.g)(0),{}}getCoordX(t,e){return(0,n.g)(0),0}getCoordY(t,e){return(0,n.g)(0),0}getCoordZ(t,e){return(0,n.g)(0),0}setPreferredAxisX(t){(0,n.g)(0)}getOrigin(){return(0,n.g)(0),{}}getNormal(){return(0,n.g)(0),{}}getAxisX(){return this.m_axisX.clone()}getAxisY(){return this.m_axisY.clone()}setAxisX(t,e=!1){(0,n.g)(0)}setAxisY(t,e=!1){(0,n.g)(0)}recalculateAxisY(){(0,n.g)(0)}setOrigin(t){(0,n.g)(0)}setNormal(t,e){(0,n.g)(0)}intersect(t,e){return(0,n.g)(0),!1}intersectLine(t){return(0,n.g)(0),0}intersectLineEx(t,e){return(0,n.g)(0),0}closestCoordinate(t){return(0,n.g)(0),{}}projectVector(t){return(0,n.g)(0),{}}signedDistance(t){return(0,n.g)(0),0}distance(t){return(0,n.g)(0),0}}function v(t,e){return!1}function b(t,e,s,i,o=100,a=v){let h,m,l,u,c,g,_,d,p;(0,n.g)(i>0);let f,x,y,P=0,E=0;const C=(0,r.av)();e>s&&(s=(0,r.b)(e,e=s));const b=t(e),S=t(s);b<S?(h=m=l=e,u=c=g=b):(h=m=l=s,u=c=g=S);let I=0;for(;I<o&&(y=.5*(s-e),p=e+y,f=i*(Math.abs(h)+.25),x=2*f,!(a(h,u)||Math.abs(h-p)<=x-y));++I){if(Math.abs(E)>f){const t=(h-m)*(u-g);let i=(h-l)*(u-c),n=(h-l)*i-(h-m)*t;i=2*(i-t),i>0&&(n=-n),i=Math.abs(i);const o=E;E=P,Math.abs(n)>=Math.abs(i*o*.5)||n<=i*(e-h)||n>=i*(s-h)?(E=h>=p?e-h:s-h,P=(0,r.av)()*E):(P=n/i,d=h+P,(d-e<x||s-d<x)&&(P=p-h<0?-Math.abs(f):Math.abs(f)))}else E=h>=p?e-h:s-h,P=E*C;d=h+P,_=t(d),_<u?(d>=h?e=h:s=h,l=m,m=h,h=d,g=c,c=u,u=_):(d<h?e=d:s=d,_<=c||m===h?(l=m,m=d,g=c,c=_):(_<=g||l===h||l===m)&&(l=d,g=_))}return(0,r.d)(h,u)}function S(t,e,s){return t>s?t-=Math.ceil((t-s)/r.p)*r.p:t<e&&(t+=Math.ceil((e-t)/r.p)*r.p),t}function I(t,e,s){return function(t,e,s){const i=s.x,n=s.y;return w(t,e,Math.cos(i),Math.sin(i),Math.cos(n),Math.sin(n),0)}(t,e,s)}function w(t,e,s,n,r,o,a){const h=t/Math.sqrt(1-e*o*o),m=h+a,l=m*r*s,u=m*r*n,c=(h*(1-e)+a)*o;return i.O.construct(l,u,c)}function D(t,e,s){const i=new r.H,n=new r.H,o=new r.H,a=new r.H;i.setCos(s.x),n.setSin(s.x),o.setCos(s.y),a.setSin(s.y);const h=a.negate().mulE(a.mul(e)).add(1).sqrt(),m=new r.H(t).divE(h),l=m.mulE(o).mulE(i),u=m.mulE(o).mulE(n),c=m.mul(1-e).mulE(a);return new E(l,u,c)}function T(t,e,s){const i=s.x,n=s.y,o=s.z,a=Math.atan2(n,i),h=Math.sqrt(i*i+n*n),m=Math.atan2(o,(1-e)*h);return r.P.construct(a,m)}function N(t,e,s){const i=1-e,n=t/Math.sqrt((0,r.e)(s.x)+(0,r.e)(s.y)+(0,r.e)(s.z)/i);return s.mul(n)}function A(t,e,s,n,r){const o=I(t,e,s),a=I(t,e,n);return T(0,e,i.O.lerp(o,a,r))}function M(t,e,s){const n=new i.O;return n.setCrossProductVector(e,s),Math.abs(Math.atan2(n.length(),e.dotProduct(s)))*t}function G(t,e,s,n,r){const o=s.getUnitVector(),a=n.getUnitVector(),h=e.getUnitVector(),m=new i.O;if(m.setCrossProductVector(o,a),!m.isZero()){m.normalizeThis();const e=h.sub(m.mul(m.dotProduct(h)));if(!e.isZero()){e.normalizeThis();const s=o.add(a).mul(.5);if(s.dotProduct(e)>s.dotProduct(o)){const s=Math.abs(m.dotProduct(h)),i=Math.asin(s);return r.assign(e.getUnitVector().mul(t)),i*t}}}const l=M(1,o,h),u=M(1,a,h);return l<=u?(r.assign(s),l*t):(r.assign(n),u*t)}function q(t,e,s,a,h,m=0,l){if(2===m||3===m)return function(t,e,s,n,o,a=!1,h){const m=N(t,e,s);if(a){const a=new C({pt0:new i.O(0,0,0),pt1:n,pt2:o}),l=a.closestCoordinate(s),u=a.closestCoordinate(n),c=a.closestCoordinate(o),g=r.P.getClosestCoordinate(u,c,l),_=N(t,e,i.O.lerp(n,o,g)),d=i.O.distance(_,m);return h&&h.assign(_),(0,r.d)(g,d)}const l=s=>{const r=N(t,e,i.O.lerp(n,o,s));return i.O.distance(r,m)},u=i.O.distance(n,o);if(u>0){const s=B(t,u),{first:a,second:m}=b(l,0,1,s);return h&&h.assign(N(t,e,i.O.lerp(n,o,a))),(0,r.d)(a,m)}{const t=i.O.distance(s,n);return h&&h.assign(s),(0,r.d)(.5,t)}}(t,e,s,a,h,3===m,l);const u=T(0,e,s),c=s=>{const r=T(0,e,i.O.lerp(a,h,s));return function(t,e,s,r,a){switch((0,n.g)(s.isFinite()&&r.isFinite()),a){case 0:return function(t,e,s,i){const n={stack:[],error:void 0,hasError:!1};try{const r=(0,o.b)(n,new Qi,!1);return rn.geodeticDistance(t,e,s.x,s.y,i.x,i.y,r,null,null,Ji.PE_LINETYPE_GEODESIC),r.val}catch(t){n.error=t,n.hasError=!0}finally{(0,o.c)(n)}}(t,e,s,r);case 1:return function(t,e,s){const i={stack:[],error:void 0,hasError:!1};try{const n=(0,o.b)(i,new Qi,!1);return rn.greatEllipticDistance(t,e,s.x,s.y,s.x,s.y,n,null,null),n.val}catch(t){i.error=t,i.hasError=!0}finally{(0,o.c)(i)}}(t,e,s);case 2:case 3:{const n=I(t,e,s),o=I(t,e,r);return i.O.distance(n,o)}default:(0,n.a)("")}}(t,e,u,r,m)},g=i.O.distance(a,h);if(g>0){const s=B(t,g),{first:n,second:o}=b(c,0,1,s);return l&&l.assign(N(t,e,i.O.lerp(a,h,n))),(0,r.d)(n,o)}{const t=c(0);return l&&l.assign(a),(0,r.d)(.5,t)}}function F(t,e,s,n,o,a){if(a[0]=Number.NaN,a[1]=Number.NaN,Math.abs(s.x-n.x)>Math.PI)return 0;if(Math.abs(s.y)>r.q||Math.abs(n.y)>r.q)return 0;if((Math.abs(s.y)===r.q||Math.abs(n.y)===r.q)&&s.x!==n.x)return 0;if(Math.abs(o)>=r.q)return 0;if(s.y>0&&n.y>0&&s.y>o&&n.y>o||s.y<0&&n.y<0&&s.y<o&&n.y<o)return 0;const h=i.ap.constructPoint2D(s),m=i.ap.constructPoint2D(n),l=D(1,e,h),u=D(1,e,m),c=l.crossProductVector(u);if(c.z.isZero())return r.E.construct(s.y,n.y).containsCoordinate(o)?(a[0]=s.x,1):0;const g=c.x.divE(c.z.negate()),_=c.y.divE(c.z.negate()),d=g.mulE(g).addE(_.mulE(_)).sqrt();if(d.isZero()||g.isZero()&&_.isZero())return 0===o?(a[0]=s.x,a[1]=n.x,2):0;const p=(1-e)*Math.tan(o)/d.value();if(Math.abs(p)>1)return 0;const f=Math.acos(p),x=Math.atan2(_.value(),g.value()),y=x-f;let P=x+f;const E=Math.min(s.x,n.x),C=Math.max(s.x,n.x);S(y,E,C),0!==o?S(P,E,C):P=y;let v=0;return E<=y&&y<=C&&(a[v]=y,v++),P!==y&&E<=P&&P<=C&&(a[v]=P,v++),v}function V(t,e){e[0]>.5*Math.PI?(t[0]+=Math.PI,e[0]=Math.PI-e[0]):e[0]<.5*-Math.PI&&(t[0]-=Math.PI,e[0]=-Math.PI-e[0]),(0,n.g)(e[0]>=.5*-Math.PI&&e[0]<=.5*Math.PI)}function R(t,e,s,i,n){i=(0,r.l)(i,-r.q,r.q),n=(0,r.l)(n,-r.q,r.q);const o=r.q-.03;let a;return a=i>o&&n>o||i<-o&&n<-o?function(t,e,s){let i=1;if(e<0&&(i=-1,e=-e,s=-s),0!==t){const n=t*t,o=n*t,a=[1,(1+11*t)/12,(1+118*t+241*n)/360,(1+1089*t+10419*n+8651*o)/20160,(1+9836*t+318246*n+1027436*o+o*t*458881)/1814400],h=e=>{let s=0;const i=(0,r.e)(e)/(t-1);for(let t=a.length-1;t>=0;--t)s=a[t]+s*i;return s*=-(0,r.e)(e/(1-t)),s},m=h(r.q-e);return(h(r.q-s)-m)*i}{const t=r.q-e,n=r.q-s,o=-4*(0,r.e)(Math.sin(t/2));return(-4*(0,r.e)(Math.sin(n/2))-o)*i}}(t,i,n):Y(t,n)-Y(t,i),.5*(s-e)*a*function(t){return 1-t}(t)}function Y(t,e){if(0===e)return 0;const s=Math.sin(e);let i=s,n=s;if(0!==t){i/=1-t*s*s;const e=Math.sqrt(t);n=s*(0,r.y)(e*s)}return i+n}function X(t,e){return t/Math.sqrt(1-e)}function k(t,e){return(1-e)*t}function H(t,e,s){const i=s/(2*k(t,e)),n=i*i;return s*(1-n*(.16666666666666666-.008333333333333333*n))}function B(t,e){if(0!==e){const s=t*(0,r.aD)()/e;return Math.min(s,1e-10)}return 0}function L(t,e,s,o,a,h=!0){switch(z(o)){case 0:break;case 1:(0,n.t)("relation string length has to be 9 characters");break;default:(0,n.t)("relation string")}if(h){const i=function(t,e,s){return function(t){return"T*F**FFF*"===t}(t)?3:function(t){return"FF*FF****"===t}(t)?4:function(t,e,s){return!(0===e&&0===s||(2===e&&2===s?"F***T****"!==t:2!==e&&1!==e||0!==s||"F**T*****"!==t))}(t,e,s)?8:function(t,e,s){return e>s?"T*****T**"===t:1===e&&1===s&&"0********"===t}(t,e,s)?16:function(t){return"T**FF*FF*"===t}(t)?64:function(t){return"T*****FF*"===t}(t)?1:function(t,e,s){return e===s&&(1!==e?"T*T***T**"===t:"1*T***T**"===t)}(t,e,s)?32:0}(o,t.getDimension(),e.getDimension());if(0!==i)return ot(t,e,s,i,a)}let m=0;if("number"==typeof s)m=s;else{const n=i.a.constructEmpty();t.queryEnvelope(n);const r=i.a.constructEmpty();e.queryEnvelope(r);const o=i.a.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(r),m=(0,i.c)(s,o,!1)}const l=et(t,m),u=et(e,m);if(l.isEmpty()||u.isEmpty())return function(t,e,s){const o=(0,r.a)(9,-1);if(t.isEmpty()&&e.isEmpty())return K(o,s);let a,h=!1;t.isEmpty()?(a=e,h=!0):a=t,o[0]=-1,o[1]=-1,o[3]=-1,o[4]=-1,o[6]=-1,o[7]=-1,o[8]=2;const m=a.getGeometryType();if((0,n.f)(m))if(m===n.G.enumPolygon)if(0!==a.calculateArea2D())o[2]=2,o[5]=1;else{o[5]=-1;const t=i.a.constructEmpty();a.queryEnvelope(t),o[2]=t.height()||t.width()?1:0}else{const t=0!==a.calculateLength2D();o[2]=t?1:0,o[5]=(0,i.aJ)(a)?0:-1}else o[2]=0,o[5]=-1;return h&&tt(o),K(o,s)}(l,u,o);const c=l.getGeometryType(),g=u.getGeometryType();let _=!1;switch(c){case n.G.enumPolygon:switch(g){case n.G.enumPolygon:_=function(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setAreaAreaPredicates_();const a=i.a.constructEmpty(),h=i.a.constructEmpty();t.queryEnvelope(a),e.queryEnvelope(h);let m=!1;if(ht(a,h,s)&&(o.areaAreaDisjointPredicates_(t,e),m=!0),m||mt(t,e),!m){const n=new i.d,a=n.addGeometry(t),h=n.addGeometry(e);o.setEditShapeCrackAndCluster_(n,new i.C(s,0),r),o.computeMatrixTopoGraphHalfEdges_(a,h),o.m_topoGraph.removeShape()}return K(o.m_matrix,o.m_scl)}(l,u,m,o,a);break;case n.G.enumPolyline:_=U(l,u,m,o,a);break;case n.G.enumPoint:_=j(l,u,m,o);break;case n.G.enumMultiPoint:_=O(l,u,m,o,a)}break;case n.G.enumPolyline:switch(g){case n.G.enumPolygon:_=U(u,l,m,st(o),a);break;case n.G.enumPolyline:_=function(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setLineLinePredicates_();const a=i.a.constructEmpty(),h=i.a.constructEmpty();t.queryEnvelope(a),e.queryEnvelope(h);let m=!1;if(ht(a,h,s)&&(o.lineLineDisjointPredicates_(t,e),m=!0),m||mt(t,e),!m){const n=new i.d,a=n.addGeometry(t),h=n.addGeometry(e);o.setEditShapeCrackAndCluster_(n,new i.C(s,0),r),o.m_clusterIndexA=o.m_topoGraph.createUserIndexForClusters(),o.m_clusterIndexB=o.m_topoGraph.createUserIndexForClusters(),J(a,o.m_topoGraph,o.m_clusterIndexA),J(h,o.m_topoGraph,o.m_clusterIndexB),o.computeMatrixTopoGraphHalfEdges_(a,h),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexA),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexB),o.m_topoGraph.removeShape()}return K(o.m_matrix,o.m_scl)}(l,u,m,o,a);break;case n.G.enumPoint:_=Z(l,u,m,o,a);break;case n.G.enumMultiPoint:_=W(l,u,m,o,a)}break;case n.G.enumPoint:switch(g){case n.G.enumPolygon:_=j(u,l,m,st(o));break;case n.G.enumPolyline:_=Z(u,l,m,st(o),a);break;case n.G.enumPoint:_=function(t,e,s,i){const n=t.getXY(),o=e.getXY(),a=(0,r.a)(9,-1);return r.P.sqrDistance(n,o)<=s*s?a[0]=0:(a[2]=0,a[6]=0),a[8]=2,K(a,i)}(l,u,m,o);break;case n.G.enumMultiPoint:_=Q(u,l,m,st(o))}break;case n.G.enumMultiPoint:switch(g){case n.G.enumPolygon:_=O(u,l,m,st(o),a);break;case n.G.enumPolyline:_=W(u,l,m,st(o),a);break;case n.G.enumMultiPoint:_=function(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setPointPointPredicates_();const a=new i.a,h=new i.a;t.queryEnvelope(a),e.queryEnvelope(h);let m=!1;if(ht(a,h,s)&&(o.pointPointDisjointPredicates_(),m=!0),!m){const n=new i.d,a=n.addGeometry(t),h=n.addGeometry(e);o.setEditShapeCrackAndCluster_(n,new i.C(s,0),r),o.computeMatrixTopoGraphClusters_(a,h),o.m_topoGraph.removeShape()}return K(o.m_matrix,o.m_scl)}(l,u,m,o,a);break;case n.G.enumPoint:_=Q(l,u,m,o)}break;default:_=!1}return _}function z(t){if(9!==t.length)return 1;for(let e=0;e<9;e++){const s=t[e];if("*"!==s&&"T"!==s&&"F"!==s&&"0"!==s&&"1"!==s&&"2"!==s)return 2}return 0}function U(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setAreaLinePredicates_();const a=i.a.constructEmpty(),h=i.a.constructEmpty();t.queryEnvelope(a),e.queryEnvelope(h);let m=!1;if(ht(a,h,s)&&(o.areaLineDisjointPredicates_(t,e),m=!0),m||mt(t,e),!m){const n=new i.d,a=n.addGeometry(t),h=n.addGeometry(e);o.setEditShapeCrackAndCluster_(n,new i.C(s,0),r),o.m_clusterIndexB=o.m_topoGraph.createUserIndexForClusters(),J(h,o.m_topoGraph,o.m_clusterIndexB),o.computeMatrixTopoGraphHalfEdges_(a,h),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexB),o.m_topoGraph.removeShape()}return K(o.m_matrix,o.m_scl)}function O(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setAreaPointPredicates_();const a=i.a.constructEmpty(),h=i.a.constructEmpty();t.queryEnvelope(a),e.queryEnvelope(h);let m=!1;if(ht(a,h,s)&&(o.areaPointDisjointPredicates_(t),m=!0),m||mt(t,e),!m){const n=new i.d,a=n.addGeometry(t),h=n.addGeometry(e);o.setEditShapeCrackAndCluster_(n,new i.C(s,0),r),o.computeMatrixTopoGraphClusters_(a,h),o.m_topoGraph.removeShape()}return K(o.m_matrix,o.m_scl)}function W(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setLinePointPredicates_();const a=i.a.constructEmpty(),h=i.a.constructEmpty();t.queryEnvelope(a),e.queryEnvelope(h);let m=!1;if(ht(a,h,s)&&(o.linePointDisjointPredicates_(t),m=!0),m||mt(t,e),!m){const n=new i.d,a=n.addGeometry(t),h=n.addGeometry(e);o.setEditShapeCrackAndCluster_(n,new i.C(s,0),r),o.m_clusterIndexA=o.m_topoGraph.createUserIndexForClusters(),J(a,o.m_topoGraph,o.m_clusterIndexA),o.computeMatrixTopoGraphClusters_(a,h),o.m_topoGraph.deleteUserIndexForClusters(o.m_clusterIndexA),o.m_topoGraph.removeShape()}return K(o.m_matrix,o.m_scl)}function j(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setAreaPointPredicates_();const a=i.a.constructEmpty();t.queryEnvelope(a);const h=e.getXY();let m=!1;if(lt(h,a,s)&&(o.areaPointDisjointPredicates_(t),m=!0),!m){const e=(0,g.i)(t,h,s);if(1===e)o.m_matrix[0]=0,o.m_matrix[2]=2,o.m_matrix[3]=-1,o.m_matrix[5]=1,o.m_matrix[6]=-1;else if(2===e)if(o.m_matrix[6]=-1,0!==t.calculateArea2D())o.m_matrix[0]=-1,o.m_matrix[3]=0,o.m_matrix[2]=2,o.m_matrix[5]=1;else{o.m_matrix[0]=0,o.m_matrix[3]=-1,o.m_matrix[5]=-1;const e=i.a.constructEmpty();t.queryEnvelope(e),o.m_matrix[2]=e.height()||e.width()?1:-1}else o.areaPointDisjointPredicates_(t)}return K(o.m_matrix,n)}function Z(t,e,s,n,r){const o=new $;o.resetMatrix_(),o.setPredicates_(n),o.setLinePointPredicates_();const a=i.a.constructEmpty();t.queryEnvelope(a);let h=!1;if(lt(e.getXY(),a,s)&&(o.linePointDisjointPredicates_(t),h=!0),!h){let n=null,a=!1,h=!1;if((o.m_performPredicates[0]||o.m_performPredicates[6])&&(ot(t,e,s,4,r)?(o.m_matrix[0]=-1,o.m_matrix[6]=0):(o.m_performPredicates[0]&&(n=(0,i.Q)(t),h=!ot(n,e,s,4,r),a=!0,o.m_matrix[0]=h?-1:0),o.m_matrix[6]=-1)),o.m_performPredicates[3]&&(null!==n&&n.isEmpty()?o.m_matrix[3]=-1:(a||(null==n&&(n=(0,i.Q)(t)),h=!ot(n,e,s,4,r),a=!0),o.m_matrix[3]=h?0:-1)),o.m_performPredicates[5])if(null!==n&&n.isEmpty())o.m_matrix[5]=-1;else if(a&&!h)o.m_matrix[5]=0;else{null===n&&(n=(0,i.Q)(t));const a=ot(n,e,s,3,r);o.m_matrix[5]=a?-1:0}if(o.m_performPredicates[2])if(0!==t.calculateLength2D())o.m_matrix[2]=1;else{const n=new i.M({vd:t.getDescription()});n.addPoints(t,0,t.getPointCount());const a=ot(n,e,s,3,r);o.m_matrix[2]=a?-1:0}}return K(o.m_matrix,o.m_scl)}function Q(t,e,s,n,o){const a=new $;a.resetMatrix_(),a.setPredicates_(n),a.setPointPointPredicates_();const h=i.a.constructEmpty();t.queryEnvelope(h);const m=e.getXY(),l=new r.P;let u=!1;if(lt(m,h,s)&&(a.pointPointDisjointPredicates_(),u=!0),!u){let e=!1,i=!0;const n=s*s;for(let s=0;s<t.getPointCount()&&(t.queryXY(s,l),r.P.sqrDistance(l,m)<=n?e=!0:i=!1,!e||i);s++);e?(a.m_matrix[0]=0,a.m_matrix[2]=i?-1:0,a.m_matrix[6]=-1):(a.m_matrix[0]=-1,a.m_matrix[2]=0,a.m_matrix[6]=0)}return K(a.m_matrix,n)}function K(t,e){for(let s=0;s<9;s++)switch(e[s]){case"T":if(-1===t[s])return!1;break;case"F":if(-1!==t[s])return!1;break;case"0":if(0!==t[s])return!1;break;case"1":if(1!==t[s])return!1;break;case"2":if(2!==t[s])return!1}return!0}function J(t,e,s){const n=e.getGeometryID(t);for(let t=e.getFirstCluster();t!==i.n;t=e.getNextCluster(t)){if(!(e.getClusterParentage(t)&n))continue;const r=e.getClusterHalfEdge(t);if(r===i.n){e.setClusterUserIndex(t,s,0);continue}let o=r,a=0;do{const t=o;e.getHalfEdgeParentage(t)&n&&a++,o=e.getHalfEdgeNext(e.getHalfEdgeTwin(t))}while(o!==r);e.setClusterUserIndex(t,s,a)}}class ${nullFunc(){return(0,n.b)("should not be called"),!1}constructor(){this.m_clusterIndexA=-1,this.m_clusterIndexB=-1,this.m_visitedIndex=-1,this.m_topoGraph=new m.q,this.m_matrix=(0,r.a)(9,0),this.m_maxDim=(0,r.a)(9,0),this.m_performPredicates=(0,r.a)(9,!1),this.m_scl="",this.m_predicateCount=0,this.m_predicatesHalfEdge=this.nullFunc,this.m_predicatesCluster=this.nullFunc}resetMatrix_(){this.m_matrix.fill(-2),this.m_maxDim.fill(-2)}setPredicates_(t){this.m_scl=t;for(let t=0;t<9;t++)"*"!==this.m_scl[t]?(this.m_performPredicates[t]=!0,this.m_predicateCount++):this.m_performPredicates[t]=!1}setRemainingPredicatesToFalse_(){for(let t=0;t<9;t++)this.m_performPredicates[t]&&-2===this.m_matrix[t]&&(this.m_matrix[t]=-1,this.m_performPredicates[t]=!1)}isPredicateKnown_(t){return!(-2===this.m_matrix[t]||(-1===this.m_matrix[t]?(this.m_performPredicates[t]=!1,this.m_predicateCount--,0):"T"!==this.m_scl[t]&&"F"!==this.m_scl[t]&&this.m_matrix[t]<this.m_maxDim[t]||(this.m_performPredicates[t]=!1,this.m_predicateCount--,0)))}setAreaAreaPredicates_(){this.m_predicatesHalfEdge=this.areaAreaPredicates_,this.m_maxDim[0]=2,this.m_maxDim[1]=1,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=1,this.m_maxDim[5]=1,this.m_maxDim[6]=2,this.m_maxDim[7]=1,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaLinePredicates_(){this.m_predicatesHalfEdge=this.areaLinePredicates_,this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=2,this.m_maxDim[3]=1,this.m_maxDim[4]=0,this.m_maxDim[5]=1,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLineLinePredicates_(){this.m_predicatesHalfEdge=this.lineLinePredicates_,this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=1,this.m_maxDim[1]=0,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=0,this.m_maxDim[5]=0,this.m_maxDim[6]=1,this.m_maxDim[7]=0,this.m_maxDim[8]=2,this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setAreaPointPredicates_(){this.m_predicatesCluster=this.areaPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=2,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setLinePointPredicates_(){this.m_predicatesCluster=this.linePointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=1,this.m_maxDim[3]=0,this.m_maxDim[4]=-1,this.m_maxDim[5]=0,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}setPointPointPredicates_(){this.m_predicatesCluster=this.pointPointPredicates_,this.m_maxDim[0]=0,this.m_maxDim[1]=-1,this.m_maxDim[2]=0,this.m_maxDim[3]=-1,this.m_maxDim[4]=-1,this.m_maxDim[5]=-1,this.m_maxDim[6]=0,this.m_maxDim[7]=-1,this.m_maxDim[8]=2,this.m_performPredicates[1]&&(this.m_matrix[1]=-1,this.m_performPredicates[1]=!1,this.m_predicateCount--),this.m_performPredicates[3]&&(this.m_matrix[3]=-1,this.m_performPredicates[3]=!1,this.m_predicateCount--),this.m_performPredicates[4]&&(this.m_matrix[4]=-1,this.m_performPredicates[4]=!1,this.m_predicateCount--),this.m_performPredicates[5]&&(this.m_matrix[5]=-1,this.m_performPredicates[5]=!1,this.m_predicateCount--),this.m_performPredicates[7]&&(this.m_matrix[7]=-1,this.m_performPredicates[7]=!1,this.m_predicateCount--),this.m_performPredicates[8]&&(this.m_matrix[8]=2,this.m_performPredicates[8]=!1,this.m_predicateCount--)}areaAreaDisjointPredicates_(t,e){this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5]),this.areaGeomContainsOrDisjointPredicates_(e,this.m_performPredicates[6]?6:-1,this.m_scl[6],this.m_performPredicates[7]?7:-1,this.m_scl[7])}areaGeomContainsOrDisjointPredicates_(t,e,s,n,r){const o=-1!==e,a=-1!==n;if(o||a)if(("T"!==s&&"F"!==s&&o||"T"!==r&&"F"!==r&&a)&&0===t.calculateArea2D()){if(a&&(this.m_matrix[n]=-1),o){const s=i.a.constructEmpty();t.queryEnvelope(s),this.m_matrix[e]=s.height()||s.width()?1:0}}else o&&(this.m_matrix[e]=2),a&&(this.m_matrix[n]=1)}areaAreaContainsPredicates_(t){this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1,this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[0]?0:-1,this.m_scl[0],this.m_performPredicates[1]?1:-1,this.m_scl[1])}areaAreaWithinPredicates_(t){this.areaAreaContainsPredicates_(t),tt(this.m_matrix)}areaLineDisjointPredicates_(t,e){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[6]){const t=this.m_scl[6],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const t=(0,i.aJ)(e);this.m_matrix[7]=t?0:-1}this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaLineContainsPredicates_(t,e){if(this.m_performPredicates[0]){const t=this.m_scl[0],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[0]=s?1:0}if(this.m_performPredicates[1]){const t=(0,i.aJ)(e);this.m_matrix[1]=t?0:-1}this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1,this.m_matrix[7]=-1}areaPointDisjointPredicates_(t){this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_matrix[6]=0,this.areaGeomContainsOrDisjointPredicates_(t,this.m_performPredicates[2]?2:-1,this.m_scl[2],this.m_performPredicates[5]?5:-1,this.m_scl[5])}areaPointContainsPredicates_(t){this.m_matrix[0]=0,this.m_matrix[2]=2,this.m_matrix[3]=-1,this.m_matrix[5]=1,this.m_matrix[6]=-1}lineLineDisjointPredicates_(t,e){if(this.m_matrix[0]=-1,this.m_matrix[1]=-1,this.m_matrix[3]=-1,this.m_matrix[4]=-1,this.m_performPredicates[2]){const e=this.m_scl[2],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const e=(0,i.aJ)(t);this.m_matrix[5]=e?0:-1}if(this.m_performPredicates[6]){const t=this.m_scl[6],s="T"===t||"F"===t||0!==e.calculateLength2D();this.m_matrix[6]=s?1:0}if(this.m_performPredicates[7]){const t=(0,i.aJ)(e);this.m_matrix[7]=t?0:-1}}linePointDisjointPredicates_(t){if(this.m_matrix[0]=-1,this.m_matrix[3]=-1,this.m_performPredicates[2]){const e=this.m_scl[2],s="T"===e||"F"===e||0!==t.calculateLength2D();this.m_matrix[2]=s?1:0}if(this.m_performPredicates[5]){const e=(0,i.aJ)(t);this.m_matrix[5]=e?0:-1}this.m_matrix[6]=0}pointPointDisjointPredicates_(){this.m_matrix[0]=-1,this.m_matrix[2]=0,this.m_matrix[6]=0}areaAreaPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorArea_(t,e,s);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[1]){this.interiorAreaBoundaryArea_(t,e,1);const s=this.isPredicateKnown_(1);i&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorArea_(t,e,s,2);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.interiorAreaBoundaryArea_(t,s,3);const e=this.isPredicateKnown_(3);i&&=e}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryArea_(t,e,s);const n=this.isPredicateKnown_(4);i&&=n}if(this.m_performPredicates[5]){this.boundaryAreaExteriorArea_(t,e,s,5);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.interiorAreaExteriorArea_(t,s,e,6);const n=this.isPredicateKnown_(6);i&&=n}if(this.m_performPredicates[7]){this.boundaryAreaExteriorArea_(t,s,e,7);const n=this.isPredicateKnown_(7);i&&=n}return i}areaLinePredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorLine_(t,e,s);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[1]){this.interiorAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(1);i&&=n}if(this.m_performPredicates[2]){this.interiorAreaExteriorLine_(t,e,s);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.boundaryAreaInteriorLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[4]){this.boundaryAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(4);i&&=n}if(this.m_performPredicates[5]){this.boundaryAreaExteriorLine_(t,e,s);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.exteriorAreaInteriorLine_(t,e);const s=this.isPredicateKnown_(6);i&&=s}if(this.m_performPredicates[7]){this.exteriorAreaBoundaryLine_(t,e,s,this.m_clusterIndexB);const n=this.isPredicateKnown_(7);i&&=n}return i}lineLinePredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[1]){this.interiorLineBoundaryLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB,1);const n=this.isPredicateKnown_(1);i&&=n}if(this.m_performPredicates[2]){this.interiorLineExteriorLine_(t,e,s,2);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.interiorLineBoundaryLine_(t,s,e,this.m_clusterIndexB,this.m_clusterIndexA,3);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[4]){this.boundaryLineBoundaryLine_(t,e,s,this.m_clusterIndexA,this.m_clusterIndexB);const n=this.isPredicateKnown_(4);i&&=n}if(this.m_performPredicates[5]){this.boundaryLineExteriorLine_(t,e,s,this.m_clusterIndexA,5);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.interiorLineExteriorLine_(t,s,e,6);const n=this.isPredicateKnown_(6);i&&=n}if(this.m_performPredicates[7]){this.boundaryLineExteriorLine_(t,s,e,this.m_clusterIndexB,7);const n=this.isPredicateKnown_(7);i&&=n}return i}areaPointPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorAreaInteriorPoint_(t,e);const s=this.isPredicateKnown_(0);i&&=s}if(this.m_performPredicates[2]){this.interiorAreaExteriorPoint_(t,e);const s=this.isPredicateKnown_(2);i&&=s}if(this.m_performPredicates[3]){this.boundaryAreaInteriorPoint_(t,e,s);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[5]){this.boundaryAreaExteriorPoint_(t,e);const s=this.isPredicateKnown_(5);i&&=s}if(this.m_performPredicates[6]){this.exteriorAreaInteriorPoint_(t,e);const s=this.isPredicateKnown_(6);i&&=s}return i}linePointPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorLineInteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[2]){this.interiorLineExteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[3]){this.boundaryLineInteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(3);i&&=n}if(this.m_performPredicates[5]){this.boundaryLineExteriorPoint_(t,e,s,this.m_clusterIndexA);const n=this.isPredicateKnown_(5);i&&=n}if(this.m_performPredicates[6]){this.exteriorLineInteriorPoint_(t,e,s);const n=this.isPredicateKnown_(6);i&&=n}return i}pointPointPredicates_(t,e,s){let i=!0;if(this.m_performPredicates[0]){this.interiorPointInteriorPoint_(t,e,s);const n=this.isPredicateKnown_(0);i&&=n}if(this.m_performPredicates[2]){this.interiorPointExteriorPoint_(t,e,s,2);const n=this.isPredicateKnown_(2);i&&=n}if(this.m_performPredicates[6]){this.interiorPointExteriorPoint_(t,s,e,6);const n=this.isPredicateKnown_(6);i&&=n}return i}interiorAreaInteriorArea_(t,e,s){if(2===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t);i&e&&i&s&&(this.m_matrix[0]=2)}interiorAreaBoundaryArea_(t,e,s){if(1===this.m_matrix[s])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));i&e&&n&e&&(this.m_matrix[s]=1)}interiorAreaExteriorArea_(t,e,s,i){if(2===this.m_matrix[i])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t);n&e&&!(n&s)&&(this.m_matrix[i]=2)}boundaryAreaBoundaryArea_(t,e,s){if(1===this.m_matrix[4])return;const i=this.m_topoGraph.getHalfEdgeParentage(t);if(i&e&&i&s)this.m_matrix[4]=1;else if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const i=this.m_topoGraph.getHalfEdgeTo(t),n=this.m_topoGraph.getClusterParentage(i);if(n&e&&n&s)return void(this.m_matrix[4]=0)}}boundaryAreaExteriorArea_(t,e,s,i){if(1===this.m_matrix[i])return;const n=this.m_topoGraph.getHalfEdgeFaceParentage(t),r=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));n&s||r&s||(this.m_matrix[i]=1)}interiorAreaInteriorLine_(t,e,s){if(1===this.m_matrix[0])return;const i=this.m_topoGraph.getHalfEdgeFaceParentage(t),n=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));i&e&&n&e&&(this.m_matrix[0]=1)}interiorAreaBoundaryLine_(t,e,s,i){if(0!==this.m_matrix[1]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(!(r&e)&&this.m_topoGraph.getHalfEdgeFaceParentage(t)&e){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2!=0)return void(this.m_matrix[1]=0)}}}interiorAreaExteriorLine_(t,e,s){2!==this.m_matrix[2]&&this.m_topoGraph.getHalfEdgeParentage(t)&e&&(this.m_matrix[2]=2)}boundaryAreaInteriorLine_(t,e,s,i){if(1===this.m_matrix[3])return;const n=this.m_topoGraph.getHalfEdgeParentage(t);if(n&e&&n&s)this.m_matrix[3]=1;else if(0!==this.m_matrix[3]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(r&e){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2==0)return void(this.m_matrix[3]=0)}}}boundaryAreaBoundaryLine_(t,e,s,i){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(r&e){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2!=0)return void(this.m_matrix[4]=0)}}}boundaryAreaExteriorLine_(t,e,s){if(1===this.m_matrix[5])return;const i=this.m_topoGraph.getHalfEdgeParentage(t);i&e&&!(i&s)&&(this.m_matrix[5]=1)}exteriorAreaInteriorLine_(t,e){if(1===this.m_matrix[6])return;const s=this.m_topoGraph.getHalfEdgeFaceParentage(t),i=this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t));s&e||i&e||(this.m_matrix[6]=1)}exteriorAreaBoundaryLine_(t,e,s,i){if(0!==this.m_matrix[7]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const n=this.m_topoGraph.getHalfEdgeTo(t),r=this.m_topoGraph.getClusterParentage(n);if(!(r&e||this.m_topoGraph.getHalfEdgeFaceParentage(t)&e)){const t=this.m_topoGraph.getClusterUserIndex(n,i);if(r&s&&t%2!=0)return void(this.m_matrix[7]=0)}}}interiorLineInteriorLine_(t,e,s,i,n){if(1===this.m_matrix[0])return;const r=this.m_topoGraph.getHalfEdgeParentage(t);if(r&e&&r&s)this.m_matrix[0]=1;else if(0!==this.m_matrix[0]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(t),o=this.m_topoGraph.getClusterParentage(r);if(o&e&&o&s){const t=this.m_topoGraph.getClusterUserIndex(r,i),e=this.m_topoGraph.getClusterUserIndex(r,n);if(t%2==0&&e%2==0)return void(this.m_matrix[0]=0)}}}interiorLineBoundaryLine_(t,e,s,i,n,r){if(0!==this.m_matrix[r]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const o=this.m_topoGraph.getHalfEdgeTo(t),a=this.m_topoGraph.getClusterParentage(o);if(a&e&&a&s){const t=this.m_topoGraph.getClusterUserIndex(o,i),e=this.m_topoGraph.getClusterUserIndex(o,n);if(t%2==0&&e%2!=0)return void(this.m_matrix[r]=0)}}}interiorLineExteriorLine_(t,e,s,i){if(1===this.m_matrix[i])return;const n=this.m_topoGraph.getHalfEdgeParentage(t);n&e&&!(n&s)&&(this.m_matrix[i]=1)}boundaryLineBoundaryLine_(t,e,s,i,n){if(0!==this.m_matrix[4]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const r=this.m_topoGraph.getHalfEdgeTo(t),o=this.m_topoGraph.getClusterParentage(r);if(o&e&&o&s){const t=this.m_topoGraph.getClusterUserIndex(r,i),e=this.m_topoGraph.getClusterUserIndex(r,n);if(t%2!=0&&e%2!=0)return void(this.m_matrix[4]=0)}}}boundaryLineExteriorLine_(t,e,s,i,n){if(0!==this.m_matrix[n]&&1!==this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgePrev(this.m_topoGraph.getHalfEdgeTwin(t)),this.m_visitedIndex)){const e=this.m_topoGraph.getHalfEdgeTo(t);if(!(this.m_topoGraph.getClusterParentage(e)&s)&&this.m_topoGraph.getClusterUserIndex(e,i)%2!=0)return void(this.m_matrix[n]=0)}}interiorAreaInteriorPoint_(t,e){if(0!==this.m_matrix[0]&&!(this.m_topoGraph.getClusterParentage(t)&e)){const s=this.m_topoGraph.getClusterChain(t);if(this.m_topoGraph.getChainParentage(s)&e)return void(this.m_matrix[0]=0)}}interiorAreaExteriorPoint_(t,e){2!==this.m_matrix[2]&&this.m_topoGraph.getClusterParentage(t)&e&&(this.m_matrix[2]=2)}boundaryAreaInteriorPoint_(t,e,s){if(0===this.m_matrix[3])return;const i=this.m_topoGraph.getClusterParentage(t);i&e&&i&s&&(this.m_matrix[3]=0)}boundaryAreaExteriorPoint_(t,e){1!==this.m_matrix[5]&&this.m_topoGraph.getClusterParentage(t)&e&&(this.m_matrix[5]=1)}exteriorAreaInteriorPoint_(t,e){if(0!==this.m_matrix[6]&&!(this.m_topoGraph.getClusterParentage(t)&e)){const s=this.m_topoGraph.getClusterChain(t);if(!(this.m_topoGraph.getChainParentage(s)&e))return void(this.m_matrix[6]=0)}}interiorLineInteriorPoint_(t,e,s,i){if(0===this.m_matrix[0])return;const n=this.m_topoGraph.getClusterParentage(t);n&e&&n&s&&this.m_topoGraph.getClusterUserIndex(t,i)%2==0&&(this.m_matrix[0]=0)}interiorLineExteriorPoint_(t,e,s,i){if(1!==this.m_matrix[2])if(-1===this.m_topoGraph.getClusterHalfEdge(t)){if(0!==this.m_matrix[2]&&!(this.m_topoGraph.getClusterParentage(t)&s))return void(this.m_matrix[2]=0)}else this.m_matrix[2]=1}boundaryLineInteriorPoint_(t,e,s,i){if(0===this.m_matrix[3])return;const n=this.m_topoGraph.getClusterParentage(t);n&e&&n&s&&this.m_topoGraph.getClusterUserIndex(t,i)%2!=0&&(this.m_matrix[3]=0)}boundaryLineExteriorPoint_(t,e,s,i){if(0===this.m_matrix[5])return;const n=this.m_topoGraph.getClusterParentage(t);!(n&e)||n&s||this.m_topoGraph.getClusterUserIndex(t,i)%2==0||(this.m_matrix[5]=0)}exteriorLineInteriorPoint_(t,e,s){if(0===this.m_matrix[6])return;const i=this.m_topoGraph.getClusterParentage(t);i&e||!(i&s)||(this.m_matrix[6]=0)}interiorPointInteriorPoint_(t,e,s){if(0===this.m_matrix[0])return;const i=this.m_topoGraph.getClusterParentage(t);i&e&&i&s&&(this.m_matrix[0]=0)}interiorPointExteriorPoint_(t,e,s,i){if(0===this.m_matrix[i])return;const n=this.m_topoGraph.getClusterParentage(t);!(n&e)||n&s||(this.m_matrix[i]=0)}computeMatrixTopoGraphHalfEdges_(t,e){let s=!1;const n=this.m_topoGraph.getGeometryID(t),r=this.m_topoGraph.getGeometryID(e);this.m_visitedIndex=this.m_topoGraph.createUserIndexForHalfEdges();for(let t=this.m_topoGraph.getFirstCluster();t!==i.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===i.n){if(null!==this.m_predicatesCluster&&(s=this.m_predicatesCluster(t,n,r),s))break;continue}let o=e;do{let t=o;if(1!==this.m_topoGraph.getHalfEdgeUserIndex(t,this.m_visitedIndex))do{if(s=this.m_predicatesHalfEdge(t,n,r),s)break;this.m_topoGraph.setHalfEdgeUserIndex(t,this.m_visitedIndex,1),t=this.m_topoGraph.getHalfEdgeNext(t)}while(t!==o&&!s);if(s)break;o=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(t))}while(o!==e);if(s)break}s||this.setRemainingPredicatesToFalse_(),this.m_topoGraph.deleteUserIndexForHalfEdges(this.m_visitedIndex)}computeMatrixTopoGraphClusters_(t,e){let s=!1;const n=this.m_topoGraph.getGeometryID(t),r=this.m_topoGraph.getGeometryID(e);for(let t=this.m_topoGraph.getFirstCluster();t!==i.n&&(s=this.m_predicatesCluster(t,n,r),!s);t=this.m_topoGraph.getNextCluster(t));s||this.setRemainingPredicatesToFalse_()}setEditShape_(t,e){this.m_topoGraph.setEditShape(t,e)}setEditShapeCrackAndCluster_(t,e,s){let r=0;if(t.hasCurves()){const i=new g.C,n=t.getEnvelope2D(s),o=(0,g.d)(e.total(),n);r=(0,g.f)(o,0),(0,g.b)(t,o,e.total(),12e3,i,null,s),i.clearStitcher(t)}(0,g.e)(t,e.add(r),s,!1,!1),t.filterClosePoints(0,!0,!0,!1,i.n);for(let e=t.getFirstGeometry();e!==i.n;e=t.getNextGeometry(e))t.getGeometryType(e)===n.G.enumPolygon&&(0,m.n)(t,e,-1,!1,i.n,s);this.setEditShape_(t,s)}}function tt(t){const e=t[1],s=t[2],i=t[5];t[1]=t[3],t[2]=t[6],t[5]=t[7],t[3]=e,t[6]=s,t[7]=i}function et(t,e,s){const r=t.getGeometryType();if((0,n.e)(r)){const e=new i.i({vd:t.getDescription()});return e.addSegment(t,!0),e}if(r===n.G.enumEnvelope){const s=t,n=i.a.constructEmpty();if(t.queryEnvelope(n),n.height()<=e&&n.width()<=e){const e=new i.P({vd:t.getDescription()});return s.getCenter(e),e}if(n.height()<=e||n.width()<=e){const e=new i.i({vd:t.getDescription()}),n=new i.P;return s.queryCornerByVal(0,n),e.startPathPoint(n),s.queryCornerByVal(2,n),e.lineToPoint(n),e}const r=new i.h({vd:t.getDescription()});return r.addEnvelope(s,!1),r}return t}function st(t){return`${t[0]}${t[3]}${t[6]}${t[1]}${t[4]}${t[7]}${t[2]}${t[5]}${t[8]}`}class it{nullFunc(){return(0,n.b)("should not be called"),!1}constructor(t,e,s,r=!1){this.m_bDone=!1,this.m_tolerance=0,this.m_elementHandle=-1,this.m_query=i.a.constructEmpty(),this.m_envInter=i.a.constructEmpty(),this.m_quadTree=null,this.m_intersector=null,this.m_function=this.nullFunc;const o=t.getAccelerators();let a=null;null!=o&&(a=r?o.getQuadTreeForPaths():o.getQuadTree());const h=e.getAccelerators();let m=null;if(null!=h&&(m=r?h.getQuadTreeForPaths():h.getQuadTree()),null===a&&null===m&&!r){const r=t.getPointCount(),o=e.getPointCount();if(r>10&&o>10){const h=i.a.constructEmpty(),l=i.a.constructEmpty(),u=i.a.constructEmpty();t.queryLooseEnvelope(h),e.queryLooseEnvelope(l),h.inflateCoords(s,s),l.inflateCoords(s,s),u.setCoords({env2D:h}),u.intersect(l),r>=o?a=(0,n.f)(t.getGeometryType())?(0,i.ac)(t,u):(0,i.aN)(t,u):m=(0,n.f)(e.getGeometryType())?(0,i.ac)(e,u):(0,i.aN)(e,u)}}this.construct_(t,a,e,m,s,r)}next(){if(this.m_bQuadTree){if(this.m_bDone)return!1;for(;this.m_function(););return!this.m_bDone}return!!this.m_intersector&&this.m_intersector.next()}getRedElement(){return this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElement(this.m_elementHandle):(0,n.f)(this.m_queryType)?this.m_bPaths?this.m_pathIndex:this.m_segIter.getStartPointIndex():this.m_pointIndex:this.m_bSwapElements?this.m_intersector.getBlueElement(this.m_intersector.getHandleB()):this.m_intersector.getRedElement(this.m_intersector.getHandleA())}getBlueElement(){return this.m_bQuadTree?this.m_bSwapElements?(0,n.f)(this.m_queryType)?this.m_bPaths?this.m_pathIndex:this.m_segIter.getStartPointIndex():this.m_pointIndex:this.m_quadTree.getElement(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedElement(this.m_intersector.getHandleA()):this.m_intersector.getBlueElement(this.m_intersector.getHandleB())}getRedEnvelope(){return this.m_bPaths||(0,n.u)(""),this.m_bQuadTree?this.m_bSwapElements?this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_query:this.m_bSwapElements?this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB()):this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA())}getBlueEnvelope(){return this.m_bPaths||(0,n.u)(""),this.m_bQuadTree?this.m_bSwapElements?this.m_query:this.m_quadTree.getElementExtent(this.m_elementHandle):this.m_bSwapElements?this.m_intersector.getRedEnvelope(this.m_intersector.getHandleA()):this.m_intersector.getBlueEnvelope(this.m_intersector.getHandleB())}construct_(t,e,s,r,o,a){const h=i.a.constructEmpty(),m=i.a.constructEmpty();t.queryLooseEnvelope(h),s.queryLooseEnvelope(m),h.inflateCoords(o,o),m.inflateCoords(o,o),this.m_envInter.setCoords({env2D:h}),this.m_envInter.intersect(m),this.m_multiVertexImplA=t,this.m_multiVertexImplB=s;const l=t.getGeometryType(),u=s.getGeometryType();this.m_bPaths=a,this.m_pathIndex=-1,this.m_pointIndex=-1,this.m_bSwapElements=!1,this.m_queryType=n.G.enumUnknown,this.m_bQuadTree=!1,null!==e&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=e,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!0,(0,n.f)(u)?(this.m_queryType=u,this.m_function=this.nextPath_,a?this.m_pathIndex=s.getPathCount():this.m_segIter=s.querySegmentIterator()):(this.m_queryType=u,this.m_function=this.nextPoint_,this.m_pointIndex=s.getPointCount())),this.m_bQuadTree||null!==r&&(this.m_bDone=!1,this.m_tolerance=o,this.m_quadTree=r,this.m_qtIter=this.m_quadTree.getIteratorForQT(),this.m_bQuadTree=!0,this.m_bSwapElements=!1,(0,n.f)(l)?(this.m_queryType=l,this.m_function=this.nextPath_,a?this.m_pathIndex=t.getPathCount():this.m_segIter=t.querySegmentIterator()):(this.m_queryType=l,this.m_function=this.nextPoint_,this.m_pointIndex=t.getPointCount())),this.m_bQuadTree||(a&&(0,n.f)(l)&&(0,n.f)(u)?this.m_intersector=(0,i.aR)(t,s,o):(0,n.f)(l)&&(0,n.f)(u)?(this.m_intersector=(0,i.aO)(t,s,o),this.m_bSwapElements=!1):(0,n.f)(l)&&!(0,n.f)(u)?(this.m_intersector=(0,i.aP)(t,s,o),this.m_bSwapElements=!1):!(0,n.f)(l)&&(0,n.f)(u)?(this.m_intersector=(0,i.aP)(s,t,o),this.m_bSwapElements=!0):(this.m_intersector=(0,i.aQ)(t,s,o),this.m_bSwapElements=!1))}nextPath_(){return this.m_bPaths?-1==--this.m_pathIndex?(this.m_bDone=!0,!1):(this.m_bSwapElements?this.m_multiVertexImplB.queryPathEnvelope(this.m_pathIndex,this.m_query):this.m_multiVertexImplA.queryPathEnvelope(this.m_pathIndex,this.m_query),this.m_qtIter.resetIterator(this.m_query,this.m_tolerance),this.m_function=this.iterate_,!0):this.m_segIter.nextPath()?(this.m_function=this.nextSegment_,!0):(this.m_bDone=!0,!1)}nextSegment_(){if(!this.m_segIter.hasNextSegment())return this.m_function=this.nextPath_,!0;const t=this.m_segIter.nextSegment(),e=new i.a;return t.queryLooseEnvelope(e),!e.isIntersecting(this.m_envInter)||(this.m_qtIter.resetIterator(t,this.m_tolerance),this.m_function=this.iterate_,!0)}nextPoint_(){if(-1==--this.m_pointIndex)return this.m_bDone=!0,!1;const t=new r.P;if(this.m_bSwapElements){const e=this.m_multiVertexImplB.getXY(this.m_pointIndex);t.setCoordsPoint2D(e)}else{const e=this.m_multiVertexImplA.getXY(this.m_pointIndex);t.setCoordsPoint2D(e)}return!this.m_envInter.contains(t)||(this.m_qtIter.resetIterator(i.a.construct(t.x,t.y,t.x,t.y),this.m_tolerance),this.m_function=this.iterate_,!0)}iterate_(){return this.m_elementHandle=this.m_qtIter.next(),-1===this.m_elementHandle&&((0,n.f)(this.m_queryType)?(this.m_function=this.m_bPaths?this.nextPath_:this.nextSegment_,!0):(this.m_function=this.nextPoint_,!0))}}function nt(t){return 2===t?1:1===t?2:128===t?64:64===t?128:t}function rt(t,e,s){let n;if(t instanceof Vi||null===t){const r=i.a.constructEmpty();r.setCoords({env2D:e}),r.mergeEnvelope2D(s),n=(0,i.c)(t,r,!1)}else n=t;return n}function ot(t,e,s,o,h){if(t.isEmpty()||e.isEmpty())return 4===o;(0,n.c)(t),(0,n.c)(e);let m=t.getGeometryType(),l=e.getGeometryType();if(m===n.G.enumEnvelope){if(l===n.G.enumEnvelope)return function(t,e,s,n){if(t.isEmpty()||e.isEmpty())return 4===n;const r=i.a.constructEmpty();t.queryEnvelope(r);const o=i.a.constructEmpty();e.queryEnvelope(o);const a=rt(s,r,o);switch(n){case 4:return ht(r,o,a);case 2:return Rt(o,r,a,!1);case 128:return Rt(o,r,a,!0);case 1:return Rt(r,o,a,!1);case 64:return Rt(r,o,a,!0);case 3:return Vt(r,o,a);case 8:return function(t,e,s){if(t.height()<=s||t.width()<=s||e.height()<=s||e.width()<=s)return!1;const n=new i.a;return n.setCoords({env2D:t}),n.inflateCoords(-s,-s),n.intersect(e),!(!n.isEmpty()&&n.height()>s&&n.width()>s||(n.setCoords({env2D:t}),n.inflateCoords(s,s),n.intersect(e),n.isEmpty()))}(r,o,a);case 32:return function(t,e,s){if(t.height()<=s||t.width()<=s||e.height()<=s||e.width()<=s)return!1;if(kt(t,e,s))return!1;if(kt(e,t,s))return!1;const n=new i.a;return n.setCoords({env2D:t}),n.inflateCoords(-s,-s),n.intersect(e),!n.isEmpty()&&(n.height()>s||n.width()>s)}(r,o,a);case 16:return!1}return!1}(t,e,s,o);if(l===n.G.enumPoint)return at(e,t,s,nt(o))}else if(m===n.G.enumPoint){if(l===n.G.enumEnvelope)return at(t,e,s,o);if(l===n.G.enumPoint)return function(t,e,s,n){if(t.isEmpty()||e.isEmpty())return 4===n;const o=t.getXY(),a=e.getXY();let h;if(s instanceof Vi||null===s){const t=i.a.constructEmpty();t.setCoords({pt:o}),t.merge(a),h=(0,i.c)(s,t,!1)}else h=s;switch(n){case 4:return function(t,e,s){return r.P.sqrDistance(t,e)>s*s}(o,a,h);case 2:case 128:return Ft(a,o,h);case 1:case 64:return Ft(o,a,h);case 3:return qt(o,a,h)}return!1}(t,e,s,o)}const u=i.a.constructEmpty();t.queryEnvelope(u);const c=i.a.constructEmpty();e.queryEnvelope(c);const g=rt(s,u,c);if(ht(u,c,g))return 4===o;let _=!1,d=null,p=null,f=null,x=null;switch((0,n.e)(m)?(d=new i.i({vd:t.getDescription()}),d.addSegment(t,!0),f=d,m=n.G.enumPolyline):f=t,(0,n.e)(l)?(p=new i.i({vd:e.getDescription()}),p.addSegment(e,!0),x=p,l=n.G.enumPolyline):x=e,m!==n.G.enumEnvelope&&l!==n.G.enumEnvelope?(f.getDimension()<x.getDimension()||m===n.G.enumPoint&&l===n.G.enumMultiPoint)&&(o=nt(o)):m!==n.G.enumPolygon&&l!==n.G.enumEnvelope&&(o=nt(o)),m){case n.G.enumPolygon:switch(l){case n.G.enumPolygon:_=function(t,e,s,i,n){switch(i){case 4:return function(t,e,s){return mt(t,e,0,!0),1===Yt(t,e,s,!0)}(t,e,s);case 2:return Et(e,t,s,n);case 128:return Ct(e,t,s);case 1:return Et(t,e,s,n);case 64:return Ct(t,e,s);case 3:return Pt(t,e,s,n);case 8:return function(t,e,s){return mt(t,e),Jt(t,e,s,null)}(t,e,s);case 32:return function(t,e,s,i){return mt(t,e),$t(t,e,s,i)}(t,e,s,n)}return!1}(f,x,g,o,h);break;case n.G.enumPolyline:_=ut(f,x,g,o,h);break;case n.G.enumPoint:_=ct(f,x,g,o);break;case n.G.enumMultiPoint:_=gt(f,x,g,o);break;case n.G.enumEnvelope:_=_t(f,x,g,o,h)}break;case n.G.enumPolyline:switch(l){case n.G.enumPolygon:_=ut(x,f,g,o,h);break;case n.G.enumPolyline:_=function(t,e,s,n,r){switch(n){case 4:return function(t,e,s){mt(t,e);const i=t.getImpl(),n=e.getImpl();return!new it(i,n,s,!0).next()||!Wt(t,e,s)}(t,e,s);case 2:return wt(e,t,s,r);case 128:return Dt(e,t,s,r);case 1:return wt(t,e,s,r);case 64:return Dt(t,e,s,r);case 3:return function(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!Vt(r,o,s)&&(mt(t,e),!!Lt(t,e,s)||(t.hasNonLinearSegments()||e.hasNonLinearSegments()?L(t,e,s,"**F**FFF*",n,!1):Ut(t,e,s,!1)))}(t,e,s,r);case 8:return function(t,e,s,n){mt(t,e);const r=[],o=jt(t,e,s,r);if(-2===o){const r=i.a.constructEmpty(),o=i.a.constructEmpty(),h=i.a.constructEmpty();let m,l;if(t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),h.setCoords({env2D:r}),h.intersect(o),t.getPointCount()>10){if(m=(0,a.c)(t,h,s,0,n),m.isEmpty())return!1}else m=t;if(e.getPointCount()>10){if(l=(0,a.c)(e,h,s,0,n),l.isEmpty())return!1}else l=e;return L(m,l,s,"F********",n,!1)}if(0!==o)return!1;const h=new i.M;for(let t=0;t<r.length;t+=2){const e=r[t],s=r[t+1];h.addXY(e,s)}const m=t.getBoundary(),l=e.getBoundary();return m.addPoints(l,0,l.getPointCount()),!m.isEmpty()&&Nt(m,h,s)}(t,e,s,r);case 32:return function(t,e,s,n){mt(t,e);const r=i.a.constructEmpty(),o=i.a.constructEmpty();t.queryEnvelope(r),e.queryEnvelope(o);const h=Bt(r,o,s),m=Bt(o,r,s),l=t.hasNonLinearSegments(),u=e.hasNonLinearSegments(),c=jt(t,e,s,null);if(-1===c)return!1;if(1===c){if(h&&m)return!0;if(!l&&!u)return h&&!m?!Ot(e,t,s,!1):m&&!h?!Ot(t,e,s,!1):!Ot(t,e,s,!1)&&!Ot(e,t,s,!1)}const g=i.a.constructEmpty(),_=i.a.constructEmpty(),d=i.a.constructEmpty();let p,f;g.setCoords({env2D:r}),g.inflateCoords(1e3*s,1e3*s),_.setCoords({env2D:o}),_.inflateCoords(1e3*s,1e3*s),d.setCoords({env2D:g}),d.intersect(_);let x="";if(x+="1*",h){if(e.getPointCount()>10){if(f=(0,a.c)(e,d,s,0,n),f.isEmpty())return!1}else f=e;x+="****"}else f=e,x+="T***";if(m){if(t.getPointCount()>10){if(p=(0,a.c)(t,d,s,0,n),p.isEmpty())return!1}else p=t;x+="***"}else p=t,x+="T**";return L(p,f,s,x,n,!1)}(t,e,s,r);case 16:return function(t,e,s,n){mt(t,e);const r=[],o=jt(t,e,s,r);if(-2===o){const r=i.a.constructEmpty(),o=i.a.constructEmpty(),h=i.a.constructEmpty();let m,l;if(t.queryEnvelope(r),e.queryEnvelope(o),r.inflateCoords(1e3*s,1e3*s),o.inflateCoords(1e3*s,1e3*s),h.setCoords({env2D:r}),h.intersect(o),t.getPointCount()>10){if(m=(0,a.c)(t,h,s,0,n),m.isEmpty())return!1}else m=t;if(e.getPointCount()>10){if(l=(0,a.c)(e,h,s,0,n),l.isEmpty())return!1}else l=e;return L(m,l,s,"0********",n,!1)}if(0!==o)return!1;const h=new i.M;for(let t=0;t<r.length;t+=2){const e=r[t],s=r[t+1];h.addXY(e,s)}const m=t.getBoundary(),l=e.getBoundary();return m.addPoints(l,0,l.getPointCount()),!!m.isEmpty()||!Nt(m,h,s)}(t,e,s,r)}return!1}(f,x,g,o,h);break;case n.G.enumPoint:_=dt(f,x,g,o);break;case n.G.enumMultiPoint:_=pt(f,x,g,o);break;case n.G.enumEnvelope:_=ft(f,x,g,o,h)}break;case n.G.enumPoint:switch(l){case n.G.enumPolygon:_=ct(x,f,g,o);break;case n.G.enumPolyline:_=dt(x,f,g,o);break;case n.G.enumMultiPoint:_=xt(x,f,g,o)}break;case n.G.enumMultiPoint:switch(l){case n.G.enumPolygon:_=gt(x,f,g,o);break;case n.G.enumPolyline:_=pt(x,f,g,o);break;case n.G.enumMultiPoint:_=function(t,e,s,n){switch(n){case 4:return function(t,e,s){const i=t,n=e,o=new it(i,n,s,!1),a=s*s,h=new r.P,m=new r.P;for(;o.next();){const t=o.getRedElement(),e=o.getBlueElement();if(i.queryXY(t,h),n.queryXY(e,m),r.P.sqrDistance(h,m)<=a)return!1}return!0}(t,e,s);case 2:case 128:return Nt(e,t,s);case 1:case 64:return Nt(t,e,s);case 3:return function(t,e,s){const n=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(o),!!Vt(n,o,s)&&(!!function(t,e,s){if(t.getPointCount()!==e.getPointCount())return!1;const i=new r.P,n=new r.P;let o=!0;const a=s*s;for(let s=0;s<t.getPointCount();s++)if(t.queryXY(s,i),e.queryXY(s,n),r.P.sqrDistance(i,n)>a){o=!1;break}return!!o}(t,e,s)||zt(t,e,s,!1,!0,!1))}(t,e,s);case 32:return function(t,e,s){return zt(t,e,s,!1,!1,!0)}(t,e,s)}return!1}(f,x,g,o);break;case n.G.enumPoint:_=xt(f,x,g,o);break;case n.G.enumEnvelope:_=yt(f,x,g,o)}break;case n.G.enumEnvelope:switch(l){case n.G.enumPolygon:_=_t(x,f,g,o,h);break;case n.G.enumPolyline:_=ft(x,f,g,o,h);break;case n.G.enumMultiPoint:_=yt(x,f,g,o)}}return _}function at(t,e,s,n,r){if(t.isEmpty()||e.isEmpty())return 4===n;const o=t.getXY(),a=i.a.constructEmpty();e.queryEnvelope(a);const h=function(t,e,s){let n;if(t instanceof Vi||null===t){const r=i.a.constructEmpty();r.setCoords({pt:e}),r.mergeEnvelope2D(s),n=(0,i.c)(t,r,!1)}else n=t;return n}(s,o,a);switch(n){case 4:return lt(o,a,h);case 2:case 128:return function(t,e,s){if(e.height()<=s||e.width()<=s)return!1;const n=i.a.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(-s,-s),n.containsExclusive(t)}(o,a,h);case 1:case 64:return!1;case 3:return function(t,e,s){const n=new i.a;return n.setCoords({pt:t}),Vt(n,e,s)}(o,a,h);case 8:return function(t,e,s){if(e.height()<=s||e.width()<=s)return!1;const n=new i.a,r=new i.a;return n.setCoords({env2D:e}),n.inflateCoords(s,s),!!n.contains(t)&&(r.setCoords({env2D:e}),r.inflateCoords(-s,-s),!r.containsExclusive(t))}(o,a,h)}return!1}function ht(t,e,s){const n=i.a.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),!t.isIntersecting(n)}function mt(t,e,s,i=!1){const r=t.getGeometryType(),o=e.getGeometryType();if((0,n.i)(r)){const e=t.getImpl().getAccelerators();if(null!==e){const t=e.getRasterizedGeometry();(0,n.g)(null===t)}}if((0,n.i)(o)){const t=e.getImpl().getAccelerators();if(null!==t){const e=t.getRasterizedGeometry();(0,n.g)(null===e)}}return 0}function lt(t,e,s,n){const r=i.a.constructEmpty();return r.setCoords({env2D:e}),r.inflateCoords(s,s),!r.contains(t)}function ut(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return mt(t,e,0,!0),1===Yt(t,e,s,!0)}(t,e,s);case 1:return function(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!kt(r,o,s)&&(mt(t,e),function(t,e,s,n){const r=[!1],o=Xt(t,e,s,r);if(r[0])return o;const h=i.a.constructEmpty();let m;if(e.queryEnvelope(h),h.inflateCoords(1e3*s,1e3*s),t.getPointCount()>10){if(m=(0,a.c)(t,h,s,0,n),m.isEmpty())return!1}else m=t;return function(t,e,s,n){const r=new $;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaLinePredicates_();const o=i.a.constructEmpty(),a=i.a.constructEmpty();t.queryEnvelope(o),e.queryEnvelope(a);let h=!1;if(ht(o,a,s)&&(r.areaLineDisjointPredicates_(t,e),h=!0),h||mt(t,e),h)return K(r.m_matrix,r.m_scl);const m=new i.d,l=m.addGeometry(t),u=m.addGeometry(e);return r.setEditShapeCrackAndCluster_(m,new i.C(s,0),n),0!==m.getPointCount(l)&&(r.computeMatrixTopoGraphHalfEdges_(l,u),r.m_topoGraph.removeShape(),K(r.m_matrix,r.m_scl))}(m,e,s,n)}(t,e,s,n))}(t,e,s,o);case 64:return function(t,e,s){const n=i.a.constructEmpty(),r=i.a.constructEmpty();return t.queryEnvelope(n),e.queryEnvelope(r),!!kt(n,r,s)&&(mt(t,e),2===Yt(t,e,s,!1))}(t,e,s);case 8:return vt(t,e,s,o);case 16:return function(t,e,s){return mt(t,e),function(t,e,s,n){const o=t.getImpl(),h=e.getImpl(),m=o.querySegmentIterator(),l=h.querySegmentIterator(),u=(0,r.a)(2,Number.NaN),c=(0,r.a)(2,Number.NaN),g=new it(o,h,s);let _=!1;for(;g.next();){const t=g.getRedElement(),e=g.getBlueElement();m.resetToVertex(t,-1),l.resetToVertex(e,-1);const i=m.nextSegment(),n=l.nextSegment();let r=0;if(ie(i,n)?!_&&n.isIntersecting(i,s)&&(_=!0):r=n.intersect(i,null,c,u,s),2===r)_=!0;else if(r){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return!0;_=!0}}if(!_)return!1;const d=i.a.constructEmpty(),p=i.a.constructEmpty(),f=i.a.constructEmpty(),x=i.a.constructEmpty(),y=i.a.constructEmpty();if(t.queryEnvelope(d),e.queryEnvelope(p),Bt(p,d,s)){let i,r;if(f.setCoords({env2D:d}),f.inflateCoords(1e3*s,1e3*s),x.setCoords({env2D:p}),x.inflateCoords(1e3*s,1e3*s),y.setCoords({env2D:f}),y.intersect(x),t.getPointCount()>10){if(i=(0,a.c)(t,y,s,0,n),i.isEmpty())return!1}else i=t;if(e.getPointCount()>10){if(r=(0,a.c)(e,y,s,0,n),r.isEmpty())return!1}else r=e;return L(i,r,s,"T********",n,!1)}return L(t,e,s,"T*****T**",n,!1)}(t,e,s,null)}(t,e,s)}return!1}function ct(t,e,s,i,n){switch(i){case 4:return function(t,e,s){return 0===(0,g.m)(t,e,s)}(t,e,s);case 1:case 64:return function(t,e,s){return function(t,e,s){return 1===(0,g.i)(t,e,s)}(t,e.getXY(),s)}(t,e,s);case 8:return function(t,e,s){return function(t,e,s){return 2===(0,g.i)(t,e,s)}(t,e.getXY(),s)}(t,e,s)}return!1}function gt(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return mt(t,e),1===function(t,e,s){const n=i.a.constructEmpty();t.queryEnvelope(n),n.inflateCoords(s,s);const o=new r.P,a=t.getImpl(),h=new i.h;let m=t,l=!1,u=!1,c=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,o),n.contains(o)){const t=(0,g.i)(m,o,s);if(1===t)return u=!0,4;if(2===t)return 4;c=!0}else c=!0;l||(!(0,g.r)(t,e.getPointCount()-1)||null!==a.getAccelerators()&&null!=a.getAccelerators().getQuadTree()?m=t:(t.copyTo(h),h.getImpl().buildQuadTreeAccelerator(1),m=h),l=!0)}return u?c?4:2:1}(t,e,s)}(t,e,s);case 1:return bt(t,e,s,!1);case 64:return bt(t,e,s,!0);case 8:return function(t,e,s){mt(t,e);const n=i.a.constructEmpty();t.queryEnvelope(n),n.inflateCoords(s,s);const o=new r.P;let a=!1;const h=t.getImpl(),m=new i.h;let l=t,u=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,o),n.contains(o)){const t=(0,g.i)(l,o,s);if(2===t)a=!0;else if(1===t)return!1}u||(!(0,g.r)(t,e.getPointCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?l=t:(t.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),u=!0)}return!!a}(t,e,s);case 16:return function(t,e,s){mt(t,e);const n=new i.a,o=new i.a,a=new i.a;t.queryEnvelope(n),e.queryEnvelope(a),o.setCoords({env2D:n}),o.inflateCoords(s,s);let h=!1,m=!1;const l=new r.P,u=t.getImpl(),c=new i.h;let _=t,d=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,l),o.contains(l)){const t=(0,g.i)(_,l,s);0===t?m=!0:1===t&&(h=!0)}else m=!0;if(h&&m)return!0;d||(!(0,g.r)(t,e.getPointCount()-1)||null!==u.getAccelerators()&&null!==u.getAccelerators().getQuadTree()?_=t:(t.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),_=c),d=!0)}return!1}(t,e,s)}return!1}function _t(t,e,s,n,r){if(function(t,e,s){mt(t,e);const n=i.a.constructEmpty(),r=i.a.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),kt(r,n,s))return!1;const o=r.getLowerLeft();return 0===(0,g.i)(t,o,0)&&!r.contains(t.getXY(0))&&!Kt(t,r,s)}(t,e,s))return 4===n;if(4===n)return!1;switch(n){case 2:return St(t,e,s,!1);case 128:return St(t,e,s,!0);case 1:return It(t,e,s,!1,r);case 64:return It(t,e,s,!0,r);case 3:return function(t,e,s,n){const r=new i.a,o=new i.a;if(t.queryEnvelope(r),e.queryEnvelope(o),!Vt(r,o,s))return!1;const a=new i.h;return a.addEnvelope(e,!1),Pt(t,a,s,n)}(t,e,s,r);case 8:return function(t,e,s,n){mt(t,e);const r=new i.a,o=new i.a;if(t.queryEnvelope(r),e.queryEnvelope(o),kt(o,r,s))return!1;if(o.height()<=s||o.width()<=s)return!1;const a=new i.h;return a.addEnvelope(e,!1),Jt(t,a,s,n)}(t,e,s,r);case 32:return function(t,e,s,n){mt(t,e);const r=new i.a,o=new i.a;if(t.queryEnvelope(r),e.queryEnvelope(o),kt(o,r,s))return!1;if(o.height()<=s||o.width()<=s)return!1;const a=new i.h;return a.addEnvelope(e,!1),$t(t,a,s,n)}(t,e,s,r);case 16:return!1}return!1}function dt(t,e,s,i,n){switch(i){case 4:return function(t,e,s){return mt(t,e),!Qt(t,e.getXY(),s)}(t,e,s);case 1:case 64:return function(t,e,s){return mt(t,e),function(t,e,s){return Qt(t,e,s)&&!se(t,e,s)}(t,e.getXY(),s)}(t,e,s);case 8:return function(t,e,s){return mt(t,e),se(t,e.getXY(),s)}(t,e,s)}return!1}function pt(t,e,s,n,o){switch(n){case 4:return function(t,e,s){return mt(t,e),!Zt(t,e,s,!1)}(t,e,s);case 1:case 64:return function(t,e,s){const n=i.a.constructEmpty(),r=i.a.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(r),!kt(n,r,s))return!1;mt(t,e);const o=Zt(t,e,s,!0);if(!o)return o;const a=t.getBoundary();return a.isEmpty()?o:!Nt(a,e,s)}(t,e,s);case 8:return function(t,e,s){mt(t,e);const n=t.getImpl(),r=e.getImpl(),o=new i.M,a=new it(n,r,s,!1),h=n.querySegmentIterator();let m=!1;for(;a.next();){const t=a.getRedElement(),e=a.getBlueElement();h.resetToVertex(t,-1);const i=h.nextSegment(),n=r.getXY(e);i.isIntersectingPoint(n,s)&&(m=!0,o.addPoint2D(n))}if(!m)return!1;const l=t.getBoundary();return!l.isEmpty()&&Nt(l,o,s)}(t,e,s);case 16:return function(t,e,s){mt(t,e);const n=t.getImpl(),o=e.getImpl(),a=o.getPointCount(),h=(0,r.a)(a,!1),m=new it(n,o,s,!1),l=n.querySegmentIterator();let u=!1;for(;m.next();){const t=m.getRedElement(),e=m.getBlueElement();l.resetToVertex(t,-1);const i=l.nextSegment(),n=o.getXY(e);i.isIntersectingPoint(n,s)&&(u=!0,h[e]=!0)}if(!u)return!1;let c=!1;for(let t=0;t<a;t++)if(!h[t]){c=!0;break}if(!c)return!1;const g=t.getBoundary();if(g.isEmpty())return!0;const _=new i.M;for(let t=0;t<a;t++)h[t]&&_.addPoint2D(o.getXY(t));return!Nt(g,_,s)}(t,e,s)}return!1}function ft(t,e,s,o,a){if(function(t,e,s){const n=i.a.constructEmpty(),r=i.a.constructEmpty();t.queryEnvelope(n),e.queryEnvelope(r);const o=function(t,e,s){const n=i.a.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),n.containsEnvelope(e)?1073741824:n.isIntersecting(e)?t.isIntersecting(e)?t.xmin<e.xmin&&e.xmax<t.xmax?e.ymin<t.ymin&&e.ymax>t.ymax?0:1073741824:t.ymin<e.ymin&&e.ymax<t.ymax?e.xmin<t.xmin&&e.xmax>t.xmax?0:1073741824:0:0:4}(r,n,s);return 0===o?!Kt(t,r,s):4===o}(t,e,s))return 4===o;if(4===o)return!1;switch(o){case 2:return Tt(t,e,s,!1);case 128:return Tt(t,e,s,!0);case 1:case 64:case 32:return!1;case 3:return function(t,e,s){const n=new i.a,r=new i.a;return t.queryEnvelope(n),e.queryEnvelope(r),!(r.height()>s&&r.width()>s)&&Vt(n,r,s)}(t,e,s);case 8:return function(t,e,s,o){const a=new i.a,h=new i.a;if(t.queryEnvelope(a),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;const m=new i.a,l=new i.a;if(m.setCoords({env2D:h}),l.setCoords({env2D:h}),m.inflateCoords(s,s),l.inflateCoords(-s,-s),l.containsEnvelope(a)||!a.isIntersecting(m))return!1;const u=t.getImpl().querySegmentIterator();u.stripAttributes();const c=t.getImpl().getAccelerators();let g=null,_=null;null!==c&&(g=c.getQuadTree(),null!==g&&(_=g.getIterator(h,s))),_||u.nextPath()||(0,n.b)("relational_operations");let d=!1,p=null;const f=new r.P,x=new r.P,y=t.hasNonLinearSegments();let P=!1;for(;;){if(null!==_){const t=_.next();if(-1===t)break;u.resetToVertex(g.getElement(t),-1),p=u.nextSegment()}else{for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;p=u.nextSegment()}if(y&&p.getGeometryType()!==n.G.enumLine){const t=new i.a;if(p.queryEnvelope(t),l.containsEnvelope(t))return!1;if(m.isIntersecting(t)){P=!0;break}}else{f.assign(p.getStartXY()),x.assign(p.getEndXY());let t=l.clipLine(f,x);if(0!==t)return!1;d||(t=m.clipLine(f,x),0!==t&&(d=!0))}}if(!P)return d;const E=new i.h;return E.addEnvelope(h,!1),vt(E,t,s,o)}(t,e,s,a);case 16:return function(t,e,s){const o=new i.a,a=new i.a;if(t.queryEnvelope(o),e.queryEnvelope(a),a.height()<=s||a.width()<=s)return!1;const h=new i.a;if(h.setCoords({env2D:a}),h.inflateCoords(s,s),h.containsEnvelope(o))return!1;const m=new i.a;if(m.setCoords({env2D:a}),m.inflateCoords(-s,-s),!m.isIntersecting(o))return!1;const l=t.getImpl().querySegmentIterator();l.stripAttributes();const u=t.getImpl().getAccelerators();let c=null,g=null;if(null!==u&&(c=u.getQuadTree(),null!==c&&(g=c.getIterator(a,s))),!g){const t=l.nextPath();(0,n.g)(t)}let _=!1,d=null;const p=new r.P,f=new r.P;let x=null,y=null,P=null,E=null;for(t.hasNonLinearSegments()&&(x=new i.L,y=new i.L,P=new i.L,E=new i.L,m.querySide(0,x),m.querySide(1,y),m.querySide(2,P),m.querySide(3,E));;){if(null!==g){const t=g.next();if(-1===t)break;l.resetToVertex(c.getElement(t),-1),d=l.nextSegment()}else{for(;!l.hasNextSegment()&&l.nextPath(););if(!l.hasNextSegment())break;d=l.nextSegment()}if(d.getGeometryType()===n.G.enumLine){if(p.assign(d.getStartXY()),f.assign(d.getEndXY()),0!==m.clipLine(p,f)){_=!0;break}}else{if(x.isIntersecting(d,s)){_=!0;break}if(y.isIntersecting(d,s)){_=!0;break}if(P.isIntersecting(d,s)){_=!0;break}if(E.isIntersecting(d,s)){_=!0;break}}}return _&&!0}(t,e,s)}return!1}function xt(t,e,s,i,n){switch(i){case 4:return Mt(t,e,s);case 2:case 128:return function(t,e,s){return At(t,e,s)}(t,e,s);case 1:case 64:return function(t,e,s){return!Mt(t,e,s)}(t,e,s);case 3:return At(t,e,s)}return!1}function yt(t,e,s,n,o){switch(n){case 4:return function(t,e,s){const n=i.a.constructEmpty(),o=i.a.constructEmpty();if(t.queryEnvelope(n),e.queryEnvelope(o),kt(o,n,s))return!1;const a=i.a.constructEmpty();a.setCoords({env2D:o}),a.inflateCoords(s,s);const h=new r.P;for(let e=0;e<t.getPointCount();e++)if(t.queryXY(e,h),a.contains(h))return!1;return!0}(t,e,s);case 2:return Gt(t,e,s,!1);case 128:return Gt(t,e,s,!0);case 1:case 64:return!1;case 3:return function(t,e,s){const n=new i.a,r=new i.a;return t.queryEnvelope(n),e.queryEnvelope(r),!(r.height()>s||r.width()>s)&&Vt(n,r,s)}(t,e,s);case 8:return function(t,e,s){const n=new i.a,o=new i.a,a=new i.a;if(e.queryEnvelope(n),n.height()<=s||n.width()<=s)return!1;o.setCoords({env2D:n}),a.setCoords({env2D:n}),o.inflateCoords(s,s),a.inflateCoords(-s,-s);const h=new r.P;let m=!1;for(let e=0;e<t.getPointCount();e++)if(t.queryXY(e,h),o.contains(h)){if(a.containsExclusive(h))return!1;m=!0}return m}(t,e,s);case 16:return function(t,e,s){const n=new i.a,o=new i.a;if(t.queryEnvelope(n),e.queryEnvelope(o),kt(o,n,s))return!1;if(o.height()<=s||o.width()<=s)return!1;const a=new i.a,h=new i.a;a.setCoords({env2D:o}),a.inflateCoords(-s,-s),h.setCoords({env2D:o}),h.inflateCoords(s,s);const m=new r.P;let l=!1,u=!1;for(let e=0;e<t.getPointCount();e++)if(t.queryXY(e,m),!l&&a.containsExclusive(m)&&(l=!0),u||h.contains(m)||(u=!0),l&&u)return!0;return!1}(t,e,s)}return!1}function Pt(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();if(t.queryEnvelope(r),e.queryEnvelope(o),!Vt(r,o,s))return!1;if(mt(t,e),Lt(t,e,s))return!0;const a=t.calculateLength2D(),h=e.calculateLength2D(),m=Math.max(t.getPointCount(),e.getPointCount());return!(Math.abs(a-h)>4*m*s)&&(t.hasNonLinearSegments()||e.hasNonLinearSegments()?L(t,e,s,"**F**FFF*",n,!1):Ut(t,e,s,!0))}function Et(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!kt(r,o,s)&&(mt(t,e),te(t,e,s,n))}function Ct(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!kt(r,o,s)&&(mt(t,e),2===Yt(t,e,s,!1))}function vt(t,e,s,n){return mt(t,e),function(t,e,s,n){const o=t.getImpl(),h=e.getImpl(),m=o.querySegmentIterator(),l=h.querySegmentIterator(),u=(0,r.a)(2,Number.NaN),c=(0,r.a)(2,Number.NaN),g=new it(o,h,s);let _=!1;for(;g.next();){const t=g.getRedElement(),e=g.getBlueElement();m.resetToVertex(t,-1),l.resetToVertex(e,-1);const i=m.nextSegment(),n=l.nextSegment();let r=0;if(ie(i,n)?!_&&n.isIntersecting(i,s)&&(_=!0):r=n.intersect(i,null,c,u,s),2===r)_=!0;else if(r){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return!1;_=!0}}if(!_)return!1;const d=i.a.constructEmpty(),p=i.a.constructEmpty(),f=i.a.constructEmpty();let x,y;if(t.queryEnvelope(d),e.queryEnvelope(p),d.inflateCoords(1e3*s,1e3*s),p.inflateCoords(1e3*s,1e3*s),f.setCoords({env2D:d}),f.intersect(p),t.getPointCount()>10){if(x=(0,a.c)(t,f,s,0,n),x.isEmpty())return!1}else x=t;if(e.getPointCount()>10){if(y=(0,a.c)(e,f,s,0,n),y.isEmpty())return!1}else y=e;return L(x,y,s,"F********",n,!1)}(t,e,s,n)}function bt(t,e,s,n,o){const a=i.a.constructEmpty(),h=i.a.constructEmpty();if(t.queryEnvelope(a),e.queryEnvelope(h),!kt(a,h,s))return!1;mt(t,e);let m=!1;const l=new r.P,u=t.getImpl(),c=new i.h;let _=t,d=!1;for(let i=0;i<e.getPointCount();i++){if(e.queryXY(i,l),!a.contains(l))return!1;const r=(0,g.i)(_,l,s);if(1===r)m=!0;else if(0===r)return!1;if(n&&2===r)return!1;d||(!(0,g.r)(t,e.getPointCount()-1)||null!==u.getAccelerators()&&null!==u.getAccelerators().getQuadTree()?_=t:(t.copyTo(c),c.getImpl().buildQuadTreeAccelerator(1),_=c),d=!0)}return m}function St(t,e,s,n,r){const o=i.a.constructEmpty(),a=i.a.constructEmpty();return t.queryEnvelope(o),e.queryEnvelope(a),n?Ht(a,o,s):kt(a,o,s)}function It(t,e,s,n,r){const o=i.a.constructEmpty(),a=i.a.constructEmpty();if(t.queryEnvelope(o),e.queryEnvelope(a),!kt(o,a,s))return!1;mt(t,e);const h=new i.h;return h.addEnvelope(e,!1),n?2===Yt(t,h,s,!1):te(t,h,s,r)}function wt(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!kt(r,o,s)&&(mt(t,e),t.hasNonLinearSegments()||e.hasNonLinearSegments()?L(t,e,s,"******FF*",n,!1):Ot(e,t,s,!1))}function Dt(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!kt(r,o,s)&&(mt(t,e),L(t,e,s,"T**FF*FF*",n,!1))}function Tt(t,e,s,r,o){const a=i.a.constructEmpty(),h=i.a.constructEmpty();if(t.queryEnvelope(a),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;if(r)return Ht(h,a,s);if(!kt(h,a,s))return!1;const m=i.a.constructEmpty();m.setCoords({env2D:h}),m.inflateCoords(-s,-s);const l=i.a.constructEmpty();if(l.setCoords({env2D:h}),l.inflateCoords(s,s),m.containsEnvelope(a))return!0;const u=t.getImpl().querySegmentIterator();u.stripAttributes(),u.nextPath()||(0,n.b)("relational_operations");let c,g,_,d,p,f,x=!1;const y=t.hasNonLinearSegments();for(y&&(_=new i.L,d=new i.L,p=new i.L,f=new i.L,m.querySide(0,_),m.querySide(1,d),m.querySide(2,p),m.querySide(3,f));;){for(;!u.hasNextSegment()&&u.nextPath(););if(!u.hasNextSegment())break;const t=u.nextSegment();if(y&&t.getGeometryType()!==n.G.enumLine){if(t.isIntersecting(_,s)){x=!0;break}if(t.isIntersecting(d,s)){x=!0;break}if(t.isIntersecting(p,s)){x=!0;break}if(t.isIntersecting(f,s)){x=!0;break}}else if(c=t.getStartXY(),g=t.getEndXY(),0!==m.clipLine(c,g)){x=!0;break}}return x}function Nt(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),!!kt(r,o,s)&&zt(e,t,s,!0,!1,!1)}function At(t,e,s,n){const r=i.a.constructEmpty(),o=i.a.constructEmpty();return t.queryEnvelope(r),e.queryEnvelope(o),Vt(r,o,s)}function Mt(t,e,s,i){return ee(t,e.getXY(),s)}function Gt(t,e,s,n,o){const a=i.a.constructEmpty(),h=i.a.constructEmpty();if(t.queryEnvelope(a),e.queryEnvelope(h),h.height()<=s||h.width()<=s)return!1;if(n)return Ht(h,a,s);if(!kt(h,a,s))return!1;let m=!1;const l=i.a.constructEmpty(),u=i.a.constructEmpty();l.setCoords({env2D:h}),u.setCoords({env2D:h}),l.inflateCoords(-s,-s),u.inflateCoords(s,s);const c=new r.P;for(let e=0;e<t.getPointCount();e++){if(t.queryXY(e,c),!u.contains(c))return!1;l.containsExclusive(c)&&(m=!0)}return m}function qt(t,e,s,i){return r.P.sqrDistance(t,e)<=s*s}function Ft(t,e,s,i){return qt(t,e,s)}function Vt(t,e,s,i){return kt(t,e,s)&&kt(e,t,s)}function Rt(t,e,s,n,r){if(t.height()<=s||t.width()<=s)return!1;if(n)return Ht(t,e,s);if(!kt(t,e,s))return!1;const o=i.a.constructEmpty();return o.setCoords({env2D:t}),o.inflateCoords(-s,-s),o.intersect(e),!o.isEmpty()}function Yt(t,e,s,o,a){const h=new r.P,m=new r.P,l=i.a.constructEmpty(),u=i.a.constructEmpty(),c=t.getImpl(),_=e.getImpl(),d=_.getGeometryType(),p=new it(c,_,s,!0);if(!p.next())return 1;if(Wt(t,e,s))return o?4:0;const f=new i.h;let x=t;const y=new i.h;let P=null;d===n.G.enumPolygon&&(P=e);const E=d===n.G.enumPolygon?(0,r.a)(c.getPathCount(),!1):[],C=(0,r.a)(_.getPathCount(),!1);let v=!1,b=!1,S=!1,I=!1,w=!1,D=!1;do{if(S&&w||I&&D)break;if(S&&I)break;const i=p.getRedElement(),r=p.getBlueElement();if(!C[r]&&(m.assign(e.getXY(e.getPathStart(r))),l.setCoords({env2D:p.getRedEnvelope()}),l.inflateCoords(s,s),l.contains(m))){if(0!==(0,g.i)(x,m,0)){if(I=!0,o)return 4}else D=!0;C[r]=!0}if(d===n.G.enumPolygon&&!E[i]&&(h.assign(t.getXY(t.getPathStart(i))),u.setCoords({env2D:p.getBlueEnvelope()}),u.inflateCoords(s,s),u.contains(h))){if(0!==(0,g.i)(P,h,0)){if(S=!0,o)return 4}else w=!0;E[i]=!0}if(v||(!(0,g.r)(t,e.getPathCount()-1)||null!==c.getAccelerators()&&null!==c.getAccelerators().getQuadTree()?x=t:(t.copyTo(f),f.getImpl().buildQuadTreeAccelerator(1),x=f),v=!0),d===n.G.enumPolygon&&!b){const s=e;!(0,g.r)(s,t.getPathCount()-1)||null!==_.getAccelerators()&&null!==_.getAccelerators().getQuadTree()?P=e:(s.copyTo(y),y.getImpl().buildQuadTreeAccelerator(1),P=y),b=!0}}while(p.next());if(!S&&!I)return 1;if(!w||!D){if(d===n.G.enumPolygon)for(let t=0,e=c.getPathCount();t<e;t++)if(!E[t]){w=!0;break}for(let t=0,e=_.getPathCount();t<e;t++)if(!C[t]){D=!0;break}}return S&&w||I&&D||S&&I?4:I?2:3}function Xt(t,e,s,r,o){r[0]=!1;const a=t.getImpl(),h=e.getImpl(),m=a.querySegmentIterator(),l=h.querySegmentIterator(),u=[0,0],c=[0,0],_=new it(a,h,s);let d=!1;for(;_.next();){const t=_.getRedElement(),e=_.getBlueElement();m.resetToVertex(t,-1),l.resetToVertex(e,-1);const i=m.nextSegment(),n=l.nextSegment();let o=0;if(ie(i,n)?!d&&n.isIntersecting(i,s)&&(d=!0):o=n.intersect(i,null,c,u,s),0!==o&&(d=!0,1===o)){const t=u[0],e=c[0];if(t>0&&t<1&&e>0&&e<1)return r[0]=!0,!1}}if(!d){r[0]=!0;const o=i.a.constructEmpty();t.queryEnvelope(o),o.inflateCoords(s,s);const m=new i.h;let l=t,u=!1;for(let s=0,r=e.getPathCount();s<r;s++)if(e.getPathSize(s)>0){const r=i.a.constructEmpty();if(e.queryPathEnvelope(s,r),!o.isIntersecting(r))return!1;{const t=e.getXY(e.getPathStart(s)),i=(0,g.u)(l,t,0);if((0,n.g)(-1!==i),0===i)return!1}u||(!(0,g.r)(t,e.getPathCount()-1)||null!==a.getAccelerators()&&null!==a.getAccelerators().getQuadTree()?l=t:(t.copyTo(m),m.getImpl().buildQuadTreeAccelerator(1),l=m),u=!0)}if(1===t.getPathCount()||e.getGeometryType()===n.G.enumPolyline)return!0;const c=e,_=i.a.constructEmpty();c.queryEnvelope(_),_.inflateCoords(s,s);const d=new i.h;let p=c,f=!1;for(let e=0,s=t.getPathCount();e<s;e++)if(t.getPathSize(e)>0){const s=i.a.constructEmpty();if(t.queryPathEnvelope(e,s),_.isIntersecting(s)){const s=t.getXY(t.getPathStart(e)),i=(0,g.u)(p,s,0);if((0,n.g)(-1!==i),1===i)return!1}f||(!(0,g.r)(c,t.getPathCount()-1)||null!==h.getAccelerators()&&null!==h.getAccelerators().getQuadTree()?p=c:(c.copyTo(d),d.getImpl().buildQuadTreeAccelerator(1),p=d),f=!0)}return!0}return!1}function kt(t,e,s){const n=i.a.constructEmpty();return n.setCoords({env2D:t}),n.inflateCoords(s,s),n.containsEnvelope(e)}function Ht(t,e,s){const n=i.a.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),t.containsExclusiveEnvelope(n)}function Bt(t,e,s){const n=i.a.constructEmpty();return n.setCoords({env2D:e}),n.inflateCoords(s,s),!(n.contains(t.getLowerLeft())&&n.contains(t.getLowerRight())&&n.contains(t.getUpperLeft())&&n.contains(t.getUpperRight()))}function Lt(t,e,s,i){if(t.getPathCount()!==e.getPathCount()||t.getPointCount()!==e.getPointCount())return!1;if(t.hasNonLinearSegments()||e.hasNonLinearSegments())return t.equals(e);const n=new r.P,o=new r.P;let a=!0;const h=s*s;for(let s=0;s<t.getPathCount();s++){if(t.getPathEnd(s)!==e.getPathEnd(s)){a=!1;break}for(let i=t.getPathStart(s);i<e.getPathEnd(s);i++)if(t.queryXY(i,n),e.queryXY(i,o),r.P.sqrDistance(n,o)>h){a=!1;break}if(!a)break}return!!a}function zt(t,e,s,i,n,o,a){const h=t.getImpl(),m=e.getImpl(),l=h.getPointCount(),u=m.getPointCount(),c=(0,r.a)(l,!1),g=n||o?(0,r.a)(u,!1):[],_=s*s,d=new it(h,m,s);for(;d.next();){const t=d.getRedElement(),e=d.getBlueElement(),s=h.getXY(t),i=m.getXY(e);r.P.sqrDistance(s,i)<=_&&(c[t]=!0,(n||o)&&(g[e]=!0))}let p=!1,f=!1;for(let t=0;t<l;t++){const e=c[t];if(p||=!e,f||=e,(n||i)&&p)return!1}if(i)return!0;let x=!1,y=!1;for(let t=0;t<u;t++){const e=g[t];if(x||=!e,y||=e,n&&x)return!1}return!!n||p&&f&&x&&y}function Ut(t,e,s,i){return Ot(t,e,s,i)&&Ot(e,t,s,i)}function Ot(t,e,s,o){if((0,n.p)(t),(0,n.p)(e),e.isEmpty())return!1;let a=!0;const h=(0,r.a)(2,Number.NaN),m=(0,r.a)(2,Number.NaN),l=[],u=new re;let c;const g=i.a.constructEmpty(),_=i.a.constructEmpty(),d=i.a.constructEmpty();t.queryEnvelope(g),e.queryEnvelope(_),g.inflateCoords(s,s),_.inflateCoords(s,s),d.setCoords({env2D:g}),d.intersect(_);const p=t.getImpl().querySegmentIterator(),f=e.getImpl().querySegmentIterator(),x=e.getImpl().getAccelerators();let y=null,P=null,E=null,C=null;if(null!==x&&(y=x.getQuadTree(),P=x.getQuadTreeForPaths(),null!==P&&(C=P.getIteratorForQT())),null===y){const s=t.getPointCount(),n=e.getPointCount();s>10&&n>10&&(y=(0,i.ac)(e.getImpl(),d))}for(null!==y&&(E=y.getIteratorForQT());p.nextPath();)for(;p.hasNextSegment();){let t=p.nextSegment();if(t.queryEnvelope(g),!g.isIntersecting(d))return a=!1,!1;if(null!==C&&(C.resetIterator(g,s),-1===C.next()))continue;let e=0,r=null;if(null!=E)E.resetIterator(t,s);else if(f.resetToFirstPath(),!f.nextPath())return a=!1,!1;do{if(e=0,null!==E){const i=E.next();if(-1===i)return a=!1,!1;f.resetToVertex(y.getElement(i),-1),r=f.nextSegment(),e=t.intersect(r,null,h,m,s)}else{for(;!f.hasNextSegment();)if(!f.nextPath())return a=!1,!1;r=f.nextSegment(),r.queryEnvelope(_),_.inflateCoords(s,s),g.isIntersecting(_)&&(e=t.intersect(r,null,h,m,s))}}while(2!==e||0!==h[0]||o&&!(m[0]<=m[1]));let x=Number.NaN,P=!1;do{let i=!1;if(1===h[1]){if(!p.hasNextSegment()){P=!0;break}t=p.nextSegment(),i=!0}if(1===m[1]&&m[0]<=m[1]){if(-1===x)break;if(x=1,!f.hasNextSegment())break;r=f.nextSegment(),i=!0}if(0===m[1]&&m[0]>m[1]){if(1===x)break;if(Number.isNaN(x)){if(!f.hasPreviousSegment())break;f.previousSegment(),x=-1}if(!f.hasPreviousSegment())break;r=f.previousSegment(),i=!0}if(!i)break;e=t.intersect(r,null,h,m,s)}while(2===e&&(!o||m[0]<=m[1]));if(P)continue;const v=t.calculateLength2D();t.queryEnvelope(g),l.length=0,u.m_overlapEvents.length=0;let b=!1,S=!1,I=0;const w=(0,i.c)(null,g,!0);for(null!==E?E.resetIterator(t,s):(f.resetToFirstPath(),f.nextPath()||(0,n.b)("relational_operations"));;){if(e=0,null!==E){const i=E.next();if(-1===i)break;f.resetToVertex(y.getElement(i),-1),r=f.nextSegment(),e=t.intersect(r,null,h,m,s)}else{for(;!f.hasNextSegment()&&f.nextPath(););if(!f.hasNextSegment())break;r=f.nextSegment(),r.queryEnvelope(_),_.inflateCoords(s,s),g.isIntersecting(_)&&(e=t.intersect(r,null,h,m,s))}if(2===e&&(!o||m[0]<=m[1])){const t=p.getStartPointIndex(),e=p.getPathIndex(),i=f.getStartPointIndex(),n=f.getPathIndex();if(c=ne(t,e,h[0],h[1],i,n,m[0],m[1]),u.m_overlapEvents.push(c),l.push(l.length),!(b||c.m_scalarA0<I&&c.m_scalarA1<I))if(0===I&&v*(c.m_scalarA0-I)>s)b=!0;else if(0!==I&&v*(c.m_scalarA0-I)>w)b=!0;else if(I=c.m_scalarA1,v*(1-I)<=s||1===I){S=!0;break}}}if(!S){if(!b)return a=!1,!1;l.length>1&&l.sort(((t,e)=>u.compareOverlapEvents(t,e))),I=0;for(let t=0;t<u.m_overlapEvents.length;t++)if(c=u.m_overlapEvents[l[t]],!(c.m_scalarA0<I&&c.m_scalarA1<I)){if(0===I&&v*(c.m_scalarA0-I)>s)return a=!1,!1;if(0!==I&&v*(c.m_scalarA0-I)>w)return a=!1,!1;if(I=c.m_scalarA1,v*(1-I)<=s||1===I)break}if(v*(1-I)>s)return a=!1,!1;l.length=0,u.m_overlapEvents.length=0}}return a}function Wt(t,e,s){const i=t.getImpl(),n=e.getImpl(),r=i.querySegmentIterator(),o=n.querySegmentIterator(),a=new it(i,n,s);for(;a.next();){const t=a.getRedElement(),e=a.getBlueElement();r.resetToVertex(t,-1),o.resetToVertex(e,-1);const i=r.nextSegment();if(o.nextSegment().isIntersecting(i,s))return!0}return!1}function jt(t,e,s,i){const n=t.getImpl(),o=e.getImpl(),a=n.querySegmentIterator(),h=o.querySegmentIterator(),m=(0,r.a)(2,Number.NaN),l=new it(n,o,s);let u=!1,c=-1;for(;l.next();){const t=l.getRedElement(),e=l.getBlueElement();a.resetToVertex(t,-1),h.resetToVertex(e,-1);const n=a.nextSegment(),o=h.nextSegment();let g=0;if(ie(n,o)){if(o.isIntersecting(n,s))return-2}else g=n.intersect(o,null,m,null,s);if(g)if(2===g){const t=n.calculateLength2D(),e=m[0];if(t*(m[1]-e)>s)return c=1,c;u=!0}else if(c=0,i){const t=m[0],e=new r.P;n.queryCoord2D(t,e),i.push(e.x),i.push(e.y)}}return u?-2:c}function Zt(t,e,s,i){const n=t.getImpl(),o=e,a=o.getPointCount(),h=i?(0,r.a)(a,!1):[],m=new it(n,o,s,!1),l=n.querySegmentIterator();for(;m.next();){const t=m.getRedElement(),e=m.getBlueElement();l.resetToVertex(t,-1);const n=l.nextSegment(),r=o.getXY(e);if(n.isIntersectingPoint(r,s)){if(!i)return!0;h[e]=!0}}if(!i)return!1;for(let t=0;t<a;t++)if(!h[t])return!1;return!0}function Qt(t,e,s){const n=new r.P,o=s*s,a=t.querySegmentIterator(),h=t.getImpl().getAccelerators();if(null!==h){const t=h.getQuadTree();if(null!==t){const h=i.a.constructEmpty();h.setCoords({pt:e});const m=t.getIterator(h,s);for(let s=m.next();-1!==s;s=m.next())if(a.resetToVertex(t.getElement(s),-1),a.hasNextSegment()){const t=a.nextSegment(),s=t.getClosestCoordinate(e,!1);if(t.queryCoord2D(s,n),r.P.sqrDistance(e,n)<=o)return!0}return!1}}const m=i.a.constructEmpty();for(;a.nextPath();)for(;a.hasNextSegment();){const t=a.nextSegment();if(t.queryEnvelope(m),m.inflateCoords(s,s),!m.contains(e))continue;const i=t.getClosestCoordinate(e,!1);if(t.queryCoord2D(i,n),r.P.sqrDistance(e,n)<=o)return!0}return!1}function Kt(t,e,s,o){const a=t.querySegmentIterator(),h=t.getImpl().getAccelerators(),m=t.hasNonLinearSegments();let l=null,u=null,c=null,g=null;if(null!==h){const t=h.getQuadTree();if(null!==t){const r=t.getIterator(e,s);m&&(l=new i.L,u=new i.L,c=new i.L,g=new i.L,e.querySide(0,l),e.querySide(1,u),e.querySide(2,c),e.querySide(3,g));const o=i.a.constructEmpty();o.setCoords({env2D:e}),o.inflateCoords(s,s);for(let i=r.next();-1!==i;i=r.next())if(a.resetToVertex(t.getElement(i),-1),a.hasNextSegment()){const t=a.nextSegment();if(t.getGeometryType()===n.G.enumLine){const e=t.getStartXY(),s=t.getEndXY();if(o.clipLine(e,s))return!0;continue}if(e.contains(t.getStartXY())||e.contains(t.getEndXY()))return!0;if(t.isIntersecting(l,s))return!0;if(t.isIntersecting(u,s))return!0;if(t.isIntersecting(c,s))return!0;if(t.isIntersecting(g,s))return!0}return!1}}if(m){l=new i.L,u=new i.L,c=new i.L,g=new i.L,e.querySide(0,l),e.querySide(1,u),e.querySide(2,c),e.querySide(3,g);const n=t.querySegmentIterator();for(;n.nextPath();)for(;n.hasNextSegment();){const t=n.nextSegment();if(e.contains(t.getStartXY())||e.contains(t.getEndXY()))return!0;if(t.isIntersecting(l,s))return!0;if(t.isIntersecting(u,s))return!0;if(t.isIntersecting(c,s))return!0;if(t.isIntersecting(g,s))return!0}}else{const n=i.a.constructEmpty();n.setCoords({env2D:e}),n.inflateCoords(s,s);const o=t.getImpl(),a=o.getAttributeStreamRef(0),h=new r.P;for(let t=0,e=o.getPathCount();t<e;t++){let e=!0;const s=new r.P,i=new r.P,m=new r.P,l=o.getPathStart(t),u=new r.P;for(let r=l,c=o.getPathEnd(t);r<c;r++)if(e)a.queryPoint2D(2*r,s),u.assign(s),e=!1;else{if(a.queryPoint2D(2*r,h),i.setCoordsPoint2D(s),m.setCoordsPoint2D(h),n.clipLine(i,m))return!0;s.assign(h)}if(o.isClosedPath(t)&&!e&&(i.setCoordsPoint2D(s),m.setCoordsPoint2D(u),n.clipLine(i,m)))return!0}}return!1}function Jt(t,e,s,n){const o=t.getImpl(),h=e.getImpl(),m=[0],l=(0,i.o)(o.getIsSimple(0,m))&&(0,i.o)(h.getIsSimple(0,m)),u=o.querySegmentIterator(),c=h.querySegmentIterator(),g=(0,r.a)(2,0),_=(0,r.a)(2,0),d=new it(o,h,s);let p=!1;for(;d.next();){const t=d.getRedElement(),e=d.getBlueElement();u.resetToVertex(t,-1),c.resetToVertex(e,-1);const i=u.nextSegment(),n=c.nextSegment();let r=0;if(ie(i,n)){if(n.isIntersecting(i,s)){p=!0;break}}else r=n.intersect(i,null,_,g,s);if(2===r){const t=g[0],e=g[1],n=i.calculateLength2D();if(l&&(e-t)*n>s)return!1;p=!0}else if(r){const t=g[0],e=_[0];if(t>0&&t<1&&e>0&&e<1)return!1;p=!0}}if(!p)return!1;const f=i.a.constructEmpty(),x=i.a.constructEmpty(),y=i.a.constructEmpty();let P,E;if(t.queryEnvelope(f),e.queryEnvelope(x),f.inflateCoords(1e3*s,1e3*s),x.inflateCoords(1e3*s,1e3*s),y.setCoords({env2D:f}),y.intersect(x),t.getPointCount()>10){if(P=(0,a.c)(t,y,s,0,n),P.isEmpty())return!1}else P=t;if(e.getPointCount()>10){if(E=(0,a.c)(e,y,s,0,n),E.isEmpty())return!1}else E=e;return L(P,E,s,"F********",n,!1)}function $t(t,e,s,n){const o=t.getImpl(),h=e.getImpl(),m=[0],l=(0,i.o)(o.getIsSimple(0,m))&&(0,i.o)(h.getIsSimple(0,m)),u=i.a.constructEmpty(),c=i.a.constructEmpty(),g=i.a.constructEmpty();t.queryEnvelope(u),e.queryEnvelope(c);let _=!1;const d=Bt(u,c,s),p=Bt(c,u,s),f=o.querySegmentIterator(),x=h.querySegmentIterator(),y=(0,r.a)(2,Number.NaN),P=(0,r.a)(2,Number.NaN),E=new it(o,h,s);for(;E.next();){const t=E.getRedElement(),e=E.getBlueElement();f.resetToVertex(t,-1),x.resetToVertex(e,-1);const i=f.nextSegment(),n=x.nextSegment();let r=0;if(ie(i,n)){if(n.isIntersecting(i,s))break}else r=n.intersect(i,null,P,y,s);if(2===r){const t=y[0],e=y[1],n=i.calculateLength2D();if(l&&(e-t)*n>s&&(_=!0,d&&p))return!0}else if(r){const t=y[0],e=P[0];if(t>0&&t<1&&e>0&&e<1)return!0}}const C=i.a.constructEmpty(),v=i.a.constructEmpty();let b,S;C.setCoords({env2D:u}),C.inflateCoords(1e3*s,1e3*s),v.setCoords({env2D:c}),v.inflateCoords(1e3*s,1e3*s),g.setCoords({env2D:C}),g.intersect(v);let I="";if(I+=_?"**":"T*",d){if(e.getPointCount()>10){if(S=(0,a.c)(e,g,s,0,n),S.isEmpty())return!1}else S=e;I+="****"}else S=e,I+="T***";if(p){if(t.getPointCount()>10){if(b=(0,a.c)(t,g,s,0,n),b.isEmpty())return!1}else b=t;I+="***"}else b=t,I+="T**";return L(b,S,s,I,n,!1)}function te(t,e,s,n){const r=[!1],o=Xt(t,e,s,r);if(r[0])return o;const h=i.a.constructEmpty();let l;if(e.queryEnvelope(h),h.inflateCoords(1e3*s,1e3*s),t.getPointCount()>10){if(l=(0,a.c)(t,h,s,0,n),l.isEmpty())return!1}else l=t;return function(t,e,s,n){const r=new $;r.resetMatrix_(),r.setPredicates_("T*****F**"),r.setAreaAreaPredicates_();const o=i.a.constructEmpty(),a=i.a.constructEmpty();t.queryEnvelope(o),e.queryEnvelope(a);let h=!1;if(ht(o,a,s)&&(r.areaAreaDisjointPredicates_(t,e),h=!0),h||mt(t,e),h)return K(r.m_matrix,r.m_scl);let l=new i.d,u=l.addGeometry(t),c=l.addGeometry(e),_=null,d=0;if(t.hasNonLinearSegments()||e.hasNonLinearSegments()){_=new g.C;const t=l.getEnvelope2D(n),e=(0,g.d)(s,t);d=(0,g.f)(e,0),(0,g.b)(l,e,s,12e3,_,null,n)}(0,g.e)(l,new i.C(s,0).add(d),n,!1,!1);const p=l.getGeometry(c).getBoundary();if(l.filterClosePoints(0,!0,!0,!1,i.n),(0,m.n)(l,u,-1,!1,i.n,n),0===l.getPointCount(u))return!1;(0,m.n)(l,c,-1,!1,i.n,n),r.setEditShape_(l,n);const f=0===l.getPointCount(c);if(!f){r.computeMatrixTopoGraphHalfEdges_(u,c),r.m_topoGraph.removeShape();const t=K(r.m_matrix,r.m_scl);if(!t)return t}const x=l.getGeometry(u);return l=new i.d,u=l.addGeometry(x),c=l.addGeometry(p),r.setEditShape_(l,n),r.m_predicateCount=0,r.resetMatrix_(),r.setPredicates_(f?"T*****F**":"******F**"),r.setAreaLinePredicates_(),r.computeMatrixTopoGraphHalfEdges_(u,c),r.m_topoGraph.removeShape(),K(r.m_matrix,r.m_scl)}(l,e,s,n)}function ee(t,e,s,i){const n=new r.P,o=s*s;for(let s=0;s<t.getPointCount();s++)if(t.queryXY(s,n),r.P.sqrDistance(n,e)<=o)return!1;return!0}function se(t,e,s){const i=t.getBoundary();return!i.isEmpty()&&!ee(i,e,s)}function ie(t,e){return t.getGeometryType()!==n.G.enumLine||e.getGeometryType()!==n.G.enumLine}function ne(t,e,s,i,n,r,o,a){return{m_ivertexA:t,m_ipathA:e,m_scalarA0:s,m_scalarA1:i,m_ivertexB:n,m_ipathB:r,m_scalarB0:o,m_scalarB1:a}}class re{constructor(){this.m_overlapEvents=[]}compareOverlapEvents(t,e){const s=this.m_overlapEvents[t],i=this.m_overlapEvents[e];if(s.m_ipathA<i.m_ipathA)return-1;if(s.m_ipathA===i.m_ipathA){if(s.m_ivertexA<i.m_ivertexA)return-1;if(s.m_ivertexA===i.m_ivertexA){if(s.m_scalarA0<i.m_scalarA0)return-1;if(s.m_scalarA0===i.m_scalarA0){if(s.m_scalarA1<i.m_scalarA1)return-1;if(s.m_scalarA1===i.m_scalarA1&&s.m_ivertexB<i.m_ivertexB)return-1}}}return 1}}function oe(t,e,s){return e.m_projector.project(t,s)}function ae(t,e,s,i,n){return t.m_projector.transformInPlaceZ(e,null,s,i,null,n)}function he(t,e,s,r){if(t&&e&&e.isPannable()||(0,n.t)("fold_into_360_range_geodetic"),t.isEmpty())return t;if(4===s)return me(t,e,r);let o=t;const a=o.getGeometryType();if((0,n.f)(a)){o=_s(t,e);const n=new i.a;o.queryEnvelope(n);const r=(0,i.b)(e,n,!1).total(),a=e.getPannableExtent();let h=Math.floor((n.xmin-a.xmin)/a.width())*a.width()+a.xmin,m=o;for(;h<n.xmax;)h>n.xmin+r&&h<n.xmax-r&&(m=cs(m,e,s,!0,h)),h+=a.width();o=m}else{if(a===n.G.enumEnvelope){const t=new i.h({vd:o.getDescription()});return t.addEnvelope(o,!1),he(t,e,s,r)}if((0,n.e)(a)){const t=new i.i({vd:o.getDescription()});return t.addSegment(o,!0),he(t,e,s,r)}}return me(o,e,r)}function me(t,e,s){if(t&&e&&e.isPannable()||(0,n.t)(""),t.isEmpty())return t;let r;const o=t.getGeometryType();if(o===n.G.enumEnvelope){const e=new i.h({vd:t.getDescription()});e.addEnvelope(t,!1),r=e}else if((0,n.e)(o)){const e=new i.i({vd:t.getDescription()});e.addSegment(t,!0),r=e}else r=t;const a=_s(r,e);return a.isEmpty()?a:as(a,e,0,a!==t,0,s)}function le(t,e,s,n){const o=e.getXYGridRange(),a=t.hasAttribute(1),h=t.hasAttribute(2);let m=new r.E,u=new r.E;a&&(m=e.getZGridRange()),h&&(u=e.getMGridRange());let c=(new l.O).execute(t,o,s,n);if(a){const e=c.queryInterval(1,0);m.contains(e)||(t===c&&(c=c.clone()),(0,i.aK)(c,m,1,0))}if(h){const e=c.queryInterval(2,0);u.contains(e)||(t===c&&(c=c.clone()),(0,i.aK)(c,u,2,0))}return c}class ue{constructor(t){this.m_inputPCSHorizonClipOption=0,this.m_outputPCSHorizonClipOption=0,this.m_bDontGeonormalizePolygon=!1,this.m_bClipOutCurvedPoles=!1,this.m_bNormalizeOutputGeometry=!1,this.m_bDontHackPolesInGeogToGeog=!1,this.m_centralMeridianOfOutputGCS=0,this.m_densificationStepInput=0,t||(0,n.t)(""),this.m_projTransform=t,this.m_bClipOutCurvedPoles=!1;const e=this.m_projTransform.getExtendedParamsImpl();this.m_bNormalizeOutputGeometry=e.normalizeResultGeometry,this.m_bNormalizeOutputGeometry&&(e.legacyHorizonClipping?this.m_bNormalizeOutputGeometry=!1:this.m_projTransform.getOutputSR().isPannable()||(this.m_bNormalizeOutputGeometry=!1)),e.clipWithInputHorizon?(this.m_inputPCSHorizonClipOption=0,!e.legacyHorizonClipping&&this.m_projTransform.getInputSR().isPannable()&&(this.m_inputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_inputPCSHorizonClipOption=1,e.clipWithOutputHorizon?(this.m_outputPCSHorizonClipOption=0,!e.legacyHorizonClipping&&this.m_projTransform.getOutputSR().isPannable()&&(this.m_outputPCSHorizonClipOption=this.m_bNormalizeOutputGeometry?4:2)):this.m_outputPCSHorizonClipOption=1,this.m_centralMeridianOfOutputGCS=e.centralMeridianOfOutputGCS,this.m_densificationStepInput=e.densificationStep;const s=this.m_projTransform.getExtendedParamsInternal();this.m_bDontGeonormalizePolygon=s.hasFlag(2147483648),this.m_bDontHackPolesInGeogToGeog=s.hasFlag(1073741824),this.m_bClipOutCurvedPoles=s.hasFlag(536870912)}project(t,e){if(this.m_projTransform.isIdentity()||t.isEmpty())return t;const s=t.getGeometryType();if(s===n.G.enumPoint)return this.projectPoint(t,e);const i=this.m_projTransform.getInputSR().getCoordinateSystemType(),r=this.m_projTransform.getOutputSR().getCoordinateSystemType(),o=this.m_projTransform.getInputSR(),a=this.m_projTransform.getOutputSR();if(0===i&&i===r){const e=ge(o,a),s=t.clone();return s.applyTransformation(e),s}switch(s){case n.G.enumPolyline:case n.G.enumPolygon:return this.projectMultiPath(t,e);case n.G.enumMultiPoint:return this.projectMultiPoint(t,e);case n.G.enumEnvelope:return this.projectEnvelope(t,e);case n.G.enumGeometryCollection:return this.projectGeometryCollection(t,e);default:(0,n.b)("")}}projectPoint(t,e){const s=[t.getXY()];let i,n=null;(i=t.hasAttribute(1))&&(n=[t.getZ()]),this.transformInPlaceZ(s,n,1,s,n,null);const r=t.clone();return r.setXY(s[0]),i&&r.setZ(n[0]),r}projectMultiPoint(t,e){let s=new i.M({copy:t});const r=this.m_projTransform.getInputSR(),o=this.m_projTransform.getOutputSR(),a=r.getCoordinateSystemType(),h=o.getCoordinateSystemType();if(3===a&&(0,n.g)(0),s=Ps(s,r,this.m_inputPCSHorizonClipOption,e),s.isEmpty())return s;2===a&&Ds(r,0,s),qs(this.m_projTransform,s,!1);let m=0;3===h&&(0,n.g)(0);const l=2===h;return l?m=o.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(m=this.m_centralMeridianOfOutputGCS),l&&0!==this.m_outputPCSHorizonClipOption||(s=as(s,bi(o),m,!1,0,e)),l&&(s=is(s,o,this.m_outputPCSHorizonClipOption,e),Ss(o,s,this.m_bNormalizeOutputGeometry),s.isEmpty()),s}projectMultiPath(t,e){const s=t.getGeometryType();return s===n.G.enumPolygon?this.projectPolygon(t,e):s===n.G.enumPolyline?this.projectPolyline(t,e):void(0,n.b)("project_multi_path_")}projectEnvelope(t,e){this.m_projTransform.getInputSR(),this.m_projTransform.getOutputSR();const s=this.m_projTransform.isVertical()&&t.hasAttribute(1);let i=r.E.constructEmpty();if(s&&(i=t.queryInterval(1,0)),i.width()>0){const s=t.clone();s.setInterval(1,0,i.vmin,i.vmin);const n=this.projectEnvelopeHelper(s,e);s.setInterval(1,0,i.vmax,i.vmax);const r=this.projectEnvelopeHelper(s,e);return n.merge(r),n}return this.projectEnvelopeHelper(t,e)}projectPolygon(t,e){(0,n.g)(t.getGeometryType()===n.G.enumPolygon),(0,n.g)(!this.m_projTransform.isIdentity()),(0,n.g)(!t.isEmpty());const s=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),o=s.getCoordinateSystemType(),l=r.getCoordinateSystemType(),u=new i.h({copy:t});3===o&&(0,n.g)(0),3===l&&(0,n.g)(0);const c=2===o,g=2===l,_=c?s.getGCS():s,d=g?r.getGCS():r,p=!g&&!this.m_bDontHackPolesInGeogToGeog;let f=!1,x=Ps(u,s,this.m_inputPCSHorizonClipOption,e);if(x.isEmpty())return x;let y=this.m_densificationStepInput;const P=!Number.isNaN(y);let E;P&&(x=(new h.O).execute(x,y,0,0,e));let C=g?r.getPCSInfo():null,v=Number.NaN;c&&(v=s.getCentralMeridian());const b=null!==r.getGCSSplitLines();if(this.m_bDontGeonormalizePolygon){const t=x;if(c&&(As(s,v,t),P)){const t=s.getUnitsPerMillimeter();y*=s.getGCS().getUnitsPerMillimeter()/t}if(Vs(this.m_projTransform,t,p),P){const t=s.getGCS().getUnitsPerMillimeter();y*=r.getGCS().getUnitsPerMillimeter()/t}E=t}else{let t=new i.i({vd:x.getDescription()});if(t.addAndExplicitlyOpenAllPaths(x,!1),c){if(As(s,v,t),P){const t=s.getUnitsPerMillimeter();y*=s.getGCS().getUnitsPerMillimeter()/t}if(this.m_bClipOutCurvedPoles){const n=s.getPCSInfo(),r=n.getSouthPoleGeometry()===en.PE_POLE_LINE_CURVED,o=n.getNorthPoleGeometry()===en.PE_POLE_LINE_CURVED;if(r||o){const s=i.a.constructEmpty();t.queryLooseEnvelope(s),s.inflateCoords(1,1);const n=89.9999*_.getOneDegreeGCSUnit();r&&(s.ymin=-n),o&&(s.ymax=n),t=(0,a.b)(t,s,_,0,0,e)}}}if(Vs(this.m_projTransform,t,p),P){const t=bi(s).getUnitsPerMillimeter();y*=bi(r).getUnitsPerMillimeter()/t}let n=Number.NaN;g?(C=r.getPCSInfo(),n=r.getCentralMeridian()):Number.isNaN(this.m_centralMeridianOfOutputGCS)||(n=this.m_centralMeridianOfOutputGCS);let o=ce(s)|ce(r),h=10*d.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(o=3,h=10*d.getTolerance(0)),E=function(t,e,s,i,n,r,o,a,h){return new Oe(t,null,s,e,i,n,o,a,r).geoNormalizePolygonGeometry(h)}(x,s,t,d,n,e,o,h,this.m_bNormalizeOutputGeometry),o=0}if(b&&((0,n.g)(!r.isPannable()),E=ts(E,r,e)),g){if(!f){const t=d.getPannableExtent().width();if(E.queryInterval(0,0).width()>=t-10*d.getTolerance(0)){const t=C.getNorthPoleLocation(),e=C.getSouthPoleLocation(),s=C.getNorthPoleGeometry(),i=C.getSouthPoleGeometry();let n=0;s===en.PE_POLE_POINT&&t!==en.PE_POLE_OUTSIDE_BOUNDARY&&(n=1),i===en.PE_POLE_POINT&&e!==en.PE_POLE_OUTSIDE_BOUNDARY&&(n|=2),f||=0!==n}}E=is(E,r,this.m_outputPCSHorizonClipOption,e),P&&(E=(new h.O).execute(E,y,0,0,e)),ws(r,E,this.m_bNormalizeOutputGeometry)}return E.isEmpty()||f&&(E=(new m.O).execute(E,r,!1,e)),E}projectPolyline(t,e){(0,n.g)(t.getGeometryType()===n.G.enumPolyline),(0,n.g)(!this.m_projTransform.isIdentity()),(0,n.g)(!t.isEmpty());const s=this.m_projTransform.getInputSR(),r=this.m_projTransform.getOutputSR(),o=s.getCoordinateSystemType(),a=r.getCoordinateSystemType(),m=new i.i({copy:t});3===o&&(0,n.g)(0),3===a&&(0,n.g)(0);const l=2===o,u=2===a;l&&s.getGCS();const c=u?r.getGCS():r,g=!u&&!this.m_bDontHackPolesInGeogToGeog;let _=Ps(m,s,this.m_inputPCSHorizonClipOption,e);if(_.isEmpty())return _;let d=Number.NaN;l&&(d=s.getCentralMeridian());const p=null!==r.getGCSSplitLines();let f=this.m_densificationStepInput;const x=!Number.isNaN(f);let y;if(x&&(_=(new h.O).execute(_,f,0,0,e)),this.m_bDontGeonormalizePolygon){if(l&&(As(s,d,_),x)){const t=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/t}if(Vs(this.m_projTransform,_,g),x){const t=s.getGCS().getUnitsPerMillimeter();f*=r.getGCS().getUnitsPerMillimeter()/t}y=_}else{const t=new i.i({vd:_.getDescription()});if(t.addAndExplicitlyOpenAllPaths(_,!1),l&&(As(s,d,t),x)){const t=s.getUnitsPerMillimeter();f*=s.getGCS().getUnitsPerMillimeter()/t}if(Vs(this.m_projTransform,t,g),x){const t=s.getGCS().getUnitsPerMillimeter();f*=r.getGCS().getUnitsPerMillimeter()/t}let n=Number.NaN;u?n=r.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(n=this.m_centralMeridianOfOutputGCS);let o=ce(s)|ce(r),a=10*c.getTolerance(0);this.m_bDontHackPolesInGeogToGeog&&(o=3,a=0),y=function(t,e,s,i,n,r,o,a,h){return new Oe(t,null,s,e,i,n,o,a,r).geoNormalizePolylineGeometry(h)}(_,s,t,c,n,e,o,a,this.m_bNormalizeOutputGeometry),o=0}return p&&((0,n.g)(!r.isPannable()),y=ts(y,r,e)),u&&(y=is(y,r,this.m_outputPCSHorizonClipOption,e),x&&(y=(new h.O).execute(y,f,0,0,e)),ws(r,y,this.m_bNormalizeOutputGeometry)),y.isEmpty(),y}projectGeometryCollection(t,e){return(0,n.g)(0),{}}projectEnvelopeHelper(t,e){const s=(t.height()+t.width())/400;if(0!==s){const n=(new h.O).execute(t,s,0,0,e),r=this.projectMultiPath(n,e),o=new i.E({vd:t.getDescription()});if(r.isEmpty()){const s=Math.min(t.height(),t.width()),r=(0,i.u)(this.m_projTransform.getInputSR(),t,!0).total();if(s>100*r){const t=i.a.constructEmpty(),e=(0,i.b)(this.m_projTransform.getOutputSR(),t,!0).total(),n=this.m_projTransform.getInputSR().getOneMeter()/this.m_projTransform.getOutputSR().getOneMeter();if(s>100*Math.max(r,e*n))return o}const a=new i.i;a.addAndExplicitlyOpenAllPaths(n,!1),this.projectMultiPath(a,e).queryEnvelope(o);const h=new i.M({vd:t.getDescription()});h.reserve(4);const m=new i.P;for(let e=0;e<4;e++)t.queryCornerByVal(e,m),h.add(m);const l=this.projectMultiPoint(h,e),u=new i.E;return l.queryEnvelope(u),o.merge(u),o}return r.queryEnvelope(o),o}{const s=t.getCenterXY(),n=new i.P(s),r=this.projectPoint(n,e),o=new i.E({vd:t.getDescription()});if(r.isEmpty())o.setEmpty();else{t.copyTo(o);const e=r.getXY();o.setCoords(e.x,e.y,e.x,e.y)}return o}}transformInPlace(t,e,s,i){return(0,n.g)(0),0}transformInPlaceZ(t,e,s,i,o,a){if(this.m_projTransform.isIdentity())return t!==i&&(0,r.ax)(i,t,s),e!==o&&(0,r.D)(o,e,0,0,s),s;const h=this.m_projTransform,m=h.getInputSR(),l=h.getOutputSR(),u=m.getCoordinateSystemType(),c=l.getCoordinateSystemType();if(0===u&&u===c)return ge(m,l).transformPoints2D(t,s,i),h.isVertical()&&(0,n.g)(0),s;3===u&&(0,n.a)("image: transform_in_place_"),3===c&&(0,n.a)("image: transform_in_place_"),function(t,e,s,i,o){const a=i.getCoordinateSystemType();if(2===a){if(0===o)s!==t&&(0,r.ax)(s,t,e),function(t,e,s){const i=t.getPCSHorizon();if(i.getGeometryType()!==n.G.enumPolygon)if(i.getGeometryType()!==n.G.enumEnvelope)(0,n.t)("");else{const t=i;for(let i=0;i<s;i++)t.contains(e[i])||e[i].setNAN()}else{const n=t.getDefaultPrecisionSR().getTolerance(0),r=i;for(let t=0;t<s;t++)1!==(0,g.i)(r,e[t],n)&&e[t].setNAN()}}(i,s,e);else if(s!==t&&(0,r.ax)(s,t,e),i.isPannable()){const t=i.getTolerance(0);(function(t,e,s,i){for(let n=0;n<e;n++){if(t[n].y<s.ymin||t[n].y>s.ymax){t[n].setNAN();continue}const e=t[n].x;t[n].x=ls(e,s,i)}})(s,e,i.getPannableExtent(),t),hs(s,e,i,0)}}else{(0,n.g)(1===a);const r=i.getTolerance(0),o=i.getPannableExtent();for(let i=0;i<e;i++)s[i].assign(ys(t[i],o,r))}}(t,s,i,m,this.m_inputPCSHorizonClipOption),o!==e&&(0,r.D)(o,e,0,0,s),2===u&&Ms(m,0,i,s),Ys(this.m_projTransform,i,o,s,!1);let _=0;const d=2===c;if(d?_=l.getCentralMeridian():Number.isNaN(this.m_centralMeridianOfOutputGCS)||(_=this.m_centralMeridianOfOutputGCS),d&&0!==this.m_outputPCSHorizonClipOption||hs(i,s,l.getGCS(),_),d){if(!os(i,s,l,this.m_outputPCSHorizonClipOption))for(let t=0;t<s;++t)i[t].setNAN();Cs(l,i,s,!1)}let p=s;for(let t=0;t<s;++t)i[t].isNAN()&&(o&&(o[t]=Number.NaN),p--);return p}}function ce(t){if(2!==t.getCoordinateSystemType())return 0;let e=0;const s=t.getPCSInfo(),i=s.getNorthPoleLocation(),n=s.getSouthPoleLocation(),r=s.getNorthPoleGeometry(),o=s.getSouthPoleGeometry();return r===en.PE_POLE_POINT&&i!==en.PE_POLE_OUTSIDE_BOUNDARY&&(e=1),o===en.PE_POLE_POINT&&n!==en.PE_POLE_OUTSIDE_BOUNDARY&&(e|=2),e}function ge(t,e){const s=t.getHorzUnitFactor(),i=e.getHorzUnitFactor();let n=1,o=1;const a=20015077/180;1===t.getUnit().getUnitType()&&(n=a),1===e.getUnit().getUnitType()&&(o=a);const h=s/i*(n!==o?n/o:1),m=new r.T;return m.setScaleCoords(h,h),m}let _e=class{getOperatorType(){return 10300}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s){return!e||e.isIdentity()?t:new de(t,e,s)}execute(t,e,s){return e.isIdentity()?t:oe(t,e,s)}transform(t,e,s,i,n=!0){return n?function(t,e,s,i){t.m_projector.transformInPlaceZ(e,null,s,i,null,null);const n=i.slice(0,s).filter((t=>!t.isNAN()));for(let t=0,e=n.length;t<e;++t)i[t].assign(n[t]);return n.length}(t,e,s,i):ae(t,e,s,i,null)}transform3D(t,e,s,i,r=!0){return(0,n.g)(0),0}foldInto360Range(t,e){return me(t,e,null)}foldInto360RangeGeodetic(t,e,s){return he(t,e,s,null)}normalizeGeometryEx(t,e,s,o,a=0){return function(t,e,s,o,a){if(!e.isPannable()||t.isEmpty())return t;const h=t.getGeometryType();h===n.G.enumGeometryCollection&&(0,n.a)("not yet impl for geometry collection");const m=e.getPannableExtent();Number.isNaN(s)&&(s=m.getCenterX());const l=m.width(),u=.5*l,c=a>0,g=t.queryInterval(0,0);if(!c&&g.width()<u||!(0,n.i)(t.getGeometryType())){const e=g.getCenter();if(Math.abs(e-s)<=u)return t;{const i=new r.T,n=(0,r.ay)((s-e)/l)*l;i.setShiftCoords(n,0);const o=t.clone();return o.applyTransformation(i),o}}if(h===n.G.enumPolygon){let n=new i.i({vd:t.getDescription()});n.addAndExplicitlyOpenAllPaths(t,!1),c&&(n=pe(n,e,2,a,Number.NaN,null,!0));const h=[];if(!o){{let s=t;c&&(s=new i.h,s.add(n,!1));const o=function(t,e,s){const n=gi();e.querySpheroidData(n);const o=e.getGCS()!==e?e.getSRToGCSTransform():null,a=(0,r.m)(r.P,100),h=new i.O(0,0,0),m=t.getPointCount(),l=e.getGCS().getUnit().getUnitToBaseFactor();for(let e=0,s=m;e<s;){const i=Math.min(100,s-e);t.queryCoordinates(a,i,e,e+i),o&&(new _e).transform(o,a,i,a,!1);for(let t=0;t<i;t++){if(a[t].isNAN())continue;a[t].scale(l);const e=I(n.majorSemiAxis,n.e2,a[t]);h.addThis(e)}e+=i}const u=T(n.majorSemiAxis,n.e2,h);u.scale(1/l);const c=t;if(!new ke(e.getGCS(),u).project(c))return 0;s.length=t.getPathCount();const g=c.calculateArea2D()<0;for(let e=0,i=t.getPathCount();e<i;e++){const t=c.calculateRingArea2D(e),i=g?t<0:t>0;s[e]=i}return g?-1:1}(t,e,h);if(o)o<0&&n.reverseAllPaths();else{const t=s.getPathCount();for(let e=0;e<t;e++)h.push(s.calculateRingArea2D(e)>0)}}o=h}return new Oe(null,o,n,null,e,s,3,0,null).geoNormalizePolygonGeometry(!0)}if(h===n.G.enumPolyline){let n=new i.i({vd:t.getDescription()});return n.addAndExplicitlyOpenAllPaths(t,!1),c&&(n=pe(n,e,2,a,Number.NaN,null,!0)),new Oe(null,null,n,null,e,s,3,0,null).geoNormalizePolylineGeometry(!0)}if(h===n.G.enumMultiPoint){const e=t,i=e.getAttributeStreamRef(0);let n,o=null,a=s,h=0;const m=.1*l;for(let s=0,c=e.getPointCount();s<c;s++){const e=i.read(2*s);let c=e-a;if(Math.abs(c)>u&&(c=(0,r.ay)(c/l)*l,h-=c,Math.abs(h)<m&&(h=0)),0!==h){o||(n=t.clone(),o=n.getAttributeStreamRef(0));const i=e+h;o.write(2*s,i)}a=e}return o?(n.notifyModified(),n):t}(0,n.b)("")}(t,e,s,o,a)}normalizeGeometry(t,e,s){return function(t,e,s){if(!e.isPannable()||t.isEmpty())return t;const i=e.getPannableExtent().width(),o=.5*i,a=t.queryInterval(0,0);if(a.width()<o||!(0,n.i)(t.getGeometryType())){if(Number.isNaN(s))return t;const e=a.getCenter();if(Math.abs(e-s)<=o)return t;{const n=new r.T,o=(0,r.ay)((s-e)/i)*i;n.setShiftCoords(o,0);const a=t.clone();return a.applyTransformation(n),a}}const h=t.getGeometryType(),m=t,l=m.getAttributeStreamRef(0),u=t.clone(),c=u.getAttributeStreamRef(0);let g=0,_=0,d=0,p=(0,n.f)(h)?0:-1;const f=r.E.constructEmpty();let x=!1;for(let t=0,e=m.getPointCount();t<e;t++){const e=l.read(2*t);t===_&&((0,n.f)(h)?(0===p&&Number.isNaN(s)&&(x=!0),p>0&&Number.isNaN(s)&&(s=f.getCenter(),x=!1),_=m.getPathEnd(p),p++):_=m.getPointCount(),Number.isNaN(s)?d=e:(d=s,g=0));let a=e-d;Math.abs(a)>o&&(a=(0,r.ay)(a/i)*i,g-=a,Math.abs(g)<.1*i&&(g=0));const u=e+g;c.write(2*t,u),x&&f.mergeCoordinate(u),d=e}return u.notifyModified(),u}(t,e,s)}clipToSpatialReference(t,e,s,r=0){return function(t,e,s,r){const o=e.getCoordinateSystemType();if(0===o){const i=new Ri;return e.queryPrecisionDescriptor(i),le(t,i,e,s)}let a=t;2!==r&&3!==r||!e.isPannable()||(a=me(a,e,s));const h=new Ri;if(e.queryPrecisionDescriptor(h),a=le(a,h,e,s),0===r||a.isEmpty())return a;if(1===o){if(1===r){const t=new i.a;a.queryLooseEnvelope(t);const n=e.getPannableExtent(),r=.01*n.width();return n.xmin=t.xmin-r,n.xmax=t.xmax+r,(new l.O).execute(a,n,e,s)}return a}if(2===o){const t=e.getPCSHorizon();if(1===r||2===r){const i=(new u.O).execute(a,t,e,s);return i===t?i.clone():i}return a}if(3===o)return a;(0,n.b)("missing implementation")}(t,e,s,r)}};class de extends c.G{constructor(t,e,s){super(),this.m_projTrans=e,this.m_progressTracker=s,this.m_index=-1,t||(0,n.t)(""),this.m_inputGeoms=t}next(){const t=this.m_inputGeoms.next();return null!=t?((0,n.p)(t),(0,n.c)(t),this.m_index=this.m_inputGeoms.getGeometryID(),oe(t,this.m_projTrans,this.m_progressTracker)):null}getGeometryID(){return this.m_index}tock(){return!0}getRank(){return 1}}function pe(t,e,s,r,o,a,h=!1){t||(0,n.t)("Geometry.Geodetic_densify.densify");let m=t.getGeometryType();if((0,n.c)(t),(0,n.p)(t),t.isEmpty()||(0,n.h)(m))return t;const l=new Ce;l.m_sr=e,l.m_gcs=e.getGCS(),l.m_transform=l.m_gcs!==e?e.getSRToGCSTransform():null,l.m_progressTracker=a;const c=gi();let g,_,d;if(l.m_gcs.querySpheroidData(c),l.m_a=c.majorSemiAxis,l.m_eSquared=c.e2,l.m_rpu=l.m_gcs.getUnit().getUnitToBaseFactor(),l.m_gcsTolerance=l.m_gcs.getTolerance(0),l.m_radTolerance=l.m_gcsTolerance*l.m_rpu,l.m_maxLength=r,l.m_maxDeviation=o,l.m_curveType=s,m===n.G.enumEnvelope){const e=new i.h({vd:t.getDescription()});e.addEnvelope(t,!1),g=e,m=n.G.enumPolygon}else if((0,n.e)(m)){const e=new i.i({vd:t.getDescription()});e.addSegment(t,!0),g=e,m=n.G.enumPolyline}else g=t;if(4!==l.m_curveType){if(_=l.m_transform&&!l.m_transform.isIdentity()?(new _e).execute(g,l.m_transform,a):_s(g,l.m_gcs),_.isEmpty())return _;_=fe(l.m_rpu,_);let t=l.geodeticDensify(_);h||(t=(new _e).foldInto360RangeGeodetic(t,l.m_gcs,l.m_curveType)),d=l.m_transform&&!l.m_transform.isIdentity()?(new _e).execute(t,l.m_transform.getInverse(),a):t}else{let t;if(e.isPannable())t=_s(g,e);else{const s=e.getPCSHorizon();t=(new u.O).execute(g,s,e,a),t===s&&(t=s.clone())}if(_=t,_.isEmpty())return _;d=l.shapePreservingDensify(_)}return d}function fe(t,e){const s=new i.a;if(e.queryLooseEnvelope(s),s.width()*t<Math.PI)return e;let n=!1;const o=e.querySegmentIterator(),a=new r.P,h=new r.P;for(;o.nextPath();)for(;o.hasNextSegment();){const e=o.nextSegment();if(a.setCoordsPoint2D(e.getStartXY()),h.setCoordsPoint2D(e.getEndXY()),a.scale(t),h.scale(t),Math.abs(a.x-h.x)>Math.PI){if(!ye(a,h)){n=!0;break}if(Math.abs(a.x-h.x)>2*Math.PI){n=!0;break}}}if(!n)return e;const m=e.createInstance();m.reserve(e.getPointCount());const l=e.getDescription().getAttributeCount()>1,u=new r.P,c=new r.P,g=new r.P(0,0),_=new r.P(0,0),d=new i.P;for(o.resetToFirstPath();o.nextPath();){let e=Number.NaN,s=0;for(;o.hasNextSegment();){const i=o.nextSegment();if(a.setCoordsPoint2D(i.getStartXY()),h.setCoordsPoint2D(i.getEndXY()),a.scale(t),h.scale(t),Number.isNaN(e)?(s=Me(a.x,Number.NaN,s),g.setCoordsPoint2D(a)):g.setCoordsPoint2D(_),e=g.x,ye(a,h)){if(h.x-a.x>2*Math.PI)for(;h.x-a.x>2*Math.PI;)h.x-=2*Math.PI;else if(h.x-a.x<2*-Math.PI)for(;h.x-a.x<2*-Math.PI;)h.x+=2*Math.PI;s=Me(h.x,Number.NaN,s),_.setCoordsPoint2D(h)}else u.setCoordsPoint2D(h),Re(u),s=Me(u.x,e,s),_.setCoords(s+u.x,u.y);if(Math.abs(_.x-h.x)<.5&&_.setCoordsPoint2D(h),l)i.queryCoord(0,d),c.setCoordsPoint2D(g),c.scale(1/t),d.setXY(c),o.isFirstSegmentInPath()?m.startPathPoint(d):m.lineToPoint(d),o.isLastSegmentInPath()&&!o.isPathClosed()&&(i.queryCoord(1,d),c.setCoordsPoint2D(_),c.scale(1/t),d.setXY(c),m.lineToPoint(d));else{o.isFirstSegmentInPath()&&m.insertPath2D(-1,null,0,0,!0);const e=m.getPathCount()-1;c.setCoordsPoint2D(g),c.scale(1/t),m.insertPoint2D(e,-1,c),o.isLastSegmentInPath()&&!o.isPathClosed()&&(c.setCoordsPoint2D(_),c.scale(1/t),m.insertPoint2D(e,-1,c))}}}return m}function xe(t,e,s,i,n,o,a,h,m,l,u,c){const g=new r.P,_=new r.P,d=i.compare(n)>0;Ne(d,i,n,g,_);const p=Se(t,e,s,g,_,o,a,h,m,l,null,u,c);return d&&Te(m,l,null,u),p}function ye(t,e){return!(!Zi(t.y,r.q)||!Zi(e.y,r.q))||!(!Zi(t.y,-r.q)||!Zi(e.y,-r.q))}function Pe(t,e){return!(!Zi(t.y,r.q)||Zi(e.y,r.q))||!(!Zi(t.y,-r.q)||Zi(e.y,-r.q))}function Ee(t,e){return!(!Zi(e.y,r.q)||Zi(t.y,r.q))||!(!Zi(e.y,-r.q)||Zi(t.y,-r.q))}class Ce{constructor(){this.m_sr=null,this.m_gcs=null,this.m_transform=null,this.m_progressTracker=null,this.m_a=0,this.m_eSquared=0,this.m_rpu=0,this.m_gcsTolerance=0,this.m_radTolerance=0,this.m_maxLength=0,this.m_maxDeviation=0,this.m_curveType=0}geodeticDensify(t){const e=t.createInstance(),s=t.querySegmentIterator(),o=[],a=[],h=new i.S,m=t.getDescription().getAttributeCount()>1;for(;s.nextPath();){const t=[0];for(;s.hasNextSegment();){const i=s.nextSegment(),l=i.getStartXY(),u=i.getEndXY();l.scale(this.m_rpu),u.scale(this.m_rpu);const c=new r.P,g=new r.P,_=l.compare(u)>0;Ne(_,l,u,c,g),o.length=0,a.length=0,this.m_maxLength>0?Se(this.m_a,this.m_eSquared,this.m_curveType,c,g,this.m_maxLength,this.m_maxDeviation,this.m_radTolerance,null,null,m?a:null,o,t):(0,n.g)(0),_&&Te(null,null,m?a:null,o),o[0].setCoordsPoint2D(i.getStartXY()),o.at(-1).setCoordsPoint2D(i.getEndXY());const d=1/this.m_rpu;for(let t=1,e=o.length-1;t<e;t++)o[t].scale(d);if(m){const t=Ae(_,i,h);be(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),i,t,a,o,e)}else ve(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),o,e)}}return e}shapePreservingDensify(t){const e=t.createInstance(),s=t.querySegmentIterator(),n=[],r=[],o=new i.S,a=t.getDescription().getAttributeCount()>1;for(;s.nextPath();)for(;s.hasNextSegment();){const t=s.nextSegment(),i=t.getStartXY(),h=t.getEndXY(),m=i.compare(h)>0,l=Ae(m,t,o);n.length=0,r.length=0,De(this.m_a,this.m_eSquared,this.m_rpu,l,this.m_sr,this.m_maxLength,this.m_maxDeviation,a?r:null,n),m&&Te(null,null,a?r:null,n),a?be(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),t,l,r,n,e):ve(s.isFirstSegmentInPath(),s.isLastSegmentInPath()&&!s.isPathClosed(),n,e)}return e}}function ve(t,e,s,i){t&&i.insertPath2D(-1,null,0,0,!0);const n=i.getPathCount()-1;i.insertPointsFromPoints(n,-1,s,0,s.length-1,!0),e&&i.insertPoint2D(n,-1,s.at(-1))}function be(t,e,s,n,r,o,a){a.reserve(a.getPointCount()+o.length-1);const h=new i.P;if(s.queryStart(h),t?a.startPathPoint(h):a.lineToPoint(h),o.length>2){const t=n.calculateLength2D();for(let e=1;e<o.length-1;e++){const s=n.lengthToT(r[e]*t);n.queryCoord(s,h),h.setXY(o[e]),a.lineToPoint(h)}}e&&(s.queryEnd(h),a.lineToPoint(h))}function Se(t,e,s,i,n,a,h,m,l,u,c,g,_){const d={stack:[],error:void 0,hasError:!1};try{const p=(0,o.b)(d,new Qi,!1),f=(0,o.b)(d,new Qi,!1),x=(0,o.b)(d,new Qi,!1);rn.geodeticDistance(t,e,i.x,i.y,n.x,n.y,x,p,f,s);const y=x.val,P=p.val,E=f.val;let C=P,v=E;C<0&&(C+=2*Math.PI),v<0&&(v+=2*Math.PI),l&&(l[0]=C),u&&(u[0]=v);let b=Number.NaN,S=Number.NaN;if(null!==c){const s=on.q90(t,e),n=on.q(t,e,i.y);b=(s-n)/y,S=(s+n)/y}const I=Pe(i,n),w=Ee(i,n),D=I||w,T=function(t,e,s){return!(!Ve(t,e,s)||Zi(t.y,r.q)||Zi(t.y,-r.q)||Zi(e.y,r.q)||Zi(e.y,-r.q))}(i,n,m),N=(0,o.b)(d,new r.S(new Qi,new Qi),!1),A=new r.P,M=new r.P,G=new r.P;_[0]=Me(i.x,Number.NaN,_[0]);let q=_[0];if(y<=a)return g.push(i.clone()),_[0]=Me(n.x,Number.NaN,_[0]),null!=c&&c.push(0),D?(I&&Ge(i,n,c,g),w&&qe(i,n,c,g)):T?Fe(i,n,P,b,S,c,g):h>0&&(M.setCoords(i.x-q,i.y),A.setCoords(n.x-_[0],n.y),q=Ie()),g.push(n.clone()),y;const F=1+Math.ceil(y/a),V=y/(F-1),R=new r.P;g.push(i.clone()),R.setCoordsPoint2D(i),M.setCoords(i.x-_[0],i.y),null!==c&&c.push(0);for(let r=1;r<F;r++){let o;if(r<F-1){const n=r*V;rn.geodeticCoordinate(t,e,i.x,i.y,n,P,N.at(0),N.at(1),s),A.setCoords(N.at(0).val,N.at(1).val),_[0]=Me(A.x,R.x,_[0]),G.setCoords(_[0]+A.x,A.y),o=r/(F-1)}else _[0]=Me(n.x,Number.NaN,_[0]),A.setCoords(n.x-_[0],n.y),G.setCoordsPoint2D(n),o=1;D?(1===r&&I&&Ge(i,G,c,g),r===F-1&&w&&qe(R,n,c,g)):T?Ve(R,G,m)&&(i.x<n.x?R.x>G.x&&(_[0]+=2*Math.PI,G.setCoords(_[0]+A.x,A.y)):R.x<G.x&&(_[0]-=2*Math.PI,G.setCoords(_[0]+A.x,A.y)),Fe(R,G,P,b,S,c,g)):h>0&&Ie(),g.push(G.clone()),null!=c&&c.push(o),R.setCoordsPoint2D(G),M.setCoordsPoint2D(A),q=_[0]}return y}catch(t){d.error=t,d.hasError=!0}finally{(0,o.c)(d)}}function Ie(t,e,s,i,r,o,a,h,m,l,u,c,g,_,d){return(0,n.g)(0),0}function we(t,e,s,n){const r=I(t,e,s),o=I(t,e,n);return i.O.distance(r,o)}function De(t,e,s,i,n,o,a,h,m){const l=i.isCurve(),u=function(t,e){return t*Math.sqrt(1-e)}(t,e)*Math.PI*179/180;let c=o;o>0&&!(o>u)||(c=u),c=H(t,e,c);let g=a;!l||g>0||(g=.001);const _=g>0;let d=Number.NaN;_&&(d=H(t,e,g));const p=n.getPECoordSys(),f=1===n.getCoordinateSystemType(),x=n.getTolerance(0),y=i.getStartXY(),P=i.getEndXY(),E=new r.P,C=new r.P;if(f)E.setCoordsPoint2D(y),E.scale(s),C.setCoordsPoint2D(P),C.scale(s);else{const t=[y.x,y.y,P.x,P.y];$i.projToGeog(p,2,t),E.setCoords(t[0],t[1]),E.scale(s),C.setCoords(t[2],t[3]),C.scale(s)}let v=0,b=0;const S=[],w=[],D=[];S.push(P.clone()),w.push(C.clone()),D.push(1),m.push(y.clone()),null!==h&&h.push(b);const T=n.isPannable(),N=y.clone(),M=[.5,.33333333333333337,.6666666666666666,.16666666666666669,.8333333333333333];let G=5;for(l||(_?(M[0]=.5,M[1]=.25,M[2]=.75,G=3):G=1);w.length>0;){const o=S.at(-1).clone();C.assign(w.at(-1));const a=D.at(-1);let u=!1,g=Number.NaN;const y=we(t,e,E,C);let P=c>=y&&Math.abs(E.y-C.y)<.9*Math.PI;f&&P&&(P=Math.abs(E.x-C.x)<.9*Math.PI);const F=new r.P,V=new r.P;let R=!1;if(l||_||!P||P&&(R=!0),i.calculateSubLength(b,a)<=x&&(R=!0),!R)for(let o=0;o<G;o++){const h=(0,r.w)(b,a,M[o]),m=new r.P;i.queryCoord2D(h,m);const l=new r.P;if(f)l.setCoords(m.x*s,m.y*s);else{const t=[m.x,m.y];$i.projToGeog(p,1,t),l.setCoords(t[0]*s,t[1]*s)}if(0===o&&(g=h,F.setCoordsPoint2D(m),V.setCoordsPoint2D(l),!P)){u=!0;break}if(f&&Math.abs(E.x-l.x)>=Math.PI){u=!0;break}if(c<we(t,e,E,l)){u=!0;break}if(_){const h=A(t,e,E,C,M[o]),m=h.clone();if(f?(m.x/=s,m.y/=s):(m.x/=s,m.y/=s,ae(n.getGCSToSRTransform(),[m],1,[m],null)),m.isNAN()){const s=I(t,e,l),i=I(t,e,E),n=I(t,e,C),{first:r,second:o}=q(t,e,s,i,n,2,null);if(o>d){u=!0;break}}else{if(T){const t=n.getPannableExtent().width(),e=(0,r.w)(i.getStartX(),i.getEndX(),.5);for(;m.x<e-.5*t;)m.x+=t;for(;m.x>=e+.5*t;)m.x-=t}const o=i.getClosestCoordinateOnInterval(m,new r.E(b,a),-1),l=i.getCoord2D(o);if(!f){const t=[l.x,l.y];$i.projToGeog(p,1,t),l.x=t[0],l.y=t[1]}l.x*=s,l.y*=s;let c=we(t,e,l,h);if(c>d){if(c<4*d){const s=I(t,e,l),i=I(t,e,E),n=I(t,e,C),{first:r,second:o}=q(t,e,s,i,n,2,null);c=o}if(c>d){u=!0;break}}}}}u?(S.push(F.clone()),w.push(V.clone()),D.push(g)):(S.pop(),w.pop(),D.pop(),m.push(o.clone()),v+=y,null!==h&&h.push(v),N.setCoordsPoint2D(o),E.setCoordsPoint2D(C),b=a)}if(null!==h){const t=1/v;for(let e=0;e<h.length;e++)h[e]*=t}}function Te(t,e,s,i){if(i.reverse(),null!==s&&s.reverse(),t){const s=t[0],i=e[0];t[0]=i,e[0]=s}}function Ne(t,e,s,i,n){t?(i.setCoordsPoint2D(s),n.setCoordsPoint2D(e)):(i.setCoordsPoint2D(e),n.setCoordsPoint2D(s))}function Ae(t,e,s){return t?(s.create(e.getGeometryType()),e.copyTo(s.get()),s.get().reverse(),s.get()):e}function Me(t,e,s){if(Number.isNaN(e)){for(;s-t>Math.PI;)s-=2*Math.PI;for(;t-s>Math.PI;)s+=2*Math.PI;return s}return s+t-e>Math.PI?s-=2*Math.PI:e-(s+t)>Math.PI&&(s+=2*Math.PI),s}function Ge(t,e,s,i){if(t.y>0){const n=new r.P;n.setCoords(e.x,r.q),Zi(t.x,n.x)||Zi(e.y,n.y)||(i.push(n),null!==s&&s.push(0))}else{const n=new r.P;n.setCoords(e.x,-r.q),Zi(t.x,n.x)||Zi(e.y,n.y)||(i.push(n),null!==s&&s.push(0))}}function qe(t,e,s,i){if(e.y>0){const n=new r.P;n.setCoords(t.x,r.q),Zi(e.x,n.x)||Zi(t.y,n.y)||(i.push(n),null!==s&&s.push(1))}else{const n=new r.P;n.setCoords(t.x,-r.q),Zi(e.x,n.x)||Zi(t.y,n.y)||(i.push(n),null!==s&&s.push(1))}}function Fe(t,e,s,i,n,o,a){if(function(t){return function(t,e){return 0===t||Math.abs(t)<=e}(t,ji)}(s)){if(r.q-t.y>0){const e=new r.P;e.setCoords(t.x,r.q),a.push(e),null!==o&&o.push(i)}if(r.q-e.y>0){const t=new r.P;t.setCoords(e.x,r.q),a.push(t),null!==o&&o.push(i)}}else{if(r.q+t.y>0){const e=new r.P;e.setCoords(t.x,-r.q),a.push(e),null!==o&&o.push(n)}if(r.q+e.y>0){const t=new r.P;t.setCoords(e.x,-r.q),a.push(t),null!==o&&o.push(n)}}}function Ve(t,e,s){return Math.abs(Math.abs(t.x-e.x)-Math.PI)<=s}function Re(t){if(t.x<-Math.PI)for(;t.x<-Math.PI;)t.x+=2*Math.PI;else if(t.x>Math.PI)for(;t.x>Math.PI;)t.x-=2*Math.PI}function Ye(t,e,s,i){const n={stack:[],error:void 0,hasError:!1};try{const r=[s.x],a=[s.y-i],h=[s.x],m=[s.y+i];V(r,a),V(h,m);const l=(0,o.b)(n,new Qi,!1),u=(0,o.b)(n,new Qi,!1);return rn.greatEllipticDistance(t,e,s.x,s.y,r[0],a[0],l,null,null),rn.greatEllipticDistance(t,e,s.x,s.y,h[0],m[0],u,null,null),Math.min(l.val,u.val)}catch(t){n.error=t,n.hasError=!0}finally{(0,o.c)(n)}}function Xe(t,e,s,n,o){const h=new i.a;s.queryEnvelope(h);const m=(0,i.u)(null,s,!0).total();if(e.xmin-h.xmin<=m&&h.xmax-e.xmax<=m)return s;const l=e.width();let u=0;for(;e.xmin+u*l<h.xmin;)u++;for(;e.xmin+u*l>h.xmin;)u--;const c=u*l,g=new r.T;g.setShiftCoords(-c,0);const _=s;_.applyTransformation(g);const d=new i.a;_.queryEnvelope(d);let p=null;if(d.xmax>e.xmax){let s=0;const n=new i.a;n.setCoords({env2D:e}),n.ymin-=1,n.ymax+=1;let r=_;for(;n.xmin<d.xmax;){d.xmax>n.xmax&&(r=cs(r,t,2,!0,n.xmax));const h=(0,i.K)(r,n),m=(0,i.b)(null,h,!0).total(),u=(0,a.c)(r,n,m,Number.NaN,o);null===p?p=u===r?u.clone():u:(g.setShiftCoords(-s*l,0),u.applyTransformation(g),p.add(u,!1)),s++,n.xmin=n.xmax,n.xmax=e.xmax+s*l}}else p=_;return p}class ke{constructor(t,e){this.m_basisX=new i.O,this.m_basisY=new i.O,this.m_normal=new i.O,(0,n.g)(1===t.getCoordinateSystemType()),this.m_gcs=t;const s=gi();t.querySpheroidData(s),this.m_a=s.majorSemiAxis,this.m_e2=s.e2,this.m_rpu=t.getUnit().getUnitToBaseFactor(),this.m_curvCenterRad=e.mul(this.m_rpu);const o=this.m_curvCenterRad.x,a=this.m_curvCenterRad.y,h=Math.cos(o),m=Math.sin(o),l=Math.cos(a),u=Math.sin(a);this.m_cartCenter3D=function(t,e,s,i,n,r){return w(t,e,s,i,n,r,0)}(this.m_a,this.m_e2,h,m,l,u),this.m_normal.setCoordsPoint3D(this.m_cartCenter3D),this.m_d=this.m_cartCenter3D.length(),this.m_normal.divThis(this.m_d),i.O.selectRightHandedBasisFromNormal(this.m_normal,this.m_basisX,this.m_basisY),this.m_northPolePcs=this.projectPoint(r.P.construct(0,.5*Math.PI/this.m_rpu)),this.m_southPolePcs=this.projectPoint(r.P.construct(0,.5*-Math.PI/this.m_rpu))}project(t){const e=t.getGeometryType();if((0,n.i)(e)){(0,n.p)(t);const e=t;return this.projectMultiVertex(e)}(0,n.t)("Gnomonic.project")}unproject(t,e,s){const o=t.getGeometryType();if((0,n.i)(o)){(0,n.p)(t);let a=t;const h=[];if(o===n.G.enumPolygon){const t=a.getPathCount();for(let e=0;e<t;e++){const t=a.calculateRingArea2D(e);h.push(t)}}return this.unprojectMultiVertex(e,a),(0,n.f)(o)?(function(t,e,s){const i=t.getPannableExtent(),n=r.P.construct(0,0);i.centerAt(n);const o=i.width(),a=.5*o,h=new r.P;h.setNAN();let m=Number.NaN;for(let t=0;t<s.getPathCount();t++)for(let e=s.getPathStart(t);e<s.getPathEnd(t);e++){const n=s.getXY(e),r=Zi(n.y,i.ymax)||Zi(i.ymin,n.y);e===s.getPathStart(t)?(h.setNAN(),m=0):h.isNAN()||r||(m=Le(n.x,h.x,a,o,m)),n.x+=m,s.setXY(e,n),r||h.setCoordsPoint2D(n)}s.getImpl().notifyModifiedFlags(2001)}(this.m_gcs,0,a),function(t,e,s,o,a){const h=o.getGeometryType(),l=e.getPannableExtent();let u=o,c=!1,g=!1;if(h===n.G.enumPolygon){const s=new i.a,n=r.P.construct(0,0);s.setCoords({env2D:l}),s.centerAt(n),c=function(t,e,s,n,o){const a=function(t,e){const s=new i.a;e.queryEnvelope(s);const n=Zi(t.ymax,s.ymax),o=Zi(t.ymin,s.ymin),a=n||o;return!!a&&(function(t,e){const s=new i.h,n=new i.a;for(let i=0;i<e.getPathCount();i++){e.queryPathEnvelope(i,n);let o=Zi(t.ymax,n.ymax),a=Zi(t.ymin,n.ymin);if(!o&&!a){s.addPath(e,i,!0);continue}s.insertPath2D(-1,null,0,0,!0);const h=e.getPathStart(i),m=e.getPathEnd(i),l=m-h;let u=-1;for(u=h;u<m;u++){const s=e.getXY(u);if(o=Zi(t.ymax,s.y),a=Zi(t.ymin,s.y),!o&&!a)break}let c=u,g=!1,_=Number.NaN;do{const n=e.getXY(c);o=Zi(t.ymax,n.y),a=Zi(t.ymin,n.y);const m=h+(c+1-h)%l;if(o||a){let o=r.P.construct(_,n.y);s.insertPoint2D(i,-1,o);const a=e.getXY(m),h=Zi(t.ymax,a.y),l=Zi(t.ymin,a.y);h||l||(o=r.P.construct(a.x,n.y),g?s.setXY(s.getPointCount()-1,o):s.insertPoint2D(i,-1,o)),g=!0}else s.insertPoint2D(i,-1,n),_=n.x,g=!1;c=m}while(c!==u)}e.setEmpty(),e.add(s,!1)}(t,e),a)}(s,n),h=function(t,e,s,n,r){const o=[],a=[],h=.5*s.width();for(let i=0;i<n.getPathCount();i++){const m=n.getXY(n.getPathStart(i)),l=n.getXY(n.getPathEnd(i)-1),u=t[i]<0;if(Math.abs(m.x-l.x)>h){const t=He(u,e,s,i,n,r);o.push(t),a.push(i)}else if(!u&&n.calculateRingArea2D(i)<0){const t=Be(e,s,i,n,r);o.push(t),a.push(i)}}if(0===o.length)return!1;const m=new i.h({vd:n.getDescription()});let l=0,u=a[l];for(let t=0;t<n.getPathCount();t++)t===u?(m.add(o[l],!1),l++,l<a.length&&(u=a[l])):m.addPath(n,t,!0);return n.setEmpty(),n.add(m,!1),!0}(t,e,s,n,o);return a||h}(t,e,s,u,a);const o=function(t,e,s,n){const r=new i.a;s.queryEnvelope(r);const o=(0,i.u)(null,s,!0).total();if(e.xmin-r.xmin<=o&&r.xmax-e.xmax<=o)return s;const a=s.createInstance();let h=s.createInstance();const m=new i.a,l=s.getPathCount();for(let i=0;i<l;i++)s.queryPathEnvelope(i,m),e.xmin-m.xmin<=o&&m.xmax-e.xmax<=o?a.addPath(s,i,!0):(h.setEmpty(),h.addPath(s,i,!0),h=Xe(t,e,h,0,n),a.add(h,!0));return a}(e,s,u,a);o!==u&&(g=!0),u=o}else u=(new _e).foldInto360RangeGeodetic(u,e,2);h===n.G.enumPolygon&&(c||g)&&(u=(new m.O).execute(u,e,!1,a)),u!==o&&(o.setEmpty(),o.add(u,!1))}(h,this.m_gcs,0,a,s)):a=as(a,this.m_gcs,0,!0,0,s),a}(0,n.t)("Gnomonic.unproject")}projectPoint(t){const e=t.mul(this.m_rpu),s=I(this.m_a,this.m_e2,e),i=this.m_normal.dotProduct(s);if(i<=0)return r.P.construct(Number.NaN,Number.NaN);const n=this.m_d/i,o=s.mul(n).sub(this.m_cartCenter3D),a=new r.P;return a.x=this.m_basisX.dotProduct(o),a.y=this.m_basisY.dotProduct(o),a}unprojectPoint(t){const e=this.m_cartCenter3D.add(this.m_basisX.mul(t.x).add(this.m_basisY.mul(t.y)));return T(this.m_a,this.m_e2,e).divide(this.m_rpu)}projectMultiVertex(t){const e=t.getImpl();let s=!0;const i=new r.P,n=new r.P;for(let t=0,r=e.getPointCount();t<r;t++)e.queryXY(t,i),i.y*this.m_rpu>.5*Math.PI?n.assign(this.m_northPolePcs):i.y*this.m_rpu<.5*-Math.PI?n.assign(this.m_southPolePcs):n.assign(this.projectPoint(i)),e.setXY(t,n),n.isNAN()&&(s=!1);return e.notifyModifiedFlags(2001),s}unprojectMultiVertex(t,e){const s=e.getImpl(),i=t*t,n=!this.m_northPolePcs.isNAN(),o=!this.m_southPolePcs.isNAN();for(let t=0,e=s.getPointCount();t<e;t++){const e=s.getXY(t);let a=new r.P;n&&r.P.sqrDistance(e,this.m_northPolePcs)<=i?(a.setCoords(this.m_curvCenterRad.x,.5*Math.PI),a.scale(1/this.m_rpu)):o&&r.P.sqrDistance(e,this.m_southPolePcs)<=i?(a.setCoords(this.m_curvCenterRad.x,.5*-Math.PI),a.scale(1/this.m_rpu)):a=this.unprojectPoint(e),s.setXY(t,a)}s.notifyModifiedFlags(2001)}}function He(t,e,s,n,o,h){const m=new i.h,l=new i.h,u=new r.T,c=o.getXY(o.getPathStart(n)),g=o.getXY(o.getPathEnd(n)-1),_=s.width(),d=.5*_,p=new i.a;o.queryEnvelope(p);const f=Math.ceil(p.width()/_)+1;let x,y;c.x>g.x?(x=-_,y=t?s.ymin:s.ymax):(x=_,y=t?s.ymax:s.ymin),u.setShiftCoords(x,0),m.addPath(o,n,!0),l.add(m,!1);const P=new i.P;for(let t=0;t<f;t++)l.applyTransformation(u),l.getPointByVal(0,P),m.lineToPoint(P),m.addSegmentsFromPath(l,0,0,l.getSegmentCount()-1,!1);const E=m.getXY(0),C=m.getXY(m.getPointCount()-1);E.y=y,C.y=y,m.lineTo(C);const v=new r.P;for(v.setCoordsPoint2D(C),v.x-=.5*x;Math.abs(v.x-E.x)>d;)m.lineTo(v),v.x-=.5*x;m.lineTo(E);const b=s.getCenter().x,S=new i.a;m.queryEnvelope(S);let I=0;const w=S.getCenter().x;w-b>d?I=-Math.ceil((w-b-d)/_):b-w>d&&(I=Math.ceil((b-w-d)/_)),0!==I&&(u.setShiftCoords(I*_,0),m.applyTransformation(u));const D=new i.d,T=D.addGeometry(m);gs(D,T,e,0,2,!0,s.xmin),gs(D,T,e,0,2,!0,s.xmax);const N=D.getGeometry(T),A=(0,i.K)(N,s);A.inflateCoords(0,1);const M=(0,i.b)(null,A,!0);return(0,a.c)(N,s,M.total(),Number.NaN,h)}function Be(t,e,s,n,o){const h=e.width(),m=.5*h,l=e.getCenter().x,u=new i.a;n.queryPathEnvelope(s,u);let c,g=0,_=u.getCenter().x;if(_-l>m?g=-Math.ceil((_-l-m)/h):l-_>m&&(g=Math.ceil((l-_-m)/h)),0!==g){const t=new r.T;t.setShiftCoords(g*h,0),n.getImpl().applyTransformationToPath(t,s),n.queryPathEnvelope(s,u),_=u.getCenter().x}const d=new i.a;e.containsExclusiveEnvelope(u)?(c=!1,d.setCoords({env2D:e})):(c=!0,d.setCoords({env2D:e}),d.xmin-=h,d.xmax+=h);let p=n.createInstance();p.addPathPoint2D(null,0,!0);const f=new r.P;if(f.setCoords(d.xmin,d.ymin),p.insertPoint2D(0,-1,f),f.setCoords(d.xmin,d.ymax),p.insertPoint2D(0,-1,f),f.setCoords(.5*(d.xmin+d.xmax),d.ymax),p.insertPoint2D(0,-1,f),f.setCoords(d.xmax,d.ymax),p.insertPoint2D(0,-1,f),f.setCoords(d.xmax,d.ymin),p.insertPoint2D(0,-1,f),f.setCoords(.5*(d.xmin+d.xmax),d.ymin),p.insertPoint2D(0,-1,f),c){p.addPath(n,s,!0);const m=new r.T;_<l?m.setShiftCoords(h,0):m.setShiftCoords(-h,0),n.getImpl().applyTransformationToPath(m,s),p.addPath(n,s,!0);const u=new i.d,c=u.addGeometry(p);gs(u,c,t,0,2,!0,e.xmin),gs(u,c,t,0,2,!0,e.xmax),p=u.getGeometry(c);const g=(0,i.K)(p,e);g.inflateCoords(0,1);const d=(0,i.b)(null,g,!0).total();p=(0,a.c)(p,e,d,Number.NaN,o)}else p.addPath(n,s,!0);return p}function Le(t,e,s,i,n){return n+t-e>s?n-=i:e-(n+t)>s&&(n+=i),n}function ze(t,e,s,n,o,a){const h=e.getAttributeStreamRef(0),m=e.getPointCount();let l=!1;const u=new r.P;for(let t=0;t<m;++t){if(h.queryPoint2D(2*t,u),1&a&&u.y>=s){l=!0;break}if(2&a&&u.y<=-s){l=!0;break}}if(!l)return!1;let c=!1;t&&(c=e.getImpl().isClosedPathInXYPlane(0));const g=new i.d,_=g.addGeometry(e),d=g.getFirstPath(_);let p=-1,f=!0;const x=new r.P,y=new i.P;let P=i.n;const E=Ue*o/360;for(let t=g.getFirstVertex(d);t!==i.n;t=g.getNextVertex(t)){g.queryXY(t,u);let e=1&a&&u.y>=s?1:0;if(e|=2&a&&u.y<=-s?2:0,p>0&&p!==e){if(x.x!==u.x){const e=g.getPrevVertex(t);g.queryPoint(e,y);const s=g.insertVertex(d,t,y);x.x=u.x,g.setXY(s,x)}if(c){let e=P!==i.n?g.getNextVertex(P):g.getFirstVertex(d);const s=g.getPrevVertex(t);for(;e!==s;)e=g.removeVertex(e,!1);if(P!==i.n){const t=g.getXY(P),e=g.getXY(s);if(Math.abs(t.x-e.x)>E){g.queryPoint(P,y);const i=g.insertVertex(d,s,y);t.x=(0,r.w)(t.x,e.x,.5),g.setXY(i,t)}}}P=i.n}if(e&&(u.y=(0,r.c)(n,u.y),g.setXY(t,u),!f&&p!==e))if(u.x!==x.x){g.queryPoint(t,y);const e=g.insertVertex(d,t,y);g.setXYCoords(e,x.x,u.y),P=e}else P=t;p=e,x.assign(u),f=!1}if(c){if(P!==i.n){let t=g.getNextVertex(P);for(;t!==i.n;)t=g.removeVertex(t,!1)}const t=g.getFirstVertex(d);let e=g.getLastVertex(d);const s=g.getXY(t),n=g.getXY(e);if(!s.equals(n)&&(g.queryPoint(t,y),e=g.insertVertex(d,i.n,y),Math.abs(s.x-n.x)>E)){const t=g.insertVertex(d,e,y);s.x=(0,r.w)(s.x,n.x,.5),g.setXY(t,s)}}return e.assignCopy(g.getGeometry(_)),!0}const Ue=210;class Oe{constructor(t,e,s,i,r,o,a,h,m){this.m_bAdjustedAtPoles=0,this.m_inputPoly=s,this.m_progressTracker=m,this.m_originalGeometry=t,this.m_originalSR=i,this.m_polygonRingFlags=e,this.m_pannableSR=r,this.m_poleSnappingTolerance=h,this.m_poleFlags=a,this.m_bAdjustedAtPoles=0,this.m_pannableExtent=function(t,e){const s=t.getPannableExtent();return Number.isNaN(e)||s.centerAtCoords(e,0),s}(this.m_pannableSR,o),this.m_centralLongitude=Number.isNaN(o)?this.m_pannableExtent.getCenterX():o,this.m_width360=this.m_pannableExtent.width(),this.m_degree=this.m_width360/360,this.m_GCSLargeDelta=Ue*this.m_degree,(0,n.g)(null===this.m_originalGeometry&&null===this.m_originalSR||null!==this.m_originalGeometry&&null!==this.m_originalSR)}geonormalizeRing(t,e,s,o,a,h,m){let l=s;const u=new i.i({vd:this.m_inputPoly.getDescription()});u.addPath(this.m_inputPoly,t,!0),0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=ze(!0,u,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,this.m_pannableExtent.width(),this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(l=!1));let c=-1;l&&(c=this.m_originalGeometry.getPathStart(t));const g=u.getAttributeStreamRef(0),_=u.getPointCount();let d=0,p=g.read(0),f=0;const x=3*this.m_pannableSR.getTolerance(0);let y=!1;const P=new r.P,E=new r.P;let C=!1;const v=u.hasNonLinearSegments(),b=new r.P;for(let t=1;t<_;++t){g.queryPoint2D(2*t,b);const e=b.x;let s=e+d;const a=s-p;if(b.x=s,Math.abs(a)>this.m_GCSLargeDelta){if(l){const e=c+t-1,s=c+(t+1<_?t:0),i=h.read(2*e),n=(h.read(2*s)-i)*o;Math.abs(a-n)>1*this.m_degree&&(l=!1)}l||(d-=(0,r.c)(this.m_width360,s-p),s=e+d,++f,C=0!==d,b.x=s)}else y||(0,i.aI)(P,E,b,x)&&(y=!0);C&&(v&&(0,n.b)("error in geonormalize_ring_ for curves"),g.write(2*t,s)),p=s,P.setCoordsPoint2D(E),E.setCoordsPoint2D(b)}f&&u.notifyModified();const S=u.getXY(0),I=u.getXY(_-1);if(r.P.distance(S,I)<x){const t=this.finalizeGeoNormalizeClosedRing(u,y,a);m.add(t,!1)}else{e<0&&(null!==this.m_originalGeometry?((0,n.g)(null!==this.m_originalGeometry),e=this.m_originalGeometry.calculateRingArea2D(t)>0?1:0):e=1);const s=this.finalizeGeoNormalizeOpenedRing(e>0,u);m.add(s,!1)}}geoNormalizePolygonGeometry(t){(0,n.g)(this.m_originalSR&&this.m_originalGeometry||!this.m_originalGeometry&&!this.m_originalSR),(0,n.g)(this.m_pannableSR.isPannable());let e=null,s=Number.NaN;const r=!!this.m_originalSR&&this.m_originalSR.isPannable();r&&(e=this.m_originalGeometry.getAttributeStreamRef(0),s=this.m_width360/this.m_originalSR.getPannableExtent().width()),this.m_bAdjustedAtPoles=0;const o=new i.h({vd:this.m_inputPoly.getDescription()});for(let i=0,n=this.m_inputPoly.getPathCount();i<n;++i){const n=this.m_polygonRingFlags?this.m_polygonRingFlags[i]?1:0:-1;this.geonormalizeRing(i,n,r,s,t,e,o)}const l=this.m_pannableSR.getTolerance(0),u=this.m_pannableExtent.width()/180;xs(o,this.m_pannableExtent,.1*l,!1);const c=i.a.constructEmpty();if(c.setCoords({env2D:this.m_pannableExtent}),t){let t=!0;for(let e=0;e<2;e++){t=!0;const e=i.a.constructEmpty();for(let s=0,i=o.getPathCount();s<i;s++)if(o.queryPathEnvelope(s,e),!(c.xmin<=e.xmin&&c.xmax>=e.xmax||e.xmin>=c.xmax||e.xmax<=c.xmin)){t=!1;break}if(t)break;c.move(.5*this.m_width360,0)}t||c.setCoords({env2D:this.m_pannableExtent})}let g=(0,a.c)(o,c,l,u,this.m_progressTracker),_=o!==g;const d=this.m_originalGeometry?this.m_originalGeometry.calculateArea2D():1,p=g.calculateArea2D();let f=0;if(p>0&&d<0)f=1;else if(p<=0&&d>0)if(0===p){if(this.m_originalSR){let t=Number.NaN;2===this.m_originalSR.getCoordinateSystemType()?t=this.m_originalSR.getPCSHorizon().calculateArea2D():1===this.m_originalSR.getCoordinateSystemType()&&(t=this.m_originalSR.getPannableExtent().getArea()),d>.99*t&&(f=-1)}}else f=-1;if(0!==f){const t=function(t,e){let s=new i.h({vd:t});s.addEnvelope(e,!1);const n=e.width()/180;return s=(new h.O).execute(s,n,0,0,null),s}(g.getDescription(),c);t.add(g,!1),_=!0,g=t}return _&&(g=(new m.O).execute(g,this.m_pannableSR,!1,this.m_progressTracker)),g}geoNormalizePolylineGeometry(t){(0,n.g)(this.m_pannableSR.isPannable());let e=null;const s=this.m_originalSR&&this.m_originalSR.isPannable();let o=1;s&&((0,n.g)(this.m_originalGeometry),o=this.m_width360/this.m_originalSR.getPannableExtent().width(),e=this.m_originalGeometry.getAttributeStreamRef(0));const h=this.m_pannableExtent.width(),m=h*(0,r.aa)()*4;let l=t,u=Number.NaN;const c=r.E.constructEmpty();this.m_bAdjustedAtPoles=0;let g=new i.i({vd:this.m_inputPoly.getDescription()});for(let t=0,a=this.m_inputPoly.getPathCount();t<a;++t){let a=s;const _=new i.i({vd:this.m_inputPoly.getDescription()});_.addPath(this.m_inputPoly,t,!0);const d=this.m_inputPoly.isClosedPath(t);0!==this.m_poleFlags&&(this.m_bAdjustedAtPoles|=ze(d,_,this.m_pannableExtent.ymax-this.m_poleSnappingTolerance,this.m_pannableExtent.ymax,h,this.m_poleFlags)?1:0,this.m_bAdjustedAtPoles&&(a=!1));let p=-1;const f=_.getPointCount();let x=!1;a&&(p=this.m_originalGeometry.getPathStart(t),x=this.m_originalGeometry.isClosedPath(t));const y=_.getAttributeStreamRef(0);let P=0,E=y.read(0),C=0;const v=new r.P,b=new r.P;let S=!1;const I=_.hasNonLinearSegments(),w=new r.P;for(let t=1;t<f;++t){y.queryPoint2D(2*t,w);const s=w.x;let i=s+P;const h=i-E;if(w.x=i,Math.abs(h)>this.m_GCSLargeDelta){if(a){const s=p+t-1;let i=p;(!x||t+1<f)&&(i+=t);const n=e.read(2*s),r=(e.read(2*i)-n)*o;Math.abs(h-r)>1*this.m_degree&&(a=!1)}a||(P-=(0,r.c)(this.m_width360,i-E),i=s+P,++C,S=0!==P,w.x=i)}S&&(I&&(0,n.b)("error in geonormalize_ring_ for curves"),y.write(2*t,i)),E=i,v.setCoordsPoint2D(b),b.setCoordsPoint2D(w)}if(C&&_.notifyModified(),l){let t=!1;if(!_.isEmpty()){const e=i.a.constructEmpty();if(_.queryEnvelope(e),e.width()>=h||e.ymin<=this.m_pannableExtent.ymin||e.ymax>=this.m_pannableExtent.ymax)t=!0;else{if(Number.isNaN(u)){const t=this.m_centralLongitude-.5*h;u=e.xmin,u+=Math.round((t-e.xmin)/h)*h,u>t&&(u-=h),(0,n.g)(u<=t),u<t&&(u+=h),(0,n.g)(u>=t)}let s=Math.round((u-e.xmin)/h)*h;if(e.xmin+s>u+m&&(s-=h),e.xmin+s<u-m&&(s+=h),c.mergeCoordinate(e.xmin+s),c.mergeCoordinate(e.xmax+s),t=c.width()>=h,!t){const t=new r.T;t.setShiftCoords(s,0),_.applyTransformation(t)}}}g.add(_,!1),t&&(g=(()=>{const t=new i.i({vd:g.getDescription()});for(let e=0,s=g.getPathCount();e<s;++e){const s=new i.i({vd:g.getDescription()});s.addPath(g,e,!0);const n=as(s,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);t.add(n,!1)}return t})(),l=!1)}else{const t=as(_,this.m_pannableSR,this.m_centralLongitude,!0,0,this.m_progressTracker);g.add(t,!1)}}if(l)return g;const _=this.m_pannableSR.getTolerance(0),d=this.m_pannableExtent.width()/180;return xs(g,this.m_pannableExtent,.1*_,!1),(0,a.c)(g,this.m_pannableExtent,_,d,this.m_progressTracker)}finalizeGeoNormalizeOpenedRing(t,e){const s=e.getPointCount(),o=e.getXY(0),a=e.getXY(s-1);{const t=Math.abs(a.x-o.x),e=Math.round(t/this.m_width360)*this.m_width360;(0,n.g)(Math.abs(t-e)<this.m_pannableSR.getTolerance(0))}const h=(0,r.s)(a.x-o.x),m=i.a.constructEmpty();e.queryLooseEnvelope(m);const l=this.m_pannableExtent.getCenterX();let u=0,c=l-this.m_width360,g=l+this.m_width360;if(h>=0){let t=Math.ceil((c-m.xmin)/this.m_width360);for(t*=this.m_width360;c>m.xmin+t;)t+=this.m_width360;for(;c<m.xmax+t;)t-=this.m_width360;for(u=t,m.width()>720&&(g=c+360*Math.ceil(m.width()/360));g<m.xmax;)g+=this.m_width360}else{let t=Math.ceil((g-m.xmax)/this.m_width360);for(t*=this.m_width360;g<m.xmax+t;)t-=this.m_width360;for(;g>m.xmin+t;)t+=this.m_width360;for(u=t,m.width()>720&&(c=g-360*Math.ceil(m.width()/360));c>m.xmin;)c-=this.m_width360}const _=Math.round(Math.abs(a.x-o.x)/this.m_width360)*this.m_width360,d=h*_,p=m.clone();p.move(u,0);const f=new r.P(0,0),x=new r.T;x.setShiftCoords(u,0),e.applyTransformation(x);const y=new i.i({vd:e.getDescription()});y.add(e,!1),f.assign(e.getXY(s-1));let P=0,E=y.getXY(0).x;for(;h>0?p.xmax<g:p.xmin>c;)p.move(d,0),x.xd=d,e.applyTransformation(x),E+=d,this.m_pannableExtent.xmin<=E&&this.m_pannableExtent.xmax>=E&&(P=y.getPointCount()-1),e.setXY(0,f),f.assign(e.getXY(s-1)),y.addSegmentsFromPath(e,0,0,s-1,!1);const C=new i.h({vd:y.getDescription()});C.add(y,!1);const v=y.getXY(0),b=y.getXY(y.getPointCount()-1),S=h<0?t:!t,I=C.getPointCount()-1;if(S){const t=new r.P(b.x,this.m_pannableExtent.ymax);C.lineTo(t);const e=new r.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymax);C.lineTo(e);const s=new r.P(v.x,this.m_pannableExtent.ymax);C.lineTo(s)}else{const t=new r.P(b.x,this.m_pannableExtent.ymin);C.lineTo(t);const e=new r.P(this.m_pannableExtent.getCenterX(),this.m_pannableExtent.ymin);C.lineTo(e);const s=new r.P(v.x,this.m_pannableExtent.ymin);C.lineTo(s)}if(C.interpolateAttributesPath(0,I,0),C.getImpl().changeRingStartPoint(P),_>this.m_width360){const t=new i.h({copy:C});x.setShiftCoords(this.m_width360,0),t.applyTransformation(x),C.add(t,!1)}return C}finalizeGeoNormalizeClosedRing(t,e,s){const o=new i.h({vd:t.getDescription()});if(o.add(t,!1),o.hasNonLinearSegments()&&(()=>{const t=o.getPointCount()-2;return o.getSegmentType(t)!==n.G.enumLine})()){const t=new i.S,e=o.getPointCount()-2;o.getSegmentBuffer(e,t,!1),o.removePointFromPath(0,e+1),o.closeLastPathWithSegment(t.get())}else o.removePointFromPath(0,o.getPointCount()-1);const a=i.a.constructEmpty();o.queryLooseEnvelope(a);let h=Math.ceil((this.m_pannableExtent.xmin-a.xmin)/this.m_width360);for(h*=this.m_width360;this.m_pannableExtent.xmin>a.xmin+h;)h+=this.m_width360;for(;this.m_pannableExtent.xmin<a.xmax+h;)h-=this.m_width360;if(h+=this.m_width360,0!==h){a.move(h,0);const t=new r.T;t.setShiftCoords(h,0),o.applyTransformation(t)}if(this.m_pannableExtent.xmin<=a.xmin&&this.m_pannableExtent.xmax>=a.xmax){if(e){const t=o.calculateArea2D(),e=(new m.O).execute(o,this.m_pannableSR,!0,this.m_progressTracker);if(e!==o){const s=e.calculateArea2D();(0,r.s)(t)!==(0,r.s)(s)&&e.reverseAllPaths(),o.assignMove(e)}}let t;if(t=new i.h(s?{copy:o}:{move:o}),s)for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const e=new r.T;e.setShiftCoords(this.m_width360,0),o.applyTransformation(e),t.add(o,!1)}return t}let l=new i.h({vd:t.getDescription()});l.add(o,!1);const u=e||a.width()>this.m_width360-10*this.m_pannableSR.getTolerance(0);for(;a.xmin<this.m_pannableExtent.xmax;){a.move(this.m_width360,0);const t=new r.T;t.setShiftCoords(this.m_width360,0),o.applyTransformation(t),l.add(o,!1)}if(u){const t=l.calculateArea2D();l.setFillRule(1),l=(new m.O).execute(l,this.m_pannableSR,!0,this.m_progressTracker);const e=l.calculateArea2D();(0,r.s)(t)!==(0,r.s)(e)&&l.reverseAllPaths()}return l}geonormalize_ring_(t,e,s,i,r,o,a){(0,n.g)(0)}}function We(t){return!1}function je(){return{m_heightMetersPerUnit:0,m_heightSign:0,m_heightZ0:0,m_XYToRadians:0,m_PrimeMeridianDegrees:0,assign(t){this.m_heightMetersPerUnit=t.m_heightMetersPerUnit,this.m_heightSign=t.m_heightSign,this.m_heightZ0=t.m_heightZ0,this.m_XYToRadians=t.m_XYToRadians,this.m_PrimeMeridianDegrees=t.m_PrimeMeridianDegrees},equals(t){return(0,r.Q)(this.m_heightSign,t.m_heightSign)&&(0,r.Q)(this.m_heightMetersPerUnit,t.m_heightMetersPerUnit)&&(0,r.Q)(this.m_heightZ0,t.m_heightZ0)&&(0,r.Q)(this.m_XYToRadians,t.m_XYToRadians)&&(0,r.Q)(this.m_PrimeMeridianDegrees,t.m_PrimeMeridianDegrees)},initFromGcsAndVcsPe(t,e){this.m_heightSign=1,this.m_heightMetersPerUnit=Number.NaN,this.m_heightZ0=0,this.m_XYToRadians=Number.NaN,this.m_PrimeMeridianDegrees=Number.NaN,e&&(0,n.g)(0),t&&(this.m_XYToRadians=t.getUnit().getUnitFactor(),this.m_PrimeMeridianDegrees=t.getPrimem().getLongitude())},initFromGcsAndVcs(t,e){const s=t?t.getPECoordSys():null,i=e?e.getPEVerticalCoordSys():null;this.initFromGcsAndVcsPe(s,i)},processUnitParams(t){Number.isNaN(this.m_heightMetersPerUnit)&&(this.m_heightMetersPerUnit=t.m_heightMetersPerUnit,this.m_heightSign=t.m_heightSign,this.m_heightZ0=t.m_heightZ0),Number.isNaN(this.m_XYToRadians)&&(this.m_XYToRadians=t.m_XYToRadians,this.m_PrimeMeridianDegrees=t.m_PrimeMeridianDegrees)}}}class Ze{supportsCurves(){return!0}accelerateGeometry(t,e,s){return Qe(t,e,s)}canAccelerateGeometry(t){return Ke(t)}}function Qe(t,e,s){if(!Ke(t))return!1;(0,i.aL)(e,t,!1);let r=0;const o=t.getGeometryType();return(0,n.f)(o)&&(0,i.G)(t)&&0!==s&&(r|=t.getImpl().buildQuadTreeAccelerator(s)?1:0),(0,n.f)(o)&&(0,i.aM)(t)&&0!==s&&(r|=t.getImpl().buildQuadTreeForPathsAccelerator(s)?1:0),r>0}function Ke(t){return(0,i.G)(t)||(0,i.aM)(t)}class Je extends Ze{getOperatorType(){return 8}execute(t,e,s,i){return ot(t,e,s,1,i)}}class $e extends Ze{getOperatorType(){return 3}execute(t,e,s,i=null){return ot(t,e,s,4,i)}}function ts(t,e,s){const n=e.getGCSSplitLines();if(null===n)return t;const o=e.getGCS(),a=o.getPannableExtent().width(),h=i.a.constructEmpty();t.queryLooseEnvelope(h);const m=r.E.constructEmpty();h.queryIntervalX(m);const l=n.querySegmentIterator();let u=null;const c=new r.T;for(;l.nextPath();)for(;l.hasNextSegment();){const t=l.nextSegment(),e=t.queryInterval(0,0),s=r.E.constructEmpty();s.setCoordsFromEnvelope(e);let n=0;for(;s.vmax>m.vmin;)s.move(-a),n--;for(;s.vmin<=m.vmax;){if(s.isIntersecting(m)){null===u&&(u=new i.i);const e=new i.L({start:t.getStartXY(),end:t.getEndXY()});0!==n&&(c.setShiftCoords(n*a,0),e.applyTransformation(c)),u.addSegment(e,!0)}s.move(a),++n}}if(null!==u){const e=(0,i.u)(o,u,!0),n=(0,i.l)(e);return(0,g.v)(t,u,n,s)}return t}function es(t,e,s){let i=t.getName();return Mi(i)||(s||e>0?(i=t.toString(Ji.PE_STR_NAME_CANON|Ji.PE_STR_AUTH_NONE),i=function(t){return t.toLocaleUpperCase("en-US")}(i)):i=t.toString(Ji.PE_STR_AUTH_TOP)),i}function ss(t,e=-1){if((e>1||e<-1)&&(0,n.t)("verbosity"),-1===e)return t.toString();{const s=0===e?Ji.PE_STR_AUTH_TOP:Ji.PE_STR_AUTH_ALL;return t.toString(s)}}function is(t,e,s,o){if(t.isEmpty()||1===s)return t;const h=t.getGeometryType();if(h===n.G.enumPoint){const i=t,n=i.getXY();return 0===os([n],1,e,s)||n.isNAN()?i.setEmpty():i.setXY(n),t}if(h===n.G.enumMultiPoint){const n=t,r=t.createInstance(),o=n.getPointCount();r.reserve(o);const a=n.getAttributeStreamRef(0),h=n.getDescription().getAttributeCount()>1,m=new i.P,l=Float64Array.from(a.getArray());if(os(l,o,e,s)>0)for(let t=0,e=2*o;t<e;t+=2)Number.isNaN(l[t])||(h?(n.getPointByVal(t>>1,m),m.setXYCoords(l[t],l[t+1]),r.add(m)):r.addXY(l[t],l[t+1]));return r}let m=t;const c=e.getOneDegreeGCSUnit(),g=90*c,_=180*c,p=360*c,f=e.getCentralMeridian(),x=.5*c,y=i.a.constructEmpty();m.queryEnvelope(y);const P=e.getGCSHorizon(),E=e.getGCSHorisonIsInclusive(),C=P.getGeometryType()===n.G.enumEnvelope,v=i.a.constructEmpty();P.queryEnvelope(v);const b=e.getGCS();if(2!==s&&4!==s||(v.xmin=f-_,v.xmax=v.xmin+p),4===s){if(!(y.width()>p-c)){const t=i.a.constructEmpty();t.setCoords({xmin:y.xmin-c,ymin:v.ymin,xmax:y.xmax+c,ymax:v.ymax}),m=(new l.O).execute(m,t,b,o);let e=Math.floor((f-y.getCenterX())/p);for(y.move(e*p,0);y.xmin>v.xmax;)e-=1,y.move(-p,0);for(;y.xmin<v.xmin;)e+=1,y.move(p,0);if(0!==e){const t=new r.T;t.setShiftCoords(e*p,0),m.applyTransformation(t)}return m}s=2}if(2===s&&(v.xmin=f-_,v.xmax=v.xmin+p),y.ymin<-g||y.ymax>g){const t=i.a.constructEmpty();if(t.setCoords({xmin:y.xmin-c,ymin:-g,xmax:y.xmax+c,ymax:g}),m=(new l.O).execute(m,t,b,o),m.isEmpty())return m;m.queryEnvelope(y)}if(E&&(v.ymax<y.ymin||v.ymin>y.ymax))return m.createInstance();y.width()>p&&(m=ps(m,f-_,p,b,!0,0,!0,o),m.queryEnvelope(y));let S=function(t,e,s,i,n){return t>=s&&e<=i?0:ds(.5*(e+t),s,i,n)}(y.xmin,y.xmax,v.xmin,v.xmax,p);if(0!==S&&y.move(S,0),y.xmax>v.xmax||y.xmin<v.xmin){if(y.xmax>v.xmax)for(;y.xmin>=v.xmax;)y.move(-p,0),S-=p;for(;y.xmin<v.xmax-p;)y.move(p,0),S+=p}const I=(0,i.aL)(b,P,!1);if(0!==S){const t=new r.T;t.setShiftCoords(S,0),m.applyTransformation(t),S=0}if(E){if(C&&v.containsEnvelope(y))return m;const t=new Array(2);for(let e=0;e<2;e++){let s;if(C?s=(0,n.f)(h)?(0,a.c)(m,v,I,x,o):(0,a.c)(m,v,I,0,o):(s=(new u.O).execute(m,P,b,o),s===P&&(s=s.clone())),v.xmin<=y.xmin&&v.xmax>=y.xmax)return s;if(v.xmin>=y.xmin&&v.xmax<=y.xmax)return s;if(t[e]=s,0===e){y.move(-p,0);const t=new r.T;t.setShiftCoords(-p,0),m.applyTransformation(t)}}return(0,n.f)(h)?t[0].add(t[1],!1):(0,n.b)("intersect_with_GCS_horizon: unexpected geometry type"),t[0]}{if(v.ymax<y.ymin||v.ymin>y.ymax)return m;let t=0;for(;!m.isEmpty()&&y.xmax>v.xmin;){if(0!==t){const e=new r.T;e.setShiftCoords(t,0),m.applyTransformation(e)}if((new $e).execute(m,P,b,o)||(m=(new d.O).execute(m,P,b,o),P===m&&(m=m.clone())),0!==t){const e=new r.T;e.setShiftCoords(-t,0),m.applyTransformation(e)}t-=p,y.move(-p,0)}return m}}function ns(t,e,s,n,a,h){const m={stack:[],error:void 0,hasError:!1};try{if(2===h)return function(t,e,s,n,o){if(Math.abs(s.x-n.x)>Math.PI)return Number.NaN;if(Math.abs(s.y)>r.q||Math.abs(n.y)>r.q)return Number.NaN;if((Math.abs(s.y)===r.q||Math.abs(n.y)===r.q)&&s.x!==n.x)return Number.NaN;const{first:a,second:h}=(0,r.aC)(s.x,n.x);let m=o;if(m=S(m,a,h),!r.E.construct(s.x,n.x).containsCoordinate(m))return Number.NaN;const l=i.ap.constructPoint2D(s),u=i.ap.constructPoint2D(n),c=D(1,e,l),g=D(1,e,u),_=c.crossProductVector(g);if(_.z.isZero())return s.y;const d=_.x.divE(_.z.negate()),p=_.y.divE(_.z.negate()),f=d.mulE(d).addE(p.mulE(p)).sqrt();if(f.isZero()||d.isZero()&&p.isZero())return s.y;const x=Math.atan2(p.value(),d.value());let y=Math.atan2(f.value()*Math.cos(x-m),1-e);const P=I(1,e,r.P.construct(m,y)),E=i.O.construct(P.x,P.y,-P.z),C=_.value().dotProduct(P),v=_.value().dotProduct(E);return Math.abs(v)<Math.abs(C)&&(y=-y),y}(0,e,s,n,a);if(Math.abs(s.x-n.x)>=Math.PI||!Bs(s.x,n.x,a))return Number.NaN;s.x>n.x&&(n=(0,r.b)(s,s=n));const l=(0,o.b)(m,new Qi,!1),u=(0,o.b)(m,new Qi,!1),c=(0,o.b)(m,new Qi,!1),g=s.clone();rn.geodeticDistance(t,e,s.x,s.y,n.x,n.y,u,l,null,h);const _=u.val;let d=0,p=1;for(;_*(p-d)>1e-12*t;){const i=.5*(d+p);if(rn.geodeticCoordinate(t,e,s.x,s.y,_*i,l.val,u,c,h),g.x=u.val,g.y=c.val,g.x===a)return g.y;if(Bs(s.x,g.x,a))p=i;else{if(!Bs(n.x,g.x,a))return Number.NaN;d=i}}return g.y}catch(t){m.error=t,m.hasError=!0}finally{(0,o.c)(m)}}function rs(t,e,s,i){for(let n=0,r=0;n<i;n++,r+=2)e[s+n].x=t[r],e[s+n].y=t[r+1]}function os(t,e,s,o){if(0===e||1===o)return e;const a=function(t,e){let s;if(Array.isArray(t)){const i=t;s=new Float64Array(2*e);for(let t=0,n=0;t<e;t++,n+=2)s[n]=i[t].x,s[n+1]=i[t].y}else s=t;return s}(t,e);if(2===o){const i=s.getPannableExtentInGCS();let n=e;for(let t=0,s=2*e;t<s;t+=2)(a[t+1]>i.ymax||a[t+1]<i.ymin)&&(a[t]=Number.NaN,n--);return n?(fs(a,e,i.xmin,i.width(),!0),t!==a&&rs(a,t,0,e),n):0}const h=s.getOneDegreeGCSUnit(),m=90*h,l=180*h,u=360*h;let c=e;for(let t=0,s=2*e;t<s;t+=2)(a[t+1]>m||a[t+1]<-m)&&(a[t]=Number.NaN,c--);if(!c)return 0;const _=i.a.constructEmpty();_.setFromPoints(a,e);const d=s.getGCSHorizon(),p=s.getGCSHorisonIsInclusive(),f=d.getGeometryType()===n.G.enumEnvelope,x=i.a.constructEmpty();if(d.queryEnvelope(x),p&&(x.ymax<_.ymin||x.ymin>_.ymax))return 0;if(p)if(fs(a,e,x.getCenterX()-l,u,!0),c=e,f)for(let t=0,s=2*e;t<s;t+=2)x.containsCoords(a[t],a[t+1])||(a[t]=Number.NaN,c--);else{const t=(0,i.aL)(s.getGCS(),d,!1),n=new r.P;for(let s=0,i=2*e;s<i;s+=2)n.setCoords(a[s],a[s+1]),0!==(0,g.i)(d,n,t)||(a[s]=Number.NaN,c--)}else{fs(a,e,-l,u,!0),c=e;const t=(0,i.aL)(s.getGCS(),d,!1),n=new r.P;for(let s=0,i=2*e;s<i;s+=2){n.setCoords(a[s],a[s+1]),n.isNAN()&&c--;const e=ds(n.x,x.xmin,x.xmax,u);n.x+=e,0!==(0,g.i)(d,n,t)&&(a[s]=Number.NaN,c--)}}return c>0&&Array.isArray(t)&&rs(a,t,0,e),c}function as(t,e,s,i,r,o){if(e.isPannable()||(0,n.t)("fold_into_360_degree_range"),t.isEmpty())return t;let a,h;if(2===e.getCoordinateSystemType()){const t=e.getPannableExtent();h=t.xmin,a=t.width()}else{const t=e.getOneDegreeGCSUnit();a=360*t,h=s-180*t}return ps(t,h,a,e,i,r,!0,o)}function hs(t,e,s,i){let n,r;if(2===s.getCoordinateSystemType()){const t=s.getPannableExtent();n=t.xmin,r=t.width()}else{const t=s.getOneDegreeGCSUnit();r=360*t,n=i-180*t}fs(t,e,n,r)}function ms(t,e){const s=e.width();let i=(0,r.r)(t-e.vmin,s);return i<0&&(i+=s),e.snapClip(i+e.vmin)}function ls(t,e,s){return t>e.xmax&&t-e.xmax<s?e.xmax:t<e.xmin&&e.xmin-t<s?e.xmin:t}function us(t,e,s){if(t[0]<e.vmin||t[0]>e.vmax||s&&t[0]===e.vmax){const s=e.width();return t[0]+=Math.ceil((e.vmin-t[0])/s)*s,t[0]=e.snapClip(t[0]),!0}return!1}function cs(t,e,s,n,r){const o=new i.d,a=o.addGeometry(t);return gs(o,a,e,(0,i.aL)(e,t,!1),s,n,r),o.getGeometry(a)}function gs(t,e,s,a,h,m,l){const u={stack:[],error:void 0,hasError:!1};try{(0,n.g)(di()),s.isPannable()||(0,n.u)("insert_geodetic_points");const c=s.getPannableExtent(),g=s.getGCS(),_=gi();g.querySpheroidData(_);const d=g.getUnit().getUnitToBaseFactor(),p=_.majorSemiAxis,f=_.e2;let x=0;const y=new r.E;c.queryIntervalX(y);let P=null;const E=new Array(4);2===s.getCoordinateSystemType()?(P=s.getPECoordSys(),m?(E[0]=ms(l,y),E[1]=c.getCenterY(),$i.projToGeog(P,1,E),x=E[0]*d):(E[0]=c.getCenterX(),E[1]=l,$i.projToGeog(P,1,E),x=E[1]*d)):x=l*d,m||0===x||2===h||(0,n.u)("insert_geodetic_points: 1");const C=(0,o.b)(u,new Qi,!1),v=new r.P,b=new r.P,S=new r.P,I=new r.P,w=new r.P,D=new r.P;for(let n=t.getFirstPath(e);n!==i.n;n=t.getNextPath(n)){const e=t.getFirstVertex(n);t.queryXY(e,S);let o=!1;const u=t.getNextVertex(e);for(let e=u;e!==i.n;e=t.getNextVertex(e)){if(e===u){if(o)break;o=!0}if(t.queryXY(e,I),m&&(a<l-S.x&&I.x-l>a||a<l-I.x&&S.x-l>a)||!m&&(0!==l||a<-S.y&&I.y>a||a<-I.y&&S.y>a))do{if(Math.abs(S.x-I.x)>=.5*y.width())break;2===s.getCoordinateSystemType()?(E[0]=ms(S.x,y),E[1]=S.y,E[2]=ms(I.x,y),E[3]=I.y,Ns(P,2,E,0),w.x=E[0]*d,w.y=E[1]*d,D.y=E[3]*d):(w.x=S.x*d,w.y=S.y*d,D.y=I.y*d),D.x=(I.x-S.x)*Math.PI*2/y.width()+w.x;let i=0;const n=(0,r.m)(r.P,2);if(m){if(b.x=x,b.y=ns(p,f,w,D,x,h),Number.isNaN(b.y))break;n[0]=b,i=1}else if(2===h){const t=[0,0];if(i=F(0,f,w,D,x,t),!i)break;n[0].x=t[0],n[0].y=x,2===i&&(n[1].x=t[1],n[1].y=x)}else{if(b.x=Ls(p,f,w,D,h),Number.isNaN(b.x))break;b.y=0,n[0]=b,i=1}let o=-1;for(let a=0;a<i;a++){rn.geodeticDistance(p,f,w.x,w.y,D.x,D.y,C,null,null,h);const i=C.val;rn.geodeticDistance(p,f,w.x,w.y,n[a].x,n[a].y,C,null,null,h);const u=C.val;2===s.getCoordinateSystemType()?(E[0]=n[a].x/d,E[1]=n[a].y/d,$i.geogToProj(P,1,E),m?(v.y=E[1],v.x=l):(v.x=zs(E[0],S.x,I.x,y),v.y=l)):m?(v.x=l,v.y=n[a].y/d):(v.x=zs(n[a].x/d,S.x,I.x,y),v.y=l);const c=i>0?(0,r.l)(u/i,0,1):.5;if(0===c||1===c)continue;if(o>c)continue;const g=t.getPrevVertex(e);t.splitSegment(g,[c],1);const _=t.getNextVertex(g);t.setXYCoords(_,v.x,v.y),o=c}}while(0);S.setCoordsPoint2D(I)}}}catch(t){u.error=t,u.hasError=!0}finally{(0,o.c)(u)}}function _s(t,e){(0,n.g)(e.isPannable());const s=e.getPannableExtent();if(t.getGeometryType()===n.G.enumPoint){const e=t.getY();return s.ymin<=e&&e<=s.ymax?t:t.createInstance()}const r=i.a.constructEmpty();t.queryEnvelope(r);const o=i.a.constructEmpty();o.setCoords({env2D:s}),o.xmin=r.xmin,o.xmax=r.xmax,o.inflateCoords(.01*o.height(),0);const h=(0,i.c)(e,r,!1);let m;return m=o.containsEnvelope(r)?t:(0,a.c)(t,o,h,0,null),m}function ds(t,e,s,i){return(0,r.ay)((.5*(s+e)-t)/i)*i}function ps(t,e,s,o,h,m,l,u){const c=t.getGeometryType(),g=r.E.constructEmpty();g.setCoords(e,e+s);const d=[0];if(c===n.G.enumPoint){const e=t;if(d[0]=e.getX(),us(d,g,l)){const e=h?t:t.clone();return e.setX(d[0]),e}return t}const p=i.a.constructEmpty();if(t.queryEnvelope(p),p.isEmpty())return t;if(c===n.G.enumMultiPoint){const e=h?t:t.clone(),s=e.getImpl(),i=s.getAttributeStreamRef(0),n=2*s.getPointCount();let r=!1;for(let t=0;t<n;t+=2)d[0]=i.read(t),us(d,g,l)&&(i.write(t,d[0]),r=!0);return r&&s.notifyModifiedFlags(2001),e}const f=r.E.constructEmpty();if(p.queryIntervalX(f),g.contains(f))return g.vmax,f.vmax,t;const x=i.a.constructEmpty();if(x.setCoords({env2D:p}),0===f.width()){let e=f.vmin;e+=Math.ceil((g.vmin-e)/s)*s,e=g.snapClip(e);const i=h?t:t.clone();return i.setAttributeBasic(0,0,e),i}if(c===n.G.enumEnvelope){const e=h?t:t.clone();return p.intersect(x),e.setEnvelope(p),e}const y=.1*Math.max(p.height(),p.width())*1;x.inflateCoords(0,y);let P=t;const E=o.getTolerance(0),C=new r.T;for(;;){const t=Math.floor((f.vmin-e)/s),i=Math.ceil((f.vmax-e)/s);if(!(i-t>3))break;{const r=Math.floor(.5*(i+t));x.xmin=p.xmin-y,x.xmax=e+s*r;const h=(0,a.c)(P,x,E,m,u);x.xmin=x.xmax,x.xmax=p.xmax+y;const l=(0,a.c)(P,x,E,m,u);C.setShiftCoords((r-i)*s,0),l.applyTransformation(C),c===n.G.enumPolygon?P=(new _.O).execute(h,l,o,u):(P=h,P.add(l,!1)),P.queryEnvelope(p),p.queryIntervalX(f)}}x.xmin=e,x.xmax=e+s;const v=i.a.constructEmpty();v.setCoords({env2D:x}),v.inflateCoords(E,0);const b=Math.floor((p.xmin-x.xmin)/s)*s;let S;b?(x.move(b,0),C.setShiftCoords(-b,0)):C.setIdentity(),S=c===n.G.enumPolyline?new i.i({vd:P.getDescription()}):new i.h({vd:P.getDescription()});const I=i.a.constructEmpty(),w=i.a.constructEmpty();for(;p.xmax>x.xmin;){const t=(0,a.c)(P,x,E,0,u);t.queryEnvelope(w);let e=!1;e=c===n.G.enumPolyline?!t.isEmpty()&&(w.width()>E||w.height()>E):!t.isEmpty()&&(c!==n.G.enumPolygon||w.width()>E),e&&(t.applyTransformation(C),t.queryEnvelope(w),S.queryEnvelope(I),I.inflateCoords(E,E),I.isIntersecting(w)&&c===n.G.enumPolygon?S=(new _.O).execute(S,t,o,u):S.add(t,!1)),x.move(s,0),C.shiftCoords(-s,0)}return S}function fs(t,e,s,i,n=!0){const o=new r.E;o.setCoords(s,s+i);const a=[0];if(Array.isArray(t)){const s=t;for(let t=0;t<e;t++)o.containsRightExclusive(s[t].x)||(a[0]=s[t].x,us(a,o,n),s[t].x=a[0])}else{const s=t;for(let t=0;t<e;t++){const e=t<<1;o.containsRightExclusive(s[e])||(a[0]=s[e],us(a,o,n),s[e]=a[0])}}}function xs(t,e,s,r=!0){if(t.isEmpty())return;const o=t.getGeometryType();if(!r||o!==n.G.enumPolygon)if((0,n.i)(o)){let i=!1;if((0,n.f)(o)&&t.hasNonLinearSegments()){const r=t.getImpl(),o=r.getAttributeStreamRef(0),a=r.getSegmentFlagsStreamRef();(0,n.g)(null!==a);for(let t=0,n=r.getPathCount();t<n;t++){let n=!0;const h=r.isClosedPath(t),m=r.getPathEnd(t);h&&r.getPathSize(t)>0&&(n=1==(31&a.read(m-1)));for(let h=r.getPathStart(t);h<m;h++)if(1==(31&a.read(h))){if(n){const t=o.read(2*h),n=ls(t,e,s);n!==t&&(i=!0,o.write(2*h,n))}n=!0}else n=!1}}else{const n=t.getImpl(),r=n.getAttributeStreamRef(0);for(let t=0,o=n.getPointCount();t<o;t++){const n=r.read(2*t),o=ls(n,e,s);o!==n&&(i=!0,r.write(2*t,o))}}i&&t.getImpl().notifyModifiedFlags(2001)}else if(o===n.G.enumEnvelope){const n=t,r=i.a.constructEmpty();n.queryEnvelope(r),r.xmin=ls(r.xmin,e,s),r.xmax=ls(r.xmax,e,s),n.setEnvelope(r)}else if(o===n.G.enumPoint){const i=t;i.setX(ls(i.getX(),e,s))}else(0,n.b)("")}function ys(t,e,s){const i=new r.P;return i.x=ls(t.x,e,s),i.y=t.y,i}function Ps(t,e,s,o){const h=t.getGeometryType();(0,n.g)(h===n.G.enumPolygon||h===n.G.enumPolyline||h===n.G.enumMultiPoint);const m=e.getCoordinateSystemType();if(2===m){let m=t;if(0===s){const s=function(t,e){if(e.isEmpty())return 0;const s=t.getPECoordSys();if(s.getProjection().getCode()===Ji.PE_PRJ_AZIMUTHAL_EQUIDISTANT){const n=gi();t.querySpheroidData(n);const o=s.getParameters();if(null===o[Ji.PE_PARM_LAM0])return 0;if(null===o[Ji.PE_PARM_PHI0])return 0;const a=[o[Ji.PE_PARM_LAM0].getValue(),o[Ji.PE_PARM_PHI0].getValue()];$i.geogToProj(s,1,a);const h=new r.P(a[0],a[1]),m=i.a.constructEmpty();e.queryEnvelope(m);const l=(0,r.m)(r.P,4);m.queryCorners(l);let u=0;const c=t.getOneMeter();let g=Math.max(n.majorSemiAxis,n.minorSemiAxis)*Math.PI,_=Math.min(n.majorSemiAxis,n.minorSemiAxis)*Math.PI;_-=g/180,g*=c,_*=c;for(let t=0;t<4;t++){const e=r.P.distance(l[t],h);if(e>g)u++;else if(e>_)return-1}if(0===u)return 1;if(4===u){const t=i.a.constructEmpty();return t.setCoords({center:h,width:g,height:g}),m.isIntersectingNe(t)?-1:0}return-1}return-1}(e,t);if(0===s)return t.createInstance();if(1===s)return t;const h=e.getPCSHorizon(),l=h.getGeometryType(),c=e.getDefaultPrecisionSR();if(l===n.G.enumEnvelope){const s=i.a.constructEmpty();h.queryEnvelope(s);const n=(0,i.c)(c,s,!1);m=(0,a.c)(t,s,n,5e4*e.getOneMeterPCSUnit(),o)}else(new Je).execute(h,t,c,o)||(m=(new u.O).execute(m,h,c,o),m===h&&(m=m.clone()))}else if(e.isPannable()){const t=i.a.constructEmpty();m.queryEnvelope(t);const r=e.getPannableExtent();r.containsEnvelope(t)||(xs(m,r,e.getTolerance(0)),2!==s&&4!==s||(m=_s(m,e)),4!==s?m=as(m,e,0,!0,1e5*e.getOneMeterPCSUnit(),o):h===n.G.enumPolygon&&t.width()>2*r.width()&&(m=ps(m,-2*r.width(),2*r.width(),e,!0,0,!0,o)))}return m}if((0,n.g)(1===m),h===n.G.enumMultiPoint)return xs(t,e.getPannableExtent(),e.getTolerance(0)),t;{const s=i.a.constructEmpty();t.queryEnvelope(s);let r=t;const a=e.getPannableExtent();if(s.ymin<a.ymin||s.ymax>a.ymax){const t=Math.max(1,s.calculateToleranceFromEnvelope()),n=new i.a(s.xmin-t,a.ymin,s.xmax+t,a.ymax);if(r=(new l.O).execute(r,n,e,o),r.isEmpty())return r}return h===n.G.enumPolygon&&s.width()>2*a.width()&&(r=ps(r,-2*a.width(),2*a.width(),e,!0,0,!0,o)),r}}function Es(t,e){const s=e.getPointCount();if(!s)return;const i=e.getImpl(),n=i.getAttributeStreamRef(0),r=t;$i.geogToProj(r,s,n.getArray()),i.notifyModifiedFlags(2001)}function Cs(t,e,s,i){if(!s)return;const n=t.getPECoordSys();if(1===s){const s=[e[0].x,e[0].y];if($i.geogToProj(n,1,s),i){const{first:i,second:n}=t.m_peCoordSysVal.getGeogToProjFactors();s[0]=i*(e[0].x-t.getCentralMeridian())+n}return void e[0].setCoords(s[0],s[1])}const o=t.isPannable(),a=o?t.getPannableExtent().width():0,h=179*a/360;let m=0;o&&(m=t.getCentralMeridian());const l=new Float64Array(512);for(let u=0;u<s;){for(let t=u;t<s&&e[t].isNAN();++t)u++;let c=Math.min(256,s-u);if(c>0){for(let t=1,s=u+1;t<c;++t,++s)if(e[s].isNAN()){c=t;break}for(let t=0;t<c;++t){const s=t<<1;l[s]=e[u+t].x,l[s+1]=e[u+t].y}if($i.geogToProj(n,c,l),i){const{first:s,second:i}=t.m_peCoordSysVal.getGeogToProjFactors();for(let t=0;t<c;++t)l[t<<1]=s*(e[u+t].x-m)+i}if(o)for(let t=0,s=u;t<c;t++,s++){const i=t<<1,n=l[i],o=(0,r.s)(n),u=e[s].x-m;o*(0,r.s)(u)<0&&Math.abs(n)>h&&(l[i]-=o*a)}rs(l,e,u,c),u+=c}}}function vs(t,e,s,i){const n=t.getSRToGCSTransform();return(new _e).transform(n,e,s,i,!1)}function bs(t,e,s,n){const r=new i.M({vd:e.getDescription()});let o;r.addPoints(e,0,-1),o=(new _e).execute(r,t,n);const a=e.getPointCount();if(s.setEmpty(),t.getInputSR().isPannable()){if(a!==o.getPointCount())return!1;const n=new i.a;e.queryEnvelope(n);const r=new i.a;o.queryEnvelope(r);const h=n.width(),m=r.width();if(0!==h&&0!==m){const e=m/h,s=t.getOutputSR().getPannableExtent().width()/t.getInputSR().getPannableExtent().width();if(Math.abs(e/s-1)>1e-10)return!1}else if(0!==h||0!==m)return!1;s.add(e,!1);for(let t=0;t<a;t++){const e=o.getXY(t);s.setXY(t,e)}return!0}return!1}function Ss(t,e,s){(0,n.g)(!s||t.isPannable());const i=e.getPointCount();if(!i)return;const o=e.getImpl(),a=o.getAttributeStreamRef(0),h=t.getPECoordSys();let m=0;const l=a.readRange(0,2*i);let u=()=>{$i.geogToProj(h,i,l)};const c=t.isPannable()&&!s,g=c?t.getPannableExtent().width():0,_=179*g/360;if(t.isPannable()&&(m=t.getCentralMeridian(),s)){const e=t.m_peCoordSysVal.getGeogToProjFactors(),s=e.first,n=e.second;u=()=>{$i.geogToProj(h,i,l);for(let t=0;t<i;t++){const e=t<<1,i=a.read(e),r=s*(i-m)+n;l[e]=r}}}if(u(),c)for(let t=0;t<i;t++){const e=t<<1,s=l[e],i=(0,r.s)(s),n=a.read(e)-m;i*(0,r.s)(n)<0&&Math.abs(s)>_&&(l[e]+=-i*g)}a.writeRangeFromArray(0,2*i,l,!0,1),o.notifyModifiedFlags(2001)}function Is(t,e,s){switch(e.getGeometryType()){case n.G.enumLine:return void function(t,e,s){const i=[e.getStartXY(),e.getEndXY()];Cs(t,i,2,s),e.setStartXY(i[0]),e.setEndXY(i[1]),e.normalizeAfterEndpointChange()}(t,e,s);case n.G.enumBezier:return void function(t,e,s){const i=(0,r.m)(r.P,4);e.queryControlPoints(i),Xs(t,i,4,s),e.setControlPoints(i)}(t,e,s);case n.G.enumEllipticArc:return void function(t,e,s){if(0===e.projectionBehavior())!function(t,e,s){Hs(!0,t,0,e,s)}(t,e,s);else{const i=e.isClosed()&&e.isMajor(),n=[e.getStartXY(),i?e.getCenter():e.getEndXY()],o=[n[0].clone(),n[1].clone()];Xs(t,o,2,s);const a=new r.T;a.initializeFromTwoPointsArray(n,o),e.applyTransformation(a);const h=i?0:1;e.setCoordsForIntersector(o[0],o[h],!1)}}(t,e,s);case n.G.enumBezier2:case n.G.enumRationalBezier2:return void(0,n.g)(0);default:(0,n.b)("")}}function ws(t,e,s){if(!e.hasNonLinearSegments())return void Ss(t,e,s);if((0,n.g)(!s||t.isPannable()),e.isEmpty())return;const o=t.getPECoordSys(),a=t.isPannable(),h=a?t.getPannableExtent().width():0,m=179*h/360;let l=0;a&&(l=t.getCentralMeridian());const u=e.createInstance();u.reserveParts(e.getPointCount(),e.getPathCount());const c=e.getImpl(),g=new i.S;for(let n=0,_=e.getPathCount();n<_;++n)if(c.hasNonLinearSegmentsPath(n)){let e=!0,o=-1;const a=c.getPathStart(n),h=a+c.getSegmentCountPath(n);c.isClosedPath(n)&&(o=h-1);const m=new r.P;for(let n=a;n<h;++n){if(c.getSegmentBuffer(n,g,!1),Is(t,g.get(),s),e||g.get().getStartXY().equals(m)||g.get().moveTo(m),n!==o)u.addSegment(g.get(),e);else{if(e){const t=new i.P;g.get().queryStart(t),u.startPathPoint(t)}u.closeLastPathWithSegment(g.get())}m.assign(g.get().getEndXY()),e=!1}}else{const t=1024;let s,i=c.getPathSize(n),g=Math.min(i,t);u.insertPath(-1,e,n,!0);const _=c.getAttributeStreamRef(0),d=u.getAttributeStreamRef(0);for(let e=c.getPathStart(n),u=c.getPathEnd(n);e<u;){if(s=_.readRange(e,g),$i.geogToProj(o,g,s),a)for(let t=0;t<g;t++){const e=t<<1,i=s[e],n=(0,r.s)(i),o=_.read(2*(0+t))-l;n*(0,r.s)(o)<0&&Math.abs(i)>m&&(s[e]+=-n*h)}d.writeRangeFromArray(e,g,s,!0,1),e+=g,i-=g,g=Math.min(i,t)}}e.assignMove(u)}function Ds(t,e,s){let i=s.getPointCount();if(!i)return;const n=s.getImpl(),o=n.getAttributeStreamRef(0);let a=Math.min(i,1e3),h=0;const m=t.getPECoordSys();Number.isNaN(e)&&(e=0);const l=t.isPannable(),u=t.getOneDegreeGCSUnit(),c=360*u,g=179*u;let _;for(;i;){if(_=o.readRange(2*h,2*a),Ns(m,a,_,e),l)for(let t=0;t<a;t++){const s=t<<1,i=_[s]-e,n=(0,r.s)(i),a=o.read(2*(h+t));n*(0,r.s)(a)<0&&Math.abs(i)>g&&(_[s]+=-n*c)}o.writeRangeFromArray(2*h,2*a,_,!0,1),h+=a,i-=a,a=Math.min(i,1e3)}n.notifyModifiedFlags(2001)}function Ts(t,e,s){switch(s.getGeometryType()){case n.G.enumLine:return void function(t,e,s){const i=[s.getStartXY(),s.getEndXY()];Ms(t,e,i,2),s.setStartXY(i[0]),s.setEndXY(i[1]),s.normalizeAfterEndpointChange()}(t,e,s);case n.G.enumBezier:return void function(t,e,s){const i=(0,r.m)(r.P,4);s.queryControlPoints(i),ks(t,e,i,4),s.setControlPoints(i)}(t,e,s);case n.G.enumEllipticArc:return void function(t,e,s){if(0===s.projectionBehavior())!function(t,e,s){Hs(!1,t,e,s,!1)}(t,e,s);else{const i=s.isClosed()&&s.isMajor(),n=[s.getStartXY(),i?s.getCenter():s.getEndXY()],o=[n[0].clone(),n[1].clone()];ks(t,e,o,2);const a=new r.T;a.initializeFromTwoPointsArray(n,o),s.applyTransformation(a);const h=i?0:1;s.setCoordsForIntersector(o[0],o[h],!1)}}(t,e,s);case n.G.enumBezier2:case n.G.enumRationalBezier2:return void(0,n.g)(0);default:(0,n.b)("")}}function Ns(t,e,s,i){const r=$i.projToGeogCenter(t,e,s,i);for(let t=0;t<e;++t){const e=t<<1;(0,n.g)(Number.isFinite(s[e]+s[e+1]))}return r}function As(t,e,s){if(!s.hasNonLinearSegments())return void Ds(t,e,s);if(s.isEmpty())return;const n=t.getPECoordSys();Number.isNaN(e)&&(e=0);const o=t.isPannable(),a=t.getOneDegreeGCSUnit(),h=360*a,m=179*a,l=s.createInstance();l.reserveParts(s.getPointCount(),s.getPathCount());const u=s.getImpl(),c=new i.S;for(let a=0,g=s.getPathCount();a<g;++a)if(u.hasNonLinearSegmentsPath(a)){let s=!0,n=-1;const o=u.getPathStart(a),h=o+u.getSegmentCountPath(a);u.isClosedPath(a)&&(n=h-1);const m=new r.P;for(let r=o;r<h;++r){if(u.getSegmentBuffer(r,c,!1),Ts(t,e,c.get()),s||c.get().getStartXY().equals(m)||c.get().moveTo(m),r!==n)l.addSegment(c.get(),s);else{if(s){const t=new i.P;c.get().queryStart(t),l.startPathPoint(t)}l.closeLastPathWithSegment(c.get())}m.assign(c.get().getEndXY()),s=!1}}else{const t=1e3;let i,c=u.getPathSize(a),g=Math.min(c,t);l.insertPath(-1,s,a,!0);const _=u.getAttributeStreamRef(0),d=l.getAttributeStreamRef(0);for(let s=u.getPathStart(a),l=u.getPathEnd(a);s<l;){if(i=_.readRange(2*s,2*g),Ns(n,g,i,e),o)for(let t=0;t<g;t++){const n=t<<1,o=i[n]-e,a=(0,r.s)(o),l=_.read(2*s);a*(0,r.s)(l)<0&&Math.abs(o)>m&&(i[n]+=-a*h)}d.writeRangeFromArray(2*s,2*g,i,!0,1),s+=g,c-=g,g=Math.min(c,t)}}s.assignMove(l)}function Ms(t,e,s,i){const n=t.getPECoordSys();Number.isNaN(e)&&(e=0);const o=t.isPannable(),a=t.getOneDegreeGCSUnit(),h=360*a,m=179*a,l=new Float64Array(512);for(let t=0;t<i;){for(let e=t;e<i&&s[e].isNAN();++e)t++;let a=Math.min(256,i-t);if(a>0){for(let e=1,i=t+1;e<a;++e,++i)if(s[i].isNAN()){a=e;break}for(let e=0;e<a;e++){const i=e<<1;l[i]=s[t+e].x,l[i+1]=s[t+e].y}if(Ns(n,a,l,e),o)for(let i=0,n=t;i<a;++i,++n){const t=i<<1,o=s[n].x,a=l[t]-e,u=(0,r.s)(a);u*(0,r.s)(o)<0&&Math.abs(a)>m&&(l[t]-=u*h)}for(let e=0;e<a;e++){const i=e<<1;s[t+e].x=l[i],s[t+e].y=l[i+1]}t+=a}}}function Gs(t,e,s,i){(0,n.g)(0)}function qs(t,e,s){let i=e.getPointCount();if(!i)return!1;const n=e.getImpl(),o=n.getAttributeStreamRef(0);let a=null;const h=t.getInputSR(),m=t.getOutputSR();h.getVCS(),m.getVCS();const l=h.getOneDegreeGCSUnit(),u=m.getOneDegreeGCSUnit(),c=t.isVertical();c&&e.hasAttribute(1)&&(a=n.getAttributeStreamRef(1));const g=t.getDatumTransformation(),_=!!g&&1===g.getType();if(_||null===a||(Gs(a.getArray()),a=null),!g||0===g.count()){const t=h.getGcsUnitFactor()/m.getGcsUnitFactor(),e=(h.getPrimeMeridian()-m.getPrimeMeridian())*u,s=-90*l,a=90*l;let c=0;const g=o.getArray(),_=[0];for(let t=1,e=2*i;t<e;)_[0]=g[t],c|=(0,r.az)(_,s,a)?1:0,g[t]=_[0],t+=2;if(0!==e||1!==t){c=1;const s=o.getArray();for(let n=0,r=2*i;n<r;){let i=s[n];i*=t,i+=e,s[n]=i,s[n+1]*=t,n+=2}}return 0!==c&&n.notifyModifiedFlags(2001),!!c}let d=Math.min(i,1e3);const p=new Array(d),f=new Array(d);let x=null;null!==a&&(x=new Float64Array(d));let y=0,P=Number.NaN,E=Number.NaN;const C=360*u,v=u/l;s&&(E=90*u,P=89.9*l,f.fill(0));let b=!0,S=0;for(;i;){let t=!1;const e=o.readRange(2*y,2*d);for(let t=0;t<d;t++)p[t]=e[t<<1];if(s)for(let s=0;s<d;s++){const i=1+(s<<1),n=Math.abs(e[i])-P;if(n>0){const o=e[i];e[i]=(0,r.c)(P,o),f[s]=(0,r.c)(n,o),t=!0}}const n=e[0];if(_){const t=g;x&&a.queryRange(y,d,x,!0,1),t.transform(!1,e,x,d),x&&a.writeRangeFromArray(y,d,x,!0,1)}else g.transform(!1,e,d);b&&(S=e[0]-v*n,b=!1);for(let t=0;t<d;t++){const s=t<<1,i=e[s]-p[t]*v-S;Math.abs(i)>200&&(e[s]+=i>0?-C:C)}if(t){for(let t=0;t<d;t++)if(f[t]){const s=1+(t<<1);e[s]+=v*f[t],e[s]>E?e[s]=E:e[s]<-E&&(e[s]=-E)}f.fill(0)}o.writeRangeFromArray(2*y,2*d,e,!0,1),c&&a&&a.writeRangeFromArray(y,d,x,!0,1),y+=d,i-=d,d=Math.min(i,1e3)}return n.notifyModifiedFlags(2001),!0}function Fs(t,e,s){switch(e.getGeometryType()){case n.G.enumLine:return function(t,e,s){const i=[e.getStartXY(),e.getEndXY()];let n=null;e.hasAttribute(1)&&(n=[0,0],n[0]=e.getAttributeAsDbl(0,1,0),n[1]=e.getAttributeAsDbl(1,1,0));const r=Ys(t,i,n,2,s);return e.setStartXY(i[0]),e.setEndXY(i[1]),n&&(e.setStartAttribute(1,0,n[0]),e.setEndAttribute(1,0,n[1])),e.normalizeAfterEndpointChange(),r}(t,e,s);case n.G.enumBezier:return function(t,e,s){const i=(0,r.m)(r.P,4);e.queryControlPoints(i);let n=null;e.hasAttribute(1)&&(n=[0,0,0,0],n[0]=e.getAttributeAsDbl(0,1,0),n[3]=e.getAttributeAsDbl(1,1,0),n[1]=(0,r.w)(n[0],n[3],.5),n[2]=n[1]);const o=Ys(t,i,n||null,i.length,s);return e.setControlPoints(i),n&&(e.setStartAttribute(1,0,n[0]),e.setEndAttribute(1,0,n[3])),e.normalizeAfterEndpointChange(),o}(t,e,s);case n.G.enumEllipticArc:return function(t,e,s){if(0===e.projectionBehavior())return function(t,e,s){const i=[e.getStartXY(),e.getEndXY(),e.getInteriorPoint(),e.getCenter()];let n=4;e.isDegenerateToLine()&&(n=2);const o=[0,0,0,0];let a=null;if(e.hasAttribute(1)){a=o,a[0]=e.getAttributeAsDbl(0,1,0),a[1]=e.getAttributeAsDbl(1,1,0);const t=(0,r.w)(a[0],a[1],.5);a[2]=t,a[3]=t}const h=e.getStartXY().equals(e.getEndXY())&&!e.isDegenerateToLine(),m=Ys(t,i,a,n,s);return h?e.constructCircleCenterAndPoint(i[3],i[0],!e.isClockwise()):e.isDegenerateToLine()?e.constructLineCircularArc(i[0],i[1]):e.constructCircularArcThreePoint(i[0],i[1],i[2]),a&&(e.setStartAttribute(1,0,a[0]),e.setEndAttribute(1,0,a[1])),m}(t,e,s);const i=e.getStartXY().equals(e.getEndXY()),n=(0,r.m)(r.P,3),o=(0,r.m)(r.P,3);let a=null;n[0].assign(e.getStartXY()),n[1].assign(i?e.getCenter():e.getEndXY());let h=!1;e.hasAttribute(1)&&(a=[0,0,0],a[0]=e.getAttributeAsDbl(0,1,0),a[1]=e.getAttributeAsDbl(1,1,0),a[2]=(0,r.w)(a[0],a[1],.5),i&&(a[1]=a[2])),o[0].setCoordsPoint2D(n[0]),o[1].setCoordsPoint2D(n[1]);const m=new r.T;if(i||e.isDegenerateToLine())h=Ys(t,o,a,2,s),m.initializeFromTwoPoints(n[0],n[1],o[0],o[1]);else{const i=new r.P;e.queryCoord2D(.5,i),n[2].setCoordsPoint2D(i),o[2].setCoordsPoint2D(i),h=Ys(t,o,a,3,s),m.setFromTwoTriangles(n,o)}return m.isIdentity()||(e.applyTransformation(m),e.setStartXY(o[0]),e.setEndXY(i?o[0]:o[1]),e.normalizeAfterEndpointChange()),a&&(e.setStartAttribute(1,0,a[0]),e.setEndAttribute(1,0,i?a[0]:a[1])),h}(t,e,s);case n.G.enumBezier2:case n.G.enumRationalBezier2:return(0,n.g)(0),!1;default:(0,n.b)("")}}function Vs(t,e,s){if(!e.hasNonLinearSegments())return qs(t,e,s);if(e.isEmpty())return!1;const n=e.createInstance();n.reserveParts(e.getPointCount(),e.getPathCount());const o=e.getImpl(),a=new i.S;for(let h=0,m=e.getPathCount();h<m;++h){let e=!0,m=-1;const l=o.getPathStart(h),u=l+o.getSegmentCountPath(h);o.isClosedPath(h)&&(m=u-1);const c=new r.P;for(let r=l;r<u;++r){if(o.getSegmentBuffer(r,a,!1),Fs(t,a.get(),s),e||a.get().getStartXY().equals(c)||a.get().moveTo(c),r!==m)n.addSegment(a.get(),e);else{if(e){const t=new i.P;a.get().queryStart(t),n.startPathPoint(t)}n.closeLastPathWithSegment(a.get())}c.assign(a.get().getEndXY()),e=!1}}return e.assignMove(n),!0}function Rs(t,e,s,n,o,a){if(t.isIdentityGeogToGeog()){const s=90*t.getInputSR().getOneDegreeGCSUnit();let i=0;const o=[0];for(let t=0;t<n;t++)o[0]=e[t].y,i|=(0,r.az)(o,-s,s)?1:0,e[t].y=o[0];return i}const h=t.getInputSR(),m=t.getOutputSR(),l=h.getVCS(),u=m.getVCS(),c=h.getOneDegreeGCSUnit(),g=90*c,_=m.getOneDegreeGCSUnit(),d=t.isVertical(),p=t.getDatumTransformation(),f=!!p&&1===p.getType();if(d||(s=null),!p||0===p.count()){let t=0;const o=[0];for(let s=0;s<n;s++)o[0]=e[s].y,t|=(0,r.az)(o,-g,g)?1:0,e[s].y=o[0];return t|=function(t,e,s,n,r,o,a){let h=null;e&&(h=e.getPEVerticalCoordSys());let m=null;t&&(m=t.getPECoordSys());let l=null;n&&(l=n.getPEVerticalCoordSys());let u=null;if(s&&(u=s.getPECoordSys()),!(m||h||u||l))return!1;const c=je();c.initFromGcsAndVcsPe(m,h);const g=je();return g.initFromGcsAndVcsPe(u,l),function(t,e,s,n,r){if(t.equals(e))return!1;if(n){let s=1,i=0,o=1,a=1,h=0,m=1;Number.isNaN(t.m_heightMetersPerUnit)||(s=t.m_heightMetersPerUnit,i=t.m_heightZ0,o=t.m_heightSign,a=e.m_heightMetersPerUnit,h=e.m_heightZ0,m=e.m_heightSign);const l=o*m*s/a;for(let t=0;t<r;t++)n[t]=(n[t]-i)*l+h}let o=1,a=0;if(Number.isNaN(t.m_XYToRadians)||(o=t.m_XYToRadians/e.m_XYToRadians,a=t.m_PrimeMeridianDegrees-e.m_PrimeMeridianDegrees,0!==a&&(a=(0,i.R)(a),a/=e.m_XYToRadians)),Array.isArray(s)){const t=s;for(let e=0;e<r;e++)t[e][0]=t[e][0]*o+a,t[e][1]=t[e][1]*o}else{const t=s;for(let e=0;e<r;e++){const s=e<<1;t[s]=t[s]*o+a,t[s+1]=t[s+1]*o}}return!0}(c,g,r,o,a)}(h.getGCS(),l,m.getGCS(),u,e,s,n)?1:0,t}f||null===s||Gs();let x=Math.min(n,1024);const y=new Array(x),P=(0,r.a)(x,0);let E=0,C=Number.NaN,v=Number.NaN;const b=360*_,S=_/c;o&&(v=90*_,C=89.9*c);let I=!0,w=0,D=n;for(;D;){let t=!1;for(let t=0;t<x;t++)y[t]=e[t+E].x;if(o)for(let s=0;s<x;s++){const i=Math.abs(e[s+E].y)-C;if(i>0){const n=e[s+E].y;e[s+E].y=(0,r.c)(C,n),P[s]=(0,r.c)(i,n),t=!0}}const i=e[0].x;f?p.transform(!1,e,s,x):p.transform(!1,e,x),I&&(w=e[0].x-S*i,I=!1);for(let t=0;t<x;t++){const s=e[E+t].x-y[t]*S-w;Math.abs(s)>200&&(s>0?e[E+t].x-=b:e[E+t].x+=b)}if(t){for(let t=0;t<x;t++)P[t]&&(e[E+t].y+=S*P[t],e[E+t].y>v?e[E+t].y=v:e[E+t].y<-v&&(e[E+t].y=-v));P.fill(0,0,x)}E+=x,D-=x,x=Math.min(D,1024)}return 1}function Ys(t,e,s,i,n,r){let o=0,a=!0,h=0;for(let r=0;r<i;++r)e[r].isNAN()?a||(o|=Rs(t,e.slice(h,r-h),s?s.slice(h,r-h):null,r-h,n),h=r,a=!0):a&&(h=r,a=!1);return a||(o|=Rs(t,0===h?e:e.slice(h),s?0===h?s:s.slice(h):null,i-h,n)),0!==o}function Xs(t,e,s,i){Cs(t,e,s,i)}function ks(t,e,s,n){Ms(t,e,s,n);const r=new i.a;r.setFromPoints(s,n);const o=t.getOneDegreeGCSUnit(),a=360*o,h=180*o;if(r.width()>h){for(let t=0;t<n;t++)for(;s[t].x<e;)s[t].x+=a;if(r.setFromPoints(s,n),r.xmax>h+e)for(let t=0;t<n;t++)s[t].x-=a}}function Hs(t,e,s,i,n){const o=(0,r.m)(r.P,3);let a=0,h=!1,m=!1;const l=i.isDegenerateToLine();l?(o[0].assign(i.getStartXY()),o[1].assign(i.getEndXY()),o[2].setCoords(0,0),a=2):i.isClosed()&&i.isMajor()?(h=!0,m=!i.isClockwise(),o[0].assign(i.getStartXY()),o[1].assign(i.getCenter()),o[2].setCoords(0,0),a=2):(o[0].assign(i.getStartXY()),o[1].assign(i.getEndXY()),o[2].assign(i.getInteriorPoint()),a=3),t?Xs(e,o,a,n):ks(e,s,o,a),l?i.constructLineCircularArc(o[0],o[1]):h?i.constructCircleCenterAndPoint(o[1],o[0],m):i.constructCircularArcThreePoint(o[0],o[1],o[2])}function Bs(t,e,s){const n=(0,i.aT)(t),r=(0,i.aT)(e),o=(0,i.aS)(n,r),a=(0,i.aS)(n,(0,i.aT)(s));return 0===a||o>0&&a>0&&a<=o||o<0&&a<0&&a>=o}function Ls(t,e,s,i,a){const h={stack:[],error:void 0,hasError:!1};try{const m=s.clone(),l=i.clone();if(2===a){const t=[0,0];return F(0,e,m,l,0,t),t[0]}if(m.y>l.y){const t=new r.P;t.assign(m),m.assign(l),l.assign(t)}const u=(0,o.b)(h,new Qi,!1),c=(0,o.b)(h,new Qi,!1),g=(0,o.b)(h,new Qi,!1),_=new r.E;if(_.setCoords(m.y,l.y),!_.containsCoordinate(0)||Math.abs(m.x-l.x)>=Math.PI)return Number.NaN;if(m.x===l.x)return m.x;rn.geodeticDistance(t,e,m.x,m.y,l.x,l.y,c,u,null,a);const d=c.val;let p=0,f=1;const x=m.clone();for(;d*(f-p)>1e-12*t;){const s=.5*(p+f);if(rn.geodeticCoordinate(t,e,m.x,m.y,d*s,u.val,c,g,a),x.x=c.val,x.y=g.val,_.setCoords(m.y,x.y),0===x.y)return x.x;if(_.containsCoordinate(0))f=s;else{if(_.setCoords(l.y,x.y),!_.containsCoordinate(0))return(0,n.g)(!1),Number.NaN;p=s}}return x.x}catch(t){h.error=t,h.hasError=!0}finally{(0,o.c)(h)}}function zs(t,e,s,i){const n=new r.E;n.setCoords(e,s);const o=i.width();let a=Math.floor((t-e)/o)*o+t;const h=n.getCenter();for(;Math.abs(a-h)>Math.abs(a+o-h);)a+=o;return a}class Us extends c.G{constructor(){super(),this.m_geometryDeque=[],this.m_index=-1}next(){if(this.m_geometryDeque.length>0){this.m_index++;const t=this.m_geometryDeque[0];return this.m_geometryDeque.shift(),t}return null}getGeometryID(){return this.m_index}tick(t){this.m_geometryDeque.push(t)}tock(){return!0}getRank(){return 1}}class Os{constructor(t,e=!0){this.m_PCSHorizon=null,this.m_GCSHorizon=null,this.m_GCSSplitLines=null,this.m_bGCSHorisonIsInclusive=!1,this.m_oneMeterPCS=0,this.m_oneDegreeGCS=0,this.m_gcsUnitFactor=0,this.m_northPole=r.P.getNAN(),this.m_southPole=r.P.getNAN(),this.m_polesUpdated=0,this.m_domain=i.a.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_oldWKID=-1973,this.m_vcsWKID=-1,this.m_bIsPannable=!1,this.m_bCached=!1,this.m_pannableExtent=i.a.constructEmpty(),this.m_pannableExtentGCS=i.a.constructEmpty(),this.m_areaOfUse=null,this.m_canonicalWkt="",this.m_peCoordSys=t,this.m_WKID=Ki.getCode(t),this.m_WKID<=0?(this.m_WKID=0,this.m_canonicalWkt=es(t,0,!0),this.m_hashCode=(0,r.aA)(this.m_canonicalWkt)):this.m_hashCode=(0,r.V)(this.m_WKID);const s=this.m_peCoordSys.getType();this.m_csType=s===Ji.PE_TYPE_PROJCS?2:1,(0,n.g)(s===Ji.PE_TYPE_PROJCS||s===Ji.PE_TYPE_GEOGCS),s===Ji.PE_TYPE_PROJCS&&(t.loadConstants()||(0,n.t)("PeProjcs.loadConstants failed"));const o=s===Ji.PE_TYPE_GEOGCS?this.m_peCoordSys:this.m_peCoordSys.getGeogcs();s!==Ji.PE_TYPE_GEOGCS&&Ki.getCode(o),this.m_unit=function(t){const e=hn(null);return t.getType()===Ji.PE_TYPE_PROJCS||t.getType()===Ji.PE_TYPE_GEOGCS?e.reset(t.getUnit()):(0,n.t)("PE_coord_sys"),e.get()||(0,n.b)("cannot create units from coord sys"),function(t){return t.getType()===Ji.PE_TYPE_LINUNIT?new ri(t):t.getType()===Ji.PE_TYPE_ANGUNIT?new y(t):void(0,n.t)("peUnit")}(e.get())}(t),this.m_primeMeridian=o.getPrimem().getLongitude();{const t=o.getUnit().getUnitFactor();this.m_gcsUnitFactor=t;let e=Math.PI/(180*t);Math.abs(e-1)<1e-10&&(e=1),this.m_oneDegreeGCS=e}if(s===Ji.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=t.getUnit().getUnitFactor();this.m_oneMeterPCS=1/e,this.m_oneMillimeter=.001/e,this.m_pPCSInfoNoDomain=en.generate(t,en.PE_PCSINFO_OPTION_NONE),this.m_pPCSInfoNoDomain||(0,n.b)("cannot create pcs info"),this.m_bIsPannable=this.m_pPCSInfoNoDomain.isPannableRectangle(),this.m_centralMeridian=this.m_pPCSInfoNoDomain.getCentralMeridian()}else{this.m_bIsPannable=!0,this.m_polesUpdated=1,this.m_oneMeterPCS=0;const t=1/o.getUnit().getUnitFactor(),e=o.getDatum().getSpheroid().getAxis();this.m_oneMillimeter=.001/e*t,this.m_centralMeridian=0}this.m_bIsPannable&&(this.updateGCSHorizon(),this.updatePCSHorizon(),this.updatePoles(),this.updateDomain(),this.updatePannableExtent(),this.updatePannableExtentGCS())}[Symbol.dispose](){}getHashCode(){return this.m_hashCode}getPCSHorizonPannable(){return this.m_PCSHorizon}getGCSHorizonPannable(){return this.m_GCSHorizon}getPCSInfo(){return(0,n.g)(this.m_pPCSInfoNoDomain),this.m_pPCSInfoNoDomain}getCentralMeridian(){return this.m_centralMeridian}updateGCSHorizon(){if(this.m_peCoordSys.getType()!==Ji.PE_TYPE_PROJCS)return;let t=!0;const e=this.m_peCoordSys,s=e.getGeogcs(),o=e.horizonGcsGenerate();if(!o)return;(0,n.g)(o.length>0);const a=o[0].getNump(),h=o[0].getKind();let m,c;t=o[0].getInclusive()>0;const g=this.getOneDegreeGCSUnit(),p=90*g,f=360*g,x=370*g,y=180*g*Ji.PE_HORIZON_DELTA/Math.PI,P=i.a.constructEmpty();let E=null;if(a>1)for(let t=1;t<a;t++)if(o[t].getKind()===Ji.PE_HORIZON_LINE){E||(E=new i.i);const e=o[t].getCoord();E.startPathCoords(e[0][0],e[0][1]),E.lineToCoords(e[1][0],e[1][1])}if(h===Ji.PE_HORIZON_RECT){const e=o[0].getCoord();if(P.setFromPoints([new r.P(e[0][0],e[0][1]),new r.P(e[1][0],e[1][1])],2),Math.abs(P.ymax-p)<1e-7*y&&(P.ymax=p),Math.abs(P.ymin+p)<1e-7*y&&(P.ymin=-p),P.width()>x){const t=-400*g,e=t+5*f;P.setCoords({xmin:t,ymin:P.ymin,xmax:e,ymax:P.ymax})}const s=new i.E({env2D:P});this.m_GCSHorizon||(this.m_GCSHorizon=s,this.m_bGCSHorisonIsInclusive=t)}else{let e=this.getPCSInfo().isGcsHorizonMultiOverlap();const h=Pi(s,null,0,1),x=[],y=new r.E;for(let t=0;t<a;t++){if(o[t].getKind()!==Ji.PE_HORIZON_POLY)continue;m=o[t].getSize();const e=o[t].getCoord(),s=i.a.constructEmpty();s.setFromPoints((0,r.aB)(e),m),x.push(new r.E(s.xmin,s.xmax)),s.width(),y.merge(x.at(-1))}let P=!1;const C=new r.E;y.width()>f&&x.length>1?(C.vmin=this.getCentralMeridian()-f,C.vmax=C.vmin+2*f,P=!0,e=!0):(C.vmin=y.vmin,C.vmax=C.vmin+f);const v=t=>{let e=0;for(;x[t].vmin+e<C.vmin;)e+=f;for(;x[t].vmax+e-f>C.vmin;)e-=f;return e};let b=new i.h;if(e){const t=new Us,e=(new _.O).executeMany(t,h,null);for(let s=0;s<a;s++){if(o[s].getKind()!==Ji.PE_HORIZON_POLY)continue;m=o[s].getSize();const n=o[s].getCoord();c=o[s].getInclusive()>0;const a=new i.h;if(a.addPathPoint2D((0,r.aB)(n),m-1,!0),P){const e=v(s),i=x[s].clone();i.move(e);let n=e;const o=new r.T;do{o.setShiftCoords(n,0);const e=a.clone();e.applyTransformation(o),t.tick(e),t.tock(),n+=f,i.move(f)}while(i.vmin<C.vmax)}else t.tick(a),e.tock()}b=e.next()}else{b=new i.h;for(let e=0;e<a;e++){if(o[e].getKind()!==Ji.PE_HORIZON_POLY)continue;m=o[e].getSize();const s=o[e].getCoord();if(c=o[e].getInclusive()>0,(0,n.g)(c===t),P){const t=new i.h;t.addPathPoint2D((0,r.aB)(s),m-1,!0);const n=v(e),o=x[e].clone();o.move(n);let a=n;const h=new r.T;do{if(0!==a){h.setShiftCoords(a,0);const e=new i.h({copy:t});e.applyTransformation(h),b.addPath(e,0,!0)}else b.addPath(t,0,!0);a+=f,o.move(f)}while(o.vmin<C.vmax)}else b.addPathPoint2D((0,r.aB)(s),m-1,!0)}}P&&(b=(new l.O).execute(b,new i.a(C.vmin,-p-g,C.vmax,p+g),h,null)),t?(new u.O).accelerateGeometry(b,h,1):(new d.O).accelerateGeometry(b,h,1),(new $e).accelerateGeometry(b,h,1),null===this.m_GCSHorizon&&(this.m_GCSHorizon=b,this.m_bGCSHorisonIsInclusive=t,this.m_GCSSplitLines=E)}}updateAreaOfUse(){return null}updatePCSHorizon(){if(this.m_peCoordSys.getType()!==Ji.PE_TYPE_PROJCS)return;const t=this.m_peCoordSys.horizonPcsGenerate();if(!t)return;let e;this.getPCSInfo();const s=t[0].getKind();t[0].getInclusive();const o=i.a.constructEmpty(),a=t[0].getNump();let m=!1;if(s===Ji.PE_HORIZON_RECT){const s=t[0].getCoord();o.setFromPoints((0,r.aB)(s),2),e=new i.E({env2D:o})}else{let s=-1;for(let e=0;e<a;e++)t[e].getKind()===Ji.PE_HORIZON_POLY&&(s=e);(0,n.g)(s>=0);const o=t[s].getSize()-1,h=t[s].getCoord(),l=new i.h;e=l,l.addPathPoint2D((0,r.aB)(h),o,!0),m=!0}if(this.getPCSInfo().isDensificationNeeded()){(0,n.g)(s!==Ji.PE_HORIZON_RECT);const t=1e5*this.getOneMeterPCSUnit();e=(new h.O).execute(e,t,0,0,null)}if(m){{const t=new i.E;e.queryEnvelope(t),e.calculateArea2D(),e.calculateLength2D(),e.getExteriorRingCount()}(new u.O).accelerateGeometry(e,null,1)}null===this.m_PCSHorizon&&(this.m_PCSHorizon=e)}updatePannableExtent(){const t=this.m_peCoordSys.getType();if(t===Ji.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=this.getPCSInfo().getCentralMeridian(),s=t.getGeogcs();s||(0,n.b)("");const r=[e+1/s.getUnit().getUnitFactor()*Math.PI,0];$i.geogToProj(t,1,r);const o=r[0],a=t.getParameters()[Ji.PE_PARM_X0].getValue(),h=this.getPCSHorizon(),m=i.a.constructEmpty();h.queryEnvelope(m);const l=Math.abs(o-a),u=l+a,c=-1*l+a,g=m.ymax,_=m.ymin;this.m_pannableExtent.setCoords({xmin:c,ymin:_,xmax:u,ymax:g})}else if(t===Ji.PE_TYPE_GEOGCS){const t=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtent.setCoords({xmin:-t,ymin:-t/2,xmax:t,ymax:t/2})}else(0,n.b)("")}updatePannableExtentGCS(){const t=this.m_peCoordSys.getType();if(t===Ji.PE_TYPE_PROJCS){const t=this.m_peCoordSys,e=this.m_centralMeridian,s=t.getGeogcs();s||(0,n.b)("");const r=1/s.getUnit().getUnitFactor()*Math.PI,o=this.getGCSHorizon(),a=i.a.constructEmpty();o.queryEnvelope(a),this.m_pannableExtentGCS.setCoords({xmin:e-r,ymin:a.ymin,xmax:e+r,ymax:a.ymax})}else if(t===Ji.PE_TYPE_GEOGCS){const t=1/this.m_peCoordSys.getUnit().getUnitFactor()*Math.PI;this.m_pannableExtentGCS.setCoords({xmin:-t,ymin:-t/2,xmax:t,ymax:t/2})}else(0,n.b)("")}updateDomain(){if(1===this.m_csType){const t=400*this.getOneDegreeGCSUnit();this.m_domain=i.a.construct(-t,-t,t,t)}else{(0,n.g)(2===this.m_csType);const t=en.generate(this.m_peCoordSys,en.PE_PCSINFO_OPTION_DOMAIN);t||(0,n.b)("generate pcs info failed");const e=new i.a(t.getDomainMinx(),t.getDomainMiny(),t.getDomainMaxx(),t.getDomainMaxy());this.m_domain.isEmpty()&&this.m_domain.setCoords({env2D:e})}}updatePoles(){if(this.m_peCoordSys.getType()===Ji.PE_TYPE_PROJCS){const t=90*this.getOneDegreeGCSUnit(),e=[[0,t],[0,-t]];$i.geogToProj(this.m_peCoordSys,2,e);const s=this.getPCSInfo().getNorthPoleLocation()!==en.PE_POLE_OUTSIDE_BOUNDARY,i=this.getPCSInfo().getSouthPoleLocation()!==en.PE_POLE_OUTSIDE_BOUNDARY;this.m_polesUpdated||(s&&this.m_northPole.setCoords(e[0][0],e[0][1]),i&&this.m_southPole.setCoords(e[1][0],e[1][1]),this.m_polesUpdated=1)}else this.m_polesUpdated=1}updateGeogToProjFactors(){if(this.m_peCoordSys.getType()===Ji.PE_TYPE_PROJCS){const t=this.getOneDegreeGCSUnit(),e=this.m_pPCSInfoNoDomain.getCentralMeridian(),s=[0,0,0,0];s[0]=e,s[1]=0,s[2]=e+t,s[3]=0;const i=$i.geogToProj(this.m_peCoordSys,2,s);(0,n.g)(2===i);const r=(s[2]-s[0])/t,o=s[0];0===this.m_geogToProjFactorsUpdated&&(this.m_geogToProjFactor=r,this.m_geogToProjOffset=o,this.m_geogToProjFactorsUpdated=1)}else this.m_geogToProjFactorsUpdated=1}getOneMeterPCSUnit(){return this.m_oneMeterPCS}getOneDegreeGCSUnit(){return this.m_oneDegreeGCS}getGcsUnitFactor(){return this.m_gcsUnitFactor}getUnitsPerMillimeter(){return this.m_oneMillimeter}getGCSSplitLines(){return this.m_bIsPannable?null:(this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSSplitLines)}getGCSHorizon(){return this.m_bIsPannable?this.getGCSHorizonPannable():(null!==this.m_GCSHorizon||this.updateGCSHorizon(),this.m_GCSHorizon)}getGCSHorisonIsInclusive(){return this.m_bIsPannable||this.getGCSHorizon(),this.m_bGCSHorisonIsInclusive}getPCSHorizon(){return this.m_bIsPannable?this.getPCSHorizonPannable():(null!==this.m_PCSHorizon||this.updatePCSHorizon(),this.m_PCSHorizon)}getPole(t){return this.m_bIsPannable||0!==this.m_polesUpdated||this.updatePoles(),t?this.m_southPole:this.m_northPole}getGeogToProjFactors(){return 0===this.m_geogToProjFactorsUpdated&&this.updateGeogToProjFactors(),(0,r.d)(this.m_geogToProjFactor,this.m_geogToProjOffset)}getDomainXY(){if(this.m_bIsPannable)return this.m_domain.clone();let t=!1;return t=this.m_domain.isEmpty(),t&&this.updateDomain(),this.m_domain.clone()}getPrimeMeridian(){return this.m_primeMeridian}getLatestID(){return this.m_WKID}getOldID(){let t=this.m_oldWKID;if(t<0){if(t=0,this.m_WKID>0){const e=[0],s=[0];(function(t,e,s,i){return e<=0?(s[0]=0,i[0]=0,!1):(s[0]=e,i[0]=e,!0)})(this.m_peCoordSys.getType(),this.m_WKID,e,s)||(0,n.b)("query_code_change"),t=e[0]}this.m_oldWKID=t}return t}isCustomWkid(){return!1}isPannable(){return this.m_bIsPannable}getPannableExtent(){return this.m_pannableExtent.clone()}getPannableExtentGCS(){return this.m_pannableExtentGCS.clone()}getAreaOfUse(){return null!==this.m_areaOfUse?this.m_areaOfUse:this.updateAreaOfUse()}getVcsCode(){return 0}saveMemory(){}getCSType(){return this.m_csType}getUnit(){return this.m_unit}setCached(){this.m_bCached=!0}getCached(){return this.m_bCached}static equal(t,e){return!1}static equal_for_projection(t,e){return!1}}function Ws(t,e,s,i){return function(t,e,s,i,n){return new Qs(2,e,s,i,n,void 0)}(0,t,e,s,i)}function js(){return{m_extendedParams:{centralMeridianOfOutputGCS:Number.NaN,densificationStep:Number.NaN,clipWithInputHorizon:!0,clipWithOutputHorizon:!0,legacyHorizonClipping:!1,normalizeResultGeometry:!1,equals(t){return(0,r.Q)(this.centralMeridianOfOutputGCS,t.centralMeridianOfOutputGCS)&&(0,r.Q)(this.densificationStep,t.densificationStep)&&this.clipWithInputHorizon===t.clipWithInputHorizon&&this.clipWithOutputHorizon===t.clipWithOutputHorizon&&this.legacyHorizonClipping===t.legacyHorizonClipping&&this.normalizeResultGeometry===t.normalizeResultGeometry}},m_extendedParamsInternal:{flagsMask:0,setFlag(t,e){e?this.flagsMask|=t:this.flagsMask&=~t},hasFlag(t){return!!(this.flagsMask&t)}}}}function Zs(){return js()}class Qs{constructor(t,e,s,i,r,o){let a,h;this.m_datumTran=null,this.m_bIdentity=!0,this.m_bIdentityGeogToGeog=!0,this.m_bVertical=!1,this.m_bNormalize=!1,e&&s||(0,n.t)("!inputSR || !outputSR"),i&&0===i.getType()&&(i.m_bReadOnly=!0),this.m_bNormalize=!1,1!==t&&(a=e.getVCS(),h=s.getVCS(),this.m_bVertical=null!=a&&null!=h),this.m_inputSR=e,this.m_outputSR=s,this.m_bIdentity=!1,this.m_bIdentityGeogToGeog=!1,(0,n.g)(!this.m_params),r&&(this.m_params=js(),this.m_params.m_extendedParams=r),o&&(this.m_params||(this.m_params=js()),this.m_params.m_extendedParamsInternal=o);let m=!1;const l=null!=i,u=e.getCoordinateSystemType(),c=s.getCoordinateSystemType();if(s.isPannable()&&0!==u&&r){const t=r.centralMeridianOfOutputGCS;if(!Number.isNaN(t)&&s.isPannable()){const e=s.getPannableExtent(),i=e.getCenterX();if(i!==t){const s=Math.ceil(e.width());t+s!==i+s&&(m=!0)}}}const g=r&&r.normalizeResultGeometry;if(e.equals(s))return this.m_bIdentity=!m,this.m_bIdentityGeogToGeog=!0,void this.updateProjector();const _=!l&&e.equalForProjection(s,this.m_bVertical);this.m_bIdentity=_&&!m,this.m_bIdentity?this.m_bIdentityGeogToGeog=!0:0!==u&&0!==c&&(g&&this.m_outputSR.isPannable()&&(this.m_bNormalize=g),this.m_datumTran=i||null,this.m_bIdentityGeogToGeog=(!this.m_datumTran||0===this.m_datumTran.count())&&this.m_inputSR.getGCS().equalForProjection(this.m_outputSR.getGCS(),this.m_bVertical)),this.updateProjector()}getInputSR(){return this.m_inputSR}getOutputSR(){return this.m_outputSR}getDatumTransformation(){return this.m_datumTran}getInverse(){const t=new Qs(1,this.m_outputSR,this.m_inputSR,this.m_datumTran?.createInverse());return t.m_bIdentity=this.m_bIdentity,t.m_bVertical=this.m_bVertical,t.m_bIdentityGeogToGeog=this.m_bIdentityGeogToGeog,t.updateProjector(),t}isIdentity(){return this.m_bIdentity}getExtendedParams(){return this.m_params?this.m_params.m_extendedParams:Zs().m_extendedParams}equals(t){return(0,n.g)(0),!1}isVertical(){return this.m_bVertical}isMatchingTransformation(t,e){return(0,n.g)(0),!1}getGeographicTransformations(){return this.m_datumTran}getExtendedParamsImpl(){return this.m_params?this.m_params.m_extendedParams:Zs().m_extendedParams}getExtendedParamsInternal(){return this.m_params?this.m_params.m_extendedParamsInternal:Zs().m_extendedParamsInternal}isIdentityGeogToGeog(){return this.m_bIdentityGeogToGeog}normalizeOutput(){return this.m_bNormalize}updateProjector(){this.m_projector=new ue(this)}}const Ks=new Map,Js=new Map,$s=new Map;function ti(t){let e=t.getCode();if(e>0)return ni(e)||ii(Ki.coordsys(e));const s=t.getName();if(Js.has(s)){const e=Js.get(s);if(e&&e.deref()){const s=e.deref();if(s.m_peCoordSys.isEqual(t))return s}}return e=Ki.getCode(t),ii(e>0?Ki.coordsys(e):t)}let ei;const si=new Map;function ii(t){const e=hn(t),s=t.getCode();if(s>0){const t=ni(s);if(t)return t}const i=t.getName();let n=Js.get(i);if(n){const e=n.deref();if(e&&e.m_peCoordSys.isEqual(t))return e}const r=new Os(e.release());if(s>0)return r.setCached(),Ks.set(s,new WeakRef(r)),Js.set(i,new WeakRef(r)),r;const o=es(t,0,!1);if(n=$s.get(o),n){const t=n.deref();if(t)return t}return r.setCached(),$s.set(o,new WeakRef(r)),r}function ni(t){const e=Ks.get(t);if(e)return e.deref()}class ri extends f{constructor(t){return void 0===t?(super(),this.m_wkid=9001,void(this.m_peUnit=null)):"number"==typeof t?(super(),this.m_factor=t,void(this.m_wkid=0)):(super(t),void(t||(this.m_factor=1,this.m_wkid=9001,this.m_peUnit=(ei||(ei=Ki.unit(9001)),ei))))}getUnitType(){return 0}convertFromMeters(t){return t/this.getUnitToBaseFactor()}convertToMeters(t){return t*this.getUnitToBaseFactor()}}const oi=["0","1","2","3","4","5","6","7","8","9","b","c","d","e","f","g","h","j","k","m","n","p","q","r","s","t","u","v","w","x","y","z"];function ai(t,e,s,i,r){(0,n.g)(i>>5<r.length);let o=e,a=s;for(let e=i;e>=0;e-=2){const s=31&e,i=.5*(a+o);t>=i?(r[e>>5]|=1<<s,o=i):a=i}}let hi=new Set;const mi=2147483645n,li=9007199254740990n,ui="operation is not supported for unknown coordinate systems";var ci;function gi(){return{majorSemiAxis:0,e2:0,minorSemiAxis:0,flattening:0,isSphere(){return 0===this.e2}}}function _i(t){!function(t){mn=t,(0,n.g)(mn)}(t)}function di(){return!!Ki}function pi(){return!!mn}function fi(){return!!Ki||!!mn}function xi(t,e,s){return(0,n.g)(fi()),Ui(t,void 0===e?0:e,null,!1)}function yi(t,e){(0,n.g)(fi());const s=new Vi;let i;return di()?(i=function(t){const e=hn(Ki.fromString(Ji.PE_TYPE_COORDSYS,t));return e.get()||(0,n.C)(t),ti(e.release())}(t),s.setHorzProj_(i),s.m_vertcs=null,s.m_userWKID=i.getLatestID()):(i=ln(t),s.m_unit=i.isPCS?new ri(i.metersOrRadiansPerUnit):new y(i.metersOrRadiansPerUnit)),Bi(s.m_precisionDescriptor,i,null,1),s.m_bDefaultDescriptor=!0,s.m_userWKT=t,s.calculateHashCode(),s.initDbgName(),s}function Pi(t,e,s,i,r=!0){let o=null;return e&&((0,n.g)(0),o={}),function(t,e,s,i,r){t||(0,n.t)("!PE_coord_sys");const o=new Vi;let a;return a=r?ti(t):new Os(t,!1),Bi(o.m_precisionDescriptor,a,e,i),o.m_bDefaultDescriptor=!0,o.setHorzProj_(a),o.m_vertcs=e,o.m_userWKID=a.getLatestID(),o.calculateHashCode(),o.initDbgName(),o}(t,o,0,i,r)}function Ei(t,e,s=!1){3===t.getCoordinateSystemType()&&(0,n.t)("image spatial reference cannot be altered");const i=new Vi,r=t;return i.m_peCoordSysVal=r.m_peCoordSysVal,i.m_vertcs=r.m_vertcs,i.m_unit=r.m_unit,i.m_precisionDescriptor.assign(e),i.m_localZToXYFactor=r.m_localZToXYFactor,(Number.isNaN(i.m_precisionDescriptor.m_falseX)||Number.isNaN(i.m_precisionDescriptor.m_falseY))&&(i.m_precisionDescriptor.m_falseX=r.m_precisionDescriptor.m_falseX,i.m_precisionDescriptor.m_falseY=r.m_precisionDescriptor.m_falseY),i.m_precisionDescriptor.snapPrecision(),i.m_precisionDescriptor.fixTolerance(),i.m_userWKID=r.m_userWKID,i.m_precisionDescriptor.equals(r.m_precisionDescriptor)?i.m_bDefaultDescriptor=r.m_bDefaultDescriptor:i.m_bDefaultDescriptor=!1,s&&(i.m_bDefaultDescriptor=!0),i.calculateHashCode(),i.initDbgName(),i}function Ci(t,e,s){void 0===e&&(e=1),(e<=0||!Number.isFinite(e))&&(0,n.t)(""),t||1===e||(0,n.t)("null Unit has to have z_to_xy_factor equal to 1");const i=new Vi;i.m_unit=t;const r=t||new ri(9001);return void 0===s?(zi(i.m_precisionDescriptor,r,null,1),i.m_bDefaultDescriptor=!0):(i.m_precisionDescriptor.assign(s),i.m_precisionDescriptor.fixTolerance(),i.m_bDefaultDescriptor=!1),Number.isNaN(i.m_precisionDescriptor.m_falseX)&&(0,n.t)("NAN false X/Y are not allowed here"),i.m_localZToXYFactor=e,i.calculateHashCode(),i.initDbgName(),i}function vi(t,e){return t.snapGeometry(e)}function bi(t){const e=t.getCoordinateSystemType();return 1===e?t:(3===e&&(0,n.g)(0),t.getGCS())}function Si(t){return(0,n.g)(fi()),pi()?function(t){return(0,n.g)(pi()),!!mn(t).isPCS||function(t){return Ki&&(0,n.u)("pe has been loaded. no-pe methods should not be used at this point."),Wi||cn(),Wi.has(t)}(t)}(t):function(t){if(si.has(t))return si.get(t);{const e=function(t){return null!==hn(Ki.coordsys(t)).get()}(t);return si.set(t,e),e}}(t)}function Ii(t){return null!==hn(Ki.fromString(Ji.PE_TYPE_COORDSYS,t)).get()}let wi;function Di(){return wi||(wi=(()=>{const t=Math.trunc(Math.random()*(0,r.o)()),e=Date.now();return`|abba_000|${t.toString(16)}|${e.toString(16)}|`})()),wi}var Ti;(Ti=ci||(ci={}))[Ti.utmDefault=0]="utmDefault",Ti[Ti.utmNorthSouth=1]="utmNorthSouth";let Ni=0;function Ai(t=""){let e=`${Di()}${Ni++}`;return""!==t&&(e+=`|${t}`),e}function Mi(t){return t.startsWith(Di())}let Gi,qi,Fi,Vi=class t{destroy(){(function(t){Js.delete(t.m_peCoordSys.getName()),$s.delete(es(t.m_peCoordSys,0,!1))})(this.m_peCoordSysVal),1===this.getCoordinateSystemType()||2===this.getCoordinateSystemType()?this.getPECoordSys().destroy():(0,n.b)("SpatialReference.destroy")}constructor(){this.m_vertcs=null,this.m_peCoordSysVal=null,this.m_userWKID=0,this.m_userWKT=null,this.m_geogSpatialReference=null,this.m_srToGcs=null,this.m_gcsToSr=null,this.m_defaultPrecisionSR=null,this.m_localZToXYFactor=-1,this.m_precisionDescriptor=new Ri,this.m_hashCode=0,this.m_bDefaultDescriptor=!1,Hi(this.m_precisionDescriptor),hi&&hi.add(new WeakRef(this))}attachToPe(){(this.m_userWKID>0?xi(this.m_userWKID):yi(this.m_userWKT)).copyTo(this,!1)}copyTo(t,e=!0){(e||t.m_bDefaultDescriptor)&&(t.m_bDefaultDescriptor=this.m_bDefaultDescriptor,t.m_precisionDescriptor.assign(this.m_precisionDescriptor)),t.m_defaultPrecisionSR=null,t.m_gcsToSr=this.m_gcsToSr,t.m_geogSpatialReference=this.m_geogSpatialReference,t.m_hashCode=this.m_hashCode,t.m_localZToXYFactor=this.m_localZToXYFactor,t.m_peCoordSysVal=this.m_peCoordSysVal,t.m_srToGcs=this.m_srToGcs,t.m_userWKID=this.m_userWKID,t.m_userWKT=this.m_userWKT,t.m_vertcs=this.m_vertcs,t.m_unit=this.m_unit}getHashCode(){return this.m_hashCode}getHashCodeHorizontal(){let t=0;return t=this.m_peCoordSysVal?this.m_peCoordSysVal.getHashCode():this.m_unit?this.m_unit.getHashCode():305419891,t}updateTransform(t){if(1===this.getCoordinateSystemType())return Ws(this,this,null);let e=t?this.m_srToGcs:this.m_gcsToSr;if(e)return e;const s=this.getGCS();e=t?Ws(this,s,null):Ws(s,this,null);const i=e;return(t?this.m_srToGcs:this.m_gcsToSr)||(t?this.m_srToGcs=i:this.m_gcsToSr=i,e)}getHashCodeVertical(){return this.m_vertcs?this.m_vertcs.getHashCode():0}calculateHashCode(){let t=this.getHashCodeHorizontal();const e=this.getHashCodeVertical(),s=this.m_precisionDescriptor.getHashCode();t=(0,r.aw)(t,e),this.m_hashCode=(0,r.aw)(t,s)}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=0){return this.m_precisionDescriptor.getResolution(t)}getPECoordSys(){return this.m_peCoordSysVal?this.m_peCoordSysVal.m_peCoordSys:null}getPCSInfo(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSInfo()}getCentralMeridian(){return this.throwIfNotGCSOrPCS(),1===this.getCoordinateSystemType()?0:this.getPCSInfo().getCentralMeridian()}getCoordinateSystemType(){const t=this.getPECoordSys();if(t)switch(t.getType()){case Ji.PE_TYPE_GEOGCS:return 1;case Ji.PE_TYPE_PROJCS:return 2;default:return 0}else{if((this.m_userWKID>0||this.m_userWKT)&&this.m_unit instanceof ri)return 2;if(this.m_unit instanceof y)return 1}return 0}getID(){return this.m_userWKID}getLatestID(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getLatestID():this.m_userWKID}getOldID(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getOldID():this.m_userWKID}getVerticalID(){return(0,n.a)("vcs not implemented"),0}getLatestVerticalID(){return this.m_vertcs?this.m_vertcs.getLatestID():0}getOldVerticalID(){return(0,n.a)("vcs not implemented"),0}getPEVerticalCoordSys(){return null}getPole(t){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPole(t)}getText(){const t=this.getPECoordSys();return t?ss(t):this.m_userWKT??""}getTextExtended(t){const e=this.getPECoordSys();return e?this.getPEVerticalCoordSys()?(this.getPEVerticalCoordSys(),(0,n.g)(0),""):ss(e,t):this.m_userWKT??""}getText2(t=-1){const e=this.getPECoordSys();return e?function(t,e){(e>1||e<-1)&&(0,n.t)("verbosity");let s=Ji.PE_STR_FMT_WKT2;return-1!==e&&(s|=0===e?Ji.PE_STR_AUTH_TOP:Ji.PE_STR_AUTH_ALL),t.toString(s)}(e,t):this.m_userWKT??""}getUnit(){return this.m_unit}getUnitsPerMillimeter(){return this.m_peCoordSysVal?this.m_peCoordSysVal.getUnitsPerMillimeter():this.m_unit instanceof ri?.001/this.m_unit.getUnitToBaseFactor():this.m_unit instanceof y?.001/(ln(this.m_userWKT??this.m_userWKID).semiMajor*this.m_unit.getUnitToBaseFactor()):((0,n.u)("sr object not in valid state"),0)}getAuthorityName(){return this.getPECoordSys()?((0,n.g)(0),""):""}getVerticalUnit(){return(0,n.a)("vcs not implemented"),{}}getVCS(){return this.m_vertcs}hasVCS(){return!1}getGCSHorisonIsInclusive(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorisonIsInclusive()}getGCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSHorizon()}getGCS(){const t=this.getCoordinateSystemType();if(0===t)(0,n.u)(ui);else{if(1===t)return this;3===t&&(0,n.u)("image cs not supported")}if(this.m_geogSpatialReference)return this.m_geogSpatialReference;let e;if(this===Yi()||this===Xi())e=ki();else{(0,n.g)(this.m_peCoordSysVal);const t=this.m_peCoordSysVal.m_peCoordSys.getGeogcs();t||(0,n.b)(""),e=Pi(t,this.m_vertcs,0,this.m_precisionDescriptor.getPrecision(),this.m_peCoordSysVal.getCached())}return this.m_geogSpatialReference?e=this.m_geogSpatialReference:this.m_geogSpatialReference=e,e}getGCSSplitLines(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGCSSplitLines()}toGCS(t,e){if(0===t.length)return 0;t.length>e.length&&(0,n.t)("coordsSrc.size() > coordsDst.size()");const s=this.getCoordinateSystemType();if(0===s&&(0,n.u)(ui),1===s)return(0,r.ax)(e,t,t.length),t.length;(0,n.g)(this.m_peCoordSysVal);const i=this.getSRToGCSTransform();return(new _e).transform(i,t,t.length,e)}toGeohash(t,e=8){const s=t.clone();s.scale(9102===this.getGCS().getUnit().getID()?1:this.getGCS().getUnit().getUnitToBaseFactor()/Math.PI*180),s.x<-180?(s.x=(0,r.r)(s.x,360),s.x<-180&&(s.x+=360)):s.x>180&&(s.x=(0,r.r)(s.x,360),s.x>180&&(s.x-=360)),s.y>90&&(s.y=90),s.y<-90&&(s.y=-90);const i=5*e,n=new Uint32Array(4);return ai(s.x,-180,180,i-1,n),ai(s.y,-90,90,i-2,n),function(t,e,s){const i=(0,r.a)(e,"R");let n=0,o=0;for(let s=0;s<e;s++){let r=t[n]>>o&31;if(o+=5,o>31){const e=37-o;r&=(1<<e)-1,o-=32,n++,r|=(t[n]&(1<<o)-1)<<e}const a=oi[r];i[e-1-s]=a}return s>e?i.push(..."0".repeat(s-e)):s<e&&(i.length=s),i.join("")}(n,e,e)}isPannable(){const t=this.getCoordinateSystemType();return 0!==t&&3!==t&&((0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.isPannable())}getPannableExtent(){return this.isPannable()||(0,n.t)("!is_pannable"),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtent()}getPannableExtentInGCS(){return this.isPannable()||(0,n.t)("!is_pannable"),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPannableExtentGCS()}throwIfNotGCSOrPCS(){const t=this.getCoordinateSystemType();1!==t&&2!==t&&(0,n.t)("Not a GCS or PCS")}getDomainXY(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getDomainXY()}getFullWorldExtent(){return this.throwIfNotGCSOrPCS(),this.isPannable()?this.getPannableExtent():this.getDomainXY()}queryPrecisionDescriptor(t){if(t.assign(this.m_precisionDescriptor),Number.isNaN(t.m_falseX))if(di()||(0,n.u)("projection engine is not loaded"),(0,n.g)(null!==this.m_peCoordSysVal),2!==this.m_precisionDescriptor.m_precision){const e=this.m_peCoordSysVal.getDomainXY();t.m_falseX=e.xmin,t.m_falseY=e.ymin}else t.m_falseX=-Number.MAX_VALUE,t.m_falseY=-Number.MAX_VALUE}queryPrecisionDescriptorWithoutFalseXY(t){t.assign(this.m_precisionDescriptor),t.m_falseX=Number.NaN,t.m_falseY=Number.NaN}queryDefaultPrecisionDescriptorWithoutFalseXY(t){if(this.m_bDefaultDescriptor)t.assign(this.m_precisionDescriptor);else{const e=this.getCoordinateSystemType();0===e?zi(t,this.m_unit,this.m_vertcs,this.m_precisionDescriptor.getPrecision()):3===e?(0,n.a)("image cs"):Bi(t,this.m_peCoordSysVal,this.m_vertcs,this.m_precisionDescriptor.getPrecision())}t.m_falseX=Number.NaN,t.m_falseY=Number.NaN}horizontalEqual(t){return function(t,e){return t===e||null!==t&&null!==e&&t.m_csType===e.m_csType&&(0===t.m_WKID&&0===e.m_WKID?t.m_hashCode===e.m_hashCode&&t.m_canonicalWkt===e.m_canonicalWkt:t.m_WKID===e.m_WKID)}(this.m_peCoordSysVal,t.m_peCoordSysVal)}verticalEqual(t){return null!==this.m_vertcs==(null!==t.m_vertcs)&&(!this.m_vertcs||this.m_vertcs.equals(t.m_vertcs))}equals(t){const e=t;if(this===e)return!0;if(!this.horizontalEqual(e)||!this.verticalEqual(e))return!1;if(!e.m_peCoordSysVal){if((0,n.g)(!this.m_peCoordSysVal),null!==this.m_unit!=(null!==e.m_unit))return!1;if(this.m_unit&&!this.m_unit.equals(e.m_unit))return!1;if(this.m_localZToXYFactor!==e.m_localZToXYFactor)return!1}if(!this.m_bDefaultDescriptor||!e.m_bDefaultDescriptor){if(this.m_peCoordSysVal){if(!this.m_precisionDescriptor.equalsWithoutFalseXY(e.m_precisionDescriptor))return!1;(0,n.g)(e.m_peCoordSysVal);let t=this.m_precisionDescriptor.m_falseX,s=this.m_precisionDescriptor.m_falseY;if(Number.isNaN(t)){const e=this.m_peCoordSysVal.getDomainXY();t=e.xmin,s=e.ymin}let i=e.m_precisionDescriptor.m_falseX,r=e.m_precisionDescriptor.m_falseY;if(Number.isNaN(i)){const t=e.m_peCoordSysVal.getDomainXY();i=t.xmin,r=t.ymin}return t===i&&s===r}return this.m_precisionDescriptor.equals(e.m_precisionDescriptor)}return!0}equalForProjection(t,e){if(this===t)return!0;const s=this.getCoordinateSystemType(),i=t.getCoordinateSystemType();if(0===s||0===i)return 0===s&&0===i?(!e||this.getZToXYFactor()===t.getZToXYFactor())&&(!this.getUnit()||!t.getUnit()||this.getUnit().equals(t.getUnit())):3!==s&&3!==i&&(null===this.getUnit()||null===t.getUnit()||(!e||this.getZToXYFactor()===t.getZToXYFactor())&&this.getUnit().equals(t.getUnit()));if(s!==i)return!1;if(3===s)return this.equals(t);if(function(t,e){return t===e||null!==t&&null!==e&&t.m_csType===e.m_csType&&(0===t.m_WKID&&0===e.m_WKID?1===t.m_csType?t.m_peCoordSys.isEqual(e.m_peCoordSys):t.m_peCoordSys===e.m_peCoordSys:t.m_WKID===e.m_WKID)}(this.m_peCoordSysVal,t.m_peCoordSysVal)){if(!e)return!0;if(null!==this.m_vertcs==(null!==t.m_vertcs))return!this.m_vertcs||this.m_vertcs.equalForProjection(t.m_vertcs)}return!1}equalHorizontal(t){return this.horizontalEqual(t)}equalVertical(t){return(0,n.g)(0),!1}equalVerticalVCS(t){return(0,n.g)(0),!1}convergenceAngle(t){return(0,n.g)(0),0}getPeCoordsysCopy(){if(this.m_peCoordSysVal){const t=this.m_peCoordSysVal.m_peCoordSys;return t||(0,n.b)("cannot clone coord sys"),t}return null}getPeVertcsCopy(){return(0,n.g)(0),0}throwIfLocal(){0===this.getCoordinateSystemType()&&(0,n.t)(ui)}getPrimeMeridian(){return this.throwIfLocal(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPrimeMeridian()}getSRToGCSTransform(){return this.updateTransform(!0)}getGCSToSRTransform(){return this.updateTransform(!1)}getOneMeter(){return 1e3*this.getUnitsPerMillimeter()}getOneMeterPCSUnit(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneMeterPCSUnit()}getDefaultPrecisionSR(){if(this.m_bDefaultDescriptor)return this;if(null===this.m_defaultPrecisionSR){const t=new Ri;this.queryDefaultPrecisionDescriptorWithoutFalseXY(t),this.m_defaultPrecisionSR=Ei(this,t,!0)}return this.m_defaultPrecisionSR}getPCSHorizon(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getPCSHorizon()}getHorzUnitFactor(){return this.m_unit?this.m_unit.getUnitToBaseFactor():1}querySpheroidData(t){this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal);const e=this.getGCS().getPECoordSys().getDatum().getSpheroid(),s=e.getFlattening();!function(t,e,s){t.majorSemiAxis=e,t.minorSemiAxis=e*(1-s),t.e2=s*(2-s),t.flattening=s}(t,e.getAxis(),s)}getAreaOfUse(){0===this.getCoordinateSystemType()&&(0,n.u)(""),(0,n.g)(this.m_peCoordSysVal);const t=this.m_peCoordSysVal.getAreaOfUse();return null===t?new p:new p({geom:t.clone(),sr:xi(4326)})}getZToXYFactor(){return 1}isCustomWkid(){return!1}getOneDegreeGCSUnit(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getOneDegreeGCSUnit()}getGcsUnitFactor(){return this.throwIfNotGCSOrPCS(),(0,n.g)(this.m_peCoordSysVal),this.m_peCoordSysVal.getGcsUnitFactor()}snapGeometry(t){if(t.isEmpty())return!1;if(2===this.m_precisionDescriptor.getPrecision())return!1;const e=t.getGeometryType();if((0,n.i)(e))return this.snapMultiVertex_(t);if(e===n.G.enumPoint)return this.snapPoint_(t);if(e===n.G.enumEnvelope)return this.snapEnvelope_(t);if((0,n.e)(e))return this.snapSegment_(t);if(e===n.G.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}(0,n.b)("what else?")}snapMultiVertex_(t){if((0,n.g)(!t.isEmpty()),(0,n.g)(2!==this.m_precisionDescriptor.getPrecision()),(0,n.f)(t.getGeometryType())){const e=t;if(e.hasNonLinearSegments())return this.snapGeometryWithCurves_(e)}const e=t.getImpl(),s=e.getDescription();let i=!1;for(let t=0,n=s.getAttributeCount();t<n;t++){const n=s.getSemantics(t),r=e.getAttributeStreamRef(n);i=this.snapAttributes(n,r,0,e.getPointCount())||i}return i&&e.notifyModifiedFlags(2001),i}snapPoint_(t){return!1}snapEnvelope_(t){return!1}snapSegment_(t){(0,n.g)(!t.isEmpty()),(0,n.g)(2!==this.m_precisionDescriptor.getPrecision());const e=new Ri;this.queryPrecisionDescriptor(e);const s=t.getStartXY(),i=new r.P;i.x=Oi(s.x,e.getFalseX(),e.getGridUnitsXY()),i.y=Oi(s.y,e.getFalseY(),e.getGridUnitsXY());let o=!i.equals(s);const a=t.getEndXY(),h=new r.P;h.x=Oi(a.x,e.getFalseX(),e.getGridUnitsXY()),h.y=Oi(a.y,e.getFalseY(),e.getGridUnitsXY()),o||=!h.equals(a),o&&t.changeEndPoints2D(i,h);const m=(e,s,i)=>{let n=!1;{const o=t.getStartAttributeAsDbl(e,0),a=Oi(o,s,i),h=!(0,r.Q)(a,o);n||=h,h&&t.setStartAttribute(e,0,a)}{const o=t.getEndAttributeAsDbl(e,0),a=Oi(o,s,i),h=!(0,r.Q)(a,o);n||=h,h&&t.setEndAttribute(e,0,a)}return n};let l=o?1:0;return t.hasAttribute(1)&&(l|=m(1,e.getFalseZ(),e.getGridUnitsZ())?1:0),t.hasAttribute(2)&&(l|=m(2,e.getFalseM(),e.getGridUnitsM())?1:0),!!l}snapGeometryWithCurves_(t){(0,n.g)(!t.isEmpty()),(0,n.g)(2!==this.m_precisionDescriptor.getPrecision());const e=t.createInstance(),s=new i.S;let r=0;for(let n=0,o=t.getPathCount();n<o;++n){const o=t.getSegmentCountPath(n);if(0===o){if(e.addPath(t,n,!0),1===e.getPathSize(n)){const t=new i.P;e.getPointByVal(e.getPointCount()-1,t),r|=this.snapGeometry(t)?1:0,e.setPointByVal(e.getPointCount()-1,t)}continue}const a=t.isClosedPath(n);for(let i=0,h=a?o-1:o;i<h;++i)t.getSegmentFromPath(n,i,s,!1),r|=this.snapGeometry(s.get())?1:0,e.addSegment(s.get(),0===i);a&&(t.getSegmentFromPath(n,o-1,s,!1),r|=this.snapGeometry(s.get())?1:0,1===o?e.addPathFromClosedSegment(s.get(),!1):e.closeLastPathWithSegment(s.get()))}return r&&e.copyTo(t),!!r}snapAttributes(e,s,i,n){let o=!1;const a=new Ri;if(this.queryPrecisionDescriptor(a),0===e){const e=s;for(let s=i;s<n;s++){const i=e.read(2*s),n=t.s_SnapValue(i,a.getFalseX(),a.getGridUnitsXY()),r=e.read(2*s+1),h=t.s_SnapValue(r,a.getFalseY(),a.getGridUnitsXY());o=o||n!==i||h!==r,o&&(e.write(2*s,n),e.write(2*s+1,h))}}else if(1===e){const e=s;for(let s=i;s<n;s++){const i=e.read(s),n=t.s_SnapValue(i,a.getFalseZ(),a.getGridUnitsZ());o=o||!(0,r.Q)(n,i),o&&e.write(s,n)}}else if(2===e){const e=s;for(let s=i;s<n;s++){const i=e.read(s),n=t.s_SnapValue(i,a.getFalseM(),a.getGridUnitsM());o=o||!(0,r.Q)(n,i),o&&e.write(s,n)}}return o}static s_SnapValue(t,e,s){return(0,r.ay)((t-e)*s)/s+e}};class Ri{constructor(){const t=li,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}getHashCode(){let t=7777,e=7777;return e=(0,r.aw)(e,this.m_falseM),e=(0,r.aw)(e,this.m_unitsM),t=(0,r.aw)(t,this.m_unitsXY),e=(0,r.aw)(e,this.m_toleranceXY),t=(0,r.aw)(t,this.m_falseZ),e=(0,r.aw)(e,this.m_toleranceZ),t=(0,r.aw)(t,this.m_unitsZ),e=(0,r.aw)(e,this.m_toleranceM),t=(0,r.aw)(t,this.m_precision),(0,r.aw)(t,e)}clone(){const t=new Ri;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(){const t=new i.a;switch(this.m_precision){case 0:{const e=Ri.getLimit32()/this.getGridUnitsXY();t.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+e,ymax:this.getFalseY()+e})}break;case 1:{const e=Number(Ri.getLimit64())/this.getGridUnitsXY();t.setCoords({xmin:this.getFalseX(),ymin:this.getFalseY(),xmax:this.getFalseX()+e,ymax:this.getFalseY()+e})}break;case 2:t.setCoords({xmin:-Number.MAX_VALUE,ymin:-Number.MAX_VALUE,xmax:Number.MAX_VALUE,ymax:Number.MAX_VALUE});break;default:t.setEmpty(),(0,n.b)("")}return t}getZGridRange(){const t=new r.E;switch(this.m_precision){case 0:{const e=Ri.getLimit32()/this.getGridUnitsZ();t.setCoords(this.getFalseZ(),this.getFalseZ()+e)}break;case 1:{const e=Number(Ri.getLimit64())/this.getGridUnitsZ();t.setCoords(this.getFalseZ(),this.getFalseZ()+e)}break;case 2:t.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:t.setEmpty(),(0,n.b)("")}return t}getMGridRange(){const t=new r.E;switch(this.m_precision){case 0:{const e=Ri.getLimit32()/this.getGridUnitsM();t.setCoords(this.getFalseM(),this.getFalseM()+e)}break;case 1:{const e=Number(Ri.getLimit64())/this.getGridUnitsM();t.setCoords(this.getFalseM(),this.getFalseM()+e)}break;case 2:t.setCoords(-Number.MAX_VALUE,Number.MAX_VALUE);break;default:t.setEmpty(),(0,n.b)("")}return t}setTolerance(t,e){switch(e<0&&(0,n.t)("tol < 0"),Number.isFinite(e)||(0,n.t)("tol is not finite"),t){case 0:this.m_toleranceXY=e;break;case 1:this.m_toleranceZ=e;break;case 2:this.m_toleranceM=e;break;default:(0,n.t)("cannot set tolerance for this attribute")}}setGridParams(t,e,s){Number.isFinite(t)&&Number.isFinite(e)&&Number.isFinite(s)||(0,n.t)("grid params are not finite"),s<1&&(0,n.t)("grid units cannot be smaller than 1.0"),this.m_falseX=t,this.m_falseY=e,this.m_unitsXY=s}setZParams(t,e){Number.isFinite(t)&&Number.isFinite(e)||(0,n.t)("grid params are not finite"),e<1&&(0,n.t)("grid units cannot be smaller than 1.0"),this.m_falseZ=t,this.m_unitsZ=e}setMParams(t,e){Number.isFinite(t)&&Number.isFinite(e)||(0,n.t)("grid params are not finite"),e<1&&(0,n.t)("grid units cannot be smaller than 1.0"),this.m_falseM=t,this.m_unitsM=e}setPrecision(t){}equals(t){return this===t||(0,r.Q)(this.m_falseX,t.m_falseX)&&(0,r.Q)(this.m_falseY,t.m_falseY)&&this.equalsWithoutFalseXY(t)}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?mi:li);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?mi:li;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(){2!==this.m_precision&&(this.m_toleranceXY=Math.max(2/this.m_unitsXY,this.m_toleranceXY),this.m_toleranceZ=Math.max(2/this.m_unitsZ,this.m_toleranceZ),this.m_toleranceM=Math.max(2/this.m_unitsM,this.m_toleranceM),(Number.isNaN(this.m_falseX)||Number.isNaN(this.m_falseY))&&(this.m_falseX=this.m_falseY=Number.NaN))}equalsWithoutFalseXY(t){return this===t||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}setBestXyDomainFromEnvelope(t,e){}setBestZDomainFromZRange(t,e,s){}setBestMDomainFromMRange(t,e,s){}}function Yi(){return Gi||(Gi=Ui(3857,0,null,!0)),Gi}function Xi(){return qi||(qi=Ui(102100,0,null,!0)),qi}function ki(){return Fi||(Fi=Ui(4326,0,null,!0)),Fi}function Hi(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*(0,r.aa)(),t.m_toleranceZ=100*(0,r.aa)(),t.m_toleranceM=100*(0,r.aa)(),t.m_precision=2}function Bi(t,e,s,i){const r=e instanceof Os;Hi(t),t.m_precision=i,t.m_falseX=Number.NaN,t.m_falseY=Number.NaN;const o=1e-4,a=.001,h=r?e.m_csType:e.isPCS?2:1;if(1===h){const s=(0===i?1/18e5:1e-9)*(r?e.getOneDegreeGCSUnit():Math.PI/e.metersOrRadiansPerUnit/180);t.m_unitsXY=1/s}else if(2===h){const s=(0===i?a:o)*(r?e.getOneMeterPCSUnit():1/e.metersOrRadiansPerUnit);t.m_unitsXY=1/s}else(0,n.t)("unrecognized cs type");t.m_falseM=-1e5,t.m_unitsM=1/(0===i?a:o),t.m_unitsM=Math.max(1,t.m_unitsM),t.m_unitsXY=Math.max(1,t.m_unitsXY);let m=0,l=0;0!==i&&1!==i||(m=2/t.m_unitsXY,l=2/t.m_unitsM),t.m_toleranceXY=Math.max(m,r?e.getUnitsPerMillimeter():2===h?.001/e.metersOrRadiansPerUnit:.001/(e.semiMajor*e.metersOrRadiansPerUnit)),t.m_toleranceM=Math.max(a,l),Li(t,s)}function Li(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 zi(t,e,s,i){Hi(t),t.m_precision=i;const n=0===i?mi:li,r=1e-4,o=.001;let a=1,h=1,m=.001;e&&(h=e.getUnitToBaseFactor()),e&&1===e.getUnitType()?(a=400*Math.PI/180,m=8.983152841195215e-9*Math.PI/180/h):(a=(0===i?o:r)*Number(n)*.5,m=o/h),a/=h,t.m_falseX=-a,t.m_falseY=-a,t.m_unitsXY=Number(n)/(2*a),t.m_falseM=-1e5,t.m_unitsM=1/(0===i?o:r),t.m_unitsM=Math.max(1,t.m_unitsM),t.snapPrecision();let l=0,u=0;0!==t.m_precision&&1!==t.m_precision||(u=2/t.m_unitsM,l=2/t.m_unitsXY),t.m_toleranceXY=Math.max(l,m),t.m_toleranceM=Math.max(o,u),Li(t,s)}function Ui(t,e,s,i){if(!i&&e<=0&&!s){if(3857===t)return Yi();if(102100===t)return Xi();if(4326===t)return ki()}const r=new Vi;let o,a=null;return di()?(o=function(t){t<=0&&(0,n.B)(t);{const e=ni(t);if(e)return e}const e=hn(Ki.coordsys(t));e.get()||(0,n.B)(t);const s=ii(e.release());return s.getLatestID()!==t&&Ks.set(t,new WeakRef(s)),s}(t),e>0?a=null:e=0,r.setHorzProj_(o),r.m_vertcs=a):(o=ln(t),r.m_unit=o.isPCS?new ri(o.metersOrRadiansPerUnit):new y(o.metersOrRadiansPerUnit)),Bi(r.m_precisionDescriptor,o,a,1),r.m_bDefaultDescriptor=!0,r.m_userWKID=t,r.calculateHashCode(),r.initDbgName(),r}function Oi(t,e,s){return(0,r.ay)((t-e)*s)/s+e}let Wi=null;const ji=3552713678800501e-30;function Zi(t,e){return function(t,e,s){return t===e||Math.abs(t-e)<=s*(1+(Math.abs(t)+Math.abs(e))/2)}(t,e,ji)}let Qi,Ki,Ji,$i,tn,en,sn,nn,rn,on,an;function hn(t){return{_this:t,get(){return this._this},reset(t){this._this=t},release(){const t=this._this;return this._this=null,t}}}let mn=null;function ln(t){(0,n.g)(mn);const e=mn(t);return e.semiMajor=e.isPCS?Number.NaN:function(t){if(Ki&&(0,n.u)("pe has been loaded. no-pe methods should not be used at this point."),"string"==typeof t){const e=t.match(un);e&&2===e.length||(0,n.t)("bad gcs wkt");const s=Number.parseFloat(e[1]);return Number.isFinite(s)||(0,n.t)("bad gcs wkt"),s}return Wi||cn(),Wi.has(t)||(0,n.u)("gcs wkid not found"),Wi.get(t)}(t),e}const un=/(?:ELLIPSOID|SPHEROID)\["(?:\w|[-()])+",(\d+\.\d+)/;function cn(){Wi=new Map;for(const t in x){const e=Number.parseFloat(t),s=x[t];if(Array.isArray(s))for(const t of s)Wi.set(t,e);else Wi.set(s,e)}!function(){for(const t in x)delete x[t]}()}(0,r.i)(0),(0,r.i)(1);const gn=Object.freeze(Object.defineProperty({__proto__:null,SpatialReference:Vi,SpatialReferencePrecisionDescriptor:Ri,create:xi,createFromWKT:yi,createImplFromPe:Pi,createLocal:Ci,createWithNewPrecision:Ei,getGCS:bi,getTempName:Ai,hasNoPe:pi,hasPe:di,injectNoPe:_i,injectPe:function(t){if(Ki)return;!function(t){const e=t;Ki=e.PeFactory,(0,n.g)(Ki),an=e.PeGCSExtent,(0,n.g)(an),rn=e.PeLineType,(0,n.g)(rn),on=e.PeMath,(0,n.g)(on),Qi=e.PeDouble,(0,n.g)(Qi),Ji=e.PeDefs,(0,n.g)(Ji),$i=e.PeCSTransformations,(0,n.g)($i),tn=e.PeGTTransformations,(0,n.g)(tn),en=e.PePCSInfo,(0,n.g)(en),sn=e.PeGTlistExtended,(0,n.g)(sn),Ki.initialize(),nn=e.PeGTlistExtendedEntry,(0,n.g)(nn),Ji.PE_TYPE_ANGUNIT=512,Ji.PE_STR_AUTH_ALL=2,en.PE_POLE_LINE_STRAIGHT=2,en.PE_POLE_LINE_CURVED=3,Ji.PE_PARM_LAM0=2,Ji.PE_PARM_PHI0=6,Ji.PE_PRJ_AZIMUTHAL_EQUIDISTANT=43032,Ji.PE_PRJ_LAMBERT_AZIMUTHAL_EQAREA=43033,Ji.PE_PRJ_ALBERS=43007,Ji.PE_PRJ_CYLINDRICAL_EQAREA=43034,Ji.PE_TYPE_VERTCS=8,Ji.PE_LINETYPE_GEODESIC=0,Ji.PE_LINETYPE_LOXODROME=1,Ji.PE_LINETYPE_GREAT_ELLIPTIC=2,Ji.PE_LINETYPE_NORMAL_SECTION=3,sn.PE_GTLIST_OPTS_USABLE=1,mn=null}(t);const e=hi;hi=null,e.forEach((t=>{const e=t.deref();e&&e.attachToPe()}))},isInitialized:fi,isTempName:Mi,isValidWkid:Si,isValidWkt:Ii,makeSpheroidData:gi,snapGeometry:vi,webMercator:Yi,webMercator102100:Xi,wgs84:ki},Symbol.toStringTag,{value:"Module"})),_n=Object.freeze(Object.defineProperty({__proto__:null,OperatorProject:_e},Symbol.toStringTag,{value:"Module"}))},32406:(t,e,s)=>{s.d(e,{O:()=>ut,T:()=>O,a:()=>U,b:()=>Y,c:()=>L,d:()=>z,e:()=>H,f:()=>R,g:()=>k,i:()=>B,j:()=>X,k:()=>K,l:()=>tt,n:()=>T,p:()=>V,q:()=>C,s:()=>q});var i,n,r,o=s(76061),a=s(55537),h=s(35368),m=s(77592),l=s(11878),u=s(90237);class c{constructor(t){this.m_currentShift=63n,this.m_currentElt=0n,this.m_iCurrentElt=-1,this.m_parent=t,this.m_aiSetElts=t.m_bits.flatMap(((t,e)=>e))}next(){if(this.m_currentShift++,64n===this.m_currentShift){if(this.m_iCurrentElt++,this.m_iCurrentElt===this.m_aiSetElts.length)return c.npos();this.m_currentShift=0n,this.m_currentElt=this.m_parent.m_bits[this.m_aiSetElts[this.m_iCurrentElt]]}for(;this.m_currentShift<63n&&!(this.m_currentElt&1n<<this.m_currentShift);)this.m_currentShift++;return this.m_currentElt&1n<<this.m_currentShift?64*this.m_aiSetElts[this.m_iCurrentElt]+Number(this.m_currentShift):this.next()}static npos(){return Number.MAX_SAFE_INTEGER}}function g(t){return 1n<<(0x3fn&BigInt(t))}function _(t){return t>>6}class d{constructor(t){this.m_bits=[],void 0!==t&&t.copy&&(this.m_bits=t.copy.m_bits.slice())}assignMove(){return this}assignCopy(){return this}hasBit(t){const e=g(t),s=_(t);return void 0!==this.m_bits[s]&&!!(this.m_bits[s]&e)}setBit(t){const e=g(t),s=_(t);void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]|=e}clearBit(t){}flipBit(t){const e=g(t),s=_(t);return void 0===this.m_bits[s]&&(this.m_bits[s]=0n),this.m_bits[s]^=e,0n!==(this.m_bits[s]&e)}clear(){this.m_bits.length=0}isZero(){let t=0;return this.m_bits.forEach((e=>{t|=e?2:1})),!(2&t)}equals(t){if(this===t)return!0;if(this.m_bits.length!==t.m_bits.length)return!1;let e=0;return this.m_bits.forEach(((s,i)=>{e|=s===t.m_bits[i]?2:1})),!(1&e||(t.m_bits.forEach(((t,s)=>{e|=t===this.m_bits[s]?2:1})),1&e))}notEquals(t){return!this.equals(t)}assignOr(t){return t.m_bits.forEach(((t,e)=>{void 0===this.m_bits[e]?this.m_bits[e]=t:this.m_bits[e]|=t})),this}assignSubtract(t){return t.m_bits.forEach(((t,e)=>{void 0!==this.m_bits[e]&&(this.m_bits[e]&=~t)})),this}assignAnd(t){return t.m_bits.forEach(((t,e)=>{void 0!==this.m_bits[e]&&(this.m_bits[e]&=t)})),this}assignXor(t){return t.m_bits.forEach(((t,e)=>{void 0===this.m_bits[e]?this.m_bits[e]=t:this.m_bits[e]^=t})),this}getHashCode(){return this.m_bits.reduce(((t,e)=>(0,l.h)(t,e)),(0,l.i)(0))}getUnorderedBitIterator(){return new c(this)}}class p{constructor(t,e){this.m_map=new Map,this.m_hf=t,this.m_ef=e}add(t){const e=this.m_hf(t);if(!this.m_map.has(e))return this.m_map.set(e,t),this;const s=this.m_map.get(e);return s instanceof Array?s.find((e=>this.m_ef(e,t)))||s.push(t):this.m_ef(s,t)||this.m_map.set(e,[s,t]),this}clear(){this.m_map.clear()}delete(t){return!1}has(t){const e=this.m_hf(t);if(!this.m_map.has(e))return!1;const s=this.m_map.get(e);return s instanceof Array?void 0!==s.find((e=>this.m_ef(e,t))):this.m_ef(s,t)}get(t){const e=this.m_hf(t),s=this.m_map.get(e);if(void 0!==s)return s instanceof Array?s.find((e=>this.m_ef(e,t))):s}get size(){let t=0;for(const e of this.m_map.values())t+=e instanceof Array?e.length:1;return t}forEach(t,e){}[Symbol.iterator](){return(new Set)[Symbol.iterator]()}entries(){return(new Set).entries()}keys(){return(new Set).keys()}values(){return(new Set).values()}get[Symbol.toStringTag](){return"ValueSet"}}class f extends h.F{constructor(t){super(),this.m_bufferLeft=new h.S,this.m_bufferRight=new h.S,this.m_intervalLeft=l.E.constructEmpty(),this.m_intervalRight=l.E.constructEmpty(),this.m_yScanline=Number.NaN,this.m_helper=t}compare(t,e,s){const i=e,n=t.getElement(s);this.m_helper.querySegmentXY(i,this.m_bufferLeft),this.m_helper.querySegmentXY(n,this.m_bufferRight);const r=this.m_bufferLeft.get(),o=this.m_bufferRight.get();if(this.m_intervalLeft.setCoords(r.getStartX(),r.getEndX()),this.m_intervalRight.setCoords(o.getStartX(),o.getEndX()),this.m_intervalLeft.vmax<this.m_intervalRight.vmin)return-1;if(this.m_intervalLeft.vmin>this.m_intervalRight.vmax)return 1;const a=r.getStartY()===r.getEndY(),h=o.getStartY()===o.getEndY();if(a||h){if(a&&h)return 0;if(r.getStartY()===o.getStartY()&&r.getStartX()===o.getStartX())return a?1:-1;if(r.getEndY()===o.getEndY()&&r.getEndX()===o.getEndX())return a?-1:1}let m=r.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(this.m_yScanline,this.m_intervalRight.vmin);if(m===l){const t=r.getEndY(),e=o.getEndY(),s=Math.min(t,e);let i=.5*(s+this.m_yScanline);i===this.m_yScanline&&(i=s),m=r.intersectionOfYMonotonicWithAxisX(i,this.m_intervalLeft.vmin),l=o.intersectionOfYMonotonicWithAxisX(i,this.m_intervalRight.vmin)}return m<l?-1:m>l?1:0}setY(t){this.m_yScanline=t}}class x{constructor(t){this.m_segmentBuffer=new h.S,this.m_point=l.P.getNAN(),this.m_parent=t}setPointXY(t){this.m_point.assign(t)}compare(t,e){const s=t.getElement(e);this.m_parent.querySegmentXY(s,this.m_segmentBuffer);const i=this.m_segmentBuffer.get(),n=new l.E;if(n.setCoords(i.getStartX(),i.getEndX()),this.m_point.x<n.vmin)return-1;if(this.m_point.x>n.vmax)return 1;const r=i.intersectionOfYMonotonicWithAxisX(this.m_point.y,this.m_point.x);return this.m_point.x<r?-1:this.m_point.x>r?1:0}}function y(t,e){return{parentage:t,rank:e}}function P(t,e){const s=t.length;if(s!==e.length)return!1;const i=t[0].parentage;if(i!==e[0].parentage)return!1;if(-1===i)return!0;for(let i=1;i<s;++i)if(t[i].parentage!==e[i].parentage)return!1;return!0}function E(t,e,s){s.length=0;let i=!1;{let n=t.getHalfEdgeVertexIterator(e);for(;n!==h.n;){const e=t.getVertexFromVertexIterator(n),r=t.getShape().getSegmentRank(e),o=t.getShape().getSegmentParentage(e);i||=o>=0,s.push(y(o,r)),n=t.incrementVertexIterator(n)}}{let n=t.getHalfEdgeVertexIterator(t.getHalfEdgeTwin(e));for(;n!==h.n;){const e=t.getVertexFromVertexIterator(n),r=t.getShape().getSegmentRank(e),o=t.getShape().getSegmentParentage(e);i||=o>=0,s.push(y(o,r)),n=t.incrementVertexIterator(n)}}i&&s.sort(((t,e)=>t.rank>e.rank?-1:t.rank<e.rank?1:t.parentage<e.parentage?-1:t.parentage>e.parentage?1:0)),-1===s[0].parentage&&(s.length=1)}(r=i||(i={}))[r.enumInputModeBuildGraph=0]="enumInputModeBuildGraph",r[r.enumInputModeSimplifyAlternate=1]="enumInputModeSimplifyAlternate",r[r.enumInputModeSimplifyWinding=2]="enumInputModeSimplifyWinding",function(t){t[t.enumSegmentParentageBreakNode=1]="enumSegmentParentageBreakNode",t[t.enumPathBreakNode=2]="enumPathBreakNode"}(n||(n={}));class C{constructor(){this.m_shape=null,this.m_clusterData=new h.r(8),this.m_clusterVertices=new h.r(2),this.m_firstCluster=h.n,this.m_lastCluster=h.n,this.m_halfEdgeData=new h.r(8),this.m_chainData=new h.r(8),this.m_chainAreas=null,this.m_chainPerimeters=null,this.m_universeChain=-1,this.m_simplifiedGeometry=-1,this.m_edgeIndices=[],this.m_clusterIndices=[],this.m_chainIndices=[],this.m_bBuildGeometryParentageSets=!1,this.m_chainBitSetIndex=-1,this.m_edgeBitSetIndex=-1,this.m_edgeBitSetIndexLeft=-1,this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_uniqueBitSets=null,this.m_chainBitSets=[],this.m_edgeBitSets=[],this.m_checkDirtyPlanesweepTolerance=Number.NaN,this.m_geometryIDIndex=-1,this.m_clusterIndex=-1,this.m_halfEdgeIndex=-1,this.m_tmpHalfEdgeParentageIndex=-1,this.m_tmpHalfEdgeParentageIndexLeft=-1,this.m_tmpHalfEdgeWindingNumberIndex=-1,this.m_tmpHalfEdgeOddEvenNumberIndex=-1,this.m_segmentParentageIndex=-1,this.m_segmentIndexHe=-1,this.m_clusterBreakNodeIndex=-1,this.m_universeGeomID=-1,this.m_pointCount=0,this.m_progressCounter=0,this.m_bBuildChains=!0,this.m_bDirtyCheckFailed=!1}setCheckDirtyPlanesweepTolerance(t){this.m_checkDirtyPlanesweepTolerance=t}dirtyCheckFailed(){return this.m_bDirtyCheckFailed}getShape(){return this.m_shape}setEditShape(t,e,s=!0,n=!1){n?this.setEditShapeImpl3D_(t,i.enumInputModeBuildGraph,null,e,!1):this.setEditShapeImpl_(t,i.enumInputModeBuildGraph,null,e,s)}setAndSimplifyEditShapeAlternate(t,e,s=null,n=!1){const r=[];r.push(e),this.m_simplifiedGeometry=e,n?this.setEditShapeImpl3D_(t,i.enumInputModeSimplifyAlternate,r,s,!1):this.setEditShapeImpl_(t,i.enumInputModeSimplifyAlternate,r,s,t.getGeometryType(e)===a.G.enumPolygon)}setAndSimplifyEditShapeWinding(t,e,s=null){const n=[];n.push(e),this.m_simplifiedGeometry=e,this.setEditShapeImpl_(t,i.enumInputModeSimplifyWinding,n,s,!0)}removeShape(){null!==this.m_shape&&(-1!==this.m_geometryIDIndex&&(this.m_shape.removeGeometryUserIndex(this.m_geometryIDIndex),this.m_geometryIDIndex=-1),-1!==this.m_clusterIndex&&(this.m_shape.removeUserIndex(this.m_clusterIndex),this.m_clusterIndex=-1),-1!==this.m_halfEdgeIndex&&(this.m_shape.removeUserIndex(this.m_halfEdgeIndex),this.m_halfEdgeIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1),-1!==this.m_segmentParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_segmentParentageIndex),this.m_segmentParentageIndex=-1),-1!==this.m_segmentIndexHe&&(this.deleteUserIndexForHalfEdges(this.m_segmentIndexHe),this.m_segmentIndexHe=-1),-1!==this.m_clusterBreakNodeIndex&&(this.deleteUserIndexForClusters(this.m_clusterBreakNodeIndex),this.m_clusterBreakNodeIndex=-1),this.deleteEdgeBitSets_(),this.deleteChainBitSets_(),this.m_emptyBitSet=null,this.m_geometryMapID=null,this.m_shape=null,this.m_clusterData.deleteAll(!0),this.m_clusterVertices.deleteAll(!0),this.m_firstCluster=h.n,this.m_lastCluster=h.n,this.m_halfEdgeData.deleteAll(!0),this.m_edgeIndices.length=0,this.m_clusterIndices.length=0,this.m_chainIndices.length=0,this.m_chainData.deleteAll(!0),this.m_universeChain=h.n,this.m_chainAreas=null)}getClusterHalfEdge(t){return this.m_clusterData.getField(t,2)}queryXY(t,e){const s=this.getClusterVertexIndex_(t);e.assign(this.m_shape.getXYWithIndex(s))}queryXYZ(t,e){(0,a.g)(0)}getClusterParentage(t){return this.m_clusterData.getField(t,1)}getFirstCluster(){return this.m_firstCluster}getPrevCluster(t){return this.m_clusterData.getField(t,3)}getNextCluster(t){return this.m_clusterData.getField(t,4)}getClusterChain(t){return this.m_clusterData.getField(t,6)}getClusterVertexIterator(t){return this.m_clusterData.getField(t,7)}incrementVertexIterator(t){return this.m_clusterVertices.getField(t,1)}getVertexFromVertexIterator(t){return this.m_clusterVertices.getField(t,0)}getClusterUserIndex(t,e){const s=this.getClusterIndex_(t),i=this.m_clusterIndices[e];return i.size()<=s?-1:i.read(s)}setClusterUserIndex(t,e,s){const i=this.getClusterIndex_(t),n=this.m_clusterIndices[e];n.size()<=i&&n.resize(this.m_clusterData.size(),-1),n.write(i,s)}hasClusterUserIndexFlags(t,e,s){if(-1===e)return!1;const i=this.getClusterUserIndex(t,e);return-1!==i&&!!(s&i)}setClusterUserIndexFlags(t,e,s){const i=this.getClusterIndex_(t),n=this.m_clusterIndices[e];n.size()<=i&&n.resize(this.m_clusterData.size(),-1);let r=n.read(i);-1===r&&(r=0),n.write(i,s|r)}clearClusterUserIndexFlags(t,e,s){const i=this.getClusterIndex_(t),n=this.m_clusterIndices[e];n.size()<=i&&n.resize(this.m_clusterData.size(),-1);let r=n.read(i);-1===r&&(r=0),n.write(i,~s&r)}createUserIndexForClusters(t=-1){const e=new h.A(this.m_clusterData.capacity(),t);for(let t=0,s=this.m_clusterIndices.length;t<s;t++)if(null===this.m_clusterIndices[t])return this.m_clusterIndices[t]=e,t;return this.m_clusterIndices.push(e),this.m_clusterIndices.length-1}deleteUserIndexForClusters(t){this.m_clusterIndices[t]=null}getHalfEdgeOrigin(t){return this.m_halfEdgeData.getField(t,1)}getHalfEdgeTo(t){return this.getHalfEdgeOrigin(this.getHalfEdgeTwin(t))}getHalfEdgeTwin(t){return this.m_halfEdgeData.getField(t,4)}getHalfEdgePrev(t){return this.m_halfEdgeData.getField(t,5)}getHalfEdgeNext(t){return this.m_halfEdgeData.getField(t,6)}getHalfEdgeChain(t){return this.m_halfEdgeData.getField(t,2)}getHalfEdgeFaceParentage(t){return this.getChainParentage(this.getHalfEdgeChain(t))}getHalfEdgeVertexIterator(t){return this.m_halfEdgeData.getField(t,7)}getHalfEdgeFromXY(t,e){this.queryXY(this.getHalfEdgeOrigin(t),e)}getHalfEdgeToXY(t,e){this.queryXY(this.getHalfEdgeTo(t),e)}isHalfEdgeCurve(t){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe)}getHalfEdgeFromXYZ(t,e){(0,a.g)(0)}getHalfEdgeToXYZ(t,e){(0,a.g)(0)}getHalfEdgeParentage(t){return this.m_halfEdgeData.getField(t,3)&C.c_EdgeParentageMask}getHalfEdgeUserIndex(t,e){const s=this.getHalfEdgeIndex_(t),i=this.m_edgeIndices[e];return i.size()<=s?-1:i.read(s)}setHalfEdgeUserIndex(t,e,s){const i=this.getHalfEdgeIndex_(t),n=this.m_edgeIndices[e];n.size()<=i&&n.resize(this.m_halfEdgeData.size(),-1),n.write(i,s)}createUserIndexForHalfEdges(t){void 0===t&&(t=-1);const e=new h.A(this.m_halfEdgeData.capacity(),t);for(let t=0,s=this.m_edgeIndices.length;t<s;t++)if(null===this.m_edgeIndices[t])return this.m_edgeIndices[t]=e,t;this.m_edgeIndices.push(e);const s=this.m_edgeIndices.length-1;return(0,a.g)(s>=0&&s<=Number.MAX_SAFE_INTEGER),s}deleteUserIndexForHalfEdges(t){this.m_edgeIndices[t]=null}deleteEdgesBreakFaces_(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],i=this.getHalfEdgeChain(s),n=this.getHalfEdgeTwin(s),r=this.getHalfEdgeChain(n);this.setChainHalfEdge_(i,h.n),this.setChainHalfEdge_(r,h.n),this.updateVertexToHalfEdgeConnection_(s,!0),this.deleteEdgeImpl_(s)}}doesHalfEdgeBelongToAPolygonInterior(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolygonExterior(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolygonBoundary(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolylineInterior(t,e){return(0,a.g)(0),!1}doesHalfEdgeBelongToAPolylineExterior(t,e){return(0,a.g)(0),!1}doesClusterBelongToAPolygonInterior(t,e){return(0,a.g)(0),!1}doesClusterBelongToAPolygonExterior(t,e){return(0,a.g)(0),!1}doesClusterBelongToAPolygonBoundary(t,e){return(0,a.g)(0),!1}getFirstChain(){return this.m_universeChain}getChainHalfEdge(t){return this.m_chainData.getField(t,1)}getChainParentage(t){return this.m_chainData.getField(t,2)}getChainParent(t){return this.m_chainData.getField(t,3)}getChainFirstIsland(t){return this.m_chainData.getField(t,4)}getChainNextInParent(t){return this.m_chainData.getField(t,5)}getChainNext(t){return this.m_chainData.getField(t,7)}getChainArea(t){const e=this.getChainIndex_(t);let s=this.m_chainAreas.read(e);return Number.isNaN(s)&&(this.updateChainAreaAndPerimeter_(t),s=this.m_chainAreas.read(e)),s}getChainPerimeter(t){return(0,a.g)(0),0}getChainUserIndex(t,e){const s=this.getChainIndex_(t),i=this.m_chainIndices[e];return i.size()<=s?-1:i.read(s)}setChainUserIndex(t,e,s){const i=this.getChainIndex_(t),n=this.m_chainIndices[e];n.size()<=i&&n.resize(this.m_chainData.size(),-1),n.write(i,s)}createUserIndexForChains(){const t=new h.A(this.m_chainData.capacity(),-1);for(let e=0,s=this.m_chainIndices.length;e<s;e++)if(null===this.m_chainIndices[e])return this.m_chainIndices[e]=t,e;return this.m_chainIndices.push(t),this.m_chainIndices.length-1}deleteUserIndexForChains(t){this.m_chainIndices[t]=null}extractPolygonFromChainAndIslands(t,e,s,i){const n=e===h.n?t.createGeometry(a.G.enumPolygon):e,r=new h.S;this.extractPolygonPathFromChain_(t,n,s,i,r);for(let e=this.getChainFirstIsland(s);e!==h.n;e=this.getChainNextInParent(e))this.extractPolygonPathFromChain_(t,n,e,i,r);return n}getGeometryID(t){const e=this.m_shape.getGeometryUserIndex(t,this.m_geometryIDIndex);return(0,a.g)(e>=0),1<<Math.min(e,31)}getClusterFromVertex(t){return this.m_shape.getUserIndex(t,this.m_clusterIndex)}getHalfEdgeFromVertex(t){return this.m_shape.getUserIndex(t,this.m_halfEdgeIndex)}buildGeometryParentageSets(){this.m_bBuildGeometryParentageSets=!0}getChainBitSet(t){if((0,a.g)(this.m_bBuildGeometryParentageSets),-1===this.m_chainBitSetIndex)return this.getEmptySet();const e=this.getChainUserIndex(t,this.m_chainBitSetIndex);(0,a.g)(e>=0);let s=this.m_chainBitSets.at(e);return s||(s=this.getEmptySet()),s}getChainBoundaryBitSet(t){(0,a.g)(this.m_bBuildGeometryParentageSets);const e=new d,s=t=>{const s=this.getChainHalfEdge(t);let i=s;do{const t=this.getEdgeBitSet_(i);null!==t&&e.assignOr(t);const s=this.getEdgeBitSet_(this.getHalfEdgeTwin(i));null!==s&&e.assignOr(s),i=this.getHalfEdgeNext(i)}while(i!==s)};s(t);for(let e=this.getChainFirstIsland(t);e!==h.n;e=this.getChainNextInParent(e))s(t);return e}getChainPolygons(t){return(0,a.g)(0),[]}getGeometriesFromBits(t){if(!this.m_bBuildGeometryParentageSets||null===t)return[];if(null===this.m_geometryMapID){this.m_geometryMapID=new Map;for(let t=this.m_shape.getFirstGeometry();t!==h.n;t=this.m_shape.getNextGeometry(t))this.m_geometryMapID.set(this.m_shape.getGeometryUserIndex(t,this.m_geometryIDIndex),t)}const e=[],s=t.getUnorderedBitIterator();for(let t=s.next();t!==c.npos();t=s.next())(0,a.g)(this.m_geometryMapID.has(t)),e.push(this.m_geometryMapID.get(t));return e}getVertexDominant(t,e){if(e===h.n)return t;const s=this.getClusterFromVertex(t);return this.getVertexDominantFromCluster(s,e)}getVertexDominantFromCluster(t,e){if(e!==h.n){let s=h.n;for(let i=this.getClusterVertexIterator(t);i!==h.n;i=this.incrementVertexIterator(i)){const t=this.getVertexFromVertexIterator(i);s===h.n&&(s=t);const n=this.m_shape.getPathFromVertex(t);if(this.m_shape.getGeometryFromPath(n)===e){s=t;break}}return s}{const e=this.getClusterVertexIterator(t);return e!==h.n?this.getVertexFromVertexIterator(e):h.n}}isBreakNode(t){return this.hasClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumSegmentParentageBreakNode)}setBreakNode(t,e){(0,a.g)(-1!==this.m_clusterBreakNodeIndex),e?this.setClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumSegmentParentageBreakNode):this.clearClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumSegmentParentageBreakNode)}isStrongPathNode(t){return this.hasClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumPathBreakNode)}setStrongPathNode(t,e){if(-1===this.m_clusterBreakNodeIndex){if(!e)return;this.m_clusterBreakNodeIndex=this.createUserIndexForClusters()}e?this.setClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumPathBreakNode):this.clearClusterUserIndexFlags(t,this.m_clusterBreakNodeIndex,n.enumPathBreakNode)}getSegmentParentage(t){if(-1===this.m_segmentParentageIndex)return-1;const e=this.getHalfEdgeUserIndex(t,this.m_segmentParentageIndex);return e>=0?e:-1}isCrossroadAhead(t){const e=this.getHalfEdgeNext(t);if(this.isStrongPathNode(this.getHalfEdgeOrigin(e)))return!0;const s=this.getHalfEdgeTwin(e),i=this.getHalfEdgeNext(s);return t!==this.getHalfEdgeTwin(i)}isCrossroadBehind(t){return(0,a.g)(0),!1}getHalfEdgeConnector(t,e){const s=this.getClusterHalfEdge(t);if(s===h.n)return h.n;let i=s,n=h.n,r=h.n;do{if(this.getHalfEdgeTo(i)===e)return i;if(n===h.n){if(n=this.getClusterHalfEdge(e),n===h.n)return h.n;r=n}if(this.getHalfEdgeTo(r)===t)return i=this.getHalfEdgeTwin(r),i;i=this.getHalfEdgeNext(this.getHalfEdgeTwin(i)),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(i!==s&&r!==n);return h.n}querySegmentXY(t,e){if(-1!==this.m_segmentIndexHe){let s=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);if(-1!==s){if(-2!==s){const t=this.m_shape.getSegmentFromIndex(s);e.copyFrom(t,!0)}else{s=this.getHalfEdgeUserIndex(this.getHalfEdgeTwin(t),this.m_segmentIndexHe);const i=this.m_shape.getSegmentFromIndex(s);e.copyFrom(i,!0),e.get().reverse()}return}}e.createLine();const s=e.get(),i=l.P.getNAN();this.getHalfEdgeFromXY(t,i),s.setStartXY(i),this.getHalfEdgeToXY(t,i),s.setEndXY(i)}isCurveEdge(t){return-1!==this.m_segmentIndexHe&&-1!==this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe)}compareEdgeAnglesCurveHelper_(t,e,s){const i=new h.S,n=new h.S;this.querySegmentXY(t,i),this.querySegmentXY(e,n);const r=i.get(),o=n.get();if(r.equals(o))return 0;const m=new l.P;this.getHalfEdgeFromXY(t,m);const u=new l.P;this.getHalfEdgeToXY(t,u);const c=new l.P;this.getHalfEdgeToXY(e,c),(0,a.g)(!u.isEqualPoint2D(c));const g=r.getTangent(0),_=o.getTangent(0);return l.P.compareVectors(g,_)}compareEdgeAnglesHelper_(t,e,s){if(t===e)return 0;if(this.isHalfEdgeCurve(t)||this.isHalfEdgeCurve(e))return this.compareEdgeAnglesCurveHelper_(t,e,s);const i=l.P.getNAN();this.getHalfEdgeToXY(t,i);const n=l.P.getNAN();if(this.getHalfEdgeToXY(e,n),i.isEqualPoint2D(n))return 0;const r=l.P.getNAN();this.getHalfEdgeFromXY(t,r);const o=l.P.getNAN();o.setSub(i,r);const a=l.P.getNAN();return a.setSub(n,r),!s||a.y>=0&&o.y>0?l.P.compareVectors(o,a):0}compareEdgeAngles_(t,e){return this.compareEdgeAnglesHelper_(t,e,!1)}compareEdgeAnglesForPair_(t,e){return this.compareEdgeAnglesHelper_(t,e,!0)}compareEdgeAngles3D_(t,e){return(0,a.g)(0),0}compareEdgeAnglesForPair3D_(t,e){return(0,a.g)(0),0}dbgDumpChains_(){}dbgDumpChainToPolygon_(t,e){}deleteEdgeInternal_(t){const e=this.getHalfEdgeChain(t),s=this.getHalfEdgeTwin(t),i=this.getHalfEdgeChain(s);(0,a.g)(i===e),(0,a.g)(t===this.getHalfEdgeNext(s)||s===this.getHalfEdgeNext(t));let n=this.getHalfEdgeNext(t);n===s&&(n=this.getHalfEdgeNext(n),n===t&&(n=h.n));const r=this.getChainIndex_(e),o=this.m_chainAreas.read(r);Number.isNaN(o)||(this.setChainArea_(e,Number.NaN),this.setChainPerimeter_(e,Number.NaN));const m=this.getChainHalfEdge(e);m!==t&&m!==s||this.setChainHalfEdge_(e,n),this.updateVertexToHalfEdgeConnection_(t,!0),this.deleteEdgeImpl_(t)}getFirstUnvisitedHalfEdgeOnCluster_(t,e,s){let i=e!==h.n?e:this.getClusterHalfEdge(t);if(i===h.n)return h.n;const n=i;for(;;){if(1!==this.getHalfEdgeUserIndex(i,s))return i;const t=this.getHalfEdgeNext(this.getHalfEdgeTwin(i));if(t===n)return h.n;i=t}}removeSpikes_(){let t=!1;const e=this.createUserIndexForHalfEdges();for(let s=this.getFirstCluster();s!==h.n;s=this.getNextCluster(s)){let i=h.n;for(;;){let n=this.getFirstUnvisitedHalfEdgeOnCluster_(s,i,e);if(n===h.n)break;i=this.getHalfEdgeNext(this.getHalfEdgeTwin(n));let r=n;for(;;){const s=this.getHalfEdgeNext(r),o=this.getHalfEdgePrev(r),a=this.getHalfEdgeTwin(r);if(o===a){if(this.deleteEdgeInternal_(r),t=!0,i!==r&&i!==a||(i=h.n),r===n||o===n){if(n=s,r===n||o===n)break;r=s;continue}}else this.setHalfEdgeUserIndex(r,e,1);if(r=s,r===n)break}}}return this.deleteUserIndexForHalfEdges(e),t}progress_(t,e=!1){}newCluster_(){const t=this.m_clusterData.newElement();return this.m_clusterData.setField(t,1,0),t}newHalfEdgePair_(){const t=this.m_halfEdgeData.newElement();this.m_halfEdgeData.setField(t,2,0),this.m_halfEdgeData.setField(t,3,0);const e=this.m_halfEdgeData.newElement();return this.m_halfEdgeData.setField(e,2,0),this.m_halfEdgeData.setField(e,3,0),this.setHalfEdgeTwin_(t,e),this.setHalfEdgeTwin_(e,t),t}newChain_(){const t=this.m_chainData.newElement();return this.m_chainData.setField(t,2,0),t}deleteChain_(t){return(0,a.g)(0),0}getClusterIndex_(t){return this.m_clusterData.elementToIndex(t)}setClusterVertexIterator_(t,e){this.m_clusterData.setField(t,7,e)}setClusterHalfEdge_(t,e){this.m_clusterData.setField(t,2,e)}setClusterParentage_(t,e){this.m_clusterData.setField(t,1,e)}setPrevCluster_(t,e){this.m_clusterData.setField(t,3,e)}setNextCluster_(t,e){this.m_clusterData.setField(t,4,e)}setClusterVertexIndex_(t,e){this.m_clusterData.setField(t,5,e)}getClusterVertexIndex_(t){return this.m_clusterData.getField(t,5)}setClusterChain_(t,e){this.m_clusterData.setField(t,6,e)}addClusterToExteriorChain_(t,e){this.setClusterChain_(e,t)}getHalfEdgeIndex_(t){return this.m_halfEdgeData.elementToIndex(t)}setHalfEdgeOrigin_(t,e){this.m_halfEdgeData.setField(t,1,e)}setHalfEdgeTwin_(t,e){this.m_halfEdgeData.setField(t,4,e)}setHalfEdgePrev_(t,e){this.m_halfEdgeData.setField(t,5,e)}setHalfEdgeNext_(t,e){this.m_halfEdgeData.setField(t,6,e)}setHalfEdgeChain_(t,e){this.m_halfEdgeData.setField(t,2,e)}setHalfEdgeParentage_(t,e){this.m_halfEdgeData.setField(t,3,e)}getHalfEdgeParentageMask_(t){return this.m_halfEdgeData.getField(t,3)}setHalfEdgeVertexIterator_(t,e){this.m_halfEdgeData.setField(t,7,e)}updateVertexToHalfEdgeConnectionHelper_(t,e){const s=e?h.n:t;for(let e=this.getHalfEdgeVertexIterator(t);e!==h.n;e=this.incrementVertexIterator(e)){const t=this.getVertexFromVertexIterator(e);this.m_shape.setUserIndex(t,this.m_halfEdgeIndex,s)}}updateVertexToHalfEdgeConnection_(t,e){t!==h.n&&(this.updateVertexToHalfEdgeConnectionHelper_(t,e),this.updateVertexToHalfEdgeConnectionHelper_(this.getHalfEdgeTwin(t),e))}getChainIndex_(t){return this.m_chainData.elementToIndex(t)}setChainHalfEdge_(t,e){this.m_chainData.setField(t,1,e)}setChainParentage_(t,e){this.m_chainData.setField(t,2,e)}setChainParent_(t,e){this.m_chainData.setField(t,3,e);const s=this.getChainFirstIsland(e);this.setChainNextInParent_(t,s),this.setChainFirstIsland_(e,t)}setChainFirstIsland_(t,e){this.m_chainData.setField(t,4,e)}setChainNextInParent_(t,e){this.m_chainData.setField(t,5,e)}setChainPrev_(t,e){this.m_chainData.setField(t,6,e)}setChainNext_(t,e){this.m_chainData.setField(t,7,e)}setChainArea_(t,e){const s=this.getChainIndex_(t);this.m_chainAreas.write(s,e)}setChainPerimeter_(t,e){const s=this.getChainIndex_(t);this.m_chainPerimeters.write(s,e)}updateChainAreaAndPerimeter_(t){const e=this.m_shape.hasCurves(),s=new l.K(0),i=new l.K(0),n=this.getChainHalfEdge(t),r=l.P.getNAN(),o=l.P.getNAN(),a=l.P.getNAN();this.getHalfEdgeFromXY(n,r),o.setCoordsPoint2D(r);let m=n;do{this.getHalfEdgeToXY(m,a),e&&this.isCurveEdge(m)||i.pe(l.P.distance(o,a)),this.getHalfEdgeChain(this.getHalfEdgeTwin(m))!==t&&s.pe((a.x-r.x-(o.x-r.x))*(a.y-r.y+(o.y-r.y))*.5),o.setCoordsPoint2D(a),m=this.getHalfEdgeNext(m)}while(m!==n);if(e){const e=new h.S;m=n;do{this.getHalfEdgeToXY(m,a);const n=this.isCurveEdge(m);if(n&&(this.querySegmentXY(m,e),i.pe(e.get().calculateLength2D())),this.getHalfEdgeChain(this.getHalfEdgeTwin(m))!==t&&n){const t=e.get().calculateArea2DHelper();s.pe(t)}m=this.getHalfEdgeNext(m)}while(m!==n)}const u=this.getChainIndex_(t);this.m_chainAreas.write(u,s.getResult()),this.m_chainPerimeters.write(u,i.getResult())}getChainTopmostEdge_(t){return(0,a.g)(0),0}planeSweepParentage_(t,e){const s=new f(this),i=new h.T;i.setCapacity(Math.trunc(this.m_pointCount/2)),i.setComparator(s);const n=[],r=this.createUserIndexForHalfEdges();let o=null;const a=l.P.getNAN();for(let m=this.getFirstCluster();m!==h.n;m=this.getNextCluster(m)){this.progress_(e);const l=this.getClusterHalfEdge(m);if(l!==h.n){if(n.length=0,!this.tryOptimizedInsertion_(i,r,n,m,l)){this.queryXY(m,a),s.setY(a.y);let t=l;do{const e=this.getHalfEdgeUserIndex(t,r);-1!==e&&(i.deleteNode(e),this.setHalfEdgeUserIndex(t,r,h.r.impossibleIndex2())),t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(l!==t);t=l;do{if(-1===this.getHalfEdgeUserIndex(t,r)){const e=i.addElement(t);n.push(e)}t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(l!==t)}for(let e=n.length-1;e>=0;e--){const s=n[e],o=i.getElement(s),a=this.getHalfEdgeTwin(o);this.setHalfEdgeUserIndex(a,r,s),this.planeSweepParentagePropagateParentage_(i,s,t)}}else if(this.getClusterChain(m)===h.n){null===o&&(o=new x(this)),this.queryXY(m,a),o.setPointXY(a);const t=i.searchLowerBound(o);let e=this.m_universeChain;if(-1!==t){let s=i.getElement(t);this.getHalfEdgeChain(s)===this.getHalfEdgeChain(this.getHalfEdgeTwin(s))&&(s=this.getLeftSkipPolylines_(i,t)),s!==h.n&&(e=this.getHalfEdgeChain(s))}this.addClusterToExteriorChain_(e,m)}}this.deleteUserIndexForHalfEdges(r)}planeSweepParentagePropagateParentage_(t,e,s){const n=t.getElement(e),r=this.getHalfEdgeChain(n);if(this.getChainParent(r)!==h.n)return;const o=this.getLeftSkipPolylines_(t,e),m=this.getHalfEdgeTwin(n),l=this.getHalfEdgeChain(m);let u=this.getChainParent(r),c=this.getChainParent(l);if(o===h.n)u===h.n&&(l===r?(this.setChainParent_(l,this.m_universeChain),c=this.m_universeChain,u=c):(c===h.n&&(this.setChainParent_(l,this.m_universeChain),c=this.m_universeChain),this.setChainParent_(r,l),u=l));else{const t=this.getHalfEdgeChain(o);if(c===h.n){if(this.getChainArea(t)<=0){const e=this.getChainParent(t);this.setChainParent_(l,e),c=e}else this.setChainParent_(l,t),c=t;l===r&&(u=c)}}u===h.n&&(this.trySetChainParentFromTwin_(r,l),u=this.getChainParent(r)),(0,a.g)(u!==h.n),s===i.enumInputModeBuildGraph?this.propagateParentageBuildGraph_(t,e,n,o):s===i.enumInputModeSimplifyWinding?this.propagateParentageWinding_(t,e,n,o,m,r,l):s===i.enumInputModeSimplifyAlternate&&this.propagateParentageAlternate_(t,e,n,o,m,r,l)}propagateParentageBuildGraph_(t,e,s,i){let n,r=e;i===h.n?(r=t.getNext(r),n=this.getHalfEdgeChain(s)):n=this.getHalfEdgeChain(i);let o=null,a=this.getChainParentage(n);for(this.m_bBuildGeometryParentageSets&&(o=this.getChainBitSet(n));-1!==r;r=t.getNext(r)){const e=t.getElement(r),s=this.getHalfEdgeTwin(e);n=this.getHalfEdgeChain(e);const i=this.getHalfEdgeChain(s);if(this.m_bBuildGeometryParentageSets){let t=this.getChainBitSet(i);t=new d({copy:t}),t.assignOr(o),this.setChainBitSet_(i,t);let s=this.getChainBitSet(n);const r=this.getLeftEdgeBitSet_(e),a=new d({copy:o});if(a.assignSubtract(r),a.isZero())break;s=new d({copy:s}),s.assignOr(a),this.setChainBitSet_(n,s),o=s}const h=this.getChainParentage(i),m=h|a;m!==h&&this.setChainParentage_(i,m);let l=this.getChainParentage(n);const u=a&~this.getHalfEdgeUserIndex(e,this.m_tmpHalfEdgeParentageIndexLeft);if(u&&(l|=u,this.setChainParentage_(n,l)),0===u)break;a=l}}propagateParentageWinding_(t,e,s,i,n,r,o){if(r===o)return;let m=this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeWindingNumberIndex);m+=this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex);let l=0;const u=[],c=[];c.push(0);for(let s=t.getFirst();s!==e;s=t.getNext(s)){const e=t.getElement(s),i=this.getHalfEdgeTwin(e),n=this.getHalfEdgeChain(e),r=this.getHalfEdgeChain(i);if(n!==r){let t=this.getHalfEdgeUserIndex(e,this.m_tmpHalfEdgeWindingNumberIndex);t+=this.getHalfEdgeUserIndex(i,this.m_tmpHalfEdgeWindingNumberIndex),l+=t;let s=!1;0!==u.length&&u.at(-1)===r&&(c.pop(),u.pop(),s=!0),(0,a.g)(this.getChainParent(r)!==h.n),s&&this.getChainParent(r)===n||(c.push(l),u.push(n))}}if(l+=m,0!==u.length&&u.at(-1)===o&&(c.pop(),u.pop()),0!==l){if(0===c.at(-1)){const t=this.m_simplifiedGeometry,e=this.getGeometryID(t);this.setChainParentage_(r,e)}}else if(0!==c.at(-1)){const t=this.m_simplifiedGeometry,e=this.getGeometryID(t);this.setChainParentage_(r,e)}}propagateParentageAlternate_(t,e,s,i,n,r,o){const a=this.m_simplifiedGeometry,m=this.getGeometryID(a);if(i===h.n)this.setChainParentage_(o,this.m_universeGeomID),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(r,m):this.setChainParentage_(r,this.m_universeGeomID);else{const t=this.getChainParentage(o);if(0===t){const t=this.getHalfEdgeChain(i),e=this.getChainParentage(t);this.setChainParentage_(o,e),1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(r,e===m?this.m_universeGeomID:m):this.setChainParentage_(r,e)}else 1&this.getHalfEdgeUserIndex(s,this.m_tmpHalfEdgeOddEvenNumberIndex)?this.setChainParentage_(r,t===m?this.m_universeGeomID:m):this.setChainParentage_(r,t)}}tryOptimizedInsertion_(t,e,s,i,n){let r=n,o=-1,a=h.n,m=0;do{if(2===m)return!1;const t=this.getHalfEdgeUserIndex(r,e);if(-1!==t){if(-1!==o)return!1;o=t}else{if(a!==h.n)return!1;a=r}m++,r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(n!==r);return a!==h.n&&-1!==o&&(this.setHalfEdgeUserIndex(t.getElement(o),e,h.r.impossibleIndex2()),t.setElement(o,a),s.push(o),!0)}trySetChainParentFromTwin_(t,e){const s=this.getChainArea(t);if(0===s)return!1;const i=this.getChainArea(e);if(s>0&&i<0||s<0&&i>0)return this.setChainParent_(t,e),!0;{const s=this.getChainParent(e);if(s!==h.n)return this.setChainParent_(t,s),!0}return!1}createHalfEdges_(t,e){this.m_halfEdgeIndex=this.m_shape.createUserIndex();for(let s=0,n=e.size();s<n;s++){const n=e.read(s),r=this.m_shape.getUserIndex(n,this.m_clusterIndex),o=this.m_shape.getPathFromVertex(n),m=this.m_shape.getGeometryFromPath(o),l=this.m_shape.getGeometryType(m);if((0,a.f)(l)){const e=this.m_shape.getNextVertex(n);if(e===h.n)continue;const s=this.m_shape.getUserIndex(e,this.m_clusterIndex);if(r===s)continue;const o=this.newHalfEdgePair_(),u=this.getHalfEdgeTwin(o),c=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(c,0,n),this.m_clusterVertices.setField(c,1,-1),this.setHalfEdgeVertexIterator_(o,c),this.m_shape.setUserIndex(n,this.m_halfEdgeIndex,o),this.setHalfEdgeOrigin_(o,r);const g=this.getClusterHalfEdge(r);if(g===h.n)this.setClusterHalfEdge_(r,o),this.setHalfEdgePrev_(o,u),this.setHalfEdgeNext_(u,o);else{const t=this.getHalfEdgePrev(g);this.setHalfEdgePrev_(g,u),this.setHalfEdgeNext_(u,g),this.setHalfEdgeNext_(t,o),this.setHalfEdgePrev_(o,t)}this.setHalfEdgeOrigin_(u,s);const _=this.getClusterHalfEdge(s);if(_===h.n)this.setClusterHalfEdge_(s,u),this.setHalfEdgeNext_(o,u),this.setHalfEdgePrev_(u,o);else{const t=this.getHalfEdgePrev(_);this.setHalfEdgePrev_(_,o),this.setHalfEdgeNext_(o,_),this.setHalfEdgeNext_(t,u),this.setHalfEdgePrev_(u,t)}const p=this.getGeometryID(m);if(t===i.enumInputModeBuildGraph){const t=l===a.G.enumPolygon?p:0;if(this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndex,0),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex,t),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndexLeft,t),this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndexLeft,0),this.m_bBuildGeometryParentageSets){const t=new d,e=this.m_shape.getGeometryUserIndex(m,this.m_geometryIDIndex);t.setBit(e),this.setEdgeBitSet_(o,t),this.setEdgeBitSet_(u,null),this.setLeftEdgeBitSet_(u,t),this.setLeftEdgeBitSet_(o,null)}}else if(t===i.enumInputModeSimplifyWinding){const t=this.m_shape.getXY(n),s=this.m_shape.getXY(e);let i=0,r=0;t.compare(s)<0?i=1:r=-1,this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeWindingNumberIndex,i),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeWindingNumberIndex,r)}else t===i.enumInputModeSimplifyAlternate&&(this.setHalfEdgeUserIndex(o,this.m_tmpHalfEdgeOddEvenNumberIndex,1),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeOddEvenNumberIndex,1));const f=l===a.G.enumPolygon?C.c_EdgeBitMask:0;this.setHalfEdgeParentage_(o,p|f),this.setHalfEdgeParentage_(u,p|f)}}if(this.m_shape.hasCurves()){this.m_segmentIndexHe=this.createUserIndexForHalfEdges();for(let t=0,s=e.size();t<s;t++){const s=e.read(t);if(this.m_shape.getSegment(s)){const t=this.m_shape.getUserIndex(s,this.m_halfEdgeIndex);t!==h.n&&(this.setHalfEdgeUserIndex(t,this.m_segmentIndexHe,this.m_shape.getVertexIndex(s)),this.setHalfEdgeUserIndex(this.getHalfEdgeTwin(t),this.m_segmentIndexHe,-2))}}}}mergeVertexListsOfEdges_(t,e){{const s=this.getHalfEdgeVertexIterator(e);if(s!==h.n){const i=this.getHalfEdgeVertexIterator(t);this.m_clusterVertices.setField(s,1,i),this.setHalfEdgeVertexIterator_(t,s),this.setHalfEdgeVertexIterator_(e,h.n)}}const s=this.getHalfEdgeTwin(t),i=this.getHalfEdgeTwin(e);{const t=this.getHalfEdgeVertexIterator(i);if(t!==h.n){const e=this.getHalfEdgeVertexIterator(s);this.m_clusterVertices.setField(t,1,e),this.setHalfEdgeVertexIterator_(s,t),this.setHalfEdgeVertexIterator_(i,h.n)}}if(-1!==this.m_segmentIndexHe){let n=this.getHalfEdgeUserIndex(t,this.m_segmentIndexHe);if(-1!==n){if(-2===n){const s=this.getHalfEdgeUserIndex(e,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(t,this.m_segmentIndexHe,s)}if(n=this.getHalfEdgeUserIndex(s,this.m_segmentIndexHe),-2===n){const t=this.getHalfEdgeUserIndex(i,this.m_segmentIndexHe);this.setHalfEdgeUserIndex(s,this.m_segmentIndexHe,t)}}}}sortHalfEdgesByAngle_(t){const e=[];for(let s=this.getFirstCluster();s!==h.n;s=this.getNextCluster(s)){e.length=0;const n=this.getClusterHalfEdge(s);if(n!==h.n){let r=n;do{e.push(r),r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n);if(e.length>1){let r=!0;e.length>2?(e.sort(((t,e)=>this.compareEdgeAngles_(t,e))),e.push(e[0])):this.compareEdgeAnglesForPair_(e[0],e[1])>0?e[1]=(0,l.b)(e[0],e[0]=e[1]):r=!1;let o=e[0],a=o,m=this.getHalfEdgeTo(a),u=this.getHalfEdgeTwin(a),c=h.n;for(let s=1,n=e.length;s<n;s++){const n=e[s],r=this.getHalfEdgeTwin(n),l=this.getHalfEdgeOrigin(r);if(l!==m||n===a)this.updateVertexToHalfEdgeConnection_(c,!1),c=h.n,a=n,m=l,u=r;else{if(t===i.enumInputModeBuildGraph){const t=this.getHalfEdgeParentageMask_(a)|this.getHalfEdgeParentageMask_(n);if(this.setHalfEdgeParentage_(a,t),this.setHalfEdgeParentage_(u,t),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndex,this.getHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndex)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndex)),this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeParentageIndexLeft)),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndexLeft,this.getHalfEdgeUserIndex(u,this.m_tmpHalfEdgeParentageIndexLeft)|this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeParentageIndexLeft)),this.m_bBuildGeometryParentageSets){let t,e,s;t=this.getEdgeBitSet_(a),e=this.getEdgeBitSet_(n),s=new d({copy:t}),s.assignOr(e),this.setEdgeBitSet_(a,s),t=this.getEdgeBitSet_(u),e=this.getEdgeBitSet_(r),s=new d({copy:t}),s.assignOr(e),this.setEdgeBitSet_(u,s),t=this.getLeftEdgeBitSet_(a),e=this.getLeftEdgeBitSet_(n),s=new d({copy:t}),s.assignOr(e),this.setLeftEdgeBitSet_(a,s),t=this.getLeftEdgeBitSet_(u),e=this.getLeftEdgeBitSet_(r),s=new d({copy:t}),s.assignOr(e),this.setLeftEdgeBitSet_(u,s)}}else if(-1!==this.m_tmpHalfEdgeWindingNumberIndex){const t=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeWindingNumberIndex),e=this.getHalfEdgeUserIndex(u,this.m_tmpHalfEdgeWindingNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeWindingNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeWindingNumberIndex,t),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeWindingNumberIndex,e)}else if(-1!==this.m_tmpHalfEdgeOddEvenNumberIndex){const t=this.getHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(n,this.m_tmpHalfEdgeOddEvenNumberIndex),e=this.getHalfEdgeUserIndex(u,this.m_tmpHalfEdgeOddEvenNumberIndex)+this.getHalfEdgeUserIndex(r,this.m_tmpHalfEdgeOddEvenNumberIndex);this.setHalfEdgeUserIndex(a,this.m_tmpHalfEdgeOddEvenNumberIndex,t),this.setHalfEdgeUserIndex(u,this.m_tmpHalfEdgeOddEvenNumberIndex,e)}this.mergeVertexListsOfEdges_(a,n),this.deleteEdgeImpl_(n),c=a,e[s]=h.n,n===o&&(e[0]=h.n,o=h.n)}}if(this.updateVertexToHalfEdgeConnection_(c,!1),c=h.n,!r){o=h.n;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s!==h.n){o=s;break}}n!==o&&this.setClusterHalfEdge_(s,o);continue}o=h.n;for(let t=0,s=e.length;t<s;t++){const s=e[t];if(s===h.n)continue;if(o===h.n){o=s,a=o,m=this.getHalfEdgeTo(a),u=this.getHalfEdgeTwin(a);continue}if(s===a)continue;const i=this.getHalfEdgeTwin(s),n=this.getHalfEdgeOrigin(i);this.setHalfEdgeNext_(u,s),this.setHalfEdgePrev_(s,u),a=s,m=n,u=i}this.setClusterHalfEdge_(s,o)}}}}sortHalfEdgesByAngle3D_(t){(0,a.g)(0)}buildChains_(t){this.m_universeChain=this.newChain_(),this.setChainHalfEdge_(this.m_universeChain,h.n);let e=this.m_universeChain;const s=this.createUserIndexForHalfEdges();for(let t=this.getFirstCluster();t!==h.n;t=this.getNextCluster(t)){const i=this.getClusterHalfEdge(t);if(i!==h.n){let t=i;do{if(1!==this.getHalfEdgeUserIndex(t,s)){const i=this.newChain_();this.setChainHalfEdge_(i,t),this.setChainPrev_(i,e),this.setChainNext_(e,i);let n=null;this.m_bBuildGeometryParentageSets&&(n=new d),e=i;let r=0,o=t;do{-1!==this.m_tmpHalfEdgeParentageIndex&&(r|=this.getHalfEdgeUserIndex(o,this.m_tmpHalfEdgeParentageIndex)),this.m_bBuildGeometryParentageSets&&n.assignOr(this.getEdgeBitSet_(o)),this.setHalfEdgeChain_(o,i),this.setHalfEdgeUserIndex(o,s,1),o=this.getHalfEdgeNext(o)}while(o!==t);this.m_bBuildGeometryParentageSets&&this.setChainBitSet_(i,n),this.setChainParentage_(i,r)}t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(t!==i)}}this.m_chainAreas=new h.s(this.m_chainData.size(),Number.NaN),this.m_chainPerimeters=new h.s(this.m_chainData.size(),Number.NaN),this.setChainArea_(this.m_universeChain,Number.POSITIVE_INFINITY),this.setChainPerimeter_(this.m_universeChain,Number.POSITIVE_INFINITY),this.deleteUserIndexForHalfEdges(s)}simplify_(t){(0,a.g)(0)}simplifyAlternate_(){(0,a.g)(0)}simplifyWinding_(){(0,a.g)(0)}setEditShapeImpl_(t,e,s,n,r){this.removeShape(),this.m_bBuildChains=r,this.m_shape=t,this.m_geometryIDIndex=this.m_shape.createGeometryUserIndex();let o=this.m_shape.getTotalPointCount();if(s){o=0;for(let t=0,e=s.length;t<e;t++)o+=this.m_shape.getPointCount(s[t])}const m=new h.A(0);let u=0,c=0;{let t=null!=s?s[0]:this.m_shape.getFirstGeometry(),e=1;for(;t!==h.n;){this.m_shape.setGeometryUserIndex(t,this.m_geometryIDIndex,c++);for(let e=this.m_shape.getFirstPath(t);e!==h.n;e=this.m_shape.getNextPath(e)){let t=this.m_shape.getFirstVertex(e);for(let s=0,i=this.m_shape.getPathSize(e);s<i;s++)m.add(t),t=this.m_shape.getNextVertex(t)}(0,a.h)(this.m_shape.getGeometryType(t))||(u+=this.m_shape.getPathCount(t)),null!=s?(t=e<s.length?s[e]:h.n,e++):t=this.m_shape.getNextGeometry(t)}}this.m_universeGeomID=1<<Math.min(c,31),this.m_pointCount=m.size(),this.m_shape.sortVerticesSimpleByY(m,0,this.m_pointCount),this.m_clusterVertices.setCapacity(this.m_pointCount),this.progress_(n,!0),this.m_clusterData.setCapacity(this.m_pointCount+10),this.m_halfEdgeData.setCapacity(2*this.m_pointCount+32),this.m_chainData.setCapacity(Math.max(32,u)),this.m_clusterIndex=this.m_shape.createUserIndex();const g=l.P.getNAN();let _=0;const d=l.P.getNAN();for(let t=0;t<=this.m_pointCount;t++){if(t<this.m_pointCount){const e=m.read(t);this.m_shape.queryXY(e,d)}else d.setNAN();if(!g.isEqualPoint2D(d)){if(_<t){const e=this.newCluster_();let s=h.n,i=-1;for(let n=_;n<t;n++){i=m.read(n),this.m_shape.setUserIndex(i,this.m_clusterIndex,e);const t=this.m_clusterVertices.newElement();this.m_clusterVertices.setField(t,0,i),this.m_clusterVertices.setField(t,1,s),s=t;const r=this.m_shape.getPathFromVertex(i),o=this.m_shape.getGeometryFromPath(r),a=this.getGeometryID(o);this.setClusterParentage_(e,this.getClusterParentage(e)|a)}this.setClusterVertexIterator_(e,s),this.setClusterVertexIndex_(e,this.m_shape.getVertexIndex(i)),this.m_lastCluster!==h.n&&this.setNextCluster_(this.m_lastCluster,e),this.setPrevCluster_(e,this.m_lastCluster),this.m_lastCluster=e,this.m_firstCluster===h.n&&(this.m_firstCluster=e)}_=t,g.setCoordsPoint2D(d)}}if(this.m_shape.hasSegmentParentage()){-1===this.m_clusterBreakNodeIndex&&(this.m_clusterBreakNodeIndex=this.createUserIndexForClusters());for(let t=0;t<this.m_pointCount;t++){const e=m.read(t);if(this.m_shape.getSegmentParentageBreakVertex(e)){const t=this.getClusterFromVertex(e);this.setBreakNode(t,!0)}}}this.progress_(n,!0);{let t=null!=s?s[0]:this.m_shape.getFirstGeometry(),e=1;for(;t!==h.n;){for(let e=this.m_shape.getFirstPath(t);e!==h.n;e=this.m_shape.getNextPath(e)){if(this.m_shape.isStrongPathStart(e)){const t=this.m_shape.getFirstVertex(e),s=this.getClusterFromVertex(t);this.setStrongPathNode(s,!0)}if(this.m_shape.isStrongPathEnd(e)){const t=this.m_shape.isClosedPath(e)?this.m_shape.getFirstVertex(e):this.m_shape.getLastVertex(e),s=this.getClusterFromVertex(t);this.setStrongPathNode(s,!0)}}null!=s?(t=e<s.length?s[e]:h.n,e++):t=this.m_shape.getNextGeometry(t)}}if(e===i.enumInputModeBuildGraph&&(this.m_tmpHalfEdgeParentageIndex=this.createUserIndexForHalfEdges(),this.m_tmpHalfEdgeParentageIndexLeft=this.createUserIndexForHalfEdges()),e===i.enumInputModeSimplifyWinding&&(this.m_tmpHalfEdgeWindingNumberIndex=this.createUserIndexForHalfEdges()),e===i.enumInputModeSimplifyAlternate&&(this.m_tmpHalfEdgeOddEvenNumberIndex=this.createUserIndexForHalfEdges()),this.createHalfEdges_(e,m),this.dbgNavigate_(),this.sortHalfEdgesByAngle_(e),!Number.isNaN(this.m_checkDirtyPlanesweepTolerance)&&!this.checkStructureAfterDirtySweep_())return this.m_bDirtyCheckFailed=!0,void this.cleanSetEditShapeImpl_();this.buildChains_(e),-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),this.m_bBuildChains&&this.planeSweepParentage_(e,n),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),this.dbgChkChainParents_(),this.dbgDumpChains_(),this.mergeSegmentParentage_(),this.dbgNavigate_(),this.dbgDumpChains_(),this.cleanSetEditShapeImpl_()}setEditShapeImpl3D_(t,e,s,i,n){(0,a.g)(0)}cleanSetEditShapeImpl_(){-1!==this.m_tmpHalfEdgeParentageIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndex),this.m_tmpHalfEdgeParentageIndex=-1),-1!==this.m_tmpHalfEdgeParentageIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeParentageIndexLeft),this.m_tmpHalfEdgeParentageIndexLeft=-1),-1!==this.m_tmpHalfEdgeWindingNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeWindingNumberIndex),this.m_tmpHalfEdgeWindingNumberIndex=-1),-1!==this.m_tmpHalfEdgeOddEvenNumberIndex&&(this.deleteUserIndexForHalfEdges(this.m_tmpHalfEdgeOddEvenNumberIndex),this.m_tmpHalfEdgeOddEvenNumberIndex=-1)}cleanSetEditShapeImpl3D_(){(0,a.g)(0)}dbgNavigate_(){}dbgChkChainParents_(){}deleteEdgeImpl_(t){const e=this.getHalfEdgeNext(t),s=this.getHalfEdgePrev(t),i=this.getHalfEdgeTwin(t),n=this.getHalfEdgeNext(i),r=this.getHalfEdgePrev(i);e!==i&&(this.setHalfEdgeNext_(r,e),this.setHalfEdgePrev_(e,r)),s!==i&&(this.setHalfEdgeNext_(s,n),this.setHalfEdgePrev_(n,s));const o=this.getHalfEdgeOrigin(t);this.getClusterHalfEdge(o)===t&&(n!==t?this.setClusterHalfEdge_(o,n):this.setClusterHalfEdge_(o,h.n));const a=this.getHalfEdgeOrigin(i);this.getClusterHalfEdge(a)===i&&(e!==i?this.setClusterHalfEdge_(a,e):this.setClusterHalfEdge_(a,h.n)),this.m_halfEdgeData.deleteElement(t),this.m_halfEdgeData.deleteElement(i)}getLeftSkipPolylines_(t,e){let s=e;for(;;){if(s=t.getPrev(s),-1===s)return h.n;{const e=t.getElement(s);if(this.getHalfEdgeChain(e)!==this.getHalfEdgeChain(this.getHalfEdgeTwin(e)))return e}}}checkStructureAfterDirtySweep_(){const t=(0,l.e)(this.m_checkDirtyPlanesweepTolerance),e=new l.P,s=new l.P,i=new l.P,n=new l.P,r=new l.P;for(let o=this.getFirstCluster();o!==h.n;o=this.getNextCluster(o)){const a=this.getClusterHalfEdge(o);if(a!==h.n){let o=a;this.getHalfEdgeFromXY(o,e),this.getHalfEdgeToXY(o,s),i.setSub(s,e);let h=i.sqrLength();do{const a=o;if(o=this.getHalfEdgeNext(this.getHalfEdgeTwin(o)),o!==a){this.getHalfEdgeToXY(o,n),r.setSub(n,e);const a=r.sqrLength(),m=r.crossProduct(i),l=m*m/(a*h);if(Math.min(a,h)*l<=t&&r.dotProduct(i)>=0)return!1;i.assign(r),h=a,s.assign(n)}}while(o!==a)}}return!0}extractPolygonPathFromChain_(t,e,s,i,n){const r=this.m_shape.hasSegmentParentage(),o=this.getChainHalfEdge(s);let a=o,m=h.n;const l=new h.P;do{const o=this.getHalfEdgeTwin(a);if(this.getHalfEdgeChain(o)!==s){let s=h.n;const o=this.getHalfEdgeOrigin(a);if(i===h.n){const t=this.getClusterVertexIterator(o);s=this.getVertexFromVertexIterator(t)}else for(let t=this.getClusterVertexIterator(o);t!==h.n;t=this.incrementVertexIterator(t)){const e=this.getVertexFromVertexIterator(t);s===h.n&&(s=e);const n=this.m_shape.getPathFromVertex(e);if(this.m_shape.getGeometryFromPath(n)===i){s=e;break}}let u;if(m===h.n&&(m=t.insertPath(e,h.n),t.setClosedPath(m,!0)),this.m_shape===t?u=t.addVertex(m,s):(this.m_shape.queryPoint(s,l),u=t.addPoint(m,l)),this.isHalfEdgeCurve(a)&&(this.querySegmentXY(a,n),t.setSegmentToIndex(t.getVertexIndex(u),n.get().clone())),r){const e=this.getSegmentParentage(a);t.setSegmentParentageAndBreak(u,e,this.isBreakNode(o))}}a=this.getHalfEdgeNext(a)}while(a!==o)}mergeSegmentParentage_(){if(!this.m_shape.hasSegmentParentage())return;(0,a.g)(-1!==this.m_clusterBreakNodeIndex),(0,a.g)(-1===this.m_segmentParentageIndex);for(let t=this.getFirstCluster();t!==h.n;t=this.getNextCluster(t)){let e=0;const s=this.getClusterHalfEdge(t);if(s!==h.n){let t=s;do{e++,t=this.getHalfEdgeNext(this.getHalfEdgeTwin(t))}while(t!==s&&e<3)}2!==e&&this.setBreakNode(t,!0)}let t=[],e=[];this.m_segmentParentageIndex=this.createUserIndexForHalfEdges();const s=this.createUserIndexForHalfEdges();for(let i=this.getFirstCluster();i!==h.n;i=this.getNextCluster(i)){const n=this.getClusterHalfEdge(i);if(n!==h.n){let i=!1,r=n;do{let n=r;for(;-1===this.getHalfEdgeUserIndex(n,s);){const r=this.getHalfEdgeNext(n),o=this.getHalfEdgeTwin(n);E(this,n,e);const a=e.at(-1).parentage;if(!i){const e=this.getHalfEdgeOrigin(n);if(!this.isBreakNode(e)){const e=this.getHalfEdgePrev(n);n!==e&&(E(this,e,t),i=!0)}}if(i&&!P(e,t)){const t=this.getHalfEdgeOrigin(n);this.setBreakNode(t,!0)}t=(0,l.b)(e,e=t),i=!0;const h=this.getHalfEdgeOrigin(r);this.isBreakNode(h)&&(i=!1),this.setHalfEdgeUserIndex(n,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(o,this.m_segmentParentageIndex,a),this.setHalfEdgeUserIndex(n,s,1),this.setHalfEdgeUserIndex(o,s,1),n=r}r=this.getHalfEdgeNext(this.getHalfEdgeTwin(r))}while(r!==n)}}this.deleteUserIndexForHalfEdges(s)}registerNewBitSet(t){return null===this.m_uniqueBitSets&&(this.m_uniqueBitSets=new p((t=>t.getHashCode()),((t,e)=>t.equals(e))),this.m_uniqueBitSets.add(this.getEmptySet())),null===t?this.getEmptySet():this.m_uniqueBitSets.has(t)?this.m_uniqueBitSets.get(t):(this.m_uniqueBitSets.add(t),t)}getLeftEdgeBitSet_(t){const e=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft);return(0,a.g)(e>=0),(0,a.g)(this.m_edgeBitSets.at(e)),this.m_edgeBitSets.at(e)}getEdgeBitSet_(t){const e=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndex);return(0,a.g)(e>=0),this.m_edgeBitSets.at(e)}setEdgeBitSet_(t,e){(0,a.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_edgeBitSetIndex&&(this.m_edgeBitSetIndex=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndex);-1!==s?this.m_edgeBitSets[s]=e:(this.setHalfEdgeUserIndex(t,this.m_edgeBitSetIndex,this.m_edgeBitSets.length),this.m_edgeBitSets.push(e))}setLeftEdgeBitSet_(t,e){(0,a.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_edgeBitSetIndexLeft&&(this.m_edgeBitSetIndexLeft=this.createUserIndexForHalfEdges());const s=this.getHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft);-1!==s?this.m_edgeBitSets[s]=e:(this.setHalfEdgeUserIndex(t,this.m_edgeBitSetIndexLeft,this.m_edgeBitSets.length),this.m_edgeBitSets.push(e))}setChainBitSet_(t,e){(0,a.g)(this.m_bBuildGeometryParentageSets),e=this.registerNewBitSet(e),-1===this.m_chainBitSetIndex&&(this.m_chainBitSetIndex=this.createUserIndexForChains());const s=this.getChainUserIndex(t,this.m_chainBitSetIndex);-1!==s?this.m_chainBitSets[s]=e:(this.setChainUserIndex(t,this.m_chainBitSetIndex,this.m_chainBitSets.length),this.m_chainBitSets.push(e))}getEmptySet(){return this.m_emptyBitSet||(this.m_emptyBitSet=new d),this.m_emptyBitSet}deleteEdgeBitSets_(){-1!==this.m_edgeBitSetIndex&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndex),this.m_edgeBitSetIndex=-1),-1!==this.m_edgeBitSetIndexLeft&&(this.deleteUserIndexForHalfEdges(this.m_edgeBitSetIndexLeft),this.m_edgeBitSetIndexLeft=-1),this.m_edgeBitSets.length=0,this.m_uniqueBitSets=null}deleteChainBitSets_(){-1!==this.m_chainBitSetIndex&&(this.deleteUserIndexForChains(this.m_chainBitSetIndex),this.m_chainBitSetIndex=-1,this.m_chainBitSets.length=0)}dbgPrintEdge_(t){}dbgVerifyEdgeSegment(t){}}function v(t,e,s){return{vertex0:t,vertex1:e,dir:s}}C.c_EdgeParentageMask=~(1<<31),C.c_EdgeBitMask=1<<31;class b{constructor(t){this.m_shape=null,this.m_spikes=[],this.m_points=new h.A(0),this.m_pointsIndex=-1,this.m_dissolvedEdges=0,this.m_progressTracker=t}executeImpl_(t,e){if(this.m_shape=t,t.getPathCount(e)<2&&t.getPointCount(e)<6)return;this.m_points.resize(0);for(let s=t.getFirstPath(e);s!==h.n;s=t.getNextPath(s)){let e=t.getFirstVertex(s);for(let i=0,n=t.getPathSize(s);i<n;i++,e=t.getNextVertex(e))this.m_points.add(e)}this.m_pointsIndex=t.createUserIndex();for(let e=0,s=this.m_points.size();e<s;++e)t.setUserIndex(this.m_points.read(e),this.m_pointsIndex,e);t.sortVerticesSimpleByY(this.m_points,0,this.m_points.size());let s=this.m_points.read(0);const i=t.getXY(s);let n=1,r=0;const o=[];for(let e=1;e<this.m_points.size();e++){const a=this.m_points.read(e);if(a===h.n)continue;if(-1===t.getUserIndex(a,this.m_pointsIndex))continue;const m=t.getXY(a);if(m.isEqualPoint2D(i))n++;else{if(n>1){for(let s=r;s<e;s++){const e=this.m_points.read(s);if(-1===t.getUserIndex(e,this.m_pointsIndex))continue;const n=t.getNextVertex(e),r=t.getPrevVertex(e);if(e!==n&&!t.isEqualXYPoint2D(n,i)){const t=v(e,n,1);o.push(t)}if(e!==r&&r!==n&&!t.isEqualXYPoint2D(r,i)){const t=v(e,r,-1);o.push(t)}}o.length>0&&this.processBunch_(o,i)}s=a,i.assign(m),n=1,r=e}}if(0===this.m_dissolvedEdges)return t.removeUserIndex(this.m_pointsIndex),void(this.m_pointsIndex=-1);let m=t.getPointCount(e);for(let e=0;e<this.m_points.size();e++){const s=this.m_points.read(e);if(s===h.n)continue;if(-1!==t.getUserIndex(s,this.m_pointsIndex)){t.setUserIndex(s,this.m_pointsIndex,-1);continue}const i=t.getPathFromVertex(s);t.getFirstVertex(i)===s&&t.setFirstVertex(i,h.n),t.freeVertex(s),this.m_points.write(e,h.n),m--}const l=t.createPathUserIndex();let u=t.getPathCount(e);for(let s=0,i=this.m_points.size();s<i;++s){if(this.m_points.read(s)===h.n)continue;let i=this.m_points.read(s);if(-1!==t.getUserIndex(i,this.m_pointsIndex))continue;let n=t.getPathFromVertex(i),r=-1;if(2===t.getPathUserIndex(n,l)){n=h.n;for(let e=t.getNextVertex(i);e!==i;e=t.getNextVertex(e)){const s=t.getPathFromVertex(e);if(2!==t.getPathUserIndex(s,l)){n=s,i=e;break}}n===h.n&&(n=t.insertPath(e,h.n),t.setClosedPath(n,!0),u++),(0,a.g)(n!==h.n)}t.setPathUserIndex(n,l,2),r=t.getFirstVertex(n);let o=0,m=!1,c=i;do{r===c&&(m=!0),t.setUserIndex(c,this.m_pointsIndex,1);const e=t.getPathFromVertex(c);e!==n&&(2!==t.getPathUserIndex(e,l)&&(t.setPathUserIndex(e,l,1),t.setFirstVertex(e,h.n)),t.setPathToVertex(c,n)),o++,c=t.getNextVertex(c)}while(c!==i);m||t.setFirstVertex(n,i),t.setPathSize(n,o)}for(let s=t.getFirstPath(e);s!==h.n;){const e=t.getNextPath(s);1!==t.getPathUserIndex(s,l)&&t.getFirstVertex(s)!==h.n||(t.removePathOnly(s),u--),s=e}t.setGeometryVertexCount(e,m),t.setGeometryPathCount(e,u),t.removePathUserIndex(l),t.removeUserIndex(this.m_pointsIndex),this.m_pointsIndex=-1,t.dbgVerifyVertexCounts(),t.filterClosePoints(0,!0,!1,!1,e)}processBunch_(t,e){t.sort(((t,s)=>{const i=this.m_shape.getXY(t.vertex1).sub(e),n=this.m_shape.getXY(s.vertex1).sub(e),r=l.P.compareVectors(i,n);return 0===r?t.dir<s.dir?-1:1:r}));let s=0;const i=this.m_shape.getXY(t[0].vertex1);let n=1;const r=this.m_shape.hasCurves();for(let e=1,o=t.length;e<o;e++){const a=this.m_shape.getXY(t[e].vertex1);if(!(a.isEqualPoint2D(i)&&(n++,e+1<o))){if(2===n){const e=t[s],i=t[s+1],n=e.dir;if(n!==i.dir){let t=!0;if(r&&(t=!this.m_shape.isCurve(1===e.dir?e.vertex0:e.vertex1)&&!this.m_shape.isCurve(1===i.dir?i.vertex0:i.vertex1)),t){if(1===n){const t=e.vertex0,s=i.vertex0;this.m_shape.setNextVertex(t,s),this.m_shape.setPrevVertex(s,t),this.m_shape.getPrevVertex(t)===s&&(this.m_shape.setUserIndex(t,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const n=e.vertex1,r=i.vertex1;this.m_shape.setPrevVertex(n,r),this.m_shape.setNextVertex(r,n),this.m_shape.getNextVertex(n)===r&&(this.m_shape.setUserIndex(n,this.m_pointsIndex,-1),this.m_shape.setUserIndex(r,this.m_pointsIndex,-1))}else{const t=e.vertex0,s=i.vertex0;this.m_shape.setPrevVertex(t,s),this.m_shape.setNextVertex(s,t),this.m_shape.getNextVertex(t)===s&&(this.m_shape.setUserIndex(t,this.m_pointsIndex,-1),this.m_shape.setUserIndex(s,this.m_pointsIndex,-1));const n=e.vertex1,r=i.vertex1;this.m_shape.setNextVertex(n,r),this.m_shape.setPrevVertex(r,n),this.m_shape.getPrevVertex(n)===r&&(this.m_shape.setUserIndex(n,this.m_pointsIndex,-1),this.m_shape.setUserIndex(r,this.m_pointsIndex,-1))}this.m_dissolvedEdges+=2}}}i.assign(a),s=e,n=1}}t.length=0}}class S{getDirection_(t){return this.m_shape.getNextVertex(this.getEnd1(t))===this.getEnd2(t)}getEnd_(t){const e=this.getEnd1(t),s=this.getEnd2(t);return this.m_shape.getNextVertex(e)===s?s:e}constructor(t){this.m_end1Nodes=[],this.m_end2Nodes=[],this.m_directions=[],this.m_shape=t,this.m_firstFree=-1}getSegment(t){return this.m_shape.getSegment(this.getStart(t))}isBottomUp(t){let e=this.getEnd1(t),s=this.getEnd2(t);this.m_shape.getPrevVertex(e)===s&&(s=(0,l.b)(e,e=s));const i=l.P.getNAN(),n=l.P.getNAN();return this.m_shape.queryXY(e,i),this.m_shape.queryXY(s,n),(0,a.g)(!i.equals(n)),i.y<n.y}getStart(t){const e=this.getEnd1(t),s=this.getEnd2(t);return this.m_shape.getNextVertex(e)===s?e:s}getEnd1(t){return this.m_end1Nodes[t]}getEnd2(t){return this.m_end2Nodes[t]}freeEdge(t){this.m_end1Nodes[t]=this.m_firstFree,this.m_firstFree=t}newEdge(t){if(-1!==this.m_firstFree){const e=this.m_firstFree;return this.m_firstFree=this.m_end1Nodes[e],this.m_end1Nodes[e]=t,this.m_end2Nodes[e]=this.m_shape.getNextVertex(t),e}const e=this.m_end1Nodes.length;return this.m_end1Nodes.push(t),this.m_end2Nodes.push(this.m_shape.getNextVertex(t)),e}getShape(){return this.m_shape}getPath(t){return this.m_shape.getPathFromVertex(this.getEnd1(t))}}let I=class extends h.F{constructor(t){super(),this.m_line1=new h.L,this.m_line2=new h.L,this.m_leftElm=-1,this.m_leftx=0,this.m_seg1=null,this.m_helper=t}compare(t,e,s){const i=t.getElement(s),n=this.m_helper.m_edges;let r;this.m_leftElm===e?r=this.m_leftx:(this.m_seg1=n.getSegment(e),this.m_seg1?r=this.m_seg1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(n.getShape().queryLineConnector(n.getStart(e),this.m_line1,!0),this.m_seg1=this.m_line1,r=this.m_line1.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),this.m_leftx=r,this.m_leftElm=e);let o,h=n.getSegment(i);if(h?o=h.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0):(n.getShape().queryLineConnector(n.getStart(i),this.m_line2,!0),h=this.m_line2,o=this.m_line2.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0)),r===o){const t=n.isBottomUp(e),s=n.isBottomUp(i),m=t?this.m_seg1.getEndY():this.m_seg1.getStartY(),l=s?h.getEndY():h.getStartY(),u=Math.min(m,l);let c=.5*(u+this.m_helper.m_yScanline);c===this.m_helper.m_yScanline&&(c=u),r=this.m_seg1.intersectionOfYMonotonicWithAxisX(c,0),o=h.intersectionOfYMonotonicWithAxisX(c,0),r===o&&(0,a.k)("")}return r<o?-1:r>o?1:0}reset(){this.m_leftElm=-1}};class w{constructor(t){this.m_node=-1,this.m_index=0,this.m_sortedVertices=t.m_sortedVertices,this.m_sortedVerticesArray=t.m_sortedVerticesArray,this.m_sortedVertices&&(this.m_node=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList()))}next(){if(this.m_sortedVertices){const t=this.m_node;if(-1===t)return h.n;const e=this.m_sortedVertices.getData(t);return this.m_node=this.m_sortedVertices.getNext(t),e}if(this.m_index<this.m_sortedVerticesArray.size()){const t=this.m_sortedVerticesArray.read(this.m_index);return this.m_index++,t}return h.n}}class D{constructor(t){this.m_edges=null,this.m_shape=null,this.m_AET=new h.T,this.m_yScanline=0,this.m_geometry=h.n,this.m_unknownRingOrientationCount=-1,this.m_sortedVertices=null,this.m_sortedVerticesArray=null,this.m_unknownNodes=[],this.m_node1UserIndex=-1,this.m_node2UserIndex=-1,this.m_pathOrientationIndex=-1,this.m_pathParentageIndex=-1,this.m_pathParentsIndex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_progressTracker=t,this.m_AET.disableBalancing(),this.m_sweepComparator=new I(this),this.m_AET.setComparator(this.m_sweepComparator)}fixRingOrientation_(){const t=this.fixRingOrientationImplMain_();return-1===this.m_pathOrientationIndex||this.fixRingOrientationImplSimplify_(),t}fixRingOrientationForMp2sp_(){return this.fixRingOrientationImplMain_(),-1===this.m_pathOrientationIndex?-1:this.fixRingOrientationImplMp2sp_()}processBunchForRingOrientationTest_(t){return this.processBunchForRingOrientationTestOddEven_(t)}processBunchForRingOrientationTestOddEven_(t){let e=!1;if(this.m_edges||(this.m_edges=new S(this.m_shape)),this.m_unknownNodes.length=0,this.processBunchForRingOrientationRemoveEdges_(t),!this.m_AET.isAutoBalancing()){let e=0;for(let s=0,i=t.length;s<i;s++)-1!==t[s]&&e++;(e>10||this.m_AET.getMaxDepthEver()>4)&&this.m_AET.enableBalancing()}for(let e=0,s=t.length;e<s;e++){const s=t[e];s!==h.n&&this.insertEdge_(s,-1)}for(let t=0;t<this.m_unknownNodes.length&&this.m_unknownRingOrientationCount>0;t++){const s=this.m_unknownNodes[t],i=this.m_AET.getElement(s),n=this.m_edges.getPath(i),r=this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex);let o=h.n;if(0===r){let t=this.m_AET.getPrev(s),i=s,n=!1;for(;t!==h.T.st_nullNode();){const e=this.m_AET.getElement(t),s=this.m_edges.getPath(e);if(0!==this.m_shape.getPathUserIndex(s,this.m_pathOrientationIndex)){o=s;break}i=t,t=this.m_AET.getPrev(t)}if(t===h.T.st_nullNode())n=!0,t=i;else{const e=this.m_AET.getElement(t);n=this.m_edges.isBottomUp(e),t=this.m_AET.getNext(t),n=!n}do{const s=this.m_AET.getElement(t),r=this.m_edges.getPath(s);if(0===this.m_shape.getPathUserIndex(r,this.m_pathOrientationIndex)){if(n!==this.m_edges.isBottomUp(s)){const t=this.m_shape.getFirstVertex(r);this.m_shape.reverseRingInternal(t),this.m_shape.setLastVertex(r,this.m_shape.getPrevVertex(t)),e=!0}if(this.m_shape.setPathUserIndex(r,this.m_pathOrientationIndex,n?3:2),!n){let t=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex);2===t?(o=this.m_shape.getPathUserIndex(o,this.m_pathParentsIndex),t=this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex),(0,a.g)(3===t)):(0,a.g)(3===t);const e=this.m_shape.getPathUserIndex(o,this.m_pathParentageIndex);this.m_shape.setPathUserIndex(o,this.m_pathParentageIndex,r),this.m_shape.setPathUserIndex(r,this.m_pathParentageIndex,e),this.m_shape.setPathUserIndex(r,this.m_pathParentsIndex,o)}if(this.m_unknownRingOrientationCount--,!this.m_unknownRingOrientationCount)return e}o=r,i=t,t=this.m_AET.getNext(t),n=!n}while(i!==s)}}return e}processBunchForRingOrientationRemoveEdges_(t){for(let e=0,s=t.length;e<s;e++){const s=t[e],i=this.m_shape.getUserIndex(s,this.m_node1UserIndex),n=this.m_shape.getUserIndex(s,this.m_node2UserIndex);if(-1!==i){const t=this.m_AET.getElement(i);this.m_edges.freeEdge(t),this.m_shape.setUserIndex(s,this.m_node1UserIndex,-1)}if(-1!==n){const t=this.m_AET.getElement(n);this.m_edges.freeEdge(t),this.m_shape.setUserIndex(s,this.m_node2UserIndex,-1)}let r=-1;-1!==i&&-1!==n?(this.m_AET.deleteNode(i),this.m_AET.deleteNode(n),t[e]=h.n):r=-1!==i?i:n,-1!==r&&(this.insertEdge_(s,r)||this.m_AET.deleteNode(r),t[e]=h.n)}}dbgVerifyRingOrientation_(){}insertEdge_(t,e){const s=l.P.getNAN(),i=l.P.getNAN();this.m_shape.queryXY(t,s);const n=this.m_shape.getNextVertex(t);this.m_shape.queryXY(n,i);let r=!1;if(s.y<i.y){r=!0;const s=this.m_edges.newEdge(t);let i;-1===e?i=this.m_AET.addElement(s):(i=e,this.m_AET.setElement(i,s)),-1===this.m_shape.getUserIndex(n,this.m_node1UserIndex)?this.m_shape.setUserIndex(n,this.m_node1UserIndex,i):this.m_shape.setUserIndex(n,this.m_node2UserIndex,i);const o=this.m_shape.getPathFromVertex(t);0===this.m_shape.getPathUserIndex(o,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(i)}const o=this.m_shape.getPrevVertex(t);if(this.m_shape.queryXY(o,i),s.y<i.y){r=!0;const s=this.m_edges.newEdge(o);let i;-1===e?i=this.m_AET.addElement(s):(i=e,this.m_AET.setElement(i,s)),-1===this.m_shape.getUserIndex(o,this.m_node1UserIndex)?this.m_shape.setUserIndex(o,this.m_node1UserIndex,i):this.m_shape.setUserIndex(o,this.m_node2UserIndex,i);const n=this.m_shape.getPathFromVertex(t);0===this.m_shape.getPathUserIndex(n,this.m_pathOrientationIndex)&&this.m_unknownNodes.push(i)}return r}fixRingSelfTangency_(){const t=[],e=[];let s=-1,i=-1;const n=new l.P;let r=h.n,o=h.n,m=-1;const u=new w(this);for(let a=u.next();a!==h.n;a=u.next()){const h=new l.P;this.m_shape.queryXY(a,h);const u=this.m_shape.getPathFromVertex(a);n.equals(h)&&o===u?(-1===i&&(s=this.m_shape.createPathUserIndex(),this.m_shape.fillPathUserIndexForGeometry(this.m_geometry,s,-1),i=this.m_shape.createUserIndex(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,i,-1)),-1===m&&(m=e.length,this.m_shape.setUserIndex(r,i,m),e.push(1),-1===this.m_shape.getPathUserIndex(u,s)&&(this.m_shape.setPathUserIndex(u,s,r),t.push(u))),this.m_shape.setUserIndex(a,i,m),e[e.length-1]++):(m=-1,n.assign(h)),r=a,o=u}if(0===t.length)return!1;(0,a.g)(-1!==s);for(let n=0,r=t.length;n<r;n++){const r=t[n];let o=this.m_shape.getPathUserIndex(r,s);const a=this.m_shape.getUserIndex(o,i),h=[],m=[];h.push(o),m.push(a);for(let t=this.m_shape.getNextVertex(o);t!==o;t=this.m_shape.getNextVertex(t)){const s=t,n=this.m_shape.getUserIndex(s,i);if(-1!==n){if(0===m.length){m.push(n),h.push(s);continue}if(m.at(-1)===n){const r=h.at(-1);this.m_shape.peelALoopIntoAPath(r,s),this.m_shape.setUserIndex(t,i,-1),e[n]--,1===e[n]&&(e[n]=0,m.pop(),h.pop()),o=r,t=r}else h.push(t),m.push(n)}}}return this.m_shape.removePathUserIndex(s),this.m_shape.removeUserIndex(i),this.m_shape.dbgVerifyVertexCounts(),!0}progress_(t=!1){}fixRingOrientationImplMain_(){const t={stack:[],error:void 0,hasError:!1};try{let e,s=!1;const i=(0,u.b)(t,(0,l.f)((()=>{this.m_sortedVerticesArray=null})),!1);if(null===this.m_sortedVertices){const t=this.m_shape.getPointCount(this.m_geometry);e=new h.A(0);for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==h.n;t=this.m_shape.getNextPath(t)){let s=this.m_shape.getFirstVertex(t);for(let i=0,n=this.m_shape.getPathSize(t);i<n;i++)e.add(s),s=this.m_shape.getNextVertex(s)}this.m_shape.sortVerticesSimpleByY(e,0,t),this.progress_(!0),this.m_sortedVerticesArray=e}else i.bForget=!0;if(this.m_bFixSelfTangency&&(s=this.fixRingSelfTangency_()),1===this.m_shape.getPathCount(this.m_geometry)){const t=this.m_shape.getFirstPath(this.m_geometry),e=this.m_shape.getRingArea(t);if(this.m_shape.setExterior(t,!0),e<0){const e=this.m_shape.getFirstVertex(t);return this.m_shape.reverseRingInternal(e),this.m_shape.setLastVertex(t,this.m_shape.getPrevVertex(e)),!0}return!1}this.m_shape.dbgVerifyCurves(),this.m_pathOrientationIndex=this.m_shape.createPathUserIndex(),this.m_pathParentageIndex=this.m_shape.createPathUserIndex(),this.m_pathParentsIndex=this.m_shape.createPathUserIndex();for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==h.n;t=this.m_shape.getNextPath(t))this.m_shape.setPathUserIndex(t,this.m_pathOrientationIndex,0),this.m_shape.setPathUserIndex(t,this.m_pathParentageIndex,-1),this.m_shape.setPathUserIndex(t,this.m_pathParentsIndex,-1);const n=[];this.m_yScanline=Number.NaN;const r=l.P.getNAN();this.m_unknownRingOrientationCount=this.m_shape.getPathCount(this.m_geometry),this.m_node1UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node1UserIndex,-1),this.m_node2UserIndex=this.m_shape.createUserIndexUninitialized(),this.m_shape.fillUserIndexForGeometry(this.m_geometry,this.m_node2UserIndex,-1);const o=new w(this);for(let t=o.next();t!==h.n&&(this.progress_(),this.m_shape.queryXY(t,r),r.y!==this.m_yScanline&&n.length&&(s=this.processBunchForRingOrientationTest_(n)||s,this.m_sweepComparator.reset(),n.length=0),n.push(t),this.m_yScanline=r.y,0!==this.m_unknownRingOrientationCount);t=o.next());return this.m_unknownRingOrientationCount>0&&(s=this.processBunchForRingOrientationTest_(n)||s,n.length=0),this.m_shape.removeUserIndex(this.m_node1UserIndex),this.m_shape.removeUserIndex(this.m_node2UserIndex),this.dbgVerifyRingOrientation_(),s}catch(e){t.error=e,t.hasError=!0}finally{(0,u.c)(t)}}fixRingOrientationImplSimplify_(){const t=[];for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==h.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(e,this.m_pathOrientationIndex)){this.m_shape.setExterior(e,!0);for(let s=this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex);s!==h.n;){const i=this.m_shape.getPathUserIndex(s,this.m_pathParentageIndex);t.push(s),this.m_shape.setExterior(s,!1),this.m_shape.setPathUserIndex(s,this.m_pathParentageIndex,e),s=i}let s=e,i=t.length;for(let t=this.m_shape.getNextPath(e);i>0&&t!==h.n;t=this.m_shape.getNextPath(t),--i){if(this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex)!==e){s=h.n;break}s=t}if(0!==i){s=e;for(let e=0,i=t.length;e<i;e++){const i=t[e];this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,h.t),this.m_shape.movePath(this.m_geometry,this.m_shape.getNextPath(s),i),s=i}}t.length=0,e=this.m_shape.getNextPath(s)}else e=this.m_shape.getNextPath(e);this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex)}fixRingOrientationImplMp2sp_(){const t=this.m_shape.createPathUserIndex();let e=0;const s=[];for(let i=this.m_shape.getFirstPath(this.m_geometry);i!==h.n;)if(this.progress_(),3===this.m_shape.getPathUserIndex(i,this.m_pathOrientationIndex)){this.m_shape.setExterior(i,!0),this.m_shape.setPathUserIndex(i,t,e),e++;for(let t=this.m_shape.getPathUserIndex(i,this.m_pathParentageIndex);t!==h.n;){const e=this.m_shape.getPathUserIndex(t,this.m_pathParentageIndex);s.push(t),this.m_shape.setExterior(t,!1),this.m_shape.setPathUserIndex(t,this.m_pathParentageIndex,i),t=e}let n=i,r=s.length,o=e;for(let e=this.m_shape.getNextPath(i);r>0&&e!==h.n;e=this.m_shape.getNextPath(e),--r){if(this.m_shape.getPathUserIndex(e,this.m_pathParentageIndex)!==i){n=h.n;break}n=e,this.m_shape.setPathUserIndex(e,t,-o),o++}if(0!==r){n=i,o=e;for(let e=0,i=s.length;e<i;e++){const i=s[e];this.m_shape.setPathUserIndex(i,t,-o),o++,this.m_shape.setPathUserIndex(i,this.m_pathParentageIndex,h.t)}n=i}e=o,s.length=0,i=this.m_shape.getNextPath(n)}else i=this.m_shape.getNextPath(i);return this.m_shape.removePathUserIndex(this.m_pathOrientationIndex),this.m_shape.removePathUserIndex(this.m_pathParentageIndex),this.m_shape.removePathUserIndex(this.m_pathParentsIndex),t}}function T(t,e,s,i,n,r){const o=new N(r);return o.m_shape=t,o.m_geometry=e,o.m_knownSimpleResult=s,o.m_bFixSelfTangency=i,o.m_polylineDegeneracies=n,o.m_bHasSegmentParentage=t.hasSegmentParentage(),o.m_bHasSegments=t.hasCurves(),o.simplify_()}class N{constructor(t){this.m_shape=null,this.m_geometry=h.n,this.m_sortedVertices=new h.I,this.m_bunchEdgeEndPoints=[],this.m_bunchEdgeCenterPoints=[],this.m_bunchEdgeIndices=[],this.m_knownSimpleResult=-1,this.m_sortedVerticesListIndex=-1,this.m_polylineDegeneracies=h.n,this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=-1,this.m_progressCounter=0,this.m_bFixSelfTangency=!1,this.m_bHasSegmentParentage=!1,this.m_bHasSegments=!1,this.m_progressTracker=t}compareAngles_(t,e){if(this.m_bHasSegments)return this.compareAnglesCurves_(t,e);const s=this.m_bunchEdgeEndPoints[t],i=new l.P;this.m_shape.queryXY(s,i);const n=new l.P,r=this.m_bunchEdgeEndPoints[e];if(this.m_shape.queryXY(r,n),i.equals(n))return 0;const o=this.m_bunchEdgeCenterPoints[t],h=new l.P;this.m_shape.queryXY(o,h);const m=this.m_bunchEdgeCenterPoints[e],u=new l.P;this.m_shape.queryXY(m,u);const c=new l.P;c.setSub(i,h);const g=new l.P;return g.setSub(n,u),(c.isZero()||g.isZero())&&(0,a.k)(""),l.P.compareVectors(c,g)}compareAnglesCurves_(t,e){const s=this.m_bunchEdgeEndPoints[t],i=this.m_bunchEdgeEndPoints[e],n=this.m_bunchEdgeCenterPoints[t],r=this.m_bunchEdgeCenterPoints[e],o=this.m_shape.getNextVertex(n)===s,m=this.m_shape.getNextVertex(r)===i,u=new h.S,c=new l.P;o?(this.m_shape.querySegment(n,u,!1,!0),c.assign(u.get().getTangent(0))):(this.m_shape.querySegment(s,u,!1,!0),c.assign(u.get().getTangent(1)),c.negateThis());const g=new l.P;return m?(this.m_shape.querySegment(r,u,!1,!0),g.assign(u.get().getTangent(0))):(this.m_shape.querySegment(i,u,!1,!0),g.assign(u.get().getTangent(1)),g.negateThis()),(c.isZero()||g.isZero())&&(0,a.k)(""),l.P.compareVectors(c,g)}beforeRemoveVertex_(t,e){const s=this.m_shape.getUserIndex(t,this.m_userIndexSortedIndexToVertex);if(this.m_nextVertexToProcess===s&&(this.m_nextVertexToProcess=this.m_sortedVertices.getNext(this.m_nextVertexToProcess)),this.m_firstCoincidentVertex===s&&(this.m_firstCoincidentVertex=this.m_sortedVertices.getNext(this.m_firstCoincidentVertex)),this.m_sortedVertices.deleteElement(this.m_sortedVerticesListIndex,s),this.removeAngleSortInfo_(t),e){const e=this.m_shape.getPathFromVertex(t);if(e!==h.n&&this.m_shape.getFirstVertex(e)===t){const s=this.m_shape.getNextVertex(t);if(s!==t){if(this.m_shape.getPathFromVertex(s)===e)return void this.m_shape.setFirstVertex(e,s);{const s=this.m_shape.getPrevVertex(t);if(s!==t&&this.m_shape.getPathFromVertex(s)===e)return void this.m_shape.setFirstVertex(e,s)}}this.m_shape.setFirstVertex(e,h.n),this.m_shape.setLastVertex(e,h.n)}}}processBunch_(){let t=!1;const e=new l.P(0,0);for(;;){this.m_bunchEdgeEndPoints.length=0,this.m_bunchEdgeCenterPoints.length=0,this.m_bunchEdgeIndices.length=0;let s=this.m_firstCoincidentVertex,i=0,n=!0;for(;s!==this.m_nextVertexToProcess;){const t=this.m_sortedVertices.getData(s);n&&(this.m_shape.queryXY(t,e),n=!1);const r=this.m_shape.getPrevVertex(t),o=this.m_shape.getNextVertex(t);this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex)!==h.t&&(this.m_bunchEdgeEndPoints.push(r),this.m_shape.setUserIndex(r,this.m_userIndexSortedAngleIndexToVertex,h.t),this.m_bunchEdgeCenterPoints.push(t),this.m_bunchEdgeIndices.push(i++)),this.m_shape.getUserIndex(o,this.m_userIndexSortedAngleIndexToVertex)!==h.t&&(this.m_bunchEdgeEndPoints.push(o),this.m_shape.setUserIndex(o,this.m_userIndexSortedAngleIndexToVertex,h.t),this.m_bunchEdgeCenterPoints.push(t),this.m_bunchEdgeIndices.push(i++)),s=this.m_sortedVertices.getNext(s)}if(this.m_bunchEdgeEndPoints.length<2){1===this.m_bunchEdgeEndPoints.length&&this.m_shape.setUserIndex(this.m_bunchEdgeEndPoints[0],this.m_userIndexSortedAngleIndexToVertex,-1);break}this.m_bunchEdgeIndices.sort(((t,e)=>this.compareAngles_(t,e)));for(let t=0,e=this.m_bunchEdgeIndices.length;t<e;t++){const e=this.m_bunchEdgeIndices[t],s=this.m_bunchEdgeEndPoints[e];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,t)}const r=this.processCrossOvers_(e);for(let t=0,e=this.m_bunchEdgeIndices.length;t<e;t++){const e=this.m_bunchEdgeIndices[t];if(-1===e)continue;const s=this.m_bunchEdgeEndPoints[e];this.m_shape.setUserIndex(s,this.m_userIndexSortedAngleIndexToVertex,-1)}if(!r)break;t=!0}return t}processCrossOvers_(t){let e=!1,s=!0;for(;s;){s=!1;let i=0;-1===this.m_bunchEdgeIndices[i]&&(i=this.getNextEdgeIndex_(i));let n=this.getNextEdgeIndex_(i);for(let r=0,o=this.m_bunchEdgeIndices.length;r<o&&-1!==i&&-1!==n&&i!==n;r++){const r=this.m_bunchEdgeIndices[i],o=this.m_bunchEdgeIndices[n],a=this.m_bunchEdgeEndPoints[r],h=this.m_bunchEdgeEndPoints[o];let m=this.m_shape.getNextVertex(a),l=!1;this.m_shape.isEqualXYPoint2D(m,t)||(m=this.m_shape.getPrevVertex(a),l=!0);let u=this.m_shape.getNextVertex(h),c=!1;this.m_shape.isEqualXYPoint2D(u,t)||(u=this.m_shape.getPrevVertex(h),c=!0);const g=l?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=c?this.m_shape.getPrevVertex(u):this.m_shape.getNextVertex(u);let d=!1;(this.removeSpike_(m)||this.removeSpike_(u)||this.removeSpike_(a)||this.removeSpike_(h)||this.removeSpike_(g)||this.removeSpike_(_))&&(d=!0),m!==u&&(!d&&this.m_shape.isEqualXY(a,h)&&(d=this.resolveOverlap_(l,c,m,a,u,h)),!d&&this.m_shape.isEqualXY(g,_)&&(d=this.resolveOverlap_(!l,!c,m,g,u,_)),!d&&this.m_shape.isEqualXY(a,_)&&(d=this.resolveOverlap_(l,!c,m,a,u,_)),!d&&this.m_shape.isEqualXY(g,h)&&(d=this.resolveOverlap_(!l,c,m,g,u,h))),d&&(e=!0),s||=d,i=d?this.getNextEdgeIndex_(i):n,n=this.getNextEdgeIndex_(i)}}if(!e){let s=0;-1===this.m_bunchEdgeIndices[s]&&(s=this.getNextEdgeIndex_(s));let i=this.getNextEdgeIndex_(s);for(let n=0,r=this.m_bunchEdgeIndices.length;n<r&&-1!==s&&-1!==i&&s!==i;n++){const n=this.m_bunchEdgeIndices[s],r=this.m_bunchEdgeIndices[i],o=this.m_bunchEdgeEndPoints[n],a=this.m_bunchEdgeEndPoints[r];let h=this.m_shape.getNextVertex(o);this.m_shape.isEqualXYPoint2D(h,t)||(h=this.m_shape.getPrevVertex(o));let m=this.m_shape.getNextVertex(a);this.m_shape.isEqualXYPoint2D(m,t)||(m=this.m_shape.getPrevVertex(a));const l=this.getDirection_(h,o),u=this.getDirection_(m,a),c=l?this.m_shape.getPrevVertex(h):this.m_shape.getNextVertex(h),g=u?this.m_shape.getPrevVertex(m):this.m_shape.getNextVertex(m),_=this.detectAndResolveCrossOver_(l,u,o,h,c,a,m,g);1!==_?0===_?(s=this.getNextEdgeIndex_(s),i=this.getNextEdgeIndex_(s)):(s=this.getPrevEdgeIndex_(s),i=this.getNextEdgeIndex_(s)):e=!0}}return e}simplify_(){this.m_shape.getGeometryType(this.m_geometry)===a.G.enumPolygon&&1===this.m_shape.getFillRule(this.m_geometry)&&new O(this.m_progressTracker).planarSimplifyNoCrackingAndCluster(this.m_bFixSelfTangency,this.m_shape,this.m_geometry,0);let t=!1;this.m_userIndexSortedIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=-1,this.m_userIndexSortedAngleIndexToVertex=this.m_shape.createUserIndexUninitialized();const e=this.m_shape.getPointCount(this.m_geometry),s=new h.A(0);this.m_shape.dbgVerifyMonotone();for(let t=this.m_shape.getFirstPath(this.m_geometry);t!==h.n;t=this.m_shape.getNextPath(t)){let e=this.m_shape.getFirstVertex(t);for(let i=0,n=this.m_shape.getPathSize(t);i<n;i++)this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,-1),s.add(e),e=this.m_shape.getNextVertex(e)}this.m_shape.sortVerticesSimpleByY(s,0,e),this.progress_(!0),this.m_userIndexSortedIndexToVertex=this.m_shape.createUserIndexUninitialized(),this.m_sortedVertices.reserveNodes(e),this.m_sortedVerticesListIndex=this.m_sortedVertices.createList(0);for(let t=0;t<e;t++){const e=s.read(t),i=this.m_sortedVertices.addElement(this.m_sortedVerticesListIndex,e);this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,i)}this.m_nextVertexToProcess=-1,this.cleanupSpikes_()&&(t=!0);let i=0,n=!1;do{n=!1,this.m_nextVertexToProcess=-1,this.m_firstCoincidentVertex=this.m_sortedVertices.getFirst(this.m_sortedVerticesListIndex);const e=new l.P(0,0);this.m_firstCoincidentVertex!==h.I.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(this.m_firstCoincidentVertex),e);let s=0,r=this.m_firstCoincidentVertex;for(;r!==h.I.st_nullNode()&&(r=this.m_sortedVertices.getNext(r),r!==h.I.st_nullNode());){this.progress_();const t=this.m_sortedVertices.getData(r),i=l.P.getNAN();if(this.m_shape.queryXY(t,i),e.equals(i))s++;else{if(s>0){this.m_nextVertexToProcess=r;const t=this.processBunch_();r=this.m_nextVertexToProcess,r!==h.I.st_nullNode()&&this.m_shape.queryXY(this.m_sortedVertices.getData(r),i),t&&(n=!0)}e.setCoordsPoint2D(i),this.m_firstCoincidentVertex=r,s=0}}this.m_nextVertexToProcess=-1,s>0&&this.processBunch_()&&(n=!0),i++>10&&(0,a.b)(""),n&&this.fixOrphanVertices_(),this.cleanupSpikes_()&&(n=!0),t||=n}while(n);return this.m_shape.dbgVerifyMonotone(),this.m_shape.dbgVerifyCurves(),this.m_shape.removeUserIndex(this.m_userIndexSortedIndexToVertex),this.m_shape.removeUserIndex(this.m_userIndexSortedAngleIndexToVertex),t=function(t,e,s,i,n){const r=new D(n);return r.m_shape=t,r.m_geometry=e,r.m_sortedVertices=s,r.m_bFixSelfTangency=i,r.fixRingOrientation_()}(this.m_shape,this.m_geometry,this.m_sortedVertices,this.m_bFixSelfTangency,this.m_progressTracker)||t,this.m_shape.dbgVerifyCurves(),t}getDirection_(t,e){return this.m_shape.getNextVertex(e)!==t}detectAndResolveCrossOver_(t,e,s,i,n,r,o,a){if(i===o)return this.removeAngleSortInfo_(s),this.removeAngleSortInfo_(r),-1;const h=this.m_shape.getUserIndex(s,this.m_userIndexSortedAngleIndexToVertex),m=this.m_shape.getUserIndex(n,this.m_userIndexSortedAngleIndexToVertex),u=this.m_shape.getUserIndex(r,this.m_userIndexSortedAngleIndexToVertex),c=this.m_shape.getUserIndex(a,this.m_userIndexSortedAngleIndexToVertex),g=new Array(8),_=new Array(4);g[0]=0,_[0]=h,g[1]=0,_[1]=m,g[2]=1,_[2]=u,g[3]=1,_[3]=c;for(let t=1;t<4;t++){const e=_[t],s=g[t];let i=t-1;for(;i>=0&&_[i]>e;)_[i+1]=_[i],g[i+1]=g[i],i--;_[i+1]=e,g[i+1]=s}let d=0;if(g[0]&&(d|=1),g[1]&&(d|=2),g[2]&&(d|=4),g[3]&&(d|=8),5!==d&&10!==d)return 0;if(t!==e&&(a=(0,l.b)(r,r=a)),t)this.m_shape.setNextVertex(a,i),this.m_shape.setPrevVertex(i,a),this.m_shape.setNextVertex(n,o),this.m_shape.setPrevVertex(o,n),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(o,!0));else{if(this.m_shape.setPrevVertex(a,i),this.m_shape.setNextVertex(i,a),this.m_shape.setPrevVertex(n,o),this.m_shape.setNextVertex(o,n),this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(i),e=this.m_shape.getSegmentParentage(o);this.m_shape.setSegmentParentageAndBreak(i,e,!0),this.m_shape.setSegmentParentageAndBreak(o,t,!0)}if(this.m_bHasSegments){const t=this.m_shape.getVertexIndex(i),e=this.m_shape.getVertexIndex(o),s=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null);const n=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null),this.m_shape.setSegmentToIndex(t,n),this.m_shape.setSegmentToIndex(e,s)}}return 1}resolveOverlap_(t,e,s,i,n,r){return this.resolveOverlapOddEven_(t,e,s,i,n,r)}resolveOverlapOddEven_(t,e,s,i,n,r){if(t!==e){t||(n=(0,l.b)(s,s=n),r=(0,l.b)(i,i=r));const e=this.m_shape.getNextVertex(n),o=this.m_shape.getNextVertex(s);if(this.m_shape.setNextVertex(s,e),this.m_shape.setPrevVertex(e,s),this.m_shape.setNextVertex(n,o),this.m_shape.setPrevVertex(o,n),this.m_bHasSegments){const t=this.m_shape.getVertexIndex(s),e=this.m_shape.getVertexIndex(n),i=this.m_shape.getSegmentFromIndex(t);this.m_shape.setSegmentToIndex(t,null);const r=this.m_shape.getSegmentFromIndex(e);this.m_shape.setSegmentToIndex(e,null),this.m_shape.setSegmentToIndex(t,r),this.m_shape.setSegmentToIndex(e,i)}if(this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(s),e=this.m_shape.getSegmentParentage(n);this.m_shape.setSegmentParentageAndBreak(s,e,!0),this.m_shape.setSegmentParentageAndBreak(n,t,!0),this.m_shape.setSegmentParentageBreakVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(r,!0)}this.removeSpike_(n)}else{const o=t?s:i,a=e?n:r,h=t?i:s,m=e?r:n;let l=null;if(this.m_bHasSegments){const t=this.m_shape.getVertexIndex(m);l=this.m_shape.getSegmentFromIndex(t),this.m_shape.setSegmentToIndex(t,null);const e=this.m_shape.getVertexIndex(a);this.m_shape.setSegmentToIndex(e,null);const s=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(s,null)}let u=-1;this.m_bHasSegmentParentage&&(u=this.m_shape.getSegmentParentage(m));let c=!1;this.m_shape.setNextVertex(o,a),this.m_shape.setNextVertex(a,o),this.m_shape.setPrevVertex(h,m),this.m_shape.setPrevVertex(m,h);let g=m;for(;g!==a;){const t=this.m_shape.getPrevVertex(g),e=this.m_shape.getNextVertex(g);if(this.m_shape.setPrevVertex(g,e),this.m_shape.setNextVertex(g,t),c||=g===o,this.m_bHasSegments&&g!==o){const t=this.m_shape.getVertexIndex(e),s=l;l=this.m_shape.getSegmentFromIndex(t),null!==s&&s.reverse(),this.m_shape.setSegmentToIndex(t,s)}if(this.m_bHasSegmentParentage){const t=this.m_shape.getSegmentParentage(e);this.m_shape.setSegmentParentagePreserveBreak(e,u),u=t}g=e}let _=null;if(!c){const t=this.m_shape.getPrevVertex(a),e=this.m_shape.getNextVertex(a);if(this.m_shape.setPrevVertex(a,e),this.m_shape.setNextVertex(a,t),this.m_bHasSegments){const t=this.m_shape.getVertexIndex(a);_=this.m_shape.getSegmentFromIndex(t),this.m_shape.setSegmentToIndex(t,null)}}let d=-1,p=-1;if(this.m_bHasSegmentParentage&&(d=c?this.m_shape.getSegmentParentage(o):this.m_shape.getSegmentParentage(a),p=this.m_shape.getSegmentParentage(h)),this.transferVertexData_(a,o),this.beforeRemoveVertex_(a,!0),this.m_shape.removeVertexInternal(a,!0),this.removeAngleSortInfo_(o),this.transferVertexData_(m,h),this.beforeRemoveVertex_(m,!0),this.m_shape.removeVertexInternal(m,!0),this.removeAngleSortInfo_(h),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageAndBreak(o,d,!0),this.m_shape.setSegmentParentageAndBreak(h,p,!0)),_){const t=this.m_shape.getVertexIndex(o);this.m_shape.setSegmentToIndex(t,_)}}return!0}cleanupSpikes_(){let t=!1;for(let e=this.m_shape.getFirstPath(this.m_geometry);e!==h.n;){const s=this.m_shape.getNextPath(e);let i=this.m_shape.getFirstVertex(e);for(let s=0,n=this.m_shape.getPathSize(e);s<n&&n>1;){this.progress_();const{v:r,bModified:o}=this.checkAndCleanupSpike_(e,i);if(r===h.n)break;o?(t=!0,i=r,s=0,n=this.m_shape.getPathSize(e)):(i=r,s++)}e=s}return t}checkAndCleanupSpike_(t,e){const s={v:h.n,bModified:!1};let i=this.m_shape.getPrevVertex(e),n=this.m_shape.getNextVertex(e),r=h.n,o=h.n;for(;this.m_shape.isEqualXY(i,n)&&(r=i,o=n,n!==e);)i=this.m_shape.getPrevVertex(i),n=this.m_shape.getNextVertex(n);if(r===h.n)return s.v=n,s;s.bModified=!0;for(let t=this.m_shape.getNextVertex(r);this.beforeRemoveVertex_(t,!1),t!==o;t=this.m_shape.getNextVertex(t));if(r===e)return this.m_polylineDegeneracies!==h.n?this.m_shape.movePath(this.m_polylineDegeneracies,h.n,t):this.m_shape.removePath(t),s.v=h.n,s;{const t=this.m_shape.peelALoopIntoAPath(r,o);this.m_polylineDegeneracies!==h.n?this.m_shape.movePath(this.m_polylineDegeneracies,h.n,t):this.m_shape.removePath(t)}return s.v=r,s}removeSpike_(t){let e=this.m_shape.getPrevVertex(t),s=this.m_shape.getNextVertex(t),i=h.n,n=h.n;for(;this.m_shape.isEqualXY(e,s)&&(i=e,n=s,s!==t);)e=this.m_shape.getPrevVertex(e),s=this.m_shape.getNextVertex(s);if(i===h.n)return!1;if(this.m_shape.peelALoop(i,n),this.m_bHasSegmentParentage&&(this.m_shape.setSegmentParentageBreakVertex(i,!0),this.m_shape.setSegmentParentageBreakVertex(n,!0)),this.removeAngleSortInfo_(i),this.m_polylineDegeneracies===h.n)for(let t=this.m_shape.getNextVertex(n);;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!0),this.m_shape.setSegmentToIndex(this.m_shape.getVertexIndex(t),null),this.m_shape.removeVertexInternal(t,!1),t===n)break;t=e}else{for(let t=n;;){const e=this.m_shape.getNextVertex(t);if(this.removeAngleSortInfo_(t),this.beforeRemoveVertex_(t,!1),t=e,t===n)break}const t=[!1];this.m_shape.insertClosedPath(this.m_polylineDegeneracies,h.n,n,n,t)}return!0}fixOrphanVertices_(){let t=0;for(let t=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==t;t=this.m_sortedVertices.getNext(t)){const e=this.m_sortedVertices.getData(t);this.m_shape.setPathToVertex(e,h.n)}let e=0;for(let s=this.m_shape.getFirstPath(this.m_geometry);s!==h.n;){const i=this.m_shape.getFirstVertex(s);if(i===h.n||this.m_shape.getPathFromVertex(i)!==h.n){const t=s;s=this.m_shape.getNextPath(s),this.m_shape.removePathOnly(t);continue}this.m_shape.setPathToVertex(i,s);let n=1;for(let t=this.m_shape.getNextVertex(i);t!==i;t=this.m_shape.getNextVertex(t))this.m_shape.setPathToVertex(t,s),n++;this.m_shape.setRingAreaValid(s,!1),this.m_shape.setPathSize(s,n),this.m_shape.setLastVertex(s,this.m_shape.getPrevVertex(i)),e+=n,t++,s=this.m_shape.getNextPath(s)}for(let s=this.m_sortedVertices.getFirst(this.m_sortedVertices.getFirstList());-1!==s;s=this.m_sortedVertices.getNext(s)){const i=this.m_sortedVertices.getData(s);if(this.m_shape.getPathFromVertex(i)!==h.n)continue;const n=[!1],r=this.m_shape.insertClosedPath(this.m_geometry,h.n,i,i,n);e+=this.m_shape.getPathSize(r),t++}this.m_shape.setGeometryPathCount(this.m_geometry,t),this.m_shape.setGeometryVertexCount(this.m_geometry,e);let s=0;for(let t=this.m_shape.getFirstGeometry();t!==h.n;t=this.m_shape.getNextGeometry(t))s+=this.m_shape.getPointCount(t);this.m_shape.setTotalPointCount(s)}getNextEdgeIndex_(t){if(-1===t)return-1;for(let e=0,s=this.m_bunchEdgeIndices.length-1;e<s;e++)if(t=(t+1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[t])return t;return-1}getPrevEdgeIndex_(t){if(-1===t)return-1;for(let e=0,s=this.m_bunchEdgeIndices.length-1;e<s;e++)if(t=(this.m_bunchEdgeIndices.length+t-1)%this.m_bunchEdgeIndices.length,-1!==this.m_bunchEdgeIndices[t])return t;return-1}transferVertexData_(t,e){const s=this.m_shape.getUserIndex(e,this.m_userIndexSortedIndexToVertex),i=this.m_shape.getUserIndex(e,this.m_userIndexSortedAngleIndexToVertex);this.m_shape.transferAllDataToTheVertex(t,e),this.m_shape.setUserIndex(e,this.m_userIndexSortedIndexToVertex,s),this.m_shape.setUserIndex(e,this.m_userIndexSortedAngleIndexToVertex,i)}removeAngleSortInfo_(t){const e=this.m_shape.getUserIndex(t,this.m_userIndexSortedAngleIndexToVertex);-1!==e&&(this.m_bunchEdgeIndices[e]=-1,this.m_shape.setUserIndex(t,this.m_userIndexSortedAngleIndexToVertex,-1))}progress_(t=!1){}}var A=a.f,M=a.e,G=a.d;function q(t){switch(t){case 1:return 1;case 2:return 2;case 3:return 3;case 4:return 4;case 0:return 0;default:(0,a.g)(0,"unrecognized cut side")}return 3}function F(t,e,s,i,n,r,o){const m=new O(n);m.m_bOGCOutput=!0;const l=t.getGeometryType()===a.G.enumPolygon&&1===t.getFillRule()&&!(0,h.o)(i);return m.planarSimplifyImpl_(t,e,l,s,i,n,r,o)}function V(t,e,s,i,n,r,o,a){return new O(r).planarSimplifyImpl_(t,e,s,i,n,r,o,a)}function R(t,e,s){return function(t,e,s){const i=t.createInstance(),n=(0,l.m)(l.P,100),r=new Array(100),o=t.getPointCount();let h=!0;const u=2===e.getDimension();1!==e.getDimension()&&2!==e.getDimension()&&(0,a.b)("");for(let a=0;a<o;){const o=t.queryCoordinates(n,n.length,a,-1)-a;u?(0,m.t)(e,n,o,s.total(),r):(0,m.l)(e,n,o,s.total(),r);let l=0;for(let e=0;e<o;e++)0===r[e]&&(h&&(h=!1,i.addPoints(t,0,a)),l!==e&&i.addPoints(t,a+l,a+e),l=e+1);h||l===o||i.addPoints(t,a+l,a+o),a+=o}return h?t:i}(t,e,s)}function Y(t,e,s,i){if(t.isEmpty()||e.isEmpty()||t.getDimension()>e.getDimension())return W(j(t),t,0,"-");const n=new h.a;t.queryEnvelope(n);const r=new h.a;e.queryEnvelope(r);const o=new h.a;o.setCoords({env2D:n}),o.mergeEnvelope2D(r);const l=(0,h.b)(s,o,!0),u=r.clone(),c=(0,h.l)(l);if(u.inflateCoords(c,c),!n.isIntersecting(u))return W(j(t),t,0,"-");const g=new O(i),_=new h.d,d=_.addGeometry(j(t)),p=_.addGeometry(j(e));let f=0,x=0,y=null;if(_.hasCurves()){y=new m.C;const t=_.getEnvelope2D(i);x=(0,m.s)(l.total());const e=(0,m.d)(l.total(),t);f=(0,m.f)(e,x),(0,m.b)(_,e,l.total(),12e3,y,null,i)}g.setEditShapeCrackAndCluster(_,l.add(f));const P=g.difference(d,p);null!==y&&y.stitchCurves(_,P,x,!0);const E=W(_.getGeometry(P),t,0,"-");return A(E.getGeometryType())&&(E.getImpl().setIsSimple(4,l.total()),E.getGeometryType()===a.G.enumPolygon&&E.getImpl().updateOGCFlagsProtected()),E}function X(t,e,s,i){if(t.getDimension()>e.getDimension())return W(j(t),t,0,"^");if(t.getDimension()<e.getDimension())return W(j(e),t,0,"^");if(t.isEmpty())return W(j(e),t,0,"^");if(e.isEmpty())return W(j(t),t,0,"^");const n=new h.a;t.queryEnvelope(n);const r=new h.a;e.queryEnvelope(r);const o=new h.a;o.setCoords({env2D:n}),o.mergeEnvelope2D(r);const l=(0,h.b)(s,o,!0),u=new O(i),c=new h.d,g=c.addGeometry(j(t)),_=c.addGeometry(j(e));let d=0,p=null;if(c.hasCurves()){p=new m.C;const t=c.getEnvelope2D(i);d=(0,m.s)(l.total());const e=(0,m.d)(l.total(),t);(0,m.b)(c,e,l.total(),12e3,p,null,i)}u.setEditShapeCrackAndCluster(c,l);const f=u.symmetricDifference(g,_);null!==p&&p.stitchCurves(c,f,d,!0);const x=W(c.getGeometry(f),t,0,"^");return A(x.getGeometryType())&&(x.getImpl().setIsSimple(4,l.total()),x.getGeometryType()===a.G.enumPolygon&&x.getImpl().updateOGCFlagsProtected()),x}function k(t,e,s){return function(t,e,s){if(t.isEmpty())return t.createInstance();if(e.isEmpty())return t.createInstance();const i=[new l.P],n=[0],r=2===e.getDimension();1!==e.getDimension()&&2!==e.getDimension()&&(0,a.b)(""),i[0]=t.getXY(),r?(0,m.t)(e,i,1,s.total(),n):(0,m.l)(e,i,1,s.total(),n);let o=0===n[0];return o?t.createInstance():t}(t,e,s)}function H(t,e,s){return t.isEmpty()||e.isEmpty()?t.createInstance():(0,m.j)(s,t,e)?new h.P({copy:(0,m.k)(t,e)}):t.createInstance()}function B(t,e,s,i){const n=h.a.constructEmpty();t.queryEnvelope(n);const r=h.a.constructEmpty();e.queryEnvelope(r);const o=h.a.constructEmpty();o.setCoords({env2D:n}),o.mergeEnvelope2D(r);const l=(0,h.b)(s,o,!0),u=new h.a(r),c=(0,h.l)(l);if(u.inflateCoords(c,c),!n.isIntersecting(u)){if(t.getDimension()<=e.getDimension())return W(j(t.createInstance()),t,0,"&");if(t.getDimension()>e.getDimension())return W(j(e.createInstance()),t,0,"&")}const g=new O(i),_=new h.d,d=_.addGeometry(j(t)),p=_.addGeometry(j(e));let f=0,x=0,y=null;if(_.hasCurves()){y=new m.C;const t=_.getEnvelope2D(i);x=(0,m.s)(l.total());const e=(0,m.d)(l.total(),t);f=(0,m.f)(e,x),(0,m.b)(_,e,l.total(),12e3,y,null,i)}g.setEditShapeCrackAndCluster(_,l.add(f));const P=g.intersection(d,p);null!==y&&y.stitchCurves(_,P,x,!0);const E=W(_.getGeometry(P),t,0,"&");return A(E.getGeometryType())&&(E.getImpl().setIsSimple(4,l.total()),E.getGeometryType()===a.G.enumPolygon&&E.getImpl().updateOGCFlagsProtected()),E}function L(t,e,s,i){const n=new Array(3),r=h.a.constructEmpty();t.queryEnvelope(r);const o=h.a.constructEmpty();e.queryEnvelope(o);const l=h.a.constructEmpty();l.setCoords({env2D:r}),l.mergeEnvelope2D(o);const u=(0,h.b)(s,l,!0),c=new h.a(o),g=(0,h.l)(u);if(c.inflateCoords(g,g),!r.isIntersecting(c)){if(t.getDimension()<=e.getDimension()){const e=W(j(t.createInstance()),t,0,"&");return n[e.getDimension()]=e,n}if(t.getDimension()>e.getDimension()){const s=W(j(e.createInstance()),t,0,"&");return n[s.getDimension()]=s,n}}const _=new O(i),d=new h.d,p=d.addGeometry(j(t)),f=d.addGeometry(j(e));let x=0,y=0,P=null;if(d.hasCurves()){P=new m.C;const t=d.getEnvelope2D(i);y=(0,m.s)(u.total());const e=(0,m.d)(u.total(),t);x=(0,m.f)(e,y),(0,m.b)(d,e,u.total(),12e3,P,null,i)}_.setEditShapeCrackAndCluster(d,u.add(x)),d.dbgVerifyCurves();const E=_.intersectionEx(p,f);for(const e of E){null!==P&&P.stitchCurves(d,e,y,!1);const s=W(d.getGeometry(e),t,0,"&");A(s.getGeometryType())&&(s.getImpl().setIsSimple(4,u.total()),s.getGeometryType()===a.G.enumPolygon&&s.getImpl().updateOGCFlagsProtected()),n[s.getDimension()]=s}return null!==P&&P.clearStitcher(d),n}function z(t,e,s,i,n,r=!1){0===e&&(0,a.t)("not enough geometries to dissolve");let o=0;for(let s=0,i=e;s<i;s++)o=Math.max(t[s].getDimension(),o);if(2===o||1===o)return new O(i).dissolveMultiPaths_(o,!1,t,e,s,n,r);let m=0,l=-1;for(let s=0,i=e;s<i;s++)t[s].getDimension()===o&&(-1===l&&(l=s),t[s].isEmpty()||(l=s,m++));if(m<2)return j(t[l]);const u=h.f.constructEmpty(),c=new h.d;let g=h.n;for(let s=0,i=e;s<i;s++)if(t[s].getDimension()===o&&!t[s].isEmpty()){g===h.n?g=c.addGeometry(j(t[s])):c.appendGeometry(g,j(t[s]));const e=h.f.constructEmpty();t[s].queryLooseEnvelope(e),u.mergeEnv3D(e)}const _=(0,h.b)(s,u.getEnvelope2D(),!0),d=new O(i);if(r){const t=(0,h.g)(s,u.getEnvelopeZs(),!0);return d.planarSimplify3DImpl_(c,_,t,0,!0)}return d.m_bOGCOutput=!0,d.planarSimplifyMultiPoints(c,_,!1,-1)}function U(t,e,s,i,n,r=!1){e<2&&(0,a.t)("not enough geometries to dissolve");let o=0;for(let s=0,i=e;s<i;s++)o=Math.max(t[s].getDimension(),o);if(2===o||1===o)return new O(i).dissolveMultiPaths_(o,!0,t,e,s,n,r);const m=h.f.constructEmpty(),l=new h.d;let u=h.n,c=0,g=-1;for(let s=0,i=e;s<i;s++)if(t[s].getDimension()===o&&(-1===g&&(g=s),!t[s].isEmpty())){g=s,u===h.n?u=l.addGeometry(j(t[s])):l.appendGeometry(u,j(t[s]));const e=h.f.constructEmpty();t[s].queryLooseEnvelope(e),m.mergeEnv3D(e),c++}if(c<2)return j(t[g]);const _=0===o?s:null,d=(0,h.b)(_,m.getEnvelope2D(),!0),p=new O(i);if(r){const t=(0,h.g)(_,m.getEnvelopeZs(),!0);return p.m_bOGCOutput=!0,p.planarSimplify3DImpl_(l,d,t,0,!0)}return p.planarSimplifyMultiPoints(l,d,!0,-1)}class O{constructor(t){this.m_topoGraph=null,this.m_maskLookup=[],this.m_dummyPt1=l.P.getNAN(),this.m_dummyPt2=l.P.getNAN(),this.m_fromEdgeForPolylines=h.n,this.m_progressCounter=0,this.m_bOGCOutput=!1,this.m_progressTracker=t}linesToPolygonsImpl(t,e){let s=0,i=0,n=null;if(t.hasCurves()){n=new m.C;const r=t.getEnvelope2D(this.m_progressTracker);i=(0,m.s)(e.total());const o=(0,m.d)(e.total(),r);s=(0,m.f)(o,i),(0,m.b)(t,o,e.total(),12e3,n,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(t,e.add(s));const r=this.m_topoGraph.createUserIndexForChains(),a=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(a,r,1);for(let t=this.m_topoGraph.getChainFirstIsland(a);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,r,1);const l=[];for(let e=this.m_topoGraph.getFirstChain();e!==h.n;e=this.m_topoGraph.getChainNext(e)){if(1===this.m_topoGraph.getChainUserIndex(e,r))continue;this.m_topoGraph.setChainUserIndex(e,r,1);for(let t=this.m_topoGraph.getChainFirstIsland(e);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,r,1);if(0===this.m_topoGraph.getChainArea(e))continue;const s=this.m_topoGraph.extractPolygonFromChainAndIslands(t,h.n,e,h.n);null!=n&&n.stitchCurves(t,s,i,!1);const o=t.getGeometry(s);l.push(o)}return new o.S(l)}autoCompleteImpl(t,e,s){let i=0,n=0,r=null;if(t.hasCurves()){r=new m.C;const e=t.getEnvelope2D(this.m_progressTracker);n=(0,m.s)(s.total());const o=(0,m.d)(s.total(),e);i=(0,m.f)(o,n),(0,m.b)(t,o,s.total(),12e3,r,null,this.m_progressTracker)}this.setEditShapeCrackAndCluster(t,s.add(i));const a=this.m_topoGraph.getGeometryID(e),l=this.m_topoGraph.createUserIndexForChains(),u=this.m_topoGraph.getFirstChain();this.m_topoGraph.setChainUserIndex(u,l,1);for(let t=this.m_topoGraph.getChainFirstIsland(u);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,l,1);const c=[];for(let e=this.m_topoGraph.getFirstChain();e!==h.n;e=this.m_topoGraph.getChainNext(e)){if(1===this.m_topoGraph.getChainUserIndex(e,l))continue;this.m_topoGraph.setChainUserIndex(e,l,1);for(let t=this.m_topoGraph.getChainFirstIsland(e);t!==h.n;t=this.m_topoGraph.getChainNextInParent(t))this.m_topoGraph.setChainUserIndex(t,l,1);if(0!==this.m_topoGraph.getChainParentage(e))continue;const s=this.m_topoGraph.getChainHalfEdge(e);let i=s,o=!1;do{const t=this.m_topoGraph.getHalfEdgeTwin(i);if(this.m_topoGraph.getHalfEdgeChain(t)!==e&&this.m_topoGraph.getHalfEdgeParentage(i)&a){o=!0;break}i=this.m_topoGraph.getHalfEdgeNext(i)}while(i!==s);if(!o)continue;if(0===this.m_topoGraph.getChainArea(e))continue;const m=this.m_topoGraph.extractPolygonFromChainAndIslands(t,h.n,e,h.n);null!==r&&r.stitchCurves(t,m,n,!1);const u=t.getGeometry(m);c.push(u)}return new o.S(c)}setEditShape(t,e=!1){null===this.m_topoGraph&&(this.m_topoGraph=new C),this.m_topoGraph.setEditShape(t,this.m_progressTracker,!0,e)}setEditShapeCrackAndCluster(t,e){(0,m.e)(t,e,this.m_progressTracker,!0,!1);for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e))t.getGeometryType(e)===a.G.enumPolygon&&T(t,e,-1,this.m_bOGCOutput,h.n,this.m_progressTracker);this.setEditShape(t)}setHalfEdgeOrientations_(t,e){const s=this.m_topoGraph.getShape();for(let i=s.getFirstGeometry();i!==h.n;i=s.getNextGeometry(i))if(i===e)for(let e=s.getFirstPath(i);e!==h.n;e=s.getNextPath(e)){let i=s.getFirstVertex(e);if(i===h.n)continue;let n=s.getNextVertex(i);for(;n!==h.n;){const e=this.m_topoGraph.getClusterFromVertex(i),r=this.m_topoGraph.getClusterFromVertex(n),o=this.m_topoGraph.getHalfEdgeConnector(e,r);if(o!==h.n){const e=this.m_topoGraph.getHalfEdgeTwin(o);this.m_topoGraph.setHalfEdgeUserIndex(o,t,1),this.m_topoGraph.setHalfEdgeUserIndex(e,t,2)}i=n,n=s.getNextVertex(i)}}}flushVertices_(t,e){const s=this.m_topoGraph.getShape(),i=s.hasSegmentParentage(),n=new h.S,r=s.insertPath(t,h.n);e.push(e[0]);const o=e.length;let a=h.n;for(let t=0;t<o;t++){const h=e[t];if(a=s.addVertex(r,h),!i)continue;const m=this.m_topoGraph.getClusterFromVertex(h);if(t>0&&this.m_topoGraph.isBreakNode(m)&&s.setSegmentParentageBreakVertex(a,!0),t<o-1){const i=this.m_topoGraph.getHalfEdgeConnector(m,this.m_topoGraph.getClusterFromVertex(e[t+1])),r=this.m_topoGraph.getSegmentParentage(i);s.setSegmentParentageAndBreak(a,r,t>0||this.m_topoGraph.isBreakNode(m)),this.m_topoGraph.isHalfEdgeCurve(i)&&(this.m_topoGraph.querySegmentXY(i,n),s.setSegmentToIndex(s.getVertexIndex(a),n.get().clone()))}}if(i){const t=this.m_topoGraph.getClusterFromVertex(e[o-1]);this.m_topoGraph.isBreakNode(t)&&s.setSegmentParentageBreakVertex(a,!0)}s.setClosedPath(r,!0)}processPolygonCuts_(t,e,s,i){const n=this.m_topoGraph.getGeometryID(s),r=this.m_topoGraph.getGeometryID(i),o=[],m=this.m_topoGraph.getShape(),l=this.m_topoGraph.createUserIndexForHalfEdges();for(let s=this.m_topoGraph.getFirstCluster();s!==h.n;s=this.m_topoGraph.getNextCluster(s)){const i=this.m_topoGraph.getClusterHalfEdge(s);if(i===h.n)continue;let u=i;do{if(1!==this.m_topoGraph.getHalfEdgeUserIndex(u,l)){let s=u,i=u,h=!1,c=0;do{if(this.m_topoGraph.setHalfEdgeUserIndex(s,l,1),h||this.m_topoGraph.getHalfEdgeParentage(s)&r&&this.m_topoGraph.getHalfEdgeFaceParentage(s)&n&&(i=s,h=!0),h){const e=this.m_topoGraph.getHalfEdgeOrigin(s),i=this.m_topoGraph.getClusterVertexIterator(e),n=this.m_topoGraph.getVertexFromVertexIterator(i);o.push(n),-1!==t&&this.m_topoGraph.getHalfEdgeParentage(s)&r&&(c|=this.m_topoGraph.getHalfEdgeUserIndex(s,t))}s=this.m_topoGraph.getHalfEdgeNext(s)}while(s!==i);if(h&&this.m_topoGraph.getChainArea(this.m_topoGraph.getHalfEdgeChain(i))>0){const t=m.createGeometry(a.G.enumPolygon);this.flushVertices_(t,o),-1!==e&&m.setGeometryUserIndex(t,e,c)}o.length=0}u=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(u))}while(u!==i)}this.m_topoGraph.deleteUserIndexForHalfEdges(l)}cutPolygonPolyline_(t,e,s,i){this.m_topoGraph.removeSpikes_();let n=-1;-1!==t&&(n=this.m_topoGraph.createUserIndexForHalfEdges(),this.setHalfEdgeOrientations_(n,s)),this.processPolygonCuts_(n,t,e,s),-1!==n&&(this.m_topoGraph.deleteUserIndexForHalfEdges(n),n=-1);const r=this.m_topoGraph.getShape();for(let t=r.getFirstGeometry();t!==h.n;t=r.getNextGeometry(t))t!==e&&t!==s&&i.push(t);i.sort(((t,e)=>{const s=r.getFirstPath(t),i=r.getRingArea(s),n=r.getFirstPath(e),o=r.getRingArea(n);return i<o?-1:i>o?1:0}))}cut(t,e,s,i,n){const r=this.m_topoGraph.getShape().getGeometryType(s),o=this.m_topoGraph.getShape().getGeometryType(i),h=(0,a.d)(r),m=(0,a.d)(o);2!==h||1!==m?1!==h||1!==m?(0,a.b)(""):new Q(this,t,e,s,i,n).Do():this.cutPolygonPolyline_(e,s,i,n)}progress_(t=!1){}isGoodParentage(t){return t>=0&&t<this.m_maskLookup.length&&this.m_maskLookup[t]}normalizeInputGeometry(t){const e=t.getGeometryType();if(e===a.G.enumEnvelope){const e=new h.h({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(e===a.G.enumPoint){const e=new h.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if((0,a.e)(e)){const e=new h.i({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return e!==a.G.enumMultiPoint&&e!==a.G.enumPolyline&&e!==a.G.enumPolygon&&(0,a.t)("Unexpected geometry type"),t}dissolveNonSimplePolygons(t,e,s,i){(0,a.g)(e>0);const n=new h.d;let r=0,o=-1;for(let s=0,i=e;s<i;s++)2===t[s].getDimension()&&(-1===o&&(o=s),t[s].isEmpty()||(r++,n.addGeometry(t[s])));return 0===r?((0,a.g)(o>=0),this.normalizeInputGeometry(t[o])):this.planarSimplifyPolygons(n,s,!0,!1,-1,!0)}dissolveMultiPaths_(t,e,s,i,n,r,o){(0,a.g)(t>=1&&t<=2),(0,a.g)(i>0);const u=8&r?1:2,c=h.f.constructEmpty();let g=0,_=-1,d=!0;for(let e=0,n=i;e<n;e++)if(s[e].getDimension()===t&&(-1===_&&(_=e),!s[e].isEmpty())){_=e,g++;const i=h.f.constructEmpty();if(s[e].queryLooseEnvelope(i),c.mergeEnv3D(i),2===t&&d&&s[e].getGeometryType()===a.G.enumPolygon)if(16&r){const t=[0],i=s[e].getImpl().getIsSimple(0,t),n=this.m_bOGCOutput?5===i:(0,h.k)(i);d&&=n}else{const t=(0,h.j)(s[e],0);d&&=t}}if(g<2&&((0,a.g)(_>=0),0===g||!(16&r)))return this.normalizeInputGeometry(s[_]);if(!d){const t=(0,h.b)(e?null:n,c.getEnvelope2D(),!0);return this.dissolveNonSimplePolygons(s,i,t,r)}const p=s.slice(0,i),f=(0,h.b)(n,c.getEnvelope2D(),!0),x=10*(0,h.l)(f);let y=new h.C(0,0);if(o&&(y=(0,h.g)(n,c.getEnvelopeZs(),!0)),1===g&&1===t&&2===u&&!e)return o?((0,a.g)(0),{}):this.m_bOGCOutput?F(p[_],f,!1,-1,this.m_progressTracker,u,!1):V(p[_],f,!1,!1,-1,this.m_progressTracker,u,!1);const P=new h.m;P.startConstruction();let E=2===t?3:4,C=0;for(let s=0,n=i;s<n;s++){if(p[s].getDimension()!==t||p[s].isEmpty())continue;let i=p[s].getGeometryType();if(i!==a.G.enumEnvelope){if((0,a.e)(i)?(p[s]=this.normalizeInputGeometry(p[s]),i=a.G.enumPolyline):(0,a.g)((0,a.f)(i)),1===t){(0,a.g)(i===a.G.enumPolyline);let t=-1;if(o)(0,a.g)(0,"3d not implemented yet");else{const e=[0];t=p[s].getImpl().getIsSimple(f.total(),e)}if(this.m_bOGCOutput?5!==t:!(0,h.k)(t))if(e)E=-1;else{o?(0,a.g)(0,"3d not implemented yet"):this.m_bOGCOutput?p[s]=F(p[s],f,!1,-1,this.m_progressTracker,u,!1):p[s]=V(p[s],f,!1,!1,-1,this.m_progressTracker,u,!1);const t=[0];(0,a.g)((0,h.k)(p[s].getImpl().getIsSimple(f.total(),t)))}}else{(0,a.g)(i===a.G.enumPolygon);const t=[0],e=p[s].getImpl().getIsSimple(0,t);(0,a.g)((0,h.o)(e))}const n=p[s].getImpl();for(let t=0,e=n.getPathCount();t<e;t++){const e=h.a.constructEmpty();n.queryLoosePathEnvelope(t,e),e.inflateCoords(x,x),P.addEnvelope(C,e),C++}}else{(0,a.g)(i===a.G.enumEnvelope);const t=h.a.constructEmpty();p[s].queryLooseEnvelope(t),t.inflateCoords(x,x),P.addEnvelope(C,t),C++,E=-1}}P.endConstruction();const v=C,S=(0,l.a)(v,-2147483647),I=(0,l.a)(v,-1);let w=0;_=-1,C=0;for(let e=0,s=i;e<s;e++){if(p[e].getDimension()!==t)continue;if(-1===_&&(_=e),p[e].isEmpty())continue;_=e,w++;const s=p[e].getGeometryType();if((0,a.f)(s))for(let t=0,s=p[e].getPathCount();t<s;t++)I[C]=e,S[C]=-t-1,C++;else(0,a.g)(s===a.G.enumEnvelope),I[C]=e,S[C]=-1,C++}if(w<2&&2===t)return(0,a.g)(_>=0),this.normalizeInputGeometry(p[_]);let D=v;for(;P.next()&&D>0;){this.progress_();const t=P.getHandleA(),e=P.getHandleB(),s=P.getElement(t),i=P.getElement(e);I[s]!==I[i]&&(S[s]<0&&(D--,S[s]=-(S[s]+1)),S[i]<0&&(D--,S[i]=-(S[i]+1)))}const T=new h.d;let N,A=!1,M=0;for(let e=0,s=i;e<s;e++){if(p[e].getDimension()!==t||p[e].isEmpty())continue;const s=p[e].getGeometryType(),i=M;let n=0,r=0;const o=(0,a.f)(s)?p[e]:null;for(let t=i,s=S.length;t<s&&I[t]===e;t++)S[t]>=0&&(n++,r+=o?o.getPathSize(S[t]):(0,a.v)(p[e])),M++;if(r>.95*(0,a.v)(p[e])){T.addGeometry(this.normalizeInputGeometry(p[e]));for(let t=i;t<M;t++)S[t]<0&&(S[t]=-(S[t]+1))}else{if(0===n){A=!0;continue}{A=!0,(0,a.g)((0,a.f)(s)),(0,a.g)(null!=o);const t=new h.h({vd:p[e].getDescription()}),n=new h.i({vd:p[e].getDescription()}),r=s===a.G.enumPolygon?t:n;for(let t=i;t<M;t++)S[t]>=0&&r.addPath(o,S[t],!0);T.addGeometry(r)}}}if(T.getFirstGeometry()!==h.n){const s=2===t,i=e?(0,h.b)(null,c.getEnvelope2D(),!0):f;let n=new h.C(0,0);if(o&&(n=e?(0,h.g)(null,c.getEnvelopeZs(),!0):y),2===t&&!(2&r)){T.collapseAllGeometriesToFirst();let t=0,e=null;if(T.hasCurves()&&!T.hasSegmentParentage()){e=new m.C;const s=T.getEnvelope2D(this.m_progressTracker);t=(0,m.s)(i.total());const n=(0,m.d)(i.total(),s);(0,m.b)(T,n,i.total(),12e3,e,null,this.m_progressTracker)}(function(t,e,s,i){s>0&&(0,m.a)(t,s,e,!1,i),new b(i).executeImpl_(t,e)})(T,T.getFirstGeometry(),i.total(),this.m_progressTracker),null!==e&&e.stitchCurves(T,h.n,t,!0)}if(o)N=this.planarSimplify3DImpl_(T,i,n,u,!0);else if(2===t)N=this.planarSimplifyPolygons(T,i,s,e,-1,!1);else{const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};t.ogcRule=this.m_bOGCOutput,t.allCrossRoadsImpassable=!0,t.unsplitBehavior=u,N=this.planarSimplifyPolylines(T,i,e,t,-1)}if(!A){const t=[0];E=N.getImpl().getIsSimple(i.total(),t)}}else(0,a.g)(A),(0,a.g)(_>=0),N=2===t?new h.h({vd:p[_].getDescription()}):new h.i({vd:p[_].getDescription()});if(A){let t=0;for(let e=0,s=S.length;e<s;e++){const s=I[e];if(!(s<0)&&S[e]<0){const i=p[s].getGeometryType(),n=(0,a.f)(i)?p[s]:null;if(n){const s=-(S[e]+1);t+=n.getPathSize(s)}else t+=4}}N.reserve(N.getPointCount()+t);for(let t=0,e=S.length;t<e;t++){const e=I[t];if(!(e<0)&&S[t]<0){const s=p[e].getGeometryType(),i=(0,a.f)(s)?p[e]:null;if(i){const e=-(S[t]+1);N.addPath(i,e,!0)}else s===a.G.enumEnvelope?N.addEnvelope(p[e],!1):((0,a.g)((0,a.e)(s)),N.addSegment(p[e],!0))}}}let G=0;if(2===t?-1!==E&&(E=3,G=e?0:f.total()):((0,a.g)(1===t),e||-1===E||(G=f.total())),o||N.getImpl().setIsSimple(E,G),!e&&A)if(2===t){if(!o)return(new ut).execute(N,n,!1,this.m_progressTracker);(0,a.g)(0,"3d not yet implemented")}else 1===t&&1!==u&&(N=o?((0,a.g)(0),{}):function(t,e,s,i){const n=new O(i),r=new h.d,o=r.addGeometry(e),m=n.planarSimplifyNoCrackingAndCluster(t,r,o,s);return(0,a.g)(m,"planar_simplify_no_cracking_and_cluster"),r.getGeometry(o)}(this.m_bOGCOutput,N,u,this.m_progressTracker),N.getImpl().setIsSimple(E,G));return N}dissolveTopoGraphCommonEdges_(){const t=this.m_topoGraph.createUserIndexForHalfEdges(),e=[];for(let s=this.m_topoGraph.getFirstCluster();s!==h.n;s=this.m_topoGraph.getNextCluster(s)){const i=this.m_topoGraph.getClusterHalfEdge(s);let n=i;if(i!==h.n)do{if(this.progress_(),1!==this.m_topoGraph.getHalfEdgeUserIndex(n,t)){const s=this.m_topoGraph.getHalfEdgeTwin(n);this.m_topoGraph.setHalfEdgeUserIndex(s,t,1),this.m_topoGraph.setHalfEdgeUserIndex(n,t,1);const i=this.m_topoGraph.getHalfEdgeFaceParentage(n);if(this.isGoodParentage(i)){const t=this.m_topoGraph.getHalfEdgeFaceParentage(s);this.isGoodParentage(t)&&e.push(n)}}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==i)}this.m_topoGraph.deleteUserIndexForHalfEdges(t),this.m_topoGraph.deleteEdgesBreakFaces_(e)}chooseVertexByOrder(t,e,s,i){let n=(0,l.j)(),r=h.n;for(let i=this.m_topoGraph.getClusterVertexIterator(t);i!==h.n;i=this.m_topoGraph.incrementVertexIterator(i)){const t=this.m_topoGraph.getVertexFromVertexIterator(i),o=e.getUserIndex(t,s);o>=0&&o<n&&(n=o,r=t)}(0,a.g)(r!==h.n);let o=e.getUserIndex(r,i);return o>0&&(e.setUserIndex(r,i,--o),0===o&&e.setUserIndex(r,s,-1)),r}chooseVertexFromCluster_(t,e){return this.m_topoGraph.getVertexDominantFromCluster(t,e)}chooseVertexFromVertexCluster_(t,e){return this.m_topoGraph.getVertexDominant(t,e)}collectPolygonPathsPreservingFrom_(t,e,s,i,n){const r=this.m_topoGraph.getShape();if(r.getGeometryType(t)!==a.G.enumPolygon)return;const o=r.hasSegmentParentage(),m=new h.S;for(let a=r.getFirstPath(t);a!==h.n;a=r.getNextPath(a)){const t=r.getFirstVertex(a);this.m_topoGraph.getClusterFromVertex(t);const l=this.m_topoGraph.getHalfEdgeFromVertex(t);if(l===h.n)continue;const u=this.m_topoGraph.getHalfEdgeUserIndex(l,s);if(1===u||2===u)continue;const c=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(!this.isGoodParentage(c)){this.m_topoGraph.setHalfEdgeUserIndex(l,s,2);continue}this.m_topoGraph.setHalfEdgeUserIndex(l,s,1);const g=r.insertPath(e,h.n);r.setClosedPath(g,!0);let _=l,d=t,p=this.m_topoGraph.getClusterFromVertex(d),f=1;do{this.progress_();const t=this.chooseVertexFromVertexCluster_(d,n),e=r.addVertex(g,t);if(this.m_topoGraph.isHalfEdgeCurve(_)&&(this.m_topoGraph.querySegmentXY(_,m),r.setSegmentToIndex(r.getVertexIndex(e),m.get().clone())),o){const t=this.m_topoGraph.getSegmentParentage(_);r.setSegmentParentageAndBreak(e,t,this.m_topoGraph.isBreakNode(p))}let a,l;-1!==i&&this.m_topoGraph.setClusterUserIndex(p,i,1),this.m_topoGraph.setHalfEdgeUserIndex(_,s,1),_=this.m_topoGraph.getHalfEdgeNext(_);do{a=1===f?r.getNextVertex(d):r.getPrevVertex(d),l=a!==h.n?this.m_topoGraph.getClusterFromVertex(a):h.n}while(l===p);const u=this.m_topoGraph.getHalfEdgeOrigin(_);if(u!==l){do{a=1===f?r.getPrevVertex(d):r.getNextVertex(d),l=a!==h.n?this.m_topoGraph.getClusterFromVertex(a):h.n}while(l===p);if(u!==l){l=u;const t=this.m_topoGraph.getClusterVertexIterator(l);a=this.m_topoGraph.getVertexFromVertexIterator(t)}else f=-f}p=l,d=a}while(_!==l)}}topoOperationPolygonPolygonHelper_(t,e,s,i,n,r){this.progress_(!0),t!==h.n&&this.collectPolygonPathsPreservingFrom_(t,s,n,r,i),e!==h.n&&this.collectPolygonPathsPreservingFrom_(e,s,n,r,i);const o=new h.S,a=this.m_topoGraph.getShape();a.dbgVerifyCurves();const m=a.hasSegmentParentage();for(let t=this.m_topoGraph.getFirstCluster();t!==h.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===h.n)continue;let l=e;do{this.progress_();const t=this.m_topoGraph.getHalfEdgeUserIndex(l,n);if(1!==t&&2!==t){const t=this.m_topoGraph.getHalfEdgeFaceParentage(l);if(this.isGoodParentage(t)){const t=a.insertPath(s,h.n);a.setClosedPath(t,!0);let e=l;do{const s=this.m_topoGraph.getHalfEdgeVertexIterator(e);let l=h.n;if(s!==h.n)l=this.m_topoGraph.getVertexFromVertexIterator(s);else{const t=this.m_topoGraph.getHalfEdgeVertexIterator(this.m_topoGraph.getHalfEdgeTwin(e));l=this.m_topoGraph.getVertexFromVertexIterator(t),l=a.getNextVertex(l)}const u=this.chooseVertexFromVertexCluster_(l,i),c=a.addVertex(t,u);if(m){const t=this.m_topoGraph.getSegmentParentage(e),s=this.m_topoGraph.getHalfEdgeOrigin(e);a.setSegmentParentageAndBreak(c,t,this.m_topoGraph.isBreakNode(s))}if(this.m_topoGraph.isHalfEdgeCurve(e)&&(this.m_topoGraph.querySegmentXY(e,o),a.setSegmentToIndex(a.getVertexIndex(c),o.get().clone())),this.m_topoGraph.setHalfEdgeUserIndex(e,n,1),-1!==r){const t=this.m_topoGraph.getClusterFromVertex(u);this.m_topoGraph.setClusterUserIndex(t,r,1)}e=this.m_topoGraph.getHalfEdgeNext(e)}while(e!==l)}else this.m_topoGraph.setHalfEdgeUserIndex(l,n,2)}l=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(l))}while(l!==e)}}topoOperationPolygonPolygon_(t,e,s,i=!1){this.dissolveTopoGraphCommonEdges_();const n=this.m_topoGraph.getShape(),r=n.createGeometry(a.G.enumPolygon),o=this.m_topoGraph.createUserIndexForHalfEdges();return this.topoOperationPolygonPolygonHelper_(t,e,r,s,o,-1),this.m_topoGraph.deleteUserIndexForHalfEdges(o),i||T(n,r,3,this.m_bOGCOutput,h.n,this.m_progressTracker),r}topoOperationPolyline_(t,e){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=e,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(h.n,t,!1,s).first}topoOperationMultiPoint_(){const t=this.m_topoGraph.getShape(),e=t.createGeometry(a.G.enumMultiPoint),s=t.insertPath(e,h.n);for(let e=this.m_topoGraph.getFirstCluster();e!==h.n;e=this.m_topoGraph.getNextCluster(e)){const i=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(i)){let i=h.n;for(let s=this.m_topoGraph.getClusterVertexIterator(e);s!==h.n;s=this.m_topoGraph.incrementVertexIterator(s)){const e=this.m_topoGraph.getVertexFromVertexIterator(s);i===h.n&&(i=e);const n=t.getGeometryFromPath(t.getPathFromVertex(e)),r=this.m_topoGraph.getGeometryID(n);if(this.isGoodParentage(r)){i=e;break}}t.addVertex(s,i)}}return e}intersection(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=(0,a.d)(s),r=(0,a.d)(i),o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);(0,a.g)(o>=0),(0,a.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o|m]=!0;let l=h.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=t),2===n&&2===r?this.topoOperationPolygonPolygon_(t,e,l):1===n&&r>0||1===r&&n>0?this.topoOperationPolyline_(l,this.m_bOGCOutput):0===n||0===r?this.topoOperationMultiPoint_():void(0,a.b)("")}topoOperationPolygonPolygonEx(t,e,s){const i=this.m_topoGraph.getShape(),n=i.createGeometry(a.G.enumPolygon),r=i.createGeometry(a.G.enumPolyline),o=i.createGeometry(a.G.enumMultiPoint);this.dissolveTopoGraphCommonEdges_();let m=h.n;const l=this.m_topoGraph.createUserIndexForHalfEdges(),u=this.m_topoGraph.createUserIndexForClusters();i.dbgVerifyCurves(),this.topoOperationPolygonPolygonHelper_(t,e,n,s,l,u),i.dbgVerifyCurves();const c=i.hasSegmentParentage(),g=new h.S;for(let t=this.m_topoGraph.getFirstCluster();t!==h.n;t=this.m_topoGraph.getNextCluster(t)){const e=this.m_topoGraph.getClusterHalfEdge(t);if(e===h.n)continue;let n=e;do{let e=this.m_topoGraph.getHalfEdgeUserIndex(n,l),o=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(n),l),a=e|o;if(2===a){let m=this.m_topoGraph.getHalfEdgeParentage(n);if(this.isGoodParentage(m)){const _=i.insertPath(r,h.n);let d=n;const p=this.chooseVertexFromCluster_(t,s);let f=i.addVertex(_,p);if(c){const t=this.m_topoGraph.getSegmentParentage(n),e=this.m_topoGraph.getHalfEdgeOrigin(n);i.setSegmentParentageAndBreak(f,t,this.m_topoGraph.isBreakNode(e))}this.m_topoGraph.isHalfEdgeCurve(n)&&(this.m_topoGraph.querySegmentXY(n,g),i.setSegmentToIndex(i.getVertexIndex(f),g.get().clone())),this.m_topoGraph.setClusterUserIndex(t,u,1);do{this.progress_();const t=this.m_topoGraph.getHalfEdgeTo(d),r=this.chooseVertexFromCluster_(t,s);if(f=i.addVertex(_,r),c){const t=this.m_topoGraph.getSegmentParentage(n),e=this.m_topoGraph.getHalfEdgeOrigin(n);i.setSegmentParentageAndBreak(f,t,this.m_topoGraph.isBreakNode(e))}if(this.m_topoGraph.setHalfEdgeUserIndex(d,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(d),l,1),this.m_topoGraph.setClusterUserIndex(t,u,1),d=this.m_topoGraph.getHalfEdgeNext(d),e=this.m_topoGraph.getHalfEdgeUserIndex(d,l),o=this.m_topoGraph.getHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(d),l),a=e|o,2!==a)break;if(m=this.m_topoGraph.getHalfEdgeParentage(d),!this.isGoodParentage(m)){this.m_topoGraph.setHalfEdgeUserIndex(d,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(d),l,1);break}this.m_topoGraph.isHalfEdgeCurve(n)&&d!==n&&(this.m_topoGraph.querySegmentXY(n,g),i.setSegmentToIndex(i.getVertexIndex(f),g.get().clone()))}while(d!==n)}else this.m_topoGraph.setHalfEdgeUserIndex(n,l,1),this.m_topoGraph.setHalfEdgeUserIndex(this.m_topoGraph.getHalfEdgeTwin(n),l,1)}n=this.m_topoGraph.getHalfEdgeNext(this.m_topoGraph.getHalfEdgeTwin(n))}while(n!==e)}for(let t=this.m_topoGraph.getFirstCluster();t!==h.n;t=this.m_topoGraph.getNextCluster(t)){if(this.progress_(),1===this.m_topoGraph.getClusterUserIndex(t,u))continue;const e=this.m_topoGraph.getClusterParentage(t);if(this.isGoodParentage(e)){m===h.n&&(m=i.insertPath(o,h.n));const e=this.m_topoGraph.getClusterVertexIterator(t);let n=h.n;if(e!==h.n){n=this.m_topoGraph.getVertexFromVertexIterator(e);const t=this.chooseVertexFromVertexCluster_(n,s);i.addVertex(m,t)}}}this.m_topoGraph.deleteUserIndexForClusters(u),this.m_topoGraph.deleteUserIndexForHalfEdges(l),i.dbgVerifyCurves(),T(i,n,3,this.m_bOGCOutput,h.n,this.m_progressTracker);const _=[h.n,h.n,h.n];return _[0]=o,_[1]=r,_[2]=n,_}topoOperationPolylinePolylineOrPolygonEx(t,e){const s={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return s.ogcRule=e,s.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(h.n,t,!0,s)}topoOperationMultiPoint(){const t=this.m_topoGraph.getShape(),e=t.createGeometry(a.G.enumMultiPoint),s=t.insertPath(e,h.n);for(let e=this.m_topoGraph.getFirstCluster();e!==h.n;e=this.m_topoGraph.getNextCluster(e)){const i=this.m_topoGraph.getClusterParentage(e);if(this.isGoodParentage(i)){let i=h.n;for(let s=this.m_topoGraph.getClusterVertexIterator(e);s!==h.n;s=this.m_topoGraph.incrementVertexIterator(s)){const e=this.m_topoGraph.getVertexFromVertexIterator(s);i===h.n&&(i=e);const n=t.getGeometryFromPath(t.getPathFromVertex(e)),r=this.m_topoGraph.getGeometryID(n);if(this.isGoodParentage(r)){i=e;break}}t.addVertex(s,i)}}return e}intersectionEx(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=G(s),r=G(i),o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);(0,a.g)(o>=0),(0,a.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o|m]=!0;let l=h.n;if(this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(l=t),2===n&&2===r)return this.topoOperationPolygonPolygonEx(t,e,l);if(1===n&&r>0||1===r&&n>0){const{first:t,second:e}=this.topoOperationPolylinePolylineOrPolygonEx(l,this.m_bOGCOutput);return[e,t]}if(0===n||0===r){const t=[];return t.push(this.topoOperationMultiPoint()),t}(0,a.b)("")}getCombinedHalfEdgeParentage(t){return this.m_topoGraph.getHalfEdgeParentage(t)|this.m_topoGraph.getHalfEdgeFaceParentage(t)|this.m_topoGraph.getHalfEdgeFaceParentage(this.m_topoGraph.getHalfEdgeTwin(t))}prevailingDirection(t,e){const s=this.getCombinedHalfEdgeParentage(e),i=this.m_topoGraph.getHalfEdgeOrigin(e),n=this.m_topoGraph.getHalfEdgeTo(e);let r=0,o=0;for(let a=this.m_topoGraph.getClusterVertexIterator(i);a!==h.n;a=this.m_topoGraph.incrementVertexIterator(a)){const i=this.m_topoGraph.getVertexFromVertexIterator(a),m=t.getPathFromVertex(i),l=t.getGeometryFromPath(m),u=this.m_topoGraph.getGeometryID(l),c=t.getFirstVertex(m),g=!!(u&s);g&&c===i&&(this.m_fromEdgeForPolylines=e);const _=t.getNextVertex(i);if(_!==h.n&&this.m_topoGraph.getClusterFromVertex(_)===n){if(r++,g){if(this.m_fromEdgeForPolylines===h.n&&c===_){const t=this.m_topoGraph.getHalfEdgeNext(e);this.isGoodParentage(this.getCombinedHalfEdgeParentage(t))&&(this.m_fromEdgeForPolylines=t)}o++}}else{const s=t.getPrevVertex(i);if(s!==h.n&&this.m_topoGraph.getClusterFromVertex(s)===n&&(r--,g)){if(this.m_fromEdgeForPolylines===h.n&&c===s){const t=this.m_topoGraph.getHalfEdgeNext(e);this.isGoodParentage(this.getCombinedHalfEdgeParentage(t))&&(this.m_fromEdgeForPolylines=t)}o--}}}return this.m_topoGraph.queryXY(i,this.m_dummyPt1),this.m_topoGraph.queryXY(n,this.m_dummyPt2),(0!==o?o:r)*l.P.distance(this.m_dummyPt1,this.m_dummyPt2)}tryMoveThroughCrossroadBackwards(t,e){const s=this.m_topoGraph.getHalfEdgePrev(t),i=this.m_topoGraph.getHalfEdgeTwin(s);if(!e){if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t)))return h.n;const e=this.m_topoGraph.getHalfEdgeTwin(t);if(i===this.m_topoGraph.getHalfEdgeNext(e))return s}let n=i,r=h.n;for(;n!==t;){const t=this.getCombinedHalfEdgeParentage(n);if(this.isGoodParentage(t)){if(r!==h.n)return h.n;r=this.m_topoGraph.getHalfEdgeTwin(n)}n=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgePrev(n))}return r}tryMoveThroughCrossroadForward(t,e){const s=this.m_topoGraph.getHalfEdgeNext(t),i=this.m_topoGraph.getHalfEdgeTwin(s);if(!e){const e=this.m_topoGraph.getHalfEdgeTwin(t);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(e)))return h.n;if(i===this.m_topoGraph.getHalfEdgePrev(e))return s}let n=i,r=h.n;for(;n!==t;){const t=this.getCombinedHalfEdgeParentage(n);if(this.isGoodParentage(t)){if(r!==h.n)return h.n;r=this.m_topoGraph.getHalfEdgeTwin(n)}n=this.m_topoGraph.getHalfEdgeTwin(this.m_topoGraph.getHalfEdgeNext(n))}return r}isOnALoop(t,e){let s=t;const i=2*this.m_topoGraph.getShape().getTotalPointCount()+10;for(let n=0;n<i;n++){if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,e))return!1;const i=this.m_topoGraph.getHalfEdgeNext(s);if(i===this.m_topoGraph.getHalfEdgeTwin(s))return!1;if(s=i,s===t)return!0}(0,a.b)("is_on_a_loop_")}restorePolylineParts(t,e,s,i,n,r,o,m,u,c){(0,a.g)(n===h.n&&r>=0&&o>=0||-1===r&&-1===o),(0,a.g)(-1===m&&1!==c.unsplitBehavior||-1!==m&&1===c.unsplitBehavior);const g=c.ogcRule,_=c.allCrossRoadsImpassable,d=1===c.unsplitBehavior,p=0===c.unsplitBehavior,f=this.m_topoGraph.getShape(),x=f.hasSegmentParentage();let y=t,P=this.m_topoGraph.getHalfEdgeTwin(y);const E=new h.S;this.m_fromEdgeForPolylines=h.n;let C=this.prevailingDirection(f,y),v=y,b=h.n,S=!1,I=!1,w=!1;if(!d)for(;;){const e=this.m_topoGraph.getHalfEdgePrev(y);if(e===P){w=!0;break}const i=this.m_topoGraph.getHalfEdgeNext(P);if(this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(i))){S=!0;break}if(this.m_topoGraph.getHalfEdgeTwin(e)!==i){if(_){S=!0;break}if(y=this.tryMoveThroughCrossroadBackwards(y,!0),y===h.n){S=!0;break}P=this.m_topoGraph.getHalfEdgeTwin(y)}else y=e,P=i;if(1===this.m_topoGraph.getHalfEdgeUserIndex(y,s)){w=!0;break}if(y===t){b=t,I=!0;break}const n=this.getCombinedHalfEdgeParentage(y);if(!this.isGoodParentage(n))break;v=y,C+=this.prevailingDirection(f,y)}if(b===h.n){for(y=t,P=this.m_topoGraph.getHalfEdgeTwin(y),b=y;;){const t=this.m_topoGraph.getHalfEdgeNext(y),e=this.m_topoGraph.isStrongPathNode(this.m_topoGraph.getHalfEdgeOrigin(t));if(e){S=!0;break}if(t===P){w=!0;break}if(-1!==m){const t=this.m_topoGraph.getHalfEdgeOrigin(P);if(1===this.m_topoGraph.getClusterUserIndex(t,m)){S=!0;break}}const i=this.m_topoGraph.getHalfEdgePrev(P);if(this.m_topoGraph.getHalfEdgeTwin(t)!==i){if(e||_){S=!0;break}if(y=this.tryMoveThroughCrossroadForward(y,!0),y===h.n){S=!0;break}P=this.m_topoGraph.getHalfEdgeTwin(y)}else y=t,P=i;if(1===this.m_topoGraph.getHalfEdgeUserIndex(y,s)){w=!0;break}const n=this.getCombinedHalfEdgeParentage(y);if(!this.isGoodParentage(n))break;b=y,C+=this.prevailingDirection(f,y)}const e=this.m_topoGraph.getHalfEdgeOrigin(v);I=this.m_topoGraph.getHalfEdgeTo(b)===e}else if(this.m_fromEdgeForPolylines!==h.n){v=t,b=this.tryMoveThroughCrossroadBackwards(v,!1),(0,a.g)(b!==h.n);const e=this.m_topoGraph.getHalfEdgeTwin(v);this.m_topoGraph.getHalfEdgeNext(e)}let D=I;I||w||u&&(D=this.isOnALoop(t,s),D||(D=this.isOnALoop(P,s)));const T=C>=0;let N=!1;D&&S&&(I?(N=g,T&&(N||d||p)&&v!==t&&((0,a.g)(!d),v=t,N=!1)):(d||T&&p)&&(v=t));let A=0;for(y=v;P=this.m_topoGraph.getHalfEdgeTwin(y),this.m_topoGraph.setHalfEdgeUserIndex(y,s,1),this.m_topoGraph.setHalfEdgeUserIndex(P,s,1),A++,y!==b;)y=_?this.m_topoGraph.getHalfEdgeNext(y):this.tryMoveThroughCrossroadForward(y,!1);T||(b=(0,l.b)(v,v=b),b=this.m_topoGraph.getHalfEdgeTwin(b),v=this.m_topoGraph.getHalfEdgeTwin(v));let M=f.insertPath(e,h.n);y=v;const G=this.m_topoGraph.getHalfEdgeOrigin(v);let q;q=-1!==r?this.chooseVertexByOrder(G,f,r,o):this.chooseVertexFromCluster_(G,n),this.m_topoGraph.isStrongPathNode(G)&&f.setStrongPathStart(M,!0);let F=f.addVertex(M,q),V=F;-1!==i&&this.m_topoGraph.setClusterUserIndex(G,i,1);let R=0;const Y=N?Math.trunc((A+1)/2):-1;let X=h.n,k=!0,H=h.n;for(;;){if(x){const t=this.m_topoGraph.getSegmentParentage(y),e=this.m_topoGraph.getHalfEdgeOrigin(y);f.setSegmentParentageAndBreak(V,t,k||this.m_topoGraph.isBreakNode(e))}k=!1,this.m_topoGraph.isHalfEdgeCurve(y)&&(this.m_topoGraph.querySegmentXY(y,E),f.setSegmentToIndex(f.getVertexIndex(V),E.get().clone())),X!==h.n&&-1!==o&&f.addToUserIndex(X,o,-1);const t=_?this.m_topoGraph.getHalfEdgeNext(y):this.tryMoveThroughCrossroadForward(y,!1),s=this.m_topoGraph.getHalfEdgeTo(y);let a;if(a=-1!==r?this.chooseVertexByOrder(s,f,r,o):this.chooseVertexFromCluster_(s,n),F=f.addVertex(M,a),H=s,-1!==i&&this.m_topoGraph.setClusterUserIndex(s,i,1),x&&this.m_topoGraph.isBreakNode(s)&&f.setSegmentParentageBreakVertex(F,!0),X=a,R++,N&&R===Y&&(M=f.insertPath(e,h.n),F=f.addVertex(M,a),k=!0,-1!==o&&f.addToUserIndex(a,o,-1),X=h.n),y===b)break;y=t,V=F}H!==h.n&&this.m_topoGraph.isStrongPathNode(H)&&f.setStrongPathEnd(M,!0)}topoOperationPolylineSimplify_(t,e){return this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,h.n,!1,e).first}topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,e,s,i){(0,a.g)(e===h.n||t===h.n);const n=this.m_topoGraph.getShape(),r=e=>t===h.n?e===h.n?n.getFirstGeometry():n.getNextGeometry(e):e===h.n?t:h.n,o=n.createGeometry(a.G.enumPolyline);let m=-1;s&&(m=this.m_topoGraph.createUserIndexForClusters());const u=this.m_topoGraph.createUserIndexForHalfEdges(),c=e===h.n?n.createUserIndex():-1,g=e===h.n?n.createUserIndex():-1;let _=-1;if(1===i.unsplitBehavior){_=this.m_topoGraph.createUserIndexForClusters();for(let t=r(h.n);t!==h.n;t=r(t))for(let e=n.getFirstPath(t);e!==h.n;e=n.getNextPath(e)){{const t=n.getFirstVertex(e),s=this.m_topoGraph.getClusterFromVertex(t);this.m_topoGraph.setClusterUserIndex(s,_,1)}if(!n.isClosedPath(e)){const t=n.getLastVertex(e),s=this.m_topoGraph.getClusterFromVertex(t);this.m_topoGraph.setClusterUserIndex(s,_,1)}}}if(e===h.n){let t=0;for(let e=r(h.n);e!==h.n;e=r(e))for(let s=n.getFirstPath(e);s!==h.n;s=n.getNextPath(s))if(n.isClosedPath(s)){let e=n.getFirstVertex(s);for(let i=0,r=n.getPathSize(s);i<r;i++,e=n.getNextVertex(e))n.setUserIndex(e,c,t++),n.setUserIndex(e,g,2)}else{const e=n.getFirstVertex(s);n.setUserIndex(e,c,t++),n.setUserIndex(e,g,1);let i=n.getNextVertex(e);for(let e=1,r=n.getPathSize(s)-1;e<r;++e)n.setUserIndex(i,c,t++),n.setUserIndex(i,g,2),i=n.getNextVertex(i);n.setUserIndex(i,c,t++),n.setUserIndex(i,g,1)}}for(let t=r(h.n);t!==h.n;t=r(t))for(let s=n.getFirstPath(t);s!==h.n;s=n.getNextPath(s)){let t=n.getFirstVertex(s);for(let r=0,a=n.getPathSize(s);r<a;r++,t=n.getNextVertex(t)){const s=this.m_topoGraph.getHalfEdgeFromVertex(t);if(s===h.n)continue;if(1===this.m_topoGraph.getHalfEdgeUserIndex(s,u))continue;const n=this.getCombinedHalfEdgeParentage(s);if(this.isGoodParentage(n)){const t=0===r;this.restorePolylineParts(s,o,u,m,e,c,g,_,t,i)}}}let d=h.n;if(s){d=n.createGeometry(a.G.enumMultiPoint);let t=h.n;for(let s=this.m_topoGraph.getFirstCluster();s!==h.n;s=this.m_topoGraph.getNextCluster(s))if(this.progress_(),1!==this.m_topoGraph.getClusterUserIndex(s,m)){const i=this.m_topoGraph.getClusterParentage(s);if(this.isGoodParentage(i)){t===h.n&&(t=n.insertPath(d,h.n));const i=this.m_topoGraph.getClusterVertexIterator(s);if(i!==h.n){let r;this.m_topoGraph.getVertexFromVertexIterator(i),r=-1!==c?this.chooseVertexByOrder(s,n,c,g):this.chooseVertexFromCluster_(s,e),n.addVertex(t,r)}}}}return-1!==g&&n.removeUserIndex(g),-1!==c&&n.removeUserIndex(c),-1!==m&&n.removeUserIndex(m),this.m_topoGraph.deleteUserIndexForHalfEdges(u),(0,l.d)(o,d)}difference(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=(0,a.d)(s),r=(0,a.d)(i);if(n>r)return t;const o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);if(this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o]=!0,2===n&&2===r){let s=h.n;return this.m_topoGraph.getShape().getVertexDescription().getAttributeCount()>1&&(s=t),this.topoOperationPolygonPolygon_(t,e,s)}if(1===n&&2===r){const e={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,h.n,!1,e).first}if(1===n&&1===r){const e={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return e.ogcRule=this.m_bOGCOutput,e.unsplitBehavior=0,this.topoOperationPolylineSimplifyOrPolylineTopoHelper_(t,h.n,!1,e).first}if(0===n)return this.topoOperationMultiPoint_();(0,a.b)("")}symmetricDifference(t,e){const s=this.m_topoGraph.getShape().getGeometryType(t),i=this.m_topoGraph.getShape().getGeometryType(e),n=G(s),r=G(i),o=this.m_topoGraph.getGeometryID(t),m=this.m_topoGraph.getGeometryID(e);return(0,a.g)(o>=0),(0,a.g)(m>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=1+(o|m),this.m_maskLookup[o]=!0,this.m_maskLookup[o]=!0,this.m_maskLookup[m]=!0,2===n&&2===r?this.topoOperationPolygonPolygon_(t,e,h.n):1===n&&1===r?this.topoOperationPolyline_(h.n,this.m_bOGCOutput):0===n&&0===r?this.topoOperationMultiPoint():void(0,a.b)("")}planarSimplifyNoCrackingAndCluster(t,e,s,i){this.m_bOGCOutput=t,this.m_topoGraph=new C;const n=e.getFillRule(s),r=e.getGeometryType(s);if(1!==n||r===a.G.enumMultiPoint?this.m_topoGraph.setAndSimplifyEditShapeAlternate(e,s,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeWinding(e,s,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return!1;this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const o=this.m_topoGraph.getGeometryID(s);if((0,a.g)(o>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=o+1,this.m_maskLookup[o]=!0,e.getGeometryType(s)===a.G.enumPolygon||1===n&&e.getGeometryType(s)!==a.G.enumMultiPoint){e.setFillRule(s,0);const r=this.topoOperationPolygonPolygon_(s,h.n,h.n);if(e.swapGeometry(r,s),e.removeGeometry(r),1===n&&this.m_bOGCOutput)return this.planarSimplifyNoCrackingAndCluster(t,e,s,i)}else if(e.getGeometryType(s)===a.G.enumPolyline){const t={unsplitBehavior:0,allCrossRoadsImpassable:!1,ogcRule:!1};t.ogcRule=this.m_bOGCOutput,t.allCrossRoadsImpassable=!0,t.unsplitBehavior=i;const n=this.topoOperationPolylineSimplify_(e.getFirstGeometry(),t);e.swapGeometry(n,s),e.removeGeometry(n)}else if(e.getGeometryType(s)===a.G.enumMultiPoint){const t=this.topoOperationMultiPoint_();e.swapGeometry(t,s),e.removeGeometry(t)}else(0,a.b)("");return!0}unsplitPolylineExact(t){return(0,a.g)(0),new h.i}planarSimplifyPolylines(t,e,s,i,n){for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e)){const s=t.getGeometryType(e);(0,a.g)(s===a.G.enumPolyline)}let r=0,o=0,l=null;if(t.hasCurves()&&!t.hasSegmentParentage()){l=new m.C;const s=t.getEnvelope2D(this.m_progressTracker);o=(0,m.s)(e.total());const i=(0,m.d)(e.total(),s);r=(0,m.f)(i,o),(0,m.b)(t,i,e.total(),12e3,l,null,this.m_progressTracker)}{const s=(0,m.c)(e.add(r));t.filterClosePoints(s,!1,!1,!1,h.n)}if(this.m_topoGraph=new C,4!==n&&5!==n)if(null===l&&s){const i=new m.P(this.m_progressTracker,!1);i.sweepVertical(t,e.total()),i.hadComplications()?((0,m.e)(t,e,this.m_progressTracker,!0,!1),s=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(e.total())}else(0,m.e)(t,e.add(r),this.m_progressTracker,!0,!1),s=!1;else s=!1;t.removeSelection(),t.collapseAllGeometriesToFirst();const u=t.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,u,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,a.g)(s&&null===l),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolylines(t,e,!1,i,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const c=this.m_topoGraph.getGeometryID(u);(0,a.g)(c>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=c+1,this.m_maskLookup[c]=!0;const g=this.topoOperationPolylineSimplify_(t.getFirstGeometry(),i);null!==l&&l.stitchCurves(t,g,o,!0);const _=t.getGeometry(g);return s||_.getImpl().setIsSimple(4,e.total()),_}planarSimplifyMultiPoints(t,e,s,i){for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e)){const s=t.getGeometryType(e);(0,a.g)(s===a.G.enumMultiPoint)}this.m_topoGraph=new C,4!==i&&5!==i?((0,m.e)(t,e,this.m_progressTracker,!0,!1),s=!1):s=!1,t.removeSelection(),t.collapseAllGeometriesToFirst();const n=t.getFirstGeometry();if(this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,n,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,a.g)(s),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyMultiPoints(t,e,!1,-1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const r=this.m_topoGraph.getGeometryID(n);(0,a.g)(r>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=r+1,this.m_maskLookup[r]=!0;const o=this.topoOperationMultiPoint(),l=t.getGeometry(o);return s||l.getImpl().setIsSimple(4,e.total()),l}planarSimplifyPolygons(t,e,s,i,n,r){for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e)){const i=t.getGeometryType(e);(0,a.g)(i===a.G.enumPolygon||i===a.G.enumPolyline&&s)}let o=0,l=0,u=null;if(t.hasCurves()&&!t.hasSegmentParentage()){u=new m.C;const s=t.getEnvelope2D(this.m_progressTracker);l=(0,m.s)(e.total());const i=(0,m.d)(e.total(),s);o=(0,m.f)(i,l),(0,m.b)(t,i,e.total(),12e3,u,null,this.m_progressTracker)}if(r){(0,m.e)(t,e.add(o),this.m_progressTracker,!0,!1);for(let e=t.getFirstGeometry();e!==h.n;e=t.getNextGeometry(e))t.getGeometryType(e)===a.G.enumPolygon&&T(t,e,-1,!1,h.n,this.m_progressTracker)}if(this.m_topoGraph=new C,r||4===n||5===n)i=!1;else if(null===u&&i){const s=new m.P(this.m_progressTracker,!1);s.sweepVertical(t,e.total()),s.hadComplications()?((0,m.e)(t,e,this.m_progressTracker,!0,!1),i=!1):this.m_topoGraph.setCheckDirtyPlanesweepTolerance(e.total())}else(0,m.e)(t,e.add(o),this.m_progressTracker,!0,!1),i=!1;t.removeSelection(),t.collapseAllGeometriesToFirst();const c=t.getFirstGeometry();if(s?this.m_topoGraph.setAndSimplifyEditShapeWinding(t,c,this.m_progressTracker):this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,c,this.m_progressTracker),this.m_topoGraph.dirtyCheckFailed())return(0,a.g)(i&&null===u),this.m_topoGraph.removeShape(),this.m_topoGraph=null,this.planarSimplifyPolygons(t,e,s,!1,-1,!1);this.m_topoGraph.setCheckDirtyPlanesweepTolerance(Number.NaN);const g=this.m_topoGraph.getGeometryID(c);(0,a.g)(g>=0),this.m_maskLookup.length=0,this.m_maskLookup.length=g+1,this.m_maskLookup[g]=!0,t.setFillRule(c,0);const _=this.m_bOGCOutput&&s,d=_;let p=this.topoOperationPolygonPolygon_(c,h.n,h.n,d);_&&(this.m_topoGraph.removeShape(),this.m_topoGraph=null,t.removeGeometry(c),this.m_topoGraph=new C,this.m_topoGraph.setAndSimplifyEditShapeAlternate(t,p,this.m_progressTracker),p=this.topoOperationPolygonPolygon_(p,h.n,h.n,!1)),null!==u&&u.stitchCurves(t,p,l,!0);const f=t.getGeometry(p);return f.setFillRule(0),i?f.getImpl().setIsSimple(3,0):(f.getImpl().setIsSimple(4,e.total()),f.getImpl().updateOGCFlagsProtected()),f}planarSimplify3DImpl_(t,e,s,i,n){return(0,a.g)(0),{}}planarSimplifyImpl_(t,e,s,i,n,r,o,m){if(t.isEmpty())return t.clone();const l=t.getGeometryType(),u=new h.d,c=u.addGeometry(t);if((0,h.o)(n)&&l===a.G.enumPolygon&&(s=!1,u.setFillRule(c,0)),m&&(t.hasAttribute(1)&&u.replaceNaNs(1,0),u.removeNaNVertices()),l===a.G.enumPolygon||l===a.G.enumPolyline&&s)return this.planarSimplifyPolygons(u,e,s,i,n,!1);if(l===h.i.type){const t={unsplitBehavior:0,allCrossRoadsImpassable:!0,ogcRule:!1};return t.ogcRule=this.m_bOGCOutput,t.unsplitBehavior=o,this.planarSimplifyPolylines(u,e,i,t,n)}if(l===a.G.enumMultiPoint)return this.planarSimplifyMultiPoints(u,e,i,n);(0,a.b)("what else?")}}function W(t,e,s,i){const n=t.getGeometryType();if(n===a.G.enumEnvelope){const e=new h.h({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(n===a.G.enumPoint&&("|"===i||"^"===i)){const e=new h.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(n===a.G.enumLine){const e=new h.i({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}if(n===a.G.enumMultiPoint&&"-"===i&&e.getGeometryType()===a.G.enumPoint){const e=new h.P({vd:t.getDescription()});return t.isEmpty()||t.getPointByVal(0,e),e}if(n===a.G.enumMultiPoint&&"&"===i&&e.getGeometryType()===a.G.enumPoint){const e=new h.P({vd:t.getDescription()});return t.isEmpty()||t.getPointByVal(0,e),e}return t}function j(t){const e=t.getGeometryType();if(e===a.G.enumEnvelope){const e=new h.h({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if(e===a.G.enumPoint){const e=new h.M({vd:t.getDescription()});return t.isEmpty()||e.add(t),e}if(M(e)){const e=new h.i({vd:t.getDescription()});return t.isEmpty()||e.addSegment(t,!0),e}return e!==a.G.enumMultiPoint&&e!==a.G.enumPolyline&&e!==a.G.enumPolygon&&(0,a.t)("Unexpected geometry type"),t}function Z(t,e,s,i){const n=s===h.n?t.getClusterHalfEdge(e):s;let r=n;(0,a.g)(t.getHalfEdgeOrigin(n)===e);do{i(r),r=t.getHalfEdgeNext(t.getHalfEdgeTwin(r))}while(r!==n)}class Q{constructor(t,e,s,i,n,r){this.m_rParent=t,this.m_rTopoGraph=t.m_topoGraph,this.m_rShape=this.m_rTopoGraph.getShape(),this.m_IDCuttee=this.m_rTopoGraph.getGeometryID(i),this.m_IDCutter=this.m_rTopoGraph.getGeometryID(n),this.m_IDBoth=this.m_IDCuttee|this.m_IDCutter,this.m_bConsiderTouch=e,this.m_sideIndex=s,this.m_cuttee=i,this.m_cutter=n,this.m_rCutHandles=r,this.m_cutteeBreadcrumbsIndex=this.m_rShape.createUserIndexUninitialized(),this.m_clusterParentageIndex=this.m_rShape.createUserIndexUninitialized();for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==h.n;t=this.m_rShape.getNextPath(t)){let e=0;const s=this.m_rShape.getPathSize(t);for(let i=this.m_rShape.getFirstVertex(t);e<s;e++,i=this.m_rShape.getNextVertex(i))this.m_rShape.setUserIndex(i,this.m_clusterParentageIndex,this.m_rTopoGraph.getClusterParentage(this.m_rTopoGraph.getClusterFromVertex(i)))}}Do(){this.cutPolylinePolyline_(),this.m_rShape.removeUserIndex(this.m_cutteeBreadcrumbsIndex),this.m_rShape.removeUserIndex(this.m_clusterParentageIndex)}setTbd(t){return 8|t}classifyStandardCut(t,e,s,i){const n=this.m_rShape.getPrevVertex(t),r=this.m_rShape.getNextVertex(t),o=n===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(n)),a=r===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(r)),m=this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(s)),l=this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(i));let u=1,c=32,g=32;if(Z(this.m_rTopoGraph,e,l,(t=>{t===m&&(u=2),t===o&&(c=u),t===a&&(g=u)})),this.m_bConsiderTouch)32!==c&&this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|c),32!==g&&this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|g);else{if(32===c||32===g)return 1;if(c===g&&o!==m&&o!==l&&a!==m&&a!==l)return 1;this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|c),this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|g)}return 0}classifyTouchCut(t,e,s,i){const n=this.m_rShape.getPrevVertex(t),r=this.m_rShape.getNextVertex(t),o=n===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(n)),a=r===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(r)),m=s===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(s)),l=i===h.n?h.n:this.m_rTopoGraph.getHalfEdgeConnector(e,this.m_rTopoGraph.getClusterFromVertex(i));if(!this.m_bConsiderTouch){let e;return(e=m===o||l===o)?this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))):(e=m===a||l===a)&&this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),e?0:1}if(o===h.n)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(a===h.n)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),0;if(o===a)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(l!==h.n){if(o===l)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(a===l)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),0;let s=1;Z(this.m_rTopoGraph,e,l,(e=>{if(e===o){const t=this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,t),s=2}else if(e===a){const e=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,e),s=2}}))}else{if(o===m)return this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex))),0;if(a===m)return this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,this.setTbd(this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex))),0;let s=2;Z(this.m_rTopoGraph,e,m,(e=>{if(e===o){const t=this.m_rShape.getUserIndex(n,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(n,this.m_cutteeBreadcrumbsIndex,t),s=1}else if(e===a){const e=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex)|s;this.m_rShape.setUserIndex(t,this.m_cutteeBreadcrumbsIndex,e),s=1}}))}return 0}classifyCutVertex(t,e){let s=0,i=0;for(let n=this.m_rTopoGraph.getClusterVertexIterator(e);n!==h.n;n=this.m_rTopoGraph.incrementVertexIterator(n)){const r=this.m_rTopoGraph.getVertexFromVertexIterator(n);if(this.m_rShape.getGeometryFromVertex(r)===this.m_cutter){i++;const n=this.m_rShape.getPrevVertex(r),o=this.m_rShape.getNextVertex(r);s+=n===h.n||o===h.n?this.classifyTouchCut(t,e,n,o):this.classifyStandardCut(t,e,n,o)}}i&&s===i&&!this.m_bConsiderTouch&&this.m_rShape.setUserIndex(t,this.m_clusterParentageIndex,this.m_IDCuttee)}cutPolylinePolyline_(){this.m_rShape.getGeometryType(this.m_cuttee),this.m_rShape.getGeometryType(this.m_cutter),this.m_rParent.m_maskLookup.length=0,this.m_rParent.m_maskLookup.length=this.m_IDBoth+1,this.m_rParent.m_maskLookup[this.m_IDBoth]=!0;for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==h.n;t=this.m_rShape.getNextPath(t)){const e=this.m_rShape.getPathSize(t);let s=this.m_rShape.getFirstVertex(t);for(let t=0;t<e;++t,s=this.m_rShape.getNextVertex(s))this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,0);s=this.m_rShape.getFirstVertex(t);for(let t=0;t<e;++t,s=this.m_rShape.getNextVertex(s)){const t=this.m_rTopoGraph.getClusterFromVertex(s);this.m_rTopoGraph.getClusterParentage(t)===this.m_IDBoth&&this.classifyCutVertex(s,t)}}const t=(t,e)=>{let s=this.m_rShape.getUserIndex(t,this.m_cutteeBreadcrumbsIndex);const i=this.m_rTopoGraph.getHalfEdgeConnector(this.m_rTopoGraph.getClusterFromVertex(t),this.m_rTopoGraph.getClusterFromVertex(e));return(this.m_rTopoGraph.getHalfEdgeParentage(i)&this.m_IDBoth)===this.m_IDBoth&&(s|=4),s};for(let e=this.m_rShape.getFirstPath(this.m_cuttee);e!==h.n;e=this.m_rShape.getNextPath(e)){let s=this.m_rShape.getFirstVertex(e);const i=this.m_rShape.isClosedPath(e),n=this.m_rShape.getPathSize(e)+(i?1:0);let r=1,o=32;for(let e=this.m_rShape.getNextVertex(s);r<n;++r,s=e,e=this.m_rShape.getNextVertex(e)){const i=t(s,e);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(o=i),32!==o&&this.m_rShape.setUserIndex(s,this.m_cutteeBreadcrumbsIndex,o|i)}s=this.m_rShape.getLastVertex(e);let a=32;r=1;for(let e=this.m_rShape.getPrevVertex(s);r<n;++r,s=e,e=this.m_rShape.getPrevVertex(e)){const i=t(e,s);this.m_rShape.getUserIndex(s,this.m_clusterParentageIndex)===this.m_IDBoth&&(a=i),32!==a&&this.m_rShape.setUserIndex(e,this.m_cutteeBreadcrumbsIndex,a|i)}}let e=h.n,s=h.n,i=32;const n=this.m_rShape.hasSegmentParentage(),r=new h.S;for(let t=this.m_rShape.getFirstPath(this.m_cuttee);t!==h.n;t=this.m_rShape.getNextPath(t)){const o=this.m_rShape.isClosedPath(t),m=this.m_rShape.getPathSize(t)+(o?1:0);let l=1,u=this.m_rShape.getFirstVertex(t),c=h.n,g=!0;for(let t=this.m_rShape.getNextVertex(u);l<m;++l,t=this.m_rShape.getNextVertex(t)){let o=this.m_rShape.getUserIndex(u,this.m_cutteeBreadcrumbsIndex);8===o?o=3:(o&=-9,4&o?o=4:3&~o||(o=3)),o!==i?(e!==h.n&&(c=this.m_rShape.addVertex(s,u),n&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(e),this.m_rShape.setGeometryUserIndex(e,this.m_sideIndex,i)),e=this.m_rShape.createGeometry(a.G.enumPolyline),s=this.m_rShape.insertPath(e,h.n),i=o,g=!0):this.m_rShape.getUserIndex(u,this.m_clusterParentageIndex)===this.m_IDBoth&&4!==o&&(c=this.m_rShape.addVertex(s,u),n&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),s=this.m_rShape.insertPath(e,h.n),g=!0),c=this.m_rShape.addVertex(s,u);const m=this.m_rTopoGraph.getClusterFromVertex(u);!g&&n&&this.m_rTopoGraph.isBreakNode(m)&&this.m_rShape.setSegmentParentageBreakVertex(c,!0);const l=this.m_rTopoGraph.getHalfEdgeFromVertex(u);if(n){const t=this.m_rTopoGraph.getSegmentParentage(l);this.m_rShape.setSegmentParentageAndBreak(c,t,g||this.m_rTopoGraph.isBreakNode(m))}this.m_rTopoGraph.isHalfEdgeCurve(l)&&(this.m_rTopoGraph.querySegmentXY(l,r),this.m_rShape.setSegmentToIndex(this.m_rShape.getVertexIndex(c),r.get().clone())),u=t,g=!1}c=this.m_rShape.addVertex(s,u),n&&this.m_rTopoGraph.isBreakNode(this.m_rTopoGraph.getClusterFromVertex(u))&&this.m_rShape.setSegmentParentageBreakVertex(c,!0),this.m_rCutHandles.push(e),this.m_rShape.setGeometryUserIndex(e,this.m_sideIndex,i),e=h.n,s=h.n,i=32}}}function K(t,e,s,i,n){if(i&&(i.m_reason=0,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),t.isEmpty())return 5;const r=t.getGeometryType();if(r===a.G.enumPoint)return et(t,i);const o=(0,h.u)(e,t,!1).total();if(r===a.G.enumEnvelope){const e=t,s=new h.a;return e.queryEnvelope(s),s.isDegenerate(o)?(i&&(i.m_reason=4,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),0):5}if((0,a.e)(r)){const r=t,o=new h.i({vd:r.getDescription()});return o.addSegment(r,!0),K(o,e,s,i,n)}(0,a.j)(r),(0,a.i)(r)||(0,a.a)("OGC simplify is not implemented for this geometry type");const m=t.getImpl().getIsSimple(o,[0]);let l=s?-1:m;if(5===l||0===l)return l;const u=new lt(t,e,l,n,!0);return r===a.G.enumMultiPoint||r===a.G.enumPolyline||r===a.G.enumPolygon?(l=u.isSimplePlanarImpl(),(0,h.k)(l)&&(l=5)):(0,a.b)(""),t.getImpl().setIsSimple(l,o),i&&i.assign(u.m_nonSimpleResult),l}function J(t,e,s,i,n){if(i&&(i.m_reason=0,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),t.isEmpty())return 5;const r=t.getGeometryType();if(r===a.G.enumPoint)return et(t,i);const o=(0,h.u)(e,t,!1).total();if(r===a.G.enumEnvelope){const e=t,s=h.a.constructEmpty();return e.queryEnvelope(s),s.isDegenerate(o)?(i&&(i.m_reason=4,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),0):5}if((0,a.e)(r)){const r=t,o=new h.i({vd:r.getDescription()});return o.addSegment(r,!0),J(o,e,s,i,n)}const m=t.getImpl().getIsSimple(o,[0]);let l=s?-1:m;if(-1!==l)return l;const u=new lt(t,e,l,n,!1);return r===a.G.enumMultiPoint?l=u.multipointIsSimpleAsFeature():r===a.G.enumPolyline?l=u.polylineIsSimpleAsFeature():r===a.G.enumPolygon?l=u.polygonIsSimpleAsFeature():(0,a.b)(""),t.getImpl().setIsSimple(l,o),i&&i.assign(u.m_nonSimpleResult),l}function $(t,e,s,i){if(t.isEmpty())return t;const n=t.getGeometryType();if(n===a.G.enumPoint){const e=new m.N;if(et(t,e),3===e.m_reason){const e=t.clone();return e.replaceNaNs(1,0),e}return 2===e.m_reason?t.createInstance():t}if(n===a.G.enumEnvelope){const s=(0,h.u)(e,t,!0).total(),i=t,n=h.a.constructEmpty();return i.queryEnvelope(n),n.isDegenerate(s)?i.createInstance():t}if((0,a.e)(n)){const n=t,r=new h.i({vd:n.getDescription()});return r.addSegment(n,!0),$(r,e,s,i)}(0,a.j)(n);const r=(0,h.u)(e,t,!1).total(),o=t.getImpl().getIsSimple(r,[0]),l=s?-1:o;if((0,h.k)(l)){if(n===a.G.enumPolygon&&0!==t.getFillRule()){const e=t.clone();return e.setFillRule(0),e}return t}if((n===a.G.enumMultiPoint||n===a.G.enumPolyline)&&l>=1)return t;const u=new lt(t,e,l,i,!1);let c;return n===a.G.enumMultiPoint?c=u.multipointSimplifyAsFeature():n===a.G.enumPolyline?c=u.polylineSimplifyAsFeature():n===a.G.enumPolygon?c=u.polygonSimplifyAsFeature():(0,a.b)(""),c}function tt(t,e,s,i){if(t.isEmpty())return t;const n=t.getGeometryType();if(n===a.G.enumPoint){const e=new m.N;if(et(t,e),3===e.m_reason){const e=t.clone();return e.replaceNaNs(1,0),e}return 2===e.m_reason?t.createInstance():t}if(n===a.G.enumEnvelope){const s=t,i=new h.a;s.queryEnvelope(i);const n=(0,h.u)(e,t,!0).total();return i.isDegenerate(n)?s.createInstance():t}if((0,a.e)(n)){const n=t,r=new h.i({vd:n.getDescription()});return r.addSegment(n,!0),tt(r,e,s,i)}(0,a.j)(n),(0,a.i)(n)||(0,a.a)("OGC simplify is not implemented for this geometry type");const r=(0,h.u)(e,t,!1).total(),o=t.getImpl().getIsSimple(r,[0]),l=s?-1:o;if(5===l){if(n===a.G.enumPolygon&&0!==t.getFillRule()){const e=t.clone();return e.setFillRule(0),e}return t}return F(t,(0,h.u)(e,t,!0),!1,l,i,0,!0)}function et(t,e){const s=t.getX(),i=t.getY();if(!Number.isFinite(s)||!Number.isFinite(i))return e&&(e.m_reason=2,e.m_vertexIndex1=-1,e.m_vertexIndex2=-1),0;if(t.hasAttribute(1)){const s=t.getZ();if(!Number.isFinite(s))return e&&(e.m_reason=Number.isNaN(s)?3:2,e.m_vertexIndex1=-1,e.m_vertexIndex2=-1),0}return 5}class st{constructor(){this.m_segment=null,this.m_vertexIndex=-1,this.m_pathIndex=-1,this.m_flags=0}setReversed(t){this.m_flags&=-2,this.m_flags=this.m_flags|(t?1:0)}getReversed(){return!!(1&this.m_flags)}getRightSide(){return this.getReversed()?0:1}}function it(t,e,s,i,n){return{x:t,y:e,ipath:s,ivertex:i,ipolygon:n}}function nt(t,e){return t.x===e.x&&t.y===e.y&&t.ipath===e.ipath&&t.ivertex===e.ivertex&&t.ipolygon===e.ipolygon}function rt(t,e){t.x=e.x,t.y=e.y,t.ipath=e.ipath,t.ivertex=e.ivertex,t.ipolygon=e.ipolygon}function ot(t,e,s,i,n,r){return{x:t,y:e,ipath:s,ivertex:i,bBoundary:n,bEndPoint:r}}function at(t,e){t.x=e.x,t.y=e.y,t.ipath=e.ipath,t.ivertex=e.ivertex,t.bBoundary=e.bBoundary,t.bEndPoint=e.bEndPoint}class ht extends h.F{constructor(t){super(),this.m_helper=t}compare(t,e,s){const i=t.getElement(s),n=this.m_helper.m_xy.read(2*e)-this.m_helper.m_xy.read(2*i);return n<0?-1:n>0?1:0}}class mt extends h.F{constructor(t){super(),this.m_helper=t}compare(t,e,s){const i=t.getElement(s),n=this.m_helper.m_edges[e],r=this.m_helper.m_edges[i],o=n.getReversed(),a=r.getReversed();let h=n.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0),m=r.m_segment.intersectionOfYMonotonicWithAxisX(this.m_helper.m_yScanline,0);if(h===m){const t=o?n.m_segment.getStartY():n.m_segment.getEndY(),e=a?r.m_segment.getStartY():r.m_segment.getEndY(),s=Math.min(t,e);let i=.5*(s-this.m_helper.m_yScanline)+this.m_helper.m_yScanline;i===this.m_helper.m_yScanline&&(i=s),h=n.m_segment.intersectionOfYMonotonicWithAxisX(i,0),m=r.m_segment.intersectionOfYMonotonicWithAxisX(i,0)}return h<m?-1:h>m?1:0}}class lt{constructor(t,e,s,i,n){this.m_multiVertexGeom=null,this.m_edges=[],this.m_freeEdges=[],this.m_lineEdgesRecycle=[],this.m_newEdges=[],this.m_recycledSegIter=null,this.m_crossOverHelperList=new h.I,this.m_progressTracker=null,this.m_progressCounter=0,this.m_AET=new h.T,this.m_xyToNode1=null,this.m_xyToNode2=null,this.m_pathOrientations=null,this.m_pathParentage=null,this.m_xy=null,this.m_pairs=[],this.m_pairIndices=null,this.m_pathsForOGCTests=[],this.m_curveStitcher=null,this.m_editShape=null,this.m_multiPathStitcher=null,this.m_nonSimpleResult=new m.N,this.m_progressCounter=0,this.m_progressTracker=i,this.m_geometry=t,this.m_knownSimpleResult=s,this.m_sr=e;const r=(0,h.u)(e,t,!1);this.m_toleranceIsSimple=r,this.m_toleranceIsSimpleClustering=(0,h.l)(r),this.m_toleranceIsSimpleCracking=(0,h.v)(r),this.m_toleranceSimplify=(0,h.u)(e,t,!0),this.m_description=this.m_geometry.getDescription(),this.m_attributeCount=this.m_description.getAttributeCount(),this.m_bOGCRestrictions=n,this.m_bPlanarSimplify=this.m_bOGCRestrictions,this.m_unknownOrientationPathCount=-1,this.m_yScanline=0,this.m_progressCounter=0}isSimplePlanarImpl(){if(this.m_bPlanarSimplify=!0,!this.checkStructure())return 0;const t=this.m_geometry.getGeometryType();return(0,a.f)(t)&&!this.checkDegenerateSegments(!1)?0:this._CheckClustering()?(0,a.f)(t)?this._CheckCracking()?this.m_geometry.getGeometryType()===a.G.enumPolyline?this.checkSelfIntersectionsPolylinePlanar()?4:0:this._CheckSelfIntersections()?this._CheckValidRingOrientation():0:0:5:0}isSimplePlanarImpl3D(){return(0,a.g)(0),7}generateSortedPairs(t){let e=null;(0,a.f)(t.getGeometryType())&&(e=t);const s=(this.m_bPlanarSimplify||this.m_bOGCRestrictions)&&null!==e,i=t.getPointCount();this.m_xy=t.getAttributeStreamRef(0),this.m_pairs.length=0,this.m_pairIndices=new h.A(0),s&&(this.m_pathsForOGCTests.length=0);let n=0;for(let t=0;t<i;t++)if(this.m_pairs.push(2*t),this.m_pairs.push(2*t+1),this.m_pairIndices.add(2*t),this.m_pairIndices.add(2*t+1),s){for(;t>=e.getPathEnd(n);)n++;this.m_pathsForOGCTests.push(n)}const r=new h.B,o={parent:this,workPt:new l.P,userSort(t,e,i){i.sort(t,e,((t,e)=>this.parent.compareVerticesForPlanarClustering(t,e,s)))},getValue(t){const e=this.parent.m_pairs[t],s=e>>1;return this.parent.m_xy.queryPoint2D(2*s,this.workPt),this.workPt.y+(1&e?this.parent.m_toleranceIsSimpleClustering:-this.parent.m_toleranceIsSimpleClustering)}};r.sort(this.m_pairIndices,0,2*i,o)}_TestToleranceDistancePlanar(t,e){const s=this.m_xy.read(2*t),i=this.m_xy.read(2*t+1),n=this.m_xy.read(2*e),r=this.m_xy.read(2*e+1);return!(0,m.g)(s,i,n,r,this.m_toleranceIsSimpleClustering*this.m_toleranceIsSimpleClustering)||0!==this.m_geometry.getDimension()&&s===n&&i===r}checkStructure(){const t=this.m_geometry.getGeometryType();if((0,a.f)(t)){const t=this.m_geometry.getImpl(),e=this.m_geometry.getGeometryType()===a.G.enumPolygon?3:2;for(let s=0,i=t.getPathCount();s<i;s++)if(t.getPathSize(s)<e){if(t.hasNonLinearSegments()&&t.hasNonLinearSegmentsPath(s)&&t.getPathSize(s)>0)continue;return this.m_nonSimpleResult=new m.N(1,s,0),!1}}if((0,a.i)(t)){const t=this.m_geometry.getImpl(),e=t.getAttributeStreamRef(0);for(let s=0,i=t.getPointCount();s<i;s++)if(!e.readPoint2D(2*s).isFinite())return this.m_nonSimpleResult=new m.N(2,s,0),!1;if(this.m_geometry.hasAttribute(1)){const e=t.getAttributeStreamRef(1);for(let s=0,i=t.getPointCount();s<i;s++){const t=e.read(s);if(!Number.isFinite(t))return Number.isNaN(t)?this.m_nonSimpleResult=new m.N(3,s,0):this.m_nonSimpleResult=new m.N(2,s,0),!1}}}return!0}checkDegenerateSegments(t){const e=this.m_geometry.getImpl(),s=e.querySegmentIterator(),i=e.hasAttribute(1),n=i?(0,h.w)(this.m_sr,e,!1).total():0,r=e.hasNonLinearSegments(),o=this.m_toleranceIsSimple.total();for(;s.nextPath();)for(;s.hasNextSegment();){const e=s.nextSegment();let a=e.calculateLowerLength2D();if(!(a>o||r&&e.isCurve()&&(a=e.calculateLength2D(),a>o))){if(t&&i){const t=e.getStartAttributeAsDbl(1,0),s=e.getEndAttributeAsDbl(1,0);if(Math.abs(s-t)>n)continue}return this.m_nonSimpleResult=new m.N(4,s.getStartPointIndex(),-1),!1}}return!0}checkDegenerateSegments3D(){return(0,a.g)(0),!1}_CheckClustering(){const t=this.m_geometry.getImpl();this.generateSortedPairs(t);const e=t.getPointCount();this.m_AET.clear(),this.m_AET.setComparator(new ht(this)),this.m_AET.setCapacity(e);for(let t=0,s=2*e;t<s;t++){this.progress_();const e=this.m_pairIndices.read(t),s=this.m_pairs[e],i=s>>1;if(1&s){const t=this.m_AET.search(i),e=this.m_AET.getPrev(t),s=this.m_AET.getNext(t);if(this.m_AET.deleteNode(t),e!==h.T.st_nullNode()&&s!==h.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(e),this.m_AET.getElement(s)))return this.m_nonSimpleResult=new m.N(5,this.m_AET.getElement(e),this.m_AET.getElement(s)),!1}else{const t=this.m_AET.addElement(i),e=this.m_AET.getPrev(t);if(e!==h.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(e),i))return this.m_nonSimpleResult=new m.N(5,i,this.m_AET.getElement(e)),!1;const s=this.m_AET.getNext(t);if(s!==h.T.st_nullNode()&&!this._TestToleranceDistancePlanar(this.m_AET.getElement(s),i))return this.m_nonSimpleResult=new m.N(5,i,this.m_AET.getElement(s)),!1}}return!0}_CheckCracking(){const t=this.m_geometry.getImpl(),e=t.getPointCount();return!t.hasNonLinearSegments()&&e<10?this._CheckCrackingBrute():this._CheckCrackingPlanesweep()}_CheckCrackingPlanesweep(){if(this.m_editShape=new h.d,this.m_editShape.addGeometry(this.m_geometry),this.m_editShape.hasCurves()){this.m_curveStitcher=new m.C;const t=h.a.constructEmpty();this.m_geometry.queryEnvelope(t);const e=(0,m.d)(this.m_toleranceSimplify.total(),t),s=new m.N;if((0,m.h)(this.m_editShape,e,this.m_toleranceSimplify.total(),12e3,s,this.m_curveStitcher,null,this.m_progressTracker),0!==s.m_reason)return this.m_editShape=null,this.m_nonSimpleResult.assign(s),!1}const t=new m.N;return(0,m.n)(!1,this.m_editShape,this.m_toleranceIsSimpleCracking,t,this.m_progressTracker)?(null!=this.m_curveStitcher?(t.m_vertexIndex1=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,t.m_vertexIndex1),t.m_vertexIndex2=this.m_curveStitcher.getOriginalVertexIndex(this.m_editShape,t.m_vertexIndex2),this.m_curveStitcher=null):(t.m_vertexIndex1=this.m_editShape.getVertexIndex(t.m_vertexIndex1),t.m_vertexIndex2=this.m_editShape.getVertexIndex(t.m_vertexIndex2)),this.m_editShape=null,this.m_nonSimpleResult.assign(t),!1):(null==this.m_curveStitcher&&(this.m_editShape=null),!0)}_CheckCrackingBrute(){const t=this.m_geometry.getImpl(),e=t.querySegmentIterator(),s=t.querySegmentIterator();for(;e.nextPath();)for(;e.hasNextSegment();){const t=e.nextSegment();if(!e.isLastSegmentInPath()||!e.isLastPath()){s.resetTo(e);do{for(;s.hasNextSegment();){const i=s.nextSegment(),n=(0,h.x)(!0,t,i,this.m_toleranceIsSimpleCracking,!0);if(n){const t=2===n?7:6;return this.m_nonSimpleResult=new m.N(t,e.getStartPointIndex(),s.getStartPointIndex()),!1}}}while(s.nextPath())}}return!0}_CheckSelfIntersections(){let t=this.m_geometry.getImpl();null!==this.m_curveStitcher&&(this.m_multiPathStitcher=this.m_editShape.getGeometry(this.m_editShape.getFirstGeometry()),t=this.m_multiPathStitcher.getImpl(),this.generateSortedPairs(t)),this.m_edges.length=0,this.m_lineEdgesRecycle.length=0,this.m_recycledSegIter=t.querySegmentIterator(),this.m_recycledSegIter.setCirculator(!0);const e=new Array(0),s=t.getPointCount();let i=Number.NaN,n=0;for(let t=0,r=2*s;t<r;t++){this.progress_();const s=this.m_pairIndices.read(t),r=this.m_pairs[s];if(1&r)continue;const o=r>>1,a=this.m_xy.read(2*o),h=this.m_xy.read(2*o+1);if(e.length&&(a!==i||h!==n)){if(!this.processBunchForSelfIntersectionTest(e))return!1;e.length=0}e.push(o),i=a,n=h}return!!this.processBunchForSelfIntersectionTest(e)}checkSelfIntersectionsPolylinePlanar(){const t=this.m_geometry.getImpl(),e=[];for(let s=0,i=t.getPathCount();s<i;s++)e.push(t.isClosedPathInXYPlane(s));const s={x:-1,y:-1,ipath:-1,ivertex:-1,bBoundary:!1,bEndPoint:!1};let i,n,r;{const o=this.m_pairIndices.read(0),a=this.m_pairs[o]>>1,h=this.m_xy.readPoint2D(2*a),m=this.m_pathsForOGCTests[a];i=e[m],n=t.getPathStart(m),r=t.getPathEnd(m)-1,s.bEndPoint=a===n||a===r,this.m_bOGCRestrictions?s.bBoundary=!i&&s.bEndPoint:s.bBoundary=s.bEndPoint,s.ipath=m,s.x=h.x,s.y=h.y,s.ivertex=a}for(let o=1,a=this.m_pairIndices.size();o<a;o++){const a=this.m_pairIndices.read(o),h=this.m_pairs[a];if(1&h)continue;const l=h>>1,u=this.m_xy.readPoint2D(2*l),c=this.m_pathsForOGCTests[l];let g;c!==s.ipath&&(i=e[c],n=t.getPathStart(c),r=t.getPathEnd(c)-1);const _=l===n||l===r;g=this.m_bOGCRestrictions?!i&&_:_;const d=ot(u.x,u.y,c,l,g,_);if(d.x===s.x&&d.y===s.y)if(this.m_bOGCRestrictions){if(!(d.bBoundary&&s.bBoundary||d.ipath===s.ipath&&d.bEndPoint&&s.bEndPoint))return this.m_nonSimpleResult=new m.N(10,d.ivertex,s.ivertex),!1}else if(!d.bEndPoint||!s.bEndPoint)return this.m_nonSimpleResult=new m.N(7,d.ivertex,s.ivertex),!1;at(s,d)}return!0}checkSelfIntersectionsPolylinePlanar3D(t){return(0,a.g)(0),!1}checkSelfIntersectionsPolygonsOGC(){const t=this.m_geometry.getImpl(),e=[];let s=-1,i=!1;for(let n=0,r=t.getPathCount();n<r;n++)t.isExteriorRingOGC(n)&&(i=!1,s++,n<r-1&&(t.isExteriorRingOGC(n+1)||(i=!0))),e.push(i?s:-1);const n={x:-1,y:-1,ipath:-1,ivertex:-1,ipolygon:-1};{const t=this.m_pairIndices.read(0),s=this.m_pairs[t]>>1,i=this.m_xy.readPoint2D(2*s),r=this.m_pathsForOGCTests[s];n.ipath=r,n.x=i.x,n.y=i.y,n.ivertex=s,n.ipolygon=e[r]}const r=[];for(let t=1,s=this.m_pairIndices.size();t<s;t++){const s=this.m_pairIndices.read(t),i=this.m_pairs[s];if(1&i)continue;const o=i>>1,a=this.m_xy.readPoint2D(2*o),h=this.m_pathsForOGCTests[o],l=it(a.x,a.y,h,o,e[h]);if(l.x===n.x&&l.y===n.y){if(l.ipath===n.ipath)return this.m_nonSimpleResult=new m.N(11,l.ivertex,n.ivertex),!1;e[l.ipath]>=0&&e[l.ipath]===e[n.ipath]&&(0!==r.length&&nt(r.at(-1),n)||r.push({...n}),r.push(l))}rt(n,l)}if(0===r.length)return!0;const o=new h.I(!0);e.fill(-1);let a=-1;const u=new l.P;for(let t=0,s=r.length;t<s;t++){const s=r[t];s.x===u.x&&s.y===u.y||(a=o.createList(0),u.x=s.x,u.y=s.y);let i=e[s.ipath];-1===i&&(i=o.createList(2),e[s.ipath]=i),o.addElement(i,a),o.addElement(a,i)}const c=[];for(let t=o.getFirstList();-1!==t;t=o.getNextList(t)){const s=o.getListData(t);if(1&s||!(2&s))continue;let i=-1;for(c.push(t),c.push(-1);c.length;){const t=c.at(-1);c.pop();const e=c.at(-1);c.pop();const s=o.getListData(e);if(1&s){i=2&s?e:t;break}o.setListData(e,1|s);for(let s=o.getFirst(e);-1!==s;s=o.getNext(s)){const i=o.getData(s);i!==t&&(c.push(i),c.push(e))}}if(-1!==i){const t=e.indexOf(i);return this.m_nonSimpleResult=new m.N(12,t,-1),!1}}return!0}_CheckValidRingOrientation(){const t=null!==this.m_multiPathStitcher?this.m_multiPathStitcher.getImpl():this.m_geometry.getImpl();if(t.calculateArea2D()<=0)return this.m_nonSimpleResult=new m.N(8,1===t.getPathCount()?1:-1,-1),0;if(1===t.getPathCount())return this.m_bOGCRestrictions&&!this.checkSelfIntersectionsPolygonsOGC()?0:4;this.m_pathOrientations=new h.y(t.getPathCount(),0),this.m_pathParentage=new h.A(t.getPathCount(),-1);let e=-1,s=0;for(let i=0,n=t.getPathCount();i<n;i++){const n=t.calculateRingArea2D(i);if(this.m_pathOrientations.write(i,n<0?0:8),n>0)e=i,s=n;else{if(0===n)return this.m_nonSimpleResult=new m.N(8,i,-1),0;if((e<0||s<Math.abs(n))&&(this.m_nonSimpleResult=new m.N(9,i,-1),this.m_bOGCRestrictions))return 0;this.m_pathParentage.write(i,e)}}this.m_unknownOrientationPathCount=t.getPathCount(),this.m_newEdges.length=0;const i=t.getPointCount();this.m_yScanline=Number.NaN;const n=[];this.m_xyToNode1=new h.A(i,h.T.st_nullNode()),this.m_xyToNode2=new h.A(i,h.T.st_nullNode()),this.m_freeEdges.length=0,this.m_AET.clear(),this.m_AET.setComparator(new mt(this));for(let t=0,e=2*i;this.m_unknownOrientationPathCount>0&&t<e;t++){const e=this.m_pairIndices.read(t),s=this.m_pairs[e];if(1&s)continue;const i=s>>1,r=this.m_xy.read(2*i+1);if(r!==this.m_yScanline&&n.length){if(!this.processBunchForRingOrientationTest(n))return 0;n.length=0}n.push(i),this.m_yScanline=r}return this.m_unknownOrientationPathCount>0&&!this.processBunchForRingOrientationTest(n)?0:this.m_bOGCRestrictions?0!==this.m_nonSimpleResult.m_reason?0:this.checkSelfIntersectionsPolygonsOGC()?5:0:0===this.m_nonSimpleResult.m_reason?4:3}processBunchForSelfIntersectionTest(t){if(1===t.length)return!0;for(let e=0,s=t.length;e<s;e++){const s=t[e];this.m_recycledSegIter.resetToVertex(s,-1);const i=this.m_recycledSegIter.previousSegment();this.m_edges.push(this.createEdge(i,s,this.m_recycledSegIter.getPathIndex(),!0)),this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();this.m_edges.push(this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!1))}this.m_edges.sort(((t,e)=>this.edgeAngleCompare(t,e)));let e=this.m_crossOverHelperList.getFirstList();-1===e&&(e=this.m_crossOverHelperList.createList(0)),this.m_crossOverHelperList.reserveNodes(this.m_edges.length);for(let t=0,s=this.m_edges.length;t<s;t++)this.m_crossOverHelperList.addElement(e,t);let s=!0,i=-1,n=-1;for(;s;){s=!1;let t=this.m_crossOverHelperList.getFirst(e);if(-1===t)break;let r=this.m_crossOverHelperList.getNext(t);for(;-1!==r;){const o=this.m_crossOverHelperList.getData(t),a=this.m_crossOverHelperList.getData(r);if(i=this.m_edges[o].m_vertexIndex,n=this.m_edges[a].m_vertexIndex,i!==n)t=r,r=this.m_crossOverHelperList.getNext(t);else if(s=!0,this.m_crossOverHelperList.deleteElement(e,t),t=this.m_crossOverHelperList.getPrev(r),r=this.m_crossOverHelperList.deleteElement(e,r),-1===r||-1===t)break}}const r=this.m_crossOverHelperList.getListSize(e);if(this.m_crossOverHelperList.clear(e),r>0)return this.m_nonSimpleResult=new m.N(7,i,n),!1;for(let e=0,s=t.length;e<s;e++)this.recycleEdge(this.m_edges[e]);return this.m_edges.length=0,!0}processBunchForRingOrientationTest(t){for(let e=0,s=t.length;e<s;e++){const s=t[e];let i=this.m_xyToNode1.read(s);if(i!==h.T.st_nullNode()){const t=this.m_AET.getElement(i);this.m_freeEdges.push(t),this.m_AET.deleteNode(i),this.recycleEdge(this.m_edges[t]),this.m_edges[t]=null,this.m_xyToNode1.write(s,h.T.st_nullNode())}if(i=this.m_xyToNode2.read(s),i!==h.T.st_nullNode()){const t=this.m_AET.getElement(i);this.m_freeEdges.push(t),this.m_AET.deleteNode(i),this.recycleEdge(this.m_edges[t]),this.m_edges[t]=null,this.m_xyToNode2.write(s,h.T.st_nullNode())}}for(let e=0,s=t.length;e<s;e++){const s=t[e];this.m_recycledSegIter.resetToVertex(s,-1);const i=this.m_recycledSegIter.previousSegment();if(i.getStartY()>i.getEndY()){const t=this.m_recycledSegIter.getStartPointIndex(),e=this.createEdge(i,s,this.m_recycledSegIter.getPathIndex(),!0);let n;this.m_freeEdges.length>0?(n=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[n]=e):(n=this.m_edges.length,this.m_edges.push(e));const r=this.m_AET.addElement(n);this.m_xyToNode1.read(t)===h.T.st_nullNode()?this.m_xyToNode1.write(t,r):this.m_xyToNode2.write(t,r),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(r)}this.m_recycledSegIter.nextSegment();const n=this.m_recycledSegIter.nextSegment();if(n.getStartY()<n.getEndY()){const t=this.m_recycledSegIter.getEndPointIndex(),e=this.createEdge(n,s,this.m_recycledSegIter.getPathIndex(),!1);let i;this.m_freeEdges.length>0?(i=this.m_freeEdges.at(-1),this.m_freeEdges.pop(),this.m_edges[i]=e):(i=this.m_edges.length,this.m_edges.push(e));const r=this.m_AET.addElement(i);this.m_xyToNode1.read(t)===h.T.st_nullNode()?this.m_xyToNode1.write(t,r):this.m_xyToNode2.write(t,r),3&this.m_pathOrientations.read(this.m_recycledSegIter.getPathIndex())||this.m_newEdges.push(r)}}for(let t=0,e=this.m_newEdges.length;t<e&&this.m_unknownOrientationPathCount>0;t++){const e=this.m_newEdges[t],s=this.m_AET.getElement(e),i=this.m_edges[s].m_pathIndex;if(!(3&this.m_pathOrientations.read(i))){let t=-1,s=this.m_AET.getPrev(e),i=e,n=0;{let e=-1,r=null,o=-1,a=0;for(;s!==h.T.st_nullNode()&&(e=this.m_AET.getElement(s),r=this.m_edges[e],o=r.m_pathIndex,a=this.m_pathOrientations.read(o),!(3&a));)i=s,s=this.m_AET.getPrev(s);s===h.T.st_nullNode()?(n=1,s=i):(t=1==(3&a)?o:this.m_pathParentage.read(o),n=r.getRightSide()?0:1,s=this.m_AET.getNext(s))}do{const e=this.m_AET.getElement(s),r=this.m_edges[e],o=r.m_pathIndex;let a=this.m_pathOrientations.read(o);if(!(3&a)){if(n!==r.getRightSide())return this.m_nonSimpleResult=new m.N(8,o,-1),!1;const e=n&&!r.getReversed()?1:2;if(a=-4&a|e,this.m_pathOrientations.write(o,a),2===e&&0===this.m_nonSimpleResult.m_reason){const e=this.m_pathParentage.read(o);if(e!==t&&(this.m_nonSimpleResult=new m.N(9,o,e),this.m_bOGCRestrictions))return!1}if(this.m_unknownOrientationPathCount--,!this.m_unknownOrientationPathCount)return!0}t=1==(3&a)?o:this.m_pathParentage.read(o),i=s,s=this.m_AET.getNext(s),n=n?0:1}while(i!==e)}}return this.m_newEdges.length=0,!0}createEdge(t,e,s,i){let n;return t.getGeometryType()===a.G.enumLine?n=this.createEdgeLine(t):(n=new st,n.m_segment=t.clone()),n.m_vertexIndex=e,n.m_pathIndex=s,n.m_flags=0,n.setReversed(i),n}createEdgeLine(t){let e;return this.m_lineEdgesRecycle.length>0?(e=this.m_lineEdgesRecycle.at(-1),this.m_lineEdgesRecycle.pop(),t.copyTo(e.m_segment)):(e=new st,e.m_segment=t.clone()),e}recycleEdge(t){t.m_segment.getGeometryType()===a.G.enumLine&&this.m_lineEdgesRecycle.push(t)}static isShortSegment(t,e,s,i){let n=t.calculateLowerLength2D();if(n<=s){let r=!0;if(t.isCurve()&&(n=t.calculateLength2D(),r=n<=s),r){if(e){let e=t.getEndAttributeAsDbl(1,0);Number.isNaN(e)&&(e=0);let s=t.getStartAttributeAsDbl(1,0);return Number.isNaN(s)&&(s=0),Math.abs(s-e)<=i}return!0}return!1}return!1}static isShortSegmentPoints(t,e,s,i,n){if(s){const s=t.getXYZ(),r=e.getXYZ();return(0,h.z)(s,r,i,n)}{const s=t.getXY(),n=e.getXY();return l.P.sqrDistance(s,n)<=i*i}}removeDegenerateSegmentsFromCurvedPath(t,e,s,i){const n=t.hasAttribute(1),r=t.querySegmentIterator();r.resetToPath(e),(0,a.g)(r.nextPath());const o=this.m_toleranceSimplify.total();let m=!1,u=!0;const c=new h.P,g=new h.P,_=new l.P;for(;r.hasNextSegment();){this.progress_();const t=r.nextSegment();if(lt.isShortSegment(t,n,o,s))if(m){if(t.queryEnd(g),lt.isShortSegmentPoints(c,g,n,o,s))continue;u&&(i.startPathPoint(c),u=!1),t.queryEnd(c),i.lineToPoint(c),m=!1}else _.assign(t.getStartXY()),t.queryStart(c),m=!0;else if(m)if(t.isCurve()){const e=t.clone();if(e.setCoordsForIntersector(_,t.getEndXY(),!1),e.setStart(c),lt.isShortSegment(e,n,o,s))continue;i.addSegment(e,u),u=!1,m=!1}else{if(t.queryEnd(g),lt.isShortSegmentPoints(c,g,n,o,s))continue;u&&(i.startPathPoint(c),u=!1),i.lineToPoint(g),m=!1}else i.addSegment(t,u),u=!1}if(u)return;if(!m)return;t.isClosedPath(e)?t.getPointByVal(t.getPathStart(e),c):t.getPointByVal(t.getPathEnd(e)-1,c);const d=i.querySegmentIterator();d.resetToLastPath(),d.resetToLastSegment();const p=i.getDescription().getAttributeCount()>1;for((0,a.g)(d.previousPath());d.hasPreviousSegment();){const t=d.previousSegment();if(t.isCurve()){const e=t.clone();if(e.setCoordsForIntersector(t.getStartXY(),c.getXY(),!1),!lt.isShortSegment(e,n,o,s)){p&&e.setEnd(c);const t=d.getEndPointIndex();for(let e=i.getPointCount()-1;e>=t;e--)i.removePoint(e);return void i.addSegment(e,!1)}}else if(t.queryStart(g),!lt.isShortSegmentPoints(g,c,n,o,s)){const t=d.getEndPointIndex();for(let e=i.getPointCount()-1;e>=t;e--)i.removePoint(e);return void i.lineToPoint(c)}}i.removePath(i.getPathCount()-1)}multipointIsSimpleAsFeature(){if(!this.checkStructure())return 0;const t=this.m_geometry.getImpl();this.m_multiVertexGeom=t;const e=t.getPointCount(),s=new Array(e);for(let t=0;t<e;t++)s[t]=t;s.sort(((t,e)=>this.compareVerticesMultiPoint(t,e)));for(let t=1;t<e;t++)if(0===this.compareVerticesMultiPoint(s[t-1],s[t]))return this.m_nonSimpleResult=new m.N(5,s[t-1],s[t]),0;return 1}polylineIsSimpleAsFeature(){return this.checkStructure()&&this.checkDegenerateSegments(!0)?1:0}polygonIsSimpleAsFeature(){return this.isSimplePlanarImpl()}multipointSimplifyAsFeature(){let t=this.m_geometry.getImpl();const e=lt.hasNanZs(t);let s,i=this.m_geometry;e&&(s=this.m_geometry.clone(),t=s.getImpl(),s.replaceNaNs(1,h.V.getDefaultValue(1)),i=s),this.m_multiVertexGeom=t;const n=t.getPointCount(),r=new Array(n);for(let t=0;t<n;t++)r[t]=t;r.sort(((t,e)=>this.compareVerticesMultiPoint(t,e)));const o=new Array(n);o.fill(!1);let a=-1;for(let e=0;e<n;e++){const s=r[e];t.getXY(s).isFinite()&&((a<0||0!==this.compareVerticesMultiPoint(a,s))&&(o[s]=!0),a=s)}const m=this.m_geometry.createInstance();let l=0,u=0;for(let t=0;t<n;t++)o[t]?u=t+1:(l<u&&m.addPoints(i,l,u),l=t+1);return l<u&&m.addPoints(i,l,u),m.getImpl().setIsSimple(1,this.m_toleranceSimplify.total()),m}polylineSimplifyAsFeature(){const t=this.m_geometry.getImpl(),e=t.querySegmentIterator(),s=t.querySegmentIterator(),i=this.m_geometry.createInstance(),n=this.m_geometry,r=t.hasAttribute(1),o=r?(0,h.w)(this.m_sr,t,!0).total():0,a=[],m=[];let u=null;r&&(u=t.getAttributeStreamRef(1));const c=new h.P,g=t.hasNonLinearSegments(),_=this.m_toleranceSimplify.total();for(;e.nextPath();){if(s.nextPath(),t.getPathSize(e.getPathIndex())<2)continue;if(g&&t.hasNonLinearSegmentsPath(e.getPathIndex())){this.removeDegenerateSegmentsFromCurvedPath(t,e.getPathIndex(),o,i);continue}s.resetToLastSegment();let h=0,d=0,p=!0,f=!0;for(;e.hasNextSegment();){this.progress_();const i=e.nextSegment(),n=s.previousSegment();if(e.getStartPointIndex()>s.getStartPointIndex())break;if(p){const s=e.getStartPointIndex();t.getXY(s).isNAN()||(p=!1,a.push(s))}if(f){const e=s.getEndPointIndex();t.getXY(e).isNAN()||(m.push(e),f=!1)}if(!p){const s=a.at(-1),n=e.getEndPointIndex();if(n-s>1){const e=new l.P;e.setSub(t.getXY(s),t.getXY(n)),h=e.length()}else h=i.calculateLength2D();if(h>_)a.push(n),h=0;else if(r){let t=u.read(s);Number.isNaN(t)&&(t=0);let e=u.read(n);Number.isNaN(e)&&(e=0),Math.abs(e-t)>o&&(a.push(n),h=0)}}if(!f){const e=m.at(-1),i=s.getStartPointIndex();if(i-e>1){const s=new l.P;s.setSub(t.getXY(e),t.getXY(i)),d=s.length()}else d=n.calculateLength2D();if(d>_)m.push(i),d=0;else if(r){let t=u.read(e);Number.isNaN(t)&&(t=0);let s=u.read(i);Number.isNaN(s)&&(s=0),Math.abs(s-t)>o&&(m.push(i),d=0)}}}if(a.length>0&&m.length>0&&(a.at(-1)<m.at(-1)?a.length>m.length?a.pop():m.pop():(a.at(-1)===m.at(-1)||m.pop(),m.pop())),m.length+a.length>=2){let t=!1;for(let e=0,s=a.length;e<s;e++)n.getPointByVal(a[e],c),t?i.lineToPoint(c):(i.startPathPoint(c),t=!0);for(let e=m.length-1;e>0;e--)n.getPointByVal(m[e],c),t?i.lineToPoint(c):(i.startPathPoint(c),t=!0);n.isClosedPath(e.getPathIndex())?i.closePathWithLine():m.length>0&&(n.getPointByVal(m[0],c),i.lineToPoint(c))}a.length=0,m.length=0}return r&&i.replaceNaNs(1,0),i.getImpl().setIsSimple(1,_),i}polygonSimplifyAsFeature(){return this.simplifyPlanar()}simplifyPlanar(){if(1===this.m_geometry.getFillRule()&&!(0,h.o)(this.m_knownSimpleResult))return V(this.m_geometry,this.m_toleranceSimplify,!0,!1,this.m_knownSimpleResult,this.m_progressTracker,0,!0);const t=new h.d;if(t.addGeometry(this.m_geometry),this.m_geometry.hasAttribute(1)&&t.replaceNaNs(1,0),t.removeNaNVertices(),0!==t.getTotalPointCount()){let e=null,s=0,i=0;if(t.hasCurves()){e=new m.C;const n=h.a.constructEmpty();this.m_geometry.queryEnvelope(n);const r=(0,m.d)(this.m_toleranceSimplify.total(),n);s=(0,m.s)(this.m_toleranceSimplify.total()),i=(0,m.f)(r,s),(0,m.b)(t,r,this.m_toleranceSimplify.total(),12e3,e,null,this.m_progressTracker)}if(!(0,h.o)(this.m_knownSimpleResult)){const e=this.m_toleranceSimplify.add(i);(0,m.e)(t,e,this.m_progressTracker,!0,!1)}this.m_geometry.getGeometryType()===a.G.enumPolygon&&T(t,t.getFirstGeometry(),this.m_knownSimpleResult,!1,-1,this.m_progressTracker),null!==e&&e.stitchCurves(t,t.getFirstGeometry(),s,!0)}const e=t.getGeometry(t.getFirstGeometry());return e.getGeometryType()===a.G.enumPolygon&&(e.getImpl().updateOGCFlagsProtected(),e.setFillRule(0)),e.getImpl().setIsSimple(4,this.m_toleranceSimplify.total()),e}progress_(){}static hasNanZs(t){if(t.hasAttribute(1)){const e=t.getAttributeStreamRef(1);for(let s=0,i=t.getPointCount();s<i;s++){const t=e.read(s);if(Number.isNaN(t))return!0}}return!1}compareVerticesForPlanarClustering(t,e,s){if(t===e)return 0;const i=this.m_pairs[t],n=this.m_pairs[e],r=i>>1,o=n>>1,a=this.m_xy.readPoint2D(2*r);a.y+=1&i?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const h=this.m_xy.readPoint2D(2*o);h.y+=1&n?this.m_toleranceIsSimpleClustering:-this.m_toleranceIsSimpleClustering;const m=a.compare(h);if(0===m&&s){const t=this.m_pathsForOGCTests[r]-this.m_pathsForOGCTests[o];return(0,l.s)(t)}return m}compareVerticesMultiPoint(t,e){if(t===e)return 0;const s=this.m_multiVertexGeom.getXY(t),i=this.m_multiVertexGeom.getXY(e),n=!s.isFinite(),r=!i.isFinite();if(n||r)return n<r?-1:n>r?1:0;if(s.y<i.y)return-1;if(s.y>i.y)return 1;if(s.x<i.x)return-1;if(s.x>i.x)return 1;for(let s=1;s<this.m_attributeCount;s++){const i=this.m_description.getSemantics(s),n=h.V.getComponentCount(i);for(let s=0;s<n;s++){const n=this.m_multiVertexGeom.getAttributeAsDbl(i,t,s),r=this.m_multiVertexGeom.getAttributeAsDbl(i,e,s),o=(0,l.g)(n,r);if(0!==o)return o}}return 0}edgeAngleCompare(t,e){if(t===e)return 0;const s=t.m_segment.getTangent(t.getReversed()?1:0);t.getReversed()&&s.negateThis();const i=e.m_segment.getTangent(e.getReversed()?1:0);e.getReversed()&&i.negateThis();const n=s.getQuarter(),r=i.getQuarter();if(r===n){const t=s.crossProduct(i);return t<0?1:t>0?-1:0}return n<r?-1:1}}class ut{getOperatorType(){return 10103}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}supportsCurves(){return!0}isSimpleAsFeature(t,e,s,i,n){const r=J(t,e,s,i,n);return(0,h.p)(t.getGeometryType(),r)}isSimplePlanarDONOTUSE(t,e,s,i,n){const r=function(t,e,s,i,n){if(i&&(i.m_reason=0,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),t.isEmpty())return 5;const r=t.getGeometryType();if(r===a.G.enumPoint)return et(t,i);const o=(0,h.u)(e,t,!1).total();if(r===a.G.enumEnvelope){const e=t,s=new h.a;return e.queryEnvelope(s),s.isDegenerate(o)?(i&&(i.m_reason=4,i.m_vertexIndex1=-1,i.m_vertexIndex2=-1),0):5}if((0,a.e)(r)){const r=t,o=new h.i({vd:r.getDescription()});return o.addSegment(r,!0),J(o,e,s,i,n)}const m=t.getImpl().getIsSimple(o,[0]);let l=s?-1:m;if((0,h.k)(l)||0===l)return l;const u=new lt(t,e,l,n,!1);return r===a.G.enumMultiPoint||r===a.G.enumPolyline||r===a.G.enumPolygon?l=u.isSimplePlanarImpl():(0,a.b)(""),t.getImpl().setIsSimple(l,o),i&&i.assign(u.m_nonSimpleResult),l}(t,e,s,i,n);return(0,h.k)(r)}executeMany(t,e,s,i){return new ct(t,e,s,i)}execute(t,e,s,i){const n=new o.S([t]),r=this.executeMany(n,e,s,i).next();return r||(0,a.b)("null geometry"),r}}class ct extends o.G{constructor(t,e,s,i){super(),this.m_progressTracker=i,this.m_bForceSimplify=s,this.m_index=-1,this.m_inputGeometryCursor=t,this.m_spatialReference=e}next(){const t=this.m_inputGeometryCursor.next();return t?(this.m_index=this.m_inputGeometryCursor.getGeometryID(),this.simplify(t)):null}getGeometryID(){return this.m_index}tock(){return!1}getRank(){return 1}simplify(t){if(t||(0,a.t)(""),t.getGeometryType()===a.G.enumGeometryCollection){const e=(0,h.q)(t,-1),s=(new ut).executeMany(e,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker),i=t.createInstance();for(let t=s.next();null!=t;t=s.next())i.addGeometry(t);return i}return $(t,this.m_spatialReference,this.m_bForceSimplify,this.m_progressTracker)}}},96546:(t,e,s)=>{s.d(e,{O:()=>m});var i=s(76061),n=s(55537),r=s(11878),o=s(35368),a=s(31085),h=s(32406);class m{getOperatorType(){return 10001}supportsCurves(){return!0}accelerateGeometry(t,e,s){return!1}canAccelerateGeometry(t){return!1}executeMany(t,e,s,i=0){return new u(t,e,s,i)}execute(t,e,s,r){const o=new i.S([t,e]),a=new u(o,s,r,0).next();return a||(0,n.b)("null output"),a}}class l{constructor(){this.binVertexCount=0,this.geometries=[]}addPair(t){this.binVertexCount+=t.vertexCount,this.geometries.push(t)}sort(){this.geometries.sort(((t,e)=>function(t,e){return r.P.compareZorder(t.location,e.location)?-1:t.location.equals(e.location)?0:1}(t,e)))}geomCount(){return this.geometries.length}geomPairs(){return this.geometries}clear(){this.binVertexCount=0,this.geometries.length=0}getBinVertexCount(){return this.binVertexCount}}class u extends i.G{constructor(t,e,s,i,n=!1){super(),this.m_index=-1,this.m_currentDim=-1,this.m_bDone=!1,this.m_unionBins=[],this.m_readyGeoms=(0,r.k)(4),this.m_dimGeomCounts=(0,r.a)(4,0),this.m_addedGeoms=0,this.m_maxDimension=-1,this.m_bHadGeometry=(0,r.a)(4,!1),this.m_complexUnionGeoms=(0,r.k)(4),this.m_totalNonEmptyGeomCounters=(0,r.a)(4,0),this.m_progressTracker=s,this.m_bUnionAllDimensions=!!(4&i),this.m_bPreserveAllPathEnds=!!(8&i),this.m_inputGeoms=t,this.m_spatialReference=e,this.m_options=i,this.m_bIs3D=n}next(){if(this.m_bDone&&this.m_currentDim===this.m_maxDimension)return null;for(;!this.step_(););if(-1===this.m_maxDimension)return null;if(this.m_bUnionAllDimensions){if(-1===this.m_currentDim)for(let t=0;t<=this.m_maxDimension;t++)if(this.m_bHadGeometry[t]){this.m_complexUnionGeoms[t]=this.getResultGeometry(t);for(let e=t+1;e<=this.m_maxDimension;e++)this.m_complexUnionGeoms[e]=this.getResultGeometry(e),this.m_bHadGeometry[e]&&!this.m_complexUnionGeoms[e].isEmpty()&&(this.m_bIs3D?(0,n.g)(0):this.m_complexUnionGeoms[t]=(new a.O).execute(this.m_complexUnionGeoms[t],this.m_complexUnionGeoms[e],this.m_spatialReference,this.m_progressTracker))}for(;this.m_currentDim++,(this.m_currentDim>this.m_maxDimension||this.m_currentDim<0)&&(0,n.b)(""),!this.m_bHadGeometry[this.m_currentDim];);if(this.m_index++,0===this.m_currentDim&&this.m_complexUnionGeoms[this.m_currentDim].getGeometryType()===n.G.enumPoint){const t=new o.M({vd:this.m_complexUnionGeoms[this.m_currentDim].getDescription()});return this.m_complexUnionGeoms[this.m_currentDim].isEmpty()||t.add(this.m_complexUnionGeoms[this.m_currentDim]),t}return this.m_complexUnionGeoms[this.m_currentDim]}return this.m_index=0,this.m_currentDim=this.m_maxDimension,this.getResultGeometry(this.m_maxDimension)}getGeometryID(){return this.m_index}getRank(){return 1}tock(){return this.step_()}getResultGeometry(t){return this.m_readyGeoms[t]}finishDim(t,e,s){let i=e;if(!s)return 16&this.m_options?(i=(0,h.d)([i],1,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D),i):i;if(1&this.m_options)return i;if(1===t)if(8&this.m_options||!(16&this.m_options||this.m_totalNonEmptyGeomCounters[t]>1))1===this.m_totalNonEmptyGeomCounters[t]&&(this.m_bIs3D?(0,n.g)(0):i=(new h.O).execute(i,this.m_spatialReference,!1,this.m_progressTracker));else{i=(0,h.d)([i],1,this.m_spatialReference,this.m_progressTracker,16|this.m_options,this.m_bIs3D);const t=[0],e=i.getImpl().getIsSimple(0,t);(0,n.g)(this.m_bIs3D||(0,o.k)(e))}else this.m_bIs3D?(0,n.g)(0):i=(new h.O).execute(i,this.m_spatialReference,!1,this.m_progressTracker);if(0===t&&i.getGeometryType()===n.G.enumPoint){const t=new o.M({vd:i.getDescription()});i.isEmpty()||t.add(i),i=t}return i}static getLevel(t){const e=(0,n.v)(t);let s=e>0?(Math.log(e)-Math.log(32))/Math.log(4):0;return s<0&&(s=0),Math.floor(s)}step_(){if(this.m_bDone)return!0;let t;if(this.m_inputGeoms?(t=this.m_inputGeoms.next(),null===t?(this.m_bDone=!0,this.m_inputGeoms=null):(this.checkAndThrow(t),t.isEmpty()||this.m_totalNonEmptyGeomCounters[t.getDimension()]++)):t=null,null!==t){const e=t.getDimension();this.m_bHadGeometry[e]=!0,(e>=this.m_maxDimension||this.m_bUnionAllDimensions)&&(this.addGeom(e,!1,t),e>this.m_maxDimension&&!this.m_bUnionAllDimensions&&this.removeAllBinsWithLowerDimension(e))}if(this.m_addedGeoms>0)for(let t=0;t<=this.m_maxDimension;t++){for(;this.m_dimGeomCounts[t]>1;){const e=this.collectGeometriesToUnion(t);if(null===e)break;{let s;s=1&this.m_options?(0,h.d)(e,e.length,this.m_spatialReference,this.m_progressTracker,this.m_options,this.m_bIs3D):(0,h.a)(e,e.length,this.m_spatialReference,this.m_progressTracker,8|this.m_options,this.m_bIs3D),this.addGeom(t,!0,s)}}if(this.m_bDone&&((0,n.g)(this.m_dimGeomCounts[t]<=1),0!==this.m_dimGeomCounts[t])){const e=this.m_unionBins[t].entries().next().value,s=e[1].geomPairs()[0].geom,i=e[1].geomPairs()[0].bUnioned;this.m_unionBins[t].clear(),this.m_readyGeoms[t]=this.finishDim(t,s,i)}}return this.m_bDone}addGeom(t,e,s){const i={geom:null,vertexCount:-1,bUnioned:!1,location:new r.P};i.geom=s;const a=(0,n.v)(s);i.vertexCount=a;const h=o.a.constructEmpty();s.queryEnvelope(h),i.location=a>0?h.getCenter():new r.P(0,0);const m=u.getLevel(s);if(t+1>this.m_unionBins.length)for(;this.m_unionBins.length<Math.max(2,t+1);)this.m_unionBins.push(new Map);let c=null;const g=this.m_unionBins[t].get(m);g&&(c=g),null===c&&(c=new l,this.m_unionBins[t].set(m,c)),i.bUnioned=e,c.addPair(i),this.m_dimGeomCounts[t]++,this.m_addedGeoms++,this.m_maxDimension=Math.max(this.m_maxDimension,t)}removeAllBinsWithLowerDimension(t){for(let e=0;e<t;e++)this.m_unionBins[e].clear(),this.m_addedGeoms-=this.m_dimGeomCounts[e],this.m_dimGeomCounts[e]=0}collectGeometriesToUnion(t){if(1&this.m_options&&!this.m_bDone)return null;let e=null;const s=[];for(const e of this.m_unionBins[t].keys())s.push(e);(0,r.n)(s);for(let i=0;i<s.length;i++){if(-1===s[i])continue;const n=this.m_unionBins[t].get(s[i]);{const r=5e3,o=4,a=n.getBinVertexCount()>r&&n.geomCount()>=o;if(this.m_bDone||a){for(let n=0;n<i;n++){if(-1===s[n])continue;const i=this.m_unionBins[t].get(s[n]);i.sort(),this.m_dimGeomCounts[t]-=i.geomCount(),this.m_addedGeoms-=i.geomCount();for(const t of i.geomPairs())e||(e=new Array),e.push(t.geom);i.clear(),this.m_unionBins[t].delete(s[n]),s[n]=-1}n.sort(),this.m_dimGeomCounts[t]-=n.geomCount(),this.m_addedGeoms-=n.geomCount();for(const t of n.geomPairs())e||(e=new Array),e.push(t.geom);if(n.clear(),this.m_unionBins[t].delete(s[i]),s[i]=-1,!this.m_bDone)break}}}return e}checkAndThrow(t){this.m_bIs3D&&(t.getDimension()>1&&(0,n.l)(),t.hasAttribute(1)||(0,n.t)("Geometry must have Zs")),(0,n.c)(t)}}},35368:(t,e,s)=>{s.d(e,{A:()=>I,B:()=>X,C:()=>J,D:()=>Fr,E:()=>qt,F:()=>z,G:()=>Ve,H:()=>st,I:()=>O,J:()=>Vt,K:()=>et,L:()=>na,M:()=>kt,N:()=>ft,O:()=>_,P:()=>Nt,Q:()=>yr,R:()=>br,S:()=>ra,T:()=>U,U:()=>Vo,V:()=>g,W:()=>Ro,X:()=>Xo,Y:()=>qo,a:()=>o,a3:()=>Nr,aA:()=>C,aB:()=>nt,aC:()=>x,aD:()=>co,aE:()=>no,aF:()=>Hr,aG:()=>ke,aH:()=>y,aI:()=>$,aJ:()=>xr,aK:()=>Dt,aL:()=>ut,aM:()=>Re,aN:()=>It,aO:()=>Et,aP:()=>vt,aQ:()=>bt,aR:()=>Ct,aS:()=>Dr,aT:()=>Sr,ab:()=>Vs,ac:()=>St,ad:()=>Gr,ae:()=>qr,af:()=>pn,ag:()=>as,ah:()=>Ti,ai:()=>fo,aj:()=>fe,ak:()=>Jo,al:()=>Ao,am:()=>Zo,an:()=>ce,ao:()=>hs,ap:()=>Wt,aq:()=>Wr,ar:()=>Ie,as:()=>Qo,at:()=>Ko,au:()=>ea,av:()=>Mo,aw:()=>uo,ax:()=>v,ay:()=>it,az:()=>E,b:()=>ot,c:()=>lt,d:()=>Go,e:()=>Mr,f:()=>d,g:()=>at,h:()=>Ar,i:()=>pr,j:()=>pt,k:()=>yt,l:()=>gt,m:()=>Q,n:()=>To,o:()=>dt,p:()=>Pt,q:()=>Ot,r:()=>k,s:()=>D,t:()=>p,u:()=>mt,v:()=>_t,w:()=>ht,x:()=>jo,y:()=>S,z:()=>xt});var i=s(55537),n=s(11878),r=s(76061);class o{static construct(t,e,s,i){return new o(t,e,s,i)}constructor(t,e,s,i){this.m_EnvelopeType=2,void 0===t?(this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN):"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),this.normalize()}static constructEmpty(){return new o(Number.NaN,Number.NaN,Number.NaN,Number.NaN)}clone(){return new o(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 Math.min(this.width(),this.height())}sqrDiagonal(){const t=this.width(),e=this.height();return t*t+e*e}diagonal(){return Math.sqrt(this.sqrDiagonal())}getCenterX(){return.5*(this.xmin+this.xmax)}getCenterY(){return.5*(this.ymin+this.ymax)}getCenter(){return n.P.construct(this.getCenterX(),this.getCenterY())}queryCenter(t){t.x=.5*(this.xmin+this.xmax),t.y=.5*(this.ymin+this.ymax)}setEmpty(){this.xmin=Number.NaN,this.ymin=Number.NaN,this.xmax=Number.NaN,this.ymax=Number.NaN}setInfinite(){this.xmin=Number.NEGATIVE_INFINITY,this.xmax=Number.POSITIVE_INFINITY,this.ymin=Number.NEGATIVE_INFINITY,this.ymax=Number.POSITIVE_INFINITY}isDegenerate(t){return!this.isEmpty()&&(this.width()<=t||this.height()<=t)}isZero(){return!(this.isEmpty()||this.width()&&this.height())}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(t,e){const s=this.clone();return s.inflateCoords(t,e),s}inflate(t){this.inflateCoords(t,t)}getInflated(t){const e=this.clone();return e.inflateCoords(t,t),e}zoom(t,e){this.isEmpty()||this.setCoords({center:this.getCenter(),width:t*this.width(),height:e*this.height()})}scale(t){t<0&&this.setEmpty(),this.xmin*=t,this.xmax*=t,this.ymin*=t,this.ymax*=t}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(t){void 0!==t.xmin?(this.xmin=t.xmin,this.xmax=t.xmax,this.ymin=t.ymin,this.ymax=t.ymax):void 0!==t.x?(this.xmin=t.x,this.xmax=t.x,this.ymin=t.y,this.ymax=t.y):void 0!==t.pt1?(this.xmin=t.pt1.x,this.ymin=t.pt1.y,this.xmax=t.pt2.x,this.ymax=t.pt2.y,this.normalize()):void 0!==t.env2D?(this.xmin=t.env2D.xmin,this.xmax=t.env2D.xmax,this.ymin=t.env2D.ymin,this.ymax=t.env2D.ymax,this.normalize()):void 0!==t.pt?(this.xmin=t.pt.x,this.xmax=t.pt.x,this.ymin=t.pt.y,this.ymax=t.pt.y):void 0!==t.center?(this.xmin=t.center.x-.5*t.width,this.xmax=this.xmin+t.width,this.ymin=t.center.y-.5*t.height,this.ymax=this.ymin+t.height,this.normalize()):(0,i.a)("unrecognized input type for setCoords"),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)return void this.setEmpty();if(Array.isArray(t)){const s=t;this.setCoords(s[0]);for(let t=1;t<e;){if(!this.isEmpty()){for(let i=t;i<e;i++)this.mergeNe(s[i]);return}this.setCoords(s[t]),t++}return}const s=t;this.setCoords({x:s[0],y:s[1]});for(let t=1,i=2*e;t<i;t+=2){if(!this.isEmpty()){for(let i=t,n=2*e;i<n;i+=2)this.mergeNeCoords(s[i],s[i+1]);return}this.setCoords({x:s[t],y:s[t+1]}),t+=2}}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 this.isEmpty()||this.xmin<=this.xmax&&this.ymin<=this.ymax}getLowerLeft(){return new n.P(this.xmin,this.ymin)}getLowerRight(){return new n.P(this.xmax,this.ymin)}getUpperLeft(){return new n.P(this.xmin,this.ymax)}getUpperRight(){return new n.P(this.xmax,this.ymax)}move(t,e){this.isEmpty()||(this.xmin+=t,this.ymin+=e,this.xmax+=t,this.ymax+=e)}centerAtCoords(t,e){this.move(t-this.getCenterX(),e-this.getCenterY())}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 n.P(this.xmin,this.ymin);case 1:return new n.P(this.xmin,this.ymax);case 2:return new n.P(this.xmax,this.ymax);default:return new n.P(this.xmax,this.ymin)}}queryCorners(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmin,this.ymax),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmax,this.ymin)}queryCornersReversed(t){t[0].setCoords(this.xmin,this.ymin),t[1].setCoords(this.xmax,this.ymin),t[2].setCoords(this.xmax,this.ymax),t[3].setCoords(this.xmin,this.ymax)}reaspect(t,e){if(this.isEmpty())return;const s=t/e,i=.5*this.width(),n=.5*this.height()*s;if(i<=n){const t=this.getCenterX();this.xmin=t-n,this.xmax=t+n}else{const t=i/s,e=this.getCenterY();this.ymin=e-t,this.ymax=e+t}this.normalize()}getArea(){return this.isEmpty()?0:this.width()*this.height()}getLength(){return this.isEmpty()?0:2*(this.width()+this.height())}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&o.XMASK?(s&o.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&o.XMASK?(i&o.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&o.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&o.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&o.YMASK?(s&o.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&o.YMASK?(i&o.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&o.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&o.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(t){return Math.sqrt(this.sqrDistanceEnvelope(t,null,null))}distance(t){return Math.sqrt(this.sqrDistance(t))}sqrDistanceEnvelope(t,e,s){if(!e&&!s){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.xmax,e>s&&(s=e),e=this.ymin-t.ymax,e>i&&(i=e),e=t.xmin-this.xmax,e>s&&(s=e),e=t.ymin-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isEmpty())return e&&e.setNAN(),s&&s.setNAN(),Number.NaN;let i,n=0,r=0;const o=Math.max(this.xmin,t.xmin),a=Math.max(this.ymin,t.ymin);return e&&e.setCoords(o,a),s&&s.setCoords(o,a),i=this.xmin-t.xmax,i>n&&(n=i,e&&(e.x=this.xmin),s&&(s.x=t.xmax)),i=this.ymin-t.ymax,i>r&&(r=i,e&&(e.y=this.ymin),s&&(s.y=t.ymax)),i=t.xmin-this.xmax,i>n&&(n=i,e&&(e.x=this.xmax),s&&(s.x=t.xmin)),i=t.ymin-this.ymax,i>r&&(r=i,e&&(e.y=this.ymax),s&&(s.y=t.ymin)),n*n+r*r}sqrDistance(t,e){if(void 0===e){if(this.isEmpty()||t.isNAN())return Number.NaN;let e,s=0,i=0;return e=this.xmin-t.x,e>s&&(s=e),e=this.ymin-t.y,e>i&&(i=e),e=t.x-this.xmax,e>s&&(s=e),e=t.y-this.ymax,e>i&&(i=e),s*s+i*i}if(this.isEmpty()||t.isNAN())return e.setNAN(),Number.NaN;e.assign(t);let s,i=0,n=0;return s=this.xmin-t.x,s>i&&(i=s,e.x=this.xmin),s=this.ymin-t.y,s>n&&(n=s,e.y=this.ymin),s=t.x-this.xmax,s>i&&(i=s,e.x=this.xmax),s=t.y-this.ymax,s>n&&(n=s,e.y=this.ymax),i*i+n*n}sqrMaxMinDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=Number.MAX_VALUE;{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),o=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmin,t.ymax),i=n.P.sqrDistanceCoords(this.xmin,this.ymin,t.xmax,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),o=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmax,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmax,this.ymin,t.xmin,t.ymax),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymax),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}{const s=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmin,t.ymin),i=n.P.sqrDistanceCoords(this.xmin,this.ymax,t.xmax,t.ymin),r=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmin,t.ymin),o=n.P.sqrDistanceCoords(this.xmax,this.ymax,t.xmax,t.ymin),a=Math.max(s,i),h=Math.max(r,o),m=Math.max(a,h);e=Math.min(m,e)}return e}sqrMaxDistanceEnvelope(t){if(this.isEmpty()||t.isEmpty())return Number.NaN;let e=0;const s=(0,n.m)(n.P,4);this.queryCorners(s);const i=(0,n.m)(n.P,4);t.queryCorners(i);for(let t=0;t<4;t++)for(let r=0;r<4;r++){const o=n.P.sqrDistance(s[t],i[r]);o>e&&(e=o)}return e}sqrMaxMinDistance(t){const e=n.P.sqrDistance(t,this.getLowerLeft()),s=n.P.sqrDistance(t,this.getUpperLeft()),i=n.P.sqrDistance(t,this.getLowerRight()),r=n.P.sqrDistance(t,this.getUpperRight());let o,a=Math.max(e,s);return o=Math.max(e,i),a>o&&(a=o),o=Math.max(s,r),a>o&&(a=o),o=Math.max(i,r),a>o&&(a=o),a}sqrMinDistance(t){return this.contains(t)?0:this.sqrDistance(t)}sqrMaxDistance(t){let e=n.P.sqrDistance(t,this.getLowerLeft());return e=Math.max(n.P.sqrDistance(t,this.getUpperLeft()),e),e=Math.max(n.P.sqrDistance(t,this.getUpperRight()),e),e=Math.max(n.P.sqrDistance(t,this.getLowerRight()),e),e}snapToBoundary(t){if(t.isNAN())return!1;if(this.isEmpty())return t.setNAN(),!0;let e=!0;if(t.x<this.xmin?t.x=this.xmin:t.x>this.xmax?t.x=this.xmax:e=!1,t.y<this.ymin?t.y=this.ymin:t.y>this.ymax?t.y=this.ymax:e=!1,e)return!0;if(t.x===this.xmin||t.x===this.xmax||t.y===this.ymin||t.y===this.ymax)return!1;const s=this.xmax-t.x,i=t.x-this.xmin,n=this.ymax-t.y,r=t.y-this.ymin;return Math.max(s,i)>Math.max(n,r)?t.y=r<n?this.ymin:this.ymax:t.x=i<s?this.xmin:this.xmax,!0}snapClip(t){const e=(0,n.l)(t.x,this.xmin,this.xmax),s=(0,n.l)(t.y,this.ymin,this.ymax);return n.P.construct(e,s)}boundaryDistance(t){if(this.isEmpty()||t.isNAN())return Number.NaN;if(t.x===this.xmin)return t.y-this.ymin;const e=this.ymax-this.ymin,s=this.xmax-this.xmin;if(t.y===this.ymax)return e+t.x-this.xmin;if(t.x===this.xmax)return e+s+this.ymax-t.y;if(t.y===this.ymin)return 2*e+s+this.xmax-t.x;const i=new n.P;return i.setCoordsPoint2D(t),this.snapToBoundary(i),this.boundaryDistance(i)}envelopeSide(t){if(this.isEmpty())return-1;let e=this.boundaryDistance(t);const s=this.ymax-this.ymin,i=this.xmax-this.xmin;return e<s?0:(e-=s)<i?1:e-i<s?2:3}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:(0,i.t)("query_side")}return e}isPointOnBoundary(t,e){return Math.abs(t.x-this.xmin)<=e||Math.abs(t.x-this.xmax)<=e||Math.abs(t.y-this.ymin)<=e||Math.abs(t.y-this.ymax)<=e}calculateToleranceFromEnvelope(){return this.isEmpty()?(0,n.O)():(Math.abs(this.xmin)+Math.abs(this.xmax)+Math.abs(this.ymin)+Math.abs(this.ymax)+1)*(0,n.O)()}toString(){return`[${this.xmin}, ${this.ymin}, ${this.xmax}, ${this.ymax}]`}}o.XLESSXMIN=1,o.YLESSYMIN=4,o.XMASK=3,o.YMASK=12;const a=[0,0,Number.NaN,0,0,0,0,0,-1,-1,0,0,0,0],h=[2,1,1,1,3,1,2,3,2,4,1,1,2,1],m=[1,1,1,0,2,1,1,1,0,0,0,0,0,1],l=[1,1,1,2,0,0,0,0,2,2,4,2,2,1],u=[4,8,4,8,1];function c(){return new Array(25)}let g=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 m[t]}static getPersistence(t){return l[t]}static getPersistenceSize(t){return u[t]}static getPersistenceSizeFromSemantics(e){return t.getPersistenceSize(t.getPersistence(e))*t.getComponentCount(e)}static getComponentCount(t){return h[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 a[t]}static isDefaultValue(t,e){return(0,n.Q)(a[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(14),this.m_indexToSemantics=new Int32Array(14),this.m_pointAttributeOffsets=new Int32Array(14),this.m_defaultPointAttributes=new Array(25),this.m_semanticsToIndexMap.fill(-1),this.m_indexToSemantics.fill(-1);let s=0,i=1,n=14;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 _{static construct(t,e,s){return new _(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 _(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}setNormalized(t){this.assign(t),this.normalizeThis()}normalizeThis(){const t=this.length();return t?(this.x/=t,this.y/=t,this.z/=t):(this.x=1,this.y=0,this.z=0),this}getUnitVector(){const t=new _;return t.setNormalized(this),t}sqrLength(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}lengthXY(){return(0,i.g)(0),0}static sqrDistance(t,e){return(0,n.e)(t.x-e.x)+(0,n.e)(t.y-e.y)+(0,n.e)(t.z-e.z)}static sqrDistanceCoords(t,e,s,i,r,o){return(0,n.e)(t-i)+(0,n.e)(e-r)+(0,n.e)(s-o)}static distance(t,e){return Math.sqrt(_.sqrDistance(t,e))}isEqual(t,e){return void 0===e&&(e=0),Math.abs(this.x-t.x)<=e&&Math.abs(this.y-t.y)<=e&&(0,n.R)(this.z,t.z,e)}static compareByLength(t,e,s,n){return(0,i.g)(0),0}isEqualCoords(t,e,s,n){return(0,i.g)(0),this.x===t&&this.y===e&&this.z===s}isEqualsTols(t,e,s){return(0,i.g)(0),!1}isEqualCoordsTols(t,e,s,n,r){return(0,i.g)(0),!1}static st_isEqual(t,e,s,n){return(0,i.g)(0),!1}equals(t,e){return this.isEqual(t,e)}equalsTols(t,e,s){return(0,i.g)(0),!1}divThis(t){return this.x/=t,this.y/=t,this.z/=t,this}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}sub(t){return _.construct(this.x-t.x,this.y-t.y,this.z-t.z)}addThis(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}add(t){return this.clone().addThis(t)}setAdd(t,e){return this.x=t.x+e.x,this.y=t.y+e.y,this.z=t.z+e.z,this}mul(t){return _.construct(this.x*t,this.y*t,this.z*t)}dotProduct(t){return this.x*t.x+this.y*t.y+this.z*t.z}crossProductVector(t){const e=this.y*t.z-t.y*this.z,s=t.x*this.z-this.x*t.z,i=this.x*t.y-t.x*this.y;return new _(e,s,i)}setCrossProductVector(t,e){const s=t.y*e.z-e.y*t.z,i=e.x*t.z-t.x*e.z,n=t.x*e.y-e.x*t.y;return this.x=s,this.y=i,this.z=n,this}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}scaleZThis(t){return this.z*=t,this}setNAN(){return(0,i.g)(0),this}isNAN(){return Number.isNaN(this.x)||Number.isNaN(this.y)||Number.isNaN(this.z)}static getNAN(){return _.construct(Number.NaN,Number.NaN,Number.NaN)}isFinite(){return(0,i.g)(0),!1}isZero(){return 0===this.x&&0===this.y&&0===this.z}norm(t){return(0,i.g)(0),0}sqrDistanceFromCenterToSpheroidSurface(t,e){return(0,i.g)(0),0}distanceFromCenterToSpheroidSurface(t,e){return Math.sqrt(this.sqrDistanceFromCenterToSpheroidSurface(t,e))}static getClosestCoordinate(t,e,s,n=!1){return(0,i.g)(0),0}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:this.z<t.z?-1:this.z>t.z?1:0}compareXYZ(t){return(0,i.g)(0),0}negateThis(){this.x=-this.x,this.y=-this.y,this.z=-this.z}static averageFast(t,e){return(0,i.g)(0),{}}static average(t,e){return(0,i.g)(0),{}}static size(){return _.dimensions}static lerp(t,e,s){const i=new _;return(0,n.x)(t,e,s,i),i}static slerp(t,e,s){return(0,i.g)(0),{}}static compareVectors(t,e){return(0,i.g)(0),0}static selectRightHandedBasisFromNormal(t,e,s){const i=t.getUnitVector(),n=i.createAPerpendicular(),r=new _;r.setCrossProductVector(i,n),r.normalizeThis(),e.setCoordsPoint3D(n),s.setCoordsPoint3D(r)}createAPerpendicular(){const t=[this.crossProductVector(new _(0,0,1)),this.crossProductVector(new _(1,0,0)),this.crossProductVector(new _(0,1,0))],e=[t[0].sqrLength(),t[1].sqrLength(),t[2].sqrLength()],s=t[e.reduce(((t,s,i)=>e[t]>e[i]?t:i),0)];return s.normalizeThis(),s}calculateAngle(t){return(0,i.g)(0),0}static crossDotSign(t,e,s){return(0,i.g)(0),0}static isBisectorRobust(t,e,s){return(0,i.g)(0),0}static compareZOrder(t,e){return(0,i.g)(0),!1}}_.dimensions=3;class d{static constructEmpty(){return new d(Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN,Number.NaN)}constructor(t,e,s,i,n,r){this.m_EnvelopeType=3,this.xmin=t,this.ymin=e,this.zmin=s,this.xmax=i,this.ymax=n,this.zmax=r,this.normalize()}inflate(t){this.inflateCoords(t,t,t)}inflateCoords(t,e,s){(0,i.g)(0)}getEnvelope2D(){return new o(this.xmin,this.ymin,this.xmax,this.ymax)}getEnvelopeZs(){return new n.E(this.zmin,this.zmax)}setEmptyZ(){this.zmin=Number.NaN,this.zmax=Number.NaN}normalize(){let t=!1;this.xmin<=this.xmax||(this.xmax=(0,n.b)(this.xmin,this.xmin=this.xmax),t=!0),this.ymin<=this.ymax||(this.ymax=(0,n.b)(this.ymin,this.ymin=this.ymax),t=!0),!t||this.xmin<=this.xmax&&this.ymin<=this.ymax?this.zmin<=this.zmax||(this.zmax=(0,n.b)(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()}sqrDistanceEnvelope3DAndPoints(t,e,s,n=1){return(0,i.g)(0),0}sqrMaxDistance(t,e=1){return(0,i.g)(0),0}}const p=-559038737;var f=g;function x(t,e,s){switch(t){case 0:return new w(e,s);case 1:return new D(e,s);case 2:return new I(e,s);case 3:throw new Error("64 bit int attribute stream not implemented");case 4:return new S(e,s);default:(0,i.t)("")}}function y(t,e){const s=f.getComponentCount(t);return x(f.getPersistence(t),e*s,f.getDefaultValue(t))}function P(t,e){const s=f.getComponentCount(t);return x(f.getPersistence(t),e*s)}function E(t,e){return new I(t,e)}function C(t,e){return new S(t,e)}function v(t,e){return new D(t,e)}class b{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>b.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(t){return this.m_a[t]}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())&&(0,i.t)(),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){return this.getPersistence()===t.getPersistence()&&function(t,e,s,i,r){if(t.getPersistence()!==e.getPersistence())return!1;const o=t.getPersistence()<=1,a=t.size(),h=e.size();if(i>a||i>h)return!1;if(r)if(o){for(let o=s;o<i;o++)if(!(0,n.R)(t.read(o),e.read(o),r))return!1}else for(let n=s;n<i;n++){let s=t.read(n)-e.read(n);if(s<0&&(s=-s),s>r)return!1}else for(let n=s;n<i;n++){const s=t.read(n),i=e.read(n);if(s!==i){if(o&&Number.isNaN(s)&&Number.isNaN(i))continue;return!1}}return!0}(this,t,e,s,i)}insertRange(t,e,s,i){const n=this.m_size;this.checkResize(Math.max(0,i)+s),this.m_a.copyWithin(t+s,t,i>=0?i:n),this.m_a.fill(e,t,t+s)}readRange(t,e){return this.m_a.slice(t,t+e)}insertRangeFromStream(t,e,s,n,r,o,a){(0,i.g)(this.getPersistence()===e.getPersistence());const h=e,m=this.m_size;n&&this.checkResize(Math.max(0,a)+n),this.m_a.copyWithin(t+n,t,a>=0?a:m),this.m_a.set(h.readRange(s,n),t),r||this.reverseRange(t,n,o)}writeRange(t,e,s,n,r,o){(0,i.g)(this.getPersistence()===s.getPersistence());const a=s;if((t<0||e<0||n<0)&&(0,i.t)(),a.size()<n+e&&(0,i.t)(),0===e)return;this.size()<e+t&&this.resize(e+t);const h=a.m_a.subarray(n,n+e);!function(t,e,s,n){if((e<0||s<0)&&(0,i.t)(),0===s)return;if(1===s)return void(t[e]=n[0]);let r=n;s<n.length&&(r=n.subarray(0,s)),t.set(r,e)}(this.m_a,t,e,h)}insertAttributes(t,e,s,i){const n=f.getComponentCount(s);this.m_a.copyWithin(t+n,t,i>=0?i:this.m_size);for(let i=0;i<n;i++)this.m_a[t+i]=e.getAttributeAsDbl(s,i)}insertAttributesFromPoints(t,e,s,r,o){(0,i.g)(f.getPersistence(r)===this.getPersistence());const a=f.getComponentCount(r),h=this.m_size;if(this.checkResize(Math.max(0,o)+a*s),this.m_a.copyWithin(t+a*s,t,o>=0?o:h),0===r){const i=new n.P;for(let n=t,r=0;r<s;r++,n+=2)e[r].queryXY(i),this.m_a[n]=i.x,this.m_a[n+1]=i.y}else if(1===a)for(let i=t,n=0;n<s;n++,i++)this.m_a[i]=e[n].getAttributeAsDbl(r,0);else for(let i=t,n=0;n<s;n++,i+=a)for(let t=0;t<a;t++)this.m_a[i+t]=e[n].getAttributeAsDbl(r,t)}eraseRange(t,e,s){this.m_size<t+e&&(0,i.t)(),this.m_a.copyWithin(t,t+e),this.m_size-=e}reverseRange(t,e,s){if((s<1||e%s!=0)&&(0,i.t)(),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(t,e,s){(e<t||e>s||t>s)&&(0,i.w)("rotate"),e!==t&&e!==s&&(this.reverseRange(t,e-t,1),this.reverseRange(e,s-e,1),this.reverseRange(t,s-t,1))}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,b.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}}}b.s_constructMin=2,b.s_resizeMin=30;class S extends b{setBits(t,e){this.m_a[t]|=e}clearBits(t,e){this.m_a[t]&=~e}getPersistence(){return 4}clone(){return new S({ctor:Int8Array,copy:this})}restrictedClone(t){return new S({ctor:Int8Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Int8Array,size:t,defaultValue:e}:t)}}class I extends b{getPersistence(){return 2}clone(){return new I({ctor:Int32Array,copy:this})}restrictedClone(t){return new I({ctor:Int32Array,copy:this,maxSize:t})}write(t,e){(0,i.g)(e<=(0,n.o)()),super.write(t,e)}constructor(t,e){super("number"==typeof t?{ctor:Int32Array,size:t,defaultValue:e}:t)}}class w extends b{getPersistence(){return 0}clone(){return new w({ctor:Float32Array,copy:this})}restrictedClone(t){return new w({ctor:Float32Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float32Array,size:t,defaultValue:e}:t)}}class D extends b{getPersistence(){return 1}getArray(){return this.m_a}applyTransformation(t,e,s){(1&e||e+2*s>this.size())&&(0,i.t)();const n=0===e?this.m_a:this.m_a.subarray(e);t.transformInterleavedPoints(n,s,n)}readPoint2D(t){const e=this.m_a[t],s=this.m_a[t+1];return new n.P(e,s)}queryPoint2D(t,e){return e.x=this.m_a[t],e.y=this.m_a[t+1],e}writePoint2D(t,e){this.write(t,e.x),this.write(t+1,e.y)}insert(t,e,s){this.checkResize(s+2),this.m_a.copyWithin(t+2,t,s),this.m_a[t]=e.x,this.m_a[t+1]=e.y}insertRangeFromPoints(t,e,s,i,n,r){const o=this.m_size;if(this.checkResize(Math.max(r,0)+2*i),this.m_a.copyWithin(t+2*i,t,r>=0?r:o),n)for(let n=s,r=t,o=0;o<i;++o,++n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}else for(let n=s+i-1,r=t,o=0;o<i;++o,--n){const t=e[n];this.m_a[r++]=t.x,this.m_a[r++]=t.y}}queryRange(t,e,s,n,r){if((t<0||e<0)&&(0,i.t)(),!n&&(r<=0||e%r!=0)&&(0,i.t)(),0===e)return;if(1===e)return void(s[0]=this.m_a[t]);const o=this.m_a.subarray(t,t+e);s.set(o)}writeRangeFromArray(t,e,s,n,r){if((t<0||e<0)&&(0,i.t)(),0===e)return;if(1===e)return void(this.m_a[t]=s[0]);let o=s;e<s.length&&(o=s.subarray(0,e)),this.m_a.set(o,t)}clone(){return new D({ctor:Float64Array,copy:this})}restrictedClone(t){return new D({ctor:Float64Array,copy:this,maxSize:t})}constructor(t,e){super("number"==typeof t?{ctor:Float64Array,size:t,defaultValue:e}:t)}}var T=g;function N(){return new Array(14)}class A{static getInstance(){return A.s_thisInstance}constructor(){this.m_map=new Map,this.m_vd2D=new T(1),this.m_map.set(1,this.m_vd2D),this.m_vd3D=new T(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 T(t);return this.m_map.set(t,s),s}}function M(t){return A.getInstance().FindOrAdd(t)}function G(t,e){if(!t||!e)return e||t;const s=t.getSemanticsBitArray()|e.getSemanticsBitArray();return(s&t.getSemanticsBitArray())===s?t:(s&e.getSemanticsBitArray())===s?e:M(s)}function q(t,e){const s=t.getSemanticsBitArray()|1<<e;return(s&t.getSemanticsBitArray())===s?t:M(s)}function F(t,e){const s=(t.getSemanticsBitArray()|1<<e)-(1<<e);return s===t.getSemanticsBitArray()?t:M(s)}function V(){return A.getInstance().GetVD2D()}function R(){return A.getInstance().GetVD3D()}function Y(t,e,s){if(s.fill(-1),null!==t&&null!==e)for(let i=0,n=t.getAttributeCount();i<n;i++)s[i]=e.getAttributeIndex(t.getSemantics(i))}A.s_thisInstance=new A;class X{constructor(){this.m_minValue=-1,this.m_maxValue=-1,this.m_dy=Number.NaN,this.m_buckets=new I(0),this.m_bucketedIndices=new I(0)}static sortEx(t,e,s,i,n=32){s-e<=n?i.userSort(e,s,t):(new X).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 n=e;n<s;n++){const e=i.getValue(t.read(n));e<o&&(o=e),e>a&&(a=e)}if(this.reset(s-e,o,a,s-e)){for(let n=e;n<s;n++){const s=t.read(n),r=i.getValue(s),o=this.getBucket(r);this.m_buckets.write(o,this.m_buckets.read(o)+1),this.m_bucketedIndices.write(n-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 n=e;n<s;n++){const s=this.m_bucketedIndices.read(n-e),r=i.getValue(s),o=this.getBucket(r),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 s=0,n=this.m_buckets.size();s<n;s++){const n=h;h=this.m_buckets.read(s),h>n&&i.userSort(e+n,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(X.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()}}X.c_maxBuckets=65536;class k{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(k.st_realBlockSize/this.m_realStride)}dbgdelete_(t){return this.m_buffer[t>>k.st_blockPower][1+(t&k.st_blockMask)]=k.st_deadVertex,!0}deleteElement(t){(t>>k.st_blockPower)*this.m_blockSize*this.m_realStride+(t&k.st_blockMask)<this.m_last*this.m_realStride?(this.m_buffer[t>>k.st_blockPower][t&k.st_blockMask]=this.m_firstFree,this.m_firstFree=t):this.m_last--,this.m_size--}getField(t,e){return this.m_buffer[t>>k.st_blockPower][(t&k.st_blockMask)+e]}setField(t,e,s){this.m_buffer[t>>k.st_blockPower][(t&k.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(2*(this.m_capacity+1)):1;this.grow(t)}t=(this.m_last/this.m_blockSize<<k.st_blockPower)+this.m_last%this.m_blockSize*this.m_realStride,this.m_last++}else this.m_firstFree=this.m_buffer[t>>k.st_blockPower][t&k.st_blockMask];this.m_size++;const e=this.m_buffer[t>>k.st_blockPower],s=t&k.st_blockMask;for(let t=0;t<this.m_stride;t++)e[s+t]=-1;return t}elementToIndex(t){return(t>>k.st_blockPower)*this.m_blockSize+(t&k.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>>k.st_blockPower],i=this.m_buffer[e>>k.st_blockPower],n=t&k.st_blockMask,r=e&k.st_blockMask;for(let t=0;t<this.m_stride;t++){const e=s[n+t];s[n+t]=i[r+t],i[r+t]=e}}swapField(t,e,s){const i=this.m_buffer[t>>k.st_blockPower],n=this.m_buffer[e>>k.st_blockPower],r=(t&k.st_blockMask)+s,o=(e&k.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){let e=0;const s=t*this.m_realStride;for(;s>k.st_sizes[e];)e++;const i=new Int32Array(k.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<k.st_realBlockSize){const t=new Int32Array(k.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(k.st_realBlockSize),this.m_capacity+=this.m_blockSize}}}k.st_realBlockSize=16384,k.st_blockMask=16383,k.st_blockPower=14,k.st_sizes=[16,32,64,128,256,512,1024,2048,4096,8192,16384],k.st_deadVertex=-2125315821;class H{constructor(t,e,s){this.m_extent=new o,this.m_dataExtent=new o,this.m_childExtents=[new o,new o,new o,new o],this.m_elementNodes=new k(4),this.m_data=[],this.m_freeData=[],this.m_root=-1,this.m_height=8,void 0===s&&(s=!1),this.m_quadTreeNodes=new k(s?11:10),this.m_bStoreDuplicates=s,this.reset_(t,e)}reset(t,e){(0,i.g)(0)}insert(t,e){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}const s=this.insert_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}insertEx(t,e,s){if(-1===this.m_root&&this.createRoot_(),this.m_bStoreDuplicates){const s=this.insertDuplicates_(t,e,0,this.m_extent,this.m_root,!1,-1);return-1!==s&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),s}let i;i=-1===s?this.m_root:this.getQuad_(s);const n=this.getHeight(i),r=this.getExtent(i),o=this.insert_(t,e,n,r,i,!1,-1);return-1!==o&&(this.m_dataExtent.isEmpty()?this.m_dataExtent.setCoords({env2D:e}):this.m_dataExtent.mergeEnvelope2D(e)),o}removeElement(t){(0,i.g)(0)}getElement(t){return this.getElementValue_(this.getData_(t))}getElementAtIndex(t){return(0,i.g)(0),0}getElementExtent(t){const e=this.getData_(t);return this.getBoundingBoxValue_(e).clone()}getElementExtentAtIndex(t){return(0,i.g)(0),{}}getDataExtent(){return this.m_dataExtent.clone()}getQuadTreeExtent(){return(0,i.g)(0),{}}getHeight(t){return this.m_quadTreeNodes.getField(t,6)>>H.m_heightBitShift}getMaxHeight(){return this.m_height}getExtent(t){const e=new o;if(e.setCoords({env2D:this.m_extent}),t===this.m_root)return e;const s=[];let i=t;do{s.push(this.getQuadrant_(i)),i=this.getParent_(i)}while(i!==this.m_root);const n=s.length;for(let t=0;t<n;t++){const t=s.at(-1);s.pop(),0===t?(e.xmin=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):1===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymin=.5*(e.ymin+e.ymax)):2===t?(e.xmax=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax)):(e.xmin=.5*(e.xmin+e.xmax),e.ymax=.5*(e.ymin+e.ymax))}return e}getQuad(t){return this.getQuad_(t)}getElementCount(){return-1===this.m_root?0:this.getSubTreeElementCount_(this.m_root)}getSubTreeElementCount(t){return this.getSubTreeElementCount_(t)}getContainedSubTreeElementCount(t){return this.m_bStoreDuplicates?this.getContainedSubTreeElementCount_(t):this.getSubTreeElementCount_(t)}getIntersectionCount(t,e,s){if(-1===this.m_root)return 0;const i=new o;i.setCoords({env2D:t}),i.inflateCoords(e,e);const r=[],a=[];r.push(this.m_root),a.push(this.m_extent.clone());const h=(0,n.m)(o,4);let m=0;for(;r.length>0;){let t=!1;const e=r.at(-1),n=a.at(-1);if(r.pop(),a.pop(),i.containsEnvelope(n)){if(m+=this.getSubTreeElementCount(e),s>0&&m>=s)return s}else if(i.isIntersecting(n)){for(let t=this.getFirstElement_(e);-1!==t;t=this.getNextElement_(t)){const e=this.getData_(t);if(this.getBoundingBoxValue_(e).isIntersecting(i)&&(m++,s>0&&m>=s))return s}t=this.getHeight(e)+1<=this.m_height}if(t){H.setChildExtents_(n,h);for(let t=0;t<4;t++){const s=this.getChild_(e,t);-1!==s&&this.getSubTreeElementCount_(s)>0&&i.isIntersecting(h[t])&&(r.push(s),a.push(h[t].clone()))}}}return m}hasData(t,e){return this.getIntersectionCount(t,e,1)>=1}getIterator(t,e){return new B(this,t,e)}getIteratorForQT(){return new B(this)}getSortedIterator(t,e){return new L(this.getIterator(t,e))}getSortedIteratorForQT(){return new L(this.getIteratorForQT())}visitLeavesNearest(t,e,s,n){(0,i.g)(0)}reset_(t,e){(e<0||e>127)&&(0,i.t)("invalid height"),this.m_height=e,this.m_extent.setCoords({env2D:t}),this.m_dataExtent.setEmpty(),this.m_root=-1}insert_(t,e,s,i,n,r,a){if(!i.containsEnvelope(e))return 0===s?-1:this.insert_(t,e,0,this.m_extent,this.m_root,r,a);if(!r)for(let t=n;-1!==t;t=this.getParent_(t))this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1);const h=new o;h.setCoords({env2D:i});let m,l=n;for(m=s;m<this.m_height&&this.canPushDown_(l);m++){H.setChildExtents_(h,this.m_childExtents);let t=!1;for(let s=0;s<4;s++)if(this.m_childExtents[s].containsEnvelope(e)){t=!0;let e=this.getChild_(l,s);-1===e&&(e=this.createChild_(l,s)),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1),l=e,h.setCoords({env2D:this.m_childExtents[s]});break}if(!t)break}return this.insertAtQuad_(t,e,m,h,l,r,n,a,-1)}insertDuplicates_(t,e,s,i,r,a,h){if(!a){if(!i.containsEnvelope(e))return-1;this.setSubTreeElementCount_(r,this.getSubTreeElementCount_(r)+1),this.setContainedSubTreeElementCount_(r,this.getContainedSubTreeElementCount_(r)+1)}const m=Math.max(e.width(),e.height());let l=-1;const u=[],c=[],g=[];u.push(r),c.push(i.clone()),g.push(s);const _=(0,n.m)(o,4);for(;u.length>0;){let s=!1;const i=u.at(-1),n=c.at(-1),o=g.at(-1);if(u.pop(),c.pop(),g.pop(),o+1<this.m_height&&this.canPushDown_(i)&&m<=Math.max(n.width(),n.height())/2&&(s=!0),s){H.setChildExtents_(n,_);let t=!1;for(let s=0;s<4;s++)if(t=_[s].containsEnvelope(e),t){let t=this.getChild_(i,s);-1===t&&(t=this.createChild_(i,s)),u.push(t),c.push(_[s].clone()),g.push(o+1),this.setSubTreeElementCount_(t,this.getSubTreeElementCount_(t)+1),this.setContainedSubTreeElementCount_(t,this.getContainedSubTreeElementCount_(t)+1);break}if(!t)for(let t=0;t<4;t++)if(_[t].isIntersecting(e)){let e=this.getChild_(i,t);-1===e&&(e=this.createChild_(i,t)),u.push(e),c.push(_[t].clone()),g.push(o+1),this.setSubTreeElementCount_(e,this.getSubTreeElementCount_(e)+1)}}else l=this.insertAtQuad_(t,e,o,n,i,a,r,h,l),a=!1}return 0}insertAtQuad_(t,e,s,i,n,r,o,a,h){this.getFirstElement_(n);const m=this.getLastElement_(n);let l=-1;if(r){if(n===o)return a;this.disconnectElementHandle_(a),l=a}else-1===h?(l=this.createElement_(),this.setDataValues_(this.getData_(l),t,e)):l=this.createElementFromDuplicate_(h);return this.setQuad_(l,n),-1!==m?(this.setPrevElement_(l,m),this.setNextElement_(m,l)):this.setFirstElement_(n,l),this.setLastElement_(n,l),this.setLocalElementCount_(n,this.getLocalElementCount_(n)+1),this.canFlush_(n)&&this.flush_(s,i,n),l}static setChildExtents_(t,e){const s=.5*(t.xmin+t.xmax),i=.5*(t.ymin+t.ymax);e[0].setCoords({xmin:s,ymin:i,xmax:t.xmax,ymax:t.ymax}),e[1].setCoords({xmin:t.xmin,ymin:i,xmax:s,ymax:t.ymax}),e[2].setCoords({xmin:t.xmin,ymin:t.ymin,xmax:s,ymax:i}),e[3].setCoords({xmin:s,ymin:t.ymin,xmax:t.xmax,ymax:i})}disconnectElementHandle_(t){const e=this.getQuad_(t),s=this.getFirstElement_(e),i=this.getLastElement_(e),n=this.getPrevElement_(t),r=this.getNextElement_(t);s===t?(-1!==r?this.setPrevElement_(r,-1):this.setLastElement_(e,-1),this.setFirstElement_(e,r)):i===t?(this.setNextElement_(n,-1),this.setLastElement_(e,n)):(this.setPrevElement_(r,n),this.setNextElement_(n,r)),this.setPrevElement_(t,-1),this.setNextElement_(t,-1),this.setLocalElementCount_(e,this.getLocalElementCount_(e)-1)}canFlush_(t){return this.getLocalElementCount_(t)===H.m_flushingCount&&!this.hasChildren_(t)}flush_(t,e,s){let i;const n=new o;let r=this.getFirstElement_(s),a=-1,h=-1;do{h=this.getData_(r),i=this.getElementValue_(h),n.setCoords({env2D:this.getBoundingBoxValue_(h)}),a=this.getNextElement_(r),this.m_bStoreDuplicates?this.insertDuplicates_(i,n,t,e,s,!0,r):this.insert_(i,n,t,e,s,!0,r),r=a}while(-1!==r)}canPushDown_(t){return this.getLocalElementCount_(t)>=H.m_flushingCount||this.hasChildren_(t)}hasChildren_(t){return-1!==this.getChild_(t,0)||-1!==this.getChild_(t,1)||-1!==this.getChild_(t,2)||-1!==this.getChild_(t,3)}createChild_(t,e){const s=this.m_quadTreeNodes.newElement();return this.setChild_(t,e,s),this.setSubTreeElementCount_(s,0),this.setLocalElementCount_(s,0),this.setParent_(s,t),this.setHeightAndQuadrant_(s,this.getHeight_(t)+1,e),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(s,0),s}createRoot_(){this.m_root=this.m_quadTreeNodes.newElement(),this.setSubTreeElementCount_(this.m_root,0),this.setLocalElementCount_(this.m_root,0),this.setHeightAndQuadrant_(this.m_root,0,0),this.m_bStoreDuplicates&&this.setContainedSubTreeElementCount_(this.m_root,0)}createElement_(){const t=this.m_elementNodes.newElement();let e;return this.m_freeData.length>0?(e=this.m_freeData.at(-1),this.m_freeData.pop()):(e=this.m_data.length,this.m_data.length=e+1),this.setData_(t,e),t}createElementFromDuplicate_(t){const e=this.m_elementNodes.newElement(),s=this.getData_(t);return this.setData_(e,s),e}freeElementAndBoxNode_(t){(0,i.g)(0)}getChild_(t,e){return this.m_quadTreeNodes.getField(t,e)}setChild_(t,e,s){this.m_quadTreeNodes.setField(t,e,s)}getFirstElement_(t){return this.m_quadTreeNodes.getField(t,4)}setFirstElement_(t,e){this.m_quadTreeNodes.setField(t,4,e)}getLastElement_(t){return this.m_quadTreeNodes.getField(t,5)}setLastElement_(t,e){this.m_quadTreeNodes.setField(t,5,e)}getQuadrant_(t){return this.m_quadTreeNodes.getField(t,6)&H.m_quadrantMask}getHeight_(t){return this.m_quadTreeNodes.getField(t,6)>>H.m_heightBitShift}setHeightAndQuadrant_(t,e,s){const i=e<<H.m_heightBitShift|s;this.m_quadTreeNodes.setField(t,6,i)}getLocalElementCount_(t){return this.m_quadTreeNodes.getField(t,7)}setLocalElementCount_(t,e){this.m_quadTreeNodes.setField(t,7,e)}getSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,8)}setSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,8,e)}getParent_(t){return this.m_quadTreeNodes.getField(t,9)}setParent_(t,e){this.m_quadTreeNodes.setField(t,9,e)}getContainedSubTreeElementCount_(t){return this.m_quadTreeNodes.getField(t,10)}setContainedSubTreeElementCount_(t,e){this.m_quadTreeNodes.setField(t,10,e)}getData_(t){return this.m_elementNodes.getField(t,0)}setData_(t,e){this.m_elementNodes.setField(t,0,e)}getPrevElement_(t){return this.m_elementNodes.getField(t,1)}getNextElement_(t){return this.m_elementNodes.getField(t,2)}setPrevElement_(t,e){this.m_elementNodes.setField(t,1,e)}setNextElement_(t,e){this.m_elementNodes.setField(t,2,e)}getQuad_(t){return this.m_elementNodes.getField(t,3)}setQuad_(t,e){this.m_elementNodes.setField(t,3,e)}getElementValue_(t){return this.m_data[t].element}getBoundingBoxValue_(t){return this.m_data[t].box}setDataValues_(t,e,s){this.m_data[t]=function(t,e){return{element:t,box:e.clone()}}(e,s)}}H.m_quadrantMask=3,H.m_heightBitShift=2,H.m_flushingCount=5;class B{constructor(t,e,s){this.m_bLinear=!1,this.m_queryStart=new n.P,this.m_queryEnd=new n.P,this.m_queryBox=new o,this.m_tolerance=0,this.m_currentElementHandle=-1,this.m_nextElementHandle=-1,this.m_quadsStack=[],this.m_extentsStack=[],this.m_childExtents=[new o,new o,new o,new o],this.m_quadTree=t,e&&this.resetIterator(e,s)}resetIterator(t,e){if(void 0===e&&(e=0),t instanceof o)return this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,this.m_queryBox.setCoords({env2D:t}),this.m_queryBox.inflateCoords(e,e),this.m_tolerance=Number.NaN,void(-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)?(this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root),this.m_bLinear=!1):this.m_nextElementHandle=-1);if(this.m_quadsStack.length=0,this.m_extentsStack.length=0,this.m_currentElementHandle=-1,t.queryLooseEnvelope(this.m_queryBox),this.m_queryBox.inflateCoords(e,e),-1!==this.m_quadTree.m_root&&this.m_queryBox.isIntersecting(this.m_quadTree.m_extent)){const s=t.getGeometryType();if(this.m_bLinear=s===i.G.enumLine,this.m_bLinear){const s=t;this.m_queryStart.assign(s.getStartXY()),this.m_queryEnd.assign(s.getEndXY()),this.m_tolerance=e}else this.m_tolerance=Number.NaN;this.m_quadsStack.push(this.m_quadTree.m_root),this.m_extentsStack.push(this.m_quadTree.m_extent.clone()),this.m_nextElementHandle=this.m_quadTree.getFirstElement_(this.m_quadTree.m_root)}else this.m_nextElementHandle=-1}next(){if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_nextElementHandle;const t=new n.P,e=new n.P,s=new o;let i=!1;for(;!i;){for(;-1!==this.m_currentElementHandle;){const n=this.m_quadTree.getData_(this.m_currentElementHandle);if(s.setCoords({env2D:this.m_quadTree.getBoundingBoxValue_(n)}),s.isIntersecting(this.m_queryBox)){if(!this.m_bLinear){i=!0;break}if(t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0){i=!0;break}}this.m_currentElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle)}if(-1===this.m_currentElementHandle){const s=this.m_quadsStack.at(-1),i=this.m_extentsStack.at(-1);H.setChildExtents_(i,this.m_childExtents),this.m_quadsStack.pop(),this.m_extentsStack.pop();for(let i=0;i<4;i++){const n=this.m_quadTree.getChild_(s,i);if(-1!==n&&this.m_quadTree.getSubTreeElementCount(n)>0&&this.m_childExtents[i].isIntersecting(this.m_queryBox))if(this.m_bLinear){t.setCoordsPoint2D(this.m_queryStart),e.setCoordsPoint2D(this.m_queryEnd);const s=new o;s.setCoords({env2D:this.m_childExtents[i]}),s.inflateCoords(this.m_tolerance,this.m_tolerance),s.clipLine(t,e)>0&&(this.m_quadsStack.push(n),this.m_extentsStack.push(this.m_childExtents[i].clone()))}else this.m_quadsStack.push(n),this.m_extentsStack.push(this.m_childExtents[i].clone())}if(0===this.m_quadsStack.length)return-1;this.m_currentElementHandle=this.m_quadTree.getFirstElement_(this.m_quadsStack.at(-1))}}return this.m_nextElementHandle=this.m_quadTree.getNextElement_(this.m_currentElementHandle),this.m_currentElementHandle}clone(){return(0,i.g)(0),{}}}class L{constructor(t){this.m_bucketSort=new X,this.m_sortedHandles=new I(0),this.m_index=-1,this.m_quadTreeIteratorImpl=t}resetIterator(t,e){this.m_quadTreeIteratorImpl.resetIterator(t,e),this.m_sortedHandles.resize(0),this.m_index=-1}next(){if(-1===this.m_index){let t=-1;for(;-1!==(t=this.m_quadTreeIteratorImpl.next());)this.m_sortedHandles.add(t);const e=this,s={userSort(t,s,i){i.sort(t,s,((t,s)=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)-e.m_quadTreeIteratorImpl.m_quadTree.getElement(s)))},getValue:t=>e.m_quadTreeIteratorImpl.m_quadTree.getElement(t)};this.m_bucketSort.sort(this.m_sortedHandles,0,this.m_sortedHandles.size(),s)}return this.m_index===this.m_sortedHandles.size()-1?-1:(this.m_index++,this.m_sortedHandles.read(this.m_index))}clone(){return(0,i.g)(0),{}}}class z{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 U{static st_nullNode(){return-1}constructor(){this.m_defaultTreap=-1,this.m_random=124234251,this.m_comparator=null,this.m_treapData=new k(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||((0,i.g)(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===U.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===U.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===U.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,r,o=-1){if(-1===o&&(this.m_defaultTreap===U.st_nullNode()&&(this.m_defaultTreap=this.createTreap(-1)),o=this.m_defaultTreap),this.getRoot_(o)===U.st_nullNode()){const t=this.newNode_(s);return this.setRoot_(t,o),this.addToList_(-1,t,o),t}let a,h,m,l,u;if(r?(a=e!==U.st_nullNode()?this.m_comparator.compare(this,s,e):-1,h=t!==U.st_nullNode()?this.m_comparator.compare(this,s,t):1):(a=-1,h=1),i&&(0===a||0===h)){this.m_comparator.onAddUniqueElementFailedImpl(s);const i=0===a?e:t;return this.setDuplicateElement_(i,o),-1}u=e!==U.st_nullNode()&&t!==U.st_nullNode()?this.m_random>(0,n.V)(this.m_random)>>1:e!==U.st_nullNode(),u?(l=a,m=e):(l=h,m=t);let c=-1,g=-1,_=!0;for(;;){if(l<0){const t=this.getLeft(m);if(t===U.st_nullNode()){g=m,c=this.newNode_(s),this.setLeft_(m,c),this.setParent_(c,m);break}m=t}else{const t=this.getRight(m);if(t===U.st_nullNode()){g=this.getNext(m),c=this.newNode_(s),this.setRight_(m,c),this.setParent_(c,m);break}m=t}_&&(l*=-1,_=!1)}return this.bubbleUp_(c),this.getParent(c)===U.st_nullNode()&&this.setRoot_(c,o),this.addToList_(g,c,o),c}replaceElementAtPosition(t,e,s,i,n=-1){if(i){const i=this.getNext(t);let r=-1;i!==U.st_nullNode()&&(r=this.m_comparator.compare(this,e,i));const o=this.getPrev(t);let a=-1;if(o!==U.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===U.st_nullNode()&&(this.m_defaultTreap===U.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!==U.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),U.st_nullNode()}searchLowerBound(t,e=-1){let s=this.getRoot(e),i=-1;for(;s!==U.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!==U.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=U.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 k.isValidElement(t)}dbgCheck_(t){}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!==U.st_nullNode()||s!==U.st_nullNode();){const r=e!==U.st_nullNode()?this.getPriority_(e):(0,n.j)(),o=s!==U.st_nullNode()?this.getPriority_(s):(0,n.j)();if(i<=Math.min(r,o))return;r<=o?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!==U.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!==U.st_nullNode()&&this.setParent_(i,e),this.setLeft_(s,e),i=this.getParent(s),i!==U.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!==U.st_nullNode()&&this.setParent_(i,e),this.setRight_(s,e),i=this.getParent(s),i!==U.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?U.st_nullNode():this.m_treapData.getField(t,0)}getFirst_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,1)}getLast_(t){return-1===t?U.st_nullNode():this.m_treapData.getField(t,2)}getDuplicateElement_(t){return-1===t?U.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!==U.st_nullNode()&&this.m_treapData.deleteElement(t)}generatePriority_(){return this.m_random=(0,n.V)(this.m_random),this.m_random&(0,n.j)()>>1}maxPriority(){return(0,i.g)(0),0}getMaxDepthHelper_(t){return t===U.st_nullNode()?0:1+Math.max(this.getMaxDepthHelper_(this.getLeft(t)),this.getMaxDepthHelper_(this.getRight(t)))}addElement_(t,e,s){if(this.getRoot(s)===U.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===U.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===U.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)===U.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),r=this.getParent(t),o=t;if(-1!==s&&-1!==i){let a;this.m_random=(0,n.V)(this.m_random),a=this.m_random>(0,n.j)()>>1?this.getNext(t):this.getPrev(t);const h=this.getParent(a)===t;this.m_treapData.swapField(t,a,0),this.m_treapData.swapField(t,a,1),this.m_treapData.swapField(t,a,2),-1!==r?this.getLeft(r)===t?this.setLeft_(r,a):this.setRight_(r,a):this.setRoot_(a,e),h?(s===a?(this.setLeft_(a,t),this.setParent_(i,a)):i===a&&(this.setRight_(a,t),this.setParent_(s,a)),this.setParent_(t,a),r=a):(this.setParent_(s,a),this.setParent_(i,a),r=this.getParent(t),o=a),s=this.getLeft(t),i=this.getRight(t),-1!==s&&this.setParent_(s,t),-1!==i&&this.setParent_(i,t)}const a=-1!==s?s:i;-1===r?this.setRoot_(a,e):this.getLeft(r)===o?this.setLeft_(r,a):this.setRight_(r,a),-1!==a&&this.setParent_(a,r),this.freeNode_(t,e)}deleteNode_(t,e){this.setPriority_(t,(0,n.j)());let s=U.st_nullNode(),i=U.st_nullNode();const r=this.getRoot_(e),o=r===t;if(o&&(s=this.getLeft(r),i=this.getRight(r),s===U.st_nullNode()&&i===U.st_nullNode()))return this.removeFromList_(r,e),this.freeNode_(r,e),void this.setRoot_(U.st_nullNode(),e);this.bubbleDown_(t);const a=this.getParent(t);a!==U.st_nullNode()&&(this.getLeft(a)===t?this.setLeft_(a,U.st_nullNode()):this.setRight_(a,U.st_nullNode())),this.removeFromList_(t,e),this.freeNode_(t,e),o&&this.setRoot_(s===U.st_nullNode()||this.getParent(s)!==U.st_nullNode()?i:s,e)}setElement_(t,e){this.m_treapData.setField(t,3,e)}addBiggestElement_(t,e){if(this.getRoot_(e)===U.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)===U.st_nullNode()&&this.setRoot_(t,e),this.addToList_(-1,t,e)}}class O{constructor(t){this.m_lists=new k(6),this.m_listOfLists=O.st_nullNode(),void 0===t?(this.m_listNodes=new k(3),this.m_bStoreListIndexWithNode=!1):(this.m_listNodes=new k(t?4:3),this.m_bStoreListIndexWithNode=t)}freeNode_(t){this.m_listNodes.deleteElement(t)}newNode_(){return this.m_listNodes.newElement()}freeList_(t){(0,i.g)(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_(t,e){(0,i.g)(0)}setList_(t,e){return this.m_listNodes.setField(t,3,e)}setListSize_(t,e){this.m_lists.setField(t,4,e)}setNextList_(t,e){(0,i.g)(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!==O.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!==O.st_nullNode()?this.setNextList_(e,s):this.m_listOfLists=s,s!==O.st_nullNode()&&this.setPrevList_(s,e),this.freeList_(t),s}reserveLists(t){(0,i.g)(0)}getListData(t){return this.m_lists.getField(t,5)}getList(t){return(0,i.g)(0),0}setListData(t,e){this.m_lists.setField(t,5,e)}addElement(t,e){return this.insertElement(t,-1,e)}insertElement(t,e,s){const i=this.newNode_();let n=-1;if(e!==O.st_nullNode()&&(n=this.getPrev(e),this.setPrev_(e,i)),this.setNext_(i,e),n!==O.st_nullNode()&&this.setNext_(n,i),e===this.m_lists.getField(t,0)&&this.m_lists.setField(t,0,i),e===O.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!==O.st_nullNode()?this.setNext_(s,i):this.m_lists.setField(t,0,i),i!==O.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!==O.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 t=this.getFirstList();-1!==t;)t=this.deleteList(t)}isEmpty(t){return(0,i.g)(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 W extends z{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?j.isLeft_(e)&&j.isRight_(i)?-1:j.isLeft_(i)&&j.isRight_(e)?1:0:1}}class j{constructor(t){this.m_bEnvelopesRef=!1,this.m_intervals=[],this.m_envelopesRef=null,this.m_intervalNodes=new k(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 k(this.m_bOfflineDynamic?5:4),this.m_secondaryTreaps=new U,this.m_secondaryTreaps.setComparator(new W(this)),this.m_secondaryLists=new O}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(){this.reset_(!0,!1)}addInterval(t){this.m_bConstructing||(0,i.u)(""),this.m_intervals.push(t.clone())}addIntervalCoords(t,e){(0,i.g)(0)}endConstruction(){this.m_bConstructing||(0,i.u)(""),this.m_bConstructing=!1,this.m_bConstructionEnded=!0,this.m_bOfflineDynamic||(this.insertIntervalsStatic_(),this.m_cCount=this.m_intervals.length)}insert(t){if(this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,i.u)(""),-1===this.m_root){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length;if(this.m_bSortIntervals){const e=new I(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),n=this.m_secondaryTreaps.addElement(1+(t<<1),s);this.setRightEnd_(e,n),this.m_intervalHandles[t]=e,this.m_cCount++}remove(t){this.m_bOfflineDynamic&&this.m_bConstructionEnded||(0,i.u)("");const e=this.m_intervalHandles[t];let s;-1===e&&(0,i.t)("the interval does not exist in the interval tree"),this.m_intervalHandles[t]=-1,this.m_cCount--;let n=this.getSecondaryFromInterval_(e),r=-1;r=this.m_secondaryTreaps.getTreapData(n),this.m_secondaryTreaps.deleteNode(this.getLeftEnd_(e),n),this.m_secondaryTreaps.deleteNode(this.getRightEnd_(e),n),s=this.m_secondaryTreaps.size(n),0===s&&(this.m_secondaryTreaps.deleteTreap(n),this.setSecondaryToTertiary_(r,-1)),this.m_intervalNodes.deleteElement(e);let o=this.getPptr_(r),a=this.getLptr_(r),h=this.getRptr_(r);for(;!(s>0||r===this.m_root||-1!==a&&-1!==h);)r===this.getLptr_(o)?-1!==a?(this.setLptr_(o,a),this.setPptr_(a,o),this.setLptr_(r,-1),this.setPptr_(r,-1)):-1!==h?(this.setLptr_(o,h),this.setPptr_(h,o),this.setRptr_(r,-1),this.setPptr_(r,-1)):(this.setLptr_(o,-1),this.setPptr_(r,-1)):-1!==a?(this.setRptr_(o,a),this.setPptr_(a,o),this.setLptr_(r,-1),this.setPptr_(r,-1)):-1!==h?(this.setRptr_(o,h),this.setPptr_(h,o),this.setRptr_(r,-1),this.setPptr_(r,-1)):(this.setRptr_(o,-1),this.setPptr_(r,-1)),this.m_tertiaryNodes.deleteElement(r),r=o,n=this.getSecondaryFromTertiary_(r),s=-1!==n?this.m_secondaryTreaps.size(n):0,a=this.getLptr_(r),h=this.getRptr_(r),o=this.getPptr_(r)}size(){return this.m_cCount}getIteratorQuery(t,e){return t instanceof n.E?new Z(this,t,e):((0,i.g)(0),{})}getIterator(){return new Z(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_(){const t=this.m_bEnvelopesRef?this.m_envelopesRef.length:this.m_intervals.length,e=new I(0);this.querySortedEndPointIndices_(e),this.m_endIndicesUnique.length=0,this.querySortedDuplicatesRemoved_(e),this.m_intervalNodes.setCapacity(t),this.m_secondaryLists.reserveNodes(2*t);const s=(0,n.a)(t,-1);this.m_root=this.createRoot_();for(let t=0;t<e.size();t++){const i=e.read(t);let n=s[i>>1];if(-1!==n){const t=this.getSecondaryFromInterval_(n);this.setRightEnd_(n,this.m_secondaryLists.addElement(t,i))}else n=this.insertIntervalEnd_(i,this.m_root),s[i>>1]=n}}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 l=Number.NaN,u=Number.NaN,c=!0;const g=this.getMin_(m),_=this.getMax_(m);let d=-1;for(;c;){h=o+(a-o>>1),d=this.calculateDiscriminantIndex1_(o,a);const e=this.getDiscriminantFromIndex1_(d);if(_<e){if(-1!==i)if(d===this.getDiscriminantIndex1_(i))s=i,l=e,i=this.getLptr_(i),u=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(u>e){const t=this.createTertiaryNode_(d);e<l?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,l=e,i=-1,u=Number.NaN}a=h;continue}if(g>e){if(-1!==i)if(d===this.getDiscriminantIndex1_(i))s=i,l=e,i=this.getRptr_(i),u=-1!==i?this.getDiscriminant_(i):Number.NaN;else if(u<e){const t=this.createTertiaryNode_(d);e<l?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,l=e,i=-1,u=Number.NaN}o=h+1;continue}let m=-1;m=-1===i||d!==this.getDiscriminantIndex1_(i)?this.createTertiaryNode_(d):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&&d===this.getDiscriminantIndex1_(i)||(e<l?this.setLptr_(s,m):this.setRptr_(s,m),this.m_bOfflineDynamic&&this.setPptr_(m,s),-1!==i&&(u<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||(0,i.u)(""),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;return s=t<e?t+(e-t>>1)+2:-(t+2),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 X).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&&j.isLeft_(t)&&j.isRight_(e)?-1:1}))}getValue_(t){if(!this.m_bEnvelopesRef){const e=this.m_intervals[t>>1];return j.isLeft_(t)?e.vmin:e.vmax}const e=this.m_envelopesRef[t>>1];return j.isLeft_(t)?e.xmin:e.xmax}}class Z{constructor(t,e,s){this.m_query=n.E.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(0,i.b)("should not be called"),!1}resetIterator(t,e){if("number"==typeof t){const s=new n.E;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||(0,i.u)(""),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&&j.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&&j.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&&j.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 Q{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 I(0),this.m_sortedEndIndicesBlue=new I(0),this.m_queuedListRed=-1,this.m_queuedListBlue=-1,this.m_queuedEnvelopes=new O,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||(0,i.u)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(new o(e))}endConstruction(){this.m_bAddRedRed||(0,i.u)(""),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||(0,i.u)(""),this.m_elementsRed.push(t),this.m_envelopesRed.push(e.clone())}endRedConstruction(){this.m_bAddRed||(0,i.u)(""),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||(0,i.u)(""),this.m_elementsBlue.push(t),this.m_envelopesBlue.push(e.clone())}endBlueConstruction(){this.m_bAddBlue||(0,i.u)(""),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}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 j(!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_(){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 j(!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,this.m_sortedEndIndicesRed.size(),!0),this.m_sweepIndexRed=this.m_sortedEndIndicesRed.size(),-1!==this.m_queuedListRed&&(this.m_queuedEnvelopes.deleteList(this.m_queuedListRed),this.m_queuedIndicesRed.length=0,this.m_queuedListRed=-1),this.m_function=this.sweepRedBlue_,this.resetBlue_()}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 j(!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 j(!0)),this.m_intervalTreeBlue||(this.m_intervalTreeBlue=new j(!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=n.E.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=n.E.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=n.E.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(0,i.b)("should not be called"),!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 X).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}}var K=g;class J{constructor(t,e){this.tolerance=void 0!==t?t:Number.NaN,this.resolution=void 0!==e?e:Number.NaN}add(t){return new J(this.tolerance+t,this.resolution)}scale(t){return new J(this.tolerance*t,this.resolution*t)}total(){return this.tolerance+this.resolution}}function $(t,e,s,i,r){const o=i*i,a=t.sub(e),h=s.sub(e),m=a.sqrLength(),l=h.sqrLength();if(m<=o||l<=o)return!0;const u=(0,n.e)(a.crossProduct(h));return(u<=o*m||u<=o*l)&&a.dotProduct(h)>=0}function tt(t,e,s){return i=>0===s?(i+t)*e:1*(i-t*e)/e}function et(t,e){const s=new o;return t.queryLooseEnvelope(s),s.mergeEnvelope2D(e),s}function st(t,e){const s=o.constructEmpty();t.queryLooseEnvelope(s);const i=o.constructEmpty();return e.queryLooseEnvelope(i),s.mergeEnvelope2D(i),s}function it(t,e){return(Number.isFinite(t)||Number.isNaN(t))&&(Number.isFinite(e)||Number.isNaN(e))}function nt(t,e){return Number.isFinite(t)&&Number.isFinite(e)}function rt(t,e,s){const i=o.constructEmpty();return i.setFromPoints(t,e),ct(0,null,i.calculateToleranceFromEnvelope(),s,!1)}function ot(t,e,s){return ct(0,t,e.calculateToleranceFromEnvelope(),s,!1)}function at(t,e,s){return ct(1,t,e.calculateToleranceFromEnvelope(),s,!1)}function ht(t,e,s){return at(t,e.queryInterval(1,0),s)}function mt(t,e,s){const i=o.constructEmpty();return e.queryEnvelope(i),ot(t,i,s)}function lt(t,e,s=!1){return ct(0,t,e.calculateToleranceFromEnvelope(),s,!0).total()}function ut(t,e,s){const i=o.constructEmpty();return e.queryEnvelope(i),lt(t,i,s)}function ct(t,e,s,i,n){const r=new J(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)}return i&&(s*=4,r.tolerance*=1.01,r.resolution*=1.01),r.total()<s?new J(s,0):r}function gt(t){return Math.sqrt(2)*(2*t.tolerance+t.resolution)}function _t(t){return Math.sqrt(2)*(t.tolerance+t.resolution)}function dt(t){return t>=3}function pt(t,e){return t.getImpl().getIsSimple(e,[0])>=3}function ft(t,e){t.getImpl().setIsSimple(3,e)}function xt(t,e,s,i){if((0,n.e)(e.x-t.x)+(0,n.e)(e.y-t.y)<=s*s){const s=t.z,r=e.z;return(0,n.R)(s,r,i)}return!1}function yt(t){return t>=4}function Pt(t,e){return t===i.G.enumPolygon?dt(e):e>=1}function Et(t,e,s){const i=o.constructEmpty(),n=o.constructEmpty();t.queryLooseEnvelope(i),e.queryLooseEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=o.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const a=t.querySegmentIterator(),h=e.querySegmentIterator(),m=o.constructEmpty(),l=o.constructEmpty(),u=new Q;u.setTolerance(s);let c=!1;for(u.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(m),m.isIntersecting(r)&&(c=!0,u.addRedEnvelope(a.getStartPointIndex(),m));if(u.endRedConstruction(),!c)return null;let g=!1;for(u.startBlueConstruction();h.nextPath();)for(;h.hasNextSegment();)h.nextSegment().queryLooseEnvelope(l),l.isIntersecting(r)&&(g=!0,u.addBlueEnvelope(h.getStartPointIndex(),l));return u.endBlueConstruction(),g?u:null}function Ct(t,e,s,i,n){t.getGeometryType(),e.getGeometryType();const r=o.constructEmpty(),a=o.constructEmpty();t.queryLooseEnvelope(r),e.queryLooseEnvelope(a),r.inflateCoords(s,s),a.inflateCoords(s,s);const h=o.constructEmpty();h.setCoords({env2D:r}),h.intersect(a);const m=new Q;m.setTolerance(s);let l=!1;m.startRedConstruction();for(let e=0,s=t.getPathCount();e<s;e++)t.queryLoosePathEnvelope(e,r),r.isIntersecting(h)&&(l=!0,m.addRedEnvelope(e,r));if(m.endRedConstruction(),!l)return null;let u=!1;m.startBlueConstruction();for(let t=0,s=e.getPathCount();t<s;t++)e.queryLoosePathEnvelope(t,a),a.isIntersecting(h)&&(u=!0,m.addBlueEnvelope(t,a));return m.endBlueConstruction(),u?m:null}function vt(t,e,s){const i=o.constructEmpty(),n=o.constructEmpty();t.queryLooseEnvelope(i),e.queryEnvelope(n),i.inflateCoords(s,s),n.inflateCoords(s,s);const r=o.constructEmpty();r.setCoords({env2D:i}),r.intersect(n);const a=t.querySegmentIterator(),h=new Q;h.setTolerance(s);let m=!1;for(h.startRedConstruction();a.nextPath();)for(;a.hasNextSegment();)a.nextSegment().queryLooseEnvelope(i),i.isIntersecting(r)&&(m=!0,h.addRedEnvelope(a.getStartPointIndex(),i));if(h.endRedConstruction(),!m)return null;let l=!1;h.startBlueConstruction();for(let t=0,s=e.getPointCount();t<s;t++){const s=e.getXY(t);r.contains(s)&&(l=!0,h.addBlueEnvelope(t,o.construct(s.x,s.y,s.x,s.y)))}return h.endBlueConstruction(),l?h:null}function bt(t,e,s){const i=o.constructEmpty(),r=o.constructEmpty();t.queryEnvelope(i),e.queryEnvelope(r),i.inflateCoords(s,s),r.inflateCoords(s,s);const a=o.constructEmpty();a.setCoords({env2D:i}),a.intersect(r);const h=new Q;h.setTolerance(s);let m=!1;h.startRedConstruction();const l=new n.P;for(let e=0,s=t.getPointCount();e<s;e++)t.queryXY(e,l),a.contains(l)&&(m=!0,h.addRedEnvelope(e,o.construct(l.x,l.y,l.x,l.y)));if(h.endRedConstruction(),!m)return null;let u=!1;h.startBlueConstruction();const c=new n.P;for(let t=0,s=e.getPointCount();t<s;t++)e.queryXY(t,c),a.contains(c)&&(u=!0,h.addBlueEnvelope(t,o.construct(c.x,c.y,c.x,c.y)));return h.endBlueConstruction(),u?h:null}function St(t,e){if(!e){const e=new o;t.queryLooseEnvelope(e);const s=new H(e,8);let n=-1;const r=new o,a=t.querySegmentIterator();let h=!1;for(;a.nextPath();)for(;a.hasNextSegment();){const o=a.nextSegment(),m=a.getStartPointIndex();if(o.queryLooseEnvelope(r),n=s.insertEx(m,r,n),-1===n){h&&(0,i.b)(""),e.assign(t.calculateEnvelope2D(!1)),h=!0,s.reset(e,8),a.resetToFirstPath();break}}return s}const s=new o;t.queryLooseEnvelope(s);const n=new H(s,8);let r=-1;const a=new o,h=t.querySegmentIterator();let m=!1;for(;h.nextPath();)for(;h.hasNextSegment();){const o=h.nextSegment(),l=h.getStartPointIndex();if(o.queryLooseEnvelope(a),a.isIntersecting(e)&&(r=n.insertEx(l,a,r),-1===r)){m&&(0,i.b)(""),s.assign(t.calculateEnvelope2D(!1)),m=!0,n.reset(s,8),h.resetToFirstPath();break}}return n}function It(t,e){if(e){const s=new H(e,8),r=new n.P,a=new o;let h=!1;for(let n=0;n<t.getPointCount();n++)r.setCoordsPoint2D(t.getXY(n)),e.contains(r)&&(a.setCoords({pt:r}),-1!==s.insert(n,a)||(h&&(0,i.b)(""),h=!0,s.reset(t.calculateEnvelope2D(),8),n=-1));return s}return(0,i.a)("no-extent version not yet impl"),null}function wt(t,e,s,i,n){let r=!1;const o=n.vmin,a=n.vmax;for(let n=s;n<e;n+=i){const e=t.read(n);e<o?(r=!0,t.write(n,o)):e>a&&(r=!0,t.write(n,a))}return r}function Dt(t,e,s,n){if(!t.hasAttribute(s))return!1;const r=t.getGeometryType();if(r===i.G.enumGeometryCollection){const i=t,r=i.getGeometryCount();let o=0;for(let t=0;t<r;++t)o|=Dt(i.getGeometry(t),e,s,n)?1:0;return!!o}if((0,i.i)(r)){const r=t,o=K.getPersistence(s),a=K.getComponentCount(s),h=r.getPointCount();if(1===o){const t=wt(r.getAttributeStreamRef(s),h*a,n,a,e);return t&&r.notifyModified(),t}if(2===o){const t=wt(r.getAttributeStreamRef(s),h*a,n,a,e);return t&&r.notifyModified(),t}(0,i.b)("snap_coordinate not implemented")}if(r===i.G.enumEnvelope){const i=t,r=i.queryInterval(s,n);let o=!1;return r.vmin<e.vmin&&(o=!0,r.vmin=e.vmin),r.vmax>e.vmax&&(o=!0,r.vmax=e.vmax),o&&i.setIntervalEnvelope(s,n,r),o}if(r===i.G.enumPoint){const i=t;let r=i.getAttributeAsDbl(s,n),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&i.setAttributeBasic(s,n,r),o}if((0,i.e)(r)){const i=t;let r=i.getStartAttributeAsDbl(s,n),o=!1;return r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&i.setStartAttribute(s,n,r),r=i.getEndAttributeAsDbl(s,n),r<e.vmin&&(o=!0,r=e.vmin),r>e.vmax&&(o=!0,r=e.vmax),o&&i.setEndAttribute(s,n,r),o}(0,i.b)("snap_coordinate not implemented")}var Tt=g;class Nt{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=V(),void this.setXY(t.pt)):void("x"in t&&("z"in t?(this.m_description=R(),this.ensureAttributes(),this.setXYZ(new _(t.x,t.y,t.z))):(this.m_description=V(),this.setXYCoords(t.x,t.y))));t.copy.copyTo(this)}else this.m_description=V()}assignCopy(t){return this.m_attribs=null,t.copyTo(this),this}assignMove(t){return this.m_attribs=null,t.copyTo(this),t.setEmpty(),this}getXY(){return new n.P(this.x,this.y)}queryXY(t){t.x=this.x,t.y=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 _;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]:Tt.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 this.getAttributeAsInt(3,0)}setID(t){this.setAttributeBasic(3,0,t)}isEqualXY(t,e){return void 0===e&&(e=0),Math.abs(t.x-this.x)<=e&&Math.abs(t.y-this.y)<=e}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;(0,i.w)("")}const s=Tt.getComponentCount(t);(e<0||e>=s)&&(0,i.w)("");const n=this.m_description.getAttributeIndex(t);return n>=0?this.m_attribs[this.m_description.getPointAttributeOffset(n)-2+e]:Tt.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:(0,i.w)(""));const n=Tt.getComponentCount(t);(e<0||e>=n)&&(0,i.w)("");let r=this.m_description.getAttributeIndex(t);r<0&&(this.addAttribute(t),r=this.m_description.getAttributeIndex(t)),this.m_attribs[this.m_description.getPointAttributeOffset(r)-2+e]=s}copyAttributesFrom(t,e){if(this===t)return;const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=Tt.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setAttributeBasic(e,s,i)}}}getAttributeArray(){return this.m_attribs}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(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=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}getGeometryType(){return i.G.enumPoint}getDimension(){return 0}queryEnvelope(t){if(t instanceof qt)return t.setEmpty(),t.assignVertexDescription(this.m_description),void t.merge(this);if(t instanceof d){if(this.isEmpty())return void t.setEmpty();const e=this.getXYZ();return t.xmin=e.x,t.ymin=e.y,t.zmin=e.z,t.xmax=e.x,t.ymax=e.y,void(t.zmax=e.z)}this.isEmpty()?t.setEmpty():(t.xmin=this.x,t.ymin=this.y,t.xmax=this.x,t.ymax=this.y)}queryLooseEnvelope(t){this.queryEnvelope(t)}queryInterval(t,e){const s=new n.E;if(this.isEmpty())return s.setEmpty(),s;const i=this.getAttributeAsDbl(t,e);return s.vmin=i,s.vmax=i,s}applyTransformation(t){if(!this.isEmpty()){if(1===t.m_TransformationType){const e=this.getXY();return t.transformInPlace(e),void this.setXY(e)}(0,i.a)("3d not impl")}}transformAttribute(t,e,s,i,n){if(this.isEmpty())return;this.addAttribute(t);const r=this.getAttributeAsDbl(t,e),o=tt(s,i,n);this.setAttributeBasic(t,e,o(r))}createInstance(){return new Nt({vd:this.m_description})}copyTo(t){if(this===t)return;t.getGeometryType()!==i.G.enumPoint&&(0,i.t)();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=V(),this.releaseAttributes()),this.x=Number.NaN,this.y=Number.NaN,this.m_attribs&&(0,n.D)(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()!==i.G.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 t=0,i=this.m_description.getTotalComponentCount()-2;t<i;t++)if(!(0,n.R)(this.m_attribs[t],s.m_attribs[t],e))return!1;return!0}getBoundary(){return null}clone(){const t=new Nt({vd:this.m_description});return this.copyTo(t),t}swap(t){if(this===t)return;t.getGeometryType()!==i.G.enumPoint&&(0,i.t)("wrong geometry type");const e=t;e.m_description=(0,n.b)(this.m_description,this.m_description=e.m_description),e.x=(0,n.b)(this.x,this.x=e.x),e.y=(0,n.b)(this.y,this.y=e.y),e.m_attribs=(0,n.b)(this.m_attribs,this.m_attribs=e.m_attribs)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=Tt.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getAttributeAsDbl(t,i);Number.isNaN(s)&&this.setAttributeBasic(t,i,e)}}lerp(t,e,s){if(t.getDescription()!==e.getDescription()&&(0,i.t)("Point.lerp"),this.assignVertexDescription(t.getDescription()),t.isEmpty()||e.isEmpty())return this.setEmpty(),this;this.ensureAttributes();const r=c();t.queryValues(r,r.length);const o=c();e.queryValues(o,o.length);const a=c();let h=r,m=o;const l=a;let u=0;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),i=Tt.getInterpolation(e),r=Tt.getComponentCount(e),o=Tt.getDefaultValue(e);(0,n.U)(i,h,m,l,u,r,s,o),h=h.slice(r),m=m.slice(r),u+=r}return this.setValues(a,u),this}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(this.m_attribs?(0,n.D)(this.m_attribs,this.m_description.getDefaultPointAttributes(),0,2,t):this.m_attribs=this.m_description.getDefaultPointAttributes().slice(2))}static sqrDistance2D(t,e){return n.P.sqrDistanceCoords(t.x,t.y,e.x,e.y)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=G(this.getDescription(),t);this.assignVertexDescription(e)}releaseAttributes(){this.m_attribs=null}assignVertexDescriptionImpl(t){this.m_description||(this.m_description=V());const e=N();Y(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=Tt.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){const s=this.m_description.getTotalComponentCount();(0,i.g)(s<=e),t[0]=this.x,t[1]=this.y,(0,n.D)(t,this.m_attribs,2,0,s-2)}copyCommonAttributesTo(t){t.x=this.x,t.y=this.y;const e=t.getDescription();if(e===this.m_description)this.m_attribs&&(0,n.D)(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=Tt.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=Tt.getDefaultValue(n);for(;0!==r;)t.m_attribs[s++]=e,r--}}}}setValues(t,e){const s=this.m_description.getTotalComponentCount();(0,i.g)(s<=e),this.x=t[0],this.y=t[1],(0,n.D)(this.m_attribs,t,0,2,s-2)}dbgDefaultAttribs(){}}Nt.type=i.G.enumPoint;var At=g;function Mt(t,e){return e*(t.getTotalComponentCount()-2)}class Gt{constructor(t){if(this.m_attributes=null,t)if(void 0!==t.xmin)this.m_envelope2D=new o(t.xmin,t.ymin,t.xmax,t.ymax);else if(void 0!==t.env2D)this.m_envelope2D=new o(t.env2D);else if(t.move)this.m_envelope2D=new o(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 o(e.m_envelope2D),this.m_attributes=e.m_attributes,e.m_attributes=null}}else this.m_envelope2D=o.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(t,e){const s=e,r=t.getTotalComponentCount()-2;if(s.m_description!==t&&(s.releaseAttributes_(),s.m_description=t,r&&(s.m_data.m_attributes=new Array(2*r))),r){(0,i.g)(this.m_attributes&&s.m_data.m_attributes);const t=2*r;(0,n.D)(s.m_data.m_attributes,this.m_attributes,0,0,t)}s.m_data.m_envelope2D=new o(this.m_envelope2D)}copyToIfNotNull(t,e){e.m_envelope2D=new o(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()}transformAttribute(t,e,s,n,r){(0,i.g)(0)}queryInterval(t,e,s,n){if(this.isEmpty())return void n.setEmpty();if(0===e)return void(0===s?this.m_envelope2D.queryIntervalX(n):1===s?this.m_envelope2D.queryIntervalY(n):(0,i.w)(""));const r=At.getComponentCount(e);(s<0||s>=r)&&(0,i.w)("");const o=t.getAttributeIndex(e);if(o>=0)return n.vmin=this.m_attributes[Mt(t,0)+t.getPointAttributeOffset(o)-2+s],void(n.vmax=this.m_attributes[Mt(t,1)+t.getPointAttributeOffset(o)-2+s]);{const t=At.getDefaultValue(e);return void n.setCoords(t,t)}}queryEnvelope3D(t,e){const s=new n.E;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 qt{constructor(t){if(this.m_EnvelopeType=4,this.m_description=V(),void 0===t)this.m_data=new Gt;else if(void 0!==t.vd)this.m_description=t.vd,this.m_data=new Gt,this.ensureAttributes_();else if(t?.env2D)this.m_data=new Gt({env2D:t.env2D});else if(void 0!==t.xmin)this.m_data=new Gt({xmin:t.xmin,ymin:t.ymin,xmax:t.xmax,ymax:t.ymax});else if(t.copy)this.m_data=new Gt,t.copy.copyTo(this);else if(t.move)this.m_description=t.move.m_description,t.move.m_description=null,this.m_data=new Gt({move:t.move.m_data});else{if(!t.centerPoint)throw new Error("unrecognized Envelope constructor options");this.m_description=t.centerPoint.getDescription(),this.m_data=new Gt,this.ensureAttributes_(),this.setFromPoint(t.centerPoint,t.width,t.height)}}accessEnvelopeData(){return this.m_description=null,this.m_data}assignMove(t){return this===t||(this.m_description=t.m_description,t.m_description=null,this.m_data=new Gt({move:t.m_data})),this}assignCopy(t){return this===t||t.copyTo(this),this}transformAttribute(t,e,s,n,r){(0,i.g)(0)}setAttributeBasic(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const i=this.queryInterval(t,e);i.vmin=s,i.vmax=s,this.setIntervalEnvelope(t,e,i)}mergeVertexDescriptionImpl(t){const e=G(this.getDescription(),t);this.assignVertexDescription(e)}asEnvelope2D(){return new o(this.m_data.m_envelope2D)}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}getGeometryType(){return i.G.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()}getCenterXY(){return this.m_data.isEmpty()?new n.P:this.m_data.m_envelope2D.getCenter()}getCenter(t){if(t.assignVertexDescription(this.m_description),this.m_data.isEmpty())return void t.setEmpty();const e=this.m_description.getAttributeCount();for(let s=1;s<e;s++){const e=this.m_description.getSemantics(s),i=At.getComponentCount(e);for(let s=0;s<i;s++){const i=.5*(this.getAttributeAsDblImpl(0,e,s)+this.getAttributeAsDblImpl(1,e,s));t.setAttributeBasic(e,s,i)}}t.setXY(this.m_data.m_envelope2D.getCenter())}setCoords(t,e,s,i){this.m_data.m_envelope2D.setCoords({xmin:t,ymin:e,xmax:s,ymax:i})}setEnvelope(t){if(t instanceof o)this.m_data.m_envelope2D=new o(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=n.E.constructEmpty();e.setCoords(t.zmin,t.zmax),this.setInterval(1,0,e.vmin,e.vmax)}}merge(t){if(t instanceof o)return t.isValid()||(0,i.t)(""),void this.m_data.m_envelope2D.mergeEnvelope2D(t);if(t instanceof qt){if(t.m_data.isEmpty())return;const e=t.getDescription();this.mergeVertexDescription(e),this.m_data.m_envelope2D.mergeEnvelope2D(t.m_data.m_envelope2D);for(let s=1,i=e.getAttributeCount();s<i;s++){const i=e.getSemantics(s),n=At.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.merge(s),this.setIntervalEnvelope(i,e,n)}}}else if(t instanceof Nt){const e=t;if(e.isEmpty())return;const s=e.getDescription();if(this.mergeVertexDescription(s),this.m_data.isEmpty())return void this.setFromPoint(e);this.m_data.m_envelope2D.merge(e.getXY());for(let t=1,i=s.getAttributeCount();t<i;t++){const i=s.getSemantics(t),n=At.getComponentCount(i);for(let t=0;t<n;t++){const s=e.getAttributeAsDbl(i,t),n=this.queryInterval(i,t);n.mergeCoordinate(s),this.setIntervalEnvelope(i,t,n)}}}else(0,i.a)("unrecognized type for envelope.merge")}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 e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=At.getComponentCount(s);for(let e=0;e<i;e++){const i=t.queryInterval(s,e),n=this.queryInterval(s,e);n.intersect(i),this.setIntervalEnvelope(s,e,n)}}return!0}intersectCommonAttributes(t){if(!this.m_data.m_envelope2D.intersect(t.m_data.m_envelope2D))return this.setEmpty(),!1;const e=t.getDescription();for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s);if(!e.hasAttribute(i))continue;const n=At.getComponentCount(i);for(let e=0;e<n;e++){const s=t.queryInterval(i,e),n=this.queryInterval(i,e);n.intersect(s),this.setIntervalEnvelope(i,e,n)}}return!0}move(t,e){this.m_data.m_envelope2D.move(t,e)}centerAt(t,e){this.m_data.m_envelope2D.centerAtCoords(t,e)}centerAtPoint(t){this.m_data.m_envelope2D.centerAt(t)}reaspect(t,e){this.m_data.m_envelope2D.reaspect(t,e)}inflateCoords(t,e){this.m_data.m_envelope2D.inflateCoords(t,e)}containsCoords(t,e){return this.m_data.m_envelope2D.containsCoords(t,e)}contains(t){return this.m_data.m_envelope2D.contains(t)}containsPoint(t){return!t.isEmpty()&&this.m_data.m_envelope2D.contains(t.getXY())}containsEnvelope(t){return this.m_data.m_envelope2D.containsEnvelope(t.m_data.m_envelope2D)}setIntervalEnvelope(t,e,s){if(this.addAttribute(t),this.m_data.isEmpty())return;const r=new n.E(s);if(r.normalize(),0===t){if(r.isEmpty())return void this.setEmpty();0===e?(this.m_data.m_envelope2D.xmin=r.vmin,this.m_data.m_envelope2D.xmax=r.vmax):1===e?(this.m_data.m_envelope2D.ymin=r.vmin,this.m_data.m_envelope2D.ymax=r.vmax):(0,i.w)("")}else this.setAttributeAsDblImpl(0,t,e,r.vmin),this.setAttributeAsDblImpl(1,t,e,r.vmax)}setInterval(t,e,s,i){this.setIntervalEnvelope(t,e,new n.E(s,i))}queryInterval(t,e){const s=new n.E;return this.m_data.queryInterval(this.m_description,t,e,s),s}queryEnvelope(t){2!==t.m_EnvelopeType?3!==t.m_EnvelopeType?4!==t.m_EnvelopeType?(0,i.a)("unrecognized type for queryEnveloper"):this.copyTo(t):this.m_data.queryEnvelope3D(this.m_description,t):t.setCoords({env2D:this.m_data.m_envelope2D})}applyTransformation(t){1!==t.m_TransformationType?(0,i.g)(0):t.transformEnvInPlace(this.m_data.m_envelope2D)}createInstance(){return new qt({vd:this.m_description})}copyTo(t){t!==this&&this.m_data.copyTo(this.m_description,t)}isEmpty(){return this.m_data.isEmpty()}setEmpty(){this.m_description||(this.m_description=V()),this.m_data.setEmpty(this.m_description)}calculateArea2D(){return this.m_data.m_envelope2D.getArea()}calculateLength2D(){return this.m_data.m_envelope2D.getLength()}calculateLength3D(t){return(0,i.g)(0),0}equals(t,e){if(t===this)return!0;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_data.isEmpty()!==s.m_data.isEmpty())return!1;if(this.m_data.isEmpty())return!0;if(void 0===e&&(e=0),Math.abs(this.m_data.m_envelope2D.xmin-s.m_data.m_envelope2D.xmin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymin-s.m_data.m_envelope2D.ymin)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.xmax-s.m_data.m_envelope2D.xmax)>e)return!1;if(Math.abs(this.m_data.m_envelope2D.ymax-s.m_data.m_envelope2D.ymax)>e)return!1;for(let t=0,i=2*(this.m_description.getTotalComponentCount()-2);t<i;t++)if(!(0,n.R)(this.m_data.m_attributes[t],s.m_data.m_attributes[t],e))return!1;return!0}getBoundary(){return(0,i.a)("getBoundary not available in this context. Use the boundary operator with an envelope parameter"),null}clone(){return new qt({copy:this})}swap(t){if(this===t)return;t.getGeometryType()!==i.G.enumEnvelope&&(0,i.t)("wrong geometry type");const e=t;e.m_description=(0,n.b)(this.m_description,this.m_description=e.m_description),e.m_data.m_envelope2D=(0,n.b)(this.m_data.m_envelope2D,this.m_data.m_envelope2D=e.m_data.m_envelope2D),e.m_data.m_attributes=(0,n.b)(this.m_data.m_attributes,this.m_data.m_attributes=e.m_data.m_attributes)}queryCoordinates(t){this.m_data.isEmpty()&&(0,i.t)(""),this.m_data.m_envelope2D.queryCorners(t)}queryCornerByVal(t,e){(t<0||t>3)&&(0,i.w)(""),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=At.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(t,e){e.assign(this.m_data.m_envelope2D.queryCorner(t))}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=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}queryLooseEnvelope(t){this.queryEnvelope(t)}replaceNaNs(t,e){if(this.addAttribute(t),this.m_data.isEmpty())return;const s=At.getComponentCount(t);for(let i=0;i<s;i++){const s=this.queryInterval(t,i);s.isEmpty()&&(s.vmin=e,s.vmax=e,this.setIntervalEnvelope(t,i,s))}}getImpl(){return this}setFromPoint(t,e,s){this.m_data.m_envelope2D.setCoords({center:t.getXY(),width:e??0,height:s??0});const i=t.getDescription();for(let e=1,s=i.getAttributeCount();e<s;e++){const s=i.getSemantics(e),n=At.getComponentCount(s);for(let e=0;e<n;e++){const i=t.getAttributeAsDbl(s,e);this.setInterval(s,e,i,i)}}}assignVertexDescriptionImpl(t){const e=N();Y(t,this.m_description,e);let s=null;const i=t.getTotalComponentCount()-2,r=this.m_description?this.m_description.getTotalComponentCount()-2:0;i>0&&(s=new Array(2*i),s.fill(Number.NaN));for(let o=1;o<t.getAttributeCount();o++){const a=e[o];if(-1!==a){const e=t.getPointAttributeOffset(o)-2,h=At.getComponentCount(t.getSemantics(o)),m=this.m_description.getPointAttributeOffset(a)-2;(0,n.D)(s,this.m_data.m_attributes,e,m,h),(0,n.D)(s,this.m_data.m_attributes,i+e,r+m,h)}}this.releaseAttributes_(),this.m_data.m_attributes=s,this.m_description=t}getAttributeAsDblImpl(t,e,s){if(this.m_data.isEmpty()&&(0,i.y)(""),0===e)return t?s?this.m_data.m_envelope2D.ymax:this.m_data.m_envelope2D.xmax:s?this.m_data.m_envelope2D.ymin:this.m_data.m_envelope2D.xmin;s>=At.getComponentCount(e)&&(0,i.w)("");const n=this.m_description.getAttributeIndex(e);return n>=0?this.m_data.m_attributes[Mt(this.m_description,t)+this.m_description.getPointAttributeOffset(n)-2+s]:g.getDefaultValue(e)}setAttributeAsDblImpl(t,e,s,n){0===e&&(t?1===s?this.m_data.m_envelope2D.ymax=n:0===s?this.m_data.m_envelope2D.xmax=n:(0,i.w)(""):1===s?this.m_data.m_envelope2D.ymin=n:0===s?this.m_data.m_envelope2D.xmin=n:(0,i.w)(""));const r=At.getComponentCount(e);(s<0||s>=r)&&(0,i.w)(""),this.addAttribute(e);const o=this.m_description.getAttributeIndex(e);this.m_data.m_attributes[Mt(this.m_description,t)+this.m_description.getPointAttributeOffset(o)-2+s]=n}releaseAttributes_(){this.m_data.releaseAttributes()}ensureAttributes_(){this.m_data.ensureAttributes(this.m_description)}}qt.type=i.G.enumEnvelope;class Ft{constructor(){this.posStream=null,this.streams=null}get(t){return t>0?this.streams[t-1]:this.posStream}set(t,e){t>0?this.streams[t-1]=e:this.posStream=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.posStream=null}swap(t){[this.streams,t.streams]=[t.streams,this.streams],[this.posStream,t.posStream]=[t.posStream,this.posStream]}empty(){return null===this.posStream&&null===this.streams}}function Vt(t,e){let s=(0,n.V)(t);const i=e.length/(0,n.o)();for(let t=0;t<e.length;++t){const t=Math.trunc(s*i);s=(0,n.V)(s);const r=Math.trunc(s*i),o=e[t];e[t]=e[r],e[r]=o}}var Rt=g;const Yt="can not assign an empty point to a vertex";class Xt{constructor(t){if(this.m_accelerators=null,void 0!==t&&t.move)this.m_description=t.move.m_description,t.move.m_description=V(),this.m_vertexAttributes=t.move.m_vertexAttributes,t.move.m_vertexAttributes=new Ft,this.m_envelopeData=t.move.m_envelopeData,t.move.m_envelopeData=new Gt,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:V();this.m_description=e,this.m_vertexAttributes=new Ft,this.m_envelopeData=new Gt,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(!(0,i.i)(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 n=this.getPointCount();if(n!==s.getPointCount())return!1;for(let t=0;t<this.m_description.getAttributeCount();t++){const i=this.m_description.getSemantics(t),r=this.getAttributeStreamRef(i),o=s.getAttributeStreamRef(i),a=Rt.getComponentCount(i);if(!r.equals(o,0,n*a,e))return!1}if(e){if(!this.equalsImplTol(t,e))return!1}else if(!this.equalsImpl(t))return!1;return!0}transformAttribute(t,e,s,n,r){this.addAttribute(t),this.isEmpty()||0===s&&1===n||(function(t,e,s,n,r){(e<0||s<0||n<1||e+n*(s-1)+1>t.size())&&(0,i.t)("Index out of bound");for(let i=e,o=e+n*(s-1)+1;i<o;i+=n)t.writeAsDbl(i,r(t.readAsDbl(i)))}(this.getAttributeStreamRef(t),e,this.getPointCount(),Rt.getComponentCount(t),tt(s,n,r)),this.notifyModified())}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}mergeVertexDescriptionImpl(t){const e=G(this.getDescription(),t);this.assignVertexDescription(e)}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=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}getAttributeStreamRef(t){this.throwIfEmpty(),this.m_description.hasAttribute(t)||(0,i.t)("AttributeStream : Geometry does not have the attribute");const e=this.m_description.getAttributeIndex(t);return this.m_vertexAttributes.get(e)}setAttributeStreamRef(t,e){e||(0,i.t)("stream"),e&&Rt.getPersistence(t)!==e.getPersistence()&&(0,i.t)(""),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 e=0;e<this.m_description.getAttributeCount();e++){const i=this.m_description.getSemantics(e);for(let n=0,r=Rt.getComponentCount(i);n<r;n++){const o=this.m_vertexAttributes.get(e).readAsDbl(r*t+n);s.setAttributeBasic(i,n,o)}}}setPointByVal(t,e){const s=e;s.isEmpty()&&(0,i.t)(Yt);const n=s.getDescription();n!==this.m_description&&this.mergeVertexDescription(n);const r=this.m_vertexAttributes.get(0);r.write(2*t,s.getX()),r.write(2*t+1,s.getY());for(let e=1,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),n=Rt.getComponentCount(i);for(let r=0;r<n;r++){const o=s.getAttributeAsDbl(i,r);this.m_vertexAttributes.get(e).writeAsDbl(t*n+r,o)}}this.notifyModifiedFlags(2001)}setPointByValFromArray(t,e,s,n){(0,i.g)(0)}getPointByValAsArray(t,e,s,n){(0,i.g)(0)}isEmpty(){return this.isEmptyImpl()}isEmptyImpl(){return 0===this.m_pointCount}getAttributeAsDbl(t,e,s){const n=Rt.getComponentCount(t);s>=n&&(0,i.w)("");const r=this.m_description.getAttributeIndex(t);return r>=0?this.m_vertexAttributes.get(r).readAsDbl(e*n+s):Rt.getDefaultValue(t)}queryAttributeAsDbl(t,e,s,n){const r=Rt.getComponentCount(t);n<r&&(0,i.w)("");const o=this.m_description.getAttributeIndex(t);if(o>=0){const t=e*r,i=this.m_vertexAttributes.get(o);for(let e=0;e<r;e++)s[e]=i.readAsDbl(t+e)}else{const e=Rt.getDefaultValue(t);for(let t=0;t<r;t++)s[t]=e}}getAttributeAsInt(t,e,s){return Math.trunc(this.getAttributeAsDbl(t,e,s))}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}setAttribute(t,e,s,n){const r=Rt.getComponentCount(t);s>=r&&(0,i.w)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001),this.m_vertexAttributes.get(o).writeAsDbl(e*r+s,n)}setAttributeFromArray(t,e,s,n){(e<0||e>=this.m_pointCount)&&(0,i.w)("");const r=Rt.getComponentCount(t);n!==r&&(0,i.w)(""),this.addAttribute(t);const o=this.m_description.getAttributeIndex(t);this.notifyModifiedFlags(2001);const a=this.m_vertexAttributes.get(o);for(let t=0;t<r;++t)a.writeAsDbl(e*r+t,s[t])}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=_.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=Rt.getDefaultValue(1),s}setXYZ(t,e){this.addAttribute(1),this.notifyModifiedFlags(2001);const s=this.m_vertexAttributes.get(0);s.write(2*t,e.x),s.write(2*t+1,e.y),this.m_vertexAttributes.get(1).write(t,e.z)}queryEnvelope(t){t instanceof o||t instanceof d?this.updateEnvelope(t):(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t))}queryLooseEnvelope(t){this.updateLooseEnvelope(t)}queryInterval(t,e){const s=n.E.constructEmpty();return this.isEmptyImpl()||(this.updateAllDirtyIntervals(!0),this.m_envelopeData.queryInterval(this.m_description,t,e,s)),s}setAttributeBasic(t,e,s){this.setAttributeImpl(t,e,s)}setAttributeImpl(t,e,s){if(this.addAttribute(t),this.isEmpty())return;let i=!1;const n=Rt.getComponentCount(t),r=this.getAttributeStreamRef(t),o=Number.isNaN(s);if(1===r.getPersistence()){const t=r;for(let r=e,a=this.m_pointCount*n;r<a;r+=n){const e=t.read(r);(o||e===s)&&Number.isNaN(e)||(t.write(r,s),i=!0)}}else for(let t=e,o=this.m_pointCount*n;t<o;t+=n)r.readAsDbl(t)!==s&&(r.writeAsDbl(t,s),i=!0);i&&this.notifyModifiedFlags(2001)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;let s=!1;const i=Rt.getComponentCount(t),n=this.getAttributeStreamRef(t);for(let t=0;t<i;t++)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,r=this.m_pointCount*i;t<r;t++){const i=n.readAsDbl(t);Number.isNaN(i)&&(n.writeAsDbl(t,e),s=!0)}s&&this.notifyModifiedFlags(2001)}calculateLength3D(t){return(0,i.g)(0),0}setEnvelopeForImport(t){this.m_description.equals(t.getDescription())||(0,i.t)(""),this.m_envelopeData=new Gt({moveEnv:t}),this.setDirtyFlagProtected(192,!1)}copyTo(t){t.getGeometryType()!==this.getGeometryType()&&(0,i.t)(""),this!==t&&this.copyToUnchecked(t,!1)}queryCoordinates(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.t)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);for(let e=2*s,i=2*r,n=0;e<i;e+=2,n++)o.queryPoint2D(e,t[n]);return r}queryCoordinates3D(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.t)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=Rt.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let l=0;for(let e=s;e<r;e++,l++)t[l].x=o.read(2*e),t[l].y=o.read(2*e+1),t[l].z=m?a.read(e):h;return r}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;return 1&i||(s=(14&i)>>1,e[0]=n,n<t&&(s=-1)),s}setIsSimple(t,e,s=!1){if(2===t?(0,i.g)(this.getGeometryType()===i.G.enumPolyline):1===t?(0,i.g)(this.getGeometryType()===i.G.enumMultiPoint||this.getGeometryType()===i.G.enumPolyline):3===t&&(0,i.g)(this.getGeometryType()===i.G.enumPolygon),-1===t)this.setDirtyFlagProtected(17,!0);else{let i=t<<1;s||(i|=16);const n=31;this.clearAndSetDirtyFlagProtected(n,i),this.m_simpleTolerance!==e&&(this.m_simpleTolerance=e)}}attributeStreamIsAllocated(t){this.throwIfEmpty();const e=this.m_description.getAttributeIndex(t);return e>=0&&null!==this.m_vertexAttributes.get(e)}capacity(){return-1===this.m_reservedPointCount&&0===this.m_pointCount?0:this.m_reservedPointCount}getDescriptionImpl(){return this.m_description}copyToUnchecked(t,e=!1){e&&this.hasDirtyFlag(32)&&(0,i.z)("Cannot do shallow clone on unprepared geometry");const s=t,n=this.getGeometryType(),r=s.getGeometryType();(0,i.g)(n===r||n===i.G.enumPolygon&&r===i.G.enumPolyline,"failure in copyToUnchcked"),s.clearAccelerators(),s.m_description=this.m_description,s.m_vertexAttributes.destroyAndSetSize(0),s.m_envelopeData.releaseAttributes();const o=this.m_description.getAttributeCount(),a=new Ft;if(!this.m_vertexAttributes.empty()){a.destroyAndSetSize(o);for(let t=0;t<o;t++)if(this.m_vertexAttributes.get(t))if(e)a.set(t,this.m_vertexAttributes.get(t));else{const e=Rt.getComponentCount(this.m_description.getSemantics(t));a.set(t,this.m_vertexAttributes.get(t).restrictedClone(this.getPointCount()*e))}}if(this.m_envelopeData.copyToIfNotNull(this.m_description,s.m_envelopeData),s.m_flags=this.m_flags,s.m_simpleTolerance=this.m_simpleTolerance,n!==r){const t=[0];s.getIsSimple(0,t)>=3?s.setIsSimple(1,t[0]):s.setIsSimple(-1,0)}s.m_vertexAttributes.swap(a),a.destroyAndSetSize(0),s.m_pointCount=this.m_pointCount,s.hasDirtyFlag(32)?((0,i.g)(!e),s.m_reservedPointCount=-1):s.m_reservedPointCount=s.m_pointCount;try{this.copyToImpl(s,e)}catch(t){throw s.setEmpty(),t}s.verifyAllStreamsAfterSizeChange()}buildRasterizedGeometryAccelerator(t,e){return!1}getAccelerators(){return this.m_accelerators}clearAccelerators(){this.m_accelerators&&this.m_accelerators.release(),this.m_accelerators=null}ensureUniqueAccelerators(){if(this.m_accelerators&&!this.m_accelerators.uniqueUse()){const t=this.m_accelerators.clone();this.m_accelerators.release(),this.m_accelerators=t}}interpolateTwoVertices(t,e,s,r){(t<0||t>=this.m_pointCount)&&(0,i.w)(""),(e<0||e>=this.m_pointCount)&&(0,i.w)(""),r.assignVertexDescription(this.m_description);const o=new Array(Rt.maxComponentCount()),a=new Array(Rt.maxComponentCount()),h=c();let m=0;for(let r=0;r<this.m_description.getAttributeCount();r++){const l=this.m_description.getSemantics(r),u=Rt.getInterpolation(l),c=Rt.getComponentCount(l),g=Rt.getDefaultValue(l);this.queryAttributeAsDbl(l,t,o,c),this.queryAttributeAsDbl(l,e,a,c),(0,i.g)(m+c<=25),(0,n.U)(u,o,a,h,m,c,s,g),m+=c}!function(t,e){const s=t.getDescription().getTotalComponentCount();t.setX(e[0]),t.setY(e[1]),(0,n.D)(t.getAttributeArray(),e,0,2,s-2)}(r,h)}getShortestDistance(t,e){return n.P.distance(this.getXY(t),this.getXY(e))}getShortestSqrDistance(t,e){return n.P.sqrDistance(this.getXY(t),this.getXY(e))}resizeImpl(t){if(t<0&&(0,i.t)(),(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)}assignVertexDescriptionImpl(t){if(!this.m_vertexAttributes.empty()){const e=N();Y(t,this.m_description,e);const s=new Ft;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:Math.trunc((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=Rt.getComponentCount(s);i=this.m_vertexAttributes.get(e).size()/n,i<this.m_pointCount&&(this.m_vertexAttributes.get(e).resize(t*n,Rt.getDefaultValue(s)),i=t)}else this.m_vertexAttributes.set(e,y(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 qt({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=Rt.getComponentCount(e),r=this.m_vertexAttributes.get(t);for(let t=0;t<i;t++){const o=new n.E;o.setEmpty();for(let e=0;e<this.m_pointCount;e++){const s=r.readAsDbl(e*i+t);o.mergeCoordinate(s)}s.setIntervalEnvelope(e,t,o)}}(t?this.hasDirtyFlag(192):this.hasDirtyFlag(128))&&(this.m_envelopeData=new Gt({moveEnv:s}),this.clearDirtyIntervalsFlag(t))}}updateXYImpl(t){const e=o.constructEmpty(),s=this.m_vertexAttributes.get(0);return e.mergePointsInterleaved(s,0,this.m_pointCount),e}updateEnvelope3D(t){(0,i.g)(0)}updateLooseEnvelope(t){this.updateAllDirtyIntervals(!1),t instanceof o?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&&(0,i.t)(""),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,P(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,P(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=Rt.getComponentCount(e);null!==this.m_vertexAttributes.get(t)?this.m_vertexAttributes.get(t).resize(s*i):this.m_vertexAttributes.set(t,P(e,s))}this.reserveImplImpl(s,e),this.m_reservedPointCount=s}}reserveRounded(t){t<0&&(0,i.t)(),t=Math.ceil(t),this.reserveImpl(t,!0)}reserveImplImpl(t,e){}throwIfEmpty(){this.isEmptyImpl()&&(0,i.y)("")}}class kt extends Xt{constructor(t){super(t),t&&(t.points?this.addPoints2D(t.points,t.pointsSize,0,-1):t.point&&this.add(t.point))}assignCopy(t){return t.copyTo(this),this}assignMove(t){return t.copyTo(this),t.setEmpty(),this}insertPoint2D(t,e){t>this.getPointCount()&&(0,i.t)("invalid point index"),t<0&&(t=this.getPointCount());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,n=this.m_description.getAttributeCount();i<n;i++){const n=this.m_description.getSemantics(i),r=g.getComponentCount(n);if(0===n)this.m_vertexAttributes.get(i).insert(r*t,e,r*s);else{const e=g.getDefaultValue(n);this.m_vertexAttributes.get(i).insertRange(r*t,e,r,r*s)}}this.notifyModifiedFlags(2001)}insertPoint(t,e){e.isEmpty()&&(0,i.t)(Yt),t<0&&(t=this.getPointCount()),this.mergeVertexDescription(e.getDescription());const s=this.m_pointCount;this.resizeNoInit(this.m_pointCount+1);for(let i=0,n=this.m_description.getAttributeCount();i<n;i++){const n=this.m_description.getSemantics(i),r=g.getComponentCount(n);if(e.hasAttribute(n))this.m_vertexAttributes.get(i).insertAttributes(r*t,e,n,r*s);else{const e=g.getDefaultValue(n);this.m_vertexAttributes.get(i).insertRange(r*t,e,r,r*s)}}this.notifyModifiedFlags(2001)}insertPoints(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.w)(""),t<0&&(t=this.getPointCount()),0===s)return;const n=e[0].getDescription();this.mergeVertexDescription(n);const r=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,o=this.m_description.getAttributeCount();i<o;i++){const o=this.m_description.getSemantics(i),a=g.getComponentCount(o);if(this.m_vertexAttributes.get(i))if(n.hasAttribute(o))this.m_vertexAttributes.get(i).insertAttributesFromPoints(t*a,e,s,o,r*a);else{const e=g.getDefaultValue(o);this.m_vertexAttributes.get(i).insertRange(a*t,e,a*s,a*r)}}this.notifyModifiedFlags(2001)}insertPoints2D(t,e,s){if((t>this.getPointCount()||s<0)&&(0,i.t)("invalid point index"),t<0&&(t=this.getPointCount()),0===s)return;const n=this.m_pointCount;this.resizeNoInit(this.m_pointCount+s);for(let i=0,r=this.m_description.getAttributeCount();i<r;i++){const r=this.m_description.getSemantics(i),o=g.getComponentCount(r);if(this.m_vertexAttributes.get(i))if(0===r)this.m_vertexAttributes.get(i).insertRangeFromPoints(o*t,e,0,s,!0,o*n);else{const e=g.getDefaultValue(r);this.m_vertexAttributes.get(i).insertRange(o*t,e,o,o*n)}}this.notifyModifiedFlags(2001)}removePoints(t,e){if((t<0||e<0||t+e>this.getPointCount())&&(0,i.w)("remove_points"),0!==e){for(let s=0,i=this.m_description.getAttributeCount();s<i;s++)if(this.m_vertexAttributes.get(s)){const i=this.m_description.getSemantics(s),n=g.getComponentCount(i);this.m_vertexAttributes.get(s).eraseRange(n*t,n*e,n*this.m_pointCount)}this.m_pointCount-=e,this.m_reservedPointCount>0&&(this.m_reservedPointCount-=e),this.notifyModifiedFlags(2001)}}removePoint(t){for(let e=0,s=this.m_description.getAttributeCount();e<s;e++)if(this.m_vertexAttributes.get(e)){const s=this.m_description.getSemantics(e),i=g.getComponentCount(s);this.m_vertexAttributes.get(e).eraseRange(i*t,i,i*this.m_pointCount)}this.m_pointCount--,this.m_reservedPointCount>0&&this.m_reservedPointCount--,this.notifyModifiedFlags(2001)}calculateEnvelope2D(){return this.updateXYImpl(!0)}resizeNoInit(t){this.resizeImpl(t)}resizeAndInitNonPositionAttributes(t){const e=this.m_pointCount;if(this.resizeImpl(t),this.m_pointCount>e)for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=g.getDefaultValue(s),n=g.getComponentCount(s);this.m_vertexAttributes.get(t).insertRange(n*e,i,n*(this.m_pointCount-e),n*e)}}queryCoordinates3D(t,e,s,n){let r=n<0?this.m_pointCount:n;if(r=Math.min(r,s+e),(s<0||r<s||this.m_pointCount>0&&s>=this.m_pointCount)&&(0,i.t)(""),0===this.m_pointCount)return r;const o=this.getAttributeStreamRef(0);let a=null;const h=g.getDefaultValue(1),m=this.m_description.hasAttribute(1);m&&(a=this.getAttributeStreamRef(1));let l=0;for(let e=s;e<r;e++,l++)t[l].x=o.read(2*e),t[l].y=o.read(2*e+1),t[l].z=m?a.read(e):h;return r}queryAttributeAsInt(t,e,s,n){(0,i.g)(0)}add(t){t.isEmpty()&&(0,i.t)(Yt),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 n.P(t,e);this.setXY(this.m_pointCount-1,s)}addXYZ(t,e,s){this.resizeAndInitNonPositionAttributes(this.m_pointCount+1);const i=new _;i.setCoords(t,e,s),this.setXYZ(this.m_pointCount-1,i)}addPoint2D(t){this.addXY(t.x,t.y)}addPoint3D(t){this.addXYZ(t.x,t.y,t.z)}addPoints(t,e,s){this===t&&(0,i.t)("Multi_point_impl.add");const n=s<0?t.getPointCount():s;if((e<0||e>t.getPointCount()||n<e)&&(0,i.t)(""),e===n)return;const r=t.getDescription();this.mergeVertexDescription(r);const o=n-e,a=this.m_pointCount;this.resizeNoInit(this.m_pointCount+o);for(let s=0,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=g.getComponentCount(i),h=this.getAttributeStreamRef(i);if(r.hasAttribute(i)){const s=t.getAttributeStreamRef(i);h.insertRangeFromStream(a*n,s,e*n,o*n,!0,1,a*n)}else{const t=g.getDefaultValue(i);h.insertRange(a*n,t,o*n,a*n)}}}addPoints2D(t,e,s,n){let r=e;const o=n<0?r:n;if((r<0||s<0||s>r||o<s)&&(0,i.t)(""),s===o)return;r=o-s;const a=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+r);const h=this.getAttributeStreamRef(0);for(let e=0;e<r;++e)h.writePoint2D(2*(a+e),t[s+e]);this.notifyModifiedFlags(2001)}addPoints3D(t,e,s,r){let o=e;const a=r<0?o:r;if((o<0||s<0||s>o||a<s)&&(0,i.t)(""),this.addAttribute(1),s===a)return;o=a-s;const h=this.m_pointCount;this.resizeAndInitNonPositionAttributes(this.m_pointCount+o);const m=this.getAttributeStreamRef(0),l=new n.P;for(let e=0;e<o;e++)l.x=t[s+e].x,l.y=t[s+e].y,m.writePoint2D(2*(h+e),l);const u=this.getAttributeStreamRef(1);for(let e=0;e<o;e++)u.write(h+e,t[s+e].z);this.notifyModifiedFlags(2001)}getGeometryType(){return i.G.enumMultiPoint}getDimension(){return 0}createInstance(){return new kt({vd:this.getDescription()})}setEmpty(){this.setEmptyImpl()}applyTransformation(t){if(this.isEmpty())return;if(t.isIdentity())return;const e=this.m_vertexAttributes.get(0);1===t.m_TransformationType?e.applyTransformation(t,0,this.m_pointCount):(0,i.a)("3d xform not impl"),this.notifyModifiedFlags(2001)}calculateArea2D(){return 0}calculateLength2D(){return 0}calculateLength3D(t){return 0}equals(t,e){return t.getGeometryType()===i.G.enumMultiPoint&&this.equalsBase(t,e)}queryEnvelope(t){4===t.m_EnvelopeType?(this.updateAllDirtyIntervals(!0),this.m_envelopeData.copyTo(this.m_description,t)):2===t.m_EnvelopeType?this.updateEnvelope(t):(0,i.a)("")}getImpl(){return this}getBoundary(){return null}reserve(t){this.reserveImpl(t)}clone(){const t=this.createInstance();return this.copyTo(t),t}swap(t){(0,i.g)(0)}buildQuadTreeAccelerator(t){return!1}getHashCodeImpl(){return(0,i.g)(0),0}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}copyToImpl(t,e){}}kt.type=i.G.enumMultiPoint;class Ht{constructor(){this.m_EnvelopeType=5,this.envAabb=o.constructEmpty(),this.envRot=o.constructEmpty()}static constructEmpty(){return new Ht}width(){return this.envAabb.width()}height(){return this.envAabb.height()}maxDim(){return Math.max(this.width(),this.height())}setEmpty(){this.envAabb.setEmpty(),this.envRot.setEmpty()}setCoords(t){this.envAabb.setCoords(t),this.envRot.setCoords({x:Bt(t),y:Lt(t)})}setFromPoints(t,e){this.setEmpty(),this.mergePoints(t,e)}mergeNe(t){this.envAabb.mergeNe(t),this.envRot.mergeNeCoords(Bt(t),Lt(t))}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=Bt(t[i]),s=Lt(t[i]);this.envRot.mergeNeCoords(e,s)}break}{const e=Bt(t[s]),i=Lt(t[s]);this.envRot.setCoords({x:e,y:i}),s++}}}isIntersectingPoint2D(t){return!(!this.envAabb.contains(t)||!this.envRot.containsCoords(Bt(t),Lt(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*(0,n.X)();this.envRot.inflateCoords(e,e),e<0&&Ht.st_reduceEmpty(this)}static st_reduceEmpty(t){const e=t.envAabb.isEmpty(),s=t.envRot.isEmpty();e&&!s?t.envRot.setEmpty():s&&!e&&t.envAabb.setEmpty()}}function Bt(t){return t.x-t.y}function Lt(t){return t.x+t.y}class zt extends r.G{constructor(t,e){super(),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 Ut{constructor(t){this.m_geoms=[],this.m_description=V(),t&&(t.vd?this.m_description=t.vd:t.copy?t.copy.copyTo(this):(0,i.t)("constructor argument not recognized"))}getGeometryCount(){return this.m_geoms.length}reserve(t){}addGeometry(t){if(t.getGeometryType()===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else this.m_geoms.push(t.clone()),this.mergeVertexDescription(t.getDescription())}addCursor(t){for(let e=t.next();null!==e;e=t.next())this.addGeometry(e)}getGeometry(t){return(t<0||t>=this.m_geoms.length)&&(0,i.t)("Geometry_collection.get_geometry"),this.m_geoms[t]}modifiedElementIndex(t){this.mergeVertexDescription(this.getGeometry(t).getDescription())}modifiedElement(t){this.mergeVertexDescription(t.getDescription())}getGeometryType(){return i.G.enumGeometryCollection}getDimension(){let t=0;for(const e of this.m_geoms)t=Math.max(t,e.getDimension());return t}getDescription(){return this.m_description}assignVertexDescription(t){this.m_description!==t&&this.assignVertexDescriptionImpl(t)}assignVertexDescriptionImpl(t){for(const e of this.m_geoms)e.assignVertexDescription(t);this.m_description=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=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}queryInterval(t,e){let s=new n.E;const i=new n.E;i.setEmpty();for(const n of this.m_geoms)s=n.queryInterval(t,e),i.merge(s);return i}queryEnvelope(t){if(4===t.m_EnvelopeType){const e=new qt;t.setEmpty(),t.assignVertexDescription(this.m_description);for(const s of this.m_geoms)s.queryEnvelope(e),t.merge(e)}else if(2===t.m_EnvelopeType){const e=new o;t.setEmpty();for(const s of this.m_geoms)s.queryEnvelope(e),t.mergeEnvelope2D(e)}(0,i.a)("3d envelope case not implemented")}queryLooseEnvelope(t){if(2===t.m_EnvelopeType){const e=new o;t.setEmpty();for(const s of this.m_geoms)s.queryLooseEnvelope(e),t.mergeEnvelope2D(e)}(0,i.a)("3d not impl")}isEmpty(){return 0===this.m_geoms.length}setEmpty(){this.m_geoms.length=0}applyTransformation(t){if(1===t.m_TransformationType)for(const e of this.m_geoms)e.applyTransformation(t);(0,i.a)("3d xform not impl")}transformAttribute(t,e,s,i,n){for(const r of this.m_geoms)r.transformAttribute(t,e,s,i,n)}createInstance(){return new Ut({vd:this.getDescription()})}copyTo(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.t)("");const e=t;if(e!==this){e.m_geoms.length=0,e.assignVertexDescription(this.m_description);for(const t of this.m_geoms)e.m_geoms.push(t.clone())}}calculateArea2D(){const t=new n.K(0);for(const e of this.m_geoms)t.pe(e.calculateArea2D());return t.getResult()}calculateLength2D(){const t=new n.K(0);for(const e of this.m_geoms)t.pe(e.calculateLength2D());return t.getResult()}calculateLength3D(t){return(0,i.g)(0),0}getBoundary(){const t=this.createInstance(),e=t;for(const t of this.m_geoms){const s=t.getBoundary();s&&e.m_geoms.push(s)}return t}clone(){return new Ut({copy:this})}equals(t,e){if(t===this)return!0;if(t.getGeometryType()!==i.G.enumGeometryCollection)return!1;const s=t;if(this.m_description!==s.m_description)return!1;if(this.m_geoms.length!==s.m_geoms.length)return!1;for(let t=0;t<this.m_geoms.length;++t)if(!this.m_geoms[t].equals(s.m_geoms[t],e))return!1;return!0}swap(t){t.getGeometryType()!==i.G.enumGeometryCollection&&(0,i.t)("");const e=t;e!==this&&(this.m_geoms=(0,n.b)(e.m_geoms,e.m_geoms=this.m_geoms))}setAttributeBasic(t,e,s){for(const i of this.m_geoms)i.setAttributeBasic(t,e,s)}replaceNaNs(t,e){for(const s of this.m_geoms)s.replaceNaNs(t,e)}getImpl(){return this}mergeVertexDescriptionImpl(t){const e=G(this.getDescription(),t);this.assignVertexDescription(e)}}function Ot(t,e=-1){return new zt(t,e)}Ut.type=i.G.enumGeometryCollection;class Wt{constructor(){this.x=n.H.getNAN(),this.y=n.H.getNAN()}static getNAN(){return new Wt}static constructPoint2D(t){const e=new Wt;return e.x.set(t.x),e.y.set(t.y),e}static constructCoords(t,e){const s=new Wt;return s.x.set(t),s.y.set(e),s}static constructCoordsE(t,e){const s=new Wt;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 Wt).setE(this)}scaleThis(t){return this.x.mulThisE(t),this.y.mulThisE(t),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 Wt;return e.setCoordsE(this.x.mulE(t),this.y.mulE(t)),e}mul(t){const e=new Wt;return e.setCoordsE(this.x.mul(t),this.y.mul(t)),e}mulThis(t){return this.x.mulThis(t),this.y.mulThis(t),this}mulThisE(t){return this.x.mulThisE(t),this.y.mulThisE(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=n.ai.clone(),this.y=n.C.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 n.P.construct(this.x.value(),this.y.value())}}class jt{constructor(){this.a11=new n.H(1),this.a12=new n.H(0),this.a21=new n.H(0),this.a22=new n.H(1)}clone(){const t=new jt;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=(0,n.b)(this.a12,this.a12=this.a21),this}eigenSymmetric(t,e){const s=this.a12.clone();s.addThisE(this.a21),s.mulThisByPower2(.5);let i=new n.H(1),r=new n.H(0);if(s.isZero())t[0].setE(this.a11),t[1].setE(this.a22);else{const e=new n.H(1);if(this.a11.ne(this.a22)){const o=this.a11.subE(this.a22).divE(s);o.mulThisByPower2(.5);const a=o.sqr();e.setE(o),e.absThis(),e.subThisE(a.add(1).sqrtThis()),o.gt(n.C)&&e.negateThis();const h=e.sqr().addThis(1).sqrtThis().invThis();r=e.mulE(h),i.setE(h);const m=e.mulE(s);t[0]=this.a11.addE(m),t[1]=this.a22.subE(m)}else i=new n.H(1/Math.sqrt(2)),r=i.clone(),t[0]=this.a11.addE(s),t[1]=this.a22.subE(s)}e[0].x=i.toDouble(),e[0].y=r.toDouble(),e[1].x=r.negate().toDouble(),e[1].y=i.toDouble(),Math.abs(t[0].toDouble())>Math.abs(t[1].toDouble())&&(t[1]=(0,n.b)(t[0],t[0]=t[1]),e[1]=(0,n.b)(e[0],e[0]=e[1]))}setZero(){this.a11.set(0),this.a21.set(0),this.a12.set(0),this.a22.set(0)}}var Zt=g;function Qt(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 Kt(t,e){let s=t.calculateLowerLength2D();return!(s>e)&&(!!t.isLine()||(s=t.calculateUpperLength2D(),s<=e||0!==e&&t.calculateLength2D()<=e))}function Jt(t,e){const s=t.getEndXY().sub(t.getStartXY()).length(),i=t.calculateUpperLength2D()-s<=e[0];return e[0]*=.1,i}function $t(t,e,s,r,o,a,h,m){let l=t.calculateUpperLength2D(),u=e.calculateUpperLength2D(),c=t,g=e,_=!1;l>u&&(g=(0,n.b)(c,c=g),r=(0,n.b)(s,s=r),u=(0,n.b)(l,l=u),_=!0);const d=0===s;{h[0]=d?1:0;const t=c.getCoord2D(h[0]);m[0]=g.getClosestCoordinate(t,!1);const e=g.getCoord2D(m[0]);if(n.P.distance(t,e)<=o){const e=[.5,.75,.25,.1,.9];let s=!0;for(let i=0;i<e.length;i++)if(t.assign(c.getCoord2D(e[i])),!g.isCloserThanDistance(t,new n.E(0,1),o)){s=!1;break}if(s)return _&&(m[0]=(0,n.b)(h[0],h[0]=m[0])),1}}if(l<=3*o)return 0;let p=(0,n.l)(Math.max(o/l,.1),0,.5),f=.01*o,x=0,y=0,P=p,E=-1,C=0,v=1/32;for(let t=0;;t++){(0,i.g)(t<4095);const e=d?p:1-p,s=c.getCoord2D(e),l=g.getClosestCoordinate(s,!1);if(l===r)return C;const u=g.getCoord2D(l),b=n.P.distance(s,u);if(0===t&&(E=b),b<=f?(v=.5,y=b,x=p):(P=p,E=b),Math.abs(y-E)>.1*f&&P-x>1e-16)p=(0,n.w)(x,P,v);else{if(h[C]=e,m[C]=l,_&&(m[C]=(0,n.b)(h[C],h[C]=m[C])),1===a||1===C)return 1===C&&h[0]>h[1]&&(h[1]=(0,n.b)(h[0],h[0]=h[1]),m[1]=(0,n.b)(m[0],m[0]=m[1])),C+1;C++,x=P,y=E,P=.8,E=-1,p=.8,v=1/32,f=10*o,t=0}}}function te(t,e,s,i,r,o,a,h,m){if((0,n.a1)(s,0,1)&&(0,n.a1)(i,0,1)&&0===n.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const m=1e-12,l=new Wt,u=(0,n.aa)();if(t.queryDerivative(new n.H(s,u),l),l.isTrueZero()){const e=1===s?-m:m;t.queryDerivative(new n.H(s,u).add(e),l)}1===s&&l.negateThis();const c=new Wt;if(e.queryDerivative(new n.H(i,u),c),c.isTrueZero()){const t=1===s?-m:m;e.queryDerivative(new n.H(i,u).add(t),c)}1===i&&c.negateThis(),l.isZero()||l.normalize(),c.isZero()||c.normalize();const g=l.dotProduct(c),_=l.crossProduct(c);_.scaleError(3);const d=()=>{{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*r/Math.min(s,i),1e-10)}};if(g.ge(n.C)&&(_.isZero()||Math.abs(_.value())<d()))return $t(t,e,s,i,r,o,a,h)}return 0}function ee(t,e){t.m_XStart=e.x,t.m_YStart=e.y}function se(t,e,s){t.m_XStart=e,t.m_YStart=s}function ie(t,e){t.m_XEnd=e.x,t.m_YEnd=e.y}function ne(t,e,s){t.m_XEnd=e,t.m_YEnd=s}function re(t,e){const s=new _;return e?(s.x=t.m_XEnd,s.y=t.m_YEnd):(s.x=t.m_XStart,s.y=t.m_YStart),s.z=function(t,e){return t.m_description.hasZ()?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)]:Zt.getDefaultValue(1)}(t,e),s}function oe(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 ae(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 i=1;i<t.m_description.getAttributeCount();i++){const n=t.m_description.getSemantics(i);for(let i=0,r=Zt.getComponentCount(n);i<r;i++){const r=me(t,e,n,i);s.setAttributeBasic(n,i,r)}}}function he(t,e,s){s.isEmpty()&&(0,i.y)(""),function(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())}(t,e,s.getXY());const n=s.getDescription();n!==t.m_description&&t.mergeVertexDescription(n);for(let i=1,r=n.getAttributeCount();i<r;i++){const r=n.getSemantics(i),o=Zt.getComponentCount(r);for(let i=0;i<o;i++)le(t,e,r,i,s.getAttributeAsDbl(r,i))}}function me(t,e,s,n){if((e<0||e>1)&&(0,i.w)(""),0===s)return(n<0||n>=2)&&(0,i.w)(""),0===e?0===n?t.m_XStart:t.m_YStart:0===n?t.m_XEnd:t.m_YEnd;const r=Zt.getComponentCount(s);(n<0||n>=r)&&(0,i.w)("");const o=t.m_description.getAttributeIndex(s);return o>=0?t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(o)-2+n]:Zt.getDefaultValue(s)}function le(t,e,s,n,r){if((e<0||e>1)&&(0,i.w)(""),0===s)return 0===e?0===n?t.m_XStart=r:1===n?t.m_YStart=r:(0,i.w)(""):1===e?0===n?t.m_XEnd=r:1===n?t.m_YEnd=r:(0,i.w)(""):(0,i.w)(""),void t.endPointModified();const o=Zt.getComponentCount(s);(n<0||n>=o)&&(0,i.w)("");let a=t.m_description.getAttributeIndex(s);a<0&&(t.addAttribute(s),a=t.m_description.getAttributeIndex(s)),t.m_attributes[e*(t.m_description.getTotalComponentCount()-2)+t.m_description.getPointAttributeOffset(a)-2+n]=r}function ue(t,e){if(t===e)return;e.isEmpty()&&(0,i.y)("");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=Zt.getComponentCount(n);for(let s=0;s<r;s++){let i=me(e,0,n,s);le(t,0,n,s,i),i=me(e,1,n,s),le(t,1,n,s,i)}}}function ce(t){return t.absNorm()*(0,n.O)()}function ge(t,e){return Math.max(t.absNorm(),e.absNorm())*(0,n.O)()}function _e(t,e,s){const i=new Ht;t.queryEnvelopeW(n.E.unit(),i);const r=new Ht;return e.queryEnvelopeW(n.E.unit(),r),r.inflate(s),!i.isIntersectingW(r)}function de(t,e,s){const i=(0,n.aq)(t,s),r=(0,n.aq)(e,s);i.sort(((t,e)=>t.compare(e))),r.sort(((t,e)=>t.compare(e)));for(let t=0;t<3;t++){if(i[t].compare(r[t])<0)return-1;if(0!==i[t].compare(r[t]))return 1}return 0}var pe=g;class fe{constructor(t){if(t.copy)this.m_XStart=t.copy.m_XStart,this.m_YStart=t.copy.m_YStart,this.m_XEnd=t.copy.m_XEnd,this.m_YEnd=t.copy.m_YEnd,this.m_description=t.copy.m_description,this.m_attributes=null,this.m_description&&this.m_description.getTotalComponentCount()-2&&(this.m_attributes=t.copy.m_attributes.slice());else{if(t.move)return this.m_description=t.move.m_description,t.move.m_description=null,this.m_attributes=t.move.m_attributes,t.move.m_attributes=null,this.m_XStart=t.move.m_XStart,this.m_YStart=t.move.m_YStart,this.m_XEnd=t.move.m_XEnd,void(this.m_YEnd=t.move.m_YEnd);if(void 0!==t.XStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_attributes=null,this.m_description=t.vd?t.vd:V(),void(t.vd&&this.setDefaultAttributeValues());if(void 0!==t.ZStart)return this.m_XStart=t.XStart,this.m_YStart=t.YStart,this.m_XEnd=t.XEnd,this.m_YEnd=t.YEnd,this.m_description=t.vd?t.vd:R(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.ZStart,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.ZEnd):this.m_attributes=[t.ZStart,t.ZEnd]);if(t.start)return this.m_XStart=t.start.x,this.m_YStart=t.start.y,this.m_XEnd=t.end.x,this.m_YEnd=t.end.y,this.m_attributes=null,void(this.m_description=V());if(t.start3D)return this.m_XStart=t.start3D.x,this.m_YStart=t.start3D.y,this.m_XEnd=t.end3D.x,this.m_YEnd=t.end3D.y,this.m_description=t.vd?t.vd:R(),void(t.vd?(this.setDefaultAttributeValues(),this.addAttribute(1),this.m_attributes[0]=t.start3D.z,this.m_attributes[this.m_description.getTotalComponentCount()-2]=t.end3D.z):this.m_attributes=[t.start3D.z,t.end3D.z]);(0,i.b)("bad constructor params"),this.m_XStart=this.m_YStart=this.m_XEnd=this.m_YEnd=Number.NaN}}setDefaultAttributeValues(){const t=this.m_description.getTotalComponentCount()-2;t>0&&(null===this.m_attributes&&(this.m_attributes=(0,n.a)(2*t,Number.NaN)),(0,n.D)(this.m_attributes,this.m_description.getDefaultPointAttributes(),0,2,t),(0,n.D)(this.m_attributes,this.m_description.getDefaultPointAttributes(),t,2,t))}absNormXYZ(t){return(0,i.a)("not implemented"),0}snapControlPoints3D(){return(0,i.a)("not implemented"),!1}setCoordsForIntersector3D(t,e,s){(0,i.a)("not implemented")}transformAttribute(t,e,s,n,r){(0,i.a)("")}mergeVertexDescriptionImpl(t){const e=G(this.getDescription(),t);this.assignVertexDescription(e)}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 s=1,i=n.getAttributeCount();s<i;s++){const i=n.getSemantics(s),r=pe.getComponentCount(i);for(let s=0;s<r;s++)le(this,0,i,s,t.getAttributeAsDbl(i,s)),le(this,1,i,s,e.getAttributeAsDbl(i,s))}}getStartXY(){return new n.P(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 re(this,0)}setStartXYZ(t){oe(this,0,t)}setStartXYZCoords(t,e,s){oe(this,0,_.construct(t,e,s))}queryStart(t){ae(this,0,t)}setStart(t){he(this,0,t)}setStart2D(t){this.setStartXY(t)}getStartAttributeAsDbl(t,e){return me(this,0,t,e)}getStartAttributeAsInt(t,e){return(0,i.g)(0),0}setStartAttribute(t,e,s){le(this,0,t,e,s)}setStartAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=pe.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setStartAttribute(e,s,i)}}}setEndAttributesFromPoint(t,e){const s=t.getDescription();for(let i=e&&s.hasZ()?2:1,n=s.getAttributeCount();i<n;++i){const e=s.getSemantics(i),n=pe.getComponentCount(e);for(let s=0;s<n;++s){const i=t.getAttributeAsDbl(e,s);this.setEndAttribute(e,s,i)}}}getStartX(){return this.m_XStart}getStartY(){return this.m_YStart}getStartZ(){return(0,i.g)(0),0}getEndX(){return this.m_XEnd}getEndY(){return this.m_YEnd}getEndZ(){return(0,i.g)(0),0}getEndXY(){return new n.P(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 re(this,1)}setEndXYZ(t){oe(this,1,t)}setEndXYZCoords(t,e,s){oe(this,1,_.construct(t,e,s))}queryEnd(t){ae(this,1,t)}setEnd(t){he(this,1,t)}setEnd2D(t){this.setEndXY(t)}getEndAttributeAsDbl(t,e){return me(this,1,t,e)}getEndAttributeAsInt(t,e){return(0,i.g)(0),Math.trunc(0)}setEndAttribute(t,e,s){le(this,1,t,e,s)}getDimension(){return 1}copyTo(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.t)("");const e=t;e.assignVertexDescription(this.m_description),e.m_attributes&&(0,n.D)(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=n.E.constructEmpty();return s.vmin=me(this,0,t,e),s.vmax=s.vmin,s.mergeNeCoordinate(me(this,1,t,e)),s}calculateLength3D(t){return(0,i.g)(0),0}getCoord3D(t){return(0,i.g)(0),{}}getCoord2D(t){const e=n.P.getNAN();return this.queryCoord2D(t,e),e}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return(0,i.g)(0),0}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=pe.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=o.constructEmpty();if(this.queryLooseEnvelopeOnInterval(e,i),i.distance(t)>s)return!1;const r=this.getClosestCoordinateOnInterval(t,e,s);return!Number.isNaN(r)&&n.P.distance(t,this.getCoord2D(r))<=s}isMonotoneQuickAndDirty(){return!1}isTrue3D(){return!1}getReversed(){const t=this.clone();return t.reverse(),t}reverse(){this.m_XEnd=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(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=pe.getComponentCount(e);t<s;t++){const s=me(this,0,e,t);le(this,0,e,t,me(this,1,e,t)),le(this,1,e,t,s)}}return this.afterCompletedModification(),this}isEmptyImpl(){return!1}isCircular(){return!1}distance(t,e,s,n){if(!e&&this.isIntersecting(t,0,!1)){if(null!==s||null!==n){const e=new Array(9),r=new Array(9),o=this.intersect(t,null,e,r,0);(0,i.g)(o<=9),0===o&&(0,i.b)(""),null!==s&&(s[0]=e[0]),null!==n&&(n[0]=r[0])}return 0}let r,o=Number.MAX_VALUE,a=-1,h=o;return r=this.getStartXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==n&&(n[0]=a),null!==s&&(s[0]=0)),r=this.getEndXY(),a=t.getClosestCoordinate(r,!1),r.subThis(t.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==n&&(n[0]=a),null!==s&&(s[0]=1)),r=t.getStartXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==s&&(s[0]=a),null!==n&&(n[0]=0)),r=t.getEndXY(),a=this.getClosestCoordinate(r,!1),r.subThis(this.getCoord2D(a)),h=r.length(),h<o&&(o=h,null!==s&&(s[0]=a),null!==n&&(n[0]=1)),o}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(0,n.w)(t,e,s)}moveTo(t){const e=this.isClosed(),s=new n.T;s.setShift(t.sub(this.getStartXY())),this.applyTransformation(s),e?this.changeEndPoints2D(t,t):this.changeEndPoints2D(t,this.getEndXY())}moveTo3D(t){(0,i.g)(0)}getDescription(){return this.m_description}assignVertexDescription(t){!function(t,e){const s=N();Y(e,t.m_description,s);let i=null;const r=e.getTotalComponentCount()-2,o=t.m_description?t.m_description.getTotalComponentCount()-2:0;if(r>0&&(i=new Array(2*r),(0,n.D)(i,e.getDefaultPointAttributes(),0,2,r),(0,n.D)(i,e.getDefaultPointAttributes(),r,2,r),null!==t.m_description))for(let n=1;n<e.getAttributeCount();n++){const a=s[n];if(-1!==a){const s=t.m_description.getPointAttributeOffset(a)-2,h=e.getPointAttributeOffset(n)-2,m=Zt.getComponentCount(e.getSemantics(n));for(let e=0;e<m;++e)i[h]=t.m_attributes[s],i[r+h]=t.m_attributes[o+s]}}t.m_attributes=i,t.m_description=e}(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=q(this.m_description,t);this.assignVertexDescription(e)}dropAttribute(t){if(!this.m_description.hasAttribute(t))return;const e=F(this.m_description,t);this.assignVertexDescription(e)}dropAllAttributes(){const t=V();t!==this.m_description&&this.assignVertexDescription(t)}swap(t){if(this===t)return;t.getGeometryType()!==this.getGeometryType()&&(0,i.t)("wrong geometry type");const e=t;e.m_description=(0,n.b)(this.m_description,this.m_description=e.m_description),e.m_XStart=(0,n.b)(this.m_XStart,this.m_XStart=e.m_XStart),e.m_YStart=(0,n.b)(this.m_YStart,this.m_YStart=e.m_YStart),e.m_XEnd=(0,n.b)(this.m_XEnd,this.m_XEnd=e.m_XEnd),e.m_YEnd=(0,n.b)(this.m_YEnd,this.m_YEnd=e.m_YEnd),e.m_attributes=(0,n.b)(this.m_attributes,this.m_attributes=e.m_attributes),this.swapImpl(e)}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 t=0,s=2*(this.m_description.getTotalComponentCount()-2);t<s;t++)if(!(0,n.R)(this.m_attributes[t],i.m_attributes[t],e))return!1;return s?this.equalsImpl(i):this.equalsImplTol(i,e)}getImpl(){return this}setAttributeBasic(t,e,s){if(this.addAttribute(t),0===t&&this.isCurve()){(e<0||e>1)&&(0,i.t)("");const t=new n.T,r=0===e?s:0,o=1===e?s:0;t.setShiftCoords(r,o),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else this.setStartAttribute(t,e,s),this.setEndAttribute(t,e,s)}replaceNaNs(t,e){if(this.addAttribute(t),this.isEmpty())return;const s=pe.getComponentCount(t);for(let i=0;i<s;i++){const s=this.getStartAttributeAsDbl(t,i);Number.isNaN(s)&&this.setStartAttribute(t,i,e);const n=this.getEndAttributeAsDbl(t,i);Number.isNaN(n)&&this.setEndAttribute(t,i,e)}}}fe.s_maxMonotonicPartParams=8;class xe extends fe{constructor(t){super(t)}}class ye extends xe{isTrue3D(){return!0}constructor(t){super(t)}}function Pe(t,e,s){Ee(e,t.getStartXY(),t.getEndXY(),s)}function Ee(t,e,s,i){(0,n.B)(e,s,t,i)}function Ce(t,e){return(0,n.w)(t.m_XStart,t.m_XEnd,e)}function ve(t,e){return(0,n.w)(t.m_YStart,t.m_YEnd,e)}function be(t,e,s){e.value()<=.5?(0,n.a8)(2,Wt.constructPoint2D(t.getStartXY()),Wt.constructPoint2D(t.getEndXY()),e,s):(0,n.a9)(2,Wt.constructPoint2D(t.getStartXY()),Wt.constructPoint2D(t.getEndXY()),e,s)}function Se(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 Ie(t){if(t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart){t.m_XEnd=(0,n.b)(t.m_XStart,t.m_XStart=t.m_XEnd),t.m_YEnd=(0,n.b)(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]=(0,n.b)(t.m_attributes[e],t.m_attributes[e]=t.m_attributes[e+s])}}function we(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:function(t,e){const s=Ne(t,e.m_XStart,e.m_YStart),i=Ne(t,e.m_XEnd,e.m_YEnd);if(s<0&&i<0||s>0&&i>0)return!1;const n=Ne(e,t.m_XStart,t.m_YStart),r=Ne(e,t.m_XEnd,t.m_YEnd);return!(n<0&&r<0||n>0&&r>0)&&(Ge(t)>Ge(e)?Me(t,e):Me(e,t))}(t,e)?4:0}function De(t,e,s,i,r,o,a,h){null!==i&&(i.length=2),null!==r&&(r.length=2),null!==s&&(s.length=2);const m=function(t,e,s,i,r,o,a,h,m){const l=Te(t,e.getStartXY(),a,!1),u=Te(t,e.getEndXY(),a,!1),c=Te(e,t.getStartXY(),a,!1),g=Te(e,t.getEndXY(),a,!1);let _=0,d=0;if(!Number.isNaN(l)){let s=!1;h&&(0,n.a1)(l,0,1)&&t.getCoord2D(l).isEqualPoint2D(e.getStartXY())&&(_++,s=!0),s||(r&&(r[d]=l),o&&(o[d]=0),i&&(i[d]=n.P.construct(e.m_XStart,e.m_YStart)),d++)}if(!Number.isNaN(u)){let s=!1;h&&(0,n.a1)(u,0,1)&&t.getCoord2D(u).isEqualPoint2D(e.getEndXY())&&(_++,s=!0),s||(2>d&&(r&&(r[d]=u),o&&(o[d]=1),i&&(i[d]=n.P.construct(e.m_XEnd,e.m_YEnd))),d++)}if(2!==d&&!Number.isNaN(c)&&!(0===l&&0===c||0===u&&1===c)){let s=!1;h&&(0,n.a1)(c,0,1)&&e.getCoord2D(c).isEqualPoint2D(t.getStartXY())&&(_++,s=!0),s||(2>d&&(r&&(r[d]=0),o&&(o[d]=c),i&&(i[d]=n.P.construct(t.m_XStart,t.m_YStart))),d++)}if(2!==d&&!Number.isNaN(g)&&!(1===l&&0===g||1===u&&1===g)){let s=!1;h&&(0,n.a1)(g,0,1)&&e.getCoord2D(g).isEqualPoint2D(t.getEndXY())&&(_++,s=!0),s||(2>d&&(r&&(r[d]=1),o&&(o[d]=g),i&&(i[d]=n.P.construct(e.m_XEnd,e.m_YEnd))),d++)}if(d>0)return m&&(o=(0,n.b)(r,r=o)),2===d&&r&&r[0]>r[1]&&(r[1]=(0,n.b)(r[0],r[0]=r[1]),o&&(o[1]=(0,n.b)(o[0],o[0]=o[1])),i&&(i[1]=(0,n.b)(i[0],i[0]=i[1]))),d;if(_>0)return 0;const p=function(t,e,s){const i=t.m_XEnd-t.m_XStart,r=t.m_YEnd-t.m_YStart,o=e.m_XEnd-e.m_XStart,a=e.m_YEnd-e.m_YStart,h=o*r-i*a;if(0===h)return n.P.getNAN();const m=4*(0,n.aa)()*(Math.abs(o*r)+Math.abs(i*a)),l=e.m_XStart-t.m_XStart,u=e.m_YStart-t.m_YStart,c=o*u-l*a,g=4*(0,n.aa)()*(Math.abs(o*u)+Math.abs(l*a)),_=c/h,d=Math.abs(h),p=(g*d+m*Math.abs(c))/(h*h)+(0,n.aa)()*Math.abs(_);if(_<-p||_>1+p)return n.P.getNAN();const f=i*u-l*r,x=f/h,y=(4*(0,n.aa)()*(Math.abs(i*u)+Math.abs(l*r))*d+m*Math.abs(f))/(h*h)+(0,n.aa)()*Math.abs(x);if(x<-y||x>1+y)return n.P.getNAN();let P=(0,n.l)(_,0,1),E=(0,n.l)(x,0,1);const C=n.P.getNAN();Pe(t,P,C);const v=n.P.getNAN();if(Pe(e,E,v),!s||n.P.distance(C,v)>s){const i=n.P.getNAN();(0,n.B)(C,v,.5,i),P=t.getClosestCoordinate(i,!1),E=e.getClosestCoordinate(i,!1);const r=n.P.getNAN();Pe(t,P,r);const o=n.P.getNAN();Pe(e,E,o),r.subThis(o);const a=r.length(),h=(t.absNorm()+e.absNorm())*(0,n.O)();if(a>Math.max(s,h))return n.P.getNAN()}return new n.P(P,E)}(t,e,a);return Number.isNaN(p.x)?0:(i&&(i[0]=t.getCoord2D(p.x)),r&&(r[0]=p.x),o&&(o[0]=p.y),1)}(t,e,0,s,i,r,o,a,h);return i&&(i.length=m),r&&(r.length=m),s&&(s.length=m),m}function Te(t,e,s,i){const r=n.P.getNAN(),o=n.P.getNAN();let a=!1;t.m_YEnd<t.m_YStart||t.m_YEnd===t.m_YStart&&t.m_XEnd<t.m_XStart?(r.setCoords(t.m_XEnd,t.m_YEnd),o.setCoords(t.m_XStart,t.m_YStart),a=!0):(r.setCoords(t.m_XStart,t.m_YStart),o.setCoords(t.m_XEnd,t.m_YEnd));const h=a?1:0,m=a?0:1,l=n.P.getNAN();l.setSub(e,r);let u=l.length(),c=3*u*(0,n.aa)();if(u<=Math.max(s,c))return i&&0===u?Number.NaN:h;if(l.setSub(e,o),u=l.length(),c=3*u*(0,n.aa)(),u<=Math.max(s,c))return i&&0===u?Number.NaN:m;l.setCoords(o.x-r.x,o.y-r.y);const g=l.length();if(g>0){const t=1/g;l.scale(t);const i=n.P.getNAN();i.setSub(e,r);const u=i.dotProduct(l),c=8*i.dotProductAbs(l)*(0,n.aa)();l.leftPerpendicularThis();const _=i.dotProduct(l),d=8*i.dotProductAbs(l)*(0,n.aa)(),p=Math.max(s,c);if(u<-p||u>g+p)return Number.NaN;const f=Math.max(s,d);if(Math.abs(_)<=f){let i=u*t;i=(0,n.l)(i,0,1);const l=n.P.getNAN();if(Ee(i,r,o,l),n.P.distance(l,e)<=s){if(i<.5){if(n.P.distance(l,r)<=s&&n.P.distance(e,r)<=s)return h}else if(n.P.distance(l,o)<=s&&n.P.distance(e,o)<=s)return m;return a?1-i:i}}}return Number.NaN}function Ne(t,e,s){const i=n.P.getNAN();i.setCoords(e,s),i.subThis(t.getStartXY());const r=n.P.getNAN();r.setSub(t.getEndXY(),t.getStartXY());const o=r.crossProduct(i),a=4*(0,n.aa)()*(Math.abs(r.x*i.y)+Math.abs(r.y*i.x));return o>a?-1:o<-a?1:0}function Ae(t,e,s,i){const r=i?t.m_XStart:t.m_XEnd,o=i?t.m_YStart:t.m_YEnd,a=n.P.getNAN();return a.x=e.getEndX()-r,a.y=e.getEndY()-o,!(s.dotProduct(a)>3*(0,n.aa)()*s.dotProductAbs(a))||(a.x=e.getStartX()-r,a.y=e.getStartY()-o,s.dotProduct(a)<=3*(0,n.aa)()*s.dotProductAbs(a))}function Me(t,e){const s=n.P.getNAN();return s.x=t.m_XEnd-t.m_XStart,s.y=t.m_YEnd-t.m_YStart,!!Ae(t,e,s,!1)&&(s.negateThis(),!!Ae(t,e,s,!0))}function Ge(t){const e=t.m_XStart-t.m_XEnd,s=t.m_YStart-t.m_YEnd;return e*e+s*s}class qe{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())&&(0,i.w)("");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)&&(0,i.w)("");const e=t.parent.isClosedPath(t.pathIndex)?0:1;t.segmentIndex>=t.parent.getPathSize(t.pathIndex)-e&&(0,i.w)(""),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}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())&&(0,i.w)(""),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 0===this.m_currentSegmentIndex}isLastSegmentInPath(){return this.m_currentSegmentIndex===this.m_segmentCount-1}resetToFirstSegment(){this.m_currentSegmentIndex=-1,this.m_nextSegmentIndex=0}resetToLastSegment(){this.m_nextSegmentIndex=this.m_segmentCount,this.m_currentSegmentIndex=-1}resetTo(t){this.m_parent!==t.m_parent&&(0,i.u)(""),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&&(0,i.w)("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&&(0,i.w)(""),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&&(0,i.w)(""),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)&&(0,i.w)(""),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 null!==this.m_segFlagStream&&1!=(31&this.m_segFlagStream.read(this.m_currentSegmentIndex))}isPathClosed(){return this.m_bCurrentPathClosed}setCirculator(t){this.m_bCirculator=t}getImpl(){return this}}class Fe{constructor(t){this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null,this.m_refCount=1,t&&t.copyTo(this)}getRasterizedGeometry(){return this.m_rasterizedGeometry}copyTo(t){t!==this&&((0,i.g)(t.uniqueUse()),t.m_quadTree=this.m_quadTree,t.m_quadTreeForPaths=this.m_quadTreeForPaths,t.m_rasterizedGeometry=this.m_rasterizedGeometry)}clone(){const t=new Fe;return this.copyTo(t),t}uniqueUse(){return 1===this.m_refCount}addRef(){++this.m_refCount}release(){0==--this.m_refCount&&(this.m_rasterizedGeometry=null,this.m_quadTree=null,this.m_quadTreeForPaths=null)}setRasterizedGeometry(t){(0,i.g)(this.uniqueUse())}setQuadTree(t){(0,i.g)(this.uniqueUse()),this.m_quadTree=t}setQuadTreeForPaths(t){(0,i.g)(this.uniqueUse()),this.m_quadTreeForPaths=t}getQuadTree(){return this.m_quadTree}getQuadTreeForPaths(){return this.m_quadTreeForPaths}}function Ve(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function Re(t){return!(t.isEmpty()||t.getGeometryType()!==i.G.enumPolyline&&t.getGeometryType()!==i.G.enumPolygon||t.getPointCount()<20)}function Ye(t,e){return t.readPoint2D(e+4)}function Xe(t){const e=t.getGeometryType();return e===i.G.enumEllipticArc?10:e===i.G.enumBezier?4:e===i.G.enumRationalBezier2?5:e===i.G.enumBezier2?2:void(0,i.b)("")}function ke(t){const e=31&t;return 4===e?10:2===e?4:8===e?5:16===e?2:0}function He(t,e,s,r){const o=4*(0,n.aa)()*(Math.abs(e.vmin)+Math.abs(e.vmax)),a=(0,n.aa)();if(1===t.getMaxDerivative()){(0,i.g)(s>0);const a=Ue(t,0,e,(0,n.aa)(),o);return r[0]=a.root,a.cRoots}let h,m=[];const l=new n.E(e.vmin-o,e.vmax+o);m.push(new n.P(l.vmin,l.vmax));let u=0;for(let i=t.getMaxDerivative()-1;i>=0;i--){h=m,m=[];for(let l=0,c=h.length;l<c;l++){if(h[l][0]<h[l][1]){let c,g,_;if(i===t.getMaxDerivative()-1?({root:c,funcAtRoot:g,cRoots:_}=Ue(t,i,n.E.construct(h[l][0],h[l][1]),a,.5*o)):({root:c,funcAtRoot:g,cRoots:_}=Oe(t,i,n.E.construct(h[l][0],h[l][1]),0,.5*o)),1===_){if(0===i)u<s&&(h[l][0]<=e.vmin&&h[l][1]>=e.vmin&&c!==e.vmin&&0===t.getValue(0,e.vmin)&&(c=e.vmin),h[l][0]<=e.vmax&&h[l][1]>=e.vmax&&c!==e.vmax&&0===t.getValue(0,e.vmax)&&(c=e.vmax),r[u]=e.snapClip(c),u>0?r[u]-r[u-1]>o&&u++:u++);else{const t=n.P.getNAN();t[0]=h[l][0],t[1]=c,m.push(t);const e=n.P.getNAN();e[0]=c,e[1]=h[l][1],m.push(e)}continue}}m.push(h[l])}}return u}function Be(t,e,s,i,r,o){const a=(0,n.m)(n.H,2),h=Ze(new n.H(t),new n.H(e),new n.H(s),i,r,a);return o[0]=a[0].value(),o[1]=a[1].value(),h}function Le(t,e,s,i,r,o,a){const h=(0,n.m)(n.H,3),m=Qe(new n.H(t),new n.H(e),new n.H(s),new n.H(i),r,o,h);return a[0]=h[0].value(),a[1]=h[1].value(),a[2]=h[2].value(),m}function ze(t,e,s,i,r,o,a,h){return function(t,e,s,i,r,o,a,h){const m=new Array(s*s);m.fill(0),(0,n.D)(h,i,0,0,s);const l=new Array(s),u=new Array(s),c=new Array(s);let g=t(h,s,e);let _=0;for(_=0;_<100;_++){const i=g;for(let t=0;t<s;++t)u[t]=h[t];if(_%s==0){m.fill(0);for(let t=0;t<s;t++)m[t*s+t]=1}let a=0,d=0;for(let i=0;i<s;++i){for(let t=0;t<s;++t)l[t]=m[i*s+t];const n=g;g=We(t,e,h,l,r,o,s);const u=n-g;u>a&&(d=i,a=u)}for(let t=0;t<s;t++)l[t]=h[t]-u[t],c[t]=h[t]+(h[t]-u[t]);const p=t(c,s,e);if(p<i&&2*(i-2*g+p)*(0,n.e)(i-g-a)<(0,n.e)(i-p)*a){g=We(t,e,h,l,r,o,s);for(let t=0;t<s;++t)m[d*s+t]=m[(s-1)*s+t],m[(s-1)*s+t]=l[t]}if(i<=g)return t(h,s,e)}return g}(t,e,s,i,r,o,0,h)}function Ue(t,e,s,r,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=s.vmax,l=0,u=Number.MAX_VALUE,c=t.getValue(e,h),g=t.getValue(e,m),_=0,d=0,p=0;if(c>=0&&g>=0||c<=0&&g<=0)return Math.abs(c)<Math.abs(g)?(a.funcAtRoot=c,a.root=h,a.cRoots=0===c?1:0,a):(a.funcAtRoot=g,a.root=m,a.cRoots=0===g?1:0,a);Math.abs(c)<Math.abs(g)&&(m=(0,n.b)(h,h=m),g=(0,n.b)(c,c=g)),l=h,_=c;let f=!0,x=0;for(;0!==g&&Math.abs(h-m)>r*Math.abs(m)+o;x++){let s=x>64;if(!s){d=c!==_&&g!==_?h*g*_/((c-g)*(c-_))+m*c*_/((g-c)*(g-_))+l*c*g/((_-c)*(_-g)):m-g*(m-h)/(g-c);const t=(3*h+m)/4;if(s=!(d>t&&d<m||d>m&&d<t),!s){const t=r*Math.abs(m)+o;if(f){const e=Math.abs(m-l);s=Math.abs(d-m)>=.5*e||e<t}else{const e=Math.abs(l-u);s=Math.abs(d-m)>=.5*e||e<t}}}if(s?(d=(h+m)/2,f=!0):f=!1,p=t.getValue(e,d),0===p)return a.root=d,a.funcAtRoot=p,a.cRoots=1,a;if(!s){const s=h-d,i=d-m;if(Math.abs(s)>10*Math.abs(i)){let s=m+3*i;for(let i=0;i<2;i++){const i=t.getValue(e,s);(0,n.s)(c)*(0,n.s)(i)>0?(h=s,c=i):s=(0,n.w)(h,m,.75)}}else if(Math.abs(i)>10*Math.abs(s)){let i=h-3*s;for(let s=0;s<2;++s){const s=t.getValue(e,i);(0,n.s)(g)*(0,n.s)(s)>0?(m=i,g=s):i=(0,n.w)(h,m,.25)}}}u=l,l=m,_=g,(0,n.s)(c)*(0,n.s)(p)<0?(m=d,g=p):(h=d,c=p),Math.abs(c)<Math.abs(g)&&(m=(0,n.b)(h,h=m),g=(0,n.b)(c,c=g)),128===x&&(0,i.b)("Root_finder iterations exceeded")}return a.root=m,a.funcAtRoot=g,a.cRoots=1,a}function Oe(t,e,s,r,o){const a={root:0,funcAtRoot:0,cRoots:0};let h=s.vmin,m=t.getValue(e,h),l=s.vmax,u=t.getValue(e,l);if(m>=0&&u>=0||m<=0&&u<=0)return Math.abs(m)<Math.abs(u)?(a.funcAtRoot=m,a.root=h,a.cRoots=0===m?1:0,a):(a.funcAtRoot=u,a.root=l,a.cRoots=0===u?1:0,a);u<0&&(u=(0,n.b)(m,m=u),l=(0,n.b)(h,h=l));let c=.5*(h+l),g=Math.abs(l-h),_=g,d=t.getValue(e,c),p=t.getValue(e+1,c),f=4,x=1,y=0,P=0,E=1,C=0;for(;++C<100;){let s;C>32||0===p||2===E&&y>1||1===E&&f<4?(E=1,x>1&&x--):(E=2,P>1&&Math.abs(2*d)>Math.abs(g*p)&&x++),g=_;let i=!1;if(1===E)do{if(P>2){const t=16*Math.abs(g);if(.5*Math.abs(h-l)>t){const e=Math.min(h,l),i=Math.max(h,l);if(c===e){s=c,c=e+t,_=c-s;break}if(c===i){s=c,c=i-t,_=c-s;break}}}_=.5*(l-h),s=c,c=h+_,i=h===c||l===c}while(0);else for(;;){_=x*d/p,s=c,c-=_,i=c===s;const t=Math.min(h,l),e=Math.max(h,l);if(c<t){if(x>1){c=s,x--;continue}_=s-t,c=t}else if(c>e){if(x>1){c=s,x--;continue}_=s-e,c=e}break}if(i||Math.abs(_)<o){s!==c&&(d=t.getValue(e,c));break}d=t.getValue(e,c),p=t.getValue(e+1,c);const n=h,r=l;d<0?(m=d,h=c):(u=d,l=c),2===E&&(h===n&&l===r||P>1&&Math.abs(_)>=.5001*Math.abs(g))?y++:y=0,1===E?(f++,P=0):(f=0,P++)}return 100===C&&(0,i.b)("Root_finder iterations exceeded"),a.root=c,a.funcAtRoot=d,a.cRoots=1,a}function We(t,e,s,i,r,o,a){const h=i.slice(0,a);let m=0;for(let t=0;t<a;t++)m+=i[t]*i[t];if(m=Math.sqrt(m),m>0)for(let t=0;t<a;t++)h[t]/=m;let l=Number.NEGATIVE_INFINITY,u=Number.POSITIVE_INFINITY;{const t=new Array(a);for(let e=0;e<a;e++)t[e]=e;t.sort(((t,e)=>{const s=Math.abs(h[t]),i=Math.abs(h[e]);return s<i?-1:s>i?1:0}));for(let e=0;e<a;e++){const i=t[e];if(0===h[i])continue;let a=(r[i]-s[i])/h[i],m=(o[i]-s[i])/h[i];m<a&&(m=(0,n.b)(a,a=m)),a>l&&(l=a),m<u&&(u=m)}}let c=0;const g=(Math.abs(l)+Math.abs(u))*(0,n.aa)()*100,_=new Array(a),d=h.slice();function p(i,n){for(let t=0,e=a;t<e;t++)_[t]=s[t]+i*d[t];return t(_,a,e)}g>0&&(c=function(t,e,s,i,r,o){return function(t,e,s,i,r,o){const a=(0,n.av)();let h=i,m=t(h,e),l=s,u=r,c=t(l,e),g=t(u,e);m>c&&(m=c,h=l),m>g&&(m=g,h=u);let _=l,d=u,p=c,f=g;p>f&&(p=(0,n.b)(f,f=p),d=(0,n.b)(_,_=d));let x=h-_,y=_-d;const P=.5*Math.min(o,u-l),E=2*P;let C,v=0;for(C=0;C<100&&!(u-l<=E);++C){const s=l+.5*(u-l);let i=v>0;if(!i&&Math.abs(y)<=P&&(i=!0,v=3),!i){const t=h-_,e=h-d,s=t*(m-f);let n=e*(m-p),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*y/2)||r<=n*(l-h)||r>=n*(u-h)?(i=!0,v=3):(y=x,x=r/n)}i&&(y=h>=s?l-h:u-h,x=a*y,v--);let n=h+x;n<l+P?n=l+P:n>u-P&&(n=u-P);const r=t(n,e);r<m?(n>=h?(l=h,c=m):(u=h,g=m),d=_,_=h,h=n,f=p,p=m,m=r):(n<h?(l=n,c=r):(u=n,g=r),r<=p||_===h?(d=_,_=n,f=p,p=r):(r<=f||d===h||d===_)&&(d=n,f=r))}return h}(t,e,s,i,r,o)}(p,null,l,0,u,g));const f=p(c);for(let t=0,e=a;t<e;t++)s[t]=(0,n.l)(_[t],r[t],o[t]);return f}function je(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 Ze(t,e,s,i,r,o){if(0===t.value())return r?(o[0].set(1),i.containsCoordinate(o[0].value())?1:0):je(e,s,i,o[0]);if(r){let e=2;return o[0].set(1),o[1].setE(s).divThisE(t),o[1].eq(o[0])&&(o[1].set(1),e=1),i.containsCoordinate(o[1].value())||(e=1),i.containsCoordinate(o[0].value())||(e--,o[0].setE(o[1])),2===e&&o[0].value()>o[1].value()&&(o[1]=(0,n.b)(o[0],o[0]=o[1])),e}const a=e.clone().sqrThis().subThisE(t.clone().mulThisE(s).mulThisE(n.aj));if(a.lt(n.C))return 0;const h=new n.H(e.value()>=0?1:-1),m=a.clone().sqrtThis(),l=new n.H(-.5).mulThisE(e.clone().addThisE(h.clone().mulThisE(m)));let u=0;o[0].setE(l.divE(t));const c=new n.H(o[0].value()),g=new n.H(t.value()).mulE(c).addE(new n.H(e.value()).mulE(c).addE(new n.H(s.value())));return g.isZero()||is(o[0],t,e,s,o[0]),i.containsCoordinate(o[0].value())&&u++,0!==m.value()&&0!==l.value()?(o[u].assign(s.divE(l)),c.set(o[u].value()),g.assign(new n.H(t.value()).mulE(c).addE(new n.H(e.value()).mulE(c).addE(new n.H(s.value())))),g.isZero()||is(o[u],t,e,s,o[u]),i.containsCoordinate(o[u].value())&&u++,2===u&&o[0].value()>o[1].value()&&(o[1]=(0,n.b)(o[0],o[0]=o[1])),u):u}function Qe(t,e,s,r,o,a,h){if(0===t.value())return Ze(e,s,r,o,a,h);if(a){let s=1;h[0].set(1);const i=h.slice(s),a=Ze(t,e.addE(t),r.negate(),o,!1,i);if(a>0){s+=a;for(let t=1;t<s;t++)h[t].eq(n.ai)&&(h[s-1]=(0,n.b)(h[t],h[t]=h[s-1]),s--)}const m=h.slice(0,s);m.sort(((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));for(let t=0;t<s;++t)h[t]=m[t];return s}return function(t,e,s,r,o,a){const h=(0,n.m)(n.H,3);let m=0;const l=e.negate().divThisE(t.clone().mulThis(3));o.containsCoordinate(l.value())&&(h[0].setE(l),m=1);const u=(0,n.m)(n.H,2),c=Ze(t.mul(3),e.mul(2),s,o,!1,u);if(c<0)return r.isZero()?-1:0;for(let t=0;t<c;t++)o.containsCoordinate(u[t].value())&&h[m++].setE(u[t]);(0,n.W)(h,0,m,((t,e)=>t.value()<e.value()?-1:t.value()>e.value()?1:0));const g=(0,n.m)(n.H,5);g[0].set(o.vmin);for(let t=0;t<m;t++)g[1+t].setE(h[t]);g[1+m].set(o.vmax);const _=m+2;let d=1,p=0;{const i=g[0].clone();if(t.clone().mulThisE(i).addThisE(e).mulThisE(i).addThisE(s).mulThisE(i).addThisE(r).isZero()){const n=Je(t,e,s,r);i.setError(n.estimateError(i.value())),a[p]=i,p++,d++}}for(let n=d;n<_;n++){const h=g[n].clone(),m=t.clone().mulThisE(h).addThisE(e).mulThisE(h).addThisE(s).mulThisE(h).addThisE(r).isZero();if(m||!g[n].eq(g[n-1])){if(m||es(g[n-1].value(),g[n].value(),g[n-1].clone().addThisE(g[n]).divThisByPower2(2),t,e,s,r,h)){if(p>0&&h.eq(a[p-1]))continue;if(p>=3&&(0,i.b)("cubic_polynomial_solver_too_many_roots"),m){const i=Je(t,e,s,r);h.setError(i.estimateError(h.value()))}a[p]=h,p++}if(g[n].value()===o.vmax)break;m&&n++}}return p}(t,e,s,r,o,h)}function Ke(t,e,s,r,o,a){return(a<e||e<0)&&(0,i.t)("nth_degree_real_roots"),function(t,e,s,i,r){const o=new $e(t,e,s,(0,n.aa)());let a=0;if(2===o.truePower)a=Ze(t[2],t[1],t[0],s,i,r);else if(1===o.truePower)a=je(t[1],t[0],s,r[0]);else{if(0===o.truePower)return t[0].value()?0:-1;{const t=[];t.length=e,a=He(o,s,e,t);for(let e=0;e<a;e++)r[e].set(t[e])}}for(let t=0;t<a;t++)r[t].setError(o.getError(r[t].value()));return a}(t,e,s,r,o)}function Je(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 $e{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 t=e;t>=1;t--)if(0!==this.coefs[t].value()){this.truePower=t;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 n.K(0);let r=1;for(let n=0,o=this.truePower-t;n<=o;++n)i.pe(r*s[n].value()),r*=e;return i.getResult()}getError(t){const e=Math.abs(t),s=new n.K(0),i=new n.H(1),r=new n.H(0);for(let t=0,n=this.power;t<=n;++t)r.addThisE(this.coefs[t].mulE(i)),s.pe(i.value()*this.coefs[t].eps()),i.mulThis(e);s.pe(r.eps());let o=1;for(let e=1;e<=this.truePower;++e){o*=e,this.updateCoefs(e);const i=new n.H(1),r=new n.H(0);for(let s=0,n=this.truePower-e;s<=n;++s)r.addThisE(this.curCoefs[s].mulE(i)),i.mulThis(t);if(!r.isZero())return Math.pow(o*s.getResult()/Math.abs(r.value()),1/e)}return 0}}function ts(t,e,s,i,r,o){let a=t,h=e,m=h-a;if(!o){let s=i.calcF(t).value(),r=i.calcF(e).value();if((s>0||s>r)&&(h=(0,n.b)(a,a=h),r=(0,n.b)(s,s=r)),s>=0||r<=0)return!1}let l,u=!1,c=s,g=0;for(;g<100;g++){const t=i.calcF(c);if(l=i.calcDF(c),l.isZero())return!1;if(!t.value()||g>3&&t.isZero()){u=!0;break}o||(t.value()<0?a=c:h=c);const e=t.value()/l.value(),s=c-e;o||(s>=a&&s<=h||s>=h&&s<=a)&&Math.abs(e)<=.5*m?(c=s,m=Math.abs(e)):(m=Math.abs(.5*(h-a)),c=.5*(a+h))}return!!u&&(r.set(c,i.estimateError(c)),!0)}function es(t,e,s,i,n,r,o,a){return ts(t,e,s.value(),Je(i,n,r,o),a,!1)}class ss{constructor(t,e,s){this.coefs=(0,n.m)(n.H,3),this.coefs[0].setE(t),this.coefs[1].setE(e),this.coefs[2].setE(s)}calcF(t){const e=new n.H(t);return this.coefs[0].mulE(e).addE(this.coefs[1]).mulE(e).addE(this.coefs[2])}calcDF(t){const e=new n.H(t);return n.H.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 n.H(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 is(t,e,s,i,n){return ts(0,0,t.value(),new ss(e,s,i),n,!0)}var ns=g;class rs extends xe{constructor(t){void 0===t||(0,n.Y)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(0,0)):t.from?(super({XStart:t.from.x,YStart:t.from.y,XEnd:t.to.x,YEnd:t.to.y,...t.vd}),this.m_cp=t.cp.clone()):t.points?(super({XStart:t.points[0].x,YStart:t.points[0].y,XEnd:t.points[2].x,YEnd:t.points[2].y,...t.vd}),this.m_cp=t.points[1].clone()):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone()):(0,i.b)("unexpected constructor args")}getBoundary(){return yr(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}construct(t,e,s){this.setStartXY(t),this.m_cp.assign(e),this.setEndXY(s),Xi(this)}constructPoints(t){this.setStartXY(t[0]),this.m_cp.assign(t[1]),this.setEndXY(t[2]),Xi(this)}getGeometryType(){return i.G.enumBezier2}queryEnvelope(t){if(2!==t.m_EnvelopeType)(0,i.a)("env type not impl");else{if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=Qi(this);if(null!==e){const s=new n.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[];Hi(this,e);const s=new n.P;for(const i of e)this.queryCoord2D(i,s),t.mergeNe(s)}}}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,n.m)(n.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}(0,i.g)(0)}createInstance(){return new rs({vd:this.m_description})}calculateLength2D(){return Bi(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp)}queryCoord2D(t,e){this.queryCoord2DExtended(t,e,!1)}queryCoord2DExtended(t,e,s){const i=(0,n.m)(n.P,3);this.queryControlPoints(i),_n(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,n.m)(n.P,3);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=Wt.constructPoint2D(t[1]),r=new Wt;(0,n.a8)(2,Wt.constructPoint2D(t[0]),i,e,r);const o=new Wt;(0,n.a8)(2,i,Wt.constructPoint2D(t[2]),e,o);const a=new Wt;(0,n.a8)(2,r,o,e,a),s.setE(a)}else{const i=Wt.constructPoint2D(t[1]),r=new Wt;(0,n.a9)(2,Wt.constructPoint2D(t[0]),i,e,r);const o=new Wt;(0,n.a9)(2,i,Wt.constructPoint2D(t[2]),e,o);const a=new Wt;(0,n.a9)(2,r,o,e,a),s.setE(a)}}(i,e,s)}(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.x}if(t<=.5){const e=(0,n.Z)(this.getStartX(),this.m_cp.x,t),s=(0,n.Z)(this.m_cp.x,this.getEndX(),t);return(0,n.Z)(e,s,t)}{const e=(0,n._)(this.getStartX(),this.m_cp.x,t),s=(0,n._)(this.m_cp.x,this.getEndX(),t);return(0,n._)(e,s,t)}}getCoordY(t){if(t<0||t>1){const e=new n.P;return this.queryCoord2DExtended(t,e,!0),e.y}if(t<=.5){const e=(0,n.Z)(this.getStartX(),this.m_cp.x,t),s=(0,n.Z)(this.m_cp.x,this.getEndX(),t);return(0,n.Z)(e,s,t)}{const e=(0,n._)(this.getStartY(),this.m_cp.y,t),s=(0,n._)(this.m_cp.y,this.getEndY(),t);return(0,n._)(e,s,t)}}cut(t,e,s){const i=new ra;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=ns.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=ns.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const i=(0,n.m)(n.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){{const e=Wt.constructPoint2D(t[1]).subE(Wt.constructPoint2D(t[0])),i=new n.H(1).subE(s),r=Wt.constructPoint2D(t[2]).subE(Wt.constructPoint2D(t[1])),o=e.mulE(i).addE(r.mulE(s));return o.mulThisE(new n.H(2)),o}}(t,0,e))}(i,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){if((t<0||e>1||t>e)&&(0,i.t)("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 r=(0,n.m)(n.P,3);this.queryControlPoints(r),on(r,t,e,r),s.constructPoints(r)}splitBezierIgnoreAttributes(t,e,s){(0,i.g)(0)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),r=i>0?this.tToLength(t)/i:0,o=ns.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,n.$)(o,a,h,r,ns.getDefaultValue(e))}getClosestCoordinate(t,e){return Ji(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return Ji(this,t,e,!1)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.t)("");const s=ki(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)sn(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const r=(0,n.m)(n.H,3),o=(0,n.m)(n.H,2),a=new n.E(0,1);let h=0;if(t){if(r[0]=new n.H(this.getStartY()).sub(e),r[1]=new n.H(this.m_cp.y).subE(new n.H(this.getStartY())).mulThisByPower2(2),r[2]=new n.H(this.getStartY()).add(this.getEndY()).subE(new n.H(this.m_cp.y).mulThisByPower2(2)),h=Ze(r[2],r[1],r[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.H(this.getStartX()).sub(e),r[1]=new n.H(this.m_cp.x).subE(new n.H(this.getStartX())).mulThisByPower2(2),r[2]=new n.H(this.getStartX()).add(this.getEndX()).subE(new n.H(this.m_cp.x).mulThisByPower2(2)),h=Ze(r[2],r[1],r[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,n.a0)(s,h);return h}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],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isLine(){return!1}isDegenerate(t){return Kt(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords(this.getStartXY()),t.mergeNe(this.m_cp),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=new o;this.queryEnvelope(t);const s=new n.E;return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,n.m)(n.P,4);this.queryControlPoints(s),on(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.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 Bi(this,t,!0)}lengthToT(t){return function(t,e){const s=Bi(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const r=[0];return 1!==He(new Ri(t,e),n.E.unit(),1,r)&&(0,i.b)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,n.m)(n.P,3);!function(t,e,s=!1){const i=(0,n.m)(n.P,3);t.queryControlPoints(i),cn(i,e,s)}(this,e);const s=e[2],i=e[1],r=new n.P,o=s.y*i.x-s.x*i.y;r.x=-(4*s.x+5*i.x)*o/60,r.y=-(4*s.y+5*i.y)*o/60;const a=ji(this);return r.x+=(e[0].x-t.x)*a,r.y+=(e[0].y-t.y)*a,r}calculateWeightedCentroid2D(){const t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=n.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const r=new n.P;if(e<0||s>1)return r.setNAN(),r;if(e>s&&(0,i.t)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return r.setCoords(0,0),r;const o=ki(t),a=ce(t),h=Math.min(a/t.calculateUpperLength2D(),1e-7);let m=e,l=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){l=t-1;break}r.setCoords(0,0);for(let e=l+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),n=Yi(t,m,i,h,a);if(r.addThis(n),m=i,s<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}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(t){for(let e=0;e<3;e++)t[e].isNAN()&&(0,i.t)("NaN control points in bezier are not supported");this.m_XStart=t[0].x,this.m_YStart=t[0].y,this.m_cp.setCoordsPoint2D(t[1]),this.m_XEnd=t[2].x,this.m_YEnd=t[2].y,this.afterCompletedModification()}getTangent(t){const e=(0,n.l)(t,0,1);let s=Oi(this,1,e);return s.isZero()&&(s=Oi(this,2,e),1===e&&s.negateThis()),s}getDerivative(t){return Oi(this,1,(0,n.l)(t,0,1))}getCurvature(t){const e=Oi(this,1,t),s=Oi(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersecting(t,e,s){return 0!==jo(!1,this,t,e,s)}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;const i=new o;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){return!1}getMonotonicPartParams(t,e){const s=ki(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s.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){(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),(0,n.b)(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]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isDegenerateToLineHelper(t){const e=[t];if(!Jt(this,e))return!1;const s=this.getEndXY().sub(this.getStartXY()),i=s.length(),n=this.getControlPoint1();return n.sub(this.getStartXY()),!(Math.abs(n.crossProduct(s))/i>e[0])}copyIgnoreAttributes(t){const e=(0,n.m)(n.P,3);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return ji(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp.norm(1);var t}queryEnvelopeW(t,e){const s=(0,n.m)(n.P,3);this.queryControlPoints(s),tn(s,t,e)}setSegmentFromCoords(t,e){this.construct(t[0],this.getControlPoint1(),t[e-1])}snapControlPoints(t){return function(t,e){const s=(0,n.m)(n.P,3);t.queryControlPoints(s);const i=n.P.sqrDistance(s[1],s[0]),r=n.P.sqrDistance(s[1],s[2]);let o=s[0].clone(),a=i;i>r&&(o=s[2].clone(),a=r);let h=!1;return a<=e&&0!==a&&(h=!0,t.setControlPoint1(o)),h}(this,t)}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(t){return function(t,e){if(!e)return!1;const s=(0,n.m)(n.P,3);t.queryControlPoints(s);const i=n.P.sqrDistance(s[1],s[0]),r=n.P.sqrDistance(s[1],s[2]);s[0].clone();let o=i;return i>r&&(s[2].clone(),o=r),o<=e&&0!==o}(this,t)}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return sn(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const r=!!i&&t.isMonotoneQuickAndDirty(),o=new n.T,a=(0,n.m)(n.P,3);a[0].setCoords(t.m_XStart,t.m_YStart),a[2].setCoords(t.m_XEnd,t.m_YEnd);const h=new n.P;h.setSub(a[2],a[0]),h.leftPerpendicularThis(),a[1].setAdd(a[0],h);const m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(s),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(a,m)?o.transformInPlace(t.m_cp):(0,n.B)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),r&&sn(t)}(this,t,e,s)}copyToImpl(t){const e=t;e.m_cp.setCoordsPoint2D(this.m_cp),Ki(e,Qi(this))}reverseImpl(){}equalsImplTol(t,e){const s=t;return!!this.m_cp.isEqualPoint2D(s.m_cp,e)}equalsImpl(t){const e=t;return!!this.m_cp.equals(e.m_cp)}swapImpl(t){const e=t;e.m_cp=(0,n.b)(this.m_cp,this.m_cp=e.m_cp),function(t,e){e.m_cachedValues=(0,n.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Xi(this)}intersect(t,e,s,i,n){return Jo(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,i,r){const o=new Ht;if(function(t,e,s){const i=(0,n.m)(n.P,3);t.queryControlPoints(i),tn(i,e,s)}(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;const a=new n.P,h=Ji(t,e,n.E.unit(),!1);return t.queryCoord2D(h,a),n.P.distance(a,e)<=r?(i&&(i[0]=h),1):0}(this,t,e.length,e,s)}endPointModified(){Xi(this)}clearEndPointModified(){}}rs.type=i.G.enumBezier2;var os=g;class as extends xe{constructor(t){return void 0===t||(0,n.Y)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=new n.P(0,0),void(this.m_weights=[1,0,1])):(t.fromPoint&&t.weight?t={fromPoint:t.fromPoint,controlPoint1:t.controlPoint1,toPoint:t.toPoint,weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weight?t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:1,weight1:t.weight,weight2:1}:t.points&&t.weights&&(t={fromPoint:t.points[0],controlPoint1:t.points[1],toPoint:t.points[2],weight0:t.weights[0],weight1:t.weights[1],weight2:t.weights[2]}),t.fromPoint&&t.weight0?(super({start:t.fromPoint,end:t.toPoint}),(t.weight0<=0||t.weight1<0||t.weight2<=0)&&(0,i.t)("weights"),this.m_cp=t.controlPoint1.clone(),void(this.m_weights=[t.weight0,t.weight1,t.weight2])):t.copy?(super(t),this.m_cp=t.copy.m_cp.clone(),void(this.m_weights=t.copy.m_weights.slice())):t.move?(super(t),this.m_cp=t.move.m_cp.clone(),void(this.m_weights=t.move.m_weights.slice())):void(0,i.a)("unexpected constructor param"))}getBoundary(){return yr(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),Us(this)}constructWeights(t,e,s,i,n,r){this.dropAllAttributes(),this.setCpsAndWeights(t,e,s,i,n,r),Us(this)}constructArray(t,e){this.construct(t[0],t[1],t[2],e)}constructArrayWeights(t,e){this.dropAllAttributes(),this.setCpsAndWeightsArray(t,e),Us(this)}convertToStandardForm(){}getStandardFormWeight(){return this.m_weights[1]/Math.sqrt(this.m_weights[0]*this.m_weights[2])}getGeometryType(){return i.G.enumRationalBezier2}queryEnvelope(t){if(t instanceof o){if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp))return;const e=ni(this);if(null!==e){const s=new n.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s)}else{const e=[],s=(0,n.m)(n.P,3);this.queryControlPoints(s),Ws(s,this.m_weights,e);const i=new n.P;for(const s of e)this.queryCoord2D(s,i),t.mergeNe(i)}}}applyTransformation(t){if(t instanceof n.T){const e=(0,n.m)(n.P,3);return this.queryControlPoints(e),t.transformPoints2D(e,3,e),this.setStartXY(e[0]),this.m_cp.assign(e[1]),this.setEndXY(e[2]),void this.afterCompletedModification()}}createInstance(){return new as({vd:this.m_description})}calculateLength2D(){return js(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return this.calculateUpperLength2D_()}calculateUpperLength2D_(){return this.m_weights[1]>0?n.P.distance(this.getStartXY(),this.m_cp)+n.P.distance(this.getEndXY(),this.m_cp):n.P.distance(this.getStartXY(),this.getEndXY())}queryCoord2D(t,e){return this.queryCoord2DExtension(t,e,!0)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,n.m)(n.P,3);t.queryControlPoints(i);const r=[0,0,0];t.queryWeights(r),function(t,e,s,i){if(0===s.value())return void i.setE(t[0]);if(1===s.value())return void i.setE(t[2]);const r=[t[0].x.mulE(e[0]),t[1].x.mulE(e[1]),t[2].x.mulE(e[2])],o=[t[0].y.mulE(e[0]),t[1].y.mulE(e[1]),t[2].y.mulE(e[2])],a=[e[0].clone(),e[1].clone(),e[2].clone()],h=new n.H,m=new n.H,l=new n.H;if(s.value()<=.5){const t=(0,n.a5)(r[0],r[1],s),e=(0,n.a5)(r[1],r[2],s);h.setE((0,n.a5)(t,e,s));const i=(0,n.a5)(o[0],o[1],s),u=(0,n.a5)(o[1],o[2],s);m.setE((0,n.a5)(i,u,s));const c=(0,n.a5)(a[0],a[1],s),g=(0,n.a5)(a[1],a[2],s);l.setE((0,n.a5)(c,g,s))}else{const t=(0,n.a6)(r[0],r[1],s),e=(0,n.a6)(r[1],r[2],s);h.setE((0,n.a6)(t,e,s));const i=(0,n.a6)(o[0],o[1],s),u=(0,n.a6)(o[1],o[2],s);m.setE((0,n.a6)(i,u,s));const c=(0,n.a6)(a[0],a[1],s),g=(0,n.a6)(a[1],a[2],s);l.setE((0,n.a6)(c,g,s))}h.divThisE(l),m.divThisE(l);const u=new n.P(h.value(),m.value());qi([t[0].value(),t[1].value(),t[2].value()],u),i.x.set(u.x,h.eps()),i.y.set(u.y,m.eps())}([Wt.constructPoint2D(i[0]),Wt.constructPoint2D(i[1]),Wt.constructPoint2D(i[2])],[new n.H(r[0]),new n.H(r[1]),new n.H(r[2])],e,s)}(this,t,e)}queryCoord2DExtension(t,e,s){if(s){if(t<0)return void Pe(new na({start:this.getStartXY(),end:this.getStartXY().add(this.getTangent(0).getUnitVector())}),t,e);if(t>1)return void Pe(new na({start:this.getEndXY(),end:this.getEndXY().add(this.getTangent(1).getUnitVector())}),t-1,e)}const i=(0,n.m)(n.P,3);this.queryControlPoints(i),wi(i,this.m_weights,t,e)}getCoordX(t){const e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.x}getCoordY(t){const e=new n.P;return this.queryCoord2DExtension(t,e,!0),e.y}cut(t,e,s){const i=new ra;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=os.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=os.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){!function(t,e,s){const r=(0,n.m)(n.P,3);t.queryControlPoints(r);const o=new Array(3);t.queryWeights(o),function(t,e,s,r){s.value()<0&&s.set(0,s.eps()),s.value()>1&&s.set(1,s.eps());const o=(0,n.m)(Wt,4);(function(t,e,s,r,o){const a=[Wt.constructPoint2D(t[0]),Wt.constructPoint2D(t[1]),Wt.constructPoint2D(t[2])];a[2].subThisE(a[0]),a[1].subThisE(a[0]),a[0].setCoords(0,0),function(t,e,s,r,o){(0,i.g)(!0);const a=[t[0].clone(),t[1].clone(),t[2].clone()];if(!a[0].isZero()){for(let t=1;t<3;++t)a[t].subThisE(a[0]);a[0]=Wt.constructCoords(0,0)}const h=Js(a,e,0,r),m=function(t,e,s){if(s.toDouble()<=.5){const e=(0,n.a5)(t[0],t[1],s),i=(0,n.a5)(t[1],t[2],s);return(0,n.a5)(e,i,s)}{const e=(0,n.a6)(t[0],t[1],s),i=(0,n.a6)(t[1],t[2],s);return(0,n.a6)(e,i,s)}}(e,0,r),l=h.divE(m);o[0].setE(l);const u=[e[1].mulE(e[0]),e[2].mulE(e[0]).mul(.5),e[1].mulE(e[2])],c=Js([t[1].subE(t[0]),t[2].subE(t[0]),t[2].subE(t[1])],u,0,r).mul(2),g=m.sqr(),_=c.divE(g);o[1].setE(_)}(a,[new n.H(e[0]),new n.H(e[1]),new n.H(e[2])],0,r,o)})(t,e,0,s,o),r.setE(o[1])}(r,o,e,s)}(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.t)("Quadratic_rational_bezier.cut_bezier_ignore_attributes");const r=(0,n.m)(n.P,3);this.queryControlPoints(r);const o=[0,0,0];_i(r,this.m_weights,t,e,r,o),s.setControlPointsAndWeights(r,o)}splitBezierIgnoreAttributes(t,e,s){}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?this.getCoordX(t):this.getCoordY(t);const i=this.calculateLength2D(),r=i>0?this.tToLength(t)/i:0,o=os.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,n.$)(o,a,h,r,os.getDefaultValue(e))}getClosestCoordinate(t,e){return oi(this,t,n.E.unit(),e,-1)}getClosestCoordinateOnInterval(t,e,s=-1){return oi(this,t,0,!1,s)}getYMonotonicParts(t,e){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.t)("");const s=Os(this);let n=0;if(2===s.specialPointsCount())return 0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)ui(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){s&&(s.length=9),i&&(i.length=9);const r=new Array(3),o=(0,n.m)(n.H,2),a=new n.E(0,1);let h=0;const m=(0,n.m)(n.P,3);if(this.queryControlPoints(m),t){if(r[0]=new n.H(m[0].y).sub(e).mul(this.m_weights[0]),r[1]=new n.H(m[1].y).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.H(m[2].y).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),h=Ze(r[2],r[1],r[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordX(o[t].value())}else if(r[0]=new n.H(m[0].x).sub(e).mul(this.m_weights[0]),r[1]=new n.H(m[1].x).sub(e).mul(this.m_weights[1]),r[2]=r[0].subE(r[1].mul(2)).addE(new n.H(m[2].x).sub(e).mul(this.m_weights[2])),r[1]=r[1].subE(r[0]).mulThisByPower2(2),h=Ze(r[2],r[1],r[0],a,!1,o),s)for(let t=0;t<h;t++)s[t]=this.getCoordY(o[t].value());if(i)for(let t=0;t<h;t++)i[t]=o[t].value();else s&&(0,n.W)(s,0,h,n.F);return h}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=[Number.NaN,Number.NaN],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return Kt(this,t)}isDegenerate3D(t,e){return!1}queryLooseEnvelope(t){if(t instanceof o)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=o.constructEmpty();this.queryEnvelope(t);const s=n.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,n.m)(n.P,3);this.queryControlPoints(s),_i(s,this.m_weights,t.vmin,t.vmax,s,[0,0,0]),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 js(this,t,!0)}lengthToT(t){return function(t,e){const s=js(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const r=[0];return 1!==He(new ei(t,e),n.E.unit(),1,r)&&(0,i.b)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=function(t){const e=(0,n.m)(n.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=Ti(e);if(1===s){const e=(0,n.m)(n.P,3);cn(t,e);const s=e[2].clone(),i=e[1].clone(),r=new n.P,o=s.y*i.x-s.x*i.y;return r.x=-(4*s.x+5*i.x)*o/60,r.y=-(4*s.y+5*i.y)*o/60,r}if(0===s)return new n.P(0,0);(0,i.g)(s>0);const r=t[1].sub(t[0]),o=t[2].sub(t[0]);if(s<1){const t=Math.sqrt(1-s),e=Math.sqrt(1+s),i=(r.y*o.x-r.x*o.y)*s/Math.pow(t*e,5)/12,n=Math.atan2(t,e),a=s*t*e,h=s*s,m=r.mul(2*(2+h)),l=o.mul(2*h-5),u=m.add(l).mul(a),c=o.sub(r.mul(2*h)).mul(6*n);return u.add(c).mul(i)}{const t=Math.sqrt(s-1),e=Math.sqrt(s+1),i=(r.y*o.x-r.x*o.y)*s/Math.pow(t*e,5)/12,n=Math.atanh(t/e),a=s*t*e,h=s*s,m=r.mul(4).sub(o.mul(5)),l=r.add(o).mul(2*h),u=m.add(l).mul(a),c=o.sub(r.mul(2*h)).mul(6*n);return u.add(c).mul(i)}}(e,s)}(this),s=si(this);return e.x+=(this.getStartX()-t.x)*s,e.y+=(this.getStartY()-t.y)*s,e}calculateWeightedCentroid2D(){const t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){if(0===t.m_weights[1])return!0;const e=n.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const r=new n.P;if(e<0||s>1)return r.setNAN(),r;if(e>s&&(0,i.t)("calculate_sub_weighted_centroid"),e===s||t.isDegenerate(0))return r.setCoords(0,0),r;const o=Os(t),a=ii(t),h=a/t.calculateUpperLength2D();let m=e,l=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){l=t-1;break}r.setCoords(0,0);for(let e=l+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),n=zs(t,m,i,h,a);if(r.addThis(n),m=i,s<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}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=(0,n.m)(n.P,3);return this.queryControlPoints(e),ti(e,this.m_weights,t)}getDerivative(t){const e=(0,n.l)(t,0,1),s=(0,n.m)(n.P,4);return Zs(this,1,e,s),s[1]}getCurvature(t){const e=(0,n.m)(n.P,4);Zs(this,2,t,e);const s=e[1].sqrLength();return 0===s?Number.NaN:(e[1].divThis(Math.sqrt(s)),e[1].crossProduct(e[2])/s)}isIntersecting(t,e,s){return!1}isIntersectingPoint(t,e,s){return!1}isIntersectingPoint3D(t,e,s,i,n=1){return!1}isMonotoneQuickAndDirty(){const t=(0,n.m)(n.P,3);return this.queryControlPoints(t),li(t)}getMonotonicPartParams(t,e){const s=Os(this),n=s.specialPointsCount();if(!e)return s.specialPointsCount();t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s.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=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(this.m_YStart,this.m_YStart=this.m_YEnd),this.m_weights[2]=(0,n.b)(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++)this.m_attributes[t+e]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cachedValues=null}}isLine(){return!1}isDegenerateToLineHelper(t){const e=[t];return!!Jt(this,e)&&function(t,e){const s=t.getEndXY().sub(t.getStartXY()),i=s.length(),n=t.getControlPoint1();return n.subThis(t.getStartXY()),!(Math.abs(n.crossProduct(s))/i>e)}(this,e[0])}copyIgnoreAttributes(t){const e=(0,n.m)(n.P,3);this.queryControlPoints(e);const s=[0,0,0];this.queryWeights(s),t.setControlPointsAndWeights(e,s)}calculateArea2DHelper(){return si(this)}absNorm(){return this.getStartXY().norm(1)+this.getEndXY().norm(1)+this.m_cp.norm(1)}absNormXYZ(t){return(0,i.g)(0),0}queryEnvelopeW(t,e){hi(this,t,e)}setSegmentFromCoords(t,e){const s=[0,0,0];this.queryWeights(s),this.constructWeights(t[0],this.getControlPoint1(),t[e-1],s[0],s[1],s[2])}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=(0,n.m)(n.P,3);this.queryControlPoints(e);const s=n.P.sqrDistance(e[1],e[0]),i=n.P.sqrDistance(e[1],e[2]);let r=e[0].clone(),o=s;s>i&&(r=e[2].clone(),o=i);let a=!1;return o<=t&&0!==o&&(a=!0,this.setControlPoint1(r)),a}needsSnapControlPoints(t){if(!t)return!1;const e=(0,n.m)(n.P,3);this.queryControlPoints(e);const s=n.P.sqrDistance(e[1],e[0]),i=n.P.sqrDistance(e[1],e[2]);e[0].clone();let r=s;return s>i&&(e[2].clone(),r=i),r<=t&&0!==r}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return ui(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const r=!!i&&t.isMonotoneQuickAndDirty(),o=new n.T,a=(0,n.m)(n.P,3);a[0].setCoords(t.m_XStart,t.m_YStart),a[2].setCoords(t.m_XEnd,t.m_YEnd);const h=new n.P;h.setSub(a[2],a[0]),h.leftPerpendicularThis(),a[1].setAdd(a[0],h);const m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(s),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(a,m)?o.transformInPlace(t.m_cp):(0,n.B)(e,s,.5,t.m_cp),t.changeEndPoints2D(e,s),r&&ui(t)}(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],ri(e,ni(this))}reverseImpl(){this.m_weights[2]=(0,n.b)(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 t=0;t<3;t++)if(this.m_weights[t]!==e.m_weights[t])return!1;return!0}equalsImplTol(t,e){const s=t;if(!this.m_cp.isEqualPoint2D(s.m_cp,e))return!1;const i=(0,n.m)(n.P,3);this.queryControlPoints(i);const r=(0,n.m)(n.P,3);s.queryControlPoints(r);const o=[s.m_weights[0],s.m_weights[1],s.m_weights[2]];for(let t=0;t<3;t++){const s=new _;s.setCoordsPoint2DZ(i[t].mul(this.m_weights[t]),this.m_weights[t]);const n=new _;if(n.setCoordsPoint2DZ(r[t].mul(o[t]),o[t]),!s.isEqual(n,e))return!1}return!0}swapImpl(t){const e=t;e.m_cp=(0,n.b)(this.m_cp,this.m_cp=e.m_cp),e.m_weights=(0,n.b)(this.m_weights,this.m_weights=e.m_weights),function(t,e){e.m_cachedValues=(0,n.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Us(this)}intersect(t,e,s,i,n){return Jo(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,r){const o=new Ht;if(hi(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;const a=Os(t);let h=0;const m=[];let l=a.specialPoints[0];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=Ls(t,e,l,n);if(0===m.length)m.push(r);else if(r.t===r.tmin)(0,i.g)(m.at(-1).d<=r.d),m.at(-1).tmax=r.tmax;else if(m.at(-1).t===m.at(-1).tmax){(0,i.g)(m.at(-1).d>=r.d);const t=m.at(-1).tmin;m[m.length-1]=r,m.at(-1).tmin=t}else m.push(r);l=n}for(const t of m)if(t.d<=r){const e=t.t;s?(s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Us(this)}clearEndPointModified(){}setCpsAndWeights(t,e,s,n,r,o){(n<=0||o<=0||r<0)&&(0,i.t)("weights"),(t.isNAN()||e.isNAN()||s.isNAN())&&(0,i.t)("NAN control points in bezier are not supported"),this.setStartXY(t),this.m_cp.assign(e),this.m_weights[0]=n,this.m_weights[1]=r,this.m_weights[2]=o,this.setEndXY(s)}setCpsAndWeightsArray(t,e){this.setCpsAndWeights(t[0],t[1],t[2],e[0],e[1],e[2])}}as.type=i.G.enumRationalBezier2;class hs{static constructPoint2D(t){return new hs(n.M.constructDouble(t.x),n.M.constructDouble(t.y))}constructor(t,e){if(void 0===t)return this.x=(new n.M).setNAN(),void(this.y=(new n.M).setNAN());this.x=t.clone(),this.y=e.clone()}assignPoint2D(t){return this.x.setDouble(t.x),this.y.setDouble(t.y),this}setCoords(t,e){return this.x.setThis(t),this.y.setThis(e),this}asPoint2D(){return new n.P(this.x.value(),this.y.value())}crossProduct(t){return this.x.mul(t.y).sub(this.y.mul(t.x))}leftPerpendicularThis(){const t=this.x.clone();this.x=this.y.clone().negate(),this.y=t}clone(){return new hs(this.x,this.y)}dotProduct(t){return this.x.mul(t.x).add(this.y.mul(t.y))}add(t){return new hs(this.x.add(t.x),this.y.add(t.y))}sub(t){return new hs(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)}}class ms{constructor(t){return t.coefsT?(this.m_zeroCtor=t.zeroCtor,this.m_elements=t.coefsT.map((t=>t.clone())),(0,i.g)(this.m_elements.length===t.power+1),void this.updatePower()):t.coef0?(this.m_zeroCtor=t.zeroCtor,void(this.m_elements=[t.coef0.clone()])):t.copy?(this.m_zeroCtor=t.copy.m_zeroCtor,void(this.m_elements=t.copy.m_elements.map((t=>t.clone())))):(this.m_zeroCtor=t.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}power(){return this.m_elements.length-1}addElement(t){this.m_elements.push(t.clone())}fmSubThis(t,e){return(0,i.g)(0),this}addThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].addThis(t.m_elements[s]);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(t){return(0,i.g)(0),this}sub(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);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(t){return(0,i.g)(0),this}subNumber0(t){return(0,i.g)(0),this}subShifted(t,e){const s=this.power(),i=t.power()+e,n=Math.min(this.power(),i);let r=0;for(let s=e;s<=n;++s)this.m_elements[s].subThis(t.m_elements[r]),r++;if(i<=s)return this.updatePower(),this;this.m_elements.length=i+1;for(let t=s+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let e=n+1;e<=i;++e)this.m_elements[e].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 i=s;i<=r;++i)this.m_elements[i].fmSubThis(t.m_elements[o],e),o++;if(n<=i)return this.updatePower(),this;this.m_elements.length=n+1;for(let t=i+1;t<this.m_elements.length;++t)this.m_elements[t]=new this.m_zeroCtor;for(let s=r+1;s<=n;++s)this.m_elements[s].fmSubThis(t.m_elements[o++],e);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 i=0,n=e.power();i<=n;i++){const n=this.m_elements[t].clone();n.mulThis(e.m_elements[i]),t+i<s.length?s[t+i].addThis(n):s.push(n)}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(t){return(0,i.g)(0),this}mulBigint0(t){return(0,i.g)(0),this}mulBigIntThis(t){return(0,i.g)(0),this}mulInt320(t){return(0,i.g)(0),this}div0(t){return(0,i.g)(0),this}absThis(){return(0,i.g)(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()),r=this.clone();let o=r.power();const a=r.power()-t.power();let h=a;for(e.m_elements=(0,n.m)(e.m_zeroCtor,a+1);;){if(o<t.power()){s.assignMove(r);break}if(o===r.power()){const s=r.getElement(r.power());s.divThis(i),r.subShiftedWithCoef(t,s,r.power()-t.power()),e.m_elements[h]=s.clone()}h--,o--}s.updatePower(),e.updatePower()}divThis(t){return(0,i.g)(0),this}subThis(t){const e=Math.min(this.power(),t.power());for(let s=0;s<=e;++s)this.m_elements[s].subThis(t.m_elements[s]);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(t,e){(0,i.g)(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(n.M.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 ls extends ms{constructor(t){super(void 0===t?{zeroCtor:n.M}:{...t,zeroCtor:n.M})}clone(){return new ls({copy:this})}absEvaluate(t){const e=this.power(),s=this.m_elements[e].clone();s.absThis();const i=t.clone();i.absThis();for(let t=e-1;t>=0;--t)s.mulThis(i),s.addThis(this.m_elements[t].abs());return s}}class us extends ms{constructor(t){super(void 0===t?{zeroCtor:ls}:{...t,zeroCtor:ls})}clone(){return new us({copy:this})}constructFromMPValues(t,e){this.m_elements.length=0;for(let s=0;s<=e;++s)this.m_elements.push(new ls({coef0:t[s]}));return this.updatePower(),this}}function cs(t,e,s,r,o,a,h,m,l,u,c,g,_,d,p,f,x,y=!1){const P={polypoly1:new us,polypoly2:new us,polyX2:new ls,polyY2:new ls,polyX2Deriv:new ls,polyY2Deriv:new ls,polypolyX1:new us,polypolyY1:new us,polypolyX1Deriv:new us,polypolyY1Deriv:new us,lazyPolypolyD1:new us,lazyPolypolyD1Deriv:new us,lazyPolyD2:new ls,lazyPolyD2Deriv:null,polypoly11:new us,polypoly12:new us,tempPp:new us,tempPp1:new us,tempPp2:new us,tempP:new ls,tempP1:new ls,tempP2:new ls};P.polyX2.construct(h,m),P.polyY2.construct(l,u),P.polypolyX1.constructFromMPValues(t,e),P.polypolyY1.constructFromMPValues(s,r),P.polypoly11.assignCopy(P.polypolyX1),P.polypoly12.assignCopy(P.polypolyY1),c&&(P.lazyPolyD2.construct(c,g),P.polypoly11.mulElementThis(P.lazyPolyD2),P.polypoly12.mulElementThis(P.lazyPolyD2)),o?(P.lazyPolypolyD1.constructFromMPValues(o,a),P.lazyPolypolyD1Deriv=new us({copy:P.lazyPolypolyD1}),P.lazyPolypolyD1Deriv.derivative1This(),P.tempPp.assignCopy(P.lazyPolypolyD1),P.tempPp.mulElementThis(P.polyX2),P.polypoly11.subThis(P.tempPp),P.tempPp.assignCopy(P.lazyPolypolyD1),P.tempPp.mulElementThis(P.polyY2),P.polypoly12.subThis(P.tempPp)):(P.polypoly11.sub0This(P.polyX2),P.polypoly12.sub0This(P.polyY2)),P.polypolyX1Deriv.assignCopy(P.polypolyX1),P.polypolyX1Deriv.derivative1This(),P.polypolyY1Deriv.assignCopy(P.polypolyY1),P.polypolyY1Deriv.derivative1This(),o&&(P.polypolyX1Deriv.mulThis(P.lazyPolypolyD1),P.tempPp2.assignCopy(P.lazyPolypolyD1Deriv),P.tempPp2.mulThis(P.polypolyX1),P.polypolyX1Deriv.subThis(P.tempPp2),P.polypolyY1Deriv.mulThis(P.lazyPolypolyD1),P.tempPp2.assignCopy(P.lazyPolypolyD1Deriv),P.tempPp2.mulThis(P.polypolyY1),P.polypolyY1Deriv.subThis(P.tempPp2)),P.polyX2Deriv.assignCopy(P.polyX2),P.polyX2Deriv.derivative1This(),P.polyY2Deriv.assignCopy(P.polyY2),P.polyY2Deriv.derivative1This(),c&&((0,i.g)(null===P.lazyPolyD2Deriv),P.lazyPolyD2Deriv=new ls({copy:P.lazyPolyD2}),P.lazyPolyD2Deriv.derivative1This(),P.polyX2Deriv.mulThis(P.lazyPolyD2),P.tempP1.assignCopy(P.lazyPolyD2Deriv),P.tempP1.mulThis(P.polyX2),P.polyX2Deriv.subThis(P.tempP1),P.polyY2Deriv.mulThis(P.lazyPolyD2),P.tempP1.assignCopy(P.lazyPolyD2Deriv),P.tempP1.mulThis(P.polyY2),P.polyY2Deriv.subThis(P.tempP1)),P.polypoly1.assignCopy(P.polypoly11),P.polypoly1.mulElementThis(P.polyX2Deriv),P.tempPp.assignCopy(P.polypoly12),P.tempPp.mulElementThis(P.polyY2Deriv),P.polypoly1.addThis(P.tempPp),P.polypoly2.assignCopy(P.polypolyX1Deriv),P.polypoly2.mulElementThis(P.polyY2Deriv),P.tempPp.assignCopy(P.polypolyY1Deriv),P.tempPp.mulElementThis(P.polyX2Deriv),P.polypoly2.subThis(P.tempPp);let E=[];const C=[];x||(x=[]),f||(f=[]),Ps(P.polypoly11,P.polypoly12,P.tempP);let v=57,b=.25*Number.EPSILON;const S=[];let I=Es(P.tempP,0,p,b,v,S);if(I<0)return-1;for(let t=0;t<I;t++){ls.evaluateCoefs(P.polypoly11,n.M.constructDouble(S[t]),P.tempP1);const e=[];let s=Es(P.tempP1,0,d,b,v,e);if(0!==s)if(ls.evaluateCoefs(P.polypoly12,n.M.constructDouble(S[t]),P.tempP2),s<0){s=Es(P.tempP2,0,d,b,v,e),s<0&&(0,i.b)("mp_curve_proximity");for(let i=0;i<s;i++)C.push((0,n.d)(e[i],S[t]))}else{const i=P.tempP2.absEvaluate(n.al);i.mulThis(n.M.constructDouble(1e-12));for(let r=0;r<s;r++){const s=P.tempP2.evaluate(n.M.constructDouble(e[r]));s.absThis(),s.lt(i)&&C.push((0,n.d)(e[r],S[t]))}}}I=C.length,Ps(P.polypoly1,P.polypoly2,P.tempP),v=57,b=.25*Number.EPSILON;const w=[];let D=Es(P.tempP,0,p,b,v,w);D<0&&(D=0);for(let t=0;t<D;t++){ls.evaluateCoefs(P.polypoly1,n.M.constructDouble(w[t]),P.tempP1);const e=[];let s=Es(P.tempP1,0,d,b,v,e);if(0!==s)if(ls.evaluateCoefs(P.polypoly2,n.M.constructDouble(w[t]),P.tempP2),s<0){if(s=Es(P.tempP2,0,d,b,v,e),s<0)continue;for(let i=0;i<s;i++)E.push((0,n.d)(e[i],w[t]))}else{const i=P.tempP2.absEvaluate(n.al);i.mulThis(n.M.constructDouble(1e-12));for(let r=0;r<s;r++){const s=P.tempP2.evaluate(n.M.constructDouble(e[r]));s.absThis(),s.lt(i)&&E.push((0,n.d)(e[r],w[t]))}}}if(D=E.length,0===I&&0===D)return 0;E=E.concat(C),E.sort(((t,e)=>y?(0,n.F)(t.second,e.second):(0,n.F)(t.first,e.first)));const T=(0,n.v)(E,((t,e)=>t.first===e.first&&t.second===e.second));E=E.slice(0,T),f.length=0,x.length=0;for(const t of E)f.push(t.first),x.push(t.second);return(0,i.g)(f.length===x.length),x.length}function gs(t,e,s,i,r,o,a,h,m,l,u){const c={polyIntersect:new ls,polyX1:new ls,polyY1:new ls,polyX1Deriv:new ls,polyY1Deriv:new ls,lazyPolyD1:new ls,lazyPolyD1Deriv:new ls,tempP:new ls,tempP1:new ls,tempP2:new ls,polypoly1Proximity:new us,polypoly2Proximity:new us};c.polyX1.construct(t,e),c.polyY1.construct(s,i),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.polyIntersect.assignCopy(c.polyX1),c.polyIntersect.mulThis(c.polyX1),c.polyIntersect.mulElementThis(a[0]),c.tempP.assignCopy(c.polyY1),c.tempP.mulThis(c.polyY1),c.tempP.mulElementThis(a[1]),c.polyIntersect.addThis(c.tempP),r?(c.lazyPolyD1.construct(r,o),c.tempP.assignCopy(c.lazyPolyD1),c.tempP.mulThis(c.lazyPolyD1),c.tempP.mulElementThis(a[2]),c.polyIntersect.addThis(c.tempP)):c.polyIntersect.add0(a[2]);{const r=a[0].clone(),o=r.clone();o.sqrThis();const h=a[1].clone(),m=h.clone();m.sqrThis();const l=a[2].clone(),u=r.clone();u.subThis(h),c.polyX1.construct(t,e),c.polyX1Deriv.assignCopy(c.polyX1),c.polyX1Deriv.derivative1This(),c.polyY1.construct(s,i),c.polyY1Deriv.assignCopy(c.polyY1),c.polyY1Deriv.derivative1This(),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(m),c.tempP.mulElementThis(l),c.polypoly1Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(h.mul(u).mul(l).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1),c.tempP.mulElementThis(r.mul(m)),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1),c.tempP1.mulElementThis(o.mul(h)),c.tempP.addThis(c.tempP1),c.tempP.add0(u.mul(u).mul(l)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulElementThis(u.mul(r).mul(h).ldexpThis(1)),c.polypoly1Proximity.addElement(c.tempP),c.tempP.construct0(r.mul(u).mul(u)),c.polypoly1Proximity.addElement(c.tempP),c.polypoly1Proximity.updatePower(),c.tempP.construct0(n.ak),c.polypoly2Proximity.construct0(c.tempP),c.tempP.assignCopy(c.polyX1),c.tempP.mulThis(c.polyX1Deriv),c.tempP1.assignCopy(c.polyY1),c.tempP1.mulThis(c.polyY1Deriv),c.tempP.addThis(c.tempP1),c.tempP.mulElementThis(r.mul(h)),c.polypoly2Proximity.addElement(c.tempP),c.tempP.assignCopy(c.polyX1Deriv),c.tempP.mulElementThis(u.mul(r)),c.polypoly2Proximity.addElement(c.tempP),c.polypoly2Proximity.updatePower()}const g=[],_=[];u||(u=[]);let d=2*c.polyIntersect.power()+58;const p=.5*Number.EPSILON,f=Es(c.polyIntersect,0,m,p,d,_);if(f<0)return-1;Ps(c.polypoly1Proximity,c.polypoly2Proximity,c.tempP),d=2*c.tempP.power()+58;let x=Es(c.tempP,0,m,p,d,g);if(x<0&&(x=0),0===f&&0===x)return 0;const y=g.concat(_);u.length=y.length,(0,n.D)(u,y,0,0,y.length),(0,n.n)(u);const P=(0,n.v)(u,((t,e)=>0===(0,n.F)(t,e)));return u.length=P,u.length}function _s(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 ds(t,e,s,i,r,o,a){if(t.isZero())return o?(a[0].setInt32(1),r.containsCoordinate(1)?1:0):_s(e,s,r,a[0]);if(o){let e=2;return a[0].setInt32(1),s.equals(t)?(a[1].setInt32(1),e=1):a[1].setThis(s.div(t)),r.containsCoordinate(a[1].value())||(e=1),r.containsCoordinate(a[0].value())||(e--,a[0].setThis(a[1])),2===e&&a[0].value()>a[1].value()&&(a[1]=(0,n.b)(a[0],a[0]=a[1])),e}const h=e.clone();h.sqrThis();const m=t.clone();if(m.mulThis(s).ldexpThis(2).negateThis().addThis(h),m.LZ())return 0;const l=i+2,u=n.M.sqrt(m,l),c=u.clone();e.LZ()&&c.negateThis(),c.addThis(e).limitPrecisionThis(l).ldexpThis(-1).negateThis();let g=0;return a[0].setThis(c).divThis(n.M.constructAssign(t,l)).limitPrecisionThis(i),(r.isEmpty()||r.containsCoordinate(a[0].value()))&&g++,u.isZero()||c.isZero()||(a[g].setThis(s).divThis(c).limitPrecisionThis(i),(r.isEmpty()||r.containsCoordinate(a[g].value()))&&g++,2===g&&a[0].gt(a[1])&&(a[1]=(0,n.b)(a[0],a[0]=a[1]))),g}function ps(t,e,s,r,o,a,h,m){if(t.isZero())return ds(e,s,r,o,a,h,m);const l=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,n.b)(m[t],m[t]=m[s-1]),s--);e=s}return(0,n.W)(m,0,e,((t,e)=>t.compare(e))),e};if(r.isZero()){let i=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),i=1),l(ds(t,e,s,o,a,h,m.slice(1)),i)}if(h){let s=0;a.containsCoordinate(1)&&(m[0].setInt32(1),s=1);const i=e.add(t),n=r.negate(),h=t.add(i).add(n).isZero();return l(ds(t,i,n,o,a,h,m.slice(s)),s)}const u=new n.M,c=new n.M,g=new n.M,_=e.clone();if(_.isZero())c.setThis(s),c.divThis(t),g.setThis(r),c.divThis(t);else{_.divThis(t).divDoubleThis(3).negateThis();const i=e.clone();i.sqrThis();const n=t.clone();n.sqrThis(),c.setThis(t),c.mulThis(s).mulDoubleThis(3).subThis(i).divThis(n).divDoubleThis(3),g.setThis(i),g.mulThis(e),g.ldexpThis(1),u.setThis(t),u.mulThis(e).mulThis(s).mulDoubleThis(9),g.subThis(u),u.setThis(n),u.mulThis(r).mulDoubleThis(27),g.addThis(u),g.divThis(n).divThis(t).divDoubleThis(27)}if(c.isZero()){const t=g.clone();return t.negateThis(),t.isZero()?(m[0].setThis(_),Ds(a,o,m,1)):(m[0].setThis(n.M.cubicRoot(g,o).add(_)),Ds(a,o,m,1))}const d=g.clone();if(d.sqrThis().ldexpThis(-2),u.setThis(c.clone()),u.sqrThis().mulThis(c).divDoubleThis(27),d.addThis(u),d.isZero())return m[0].setThis(g),m[0].mulDoubleThis(3).divThis(c),m[1].setThis(m[0]),m[1].negateThis(),m[1].ldexpThis(-1),m[0].addThis(_),m[1].addThis(_),Ds(a,o,m,2);if(d.GZ())return d.setThis(n.M.sqrt(d,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.addThis(d),m[0].setThis(n.M.cubicRoot(u,o+8)),u.setThis(g),u.ldexpThis(-1).negateThis(),u.subThis(d),m[0].addThis(n.M.cubicRoot(u,o+8)),m[0].addThis(_),Ds(a,o,m,1);u.setThis(c),u.divDoubleThis(3).negateThis(),(0,i.g)(u.GEZ());const p=n.M.sqrt(u,o+8),f=p.clone();f.negateThis(),f.addThis(_),p.addThis(_);const x=n.M.constructDouble(a.isEmpty()?-Number.MAX_VALUE:a.vmin),y=n.M.constructDouble(a.isEmpty()?Number.MAX_VALUE:a.vmax),P=new ls({zeroCtor:n.M});P.construct0(r),P.addElement(s),P.addElement(e),P.addElement(t);const E=new ls({copy:P});E.derivative1This();let C=0;const v=(0,n.m)(n.M,4);v[C++].setThis(x),f.gt(x)&&f.lt(y)&&v[C++].setThis(f),p.gt(x)&&p.lt(y)&&v[C++].setThis(p),v[C++].setThis(y);const b=3*o;let S=52,I=Number.EPSILON;for(;S<b;)2*S<=b?(I*=I,S*=2):(I*=Number.EPSILON,S+=52);S+=2;let w=0,D=!1;for(let t=1;t<C;t++)if(bs(P,E,v[t-1],v[t],I,S,m[0])){w=1,D=t+1<C;break}if(!w)return 0;if(D){const t=new ls({zeroCtor:n.M,coef0:m[0]});t.negateThis(),t.addElement(n.al);const e=new ls({zeroCtor:n.M}),s=new ls({zeroCtor:n.M});P.div(t,e,s),(0,i.g)(2===e.power()),(0,i.g)(0===s.power());const r=ds(e.getElement(2),e.getElement(1),e.getElement(0),o,a,!1,m.slice(1));(0,i.g)(r>=0&&r<=2),w+=r}return Ds(a,o,m,w)}function fs(t,e,s,i,r,o,a,h,m){if(t.isZero())return ps(e,s,i,r,o,a,h,m);const l=(t,e)=>{if(t>0){let s=e+t;for(let t=1;t<s;t++)m[t].equals(m[0])&&(m[s-1]=(0,n.b)(m[t],m[t]=m[s-1]),s--);e=s}return(0,n.W)(m,0,e,((t,e)=>t.compare(e))),e};if(r.isZero()){let n=0;return a.containsCoordinate(0)&&(m[0].setInt32(0),n=1),l(ps(t,e,s,i,o,a,h,m.slice(n)),n)}const u=new ls({zeroCtor:n.M,coef0:r});if(u.addElement(i),u.addElement(s),u.addElement(e),u.addElement(t),h){let t=0;a.containsCoordinate(1)&&(m[0].setInt32(1),t=1);const e=new ls({zeroCtor:n.M,coef0:n.M.constructInt32(-1)});e.addElement(n.M.constructInt32(1));const s=new ls({zeroCtor:n.M}),i=new ls({zeroCtor:n.M});return u.div(e,s,i),l(ps(3===s.power()?s.getElement(3):n.ak.clone(),s.power()>=2?s.getElement(2):n.ak.clone(),s.power()>=1?s.getElement(1):n.ak.clone(),s.getElement(0),o,a,s.evaluate(n.al).isZero(),m.slice(t)),t)}if(u.getElement(0).isZero()){let t=0;for(a.containsCoordinate(0)&&(t=1,m[0].setDouble(0));u.getElement(0).isZero()&&u.power()>0;)u.shiftRight(1);const e=ps(3===u.power()?u.getElement(3):n.ak.clone(),u.power()>=2?u.getElement(2):n.ak.clone(),u.power()>=1?u.getElement(1):n.ak.clone(),u.getElement(0),o,a,!1,m.slice(t));return e>0&&(t+=e),(0,n.W)(m,0,t,((t,e)=>t.compare(e))),t}let c=52,g=Number.EPSILON;for(;c<o;)2*c<=o?(g*=g,c*=2):(g*=Number.EPSILON,c+=52);c+=2;const _=ws(u),d=n.M.constructDouble(Math.max(Math.abs(a.vmax),Math.abs(a.vmin)));return g=(_.lt(d)?_:d).mul(n.M.constructDouble(g)).toDouble(),Is(u,a,g,c,h,0,m,4)}function xs(t,e){let s=t,i=e;i.power()>s.power()&&(i=(0,n.b)(s,s=i));const r=s.power()-i.power(),o=new ls({copy:s.getElement(s.power())});s.mulThis(i.getElement(i.power()));for(let t=0,e=s.power();t<e;t++)if(t>=r){const e=new ls({copy:i.getElement(t-r)});e.mulThis(o);const n=s.getElement(t).sub(e);s.setElement(t,n)}s.setElement(s.power(),s.getElement(s.power()).setZero()),s.updatePower(),ys(s)}function ys(t){let e=0;for(;e<t.power()&&t.getElement(e).isZero();)e++;return e>0&&(t.shiftRight(e),!0)}function Ps(t,e,s){const i=t.clone(),n=e.clone();for(ys(i),ys(n);0!==i.power()||0!==n.power();)xs(i,n);s.assignMove(i.getElement(0))}function Es(t,e,s,i,r,o){o.length=0;const a=t.power(),h=(0,n.m)(n.M,2*a+4),m=function(t,e,s,i,r,o,a){if(0===t.power())return t.isZero()?-1:0;const h=t.evaluate(n.M.constructInt32(1)).isZero();if(1===t.power()){const s=_s(t.getElement(1),t.getElement(0),e,o.at(0));return o[0].limitPrecisionThis(i),1!==s?0:(o[0].limitPrecisionThis(i),1)}return 2===t.power()?ds(t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):3===t.power()?ps(t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):4===t.power()?fs(t.getElement(4),t.getElement(3),t.getElement(2),t.getElement(1),t.getElement(0),i,e,h,o):Is(t,e,s,i,h,0,o,a)}(t,s||n.E.unit(),i,r,0,h,h.length);if(m>0){o.length=0;for(let t=0;t<m;t++){const e=h[t].value();t>0&&e<=o.at(-1)||o.push(e)}return o.length}return m}function Cs(t,e,s){if((0,i.g)(s>=1),0===t.power())return t.isZero()?-1:0;const n=t.getElement(0);return n.negateThis(),n.divThis(t.getElement(1)),e[0].setThis(n),1}function vs(t,e,s,r){if(t.power()<2)return Cs(t,s,r);(0,i.g)(r>=1);let o=t.getElement(1);o.mulThis(t.getElement(1));const a=t.getElement(0);if(a.mulThis(t.getElement(2)),a.ldexpThis(2),o.subThis(a),o.LZ())return 0;if(o.isZero()){const i=t.getElement(1);return i.negateThis(),i.divThis(t.getElement(2)),i.ldexpThis(-1),i.limitPrecisionThis(e),s[0].setThis(i),1}(0,i.g)(r>=2),o=n.M.sqrt(o,e+8);const h=t.getElement(1);h.negateThis();const m=h.clone();m.subThis(o),m.divThis(t.getElement(2)),m.ldexpThis(-1),m.limitPrecisionThis(e);const l=h.clone();return l.addThis(o),l.divThis(t.getElement(2)),l.ldexpThis(-1),l.limitPrecisionThis(e),m.lt(l)?(s[0].setThis(m),s[1].setThis(l)):(s[1].setThis(m),s[0].setThis(l)),2}function bs(t,e,s,r,o,a,h){let m=s.clone(),l=r.clone();m.limitPrecisionThis(a),l.limitPrecisionThis(a);let u=t.evaluate(m);u.limitPrecisionThis(a+2);let c=t.evaluate(l);if(c.limitPrecisionThis(a+2),u.GEZ()&&c.GEZ()||u.LEZ()&&c.LEZ())return u.absLessAbs(c)?(h=m,u.isZero()):(h=l,c.isZero());const g=c.LZ();g&&(c=(0,n.b)(u,u=c),l=(0,n.b)(m,m=l));const _=g?l:m,d=g?m:l,p=m.add(l).ldexpThis(-1);p.limitPrecisionThis(a);const f=l.sub(m);f.limitPrecisionThis(a),f.absThis();const x=f.clone();let y=t.evaluate(p),P=e.evaluate(p);const E=new ls({copy:t}),C=new ls({copy:e});{const s=Math.max(t.hiBitIndex(),e.hiBitIndex()),i=n.al.clone();i.ldexpThis(-(a+2));for(let n=64;n<s;){E.limitPrecisionThis(n),C.limitPrecisionThis(n);const r=E.evaluate(p),o=C.evaluate(p),a=r.sub(y),h=o.sub(P);if(a.divThis(y).absThis().lt(i)&&(P.isZero()||h.divThis(P).absThis().lt(i)))break;E.assignCopy(t),C.assignCopy(e),n=Math.min(n+64,s)}y.limitPrecisionThis(a+2),P.limitPrecisionThis(a+2)}let v=4,b=1,S=0,I=0,w=1;const D=n.M.constructDouble(.25*o),T=n.M.constructDouble(.5001);let N=0;for(;++N<300;){if(N>32&&S>0||P.isZero()||2===w&&S>1||1===w&&v<4)w=1,b>1&&b--;else if(w=2,I>1){const t=f.mul(P);t.absThis(),t.ldexpThis(-3),t.absLessAbs(y)&&b++}f.setThis(x);const t=new n.M;let e=!1;if(1===w)do{if(I>2){const e=f.clone();if(e.absThis(),e.ldexpThis(4),d.sub(_).ldexpThis(-1).gt(e)){if(p.equals(_)){t.setThis(p),p.setThis(_.add(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}if(p.equals(d)){t.setThis(p),p.setThis(d.sub(e)),p.limitPrecisionThis(a),x.setThis(p.sub(t));break}}}x.setThis(l.sub(m)),x.ldexpThis(-1),x.limitPrecisionThis(a),t.setThis(p),p.setThis(m.add(x)),p.limitPrecisionThis(a),p.lt(_)?p.setThis(_):p.gt(d)&&p.setThis(d),e=m.equals(p)||l.equals(p)}while(0);else for(;;){if(x.setThis(y.div(P)),x.limitPrecisionThis(a),1!==b&&x.mulDoubleThis(b),t.setThis(p),p.subThis(x),p.limitPrecisionThis(a),e=p.equals(t),p.lt(_)){if(b>1){p.setThis(t),b--;continue}x.setThis(t.sub(_)),p.setThis(_)}else if(p.gt(d)){if(b>1){p.setThis(t),b--;continue}x.setThis(t.sub(d)),p.setThis(d)}break}if(e||x.absLessAbs(D)){t.equals(p)||(y=E.evaluate(p),y.limitPrecisionThis(a+2));break}y=E.evaluate(p),y.limitPrecisionThis(a+2),P=C.evaluate(p),P.limitPrecisionThis(a+2);const s=m.clone(),i=l.clone();y.LZ()?(u.setThis(y),m.setThis(p)):(c.setThis(y),l.setThis(p)),2===w&&(m.equals(s)&&l.equals(i)||I>1&&!x.absLessAbs(T.mul(f)))?S++:S=0,1===w?(v++,I=0):(v=0,I++)}return N>=300&&(0,i.b)("Root_finder iterations exceeded"),h.setThis(p),!0}function Ss(t,e,s,i,r){const o=t.evaluate(s);if(o.isZero())return!0;const a=n.M.constructDouble(.5*i),h=s.clone();h.subThis(a);const m=t.evaluate(h),l=s.clone();l.addThis(a);const u=t.evaluate(l);if(m.LZ()&&u.GZ()||m.GZ()&&u.LZ())return!0;if(o.GZ()?m.LEZ()||u.LEZ():m.GEZ()||u.GEZ())return!0;const c=m.LEZ()&&u.LEZ(),g=m.GEZ()&&u.GEZ();let _=!1;return c?o.gt(m)&&o.gt(u)&&(_=!0):g&&o.lt(m)&&o.lt(u)&&(_=!0),!!_&&o.absThis().lt(n.M.constructDouble(1e-17))}function Is(t,e,s,r,o,a,h,m){(0,i.g)(s>0),(0,i.g)(m>=t.power());const l=h,u=[];let c=[];const g=new ls({zeroCtor:t.m_zeroCtor}),_=new ls({zeroCtor:t.m_zeroCtor}),d=new ls({zeroCtor:t.m_zeroCtor}),p=n.M.constructDouble(s),f=n.M.constructDouble(e.vmin),x=n.M.constructDouble(e.vmax),y=f.sub(p),P=x.add(p),E=ws(t),C=E.clone();if(C.negateThis(),y.lt(C))y.setThis(C.sub(p));else if(y.gt(E))return 0;if(P.gt(E))P.setThis(E.add(p));else if(P.lt(C))return 0;let v=t,b=null;if(o){const e=new ls({coef0:n.M.constructInt32(-1)});e.addElement(n.al),b=new ls,v=b;const s=new ls,i=new ls;for(t.div(e,s,i),b.assignCopy(s);v.evaluate(n.al).isZero();)v.div(e,s,i),b.assignCopy(s)}let S=!1;if(v.power()>0&&v.getElement(0).isZero())for(S=!0,b||(b=new ls({copy:v}),v=b);v.getElement(0).isZero();)b.shiftRight(1);let I=r+2*v.power()+2,w=s/Math.pow(2,v.power()+2),D=I;if(n.ak.gt(y)&&n.ak.lt(P))for(let t=0,e=v.power();t<e;t++)if(v.getElement(t).isZero()){u.push(n.ak.clone());break}for(let t=v.power()-1;t>0;t--)if(w*=2,I-=2,D-=2,v.power()-t!=1)if(v.power()-t!=2){_.assignMove(d),d.assignMove(v.derivative(t-1));let e=[];for(let t=0,s=c.length;t<s;++t)if(c[t].first.lte(c[t].second)){const s=new n.M;if(bs(_,g,c[t].first,c[t].second,w,I,s)){u.push(s);let i=s.sub(p);i.limitPrecisionThis(D),e.push((0,n.d)(c[t].first,i)),i=s.add(p),i.limitPrecisionThis(D),e.push((0,n.d)(i,c[t].second))}else e.push(c[t])}c=e,e=[],g.assignMove(_)}else{_.assignMove(v.derivative(t));const e=vs(_,I,l,m);(0,i.g)(e>=0&&e<=2);for(let t=0;t<e;t++)l[t].gt(y)&&l[t].lt(P)&&!l[t].isZero()&&u.push(l[t].clone());if(u.length>1&&u.sort(((t,e)=>t.compare(e))),u.length>0){let t=u[0].sub(p);t.limitPrecisionThis(D),c.push((0,n.d)(y.clone(),t));let e=1===u.length?P.clone():u[1].sub(p);t=u[0].add(p),t.limitPrecisionThis(D),e.limitPrecisionThis(D),c.push((0,n.d)(t,e)),u.length>1&&(e=2===u.length?P.clone():u[2].sub(p),e.limitPrecisionThis(D),t=u[1].add(p),t.limitPrecisionThis(D),c.push((0,n.d)(t,e)),u.length>2&&(t=u[2].add(p),t.limitPrecisionThis(D),c.push((0,n.d)(t,P.clone()))))}else c.push((0,n.d)(y.clone(),P.clone()));g.assignCopy(_),d.assignMove(v.derivative(t-1))}else _.assignMove(v.derivative(t)),1===Cs(_,l,m)&&(l[0].gt(y)&&l[0].lt(P)&&!l[0].isZero()&&u.push(l[0].clone()),g.assignMove(_),d.assignMove(v.derivative(t-1)));u.sort(((t,e)=>t.compare(e))),0===c.length&&(g.assignMove(v.derivative(v.power())),g.isZero()||c.push((0,n.d)(y.clone(),P.clone())));let T=0,N=0,A=0;const M=new n.M;for(;;){if(N<c.length){if(c[N].first.gt(c[N].second)){N++;continue}let t=!1;if(A<u.length&&u[A].lt(c[N].first)&&(t=!0),!t){bs(v,g,c[N].first,c[N].second,s,r,M)&&(M.lt(f)?l[T++].setThis(f):M.gt(x)?l[T++].setThis(x):l[T++].setThis(M)),N++;continue}}if(!(A<u.length))break;0!==A&&u[A-1].equals(u[A])||Ss(v,0,u[A],s)&&(M.setThis(u[A]),M.lt(f)?M.setThis(f):M.gt(x)&&M.setThis(x),0!==T&&l[T].equals(M)||l[T++].setThis(M)),A++}return S&&n.ak.gt(y)&&n.ak.lt(P)&&(l[T++].setThis(n.ak),(0,n.W)(l,0,T,((t,e)=>t.compare(e)))),o&&n.al.gt(y)&&n.al.lt(P)&&(l[T++].setThis(n.al),(0,n.W)(l,0,T,((t,e)=>t.compare(e)))),T}function ws(t){const e=t.getElement(t.power());e.limitPrecisionThis(53);const s=n.ak.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(n.al),s.mulThis(n.M.constructDouble(1+100*Number.EPSILON)),s}function Ds(t,e,s,i){let r=i;if(!t.isEmpty()){r=0;for(let e=0;e<i;++e)t.containsCoordinate(s[e].value())&&(r!==e&&s[r].setThis(s[e]),r++)}r>1&&(s[0].gt(s[1])&&(s[1]=(0,n.b)(s[0],s[0]=s[1])),r>2&&(s[0].gt(s[2])&&(s[2]=(0,n.b)(s[0],s[0]=s[2])),s[1].gt(s[2])&&(s[2]=(0,n.b)(s[1],s[1]=s[2]))));for(let t=0;t<r;++t)s[t].limitPrecisionThis(e);return r}const Ts=[[.33998104358485626,.6521451548625461],[.8611363115940526,.34785484513745385]],Ns=[[.1834346424956498,.362683783378362],[.525532409916329,.31370664587788727],[.7966664774136267,.22238103445337448],[.9602898564975363,.10122853629037626]],As=[[.09501250983763744,.1894506104550685],[.2816035507792589,.18260341504492358],[.45801677765722737,.16915651939500254],[.6178762444026438,.14959598881657674],[.755404408355003,.12462897125553388],[.8656312023878318,.09515851168249279],[.9445750230732326,.062253523938647894],[.9894009349916499,.027152459411754096]],Ms=[[.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]],Gs=[[.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]],qs=[[.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 Fs(t,e,s,i){const r=.5*(i-s),o=s+r,a=new n.K(0);for(let s=0,i=Math.trunc(t/2);s<i;++s){let i,h;switch(t){case 4:i=Ts[s][0],h=Ts[s][1];break;case 8:i=Ns[s][0],h=Ns[s][1];break;case 16:i=As[s][0],h=As[s][1];break;case 32:i=Ms[s][0],h=Ms[s][1];break;case 64:i=Gs[s][0],h=Gs[s][1];break;case 128:i=qs[s][0],h=qs[s][1];break;default:throw new Error("Quadrature_integral: invalid n")}const m=(0,n.ar)(-r,i,o),l=(0,n.ar)(r,i,o);a.pe(e(m)*h),a.pe(e(l)*h)}return a.getResult()*r}function Vs(t,e,s,r,o,a){return function(t,e,s,r,o,a){if(s<e&&(0,i.t)("xTo < xFrom"),s===e)return 0;const h=[0];let m=Number.MAX_VALUE;const l=[Number.MAX_VALUE];let u=0;const c=(0,n.a)(33,Number.NaN),g=(0,n.a)(33,Number.NaN),_=[0];c[0]=1;let d=0,p=0;for(let n=0;n<32;n++){if(u=Rs(e,s,r,0===n,u,_),g[n]=u,n+1>=t){Ys(n+1-t,t,c,g,0,h,l)||(0,i.b)("polynomial_interpolation");const e=o*Math.abs(h[0])+a,s=Math.abs(m-h[0]);if(s<=e&&Math.abs(l[0])<=e){if(d++,d>1&&(s<=.1*p||0===p||d>2))return h[0]}else d=0;p=s,m=h[0]}g[n+1]=g[n],c[n+1]=.25*c[n]}return h[0]}(t,e,s,a,r,o)}function Rs(t,e,s,i,r,o){let a=r;if(i)return o[0]=1,a=.5*(e-t)*(s(t)+s(e)),a;const h=o[0],m=(e-t)/h,l=t,u=new n.K(0);for(let t=1;t<=o[0];++t){const e=(t-.5)*m;u.add(s(l+e))}return a=.5*(a+(e-t)*u.getResult()/h),o[0]*=2,a}function Ys(t,e,s,i,r,o,a){let h=0,m=Math.abs(r-s[t]);const l=(0,n.a)(e,Number.NaN),u=(0,n.a)(e,Number.NaN);for(let n=0;n<e;++n){const e=Math.abs(r-s[t+n]);e<m&&(h=n,m=e),l[n]=i[t+n],u[n]=i[t+n]}let c=0,g=0,_=0;o[0]=i[t+h],h--;for(let i=1;i<e;i++){for(let n=0;n<e-i;n++){if(g=s[t+n]-r,_=s[t+n+i]-r,c=g-_,0===c)return!1;const e=(l[n+1]-u[n])/c;l[n]=g*e,u[n]=_*e}if(2*(h+1)<e-i){const t=h+1;a[0]=l[t]}else{const t=h;a[0]=u[t],h--}o[0]+=a[0]}return!0}class Xs{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 ks(t,e,s,r,o,a,h,m){for(;;){const l=n.P.distance(e[0],e[2]),u=n.P.distance(e[0],e[1])+n.P.distance(e[1],e[2]);if(u-l<=o+r*u)return t+(0,n.w)(l,u,.5);const c=(0,n.m)(n.P,4),g=t=>(Qs(e,s,1,t,c),c[1].length());if(0===h&&m<8){(0,i.g)(m<8);let l=g(0),c=g(1);a[0]+=2,l>c&&(c=(0,n.b)(l,l=c),e[2]=(0,n.b)(e[0],e[0]=e[2]),s[2]=(0,n.b)(s[0],s[0]=s[2]));let _=l/(l+c),d=1,p=u;for(;_<1/32&&p>=o+r*p;){d/=4;const t=g(d);a[0]++,_=l/(t+l);const i=new n.P;if(wi(e,s,.5*d,i),p=n.P.distance(i,e[0]),p<=o){const t=new n.P;wi(e,s,d,t),p+=n.P.distance(t,i)}}if(1!==d){const i=(0,n.m)(n.P,3),l=[0,0,0];gi(e,s,d,e,s,i,l),t=ks(t,i,l,r,o,a,0,m+1),h++,m++;continue}}let _=!1;const d=8;a[0]+=d;const p=Fs(d,g,0,1),f=16;a[0]+=f;const x=Fs(f,g,0,1);if(_=Math.abs(p-x)>o+r*u,!_)return t+x;if(h<8&&m<9){const i=(0,n.m)(n.P,3),l=[0,0,0];gi(e,s,.5,e,s,i,l),t=ks(t,i,l,r,o,a,h+1,m+1),h++,m++;continue}const y=32;a[0]+=y;const P=Fs(y,g,0,1);if(_=Math.abs(x-P)>o+r*u,!_)return t+P;const E=64;a[0]+=E;const C=Fs(E,g,0,1);if(_=Math.abs(P-C)>o+r*u,!_)return t+C;const v=128;a[0]+=v;const b=Fs(v,g,0,1);return _=Math.abs(C-b)>o+r*u,t+b}}function Hs(t,e,s,i,r){if(s===e)return 0;const o=(0,n.m)(n.P,3),a=[0,0,0];t.queryControlPoints(o),t.queryWeights(a);const h=[0,0,0],m=(0,n.m)(n.P,3);return _i(o,a,e,s,m,h),ks(0,m,h,i,r,[0],0,0)}let Bs=class{constructor(t,e,s){this.controlPoints=(0,n.aq)(t,3),this.weights=[0,0,0],(0,n.D)(this.weights,e,0,0,3),this.point=s.clone()}getMaxDerivative(){return 3}getValue(t,e){if(0===t){const t=new n.P;wi(this.controlPoints,this.weights,e,t);const s=(0,n.m)(n.P,4);return Qs(this.controlPoints,this.weights,1,e,s),2*t.sub(this.point).dotProduct(s[1])}if(1===t){const t=new n.P;wi(this.controlPoints,this.weights,e,t);const s=(0,n.m)(n.P,4);return Qs(this.controlPoints,this.weights,2,e,s),2*(t.sub(this.point).dotProduct(s[2])+s[1].dotProduct(s[1]))}if(2===t){const t=new n.P;wi(this.controlPoints,this.weights,e,t);const s=(0,n.m)(n.P,4);return Qs(this.controlPoints,this.weights,3,e,s),2*(t.sub(this.point).dotProduct(s[3])+3*s[1].dotProduct(s[2]))}return 0}getError(t){return(0,i.g)(0),0}};function Ls(t,e,s,i){const r=function(t,e,s,i,n){return{tmin:0,tmax:0,t:0,d:0,pt:n.clone()}}(0,0,0,0,n.P.getNAN()),o=new Array(18),a=(0,n.m)(n.P,3);t.queryControlPoints(a),a[2].subThis(e),a[1].subThis(e),a[0].subThis(e);const h=[0,0,0];t.queryWeights(h);const m=[1,Ti(h),1],l=Ai(h,s),u=Ai(h,i),c=He(new Bs(a,m,new n.P(0,0)),n.E.construct(l,u),18,o);wi(a,m,l,r.pt),r.t=l,r.d=n.P.distance(r.pt,new n.P(0,0));const g=new n.P;wi(a,m,u,g);const _=n.P.distance(g,new n.P(0,0));_<r.d&&(r.d=_,r.t=u,r.pt.assign(g));for(let t=0;t<c;t++){wi(a,m,o[t],g);const e=n.P.distance(g,new n.P(0,0));e<r.d&&(r.d=e,r.t=Ni(h,o[t]),r.pt.assign(g))}return r}function zs(t,e,s,i,r){let o=!0;const a=(0,n.m)(n.P,4),h=Vs(5,e,s,i,r,(e=>(Zs(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length())));o=!1;const m=Vs(5,e,s,i,r,(e=>(Zs(t,1,e,a),(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*a[1].length())));return new n.P(h,m)}function Us(t){t.m_cachedValues=null}function Os(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Xs,s=(0,n.m)(n.P,3);t.queryControlPoints(s);const i=[0,0,0];return t.queryWeights(i),Ws(s,i,e.specialPoints),ri(t,e),e}function Ws(t,e,s){if(0===e[1])return s.length=2,s[0]=0,void(s[1]=1);const i=(0,n.m)(n.H,8);i[0].set(0);let r=1;{const s=new n.H(t[1].x).subThis(t[0].x).mulThis(e[1]).mulThis(e[0]),o=new n.H(t[2].x).subThis(t[0].x).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new n.H(t[2].x).subThis(t[1].x).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,n.m)(n.H,2);let m=Ze(a,o,s,new n.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,n.a1)(h[t].value(),0,1)||(i[r]=h[t],r++)}{const s=new n.H(t[1].y).subThis(t[0].y).mulThis(e[1]).mulThis(e[0]),o=new n.H(t[2].y).subThis(t[0].y).mulThis(e[2]).mulThis(e[0]),a=s.subE(o).addThisE(new n.H(t[2].y).subThis(t[1].y).mulThis(e[2]).mulThis(e[1]));o.subThisE(s.mul(2));const h=(0,n.m)(n.H,2);let m=Ze(a,o,s,new n.E(0,1),!1,h);m<0&&(m=0);for(let t=0;t<m;t++)(0,n.a1)(h[t].value(),0,1)||(i[r]=h[t],r++)}if(i[r].set(1),r++,r>2){(0,n.W)(i,0,r,((t,e)=>(0,n.F)(t.value(),e.value())));let t=0,e=i[0].value(),s=1;for(let n=1;n<r;n++)i[n].eq(i[n-1])?(e+=i[n].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[n],e=i[n].value(),s=1);t++,r=t}i[0].set(0),i[r-1].set(1),s.length=r;for(let t=0;t<r;t++)s[t]=i[t].value()}function js(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+js(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=Os(t);if(i&&!Number.isNaN(n.length))return n.length;const r=ii(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=Hs(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function Zs(t,e,s,i){const r=(0,n.m)(n.P,3);t.queryControlPoints(r);const o=[0,0,0];t.queryWeights(o),Qs(r,o,e,s,i)}function Qs(t,e,s,r,o){const a=[t[0],t[1],t[2]],h=[e[0],e[1],e[2]],m=(0,n.m)(n.P,4);!function(t,e,s,n,r){(0,i.g)(s>0);const o=[t[0].clone(),t[1].clone(),t[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=Ks(o,e,0,n),h=$s(e,0,n),m=a.divide(h);if(r[0].assign(m),0===s)return;const l=[e[1]*e[0],e[2]*e[0]*.5,e[1]*e[2]],u=[t[1].sub(t[0]),t[2].sub(t[0]),t[2].sub(t[1])],c=h*h,g=Ks(u,l,0,n).mul(2).divide(c);if(r[1].assign(g),1===s)return;const _=$s(e,1,n),d=2*h*_,p=Ks(u,l,1,n).mul(2).sub(g.mul(d)).divide(c);if(r[2].assign(p),2===s)return;const f=Ks(u,l,2,n).mul(2),x=2*(_*_+h*$s(e,2,n)),y=f.sub(p.mul(d).mul(2)).sub(g.mul(x)).divide(c);r[3].assign(y),3!==s&&(0,i.b)("")}(a,h,s,r,m);for(let t=0;t<=s;t++)o[t].setCoords(m[t].x,m[t].y)}function Ks(t,e,s,r){if(0===s){if(r<=.5){const s=new n.P;(0,n.a2)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,s);const i=new n.P;(0,n.a2)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,i);const o=new n.P;return(0,n.a2)(2,s,i,r,o),o}{const s=new n.P;(0,n.a3)(2,t[0].mul(e[0]),t[1].mul(e[1]),r,s);const i=new n.P;(0,n.a3)(2,t[1].mul(e[1]),t[2].mul(e[2]),r,i);const o=new n.P;return(0,n.a3)(2,s,i,r,o),o}}if(1===s){const s=t[1].mul(e[1]),i=s.sub(t[0].mul(e[0])).mul(1-r).add(t[2].mul(e[2]).sub(s).mul(r));return i.mulThis(2),i}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}(0,i.b)("")}function Js(t,e,s,i){if(i.toDouble()<=.5){const s=new Wt;(0,n.a8)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const r=new Wt;(0,n.a8)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,r);const o=new Wt;return(0,n.a8)(2,s,r,i,o),o}{const s=new Wt;(0,n.a9)(2,t[0].mulE(e[0]),t[1].mulE(e[1]),i,s);const r=new Wt;(0,n.a9)(2,t[1].mulE(e[1]),t[2].mulE(e[2]),i,r);const o=new Wt;return(0,n.a9)(2,s,r,i,o),o}}function $s(t,e,s){if(0===e){const e=(0,n.w)(t[0],t[1],s),i=(0,n.w)(t[1],t[2],s);return(0,n.w)(e,i,s)}return 1===e?2*((1-s)*(t[1]-t[0])+(t[2]-t[1])*s):2===e?2*(t[2]-t[1]-(t[1]-t[0])):void(0,i.b)("")}function ti(t,e,s){const i=(0,n.l)(s,0,1),r=(0,n.m)(n.P,4);if(Qs(t,e,3,i,r),r[1].isZero()){if(r[2].isZero())return r[3];{const t=r[2].clone();return 1===i&&t.negateThis(),t}}return r[1]}let ei=class{constructor(t,e){this.len=0,this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-js(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}};function si(t){const e=(0,n.m)(n.P,3),s=[0,0,0];return t.queryControlPoints(e),t.queryWeights(s),function(t,e){const s=Ti(e);if(1===s)return Zi(t);if(0===s)return 0;const r=[new n.P(0,0),t[1].sub(t[0]),t[2].sub(t[0])],o=r[1].crossProduct(r[2]);if(s<1){(0,i.g)(s>0);const t=1-s;let e;if(t<.01)e=-1/3+t*(2/15+t*(3/35+t*(16/315+t*(20/693+t*(16/1001+t*(56/6435))))));else{const i=t*(1+s),r=Math.atan2(Math.sqrt(t),Math.sqrt(1+s));e=s*(.5*s-(0,n.as)(i)*r)/i}return o*e}{const t=(s-1)*(s+1);return.25*s/Math.pow(t,1.5)*(-2*s*Math.sqrt(t)*o-4*r[1].y*r[2].x*Math.atanh(Math.sqrt((s-1)/(s+1)))-r[1].x*r[2].y*Math.log(2*s*(s-Math.sqrt(t))-1))}}(e,s)}function ii(t){return function(t){return 256*(0,n.aa)()*t}(t.calculateUpperLength2D())}function ni(t){return t.m_cachedValues}function ri(t,e){t.m_cachedValues=e}function oi(t,e,s,i,r){const o=(0,n.m)(n.P,3);t.queryControlPoints(o);const a=[0,0,0];t.queryWeights(a);const h=[0];return 1===ai(o,a,e,n.E.unit(),i,r,1,h)?h[0]:Number.NaN}function ai(t,e,s,r,o,a,h,m){(0,i.A)(n.E.unit().contains(r)&&h>0,""),(a<0||Number.isNaN(a))&&(a=Number.MAX_VALUE);const l=new Array(3);for(let e=0;e<3;++e)l[e]=t[e].sub(s);const u=Ti(e),c=hs.constructPoint2D(l[0]),g=hs.constructPoint2D(l[1]),_=hs.constructPoint2D(l[2]),d=n.M.constructDouble(u),p=d.clone();p.ldexpThis(1);const f=c.dotProduct(g.sub(c)).mul(d),x=d.mul(d.addDouble(2)),y=_.sub(g.mul(x.ldexp(1))),P=g.sqrLength().mul(d.mul(d).ldexp(1)).add(c.sqrLength().mul(d.ldexp(2).subDouble(1))).add(c.dotProduct(y)),E=_.sub(g.mul(p)).add(c.mul(p.subDouble(1))),C=g.mul(d).sub(c).dotProduct(E).mulDouble(3),v=g.dotProduct(_).mul(d.subDouble(3).mul(d)).ldexp(1),b=g.sqrLength().mul(d.mul(d).ldexp(2)),S=c.sqrLength().mul(d.ldexp(2).subDouble(3)),I=c.dotProduct(_.sub(g.mul(d.mulDouble(3).subDouble(1)).mul(d))).ldexp(1),w=_.sqrLength().addThis(v).addThis(b).addThis(S).addThis(I),D=c.add(_).sub(g.mul(p)),T=d.subDouble(1),N=_.sub(c).dotProduct(D).mul(T),A=new n.P(0,0),M=[];let G=new n.P;wi(l,e,r.vmin,G);let q=n.P.distance(G,A);if(q<=a&&M.push(new n.P(r.vmin,q)),r.vmin!==r.vmax&&(wi(l,e,r.vmax,G),q=n.P.distance(G,A),q<=a&&M.push(new n.P(r.vmax,q))),r.width()>0){const t=l[2].isZero(),s=(0,n.m)(n.M,4),i=fs(N,w,C,P,f,58,r,t,s);for(let t=0;t<i;t++){if(!r.containsExclusiveCoordinate(s[t].toDouble()))continue;let i=s[t].toDouble();i=Ni(e,i);const o=new n.P;wi(l,e,i,o),q=n.P.distance(o,A),q<=a&&M.push(new n.P(i,q))}}if(o){(0,i.g)(r.equals(n.E.unit()));{wi(l,e,-1,G,!0);const t=new n.P;wi(l,e,0,t);const s=new na({start:G,end:t}),i=s.getClosestCoordinate(A,!0);i<1&&(G=s.getCoord2D(i),q=n.P.distance(G,A),q<=a&&M.push(new n.P(i-1,q)))}{wi(l,e,2,G,!0);const t=new n.P;wi(l,e,r.vmax,t);const s=new na({start:t,end:G}),i=s.getClosestCoordinate(A,!0);i>0&&(G=s.getCoord2D(i),q=n.P.distance(G,A),q<=a&&M.push(new n.P(1+i,q)))}}if(!M.length)return 0;M.sort(((t,e)=>t.compare(e)));let F=0;const V=M[0].x;if(m[F++]=V,F<h){const t=rt(l,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)=>(0,n.F)(t.x,e.x))),F=0,m[F++]=M[0].x;for(let t=1,e=M.length;t<e;t++)M[t].x!==m[F-1]&&F<h&&(m[F++]=M[t].x)}return F}function hi(t,e,s){const i=(0,n.m)(n.P,3);t.queryControlPoints(i);const r=[0,0,0];t.queryWeights(r),mi(i,r,e,s)}function mi(t,e,s,i){if(s.equalsRange(0,1))return void i.setFromPoints(t,3);const r=(0,n.m)(n.P,3);_i(t,e,s.vmin,s.vmax,r,[0,0,0]),i.setFromPoints(r,3)}function li(t){const e=(0,n.a4)(t[0].y,t[1].y),s=(0,n.a4)(t[1].y,t[2].y);if(e>=0&&s>=0||e<=0&&s<=0){const e=(0,n.a4)(t[0].x,t[1].x),s=(0,n.a4)(t[1].x,t[2].x);if(e>=0&&s>=0||e<=0&&s<=0)return!0}return!1}function ui(t){const e=(0,n.m)(n.P,3);t.queryControlPoints(e);const s=ci(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function ci(t){let e=!1;for(let s=0;s<2;s++){const i=(0,n.a4)(t[0][s],t[2][s]);i>0?((0,n.a4)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,n.a4)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,n.a4)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,n.a4)(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 gi(t,e,s,r,o,a,h){(0,i.g)(s>=0&&s<=1&&r!==a&&o!==h),(0,i.g)(e[0]>0&&e[2]>0&&e[1]>=0);const m=[1,Ti(e),1],l=Ai(e,s),u=(0,n.aq)(t,3),c=(0,n.m)(_,3);bi(u,m,c);const g=(0,n.m)(_,3),d=(0,n.m)(_,3);Mi(c,l,r?g:null,a?d:null),Gi(e,s,o,h);const p=li(u);if(r){for(let t=0;t<3;++t)Ii(g[t],r[t]);Fi(u,r),p&&ci(r)}if(a){for(let t=0;t<3;++t)Ii(d[t],a[t]);Fi(u,a),p&&ci(a)}}function _i(t,e,s,r,o,a){if((0,i.g)(s>=0&&r<=1&&s<=r),s===r){const i=new n.P,r=Si(t,e,s,i);return qi(t,i),o[0].assign(i),o[1].assign(i),o[2].assign(i),a[0]=r,a[1]=r,void(a[2]=r)}if(0===s&&1===r)return o[0].assign(t[0]),o[1].assign(t[1]),o[2].assign(t[2]),a[0]=e[0],a[1]=e[1],void(a[2]=e[2]);const h=(0,n.m)(_,3);{const i=[1,Ti(e),1],n=Ai(e,s),o=Ai(e,r);bi(t,i,h),Mi(h,o,h,null),Mi(h,n>=o?1:n/o,null,h)}const m=[0,0,0];Gi(e,r,m,null),Gi(m,s/r,null,m);const l=li(t),u=(0,n.m)(n.P,3);Ii(h[1],u[1]),wi(t,e,s,u[0]),wi(t,e,r,u[2]),Fi(t,u);for(let t=0;t<3;++t)o[t].assign(u[t]),a[t]=m[t];l&&ci(o)}function di(t,e,s){const i=Ti(e),r=[1,i,1],o=4*i/(3*(1+i));s[0].assign(t[0]),s[3].assign(t[2]),(0,n.B)(t[0],t[1],o,s[1]),(0,n.B)(t[2],t[1],o,s[2]),new pn({cp:s}),new as({points:t,weight:i});let a=0,h=.1,m=0;for(let e=0;e<9;e++,h+=.1){const e=new n.P;wi(t,r,h,e);const i=new n.P;kn(s,h,i);const o=n.P.sqrDistance(e,i);o>a&&(a=o,m=h)}{const e=new n.P;wi(t,r,m,e);const i=[0];er(s,e,n.E.unit(),!1,-1,1,i);const o=new n.P;return kn(s,i[0],o),a=n.P.sqrDistance(e,o),Math.sqrt(a)}}function pi(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==yi(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function fi(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==Pi(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function xi(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==Ci(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function yi(t,e,s,r,o,a,h,m,l,u){if(null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!=a)for(let t=0;t<i;t++)a.push(0);if(null!=r)for(let s=0;s<i;s++){const i=new n.P;e.queryCoord2D(t[s],i),r.push(i)}}return i}const c=ge(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new na({start:e.getStartXY(),end:e.getEndXY()}),i=De(t,s,r,o,a,h,m,u);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(_e(e,s,h))return 0;const g=(0,n.m)(n.P,3);e.queryControlPoints(g);const _=[0,0,0];e.queryWeights(_);const d=[1,Ti(_),1],p=s.getEndXY().sub(s.getStartXY()),f=p.clone();f.leftPerpendicularThis();const x=g[0].clone(),y=g[1].clone(),P=g[2].clone(),E=y.sub(x),C=P.sub(x),v=P.sub(y),b=d[0],S=d[1],I=d[2],w=b*S,D=b*I,T=S*I,N=E.dotProduct(f)*w,A=C.dotProduct(f)*D;let M=N,G=A-2*N,q=v.dotProduct(f)*T+A-A;const F=new Array(13),V=new Array(13);let R=Be(q,G,M,n.E.unit(),!1,F);R<0&&(F[0]=0,F[1]=1,R=2);let Y=0;for(let t=0,e=Y;t<R;++t){const i=new n.P;wi(g,d,F[t+e],i),V[Y]=s.getClosestCoordinate(i,!1),n.P.distance(i,s.getCoord2D(V[Y]))<=h&&(F[Y]=F[t+e],Y++)}const X=(0,n.m)(n.P,3),k=(0,n.m)(n.P,3);if(e.queryControlPoints(k),k[0].subThis(s.getStartXY()),k[1].subThis(s.getStartXY()),k[2].subThis(s.getStartXY()),function(t,e,s,i=!1){const r=(0,n.m)(n.P,3);i?(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[1].subThis(r[0]),r[2].setCoordsPoint2D(t[2]),r[2].subThis(r[0]),r[0].setCoords(0,0)):(r[0].setCoordsPoint2D(t[0]),r[1].setCoordsPoint2D(t[1]),r[2].setCoordsPoint2D(t[2])),r[0].mulThis(e[0]),r[1].mulThis(e[1]),r[2].mulThis(e[2]),s[1].setCoords(r[1].x-r[0].x,r[1].y-r[0].y),s[2].setCoordsPoint2D(r[2].sub(r[1])),s[2].subThis(s[1]),s[1].x*=2,s[1].y*=2,s[0].setCoordsPoint2D(r[0])}(k,d,X,!1),Math.abs(p.x)>=Math.abs(p.y)){const t=p.y/p.x;q=X[2].y-X[2].x*t,G=X[1].y-X[1].x*t,M=X[0].y-X[0].x*t}else{const t=p.x/p.y;q=X[2].x-X[2].y*t,G=X[1].x-X[1].y*t,M=X[0].x-X[0].y*t}const H=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),B=[0,0];R=Be(q,G,M,n.E.unit(),H,B);for(let t=0,e=Y;t<R;++t){F[t+e]=B[t];const i=new n.P;wi(g,d,F[t+e],i),V[Y]=s.getClosestCoordinate(i,!1),n.P.distance(i,s.getCoord2D(V[Y]))<=h&&(F[Y]=F[t+e],Y++)}(0,i.g)(Y<F.length+4);for(let t=0;t<Y;t++)F[t]=Ni(_,F[t]);R=e.intersectPoint(s.getStartXY(),B,h);for(let t=0;t<R;t++)F[Y]=B[t],V[Y++]=0;R=e.intersectPoint(s.getEndXY(),B,h);for(let t=0;t<R;t++)F[Y]=B[t],V[Y++]=1;R=s.intersectPoint(e.getStartXY(),B,h);for(let t=0;t<R;t++)V[Y]=B[t],F[Y++]=0;R=s.intersectPoint(e.getEndXY(),B,h);for(let t=0;t<R;t++)V[Y]=B[t],F[Y++]=1;return 0===Y?0:ta(t,e,s,F,V,Y,r,o,a,h,m,0,u)}function Pi(t,e,s,i,r,o,a,h,m,l){if(to(s))return yi(t,e,new na({start:s.getStartXY(),end:s.getEndXY()}),i,r,o,a,h,0,l);const u=ge(e,s);if(_e(e,s,a=Math.max(a,u)))return 0;const c=[],g=[],_=(0,n.m)(n.P,4);{e.queryControlPoints(_);const t=(0,n.m)(n.P,4),i=new n.T;s.canonicToWorldTransformation(i);const r=new n.T;r.setInvert(i),r.transformPoints2D(_,4,t);const o=(0,n.m)(n.M,3),h=(0,n.m)(n.M,3),m=(0,n.m)(n.M,3),l=[0,0,0];e.queryWeights(l),vi(t,l,o,h,m);const u=(0,n.m)(n.M,3);u[0].setDouble(s.getSemiMinorAxis()),u[0].sqrThis(),u[1].setDouble(s.getSemiMajorAxis()),u[1].sqrThis(),u[2].setThis(u[0]),u[2].mulThis(u[1]),u[2].negateThis();const d=gs(o,2,h,2,m,2,u,0,n.E.unit(),n.E.unit(),c);if(d>0){let t=0;for(let i=0;i<d;i++){const r=new n.P;e.queryCoord2D(c[i],r);const o=s.getClosestCoordinate(r,!1),h=new n.P;s.queryCoord2D(o,h),n.P.distance(r,h)<=a&&(c[t]=c[i],g.push(o),t++)}c.length=t}}const d=[0,1];for(let t=0;t<2;t++){const i=0===t?s.getStartXY():s.getEndXY(),r=oi(e,i,n.E.unit(),!1,-1),o=new n.P;e.queryCoord2D(r,o),n.P.distance(i,o)<=a&&(c.push(r),g.push(d[t]))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(_[e[t]],!1),r=new n.P;s.queryCoord2D(i,r),n.P.distance(_[e[t]],r)<=a&&(c.push(d[t]),g.push(i))}}return ta(t,e,s,c,g,c.length,i,r,o,a,h,0,l)}function Ei(t,e,s,r,o,a,h,m,l,u){const c=(0,n.m)(n.P,3);e.queryControlPoints(c);const g=(0,n.m)(n.P,3);if(s.queryControlPoints(g),de(c,g,3)<0)return Ei(t,s,e,r,a,o,h,m,l,!u);const _=ge(e,s);if(e.isDegenerateToLineHelper(_)){const i=new na({start:e.getStartXY(),end:e.getEndXY()}),n=yi(t,s,i,r,a,o,h,m,0,!u);if(o)for(let t=0;t<n;++t){const s=i.getCoord2D(o[t]);o[t]=e.getClosestCoordinate(s,!1)}return n}if(s.isDegenerateToLineHelper(_)){const i=new na({start:s.getStartXY(),end:s.getEndXY()}),n=yi(t,e,i,r,o,a,h,m,0,u);if(a)for(let t=0;t<n;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return n}if(_e(e,s,h=Math.max(h,_)))return 0;const d=new Array(3);e.queryWeights(d);const p=new Array(3);s.queryWeights(p);const f=[1,Ti(d),1],x=[1,Ti(p),1],y=new n.E(0,1),P=new n.E(0,1);{const t=Ht.constructEmpty();mi(c,f,new n.E(0,1),t);const e=Ht.constructEmpty();mi(g,x,new n.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(Di(c,f,t,y),Di(g,x,t,P),y.isEmpty()||P.isEmpty())return 0;_i(c,f,y.vmin,y.vmax,c,f),_i(g,x,P.vmin,P.vmax,g,x)}}const E=sa(c,2,g,2,h);if(0===E)return 0;const C=[],v=[];if(-1===E){const t=(0,n.m)(n.M,3),e=(0,n.m)(n.M,3),s=(0,n.m)(n.M,3);vi(c,f,t,e,s);const i=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=(0,n.m)(n.M,3);vi(g,x,i,r,o);const a=[],m=[],l=cs(t,2,e,2,s,2,i,2,r,2,o,2,0,n.E.unit(),n.E.unit(),a,m);if(l>0)for(let t=0;t<l;t++){const e=new n.P;wi(g,x,m[t],e);const s=new n.P;wi(c,f,a[t],s),n.P.distance(s,e)<=h&&(C.push(a[t]),v.push(m[t]))}}for(let t=0;t<2;t++){let e,s,r;0===t?(e=c,s=g,r=x):(e=g,s=c,r=f);for(let o=0;o<2;o++){const a=0===o?0:e.length-1,m=new n.P,l=[0],u=ai(s,r,e[a],n.E.unit(),!1,-1,1,l);(0,i.g)(1===u),wi(s,r,l[0],m),n.P.distance(e[a],m)<=h&&(0===t?(C.push(0===a?0:1),v.push(l[0])):(v.push(0===a?0:1),C.push(l[0])))}}if(0===C.length)return 0;if(!y.equalsRange(0,1))for(let t=0;t<C.length;++t)C[t]=as.recalculateParentT(y.vmin,y.vmax,C[t]);if(!P.equalsRange(0,1))for(let t=0;t<v.length;++t)v[t]=as.recalculateParentT(P.vmin,P.vmax,v[t]);for(let t=0;t<C.length;++t)C[t]=Ni(d,C[t]);for(let t=0;t<v.length;++t)v[t]=Ni(p,v[t]);return ta(t,e,s,C,v,C.length,r,o,a,h,m,0,u)}function Ci(t,e,s,i,r,o,a,h,m,l){if(e.isLine())return mn(t,s,new na({start:e.getStartXY(),end:e.getEndXY()}),i,o,r,a,h,m,!l);if(s.isLine())return yi(t,e,new na({start:s.getStartXY(),end:s.getEndXY()}),i,r,o,a,h,0,l);const u=ge(e,s);if(_e(e,s,a=Math.max(a,u)))return 0;const c=(0,n.m)(n.P,3);e.queryControlPoints(c);const g=(0,n.m)(n.P,3);s.queryControlPoints(g);const _=sa(c,2,g,2,a);if(0===_)return 0;const d=[],p=[];if(-1===_){const t=(0,n.m)(n.M,3),i=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=[0,0,0];e.queryWeights(o),vi(c,o,t,i,r);const h=(0,n.m)(hs,3);gn(g,h);const m=cs(t,2,i,2,r,2,[h[0].x,h[1].x,h[2].x],2,[h[0].y,h[1].y,h[2].y],2,null,0,0,n.E.unit(),n.E.unit(),d,p);if(m>0){let t=0;for(let i=0;i<m;i++){const r=new n.P;s.queryCoord2D(p[i],r);const o=new n.P;e.queryCoord2D(d[i],o),n.P.distance(o,r)<=a&&(d[t]=d[i],p[t]=p[i],t++)}d.length=t,p.length=t}}for(let t=0;t<2;t++){let i;i=0===t?c:g;for(let r=0;r<2;r++){const o=0===r?0:i.length-1;let h;const m=new n.P;0===t?(h=Ji(s,i[o],n.E.unit(),!1),s.queryCoord2D(h,m)):(h=oi(e,i[o],n.E.unit(),!1,-1),e.queryCoord2D(h,m)),n.P.distance(i[o],m)<=a&&(0===t?(d.push(0===o?0:1),p.push(h)):(p.push(0===o?0:1),d.push(h)))}}return ta(t,e,s,d,p,d.length,i,r,o,a,h,0,l)}function vi(t,e,s,i,r){const o=n.M.constructDouble(e[0]),a=n.M.constructDouble(e[1]),h=n.M.constructDouble(e[2]);s[0].setDouble(t[0].x),s[0].mulThis(o),s[1].setDouble(t[1].x),s[1].mulThis(a),s[2].setDouble(t[2].x),s[2].mulThis(h),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(o),i[1].setDouble(t[1].y),i[1].mulThis(a),i[2].setDouble(t[2].y),i[2].mulThis(h),i[2].subThis(i[1]),i[1].subThis(i[0]),i[2].subThis(i[1]),i[1].ldexpThis(1),r[0].setDouble(e[0]),r[1].setDouble(e[1]),r[2].setThis(r[1]),r[2].ldexpThis(1),r[2].negateThis(),r[2].addThis(r[0]),r[2].addDoubleThis(e[2]),r[1].subThis(r[0]),r[1].ldexpThis(1)}function bi(t,e,s){for(let i=0;i<3;++i)s[i].setCoordsPoint2DZ(t[i].mul(e[i]),e[i])}function Si(t,e,s,i){if(0===s)return i.assign(t[0]),e[0];if(1===s)return i.assign(t[2]),e[2];const r=[t[0].x*e[0],t[1].x*e[1],t[2].x*e[2]],o=[t[0].y*e[0],t[1].y*e[1],t[2].y*e[2]],a=[e[0],e[1],e[2]],h=s;let m,l,u;if(s<=.5){const t=(0,n.Z)(r[0],r[1],h),e=(0,n.Z)(r[1],r[2],h);m=(0,n.w)(t,e,h);const s=(0,n.Z)(o[0],o[1],h),i=(0,n.Z)(o[1],o[2],h);l=(0,n.w)(s,i,h);const c=(0,n.Z)(a[0],a[1],h),g=(0,n.Z)(a[1],a[2],h);u=(0,n.Z)(c,g,h)}else{const t=(0,n._)(r[0],r[1],h),e=(0,n._)(r[1],r[2],h);m=(0,n._)(t,e,h);const s=(0,n._)(o[0],o[1],h),i=(0,n._)(o[1],o[2],h);l=(0,n._)(s,i,h);const c=(0,n._)(a[0],a[1],h),g=(0,n._)(a[1],a[2],h);u=(0,n._)(c,g,h)}return m/=u,l/=u,i.setCoords(m,l),qi(t,i),u}function Ii(t,e){return e.setCoords(t.x/t.z,t.y/t.z),t.z}function wi(t,e,s,i,n){if(n){if(s<0)return void Pe(new na({start:t[0],end:t[0].add(ti(t,e,0).getUnitVector())}),s,i);if(s>1)return void Pe(new na({start:t[2],end:t[2].add(ti(t,e,1).getUnitVector())}),s-1,i)}Si(t,e,s,i)}function Di(t,e,s,i){i.setEmpty();const r=[];r.push(new n.E(0,1));const o=.5*Math.max(s.width(),s.height());for(;r.length;){const a=r.at(-1);r.pop();const h=new Ht;if(mi(t,e,a,h),h.isIntersectingW(s)){const t=Math.max(h.width(),h.height());if(s.containsW(h)||t<=o||a.width()<1e-12)i.merge(a);else{const t=a.getCenter();r.push(n.E.construct(a.vmin,t)),r.push(n.E.construct(t,a.vmax))}}}}function Ti(t){return t[1]/Math.sqrt(t[0]*t[2])}function Ni(t,e){const s=Math.sqrt(t[2]/t[0]);return e/(0,n.w)(s,1,e)}function Ai(t,e){const s=Math.sqrt(t[0]/t[2]);return e/(0,n.w)(s,1,e)}function Mi(t,e,s,r){(0,i.g)(e>=0&&e<=1),(new _).setCoordsPoint3D(t[0]),(new _).setCoordsPoint3D(t[1]),(new _).setCoordsPoint3D(t[2]);const o=new _,a=new _,h=new _;(0,n.a7)(3,t[0],t[1],e,o),(0,n.a7)(3,t[1],t[2],e,a),(0,n.a7)(3,o,a,e,h);const m=t[2].clone();s&&(s[0].assign(t[0]),s[1].assign(o),s[2].assign(h)),r&&(r[0].assign(h),r[1].assign(a),r[2].assign(m))}function Gi(t,e,s,r){const o=[t[0],t[1],t[2]];(0,i.g)(e>=0&&e<=1&&s!==r);const a=(0,n.w)(o[0],o[1],e),h=(0,n.w)(o[1],o[2],e),m=(0,n.w)(a,h,e);s&&(s[0]=o[0],s[1]=a,s[2]=m),r&&(r[0]=m,r[1]=h,r[2]=o[2])}function qi(t,e){const s=n.E.constructEmpty();s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e.x=(0,n.l)(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=(0,n.l)(e.y,s.vmin,s.vmax)}function Fi(t,e){const s=new n.E;s.vmin=s.vmax=t[0].x,s.mergeNeCoordinate(t[1].x),s.mergeNeCoordinate(t[2].x),e[0].x=(0,n.l)(e[0].x,s.vmin,s.vmax),e[1].x=(0,n.l)(e[1].x,s.vmin,s.vmax),e[2].x=(0,n.l)(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=(0,n.l)(e[0].y,s.vmin,s.vmax),e[1].y=(0,n.l)(e[1].y,s.vmin,s.vmax),e[2].y=(0,n.l)(e[2].y,s.vmin,s.vmax)}class Vi{constructor(){this.area=Number.NaN,this.centroid_x=Number.NaN,this.centroid_y=0,this.specialPoints=[],this.specialPointsLength=[]}specialPointsCount(){return this.specialPoints.length}}class Ri{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Bi(this.b,e,!1):0}getError(t){return(0,i.g)(0),0}}function Yi(t,e,s,i,r){let o=!0;const a=(0,n.m)(n.P,3);t.queryControlPoints(a);let h=o?0:1,m=a[1][h]-a[0][h],l=a[2][h]-a[0][h];const u=Vs(5,e,s,i,r,(t=>{let e;if(t<=.5){const s=(0,n.Z)(0,m,t),i=(0,n.Z)(m,l,t);e=(0,n.Z)(s,i,t)}else{const s=(0,n._)(0,m,t),i=(0,n._)(m,l,t);e=(0,n._)(s,i,t)}return e*Wi(a,1,t).length()}));o=!1,h=o?0:1,m=a[1][h]-a[0][h],l=a[2][h]-a[0][h];const c=Vs(5,e,s,i,r,(t=>{let e;if(t<=.5){const s=(0,n.Z)(0,m,t),i=(0,n.Z)(m,l,t);e=(0,n.Z)(s,i,t)}else{const s=(0,n._)(0,m,t),i=(0,n._)(m,l,t);e=(0,n._)(s,i,t)}return e*Wi(a,1,t).length()}));return new n.P(u,c)}function Xi(t){t.m_cachedValues=null}function ki(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new Vi;return Hi(t,e.specialPoints),Ki(t,e),e}function Hi(t,e){const s=(0,n.m)(n.P,3);t.queryControlPoints(s);const i=(0,n.m)(n.H,8);i[0].set(0);let r=1;{const t=(0,n.m)(n.H,3);!function(t,e,s=!1){const i=new n.H(t[1][0]).subE(new n.H(t[0][0]));e[1]=i.mul(2),e[2]=new n.H(t[2][0]).subE(new n.H(t[1][0])).subE(i),s?e[0].set(0):e[0].set(t[0][0])}(s,t,!1);const e=(0,n.m)(n.H,2),o=new n.E(0,1);let a=je(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.a1)(e[t].value(),0,1)||(i[r]=e[t],r++)}{const t=(0,n.m)(n.H,3);!function(t,e,s=!1){const i=new n.H(t[1][1]).subE(new n.H(t[0][1]));e[1]=i.mul(2),e[2]=new n.H(t[2][1]).subE(new n.H(t[1][1])).subE(i),s?e[0].set(0):e[0].set(t[0][1])}(s,t,!1);const e=(0,n.m)(n.H,2),o=new n.E(0,1);let a=je(t[2].mul(2),t[1],o,e[0]);a<0&&(a=0);for(let t=0;t<a;t++)(0,n.a1)(e[t].value(),0,1)||(i[r]=e[t],r++)}if(i[r].set(1),r++,r>2){(0,n.W)(i,0,r,((t,e)=>t.value()-e.value()));let t=0,e=i[0].value(),s=1;for(let n=1;n<r;n++)i[n].eq(i[n-1])?(e+=i[n].value(),s++):(s>1&&(e/=s,i[t].set(e)),t++,i[t]=i[n],e=i[n].value(),s=1);t++,r=t}i[0].set(0),i[r-1].set(1),e.length=r;for(let t=0;t<r;t++)e[t]=i[t].value()}function Bi(t,e,s){const i=(0,n.m)(n.P,3);return t.queryControlPoints(i),Li(i,e,s)}function Li(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Li(t,1,!1)}if(1===e)return zi(t);const i=(0,n.m)(n.P,3);return rn(t,e,i,null),zi(i)}function zi(t){if(t[0].equals(t[1]))return n.P.distance(t[2],t[0]);if(t[1].equals(t[2]))return n.P.distance(t[0],t[2]);const e=n.P.distance(t[0],t[1])+n.P.distance(t[2],t[1]),s=n.P.distance(t[0],t[2]);if(e-s<=e*Number.EPSILON)return s;const i=(0,n.m)(n.P,3);cn(t,i,!0);const r=4*((0,n.e)(i[2].x)+(0,n.e)(i[2].y)),o=2*(i[2].x*i[1].x+i[2].y*i[1].y),a=(0,n.e)(i[1].x)+(0,n.e)(i[1].y);if(1e-14*(Math.abs(o)+Math.abs(a))>=Math.abs(r))return 1e-14*Math.abs(a)>=Math.abs(o)?1*Math.sqrt(a):2/(3*o)*(Math.pow(1*o+a,1.5)-Math.pow(a,1.5));const h=o/r,m=a/r,l=m-h*h,u=1+h;if(0===l)return h>=0&&u>=0||h<=0&&u<=0?Math.abs(.5*Math.sqrt(r)*(u*u-h*h)):.5*Math.sqrt(r)*(u*u+h*h);const c=Math.sqrt(l+u*u),g=Math.sqrt(m);return.5*Math.sqrt(r)*(u*c-h*g+l*Math.log(Math.abs((u+c)/(h+g))))}function Ui(t,e){const s=(0,n.l)(e,0,1);let i=Wi(t,1,s);return i.isZero()&&(i=Wi(t,2,s)),i}function Oi(t,e,s){const i=(0,n.m)(n.P,3);return t.queryControlPoints(i),Wi(i,e,s)}function Wi(t,e,s){if(1===e){const e=t[1].sub(t[0]).mul(1-s).add(t[2].sub(t[1]).mul(s));return e.mulThis(2),e}return 2===e?t[2].sub(t[1]).sub(t[1].sub(t[0]).mul(2)):n.P.construct(0,0)}function ji(t){const e=(0,n.m)(n.P,3);return t.queryControlPoints(e),Zi(e)}function Zi(t){return-t[1].sub(t[0]).crossProduct(t[2].sub(t[0]))/3}function Qi(t){return t.m_cachedValues}function Ki(t,e){t.m_cachedValues=e}function Ji(t,e,s,r,o){(0,i.A)(n.E.unit().contains(s),"QuadraticBezierHelper::getClosestCoordinateSegment");const a=(0,n.m)(n.P,3);t.queryControlPoints(a);let h=Number.MAX_VALUE;const m=[0],l=$i(a,e,m);if(s.containsCoordinate(m[0]))h=n.P.distance(e,l);else{m[0]=s.vmin,_n(a,m[0],l),h=n.P.distance(l,e);const t=new n.P;_n(a,s.vmax,t);const i=n.P.distance(t,e);h>i&&(l.setCoordsPoint2D(t),m[0]=s.vmax,h=i)}if(!r)return m[0];if(s.vmin<=0){const i=new n.P;t.queryCoord2DExtended(-1,i,!0);const r=new n.P;t.queryCoord2D(s.vmin,r);const o=new na({start:i,end:r}),a=o.getClosestCoordinate(e,!0);if(a<1){const t=o.getCoord2D(a),s=n.P.distance(t,e);s<h&&(h=s,m[0]=a-1,l.assign(t))}}if(s.vmin>=1){const i=new n.P;t.queryCoord2DExtended(2,i,!0);const r=new n.P;t.queryCoord2D(s.vmax,r);const o=new na({start:r,end:i}),a=o.getClosestCoordinate(e,!0);if(a>0){const t=o.getCoord2D(a),s=n.P.distance(t,e);s<h&&(h=s,m[0]=1+a,l.assign(t))}}return m[0]}function $i(t,e,s){const i=t[2].sub(t[1]).sub(t[1].sub(t[0])),r=t[1].sub(t[0]),o=t[0].sub(e),a=o.dotProduct(r),h=o.dotProduct(i)+2*r.dotProduct(r),m=3*r.dotProduct(i),l=i.dotProduct(i),u=new Array(3),c=Le(l,m,h,a,n.E.unit(),!1,u),g=t[0].clone();let _=0,d=n.P.sqrDistance(t[0],e),p=n.P.sqrDistance(t[2],e);p<d&&(_=1,g.assign(t[2]),d=p);for(let s=0;s<c;s++){const i=new n.P;_n(t,u[s],i),p=n.P.sqrDistance(i,e),p<d&&(d=p,g.assign(i),_=u[s])}return s&&(s[0]=_),g}function tn(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,3);const i=(0,n.m)(n.P,3);on(t,e.vmin,e.vmax,i),s.setFromPoints(i,3)}function en(t,e,s){s.setEmpty();const i=[];i.push(new n.E(0,1));const r=.5*Math.max(e.width(),e.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new Ht;if(tn(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=r||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();i.push(n.E.construct(o.vmin,t)),i.push(n.E.construct(t,o.vmax))}}}}function sn(t){const e=(0,n.m)(n.P,3);t.queryControlPoints(e);const s=nn(e);return s&&(t.m_cp.setCoordsPoint2D(e[1]),t.afterCompletedModification()),s}function nn(t){let e=!1;for(let s=0;s<2;s++){const i=(0,n.a4)(t[0][s],t[2][s]);i>0?((0,n.a4)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,n.a4)(t[1][s],t[2][s])<0&&(t[1][s]=t[2][s],e=!0)):i<0?((0,n.a4)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,n.a4)(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 rn(t,e,s,i){(new n.P).setCoordsPoint2D(t[0]),(new n.P).setCoordsPoint2D(t[1]),(new n.P).setCoordsPoint2D(t[2]);const r=new n.P,o=new n.P,a=new n.P;if((0,n.B)(t[0],t[1],e,r),(0,n.B)(t[1],t[2],e,o),(0,n.B)(r,o,e,a),s&&(s[0].assign(t[0]),s[1].assign(r),s[2].assign(a)),i){const e=t[2];i[0].assign(a),i[1].assign(o),i[2].assign(e)}}function on(t,e,s,i){if(e===s){const s=new n.P;return _n(t,e,s),i[0]=s,i[1]=s,void(i[2]=s)}const r=(0,n.m)(n.P,3);rn(t,s,r,null),rn(r,e/s,null,r),_n(t,e,r[0]),_n(t,s,r[2]),i[0].setCoordsPoint2D(r[0]),i[1].setCoordsPoint2D(r[1]),i[2].setCoordsPoint2D(r[2])}function an(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==mn(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function hn(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==ln(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function mn(t,e,s,r,o,a,h,m,l,u){if(null!=o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0),s.isDegenerate(0)){const t=[0,0],i=e.intersectPoint(s.getStartXY(),t,h);if(i>0){if(null!==o)for(let e=0;e<i;e++)o.push(t[e]);if(null!==a)for(let t=0;t<i;t++)a.push(0);if(null!==r)for(let s=0;s<i;s++){const i=new n.P;e.queryCoord2D(t[s],i),r.push(i)}}return i}const c=ge(e,s);if(h=Math.max(h,c),e.isDegenerateToLineHelper(c)){const t=new na({start:e.getStartXY(),end:e.getEndXY()}),i=De(t,s,r,o,a,h,m,u);if(o)for(let s=0;s<i;++s){const i=t.getCoord2D(o[s]);o[s]=e.getClosestCoordinate(i,!1)}return i}if(_e(e,s,h))return 0;const g=hs.constructPoint2D(s.getStartXY()),_=hs.constructPoint2D(s.getEndXY()).sub(g),d=_.clone();d.leftPerpendicularThis();const p=hs.constructPoint2D(e.m_cp).sub(hs.constructPoint2D(e.getStartXY())),f=hs.constructPoint2D(e.getEndXY()).sub(hs.constructPoint2D(e.m_cp));let x=p.dotProduct(d).toDouble(),y=f.sub(p).dotProduct(d).toDouble();const P=(0,n.a)(12,Number.NaN),E=(0,n.a)(12,Number.NaN);let C=function(t,e,s,i){const r=new n.H,o=je(new n.H(t),new n.H(e),s,r);return i[0]=r.value(),o}(y,x,n.E.unit(),P);C<0&&(P[0]=0,P[1]=1,C=2);let v,b=0;for(let t=0,i=b;t<C;++t){const r=e.getCoord2D(P[t+i]);E[b]=s.getClosestCoordinate(r,!1),n.P.distance(r,s.getCoord2D(E[b]))<=h&&(P[b]=P[t+i],b++)}const S=(0,n.m)(n.P,3);e.queryControlPoints(S);{const t=(0,n.m)(hs,3);if(gn(S,t,!1),t[0]=t[0].sub(g),_.x.abs().gte(_.y.abs())){const e=_.y.div(_.x);y=t[2].y.sub(t[2].x.mul(e)).toDouble(),x=t[1].y.sub(t[1].x.mul(e)).toDouble(),v=t[0].y.sub(t[0].x.mul(e)).toDouble()}else{const e=_.x.div(_.y);y=t[2].x.sub(t[2].y.mul(e)).toDouble(),x=t[1].x.sub(t[1].y.mul(e)).toDouble(),v=t[0].x.sub(t[0].y.mul(e)).toDouble()}}const I=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),w=[0,0];C=Be(y,x,v,n.E.unit(),I,w);for(let t=0,i=b;t<C;++t){P[t+i]=w[t];const r=e.getCoord2D(P[t+i]);E[b]=s.getClosestCoordinate(r,!1),n.P.distance(r,s.getCoord2D(E[b]))<=h&&(P[b]=P[t+i],b++)}(0,i.g)(b<P.length+4),C=e.intersectPoint(s.getStartXY(),w,h);for(let t=0;t<C;t++)P[b]=w[t],E[b++]=0;C=e.intersectPoint(s.getEndXY(),w,h);for(let t=0;t<C;t++)P[b]=w[t],E[b++]=1;C=s.intersectPoint(e.getStartXY(),w,h);for(let t=0;t<C;t++)E[b]=w[t],P[b++]=0;C=s.intersectPoint(e.getEndXY(),w,h);for(let t=0;t<C;t++)E[b]=w[t],P[b++]=0;return 0===b?0:ta(t,e,s,P,E,b,r,o,a,h,m,0,u)}function ln(t,e,s,i,r,o,a,h,m,l){if(to(s))return mn(t,e,new na({start:s.getStartXY(),end:s.getEndXY()}),i,r,o,a,h,0,l);const u=ge(e,s);if(_e(e,s,a=Math.max(a,u)))return 0;const c=[],g=[],_=(0,n.m)(n.P,3);{e.queryControlPoints(_);const t=(0,n.m)(n.P,3),i=new n.T;s.canonicToWorldTransformation(i);const r=new n.T;r.setInvert(i),r.transformPoints2D(_,3,t);const o=(0,n.m)(hs,3);gn(t,o);const h=[o[0].x,o[1].x,o[2].x],m=[o[0].y,o[1].y,o[2].y],l=(0,n.m)(n.M,3);l[0].setDouble(s.getSemiMinorAxis()),l[0].sqrThis(),l[1].setDouble(s.getSemiMajorAxis()),l[1].sqrThis(),l[2]=l[0],l[2].mul(l[1]),l[2].negate();const u=gs(h,2,m,2,null,0,l,0,n.E.unit(),n.E.unit(),c);if(u>0){let t=0;for(let i=0;i<u;i++){const r=new n.P;e.queryCoord2D(c[i],r);const o=s.getClosestCoordinate(r,!1),h=new n.P;s.queryCoord2D(o,h),n.P.distance(r,h)<=a&&(c[t]=c[i],g.push(o),t++)}c.length=t}}const d=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];$i(_,e,i);const r=new n.P;_n(_,i[0],r),n.P.distance(e,r)<=a&&(c.push(i[0]),g.push(d[t]))}for(let t=0;t<2;t++){const e=[0,2];{const i=s.getClosestCoordinate(_[e[t]],!1),r=new n.P;s.queryCoord2D(i,r),n.P.distance(_[e[t]],r)<=a&&(c.push(d[t]),g.push(i))}}return ta(t,e,s,c,g,c.length,i,r,o,a,h,0,l)}function un(t,e,s,i,r,o,a,h,m,l){const u=(0,n.m)(n.P,3);e.queryControlPoints(u);const c=(0,n.m)(n.P,3);if(s.queryControlPoints(c),de(u,c,3)<0)return un(t,s,e,i,o,r,a,h,m,!l);const g=ge(e,s);if(_e(e,s,a=Math.max(a,g)))return 0;if(function(t,e,s,i,r,o,a,h,m){const l=(0,n.m)(n.P,3);t.queryControlPoints(l);const u=(0,n.m)(n.P,3);if(e.queryControlPoints(u),l[0].equals(u[0])){if(l[1].equals(u[1])&&l[2].equals(u[2]))return s&&(s.length=0,s.push(l[0]),s.push(l[2])),i&&(i.length=0,i.push(0),i.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!l[0].equals(u[2]))return!1}return!!(l[0].equals(u[2])&&l[1].equals(u[1])&&l[2].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,n.b)(i[0],i[0]=i[1]))),r&&(r.length=0,r.push(1),r.push(0),m&&(r[1]=(0,n.b)(r[0],r[0]=r[1]))),s&&(s.length=0,s.push(l[0]),s.push(l[2]),m&&(s[1]=(0,n.b)(s[0],s[0]=s[1]))),!0)}(e,s,i,r,o,0,0,0,l))return 2;const _=new n.E(0,1),d=new n.E(0,1);{const t=new Ht;tn(u,n.E.unit(),t);const e=new Ht;tn(c,n.E.unit(),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(en(u,t,_),en(c,t,d),_.isEmpty()||d.isEmpty())return 0;on(u,_.vmin,_.vmax,u),on(c,d.vmin,d.vmax,c)}}const p=sa(u,2,c,2,a);if(0===p)return 0;const f=[],x=[];if(-1===p){const t=(0,n.m)(hs,3);gn(u,t);const e=[t[0].x,t[1].x,t[2].x],s=[t[0].y,t[1].y,t[2].y],i=(0,n.m)(hs,3);gn(c,i);const r=cs(e,2,s,2,null,0,[i[0].x,i[1].x,i[2].x],2,[i[0].y,i[1].y,i[2].y],2,null,0,0,n.E.unit(),n.E.unit(),f,x,l);if(r>0){let t=0;for(let e=0;e<r;e++){const s=new n.P,i=new n.P;_n(c,x[e],i),_n(u,f[e],s),n.P.distance(s,i)<=a&&(f[t]=f[e],x[t]=x[e],t++)}f.length=t,x.length=t}}for(let t=0;t<2;t++){const e=0===t?u:c,s=0===t?c:u;for(let i=0;i<2;i++){const r=0===i?0:2,o=[0];$i(s,e[r],o);const h=new n.P;_n(s,o[0],h),n.P.distance(e[r],h)<=a&&(0===t?(f.push(0===r?0:1),x.push(o[0])):(x.push(0===r?0:1),f.push(o[0])))}}if(0===f.length)return 0;if(!_.equalsRange(0,1))for(let t=0;t<f.length;++t)f[t]=rs.recalculateParentT(_.vmin,_.vmax,f[t]);if(!d.equalsRange(0,1))for(let t=0;t<x.length;++t)x[t]=rs.recalculateParentT(d.vmin,d.vmax,x[t]);return ta(t,e,s,f,x,f.length,i,r,o,a,h,0,l)}function cn(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 gn(t,e,s=!1){const i=hs.constructPoint2D(t[1]),r=i.sub(hs.constructPoint2D(t[0]));e[1]=r.mul(n.M.constructInt32(2)),e[2]=hs.constructPoint2D(t[2]).sub(i).sub(r),e[0]=s?new hs(n.ak,n.ak):hs.constructPoint2D(t[0])}function _n(t,e,s,i){if(i){if(e<0)return void Pe(new na({start:t[0],end:t[0].add(Ui(t,0).getUnitVector())}),e,s);if(e>1)return void Pe(new na({start:t[2],end:t[2].add(Ui(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=t[1].clone(),r=new n.P;(0,n.a2)(2,t[0],i,e,r);const o=new n.P;(0,n.a2)(2,i,t[2],e,o);const a=new n.P;(0,n.a2)(2,r,o,e,a),s.assign(a)}else{const i=t[1].clone(),r=new n.P;(0,n.a3)(2,t[0],i,e,r);const o=new n.P;(0,n.a3)(2,i,t[2],e,o);const a=new n.P;(0,n.a3)(2,r,o,e,a),s.assign(a)}}var dn=g;class pn extends xe{constructor(t){t&&t.cp?(super({start:t.cp[0],end:t.cp[3],vd:t.vd}),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].assign(t.cp[1]),this.m_cp[1].assign(t.cp[2])):void 0===t||(0,n.Y)(t,"vd")?(super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_cp=(0,n.m)(n.P,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=(0,n.m)(n.P,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}),(0,i.b)("unrecognized constructor params"),this.m_cp=(0,n.m)(n.P,2),this.m_cp[0].setCoords(0,0),this.m_cp[1].setCoords(0,0)),this.m_cachedValues=0}getBoundary(){return yr(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=(0,n.m)(n.P,4);(function(t,e){e[0].assign(t[0]),e[3].assign(t[2]),(0,n.B)(t[0],t[1],2/3,e[1]),(0,n.B)(t[1],t[2],1/3,e[2])})(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(),(0,n.a7)(2,t.getStartXY(),t.getControlPoint1(),2/3,this.m_cp[0]),(0,n.a7)(2,t.getControlPoint1(),t.getEndXY(),1/3,this.m_cp[1]),this.afterCompletedModification(),ue(this,t)}getGeometryType(){return i.G.enumBezier}queryEnvelope(t){if(2!==t.m_EnvelopeType)return void(0,i.g)(0);if(t.setCoords(this.getStartXY()),t.mergeNe(this.getEndXY()),t.contains(this.m_cp[0])&&t.contains(this.m_cp[1]))return;const e=wn(this);if(null!==e){const s=new n.P;for(const i of e.specialPoints)this.queryCoord2D(i,s),t.mergeNe(s);return}const s=(0,n.m)(n.H,8),r=(0,n.m)(n.P,4);this.queryControlPoints(r);const o=ir(r,s),a=new n.P;for(let e=1;e<o-1;e++)this.queryCoord2D(s[e].value(),a),t.mergeNe(a)}applyTransformation(t){if(1===t.m_TransformationType){const e=(0,n.m)(n.P,4);return this.queryControlPoints(e),t.transformPoints2D(e,4,e),this.setStartXY(e[0]),this.m_cp[0].assign(e[1]),this.m_cp[1].assign(e[2]),this.setEndXY(e[3]),void Tn(this)}(0,i.g)(0)}createInstance(){return new pn({vd:this.m_description})}calculateLength2D(){return Sn(this,1,!1)}calculateLowerLength2D(){return n.P.distance(this.getStartXY(),this.getEndXY())}calculateUpperLength2D(){return n.P.distance(this.getStartXY(),this.m_cp[0])+n.P.distance(this.m_cp[0],this.m_cp[1])+n.P.distance(this.getEndXY(),this.m_cp[1])}queryCoord2D(t,e){return this.queryCoord2DExtends(t,e,!0)}queryCoord2DExtends(t,e,s){const i=(0,n.m)(n.P,4);this.queryControlPoints(i),kn(i,t,e,s)}queryCoord2DE(t,e){!function(t,e,s){const i=(0,n.m)(n.P,4);t.queryControlPoints(i),function(t,e,s){if(e.value()<=.5){const i=new Wt;(0,n.a8)(2,Wt.constructPoint2D(t[0]),Wt.constructPoint2D(t[1]),e,i);const r=new Wt;(0,n.a8)(2,Wt.constructPoint2D(t[1]),Wt.constructPoint2D(t[2]),e,r);const o=new Wt;(0,n.a8)(2,Wt.constructPoint2D(t[2]),Wt.constructPoint2D(t[3]),e,o);const a=new Wt;(0,n.a8)(2,i,r,e,a);const h=new Wt;(0,n.a8)(2,r,o,e,h),(0,n.a8)(2,a,h,e,s)}else{const i=new Wt;(0,n.a9)(2,Wt.constructPoint2D(t[0]),Wt.constructPoint2D(t[1]),e,i);const r=new Wt;(0,n.a9)(2,Wt.constructPoint2D(t[1]),Wt.constructPoint2D(t[2]),e,r);const o=new Wt;(0,n.a9)(2,Wt.constructPoint2D(t[2]),Wt.constructPoint2D(t[3]),e,o);const a=new Wt;(0,n.a9)(2,i,r,e,a);const h=new Wt;(0,n.a9)(2,r,o,e,h),(0,n.a9)(2,a,h,e,s)}}(i,e,s)}(this,t,e)}getCoordX(t){if(t<0||t>1){const e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.x}const e=(0,n.w)(this.getStartX(),this.m_cp[0].x,t),s=(0,n.w)(this.m_cp[0].x,this.m_cp[1].x,t),i=(0,n.w)(this.m_cp[1].x,this.getEndX(),t),r=(0,n.w)(e,s,t),o=(0,n.w)(s,i,t);return(0,n.w)(r,o,t)}getCoordY(t){if(t<0||t>1){const e=new n.P;return this.queryCoord2DExtends(t,e,!0),e.y}const e=(0,n.w)(this.getStartY(),this.m_cp[0].y,t),s=(0,n.w)(this.m_cp[0].y,this.m_cp[1].y,t),i=(0,n.w)(this.m_cp[1].y,this.getEndY(),t),r=(0,n.w)(e,s,t),o=(0,n.w)(s,i,t);return(0,n.w)(r,o,t)}cut(t,e,s){const i=new ra;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=dn.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=dn.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);n.setEndAttribute(s,t,i)}}}}queryDerivative(t,e){Bn(this,t,e)}cutBezierIgnoreAttributes(t,e,s){(t<0||e>1||t>e)&&(0,i.t)("Cubic_bezier.cut_bezier_ignore_attributes");const r=(0,n.m)(n.P,4);this.queryControlPoints(r);const o=(0,n.m)(n.P,4);Xn(r,t,e,o),s.setControlPoints(o)}splitBezierIgnoreAttributes(t,e,s){this===e&&this===s&&(0,i.t)("Cubic_bezier.split_bezier_ignore_attributes");const r=(0,n.m)(n.P,4);this.queryControlPoints(r);const o=(0,n.m)(n.P,4),a=(0,n.m)(n.P,4);Yn(r,t,o,a),e&&e.setControlPoints(o),s&&s.setControlPoints(a)}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.getStartAttributeAsDbl(e,s),r=this.getEndAttributeAsDbl(e,s),o=this.calculateLength2D(),a=o>0?this.tToLength(t)/o:0,h=dn.getInterpolation(e);return(0,n.$)(h,i,r,a,dn.getDefaultValue(e))}getClosestCoordinate(t,e){const s=[Number.NaN];return sr(this,t,n.E.unit(),e,-1,1,s),s[0]}getClosestCoordinateOnInterval(t,e,s=-1){const i=[Number.NaN];return 0===sr(this,t,e,!1,s,1,i)?Number.NaN:i[0]}getYMonotonicParts(t,e=!1){return this.getMonotonicParts(t,e)}getMonotonicParts(t,e){t.length<2&&(0,i.t)("");const s=In(this);if(2===s.specialPointsCount()&&this.isMonotoneQuickAndDirty())return 0;let n=0;(0,i.g)(t.length>=s.specialPointsCount()-1);for(let i=1,r=s.specialPointsCount();i<r;++i)this.queryCut(s.specialPoints[i-1],s.specialPoints[i],t[n],e),n++;for(let e=0;e<n;++e)Fn(t[e].get());return n}intersectionWithAxis2D(t,e,s,i){const r=(0,n.m)(n.P,4);return this.queryControlPoints(r),function(t,e,s,i,r){const o=(0,n.m)(n.H,4),a=(0,n.m)(n.H,3),h=new n.E(0,1);let m=0;if(e){if(vn(t,o,!1),m=Qe(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new n.P;kn(t,a[e].value(),s),i[e]=s.x}}else if(Cn(t,o,!1),m=Qe(o[3],o[2],o[1],o[0].sub(s),h,!1,a),i)for(let e=0;e<m;e++){const s=new n.P;kn(t,a[e].value(),s),i[e]=s.y}if(r)for(let t=0;t<m;t++)r[t]=a[t].value();else i&&(0,n.W)(i,0,m,n.F);return m}(r,t,e,s,i)}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],n=this.intersectionWithAxis2D(!0,t,s,null);return(0,i.g)(2!==n),-1===n?e:s[0]}isCurve(){return!0}isDegenerate(t){return Kt(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){if(2===t.m_EnvelopeType)return t.setCoords({pt:this.getStartXY()}),t.mergeNe(this.m_cp[0]),t.mergeNe(this.m_cp[1]),void t.mergeNe(this.getEndXY());(0,i.g)(0)}clone(t){const e=this.createInstance();return this.copyTo(e),e}queryInterval(t,e){if(0===t){const t=o.constructEmpty();this.queryEnvelope(t);const s=n.E.constructEmpty();return 0===e?t.queryIntervalX(s):t.queryIntervalY(s),s}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=(0,n.m)(n.P,4);this.queryControlPoints(s),Xn(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 Sn(this,t,!0)}lengthToT(t){return function(t,e){const s=Sn(t,1,!1);if(e<=0)return e;if(e>=s)return e-s+1;const r=[0];return 1!==He(new rr(t,e),n.E.unit(),1,r)&&(0,i.b)(""),r[0]}(this,t)}calculateWeightedAreaCentroid2D(t){const e=(0,n.m)(n.P,4);yn(this,e);const s=e[3],i=e[2],r=e[1],o=new n.P;o.x=(5*s.x*s.x*(7*i.y+16*r.y)+s.x*(-35*s.y*i.x+40*i.x*i.y-80*s.y*r.x+140*i.x*r.y+112*r.x*r.y)-2*(s.y*(20*i.x*i.x+70*i.x*r.x+56*r.x*r.x)-7*(4*i.x+5*r.x)*(-i.y*r.x+i.x*r.y)))/840,o.y=(-5*s.y*s.y*(7*i.x+16*r.x)+s.y*(5*s.x*(7*i.y+16*r.y)-4*(10*i.x*i.y+35*i.y*r.x+28*r.x*r.y))+2*(-7*(4*i.y+5*r.y)*(i.y*r.x-i.x*r.y)+s.x*(20*i.y*i.y+70*i.y*r.y+56*r.y*r.y)))/840;const a=qn(this);return o.x+=(e[0].x-t.x)*a,o.y+=(e[0].y-t.y)*a,o}calculateWeightedCentroid2D(){const t=new n.P;return this.isDegenerate(0)?(t.setCoords(0,0),t):function(t){const e=n.P.distance(t.getStartXY(),t.getEndXY()),s=t.calculateUpperLength2D();return s-e<=8*Number.EPSILON*s}(this)?(t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t):(t.assign(function(t,e,s){void 0===s&&(s=e,e=0);const r=new n.P;if(e<0||s>1)return r.setNAN(),r;if(e>s&&(0,i.t)("calculate_sub_weightedCentroid"),e===s||t.isDegenerate(0))return r.setCoords(0,0),r;const o=In(t),a=xn(t),h=a/t.calculateUpperLength2D();let m=e,l=0;for(let t=1,s=o.specialPointsCount();t<s;t++)if(e<o.specialPoints[t]){l=t-1;break}r.setCoords(0,0);for(let e=l+1,i=o.specialPointsCount();e<i;e++){const i=Math.min(o.specialPoints[e],s),n=hr(t,m,i,h,a);if(r.addThis(n),m=i,s<=o.specialPoints[e])break}return r.add(t.getStartXY().mul(t.calculateLength2D()))}(this,1)),t)}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()&&(0,i.t)("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=(0,n.m)(n.P,4);return this.queryControlPoints(e),Hn(e,t)}getDerivative(t){const e=(0,n.m)(n.P,4);return this.queryControlPoints(e),Mn(e,1,t)}getCurvature(t){const e=Gn(this,1,t),s=Gn(this,2,t),i=e.sqrLength();return 0===i?Number.NaN:(e.divThis(Math.sqrt(i)),e.crossProduct(s)/i)}isIntersectingPoint(t,e,s){if(s&&(t.equals(this.getStartXY())||t.equals(this.getEndXY())))return!1;const i=new o;if(this.queryLooseEnvelope(i),i.inflateCoords(e,e),!i.contains(t))return!1;const r=this.getClosestCoordinate(t,!1),a=new n.P;return this.queryCoord2D(r,a),n.P.distance(a,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}isMonotoneQuickAndDirty(){const t=(0,n.m)(n.P,4);return this.queryControlPoints(t),function(t){const e=(0,n.a4)(t[0].y,t[1].y),s=(0,n.a4)(t[1].y,t[2].y),i=(0,n.a4)(t[2].y,t[3].y);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0){const e=(0,n.a4)(t[0].x,t[1].x),s=(0,n.a4)(t[1].x,t[2].x),i=(0,n.a4)(t[2].x,t[3].x);if(e>=0&&s>=0&&i>=0||e<=0&&s<=0&&i<=0)return!0}return!1}(t)}getMonotonicPartParams(t,e){const s=In(this),n=s.specialPointsCount();if((0,i.g)(fe.s_maxMonotonicPartParams>=n),!e)return s.specialPointsCount();t<n&&(0,i.t)("");for(let t=0;t<n;t++)e[t]=s.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=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(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]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_cp[1]=(0,n.b)(this.m_cp[0],this.m_cp[0]=this.m_cp[1]),this.m_cachedValues=null}}findMinDeriv(){const t=new n.H;return An(this,t),t.value()}isLine(){return!1}isDegenerateToLineHelper(t){const e=this.getEndXY().sub(this.getStartXY()),s=e.length(),i=.1*t;let n=this.getControlPoint1();n.subThis(this.getStartXY());let r=Math.abs(n.crossProduct(e))/s;return!(r>i||(n=this.getControlPoint2(),n.subThis(this.getStartXY()),r=Math.abs(n.crossProduct(e))/s,r>i))}copyIgnoreAttributes(t){const e=(0,n.m)(n.P,4);this.queryControlPoints(e),t.setControlPoints(e)}calculateArea2DHelper(){return qn(this)}absNorm(){return(t=this).getStartXY().norm(1)+t.getEndXY().norm(1)+t.m_cp[0].norm(1)+t.m_cp[1].norm(1);var t}queryEnvelopeW(t,e){Jn(this,t,e)}setSegmentFromCoords(t,e){!function(t,e,s){if((0,i.g)(s>=2),2===s){const i=new n.P;(0,n.B)(e[0],e[s-1],1/3,i);const r=new n.P;return(0,n.B)(e[0],e[s-1],2/3,r),void t.construct(e[0],i,r,e[s-1])}const r=e[0],o=e[s-1],a=[0,0],h=sr(t,r,n.E.unit(),!1,Number.NaN,2,a),m=[0,0],l=sr(t,o,n.E.unit(),!1,Number.NaN,2,m),u=[];for(let i=0;i<h;i++)for(let h=0;h<l;h++){const l=a[i],c=m[h],g=(i,a)=>{const h=[];h.length=s-2;const m=()=>{let t=0;for(let i=1,r=s-1;i<r;i++){t+=n.P.distance(e[i-1],e[i]);const s=t;h[i-1]=s}t+=n.P.distance(e[s-2],e[s-1]);for(let e=1,i=s-1;e<i;e++)h[e-1]/=t};let u=!1,g=!1;{const e=new ra;l<=c?(t.queryCut(l,c,e,!0),i.assign(e.get().getControlPoint1()),a.assign(e.get().getControlPoint2())):(t.queryCut(c,l,e,!0),i.assign(e.get().getControlPoint2()),a.assign(e.get().getControlPoint1())),r.equals(i)&&(u=!0),o.equals(a)&&(g=!0)}m();let _=Number.MAX_VALUE;const d=i.clone(),p=a.clone();for(let t=0;t<5;t++)_=mr(!0,!1,r,d,p,o,u,g,h,0,e,s);for(let t=0;t<30;t++){const t=d.clone();p.clone();const i=mr(!0,!0,r,d,p,o,u,g,h,0,e,s);if(_<=i&&t.equals(d)&&t.equals(p))break;_=i}m();let f=!1,x=Number.EPSILON;const y=i.clone(),P=a.clone();for(let t=0;t<30;t++){const t=y.clone();P.clone();const i=mr(f,!0,r,y,P,o,u,g,h,0,e,s);if(x<=i&&t.equals(y)&&t.equals(P))break;f=!0,x=i}return x<_?(i.assign(y),a.assign(P)):(i.assign(d),a.assign(p),x=_),x},_=new n.P,d=new n.P,p=[g(_,d),n.P.distance(r,_)+n.P.distance(_,d)+n.P.distance(d,o),_.x,_.y,d.x,d.y];u.splice(u.length,0,...p)}let c=u[0],g=u[1],_=0;for(let t=6;t<u.length;t+=6)u[t]<c&&(c=u[t],g=u[t+1],_=t);let d=_;for(let t=0;t<u.length;t+=6)t!==_&&u[t+1]<g&&Math.abs(c-u[t])<10*c&&(g=u[t+1],d=t);t.construct(r,new n.P(u[d+2],u[d+3]),new n.P(u[d+4],u[d+5]),o)}(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=(0,n.m)(n.P,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=(0,n.m)(n.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let r=!1;return n.P.sqrDistance(e,i)<=t&&(r=!e.equals(i),e.setCoordsPoint2D(i),n.P.sqrDistance(s,i)<=t&&(r||=!s.equals(i),s.setCoordsPoint2D(i))),r},i=s(e[1],e[2],e[0]),r=s(e[2],e[1],e[3]);return(i||r)&&this.setControlPoints(e),i||r}needsSnapControlPoints(t){if(!t)return!1;const e=(0,n.m)(n.P,4);this.queryControlPoints(e);const s=(e,s,i)=>{let r=!1;return n.P.sqrDistance(e,i)<=t&&(r=!e.equals(i),e.setCoordsPoint2D(i),n.P.sqrDistance(s,i)<=t&&(r||=!s.equals(i),s.setCoordsPoint2D(i))),r},i=s(e[1],e[2],e[0]),r=s(e[2],e[1],e[3]);return i||r}calculateSpecialPointsForCracking(t,e){return function(t,e,s){s.length=0;{const e=new n.H;An(t,e);const i=new Wt;if(Bn(t,e,i),i.isZero())return e.isZero()||e.eq(new n.H(1))?0:(s.push(e.value()),1)}const i=(0,n.m)(n.H,4);Pn(t,i,!0);const r=(0,n.m)(n.H,4);En(t,r,!0);const o=(0,n.m)(n.H,6),a=i[3].negate().mulE(r[1]).addE(i[2].mulE(r[2]).mul(2)).addE(i[1].mulE(r[3])),h=i[3].negate().mulE(r[1]).subE(i[2].mulE(r[2]).mul(2)).addE(i[1].mulE(r[3])),m=i[2].mulE(i[2]).subE(r[2].mulE(r[2]));o[0]=r[1].mulE(r[1]).mulE(a).addE(i[1].mulE(i[1]).mulE(h)).addE(i[1].mulE(r[1]).mulE(m).mul(2)).mul(6),o[1]=i[2].mulE(r[1]).subE(i[1].mulE(r[2])).mulE(i[2].mulE(i[2]).addE(i[1].mulE(i[3]).mul(2)).addE(r[2].mulE(r[2])).addE(r[1].mulE(r[3]).mul(2))).mul(24);const l=i[1].mulE(r[2]).mulE(r[2]).mulE(r[3]),u=i[2].mulE(i[2]).mulE(i[3]).mulE(r[1]).subE(l).mul(156),c=i[3].mulE(r[1]).subE(i[1].mulE(r[3])),g=i[3].mulE(r[1]).subE(i[1].mulE(r[3])),_=i[1].mulE(i[3]).mulE(g).addE(r[1].mulE(r[3]).mulE(c)).mul(72),d=r[1].mulE(r[3]).subE(i[1].mulE(i[3])),p=i[2].mulE(r[2]).mulE(d).mul(120),f=i[1].mulE(i[2]).mulE(i[2]).mulE(r[3]),x=i[3].mulE(r[1]).mulE(r[2]).mulE(r[2]).subE(f).mul(36);o[2]=u.addE(_).addE(p).addE(x);const y=i[2].mulE(i[3]).mulE(i[3]).mulE(r[1]).subE(i[1].mulE(r[2]).mulE(r[3]).mulE(r[3])).mul(360),P=i[2].mulE(r[2]).mulE(i[2].mulE(i[3]).subE(r[2].mulE(r[3]))).addE(i[3].mulE(r[2]).mulE(r[2]).mulE(r[2])).subE(i[2].mulE(i[2]).mulE(i[2]).mulE(r[3])).mul(24),E=i[2].mulE(r[1]).mulE(r[3]).mulE(r[3]).subE(i[1].mulE(i[3]).mulE(i[3]).mulE(r[2])).mul(72),C=i[3].mulE(r[3]).mulE(r[1].mulE(r[2]).subE(i[1].mulE(i[2]))).mul(288);o[3]=y.addE(P).addE(E).addE(C),o[4]=r[3].mulE(r[3]).addE(i[3].mulE(i[3])).mulE(i[3].mulE(r[1]).subE(i[1].mulE(r[3]))).mul(270).addE(i[3].mulE(r[2]).subE(i[2].mulE(r[3]))).mulE(i[2].mulE(i[3]).addE(r[2].mulE(r[3]))).mul(180),o[5]=i[3].mulE(r[2]).subE(i[2].mulE(r[3])).mulE(i[3].mulE(i[3]).addE(r[3].mulE(r[3]))).mul(216);const v=(0,n.m)(n.H,5),b=Ke(o,5,new n.E(0,1),!1,v,5);if(b>0){let i=Math.abs(t.getCurvature(0)),r=0;const o=Math.abs(t.getCurvature(1));(o>i||!Number.isFinite(o))&&(r=1);for(let e=0;e<b;e++){const s=Math.abs(t.getCurvature(v[e].value()));t.getCoord2D(v[e].value()),(s>i||!Number.isFinite(s))&&(i=s,r=v[e].value())}if((!Number.isFinite(i)||1/i<e)&&!(0,n.a1)(r,0,1)){const e=t.getCoord2D(r);if(!e.equals(t.getStartXY())&&!e.equals(t.getEndXY()))return s.push(r),1}}return 0}(this,t,e)}ensureXYMonotone(){return Fn(this)}setCoordsForIntersector(t,e,s){!function(t,e,s,i){if(e.isEqual(t.m_XStart,t.m_YStart)&&s.isEqual(t.m_XEnd,t.m_YEnd))return;const r=!!i&&t.isMonotoneQuickAndDirty(),o=new n.T,a=(0,n.m)(n.P,3);a[0].setCoords(t.m_XStart,t.m_YStart),a[2].setCoords(t.m_XEnd,t.m_YEnd);const h=new n.P;h.setSub(a[2],a[0]),h.leftPerpendicularThis(),a[1].setAdd(a[0],h);const m=(0,n.m)(n.P,3);m[0].setCoordsPoint2D(e),m[2].setCoordsPoint2D(s),h.setSub(m[2],m[0]),h.leftPerpendicularThis(),m[1].setAdd(m[0],h),o.setFromTwoTriangles(a,m)?o.transformPoints2D(t.m_cp,2,t.m_cp):((0,n.B)(e,s,1/3,t.m_cp[0]),(0,n.B)(e,s,2/3,t.m_cp[1])),t.changeEndPoints2D(e,s),r&&Fn(t)}(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]),Dn(e,wn(this))}reverseImpl(){this.m_cp[1]=(0,n.b)(this.m_cp[0],this.m_cp[0]=this.m_cp[1])}equalsImpl(t){const e=t;return!!this.m_cp[0].equals(e.m_cp[0])&&!!this.m_cp[1].equals(e.m_cp[1])}equalsImplTol(t,e){const s=t;return!!this.m_cp[0].isEqualPoint2D(s.m_cp[0],e)&&!!this.m_cp[1].isEqualPoint2D(s.m_cp[1],e)}swapImpl(t){const e=t;e.m_cp[0]=(0,n.b)(this.m_cp[0],this.m_cp[0]=e.m_cp[0]),e.m_cp[1]=(0,n.b)(this.m_cp[1],this.m_cp[1]=e.m_cp[1]),function(t,e){e.m_cachedValues=(0,n.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){Tn(this)}isIntersecting(t,e,s){return 0!==jo(!1,this,t,e,s)}intersect(t,e,s,i,n){return Jo(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){return function(t,e,s,r){const o=new Ht;if(Jn(t,n.E.unit(),o),o.inflate(r),!o.isIntersectingPoint2D(e))return 0;const a=In(t);let h=0,m=a.specialPoints[0];const l=[];for(let s=1,n=a.specialPoints.length;s<n;++s){const n=a.specialPoints[s],r=Nn(t,e,m,n);if(0===l.length)l.push(r);else if(r.t===r.tmin)(0,i.g)(l.at(-1).d<=r.d),l.at(-1).tmax=r.tmax;else if(l.at(-1).t===l.at(-1).tmax){(0,i.g)(l.at(-1).d>=r.d);const t=l.at(-1).tmin;l[l.length-1]=r,l.at(-1).tmin=t}else l.push(r);m=n}for(const t of l)if(t.d<=r){const e=t.t;s?(h>=s.length&&(0,i.w)(""),s[h]=e,h++):h++}return h}(this,t,e,s)}endPointModified(){Tn(this)}clearEndPointModified(){}}pn.type=i.G.enumBezier;class fn{constructor(){this.length=Number.NaN,this.specialPoints=[]}specialPointsCount(){return this.specialPoints.length}}function xn(t){return function(t){return 256*(0,n.aa)()*t}(t.calculateUpperLength2D())}function yn(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 Pn(t,e,s){const i=(0,n.m)(n.P,4);t.queryControlPoints(i),Cn(i,e,s)}function En(t,e,s){const i=(0,n.m)(n.P,4);t.queryControlPoints(i),vn(i,e,s)}function Cn(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 vn(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 bn(t,e,s=!1){const i=(0,n.m)(hs,4);i[0].assignPoint2D(t[0]),i[1].assignPoint2D(t[1]),i[2].assignPoint2D(t[2]),i[3].assignPoint2D(t[3]),e[1].setCoords(i[1].x.sub(i[0].x),i[1].y.sub(i[0].y)),e[1].mulThis(n.M.constructInt32(3)),e[2].setCoords(i[2].x.sub(i[1].x),i[2].y.sub(i[1].y)),e[2].mulThis(n.M.constructInt32(3)),e[3]=i[3].sub(i[0]),e[3]=e[3].sub(e[2]),e[2]=e[2].sub(e[1]),s?e[0].setCoords(n.ak,n.ak):e[0]=i[0].clone()}function Sn(t,e,s){if(s){if(e<0)return e;if(e>1)return e-1+Sn(t,1,!1)}if(t.isDegenerate(0))return 0;const i=1===e,n=In(t);if(i&&!Number.isNaN(n.length)&&!Number.isNaN(n.length))return n.length;const r=xn(t),o=r/t.calculateUpperLength2D();let a=0,h=0;for(let s=1,i=n.specialPointsCount();s<i;s++){const i=n.specialPoints[s];if(a+=ar(t,h,Math.min(e,i),o,r),e<=i)break;h=i}return i&&(n.length=a),a}function In(t){if(t.m_cachedValues)return t.m_cachedValues;const e=new fn,s=(0,n.m)(n.H,8),i=(0,n.m)(n.P,4);t.queryControlPoints(i);const r=ir(i,s);e.specialPoints=[];for(let t=0;t<r;t++)e.specialPoints.push(s[t].value());return Dn(t,e),e}function wn(t){let e=null;return e=t.m_cachedValues,e}function Dn(t,e){t.m_cachedValues=e}function Tn(t){t.m_cachedValues=null}function Nn(t,e,s,i){const r=new Array(18),o=(0,n.m)(n.P,4);t.queryControlPoints(o);const a=He(new tr(o,e),n.E.construct(s,i),18,r),h=new n.P;t.queryCoord2D(s,h);let m=s,l=n.P.distance(h,e);const u=new n.P;t.queryCoord2D(i,u);const c=n.P.distance(u,e);c<l&&(l=c,m=i,h.assign(u));for(let s=0;s<a;s++){t.queryCoord2D(r[s],u);const i=n.P.distance(u,e);i<l&&(l=i,m=r[s],h.assign(u))}return function(t,e,s,i,n){return{tmin:t,tmax:e,t:s,d:i,pt:n.clone()}}(s,i,m,l,h)}function An(t,e){const s=(0,n.m)(n.H,4);Pn(t,s,!0);const r=(0,n.m)(n.H,4);En(t,r,!0);const o=s[3].clone(),a=s[2].clone(),h=s[1].clone(),m=r[3].clone(),l=r[2].clone(),u=r[1].clone(),c=a.mulE(h).addE(l.mulE(u)).mul(4),g=a.mulE(a).mul(8).addE(o.mulE(h).mul(12)).addE(l.mulE(l).mul(8).addE(m.mulE(u).mul(12))),_=o.mulE(a).addE(m.mulE(l)).mul(36),d=o.mulE(o).addE(m.mulE(m)).mul(36),p=(0,n.m)(n.H,3),f=Qe(d,_,g,c,new n.E(0,1),!1,p);if((0,i.g)(f<=3),f>0){const s=Gn(t,1,0).sqrLength(),i=Gn(t,1,1).sqrLength();let n=s;e.set(0),n<i&&(n=i,e.set(1));for(let s=0;s<f;s++){const i=Gn(t,1,p[s].value()).sqrLength();i<n&&(n=i,e=p[s])}}}function Mn(t,e,s){const i=new n.P;return function(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)}(t,e,s,i),i}function Gn(t,e,s){const i=(0,n.m)(n.P,4);return t.queryControlPoints(i),Mn(i,e,s)}function qn(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());return e.mulThis(3),s.mulThis(3),i.subThis(s),s.subThis(e),(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 Fn(t){const e=(0,n.m)(n.P,4);t.queryControlPoints(e);const s=Vn(e);return s&&(t.m_cp[0].setCoordsPoint2D(e[1]),t.m_cp[1].setCoordsPoint2D(e[2]),t.afterCompletedModification()),s}function Vn(t){let e=!1;for(let s=0;s<2;s++){const i=(0,n.a4)(t[0][s],t[3][s]);i>0?((0,n.a4)(t[0][s],t[1][s])<0&&(t[1][s]=t[0][s],e=!0),(0,n.a4)(t[1][s],t[3][s])<0&&(t[1][s]=t[3][s],e=!0),(0,n.a4)(t[0][s],t[2][s])<0&&(t[2][s]=t[0][s],e=!0),(0,n.a4)(t[2][s],t[3][s])<0&&(t[2][s]=t[3][s],e=!0),(0,n.a4)(t[1][s],t[2][s])<0&&(t[2][s]=t[1][s],e=!0)):i<0?((0,n.a4)(t[0][s],t[1][s])>0&&(t[1][s]=t[0][s],e=!0),(0,n.a4)(t[1][s],t[3][s])>0&&(t[1][s]=t[3][s],e=!0),(0,n.a4)(t[0][s],t[2][s])>0&&(t[2][s]=t[0][s],e=!0),(0,n.a4)(t[2][s],t[3][s])>0&&(t[2][s]=t[3][s],e=!0),(0,n.a4)(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 Rn(t,e,s){const i=new n.P,r=new n.P,o=new n.P,a=new n.P,h=new n.P;e<=.5?((0,n.a2)(2,t[0],t[1],e,i),(0,n.a2)(2,t[1],t[2],e,r),(0,n.a2)(2,t[2],t[3],e,o),(0,n.a2)(2,i,r,e,a),(0,n.a2)(2,r,o,e,h),(0,n.a2)(2,a,h,e,s)):((0,n.a3)(2,t[0],t[1],e,i),(0,n.a3)(2,t[1],t[2],e,r),(0,n.a3)(2,t[2],t[3],e,o),(0,n.a3)(2,i,r,e,a),(0,n.a3)(2,r,o,e,h),(0,n.a3)(2,a,h,e,s))}function Yn(t,e,s,r){(0,i.g)(e>=0&&e<=1);const o=new n.P,a=new n.P,h=new n.P,m=new n.P,l=new n.P,u=new n.P;e<=.5?((0,n.a2)(2,t[0],t[1],e,o),(0,n.a2)(2,t[1],t[2],e,a),(0,n.a2)(2,t[2],t[3],e,h),(0,n.a2)(2,o,a,e,m),(0,n.a2)(2,a,h,e,l),(0,n.a2)(2,m,l,e,u)):((0,n.a3)(2,t[0],t[1],e,o),(0,n.a3)(2,t[1],t[2],e,a),(0,n.a3)(2,t[2],t[3],e,h),(0,n.a3)(2,o,a,e,m),(0,n.a3)(2,a,h,e,l),(0,n.a3)(2,m,l,e,u));const c=t[3].clone();s&&(s[0].assign(t[0]),s[1].assign(o),s[2].assign(m),s[3].assign(u)),r&&(r[0].assign(u),r[1].assign(l),r[2].assign(h),r[3].assign(c))}function Xn(t,e,s,r){if((0,i.g)(e>=0&&s<=1&&e<=s),e===s){const s=new n.P;return kn(t,e,s),r[0].assign(s),r[1].assign(s),r[2].assign(s),void r[3].assign(s)}if(0===e&&1===s){for(let e=0;e<4;++e)r[e].assign(t[e]);return}const o=(0,n.m)(n.P,4);Yn(t,s,o,null),Yn(o,s>0?e/s:0,null,o),kn(t,e,o[0]),kn(t,s,o[3]),r[0].setCoordsPoint2D(o[0]),r[1].setCoordsPoint2D(o[1]),r[2].setCoordsPoint2D(o[2]),r[3].setCoordsPoint2D(o[3])}function kn(t,e,s,i){if(i){if(e<0)return void Pe(new na({start:t[0],end:t[0].add(Hn(t,0).getUnitVector())}),e,s);if(e>1)return void Pe(new na({start:t[3],end:t[3].add(Hn(t,1).getUnitVector())}),e-1,s)}if(e<=.5){const i=new n.P;(0,n.a2)(2,t[0],t[1],e,i);const r=new n.P;(0,n.a2)(2,t[1],t[2],e,r);const o=new n.P;(0,n.a2)(2,t[2],t[3],e,o);const a=new n.P;(0,n.a2)(2,i,r,e,a);const h=new n.P;(0,n.a2)(2,r,o,e,h),(0,n.a2)(2,a,h,e,s)}else{const i=new n.P;(0,n.a3)(2,t[0],t[1],e,i);const r=new n.P;(0,n.a3)(2,t[1],t[2],e,r);const o=new n.P;(0,n.a3)(2,t[2],t[3],e,o);const a=new n.P;(0,n.a3)(2,i,r,e,a);const h=new n.P;(0,n.a3)(2,r,o,e,h),(0,n.a3)(2,a,h,e,s)}}function Hn(t,e){const s=(0,n.l)(e,0,1);let i=Mn(t,1,s);return i.isZero()&&(i=Mn(t,2,s),i.isZero()?i=Mn(t,3,s):1===s&&i.negateThis()),i}function Bn(t,e,s){const i=(0,n.m)(n.P,4);t.queryControlPoints(i),function(t,e,s){e.value()<0&&e.set(0,e.eps()),e.value()>1&&e.set(1,e.eps()),s.setE(function(t,e,s){const i=[Wt.constructPoint2D(t[0]),Wt.constructPoint2D(t[1]),Wt.constructPoint2D(t[2]),Wt.constructPoint2D(t[3])],r=new Wt;return function(t,e,s,i){{const e=n.ai.subE(s),r=e.sqr(),o=s.sqr(),a=t[1].subE(t[0]).mulE(r).addE(t[2].subE(t[1]).mulE(new n.H(2).mulE(e).mulE(s))).addE(t[3].subE(t[2]).mulE(o));i.setE(a.mulE(new n.H(3)))}}(i,0,s,r),r}(t,0,e))}(i,e,s)}function Ln(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==Wn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function zn(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==jn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Un(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==Qn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function On(t,e,s,i,n){if(n){if(0!==Qo(e,s))return t?4:2}else if(Qt(e,s))return 1;return 0!==Kn(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}function Wn(t,e,s,i,r,o,a,h,m,l){if(null!==r&&(r.length=0),null!=o&&(o.length=0),null!==i&&(i.length=0),s.isDegenerate(0)){const t=[0,0,0],h=e.intersectPoint(s.getStartXY(),t,a);if(h>0){if(null!==r)for(let e=0;e<h;e++)r.push(t[e]);if(null!==o)for(let t=0;t<h;t++)o.push(0);if(null!=i)for(let s=0;s<h;s++){const r=new n.P;e.queryCoord2D(t[s],r),i.push(r)}}return h}const u=ge(e,s);if(_e(e,s,a=Math.max(a,u)))return 0;const c=(0,n.m)(n.P,4);yn(e,c);const g=s.getEndXY();g.subThis(s.getStartXY());const _=g.clone();_.leftPerpendicularThis();let d=3*c[3].dotProduct(_),p=2*c[2].dotProduct(_),f=c[1].dotProduct(_);const x=new Array(15),y=new Array(15);let P=Be(d,p,f,n.E.unit(),!1,x);P<0&&(x[0]=0,x[1]=1,P=2);let E,C=0;for(let t=0,i=C;t<P;++t){const r=e.getCoord2D(x[t+i]);y[C]=s.getClosestCoordinate(r,!1),n.P.distance(r,s.getCoord2D(y[C]))<=a&&(x[C]=x[t+i],C++)}if(c[0].subThis(s.getStartXY()),Math.abs(g.x)>=Math.abs(g.y)){const t=g.y/g.x;d=c[3].y-c[3].x*t,p=c[2].y-c[2].x*t,f=c[1].y-c[1].x*t,E=c[0].y-c[0].x*t}else{const t=g.x/g.y;d=c[3].x-c[3].y*t,p=c[2].x-c[2].y*t,f=c[1].x-c[1].y*t,E=c[0].x-c[0].y*t}const v=e.getEndXY().equals(s.getStartXY())||e.getEndXY().equals(s.getEndXY()),b=[0,0,0];P=Le(d,p,f,E,n.E.unit(),v,b);for(let t=0,i=C;t<P;++t){x[t+i]=b[t];const r=e.getCoord2D(x[t+i]);y[C]=s.getClosestCoordinate(r,!1),n.P.distance(r,s.getCoord2D(y[C]))<=a&&(x[C]=x[t+i],C++)}P=e.intersectPoint(s.getStartXY(),b,a);for(let t=0;t<P;t++)x[C]=b[t],y[C++]=0;P=e.intersectPoint(s.getEndXY(),b,a);for(let t=0;t<P;t++)x[C]=b[t],y[C++]=1;return 0!==s.intersectPoint(e.getStartXY(),b,a)&&(y[C]=b[0],x[C++]=0),0!==s.intersectPoint(e.getEndXY(),b,a)&&(y[C]=b[0],x[C++]=1),0===C?0:ta(t,e,s,x,y,C,i,r,o,a,h,0,l)}function jn(t,e,s,i,r,o,a,h,m,l){if(to(s))return Wn(t,e,new na({start:s.getStartXY(),end:s.getEndXY()}),i,r,o,a,h,0,l);const u=ge(e,s);if(_e(e,s,a=Math.max(a,u)))return 0;const c=[],g=[],_=[],d=(0,n.m)(n.P,4);{e.queryControlPoints(d);const t=(0,n.m)(n.P,4),i=new n.T;s.canonicToWorldTransformation(i);const r=new n.T;r.setInvert(i),r.transformPoints2D(d,4,t);const o=(0,n.m)(hs,4);bn(t,o);const h=[o[0].x,o[1].x,o[2].x,o[3].x],m=[o[0].y,o[1].y,o[2].y,o[3].y],l=(0,n.m)(n.M,3);l[0].setDouble(s.getSemiMinorAxis()),l[0].sqrThis(),l[1].setDouble(s.getSemiMajorAxis()),l[1].sqrThis(),l[2].setThis(l[0]),l[2].mulThis(l[1]),l[2].negateThis();const u=gs(h,3,m,3,null,0,l,0,n.E.unit(),n.E.unit(),g);if(u>0){let t=0;for(let i=0;i<u;i++){const r=new n.P;e.queryCoord2D(g[i],r);const o=s.getClosestCoordinate(r,!1),h=new n.P;s.queryCoord2D(o,h),n.P.distance(r,h)<=a&&(c.push(r.clone()),g[t]=g[i],_.push(o),t++)}g.length=t,c.length=t}}const p=[0,1];for(let t=0;t<2;t++){const e=0===t?s.getStartXY():s.getEndXY(),i=[0];er(d,e,n.E.unit(),!1,-1,1,i);const r=new n.P;kn(d,i[0],r),n.P.distance(e,r)<=a&&(g.push(i[0]),_.push(p[t]),c.push(r.clone()))}for(let t=0;t<2;t++){const e=[0,3];{const i=s.getClosestCoordinate(d[e[t]],!1),r=new n.P;s.queryCoord2D(i,r),n.P.distance(d[e[t]],r)<=a&&(g.push(p[t]),_.push(i),c.push(r.clone()))}}return ta(t,e,s,g,_,g.length,i,r,o,a,h,0,l)}function Zn(t,e,s,r,o,a,h,m,l,u){const c=(0,n.m)(n.P,4);e.queryControlPoints(c);const g=(0,n.m)(n.P,4);if(s.queryControlPoints(g),de(c,g,4)<0)return Zn(t,s,e,r,a,o,h,m,l,!u);const _=ge(e,s);if(_e(e,s,h=Math.max(h,_)))return 0;if(function(t,e,s,i,r,o,a,h,m){const l=(0,n.m)(n.P,4);t.queryControlPoints(l);const u=(0,n.m)(n.P,4);if(e.queryControlPoints(u),l[0].equals(u[0])){if(l[1].equals(u[1])&&l[2].equals(u[2])&&l[3].equals(u[3]))return s&&(s.length=0,s.push(l[0]),s.push(l[3])),i&&(i.length=0,i.push(0),i.push(1)),r&&(r.length=0,r.push(0),r.push(1)),!0;if(!l[0].equals(u[3]))return!1}return!!(l[0].equals(u[3])&&l[1].equals(u[2])&&l[2].equals(u[1])&&l[3].equals(u[0]))&&(i&&(i.length=0,i.push(0),i.push(1),m&&(i[1]=(0,n.b)(i[0],i[0]=i[1]))),r&&(r.length=0,r.push(1),r.push(0),m&&(r[1]=(0,n.b)(r[0],r[0]=r[1]))),s&&(s.length=0,s.push(l[0]),s.push(l[3]),m&&(s[1]=(0,n.b)(s[0],s[0]=s[1]))),!0)}(e,s,r,o,a,0,0,0,u))return 2;const d=new n.E(0,1),p=new n.E(0,1);{const t=new Ht;$n(c,new n.E(0,1),t);const e=new Ht;$n(g,new n.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(nr(c,t,d),nr(g,t,p),d.isEmpty()||p.isEmpty())return 0;Xn(c,d.vmin,d.vmax,c),Xn(g,p.vmin,p.vmax,g)}}const f=sa(c,3,g,3,h);if(0===f)return 0;const x=[],y=[],P=[];let E=!1;if(-1===f){const t=(0,n.m)(hs,4);bn(c,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,n.m)(hs,4);bn(g,i);const r=[],o=[],a=cs(e,3,s,3,null,0,[i[0].x,i[1].x,i[2].x,i[3].x],3,[i[0].y,i[1].y,i[2].y,i[3].y],3,null,0,0,n.E.unit(),n.E.unit(),r,o);if(a>0)for(let t=0;t<a;t++){const e=new n.P;kn(g,o[t],e);const s=new n.P;kn(c,r[t],s),n.P.distance(s,e)<=h&&(x.push(s.clone()),P.push(o[t]),y.push(r[t]))}else-1===a&&(E=!0)}for(let t=0;t<2;t++){const e=0===t?c:g,s=0===t?g:c;for(let i=0;i<2;i++){const r=0===i?0:3,o=[0];er(s,e[r],n.E.unit(),!1,-1,1,o);const a=new n.P;kn(s,o[0],a),n.P.distance(e[r],a)<=h&&(0===t?(y.push(0===r?0:1),P.push(o[0])):(P.push(0===r?0:1),y.push(o[0])),x.push(a.clone()))}}if(0===y.length&&E){const t=e.calculateUpperLength2D()>s.calculateUpperLength2D();{const r=[0,0];if(2===function(t,e,s=!1){const i=(0,n.m)(n.P,4);t.queryControlPoints(i);const r=(0,n.m)(hs,4);let o,a,h;bn(i,r,!0);const m=r[3].x.isZero(),l=r[3].y.isZero();if(m||l)if(m&&!l){if(r[2].x.isZero())return 0;o=r[1].x.div(r[2].x).negate(),a=r[2].y.div(r[3].y),h=r[1].y.div(r[3].y)}else{if(m||!l)return 0;if(r[2].y.isZero())return 0;o=r[1].y.div(r[2].y).negate(),a=r[2].x.div(r[3].x),h=r[1].x.div(r[3].x)}else{r[2].x.divThis(r[3].x),r[1].x.divThis(r[3].x),r[2].y.divThis(r[3].y),r[1].y.divThis(r[3].y);const t=r[2].x.sub(r[2].y);if(t.isZero())return 0;o=r[1].x.sub(r[1].y).div(t).negate(),a=r[2].x.clone(),h=r[1].x.clone()}if(!s&&o.abs().value()>2)return 0;const u=[0,0],c=t.getStartXY().equals(t.getEndXY()),g=Be(1,-o.toDouble(),o.add(a).mul(o).add(h).toDouble(),n.E.unit(),c,u);if(0===g)return 0;if(u[0]>=0&&u[0]<=1){const t=o.toDouble()-u[0];if(s||t>=0&&t<=1)return e[0]=u[0],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.b)(e[0],e[0]=e[1])),2}if(2===g&&u[1]>=0&&u[1]<=1){const t=o.toDouble()-u[1];if(s||t>=0&&t<=1)return e[0]=u[1],e[1]=t,e[0]>e[1]&&(e[1]=(0,n.b)(e[0],e[0]=e[1])),2}return 0}(t?e:s,r,!0)&&((0,i.g)(n.E.unit().containsCoordinate(r[0])),!n.E.unit().containsCoordinate(r[1]))){const e=new n.P;kn(t?c:g,r[0],e);const s=[0,0];1===er(t?g:c,e,n.E.unit(),!1,-1,2,s)&&(x.push(e.clone()),y.push(t?r[0]:s[0]),P.push(t?s[0]:r[0]))}}}if(0===y.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<y.length;++t)y[t]=pn.recalculateParentT(d.vmin,d.vmax,y[t]);if(!p.equalsRange(0,1))for(let t=0;t<P.length;++t)P[t]=pn.recalculateParentT(p.vmin,p.vmax,P[t]);return ta(t,e,s,y,P,y.length,r,o,a,h,m,0,u)}function Qn(t,e,s,r,o,a,h,m,l,u){const c=ge(e,s);if(s.isDegenerateToLineHelper(c)){const i=new na({start:s.getStartXY(),end:s.getEndXY()}),n=Wn(t,e,i,r,o,a,h,m,0,u);if(a)for(let t=0;t<n;++t){const e=i.getCoord2D(a[t]);a[t]=s.getClosestCoordinate(e,!1)}return n}if(_e(e,s,h=Math.max(h,c)))return 0;const g=(0,n.m)(n.P,4);e.queryControlPoints(g);const _=(0,n.m)(n.P,3);s.queryControlPoints(_);const d=new n.E(0,1),p=new n.E(0,1),f=[0,0,0];s.queryWeights(f);const x=[1,Ti(f),1];{const t=new Ht;$n(g,new n.E(0,1),t);const e=new Ht;mi(_,x,new n.E(0,1),e);const s=Math.max(t.maxDim(),e.maxDim());if(t.inflate(3*h),e.inflate(3*h),!t.intersectW(e))return 0;if(t.maxDim()<.1*s){if(nr(g,t,d),Di(_,x,t,p),d.isEmpty()||p.isEmpty())return 0;Xn(g,d.vmin,d.vmax,g),_i(_,x,p.vmin,p.vmax,_,x)}}const y=sa(g,3,_,2,h);if(0===y)return 0;const P=[],E=[],C=[];if(-1===y){const t=(0,n.m)(hs,4);bn(g,t);const e=[t[0].x,t[1].x,t[2].x,t[3].x],s=[t[0].y,t[1].y,t[2].y,t[3].y],i=(0,n.m)(n.M,3),r=(0,n.m)(n.M,3),o=(0,n.m)(n.M,3);vi(_,x,i,r,o);const a=[],m=[],l=cs(i,2,r,2,o,2,e,3,s,3,null,0,0,n.E.unit(),n.E.unit(),m,a);if(l>0)for(let t=0;t<l;t++){const e=new n.P;kn(g,a[t],e);const s=new n.P;wi(_,x,m[t],s),n.P.distance(e,s)<=h&&(P.push(e.clone()),E.push(a[t]),C.push(m[t]))}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=_):(s=g,e=_);for(let r=0;r<2;r++){const o=0===r?0:e.length-1,a=[0],m=new n.P;if(0===t){const t=ai(s,x,e[o],n.E.unit(),!1,-1,1,a);(0,i.g)(1===t),wi(s,x,a[0],m)}else{const t=er(s,e[o],n.E.unit(),!1,-1,1,a);(0,i.g)(1===t),kn(s,a[0],m)}n.P.distance(e[o],m)<=h&&(0===t?(E.push(0===o?0:1),C.push(a[0])):(C.push(0===o?0:1),E.push(a[0])),P.push(m.clone()))}}if(0===E.length)return 0;if(!d.equalsRange(0,1))for(let t=0;t<E.length;++t)E[t]=pn.recalculateParentT(d.vmin,d.vmax,E[t]);if(!p.equalsRange(0,1))for(let t=0;t<C.length;++t)C[t]=as.recalculateParentT(p.vmin,p.vmax,C[t]);for(let t=0;t<C.length;++t)C[t]=Ni(f,C[t]);return ta(t,e,s,E,C,E.length,r,o,a,h,m,0,u)}function Kn(t,e,s,r,o,a,h,m,l,u){const c=ge(e,s);if(_e(e,s,h=Math.max(h,c)))return 0;const g=(0,n.m)(n.P,4);e.queryControlPoints(g);const _=(0,n.m)(n.P,3);s.queryControlPoints(_);const d=sa(g,3,_,2,h);if(0===d)return 0;const p=[],f=[],x=[];if(-1===d){const t=(0,n.m)(hs,4);bn(g,t);const i=[t[0].x,t[1].x,t[2].x,t[3].x],r=[t[0].y,t[1].y,t[2].y,t[3].y],o=(0,n.m)(hs,3);gn(_,o);const a=cs([o[0].x,o[1].x,o[2].x],2,[o[0].y,o[1].y,o[2].y],2,null,0,i,3,r,3,null,0,0,n.E.unit(),n.E.unit(),x,f);if(a>0){let t=0;for(let i=0;i<a;i++){const r=new n.P;e.queryCoord2D(f[i],r);const o=new n.P;s.queryCoord2D(x[i],o),n.P.distance(r,o)<=h&&(p.push(r.clone()),f[t]=f[i],x[t]=x[i],t++)}f.length=t,p.length=t}}for(let t=0;t<2;t++){let e,s;0===t?(e=g,s=_):(s=g,e=_);for(let r=0;r<2;r++){const o=0===r?0:e.length-1,a=[0],m=new n.P;if(0===t)$i(s,e[o],a),_n(s,a[0],m);else{const t=er(s,e[o],n.E.unit(),!1,-1,1,a);(0,i.g)(1===t),kn(s,a[0],m)}n.P.distance(e[o],m)<=h&&(0===t?(f.push(0===o?0:1),x.push(a[0])):(x.push(0===o?0:1),f.push(a[0])),p.push(m.clone()))}}return ta(t,e,s,f,x,f.length,r,o,a,h,m,0,u)}function Jn(t,e,s){const i=(0,n.m)(n.P,4);t.queryControlPoints(i),$n(i,e,s)}function $n(t,e,s){if(e.equalsRange(0,1))return void s.setFromPoints(t,4);const i=(0,n.m)(n.P,4);Xn(t,e.vmin,e.vmax,i),s.setFromPoints(i,4)}class tr{constructor(t,e){this.controlPoints=t,this.point=e.clone()}getMaxDerivative(){return 6}getValue(t,e){switch(t){case 0:{const t=new n.P;kn(this.controlPoints,e,t);const s=Mn(this.controlPoints,1,e);return 2*t.sub(this.point).dotProduct(s)}case 1:{const t=new n.P;kn(this.controlPoints,e,t);const s=Mn(this.controlPoints,1,e),i=Mn(this.controlPoints,2,e);return 2*(t.sub(this.point).dotProduct(i)+s.dotProduct(s))}case 2:{const t=new n.P;kn(this.controlPoints,e,t);const s=Mn(this.controlPoints,1,e),i=Mn(this.controlPoints,2,e),r=Mn(this.controlPoints,3,e);return 2*(t.sub(this.point).dotProduct(r)+3*s.dotProduct(i))}case 3:{const t=Mn(this.controlPoints,1,e),s=Mn(this.controlPoints,2,e),i=Mn(this.controlPoints,3,e);return 2*(4*t.dotProduct(i)+3*s.sqrLength())}case 4:{const t=Mn(this.controlPoints,2,e),s=Mn(this.controlPoints,3,e);return 10*t.dotProduct(s)*2}case 5:{const t=Mn(this.controlPoints,3,e);return 10*t.dotProduct(t)*2}default:return 0}}getError(t){return 0}}function er(t,e,s,r,o,a,h){(0,i.A)(n.E.unit().contains(s)&&a>0,"getClosestCoordinate"),(o<0||Number.isNaN(o))&&(o=Number.MAX_VALUE);const m=[],l=new n.P;kn(t,s.vmin,l);let u=n.P.distance(l,e);if(u<=o&&m.push(new n.P(s.vmin,u)),s.vmin!==s.vmax&&(kn(t,s.vmax,l),u=n.P.distance(l,e),u<=o&&m.push(new n.P(s.vmax,u))),s.width()>0){const i=new Array(18),r=He(new tr(t,e),s,18,i);for(let s=0;s<r;s++)kn(t,i[s],l),u=n.P.distance(l,e),u>o||m.push(new n.P(i[s],u))}if(r){(0,i.g)(s.equals(n.E.unit()));{kn(t,-1,l,!0);const s=new n.P;kn(t,0,s);const i=new na({start:l,end:s}),r=i.getClosestCoordinate(e,!0);r<1&&(l.assign(i.getCoord2D(r)),u=n.P.distance(l,e),u<=o&&m.push(new n.P(r-1,u)))}{kn(t,2,l,!0);const i=new n.P;kn(t,s.vmax,i);const r=new na({start:i,end:l}),a=r.getClosestCoordinate(e,!0);a>0&&(l.assign(r.getCoord2D(a)),u=n.P.distance(l,e),u<=o&&m.push(new n.P(1+a,u)))}}if(!m.length)return 0;m.sort(((t,e)=>t.compare(e)));let c=0;const g=m[0].x;if(h[c++]=g,c<a){const e=rt(t,4,!1).total(),s=m[0].y;for(let t=1,i=m.length;t<i;t++)if(m[t].y>s+e){m.length=t;break}m.sort(((t,e)=>(0,n.F)(t.x,e.x))),c=0,h[c++]=m[0].x;for(let t=1,e=m.length;t<e;t++)m[t].x!==h[c-1]&&c<a&&(h[c++]=m[t].x)}return c}function sr(t,e,s,i,r,o,a){const h=(0,n.m)(n.P,4);return t.queryControlPoints(h),er(h,e,s,i,r,o,a)}function ir(t,e){e[0].set(0);let s=1;const r=(0,n.m)(n.H,4);Cn(t,r,!0);const o=(0,n.m)(n.H,4);vn(t,o,!0);{const t=r[3].mul(3),i=r[2].mul(2),o=r[1].clone(),a=(0,n.m)(n.H,2);let h=Ze(t,i,o,new n.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.a1)(a[t].value(),0,1)||(e[s]=a[t],s++)}{const t=o[3].mul(3),i=o[2].mul(2),r=o[1].clone(),a=(0,n.m)(n.H,2);let h=Ze(t,i,r,new n.E(0,1),!1,a);h<0&&(h=0);for(let t=0;t<h;t++)(0,n.a1)(a[t].value(),0,1)||(e[s]=a[t],s++)}if(s+=function(t,e,s){const i=t[1].mulE(e[2]).subThisE(t[2].mulE(e[1])),r=t[1].mulE(e[3]).subThisE(t[3].mulE(e[1])).mulThis(3),o=t[2].mulE(e[3]).subThisE(t[3].mulE(e[2])).mulThis(3),a=(0,n.m)(n.H,2);let h=Ze(o,r,i,new n.E(0,1),!1,a);h<0&&(h=0);let m=0;for(let t=0;t<h;t++)(0,n.a1)(a[t].value(),0,1)||(s[m].setE(a[t]),m++);return m}(r,o,e.slice(s)),e[s].set(1),s++,s>2){(0,n.W)(e,0,s,((t,e)=>{const s=t.value(),i=e.value();return s<i?-1:s>i?1:0}));let i=0;const r=e[0].clone();let o=0;const a=function(t){return t[0].norm(1)+t[1].norm(1)+t[2].norm(1)+t[3].norm(1)}(t)*(0,n.aa)(),h=new n.P;Rn(t,e[0].value(),h);for(let m=1;m<s;m++){const s=new n.P;if(Rn(t,e[m].value(),s),e[m].eq(r)||s.isEqualPoint2D(h,a)){if(0!==i){if(0===e[m].eps())r.setE(e[m]),o=0;else if(0!==o){const t=(0,n.e)(1/e[m].eps()),s=1/o,i=t+s;r.set((e[m].value()*t+r.value()*s)/i),o=1/i,r.setError(Math.sqrt(o))}e[i].setE(r),Rn(t,r.value(),h)}}else i++,e[i].setE(e[m]),r.setE(e[m]),Rn(t,r.value(),h),o=(0,n.e)(e[m].eps())}i++,s=i}return 1===s&&(s=2,e[1].set(1)),(0,i.g)(0===e[0].value()),(0,i.g)(1===e[s-1].value()),s}function nr(t,e,s){s.setEmpty();const i=[];i.push(new n.E(0,1));const r=.5*Math.max(e.width(),e.height());for(;i.length;){const o=i.at(-1);i.pop();const a=new Ht;if($n(t,o,a),a.isIntersectingW(e)){const t=Math.max(a.width(),a.height());if(e.containsW(a)||t<=r||o.width()<1e-12)s.merge(o);else{const t=o.getCenter();i.push(n.E.construct(o.vmin,t)),i.push(n.E.construct(t,o.vmax))}}}}class rr{constructor(t,e){this.b=t,this.len=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?this.len-Sn(this.b,e,!1):0}getError(t){return 0}}function or(t,e,s,r,o,a,h){for(;;){const m=n.P.distance(e[0],e[3]),l=n.P.distance(e[0],e[1])+n.P.distance(e[1],e[2])+n.P.distance(e[2],e[3]);if(l-m<=r+s*l)return t+(0,n.w)(m,l,.5);const u=t=>Mn(e,1,t).length();if(0===a){(0,i.g)(h<8);let m=u(0),c=u(1);o[0]+=2,m>c&&(c=(0,n.b)(m,m=c),e[3]=(0,n.b)(e[0],e[0]=e[3]),e[2]=(0,n.b)(e[1],e[1]=e[2]));let g=m/(m+c),_=1,d=l;for(;g<1/32&&d>=32*(r+s*d);){_/=4;const t=u(_);o[0]++,g=m/(t+m);const s=new n.P;if(kn(e,.5*_,s),d=n.P.distance(s,e[0]),d<=r){const t=new n.P;kn(e,_,t),d+=n.P.distance(t,s)}}if(1!==_){const i=(0,n.m)(n.P,4);Yn(e,_,e,i),t=or(t,i,s,r,o,0,h+1),a++,h++;continue}}const c=8;o[0]+=c;const g=Fs(c,u,0,1),_=16;o[0]+=_;const d=Fs(_,u,0,1);let p=Math.abs(g-d)>r+s*l;if(!p)return t+d;if(a<3){const i=(0,n.m)(n.P,4);Yn(e,.5,e,i),t=or(t,i,s,r,o,a+1,h+1),a++,h++;continue}const f=32;o[0]+=f;const x=Fs(f,u,0,1);if(p=Math.abs(d-x)>r+s*l,!p)return t+x;const y=64;o[0]+=y;const P=Fs(y,u,0,1);if(p=Math.abs(x-P)>r+s*l,!p)return t+P;const E=128;o[0]+=E;const C=Fs(E,u,0,1);return p=Math.abs(P-C)>r+s*l,t+C}}function ar(t,e,s,i,r){if(s===e)return 0;const o=(0,n.m)(n.P,4);t.queryControlPoints(o);const a=(0,n.m)(n.P,4);return Xn(o,e,s,a),or(0,a,i,r,[0],0,0)}function hr(t,e,s,i,r){let o=!0;const a=Vs(5,e,s,i,r,(e=>{const s=Gn(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));o=!1;const h=Vs(5,e,s,i,r,(e=>{const s=Gn(t,1,e);return(o?t.getCoordX(e)-t.getStartX():t.getCoordY(e)-t.getStartY())*s.length()}));return new n.P(a,h)}function mr(t,e,s,i,r,o,a,h,m,l,u,c){let g=0,_=0,d=0,p=0,f=0,x=0,y=0;for(let e=1,a=c-1;e<a;e++){let a,h,l,c,P,E,C=-1,v=m[e-1];t&&(e>2?(v=(0,n.l)(2*m[e-2]-m[e-3],0,1),m[e-1]=v):2===e&&v<=m[0]&&(v=m[0]));for(let g=0;g<11&&(a=m[e-1],h=a*a,l=h*a,c=1-a,P=c*c,E=P*c,t)&&!(Math.abs(a-C)<1e-12)&&10!==g;g++){const t=s.x-2*i.x+r.x,l=s.x-3*i.x+3*r.x-o.x,c=s.y-2*i.y+r.y,g=s.y-3*i.y+3*r.y-o.y,_=s.x-i.x-2*t*a+l*h,d=-u[e].x+s.x*E+a*(3*i.x*P+a*(3*r.x-3*r.x*a+o.x*a)),p=s.y-i.y-2*c*a+g*h,f=-u[e].y+s.y*E+a*(3*i.y*P+a*(3*r.y-3*r.y*a+o.y*a));C=a;const x=a- -6*(_*d+p*f)/(6*(3*(0,n.e)(_)-(-2*t+2*l*a)*d)+6*(3*(0,n.e)(p)-(-2*c+2*g*a)*f));m[e-1]=(0,n.l)(x,e>1?m[e-2]:0,1)}g+=3*h*P*P,_+=3*l*E,d+=3*h*h*P;const b=-(E*s.x+l*o.x-u[e].x);p+=b*a*P,f+=b*h*c;const S=-(E*s.y+l*o.y-u[e].y);x+=S*a*P,y+=S*h*c}if(e){const t=g*d-_*_;Math.abs(t)>=1e-12*(Math.abs(g*d)+Math.abs(_*_))+1e-10?(a||(i.x=(p*d-f*_)/t,i.y=(x*d-y*_)/t),h||(r.x=(g*f-_*p)/t,r.y=(g*y-_*x)/t)):((0,n.B)(s,o,.3,i),(0,n.B)(s,o,.6,r))}let P=0;for(let t=1,e=c-1;t<e;t++){const e=m[t-1],a=1-e,h=s.mul((0,n.am)(a)),l=i.mul(3*e*a*a),c=r.mul(3*e*e*a),g=o.mul((0,n.am)(e));P+=h.add(l).add(c).add(g).sub(u[t]).sqrLength()}return P}function lr(t,e,s,i){const r=t.getPathStart(e),o=t.getPathEnd(e);if(o-r<3)return;const a=2*r,h=n.P.getNAN();s.queryPoint2D(a,h);const m=h.x,l=h.y,u=n.P.getNAN();s.queryPoint2D(a+2,u);const c=n.P.getNAN();for(let t=a+4,e=2*o;t<e;t+=2)s.queryPoint2D(t,c),i.pe((c.x-h.x)*(u.y-l)),h.setCoordsPoint2D(u),u.setCoordsPoint2D(c);i.pe((m-h.x)*(u.y-l))}function ur(t,e,s){for(;e.hasNextSegment();){const t=e.nextCurve();if(null===t)break;s.pe(2*t.calculateArea2DHelper())}}var cr=g;class gr{static toSegType(t){let e=0;switch(t){case i.G.enumLine:e=1;break;case i.G.enumBezier:e=2;break;case i.G.enumEllipticArc:e=4;break;case i.G.enumRationalBezier2:e=8;break;case i.G.enumBezier2:e=16;break;default:(0,i.b)("")}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 _r extends Xt{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.m_curveData=null,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?i.G.enumPolygon:i.G.enumPolyline}getDimension(){return this.m_bPolygon?2:1}changeRingStartPoint(t){(0,i.g)(this.m_bPolygon);const e=this.getPathIndexFromPointIndex(t),s=this.getPathStart(e);if(s===t)return;const n=this.getPathEnd(e);(t>=n||t<s)&&(0,i.t)("change_ring_start_point");for(let e=0,i=this.m_description.getAttributeCount();e<i;e++){const i=this.m_description.getSemantics(e),r=cr.getComponentCount(i);this.m_vertexAttributes.get(e).rotate(s*r,t*r,n*r)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.rotate(s,t,n),this.m_curveData.m_segmentParamIndex.rotate(s,t,n))}setFillRule(t){this.m_bFillRule=1===t}getFillRule(){return this.m_bFillRule?1:0}isExteriorRingOGC(t){return!!this.m_bPolygon&&(this.updateOGCFlagsProtected(),!!(8&this.m_pathFlags.read(t)))}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 D(t),s=new n.K(0),i=new n.K(0);if(0!==this.m_pointCount){const n=this.getAttributeStreamRef(0);if(this.hasNonLinearSegments()){const t=new qe({parent:this});for(t.stripAttributes();t.nextPath();){i.reset();const r=t.getPathIndex();lr(this,r,n,i),ur(0,t,i);const o=.5*i.getResult();s.add(o),e.write(r,o)}}else for(let r=0;r<t;r++){i.reset(),lr(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(){if(!this.m_bPolygon)return 0;this.updateOGCFlagsProtected();let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)8&this.m_pathFlags.read(s)&&t++;return t}getHashCodeImpl(){return(0,i.g)(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(!_r.isNonLinearSegmentFlag(s))continue;const i=this.m_curveData.m_segmentParamIndex.read(t),r=e.m_curveData.m_segmentParamIndex.read(t),o=ke(s);for(let t=0;t<o;t++){const s=this.m_curveData.m_segmentParams.read(i+t),o=e.m_curveData.m_segmentParams.read(r+t);if(!(0,n.Q)(s,o))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=E(1,0),this.m_pathFlags=C(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 gr),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 n.K(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(t){const e=this.querySegmentIteratorAtVertex(this.getPathStart(t)),s=new n.K(0);for(;e.hasNextSegment();)s.add(e.nextSegment().calculateLength2D());return s.getResult()}calculateLength3D(t){return(0,i.g)(0),0}calculatePathLength3D(t,e){return(0,i.g)(0),0}copyTo(t){(0,i.f)(t.getGeometryType())||(0,i.t)(""),this!==t&&super.copyTo(t)}swap(t){(0,i.g)(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&&(0,i.t)("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,n,r){if(this===t&&(0,i.t)("Multi_path_impl.add_segments_from_path"),r||0!==this.getPathCount()||(r=!0),e<0&&(e=t.getPathCount()-1),(e>=t.getPathCount()||s<0||n<0||s+n>t.getSegmentCountPath(e))&&(0,i.w)("add_segments_from_path"),0===n)return;const o=t.getPathStart(e),a=t.isClosedPath(e)&&s+n===t.getSegmentCountPath(e);this.m_bPathStarted=!1,this.mergeVertexDescription(t.getDescription());let h=n;const m=o+s;let l=m+1;r&&(h++,l--),!r&&t.hasNonLinearSegments()&&1!==t.m_curveData.m_segmentFlags.read(m)&&(t.getXY(m).equals(this.getXY(this.m_pointCount-1))||(0,i.t)("add_segments_from_path: start point mismatch"));const u=this.m_pointCount;if(this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange(),r){if(0===h)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 c=a?h-1:h;for(let e=0,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e),i=cr.getComponentCount(s),n=t.m_description.getAttributeIndex(s);if(c>0){if(n<0||!t.m_vertexAttributes.get(n)){const t=cr.getDefaultValue(s);this.m_vertexAttributes.get(e).insertRange(i*u,t,c*i,i*u),a&&this.m_vertexAttributes.get(e).insertRange(i*u+c*i,t,i,i*u);continue}this.m_vertexAttributes.get(e).insertRangeFromStream(i*u,t.m_vertexAttributes.get(n),i*l,c*i,!0,i,i*u)}a&&this.m_vertexAttributes.get(e).insertRangeFromStream(i*(u+c),t.m_vertexAttributes.get(n),i*o,i,!0,i,i*(u+c))}if(this.hasNonLinearSegments()&&this.initSegmentData(0),t.hasNonLinearSegments()){let e=0;for(let s=0,i=m;s<n;s++)e+=ke(t.m_curveData.m_segmentFlags.read(i)),i++;if(e>0){this.initSegmentData(e);let s=m,i=u-(r?0:1),o=0;for(let e=0;e<n;e++){const e=t.m_curveData.m_segmentFlags.read(s);if(this.m_curveData.m_segmentFlags.write(i,e),_r.isNonLinearSegmentFlag(e)){o++;let n=t.m_curveData.m_segmentParamIndex.read(s);const r=ke(e);this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);for(let e=0;e<r;e++){const e=t.m_curveData.m_segmentParams.read(n);this.m_curveData.m_segmentParams.write(this.m_curveData.m_curveParamWritePoint,e),this.m_curveData.m_curveParamWritePoint++,n++}this.incCurveType(e,1)}else this.m_curveData.m_segmentParamIndex.write(i,-1);i++,s++}this.modifyCurveCounter(o)}}if(a){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()&&(0,i.t)("");const e=this.getPathSize(t);if(0===e)return;const s=this.getPathStart(t),n=this.isClosedPath(t);if(this.hasNonLinearSegments()){let t=s;const i=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(!_r.isNonLinearSegmentFlag(e))continue;r=!0,this.querySegment(t,i,!0),i.get().reverse();const s=this.m_curveData.m_segmentParamIndex.read(t);i.get().writeInBufferStream(this.m_curveData.m_segmentParams,s)}if(r){const t=n?0:1;this.m_curveData.m_segmentFlags.reverseRange(s,e-t,1),this.m_curveData.m_segmentParamIndex.reverseRange(s,e-t,1)}}const r=n?1:0;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++)if(this.m_vertexAttributes.get(t)){const i=this.m_description.getSemantics(t),n=cr.getComponentCount(i);this.m_vertexAttributes.get(t).reverseRange(n*(s+r),n*(e-r),n)}const o=6&this.m_pathFlags.read(t);if(o){let e=0;4&o&&(e|=2),2&o&&(e|=4),this.m_pathFlags.clearBits(t,6),this.m_pathFlags.setBits(t,e)}this.notifyModifiedFlags(1233)}removePath(t){const e=this.getPathCount();t<0&&(t=e-1),t>=e&&(0,i.t)("");const s=this.getPathStart(t),n=this.getPathSize(t);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),i=cr.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(i*s,i*n,i*this.m_pointCount)}if(this.hasNonLinearSegments()){let t=0;for(let e=s,i=s+n;e<i;e++){const s=this.m_curveData.m_segmentFlags.read(e);_r.isNonLinearSegmentFlag(s)&&(this.incCurveType(s,-1),t++)}this.modifyCurveCounter(-t),this.m_curveData.m_segmentFlags.eraseRange(s,n,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(s,n,this.m_pointCount)}for(let s=t+1;s<=e;s++){const t=this.m_paths.read(s);this.m_paths.write(s-1,t-n)}if(this.m_pathFlags)for(let s=t+1;s<=e;s++){const t=this.m_pathFlags.read(s);this.m_pathFlags.write(s-1,t)}this.m_paths.resize(e),this.m_pathFlags.resize(e),this.m_pointCount-=n,this.m_reservedPointCount-=n,t===e-1&&(this.m_bPathStarted=!1),this.notifyModifiedFlags(2001),this.checkCompactSegmentParams(),this.dbgVerifyCurves()}dbgVerifyCurves(){}insertPath(t,e,s,n){this===e&&(0,i.t)("Multi_path_impl::insert_path");const r=this.getPathCount();if(!n&&e.hasNonLinearSegmentsPath(s))return t=this.insertPath(t,e,s,!0),this.reversePath(t),t;s>=e.getPathCount()&&(0,i.t)(""),t>r&&(0,i.t)(""),t<0&&(t=r),s<0&&(s=e.getPathCount()-1),this.m_bPathStarted=!1,this.mergeVertexDescription(e.getDescription());const o=e.getPathStart(s),a=e.getPathSize(s);if(0===a)return this.insertPath2D(t,null,0,0,!0);const h=this.m_pointCount,m=e.isClosedPath(s)&&!n?1:0;this.resizeImpl(this.m_pointCount+a),this.verifyAllStreamsAfterSizeChange();const l=t<r?this.getPathStart(t):h;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=e.getDescription().getAttributeIndex(s),r=cr.getComponentCount(s);if(i>=0&&e.m_vertexAttributes.get(i))0!==m&&this.m_vertexAttributes.get(t).insertRangeFromStream(l*r,e.m_vertexAttributes.get(i),r*o,r,!0,r,r*h),this.m_vertexAttributes.get(t).insertRangeFromStream((l+m)*r,e.m_vertexAttributes.get(i),r*(o+m),r*(a-m),n,r,r*(h+m));else{const e=cr.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(l*r,e,r*a,r*h)}}const u=h+a;this.m_paths.add(u);for(let e=r;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+a)}this.m_pathFlags.add(0);for(let e=r-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let c=e.getPathFlagsStreamRef().read(s);if(c&=-9,this.m_bPolygon&&(c|=1),this.m_pathFlags.write(t,c),e.hasNonLinearSegments()){this.initSegmentData(0);let t=o,s=0;for(let i=0;i<a;i++)s+=ke(e.m_curveData.m_segmentFlags.read(t)),t++;if(s>0){null===this.m_curveData.m_segmentFlags?(this.m_curveData.m_segmentFlags=C(this.m_pointCount,1),this.m_curveData.m_segmentParamIndex=E(this.m_pointCount,-1)):(this.m_curveData.m_segmentFlags.insertRange(l,1,a,h),this.m_curveData.m_segmentParamIndex.insertRange(l,-1,a,h)),this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams.resize(this.m_curveData.m_curveParamWritePoint+s):this.m_curveData.m_segmentParams=v(s),t=o;let i=l,n=0;for(let s=0;s<a;s++){const s=e.m_curveData.m_segmentFlags.read(t);if(_r.isNonLinearSegmentFlag(s)){this.m_curveData.m_segmentFlags.write(i,s),this.m_curveData.m_segmentParamIndex.write(i,this.m_curveData.m_curveParamWritePoint);const r=ke(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,n,r){const o=this.getPathCount();(t>o||s<0)&&(0,i.t)(""),t<0&&(t=o),this.m_bPathStarted=!1;const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+n),0===n&&this.notifyModifiedFlags(32),this.verifyAllStreamsAfterSizeChange();const h=t<o?this.getPathStart(t):a;if(e)this.m_vertexAttributes.get(0).insertRangeFromPoints(2*h,e,s,n,r,2*a);else{const t=cr.getDefaultValue(0);this.m_vertexAttributes.get(0).insertRange(2*h,t,2*n,2*a)}for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=cr.getComponentCount(e),i=cr.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(h*s,i,s*n,s*a)}this.m_paths.add(this.m_pointCount);for(let e=o;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+n)}this.m_pathFlags.add(0);for(let e=o-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}return this.m_bPolygon&&this.m_pathFlags.write(t,1),this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h,1,n,a),this.m_curveData.m_segmentParamIndex.insertRange(h,-1,n,a)),this.notifyModifiedFlags(2001),t}insertPathFromMultipoint(t,e,s,n,r){const o=e.getImpl(),a=this.getPathCount();(t>a||s<0)&&(0,i.t)("");const h=n<0?o.getPointCount()-s:n;if(h>o.getPointCount()&&(0,i.t)(""),s>=o.getPointCount()&&(0,i.t)("pointsOffset"),t<0&&(t=a),this.m_bPathStarted=!1,this.mergeVertexDescription(o.getDescription()),0===h)return void this.insertPath2D(t,null,0,0,!0);const m=this.m_pointCount,l=s;this.resizeImpl(this.m_pointCount+h),this.verifyAllStreamsAfterSizeChange();const u=t<a?this.getPathStart(t):m;for(let t=0,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=o.getDescription().getAttributeIndex(e),i=cr.getComponentCount(e);if(s>=0){const s=o.getAttributeStreamRef(e);this.m_vertexAttributes.get(t).insertRangeFromStream(u*i,s,i*l,i*h,r,i,i*m)}else{const s=cr.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(u*i,s,i*h,i*m)}}const c=m+h;this.m_paths.add(c);for(let e=a;e>=t+1;e--){const t=this.m_paths.read(e-1);this.m_paths.write(e,t+h)}this.m_pathFlags.add(0);for(let e=a-1;e>=t+1;e--){let t=this.m_pathFlags.read(e);t&=-9,this.m_pathFlags.write(e+1,t)}let g=0;this.m_bPolygon&&(g|=1),this.m_pathFlags.write(t,g),this.notifyModifiedFlags(2001)}insertPoints(t,e,s,n,r,o,a){if(this===s&&(0,i.t)("Multi_path_impl.insert_points"),t<0&&(t=this.getPathCount()),n<0&&(n=s.getPathCount()-1),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||n>=s.getPathCount()||o>s.getPathSize(n))&&(0,i.w)(""),!o)return;if(this.mergeVertexDescription(s.m_description),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);let t=s.m_pathFlags.read(n);t&=-9,this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+o),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+e;o<0&&(o=s.getPathSize(n));const u=s.getPathStart(n),c=u+o;for(let t=0,i=this.m_description.getAttributeCount();t<i;t++){const i=this.m_description.getSemantics(t),n=cr.getComponentCount(i),g=s.m_description.getAttributeIndex(i);if(g<0||!s.m_vertexAttributes.get(g)){const e=cr.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*l,e,c*n,n*h)}else this.m_vertexAttributes.get(t)?.insertRangeFromStream(n*(m+e),s.m_vertexAttributes.get(g),n*(u+r),o*n,a,n,n*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,o,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,o,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+o)}this.notifyModifiedFlags(2001)}insertPointsFromPoints(t,e,s,n,r,o){if(t<0&&(t=this.getPathCount()),(t>this.getPathCount()||e>this.getPathSize(t)||n<0)&&(0,i.w)(""),!r)return;t===this.getPathCount()&&(this.m_paths.add(this.m_pointCount),this.m_bPolygon?this.m_pathFlags.add(1):this.m_pathFlags.add(0)),e<0&&(e=this.getPathSize(t));const a=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const h=this.getPathStart(t);this.m_vertexAttributes.get(0).insertRangeFromPoints(2*(h+e),s,n,r,o,2*a);for(let t=1,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=cr.getComponentCount(s),n=cr.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange((h+e)*i,n,i*r,i*a)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(h+e,1,r,a),this.m_curveData.m_segmentParamIndex.insertRange(h+e,-1,r,a),e>0&&this.isNonLinearSegment(h+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(h+e-1),-1),this.m_curveData.m_segmentFlags.write(h+e-1,1),this.m_curveData.m_segmentParamIndex.write(h+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+r);this.notifyModifiedFlags(2001)}insertPointsFromMultipoint(t,e,s,n,r,o){const a=s.getImpl();if(t<0&&(t=this.getPathCount()),r<0&&(r=s.getPointCount()),(t>this.getPathCount()||e>=0&&e>this.getPathSize(t)||r>s.getPointCount())&&(0,i.w)(""),!r)return;if(this.mergeVertexDescription(a.getDescription()),t===this.getPathCount()){this.m_paths.add(this.m_pointCount);const t=0;this.m_bPolygon?this.m_pathFlags.add(1|t):this.m_pathFlags.add(t)}e<0&&(e=this.getPathSize(t));const h=this.m_pointCount;this.resizeImpl(this.m_pointCount+r),this.verifyAllStreamsAfterSizeChange();const m=this.getPathStart(t),l=m+e,u=0+r;for(let t=0,s=this.m_description.getAttributeCount();t<s;t++){const s=this.m_description.getSemantics(t),i=cr.getComponentCount(s);if(a.getDescription().getAttributeIndex(s)<0){const e=cr.getDefaultValue(s);this.m_vertexAttributes.get(t).insertRange(i*l,e,u*i,i*h);continue}const c=a.getAttributeStreamRef(s);this.m_vertexAttributes.get(t).insertRangeFromStream(i*(m+e),c,i*(0+n),r*i,o,i,i*h)}this.hasNonLinearSegments()&&(this.m_curveData.m_segmentFlags.insertRange(m+e,1,r,h),this.m_curveData.m_segmentParamIndex.insertRange(m+e,-1,r,h),e>0&&this.isNonLinearSegment(m+e-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(m+e-1),-1),this.m_curveData.m_segmentFlags.write(m+e-1,1),this.m_curveData.m_segmentParamIndex.write(m+e-1,-1),this.modifyCurveCounter(-1)));for(let e=t+1,s=this.getPathCount();e<=s;e++){const t=this.m_paths.read(e);this.m_paths.write(e,t+r)}this.notifyModifiedFlags(2001)}insertPoint2D(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.w)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o,h=this.m_vertexAttributes.get(0);if(a===r)this.m_paths.write(t+1,r+1),h.writePoint2D(2*a,s);else{h.insert(2*a,s,2*r);for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=cr.getComponentCount(e),i=cr.getDefaultValue(e);this.m_vertexAttributes.get(t).insertRange(s*a,i,s,s*r)}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}insertPoint(t,e,s){const n=this.getPathCount();t<0&&(t=n),(t>n||t<n&&e>this.getPathSize(t))&&(0,i.w)(""),t===n&&this.addPathPoint2D(null,0,!0);const r=this.m_pointCount;this.resizeImpl(this.m_pointCount+1),this.verifyAllStreamsAfterSizeChange();const o=this.getPathStart(t),a=e<0?this.getPathSize(t)+o:e+o;if(a===r)this.m_paths.write(t+1,r+1),this.setPointByVal(a,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),n=cr.getComponentCount(i);if(e.hasAttribute(i))this.m_vertexAttributes.get(t).insertAttributes(n*a,s,i,n*r);else{const e=cr.getDefaultValue(i);this.m_vertexAttributes.get(t).insertRange(n*a,e,n,n*r)}}this.m_curveData&&this.m_curveData.m_segmentFlags&&(this.m_curveData.m_segmentFlags.insertRange(a,1,1,r),this.m_curveData.m_segmentParamIndex.insertRange(a,-1,1,r));for(let e=t+1,s=n;e<=s;e++)this.m_paths.write(e,this.m_paths.read(e)+1)}this.m_curveData&&this.m_curveData.m_segmentFlags&&a>o&&this.isNonLinearSegment(a-1)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(a-1),-1),this.modifyCurveCounter(-1),this.m_curveData.m_segmentFlags.write(a-1,1),this.m_curveData.m_segmentParamIndex.write(a-1,-1)),this.notifyModifiedFlags(2001)}removePointFromPath(t,e){const s=this.getPathCount();t<0&&(t=s-1),(t>=s||e>=this.getPathSize(t))&&(0,i.w)("Multi_path.remove_point");const n=this.getPathStart(t),r=this.isClosedPath(t);e<0&&(e=this.getPathSize(t)-1),e<0&&(0,i.w)("Multi_path.remove_point");const o=n+e;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),s=cr.getComponentCount(e);this.m_vertexAttributes.get(t).eraseRange(s*o,s,s*this.m_pointCount)}if(this.m_curveData&&this.m_curveData.m_segmentFlags){this.checkCompactSegmentParams();let e=0;if(o>n&&this.isNonLinearSegment(o-1))e+=1,this.incCurveType(this.m_curveData.m_segmentFlags.read(o-1),-1),this.m_curveData.m_segmentFlags.write(o-1,1),this.m_curveData.m_segmentParamIndex.write(o-1,-1);else{const s=this.getPathEnd(t);r&&n+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(o)&&(this.incCurveType(this.m_curveData.m_segmentFlags.read(o),-1),e+=1),e>0&&this.modifyCurveCounter(-e),this.m_curveData.m_segmentFlags.eraseRange(o,1,this.m_pointCount),this.m_curveData.m_segmentParamIndex.eraseRange(o,1,this.m_pointCount)}for(let e=s;e>=t+1;e--){const t=this.m_paths.read(e);this.m_paths.write(e,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++)_r.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=_r.getPathIndexFromPointIndexImpl(this.m_paths,s,t,e);return this.m_currentPathIndex=i,i}startPathCoords(t,e){this.startPathPoint(new Nt({x:t,y:e}))}startPath(t){this.startPathPoint(new Nt({pt:t}))}startPath3D(t){this.startPathPoint(new Nt({x:t.x,y:t.y,z:t.z}))}startPath3DCoords(t,e,s){this.startPathPoint(new Nt({x:t,y:e,z:s}))}startPathPoint(t){t.isEmpty()&&(0,i.t)("");const e=t.getDescription();let s;if(this.m_description!==e){this.mergeVertexDescription(e);const i=new Nt({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=E(2),this.m_paths.write(0,0),this.m_pathFlags=C(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=c(),i=new Nt({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=G(this.m_description,R()),s=c(),i=new Nt({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 _(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=c(),s=new Nt({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&&(0,i.b)("");const e=this.getPathCount();if(t>e&&(0,i.t)(""),!this.isClosedPath(t))return;this.m_pathFlags||(0,i.b)("");const s=this.m_pointCount,n=this.getPathStart(t),r=this.getPathEnd(t);if(r-n!=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),i=cr.getComponentCount(e);this.m_vertexAttributes.get(t).insertRangeFromStream(i*r,this.m_vertexAttributes.get(t),i*n,i,!0,1,i*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(r,1,1,s),this.m_curveData.m_segmentParamIndex.insertRange(r,-1,1,s)),this.m_pathFlags.clearBits(t,1)}}openPath(t){this.m_bPolygon&&(0,i.b)(""),t>this.getPathCount()&&(0,i.t)(""),this.m_pathFlags||(0,i.b)(""),this.m_pathFlags.clearBits(t,1)}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&&(0,i.b)(""),this.isEmpty())return;this.m_pathFlags||(0,i.b)("");let t=0;const e=this.getPathCount();for(let s=0;s<e;s++)this.isClosedPath(s)&&(this.getPathSize(s)>0?t++:this.m_pathFlags.clearBits(s,1));if(0===t)return;const s=this.hasNonLinearSegments();let n=0;const r=this.getPathCount(),o=this.m_description.getAttributeCount(),a=new Array(o);let h=null,m=null;for(let e=0;e<r;++e){const i=this.getPathStart(e),r=this.getPathSize(e),l=this.isClosedPath(e);if(r>0){const e=i+n;for(let s=0;s<o;s++)if(this.m_vertexAttributes.get(s)){const n=this.m_description.getSemantics(s),o=cr.getComponentCount(n);if(!a[s]){const e=P(n,o*(this.m_pointCount+t));a[s]=e}a[s].writeRange(e*o,r*o,this.m_vertexAttributes.get(s),i*o,!0,1),l&&a[s].writeRange((e+r)*o,o,this.m_vertexAttributes.get(s),i*o,!0,1)}if(s){if(null===h){const e=this.m_pointCount+t;h=C(e),m=E(e)}h.writeRange(e,r,this.m_curveData.m_segmentFlags,i,!0,1),m.writeRange(e,r,this.m_curveData.m_segmentParamIndex,i,!0,1),l&&(h.write(e+r,1),m.write(e+r,-1))}}this.m_paths.write(e,i+n),l&&(this.m_pathFlags.clearBits(e,1),++n)}this.m_paths.write(r,this.m_pointCount+t),this.m_pathFlags.clearBits(r,1);for(let t=0;t<o;t++)this.m_vertexAttributes.get(t)&&this.m_vertexAttributes.set(t,a[t]);s&&(this.m_curveData.m_segmentFlags=h,this.m_curveData.m_segmentParamIndex=m),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())&&(0,i.t)("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())&&(0,i.t)("close_path_with_line"),e.getEndXY().equals(this.getXY(this.getPathStart(t)))||(0,i.t)("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(),n=this.getPathEnd(t)-1;s.equals(this.getXY(n))||(0,i.t)("close_path_with_segment: start point mismatch");const r=e.getGeometryType();if(r===i.G.enumLine)return void this.closePathWithLine(t);{const t=Xe(e);this.initSegmentData(t);const s=gr.toSegType(r),i=this.m_curveData.m_segmentFlags.read(n);if(i!==s)this.m_curveData.m_segmentParamIndex.write(n,this.m_curveData.m_curveParamWritePoint),e.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=t,this.incCurveType(s,1),1!==i?this.incCurveType(i,-1):this.modifyCurveCounter(1);else{const t=this.m_curveData.m_segmentParamIndex.read(n);e.writeInBufferStream(this.m_curveData.m_segmentParams,t)}this.m_curveData.m_segmentFlags.write(n,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(t){return(0,i.g)(0),!1}hasNonLinearSegmentsPath(t){if(!this.hasNonLinearSegments())return!1;for(let e=this.getPathStart(t),s=this.getPathEnd(t);e<s;e++)if(_r.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 o)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=c(),n=new Nt({vd:s,attribBuffer:i,initDefaultValues:!1});for(let s=0,i=4;s<i;s++){const r=e?i-s-1:s;t.queryCornerByVal(r,n),0===s?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()||(0,i.t)("add_path_from_closedSegment: segment must be closed"),e){const e=t.getReversed(),s=new Nt;e.queryStart(s),this.startPathPoint(s),this.closeLastPathWithSegment(e)}else{const e=new Nt;t.queryStart(e),this.startPathPoint(e),this.closeLastPathWithSegment(t)}}addSegment_(t,e){const s=t.getDescription();this.mergeVertexDescription(s);const n=c(),r=new Nt({vd:s,attribBuffer:n,initDefaultValues:!1}),o=t.getGeometryType();if(o===i.G.enumLine)(e||this.isEmptyImpl())&&(t.queryStart(r),this.startPathPoint(r)),t.queryEnd(r),this.lineToPoint(r);else{let s=!1;if((e||this.isEmptyImpl())&&(s=!0),s||t.getStartXY().equals(this.getXY(this.m_pointCount-1))||(0,i.t)("add_segment: start point mismatch"),s&&(t.queryStart(r),this.startPathPoint(r)),this.beforeNewSegment(1),t.queryEnd(r),r.getDescription()===this.m_description)this.setPointByVal(this.m_pointCount-1,r);else{const t=c(),e=new Nt({vd:this.m_description,attribBuffer:t,initDefaultValues:!1});r.copyCommonAttributesTo(e),this.setPointByVal(this.m_pointCount-1,e)}const n=Xe(t);this.initSegmentData(n),this.m_curveData.m_segmentParamIndex.write(this.m_pointCount-2,this.m_curveData.m_curveParamWritePoint),t.writeInBufferStream(this.m_curveData.m_segmentParams,this.m_curveData.m_curveParamWritePoint),this.m_curveData.m_curveParamWritePoint+=n;const a=gr.toSegType(o);this.incCurveType(a,1),this.modifyCurveCounter(1),this.m_curveData.m_segmentFlags.write(this.m_pointCount-2,a)}}addSegment(t,e,s){s?e?this.addPathFromClosedSegment(t,!1):this.closeLastPathWithSegment(t):this.addSegment_(t,e)}interpolateAttributesRange(t,e,s,n){for(let e=t;e<s-1;e++)this.isClosedPath(e)&&(0,i.t)("cannot interpolate across closed paths");const r=this.m_description.getAttributeCount();if(1===r)return;const o=this.calculateSubLength2D(t,e,s,n);if(0!==o)for(let i=1;i<r;i++){const r=this.m_description.getSemantics(i);this.interpolateAttributesSemanticsImpl(r,t,e,s,n,o)}}interpolateAttributesSemantics(t,e,s,n,r){if(0===t)return;this.hasAttribute(t)||(0,i.t)("does not have the given attribute"),2===cr.getInterpolation(t)&&(0,i.t)("angular interpolation");for(let t=e;t<n-1;t++)this.isClosedPath(t)&&(0,i.t)("cannot interpolate across closed paths");const o=this.calculateSubLength2D(e,s,n,r);0!==o&&this.interpolateAttributesSemanticsImpl(t,e,s,n,r,o)}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(t,e,s,n){if(0===t)return;this.hasAttribute(t)||(0,i.t)("does not have the given attribute"),2===cr.getInterpolation(t)&&(0,i.t)("angular interpolation");const r=this.calculatePathSubLength2D(e,s,n);0!==r&&this.interpolateAttributesSemanticsPathImpl(t,e,s,n,r)}interpolateAttributesSemanticsImpl(t,e,s,i,r,o){const a=this.querySegmentIterator(),h=this.getPathStart(e)+s,m=this.getPathStart(i)+r,l=cr.getComponentCount(t),u=new Array(cr.maxComponentCount());this.queryAttributeAsDbl(t,h,u,l);const c=new Array(cr.maxComponentCount());this.queryAttributeAsDbl(t,m,c,l);const g=new Array(cr.maxComponentCount());(0,n.D)(g,u,0,0,l);let _=0;const d=cr.getDefaultValue(t),p=cr.getInterpolation(t);a.resetToVertex(h,e);do{if(a.hasNextSegment()){if(a.nextSegment(),a.getStartPointIndex()===m)return;this.setAttributeFromArray(t,a.getStartPointIndex(),g,l),a.previousSegment();do{const e=a.nextSegment();if(a.getEndPointIndex()===m)return;_+=e.calculateLength2D(),(0,n.U)(p,u,c,g,0,l,_/o,d),a.isClosingSegment()||this.setAttributeFromArray(t,a.getEndPointIndex(),g,l)}while(a.hasNextSegment())}}while(a.nextPath())}interpolateAttributesSemanticsPathImpl(t,e,s,i,r){const o=this.querySegmentIterator(),a=cr.getInterpolation(t),h=this.getPathStart(e)+s,m=this.getPathStart(e)+i;if(m===h)return;const l=cr.getComponentCount(t),u=new Array(cr.maxComponentCount());this.queryAttributeAsDbl(t,h,u,l);const c=new Array(cr.maxComponentCount());this.queryAttributeAsDbl(t,m,c,l);const g=new n.K(0);o.resetToVertex(h,e),o.setCirculator(this.isClosedPath(e));const _=cr.getDefaultValue(t),d=new Array(cr.maxComponentCount());(0,n.D)(d,u,0,0,l);const p=0===r;let f=.5;do{const e=o.nextSegment();if(this.setAttributeFromArray(t,o.getStartPointIndex(),d,l),!p){const t=e.calculateLength2D();g.pe(t),f=g.getResult()/r}(0,n.U)(a,u,c,d,0,l,f,_)}while(o.getEndPointIndex()!==m)}querySegment(t,e,s){const n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.t)("get_segment"),this.getSegmentFromPath(n,r,e,s)}getSegment(t,e){const s=new this.m_segmentBufferCTor;return this.getSegmentBuffer(t,s,e),s.releaseSegment()}getSegmentType(t){const e=this.getPathIndexFromPointIndex(t),s=t-this.getPathStart(e);return s>=this.getSegmentCountPath(e)&&(0,i.t)("get_segment"),this.getSegmentTypeFromPath(e,s)}getSegmentFromPath(t,e,s,n){const r=this.getPathStart(t)+e,o=this.getSegmentFlagsStreamRef();let a=1;switch(o&&(a=31&o.read(r)),a){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:(0,i.b)("")}const h=s.get();let m,l=null;if(n?(l=V(),h.assignVertexDescription(l)):h.assignVertexDescription(this.m_description),m=r===this.getPathEnd(t)-1&&this.isClosedPath(t)?this.getPathStart(t):r+1,ee(h,this.getXY(r)),ie(h,this.getXY(m)),!n)for(let t=1,e=this.m_description.getAttributeCount();t<e;t++){const e=this.m_description.getSemantics(t),s=cr.getComponentCount(e);for(let t=0;t<s;t++){const s=this.getAttributeAsDbl(e,r,t);h.setStartAttribute(e,t,s);const i=this.getAttributeAsDbl(e,m,t);h.setEndAttribute(e,t,i)}}if(_r.isNonLinearSegmentFlag(a)){const t=this.m_curveData.m_segmentParamIndex.read(r);h.readFromBufferStream(this.m_curveData.m_segmentParams,t)}}replaceLinearEllipticalArcsWithTrueLines(){if(!this.hasNonLinearSegments())return!1;if(0===this.m_curveData.m_arcCount)return!1;let t=!1;for(let e=0,s=this.getPointCount();e<s;e++)if(4===this.m_curveData.m_segmentFlags.read(e)){const s=this.m_curveData.m_segmentParamIndex.read(e);Ye(this.m_curveData.m_segmentParams,s).isNAN()&&(this.m_curveData.m_segmentFlags.write(e,1),this.m_curveData.m_segmentParamIndex.write(e,-1),this.incCurveType(4,-1),this.modifyCurveCounter(-1),t=!0)}return t&&this.checkCompactSegmentParams(),t}queryPointAlongPath(t,e,s,r=!1){const o={iSegment:-1},a=r?o:{iSegment:-1,tSegment:0};if(s.setEmpty(),this.isEmpty())return o;if((t<0||t>=this.getPathCount())&&(0,i.t)("query_point_along_path"),e<0)return o;const h=this.getPathSize(t);if(0===h)return o;if(1===h)return this.getPointByVal(this.getPathStart(t),s),a.tSegment=0,o.iSegment=this.getPathStart(t),o;const m=this.querySegmentIteratorAtVertex(this.getPathStart(t)),l=new n.K(0);for(;m.hasNextSegment();){const t=m.nextSegment(),i=t.calculateLength2D(),n=l.getResult();if(l.add(i),l.getResult()>=e){let r=e-n;r>i&&(r=i);const h=t.lengthToT(r);return t.queryCoord(h,s),a.tSegment=h,o.iSegment=m.getStartPointIndex(),o}}if(this.isClosedPath(t)){const e=this.getPathStart(t);return this.getPointByVal(e,s),a.tSegment=1,o.iSegment=this.getPathEnd(t)-1,o}{const e=this.getPathEnd(t)-1;return this.getPointByVal(e,s),this.getPathSize(t)>1?(a.tSegment=1,o.iSegment=this.getPathEnd(t)-2,o):(a.tSegment=0,o.iSegment=this.getPathStart(t),o)}}queryPointsAlongPath(t,e,s,r,o,a){{let t=0;for(let n=0;n<e;++n)r&&r[n].setEmpty(),o&&(o[n]=-1),a&&(a[n]=0),t>s[n]&&(0,i.t)("query_points_along"),t=s[n]}const h=this.getPathSize(t);if(0===e||0===h)return 0;if(1===h){const e=this.getPathStart(t);return r&&this.getPointByVal(e,r[0]),a&&(a[0]=0),o&&(o[0]=e),1}const m=this.getPathStart(t),l=new n.K(0),u=this.querySegmentIteratorAtVertex(m);let c=0,g=0,_=s[c];for(;u.hasNextSegment();){const t=u.nextSegment(),i=t.calculateLength2D(),n=l.getResult();for(l.add(i);l.getResult()>=_;){let h=_-n;h>i&&(h=i);const m=t.lengthToT(h);if(r&&t.queryCoord(m,r[g]),a&&(a[g]=m),o&&(o[g]=u.getStartPointIndex()),g++,c++,_=s[c],c===e)return g}}if(this.isClosedPath(t)){const e=this.getPathStart(t),s=0;r&&this.getPointByVal(e,r[g]),a&&(a[g]=s),o&&(o[g]=e),g++}else if(this.getPathSize(t)>1){const e=this.getPathEnd(t)-2,s=1;r&&this.getPointByVal(e+1,r[g]),a&&(a[g]=s),o&&(o[g]=e),g++}return g}queryPointsAlong(t,e,s,r,o){{let n=0;for(let a=0;a<t;++a)s&&s[a].setEmpty(),r&&(r[a]=-1),o&&(o[a]=0),n>e[a]&&(0,i.t)("query_points_along"),n=e[a]}if(0===t)return 0;const a=new n.K(0),h=this.querySegmentIterator();let m=-1,l=0,u=0,c=e[l];for(;h.nextPath();)for(;h.hasNextSegment();){m=h.getPathIndex();const i=h.nextSegment(),n=i.calculateLength2D(),g=a.getResult();for(a.add(n);a.getResult()>=c;){let a=c-g;a>n&&(a=n);const m=i.lengthToT(a);if(s&&i.queryCoord(m,s[u]),o&&(o[u]=m),r&&(r[u]=h.getStartPointIndex()),u++,l++,c=e[l],l===t)return u}}if(m<0)return 0;if(this.isClosedPath(m)){const t=this.getPathStart(m),e=0;s&&this.getPointByVal(t,s[u]),o&&(o[u]=e),r&&(r[u]=t),u++}else if(this.getPathSize(m)>1){const t=this.getPathEnd(m)-2,e=1;s&&this.getPointByVal(t+1,s[u]),o&&(o[u]=e),r&&(r[u]=t),u++}return u}querySegmentIterator(){return new qe({parent:this})}querySegmentIteratorAtVertex(t){return new qe({parent:this,pointIndex:t})}queryPathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!0)}queryLoosePathEnvelope(t,e){this.queryPathEnvelopeImpl(t,e,!1)}queryPathEnvelopeImpl(t,e,s){if(e instanceof qt&&(0,i.g)(0,"not implemented for Envelope"),e instanceof d&&(0,i.g)(0,"not implemented for Envelope3D"),(t>=this.getPathCount()||t<0)&&(0,i.t)(""),this.isEmpty())return void e.setEmpty();const n=this.getAttributeStreamRef(0),r=o.constructEmpty();r.setEmpty();for(let e=2*this.getPathStart(t),s=2*this.getPathEnd(t);e<s;){const t=s-e;(0,i.g)(!(1&t)),r.mergePointsInterleaved(n,e/2,t/2),e+=t}if(e.setCoords({env2D:r}),this.hasNonLinearSegmentsPath(t)){const n=this.querySegmentIterator();if(n.resetToPath(t),n.nextPath())for(;n.hasNextSegment();){const t=n.nextCurve();if(!t)break;{const i=o.constructEmpty();s?t.queryEnvelope(i):t.queryLooseEnvelope(i),e.mergeEnvelope2D(i)}}else(0,i.g)(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=ke(4)*this.m_curveData.m_arcCount+ke(2)*this.m_curveData.m_bezierCount+ke(8)*this.m_curveData.m_rbezier2Count+ke(16)*this.m_curveData.m_bezier2Count;return this.m_curveData.m_segmentParams.size()>Math.max(3*t>>1,10)?(this.forceCompactSegmentParams(),!0):(0===this.m_pointCount&&(this.m_curveData.m_curveParamWritePoint=0),!1)}forceCompactSegmentParams(){let t=0;for(let e=0,s=this.getPointCount();e<s;e++){const s=this.m_curveData.m_segmentFlags.read(e);_r.isNonLinearSegmentFlag(s)&&(t+=ke(s))}const e=v(t);let s=0;for(let t=0,i=this.getPointCount();t<i;t++){const i=this.m_curveData.m_segmentFlags.read(t);if(_r.isNonLinearSegmentFlag(i)){let n=this.m_curveData.m_segmentParamIndex.read(t);this.m_curveData.m_segmentParamIndex.write(t,s);const r=ke(i);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}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(t){(0,i.g)(0)}getImpl(){return this}reserve(t){this.reserveImpl(t),t>0&&!this.m_paths&&(this.m_paths=E(0),this.m_pathFlags=C(0),this.m_paths.reserve(2),this.m_pathFlags.reserve(2),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0))}reserveParts(t,e){this.reserveImpl(t),e>0&&(this.m_paths?(this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1)):(this.m_paths=E(0),this.m_pathFlags=C(0),this.m_paths.reserve(e+1),this.m_pathFlags.reserve(e+1),this.m_paths.resize(1,0),this.m_pathFlags.resize(1,0)))}clone(){const t=this.createInstance();return this.copyTo(t),t}queryLimitedSegmentIterator(t){return new dr(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 gr),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,n){if(n>=0&&n<e){if(s>=t.read(n)){if(s<t.read(n+1))return n;n++}else n--;if(n>=0&&n<e&&s>=t.read(n)&&s<t.read(n+1))return n}if(e<5){for(let i=0;i<e;i++)if(s<t.read(i+1))return i;(0,i.o)("")}let r=0,o=e-1;for(;o>r;){const e=r+(o-r>>1);if(s<t.read(e))o=e-1;else{if(!(s>=t.read(e+1)))return e;r=e+1}}return r}getHighestPointIndex(t){(0,i.g)(t>=0&&t<this.getPathCount());const e=this.getAttributeStreamRef(0),s=this.getPathEnd(t),r=this.getPathStart(t);let o=-1;const a=new n.P;a.y=Number.NEGATIVE_INFINITY,a.x=Number.NEGATIVE_INFINITY;for(let t=r+0;t<s;t++){const s=e.readPoint2D(2*t);-1===a.compare(s)&&(o=t,a.setCoordsPoint2D(s))}return o}applyTransformationToPath(t,e){if(e>=this.getPathCount()&&(0,i.t)("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 r=new this.m_segmentBufferCTor,o=this.getPathCount();let a=e<0?0:e;do{const i=this.getPathStart(a),o=this.getPathEnd(a),h=this.isClosedPath(a),m=s.readPoint2D(2*i);if(!this.hasNonLinearSegmentsPath(a)){s.applyTransformation(t,2*i,o-i);continue}const l=n.P.getNAN();for(let e=i;e<o;++e){if(1!=(31&this.m_curveData.m_segmentFlags.read(e))){const n=h&&e+1===o;n&&s.writePoint2D(2*i,m),this.getSegmentBuffer(e,r,!0),r.get().applyTransformation(t);const a=this.m_curveData.m_segmentParamIndex.read(e);r.get().writeInBufferStream(this.m_curveData.m_segmentParams,a),s.writePoint2D(2*e,r.get().getStartXY()),n&&s.writePoint2D(2*i,r.get().getEndXY());continue}const n=2*e;s.queryPoint2D(n,l),t.transformInPlace(l),s.writePoint2D(n,l)}if(a===e)break}while(++a<o);this.notifyModifiedFlags(2001)}calculateSubLength2D(t,e,s,n){const r=this.getPathStart(t)+e,o=this.getPathStart(s)+n;(o<r||r<0||o>this.getPointCount()-1)&&(0,i.u)("");const a=this.querySegmentIterator();let h=0;a.resetToVertex(r,t);do{for(;a.hasNextSegment();){const t=a.nextSegment();if(a.getStartPointIndex()===o)break;h+=t.calculateLength2D()}if(a.getStartPointIndex()===o)break}while(a.nextPath());return h}calculatePathSubLength2D(t,e,s){const n=this.getPathStart(t)+e,r=this.getPathStart(t)+s;(n<0||r>this.getPointCount()-1)&&(0,i.u)("");const o=this.querySegmentIterator();if(n>r&&(this.isClosedPath(t)||(0,i.t)("cannot iterate across an open path"),o.setCirculator(!0)),n===r)return 0;let a=0,h=0;o.resetToVertex(n,t);do{h+=a,a=o.nextSegment().calculateLength2D()}while(o.getStartPointIndex()!==r);return h}calculateEnvelope2D(t){return this.updateXYImpl(t)}updateXYImpl(t){const e=super.updateXYImpl(t);if(this.hasNonLinearSegments()){const s=o.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&&(0,i.t)("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 n=this.getPathIndexFromPointIndex(t),r=t-this.getPathStart(n);r>=this.getSegmentCountPath(n)&&(0,i.t)("getSegmentBuffer"),this.getSegmentFromPath(n,r,e,s)}getSegmentTypeFromPath(t,e){const s=this.getPathStart(t)+e,n=this.getSegmentFlagsStreamRef();let r=1;switch(n&&(r=31&n.read(s)),r){case 1:return i.G.enumLine;case 2:return i.G.enumBezier;case 4:return i.G.enumEllipticArc;case 8:return i.G.enumRationalBezier2;case 16:return i.G.enumBezier2;default:(0,i.b)("")}}ensureXYMonotoneSegments(){if(!this.m_curveData)return!1;let t=!1;for(let e=0,s=this.getPathCount();e<s;e++){const s=this.getPathStart(e),r=this.getPathEnd(e),o=r-s;for(let e=s;e<r;e++){const r=31&this.m_curveData.m_segmentFlags.read(e);if(1===r)continue;2!==r&&(0,i.a)("ensure_xy_monotone_segments");const a=(e-s+1)%o+s,h=this.m_curveData.m_segmentParamIndex.read(e),m=(0,n.m)(n.P,4);m[0]=this.getXY(e),m[3]=this.getXY(a),m[1].x=this.m_curveData.m_segmentParams.read(h),m[1].y=this.m_curveData.m_segmentParams.read(h+1),m[2].x=this.m_curveData.m_segmentParams.read(h+2),m[2].y=this.m_curveData.m_segmentParams.read(h+3),Vn(m)&&(t=!0,this.m_curveData.m_segmentParams.write(h,m[1].x),this.m_curveData.m_segmentParams.write(h+1,m[1].y),this.m_curveData.m_segmentParams.write(h+2,m[2].x),this.m_curveData.m_segmentParams.write(h+3,m[2].y))}}return t&&this.notifyModifiedFlags(2001),t}buildRasterizedGeometryAccelerator(t,e){return!1}buildQuadTreeAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Fe),null!==this.m_accelerators.getQuadTree())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTree(null);const e=St(this);return this.m_accelerators.setQuadTree(e),!0}buildQuadTreeForPathsAccelerator(t){if(this.m_accelerators||(this.m_accelerators=new Fe),null!==this.m_accelerators.getQuadTreeForPaths())return!0;this.ensureUniqueAccelerators(),this.m_accelerators.setQuadTreeForPaths(null);const e=function(t){const e=new o;return t.queryLooseEnvelope(e),e.inflateCoords(1,1),function(t,e){const s=new o;if(t.queryLooseEnvelope(s),s.isEmpty())return null;t.getGeometryType();const n=new H(s,8);let r=-1;const a=new o;let h=!1;do{for(let o=0,m=t.getPathCount();o<m;o++)if(t.queryLoosePathEnvelope(o,a),a.isIntersecting(e)){if(r=n.insertEx(o,a,r),-1===r){h&&(0,i.b)("build_quad_tree_for_paths"),s.assign(t.calculateEnvelope2D(!1)),h=!0,n.reset(s,8);break}h=!1}}while(h);return n}(t,e)}(this);return this.m_accelerators.setQuadTreeForPaths(e),!0}updateCurveCounter(t){this.modifyCurveCounter(t-this.getCurveCount())}removeAllCurvesFromGlobalCounter(){this.m_curveData&&(_r.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 gr),_r.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 gr),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 null!==this.m_curveData?this.m_curveData.m_curveParamWritePoint:0}initSegmentData(t){null===this.m_curveData&&(this.m_curveData=new gr);const e=this.m_reservedPointCount>0?this.m_reservedPointCount:this.m_pointCount;null===this.m_curveData.m_segmentParamIndex&&(this.m_curveData.m_segmentFlags=C(e,1),this.m_curveData.m_segmentParamIndex=E(e,-1));const s=this.m_curveData.m_curveParamWritePoint+t;null===this.m_curveData.m_segmentParams?this.m_curveData.m_segmentParams=v(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(t){null===this.m_curveData&&(this.m_curveData=new gr),this.m_curveData.m_curveParamWritePoint=t}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=(0,n.s)(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(t,e,s){(t<0||t>=this.getPointCount())&&(0,i.t)("Multi_path_impl.replace_segment"),(0,i.g)(e.isCurve());const n=this.getPathIndexFromPointIndex(t),r=this.getPathStart(n),o=(t-r+1)%this.getPathSize(n)+r;{const s=this.getXY(t),n=this.getXY(o),r=!s.isEqualPoint2D(e.getStartXY())||!n.isEqualPoint2D(e.getEndXY());(0,i.g)(!r)}const a=e.getDescription();this.mergeVertexDescription(a);const h=new Array(32),m=new Nt({vd:a,attribBuffer:h,initDefaultValues:!1}),l=null===this.m_curveData?1:31&this.m_curveData.m_segmentFlags.read(t),u=ke(l),c=Xe(e);let g,_=!1;u>=c?((0,i.g)(null!==this.m_curveData),_=!0,g=this.m_curveData.m_segmentParamIndex.read(t)):(this.initSegmentData(c),_=!1,g=this.m_curveData.m_curveParamWritePoint);const d=e.getGeometryType(),p=gr.toSegType(d);s||(e.queryStart(m),this.setPointByVal(t,m),e.queryEnd(m),this.setPointByVal(o,m)),this.m_curveData.m_segmentParamIndex.write(t,1!==p?g:-1),this.m_curveData.m_segmentFlags.write(t,p),1!==p&&e.writeInBufferStream(this.m_curveData.m_segmentParams,g),_||(this.m_curveData.m_curveParamWritePoint+=c),l!==p&&(this.incCurveType(l,-1),this.incCurveType(p,1),this.modifyCurveCounter(1===l?1:-1))}setAttributeImpl(t,e,s){if(this.addAttribute(t),!this.isEmpty())if(this.hasNonLinearSegments()&&0===t){(e<0||e>1)&&(0,i.t)("");const t=new n.T,r=0===e?s:0,o=0===e?0:1;t.setShiftCoords(r,o),0===e?t.xx=0:t.yy=0,this.applyTransformation(t)}else super.setAttributeImpl(t,e,s)}}_r.st_totalCurveCount=0;class dr{constructor(t,e){this.m_segIter=null,this.m_quadTree=null,this.m_qtIter=null,this.m_extentOfInterest=new o(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_(){const t=this.m_parent.getAccelerators();t&&(this.m_quadTree=t.getQuadTree(),this.m_quadTree&&(this.m_qtIter=this.m_quadTree.getSortedIterator(this.m_extentOfInterest,0))),this.m_segIter=this.m_parent.querySegmentIterator()}nextSegmentQt(){this.m_bfirst=!1;const t=this.m_qtIter.next();if(-1===t)return null;const e=this.m_quadTree.getElement(t);return(e!==this.m_prevIndex+1||this.m_segIter.isLastSegmentInPath())&&(this.m_segIter.resetToVertex(e,this.m_segIter.getPathIndex()),this.m_prevIndex=e),this.m_segIter.nextSegment()}nextSegmentNoQt(){for(;;){if(!this.m_bfirst&&this.m_segIter.hasNextSegment()){const t=this.m_segIter.nextSegment(),e=o.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 pr extends _r{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!1}),this.m_segmentBufferCTor=ra):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ra,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=ra):t.start?(super({vd:t.start.getDescription(),bPolygon:!1}),this.m_segmentBufferCTor=ra,this.startPathPoint(t.start),this.lineToPoint(t.end)):t.path?(super({bPolygon:!1}),this.m_segmentBufferCTor=ra,this.addPathPoint2D(t.path,t.pointCount,t.bForward)):(0,i.b)("bad constructor arg"):(super({bPolygon:!1}),this.m_segmentBufferCTor=ra)}getBoundary(){return yr(this)}assignCopy(t){return this!==t&&t.copyTo(this),this}assignMove(t){return t.copyTo(this),this}getGeometryType(){return pr.type}getDimension(){return 1}createInstance(){return new pr({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}pr.type=i.G.enumPolyline;var fr=i.G;function xr(t,e){if(t.isEmpty())return!1;const s=t.getGeometryType();if(s===fr.enumPolygon)return 0!==t.calculateArea2D();if(s===fr.enumPolyline)return Pr(t.getImpl(),0,!0).bNotEmpty;if(s===fr.enumEnvelope)return!0;if((0,i.e)(s))return!!t.isClosed();if((0,i.h)(s))return!1;if(s===fr.enumGeometryCollection){const s=t;for(let t=0,i=s.getGeometryCount();t<i;t++)if(xr(s.getGeometry(t),e))return!0;return!1}(0,i.a)("")}function yr(t,e){const s=t.getGeometryType();if(s===fr.enumPolygon){const e=new pr({vd:t.getDescription()});return t.isEmpty()||t.copyToUnchecked(e),e}if(s===fr.enumPolyline)return Pr(t.getImpl(),0,!1).boundary;if(s===fr.enumEnvelope){const e=new pr({vd:t.getDescription()});return t.isEmpty()||e.addEnvelope(t,!1),e}if((0,i.e)(s)){const e=new kt({vd:t.getDescription()});if(!t.isEmpty()&&!t.isClosed()){const s=new Nt;e.reserve(2),t.queryStart(s),e.add(s),t.queryEnd(s),e.add(s)}return e}if(s===fr.enumGeometryCollection){const s=t;let i=null;for(let n=0,r=s.getGeometryCount();n<r;n++){const r=yr(s.getGeometry(n),e);if(null!==r){null===i&&(i=t.createInstance());const e=r;i.addGeometry(e)}}return i}if((0,i.h)(s))return new Nt({vd:t.getDescription()});(0,i.a)("")}function Pr(t,e,s){const i=!1,r=t;let o=null;if(s||(o=new kt({vd:r.getDescription()})),!r.isEmpty()){const t=new I(0);for(let e=0,s=r.getPathCount();e<s;e++)if(r.getPathSize(e)>0&&!r.isClosedPathInXYPlane(e)){const s=r.getPathStart(e);t.add(s);const i=r.getPathEnd(e)-1;t.add(i)}if(t.size()>0){const e=new X,i=r.getAttributeStreamRef(0),a={userSort(t,e,s){const r=n.P.getNAN(),o=n.P.getNAN();s.sort(t,e,((t,e)=>(i.queryPoint2D(2*t,r),i.queryPoint2D(2*e,o),r.compare(o))))},getValue:t=>i.read(2*t+1)};e.sort(t,0,t.size(),a);let h=i.readPoint2D(2*t.read(0)),m=0,l=1;const u=new Nt;for(let e=1,r=t.size();e<r;e++){const r=i.readPoint2D(2*t.read(e));if(r.isEqualPoint2D(h))t.read(m)>t.read(e)?(t.write(m,(0,n.j)()),m=e):t.write(e,(0,n.j)()),l++;else{if(1&l){if(s)return{bNotEmpty:!0,boundary:new kt({})}}else t.write(m,(0,n.j)());h=r,m=e,l=1}}if(1&l){if(s)return{bNotEmpty:!0,boundary:new kt({})}}else t.write(m,(0,n.j)());if(!s){t.sort(0,t.size());for(let e=0,s=t.size();e<s&&t.read(e)!==(0,n.j)();e++)r.getPointByVal(t.read(e),u),o.add(u)}}}return s?{bNotEmpty:i,boundary:new kt({})}:{bNotEmpty:i,boundary:o}}const Er=n.ab/180,Cr=180/n.ab;function vr(t){let e=t;return e=function(t){let e=t;return e>=-360&&e<720?(e<0?e+=360:e>=360&&(e-=360),e):(e=(0,n.r)(e,360),e<0&&(e+=360),e)}(e),e>180&&(e-=360),e}function br(t){return t*Er}function Sr(t){return t*Cr}function Ir(t){const e=(0,n.af)();let s=t;return s>=-e&&s<2*e?(s<0&&(s+=e),s>=e&&(s-=e),s):(s=(0,n.r)(s,e),s<0&&(s+=e),s)}function wr(t){const e=(0,n.ac)();let s=t;return s>-e&&s<=e||(s=Ir(s),s>e&&(s-=(0,n.af)())),s}function Dr(t,e){return vr(e-t)}var Tr=g;class Nr extends xe{constructor(t){if(void 0===t||(0,n.Y)(t,"vd"))return super({vd:t?.vd,XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_semiMajorAxis=0,this.m_minorMajorRatio=1,this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,this.m_center=new n.P(0,0),this.m_sweepAngle=0,this.m_startAngle=0,this.m_interior=new n.P(0,0),void(this.m_bits=0);if(t.copy)return super(t),void(this!==t.copy&&(this.m_center=new n.P(0,0),this.m_interior=new n.P(0,0),t.copy.copyToImpl(this)));if(t.move)super(t),this.m_semiMajorAxis=t.move.m_semiMajorAxis,this.m_minorMajorRatio=t.move.m_minorMajorRatio,this.m_rotation=t.move.m_rotation,this.m_cosr=t.move.m_cosr,this.m_sinr=t.move.m_sinr,this.m_center=t.move.m_center.clone(),this.m_sweepAngle=t.move.m_sweepAngle,this.m_startAngle=t.move.m_startAngle,this.m_interior=t.move.m_interior.clone(),this.m_bits=t.move.m_bits,this.m_cachedValues=t.move.m_cachedValues,t.move.m_cachedValues=null;else{if(t.fromPoint)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new n.P(0,0),this.m_interior=new n.P(0,0),void this.constructCircularArcThreePoint(t.fromPoint,t.toPoint,t.interiorPoint);if(t.center)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),this.m_center=new n.P(0,0),this.m_interior=new n.P(0,0),void this.constructCircleRadius(t.radius,t.center,t.bIsCounterClockwise);if(t.semiMajorAxis)return super({XStart:0,YStart:0,XEnd:0,YEnd:0}),void this.constructEllipticArcEndPoints(t.fromPoint,t.toPoint,t.semiMajorAxis,t.minorMajorRatio,t.axisXRotationRad,t.bBigArc,t.bIsCounterClockwise)}}getBoundary(){return yr(this)}assignCopy(t){return this!==t&&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=n.P.distance(t,e);return this.constructEllipticArcEndPointsCenter(e,e,i,1,0,!0,s,t),this.setProjectionBehavior(0),this.afterCompletedModification(),this}constructTwoPointCircle(t,e,s=!1){const i=n.P.lerp(t,e,.5);return this.constructCircleCenterAndPoint(i,t,s),this}constructLineEllipticArc(t,e){return $r(this,t,e,1),this}constructLineCircularArc(t,e){return $r(this,t,e,0),this}constructEllipse(t,e,s,i,r=!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 o=new n.P(0,this.m_minorMajorRatio*this.m_semiMajorAxis),a=Math.cos(i),h=Math.sin(i);return o.rotateDirect(a,h),o.addThis(s),this.constructEllipticArcEndPointsCenter(o,o,this.m_semiMajorAxis,this.m_minorMajorRatio,i,!0,r,s),this}inflate(t){if(this.isDegenerateToLine())return;let e=this.getSemiMinorAxis()+t;if(e=e<=0?0:(this.getSemiMajorAxis()+t)/this.getSemiMajorAxis(),this.isCircular()){const t=new n.T;t.setShiftCoords(-this.m_center.x,-this.m_center.y),t.scale(e,e),t.shiftCoords(this.m_center.x,this.m_center.y),this.applyTransformation(t)}else{const t=new n.T;this.canonicToWorldTransformation(t);const s=t.clone();s.invertPreciseThis(),s.scale(e,e),s.multiply(t),this.applyTransformation(s)}}constructEnclosingCircle(t,e,s=!1){return function(t,e,s,r){0===s&&(0,i.t)("construct_enclosing_circle");const o=[0,0,0],a=function(t,e,s){const i=[];return function(t,e){e.length=t;for(let t=0;t<e.length;++t)e[t]=t;t>3&&Vt(t,e)}(e,i),function(t,e,s,i){let r=0;const o=[0,0,0];let a=0,h=0;for(let m=0;m<3;++m){let l=!1;for(;h<s;){const s=t.at(e[h]);let u=1;if(3===r?u=n.P.inCircleRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]),s):2===r?u=n.P.inCircleRobust3Point(t.at(i[0]),t.at(i[1]),s):1===r&&s.equals(t.at(i[0]))&&(u=0),u<=0){if(u<0&&m+1<3){e[a]=(0,n.b)(e[h],e[h]=e[a]);for(let t=0;t<r;t++)if(i[t]===e[h]){o[t]=h;break}a++}h++;continue}l=!0;let c=0;for(let t=0;t<r;t++)o[t]>h&&(i[c]=i[t],o[c]=o[t],c++);r=c,i[r]=e[h],o[r]=h,r++,r<3?h=a:(1===n.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,n.b)(i[0],i[0]=i[2]),o[2]=(0,n.b)(o[0],o[0]=o[2])),h++)}if(!l)break;if(m+1<3){a=0;let s=!1;for(let t=0;t<r;t++)for(let e=t+1;e<r;e++)o[t]>o[e]&&(o[e]=(0,n.b)(o[t],o[t]=o[e]),i[e]=(0,n.b)(i[t],i[t]=i[e]),s=!0);for(let t=0;t<r;t++)e[o[t]]=(0,n.b)(e[t],e[t]=e[o[t]]),o[t]=t;s&&3===r&&1===n.P.orientationRobust(t.at(i[0]),t.at(i[1]),t.at(i[2]))&&(i[2]=(0,n.b)(i[0],i[0]=i[2]),o[2]=(0,n.b)(o[0],o[0]=o[2]))}h=r}return r}(t,i,e,s)}(e,s,o);if(1===a)t.constructCircleRadius(0,e[o[0]],r);else if(2===a){const s=n.P.lerp(e[o[0]],e[o[1]],.5),i=n.P.distance(e[o[0]],s),a=n.P.distance(e[o[1]],s);t.constructCircleRadius(Math.max(i,a),s,r)}else if(3===a){const s=n.P.calculateCircleCenterFromThreePoints(e[o[0]],e[o[1]],e[o[2]]),i=n.P.distance(e[o[0]],s),a=n.P.distance(e[o[1]],s),h=n.P.distance(e[o[2]],s);t.constructCircleRadius(Math.max(i,a,h),s,r)}else(0,i.b)("unexpected")}(this,t,e,s),this}constructThreePointCircle(t,e,s,i=!1){if(t.equals(e)||e.equals(s)||t.equals(s)){const n=t.clone(),r=e.clone(),o=s.clone();return n.equals(r)&&r.assign(o),this.constructTwoPointCircle(n,r,i)}{const r=n.P.calculateCircleCenterFromThreePoints(t,e,s);if(!r.isFinite()||!Number.isFinite(n.P.distance(t,r))){const i=n.P.distance(t,e),r=n.P.distance(t,s);this.constructLineCircularArc(t,i>=r?e:s)}return this.constructCircleCenterAndPoint(r,t,i)}}constructCircularArcThreePoint(t,e,s){const i=new n.H(t.x),r=new n.H(e.x),o=new n.H(s.x),a=new n.H(t.y),h=new n.H(e.y),m=new n.H(s.y),l=new n.H(.5),u=r.subE(i),c=h.subE(a),g=o.subE(i),_=m.subE(a),d=u.mulE(_).subThisE(c.mulE(g));if(d.scaleError(10),d.isZero()){if(!u.isZero()||!c.isZero())return $r(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 p=u.sqr().addThisE(c.sqr()).mulThisE(l),f=g.sqr().addThisE(_.sqr()).mulThisE(l),x=p.mulE(_).subThisE(f.mulE(c)),y=u.mulE(f).subThisE(g.mulE(p));x.divThisE(d),y.divThisE(d);const P=x.sqr().addThisE(y.sqr());P.sqrtThis();const E=x.addE(i),C=y.addE(a);let v=t.x-E.value(),b=t.y-C.value();const S=Math.atan2(b,v);v=e.x-E.value(),b=e.y-C.value();const I=Math.atan2(b,v);v=s.x-E.value(),b=s.y-C.value();const w=Math.atan2(b,v);let D=w-2*(0,n.ac)();for(;D<S;)D+=2*(0,n.ac)();let T=I-2*(0,n.ac)();for(;T<D;)T+=2*(0,n.ac)();let N=w+2*(0,n.ac)();for(;N>S;)N-=2*(0,n.ac)();let A,M=I+2*(0,n.ac)();for(;M>N;)M-=2*(0,n.ac)();A=T-S<S-M?T-S:M-S;const G=new n.P(E.value(),C.value());return this.constructEllipticArcEndPointsCenter(t,e,P.value(),1,0,Math.abs(A)>(0,n.ac)(),A>0,G),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 Jr(this,t,e,s,i,n,r,o)}constructEllipticArcEndPointsCenter(t,e,s,i,n,r,o,a){return Jr(this,t,e,s,i,n,r,o,a)}constructEllipticArcGeneral(t,e,s,i,r,o){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 a=wr(o),h=Math.cos(a),m=Math.sin(a),l=new n.P(this.m_semiMajorAxis,this.m_minorMajorRatio*this.m_semiMajorAxis),u=n.P.getNAN(),c=wr(i);u.x=l.x*Math.cos(c),u.y=l.y*Math.sin(c),u.rotateDirect(h,m),u.addThis(s);const g=(0,n.an)(r,(0,n.af)());let _=g;Math.abs(_)===(0,n.af)()&&(_=0);const d=n.P.getNAN();return d.x=l.x*Math.cos(c+_),d.y=l.y*Math.sin(c+_),d.rotateDirect(h,m),d.addThis(s),this.constructEllipticArcEndPointsCenter(u,d,this.m_semiMajorAxis,this.m_minorMajorRatio,a,Math.abs(g)>(0,n.ac)(),g>0,s)}constructEllipticArcAsNURB(t,e,s,n){return(n>=1||n<0)&&(0,i.t)("construct_elliptic_arc_as_NURB: weight"),e.isFinite()||(0,i.t)("construct_elliptic_arc_as_NURB: control_point"),po([t,e,s],n*n,null,!1,this),this}constructCanonic(t){return this.assignCopy(t),t.isDegenerateToLine()||t.m_center.isEqual(0,0)&&0===this.m_rotation||(this.m_XStart=t.getSemiMajorAxis()*Math.cos(t.m_startAngle),this.m_YStart=t.getSemiMinorAxis()*Math.sin(t.m_startAngle),this.m_XEnd=t.getSemiMajorAxis()*Math.cos(t.getEndAngle()),this.m_YEnd=t.getSemiMinorAxis()*Math.sin(t.getEndAngle()),this.m_center.setCoords(0,0),this.m_rotation=0,this.m_cosr=1,this.m_sinr=0,Po(this),this.afterCompletedModification(),t!==this&&ue(this,t)),this}isCircular(){return 1===this.m_minorMajorRatio&&0===this.m_rotation&&!this.isDegenerateToLine()}isDegenerateToLineHelper(t){return!!Jt(this,[t])&&to(this)}isDegenerateToLine(){return to(this)}getCenter(){return this.m_center.clone()}setCenter(t){if(!this.m_center.isNAN()){const e=t.sub(this.m_center);this.m_XStart+=e.x,this.m_YStart+=e.y,this.m_XEnd+=e.x,this.m_YEnd+=e.y,this.m_interior.addThis(e),this.m_center.assign(t),this.endPointModified(),this.normalizeAfterEndpointChange()}}getAxisXRotation(){return this.m_rotation}getSemiAxes(){return n.P.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!ho(this)}isMajor(){return lo(this)}getSweepAngle(){return this.m_sweepAngle}getStartAngle(){return this.m_startAngle}getEndAngle(){return this.m_startAngle+this.m_sweepAngle}getGeometryType(){return i.G.enumEllipticArc}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=Tr.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?bo(this,n.E.unit(),t):(0,i.a)("3d not impl")}applyTransformation(t){io(this,t,!1)}createInstance(){return new Nr}calculateLength2D(){return function(t){if(to(t))return 1*n.P.distance(t.getStartXY(),t.getEndXY());if(1===t.m_minorMajorRatio)return Math.abs(-1*t.getSweepAngle())*t.m_semiMajorAxis;const e=eo(t,0);return eo(t,1)-e}(this)}queryCoord2D(t,e){if(to(this))Ee(t,this.getStartXY(),this.getEndXY(),e);else if(0===t)e.assign(n.P.construct(this.m_XStart,this.m_YStart));else if(1===t)e.assign(n.P.construct(this.m_XEnd,this.m_YEnd));else{const s=Wr(this,t),i=new n.P(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){!function(t,e,s){if(to(t))be(new na({start:t.getStartXY(),end:t.getEndXY()}),e,s);else if(0===e.value())s.set(t.getStartXY());else if(1===e.value())s.set(t.getEndXY());else{const i=new n.H;jr(t,e,i);const r=new n.H,o=new n.H;n.H.st_cosAndSin(i,r,o);const a=Wt.constructCoordsE(new n.H(t.m_semiMajorAxis).mulThisE(r),new n.H(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio).mulThisE(o)),h=new n.H(t.m_rotation);n.H.st_cosAndSin(h,r,o),a.rotateDirect(r,o),a.addThisE(Wt.constructPoint2D(t.m_center)),s.setE(a)}}(this,t,e)}getCoordX(t){const e=new n.P;return this.queryCoord2D(t,e),e.x}getCoordY(t){const e=new n.P;return this.queryCoord2D(t,e),e.y}cut(t,e,s){const i=new ra;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const r=s.createEllipticArc();let o=0===t&&1===e;if(o&&!i)return void this.copyTo(r);const a=n.P.getNAN();this.queryCoord2D(t,a);const h=n.P.getNAN();if(this.queryCoord2D(e,h),!o)if(a.equals(h))e-t>.5&&this.isMajor()&&this.isClosed()?(o=!0,t=0,e=1):1===e?t=e:e=t;else if(t>0&&a.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&h.isEqual(this.m_XEnd,this.m_YEnd)&&(e=1),o=0===t&&1===e,o&&!i)return void this.copyTo(r);if(r.m_center.assign(this.m_center),r.m_semiMajorAxis=this.m_semiMajorAxis,r.m_minorMajorRatio=this.m_minorMajorRatio,r.m_interior.assign(this.m_interior),r.m_rotation=this.m_rotation,r.m_cosr=this.m_cosr,r.m_sinr=this.m_sinr,r.m_sweepAngle=this.m_sweepAngle,r.m_startAngle=this.m_startAngle,r.m_bits=this.m_bits,se(r,a.x,a.y),ne(r,h.x,h.y),o)return void ro(r,Zr(this));r.m_startAngle=Wr(this,t),r.m_sweepAngle=Wr(this,e)-r.m_startAngle,r.m_startAngle=Br(r.m_startAngle),mo(r,Math.abs(r.m_sweepAngle)>(0,n.ac)()),r.assignVertexDescription(this.m_description),Po(r),Ur(r);const m=this.m_description.getAttributeCount();if(m>1){for(let e=1;e<m;e++){const s=this.m_description.getSemantics(e),i=Tr.getComponentCount(s);for(let e=0;e<i;e++){const i=this.getAttributeAsDbl(t,s,e);r.setStartAttribute(s,e,i)}}for(let t=1;t<m;t++){const s=this.m_description.getSemantics(t),i=Tr.getComponentCount(s);for(let t=0;t<i;t++){const i=this.getAttributeAsDbl(e,s,t);r.setEndAttribute(s,t,i)}}}r.afterCompletedModification()}queryDerivative(t,e){!function(t,e,s){if(to(t))s.setE(Wt.constructPoint2D(t.getEndXY()).subE(Wt.constructPoint2D(t.getStartXY())));else{const i=new n.H;jr(t,e,i);const r=new Wt;if(r.setCoordsE(new n.H(t.m_semiMajorAxis).negate().mulE((new n.H).setSin(i)),new n.H(t.getSemiMinorAxis()).mulE((new n.H).setCos(i))),t.m_rotation){const e=new n.H(t.m_rotation);r.rotateDirect((new n.H).setCos(e),(new n.H).setSin(e))}r.scaleThis(new n.H(t.getSweepAngle())),s.setE(r)}}(this,t,e)}cutArcIgnoreAttributes(t,e,s){let i=0===t&&1===e;const r=new n.P;this.queryCoord2D(t,r);const o=new n.P;this.queryCoord2D(e,o),i||(r.equals(o)?e-t>.5&&this.isMajor()&&this.isClosed()?(i=!0,t=0,e=1):1===e?t=e:e=t:(t>0&&r.isEqual(this.m_XStart,this.m_YStart)&&(t=0),e<1&&o.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,se(s,r.x,r.y),ne(s,o.x,o.y),i?ro(s,Zr(this)):(s.m_startAngle=Wr(this,t),s.m_sweepAngle=Wr(this,e)-s.m_startAngle,s.m_startAngle=Br(s.m_startAngle),mo(s,Math.abs(s.m_sweepAngle)>Math.PI),Po(s),s.afterCompletedModification())}changeEndPoints2D(t,e){Kr(this,t,e,!1)}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(),r=i>0?this.tToLength(t)/i:0,o=Tr.getInterpolation(e),a=this.getStartAttributeAsDbl(e,s),h=this.getEndAttributeAsDbl(e,s);return(0,n.$)(o,a,h,r,Tr.getDefaultValue(e))}getClosestCoordinate(t,e){return So(this,t,n.E.unit(),e)}getClosestCoordinateOnInterval(t,e,s=-1){return So(this,t,e,!1)}getYMonotonicParts(t,e=!1){t.length<2&&(0,i.t)("");const s=this.getSemiAxes(),r=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),o=r+(0,n.ac)(),a=new Array(3);let h=0;if(a[0]=Or(this,r),a[0]>0&&a[0]<1&&h++,a[1]=Or(this,o),a[1]>0&&a[1]<1&&(a[h]=a[1],h++),0===h)return 0;a[h]=1,h++,(0,i.g)(t.length>=h);let m=0;for(let s=0;s<h;s++){const i=a[s];this.queryCut(m,i,t[s],e),m=i}return h}getMonotonicParts(t,e){if(t.length<4&&(0,i.t)(""),this.isDegenerateToLine())return t[0].createEllipticArc().assignCopy(this),e&&t[0].get().dropAllAttributes(),1;const s=this.getSemiAxes(),r=new Array(4);r[0]=Math.atan2(s.y*this.m_cosr,s.x*this.m_sinr),r[1]=r[0]+(0,n.ac)(),r[2]=Math.atan2(-s.y*this.m_sinr,s.x*this.m_cosr),r[3]=r[2]+(0,n.ac)();const o=new Array(5);let a=0;for(let t=0;t<4;t++)o[a]=Or(this,r[t]),o[a]>0&&o[a]<1&&a++;if(0===a)return 0;(0,n.a0)(o,a),o[a-1]<1&&(o[a]=1,a++),(0,i.g)(t.length>=a);let h=0;for(let s=0;s<a;s++){const i=o[s];this.queryCut(h,i,t[s],e),h=i}return a}intersectionWithAxis2D(t,e,s,i){if(to(this))return new na({start:this.getStartXY(),end:this.getEndXY()}).intersectionWithAxis2D(t,e,s,i);let r,o;const a=new n.H(e),h=this.getSemiAxes();if(t){if(e>this.m_center.y+h.x||e<this.m_center.y-h.x)return 0;r=new n.H(h.x).mulThis(this.m_sinr),o=new n.H(h.y).mulThis(this.m_cosr),a.subThis(this.m_center.y)}else{if(e>this.m_center.x+h.x||e<this.m_center.x-h.x)return 0;r=new n.H(h.x).mulThis(this.m_cosr),o=new n.H(h.y).mulThis(-this.m_sinr),a.subThis(this.m_center.x)}const m=r.sqr(),l=o.sqr(),u=m.addE(l),c=o.mulE(a).mulThis(-2),g=a.sqr().subThisE(m),_=c.sqr().subThisE(u.mulE(g).mulThis(4)),d=r.mulE(a).mulThis(-2),p=a.sqr().subThisE(l),f=d.sqr().subThisE(u.mulE(p).mulThis(4));let x=_.eps()*Math.abs(f.value())<=f.eps()*Math.abs(_.value());x?r.isZero()&&(x=!1):o.isZero()&&(x=!0),x||(c.setE(d),g.setE(p));const y=(0,n.m)(n.H,2);let P=Ze(u,c,g,n.E.construct(-1,1),!1,y);if(0===P)return 0;const E=[0,0];let C=0;for(let t=0;t<P;t++){const e=new n.H,s=new n.H;x?(e.setE(y[t]),s.setE(a.subE(o.mulE(y[t])).divThisE(r))):(s.setE(y[t]),e.setE(a.subE(r.mulE(y[t])).divThisE(o)));const i=Or(this,Math.atan2(e.value(),s.value()));i>=0&&i<=1&&(E[C]=i,C++)}return P=C,0===P?0:(2===P&&E[0]>E[1]&&(E[1]=(0,n.b)(E[0],E[0]=E[1])),i&&(0,n.D)(i,E,0,0,P),s&&(s[0]=t?this.getCoordX(E[0]):this.getCoordY(E[0]),P>1&&(s[1]=t?this.getCoordX(E[1]):this.getCoordY(E[1]),!i&&s[0]>s[1]&&(s[1]=(0,n.b)(s[0],s[0]=s[1])))),P)}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 Kt(this,t)}isDegenerate3D(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){3!==t.m_EnvelopeType?this.queryLooseEnvelopeOnInterval(new n.E(0,1),t):(0,i.a)("3d not impl")}clone(t){const e=new Nr;return this.copyTo(e),e}queryInterval(t,e){if(0===t){if(to(this))return 0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.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,r=[0,0];r[0]=Or(this,t),r[1]=Or(this,i);const o=0===e?n.E.construct(this.getStartX(),this.getEndX()):n.E.construct(this.getStartY(),this.getEndY()),a=new n.P;for(let t=0;t<2;t++){const s=r[t];s>0&&s<1&&(this.queryCoord2D(s,a),o.mergeNeCoordinate(0===e?a.x:a.y))}return o}return super.queryInterval(t,e)}queryLooseEnvelopeOnInterval(t,e){const s=new n.E(0,1);if(s.intersect(t),s.isEmpty())return void e.setEmpty();if(to(this))return e.setCoords(this.getCoord2D(s.vmin)),void e.mergeNe(this.getCoord2D(s.vmax));const i=this.getCoord2D(s.vmin),r=this.getCoord2D(s.vmax);if(1===this.m_minorMajorRatio&&Math.abs(this.m_sweepAngle)*s.width()<=n.q){let t=n.P.lerp(i,r,.5);const s=t.sub(this.m_center);return s.normalize(),t=t.add(s.mul(.5*n.P.distance(i,r))),e.setCoords(i),e.mergeNe(r),void e.mergeNe(t)}bo(this,s,e)}tToLength(t){return to(this)?t*n.P.distance(this.getStartXY(),this.getEndXY()):1===this.m_minorMajorRatio?Math.abs(this.getSweepAngle()*t)*this.m_semiMajorAxis:eo(this,t)}parametricAngleToT(t){return Or(this,t)}tToParametricAngle(t){return Wr(this,t)}lengthToT(t){if(to(this)){const e=n.P.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 function(t,e){if(to(t)){const s=n.P.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=Qr(t),r=(0,n.ae)(),o=so(t);s<0&&(e=-e);const a=e/t.m_semiMajorAxis+o;let h=(0,n.ah)(a,i.e2,i.completeE);return h-=r,h-=t.getStartAngle(),h/s}(this,t)}calculateWeightedAreaCentroid2D(t){if(to(this)){const t=new n.P;return t.setCoords(0,0),t}const e=yo(this),s=this.getStartXY().sub(this.m_center),i=this.getEndXY().sub(this.m_center),r=this.m_semiMajorAxis,o=this.getSemiMinorAxis(),a=this.m_startAngle+this.m_sweepAngle,h=new n.P;h.x=r*o*(r*this.m_cosr*(-Math.sin(a)+Math.sin(this.m_startAngle))+o*(-Math.cos(a)+Math.cos(this.m_startAngle))*this.m_sinr)/3,h.y=r*o*(o*(Math.cos(a)-Math.cos(this.m_startAngle))*this.m_cosr+r*(-Math.sin(a)+Math.sin(this.m_startAngle))*this.m_sinr)/3;const m=i.add(s).mul(i.crossProduct(s)/6);return h.x-=m.x,h.y-=m.y,h.add(this.m_center.sub(t).mul(e))}calculateWeightedCentroid2D(){const t=new n.P;if(this.isDegenerate(0))return t.setCoords(0,0),t;if(to(this))return t.assign(this.getCoord2D(.5).mul(this.calculateLength2D())),t;let e=this.m_startAngle,s=this.m_startAngle+this.m_sweepAngle;if(s<e){const t=e;e=s,s=t}const i=Math.sin(e),r=Math.sin(s),o=Math.cos(e),a=Math.cos(s);if(1===this.m_minorMajorRatio){const e=this.getSemiMajorAxis(),s=e*e,n=s*(r-i),h=s*(o-a);t.setCoords(n,h)}else{const e=this.getSemiMajorAxis(),s=this.getSemiMinorAxis(),n=e*e,h=s*s,m=e*s,l=n-h,u=l/h,c=l/n,g=Math.sqrt(u),_=Math.sqrt(c),d=.5*m*(Math.asinh(g*r)/g+r*Math.sqrt(1+u*r*r))-.5*m*(Math.asinh(g*i)/g+i*Math.sqrt(1+u*i*i)),p=-.5*m*(Math.asin(_*a)/_+a*Math.sqrt(1-c*a*a))- -.5*m*(Math.asin(_*o)/_+o*Math.sqrt(1-c*o*o));t.setCoords(d,p)}return t.rotateDirect(this.m_cosr,this.m_sinr),t.assign(t.add(this.m_center.mul(this.calculateLength2D()))),t}isIntersectingPoint(t,e,s){if(s&&(t.isEqualPoint2D(this.getStartXY())||t.isEqualPoint2D(this.getEndXY())))return!1;if(!to(this)){const s=n.P.distance(t,this.m_center),i=this.getSemiAxes();if(s<i.x-e||s>i.y+e)return!1}const i=this.getClosestCoordinate(t,!1),r=new n.P;return this.queryCoord2D(i,r),n.P.distance(r,t)<=e}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getTangent(t){if(to(this))return this.getEndXY().sub(this.getStartXY());{const e=Wr(this,t),s=new n.P;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(t){if(to(this))return this.getEndXY().sub(this.getStartXY());{const e=Wr(this,t),s=new n.P;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}}normalizeAfterEndpointChange(){return!!uo(this)&&(to(this)?(co(this),!1):go(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 n.P(t.x,t.y);return e.subThis(this.m_center),e.rotateReverse(this.m_cosr,this.m_sinr),e}convertFromCanonic(t){const e=new n.P(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)}getCurvature(t){const e=Wr(this,t),s=new n.P,i=this.getSemiMinorAxis();s.setCoords(-this.m_semiMajorAxis*Math.sin(e),i*Math.cos(e));const r=new n.P;r.setCoords(-this.m_semiMajorAxis*Math.cos(e),-i*Math.sin(e)),this.m_rotation&&(s.rotateDirect(this.m_cosr,this.m_sinr),r.rotateDirect(this.m_cosr,this.m_sinr));const o=s.sqrLength();if(0===o)return Number.NaN;const a=Math.sqrt(o);return s.divThis(a),s.crossProduct(r)/o}getMonotonicPartParams(t,e){const s=new Array(6);s[0]=0;let r=1;if(this.isDegenerateToLine())s[1]=1,r=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]=(0,n.ad)());for(let t=0;t<4;t++){const i=Or(this,e[t]);i>0&&i<1&&(s[r]=i,r++)}r>2&&(0,n.a0)(s,r),s[r]=1,r++}if(e){t<r&&(0,i.t)("");for(let t=0;t<r;t++)e[t]=s[t]}return r}calculateLowerLength2D(){const t=n.P.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=n.P.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(){if(this.m_YEnd<this.m_YStart||this.m_YEnd===this.m_YStart&&this.m_XEnd<this.m_XStart){this.m_XEnd=(0,n.b)(this.m_XStart,this.m_XStart=this.m_XEnd),this.m_YEnd=(0,n.b)(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]=(0,n.b)(this.m_attributes[t],this.m_attributes[t]=this.m_attributes[t+e]);this.m_startAngle=this.m_startAngle+this.m_sweepAngle,this.m_sweepAngle=-this.m_sweepAngle}}isLine(){return to(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,oo(t)}calculateArea2DHelper(){return yo(this)}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)),to(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]=Or(this,t),i[1]=Or(this,e),i[2]=Or(this,n),i[3]=Or(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]=Or(this,n),i[5]=Or(this,r),i[6]=Or(this,o),i[7]=Or(this,a)}const r=n.P.getNAN();for(let s=0;s<8;s++){const n=i[s];t.containsExclusiveCoordinate(n)&&(this.queryCoord2D(n,r),e.mergeNe(r))}}setSegmentFromCoords(t,e){!function(t,e,s){const i=0===t.projectionBehavior();if(s<=2)return void $r(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 n.P;return t.queryCoord2D(.5,i),void t.m_interior.setCoordsPoint2D(i)}const r=t.getSemiMajorAxis(),o=t.getMinorMajorRatio(),a=t.getAxisXRotation(),h=t.getCenter(),m=new Array(4);m[0]=t.isMajor(),m[1]=!m[0],m[2]=m[0],m[3]=!m[0];const l=new Array(4);l[0]=t.isClockwise(),l[1]=l[0],l[2]=!l[0],l[3]=!l[0];const u=Math.trunc(s<5?1:(s+4)/5),c=(0,n.m)(Nr,4),g=new Array(4);let _=0;for(let t=0;t<4;t++){c[t].constructEllipticArcEndPointsCenter(e[0],e[s-1],r,o,a,m[t],l[t],h),g[t]=0;let i=0;for(let r=u;r<s-1;r+=u){const s=c[t].getClosestCoordinate(e[r],!1);g[t]+=n.P.sqrDistance(c[t].getCoord2D(s),e[r]),i++}g[t]/=i,g[t]<g[_]&&(_=t)}t.assignCopy(c[_])}(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(t){return!1}calculateSpecialPointsForCracking(t,e){return(0,i.b)("should not1; be called"),0}ensureXYMonotone(){if(to(this))return!1;if(this.getStartXY().equals(this.getEndXY()))return $r(this,this.getStartXY(),this.getEndXY(),this.projectionBehavior()),!0;const t=(0,n.m)(n.P,3);let e=_o(this,t);if(ci(t)){let s=!1;if(0===this.projectionBehavior()){const i=new o;i.setCoords({pt:t[0]}),i.mergeNe(t[2]);const r=new n.P;r.setSub(t[2],t[0]),r.leftPerpendicularThis(),r.normalize(),r.scale(n.P.distance(t[2],t[0]));const a=n.P.lerp(t[2],t[0],.5),h=a.sub(r),m=a.add(r);i.clipLine(h,m);const l=n.P.getClosestCoordinate(h,m,t[1],!1);t[1]=n.P.lerp(h,m,l);const u=t[2].sub(t[1]),c=t[0].sub(t[1]),g=u.crossProduct(c),_=u.dotProduct(c);e=(0,n.ae)()-Math.abs(.5*Math.atan2(g,_)),s=!0}return po(t,e*e,null,s,this),!0}return!1}setCoordsForIntersector(t,e,s){Kr(this,t,e,s)}getInteriorPoint(){return this.m_interior.clone()}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,ro(e,Zr(this))}reverseImpl(){ao(this,!ho(this)),Ur(this),(0!==this.projectionBehavior()||this.getStartXY().equals(this.getEndXY()))&&Po(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(br(vr(Sr(this.m_rotation-s.m_rotation)))),r=Math.abs((0,n.ac)()-i),o=Math.min(i,r);if(this.m_semiMajorAxis*Math.abs(o)>e)return!1;const a=this.getCoord2D(.5),h=s.getCoord2D(.5);return!!a.isEqualPoint2D(h,e)}swapImpl(t){const e=t;this.m_center=(0,n.b)(e.m_center,e.m_center=this.m_center),this.m_semiMajorAxis=(0,n.b)(e.m_semiMajorAxis,e.m_semiMajorAxis=this.m_semiMajorAxis),this.m_minorMajorRatio=(0,n.b)(e.m_minorMajorRatio,e.m_minorMajorRatio=this.m_minorMajorRatio),this.m_interior=(0,n.b)(e.m_interior,e.m_interior=this.m_interior),this.m_rotation=(0,n.b)(e.m_rotation,e.m_rotation=this.m_rotation),this.m_cosr=(0,n.b)(e.m_cosr,e.m_cosr=this.m_cosr),this.m_sinr=(0,n.b)(e.m_sinr,e.m_sinr=this.m_sinr),this.m_sweepAngle=(0,n.b)(e.m_sweepAngle,e.m_sweepAngle=this.m_sweepAngle),this.m_startAngle=(0,n.b)(e.m_startAngle,e.m_startAngle=this.m_startAngle),this.m_bits=(0,n.b)(e.m_bits,e.m_bits=this.m_bits),function(t,e){e.m_cachedValues=(0,n.b)(t.m_cachedValues,t.m_cachedValues=e.m_cachedValues)}(this,e)}afterCompletedModification(){co(this),oo(this)}intersect(t,e,s,i,n){return Jo(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){if(e.length<2&&(0,i.w)(""),to(this))return new na({start:this.getStartXY(),end:this.getEndXY()}).intersectPoint(t,e,s);{const e=n.P.distance(t,this.m_center);if(e>this.m_semiMajorAxis+s||e<this.getSemiMinorAxis()-s)return 0}const r=this.getClosestCoordinate(t,!1),o=n.P.getNAN();return this.queryCoord2D(r,o),n.P.distance(o,t)<=s?(0,n.a1)(r,0,1)&&(this.queryCoord2D(0===r?1:0,o),n.P.distance(o,t)<=s)?(e&&(e[0]=0,e[1]=1),2):(e&&(e[0]=r),1):0}isIntersecting(t,e,s){return 0!==jo(!1,this,t,e,s)}endPointModified(){this.m_bits|=8,oo(this)}clearEndPointModified(){co(this)}}Nr.type=i.G.enumEllipticArc;class Ar extends _r{constructor(t){t?t.vd?(super({vd:t.vd,bPolygon:!0}),this.m_segmentBufferCTor=ra):t.copy?(super({vd:t.copy.getDescription(),bPolygon:!0}),this.m_segmentBufferCTor=ra,t.copy.copyTo(this)):t.move?(super({move:t.move}),this.m_segmentBufferCTor=ra):t.envelope?(0,i.a)("envelope constructor not impl"):(0,i.b)("bad arg to polygon constructor"):(super({bPolygon:!0}),this.m_segmentBufferCTor=ra)}assignMove(t){return t.copyTo(this),this}assignCopy(t){return t.copyTo(this),this}getBoundary(){return yr(this)}getExteriorRingCount(){return this.getOGCPolygonCount()}getGeometryType(){return Ar.type}getDimension(){return 2}createInstance(){return new Ar({vd:this.getDescription()})}equals(t,e){return this.equalsBase(t,e)}}function Mr(t,e,s,i,r,o){return new Fr(0,0,0,null,!1,(0,n.o)()).densifyEx(t,e,s,i,!1,o)}function Gr(t,e,s,r,o,a,h,m){a&&(a.length=0),h&&(h.length=0);const l=t.getGeometryType();if(l===i.G.enumLine)return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(n.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(l===i.G.enumBezier){if(!r)return a&&(a.push(t.getStartXY()),a.push(t.getControlPoint1()),a.push(t.getControlPoint2()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;const e=[];e.length=9;let i=t.getMonotonicPartParams(e.length,e);if(e.length=i,i=Vr(t,s,e),2===i&&o&&(e[1]=.5,e.push(1),i=3),h&&h.splice(0,0,...e.slice(0,i)),a){const s=new ra;for(let n=1;n<i;n++){const i=e[n-1],r=e[n];t.queryCut(i,r,s,!0);const o=s.get();Fn(o),1===n&&a.push(o.getStartXY()),a.push(o.getControlPoint1()),a.push(o.getControlPoint2()),a.push(o.getEndXY())}}return i-1}if(l===i.G.enumEllipticArc){const m=t;if(m.isDegenerateToLine()||m.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(n.P.getNAN()),a.push(t.getEndXY())),h&&(h.push(0),h.push(1)),1;if(r&&(o||!m.isMonotoneQuickAndDirty())){const n=[];n.length=6;let l=m.getMonotonicPartParams(n.length,n);n.length=l,l=Vr(t,s,n),2===l&&o&&(n[1]=.5,n.push(1),l=3);let u=0;if(l>2){const t=new ra,o=h||[];let c=0;for(let g=1;g<l;g++){const _=n[c],d=n[g];if(m.queryCut(_,d,t,!0),t.get().isDegenerate(0))continue;const p=o.length,f=Rr(1===g,t.get(),e,s,r,a,h);(0,i.g)(f>0),u+=f;const x=g===l-1,y=n[c],P=t.get().getSweepAngle()/m.getSweepAngle();for(let t=p,e=o.length;t<e;t++)if(o[t]=!x||t+1<e?y+o[t]*P:1,a){const e=3*t,s=m.getCoord2D(o[t]);a[e].setCoordsPoint2D(s),e>0&&Vn(a.slice(e-3))}c=g}return u}}return Rr(!0,m,e,s,r,a,h)}if(l===i.G.enumRationalBezier2){const i=t;if(r&&(o||!i.isMonotoneQuickAndDirty())){const n=[];n.length=6;let r=i.getMonotonicPartParams(n.length,n);n.length=r,r=Vr(t,s,n),2===r&&o&&(n[1]=.5,n.push(1),r=3);let m=0;if(r>2){const t=new ra,o=h||[];for(let l=1;l<r;l++){const u=n[l-1],c=n[l];i.queryCut(u,c,t,!0);const g=o.length;m+=Yr(1===l,t.get(),e,s,!1,a,h);const _=l===r-1,d=n[l-1];for(let t=g,e=o.length;t<e;t++)if(o[t]=!_||t+1<e?d+o[t]:1,a){const e=3*t,s=i.getCoord2D(o[t]);a[e].setCoordsPoint2D(s),e>0&&nn(a.slice(e-3))}}return m}}return Yr(!0,i,e,s,r,a,h)}if(l===i.G.enumBezier2){const i=t,m=(0,n.m)(n.P,3);i.queryControlPoints(m);const l=new pn;return l.constructFromQuadratic(m),Gr(l,e,s,r,o,a,h)}(0,i.a)("")}function qr(t,e,s,r,o,a,h,m,l){const u=t.getGeometryType();if(a&&(a.length=0,h.length=0),m&&(m.length=0),u===i.G.enumEllipticArc){const e=t;if(e.isDegenerateToLine()||e.isDegenerate(0))return a&&(a.push(t.getStartXY()),a.push(n.P.getNAN()),a.push(t.getEndXY()),h.push(Number.NaN),h.push(Number.NaN),h.push(Number.NaN)),m&&(m.push(0),m.push(1)),1}const c=(0,n.a)(9,Number.NaN);let g;if(o)g=t.getMonotonicPartParams(c.length,c),c.length=g,g=Vr(t,s,c);else{if(g=2,c[0]=0,c[1]=1,u===Nr.type){const e=t.getSweepAngle();if(e>.9*Math.PI){const t=2*Math.PI/3;Math.min(3,Math.trunc(e/t+.5))>2?(c[0]=0,c[1]=1/3,c[2]=2/3,c[3]=1,g=4):(c[0]=0,c[1]=.5,c[2]=1,g=3)}}else(0,i.g)(u===as.type);c.length=g}if(2===g&&r&&(c[1]=.5,c.push(1),g=3),a){const e=new ra;let s=1;for(;s<g;){const r=c[s-1],m=c[s];t.queryCut(r,m,e,!0);const l=(0,n.m)(n.P,3),_=[1,1,1];if(u===i.G.enumEllipticArc){const t=e.get();if(Math.abs(t.getSweepAngle())>.9*Math.PI){const t=(m-r)/3;c.splice(s,0,r+t),c.splice(s+1,0,r+2*t),g+=2;continue}_[1]=_o(t,l)}else{const t=e.get();t.queryControlPoints(l),t.queryWeights(_)}o&&ci(l),1===s&&(a.push(l[0].clone()),h.push(_[0])),a.push(l[1].clone()),a.push(l[2].clone()),h.push(_[1]),h.push(_[2]),s++}}return m&&(m.length=g,(0,n.D)(m,c,0,0,g)),g-1}Ar.type=i.G.enumPolygon;class Fr{static constructDefault(t){return new Fr(0,0,0,t,!1,(0,n.o)())}constructor(t,e,s,r,o,a){this.m_segmentBuffer=null,this.m_dummyPoint=new Nt,this.m_progressCounter=0,this.m_progressTracker=r,this.m_bSetDensifyFlag=o,this.m_maxLength=t,this.m_maxDeviation=e,this.m_maxAngle=s>(0,n.ae)()?(0,n.ae)():s,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_maxSegmentsPerCurve=a,(0,i.A)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve}densify(t){return this.densifyGeom(t)}densifySegment(t,e){this.densifySegmentEx(t,null,!0,!1,e)}densifyEx(t,e,s,r,o,a){return this.m_maxLength=e,this.m_maxDeviation=s,this.m_maxAngle=r>(0,n.ae)()?(0,n.ae)():r,this.m_cosMaxAngle=Math.cos(this.m_maxAngle),this.m_bOnlyCurveDensify=this.m_maxAngle>0||this.m_maxDeviation>0,this.m_bSetDensifyFlag=o,this.m_maxSegmentsPerCurve=a,(0,i.A)(this.m_maxSegmentsPerCurve>0,"this.m_maxSegmentsPerCurve > 0"),this.m_minStep=1/this.m_maxSegmentsPerCurve,this.densifyGeom(t)}densifyGeom(t){if(t.isEmpty()||t.getDimension()<1)return t;const e=t.getGeometryType();return(0,i.q)(e)?t:(0,i.f)(e)?this.densifyMultiPath(t):(0,i.e)(e)?this.densifySegmentImpl(t):e===i.G.enumEnvelope?this.densifyEnvelope(t):void(0,i.b)("")}densifySegmentEx(t,e,s,n,r){const o=t.getGeometryType();if(!(this.m_maxLength>0||this.m_bOnlyCurveDensify&&o!==i.G.enumLine)&&(!n||s))return void(e?o===i.G.enumLine?e.addSegment(t,s):(s&&(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)),t.queryEnd(this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint)):(s&&r.push(0),r.push(1)));if(o===i.G.enumBezier)return void this.densifyCubicBezier(t,e,s,n,r);if(o===i.G.enumRationalBezier2)return void this.densifyRationalBezier2(t,e,s,n,r);if(o===i.G.enumBezier2)return void this.densifyBezier2(t,e,s,n,r);if(o===i.G.enumEllipticArc&&!t.isLine()&&t.getMinorMajorRatio()<.25)return void this.densifyEllipticArc(t,e,s,n,r);let a=1;this.m_maxLength>0&&(a=this.calculateLengthSubdivisionStep(t,this.m_maxLength)),this.m_maxDeviation>0&&(a=Math.min(a,this.calculateDeviationSubdivisionStep(t,this.m_maxDeviation))),this.m_maxAngle>0&&(a=Math.min(a,this.calculateAngularSubdivisionStep(t,this.m_maxAngle))),this.densifySegmentByLength(t,a,e,s,n,r)}densifyMultiPath(t){if(!t.hasNonLinearSegments()){if(1===t.getDescription().getAttributeCount())return this.densifyMultiPathLinear(t);if(!(this.m_maxLength>0))return t}const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=t.getImpl().querySegmentIterator();for(;s.nextPath();){let t=!0;for(;s.hasNextSegment();){const i=s.nextSegment(),n=s.isClosingSegment();this.densifySegmentEx(i,e,t,n,null),n&&e.closePathWithLine(),t=!1}}return e}densifySegmentImpl(t){const e=new pr({vd:t.getDescription()});return this.densifySegmentEx(t,e,!0,!1,[0]),e}densifyEnvelope(t){const e=new Ar({vd:t.getDescription()});e.addEnvelope(t,!1);const s=o.constructEmpty();t.queryEnvelope(s);const i=s.width(),n=s.height();return!(this.m_maxLength>0)||i<=this.m_maxLength&&n<=this.m_maxLength?e:this.densifyMultiPath(e)}densifyMultiPathLinear(t){if(!(this.m_maxLength>0))return t;const e=t.createInstance();e.getGeometryType()===i.G.enumPolygon&&e.setFillRule(t.getFillRule()),e.reserve(t.getPointCount());const s=e.getImpl(),r=t.getImpl(),o=r.getAttributeStreamRef(0),a=new na;for(let t=0,i=r.getPathCount();t<i;t++){const i=r.isClosedPath(t);if(0===r.getPathSize(t))continue;const h=r.getPathStart(t),m=o.readPoint2D(2*h),l=m.clone();s.startPath(m);for(let i=h+1,m=r.getPathEnd(t);i<m;i++){const t=o.readPoint2D(2*i),r=n.P.distance(l,t);if(r>this.m_maxLength){let e=Math.ceil(r/this.m_maxLength);e>(0,n.o)()&&(e=(0,n.o)());const i=1/e;let o,h,m;l.compare(t)<0?(a.setStartXY(l),a.setEndXY(t),o=0,h=1):(a.setStartXY(t),a.setEndXY(l),o=e-2,h=-1);for(let t=0,r=e-1;t<r;t++,o+=h){this.progress_(),m=i*(o+1);const t=new n.P;a.queryCoord2D(m,t),s.lineTo(t),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}}else this.progress_();e.lineTo(t),l.assign(t)}if(i){const t=n.P.distance(l,m);if(t>this.m_maxLength){const e=m;let i=Math.ceil(t/this.m_maxLength);i>(0,n.o)()&&(i=(0,n.o)());const r=1/i;let o,h;l.compare(e)<0?(a.setStartXY(l),a.setEndXY(e),o=0,h=1):(a.setStartXY(e),a.setEndXY(l),o=i-2,h=-1);const u=new n.P(0,0);let c;for(let t=0,e=i-1;t<e;t++,o+=h)this.progress_(),c=r*(o+1),a.queryCoord2D(c,u),s.lineTo(u),this.m_bSetDensifyFlag&&s.setAttribute(10,s.getPointCount()-1,0,1)}s.closePathWithLine()}}return e}densifySegmentByLength(t,e,s,r,o,a){(0,i.g)(t.getGeometryType()!==i.G.enumBezier);let h=t.getStartXY().compare(t.getEndXY());0===h&&e<1&&(t.getGeometryType()===i.G.enumEllipticArc?h=t.getSweepAngle()<0?1:-1:(0,i.a)("densify segment by length"));let m=0;if(r&&(s?(t.queryStart(this.m_dummyPoint),s.startPathPoint(this.m_dummyPoint)):a.push(0),++m),e*this.m_maxSegmentsPerCurve<1&&(e=1/this.m_maxSegmentsPerCurve),e<1){this.m_segmentBuffer||(this.m_segmentBuffer=new ra);let i=Math.ceil(1/e);i>(0,n.o)()&&(i=(0,n.o)()),e=1/i,this.m_segmentBuffer.create(t.getGeometryType());let r,o,l,u=t;h<0?(r=0,o=1):(t.copyTo(this.m_segmentBuffer.get()),this.m_segmentBuffer.get().reverse(),r=i-2,o=-1,u=this.m_segmentBuffer.get());const c=i-1;for(let t=0;t<c;t++,r+=o)l=e*(r+1),s?(u.queryCoord(l,this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==l&&0!==l&&s.setAttribute(10,s.getPointCount()-1,0,1)):a.push(h>0?1-l:l),this.progress_();l=1,m+=c}(!o||o&&r&&m<2)&&(s?(t.queryEnd(this.m_dummyPoint),s.lineToPoint(this.m_dummyPoint)):a.push(1))}densifyCubicBezier(t,e,s,i,r){const o=new pn;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());if(0===m&&h>0){const e=(0,n.m)(n.P,4);t.queryControlPoints(e),m=e[1].compare(e[2]),0===m&&(m=e[1].compare(e[0]))}m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++l);const u=[],c=[],g=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve));let _=!0,d=0;if(m>0)for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),c.push(0);u.length;){this.progress_();const t=u.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){_&&(d=a.findMinDeriv(),_=!1);let e=.5*(h+m);Math.abs(d-e)<.4*(m-h)&&(e=d);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),r=t[1].mul(1-s).add(t[2].mul(s)),l=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(r.mul(s)),p=r.mul(1-s).add(l.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[3];t[1]=i,t[2]=g,t[3]=f,t[4].setCoords(h,e);const y=[f,p,l,x,new n.P(e,m)];u.push(y),c[c.length-1]=o+1,c.push(o+1)}else u.pop(),c.pop(),(u.length>0||!i||i&&s&&l<2)&&(e?(a.queryCoord(h,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==h&&0!==h&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(1-h),++l)}else for(u.push([a.getStartXY(),a.getControlPoint1(),a.getControlPoint2(),a.getEndXY(),new n.P(0,1)]),c.push(0);u.length;){this.progress_();const t=u.at(-1),o=c.at(-1),h=t[4].x,m=t[4].y;if(o<g&&this.bezierNeedsSplit(t)){_&&(d=a.findMinDeriv(),_=!1);let e=.5*(h+m);Math.abs(d-e)<.4*(m-h)&&(e=d);const s=(e-h)/(m-h),i=t[0].mul(1-s).add(t[1].mul(s)),r=t[1].mul(1-s).add(t[2].mul(s)),l=t[2].mul(1-s).add(t[3].mul(s)),g=i.mul(1-s).add(r.mul(s)),p=r.mul(1-s).add(l.mul(s)),f=g.mul(1-s).add(p.mul(s)),x=t[0];t[0]=f,t[1]=p,t[2]=l,t[4].setCoords(e,m);const y=[x,i,g,f,new n.P(h,e)];u.push(y),c[c.length-1]=o+1,c.push(o+1)}else u.pop(),c.pop(),(u.length>0||!i||i&&s&&l<2)&&(e?(a.queryCoord(m,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==m&&0!==m&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(m),++l)}}densifyRationalBezier2(t,e,s,i,r){const o=new as;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++l);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new as,g=[],_=[];for(g.push(new n.E(0,1)),_.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=_.at(-1);if(o<u&&this.rationalBezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),_[_.length-1]=o+1,_.push(o+1)}else if(g.pop(),_.pop(),g.length>0||!i||i&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(m>0?1-s:s),++l}}}densifyBezier2(t,e,s,i,r){const o=new rs;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=0),m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++l);const u=Math.ceil(Math.log2(this.m_maxSegmentsPerCurve)),c=new rs,g=[],_=[];for(g.push(new n.E(0,1)),_.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=_.at(-1);if(o<u&&this.bezier2NeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),_[_.length-1]=o+1,_.push(o+1)}else if(g.pop(),_.pop(),g.length>0||!i||i&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(m>0?1-s:s),++l}}}densifyEllipticArc(t,e,s,i,r){const o=new Nr;let a=t;const h=t.calculateUpperLength2D();let m=t.getStartXY().compare(t.getEndXY());0===m&&h>0&&(m=t.isClockwise()?0:1),m>0&&(t.copyTo(o),o.reverse(),a=o);let l=0;s&&(e?(t.queryStart(this.m_dummyPoint),e.startPathPoint(this.m_dummyPoint)):r.push(0),++l);const u=Math.trunc(Math.log2(this.m_maxSegmentsPerCurve)),c=new Nr,g=[],_=[];for(g.push(new n.E(0,1)),_.push(0);g.length;){this.progress_();const t=g.at(-1).clone(),o=_.at(-1);if(o<u&&this.ellipticArcNeedsSplit(a,c,t.vmin,t.vmax)){const e=t.getCenter();m>0?(g.at(-1).vmax=e,g.push(new n.E(e,t.vmax))):(g.at(-1).vmin=e,g.push(new n.E(t.vmin,e))),_[_.length-1]=o+1,_.push(o+1)}else if(g.pop(),_.pop(),g.length>0||!i||i&&s&&l<2){const s=m>0?t.vmin:t.vmax;e?(a.queryCoord(s,this.m_dummyPoint),e.lineToPoint(this.m_dummyPoint),this.m_bSetDensifyFlag&&1!==s&&0!==s&&e.setAttribute(10,e.getPointCount()-1,0,1)):r.push(m>0?1-s:s),++l}}}calculateLengthSubdivisionStep(t,e){const s=t.calculateUpperLength2D();if(!t.isCurve())return s?e/s:1;if(t.getGeometryType()===i.G.enumEllipticArc){const i=t;if(i.isCircular()||i.isDegenerate(0)||i.isDegenerateToLine()){let t=e/s;return t<this.m_minStep&&(t=this.m_minStep),t}return e/s*i.getSemiAxes().y/i.getSemiAxes().x}t.getGeometryType()===i.G.enumBezier&&(0,i.a)(""),(0,i.a)("")}calculateDeviationSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;if(s.isDegenerate(0)||s.isDegenerateToLine())return 1;{const i=s.getSemiMajorAxis(),n=1-e/i;let r=Math.PI/2;if(n>0){const t=4*Math.sqrt(e/i*.5);r=Math.min(Math.PI/2,Math.abs(t))}r=Math.max(r,2*Math.PI/this.m_maxSegmentsPerCurve);const o=r*i;return this.calculateLengthSubdivisionStep(t,o)}}(0,i.a)("")}calculateAngularSubdivisionStep(t,e){if(!t.isCurve())return 1;if(t.getGeometryType()===i.G.enumEllipticArc){const s=t;return s.isDegenerate(0)||s.isDegenerateToLine()?1:this.calculateLengthSubdivisionStep(t,e*s.getSemiMinorAxis())}(0,i.a)("")}rationalBezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;const o=(0,n.m)(n.P,3);e.queryControlPoints(o);const a=[0,0,0];return e.queryWeights(a),!r&&this.m_maxDeviation>0&&(r=!Fr.checkRationalBezier2MaxDeviation(o,a,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!Fr.checkRationalBezier2MaxAngle(o,a,this.m_cosMaxAngle)),r}bezier2NeedsSplit(t,e,s,i){t.cutBezierIgnoreAttributes(s,i,e);let r=!1;if(this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength)return r=!0,!0;const o=(0,n.m)(n.P,3);return e.queryControlPoints(o),!r&&this.m_maxDeviation>0&&(r=!Fr.checkBezier2MaxDeviation(o,this.m_maxDeviation)),!r&&this.m_maxAngle>0&&(r=!Fr.checkBezier2MaxAngle(o,this.m_cosMaxAngle)),r}ellipticArcNeedsSplit(t,e,s,i){t.cutArcIgnoreAttributes(s,i,e);let n=!1;return this.m_maxLength>0&&e.calculateUpperLength2D()>this.m_maxLength?(n=!0,!0):(!n&&this.m_maxDeviation>0&&(n=!Fr.checkEllipticArcMaxDeviation(e,this.m_maxDeviation)),!n&&this.m_maxAngle>0&&(n=!Fr.checkEllipticArcMaxAngle(e,this.m_cosMaxAngle)),n)}bezierNeedsSplit(t){let e=!1;return this.m_maxLength>0&&n.P.distance(t[0],t[1])+n.P.distance(t[1],t[2])+n.P.distance(t[2],t[3])>this.m_maxLength?(e=!0,!0):(!e&&this.m_maxDeviation>0&&(e=!Fr.checkBezierMaxDeviation(t,this.m_maxDeviation)),!e&&this.m_maxAngle>0&&(e=!Fr.checkBezierMaxAngle(t,this.m_cosMaxAngle)),e)}progress_(){}static checkBezierMaxDeviation(t,e){const s=t[3].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const r=i.dotProduct(t[0].sub(t[1])),o=i.dotProduct(t[0].sub(t[2]));if(Math.max(Math.abs(r),Math.abs(o))<=e){const e=new n.P;kn(t,.5,e,!1);const i=e.sub(t[0]).dotProduct(s);return i>=0&&i<=s.sqrLength()}return!1}return Math.max(t[0].sub(t[1]).sqrLength(),t[0].sub(t[2]).sqrLength())<=e*e}static checkBezierMaxAngle(t,e){if(t[0].equals(t[3]))return!(!t[0].equals(t[1])||!t[1].equals(t[2]));const s=t[3].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}{const i=t[2].sub(t[1]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkRationalBezier2MaxDeviation(t,e,s){if(0===e[1])return!1;const i=t[2].sub(t[0]);if(i.sqrLength()>0){const e=i.clone();e.leftPerpendicularThis(),e.normalize();const n=e.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=s){const e=t[1].sub(t[0]).dotProduct(i);return e>=0&&e<=i.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=s*s}static checkRationalBezier2MaxAngle(t,e,s){if(0===e[1])return!1;if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const i=t[2].sub(t[0]);i.normalize();{const e=t[1].sub(t[0]),n=e.dotProduct(i);if(n<0)return!1;if(e.length()*s>n)return!1}return!0}static checkBezier2MaxDeviation(t,e){const s=t[2].sub(t[0]);if(s.sqrLength()>0){const i=s.clone();i.leftPerpendicularThis(),i.normalize();const n=i.dotProduct(t[0].sub(t[1]));if(Math.abs(n)<=e){const e=t[1].sub(t[0]).dotProduct(s);return e>=0&&e<=s.sqrLength()}return!1}return t[0].sub(t[1]).sqrLength()<=e*e}static checkBezier2MaxAngle(t,e){if(t[0].equals(t[2]))return!!t[0].equals(t[1]);const s=t[2].sub(t[0]);s.normalize();{const i=t[1].sub(t[0]),n=i.dotProduct(s);if(n<0)return!1;if(i.length()*e>n)return!1}return!0}static checkEllipticArcMaxDeviation(t,e){if(Math.abs(t.getSweepAngle())<Math.PI){const s=t.getEndXY().sub(t.getStartXY()),r=[0,0];if(1===function(t,e,s){(0,i.g)(!to(t));const r=new n.T;r.setRotateAngle(-t.getAxisXRotation());const o=new n.P;r.queryTransform(e,o);const a=Math.atan2(-o.x*t.getMinorMajorRatio(),o.y),h=a+(0,n.ac)();let m=Or(t,a),l=Or(t,h);l<m&&(l=(0,n.b)(m,m=l));let u=0;return m>=0&&m<=1&&(s[u++]=m),l>=0&&l<=1&&(s[u++]=l),u}(t,s,r)){const s=t.getCoord2D(r[0]),i=n.P.getClosestCoordinate(t.getStartXY(),t.getEndXY(),s),o=new n.P;return(0,n.B)(t.getStartXY(),t.getEndXY(),i,o),n.P.distance(s,o)<=e}}const s=t.getCoord2D(.5),r=new n.P;return(0,n.B)(t.getEndXY(),t.getStartXY(),.5,r),n.P.distance(s,r)<=e}static checkEllipticArcMaxAngle(t,e){const s=t.getTangent(0),i=t.getTangent(1),n=s.dotProduct(i);return!(n<0||s.length()*i.length()*e>n)}static checkTypeForReplace(t,e){return t.getGeometryType()===e&&(e!==i.G.enumEllipticArc||t.isCircular())}}function Vr(t,e,s){const i=s.length;if(e<=0||i<=2)return i;let n=0;const r=[];r.length=i-1;for(let e=1,o=i;e<o;e++){const i=t.tToLength(s[e]);r[e-1]=i-n,n=i}for(;r.length>1;){const t=r.findIndex((t=>t<=2*e));if(-1===t)break;let i=t+1,n=t+1;if(t>0){const e=t-1;(n===r.length||r[e]>r[n])&&(n=e,i--)}r[n]+=r[t],r.splice(t,1),s.splice(i,1)}return s.length}function Rr(t,e,s,i,r,a,h,m){const l=e.clone();l.dropAllAttributes();const u=(t,e,s,i)=>(e&&(t&&e.push(i.getStartXY()),e.push(n.P.getNAN()),e.push(n.P.getNAN()),e.push(i.getEndXY())),s&&(t&&s.push(0),s.push(1)),1);if(l.isDegenerateToLine()||l.isDegenerate(0))return u(t,a,h,e);const c=l.getStartXY(),g=l.getEndXY(),_=l.getSemiAxes(),d=new n.T;if(l.isCircular())d.setIdentity();else{const t=l.getAxisXRotation();d.setScaleCoords(1,l.getMinorMajorRatio()),d.rotateAngle(t)}const p=l.getCenter();d.shift(p);const f=d.clone();f.invertThis(),l.applyTransformation(f);const x=l.getSweepAngle();if(0===x)return u(t,a,h,e);const y=o.constructEmpty();y.setCoords({center:p,width:2*_.x,height:2*_.x});const P=.05*y.calculateToleranceFromEnvelope(),E=Math.max(s/_.x,P/_.x);let C=4*Math.pow(E/.0741,1/6);C=Math.min(C,Math.PI/2);const v=Ir(l.getStartAngle());let b=x>0?Math.floor(v/C):Math.ceil(v/C);b*=C;const S=x>0?C:-C;b+S===v&&(b+=S);let I=4/3*Math.tan(Math.abs(C)/4);x>0&&(I=-I),h&&t&&h.push(0);const w=C/Math.abs(x);let D=(b-v)/x;const T=c.clone(),N=new n.P;l.queryCoord2D(0,N);const A=N.clone(),M=1-.01*w;let G=0,q=0;for(;D<1;){let s;if(D+=w,q>0&&D<M)s=I;else{D>=M&&(D=1);const t=(D-q)*x;s=4/3*Math.tan(Math.abs(t)/4),x>0&&(s=-s)}l.queryCoord2D(D,N);const o=new n.P;d.queryTransform(N,o);const m=e.getClosestCoordinate(o,!1);if(e.queryCoord2D(m,o),1!==D&&(n.P.distance(T,o)<=2*i||n.P.distance(o,g)<=2*i))continue;T.setCoordsPoint2D(o);const u=(0,n.m)(n.P,4);u[0].assign(A),u[3].assign(N),u[1].rightPerpendicularOther(A),u[1].scaleAddThis(s,A),u[2].leftPerpendicularOther(N),u[2].scaleAddThis(s,N),d.transformPoints2D(u,3,u),u[3].assign(o),0===q&&u[0].setCoordsPoint2D(c),1===D&&u[3].setCoordsPoint2D(g),r&&Vn(u);let _=!0;for(let t=1;t<4;t++)if(!u[t].isEqualPoint2D(u[0])){_=!1;break}_||(h&&h.push(m),a&&(0===q&&t&&a.push(u[0].clone()),a.push(u[1].clone()),a.push(u[2].clone()),a.push(u[3].clone())),G++),q=D,A.setCoordsPoint2D(N)}return G}function Yr(t,e,s,i,r,a,h,m){e.clone().dropAllAttributes();const l=new o;e.queryLooseEnvelope(l);const u=.05*l.calculateToleranceFromEnvelope(),c=Math.max(s,u);h&&t&&h.push(0);let g=0;const _=(0,n.m)(n.P,3);e.queryControlPoints(_);const d=[0,0,0];e.queryWeights(d);const p=[],f=(0,n.a)(9,Number.NaN);let x=0;r?(x=e.getMonotonicPartParams(f.length,f),f.length=x,x=Vr(e,i,f)):(f.length=2,x=2,f[0]=0,f[1]=1);let y=0,P=t;for(let t=1;t<x;t++){const e=f[t];for(p.length=0,p.push(e),p.push(y);p.length>1;){const t=p.at(-1);p.pop();const e=p.at(-1),s=(0,n.m)(n.P,3),i=[0,0,0];_i(_,d,t,e,s,i);const r=(0,n.m)(n.P,4),o=di(s,i,r),m=16,l=p.length>m;c>=o||l?(h.push(e),a&&(P&&(a.push(r[0]),P=!1),a.push(r[1]),a.push(r[2]),a.push(r[3])),g++):(p.push(.5*(t+e)),p.push(t))}y=e}return g}class Xr{constructor(t,e){this.m_arc=t,this.m_sqrChordLength=e}getMaxDerivative(){return 1}getValue(t,e){return 0===t?n.P.sqrDistance(this.m_arc.getCoord2D(e),this.m_arc.getCoord2D(1-e))-this.m_sqrChordLength:0}getError(t){return 0}}function kr(t,e){return t.convertToCanonic(e)}function Hr(t,e,s,i){let r=t.m_startAngle,o=t.m_sweepAngle;const a=1e-12;for(;r>(0,n.ac)();)r-=2*(0,n.ac)();for(;r<=-(0,n.ac)();)r+=2*(0,n.ac)();if(!Number.isNaN(e)){for(;e>(0,n.ac)();)e-=2*(0,n.ac)();for(;e<=-(0,n.ac)();)e+=2*(0,n.ac)();!s&&e>r&&(e-=2*(0,n.ac)()),s&&e<r&&(e+=2*(0,n.ac)()),o=e-r,Math.abs(o)<a&&!i&&(o=s?2*(0,n.ac)():-2*(0,n.ac)()),Math.abs(o)>2*(0,n.ac)()-a&&i&&(o=0)}Math.abs(o)>2*(0,n.ac)()-a&&(o=o>=0?2*(0,n.ac)():-2*(0,n.ac)(),t.setEndXY(t.getStartXY())),Math.abs(o)<a&&(o=0,t.setEndXY(t.getStartXY())),i=Math.abs(o)<=(0,n.ac)(),o&&(s=o>0),t.m_startAngle=Br(r),t.m_sweepAngle=o,mo(t,!i),ao(t,s)}function Br(t){let e=t,s=!1;return e<=-(0,n.ac)()?(e+=(0,n.af)(),s=!0):e>(0,n.ac)()&&(e-=(0,n.af)(),s=!0),e<=-(0,n.ac)()?(e=(0,n.r)(e,(0,n.af)()),e<=-(0,n.ac)()&&(e+=(0,n.af)()),s=!0):e>(0,n.ac)()&&(e=(0,n.r)(e,(0,n.af)()),e>(0,n.ac)()&&(e-=(0,n.af)()),s=!0),s&&(e>(0,n.ac)()||e<=-(0,n.ac)())&&(e=(0,n.ac)()),e}function Lr(t,e,s){const i=s,r=i.getSemiAxes();let o=new n.P(r.x*Math.cos(t[0]),r.y*Math.sin(t[0]));return o=i.convertFromCanonic(o),n.P.sqrDistance(o,i.getStartXY())}function zr(t,e,s){const i=s,r=i.getSemiAxes(),o=t[0]+i.getStartAngle();let a=new n.P(r.x*Math.cos(o),r.y*Math.sin(o));return a=i.convertFromCanonic(a),n.P.sqrDistance(a,i.getEndXY())}function Ur(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),r=lo(t),o=ho(t),a=t.projectionBehavior();if(i){const s=t.convertToCanonic(e),i=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);s.x/=i.x,s.y/=i.y,t.m_startAngle=Br(Math.atan2(s.y,s.x)),t.m_sweepAngle=r?o?(0,n.af)():-(0,n.af)():0}else{const i=t.convertToCanonic(e),h=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);i.x/=h.x,i.y/=h.y;const m=t.convertToCanonic(s);m.x/=h.x,m.y/=h.y,t.m_startAngle=Math.atan2(i.y,i.x),t.m_sweepAngle=n.P.calculateAngle(i,m),o?t.m_sweepAngle<0&&(t.m_sweepAngle+=(0,n.af)()):t.m_sweepAngle>0&&(t.m_sweepAngle-=(0,n.af)()),t.m_startAngle=Br(t.m_startAngle);let l=Lr([t.m_startAngle],0,t);if(l=Math.sqrt(l),l>.25*ce(t)){const e=t.m_startAngle-1e-4,s=t.m_startAngle+1e-4,i=[0];ze(Lr,t,1,[t.m_startAngle],[e],[s],0,i),t.m_startAngle=Br(i[0])}if(l=zr([t.m_sweepAngle],0,t),l=Math.sqrt(l),l>.25*ce(t)){const e=t.m_sweepAngle-1e-4,s=t.m_sweepAngle+1e-4,i=[0];ze(zr,t,1,[t.m_sweepAngle],[e],[s],0,i),t.m_sweepAngle=i[0]}const u=Math.abs(t.m_sweepAngle)>(0,n.ac)();if(mo(t,u),r!==u&&!r&&Math.abs(t.m_sweepAngle)>1.5*(0,n.ac)())return void $r(t,e,s,a);if(0===t.m_sweepAngle||o!==t.m_sweepAngle>0)return void $r(t,e,s,a)}}function Or(t,e){return(function(t,e){const s=new n.E(t.getStartAngle(),t.getEndAngle());s.normalize();const i=(0,n.af)(),r=(0,n.r)(e,i);if(r<s.vmin){let t=r+i;for(;t<s.vmin;)t+=i;return s.containsCoordinate(t)?t:s.vmin-r<t-s.vmax?r:t}if(r>s.vmax){let t=r-i;for(;t>s.vmax;)t-=i;return s.containsCoordinate(t)||s.vmin-t<r-s.vmax?t:r}return r}(t,e)-t.getStartAngle())/t.getSweepAngle()}function Wr(t,e){return t.m_startAngle+e*t.m_sweepAngle}function jr(t,e,s){s.assign(new n.H(t.m_startAngle).addE(e.mulE(new n.H(t.m_sweepAngle))))}function Zr(t){return t.m_cachedValues}function Qr(t){if(t.m_cachedValues)return t.m_cachedValues;const e={e2:0,completeE:0};return e.e2=function(t){return 1-(0,n.e)(t.m_minorMajorRatio)}(t),e.completeE=(0,n.ao)(e.e2),t.m_cachedValues=e,e}function Kr(t,e,s,i){if(!e.isEqual(t.m_XStart,t.m_YStart)||!s.isEqual(t.m_XEnd,t.m_YEnd)){if(to(t))return t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,Po(t),void t.afterCompletedModification();if(i&&Math.abs(t.getSweepAngle())<=1.01*(0,n.ae)()){const i=(0,n.m)(n.P,3),r=_o(t,i);if(li(i)){if(i[0].assign(e),i[2].assign(s),ci(i),0===t.projectionBehavior()){let e=0,s=2;n.P.sqrDistance(i[1],i[0])<n.P.sqrDistance(i[1],i[2])&&(s=(0,n.b)(e,e=s));const r=i[s].sub(i[e]),o=r.length();r.divThis(o);const a=i[1].sub(i[e]),h=a.length(),m=a.dotProduct(r)/h,l=a.crossProduct(r)/h,u=new n.P;(0,n.B)(i[e],i[s],.5,u);const c=.5*o/l*(0,n.l)(1-m,0,1),g=i[1].side(i[e],i[s]),_=r.clone();g?_.leftPerpendicularThis():_.rightPerpendicularThis();const d=u.sub(_.mul(c));t.constructCircularArcThreePoint(i[0],i[2],d)}else po(i,r*r,null,!1,t);return}}0===t.projectionBehavior()?function(t,e,s){const i=t.getStartXY(),r=t.getEndXY(),o=i.equals(r),a=e.equals(s);if(!o&&!a){const o=new n.T;o.setShiftCoords(-t.m_XStart,-t.m_YStart);const a=n.P.distance(e,s),h=n.P.distance(i,r),m=a/h;o.scale(m,m);const l=r.sub(i);l.divThis(h);const u=s.sub(e);u.divThis(a);const c=l.crossProduct(u),g=u.dotProduct(l);return o.rotate(g,c),o.shiftCoords(e.x,e.y),io(t,o,!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 n.P;if(t.queryCoord2D(.5,h),a){if(o){const n=t.m_center.add(e.sub(i));t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),1,0,!0,!t.isClockwise(),n),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),l=s.sub(e);l.rightPerpendicularThis();const u=m.add(l),c=n.P.getClosestCoordinate(m,u,t.getCenter(),!0),g=new n.P;(0,n.B)(m,u,c,g);const _=n.P.distance(e,g);t.constructEllipticArcEndPointsCenter(e,s,_,1,0,!0,!t.isClockwise(),g),t.setProjectionBehavior(0)}(t,e,s):wo(t,e,s)}}function Jr(t,e,s,i,n,r,o,a,h){return t.m_bits=0,t.m_rotation=r,ee(t,e),ie(t,s),t.m_cosr=Math.cos(r),t.m_sinr=Math.sin(r),mo(t,o),ao(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,go(t,void 0===h)}function $r(t,e,s,i){t.m_bits=0,t.m_rotation=0,ee(t,e),ie(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,mo(t,!1),ao(t,!1),t.m_center.setNAN(),t.m_semiMajorAxis=1,t.m_minorMajorRatio=0,t.setProjectionBehavior(i),t.afterCompletedModification()}function to(t){return t.m_center.isNAN()}function eo(t,e){if(0===e)return 0;const s=Qr(t),i=Wr(t,e),r=(0,n.ae)(),o=so(t),a=(0,n.ag)(i+r,s.e2,s.completeE),h=t.m_semiMajorAxis*(a-o);return Math.abs(h)}function so(t){const e=Qr(t);return(0,n.ag)(t.getStartAngle()+(0,n.ae)(),e.e2,e.completeE)}function io(t,e,s){if(2===e.m_TransformationType)return void(0,i.g)(0);if((0,i.g)(!uo(t)),e.isIdentity())return;oo(t);const r=n.P.getNAN();r.x=t.m_XStart,r.y=t.m_YStart,e.transformInPlace(r);const o=n.P.getNAN();if(o.x=t.m_XEnd,o.y=t.m_YEnd,e.transformInPlace(o),to(t))return t.m_XStart=r.x,t.m_YStart=r.y,t.m_XEnd=o.x,void(t.m_YEnd=o.y);const a=t.m_center.clone();if(e.transformInPlace(a),s||e.isUniformNoRotation()){let s=ho(t);if(e.isReflective()&&(s=!s),0===t.projectionBehavior()){if(!r.equals(o)){const s=t.m_interior.clone();return e.transformInPlace(s),void t.constructCircularArcThreePoint(r,o,s)}return void no(t,r,o,a,s,!1)}const i=new n.P(t.m_cosr,t.m_sinr);e.transformWithoutTranslateInPlace(i);const h=Math.atan2(i.y,i.x),m=t.getSemiAxes();e.transformWithoutTranslateInPlace(m);const l=t.m_center.clone();return e.transformInPlace(l),void t.constructEllipticArcEndPointsCenter(r,o,m.x,m.y/m.x,h,t.isMajor(),s,l)}{{const s=new Array(4);!function(t,e){const s=new n.H(t.m_cosr).sqrThis(),i=new n.H(t.m_sinr).sqrThis(),r=new n.H(t.m_minorMajorRatio),o=new n.H(1/t.m_minorMajorRatio),a=r.mulE(s).addThisE(o.mulE(i)),h=r.subE(o).mulThis(2*t.m_cosr*t.m_sinr),m=r.mulE(i).addThisE(o.mulE(s));e[0]=a,e[1]=h,e[2]=m,e[3]=new n.H(-t.m_semiMajorAxis).mulThis(t.m_semiMajorAxis).mulThis(t.m_minorMajorRatio)}(t,s);const i=new jt;if(i.a11.setE(s[0]),i.a12.setE(s[1]),i.a12.mulThisByPower2(.5),i.a21.setE(i.a12),i.a22.setE(s[2]),!i.det().isZero()){const h=new jt;if(h.a11.set(e.xx),h.a12.set(e.xy),h.a21.set(e.yx),h.a22.set(e.yy),h.invertThis()){const m=h.clone();m.transposeThis();const l=i.clone();if(l.mulThis(h),l.mulLeftThis(m),!l.det().isZero()){const i=(0,n.m)(n.H,4);i[0].setE(l.a11),i[1].setE(l.a12),i[1].mulThisByPower2(2),i[2].setE(l.a22),i[3].setE(s[3]);const h=n.P.getNAN(),m=function(t,e){const s=new jt;s.a11.setE(t[0]),s.a12=n.H.st_mulByPower2(t[1],.5),s.a21.setE(s.a12),s.a22.setE(t[2]);const i=[n.P.getNAN(),n.P.getNAN()],r=[new n.H,new n.H];s.eigenSymmetric(r,i);const o=t[3].clone();return o.negateThis(),o.invThis(),r[0].mulThisE(o),r[1].mulThisE(o),r[0].sqrtThis().invThis(),r[1].sqrtThis().invThis(),e.x=r[0].toDouble(),e.y=r[1].toDouble(),Math.atan2(i[0].y,i[0].x)}(i,h);let u=ho(t);return e.isReflective()&&(u=!u),void t.constructEllipticArcEndPointsCenter(r,o,h.x,h.y/h.x,m,t.isMajor(),u,a)}}}}const s=[n.P.getNAN(),n.P.getNAN(),n.P.getNAN()];s[0].setCoords(t.getSemiMajorAxis(),0),s[0].rotateDirect(t.m_cosr,t.m_sinr),s[1].setCoords(t.getSemiMajorAxis(),t.getSemiMinorAxis()),s[1].rotateDirect(t.m_cosr,t.m_sinr),s[2].setCoords(0,t.getSemiMinorAxis()),s[2].rotateDirect(t.m_cosr,t.m_sinr);let i=t.isClockwise();i&&(s[2]=(0,n.b)(s[0],s[0]=s[2]));const h=.5;e.transformWithoutTranslateArray(s,3,s),e.isReflective()&&(i=!i);const m=new n.P(0,0),l=t.createInstance();po(s,h,m,!1,l),t.constructEllipticArcEndPointsCenter(r,o,l.getSemiMajorAxis(),l.getMinorMajorRatio(),l.getAxisXRotation(),t.isMajor(),!i,a)}}function no(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),Hr(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 ro(t,e){t.m_cachedValues=e}function oo(t){t.m_cachedValues=null}function ao(t,e){const s=e?1:0;t.m_bits=-2&t.m_bits|s}function ho(t){return!!(1&t.m_bits)}function mo(t,e){const s=e?1:0;t.m_bits=-3&t.m_bits|s<<1}function lo(t){return!!(2&t.m_bits)}function uo(t){return!!(8&t.m_bits)}function co(t){t.m_bits&=-9}function go(t,e){co(t);const s=t.getStartXY(),r=t.getEndXY();let o=!1;const a=lo(t),h=ho(t),m=t.projectionBehavior(),l=s.equals(r);let u=0===t.m_minorMajorRatio||0===t.m_semiMajorAxis;if(Number.isNaN(t.m_minorMajorRatio)&&(0===t.m_semiMajorAxis?t.m_minorMajorRatio=1:(0,i.o)("NAN minor major ratio and non-zero major axis")),u||=e?l:t.m_center.isNAN(),u)return $r(t,s,r,m),!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 c=new n.P(t.m_semiMajorAxis,t.m_semiMajorAxis*t.m_minorMajorRatio);if(l){const e=t.convertToCanonic(s);e.x/=c.x,e.y/=c.y;const i=Math.sqrt((0,n.e)(e.x)+(0,n.e)(e.y));if(o=1!==i,t.m_semiMajorAxis*=i,c.mulThis(i),t.m_startAngle=Br(Math.atan2(e.y,e.x)),!a)return t.m_interior.assign(s),t.m_sweepAngle=0,t.afterCompletedModification(),o;t.m_sweepAngle=h?(0,n.af)():-(0,n.af)()}else{let e=t.m_center.isNAN()||function(t){if(t.m_center.isNAN())return!1;const e=new Wt;e.setWithEps(t.getStartXY(),8),e.subThisE((new Wt).setWithEps(t.m_center,8));const s=new n.H;s.setWithEps(t.m_rotation,8);const i=new n.H,r=new n.H;n.H.st_cosAndSin(s,i,r),e.rotateReverse(i,r);const o=new Wt;o.setWithEps(t.getEndXY()),o.subThisE(Wt.constructPoint2D(t.m_center)),o.rotateReverse(i,r);const a=new n.H;a.setWithEps(t.m_semiMajorAxis,8);const h=a.clone(),m=new n.H;m.setWithEps(t.m_minorMajorRatio),h.mulThisE(m),e.x.divThisE(a),e.y.divThisE(h),o.x.divThisE(a),o.y.divThisE(h);const l=e.x.sqr().addThisE(e.y.sqr()).subThisE(n.ai),u=o.x.sqr().addThisE(o.y.sqr()).subThisE(n.ai);return!l.isZero()||!u.isZero()}(t);if(!e){const i=t.convertToCanonic(s);i.x/=c.x,i.y/=c.y;const o=new n.P(1,0);t.m_startAngle=n.P.calculateAngle(o,i);const a=t.convertToCanonic(r);a.x/=c.x,a.y/=c.y,t.m_sweepAngle=n.P.calculateAngle(i,a),e=!xo(t)}if(e){o=!0;const e=s.sub(r).mulThis(.5);e.rotateReverse(t.m_cosr,t.m_sinr);let i=(0,n.e)(e.x/c.x)+(0,n.e)(e.y/c.y);i>1&&(i=Math.sqrt(i),t.m_semiMajorAxis*=i,c.mulThis(i));const m=new n.P(0,0);{const t=c.x*c.x,s=c.y*c.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);m.setCoords(c.x*e.y/c.y,-c.y*e.x/c.x),m.mulThis(t),a===h&&m.negateThis()}}{const e=new n.P(m.x,m.y);e.rotateDirect(t.m_cosr,t.m_sinr),e.addThis(s.add(r).mulThis(.5)),t.m_center.assign(e)}}if(Ur(t),!xo(t))return $r(t,s,r,m),!0}return Po(t),t.afterCompletedModification(),o}function _o(t,e){(0,i.g)(Math.abs(t.getSweepAngle())<15*Math.PI/16);const s=t.getSemiMajorAxis(),r=t.getSemiMinorAxis();let o;if(0===s)return e[0].setCoordsPoint2D(t.getStartXY()),e[1].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getStartXY()),o=1,o;if(0===r)return e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1]=n.P.lerp(e[0],e[2],.5),o=1,o;const a=t.getSweepAngle(),h=t.getStartAngle(),m=h+a,l=new n.P(-s*Math.sin(h),r*Math.cos(h)),u=new n.P(-s*Math.sin(m),r*Math.cos(m));l.normalize(),u.normalize(),l.rotateDirect(t.m_cosr,t.m_sinr),u.rotateDirect(t.m_cosr,t.m_sinr),e[0].setCoordsPoint2D(t.getStartXY()),e[2].setCoordsPoint2D(t.getEndXY()),e[1].setSub(e[2],e[0]);const c=l.crossProduct(u);return e[1].assign(l.mul(e[1].crossProduct(u)/c)),e[1].addThis(e[0]),o=Math.cos(.5*a),o}function po(t,e,s,r,o){if(r){const s=.5,i=Math.sqrt(e),r=(0,n.e)(1-s)+2*i*s*(1-s)+(0,n.e)(s),a=t[0].mul((0,n.e)(1-s)).add(t[1].mul(2*i*s*(1-s))).add(t[2].mul((0,n.e)(s))).divThis(r);return o.constructCircularArcThreePoint(t[0],t[2],a),!0}const a=t[0].sub(t[1]),h=t[2].sub(t[1]),m=a.crossProduct(h),l=a.dotProduct(h),u=e;(0,i.g)(u<=1),(0,i.g)(u>0);const c=.5/(1-u),g=a.sqrLength(),_=l,d=h.sqrLength(),p=(0,n.e)(m),f=a.sub(h).sqrLength();if(0===p)return $r(o,t[0],t[2],1),!1;if(l<=-Math.sqrt(g)*Math.sqrt(d))return $r(o,t[0],t[2],1),!1;const x=[0,0],y=new n.E;y.setInfinite();const P=Be(2*p,-(f/u+4*_),2*(1-u)/u,y,!1,x);if(0===P)return $r(o,t[0],t[2],1),!1;1===P&&(x[1]=x[0]);const E=Math.sqrt(c/x[0]),C=Math.sqrt(c/x[1]),v=.5/u;let b=v-d*x[0],S=v-g*x[0];Math.abs(b)>Math.abs(S)?S=_*x[0]-v+1:b=_*x[0]-v+1;const I=a.mul(b).add(h.mul(S)),w=I.norm(1)<1e-15*E?0:Math.atan2(I.y,I.x)+Math.PI,D=a.add(h),T=s?s.clone():t[1].add(D.mul(c)),N=t[0].sub(T),A=t[2].sub(T),M=N.crossProduct(A)<0;return new Nr,o.constructEllipticArcEndPointsCenter(t[0],t[2],E,C/E,w,!1,!M,T)}function fo(t,e,s,i,n){return po(t,e,s,i,n)}function xo(t){let e=!1;{const s=new n.P(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=n.P.distance(t.getStartXY(),s)>ce(t)}let s=!1;if(!e){const e=new n.P(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=n.P.distance(t.getEndXY(),e)>ce(t)}return!e&&!s}function yo(t){if(to(t))return 0;if(t.isDegenerate(0))return 0;const e=t.m_semiMajorAxis,s=t.getSemiMinorAxis(),i=e*e+s*s,n=t.getStartAngle(),r=t.getEndAngle(),o=t.m_center.y-t.m_YStart,a=t.m_cosr,h=t.m_sinr;let m=1,l=0;t.m_rotation&&(m=(a-h)*(a+h),l=2*a*h);const u=((-.5*(r-n)+.25*m*(2*Math.cos(r+n)*Math.sin(r-n)))*s+-2*Math.sin(.5*(r+n))*Math.sin(.5*(r-n))*a*o)*e/i;let c=0;return t.m_rotation&&(c=-2*Math.sin(r+n)*Math.sin(r-n)*.125*l-s*o/i*(2*Math.cos(.5*(r+n))*Math.sin(.5*(r-n)))*h),i*(u+c)+-.5*(t.m_XEnd-t.m_XStart)*(t.m_YEnd-t.m_YStart)}function Po(t){t.queryCoord2D(.5,t.m_interior)}function Eo(t,e,s,i,n){if(n){if(0!==Qo(e,s))return 2}else if(Qt(e,s))return 1;return 0!==Co(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}function Co(t,e,s,r,o,a,h,m,l,u){if(to(e))return De(new na({start:e.getStartXY(),end:e.getEndXY()}),s,r,o,a,h,m,u);null!==o&&(o.length=0),null!==a&&(a.length=0),null!==r&&(r.length=0);const c=ge(e,s);if(_e(e,s,h=Math.max(c,h)))return 0;const g=s.getStartXY();g.subThis(e.m_center);const _=s.getEndXY();_.subThis(e.m_center),g.rotateReverse(e.m_cosr,e.m_sinr),_.rotateReverse(e.m_cosr,e.m_sinr);const d=_.clone();d.subThis(g);const p=e.m_semiMajorAxis,f=1/p,x=e.getSemiMinorAxis(),y=1/x,P=d.clone();P.leftPerpendicularThis();const E=Math.atan2(x*P.y,p*P.x),C=new Array(16),v=new Array(16);let b=0;const S=[E,E+Math.PI];for(let t=0;t<2;++t){const i=Or(e,S[t]);if(i>=0&&i<=1){C[b]=i;const t=e.getCoord2D(C[b]);v[b]=s.getClosestCoordinate(t,!1),n.P.distance(t,s.getCoord2D(v[b]))<=h&&b++}}const I=g.x*f,w=g.y*y,D=d.x*f,T=d.y*y;let N=Be(D*D+T*T,2*(I*D+w*T),I*I+w*w-1,n.E.unit(),!1,v);(0,i.g)(N>=0);for(let t=0;t<N;t++){const i=d.mul(v[t]).add(g);i.x*=f,i.y*=y;const r=Or(e,Math.atan2(i.y,i.x));if(r>=0&&r<=1){C[b]=r;const t=e.getCoord2D(r);v[b]=s.getClosestCoordinate(t,!1),n.P.distance(t,s.getCoord2D(v[b]))<=h&&b++}}(0,i.g)(b<C.length+4);const A=new Array(16);N=e.intersectPoint(s.getStartXY(),A,h);for(let t=0;t<N;t++,b++)C[b]=A[t],v[b]=0;N=e.intersectPoint(s.getEndXY(),A,h);for(let t=0;t<N;t++,b++)C[b]=A[t],v[b]=1;N=s.intersectPoint(e.getStartXY(),A,h);for(let t=0;t<N;t++,b++)C[b]=0,v[b]=A[t];N=s.intersectPoint(e.getEndXY(),A,h);for(let t=0;t<N;t++,b++)C[b]=1,v[b]=A[t];return 0===b?0:ta(t,e,s,C,v,b,r,o,a,h,m,0,u)}function vo(t,e,s,r,o,a,h,m,l,u){if(to(e)){const i=new na({start:e.getStartXY(),end:e.getEndXY()});return Co(t,s,i,r,a,o,h,m,0,!u)}if(to(s)){const i=new na({start:s.getStartXY(),end:s.getEndXY()});return Co(t,e,i,r,o,a,h,m,0,u)}const c=ge(e,s);h=Math.max(h,c);let g=!1;{const t=e.getSemiAxes(),r=e.getCenter(),u=s.getSemiAxes(),c=s.getCenter(),_=n.P.distance(c,r),d=t.x+u.x;if(_>d+h)return 0;if(t.y>u.x){if(_+u.x+h<t.y)return 0}else if(u.y>t.x&&_+t.x+h<u.y)return 0;if(l&&!m){const n=1===e.m_minorMajorRatio&&e.isClosed()&&e.isMajor(),r=1===s.m_minorMajorRatio&&s.isClosed()&&s.isMajor();if(n&&r&&(g=!0,_<=d)&&Math.max(t.x,u.x)<=Math.min(t.x,u.x)+_)return(0,i.g)(!o&&!a),1}}if(!g&&_e(e,s,h))return 0;const _=[],d=[],p=!1,f=!1,x=qr(e,0,0,p,f,_,d,null),y=[],P=[],E=qr(s,0,0,p,f,y,P,null);if(1===x&&1===E){const t=new as({points:_,weights:d}),i=new as({points:y,weights:P}),c=[],g=[],p=Ei(!1,t,i,r,null===o?null:c,null===a?null:g,h,m,l,u);if(p>0&&null!==o||null!==a){o&&(o.length=0),a&&(a.length=0);for(let r=0;r<p;++r){if(o)if((0,n.a1)(c[r],0,1))o.push(c[r]);else{const s=t.tToLength(c[r]),i=e.lengthToT(s);o.push(i)}if(a)if((0,n.a1)(g[r],0,1))a.push(g[r]);else{const t=i.tToLength(g[r]),e=s.lengthToT(t);a.push(e)}}}return p}let C=[];const v=[];let b=0;const S=l&&!m;for(let t=0;t<x;t++){const i=new as({points:_.slice(2*t,2*t+3),weights:d.slice(2*t,2*t+3)});let r=0;for(let o=0;o<E;o++){v.length<=o&&v.push(new as({points:y.slice(2*o,2*o+3),weights:P.slice(2*o,2*o+3)}));const a=[],m=[],l=S?null:a,u=S?null:m,c=Ei(!1,i,v[o],null,l,u,h,!1,S,!1);if(c>0&&S)return 1;for(let h=0;h<c;++h){if(0===a[h]&&0===t)a[h]=0;else if(1===a[h]&&t===x-1)a[h]=1;else{const t=i.tToLength(a[h])+b,s=e.lengthToT(t);a[h]=s}if(0===m[h]&&0===o)m[h]=0;else if(1===m[h]&&o===E-1)m[h]=1;else{const t=v[o].tToLength(m[h])+r,e=s.lengthToT(t);m[h]=e}C.push((0,n.d)(a[h],m[h]))}r+=v[o].calculateLength2D()}b+=i.calculateLength2D()}if(0===C.length)return 0;if(m&&(C=C.filter((t=>!(0,n.a1)(t.first,0,1)||!(0,n.a1)(t.second,0,1)||!e.getCoord2D(t.first).equals(s.getCoord2D(t.second))))),l)return C.length;const I=[],w=[];for(const t of C)I.push(t.first),w.push(t.second);return ta(t,e,s,I,w,I.length,r,o,a,h,m,0,u)}function bo(t,e,s){if(s.setCoords(t.getCoord2D(e.vmin)),s.mergeNe(t.getCoord2D(e.vmax)),to(t))return;const i=t.getSemiAxes(),r=[0,0,0,0];{const e=Math.atan2(-i.y*t.m_sinr,i.x*t.m_cosr),s=e+Math.PI,n=Math.atan2(i.y*t.m_cosr,i.x*t.m_sinr),o=n+Math.PI;r[0]=Or(t,e),r[1]=Or(t,s),r[2]=Or(t,n),r[3]=Or(t,o)}const o=new n.P;for(let i=0;i<4;i++){const n=r[i];e.containsExclusiveCoordinate(n)&&(t.queryCoord2D(n,o),s.mergeNe(o))}}function So(t,e,s,r,o){if(0===t.m_semiMajorAxis)return s.vmin;let a=n.P.getNAN();t.queryCoord2D(s.vmin,a);let h=n.P.getNAN();if(t.queryCoord2D(s.vmax,h),to(t))return new na({start:a,end:h}).getClosestCoordinate(e,r);const m=kr(t,e);if(a=kr(t,a),h=kr(t,h),1===t.m_minorMajorRatio){if(m.isEqual(0,0))return s.vmin;const e=Or(t,Math.atan2(m.y,m.x));return r||s.containsCoordinate(e)?e:n.P.distance(m,a)<=n.P.distance(m,h)?s.vmin:s.vmax}const l=t.getSemiMajorAxis(),u=t.getSemiMinorAxis(),c=(l-u)*(l+u),g=(0,n.e)(c),_=m.x,d=m.y,p=(0,n.e)(u*d),f=u*c*d*2,x=[new n.H(p),new n.H(f),new n.H(g-(0,n.e)(l*_)-p),new n.H(-f),new n.H(-g)],y=(0,n.m)(n.H,4),P=Ke(x,4,new n.E(-1,1),!1,y,4);let E=s.vmin,C=n.P.sqrDistance(m,a);{const t=n.P.sqrDistance(m,h);t<C&&(E=s.vmax,C=t)}(0,i.g)(!r);let v=new Array(8);for(let e=0;e<P;++e){const s=y[e].value(),i=Math.sqrt(1-s*s),n=Math.atan2(s,i),r=Math.atan2(s,-i);v[2*e]=Or(t,n),v[2*e+1]=Or(t,r)}v=v.slice(0,2*P),(0,n.n)(v);for(let i=0,r=2*P;i<r;++i)if(v[i]>s.vmin&&v[i]<s.vmax){const s=n.P.sqrDistance(e,t.getCoord2D(v[i]));C>s&&(C=s,E=v[i])}return E}function Io(t,e,s){return t.m_semiMajorAxis===e.m_semiMajorAxis&&t.isMajor()!==e.isMajor()&&!!t.m_center.equals(e.m_center)&&t.m_sinr===e.m_sinr&&t.m_cosr===e.m_cosr&&t.m_minorMajorRatio===e.m_minorMajorRatio&&(s?t.isClockwise()!==e.isClockwise():t.isClockwise()===e.isClockwise())}function wo(t,e,s,r){const o=t.getStartXY(),a=t.getEndXY(),h=o.equals(a),m=e.equals(s);if(!h&&!m){const i=new n.T;return i.initializeFromTwoPoints(o,a,e,s),io(t,i,!0),t.m_XStart=e.x,t.m_YStart=e.y,t.m_XEnd=s.x,t.m_YEnd=s.y,t.endPointModified(),void t.normalizeAfterEndpointChange()}if(!t.isMajor())return void $r(t,e,s,1);if(h&&m){const i=t.m_center.add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),i)}if(!h){const i=.5*((0,n.af)()-Math.abs(t.getSweepAngle())),r=(t.getSweepAngle()+i*(0,n.s)(t.getSweepAngle()))/t.getSweepAngle(),o=new n.P;t.queryCoord2D(r,o),t.constructEllipticArcEndPointsCenter(o,o,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.getCenter());const a=t.getCenter().add(e.sub(o));return void t.constructEllipticArcEndPointsCenter(e,s,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),a)}const l=n.P.sqrDistance(e,s);let u=.25,c=.75;if(l<n.P.sqrDistance(t.getCoord2D(.25),t.getCoord2D(.75))){const e=[0],s=He(new Xr(t,l),n.E.construct(0,.25),1,e);s>0&&((0,i.g)(1===s),u=e[0],c=1-e[0])}const g=t.getCoord2D(u),_=t.getCoord2D(c);(0,i.g)(!g.equals(_)),t.constructEllipticArcEndPointsCenter(g,_,t.getSemiMajorAxis(),t.getMinorMajorRatio(),t.getAxisXRotation(),!0,!t.isClockwise(),t.m_center),wo(t,e,s)}var Do=g;const To=-1;class No{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)}}class Ao{constructor(t){!function(t){return void 0!==t.parent}(t)?(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):(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)}moveToNextHelper(){for(this.m_path=this.m_parent.getNextPath(this.m_path),this.m_index=0;this.m_geometry!==To;){for(;this.m_path!==To;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!==To)return this.m_vertex;if(this.m_bOneGeom)return To;if(this.m_geometry=this.m_parent.getNextGeometry(this.m_geometry),this.m_geometry===To)break;this.m_bSkipMultiPoints&&!(0,i.f)(this.m_parent.getGeometryType(this.m_geometry))||(this.m_path=this.m_parent.getFirstPath(this.m_geometry))}return To}nextSelection(){for(;this.m_index<this.m_parent.m_selectedVertices.length;){const t=this.m_parent.m_selectedVertices[this.m_index++];if(t!==To&&(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 To}next(){return this.m_selection?this.nextSelection():this.m_bFirst?(this.m_bFirst=!1,this.m_vertex):this.m_vertex!==To?(this.m_vertex=this.m_parent.getNextVertex(this.m_vertex),this.m_index++,this.m_vertex!==To&&this.m_vertex!==this.m_firstVertex?this.m_vertex:this.moveToNextHelper()):To}currentGeometry(){return this.m_geometry}currentPath(){return this.m_path}static create_(t,e,s,i,n,r,o,a,h){return new Ao({parent:t,geometry:e,path:s,vertex:i,firstVertex:n,index:r,bSkipMultiPoints:o,selection:a,bOneGeom:h})}}class Mo{constructor(t){this.parentage=t}equals(t){return this.parentage===t.parentage}}class Go{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 t=0,s=this.m_indices.length;t<s;t++){if(t===this.m_selectionIndex)continue;const s=this.m_indices[t];null!==s&&s.size()>e&&s.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,1),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,1),this.m_segments&&this.setSegmentToIndex(e,null)}insertVertex_(t,e,s,i){this.m_hasForceSetEnvelope=0;const n=e!==To?this.getPrevVertex(e):this.getLastVertex(t),r=n!==To?this.getNextVertex(n):To,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!==To&&this.setPrevVertex(r,o),n!==To&&this.setNextVertex(n,o);const h=this.isClosedPath(t),m=this.getFirstVertex(t);e===To&&this.setLastVertex(t,o),e===m&&(h&&i&&m!==To||this.setFirstVertex(t,o)),h&&r===To&&(this.setNextVertex(o,o),this.setPrevVertex(o,o)),this.setPathSize(t,this.getPathSize(t)+1);const l=this.getGeometryFromPath(t);return this.setGeometryVertexCount(l,this.getPointCount(l)+1),o}getHelperPoint(){return this.m_helperPoint||(this.m_helperPoint=new Nt({vd:this.m_vertices.getDescription()}),this.m_helperPoint.setXYCoords(0,0)),this.m_helperPoint}addMultiPoint(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return this.appendMultiPoint(s,t,e),s}addPoint_(t,e){const s=this.createGeometry(i.G.enumMultiPoint,t.getDescription());return this.appendPoint(s,t,e),s}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 e=0,n=s.getPathCount();e<n;e++){if(0===s.getPathSize(e))continue;const n=this.insertPath(t,To);this.setClosedPath(n,s.isClosedPath(e));for(let t=s.getPathStart(e),r=s.getPathEnd(e);t<r;t++){const e=this.insertVertex_(n,To,null,!1);if(i){const i=this.getVertexIndex(e);if(1&s.getSegmentFlags(t))this.setSegmentToIndex(i,null);else{const e=new ra;s.querySegment(t,e,!0),this.setSegmentToIndex(i,e.releaseSegment())}}}s.isStrongPathStart(e)&&this.setStrongPathStart(n,!0),s.isStrongPathEnd(e)&&this.setStrongPathEnd(n,!0)}}addMultiPath(t,e){const s=this.createGeometry(t.getGeometryType(),t.getDescription());return t.getGeometryType()===i.G.enumPolygon&&this.setFillRule(s,t.getFillRule()),this.appendMultiPath(s,t,e),s}appendMultiPathPolyline(t,e,s){const i=e.getImpl(),n=null!==this.m_segments||null!==i.getSegmentFlagsStreamRef(),r=new o;e.queryEnvelope(r);{const r=s.clone();let o=i.getPointCount();const a=i.getAccelerators();if(a&&a.getQuadTree()&&(o=a.getQuadTree().getIntersectionCount(r,0,i.getPointCount()+1)),o<e.getPointCount()){if(0===o)return;const s=i.queryLimitedSegmentIterator(r);let a=-1,h=-100,m=-1,l=0,u=-1,c=To,g=!1,_=s.nextSegment();if(null!==_)for(;;_=s.nextSegment()){let r=null===_;const o=null!==_?s.getPathIndex():a,d=null!==_?s.getStartPointIndex():h;if(r||(a===o&&h+1===d?l++:r=!0),r){if(-1!==u){let t=-1,s=-1;if(l===m){this.setClosedPath(c,g);const n=i.getPathEnd(a);this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n-u),this.m_verticesMp.addPoints(e,u,n),s=i.getPathSize(a),t=n-1}else if(!g||h+1<i.getPathEnd(a))this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-u),this.m_verticesMp.addPoints(e,u,h+2),s=h-u+2,t=h;else{this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h+2-u),this.m_verticesMp?.addPoints(e,u,h+1),t=h,s=h-u+1;const n=i.getPathStart(a);this.m_verticesMp.addPoints(e,n,n+1),s+=1}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);for(let e=0,r=u;e<s;e++,r++){const e=this.insertVertex_(c,To,null,!1);if(n){const s=this.getVertexIndex(e);if(1&i.getSegmentFlags(r)||r>t)this.setSegmentToIndex(s,null);else{const t=new ra;i.getSegmentBuffer(r,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(null===_)break;l=1,u=d,a!==o?(c=this.insertPath(t,To),this.setClosedPath(c,!1),m=i.getSegmentCountPath(o),g=i.isClosedPath(o),a=o):c=this.insertPath(t,To)}h=d}return}}this.appendMultiPath_(t,e)}appendMultiPathPolygon(t,e,s){const r=e.getImpl(),a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef(),h=o.constructEmpty();e.queryEnvelope(h),(0,i.g)(s.isIntersecting(h)&&!s.containsEnvelope(h));let m=o.construct(Number.NEGATIVE_INFINITY,s.ymin,Number.POSITIVE_INFINITY,s.ymax),l=o.construct(s.xmin,Number.NEGATIVE_INFINITY,s.xmax,Number.POSITIVE_INFINITY);const u=r.getAccelerators();if(u&&u.getQuadTree()){const t=u.getQuadTree(),e=t.getIntersectionCount(m,0,0);e>t.getIntersectionCount(l,0,e+1)&&(l=(0,n.b)(m,m=l))}else m.height()>l.width()&&(l=(0,n.b)(m,m=l));const c=[],g=r.queryLimitedSegmentIterator(m);let _=-1,d=-100,p=-1,f=0,x=-1,y=-1,P=To,E=!0,C=g.nextSegment();if(null!==C)for(;;C=g.nextSegment()){let s=null===C;const h=null!==C?g.getPathIndex():_,m=null!==C?g.getStartPointIndex():d;if(s||(h===_?d+1===m?f++:s=!0:(s=_>=0,_<0&&(_=h,p=r.getSegmentCountPath(_),x=m,P=To,f=1))),s){if(0!==c.length||p!==f){0!==c.length&&c[0].first===x||(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,x,x+1),-1===y&&(y=x),P===To&&(P=this.insertPath(t,To),this.setClosedPath(P,!0)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.insertVertex_(P,To,null,!1));for(const{first:s,second:n}of c){-1===y&&(y=s);let o=-1,h=-1;const m=s+n-1;if(n===p){const t=m+1;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m,(0,i.g)(1===c.length)}else if(m+1<r.getPathEnd(_)){const t=m+2;h=t-s,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+h),this.m_verticesMp.addPoints(e,s,t),o=m}else{const t=r.getPathStart(_),i=t!==y?1:0,n=m+1;h=n-s+i,this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+(n-s)+i),this.m_verticesMp.addPoints(e,s,n),o=m,i>0&&this.m_verticesMp?.addPoints(e,t,t+1)}this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),P===To&&(P=this.insertPath(t,To),this.setClosedPath(P,!0));for(let t=0,e=s;t<h;t++,e++){const t=this.insertVertex_(P,To,null,!1);if(a){const s=this.getVertexIndex(t);if(1&r.getSegmentFlags(e)||e>o)this.setSegmentToIndex(s,null);else{const t=new ra;r.getSegmentBuffer(e,t,!0),this.setSegmentToIndex(s,t.releaseSegment())}}}}if(0===c.length||c.at(-1).first+c.at(-1).second!==x+f){let t=x+f;t===e.getPathEnd(_)&&(t=e.getPathStart(_)),y!==t&&(this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.addPoints(e,t,t+1),this.insertVertex_(P,To,null,!1))}}c.length=0,E=!0,h!==_&&(_=h,p=r.getSegmentCountPath(_),P=To,y=-1),x=m,f=1}if(!C)break;{const t=o.constructEmpty();C.queryLooseEnvelope(t),l.isIntersecting(t)?(E?c.push((0,n.d)(m,1)):c.at(-1).second++,E=!1):E=!0}d=m}}appendMultiPath(t,e,s){if(void 0===s)return void this.appendMultiPath_(t,e);if(e.isEmpty())return;const n=e.getGeometryType()===i.G.enumPolygon,r=o.constructEmpty();e.queryEnvelope(r),s.isIntersecting(r)&&(!s.containsEnvelope(r)&&e.getPointCount()>10?n?this.appendMultiPathPolygon(t,e,s):this.appendMultiPathPolyline(t,e,s):this.appendMultiPath_(t,e))}appendPoint(t,e,s){if(e.isEmpty())return;if(void 0!==s&&!s.contains(e.getXY()))return;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+1),this.m_verticesMp.add(e),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0),this.m_vertexIndexList.setCapacity(this.m_vertexIndexList.size()+1);const i=this.insertPath(t,To);this.insertVertex_(i,To,null,!1)}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,To);for(let t=0,i=e.getPointCount();t<i;t++)this.insertVertex_(s,To,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 t=0,r=e.getPointCount();t<r;t++){const e=i.readPoint2D(2*t);s.contains(e)&&n++}this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+n);let r=-1,o=-1,a=0;for(let t=0,n=e.getPointCount();t<n;t++){const n=i.readPoint2D(2*t);s.contains(n)?(-1===r&&(r=t,o=t),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,To);for(let t=0,n=e.getPointCount();t<n;t++){const e=i.readPoint2D(2*t);s.contains(e)&&this.insertVertex_(h,To,null,!1)}}splitSegmentForward(t,e,s,n,r){const o=this.getNextVertex(t);o===To&&(0,i.t)("Edit_shape.split_segment_forward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const u=this.getVertexIndex(m),c=this.getNextVertex(m),g=e.getResultSegment(s,t);let _=null;if(g.getGeometryType()!==i.G.enumLine&&(_=g.clone(),_.dropAllAttributes()),0===t&&(g.queryStart(a),this.setSegmentToIndex(u,null),this.setPointEx(m,a,e.getResultSegmentStartPointRank(s,t),e.getResultSegmentStartPointWeight(s,t),r)),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,t)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,t)),l){const i=e.getResultSegmentSegmentParentage(s,t),n=e.getResultSegmentStartPointIsBreak(s,t);this.setSegmentParentageAndBreak(m,i,n)}if(g.queryEnd(a),t<n-1){this.setSegmentToIndex(u,_);const i=this.insertVertex(h,c,a);this.setWeight(i,e.getResultSegmentEndPointWeight(s,t)),this.setRank(i,e.getResultSegmentEndPointRank(s,t)),this.select(i),m=i}else{this.setPointEx(o,a,e.getResultSegmentEndPointRank(s,t),e.getResultSegmentEndPointWeight(s,t),r);const i=e.getResultSegmentEndPointIsBreak(s,t);this.setSegmentParentageBreakVertex(o,i),this.setSegmentToIndex(u,_)}}}splitSegmentBackward(t,e,s,n,r){const o=this.getNextVertex(t);o===To&&(0,i.t)("Edit_shape.split_segment_backward_");const a=this.getHelperPoint(),h=this.getPathFromVertex(t);let m=t;const l=this.hasSegmentParentage();for(let t=0,n=e.getResultSegmentCount(s);t<n;t++){const u=n-t-1,c=this.getVertexIndex(m),g=this.getNextVertex(m),_=e.getResultSegment(s,u);let d=null;if(_.getGeometryType()!==i.G.enumLine&&(d=_.clone(),d.reverse(),d.dropAllAttributes()),0===t&&(_.queryEnd(a),this.setSegmentToIndex(c,null),this.setPointEx(m,a,e.getResultSegmentEndPointRank(s,u),e.getResultSegmentEndPointWeight(s,u),r),this.setSegmentParentageAndBreak(m,e.getResultSegmentSegmentParentage(s,u),e.getResultSegmentEndPointIsBreak(s,u))),_.getGeometryType()===i.G.enumLine?this.setSegmentToIndex(c,null):this.setSegmentToIndex(c,d),this.setSegmentRank(m,e.getResultSegmentInteriorRank(s,u)),this.setSegmentWeight(m,e.getResultSegmentInteriorWeight(s,u)),_.queryStart(a),t<n-1){const t=this.insertVertex(h,g,a);this.setWeight(t,e.getResultSegmentStartPointWeight(s,u)),this.setRank(t,e.getResultSegmentStartPointRank(s,u)),this.select(t),m=t,l&&this.setSegmentParentageAndBreak(t,e.getResultSegmentSegmentParentage(s,u),e.getResultSegmentEndPointIsBreak(s,u))}else this.setPointEx(o,a,e.getResultSegmentStartPointRank(s,u),e.getResultSegmentStartPointWeight(s,u),r)}}selected_(t){return this.getUserIndex(t,this.m_selectionIndex)>=0}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?E(0,-1):E(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 E(0)}recyclePathUserIndex(t){this.m_deletedPathIndices.push(t)}peelALoop_(t,e,s){const i=this.getNextVertex(t),r=this.getNextVertex(e),o=this.getVertexIndex(t),a=this.getVertexIndex(e);if(this.setNextVertex(t,r),this.setPrevVertex(r,t),this.setNextVertex(e,i),this.setPrevVertex(i,e),this.m_segments){const t=this.getSegmentFromIndex(o),e=this.getSegmentFromIndex(a);this.setSegmentToIndex(a,null),this.setSegmentToIndex(o,e),this.setSegmentToIndex(a,t)}if(this.hasSegmentParentage()){let s=this.getSegmentParentage(e),i=this.getSegmentParentage(t);-1===s&&-1===i||(i=(0,n.b)(s,s=i),this.setSegmentParentageAndBreak(t,i),this.setSegmentParentageAndBreak(e,s))}if(s){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e),n=[!1],o=this.insertClosedPath(s,To,i,this.getFirstVertex(e),n);n[0]&&this.setFirstVertex(e,r);let a=this.getPathSize(e);return a-=this.getPathSize(o),this.setPathSize(e,a),o}return To}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(t,e,s){(0,i.g)(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_forceSetEnvelope=d.constructEmpty(),this.m_hasForceSetEnvelope=0,this.m_workPoint2D=n.P.getNAN(),this.m_workPoint2_2D=n.P.getNAN(),this.m_curveStitcher=null,this.m_pathCount=0,this.m_pointCount=0,this.m_firstGeometry=To,this.m_lastGeometry=To,this.m_vertexIndexList=new k(5),this.m_pathIndexList=new k(8),this.m_geometryIndexList=new k(8),this.m_bHasAttributes=!1,this.m_selectedCount=0,this.m_selectionIndex=-1,this.m_selection=!1,this.m_bucketSort=new X,this.m_segmentParentageIndex=-1}getTotalPointCount(){return this.m_pointCount}getEnvelope2D(t){if(0!==this.m_hasForceSetEnvelope)return new o(this.m_forceSetEnvelope.xmin,this.m_forceSetEnvelope.ymin,this.m_forceSetEnvelope.xmax,this.m_forceSetEnvelope.ymax);const e=this.hasCurves(),s=o.constructEmpty(),i=this.queryVertexIterator();let n=!0;for(let t=i.next();t!==To;t=i.next()){if(n?s.merge(this.getXY(t)):s.mergeNe(this.getXY(t)),e){const e=this.getSegment(t);if(null!==e){const t=o.constructEmpty();e.queryLooseEnvelope(t),s.mergeEnvelope2D(t)}}n=!1}return s}getEnvelope3D(t){return(0,i.g)(0),d.constructEmpty()}forceSetEnvelope2D(t){this.m_hasForceSetEnvelope=1,this.m_forceSetEnvelope.setCoords(t.xmin,t.ymin,0,t.xmax,t.ymax,0)}forceSetEnvelope3D(t){(0,i.g)(0)}forgetForceSetEnvelope(){this.m_hasForceSetEnvelope=0}getGeometryCount(){return this.m_geometryIndexList.size()}addGeometry(t,e){const s=t.getGeometryType();if((0,i.f)(s))return this.addMultiPath(t,e);if(s===i.G.enumMultiPoint)return this.addMultiPoint(t,e);if(s===i.G.enumPoint)return this.addPoint_(t,e);if(s===i.G.enumEnvelope){const s=new Ar;return s.addEnvelope(t,!1),this.addMultiPath(s,e)}(0,i.t)("")}appendGeometry(t,e){this.mergeVertexDescription(e.getDescription());const s=e.getGeometryType();(0,i.f)(s)?this.appendMultiPath(t,e):s!==i.G.enumMultiPoint?(0,i.t)(""):this.appendMultiPoint(t,e)}assignRankToGeometryVertices(t,e){e<1&&(e=1);const s=this.queryVertexIterator();for(let t=s.next();t!==To;t=s.next())this.setRank(t,e),this.setSegmentRank(t,e)}collapseAllGeometriesToFirst(){this.collapseGeometriesToFirst(i.G.enumUnknown)}collapseGeometriesToFirst(t){this.dbgVerifyVertexCounts();let e=To,s=-1,n=-1;for(let r=this.getFirstGeometry();r!==To;)if(t!==i.G.enumUnknown&&this.getGeometryType(r)!==t)r=this.getNextGeometry(r);else{if(e===To){e=r,s=this.getPathCount(e),n=this.getPointCount(e),r=this.getNextGeometry(r);continue}for(let t=this.getFirstPath(r);t!==To;t=this.getNextPath(t))this.setPathGeometry(t,e);s+=this.getPathCount(r),n+=this.getPointCount(r);const t=this.getLastPath(e),i=this.getFirstPath(r);t!==To?this.setNextPath(t,i):this.setFirstPath(e,i),i!==To&&(this.setPrevPath(i,t),this.setLastPath(e,this.getLastPath(r))),this.setFirstPath(r,To),this.setLastPath(r,To);const o=r;r=this.getNextGeometry(r),this.setGeometryVertexCount(o,0),this.removeGeometry(o)}return e!==To&&(this.setGeometryVertexCount(e,n),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(t){const e=this.getPathFromVertex(t),s=this.getGeometryFromPath(e);return this.getGeometryModified(s)}swapGeometry(t,e){const s=this.getFirstPath(t),i=this.getFirstPath(e),n=this.getLastPath(t),r=this.getLastPath(e);for(let s=this.getFirstPath(t);s!==To;s=this.getNextPath(s))this.setPathGeometry(s,e);for(let s=this.getFirstPath(e);s!==To;s=this.getNextPath(s))this.setPathGeometry(s,t);this.setFirstPath(t,i),this.setFirstPath(e,s),this.setLastPath(t,r),this.setLastPath(e,n);const o=this.getPointCount(t),a=this.getPathCount(t),h=this.getPointCount(e),m=this.getPathCount(e);this.setGeometryVertexCount(t,h),this.setGeometryVertexCount(e,o),this.setGeometryPathCount(t,m),this.setGeometryPathCount(e,a);const l=this.m_geometryIndexList.getField(t,2),u=this.m_geometryIndexList.getField(e,2);this.m_geometryIndexList.setField(t,2,u),this.m_geometryIndexList.setField(e,2,l)}addPathFromMultiPath(t,e,s){const n=this.createGeometry(s?i.G.enumPolygon:i.G.enumPolyline,t.getDescription()),r=t.getImpl();if(t.getPathSize(e)<2)return n;this.m_vertices.reserveRounded(this.m_vertices.getPointCount()+t.getPathSize(e)),this.m_verticesMp.addPoints(t,t.getPathStart(e),r.getPathEnd(e)),this.m_xyStream=this.m_vertices.getAttributeStreamRef(0);const o=this.insertPath(n,To);this.setClosedPath(o,r.isClosedPath(e)||s);const a=null!==this.m_segments||null!==r.getSegmentFlagsStreamRef();for(let t=r.getPathStart(e),s=r.getPathEnd(e);t<s;t++){const e=this.insertVertex_(o,To,null,!1);if(a){const s=this.getVertexIndex(e);if(1&r.getSegmentFlags(t))this.setSegmentToIndex(s,null);else{const e=new ra;r.querySegment(t,e,!0),this.setSegmentToIndex(s,e.releaseSegment())}}}return r.isStrongPathStart(e)&&this.setStrongPathStart(o,!0),r.isStrongPathEnd(e)&&this.setStrongPathEnd(o,!0),n}getGeometry(t){const e=this.getGeometryType(t),s=function(t,e){let s=e,n=null;s||(n=(0,i.q)(t)?R():V(),s=n);let r=null;switch(t){case i.G.enumPoint:r=new Nt({vd:s});break;case i.G.enumLine:r=new na({vd:s});break;case i.G.enumBezier:r=new pn({vd:s});break;case i.G.enumEllipticArc:r=new Nr({vd:s});break;case i.G.enumRationalBezier2:r=new as({vd:s});break;case i.G.enumBezier2:r=new rs({vd:s});break;case i.G.enumEnvelope:r=new qt({vd:s});break;case i.G.enumMultiPoint:r=new kt({vd:s});break;case i.G.enumPolyline:r=new pr({vd:s});break;case i.G.enumPolygon:r=new Ar({vd:s});break;case i.G.enumMultipatch:(0,i.a)("multipatch not impl");break;case i.G.enumGeometryCollection:r=new Ut({vd:s});break;default:(0,i.t)("Geometry.create")}return r}(e,this.m_verticesMp.getDescription()),n=this.getPointCount(t);if(0===n)return s;if((0,i.f)(e)){const e=s.getImpl(),i=this.getPathCount(t),r=E(i+1),o=C(i+1,0),a=s.getDescription(),h=this.hasCurves();for(let s=0,h=a.getAttributeCount();s<h;s++){const h=a.getSemantics(s),m=Do.getComponentCount(h),l=y(h,n),u=this.m_vertices.getAttributeStreamRef(h);let c=0,g=0,_=0;for(let e=this.getFirstPath(t);e!==To;e=this.getNextPath(e)){let t=0;this.isClosedPath(e)&&(t|=1),this.isExterior(e)&&(t|=8),this.isStrongPathStart(e)&&(t|=2),this.isStrongPathEnd(e)&&(t|=4),t&&o.setBits(g,t);const s=this.getPathSize(e);if(r.write(g++,_),_+=s,0===h){const t=u,s=l;let i;for(let n=this.getFirstVertex(e);c<_;n=this.getNextVertex(n),c++){const e=this.getVertexIndex(n);i=t.readPoint2D(2*e),s.writePoint2D(2*c,i)}}else for(let t=this.getFirstVertex(e);c<_;t=this.getNextVertex(t),c++){const e=this.getVertexIndex(t);for(let t=0;t<m;t++){const s=u.readAsDbl(e*m+t);l.writeAsDbl(c*m+t,s)}}}e.setAttributeStreamRef(h,l),r.write(i,n)}if(e.setPathFlagsStreamRef(o),e.setPathStreamRef(r),e.notifyModifiedFlags(65535),h){let s=0,i=0;for(let n=this.getFirstPath(t);n!==To;n=this.getNextPath(n)){s+=this.getPathSize(n);for(let t=this.getFirstVertex(n);i<s;t=this.getNextVertex(t)){const s=this.getSegment(t);null!==s&&s.isCurve()&&e.replaceSegment(i,s,!0),i++}}}}else if(e===i.G.enumMultiPoint){const e=s.getImpl(),i=s.getDescription();e.reserve(n),e.resizeNoInit(n);for(let s=0,n=i.getAttributeCount();s<n;s++){const n=i.getSemantics(s),r=Do.getComponentCount(n),o=e.getAttributeStreamRef(n),a=this.m_vertices.getAttributeStreamRef(n);let h=0;const m=this.getFirstPath(t),l=this.getPathSize(m);for(let t=this.getFirstVertex(m);h<l;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)}}e.setAttributeStreamRef(n,o)}e.notifyModifiedFlags(65535)}else(0,i.b)("getGeometry");return s}queryPointGeometryOnly(t,e){this.getGeometryType(t)!==i.G.enumMultiPoint&&(0,i.t)("get_point_geometry_only");const s=this.getPointCount(t);if(s>1&&(0,i.t)("get_point_geometry_only"),0===s)return e.assignVertexDescription(this.m_vertexDescription),void e.setEmpty();const n=this.getFirstPath(t),r=this.getFirstVertex(n);this.queryPoint(r,e)}removeGeometry(t){for(let e=this.getFirstPath(t);e!==To;e=this.removePath(e));const e=this.getPrevGeometry(t),s=this.getNextGeometry(t);return e!==To?this.setNextGeometry(e,s):this.m_firstGeometry=s,s!==To?this.setPrevGeometry(s,e):this.m_lastGeometry=e,this.freeGeometry(t),s}createGeometry(t,e){void 0===e&&(e=V());const s=this.newGeometry(t);return this.m_vertices||(this.m_verticesMp=new kt({vd:e}),this.m_vertices=this.m_verticesMp.getImpl()),this.mergeVertexDescription(e),this.m_firstGeometry===To?(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]=E(0),t;this.m_geometryIndices.push(E(0));const t=this.m_geometryIndices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}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!==To;t=this.getNextGeometry(t))if(!(0,i.f)(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(t,e,s,r,o){const a=t*t;let h=0;const m=this.hasCurves(),l=this.hasSegmentParentage();for(let t=o===To?this.getFirstGeometry():o;t!==To;t=o===To?this.getNextGeometry(t):To){const o=this.getGeometryType(t);if(!(0,i.f)(o))continue;if(s&&o!==i.G.enumPolygon)continue;const u=this.getGeometryType(t)===i.G.enumPolygon;let c=this.getGeometryModified(t);for(let s=this.getFirstPath(t);s!==To;){let o=0;for(let e=this.getFirstVertex(s);o<Math.trunc(this.getPathSize(s)/2);){const u=this.getNextVertex(e);if(u===To)break;const g=this.getXY(e),_=this.getXY(u);let d=n.P.sqrDistance(g,_),p=!0;do{if(d<=a){if(m){const t=this.getSegment(e);if(null!==t){const e=t.calculateLength2D();if(d=e*e,d>a)break}}if(0===d?0===h&&(h=-1):h=1,u!==this.getLastVertex(s)){const s=l&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(u));if(this.transferAllDataToTheVertex(u,e),this.removeVertex(u,!1),r&&!c&&(this.setGeometryModified(t,!0),c=!0),l&&e!==u){this.setSegmentParentageBreakVertex(e,s);const t=this.getNextVertex(e);(0,i.g)(t!==To),this.isDiscontinuousSegmentParentage(t)&&this.setSegmentParentageBreakVertex(t,!0)}}p=!1}}while(0);p&&(e=this.getNextVertex(e)),o++}let g=this.getFirstVertex(s);for(let e=this.isClosedPath(s)?g:this.getLastVertex(s);this.getPathSize(s)>0;){const i=this.getPrevVertex(e);if(i===To)break;{const o=this.getXY(i),u=this.getXY(e);let _=n.P.sqrDistance(o,u),d=!0;do{if(_<=a){if(m){const t=this.getSegment(i);if(null!==t){const e=t.calculateLength2D();if(_=e*e,_>a)break}}0===_?0===h&&(h=-1):h=1;const n=l&&(this.getSegmentParentageBreakVertex(e)||this.getSegmentParentageBreakVertex(i));this.removeVertex(i,!0),r&&!c&&(this.setGeometryModified(t,!0),c=!0),l&&i!==e&&(n||this.isDiscontinuousSegmentParentage(e))&&this.setSegmentParentageBreakVertex(e,!0),g===i&&(g=this.getFirstVertex(s)),d=!1}}while(0);if(d&&(e=this.getPrevVertex(e),e===g))break}}const _=this.getPathSize(s);let d=e&&_<(u?3:2);d&&u&&2===_&&m&&(d=!this.pathHasCurves(s)),d?(s=this.removePath(s),0===h&&(h=-1),r&&!c&&(this.setGeometryModified(t,!0),c=!0)):s=this.getNextPath(s)}}return h}filterClosePoints3D(t,e,s,n,r,o){return(0,i.g)(0),0}hasDegenerateSegments(t){for(let e=this.getFirstGeometry();e!==To;e=this.getNextGeometry(e))if((0,i.f)(this.getGeometryType(e)))for(let s=this.getFirstPath(e);s!==To;){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===To)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(t,e){return(0,i.g)(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)}for(let s=0,i=this.m_indices.length;s<i;s++)if(s!==this.m_selectionIndex&&null!==this.m_indices[s]){const i=this.getUserIndex(t,s);-1!==i&&this.setUserIndex(e,s,i)}const n=this.selected(t);n!==this.selected(e)&&(n?this.select(e):this.unselect(e))}splitSegmentAxisAware(t,e,s,n,r){let o=0;const a=this.getNextVertex(t);a===To&&(0,i.t)("");const h=this.getVertexIndex(t),m=this.getVertexIndex(a),l=this.getSegmentFromIndex(h);let u=this.m_vertices.getShortestDistance(h,m);const c=this.getPathFromVertex(t),g=this.m_bHasAttributes;g&&l&&(u=l.calculateLength2D());const _=this.getSegmentParentage(t),d=this.getHelperPoint();if(l){let t=0,i=0,r=To;for(let p=0;p<s;p++){const s=e[p];if(t<s&&s<1){const e=l.cut(t,s);if(null!==n&&(p>0&&e.setStartXY(n[p-1]),e.setEndXY(n[p]),e.normalizeAfterEndpointChange(),i=p),g){const t=u>0?l.calculateSubLengthFromStart(s)/u:0;this.m_vertices.interpolateTwoVertices(h,m,t,d)}d.setXY(e.getEndXY()),r=this.insertVertex(c,a,d),o++;const f=this.getPrevVertex(r),x=this.getVertexIndex(f);this.setSegmentToIndex(x,e),-1!==_&&this.setSegmentParentageAndBreak(r,_,!1),t=s}}if(r!==To){const e=l.cut(t,1);null!==n&&(e.setStartXY(n[i]),e.normalizeAfterEndpointChange());const s=this.getVertexIndex(r);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(h,m,s,d);const t=this.insertVertex(c,a,d);o++,-1!==_&&this.setSegmentParentageAndBreak(t,_,!1)}t=s}}return o}splitSegment(t,e,s,i=null){return this.splitSegmentAxisAware(t,e,s,i,-1)}snapControlPoints(t,e,s){this.getNextVertex(t)===To&&(0,i.t)("");let n=t,r=!1;for(let t=0;t<e;++t){const t=this.getVertexIndex(n),e=this.getSegmentFromIndex(t);if(e){const t=e.snapControlPoints(s);r||=t}n=this.getNextVertex(n)}return r}snapControlPointsOnSelection(t){if(!this.hasCurves())return!1;let e=0;const s=this.queryVertexIteratorOnSelection();for(let i=s.next();i!==To;i=s.next()){const s=this.getVertexIndex(i),n=this.getSegmentFromIndex(s);n&&(e|=n.snapControlPoints(t)?1:0)}return 0!==e}calculateSubLength2D(t,e,s){return(0,i.g)(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!==To){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(t,e,s,n){(0,i.g)(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!==To){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 r=this.getSegmentFromIndex(i);if(null!==r){const t=r.getEndXY();r.setCoordsForIntersector(new n.P(e,s),t,!1),r.ensureXYMonotone()}const o=this.getPrevVertex(t);if(o!==To){const t=this.getVertexIndex(o),i=this.getSegmentFromIndex(t);if(null!==i){const t=i.getStartXY();i.setCoordsForIntersector(t,new n.P(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)}static setSegDefault(t,e,s){(0,i.g)(0)}setXYZ(t,e,s){(0,i.g)(0)}setXYZCoords(t,e,s,n){(0,i.g)(0)}queryXYZ(t,e){(0,i.g)(0)}getXYZ(t){return(0,i.g)(0),_.getNAN()}getXYZWithIndex(t){return(0,i.g)(0),_.getNAN()}mergeVertexDescription(t){this.m_verticesMp.mergeVertexDescription(t),this.m_vertexDescription=this.m_verticesMp.getDescription(),this.m_bHasAttributes=this.m_vertexDescription.getAttributeCount()>1}addAttribute(t){(0,i.g)(0)}getAttributeAsDbl(t,e,s){return this.m_vertices.getAttributeAsDbl(t,this.getVertexIndex(e),s)}queryAttributeAsDbl(t,e,s,n){(0,i.g)(0)}setAttribute(t,e,s,n){(0,i.g)(0)}setAttributeInt(t,e,s,n){(0,i.g)(0)}getVertexDescription(){return this.m_vertexDescription}getMinPathVertexY(t){return(0,i.g)(0),0}getVertexIndex(t){return this.m_vertexIndexList.getField(t,0)}getY(t){const e=this.getVertexIndex(t);return this.m_vertices.queryXY(e,this.m_workPoint2D),this.m_workPoint2D.y}getX(t){return this.getXY(t).x}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(t,e){return(0,i.g)(0),!1}setWeight(t,e){e<1&&(e=1);const s=1===e;if(null==this.m_weights){if(s)return;this.m_weights=v(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=v(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 1;const e=this.getVertexIndex(t);return e>=this.m_ranks.size()?1:this.m_ranks.read(e)}getRankWithIndex(t){return null===this.m_ranks||t>=this.m_ranks.size()?1:this.m_ranks.read(t)}setRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=E(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(i+1,1)}this.m_ranks.write(i,e)}setRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_ranks){if(s)return;this.m_ranks=E(this.m_vertices.getPointCount(),1)}if(t>=this.m_ranks.size()){if(s)return;this.m_ranks.resize(t+1,1)}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=v(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=v(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 Go.st_defaultRank;const e=this.getVertexIndex(t);return e>=this.m_segmentRanks.size()?Go.st_defaultRank:this.m_segmentRanks.read(e)}getSegmentRankWithIndex(t){return null===this.m_segmentRanks||t>=this.m_segmentRanks.size()?1:this.m_segmentRanks.read(t)}setSegmentRank(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=E(this.m_vertices.getPointCount(),1)}const i=this.getVertexIndex(t);if(i>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(i+1,1)}this.m_segmentRanks.write(i,e)}setSegmentRankWithIndex(t,e){e<1&&(e=1);const s=1===e;if(null===this.m_segmentRanks){if(s)return;this.m_segmentRanks=E(this.m_vertices.getPointCount(),1)}if(t>=this.m_segmentRanks.size()){if(s)return;this.m_segmentRanks.resize(t+1,1)}this.m_segmentRanks.write(t,e)}removeWeights(){this.m_weights=null,this.m_segmentWeights=null}removeRanks(){this.m_ranks=null,this.m_segmentRanks=null}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];return s<i.size()?i.read(s):-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 t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=(0,n.o)()),t}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 t=this.m_indices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillUserIndexForGeometry(t,e,s){const i=this.m_indices[e],n=i.size();for(let e=this.getFirstPath(t);e!==To;e=this.getNextPath(e)){let t=this.getFirstVertex(e);for(let r=0,o=this.getPathSize(e);r<o;r++,t=this.getNextVertex(t)){const e=this.getVertexIndex(t);e<n&&i.write(e,s)}}}fillUserIndexForSelection(t,e){(0,i.g)(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===To)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 Nt({vd:this.getVertexDescription()});this.queryPoint(t,s),e.setStart(s),this.queryPoint(i,s),e.setEnd(s)}return!0}queryLineConnector3D(t,e,s=!1){return(0,i.g)(0),!1}hasCurves(){return null!==this.m_segments}geometryHasCurves(t){return(0,i.g)(0),!1}pathHasCurves(t){if(!this.hasCurves())return!1;const e=this.getFirstVertex(t);if(e===To)return!1;const s=this.getPathSize(t);let n=e;for(let t=0;t<s;t++,n=this.getNextVertex(n)){const t=this.getSegment(n);if(null!==t&&t.getGeometryType()!==i.G.enumLine)return!0}return!1}insertPath(t,e){let s=To;e!==To?(t!==this.getGeometryFromPath(e)&&(0,i.t)(""),s=this.getPrevPath(e)):s=this.getLastPath(t);const n=this.newPath(t);return e!==To&&this.setPrevPath(e,n),this.setNextPath(n,e),this.setPrevPath(n,s),s!==To?this.setNextPath(s,n):this.setFirstPath(t,n),e===To&&this.setLastPath(t,n),this.setGeometryPathCount(t,this.getPathCount(t)+1),n}removePath(t){const e=this.getPrevPath(t),s=this.getNextPath(t),i=this.getGeometryFromPath(t);return e!==To?this.setNextPath(e,s):this.setFirstPath(i,s),s!==To?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!==To){let s=e;for(let e=0,i=this.getPathSize(t);e<i;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,To),this.setPrevVertex(s,To);const t=this.getVertexIndex(i);this.setSegmentToIndex(t,null)}}const s=(1|this.getPathFlags(t))-1;this.setPathFlags(t,s|(e?1:0))}closeAllPaths(t){(0,i.g)(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===To)return 0;const s=this.getXY(e),r=new n.K(0),o=this.getPathSize(t);if(o>2){const t=s.clone(),i=t.x,a=t.y;let h=this.getNextVertex(e);const m=this.getXY(h);h=this.getNextVertex(h);const l=n.P.getNAN();for(let e=2;e<o;e++,h=this.getNextVertex(h))this.queryXY(h,l),r.pe((l.x-t.x)*(m.y-a)),t.setCoordsPoint2D(m),m.setCoordsPoint2D(l);r.pe((i-t.x)*(m.y-a))}if(this.hasCurves()){let t=e;for(let e=0;e<o;e++,t=this.getNextVertex(t)){const e=this.getSegment(t);if(null===e||e.getGeometryType()===i.G.enumLine)continue;const s=2*e.calculateArea2DHelper();r.pe(s)}}this.setRingAreaValid(t,!0);const a=.5*r.getResult();return this.m_pathAreas[this.getPathIndex(t)]=a,a}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 t=this.m_pathindices.length-1;return(0,i.g)(t>=0&&t<=Number.MAX_SAFE_INTEGER),t}fillPathUserIndexForGeometry(t,e,s){const i=this.m_pathindices[e],n=i.size();for(let e=this.getFirstPath(t);e!==To;e=this.getNextPath(e)){const t=this.getPathIndex(e);t<n&&i.write(t,s)}}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===To&&(0,i.t)(""),e===s)return;const n=this.getNextPath(s);let r=this.getPrevPath(s);const o=this.getGeometryFromPath(s);r===To?this.setFirstPath(o,n):this.setNextPath(r,n),n===To?this.setLastPath(o,r):this.setPrevPath(n,r),this.setGeometryVertexCount(o,this.getPointCount(o)-this.getPathSize(s)),this.setGeometryPathCount(o,this.getPathCount(o)-1),r=e===To?this.getLastPath(t):this.getPrevPath(e),this.setPrevPath(s,r),this.setNextPath(s,e),e===To?this.setLastPath(t,s):this.setPrevPath(e,s),r===To?this.setFirstPath(t,s):this.setNextPath(r,s),this.setGeometryVertexCount(t,this.getPointCount(t)+this.getPathSize(s)),this.setGeometryPathCount(t,this.getPathCount(t)+1),this.setPathGeometry(s,t)}addVertex(t,e){return this.m_vertices.getPointByVal(this.getVertexIndex(e),this.getHelperPoint()),this.insertVertex_(t,To,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!==To&&this.setNextVertex(i,n);const r=this.getPathSize(s);if(t===this.getFirstVertex(s)&&this.setFirstVertex(s,r>1?n:To),n!==To&&this.setPrevVertex(n,i),t===this.getLastVertex(s)&&this.setLastVertex(s,r>1?i:To),this.hasCurves()&&i!==To&&n!==To){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(t,e){(0,i.g)(t!==e);const s=this.getPathFromVertex(t),n=this.getPrevVertex(t),r=this.getPrevVertex(e);n!==To&&this.setNextVertex(n,e);let o=this.getPathSize(s);const a=this.getVertexIndex(t);this.setSegmentToIndex(a,null),this.setPrevVertex(e,n),this.setPrevVertex(t,To),this.setNextVertex(r,To);let h=0,m=t;const l=this.getFirstVertex(s);let u=!1;for(;;){const t=this.getNextVertex(m);if(u||=l===m,this.freeVertex(m),h++,m===r)break;m=t}o-=h,u&&this.setFirstVertex(s,o>0?e:To),this.setPathSize(s,o);const c=this.getGeometryFromPath(s);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(t,e){return this.insertVertex_(t,To,e,!1)}getGeometryFromVertex(t){return this.getGeometryFromPath(this.getPathFromVertex(t))}replaceNaNs(t,e){this.m_vertexDescription.hasAttribute(t)||(0,i.b)(""),this.m_vertices.replaceNaNs(t,e)}removeNaNVertices(){for(let t=this.getFirstGeometry();t!==To;t=this.getNextGeometry(t))for(let e=this.getFirstPath(t);e!==To;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=To){return this.queryVertexIteratorEx(!1,t)}queryVertexIteratorEx(t,e=To){let s=To,n=To,r=To,o=To,a=0,h=!1;for(s=e!==To?e:this.getFirstGeometry();s!==To;s=this.getNextGeometry(s))if(!t||(0,i.f)(this.getGeometryType(s))){for(n=this.getFirstPath(s);n!==To;n=this.getNextPath(n))if(r=this.getFirstVertex(n),o=r,a=0,r!==To){h=!0;break}if(h||e!==To)break}return h||(s=To),Ao.create_(this,s,n,r,o,a,t,!1,e!==To)}queryVertexIteratorOnSelection(t=To){return this.m_selection?Ao.create_(this,t,To,To,To,-1,!1,!0,t!==To):this.queryVertexIteratorEx(!1,t)}hasSelection(){return this.m_selection}createEmptySelection(){(0,i.g)(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]=To,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(t,e){return(0,i.g)(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)}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(t){return(0,i.g)(0),!1}querySegment(t,e,s=!0,i=!1){const n=this.getNextVertex(t);if(n===To)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){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}getAndClearSegmentFromIndex(t){return(null!==this.m_segments&&this.m_segments.length>t?this.m_segments[t]:null)||null}setSegmentToIndex(t,e){if(this.m_hasForceSetEnvelope=0,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(t,e){return(0,i.g)(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!==To?this.setNextPath(e,s):this.setFirstPath(i,s),s!==To?this.setPrevPath(s,e):this.setLastPath(i,e),this.setFirstVertex(t,To),this.setLastVertex(t,To),this.freePath(t)}insertClosedPath(t,e,s,i,n){const r=this.insertPath(t,To);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(t,e){return(0,i.g)(0),0}findVertex3D(t,e,s){return(0,i.g)(0),0}dbgVerifyMonotone(){}dbgCheckSelection(){}dbgVerifySegment(t){}dbgVerifyIntegrity(t,e=!0){}dbgVerifyVertexCounts(){}dbgVerifyCurves(){}dbgDumpGeometry(t,e){}removeVertexInternal(t,e){const s=this.getPrevVertex(t),i=this.getNextVertex(t);if(s!==To&&this.setNextVertex(s,i),i!==To&&this.setPrevVertex(i,s),this.hasCurves()&&s!==To&&i!==To){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.queryXY(t,this.m_workPoint2D),this.queryXY(e,this.m_workPoint2_2D),this.m_workPoint2D.compare(this.m_workPoint2_2D)}compareVerticesSimpleY3D(t,e){return this.getXYZ(t).compare(this.getXYZ(e))}compareVerticesSimpleX(t,e){return this.getXY(t).compareX(this.getXY(e))}sortVerticesSimpleByYHeapMerge(t,e){(0,i.g)(0)}sortVerticesSimpleByY(t,e,s){this.m_bucketSort.sort(t,e,s,new No(this))}sortVerticesSimpleByX(t,e,s){(0,i.g)(0)}sortVerticesSimpleByY3D(t,e,s){(0,i.g)(0)}snapVertexForPoleClipping(t,e){const s=this.getPrevVertex(t);s!==To&&this.replaceCurveWithLine(s),this.getNextVertex(t)!==To&&this.replaceCurveWithLine(t);const i=new n.P;this.queryXY(t,i),i.y=e,this.setXY(t,i)}setSegmentParentageAndBreak(t,e,s=!0){if(-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,n.j)()>>1),e<<=1,e|=s?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}setSegmentParentagePreserveBreak(t,e){if((0,i.g)(e>=-1),-1===this.m_segmentParentageIndex){if(-1===e)return;this.m_segmentParentageIndex=this.createUserIndex()}e>=0&&((0,i.g)(e<=(0,n.j)()>>1),e<<=1,e|=this.getSegmentParentageBreakVertex(t)?1:0),this.setUserIndex(t,this.m_segmentParentageIndex,e)}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 Mo(e)}return new Mo(-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&=(0,n.j)()>>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);return e!==To&&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 qo(t){if(t.isEmpty())return new Ar({vd:t.getDescription()});const e=t.getImpl(),s=e.getPointCount();if(s<=2){if(1===s||e.getXY(0).equals(e.getXY(1))){const t=new Nt({vd:e.getDescription()});return e.getPointByVal(0,t),t}{const t=new Nt,s=new pr({vd:e.getDescription()});return e.getPointByVal(0,t),s.startPathPoint(t),e.getPointByVal(1,t),s.lineToPoint(t),s}}const i=e.getAttributeStreamRef(0),r=new Xo({stream:i,n:s});let o=1;const a=i.readPoint2D(0),h=new n.P;for(;o<s&&i.queryPoint2D(o<<1,h).equals(a);)o++;if(r.m_treeHull.addElement(0),o<s){r.m_treeHull.addBiggestElement(o);const t=new n.P;for(let s=o+1;s<e.getPointCount();s++){i.queryPoint2D(s<<1,t);const e=r.treeHull(t);-1!==e&&r.m_treeHull.setElement(e,s)}}const m=e.getDescription(),l=m.getAttributeCount()>1,u=r.m_treeHull.size();let c=null;if(u>=2){c=u>=3?new Ar({vd:m}):new pr({vd:m});const t=c.getImpl();t.reserve(r.m_treeHull.size()),t.addPathPoint2D(null,0,!0);const s=new n.P;for(let n=r.m_treeHull.getFirst();-1!==n;n=r.m_treeHull.getNext(n))if(l){const s=new Nt;e.getPointByVal(r.m_treeHull.getElement(n),s),t.insertPoint(0,-1,s)}else i.queryPoint2D(r.m_treeHull.getElement(n)<<1,s),t.insertPoint2D(0,-1,s)}else if(l){const t=new Nt({vd:m});e.getPointByVal(r.m_treeHull.getElement(r.m_treeHull.getFirst()),t),c=t}else{const t=i.readPoint2D(r.m_treeHull.getElement(r.m_treeHull.getFirst())<<1);c=new Nt(t)}return c}function Fo(t,e,s){if(e<=262144)return function(t,e,s){const i=new I(0);for(let t=0;t<e;t++)i.add(t);const n={userSort(e,s,i){i.sort(e,s,((e,s)=>t[e].compareX(t[s])))},getValue:e=>t[e].x};X.sortEx(i,0,e,n);let r=0;t:for(let n=0;n<e;++n){const e=i.read(n);for(;r>=2;){const o=s[r-2],a=s[r-1];if(t[a].equals(t[e])){i.write(n,-1);continue t}if(!(ko(t[o],t[a],t[e])>=0)){a===i.read(n-1)&&i.write(n-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 n=e-2;n>=0;--n){const e=i.read(n);if(!(e<0)){for(;r>=o;){const i=s[r-2],n=s[r-1];if(t[n].equals(t[e]))continue t;if(!(Ho(t[i],t[n],t[e])>=0))break;r--}if(0!==n){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}(t,e,s);(0,i.g)(0);const n=new Xo({points:t,n:e});let r=1;const o=t[0].clone();for(;r<e&&t[r].equals(o);)r++;if(n.m_treeHull.addElement(0),r<e){n.m_treeHull.addBiggestElement(r);for(let s=r+1;s<e;s++){const e=t[s],i=n.treeHull(e);-1!==i&&n.m_treeHull.setElement(i,s)}}let a=0;for(let t=n.m_treeHull.getFirst();-1!==t;t=n.m_treeHull.getNext(t))s[a++]=n.m_treeHull.getElement(t);return a}function Vo(t,e,s){const i=t.getImpl(),r=i.getPathStart(e),o=i.getPathEnd(e),a=!i.isClosedPath(e)&&i.isClosedPathInXYPlane(e),h=i.getAttributeStreamRef(0),m=2*r;let l=2*o;if(a&&(l-=2),l-m<6)return!0;const u=h.readPoint2D(m),c=h.readPoint2D(m+2),g=h.readPoint2D(m+4);if(!Bo(n.P.orientationRobust(c,g,u)))return!1;const _=c.clone(),d=new n.P;for(let t=m+6;t<l;t+=2){if(d.assign(c),c.assign(g),h.queryPoint2D(t,g),!Bo(n.P.orientationRobust(c,g,u)))return!1;if(!Bo(n.P.orientationRobust(_,g,u)))return!1;if(!Bo(n.P.orientationRobust(c,g,d)))return!1}return!0}function Ro(t,e,s,r,o){if(s.setNAN(),r.setCoords(1,0),o.setCoords(0,0),t.isEmpty())return;if(t.getGeometryType()===i.G.enumPoint)return void s.assign(t.getXY());const a=t,h=a.getPointCount();if(2===h){const t=a.getXY(0),e=a.getXY(1);s.assign(t.add(e).mul(.5));const i=e.sub(t);r=Uo(i),o.setCoords(.5*i.length(),0)}else{let t=Number.MAX_VALUE;const i=[0,1,0,0],m=new n.ap(4,2);for(m.set(0,0,0),m.set(0,1,1),m.set(1,0,1),m.set(1,1,2);i[0]<h;++i[0],Oo(m,0,h)){i[1]===i[0]&&(++i[1],Oo(m,1,h));for(let t=1;;++t){for(;;){const e=Wo(a.getXY(m.get(0,0)),a.getXY(m.get(0,1)),a.getXY(m.get(t,0)),a.getXY(m.get(t,1)),2^t);if(e>0)break;if(++i[t],Oo(m,t,h),0===e)break}if(3===t)break;i[t+1]<i[t]&&(i[t+1]=i[t],m.set(t+1,0,m.get(t,0)),m.set(t+1,1,m.get(t,1)))}const l=a.getXY(m.get(0,0)).add(a.getXY(m.get(2,0))).mul(.5),u=Uo(a.getXY(m.get(0,1)).sub(a.getXY(m.get(0,0)))),c=new n.P;let g,_;if(c.x=Math.max(0,u.dotProduct(a.getXY(m.get(1,0)).sub(a.getXY(m.get(3,0))))),c.y=Math.max(0,u.crossProduct(a.getXY(m.get(0,0)).sub(a.getXY(m.get(2,0))))),e?(g=c.x*c.y,_=g<t):(g=c.y,_=g<t),_){t=g;const e=a.getXY(m.get(1,0)),i=a.getXY(m.get(3,0)),n=e.add(i).mul(.5).sub(l);s.assign(l.add(u.mul(u.dotProduct(n)))),r.assign(u),o.assign(c)}}o.mulThis(.5),o.x<o.y&&(o.y=(0,n.b)(o.x,o.x=o.y),r.leftPerpendicularThis())}r.y<0?r.negateThis():0===r.y&&(r.x=1)}Go.st_defaultRank=1;class Yo{constructor(t){this.m_handleP=-1,this.m_handleQ=-1,this.m_currentSupport=-1,this.m_area=0,this.m_bDone=!0,(0,i.g)(0),this.m_convexHull=t,this.m_function=this.done_}next(){return(0,i.g)(0),!1}get_vertex_handle_p(){return(0,i.g)(0),0}get_vertex_handle_q(){return(0,i.g)(0),0}get_current_support(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}intialize_(){return(0,i.g)(0),!1}increment_(){return(0,i.g)(0),!1}increment_q_(){return(0,i.g)(0),!1}increment_p_(){return(0,i.g)(0),!1}parallel_edge_with_q_support_(){return(0,i.g)(0),!1}parallel_edge_with_p_support_(){return(0,i.g)(0),!1}done_(){return(0,i.g)(0),!1}}class Xo{nullGetXY(t){return(0,i.b)("m_getXY is null"),{}}nullDeleteNode(t){(0,i.b)("m_deleteNode is null")}constructor(t){return this.m_treeHull=new U,this.m_shape=null,this.m_stream=null,this.m_points=null,this.m_geometryHandle=-1,this.m_pathHandle=-1,this.m_getXY=this.nullGetXY,this.m_deleteNode=this.nullDeleteNode,t?t.stream?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_stream=t.stream,this.m_getXY=this.getXYStream,this.m_deleteNode=this.deleteNodeStream,this.m_points=null,this.m_geometryHandle=To,void(this.m_pathHandle=To)):t.points?(this.m_treeHull.setCapacity(Math.min(20,t.n)),this.m_points=t.points,this.m_getXY=this.getXYPoints,this.m_deleteNode=this.deleteNodePoints,this.m_stream=null,this.m_geometryHandle=To,void(this.m_pathHandle=To)):void(0,i.u)("unrecognized constructor parameter"):(this.m_treeHull.setCapacity(20),this.m_shape=new Go,this.m_geometryHandle=this.m_shape.createGeometry(i.G.enumMultiPoint),this.m_pathHandle=this.m_shape.insertPath(this.m_geometryHandle,To),this.m_getXY=this.getXYShape,this.m_deleteNode=this.deleteNodeShape,this.m_stream=null,void(this.m_points=null))}getXYShape(t){return this.m_shape.getXY(t)}getXYStream(t){return this.m_stream.readPoint2D(t<<1)}getXYPoints(t){return(0,i.g)(0),new n.P}deleteNodeShape(t){const e=this.m_treeHull.getElement(t);this.m_treeHull.deleteNode(t),this.m_shape.removeVertex(e,!1)}deleteNodeStream(t){this.m_treeHull.deleteNode(t)}deleteNodePoints(t){(0,i.g)(0)}addGeometry(t){if(t.isEmpty())return;const e=t.getGeometryType();if(e===i.G.enumGeometryCollection){const e=t;for(let t=0,s=e.getGeometryCount();t<s;t++)this.addGeometry(e.getGeometry(t))}else(0,i.i)(e)?this.addMultiVertexGeometry(t):(0,i.e)(e)?this.addSegment(t):e===i.G.enumEnvelope?this.addEnvelope(t):e===i.G.enumPoint?this.addPoint(t):(0,i.t)("Convex_hull: geometry not supported")}getBoundingGeometry(){const t=new Nt,e=this.m_treeHull.getFirst(),s=new Ar({vd:this.m_shape.getVertexDescription()});if(0===this.m_treeHull.size())return s;s.reserve(this.m_treeHull.size()),this.m_shape.queryPoint(this.m_treeHull.getElement(e),t),s.startPathPoint(t);for(let i=this.m_treeHull.getNext(e);-1!==i;i=this.m_treeHull.getNext(i))this.m_shape.queryPoint(this.m_treeHull.getElement(i),t),s.lineToPoint(t);return s}getAntipodalPairsIterator(){return(0,i.g)(0),new Yo(this)}getXY(t){return(0,i.g)(0),new n.P}getXYWithIndex(t){return(0,i.g)(0),new n.P}getFirst(){return(0,i.g)(0),0}getLast(){return(0,i.g)(0),0}getNext(t){return(0,i.g)(0),0}getPrev(t){return(0,i.g)(0),0}getVertexIndex(t){return(0,i.g)(0),0}getPointCount(){return(0,i.g)(0),0}addMultiVertexGeometry(t){const e=new Nt,s=t.getImpl(),i=new n.P;for(let n=0;n<t.getPointCount();n++){s.queryXY(n,i);const r=this.addPoint2D(i);if(-1!==r){t.getPointByVal(n,e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}}addEnvelope(t){const e=new Nt;for(let s=0;s<4;s++){const i=new n.P;t.queryCorner(s,i);const r=this.addPoint2D(i);if(-1!==r){t.queryCornerByVal(s,e);const i=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,i)}}}addSegment(t){const e=new Nt,s=t.getStartXY(),i=this.addPoint2D(s);if(-1!==i){t.queryStart(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(i,s)}const n=t.getEndXY(),r=this.addPoint2D(n);if(-1!==r){t.queryEnd(e);const s=this.m_shape.addPoint(this.m_pathHandle,e);this.m_treeHull.setElement(r,s)}}addPoint(t){const e=t.getXY(),s=this.addPoint2D(e);if(-1!==s){const e=this.m_shape.addPoint(this.m_pathHandle,t);this.m_treeHull.setElement(s,e)}}addPoint2D(t){let e=-1;if(0===this.m_treeHull.size())return e=this.m_treeHull.addElement(-4),e;if(1===this.m_treeHull.size()){const s=this.m_treeHull.getElement(this.m_treeHull.getFirst()),i=this.m_shape.getXY(s);return t.equals(i)||(e=this.m_treeHull.addBiggestElement(-5)),e}return e=this.treeHull(t),e}treeHull(t){let e=-1;do{const s=this.m_treeHull.getFirst(),i=this.m_treeHull.getLast(),r=this.m_treeHull.getElement(s),o=this.m_treeHull.getElement(i),a=this.m_getXY(r),h=this.m_getXY(o),m=n.P.orientationRobust(h,t,a);if(Bo(m)){e=this.m_treeHull.addBiggestElement(-1);const n=this.treeHullWalkBackward(t,i,s);n!==s&&this.treeHullWalkForward(t,s,this.m_treeHull.getPrev(n));break}if(Lo(m)){let r=this.m_treeHull.getRoot(),o=this.m_treeHull.getFirst(),h=this.m_treeHull.getLast(),m=-1,l=-1,u=-1;for(;o!==this.m_treeHull.getPrev(h);){l=this.m_treeHull.getElement(r);const e=this.m_getXY(l);Lo(n.P.orientationRobust(e,t,a))?(h=r,r=this.m_treeHull.getLeft(r)):(o=r,r=this.m_treeHull.getRight(r))}r=h,m=o,l=this.m_treeHull.getElement(r),u=this.m_treeHull.getElement(m);const c=this.m_getXY(l),g=this.m_getXY(u);if(m!==s&&!Bo(n.P.orientationRobust(g,t,c)))break;e=this.m_treeHull.addElementAtPosition(m,r,-2,!0,!1),this.treeHullWalkForward(t,r,i),this.treeHullWalkBackward(t,m,s);break}{const n=zo(t,h,a);if(-1===n){const n=this.m_treeHull.getPrev(i);this.m_treeHull.deleteNode(i),e=this.m_treeHull.addBiggestElement(-3),this.treeHullWalkBackward(t,n,s)}else if(1===n){const n=this.m_treeHull.getNext(s);this.m_treeHull.deleteNode(s),e=this.m_treeHull.addElementAtPosition(-1,n,-3,!0,!1),this.treeHullWalkForward(t,n,i)}break}}while(0);return e}treeHullWalkForward(t,e,s){if(e===s)return s;let i=e,r=this.m_treeHull.getElement(i),o=this.m_treeHull.getNext(i);const a=this.m_getXY(r);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(Bo(n.P.orientationRobust(s,t,a)))break;const h=i;i=o,r=e,a.assign(s),o=this.m_treeHull.getNext(i),this.m_deleteNode(h)}return i}treeHullWalkBackward(t,e,s){if(e===s)return s;let i=e,r=this.m_treeHull.getElement(i),o=this.m_treeHull.getPrev(i);const a=this.m_getXY(r);for(;i!==s&&this.m_treeHull.size()>2;){const e=this.m_treeHull.getElement(o),s=this.m_getXY(e);if(Bo(n.P.orientationRobust(a,t,s)))break;const h=i;i=o,r=e,a.assign(s),o=this.m_treeHull.getPrev(i),this.m_deleteNode(h)}return i}}function ko(t,e,s){const i=e.sub(t),r=s.sub(e);if(0===i.x)return r.x>0?-1:0;if(0===i.y)return r.y>0?1:r.y<0?-1:0;const o=i.crossProduct(r),a=4*Number.EPSILON*(Math.abs(r.x*i.y)+Math.abs(r.y*i.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,s)}function Ho(t,e,s){const i=e.sub(t),r=s.sub(e);if(0===i.x)return r.x<0?-1:0;if(0===i.y)return r.y>0?-1:r.y<0?1:0;const o=i.crossProduct(r),a=4*Number.EPSILON*(Math.abs(r.x*i.y)+Math.abs(r.y*i.x));return o>a?1:o<-a?-1:n.P.orientationRobust(t,e,s)}function Bo(t){return t<0}function Lo(t){return t>0}function zo(t,e,s){let i=-1;i=e.y===s.y?0:e.x===s.x?1:Math.abs(e.x-s.x)>=Math.abs(e.y-s.y)?0:1;let n=-1;return n=e[i]<s[i]?t[i]<e[i]?-1:s[i]<t[i]?1:0:e[i]<t[i]?-1:t[i]<s[i]?1:0,n}function Uo(t){return(t=t.clone()).divThis(Math.max(Math.abs(t.x),Math.abs(t.y))),t.normalize(),t}function Oo(t,e,s){t.inc(e,0)===s&&t.set(e,0,0),t.inc(e,1)===s&&t.set(e,1,0)}function Wo(t,e,s,r,o){switch(o){case 0:break;case 1:e.rightPerpendicularThis(),t.rightPerpendicularThis();break;case 2:e.negateThis(),t.negateThis();break;case 3:e.leftPerpendicularThis(),t.leftPerpendicularThis();break;default:(0,i.t)("")}return n.P.orientationRobustEx(t,e,s,r)}function jo(t,e,s,i,n){return Zo(t,!1,e,s,i,n)}function Zo(t,e,s,n,r,o){const a=s.getGeometryType(),h=n.getGeometryType(),m=Math.max(r,ge(s,n));if(a===i.G.enumLine&&h===i.G.enumLine)return we(s,n,m,o);let l=s,u=n,c=s.getStartXY(),g=s.getEndXY();if(c.compare(g)>0&&(l=s.clone().reverse()),c=n.getStartXY(),g=n.getEndXY(),c.compare(g)>0&&(u=n.clone().reverse()),e){if(s.equals(n))return 2;if(function(t,e,s){return(0,i.g)(t.isCurve()||e.isCurve()),!!(t.getStartXY().equals(e.getStartXY())&&te(t,e,0,0,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getEndXY())&&te(t,e,1,1,s,2,[0,0],[0,0])||t.getStartXY().equals(e.getEndXY())&&te(t,e,0,1,s,2,[0,0],[0,0])||t.getEndXY().equals(e.getStartXY())&&te(t,e,1,0,s,2,[0,0],[0,0]))}(s,n,m))return 4}switch(a){case i.G.enumLine:switch(h){case i.G.enumEllipticArc:return Eo(t,u,l,m,o);case i.G.enumBezier:return Ln(t,u,l,m,o);case i.G.enumRationalBezier2:return pi(t,u,l,m,o);case i.G.enumBezier2:return an(t,u,l,m,o);default:(0,i.b)("")}break;case i.G.enumEllipticArc:switch(h){case i.G.enumLine:return Eo(t,l,u,m,o);case i.G.enumEllipticArc:return function(t,e,s,i,n){if(n){if(0!==Qo(e,s))return 2}else if(Qt(e,s))return 1;return 0!==vo(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,l,u,m,o);case i.G.enumBezier:return zn(t,u,l,m,o);case i.G.enumRationalBezier2:return fi(t,u,l,m,o);case i.G.enumBezier2:return hn(t,u,l,m,o);default:(0,i.b)("")}break;case i.G.enumBezier:switch(h){case i.G.enumLine:return Ln(t,l,u,m,o);case i.G.enumEllipticArc:return zn(t,l,u,m,o);case i.G.enumBezier:return function(t,e,s,i,n){if(n){if(0!==Qo(e,s))return 2}else if(Qt(e,s))return 1;return 0!==Zn(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,l,u,m,o);case i.G.enumRationalBezier2:return Un(t,l,u,m,o);case i.G.enumBezier2:return On(t,l,u,m,o);default:(0,i.b)("")}break;case i.G.enumRationalBezier2:switch(h){case i.G.enumLine:return pi(t,l,u,m,o);case i.G.enumEllipticArc:return fi(t,l,u,m,o);case i.G.enumBezier:return Un(t,u,l,m,o);case i.G.enumRationalBezier2:return function(t,e,s,i,n){if(n){const i=Qo(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(Qt(e,s))return 1;return 0!==Ei(t,e,s,null,null,null,i,void 0!==n&&n,!0,!1)?4:0}(t,l,u,m,o);case i.G.enumBezier2:return xi(t,l,u,m,o);default:(0,i.b)("")}break;case i.G.enumBezier2:switch(h){case i.G.enumLine:return an(t,l,u,m,o);case i.G.enumEllipticArc:return hn(t,l,u,m,o);case i.G.enumBezier:return On(t,u,l,m,o);case i.G.enumRationalBezier2:return xi(t,u,l,m,o);case i.G.enumBezier2:return function(t,e,s,i,n){if(n){if(0!==Qo(e,s))return 2}else if(Qt(e,s))return 1;return 0!==un(t,e,s,null,null,null,i,n??!1,!0,!1)?4:0}(t,l,u,m,o);default:(0,i.b)("")}break;default:(0,i.b)("")}}function Qo(t,e,s=!0){if(!s&&!Ko(t,e))return 0;const n=t.isLine()&&e.isLine();if(t.getStartXY().equals(e.getStartXY())&&t.getEndXY().equals(e.getEndXY())){const s=1;if(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint1())&&i.getControlPoint2().equals(n.getControlPoint2())?s:0}if(r===i.G.enumEllipticArc)return Io(t,e,!1)?s:0;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.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(n)return s;const r=t.getGeometryType();if(r!==e.getGeometryType())return 0;if(r===i.G.enumBezier){const i=t,n=e;return i.getControlPoint1().equals(n.getControlPoint2())&&i.getControlPoint2().equals(n.getControlPoint1())?s:0}if(r===i.G.enumEllipticArc)return Io(t,e,!0)?s:-1;if(r===i.G.enumRationalBezier2){const i=t,n=e;if(i.getControlPoint1().equals(n.getControlPoint1())&&i.getStandardFormWeight()===n.getStandardFormWeight())return s}else if(r===i.G.enumBezier2){const i=e;if(t.getControlPoint1().equals(i.getControlPoint1()))return s}return 0}return 0}function Ko(t,e){const s=t.getGeometryType();return s===e.getGeometryType()&&(s!==i.G.enumEllipticArc||t.projectionBehavior()===e.projectionBehavior())}function Jo(t,e,s,n,r,o,a){!r&&o&&(0,i.t)("");const h=e.getGeometryType(),m=s.getGeometryType(),l=Math.max(a,ge(e,s));if(n&&(n.length=0),r&&(r.length=0),o&&(o.length=0),h===i.G.enumLine&&m===i.G.enumLine)return De(e,s,n,r,o,l,!1,!1);let u=e,c=s,g=e.getStartXY(),_=e.getEndXY(),d=!1,p=!1;g.compare(_)>0&&(u=e.clone(!0).reverse(),d=!0),g=s.getStartXY(),_=s.getEndXY(),g.compare(_)>0&&(c=s.clone(!0).reverse(),p=!0);let f=0;switch(h){case i.G.enumLine:switch(m){case i.G.enumEllipticArc:f=Co(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumBezier:f=Wn(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=yi(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumBezier2:f=mn(t,c,u,n,o,r,l,!1,0,!0);break;default:(0,i.b)("")}break;case i.G.enumEllipticArc:switch(m){case i.G.enumLine:f=Co(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=vo(t,u,c,n,r,o,l,!1,!1,!1);break;case i.G.enumBezier:f=jn(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=Pi(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumBezier2:f=ln(t,c,u,n,o,r,l,!1,0,!0);break;default:(0,i.b)("")}break;case i.G.enumRationalBezier2:switch(m){case i.G.enumLine:f=yi(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=Pi(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier:f=Qn(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=Ei(t,u,c,n,r,o,l,!1,!1,!1);break;case i.G.enumBezier2:f=Ci(t,u,c,n,r,o,l,!1,!1,!1);break;default:(0,i.b)("")}break;case i.G.enumBezier2:switch(m){case i.G.enumLine:f=mn(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=ln(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier:f=Kn(t,c,u,n,o,r,l,!1,0,!0);break;case i.G.enumRationalBezier2:f=Ci(t,c,u,n,o,r,l,!1,!1,!0);break;case i.G.enumBezier2:f=un(t,u,c,n,r,o,l,!1,!1,!1);break;default:(0,i.b)("")}break;case i.G.enumBezier:switch(m){case i.G.enumLine:f=Wn(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumEllipticArc:f=jn(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier:f=Zn(t,u,c,n,r,o,l,!1,!1,!1);break;case i.G.enumRationalBezier2:f=Qn(t,u,c,n,r,o,l,!1,0,!1);break;case i.G.enumBezier2:f=Kn(t,u,c,n,r,o,l,!1,0,!1);break;default:(0,i.b)("")}break;default:(0,i.b)("")}if(d){if(r){for(let t=0;t<f;t++)r[t]=1-r[t];r.reverse()}n&&n.reverse(),o&&o.reverse()}if(p&&o)for(let t=0;t<f;t++)o[t]=1-o[t];return f}function $o(t,e,s){return e===s?0:(e>s&&(s=(0,n.b)(e,e=s)),t.cut(e,s,!0).calculateUpperLength2D())}function ta(t,e,s,i,r,o,a,h,m,l,u,c,g){if(!o)return 0;const _=(t,e)=>{for(let s=0;s<o;++s){let i=e[s];if((0,n.a1)(i,0,1)){i=(0,n.at)(i);continue}const r=t.getCoord2D(i);i<.5?r.equals(t.getStartXY())&&$o(t,0,i)<=ce(t)&&(e[s]=0):r.equals(t.getEndXY())&&$o(t,i,1)<=ce(t)&&(e[s]=1)}};_(e,i),_(s,r),function(t,e,s,i,r){const o=[],a=[],h=[];for(let m=0,l=r;m<l;m++)o.push(t.calculateSubLengthFromStart(s[m])),a.push(e.calculateSubLengthFromStart(i[m])),(0,n.a1)(s[m],0,1)&&(0,n.a1)(i[m],0,1)&&t.getCoord2D(s[m]).equals(e.getCoord2D(i[m]))&&h.push(m);if(0===h.length||h.length===r)return;h.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 m=-1;for(const l of h){if(m>=0&&s[l]===s[m]&&s[l]===s[m]){m=l;continue}m=l;const h=[];h.length=r;for(let t=0;t<h.length;++t)h[t]=t;h.sort(((t,e)=>{const s=o[l],i=a[l],n=o[t]-s,r=a[t]-i,h=n*n+r*r,m=o[e]-s,u=a[e]-i,c=m*m+u*u;return h<c?-1:h>c?1:0}));for(let o=0;o<r;o++){const r=h[o];if(r===l||s[r]===s[l]&&i[r]===i[l]||(0,n.a1)(s[r],0,1)&&(0,n.a1)(i[r],0,1))continue;const a=(s,i,r,o)=>{const a=new Wt,h=new n.H;h.setWithEps(1);const m=new n.H;m.set(i,h.eps()),t.queryCoord2DE(m,a);const l=new Wt;t.queryCoord2DE(new n.H(s),l);let u=!1;return a.eq(l)&&(m.set(o,h.eps()),e.queryCoord2DE(m,a),e.queryCoord2DE(new n.H(r),l),u=a.eq(l)),!u},m=n.P.getNAN();t.queryCoord2D(s[r],m);const u=n.P.getNAN();if(e.queryCoord2D(i[r],u),0===n.P.distance(m,u)&&a(s[l],s[r],i[l],i[r]))break;const c=new n.E(i[r],i[l]);c.normalizeNoNAN();const g=new n.E(s[r],s[l]);g.normalizeNoNAN();let _=-1,d=Number.POSITIVE_INFINITY,p=Number.POSITIVE_INFINITY,f=s[r];m.assign(t.getCoord2D(f));for(let o=0;o<5;o++){const o=e.getClosestCoordinateOnInterval(m,c,-1);u.assign(e.getCoord2D(o));const h=n.P.distance(m,u);if(f=t.getClosestCoordinateOnInterval(u,g,-1),f===s[l]&&o===i[l]){_=1;break}m.assign(t.getCoord2D(f));const x=n.P.distance(u,m);if(!(x<p&&h<d)){_=0;break}if(0===x&&0===h){a(s[l],s[r],i[l],i[r])?(s[r]=f,i[r]=o,_=0):_=1;break}p=x,d=h}if(-1===_&&(_=(0,n.a1)(s[r],0,1)||(0,n.a1)(i[r],0,1)?0:1),1!==_)break;s[r]=s[l],i[r]=i[l]}}}(e,s,i,r,o);const d=[];for(let t=0,e=o;t<e;t++)d.push(t);const p=(t,e)=>g?(0,n.au)(r[t],i[t],r[e],i[e]):(0,n.au)(i[t],r[t],i[e],r[e]);if(d.length>1){d.sort(p);const t=Math.max(ce(e),ce(s));let o=0;for(let a=1,h=d.length;a<h;a++){const h=i[d[o]],m=i[d[a]],l=r[d[o]],u=r[d[a]];if(h!==m||l!==u)if(!($o(e,h,m)<=t&&$o(s,l,u)<=t)||(0,n.a1)(h,0,1)&&(0,n.a1)(l,0,1)||(0,n.a1)(m,0,1)&&(0,n.a1)(u,0,1))o++,d[o]=d[a];else{const t=n.P.distance(e.getCoord2D(h),s.getCoord2D(l)),i=n.P.distance(e.getCoord2D(m),s.getCoord2D(u));if(t<=i)continue;if(i<t){d[o]=d[a];continue}}}if(d.length=o+1,1===d.length&&0!==d[0]&&(i[0]=i[d[0]],r[0]=r[d[0]],d[0]=0),d.length>2){const t=n.E.constructEmpty(),o=n.E.constructEmpty();t.setCoords(i[d[0]],i[d.at(-1)]),o.setCoords(r[d[0]],r[d.at(-1)]);let a=!0;for(let e=1,s=d.length-1;e<s;e++)if(!t.containsCoordinate(i[d[e]])||!o.containsCoordinate(r[d[e]])){a=!1;break}if(a){const i=[.5,.2,.7,.1,.3,.4,.6,.8,.9];for(let r=0;r<i.length;r++){let h=(0,n.w)(t.vmin,t.vmax,i[r]);const m=e.getCoord2D(h);if(!s.isCloserThanDistance(m,o,l)){a=!1;break}h=(0,n.w)(o.vmin,o.vmax,i[r]);const u=s.getCoord2D(h);if(!e.isCloserThanDistance(u,t,l)){a=!1;break}}}a&&(d[1]=d.at(-1),d.length=2)}}if(1===d.length&&t){const t=0,n=0;te(e,s,i[0],r[0],l,1,[t],[n])&&(d.push(1),i[1]=t,r[1]=n,d.sort(p))}if(u&&1===d.length){let t=!0;for(let o=0,a=d.length;o<a;o++)if(!(0,n.a1)(i[d[o]],0,1)||!(0,n.a1)(r[d[o]],0,1)||0!==n.P.distance(e.getCoord2D(i[d[o]]),s.getCoord2D(r[d[o]]))){t=!1;break}if(t)return 0}let f=0;for(let t=0,s=d.length;t<s;t++){if(h&&h.push(i[d[t]]),m&&m.push(r[d[t]]),a){const s=n.P.getNAN();e.queryCoord2D(i[d[t]],s),a.push(s)}f++}return f}function ea(t,e,s,i,r,o,a,h,m){if((0,n.a1)(s,0,1)&&(0,n.a1)(i,0,1)&&0===n.P.distance(t.getCoord2D(s),e.getCoord2D(i))){const l=1e-12,u=new Wt,c=Number.EPSILON;if(t.queryDerivative(new n.H(s,c),u),u.isTrueZero()){const e=1===s?-l:l;t.queryDerivative(new n.H(s,c).add(e),u)}1===s&&u.negateThis();const g=new Wt;if(e.queryDerivative(new n.H(i,c),g),g.isTrueZero()){const t=1===s?-l:l;e.queryDerivative(new n.H(i,c).add(t),g)}1===i&&g.negateThis(),u.isZero()||u.normalize(),g.isZero()||g.normalize();const _=u.dotProduct(g),d=u.crossProduct(g);d.scaleError(3);const p=()=>{if(m)return.001;{const s=t.calculateUpperLength2D(),i=e.calculateUpperLength2D();return Math.min(.01*r/Math.min(s,i),1e-10)}};if(_.ge(n.C)&&(d.isZero()||Math.abs(d.value())<p()))return $t(t,e,s,i,r,o,a,h)}return 0}function sa(t,e,s,r,o){let a=-1,h=-1,m=-1,l=-1;{const i=[0,e],n=[e,0],o=[0,r],u=[r,0];for(let e=0;e<2&&-1===a;++e)for(let r=0;r<2;++r)if(t[i[e]].equals(s[o[r]])){a=i[e],h=n[e],m=o[r],l=u[r];break}}if(-1===a){const i=new Ht;i.setFromPoints(t,e+1);const n=new Ht;return n.setFromPoints(s,r+1),n.inflate(o),i.isIntersectingW(n)?-1:0}{const u=new Array(e+1),c=Fo(t,e+1,u);(0,i.g)(c>1);let g=0,_=0;for(let t=0;t<c;++t)a===u[t]&&(_=t,g++),h===u[t]&&g++;if(2!==g)return-1;const d=new Array(r+1),p=Fo(s,r+1,d);(0,i.g)(p>1),g=0;let f=0;for(let t=0;t<p;++t)m===d[t]&&(f=t,g++),l===d[t]&&g++;if(2!==g)return-1;const x=t[u[(_+c-1)%c]],y=t[u[(_+1)%c]],P=s[d[(f+p-1)%p]],E=s[d[(f+1)%p]],C=t[a],v=[x,y,P,E],b=[0,1,2,3];b.sort(((t,e)=>n.P.compareVectorsOrigin(C,v[t],v[e])));let S=b[0];for(let t=1;t<4;t++){if(b[t]!==(S+1)%4)return-1;S=b[t]}{const t=x.sub(C),e=E.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}{const t=y.sub(C),e=P.sub(C),s=e.dotProduct(t);if(s>0){const i=e.crossProduct(t),n=Math.abs(Math.atan2(i,s)),r=n*t.length(),a=n*e.length();if(r<=o||a<=o)return-1}}return 1}}var ia=g;class na extends ye{constructor(t){super(t||{XStart:0,YStart:0,XEnd:0,YEnd:0})}assignMove(t){return this!==t&&(this.m_description=t.m_description,t.m_description=null,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}calculateLowerLength3D(){return(0,i.g)(0),0}calculateUpperLength3D(){return(0,i.g)(0),0}changeEndPoints3D(t,e){(0,i.g)(0)}getClosestCoordinate3D(t,e,s){return(0,i.g)(0),0}getBoundary(){return yr(this)}getAttributeAsDbl(t,e,s){if(0===e)return 0===s?Ce(this,t):ve(this,t);const i=ia.getInterpolation(e),r=this.getStartAttributeAsDbl(e,s),o=this.getEndAttributeAsDbl(e,s);return(0,n.$)(i,r,o,t,ia.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)}construct3D(t,e){(0,i.g)(0)}constructPoint(t,e){this.assignVertexDescription(t.getDescription()),this.mergeVertexDescription(e.getDescription()),this.setStart(t),this.setEnd(e)}getGeometryType(){return na.type}queryEnvelope(t){if(4===t.m_EnvelopeType){t.setEmpty(),t.assignVertexDescription(this.m_description);const e=o.constructEmpty();this.queryEnvelope(e),t.setEnvelope(e);for(let e=1,s=this.m_description.getAttributeCount();e<s;e++){const s=this.m_description.getSemantics(e);for(let i=0,n=ia.getComponentCount(s);e<n;e++){const e=this.queryInterval(s,i);t.setIntervalEnvelope(s,i,e)}}}else 2===t.m_EnvelopeType?t.setCoords({xmin:this.m_XStart,ymin:this.m_YStart,xmax:this.m_XEnd,ymax:this.m_YEnd}):3===t.m_EnvelopeType?(t.setEmpty(),t.mergeCoords(this.m_XStart,this.m_YStart,me(this,0,1,0)),t.mergeCoords(this.m_XEnd,this.m_YEnd,me(this,1,1,0))):(0,i.a)("env type not impl")}applyTransformation(t){(0,i.g)(t instanceof n.T);const e=new n.P;e.x=this.m_XStart,e.y=this.m_YStart,t.transformInPlace(e),this.m_XStart=e.x,this.m_YStart=e.y,e.x=this.m_XEnd,e.y=this.m_YEnd,t.transformInPlace(e),this.m_XEnd=e.x,this.m_YEnd=e.y}createInstance(){return new na({vd:this.m_description})}calculateLength2D(){return Math.sqrt(Ge(this))}calculateLength3D(t){return(0,i.g)(0),0}changeEndPoints2D(t,e){this.setStartXY(t),this.setEndXY(e),this.normalizeAfterEndpointChange()}queryCoord2D(t,e){return Pe(this,t,e)}queryCoord3D(t,e){(0,i.g)(0)}getCoordZ(t){return function(t,e){const s=t.getStartZ(),i=t.getEndZ();return(0,n.w)(s,i,e)}(this,t)}queryCoord2DE(t,e){be(this,t,e)}getCoordX(t){return Ce(this,t)}getCoordY(t){return ve(this,t)}cut(t,e,s){const i=new ra;return this.queryCut(t,e,i,s),i.releaseSegment()}queryCut(t,e,s,i){const r=s.createLine();i&&r.assignVertexDescription(this.m_description);const o=n.P.getNAN();if(Pe(this,t,o),r.setStartXYCoords(o.x,o.y),Pe(this,e,o),r.setEndXYCoords(o.x,o.y),!i)for(let s=1,i=this.m_description.getAttributeCount();s<i;s++){const i=this.m_description.getSemantics(s),n=ia.getComponentCount(i);for(let s=0;s<n;s++){const n=this.getAttributeAsDbl(t,i,s);r.setStartAttribute(i,s,n);const o=this.getAttributeAsDbl(e,i,s);r.setEndAttribute(i,s,o)}}}queryDerivative(t,e){!function(t,e,s){const i=Wt.constructPoint2D(t.getStartXY()),n=Wt.constructPoint2D(t.getEndXY());s.setCoordsE(n.x.subE(i.x),n.y.subE(i.y))}(this,0,e)}getClosestCoordinate(t,e){return n.P.getClosestCoordinate(this.getStartXY(),this.getEndXY(),t,e)}getClosestCoordinateOnInterval(t,e,s=-1){const i=new n.P;this.queryCoord2D(e.vmin,i);const r=new n.P;this.queryCoord2D(e.vmax,r);const o=n.P.getClosestCoordinate(i,r,t,!1);return fe.recalculateParentT(e.vmin,e.vmax,o)}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=Ce(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(t,e){return(0,i.g)(0),!1}queryLooseEnvelope(t){this.queryEnvelope(t)}clone(t){const e=new na;return this.copyTo(e),e}tToLength(t){return t*this.calculateLength2D()}lengthToT(t){const e=this.calculateLength2D();return 0!==e?t/e:0}calculateWeightedAreaCentroid2D(t){const e=new n.P;return e.setCoords(0,0),e}calculateWeightedCentroid2D(){return this.getCoord2D(.5).mul(this.calculateLength2D())}getTangent(t){const e=n.P.getNAN();return e.setSub(this.getEndXY(),this.getStartXY()),e}getDerivative(t){const e=new n.P;return e.setSub(this.getEndXY(),this.getStartXY()),e}getCurvature(t){return 0}isIntersectingPoint(t,e,s){return Te(this,t,e,s)>=0}isIntersectingPoint3D(t,e,s,n,r=1){return(0,i.g)(0),!1}getYMonotonicParts(t,e){return 0}getMonotonicParts(t,e){return 0}getMonotonicPartParams(t,e){return e&&(t<2&&(0,i.t)(""),e[0]=0,e[1]=1),2}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]=Ce(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]=ve(this,n)),i&&(i[0]=n),1)}}calculateUpperLength2D(){return this.calculateLength2D()}calculateLowerLength2D(){return this.calculateLength2D()}normalizeAfterEndpointChange(){return!1}queryLooseEnvelopeOnInterval(t,e){if(2===e.m_EnvelopeType){let s=(0,n.l)(t.vmin,0,1);const i=new n.P;return this.queryCoord2D(s,i),e.setCoords({pt:i}),s=(0,n.l)(t.vmax,0,1),this.queryCoord2D(s,i),void e.mergeNe(i)}(0,i.a)("3d dst not impl")}orientBottomUp(){Ie(this)}isLine(){return!0}isDegenerateToLineHelper(t){return!0}copyIgnoreAttributes(t){t.setStartXY(this.getStartXY()),t.setEndXY(this.getEndXY()),t.normalizeAfterEndpointChange()}calculateArea2DHelper(){return 0}absNormXYZ(t){return function(t,e){const s=t.getStartXYZ();s.z*=e;const i=t.getEndXYZ();return i.z*=e,s.norm(1)+i.norm(1)}(this,t)}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(t,e){Se(this,t[0],t[e-1])}writeInBufferStream(t,e){return(0,i.g)(0),0}readFromBufferStream(t,e){(0,i.g)(0)}snapControlPoints(t){return!1}needsSnapControlPoints(t){return!1}calculateSpecialPointsForCracking(t,e){return 0}ensureXYMonotone(){return!1}setCoordsForIntersector(t,e,s){Se(this,t,e)}static isIntersectingLineLine(t,e,s,i){return we(t,e,s,i)}static isIntersectingLineLine_(t,e,s,i){return we(t,e,s,i)}copyToImpl(t){}reverseImpl(){}equalsImpl(t){return!0}equalsImplTol(t,e){return!0}swapImpl(t){}afterCompletedModification(){}endPointModified(){}clearEndPointModified(){}intersect(t,e,s,i,n){return Jo(!1,this,t,e,s,i,n)}intersectPoint(t,e,s){e.length<1&&(0,i.w)("");const n=Te(this,t,s,!1);return n>=0?(e&&(e[0]=n),1):0}isIntersecting(t,e,s){return 0!==jo(!1,this,t,e,s)}}na.type=i.G.enumLine;class ra{constructor(t){this.m_seg=null,this.m_curves=null,this.m_lineBuffer=new na,this.m_mask=0,this.m_active=0,void 0!==t&&(t.copy?t.copy.copyTo(this,!1):t.move?this.assignMove(t.move):t.segment?this.copyFrom(t.segment,!!t.bIgnoreAttributes):(0,i.b)("bad constructor params"))}assignCopy(t){return t instanceof ra?this!==t&&t.copyTo(this,!1):this.copyFrom(t,!1),this}assignMove(t){if(t instanceof ra){if(this===t)return this;this.reset(),1&t.m_mask&&(this.m_lineBuffer=t.m_lineBuffer,t.m_lineBuffer=null,this.m_mask=1),this.m_curves=t.m_curves,this.m_mask=t.m_mask,this.m_active=t.m_active,t.reset(),this.m_seg=this.activeSegment(),t.m_seg=null}else{if(this.m_seg===t)return this;this.create(t.getGeometryType()),this.m_seg.swap(t)}return this}activeSegment(){switch(this.m_active){case 0:return null;case 1:return this.line();case 2:return this.arc();case 4:return this.bezier3();case 8:return this.bezier2();case 16:return this.rbezier2();default:(0,i.b)("")}}get(){return this.m_seg}reset(){1&this.m_mask&&(this.m_lineBuffer=null),this.m_mask>1&&(this.m_curves=null),this.m_mask=0,this.m_active=0}empty(){return null===this.m_seg}copyTo(t,e){this!==t&&(this.empty()?t.m_seg=null:t.copyFrom(this.m_seg,e))}copyToWithZ(t,e){(0,i.g)(0)}createImpl(t){switch(t){case i.G.enumLine:1&this.m_mask||(this.m_lineBuffer=new na,this.m_mask|=1,this.m_active=1);break;case i.G.enumEllipticArc:2&this.m_mask||(this.m_curves=new Nr,this.m_mask=1&this.m_mask|2,this.m_active=2);break;case i.G.enumBezier:4&this.m_mask||(this.m_curves=new pn,this.m_mask=1&this.m_mask|4,this.m_active=4);break;case i.G.enumBezier2:8&this.m_mask||(this.m_curves=new rs,this.m_mask=1&this.m_mask|8,this.m_active=8);break;case i.G.enumRationalBezier2:16&this.m_mask||(this.m_curves=new as,this.m_mask=1&this.m_mask|16,this.m_active=16);break;default:(0,i.t)("")}}create(t){t===i.G.enumLine?this.createLine():t===i.G.enumEllipticArc?this.createEllipticArc():t===i.G.enumBezier?this.createCubicBezier():t===i.G.enumRationalBezier2?this.createQuadraticRationalBezier():t===i.G.enumBezier2?this.createQuadraticBezier():(0,i.t)("Segment_buffer.create")}copyFrom(t,e){this.m_seg!==t&&(this.create(t.getGeometryType()),e?t.copyIgnoreAttributes(this.m_seg):t.copyTo(this.m_seg))}copyFromWithZ(t,e){(0,i.g)(0)}line(){return this.m_lineBuffer}arc(){return this.m_curves}bezier3(){return this.m_curves}bezier2(){return this.m_curves}rbezier2(){return this.m_curves}createLine(){return this.createImpl(i.G.enumLine),this.m_seg=this.line(),this.line()}createEllipticArc(){return this.createImpl(i.G.enumEllipticArc),this.m_seg=this.arc(),this.arc()}createCubicBezier(){return this.createImpl(i.G.enumBezier),this.m_seg=this.bezier3(),this.bezier3()}createQuadraticRationalBezier(){return this.createImpl(i.G.enumRationalBezier2),this.m_seg=this.rbezier2(),this.rbezier2()}createQuadraticBezier(){return this.createImpl(i.G.enumBezier2),this.m_seg=this.bezier2(),this.bezier2()}releaseSegment(){if(this.m_seg=null,0===this.m_active&&(0,i.b)("releaseSegment"),1&this.m_active){const t=this.line();return this.m_mask-=1,this.m_active=0,this.m_lineBuffer=null,t}let t;return 2&this.m_active?t=this.arc():4&this.m_active?t=this.bezier3():8&this.m_active?t=this.bezier2():16&this.m_active?t=this.rbezier2():(0,i.b)("releaseSegment"),this.m_mask-=this.m_active,this.m_active=0,this.m_curves=null,t}equals(t){return t instanceof ra?this===t||(this.empty()?t.empty():!t.empty()&&this.get().equals(t.get())):((0,i.a)("seg comparison not yet impl"),!1)}}},11878:(t,e,s)=>{s.d(e,{$:()=>ht,A:()=>yt,B:()=>V,C:()=>f,D:()=>lt,E:()=>m,F:()=>pt,G:()=>jt,H:()=>u,I:()=>ae,J:()=>oe,K:()=>n,L:()=>Qt,M:()=>we,N:()=>ut,O:()=>ce,P:()=>Me,Q:()=>Lt,R:()=>zt,S:()=>Dt,T:()=>Fe,U:()=>mt,V:()=>me,W:()=>dt,X:()=>_e,Y:()=>wt,Z:()=>q,_:()=>F,a:()=>It,a0:()=>_t,a1:()=>pe,a2:()=>D,a3:()=>T,a4:()=>Ut,a5:()=>P,a6:()=>E,a7:()=>N,a8:()=>A,a9:()=>M,aA:()=>ie,aB:()=>Ae,aC:()=>S,aD:()=>Yt,aa:()=>de,ab:()=>Nt,ac:()=>Pe,ad:()=>be,ae:()=>Ce,af:()=>Ee,ag:()=>it,ah:()=>nt,ai:()=>x,aj:()=>y,ak:()=>Te,al:()=>De,am:()=>X,an:()=>ye,ao:()=>st,ap:()=>Gt,aq:()=>vt,ar:()=>U,as:()=>k,at:()=>Se,au:()=>ft,av:()=>ge,aw:()=>ne,ax:()=>Ct,ay:()=>w,az:()=>xe,b:()=>ct,c:()=>I,d:()=>Tt,e:()=>Y,f:()=>Pt,g:()=>Ot,h:()=>re,i:()=>he,j:()=>Wt,k:()=>bt,l:()=>fe,m:()=>Et,n:()=>gt,o:()=>Zt,p:()=>At,q:()=>Mt,r:()=>et,s:()=>H,t:()=>St,u:()=>B,v:()=>xt,w:()=>G,x:()=>R,y:()=>C,z:()=>b});var i=s(55537);class n{constructor(t){this.sum=t,this.compensation=0}assign(t){return this.compensation=t.compensation,this.sum=t.sum,this}reset(){this.sum=this.compensation=0}resetToStart(t){this.sum=t,this.compensation=0}normalize(){const t=[Number.NaN];this.sum=tt(this.sum,this.compensation,t),this.compensation=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=Q(t,e,s);this.add(i),this.add(s[0])}mul(t){const e=new n(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}}const r=[5,1,2,1,3,1,2,1,4,1,2,1,3,1,2,1],o=[-1,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3];function a(t){let e=0;return 65535n&t||(e+=16,t>>=16n),255n&t||(e+=8,t>>=8n),15n&t||(e+=4,t>>=4n),e+r[Number(BigInt.asUintN(4,t))]}function h(t){let e=0;return 4294967295n&t||(e=32,t>>=32n),e+a(BigInt.asUintN(32,t))}class m{constructor(t,e){if(this.m_EnvelopeType=1,void 0!==t){if(t instanceof m)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 m(t,e)}static constructEmpty(){return new m}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 Lt(this.vmin,t)&&Lt(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 this.vmin===this.vmax}setInfinite(){this.vmin=Number.NEGATIVE_INFINITY,this.vmax=Number.POSITIVE_INFINITY}move(t){this.isEmpty()||(this.vmin+=t,this.vmax+=t)}contains(t){return t.vmin>=this.vmin&&t.vmax<=this.vmax}containsCoordinate(t){return t>=this.vmin&&t<=this.vmax}containsRightExclusive(t){return t>=this.vmin&&t<this.vmax}containsExclusiveCoordinate(t){return t>this.vmin&&t<this.vmax}containsExclusive(t){return t.vmin>this.vmin&&t.vmax<this.vmax}isIntersecting(t){return this.vmin<=t.vmin?this.vmax>=t.vmin:t.vmax>=this.vmin}mergeCoordinate(t){if(this.isEmpty())return this.vmin=t,void(this.vmax=t);this.mergeNeCoordinate(t)}merge(t){if(t.isEmpty())return;const 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(t){this.isEmpty()||t.isEmpty()?this.setEmpty():(this.vmin<t.vmin&&(this.vmin=t.vmin),this.vmax>t.vmax&&(this.vmax=t.vmax),this.vmin>this.vmax&&this.setEmpty())}inflate(t){this.isEmpty()||(this.vmin-=t,this.vmax+=t,this.vmax<this.vmin&&this.setEmpty())}normalize(){this.vmin<=this.vmax||(this.vmin>this.vmax?this.vmax=ct(this.vmin,this.vmin=this.vmax):this.setEmpty())}isValid(){return this.isEmpty()||this.vmin<=this.vmax}snapClip(t){return fe(t,this.vmin,this.vmax)}calculateToleranceFromEnvelope(){return this.isEmpty()?ce():(Math.abs(this.vmin)+Math.abs(this.vmax)+1)*ce()}static unit(){return l}normalizeNoNAN(){this.vmin>this.vmax&&(this.vmax=ct(this.vmin,this.vmin=this.vmax))}setCoordsNoNAN(t,e){this.vmin=t,this.vmax=e,this.normalizeNoNAN()}clone(){return new m(this.vmin,this.vmax)}}const l=new m(0,1);class u{static getNAN(){return new u(Number.NaN)}constructor(t,e){this.m_value=t??0,this.m_eps=e??0}[Symbol.toPrimitive](t){return this}clone(){return new u(this.m_value,this.m_eps)}assign(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}scaleError(t){this.m_eps*=t}setError(t){this.m_eps=t}set(t,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=u.ulp(t)*e,this}setE(t){return this.m_value=t.m_value,this.m_eps=t.m_eps,this}precise(){return new u(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+u.ulp(e);return this.m_value=e,this.m_eps=s,this}addThis(t){const e=this.m_value+t,s=this.m_eps+u.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+u.ulp(e);return this.m_value=e,this.m_eps=s,this}subThis(t){const e=this.m_value-t,s=this.m_eps+u.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+u.ulp(this.m_value),this}setAdd(t,e){return this.m_value=t+e,this.m_eps=u.ulp(this.m_value),this}setAddEN(t,e){return this.m_value=t.m_value+e,this.m_eps=t.m_eps+u.ulp(this.m_value),this}setAddNE(t,e){return this.m_value=t+e.m_value,this.m_eps=e.m_eps+u.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+u.ulp(this.m_value),this}setSub(t,e){return this.m_value=t-e,this.m_eps=u.ulp(this.m_value),this}setSubEN(t,e){return this.m_value=t.m_value-e,this.m_eps=t.m_eps+u.ulp(this.m_value),this}setSubNE(t,e){return this.m_value=t-e.m_value,this.m_eps=e.m_eps+u.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+u.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)+u.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+u.ulp(s),this.m_value=s,this}setMul(t,e){return this.m_value=t*e,this.m_eps=u.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 u(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+u.ulp(s),this}divThis(t){const e=Math.abs(t);return this.m_value/=t,this.m_eps=this.m_eps/e+u.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=u.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(x.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+=u.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+u.ulp(t),this.m_value=t,this}setSin(t){const e=Math.sin(t.m_value),s=Math.cos(t.m_value);this.m_value=e;const i=Math.abs(e),n=Math.abs(t.value());return this.m_eps=(Math.abs(s)+.5*i*t.m_eps)*t.m_eps+u.ulp(i+n),this}static ulp(t){let e=Xt(t);const s=((0x7ff0000000000000n&e)>>52n)-1075n;return s>-1023n?(e=s+0x3ffn<<52n,function(t){return Vt[0]=t,Ft[0]}(e)):0===t?0:Number.MIN_VALUE}setCos(t){const e=Math.sin(t.m_value),s=Math.cos(t.m_value);this.m_value=s;const i=Math.abs(s),n=Math.abs(t.value());return this.m_eps=(Math.abs(e)+.5*i*t.m_eps)*t.m_eps+u.ulp(i+n),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+u.ulp(r+a),e.m_eps=(Math.abs(i)+.5*o*t.m_eps)*t.m_eps+u.ulp(o+a)}negate(){return this.clone().negateThis()}negateThis(){return this.m_value=-this.m_value,this}setAbs(){return this.m_value=Math.abs(this.m_value),this}isInInterval(t){return m.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(p)}setEuler(){this.set(2.718281828459045,d())}static size(){return 1}}function c(t,e){const s=kt(t),i=kt(e),n=53-h(s),r=53-h(i);return(n>=0?n:0)+(r>=0?r:0)<=52}function g(t,e){const s=t+e;return s-t===e&&s-e===t}function _(t,e){const s=t-e;return t-s===e&&e+s===t}function d(){return de()}u.dimensions=1;const p=new u(Math.PI,.5*d()),f=new u(0,0),x=new u(1,0),y=new u(4,0);function P(t,e,s){return t.addE(e.subE(t).mulE(s))}function E(t,e,s){return e.subE(e.subE(t).mulE(x.subE(s)))}function C(t){let e;if(0===t)e=1;else if(Math.abs(t)>.01)e=function(t){return Math.atanh(t)}(t)/t;else{let s;const i=-36.841361487904734;e=0;const n=t*t;for(let t=2*Math.trunc(i/Math.log(n)+2.5)-1;t>1;t-=2)s=1/t,e=(e+s)*n;e+=1}return e}function v(t){const e=Math.PI*Math.PI/6;let s;if(1===t)s=e;else if(t>1)s=e;else if(0===t)s=t;else if(t<0){const e=1+(t=Math.abs(t)),i=Math.log(e);s=i*i/-2-v(t/e)}else if(t>.5){const i=1-t,n=Math.log(t)*Math.log(i);s=e-v(i)-n}else{s=0;const e=1+Math.trunc(-16*Math.log(10)/Math.log(t)+1.5);let i=e;for(let n=e;n>0;n--,i-=1)s*=t,s+=1/(i*i);s*=t}return s}function b(t,e){const s=e*t;if(Math.abs(e)<.1){let e=0;for(let t=60;t>=1;t--)e*=s,e+=1/t/t;return e*=t,e}return v(s)/e}function S(t,e){return t<e?Tt(t,e):Tt(e,t)}function I(t,e){const s=Math.abs(t);return e>=0?s:-s}function w(t){return Math.round(t)}function D(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 T(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 N(t,e,s,i,n){i<=.5?D(t,e,s,i,n):T(t,e,s,i,n)}function A(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 M(t,e,s,i,n){n[0]=s[0].subE(s[0].subE(e[0]).mulE(x.subE(i))),n[1]=s[1].subE(s[1].subE(e[1]).mulE(x.subE(i)))}function G(t,e,s){let i;return i=s<=.5?t+(e-t)*s:e-(e-t)*(1-s),i}function q(t,e,s){return t+(e-t)*s}function F(t,e,s){return e-(e-t)*(1-s)}function V(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 R(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.z=t.z+(e.z-t.z)*s):(i.x=e.x-(e.x-t.x)*(1-s),i.y=e.y-(e.y-t.y)*(1-s),i.z=e.z-(e.z-t.z)*(1-s))}function Y(t){return t*t}function X(t){return t*t*t}function k(t){return 1/Math.sqrt(t)}function H(t){return t<0?-1:t>0?1:0}function B(t,e,s,i){const n=[0],r=[0],o=[0];return tt(Q(t,s,n),Q(e,i,r),o)+(n[0]+r[0]+o[0])}const L=[0],z=[0];function U(t,e,s){return function(t,e,s,i){const n=tt(t,e,J),r=tt(n,s,$);return tt(r,J[0]+$[0],i)}(Q(t,e,L),s,L[0],z)}const O=[0],W=[0],j=[0],Z=[0];function Q(t,e,s){const i=t*e;return K(t,O,W),K(e,j,Z),s[0]=W[0]*Z[0]-(i-O[0]*j[0]-W[0]*j[0]-O[0]*Z[0]),i}function K(t,e,s){const i=134217729*t;e[0]=i-(i-t),s[0]=t-e[0]}const J=[0],$=[0];function tt(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 et(t,e){return t%e}function st(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 Ce()*(1-e*(s+e*(i+e*(n+e*(r+e*(o+e*(a+e*(h+e*m))))))))}s=rt(0,e,1)-t*ot(0,e,1)/3}return fe(s,1,Ce())}function it(t,e,s=Number.NaN){if((0,i.g)(e>=0&&e<=1),0===e)return t;let n=1,r=t;if(r<0&&(r=-r,n=-1),1===e){const t=Math.round(r/Pe()),e=r-t*Pe();return n*(2*t+Math.sin(e))}const o=Ce(),a=Math.floor(r/o);1&a?r=(a+1)*o-r:r-=a*o;const h=Math.sin(r),m=Number.isNaN(s)?st(e):s;let l;if(1===h)l=m+Math.sqrt(1-e)*(r-o);else{const t=r*r;if(.01424*Math.pow(t,4)<=2*de())l=r*(1+t*e*(-1/6+t*((4-3*e)/120-(16+(45*e-60)*e)/5040*t)));else if(e<=.01){const t=Math.sin(2*r),s=Math.sin(4*r),i=Math.sin(6*r),n=Math.sin(8*r),o=Math.sin(10*r);l=r+e*((2*-r+t)/8+e*((-3*r+2*t-.25*s)/64+e*((-20*r+15*t-3*s+i/3)/1024+e*(5*(-140*r+112*t-28*s+16/3*i-.5*n)/65536+7*e*((-63*r+52.5*t-15*s+3.75*i-.625*n+.05*o)/65536+e*(-693*r+594*t-185.625*s+1.375*i-12.375*n+1.8*o-.125*Math.sin(12*r))/1048576)))))}else{const t=h*h,s=Math.cos(r),i=s*s,n=at(h,s,e);l=h*(rt(i,n,1)-e*t*ot(i,n,1)/3)}}return 1&a?l=m*(a+1)-l:l+=m*a,n*l}function nt(t,e,s=Number.NaN){if(0===t)return 0;let i=1,n=t;t<0&&(n=-n,i=-1);const r=Number.isNaN(s)?st(e):s,o=Math.floor(n/r);1&o?n=(o+1)*r-n:n-=o*r;let a=n<=0?0:n>=r?Ce():function(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)*de())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+de());i=Ce()+Math.sqrt(o)*(a-Ce())}let r=0;for(let n=0;n<7;n++){r=it(i,e,s);const o=at(Math.sin(i),Math.cos(i),e);if(i-=(r-t)/Math.sqrt(o),n>0&&Math.abs(r-t)<=4*de()*t)break}return i}(n,e,r);return 1&o?a=Ce()*(o+1)-a:a+=Ce()*o,i*a}function rt(t,e,s){(0,i.g)((0!==t?1:0)+(0!==e?1:0)+1>1);let n=t,r=e,o=s;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 ot(t,e,s){(0,i.g)(0!==t||0!==e);let r=t,o=e,a=s;const h=new n(0);let m=1;for(;;){const t=.2*(r+o+3*a),e=(t-r)/t,s=(t-o)/t,i=(t-a)/t;if(Math.abs(e)<=.0015&&Math.abs(s)<=.0015&&Math.abs(i)<=.0015){const n=e*s,r=i*i,o=n-r,a=n-6*r,l=a+o+o,u=9/22,c=3/26,g=a*(.25*u*a-3/14-1.5*c*i*l),_=i*(1/6*l+i*(-u*o+i*c*n));return 3*h.getResult()+m*(1+g+_)/(t*Math.sqrt(t))}const n=Math.sqrt(r),l=Math.sqrt(o),u=Math.sqrt(a),c=n*(l+u)+l*u;h.add(m/(u*(a+c))),m*=.25,r=.25*(r+c),o=.25*(o+c),a=.25*(a+c)}}function at(t,e,s){return t<.999?1-s*Y(t):1-s+s*Y(e)}function ht(t,e,s,n,r){return 0===t?0===n?e:1===n?s:r:1===t?0===n?e:1===n?s:G(e,s,n):(2===t&&(0,i.a)("angular interpolation"),void(0,i.a)(""))}function mt(t,e,s,n,r,o,a,h){if(0===t)for(let t=0;t<o;++t)n[t+r]=0===a?e[t]:1===a?s[t]:h;else if(1===t)if(0===a)lt(n,e,r,0,o);else if(1===a)lt(n,s,r,0,o);else for(let t=0;t<o;++t)n[t+r]=G(e[t],s[t],a);else if(2===t)if(0===a)lt(n,e,r,0,o);else if(1===a)lt(n,s,r,0,o);else{let t=0;for(let i=0,h=r;i<o;++i,++h)n[h]=G(e[i],s[i],a),t+=n[h]*n[h];if(t>0){t=Math.sqrt(t);for(let e=r;e<r+o;++e)n[e]/=t}else{for(let t=r;t<r+o;++t)n[t]=0;n[r]=1}}else(0,i.a)("")}function lt(t,e,s,i,n){if(0===n)return;let r=0,o=s,a=i;for(;r++<n;)t[o++]=e[a++]}function ut(t,e,s){let i=0;for(let n=0;!i&&n<s;++n)i=t[n]-e[n];return i}function ct(t,e){return t}function gt(t){t.sort(((t,e)=>t<e?-1:t>e?1:0))}function _t(t,e){const s=t.slice(0,e);gt(s),lt(t,s,0,0,e)}function dt(t,e,s,i){const n=t.slice(e,e+s);n.sort(i),lt(t,n,e,0,s)}function pt(t,e){return t<e?-1:t>e?1:0}function ft(t,e,s,i){return t<s?-1:t>s?1:e<i?-1:e>i?1:0}function xt(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]=ct(t[s],t[s]=t[i]));return 1+s}function yt(t,e){t[e]=t.at(-1),t.pop()}function Pt(t,e=!1){return{[Symbol.dispose](){this.bForget||t()},bForget:e}}function Et(t,e){return Array.from({length:e},(()=>new t))}function Ct(t,e,s){for(let i=0;i<s;++i)t[i].assign(e[i]);return s}function vt(t,e){const s=t.slice(0,e);for(let t=0;t<e;++t)s[t]=s[t].clone();return s}function bt(t){return Array.from({length:t},(()=>null))}function St(t,e){return Array.from({length:e},(()=>t()))}function It(t,e){return Array.from({length:t},(()=>e))}function wt(t,e){return e in t&&1===Object.getOwnPropertyNames(t).length}class Dt{constructor(...t){this.m_elts=t}get length(){return this.m_elts.length}at(t){return this.m_elts[t]}[Symbol.dispose](){for(const t of this.m_elts)t[Symbol.dispose]()}}function Tt(t,e){return{first:t,second:e}}const Nt=Math.PI,At=2*Math.PI,Mt=.5*Math.PI;class Gt{constructor(t,e){this.m_cr=t,this.m_cc=e,this.m_v=It(t*e,0)}get(t,e){return this.m_v[t*this.m_cc+e]}set(t,e,s){this.m_v[t*this.m_cc+e]=s}inc(t,e){return++this.m_v[t*this.m_cc+e]}}const qt=new ArrayBuffer(8),Ft=new Float64Array(qt),Vt=new BigUint64Array(qt),Rt=0x0fffffffffffffn;function Yt(){return Number.EPSILON*ue}function Xt(t){return Ft[0]=t,Vt[0]}function kt(t){return Xt(t)&Rt}function Ht(t){return Number((9218868437227405312n&Xt(t))>>52n)}function Bt(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 Lt(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function zt(t,e,s){return t===e||Math.abs(t-e)<=s||Number.isNaN(t)&&Number.isNaN(e)}function Ut(t,e){return t<e?-1:t>e?1:0}function Ot(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 Wt(){return 2147483647}function jt(){return 32767}function Zt(){return 2147483647}function Qt(){return-2147483648}const Kt=2147483647,Jt=BigInt(Kt),$t=2166136261,te=16777619,ee=14695981039346656037n,se=1099511628211n;function ie(t){let e=$t;for(let s=0,i=t.length;s<i;++s)e=(e^t.charCodeAt(s))*te;return e&Kt}function ne(t,e){return e+2654435769+(t<<6)+(t>>2)&Kt}function re(t,e){return ne(t,function(t){return Number(function(t){let e=ee,s=t;return e=(e^0xffn&s)*se,s>>=8n,e=(e^0xffn&s)*se,s>>=8n,e=(e^0xffn&s)*se,s>>=8n,e=(e^0xffn&s)*se,s>>=8n,e=(e^0xffn&s)*se,s>>=8n,e=(e^0xffn&s)*se,s>>=8n,e=(e^0xffn&s)*se,e&Jt}(t))}(e))}function oe(t){return ne(3735928559,t)}function ae(t,e){return ne(t,oe(e))}function he(t){return function(t){let e=$t,s=t;return e=(e^255&s)*te,s>>=8,e=(e^255&s)*te,s>>=8,e=(e^255&s)*te,s>>=8,e=(e^255&s)*te,e&Kt}(t)}function me(t){return function(t){return 1103515245*t+12345&2147483647}(t)}const le=100,ue=100;function ce(){return Number.EPSILON*le}function ge(){return.38196601125010515}function _e(){return 1.4142135623730951}function de(){return Number.EPSILON}function pe(t,e,s){return t===e||t===s}function fe(t,e,s){return t>=e?t<=s?t:s:e}function xe(t,e,s){const i=t[0];if(i>=e){if(i<=s)return!1;t[0]=s}else t[0]=e;return!0}function ye(t,e){return t>=e?e:t<-e?-e:t}function Pe(){return Nt}function Ee(){return At}function Ce(){return Mt}const ve=3*Ce();function be(){return ve}function Se(t){return t+0}function Ie(t){return{v:t}}class we{constructor(){this.m_rn=Ie(0n),this.m_rd=Ie(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 we).setDouble(t)}static constructInt64(t){return(new we).setInt64(t)}static constructRational(t,e){return(new we).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 we).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)<2147483647)return this.setInt32(t);const e=Xt(t),s=(e&we.s_em)>>52n,n=!!(e&we.s_sm),r=e&we.s_fm;if(s===we.s_emax)return r?(this.m_rn.v=this.m_rd.v=0n,this.m_bNaN=!0,this):(this.m_rn.v=n?-1n:1n,this.m_rd.v=0n,this);0n===s&&(0,i.a)("denormalized numbers not yet implemented");const o=s-1023n,a=o>=0n?o:0n,h=o<0n?-o:0n;return this.m_rn.v=(1n<<52n|r)<<a,this.m_rd.v=1n<<52n+h,this.m_sign=n?-1:1,this.m_bNormalized=!1,this.normalizeThis()}setInt64(t){return 0n===t?this.setZero():(this.m_bNaN=!1,this.m_sign=t>0n?1:-1,this.m_rn.v=t>0n?t:-t,this.m_rd.v=1n,this.m_power=0,this.m_bNormalized=!1,this.normalizeThis())}setRational(t,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(t){return(0,i.g)(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(we.constructDouble(t))}thisMulInt64(t){return(0,i.g)(0),this}thisMulInt32(t){return(0,i.g)(0),this}divThis(t){return this.mulThis(t.clone().invertThis())}divDoubleThis(t){return this.divThis(we.constructDouble(t))}addDoubleThis(t){return this.addThis(we.constructDouble(t))}subDoubleThis(t){return this.subThis(we.constructDouble(t))}mul(t){return this.clone().mulThis(t)}mulBigIntThis(t){return this.mulThis(we.constructInt64(t))}mulDouble(t){return this.clone().mulThis(we.constructDouble(t))}div(t){return this.clone().divThis(t)}divDouble(t){return this.clone().divDoubleThis(t)}add(t){return this.clone().addThis(t)}fmSubThis(t,e){return this.subThis(t.clone().mulThis(e))}fmAddThis(t,e){return this.addThis(t.clone().mulThis(e))}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(we.constructDouble(t))}sub(t){return this.clone().subThis(t)}subDouble(t){return this.clone().subThis(we.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+=a(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+=a(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=ct(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(Bt(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(Bt(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(Bt(this.m_rn.v)),Number(Bt(this.m_rd.v)))}ldexp(t){return this.clone().ldexpThis(t)}ldexpThis(t){return t&&(this.m_bNormalized=!1,this.m_power+=t,this.normalizeThis()),this}LZ(){return!this.isNAN()&&-1===this.m_sign}GZ(){return!this.isNAN()&&1===this.m_sign}LEZ(){return!this.isNAN()&&this.m_sign<=0}GEZ(){return!this.isNAN()&&this.m_sign>=0}toString(){return this.toDouble().toString()}sqr(){return this.clone().sqrThis()}sqrThis(){return this.mulThis(this.clone())}static sqrt(t,e){if(t.m_sign<0n&&(0,i.w)("MP_value: sqrt(-1)"),t.isZero())return t.clone();let s=52,n=2220446049250313e-31;for(;s<e;)2*s<=e?(n*=n,s*=2):(n*=2220446049250313e-31,s+=52);s+=52;const r=Bt(t.m_rn.v),o=Bt(t.m_rd.v);let a,h=t.m_power+Number(r-o);const m=new we;Math.abs(h)>200?(1&Math.abs(h)&&(h+=1),a=we.constructAssign(t,53).ldexpThis(-h).value(),m.setThis(t).ldexpThis(-h),(0,i.g)(Number.isFinite(a))):(m.setThis(t),a=m.value(),(0,i.g)(Number.isFinite(a)),h=0),a=Math.sqrt(a);const l=we.constructDouble(a),u=we.constructDouble(n);u.mulThis(l).ldexpThis(1);const c=n*a*2,g=l.clone(),_=new we;let d;for(let t=0;t<10;++t){g.mulThis(l),_.setThis(m).subThis(g).absThis();let t=_.value();if(d=1,t<.9)for(;t>c;)t*=t,++d;else d=4;if(_.lte(u))break;for(let t=0;t<d;t++)g.setThis(l).divThis(m).invertThis().addThis(l).ldexpThis(-1).limitPrecisionThis(s),l.setThis(g)}return l.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=we.constructDouble(n),o=r.clone();o.sqrThis().mulDoubleThis(3).mulDoubleThis(i),o.limitPrecisionThis(32),t.LZ()&&r.negateThis();for(let e=0;e<10;++e){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(0,i.g)(0),!1}sign(){return this.m_sign}cosAndSin(t,e){(0,i.g)(0)}static nan(){return(0,i.g)(0),new we}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=Bt(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}}we.s_sm=0x8000000000000000n,we.s_em=0x7ff0000000000000n,we.s_fm=0x000fffffffffffffn,we.s_emax=0x7ffn;const De=we.constructInt32(1),Te=we.constructInt32(0);function Ne(t,e){let s=Ht(t);const i=Ht(e);return s===i?(s-=53-function(t,e){return function(t){let e=0;return 0xffffffff00000000n&t&&(e=32,t>>=32n),e+function(t){let e=0;return 4294901760n&t&&(e+=16,t>>=16n),65280n&t&&(e+=8,t>>=8n),240n&t&&(e+=4,t>>=4n),e+o[Number(BigInt.asUintN(4,t))]+1}(t)}(t^e)}(kt(t),kt(e)),s):s>i?s:i}function Ae(t){const e=Et(Me,t.length);for(let s=0,i=t.length;s<i;++s)e[s].setCoords(t[s][0],t[s][1]);return e}class Me{static construct(t,e){return new Me(t,e)}constructor(t,e){void 0!==t?(this.x=t,this.y=e):this.x=this.y=Number.NaN}clone(){return new Me(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(0,i.g)(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(t,e,s){(0,i.g)(0)}scaleAddThis(t,e){this.x=this.x*t+e.x,this.y=this.y*t+e.y}setScaleAdd(t,e,s){this.x=e.x*t+s.x,this.y=e.y*t+s.y}scaleOther(t,e){(0,i.g)(0)}scale(t){this.x*=t,this.y*=t}compare(t){return this.y<t.y?-1:this.y>t.y?1:this.x<t.x?-1:this.x>t.x?1:0}compareX(t){return this.x<t.x?-1:this.x>t.x?1:this.y<t.y?-1:this.y>t.y?1:0}normalizeOther(t){(0,i.g)(0)}normalize(){const t=this.length();return t?(this.x/=t,this.y/=t):(this.x=1,this.y=0),this}getUnitVector(){return this.clone().normalize()}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}sqrLength(){return this.x*this.x+this.y*this.y}static averageFast(t,e){return(0,i.g)(0),{}}static average(t,e){const s=new Me;if(0===e)return s.setNAN(),s;if(1===e)return s.assign(t[0]),s;const i=new n(t[0].x),r=new n(t[0].y);for(let s=1;s<e;s++)i.add(t[s].x),r.add(t[s].y),255&s||(i.normalize(),r.normalize());return s.x=i.getResult()/e,s.y=r.getResult()/e,s}offset(t,e){const s=Me.distance(t,e),i=Me.construct(this.x,this.y);if(0===s)return Me.distance(i,t);const n=e.clone();return n.subThis(t),i.subThis(t),i.crossProduct(n)/s}side(t,e){return t.equals(e)?this.equals(t)?0:1:Me.orientationRobust(e,t,this)}static sqrDistance(t,e){const s=t.x-e.x,i=t.y-e.y;return s*s+i*i}static sqrDistanceCoords(t,e,s,i){const n=s-t,r=i-e;return n*n+r*r}static distance(t,e){return Math.sqrt(Me.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(t){return(0,i.g)(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 Me(this.x+t.x,this.y+t.y)}sub(t){return new Me(this.x-t.x,this.y-t.y)}negateThis(){return this.x=-this.x,this.y=-this.y,this}negate(){return new Me(-this.x,-this.y)}mul(t){return new Me(this.x*t,this.y*t)}mulThis(t){return this.x*=t,this.y*=t,this}divide(t){return new Me(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 Me(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:(0,i.t)("norm")}}getQuarter(){return Me.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?Me.orientationRobustImpl(Me.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?Me.orientationRobustImpl(t,s,e,!0):r<o?-1:1}static orientationRobust(t,e,s){return Me.orientationRobustImpl(t,e,s,!1)}static orientationRobustEx(t,e,s,i){if(t.equals(e)||s.equals(i))return 0;const n=e.x-t.x,r=e.y-t.y,o=i.x-s.x,a=i.y-s.y;{const t=Me.getQuarterCoords(n,r)-1,e=Me.getQuarterCoords(o,a)-1,s=Me.d[t][e];if(0!==s)return s}const h=n*a,m=r*o,l=4*de()*(Math.abs(h)+Math.abs(m)),u=h-m;return Math.abs(u)>=l?u<0?-1:u>0?1:0:Me.orientationRobustExMp(t,e,s,i)}static orientationRobustExMp(t,e,s,i){const n=we.constructDouble(e.x),r=we.constructDouble(i.x);n.subThis(we.constructDouble(t.x)),r.subThis(we.constructDouble(s.x));const o=we.constructDouble(e.y),a=we.constructDouble(i.y);return o.subThis(we.constructDouble(t.y)),a.subThis(we.constructDouble(s.y)),n.mulThis(a),o.mulThis(r),n.subThis(o),n.LZ()?-1:n.GZ()?1:0}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=Me.getQuarterCoords(n,r)-1,e=Me.getQuarterCoords(o,a)-1,s=Me.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*d(),m=n*a-r*o;if(Math.abs(m)>h)return m<0?-1:1;if(_(e.x,t.x)&&_(s.y,t.y)&&_(e.y,t.y)&&_(s.x,t.x)&&c(n,a)&&c(r,o)){const t=n*a,e=r*o;if(_(t,e)){const s=t-e;return s<0?-1:s>0?1:0}}return Me.orientationRobustMp(t,e,s)}static orientationRobustMp(t,e,s){const i=we.constructDouble(e.x),n=we.constructDouble(s.x);{const e=we.constructDouble(t.x);i.subThis(e),n.subThis(e)}const r=we.constructDouble(s.y),o=we.constructDouble(e.y);{const e=we.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(t,e,s,i){const n=new u,r=new u;n.set(t.x),n.subThis(i.x),r.set(t.y),r.subThis(i.y);const o=new u,a=new u;o.set(e.x),o.subThis(i.x),a.set(e.y),a.subThis(i.y);const h=new u,m=new u;h.set(s.x),h.subThis(i.x),m.set(s.y),m.subThis(i.y);const l=n.mulE(a).subE(r.mulE(o)),c=o.mulE(m).subE(a.mulE(h)),g=n.mulE(m).subE(r.mulE(h)),_=n.mulE(n).addE(r.mulE(r)),d=o.mulE(o).addE(a.mulE(a)),p=h.mulE(h).addE(m.mulE(m)),f=_.mulE(c).subE(d.mulE(g)).addE(p.mulE(l));if(!f.isFuzzyZero()){const t=f.value();return t<0?-1:t>0?1:0}return Me.inCircleRobustMp(t,e,s,i)}static inCircleRobustMp(t,e,s,i){do{if(!_(t.x,i.x)||!_(t.y,i.y))break;if(!_(e.x,i.x)||!_(e.y,i.y))break;if(!_(s.x,i.x)||!_(s.y,i.y))break;const n=t.x-i.x,r=t.y-i.y,o=e.x-i.x,a=e.y-i.y,h=s.x-i.x,m=s.y-i.y;if(!c(n,a)||!c(r,o))break;if(!c(o,m)||!c(a,h))break;if(!c(n,m)||!c(r,h))break;if(!c(n,n)||!c(r,r))break;if(!c(o,o)||!c(a,a))break;if(!c(h,h)||!c(m,m))break;const l=n*a,u=r*o,d=o*m,p=a*h,f=n*m,x=r*h,y=n*n,P=r*r,E=o*o,C=a*a,v=h*h,b=m*m;if(!_(l,u))break;if(!_(d,p))break;if(!_(f,x))break;if(!g(y,P))break;if(!g(E,C))break;if(!g(v,b))break;const S=l-u,I=d-p,w=f-x,D=y+P,T=E+C,N=v+b;if(!c(D,I))break;if(!c(T,w))break;if(!c(N,S))break;const A=D*I,M=T*w,G=N*S;if(!_(A,M))break;const q=A-M;if(!g(q,G))break;const F=q+G;return F<0?-1:F>0?1:0}while(0);const n=we.constructDouble(i.x),r=we.constructDouble(i.y),o=we.constructDouble(t.x),a=we.constructDouble(t.y);o.subThis(n),a.subThis(r);const h=we.constructDouble(e.x),m=we.constructDouble(e.y);h.subThis(n),m.subThis(r);const l=we.constructDouble(s.x),u=we.constructDouble(s.y);l.subThis(n),u.subThis(r);const d=o.mul(m).sub(a.mul(h)),p=h.mul(u).sub(m.mul(l)),f=o.mul(u).sub(a.mul(l)),x=o.mul(o).add(a.mul(a)),y=h.mul(h).add(m.mul(m)),P=l.mul(l).add(u.mul(u)),E=x.mul(p).sub(y.mul(f)).add(P.mul(d));return E.LZ()?-1:E.GZ()?1:0}static inCircleRobustMp3Point(t,e,s){const i=we.constructDouble(t.x),n=we.constructDouble(t.y),r=we.constructDouble(e.x),o=we.constructDouble(e.y),a=we.constructDouble(s.x),h=we.constructDouble(s.y),m=a.mul(a).add(h.mul(h)).sub(a.mul(i).add(h.mul(n)).add(a.mul(r)).add(h.mul(o))).add(i.mul(r).add(n.mul(o)));return m.LZ()?-1:m.GZ()?1:0}static inCircleRobust3Point(t,e,s){const i=new u(t.x),n=new u(t.y),r=new u(e.x),o=new u(e.y),a=new u(s.x),h=new u(s.y),m=a.mulE(a).addE(h.mulE(h)).subE(a.mulE(i).addE(h.mulE(n)).addE(a.mulE(r)).addE(h.mulE(o))).addE(i.mulE(r).addE(n.mulE(o)));if(!m.isFuzzyZero()){const t=m.value();return t<0?-1:t>0?1:0}return Me.inCircleRobustMp3Point(t,e,s)}static calculateCircleCenterFromThreePoints(t,e,s){if(t.equals(s)||t.equals(e)||s.equals(e))return Me.getNAN();const i=function(t,e,s){const i=new u(e.x);i.subThis(t.x);const n=new u(e.y);n.subThis(t.y);const r=new u(s.x);r.subThis(t.x);const o=new u(s.y);o.subThis(t.y);const a=i.clone();a.mulThisE(o);let h=n.clone();if(h.mulThisE(r),a.subThisE(h),0===a.value())return Me.getNAN();a.mulThis(2);const m=i.clone();m.mulThisE(i);const l=n.clone();l.mulThisE(n);const c=m.clone();c.addThisE(l);const g=r.clone();g.mulThisE(r);const _=o.clone();_.mulThisE(o);const d=g.clone();d.addThisE(_);const p=n.clone();p.mulThisE(d),h=o.clone(),h.mulThisE(c),p.subThisE(h),p.divThisE(a);const f=i.clone();f.mulThisE(d),h=r.clone(),h.mulThisE(c),f.subThisE(h),f.divThisE(a);const x=Me.construct(t.x-p.value(),t.y+f.value()),y=t.sub(x).length(),P=e.sub(x).length(),E=s.sub(x).length(),C=1e-15*(y+Math.abs(t.x)+Math.abs(e.x)+Math.abs(s.x)+Math.abs(t.y)+Math.abs(e.y)+Math.abs(s.y));return Math.abs(y-P)<=C&&Math.abs(y-E)<=C&&p.eps()<C&&f.eps()<C?x:Me.getNAN()}(t,e,s);return i.isNAN()?function(t,e,s){const i=we.constructDouble(e.x);i.subDoubleThis(t.x);const n=we.constructDouble(e.y);n.subDoubleThis(t.y);const r=we.constructDouble(s.x);r.subDoubleThis(t.x);const o=we.constructDouble(s.y);o.subDoubleThis(t.y);const a=i.clone();a.mulThis(o);let h=n.clone();if(h.mulThis(r),a.subThis(h),a.isZero())return Me.getNAN();a.mulDoubleThis(2);const m=i.clone();m.mulThis(i);const l=n.clone();l.mulThis(n);const u=m.clone();u.addThis(l);const c=r.clone();c.mulThis(r);const g=o.clone();g.mulThis(o);const _=c.clone();_.addThis(g);const d=n.clone();d.mulThis(_),h=o.clone(),h.mulThis(u),d.subThis(h),d.divThis(a);const p=i.clone();return p.mulThis(_),h=r.clone(),h.mulThis(u),p.subThis(h),p.divThis(a),Me.construct(t.x-d.value(),t.y+p.value())}(t,e,s):i}static calculateAngle(t,e){return Math.atan2(t.crossProduct(e),t.dotProduct(e))}static isBisectorRobust(t,e,s){return(0,i.g)(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=Me.c_compare_zorder_xx[t.x<0?1:0]|Me.c_compare_zorder_yy[t.y<0?1:0],i=Me.c_compare_zorder_xx[e.x<0?1:0]|Me.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=Ne(t[n],e[n]);r>s&&(s=r,i=n)}return t[i]<e[i]}return s<i}static lerp(t,e,s){const i=new Me;return V(t,e,s,i),i}static getClosestCoordinate(t,e,s,i=!1){const n=Me.getNAN();n.setSub(e,t);const r=n.sqrLength();if(0===r)return.5;if(e.isEqualPoint2D(s))return 1;const o=Me.getNAN();o.setSub(s,t);let a=o.dotProduct(n)/r;return i||(a<0?a=0:a>1&&(a=1)),a}static intersectLinesAtOnePoint(t,e,s,i){if(t.equals(e)||s.equals(i))return Me.getNAN();const n=e.x-t.x,r=s.x-i.x,o=e.y-t.y,a=s.y-i.y,h=n*a-r*o;if(!h)return Me.getNAN();const m=h;if(0===m)return Me.getNAN();let l=(s.x-t.x)*a-(s.y-t.y)*r;l/=m;const u=new Me;return V(t,e,l,u),u.isFinite()?u:Me.getNAN()}toString(){return`[${this.x},${this.y}]`}}Me.dimensions=2,Me.d=[[0,1,0,-1],[-1,0,1,0],[0,-1,0,1],[1,0,-1,0]],Me.c_compare_zorder_xx=[2,0],Me.c_compare_zorder_yy=[1,0];class Ge{constructor(t,e,s){if(t instanceof Ge)return this.data=t.data,this.N=t.N,this.M=t.M,t.data=null,t.N=0,void(t.M=0);this.data=t,this.N=e,this.M=s}assignCopy(t){return this===t||((0,i.g)(this.N*this.M==t.N*t.M),this.data.set(t.data),this.N=t.N,this.M=t.M),this}setZero(){return this.data?.fill(0),this}setIdentity(){for(let t=0;t<this.N;t++)for(let e=0;e<this.M;e++)this.setRowCol(t,e,t===e?1:0);return this}rows(){return this.N}cols(){return this.M}row(t){return(0,i.g)(0),{}}set(t,e){return this.data[t]=e,this}setRowCol(t,e,s){return this.data[t*this.M+e]=s,this}at(t){return this.data[t]}atRowCol(t,e){return this.data[t*this.M+e]}mulScalar(t,e){(0,i.g)(0)}mul(t,e){if((0,i.g)(this.M===t.rows()),(0,i.g)(this.N===e.rows()),(0,i.g)(t.cols()===e.cols()),e===this){const s=new Float64Array(this.N*this.M),i=new Ge(s,this.N,this.M);return this.mul(t,i),void e.assignCopy(i)}if(e===t){const s=new Float64Array(t.N*t.M),i=new Ge(s,t.N,t.M);return this.mul(t,i),void e.assignCopy(i)}const s=t.cols();for(let i=0;i<this.N;i++)for(let n=0;n<s;n++){let s=0;for(let e=0;e<this.M;e++)s+=this.atRowCol(i,e)*t.atRowCol(e,n);e.setRowCol(i,n,s)}}mulTranspose(t,e){if((0,i.g)(this.M===t.cols()),(0,i.g)(this.N===e.rows()),(0,i.g)(t.rows()===e.cols()),e===this){const s=new Float64Array(this.N*this.M),i=new Ge(s,this.N,this.M);return this.mulTranspose(t,i),void e.assignCopy(i)}if(e===t){const s=new Float64Array(t.N*t.M),i=new Ge(s,t.N,t.M);return this.mulTranspose(t,i),void e.assignCopy(i)}const s=t.rows();for(let i=0;i<this.N;i++)for(let n=0;n<s;n++){let s=0;for(let e=0;e<this.M;e++)s+=this.atRowCol(i,e)*t.atRowCol(n,e);e.setRowCol(i,n,s)}}mulLeft(t,e){(0,i.g)(0)}mulLeftTranspose(t,e){(0,i.g)(0)}mulDiag(t,e){if((0,i.g)(this.M===t.N*t.M),(0,i.g)(this.N===e.rows()),(0,i.g)(this.M===e.cols()),e===this){const s=new Float64Array(this.N*this.M),i=new Ge(s,this.N,this.M);return this.mulDiag(t,i),void e.assignCopy(i)}const s=this.M;for(let i=0;i<this.N;i++)for(let n=0;n<s;n++)e.setRowCol(i,n,this.atRowCol(i,n)*t.at(n))}transposeInPlace(){if(this.N===this.M){for(let t=0;t<this.N;t++)for(let e=t+1;e<this.M;e++){const s=this.atRowCol(t,e);this.setRowCol(t,e,this.atRowCol(e,t)),this.setRowCol(e,t,s)}return this}const t=new Float64Array(this.N*this.M),e=new Ge(t,this.N,this.M);return e.assignCopy(this),this.M=ct(this.N,this.N=this.M),e.transpose(this),this}transpose(t){if(this!==t){Ge.checkDims(t,this.M,this.N);for(let e=0;e<this.N;e++)for(let s=0;s<this.M;s++)t.setRowCol(s,e,this.atRowCol(e,s))}else t.transposeInPlace()}add(t,e){}svd(t,e,s,n=!1){if(Ge.checkDims(t,this.N,this.M),Ge.checkDims(e,this.M,1),Ge.checkDims(s,this.M,this.M),n){if((0,i.g)(this.N===this.M),!this.symmetricEigen(e,s))return!1;for(let t=0;t<this.M;++t)e.at(t)<0&&e.set(t,0);return t.assignCopy(s),!0}let r,o,a,h,m,l,u,c=0,g=0,_=0,d=0,p=0;const f=this.M,x=this.N;t.assignCopy(this);const y=new Float64Array(f),P=new Ge(y,f,1),E=(t,e)=>e>=0?Math.abs(t):-Math.abs(t),C=(t,e)=>{if((t=Math.abs(t))>(e=Math.abs(e))){const s=e/t;return t*Math.sqrt(s*s+1)}if(e>0){const s=t/e;return e*Math.sqrt(s*s+1)}return 0};for(let s=0;s<f;s++){if(c=s+1,P.set(s,d*_),_=h=d=0,s<x){for(let e=s;e<x;e++)d+=Math.abs(t.atRowCol(e,s));if(d){for(let e=s;e<x;e++)t.setRowCol(e,s,t.atRowCol(e,s)/d),h+=t.atRowCol(e,s)*t.atRowCol(e,s);o=t.atRowCol(s,s),_=-E(Math.sqrt(h),o),a=o*_-h,t.setRowCol(s,s,o-_);for(let e=c;e<f;e++){h=0;for(let i=s;i<x;i++)h+=t.atRowCol(i,s)*t.atRowCol(i,e);o=h/a;for(let i=s;i<x;i++)t.setRowCol(i,e,t.atRowCol(i,e)+o*t.atRowCol(i,s))}for(let e=s;e<x;e++)t.setRowCol(e,s,t.atRowCol(e,s)*d)}}if(e.set(s,d*_),_=h=d=0,s<x&&s!==f-1){for(let e=c;e<f;e++)d+=Math.abs(t.atRowCol(s,e));if(d){for(let e=c;e<f;e++)t.setRowCol(s,e,t.atRowCol(s,e)/d),h+=t.atRowCol(s,e)*t.atRowCol(s,e);o=t.atRowCol(s,c),_=-E(Math.sqrt(h),o),a=o*_-h,t.setRowCol(s,c,o-_);for(let e=c;e<f;e++)P.set(e,t.atRowCol(s,e)/a);for(let e=c;e<x;e++){h=0;for(let i=c;i<f;i++)h+=t.atRowCol(e,i)*t.atRowCol(s,i);for(let s=c;s<f;s++)t.setRowCol(e,s,t.atRowCol(e,s)+h*P.at(s))}for(let e=c;e<f;e++)t.setRowCol(s,e,t.atRowCol(s,e)*d)}}const i=Math.abs(e.at(s))+Math.abs(P.at(s));p=i>p?i:p}for(let e=f-1;e>=0;e--){if(e<f-1){if(_){for(let i=c;i<f;i++)s.setRowCol(i,e,t.atRowCol(e,i)/t.atRowCol(e,c)/_);for(let i=c;i<f;i++){h=0;for(let n=c;n<f;n++)h+=t.atRowCol(e,n)*s.atRowCol(n,i);for(let t=c;t<f;t++)s.setRowCol(t,i,s.atRowCol(t,i)+h*s.atRowCol(t,e))}}for(let t=c;t<f;t++)s.setRowCol(e,t,0),s.setRowCol(t,e,0)}s.setRowCol(e,e,1),_=P.at(e),c=e}for(let s=(x<f?x:f)-1;s>=0;s--){c=s+1,_=e.at(s);for(let e=c;e<f;e++)t.setRowCol(s,e,0);if(_){_=1/_;for(let e=c;e<f;e++){h=0;for(let i=c;i<x;i++)h+=t.atRowCol(i,s)*t.atRowCol(i,e);o=h/t.atRowCol(s,s)*_;for(let i=s;i<x;i++)t.setRowCol(i,e,t.atRowCol(i,e)+o*t.atRowCol(i,s))}for(let e=s;e<x;e++)t.setRowCol(e,s,t.atRowCol(e,s)*_)}else for(let e=s;e<x;e++)t.setRowCol(e,s,0);t.setRowCol(s,s,t.atRowCol(s,s)+1)}for(let i=f-1;i>=0;i--)for(let n=1;;n++){let d=1;for(c=i;c>=0;c--){if(g=c-1,Math.abs(P.at(c))+p===p){d=0;break}if(Math.abs(e.at(g))+p===p)break}if(d){r=0,h=1;for(let s=c;s<=i&&(o=h*P.at(s),P.set(s,P.at(s)*r),Math.abs(o)+p!==p);s++){_=e.at(s),a=C(o,_),e.set(s,a),a=1/a,r=_*a,h=-o*a;for(let e=0;e<x;e++)l=t.atRowCol(e,g),u=t.atRowCol(e,s),t.setRowCol(e,g,l*r+u*h),t.setRowCol(e,s,u*r-l*h)}}if(u=e.at(i),c===i){if(u<0){e.set(i,-u);for(let t=0;t<f;t++)s.setRowCol(t,i,-s.atRowCol(t,i))}break}if(100===n)return!1;m=e.at(c),g=i-1,l=e.at(g),_=P.at(g),a=P.at(i),o=((l-u)*(l+u)+(_-a)*(_+a))/(2*a*l),_=C(o,1),o=((m-u)*(m+u)+a*(l/(o+E(_,o))-a))/m,r=h=1;for(let i=c;i<=g;i++){const n=i+1;_=P.at(n),l=e.at(n),a=h*_,_*=r,u=C(o,a),P.set(i,u),r=o/u,h=a/u,o=m*r+_*h,_=_*r-m*h,a=l*h,l*=r;for(let t=0;t<f;t++)m=s.atRowCol(t,i),u=s.atRowCol(t,n),s.setRowCol(t,i,m*r+u*h),s.setRowCol(t,n,u*r-m*h);u=C(o,a),e.set(i,u),u&&(u=1/u,r=o*u,h=a*u),o=r*_+h*l,m=r*l-h*_;for(let e=0;e<x;e++)l=t.atRowCol(e,i),u=t.atRowCol(e,n),t.setRowCol(e,i,l*r+u*h),t.setRowCol(e,n,u*r-l*h)}P.set(c,0),P.set(i,o),e.set(i,m)}const v=new Float64Array(this.N),b=new Float64Array(this.M),S=new Ge(v,this.N,1),I=new Ge(b,this.M,1);let w=1;do{w*=3,w++}while(w<=this.M);do{w/=3,w=Math.trunc(w);for(let i=w;i<this.M;i++){const n=e.at(i);for(let e=0;e<this.N;e++)S.set(e,t.atRowCol(e,i));for(let t=0;t<this.M;t++)I.set(t,s.atRowCol(t,i));let r=i;for(;e.at(r-w)<n;){e.set(r,e.at(r-w));for(let e=0;e<this.N;e++)t.setRowCol(e,r,t.atRowCol(e,r-w));for(let t=0;t<this.M;t++)s.setRowCol(t,r,s.atRowCol(t,r-w));if(r-=w,r<w)break}e.set(r,n);for(let e=0;e<this.N;e++)t.setRowCol(e,r,S.at(e));for(let t=0;t<this.M;t++)s.setRowCol(t,r,I.at(t))}}while(w>1);for(let e=0;e<this.M;e++){let i=0;for(let s=0;s<this.N;s++)t.atRowCol(s,e)<0&&i++;for(let t=0;t<this.M;t++)s.atRowCol(t,e)<0&&i++;if(i>Math.trunc((this.N+this.M)/2)){for(let s=0;s<this.N;s++)t.setRowCol(s,e,-t.atRowCol(s,e));for(let t=0;t<this.M;t++)s.setRowCol(t,e,-s.atRowCol(t,e))}}return!0}isSymmetric(){if(this.N!==this.M)return!1;for(let t=0;t<this.N;t++)for(let e=t+1;e<this.M;e++)if(this.atRowCol(t,e)!==this.atRowCol(e,t))return!1;return!0}isZero(){return(0,i.g)(0),!1}isIdentity(){return(0,i.g)(0),!1}equals(t,e){if(void 0!==e&&(0,i.g)(0),this.N!==t.N||this.M!==t.M)return!1;for(let e=0;e<this.N*this.M;e++)if(this.data[e]!==t.data[e])return!1;return!0}maxElement(){return(0,i.g)(0),0}minElement(){return(0,i.g)(0),0}determinant(){if((0,i.g)(this.N===this.M),1===this.N)return this.data[0];if(2===this.N)return this.data[0]*this.data[3]-this.data[1]*this.data[2];if(3===this.N){const t=this;return t.atRowCol(0,0)*(t.atRowCol(1,1)*t.atRowCol(2,2)-t.atRowCol(1,2)*t.atRowCol(2,1))-t.atRowCol(0,1)*(t.atRowCol(1,0)*t.atRowCol(2,2)-t.atRowCol(2,0)*t.atRowCol(1,2))+t.atRowCol(0,2)*(t.atRowCol(1,0)*t.atRowCol(2,1)-t.atRowCol(1,1)*t.atRowCol(2,0))}const t=new Float64Array(this.N*this.N),e=new Ge(t,this.N,this.N),s=new Float64Array(this.N);if(!this.luDecomposition(e,s))return 0;let n=1;for(let t=0;t<this.N;t++)n*=e.atRowCol(t,t),s[t]!==t&&(n=-n);return n}submatrix(t,e,s){(0,i.g)(0)}inverse(t){(0,i.g)(0)}pseudoInverse(t,e=!1,s=2220446049250313e-31){if(t.setZero(),1===this.N&&1===this.M)return 0!==this.atRowCol(0,0)?t.setRowCol(0,0,1/this.atRowCol(0,0)):t.setRowCol(0,0,0),!0;if(2===this.N&&2===this.M){const e=this.atRowCol(0,0)*this.atRowCol(1,1)-this.atRowCol(0,1)*this.atRowCol(1,0),s=1e-5*(Math.abs(this.atRowCol(0,0)*this.atRowCol(1,1))+Math.abs(this.atRowCol(0,1)*this.atRowCol(1,0)));if(Math.abs(e)>s)return t.setRowCol(0,0,this.atRowCol(1,1)/e),t.setRowCol(0,1,-this.atRowCol(0,1)/e),t.setRowCol(1,0,-this.atRowCol(1,0)/e),t.setRowCol(1,1,this.atRowCol(0,0)/e),!0}const i=new Float64Array(this.N*this.M),n=new Ge(i,this.N,this.M),r=new Float64Array(this.M),o=new Ge(r,this.M,1),a=new Float64Array(this.M*this.M),h=new Ge(a,this.M,this.M);if(!this.svd(n,o,h,e))return!1;const m=Math.max(this.N,this.M),l=s*Math.abs(o.at(0))*m;for(let t=0;t<this.M;t++)o.at(t)>l?o.set(t,1/o.at(t)):o.set(t,0);return h.mulDiag(o,t),t.mulTranspose(n,t),!0}luDecomposition(t,e){return(0,i.g)(0),!1}symmetricEigen(t,e){(0,i.g)(this.rows()===this.cols()),(0,i.g)(this.rows()===t.rows()),(0,i.g)(e.rows()===e.cols()&&e.rows()===this.rows()),(0,i.g)(this.isSymmetric());const s=new Float64Array(this.N*this.M),n=new Ge(s,this.N,this.M);n.assignCopy(this);const r=100/Number.EPSILON,o=this.rows(),a=new Float64Array(o),h=new Float64Array(o),m=new Ge(a,o,1),l=new Ge(h,o,1);for(let e=0;e<o;e++)m.set(e,n.atRowCol(e,e)),t.set(e,n.atRowCol(e,e)),l.set(e,0);e.setIdentity();const u=()=>{const s=m;e.transposeInPlace();let i=1;do{i*=3,i++}while(i<=o);do{i/=3,i=Math.trunc(i);for(let n=i;n<o;n++){const r=t.at(n),o=Math.abs(r);for(let t=0;t<this.M;t++)s.set(t,e.atRowCol(t,n));let a=n;for(;Math.abs(t.at(a-i))<o;){t.set(a,t.at(a-i));for(let t=0;t<this.M;t++)e.setRowCol(t,a,e.atRowCol(t,a-i));if(a-=i,a<i)break}if(a!==n){t.set(a,r);for(let t=0;t<this.M;t++)e.setRowCol(t,a,s.at(t))}}}while(i>1)};for(let s=1;;s++){let i=0;for(let t=1;t<o;t++)for(let e=0;e<t;e++)i+=Math.abs(n.atRowCol(t,e));if(0===i)return u(),!0;const a=s<4?.2*i/(o*o):0;for(let i=0;i<o;i++)for(let h=i+1;h<o;h++){let m=r*Math.abs(n.atRowCol(h,i));if(s>4&&m<=Math.abs(t.at(i))&&m<=Math.abs(t.at(h)))n.setRowCol(h,i,0);else if(Math.abs(n.atRowCol(h,i))>a){let s,r=t.at(h)-t.at(i);if(m<Math.abs(r))s=n.atRowCol(h,i)/r;else{const t=.5*r/n.atRowCol(h,i);s=1/(Math.abs(t)+Math.sqrt(1+t*t)),t<0&&(s=-s)}const a=1/Math.sqrt(1+s*s),u=s*a,c=u/(1+a);r=s*n.atRowCol(h,i),l.set(i,l.at(i)-r),l.set(h,l.at(h)+r),t.set(i,t.at(i)-r),t.set(h,t.at(h)+r),n.setRowCol(h,i,0);let g=0;for(;g<i;g++)m=n.atRowCol(i,g),r=n.atRowCol(h,g),n.setRowCol(i,g,m-u*(r+m*c)),n.setRowCol(h,g,r+u*(m-r*c));for(g++;g<h;g++)m=n.atRowCol(g,i),r=n.atRowCol(h,g),n.setRowCol(g,i,m-u*(r+m*c)),n.setRowCol(h,g,r+u*(m-r*c));for(g++;g<o;g++)m=n.atRowCol(g,i),r=n.atRowCol(g,h),n.setRowCol(g,i,m-u*(r+m*c)),n.setRowCol(g,h,r+u*(m-r*c));for(g=0;g<o;g++)m=e.atRowCol(i,g),r=e.atRowCol(h,g),e.setRowCol(i,g,m-u*(r+m*c)),e.setRowCol(h,g,r+u*(m-r*c))}}for(let e=0;e<o;e++)m.set(e,m.at(e)+l.at(e)),t.set(e,m.at(e)),l.set(e,0)}}static checkDims(t,e,s){(0,i.g)(t.rows()===e&&t.cols()===s)}}class qe extends Ge{constructor(t){if(t.copy){const e=new Float64Array(t.copy.N*t.copy.M);return super(e,t.copy.N,t.copy.M),this.buffer=e,void this.assignCopy(t.copy)}const e=new Float64Array(t.NN*t.MM);super(e,t.NN,t.MM),this.buffer=e,t.initializerList&<(this.buffer,t.initializerList,0,0,t.initializerList.length)}assignCopy(t){return this===t||super.assignCopy(t),this}}class Fe{constructor(t){this.m_TransformationType=1,void 0===t?this.setIdentity():t instanceof Fe?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 Fe).set(this)}setZero(){this.xx=0,this.yy=0,this.xy=0,this.yx=0,this.xd=0,this.yd=0}isEqual(t){return this===t||this.xx===t.xx&&this.xy===t.xy&&this.xd===t.xd&&this.yx===t.yx&&this.yy===t.yy&&this.yd===t.yd}transformInPlace(t){const 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(t){const e=t.clone();return this.transformInPlace(e),e}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(t){if(t.isEmpty())return;const e=Et(Me,4);t.queryCorners(e),this.transformPoints2D(e,4,e),t.setFromPoints(e,4)}queryTransformEnv(t,e){(0,i.g)(0)}transformPoints2D(t,e,s){for(let i=0;i<e;++i)this.queryTransform(t[i],s[i])}transformInterleavedPoints(t,e,s){e*=2;const i=Me.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 Fe.st_multiply(this,t,this),this}mulLeft(t){return(0,i.g)(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(t){(0,i.g)(t.length>=6),t[0]=this.xx,t[1]=this.xy,t[2]=this.xd,t[3]=this.yx,t[4]=this.yy,t[5]=this.yd}setCoefficients(t){(0,i.g)(t.length>=6),this.xx=t[0],this.xy=t[1],this.xd=t[2],this.yx=t[3],this.yy=t[4],this.yd=t[5]}copyTo(t){(0,i.g)(0)}initializeFromRect(t,e){t.isEmpty()||e.isEmpty()||!t.width()||!t.height()?this.setZero():(this.xy=this.yx=0,this.xx=e.width()/t.width(),this.yy=e.height()/t.height(),this.xd=e.xmin-t.xmin*this.xx,this.yd=e.ymin-t.ymin*this.yy)}initializeFromRectIsotropic(t,e){if(t.isEmpty()||!t.width()||!t.height()||e.isEmpty())this.setZero();else{this.yx=0,this.xy=0,this.xx=e.width()/t.width(),this.yy=e.height()/t.height(),this.xx>this.yy?this.xx=this.yy:this.yy=this.xx;const s=e.getCenter(),i=t.getCenter();this.xd=s.x-i.x*this.xx,this.yd=s.y-i.y*this.yy}}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]));(0,i.t)("")}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=Me.distance(t[0],t[1]),n=Me.distance(e[0],e[1]),r=n/s;this.scale(r,r);const o=t[1].sub(t[0]);o.divThis(s);const a=e[1].sub(e[0]);a.divThis(n);const h=o.crossProduct(a),m=o.dotProduct(a);this.rotate(m,h),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(t){(0,i.g)(0)}transformSize(t,e){(0,i.g)(0)}transformTol(t){return(0,i.g)(0),0}transformWithoutTranslateArray(t,e,s){for(let i=0;i<e;++i)this.transformWithoutTranslate(t[i],s[i])}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(t,e){const s=this.xx*t.x+this.xy*t.y,i=this.yx*t.x+this.yy*t.y;e.setCoords(s,i)}setIdentity(){this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=1,this.yd=0}isIdentity(){return!(1!==this.xx||1!==this.yy||this.xy||this.xd||this.yx||this.yd)}isIdentityTol(t){const e=t*t;return!(Y(this.xd)+Y(this.yd)>e||Y(this.xy+this.xd)+Y(this.yy+this.yd-1)>e||Y(this.xx+this.xd-1)+Y(this.yx+this.yd)>e)}isReflective(){return this.xx*this.yy-this.yx*this.xy<0}isUniform(t){const e=this.xx*this.xx+this.yx*this.yx,s=this.xy*this.xy+this.yy*this.yy,i=(e+s)*t;return Math.abs(e-s)<=i&&Math.abs(this.xx*this.xy+this.yx*this.yy)<=i}isUniformNoRotation(){return 0!==this.xx&&Math.abs(this.xx)===Math.abs(this.yy)&&0===this.xy&&0===this.yx}isTranslate(){return 1===this.xx&&1===this.yy&&!this.xy&&!this.yx}isTranslateTol(t){const e=new Me;return e.setCoords(0,1),this.transformWithoutTranslateInPlace(e),e.y-=1,!(e.sqrLength()>t*t)&&(e.setCoords(1,0),this.transformWithoutTranslateInPlace(e),e.x-=1,e.sqrLength()<=t*t)}isOrthonormal(t){const e=new Fe;return e.xx=this.xx*this.xx+this.xy*this.xy,e.xy=this.xx*this.yx+this.xy*this.yy,e.yx=this.yx*this.xx+this.yy*this.xy,e.yy=this.yx*this.yx+this.yy*this.yy,e.xd=0,e.yd=0,e.isIdentityTol(t)}isDegenerate(t){return Math.abs(this.xx*this.yy-this.yx*this.xy)<=2*t*(Math.abs(this.xx*this.yy)+Math.abs(this.yx*this.xy))}isZero(){return 0===this.xx&&0===this.yy&&0===this.xy&&0===this.yx&&0===this.xd&&0===this.yd}isScaleAndTranslateTol(t){return this.xy*this.xy+this.yx*this.yx<=(this.xx*this.xx+this.yy*this.yy)*t}setTranslate(t,e){return this.xx=1,this.xy=0,this.xd=t,this.yx=0,this.yy=1,this.yd=e,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(t,e){return this.xx=-1,this.xy=0,this.xd=t+e,this.yx=0,this.yy=1,this.yd=0,this}setFlipY(t,e){return this.xx=1,this.xy=0,this.xd=0,this.yx=0,this.yy=-1,this.yd=t+e,this}setShear(t,e){return this.xx=1,this.xy=t,this.xd=0,this.yx=e,this.yy=1,this.yd=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(t,e){return this.setRotateAbout(Math.cos(t),Math.sin(t),e)}setRotateAbout(t,e,s){return this.setTranslate(-s.x,-s.y),this.rotate(t,e),this.translate(s.x,s.y)}setSwapCoordinates(){return this.xx=0,this.xy=1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}setRotateCw90(){return this.xx=0,this.xy=1,this.xd=0,this.yx=-1,this.yy=0,this.yd=0,this}setRotateCcw90(){return this.xx=0,this.xy=-1,this.xd=0,this.yx=1,this.yy=0,this.yd=0,this}shiftCoords(t,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}flipX(t,e){return this.xx=-this.xx,this.xy=-this.xy,this.xd=t+e-this.xd,this}flipY(t,e){return this.yx=-this.yx,this.yy=-this.yy,this.yd=t+e-this.yd,this}shear(t,e){const s=new Fe;return s.setShear(t,e),this.multiply(s)}rotateAngle(t){const e=new Fe;return e.setRotateAngle(t),this.multiply(e)}rotate(t,e){const s=new Fe;return s.setRotate(t,e),this.multiply(s)}rotateAbout(t,e,s){return this.translate(-s.x,-s.y),this.rotate(t,e),this.translate(s.x,s.y)}rotateAngleAbout(t,e){return this.rotateAbout(Math.cos(t),Math.sin(t),e)}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(){const t=we.constructDouble(this.xy),e=we.constructDouble(this.xx),s=e.mulDouble(this.yy).sub(t.mulDouble(this.yx));if(s.isZero())return this.setZero(),this;const i=s.clone();i.invertThis();const n=we.constructDouble(this.xd),r=t.mulDouble(this.yd).sub(n.mulDouble(this.yy)).mul(i).toDouble(),o=n.mulDouble(this.yx).sub(e.mulDouble(this.yd)).mul(i).toDouble(),a=i.mulDouble(this.yy).toDouble(),h=i.mulDouble(-this.xy).toDouble(),m=i.mulDouble(-this.yx).toDouble(),l=i.mulDouble(this.xx).toDouble();return this.xd=r,this.yd=o,this.xx=a,this.yy=l,this.xy=h,this.yx=m,this}extractScaleTransform(t,e){const s=Math.sqrt(this.xx*this.xx+this.xy*this.xy),i=Math.sqrt(this.yx*this.yx+this.yy*this.yy);e.setScaleCoords(1/s,1/i),e.multiply(this),t.setScaleCoords(s,i)}setFromTwoTriangles(t,e){let s=!0;for(let i=0;i<3;++i)s=s&&t[i].equals(e[i]);if(s)return this.setIdentity(),!0;const i=new Me;i.setSub(t[0],t[1]);const n=new Me;n.setSub(t[0],t[2]);const r=new Me;r.setSub(e[0],e[1]);const o=new Me;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)}initializeFromControlPoints(t,e,s,n,r=null){return 0===e?(this.setIdentity(),void(r&&r.setIdentity())):1===e?(this.setShift(n[0].sub(s[0])),void(r&&r.setShift(s[0].sub(n[0])))):(e<3&&(t=1),void(4===t&&e>2?function(t,e,s,n,r){const o=Me.average(s,e),a=Me.average(n,e),h=new qe({NN:2,MM:2});h.setZero();const m=new qe({NN:2,MM:2});m.setZero();for(let t=0;t<e;++t)h.setRowCol(0,0,h.atRowCol(0,0)+(s[t].x-o.x)*(s[t].x-o.x)),h.setRowCol(0,1,h.atRowCol(0,1)+(s[t].x-o.x)*(s[t].y-o.y)),h.setRowCol(1,1,h.atRowCol(1,1)+(s[t].y-o.y)*(s[t].y-o.y)),m.setRowCol(0,0,m.atRowCol(0,0)+(n[t].x-a.x)*(s[t].x-o.x)),m.setRowCol(0,1,m.atRowCol(0,1)+(n[t].x-a.x)*(s[t].y-o.y)),m.setRowCol(1,0,m.atRowCol(1,0)+(n[t].y-a.y)*(s[t].x-o.x)),m.setRowCol(1,1,m.atRowCol(1,1)+(n[t].y-a.y)*(s[t].y-o.y));h.setRowCol(1,0,h.atRowCol(0,1));const l=new qe({NN:2,MM:2});h.pseudoInverse(l,!0)||(0,i.x)("Failed to compute pseudo inverse"),m.mul(l,m),Re(t,m);const u=o.clone();t.transformInPlace(u),t.xd=a.x-u.x,t.yd=a.y-u.y,r&&(m.pseudoInverse(l,!1)||(0,i.x)("Failed to compute pseudo inverse"),Re(r,l),r.transformInPlace(a),r.xd=o.x-a.x,r.yd=o.y-a.y)}(this,e,s,n,r):function(t,e,s,n,r,o){(0,i.g)(1===t||0===t||2===t||3===t),e.setIdentity();const a=Me.average(n,s),h=Me.average(r,s);if((0,i.g)(t<Ve.length&&t>0),8&Ve[t]){const o=new qe({NN:2,MM:2});o.setZero();for(let t=0;t<s;++t)o.setRowCol(0,0,o.atRowCol(0,0)+(r[t].x-h.x)*(n[t].x-a.x)),o.setRowCol(1,0,o.atRowCol(1,0)+(r[t].x-h.x)*(n[t].y-a.y)),o.setRowCol(0,1,o.atRowCol(0,1)+(r[t].y-h.y)*(n[t].x-a.x)),o.setRowCol(1,1,o.atRowCol(1,1)+(r[t].y-h.y)*(n[t].y-a.y));const m=new qe({NN:2,MM:2}),l=new qe({NN:2,MM:1}),u=new qe({NN:2,MM:2});o.svd(m,l,u)||(0,i.x)("Failed to compute svd");const c=new qe({NN:2,MM:2});m.transpose(c);const g=new qe({NN:2,MM:2});u.mul(c,g),32&Ve[t]||g.determinant()<0&&(c.setRowCol(1,0,-c.atRowCol(1,0)),c.setRowCol(1,1,-c.atRowCol(1,1)),u.mul(c,g));const _=new Fe;Re(_,g),e.set(_)}if(2&Ve[t]){let t=0,i=0;for(let o=0;o<s;++o){const s=n[o].sub(a);t+=s.sqrLength(),e.transformInPlace(s),i+=s.dotProduct(r[o].sub(h))}if(0===t)0===i?e.setIdentity():e.setZero();else{const s=i/t;e.scale(s,s)}}else(0,i.g)(!(4&Ve[t]));const m=a.clone();e.transformInPlace(m),e.xd=h.x-m.x,e.yd=h.y-m.y,o&&(o.set(e),o.invertThis(),o.isZero()&&(o.xd=a.x,o.yd=a.y))}(t,this,e,s,n,r)))}calculateErrors(t,e,s,n){(0,i.g)(t>0&&null!==e&&null!==s);let r=0;for(let i=0;i<t;++i){const t=this.transform(e[i]),o=Me.sqrDistance(s[i],t);r+=o,n&&(n[i]=Math.sqrt(o))}return Math.sqrt(r/t)}}const Ve=[43,11,41,9,61];function Re(t,e){(0,i.g)(!(2!==e.rows()&&3!==e.rows()||2!==e.cols()&&3!==e.rows())),t.xx=e.atRowCol(0,0),t.xy=e.atRowCol(0,1),t.yx=e.atRowCol(1,0),t.yy=e.atRowCol(1,1),3===e.cols()?(t.xd=e.atRowCol(0,2),t.yd=e.atRowCol(1,2)):(t.xd=0,t.yd=0)}}}]);
|